[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241220215058.11118-4-johndale@cisco.com>
Date: Fri, 20 Dec 2024 13:50:56 -0800
From: John Daley <johndale@...co.com>
To: benve@...co.com,
satishkh@...co.com,
andrew+netdev@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
netdev@...r.kernel.org
Cc: John Daley <johndale@...co.com>,
Nelson Escobar <neescoba@...co.com>
Subject: [PATCH net-next 3/5] enic: Use function pointers for buf alloc, free and RQ service
In order to support more than one packet receive processing scheme, use
pointers for allocate, free and RQ descrptor processing functions.
Co-developed-by: Nelson Escobar <neescoba@...co.com>
Signed-off-by: Nelson Escobar <neescoba@...co.com>
Co-developed-by: Satish Kharat <satishkh@...co.com>
Signed-off-by: Satish Kharat <satishkh@...co.com>
Signed-off-by: John Daley <johndale@...co.com>
---
drivers/net/ethernet/cisco/enic/enic.h | 5 +++++
drivers/net/ethernet/cisco/enic/enic_main.c | 14 +++++++++-----
drivers/net/ethernet/cisco/enic/enic_rq.c | 2 +-
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
index 10b7e02ba4d0..51f80378d928 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -226,6 +226,11 @@ struct enic {
u32 rx_copybreak;
u8 rss_key[ENIC_RSS_LEN];
struct vnic_gen_stats gen_stats;
+ void (*rq_buf_service)(struct vnic_rq *rq, struct cq_desc *cq_desc,
+ struct vnic_rq_buf *buf, int skipped,
+ void *opaque);
+ int (*rq_alloc_buf)(struct vnic_rq *rq);
+ void (*rq_free_buf)(struct vnic_rq *rq, struct vnic_rq_buf *buf);
};
static inline struct net_device *vnic_get_netdev(struct vnic_dev *vdev)
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index f8d0011486d7..45ab6b670563 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1519,7 +1519,7 @@ static int enic_poll(struct napi_struct *napi, int budget)
0 /* don't unmask intr */,
0 /* don't reset intr timer */);
- err = vnic_rq_fill(&enic->rq[0].vrq, enic_rq_alloc_buf);
+ err = vnic_rq_fill(&enic->rq[0].vrq, enic->rq_alloc_buf);
/* Buffer allocation failed. Stay in polling
* mode so we can try to fill the ring again.
@@ -1647,7 +1647,7 @@ static int enic_poll_msix_rq(struct napi_struct *napi, int budget)
0 /* don't unmask intr */,
0 /* don't reset intr timer */);
- err = vnic_rq_fill(&enic->rq[rq].vrq, enic_rq_alloc_buf);
+ err = vnic_rq_fill(&enic->rq[rq].vrq, enic->rq_alloc_buf);
/* Buffer allocation failed. Stay in polling mode
* so we can try to fill the ring again.
@@ -1882,6 +1882,10 @@ static int enic_open(struct net_device *netdev)
unsigned int i;
int err, ret;
+ enic->rq_buf_service = enic_rq_indicate_buf;
+ enic->rq_alloc_buf = enic_rq_alloc_buf;
+ enic->rq_free_buf = enic_free_rq_buf;
+
err = enic_request_intr(enic);
if (err) {
netdev_err(netdev, "Unable to request irq.\n");
@@ -1900,7 +1904,7 @@ static int enic_open(struct net_device *netdev)
for (i = 0; i < enic->rq_count; i++) {
/* enable rq before updating rq desc */
vnic_rq_enable(&enic->rq[i].vrq);
- vnic_rq_fill(&enic->rq[i].vrq, enic_rq_alloc_buf);
+ vnic_rq_fill(&enic->rq[i].vrq, enic->rq_alloc_buf);
/* Need at least one buffer on ring to get going */
if (vnic_rq_desc_used(&enic->rq[i].vrq) == 0) {
netdev_err(netdev, "Unable to alloc receive buffers\n");
@@ -1939,7 +1943,7 @@ static int enic_open(struct net_device *netdev)
for (i = 0; i < enic->rq_count; i++) {
ret = vnic_rq_disable(&enic->rq[i].vrq);
if (!ret)
- vnic_rq_clean(&enic->rq[i].vrq, enic_free_rq_buf);
+ vnic_rq_clean(&enic->rq[i].vrq, enic->rq_free_buf);
}
enic_dev_notify_unset(enic);
err_out_free_intr:
@@ -1998,7 +2002,7 @@ static int enic_stop(struct net_device *netdev)
for (i = 0; i < enic->wq_count; i++)
vnic_wq_clean(&enic->wq[i].vwq, enic_free_wq_buf);
for (i = 0; i < enic->rq_count; i++)
- vnic_rq_clean(&enic->rq[i].vrq, enic_free_rq_buf);
+ vnic_rq_clean(&enic->rq[i].vrq, enic->rq_free_buf);
for (i = 0; i < enic->cq_count; i++)
vnic_cq_clean(&enic->cq[i]);
for (i = 0; i < enic->intr_count; i++)
diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethernet/cisco/enic/enic_rq.c
index 571af8f31470..ae2ab5af87e9 100644
--- a/drivers/net/ethernet/cisco/enic/enic_rq.c
+++ b/drivers/net/ethernet/cisco/enic/enic_rq.c
@@ -114,7 +114,7 @@ int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc,
struct enic *enic = vnic_dev_priv(vdev);
vnic_rq_service(&enic->rq[q_number].vrq, cq_desc, completed_index,
- VNIC_RQ_RETURN_DESC, enic_rq_indicate_buf, opaque);
+ VNIC_RQ_RETURN_DESC, enic->rq_buf_service, opaque);
return 0;
}
--
2.35.2
Powered by blists - more mailing lists