Lines Matching refs:bpf
180 static int nsim_xdp_offload_prog(struct netdevsim *ns, struct netdev_bpf *bpf) in nsim_xdp_offload_prog() argument
182 if (!nsim_xdp_offload_active(ns) && !bpf->prog) in nsim_xdp_offload_prog()
184 if (!nsim_xdp_offload_active(ns) && bpf->prog && ns->bpf_offloaded) { in nsim_xdp_offload_prog()
185 NSIM_EA(bpf->extack, "TC program is already loaded"); in nsim_xdp_offload_prog()
189 return nsim_bpf_offload(ns, bpf->prog, nsim_xdp_offload_active(ns)); in nsim_xdp_offload_prog()
193 nsim_xdp_set_prog(struct netdevsim *ns, struct netdev_bpf *bpf, in nsim_xdp_set_prog() argument
198 if (bpf->command == XDP_SETUP_PROG && !ns->bpf_xdpdrv_accept) { in nsim_xdp_set_prog()
199 NSIM_EA(bpf->extack, "driver XDP disabled in DebugFS"); in nsim_xdp_set_prog()
202 if (bpf->command == XDP_SETUP_PROG_HW && !ns->bpf_xdpoffload_accept) { in nsim_xdp_set_prog()
203 NSIM_EA(bpf->extack, "XDP offload disabled in DebugFS"); in nsim_xdp_set_prog()
207 if (bpf->command == XDP_SETUP_PROG_HW) { in nsim_xdp_set_prog()
208 err = nsim_xdp_offload_prog(ns, bpf); in nsim_xdp_set_prog()
213 xdp_attachment_setup(xdp, bpf); in nsim_xdp_set_prog()
293 static int nsim_setup_prog_checks(struct netdevsim *ns, struct netdev_bpf *bpf) in nsim_setup_prog_checks() argument
295 if (bpf->prog && bpf->prog->aux->offload) { in nsim_setup_prog_checks()
296 NSIM_EA(bpf->extack, "attempt to load offloaded prog to drv"); in nsim_setup_prog_checks()
300 NSIM_EA(bpf->extack, "MTU too large w/ XDP enabled"); in nsim_setup_prog_checks()
307 nsim_setup_prog_hw_checks(struct netdevsim *ns, struct netdev_bpf *bpf) in nsim_setup_prog_hw_checks() argument
311 if (!bpf->prog) in nsim_setup_prog_hw_checks()
314 if (!bpf_prog_is_offloaded(bpf->prog->aux)) { in nsim_setup_prog_hw_checks()
315 NSIM_EA(bpf->extack, "xdpoffload of non-bound program"); in nsim_setup_prog_hw_checks()
319 state = bpf->prog->aux->offload->dev_priv; in nsim_setup_prog_hw_checks()
321 NSIM_EA(bpf->extack, "offloading program in bad state"); in nsim_setup_prog_hw_checks()
547 int nsim_bpf(struct net_device *dev, struct netdev_bpf *bpf) in nsim_bpf() argument
554 switch (bpf->command) { in nsim_bpf()
556 err = nsim_setup_prog_checks(ns, bpf); in nsim_bpf()
560 return nsim_xdp_set_prog(ns, bpf, &ns->xdp); in nsim_bpf()
562 err = nsim_setup_prog_hw_checks(ns, bpf); in nsim_bpf()
566 return nsim_xdp_set_prog(ns, bpf, &ns->xdp_hw); in nsim_bpf()
571 return nsim_bpf_map_alloc(ns, bpf->offmap); in nsim_bpf()
573 nsim_bpf_map_free(bpf->offmap); in nsim_bpf()