[dpdk-dev] [PATCH v3 09/10] vdpa/sfc: add support to set vring state

Xia, Chenbo chenbo.xia at intel.com
Tue Nov 2 09:18:24 CET 2021


> -----Original Message-----
> From: Vijay Srivastava <vijay.srivastava at xilinx.com>
> Sent: Friday, October 29, 2021 10:47 PM
> To: dev at dpdk.org
> Cc: maxime.coquelin at redhat.com; Xia, Chenbo <chenbo.xia at intel.com>;
> andrew.rybchenko at oktetlabs.ru; Vijay Kumar Srivastava <vsrivast at xilinx.com>
> Subject: [PATCH v3 09/10] vdpa/sfc: add support to set vring state
> 
> From: Vijay Kumar Srivastava <vsrivast at xilinx.com>
> 
> Implements vDPA ops set_vring_state to configure vring state.
> 
> Signed-off-by: Vijay Kumar Srivastava <vsrivast at xilinx.com>
> Acked-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
> Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
> ---
>  drivers/vdpa/sfc/sfc_vdpa_ops.c | 54 ++++++++++++++++++++++++++++++++++++++--
> -
>  1 file changed, 50 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c b/drivers/vdpa/sfc/sfc_vdpa_ops.c
> index 8551b65..3430643 100644
> --- a/drivers/vdpa/sfc/sfc_vdpa_ops.c
> +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.c
> @@ -719,11 +719,57 @@
>  static int
>  sfc_vdpa_set_vring_state(int vid, int vring, int state)
>  {
> -	RTE_SET_USED(vid);
> -	RTE_SET_USED(vring);
> -	RTE_SET_USED(state);
> +	struct sfc_vdpa_ops_data *ops_data;
> +	struct rte_vdpa_device *vdpa_dev;
> +	efx_rc_t rc;
> +	int vring_max;
> +	void *dev;
> 
> -	return -1;
> +	vdpa_dev = rte_vhost_get_vdpa_device(vid);
> +
> +	ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev);
> +	if (ops_data == NULL)
> +		return -1;
> +
> +	dev = ops_data->dev_handle;
> +
> +	sfc_vdpa_info(dev,
> +		      "vDPA ops set_vring_state: vid: %d, vring: %d, state:%d",
> +		      vid, vring, state);
> +
> +	vring_max = (sfc_vdpa_adapter_by_dev_handle(dev)->max_queue_count * 2);
> +
> +	if (vring < 0 || vring > vring_max) {
> +		sfc_vdpa_err(dev, "received invalid vring id : %d to set state",
> +			     vring);
> +		return -1;
> +	}
> +
> +	/*
> +	 * Skip if device is not yet started. virtqueues state can be
> +	 * changed once it is created and other configurations are done.
> +	 */
> +	if (ops_data->state != SFC_VDPA_STATE_STARTED)
> +		return 0;
> +
> +	if (ops_data->vq_cxt[vring].enable == state)
> +		return 0;
> +
> +	if (state == 0) {
> +		rc = sfc_vdpa_virtq_stop(ops_data, vring);
> +		if (rc != 0) {
> +			sfc_vdpa_err(dev, "virtqueue stop failed: %s",
> +				     rte_strerror(rc));
> +		}
> +	} else {
> +		rc = sfc_vdpa_virtq_start(ops_data, vring);
> +		if (rc != 0) {
> +			sfc_vdpa_err(dev, "virtqueue start failed: %s",
> +				     rte_strerror(rc));
> +		}
> +	}
> +
> +	return rc;
>  }
> 
>  static int
> --
> 1.8.3.1

Reviewed-by: Chenbo Xia <chenbo.xia at intel.com>


More information about the dev mailing list