summaryrefslogtreecommitdiffstats
path: root/src/vnet/ethernet
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-03-29 01:28:09 -0700
committerDave Barach <openvpp@barachs.net>2018-04-04 13:40:39 +0000
commit871dc4287d8c05ff76106dba4f5f8654c24347fe (patch)
tree97f6026e284f8cb570855f47512b22a0b58112d1 /src/vnet/ethernet
parent6df19030f2bf986f1876c2c46b44c046b9b2c686 (diff)
Detailed stats collection feature
Use device-input and interface-output feautre arcs to collect unicast, multicast and broadcast states for RX and TX resp. Since these feature arcs are present only for 'physical' interfaces (i.e. not su-interfaces) counter collection is supported only on parent interface types. Change-Id: I915c235e336b0fc3a3c3de918f95dd674e4e0e4e Signed-off-by: Neale Ranns <nranns@cisco.com> Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/ethernet')
-rw-r--r--src/vnet/ethernet/packet.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/vnet/ethernet/packet.h b/src/vnet/ethernet/packet.h
index 09f5e7f3d0b..1a0506dc4d6 100644
--- a/src/vnet/ethernet/packet.h
+++ b/src/vnet/ethernet/packet.h
@@ -40,6 +40,8 @@
#ifndef included_ethernet_packet_h
#define included_ethernet_packet_h
+#include <vnet/interface.h>
+
typedef enum
{
#define ethernet_type(n,s) ETHERNET_TYPE_##s = n,
@@ -67,6 +69,13 @@ ethernet_address_cast (u8 * a)
return (a[0] >> 0) & 1;
}
+always_inline int
+ethernet_address_is_broadcast (u8 * a)
+{
+ return clib_mem_unaligned (a, u32) == 0xffffffff &&
+ clib_mem_unaligned (a + 4, u16) == 0xffff;
+}
+
always_inline uword
ethernet_address_is_locally_administered (u8 * a)
{
@@ -79,6 +88,42 @@ ethernet_address_set_locally_administered (u8 * a)
a[0] |= 1 << 1;
}
+always_inline int
+eh_dst_addr_to_rx_ctype (ethernet_header_t * eh)
+{
+ if (PREDICT_TRUE (ethernet_address_cast (eh->dst_address) ==
+ ETHERNET_ADDRESS_UNICAST))
+ {
+ return VNET_INTERFACE_COUNTER_RX_UNICAST;
+ }
+ else if (ethernet_address_is_broadcast (eh->dst_address))
+ {
+ return VNET_INTERFACE_COUNTER_RX_BROADCAST;
+ }
+ else
+ {
+ return VNET_INTERFACE_COUNTER_RX_MULTICAST;
+ }
+}
+
+always_inline int
+eh_dst_addr_to_tx_ctype (ethernet_header_t * eh)
+{
+ if (PREDICT_TRUE (ethernet_address_cast (eh->dst_address) ==
+ ETHERNET_ADDRESS_UNICAST))
+ {
+ return VNET_INTERFACE_COUNTER_TX_UNICAST;
+ }
+ else if (ethernet_address_is_broadcast (eh->dst_address))
+ {
+ return VNET_INTERFACE_COUNTER_TX_BROADCAST;
+ }
+ else
+ {
+ return VNET_INTERFACE_COUNTER_TX_MULTICAST;
+ }
+}
+
/* For VLAN ethernet type. */
typedef struct
{