From patchwork Thu Oct 11 13:31:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyu Min X-Patchwork-Id: 46627 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 103281B5A7; Thu, 11 Oct 2018 15:31:42 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00041.outbound.protection.outlook.com [40.107.0.41]) by dpdk.org (Postfix) with ESMTP id C861F1B592 for ; Thu, 11 Oct 2018 15:31:40 +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:X-MS-Exchange-SenderADCheck; bh=Yns8dfsCkzYCvsqbSdbTFMxwvlHck28bthvdfryG/gc=; b=N61BFE5zkGk2bOEJR7EFnlkZ9X/RK7P9qtNV8sGGB7mixI4/uNF/06D3qNbLhF88WxbHiyo9INee778yMRS4uwQHCop44OhxWP0DLGiWFRK9visQ0noLRMtU6V6XWvVV4YuWakgJS6+GGpYxQyISsi8Eyoz2NZkoMFQLxVA/0ls= Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com (10.168.9.17) by DB6PR0501MB2791.eurprd05.prod.outlook.com (10.172.226.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.23; Thu, 11 Oct 2018 13:31:39 +0000 Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913]) by DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913%3]) with mapi id 15.20.1228.020; Thu, 11 Oct 2018 13:31:39 +0000 From: Jack Min To: Adrien Mazarguil , John McNamara , Marko Kovacevic , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: "dev@dpdk.org" Thread-Topic: [PATCH v3 1/3] ethdev: add generic MAC address rewrite actions Thread-Index: AQHUYWa9idFWx9tngkK3snd21Exacg== Date: Thu, 11 Oct 2018 13:31:39 +0000 Message-ID: <20181011133109.1520-2-jackmin@mellanox.com> References: <20181010131108.24167-1-jackmin@mellanox.com> <20181011133109.1520-1-jackmin@mellanox.com> In-Reply-To: <20181011133109.1520-1-jackmin@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK2PR0302CA0021.apcprd03.prod.outlook.com (2603:1096:202::31) To DB6PR0501MB2023.eurprd05.prod.outlook.com (2603:10a6:4:6::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jackmin@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [118.201.220.138] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0501MB2791; 6:l+UvNBIO39HHAZwd9xvR+WUKyPSZfUOhBkqhKHAxnUDpfy5fWRV1jspjYFij4yFHg+60TblFhhw5SAnC72ll3sDq3FjiaYKefQR9kuJS33JWt8HBOfgMvzIS++lwaEepsox8OcbPXN7nOpL+f69S7tpPaxxBzj4oaWaPf9tJXDAirk8PjpZdgCyXN79szQ1UEaC6yoZracDXI5O3wGVtpsLETDj2qtZRQIzUeyyl7fZIi+Ew6P+d9XuFoUo4n8FYDAFTkFaWvyHE2M6ov98dwgGQ8kz6M9+l2wBrKYmKiVJZV+KbD96iegcBPGAMRFmmiKC+chLvAhdwKWrT/y7Wo0dt+/13ZqB6L3Rb0q+VBnDUAAwdfsw1wYi1TvF/kpEuKLwCQPT6sw9KyXxO3P2ORz22iyPyK49uWp5UMs2Q0l7MT3fGowOWcHxmY6CxB0E1Hlcs0BI+t0LkmhMy7UWI+Q==; 5:/T6qdPOH9BTe7Qi/dUS49OY7RzvKvp1kROP3rBG8s9DNgy3h5gUFnei8zkmQToogx2EjHSCSbkyh+P4ERYkEIwO6Mlj6pRa5xcpI85Wk6kLw9zME2MpZqM71ngjG2vRaYI2Ywh+0VQopZ/ncLAu9715VmArc9yAB3o5WPZnPU9I=; 7:OkDr31711oQgToTN7UXs+YtfIfDyd2ctGOwyOYbNratLrXQI2sEQRF9ydkfx3NZMmqtQaixxeReM+WI9c/rl5/77Y46Eay+1pk0D4Wlxb9h/nvgZ/64m7Y+dJIKbDKvG4Vynopve/qe2FfpUN7m3M8lycMPsiN8NUh98y/XQDbaTfTg9+jvIatPIRtRcMB97EtFL8eV3E/eOiT51/erZUX3pgpzZTiqk2oL5Lt/JH3GdqHDNw2jyc0e/9867HR+/ x-ms-office365-filtering-correlation-id: 9854687c-e4ff-4b26-3bda-08d62f7ddf81 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2791; x-ms-traffictypediagnostic: DB6PR0501MB2791: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(201708071742011)(7699051); SRVR:DB6PR0501MB2791; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2791; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(39860400002)(396003)(376002)(346002)(199004)(189003)(305945005)(53936002)(7736002)(99286004)(105586002)(316002)(478600001)(6506007)(386003)(52116002)(36756003)(106356001)(68736007)(76176011)(110136005)(4326008)(6116002)(81156014)(1076002)(8936002)(8676002)(5250100002)(102836004)(3846002)(81166006)(256004)(14444005)(2900100001)(14454004)(5660300001)(71190400001)(71200400001)(66066001)(97736004)(446003)(6512007)(11346002)(6486002)(86362001)(26005)(25786009)(6436002)(486006)(186003)(2616005)(476003)(2906002)(41533002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2791; H:DB6PR0501MB2023.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: VTmwNySRfEeoGswgZ99Jicp2JkB9g2MMlrRIy+KZ4gdil01dqXppS0urwGs0zGJB6dqMvCKT9hK/vDklEWDP5g4XAL2aGYM5MJldF6iN1k+xihsPSexr+N9ukRn6ThEZt59Ne7tM1oCu8ort7YhAg6pOAYV/Qf4dygufKjSZQaaVF4DcUKTnSlPQQlX3lCB/LjRMAGIngDu1MiQ8gMtNDkdtNJ3Zm75bm4zaUcbZjL8LwwWy4rR/bcq+qy/GPCy53m8L52xV3+CjLUDaShNlz8exvraQTBXVG0oEqpAFMAXYBKYGqP9e8C0LxXHXSZec9vawf8Mn7ci4HZmj2KN5Kim79xWzsG4Od0lsN4sSVm8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9854687c-e4ff-4b26-3bda-08d62f7ddf81 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 13:31:39.1397 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2791 Subject: [dpdk-dev] [PATCH v3 1/3] ethdev: add generic MAC address rewrite actions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" rte_flow actions: - RTE_FLOW_ACTION_TYPE_SET_MAC_SRC - RTE_FLOW_ACTION_TYPE_SET_MAC_DST added in order to offload to NIC The rte_flow_itme_eth must be present in rte_flow pattern Signed-off-by: Xiaoyu Min Acked-by: Yongseok Koh Acked-by: Andrew Rybchenko --- doc/guides/prog_guide/rte_flow.rst | 30 ++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 2 ++ lib/librte_ethdev/rte_flow.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 9fc5b88f2..0f7d89555 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2227,6 +2227,36 @@ Assigns a new TTL value. | ``ttl_value`` | new TTL value | +---------------+--------------------+ +Action: ``SET_MAC_SRC`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Set source MAC address + +.. _table_rte_flow_action_set_mac_src: + +.. table:: SET_MAC_SRC + + +--------------+---------------+ + | Field | Value | + +==============+===============+ + | ``mac_addr`` | MAC address | + +--------------+---------------+ + +Action: ``SET_MAC_DST`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Set source MAC address + +.. _table_rte_flow_action_set_mac_dst: + +.. table:: SET_MAC_DST + + +--------------+---------------+ + | Field | Value | + +==============+===============+ + | ``mac_addr`` | MAC address | + +--------------+---------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 5040c7667..1752ed5eb 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -138,6 +138,8 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(MAC_SWAP, 0), MK_FLOW_ACTION(DEC_TTL, 0), MK_FLOW_ACTION(SET_TTL, sizeof(struct rte_flow_action_set_ttl)), + MK_FLOW_ACTION(SET_MAC_SRC, sizeof(struct rte_flow_action_set_mac)), + MK_FLOW_ACTION(SET_MAC_DST, sizeof(struct rte_flow_action_set_mac)), }; static int diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index f102e6939..844ee3b25 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -1599,6 +1599,26 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_ttl */ RTE_FLOW_ACTION_TYPE_SET_TTL, + + /** + * Set source MAC address from matched flow. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, + * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_mac. + */ + RTE_FLOW_ACTION_TYPE_SET_MAC_SRC, + + /** + * Set destination MAC address from matched flow. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, + * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_mac. + */ + RTE_FLOW_ACTION_TYPE_SET_MAC_DST, }; /** @@ -2018,6 +2038,15 @@ struct rte_flow_action_set_ttl { uint8_t ttl_value; }; +/** + * RTE_FLOW_ACTION_TYPE_SET_MAC + * + * Set MAC address from the matched flow + */ +struct rte_flow_action_set_mac { + uint8_t mac_addr[ETHER_ADDR_LEN]; +}; + /* * Definition of a single action. * From patchwork Thu Oct 11 13:31:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyu Min X-Patchwork-Id: 46628 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 162DC1B5B3; Thu, 11 Oct 2018 15:31:47 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00073.outbound.protection.outlook.com [40.107.0.73]) by dpdk.org (Postfix) with ESMTP id 6E8E81B5B3 for ; Thu, 11 Oct 2018 15:31:45 +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:X-MS-Exchange-SenderADCheck; bh=AhLj11ob/0HcfILYWa9gHHhjvgwGHR1GFfdxqclQ6gU=; b=Fl4SBjn5WViaSxrHo+n6RIvTQBV9sTLCMZ2ko3cd/aXo+tRZJ+2m1ktfuazWdRIlLdfiba32RHetbHVSbEiUlR6fr1p/LBNyUZjAQalm8CLW0sao1AUyaF9hIziCTrEuGIAOavlxAXy5iO6yK2Qrc06Ho1jHNFLJs1jMFnFz41M= Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com (10.168.9.17) by DB6PR0501MB2791.eurprd05.prod.outlook.com (10.172.226.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.23; Thu, 11 Oct 2018 13:31:44 +0000 Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913]) by DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913%3]) with mapi id 15.20.1228.020; Thu, 11 Oct 2018 13:31:44 +0000 From: Jack Min To: Adrien Mazarguil , Wenzhuo Lu , Jingjing Wu , Bernard Iremonger , John McNamara , Marko Kovacevic CC: "dev@dpdk.org" Thread-Topic: [PATCH v3 2/3] app/testpmd: add commands of modify MAC address Thread-Index: AQHUYWbAZ0Bap5VxUEWNpBFj22kyqQ== Date: Thu, 11 Oct 2018 13:31:43 +0000 Message-ID: <20181011133109.1520-3-jackmin@mellanox.com> References: <20181010131108.24167-1-jackmin@mellanox.com> <20181011133109.1520-1-jackmin@mellanox.com> In-Reply-To: <20181011133109.1520-1-jackmin@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK2PR0302CA0021.apcprd03.prod.outlook.com (2603:1096:202::31) To DB6PR0501MB2023.eurprd05.prod.outlook.com (2603:10a6:4:6::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jackmin@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [118.201.220.138] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0501MB2791; 6:kbsZ6ydRXi+QFSZsbzTtBhCvNZNW06kOTJ1Rpeji7cQN+HSVePPXDWG7nm+69V7jdvuf8ER4YBRiIPWv6S08wuaXnRJcqaNvH+oY7PWQXQNkM1h+Msh4RD60htasnpgNzBbFSgevEax6ifLb9zWv518Eics3H6wzdWwWLhimle0oukY0ZE2APDa373PvzgCkiTv9/OrYeACiFjTdxHq4xkjG5LmF8sJYbxwaEXEvfroivhS514agx3BWk4ziUlT+IUBFRCPoS+A/5WxiBcP+YJrC4mZrfIUSHL8ErnWTk+Jf0Ss0xu41yX5ICfz1ZNteXG4WGpbD8LVQl3nREjVoEnpkYU36g6JvFr/0WQWr+ih+QSD9Icir2NnEu4Fivpky9XMvuSpNE9HRAglyQ1/Ph1lJzI9BowNmuIafu36R2x9WKa2O8lTcU5YWyVjDlpiMiMuj/YNxYGNYhg4YWDsv8A==; 5:GpTwmHEerJdH1aI6zmTSycKzGR70ppEs/RlLsQd44LsJy+bJl5RzSozjgeJtcHg1+vwUPw5bNLXXHVxB323c2mrA/c9l3C/ZFHDix89n+6Tp+g1ggNudyNILLmzXDzR3z2f+HJDBrVD6eAE0wSEbOFJhNoB++PepUJL1zoTSVWA=; 7:QIpgsFoW0bUEIVZ0ScTI8tqy5zCLboTcmTGr2KYViW+PdMASZ22/Mb89QMBcRmfCe3/RTwcGQZ38Bk0V5jVdDxl4yogIbcSoJ8o1egFTolx6ecf/iezBcKfpFp42MfYGkzPQ9EfpRQNuSeCuEmABtDy5/VbuUOFEL5oIGaNqSV1ausoRPC07XHiVWdCh6bmBt0fmJuvV7ewTdlW9Bt0HoF4X8/kMPhcvyGvPi63c90IcdaPXtcj5P89SNSOJDhkH x-ms-office365-filtering-correlation-id: b0f607fb-48c6-44ed-9c57-08d62f7de240 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2791; x-ms-traffictypediagnostic: DB6PR0501MB2791: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(201708071742011)(7699051); SRVR:DB6PR0501MB2791; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2791; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(39860400002)(396003)(376002)(346002)(199004)(189003)(305945005)(53936002)(7736002)(99286004)(105586002)(316002)(478600001)(6506007)(386003)(52116002)(36756003)(106356001)(68736007)(76176011)(110136005)(4326008)(6116002)(81156014)(1076002)(8936002)(8676002)(5250100002)(102836004)(3846002)(81166006)(256004)(2900100001)(14454004)(5660300001)(71190400001)(71200400001)(66066001)(97736004)(446003)(6512007)(11346002)(6486002)(86362001)(26005)(25786009)(6436002)(486006)(186003)(2616005)(476003)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2791; H:DB6PR0501MB2023.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: INLELg5mKi7MQjpkxAoiJ7Kkf8IJehzsIJMEJXs36ykRlmXokFoDDwMa/YTWTtlMFO/CMRo6SB/TzqmRi7yRFRq2IZ1TjRxKeP6/d8U+F3NeNJxxUFE3OTebe7D5/HrPNsWPss7jzqnxV99RJEW9/QRoWu1Rr3lSjjVBxAnYm8ulwQLsebdAePSY0OTSe8dQsBSOL6ZXh9v1eK739VKctitJQNwpVBcs0tt0CBnzfEqUSRUxxIUpb/Eh6nGifuzGGl87MRYMqhtpnWTIoqP6h5qwcgMFUp+OUaIoDGWy14Bs+D0o67xxuw0HLfJ7pd/x14LW19W/JBdIIBIAtiVu+VTXI8HdRROvVIRCUuAlPJ4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0f607fb-48c6-44ed-9c57-08d62f7de240 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 13:31:43.9525 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2791 Subject: [dpdk-dev] [PATCH v3 2/3] app/testpmd: add commands of modify MAC address 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" add commands to support following actions: - RTE_FLOW_ACTION_TYPE_SET_MAC_SRC - RTE_FLOW_ACTION_TYPE_SET_MAC_DST Signed-off-by: Xiaoyu Min Acked-by: Yongseok Koh --- app/test-pmd/cmdline_flow.c | 50 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 ++++ 2 files changed, 58 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 3efc2d86e..a527b6bb4 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -259,6 +259,10 @@ enum index { ACTION_DEC_TTL, ACTION_SET_TTL, ACTION_SET_TTL_TTL, + ACTION_SET_MAC_SRC, + ACTION_SET_MAC_SRC_MAC_SRC, + ACTION_SET_MAC_DST, + ACTION_SET_MAC_DST_MAC_DST, }; /** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -841,6 +845,8 @@ static const enum index next_action[] = { ACTION_MAC_SWAP, ACTION_DEC_TTL, ACTION_SET_TTL, + ACTION_SET_MAC_SRC, + ACTION_SET_MAC_DST, ZERO, }; @@ -949,6 +955,12 @@ static const enum index action_set_ipv4_src[] = { ZERO, }; +static const enum index action_set_mac_src[] = { + ACTION_SET_MAC_SRC_MAC_SRC, + ACTION_NEXT, + ZERO, +}; + static const enum index action_set_ipv4_dst[] = { ACTION_SET_IPV4_DST_IPV4_DST, ACTION_NEXT, @@ -991,6 +1003,12 @@ static const enum index action_jump[] = { ZERO, }; +static const enum index action_set_mac_dst[] = { + ACTION_SET_MAC_DST_MAC_DST, + ACTION_NEXT, + ZERO, +}; + static int parse_init(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -2670,6 +2688,38 @@ static const struct token token_list[] = { (struct rte_flow_action_set_ttl, ttl_value)), .call = parse_vc_conf, }, + [ACTION_SET_MAC_SRC] = { + .name = "set_mac_src", + .help = "set source mac address", + .priv = PRIV_ACTION(SET_MAC_SRC, + sizeof(struct rte_flow_action_set_mac)), + .next = NEXT(action_set_mac_src), + .call = parse_vc, + }, + [ACTION_SET_MAC_SRC_MAC_SRC] = { + .name = "mac_addr", + .help = "new source mac address", + .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)), + .args = ARGS(ARGS_ENTRY_HTON + (struct rte_flow_action_set_mac, mac_addr)), + .call = parse_vc_conf, + }, + [ACTION_SET_MAC_DST] = { + .name = "set_mac_dst", + .help = "set destination mac address", + .priv = PRIV_ACTION(SET_MAC_DST, + sizeof(struct rte_flow_action_set_mac)), + .next = NEXT(action_set_mac_dst), + .call = parse_vc, + }, + [ACTION_SET_MAC_DST_MAC_DST] = { + .name = "mac_addr", + .help = "new destination mac address to set", + .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)), + .args = ARGS(ARGS_ENTRY_HTON + (struct rte_flow_action_set_mac, mac_addr)), + .call = parse_vc_conf, + }, }; /** Remove and return last entry from argument stack. */ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 77233987b..1ca3e8c20 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3744,6 +3744,14 @@ This section lists supported actions and their attributes, if any. - ``set_ttl``: Set TTL value with specificed value - ``ttl_value {unsigned}``: The new TTL value to be set +- ``set_mac_src``: set source MAC address + + - ``mac_addr {MAC-48}``: new source MAC address + +- ``set_mac_dst``: set destination MAC address + + - ``mac_addr {MAC-48}``: new destination MAC address + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ From patchwork Thu Oct 11 13:31:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyu Min X-Patchwork-Id: 46629 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C6AF1B5BA; Thu, 11 Oct 2018 15:31:50 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00068.outbound.protection.outlook.com [40.107.0.68]) by dpdk.org (Postfix) with ESMTP id 46A401B5B8 for ; Thu, 11 Oct 2018 15:31:48 +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:X-MS-Exchange-SenderADCheck; bh=WvyYisviuOrv8DZcxGodUFGhIqJEiVSdlnXEDN0PlX8=; b=BHFGwQc97fCl77HK7+fhdoK4a75Z9xKFbOs2FNO9iwzKM423G3OA3U4EdMp94usoQ9punyosM3DgA1ZQnivqk0GFlxR+cV2nptgxxYdXX+d7BGAfNHC8pYpGPt/PIsDwBtxse9zlaa1IhSNcpDkUkyXyFHfIEXt2pW0jswSKgRA= Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com (10.168.9.17) by DB6PR0501MB2791.eurprd05.prod.outlook.com (10.172.226.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.23; Thu, 11 Oct 2018 13:31:47 +0000 Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913]) by DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913%3]) with mapi id 15.20.1228.020; Thu, 11 Oct 2018 13:31:47 +0000 From: Jack Min To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" Thread-Topic: [PATCH v3 3/3] net/mlx5: rewrite MAC address by E-Switch Thread-Index: AQHUYWbBJ5EGy0hvb0+4NsMUyiWy3g== Date: Thu, 11 Oct 2018 13:31:46 +0000 Message-ID: <20181011133109.1520-4-jackmin@mellanox.com> References: <20181010131108.24167-1-jackmin@mellanox.com> <20181011133109.1520-1-jackmin@mellanox.com> In-Reply-To: <20181011133109.1520-1-jackmin@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK2PR0302CA0021.apcprd03.prod.outlook.com (2603:1096:202::31) To DB6PR0501MB2023.eurprd05.prod.outlook.com (2603:10a6:4:6::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jackmin@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [118.201.220.138] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0501MB2791; 6:3SWMK0iad5YAe6/Hou5Zn8yMYGunTrHwBGDaJad5h41r6w1JQa7rrTA54qj4cLgOoVrXT4O+FdgOd6Krb51ZEuIk1RK1essHkcFz9t6G9iHyg4vyY8E5KHHkVrbQTVYlhjYjZMn2c0FVwbqgh9Qb0j5G3Rj3MGBbECTpE/sDilTeJKrXgX3wPLNHY/hDUzCDbiSvna5r96uliZCYcV6YuN22EKDK6k/02wYiV/HvnAMDKgm5gEH3mX5FpAajeirn2yrIspX5Yh0I/pBeEV6iqS1GCCkgOt0c1IVWFN0RCPXxw1PD7DPsUcHYAZKJexywON7bY4QOiK/5WGbooSpVbGO21ipTwK0Qm7PYWvw7RK83a9uFhuUp+pqL0clUOIbTK14bWJDfog3c8s7oBuXrLqheam3zg3QGj2U4eJjQYyletGajKKFr0n1mj7WQbiMELHvXcjp/oF8+UxJYcNWjHw==; 5:DcPTsWcFNTlml8GapUPNWac0TA4cSsnuWjHG4wqbceCD/NLSTP4zfodXwtxQfMeLJIBcdpE4fO2KhJZ/f/3+RWov0dDBrAdSJcKr3nCidMaEvdlNXo7ie4I9MkH+Sui+wJbyt/sVg+RI4FGzBV/OWLNifTfMQbVvjgZ1vkc5MjE=; 7:bvNK79p28PDXxL5JLDwlpSzGxc2ctZIRXZe1gKZVZwI0ol9GW0/1kljkjEk0rsXqBau7Q7STYuIhT2++THxU6SUXt8HPn41hFdNdhuOvH44orJCFV64ilLA92niAtgOFDyO7MzR7+VBZowHZ+5m3/rGcX/VVBzWv9dISx665RrQo1MV+d3FTdjYrTEm7FYPYN5+GLNxhwtW4EqFE2UJZBskyvMHHemEWuYcPBP8wjt4h5efszVePR0Wu11LIBDZX x-ms-office365-filtering-correlation-id: 570a005a-4f09-4c10-07c8-08d62f7de42c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2791; x-ms-traffictypediagnostic: DB6PR0501MB2791: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(201708071742011)(7699051); SRVR:DB6PR0501MB2791; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2791; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(39860400002)(396003)(376002)(346002)(199004)(189003)(305945005)(53936002)(7736002)(99286004)(85306007)(105586002)(316002)(478600001)(6506007)(386003)(52116002)(36756003)(106356001)(68736007)(76176011)(110136005)(4326008)(6116002)(81156014)(1076002)(8936002)(8676002)(5250100002)(102836004)(3846002)(81166006)(256004)(14444005)(2900100001)(14454004)(5660300001)(71190400001)(71200400001)(66066001)(6636002)(97736004)(446003)(6512007)(11346002)(6486002)(86362001)(26005)(25786009)(6436002)(486006)(575784001)(186003)(2616005)(476003)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2791; H:DB6PR0501MB2023.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: QqhGMjhE07iIJE8QOahh5OeUiuSewG5i+apXoQ3Y++9psvNsXQwd/53WGXX09GFwAdXH+PoHqjwVJERIbyLW19tICKRj0HauVtfPtv++BM0KB0zy1qmPyR/O4UJkD3FUUJcVcUEne/OZli4ViIeMJbfyQd9wJLHAoLaphyiND3DFpXQ0rOCntQDeZJsZC8f7wr1uyXcXKgzNMN/z6MZ+R02bTUjefzfSAzMWbgXvFGFfoYgW9tpoxhfZS6PUs2TO0cm5+7S7jPSHkrrWc/RqR+ksi/AlBKJg91A1C8hNoAUPrIcOsZ3Y1WMwwrXJ1yE7c1lYFu6w296N+8ZnhRhfdFCF++Vn6RMHMj10MeaiqhY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 570a005a-4f09-4c10-07c8-08d62f7de42c X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 13:31:46.9387 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2791 Subject: [dpdk-dev] [PATCH v3 3/3] net/mlx5: rewrite MAC address by E-Switch 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Offload following modify MAC address actions to E-Switch via TC-Flower driver - RTE_FLOW_ACTION_TYPE_SET_MAC_SRC - RTE_FLOW_ACTION_TYPE_SET_MAC_DST The corresponding rte_flow_item_eth must be present in rte_flow pattern Only support modify outer layer MAC address The example testpmd command is: flow create 0 transfer ingress pattern eth / ipv4 / udp dst is 7000 / end actions set_mac_dst mac_addr dd:00:aa:11:bb:33 / set_mac_src mac_addr bb:00:cc:11:aa:22 / port_id id 1 / end Signed-off-by: Xiaoyu Min Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_flow_tcf.c | 70 +++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index cb07cf652..8ac24ebd5 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -86,6 +86,8 @@ #define MLX5_FLOW_ACTION_SET_TP_DST (1u << 16) #define MLX5_FLOW_ACTION_SET_TTL (1u << 17) #define MLX5_FLOW_ACTION_DEC_TTL (1u << 18) +#define MLX5_FLOW_ACTION_SET_MAC_SRC (1u << 19) +#define MLX5_FLOW_ACTION_SET_MAC_DST (1u << 20) #define MLX5_FLOW_FATE_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index a0a3680d5..885e50235 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -303,7 +303,8 @@ struct flow_tcf_ptoi { (MLX5_FLOW_ACTION_SET_IPV4_SRC | MLX5_FLOW_ACTION_SET_IPV4_DST | \ MLX5_FLOW_ACTION_SET_IPV6_SRC | MLX5_FLOW_ACTION_SET_IPV6_DST | \ MLX5_FLOW_ACTION_SET_TP_SRC | MLX5_FLOW_ACTION_SET_TP_DST | \ - MLX5_FLOW_ACTION_SET_TTL | MLX5_FLOW_ACTION_DEC_TTL) + MLX5_FLOW_ACTION_SET_TTL | MLX5_FLOW_ACTION_DEC_TTL | \ + MLX5_FLOW_ACTION_SET_MAC_SRC | MLX5_FLOW_ACTION_SET_MAC_DST) #define MLX5_TCF_CONFIG_ACTIONS \ (MLX5_FLOW_ACTION_PORT_ID | MLX5_FLOW_ACTION_OF_PUSH_VLAN | \ @@ -328,6 +329,42 @@ struct pedit_parser { }; +/** + * Set pedit key of MAC address + * + * @param[in] actions + * pointer to action specification + * @param[in,out] p_parser + * pointer to pedit_parser + */ +static void +flow_tcf_pedit_key_set_mac(const struct rte_flow_action *actions, + struct pedit_parser *p_parser) +{ + int idx = p_parser->sel.nkeys; + uint32_t off = actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ? + offsetof(struct ether_hdr, s_addr) : + offsetof(struct ether_hdr, d_addr); + const struct rte_flow_action_set_mac *conf = + (const struct rte_flow_action_set_mac *)actions->conf; + + p_parser->keys[idx].off = off; + p_parser->keys[idx].mask = ~UINT32_MAX; + p_parser->keys_ex[idx].htype = TCA_PEDIT_KEY_EX_HDR_TYPE_ETH; + p_parser->keys_ex[idx].cmd = TCA_PEDIT_KEY_EX_CMD_SET; + memcpy(&p_parser->keys[idx].val, + conf->mac_addr, SZ_PEDIT_KEY_VAL); + idx++; + p_parser->keys[idx].off = off + SZ_PEDIT_KEY_VAL; + p_parser->keys[idx].mask = 0xFFFF0000; + p_parser->keys_ex[idx].htype = TCA_PEDIT_KEY_EX_HDR_TYPE_ETH; + p_parser->keys_ex[idx].cmd = TCA_PEDIT_KEY_EX_CMD_SET; + memcpy(&p_parser->keys[idx].val, + conf->mac_addr + SZ_PEDIT_KEY_VAL, + ETHER_ADDR_LEN - SZ_PEDIT_KEY_VAL); + p_parser->sel.nkeys = (++idx); +} + /** * Set pedit key of decrease/set ttl * @@ -508,6 +545,10 @@ flow_tcf_create_pedit_mnl_msg(struct nlmsghdr *nl, flow_tcf_pedit_key_set_dec_ttl(*actions, &p_parser, item_flags); break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: + flow_tcf_pedit_key_set_mac(*actions, &p_parser); + break; default: goto pedit_mnl_msg_done; } @@ -596,6 +637,14 @@ flow_tcf_get_pedit_actions_size(const struct rte_flow_action **actions, keys += NUM_OF_PEDIT_KEYS(TTL_LEN); flags |= MLX5_FLOW_ACTION_DEC_TTL; break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: + keys += NUM_OF_PEDIT_KEYS(ETHER_ADDR_LEN); + flags |= MLX5_FLOW_ACTION_SET_MAC_SRC; + break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: + keys += NUM_OF_PEDIT_KEYS(ETHER_ADDR_LEN); + flags |= MLX5_FLOW_ACTION_SET_MAC_DST; + break; default: goto get_pedit_action_size_done; } @@ -1122,6 +1171,12 @@ flow_tcf_validate(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_DEC_TTL: current_action_flag = MLX5_FLOW_ACTION_DEC_TTL; break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: + current_action_flag = MLX5_FLOW_ACTION_SET_MAC_SRC; + break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: + current_action_flag = MLX5_FLOW_ACTION_SET_MAC_DST; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1227,6 +1282,15 @@ flow_tcf_validate(struct rte_eth_dev *dev, actions, "no IP found in pattern"); } + if (action_flags & + (MLX5_FLOW_ACTION_SET_MAC_SRC | MLX5_FLOW_ACTION_SET_MAC_DST)) { + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L2)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "no ethernet found in" + " pattern"); + } return 0; } @@ -1378,6 +1442,8 @@ flow_tcf_get_actions_and_size(const struct rte_flow_action actions[], case RTE_FLOW_ACTION_TYPE_SET_TP_DST: case RTE_FLOW_ACTION_TYPE_SET_TTL: case RTE_FLOW_ACTION_TYPE_DEC_TTL: + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: size += flow_tcf_get_pedit_actions_size(&actions, &flags); break; @@ -1924,6 +1990,8 @@ flow_tcf_translate(struct rte_eth_dev *dev, struct mlx5_flow *dev_flow, case RTE_FLOW_ACTION_TYPE_SET_TP_DST: case RTE_FLOW_ACTION_TYPE_SET_TTL: case RTE_FLOW_ACTION_TYPE_DEC_TTL: + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: na_act_index = mnl_attr_nest_start(nlh, na_act_index_cur++); flow_tcf_create_pedit_mnl_msg(nlh,