[dpdk-dev] [PATCH 07/10] vdpa/sfc: add support to get queue notify area info
Maxime Coquelin
maxime.coquelin at redhat.com
Mon Aug 30 15:22:49 CEST 2021
On 7/6/21 6:44 PM, Vijay Srivastava wrote:
> From: Vijay Kumar Srivastava <vsrivast at xilinx.com>
>
> Implement the vDPA ops get_notify_area to get the notify
> area info of the queue.
>
> Signed-off-by: Vijay Kumar Srivastava <vsrivast at xilinx.com>
> ---
> drivers/vdpa/sfc/sfc_vdpa_ops.c | 166 ++++++++++++++++++++++++++++++++++++++--
> drivers/vdpa/sfc/sfc_vdpa_ops.h | 2 +
> 2 files changed, 162 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c b/drivers/vdpa/sfc/sfc_vdpa_ops.c
...
> +static int
> +sfc_vdpa_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)
> +{
> + int ret;
> + efx_nic_t *nic;
> + int vfio_dev_fd;
> + efx_rc_t rc;
> + unsigned int bar_offset;
> + struct rte_vdpa_device *vdpa_dev;
> + struct sfc_vdpa_ops_data *ops_data;
> + struct vfio_region_info reg = { .argsz = sizeof(reg) };
> + const efx_nic_cfg_t *encp;
> + int max_vring_cnt;
> + int64_t len;
> + void *dev;
> +
> + 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;
> +
> + vfio_dev_fd = sfc_vdpa_adapter_by_dev_handle(dev)->vfio_dev_fd;
> + max_vring_cnt =
> + (sfc_vdpa_adapter_by_dev_handle(dev)->max_queue_count * 2);
> +
> + nic = sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)->nic;
> + encp = efx_nic_cfg_get(nic);
> +
> + if (qid >= max_vring_cnt) {
> + sfc_vdpa_err(dev, "invalid qid : %d", qid);
> + return -1;
> + }
> +
> + if (ops_data->vq_cxt[qid].enable != B_TRUE) {
> + sfc_vdpa_err(dev, "vq is not enabled");
> + return -1;
> + }
> +
> + rc = efx_virtio_get_doorbell_offset(ops_data->vq_cxt[qid].vq,
> + &bar_offset);
> + if (rc != 0) {
> + sfc_vdpa_err(dev, "failed to get doorbell offset: %s",
> + rte_strerror(rc));
> + return rc;
> + }
> +
> + reg.index = sfc_vdpa_adapter_by_dev_handle(dev)->mem_bar.esb_rid;
> + ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®);
> + if (ret != 0) {
> + sfc_vdpa_err(dev, "could not get device region info: %s",
> + strerror(errno));
> + return ret;
> + }
> +
> + *offset = reg.offset + bar_offset;
> +
> + len = (1U << encp->enc_vi_window_shift) / 2;
> + if (len >= sysconf(_SC_PAGESIZE))
> + *size = sysconf(_SC_PAGESIZE);
> + else
> + return -1;
This error case may deserve an error messageto be logged.
> +
> + sfc_vdpa_info(dev, "vDPA ops get_notify_area :: offset : 0x%" PRIx64,
> + *offset);
> +
> + return 0;
> +}
> +
More information about the dev
mailing list