OSDN Git Service

liquidio: Moved common function setup_glists to lio_core.c
authorIntiyaz Basha <intiyaz.basha@cavium.com>
Sat, 28 Apr 2018 06:32:55 +0000 (23:32 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Apr 2018 13:26:28 +0000 (09:26 -0400)
Moved common function setup_glists to lio_core.c
and reamed it to lio_setup_glists

Signed-off-by: Intiyaz Basha <intiyaz.basha@cavium.com>
Acked-by: Derek Chickles <derek.chickles@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/liquidio/lio_core.c
drivers/net/ethernet/cavium/liquidio/lio_main.c
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
drivers/net/ethernet/cavium/liquidio/octeon_network.h

index 669b4f2..b805d54 100644 (file)
@@ -29,6 +29,8 @@
 /* OOM task polling interval */
 #define LIO_OOM_POLL_INTERVAL_MS 250
 
+#define OCTNIC_MAX_SG  MAX_SKB_FRAGS
+
 /**
  * \brief Callback for getting interface configuration
  * @param status status of request
@@ -102,6 +104,87 @@ void lio_delete_glists(struct lio *lio)
        lio->glist = NULL;
 }
 
+/**
+ * \brief Setup gather lists
+ * @param lio per-network private data
+ */
+int lio_setup_glists(struct octeon_device *oct, struct lio *lio, int num_iqs)
+{
+       struct octnic_gather *g;
+       int i, j;
+
+       lio->glist_lock =
+           kcalloc(num_iqs, sizeof(*lio->glist_lock), GFP_KERNEL);
+       if (!lio->glist_lock)
+               return -ENOMEM;
+
+       lio->glist =
+           kcalloc(num_iqs, sizeof(*lio->glist), GFP_KERNEL);
+       if (!lio->glist) {
+               kfree(lio->glist_lock);
+               lio->glist_lock = NULL;
+               return -ENOMEM;
+       }
+
+       lio->glist_entry_size =
+               ROUNDUP8((ROUNDUP4(OCTNIC_MAX_SG) >> 2) * OCT_SG_ENTRY_SIZE);
+
+       /* allocate memory to store virtual and dma base address of
+        * per glist consistent memory
+        */
+       lio->glists_virt_base = kcalloc(num_iqs, sizeof(*lio->glists_virt_base),
+                                       GFP_KERNEL);
+       lio->glists_dma_base = kcalloc(num_iqs, sizeof(*lio->glists_dma_base),
+                                      GFP_KERNEL);
+
+       if (!lio->glists_virt_base || !lio->glists_dma_base) {
+               lio_delete_glists(lio);
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < num_iqs; i++) {
+               int numa_node = dev_to_node(&oct->pci_dev->dev);
+
+               spin_lock_init(&lio->glist_lock[i]);
+
+               INIT_LIST_HEAD(&lio->glist[i]);
+
+               lio->glists_virt_base[i] =
+                       lio_dma_alloc(oct,
+                                     lio->glist_entry_size * lio->tx_qsize,
+                                     &lio->glists_dma_base[i]);
+
+               if (!lio->glists_virt_base[i]) {
+                       lio_delete_glists(lio);
+                       return -ENOMEM;
+               }
+
+               for (j = 0; j < lio->tx_qsize; j++) {
+                       g = kzalloc_node(sizeof(*g), GFP_KERNEL,
+                                        numa_node);
+                       if (!g)
+                               g = kzalloc(sizeof(*g), GFP_KERNEL);
+                       if (!g)
+                               break;
+
+                       g->sg = lio->glists_virt_base[i] +
+                               (j * lio->glist_entry_size);
+
+                       g->sg_dma_ptr = lio->glists_dma_base[i] +
+                                       (j * lio->glist_entry_size);
+
+                       list_add_tail(&g->list, &lio->glist[i]);
+               }
+
+               if (j != lio->tx_qsize) {
+                       lio_delete_glists(lio);
+                       return -ENOMEM;
+               }
+       }
+
+       return 0;
+}
+
 int liquidio_set_feature(struct net_device *netdev, int cmd, u16 param1)
 {
        struct lio *lio = GET_LIO(netdev);
index 00d5634..4b8e29f 100644 (file)
@@ -138,8 +138,6 @@ union tx_info {
  * by this structure in the NIC module.
  */
 
-#define OCTNIC_MAX_SG  (MAX_SKB_FRAGS)
-
 #define OCTNIC_GSO_MAX_HEADER_SIZE 128
 #define OCTNIC_GSO_MAX_SIZE                                                    \
        (CN23XX_DEFAULT_INPUT_JABBER - OCTNIC_GSO_MAX_HEADER_SIZE)
@@ -521,87 +519,6 @@ static inline int check_txq_status(struct lio *lio)
 }
 
 /**
- * \brief Setup gather lists
- * @param lio per-network private data
- */
-static int setup_glists(struct octeon_device *oct, struct lio *lio, int num_iqs)
-{
-       int i, j;
-       struct octnic_gather *g;
-
-       lio->glist_lock = kcalloc(num_iqs, sizeof(*lio->glist_lock),
-                                 GFP_KERNEL);
-       if (!lio->glist_lock)
-               return -ENOMEM;
-
-       lio->glist = kcalloc(num_iqs, sizeof(*lio->glist),
-                            GFP_KERNEL);
-       if (!lio->glist) {
-               kfree(lio->glist_lock);
-               lio->glist_lock = NULL;
-               return -ENOMEM;
-       }
-
-       lio->glist_entry_size =
-               ROUNDUP8((ROUNDUP4(OCTNIC_MAX_SG) >> 2) * OCT_SG_ENTRY_SIZE);
-
-       /* allocate memory to store virtual and dma base address of
-        * per glist consistent memory
-        */
-       lio->glists_virt_base = kcalloc(num_iqs, sizeof(*lio->glists_virt_base),
-                                       GFP_KERNEL);
-       lio->glists_dma_base = kcalloc(num_iqs, sizeof(*lio->glists_dma_base),
-                                      GFP_KERNEL);
-
-       if (!lio->glists_virt_base || !lio->glists_dma_base) {
-               lio_delete_glists(lio);
-               return -ENOMEM;
-       }
-
-       for (i = 0; i < num_iqs; i++) {
-               int numa_node = dev_to_node(&oct->pci_dev->dev);
-
-               spin_lock_init(&lio->glist_lock[i]);
-
-               INIT_LIST_HEAD(&lio->glist[i]);
-
-               lio->glists_virt_base[i] =
-                       lio_dma_alloc(oct,
-                                     lio->glist_entry_size * lio->tx_qsize,
-                                     &lio->glists_dma_base[i]);
-
-               if (!lio->glists_virt_base[i]) {
-                       lio_delete_glists(lio);
-                       return -ENOMEM;
-               }
-
-               for (j = 0; j < lio->tx_qsize; j++) {
-                       g = kzalloc_node(sizeof(*g), GFP_KERNEL,
-                                        numa_node);
-                       if (!g)
-                               g = kzalloc(sizeof(*g), GFP_KERNEL);
-                       if (!g)
-                               break;
-
-                       g->sg = lio->glists_virt_base[i] +
-                               (j * lio->glist_entry_size);
-
-                       g->sg_dma_ptr = lio->glists_dma_base[i] +
-                                       (j * lio->glist_entry_size);
-
-                       list_add_tail(&g->list, &lio->glist[i]);
-               }
-
-               if (j != lio->tx_qsize) {
-                       lio_delete_glists(lio);
-                       return -ENOMEM;
-               }
-       }
-
-       return 0;
-}
-
-/**
  * \brief Print link information
  * @param netdev network device
  */
@@ -3657,7 +3574,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
                lio->tx_qsize = octeon_get_tx_qsize(octeon_dev, lio->txq);
                lio->rx_qsize = octeon_get_rx_qsize(octeon_dev, lio->rxq);
 
-               if (setup_glists(octeon_dev, lio, num_iqueues)) {
+               if (lio_setup_glists(octeon_dev, lio, num_iqueues)) {
                        dev_err(&octeon_dev->pci_dev->dev,
                                "Gather list allocation failed\n");
                        goto setup_nic_dev_fail;
index c4ba7ee..be28b8f 100644 (file)
@@ -69,8 +69,6 @@ union tx_info {
        } s;
 };
 
-#define OCTNIC_MAX_SG  (MAX_SKB_FRAGS)
-
 #define OCTNIC_GSO_MAX_HEADER_SIZE 128
 #define OCTNIC_GSO_MAX_SIZE \
                (CN23XX_DEFAULT_INPUT_JABBER - OCTNIC_GSO_MAX_HEADER_SIZE)
@@ -267,82 +265,6 @@ static struct pci_driver liquidio_vf_pci_driver = {
 };
 
 /**
- * \brief Setup gather lists
- * @param lio per-network private data
- */
-static int setup_glists(struct lio *lio, int num_iqs)
-{
-       struct octnic_gather *g;
-       int i, j;
-
-       lio->glist_lock =
-           kzalloc(sizeof(*lio->glist_lock) * num_iqs, GFP_KERNEL);
-       if (!lio->glist_lock)
-               return -ENOMEM;
-
-       lio->glist =
-           kzalloc(sizeof(*lio->glist) * num_iqs, GFP_KERNEL);
-       if (!lio->glist) {
-               kfree(lio->glist_lock);
-               lio->glist_lock = NULL;
-               return -ENOMEM;
-       }
-
-       lio->glist_entry_size =
-               ROUNDUP8((ROUNDUP4(OCTNIC_MAX_SG) >> 2) * OCT_SG_ENTRY_SIZE);
-
-       /* allocate memory to store virtual and dma base address of
-        * per glist consistent memory
-        */
-       lio->glists_virt_base = kcalloc(num_iqs, sizeof(*lio->glists_virt_base),
-                                       GFP_KERNEL);
-       lio->glists_dma_base = kcalloc(num_iqs, sizeof(*lio->glists_dma_base),
-                                      GFP_KERNEL);
-
-       if (!lio->glists_virt_base || !lio->glists_dma_base) {
-               lio_delete_glists(lio);
-               return -ENOMEM;
-       }
-
-       for (i = 0; i < num_iqs; i++) {
-               spin_lock_init(&lio->glist_lock[i]);
-
-               INIT_LIST_HEAD(&lio->glist[i]);
-
-               lio->glists_virt_base[i] =
-                       lio_dma_alloc(lio->oct_dev,
-                                     lio->glist_entry_size * lio->tx_qsize,
-                                     &lio->glists_dma_base[i]);
-
-               if (!lio->glists_virt_base[i]) {
-                       lio_delete_glists(lio);
-                       return -ENOMEM;
-               }
-
-               for (j = 0; j < lio->tx_qsize; j++) {
-                       g = kzalloc(sizeof(*g), GFP_KERNEL);
-                       if (!g)
-                               break;
-
-                       g->sg = lio->glists_virt_base[i] +
-                               (j * lio->glist_entry_size);
-
-                       g->sg_dma_ptr = lio->glists_dma_base[i] +
-                                       (j * lio->glist_entry_size);
-
-                       list_add_tail(&g->list, &lio->glist[i]);
-               }
-
-               if (j != lio->tx_qsize) {
-                       lio_delete_glists(lio);
-                       return -ENOMEM;
-               }
-       }
-
-       return 0;
-}
-
-/**
  * \brief Print link information
  * @param netdev network device
  */
@@ -2226,7 +2148,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
                lio->tx_qsize = octeon_get_tx_qsize(octeon_dev, lio->txq);
                lio->rx_qsize = octeon_get_rx_qsize(octeon_dev, lio->rxq);
 
-               if (setup_glists(lio, num_iqueues)) {
+               if (lio_setup_glists(octeon_dev, lio, num_iqueues)) {
                        dev_err(&octeon_dev->pci_dev->dev,
                                "Gather list allocation failed\n");
                        goto setup_nic_dev_fail;
index caf25b8..f8c1091 100644 (file)
@@ -226,6 +226,8 @@ void lio_if_cfg_callback(struct octeon_device *oct,
 
 void lio_delete_glists(struct lio *lio);
 
+int lio_setup_glists(struct octeon_device *oct, struct lio *lio, int num_qs);
+
 /**
  * \brief Net device change_mtu
  * @param netdev network device