[vpp-dev] ?????? ?????? ?????? ?????? How to get interface stats using C api?

2017-09-28 Thread ????????
Sorry, I do not know how to write a client. There is no documents which i can 
referece. I just know the steps which a client should have. But I do not know 
which functions to use. I would appricate it if you can write a draf client. I 
am studying 
  Yes, for study, I add some event apis int snat.


--  --
??: "Klement Sekera -X (ksekera - PA";<ksek...@cisco.com>;
: 2017??9??28??(??) 4:02
??: ""<15803846...@qq.com>;
: "vpp-dev"<vpp-dev@lists.fd.io>; "Keith Burns"<alaga...@gmail.com>; 
: Re: ?????? [vpp-dev] ?? ??  How to get interface stats using C 
api?



Looking at your code it seems you're not waiting for the reply at all. I
don't have experience with VAT and I don't think this is the recommended
way to write a client. Nevertheless, looking at your code, I don't see
any attempt to wait for a response. You are sending a message to VPP,
but not waiting for the reply nor the event.

Also I see that you are referencing VL_API_SNAT_DECRYPT_EVENT but I
don't see such event anywhere. Is this something which you added, but is
not committed yet?

Quoting  (2017-09-28 03:23:30)
>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 ->  -> 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
>>  ??: "??

[vpp-dev] ?????? ?????? ?????? How to get interface stats using C api?

2017-09-27 Thread ????????
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 ->  -> 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 s

[vpp-dev] ?????? ?????? How to get interface stats using C api?

2017-09-26 Thread ????????
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, "" <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";<alaga...@gmail.com>;
: 2017??9??27??(??) ????6:39
??????: ""<15803846...@qq.com>;"vpp-dev"<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 
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:
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  <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
 vpp-dev@lists.fd.io
 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 to get interface stats using C api?

2017-09-26 Thread ????????
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?  By 
the way, i use vpp 17.04. is it same?
   Thanks??




--  --
??: "Keith Burns";<alaga...@gmail.com>;
: 2017??9??27??(??) 6:39
??: ""<15803846...@qq.com>;"vpp-dev"<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 
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:
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  <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
 vpp-dev@lists.fd.io
 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 to get interface stats using C api?

2017-09-26 Thread ????????
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";<alaga...@gmail.com>;
: 2017??9??27??(??) 6:39
??: ""<15803846...@qq.com>;"vpp-dev"<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 
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:
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  <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
 vpp-dev@lists.fd.io
 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

Re: [vpp-dev] How to get interface stats using C api?

2017-09-26 Thread Keith Burns
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
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:


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 重新开始 <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
> vpp-dev@lists.fd.io
> 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 to get interface stats using C api?

2017-09-26 Thread ????????
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
vpp-dev@lists.fd.io
https://lists.fd.io/mailman/listinfo/vpp-dev