Commit af8eb69a authored by Zhu Lingshan's avatar Zhu Lingshan Committed by Michael S. Tsirkin

vDPA/ifcvf: decouple config space ops from the adapter

This commit decopules the config space ops from the
adapter layer, so these functions can be invoked
once the device is probed.
Signed-off-by: default avatarZhu Lingshan <lingshan.zhu@intel.com>
Cc: stable@vger.kernel.org
Message-Id: <20221125145724.1129962-3-lingshan.zhu@intel.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent d59f633d
...@@ -10,11 +10,6 @@ ...@@ -10,11 +10,6 @@
#include "ifcvf_base.h" #include "ifcvf_base.h"
struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw)
{
return container_of(hw, struct ifcvf_adapter, vf);
}
u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector) u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector)
{ {
struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
...@@ -37,8 +32,6 @@ u16 ifcvf_set_config_vector(struct ifcvf_hw *hw, int vector) ...@@ -37,8 +32,6 @@ u16 ifcvf_set_config_vector(struct ifcvf_hw *hw, int vector)
static void __iomem *get_cap_addr(struct ifcvf_hw *hw, static void __iomem *get_cap_addr(struct ifcvf_hw *hw,
struct virtio_pci_cap *cap) struct virtio_pci_cap *cap)
{ {
struct ifcvf_adapter *ifcvf;
struct pci_dev *pdev;
u32 length, offset; u32 length, offset;
u8 bar; u8 bar;
...@@ -46,17 +39,14 @@ static void __iomem *get_cap_addr(struct ifcvf_hw *hw, ...@@ -46,17 +39,14 @@ static void __iomem *get_cap_addr(struct ifcvf_hw *hw,
offset = le32_to_cpu(cap->offset); offset = le32_to_cpu(cap->offset);
bar = cap->bar; bar = cap->bar;
ifcvf= vf_to_adapter(hw);
pdev = ifcvf->pdev;
if (bar >= IFCVF_PCI_MAX_RESOURCE) { if (bar >= IFCVF_PCI_MAX_RESOURCE) {
IFCVF_DBG(pdev, IFCVF_DBG(hw->pdev,
"Invalid bar number %u to get capabilities\n", bar); "Invalid bar number %u to get capabilities\n", bar);
return NULL; return NULL;
} }
if (offset + length > pci_resource_len(pdev, bar)) { if (offset + length > pci_resource_len(hw->pdev, bar)) {
IFCVF_DBG(pdev, IFCVF_DBG(hw->pdev,
"offset(%u) + len(%u) overflows bar%u's capability\n", "offset(%u) + len(%u) overflows bar%u's capability\n",
offset, length, bar); offset, length, bar);
return NULL; return NULL;
...@@ -92,6 +82,7 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev) ...@@ -92,6 +82,7 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev)
IFCVF_ERR(pdev, "Failed to read PCI capability list\n"); IFCVF_ERR(pdev, "Failed to read PCI capability list\n");
return -EIO; return -EIO;
} }
hw->pdev = pdev;
while (pos) { while (pos) {
ret = ifcvf_read_config_range(pdev, (u32 *)&cap, ret = ifcvf_read_config_range(pdev, (u32 *)&cap,
...@@ -230,13 +221,11 @@ int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features) ...@@ -230,13 +221,11 @@ int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features)
u32 ifcvf_get_config_size(struct ifcvf_hw *hw) u32 ifcvf_get_config_size(struct ifcvf_hw *hw)
{ {
struct ifcvf_adapter *adapter;
u32 net_config_size = sizeof(struct virtio_net_config); u32 net_config_size = sizeof(struct virtio_net_config);
u32 blk_config_size = sizeof(struct virtio_blk_config); u32 blk_config_size = sizeof(struct virtio_blk_config);
u32 cap_size = hw->cap_dev_config_size; u32 cap_size = hw->cap_dev_config_size;
u32 config_size; u32 config_size;
adapter = vf_to_adapter(hw);
/* If the onboard device config space size is greater than /* If the onboard device config space size is greater than
* the size of struct virtio_net/blk_config, only the spec * the size of struct virtio_net/blk_config, only the spec
* implementing contents size is returned, this is very * implementing contents size is returned, this is very
...@@ -251,7 +240,7 @@ u32 ifcvf_get_config_size(struct ifcvf_hw *hw) ...@@ -251,7 +240,7 @@ u32 ifcvf_get_config_size(struct ifcvf_hw *hw)
break; break;
default: default:
config_size = 0; config_size = 0;
IFCVF_ERR(adapter->pdev, "VIRTIO ID %u not supported\n", hw->dev_type); IFCVF_ERR(hw->pdev, "VIRTIO ID %u not supported\n", hw->dev_type);
} }
return config_size; return config_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment