liquidio: moved liquidio_napi_poll to lio_core.c
authorIntiyaz Basha <intiyaz.basha@cavium.com>
Mon, 14 Aug 2017 19:01:50 +0000 (12:01 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 15 Aug 2017 05:21:40 +0000 (22:21 -0700)
Moving common liquidio_napi_poll to lio_core.c

Signed-off-by: Intiyaz Basha <intiyaz.basha@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 8cba9278c274f8faa603b5fef5fa83f7ec2a7c01..2030c2531309c4c2bc1e0bb421e969bd58e60c5f 100644 (file)
@@ -366,7 +366,7 @@ void cleanup_rx_oom_poll_fn(struct net_device *netdev)
 }
 
 /* Runs in interrupt context. */
-void lio_update_txq_status(struct octeon_device *oct, int iq_num)
+static void lio_update_txq_status(struct octeon_device *oct, int iq_num)
 {
        struct octeon_instr_queue *iq = oct->instr_queue[iq_num];
        struct net_device *netdev;
@@ -620,3 +620,62 @@ void liquidio_napi_drv_callback(void *arg)
                smp_call_function_single_async(droq->cpu_id, csd);
        }
 }
+
+/**
+ * \brief Entry point for NAPI polling
+ * @param napi NAPI structure
+ * @param budget maximum number of items to process
+ */
+int liquidio_napi_poll(struct napi_struct *napi, int budget)
+{
+       struct octeon_instr_queue *iq;
+       struct octeon_device *oct;
+       struct octeon_droq *droq;
+       int tx_done = 0, iq_no;
+       int work_done;
+
+       droq = container_of(napi, struct octeon_droq, napi);
+       oct = droq->oct_dev;
+       iq_no = droq->q_no;
+
+       /* Handle Droq descriptors */
+       work_done = octeon_process_droq_poll_cmd(oct, droq->q_no,
+                                                POLL_EVENT_PROCESS_PKTS,
+                                                budget);
+
+       /* Flush the instruction queue */
+       iq = oct->instr_queue[iq_no];
+       if (iq) {
+               /* TODO: move this check to inside octeon_flush_iq,
+                * once check_db_timeout is removed
+                */
+               if (atomic_read(&iq->instr_pending))
+                       /* Process iq buffers with in the budget limits */
+                       tx_done = octeon_flush_iq(oct, iq, budget);
+               else
+                       tx_done = 1;
+               /* Update iq read-index rather than waiting for next interrupt.
+                * Return back if tx_done is false.
+                */
+               /* sub-queue status update */
+               lio_update_txq_status(oct, iq_no);
+       } else {
+               dev_err(&oct->pci_dev->dev, "%s:  iq (%d) num invalid\n",
+                       __func__, iq_no);
+       }
+
+#define MAX_REG_CNT  2000000U
+       /* force enable interrupt if reg cnts are high to avoid wraparound */
+       if (((work_done < budget) && (tx_done)) ||
+           (iq->pkt_in_done >= MAX_REG_CNT) ||
+           (droq->pkt_count >= MAX_REG_CNT)) {
+               tx_done = 1;
+               napi_complete_done(napi, work_done);
+
+               octeon_process_droq_poll_cmd(droq->oct_dev, droq->q_no,
+                                            POLL_EVENT_ENABLE_INTR, 0);
+               return 0;
+       }
+
+       return (!tx_done) ? (budget) : (work_done);
+}
index e72618f6b2eb7d0d54e9a21c8da2cd26ee9a5e15..632c395a4f4461dbc9891e93f72393a914283d79 100644 (file)
@@ -2231,58 +2231,6 @@ static void if_cfg_callback(struct octeon_device *oct,
        wake_up_interruptible(&ctx->wc);
 }
 
-/**
- * \brief Entry point for NAPI polling
- * @param napi NAPI structure
- * @param budget maximum number of items to process
- */
-static int liquidio_napi_poll(struct napi_struct *napi, int budget)
-{
-       struct octeon_droq *droq;
-       int work_done;
-       int tx_done = 0, iq_no;
-       struct octeon_instr_queue *iq;
-       struct octeon_device *oct;
-
-       droq = container_of(napi, struct octeon_droq, napi);
-       oct = droq->oct_dev;
-       iq_no = droq->q_no;
-       /* Handle Droq descriptors */
-       work_done = octeon_process_droq_poll_cmd(oct, droq->q_no,
-                                                POLL_EVENT_PROCESS_PKTS,
-                                                budget);
-
-       /* Flush the instruction queue */
-       iq = oct->instr_queue[iq_no];
-       if (iq) {
-               if (atomic_read(&iq->instr_pending))
-                       /* Process iq buffers with in the budget limits */
-                       tx_done = octeon_flush_iq(oct, iq, budget);
-               else
-                       tx_done = 1;
-               /* Update iq read-index rather than waiting for next interrupt.
-                * Return back if tx_done is false.
-                */
-               lio_update_txq_status(oct, iq_no);
-       } else {
-               dev_err(&oct->pci_dev->dev, "%s:  iq (%d) num invalid\n",
-                       __func__, iq_no);
-       }
-
-       /* force enable interrupt if reg cnts are high to avoid wraparound */
-       if ((work_done < budget && tx_done) ||
-           (iq && iq->pkt_in_done >= MAX_REG_CNT) ||
-           (droq->pkt_count >= MAX_REG_CNT)) {
-               tx_done = 1;
-               napi_complete_done(napi, work_done);
-               octeon_process_droq_poll_cmd(droq->oct_dev, droq->q_no,
-                                            POLL_EVENT_ENABLE_INTR, 0);
-               return 0;
-       }
-
-       return (!tx_done) ? (budget) : (work_done);
-}
-
 /**
  * \brief Setup input and output queues
  * @param octeon_dev octeon device
index 2663bd60e5d261b0e71d085d3af488f31e8c73e1..0bd0c30077c7c057ff196b506be04d33e0172fcf 100644 (file)
@@ -1376,60 +1376,6 @@ static void if_cfg_callback(struct octeon_device *oct,
        wake_up_interruptible(&ctx->wc);
 }
 
-/**
- * \brief Entry point for NAPI polling
- * @param napi NAPI structure
- * @param budget maximum number of items to process
- */
-static int liquidio_napi_poll(struct napi_struct *napi, int budget)
-{
-       struct octeon_instr_queue *iq;
-       struct octeon_device *oct;
-       struct octeon_droq *droq;
-       int tx_done = 0, iq_no;
-       int work_done;
-
-       droq = container_of(napi, struct octeon_droq, napi);
-       oct = droq->oct_dev;
-       iq_no = droq->q_no;
-
-       /* Handle Droq descriptors */
-       work_done = octeon_process_droq_poll_cmd(oct, droq->q_no,
-                                                POLL_EVENT_PROCESS_PKTS,
-                                                budget);
-
-       /* Flush the instruction queue */
-       iq = oct->instr_queue[iq_no];
-       if (iq) {
-               if (atomic_read(&iq->instr_pending))
-                       /* Process iq buffers with in the budget limits */
-                       tx_done = octeon_flush_iq(oct, iq, budget);
-               else
-                       tx_done = 1;
-
-               /* Update iq read-index rather than waiting for next interrupt.
-                * Return back if tx_done is false.
-                */
-               lio_update_txq_status(oct, iq_no);
-       } else {
-               dev_err(&oct->pci_dev->dev, "%s: iq (%d) num invalid\n",
-                       __func__, iq_no);
-       }
-
-       /* force enable interrupt if reg cnts are high to avoid wraparound */
-       if ((work_done < budget && tx_done) ||
-           (iq && iq->pkt_in_done >= MAX_REG_CNT) ||
-           (droq->pkt_count >= MAX_REG_CNT)) {
-               tx_done = 1;
-               napi_complete_done(napi, work_done);
-               octeon_process_droq_poll_cmd(droq->oct_dev, droq->q_no,
-                                            POLL_EVENT_ENABLE_INTR, 0);
-               return 0;
-       }
-
-       return (!tx_done) ? (budget) : (work_done);
-}
-
 /**
  * \brief Setup input and output queues
  * @param octeon_dev octeon device
index 076fdfcdd103b2a4ac5356e228e884dc766b9d96..b6597ef5696803fbf499a45c7a229a637f9a9070 100644 (file)
@@ -474,7 +474,6 @@ static inline int wait_for_pending_requests(struct octeon_device *oct)
        return 0;
 }
 
-void lio_update_txq_status(struct octeon_device *oct, int iq_num);
 int octeon_setup_droq(struct octeon_device *oct, int q_no, int num_descs,
                      int desc_size, void *app_ctx);
 void
@@ -485,4 +484,5 @@ liquidio_push_packet(u32 octeon_id __attribute__((unused)),
                     void *param,
                     void *arg);
 void liquidio_napi_drv_callback(void *arg);
+int liquidio_napi_poll(struct napi_struct *napi, int budget);
 #endif