fm10k: add vector pre-condition check
authorChen Jing D(Mark) <jing.d.chen@intel.com>
Fri, 30 Oct 2015 08:02:55 +0000 (16:02 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 2 Nov 2015 08:59:00 +0000 (09:59 +0100)
Add condition check in rx_queue_setup func. If number of RX desc
can't satisfy vPMD requirement, record it into a variable. Or
call fm10k_rxq_vec_setup to initialize Vector RX.

Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
Acked-by: Cunming Liang <cunming.liang@intel.com>
drivers/net/fm10k/fm10k.h
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/fm10k/fm10k_rxtx_vec.c

index 439e95f..48b2f6d 100644 (file)
@@ -138,6 +138,8 @@ struct fm10k_dev_info {
        /* Protect the mailbox to avoid race condition */
        rte_spinlock_t    mbx_lock;
        struct fm10k_macvlan_filter_info    macvlan;
+       /* Flag to indicate if RX vector conditions satisfied */
+       bool rx_vec_allowed;
 };
 
 /*
@@ -168,9 +170,10 @@ struct fm10k_rx_queue {
        struct rte_mempool *mp;
        struct rte_mbuf **sw_ring;
        volatile union fm10k_rx_desc *hw_ring;
-       struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
-       struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+       struct rte_mbuf *pkt_first_seg; /* First segment of current packet. */
+       struct rte_mbuf *pkt_last_seg;  /* Last segment of current packet. */
        uint64_t hw_ring_phys_addr;
+       uint64_t mbuf_initializer; /* value to init mbufs */
        uint16_t next_dd;
        uint16_t next_alloc;
        uint16_t next_trigger;
@@ -180,7 +183,7 @@ struct fm10k_rx_queue {
        uint16_t queue_id;
        uint8_t port_id;
        uint8_t drop_en;
-       uint8_t rx_deferred_start; /**< don't start this queue in dev start. */
+       uint8_t rx_deferred_start; /* don't start this queue in dev start. */
 };
 
 /*
@@ -316,4 +319,6 @@ uint16_t fm10k_recv_scattered_pkts(void *rx_queue,
 
 uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        uint16_t nb_pkts);
+
+int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
 #endif
index caa1272..c61fd63 100644 (file)
@@ -1466,6 +1466,7 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id,
        const struct rte_eth_rxconf *conf, struct rte_mempool *mp)
 {
        struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct fm10k_dev_info *dev_info = FM10K_DEV_PRIVATE_TO_INFO(dev);
        struct fm10k_rx_queue *q;
        const struct rte_memzone *mz;
 
@@ -1548,6 +1549,16 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id,
        q->hw_ring_phys_addr = mz->phys_addr;
 #endif
 
+       /* Check if number of descs satisfied Vector requirement */
+       if (!rte_is_power_of_2(nb_desc)) {
+               PMD_INIT_LOG(DEBUG, "queue[%d] doesn't meet Vector Rx "
+                                   "preconditions - canceling the feature for "
+                                   "the whole port[%d]",
+                            q->queue_id, q->port_id);
+               dev_info->rx_vec_allowed = false;
+       } else
+               fm10k_rxq_vec_setup(q);
+
        dev->data->rx_queues[queue_id] = q;
        return 0;
 }
index 69174d9..34b677b 100644 (file)
 #ifndef __INTEL_COMPILER
 #pragma GCC diagnostic ignored "-Wcast-qual"
 #endif
+
+int __attribute__((cold))
+fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq)
+{
+       uintptr_t p;
+       struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
+
+       mb_def.nb_segs = 1;
+       /* data_off will be ajusted after new mbuf allocated for 512-byte
+        * alignment.
+        */
+       mb_def.data_off = RTE_PKTMBUF_HEADROOM;
+       mb_def.port = rxq->port_id;
+       rte_mbuf_refcnt_set(&mb_def, 1);
+
+       /* prevent compiler reordering: rearm_data covers previous fields */
+       rte_compiler_barrier();
+       p = (uintptr_t)&mb_def.rearm_data;
+       rxq->mbuf_initializer = *(uint64_t *)p;
+       return 0;
+}