From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by dpdk.org (Postfix) with ESMTP id 55DC8C3BC for ; Sat, 6 Jun 2015 01:16:07 +0200 (CEST) Received: by wibut5 with SMTP id ut5so34654533wib.1 for ; Fri, 05 Jun 2015 16:16:07 -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=InBm5nNq1huxYsEgmtpjAof7zfoxIjLvA246f5gZWTc=; b=YPwjbWbdm5PMWT8tf8FA2JH/pyfHBnM99iikUGqpYu1zK+Vx8kcEB3siBjLBodQOe2 hyGFqPiQZa6sDeGNut39u4YsQEsIC1kF8E6tqyyXmt00gXBALD4FSQyYt8AFww3+pFNZ wac9bd7w/84PN9SdC0Yo7sx4TuQsImZb5H0yC2bHweQiPNnMi+VA3YhJrUM9IcA/4rB9 +eEZz1VYh5Y4CFipFaWMdovxDhiK0cHGOWuNngB1V8F1Ba/QsRms6I2PS59W7lo6KRUr UZvvjFaVyP2FD6f4FRT4hBiRmdi8uCypHhH4gtxVg3WQG3UB6zm13mxCCM71YQfYt8Qh 6USA== X-Gm-Message-State: ALoCoQnYX+wxQ4Lm0lDVcMdd7n0O/h+h/xO9EpZ6Ozyw4vSQUAumOTmC7GwNBLAsnAfqjyG3IkVN X-Received: by 10.194.187.170 with SMTP id ft10mr10572539wjc.26.1433546167222; Fri, 05 Jun 2015 16:16:07 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id r9sm12607895wjo.26.2015.06.05.16.16.06 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 05 Jun 2015 16:16:06 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Sat, 6 Jun 2015 01:15:12 +0200 Message-Id: <1433546120-2254-9-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433546120-2254-1-git-send-email-adrien.mazarguil@6wind.com> References: <1433546120-2254-1-git-send-email-adrien.mazarguil@6wind.com> Cc: Alex Rosenbaum Subject: [dpdk-dev] [PATCH 08/16] 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: Fri, 05 Jun 2015 23:16:07 -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 061f5e6..080602e 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -208,6 +208,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. */ @@ -1651,6 +1652,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; @@ -1795,6 +1797,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; @@ -2376,6 +2379,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_exp_wc wcs[pkts_n]; struct ibv_recv_wr head; struct ibv_recv_wr **next = &head.next; @@ -2402,7 +2407,7 @@ mlx4_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) struct ibv_exp_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; @@ -2410,10 +2415,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; @@ -2522,6 +2532,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; @@ -2539,6 +2551,7 @@ repost: strerror(i)); abort(); } + rxq->elts_head = elts_head; #ifdef MLX4_PMD_SOFT_COUNTERS /* Increase packets counter. */ rxq->stats.ipackets += ret; @@ -2568,6 +2581,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_exp_wc wcs[pkts_n]; struct ibv_recv_wr head; struct ibv_recv_wr **next = &head.next; @@ -2592,7 +2607,7 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) struct ibv_exp_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 *)(elt->sge.addr - WR_ID(wr_id).offset); @@ -2603,6 +2618,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; @@ -2663,6 +2680,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; @@ -2680,6 +2699,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