Message ID | 20190228215441.28275-4-stephen@networkplumber.org |
---|---|
State | RFC |
Delegated to: | David Miller |
Headers | show |
Series | use extack when setting up XDP | expand |
On Thu, 28 Feb 2019 13:54:38 -0800, Stephen Hemminger wrote: > @@ -12140,12 +12144,14 @@ static int i40e_xdp(struct net_device *dev, > struct i40e_netdev_priv *np = netdev_priv(dev); > struct i40e_vsi *vsi = np->vsi; > > - if (vsi->type != I40E_VSI_MAIN) > + if (vsi->type != I40E_VSI_MAIN) { > + NL_SET_ERR_MSG_MOD(xdp->extack, "XDP not allowed on VF"); Is that right? Intel tends to have separate drivers for VFs, I think the i40evf got renamed to iavf. I think it would be a good idea to CC maintainers on the driver patches. > return -EINVAL; > + } >
On Thu, 28 Feb 2019 19:06:45 -0800 Jakub Kicinski <jakub.kicinski@netronome.com> wrote: > On Thu, 28 Feb 2019 13:54:38 -0800, Stephen Hemminger wrote: > > @@ -12140,12 +12144,14 @@ static int i40e_xdp(struct net_device *dev, > > struct i40e_netdev_priv *np = netdev_priv(dev); > > struct i40e_vsi *vsi = np->vsi; > > > > - if (vsi->type != I40E_VSI_MAIN) > > + if (vsi->type != I40E_VSI_MAIN) { > > + NL_SET_ERR_MSG_MOD(xdp->extack, "XDP not allowed on VF"); > > Is that right? Intel tends to have separate drivers for VFs, I think > the i40evf got renamed to iavf. > Good catch, this sanity check is to make sure that XDP is being enabled on main VSI of PF, not for example the VSI dedicated for Flow Director management (I40E_VSI_FDIR). Besides that, vsi->type != I40E_VSI_MAIN doesn't yield the I40E_VSI_SRIOV type. So it would be better to have an error message like "XDP is not allowed on VSIs other than main VSI". Thoughts? > I think it would be a good idea to CC maintainers on the driver patches. > > > return -EINVAL; > > + } > > >
On Fri, 1 Mar 2019 12:31:08 +0100, Maciej Fijalkowski wrote: > On Thu, 28 Feb 2019 19:06:45 -0800 > Jakub Kicinski <jakub.kicinski@netronome.com> wrote: > > > On Thu, 28 Feb 2019 13:54:38 -0800, Stephen Hemminger wrote: > > > @@ -12140,12 +12144,14 @@ static int i40e_xdp(struct net_device *dev, > > > struct i40e_netdev_priv *np = netdev_priv(dev); > > > struct i40e_vsi *vsi = np->vsi; > > > > > > - if (vsi->type != I40E_VSI_MAIN) > > > + if (vsi->type != I40E_VSI_MAIN) { > > > + NL_SET_ERR_MSG_MOD(xdp->extack, "XDP not allowed on VF"); > > > > Is that right? Intel tends to have separate drivers for VFs, I think > > the i40evf got renamed to iavf. > > > Good catch, this sanity check is to make sure that XDP is being enabled on main > VSI of PF, not for example the VSI dedicated for Flow Director management > (I40E_VSI_FDIR). Besides that, vsi->type != I40E_VSI_MAIN doesn't yield the > I40E_VSI_SRIOV type. > > So it would be better to have an error message like "XDP is not allowed on VSIs > other than main VSI". > > Thoughts? Do the other VSI types have netdevs? If they do this may be hard to understand (unless Intel's manuals refer to VSI and users know what that is). If there is no netdev on other VSIs perhaps this "should never happen" and we can convert it to a WARN_ON()? > > I think it would be a good idea to CC maintainers on the driver patches. > > > > > return -EINVAL; > > > + } > > > > > >
On Fri, 1 Mar 2019 08:28:49 -0800 Jakub Kicinski <jakub.kicinski@netronome.com> wrote: > On Fri, 1 Mar 2019 12:31:08 +0100, Maciej Fijalkowski wrote: > > On Thu, 28 Feb 2019 19:06:45 -0800 > > Jakub Kicinski <jakub.kicinski@netronome.com> wrote: > > > > > On Thu, 28 Feb 2019 13:54:38 -0800, Stephen Hemminger wrote: > > > > @@ -12140,12 +12144,14 @@ static int i40e_xdp(struct net_device *dev, > > > > struct i40e_netdev_priv *np = netdev_priv(dev); > > > > struct i40e_vsi *vsi = np->vsi; > > > > > > > > - if (vsi->type != I40E_VSI_MAIN) > > > > + if (vsi->type != I40E_VSI_MAIN) { > > > > + NL_SET_ERR_MSG_MOD(xdp->extack, "XDP not allowed on VF"); > > > > > > Is that right? Intel tends to have separate drivers for VFs, I think > > > the i40evf got renamed to iavf. > > > > > Good catch, this sanity check is to make sure that XDP is being enabled on main > > VSI of PF, not for example the VSI dedicated for Flow Director management > > (I40E_VSI_FDIR). Besides that, vsi->type != I40E_VSI_MAIN doesn't yield the > > I40E_VSI_SRIOV type. > > > > So it would be better to have an error message like "XDP is not allowed on VSIs > > other than main VSI". > > > > Thoughts? > > Do the other VSI types have netdevs? If they do this may be hard to > understand (unless Intel's manuals refer to VSI and users know what > that is). > > If there is no netdev on other VSIs perhaps this "should never happen" > and we can convert it to a WARN_ON()? I was just making a best guess based on similar checks elsewhere in the code as to the correct error message
On Fri, 1 Mar 2019 13:55:53 -0800, Stephen Hemminger wrote: > On Fri, 1 Mar 2019 08:28:49 -0800 > Jakub Kicinski <jakub.kicinski@netronome.com> wrote: > > > On Fri, 1 Mar 2019 12:31:08 +0100, Maciej Fijalkowski wrote: > > > On Thu, 28 Feb 2019 19:06:45 -0800 > > > Jakub Kicinski <jakub.kicinski@netronome.com> wrote: > > > > > > > On Thu, 28 Feb 2019 13:54:38 -0800, Stephen Hemminger wrote: > > > > > @@ -12140,12 +12144,14 @@ static int i40e_xdp(struct net_device *dev, > > > > > struct i40e_netdev_priv *np = netdev_priv(dev); > > > > > struct i40e_vsi *vsi = np->vsi; > > > > > > > > > > - if (vsi->type != I40E_VSI_MAIN) > > > > > + if (vsi->type != I40E_VSI_MAIN) { > > > > > + NL_SET_ERR_MSG_MOD(xdp->extack, "XDP not allowed on VF"); > > > > > > > > Is that right? Intel tends to have separate drivers for VFs, I think > > > > the i40evf got renamed to iavf. > > > > > > > Good catch, this sanity check is to make sure that XDP is being enabled on main > > > VSI of PF, not for example the VSI dedicated for Flow Director management > > > (I40E_VSI_FDIR). Besides that, vsi->type != I40E_VSI_MAIN doesn't yield the > > > I40E_VSI_SRIOV type. > > > > > > So it would be better to have an error message like "XDP is not allowed on VSIs > > > other than main VSI". > > > > > > Thoughts? > > > > Do the other VSI types have netdevs? If they do this may be hard to > > understand (unless Intel's manuals refer to VSI and users know what > > that is). > > > > If there is no netdev on other VSIs perhaps this "should never happen" > > and we can convert it to a WARN_ON()? > > I was just making a best guess based on similar checks elsewhere in the > code as to the correct error message Digging into this I think there are more netdevs, so perhaps "XDP is only allowed on the main netdev instance"? Hopefully Intel folks can advise even better.
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index da62218eb70a..a6a5866d79a8 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -11831,7 +11831,8 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb, * @prog: XDP program **/ static int i40e_xdp_setup(struct i40e_vsi *vsi, - struct bpf_prog *prog) + struct bpf_prog *prog, + struct netlink_ext_ack *extack) { int frame_size = vsi->netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; struct i40e_pf *pf = vsi->back; @@ -11840,8 +11841,11 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi, int i; /* Don't allow frames that span over multiple buffers */ - if (frame_size > vsi->rx_buf_len) + if (frame_size > vsi->rx_buf_len) { + NL_SET_ERR_MSG_MOD(extack, + "XDP does not support multiple buffers"); return -EINVAL; + } if (!i40e_enabled_xdp_vsi(vsi) && !prog) return 0; @@ -12140,12 +12144,14 @@ static int i40e_xdp(struct net_device *dev, struct i40e_netdev_priv *np = netdev_priv(dev); struct i40e_vsi *vsi = np->vsi; - if (vsi->type != I40E_VSI_MAIN) + if (vsi->type != I40E_VSI_MAIN) { + NL_SET_ERR_MSG_MOD(xdp->extack, "XDP not allowed on VF"); return -EINVAL; + } switch (xdp->command) { case XDP_SETUP_PROG: - return i40e_xdp_setup(vsi, xdp->prog); + return i40e_xdp_setup(vsi, xdp->prog, xdp->extack); case XDP_QUERY_PROG: xdp->prog_id = vsi->xdp_prog ? vsi->xdp_prog->aux->id : 0; return 0; @@ -12153,6 +12159,7 @@ static int i40e_xdp(struct net_device *dev, return i40e_xsk_umem_setup(vsi, xdp->xsk.umem, xdp->xsk.queue_id); default: + NL_SET_ERR_MSG_MOD(xdp->extack, "Unknown XDP command"); return -EINVAL; } }
If ndo_bpf fails fill in error string with reason. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- drivers/net/ethernet/intel/i40e/i40e_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)