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: Niklas Söderlund <niklas.soderlund@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Niklas Söderlund 2022-03-04 11:22:12 +01:00 коммит произвёл David S. Miller
Родитель 58eb436353
Коммит 543bd14fc8
2 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -109,6 +109,7 @@ struct nfp_eth_table_port;
struct nfp_net;
struct nfp_net_r_vector;
struct nfp_port;
struct xsk_buff_pool;
/* Convenience macro for wrapping descriptor index on ring size */
#define D_IDX(ring, idx) ((idx) & ((ring)->cnt - 1))
@ -501,6 +502,7 @@ struct nfp_stat_pair {
* @num_stack_tx_rings: Number of TX rings used by the stack (not XDP)
* @num_rx_rings: Currently configured number of RX rings
* @mtu: Device MTU
* @xsk_pools: AF_XDP UMEM table (@num_r_vecs in size)
*/
struct nfp_net_dp {
struct device *dev;
@ -537,6 +539,8 @@ struct nfp_net_dp {
unsigned int num_rx_rings;
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)
*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 */
new->fl_bufsz = 0;
new->tx_rings = NULL;
@ -3312,6 +3321,12 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn)
return new;
}
static void nfp_net_free_dp(struct nfp_net_dp *dp)
{
kfree(dp->xsk_pools);
kfree(dp);
}
static int
nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp,
struct netlink_ext_ack *extack)
@ -3395,7 +3410,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp,
nfp_net_open_stack(nn);
exit_free_dp:
kfree(dp);
nfp_net_free_dp(dp);
return err;
@ -3404,7 +3419,7 @@ err_free_rx:
err_cleanup_vecs:
for (r = dp->num_r_vecs - 1; r >= nn->dp.num_r_vecs; r--)
nfp_net_cleanup_vector(nn, &nn->r_vecs[r]);
kfree(dp);
nfp_net_free_dp(dp);
return err;
}