Skip to contentSkip to conversation

net/ice: avoid the parsed devargs value being overwritten

PATCH In review Haiyue Wang 2 participants 8 messages Oct 9, 2019 – Oct 16, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: avoid the parsed devargs value being overwritten

If the default dev args 'proto_xtr' is not in the first position, it will overwrite the parsed queue map value, so use an new variable to save the default.

And enhance the error message printing to show the right information.

---
 drivers/net/ice/ice_ethdev.c | 44 +++++++++++++++++++++++++-----------
 drivers/net/ice/ice_ethdev.h |  1 +
 2 files changed, 32 insertions(+), 13 deletions(-)
drivers/net/ice/ice_ethdev.c +31 -13
index 022b58c01..440203247 100644
@@ -428,8 +428,7 @@ parse_queue_proto_xtr(const char *queues, struct ice_devargs *devargs)
 		if (xtr_type < 0)
 			return -1;
 
-		memset(devargs->proto_xtr, xtr_type,
-		       sizeof(devargs->proto_xtr));
+		devargs->proto_xtr_dflt = xtr_type;
 
 		return 0;
 	}
@@ -1369,12 +1368,36 @@ ice_interrupt_handler(void *param)
 	rte_intr_ack(dev->intr_handle);
 }
 
+static void
+ice_init_proto_xtr(struct rte_eth_dev *dev)
+{
+	struct ice_adapter *ad =
+			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct ice_hw *hw = ICE_PF_TO_HW(pf);
+	uint16_t i;
+
+	if (!ice_proto_xtr_support(hw)) {
+		PMD_DRV_LOG(NOTICE, "Protocol extraction is not supported");
+		return;
+	}
+
+	pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0);
+	if (unlikely(pf->proto_xtr == NULL)) {
+		PMD_DRV_LOG(ERR, "No memory for setting up protocol extraction table");
+		return;
+	}
+
+	for (i = 0; i < pf->lan_nb_qps; i++)
+		pf->proto_xtr[i] = ad->devargs.proto_xtr[i] != PROTO_XTR_NONE ?
+				   ad->devargs.proto_xtr[i] :
+				   ad->devargs.proto_xtr_dflt;
+}
+
 /*  Initialize SW parameters of PF */
 static int
 ice_pf_sw_init(struct rte_eth_dev *dev)
 {
-	struct ice_adapter *ad =
-			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct ice_hw *hw = ICE_PF_TO_HW(pf);
 
@@ -1384,15 +1407,7 @@ ice_pf_sw_init(struct rte_eth_dev *dev)
 
 	pf->lan_nb_qps = pf->lan_nb_qp_max;
 
-	if (ice_proto_xtr_support(hw))
-		pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0);
-
-	if (pf->proto_xtr != NULL)
-		rte_memcpy(pf->proto_xtr, ad->devargs.proto_xtr,
-			   RTE_MIN((size_t)pf->lan_nb_qps,
-				   sizeof(ad->devargs.proto_xtr)));
-	else
-		PMD_DRV_LOG(NOTICE, "Protocol extraction is disabled");
+	ice_init_proto_xtr(dev);
 
 	return 0;
 }
@@ -1805,6 +1820,7 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
+	ad->devargs.proto_xtr_dflt = PROTO_XTR_NONE;
 	memset(ad->devargs.proto_xtr, PROTO_XTR_NONE,
 	       sizeof(ad->devargs.proto_xtr));
 
@@ -2126,6 +2142,8 @@ ice_dev_close(struct rte_eth_dev *dev)
 	rte_free(hw->port_info);
 	hw->port_info = NULL;
 	ice_shutdown_all_ctrlq(hw);
+	rte_free(pf->proto_xtr);
+	pf->proto_xtr = NULL;
 
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
drivers/net/ice/ice_ethdev.h +1 -0
index 182c6f611..2fd98817b 100644
@@ -288,6 +288,7 @@ struct ice_pf {
  */
 struct ice_devargs {
 	int safe_mode_support;
+	uint8_t proto_xtr_dflt;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 };
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 12 lines · Haiyue Wang

If the default dev args 'proto_xtr' is not in the first position, it will overwrite the parsed queue map value, so use an new variable to save the default.

And enhance the error message printing to show the right information.

---
drivers/net/ice/ice_ethdev.c | 44 +++++++++++++++++++++++++----------- drivers/net/ice/ice_ethdev.h | 1 +

2 files changed, 32 insertions(+), 13 deletions(-)

[snip]

drivers/net/ice/ice_ethdev.c ice_dev_close(struct rte_eth_dev *dev) · line 2146

Quoted 6 lines
drivers/net/ice/ice_ethdev.c +2 -0
@@ -2126,6 +2142,8 @@ ice_dev_close(struct rte_eth_dev *dev)
 	rte_free(hw->port_info);
 	hw->port_info = NULL;
 	ice_shutdown_all_ctrlq(hw);
+	rte_free(pf->proto_xtr);
+	pf->proto_xtr = NULL;

These two lines seems irrelevant to this patch, I noticed that the resource free operation was contained in the original patch, and they are removed unexpectedly by commit bd513ece3c40 ("net/ice: release port upon close"), sorry for not catching it when reviewing.

Prefer one individual patch for the fix.

Thanks,
Xiaolong

Quoted 18 lines
drivers/net/ice/ice_ethdev.c +0 -0
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
drivers/net/ice/ice_ethdev.h +1 -0
index 182c6f611..2fd98817b 100644
@@ -288,6 +288,7 @@ struct ice_pf {
 */
 struct ice_devargs {
 	int safe_mode_support;
+	uint8_t proto_xtr_dflt;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 };
 
Signature · 1 line
2.17.1
#2 lore raw
Quoted 35 lines

-----Original Message-----
From: Ye, Xiaolong
Sent: Monday, October 14, 2019 16:25
To: Wang, Haiyue <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v1] net/ice: avoid the parsed devargs value being overwritten

Quoted 12 lines · Haiyue Wang

If the default dev args 'proto_xtr' is not in the first position, it will overwrite the parsed queue map value, so use an new variable to save the default.

And enhance the error message printing to show the right information.

---
drivers/net/ice/ice_ethdev.c | 44 +++++++++++++++++++++++++----------- drivers/net/ice/ice_ethdev.h | 1 +

2 files changed, 32 insertions(+), 13 deletions(-)

[snip]

drivers/net/ice/ice_ethdev.c ice_dev_close(struct rte_eth_dev *dev) · line 2146

Quoted 6 lines
drivers/net/ice/ice_ethdev.c +2 -0
@@ -2126,6 +2142,8 @@ ice_dev_close(struct rte_eth_dev *dev)
 	rte_free(hw->port_info);
 	hw->port_info = NULL;
 	ice_shutdown_all_ctrlq(hw);
+	rte_free(pf->proto_xtr);
+	pf->proto_xtr = NULL;

These two lines seems irrelevant to this patch, I noticed that the resource free operation was contained in the original patch, and they are removed unexpectedly by commit bd513ece3c40 ("net/ice: release port upon close"), sorry for not catching it when reviewing.

Quoted 2 lines

Prefer one individual patch for the fix.

Planed to send two patches, but a little lazy. :) Will do this in v2.

Quoted 21 lines

Thanks,
Xiaolong

Quoted 18 lines
drivers/net/ice/ice_ethdev.c +0 -0
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
drivers/net/ice/ice_ethdev.h +1 -1
index 182c6f611..2fd98817b 100644
@@ -288,6 +288,7 @@ struct ice_pf {
 */
 struct ice_devargs {
 	int safe_mode_support;
+	uint8_t proto_xtr_dflt;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 };
 
--

2.17.1

#3 lore raw

v2 cover net/ice: protocol extraction related issues

In reply to Haiyue Wang

v1 -> v2:
Split into two patches, one is fixing a commit

Haiyue Wang (2):
net/ice: fix the missed memory free when dev is closed net/ice: avoid the parsed devargs value being overwritten

 drivers/net/ice/ice_ethdev.c | 44 +++++++++++++++++++++++++-----------
 drivers/net/ice/ice_ethdev.h |  1 +
 2 files changed, 32 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 1/2 net/ice: fix the missed memory free when dev is closed

The original protocol extraction memory free is removed by introducing new design for releasing port upon close.

Fixes bd513ece3c40 ("net/ice: release port upon close")
---
 drivers/net/ice/ice_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ice/ice_ethdev.c +2 -0
index 022b58c01..880d2679b 100644
@@ -2126,6 +2126,8 @@ ice_dev_close(struct rte_eth_dev *dev)
 	rte_free(hw->port_info);
 	hw->port_info = NULL;
 	ice_shutdown_all_ctrlq(hw);
+	rte_free(pf->proto_xtr);
+	pf->proto_xtr = NULL;
 
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
Signature · 1 line
2.17.1
#5 lore raw

PATCH v2 2/2 net/ice: avoid the parsed devargs value being overwritten

In reply to Haiyue Wang

If the default dev args 'proto_xtr' is not in the first position, it will overwrite the parsed queue map value, so use an new variable to save the default.

And enhance the error message printing to show the right information.

---
 drivers/net/ice/ice_ethdev.c | 42 +++++++++++++++++++++++++-----------
 drivers/net/ice/ice_ethdev.h |  1 +
 2 files changed, 30 insertions(+), 13 deletions(-)
drivers/net/ice/ice_ethdev.c +29 -13
index 880d2679b..440203247 100644
@@ -428,8 +428,7 @@ parse_queue_proto_xtr(const char *queues, struct ice_devargs *devargs)
 		if (xtr_type < 0)
 			return -1;
 
-		memset(devargs->proto_xtr, xtr_type,
-		       sizeof(devargs->proto_xtr));
+		devargs->proto_xtr_dflt = xtr_type;
 
 		return 0;
 	}
@@ -1369,12 +1368,36 @@ ice_interrupt_handler(void *param)
 	rte_intr_ack(dev->intr_handle);
 }
 
+static void
+ice_init_proto_xtr(struct rte_eth_dev *dev)
+{
+	struct ice_adapter *ad =
+			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct ice_hw *hw = ICE_PF_TO_HW(pf);
+	uint16_t i;
+
+	if (!ice_proto_xtr_support(hw)) {
+		PMD_DRV_LOG(NOTICE, "Protocol extraction is not supported");
+		return;
+	}
+
+	pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0);
+	if (unlikely(pf->proto_xtr == NULL)) {
+		PMD_DRV_LOG(ERR, "No memory for setting up protocol extraction table");
+		return;
+	}
+
+	for (i = 0; i < pf->lan_nb_qps; i++)
+		pf->proto_xtr[i] = ad->devargs.proto_xtr[i] != PROTO_XTR_NONE ?
+				   ad->devargs.proto_xtr[i] :
+				   ad->devargs.proto_xtr_dflt;
+}
+
 /*  Initialize SW parameters of PF */
 static int
 ice_pf_sw_init(struct rte_eth_dev *dev)
 {
-	struct ice_adapter *ad =
-			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct ice_hw *hw = ICE_PF_TO_HW(pf);
 
@@ -1384,15 +1407,7 @@ ice_pf_sw_init(struct rte_eth_dev *dev)
 
 	pf->lan_nb_qps = pf->lan_nb_qp_max;
 
-	if (ice_proto_xtr_support(hw))
-		pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0);
-
-	if (pf->proto_xtr != NULL)
-		rte_memcpy(pf->proto_xtr, ad->devargs.proto_xtr,
-			   RTE_MIN((size_t)pf->lan_nb_qps,
-				   sizeof(ad->devargs.proto_xtr)));
-	else
-		PMD_DRV_LOG(NOTICE, "Protocol extraction is disabled");
+	ice_init_proto_xtr(dev);
 
 	return 0;
 }
@@ -1805,6 +1820,7 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
+	ad->devargs.proto_xtr_dflt = PROTO_XTR_NONE;
 	memset(ad->devargs.proto_xtr, PROTO_XTR_NONE,
 	       sizeof(ad->devargs.proto_xtr));
 
drivers/net/ice/ice_ethdev.h +1 -0
index 182c6f611..2fd98817b 100644
@@ -288,6 +288,7 @@ struct ice_pf {
  */
 struct ice_devargs {
 	int safe_mode_support;
+	uint8_t proto_xtr_dflt;
 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
 };
 
Signature · 1 line
2.17.1
Reviewed-by on the v2 series
#6 lore raw

Re: [dpdk-dev] [PATCH v2 0/2] net/ice: protocol extraction related issues

In reply to Haiyue Wang
Quoted 14 lines · Haiyue Wang

v1 -> v2:
Split into two patches, one is fixing a commit

Haiyue Wang (2):
net/ice: fix the missed memory free when dev is closed net/ice: avoid the parsed devargs value being overwritten

drivers/net/ice/ice_ethdev.c | 44 +++++++++++++++++++++++++----------- drivers/net/ice/ice_ethdev.h | 1 +

2 files changed, 32 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1

For series:

#7 lore raw

Re: [dpdk-dev] [PATCH v2 0/2] net/ice: protocol extraction related issues

In reply to Haiyue Wang
Quoted 14 lines · Haiyue Wang

v1 -> v2:
Split into two patches, one is fixing a commit

Haiyue Wang (2):
net/ice: fix the missed memory free when dev is closed net/ice: avoid the parsed devargs value being overwritten

drivers/net/ice/ice_ethdev.c | 44 +++++++++++++++++++++++++----------- drivers/net/ice/ice_ethdev.h | 1 +

2 files changed, 32 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1

Series applied to dpdk-next-net-intel.