From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30066.outbound.protection.outlook.com [40.107.3.66]) by dpdk.org (Postfix) with ESMTP id 2CE851B4DC for ; Tue, 9 Oct 2018 14:50:36 +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=3J0Pd5GCwPfXR8KxRwM0ALrrXx4NO5cNJbQWc/COG9k=; b=xiXEiIdKk2JYUQfUXS71oc55lCxCGr8hiOBIgNu7llnD4Q3a+H8odvLhc12zEH8HQFbBnGBrx2nCD/ZM5UWwpEx9hOz1cLOJERdKwvVkkLCZHoQM4NTVbB0O4wsdtTgjSZI09yUD2Gob68gFOEswOchJP1oidAGXDxFSV/xyxHw= Received: from VI1PR05MB4431.eurprd05.prod.outlook.com (52.133.13.26) by VI1PR05MB1216.eurprd05.prod.outlook.com (10.162.15.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.28; Tue, 9 Oct 2018 12:50:30 +0000 Received: from VI1PR05MB4431.eurprd05.prod.outlook.com ([fe80::80:564f:9ae9:ed9]) by VI1PR05MB4431.eurprd05.prod.outlook.com ([fe80::80:564f:9ae9:ed9%2]) with mapi id 15.20.1207.024; Tue, 9 Oct 2018 12:50:30 +0000 From: Shahaf Shuler To: Yongseok Koh CC: "dev@dpdk.org" Thread-Topic: [PATCH v2] net/mlx5: support multiple groups and jump action Thread-Index: AQHUXzGjUMhvSmRTa0+Z+g4dqR1qcKUW21vg Date: Tue, 9 Oct 2018 12:50:30 +0000 Message-ID: References: <20181003015640.36306-1-yskoh@mellanox.com> <20181008180552.39671-1-yskoh@mellanox.com> In-Reply-To: <20181008180552.39671-1-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB1216; 6:Qw9XkW08KeSCmQshp4i6kgCmwH1BZDJMJa2SaRwxyT5PK3AVI1+iqNjHs4B1bYl5ltgAm2o2b+YDwNTDmSdXL32VaOrzFOXVLECHnUVI4Co/rCbKFJoZqiot+dtibw1XfoeBg2G0Xk/h8y2LZAh4uvu/jeWAGKjCFRtwsBcw+8swhvwiimP59Wut58B6fWrzFcnJBsruT3GdBavxQrRL765mo3mWFm3DsYrjLeYuMBF0fspnq3Lsh0F3S1JTK+eQ3e8ASTXEl8FEpoSEBqp15pb2+zbO5j7Miq8FfIiwNzVR+qYvHjxuzA8yrqa6KQu4O4gELX+/2GW8K3s1CptdS9UtDLUEkyB2OvulqvVZdWxJ5AJQI/Qlfh2q2RyJxWZJ41K1Nu/74X9FRQG4s3XTxIi3k061mru9DgJm6zspch/IZFs+vzTd77/k0Y/8TN3p6eqgFFdK/rs8egqk9hTCtA==; 5:h+NOcVL+oxG8g+vwIWiKK03XmReOtRmszfTX1Fyshe4tSl9vMSQ0fgoNwvYLOkFz5S415pdVnKmhTM1Y2b4QwIRKbX1lQTip83IGfyTWoWVScYcLKCA3jX4gf3Tul/2tAj5TjPuq7D4/o34lVS7vyljSYwATBb4pMG82fhYOTYc=; 7:x8CA2+Bc3Y+FFSROVF2k1bGxJdAebAujr4o5qcjgkEHGaJqFEbd0aTUG95cqUny4UXjrOXiNTRJ4SO4Lm0dECAyNOKtzhsG2W0IDmu0qL/U6SZo48VFxqXCD+Y+a9hwpudMjpDoJF+gRfGZABP74w+3w2pFuiusUZfZ6WC3VbqSsIGJgfV3Xx5nQ+g/VtiOW/AcUJ7y0L8HZdmK91L1QF+PdNgJoWLrIkovNXxx+i724qWCayT5lTHk0pWbf5ckI x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: eca7bd25-9476-401a-573e-08d62de5cb5c 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:VI1PR05MB1216; x-ms-traffictypediagnostic: VI1PR05MB1216: 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)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991055); SRVR:VI1PR05MB1216; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB1216; x-forefront-prvs: 08200063E9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(136003)(39860400002)(376002)(346002)(199004)(189003)(6116002)(3846002)(14454004)(71190400001)(71200400001)(478600001)(305945005)(7736002)(2900100001)(68736007)(2906002)(25786009)(6636002)(6862004)(81156014)(8936002)(81166006)(86362001)(575784001)(105586002)(74316002)(4326008)(8676002)(106356001)(5660300001)(99286004)(76176011)(6246003)(486006)(7696005)(66066001)(316002)(6506007)(53936002)(102836004)(6436002)(9686003)(186003)(26005)(55016002)(229853002)(33656002)(5250100002)(97736004)(476003)(446003)(11346002)(256004)(14444005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1216; H:VI1PR05MB4431.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: tgm+znHJWWqwZ+k4rlv6bbKZoYC/up6UYhfG3Ru3EH5ih+g7g/HFuNGC/9OkWmrT+FPc8AKmGwf8AZSHph5WcoJGGXKHUh43Mii4a4KNErALWfj9RY2pN3+dKzu10MGj3ky2D6OdJBP/YihmXd/YvF1UqtSBDGDzuTrpZgfxktk2lZLQYLZX//fo0owi04/2nukSVb/NxPhWJLogqmLflV7MU1pUwFXPWXxoSjbUg6sUA4ekAJ/hE9IR34D4GI1Duwf+omEWLnNKvrZ66lY3QSZOrcbfW7Ba6dFgGynAuvYl70cJWMH9U4q/xZ5+Iqv/Dva35zyhPW5ibGRupgWwjrOfNnkVYJ/WUExWTGo7RpU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: eca7bd25-9476-401a-573e-08d62de5cb5c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Oct 2018 12:50:30.1309 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1216 Subject: Re: [dpdk-dev] [PATCH v2] net/mlx5: support multiple groups and jump action 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: Tue, 09 Oct 2018 12:50:36 -0000 Hi Koh, Few comments.=20 Monday, October 8, 2018 9:06 PM=B8 Yongseok Koh: > Subject: [PATCH v2] net/mlx5: support multiple groups and jump action >=20 > rte_flow has 'group' attribute and 'jump' action in order to support mult= iple > groups. This feature is known as multi-table support ('chain' in linux TC > flower) in general because a group means a table of flows. Example > commands are: >=20 > flow create 0 transfer priority 1 ingress > pattern eth / vlan vid is 100 / end > actions jump group 1 / end >=20 > flow create 0 transfer priority 1 ingress > pattern eth / vlan vid is 200 / end > actions jump group 2 / end >=20 > flow create 0 transfer group 1 priority 2 ingress > pattern eth / vlan vid is 100 / > ipv4 dst spec 192.168.40.0 dst prefix 24 / end > actions drop / end >=20 > flow create 0 transfer group 1 priority 2 ingress > pattern end > actions of_pop_vlan / port_id id 1 / end >=20 > flow create 0 transfer group 2 priority 2 ingress > pattern eth / vlan vid is 200 / > ipv4 dst spec 192.168.40.0 dst prefix 24 / end > actions of_pop_vlan / port_id id 2 / end >=20 > flow create 0 transfer group 2 priority 2 ingress > pattern end > actions port_id id 2 / end >=20 > With theses flows, if a packet having vlan 200 and src_ip as 192.168.40.1= , this > packet will firstly hit the 1st flow. Then it will hit the 5th flow becau= se of the > 'jump' action. As a result, the packet will be forwarded to port 2 (VF > representor) with vlan tag being stripped off. If the packet had vlan 100 > instead, it would be dropped by the 3rd flow. >=20 > Signed-off-by: Yongseok Koh > --- >=20 > v2: > * drop ethdev patch as it had already been fixed by Adrien's patch > * move TCF macros from mlx5_flow.h to mlx5_flow_tcf.c >=20 > drivers/net/mlx5/Makefile | 10 +++++ > drivers/net/mlx5/meson.build | 4 ++ > drivers/net/mlx5/mlx5_flow.h | 1 + > drivers/net/mlx5/mlx5_flow_tcf.c | 82 > +++++++++++++++++++++++++++++++++++----- > 4 files changed, 88 insertions(+), 9 deletions(-) >=20 > diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index > ca1de9f21..92bae9dfc 100644 > --- a/drivers/net/mlx5/Makefile > +++ b/drivers/net/mlx5/Makefile > @@ -347,6 +347,16 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto- > config-h.sh > enum TCA_VLAN_PUSH_VLAN_PRIORITY \ > $(AUTOCONF_OUTPUT) > $Q sh -- '$<' '$@' \ > + HAVE_TCA_CHAIN \ > + linux/rtnetlink.h \ > + enum TCA_CHAIN \ > + $(AUTOCONF_OUTPUT) > + $Q sh -- '$<' '$@' \ > + HAVE_TC_ACT_GOTO_CHAIN \ > + linux/pkt_cls.h \ > + define TC_ACT_GOTO_CHAIN \ > + $(AUTOCONF_OUTPUT) > + $Q sh -- '$<' '$@' \ > HAVE_SUPPORTED_40000baseKR4_Full \ > /usr/include/linux/ethtool.h \ > define SUPPORTED_40000baseKR4_Full \ > diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build > index fd93ac162..696624838 100644 > --- a/drivers/net/mlx5/meson.build > +++ b/drivers/net/mlx5/meson.build > @@ -182,6 +182,10 @@ if build > 'TCA_FLOWER_KEY_VLAN_ETH_TYPE' ], > [ 'HAVE_TC_ACT_VLAN', 'linux/tc_act/tc_vlan.h', > 'TCA_VLAN_PUSH_VLAN_PRIORITY' ], > + [ 'HAVE_TCA_CHAIN', 'linux/rtnetlink.h', > + 'TCA_CHAIN' ], > + [ 'HAVE_TC_ACT_GOTO_CHAIN', 'linux/pkt_cls.h', > + 'TC_ACT_GOTO_CHAIN' ], Please keep the dictionary order according to the linux header for the sear= ch.=20 > [ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h', > 'RDMA_NL_NLDEV' ], > [ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h', > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 12de841e8..3ed0ddc58 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -78,6 +78,7 @@ > #define MLX5_FLOW_ACTION_OF_PUSH_VLAN (1u << 8) #define > MLX5_FLOW_ACTION_OF_SET_VLAN_VID (1u << 9) #define > MLX5_FLOW_ACTION_OF_SET_VLAN_PCP (1u << 10) > +#define MLX5_FLOW_ACTION_JUMP (1u << 11) >=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 91f6ef678..fbc4c2bb7 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -148,6 +148,12 @@ struct tc_vlan { > #ifndef HAVE_TCA_FLOWER_KEY_VLAN_ETH_TYPE #define > TCA_FLOWER_KEY_VLAN_ETH_TYPE 25 #endif > +#ifndef HAVE_TCA_CHAIN > +#define TCA_CHAIN 11 > +#endif > +#ifndef HAVE_TC_ACT_GOTO_CHAIN > +#define TC_ACT_GOTO_CHAIN 0x20000000 > +#endif >=20 > #ifndef IPV6_ADDR_LEN > #define IPV6_ADDR_LEN 16 > @@ -225,7 +231,13 @@ struct flow_tcf_ptoi { > unsigned int ifindex; /**< Network interface index. */ }; >=20 > -#define MLX5_TCF_FATE_ACTIONS (MLX5_FLOW_ACTION_DROP | > MLX5_FLOW_ACTION_PORT_ID) > +/* Due to a limitation on driver/FW. */ #define > MLX5_TCF_GROUP_ID_MAX 3 > +#define MLX5_TCF_GROUP_PRIORITY_MAX 14 I guess there is no way to query those and trial and error is overkill for = this first implementation.=20 > + > +#define MLX5_TCF_FATE_ACTIONS \ > + (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \ > + MLX5_FLOW_ACTION_JUMP) > #define MLX5_TCF_VLAN_ACTIONS \ > (MLX5_FLOW_ACTION_OF_POP_VLAN | > MLX5_FLOW_ACTION_OF_PUSH_VLAN | \ > MLX5_FLOW_ACTION_OF_SET_VLAN_VID | > MLX5_FLOW_ACTION_OF_SET_VLAN_PCP) @@ -370,14 +382,25 @@ > flow_tcf_validate_attributes(const struct rte_flow_attr *attr, > struct rte_flow_error *error) > { > /* > - * Supported attributes: no groups, some priorities and ingress only. > - * Don't care about transfer as it is the caller's problem. > + * Supported attributes: groups, some priorities and ingress only. > + * group is supported only if kernel supports chain. Don't care about > + * transfer as it is the caller's problem. > */ > - if (attr->group) > + if (attr->group > MLX5_TCF_GROUP_ID_MAX) > return rte_flow_error_set(error, ENOTSUP, >=20 > RTE_FLOW_ERROR_TYPE_ATTR_GROUP, attr, > - "groups are not supported"); > - if (attr->priority > 0xfffe) > + "group ID larger than " > + > RTE_STR(MLX5_TCF_GROUP_ID_MAX) > + " isn't supported"); > + else if (attr->group > 0 && > + attr->priority > MLX5_TCF_GROUP_PRIORITY_MAX) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, > + attr, > + "lowest priority level is " Lowest or highest? > + > RTE_STR(MLX5_TCF_GROUP_PRIORITY_MAX) > + " when group is configured"); > + else if (attr->priority > 0xfffe) > return rte_flow_error_set(error, ENOTSUP, >=20 > RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, > attr, [... ] > flow_tcf_translate(struct rte_eth_dev *dev, struct mlx5_flow *dev_flow, > mnl_attr_nest_end(nlh, na_act); > mnl_attr_nest_end(nlh, na_act_index); > break; > + case RTE_FLOW_ACTION_TYPE_JUMP: > + conf.jump =3D actions->conf; > + na_act_index =3D > + mnl_attr_nest_start(nlh, > na_act_index_cur++); > + assert(na_act_index); > + mnl_attr_put_strz(nlh, TCA_ACT_KIND, "gact"); > + na_act =3D mnl_attr_nest_start(nlh, > TCA_ACT_OPTIONS); > + assert(na_act); > + mnl_attr_put(nlh, TCA_GACT_PARMS, > + sizeof(struct tc_gact), > + &(struct tc_gact){ > + .action =3D TC_ACT_GOTO_CHAIN | > + conf.jump->group, > + }); > + mnl_attr_nest_end(nlh, na_act); > + mnl_attr_nest_end(nlh, na_act_index); > + break; > case RTE_FLOW_ACTION_TYPE_DROP: > na_act_index =3D > mnl_attr_nest_start(nlh, > na_act_index_cur++); We also spoke about that for group > 0 the flow items can start from the mi= ddle. E.g. on table 0 we have flow rule that redirect all eth/ip to group 1= , and on group 1 the rules can start with udp or tcp.=20 Is this possible today w/o any code change?=20 > -- > 2.11.0