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

sfc: account XDP TXes in netdev base stats

When we handle a TX completion for an XDP packet, it is not counted
in the per-TXQ netdev stats. Record it in new internal counters,
and include those in the device-wide total in efx_get_base_stats().

Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Edward Cree and committed by
David S. Miller
cfa63b90 5c24de42

+39 -8
+3
drivers/net/ethernet/sfc/efx.c
··· 690 690 tx->packets += tx_queue->old_complete_packets; 691 691 tx->bytes += tx_queue->old_complete_bytes; 692 692 } 693 + /* Include XDP TX in device-wide stats */ 694 + tx->packets += tx_queue->complete_xdp_packets; 695 + tx->bytes += tx_queue->complete_xdp_bytes; 693 696 } 694 697 } 695 698 }
+6
drivers/net/ethernet/sfc/net_driver.h
··· 216 216 * created. For TSO, counts the superframe size, not the sizes of 217 217 * generated frames on the wire (i.e. the headers are only counted 218 218 * once) 219 + * @complete_xdp_packets: Number of XDP TX packets completed since this 220 + * struct was created. 221 + * @complete_xdp_bytes: Number of XDP TX bytes completed since this 222 + * struct was created. 219 223 * @completed_timestamp_major: Top part of the most recent tx timestamp. 220 224 * @completed_timestamp_minor: Low part of the most recent tx timestamp. 221 225 * @insert_count: Current insert pointer ··· 285 281 unsigned int pkts_compl; 286 282 unsigned long complete_packets; 287 283 unsigned long complete_bytes; 284 + unsigned long complete_xdp_packets; 285 + unsigned long complete_xdp_bytes; 288 286 u32 completed_timestamp_major; 289 287 u32 completed_timestamp_minor; 290 288
+5 -1
drivers/net/ethernet/sfc/tx.c
··· 553 553 554 554 void efx_xmit_done_single(struct efx_tx_queue *tx_queue) 555 555 { 556 + unsigned int xdp_pkts_compl = 0, xdp_bytes_compl = 0; 556 557 unsigned int pkts_compl = 0, bytes_compl = 0; 557 558 unsigned int efv_pkts_compl = 0; 558 559 unsigned int read_ptr; ··· 578 577 if (buffer->flags & EFX_TX_BUF_SKB) 579 578 finished = true; 580 579 efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl, 581 - &efv_pkts_compl); 580 + &efv_pkts_compl, &xdp_pkts_compl, 581 + &xdp_bytes_compl); 582 582 583 583 ++tx_queue->read_count; 584 584 read_ptr = tx_queue->read_count & tx_queue->ptr_mask; ··· 587 585 588 586 tx_queue->pkts_compl += pkts_compl; 589 587 tx_queue->bytes_compl += bytes_compl; 588 + tx_queue->complete_xdp_packets += xdp_pkts_compl; 589 + tx_queue->complete_xdp_bytes += xdp_bytes_compl; 590 590 591 591 EFX_WARN_ON_PARANOID(pkts_compl + efv_pkts_compl != 1); 592 592
+22 -6
drivers/net/ethernet/sfc/tx_common.c
··· 112 112 113 113 /* Free any buffers left in the ring */ 114 114 while (tx_queue->read_count != tx_queue->write_count) { 115 + unsigned int xdp_pkts_compl = 0, xdp_bytes_compl = 0; 115 116 unsigned int pkts_compl = 0, bytes_compl = 0; 116 117 unsigned int efv_pkts_compl = 0; 117 118 118 119 buffer = &tx_queue->buffer[tx_queue->read_count & tx_queue->ptr_mask]; 119 120 efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl, 120 - &efv_pkts_compl); 121 + &efv_pkts_compl, &xdp_pkts_compl, 122 + &xdp_bytes_compl); 121 123 122 124 ++tx_queue->read_count; 123 125 } ··· 155 153 struct efx_tx_buffer *buffer, 156 154 unsigned int *pkts_compl, 157 155 unsigned int *bytes_compl, 158 - unsigned int *efv_pkts_compl) 156 + unsigned int *efv_pkts_compl, 157 + unsigned int *xdp_pkts, 158 + unsigned int *xdp_bytes) 159 159 { 160 160 if (buffer->unmap_len) { 161 161 struct device *dma_dev = &tx_queue->efx->pci_dev->dev; ··· 202 198 tx_queue->queue, tx_queue->read_count); 203 199 } else if (buffer->flags & EFX_TX_BUF_XDP) { 204 200 xdp_return_frame_rx_napi(buffer->xdpf); 201 + if (xdp_pkts) 202 + (*xdp_pkts)++; 203 + if (xdp_bytes) 204 + (*xdp_bytes) += buffer->xdpf->len; 205 205 } 206 206 207 207 buffer->len = 0; ··· 221 213 unsigned int index, 222 214 unsigned int *pkts_compl, 223 215 unsigned int *bytes_compl, 224 - unsigned int *efv_pkts_compl) 216 + unsigned int *efv_pkts_compl, 217 + unsigned int *xdp_pkts, 218 + unsigned int *xdp_bytes) 225 219 { 226 220 struct efx_nic *efx = tx_queue->efx; 227 221 unsigned int stop_index, read_ptr; ··· 243 233 } 244 234 245 235 efx_dequeue_buffer(tx_queue, buffer, pkts_compl, bytes_compl, 246 - efv_pkts_compl); 236 + efv_pkts_compl, xdp_pkts, xdp_bytes); 247 237 248 238 ++tx_queue->read_count; 249 239 read_ptr = tx_queue->read_count & tx_queue->ptr_mask; ··· 266 256 int efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index) 267 257 { 268 258 unsigned int fill_level, pkts_compl = 0, bytes_compl = 0; 259 + unsigned int xdp_pkts_compl = 0, xdp_bytes_compl = 0; 269 260 unsigned int efv_pkts_compl = 0; 270 261 struct efx_nic *efx = tx_queue->efx; 271 262 272 263 EFX_WARN_ON_ONCE_PARANOID(index > tx_queue->ptr_mask); 273 264 274 265 efx_dequeue_buffers(tx_queue, index, &pkts_compl, &bytes_compl, 275 - &efv_pkts_compl); 266 + &efv_pkts_compl, &xdp_pkts_compl, &xdp_bytes_compl); 276 267 tx_queue->pkts_compl += pkts_compl; 277 268 tx_queue->bytes_compl += bytes_compl; 269 + tx_queue->complete_xdp_packets += xdp_pkts_compl; 270 + tx_queue->complete_xdp_bytes += xdp_bytes_compl; 278 271 279 272 if (pkts_compl + efv_pkts_compl > 1) 280 273 ++tx_queue->merge_events; ··· 306 293 void efx_enqueue_unwind(struct efx_tx_queue *tx_queue, 307 294 unsigned int insert_count) 308 295 { 296 + unsigned int xdp_bytes_compl = 0; 297 + unsigned int xdp_pkts_compl = 0; 309 298 unsigned int efv_pkts_compl = 0; 310 299 struct efx_tx_buffer *buffer; 311 300 unsigned int bytes_compl = 0; ··· 318 303 --tx_queue->insert_count; 319 304 buffer = __efx_tx_queue_get_insert_buffer(tx_queue); 320 305 efx_dequeue_buffer(tx_queue, buffer, &pkts_compl, &bytes_compl, 321 - &efv_pkts_compl); 306 + &efv_pkts_compl, &xdp_pkts_compl, 307 + &xdp_bytes_compl); 322 308 } 323 309 } 324 310
+3 -1
drivers/net/ethernet/sfc/tx_common.h
··· 20 20 struct efx_tx_buffer *buffer, 21 21 unsigned int *pkts_compl, 22 22 unsigned int *bytes_compl, 23 - unsigned int *efv_pkts_compl); 23 + unsigned int *efv_pkts_compl, 24 + unsigned int *xdp_pkts, 25 + unsigned int *xdp_bytes); 24 26 25 27 static inline bool efx_tx_buffer_in_use(struct efx_tx_buffer *buffer) 26 28 {