From: beilei.xing@intel.com
To: jingjing.wu@intel.com
Cc: dev@dpdk.org, Beilei Xing <beilei.xing@intel.com>
Subject: [PATCH] net/idpf: add VF support
Date: Tue, 21 Mar 2023 06:56:01 +0000 [thread overview]
Message-ID: <20230321065601.80171-1-beilei.xing@intel.com> (raw)
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
next reply other threads:[~2023-03-21 7:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 6:56 beilei.xing [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230321065601.80171-1-beilei.xing@intel.com \
--to=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).