@@ -47,7 +47,7 @@ static const char octep_gstrings_global_stats[][ETH_GSTRING_LEN] = {
4747 "rx_err_pkts" ,
4848};
4949
50- #define OCTEP_GLOBAL_STATS_CNT (sizeof( octep_gstrings_global_stats) / ETH_GSTRING_LEN )
50+ #define OCTEP_GLOBAL_STATS_CNT ARRAY_SIZE( octep_gstrings_global_stats)
5151
5252static const char octep_gstrings_tx_q_stats [][ETH_GSTRING_LEN ] = {
5353 "tx_packets_posted[Q-%u]" ,
@@ -56,15 +56,15 @@ static const char octep_gstrings_tx_q_stats[][ETH_GSTRING_LEN] = {
5656 "tx_busy[Q-%u]" ,
5757};
5858
59- #define OCTEP_TX_Q_STATS_CNT (sizeof( octep_gstrings_tx_q_stats) / ETH_GSTRING_LEN )
59+ #define OCTEP_TX_Q_STATS_CNT ARRAY_SIZE( octep_gstrings_tx_q_stats)
6060
6161static const char octep_gstrings_rx_q_stats [][ETH_GSTRING_LEN ] = {
6262 "rx_packets[Q-%u]" ,
6363 "rx_bytes[Q-%u]" ,
6464 "rx_alloc_errors[Q-%u]" ,
6565};
6666
67- #define OCTEP_RX_Q_STATS_CNT (sizeof( octep_gstrings_rx_q_stats) / ETH_GSTRING_LEN )
67+ #define OCTEP_RX_Q_STATS_CNT ARRAY_SIZE( octep_gstrings_rx_q_stats)
6868
6969static void octep_get_drvinfo (struct net_device * netdev ,
7070 struct ethtool_drvinfo * info )
@@ -80,32 +80,25 @@ static void octep_get_strings(struct net_device *netdev,
8080{
8181 struct octep_device * oct = netdev_priv (netdev );
8282 u16 num_queues = CFG_GET_PORTS_ACTIVE_IO_RINGS (oct -> conf );
83- char * strings = ( char * ) data ;
83+ const char * str ;
8484 int i , j ;
8585
8686 switch (stringset ) {
8787 case ETH_SS_STATS :
88- for (i = 0 ; i < OCTEP_GLOBAL_STATS_CNT ; i ++ ) {
89- snprintf (strings , ETH_GSTRING_LEN ,
90- octep_gstrings_global_stats [i ]);
91- strings += ETH_GSTRING_LEN ;
92- }
88+ for (i = 0 ; i < OCTEP_GLOBAL_STATS_CNT ; i ++ )
89+ ethtool_puts (& data , octep_gstrings_global_stats [i ]);
9390
94- for (i = 0 ; i < num_queues ; i ++ ) {
91+ for (i = 0 ; i < num_queues ; i ++ )
9592 for (j = 0 ; j < OCTEP_TX_Q_STATS_CNT ; j ++ ) {
96- snprintf (strings , ETH_GSTRING_LEN ,
97- octep_gstrings_tx_q_stats [j ], i );
98- strings += ETH_GSTRING_LEN ;
93+ str = octep_gstrings_tx_q_stats [j ];
94+ ethtool_sprintf (& data , str , i );
9995 }
100- }
10196
102- for (i = 0 ; i < num_queues ; i ++ ) {
97+ for (i = 0 ; i < num_queues ; i ++ )
10398 for (j = 0 ; j < OCTEP_RX_Q_STATS_CNT ; j ++ ) {
104- snprintf (strings , ETH_GSTRING_LEN ,
105- octep_gstrings_rx_q_stats [j ], i );
106- strings += ETH_GSTRING_LEN ;
99+ str = octep_gstrings_rx_q_stats [j ];
100+ ethtool_sprintf (& data , str , i );
107101 }
108- }
109102 break ;
110103 default :
111104 break ;
@@ -157,17 +150,14 @@ octep_get_ethtool_stats(struct net_device *netdev,
157150 iface_rx_stats ,
158151 iface_tx_stats );
159152
160- for (q = 0 ; q < oct -> num_oqs ; q ++ ) {
161- struct octep_iq * iq = oct -> iq [q ];
162- struct octep_oq * oq = oct -> oq [q ];
153+ for (q = 0 ; q < OCTEP_MAX_QUEUES ; q ++ ) {
154+ tx_packets += oct -> stats_iq [q ].instr_completed ;
155+ tx_bytes += oct -> stats_iq [q ].bytes_sent ;
156+ tx_busy_errors += oct -> stats_iq [q ].tx_busy ;
163157
164- tx_packets += iq -> stats .instr_completed ;
165- tx_bytes += iq -> stats .bytes_sent ;
166- tx_busy_errors += iq -> stats .tx_busy ;
167-
168- rx_packets += oq -> stats .packets ;
169- rx_bytes += oq -> stats .bytes ;
170- rx_alloc_errors += oq -> stats .alloc_failures ;
158+ rx_packets += oct -> stats_oq [q ].packets ;
159+ rx_bytes += oct -> stats_oq [q ].bytes ;
160+ rx_alloc_errors += oct -> stats_oq [q ].alloc_failures ;
171161 }
172162 i = 0 ;
173163 data [i ++ ] = rx_packets ;
@@ -205,22 +195,18 @@ octep_get_ethtool_stats(struct net_device *netdev,
205195 data [i ++ ] = iface_rx_stats -> err_pkts ;
206196
207197 /* Per Tx Queue stats */
208- for (q = 0 ; q < oct -> num_iqs ; q ++ ) {
209- struct octep_iq * iq = oct -> iq [q ];
210-
211- data [i ++ ] = iq -> stats .instr_posted ;
212- data [i ++ ] = iq -> stats .instr_completed ;
213- data [i ++ ] = iq -> stats .bytes_sent ;
214- data [i ++ ] = iq -> stats .tx_busy ;
198+ for (q = 0 ; q < OCTEP_MAX_QUEUES ; q ++ ) {
199+ data [i ++ ] = oct -> stats_iq [q ].instr_posted ;
200+ data [i ++ ] = oct -> stats_iq [q ].instr_completed ;
201+ data [i ++ ] = oct -> stats_iq [q ].bytes_sent ;
202+ data [i ++ ] = oct -> stats_iq [q ].tx_busy ;
215203 }
216204
217205 /* Per Rx Queue stats */
218- for (q = 0 ; q < oct -> num_oqs ; q ++ ) {
219- struct octep_oq * oq = oct -> oq [q ];
220-
221- data [i ++ ] = oq -> stats .packets ;
222- data [i ++ ] = oq -> stats .bytes ;
223- data [i ++ ] = oq -> stats .alloc_failures ;
206+ for (q = 0 ; q < OCTEP_MAX_QUEUES ; q ++ ) {
207+ data [i ++ ] = oct -> stats_oq [q ].packets ;
208+ data [i ++ ] = oct -> stats_oq [q ].bytes ;
209+ data [i ++ ] = oct -> stats_oq [q ].alloc_failures ;
224210 }
225211}
226212
0 commit comments