Commit 543bd14f authored by Niklas Söderlund's avatar Niklas Söderlund Committed by David S. Miller

nfp: xsk: add an array of xsk buffer pools to each data path

Each data path needs an array of xsk pools to track if an xsk socket is
in use. Add this array and make sure it's handled correctly when the
data path is duplicated.
Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 58eb4363
...@@ -109,6 +109,7 @@ struct nfp_eth_table_port; ...@@ -109,6 +109,7 @@ struct nfp_eth_table_port;
struct nfp_net; struct nfp_net;
struct nfp_net_r_vector; struct nfp_net_r_vector;
struct nfp_port; struct nfp_port;
struct xsk_buff_pool;
/* Convenience macro for wrapping descriptor index on ring size */ /* Convenience macro for wrapping descriptor index on ring size */
#define D_IDX(ring, idx) ((idx) & ((ring)->cnt - 1)) #define D_IDX(ring, idx) ((idx) & ((ring)->cnt - 1))
...@@ -501,6 +502,7 @@ struct nfp_stat_pair { ...@@ -501,6 +502,7 @@ struct nfp_stat_pair {
* @num_stack_tx_rings: Number of TX rings used by the stack (not XDP) * @num_stack_tx_rings: Number of TX rings used by the stack (not XDP)
* @num_rx_rings: Currently configured number of RX rings * @num_rx_rings: Currently configured number of RX rings
* @mtu: Device MTU * @mtu: Device MTU
* @xsk_pools: AF_XDP UMEM table (@num_r_vecs in size)
*/ */
struct nfp_net_dp { struct nfp_net_dp {
struct device *dev; struct device *dev;
...@@ -537,6 +539,8 @@ struct nfp_net_dp { ...@@ -537,6 +539,8 @@ struct nfp_net_dp {
unsigned int num_rx_rings; unsigned int num_rx_rings;
unsigned int mtu; unsigned int mtu;
struct xsk_buff_pool **xsk_pools;
}; };
/** /**
......
...@@ -3302,6 +3302,15 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn) ...@@ -3302,6 +3302,15 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn)
*new = nn->dp; *new = nn->dp;
new->xsk_pools = kmemdup(new->xsk_pools,
array_size(nn->max_r_vecs,
sizeof(new->xsk_pools)),
GFP_KERNEL);
if (!new->xsk_pools) {
kfree(new);
return NULL;
}
/* Clear things which need to be recomputed */ /* Clear things which need to be recomputed */
new->fl_bufsz = 0; new->fl_bufsz = 0;
new->tx_rings = NULL; new->tx_rings = NULL;
...@@ -3312,6 +3321,12 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn) ...@@ -3312,6 +3321,12 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn)
return new; return new;
} }
static void nfp_net_free_dp(struct nfp_net_dp *dp)
{
kfree(dp->xsk_pools);
kfree(dp);
}
static int static int
nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp, nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
...@@ -3395,7 +3410,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp, ...@@ -3395,7 +3410,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp,
nfp_net_open_stack(nn); nfp_net_open_stack(nn);
exit_free_dp: exit_free_dp:
kfree(dp); nfp_net_free_dp(dp);
return err; return err;
...@@ -3404,7 +3419,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp, ...@@ -3404,7 +3419,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp,
err_cleanup_vecs: err_cleanup_vecs:
for (r = dp->num_r_vecs - 1; r >= nn->dp.num_r_vecs; r--) for (r = dp->num_r_vecs - 1; r >= nn->dp.num_r_vecs; r--)
nfp_net_cleanup_vector(nn, &nn->r_vecs[r]); nfp_net_cleanup_vector(nn, &nn->r_vecs[r]);
kfree(dp); nfp_net_free_dp(dp);
return err; return err;
} }
......
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