DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] common/idpf: move PF specific functions from common init
@ 2023-03-21  6:53 beilei.xing
  2023-03-21  7:07 ` [PATCH v2] " beilei.xing
  0 siblings, 1 reply; 12+ messages in thread
From: beilei.xing @ 2023-03-21  6:53 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Move PF reset and PF mailbox initialization functions from
idpf_adapter_init function to xxxx_adapter_ext_init function,
since ther're different between PF and VF support.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/common/idpf/idpf_common_device.c | 72 +++++-------------------
 drivers/common/idpf/idpf_common_device.h | 13 +++++
 drivers/common/idpf/version.map          |  5 ++
 drivers/net/cpfl/cpfl_ethdev.c           | 18 ++++++
 drivers/net/idpf/idpf_ethdev.c           | 51 +++++++++++++++++
 5 files changed, 100 insertions(+), 59 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c
index c5e7bbf66c..3b58bdd41e 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -6,8 +6,8 @@
 #include <idpf_common_device.h>
 #include <idpf_common_virtchnl.h>
 
-static void
-idpf_reset_pf(struct idpf_hw *hw)
+void
+idpf_hw_pf_reset(struct idpf_hw *hw)
 {
 	uint32_t reg;
 
@@ -15,9 +15,8 @@ idpf_reset_pf(struct idpf_hw *hw)
 	IDPF_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
 }
 
-#define IDPF_RESET_WAIT_CNT 100
-static int
-idpf_check_pf_reset_done(struct idpf_hw *hw)
+int
+idpf_hw_pf_reset_check(struct idpf_hw *hw)
 {
 	uint32_t reg;
 	int i;
@@ -33,48 +32,13 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
 	return -EBUSY;
 }
 
-#define CTLQ_NUM 2
-static int
-idpf_init_mbx(struct idpf_hw *hw)
+int
+idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info)
 {
-	struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM] = {
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ATQH,
-				.tail = PF_FW_ATQT,
-				.len = PF_FW_ATQLEN,
-				.bah = PF_FW_ATQBAH,
-				.bal = PF_FW_ATQBAL,
-				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
-				.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
-				.head_mask = PF_FW_ATQH_ATQH_M,
-			}
-		},
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ARQH,
-				.tail = PF_FW_ARQT,
-				.len = PF_FW_ARQLEN,
-				.bah = PF_FW_ARQBAH,
-				.bal = PF_FW_ARQBAL,
-				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
-				.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
-				.head_mask = PF_FW_ARQH_ARQH_M,
-			}
-		}
-	};
 	struct idpf_ctlq_info *ctlq;
 	int ret;
 
-	ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, ctlq_info);
 	if (ret != 0)
 		return ret;
 
@@ -96,6 +60,12 @@ idpf_init_mbx(struct idpf_hw *hw)
 	return ret;
 }
 
+void
+idpf_hw_mbx_deinit(struct idpf_hw *hw)
+{
+	idpf_ctlq_deinit(hw);
+}
+
 static int
 idpf_get_pkt_type(struct idpf_adapter *adapter)
 {
@@ -312,19 +282,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	struct idpf_hw *hw = &adapter->hw;
 	int ret;
 
-	idpf_reset_pf(hw);
-	ret = idpf_check_pf_reset_done(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "IDPF is still resetting");
-		goto err_check_reset;
-	}
-
-	ret = idpf_init_mbx(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to init mailbox");
-		goto err_check_reset;
-	}
-
 	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp",
 					IDPF_DFLT_MBX_BUF_SIZE, 0);
 	if (adapter->mbx_resp == NULL) {
@@ -357,8 +314,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 err_mbx_resp:
-	idpf_ctlq_deinit(hw);
-err_check_reset:
 	return ret;
 }
 
@@ -367,7 +322,6 @@ idpf_adapter_deinit(struct idpf_adapter *adapter)
 {
 	struct idpf_hw *hw = &adapter->hw;
 
-	idpf_ctlq_deinit(hw);
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 
diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index c2dc2f16b9..ac4afd5ab9 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -10,8 +10,11 @@
 #include <base/virtchnl2.h>
 #include <idpf_common_logs.h>
 
+#define IDPF_RESET_WAIT_CNT	100
+
 #define IDPF_RSS_KEY_LEN	52
 
+#define IDPF_CTLQ_NUM		2
 #define IDPF_CTLQ_ID		-1
 #define IDPF_CTLQ_LEN		64
 #define IDPF_DFLT_MBX_BUF_SIZE	4096
@@ -142,6 +145,8 @@ struct idpf_cmd_info {
 	uint32_t out_size;      /* buffer size for response */
 };
 
+struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM];
+
 /* notify current command done. Only call in case execute
  * _atomic_set_cmd successfully.
  */
@@ -180,6 +185,14 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)
 	return !ret;
 }
 
+__rte_internal
+void idpf_hw_pf_reset(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_pf_reset_check(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info);
+__rte_internal
+void idpf_hw_mbx_deinit(struct idpf_hw *hw);
 __rte_internal
 int idpf_adapter_init(struct idpf_adapter *adapter);
 __rte_internal
diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map
index 70334a1b03..7076759024 100644
--- a/drivers/common/idpf/version.map
+++ b/drivers/common/idpf/version.map
@@ -15,6 +15,11 @@ INTERNAL {
 	idpf_dp_splitq_xmit_pkts;
 	idpf_dp_splitq_xmit_pkts_avx512;
 
+	idpf_hw_mbx_deinit;
+	idpf_hw_mbx_init;
+	idpf_hw_pf_reset;
+	idpf_hw_pf_reset_check;
+
 	idpf_qc_rx_thresh_check;
 	idpf_qc_rx_queue_release;
 	idpf_qc_rxq_mbufs_release;
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ede730fd50..21505b86f2 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1165,6 +1165,8 @@ cpfl_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter);
 }
 
+extern struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM];
+
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
 {
@@ -1181,6 +1183,19 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1213,6 +1228,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1323,6 +1340,7 @@ cpfl_adapter_ext_deinit(struct cpfl_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index e02ec2ec5a..c23623c5fc 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1128,6 +1128,41 @@ idpf_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter);
 }
 
+struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ATQH,
+			.tail = PF_FW_ATQT,
+			.len = PF_FW_ATQLEN,
+			.bah = PF_FW_ATQBAH,
+			.bal = PF_FW_ATQBAL,
+			.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+			.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+			.head_mask = PF_FW_ATQH_ATQH_M,
+		}
+	},
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ARQH,
+			.tail = PF_FW_ARQT,
+			.len = PF_FW_ARQLEN,
+			.bah = PF_FW_ARQBAH,
+			.bal = PF_FW_ARQBAL,
+			.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+			.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+			.head_mask = PF_FW_ARQH_ARQH_M,
+		}
+	}
+};
+
 static int
 idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
 {
@@ -1144,6 +1179,19 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1175,6 +1223,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1311,6 +1361,7 @@ idpf_adapter_ext_deinit(struct idpf_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] common/idpf: move PF specific functions from common init
  2023-03-21  6:53 [PATCH] common/idpf: move PF specific functions from common init beilei.xing
@ 2023-03-21  7:07 ` beilei.xing
  2023-04-04 12:41   ` [PATCH v3 0/2] refine common module beilei.xing
  0 siblings, 1 reply; 12+ messages in thread
From: beilei.xing @ 2023-03-21  7:07 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Move PF reset and PF mailbox initialization functions from
idpf_adapter_init function to xxxx_adapter_ext_init function,
since they're different between PF and VF support.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v2 change:
 - fix typo.

 drivers/common/idpf/idpf_common_device.c | 72 +++++-------------------
 drivers/common/idpf/idpf_common_device.h | 13 +++++
 drivers/common/idpf/version.map          |  5 ++
 drivers/net/cpfl/cpfl_ethdev.c           | 18 ++++++
 drivers/net/idpf/idpf_ethdev.c           | 51 +++++++++++++++++
 5 files changed, 100 insertions(+), 59 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c
index c5e7bbf66c..3b58bdd41e 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -6,8 +6,8 @@
 #include <idpf_common_device.h>
 #include <idpf_common_virtchnl.h>
 
-static void
-idpf_reset_pf(struct idpf_hw *hw)
+void
+idpf_hw_pf_reset(struct idpf_hw *hw)
 {
 	uint32_t reg;
 
@@ -15,9 +15,8 @@ idpf_reset_pf(struct idpf_hw *hw)
 	IDPF_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
 }
 
-#define IDPF_RESET_WAIT_CNT 100
-static int
-idpf_check_pf_reset_done(struct idpf_hw *hw)
+int
+idpf_hw_pf_reset_check(struct idpf_hw *hw)
 {
 	uint32_t reg;
 	int i;
@@ -33,48 +32,13 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
 	return -EBUSY;
 }
 
-#define CTLQ_NUM 2
-static int
-idpf_init_mbx(struct idpf_hw *hw)
+int
+idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info)
 {
-	struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM] = {
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ATQH,
-				.tail = PF_FW_ATQT,
-				.len = PF_FW_ATQLEN,
-				.bah = PF_FW_ATQBAH,
-				.bal = PF_FW_ATQBAL,
-				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
-				.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
-				.head_mask = PF_FW_ATQH_ATQH_M,
-			}
-		},
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ARQH,
-				.tail = PF_FW_ARQT,
-				.len = PF_FW_ARQLEN,
-				.bah = PF_FW_ARQBAH,
-				.bal = PF_FW_ARQBAL,
-				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
-				.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
-				.head_mask = PF_FW_ARQH_ARQH_M,
-			}
-		}
-	};
 	struct idpf_ctlq_info *ctlq;
 	int ret;
 
-	ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, ctlq_info);
 	if (ret != 0)
 		return ret;
 
@@ -96,6 +60,12 @@ idpf_init_mbx(struct idpf_hw *hw)
 	return ret;
 }
 
+void
+idpf_hw_mbx_deinit(struct idpf_hw *hw)
+{
+	idpf_ctlq_deinit(hw);
+}
+
 static int
 idpf_get_pkt_type(struct idpf_adapter *adapter)
 {
@@ -312,19 +282,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	struct idpf_hw *hw = &adapter->hw;
 	int ret;
 
-	idpf_reset_pf(hw);
-	ret = idpf_check_pf_reset_done(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "IDPF is still resetting");
-		goto err_check_reset;
-	}
-
-	ret = idpf_init_mbx(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to init mailbox");
-		goto err_check_reset;
-	}
-
 	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp",
 					IDPF_DFLT_MBX_BUF_SIZE, 0);
 	if (adapter->mbx_resp == NULL) {
@@ -357,8 +314,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 err_mbx_resp:
-	idpf_ctlq_deinit(hw);
-err_check_reset:
 	return ret;
 }
 
@@ -367,7 +322,6 @@ idpf_adapter_deinit(struct idpf_adapter *adapter)
 {
 	struct idpf_hw *hw = &adapter->hw;
 
-	idpf_ctlq_deinit(hw);
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 
diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index c2dc2f16b9..ac4afd5ab9 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -10,8 +10,11 @@
 #include <base/virtchnl2.h>
 #include <idpf_common_logs.h>
 
+#define IDPF_RESET_WAIT_CNT	100
+
 #define IDPF_RSS_KEY_LEN	52
 
+#define IDPF_CTLQ_NUM		2
 #define IDPF_CTLQ_ID		-1
 #define IDPF_CTLQ_LEN		64
 #define IDPF_DFLT_MBX_BUF_SIZE	4096
@@ -142,6 +145,8 @@ struct idpf_cmd_info {
 	uint32_t out_size;      /* buffer size for response */
 };
 
+struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM];
+
 /* notify current command done. Only call in case execute
  * _atomic_set_cmd successfully.
  */
@@ -180,6 +185,14 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)
 	return !ret;
 }
 
+__rte_internal
+void idpf_hw_pf_reset(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_pf_reset_check(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info);
+__rte_internal
+void idpf_hw_mbx_deinit(struct idpf_hw *hw);
 __rte_internal
 int idpf_adapter_init(struct idpf_adapter *adapter);
 __rte_internal
diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map
index 70334a1b03..7076759024 100644
--- a/drivers/common/idpf/version.map
+++ b/drivers/common/idpf/version.map
@@ -15,6 +15,11 @@ INTERNAL {
 	idpf_dp_splitq_xmit_pkts;
 	idpf_dp_splitq_xmit_pkts_avx512;
 
+	idpf_hw_mbx_deinit;
+	idpf_hw_mbx_init;
+	idpf_hw_pf_reset;
+	idpf_hw_pf_reset_check;
+
 	idpf_qc_rx_thresh_check;
 	idpf_qc_rx_queue_release;
 	idpf_qc_rxq_mbufs_release;
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ede730fd50..21505b86f2 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1165,6 +1165,8 @@ cpfl_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter);
 }
 
+extern struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM];
+
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
 {
@@ -1181,6 +1183,19 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1213,6 +1228,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1323,6 +1340,7 @@ cpfl_adapter_ext_deinit(struct cpfl_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index e02ec2ec5a..c23623c5fc 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1128,6 +1128,41 @@ idpf_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter);
 }
 
+struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ATQH,
+			.tail = PF_FW_ATQT,
+			.len = PF_FW_ATQLEN,
+			.bah = PF_FW_ATQBAH,
+			.bal = PF_FW_ATQBAL,
+			.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+			.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+			.head_mask = PF_FW_ATQH_ATQH_M,
+		}
+	},
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ARQH,
+			.tail = PF_FW_ARQT,
+			.len = PF_FW_ARQLEN,
+			.bah = PF_FW_ARQBAH,
+			.bal = PF_FW_ARQBAL,
+			.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+			.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+			.head_mask = PF_FW_ARQH_ARQH_M,
+		}
+	}
+};
+
 static int
 idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
 {
@@ -1144,6 +1179,19 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1175,6 +1223,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1311,6 +1361,7 @@ idpf_adapter_ext_deinit(struct idpf_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 0/2] refine common module
  2023-03-21  7:07 ` [PATCH v2] " beilei.xing
@ 2023-04-04 12:41   ` beilei.xing
  2023-04-04 12:41     ` [PATCH v3 1/2] common/idpf: move PF specific functions from common init beilei.xing
                       ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: beilei.xing @ 2023-04-04 12:41 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Refine common module to support different configuration for
different PMDs.

V3 changes:
 - refine capability get.

Beilei Xing (2):
  common/idpf: move PF specific functions from common init
  common/idpf: refine capability get

 drivers/common/idpf/idpf_common_device.c   | 72 +++--------------
 drivers/common/idpf/idpf_common_device.h   | 11 +++
 drivers/common/idpf/idpf_common_virtchnl.c | 45 +----------
 drivers/common/idpf/version.map            |  5 ++
 drivers/net/cpfl/cpfl_ethdev.c             | 92 ++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.c             | 91 +++++++++++++++++++++
 6 files changed, 215 insertions(+), 101 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 1/2] common/idpf: move PF specific functions from common init
  2023-04-04 12:41   ` [PATCH v3 0/2] refine common module beilei.xing
@ 2023-04-04 12:41     ` beilei.xing
  2023-04-04 12:41     ` [PATCH v3 2/2] common/idpf: refine capability get beilei.xing
  2023-04-06  7:42     ` [PATCH v4 0/2] refine common module beilei.xing
  2 siblings, 0 replies; 12+ messages in thread
From: beilei.xing @ 2023-04-04 12:41 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Move PF reset and PF mailbox initialization functions from
idpf_adapter_init function to xxxx_adapter_ext_init function,
since they're different between PF and VF support.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/common/idpf/idpf_common_device.c | 72 +++++-------------------
 drivers/common/idpf/idpf_common_device.h | 11 ++++
 drivers/common/idpf/version.map          |  5 ++
 drivers/net/cpfl/cpfl_ethdev.c           | 51 +++++++++++++++++
 drivers/net/idpf/idpf_ethdev.c           | 51 +++++++++++++++++
 5 files changed, 131 insertions(+), 59 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c
index c5e7bbf66c..3b58bdd41e 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -6,8 +6,8 @@
 #include <idpf_common_device.h>
 #include <idpf_common_virtchnl.h>
 
-static void
-idpf_reset_pf(struct idpf_hw *hw)
+void
+idpf_hw_pf_reset(struct idpf_hw *hw)
 {
 	uint32_t reg;
 
@@ -15,9 +15,8 @@ idpf_reset_pf(struct idpf_hw *hw)
 	IDPF_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
 }
 
-#define IDPF_RESET_WAIT_CNT 100
-static int
-idpf_check_pf_reset_done(struct idpf_hw *hw)
+int
+idpf_hw_pf_reset_check(struct idpf_hw *hw)
 {
 	uint32_t reg;
 	int i;
@@ -33,48 +32,13 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
 	return -EBUSY;
 }
 
-#define CTLQ_NUM 2
-static int
-idpf_init_mbx(struct idpf_hw *hw)
+int
+idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info)
 {
-	struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM] = {
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ATQH,
-				.tail = PF_FW_ATQT,
-				.len = PF_FW_ATQLEN,
-				.bah = PF_FW_ATQBAH,
-				.bal = PF_FW_ATQBAL,
-				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
-				.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
-				.head_mask = PF_FW_ATQH_ATQH_M,
-			}
-		},
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ARQH,
-				.tail = PF_FW_ARQT,
-				.len = PF_FW_ARQLEN,
-				.bah = PF_FW_ARQBAH,
-				.bal = PF_FW_ARQBAL,
-				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
-				.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
-				.head_mask = PF_FW_ARQH_ARQH_M,
-			}
-		}
-	};
 	struct idpf_ctlq_info *ctlq;
 	int ret;
 
-	ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, ctlq_info);
 	if (ret != 0)
 		return ret;
 
@@ -96,6 +60,12 @@ idpf_init_mbx(struct idpf_hw *hw)
 	return ret;
 }
 
+void
+idpf_hw_mbx_deinit(struct idpf_hw *hw)
+{
+	idpf_ctlq_deinit(hw);
+}
+
 static int
 idpf_get_pkt_type(struct idpf_adapter *adapter)
 {
@@ -312,19 +282,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	struct idpf_hw *hw = &adapter->hw;
 	int ret;
 
-	idpf_reset_pf(hw);
-	ret = idpf_check_pf_reset_done(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "IDPF is still resetting");
-		goto err_check_reset;
-	}
-
-	ret = idpf_init_mbx(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to init mailbox");
-		goto err_check_reset;
-	}
-
 	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp",
 					IDPF_DFLT_MBX_BUF_SIZE, 0);
 	if (adapter->mbx_resp == NULL) {
@@ -357,8 +314,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 err_mbx_resp:
-	idpf_ctlq_deinit(hw);
-err_check_reset:
 	return ret;
 }
 
@@ -367,7 +322,6 @@ idpf_adapter_deinit(struct idpf_adapter *adapter)
 {
 	struct idpf_hw *hw = &adapter->hw;
 
-	idpf_ctlq_deinit(hw);
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 
diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index c2dc2f16b9..7cf2355bc9 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -10,8 +10,11 @@
 #include <base/virtchnl2.h>
 #include <idpf_common_logs.h>
 
+#define IDPF_RESET_WAIT_CNT	100
+
 #define IDPF_RSS_KEY_LEN	52
 
+#define IDPF_CTLQ_NUM		2
 #define IDPF_CTLQ_ID		-1
 #define IDPF_CTLQ_LEN		64
 #define IDPF_DFLT_MBX_BUF_SIZE	4096
@@ -180,6 +183,14 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)
 	return !ret;
 }
 
+__rte_internal
+void idpf_hw_pf_reset(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_pf_reset_check(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info);
+__rte_internal
+void idpf_hw_mbx_deinit(struct idpf_hw *hw);
 __rte_internal
 int idpf_adapter_init(struct idpf_adapter *adapter);
 __rte_internal
diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map
index 70334a1b03..7076759024 100644
--- a/drivers/common/idpf/version.map
+++ b/drivers/common/idpf/version.map
@@ -15,6 +15,11 @@ INTERNAL {
 	idpf_dp_splitq_xmit_pkts;
 	idpf_dp_splitq_xmit_pkts_avx512;
 
+	idpf_hw_mbx_deinit;
+	idpf_hw_mbx_init;
+	idpf_hw_pf_reset;
+	idpf_hw_pf_reset_check;
+
 	idpf_qc_rx_thresh_check;
 	idpf_qc_rx_queue_release;
 	idpf_qc_rxq_mbufs_release;
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ede730fd50..d3c50619ea 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1165,6 +1165,41 @@ cpfl_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter);
 }
 
+static struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ATQH,
+			.tail = PF_FW_ATQT,
+			.len = PF_FW_ATQLEN,
+			.bah = PF_FW_ATQBAH,
+			.bal = PF_FW_ATQBAL,
+			.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+			.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+			.head_mask = PF_FW_ATQH_ATQH_M,
+		}
+	},
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ARQH,
+			.tail = PF_FW_ARQT,
+			.len = PF_FW_ARQLEN,
+			.bah = PF_FW_ARQBAH,
+			.bal = PF_FW_ARQBAL,
+			.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+			.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+			.head_mask = PF_FW_ARQH_ARQH_M,
+		}
+	}
+};
+
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
 {
@@ -1181,6 +1216,19 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1213,6 +1261,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1323,6 +1373,7 @@ cpfl_adapter_ext_deinit(struct cpfl_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index e02ec2ec5a..662a8a806a 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1128,6 +1128,41 @@ idpf_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter);
 }
 
+static struct idpf_ctlq_create_info idpf_ctlq_info[IDPF_CTLQ_NUM] = {
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ATQH,
+			.tail = PF_FW_ATQT,
+			.len = PF_FW_ATQLEN,
+			.bah = PF_FW_ATQBAH,
+			.bal = PF_FW_ATQBAL,
+			.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+			.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+			.head_mask = PF_FW_ATQH_ATQH_M,
+		}
+	},
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ARQH,
+			.tail = PF_FW_ARQT,
+			.len = PF_FW_ARQLEN,
+			.bah = PF_FW_ARQBAH,
+			.bal = PF_FW_ARQBAL,
+			.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+			.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+			.head_mask = PF_FW_ARQH_ARQH_M,
+		}
+	}
+};
+
 static int
 idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
 {
@@ -1144,6 +1179,19 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, idpf_ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1175,6 +1223,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1311,6 +1361,7 @@ idpf_adapter_ext_deinit(struct idpf_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 2/2] common/idpf: refine capability get
  2023-04-04 12:41   ` [PATCH v3 0/2] refine common module beilei.xing
  2023-04-04 12:41     ` [PATCH v3 1/2] common/idpf: move PF specific functions from common init beilei.xing
@ 2023-04-04 12:41     ` beilei.xing
  2023-04-06  7:42     ` [PATCH v4 0/2] refine common module beilei.xing
  2 siblings, 0 replies; 12+ messages in thread
From: beilei.xing @ 2023-04-04 12:41 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Initialize required capability in PMD, and refine
idpf_vc_caps_get function. Then different PMDs can
require different capability.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/common/idpf/idpf_common_virtchnl.c | 45 ++--------------------
 drivers/net/cpfl/cpfl_ethdev.c             | 41 ++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.c             | 40 +++++++++++++++++++
 3 files changed, 84 insertions(+), 42 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_virtchnl.c b/drivers/common/idpf/idpf_common_virtchnl.c
index 9ee7259539..a4e129062e 100644
--- a/drivers/common/idpf/idpf_common_virtchnl.c
+++ b/drivers/common/idpf/idpf_common_virtchnl.c
@@ -278,51 +278,12 @@ idpf_vc_api_version_check(struct idpf_adapter *adapter)
 int
 idpf_vc_caps_get(struct idpf_adapter *adapter)
 {
-	struct virtchnl2_get_capabilities caps_msg;
 	struct idpf_cmd_info args;
 	int err;
 
-	memset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities));
-
-	caps_msg.csum_caps =
-		VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
-		VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
-		VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
-		VIRTCHNL2_CAP_RX_CSUM_GENERIC;
-
-	caps_msg.rss_caps =
-		VIRTCHNL2_CAP_RSS_IPV4_TCP             |
-		VIRTCHNL2_CAP_RSS_IPV4_UDP             |
-		VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
-		VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
-		VIRTCHNL2_CAP_RSS_IPV6_TCP             |
-		VIRTCHNL2_CAP_RSS_IPV6_UDP             |
-		VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
-		VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
-		VIRTCHNL2_CAP_RSS_IPV4_AH              |
-		VIRTCHNL2_CAP_RSS_IPV4_ESP             |
-		VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
-		VIRTCHNL2_CAP_RSS_IPV6_AH              |
-		VIRTCHNL2_CAP_RSS_IPV6_ESP             |
-		VIRTCHNL2_CAP_RSS_IPV6_AH_ESP;
-
-	caps_msg.other_caps = VIRTCHNL2_CAP_WB_ON_ITR;
-
 	args.ops = VIRTCHNL2_OP_GET_CAPS;
-	args.in_args = (uint8_t *)&caps_msg;
-	args.in_args_size = sizeof(caps_msg);
+	args.in_args = (uint8_t *)&adapter->caps;
+	args.in_args_size = sizeof(struct virtchnl2_get_capabilities);
 	args.out_buffer = adapter->mbx_resp;
 	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
 
@@ -333,7 +294,7 @@ idpf_vc_caps_get(struct idpf_adapter *adapter)
 		return err;
 	}
 
-	rte_memcpy(&adapter->caps, args.out_buffer, sizeof(caps_msg));
+	rte_memcpy(&adapter->caps, args.out_buffer, sizeof(struct virtchnl2_get_capabilities));
 
 	return 0;
 }
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index d3c50619ea..186ccb3095 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1200,6 +1200,45 @@ static struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
 	}
 };
 
+static struct virtchnl2_get_capabilities req_caps = {
+	.csum_caps =
+	VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
+	VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_GENERIC,
+
+	.rss_caps =
+	VIRTCHNL2_CAP_RSS_IPV4_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV4_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV6_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV6_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV4_AH              |
+	VIRTCHNL2_CAP_RSS_IPV4_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
+	VIRTCHNL2_CAP_RSS_IPV6_AH              |
+	VIRTCHNL2_CAP_RSS_IPV6_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV6_AH_ESP,
+
+	.other_caps = VIRTCHNL2_CAP_WB_ON_ITR  |
+	VIRTCHNL2_CAP_PTP
+};
+
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
 {
@@ -1229,6 +1268,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 		goto err_reset_check;
 	}
 
+	rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 662a8a806a..18c152b598 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1163,6 +1163,44 @@ static struct idpf_ctlq_create_info idpf_ctlq_info[IDPF_CTLQ_NUM] = {
 	}
 };
 
+static struct virtchnl2_get_capabilities req_caps = {
+	.csum_caps =
+	VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
+	VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_GENERIC,
+
+	.rss_caps =
+	VIRTCHNL2_CAP_RSS_IPV4_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV4_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV6_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV6_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV4_AH              |
+	VIRTCHNL2_CAP_RSS_IPV4_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
+	VIRTCHNL2_CAP_RSS_IPV6_AH              |
+	VIRTCHNL2_CAP_RSS_IPV6_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV6_AH_ESP,
+
+	.other_caps = VIRTCHNL2_CAP_WB_ON_ITR
+};
+
 static int
 idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
 {
@@ -1192,6 +1230,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 		goto err_reset_check;
 	}
 
+	rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 0/2] refine common module
  2023-04-04 12:41   ` [PATCH v3 0/2] refine common module beilei.xing
  2023-04-04 12:41     ` [PATCH v3 1/2] common/idpf: move PF specific functions from common init beilei.xing
  2023-04-04 12:41     ` [PATCH v3 2/2] common/idpf: refine capability get beilei.xing
@ 2023-04-06  7:42     ` beilei.xing
  2023-04-06  7:42       ` [PATCH v4 1/2] common/idpf: move PF specific functions from common init beilei.xing
                         ` (2 more replies)
  2 siblings, 3 replies; 12+ messages in thread
From: beilei.xing @ 2023-04-06  7:42 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Refine common module to support different configuration for
different PMDs.

V4 changes:
 - No need to require PTP CAP for CPFL. 
V3 changes:
 - refine capability get.

Beilei Xing (2):
  common/idpf: move PF specific functions from common init
  common/idpf: refine capability get

 drivers/common/idpf/idpf_common_device.c   | 72 ++++-------------
 drivers/common/idpf/idpf_common_device.h   | 11 +++
 drivers/common/idpf/idpf_common_virtchnl.c | 45 +----------
 drivers/common/idpf/version.map            |  5 ++
 drivers/net/cpfl/cpfl_ethdev.c             | 91 ++++++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.c             | 91 ++++++++++++++++++++++
 6 files changed, 214 insertions(+), 101 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 1/2] common/idpf: move PF specific functions from common init
  2023-04-06  7:42     ` [PATCH v4 0/2] refine common module beilei.xing
@ 2023-04-06  7:42       ` beilei.xing
  2023-04-23  8:25         ` Wu, Jingjing
  2023-04-06  7:42       ` [PATCH v4 2/2] common/idpf: refine capability get beilei.xing
  2023-04-24  8:08       ` [PATCH v5] " beilei.xing
  2 siblings, 1 reply; 12+ messages in thread
From: beilei.xing @ 2023-04-06  7:42 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Move PF reset and PF mailbox initialization functions from
idpf_adapter_init function to xxxx_adapter_ext_init function,
since they're different between PF and VF support.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/common/idpf/idpf_common_device.c | 72 +++++-------------------
 drivers/common/idpf/idpf_common_device.h | 11 ++++
 drivers/common/idpf/version.map          |  5 ++
 drivers/net/cpfl/cpfl_ethdev.c           | 51 +++++++++++++++++
 drivers/net/idpf/idpf_ethdev.c           | 51 +++++++++++++++++
 5 files changed, 131 insertions(+), 59 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c
index c5e7bbf66c..3b58bdd41e 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -6,8 +6,8 @@
 #include <idpf_common_device.h>
 #include <idpf_common_virtchnl.h>
 
-static void
-idpf_reset_pf(struct idpf_hw *hw)
+void
+idpf_hw_pf_reset(struct idpf_hw *hw)
 {
 	uint32_t reg;
 
@@ -15,9 +15,8 @@ idpf_reset_pf(struct idpf_hw *hw)
 	IDPF_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
 }
 
-#define IDPF_RESET_WAIT_CNT 100
-static int
-idpf_check_pf_reset_done(struct idpf_hw *hw)
+int
+idpf_hw_pf_reset_check(struct idpf_hw *hw)
 {
 	uint32_t reg;
 	int i;
@@ -33,48 +32,13 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
 	return -EBUSY;
 }
 
-#define CTLQ_NUM 2
-static int
-idpf_init_mbx(struct idpf_hw *hw)
+int
+idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info)
 {
-	struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM] = {
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ATQH,
-				.tail = PF_FW_ATQT,
-				.len = PF_FW_ATQLEN,
-				.bah = PF_FW_ATQBAH,
-				.bal = PF_FW_ATQBAL,
-				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
-				.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
-				.head_mask = PF_FW_ATQH_ATQH_M,
-			}
-		},
-		{
-			.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
-			.id = IDPF_CTLQ_ID,
-			.len = IDPF_CTLQ_LEN,
-			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
-			.reg = {
-				.head = PF_FW_ARQH,
-				.tail = PF_FW_ARQT,
-				.len = PF_FW_ARQLEN,
-				.bah = PF_FW_ARQBAH,
-				.bal = PF_FW_ARQBAL,
-				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
-				.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
-				.head_mask = PF_FW_ARQH_ARQH_M,
-			}
-		}
-	};
 	struct idpf_ctlq_info *ctlq;
 	int ret;
 
-	ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+	ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, ctlq_info);
 	if (ret != 0)
 		return ret;
 
@@ -96,6 +60,12 @@ idpf_init_mbx(struct idpf_hw *hw)
 	return ret;
 }
 
+void
+idpf_hw_mbx_deinit(struct idpf_hw *hw)
+{
+	idpf_ctlq_deinit(hw);
+}
+
 static int
 idpf_get_pkt_type(struct idpf_adapter *adapter)
 {
@@ -312,19 +282,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	struct idpf_hw *hw = &adapter->hw;
 	int ret;
 
-	idpf_reset_pf(hw);
-	ret = idpf_check_pf_reset_done(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "IDPF is still resetting");
-		goto err_check_reset;
-	}
-
-	ret = idpf_init_mbx(hw);
-	if (ret != 0) {
-		DRV_LOG(ERR, "Failed to init mailbox");
-		goto err_check_reset;
-	}
-
 	adapter->mbx_resp = rte_zmalloc("idpf_adapter_mbx_resp",
 					IDPF_DFLT_MBX_BUF_SIZE, 0);
 	if (adapter->mbx_resp == NULL) {
@@ -357,8 +314,6 @@ idpf_adapter_init(struct idpf_adapter *adapter)
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 err_mbx_resp:
-	idpf_ctlq_deinit(hw);
-err_check_reset:
 	return ret;
 }
 
@@ -367,7 +322,6 @@ idpf_adapter_deinit(struct idpf_adapter *adapter)
 {
 	struct idpf_hw *hw = &adapter->hw;
 
-	idpf_ctlq_deinit(hw);
 	rte_free(adapter->mbx_resp);
 	adapter->mbx_resp = NULL;
 
diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index c2dc2f16b9..7cf2355bc9 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -10,8 +10,11 @@
 #include <base/virtchnl2.h>
 #include <idpf_common_logs.h>
 
+#define IDPF_RESET_WAIT_CNT	100
+
 #define IDPF_RSS_KEY_LEN	52
 
+#define IDPF_CTLQ_NUM		2
 #define IDPF_CTLQ_ID		-1
 #define IDPF_CTLQ_LEN		64
 #define IDPF_DFLT_MBX_BUF_SIZE	4096
@@ -180,6 +183,14 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)
 	return !ret;
 }
 
+__rte_internal
+void idpf_hw_pf_reset(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_pf_reset_check(struct idpf_hw *hw);
+__rte_internal
+int idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info);
+__rte_internal
+void idpf_hw_mbx_deinit(struct idpf_hw *hw);
 __rte_internal
 int idpf_adapter_init(struct idpf_adapter *adapter);
 __rte_internal
diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map
index 70334a1b03..7076759024 100644
--- a/drivers/common/idpf/version.map
+++ b/drivers/common/idpf/version.map
@@ -15,6 +15,11 @@ INTERNAL {
 	idpf_dp_splitq_xmit_pkts;
 	idpf_dp_splitq_xmit_pkts_avx512;
 
+	idpf_hw_mbx_deinit;
+	idpf_hw_mbx_init;
+	idpf_hw_pf_reset;
+	idpf_hw_pf_reset_check;
+
 	idpf_qc_rx_thresh_check;
 	idpf_qc_rx_queue_release;
 	idpf_qc_rxq_mbufs_release;
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ede730fd50..d3c50619ea 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1165,6 +1165,41 @@ cpfl_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter);
 }
 
+static struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ATQH,
+			.tail = PF_FW_ATQT,
+			.len = PF_FW_ATQLEN,
+			.bah = PF_FW_ATQBAH,
+			.bal = PF_FW_ATQBAL,
+			.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+			.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+			.head_mask = PF_FW_ATQH_ATQH_M,
+		}
+	},
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ARQH,
+			.tail = PF_FW_ARQT,
+			.len = PF_FW_ARQLEN,
+			.bah = PF_FW_ARQBAH,
+			.bal = PF_FW_ARQBAL,
+			.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+			.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+			.head_mask = PF_FW_ARQH_ARQH_M,
+		}
+	}
+};
+
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
 {
@@ -1181,6 +1216,19 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1213,6 +1261,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1323,6 +1373,7 @@ cpfl_adapter_ext_deinit(struct cpfl_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index e02ec2ec5a..662a8a806a 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1128,6 +1128,41 @@ idpf_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter);
 }
 
+static struct idpf_ctlq_create_info idpf_ctlq_info[IDPF_CTLQ_NUM] = {
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ATQH,
+			.tail = PF_FW_ATQT,
+			.len = PF_FW_ATQLEN,
+			.bah = PF_FW_ATQBAH,
+			.bal = PF_FW_ATQBAL,
+			.len_mask = PF_FW_ATQLEN_ATQLEN_M,
+			.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
+			.head_mask = PF_FW_ATQH_ATQH_M,
+		}
+	},
+	{
+		.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
+		.id = IDPF_CTLQ_ID,
+		.len = IDPF_CTLQ_LEN,
+		.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
+		.reg = {
+			.head = PF_FW_ARQH,
+			.tail = PF_FW_ARQT,
+			.len = PF_FW_ARQLEN,
+			.bah = PF_FW_ARQBAH,
+			.bal = PF_FW_ARQBAL,
+			.len_mask = PF_FW_ARQLEN_ARQLEN_M,
+			.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
+			.head_mask = PF_FW_ARQH_ARQH_M,
+		}
+	}
+};
+
 static int
 idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
 {
@@ -1144,6 +1179,19 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	idpf_hw_pf_reset(hw);
+	ret = idpf_hw_pf_reset_check(hw);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "PF is still resetting");
+		goto err_reset_check;
+	}
+
+	ret = idpf_hw_mbx_init(hw, idpf_ctlq_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init mailbox");
+		goto err_reset_check;
+	}
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
@@ -1175,6 +1223,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(base);
 err_adapter_init:
+	idpf_hw_mbx_deinit(hw);
+err_reset_check:
 	return ret;
 }
 
@@ -1311,6 +1361,7 @@ idpf_adapter_ext_deinit(struct idpf_adapter_ext *adapter)
 {
 	rte_eal_alarm_cancel(idpf_dev_alarm_handler, adapter);
 	idpf_adapter_deinit(&adapter->base);
+	idpf_hw_mbx_deinit(&adapter->base.hw);
 
 	rte_free(adapter->vports);
 	adapter->vports = NULL;
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 2/2] common/idpf: refine capability get
  2023-04-06  7:42     ` [PATCH v4 0/2] refine common module beilei.xing
  2023-04-06  7:42       ` [PATCH v4 1/2] common/idpf: move PF specific functions from common init beilei.xing
@ 2023-04-06  7:42       ` beilei.xing
  2023-04-24  8:08       ` [PATCH v5] " beilei.xing
  2 siblings, 0 replies; 12+ messages in thread
From: beilei.xing @ 2023-04-06  7:42 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Initialize required capability in PMD, and refine
idpf_vc_caps_get function. Then different PMDs can
require different capability.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/common/idpf/idpf_common_virtchnl.c | 45 ++--------------------
 drivers/net/cpfl/cpfl_ethdev.c             | 40 +++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.c             | 40 +++++++++++++++++++
 3 files changed, 83 insertions(+), 42 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_virtchnl.c b/drivers/common/idpf/idpf_common_virtchnl.c
index 9ee7259539..a4e129062e 100644
--- a/drivers/common/idpf/idpf_common_virtchnl.c
+++ b/drivers/common/idpf/idpf_common_virtchnl.c
@@ -278,51 +278,12 @@ idpf_vc_api_version_check(struct idpf_adapter *adapter)
 int
 idpf_vc_caps_get(struct idpf_adapter *adapter)
 {
-	struct virtchnl2_get_capabilities caps_msg;
 	struct idpf_cmd_info args;
 	int err;
 
-	memset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities));
-
-	caps_msg.csum_caps =
-		VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
-		VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
-		VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
-		VIRTCHNL2_CAP_RX_CSUM_GENERIC;
-
-	caps_msg.rss_caps =
-		VIRTCHNL2_CAP_RSS_IPV4_TCP             |
-		VIRTCHNL2_CAP_RSS_IPV4_UDP             |
-		VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
-		VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
-		VIRTCHNL2_CAP_RSS_IPV6_TCP             |
-		VIRTCHNL2_CAP_RSS_IPV6_UDP             |
-		VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
-		VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
-		VIRTCHNL2_CAP_RSS_IPV4_AH              |
-		VIRTCHNL2_CAP_RSS_IPV4_ESP             |
-		VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
-		VIRTCHNL2_CAP_RSS_IPV6_AH              |
-		VIRTCHNL2_CAP_RSS_IPV6_ESP             |
-		VIRTCHNL2_CAP_RSS_IPV6_AH_ESP;
-
-	caps_msg.other_caps = VIRTCHNL2_CAP_WB_ON_ITR;
-
 	args.ops = VIRTCHNL2_OP_GET_CAPS;
-	args.in_args = (uint8_t *)&caps_msg;
-	args.in_args_size = sizeof(caps_msg);
+	args.in_args = (uint8_t *)&adapter->caps;
+	args.in_args_size = sizeof(struct virtchnl2_get_capabilities);
 	args.out_buffer = adapter->mbx_resp;
 	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
 
@@ -333,7 +294,7 @@ idpf_vc_caps_get(struct idpf_adapter *adapter)
 		return err;
 	}
 
-	rte_memcpy(&adapter->caps, args.out_buffer, sizeof(caps_msg));
+	rte_memcpy(&adapter->caps, args.out_buffer, sizeof(struct virtchnl2_get_capabilities));
 
 	return 0;
 }
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index d3c50619ea..306b8ad769 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1200,6 +1200,44 @@ static struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
 	}
 };
 
+static struct virtchnl2_get_capabilities req_caps = {
+	.csum_caps =
+	VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
+	VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_GENERIC,
+
+	.rss_caps =
+	VIRTCHNL2_CAP_RSS_IPV4_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV4_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV6_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV6_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV4_AH              |
+	VIRTCHNL2_CAP_RSS_IPV4_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
+	VIRTCHNL2_CAP_RSS_IPV6_AH              |
+	VIRTCHNL2_CAP_RSS_IPV6_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV6_AH_ESP,
+
+	.other_caps = VIRTCHNL2_CAP_WB_ON_ITR
+};
+
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
 {
@@ -1229,6 +1267,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 		goto err_reset_check;
 	}
 
+	rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 662a8a806a..18c152b598 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1163,6 +1163,44 @@ static struct idpf_ctlq_create_info idpf_ctlq_info[IDPF_CTLQ_NUM] = {
 	}
 };
 
+static struct virtchnl2_get_capabilities req_caps = {
+	.csum_caps =
+	VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
+	VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_GENERIC,
+
+	.rss_caps =
+	VIRTCHNL2_CAP_RSS_IPV4_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV4_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV6_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV6_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV4_AH              |
+	VIRTCHNL2_CAP_RSS_IPV4_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
+	VIRTCHNL2_CAP_RSS_IPV6_AH              |
+	VIRTCHNL2_CAP_RSS_IPV6_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV6_AH_ESP,
+
+	.other_caps = VIRTCHNL2_CAP_WB_ON_ITR
+};
+
 static int
 idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
 {
@@ -1192,6 +1230,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 		goto err_reset_check;
 	}
 
+	rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v4 1/2] common/idpf: move PF specific functions from common init
  2023-04-06  7:42       ` [PATCH v4 1/2] common/idpf: move PF specific functions from common init beilei.xing
@ 2023-04-23  8:25         ` Wu, Jingjing
  0 siblings, 0 replies; 12+ messages in thread
From: Wu, Jingjing @ 2023-04-23  8:25 UTC (permalink / raw)
  To: Xing, Beilei; +Cc: dev



> -----Original Message-----
> From: Xing, Beilei <beilei.xing@intel.com>
> Sent: Thursday, April 6, 2023 3:43 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Xing, Beilei <beilei.xing@intel.com>
> Subject: [PATCH v4 1/2] common/idpf: move PF specific functions from common init
> 
> From: Beilei Xing <beilei.xing@intel.com>
> 
> Move PF reset and PF mailbox initialization functions from
> idpf_adapter_init function to xxxx_adapter_ext_init function,
> since they're different between PF and VF support.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/common/idpf/idpf_common_device.c | 72 +++++-------------------
>  drivers/common/idpf/idpf_common_device.h | 11 ++++
>  drivers/common/idpf/version.map          |  5 ++
>  drivers/net/cpfl/cpfl_ethdev.c           | 51 +++++++++++++++++
>  drivers/net/idpf/idpf_ethdev.c           | 51 +++++++++++++++++
>  5 files changed, 131 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/common/idpf/idpf_common_device.c
> b/drivers/common/idpf/idpf_common_device.c
> index c5e7bbf66c..3b58bdd41e 100644
> --- a/drivers/common/idpf/idpf_common_device.c
> +++ b/drivers/common/idpf/idpf_common_device.c
> @@ -6,8 +6,8 @@
>  #include <idpf_common_device.h>
>  #include <idpf_common_virtchnl.h>
> 
> -static void
> -idpf_reset_pf(struct idpf_hw *hw)
> +void
> +idpf_hw_pf_reset(struct idpf_hw *hw)
>  {
>  	uint32_t reg;
> 
> @@ -15,9 +15,8 @@ idpf_reset_pf(struct idpf_hw *hw)
>  	IDPF_WRITE_REG(hw, PFGEN_CTRL, (reg | PFGEN_CTRL_PFSWR));
>  }
> 
> -#define IDPF_RESET_WAIT_CNT 100
> -static int
> -idpf_check_pf_reset_done(struct idpf_hw *hw)
> +int
> +idpf_hw_pf_reset_check(struct idpf_hw *hw)
>  {
>  	uint32_t reg;
>  	int i;
> @@ -33,48 +32,13 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
>  	return -EBUSY;
>  }
> 
> -#define CTLQ_NUM 2
> -static int
> -idpf_init_mbx(struct idpf_hw *hw)
> +int
> +idpf_hw_mbx_init(struct idpf_hw *hw, struct idpf_ctlq_create_info *ctlq_info)
>  {
> -	struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM] = {
> -		{
> -			.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
> -			.id = IDPF_CTLQ_ID,
> -			.len = IDPF_CTLQ_LEN,
> -			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
> -			.reg = {
> -				.head = PF_FW_ATQH,
> -				.tail = PF_FW_ATQT,
> -				.len = PF_FW_ATQLEN,
> -				.bah = PF_FW_ATQBAH,
> -				.bal = PF_FW_ATQBAL,
> -				.len_mask = PF_FW_ATQLEN_ATQLEN_M,
> -				.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M,
> -				.head_mask = PF_FW_ATQH_ATQH_M,
> -			}
> -		},
> -		{
> -			.type = IDPF_CTLQ_TYPE_MAILBOX_RX,
> -			.id = IDPF_CTLQ_ID,
> -			.len = IDPF_CTLQ_LEN,
> -			.buf_size = IDPF_DFLT_MBX_BUF_SIZE,
> -			.reg = {
> -				.head = PF_FW_ARQH,
> -				.tail = PF_FW_ARQT,
> -				.len = PF_FW_ARQLEN,
> -				.bah = PF_FW_ARQBAH,
> -				.bal = PF_FW_ARQBAL,
> -				.len_mask = PF_FW_ARQLEN_ARQLEN_M,
> -				.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M,
> -				.head_mask = PF_FW_ARQH_ARQH_M,
> -			}
> -		}
> -	};
>  	struct idpf_ctlq_info *ctlq;
>  	int ret;
> 
> -	ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
> +	ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, ctlq_info);
>  	if (ret != 0)
>  		return ret;
> 
> @@ -96,6 +60,12 @@ idpf_init_mbx(struct idpf_hw *hw)
>  	return ret;
>  }

You can check the device id if idpf_hw, and then decide how to init ctlq and then this function can also be consumed by VF driver. No need to move them out from common. The same as other functions.
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v5] common/idpf: refine capability get
  2023-04-06  7:42     ` [PATCH v4 0/2] refine common module beilei.xing
  2023-04-06  7:42       ` [PATCH v4 1/2] common/idpf: move PF specific functions from common init beilei.xing
  2023-04-06  7:42       ` [PATCH v4 2/2] common/idpf: refine capability get beilei.xing
@ 2023-04-24  8:08       ` beilei.xing
  2023-04-26  5:17         ` Wu, Jingjing
  2 siblings, 1 reply; 12+ messages in thread
From: beilei.xing @ 2023-04-24  8:08 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Beilei Xing

From: Beilei Xing <beilei.xing@intel.com>

Initialize required capability in PMD, and refine
idpf_vc_caps_get function. Then different PMDs can
require different capability.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v5 changes:
 - No need to move check_pf_reset_done and mbx_init from common module.
V4 changes:
 - No need to require PTP CAP for CPFL. 
V3 changes:
 - refine capability get.
 
 drivers/common/idpf/idpf_common_virtchnl.c | 45 ++--------------------
 drivers/net/cpfl/cpfl_ethdev.c             | 40 +++++++++++++++++++
 drivers/net/idpf/idpf_ethdev.c             | 40 +++++++++++++++++++
 3 files changed, 83 insertions(+), 42 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_virtchnl.c b/drivers/common/idpf/idpf_common_virtchnl.c
index 9ee7259539..a4e129062e 100644
--- a/drivers/common/idpf/idpf_common_virtchnl.c
+++ b/drivers/common/idpf/idpf_common_virtchnl.c
@@ -278,51 +278,12 @@ idpf_vc_api_version_check(struct idpf_adapter *adapter)
 int
 idpf_vc_caps_get(struct idpf_adapter *adapter)
 {
-	struct virtchnl2_get_capabilities caps_msg;
 	struct idpf_cmd_info args;
 	int err;
 
-	memset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities));
-
-	caps_msg.csum_caps =
-		VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
-		VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
-		VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
-		VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
-		VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
-		VIRTCHNL2_CAP_RX_CSUM_GENERIC;
-
-	caps_msg.rss_caps =
-		VIRTCHNL2_CAP_RSS_IPV4_TCP             |
-		VIRTCHNL2_CAP_RSS_IPV4_UDP             |
-		VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
-		VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
-		VIRTCHNL2_CAP_RSS_IPV6_TCP             |
-		VIRTCHNL2_CAP_RSS_IPV6_UDP             |
-		VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
-		VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
-		VIRTCHNL2_CAP_RSS_IPV4_AH              |
-		VIRTCHNL2_CAP_RSS_IPV4_ESP             |
-		VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
-		VIRTCHNL2_CAP_RSS_IPV6_AH              |
-		VIRTCHNL2_CAP_RSS_IPV6_ESP             |
-		VIRTCHNL2_CAP_RSS_IPV6_AH_ESP;
-
-	caps_msg.other_caps = VIRTCHNL2_CAP_WB_ON_ITR;
-
 	args.ops = VIRTCHNL2_OP_GET_CAPS;
-	args.in_args = (uint8_t *)&caps_msg;
-	args.in_args_size = sizeof(caps_msg);
+	args.in_args = (uint8_t *)&adapter->caps;
+	args.in_args_size = sizeof(struct virtchnl2_get_capabilities);
 	args.out_buffer = adapter->mbx_resp;
 	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
 
@@ -333,7 +294,7 @@ idpf_vc_caps_get(struct idpf_adapter *adapter)
 		return err;
 	}
 
-	rte_memcpy(&adapter->caps, args.out_buffer, sizeof(caps_msg));
+	rte_memcpy(&adapter->caps, args.out_buffer, sizeof(struct virtchnl2_get_capabilities));
 
 	return 0;
 }
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ede730fd50..517ae15f4c 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1165,6 +1165,44 @@ cpfl_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter);
 }
 
+static struct virtchnl2_get_capabilities req_caps = {
+	.csum_caps =
+	VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
+	VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_GENERIC,
+
+	.rss_caps =
+	VIRTCHNL2_CAP_RSS_IPV4_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV4_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV6_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV6_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV4_AH              |
+	VIRTCHNL2_CAP_RSS_IPV4_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
+	VIRTCHNL2_CAP_RSS_IPV6_AH              |
+	VIRTCHNL2_CAP_RSS_IPV6_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV6_AH_ESP,
+
+	.other_caps = VIRTCHNL2_CAP_WB_ON_ITR
+};
+
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
 {
@@ -1181,6 +1219,8 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index e02ec2ec5a..899fdf8b29 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1128,6 +1128,44 @@ idpf_dev_alarm_handler(void *param)
 	rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter);
 }
 
+static struct virtchnl2_get_capabilities req_caps = {
+	.csum_caps =
+	VIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_TX_CSUM_GENERIC          |
+	VIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |
+	VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |
+	VIRTCHNL2_CAP_RX_CSUM_GENERIC,
+
+	.rss_caps =
+	VIRTCHNL2_CAP_RSS_IPV4_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV4_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV4_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV4_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV6_TCP             |
+	VIRTCHNL2_CAP_RSS_IPV6_UDP             |
+	VIRTCHNL2_CAP_RSS_IPV6_SCTP            |
+	VIRTCHNL2_CAP_RSS_IPV6_OTHER           |
+	VIRTCHNL2_CAP_RSS_IPV4_AH              |
+	VIRTCHNL2_CAP_RSS_IPV4_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |
+	VIRTCHNL2_CAP_RSS_IPV6_AH              |
+	VIRTCHNL2_CAP_RSS_IPV6_ESP             |
+	VIRTCHNL2_CAP_RSS_IPV6_AH_ESP,
+
+	.other_caps = VIRTCHNL2_CAP_WB_ON_ITR
+};
+
 static int
 idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
 {
@@ -1144,6 +1182,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
+	rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
+
 	ret = idpf_adapter_init(base);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init adapter");
-- 
2.26.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v5] common/idpf: refine capability get
  2023-04-24  8:08       ` [PATCH v5] " beilei.xing
@ 2023-04-26  5:17         ` Wu, Jingjing
  2023-04-26  8:11           ` Zhang, Qi Z
  0 siblings, 1 reply; 12+ messages in thread
From: Wu, Jingjing @ 2023-04-26  5:17 UTC (permalink / raw)
  To: Xing, Beilei; +Cc: dev



> -----Original Message-----
> From: Xing, Beilei <beilei.xing@intel.com>
> Sent: Monday, April 24, 2023 4:08 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Xing, Beilei <beilei.xing@intel.com>
> Subject: [PATCH v5] common/idpf: refine capability get
> 
> From: Beilei Xing <beilei.xing@intel.com>
> 
> Initialize required capability in PMD, and refine
> idpf_vc_caps_get function. Then different PMDs can
> require different capability.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com> 
Acked-by: Jingjing Wu <jingjing.wu@intel.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v5] common/idpf: refine capability get
  2023-04-26  5:17         ` Wu, Jingjing
@ 2023-04-26  8:11           ` Zhang, Qi Z
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang, Qi Z @ 2023-04-26  8:11 UTC (permalink / raw)
  To: Wu, Jingjing, Xing, Beilei; +Cc: dev



> -----Original Message-----
> From: Wu, Jingjing <jingjing.wu@intel.com>
> Sent: Wednesday, April 26, 2023 1:18 PM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v5] common/idpf: refine capability get
> 
> 
> 
> > -----Original Message-----
> > From: Xing, Beilei <beilei.xing@intel.com>
> > Sent: Monday, April 24, 2023 4:08 PM
> > To: Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: dev@dpdk.org; Xing, Beilei <beilei.xing@intel.com>
> > Subject: [PATCH v5] common/idpf: refine capability get
> >
> > From: Beilei Xing <beilei.xing@intel.com>
> >
> > Initialize required capability in PMD, and refine idpf_vc_caps_get
> > function. Then different PMDs can require different capability.
> >
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> Acked-by: Jingjing Wu <jingjing.wu@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-04-26  8:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21  6:53 [PATCH] common/idpf: move PF specific functions from common init beilei.xing
2023-03-21  7:07 ` [PATCH v2] " beilei.xing
2023-04-04 12:41   ` [PATCH v3 0/2] refine common module beilei.xing
2023-04-04 12:41     ` [PATCH v3 1/2] common/idpf: move PF specific functions from common init beilei.xing
2023-04-04 12:41     ` [PATCH v3 2/2] common/idpf: refine capability get beilei.xing
2023-04-06  7:42     ` [PATCH v4 0/2] refine common module beilei.xing
2023-04-06  7:42       ` [PATCH v4 1/2] common/idpf: move PF specific functions from common init beilei.xing
2023-04-23  8:25         ` Wu, Jingjing
2023-04-06  7:42       ` [PATCH v4 2/2] common/idpf: refine capability get beilei.xing
2023-04-24  8:08       ` [PATCH v5] " beilei.xing
2023-04-26  5:17         ` Wu, Jingjing
2023-04-26  8:11           ` Zhang, Qi Z

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).