DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com,
	stephen@networkplumber.org
Subject: Re: [PATCH v2 16/21] net/virtio-user: allocate shadow control queue
Date: Thu, 9 Feb 2023 09:48:48 +0100	[thread overview]
Message-ID: <5fa83587-95ce-85a7-4cdd-a5670f2a811b@redhat.com> (raw)
In-Reply-To: <CAJaqyWegsqEZqPUF44Z9m6Zw-vgMtzQ2jFAMZLOe7cidM=11jQ@mail.gmail.com>



On 2/7/23 19:06, Eugenio Perez Martin wrote:
> On Tue, Feb 7, 2023 at 4:18 PM Maxime Coquelin
> <maxime.coquelin@redhat.com> wrote:
>>
>> If the backends supports control virtqueue, allocate a
>> shadow control virtqueue, and implement the notify callback
>> that writes into the kickfd.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
> 
> Even with the nitpick below,
> 
> Acked-by: Eugenio Pérez <eperezma@redhat.com>
> 
>> ---
>>   .../net/virtio/virtio_user/virtio_user_dev.c  | 47 ++++++++++++++++++-
>>   .../net/virtio/virtio_user/virtio_user_dev.h  |  5 ++
>>   drivers/net/virtio/virtio_user_ethdev.c       |  6 +++
>>   3 files changed, 56 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
>> index a3584e7735..16a0e07413 100644
>> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
>> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
>> @@ -146,8 +146,9 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)
>>
>>          /* Strip VIRTIO_NET_F_MAC, as MAC address is handled in vdev init */
>>          features &= ~(1ull << VIRTIO_NET_F_MAC);
>> -       /* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know */
>> -       features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
>> +       /* Strip VIRTIO_NET_F_CTRL_VQ if the devices does not really support control VQ */
>> +       if (!dev->hw_cvq)
>> +               features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
>>          features &= ~(1ull << VIRTIO_NET_F_STATUS);
>>          ret = dev->ops->set_features(dev, features);
>>          if (ret < 0)
>> @@ -911,6 +912,48 @@ virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx)
>>          }
>>   }
>>
>> +static void
>> +virtio_user_control_queue_notify(struct virtqueue *vq, void *cookie)
>> +{
>> +       struct virtio_user_dev *dev = cookie;
>> +       uint64_t buf = 1;
>> +
>> +       if (write(dev->kickfds[vq->vq_queue_index], &buf, sizeof(buf)) < 0)
>> +               PMD_DRV_LOG(ERR, "failed to kick backend: %s",
>> +                           strerror(errno));
>> +}
>> +
>> +int
>> +virtio_user_dev_create_shadow_cvq(struct virtio_user_dev *dev, struct virtqueue *vq)
>> +{
>> +       char name[VIRTQUEUE_MAX_NAME_SZ];
>> +       struct virtqueue *scvq;
>> +
>> +       snprintf(name, sizeof(name), "port%d_shadow_cvq", vq->hw->port_id);
>> +       scvq = virtqueue_alloc(&dev->hw, vq->vq_queue_index, vq->vq_nentries,
>> +                       VTNET_CQ, SOCKET_ID_ANY, name);
>> +       if (!scvq) {
>> +               PMD_INIT_LOG(ERR, "(%s) Failed to alloc shadow control vq\n", dev->path);
>> +               return -ENOMEM;
>> +       }
>> +
>> +       scvq->cq.notify_queue = &virtio_user_control_queue_notify;
>> +       scvq->cq.notify_cookie = dev;
>> +       dev->scvq = scvq;
>> +
>> +       return 0;
>> +}
>> +
>> +void
>> +virtio_user_dev_destroy_shadow_cvq(struct virtio_user_dev *dev)
>> +{
>> +       if (!dev->scvq)
>> +               return;
>> +
>> +       virtqueue_free(dev->scvq);
>> +       dev->scvq = NULL;
>> +}
>> +
>>   int
>>   virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status)
>>   {
>> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
>> index 3c5453eac0..e0db4faf3f 100644
>> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
>> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
>> @@ -58,6 +58,9 @@ struct virtio_user_dev {
>>          pthread_mutex_t mutex;
>>          bool            started;
>>
>> +       bool                    hw_cvq;
>> +       struct virtqueue        *scvq;
>> +
>>          void *backend_data;
>>   };
>>
>> @@ -74,6 +77,8 @@ void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
>>   void virtio_user_handle_cq_packed(struct virtio_user_dev *dev,
>>                                    uint16_t queue_idx);
>>   uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs);
>> +int virtio_user_dev_create_shadow_cvq(struct virtio_user_dev *dev, struct virtqueue *vq);
>> +void virtio_user_dev_destroy_shadow_cvq(struct virtio_user_dev *dev);
>>   int virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status);
>>   int virtio_user_dev_update_status(struct virtio_user_dev *dev);
>>   int virtio_user_dev_update_link_state(struct virtio_user_dev *dev);
>> diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
>> index 6c3e875793..626bd95b62 100644
>> --- a/drivers/net/virtio/virtio_user_ethdev.c
>> +++ b/drivers/net/virtio/virtio_user_ethdev.c
>> @@ -232,6 +232,9 @@ virtio_user_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
>>          else
>>                  virtio_user_setup_queue_split(vq, dev);
>>
>> +       if (dev->hw_cvq && hw->cvq && (virtnet_cq_to_vq(hw->cvq) == vq))
>> +               return virtio_user_dev_create_shadow_cvq(dev, vq);
>> +
>>          return 0;
>>   }
>>
>> @@ -251,6 +254,9 @@ virtio_user_del_queue(struct virtio_hw *hw, struct virtqueue *vq)
>>
>>          close(dev->callfds[vq->vq_queue_index]);
>>          close(dev->kickfds[vq->vq_queue_index]);
>> +
>> +       if (hw->cvq && (virtnet_cq_to_vq(hw->cvq) == vq) && dev->scvq)
> 
> Not sure if intended, but check for dev->scvq is already in
> virtio_user_dev_destroy_shadow_cvq.

This was not intended, I can remove it in next revision.

Thanks,
Maxime

> 
>> +               virtio_user_dev_destroy_shadow_cvq(dev);
>>   }
>>
>>   static void
>> --
>> 2.39.1
>>
> 


  reply	other threads:[~2023-02-09  8:49 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 15:17 [PATCH v2 00/21] Add control queue & MQ support to Virtio-user vDPA Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 01/21] net/virtio: move CVQ code into a dedicated file Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 02/21] net/virtio: introduce notify callback for control queue Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 03/21] net/virtio: virtqueue headers alloc refactoring Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 04/21] net/virtio: remove port ID info from Rx queue Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 05/21] net/virtio: remove unused fields in Tx queue struct Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 06/21] net/virtio: remove unused queue ID field in Rx queue Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 07/21] net/virtio: remove unused Port ID in control queue Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 08/21] net/virtio: move vring memzone to virtqueue struct Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 09/21] net/virtio: refactor indirect desc headers init Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 10/21] net/virtio: alloc Rx SW ring only if vectorized path Maxime Coquelin
2023-02-08  1:05   ` Xia, Chenbo
2023-02-07 15:17 ` [PATCH v2 11/21] net/virtio: extract virtqueue init from virtio queue init Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 12/21] net/virtio-user: fix device starting failure handling Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 13/21] net/virtio-user: simplify queues setup Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 14/21] net/virtio-user: use proper type for number of queue pairs Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 15/21] net/virtio-user: get max number of queue pairs from device Maxime Coquelin
2023-02-07 18:02   ` Eugenio Perez Martin
2023-02-07 15:17 ` [PATCH v2 16/21] net/virtio-user: allocate shadow control queue Maxime Coquelin
2023-02-07 18:06   ` Eugenio Perez Martin
2023-02-09  8:48     ` Maxime Coquelin [this message]
2023-02-07 15:17 ` [PATCH v2 17/21] net/virtio-user: send shadow virtqueue info to the backend Maxime Coquelin
2023-02-07 18:08   ` Eugenio Perez Martin
2023-02-07 15:17 ` [PATCH v2 18/21] net/virtio-user: add new callback to enable control queue Maxime Coquelin
2023-02-07 18:10   ` Eugenio Perez Martin
2023-02-09  8:50     ` Maxime Coquelin
2023-02-07 15:17 ` [PATCH v2 19/21] net/virtio-user: forward control messages to shadow queue Maxime Coquelin
2023-02-07 18:30   ` Eugenio Perez Martin
2023-02-08  1:06   ` Xia, Chenbo
2023-02-07 15:17 ` [PATCH v2 20/21] net/virtio-user: advertize control VQ support with vDPA Maxime Coquelin
2023-02-07 18:17   ` Eugenio Perez Martin
2023-02-07 15:17 ` [PATCH v2 21/21] net/virtio-user: remove max queues limitation Maxime Coquelin
2023-02-08  1:06   ` Xia, Chenbo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fa83587-95ce-85a7-4cdd-a5670f2a811b@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=chenbo.xia@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=eperezma@redhat.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).