* [PATCH] net/idpf: add VF support
@ 2023-03-21 6:56 beilei.xing
2023-04-04 12:49 ` [PATCH v2] " beilei.xing
0 siblings, 1 reply; 7+ messages in thread
From: beilei.xing @ 2023-03-21 6:56 UTC (permalink / raw)
To: jingjing.wu; +Cc: dev, Beilei Xing
From: Beilei Xing <beilei.xing@intel.com>
Support VF whose device id is 0x145c.
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
This patch depends on
https://patches.dpdk.org/project/dpdk/patch/20230321065316.79549-1-beilei.xing@intel.com/.
drivers/net/idpf/idpf_ethdev.c | 88 ++++++++++++++++++++++++++++++----
drivers/net/idpf/idpf_ethdev.h | 2 +
2 files changed, 80 insertions(+), 10 deletions(-)
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index c23623c5fc..57d58c3c89 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1078,6 +1078,7 @@ idpf_handle_virtchnl_msg(struct idpf_adapter_ext *adapter_ex)
switch (mbx_op) {
case idpf_mbq_opc_send_msg_to_peer_pf:
+ case idpf_mbq_opc_send_msg_to_peer_drv:
if (vc_op == VIRTCHNL2_OP_EVENT) {
if (ctlq_msg.data_len < sizeof(struct virtchnl2_event)) {
PMD_DRV_LOG(ERR, "Error event");
@@ -1128,6 +1129,23 @@ idpf_dev_alarm_handler(void *param)
rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter);
}
+static int
+idpf_hw_vf_reset_check(struct idpf_hw *hw)
+{
+ uint32_t reg;
+ int i;
+
+ for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+ reg = IDPF_READ_REG(hw, VFGEN_RSTAT);
+ if (reg != 0xFFFFFFFF && (reg & VFGEN_RSTAT_VFR_STATE_M))
+ return 0;
+ rte_delay_ms(1000);
+ }
+
+ PMD_INIT_LOG(ERR, "VF reset timeout");
+ return -EBUSY;
+}
+
struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
{
.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
@@ -1163,6 +1181,41 @@ struct idpf_ctlq_create_info ctlq_info[IDPF_CTLQ_NUM] = {
}
};
+struct idpf_ctlq_create_info vf_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 = VF_ATQH,
+ .tail = VF_ATQT,
+ .len = VF_ATQLEN,
+ .bah = VF_ATQBAH,
+ .bal = VF_ATQBAL,
+ .len_mask = VF_ATQLEN_ATQLEN_M,
+ .len_ena_mask = VF_ATQLEN_ATQENABLE_M,
+ .head_mask = VF_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 = VF_ARQH,
+ .tail = VF_ARQT,
+ .len = VF_ARQLEN,
+ .bah = VF_ARQBAH,
+ .bal = VF_ARQBAL,
+ .len_mask = VF_ARQLEN_ARQLEN_M,
+ .len_ena_mask = VF_ARQLEN_ARQENABLE_M,
+ .head_mask = VF_ARQH_ARQH_M,
+ }
+ }
+};
+
static int
idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
{
@@ -1179,17 +1232,31 @@ 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;
- }
+ if (hw->device_id == IDPF_DEV_ID_PF) {
+ 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_hw_mbx_init(hw, ctlq_info);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to init mailbox");
+ goto err_reset_check;
+ }
+ } else if (hw->device_id == IDPF_DEV_ID_VF) {
+ ret = idpf_hw_vf_reset_check(hw);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "VF is still resetting");
+ goto err_reset_check;
+ }
+
+ ret = idpf_hw_mbx_init(hw, vf_ctlq_info);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to init mailbox");
+ goto err_reset_check;
+ }
}
ret = idpf_adapter_init(base);
@@ -1329,6 +1396,7 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
static const struct rte_pci_id pci_id_idpf_map[] = {
{ RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_PF) },
+ { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_SRIOV) },
{ .vendor_id = 0, /* sentinel */ },
};
diff --git a/drivers/net/idpf/idpf_ethdev.h b/drivers/net/idpf/idpf_ethdev.h
index 3c2c932438..030f1470e2 100644
--- a/drivers/net/idpf/idpf_ethdev.h
+++ b/drivers/net/idpf/idpf_ethdev.h
@@ -20,6 +20,8 @@
#include <base/idpf_prototype.h>
#include <base/virtchnl2.h>
+#define IDPF_DEV_ID_SRIOV 0x145c
+
#define IDPF_MAX_VPORT_NUM 8
#define IDPF_INVALID_VPORT_IDX 0xffff
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] net/idpf: add VF support
2023-03-21 6:56 [PATCH] net/idpf: add VF support beilei.xing
@ 2023-04-04 12:49 ` beilei.xing
2023-04-24 8:26 ` [PATCH] " beilei.xing
2023-04-24 8:28 ` [PATCH v3] " beilei.xing
0 siblings, 2 replies; 7+ messages in thread
From: beilei.xing @ 2023-04-04 12:49 UTC (permalink / raw)
To: jingjing.wu; +Cc: dev, Beilei Xing
From: Beilei Xing <beilei.xing@intel.com>
Support VF whose device id is 0x145c.
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v2 change:
- Rebase code based on new patchset:
https://patches.dpdk.org/project/dpdk/cover/20230404124112.71703-1-beilei.xing@intel.com/
drivers/net/idpf/idpf_ethdev.c | 89 ++++++++++++++++++++++++++++++----
drivers/net/idpf/idpf_ethdev.h | 2 +
2 files changed, 81 insertions(+), 10 deletions(-)
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 18c152b598..b4364bbb08 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1078,6 +1078,7 @@ idpf_handle_virtchnl_msg(struct idpf_adapter_ext *adapter_ex)
switch (mbx_op) {
case idpf_mbq_opc_send_msg_to_peer_pf:
+ case idpf_mbq_opc_send_msg_to_peer_drv:
if (vc_op == VIRTCHNL2_OP_EVENT) {
if (ctlq_msg.data_len < sizeof(struct virtchnl2_event)) {
PMD_DRV_LOG(ERR, "Error event");
@@ -1128,6 +1129,23 @@ idpf_dev_alarm_handler(void *param)
rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter);
}
+static int
+idpf_hw_vf_reset_check(struct idpf_hw *hw)
+{
+ uint32_t reg;
+ int i;
+
+ for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+ reg = IDPF_READ_REG(hw, VFGEN_RSTAT);
+ if (reg != 0xFFFFFFFF && (reg & VFGEN_RSTAT_VFR_STATE_M))
+ return 0;
+ rte_delay_ms(1000);
+ }
+
+ PMD_INIT_LOG(ERR, "VF reset timeout");
+ return -EBUSY;
+}
+
static struct idpf_ctlq_create_info idpf_ctlq_info[IDPF_CTLQ_NUM] = {
{
.type = IDPF_CTLQ_TYPE_MAILBOX_TX,
@@ -1201,6 +1219,41 @@ static struct virtchnl2_get_capabilities req_caps = {
.other_caps = VIRTCHNL2_CAP_WB_ON_ITR
};
+struct idpf_ctlq_create_info vf_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 = VF_ATQH,
+ .tail = VF_ATQT,
+ .len = VF_ATQLEN,
+ .bah = VF_ATQBAH,
+ .bal = VF_ATQBAL,
+ .len_mask = VF_ATQLEN_ATQLEN_M,
+ .len_ena_mask = VF_ATQLEN_ATQENABLE_M,
+ .head_mask = VF_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 = VF_ARQH,
+ .tail = VF_ARQT,
+ .len = VF_ARQLEN,
+ .bah = VF_ARQBAH,
+ .bal = VF_ARQBAL,
+ .len_mask = VF_ARQLEN_ARQLEN_M,
+ .len_ena_mask = VF_ARQLEN_ARQENABLE_M,
+ .head_mask = VF_ARQH_ARQH_M,
+ }
+ }
+};
+
static int
idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter)
{
@@ -1217,17 +1270,32 @@ 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;
- }
+ if (hw->device_id == IDPF_DEV_ID_PF) {
+ 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;
+ }
+ } else if (hw->device_id == IDPF_DEV_ID_VF) {
+ ret = idpf_hw_vf_reset_check(hw);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "VF is still resetting");
+ goto err_reset_check;
+ }
+
+ ret = idpf_hw_mbx_init(hw, vf_ctlq_info);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to init mailbox");
+ 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;
}
rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
@@ -1369,6 +1437,7 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
static const struct rte_pci_id pci_id_idpf_map[] = {
{ RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_PF) },
+ { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_SRIOV) },
{ .vendor_id = 0, /* sentinel */ },
};
diff --git a/drivers/net/idpf/idpf_ethdev.h b/drivers/net/idpf/idpf_ethdev.h
index 3c2c932438..030f1470e2 100644
--- a/drivers/net/idpf/idpf_ethdev.h
+++ b/drivers/net/idpf/idpf_ethdev.h
@@ -20,6 +20,8 @@
#include <base/idpf_prototype.h>
#include <base/virtchnl2.h>
+#define IDPF_DEV_ID_SRIOV 0x145c
+
#define IDPF_MAX_VPORT_NUM 8
#define IDPF_INVALID_VPORT_IDX 0xffff
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] net/idpf: add VF support
2023-04-04 12:49 ` [PATCH v2] " beilei.xing
@ 2023-04-24 8:26 ` beilei.xing
2023-04-24 8:28 ` [PATCH v3] " beilei.xing
1 sibling, 0 replies; 7+ messages in thread
From: beilei.xing @ 2023-04-24 8:26 UTC (permalink / raw)
To: jingjing.wu; +Cc: dev, Beilei Xing
From: Beilei Xing <beilei.xing@intel.com>
Support VF whose device id is 0x145c.
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v3 change:
- move check reset done function and mail box init to common module.
v2 change:
- Rebase code based on new patchset:
https://patches.dpdk.org/project/dpdk/cover/20230404124112.71703-1-beilei.xing@intel.com/
drivers/common/idpf/idpf_common_device.c | 140 ++++++++++++++++-------
drivers/common/idpf/idpf_common_device.h | 2 +
drivers/net/idpf/idpf_ethdev.c | 2 +
3 files changed, 105 insertions(+), 39 deletions(-)
diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c
index c5e7bbf66c..7da4eef82c 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -16,6 +16,7 @@ idpf_reset_pf(struct idpf_hw *hw)
}
#define IDPF_RESET_WAIT_CNT 100
+
static int
idpf_check_pf_reset_done(struct idpf_hw *hw)
{
@@ -33,48 +34,105 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
return -EBUSY;
}
-#define CTLQ_NUM 2
static int
-idpf_init_mbx(struct idpf_hw *hw)
+idpf_check_vf_reset_done(struct idpf_hw *hw)
{
- 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,
- }
+ uint32_t reg;
+ int i;
+
+ for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+ reg = IDPF_READ_REG(hw, VFGEN_RSTAT);
+ if (reg != 0xFFFFFFFF && (reg & VFGEN_RSTAT_VFR_STATE_M))
+ return 0;
+ rte_delay_ms(1000);
+ }
+
+ DRV_LOG(ERR, "VF reset timeout");
+ return -EBUSY;
+}
+
+#define IDPF_CTLQ_NUM 2
+
+struct idpf_ctlq_create_info pf_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,
+ }
+ }
+};
+
+struct idpf_ctlq_create_info vf_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 = VF_ATQH,
+ .tail = VF_ATQT,
+ .len = VF_ATQLEN,
+ .bah = VF_ATQBAH,
+ .bal = VF_ATQBAL,
+ .len_mask = VF_ATQLEN_ATQLEN_M,
+ .len_ena_mask = VF_ATQLEN_ATQENABLE_M,
+ .head_mask = VF_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 = VF_ARQH,
+ .tail = VF_ARQT,
+ .len = VF_ARQLEN,
+ .bah = VF_ARQBAH,
+ .bal = VF_ARQBAL,
+ .len_mask = VF_ARQLEN_ARQLEN_M,
+ .len_ena_mask = VF_ARQLEN_ARQENABLE_M,
+ .head_mask = VF_ARQH_ARQH_M,
+ }
+ }
+};
+
+static int
+idpf_init_mbx(struct idpf_hw *hw)
+{
struct idpf_ctlq_info *ctlq;
- int ret;
+ int ret = 0;
- ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+ if (hw->device_id == IDPF_DEV_ID_PF)
+ ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, pf_ctlq_info);
+ else if (hw->device_id == IDPF_DEV_ID_SRIOV)
+ ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, vf_ctlq_info);
if (ret != 0)
return ret;
@@ -312,8 +370,12 @@ 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 (hw->device_id == IDPF_DEV_ID_PF) {
+ idpf_reset_pf(hw);
+ ret = idpf_check_pf_reset_done(hw);
+ } else if (hw->device_id == IDPF_DEV_ID_SRIOV) {
+ ret = idpf_check_vf_reset_done(hw);
+ }
if (ret != 0) {
DRV_LOG(ERR, "IDPF is still resetting");
goto err_check_reset;
diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index c2dc2f16b9..261cf2c8ee 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -10,6 +10,8 @@
#include <base/virtchnl2.h>
#include <idpf_common_logs.h>
+#define IDPF_DEV_ID_SRIOV 0x145C
+
#define IDPF_RSS_KEY_LEN 52
#define IDPF_CTLQ_ID -1
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 899fdf8b29..ec87d88fb0 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1078,6 +1078,7 @@ idpf_handle_virtchnl_msg(struct idpf_adapter_ext *adapter_ex)
switch (mbx_op) {
case idpf_mbq_opc_send_msg_to_peer_pf:
+ case idpf_mbq_opc_send_msg_to_peer_drv:
if (vc_op == VIRTCHNL2_OP_EVENT) {
if (ctlq_msg.data_len < sizeof(struct virtchnl2_event)) {
PMD_DRV_LOG(ERR, "Error event");
@@ -1319,6 +1320,7 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
static const struct rte_pci_id pci_id_idpf_map[] = {
{ RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_PF) },
+ { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_SRIOV) },
{ .vendor_id = 0, /* sentinel */ },
};
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] net/idpf: add VF support
2023-04-04 12:49 ` [PATCH v2] " beilei.xing
2023-04-24 8:26 ` [PATCH] " beilei.xing
@ 2023-04-24 8:28 ` beilei.xing
2023-04-24 12:45 ` [PATCH v4] " beilei.xing
1 sibling, 1 reply; 7+ messages in thread
From: beilei.xing @ 2023-04-24 8:28 UTC (permalink / raw)
To: jingjing.wu; +Cc: dev, Beilei Xing
From: Beilei Xing <beilei.xing@intel.com>
Support VF whose device id is 0x145c.
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v3 change:
- move check reset done function and mail box init to common module.
v2 change:
- Rebase code based on new patchset:
https://patches.dpdk.org/project/dpdk/cover/20230404124112.71703-1-beilei.xing@intel.com/
drivers/common/idpf/idpf_common_device.c | 140 ++++++++++++++++-------
drivers/common/idpf/idpf_common_device.h | 2 +
drivers/net/idpf/idpf_ethdev.c | 2 +
3 files changed, 105 insertions(+), 39 deletions(-)
diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c
index c5e7bbf66c..7da4eef82c 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -16,6 +16,7 @@ idpf_reset_pf(struct idpf_hw *hw)
}
#define IDPF_RESET_WAIT_CNT 100
+
static int
idpf_check_pf_reset_done(struct idpf_hw *hw)
{
@@ -33,48 +34,105 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
return -EBUSY;
}
-#define CTLQ_NUM 2
static int
-idpf_init_mbx(struct idpf_hw *hw)
+idpf_check_vf_reset_done(struct idpf_hw *hw)
{
- 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,
- }
+ uint32_t reg;
+ int i;
+
+ for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+ reg = IDPF_READ_REG(hw, VFGEN_RSTAT);
+ if (reg != 0xFFFFFFFF && (reg & VFGEN_RSTAT_VFR_STATE_M))
+ return 0;
+ rte_delay_ms(1000);
+ }
+
+ DRV_LOG(ERR, "VF reset timeout");
+ return -EBUSY;
+}
+
+#define IDPF_CTLQ_NUM 2
+
+struct idpf_ctlq_create_info pf_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,
+ }
+ }
+};
+
+struct idpf_ctlq_create_info vf_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 = VF_ATQH,
+ .tail = VF_ATQT,
+ .len = VF_ATQLEN,
+ .bah = VF_ATQBAH,
+ .bal = VF_ATQBAL,
+ .len_mask = VF_ATQLEN_ATQLEN_M,
+ .len_ena_mask = VF_ATQLEN_ATQENABLE_M,
+ .head_mask = VF_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 = VF_ARQH,
+ .tail = VF_ARQT,
+ .len = VF_ARQLEN,
+ .bah = VF_ARQBAH,
+ .bal = VF_ARQBAL,
+ .len_mask = VF_ARQLEN_ARQLEN_M,
+ .len_ena_mask = VF_ARQLEN_ARQENABLE_M,
+ .head_mask = VF_ARQH_ARQH_M,
+ }
+ }
+};
+
+static int
+idpf_init_mbx(struct idpf_hw *hw)
+{
struct idpf_ctlq_info *ctlq;
- int ret;
+ int ret = 0;
- ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+ if (hw->device_id == IDPF_DEV_ID_PF)
+ ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, pf_ctlq_info);
+ else if (hw->device_id == IDPF_DEV_ID_SRIOV)
+ ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, vf_ctlq_info);
if (ret != 0)
return ret;
@@ -312,8 +370,12 @@ 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 (hw->device_id == IDPF_DEV_ID_PF) {
+ idpf_reset_pf(hw);
+ ret = idpf_check_pf_reset_done(hw);
+ } else if (hw->device_id == IDPF_DEV_ID_SRIOV) {
+ ret = idpf_check_vf_reset_done(hw);
+ }
if (ret != 0) {
DRV_LOG(ERR, "IDPF is still resetting");
goto err_check_reset;
diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index c2dc2f16b9..261cf2c8ee 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -10,6 +10,8 @@
#include <base/virtchnl2.h>
#include <idpf_common_logs.h>
+#define IDPF_DEV_ID_SRIOV 0x145C
+
#define IDPF_RSS_KEY_LEN 52
#define IDPF_CTLQ_ID -1
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 899fdf8b29..ec87d88fb0 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1078,6 +1078,7 @@ idpf_handle_virtchnl_msg(struct idpf_adapter_ext *adapter_ex)
switch (mbx_op) {
case idpf_mbq_opc_send_msg_to_peer_pf:
+ case idpf_mbq_opc_send_msg_to_peer_drv:
if (vc_op == VIRTCHNL2_OP_EVENT) {
if (ctlq_msg.data_len < sizeof(struct virtchnl2_event)) {
PMD_DRV_LOG(ERR, "Error event");
@@ -1319,6 +1320,7 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
static const struct rte_pci_id pci_id_idpf_map[] = {
{ RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_PF) },
+ { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_SRIOV) },
{ .vendor_id = 0, /* sentinel */ },
};
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4] net/idpf: add VF support
2023-04-24 8:28 ` [PATCH v3] " beilei.xing
@ 2023-04-24 12:45 ` beilei.xing
2023-04-25 9:10 ` Wu, Jingjing
0 siblings, 1 reply; 7+ messages in thread
From: beilei.xing @ 2023-04-24 12:45 UTC (permalink / raw)
To: jingjing.wu; +Cc: dev, Beilei Xing
From: Beilei Xing <beilei.xing@intel.com>
Support VF whose device id is 0x145c.
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v4 change:
- refine if condition.
v3 change:
- move check reset done function and mail box init to common module.
v2 change:
- Rebase code based on new patchset:
https://patches.dpdk.org/project/dpdk/cover/20230404124112.71703-1-beilei.xing@intel.com/
drivers/common/idpf/idpf_common_device.c | 140 ++++++++++++++++-------
drivers/common/idpf/idpf_common_device.h | 2 +
drivers/net/idpf/idpf_ethdev.c | 2 +
3 files changed, 105 insertions(+), 39 deletions(-)
diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c
index c5e7bbf66c..abd4be423a 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -16,6 +16,7 @@ idpf_reset_pf(struct idpf_hw *hw)
}
#define IDPF_RESET_WAIT_CNT 100
+
static int
idpf_check_pf_reset_done(struct idpf_hw *hw)
{
@@ -33,48 +34,105 @@ idpf_check_pf_reset_done(struct idpf_hw *hw)
return -EBUSY;
}
-#define CTLQ_NUM 2
static int
-idpf_init_mbx(struct idpf_hw *hw)
+idpf_check_vf_reset_done(struct idpf_hw *hw)
{
- 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,
- }
+ uint32_t reg;
+ int i;
+
+ for (i = 0; i < IDPF_RESET_WAIT_CNT; i++) {
+ reg = IDPF_READ_REG(hw, VFGEN_RSTAT);
+ if (reg != 0xFFFFFFFF && (reg & VFGEN_RSTAT_VFR_STATE_M))
+ return 0;
+ rte_delay_ms(1000);
+ }
+
+ DRV_LOG(ERR, "VF reset timeout");
+ return -EBUSY;
+}
+
+#define IDPF_CTLQ_NUM 2
+
+struct idpf_ctlq_create_info pf_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,
+ }
+ }
+};
+
+struct idpf_ctlq_create_info vf_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 = VF_ATQH,
+ .tail = VF_ATQT,
+ .len = VF_ATQLEN,
+ .bah = VF_ATQBAH,
+ .bal = VF_ATQBAL,
+ .len_mask = VF_ATQLEN_ATQLEN_M,
+ .len_ena_mask = VF_ATQLEN_ATQENABLE_M,
+ .head_mask = VF_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 = VF_ARQH,
+ .tail = VF_ARQT,
+ .len = VF_ARQLEN,
+ .bah = VF_ARQBAH,
+ .bal = VF_ARQBAL,
+ .len_mask = VF_ARQLEN_ARQLEN_M,
+ .len_ena_mask = VF_ARQLEN_ARQENABLE_M,
+ .head_mask = VF_ARQH_ARQH_M,
+ }
+ }
+};
+
+static int
+idpf_init_mbx(struct idpf_hw *hw)
+{
struct idpf_ctlq_info *ctlq;
- int ret;
+ int ret = 0;
- ret = idpf_ctlq_init(hw, CTLQ_NUM, ctlq_info);
+ if (hw->device_id == IDPF_DEV_ID_SRIOV)
+ ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, vf_ctlq_info);
+ else
+ ret = idpf_ctlq_init(hw, IDPF_CTLQ_NUM, pf_ctlq_info);
if (ret != 0)
return ret;
@@ -312,8 +370,12 @@ 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 (hw->device_id == IDPF_DEV_ID_SRIOV) {
+ ret = idpf_check_vf_reset_done(hw);
+ } else {
+ 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;
diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index c2dc2f16b9..261cf2c8ee 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -10,6 +10,8 @@
#include <base/virtchnl2.h>
#include <idpf_common_logs.h>
+#define IDPF_DEV_ID_SRIOV 0x145C
+
#define IDPF_RSS_KEY_LEN 52
#define IDPF_CTLQ_ID -1
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 899fdf8b29..ec87d88fb0 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1078,6 +1078,7 @@ idpf_handle_virtchnl_msg(struct idpf_adapter_ext *adapter_ex)
switch (mbx_op) {
case idpf_mbq_opc_send_msg_to_peer_pf:
+ case idpf_mbq_opc_send_msg_to_peer_drv:
if (vc_op == VIRTCHNL2_OP_EVENT) {
if (ctlq_msg.data_len < sizeof(struct virtchnl2_event)) {
PMD_DRV_LOG(ERR, "Error event");
@@ -1319,6 +1320,7 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
static const struct rte_pci_id pci_id_idpf_map[] = {
{ RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_PF) },
+ { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_SRIOV) },
{ .vendor_id = 0, /* sentinel */ },
};
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v4] net/idpf: add VF support
2023-04-24 12:45 ` [PATCH v4] " beilei.xing
@ 2023-04-25 9:10 ` Wu, Jingjing
2023-04-26 3:00 ` Zhang, Qi Z
0 siblings, 1 reply; 7+ messages in thread
From: Wu, Jingjing @ 2023-04-25 9:10 UTC (permalink / raw)
To: Xing, Beilei; +Cc: dev
> -----Original Message-----
> From: Xing, Beilei <beilei.xing@intel.com>
> Sent: Monday, April 24, 2023 8:45 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Xing, Beilei <beilei.xing@intel.com>
> Subject: [PATCH v4] net/idpf: add VF support
>
> From: Beilei Xing <beilei.xing@intel.com>
>
> Support VF whose device id is 0x145c.
>
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v4] net/idpf: add VF support
2023-04-25 9:10 ` Wu, Jingjing
@ 2023-04-26 3:00 ` Zhang, Qi Z
0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Qi Z @ 2023-04-26 3:00 UTC (permalink / raw)
To: Wu, Jingjing, Xing, Beilei; +Cc: dev
> -----Original Message-----
> From: Wu, Jingjing <jingjing.wu@intel.com>
> Sent: Tuesday, April 25, 2023 5:11 PM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v4] net/idpf: add VF support
>
>
>
> > -----Original Message-----
> > From: Xing, Beilei <beilei.xing@intel.com>
> > Sent: Monday, April 24, 2023 8:45 PM
> > To: Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: dev@dpdk.org; Xing, Beilei <beilei.xing@intel.com>
> > Subject: [PATCH v4] net/idpf: add VF support
> >
> > From: Beilei Xing <beilei.xing@intel.com>
> >
> > Support VF whose device id is 0x145c.
> >
> > 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] 7+ messages in thread
end of thread, other threads:[~2023-04-26 3:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 6:56 [PATCH] net/idpf: add VF support beilei.xing
2023-04-04 12:49 ` [PATCH v2] " beilei.xing
2023-04-24 8:26 ` [PATCH] " beilei.xing
2023-04-24 8:28 ` [PATCH v3] " beilei.xing
2023-04-24 12:45 ` [PATCH v4] " beilei.xing
2023-04-25 9:10 ` Wu, Jingjing
2023-04-26 3:00 ` 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).