Skip to content

Commit 27e95e3

Browse files
netoptimizerAlexei Starovoitov
authored andcommitted
thunderx: setup xdp_rxq_info
This driver uses a bool scheme for "enable"/"disable" when setting up different resources. Thus, the hook points for xdp_rxq_info is done in the same function call nicvf_rcv_queue_config(). This is activated through enable/disable via nicvf_config_data_transfer(), which is tied into nicvf_stop()/nicvf_open(). Extending driver packet handler call-path nicvf_rcv_pkt_handler() with a pointer to the given struct rcv_queue, in-order to access the xdp_rxq_info data area (in nicvf_xdp_rx()). V2: Driver have no proper error path for failed XDP RX-queue info reg, as nicvf_rcv_queue_config is a void function. Cc: [email protected] Cc: Sunil Goutham <[email protected]> Cc: Robert Richter <[email protected]> Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 7f1c684 commit 27e95e3

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

drivers/net/ethernet/cavium/thunder/nicvf_main.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static void nicvf_unmap_page(struct nicvf *nic, struct page *page, u64 dma_addr)
521521

522522
static inline bool nicvf_xdp_rx(struct nicvf *nic, struct bpf_prog *prog,
523523
struct cqe_rx_t *cqe_rx, struct snd_queue *sq,
524-
struct sk_buff **skb)
524+
struct rcv_queue *rq, struct sk_buff **skb)
525525
{
526526
struct xdp_buff xdp;
527527
struct page *page;
@@ -545,6 +545,7 @@ static inline bool nicvf_xdp_rx(struct nicvf *nic, struct bpf_prog *prog,
545545
xdp.data = (void *)cpu_addr;
546546
xdp_set_data_meta_invalid(&xdp);
547547
xdp.data_end = xdp.data + len;
548+
xdp.rxq = &rq->xdp_rxq;
548549
orig_data = xdp.data;
549550

550551
rcu_read_lock();
@@ -698,7 +699,8 @@ static inline void nicvf_set_rxhash(struct net_device *netdev,
698699

699700
static void nicvf_rcv_pkt_handler(struct net_device *netdev,
700701
struct napi_struct *napi,
701-
struct cqe_rx_t *cqe_rx, struct snd_queue *sq)
702+
struct cqe_rx_t *cqe_rx,
703+
struct snd_queue *sq, struct rcv_queue *rq)
702704
{
703705
struct sk_buff *skb = NULL;
704706
struct nicvf *nic = netdev_priv(netdev);
@@ -724,7 +726,7 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev,
724726
/* For XDP, ignore pkts spanning multiple pages */
725727
if (nic->xdp_prog && (cqe_rx->rb_cnt == 1)) {
726728
/* Packet consumed by XDP */
727-
if (nicvf_xdp_rx(snic, nic->xdp_prog, cqe_rx, sq, &skb))
729+
if (nicvf_xdp_rx(snic, nic->xdp_prog, cqe_rx, sq, rq, &skb))
728730
return;
729731
} else {
730732
skb = nicvf_get_rcv_skb(snic, cqe_rx,
@@ -781,6 +783,7 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
781783
struct cqe_rx_t *cq_desc;
782784
struct netdev_queue *txq;
783785
struct snd_queue *sq = &qs->sq[cq_idx];
786+
struct rcv_queue *rq = &qs->rq[cq_idx];
784787
unsigned int tx_pkts = 0, tx_bytes = 0, txq_idx;
785788

786789
spin_lock_bh(&cq->lock);
@@ -811,7 +814,7 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
811814

812815
switch (cq_desc->cqe_type) {
813816
case CQE_TYPE_RX:
814-
nicvf_rcv_pkt_handler(netdev, napi, cq_desc, sq);
817+
nicvf_rcv_pkt_handler(netdev, napi, cq_desc, sq, rq);
815818
work_done++;
816819
break;
817820
case CQE_TYPE_SEND:

drivers/net/ethernet/cavium/thunder/nicvf_queues.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ static void nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs,
760760

761761
if (!rq->enable) {
762762
nicvf_reclaim_rcv_queue(nic, qs, qidx);
763+
xdp_rxq_info_unreg(&rq->xdp_rxq);
763764
return;
764765
}
765766

@@ -772,6 +773,9 @@ static void nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs,
772773
/* all writes of RBDR data to be loaded into L2 Cache as well*/
773774
rq->caching = 1;
774775

776+
/* Driver have no proper error path for failed XDP RX-queue info reg */
777+
WARN_ON(xdp_rxq_info_reg(&rq->xdp_rxq, nic->netdev, qidx) < 0);
778+
775779
/* Send a mailbox msg to PF to config RQ */
776780
mbx.rq.msg = NIC_MBOX_MSG_RQ_CFG;
777781
mbx.rq.qs_num = qs->vnic_id;

drivers/net/ethernet/cavium/thunder/nicvf_queues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/netdevice.h>
1313
#include <linux/iommu.h>
1414
#include <linux/bpf.h>
15+
#include <net/xdp.h>
1516
#include "q_struct.h"
1617

1718
#define MAX_QUEUE_SET 128
@@ -255,6 +256,7 @@ struct rcv_queue {
255256
u8 start_qs_rbdr_idx; /* RBDR idx in the above QS */
256257
u8 caching;
257258
struct rx_tx_queue_stats stats;
259+
struct xdp_rxq_info xdp_rxq;
258260
} ____cacheline_aligned_in_smp;
259261

260262
struct cmp_queue {

0 commit comments

Comments
 (0)