From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 1C6921B6A2 for ; Wed, 4 Oct 2017 23:49:55 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Oct 2017 23:49:49 +0200 Received: from pegasus05.mtr.labs.mlnx (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v94LnnK2015910; Thu, 5 Oct 2017 00:49:49 +0300 Received: from pegasus05.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus05.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id v94Lnn6d031342; Wed, 4 Oct 2017 21:49:49 GMT Received: (from root@localhost) by pegasus05.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id v94Lnnnj031341; Wed, 4 Oct 2017 21:49:49 GMT From: Ophir Munk To: Adrien Mazarguil Cc: dev@dpdk.org, Thomas Monjalon , Olga Shern , Matan Azrad , Moti Haimovsky Date: Wed, 4 Oct 2017 21:49:06 +0000 Message-Id: <1507153746-31255-8-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1507153746-31255-1-git-send-email-ophirmu@mellanox.com> References: <1507027711-879-1-git-send-email-matan@mellanox.com> <1507153746-31255-1-git-send-email-ophirmu@mellanox.com> Subject: [dpdk-dev] [PATCH v3 7/7] net/mlx4: add loopback Tx from VF X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Oct 2017 21:49:55 -0000 From: Moti Haimovsky This patch adds loopback functionality used when the chip is a VF in order to enable packet transmission between VFs and between VFs and PF. Signed-off-by: Moti Haimovsky --- drivers/net/mlx4/mlx4_rxtx.c | 38 ++++++++++++++++++++++++++------------ drivers/net/mlx4/mlx4_rxtx.h | 2 ++ drivers/net/mlx4/mlx4_txq.c | 2 ++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index ca66b1d..87c4c38 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -321,10 +321,13 @@ struct pv { struct mlx4_wqe_data_seg *dseg; struct mlx4_sq *sq = &txq->msq; struct rte_mbuf *buf; + union { + uint32_t flags; + uint16_t flags16[2]; + } srcrb; uint32_t head_idx = sq->head & sq->txbb_cnt_mask; uint32_t lkey; uintptr_t addr; - uint32_t srcrb_flags; uint32_t owner_opcode = MLX4_OPCODE_SEND; uint32_t byte_count; int wqe_real_size; @@ -422,21 +425,15 @@ struct pv { /* Fill the control parameters for this packet. */ ctrl->fence_size = (wqe_real_size >> 4) & 0x3f; /* - * The caller should prepare "imm" in advance in order to support - * VF to VF communication (when the device is a virtual-function - * device (VF)). - */ - ctrl->imm = 0; - /* * For raw Ethernet, the SOLICIT flag is used to indicate that no icrc * should be calculated. */ txq->elts_comp_cd -= nr_txbbs; if (unlikely(txq->elts_comp_cd <= 0)) { txq->elts_comp_cd = txq->elts_comp_cd_init; - srcrb_flags = MLX4_WQE_CTRL_SOLICIT | MLX4_WQE_CTRL_CQ_UPDATE; + srcrb.flags = MLX4_WQE_CTRL_SOLICIT | MLX4_WQE_CTRL_CQ_UPDATE; } else { - srcrb_flags = MLX4_WQE_CTRL_SOLICIT; + srcrb.flags = MLX4_WQE_CTRL_SOLICIT; } /* Enable HW checksum offload if requested */ if (txq->csum && @@ -450,13 +447,30 @@ struct pv { owner_opcode |= MLX4_WQE_CTRL_IIP_HDR_CSUM | MLX4_WQE_CTRL_IL4_HDR_CSUM; if (pkt->ol_flags & PKT_TX_OUTER_IP_CKSUM) - srcrb_flags |= MLX4_WQE_CTRL_IP_HDR_CSUM; + srcrb.flags |= MLX4_WQE_CTRL_IP_HDR_CSUM; } else { - srcrb_flags |= MLX4_WQE_CTRL_IP_HDR_CSUM | + srcrb.flags |= MLX4_WQE_CTRL_IP_HDR_CSUM | MLX4_WQE_CTRL_TCP_UDP_CSUM; } } - ctrl->srcrb_flags = rte_cpu_to_be_32(srcrb_flags); + /* + * convert flags to BE before adding the mac address (if at all) + * to it + */ + srcrb.flags = rte_cpu_to_be_32(srcrb.flags); + if (txq->lb) { + /* + * Copy destination mac address to the wqe, + * this allows loopback in eSwitch, so that VFs and PF + * can communicate with each other. + */ + srcrb.flags16[0] = *(rte_pktmbuf_mtod(pkt, uint16_t *)); + ctrl->imm = *(rte_pktmbuf_mtod_offset(pkt, uint32_t *, + sizeof(uint16_t))); + } else { + ctrl->imm = 0; + } + ctrl->srcrb_flags = srcrb.flags; /* * Make sure descriptor is fully written before * setting ownership bit (because HW can start diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index 75c98c1..6f33d1c 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -114,6 +114,8 @@ struct txq { uint32_t max_inline; /**< Max inline send size. */ uint32_t csum:1; /**< Checksum is supported and enabled */ uint32_t csum_l2tun:1; /**< L2 tun Checksum is supported and enabled */ + uint32_t lb:1; + /**< Whether pkts should be looped-back by eswitch or not */ char *bounce_buf; /**< memory used for storing the first DWORD of data TXBBs. */ struct { diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index 4eb739c..8205647 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -415,6 +415,8 @@ struct txq_mp2mr_mbuf_check_data { (void *)dev, strerror(rte_errno)); goto error; } + /* If a VF device - need to loopback xmitted packets */ + tmpl.lb = !!(priv->vf); /* Clean up txq in case we're reinitializing it. */ DEBUG("%p: cleaning-up old txq just in case", (void *)txq); mlx4_txq_cleanup(txq); -- 1.8.3.1