octeontx2-pf: Add XDP support to netdev PF
Geetha sowjanya
maintainerPATCH v2 1/1 octeontx2-pf: Add XDP support to netdev PF
Adds XDP_PASS, XDP_TX, XDP_DROP and XDP_REDIRECT support for netdev PF.
Signed-off-by Geetha sowjanya <[email protected]>
Signed-off-by Sunil Goutham <[email protected]>
---
v1-v2:
-Fixed compilation warnings.
.../marvell/octeontx2/nic/otx2_common.c | 35 ++-- .../marvell/octeontx2/nic/otx2_common.h | 4 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 135 +++++++++++++- .../marvell/octeontx2/nic/otx2_txrx.c | 174 ++++++++++++++++-- .../marvell/octeontx2/nic/otx2_txrx.h | 7 +- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 1 + 6 files changed, 322 insertions(+), 34 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +22 -13
@@ -718,7 +718,7 @@ void otx2_sqb_flush(struct otx2_nic *pfvf)int timeout =1000 ; ptr = (u64 *)otx2_get_regaddr (pfvf,NIX_LF_SQ_OP_STATUS ); -for (qidx =0 ; qidx < pfvf->hw.tx_queues; qidx++) { +for (qidx =0 ; qidx < pfvf->hw.tot_tx_queues; qidx++) { incr = (u64 )qidx <<32 ;while (timeout) { val =otx2_atomic64_add (incr, ptr);
@@ -835,17 +835,19 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)if (err)return err; - err =qmem_alloc (pfvf->dev, &sq->tso_hdrs, qset->sqe_cnt, -TSO_HEADER_SIZE ); -if (err) -return err; +if (qidx < pfvf->hw.tx_queues) { + err =qmem_alloc (pfvf->dev, &sq->tso_hdrs, qset->sqe_cnt, +TSO_HEADER_SIZE ); +if (err) +return err; + } sq->sqe_base = sq->sqe->base; sq->sg =kcalloc (qset->sqe_cnt,sizeof (struct sg_list ),GFP_KERNEL );if (!sq->sg)return -ENOMEM ; -if (pfvf->ptp) { +if (pfvf->ptp && qidx < pfvf->hw.tx_queues) { err =qmem_alloc (pfvf->dev, &sq->timestamps, qset->sqe_cnt,sizeof (*sq->timestamps));if (err)
@@ -871,20 +873,27 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)static int otx2_cq_init (struct otx2_nic *pfvf,u16 qidx) {struct otx2_qset *qset = &pfvf->qset; +int err, pool_id, non_xdp_queues;struct nix_aq_enq_req *aq;struct otx2_cq_queue *cq; -int err, pool_id; cq = &qset->cq[qidx]; cq->cq_idx = qidx; + non_xdp_queues = pfvf->hw.rx_queues + pfvf->hw.tx_queues;if (qidx < pfvf->hw.rx_queues) { cq->cq_type =CQ_RX ; cq->cint_idx = qidx; cq->cqe_cnt = qset->rqe_cnt; - }else { +if (pfvf->xdp_prog) +xdp_rxq_info_reg (&cq->xdp_rxq, pfvf->netdev, qidx,0 ); + }else if (qidx < non_xdp_queues) { cq->cq_type =CQ_TX ; cq->cint_idx = qidx - pfvf->hw.rx_queues; cq->cqe_cnt = qset->sqe_cnt; + }else { + cq->cq_type =CQ_XDP ; + cq->cint_idx = qidx - non_xdp_queues; + cq->cqe_cnt = qset->sqe_cnt; } cq->cqe_size = pfvf->qset.xqe_size;
@@ -991,7 +1000,7 @@ int otx2_config_nix_queues(struct otx2_nic *pfvf) }/* Initialize TX queues */ -for (qidx =0 ; qidx < pfvf->hw.tx_queues; qidx++) { +for (qidx =0 ; qidx < pfvf->hw.tot_tx_queues; qidx++) {u16 sqb_aura =otx2_get_pool_idx (pfvf,AURA_NIX_SQ , qidx); err =otx2_sq_init (pfvf, qidx, sqb_aura);
@@ -1038,7 +1047,7 @@ int otx2_config_nix(struct otx2_nic *pfvf)/* Set RQ/SQ/CQ counts */ nixlf->rq_cnt = pfvf->hw.rx_queues; - nixlf->sq_cnt = pfvf->hw.tx_queues; + nixlf->sq_cnt = pfvf->hw.tot_tx_queues; nixlf->cq_cnt = pfvf->qset.cq_cnt; nixlf->rss_sz =MAX_RSS_INDIR_TBL_SIZE ; nixlf->rss_grps =MAX_RSS_GROUPS ;
@@ -1076,7 +1085,7 @@ void otx2_sq_free_sqbs(struct otx2_nic *pfvf)int sqb, qidx;u64 iova, pa; -for (qidx =0 ; qidx < hw->tx_queues; qidx++) { +for (qidx =0 ; qidx < hw->tot_tx_queues; qidx++) { sq = &qset->sq[qidx];if (!sq->sqb_ptrs)continue ;
@@ -1288,7 +1297,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) stack_pages = (num_sqbs + hw->stack_pg_ptrs -1 ) / hw->stack_pg_ptrs; -for (qidx =0 ; qidx < hw->tx_queues; qidx++) { +for (qidx =0 ; qidx < hw->tot_tx_queues; qidx++) { pool_id =otx2_get_pool_idx (pfvf,AURA_NIX_SQ , qidx);/* Initialize aura context */ err =otx2_aura_init (pfvf, pool_id, pool_id, num_sqbs);
@@ -1308,7 +1317,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf) goto fail;/* Allocate pointers and free them to aura/pool */ -for (qidx =0 ; qidx < hw->tx_queues; qidx++) { +for (qidx =0 ; qidx < hw->tot_tx_queues; qidx++) { pool_id =otx2_get_pool_idx (pfvf,AURA_NIX_SQ , qidx); pool = &pfvf->qset.pool[pool_id];
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +4 -0
@@ -171,6 +171,8 @@ struct otx2_hw {struct otx2_rss_info rss_info;u16 rx_queues;u16 tx_queues; +u16 xdp_queues; +u16 tot_tx_queues;u16 max_queues;u16 pool_cnt;u16 rqpool_cnt;
@@ -345,6 +347,7 @@ struct otx2_nic {u64 flags;u64 *cq_op_addr; +struct bpf_prog *xdp_prog;struct otx2_qset qset;struct otx2_hw hw;struct pci_dev *pdev;
@@ -854,6 +857,7 @@ int otx2_del_macfilter(struct net_device *netdev, const u8 *mac);int otx2_add_macfilter (struct net_device *netdev,const u8 *mac);int otx2_enable_rxvlan (struct otx2_nic *pf,bool enable);int otx2_install_rxvlan_offload_flow (struct otx2_nic *pfvf); +bool otx2_xdp_sq_append_pkt (struct otx2_nic *pfvf,u64 iova,int len,u16 qidx);u16 otx2_get_max_mtu (struct otx2_nic *pfvf);/* tc support */ int otx2_init_tc (struct otx2_nic *nic);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +130 -5
209 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +159 -15
248 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +6 -1
@@ -11,6 +11,7 @@#include <linux/etherdevice.h> #include <linux/iommu.h> #include <linux/if_vlan.h> +#include <net/xdp.h> #define LBK_CHAN_BASE 0x000#define SDP_CHAN_BASE 0x700
@@ -25,6 +26,8 @@#define OTX2_MAX_GSO_SEGS 255#define OTX2_MAX_FRAGS_IN_SQE 9 +#define MAX_XDP_MTU (1530 - OTX2_ETH_HLEN) +/* Rx buffer size should be in multiples of 128bytes */ #define RCV_FRAG_LEN1 (x) \ ((OTX2_HEAD_ROOM + OTX2_DATA_ALIGN(x)) + \
@@ -99,7 +102,8 @@ struct otx2_snd_queue {enum cq_type {CQ_RX ,CQ_TX , -CQS_PER_CINT =2 ,/* RQ + SQ */ +CQ_XDP , +CQS_PER_CINT =3 ,/* RQ + SQ + XDP */ };struct otx2_cq_poll {
@@ -130,6 +134,7 @@ struct otx2_cq_queue {void *cqe_base;struct qmem *cqe;struct otx2_pool *rbpool; +struct xdp_rxq_info xdp_rxq; }____cacheline_aligned_in_smp ;struct otx2_qset {
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +1 -0
@@ -583,6 +583,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) hw->rx_queues = qcount; hw->tx_queues = qcount; hw->max_queues = qcount; + hw->tot_tx_queues = qcount; hw->irq_name =devm_kmalloc_array (&hw->pdev->dev, num_vec,NAME_SIZE ,GFP_KERNEL );
Signature · 1 line
2.17.1
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Wed, 29 Sep 2021 15:24:56 +0530 you wrote:
Adds
XDP_PASS,XDP_TX,XDP_DROPandXDP_REDIRECTsupport for netdev PF.Signed-off-by Geetha sowjanya <[email protected]>Signed-off-by Sunil Goutham <[email protected]>---
v1-v2:
-Fixed compilation warnings.[...]
Here is the summary with links:
- [net-next,v2] octeontx2-pf: Add XDP support to netdev PF
https://git.kernel.org/netdev/net-next/c/06059a1a9a4a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html