From patchwork Fri Jul 24 13:58:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ananyev, Konstantin" X-Patchwork-Id: 6581 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A1710C462; Fri, 24 Jul 2015 16:00:12 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 4F3A0C45C for ; Fri, 24 Jul 2015 16:00:10 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 24 Jul 2015 07:00:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,538,1432623600"; d="scan'208";a="529609285" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jul 2015 07:00:08 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t6OE07fn026797; Fri, 24 Jul 2015 15:00:07 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t6OE07eR012480; Fri, 24 Jul 2015 15:00:07 +0100 Received: (from kananye1@localhost) by sivswdev02.ir.intel.com with id t6OE07ao012476; Fri, 24 Jul 2015 15:00:07 +0100 From: Konstantin Ananyev To: dev@dpdk.org Date: Fri, 24 Jul 2015 14:58:15 +0100 Message-Id: <1437746295-12184-6-git-send-email-konstantin.ananyev@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1437746295-12184-1-git-send-email-konstantin.ananyev@intel.com> References: <1437667506-3890-2-git-send-email-bruce.richardson@intel.com> <1437746295-12184-1-git-send-email-konstantin.ananyev@intel.com> In-Reply-To: <1437667506-3890-2-git-send-email-bruce.richardson@intel.com> References: <1437667506-3890-2-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCHv2 5/5] ixgbe: remove awkward typecasts from ixgbe SSE PMD X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The vector/SSE pmd used a different element type for the tx queue sw_ring entries. This led to lots of typecasts in the code which required specific use of bracketing, leading to subtle errors. For example, in the original code: txe = (struct ixgbe_tx_entry_v *)&txq->sw_ring[i]; instead needs to be written as: txe = &((struct ixgbe_tx_entry_v *)txq->sw_ring)[i]; We can eliminate this problem, by having two software ring pointers in the structure for the two different element types. v2 changes: - fix remaining wrong typecast. Signed-off-by: Bruce Richardson Signed-off-by: Konstantin Ananyev --- drivers/net/ixgbe/ixgbe_rxtx.h | 5 ++++- drivers/net/ixgbe/ixgbe_rxtx_vec.c | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h index befdc3a..1557438 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.h +++ b/drivers/net/ixgbe/ixgbe_rxtx.h @@ -193,7 +193,10 @@ struct ixgbe_tx_queue { /** TX ring virtual address. */ volatile union ixgbe_adv_tx_desc *tx_ring; uint64_t tx_ring_phys_addr; /**< TX ring DMA address. */ - struct ixgbe_tx_entry *sw_ring; /**< virtual address of SW ring. */ + union { + struct ixgbe_tx_entry *sw_ring; /**< address of SW ring for scalar PMD. */ + struct ixgbe_tx_entry_v *sw_ring_v; /**< address of SW ring for vector PMD */ + }; volatile uint32_t *tdt_reg_addr; /**< Address of TDT register. */ uint16_t nb_tx_desc; /**< number of TX descriptors. */ uint16_t tx_tail; /**< current value of TDT reg. */ diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec.c b/drivers/net/ixgbe/ixgbe_rxtx_vec.c index d3da31d..9c5390e 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec.c +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec.c @@ -608,8 +608,7 @@ ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq) * first buffer to free from S/W ring is at index * tx_next_dd - (tx_rs_thresh-1) */ - txep = &((struct ixgbe_tx_entry_v *)txq->sw_ring)[txq->tx_next_dd - - (n - 1)]; + txep = &txq->sw_ring_v[txq->tx_next_dd - (n - 1)]; m = __rte_pktmbuf_prefree_seg(txep[0].mbuf); if (likely(m != NULL)) { free[0] = m; @@ -678,7 +677,7 @@ ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, tx_id = txq->tx_tail; txdp = &txq->tx_ring[tx_id]; - txep = &((struct ixgbe_tx_entry_v *)txq->sw_ring)[tx_id]; + txep = &txq->sw_ring_v[tx_id]; txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts); @@ -699,7 +698,7 @@ ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, /* avoid reach the end of ring */ txdp = &(txq->tx_ring[tx_id]); - txep = &(((struct ixgbe_tx_entry_v *)txq->sw_ring)[tx_id]); + txep = &txq->sw_ring_v[tx_id]; } tx_backlog_entry(txep, tx_pkts, nb_commit); @@ -735,14 +734,14 @@ ixgbe_tx_queue_release_mbufs_vec(struct ixgbe_tx_queue *txq) for (i = txq->tx_next_dd - (txq->tx_rs_thresh - 1); i != txq->tx_tail; i = (i + 1) & max_desc) { - txe = &((struct ixgbe_tx_entry_v *)txq->sw_ring)[i]; + txe = &txq->sw_ring_v[i]; rte_pktmbuf_free_seg(txe->mbuf); } txq->nb_tx_free = max_desc; /* reset tx_entry */ for (i = 0; i < txq->nb_tx_desc; i++) { - txe = (struct ixgbe_tx_entry_v *)&txq->sw_ring[i]; + txe = &txq->sw_ring_v[i]; txe->mbuf = NULL; } } @@ -772,8 +771,8 @@ ixgbe_tx_free_swring(struct ixgbe_tx_queue *txq) return; if (txq->sw_ring != NULL) { - rte_free((struct ixgbe_rx_entry *)txq->sw_ring - 1); - txq->sw_ring = NULL; + rte_free(txq->sw_ring_v - 1); + txq->sw_ring_v = NULL; } } @@ -781,7 +780,7 @@ static void __attribute__((cold)) ixgbe_reset_tx_queue(struct ixgbe_tx_queue *txq) { static const union ixgbe_adv_tx_desc zeroed_desc = {{0}}; - struct ixgbe_tx_entry_v *txe = (struct ixgbe_tx_entry_v *)txq->sw_ring; + struct ixgbe_tx_entry_v *txe = txq->sw_ring_v; uint16_t i; /* Zero out HW ring memory */ @@ -838,12 +837,11 @@ ixgbe_rxq_vec_setup(struct ixgbe_rx_queue *rxq) int __attribute__((cold)) ixgbe_txq_vec_setup(struct ixgbe_tx_queue *txq) { - if (txq->sw_ring == NULL) + if (txq->sw_ring_v == NULL) return -1; /* leave the first one for overflow */ - txq->sw_ring = (struct ixgbe_tx_entry *) - ((struct ixgbe_tx_entry_v *)txq->sw_ring + 1); + txq->sw_ring_v = txq->sw_ring_v + 1; txq->ops = &vec_txq_ops; return 0;