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 0ABFB8E5A for ; Wed, 14 Sep 2016 13:54:35 +0200 (CEST) Received: by mail-wm0-f48.google.com with SMTP id 1so25924627wmz.1 for ; Wed, 14 Sep 2016 04:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:in-reply-to :references; bh=5gyxo94RJxVqE7jDFtfMQvl7jyHVko74EcNWPzPLGRw=; b=oaFnCTuYZww6lOqCKB7DrxAJBzZrr4zMh/b5cCQnMWxKe67VFeXkuKdcLNT7Xlxq7X 2TeVWltskCn4mSBRSqSxrOD3t2Op9c7eVZsiq7D59LegXHPyYNJvpe6rt7roxQQv9Ijt ZTRjPwt2ju37aWNCXPnMmnY/fuk3Tcj6/2i/acPdMe0IktYCLNXKQOtCI7HitpkuxK1Z uzRTXuADDm+h06HntG7PfRjR2q1wk3PD0vB0d5IrcE5AcOHUmIHEtSudCpXMILBHUt56 mT3LV+5ORBkl6HJwaN5CzqbfG28U+1MJo+u9I4IysEJAZZyJSaEKPyT/NZFLNRbIjGgI W6Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=5gyxo94RJxVqE7jDFtfMQvl7jyHVko74EcNWPzPLGRw=; b=B/5hyxFfjiOwUwplFRpJw/2tgNAN7vbWtcBqHc84G2OWfbM43JPyzYtp867dw/LzbY 04Y5Yb8CJ2aEUmfZk5ihL+WrcpW/T9GRocinNbIj2InrjfQmFdmHNbaHY0WBucyVtwBl YLqeIQONQDDxbtmlTn2EtlhTNYmqfHDs71zmlzLTHSa1q3ojVgFZyuGPZV/5xRcPNhWV FlaBgoUGPalrfxkG8g22mtj1UEnITaRngG2SXfzZ6w3kFhpzB1LXsL3JkT73r98KHa8H ASx9BmsIg7NJC1Ffq0qazhwdA3l3JdHpTEI0Hgst1dFAT9hMCN0BaI+TLkmCXDgwnVhv HEsg== X-Gm-Message-State: AE9vXwN4dU/vSE6FPpJOmMH+pePeCqZluGIELB2pvuVMT/7EmNvFXKDx/ygoVX87zfTcz+s+ X-Received: by 10.194.113.41 with SMTP id iv9mr2607441wjb.97.1473854074610; Wed, 14 Sep 2016 04:54:34 -0700 (PDT) Received: from ping.vm.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id m133sm10417332wmg.0.2016.09.14.04.54.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Sep 2016 04:54:34 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Date: Wed, 14 Sep 2016 13:53:54 +0200 Message-Id: <52dd465773598f4b98c066ed2074190dc3e440a3.1473851528.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH V2 7/8] net/mlx5: re-factorize 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: Wed, 14 Sep 2016 11:54:35 -0000 Rework logic of wqe_write() and wqe_write_vlan() which are pretty similar to keep a single one. Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_rxtx.c | 98 ++++++++++---------------------------------- 1 file changed, 22 insertions(+), 76 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 5c39cbb..c7e538f 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -293,8 +293,8 @@ txq_mp2mr(struct txq *txq, struct rte_mempool *mp) * Pointer to TX queue structure. * @param wqe * Pointer to the WQE to fill. - * @param addr - * Buffer data address. + * @param buf + * Buffer. * @param length * Packet length. * @param lkey @@ -302,54 +302,24 @@ txq_mp2mr(struct txq *txq, struct rte_mempool *mp) */ static inline void mlx5_wqe_write(struct txq *txq, volatile union mlx5_wqe *wqe, - uintptr_t addr, uint32_t length, uint32_t lkey) -{ - wqe->wqe.ctrl.data[0] = htonl((txq->wqe_ci << 8) | MLX5_OPCODE_SEND); - wqe->wqe.ctrl.data[1] = htonl((txq->qp_num_8s) | 4); - wqe->wqe.ctrl.data[2] = 0; - wqe->wqe.ctrl.data[3] = 0; - wqe->inl.eseg.rsvd0 = 0; - wqe->inl.eseg.rsvd1 = 0; - wqe->inl.eseg.mss = 0; - wqe->inl.eseg.rsvd2 = 0; - wqe->wqe.eseg.inline_hdr_sz = htons(MLX5_ETH_INLINE_HEADER_SIZE); - /* Copy the first 16 bytes into inline header. */ - rte_memcpy((uint8_t *)(uintptr_t)wqe->wqe.eseg.inline_hdr_start, - (uint8_t *)(uintptr_t)addr, - MLX5_ETH_INLINE_HEADER_SIZE); - addr += MLX5_ETH_INLINE_HEADER_SIZE; - length -= MLX5_ETH_INLINE_HEADER_SIZE; - /* Store remaining data in data segment. */ - wqe->wqe.dseg.byte_count = htonl(length); - wqe->wqe.dseg.lkey = lkey; - wqe->wqe.dseg.addr = htonll(addr); - /* Increment consumer index. */ - ++txq->wqe_ci; -} - -/** - * Write a regular WQE with VLAN. - * - * @param txq - * Pointer to TX queue structure. - * @param wqe - * Pointer to the WQE to fill. - * @param addr - * Buffer data address. - * @param length - * Packet length. - * @param lkey - * Memory region lkey. - * @param vlan_tci - * VLAN field to insert in packet. - */ -static inline void -mlx5_wqe_write_vlan(struct txq *txq, volatile union mlx5_wqe *wqe, - uintptr_t addr, uint32_t length, uint32_t lkey, - uint16_t vlan_tci) + struct rte_mbuf *buf, uint32_t length, uint32_t lkey) { - uint32_t vlan = htonl(0x81000000 | vlan_tci); - + uintptr_t addr = rte_pktmbuf_mtod(buf, uintptr_t); + + rte_mov16((uint8_t *)&wqe->wqe.eseg.inline_hdr_start, + (uint8_t *)addr); + addr += 16; + length -= 16; + /* Need to insert VLAN ? */ + if (buf->ol_flags & PKT_TX_VLAN_PKT) { + uint32_t vlan = htonl(0x81000000 | buf->vlan_tci); + + memcpy((uint8_t *)&wqe->wqe.eseg.inline_hdr_start + 12, + &vlan, sizeof(vlan)); + addr -= sizeof(vlan); + length += sizeof(vlan); + } + /* Write the WQE. */ wqe->wqe.ctrl.data[0] = htonl((txq->wqe_ci << 8) | MLX5_OPCODE_SEND); wqe->wqe.ctrl.data[1] = htonl((txq->qp_num_8s) | 4); wqe->wqe.ctrl.data[2] = 0; @@ -358,20 +328,7 @@ mlx5_wqe_write_vlan(struct txq *txq, volatile union mlx5_wqe *wqe, wqe->inl.eseg.rsvd1 = 0; wqe->inl.eseg.mss = 0; wqe->inl.eseg.rsvd2 = 0; - wqe->wqe.eseg.inline_hdr_sz = htons(MLX5_ETH_VLAN_INLINE_HEADER_SIZE); - /* - * Copy 12 bytes of source & destination MAC address. - * Copy 4 bytes of VLAN. - * Copy 2 bytes of Ether type. - */ - rte_memcpy((uint8_t *)(uintptr_t)wqe->wqe.eseg.inline_hdr_start, - (uint8_t *)(uintptr_t)addr, 12); - rte_memcpy((uint8_t *)((uintptr_t)wqe->wqe.eseg.inline_hdr_start + 12), - &vlan, sizeof(vlan)); - rte_memcpy((uint8_t *)((uintptr_t)wqe->wqe.eseg.inline_hdr_start + 16), - (uint8_t *)((uintptr_t)addr + 12), 2); - addr += MLX5_ETH_VLAN_INLINE_HEADER_SIZE - sizeof(vlan); - length -= MLX5_ETH_VLAN_INLINE_HEADER_SIZE - sizeof(vlan); + wqe->wqe.eseg.inline_hdr_sz = htons(16); /* Store remaining data in data segment. */ wqe->wqe.dseg.byte_count = htonl(length); wqe->wqe.dseg.lkey = lkey; @@ -612,7 +569,6 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) do { struct rte_mbuf *buf = *(pkts++); unsigned int elts_head_next; - uintptr_t addr; uint32_t length; uint32_t lkey; unsigned int segs_n = buf->nb_segs; @@ -634,8 +590,6 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) rte_prefetch0(wqe); if (pkts_n) rte_prefetch0(*pkts); - /* Retrieve buffer information. */ - addr = rte_pktmbuf_mtod(buf, uintptr_t); length = DATA_LEN(buf); /* Update element. */ (*txq->elts)[elts_head] = buf; @@ -645,11 +599,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) volatile void *)); /* Retrieve Memory Region key for this memory pool. */ lkey = txq_mp2mr(txq, txq_mb2mp(buf)); - if (buf->ol_flags & PKT_TX_VLAN_PKT) - mlx5_wqe_write_vlan(txq, wqe, addr, length, lkey, - buf->vlan_tci); - else - mlx5_wqe_write(txq, wqe, addr, length, lkey); + mlx5_wqe_write(txq, wqe, buf, length, lkey); /* Should we enable HW CKSUM offload */ if (buf->ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM)) { @@ -813,11 +763,7 @@ mlx5_tx_burst_inline(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) } else { /* Retrieve Memory Region key for this memory pool. */ lkey = txq_mp2mr(txq, txq_mb2mp(buf)); - if (buf->ol_flags & PKT_TX_VLAN_PKT) - mlx5_wqe_write_vlan(txq, wqe, addr, length, - lkey, buf->vlan_tci); - else - mlx5_wqe_write(txq, wqe, addr, length, lkey); + mlx5_wqe_write(txq, wqe, buf, length, lkey); } while (--segs_n) { /* -- 2.1.4