vDPA/ifcvf: implement management netlink framework
Subsystems (5)
v3 cover vDPA/ifcvf: implement management netlink framework
(Rebase on kernel 5.14-rc5, resend)
This series implements vDPA management netlink for ifcvf.
Please help review
Thanks!
Changes from V2:
fix typos in commit messages(Michael)
Changes from V1:
(1)handle adapter related error handling in ifcvf_vdpa_dev_add (Jason and Michael)
(2)relace vdpa_unregister_device() with vdpa_mgmtdev_unregister() in ifcvf_remove (Jason)
(3)squash patch 3 to patch 2(Jason)
Zhu Lingshan (2):
vDPA/ifcvf: introduce get_dev_type() which returns virtio dev id vDPA/ifcvf: implement management netlink framework for ifcvf
drivers/vdpa/ifcvf/ifcvf_base.h | 6 + drivers/vdpa/ifcvf/ifcvf_main.c | 188 +++++++++++++++++++++++--------- 2 files changed, 145 insertions(+), 49 deletions(-)
Signature · 1 line
2.27.0
PATCH RESEND v3 1/2 vDPA/ifcvf: introduce get_dev_type() which returns virtio dev id
This commit introduces a new function get_dev_type() which returns the virtio device id of a device, to avoid duplicated code.
--- drivers/vdpa/ifcvf/ifcvf_main.c | 34 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
drivers/vdpa/ifcvf/ifcvf_main.c +21 -13
@@ -458,6 +458,26 @@ static const struct vdpa_config_ops ifc_vdpa_ops = { .get_vq_notification = ifcvf_get_vq_notification, }; +static u32 get_dev_type (struct pci_dev *pdev) +{ +u32 dev_type; + +/* This drirver drives both modern virtio devices and transitional +* devices in modern mode. +* vDPA requires feature bit VIRTIO_F_ACCESS_PLATFORM, +* so legacy devices and transitional devices in legacy +* mode will not work for vDPA, this driver will not +* drive devices with legacy interface. +*/ + +if (pdev->device <0x1040 ) + dev_type = pdev->subsystem_device; +else + dev_type = pdev->device -0x1040 ; + +return dev_type; +} +static int ifcvf_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct device *dev = &pdev->dev;
@@ -502,19 +522,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)pci_set_drvdata (pdev, adapter); vf = &adapter->vf; - -/* This drirver drives both modern virtio devices and transitional -* devices in modern mode. -* vDPA requires feature bit VIRTIO_F_ACCESS_PLATFORM, -* so legacy devices and transitional devices in legacy -* mode will not work for vDPA, this driver will not -* drive devices with legacy interface. -*/ -if (pdev->device <0x1040 ) - vf->dev_type = pdev->subsystem_device; -else - vf->dev_type = pdev->device -0x1040 ; - + vf->dev_type =get_dev_type (pdev); vf->base =pcim_iomap_table (pdev); adapter->pdev = pdev;
Signature · 1 line
2.27.0
PATCH RESEND v3 2/2 vDPA/ifcvf: implement management netlink framework for ifcvf
In reply to Zhu LingshanThis commit implements the management netlink framework for ifcvf, including register and add / remove a device
It works with iproute2:
[root@localhost lszhu]# vdpa mgmtdev show -jp
{
"mgmtdev": {
"pci/0000:01:00.5": {
"supported_classes": [ "net" ]
},
"pci/0000:01:00.6": {
"supported_classes": [ "net" ]
}
}
}[root@localhost lszhu]# vdpa dev add mgmtdev pci/0000:01:00.5 name vdpa0 [root@localhost lszhu]# vdpa dev add mgmtdev pci/0000:01:00.6 name vdpa1
--- drivers/vdpa/ifcvf/ifcvf_base.h | 6 ++ drivers/vdpa/ifcvf/ifcvf_main.c | 154 ++++++++++++++++++++++++-------- 2 files changed, 124 insertions(+), 36 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.h +6 -0
@@ -106,6 +106,12 @@ struct ifcvf_lm_cfg {struct ifcvf_vring_lm_cfg vring_lm_cfg[IFCVF_MAX_QUEUE_PAIRS ]; }; +struct ifcvf_vdpa_mgmt_dev { +struct vdpa_mgmt_dev mdev; +struct ifcvf_adapter *adapter; +struct pci_dev *pdev; +}; +int ifcvf_init_hw (struct ifcvf_hw *hw,struct pci_dev *dev);int ifcvf_start_hw (struct ifcvf_hw *hw);void ifcvf_stop_hw (struct ifcvf_hw *hw);
drivers/vdpa/ifcvf/ifcvf_main.c +118 -36
199 lines not on this page · raw message
Signature · 1 line
2.27.0