Refactoring RVU NIC driver
Geetha sowjanya
maintainerv2 cover Refactoring RVU NIC driver
This is a preparation pathset for follow-up "Introducing RVU representors driver" patches. The RVU representor driver creates representor netdev of each rvu device when switch dev mode is enabled.
RVU representor and NIC have a similar set of HW resources(NIX_LF,RQ/SQ/CQ) and implements a subset of NIC functionality.
This patch set groups hw resources and queue configuration code into single API and export the existing functions so, that code can be shared between NIC and representor drivers.
v1-v2:
- Removed unwanted variable.
- Dropped unrelated changes from patch4.
Geetha sowjanya (4):
octeontx2-pf: Define common API for HW resources configuration
octeontx2-pf: Add new APIs for queue memory alloc/free.
octeontx2-pf: Reuse PF max mtu value
octeontx2-pf: Export common APIs
.../marvell/octeontx2/nic/otx2_common.c | 6 +- .../marvell/octeontx2/nic/otx2_common.h | 15 ++ .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 238 +++++++++++------- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 5 +- 4 files changed, 169 insertions(+), 95 deletions(-)
Signature · 1 line
2.25.1
Geetha sowjanya
maintainerPATCH v2 1/4 octeontx2-pf: Define common API for HW resources configuration
Define new API "otx2_init_rsrc" and move the HW blocks NIX/NPA resources configuration code under this API. So, that it can be used by the RVU representor driver that has similar resources of RVU NIC.
--- .../marvell/octeontx2/nic/otx2_common.h | 1 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 146 ++++++++++-------- 2 files changed, 84 insertions(+), 63 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +1 -0
@@ -996,6 +996,7 @@ int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id, int stack_pages, int numptrs, int buf_size, int type);int otx2_aura_init (struct otx2_nic *pfvf,int aura_id,int pool_id,int numptrs); +int otx2_init_rsrc (struct pci_dev *pdev,struct otx2_nic *pf);/* RSS configuration APIs*/ int otx2_rss_init (struct otx2_nic *pfvf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +83 -63
179 lines not on this page · raw message
Signature · 1 line
2.25.1
Paolo Abeni
maintainerRe: [net-next PATCH v2 1/4] octeontx2-pf: Define common API for HW resources configuration
Quoted 6 lines · Geetha sowjanya
Define new API "
otx2_init_rsrc" and move the HW blocks NIX/NPA resources configuration code under this API. So, that it can be used by the RVU representor driver that has similar resources of RVU NIC.Signed-off-by Geetha sowjanya <[email protected]>
For future memory: Jiri gave his ack on v1, and I don't see any changes here WRT such version: you should have included his ack in the tag area.
You should have included also in case of minor modification.
You should include a changelog in each patch incrementally describing the modification from previous revision, to help the reviews.
Thanks,
Paolo
Geethasowjanya Akula
maintainerRE: [EXTERNAL] Re: [net-next PATCH v2 1/4] octeontx2-pf: Define common API for HW resources configuration
Quoted 21 lines
-----Original Message-----
From: Paolo Abeni <[email protected]>
Sent: Tuesday, September 10, 2024 3:03 PM
To: Geethasowjanya Akula <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Hariprasad Kelam <[email protected]>
Subject: [EXTERNAL] Re: [net-next PATCH v2 1/4] octeontx2-pf: Define common API for HW resources configurationQuoted 5 lines · Geetha sowjanya
Define new API "
otx2_init_rsrc" and move the HW blocks NIX/NPA resources configuration code under this API. So, that it can be used by the RVU representor driver that has similar resources of RVU NIC.Signed-off-by Geetha sowjanya <[email protected]>
Quoted 7 lines
For future memory: Jiri gave his ack on v1, and I don't see any changes here WRT such version: you should have included his ack in the tag area.
You should have included also in case of minor modification.
You should include a changelog in each patch incrementally describing the modification from previous revision, to help the reviews.
Will add change log and review tag and submit next version.
Quoted 4 lines
Thanks,
Paolo
Geetha sowjanya
maintainerPATCH v2 2/4 octeontx2-pf: Add new APIs for queue memory alloc/free.
In reply to Geetha sowjanyaGroup the queue(RX/TX/CQ) memory allocation and free code to single APIs.
--- .../marvell/octeontx2/nic/otx2_common.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 54 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2 -0
@@ -997,6 +997,8 @@ int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,int otx2_aura_init (struct otx2_nic *pfvf,int aura_id,int pool_id,int numptrs);int otx2_init_rsrc (struct pci_dev *pdev,struct otx2_nic *pf); +void otx2_free_queue_mem (struct otx2_qset *qset); +int otx2_alloc_queue_mem (struct otx2_nic *pf);/* RSS configuration APIs*/ int otx2_rss_init (struct otx2_nic *pfvf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +38 -16
87 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [net-next PATCH v2 2/4] octeontx2-pf: Add new APIs for queue memory alloc/free.
Quoted 9 lines · Geetha sowjanya
Group the queue(RX/TX/CQ) memory allocation and free code to single APIs.
Signed-off-by Geetha sowjanya <[email protected]>--- .../marvell/octeontx2/nic/otx2_common.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 54 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-)
Paolo Abeni
maintainerRe: [net-next PATCH v2 2/4] octeontx2-pf: Add new APIs for queue memory alloc/free.
In reply to Geetha sowjanyaQuoted 29 lines · Geetha sowjanya
Group the queue(RX/TX/CQ) memory allocation and free code to single APIs.
Signed-off-by Geetha sowjanya <[email protected]>--- .../marvell/octeontx2/nic/otx2_common.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 54 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2
-0@@ -997,6 +997,8 @@ int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,int otx2_aura_init (struct otx2_nic *pfvf,int aura_id,int pool_id,int numptrs);int otx2_init_rsrc (struct pci_dev *pdev,struct otx2_nic *pf); +void otx2_free_queue_mem (struct otx2_qset *qset); +int otx2_alloc_queue_mem (struct otx2_nic *pf);/* RSS configuration APIs*/ int otx2_rss_init (struct otx2_nic *pfvf);drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0@@ -1770,15 +1770,23 @@ static void otx2_dim_work(struct work_struct *w) dim->state =DIM_START_MEASURE ; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static void otx2_dim_work(struct work_struct *w) · line 1781
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +9
-1-int otx2_open (struct net_device *netdev) +void otx2_free_queue_mem (struct otx2_qset *qset) +{ +kfree (qset->sq); + qset->sq =NULL ; +kfree (qset->cq); + qset->cq =NULL ; +kfree (qset->rq); + qset->rq =NULL ; +kfree (qset->napi);
It's strange that the napi ptr is not reset here. You should add a comment describing the reason or zero such field, too.
Thanks,
Paolo
Geethasowjanya Akula
maintainerRE: [EXTERNAL] Re: [net-next PATCH v2 2/4] octeontx2-pf: Add new APIs for queue memory alloc/free.
Quoted 46 lines
-----Original Message-----
From: Paolo Abeni <[email protected]>
Sent: Tuesday, September 10, 2024 3:11 PM
To: Geethasowjanya Akula <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Hariprasad Kelam <[email protected]>
Subject: [EXTERNAL] Re: [net-next PATCH v2 2/4] octeontx2-pf: Add new APIs for queue memory alloc/free.drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static void otx2_dim_work(struct work_struct
Quoted 28 lines · Geetha sowjanya
Group the queue(RX/TX/CQ) memory allocation and free code to single APIs.
Signed-off-by Geetha sowjanya <[email protected]>--- .../marvell/octeontx2/nic/otx2_common.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 54 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-)drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2
-0@@ -997,6 +997,8 @@ int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,int otx2_aura_init (struct otx2_nic *pfvf,int aura_id,int pool_id,int numptrs);int otx2_init_rsrc (struct pci_dev *pdev,struct otx2_nic *pf); +void otx2_free_queue_mem (struct otx2_qset *qset);int +otx2_alloc_queue_mem (struct otx2_nic *pf);/* RSS configuration APIs*/ int otx2_rss_init(struct otx2_nic *pfvf); diff --git
a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.cb/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.cindex4cfeca5ca626..6dfd6d1064ad100644drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0@@ -1770,15 +1770,23 @@ static void otx2_dim_work(struct work_struct*w)
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0
-0dim->state =DIM_START_MEASURE ; }
Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c static void otx2_dim_work(struct work_struct *w) · line 1781
Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +8
-1-int otx2_open (struct net_device *netdev) +void otx2_free_queue_mem (struct otx2_qset *qset) { +kfree (qset->sq); + qset->sq =NULL ; +kfree (qset->cq); + qset->cq =NULL ; +kfree (qset->rq); + qset->rq =NULL ; +kfree (qset->napi);It's strange that the napi ptr is not reset here. You should add a comment describing the reason or zero such field, too.
"qset->napi " ptr get initialized and free on otx2_open/otx2_stop.
This ptr is not referred if the interface is in down state. Hence, ptr reset is not needed. Will add proper comment in next version.
Quoted 4 lines
Thanks,
Paolo
Geetha sowjanya
maintainerPATCH v2 3/4 octeontx2-pf: Reuse PF max mtu value
In reply to Geetha sowjanyaReuse the maximum support HW MTU value that is fetch during probe. Instead of fetching through mbox each time mtu is changed as the value is fixed for interface.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 4 ++-- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h | 1 + drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 1 + drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 1 + 4 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2 -2
@@ -227,7 +227,7 @@ int otx2_hw_set_mtu(struct otx2_nic *pfvf, int mtu)u16 maxlen;int err; - maxlen =otx2_get_max_mtu (pfvf) +OTX2_ETH_HLEN +OTX2_HW_TIMESTAMP_LEN ; + maxlen = pfvf->hw.max_mtu +OTX2_ETH_HLEN +OTX2_HW_TIMESTAMP_LEN ;mutex_lock (&pfvf->mbox.lock); req =otx2_mbox_alloc_msg_nix_set_hw_frs (&pfvf->mbox);
@@ -236,7 +236,7 @@ int otx2_hw_set_mtu(struct otx2_nic *pfvf, int mtu)return -ENOMEM ; } - req->maxlen = pfvf->netdev->mtu +OTX2_ETH_HLEN +OTX2_HW_TIMESTAMP_LEN ; + req->maxlen = mtu +OTX2_ETH_HLEN +OTX2_HW_TIMESTAMP_LEN ;/* Use max receive length supported by hardware for loopback devices */ if (is_otx2_lbkvf (pfvf->pdev))
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +1 -0
@@ -228,6 +228,7 @@ struct otx2_hw {u16 txschq_list[NIX_TXSCH_LVL_CNT ][MAX_TXSCHQ_PER_FUNC ];u16 matchall_ipolicer;u32 dwrr_mtu; +u32 max_mtu;u8 smq_link_type;/* HW settings, coalescing etc */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1 -0
@@ -3103,6 +3103,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) netdev->min_mtu =OTX2_MIN_MTU ; netdev->max_mtu =otx2_get_max_mtu (pf); + hw->max_mtu = netdev->max_mtu;/* reset CGX/RPM MAC stats */ otx2_reset_mac_stats (pf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +1 -0
@@ -671,6 +671,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) netdev->min_mtu =OTX2_MIN_MTU ; netdev->max_mtu =otx2_get_max_mtu (vf); + hw->max_mtu = netdev->max_mtu;/* To distinguish, for LBK VFs set netdev name explicitly */ if (is_otx2_lbkvf (vf->pdev)) {
Signature · 1 line
2.25.1
Geetha sowjanya
maintainerPATCH v2 4/4 octeontx2-pf: Export common APIs
In reply to Geetha sowjanyaExport mbox, hw resources and interrupt configuration functions. So, that they can be used later by the RVU representor driver.
--- .../marvell/octeontx2/nic/otx2_common.c | 2 + .../marvell/octeontx2/nic/otx2_common.h | 11 ++++++ .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 37 +++++++++++++------ .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 4 +- 4 files changed, 40 insertions(+), 14 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2 -0
@@ -246,6 +246,7 @@ int otx2_hw_set_mtu(struct otx2_nic *pfvf, int mtu)mutex_unlock (&pfvf->mbox.lock);return err; } +EXPORT_SYMBOL (otx2_hw_set_mtu);int otx2_config_pause_frm (struct otx2_nic *pfvf) {
@@ -1782,6 +1783,7 @@ void otx2_free_cints(struct otx2_nic *pfvf, int n)free_irq (vector, &qset->napi[qidx]); } } +EXPORT_SYMBOL (otx2_free_cints);void otx2_set_cints_affinity (struct otx2_nic *pfvf) {
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +11 -0
@@ -1000,6 +1000,17 @@ int otx2_aura_init(struct otx2_nic *pfvf, int aura_id,int otx2_init_rsrc (struct pci_dev *pdev,struct otx2_nic *pf);void otx2_free_queue_mem (struct otx2_qset *qset);int otx2_alloc_queue_mem (struct otx2_nic *pf); +int otx2_init_hw_resources (struct otx2_nic *pfvf); +void otx2_free_hw_resources (struct otx2_nic *pf); +int otx2_wq_init (struct otx2_nic *pf); +int otx2_check_pf_usable (struct otx2_nic *pf); +int otx2_pfaf_mbox_init (struct otx2_nic *pf); +int otx2_register_mbox_intr (struct otx2_nic *pf,bool probe_af); +int otx2_realloc_msix_vectors (struct otx2_nic *pf); +void otx2_pfaf_mbox_destroy (struct otx2_nic *pf); +void otx2_disable_mbox_intr (struct otx2_nic *pf); +void otx2_disable_napi (struct otx2_nic *pf); +irqreturn_t otx2_cq_intr_handler (int irq,void *cq_irq);/* RSS configuration APIs*/ int otx2_rss_init (struct otx2_nic *pfvf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +25 -12
@@ -1008,7 +1008,7 @@ static irqreturn_t otx2_pfaf_mbox_intr_handler(int irq, void *pf_irq)return IRQ_HANDLED ; } -static void otx2_disable_mbox_intr (struct otx2_nic *pf) +void otx2_disable_mbox_intr (struct otx2_nic *pf) {int vector =pci_irq_vector (pf->pdev,RVU_PF_INT_VEC_AFPF_MBOX );
@@ -1016,8 +1016,9 @@ static void otx2_disable_mbox_intr(struct otx2_nic *pf)otx2_write64 (pf,RVU_PF_INT_ENA_W1C ,BIT_ULL (0 ));free_irq (vector, pf); } +EXPORT_SYMBOL (otx2_disable_mbox_intr); -static int otx2_register_mbox_intr (struct otx2_nic *pf,bool probe_af) +int otx2_register_mbox_intr (struct otx2_nic *pf,bool probe_af) {struct otx2_hw *hw = &pf->hw;struct msg_req *req;
@@ -1060,8 +1061,9 @@ static int otx2_register_mbox_intr(struct otx2_nic *pf, bool probe_af)return 0 ; } +EXPORT_SYMBOL (otx2_register_mbox_intr); -static void otx2_pfaf_mbox_destroy (struct otx2_nic *pf) +void otx2_pfaf_mbox_destroy (struct otx2_nic *pf) {struct mbox *mbox = &pf->mbox;
@@ -1076,8 +1078,9 @@ static void otx2_pfaf_mbox_destroy(struct otx2_nic *pf)otx2_mbox_destroy (&mbox->mbox);otx2_mbox_destroy (&mbox->mbox_up); } +EXPORT_SYMBOL (otx2_pfaf_mbox_destroy); -static int otx2_pfaf_mbox_init (struct otx2_nic *pf) +int otx2_pfaf_mbox_init (struct otx2_nic *pf) {struct mbox *mbox = &pf->mbox;void __iomem *hwbase;
@@ -1124,6 +1127,7 @@ static int otx2_pfaf_mbox_init(struct otx2_nic *pf)otx2_pfaf_mbox_destroy (pf);return err; } +EXPORT_SYMBOL (otx2_pfaf_mbox_init);static int otx2_cgx_config_linkevents (struct otx2_nic *pf,bool enable) {
@@ -1379,7 +1383,7 @@ static irqreturn_t otx2_q_intr_handler(int irq, void *data)return IRQ_HANDLED ; } -static irqreturn_t otx2_cq_intr_handler (int irq,void *cq_irq) +irqreturn_t otx2_cq_intr_handler (int irq,void *cq_irq) {struct otx2_cq_poll *cq_poll = (struct otx2_cq_poll *)cq_irq;struct otx2_nic *pf = (struct otx2_nic *)cq_poll->dev;
@@ -1398,20 +1402,25 @@ static irqreturn_t otx2_cq_intr_handler(int irq, void *cq_irq)return IRQ_HANDLED ; } +EXPORT_SYMBOL (otx2_cq_intr_handler); -static void otx2_disable_napi (struct otx2_nic *pf) +void otx2_disable_napi (struct otx2_nic *pf) {struct otx2_qset *qset = &pf->qset;struct otx2_cq_poll *cq_poll; +struct work_struct *work;int qidx;for (qidx =0 ; qidx < pf->hw.cint_cnt; qidx++) { cq_poll = &qset->napi[qidx]; -cancel_work_sync (&cq_poll->dim.work); + work = &cq_poll->dim.work; +if (work->func) +cancel_work_sync (work);napi_disable (&cq_poll->napi);netif_napi_del (&cq_poll->napi); } } +EXPORT_SYMBOL (otx2_disable_napi);static void otx2_free_cq_res (struct otx2_nic *pf) {
@@ -1477,7 +1486,7 @@ static int otx2_get_rbuf_size(struct otx2_nic *pf, int mtu)return ALIGN (rbuf_size,2048 ); } -static int otx2_init_hw_resources (struct otx2_nic *pf) +int otx2_init_hw_resources (struct otx2_nic *pf) {struct nix_lf_free_req *free_req;struct mbox *mbox = &pf->mbox;
@@ -1601,8 +1610,9 @@ static int otx2_init_hw_resources(struct otx2_nic *pf)mutex_unlock (&mbox->lock);return err; } +EXPORT_SYMBOL (otx2_init_hw_resources); -static void otx2_free_hw_resources (struct otx2_nic *pf) +void otx2_free_hw_resources (struct otx2_nic *pf) {struct otx2_qset *qset = &pf->qset;struct nix_lf_free_req *free_req;
@@ -1688,6 +1698,7 @@ static void otx2_free_hw_resources(struct otx2_nic *pf) }mutex_unlock (&mbox->lock); } +EXPORT_SYMBOL (otx2_free_hw_resources);static bool otx2_promisc_use_mce_list (struct otx2_nic *pfvf) {
@@ -2808,7 +2819,7 @@ static const struct net_device_ops otx2_netdev_ops = { .ndo_set_vf_trust = otx2_ndo_set_vf_trust, }; -static int otx2_wq_init (struct otx2_nic *pf) +int otx2_wq_init (struct otx2_nic *pf) { pf->otx2_wq =create_singlethread_workqueue ("otx2_wq" );if (!pf->otx2_wq)
@@ -2819,7 +2830,7 @@ static int otx2_wq_init(struct otx2_nic *pf)return 0 ; } -static int otx2_check_pf_usable (struct otx2_nic *nic) +int otx2_check_pf_usable (struct otx2_nic *nic) {u64 rev;
@@ -2836,8 +2847,9 @@ static int otx2_check_pf_usable(struct otx2_nic *nic) }return 0 ; } +EXPORT_SYMBOL (otx2_check_pf_usable); -static int otx2_realloc_msix_vectors (struct otx2_nic *pf) +int otx2_realloc_msix_vectors (struct otx2_nic *pf) {struct otx2_hw *hw = &pf->hw;int num_vec, err;
@@ -2859,6 +2871,7 @@ static int otx2_realloc_msix_vectors(struct otx2_nic *pf)return otx2_register_mbox_intr (pf, false); } +EXPORT_SYMBOL (otx2_realloc_msix_vectors);static int otx2_sriov_vfcfg_init (struct otx2_nic *pf) {
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +2 -2
@@ -500,7 +500,7 @@ static const struct net_device_ops otx2vf_netdev_ops = { .ndo_setup_tc = otx2_setup_tc, }; -static int otx2_wq_init (struct otx2_nic *vf) +static int otx2_vf_wq_init (struct otx2_nic *vf) { vf->otx2_wq =create_singlethread_workqueue ("otx2vf_wq" );if (!vf->otx2_wq)
@@ -689,7 +689,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_ptp_destroy; } - err =otx2_wq_init (vf); + err =otx2_vf_wq_init (vf);if (err) goto err_unreg_netdev;
Signature · 1 line
2.25.1