Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c496291c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller
Browse files

nfp: separate app vNIC init/clean from alloc/free



We currently only have one app callback for vNIC creation
and destruction.  This is insufficient, because some actions
have to be taken before netdev is registered, after it's
registered and after it's unregistered.  Old callbacks
were really corresponding to alloc/free actions.  Rename
them and add proper init/clean.  Apps using representors
will be able to use new callbacks to manage lifetime of
upper devices.

Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 18a4ded9
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ static const char *nfp_bpf_extra_cap(struct nfp_app *app, struct nfp_net *nn)
}

static int
nfp_bpf_vnic_init(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
nfp_bpf_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
{
	struct nfp_net_bpf_priv *priv;
	int ret;
@@ -106,14 +106,14 @@ nfp_bpf_vnic_init(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
	setup_timer(&priv->rx_filter_stats_timer,
		    nfp_net_filter_stats_timer, (unsigned long)nn);

	ret = nfp_app_nic_vnic_init(app, nn, id);
	ret = nfp_app_nic_vnic_alloc(app, nn, id);
	if (ret)
		kfree(priv);

	return ret;
}

static void nfp_bpf_vnic_clean(struct nfp_app *app, struct nfp_net *nn)
static void nfp_bpf_vnic_free(struct nfp_app *app, struct nfp_net *nn)
{
	if (nn->dp.bpf_offload_xdp)
		nfp_bpf_xdp_offload(app, nn, NULL);
@@ -149,8 +149,8 @@ const struct nfp_app_type app_bpf = {

	.extra_cap	= nfp_bpf_extra_cap,

	.vnic_init	= nfp_bpf_vnic_init,
	.vnic_clean	= nfp_bpf_vnic_clean,
	.vnic_alloc	= nfp_bpf_vnic_alloc,
	.vnic_free	= nfp_bpf_vnic_free,

	.setup_tc	= nfp_bpf_setup_tc,
	.tc_busy	= nfp_bpf_tc_busy,
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ void nfp_flower_cmsg_process_rx(struct work_struct *work)
	priv = container_of(work, struct nfp_flower_priv, cmsg_work);

	while ((skb = skb_dequeue(&priv->cmsg_skbs)))
		nfp_flower_cmsg_process_one_rx(priv->nn->app, skb);
		nfp_flower_cmsg_process_one_rx(priv->app, skb);
}

void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb)
+21 −6
Original line number Diff line number Diff line
@@ -313,18 +313,14 @@ static int nfp_flower_start(struct nfp_app *app)
					   NFP_REPR_TYPE_PF, 1);
}

static int nfp_flower_vnic_init(struct nfp_app *app, struct nfp_net *nn,
static int nfp_flower_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
				 unsigned int id)
{
	struct nfp_flower_priv *priv = app->priv;

	if (id > 0) {
		nfp_warn(app->cpp, "FlowerNIC doesn't support more than one data vNIC\n");
		goto err_invalid_port;
	}

	priv->nn = nn;

	eth_hw_addr_random(nn->dp.netdev);
	netif_keep_dst(nn->dp.netdev);

@@ -335,6 +331,22 @@ static int nfp_flower_vnic_init(struct nfp_app *app, struct nfp_net *nn,
	return PTR_ERR_OR_ZERO(nn->port);
}

static void nfp_flower_vnic_clean(struct nfp_app *app, struct nfp_net *nn)
{
	struct nfp_flower_priv *priv = app->priv;

	priv->nn = NULL;
}

static int nfp_flower_vnic_init(struct nfp_app *app, struct nfp_net *nn)
{
	struct nfp_flower_priv *priv = app->priv;

	priv->nn = nn;

	return 0;
}

static int nfp_flower_init(struct nfp_app *app)
{
	const struct nfp_pf *pf = app->pf;
@@ -374,6 +386,7 @@ static int nfp_flower_init(struct nfp_app *app)
		return -ENOMEM;

	app->priv = app_priv;
	app_priv->app = app;
	skb_queue_head_init(&app_priv->cmsg_skbs);
	INIT_WORK(&app_priv->cmsg_work, nfp_flower_cmsg_process_rx);

@@ -410,7 +423,9 @@ const struct nfp_app_type app_flower = {
	.init		= nfp_flower_init,
	.clean		= nfp_flower_clean,

	.vnic_alloc	= nfp_flower_vnic_alloc,
	.vnic_init	= nfp_flower_vnic_init,
	.vnic_clean	= nfp_flower_vnic_clean,

	.repr_open	= nfp_flower_repr_netdev_open,
	.repr_stop	= nfp_flower_repr_netdev_stop,
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ struct nfp_fl_stats_id {

/**
 * struct nfp_flower_priv - Flower APP per-vNIC priv data
 * @app:		Back pointer to app
 * @nn:			Pointer to vNIC
 * @mask_id_seed:	Seed used for mask hash table
 * @flower_version:	HW version of flower
@@ -83,6 +84,7 @@ struct nfp_fl_stats_id {
 * @cmsg_skbs:		List of skbs for control message processing
 */
struct nfp_flower_priv {
	struct nfp_app *app;
	struct nfp_net *nn;
	u32 mask_id_seed;
	u64 flower_version;
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ struct nfp_app *nfp_app_alloc(struct nfp_pf *pf, enum nfp_app_id id)
		return ERR_PTR(-EINVAL);
	}

	if (WARN_ON(!apps[i]->name || !apps[i]->vnic_init))
	if (WARN_ON(!apps[i]->name || !apps[i]->vnic_alloc))
		return ERR_PTR(-EINVAL);

	app = kzalloc(sizeof(*app), GFP_KERNEL);
Loading