lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <20230328092847.91643-10-xuanzhuo@linux.alibaba.com> Date: Tue, 28 Mar 2023 17:28:40 +0800 From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com> To: netdev@...r.kernel.org Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, "Michael S. Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>, Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, Jesper Dangaard Brouer <hawk@...nel.org>, John Fastabend <john.fastabend@...il.com>, virtualization@...ts.linux-foundation.org, bpf@...r.kernel.org Subject: [PATCH 09/16] virtio_net: introduce virtnet_rq_update_stats() Separating the code of updating rq stats. This is prepare for separating the code of ethtool. Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com> --- drivers/net/virtio/virtnet.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtnet.c b/drivers/net/virtio/virtnet.c index 84b90333dc77..36c747e43b3f 100644 --- a/drivers/net/virtio/virtnet.c +++ b/drivers/net/virtio/virtnet.c @@ -1550,6 +1550,21 @@ static void refill_work(struct work_struct *work) } } +static void virtnet_rq_update_stats(struct virtnet_rq *rq, struct virtnet_rq_stats *stats) +{ + int i; + + u64_stats_update_begin(&rq->stats.syncp); + for (i = 0; i < VIRTNET_RQ_STATS_LEN; i++) { + size_t offset = virtnet_rq_stats_desc[i].offset; + u64 *item; + + item = (u64 *)((u8 *)&rq->stats + offset); + *item += *(u64 *)((u8 *)stats + offset); + } + u64_stats_update_end(&rq->stats.syncp); +} + static int virtnet_receive(struct virtnet_rq *rq, int budget, unsigned int *xdp_xmit) { @@ -1557,7 +1572,6 @@ static int virtnet_receive(struct virtnet_rq *rq, int budget, struct virtnet_rq_stats stats = {}; unsigned int len; void *buf; - int i; if (!vi->big_packets || vi->mergeable_rx_bufs) { void *ctx; @@ -1584,15 +1598,7 @@ static int virtnet_receive(struct virtnet_rq *rq, int budget, } } - u64_stats_update_begin(&rq->stats.syncp); - for (i = 0; i < VIRTNET_RQ_STATS_LEN; i++) { - size_t offset = virtnet_rq_stats_desc[i].offset; - u64 *item; - - item = (u64 *)((u8 *)&rq->stats + offset); - *item += *(u64 *)((u8 *)&stats + offset); - } - u64_stats_update_end(&rq->stats.syncp); + virtnet_rq_update_stats(rq, &stats); return stats.packets; } -- 2.32.0.3.g01195cf9f
Powered by blists - more mailing lists