net/bonding: LACP Packet statistics support Store the LACP packets sent and received for each slave. This can be used for debug purposes from any DPDK application.
Signed-Off-By: Kiran K N <kira...@juniper.net> Change-Id: Iae82bd7d0879a4c4333a292c96d431798c56e301 --- drivers/net/bonding/eth_bond_8023ad_private.h | 2 ++ drivers/net/bonding/rte_eth_bond_8023ad.c | 39 +++++++++++++++++++++++++++ drivers/net/bonding/rte_eth_bond_8023ad.h | 20 ++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/drivers/net/bonding/eth_bond_8023ad_private.h b/drivers/net/bonding/eth_bond_8023ad_private.h index ef0b56850..500640b28 100644 --- a/drivers/net/bonding/eth_bond_8023ad_private.h +++ b/drivers/net/bonding/eth_bond_8023ad_private.h @@ -19,6 +19,8 @@ #define BOND_MODE_8023AX_SLAVE_RX_PKTS 3 /** Maximum number of LACP packets from one slave queued in TX ring. */ #define BOND_MODE_8023AX_SLAVE_TX_PKTS 1 +/** maximum number of slaves for each port */ +#define BOND_MODE_8023AD_MAX_SLAVES 6 /** * Timeouts deffinitions (5.4.4 in 802.1AX documentation). */ diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index ea79a1344..37eb29847 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -132,6 +132,9 @@ static const struct rte_ether_addr lacp_mac_addr = { struct port bond_mode_8023ad_ports[RTE_MAX_ETHPORTS]; +static uint64_t lacpdu_tx_count[BOND_MODE_8023AD_MAX_SLAVES]; +static uint64_t lacpdu_rx_count[BOND_MODE_8023AD_MAX_SLAVES]; + static void timer_cancel(uint64_t *timer) { @@ -629,6 +632,7 @@ tx_machine(struct bond_dev_private *internals, uint16_t slave_id) set_warning_flags(port, WRN_TX_QUEUE_FULL); return; } +lacpdu_tx_count[slave_id]++; } else { uint16_t pkts_sent = rte_eth_tx_burst(slave_id, internals->mode4.dedicated_queues.tx_qid, @@ -638,6 +642,7 @@ tx_machine(struct bond_dev_private *internals, uint16_t slave_id) set_warning_flags(port, WRN_TX_QUEUE_FULL); return; } +lacpdu_tx_count[slave_id] += pkts_sent; } @@ -896,6 +901,10 @@ bond_mode_8023ad_periodic_cb(void *arg) lacp_pkt = NULL; rx_machine_update(internals, slave_id, lacp_pkt); + +if (retval == 0) { + lacpdu_rx_count[slave_id]++; + } } else { uint16_t rx_count = rte_eth_rx_burst(slave_id, internals->mode4.dedicated_queues.rx_qid, @@ -906,6 +915,8 @@ bond_mode_8023ad_periodic_cb(void *arg) slave_id, lacp_pkt); else rx_machine_update(internals, slave_id, NULL); + +lacpdu_rx_count[slave_id] += rx_count; } periodic_machine(internals, slave_id); @@ -1715,3 +1726,31 @@ rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port) return retval; } + +uint64_t +rte_eth_bond_8023ad_lacp_tx_count(uint16_t port_id, uint8_t clear) +{ +if(port_id > BOND_MODE_8023AD_MAX_SLAVES) +return -1; + +if(clear) { +lacpdu_tx_count[port_id] = 0; +return 0; +} + + return lacpdu_tx_count[port_id]; +} + +uint64_t +rte_eth_bond_8023ad_lacp_rx_count(uint16_t port_id, uint8_t clear) +{ +if(port_id > BOND_MODE_8023AD_MAX_SLAVES) +return -1; + +if(clear) { +lacpdu_rx_count[port_id] = 0; +return 0; +} + +return lacpdu_rx_count[port_id]; +} diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.h b/drivers/net/bonding/rte_eth_bond_8023ad.h index 5623e1424..7163de381 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.h +++ b/drivers/net/bonding/rte_eth_bond_8023ad.h @@ -340,4 +340,24 @@ rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id, */ int rte_eth_bond_8023ad_ext_set_fast(uint16_t port_id, uint16_t slave_id); + +/** + * Get Lacp statistics counter for slaves + * @param port_id Bonding slave device id + * @param clear, reset statistics + * @return + * 0 on success, negative value otherwise + */ +uint64_t +rte_eth_bond_8023ad_lacp_tx_count(uint16_t port_id, uint8_t clear); + +/** + * Get Lacp statistics counter for slaves + * @param port_id Bonding slave device id + * @param clear, reset statistics + * @return + * 0 on success, negative value otherwise + */ +uint64_t +rte_eth_bond_8023ad_lacp_rx_count(uint16_t port_id, uint8_t clear); #endif /* RTE_ETH_BOND_8023AD_H_ */ -- 2.16.6 Juniper Business Use Only