diff options
| author | Quentin Monnet <quentin.monnet@netronome.com> | 2018-11-09 08:03:25 -0500 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2018-11-10 18:39:53 -0500 |
| commit | 1385d755cfb42f596ef1cf9f5c761010ff3b34e7 (patch) | |
| tree | 685f8d826e45d2e889feed5142d5c361847e5f5d /drivers/net/netdevsim/bpf.c | |
| parent | 1da6f5733853fb230265fe1a7d1b5373f13bf5ca (diff) | |
bpf: pass a struct with offload callbacks to bpf_offload_dev_create()
For passing device functions for offloaded eBPF programs, there used to
be no place where to store the pointer without making the non-offloaded
programs pay a memory price.
As a consequence, three functions were called with ndo_bpf() through
specific commands. Now that we have struct bpf_offload_dev, and since
none of those operations rely on RTNL, we can turn these three commands
into hooks inside the struct bpf_prog_offload_ops, and pass them as part
of bpf_offload_dev_create().
This commit effectively passes a pointer to the struct to
bpf_offload_dev_create(). We temporarily have two struct
bpf_prog_offload_ops instances, one under offdev->ops and one under
offload->dev_ops. The next patches will make the transition towards the
former, so that offload->dev_ops can be removed, and callbacks relying
on ndo_bpf() added to offdev->ops as well.
While at it, rename "nfp_bpf_analyzer_ops" as "nfp_bpf_dev_ops" (and
similarly for netdevsim).
Suggested-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'drivers/net/netdevsim/bpf.c')
| -rw-r--r-- | drivers/net/netdevsim/bpf.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c index cb3518474f0e..135aee864162 100644 --- a/drivers/net/netdevsim/bpf.c +++ b/drivers/net/netdevsim/bpf.c | |||
| @@ -91,7 +91,7 @@ static int nsim_bpf_finalize(struct bpf_verifier_env *env) | |||
| 91 | return 0; | 91 | return 0; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | static const struct bpf_prog_offload_ops nsim_bpf_analyzer_ops = { | 94 | static const struct bpf_prog_offload_ops nsim_bpf_dev_ops = { |
| 95 | .insn_hook = nsim_bpf_verify_insn, | 95 | .insn_hook = nsim_bpf_verify_insn, |
| 96 | .finalize = nsim_bpf_finalize, | 96 | .finalize = nsim_bpf_finalize, |
| 97 | }; | 97 | }; |
| @@ -547,7 +547,7 @@ int nsim_bpf(struct net_device *dev, struct netdev_bpf *bpf) | |||
| 547 | if (err) | 547 | if (err) |
| 548 | return err; | 548 | return err; |
| 549 | 549 | ||
| 550 | bpf->verifier.ops = &nsim_bpf_analyzer_ops; | 550 | bpf->verifier.ops = &nsim_bpf_dev_ops; |
| 551 | return 0; | 551 | return 0; |
| 552 | case BPF_OFFLOAD_TRANSLATE: | 552 | case BPF_OFFLOAD_TRANSLATE: |
| 553 | state = bpf->offload.prog->aux->offload->dev_priv; | 553 | state = bpf->offload.prog->aux->offload->dev_priv; |
| @@ -599,7 +599,7 @@ int nsim_bpf_init(struct netdevsim *ns) | |||
| 599 | if (IS_ERR_OR_NULL(ns->sdev->ddir_bpf_bound_progs)) | 599 | if (IS_ERR_OR_NULL(ns->sdev->ddir_bpf_bound_progs)) |
| 600 | return -ENOMEM; | 600 | return -ENOMEM; |
| 601 | 601 | ||
| 602 | ns->sdev->bpf_dev = bpf_offload_dev_create(); | 602 | ns->sdev->bpf_dev = bpf_offload_dev_create(&nsim_bpf_dev_ops); |
| 603 | err = PTR_ERR_OR_ZERO(ns->sdev->bpf_dev); | 603 | err = PTR_ERR_OR_ZERO(ns->sdev->bpf_dev); |
| 604 | if (err) | 604 | if (err) |
| 605 | return err; | 605 | return err; |
