From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0074.outbound.protection.outlook.com [104.47.2.74]) by dpdk.org (Postfix) with ESMTP id 9022C5F44 for ; Fri, 2 Nov 2018 22:38:08 +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:X-MS-Exchange-SenderADCheck; bh=lVe4Cr/Ip4t88+cuBnBThhY63OIdZGYchw3jcp9tzZ8=; b=Ht7ze54jQ0s0Wi3+hb9WmzPewU/EPbT2lLrOkGUeHTip5JyA3Xma54/gbglmOKJY3QBvDjj/5KFjYc3vfGVUR1mcgVBEZ2L2p1/df0RQjYXB4e8R8OYkZMZnChobI7nN5BbsIXVqxr6X1GXwM45k/+5OXm+iNmfBmZns8DYNCmY= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4060.eurprd05.prod.outlook.com (52.134.72.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.25; Fri, 2 Nov 2018 21:38:06 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::f8a1:fcab:94f0:97cc%4]) with mapi id 15.20.1273.030; Fri, 2 Nov 2018 21:38:06 +0000 From: Yongseok Koh To: Slava Ovsiienko CC: Shahaf Shuler , "dev@dpdk.org" Thread-Topic: [PATCH v4 07/13] net/mlx5: add VXLAN support to flow prepare routine Thread-Index: AQHUctTxoABgeOFuWEmBfUp/chAw96U9Av0A Date: Fri, 2 Nov 2018 21:38:06 +0000 Message-ID: <20181102213759.GB15737@mtidpdk.mti.labs.mlnx> References: <1541074741-41368-1-git-send-email-viacheslavo@mellanox.com> <1541181152-15788-1-git-send-email-viacheslavo@mellanox.com> <1541181152-15788-8-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1541181152-15788-8-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR05CA0015.namprd05.prod.outlook.com (2603:10b6:a03:c0::28) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB4060; 6:aiDJG+63W/chICUL9PM9Y+M2h+Oyb7EpJ7oYzLlNyd1QTZjQ211O7RUuLDYTYcdC0/Dko/e4N4g9sK1QRx+mcY6ElxzOiv1ZSBprsbp2vvOmKkK3S645oZNpVgEl5dhFgrLS8XJpln5t9Y1TfxFW0L3a4GxHkSSHin9fiKIFzQLB1vPESiPaV1BkvC9unNNhITZJ+RQfGwuxovQSkI2hK2tf58Af2aG+AVMeiHLgzIQrXuVFmVHnUlHd2gw8OU6P6Upfg1TWlUZl0uoFwjVbgc/8mdPX5cYZzTqSiFjgaOd+Ws/Dr4PlWvGF+KMzrTfnxe3fW4LucDngwnMzPqDSZwZtEO5PfykachS62bRDEXnUQ8p9wmI3pQkCCuXWRRw5q/8G8nPn/ifIqwuvay4gSW1Ifz7cI/7QWkwAYwOyWrb7pkpH6zqqx3YIMGjtwk0qDTnZVbrIoSLtU01ZBTuOGA==; 5:Q1W5Q/J6QbM0VTdHnsM/SWn37h8eetmS2ScTaoTsEvNUU7RSZ76ZoSxyNU5N164ySFxww+2tXFz2lY/QWdQa4Meit3bS3/NEpjsAFPu1r2G9WV6e2l9oiHfwgHzZipBbW/iGfPT/RDIRCVxCwfEZmcIQhx30w4ni/PfdHS6gHWI=; 7:mBtE4hklYf6Vg8C4I57+WAEiqarrpuHmG5BzbVPy6afhQaJjRbO6xJGw4vNm1DAqiHHDqURFHT/5ZEmVLNW5HX/tztXBf9+dbGjryqKe0LBVIs2g4vHPAkX8u5ngFCJa0eeVFGGALqSN5NqkDayBpg== x-ms-office365-filtering-correlation-id: eb362c08-9149-4bca-6cea-08d6410b79da x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB4060; x-ms-traffictypediagnostic: DB3PR0502MB4060: 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)(10201501046)(3231382)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB4060; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4060; x-forefront-prvs: 08444C7C87 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(39860400002)(366004)(136003)(199004)(189003)(3846002)(6116002)(8936002)(2906002)(6636002)(4326008)(71190400001)(71200400001)(81166006)(478600001)(81156014)(8676002)(486006)(105586002)(106356001)(25786009)(68736007)(97736004)(66066001)(6246003)(33656002)(7736002)(86362001)(305945005)(6862004)(1076002)(53936002)(476003)(6436002)(14454004)(256004)(14444005)(5660300001)(229853002)(6486002)(2900100001)(6512007)(9686003)(33896004)(446003)(54906003)(11346002)(6506007)(386003)(186003)(76176011)(99286004)(52116002)(316002)(26005)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4060; H:DB3PR0502MB3980.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: voiSFpHN7D/IQqmAxFGFcX2LLq/pdGTfaD8TjhaXJOB/dc8sKP1C946JVYcYQELQ3iIEha3s/5SvVyyVa2eWIKABcWT3Ir5zHoWQC1gqyRVFnTuAG95N+awZIA/dC3CmFPGHPnb5OTKjR2YS1W8yiIT4yUd1/IA1P1zAfhGM0dkMGFFZpUoAxFoc8CUfe9lTiLZhXr86yOECfhmeuaE//JvdX5haCX16vPP8z96ji/CLLq5+jtVHnPrPhfnt4mzK5Lv3yrlOswvNFTIOsAEXD3WamSXiyodUTw+5vUPCzjgaA3LQXWgb4VEA+HF+E05/LbEAiJZXjAWqT5nSGCpeFFfa7dkacIGcz0nHw5GHfvA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb362c08-9149-4bca-6cea-08d6410b79da X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Nov 2018 21:38:06.7479 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4060 Subject: Re: [dpdk-dev] [PATCH v4 07/13] net/mlx5: add VXLAN support to flow prepare routine 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: Fri, 02 Nov 2018 21:38:08 -0000 On Fri, Nov 02, 2018 at 10:53:19AM -0700, Slava Ovsiienko wrote: > The e-switch Flow prepare function is updated to support VXLAN > encapsulation/and decapsulation actions. The function calculates > buffer size for Netlink message and Flow description structures, > including optional ones for tunneling purposes. >=20 > Suggested-by: Adrien Mazarguil > Signed-off-by: Viacheslav Ovsiienko > --- Acked-by: Yongseok Koh Thanks > drivers/net/mlx5/mlx5_flow_tcf.c | 137 +++++++++++++++++++++++++++++++++= +++++- > 1 file changed, 134 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index 6299069..017f2bd 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -2422,7 +2422,7 @@ struct pedit_parser { > case RTE_FLOW_ITEM_TYPE_IPV6: > size +=3D SZ_NLATTR_TYPE_OF(uint16_t) + /* Ether type. */ > SZ_NLATTR_TYPE_OF(uint8_t) + /* IP proto. */ > - SZ_NLATTR_TYPE_OF(IPV6_ADDR_LEN) * 4; > + SZ_NLATTR_DATA_OF(IPV6_ADDR_LEN) * 4; > /* dst/src IP addr and mask. */ > flags |=3D MLX5_FLOW_LAYER_OUTER_L3_IPV6; > break; > @@ -2438,6 +2438,10 @@ struct pedit_parser { > /* dst/src port and mask. */ > flags |=3D MLX5_FLOW_LAYER_OUTER_L4_TCP; > break; > + case RTE_FLOW_ITEM_TYPE_VXLAN: > + size +=3D SZ_NLATTR_TYPE_OF(uint32_t); > + flags |=3D MLX5_FLOW_LAYER_VXLAN; > + break; > default: > DRV_LOG(WARNING, > "unsupported item %p type %d," > @@ -2451,6 +2455,69 @@ struct pedit_parser { > } > =20 > /** > + * Calculate size of memory to store the VXLAN encapsultion > + * related items in the Netlink message buffer. Items list > + * is specified by RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP action. > + * The item list should be validated. > + * > + * @param[in] action > + * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP action object. > + * List of pattern items to scan data from. > + * > + * @return > + * The size the part of Netlink message buffer to store the > + * VXLAN encapsulation item attributes. > + */ > +static int > +flow_tcf_vxlan_encap_size(const struct rte_flow_action *action) > +{ > + const struct rte_flow_item *items; > + int size =3D 0; > + > + assert(action->type =3D=3D RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP); > + assert(action->conf); > + > + items =3D ((const struct rte_flow_action_vxlan_encap *) > + action->conf)->definition; > + assert(items); > + for (; items->type !=3D RTE_FLOW_ITEM_TYPE_END; items++) { > + switch (items->type) { > + case RTE_FLOW_ITEM_TYPE_VOID: > + break; > + case RTE_FLOW_ITEM_TYPE_ETH: > + /* This item does not require message buffer. */ > + break; > + case RTE_FLOW_ITEM_TYPE_IPV4: > + size +=3D SZ_NLATTR_DATA_OF(IPV4_ADDR_LEN) * 2; > + break; > + case RTE_FLOW_ITEM_TYPE_IPV6: > + size +=3D SZ_NLATTR_DATA_OF(IPV6_ADDR_LEN) * 2; > + break; > + case RTE_FLOW_ITEM_TYPE_UDP: { > + const struct rte_flow_item_udp *udp =3D items->mask; > + > + size +=3D SZ_NLATTR_TYPE_OF(uint16_t); > + if (!udp || udp->hdr.src_port !=3D RTE_BE16(0x0000)) > + size +=3D SZ_NLATTR_TYPE_OF(uint16_t); > + break; > + } > + case RTE_FLOW_ITEM_TYPE_VXLAN: > + size +=3D SZ_NLATTR_TYPE_OF(uint32_t); > + break; > + default: > + assert(false); > + DRV_LOG(WARNING, > + "unsupported item %p type %d," > + " items must be validated" > + " before flow creation", > + (const void *)items, items->type); > + return 0; > + } > + } > + return size; > +} > + > +/** > * Calculate maximum size of memory for flow actions of Linux TC flower = and > * extract specified actions. > * > @@ -2519,6 +2586,29 @@ struct pedit_parser { > SZ_NLATTR_TYPE_OF(uint16_t) + /* VLAN ID. */ > SZ_NLATTR_TYPE_OF(uint8_t); /* VLAN prio. */ > break; > + case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > + size +=3D SZ_NLATTR_NEST + /* na_act_index. */ > + SZ_NLATTR_STRZ_OF("tunnel_key") + > + SZ_NLATTR_NEST + /* TCA_ACT_OPTIONS. */ > + SZ_NLATTR_TYPE_OF(uint8_t); > + size +=3D SZ_NLATTR_TYPE_OF(struct tc_tunnel_key); > + size +=3D flow_tcf_vxlan_encap_size(actions) + > + RTE_ALIGN_CEIL /* preceding encap params. */ > + (sizeof(struct flow_tcf_vxlan_encap), > + MNL_ALIGNTO); > + flags |=3D MLX5_FLOW_ACTION_VXLAN_ENCAP; > + break; > + case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: > + size +=3D SZ_NLATTR_NEST + /* na_act_index. */ > + SZ_NLATTR_STRZ_OF("tunnel_key") + > + SZ_NLATTR_NEST + /* TCA_ACT_OPTIONS. */ > + SZ_NLATTR_TYPE_OF(uint8_t); > + size +=3D SZ_NLATTR_TYPE_OF(struct tc_tunnel_key); > + size +=3D RTE_ALIGN_CEIL /* preceding decap params. */ > + (sizeof(struct flow_tcf_vxlan_decap), > + MNL_ALIGNTO); > + flags |=3D MLX5_FLOW_ACTION_VXLAN_DECAP; > + break; > case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC: > case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST: > case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC: > @@ -2594,12 +2684,15 @@ struct pedit_parser { > uint64_t *item_flags, uint64_t *action_flags, > struct rte_flow_error *error) > { > - size_t size =3D sizeof(struct mlx5_flow) + > + size_t size =3D RTE_ALIGN_CEIL > + (sizeof(struct mlx5_flow), > + alignof(struct flow_tcf_tunnel_hdr)) + > MNL_ALIGN(sizeof(struct nlmsghdr)) + > MNL_ALIGN(sizeof(struct tcmsg)); > struct mlx5_flow *dev_flow; > struct nlmsghdr *nlh; > struct tcmsg *tcm; > + uint8_t *sp, *tun =3D NULL; > =20 > size +=3D flow_tcf_get_items_and_size(attr, items, item_flags); > size +=3D flow_tcf_get_actions_and_size(actions, action_flags); > @@ -2610,14 +2703,52 @@ struct pedit_parser { > "not enough memory to create E-Switch flow"); > return NULL; > } > - nlh =3D mnl_nlmsg_put_header((void *)(dev_flow + 1)); > + sp =3D (uint8_t *)(dev_flow + 1); > + if (*action_flags & MLX5_FLOW_ACTION_VXLAN_ENCAP) { > + sp =3D RTE_PTR_ALIGN > + (sp, alignof(struct flow_tcf_tunnel_hdr)); > + tun =3D sp; > + sp +=3D RTE_ALIGN_CEIL > + (sizeof(struct flow_tcf_vxlan_encap), > + MNL_ALIGNTO); > +#ifndef NDEBUG > + size -=3D RTE_ALIGN_CEIL > + (sizeof(struct flow_tcf_vxlan_encap), > + MNL_ALIGNTO); > +#endif > + } else if (*action_flags & MLX5_FLOW_ACTION_VXLAN_DECAP) { > + sp =3D RTE_PTR_ALIGN > + (sp, alignof(struct flow_tcf_tunnel_hdr)); > + tun =3D sp; > + sp +=3D RTE_ALIGN_CEIL > + (sizeof(struct flow_tcf_vxlan_decap), > + MNL_ALIGNTO); > +#ifndef NDEBUG > + size -=3D RTE_ALIGN_CEIL > + (sizeof(struct flow_tcf_vxlan_decap), > + MNL_ALIGNTO); > +#endif > + } else { > + sp =3D RTE_PTR_ALIGN(sp, MNL_ALIGNTO); > + } > + nlh =3D mnl_nlmsg_put_header(sp); > tcm =3D mnl_nlmsg_put_extra_header(nlh, sizeof(*tcm)); > *dev_flow =3D (struct mlx5_flow){ > .tcf =3D (struct mlx5_flow_tcf){ > +#ifndef NDEBUG > + .nlsize =3D size - RTE_ALIGN_CEIL > + (sizeof(struct mlx5_flow), > + alignof(struct flow_tcf_tunnel_hdr)), > +#endif > + .tunnel =3D (struct flow_tcf_tunnel_hdr *)tun, > .nlh =3D nlh, > .tcm =3D tcm, > }, > }; > + if (*action_flags & MLX5_FLOW_ACTION_VXLAN_DECAP) > + dev_flow->tcf.tunnel->type =3D FLOW_TCF_TUNACT_VXLAN_DECAP; > + else if (*action_flags & MLX5_FLOW_ACTION_VXLAN_ENCAP) > + dev_flow->tcf.tunnel->type =3D FLOW_TCF_TUNACT_VXLAN_ENCAP; > /* > * Generate a reasonably unique handle based on the address of the > * target buffer. > --=20 > 1.8.3.1 >=20