From: "WanRenyong" <wanry@yunsilicon.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>
Cc: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
<qianr@yunsilicon.com>, <nana@yunsilicon.com>,
<zhangxx@yunsilicon.com>, <xudw@yunsilicon.com>,
<jacky@yunsilicon.com>, <weihg@yunsilicon.com>
Subject: Re: [PATCH v6 06/15] net/xsc: initialize xsc representors
Date: Tue, 21 Jan 2025 13:27:14 +0800 [thread overview]
Message-ID: <196f1fd9-f05c-4233-ac20-9d79b9ed48b6@yunsilicon.com> (raw)
In-Reply-To: <20250120110619.33edcdec@hermes.local>
On 2025/1/21 3:06, Stephen Hemminger wrote:
> On Mon, 20 Jan 2025 19:14:44 +0800
> "WanRenyong" <wanry@yunsilicon.com> wrote:
>
>> +static int
>> +xsc_ethdev_init_representors(struct rte_eth_dev *eth_dev)
>> +{
>> + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(eth_dev);
>> + struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
>> + struct rte_device *dev;
>> + struct xsc_dev *xdev;
>> + struct xsc_repr_port *repr_port;
>> + char name[RTE_ETH_NAME_MAX_LEN];
>> + int i;
>> + int ret;
>> +
>> + PMD_INIT_FUNC_TRACE();
>> +
>> + dev = &priv->pci_dev->device;
>> + if (dev->devargs != NULL) {
>> + ret = rte_eth_devargs_parse(dev->devargs->args, ð_da, 1);
>> + if (ret < 0) {
>> + PMD_DRV_LOG(ERR, "Failed to parse device arguments: %s",
>> + dev->devargs->args);
>> + return -EINVAL;
>> + }
>> + }
>> +
>> + xdev = priv->xdev;
>> + ret = xsc_dev_repr_ports_probe(xdev, eth_da.nb_representor_ports, RTE_MAX_ETHPORTS);
>> + if (ret != 0) {
>> + PMD_DRV_LOG(ERR, "Failed to probe %d xsc device representors",
>> + eth_da.nb_representor_ports);
>> + return ret;
>> + }
>> +
>> + /* PF rep init */
>> + repr_port = &xdev->repr_ports[xdev->num_repr_ports - 1];
>> + ret = xsc_ethdev_init_one_representor(eth_dev, repr_port);
>> + if (ret != 0) {
>> + PMD_DRV_LOG(ERR, "Failed to init backing representor");
>> + return ret;
>> + }
>> +
>> + /* VF rep init */
>> + for (i = 0; i < eth_da.nb_representor_ports; i++) {
>> + repr_port = &xdev->repr_ports[i];
>> + snprintf(name, sizeof(name), "%s_rep_%d",
>> + xdev->name, repr_port->info.repr_id);
>
> If I enable format-truncation warnings then there is this message.
> The warning is suppressed by drivers/meson.build, but would like in the future
> to not disable warnings there.
>
> ../drivers/net/xsc/xsc_ethdev.c: In function ‘xsc_ethdev_init’:
> ../drivers/net/xsc/xsc_ethdev.c:787:49: warning: ‘_rep_’ directive output may be truncated writing 5 bytes into a region of size between 1 and 64 [-Wformat-truncation=]
> 787 | snprintf(name, sizeof(name), "%s_rep_%d",
> | ^~~~~
> In function ‘xsc_ethdev_init_representors’,
> inlined from ‘xsc_ethdev_init’ at ../drivers/net/xsc/xsc_ethdev.c:834:8:
> ../drivers/net/xsc/xsc_ethdev.c:787:17: note: ‘snprintf’ output between 7 and 80 bytes into a destination of size 64
> 787 | snprintf(name, sizeof(name), "%s_rep_%d",
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 788 | xdev->name, repr_port->info.repr_id);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This is because local variable name is of size RTE_ETH_NAME_MAX_LEN which is 64
> and xdev->name is defined as RTE_ETH_NAME_MAX_LEN as well.
> The warning is correct but impossible to happen since xdev->name is only filled
> in with PCI information. A simple way to get rid of it (and save some space)
> would be to define name to be for PCI address only.
>
> Would this work?
>
> diff --git a/drivers/net/xsc/xsc_dev.h b/drivers/net/xsc/xsc_dev.h
> index d661523e13..cc5fa8aad8 100644
> --- a/drivers/net/xsc/xsc_dev.h
> +++ b/drivers/net/xsc/xsc_dev.h
> @@ -121,7 +121,7 @@ struct xsc_dev {
> int ifindex;
> int port_id; /* Probe dev */
> void *dev_priv;
> - char name[RTE_ETH_NAME_MAX_LEN];
> + char name[PCI_PRI_STR_SIZE];
> void *bar_addr;
> void *jumbo_buffer_pa;
> void *jumbo_buffer_va;
Hello Stephen Hemminger,
Thanks for your review.
Your suggestion is correct. In fact, xdev->name is initialized to the
PCI address , it will work if size of xdev->name defined as
PCI_PRI_STR_SIZE. I will modify it in the next version.
--
Best regards,
WanRenyong
next prev parent reply other threads:[~2025-01-21 5:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 11:15 [PATCH v6 00/15] XSC PMD for Yunsilicon NICs WanRenyong
2025-01-20 11:14 ` [PATCH v6 01/15] net/xsc: add xsc PMD framework WanRenyong
2025-01-20 11:14 ` [PATCH v6 02/15] net/xsc: add xsc device initialization WanRenyong
2025-01-20 11:14 ` [PATCH v6 03/15] net/xsc: add xsc mailbox WanRenyong
2025-01-20 18:18 ` Stephen Hemminger
2025-01-21 2:39 ` WanRenyong
2025-01-20 18:19 ` Stephen Hemminger
2025-01-21 3:31 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 04/15] net/xsc: add xsc dev ops to support VFIO driver WanRenyong
2025-01-20 11:14 ` [PATCH v6 05/15] net/xsc: add PCT interfaces WanRenyong
2025-01-20 18:24 ` Stephen Hemminger
2025-01-21 3:44 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 06/15] net/xsc: initialize xsc representors WanRenyong
2025-01-20 19:06 ` Stephen Hemminger
2025-01-21 5:27 ` WanRenyong [this message]
2025-01-20 11:14 ` [PATCH v6 07/15] net/xsc: add ethdev configure and RSS ops WanRenyong
2025-01-20 11:14 ` [PATCH v6 08/15] net/xsc: add Rx and Tx queue setup WanRenyong
2025-01-20 18:16 ` Stephen Hemminger
2025-01-21 3:21 ` WanRenyong
2025-01-20 11:14 ` [PATCH v6 09/15] net/xsc: add ethdev start WanRenyong
2025-01-20 11:14 ` [PATCH v6 10/15] net/xsc: add ethdev stop and close WanRenyong
2025-01-20 11:14 ` [PATCH v6 11/15] net/xsc: add ethdev Rx burst WanRenyong
2025-01-20 11:14 ` [PATCH v6 12/15] net/xsc: add ethdev Tx burst WanRenyong
2025-01-20 11:15 ` [PATCH v6 13/15] net/xsc: add basic stats ops WanRenyong
2025-01-20 11:15 ` [PATCH v6 14/15] net/xsc: add ethdev infos get WanRenyong
2025-01-20 11:15 ` [PATCH v6 15/15] net/xsc: add ethdev link and MTU ops WanRenyong
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=196f1fd9-f05c-4233-ac20-9d79b9ed48b6@yunsilicon.com \
--to=wanry@yunsilicon.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=jacky@yunsilicon.com \
--cc=nana@yunsilicon.com \
--cc=qianr@yunsilicon.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
--cc=weihg@yunsilicon.com \
--cc=xudw@yunsilicon.com \
--cc=zhangxx@yunsilicon.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).