From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0061.outbound.protection.outlook.com [104.47.0.61]) by dpdk.org (Postfix) with ESMTP id D095D5F1B for ; Mon, 19 Mar 2018 17:37:02 +0100 (CET) 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=EvN1j9hUC8X7UV/fRJFUO4SLyQmCXaRAYL0zMrrwHko=; b=YOWThz763Wnz9ILK3/8Xo7dHlH+I9aPHSFwumH+ENRfIgSwoBukx1opEghIOGicd9g0eGB1hmkw1ggcPQuzxv3oNojRbHeI73IEc0dfxqPcbzFtlhoe5zhlOVbfn95g31x6WoNzFtgulZmku5ntSh7x6eD6lr80l+TyHrLERRyc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR0502MB3887.eurprd05.prod.outlook.com (2603:10a6:803:c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Mon, 19 Mar 2018 16:37:00 +0000 From: Ophir Munk To: dev@dpdk.org, Adrien Mazarguil Cc: Thomas Monjalon , Olga Shern , Ophir Munk , Shahaf shuler Date: Mon, 19 Mar 2018 16:36:50 +0000 Message-Id: <1521477410-8936-1-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1521450055-11523-1-git-send-email-ophirmu@mellanox.com> References: <1521450055-11523-1-git-send-email-ophirmu@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR0402CA0057.eurprd04.prod.outlook.com (2603:10a6:7:7c::46) To VI1PR0502MB3887.eurprd05.prod.outlook.com (2603:10a6:803:c::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a1f8b0be-063d-46d4-c893-08d58db7a44b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0502MB3887; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3887; 3:DKShg3WOtH0W0VwxQk5ZM+nHLjViIzOEoEO2kckJLKMJMjcfkNSYcOnK8Rvc+9hj3arfVoO4N1ubTS3eh1SRH1DMZav92vKiOHss0q8Qgtl8WFM0uliMhUfuPNgh56v0w6pUNM88aWhuYL/hWRyq/JqHVZJRSjcx27obxubtzwlgtuxa0/nhMFT7nidmIUIJVOxJGmxMM0gIoqakm4bRdocEvxnhW0rMfVeZI8R1mlALhLBjGno3eb23768auJAh; 25:eJSEz1DTZyF5cCnksWbrxPBAgvM+TzKf6kiDuXLH5uvCT7B8DrVH9C9GJk5qc+J0NDAes7y8NxDlYAUERiWUEIjFe7hz2gbSDBg/euVWGFUrYKh2CiiQnjJ2SSxQbX+DRKDQnA7hxB1xaqbx6TURWQx+ixf38Egxf1QPxGGx+07QrsufTXKc9M4a+M7CVfQiCQt/G4XKyX3pJWqJMVzXpV1OxChK6KTNqTXXzt5xp1wxUbxGLNhwsq7FWmKbGong8diXLuJrG/B/WNzOE6Z6ImkkP1/5quos7cvPDFvP81BHbvFBbkDiEMkcZGEOD+3qXZBf5nIxdkiQ/aFg2b22TQ==; 31:g+MS4JkT+wrIZT341D6sKJrq+YuOKKCIFQzfrI3I5pZL7whumgd3q8ZTzEI7qAXfSFlyhk6nvStQCV4qeyeED6R++k6vssxOJKqM/d2kWl5TKsb+ONZUYecQFREE1fsPnhB7252FYJ6swr3Qybk43vqnUw6PV6acnHbjfzcE5DPLzadSohGWPP9xkdrUNi1ZU0NehNXDkXAKkO67igcK2TqjHbxNpDBBR/pUVNGL/UE= X-MS-TrafficTypeDiagnostic: VI1PR0502MB3887: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3887; 20:rcJStuCt55FaF6TwyFyYFW6zXd1BkuObJwPOhTK7RhGMnKeI4d4lo0Tz3cbVH23pTqGzR8MaSx4Cov3YwwUN5O2HF/GY621ydaX/dmuKLfwxOkE6IR7iwRgKToPtq4V/w3DJpDM/ZRI6kNqGmHTlR7uzo0+NR0BpteX+NSUW2YaqwaS/8HZVZTECQdZtabgMw54Jiy9NoMd260AOUGnWAbIu783TgyZCO9aZxY98BKhXXQxe2H3Y4ibzqSkgeZhLxRdSYA9IiQt9bJwNSw4f80zhf6kRNR2/HQxew/sv3pRrnX1mQphkWawwf1R3QcNqgNbI+iJjyESvyRLY32xIjT92CPUxOWUUlxa7z0nuDlLjuUGnIU3V4DwP4u5C69pu2ZcQZo9evJ2S3/2IB/od/us/Rln61ECueLPzHGEpQeeOFHWvpClPAEBLJI7XUV/hAztaEq9ov5eXJwwW9o9YeWaaBzFDSo2jNzrhjy2s2ubx3Nqs4lSKygh49FPbCl2B; 4:Ai4aSHyBCVLjWl7iZDnuqVJdBhT4MN04LHwpczajCBYlkTYI09TYwX4Mq+RNNNamw6Ss+s0GybFO3Ot68ry58pKVncCP/UW4wZPiZSjF67uU1UbH988mOt+Hp16hZk0zuG7UCbEr4R/N63SN8uTSvDiEca0UaJ0iG4zaadBt1qJNgKNWtYB8Foxlt7Osm1rV9NQ3gP26ofKMbxL7bf6xsAvjsMBmzre20pt/bay2SenoOdzIPQrlc7rYlBPnZGb+0dVjZ0QoQrbQUOgGgttmtw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231221)(944501244)(52105095)(10201501046)(6055026)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:VI1PR0502MB3887; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0502MB3887; X-Forefront-PRVS: 06167FAD59 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39380400002)(39860400002)(346002)(396003)(366004)(189003)(199004)(33026002)(53936002)(86362001)(68736007)(105586002)(2906002)(107886003)(26005)(48376002)(305945005)(50466002)(5660300001)(7736002)(21086003)(478600001)(50226002)(81166006)(81156014)(5890100001)(8676002)(8936002)(69596002)(55016002)(6916009)(4720700003)(66066001)(36756003)(59450400001)(6666003)(16586007)(386003)(3846002)(7696005)(52116002)(51416003)(76176011)(47776003)(106356001)(186003)(25786009)(16526019)(4326008)(316002)(97736004)(2950100002)(6116002)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3887; 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; VI1PR0502MB3887; 23:pViA+NiH2+kVCNpT65+CT04RHiyyak+Km/Ov1EY?= =?us-ascii?Q?6l/CYedr91+rzSswQeTXT9ubob243nLY/BJ9rH2VHUGg8ZPv/HWtOg78olZg?= =?us-ascii?Q?pBwtMnhN637MdYvRhzBpUl88gy69rNQn8fqXn6jUpJDdrH6Qj55ACRVLNSLY?= =?us-ascii?Q?XxM1hCcJtWdeMJu7Kpzjuvj+WmcFBHqWAwbPCa7TQ1jbnMKSR+wx+CsQXOPO?= =?us-ascii?Q?OePLko0WcfiDTLHQ+uFOjEDswwrIWiqTUVylLUKCsrG7d0Yk19aKJcuQLdL5?= =?us-ascii?Q?PUzLGUrIKMO2aMFvyXAdgfYfhPwsGBddQLgPujOmQGjs/JfOYz2DiOfs8QRi?= =?us-ascii?Q?cFXKgvvUBavfApojRqmpGV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wX8gr909xgjufOB1oZN7mjnLU8nepyKhOv+zkUGL6n4Dhpkv0DhXRpj4IB+hoPjvUbiclDJ6la0buEOPw1hyJxq/4ZySg+5uKUpjk6LxyUz65HEjplHI1zdErOhaMgUzbLXzF+BL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2018 16:37:00.3692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1f8b0be-063d-46d4-c893-08d58db7a44b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3887 Subject: [dpdk-dev] [PATCH v2] net/mlx4: support CRC strip toggling 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: Mon, 19 Mar 2018 16:37:03 -0000 Previous to this commit mlx4 CRC stripping was executed by default and there was no verbs API to disable it. Current support in MLNX_OFED_4.3-1.5.0.0 and above Signed-off-by: Ophir Munk --- v1: initial version v2: following internal reviews drivers/net/mlx4/mlx4.c | 4 ++++ drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/mlx4_rxq.c | 33 +++++++++++++++++++++++++++++++-- drivers/net/mlx4/mlx4_rxtx.c | 5 ++++- drivers/net/mlx4/mlx4_rxtx.h | 1 + 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index ee93daf..d4f4323 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -578,6 +578,10 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) } DEBUG("supported RSS hash fields mask: %016" PRIx64, priv->hw_rss_sup); + priv->hw_fcs_strip = !!(device_attr_ex.raw_packet_caps & + IBV_RAW_PACKET_CAP_SCATTER_FCS); + DEBUG("FCS stripping toggling is %ssupported", + (priv->hw_fcs_strip ? "" : "not ")); /* Configure the first MAC address by default. */ if (mlx4_get_mac(priv, &mac.addr_bytes)) { ERROR("cannot get MAC address, is mlx4_en loaded?" diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 19c8a22..3ae3ce6 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -105,6 +105,7 @@ struct priv { uint32_t isolated:1; /**< Toggle isolated mode. */ uint32_t hw_csum:1; /**< Checksum offload is supported. */ uint32_t hw_csum_l2tun:1; /**< Checksum support for L2 tunnels. */ + uint32_t hw_fcs_strip:1; /**< FCS stripping toggling is supported. */ uint64_t hw_rss_sup; /**< Supported RSS hash fields (Verbs format). */ struct rte_intr_handle intr_handle; /**< Port interrupt handle. */ struct mlx4_drop *drop; /**< Shared resources for drop flow rules. */ diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 7a036ed..6748355 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -491,6 +491,8 @@ mlx4_rxq_attach(struct rxq *rxq) const char *msg; struct ibv_cq *cq = NULL; struct ibv_wq *wq = NULL; + unsigned int create_flags = 0; + unsigned int comp_mask = 0; volatile struct mlx4_wqe_data_seg (*wqes)[]; unsigned int i; int ret; @@ -503,6 +505,11 @@ mlx4_rxq_attach(struct rxq *rxq) msg = "CQ creation failure"; goto error; } + /* By default, FCS (CRC) is stripped by hardware. */ + if (rxq->crc_present) { + create_flags |= IBV_WQ_FLAGS_SCATTER_FCS; + comp_mask |= IBV_WQ_INIT_ATTR_FLAGS; + } wq = mlx4_glue->create_wq (priv->ctx, &(struct ibv_wq_init_attr){ @@ -511,6 +518,8 @@ mlx4_rxq_attach(struct rxq *rxq) .max_sge = sges_n, .pd = priv->pd, .cq = cq, + .comp_mask = comp_mask, + .create_flags = create_flags, }); if (!wq) { ret = errno ? errno : EINVAL; @@ -649,9 +658,10 @@ mlx4_rxq_detach(struct rxq *rxq) uint64_t mlx4_get_rx_queue_offloads(struct priv *priv) { - uint64_t offloads = DEV_RX_OFFLOAD_SCATTER | - DEV_RX_OFFLOAD_CRC_STRIP; + uint64_t offloads = DEV_RX_OFFLOAD_SCATTER; + if (priv->hw_fcs_strip) + offloads |= DEV_RX_OFFLOAD_CRC_STRIP; if (priv->hw_csum) offloads |= DEV_RX_OFFLOAD_CHECKSUM; return offloads; @@ -781,6 +791,24 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, (void *)dev, idx); return -rte_errno; } + /* By default, FCS (CRC) is stripped by hardware. */ + unsigned char crc_present; + if (conf->offloads & DEV_RX_OFFLOAD_CRC_STRIP) { + crc_present = 0; + } else if (priv->hw_fcs_strip) { + crc_present = 1; + } else { + WARN("%p: CRC stripping has been disabled but will still" + " be performed by hardware, make sure MLNX_OFED and" + " firmware are up to date", + (void *)dev); + crc_present = 0; + } + DEBUG("%p: CRC stripping is %s, %u bytes will be subtracted from" + " incoming frames to hide it", + (void *)dev, + crc_present ? "disabled" : "enabled", + crc_present << 2); *rxq = (struct rxq){ .priv = priv, .mp = mp, @@ -794,6 +822,7 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, .csum_l2tun = priv->hw_csum_l2tun && (conf->offloads & DEV_RX_OFFLOAD_CHECKSUM), .l2tun_offload = priv->hw_csum_l2tun, + .crc_present = crc_present, .stats = { .idx = idx, }, diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index 8ca8b77..84a7bf1 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -934,12 +934,12 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) goto skip; } pkt = seg; + assert(len >= (rxq->crc_present << 2)); /* Update packet information. */ pkt->packet_type = rxq_cq_to_pkt_type(cqe, rxq->l2tun_offload); pkt->ol_flags = PKT_RX_RSS_HASH; pkt->hash.rss = cqe->immed_rss_invalid; - pkt->pkt_len = len; if (rxq->csum | rxq->csum_l2tun) { uint32_t flags = mlx4_cqe_flags(cqe, @@ -951,6 +951,9 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) rxq->csum, rxq->csum_l2tun); } + if (rxq->crc_present) + len -= ETHER_CRC_LEN; + pkt->pkt_len = len; } rep->nb_segs = 1; rep->port = rxq->port_id; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index c12bd39..a0633bf 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -52,6 +52,7 @@ struct rxq { volatile uint32_t *rq_db; /**< RQ doorbell record. */ uint32_t csum:1; /**< Enable checksum offloading. */ uint32_t csum_l2tun:1; /**< Same for L2 tunnels. */ + uint32_t crc_present:1; /**< CRC must be subtracted. */ uint32_t l2tun_offload:1; /**< L2 tunnel offload is enabled. */ struct mlx4_cq mcq; /**< Info for directly manipulating the CQ. */ struct mlx4_rxq_stats stats; /**< Rx queue counters. */ -- 2.7.4