From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id C58E61B6DF for ; Wed, 4 Oct 2017 20:49:23 +0200 (CEST) Received: by mail-wm0-f41.google.com with SMTP id i124so24982418wmf.3 for ; Wed, 04 Oct 2017 11:49:23 -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=Vst3bLdekAlIxg5wo61Jb06Q/OUzopSPXMZwH5Yzdcw=; b=T522g5BFQb4t1qIFPGiks3mxlt9hWExQaHWswHv0HIDEmzMiiV6lVWMKtUh7kdotZ0 KYAHq7MIbVzTy93/VkFVXOUbBFOjKRr7ZdginzQ+CqxnAuADEC9RQXc3955y7+/uRvDi GrEAb/RQPPMAZ0oVayPiPctfREjytPBEzsGNgOcECRRdP4lQBByry9tAOVPM77xMh0do UlUAIz+pdPE3ZJ63y7hkwo6p6/pya95bJduKgkoiBMcxaNuTn5uXxG7RrkIR39+WcZf3 b1EfqlVaiSI+amksuRlnnvvYvmtQn6df31OtUYG9fqQvgWdBZ4ubcda2nh+jm2/zx/fG W35Q== 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=Vst3bLdekAlIxg5wo61Jb06Q/OUzopSPXMZwH5Yzdcw=; b=r0/PkyTXVSzoSxJD7xPQU2GzihMDUr6QzHIcDEDejAf+IOjBlJWaCrLRl6sUwfKZQh 7UNiax0UPOrVQ4MPhE0RpbQg3VOVkS++2LhZGa1fFW+DRVuAkoQSgtCzYyGcw+eIElQf sBs0KGNqOhwFQCEnY1C/Fme9Dwg8u5n8BvwqLIFesk3HHURl+QroA8xJl+Ne+j6grmhI gPrJwgb0FXwVeZCRwpDh2dRI/keTS73G7GIatVg0s3PPGJwPaTmla9DudCXKla2lc4uh g5fwhsn98hAOjfRjoxpanFtlZ/A/O+ZmcGATjPr1uMAB9a91hvlBG6ZbipPwwWbfcLYe 1niA== X-Gm-Message-State: AMCzsaVk/Mxoq7vz+b6pyVrCk5Utf7p1JrWRrQK6+rep6qxAmBeSFhQ+ LjoHqJYRVNjggJIXJy+r8NE0eMQR X-Google-Smtp-Source: AOwi7QC1cu5TyU79mhW+zkHb9GlFtM1F+WPFZSuFcY77LAVokNiSS3LbqE5tXkKFdz2fzIjeDfd5/Q== X-Received: by 10.80.182.146 with SMTP id d18mr3175326ede.131.1507142963283; Wed, 04 Oct 2017 11:49:23 -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 p45sm8483367edc.30.2017.10.04.11.49.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 11:49:22 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Cc: Moti Haimovsky , Matan Azrad Date: Wed, 4 Oct 2017 20:48:58 +0200 Message-Id: <3327a0e35529a430e5244a78be675ef7022e5e9c.1507141616.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1507027711-879-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH v3 6/6] 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 18:49:24 -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 6aad41a..37f31f4 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -112,6 +112,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 96429bc..9d1be95 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -412,6 +412,8 @@ mlx4_txq_setup(struct rte_eth_dev *dev, struct txq *txq, uint16_t desc, (void *)dev, strerror(rte_errno)); goto error; } + /* Enable Tx loopback for VF devices. */ + 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); -- 2.1.4