DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Wenbo Cao <caowenbo@mucse.com>
Cc: thomas@monjalon.net, dev@dpdk.org, ferruh.yigit@amd.com,
	andrew.rybchenko@oktetlabs.ru, yaojun@mucse.com
Subject: Re: [PATCH v12 00/28] [v12]drivers/net Add Support mucse N10 Pmd Driver
Date: Thu, 13 Feb 2025 10:28:33 -0800	[thread overview]
Message-ID: <20250213102833.12f6399d@hermes.local> (raw)
In-Reply-To: <1739374368-4949-1-git-send-email-caowenbo@mucse.com>

On Wed, 12 Feb 2025 23:32:20 +0800
Wenbo Cao <caowenbo@mucse.com> wrote:

> For This patchset just to support the basic chip init work
> and user can just found the eth_dev, but can't control more.
> For Now just support 2*10g nic,the chip can support
> 2*10g,4*10g,4*1g,8*1g,8*10g.
> The Feature rx side can support rx-cksum-offload,rss,vlan-filter
> flow_clow,uncast_filter,mcast_filter,1588,Jumbo-frame
> The Feature tx side can support tx-cksum-offload,tso,vxlan-tso 
> flow director base on ntuple pattern of tcp/udp/ip/ eth_hdr->type
> for sriov is also support.
> 
> Because of the chip design defect, for multiple-port mode
> one pci-bdf will have multiple-port (max can have four ports)
> so this code must be care of one bdf init multiple-port.

The driver is getting very close to being ready to merge but still see
some things. Mostly the issues are around the documentation now.

Review checklist for rnp v12 patches:

Mark items with:
    ✔ passed
    ✘ Failed

Basic hygiene
    ✔ Look at CI results in patchwork
    ✔ Merge cleanly with git am; look for missing newline at EOF etc
    ✘ Run checkpatches; warnings are ok, but look more carefully.
      Lots of warnings from base code (allowed but not preferred).

Fix these by making it an inline function?

#1143: FILE: drivers/net/rnp/rnp.h:62:
+#define RNP_PF_OWN_PORTS(id)	(((id) == 0) ? 1 : (((id) == 1) ? 2 : 4))

+#define RNP_LINK_SPEED_CODE(sp, n) \
+	(((sp) & RTE_GENMASK32((11) + ((4) * (n)), \
+		(8) + ((4) * (n)))) >> (8 + 4 * (n)))

This warning could be fixed with either a temporary variable or longer line

WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'rte_eth_devices[rxq->attr.port_id].data->rx_mbuf_alloc_failed'
#63: FILE: drivers/net/rnp/rnp_rxtx.c:849:
+			rte_eth_devices[rxq->attr.port_id].data->
+				rx_mbuf_alloc_failed++;


    ✔ Run check-git-log
    ✔ Run check-symbol-maps.sh
    ✔ Run check-doc-vs-code
    ✔ Run check-spdk-tag

Builds
    ✔ Normal Gcc build
    ✔ Use latest experimental Gcc 15 to catch new warnings
    ✔ Clang build using current version (clang-19)
    ✔ Build for 32 bit x86
    ✔ Doc build; works but needs editing
The wording in rnp.rst is not grammatically correct.
Missing articles and some punctuation issues.
Need to mention big-endian limitations.
Windows limitation not mentioned.
Suggest using svg diagram (looks better) rather than ASCII art.

    ✘ Check feature matrix versus code
The driver doc says it supports queue start/stop but no
rx_queue_start or tx_queue_start operations are listed.

    ✔ Debug build
    ✔ Enable asserts
    ✔ Test meson builds

Experimental builds:
     Enable address sanitizer
     ✘ Enable extra warnings (edit meson.build) for
        -Wvla, -Wformat-truncation, -Waddress-of-packed-member

     The issue here is that name is limited to RTE_ETH_NAME_MAX_LEN
     and hw->device_name is RTE_DEV_NAME_MAX_LEN is also 64
     so adding a suffix could potentially overflow the name.

     One way to avoid compiler warning is a a check on length of
     hw->device_name in this code like:
        if (strlen(hw->device_name) + 4 > sizeof(name))
	   return -EINVAL


../drivers/net/rnp/rnp_ethdev.c: In function ‘rnp_eth_dev_init’:
../drivers/net/rnp/rnp_ethdev.c:1705:45: warning: ‘%d’ directive output may be truncated writing 1 byte into a region of size between 0 and 63 [-Wformat-truncation=]
 1705 |                                         "%s_%d", hw->device_name, p_id);
      |                                             ^~
../drivers/net/rnp/rnp_ethdev.c:1705:41: note: directive argument in the range [1, 4]
 1705 |                                         "%s_%d", hw->device_name, p_id);
      |                                         ^~~~~~~
../drivers/net/rnp/rnp_ethdev.c:1704:25: note: ‘snprintf’ output between 3 and 66 bytes into a destination of size 64
 1704 |                         snprintf(name, sizeof(name),
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1705 |                                         "%s_%d", hw->device_name, p_id);
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Look for anti-patterns:
    ✔ Driver must not disable warnings with compiler flags or pragma's
    ✔ Driver must not use thread and signal
    ✔ Apply coccinelle scripts; look that for example null free checks
    ✔ Review use of memcpy/rte_memcpy
    ✔ Review use of malloc
    ✔ Review locking
    ✘ Review use of memset
      Use of memset before snprintf is unnecessary.

    ✘ Handling of deferred start
      If driver supports deferred start then it has to have a
      queue start/stop operation. Otherwise ignore the flag.

    ✘ Review whitespace
      Unneeded indents in meson.build

sources = files(
                'rnp_ethdev.c',
...
vs.
sources = files(
        'ixgbe_82599_bypass.c',
...

Other
1. The xstat names are long and have spaces in them.
   I don't see this in other drivers.
   Suggest using similar naming pattern as virtio

2. Handling of queue counters
   This code would look much cleaner with temp variable.
   No need for useless init of i. and it is unsigned.
   Don't need to cast void * pointer

diff --git a/drivers/net/rnp/rnp_ethdev.c b/drivers/net/rnp/rnp_ethdev.c
index a295982780..1305d7e0dc 100644
--- a/drivers/net/rnp/rnp_ethdev.c
+++ b/drivers/net/rnp/rnp_ethdev.c
@@ -1254,48 +1254,36 @@ rnp_dev_stats_get(struct rte_eth_dev *dev,
 	struct rnp_eth_port *port = RNP_DEV_TO_PORT(dev);
 	struct rnp_hw_eth_stats *eth_stats = &port->eth_stats;
 	struct rte_eth_dev_data *data = dev->data;
-	int i = 0;
+	uint16_t i;

 	PMD_INIT_FUNC_TRACE();
 	rnp_get_hw_stats(dev);
+
 	for (i = 0; i < data->nb_rx_queues; i++) {
-		if (!data->rx_queues[i])
+		const struct rnp_rx_queue *rxq = dev->data->rx_queues[i];
+		if (!rxq)
 			continue;
+
+		stats->ipackets += rxq->stats.ipackets;
+		stats->ibytes += rxq->stats.ibytes;
 		if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
-			stats->q_ipackets[i] = ((struct rnp_rx_queue **)
-					(data->rx_queues))[i]->stats.ipackets;
-			stats->q_ibytes[i] = ((struct rnp_rx_queue **)
-					(data->rx_queues))[i]->stats.ibytes;
-			stats->ipackets += stats->q_ipackets[i];
-			stats->ibytes += stats->q_ibytes[i];
-		} else {
-			stats->ipackets += ((struct rnp_rx_queue **)
-					(data->rx_queues))[i]->stats.ipackets;
-			stats->ibytes += ((struct rnp_rx_queue **)
-					(data->rx_queues))[i]->stats.ibytes;
+			stats->q_ipackets[i] = rxq->stats.ipackets;
+			stats->q_ibytes[i] = rxq->stats.ibytes;
 		}
 	}

 	for (i = 0; i < data->nb_tx_queues; i++) {
-		if (!data->tx_queues[i])
+		const struct rnp_tx_queue *txq = dev->data->tx_queues[i];
+		if (!txq)
 			continue;
-		if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
-			stats->q_opackets[i] = ((struct rnp_tx_queue **)
-					(data->tx_queues))[i]->stats.opackets;
-			stats->q_obytes[i] = ((struct rnp_tx_queue **)
-					(data->tx_queues))[i]->stats.obytes;
-			stats->oerrors += ((struct rnp_tx_queue **)
-					(data->tx_queues))[i]->stats.errors;
-			stats->opackets += stats->q_opackets[i];
-			stats->obytes += stats->q_obytes[i];

-		} else {
-			stats->opackets += ((struct rnp_tx_queue **)
-					(data->tx_queues))[i]->stats.opackets;
-			stats->obytes += ((struct rnp_tx_queue **)
-					(data->tx_queues))[i]->stats.obytes;
-			stats->oerrors += ((struct rnp_tx_queue **)
-					(data->tx_queues))[i]->stats.errors;
+		stats->opackets += txq->stats.opackets;
+		stats->obytes += txq->stats.obytes;
+		stats->oerrors += txq->stats.errors;
+
+		if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
+			stats->q_opackets[i] = txq->stats.opackets;
+			stats->q_obytes[i] = txq->stats.obytes;
 		}
 	}
 	stats->imissed = eth_stats->rx_trans_drop + eth_stats->rx_trunc_drop;
@@ -1308,22 +1296,18 @@ rnp_dev_stats_reset(struct rte_eth_dev *dev)
 {
 	struct rnp_eth_port *port = RNP_DEV_TO_PORT(dev);
 	struct rnp_hw_eth_stats *eth_stats = &port->eth_stats;
-	struct rnp_rx_queue *rxq;
-	struct rnp_tx_queue *txq;
 	uint16_t idx;

 	PMD_INIT_FUNC_TRACE();
 	memset(eth_stats, 0, sizeof(*eth_stats));
 	for (idx = 0; idx < dev->data->nb_rx_queues; idx++) {
-		rxq = ((struct rnp_rx_queue **)
-				(dev->data->rx_queues))[idx];
+		struct rnp_rx_queue *rxq = dev->data->rx_queues[i];
 		if (!rxq)
 			continue;
 		memset(&rxq->stats, 0, sizeof(struct rnp_queue_stats));
 	}
 	for (idx = 0; idx < dev->data->nb_tx_queues; idx++) {
-		txq = ((struct rnp_tx_queue **)
-				(dev->data->tx_queues))[idx];
+		struct rnp_tx_queue *txq = dev->data->tx_queues[idx];
 		if (!txq)
 			continue;
 		memset(&txq->stats, 0, sizeof(struct rnp_queue_stats));


      parent reply	other threads:[~2025-02-13 18:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 15:32 Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 01/28] net/rnp: add skeleton Wenbo Cao
2025-02-13 18:49   ` Stephen Hemminger
2025-02-12 15:32 ` [PATCH v12 02/28] net/rnp: add ethdev probe and remove Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 03/28] net/rnp: add log Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 04/28] net/rnp: support mailbox basic operate Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 05/28] net/rnp: add device init and uninit Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 06/28] net/rnp: add get device information operation Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 07/28] net/rnp: add support MAC promisc mode Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 08/28] net/rnp: add queue setup and release operations Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 09/28] net/rnp: add queue stop and start operations Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 10/28] net/rnp: add support device start stop operations Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 11/28] net/rnp: add RSS support operations Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 12/28] net/rnp: add support link update operations Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 13/28] net/rnp: add support link setup operations Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 14/28] net/rnp: add Rx burst simple support Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 15/28] net/rnp: add Tx " Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 16/28] net/rnp: add MTU set operation Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 17/28] net/rnp: add Rx scatter segment version Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 18/28] net/rnp: add Tx multiple " Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 19/28] net/rnp: add support basic stats operation Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 20/28] net/rnp: add support xstats operation Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 21/28] net/rnp: add unicast MAC filter operation Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 22/28] net/rnp: add supported packet types Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 23/28] net/rnp: add support Rx checksum offload Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 24/28] net/rnp: add support Tx TSO offload Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 25/28] net/rnp: support VLAN offloads Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 26/28] net/rnp: add support VLAN filters operations Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 27/28] net/rnp: add queue info operation Wenbo Cao
2025-02-12 15:32 ` [PATCH v12 28/28] net/rnp: support Rx/Tx burst mode info Wenbo Cao
2025-02-13 18:28 ` Stephen Hemminger [this message]

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=20250213102833.12f6399d@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=caowenbo@mucse.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=thomas@monjalon.net \
    --cc=yaojun@mucse.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).