From: Jason Wang <jasowang@redhat.com> 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 v1] vdpa: Warn if MTU configured is too low Date: Thu, 12 May 2022 12:16:47 +0800 [thread overview] Message-ID: <CACGkMEv2FGZ3na_HpAWorjBPN1vSp4_pmjz0s9O_hOoSihCL-w@mail.gmail.com> (raw) In-Reply-To: <20220511105642.124806-1-elic@nvidia.com> On Wed, May 11, 2022 at 6:56 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> > --- > v0 -> v1: > chage pr_warn to netlink warning to userspace > > 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..0fb4a615f267 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)) > + NL_SET_ERR_MSG_MOD(info->extack, "MTU is below recommended value\n"); Can this function be used for warning? I have a quick cscope that tells me it's probably used only for error. Will it be better if we fail only when the device supports VERSION_1? Thanks > 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 >
WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com> To: Eli Cohen <elic@nvidia.com> Cc: Si-Wei Liu <si-wei.liu@oracle.com>, virtualization <virtualization@lists.linux-foundation.org>, linux-kernel <linux-kernel@vger.kernel.org>, mst <mst@redhat.com> Subject: Re: [PATCH v1] vdpa: Warn if MTU configured is too low Date: Thu, 12 May 2022 12:16:47 +0800 [thread overview] Message-ID: <CACGkMEv2FGZ3na_HpAWorjBPN1vSp4_pmjz0s9O_hOoSihCL-w@mail.gmail.com> (raw) In-Reply-To: <20220511105642.124806-1-elic@nvidia.com> On Wed, May 11, 2022 at 6:56 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> > --- > v0 -> v1: > chage pr_warn to netlink warning to userspace > > 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..0fb4a615f267 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)) > + NL_SET_ERR_MSG_MOD(info->extack, "MTU is below recommended value\n"); Can this function be used for warning? I have a quick cscope that tells me it's probably used only for error. Will it be better if we fail only when the device supports VERSION_1? Thanks > 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
next prev parent reply other threads:[~2022-05-12 4:17 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-11 10:56 [PATCH v1] vdpa: Warn if MTU configured is too low Eli Cohen 2022-05-12 4:16 ` Jason Wang [this message] 2022-05-12 4:16 ` Jason Wang 2022-05-12 5:20 ` Eli Cohen 2022-05-12 5:57 ` Michael S. Tsirkin 2022-05-12 5:57 ` Michael S. Tsirkin 2022-05-12 6:02 ` Eli Cohen
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=CACGkMEv2FGZ3na_HpAWorjBPN1vSp4_pmjz0s9O_hOoSihCL-w@mail.gmail.com \ --to=jasowang@redhat.com \ --cc=elic@nvidia.com \ --cc=linux-kernel@vger.kernel.org \ --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: linkBe 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.