From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by dpdk.org (Postfix) with ESMTP id B641B2BDD for ; Thu, 3 Mar 2016 15:27:40 +0100 (CET) Received: by mail-wm0-f48.google.com with SMTP id p65so37287788wmp.1 for ; Thu, 03 Mar 2016 06:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iXUlPx96iTzc0B5krEAf8ul/voEG4A4R274p1SWOd+8=; b=OpBOCyciNIu5n6qIhhUc4u2xV3L3WXcaNrJ117E/vbCPv+syFldNGOztjGCgTPd5Eo E5iC7lz/FPQq6GdFKU3/m96YKi0nbt6MWXc8mhNEVCJpd6I9w+elWj9KupYBaHtugeta fgAA2hi1mpVA2izwUNMfli1dutS5OG79naLd6JZRkTdSinhTsGhN4VGua+KCgOWllplU zJRpMPgocak+5Gn+655yCaCzHzshyJFafIaidgXJA4LazdTQFY/aAQwoKvN/xY4hzsE2 iZqLA3H5iAxOBk5hot9vtkEpmVgYb6nXrEw/Y5BeDCIQMP6GuPs7iIhfoBDWA1Z8C3AR vbIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iXUlPx96iTzc0B5krEAf8ul/voEG4A4R274p1SWOd+8=; b=cg4+SX9220PF5cJkPQZFmQ4Jf0Is3UoyI1GGmUVSdQbl7j4Ua/n2c1xhhJ0SHy7L2v s88kZIVprYR5NL6RGQmpZembiUB8/O1gyAESuDKZ731UFbMIFX9lzxb7v00JEgdf3p42 0ks9zrkZXT9mhtfoWVXjz3EdyTyqPK/SX4IdpybUK8ARllGSCdwOlxcT9aR+EWadWy1q 2vOsaceTbbYD8/bUCv1ym3c/JE3CQzXtHCNEBiSbpYF+pZVzYsKdsFiNagqY965s9eD1 LHP8o1Pt2OMYWd3IxU+w9QLHdLd3J3SMEPY95LMRzFIV4+6U4te6dcHirGmvI5Scu54K 5taw== X-Gm-Message-State: AD7BkJKWP3+z7klbxtIkly0Fa9gudUU2Mzx6epcy0H2FfmeBnpIj5pKSYs2IwZKI1m7l01wk X-Received: by 10.194.90.137 with SMTP id bw9mr3324066wjb.120.1457015260033; Thu, 03 Mar 2016 06:27:40 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id w17sm9244945wmw.5.2016.03.03.06.27.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Mar 2016 06:27:39 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Thu, 3 Mar 2016 15:27:13 +0100 Message-Id: <1457015237-2993-4-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457015237-2993-1-git-send-email-adrien.mazarguil@6wind.com> References: <1456165083-28316-1-git-send-email-adrien.mazarguil@6wind.com> <1457015237-2993-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH v3 3/7] mlx5: remove one indirection level from RX/TX functions 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: , X-List-Received-Date: Thu, 03 Mar 2016 14:27:40 -0000 From: Nelio Laranjeiro Avoid dereferencing pointers twice to get to fast Verbs functions by storing them directly in RX/TX queue structures. Signed-off-by: Nelio Laranjeiro Signed-off-by: Yaacov Hazan --- drivers/net/mlx5/Makefile | 1 + drivers/net/mlx5/mlx5_rxq.c | 16 ++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 34 +++++++++------------------------- drivers/net/mlx5/mlx5_rxtx.h | 23 +++++++++++++++++------ drivers/net/mlx5/mlx5_txq.c | 14 ++++++++++++++ 5 files changed, 57 insertions(+), 31 deletions(-) diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 46a17e0..39cdf2c 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -67,6 +67,7 @@ CFLAGS += -g CFLAGS += -I. CFLAGS += -D_XOPEN_SOURCE=600 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -Wno-strict-prototypes LDLIBS += -libverbs # A few warnings cannot be avoided in external headers. diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 573ad8f..55d002e 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -901,6 +901,8 @@ rxq_cleanup(struct rxq *rxq) rxq_free_elts_sp(rxq); else rxq_free_elts(rxq); + rxq->poll = NULL; + rxq->recv = NULL; if (rxq->if_wq != NULL) { assert(rxq->priv != NULL); assert(rxq->priv->ctx != NULL); @@ -1103,6 +1105,10 @@ rxq_rehash(struct rte_eth_dev *dev, struct rxq *rxq) err = EIO; goto error; } + if (tmpl.sp) + tmpl.recv = tmpl.if_wq->recv_sg_list; + else + tmpl.recv = tmpl.if_wq->recv_burst; error: *rxq = tmpl; assert(err >= 0); @@ -1345,6 +1351,16 @@ rxq_setup(struct rte_eth_dev *dev, struct rxq *rxq, uint16_t desc, *rxq = tmpl; DEBUG("%p: rxq updated with %p", (void *)rxq, (void *)&tmpl); assert(ret == 0); + /* Assign function in queue. */ +#ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS + rxq->poll = rxq->if_cq->poll_length_flags_cvlan; +#else /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ + rxq->poll = rxq->if_cq->poll_length_flags; +#endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ + if (rxq->sp) + rxq->recv = rxq->if_wq->recv_sg_list; + else + rxq->recv = rxq->if_wq->recv_burst; return 0; error: rxq_cleanup(&tmpl); diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index bee5ce2..63ddc53 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -93,7 +93,7 @@ txq_complete(struct txq *txq) DEBUG("%p: processing %u work requests completions", (void *)txq, elts_comp); #endif - wcs_n = txq->if_cq->poll_cnt(txq->cq, elts_comp); + wcs_n = txq->poll_cnt(txq->cq, elts_comp); if (unlikely(wcs_n == 0)) return 0; if (unlikely(wcs_n < 0)) { @@ -538,14 +538,14 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) /* Put packet into send queue. */ #if MLX5_PMD_MAX_INLINE > 0 if (length <= txq->max_inline) - err = txq->if_qp->send_pending_inline + err = txq->send_pending_inline (txq->qp, (void *)addr, length, send_flags); else #endif - err = txq->if_qp->send_pending + err = txq->send_pending (txq->qp, addr, length, @@ -567,7 +567,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) goto stop; RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf); /* Put SG list into send queue. */ - err = txq->if_qp->send_pending_sg_list + err = txq->send_pending_sg_list (txq->qp, sges, ret.num, @@ -599,7 +599,7 @@ stop: txq->stats.opackets += i; #endif /* Ring QP doorbell. */ - err = txq->if_qp->send_flush(txq->qp); + err = txq->send_flush(txq->qp); if (unlikely(err)) { /* A nonzero value is not supposed to be returned. * Nothing can be done about it. */ @@ -733,14 +733,7 @@ mlx5_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) /* Sanity checks. */ assert(elts_head < rxq->elts_n); assert(rxq->elts_head < rxq->elts_n); -#ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS - ret = rxq->if_cq->poll_length_flags_cvlan(rxq->cq, NULL, NULL, - &flags, &vlan_tci); -#else /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ - ret = rxq->if_cq->poll_length_flags(rxq->cq, NULL, NULL, - &flags); - (void)vlan_tci; -#endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ + ret = rxq->poll(rxq->cq, NULL, NULL, &flags, &vlan_tci); if (unlikely(ret < 0)) { struct ibv_wc wc; int wcs_n; @@ -877,9 +870,7 @@ mlx5_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) rxq->stats.ibytes += pkt_buf_len; #endif repost: - ret = rxq->if_wq->recv_sg_list(rxq->wq, - elt->sges, - RTE_DIM(elt->sges)); + ret = rxq->recv(rxq->wq, elt->sges, RTE_DIM(elt->sges)); if (unlikely(ret)) { /* Inability to repost WRs is fatal. */ DEBUG("%p: recv_sg_list(): failed (ret=%d)", @@ -950,14 +941,7 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) */ rte_prefetch0(seg); rte_prefetch0(&seg->cacheline1); -#ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS - ret = rxq->if_cq->poll_length_flags_cvlan(rxq->cq, NULL, NULL, - &flags, &vlan_tci); -#else /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ - ret = rxq->if_cq->poll_length_flags(rxq->cq, NULL, NULL, - &flags); - (void)vlan_tci; -#endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ + ret = rxq->poll(rxq->cq, NULL, NULL, &flags, &vlan_tci); if (unlikely(ret < 0)) { struct ibv_wc wc; int wcs_n; @@ -1049,7 +1033,7 @@ repost: #ifdef DEBUG_RECV DEBUG("%p: reposting %u WRs", (void *)rxq, i); #endif - ret = rxq->if_wq->recv_burst(rxq->wq, sges, i); + ret = rxq->recv(rxq->wq, sges, i); if (unlikely(ret)) { /* Inability to repost WRs is fatal. */ DEBUG("%p: recv_burst(): failed (ret=%d)", diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 4a857d8..b239ebf 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -107,12 +107,8 @@ struct rxq { struct rte_mempool *mp; /* Memory Pool for allocations. */ struct ibv_cq *cq; /* Completion Queue. */ struct ibv_exp_wq *wq; /* Work Queue. */ - struct ibv_exp_wq_family *if_wq; /* WQ burst interface. */ -#ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS - struct ibv_exp_cq_family_v1 *if_cq; /* CQ interface. */ -#else /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ - struct ibv_exp_cq_family *if_cq; /* CQ interface. */ -#endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ + int32_t (*poll)(); /* Verbs poll function. */ + int32_t (*recv)(); /* Verbs receive function. */ unsigned int port_id; /* Port ID for incoming packets. */ unsigned int elts_n; /* (*elts)[] length. */ unsigned int elts_head; /* Current index in (*elts)[]. */ @@ -130,6 +126,12 @@ struct rxq { struct ibv_exp_res_domain *rd; /* Resource Domain. */ struct fdir_queue fdir_queue; /* Flow director queue. */ struct ibv_mr *mr; /* Memory Region (for mp). */ + struct ibv_exp_wq_family *if_wq; /* WQ burst interface. */ +#ifdef HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS + struct ibv_exp_cq_family_v1 *if_cq; /* CQ interface. */ +#else /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ + struct ibv_exp_cq_family *if_cq; /* CQ interface. */ +#endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ }; /* Hash RX queue types. */ @@ -248,6 +250,15 @@ typedef uint8_t linear_t[16384]; /* TX queue descriptor. */ struct txq { struct priv *priv; /* Back pointer to private data. */ + int32_t (*poll_cnt)(struct ibv_cq *cq, uint32_t max); + int (*send_pending)(); +#if MLX5_PMD_MAX_INLINE > 0 + int (*send_pending_inline)(); +#endif +#if MLX5_PMD_SGE_WR_N > 1 + int (*send_pending_sg_list)(); +#endif + int (*send_flush)(struct ibv_qp *qp); struct ibv_cq *cq; /* Completion Queue. */ struct ibv_qp *qp; /* Queue Pair. */ struct txq_elt (*elts)[]; /* TX elements. */ diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 214a7c1..3364fca 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -187,6 +187,11 @@ txq_cleanup(struct txq *txq) DEBUG("cleaning up %p", (void *)txq); txq_free_elts(txq); + txq->poll_cnt = NULL; +#if MLX5_PMD_MAX_INLINE > 0 + txq->send_pending_inline = NULL; +#endif + txq->send_flush = NULL; if (txq->if_qp != NULL) { assert(txq->priv != NULL); assert(txq->priv->ctx != NULL); @@ -414,6 +419,15 @@ txq_setup(struct rte_eth_dev *dev, struct txq *txq, uint16_t desc, DEBUG("%p: cleaning-up old txq just in case", (void *)txq); txq_cleanup(txq); *txq = tmpl; + txq->poll_cnt = txq->if_cq->poll_cnt; +#if MLX5_PMD_MAX_INLINE > 0 + txq->send_pending_inline = txq->if_qp->send_pending_inline; +#endif +#if MLX5_PMD_SGE_WR_N > 1 + txq->send_pending_sg_list = txq->if_qp->send_pending_sg_list; +#endif + txq->send_pending = txq->if_qp->send_pending; + txq->send_flush = txq->if_qp->send_flush; DEBUG("%p: txq updated with %p", (void *)txq, (void *)&tmpl); /* Pre-register known mempools. */ rte_mempool_walk(txq_mp2mr_iter, txq); -- 2.1.4