vDPA/ifcvf: implement immediate initialization mechanism
Subsystems (2)
PATCH 1/5 virt queue ops take immediate actions
In reply to Zhu LingshanIn this commit, virtqueue operations including:set_vq_num(), set_vq_address(), set_vq_ready()
and get_vq_ready() access PCI registers directly
to take immediate actions.
--- drivers/vdpa/ifcvf/ifcvf_base.c | 58 ++++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 10 +++--- drivers/vdpa/ifcvf/ifcvf_main.c | 16 +++------ 3 files changed, 45 insertions(+), 39 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.c +36 -22
@@ -329,31 +329,49 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num)return 0 ; } -static int ifcvf_hw_enable (struct ifcvf_hw *hw) +void ifcvf_set_vq_num (struct ifcvf_hw *hw,u16 qid,u32 num) { -struct virtio_pci_common_cfg __iomem *cfg; -u32 i; +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; - cfg = hw->common_cfg; -for (i =0 ; i < hw->nr_vring; i++) { -if (!hw->vring[i].ready) -break ; +vp_iowrite16 (qid, &cfg->queue_select); +vp_iowrite16 (num, &cfg->queue_size); +} -vp_iowrite16 (i, &cfg->queue_select); -vp_iowrite64_twopart (hw->vring[i].desc, &cfg->queue_desc_lo, - &cfg->queue_desc_hi); -vp_iowrite64_twopart (hw->vring[i].avail, &cfg->queue_avail_lo, - &cfg->queue_avail_hi); -vp_iowrite64_twopart (hw->vring[i].used, &cfg->queue_used_lo, - &cfg->queue_used_hi); -vp_iowrite16 (hw->vring[i].size, &cfg->queue_size); -ifcvf_set_vq_state (hw, i, hw->vring[i].last_avail_idx); -vp_iowrite16 (1 , &cfg->queue_enable); - } +int ifcvf_set_vq_address (struct ifcvf_hw *hw,u16 qid,u64 desc_area, +u64 driver_area,u64 device_area) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + +vp_iowrite16 (qid, &cfg->queue_select); +vp_iowrite64_twopart (desc_area, &cfg->queue_desc_lo, + &cfg->queue_desc_hi); +vp_iowrite64_twopart (driver_area, &cfg->queue_avail_lo, + &cfg->queue_avail_hi); +vp_iowrite64_twopart (device_area, &cfg->queue_used_lo, + &cfg->queue_used_hi);return 0 ; } +bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +u16 queue_enable; + +vp_iowrite16 (qid, &cfg->queue_select); + queue_enable =vp_ioread16 (&cfg->queue_enable); + +return (bool )queue_enable; +} + +void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + +vp_iowrite16 (qid, &cfg->queue_select); +vp_iowrite16 (ready, &cfg->queue_enable); +} +static void ifcvf_hw_disable (struct ifcvf_hw *hw) {u32 i;
@@ -366,16 +384,12 @@ static void ifcvf_hw_disable(struct ifcvf_hw *hw)int ifcvf_start_hw (struct ifcvf_hw *hw) { -ifcvf_reset (hw);ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE );ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER );if (ifcvf_config_features (hw) <0 )return -EINVAL ; -if (ifcvf_hw_enable (hw) <0 ) -return -EINVAL ; -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK );return 0 ;
drivers/vdpa/ifcvf/ifcvf_base.h +5 -5
@@ -47,12 +47,7 @@#define MSIX_VECTOR_DEV_SHARED 3struct vring_info { -u64 desc; -u64 avail; -u64 used; -u16 size;u16 last_avail_idx; -bool ready;void __iomem *notify_addr;phys_addr_t notify_pa;u32 irq;
@@ -137,4 +132,9 @@ int ifcvf_probed_virtio_net(struct ifcvf_hw *hw);u32 ifcvf_get_config_size (struct ifcvf_hw *hw);u16 ifcvf_set_vq_vector (struct ifcvf_hw *hw,u16 qid,int vector);u16 ifcvf_set_config_vector (struct ifcvf_hw *hw,int vector); +void ifcvf_set_vq_num (struct ifcvf_hw *hw,u16 qid,u32 num); +int ifcvf_set_vq_address (struct ifcvf_hw *hw,u16 qid,u64 desc_area, +u64 driver_area,u64 device_area); +bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid); +void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready);#endif /* _IFCVF_H_ */
drivers/vdpa/ifcvf/ifcvf_main.c +4 -12
@@ -382,10 +382,6 @@ static void ifcvf_reset_vring(struct ifcvf_adapter *adapter)for (i =0 ; i < vf->nr_vring; i++) { vf->vring[i].last_avail_idx =0 ; - vf->vring[i].desc =0 ; - vf->vring[i].avail =0 ; - vf->vring[i].used =0 ; - vf->vring[i].ready =0 ; vf->vring[i].cb.callback =NULL ; vf->vring[i].cb.private =NULL ; }
@@ -542,14 +538,14 @@ static void ifcvf_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); - vf->vring[qid].ready = ready; +ifcvf_set_vq_ready (vf, qid, ready); }static bool ifcvf_vdpa_get_vq_ready (struct vdpa_device *vdpa_dev,u16 qid) {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); -return vf->vring[qid].ready; +return ifcvf_get_vq_ready (vf, qid); } static void ifcvf_vdpa_set_vq_num(struct vdpa_device *vdpa_dev, u16 qid,
@@ -557,7 +553,7 @@ static void ifcvf_vdpa_set_vq_num(struct vdpa_device *vdpa_dev, u16 qid, {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); - vf->vring[qid].size = num; +ifcvf_set_vq_num (vf, qid, num); } static int ifcvf_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid,
@@ -566,11 +562,7 @@ static int ifcvf_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid, {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); - vf->vring[qid].desc = desc_area; - vf->vring[qid].avail = driver_area; - vf->vring[qid].used = device_area; - -return 0 ; +return ifcvf_set_vq_address (vf, qid, desc_area, driver_area, device_area); }static void ifcvf_vdpa_kick_vq (struct vdpa_device *vdpa_dev,u16 qid)
Signature · 6 lines
2.39.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH 2/5 get_driver_features from virito registers
In reply to Zhu LingshanThis commit implements a new function ifcvf_get_driver_feature() which read driver_features from virtio registers.
To be less ambiguous, ifcvf_set_features() is renamed to ifcvf_set_driver_features(), and ifcvf_get_features() is renamed to ifcvf_get_dev_features() which returns the provisioned vDPA device features.
--- drivers/vdpa/ifcvf/ifcvf_base.c | 38 +++++++++++++++++---------------- drivers/vdpa/ifcvf/ifcvf_base.h | 5 +++-- drivers/vdpa/ifcvf/ifcvf_main.c | 9 +++++--- 3 files changed, 29 insertions(+), 23 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.c +20 -18
@@ -204,11 +204,29 @@ u64 ifcvf_get_hw_features(struct ifcvf_hw *hw)return features; } -u64 ifcvf_get_features (struct ifcvf_hw *hw) +/* return provisioned vDPA dev features */ +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw) {return hw->dev_features; } +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +u32 features_lo, features_hi; +u64 features; + +vp_iowrite32 (0 , &cfg->device_feature_select); + features_lo =vp_ioread32 (&cfg->guest_feature); + +vp_iowrite32 (1 , &cfg->device_feature_select); + features_hi =vp_ioread32 (&cfg->guest_feature); + + features = ((u64 )features_hi <<32 ) | features_lo; + +return features; +} +int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features) {if (!(features &BIT_ULL (VIRTIO_F_ACCESS_PLATFORM )) && features) {
@@ -275,7 +293,7 @@ void ifcvf_write_dev_config(struct ifcvf_hw *hw, u64 offset,vp_iowrite8 (*p++, hw->dev_cfg + offset + i); } -static void ifcvf_set_features (struct ifcvf_hw *hw,u64 features) +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features) {struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
@@ -286,19 +304,6 @@ static void ifcvf_set_features(struct ifcvf_hw *hw, u64 features)vp_iowrite32 (features >>32 , &cfg->guest_feature); } -static int ifcvf_config_features (struct ifcvf_hw *hw) -{ -ifcvf_set_features (hw, hw->req_features); -ifcvf_add_status (hw,VIRTIO_CONFIG_S_FEATURES_OK ); - -if (!(ifcvf_get_status (hw) &VIRTIO_CONFIG_S_FEATURES_OK )) { -IFCVF_ERR (hw->pdev,"Failed to set FEATURES_OK status\n" ); -return -EIO ; - } - -return 0 ; -} -u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid) {struct ifcvf_lm_cfg __iomem *ifcvf_lm;
@@ -387,9 +392,6 @@ int ifcvf_start_hw(struct ifcvf_hw *hw)ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE );ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER ); -if (ifcvf_config_features (hw) <0 ) -return -EINVAL ; -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK );return 0 ;
drivers/vdpa/ifcvf/ifcvf_base.h +3 -2
@@ -69,7 +69,6 @@ struct ifcvf_hw {phys_addr_t notify_base_pa;u32 notify_off_multiplier;u32 dev_type; -u64 req_features;u64 hw_features;/* provisioned device features */ u64 dev_features;
@@ -122,7 +121,7 @@ u8 ifcvf_get_status(struct ifcvf_hw *hw);void ifcvf_set_status (struct ifcvf_hw *hw,u8 status);void io_write64_twopart (u64 val,u32 *lo,u32 *hi);void ifcvf_reset (struct ifcvf_hw *hw); -u64 ifcvf_get_features (struct ifcvf_hw *hw); +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw);u64 ifcvf_get_hw_features (struct ifcvf_hw *hw);int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features);u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid);
@@ -137,4 +136,6 @@ int ifcvf_set_vq_address(struct ifcvf_hw *hw, u16 qid, u64 desc_area, u64 driver_area, u64 device_area);bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid);void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready); +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features); +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw);#endif /* _IFCVF_H_ */
drivers/vdpa/ifcvf/ifcvf_main.c +6 -3
@@ -410,7 +410,7 @@ static u64 ifcvf_vdpa_get_device_features(struct vdpa_device *vdpa_dev)u64 features;if (type ==VIRTIO_ID_NET || type ==VIRTIO_ID_BLOCK ) - features =ifcvf_get_features (vf); + features =ifcvf_get_dev_features (vf);else { features =0 ;IFCVF_ERR (pdev,"VIRTIO ID %u not supported\n" , vf->dev_type);
@@ -428,7 +428,7 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featif (ret)return ret; - vf->req_features = features; +ifcvf_set_driver_features (vf, features);return 0 ; }
@@ -436,8 +436,11 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featstatic u64 ifcvf_vdpa_get_driver_features (struct vdpa_device *vdpa_dev) {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); +u64 features; + + features =ifcvf_get_driver_features (vf); -return vf->req_features; +return features; }static u8 ifcvf_vdpa_get_status (struct vdpa_device *vdpa_dev)
Signature · 6 lines
2.39.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH 3/5 retire ifcvf_start_datapath and ifcvf_add_status
In reply to Zhu LingshanRather than former lazy-initialization mechanism, now the virtqueue operations and driver_features related ops access the virtio registers directly to take immediate actions. So ifcvf_start_datapath() should retire.
ifcvf_add_status() is retierd because we should not change device status by a vendor driver's decision, this driver should only set device status which is from virito drivers upon vdpa_ops.set_status()
--- drivers/vdpa/ifcvf/ifcvf_base.c | 19 ------------------- drivers/vdpa/ifcvf/ifcvf_base.h | 1 - drivers/vdpa/ifcvf/ifcvf_main.c | 23 ----------------------- 3 files changed, 43 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.c +0 -19
@@ -178,15 +178,6 @@ void ifcvf_reset(struct ifcvf_hw *hw)ifcvf_get_status (hw); } -static void ifcvf_add_status (struct ifcvf_hw *hw,u8 status) -{ -if (status !=0 ) - status |=ifcvf_get_status (hw); - -ifcvf_set_status (hw, status); -ifcvf_get_status (hw); -} -u64 ifcvf_get_hw_features (struct ifcvf_hw *hw) {struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
@@ -387,16 +378,6 @@ static void ifcvf_hw_disable(struct ifcvf_hw *hw) } } -int ifcvf_start_hw (struct ifcvf_hw *hw) -{ -ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE ); -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER ); - -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK ); - -return 0 ; -} -void ifcvf_stop_hw (struct ifcvf_hw *hw) {ifcvf_hw_disable (hw);
drivers/vdpa/ifcvf/ifcvf_base.h +0 -1
@@ -110,7 +110,6 @@ struct ifcvf_vdpa_mgmt_dev { };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);void ifcvf_notify_queue (struct ifcvf_hw *hw,u16 qid); void ifcvf_read_dev_config(struct ifcvf_hw *hw, u64 offset,
drivers/vdpa/ifcvf/ifcvf_main.c +0 -23
@@ -346,22 +346,6 @@ static int ifcvf_request_irq(struct ifcvf_hw *vf)return 0 ; } -static int ifcvf_start_datapath (struct ifcvf_adapter *adapter) -{ -struct ifcvf_hw *vf = adapter->vf; -u8 status; -int ret; - - ret =ifcvf_start_hw (vf); -if (ret <0 ) { - status =ifcvf_get_status (vf); - status |=VIRTIO_CONFIG_S_FAILED ; -ifcvf_set_status (vf, status); - } - -return ret; -} -static int ifcvf_stop_datapath (struct ifcvf_adapter *adapter) {struct ifcvf_hw *vf = adapter->vf;
@@ -452,13 +436,11 @@ static u8 ifcvf_vdpa_get_status(struct vdpa_device *vdpa_dev)static void ifcvf_vdpa_set_status (struct vdpa_device *vdpa_dev,u8 status) { -struct ifcvf_adapter *adapter;struct ifcvf_hw *vf;u8 status_old;int ret; vf =vdpa_to_vf (vdpa_dev); - adapter =vdpa_to_adapter (vdpa_dev); status_old =ifcvf_get_status (vf);if (status_old == status)
@@ -473,11 +455,6 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status)ifcvf_set_status (vf, status);return ; } - -if (ifcvf_start_datapath (adapter) <0 ) -IFCVF_ERR (adapter->pdev, -"Failed to set ifcvf vdpa status %u\n" , - status); }ifcvf_set_status (vf, status);
Signature · 6 lines
2.39.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH 4/5 synchronize irqs in the reset routine
In reply to Zhu LingshanThis commit synchronize irqs of the virtqueues and config space in the reset routine.
Thus ifcvf_stop_hw() and reset() are refactored as well.
--- drivers/vdpa/ifcvf/ifcvf_base.c | 61 ++++++++++++++++++++++++++------- drivers/vdpa/ifcvf/ifcvf_main.c | 45 +++--------------------- 2 files changed, 54 insertions(+), 52 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.c +49 -12
@@ -170,12 +170,7 @@ void ifcvf_set_status(struct ifcvf_hw *hw, u8 status)void ifcvf_reset (struct ifcvf_hw *hw) { - hw->config_cb.callback =NULL ; - hw->config_cb.private =NULL ; -ifcvf_set_status (hw,0 ); -/* flush set_status, make sure VF is stopped, reset */ -ifcvf_get_status (hw); }u64 ifcvf_get_hw_features (struct ifcvf_hw *hw)
@@ -368,20 +363,62 @@ void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready)vp_iowrite16 (ready, &cfg->queue_enable); } -static void ifcvf_hw_disable (struct ifcvf_hw *hw) +static void synchronize_per_vq_irq (struct ifcvf_hw *hw) { -u32 i; +u16 qid; -ifcvf_set_config_vector (hw,VIRTIO_MSI_NO_VECTOR ); -for (i =0 ; i < hw->nr_vring; i++) { -ifcvf_set_vq_vector (hw, i,VIRTIO_MSI_NO_VECTOR ); +for (qid =0 ; qid < hw->nr_vring; qid++) { +if (hw->vring[qid].irq != -EINVAL ) +synchronize_irq (hw->vring[qid].irq); } } +static void synchronize_vqs_reused_irq (struct ifcvf_hw *hw) +{ +if (hw->vqs_reused_irq != -EINVAL ) +synchronize_irq (hw->vqs_reused_irq); +} + +static void synchronize_vq_irq (struct ifcvf_hw *hw) +{ +u8 status = hw->msix_vector_status; + +if (status ==MSIX_VECTOR_PER_VQ_AND_CONFIG ) +synchronize_per_vq_irq (hw); +else +synchronize_vqs_reused_irq (hw); +} + +static void synchronize_config_irq (struct ifcvf_hw *hw) +{ +if (hw->config_irq != -EINVAL ) +synchronize_irq (hw->config_irq); +} + +static void ifcvf_reset_vring (struct ifcvf_hw *hw) +{ +u16 qid; + +for (qid =0 ; qid < hw->nr_vring; qid++) { +synchronize_vq_irq (hw); + hw->vring[qid].cb.callback =NULL ; + hw->vring[qid].cb.private =NULL ; +ifcvf_set_vq_vector (hw, qid,VIRTIO_MSI_NO_VECTOR ); + } +} + +static void ifcvf_reset_config_handler (struct ifcvf_hw *hw) +{ +synchronize_config_irq (hw); + hw->config_cb.callback =NULL ; + hw->config_cb.private =NULL ; +ifcvf_set_config_vector (hw,VIRTIO_MSI_NO_VECTOR ); +} +void ifcvf_stop_hw (struct ifcvf_hw *hw) { -ifcvf_hw_disable (hw); -ifcvf_reset (hw); +ifcvf_reset_vring (hw); +ifcvf_reset_config_handler (hw); }void ifcvf_notify_queue (struct ifcvf_hw *hw,u16 qid)
drivers/vdpa/ifcvf/ifcvf_main.c +5 -40
61 lines not on this page · raw message
Signature · 6 lines
2.39.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH 5/5 a vendor driver should not set _CONFIG_S_FAILED
In reply to Zhu LingshanVIRTIO_CONFIG_S_FAILED indicates the guest driver has given up the device due to fatal errors. So it is the guest decision, the vendor driver should not set this status to the device.
--- drivers/vdpa/ifcvf/ifcvf_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/vdpa/ifcvf/ifcvf_main.c +1 -3
@@ -423,9 +423,7 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) !(status_old & VIRTIO_CONFIG_S_DRIVER_OK)) { ret =ifcvf_request_irq (vf);if (ret) { - status =ifcvf_get_status (vf); - status |=VIRTIO_CONFIG_S_FAILED ; -ifcvf_set_status (vf, status); +IFCVF_ERR (vf->pdev,"failed to request irq with error %d\n" , ret);return ; } }
Signature · 6 lines
2.39.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
cover vDPA/ifcvf: implement immediate initialization mechanism
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space upon DRIVER_OK.
This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actions get_driver_features from virito registers retire ifcvf_start_datapath and ifcvf_add_status synchronize irqs in the reset routine
a vendor driver should not set _CONFIG_S_FAILED
drivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)
Signature · 6 lines
2.39.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 10 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Is there any chance that ifcvf can use virtio_pci_modern_dev library?
Then we don't need to duplicate the codes.
Note that pds_vdpa will be the second user for virtio_pci_modern_dev library (and the first vDPA parent to use that library).
Thanks
Quoted 11 lines
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILED
Quoted 8 lines
drivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)--
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 10 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Quoted 6 lines
Is there any chance that ifcvf can use
virtio_pci_modern_devlibrary?Then we don't need to duplicate the codes.
Note that
pds_vdpawill be the second user forvirtio_pci_modern_devlibrary (and the first vDPA parent to use that library).
Yes I agree this library can help a lot for a standard virtio pci device.
But this change would be huge, its like require to change every line of
the driver. For example current driver functions work on the adapter andifcvf_hw, if we wants to reuse the lib, we need the driver work on struct virtio_pci_modern_device. Almost need to re-write the driver.
Can we plan this huge change in following series?
Thanks,
Zhu Lingshan
Quoted 21 lines
Thanks
Quoted 18 lines
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILEDdrivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)--
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 19 lines · Lingshan
Quoted 10 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Quoted 6 lines
Is there any chance that ifcvf can use
virtio_pci_modern_devlibrary?Then we don't need to duplicate the codes.
Note that
pds_vdpawill be the second user forvirtio_pci_modern_devlibrary (and the first vDPA parent to use that library).
Quoted 7 lines
Yes I agree this library can help a lot for a standard virtio pci device.
But this change would be huge, its like require to change every line of
the driver. For example current driver functions work on the adapter andifcvf_hw, if we wants to reuse the lib, we need the driver work on structvirtio_pci_modern_device. Almost need to re-write the driver.Can we plan this huge change in following series?
ping
Quoted 26 lines
Thanks,
Zhu LingshanQuoted 22 lines
Thanks
Quoted 19 lines
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILED
drivers/vdpa/ifcvf/ifcvf_base.c| 162
+++++++++++++++++++-------------
drivers/vdpa/ifcvf/ifcvf_base.h| 16 ++--drivers/vdpa/ifcvf/ifcvf_main.c| 97 ++++---------------3 files changed, 122 insertions(+), 153 deletions(-)Signature · 1 line
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 31 lines · Lingshan
Quoted 27 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Quoted 6 lines
Is there any chance that ifcvf can use
virtio_pci_modern_devlibrary?Then we don't need to duplicate the codes.
Note that
pds_vdpawill be the second user forvirtio_pci_modern_devlibrary (and the first vDPA parent to use that library).Yes I agree this library can help a lot for a standard virtio pci device. But this change would be huge, its like require to change every line of the driver. For example current driver functions work on the adapter and
ifcvf_hw, if we wants to reuse the lib, we need the driver work on structvirtio_pci_modern_device.
Almost need to re-write the driver.
Quoted 2 lines
Quoted 1 line
Can we plan this huge change in following series?
ping
Will go through this this week.
Thanks
Quoted 22 lines
Quoted 22 lines
Thanks,
Zhu LingshanQuoted 19 lines
Thanks
Quoted 16 lines
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILEDdrivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerRe: [PATCH 2/5] get_driver_features from virito registers
In reply to Zhu Lingshansubj typo: virtio
Quoted 154 lines · Zhu Lingshan
This commit implements a new function
ifcvf_get_driver_feature()which readdriver_featuresfrom virtio registers.To be less ambiguous,
ifcvf_set_features()is renamed toifcvf_set_driver_features(), andifcvf_get_features()is renamed toifcvf_get_dev_features()which returns the provisioned vDPA device features.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/ifcvf/ifcvf_base.c | 38 +++++++++++++++++---------------- drivers/vdpa/ifcvf/ifcvf_base.h | 5 +++-- drivers/vdpa/ifcvf/ifcvf_main.c | 9 +++++--- 3 files changed, 29 insertions(+), 23 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +20
-18@@ -204,11 +204,29 @@ u64 ifcvf_get_hw_features(struct ifcvf_hw *hw)return features; } -u64 ifcvf_get_features (struct ifcvf_hw *hw) +/* return provisioned vDPA dev features */ +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw) {return hw->dev_features; } +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +u32 features_lo, features_hi; +u64 features; + +vp_iowrite32 (0 , &cfg->device_feature_select); + features_lo =vp_ioread32 (&cfg->guest_feature); + +vp_iowrite32 (1 , &cfg->device_feature_select); + features_hi =vp_ioread32 (&cfg->guest_feature); + + features = ((u64 )features_hi <<32 ) | features_lo; + +return features; +} +int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features) {if (!(features &BIT_ULL (VIRTIO_F_ACCESS_PLATFORM )) && features) {@@ -275,7 +293,7 @@ void ifcvf_write_dev_config(struct ifcvf_hw *hw, u64 offset,vp_iowrite8 (*p++, hw->dev_cfg + offset + i); } -static void ifcvf_set_features (struct ifcvf_hw *hw,u64 features) +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features) {struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;@@ -286,19 +304,6 @@ static void ifcvf_set_features(struct ifcvf_hw *hw, u64 features)vp_iowrite32 (features >>32 , &cfg->guest_feature); } -static int ifcvf_config_features (struct ifcvf_hw *hw) -{ -ifcvf_set_features (hw, hw->req_features); -ifcvf_add_status (hw,VIRTIO_CONFIG_S_FEATURES_OK ); - -if (!(ifcvf_get_status (hw) &VIRTIO_CONFIG_S_FEATURES_OK )) { -IFCVF_ERR (hw->pdev,"Failed to set FEATURES_OK status\n" ); -return -EIO ; - } - -return 0 ; -} -u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid) {struct ifcvf_lm_cfg __iomem *ifcvf_lm;@@ -387,9 +392,6 @@ int ifcvf_start_hw(struct ifcvf_hw *hw)ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE );ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER ); -if (ifcvf_config_features (hw) <0 ) -return -EINVAL ; -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK );return 0 ;drivers/vdpa/ifcvf/ifcvf_base.h +3
-2@@ -69,7 +69,6 @@ struct ifcvf_hw {phys_addr_t notify_base_pa;u32 notify_off_multiplier;u32 dev_type; -u64 req_features;u64 hw_features;/* provisioned device features */ u64 dev_features;@@ -122,7 +121,7 @@ u8 ifcvf_get_status(struct ifcvf_hw *hw);void ifcvf_set_status (struct ifcvf_hw *hw,u8 status);void io_write64_twopart (u64 val,u32 *lo,u32 *hi);void ifcvf_reset (struct ifcvf_hw *hw); -u64 ifcvf_get_features (struct ifcvf_hw *hw); +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw);u64 ifcvf_get_hw_features (struct ifcvf_hw *hw);int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features);u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid);@@ -137,4 +136,6 @@ int ifcvf_set_vq_address(struct ifcvf_hw *hw, u16 qid, u64 desc_area, u64 driver_area, u64 device_area);bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid);void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready); +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features); +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw);#endif /* _IFCVF_H_ */ drivers/vdpa/ifcvf/ifcvf_main.c +6
-3@@ -410,7 +410,7 @@ static u64 ifcvf_vdpa_get_device_features(struct vdpa_device *vdpa_dev)u64 features;if (type ==VIRTIO_ID_NET || type ==VIRTIO_ID_BLOCK ) - features =ifcvf_get_features (vf); + features =ifcvf_get_dev_features (vf);else { features =0 ;IFCVF_ERR (pdev,"VIRTIO ID %u not supported\n" , vf->dev_type);@@ -428,7 +428,7 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featif (ret)return ret; - vf->req_features = features; +ifcvf_set_driver_features (vf, features);return 0 ; }@@ -436,8 +436,11 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featstatic u64 ifcvf_vdpa_get_driver_features (struct vdpa_device *vdpa_dev) {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); +u64 features; + + features =ifcvf_get_driver_features (vf); -return vf->req_features; +return features; }static u8 ifcvf_vdpa_get_status (struct vdpa_device *vdpa_dev)Signature · 1 line
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 5 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.
Quoted 7 lines
This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
This series also implement irq synchronization in the reset routine
Please, prefix each patch subject with vDPA/ifcvf:
Quoted 7 lines
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILED
Quoted 7 lines
drivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)Signature · 1 line
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 32 lines · Jason Wang
Quoted 31 lines · Lingshan
Quoted 27 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Quoted 6 lines
Is there any chance that ifcvf can use
virtio_pci_modern_devlibrary?Then we don't need to duplicate the codes.
Note that
pds_vdpawill be the second user forvirtio_pci_modern_devlibrary (and the first vDPA parent to use that library).Yes I agree this library can help a lot for a standard virtio pci device. But this change would be huge, its like require to change every line of the driver. For example current driver functions work on the adapter and
ifcvf_hw, if we wants to reuse the lib, we need the driver work on structvirtio_pci_modern_device.
Almost need to re-write the driver.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Can we plan this huge change in following series?
ping
Will go through this this week.
Thanks
why do you expect it to go through, you didn't ack?
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Thanks,
Zhu LingshanQuoted 19 lines
Thanks
Quoted 16 lines
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILEDdrivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 34 lines · Michael S. Tsirkin
Quoted 32 lines · Jason Wang
Quoted 31 lines · Lingshan
Quoted 27 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Quoted 6 lines
Is there any chance that ifcvf can use
virtio_pci_modern_devlibrary?Then we don't need to duplicate the codes.
Note that
pds_vdpawill be the second user forvirtio_pci_modern_devlibrary (and the first vDPA parent to use that library).Yes I agree this library can help a lot for a standard virtio pci device. But this change would be huge, its like require to change every line of the driver. For example current driver functions work on the adapter and
ifcvf_hw, if we wants to reuse the lib, we need the driver work on structvirtio_pci_modern_device.
Almost need to re-write the driver.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Can we plan this huge change in following series?
ping
Will go through this this week.
Thanks
why do you expect it to go through, you didn't ack?
I meant I will have a look at it this week,
(Google told me "go through" meant "to look at or examine something carefully")
Thanks
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Thanks,
Zhu LingshanQuoted 19 lines
Thanks
Quoted 16 lines
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILEDdrivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 2/5] get_driver_features from virito registers
In reply to Michael S. TsirkinQuoted 1 line · Michael S. Tsirkin
subj typo: virtio
will fix in V2, thanks!
Quoted 149 lines · Zhu Lingshan
Quoted 147 lines
This commit implements a new function
ifcvf_get_driver_feature()which readdriver_featuresfrom virtio registers.To be less ambiguous,
ifcvf_set_features()is renamed toifcvf_set_driver_features(), andifcvf_get_features()is renamed toifcvf_get_dev_features()which returns the provisioned vDPA device features.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/ifcvf/ifcvf_base.c | 38 +++++++++++++++++---------------- drivers/vdpa/ifcvf/ifcvf_base.h | 5 +++-- drivers/vdpa/ifcvf/ifcvf_main.c | 9 +++++--- 3 files changed, 29 insertions(+), 23 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +20
-18@@ -204,11 +204,29 @@ u64 ifcvf_get_hw_features(struct ifcvf_hw *hw)return features; } -u64 ifcvf_get_features (struct ifcvf_hw *hw) +/* return provisioned vDPA dev features */ +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw) {return hw->dev_features; } +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +u32 features_lo, features_hi; +u64 features; + +vp_iowrite32 (0 , &cfg->device_feature_select); + features_lo =vp_ioread32 (&cfg->guest_feature); + +vp_iowrite32 (1 , &cfg->device_feature_select); + features_hi =vp_ioread32 (&cfg->guest_feature); + + features = ((u64 )features_hi <<32 ) | features_lo; + +return features; +} +int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features) {if (!(features &BIT_ULL (VIRTIO_F_ACCESS_PLATFORM )) && features) {@@ -275,7 +293,7 @@ void ifcvf_write_dev_config(struct ifcvf_hw *hw, u64 offset,vp_iowrite8 (*p++, hw->dev_cfg + offset + i); } -static void ifcvf_set_features (struct ifcvf_hw *hw,u64 features) +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features) {struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;@@ -286,19 +304,6 @@ static void ifcvf_set_features(struct ifcvf_hw *hw, u64 features)vp_iowrite32 (features >>32 , &cfg->guest_feature); } -static int ifcvf_config_features (struct ifcvf_hw *hw) -{ -ifcvf_set_features (hw, hw->req_features); -ifcvf_add_status (hw,VIRTIO_CONFIG_S_FEATURES_OK ); - -if (!(ifcvf_get_status (hw) &VIRTIO_CONFIG_S_FEATURES_OK )) { -IFCVF_ERR (hw->pdev,"Failed to set FEATURES_OK status\n" ); -return -EIO ; - } - -return 0 ; -} -u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid) {struct ifcvf_lm_cfg __iomem *ifcvf_lm;@@ -387,9 +392,6 @@ int ifcvf_start_hw(struct ifcvf_hw *hw)ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE );ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER ); -if (ifcvf_config_features (hw) <0 ) -return -EINVAL ; -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK );return 0 ;drivers/vdpa/ifcvf/ifcvf_base.h +3
-2@@ -69,7 +69,6 @@ struct ifcvf_hw {phys_addr_t notify_base_pa;u32 notify_off_multiplier;u32 dev_type; -u64 req_features;u64 hw_features;/* provisioned device features */ u64 dev_features;@@ -122,7 +121,7 @@ u8 ifcvf_get_status(struct ifcvf_hw *hw);void ifcvf_set_status (struct ifcvf_hw *hw,u8 status);void io_write64_twopart (u64 val,u32 *lo,u32 *hi);void ifcvf_reset (struct ifcvf_hw *hw); -u64 ifcvf_get_features (struct ifcvf_hw *hw); +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw);u64 ifcvf_get_hw_features (struct ifcvf_hw *hw);int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features);u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid);@@ -137,4 +136,6 @@ int ifcvf_set_vq_address(struct ifcvf_hw *hw, u16 qid, u64 desc_area, u64 driver_area, u64 device_area);bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid);void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready); +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features); +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw);#endif /* _IFCVF_H_ */ drivers/vdpa/ifcvf/ifcvf_main.c +5
-2@@ -410,7 +410,7 @@ static u64 ifcvf_vdpa_get_device_features(struct vdpa_device *vdpa_dev)u64 features;if (type ==VIRTIO_ID_NET || type ==VIRTIO_ID_BLOCK ) - features =ifcvf_get_features (vf); + features =ifcvf_get_dev_features (vf);else { features =0 ;IFCVF_ERR (pdev,"VIRTIO ID %u not supported\n" , vf->dev_type);@@ -428,7 +428,7 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featif (ret)return ret; - vf->req_features = features; +ifcvf_set_driver_features (vf, features);return 0 ; }@@ -436,8 +436,11 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featstatic u64 ifcvf_vdpa_get_driver_features (struct vdpa_device *vdpa_dev) {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); +u64 features; + + features =ifcvf_get_driver_features (vf);
Quoted 7 lines
Quoted 7 lines
drivers/vdpa/ifcvf/ifcvf_main.c +1
-1-return vf->req_features; +return features; }static u8 ifcvf_vdpa_get_status (struct vdpa_device *vdpa_dev)Signature · 1 line
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Quoted 4 lines
Quoted 2 lines
This series also implement irq synchronization in the reset routine
Please, prefix each patch subject with vDPA/ifcvf:
I will fix this in V2. Thanks
Quoted 9 lines
Quoted 9 lines
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILED
Quoted 7 lines
Quoted 7 lines
drivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)Signature · 1 line
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 42 lines · Jason Wang
Quoted 41 lines · Michael S. Tsirkin
Quoted 38 lines · Jason Wang
Quoted 31 lines · Lingshan
Quoted 27 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
Formerly, ifcvf driver has implemented a lazy-initialization mechanism for the virtqueues and other config space contents,
it would store all configurations that passed down from the userspace, then load them to the device config space uponDRIVER_OK.This can not serve live migration, so this series implement an immediate initialization mechanism, which means rather than the former store-load process, the virtio operations like vq ops would take immediate actions by access the virtio registers.
Quoted 6 lines
Is there any chance that ifcvf can use
virtio_pci_modern_devlibrary?Then we don't need to duplicate the codes.
Note that
pds_vdpawill be the second user forvirtio_pci_modern_devlibrary (and the first vDPA parent to use that library).Yes I agree this library can help a lot for a standard virtio pci device. But this change would be huge, its like require to change every line of the driver. For example current driver functions work on the adapter and
ifcvf_hw, if we wants to reuse the lib, we need the driver work on structvirtio_pci_modern_device.
Almost need to re-write the driver.Quoted 2 lines
Quoted 1 line
Can we plan this huge change in following series?
ping
Will go through this this week.
Thanks
Quoted 7 lines
Quoted 1 line
why do you expect it to go through, you didn't ack?
I meant I will have a look at it this week,
(Google told me "go through" meant "to look at or examine something carefully")
Thanks
Oh, I misread what you wrote. Indeed. For some reason I read "this will go through this week". That would have been different.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Thanks,
Zhu LingshanQuoted 19 lines
Thanks
Quoted 16 lines
This series also implement irq synchronization in the reset routine
Zhu Lingshan (5):
virt queue ops take immediate actionsget_driver_featuresfrom virito registers retireifcvf_start_datapathandifcvf_add_statussynchronize irqs in the reset routine
a vendor driver should not set_CONFIG_S_FAILEDdrivers/vdpa/ifcvf/ifcvf_base.c | 162 +++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 16 ++-- drivers/vdpa/ifcvf/ifcvf_main.c | 97 ++++--------------- 3 files changed, 122 insertions(+), 153 deletions(-)
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
2.39.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 1/5] virt queue ops take immediate actions
In reply to Zhu LingshanQuoted 85 lines · Zhu Lingshan
In this commit, virtqueue operations including:
set_vq_num(),set_vq_address(),set_vq_ready()
andget_vq_ready()access PCI registers directly
to take immediate actions.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/ifcvf/ifcvf_base.c | 58 ++++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 10 +++--- drivers/vdpa/ifcvf/ifcvf_main.c | 16 +++------ 3 files changed, 45 insertions(+), 39 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +36
-18@@ -329,31 +329,49 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num)return 0 ; } -static int ifcvf_hw_enable (struct ifcvf_hw *hw) +void ifcvf_set_vq_num (struct ifcvf_hw *hw,u16 qid,u32 num) { -struct virtio_pci_common_cfg __iomem *cfg; -u32 i; +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; - cfg = hw->common_cfg; -for (i =0 ; i < hw->nr_vring; i++) { -if (!hw->vring[i].ready) -break ; +vp_iowrite16 (qid, &cfg->queue_select); +vp_iowrite16 (num, &cfg->queue_size); +} -vp_iowrite16 (i, &cfg->queue_select); -vp_iowrite64_twopart (hw->vring[i].desc, &cfg->queue_desc_lo, - &cfg->queue_desc_hi); -vp_iowrite64_twopart (hw->vring[i].avail, &cfg->queue_avail_lo, - &cfg->queue_avail_hi); -vp_iowrite64_twopart (hw->vring[i].used, &cfg->queue_used_lo, - &cfg->queue_used_hi); -vp_iowrite16 (hw->vring[i].size, &cfg->queue_size); -ifcvf_set_vq_state (hw, i, hw->vring[i].last_avail_idx); -vp_iowrite16 (1 , &cfg->queue_enable); - } +int ifcvf_set_vq_address (struct ifcvf_hw *hw,u16 qid,u64 desc_area, +u64 driver_area,u64 device_area) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + +vp_iowrite16 (qid, &cfg->queue_select); +vp_iowrite64_twopart (desc_area, &cfg->queue_desc_lo, + &cfg->queue_desc_hi); +vp_iowrite64_twopart (driver_area, &cfg->queue_avail_lo, + &cfg->queue_avail_hi); +vp_iowrite64_twopart (device_area, &cfg->queue_used_lo, + &cfg->queue_used_hi);return 0 ; } +bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +u16 queue_enable; + +vp_iowrite16 (qid, &cfg->queue_select); + queue_enable =vp_ioread16 (&cfg->queue_enable); + +return (bool )queue_enable; +} + +void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + +vp_iowrite16 (qid, &cfg->queue_select); +vp_iowrite16 (ready, &cfg->queue_enable); +} +static void ifcvf_hw_disable (struct ifcvf_hw *hw) {u32 i;
drivers/vdpa/ifcvf/ifcvf_base.c static void ifcvf_hw_disable(struct ifcvf_hw *hw) · line 369
Quoted 4 lines
drivers/vdpa/ifcvf/ifcvf_base.c +0
-1@@ -366,16 +384,12 @@ static void ifcvf_hw_disable(struct ifcvf_hw *hw)int ifcvf_start_hw (struct ifcvf_hw *hw) { -ifcvf_reset (hw);
This seems unrelated to the immediate actions?
The rest looks good.
Thanks
Quoted 83 lines
drivers/vdpa/ifcvf/ifcvf_base.c +0
-3ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE );ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER );if (ifcvf_config_features (hw) <0 )return -EINVAL ; -if (ifcvf_hw_enable (hw) <0 ) -return -EINVAL ; -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK );return 0 ;drivers/vdpa/ifcvf/ifcvf_base.h +5
-5@@ -47,12 +47,7 @@#define MSIX_VECTOR_DEV_SHARED 3struct vring_info { -u64 desc; -u64 avail; -u64 used; -u16 size;u16 last_avail_idx; -bool ready;void __iomem *notify_addr;phys_addr_t notify_pa;u32 irq;@@ -137,4 +132,9 @@ int ifcvf_probed_virtio_net(struct ifcvf_hw *hw);u32 ifcvf_get_config_size (struct ifcvf_hw *hw);u16 ifcvf_set_vq_vector (struct ifcvf_hw *hw,u16 qid,int vector);u16 ifcvf_set_config_vector (struct ifcvf_hw *hw,int vector); +void ifcvf_set_vq_num (struct ifcvf_hw *hw,u16 qid,u32 num); +int ifcvf_set_vq_address (struct ifcvf_hw *hw,u16 qid,u64 desc_area, +u64 driver_area,u64 device_area); +bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid); +void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready);#endif /* _IFCVF_H_ */ drivers/vdpa/ifcvf/ifcvf_main.c +3
-7@@ -382,10 +382,6 @@ static void ifcvf_reset_vring(struct ifcvf_adapter *adapter)for (i =0 ; i < vf->nr_vring; i++) { vf->vring[i].last_avail_idx =0 ; - vf->vring[i].desc =0 ; - vf->vring[i].avail =0 ; - vf->vring[i].used =0 ; - vf->vring[i].ready =0 ; vf->vring[i].cb.callback =NULL ; vf->vring[i].cb.private =NULL ; }@@ -542,14 +538,14 @@ static void ifcvf_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); - vf->vring[qid].ready = ready; +ifcvf_set_vq_ready (vf, qid, ready); }static bool ifcvf_vdpa_get_vq_ready (struct vdpa_device *vdpa_dev,u16 qid) {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); -return vf->vring[qid].ready; +return ifcvf_get_vq_ready (vf, qid); } static void ifcvf_vdpa_set_vq_num(struct vdpa_device *vdpa_dev, u16 qid,@@ -557,7 +553,7 @@ static void ifcvf_vdpa_set_vq_num(struct vdpa_device *vdpa_dev, u16 qid, {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); - vf->vring[qid].size = num; +ifcvf_set_vq_num (vf, qid, num); } static int ifcvf_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid,@@ -566,11 +562,7 @@ static int ifcvf_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid, {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev);
drivers/vdpa/ifcvf/ifcvf_main.c static int ifcvf_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid, · line 568
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_main.c +1
-5- vf->vring[qid].desc = desc_area; - vf->vring[qid].avail = driver_area; - vf->vring[qid].used = device_area; - -return 0 ; +return ifcvf_set_vq_address (vf, qid, desc_area, driver_area, device_area); }static void ifcvf_vdpa_kick_vq (struct vdpa_device *vdpa_dev,u16 qid)
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 2/5] get_driver_features from virito registers
In reply to Zhu LingshanQuoted 36 lines · Zhu Lingshan
This commit implements a new function
ifcvf_get_driver_feature()which readdriver_featuresfrom virtio registers.To be less ambiguous,
ifcvf_set_features()is renamed toifcvf_set_driver_features(), andifcvf_get_features()is renamed toifcvf_get_dev_features()which returns the provisioned vDPA device features.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/ifcvf/ifcvf_base.c | 38 +++++++++++++++++---------------- drivers/vdpa/ifcvf/ifcvf_base.h | 5 +++-- drivers/vdpa/ifcvf/ifcvf_main.c | 9 +++++--- 3 files changed, 29 insertions(+), 23 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +8
-1@@ -204,11 +204,29 @@ u64 ifcvf_get_hw_features(struct ifcvf_hw *hw)return features; } -u64 ifcvf_get_features (struct ifcvf_hw *hw) +/* return provisioned vDPA dev features */ +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw) {return hw->dev_features; } +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw) +{ +struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; +u32 features_lo, features_hi; +u64 features; +
drivers/vdpa/ifcvf/ifcvf_base.c u64 ifcvf_get_hw_features(struct ifcvf_hw *hw) · line 228
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_base.c +10
-0+vp_iowrite32 (0 , &cfg->device_feature_select); + features_lo =vp_ioread32 (&cfg->guest_feature); + +vp_iowrite32 (1 , &cfg->device_feature_select); + features_hi =vp_ioread32 (&cfg->guest_feature); + + features = ((u64 )features_hi <<32 ) | features_lo; + +return features; +}
This duplicates with the logic ifcvf_get_hw_features(), it would be simpler if we just do a rename.
Thanks
Quoted 96 lines
drivers/vdpa/ifcvf/ifcvf_base.c +2
-17+int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features) {if (!(features &BIT_ULL (VIRTIO_F_ACCESS_PLATFORM )) && features) {@@ -275,7 +293,7 @@ void ifcvf_write_dev_config(struct ifcvf_hw *hw, u64 offset,vp_iowrite8 (*p++, hw->dev_cfg + offset + i); } -static void ifcvf_set_features (struct ifcvf_hw *hw,u64 features) +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features) {struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;@@ -286,19 +304,6 @@ static void ifcvf_set_features(struct ifcvf_hw *hw, u64 features)vp_iowrite32 (features >>32 , &cfg->guest_feature); } -static int ifcvf_config_features (struct ifcvf_hw *hw) -{ -ifcvf_set_features (hw, hw->req_features); -ifcvf_add_status (hw,VIRTIO_CONFIG_S_FEATURES_OK ); - -if (!(ifcvf_get_status (hw) &VIRTIO_CONFIG_S_FEATURES_OK )) { -IFCVF_ERR (hw->pdev,"Failed to set FEATURES_OK status\n" ); -return -EIO ; - } - -return 0 ; -} -u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid) {struct ifcvf_lm_cfg __iomem *ifcvf_lm;@@ -387,9 +392,6 @@ int ifcvf_start_hw(struct ifcvf_hw *hw)ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE );ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER ); -if (ifcvf_config_features (hw) <0 ) -return -EINVAL ; -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK );return 0 ;drivers/vdpa/ifcvf/ifcvf_base.h +3
-2@@ -69,7 +69,6 @@ struct ifcvf_hw {phys_addr_t notify_base_pa;u32 notify_off_multiplier;u32 dev_type; -u64 req_features;u64 hw_features;/* provisioned device features */ u64 dev_features;@@ -122,7 +121,7 @@ u8 ifcvf_get_status(struct ifcvf_hw *hw);void ifcvf_set_status (struct ifcvf_hw *hw,u8 status);void io_write64_twopart (u64 val,u32 *lo,u32 *hi);void ifcvf_reset (struct ifcvf_hw *hw); -u64 ifcvf_get_features (struct ifcvf_hw *hw); +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw);u64 ifcvf_get_hw_features (struct ifcvf_hw *hw);int ifcvf_verify_min_features (struct ifcvf_hw *hw,u64 features);u16 ifcvf_get_vq_state (struct ifcvf_hw *hw,u16 qid);@@ -137,4 +136,6 @@ int ifcvf_set_vq_address(struct ifcvf_hw *hw, u16 qid, u64 desc_area, u64 driver_area, u64 device_area);bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid);void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready); +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features); +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw);#endif /* _IFCVF_H_ */ drivers/vdpa/ifcvf/ifcvf_main.c +2
-2@@ -410,7 +410,7 @@ static u64 ifcvf_vdpa_get_device_features(struct vdpa_device *vdpa_dev)u64 features;if (type ==VIRTIO_ID_NET || type ==VIRTIO_ID_BLOCK ) - features =ifcvf_get_features (vf); + features =ifcvf_get_dev_features (vf);else { features =0 ;IFCVF_ERR (pdev,"VIRTIO ID %u not supported\n" , vf->dev_type);@@ -428,7 +428,7 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featif (ret)return ret; - vf->req_features = features; +ifcvf_set_driver_features (vf, features);return 0 ; }@@ -436,8 +436,11 @@ static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featstatic u64 ifcvf_vdpa_get_driver_features (struct vdpa_device *vdpa_dev) {
drivers/vdpa/ifcvf/ifcvf_main.c static int ifcvf_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 feat · line 446
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_main.c +4
-1struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); +u64 features; + + features =ifcvf_get_driver_features (vf); -return vf->req_features; +return features; }static u8 ifcvf_vdpa_get_status (struct vdpa_device *vdpa_dev)
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/5] retire ifcvf_start_datapath and ifcvf_add_status
In reply to Zhu LingshanQuoted 6 lines · Zhu Lingshan
Rather than former lazy-initialization mechanism, now the virtqueue operations and
driver_featuresrelated ops access the virtio registers directly to take immediate actions. Soifcvf_start_datapath()should retire.
Quoted 6 lines
ifcvf_add_status()is retierd because we should not change device status by a vendor driver's decision, this driver should only set device status which is from virito drivers uponvdpa_ops.set_status()Signed-off-by Zhu Lingshan <[email protected]>
Thanks
Quoted 98 lines
--- drivers/vdpa/ifcvf/ifcvf_base.c | 19 ------------------- drivers/vdpa/ifcvf/ifcvf_base.h | 1 - drivers/vdpa/ifcvf/ifcvf_main.c | 23 ----------------------- 3 files changed, 43 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +0
-19@@ -178,15 +178,6 @@ void ifcvf_reset(struct ifcvf_hw *hw)ifcvf_get_status (hw); } -static void ifcvf_add_status (struct ifcvf_hw *hw,u8 status) -{ -if (status !=0 ) - status |=ifcvf_get_status (hw); - -ifcvf_set_status (hw, status); -ifcvf_get_status (hw); -} -u64 ifcvf_get_hw_features (struct ifcvf_hw *hw) {struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;@@ -387,16 +378,6 @@ static void ifcvf_hw_disable(struct ifcvf_hw *hw) } } -int ifcvf_start_hw (struct ifcvf_hw *hw) -{ -ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE ); -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER ); - -ifcvf_add_status (hw,VIRTIO_CONFIG_S_DRIVER_OK ); - -return 0 ; -} -void ifcvf_stop_hw (struct ifcvf_hw *hw) {ifcvf_hw_disable (hw);drivers/vdpa/ifcvf/ifcvf_base.h +0
-1@@ -110,7 +110,6 @@ struct ifcvf_vdpa_mgmt_dev { };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);void ifcvf_notify_queue (struct ifcvf_hw *hw,u16 qid); void ifcvf_read_dev_config(struct ifcvf_hw *hw, u64 offset,drivers/vdpa/ifcvf/ifcvf_main.c +0
-18@@ -346,22 +346,6 @@ static int ifcvf_request_irq(struct ifcvf_hw *vf)return 0 ; } -static int ifcvf_start_datapath (struct ifcvf_adapter *adapter) -{ -struct ifcvf_hw *vf = adapter->vf; -u8 status; -int ret; - - ret =ifcvf_start_hw (vf); -if (ret <0 ) { - status =ifcvf_get_status (vf); - status |=VIRTIO_CONFIG_S_FAILED ; -ifcvf_set_status (vf, status); - } - -return ret; -} -static int ifcvf_stop_datapath (struct ifcvf_adapter *adapter) {struct ifcvf_hw *vf = adapter->vf;@@ -452,13 +436,11 @@ static u8 ifcvf_vdpa_get_status(struct vdpa_device *vdpa_dev)static void ifcvf_vdpa_set_status (struct vdpa_device *vdpa_dev,u8 status) { -struct ifcvf_adapter *adapter;struct ifcvf_hw *vf;u8 status_old;int ret; vf =vdpa_to_vf (vdpa_dev); - adapter =vdpa_to_adapter (vdpa_dev); status_old =ifcvf_get_status (vf);if (status_old == status)@@ -473,11 +455,6 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status)ifcvf_set_status (vf, status);
drivers/vdpa/ifcvf/ifcvf_main.c static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) · line 460
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_main.c +0
-5return ; } - -if (ifcvf_start_datapath (adapter) <0 ) -IFCVF_ERR (adapter->pdev, -"Failed to set ifcvf vdpa status %u\n" , - status); }ifcvf_set_status (vf, status);
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 4/5] synchronize irqs in the reset routine
In reply to Zhu LingshanQuoted 15 lines · Zhu Lingshan
This commit synchronize irqs of the virtqueues and config space in the reset routine.
Thusifcvf_stop_hw()andreset()are refactored as well.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/ifcvf/ifcvf_base.c | 61 ++++++++++++++++++++++++++------- drivers/vdpa/ifcvf/ifcvf_main.c | 45 +++--------------------- 2 files changed, 54 insertions(+), 52 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +0
-0
drivers/vdpa/ifcvf/ifcvf_base.c void ifcvf_set_status(struct ifcvf_hw *hw, u8 status) · line 178
Quoted 9 lines
drivers/vdpa/ifcvf/ifcvf_base.c +0
-5@@ -170,12 +170,7 @@ void ifcvf_set_status(struct ifcvf_hw *hw, u8 status)void ifcvf_reset (struct ifcvf_hw *hw) { - hw->config_cb.callback =NULL ; - hw->config_cb.private =NULL ; -ifcvf_set_status (hw,0 ); -/* flush set_status, make sure VF is stopped, reset */ -ifcvf_get_status (hw);
If we don't flush or poll how can we know the reset is done?
E.g modern virtio-pci did:
/* 0 status means a reset. */
vp_modern_set_status(mdev, 0);
/* After writing 0 to device_status, the driver MUST wait for a read of
* device_status to return 0 before reinitializing the device.
* This will flush out the status write, and flush in device writes,
* including MSI-X interrupts, if any.
*/
while (vp_modern_get_status(mdev))
msleep(1);
/* Flush pending VQ/configuration callbacks. */ vp_synchronize_vectors(vdev);
Quoted 27 lines
drivers/vdpa/ifcvf/ifcvf_base.c +10
-5}u64 ifcvf_get_hw_features (struct ifcvf_hw *hw)@@ -368,20 +363,62 @@ void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready)vp_iowrite16 (ready, &cfg->queue_enable); } -static void ifcvf_hw_disable (struct ifcvf_hw *hw) +static void synchronize_per_vq_irq (struct ifcvf_hw *hw) { -u32 i; +u16 qid; -ifcvf_set_config_vector (hw,VIRTIO_MSI_NO_VECTOR ); -for (i =0 ; i < hw->nr_vring; i++) { -ifcvf_set_vq_vector (hw, i,VIRTIO_MSI_NO_VECTOR ); +for (qid =0 ; qid < hw->nr_vring; qid++) { +if (hw->vring[qid].irq != -EINVAL ) +synchronize_irq (hw->vring[qid].irq); } } +static void synchronize_vqs_reused_irq (struct ifcvf_hw *hw) +{ +if (hw->vqs_reused_irq != -EINVAL ) +synchronize_irq (hw->vqs_reused_irq); +}
drivers/vdpa/ifcvf/ifcvf_base.c void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready) · line 390
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_base.c +10
-0+ +static void synchronize_vq_irq (struct ifcvf_hw *hw) +{ +u8 status = hw->msix_vector_status; + +if (status ==MSIX_VECTOR_PER_VQ_AND_CONFIG ) +synchronize_per_vq_irq (hw); +else +synchronize_vqs_reused_irq (hw); +}
I wonder if we need to go with such complicated ways,can we synchronize through the vectors like virtio-pci did?
for (i = 0; i < vp_dev->msix_vectors; ++i) synchronize_irq(pci_irq_vector(vp_dev->pci_dev, i)); ?
drivers/vdpa/ifcvf/ifcvf_base.c void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready) · line 403
Quoted 13 lines
drivers/vdpa/ifcvf/ifcvf_base.c +13
-0+ +static void synchronize_config_irq (struct ifcvf_hw *hw) +{ +if (hw->config_irq != -EINVAL ) +synchronize_irq (hw->config_irq); +} + +static void ifcvf_reset_vring (struct ifcvf_hw *hw) +{ +u16 qid; + +for (qid =0 ; qid < hw->nr_vring; qid++) { +synchronize_vq_irq (hw);
Since IRQ could be shared, this will result extra complexity, like a irq could be flushed multiple times?
Thanks
Quoted 80 lines
drivers/vdpa/ifcvf/ifcvf_base.c +16
-2+ hw->vring[qid].cb.callback =NULL ; + hw->vring[qid].cb.private =NULL ; +ifcvf_set_vq_vector (hw, qid,VIRTIO_MSI_NO_VECTOR ); + } +} + +static void ifcvf_reset_config_handler (struct ifcvf_hw *hw) +{ +synchronize_config_irq (hw); + hw->config_cb.callback =NULL ; + hw->config_cb.private =NULL ; +ifcvf_set_config_vector (hw,VIRTIO_MSI_NO_VECTOR ); +} +void ifcvf_stop_hw (struct ifcvf_hw *hw) { -ifcvf_hw_disable (hw); -ifcvf_reset (hw); +ifcvf_reset_vring (hw); +ifcvf_reset_config_handler (hw); }void ifcvf_notify_queue (struct ifcvf_hw *hw,u16 qid)drivers/vdpa/ifcvf/ifcvf_main.c +3
-37@@ -346,33 +346,6 @@ static int ifcvf_request_irq(struct ifcvf_hw *vf)return 0 ; } -static int ifcvf_stop_datapath (struct ifcvf_adapter *adapter) -{ -struct ifcvf_hw *vf = adapter->vf; -int i; - -for (i =0 ; i < vf->nr_vring; i++) - vf->vring[i].cb.callback =NULL ; - -ifcvf_stop_hw (vf); - -return 0 ; -} - -static void ifcvf_reset_vring (struct ifcvf_adapter *adapter) -{ -struct ifcvf_hw *vf = adapter->vf; -int i; - -for (i =0 ; i < vf->nr_vring; i++) { - vf->vring[i].last_avail_idx =0 ; - vf->vring[i].cb.callback =NULL ; - vf->vring[i].cb.private =NULL ; - } - -ifcvf_reset (vf); -} -static struct ifcvf_adapter *vdpa_to_adapter (struct vdpa_device *vdpa_dev) { return container_of(vdpa_dev, struct ifcvf_adapter, vdpa);@@ -462,23 +435,15 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status)static int ifcvf_vdpa_reset (struct vdpa_device *vdpa_dev) { -struct ifcvf_adapter *adapter; -struct ifcvf_hw *vf; -u8 status_old; - - vf =vdpa_to_vf (vdpa_dev); - adapter =vdpa_to_adapter (vdpa_dev); - status_old =ifcvf_get_status (vf); +struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); +u8 status =ifcvf_get_status (vf); -if (status_old ==0 ) -return 0 ; +ifcvf_stop_hw (vf); -if (status_old &VIRTIO_CONFIG_S_DRIVER_OK ) {
drivers/vdpa/ifcvf/ifcvf_main.c static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) · line 449
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_main.c +2
-3-ifcvf_stop_datapath (adapter); +if (status &VIRTIO_CONFIG_S_DRIVER_OK )ifcvf_free_irq (vf); - } -ifcvf_reset_vring (adapter); +ifcvf_reset (vf);return 0 ; }
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 5/5] a vendor driver should not set _CONFIG_S_FAILED
In reply to Zhu LingshanQuoted 5 lines · Zhu Lingshan
VIRTIO_CONFIG_S_FAILEDindicates the guest driver has given up the device due to fatal errors. So it is the guest decision, the vendor driver should not set this status to the device.Signed-off-by Zhu Lingshan <[email protected]>
Thanks
Quoted 9 lines
--- drivers/vdpa/ifcvf/ifcvf_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/vdpa/ifcvf/ifcvf_main.c +0
-0
drivers/vdpa/ifcvf/ifcvf_main.c static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) · line 429
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_main.c +1
-3@@ -423,9 +423,7 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) !(status_old & VIRTIO_CONFIG_S_DRIVER_OK)) { ret =ifcvf_request_irq (vf);if (ret) { - status =ifcvf_get_status (vf); - status |=VIRTIO_CONFIG_S_FAILED ; -ifcvf_set_status (vf, status); +IFCVF_ERR (vf->pdev,"failed to request irq with error %d\n" , ret);return ; } }
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 1/5] virt queue ops take immediate actions
In reply to Jason WangQuoted 81 lines · Jason Wang
Quoted 79 lines · Zhu Lingshan
In this commit, virtqueue operations including:
set_vq_num(),set_vq_address(),set_vq_ready()
andget_vq_ready()access PCI registers directly
to take immediate actions.Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/ifcvf/ifcvf_base.c | 58 ++++++++++++++++++++------------- drivers/vdpa/ifcvf/ifcvf_base.h | 10 +++--- drivers/vdpa/ifcvf/ifcvf_main.c | 16 +++------ 3 files changed, 45 insertions(+), 39 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +35
-15@@ -329,31 +329,49 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num) return 0; } -static int ifcvf_hw_enable(struct ifcvf_hw *hw) +void ifcvf_set_vq_num(struct ifcvf_hw *hw, u16 qid, u32 num) { - struct virtio_pci_common_cfg __iomem *cfg; - u32 i; + struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; - cfg = hw->common_cfg; - for (i = 0; i < hw->nr_vring; i++) { - if (!hw->vring[i].ready) - break; + vp_iowrite16(qid, &cfg->queue_select); + vp_iowrite16(num, &cfg->queue_size); +} - vp_iowrite16(i, &cfg->queue_select); - vp_iowrite64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo, - &cfg->queue_desc_hi); - vp_iowrite64_twopart(hw->vring[i].avail, &cfg->queue_avail_lo, - &cfg->queue_avail_hi); - vp_iowrite64_twopart(hw->vring[i].used, &cfg->queue_used_lo, - &cfg->queue_used_hi); - vp_iowrite16(hw->vring[i].size, &cfg->queue_size); - ifcvf_set_vq_state(hw, i, hw->vring[i].last_avail_idx); - vp_iowrite16(1, &cfg->queue_enable); - } +int ifcvf_set_vq_address (struct ifcvf_hw *hw,u16 qid,u64 desc_area, + u64 driver_area, u64 device_area) +{ + struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + + vp_iowrite16(qid, &cfg->queue_select); + vp_iowrite64_twopart(desc_area, &cfg->queue_desc_lo, + &cfg->queue_desc_hi); + vp_iowrite64_twopart(driver_area, &cfg->queue_avail_lo, + &cfg->queue_avail_hi); + vp_iowrite64_twopart(device_area, &cfg->queue_used_lo, + &cfg->queue_used_hi); return 0; } +bool ifcvf_get_vq_ready(struct ifcvf_hw *hw, u16 qid) +{ + struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + u16 queue_enable; + + vp_iowrite16(qid, &cfg->queue_select); + queue_enable = vp_ioread16(&cfg->queue_enable); + + return (bool)queue_enable; +} + +void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready) +{ + struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + + vp_iowrite16(qid, &cfg->queue_select); + vp_iowrite16(ready, &cfg->queue_enable); +} + static void ifcvf_hw_disable(struct ifcvf_hw *hw) {
Quoted 8 lines
drivers/vdpa/ifcvf/ifcvf_base.c static void ifcvf_hw_disable(struct ifcvf_hw *hw) · line 368
Quoted 5 lines
drivers/vdpa/ifcvf/ifcvf_base.c +0
-1u32 i;@@ -366,16 +384,12 @@ static void ifcvf_hw_disable(struct ifcvf_hw *hw) int ifcvf_start_hw(struct ifcvf_hw *hw) { - ifcvf_reset(hw);This seems unrelated to the immediate actions?
This is because we must not reset the device after vq settings already take affections, e.g., we must not reset the hw after set_vq_address or set_vq_ready.
Thanks
Quoted 83 lines
The rest looks good.
Thanks
Quoted 77 lines
drivers/vdpa/ifcvf/ifcvf_base.c +0
-2ifcvf_add_status (hw,VIRTIO_CONFIG_S_ACKNOWLEDGE ); ifcvf_add_status(hw, VIRTIO_CONFIG_S_DRIVER); if (ifcvf_config_features(hw) < 0) return -EINVAL; - if (ifcvf_hw_enable(hw) < 0) - return -EINVAL; - ifcvf_add_status(hw, VIRTIO_CONFIG_S_DRIVER_OK); return 0;drivers/vdpa/ifcvf/ifcvf_base.h +5
-5@@ -47,12 +47,7 @@ #define MSIX_VECTOR_DEV_SHARED 3 struct vring_info { - u64 desc; - u64 avail; - u64 used; - u16 size; u16 last_avail_idx; - bool ready; void __iomem *notify_addr; phys_addr_t notify_pa; u32 irq;@@ -137,4 +132,9 @@ int ifcvf_probed_virtio_net(struct ifcvf_hw *hw); u32 ifcvf_get_config_size(struct ifcvf_hw *hw); u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector); u16 ifcvf_set_config_vector(struct ifcvf_hw *hw, int vector); +void ifcvf_set_vq_num (struct ifcvf_hw *hw,u16 qid,u32 num); +int ifcvf_set_vq_address (struct ifcvf_hw *hw,u16 qid,u64 desc_area, + u64 driver_area, u64 device_area); +bool ifcvf_get_vq_ready (struct ifcvf_hw *hw,u16 qid); +void ifcvf_set_vq_ready (struct ifcvf_hw *hw,u16 qid,bool ready); #endif /* _IFCVF_H_ */drivers/vdpa/ifcvf/ifcvf_main.c +3
-4@@ -382,10 +382,6 @@ static void ifcvf_reset_vring(struct ifcvf_adapter *adapter) for (i = 0; i < vf->nr_vring; i++) { vf->vring[i].last_avail_idx = 0; - vf->vring[i].desc = 0; - vf->vring[i].avail = 0; - vf->vring[i].used = 0; - vf->vring[i].ready = 0; vf->vring[i].cb.callback = NULL; vf->vring[i].cb.private = NULL; }@@ -542,14 +538,14 @@ static void ifcvf_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, { struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); - vf->vring[qid].ready = ready; + ifcvf_set_vq_ready(vf, qid, ready); } static bool ifcvf_vdpa_get_vq_ready(struct vdpa_device *vdpa_dev, u16 qid) { struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); - return vf->vring[qid].ready; + return ifcvf_get_vq_ready(vf, qid); } static void ifcvf_vdpa_set_vq_num(struct vdpa_device *vdpa_dev, u16 qid,@@ -557,7 +553,7 @@ static void ifcvf_vdpa_set_vq_num(struct vdpa_device *vdpa_dev, u16 qid, { struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); - vf->vring[qid].size = num; + ifcvf_set_vq_num(vf, qid, num); } static int ifcvf_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid,@@ -566,11 +562,7 @@ static int ifcvf_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid, { struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); - vf->vring[qid].desc = desc_area;
Quoted 9 lines
Quoted 8 lines
drivers/vdpa/ifcvf/ifcvf_main.c +1
-4- vf->vring[qid].avail = driver_area; - vf->vring[qid].used = device_area; - - return 0; + return ifcvf_set_vq_address(vf, qid, desc_area, driver_area, device_area); }static void
ifcvf_vdpa_kick_vq(struct vdpa_device *vdpa_dev, u16 qid)
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 2/5] get_driver_features from virito registers
In reply to Jason WangQuoted 41 lines · Jason Wang
Quoted 39 lines · Zhu Lingshan
This commit implements a new function
ifcvf_get_driver_feature()which readdriver_featuresfrom virtio registers.To be less ambiguous,
ifcvf_set_features()is renamed toifcvf_set_driver_features(), andifcvf_get_features()is renamed toifcvf_get_dev_features()which returns the provisioned vDPA device features.Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/ifcvf/ifcvf_base.c | 38 +++++++++++++++++---------------- drivers/vdpa/ifcvf/ifcvf_base.h | 5 +++-- drivers/vdpa/ifcvf/ifcvf_main.c | 9 +++++--- 3 files changed, 29 insertions(+), 23 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +12
-0@@ -204,11 +204,29 @@ u64 ifcvf_get_hw_features(struct ifcvf_hw *hw) return features; } -u64 ifcvf_get_features(struct ifcvf_hw *hw) +/* return provisioned vDPA dev features */ +u64 ifcvf_get_dev_features(struct ifcvf_hw *hw) { return hw->dev_features; } +u64 ifcvf_get_driver_features(struct ifcvf_hw *hw) +{ + struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; + u32 features_lo, features_hi; + u64 features; + + vp_iowrite32(0, &cfg->device_feature_select); + features_lo = vp_ioread32(&cfg->guest_feature); + + vp_iowrite32(1, &cfg->device_feature_select); + features_hi = vp_ioread32(&cfg->guest_feature);
Quoted 8 lines
drivers/vdpa/ifcvf/ifcvf_base.c u64 ifcvf_get_hw_features(struct ifcvf_hw *hw) · line 228
Quoted 5 lines
drivers/vdpa/ifcvf/ifcvf_base.c +5
-0+ + features = ((u64)features_hi << 32) | features_lo; + + return features; +}This duplicates with the logic
ifcvf_get_hw_features(), it would be simpler if we just do a rename.
Yes, they look very similar. ifcvf_get_hw_features() reads virtio_pci_common_cfg.device_feature and ifcvf_get_driver_features reads virtio_pci_common_cfg.driver_feature.
Do you suggest we merge these two functions? something like this may look chaotic:
u64 ifcvf_get_features(struct ifcvf_hw *hw, bool device_feature) {
struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; u32 features_lo, features_hi;
u64 features;
if (device_feature) {vp_iowrite32(0, &cfg->device_feature_select); features_lo = vp_ioread32(&cfg->guest_feature); vp_iowrite32(1, &cfg->device_feature_select); features_hi = vp_ioread32(&cfg->guest_feature); } else {
vp_iowrite32(0, &cfg->device_feature_select); features_lo = vp_ioread32(&cfg->guest_feature);
vp_iowrite32(1, &cfg->device_feature_select); features_hi = vp_ioread32(&cfg->guest_feature);
}
features = ((u64)features_hi << 32) | features_lo;
return features;
}
Maybe separate functions looks better.
Quoted 97 lines
Thanks
Quoted 93 lines
drivers/vdpa/ifcvf/ifcvf_base.c +2
-0+ int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features) { if (!(features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM)) && features) {@@ -275,7 +293,7 @@ void ifcvf_write_dev_config(struct ifcvf_hw *hw,u64 offset, vp_iowrite8(*p++, hw->dev_cfg + offset + i); } -static void ifcvf_set_features(struct ifcvf_hw *hw, u64 features) +void ifcvf_set_driver_features(struct ifcvf_hw *hw, u64 features) { struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;@@ -286,19 +304,6 @@ static void
ifcvf_set_features(struct ifcvf_hw *hw, u64 features)vp_iowrite32(features >> 32, &cfg->guest_feature);
}
-static intifcvf_config_features(struct ifcvf_hw *hw)drivers/vdpa/ifcvf/ifcvf_base.c +0
-12-{ - ifcvf_set_features(hw, hw->req_features); - ifcvf_add_status(hw, VIRTIO_CONFIG_S_FEATURES_OK); - - if (!(ifcvf_get_status(hw) & VIRTIO_CONFIG_S_FEATURES_OK)) { - IFCVF_ERR(hw->pdev, "Failed to set FEATURES_OK status\n"); - return -EIO; - } - - return 0; -} -u16
ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid){
structifcvf_lm_cfg__iomem*ifcvf_lm;drivers/vdpa/ifcvf/ifcvf_base.c +0
-2@@ -387,9 +392,6 @@ int ifcvf_start_hw(struct ifcvf_hw *hw) ifcvf_add_status(hw, VIRTIO_CONFIG_S_ACKNOWLEDGE); ifcvf_add_status(hw, VIRTIO_CONFIG_S_DRIVER); - if (ifcvf_config_features(hw) < 0) - return -EINVAL; - ifcvf_add_status(hw, VIRTIO_CONFIG_S_DRIVER_OK); return 0;drivers/vdpa/ifcvf/ifcvf_base.h +3
-2@@ -69,7 +69,6 @@ struct ifcvf_hw { phys_addr_t notify_base_pa; u32 notify_off_multiplier; u32 dev_type; - u64 req_features; u64 hw_features; /* provisioned device features */ u64 dev_features;@@ -122,7 +121,7 @@ u8 ifcvf_get_status(struct ifcvf_hw *hw); void ifcvf_set_status(struct ifcvf_hw *hw, u8 status); void io_write64_twopart(u64 val, u32 *lo, u32 *hi); void ifcvf_reset(struct ifcvf_hw *hw); -u64 ifcvf_get_features (struct ifcvf_hw *hw); +u64 ifcvf_get_dev_features (struct ifcvf_hw *hw); u64 ifcvf_get_hw_features(struct ifcvf_hw *hw); int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features); u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid);@@ -137,4 +136,6 @@ int ifcvf_set_vq_address(struct ifcvf_hw *hw, u16 qid, u64 desc_area, u64 driver_area, u64 device_area); bool ifcvf_get_vq_ready(struct ifcvf_hw *hw, u16 qid); void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready); +void ifcvf_set_driver_features (struct ifcvf_hw *hw,u64 features); +u64 ifcvf_get_driver_features (struct ifcvf_hw *hw);#endif /* _IFCVF_H_ */
drivers/vdpa/ifcvf/ifcvf_main.c +1
-1@@ -410,7 +410,7 @@ static u64 ifcvf_vdpa_get_device_features(struct vdpa_device *vdpa_dev) u64 features; if (type == VIRTIO_ID_NET || type == VIRTIO_ID_BLOCK) - features = ifcvf_get_features(vf); + features = ifcvf_get_dev_features(vf); else { features = 0; IFCVF_ERR(pdev, "VIRTIO ID %u not supported\n", vf->dev_type);@@ -428,7 +428,7 @@ static int ifcvf_vdpa_set_driver_features(struct
vdpa_device*vdpa_dev, u64 feat
if (ret)
return ret;
-vf->req_features= features;
+ifcvf_set_driver_features(vf, features);
return 0;
}drivers/vdpa/ifcvf/ifcvf_main.c +0
-0@@ -436,8 +436,11 @@ static int ifcvf_vdpa_set_driver_features(struct
vdpa_device*vdpa_dev, u64 feat
static u64ifcvf_vdpa_get_driver_features(struct vdpa_device *vdpa_dev){
Quoted 9 lines
Quoted 8 lines
struct
ifcvf_hw*vf =vdpa_to_vf(vdpa_dev);
+ u64 features;
+
+ features =ifcvf_get_driver_features(vf);
- returnvf->req_features;
+ return features;
}
static u8ifcvf_vdpa_get_status(struct vdpa_device *vdpa_dev)
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 4/5] synchronize irqs in the reset routine
In reply to Jason WangQuoted 32 lines · Jason Wang
Quoted 15 lines · Zhu Lingshan
This commit synchronize irqs of the virtqueues and config space in the reset routine.
Thusifcvf_stop_hw()andreset()are refactored as well.Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/ifcvf/ifcvf_base.c| 61 ++++++++++++++++++++++++++-------drivers/vdpa/ifcvf/ifcvf_main.c| 45 +++---------------------2 files changed, 54 insertions(+), 52 deletions(-)drivers/vdpa/ifcvf/ifcvf_base.c +0
-0drivers/vdpa/ifcvf/ifcvf_base.c void ifcvf_set_status(struct ifcvf_hw *hw, u8 · line 178
Quoted 9 lines
drivers/vdpa/ifcvf/ifcvf_base.c +0
-5@@ -170,12 +170,7 @@ void ifcvf_set_status(struct ifcvf_hw *hw, u8 status) void ifcvf_reset(struct ifcvf_hw *hw) { - hw->config_cb.callback = NULL; - hw->config_cb.private = NULL; - ifcvf_set_status(hw, 0); - /* flush set_status, make sure VF is stopped, reset */ - ifcvf_get_status(hw);If we don't flush or poll how can we know the reset is done?
E.g modern virtio-pci did:
Quoted 11 lines
/* 0 status means a reset. */
vp_modern_set_status(mdev, 0);
/* After writing 0 todevice_status, the driver MUST wait for a read of
*device_statusto return 0 before reinitializing the device.
* This will flush out the status write, and flush in device writes,
* including MSI-X interrupts, if any.
*/
while (vp_modern_get_status(mdev))
msleep(1);
/* Flush pending VQ/configuration callbacks. */vp_synchronize_vectors(vdev);
Thanks, I can implement a similar get_status() here.
Quoted 39 lines
Quoted 25 lines
drivers/vdpa/ifcvf/ifcvf_base.c +9
-3} u64 ifcvf_get_hw_features(struct ifcvf_hw *hw)@@ -368,20 +363,62 @@ void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready) vp_iowrite16(ready, &cfg->queue_enable); } -static void ifcvf_hw_disable(struct ifcvf_hw *hw) +static void synchronize_per_vq_irq(struct ifcvf_hw *hw) { - u32 i; + u16 qid; - ifcvf_set_config_vector(hw, VIRTIO_MSI_NO_VECTOR); - for (i = 0; i < hw->nr_vring; i++) { - ifcvf_set_vq_vector(hw, i, VIRTIO_MSI_NO_VECTOR); + for (qid = 0; qid < hw->nr_vring; qid++) { + if (hw->vring[qid].irq != -EINVAL) + synchronize_irq(hw->vring[qid].irq); } } +static void synchronize_vqs_reused_irq(struct ifcvf_hw *hw) +{ + if (hw->vqs_reused_irq != -EINVAL) + synchronize_irq(hw->vqs_reused_irq); +}drivers/vdpa/ifcvf/ifcvf_base.c void ifcvf_set_vq_ready(struct ifcvf_hw *hw, · line 390
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_base.c +10
-0+ +static void synchronize_vq_irq (struct ifcvf_hw *hw) +{ + u8 status = hw->msix_vector_status; + + if (status == MSIX_VECTOR_PER_VQ_AND_CONFIG) + synchronize_per_vq_irq(hw); + else + synchronize_vqs_reused_irq(hw); +}I wonder if we need to go with such complicated ways,can we synchronize through the vectors like virtio-pci did?
Quoted 3 lines
for (i = 0; i <
vp_dev->msix_vectors; ++i)synchronize_irq(pci_irq_vector(vp_dev->pci_dev, i)); ?
I can record the number of msix_vectors and sycn irq based on it in V2.
Quoted 17 lines
Quoted 5 lines
drivers/vdpa/ifcvf/ifcvf_base.c +3
-0+ +static void synchronize_config_irq (struct ifcvf_hw *hw) +{drivers/vdpa/ifcvf/ifcvf_base.c void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready) · line 403
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_base.c +10
-0+ if (hw->config_irq != -EINVAL) + synchronize_irq(hw->config_irq); +} + +static void ifcvf_reset_vring (struct ifcvf_hw *hw) +{ + u16 qid; + + for (qid = 0; qid < hw->nr_vring; qid++) { + synchronize_vq_irq(hw);Since IRQ could be shared, this will result extra complexity, like a irq could be flushed multiple times?
No for this code path, E.g., if the all vqs share one irq, it will only be flushed once in synchronize_vqs_reused_irq()
Thanks
Quoted 80 lines
Thanks
Quoted 76 lines
drivers/vdpa/ifcvf/ifcvf_base.c +16
-2+ hw->vring[qid].cb.callback =NULL ; + hw->vring[qid].cb.private = NULL; + ifcvf_set_vq_vector(hw, qid, VIRTIO_MSI_NO_VECTOR); + } +} + +static void ifcvf_reset_config_handler (struct ifcvf_hw *hw) +{ + synchronize_config_irq(hw); + hw->config_cb.callback = NULL; + hw->config_cb.private = NULL; + ifcvf_set_config_vector(hw, VIRTIO_MSI_NO_VECTOR); +} + void ifcvf_stop_hw(struct ifcvf_hw *hw) { - ifcvf_hw_disable(hw); - ifcvf_reset(hw); + ifcvf_reset_vring(hw); + ifcvf_reset_config_handler(hw); } void ifcvf_notify_queue(struct ifcvf_hw *hw, u16 qid)drivers/vdpa/ifcvf/ifcvf_main.c +3
-34@@ -346,33 +346,6 @@ static int ifcvf_request_irq(struct ifcvf_hw *vf) return 0; } -static int ifcvf_stop_datapath(struct ifcvf_adapter *adapter) -{ - struct ifcvf_hw *vf = adapter->vf; - int i; - - for (i = 0; i < vf->nr_vring; i++) - vf->vring[i].cb.callback = NULL; - - ifcvf_stop_hw(vf); - - return 0; -} - -static void ifcvf_reset_vring (struct ifcvf_adapter *adapter) -{ - struct ifcvf_hw *vf = adapter->vf; - int i; - - for (i = 0; i < vf->nr_vring; i++) { - vf->vring[i].last_avail_idx = 0; - vf->vring[i].cb.callback = NULL; - vf->vring[i].cb.private = NULL; - } - - ifcvf_reset(vf); -} - static struct ifcvf_adapter *vdpa_to_adapter(struct vdpa_device *vdpa_dev) { return container_of(vdpa_dev, struct ifcvf_adapter, vdpa);@@ -462,23 +435,15 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) static int ifcvf_vdpa_reset(struct vdpa_device *vdpa_dev) { - struct ifcvf_adapter *adapter; - struct ifcvf_hw *vf; - u8 status_old; - - vf = vdpa_to_vf(vdpa_dev); - adapter = vdpa_to_adapter(vdpa_dev); - status_old = ifcvf_get_status(vf); + struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); + u8 status = ifcvf_get_status(vf); - if (status_old == 0) - return 0; + ifcvf_stop_hw(vf); - if (status_old & VIRTIO_CONFIG_S_DRIVER_OK) {
Quoted 9 lines
drivers/vdpa/ifcvf/ifcvf_main.c static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) · line 449
Quoted 8 lines
drivers/vdpa/ifcvf/ifcvf_main.c +2
-2- ifcvf_stop_datapath(adapter); + if (status & VIRTIO_CONFIG_S_DRIVER_OK) ifcvf_free_irq(vf); - } - ifcvf_reset_vring(adapter); + ifcvf_reset(vf); return 0; }
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization