Skip to content

Commit bd32aa1

Browse files
LorenzoBianconidavem330
authored andcommitted
veth: rely on veth_rq in veth_xdp_flush_bq signature
Substitute net_device point with veth_rq one in veth_xdp_flush_bq, veth_xdp_flush and veth_xdp_tx signature. This is a preliminary patch to account xdp_xmit counter on 'receiving' veth_rq Acked-by: Toshiaki Makita <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent afaa4d0 commit bd32aa1

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/net/veth.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -468,46 +468,46 @@ static int veth_ndo_xdp_xmit(struct net_device *dev, int n,
468468
return veth_xdp_xmit(dev, n, frames, flags, true);
469469
}
470470

471-
static void veth_xdp_flush_bq(struct net_device *dev, struct veth_xdp_tx_bq *bq)
471+
static void veth_xdp_flush_bq(struct veth_rq *rq, struct veth_xdp_tx_bq *bq)
472472
{
473473
int sent, i, err = 0;
474474

475-
sent = veth_xdp_xmit(dev, bq->count, bq->q, 0, false);
475+
sent = veth_xdp_xmit(rq->dev, bq->count, bq->q, 0, false);
476476
if (sent < 0) {
477477
err = sent;
478478
sent = 0;
479479
for (i = 0; i < bq->count; i++)
480480
xdp_return_frame(bq->q[i]);
481481
}
482-
trace_xdp_bulk_tx(dev, sent, bq->count - sent, err);
482+
trace_xdp_bulk_tx(rq->dev, sent, bq->count - sent, err);
483483

484484
bq->count = 0;
485485
}
486486

487-
static void veth_xdp_flush(struct net_device *dev, struct veth_xdp_tx_bq *bq)
487+
static void veth_xdp_flush(struct veth_rq *rq, struct veth_xdp_tx_bq *bq)
488488
{
489-
struct veth_priv *rcv_priv, *priv = netdev_priv(dev);
489+
struct veth_priv *rcv_priv, *priv = netdev_priv(rq->dev);
490490
struct net_device *rcv;
491-
struct veth_rq *rq;
491+
struct veth_rq *rcv_rq;
492492

493493
rcu_read_lock();
494-
veth_xdp_flush_bq(dev, bq);
494+
veth_xdp_flush_bq(rq, bq);
495495
rcv = rcu_dereference(priv->peer);
496496
if (unlikely(!rcv))
497497
goto out;
498498

499499
rcv_priv = netdev_priv(rcv);
500-
rq = &rcv_priv->rq[veth_select_rxq(rcv)];
500+
rcv_rq = &rcv_priv->rq[veth_select_rxq(rcv)];
501501
/* xdp_ring is initialized on receive side? */
502-
if (unlikely(!rcu_access_pointer(rq->xdp_prog)))
502+
if (unlikely(!rcu_access_pointer(rcv_rq->xdp_prog)))
503503
goto out;
504504

505-
__veth_xdp_flush(rq);
505+
__veth_xdp_flush(rcv_rq);
506506
out:
507507
rcu_read_unlock();
508508
}
509509

510-
static int veth_xdp_tx(struct net_device *dev, struct xdp_buff *xdp,
510+
static int veth_xdp_tx(struct veth_rq *rq, struct xdp_buff *xdp,
511511
struct veth_xdp_tx_bq *bq)
512512
{
513513
struct xdp_frame *frame = convert_to_xdp_frame(xdp);
@@ -516,7 +516,7 @@ static int veth_xdp_tx(struct net_device *dev, struct xdp_buff *xdp,
516516
return -EOVERFLOW;
517517

518518
if (unlikely(bq->count == VETH_XDP_TX_BULK_SIZE))
519-
veth_xdp_flush_bq(dev, bq);
519+
veth_xdp_flush_bq(rq, bq);
520520

521521
bq->q[bq->count++] = frame;
522522

@@ -559,7 +559,7 @@ static struct sk_buff *veth_xdp_rcv_one(struct veth_rq *rq,
559559
orig_frame = *frame;
560560
xdp.data_hard_start = head;
561561
xdp.rxq->mem = frame->mem;
562-
if (unlikely(veth_xdp_tx(rq->dev, &xdp, bq) < 0)) {
562+
if (unlikely(veth_xdp_tx(rq, &xdp, bq) < 0)) {
563563
trace_xdp_exception(rq->dev, xdp_prog, act);
564564
frame = &orig_frame;
565565
stats->rx_drops++;
@@ -692,7 +692,7 @@ static struct sk_buff *veth_xdp_rcv_skb(struct veth_rq *rq,
692692
get_page(virt_to_page(xdp.data));
693693
consume_skb(skb);
694694
xdp.rxq->mem = rq->xdp_mem;
695-
if (unlikely(veth_xdp_tx(rq->dev, &xdp, bq) < 0)) {
695+
if (unlikely(veth_xdp_tx(rq, &xdp, bq) < 0)) {
696696
trace_xdp_exception(rq->dev, xdp_prog, act);
697697
stats->rx_drops++;
698698
goto err_xdp;
@@ -817,7 +817,7 @@ static int veth_poll(struct napi_struct *napi, int budget)
817817
}
818818

819819
if (stats.xdp_tx > 0)
820-
veth_xdp_flush(rq->dev, &bq);
820+
veth_xdp_flush(rq, &bq);
821821
if (stats.xdp_redirect > 0)
822822
xdp_do_flush();
823823
xdp_clear_return_frame_no_direct();

0 commit comments

Comments
 (0)