From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0084.outbound.protection.outlook.com [104.47.0.84]) by dpdk.org (Postfix) with ESMTP id 42CC41B37D for ; Tue, 3 Oct 2017 12:50:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LAZJwNhkqwVJv5gL8rF2HVeOiCbdtL51IFgyb6xmU9o=; b=NLTHJjLFalZdYP0QFabj6mur3dMmiDAdkGXpk3u5cemusMZj3kVEGIABiUR2dRDC+Ee+A7VTwzQzDREnQRUpjsVhqzQAGc6m3zYO6KMPL6+sceMd+tgmpUJ97LFHcgR/DaIcaW/0UzOkFAMDOdpzHvIjsoUt/V1J3bH/kTY+U5I= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM5PR0502MB3042.eurprd05.prod.outlook.com (2603:10a6:203:a1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Tue, 3 Oct 2017 10:50:10 +0000 From: Matan Azrad To: Adrien Mazarguil Cc: dev@dpdk.org, Moti Haimovsky Date: Tue, 3 Oct 2017 10:48:31 +0000 Message-Id: <1507027711-879-7-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1507027711-879-1-git-send-email-matan@mellanox.com> References: <1503590050-196143-1-git-send-email-motih@mellanox.com> <1507027711-879-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR09CA0085.eurprd09.prod.outlook.com (2603:10a6:7:3d::29) To AM5PR0502MB3042.eurprd05.prod.outlook.com (2603:10a6:203:a1::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d50854a-c0ac-488a-474b-08d50a4c8504 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:AM5PR0502MB3042; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 3:UALdMpvQmI6nSew6AMVLb5PqWwU2q1lIEbnuEohlLDQTPYhEBshmTqHc2y+QoL6265Et//KxTnx/6x6VfJPDkrTNggMmHZVwmXh2+cilE6rq/Q4o9IeetOYnftpWk3Wy0N3ghrAWxkSxLpybMAcvpKgxZ41QaQVsmM8he+x/bdxb9Ay6WMC+lLudEQP9eTOYIGuXkF2tA0PJP5aGOM+0UeVMlliwNst/2x00qEvZcwaJsgj0N0w51t30Ea6gGfc3; 25:vCnjWIDy1zGCFytAJrb2IyxwPYo9pnthyrrZW+pz94Z/+vy7zS57TirHNvEnhxb2Tu16hfkcbk0BVCN3mcoaKXnmN5Q9sfiILB3f1X2M2s4xZLzPMCI0SMgkB58Bl/Bv9TOsF1anstE4cbEqSn6pMXsnyxtPoEtG+E2zyI3OOuMIrf7Ci0FYNbd6Baf2JdaOlVbL62o7WUu2Sh7E5MJo/LM8cncfGS93bePM22kKcVuPt1049sK8KGo+LSVVJBfrW2zs9FGyy04fxexVYIK7gx7GkOZK9ODa3QADUyzchMV/vBNEFz+gURSeJ6dp7FFVwWQkYXgartu9LICtuzUNpQ==; 31:gkbmbIInq9KGlq3CXnPu5ovGpyori4NlRFp4Ogm2um7YJQOBZXy0aE2jrqVUvRPmJZ7tqMz42DSbdYUy9P3lJUjwHD81G37Cc2tq/0Ae/iYL+YJuKgNz3m6JraOS+cP/A6ivEFtCMspHLmw/YN5kspClwOMt5IShJQqm8WMR+3cFTthIB6+3mP/F6FU5JCJeNqknbwcSC4azfFWhv/BUeGP67ASxtqr5u9kdIBaAXXA= X-MS-TrafficTypeDiagnostic: AM5PR0502MB3042: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 20:xTU3wTx1w/Cag/OhEXq1pu5GxM3qcb25ZJtMAnKwZ0BwvnrxRfloGZ8j4TXoEReQHkmxxVqRZpTcAT9i7mfvqhJX5yf0oOi+MSwWH6CatDfYlVsFeEEo+1m+VyFJRFqDNBc4hpy8eLpXa0h9bGHT0bU5PreQVb8XTP6y2Ho9ucVG7n72lz0OmUXCiNFrU2j00InlN88Npd7icnWmtUfFSsX5GLiGEyy9L13XxPgzmykq+IRDPe9G1quKNM3hz39m8JXpdux8pcw76YSGwED+pVbsEs9NExy0+tWfBfc2q6VuvPuAXauu8LBya5YIfVPUct5xstOESakmIB5/Oiq/rwxjAjuMBDIEwvj07ohE6Oi7EK0qdwcJ21FEHb2e1EhilT9WukvWjCAReMdQNtdGcVrFeHLK6yIjWXeRlR/kmxdVNyPlQTSXsY0U6neHnLc/Unf66uu97w9ivAdt0MUrlpsrYVZ67wElMp7IhYzamtH2mVAKZlHwgSKaQW/gsYBX; 4:z1UIIDfNuA6LL1y42s/peQIPX5DWyx+R7gpLZXhwxrE4Qe3CoS77qMgR1GlAbLPhWNjuiEjUVlxVgyuQGA8phNOlcXcI9Z8T3k1TWEV6w2MCm1FsnEJs8fEYLoZVqdp4dUbXQj/KamqnL7Mdojhya9sXk1lLG0FTCD9eMn5en5OBcMU0aaU71a1HJkrtWz+M7KoOoJWOApS80WxjKunketOuw6Z9y+UXGhxUZHudghVUSB9JrnzsXpL5gzeeUWX3zcvqZo4z7RBdCb4LiDsRLDQD/zYiMoixEYh0XBOg2Gw= X-Exchange-Antispam-Report-Test: UriScan:(60795455431006); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM5PR0502MB3042; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM5PR0502MB3042; X-Forefront-PRVS: 044968D9E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(6009001)(376002)(346002)(189002)(199003)(33646002)(107886003)(5660300001)(55016002)(105586002)(47776003)(3846002)(53936002)(2906002)(66066001)(50986999)(76176999)(16586007)(86362001)(316002)(101416001)(81156014)(305945005)(8936002)(81166006)(8676002)(33026002)(50226002)(7736002)(16526017)(97736004)(48376002)(69596002)(25786009)(478600001)(50466002)(6116002)(4326008)(106356001)(5003940100001)(36756003)(6916009)(6666003)(4720700003)(21086003)(2950100002)(68736007)(189998001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0502MB3042; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0502MB3042; 23:AiYr3MkB3pD3P/ayPgcADGg9dz8YNwXhyBXOCA5?= =?us-ascii?Q?nbj6U+P3R6oO/ijsLgB8yaMU9o8EH8oWP55CMRT1/wArr3vYoYPP9IjObd4u?= =?us-ascii?Q?cgQjySUG9Aku5fsDixXm750/W3yYI/rek67H07yLaeS9j7Y6+HMzD2AYUFtt?= =?us-ascii?Q?Qw6AOswaAGYT5bjlN8c+xwnPbQA2jQUYGrizFtNmo6nKIhLjV0e5PpS7dOq6?= =?us-ascii?Q?j4tgZQxwYwHGR4I98E98x0BbHm2PXW3uffJful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DiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2017 10:50:10.0110 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0502MB3042 Subject: [dpdk-dev] [PATCH v2 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: Tue, 03 Oct 2017 10:50:12 -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 1e91aaf..85fb6d7 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -320,10 +320,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; @@ -421,21 +424,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 && @@ -449,13 +446,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 2d776eb..fd1dce0 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