Skip to content

Commit cbd5228

Browse files
antonblancharddavem330
authored andcommitted
ibmveth: Fix endian issues with rx_no_buffer statistic
Hidden away in the last 8 bytes of the buffer_list page is a solitary statistic. It needs to be byte swapped or else ethtool -S will produce numbers that terrify the user. Since we do this in multiple places, create a helper function with a comment explaining what is going on. Signed-off-by: Anton Blanchard <[email protected]> Cc: [email protected] Signed-off-by: David S. Miller <[email protected]>
1 parent c10e4ca commit cbd5228

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

drivers/net/ethernet/ibm/ibmveth.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,18 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter,
292292
atomic_add(buffers_added, &(pool->available));
293293
}
294294

295+
/*
296+
* The final 8 bytes of the buffer list is a counter of frames dropped
297+
* because there was not a buffer in the buffer list capable of holding
298+
* the frame.
299+
*/
300+
static void ibmveth_update_rx_no_buffer(struct ibmveth_adapter *adapter)
301+
{
302+
__be64 *p = adapter->buffer_list_addr + 4096 - 8;
303+
304+
adapter->rx_no_buffer = be64_to_cpup(p);
305+
}
306+
295307
/* replenish routine */
296308
static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
297309
{
@@ -307,8 +319,7 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
307319
ibmveth_replenish_buffer_pool(adapter, pool);
308320
}
309321

310-
adapter->rx_no_buffer = *(u64 *)(((char*)adapter->buffer_list_addr) +
311-
4096 - 8);
322+
ibmveth_update_rx_no_buffer(adapter);
312323
}
313324

314325
/* empty and free ana buffer pool - also used to do cleanup in error paths */
@@ -698,8 +709,7 @@ static int ibmveth_close(struct net_device *netdev)
698709

699710
free_irq(netdev->irq, netdev);
700711

701-
adapter->rx_no_buffer = *(u64 *)(((char *)adapter->buffer_list_addr) +
702-
4096 - 8);
712+
ibmveth_update_rx_no_buffer(adapter);
703713

704714
ibmveth_cleanup(adapter);
705715

0 commit comments

Comments
 (0)