From: Shijith Thotton Date: Sat, 25 Mar 2017 06:24:26 +0000 (+0530) Subject: net/liquidio: add APIs to allocate and free SC buffer pool X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=460da0e78976c89426a903990134b0bb77f18d66;p=dpdk.git net/liquidio: add APIs to allocate and free SC buffer pool 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 Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 5d7d5a7d4c..a1dcdf66dd 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -101,6 +101,12 @@ lio_first_time_init(struct lio_device *lio_dev, 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 @@ lio_first_time_init(struct lio_device *lio_dev, 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 @@ error: 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; diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c index 4a687d82c3..1c6ce59e96 100644 --- a/drivers/net/liquidio/lio_rxtx.c +++ b/drivers/net/liquidio/lio_rxtx.c @@ -206,3 +206,24 @@ lio_free_instr_queue0(struct lio_device *lio_dev) 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); +} diff --git a/drivers/net/liquidio/lio_rxtx.h b/drivers/net/liquidio/lio_rxtx.h index 33f178bc9b..b30821184e 100644 --- a/drivers/net/liquidio/lio_rxtx.h +++ b/drivers/net/liquidio/lio_rxtx.h @@ -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 * diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index 2806c379de..992ad39f56 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -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];