Skip to content

Commit 4da98ee

Browse files
Jakub Kicinskiborkmann
authored andcommitted
nfp: bpf: add map data structure
To be able to split code into reasonable chunks we need to add the map data structures already. Later patches will add code piece by piece. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent a388457 commit 4da98ee

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

drivers/net/ethernet/netronome/nfp/bpf/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ static int nfp_bpf_init(struct nfp_app *app)
313313
bpf->app = app;
314314
app->priv = bpf;
315315

316+
INIT_LIST_HEAD(&bpf->map_list);
317+
316318
err = nfp_bpf_parse_capabilities(app);
317319
if (err)
318320
goto err_free_bpf;
@@ -326,7 +328,10 @@ static int nfp_bpf_init(struct nfp_app *app)
326328

327329
static void nfp_bpf_clean(struct nfp_app *app)
328330
{
329-
kfree(app->priv);
331+
struct nfp_app_bpf *bpf = app->priv;
332+
333+
WARN_ON(!list_empty(&bpf->map_list));
334+
kfree(bpf);
330335
}
331336

332337
const struct nfp_app_type app_bpf = {

drivers/net/ethernet/netronome/nfp/bpf/main.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ enum pkt_vec {
9393
* struct nfp_app_bpf - bpf app priv structure
9494
* @app: backpointer to the app
9595
*
96+
* @map_list: list of offloaded maps
97+
*
9698
* @adjust_head: adjust head capability
9799
* @flags: extra flags for adjust head
98100
* @off_min: minimal packet offset within buffer required
@@ -103,6 +105,8 @@ enum pkt_vec {
103105
struct nfp_app_bpf {
104106
struct nfp_app *app;
105107

108+
struct list_head map_list;
109+
106110
struct nfp_bpf_cap_adjust_head {
107111
u32 flags;
108112
int off_min;
@@ -112,6 +116,20 @@ struct nfp_app_bpf {
112116
} adjust_head;
113117
};
114118

119+
/**
120+
* struct nfp_bpf_map - private per-map data attached to BPF maps for offload
121+
* @offmap: pointer to the offloaded BPF map
122+
* @bpf: back pointer to bpf app private structure
123+
* @tid: table id identifying map on datapath
124+
* @l: link on the nfp_app_bpf->map_list list
125+
*/
126+
struct nfp_bpf_map {
127+
struct bpf_offloaded_map *offmap;
128+
struct nfp_app_bpf *bpf;
129+
u32 tid;
130+
struct list_head l;
131+
};
132+
115133
struct nfp_prog;
116134
struct nfp_insn_meta;
117135
typedef int (*instr_cb_t)(struct nfp_prog *, struct nfp_insn_meta *);

0 commit comments

Comments
 (0)