From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr60076.outbound.protection.outlook.com [40.107.6.76]) by dpdk.org (Postfix) with ESMTP id E06CB1B1D9 for ; Wed, 10 Jan 2018 10:10:05 +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=Do3jb21TnclpTZKIKl9+UElhK474lutkIgp77RFrKdI=; b=rORYhxu2TBaUsovUn8X+ZUJnFqKGjcR1V6sJEdHJK+dVulBZ1yfhPcUNR7n4i/NDOMNnAv5rsucSU62kFceUzC9KgKNg1xQL84AnA1n5y9LdZ5Hj+RIgUg42uH2e3Kec8igp5aefjIgC1df/vhrWBKvNolVQHP8xzsreRVMmrDM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; Received: from mellanox.com (82.166.227.17) by AM4PR05MB3137.eurprd05.prod.outlook.com (2603:10a6:205:3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Wed, 10 Jan 2018 09:10:04 +0000 From: Shahaf Shuler To: jingjing.wu@intel.com, thomas@monjalon.net, ferruh.yigit@intel.com Cc: dev@dpdk.org Date: Wed, 10 Jan 2018 11:09:17 +0200 Message-Id: X-Mailer: git-send-email 2.12.0 In-Reply-To: References: <20171123120804.143897-1-shahafs@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [82.166.227.17] X-ClientProxiedBy: VI1PR0202CA0030.eurprd02.prod.outlook.com (2603:10a6:803:14::43) To AM4PR05MB3137.eurprd05.prod.outlook.com (2603:10a6:205:3::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1d50dc66-b4c2-4494-daa2-08d55809f00f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM4PR05MB3137; X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3137; 3:gWf1nSmDM9njDDV1QNARjcPYw0Deu42Srptnr6bN+YsivSmwtLjHOIxz/v43ZK8xd3E8zpQnCV19AOo+f2hUbmbVVGbsy67KotTuaclfuePjW+6ORgmXhEOYagxJgj4tkK2Nw0FGsc3WWT4Zo0yAtoFY0LikNX7sHFe+2akcyDkFLukLmmJ+y7tCvNdtZ2MNN8VYtT5e3Bau6vaqAgEmSy0AvgmvvF63GsjIDXMGZGC1rEOcS8e8ToNSTpn5DKWm; 25:2AiKtQjN3UoiqDm9XssXbzgn9/FWQ3rwj+MyNYqRK1vIp4gQClgcDw/th4V+71rxyw0yGUQcQBIKQLE0Yf7snkI7dvWpd4TUR3L0O60CKgpmHBABXPRSqJ1PxC0LywahY4l7UW8XRsx/0PDGaorZWMA/oeyX+4HU70isihUrYMD9sujc38AEadrdi9g4YIoCBRoQEsZamiPtYHUuBPXkWcmd7xXHOgx0NTm2EA6wIIKWGKa33l6+8UWzwxiHBOfQeXeRGM2UGhxu2XO57FMObdQazftU0KqSNYghtOv3QdAUT7p2cT0hAvV3wKTp6xykeoi4dxcdkMGYZmvNd8IyvQ==; 31:elt1CNGAjZBguO+dgWG+vCED6n0igJ+1u6P4xToGpzNB6FnE2EZdjtJSwXi5eJvY7dYY8cLj150slc760Oce2TgKAuV3gSBKTt3hebGh0w4pJHyrixsUqAHltyEJ+977Dwx+S8UWxJTBd3ya1VJrh1M54IbPpBi5GUgZWcOrDnCjG9NOKJFdIVhOpcAbkysE5zH2DK6xcGV3kZgAIy3CN3I1L8p9JkOYIu4tM9dycas= X-MS-TrafficTypeDiagnostic: AM4PR05MB3137: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3137; 20:RR3n+ktu4C3yQjn5trRhb3D7v94ITMvp6uc3qqvVkJsckdQx1aPdJmdtC94Md74oRRqOn979XHabOsMOoBnN4/n7ZgPwEjbbJAzkC6UpQhqC0Tthy41AnQ177bg26nKJicmDmvKAk54ZkkHQVO4hVNNcwa6dU0zVcDmkV+Z5Gkzf3HW51rPjSmVVJ3XN1qMDAfx77GInpxJnwyb/b2gPCvVFth8Ob5KXVbZDoQG9vV7pOROMEXTAZLmR6Gk7UhPLMAzTqtBQ4N10roW2hcf8VVzmotKY3ij1orXZHvneeca8ki7ijvbdhft9GdiCksgRqkCSMqkJlV1RbhHta1RugSHfBsBqgm+HlU6X3iDJ2mfnTp0y1o+TLu0gbYiQz7g0EJuIrZ/tAbCx1kGpHQufknU3qaD3cmoV4+yKUY3872yrmpDilSvQGyoJ1PADxVa4osNLyw1wtbKNSvAJ8+Ue6E1969tLgz198H7/vjpwZXUh4FZ+v61UMP/4AgfijclG; 4:qV8o1E/qPvGics0uUNIbAC/yOc9bZeIkHrt0Ogg0Zo6Zg5uuOe9Ol8DP6p/oG2CfHHx+X+ZPLp726qp2K2BwVA8REH39zSN0nFvdlVqQxDvCwzoupcHkWFaGvA6WmNRs/+cRW93lVoyhACHAzo0q6+ZR/LbXDm2oODbzh3yQ2lh4sXAKWMDDlHetTSybLUTWJjiZ8pKtYtgU5KrnnOMPneMs1DD5s8evEoZmpeDEgqcqYlQhriegz4D/OGZlTJgobOXQSXw++cfde7+c2puiqdTRBFwACAmh1LgE/aMeUyYUlsi6R/z07EzTsW7xY5wY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231023)(944501075)(6055026)(6041268)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM4PR05MB3137; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM4PR05MB3137; X-Forefront-PRVS: 0548586081 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(396003)(366004)(39380400002)(346002)(199004)(189003)(6666003)(478600001)(2950100002)(5660300001)(8936002)(50226002)(8676002)(81156014)(68736007)(86362001)(81166006)(575784001)(118296001)(305945005)(7736002)(55016002)(2906002)(21086003)(6116002)(3846002)(106356001)(105586002)(59450400001)(316002)(50466002)(69596002)(386003)(16586007)(36756003)(4326008)(52116002)(76176011)(51416003)(7696005)(97736004)(16526018)(47776003)(53936002)(25786009)(48376002)(33026002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3137; 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; AM4PR05MB3137; 23:g+ECsFHhoPe0ACXVJH/f/h1klNJ+Kyb5BALihw9Ne?= =?us-ascii?Q?lmocXOaqdTzyQ486Etix8AQje6Ej+5P6Xm1Jv8qyknbSsrq8Xfizuu5tYGj9?= =?us-ascii?Q?ox5ynHx3XqSBlieWh0WH3v05R+ob4Qrj0kOaFTdU+gzbd6WSc9MwxtlqDlAA?= =?us-ascii?Q?NCc42R92/lUnA2YFej/yiQOE3XC4jfhVH50mkEF95MEMu8i9JaTZdpf5x45k?= =?us-ascii?Q?rT+M5oSGc9mA5xfp17Rdtj8rp5+En12TdZ1eQw9Cc0tZjsSpp8aOa73G4Mwe?= =?us-ascii?Q?D1RXBx92Pyc/0UHk9UNnlbUm9TysRXF8sAg0/+Yni1bxseM+vhqd4c1Ux2PV?= =?us-ascii?Q?EbmRE8Y8UbOGe1foLyUC9ukadUOwPh+ZdUdvOWJHvL07IGTPCunJMACTRtkr?= =?us-ascii?Q?lz0piDt0CqaCOTsU5DkQpjrNJ+nvuMsYA3rRkg5Bvt15E0SJ5Rdbuv3BVM1N?= =?us-ascii?Q?Wtq0pHbDatRntXJxLkfiQkgWJTI79M1Xd0CkXNU404vPDjFQ8RB7O1TMf1uA?= =?us-ascii?Q?0UgkJDNCDMJ8hQry/1Ykas0KfOMVS7Km1Fs8MvcADb61EVGZbEAG5L/CfDGO?= =?us-ascii?Q?aEOxe02zo3PgT84X4SWpRIvd/AVsbQOhC8PCOBk97ResqgzrfIK4g/HSd/DA?= =?us-ascii?Q?sN9UHOJl4U5bvs6+MEXzQ7Xzq7dGxJ1da9vmt/wZ4YLMI8WcqmEhbhRCm/5X?= =?us-ascii?Q?eq171lV0A1xuA5DAdNdc2xUKAmYb0VGZUCxBfheHcmN29fgAYUvlv8mHkqJu?= =?us-ascii?Q?IjZI86vlXohPZylDFzLddJBfgrQ3ob3FYK5MI4Rnx9RkFGqpr45yPQLL+Lag?= =?us-ascii?Q?1yZ2fg1I78rF2mBh9BRaJyHprmUFe3HyEvKHGv96MaYhbhK9ty6X9XSfPUm8?= =?us-ascii?Q?BB46CBUPK1gtshyfDsqx19BJhRFQ1jgnAJ9kkjcEnpwxkJL6JM+RrfankzmS?= =?us-ascii?Q?5LiZxTjYPYQu9HUcB+hQkRP2tTJsvoxElY5NAus4A276YIN5JYCJ44vERdQK?= =?us-ascii?Q?MY68M54r1IYrVAECjMyibDFvDCeDsJM/cneR3/rL5ZW5LKVyTG8Fk7zmrsN0?= =?us-ascii?Q?LqC7YGLsPAHwuzBWnFlVoge/0mrH8BPY6PPvWsPciVdrrVKzs4CJ4w16c0I3?= =?us-ascii?Q?mVS57jxvh6fh10o9GmhIQBb4hpmZO+X7HnElXFW84biaOeUeC0Nkw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3137; 6:POcH0+RqYz9b8MGY4DFnXMRICjLS4keTBpehUdRVGmx0KO0g+3br+I3apTwB++TKCeo1z69/8zS8snFduohrO9rUAx0vT1KK5Yikzg2/1tClSesSURg4GWTpTnSNCoMemcs6RXgz1NoUIOY5WA3t5Z+aSImVfPeLZLuVQJ0IHkBJKq0xyqh9m2p9XQ6hFqHILwM5oOXijjZDlchRzwUTSqRb44U8SYUWCOPHl6+guWkPQvVCZU7lHxLO9QibdRD+HkusLzr4JJP0/VpUVpqPy3Tkw/DXuc5yfxpJAbqDmn6FrWGDlRs24lYSAVnDJSCekLGYc+/MpUzNBiDARLof89Wr9o2Sh+eGiExJxLketBg=; 5:lCi3GDBU8U8GV0Eb/TmistLox2tOKJPFOEJs4yxFf3XgPhI97AkNbJKjJy4EXAPFJQ/pvRyFvKU5hfVJxERYHlpk/0KIQ7OzN5/KII5M/VN3FE9bOvre2do6mJ1nMn+u/YcQeORH6x34KonuqoU5DsRRy40tljRANFAu/KecznY=; 24:pw4NRYA/Ag7qjyVN45TC6NBsqTNG0fOk7ttgpEOXlyahMvw6rVVLGNkiZxTkSN8Vyny5nZe2uxx65alhwSlfStJsVwwnsxX25+LWCo0PJIk=; 7:US6T5AqQ15HTSRMx2ekZqCKjwhrkoVblocvxZ9twxd7gIHL5obwe/BWltaCmK6gxn41a43J7x1f3MUck2gQM6g2ajEQwRGA1nA9KJEp69ydTzlxVz8a4M1nxPCrEDw21e57bFB5L2QgXq7RQdSw64qIq7oI86zK6h4OFK87XQoTX+5vY+H43RrjXnYjlwEwNDvNxCRZi1ZW1/r9W44xY3Tnt9w78xYz59FncNsAJB5ME6Bx1YkIW0pijuT1IbVmu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2018 09:10:04.0813 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d50dc66-b4c2-4494-daa2-08d55809f00f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3137 Subject: [dpdk-dev] [PATCH v4 09/11] app/testpmd: enforce offloads caps 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, 10 Jan 2018 09:10:06 -0000 In the current design it was possible for offload to be set even though the device is not supporting it. A warning message was printed instead. This is a wrong behaviour, as application should set only the offloads reported by the capabilities of the device. This patch adds verification for the offloads being set and make sure the offload configuration passed to the device always match its capabilities. Signed-off-by: Shahaf Shuler Acked-by: Wenzhuo Lu --- app/test-pmd/cmdline.c | 103 +++++++++++++++++++++++++++++++++----------- app/test-pmd/config.c | 14 ++++++ 2 files changed, 92 insertions(+), 25 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b4ef1d0eb..d1b8dab6e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -3638,6 +3638,7 @@ cmd_csum_parsed(void *parsed_result, struct cmd_csum_result *res = parsed_result; int hw = 0; uint64_t csum_offloads = 0; + struct rte_eth_dev_info dev_info; if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { printf("invalid port %d\n", res->port_id); @@ -3648,21 +3649,53 @@ cmd_csum_parsed(void *parsed_result, return; } + rte_eth_dev_info_get(res->port_id, &dev_info); if (!strcmp(res->mode, "set")) { if (!strcmp(res->hwsw, "hw")) hw = 1; if (!strcmp(res->proto, "ip")) { - csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; + if (dev_info.tx_offload_capa & + DEV_TX_OFFLOAD_IPV4_CKSUM) { + csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; + } else { + printf("IP checksum offload is not supported " + "by port %u\n", res->port_id); + } } else if (!strcmp(res->proto, "udp")) { - csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; + if (dev_info.tx_offload_capa & + DEV_TX_OFFLOAD_UDP_CKSUM) { + csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; + } else { + printf("UDP checksum offload is not supported " + "by port %u\n", res->port_id); + } } else if (!strcmp(res->proto, "tcp")) { - csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; + if (dev_info.tx_offload_capa & + DEV_TX_OFFLOAD_TCP_CKSUM) { + csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; + } else { + printf("TCP checksum offload is not supported " + "by port %u\n", res->port_id); + } } else if (!strcmp(res->proto, "sctp")) { - csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; + if (dev_info.tx_offload_capa & + DEV_TX_OFFLOAD_SCTP_CKSUM) { + csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; + } else { + printf("SCTP checksum offload is not supported " + "by port %u\n", res->port_id); + } } else if (!strcmp(res->proto, "outer-ip")) { - csum_offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; + if (dev_info.tx_offload_capa & + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) { + csum_offloads |= + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; + } else { + printf("Outer IP checksum offload is not " + "supported by port %u\n", res->port_id); + } } if (hw) { @@ -3805,6 +3838,14 @@ cmd_tso_set_parsed(void *parsed_result, if (!strcmp(res->mode, "set")) ports[res->port_id].tso_segsz = res->tso_segsz; + rte_eth_dev_info_get(res->port_id, &dev_info); + if ((ports[res->port_id].tso_segsz != 0) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { + printf("Error: TSO is not supported by port %d\n", + res->port_id); + return; + } + if (ports[res->port_id].tso_segsz == 0) { ports[res->port_id].dev_conf.txmode.offloads &= ~DEV_TX_OFFLOAD_TCP_TSO; @@ -3881,24 +3922,25 @@ struct cmd_tunnel_tso_set_result { portid_t port_id; }; -static void +static struct rte_eth_dev_info check_tunnel_tso_nic_support(portid_t port_id) { struct rte_eth_dev_info dev_info; rte_eth_dev_info_get(port_id, &dev_info); if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) - printf("Warning: TSO enabled but VXLAN TUNNEL TSO not " - "supported by port %d\n", port_id); + printf("Warning: VXLAN TUNNEL TSO not supported therefore " + "not enabled for port %d\n", port_id); if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) - printf("Warning: TSO enabled but GRE TUNNEL TSO not " - "supported by port %d\n", port_id); + printf("Warning: GRE TUNNEL TSO not supported therefore " + "not enabled for port %d\n", port_id); if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) - printf("Warning: TSO enabled but IPIP TUNNEL TSO not " - "supported by port %d\n", port_id); + printf("Warning: IPIP TUNNEL TSO not supported therefore " + "not enabled for port %d\n", port_id); if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) - printf("Warning: TSO enabled but GENEVE TUNNEL TSO not " - "supported by port %d\n", port_id); + printf("Warning: GENEVE TUNNEL TSO not supported therefore " + "not enabled for port %d\n", port_id); + return dev_info; } static void @@ -3907,6 +3949,7 @@ cmd_tunnel_tso_set_parsed(void *parsed_result, __attribute__((unused)) void *data) { struct cmd_tunnel_tso_set_result *res = parsed_result; + struct rte_eth_dev_info dev_info; if (port_id_is_invalid(res->port_id, ENABLED_WARN)) return; @@ -3918,6 +3961,7 @@ cmd_tunnel_tso_set_parsed(void *parsed_result, if (!strcmp(res->mode, "set")) ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; + dev_info = check_tunnel_tso_nic_support(res->port_id); if (ports[res->port_id].tunnel_tso_segsz == 0) { ports[res->port_id].dev_conf.txmode.offloads &= ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | @@ -3926,11 +3970,13 @@ cmd_tunnel_tso_set_parsed(void *parsed_result, DEV_TX_OFFLOAD_GENEVE_TNL_TSO); printf("TSO for tunneled packets is disabled\n"); } else { + uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | + DEV_TX_OFFLOAD_GRE_TNL_TSO | + DEV_TX_OFFLOAD_IPIP_TNL_TSO | + DEV_TX_OFFLOAD_GENEVE_TNL_TSO); + ports[res->port_id].dev_conf.txmode.offloads |= - (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | - DEV_TX_OFFLOAD_GRE_TNL_TSO | - DEV_TX_OFFLOAD_IPIP_TNL_TSO | - DEV_TX_OFFLOAD_GENEVE_TNL_TSO); + (tso_offloads & dev_info.tx_offload_capa); printf("TSO segment size for tunneled packets is %d\n", ports[res->port_id].tunnel_tso_segsz); @@ -3945,7 +3991,6 @@ cmd_tunnel_tso_set_parsed(void *parsed_result, * is not necessary for IPv6 tunneled pkts because there's no * checksum in IP header anymore. */ - check_tunnel_tso_nic_support(res->port_id); if (!ports[res->port_id].parse_tunnel) printf("Warning: csum parse_tunnel must be set " @@ -12995,6 +13040,7 @@ cmd_set_macsec_offload_on_parsed( portid_t port_id = res->port_id; int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; + struct rte_eth_dev_info dev_info; if (port_id_is_invalid(port_id, ENABLED_WARN)) return; @@ -13003,15 +13049,19 @@ cmd_set_macsec_offload_on_parsed( return; } - ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_MACSEC_INSERT; + rte_eth_dev_info_get(port_id, &dev_info); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { #ifdef RTE_LIBRTE_IXGBE_PMD - ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); + ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); #endif + } RTE_SET_USED(en); RTE_SET_USED(rp); switch (ret) { case 0: + ports[port_id].dev_conf.txmode.offloads |= + DEV_TX_OFFLOAD_MACSEC_INSERT; cmd_reconfig_device_queue(port_id, 1, 1); break; case -ENODEV: @@ -13083,6 +13133,7 @@ cmd_set_macsec_offload_off_parsed( { struct cmd_macsec_offload_off_result *res = parsed_result; int ret = -ENOTSUP; + struct rte_eth_dev_info dev_info; portid_t port_id = res->port_id; if (port_id_is_invalid(port_id, ENABLED_WARN)) @@ -13092,14 +13143,16 @@ cmd_set_macsec_offload_off_parsed( return; } - ports[port_id].dev_conf.txmode.offloads &= - ~DEV_TX_OFFLOAD_MACSEC_INSERT; + rte_eth_dev_info_get(port_id, &dev_info); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { #ifdef RTE_LIBRTE_IXGBE_PMD - ret = rte_pmd_ixgbe_macsec_disable(port_id); + ret = rte_pmd_ixgbe_macsec_disable(port_id); #endif - + } switch (ret) { case 0: + ports[port_id].dev_conf.txmode.offloads &= + ~DEV_TX_OFFLOAD_MACSEC_INSERT; cmd_reconfig_device_queue(port_id, 1, 1); break; case -ENODEV: diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index faccb84ca..d32a4672b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2792,6 +2792,7 @@ void tx_vlan_set(portid_t port_id, uint16_t vlan_id) { int vlan_offload; + struct rte_eth_dev_info dev_info; if (port_id_is_invalid(port_id, ENABLED_WARN)) return; @@ -2803,6 +2804,12 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id) printf("Error, as QinQ has been enabled.\n"); return; } + rte_eth_dev_info_get(port_id, &dev_info); + if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) == 0) { + printf("Error: vlan insert is not supported by port %d\n", + port_id); + return; + } tx_vlan_reset(port_id); ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_VLAN_INSERT; @@ -2813,6 +2820,7 @@ void tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer) { int vlan_offload; + struct rte_eth_dev_info dev_info; if (port_id_is_invalid(port_id, ENABLED_WARN)) return; @@ -2826,6 +2834,12 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer) printf("Error, as QinQ hasn't been enabled.\n"); return; } + rte_eth_dev_info_get(port_id, &dev_info); + if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_QINQ_INSERT) == 0) { + printf("Error: qinq insert not supported by port %d\n", + port_id); + return; + } tx_vlan_reset(port_id); ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_QINQ_INSERT; -- 2.12.0