[dpdk-dev,RFC,11/14] ixgbe: make mbuf_initializer queue variable global

Message ID 1407789890-17355-12-git-send-email-bruce.richardson@intel.com (mailing list archive)
State RFC, archived
Headers

Commit Message

Bruce Richardson Aug. 11, 2014, 8:44 p.m. UTC
On descriptor rearm, the mbuf_initializer variable can be used to do a
single-shot write to an mbuf to initialize all variables that can be
set. This is currently used only by vector PMD function, but now allow
it to be generally used by other RX code paths.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_rxtx.c     | 25 +++++++++++++++++++++++--
 lib/librte_pmd_ixgbe/ixgbe_rxtx.h     |  9 ++++++---
 lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c | 25 +------------------------
 3 files changed, 30 insertions(+), 29 deletions(-)
  

Comments

Stephen Hemminger Aug. 11, 2014, 9:47 p.m. UTC | #1
On Mon, 11 Aug 2014 21:44:47 +0100
Bruce Richardson <bruce.richardson@intel.com> wrote:

> On descriptor rearm, the mbuf_initializer variable can be used to do a
> single-shot write to an mbuf to initialize all variables that can be
> set. This is currently used only by vector PMD function, but now allow
> it to be generally used by other RX code paths.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  lib/librte_pmd_ixgbe/ixgbe_rxtx.c     | 25 +++++++++++++++++++++++--
>  lib/librte_pmd_ixgbe/ixgbe_rxtx.h     |  9 ++++++---
>  lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c | 25 +------------------------
>  3 files changed, 30 insertions(+), 29 deletions(-)


These patches from 11-14 are really a follow on thread to the original
changes. The sequence could be shorter so that reviewers digest 1-10 first.
  
Bruce Richardson Aug. 11, 2014, 10:03 p.m. UTC | #2
> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Monday, August 11, 2014 2:48 PM
> To: Richardson, Bruce
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [RFC PATCH 11/14] ixgbe: make mbuf_initializer queue
> variable global
> 
> On Mon, 11 Aug 2014 21:44:47 +0100
> Bruce Richardson <bruce.richardson@intel.com> wrote:
> 
> > On descriptor rearm, the mbuf_initializer variable can be used to do a
> > single-shot write to an mbuf to initialize all variables that can be
> > set. This is currently used only by vector PMD function, but now allow
> > it to be generally used by other RX code paths.
> >
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> >  lib/librte_pmd_ixgbe/ixgbe_rxtx.c     | 25 +++++++++++++++++++++++--
> >  lib/librte_pmd_ixgbe/ixgbe_rxtx.h     |  9 ++++++---
> >  lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c | 25 +------------------------
> >  3 files changed, 30 insertions(+), 29 deletions(-)
> 
> 
> These patches from 11-14 are really a follow on thread to the original
> changes. The sequence could be shorter so that reviewers digest 1-10 first.

Ok. The whole patch sequence needs to be cleaned up a lot before it's ready to go into the code, so I'll try and keep that in mind when doing the cleanup.
  

Patch

diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
index f9cc352..fadb9a0 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
@@ -90,6 +90,27 @@ 
 		ETH_RSS_IPV6_UDP | \
 		ETH_RSS_IPV6_UDP_EX)
 
+int
+ixgbe_set_mbuf_initializer(struct igb_rx_queue *rxq)
+{
+	static struct rte_mbuf mb_def = {
+		.buf_len = 0,
+		.data_len = 0,
+
+		.data_off = RTE_PKTMBUF_HEADROOM,
+#ifdef RTE_MBUF_REFCNT
+		.refcnt = 1,
+#endif
+		.nb_segs = 1,
+		.port = 0
+	};
+
+	mb_def.buf_len = rxq->mb_pool->elt_size - sizeof(struct rte_mbuf);
+	mb_def.port = rxq->port_id;
+	rxq->mbuf_initializer = *((uint64_t *)&mb_def.rearm_data);
+	return 0;
+}
+
 static inline struct rte_mbuf *
 rte_rxmbuf_alloc(struct rte_mempool *mp)
 {
@@ -1878,7 +1899,7 @@  ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		PMD_INIT_LOG(INFO, "Using simple tx code path\n");
 #ifdef RTE_IXGBE_INC_VECTOR
 		if (txq->tx_rs_thresh <= RTE_IXGBE_TX_MAX_FREE_BUF_SZ &&
-		    ixgbe_txq_vec_setup(txq, socket_id) == 0) {
+		    ixgbe_txq_vec_setup(txq) == 0) {
 			PMD_INIT_LOG(INFO, "Vector tx enabled.\n");
 			dev->tx_pkt_burst = ixgbe_xmit_pkts_vec;
 		}
@@ -2169,7 +2190,6 @@  ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		if (!ixgbe_rx_vec_condition_check(dev)) {
 			PMD_INIT_LOG(INFO, "Vector rx enabled, please make "
 				     "sure RX burst size no less than 32.\n");
-			ixgbe_rxq_vec_setup(rxq, socket_id);
 			dev->rx_pkt_burst = ixgbe_recv_pkts_vec;
 		}
 #endif
@@ -2183,6 +2203,7 @@  ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	}
 	dev->data->rx_queues[queue_idx] = rxq;
 
+	ixgbe_set_mbuf_initializer(rxq);
 	ixgbe_reset_rx_queue(rxq);
 
 	return 0;
diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.h b/lib/librte_pmd_ixgbe/ixgbe_rxtx.h
index d9889d9..76db3ca 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.h
@@ -107,6 +107,7 @@  struct igb_rx_queue {
 	struct igb_rx_entry *sw_ring; /**< address of RX software ring. */
 	struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
 	struct rte_mbuf *pkt_last_seg; /**< Last segment of current packet. */
+	uint64_t            mbuf_initializer; /**< value to init mbufs */
 	uint16_t            nb_rx_desc; /**< number of RX descriptors. */
 	uint16_t            rx_tail;  /**< current value of RDT register. */
 	uint16_t            nb_rx_hold; /**< number of held free RX desc. */
@@ -118,7 +119,6 @@  struct igb_rx_queue {
 #ifdef RTE_IXGBE_INC_VECTOR
 	uint16_t            rxrearm_nb; /**< the idx we start the re-arming from */
 	uint16_t            rxrearm_start;  /**< number of remaining to be re-armed */
-	uint64_t            mbuf_initializer; /**< value to init mbufs */
 #endif
 	uint16_t            rx_free_thresh; /**< max free RX desc to hold. */
 	uint16_t            queue_id; /**< RX queue index. */
@@ -226,9 +226,12 @@  struct ixgbe_txq_ops {
 #ifdef RTE_IXGBE_INC_VECTOR
 uint16_t ixgbe_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 uint16_t ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-int ixgbe_txq_vec_setup(struct igb_tx_queue *txq, unsigned int socket_id);
-int ixgbe_rxq_vec_setup(struct igb_rx_queue *rxq, unsigned int socket_id);
+int ixgbe_txq_vec_setup(struct igb_tx_queue *txq);
 int ixgbe_rx_vec_condition_check(struct rte_eth_dev *dev);
 #endif
 
+int
+ixgbe_set_mbuf_initializer(struct igb_rx_queue *rxq);
+
+
 #endif
diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c
index c98356e..39c06e2 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c
@@ -45,28 +45,6 @@ 
 #endif
 
 
-int
-ixgbe_rxq_vec_setup(struct igb_rx_queue *rxq,
-			__rte_unused unsigned int socket_id)
-{
-	static struct rte_mbuf mb_def = {
-		.buf_len = 0,
-		.data_len = 0,
-
-		.data_off = RTE_PKTMBUF_HEADROOM,
-#ifdef RTE_MBUF_REFCNT
-		.refcnt = 1,
-#endif
-		.nb_segs = 1,
-		.port = 0
-	};
-
-	mb_def.buf_len = rxq->mb_pool->elt_size - sizeof(struct rte_mbuf);
-	mb_def.port = rxq->port_id;
-	rxq->mbuf_initializer = *((uint64_t *)&mb_def.rearm_data);
-	return 0;
-}
-
 static inline void
 ixgbe_rxq_rearm(struct igb_rx_queue *rxq)
 {
@@ -586,8 +564,7 @@  static struct ixgbe_txq_ops vec_txq_ops = {
 	.reset = ixgbe_reset_tx_queue,
 };
 
-int ixgbe_txq_vec_setup(struct igb_tx_queue *txq,
-			unsigned int socket_id __rte_unused)
+int ixgbe_txq_vec_setup(struct igb_tx_queue *txq)
 {
 	if (txq->sw_ring == NULL)
 		return -1;