[dpdk-stable] patch 'ethdev: fix data type for port id' has been queued to stable release 19.11.6

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Nov 9 19:41:05 CET 2020


Hi,

FYI, your patch has been queued to stable release 19.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/11/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/5c1c95c7ff54e8a7f073c31151d97fbc40151bf1

Thanks.

Luca Boccassi

---
>From 5c1c95c7ff54e8a7f073c31151d97fbc40151bf1 Mon Sep 17 00:00:00 2001
From: Yunjian Wang <wangyunjian at huawei.com>
Date: Wed, 4 Nov 2020 10:57:57 +0800
Subject: [PATCH] ethdev: fix data type for port id

[ upstream commit 4bb02a6f5b7f11aafde1be7bfd08b6e81997b916 ]

The ethdev port id is 16 bits now. This patch fixes the data type
of the variable for 'pid', which changing from uint32_t to uint16_t.

RTE_MAX_ETHPORTS is the maximum number of ports, which customized by
the user. To avoid 16-bit unsigned integer overflow, the valid value
of RTE_MAX_ETHPORTS should be set from 0 to UINT16_MAX, and it is
safer to cut one more port from space.

So we use RTE_BUILD_BUG_ON() to ensure that RTE_MAX_ETHPORTS is less
to UINT16_MAX.

Fixes: 5b7ba31148a8 ("ethdev: add port ownership")

Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
Acked-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
 lib/librte_ethdev/rte_ethdev.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index d74429a9e7..e7d786c5b4 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -408,7 +408,9 @@ is_allocated(const struct rte_eth_dev *ethdev)
 static struct rte_eth_dev *
 _rte_eth_dev_allocated(const char *name)
 {
-	unsigned i;
+	uint16_t i;
+
+	RTE_BUILD_BUG_ON(RTE_MAX_ETHPORTS >= UINT16_MAX);
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
 		if (rte_eth_devices[i].data != NULL &&
@@ -437,7 +439,7 @@ rte_eth_dev_allocated(const char *name)
 static uint16_t
 rte_eth_dev_find_free_port(void)
 {
-	unsigned i;
+	uint16_t i;
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
 		/* Using shared name field to find a free port. */
@@ -800,7 +802,7 @@ rte_eth_dev_get_name_by_port(uint16_t port_id, char *name)
 int
 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)
 {
-	uint32_t pid;
+	uint16_t pid;
 
 	if (name == NULL) {
 		RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
@@ -3954,7 +3956,7 @@ rte_eth_mirror_rule_reset(uint16_t port_id, uint8_t rule_id)
 
 RTE_INIT(eth_dev_init_cb_lists)
 {
-	int i;
+	uint16_t i;
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
 		TAILQ_INIT(&rte_eth_devices[i].link_intr_cbs);
@@ -3967,7 +3969,7 @@ rte_eth_dev_callback_register(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *user_cb;
-	uint32_t next_port; /* size is 32-bit to prevent loop wrap-around */
+	uint16_t next_port;
 	uint16_t last_port;
 
 	if (!cb_fn)
@@ -4030,7 +4032,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 	int ret;
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *cb, *next;
-	uint32_t next_port; /* size is 32-bit to prevent loop wrap-around */
+	uint16_t next_port;
 	uint16_t last_port;
 
 	if (!cb_fn)
@@ -5097,7 +5099,7 @@ static struct rte_eth_dev_switch {
 int
 rte_eth_switch_domain_alloc(uint16_t *domain_id)
 {
-	unsigned int i;
+	uint16_t i;
 
 	*domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;
 
-- 
2.27.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-11-09 18:40:14.027482358 +0000
+++ 0077-ethdev-fix-data-type-for-port-id.patch	2020-11-09 18:40:11.227312776 +0000
@@ -1 +1 @@
-From 4bb02a6f5b7f11aafde1be7bfd08b6e81997b916 Mon Sep 17 00:00:00 2001
+From 5c1c95c7ff54e8a7f073c31151d97fbc40151bf1 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 4bb02a6f5b7f11aafde1be7bfd08b6e81997b916 ]
+
@@ -18 +19,0 @@
-Cc: stable at dpdk.org
@@ -28 +29 @@
-index c5e3ba4218..17ddacc78d 100644
+index d74429a9e7..e7d786c5b4 100644
@@ -31 +32 @@
-@@ -411,7 +411,9 @@ eth_dev_is_allocated(const struct rte_eth_dev *ethdev)
+@@ -408,7 +408,9 @@ is_allocated(const struct rte_eth_dev *ethdev)
@@ -33 +34 @@
- eth_dev_allocated(const char *name)
+ _rte_eth_dev_allocated(const char *name)
@@ -42 +43 @@
-@@ -440,7 +442,7 @@ rte_eth_dev_allocated(const char *name)
+@@ -437,7 +439,7 @@ rte_eth_dev_allocated(const char *name)
@@ -44 +45 @@
- eth_dev_find_free_port(void)
+ rte_eth_dev_find_free_port(void)
@@ -51 +52 @@
-@@ -816,7 +818,7 @@ rte_eth_dev_get_name_by_port(uint16_t port_id, char *name)
+@@ -800,7 +802,7 @@ rte_eth_dev_get_name_by_port(uint16_t port_id, char *name)
@@ -60 +61 @@
-@@ -4293,7 +4295,7 @@ rte_eth_mirror_rule_reset(uint16_t port_id, uint8_t rule_id)
+@@ -3954,7 +3956,7 @@ rte_eth_mirror_rule_reset(uint16_t port_id, uint8_t rule_id)
@@ -69 +70 @@
-@@ -4306,7 +4308,7 @@ rte_eth_dev_callback_register(uint16_t port_id,
+@@ -3967,7 +3969,7 @@ rte_eth_dev_callback_register(uint16_t port_id,
@@ -78 +79 @@
-@@ -4369,7 +4371,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
+@@ -4030,7 +4032,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
@@ -87 +88 @@
-@@ -5426,7 +5428,7 @@ static struct rte_eth_dev_switch {
+@@ -5097,7 +5099,7 @@ static struct rte_eth_dev_switch {


More information about the stable mailing list