All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vdpa: Warn if MTU configured is too low
@ 2022-05-11  8:48 Eli Cohen
  2022-05-11  9:34   ` Jason Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Cohen @ 2022-05-11  8:48 UTC (permalink / raw)
  To: mst, jasowang; +Cc: virtualization, linux-kernel, si-wei.liu, Eli Cohen

Following the recommendation in virio spec 1.1, a device offering
VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.

Print a warning if this recommendation is not met.

Signed-off-by: Eli Cohen <elic@nvidia.com>
---
 drivers/vdpa/vdpa.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 91f4c13c7c7c..961168fe9094 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
 				 BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
 				 BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
 
+/* Recommended virtio spec 1.1 section 5.1.4.1 */
+#define VIRTIO_MIN_PREFERRED_MTU 1280
+
 static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct vdpa_dev_set_config config = {};
@@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
 		err = PTR_ERR(mdev);
 		goto err;
 	}
+	if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
+	    (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
+	    config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
+		pr_warn("MTU is below recommended value\n");
 	if ((config.mask & mdev->config_attr_mask) != config.mask) {
 		NL_SET_ERR_MSG_MOD(info->extack,
 				   "All provided attributes are not supported");
@@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
 	[VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
 	[VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
 	/* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
-	[VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
+	[VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
 };
 
 static const struct genl_ops vdpa_nl_ops[] = {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
  2022-05-11  8:48 [PATCH] vdpa: Warn if MTU configured is too low Eli Cohen
@ 2022-05-11  9:34   ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2022-05-11  9:34 UTC (permalink / raw)
  To: Eli Cohen; +Cc: mst, virtualization, linux-kernel, Si-Wei Liu

On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
>
> Following the recommendation in virio spec 1.1, a device offering
> VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
>
> Print a warning if this recommendation is not met.
>
> Signed-off-by: Eli Cohen <elic@nvidia.com>

I wonder why it's a must?

> ---
>  drivers/vdpa/vdpa.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 91f4c13c7c7c..961168fe9094 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
>                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
>                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
>
> +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> +#define VIRTIO_MIN_PREFERRED_MTU 1280
> +
>  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
>  {
>         struct vdpa_dev_set_config config = {};
> @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
>                 err = PTR_ERR(mdev);
>                 goto err;
>         }
> +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))

Should be <= ?

Thanks

> +               pr_warn("MTU is below recommended value\n");
>         if ((config.mask & mdev->config_attr_mask) != config.mask) {
>                 NL_SET_ERR_MSG_MOD(info->extack,
>                                    "All provided attributes are not supported");
> @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
>         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
>         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
>         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
>  };
>
>  static const struct genl_ops vdpa_nl_ops[] = {
> --
> 2.35.1
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
@ 2022-05-11  9:34   ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2022-05-11  9:34 UTC (permalink / raw)
  To: Eli Cohen; +Cc: Si-Wei Liu, virtualization, linux-kernel, mst

On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
>
> Following the recommendation in virio spec 1.1, a device offering
> VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
>
> Print a warning if this recommendation is not met.
>
> Signed-off-by: Eli Cohen <elic@nvidia.com>

I wonder why it's a must?

> ---
>  drivers/vdpa/vdpa.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 91f4c13c7c7c..961168fe9094 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
>                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
>                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
>
> +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> +#define VIRTIO_MIN_PREFERRED_MTU 1280
> +
>  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
>  {
>         struct vdpa_dev_set_config config = {};
> @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
>                 err = PTR_ERR(mdev);
>                 goto err;
>         }
> +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))

Should be <= ?

Thanks

> +               pr_warn("MTU is below recommended value\n");
>         if ((config.mask & mdev->config_attr_mask) != config.mask) {
>                 NL_SET_ERR_MSG_MOD(info->extack,
>                                    "All provided attributes are not supported");
> @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
>         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
>         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
>         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
>  };
>
>  static const struct genl_ops vdpa_nl_ops[] = {
> --
> 2.35.1
>

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
  2022-05-11  9:34   ` Jason Wang
@ 2022-05-11  9:58     ` Michael S. Tsirkin
  -1 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2022-05-11  9:58 UTC (permalink / raw)
  To: Jason Wang; +Cc: Eli Cohen, virtualization, linux-kernel, Si-Wei Liu

On Wed, May 11, 2022 at 05:34:25PM +0800, Jason Wang wrote:
> On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> >
> > Following the recommendation in virio spec 1.1, a device offering
> > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> >
> > Print a warning if this recommendation is not met.
> >
> > Signed-off-by: Eli Cohen <elic@nvidia.com>
> 
> I wonder why it's a must?


It's a SHOULD in the spec.  I guess 1280 is to allow IPv6.

> > ---
> >  drivers/vdpa/vdpa.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > index 91f4c13c7c7c..961168fe9094 100644
> > --- a/drivers/vdpa/vdpa.c
> > +++ b/drivers/vdpa/vdpa.c
> > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> >
> > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > +
> >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> >  {
> >         struct vdpa_dev_set_config config = {};
> > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> >                 err = PTR_ERR(mdev);
> >                 goto err;
> >         }
> > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> 
> Should be <= ?
> 
> Thanks



> > +               pr_warn("MTU is below recommended value\n");
> >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> >                 NL_SET_ERR_MSG_MOD(info->extack,
> >                                    "All provided attributes are not supported");
> > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> >  };
> >
> >  static const struct genl_ops vdpa_nl_ops[] = {
> > --
> > 2.35.1
> >


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
@ 2022-05-11  9:58     ` Michael S. Tsirkin
  0 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2022-05-11  9:58 UTC (permalink / raw)
  To: Jason Wang; +Cc: Si-Wei Liu, Eli Cohen, linux-kernel, virtualization

On Wed, May 11, 2022 at 05:34:25PM +0800, Jason Wang wrote:
> On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> >
> > Following the recommendation in virio spec 1.1, a device offering
> > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> >
> > Print a warning if this recommendation is not met.
> >
> > Signed-off-by: Eli Cohen <elic@nvidia.com>
> 
> I wonder why it's a must?


It's a SHOULD in the spec.  I guess 1280 is to allow IPv6.

> > ---
> >  drivers/vdpa/vdpa.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > index 91f4c13c7c7c..961168fe9094 100644
> > --- a/drivers/vdpa/vdpa.c
> > +++ b/drivers/vdpa/vdpa.c
> > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> >
> > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > +
> >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> >  {
> >         struct vdpa_dev_set_config config = {};
> > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> >                 err = PTR_ERR(mdev);
> >                 goto err;
> >         }
> > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> 
> Should be <= ?
> 
> Thanks



> > +               pr_warn("MTU is below recommended value\n");
> >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> >                 NL_SET_ERR_MSG_MOD(info->extack,
> >                                    "All provided attributes are not supported");
> > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> >  };
> >
> >  static const struct genl_ops vdpa_nl_ops[] = {
> > --
> > 2.35.1
> >

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH] vdpa: Warn if MTU configured is too low
  2022-05-11  9:34   ` Jason Wang
  (?)
  (?)
@ 2022-05-11 10:02   ` Eli Cohen
  2022-05-11 10:18       ` Jason Wang
  -1 siblings, 1 reply; 11+ messages in thread
From: Eli Cohen @ 2022-05-11 10:02 UTC (permalink / raw)
  To: Jason Wang; +Cc: mst, virtualization, linux-kernel, Si-Wei Liu

> From: Jason Wang <jasowang@redhat.com>
> Sent: Wednesday, May 11, 2022 12:34 PM
> To: Eli Cohen <elic@nvidia.com>
> Cc: mst <mst@redhat.com>; virtualization <virtualization@lists.linux-foundation.org>; linux-kernel <linux-kernel@vger.kernel.org>; Si-
> Wei Liu <si-wei.liu@oracle.com>
> Subject: Re: [PATCH] vdpa: Warn if MTU configured is too low
> 
> On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> >
> > Following the recommendation in virio spec 1.1, a device offering
> > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> >
> > Print a warning if this recommendation is not met.
> >
> > Signed-off-by: Eli Cohen <elic@nvidia.com>
> 
> I wonder why it's a must?

It's definitely not a must but I thought if the spec says "should" it deserves a warning
but we can drop this if you think the warning is not in place.

> 
> > ---
> >  drivers/vdpa/vdpa.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > index 91f4c13c7c7c..961168fe9094 100644
> > --- a/drivers/vdpa/vdpa.c
> > +++ b/drivers/vdpa/vdpa.c
> > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> >
> > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > +
> >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> >  {
> >         struct vdpa_dev_set_config config = {};
> > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> >                 err = PTR_ERR(mdev);
> >                 goto err;
> >         }
> > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> 
> Should be <= ?

I don't think so. If it equals 1280 you don't want to warn.

> 
> Thanks
> 
> > +               pr_warn("MTU is below recommended value\n");
> >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> >                 NL_SET_ERR_MSG_MOD(info->extack,
> >                                    "All provided attributes are not supported");
> > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> >  };
> >
> >  static const struct genl_ops vdpa_nl_ops[] = {
> > --
> > 2.35.1
> >


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
  2022-05-11  9:58     ` Michael S. Tsirkin
@ 2022-05-11 10:17       ` Jason Wang
  -1 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2022-05-11 10:17 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Eli Cohen, virtualization, linux-kernel, Si-Wei Liu

On Wed, May 11, 2022 at 5:59 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Wed, May 11, 2022 at 05:34:25PM +0800, Jason Wang wrote:
> > On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> > >
> > > Following the recommendation in virio spec 1.1, a device offering
> > > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> > >
> > > Print a warning if this recommendation is not met.
> > >
> > > Signed-off-by: Eli Cohen <elic@nvidia.com>
> >
> > I wonder why it's a must?
>
>
> It's a SHOULD in the spec.  I guess 1280 is to allow IPv6.

Right, I see this.

Thanks

>
> > > ---
> > >  drivers/vdpa/vdpa.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > index 91f4c13c7c7c..961168fe9094 100644
> > > --- a/drivers/vdpa/vdpa.c
> > > +++ b/drivers/vdpa/vdpa.c
> > > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> > >
> > > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > > +
> > >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> > >  {
> > >         struct vdpa_dev_set_config config = {};
> > > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> > >                 err = PTR_ERR(mdev);
> > >                 goto err;
> > >         }
> > > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> >
> > Should be <= ?
> >
> > Thanks
>
>
>
> > > +               pr_warn("MTU is below recommended value\n");
> > >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> > >                 NL_SET_ERR_MSG_MOD(info->extack,
> > >                                    "All provided attributes are not supported");
> > > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> > >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> > >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> > >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> > >  };
> > >
> > >  static const struct genl_ops vdpa_nl_ops[] = {
> > > --
> > > 2.35.1
> > >
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
@ 2022-05-11 10:17       ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2022-05-11 10:17 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Si-Wei Liu, Eli Cohen, linux-kernel, virtualization

On Wed, May 11, 2022 at 5:59 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Wed, May 11, 2022 at 05:34:25PM +0800, Jason Wang wrote:
> > On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> > >
> > > Following the recommendation in virio spec 1.1, a device offering
> > > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> > >
> > > Print a warning if this recommendation is not met.
> > >
> > > Signed-off-by: Eli Cohen <elic@nvidia.com>
> >
> > I wonder why it's a must?
>
>
> It's a SHOULD in the spec.  I guess 1280 is to allow IPv6.

Right, I see this.

Thanks

>
> > > ---
> > >  drivers/vdpa/vdpa.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > index 91f4c13c7c7c..961168fe9094 100644
> > > --- a/drivers/vdpa/vdpa.c
> > > +++ b/drivers/vdpa/vdpa.c
> > > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> > >
> > > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > > +
> > >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> > >  {
> > >         struct vdpa_dev_set_config config = {};
> > > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> > >                 err = PTR_ERR(mdev);
> > >                 goto err;
> > >         }
> > > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> >
> > Should be <= ?
> >
> > Thanks
>
>
>
> > > +               pr_warn("MTU is below recommended value\n");
> > >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> > >                 NL_SET_ERR_MSG_MOD(info->extack,
> > >                                    "All provided attributes are not supported");
> > > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> > >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> > >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> > >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> > >  };
> > >
> > >  static const struct genl_ops vdpa_nl_ops[] = {
> > > --
> > > 2.35.1
> > >
>

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
  2022-05-11 10:02   ` Eli Cohen
@ 2022-05-11 10:18       ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2022-05-11 10:18 UTC (permalink / raw)
  To: Eli Cohen; +Cc: mst, virtualization, linux-kernel, Si-Wei Liu

On Wed, May 11, 2022 at 6:02 PM Eli Cohen <elic@nvidia.com> wrote:
>
> > From: Jason Wang <jasowang@redhat.com>
> > Sent: Wednesday, May 11, 2022 12:34 PM
> > To: Eli Cohen <elic@nvidia.com>
> > Cc: mst <mst@redhat.com>; virtualization <virtualization@lists.linux-foundation.org>; linux-kernel <linux-kernel@vger.kernel.org>; Si-
> > Wei Liu <si-wei.liu@oracle.com>
> > Subject: Re: [PATCH] vdpa: Warn if MTU configured is too low
> >
> > On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> > >
> > > Following the recommendation in virio spec 1.1, a device offering
> > > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> > >
> > > Print a warning if this recommendation is not met.
> > >
> > > Signed-off-by: Eli Cohen <elic@nvidia.com>
> >
> > I wonder why it's a must?
>
> It's definitely not a must but I thought if the spec says "should" it deserves a warning

Right.

> but we can drop this if you think the warning is not in place.

I remember netlink has an extra log buffer, I wonder if it's better to
warn there?

>
> >
> > > ---
> > >  drivers/vdpa/vdpa.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > index 91f4c13c7c7c..961168fe9094 100644
> > > --- a/drivers/vdpa/vdpa.c
> > > +++ b/drivers/vdpa/vdpa.c
> > > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> > >
> > > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > > +
> > >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> > >  {
> > >         struct vdpa_dev_set_config config = {};
> > > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> > >                 err = PTR_ERR(mdev);
> > >                 goto err;
> > >         }
> > > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> >
> > Should be <= ?
>
> I don't think so. If it equals 1280 you don't want to warn.

Yes, you're right.

Thanks

>
> >
> > Thanks
> >
> > > +               pr_warn("MTU is below recommended value\n");
> > >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> > >                 NL_SET_ERR_MSG_MOD(info->extack,
> > >                                    "All provided attributes are not supported");
> > > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> > >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> > >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> > >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> > >  };
> > >
> > >  static const struct genl_ops vdpa_nl_ops[] = {
> > > --
> > > 2.35.1
> > >
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] vdpa: Warn if MTU configured is too low
@ 2022-05-11 10:18       ` Jason Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2022-05-11 10:18 UTC (permalink / raw)
  To: Eli Cohen; +Cc: Si-Wei Liu, virtualization, linux-kernel, mst

On Wed, May 11, 2022 at 6:02 PM Eli Cohen <elic@nvidia.com> wrote:
>
> > From: Jason Wang <jasowang@redhat.com>
> > Sent: Wednesday, May 11, 2022 12:34 PM
> > To: Eli Cohen <elic@nvidia.com>
> > Cc: mst <mst@redhat.com>; virtualization <virtualization@lists.linux-foundation.org>; linux-kernel <linux-kernel@vger.kernel.org>; Si-
> > Wei Liu <si-wei.liu@oracle.com>
> > Subject: Re: [PATCH] vdpa: Warn if MTU configured is too low
> >
> > On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> > >
> > > Following the recommendation in virio spec 1.1, a device offering
> > > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> > >
> > > Print a warning if this recommendation is not met.
> > >
> > > Signed-off-by: Eli Cohen <elic@nvidia.com>
> >
> > I wonder why it's a must?
>
> It's definitely not a must but I thought if the spec says "should" it deserves a warning

Right.

> but we can drop this if you think the warning is not in place.

I remember netlink has an extra log buffer, I wonder if it's better to
warn there?

>
> >
> > > ---
> > >  drivers/vdpa/vdpa.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > index 91f4c13c7c7c..961168fe9094 100644
> > > --- a/drivers/vdpa/vdpa.c
> > > +++ b/drivers/vdpa/vdpa.c
> > > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> > >
> > > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > > +
> > >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> > >  {
> > >         struct vdpa_dev_set_config config = {};
> > > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> > >                 err = PTR_ERR(mdev);
> > >                 goto err;
> > >         }
> > > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> >
> > Should be <= ?
>
> I don't think so. If it equals 1280 you don't want to warn.

Yes, you're right.

Thanks

>
> >
> > Thanks
> >
> > > +               pr_warn("MTU is below recommended value\n");
> > >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> > >                 NL_SET_ERR_MSG_MOD(info->extack,
> > >                                    "All provided attributes are not supported");
> > > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> > >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> > >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> > >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> > >  };
> > >
> > >  static const struct genl_ops vdpa_nl_ops[] = {
> > > --
> > > 2.35.1
> > >
>

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH] vdpa: Warn if MTU configured is too low
  2022-05-11 10:18       ` Jason Wang
  (?)
@ 2022-05-11 10:53       ` Eli Cohen
  -1 siblings, 0 replies; 11+ messages in thread
From: Eli Cohen @ 2022-05-11 10:53 UTC (permalink / raw)
  To: Jason Wang; +Cc: mst, virtualization, linux-kernel, Si-Wei Liu

> -----Original Message-----
> From: Jason Wang <jasowang@redhat.com>
> Sent: Wednesday, May 11, 2022 1:19 PM
> To: Eli Cohen <elic@nvidia.com>
> Cc: mst <mst@redhat.com>; virtualization <virtualization@lists.linux-foundation.org>; linux-kernel <linux-kernel@vger.kernel.org>; Si-
> Wei Liu <si-wei.liu@oracle.com>
> Subject: Re: [PATCH] vdpa: Warn if MTU configured is too low
> 
> On Wed, May 11, 2022 at 6:02 PM Eli Cohen <elic@nvidia.com> wrote:
> >
> > > From: Jason Wang <jasowang@redhat.com>
> > > Sent: Wednesday, May 11, 2022 12:34 PM
> > > To: Eli Cohen <elic@nvidia.com>
> > > Cc: mst <mst@redhat.com>; virtualization <virtualization@lists.linux-foundation.org>; linux-kernel <linux-kernel@vger.kernel.org>; Si-
> > > Wei Liu <si-wei.liu@oracle.com>
> > > Subject: Re: [PATCH] vdpa: Warn if MTU configured is too low
> > >
> > > On Wed, May 11, 2022 at 4:48 PM Eli Cohen <elic@nvidia.com> wrote:
> > > >
> > > > Following the recommendation in virio spec 1.1, a device offering
> > > > VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> > > >
> > > > Print a warning if this recommendation is not met.
> > > >
> > > > Signed-off-by: Eli Cohen <elic@nvidia.com>
> > >
> > > I wonder why it's a must?
> >
> > It's definitely not a must but I thought if the spec says "should" it deserves a warning
> 
> Right.
> 
> > but we can drop this if you think the warning is not in place.
> 
> I remember netlink has an extra log buffer, I wonder if it's better to
> warn there?
> 

You mean use NL_SET_ERR_MSG_MOD(info->extack, "MTU is below recommended value\n") ?
dmesg stays clean but the user gets a warning

> >
> > >
> > > > ---
> > > >  drivers/vdpa/vdpa.c | 9 ++++++++-
> > > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > > index 91f4c13c7c7c..961168fe9094 100644
> > > > --- a/drivers/vdpa/vdpa.c
> > > > +++ b/drivers/vdpa/vdpa.c
> > > > @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
> > > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
> > > >                                  BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
> > > >
> > > > +/* Recommended virtio spec 1.1 section 5.1.4.1 */
> > > > +#define VIRTIO_MIN_PREFERRED_MTU 1280
> > > > +
> > > >  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
> > > >  {
> > > >         struct vdpa_dev_set_config config = {};
> > > > @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
> > > >                 err = PTR_ERR(mdev);
> > > >                 goto err;
> > > >         }
> > > > +       if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> > > > +           (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> > > > +           config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> > >
> > > Should be <= ?
> >
> > I don't think so. If it equals 1280 you don't want to warn.
> 
> Yes, you're right.
> 
> Thanks
> 
> >
> > >
> > > Thanks
> > >
> > > > +               pr_warn("MTU is below recommended value\n");
> > > >         if ((config.mask & mdev->config_attr_mask) != config.mask) {
> > > >                 NL_SET_ERR_MSG_MOD(info->extack,
> > > >                                    "All provided attributes are not supported");
> > > > @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
> > > >         [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
> > > >         [VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
> > > >         /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> > > > -       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> > > > +       [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
> > > >  };
> > > >
> > > >  static const struct genl_ops vdpa_nl_ops[] = {
> > > > --
> > > > 2.35.1
> > > >
> >


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-05-11 10:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  8:48 [PATCH] vdpa: Warn if MTU configured is too low Eli Cohen
2022-05-11  9:34 ` Jason Wang
2022-05-11  9:34   ` Jason Wang
2022-05-11  9:58   ` Michael S. Tsirkin
2022-05-11  9:58     ` Michael S. Tsirkin
2022-05-11 10:17     ` Jason Wang
2022-05-11 10:17       ` Jason Wang
2022-05-11 10:02   ` Eli Cohen
2022-05-11 10:18     ` Jason Wang
2022-05-11 10:18       ` Jason Wang
2022-05-11 10:53       ` Eli Cohen

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.