net/liquidio: add APIs to allocate and free SC buffer pool
authorShijith Thotton <shijith.thotton@caviumnetworks.com>
Sat, 25 Mar 2017 06:24:26 +0000 (11:54 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 4 Apr 2017 16:59:48 +0000 (18:59 +0200)
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
drivers/net/liquidio/lio_rxtx.c
drivers/net/liquidio/lio_rxtx.h
drivers/net/liquidio/lio_struct.h

index 5d7d5a7..a1dcdf6 100644 (file)
@@ -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;
 
index 4a687d8..1c6ce59 100644 (file)
@@ -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);
+}
index 33f178b..b308211 100644 (file)
@@ -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
  *
index 2806c37..992ad39 100644 (file)
@@ -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];