Skip to contentSkip to conversation

fixes for queue resource free and code style

PATCH In review Xiaoyun wang 2 participants 6 messages May 14, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

cover fixes for queue resource free and code style

This patch adds tx_queues and rx_queues non-null judgment before free tx or rx resources, because some app may set tx_queues or rx_queues to be null before call free resource interfaces, which may cause a segfault, adds pkt_len member update for dst_mbuf when copy a mbuf to a new dst_mbuf, code style format rectification, and adjusts the legality judgment order of RSS RETA table.

--
v1:
- the queues resource free problem fixes
- the pkt len updates of mbuf fixes
- code style modification
- optimize RSS RETA table updates

Xiaoyun wang (4):
net/hinic: the queues resource free problem fixes net/hinic: the pkt len updates of mbuf fixes net/hinic: code style modification net/hinic: optimize RSS RETA table updates

 drivers/net/hinic/base/hinic_pmd_cmdq.h  |  2 +-
 drivers/net/hinic/base/hinic_pmd_hwif.c  |  2 +-
 drivers/net/hinic/base/hinic_pmd_nicio.c |  1 -
 drivers/net/hinic/hinic_pmd_ethdev.c     | 44 +++++++++++++++-----------------
 drivers/net/hinic/hinic_pmd_ethdev.h     | 12 +++++----
 drivers/net/hinic/hinic_pmd_rx.c         |  3 ++-
 drivers/net/hinic/hinic_pmd_tx.c         |  5 +++-
 7 files changed, 36 insertions(+), 33 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/4 net/hinic: the queues resource free problem fixes

Adds tx_queues and rx_queues non-null judgment before free tx or rx resources, because some app may set tx_queues or rx_queues to be null before call free resource interfaces, which may cause a segfault.

Fixes 64727024d2fd ("net/hinic: add device initialization")
---
 drivers/net/hinic/hinic_pmd_rx.c | 3 ++-
 drivers/net/hinic/hinic_pmd_tx.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/hinic/hinic_pmd_rx.c +2 -1
index 4ca74f0..a49769a 100644
@@ -413,7 +413,8 @@ void hinic_free_all_rx_resources(struct rte_eth_dev *eth_dev)
 				HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
 
 	for (q_id = 0; q_id < nic_dev->num_rq; q_id++) {
-		eth_dev->data->rx_queues[q_id] = NULL;
+		if (eth_dev->data->rx_queues != NULL)
+			eth_dev->data->rx_queues[q_id] = NULL;
 
 		if (nic_dev->rxqs[q_id] == NULL)
 			continue;
drivers/net/hinic/hinic_pmd_tx.c +2 -1
index 258f2c1..996e0b2 100644
@@ -1217,7 +1217,8 @@ void hinic_free_all_tx_resources(struct rte_eth_dev *eth_dev)
 				HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
 
 	for (q_id = 0; q_id < nic_dev->num_sq; q_id++) {
-		eth_dev->data->tx_queues[q_id] = NULL;
+		if (eth_dev->data->tx_queues != NULL)
+			eth_dev->data->tx_queues[q_id] = NULL;
 
 		if (nic_dev->txqs[q_id] == NULL)
 			continue;
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/4 net/hinic: the pkt len updates of mbuf fixes

In reply to Xiaoyun wang

When copy a mbuf to a new dst_mbuf, the pkt_len member of dst_mbuf needs to be updated.

Fixes 076221c8fe1d ("net/hinic: add Rx/Tx")
---
 drivers/net/hinic/hinic_pmd_tx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/hinic/hinic_pmd_tx.c +2 -0
index 996e0b2..bd39f93 100644
@@ -313,6 +313,8 @@ static inline struct rte_mbuf *hinic_copy_tx_mbuf(struct hinic_nic_dev *nic_dev,
 		mbuf = mbuf->next;
 	}
 
+	dst_mbuf->pkt_len = dst_mbuf->data_len;
+
 	return dst_mbuf;
 }
 
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/4 net/hinic: code style modification

In reply to Xiaoyun wang

The patch modifies the comments of structures or functions, and adds space for comments, removes extra empty lines and adjusts the print level for VF branches in one sdk interface.

---
 drivers/net/hinic/base/hinic_pmd_cmdq.h  |  2 +-
 drivers/net/hinic/base/hinic_pmd_hwif.c  |  2 +-
 drivers/net/hinic/base/hinic_pmd_nicio.c |  1 -
 drivers/net/hinic/hinic_pmd_ethdev.c     | 28 +++++++++++++---------------
 drivers/net/hinic/hinic_pmd_ethdev.h     | 12 +++++++-----
 5 files changed, 22 insertions(+), 23 deletions(-)
drivers/net/hinic/base/hinic_pmd_cmdq.h +1 -1
index 4ce0a4c..0d5e380 100644
@@ -9,7 +9,7 @@
 
 #define HINIC_SCMD_DATA_LEN		16
 
-/* hiovs pmd use 64, kernel l2nic use 4096 */
+/* pmd driver uses 64, kernel l2nic use 4096 */
 #define	HINIC_CMDQ_DEPTH		64
 
 #define	HINIC_CMDQ_BUF_SIZE		2048U
drivers/net/hinic/base/hinic_pmd_hwif.c +1 -1
index 63fba0d..4578b68 100644
@@ -99,7 +99,7 @@ void hinic_set_pf_status(struct hinic_hwif *hwif, enum hinic_pf_status status)
 	u32 addr  = HINIC_CSR_FUNC_ATTR5_ADDR;
 
 	if (hwif->attr.func_type == TYPE_VF) {
-		PMD_DRV_LOG(ERR, "VF doesn't support set attr5");
+		PMD_DRV_LOG(INFO, "VF doesn't support to set attr5");
 		return;
 	}
 
drivers/net/hinic/base/hinic_pmd_nicio.c +0 -1
index 60c4e14..7f7e11d 100644
@@ -369,7 +369,6 @@ static int init_rq_ctxts(struct hinic_nic_io *nic_io)
 					     HINIC_MOD_L2NIC,
 					     HINIC_UCODE_CMD_MDY_QUEUE_CONTEXT,
 					     cmd_buf, &out_param, 0);
-
 		if ((err) || out_param != 0) {
 			PMD_DRV_LOG(ERR, "Failed to set RQ ctxts");
 			err = -EFAULT;
drivers/net/hinic/hinic_pmd_ethdev.c +13 -15
index 073afa4..8634fe8 100644
@@ -354,7 +354,7 @@ static int hinic_dev_configure(struct rte_eth_dev *dev)
 		return err;
 	}
 
-	/*clear fdir filter flag in function table*/
+	/* clear fdir filter flag in function table */
 	hinic_free_fdir_filter(nic_dev);
 
 	return HINIC_OK;
@@ -440,7 +440,7 @@ static int hinic_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	}
 	nic_dev->rxqs[queue_idx] = rxq;
 
-	/* alloc rx sq hw wqepage*/
+	/* alloc rx sq hw wqe page */
 	rc = hinic_create_rq(hwdev, queue_idx, rq_depth, socket_id);
 	if (rc) {
 		PMD_DRV_LOG(ERR, "Create rxq[%d] failed, dev_name: %s, rq_depth: %d",
@@ -2035,12 +2035,12 @@ static int hinic_rss_conf_get(struct rte_eth_dev *dev,
 }
 
 /**
- * DPDK callback to update the RETA indirection table.
+ * DPDK callback to update the RSS redirection table.
  *
  * @param dev
  *   Pointer to Ethernet device structure.
  * @param reta_conf
- *   Pointer to RETA configuration structure array.
+ *   Pointer to RSS reta configuration data.
  * @param reta_size
  *   Size of the RETA table.
  *
@@ -2102,14 +2102,13 @@ static int hinic_rss_indirtbl_update(struct rte_eth_dev *dev,
 	return HINIC_ERROR;
 }
 
-
 /**
- * DPDK callback to get the RETA indirection table.
+ * DPDK callback to get the RSS indirection table.
  *
  * @param dev
  *   Pointer to Ethernet device structure.
  * @param reta_conf
- *   Pointer to RETA configuration structure array.
+ *   Pointer to RSS reta configuration data.
  * @param reta_size
  *   Size of the RETA table.
  *
@@ -2309,8 +2308,7 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev,
 	for (i = 0; i < HINIC_VPORT_XSTATS_NUM; i++) {
 		snprintf(xstats_names[count].name,
 			 sizeof(xstats_names[count].name),
-			 "%s",
-			 hinic_vport_stats_strings[i].name);
+			 "%s", hinic_vport_stats_strings[i].name);
 		count++;
 	}
 
@@ -2321,13 +2319,13 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev,
 	for (i = 0; i < HINIC_PHYPORT_XSTATS_NUM; i++) {
 		snprintf(xstats_names[count].name,
 			 sizeof(xstats_names[count].name),
-			 "%s",
-			 hinic_phyport_stats_strings[i].name);
+			 "%s", hinic_phyport_stats_strings[i].name);
 		count++;
 	}
 
 	return count;
 }
+
 /**
  *  DPDK callback to set mac address
  *
@@ -2492,19 +2490,19 @@ static int hinic_set_mc_addr_list(struct rte_eth_dev *dev,
 }
 
 /**
- * DPDK callback to manage filter operations
+ * DPDK callback to manage filter control operations
  *
  * @param dev
  *   Pointer to Ethernet device structure.
  * @param filter_type
- *   Filter type.
+ *   Filter type, which just supports generic type.
  * @param filter_op
- *   Operation to perform.
+ *   Filter operation to perform.
  * @param arg
  *   Pointer to operation-specific structure.
  *
  * @return
- *   0 on success, negative errno value on failure.
+ *   0 on success, negative error value otherwise.
  */
 static int hinic_dev_filter_ctrl(struct rte_eth_dev *dev,
 		     enum rte_filter_type filter_type,
drivers/net/hinic/hinic_pmd_ethdev.h +7 -5
index 1cb389d..64b2c81 100644
@@ -53,11 +53,13 @@ struct hinic_5tuple_filter_info {
 	 * used when more than one filter matches.
 	 */
 	uint8_t priority;
-	uint8_t dst_ip_mask:1, /* if mask is 1b, do not compare dst ip. */
-		src_ip_mask:1, /* if mask is 1b, do not compare src ip. */
-		dst_port_mask:1, /* if mask is 1b, do not compare dst port. */
-		src_port_mask:1, /* if mask is 1b, do not compare src port. */
-		proto_mask:1; /* if mask is 1b, do not compare protocol. */
+
+	/* if mask is 1b, do not compare the response bit domain */
+	uint8_t dst_ip_mask:1,
+		src_ip_mask:1,
+		dst_port_mask:1,
+		src_port_mask:1,
+		proto_mask:1;
 };
 
 /* 5tuple filter structure */
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/4 net/hinic: optimize RSS RETA table updates

In reply to Xiaoyun wang

Before updating RSS indirection table, firstly determine whether rq num in RETA table is legal, if it is invalid(such as exceeding the maximum rxq num), driver will not update hw indirection table and return fail.

---
 drivers/net/hinic/hinic_pmd_ethdev.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/hinic/hinic_pmd_ethdev.c +8 -8
index 8634fe8..2f0f33a 100644
@@ -2075,16 +2075,16 @@ static int hinic_rss_indirtbl_update(struct rte_eth_dev *dev,
 	for (i = 0; i < reta_size; i++) {
 		idx = i / RTE_RETA_GROUP_SIZE;
 		shift = i % RTE_RETA_GROUP_SIZE;
-		if (reta_conf[idx].mask & (1ULL << shift))
-			indirtbl[i] = reta_conf[idx].reta[shift];
-	}
 
-	for (i = 0 ; i < reta_size; i++) {
-		if (indirtbl[i] >= nic_dev->num_rq) {
-			PMD_DRV_LOG(ERR, "Invalid reta entry, index: %d, num_rq: %d",
-				    i, nic_dev->num_rq);
-			goto disable_rss;
+		if (reta_conf[idx].reta[shift] >= nic_dev->num_rq) {
+			PMD_DRV_LOG(ERR, "Invalid reta entry, indirtbl[%d]: %d "
+				"exceeds the maximum rxq num: %d", i,
+				reta_conf[idx].reta[shift], nic_dev->num_rq);
+			return -EINVAL;
 		}
+
+		if (reta_conf[idx].mask & (1ULL << shift))
+			indirtbl[i] = reta_conf[idx].reta[shift];
 	}
 
 	err = hinic_rss_set_indir_tbl(nic_dev->hwdev, tmpl_idx, indirtbl);
Signature · 1 line
1.8.3.1
#5 lore raw
In reply to Xiaoyun wang
Quoted 14 lines · Xiaoyun wang

This patch adds tx_queues and rx_queues non-null judgment before free tx or rx resources, because some app may set tx_queues or rx_queues to be null before call free resource interfaces, which may cause a segfault, adds pkt_len member update for dst_mbuf when copy a mbuf to a new dst_mbuf, code style format rectification, and adjusts the legality judgment order of RSS RETA table.

--
v1:
- the queues resource free problem fixes
- the pkt len updates of mbuf fixes
- code style modification
- optimize RSS RETA table updates

Quoted 5 lines

Xiaoyun wang (4):
net/hinic: the queues resource free problem fixes net/hinic: the pkt len updates of mbuf fixes net/hinic: code style modification net/hinic: optimize RSS RETA table updates

Series applied to dpdk-next-net/master, thanks.