[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a4602b15-25b1-c388-73b4-1f97f6f0e555@gmail.com>
Date: Mon, 29 Nov 2021 19:36:46 -0700
From: David Ahern <dsahern@...il.com>
To: Alexander Lobakin <alexandr.lobakin@...el.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: Jesse Brandeburg <jesse.brandeburg@...el.com>,
Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
Jonathan Corbet <corbet@....net>,
Shay Agroskin <shayagr@...zon.com>,
Arthur Kiyanovski <akiyano@...zon.com>,
David Arinzon <darinzon@...zon.com>,
Noam Dagan <ndagan@...zon.com>,
Saeed Bishara <saeedb@...zon.com>,
Ioana Ciornei <ioana.ciornei@....com>,
Claudiu Manoil <claudiu.manoil@....com>,
Tony Nguyen <anthony.l.nguyen@...el.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Marcin Wojtas <mw@...ihalf.com>,
Russell King <linux@...linux.org.uk>,
Saeed Mahameed <saeedm@...dia.com>,
Leon Romanovsky <leon@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
Toke Høiland-Jørgensen <toke@...hat.com>,
John Fastabend <john.fastabend@...il.com>,
Edward Cree <ecree.xilinx@...il.com>,
Martin Habets <habetsm.xilinx@...il.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>,
Lorenzo Bianconi <lorenzo@...nel.org>,
Yajun Deng <yajun.deng@...ux.dev>,
Sergey Ryazanov <ryazanov.s.a@...il.com>,
David Ahern <dsahern@...nel.org>,
Andrei Vagin <avagin@...il.com>,
Johannes Berg <johannes.berg@...el.com>,
Vladimir Oltean <vladimir.oltean@....com>,
Cong Wang <cong.wang@...edance.com>, netdev@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-rdma@...r.kernel.org, bpf@...r.kernel.org,
virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v2 net-next 01/26] rtnetlink: introduce generic XDP
statistics
On 11/23/21 9:39 AM, Alexander Lobakin wrote:
> +static bool rtnl_get_xdp_stats_xdpxsk(struct sk_buff *skb, u32 ch,
> + const void *attr_data)
> +{
> + const struct ifla_xdp_stats *xstats = attr_data;
> +
> + xstats += ch;
> +
> + if (nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_PACKETS, xstats->packets,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_BYTES, xstats->bytes,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_ERRORS, xstats->errors,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_ABORTED, xstats->aborted,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_DROP, xstats->drop,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_INVALID, xstats->invalid,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_PASS, xstats->pass,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_REDIRECT, xstats->redirect,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_REDIRECT_ERRORS,
> + xstats->redirect_errors,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_TX, xstats->tx,
> + IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_TX_ERRORS,
> + xstats->tx_errors, IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_XMIT_PACKETS,
> + xstats->xmit_packets, IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_XMIT_BYTES,
> + xstats->xmit_bytes, IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_XMIT_ERRORS,
> + xstats->xmit_errors, IFLA_XDP_XSTATS_UNSPEC) ||
> + nla_put_u64_64bit(skb, IFLA_XDP_XSTATS_XMIT_FULL,
> + xstats->xmit_full, IFLA_XDP_XSTATS_UNSPEC))
> + return false;
> +
> + return true;
> +}
> +
Another thought on this patch: with individual attributes you could save
some overhead by not sending 0 counters to userspace. e.g., define a
helper that does:
static inline int nla_put_u64_if_set(struct sk_buff *skb, int attrtype,
u64 value, int padattr)
{
if (value)
return nla_put_u64_64bit(skb, attrtype, value, padattr);
return 0;
}
Powered by blists - more mailing lists