From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0052.outbound.protection.outlook.com [104.47.0.52]) by dpdk.org (Postfix) with ESMTP id EAA007D63 for ; Thu, 24 Aug 2017 17:54:33 +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=vZ67tFr1pd2l+EOphjTgPDD3tQ4vuifz6I2RjY730cU=; b=mSx7vjTNT8U4IvaPN40VsFLQKxTjKLMI7mu3kXQjWN6Qi7yhMdQOueTDadv3poPV69PPM6Oku28nK1AtcXAjrP+5I3yIuHn1Ia9ZdhUY02c7ZK+by9u0RdDxO5laf/FtFLN6nSXQFAshB350vHCjaTHKp6873vRnluIuiKw2xtk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM4PR05MB1907.eurprd05.prod.outlook.com (2603:10a6:200:15::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Thu, 24 Aug 2017 15:54:31 +0000 From: Moti Haimovsky To: adrien.mazarguil@6wind.com Cc: dev@dpdk.org, Moti Haimovsky Date: Thu, 24 Aug 2017 18:54:10 +0300 Message-Id: <1503590050-196143-6-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1503590050-196143-1-git-send-email-motih@mellanox.com> References: <1503590050-196143-1-git-send-email-motih@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0302CA0006.eurprd03.prod.outlook.com (2603:10a6:800:e9::16) To AM4PR05MB1907.eurprd05.prod.outlook.com (2603:10a6:200:15::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f1b6294-654b-4c91-2341-08d4eb086968 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM4PR05MB1907; X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB1907; 3:xDBDeM9quGMC3rE7TTSazDVdvRXekR51cyedDwhbal93pLj9zPlbHZL+wMUQ/vtEb76hopPWYE77lgcmbTJJ5JCcGzyyqhb8sSiRGcbb5jEVXbkUSOnydZpUileFtbGW2947A+iV7LdWtwTzYSWPFsXSz6CQgC37cMdk4Aqf5nM5aEtgIWNpWRKftv2kP+q6xEc2HC5y1PD0uX539bra7xj9No1yP5hjfj6Pnym52I/rV/dryOIhq1+SEt09ymH8; 25:hoMTal4YsZzF3yCrkzf+FwBeWPnyBDVhry88LnVufJXqzd6lIbPZMM91h442tcZ8a4ftFcFCHrBICPmTvGo13YRC4b6YBDJD9b00X6KDMVVB8VUZnBC9UTbLaqPHdgPSFXupbmtRzMdlC3V5pZe4Ds+uAfUTbLnckEzp1vQIVPEbebIMWBWNJaxlrnTofRSpz02lP1s3ox4CM8jrxMYzQmFRKYP5cwLsN1XF0eSApRrPsOnThJ+3cLZCOXaP7Fggbokl22gn9H+Or/CxTRLwPTEx+lk3u3iFdiWf+hwqZSRzWqcItkZLMOvqpnNw3dLXR5/HvwiLWU5ffo1tzKkoog==; 31:cSDta61rJ1guGIqiFWsjkMnODLvJJc4/PmvVLkH+Be5OJu9fjmePdg8kuq27z+5BbYlXs2+JDCJLhqO7mss+l4SCLdiWbcgeW42mZC8k+LAhq0G01+IJtX1qKhq6chVw6JLredVSbnHVFrgY4ZT6JIByrIlS/+ez0DEqAzcHxtmj/dwV7e4QERX1wYKh4sa95UBr/l43pUdWK7GxF37bz0IlTzHFQiRxbzBXBda4adA= X-MS-TrafficTypeDiagnostic: AM4PR05MB1907: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB1907; 20:NTXzyI/S9spXIyZ1jXhtEQNFUE5JfwhgxCL2vEC0R1o9xOvnxtbXP870sbnISednGVo2dVqQX8WlNJ5gGFUgNALnxATStGxIoXJdvM/zhFUz+a3eoZIhSKW1XSdQ6s5dLA07jRIRT3Ov/EnnaguGj/j/K5glZTtDJDBparUsPykLPhPH9eP54v3TvHVa9Ns8BKTNt1AnCfJcK1u0vewmRPVoOMySnQWpU70H5acnCI4DIJrVzYf2XZieFyGOO+0ooxogVcaQdsnROTWngS2AeueK5u3d9PTWPxmmGvYT62l2LtWCBjHsQk8BMyyjdvhMZV3pjzdQaAz39WXxwBl1GAivKDy599qG3pVu0/wmW6JcMdlKwxQh87drft/oBMRcui6c6P0syMvWXxXOScVexvi9ZR4F9LmKWTKYrte9GSnUp7SXdf52A0VUQ3WGDl6ZL3HgtMiseqNw0gXSLK6xzyr+RKqy8walgxkeiWbxi+HtOB+Cz+HZw7pnjOm/42wE; 4:oZ3f+i9vGx/97mNbTP5DzWkj4KA7lGptHaLJmAMv7rbpw3nufuyCdedlR6IDIcBvj9stFPb8n0IRbXyj6aZzeioZMFLwJmx7MLKI6kX53xWHvjlEhaFiNF9Uz6G6rrajLPSQcPOOzaOG+JZXUt1wWl2INK8ydBtm3AXpRhKTngBiuPz8mvnoKFwv5vX1RW1mXUfRzHO28sgas6Gf8bPmNTyc1QFdbBndswc+Ybe9zYUeOoJBPCtfJlpZWxnGGBxVrXr/fdfjvnSC8PiFykxK8Ke5dxe48F3MesGkrW7cDbo= 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)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM4PR05MB1907; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM4PR05MB1907; X-Forefront-PRVS: 04097B7F7F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(199003)(189002)(66066001)(47776003)(5660300001)(50226002)(2361001)(50986999)(81166006)(8676002)(69596002)(33026002)(478600001)(105586002)(7736002)(42186005)(76176999)(106356001)(305945005)(33646002)(4326008)(81156014)(2906002)(2351001)(101416001)(21086003)(48376002)(25786009)(189998001)(2950100002)(4720700003)(86362001)(6916009)(55016002)(6666003)(53936002)(50466002)(107886003)(110136004)(7350300001)(6116002)(36756003)(5003940100001)(97736004)(3846002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB1907; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; AM4PR05MB1907; 23:Ubd1ldx0HC3DTDaHTqXB57O6aZyJ5Dixu4kEgXmer?= =?us-ascii?Q?hXtGEYlRPiMFeSIxjmmVrbpMdSzEhf3PEFNXG4rfFSnYQ9zUF4npPn3YbUFX?= =?us-ascii?Q?O2RY3TMx3uthTcAD//BtmlSJYRkfc/yk3/DbRLWKz9m0r3HBK+33m+jMmKvj?= =?us-ascii?Q?pm03RpWQJnsCfHP6WbZ9upYhuk1xz0+5p5Nh/ilB+aIgnxbMF7H3YJ7S4Y16?= =?us-ascii?Q?Q9JqJ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iagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2017 15:54:31.9749 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1907 Subject: [dpdk-dev] [PATCH 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, 24 Aug 2017 15:54:34 -0000 Added loopback functionality use 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_prm.h | 2 +- drivers/net/mlx4/mlx4_rxtx.c | 28 ++++++++++++++++++++++------ drivers/net/mlx4/mlx4_rxtx.h | 2 ++ drivers/net/mlx4/mlx4_txq.c | 2 ++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/net/mlx4/mlx4_prm.h b/drivers/net/mlx4/mlx4_prm.h index 38e9a45..e328cff 100644 --- a/drivers/net/mlx4/mlx4_prm.h +++ b/drivers/net/mlx4/mlx4_prm.h @@ -168,7 +168,7 @@ uint32_t srcrb_flags, uint32_t imm) { seg->fence_size = fence_size; - seg->srcrb_flags = rte_cpu_to_be_32(srcrb_flags); + seg->srcrb_flags = srcrb_flags; /* * The caller should prepare "imm" in advance based on WR opcode. * For IBV_WR_SEND_WITH_IMM and IBV_WR_RDMA_WRITE_WITH_IMM, diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index 3415f63..ed19c72 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -426,7 +426,11 @@ struct mlx4_wqe_data_seg *dseg; struct mlx4_sq *sq = &txq->msq; struct ibv_sge sge[wr->num_sge]; - uint32_t srcrb_flags; + union { + uint32_t flags; + uint16_t flags16[2]; + } srcrb; + uint32_t imm = 0; uint8_t fence_size; uint32_t head_idx = sq->head & sq->txbb_cnt_mask; uint32_t owner_opcode; @@ -466,10 +470,10 @@ /* Request Tx completion. */ txq->elts_comp_cd -= nr_txbbs; if (unlikely(txq->elts_comp_cd <= 0)) { - srcrb_flags = MLX4_WQE_CTRL_SOLICIT | MLX4_WQE_CTRL_CQ_UPDATE; + srcrb.flags = MLX4_WQE_CTRL_SOLICIT | MLX4_WQE_CTRL_CQ_UPDATE; txq->elts_comp_cd = txq->elts_comp_cd_init; } else { - srcrb_flags = MLX4_WQE_CTRL_SOLICIT; + srcrb.flags = MLX4_WQE_CTRL_SOLICIT; } fence_size = (wr->send_flags & IBV_SEND_FENCE ? MLX4_WQE_CTRL_FENCE : 0) | ((wqe_real_size / 16) & 0x3f); @@ -487,14 +491,26 @@ 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; } } + /* convert flags to BE before adding the mac address (if at all) + * to it + */ + srcrb.flags = rte_cpu_to_be_32(srcrb.flags); + /* Copy dst mac address to wqe. This allows loopback in eSwitch, + * so that VFs and PF can communicate with each other + */ + if (txq->lb) { + srcrb.flags16[0] = *(rte_pktmbuf_mtod(pkt, uint16_t *)); + imm = *(rte_pktmbuf_mtod_offset(pkt, uint32_t *, + sizeof(uint16_t))); + } /* fill in ctrl info but ownership */ - mlx4_set_ctrl_seg(ctrl, fence_size, srcrb_flags, 0); + mlx4_set_ctrl_seg(ctrl, fence_size, srcrb.flags, imm); /* If we used a bounce buffer then copy wqe back into sq */ if (unlikely(bounce)) ctrl = mlx4_bounce_to_desc(txq, head_idx, wqe_size); diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index b4675b7..8e407f5 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -148,6 +148,8 @@ struct txq { struct mlx4_cq mcq; /**< Info for directly manipulating the CQ. */ uint16_t tunnel_en:1; /* When set TX offload for tunneled packets are supported. */ + uint16_t lb:1; + /* Whether pkts should be looped-back by eswitch or not */ char *bounce_buf; /**< Side memory to be used when wqe wraps around */ }; diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index cecd5e8..296d72d 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -410,6 +410,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