From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by dpdk.org (Postfix) with ESMTP id DE490C364 for ; Tue, 30 Jun 2015 11:28:32 +0200 (CEST) Received: by wicgi11 with SMTP id gi11so10686734wic.0 for ; Tue, 30 Jun 2015 02:28:31 -0700 (PDT) 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=gGgEBBGs1KC1iwx0UuW38ZyB1eGURz4+BcS1ayiJNfU=; b=de9ca1PgweujLnI/EsHCQ+nDtr9aiBvb1xOqCZC76f4O0woM90/ndRF9zIcY9gjsoq RHG0zG+11rKdnJcsKS6Xv/Kkeanxv7BiekDL//rARGUj+TlJqk/d8nSd1nNh2uBgHpFw vDtK/es1/4k+KJstQJ4QvIc3sQDn0ncut1dka6ujdiq9VDlDtPmiwUplo8fq9uPs8Ha/ LdfB7EGLYlUlejTTgOwlNL0sh61OSmOB4cCv4JacQ5eFfTsMFRe3419ES2C+5Sro6ZL5 3VydMCQx+s9STpeBvh7esVJjF7oSJHTb6MbaZE6LRV7QWUttwVDC0F6xhcwHEGaxtmzM BoCw== X-Gm-Message-State: ALoCoQnnzYHKRBuOlYzvEHj0xGNt1e6H+mBExtfjHX1OSmODejTyaZMJwpnwpckRDV9Q7Up1FkZ0 X-Received: by 10.194.243.230 with SMTP id xb6mr37520636wjc.13.1435656511586; Tue, 30 Jun 2015 02:28:31 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.151.210]) by mx.google.com with ESMTPSA id v3sm16132206wiz.14.2015.06.30.02.28.30 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 30 Jun 2015 02:28:30 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 30 Jun 2015 11:27:50 +0200 Message-Id: <1435656489-27986-5-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1435656489-27986-1-git-send-email-adrien.mazarguil@6wind.com> References: <1433546120-2254-1-git-send-email-adrien.mazarguil@6wind.com> <1435656489-27986-1-git-send-email-adrien.mazarguil@6wind.com> Cc: Alex Rosenbaum Subject: [dpdk-dev] [PATCH v2 04/23] mlx4: avoid looking up WR ID to improve RX performance 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: Tue, 30 Jun 2015 09:28:33 -0000 From: Alex Rosenbaum This is done by storing the current index in the RX queue structure. Signed-off-by: Alex Rosenbaum Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index bd20569..08b1b81 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -200,6 +200,7 @@ struct rxq { struct ibv_exp_flow *allmulti_flow; /* Multicast flow. */ unsigned int port_id; /* Port ID for incoming packets. */ unsigned int elts_n; /* (*elts)[] length. */ + unsigned int elts_head; /* Current index in (*elts)[]. */ union { struct rxq_elt_sp (*sp)[]; /* Scattered RX elements. */ struct rxq_elt (*no_sp)[]; /* RX elements. */ @@ -1640,6 +1641,7 @@ rxq_alloc_elts_sp(struct rxq *rxq, unsigned int elts_n, DEBUG("%p: allocated and configured %u WRs (%zu segments)", (void *)rxq, elts_n, (elts_n * elemof((*elts)[0].sges))); rxq->elts_n = elts_n; + rxq->elts_head = 0; rxq->elts.sp = elts; assert(ret == 0); return 0; @@ -1785,6 +1787,7 @@ rxq_alloc_elts(struct rxq *rxq, unsigned int elts_n, struct rte_mbuf **pool) DEBUG("%p: allocated and configured %u single-segment WRs", (void *)rxq, elts_n); rxq->elts_n = elts_n; + rxq->elts_head = 0; rxq->elts.no_sp = elts; assert(ret == 0); return 0; @@ -2320,6 +2323,8 @@ mlx4_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) { struct rxq *rxq = (struct rxq *)dpdk_rxq; struct rxq_elt_sp (*elts)[rxq->elts_n] = rxq->elts.sp; + const unsigned int elts_n = rxq->elts_n; + unsigned int elts_head = rxq->elts_head; struct ibv_wc wcs[pkts_n]; struct ibv_recv_wr head; struct ibv_recv_wr **next = &head.next; @@ -2346,7 +2351,7 @@ mlx4_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) struct ibv_wc *wc = &wcs[i]; uint64_t wr_id = wc->wr_id; uint32_t len = wc->byte_len; - struct rxq_elt_sp *elt = &(*elts)[wr_id]; + struct rxq_elt_sp *elt = &(*elts)[elts_head]; struct ibv_recv_wr *wr = &elt->wr; struct rte_mbuf *pkt_buf = NULL; /* Buffer returned in pkts. */ struct rte_mbuf **pkt_buf_next = &pkt_buf; @@ -2354,10 +2359,15 @@ mlx4_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) unsigned int j = 0; /* Sanity checks. */ +#ifdef NDEBUG + (void)wr_id; +#endif assert(wr_id < rxq->elts_n); assert(wr_id == wr->wr_id); assert(wr->sg_list == elt->sges); assert(wr->num_sge == elemof(elt->sges)); + assert(elts_head < rxq->elts_n); + assert(rxq->elts_head < rxq->elts_n); /* Link completed WRs together for repost. */ *next = wr; next = &wr->next; @@ -2468,6 +2478,8 @@ mlx4_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) rxq->stats.ibytes += wc->byte_len; #endif repost: + if (++elts_head >= elts_n) + elts_head = 0; continue; } *next = NULL; @@ -2485,6 +2497,7 @@ repost: strerror(i)); abort(); } + rxq->elts_head = elts_head; #ifdef MLX4_PMD_SOFT_COUNTERS /* Increase packets counter. */ rxq->stats.ipackets += ret; @@ -2514,6 +2527,8 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) { struct rxq *rxq = (struct rxq *)dpdk_rxq; struct rxq_elt (*elts)[rxq->elts_n] = rxq->elts.no_sp; + const unsigned int elts_n = rxq->elts_n; + unsigned int elts_head = rxq->elts_head; struct ibv_wc wcs[pkts_n]; struct ibv_recv_wr head; struct ibv_recv_wr **next = &head.next; @@ -2538,7 +2553,7 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) struct ibv_wc *wc = &wcs[i]; uint64_t wr_id = wc->wr_id; uint32_t len = wc->byte_len; - struct rxq_elt *elt = &(*elts)[WR_ID(wr_id).id]; + struct rxq_elt *elt = &(*elts)[elts_head]; struct ibv_recv_wr *wr = &elt->wr; struct rte_mbuf *seg = (void *)((uintptr_t)elt->sge.addr - WR_ID(wr_id).offset); @@ -2549,6 +2564,8 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) assert(wr_id == wr->wr_id); assert(wr->sg_list == &elt->sge); assert(wr->num_sge == 1); + assert(elts_head < rxq->elts_n); + assert(rxq->elts_head < rxq->elts_n); /* Link completed WRs together for repost. */ *next = wr; next = &wr->next; @@ -2609,6 +2626,8 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) rxq->stats.ibytes += wc->byte_len; #endif repost: + if (++elts_head >= elts_n) + elts_head = 0; continue; } *next = NULL; @@ -2626,6 +2645,7 @@ repost: strerror(i)); abort(); } + rxq->elts_head = elts_head; #ifdef MLX4_PMD_SOFT_COUNTERS /* Increase packets counter. */ rxq->stats.ipackets += ret; -- 2.1.0