[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220413171026.1264294-5-drt@linux.ibm.com>
Date: Wed, 13 Apr 2022 13:10:24 -0400
From: Dany Madden <drt@...ux.ibm.com>
To: netdev@...r.kernel.org
Cc: sukadev@...ux.ibm.com
Subject: [PATCH net-next 4/6] ibmvnic: convert rxpool ltb to a set of ltbs
From: Sukadev Bhattiprolu <sukadev@...ux.ibm.com>
Define and use interfaces that treat the long term buffer (LTB) of an
rxpool as a set of LTBs rather than a single LTB. The set only has one
LTB for now.
Signed-off-by: Sukadev Bhattiprolu <sukadev@...ux.ibm.com>
Signed-off-by: Dany Madden <drt@...ux.ibm.com>
---
drivers/net/ethernet/ibm/ibmvnic.c | 44 ++++++++++++++++++++++++++----
drivers/net/ethernet/ibm/ibmvnic.h | 7 ++++-
2 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 2e6042409585..765a48833b3b 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -345,6 +345,41 @@ static void free_long_term_buff(struct ibmvnic_adapter *adapter,
ltb->map_id = 0;
}
+static void free_ltb_set(struct ibmvnic_adapter *adapter,
+ struct ibmvnic_ltb_set *ltb_set)
+{
+ int i;
+
+ for (i = 0; i < ltb_set->num_ltbs; i++)
+ free_long_term_buff(adapter, <b_set->ltbs[i]);
+
+ kfree(ltb_set->ltbs);
+ ltb_set->ltbs = NULL;
+ ltb_set->num_ltbs = 0;
+}
+
+static int alloc_ltb_set(struct ibmvnic_adapter *adapter,
+ struct ibmvnic_ltb_set *ltb_set, int num_buffs,
+ int buff_size)
+{
+ struct ibmvnic_long_term_buff *ltb;
+ int ltb_size;
+ int size;
+
+ size = sizeof(struct ibmvnic_long_term_buff);
+
+ ltb_set->ltbs = kmalloc(size, GFP_KERNEL);
+ if (!ltb_set->ltbs)
+ return -ENOMEM;
+
+ ltb_set->num_ltbs = 1;
+ ltb = <b_set->ltbs[0];
+
+ ltb_size = num_buffs * buff_size;
+
+ return alloc_long_term_buff(adapter, ltb, ltb_size);
+}
+
/**
* map_rxpool_buf_to_ltb - Map given rxpool buffer to offset in an LTB.
* @rxpool: The receive buffer pool containing buffer
@@ -360,7 +395,7 @@ static void map_rxpool_buf_to_ltb(struct ibmvnic_rx_pool *rxpool,
struct ibmvnic_long_term_buff **ltbp,
unsigned int *offset)
{
- *ltbp = &rxpool->long_term_buff;
+ *ltbp = &rxpool->ltb_set.ltbs[0];
*offset = bufidx * rxpool->buff_size;
}
@@ -618,7 +653,7 @@ static void release_rx_pools(struct ibmvnic_adapter *adapter)
kfree(rx_pool->free_map);
- free_long_term_buff(adapter, &rx_pool->long_term_buff);
+ free_ltb_set(adapter, &rx_pool->ltb_set);
if (!rx_pool->rx_buff)
continue;
@@ -763,9 +798,8 @@ static int init_rx_pools(struct net_device *netdev)
dev_dbg(dev, "Updating LTB for rx pool %d [%d, %d]\n",
i, rx_pool->size, rx_pool->buff_size);
- rc = alloc_long_term_buff(adapter, &rx_pool->long_term_buff,
- rx_pool->size * rx_pool->buff_size);
- if (rc)
+ if (alloc_ltb_set(adapter, &rx_pool->ltb_set,
+ rx_pool->size, rx_pool->buff_size))
goto out;
for (j = 0; j < rx_pool->size; ++j) {
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index 8f5cefb932dd..7d430fdf47c0 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -798,6 +798,11 @@ struct ibmvnic_long_term_buff {
u8 map_id;
};
+struct ibmvnic_ltb_set {
+ int num_ltbs;
+ struct ibmvnic_long_term_buff *ltbs;
+};
+
struct ibmvnic_tx_buff {
struct sk_buff *skb;
int index;
@@ -833,7 +838,7 @@ struct ibmvnic_rx_pool {
int next_free;
int next_alloc;
int active;
- struct ibmvnic_long_term_buff long_term_buff;
+ struct ibmvnic_ltb_set ltb_set;
} ____cacheline_aligned;
struct ibmvnic_vpd {
--
2.27.0
Powered by blists - more mailing lists