Commit d957c0f7 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: make use of extended ack message reporting

Try to carry error messages to the user via the netlink extended
ack message attribute.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ddf9f970
...@@ -818,7 +818,8 @@ nfp_net_irqs_assign(struct nfp_net *nn, struct msix_entry *irq_entries, ...@@ -818,7 +818,8 @@ nfp_net_irqs_assign(struct nfp_net *nn, struct msix_entry *irq_entries,
unsigned int n); unsigned int n);
struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn); struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn);
int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *new); int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *new,
struct netlink_ext_ack *extack);
bool nfp_net_link_changed_read_clear(struct nfp_net *nn); bool nfp_net_link_changed_read_clear(struct nfp_net *nn);
int nfp_net_refresh_eth_port(struct nfp_net *nn); int nfp_net_refresh_eth_port(struct nfp_net *nn);
......
...@@ -2524,24 +2524,27 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn) ...@@ -2524,24 +2524,27 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn)
return new; return new;
} }
static int nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp) static int
nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp,
struct netlink_ext_ack *extack)
{ {
/* XDP-enabled tests */ /* XDP-enabled tests */
if (!dp->xdp_prog) if (!dp->xdp_prog)
return 0; return 0;
if (dp->fl_bufsz > PAGE_SIZE) { if (dp->fl_bufsz > PAGE_SIZE) {
nn_warn(nn, "MTU too large w/ XDP enabled\n"); NL_MOD_TRY_SET_ERR_MSG(extack, "MTU too large w/ XDP enabled");
return -EINVAL; return -EINVAL;
} }
if (dp->num_tx_rings > nn->max_tx_rings) { if (dp->num_tx_rings > nn->max_tx_rings) {
nn_warn(nn, "Insufficient number of TX rings w/ XDP enabled\n"); NL_MOD_TRY_SET_ERR_MSG(extack, "Insufficient number of TX rings w/ XDP enabled");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
} }
int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp) int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp,
struct netlink_ext_ack *extack)
{ {
int r, err; int r, err;
...@@ -2553,7 +2556,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp) ...@@ -2553,7 +2556,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp)
dp->num_r_vecs = max(dp->num_rx_rings, dp->num_stack_tx_rings); dp->num_r_vecs = max(dp->num_rx_rings, dp->num_stack_tx_rings);
err = nfp_net_check_config(nn, dp); err = nfp_net_check_config(nn, dp, extack);
if (err) if (err)
goto exit_free_dp; goto exit_free_dp;
...@@ -2628,7 +2631,7 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu) ...@@ -2628,7 +2631,7 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu)
dp->mtu = new_mtu; dp->mtu = new_mtu;
return nfp_net_ring_reconfig(nn, dp); return nfp_net_ring_reconfig(nn, dp, NULL);
} }
static void nfp_net_stat64(struct net_device *netdev, static void nfp_net_stat64(struct net_device *netdev,
...@@ -2944,9 +2947,10 @@ static int nfp_net_xdp_offload(struct nfp_net *nn, struct bpf_prog *prog) ...@@ -2944,9 +2947,10 @@ static int nfp_net_xdp_offload(struct nfp_net *nn, struct bpf_prog *prog)
return ret; return ret;
} }
static int nfp_net_xdp_setup(struct nfp_net *nn, struct bpf_prog *prog) static int nfp_net_xdp_setup(struct nfp_net *nn, struct netdev_xdp *xdp)
{ {
struct bpf_prog *old_prog = nn->dp.xdp_prog; struct bpf_prog *old_prog = nn->dp.xdp_prog;
struct bpf_prog *prog = xdp->prog;
struct nfp_net_dp *dp; struct nfp_net_dp *dp;
int err; int err;
...@@ -2969,7 +2973,7 @@ static int nfp_net_xdp_setup(struct nfp_net *nn, struct bpf_prog *prog) ...@@ -2969,7 +2973,7 @@ static int nfp_net_xdp_setup(struct nfp_net *nn, struct bpf_prog *prog)
dp->rx_dma_off = prog ? XDP_PACKET_HEADROOM - nn->dp.rx_offset : 0; dp->rx_dma_off = prog ? XDP_PACKET_HEADROOM - nn->dp.rx_offset : 0;
/* We need RX reconfig to remap the buffers (BIDIR vs FROM_DEV) */ /* We need RX reconfig to remap the buffers (BIDIR vs FROM_DEV) */
err = nfp_net_ring_reconfig(nn, dp); err = nfp_net_ring_reconfig(nn, dp, xdp->extack);
if (err) if (err)
return err; return err;
...@@ -2987,7 +2991,7 @@ static int nfp_net_xdp(struct net_device *netdev, struct netdev_xdp *xdp) ...@@ -2987,7 +2991,7 @@ static int nfp_net_xdp(struct net_device *netdev, struct netdev_xdp *xdp)
switch (xdp->command) { switch (xdp->command) {
case XDP_SETUP_PROG: case XDP_SETUP_PROG:
return nfp_net_xdp_setup(nn, xdp->prog); return nfp_net_xdp_setup(nn, xdp);
case XDP_QUERY_PROG: case XDP_QUERY_PROG:
xdp->prog_attached = !!nn->dp.xdp_prog; xdp->prog_attached = !!nn->dp.xdp_prog;
return 0; return 0;
......
...@@ -309,7 +309,7 @@ static int nfp_net_set_ring_size(struct nfp_net *nn, u32 rxd_cnt, u32 txd_cnt) ...@@ -309,7 +309,7 @@ static int nfp_net_set_ring_size(struct nfp_net *nn, u32 rxd_cnt, u32 txd_cnt)
dp->rxd_cnt = rxd_cnt; dp->rxd_cnt = rxd_cnt;
dp->txd_cnt = txd_cnt; dp->txd_cnt = txd_cnt;
return nfp_net_ring_reconfig(nn, dp); return nfp_net_ring_reconfig(nn, dp, NULL);
} }
static int nfp_net_set_ringparam(struct net_device *netdev, static int nfp_net_set_ringparam(struct net_device *netdev,
...@@ -880,7 +880,7 @@ static int nfp_net_set_num_rings(struct nfp_net *nn, unsigned int total_rx, ...@@ -880,7 +880,7 @@ static int nfp_net_set_num_rings(struct nfp_net *nn, unsigned int total_rx,
if (dp->xdp_prog) if (dp->xdp_prog)
dp->num_tx_rings += total_rx; dp->num_tx_rings += total_rx;
return nfp_net_ring_reconfig(nn, dp); return nfp_net_ring_reconfig(nn, dp, NULL);
} }
static int nfp_net_set_channels(struct net_device *netdev, static int nfp_net_set_channels(struct net_device *netdev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment