[dpdk-dev] [PATCH v3 09/11] i40e: add xstats() implementation

2015-10-23 Thread Tahhan, Maryam
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Harry van Haaren
> Sent: Thursday, October 22, 2015 4:49 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v3 09/11] i40e: add xstats() implementation
> 
> Add xstats functions to i40e PMD, allowing extended statistics to be retrieved
> from the NIC and exposed to the DPDK.
> 
> Signed-off-by: Harry van Haaren 

Acked-by: Maryam Tahhan 


[dpdk-dev] [PATCH v3 09/11] i40e: add xstats() implementation

2015-10-22 Thread Harry van Haaren
Add xstats functions to i40e PMD, allowing extended statistics
to be retrieved from the NIC and exposed to the DPDK.

Signed-off-by: Harry van Haaren 
---
 drivers/net/i40e/i40e_ethdev.c | 265 +++--
 1 file changed, 258 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..cf0199d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -127,7 +127,10 @@ static int i40e_dev_set_link_up(struct rte_eth_dev *dev);
 static int i40e_dev_set_link_down(struct rte_eth_dev *dev);
 static void i40e_dev_stats_get(struct rte_eth_dev *dev,
   struct rte_eth_stats *stats);
+static int i40e_dev_xstats_get(struct rte_eth_dev *dev,
+  struct rte_eth_xstats *xstats, unsigned n);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
+static void i40e_dev_xstats_reset(struct rte_eth_dev *dev);
 static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
uint16_t queue_id,
uint8_t stat_idx,
@@ -232,6 +235,8 @@ static int i40e_timesync_read_rx_timestamp(struct 
rte_eth_dev *dev,
   uint32_t flags);
 static int i40e_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
   struct timespec *timestamp);
+static void i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw);
+

 static const struct rte_pci_id pci_id_i40e_map[] = {
 #define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
@@ -252,7 +257,9 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.dev_set_link_down= i40e_dev_set_link_down,
.link_update  = i40e_dev_link_update,
.stats_get= i40e_dev_stats_get,
+   .xstats_get   = i40e_dev_xstats_get,
.stats_reset  = i40e_dev_stats_reset,
+   .xstats_reset = i40e_dev_xstats_reset,
.queue_stats_mapping_set  = i40e_dev_queue_stats_mapping_set,
.dev_infos_get= i40e_dev_info_get,
.vlan_filter_set  = i40e_vlan_filter_set,
@@ -291,6 +298,187 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.timesync_read_tx_timestamp   = i40e_timesync_read_tx_timestamp,
 };

+/* store statistics names and its offset in stats structure */
+struct rte_i40e_xstats_name_off {
+   char name[RTE_ETH_XSTATS_NAME_SIZE];
+   unsigned offset;
+};
+
+static const struct rte_i40e_xstats_name_off rte_i40e_stats_strings[] = {
+   {"rx_unicast_packets", offsetof(struct i40e_eth_stats, rx_unicast)},
+   {"rx_multicast_packets", offsetof(struct i40e_eth_stats, rx_multicast)},
+   {"rx_broadcast_packets", offsetof(struct i40e_eth_stats, rx_broadcast)},
+   {"rx_dropped", offsetof(struct i40e_eth_stats, rx_discards)},
+   {"rx_unknown_protocol_packets", offsetof(struct i40e_eth_stats,
+   rx_unknown_protocol)},
+   {"tx_unicast_packets", offsetof(struct i40e_eth_stats, tx_unicast)},
+   {"tx_multicast_packets", offsetof(struct i40e_eth_stats, tx_multicast)},
+   {"tx_broadcast_packets", offsetof(struct i40e_eth_stats, tx_broadcast)},
+   {"tx_dropped", offsetof(struct i40e_eth_stats, tx_discards)},
+};
+
+static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
+   {"tx_link_down_dropped", offsetof(struct i40e_hw_port_stats,
+   tx_dropped_link_down)},
+   {"rx_crc_errors", offsetof(struct i40e_hw_port_stats, crc_errors)},
+   {"rx_illegal_bytes", offsetof(struct i40e_hw_port_stats,
+   illegal_bytes)},
+   {"rx_error_bytes", offsetof(struct i40e_hw_port_stats, error_bytes)},
+   {"mac_local_errors", offsetof(struct i40e_hw_port_stats,
+   mac_local_faults)},
+   {"mac_remote_errors", offsetof(struct i40e_hw_port_stats,
+   mac_remote_faults)},
+   {"rx_length_errors", offsetof(struct i40e_hw_port_stats,
+   rx_length_errors)},
+   {"tx_xon_packets", offsetof(struct i40e_hw_port_stats, link_xon_tx)},
+   {"rx_xon_packets", offsetof(struct i40e_hw_port_stats, link_xon_rx)},
+   {"tx_xoff_packets", offsetof(struct i40e_hw_port_stats, link_xoff_tx)},
+   {"rx_xoff_packets", offsetof(struct i40e_hw_port_stats, link_xoff_rx)},
+   {"rx_size_64_packets", offsetof(struct i40e_hw_port_stats, rx_size_64)},
+   {"rx_size_65_to_127_packets", offsetof(struct i40e_hw_port_stats,
+   rx_size_127)},
+   {"rx_size_128_to_255_packets", offsetof(struct i40e_hw_port_stats,
+   rx_size_255)},
+   {"rx_size_256_to_511_packets", offsetof(struct i40e_hw_port_stats,
+   rx_size_511)},
+   {"rx_size_512_to_1023_packets", offsetof(struct i40e_hw_port_stats,
+