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

Commit eae249b2 authored by David S. Miller's avatar David S. Miller
Browse files


Daniel Borkmann says:

====================
pull-request: bpf-next 2018-07-20

The following pull-request contains BPF updates for your *net-next* tree.

The main changes are:

1) Add sharing of BPF objects within one ASIC: this allows for reuse of
   the same program on multiple ports of a device, and therefore gains
   better code store utilization. On top of that, this now also enables
   sharing of maps between programs attached to different ports of a
   device, from Jakub.

2) Cleanup in libbpf and bpftool's Makefile to reduce unneeded feature
   detections and unused variable exports, also from Jakub.

3) First batch of RCU annotation fixes in prog array handling, i.e.
   there are several __rcu markers which are not correct as well as
   some of the RCU handling, from Roman.

4) Two fixes in BPF sample files related to checking of the prog_cnt
   upper limit from sample loader, from Dan.

5) Minor cleanup in sockmap to remove a set but not used variable,
   from Colin.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c59e18b8 8ae71e76
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -404,6 +404,20 @@ static int nfp_bpf_parse_capabilities(struct nfp_app *app)
	return -EINVAL;
}

static int nfp_bpf_ndo_init(struct nfp_app *app, struct net_device *netdev)
{
	struct nfp_app_bpf *bpf = app->priv;

	return bpf_offload_dev_netdev_register(bpf->bpf_dev, netdev);
}

static void nfp_bpf_ndo_uninit(struct nfp_app *app, struct net_device *netdev)
{
	struct nfp_app_bpf *bpf = app->priv;

	bpf_offload_dev_netdev_unregister(bpf->bpf_dev, netdev);
}

static int nfp_bpf_init(struct nfp_app *app)
{
	struct nfp_app_bpf *bpf;
@@ -427,6 +441,11 @@ static int nfp_bpf_init(struct nfp_app *app)
	if (err)
		goto err_free_neutral_maps;

	bpf->bpf_dev = bpf_offload_dev_create();
	err = PTR_ERR_OR_ZERO(bpf->bpf_dev);
	if (err)
		goto err_free_neutral_maps;

	return 0;

err_free_neutral_maps:
@@ -445,6 +464,7 @@ static void nfp_bpf_clean(struct nfp_app *app)
{
	struct nfp_app_bpf *bpf = app->priv;

	bpf_offload_dev_destroy(bpf->bpf_dev);
	WARN_ON(!skb_queue_empty(&bpf->cmsg_replies));
	WARN_ON(!list_empty(&bpf->map_list));
	WARN_ON(bpf->maps_in_use || bpf->map_elems_in_use);
@@ -466,6 +486,9 @@ const struct nfp_app_type app_bpf = {

	.extra_cap	= nfp_bpf_extra_cap,

	.ndo_init	= nfp_bpf_ndo_init,
	.ndo_uninit	= nfp_bpf_ndo_uninit,

	.vnic_alloc	= nfp_bpf_vnic_alloc,
	.vnic_free	= nfp_bpf_vnic_free,

+4 −0
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@ enum pkt_vec {
 * struct nfp_app_bpf - bpf app priv structure
 * @app:		backpointer to the app
 *
 * @bpf_dev:		BPF offload device handle
 *
 * @tag_allocator:	bitmap of control message tags in use
 * @tag_alloc_next:	next tag bit to allocate
 * @tag_alloc_last:	next tag bit to be freed
@@ -150,6 +152,8 @@ enum pkt_vec {
struct nfp_app_bpf {
	struct nfp_app *app;

	struct bpf_offload_dev *bpf_dev;

	DECLARE_BITMAP(tag_allocator, U16_MAX + 1);
	u16 tag_alloc_next;
	u16 tag_alloc_last;
+2 −8
Original line number Diff line number Diff line
@@ -566,14 +566,8 @@ int nfp_net_bpf_offload(struct nfp_net *nn, struct bpf_prog *prog,
{
	int err;

	if (prog) {
		struct bpf_prog_offload *offload = prog->aux->offload;

		if (!offload)
			return -EINVAL;
		if (offload->netdev != nn->dp.netdev)
	if (prog && !bpf_offload_dev_match(prog, nn->dp.netdev))
		return -EINVAL;
	}

	if (prog && old_prog) {
		u8 cap;
+17 −0
Original line number Diff line number Diff line
@@ -86,6 +86,23 @@ const char *nfp_app_mip_name(struct nfp_app *app)
	return nfp_mip_name(app->pf->mip);
}

int nfp_app_ndo_init(struct net_device *netdev)
{
	struct nfp_app *app = nfp_app_from_netdev(netdev);

	if (!app || !app->type->ndo_init)
		return 0;
	return app->type->ndo_init(app, netdev);
}

void nfp_app_ndo_uninit(struct net_device *netdev)
{
	struct nfp_app *app = nfp_app_from_netdev(netdev);

	if (app && app->type->ndo_uninit)
		app->type->ndo_uninit(app, netdev);
}

u64 *nfp_app_port_get_stats(struct nfp_port *port, u64 *data)
{
	if (!port || !port->app || !port->app->type->port_get_stats)
+8 −0
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ extern const struct nfp_app_type app_abm;
 * @init:	perform basic app checks and init
 * @clean:	clean app state
 * @extra_cap:	extra capabilities string
 * @ndo_init:	vNIC and repr netdev .ndo_init
 * @ndo_uninit:	vNIC and repr netdev .ndo_unint
 * @vnic_alloc:	allocate vNICs (assign port types, etc.)
 * @vnic_free:	free up app's vNIC state
 * @vnic_init:	vNIC netdev was registered
@@ -117,6 +119,9 @@ struct nfp_app_type {

	const char *(*extra_cap)(struct nfp_app *app, struct nfp_net *nn);

	int (*ndo_init)(struct nfp_app *app, struct net_device *netdev);
	void (*ndo_uninit)(struct nfp_app *app, struct net_device *netdev);

	int (*vnic_alloc)(struct nfp_app *app, struct nfp_net *nn,
			  unsigned int id);
	void (*vnic_free)(struct nfp_app *app, struct nfp_net *nn);
@@ -200,6 +205,9 @@ static inline void nfp_app_clean(struct nfp_app *app)
		app->type->clean(app);
}

int nfp_app_ndo_init(struct net_device *netdev);
void nfp_app_ndo_uninit(struct net_device *netdev);

static inline int nfp_app_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
				     unsigned int id)
{
Loading