Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ionic: add more ethtool stats

Add hardware port stats and a few more driver collected
statistics to the ethtool stats output.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Shannon Nelson and committed by
David S. Miller
f64e0c56 c06107ca

+170 -13
+2 -2
drivers/net/ethernet/pensando/ionic/ionic_lif.c
··· 792 792 return max(n_work, a_work); 793 793 } 794 794 795 - static void ionic_get_stats64(struct net_device *netdev, 796 - struct rtnl_link_stats64 *ns) 795 + void ionic_get_stats64(struct net_device *netdev, 796 + struct rtnl_link_stats64 *ns) 797 797 { 798 798 struct ionic_lif *lif = netdev_priv(netdev); 799 799 struct ionic_lif_stats *ls;
+13 -2
drivers/net/ethernet/pensando/ionic/ionic_lif.h
··· 20 20 u64 bytes; 21 21 u64 clean; 22 22 u64 linearize; 23 - u64 no_csum; 23 + u64 csum_none; 24 24 u64 csum; 25 25 u64 crc32_csum; 26 26 u64 tso; 27 + u64 tso_bytes; 27 28 u64 frags; 29 + u64 vlan_inserted; 28 30 u64 sg_cntr[IONIC_MAX_NUM_SG_CNTR]; 29 31 }; 30 32 ··· 40 38 u64 csum_error; 41 39 u64 buffers_posted; 42 40 u64 dropped; 41 + u64 vlan_stripped; 43 42 }; 44 43 45 44 #define IONIC_QCQ_F_INITED BIT(0) ··· 117 114 u64 rx_packets; 118 115 u64 rx_bytes; 119 116 u64 tx_tso; 120 - u64 tx_no_csum; 117 + u64 tx_tso_bytes; 118 + u64 tx_csum_none; 121 119 u64 tx_csum; 122 120 u64 rx_csum_none; 123 121 u64 rx_csum_complete; 124 122 u64 rx_csum_error; 123 + u64 hw_tx_dropped; 124 + u64 hw_rx_dropped; 125 + u64 hw_rx_over_errors; 126 + u64 hw_rx_missed_errors; 127 + u64 hw_tx_aborted_errors; 125 128 }; 126 129 127 130 enum ionic_lif_state_flags { ··· 249 240 } 250 241 251 242 void ionic_link_status_check_request(struct ionic_lif *lif); 243 + void ionic_get_stats64(struct net_device *netdev, 244 + struct rtnl_link_stats64 *ns); 252 245 void ionic_lif_deferred_enqueue(struct ionic_deferred *def, 253 246 struct ionic_deferred_work *work); 254 247 int ionic_lifs_alloc(struct ionic *ionic);
+134 -2
drivers/net/ethernet/pensando/ionic/ionic_stats.c
··· 15 15 IONIC_LIF_STAT_DESC(rx_packets), 16 16 IONIC_LIF_STAT_DESC(rx_bytes), 17 17 IONIC_LIF_STAT_DESC(tx_tso), 18 - IONIC_LIF_STAT_DESC(tx_no_csum), 18 + IONIC_LIF_STAT_DESC(tx_tso_bytes), 19 + IONIC_LIF_STAT_DESC(tx_csum_none), 19 20 IONIC_LIF_STAT_DESC(tx_csum), 20 21 IONIC_LIF_STAT_DESC(rx_csum_none), 21 22 IONIC_LIF_STAT_DESC(rx_csum_complete), 22 23 IONIC_LIF_STAT_DESC(rx_csum_error), 24 + IONIC_LIF_STAT_DESC(hw_tx_dropped), 25 + IONIC_LIF_STAT_DESC(hw_rx_dropped), 26 + IONIC_LIF_STAT_DESC(hw_rx_over_errors), 27 + IONIC_LIF_STAT_DESC(hw_rx_missed_errors), 28 + IONIC_LIF_STAT_DESC(hw_tx_aborted_errors), 29 + }; 30 + 31 + static const struct ionic_stat_desc ionic_port_stats_desc[] = { 32 + IONIC_PORT_STAT_DESC(frames_rx_ok), 33 + IONIC_PORT_STAT_DESC(frames_rx_all), 34 + IONIC_PORT_STAT_DESC(frames_rx_bad_fcs), 35 + IONIC_PORT_STAT_DESC(frames_rx_bad_all), 36 + IONIC_PORT_STAT_DESC(octets_rx_ok), 37 + IONIC_PORT_STAT_DESC(octets_rx_all), 38 + IONIC_PORT_STAT_DESC(frames_rx_unicast), 39 + IONIC_PORT_STAT_DESC(frames_rx_multicast), 40 + IONIC_PORT_STAT_DESC(frames_rx_broadcast), 41 + IONIC_PORT_STAT_DESC(frames_rx_pause), 42 + IONIC_PORT_STAT_DESC(frames_rx_bad_length), 43 + IONIC_PORT_STAT_DESC(frames_rx_undersized), 44 + IONIC_PORT_STAT_DESC(frames_rx_oversized), 45 + IONIC_PORT_STAT_DESC(frames_rx_fragments), 46 + IONIC_PORT_STAT_DESC(frames_rx_jabber), 47 + IONIC_PORT_STAT_DESC(frames_rx_pripause), 48 + IONIC_PORT_STAT_DESC(frames_rx_stomped_crc), 49 + IONIC_PORT_STAT_DESC(frames_rx_too_long), 50 + IONIC_PORT_STAT_DESC(frames_rx_vlan_good), 51 + IONIC_PORT_STAT_DESC(frames_rx_dropped), 52 + IONIC_PORT_STAT_DESC(frames_rx_less_than_64b), 53 + IONIC_PORT_STAT_DESC(frames_rx_64b), 54 + IONIC_PORT_STAT_DESC(frames_rx_65b_127b), 55 + IONIC_PORT_STAT_DESC(frames_rx_128b_255b), 56 + IONIC_PORT_STAT_DESC(frames_rx_256b_511b), 57 + IONIC_PORT_STAT_DESC(frames_rx_512b_1023b), 58 + IONIC_PORT_STAT_DESC(frames_rx_1024b_1518b), 59 + IONIC_PORT_STAT_DESC(frames_rx_1519b_2047b), 60 + IONIC_PORT_STAT_DESC(frames_rx_2048b_4095b), 61 + IONIC_PORT_STAT_DESC(frames_rx_4096b_8191b), 62 + IONIC_PORT_STAT_DESC(frames_rx_8192b_9215b), 63 + IONIC_PORT_STAT_DESC(frames_rx_other), 64 + IONIC_PORT_STAT_DESC(frames_tx_ok), 65 + IONIC_PORT_STAT_DESC(frames_tx_all), 66 + IONIC_PORT_STAT_DESC(frames_tx_bad), 67 + IONIC_PORT_STAT_DESC(octets_tx_ok), 68 + IONIC_PORT_STAT_DESC(octets_tx_total), 69 + IONIC_PORT_STAT_DESC(frames_tx_unicast), 70 + IONIC_PORT_STAT_DESC(frames_tx_multicast), 71 + IONIC_PORT_STAT_DESC(frames_tx_broadcast), 72 + IONIC_PORT_STAT_DESC(frames_tx_pause), 73 + IONIC_PORT_STAT_DESC(frames_tx_pripause), 74 + IONIC_PORT_STAT_DESC(frames_tx_vlan), 75 + IONIC_PORT_STAT_DESC(frames_tx_less_than_64b), 76 + IONIC_PORT_STAT_DESC(frames_tx_64b), 77 + IONIC_PORT_STAT_DESC(frames_tx_65b_127b), 78 + IONIC_PORT_STAT_DESC(frames_tx_128b_255b), 79 + IONIC_PORT_STAT_DESC(frames_tx_256b_511b), 80 + IONIC_PORT_STAT_DESC(frames_tx_512b_1023b), 81 + IONIC_PORT_STAT_DESC(frames_tx_1024b_1518b), 82 + IONIC_PORT_STAT_DESC(frames_tx_1519b_2047b), 83 + IONIC_PORT_STAT_DESC(frames_tx_2048b_4095b), 84 + IONIC_PORT_STAT_DESC(frames_tx_4096b_8191b), 85 + IONIC_PORT_STAT_DESC(frames_tx_8192b_9215b), 86 + IONIC_PORT_STAT_DESC(frames_tx_other), 87 + IONIC_PORT_STAT_DESC(frames_tx_pri_0), 88 + IONIC_PORT_STAT_DESC(frames_tx_pri_1), 89 + IONIC_PORT_STAT_DESC(frames_tx_pri_2), 90 + IONIC_PORT_STAT_DESC(frames_tx_pri_3), 91 + IONIC_PORT_STAT_DESC(frames_tx_pri_4), 92 + IONIC_PORT_STAT_DESC(frames_tx_pri_5), 93 + IONIC_PORT_STAT_DESC(frames_tx_pri_6), 94 + IONIC_PORT_STAT_DESC(frames_tx_pri_7), 95 + IONIC_PORT_STAT_DESC(frames_rx_pri_0), 96 + IONIC_PORT_STAT_DESC(frames_rx_pri_1), 97 + IONIC_PORT_STAT_DESC(frames_rx_pri_2), 98 + IONIC_PORT_STAT_DESC(frames_rx_pri_3), 99 + IONIC_PORT_STAT_DESC(frames_rx_pri_4), 100 + IONIC_PORT_STAT_DESC(frames_rx_pri_5), 101 + IONIC_PORT_STAT_DESC(frames_rx_pri_6), 102 + IONIC_PORT_STAT_DESC(frames_rx_pri_7), 103 + IONIC_PORT_STAT_DESC(tx_pripause_0_1us_count), 104 + IONIC_PORT_STAT_DESC(tx_pripause_1_1us_count), 105 + IONIC_PORT_STAT_DESC(tx_pripause_2_1us_count), 106 + IONIC_PORT_STAT_DESC(tx_pripause_3_1us_count), 107 + IONIC_PORT_STAT_DESC(tx_pripause_4_1us_count), 108 + IONIC_PORT_STAT_DESC(tx_pripause_5_1us_count), 109 + IONIC_PORT_STAT_DESC(tx_pripause_6_1us_count), 110 + IONIC_PORT_STAT_DESC(tx_pripause_7_1us_count), 111 + IONIC_PORT_STAT_DESC(rx_pripause_0_1us_count), 112 + IONIC_PORT_STAT_DESC(rx_pripause_1_1us_count), 113 + IONIC_PORT_STAT_DESC(rx_pripause_2_1us_count), 114 + IONIC_PORT_STAT_DESC(rx_pripause_3_1us_count), 115 + IONIC_PORT_STAT_DESC(rx_pripause_4_1us_count), 116 + IONIC_PORT_STAT_DESC(rx_pripause_5_1us_count), 117 + IONIC_PORT_STAT_DESC(rx_pripause_6_1us_count), 118 + IONIC_PORT_STAT_DESC(rx_pripause_7_1us_count), 119 + IONIC_PORT_STAT_DESC(rx_pause_1us_count), 120 + IONIC_PORT_STAT_DESC(frames_tx_truncated), 23 121 }; 24 122 25 123 static const struct ionic_stat_desc ionic_tx_stats_desc[] = { ··· 127 29 IONIC_TX_STAT_DESC(dma_map_err), 128 30 IONIC_TX_STAT_DESC(linearize), 129 31 IONIC_TX_STAT_DESC(frags), 32 + IONIC_TX_STAT_DESC(tso), 33 + IONIC_TX_STAT_DESC(tso_bytes), 34 + IONIC_TX_STAT_DESC(csum_none), 35 + IONIC_TX_STAT_DESC(csum), 36 + IONIC_TX_STAT_DESC(vlan_inserted), 130 37 }; 131 38 132 39 static const struct ionic_stat_desc ionic_rx_stats_desc[] = { ··· 143 40 IONIC_RX_STAT_DESC(csum_complete), 144 41 IONIC_RX_STAT_DESC(csum_error), 145 42 IONIC_RX_STAT_DESC(dropped), 43 + IONIC_RX_STAT_DESC(vlan_stripped), 146 44 }; 147 45 148 46 static const struct ionic_stat_desc ionic_txq_stats_desc[] = { ··· 166 62 }; 167 63 168 64 #define IONIC_NUM_LIF_STATS ARRAY_SIZE(ionic_lif_stats_desc) 65 + #define IONIC_NUM_PORT_STATS ARRAY_SIZE(ionic_port_stats_desc) 169 66 #define IONIC_NUM_TX_STATS ARRAY_SIZE(ionic_tx_stats_desc) 170 67 #define IONIC_NUM_RX_STATS ARRAY_SIZE(ionic_rx_stats_desc) 171 68 #define IONIC_NUM_TX_Q_STATS ARRAY_SIZE(ionic_txq_stats_desc) ··· 181 76 { 182 77 struct ionic_tx_stats *tstats; 183 78 struct ionic_rx_stats *rstats; 79 + struct rtnl_link_stats64 ns; 184 80 struct ionic_qcq *txqcq; 185 81 struct ionic_qcq *rxqcq; 186 82 int q_num; ··· 195 89 stats->tx_packets += tstats->pkts; 196 90 stats->tx_bytes += tstats->bytes; 197 91 stats->tx_tso += tstats->tso; 198 - stats->tx_no_csum += tstats->no_csum; 92 + stats->tx_tso_bytes += tstats->tso_bytes; 93 + stats->tx_csum_none += tstats->csum_none; 199 94 stats->tx_csum += tstats->csum; 200 95 } 201 96 ··· 210 103 stats->rx_csum_error += rstats->csum_error; 211 104 } 212 105 } 106 + 107 + ionic_get_stats64(lif->netdev, &ns); 108 + stats->hw_tx_dropped = ns.tx_dropped; 109 + stats->hw_rx_dropped = ns.rx_dropped; 110 + stats->hw_rx_over_errors = ns.rx_over_errors; 111 + stats->hw_rx_missed_errors = ns.rx_missed_errors; 112 + stats->hw_tx_aborted_errors = ns.tx_aborted_errors; 213 113 } 214 114 215 115 static u64 ionic_sw_stats_get_count(struct ionic_lif *lif) ··· 231 117 232 118 /* rx stats */ 233 119 total += MAX_Q(lif) * IONIC_NUM_RX_STATS; 120 + 121 + /* port stats */ 122 + total += IONIC_NUM_PORT_STATS; 234 123 235 124 if (test_bit(IONIC_LIF_F_UP, lif->state) && 236 125 test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) { ··· 261 144 snprintf(*buf, ETH_GSTRING_LEN, ionic_lif_stats_desc[i].name); 262 145 *buf += ETH_GSTRING_LEN; 263 146 } 147 + 148 + for (i = 0; i < IONIC_NUM_PORT_STATS; i++) { 149 + snprintf(*buf, ETH_GSTRING_LEN, 150 + ionic_port_stats_desc[i].name); 151 + *buf += ETH_GSTRING_LEN; 152 + } 153 + 264 154 for (q_num = 0; q_num < MAX_Q(lif); q_num++) { 265 155 for (i = 0; i < IONIC_NUM_TX_STATS; i++) { 266 156 snprintf(*buf, ETH_GSTRING_LEN, "tx_%d_%s", ··· 349 225 350 226 static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf) 351 227 { 228 + struct ionic_port_stats *port_stats; 352 229 struct ionic_lif_sw_stats lif_stats; 353 230 struct ionic_qcq *txqcq, *rxqcq; 354 231 struct ionic_tx_stats *txstats; ··· 360 235 361 236 for (i = 0; i < IONIC_NUM_LIF_STATS; i++) { 362 237 **buf = IONIC_READ_STAT64(&lif_stats, &ionic_lif_stats_desc[i]); 238 + (*buf)++; 239 + } 240 + 241 + port_stats = &lif->ionic->idev.port_info->stats; 242 + for (i = 0; i < IONIC_NUM_PORT_STATS; i++) { 243 + **buf = IONIC_READ_STAT_LE64(port_stats, 244 + &ionic_port_stats_desc[i]); 363 245 (*buf)++; 364 246 } 365 247
+6
drivers/net/ethernet/pensando/ionic/ionic_stats.h
··· 11 11 .offset = IONIC_STAT_TO_OFFSET(type, stat_name) \ 12 12 } 13 13 14 + #define IONIC_PORT_STAT_DESC(stat_name) \ 15 + IONIC_STAT_DESC(struct ionic_port_stats, stat_name) 16 + 14 17 #define IONIC_LIF_STAT_DESC(stat_name) \ 15 18 IONIC_STAT_DESC(struct ionic_lif_sw_stats, stat_name) 16 19 ··· 47 44 48 45 #define IONIC_READ_STAT64(base_ptr, desc_ptr) \ 49 46 (*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset))) 47 + 48 + #define IONIC_READ_STAT_LE64(base_ptr, desc_ptr) \ 49 + __le64_to_cpu(*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset))) 50 50 51 51 struct ionic_stat_desc { 52 52 char name[ETH_GSTRING_LEN];
+15 -7
drivers/net/ethernet/pensando/ionic/ionic_txrx.c
··· 214 214 (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_IP_BAD))) 215 215 stats->csum_error++; 216 216 217 - if (likely(netdev->features & NETIF_F_HW_VLAN_CTAG_RX)) { 218 - if (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_VLAN) 219 - __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), 220 - le16_to_cpu(comp->vlan_tci)); 217 + if (likely(netdev->features & NETIF_F_HW_VLAN_CTAG_RX) && 218 + (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_VLAN)) { 219 + __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), 220 + le16_to_cpu(comp->vlan_tci)); 221 + stats->vlan_stripped++; 221 222 } 222 223 223 224 if (le16_to_cpu(comp->len) <= q->lif->rx_copybreak) ··· 861 860 stats->pkts += total_pkts; 862 861 stats->bytes += total_bytes; 863 862 stats->tso++; 863 + stats->tso_bytes += total_bytes; 864 864 865 865 return 0; 866 866 ··· 900 898 flags, skb_shinfo(skb)->nr_frags, dma_addr); 901 899 desc->cmd = cpu_to_le64(cmd); 902 900 desc->len = cpu_to_le16(skb_headlen(skb)); 903 - desc->vlan_tci = cpu_to_le16(skb_vlan_tag_get(skb)); 904 901 desc->csum_start = cpu_to_le16(skb_checksum_start_offset(skb)); 905 902 desc->csum_offset = cpu_to_le16(skb->csum_offset); 903 + if (has_vlan) { 904 + desc->vlan_tci = cpu_to_le16(skb_vlan_tag_get(skb)); 905 + stats->vlan_inserted++; 906 + } 906 907 907 908 if (skb->csum_not_inet) 908 909 stats->crc32_csum++; ··· 940 935 flags, skb_shinfo(skb)->nr_frags, dma_addr); 941 936 desc->cmd = cpu_to_le64(cmd); 942 937 desc->len = cpu_to_le16(skb_headlen(skb)); 943 - desc->vlan_tci = cpu_to_le16(skb_vlan_tag_get(skb)); 938 + if (has_vlan) { 939 + desc->vlan_tci = cpu_to_le16(skb_vlan_tag_get(skb)); 940 + stats->vlan_inserted++; 941 + } 944 942 945 - stats->no_csum++; 943 + stats->csum_none++; 946 944 947 945 return 0; 948 946 }