From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 90D311B293 for ; Thu, 12 Oct 2017 14:30:35 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id k4so12913875wmc.1 for ; Thu, 12 Oct 2017 05:30:35 -0700 (PDT) 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=YjlLdwKTC10+luJCFlCUm5nW5KnXmHabkinc33QukhY=; b=C05fb6YoALNwAF54XNtAloC6Sco9OiSbsE4asCl3UW3GS41pbvNU5Eg4ybY7Q4LBxE q1wgJdYOiClSmL4+seeekK5xSmX7/fPCNPsZwUsNnymladCSlFGl4qZYxSCPs5WagWOm 3dzsDG7HyB+jXgV/dFmJcGSJ9KUYLFdEIboI2vQPK7QzgXIX5RqtshqIfGe5Q5PKobhG hv1VMl10lIM0G9x/VsExJGi4n9MPaAP61aMSnIi0HSaCYXw9Q/gWtaqRIpnIQ1IXiPox d5n3V2APcF2hD3HKEdG/p0SzZuz/YnoiMJxTRToAAdNwJLvp5bwc37iHZmlqfCL2KfqG zgLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YjlLdwKTC10+luJCFlCUm5nW5KnXmHabkinc33QukhY=; b=OZEYnGZ8ZaE0f8QWEVkhIPMrqHZAHx/aLKRqLNsbR/cxNepUImXMLgJ61oRK76ISWN Wrc30jOtNGAhRzbv7WbD6BahFLr1rzabp3XQDP6wxGCkn6tnPzkEjyOR0iUeMe+bNPXc kFk0mc4NeDPJhbQx4X30CIruh8HGlodcUJhS/5ecbpoq3uP0xjS13TGHg1vA0SE3qXvf AH4gV8mOqNQ9+fz+rsusm6hnPoYKvCR32PMjAmahVCOUzkSww8F3amsaG58EG/yP5SPj C/3At32L/gyLf01DqbvHO1r7G28TdQjeBFHhC0sjY0mW10MJQPNcte5ixw3xJgJzXYQ8 GMVg== X-Gm-Message-State: AMCzsaUDkR9b9/QXq1Vtsu7ST5dUDqNUmCfKiXjmorAtbEeJx/oYd0ao HD5Ee3GehSS8h2N9dYH0qRg4VdFx X-Google-Smtp-Source: AOwi7QCQnEMCTdDKkiTA25ZQm3n6opZYXCcynragzxKa60GT/qWB0BXldzszbP4ulY74ICUb7Z3nUA== X-Received: by 10.223.153.242 with SMTP id y105mr2259907wrb.126.1507811435251; Thu, 12 Oct 2017 05:30:35 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id b190sm167398wma.22.2017.10.12.05.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 05:30:34 -0700 (PDT) From: Adrien Mazarguil To: Ferruh Yigit Cc: dev@dpdk.org, Matan Azrad , Ophir Munk , Moti Haimovsky Date: Thu, 12 Oct 2017 14:30:00 +0200 Message-Id: <382e95434b631f40c81fda0764174ce8e166a99b.1507810956.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 5/5] 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: Thu, 12 Oct 2017 12:30:35 -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 PF. Signed-off-by: Moti Haimovsky Acked-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4_rxtx.c | 33 +++++++++++++++++++++------------ drivers/net/mlx4/mlx4_rxtx.h | 1 + drivers/net/mlx4/mlx4_txq.c | 2 ++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index 87c5261..36173ad 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -311,10 +311,13 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt) 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; @@ -414,22 +417,16 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt) /* 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 = RTE_BE32(MLX4_WQE_CTRL_SOLICIT | + srcrb.flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT | MLX4_WQE_CTRL_CQ_UPDATE); } else { - srcrb_flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT); + srcrb.flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT); } /* Enable HW checksum offload if requested */ if (txq->csum && @@ -443,14 +440,26 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt) 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 |= + srcrb.flags |= RTE_BE32(MLX4_WQE_CTRL_IP_HDR_CSUM); } else { - srcrb_flags |= RTE_BE32(MLX4_WQE_CTRL_IP_HDR_CSUM | + srcrb.flags |= RTE_BE32(MLX4_WQE_CTRL_IP_HDR_CSUM | MLX4_WQE_CTRL_TCP_UDP_CSUM); } } - ctrl->srcrb_flags = 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 51af69c..e10bbca 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -128,6 +128,7 @@ struct txq { uint32_t max_inline; /**< Max inline send size. */ uint32_t csum:1; /**< Enable checksum offloading. */ uint32_t csum_l2tun:1; /**< Same for L2 tunnels. */ + uint32_t lb:1; /**< Whether packets should be looped back by eSwitch. */ uint8_t *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 0e27df2..6d3dd78 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -278,6 +278,8 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, RTE_MIN(MLX4_PMD_TX_PER_COMP_REQ, desc / 4), .csum = priv->hw_csum, .csum_l2tun = priv->hw_csum_l2tun, + /* Enable Tx loopback for VF devices. */ + .lb = !!priv->vf, .bounce_buf = bounce_buf, }; txq->cq = ibv_create_cq(priv->ctx, desc, NULL, NULL, 0); -- 2.1.4