From: "Nambiar, Amritha" <amritha.nambiar@intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
<sridhar.samudrala@intel.com>
Subject: Re: [net-next PATCH v2 5/9] netdev-genl: Add netlink framework functions for napi
Date: Wed, 23 Aug 2023 16:53:39 -0700 [thread overview]
Message-ID: <0712fad6-bebd-4c9b-9ab7-46c0aa0ea02a@intel.com> (raw)
In-Reply-To: <20230822175111.78d4fe32@kernel.org>
On 8/22/2023 5:51 PM, Jakub Kicinski wrote:
> On Mon, 21 Aug 2023 16:25:36 -0700 Amritha Nambiar wrote:
>> Implement the netdev netlink framework functions for
>> napi support. The netdev structure tracks all the napi
>> instances and napi fields. The napi instances and associated
>> queue[s] can be retrieved this way.
>>
>> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>
>> @@ -119,14 +134,158 @@ int netdev_nl_dev_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
>> return skb->len;
>> }
>>
>> +static int
>> +netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi,
>> + const struct genl_info *info)
>> +{
>> + struct netdev_rx_queue *rx_queue, *rxq;
>> + struct netdev_queue *tx_queue, *txq;
>> + unsigned int rx_qid, tx_qid;
>> + void *hdr;
>> +
>> + if (!napi->dev)
>> + return -EINVAL;
>
> WARN_ON_ONCE()? If this can be assumed not to happen.
Okay. Will fix in v3.
>
>> + hdr = genlmsg_iput(rsp, info);
>> + if (!hdr)
>> + return -EMSGSIZE;
>> +
>> + if (nla_put_u32(rsp, NETDEV_A_NAPI_NAPI_ID, napi->napi_id))
>
> napi_id can be zero.
Will fix in v3.
>
>> + goto nla_put_failure;
>> +
>> + if (nla_put_u32(rsp, NETDEV_A_NAPI_IFINDEX, napi->dev->ifindex))
>> + goto nla_put_failure;
>
>> int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info)
>> {
>> - return -EOPNOTSUPP;
>> + struct net_device *netdev;
>> + struct sk_buff *rsp;
>> + u32 napi_id;
>> + int err;
>> +
>> + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_NAPI_NAPI_ID))
>> + return -EINVAL;
>> +
>> + napi_id = nla_get_u32(info->attrs[NETDEV_A_NAPI_NAPI_ID]);
>> +
>> + rsp = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
>> + if (!rsp)
>> + return -ENOMEM;
>> +
>> + rtnl_lock();
>> +
>> + netdev = dev_get_by_napi_id(napi_id);
>
> Why lookup the dev and not the NAPI?
Agree. Will fix in v3.
>
>> + if (netdev)
>> + err = netdev_nl_napi_fill(netdev, rsp, info, napi_id);
>> + else
>> + err = -ENODEV;
>> +
>> + rtnl_unlock();
>> +
>> + if (err)
>> + goto err_free_msg;
>> +
>> + return genlmsg_reply(rsp, info);
>> +
>> +err_free_msg:
>> + nlmsg_free(rsp);
>> + return err;
>> +}
>> +
>> +static int
>> +netdev_nl_napi_dump_one(struct net_device *netdev, struct sk_buff *rsp,
>> + const struct genl_info *info, int *start)
>> +{
>> + struct napi_struct *napi, *n;
>> + int err = 0;
>> + int i = 0;
>> +
>> + list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list) {
>
> Why _safe()? I think you need _rcu() instead?
Agree. This is called within rtnl_lock. Will fix.
>
>> + if (i < *start) {
>> + i++;
>> + continue;
>> + }
>> + err = netdev_nl_napi_fill_one(rsp, napi, info);
>> + if (err)
>> + break;
>> + *start = ++i;
>
> Why count them instead of relying on the IDs?
Makes sense. Will fix.
>
>> int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
>> {
>> - return -EOPNOTSUPP;
>> + const struct genl_dumpit_info *info = genl_dumpit_info(cb);
>
> You can get genl_info_dump(cb) here, you don't use the genl_dumpit_info
> AFAICT, only info->info.
Will fix in v3.
next prev parent reply other threads:[~2023-08-23 23:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 23:25 [net-next PATCH v2 0/9] Introduce NAPI queues support Amritha Nambiar
2023-08-21 23:25 ` [net-next PATCH v2 1/9] net: Introduce new fields for napi and queue associations Amritha Nambiar
2023-08-21 23:25 ` [net-next PATCH v2 2/9] ice: Add support in the driver for associating napi with queue[s] Amritha Nambiar
2023-08-21 23:25 ` [net-next PATCH v2 3/9] netdev-genl: spec: Extend netdev netlink spec in YAML for NAPI Amritha Nambiar
2023-08-23 0:39 ` Jakub Kicinski
2023-08-24 0:46 ` Nambiar, Amritha
2023-08-24 1:34 ` Jakub Kicinski
2023-08-24 22:26 ` Nambiar, Amritha
2023-08-24 23:55 ` Jakub Kicinski
2023-08-21 23:25 ` [net-next PATCH v2 4/9] net: Move kernel helpers for queue index outside sysfs Amritha Nambiar
2023-08-23 0:40 ` Jakub Kicinski
2023-08-23 23:57 ` Nambiar, Amritha
2023-08-21 23:25 ` [net-next PATCH v2 5/9] netdev-genl: Add netlink framework functions for napi Amritha Nambiar
2023-08-23 0:51 ` Jakub Kicinski
2023-08-23 23:53 ` Nambiar, Amritha [this message]
2023-08-21 23:25 ` [net-next PATCH v2 6/9] netdev-genl: spec: Add irq in netdev netlink YAML spec Amritha Nambiar
2023-08-21 23:25 ` [net-next PATCH v2 7/9] net: Add NAPI IRQ support Amritha Nambiar
2023-08-23 0:52 ` Jakub Kicinski
2023-08-23 23:49 ` Nambiar, Amritha
2023-08-21 23:25 ` [net-next PATCH v2 8/9] netdev-genl: spec: Add PID in netdev netlink YAML spec Amritha Nambiar
2023-08-21 23:25 ` [net-next PATCH v2 9/9] netdev-genl: Add PID for the NAPI thread Amritha Nambiar
2023-08-23 10:24 ` [net-next PATCH v2 0/9] Introduce NAPI queues support David Laight
2023-08-23 23:49 ` Nambiar, Amritha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0712fad6-bebd-4c9b-9ab7-46c0aa0ea02a@intel.com \
--to=amritha.nambiar@intel.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sridhar.samudrala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).