Skip to content

Commit

Permalink
net/idpf: add VF support
Browse files Browse the repository at this point in the history
Support VF whose device id is 0x145c.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
beileix authored and ovsrobot committed Apr 24, 2023
1 parent 70cc4e1 commit 6785d7c
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 39 deletions.
140 changes: 101 additions & 39 deletions drivers/common/idpf/idpf_common_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions drivers/common/idpf/idpf_common_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/idpf/idpf_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -1279,6 +1280,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 */ },
};

Expand Down

0 comments on commit 6785d7c

Please sign in to comment.