[dpdk-dev,v2,15/46] net/liquidio: add APIs to allocate and free SC buffer pool
Checks
Commit Message
Soft command (SC) holds device control command and related information.
SC buffer pool holds buffers which are used during soft command
allocation.
Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Derek Chickles <derek.chickles@caviumnetworks.com>
Signed-off-by: Venkat Koppula <venkat.koppula@caviumnetworks.com>
Signed-off-by: Srisivasubramanian S <ssrinivasan@caviumnetworks.com>
Signed-off-by: Mallesham Jatharakonda <mjatharakonda@oneconvergence.com>
---
drivers/net/liquidio/lio_ethdev.c | 12 ++++++++++++
drivers/net/liquidio/lio_rxtx.c | 21 +++++++++++++++++++++
drivers/net/liquidio/lio_rxtx.h | 9 +++++++++
drivers/net/liquidio/lio_struct.h | 3 +++
4 files changed, 45 insertions(+)
@@ -101,6 +101,12 @@
return -1;
}
+ /* Initialize soft command buffer pool */
+ if (lio_setup_sc_buffer_pool(lio_dev)) {
+ lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
+ return -1;
+ }
+
if (lio_dev->fn_list.setup_mbox(lio_dev)) {
lio_dev_err(lio_dev, "Mailbox setup failed\n");
goto error;
@@ -141,6 +147,7 @@
return 0;
error:
+ lio_free_sc_buffer_pool(lio_dev);
if (lio_dev->mbox[0])
lio_dev->fn_list.free_mbox(lio_dev);
if (lio_dev->instr_queue[0])
@@ -152,11 +159,16 @@
static int
lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
{
+ struct lio_device *lio_dev = LIO_DEV(eth_dev);
+
PMD_INIT_FUNC_TRACE();
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return -EPERM;
+ /* lio_free_sc_buffer_pool */
+ lio_free_sc_buffer_pool(lio_dev);
+
rte_free(eth_dev->data->mac_addrs);
eth_dev->data->mac_addrs = NULL;
@@ -206,3 +206,24 @@
lio_dev->instr_queue[0] = NULL;
lio_dev->num_iqs--;
}
+
+int
+lio_setup_sc_buffer_pool(struct lio_device *lio_dev)
+{
+ char sc_pool_name[RTE_MEMPOOL_NAMESIZE];
+ uint16_t buf_size;
+
+ buf_size = LIO_SOFT_COMMAND_BUFFER_SIZE + RTE_PKTMBUF_HEADROOM;
+ snprintf(sc_pool_name, sizeof(sc_pool_name),
+ "lio_sc_pool_%u", lio_dev->port_id);
+ lio_dev->sc_buf_pool = rte_pktmbuf_pool_create(sc_pool_name,
+ LIO_MAX_SOFT_COMMAND_BUFFERS,
+ 0, 0, buf_size, SOCKET_ID_ANY);
+ return 0;
+}
+
+void
+lio_free_sc_buffer_pool(struct lio_device *lio_dev)
+{
+ rte_mempool_free(lio_dev->sc_buf_pool);
+}
@@ -47,6 +47,15 @@ struct lio_request_list {
void *buf;
};
+/** The size of each buffer in soft command buffer pool */
+#define LIO_SOFT_COMMAND_BUFFER_SIZE 1536
+
+/** Maximum number of buffers to allocate into soft command buffer pool */
+#define LIO_MAX_SOFT_COMMAND_BUFFERS 255
+
+int lio_setup_sc_buffer_pool(struct lio_device *lio_dev);
+void lio_free_sc_buffer_pool(struct lio_device *lio_dev);
+
/** Setup instruction queue zero for the device
* @param lio_dev which lio device to setup
*
@@ -277,6 +277,9 @@ struct lio_device {
uint32_t num_iqs;
+ /* The pool containing pre allocated buffers used for soft commands */
+ struct rte_mempool *sc_buf_pool;
+
/** The input instruction queues */
struct lio_instr_queue *instr_queue[LIO_MAX_POSSIBLE_INSTR_QUEUES];