[ovs-dev] [RFC v2 3/4] dpif-netdev: Add rxq prioritization

Billy O'Mahony billy.o.mahony at intel.com
Tue Jul 11 16:58:32 UTC 2017


If an rxq is marked as 'prioritized' then keep reading from this queue until
there are no packets available. Only then proceed to other queues.

Signed-off-by: Billy O'Mahony <billy.o.mahony at intel.com>
---
 lib/dpif-netdev.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 66712c7..0dca0f5 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -480,6 +480,7 @@ struct dp_netdev_pmd_cycles {
 struct polled_queue {
     struct netdev_rxq *rx;
     odp_port_t port_no;
+    uint8_t is_priority;
 };
 
 /* Contained by struct dp_netdev_pmd_thread's 'poll_list' member. */
@@ -3080,19 +3081,21 @@ cycles_count_end(struct dp_netdev_pmd_thread *pmd,
     non_atomic_ullong_add(&pmd->cycles.n[type], interval);
 }
 
-static void
+static unsigned int
 dp_netdev_process_rxq_port(struct dp_netdev_pmd_thread *pmd,
                            struct netdev_rxq *rx,
                            odp_port_t port_no)
 {
     struct dp_packet_batch batch;
     int error;
+    unsigned int pkt_cnt = 0;
 
     dp_packet_batch_init(&batch);
     cycles_count_start(pmd);
     error = netdev_rxq_recv(rx, &batch);
     cycles_count_end(pmd, PMD_CYCLES_POLLING);
     if (!error) {
+         pkt_cnt = batch.count;
         *recirc_depth_get() = 0;
 
         cycles_count_start(pmd);
@@ -3104,6 +3107,7 @@ dp_netdev_process_rxq_port(struct dp_netdev_pmd_thread *pmd,
         VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
                     netdev_rxq_get_name(rx), ovs_strerror(error));
     }
+    return pkt_cnt;
 }
 
 static struct tx_port *
@@ -3685,6 +3689,8 @@ pmd_load_queues_and_ports(struct dp_netdev_pmd_thread *pmd,
     HMAP_FOR_EACH (poll, node, &pmd->poll_list) {
         poll_list[i].rx = poll->rxq->rx;
         poll_list[i].port_no = poll->rxq->port->port_no;
+        poll_list[i].is_priority = \
+            (poll->rxq->rx->queue_id == poll->rxq->rx->netdev->priority_rxq);
         i++;
     }
 
@@ -3731,10 +3737,21 @@ reload:
         lc = UINT_MAX;
     }
 
+    unsigned int log_cnt = 0;
+    int rxd_cnt;
+    int streak_len;
+    const unsigned int MAX_STREAK_LEN = 100;
+
     for (;;) {
+        log_cnt++;
         for (i = 0; i < poll_cnt; i++) {
-            dp_netdev_process_rxq_port(pmd, poll_list[i].rx,
-                                       poll_list[i].port_no);
+            streak_len = 0;
+            do {
+                rxd_cnt = dp_netdev_process_rxq_port(pmd, poll_list[i].rx,
+                                                     poll_list[i].port_no);
+                streak_len++;
+            } while (rxd_cnt && poll_list[i].is_priority &&
+                     streak_len < MAX_STREAK_LEN);
         }
 
         if (lc++ > 1024) {
-- 
2.7.4



More information about the dev mailing list