Skip to content

Commit bba71ca

Browse files
elvinongbldavem330
authored andcommitted
net: stmmac: Refactor __stmmac_xdp_run_prog for XDP ZC
Prepare stmmac_xdp_run_prog() for AF_XDP zero-copy support which will be added by upcoming patches by splitting out the XDP verdict processing into __stmmac_xdp_run_prog() and it callable for XDP ZC path which does not need to verify bpf_prog is not NULL. The stmmac_xdp_run_prog() is used for regular XDP Rx path which requires bpf_prog to be verified. Signed-off-by: Ong Boon Leong <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent de0b90e commit bba71ca

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4408,20 +4408,13 @@ static int stmmac_xdp_xmit_back(struct stmmac_priv *priv,
44084408
return res;
44094409
}
44104410

4411-
static struct sk_buff *stmmac_xdp_run_prog(struct stmmac_priv *priv,
4412-
struct xdp_buff *xdp)
4411+
/* This function assumes rcu_read_lock() is held by the caller. */
4412+
static int __stmmac_xdp_run_prog(struct stmmac_priv *priv,
4413+
struct bpf_prog *prog,
4414+
struct xdp_buff *xdp)
44134415
{
4414-
struct bpf_prog *prog;
4415-
int res;
44164416
u32 act;
4417-
4418-
rcu_read_lock();
4419-
4420-
prog = READ_ONCE(priv->xdp_prog);
4421-
if (!prog) {
4422-
res = STMMAC_XDP_PASS;
4423-
goto unlock;
4424-
}
4417+
int res;
44254418

44264419
act = bpf_prog_run_xdp(prog, xdp);
44274420
switch (act) {
@@ -4448,6 +4441,24 @@ static struct sk_buff *stmmac_xdp_run_prog(struct stmmac_priv *priv,
44484441
break;
44494442
}
44504443

4444+
return res;
4445+
}
4446+
4447+
static struct sk_buff *stmmac_xdp_run_prog(struct stmmac_priv *priv,
4448+
struct xdp_buff *xdp)
4449+
{
4450+
struct bpf_prog *prog;
4451+
int res;
4452+
4453+
rcu_read_lock();
4454+
4455+
prog = READ_ONCE(priv->xdp_prog);
4456+
if (!prog) {
4457+
res = STMMAC_XDP_PASS;
4458+
goto unlock;
4459+
}
4460+
4461+
res = __stmmac_xdp_run_prog(priv, prog, xdp);
44514462
unlock:
44524463
rcu_read_unlock();
44534464
return ERR_PTR(-res);

0 commit comments

Comments
 (0)