Skip to content

Commit

Permalink
net/hns3: fix setting DCB capability
Browse files Browse the repository at this point in the history
[ upstream commit ac61c444e647298dded80a2ab52966a2dbe22b68 ]

The "hw->capability" is set after querying firmware and version.
But the DCB capability of PF is set in other place.
So this patch moves setting DCB capability to the place where
all capabilities are set.

Fixes: ab2e2e3 ("net/hns3: get device capability in primary process")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Jie Hai <haijie1@huawei.com>
  • Loading branch information
LiHuiSong1 authored and bluca committed Nov 8, 2023
1 parent 02f1c31 commit 4cf3c23
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
25 changes: 25 additions & 0 deletions drivers/net/hns3/hns3_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,28 @@ hns3_build_api_caps(void)
return rte_cpu_to_le_32(api_caps);
}

static void
hns3_set_dcb_capability(struct hns3_hw *hw)
{
struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
struct rte_pci_device *pci_dev;
struct rte_eth_dev *eth_dev;
uint16_t device_id;

if (hns->is_vf)
return;

eth_dev = &rte_eth_devices[hw->data->port_id];
pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
device_id = pci_dev->id.device_id;

if (device_id == HNS3_DEV_ID_25GE_RDMA ||
device_id == HNS3_DEV_ID_50GE_RDMA ||
device_id == HNS3_DEV_ID_100G_RDMA_MACSEC ||
device_id == HNS3_DEV_ID_200G_RDMA)
hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1);
}

static int
hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw)
{
Expand All @@ -465,6 +487,9 @@ hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw)
return ret;

hw->fw_version = rte_le_to_cpu_32(resp->firmware);

hns3_set_dcb_capability(hw);

hns3_parse_capability(hw, resp);

return 0;
Expand Down
8 changes: 0 additions & 8 deletions drivers/net/hns3/hns3_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3112,19 +3112,11 @@ hns3_get_capability(struct hns3_hw *hw)
struct rte_pci_device *pci_dev;
struct hns3_pf *pf = &hns->pf;
struct rte_eth_dev *eth_dev;
uint16_t device_id;
uint8_t revision;
int ret;

eth_dev = &rte_eth_devices[hw->data->port_id];
pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
device_id = pci_dev->id.device_id;

if (device_id == HNS3_DEV_ID_25GE_RDMA ||
device_id == HNS3_DEV_ID_50GE_RDMA ||
device_id == HNS3_DEV_ID_100G_RDMA_MACSEC ||
device_id == HNS3_DEV_ID_200G_RDMA)
hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1);

/* Get PCI revision id */
ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
Expand Down

0 comments on commit 4cf3c23

Please sign in to comment.