Thank you very much! After reading this email, I understand the calling event 
api process. But in the step 3, i do not know call which function and how to 
call? In the test/ext/vapi_c_test.c, i can not find the function proto which in 
using. Can you write a simple client which get stat event by C ? Thank you very 
much!




------------------ ???????? ------------------
??????: "Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at 
Cisco)";<ksek...@cisco.com>;
????????: 2017??9??27??(??????) ????3:15
??????: "????????"<15803846...@qq.com>;"Keith Burns"<alaga...@gmail.com>;
????: "vpp-dev"<vpp-dev@lists.fd.io>; 
????: Re: [vpp-dev] ?????? ??????  How to get interface stats using C api?



There are new C and C++ APIs added recently to vpp source code along
with test programs. You can take a look at test/ext/vapi_c_test.c and
vapi_cpp_test.cpp. Functions receiving stats are named test_stats_XXX().
These are there to verify that receiving events works. Functionally,
these are the same, they just test different ways of doing stuff.

At shared memory level it looks like this:

1.) client -> want_stats -> vpp
2.) vpp -> want_stats_reply -> client (confirms subscription)
3.) vpp -> <various stats messages> -> client (when timer fires)

in step 3.), client needs to read the shared memory queue in the
vpp->client direction (or use the appropriate XXX_read() function). Note
that stats take a few seconds to arrive (the test programs require
10-15 seconds of runtime to get some stats).

HTH,
Klement

Quoting ???????? (2017-09-27 04:55:29)
>    That is ok??
>     Now I am research calling the plugin apis by C. Especially how to call
>    the event apis. I would appreciate it if you can write a brief client.
>    ------------------ ???????? ------------------
>    ??????: "Keith Burns";<alaga...@gmail.com>;
>    ????????: 2017??9??27??(??????) ????10:47
>    ??????: "????????"<15803846...@qq.com>;
>    ????: "vpp-dev"<vpp-dev@lists.fd.io>;
>    ????: Re: ?????? [vpp-dev] How to get interface stats using C api?
>    Apologies,
>    It's a callback.
>    We probably need some decent literature written for how to consume the
>    various C, C++, Python and Lua APIs
>    If you have a preference for any of those languages I could write a brief
>    client program for you and start work on documenting this stuff.
>    On Sep 26, 2017 6:04 PM, "????????" <[1]15803846...@qq.com> wrote:
> 
>      Hi??
>        Thank you for your detail information. After reading this, i can
>      understand. But after calling  "want_per_interface_simple_stats" with
>      enable_disable=1, num=1 and sw_ifs[4], i do not know how to receive this
>      stats. calling other function or variable? Can you tell me how to
>      receive stats in my c program?
>         Thanks??
>      ------------------ ???????? ------------------
>      ??????: "Keith Burns";<[2]alaga...@gmail.com>;
>      ????????: 2017??9??27??(??????) ????6:39
>      ??????: "??????
>      ??"<[3]15803846...@qq.com>;"vpp-dev"<[4]vpp-dev@lists.fd.io>;
>      ????: Re: [vpp-dev] How to get interface stats using C api?
>      Hi there,
>      As of 17.10 you can now register for statistics on a per interface
>      level.
>      You need the sw_if_index of the interface you want stats for, but the
>      calls are in
>      [5]https://git.fd.io/vpp/tree/src/vpp/stats/stats.api
>      but as an example:
>      Register:
> 
>  autoreply define want_per_interface_simple_stats
>  {
>    u32 client_index;
>    u32 context;
>    u32 enable_disable;
>    u32 pid;
>    u32 num;
>    u32 sw_ifs[num];
> 
>  };
> 
>  So calling "want_per_interface_simple_stats" with enable_disable=1, num=1 
> and sw_ifs[4] will give you
> 
>  interface_simple_stats every 10sec for sw_if_index=4.
> 
>  The content of "interface_simple_stats" looks like:
> 
>  /** \brief Simple per interface stats counters structure
>      @param count - number of elements in message
>      @param timestamp - u32 vlib timestamp for control plane
>      @param data[count] - vl_api_vnet_simple_counter_t
> 
>  */
>  manual_print manual_endian define vnet_per_interface_simple_counters
>  {
>    u32 count;
>    u32 timestamp;
>    vl_api_vnet_simple_counter_t data[count];
>  };
> 
>  Where each "vnet_simple_counter_t" looks like:
> 
>  [6]https://git.fd.io/vpp/tree/src/vnet/interface.api
> 
>  /** \brief Simple interface counter data type for 
> vnet_interface_simple_counters
>      @param sw_if_index - interface indexes for counters
>      @param drop - RX or TX drops due to buffer starvation
>      @param punt - used with VNET "punt" disposition
>      @param rx_ip4 - received IP4 packets
>      @param rx_ip6 - received IP6 packets
>      @param rx_no_buffer - no RX buffers available
>      @param rx_miss - receive misses
>      @param rx_error - receive errors
>      @param tx_error - transmit errors
>      @param rx_mpls - received MPLS packet
> 
>  */
>  typeonly manual_print manual_endian define vnet_simple_counter
>  {
>    u32 sw_if_index;
>    u64 drop;
>    u64 punt;
>    u64 rx_ip4;
>    u64 rx_ip6;
>    u64 rx_no_buffer;
>    u64 rx_miss;
>    u64 rx_error;
>    u64 tx_error;
>    u64 rx_mpls;
>  };
> 
>  So you will get back an array of counter structs for each sw_if_index you 
> registered for.
> 
>  At the moment the impl sends on sw_if_index per reply but that is going to 
> change so that for each client we send as much in one message as possible.
> 
>      On Tue, Sep 26, 2017 at 4:50 AM ???????? <[7]15803846...@qq.com> wrote:
> 
>  Hi,  everyone!
>  How to get interface stats using C api?
>  For example, I want to know "GigabitEthernete/0/1" rx packets , what should 
> I do?
> 
>  Thanks
> 
>        _______________________________________________
>        vpp-dev mailing list
>        [8]vpp-dev@lists.fd.io
>        [9]https://lists.fd.io/mailman/listinfo/vpp-dev
> 
> References
> 
>    Visible links
>    1. mailto:15803846...@qq.com
>    2. mailto:alaga...@gmail.com
>    3. mailto:15803846...@qq.com
>    4. mailto:vpp-dev@lists.fd.io
>    5. https://git.fd.io/vpp/tree/src/vpp/stats/stats.api
>    6. https://git.fd.io/vpp/tree/src/vnet/interface.api
>    7. mailto:15803846...@qq.com
>    8. mailto:vpp-dev@lists.fd.io
>    9. https://lists.fd.io/mailman/listinfo/vpp-dev
_______________________________________________
vpp-dev mailing list
vpp-dev@lists.fd.io
https://lists.fd.io/mailman/listinfo/vpp-dev
  • [vpp-dev] How... ????????
    • Re: [vpp... Keith Burns
      • [vpp... ????????
        • ... Keith Burns
          • ... ????????
            • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
              • ... ????????
                • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
                • ... ????????
                • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
          • ... Jon Loeliger

Reply via email to