From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0082.outbound.protection.outlook.com [104.47.1.82]) by dpdk.org (Postfix) with ESMTP id 540631B4D0 for ; Thu, 12 Jul 2018 03:10:41 +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=nmJD/+5wbFLWtoNU2KRSJY0zv5C3TIXcTti1I/d4kHY=; b=gkp7eDJI3EmCYLgZxY7e3bW3PXmtBKW4JxLgLJJmM4ak/LfTKo3oA6nIk080nzzl79bG5UK8+ypVtP/Lnsqsoi2oVVV42RiA34EnPveUJqF5hJqt+tAOcKcK92hiT/WEVHLbS11dW9UB1CoJ4Ie5xZAsLhKEH/xa1Q5XOK5Aers= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; Received: from yongseok-MBP.local (209.116.155.178) by VI1PR0501MB2045.eurprd05.prod.outlook.com (2603:10a6:800:36::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.18; Thu, 12 Jul 2018 01:10:38 +0000 Date: Wed, 11 Jul 2018 18:10:25 -0700 From: Yongseok Koh To: Adrien Mazarguil Cc: Shahaf Shuler , Nelio Laranjeiro , dev@dpdk.org Message-ID: <20180712011024.GG69686@yongseok-MBP.local> References: <20180627173355.4718-1-adrien.mazarguil@6wind.com> <20180627173355.4718-6-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180627173355.4718-6-adrien.mazarguil@6wind.com> User-Agent: Mutt/1.9.3 (2018-01-21) X-Originating-IP: [209.116.155.178] X-ClientProxiedBy: BN6PR11CA0005.namprd11.prod.outlook.com (2603:10b6:405:2::15) To VI1PR0501MB2045.eurprd05.prod.outlook.com (2603:10a6:800:36::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4fe44d6-cffc-424a-5aef-08d5e79447f6 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2045; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2045; 3:r0e5XJ2yE8EBE+fCuow4RGRiroyvBrymOFlGyFf6o/ObS9kO4qSfFeLZQqP0JIt/NcPldme1VML90v6Mxk3p6ItSAIi66VV2bSXdsswNLYHEQBPMxYkEKKt4YAZqMJJRv+qip9gKDCqtD7YFHy6EoHSJV6mZu99wmmCo97NPaA1LVWcc/LF5s4RiUbIuNOYZ//BNC5WX+i/NTI/sxw0MPiPKJvgC8aPzXH9UXV2GtMQm8wxDh12uxbgLhCzP3KF5; 25:AcabKecT5I5TDrUUUQQT+4Ce9F4vHtAatBdxq+Luo7LmcYcgvv6Pt5ZqA7ZunW+M+4Ssb9f7LJ4AN/bl4DMWZ9cSV0nSFLGDDaY+xVdMSasaFJW8AOw8HORBGV3rHa6Q8KQWD4FZ3F9AZXdNPSoHuU2JR+OMXILvdcfMIaghi4TIUYzDVycUI2iRJ5BNU2x7YjJHF2xAcSaLUN2Q99+PA+uzSEZL7sINd9qzldBgEnuiEd/S/6S0M38gkQL5PhOHosUbNlSX/35EpVL9BHRKqMpsos6+7AfLev6ZF7hhk0Gxd+UtnEGhvMpUBqCOyRo03QLd53TN9wWqOk1NWytbOg==; 31:UfEEZ5PntvpPnPanaQOgU7p+4yqO8qlB7m/gntCtCLF8jkruIG2RRR8R+sBcVBOIAW3E6iCa1O7Eh924/gXVREuKWIeB6TKdMbtSQg7DUJXKBVNTQLJzYJ035YvDj1tqjWnCtpAkaTVhC+svyU/BB6Jm/RHS7ESG07NU8zmbrTbvybidy0aBQ3DG2nHw+WllHrq4Q0oA6U4dSoU3BJmhnuJtlmybxNHYHw/uE2Vi03I= X-MS-TrafficTypeDiagnostic: VI1PR0501MB2045: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2045; 20:ByKvvw6zEymBxX3ajI0ADVX0G9RzqsnV0Qk7jlcbm9h7FCOPSd+Rg5Q980Rcb7jEUtjNJHy+fnKSr0Mz72aD8VJA71LUHW6+MQG7TniGTOrCGNYHBFRi1tRgMhID/l7Qjin+Y0mHct5uX8dN4C7AtAU0aAfL3fyYqFSVjh+tqbQydwpUm6tT5klt2Z7zg94j5R+OMK1rBtzgi8QWtXF8TSYm+ZpFrW2EsWSajGRUW0dXtCqv8x5pU7UDq1J13czf4l5Jp0jbbx/DGeTUJGjY5bMrbd4XSmuGUkuPFmvurSDvlK5MO5hUVXv0exc9vIG1VjJz3eT+Ao3ThXMBGpI2GEtOY5XCl04cwbr98G97bn/ruFwh9EO7rJArW9T47G2QiEilcYIZHhSn7aQP+bqtD2LkmwKd1MYgus6oOg4J/MXvtMIV3fnUZ7F0dlq8bkj6pceIad75glxBXDddIY4ulk6GoBFaAXQDJ3EOhkGXERWzp1fFPJtDSoDnmjtE6bLN; 4:4iO73h0TwzmNAvXcgCPriJjJLCMUg6/G2posPGli0TmQQiTCMSFGe5KUD6/jFAK4Sr1K3167X35dXP+OCWBxPd//e9Bl3mwyHQmPFCqKGPp36f7t7LHzGq/wY4xXfWCjH2Ikv37PvlLKoBD94//S27t8tZcNeiIzhocZcne5WA8s7FC+nYn9doN05fW2Gir5XlpTXGxhFd/IcNiNZvupfTyTA3W+/1g8Hfdh52JwEVVchKmhAq1LXGU0D1jWtNylnwZHFI63/LPb8qfsc6hueA== 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)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2045; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2045; X-Forefront-PRVS: 0731AA2DE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(376002)(346002)(396003)(136003)(199004)(189003)(386003)(14444005)(97736004)(7736002)(23726003)(3846002)(6116002)(8936002)(229853002)(1076002)(305945005)(4326008)(486006)(68736007)(25786009)(47776003)(33656002)(446003)(5660300001)(52116002)(11346002)(6246003)(66066001)(76176011)(86362001)(575784001)(7696005)(316002)(53936002)(81166006)(956004)(16586007)(55016002)(81156014)(478600001)(58126008)(476003)(8676002)(54906003)(16526019)(9686003)(33896004)(98436002)(6506007)(6666003)(2906002)(6916009)(105586002)(186003)(106356001)(50466002)(26005)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2045; H:yongseok-MBP.local; 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-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0501MB2045; 23:2UJeyi51BBMlDkYeRXPY24zGrg0niKwu96euYMT?= =?us-ascii?Q?6jeEbqN8G/bFkUEmjVIqsAKH+QKdYbU+hiTXiMUiwDk5oH3bhD1LjZ3zZIfo?= =?us-ascii?Q?yC4pXQ8103b7GvTXMWeXklxv36LE52XuDu592lHnWo7KLGZt9DGr/6ZMdTH9?= =?us-ascii?Q?QBARmke6oQhfH6F69LS6dSKfGP3vH8jLsxVf0ERkC1/UsSaiEThJqkdHjvOL?= =?us-ascii?Q?lUsMABlB6q2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/b/jdQSL3Wtgs3Vn07kMft3M1pzrn7qMIqsAyO69t5MpzDGi86cS9dyHQ0ZWYF3eagGjU9Tqr7g96XQEAywHKAqXWZ2FBFpZbqHl2bNV0n09w==; 5:n38YOlPC3nOavm7bxEfYR1Gfo6OHz1XW0ANK7m6M0WIjfspEttoAyvzuKJTLSr7fbDYbkdyPS8g1k7+YB7ICvjSt78G9FbjzlyMyHm/zj+Ocdz/u1Xq9s4vWNeFWqWttyHNj3Zxjmt8rltvbyEaq6MdwPGSPFlJSVnoU6MTwsGM=; 24:8i6l5u0nXDRt8L6HW+WSdtWSmG4xZymZKGkHh+tHcM7VzPHTgAeqBf99wuFPWmzrULMrJq8RV1rGQpG2i4wplOz2ASN6q8yb2YBvcUej3mk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2045; 7:E8WpONfZV0UarlIn5MSOALHC0tUGgIuTZKdwIYirf520mUYNIAR7ic7RPrZKOQGjJy7PjztNEG2GT9g+l6G1I54SsjdqlMGCT5kqrO3iEi9pFe5S5jEJJNsc960pn6OpD373G2N7zPJhttGEi6CqTnQwdsBAIgCqn8HD+lHwKyDWL+m4z9P9acdOIA6Lc9vOoPlQMnN7FxOdDuq6lc4YQ5ZR6oHlaDy1EQPoGHvYyoQpoeCuGtde8vKjX12Rrrrw X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2018 01:10:38.1048 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4fe44d6-cffc-424a-5aef-08d5e79447f6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2045 Subject: Re: [dpdk-dev] [PATCH 5/6] net/mlx5: add VLAN item and actions to switch flow rules 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: Thu, 12 Jul 2018 01:10:41 -0000 On Wed, Jun 27, 2018 at 08:08:18PM +0200, Adrien Mazarguil wrote: > This enables flow rules to explicitly match VLAN traffic (VLAN pattern > item) and perform various operations on VLAN headers at the switch level > (OF_POP_VLAN, OF_PUSH_VLAN, OF_SET_VLAN_VID and OF_SET_VLAN_PCP actions). > > Testpmd examples: > > - Directing all VLAN traffic received on port ID 1 to port ID 0: > > flow create 1 ingress transfer pattern eth / vlan / end actions > port_id id 0 / end > > - Adding a VLAN header to IPv6 traffic received on port ID 1 and directing > it to port ID 0: > > flow create 1 ingress transfer pattern eth / ipv6 / end actions > of_push_vlan ethertype 0x8100 / of_set_vlan_vid / port_id id 0 / end > > Signed-off-by: Adrien Mazarguil > --- > drivers/net/mlx5/mlx5_nl_flow.c | 177 ++++++++++++++++++++++++++++++++++- > 1 file changed, 173 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_nl_flow.c b/drivers/net/mlx5/mlx5_nl_flow.c > index ad1e001c6..a45d94fae 100644 > --- a/drivers/net/mlx5/mlx5_nl_flow.c > +++ b/drivers/net/mlx5/mlx5_nl_flow.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -36,6 +37,7 @@ enum mlx5_nl_flow_trans { > PATTERN, > ITEM_VOID, > ITEM_ETH, > + ITEM_VLAN, > ITEM_IPV4, > ITEM_IPV6, > ITEM_TCP, > @@ -44,6 +46,10 @@ enum mlx5_nl_flow_trans { > ACTION_VOID, > ACTION_PORT_ID, > ACTION_DROP, > + ACTION_OF_POP_VLAN, > + ACTION_OF_PUSH_VLAN, > + ACTION_OF_SET_VLAN_VID, > + ACTION_OF_SET_VLAN_PCP, > END, > }; > > @@ -52,7 +58,8 @@ enum mlx5_nl_flow_trans { > #define PATTERN_COMMON \ > ITEM_VOID, ACTIONS > #define ACTIONS_COMMON \ > - ACTION_VOID > + ACTION_VOID, ACTION_OF_POP_VLAN, ACTION_OF_PUSH_VLAN, \ > + ACTION_OF_SET_VLAN_VID, ACTION_OF_SET_VLAN_PCP > #define ACTIONS_FATE \ > ACTION_PORT_ID, ACTION_DROP > > @@ -63,7 +70,8 @@ static const enum mlx5_nl_flow_trans *const mlx5_nl_flow_trans[] = { > [ATTR] = TRANS(PATTERN), > [PATTERN] = TRANS(ITEM_ETH, PATTERN_COMMON), > [ITEM_VOID] = TRANS(BACK), > - [ITEM_ETH] = TRANS(ITEM_IPV4, ITEM_IPV6, PATTERN_COMMON), > + [ITEM_ETH] = TRANS(ITEM_IPV4, ITEM_IPV6, ITEM_VLAN, PATTERN_COMMON), > + [ITEM_VLAN] = TRANS(ITEM_IPV4, ITEM_IPV6, PATTERN_COMMON), > [ITEM_IPV4] = TRANS(ITEM_TCP, ITEM_UDP, PATTERN_COMMON), > [ITEM_IPV6] = TRANS(ITEM_TCP, ITEM_UDP, PATTERN_COMMON), > [ITEM_TCP] = TRANS(PATTERN_COMMON), > @@ -72,12 +80,17 @@ static const enum mlx5_nl_flow_trans *const mlx5_nl_flow_trans[] = { > [ACTION_VOID] = TRANS(BACK), > [ACTION_PORT_ID] = TRANS(ACTION_VOID, END), > [ACTION_DROP] = TRANS(ACTION_VOID, END), > + [ACTION_OF_POP_VLAN] = TRANS(ACTIONS_FATE, ACTIONS_COMMON), > + [ACTION_OF_PUSH_VLAN] = TRANS(ACTIONS_FATE, ACTIONS_COMMON), > + [ACTION_OF_SET_VLAN_VID] = TRANS(ACTIONS_FATE, ACTIONS_COMMON), > + [ACTION_OF_SET_VLAN_PCP] = TRANS(ACTIONS_FATE, ACTIONS_COMMON), > [END] = NULL, > }; > > /** Empty masks for known item types. */ > static const union { > struct rte_flow_item_eth eth; > + struct rte_flow_item_vlan vlan; > struct rte_flow_item_ipv4 ipv4; > struct rte_flow_item_ipv6 ipv6; > struct rte_flow_item_tcp tcp; > @@ -87,6 +100,7 @@ static const union { > /** Supported masks for known item types. */ > static const struct { > struct rte_flow_item_eth eth; > + struct rte_flow_item_vlan vlan; > struct rte_flow_item_ipv4 ipv4; > struct rte_flow_item_ipv6 ipv6; > struct rte_flow_item_tcp tcp; > @@ -97,6 +111,11 @@ static const struct { > .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", > .src.addr_bytes = "\xff\xff\xff\xff\xff\xff", > }, > + .vlan = { > + /* PCP and VID only, no DEI. */ > + .tci = RTE_BE16(0xefff), > + .inner_type = RTE_BE16(0xffff), > + }, > .ipv4.hdr = { > .next_proto_id = 0xff, > .src_addr = RTE_BE32(0xffffffff), > @@ -242,9 +261,13 @@ mlx5_nl_flow_transpose(void *buf, > unsigned int n; > uint32_t act_index_cur; > bool eth_type_set; > + bool vlan_present; > + bool vlan_eth_type_set; > bool ip_proto_set; > struct nlattr *na_flower; > struct nlattr *na_flower_act; > + struct nlattr *na_vlan_id; > + struct nlattr *na_vlan_priority; > const enum mlx5_nl_flow_trans *trans; > const enum mlx5_nl_flow_trans *back; > > @@ -256,15 +279,20 @@ mlx5_nl_flow_transpose(void *buf, > n = 0; > act_index_cur = 0; > eth_type_set = false; > + vlan_present = false; > + vlan_eth_type_set = false; > ip_proto_set = false; > na_flower = NULL; > na_flower_act = NULL; > + na_vlan_id = NULL; > + na_vlan_priority = NULL; > trans = TRANS(ATTR); > back = trans; > trans: > switch (trans[n++]) { > union { > const struct rte_flow_item_eth *eth; > + const struct rte_flow_item_vlan *vlan; > const struct rte_flow_item_ipv4 *ipv4; > const struct rte_flow_item_ipv6 *ipv6; > const struct rte_flow_item_tcp *tcp; > @@ -272,6 +300,11 @@ mlx5_nl_flow_transpose(void *buf, > } spec, mask; > union { > const struct rte_flow_action_port_id *port_id; > + const struct rte_flow_action_of_push_vlan *of_push_vlan; > + const struct rte_flow_action_of_set_vlan_vid * > + of_set_vlan_vid; > + const struct rte_flow_action_of_set_vlan_pcp * > + of_set_vlan_pcp; > } conf; > struct nlmsghdr *nlh; > struct tcmsg *tcm; > @@ -408,6 +441,58 @@ mlx5_nl_flow_transpose(void *buf, > goto error_nobufs; > ++item; > break; > + case ITEM_VLAN: > + if (item->type != RTE_FLOW_ITEM_TYPE_VLAN) > + goto trans; > + mask.vlan = mlx5_nl_flow_item_mask > + (item, &rte_flow_item_vlan_mask, > + &mlx5_nl_flow_mask_supported.vlan, > + &mlx5_nl_flow_mask_empty.vlan, > + sizeof(mlx5_nl_flow_mask_supported.vlan), error); > + if (!mask.vlan) > + return -rte_errno; > + if (!eth_type_set && > + !mnl_attr_put_u16_check(buf, size, > + TCA_FLOWER_KEY_ETH_TYPE, > + RTE_BE16(ETH_P_8021Q))) > + goto error_nobufs; > + eth_type_set = 1; > + vlan_present = 1; > + if (mask.vlan == &mlx5_nl_flow_mask_empty.vlan) { > + ++item; > + break; > + } > + spec.vlan = item->spec; > + if ((mask.vlan->tci & RTE_BE16(0xe000) && > + (mask.vlan->tci & RTE_BE16(0xe000)) != RTE_BE16(0xe000)) || > + (mask.vlan->tci & RTE_BE16(0x0fff) && > + (mask.vlan->tci & RTE_BE16(0x0fff)) != RTE_BE16(0x0fff)) || > + (mask.vlan->inner_type && > + mask.vlan->inner_type != RTE_BE16(0xffff))) > + return rte_flow_error_set > + (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM_MASK, > + mask.vlan, > + "no support for partial masks on" > + " \"tci\" (PCP and VID parts) and" > + " \"inner_type\" fields"); > + if (mask.vlan->inner_type) { > + if (!mnl_attr_put_u16_check > + (buf, size, TCA_FLOWER_KEY_VLAN_ETH_TYPE, > + spec.vlan->inner_type)) > + goto error_nobufs; > + vlan_eth_type_set = 1; > + } > + if ((mask.vlan->tci & RTE_BE16(0xe000) && > + !mnl_attr_put_u8_check > + (buf, size, TCA_FLOWER_KEY_VLAN_PRIO, > + (rte_be_to_cpu_16(spec.vlan->tci) >> 13) & 0x7)) || > + (mask.vlan->tci & RTE_BE16(0x0fff) && > + !mnl_attr_put_u16_check > + (buf, size, TCA_FLOWER_KEY_VLAN_ID, > + spec.vlan->tci & RTE_BE16(0x0fff)))) > + goto error_nobufs; > + ++item; > + break; > case ITEM_IPV4: > if (item->type != RTE_FLOW_ITEM_TYPE_IPV4) > goto trans; > @@ -418,12 +503,15 @@ mlx5_nl_flow_transpose(void *buf, > sizeof(mlx5_nl_flow_mask_supported.ipv4), error); > if (!mask.ipv4) > return -rte_errno; > - if (!eth_type_set && > + if ((!eth_type_set || !vlan_eth_type_set) && > !mnl_attr_put_u16_check(buf, size, > + vlan_present ? > + TCA_FLOWER_KEY_VLAN_ETH_TYPE : > TCA_FLOWER_KEY_ETH_TYPE, > RTE_BE16(ETH_P_IP))) > goto error_nobufs; > eth_type_set = 1; > + vlan_eth_type_set = 1; > if (mask.ipv4 == &mlx5_nl_flow_mask_empty.ipv4) { > ++item; > break; > @@ -470,12 +558,15 @@ mlx5_nl_flow_transpose(void *buf, > sizeof(mlx5_nl_flow_mask_supported.ipv6), error); > if (!mask.ipv6) > return -rte_errno; > - if (!eth_type_set && > + if ((!eth_type_set || !vlan_eth_type_set) && > !mnl_attr_put_u16_check(buf, size, > + vlan_present ? > + TCA_FLOWER_KEY_VLAN_ETH_TYPE : > TCA_FLOWER_KEY_ETH_TYPE, > RTE_BE16(ETH_P_IPV6))) > goto error_nobufs; > eth_type_set = 1; > + vlan_eth_type_set = 1; > if (mask.ipv6 == &mlx5_nl_flow_mask_empty.ipv6) { > ++item; > break; > @@ -681,6 +772,84 @@ mlx5_nl_flow_transpose(void *buf, > mnl_attr_nest_end(buf, act_index); > ++action; > break; > + case ACTION_OF_POP_VLAN: > + if (action->type != RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) > + goto trans; > + conf.of_push_vlan = NULL; > + i = TCA_VLAN_ACT_POP; > + goto action_of_vlan; > + case ACTION_OF_PUSH_VLAN: > + if (action->type != RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) > + goto trans; > + conf.of_push_vlan = action->conf; > + i = TCA_VLAN_ACT_PUSH; > + goto action_of_vlan; > + case ACTION_OF_SET_VLAN_VID: > + if (action->type != RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) > + goto trans; > + conf.of_set_vlan_vid = action->conf; > + if (na_vlan_id) > + goto override_na_vlan_id; > + i = TCA_VLAN_ACT_MODIFY; > + goto action_of_vlan; > + case ACTION_OF_SET_VLAN_PCP: > + if (action->type != RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) > + goto trans; > + conf.of_set_vlan_pcp = action->conf; > + if (na_vlan_priority) > + goto override_na_vlan_priority; > + i = TCA_VLAN_ACT_MODIFY; > + goto action_of_vlan; > +action_of_vlan: > + act_index = > + mnl_attr_nest_start_check(buf, size, act_index_cur++); > + if (!act_index || > + !mnl_attr_put_strz_check(buf, size, TCA_ACT_KIND, "vlan")) > + goto error_nobufs; > + act = mnl_attr_nest_start_check(buf, size, TCA_ACT_OPTIONS); > + if (!act) > + goto error_nobufs; > + if (!mnl_attr_put_check(buf, size, TCA_VLAN_PARMS, > + sizeof(struct tc_vlan), > + &(struct tc_vlan){ > + .action = TC_ACT_PIPE, > + .v_action = i, > + })) > + goto error_nobufs; > + if (i == TCA_VLAN_ACT_POP) { > + mnl_attr_nest_end(buf, act); > + ++action; > + break; > + } > + if (i == TCA_VLAN_ACT_PUSH && > + !mnl_attr_put_u16_check(buf, size, > + TCA_VLAN_PUSH_VLAN_PROTOCOL, > + conf.of_push_vlan->ethertype)) > + goto error_nobufs; > + na_vlan_id = mnl_nlmsg_get_payload_tail(buf); > + if (!mnl_attr_put_u16_check(buf, size, TCA_VLAN_PAD, 0)) > + goto error_nobufs; > + na_vlan_priority = mnl_nlmsg_get_payload_tail(buf); > + if (!mnl_attr_put_u8_check(buf, size, TCA_VLAN_PAD, 0)) > + goto error_nobufs; > + mnl_attr_nest_end(buf, act); > + mnl_attr_nest_end(buf, act_index); > + if (action->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) { > +override_na_vlan_id: > + na_vlan_id->nla_type = TCA_VLAN_PUSH_VLAN_ID; > + *(uint16_t *)mnl_attr_get_payload(na_vlan_id) = > + rte_be_to_cpu_16 > + (conf.of_set_vlan_vid->vlan_vid); > + } else if (action->type == > + RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) { > +override_na_vlan_priority: > + na_vlan_priority->nla_type = > + TCA_VLAN_PUSH_VLAN_PRIORITY; > + *(uint8_t *)mnl_attr_get_payload(na_vlan_priority) = > + conf.of_set_vlan_pcp->vlan_pcp; > + } > + ++action; > + break; I'm wondering if there's no need to check the existence of VLAN in pattern when having VLAN modification actions. For example, if flow has POP_VLAN action, its pattern has to have VLAN item, doesn't it? Even though kernel driver has such validation checks, mlx5_flow_validate() can't validate it. In the PRM, 8.18.2.7 Packet Classification Ambiguities ... In addition, a flow should not match or attempt to modify (Modify Header action, Pop VLAN action) non-existing fields of a packet, as defined by the packet classification process. ... Thanks, Yongseok > case END: > if (item->type != RTE_FLOW_ITEM_TYPE_END || > action->type != RTE_FLOW_ACTION_TYPE_END) > -- > 2.11.0