Skip to content

Commit cf599f5

Browse files
Jiong Wangborkmann
authored andcommitted
nfp: bpf: relax prog rejection through max_pkt_offset
NFP is refusing to offload programs whenever the MTU is set to a value larger than the max packet bytes that fits in NFP Cluster Target Memory (CTM). However, a eBPF program doesn't always need to access the whole packet data. Verifier has always calculated maximum direct packet access (DPA) offset, and kept it in max_pkt_offset inside prog auxiliar information. This patch relax prog rejection based on max_pkt_offset. Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Jiong Wang <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent e647815 commit cf599f5

File tree

1 file changed

+5
-4
lines changed
  • drivers/net/ethernet/netronome/nfp/bpf

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,15 @@ nfp_net_bpf_load(struct nfp_net *nn, struct bpf_prog *prog,
489489
struct netlink_ext_ack *extack)
490490
{
491491
struct nfp_prog *nfp_prog = prog->aux->offload->dev_priv;
492-
unsigned int max_mtu, max_stack, max_prog_len;
492+
unsigned int fw_mtu, pkt_off, max_stack, max_prog_len;
493493
dma_addr_t dma_addr;
494494
void *img;
495495
int err;
496496

497-
max_mtu = nn_readb(nn, NFP_NET_CFG_BPF_INL_MTU) * 64 - 32;
498-
if (max_mtu < nn->dp.netdev->mtu) {
499-
NL_SET_ERR_MSG_MOD(extack, "BPF offload not supported with MTU larger than HW packet split boundary");
497+
fw_mtu = nn_readb(nn, NFP_NET_CFG_BPF_INL_MTU) * 64 - 32;
498+
pkt_off = min(prog->aux->max_pkt_offset, nn->dp.netdev->mtu);
499+
if (fw_mtu < pkt_off) {
500+
NL_SET_ERR_MSG_MOD(extack, "BPF offload not supported with potential packet access beyond HW packet split boundary");
500501
return -EOPNOTSUPP;
501502
}
502503

0 commit comments

Comments
 (0)