From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30042.outbound.protection.outlook.com [40.107.3.42]) by dpdk.org (Postfix) with ESMTP id 5B23D5F34 for ; Mon, 19 Mar 2018 10:01:09 +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=nF6APo+AzprWM9+GJTwksWt1Gf5E9JLPibZLPlN54wU=; b=xWL7eOAb11Pk2H8na6MT6QQisJFkQgee8/rDf90SJLx0PMYZtjYaiRbwWedtTwOhq8cLkZLQT/yWbxqsR/2Psx/59qJ3hRdDs1PprdkweRR0EiEuIwYZD6PRGHp5hFJ9gXxCavjzQgM1a9pRQIgBqFCcc6T1qr7+mZsIJ5VfN5k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR0502MB3882.eurprd05.prod.outlook.com (2603:10a6:7:87::25) 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 09:01:05 +0000 From: Ophir Munk To: dev@dpdk.org, Adrien Mazarguil Cc: Thomas Monjalon , Olga Shern , Ophir Munk Date: Mon, 19 Mar 2018 09:00:55 +0000 Message-Id: <1521450055-11523-1-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: AM5PR0701CA0016.eurprd07.prod.outlook.com (2603:10a6:203:51::26) To HE1PR0502MB3882.eurprd05.prod.outlook.com (2603:10a6:7:87::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 72fc7961-0152-4904-0dce-08d58d77f334 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0502MB3882; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3882; 3:vMp7N3IZ3kZhv9M2317xO+qXRX2KNRiSiRN+gKWrqQbQ7uKPwB1/fQhdmsM3Os68ckk1MVu3EHupabE2zShhn2hzB6zvoSMA4pIUApPN+xAo1r3bkfo1SchQsNDV8avsPEx0bQAaPkNRemUw+j7OHeUIyedHtle0Y0E1uYXxAZ9MeAr0uCxPeVThirckFnGwrin0ghidSVYy02KPUQQUPtRoEhQeJ/rMAGwS4SrpC4sgOIb31luF7Y5aW6OGTA3q; 25:UmdhupdQrxlmRm7RJXiuxth0SbsrpUTUu2eoHm3RSJL9+DLbUsJk+5+nH7W7e0cVFcP5aBzxrJtTK4VMwSqP57sLIqWdcYMkSXjyRwFsoJqZzvYlIuIxaLCbbZ3n4WSnu61DnzN2EzcnYPQHgqgT3+sOZJs9VX03zKPdlY+z2zKfP03shOL8dGK7cwGvC4EZH4Y5Uj9QOxWnEY7qr0KvYSqU6ja0YARpkxVvifthT2w+Y87n4MC5l8rj6FIcSVA9KVI9d59iHTNzl/yyQ4yWRfysCFcCVdIugXHdSjuTixSNlbTHNy/2EaI29waPRP+kzS5ZKamH/hwPPCjQqb9YIw==; 31:3OpCUEdRBhQa4W5VsECzmdwsTrV1zLZyg6NjbTZ85fbpKqKJzU7RZCDw2SU6Uqc6dWXkt0HZatq6kkeIuPESTmsgaWrtDxoXHpO/0ivOwmJKN/f4zq+Mxo1KhFnVJyIYKR6DD3fkNPnuTRw4VAoquihFgGJH3jJJLjy/zqoZPJGEl6dmiJhZqpnSZtmhqR65UZF2zJmv0fhEY8XiYo7gDBqYfkqhK4vBiuHDMLKAMtA= X-MS-TrafficTypeDiagnostic: HE1PR0502MB3882: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3882; 20:m4cMfywlGyKq67u6SyRmIWTBNFpyAo2v/sz7cWeWYQGf2spQLMG5Ui6zUkC2+0G7UsY6yXPquN0Uh4yqD1BqVxRTT8TQUJgYPmliurDgD+QdQbxumlq8GAxudaJAfPv65zDTkDxtkrutpU5+ZZfGjmqWJS0RdjslF2Bpr5mJnPrXgXZj5yZLO/Faji/0qyy/AhC6KqFk0d4fjzIGA1opg5vC4vWMK15cNKkgsR6Jd2qmd4Jm5a1YCLIB/Mjt2IdKwvc9BpMXP3IKf5LAUoInCnYX0ik9+rlU+JYQKgjK6H34nNqrq6lgVSmSgi4tV+swS3uQRqwpDUQGRwqHeEP3AWKWPrQauN70ziYQ0fDUeZOHXrene4/6/gIEwsRdM+UrricV7vlAvn6+XLRpiiLh0s7+FrMnt92qk6EzNNkhSL0RsKPlVvh5WZa0ZLD8urGOWaJFFXqww4vb0a33Wnxj5mKR/LblIlWt+U4Nso0/vY4cvFphJqiYzsZn958Bv963; 4:do2GLBTkvu/5i0KIaSHlb7hF7Y9dmIOymxwi5KJYarQzqRigAOZuK94sjOSDjyVSH7CuyPmIQaYCtN2BJXxOS8uu+nyTn5kPFzls/Y60Oj56zdt679fpRWaeqYCiWOMQSzMxlXrZLtvz3DYBXjDa4htfmXW5/GD5SA0v+GPW60cw+F6WhoI3cL2z7yD6UOy6OIzOoVz3VzUF7B/+eRYcfFOZ5bRK1jmBHIpnQHIHx109vJlZJJbz9F/3FcDdI4tDBOfllAdCVDfBio3N7TO6KQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231221)(944501300)(52105095)(10201501046)(93006095)(93001095)(6055026)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:HE1PR0502MB3882; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0502MB3882; X-Forefront-PRVS: 06167FAD59 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(396003)(39380400002)(376002)(366004)(189003)(199004)(6916009)(386003)(25786009)(105586002)(81166006)(66066001)(81156014)(5660300001)(33026002)(47776003)(69596002)(53936002)(106356001)(316002)(8676002)(21086003)(16526019)(107886003)(26005)(478600001)(186003)(4720700003)(97736004)(16586007)(3846002)(54906003)(86362001)(50466002)(305945005)(7696005)(55016002)(6116002)(50226002)(7736002)(2906002)(48376002)(4326008)(8936002)(36756003)(5890100001)(51416003)(6666003)(68736007)(59450400001)(52116002)(168613001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0502MB3882; 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; HE1PR0502MB3882; 23:e9neg7MMnQwrXe8C7x958qlTcwtT+8njAvMsEXV?= =?us-ascii?Q?f0MFxV7hrb+IANE+TMJz6ItSSYvpYarNH7ItqkaHZWSTu3Pkj0zkkjj6YQdp?= =?us-ascii?Q?lcmMSPlb0zCKB2yLZaubMZjPyx9yhNmKAXxF0bZrYOFqfmUuXIn66GdHVS/6?= =?us-ascii?Q?XjkOTtsXIqkfqnSMUIupOO03sm5u0Z93v4db0HCV5hEE4PsULd4el4f1Rt5o?= =?us-ascii?Q?jb/1WgG5lxmCg/7AxDe2DigTGYm/b6hBejyehTmKcka4zh874JV/oGKqH5F9?= =?us-ascii?Q?r1MFS6/xQipY3mjpTANlP+3VgrO7BVIZHVhsMz9jC09/VY0rWWa4vv6ISJL9?= =?us-ascii?Q?lbtHpA25ItHsYkwnbIN7fSUIFulJDxzqFUMbBLvqyTYOGvPFKP4CpREXnc58?= =?us-ascii?Q?XIITM4d1BEG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pDYi1TJQKQYQ8/fNclAqu/Tbgb/F4X7glnDqZ6kCqjvCmokrGPA7Fuvk3g+q1lz1IrnasqCge SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2018 09:01:05.3848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72fc7961-0152-4904-0dce-08d58d77f334 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3882 Subject: [dpdk-dev] [PATCH v1] net/mlx4: disable CRC stripping 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 09:01:09 -0000 Previous to this commit mlx4 CRC stripping was executed by default and there was no verbs API to disable it. Since OFED version 4.3-1.5.0.0 the API query_device_ex() indicates if CRC stripping capability is supported in HW and if so CRC stripping can be disabled during WQ initialization. This commit uses these new APIs to allow disabling CRC stripping through rte configuration. A user can specify --disable-crc-stipping in testpmd command line or 'port config all crc-strip off' in testpmd interactive shell. Signed-off-by: Ophir Munk --- drivers/net/mlx4/mlx4.c | 4 ++++ drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/mlx4_rxq.c | 33 +++++++++++++++++++++++++++++++-- drivers/net/mlx4/mlx4_rxtx.h | 1 + 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index ee93daf..95e01a6 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 configuration 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..7de896a 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 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.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