Commit dbdd0da3 authored by willy tarreau's avatar willy tarreau Committed by Jiri Slaby

net: mvneta: increase the 64-bit rx/tx stats out of the hot path

commit dc4277dd upstream.

Better count packets and bytes in the stack and on 32 bit then
accumulate them at the end for once. This saves two memory writes
and two memory barriers per packet. The incoming packet rate was
increased by 4.7% on the Openblocks AX3 thanks to this.

Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Tested-by: default avatarArnaud Ebalard <arno@natisbad.org>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent e63a4401
...@@ -1391,6 +1391,8 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo, ...@@ -1391,6 +1391,8 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
{ {
struct net_device *dev = pp->dev; struct net_device *dev = pp->dev;
int rx_done, rx_filled; int rx_done, rx_filled;
u32 rcvd_pkts = 0;
u32 rcvd_bytes = 0;
/* Get number of received packets */ /* Get number of received packets */
rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq); rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
...@@ -1428,10 +1430,8 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo, ...@@ -1428,10 +1430,8 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
rx_bytes = rx_desc->data_size - rx_bytes = rx_desc->data_size -
(ETH_FCS_LEN + MVNETA_MH_SIZE); (ETH_FCS_LEN + MVNETA_MH_SIZE);
u64_stats_update_begin(&pp->rx_stats.syncp); rcvd_pkts++;
pp->rx_stats.packets++; rcvd_bytes += rx_bytes;
pp->rx_stats.bytes += rx_bytes;
u64_stats_update_end(&pp->rx_stats.syncp);
/* Linux processing */ /* Linux processing */
skb_reserve(skb, MVNETA_MH_SIZE); skb_reserve(skb, MVNETA_MH_SIZE);
...@@ -1452,6 +1452,13 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo, ...@@ -1452,6 +1452,13 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
} }
} }
if (rcvd_pkts) {
u64_stats_update_begin(&pp->rx_stats.syncp);
pp->rx_stats.packets += rcvd_pkts;
pp->rx_stats.bytes += rcvd_bytes;
u64_stats_update_end(&pp->rx_stats.syncp);
}
/* Update rxq management counters */ /* Update rxq management counters */
mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_filled); mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_filled);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment