All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Eli Cohen <elic@nvidia.com>
Cc: Laurent Vivier <lvivier@redhat.com>, mst <mst@redhat.com>,
	virtualization <virtualization@lists.linux-foundation.org>,
	eperezma <eperezma@redhat.com>,
	Si-Wei Liu <si-wei.liu@oracle.com>
Subject: Re: [PATCH v1 6/7] vdpa: Add support for querying control virtqueue index
Date: Fri, 10 Dec 2021 10:27:11 +0800	[thread overview]
Message-ID: <CACGkMEs8dW3QVcUmtG6qkU2h0R6tKtZWFow=Yf1GGPZ3O4spOQ@mail.gmail.com> (raw)
In-Reply-To: <20211209092053.GA113385@mtl-vdi-166.wap.labs.mlnx>

On Thu, Dec 9, 2021 at 5:21 PM Eli Cohen <elic@nvidia.com> wrote:
>
> On Thu, Dec 09, 2021 at 05:12:01PM +0800, Jason Wang wrote:
> > On Thu, Dec 9, 2021 at 4:26 PM Eli Cohen <elic@nvidia.com> wrote:
> > >
> > > On Thu, Dec 09, 2021 at 04:17:22PM +0800, Jason Wang wrote:
> > > > On Thu, Dec 9, 2021 at 4:04 PM Eli Cohen <elic@nvidia.com> wrote:
> > > > >
> > > > > On Thu, Dec 09, 2021 at 03:55:48PM +0800, Jason Wang wrote:
> > > > > > On Thu, Dec 9, 2021 at 3:09 PM Eli Cohen <elic@nvidia.com> wrote:
> > > > > > >
> > > > > > > On Thu, Dec 09, 2021 at 01:44:56PM +0800, Jason Wang wrote:
> > > > > > > > On Thu, Dec 9, 2021 at 4:15 AM Eli Cohen <elic@nvidia.com> wrote:
> > > > > > > > >
> > > > > > > > > Add netlink attribute and callback function to query the control VQ
> > > > > > > > > index of a device.
> > > > > > > > >
> > > > > > > > > Example:
> > > > > > > > >
> > > > > > > > > $ vdpa dev config show vdpa-a
> > > > > > > > >   vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 5 \
> > > > > > > > >   mtu 9000 ctrl_vq_idx 10
> > > > > > > >
> > > > > > > >
> > > > > > > > I still wonder about the motivation for this.
> > > > > > > To be able to show the stats for CVQ.
> > > > > >
> > > > > > Right.
> > > > > >
> > > > > > >
> > > > > > > > And as discussed, the
> > > > > > > > ctrl_vq_idx varies depending on whether MQ is negotiated.
> > > > > > >
> > > > > > > I handle this according to the spec and it depends on MQ.
> > > > > >
> > > > > > Yes, but there could be a chance that the cvq index changes after the
> > > > > > vdpa dev config show.
> > > > > >
> > > > >
> > > > > It depends on:
> > > > > VIRTIO_NET_F_CTRL_VQ
> > > > > VIRTIO_NET_F_MQ
> > > > >
> > > > > which can change only if the features are re-negotiated and that happens
> > > > > on driver in itialization.
> > > > >
> > > > > And on max_virtqueue_pairs which is also set at driver initialization.
> > > > >
> > > > > So I don't see any real issue here. Am I missing something?
> > > >
> > > > No. I meant technically there could be a re-negotiation that happens
> > > > in the middle:
> > > >
> > > > 1) vdpa dev config show
> > > > 2) feature renegotiation which change the cvq index
> > > > 3) getting cvq stats
> > > >
> > > > So the cvq index might be changed. E.g it could be changed from a cvq
> > > > to a rx queue. It might be easier to make the get index and stats
> > > > atomic.
> > > >
> > >
> > > The interface to read VQ stats is based on the user providing the index
> > > and getting the statistics.
> > >
> > > If we want to follow your suggestion then we need maybe to use a
> > > slightly modified command:
> > >
> > > For regular VQ:
> > > dpa dev vstats show vdpa-a qidx 0
> > >
> > > For CVQ:
> > > vdpa dev vstats show vdpa-a cvq
> >
> > This might be better, but we need to make sure cvq only works for the
> > device that has a cvq.
> >
>
> OK.
>
> > >
> > > And that raises another question. Do we want to report the CVQ index in
> > > config show?
> >
> > If we go with stats show vdpa-a cvq, we don't need to report the cvq index.
> >
>
> Maybe we should leave some kind of indication as to whether there is a
> CVQ. Maybe not the index itself by just "CVQ" so a user will know if
> it's worth trying to read cvq stats.
>
> Otherwise, the user will attempt to read and fail.
> What do you think?

I agree.

Thanks

>
> > Thanks
> >
> > >
> > > > Thanks
> > > >
> > > > >
> > > > > > Thanks
> > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Signed-off-by: Eli Cohen <elic@nvidia.com>
> > > > > > > > > ---
> > > > > > > > > v0 -> v1:
> > > > > > > > > 1. Use logic defined in the spec to deduce virtqueue index.
> > > > > > > > >
> > > > > > > > >  drivers/vdpa/vdpa.c       | 25 +++++++++++++++++++++++++
> > > > > > > > >  include/uapi/linux/vdpa.h |  1 +
> > > > > > > > >  2 files changed, 26 insertions(+)
> > > > > > > > >
> > > > > > > > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > > > > > > > index 3bf016e03512..b4d4b8a7ca4e 100644
> > > > > > > > > --- a/drivers/vdpa/vdpa.c
> > > > > > > > > +++ b/drivers/vdpa/vdpa.c
> > > > > > > > > @@ -712,6 +712,27 @@ static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callba
> > > > > > > > >         return msg->len;
> > > > > > > > >  }
> > > > > > > > >
> > > > > > > > > +static int vdpa_dev_net_ctrl_vq_fill(struct vdpa_device *vdev,
> > > > > > > > > +                                    struct sk_buff *msg,
> > > > > > > > > +                                    struct virtio_net_config *config,
> > > > > > > > > +                                    u64 features)
> > > > > > > > > +{
> > > > > > > > > +       u16 N;
> > > > > > > > > +
> > > > > > > > > +       /* control VQ index, if available, is deduced according to the logic
> > > > > > > > > +        * described in the virtio spec in section 5.1.2
> > > > > > > > > +        */
> > > > > > > > > +       if (!(features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
> > > > > > > > > +               return 0;
> > > > > > > > > +
> > > > > > > > > +       if (features & BIT_ULL(VIRTIO_NET_F_MQ))
> > > > > > > > > +               N = le16_to_cpu(config->max_virtqueue_pairs);
> > > > > > > > > +       else
> > > > > > > > > +               N = 1;
> > > > > > > > > +
> > > > > > > > > +       return nla_put_u16(msg, VDPA_ATTR_DEV_CTRL_VQ_IDX, 2 * N);
> > > > > > > > > +}
> > > > > > > > > +
> > > > > > > > >  static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
> > > > > > > > >                                        struct sk_buff *msg, u64 features,
> > > > > > > > >                                        const struct virtio_net_config *config)
> > > > > > > > > @@ -730,6 +751,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
> > > > > > > > >         struct virtio_net_config config = {};
> > > > > > > > >         u64 features;
> > > > > > > > >         u16 val_u16;
> > > > > > > > > +       int err;
> > > > > > > > >
> > > > > > > > >         vdpa_get_config(vdev, 0, &config, sizeof(config));
> > > > > > > > >
> > > > > > > > > @@ -746,6 +768,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
> > > > > > > > >                 return -EMSGSIZE;
> > > > > > > > >
> > > > > > > > >         features = vdev->config->get_driver_features(vdev);
> > > > > > > > > +       err = vdpa_dev_net_ctrl_vq_fill(vdev, msg, &config, features);
> > > > > > > > > +       if (err)
> > > > > > > > > +               return err;
> > > > > > > > >
> > > > > > > > >         return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
> > > > > > > > >  }
> > > > > > > > > diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h
> > > > > > > > > index a252f06f9dfd..2e3a7f89f42d 100644
> > > > > > > > > --- a/include/uapi/linux/vdpa.h
> > > > > > > > > +++ b/include/uapi/linux/vdpa.h
> > > > > > > > > @@ -34,6 +34,7 @@ enum vdpa_attr {
> > > > > > > > >         VDPA_ATTR_DEV_MAX_VQS,                  /* u32 */
> > > > > > > > >         VDPA_ATTR_DEV_MAX_VQ_SIZE,              /* u16 */
> > > > > > > > >         VDPA_ATTR_DEV_MIN_VQ_SIZE,              /* u16 */
> > > > > > > > > +       VDPA_ATTR_DEV_CTRL_VQ_IDX,              /* u16 */
> > > > > > > > >
> > > > > > > > >         VDPA_ATTR_DEV_NET_CFG_MACADDR,          /* binary */
> > > > > > > > >         VDPA_ATTR_DEV_NET_STATUS,               /* u8 */
> > > > > > > > > --
> > > > > > > > > 2.33.1
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  parent reply	other threads:[~2021-12-10  2:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211208201430.73720-1-elic@nvidia.com>
     [not found] ` <20211208201430.73720-3-elic@nvidia.com>
2021-12-09  0:12   ` [PATCH v1 2/7] vdpa/mlx5: Distribute RX virtqueues in RQT object Si-Wei Liu
     [not found]     ` <20211209065504.GB108239@mtl-vdi-166.wap.labs.mlnx>
2021-12-10  8:26       ` Si-Wei Liu
     [not found] ` <20211208201430.73720-4-elic@nvidia.com>
2021-12-09  0:25   ` [PATCH v1 3/7] vdpa: Allow to configure max data virtqueues Si-Wei Liu
2021-12-09  5:36     ` Jason Wang
2021-12-09 21:50       ` Si-Wei Liu
2021-12-10  2:29         ` Jason Wang
     [not found]           ` <20211213064453.GD41423@mtl-vdi-166.wap.labs.mlnx>
     [not found]             ` <20211213130734.GB44427@mtl-vdi-166.wap.labs.mlnx>
2021-12-14  0:47               ` Si-Wei Liu
     [not found] ` <20211208201430.73720-2-elic@nvidia.com>
2021-12-08 23:57   ` [PATCH v1 1/7] vdpa: Provide interface to read driver features Si-Wei Liu
     [not found]     ` <20211209064702.GA108239@mtl-vdi-166.wap.labs.mlnx>
2021-12-09 22:29       ` Si-Wei Liu
2021-12-12  9:45         ` Michael S. Tsirkin
     [not found]         ` <20211212133854.GA8840@mtl-vdi-166.wap.labs.mlnx>
2021-12-13 22:34           ` [PATCH v1 1/7] vdpa: Provide interface to read driver featuresy Si-Wei Liu
2021-12-09  5:33   ` [PATCH v1 1/7] vdpa: Provide interface to read driver features Jason Wang
     [not found]     ` <20211209070654.GD108239@mtl-vdi-166.wap.labs.mlnx>
2021-12-09  7:55       ` Jason Wang
     [not found] ` <20211208201430.73720-6-elic@nvidia.com>
2021-12-09  5:43   ` [PATCH v1 5/7] vdpa/mlx5: Support configuring max data virtqueue pairs Jason Wang
     [not found] ` <20211208201430.73720-7-elic@nvidia.com>
2021-12-09  0:59   ` [PATCH v1 6/7] vdpa: Add support for querying control virtqueue index Si-Wei Liu
2021-12-09  5:44   ` Jason Wang
     [not found]     ` <20211209070904.GE108239@mtl-vdi-166.wap.labs.mlnx>
2021-12-09  7:55       ` Jason Wang
     [not found]         ` <20211209080414.GA110931@mtl-vdi-166.wap.labs.mlnx>
2021-12-09  8:17           ` Jason Wang
     [not found]             ` <20211209082618.GA111658@mtl-vdi-166.wap.labs.mlnx>
2021-12-09  9:12               ` Jason Wang
     [not found]                 ` <20211209092053.GA113385@mtl-vdi-166.wap.labs.mlnx>
2021-12-10  2:27                   ` Jason Wang [this message]
2021-12-13  3:05                   ` Jason Wang
     [not found] ` <20211208201430.73720-8-elic@nvidia.com>
2021-12-10  8:17   ` [PATCH v1 7/7] vdpa/mlx5: Restore cur_num_vqs in case of failure in change_num_qps() Si-Wei Liu

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='CACGkMEs8dW3QVcUmtG6qkU2h0R6tKtZWFow=Yf1GGPZ3O4spOQ@mail.gmail.com' \
    --to=jasowang@redhat.com \
    --cc=elic@nvidia.com \
    --cc=eperezma@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=si-wei.liu@oracle.com \
    --cc=virtualization@lists.linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.