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. *