From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80050.outbound.protection.outlook.com [40.107.8.50]) by dpdk.org (Postfix) with ESMTP id 7470723D; Tue, 30 Oct 2018 08:51:30 +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=0WDrPDjZDF6eJPiwc7ujAV8a7SeqzOw3CVvNaN/AQr4=; b=U/BB7KBOj1tPhZgcucIl/ptQKTSZAxaQMKNYeO1qa2VUqHWqbbABF2v5AAqgEM5WOdcD5dNMfr7YMIKA6Yvs27vafZ1OvHcHsFbzuLvaX/l4Vt0u/5mwa1exgu0AhrfgFI0vVuCncqlFNvINYiUgLJynmNpSf5YDUe8/wfgNzU8= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4012.eurprd05.prod.outlook.com (52.134.68.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.20; Tue, 30 Oct 2018 07:51:28 +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.027; Tue, 30 Oct 2018 07:51:28 +0000 From: Yongseok Koh To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh , "stable@dpdk.org" Thread-Topic: [PATCH] net/mlx5: add missing FDIR flow delete Thread-Index: AQHUcCVcQnJJen3d0E6ZcqD3PeF9UA== Date: Tue, 30 Oct 2018 07:51:27 +0000 Message-ID: <20181030075119.40828-1-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0072.namprd07.prod.outlook.com (2603:10b6:a03:60::49) 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; DB3PR0502MB4012; 6:77I2LIpGGZLcM8Oh54XAkEA5OEn3ATkZ2Dyun0M+p06bar0yHwSsZUDBwXRyGoOyQrqd6zxpoMKsikCE1oRrsIgQSKKTaE/LEoQR05xmv6msLXo2aHdga2s+evHKnPnxW+/pST7S7EhH1ir3NfAzUPLUXvvQA/KIGDHuZaai2oDXmca6nINQZzdKWmvI512RnkxDopv4NaqOsX3UViUGOebNYesi6ecu5+poWRaIatoO0hYDpymIOYvaKNCNRcjyIE/lkeX6v/bBMDQT6dkm/qpFgMCmONXUoVW+nulfprenmC7WlYCBuhpqngi1aXyhwXPzqOUt0+tLp080prsv68/lpHuttiiQKvV/yOXBtQcmL7YxIs7xIaw+6IhAbZkl78+iV6P+fXulKBWtdPw6Rh7Fh3HxRkAJb/BhgWM8iJJznetvqUIfXRFMZxH5PMNVFU/Otu/SfFat/CBu6GT8Ig==; 5:8bMDB2ivLOO50Wn3c2Jc55kkibIb8aytiE87NF/ALpbC9lHF40pwB0uCVO4CWwazl7P/jd+64g+D6v0DN9lMQvDVnhDx+ve8DhCt1McVb8DH0Ta9SEyFVt/Agfa8esF2LlovwEmjYO6Blv/quZUJlQI3rOd8MXS/g6HYcBxNM7E=; 7:ZQtvJG0qmfpMIZk0od6UIrYfFHJI5hb3gIPdQluG5MbHXuTtqjNe2yRujmDEWvWCGHSSb9pTPE9+0Sy6zzTfBtUFpkj7uz7B2+x/pvSGImzJZr/2c+DzZ/iEUrCQT3+TFrzZTZ1DW/1FAuuAAHnI4Q== x-ms-office365-filtering-correlation-id: c86cbe91-5c3f-40f8-a6a5-08d63e3c7f2b 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:DB3PR0502MB4012; x-ms-traffictypediagnostic: DB3PR0502MB4012: 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)(3231382)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB4012; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4012; x-forefront-prvs: 08417837C5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(366004)(39860400002)(396003)(189003)(199004)(68736007)(54906003)(26005)(256004)(102836004)(6506007)(386003)(99286004)(4326008)(8936002)(478600001)(7736002)(5250100002)(66066001)(52116002)(6116002)(2906002)(6486002)(3846002)(14454004)(14444005)(97736004)(6862004)(1076002)(53936002)(5660300001)(6636002)(105586002)(86362001)(81156014)(36756003)(81166006)(186003)(8676002)(6436002)(106356001)(6512007)(25786009)(305945005)(476003)(2900100001)(316002)(2616005)(1857600001)(37006003)(486006)(71190400001)(71200400001)(450100002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4012; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: zRB/JuaeEKf6WNPLZhMX9ozxWuqs/8FMfeA94vx5EO9h4k54RN3As3oXXKA/WDCNBztuvhPNW7UHvRwC7zUJT5IWHCk34TUjOcXa7s/QuOi6wN8Jex3eDnajFHntqpLjqNsAmUQvOQKBgPa+wnUaFkhpQDu8c5+9JND596RkI6BE1NxYeI/8CoPeSaVNcdfcPwU4yk3Ry2DJAQDizIKaFDOFaDE6H/Qx1cvmecuZwD/sDNj1avVoBWygWKH1o3wQD9MlXzWtrRGDgGNoRoENWDvgy49VX+oNAY0q8uG7uJr4XX2lwAsseXlDYkX+7NXurAH9IFRNfFD7dva1bYcNg8W+GvfzGqwdasdR+AgN2c0= 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: c86cbe91-5c3f-40f8-a6a5-08d63e3c7f2b X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2018 07:51:27.9946 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4012 Subject: [dpdk-dev] [PATCH] net/mlx5: add missing FDIR flow delete 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, 30 Oct 2018 07:51:30 -0000 Deleting FDIR flow is not implemented by mistake. Also the name of static functions are properly renamed. Fixes: b42c000e37a8 ("net/mlx5: remove flow support") Cc: stable@dpdk.org Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.c | 158 +++++++++++++++++++++++++++++++++------= ---- drivers/net/mlx5/mlx5_flow.h | 2 + 2 files changed, 124 insertions(+), 36 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 2dd481f81a..370cf7792b 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -239,7 +239,6 @@ static const struct rte_flow_ops mlx5_flow_ops =3D { /* Convert FDIR request to Generic flow. */ struct mlx5_fdir { struct rte_flow_attr attr; - struct rte_flow_action actions[2]; struct rte_flow_item items[4]; struct rte_flow_item_eth l2; struct rte_flow_item_eth l2_mask; @@ -259,6 +258,7 @@ struct mlx5_fdir { struct rte_flow_item_udp udp; struct rte_flow_item_tcp tcp; } l4_mask; + struct rte_flow_action actions[2]; struct rte_flow_action_queue queue; }; =20 @@ -2136,6 +2136,7 @@ flow_list_destroy(struct rte_eth_dev *dev, struct mlx= 5_flows *list, */ if (dev->data->dev_started) flow_rxq_flags_trim(dev, flow); + rte_free(flow->fdir); rte_free(flow); } =20 @@ -2453,7 +2454,7 @@ mlx5_flow_query(struct rte_eth_dev *dev, * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_fdir_filter_convert(struct rte_eth_dev *dev, +flow_fdir_filter_convert(struct rte_eth_dev *dev, const struct rte_eth_fdir_filter *fdir_filter, struct mlx5_fdir *attributes) { @@ -2625,6 +2626,69 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, return 0; } =20 +#define FLOW_FDIR_CMP(f1, f2, fld) \ + memcmp(&(f1)->fld, &(f2)->fld, sizeof(f1->fld)) + +/** + * Compare two FDIR flows. If items and actions are identical, the two flo= ws are + * regarded as same. + * + * @param dev + * Pointer to Ethernet device. + * @param f1 + * FDIR flow to compare. + * @param f2 + * FDIR flow to compare. + * + * @return + * Zero on match, 1 otherwise. + */ +static int +flow_fdir_cmp(const struct mlx5_fdir *f1, const struct mlx5_fdir *f2) +{ + if (FLOW_FDIR_CMP(f1, f2, attr) || + FLOW_FDIR_CMP(f1, f2, l2) || + FLOW_FDIR_CMP(f1, f2, l2_mask) || + FLOW_FDIR_CMP(f1, f2, l3) || + FLOW_FDIR_CMP(f1, f2, l3_mask) || + FLOW_FDIR_CMP(f1, f2, l4) || + FLOW_FDIR_CMP(f1, f2, l4_mask) || + FLOW_FDIR_CMP(f1, f2, actions[0])) + return 1; + if (f1->actions[0].type =3D=3D RTE_FLOW_ACTION_TYPE_QUEUE && + FLOW_FDIR_CMP(f1, f2, queue)) + return 1; + return 0; +} + +/** + * Search device flow list to find out a matched FDIR flow. + * + * @param dev + * Pointer to Ethernet device. + * @param fdir_flow + * FDIR flow to lookup. + * + * @return + * Pointer of flow if found, NULL otherwise. + */ +static struct rte_flow * +flow_fdir_filter_lookup(struct rte_eth_dev *dev, struct mlx5_fdir *fdir_fl= ow) +{ + struct priv *priv =3D dev->data->dev_private; + struct rte_flow *flow =3D NULL; + + assert(fdir_flow); + TAILQ_FOREACH(flow, &priv->flows, next) { + if (flow->fdir && !flow_fdir_cmp(flow->fdir, fdir_flow)) { + DRV_LOG(DEBUG, "port %u found FDIR flow %p", + dev->data->port_id, (void *)flow); + break; + } + } + return flow; +} + /** * Add new flow director filter and store it in list. * @@ -2637,32 +2701,38 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_fdir_filter_add(struct rte_eth_dev *dev, +flow_fdir_filter_add(struct rte_eth_dev *dev, const struct rte_eth_fdir_filter *fdir_filter) { struct priv *priv =3D dev->data->dev_private; - struct mlx5_fdir attributes =3D { - .attr.group =3D 0, - .l2_mask =3D { - .dst.addr_bytes =3D "\x00\x00\x00\x00\x00\x00", - .src.addr_bytes =3D "\x00\x00\x00\x00\x00\x00", - .type =3D 0, - }, - }; - struct rte_flow_error error; + struct mlx5_fdir *fdir_flow; struct rte_flow *flow; int ret; =20 - ret =3D mlx5_fdir_filter_convert(dev, fdir_filter, &attributes); + fdir_flow =3D rte_zmalloc(__func__, sizeof(*fdir_flow), 0); + if (!fdir_flow) { + rte_errno =3D ENOMEM; + return -rte_errno; + } + ret =3D flow_fdir_filter_convert(dev, fdir_filter, fdir_flow); if (ret) - return ret; - flow =3D flow_list_create(dev, &priv->flows, &attributes.attr, - attributes.items, attributes.actions, &error); + goto error; + flow =3D flow_fdir_filter_lookup(dev, fdir_flow); if (flow) { - DRV_LOG(DEBUG, "port %u FDIR created %p", dev->data->port_id, - (void *)flow); - return 0; + rte_errno =3D EEXIST; + goto error; } + flow =3D flow_list_create(dev, &priv->flows, &fdir_flow->attr, + fdir_flow->items, fdir_flow->actions, NULL); + if (!flow) + goto error; + assert(!flow->fdir); + flow->fdir =3D fdir_flow; + DRV_LOG(DEBUG, "port %u created FDIR flow %p", + dev->data->port_id, (void *)flow); + return 0; +error: + rte_free(fdir_flow); return -rte_errno; } =20 @@ -2678,12 +2748,28 @@ mlx5_fdir_filter_add(struct rte_eth_dev *dev, * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_fdir_filter_delete(struct rte_eth_dev *dev __rte_unused, - const struct rte_eth_fdir_filter *fdir_filter - __rte_unused) +flow_fdir_filter_delete(struct rte_eth_dev *dev, + const struct rte_eth_fdir_filter *fdir_filter) { - rte_errno =3D ENOTSUP; - return -rte_errno; + struct priv *priv =3D dev->data->dev_private; + struct rte_flow *flow; + struct mlx5_fdir fdir_flow =3D { + .attr.group =3D 0, + }; + int ret; + + ret =3D flow_fdir_filter_convert(dev, fdir_filter, &fdir_flow); + if (ret) + return -rte_errno; + flow =3D flow_fdir_filter_lookup(dev, &fdir_flow); + if (!flow) { + rte_errno =3D ENOENT; + return -rte_errno; + } + flow_list_destroy(dev, &priv->flows, flow); + DRV_LOG(DEBUG, "port %u deleted FDIR flow %p", + dev->data->port_id, (void *)flow); + return 0; } =20 /** @@ -2698,15 +2784,15 @@ mlx5_fdir_filter_delete(struct rte_eth_dev *dev __r= te_unused, * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_fdir_filter_update(struct rte_eth_dev *dev, +flow_fdir_filter_update(struct rte_eth_dev *dev, const struct rte_eth_fdir_filter *fdir_filter) { int ret; =20 - ret =3D mlx5_fdir_filter_delete(dev, fdir_filter); + ret =3D flow_fdir_filter_delete(dev, fdir_filter); if (ret) return ret; - return mlx5_fdir_filter_add(dev, fdir_filter); + return flow_fdir_filter_add(dev, fdir_filter); } =20 /** @@ -2716,7 +2802,7 @@ mlx5_fdir_filter_update(struct rte_eth_dev *dev, * Pointer to Ethernet device. */ static void -mlx5_fdir_filter_flush(struct rte_eth_dev *dev) +flow_fdir_filter_flush(struct rte_eth_dev *dev) { struct priv *priv =3D dev->data->dev_private; =20 @@ -2732,7 +2818,7 @@ mlx5_fdir_filter_flush(struct rte_eth_dev *dev) * Resulting flow director information. */ static void -mlx5_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir= _info) +flow_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir= _info) { struct rte_eth_fdir_masks *mask =3D &dev->data->dev_conf.fdir_conf.mask; @@ -2762,7 +2848,7 @@ mlx5_fdir_info_get(struct rte_eth_dev *dev, struct rt= e_eth_fdir_info *fdir_info) * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_fdir_ctrl_func(struct rte_eth_dev *dev, enum rte_filter_op filter_op, +flow_fdir_ctrl_func(struct rte_eth_dev *dev, enum rte_filter_op filter_op, void *arg) { enum rte_fdir_mode fdir_mode =3D @@ -2779,16 +2865,16 @@ mlx5_fdir_ctrl_func(struct rte_eth_dev *dev, enum r= te_filter_op filter_op, } switch (filter_op) { case RTE_ETH_FILTER_ADD: - return mlx5_fdir_filter_add(dev, arg); + return flow_fdir_filter_add(dev, arg); case RTE_ETH_FILTER_UPDATE: - return mlx5_fdir_filter_update(dev, arg); + return flow_fdir_filter_update(dev, arg); case RTE_ETH_FILTER_DELETE: - return mlx5_fdir_filter_delete(dev, arg); + return flow_fdir_filter_delete(dev, arg); case RTE_ETH_FILTER_FLUSH: - mlx5_fdir_filter_flush(dev); + flow_fdir_filter_flush(dev); break; case RTE_ETH_FILTER_INFO: - mlx5_fdir_info_get(dev, arg); + flow_fdir_info_get(dev, arg); break; default: DRV_LOG(DEBUG, "port %u unknown operation %u", @@ -2829,7 +2915,7 @@ mlx5_dev_filter_ctrl(struct rte_eth_dev *dev, *(const void **)arg =3D &mlx5_flow_ops; return 0; case RTE_ETH_FILTER_FDIR: - return mlx5_fdir_ctrl_func(dev, filter_op, arg); + return flow_fdir_ctrl_func(dev, filter_op, arg); default: DRV_LOG(ERR, "port %u filter type (%d) not supported", dev->data->port_id, filter_type); diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index c24d26ed45..838cf75d17 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -253,7 +253,9 @@ struct rte_flow { /**< Device flows that are part of the flow. */ uint64_t actions; /**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */ + struct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */ }; + typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], --=20 2.11.0