From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0073.outbound.protection.outlook.com [104.47.0.73]) by dpdk.org (Postfix) with ESMTP id D231F378B for ; Wed, 19 Sep 2018 09:21:56 +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=oncnDQLZ9PkXkYHojUlp/YGY1YAua7nGl9h0DBg0dEY=; b=WUnHZGKJbwNx64dUx4oxpIjZTQ7fEfke04zTS+H7bM+rVF3Ypl0xgJ3iDyR+vZbonrd3Luw5KYrEtxvGGmzo1qN9J5LfNhSj6npfbj5q2zTWftZNkTZ8QJtkLG0vQG293+Q5MJWq+NONp/uvGuCBv52CRHzA0YNWLgp+yBrXZeM= 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.1143.18; Wed, 19 Sep 2018 07:21:55 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::452:cfe7:8363:61c1]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::452:cfe7:8363:61c1%2]) with mapi id 15.20.1143.017; Wed, 19 Sep 2018 07:21:55 +0000 From: Yongseok Koh To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh Thread-Topic: [PATCH 1/3] net/mlx5: add abstraction for multiple flow drivers Thread-Index: AQHUT+lx0K5QmXSaw0qhPWK5YpR2OQ== Date: Wed, 19 Sep 2018 07:21:54 +0000 Message-ID: <20180919072143.23211-2-yskoh@mellanox.com> References: <20180919072143.23211-1-yskoh@mellanox.com> In-Reply-To: <20180919072143.23211-1-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR03CA0020.namprd03.prod.outlook.com (2603:10b6:a02:a8::33) 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:EdkIvryFdxixjdUbw1W2PyZyJ1Pg2v7mJR8poFoMOJAUWDxyS7RZPGqetk7IOXGHHBmTB1GelQnWC0bG7ICQzA1EY/XCDIggUswnYSuaVs8d1A8JXNLr4XshUa9GFKGQ17LaDW0Zrq4dXHS7d2nmDL6xIE/jSbwaFLnTSehMZhFKa4mlrl/kCixSTtfrUsIhR//rtqPzD67B24uQBMSfKPUdqBYqMg7Fn38xdGS5WWdVwjgPLwcwbLaXjNZbPiI3l/Qx9bKQ4pGgLL44EFySamQIiVtlhyqDN5E2IpCURWbZ0ELOJbek3W+J2bCLqlYAobBez6B3PBB6M9oUiFmlV942urt81RFBQgvAvn8IKXex6YSSFsQPAw++4W5Blvz0iwdlU32z4aAVnHlDeC084lkDBPvqsRc01ibUzH7kzdDHVM3XilHI2pzeC+5N9LAoFWEjMLmyDnbbccxKv3PMqQ==; 5:T7a7t1mTzpu3Ep28PNlEyviK22Q5vd08Io2ZYpSpsREg1mDfhq5pClfCz07IFGXujmFH12jZmca1BCUYUWedovXCp5AoXaA7ec3nHRgljeQkh/GePSw48HcW/7IORaTIs2qiwo3/Iyu4CmcABOgZV2Jat2qnqME33BFtmm/OAdg=; 7:HvbU29ARy2hFsdBpyYs/iYQzFTuicDO4Q/mgXetO7YrSMqU+qq1LBLGFBbX8zKmioLDvGNOHFIA3q6CuLY35ejkejF3Eom1wy1ewUls2KyxliS2qTMj4j2TueUBdzO2f1YUOTRJ//25smR9anl6fATZKTYqe1eu32ccJbY1B+tYqYqR17ptZ0Pbr/PBdDY22lgluEzyyNHSIume6erlD+SMngZqK3eWGM81zyVgadc07EzK2r+k/7Xpt/BQZjzMk x-ms-office365-filtering-correlation-id: 7fda890d-0f8a-4343-bbb3-08d61e0093a9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(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)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(201708071742011)(7699050); SRVR:DB3PR0502MB4060; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4060; x-forefront-prvs: 0800C0C167 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(346002)(396003)(376002)(39860400002)(199004)(189003)(3846002)(6512007)(68736007)(99286004)(6436002)(575784001)(6486002)(86362001)(97736004)(478600001)(2900100001)(6116002)(4326008)(2906002)(6862004)(1076002)(106356001)(54906003)(25786009)(36756003)(8676002)(8936002)(81156014)(316002)(486006)(5660300001)(66066001)(105586002)(446003)(37006003)(107886003)(102836004)(81166006)(476003)(305945005)(7736002)(2616005)(11346002)(6636002)(5250100002)(76176011)(256004)(53936002)(386003)(14444005)(14454004)(26005)(52116002)(53946003)(6506007); 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: SwlZ+heeS7y7QClzAXIKBZwEEsyGH/rAzBakGwNu3sQC3w2xRIkuMgVsXF5P5TIxUYUshVaxdJVG05Ay5W3AgYV67PONcF9T1wiNuIquWPFqetF8eO4Y6q/SeveJsOCbt24tnoiz8MUNJGScNrGa70H7wncsZpA5e44vZrlz0I4citnvvFaZ5dvnCuQTmSxuEbhaEPcARbf5s92OOm6KKLVCkyYDPljye6WGUypOp+o8UOf1MoyMwhLfiAvGozZ5BIKSvvhlBLu234wPfHf7bqF0p/BPx610hVazBbfHTX57DPU6UTY3srNNudORWKcUAztC7pCagKiZSiSQ7AXjFMu84LzMqHmxAW5MW6gV6sw= 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: 7fda890d-0f8a-4343-bbb3-08d61e0093a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2018 07:21:54.9964 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4060 Subject: [dpdk-dev] [PATCH 1/3] net/mlx5: add abstraction for multiple flow drivers 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: Wed, 19 Sep 2018 07:21:57 -0000 Flow engine has to support multiple driver paths. Verbs/DV for NIC flow steering and Linux TC flower for E-Switch flow steering. In the future, another flow driver could be added (devX). Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5.c | 1 - drivers/net/mlx5/mlx5_flow.c | 348 +++++++++++++++++++++++++++++++++= ---- drivers/net/mlx5/mlx5_flow.h | 17 +- drivers/net/mlx5/mlx5_flow_dv.c | 26 +-- drivers/net/mlx5/mlx5_flow_verbs.c | 20 +-- 5 files changed, 335 insertions(+), 77 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d5936091b..02324ef4f 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1192,7 +1192,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (err < 0) goto error; priv->config.flow_prio =3D err; - mlx5_flow_init_driver_ops(eth_dev); /* * Once the device is added to the list of memory event * callback, its global MR cache table cannot be expanded diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 677cc7a32..2d3158a6f 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -37,6 +37,23 @@ extern const struct eth_dev_ops mlx5_dev_ops; extern const struct eth_dev_ops mlx5_dev_ops_isolate; =20 +/** Device flow drivers. */ +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops; +#endif +extern const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops; + +const struct mlx5_flow_driver_ops mlx5_flow_null_drv_ops; + +const struct mlx5_flow_driver_ops *flow_drv_ops[] =3D { + [MLX5_FLOW_TYPE_MIN] =3D &mlx5_flow_null_drv_ops, +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + [MLX5_FLOW_TYPE_DV] =3D &mlx5_flow_dv_drv_ops, +#endif + [MLX5_FLOW_TYPE_VERBS] =3D &mlx5_flow_verbs_drv_ops, + [MLX5_FLOW_TYPE_MAX] =3D &mlx5_flow_null_drv_ops +}; + enum mlx5_expansion { MLX5_EXPANSION_ROOT, MLX5_EXPANSION_ROOT_OUTER, @@ -282,9 +299,6 @@ static struct mlx5_flow_tunnel_info tunnels_info[] =3D = { }, }; =20 -/* Holds the nic operations that should be used. */ -struct mlx5_flow_driver_ops nic_ops; - /** * Discover the maximum number of priority available. * @@ -1511,6 +1525,284 @@ mlx5_flow_validate_item_mpls(const struct rte_flow_= item *item __rte_unused, " update."); } =20 +static int +flow_null_validate(struct rte_eth_dev *dev __rte_unused, + const struct rte_flow_attr *attr __rte_unused, + const struct rte_flow_item items[] __rte_unused, + const struct rte_flow_action actions[] __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + rte_errno =3D ENOTSUP; + return -rte_errno; +} + +static struct mlx5_flow * +flow_null_prepare(const struct rte_flow_attr *attr __rte_unused, + const struct rte_flow_item items[] __rte_unused, + const struct rte_flow_action actions[] __rte_unused, + uint64_t *item_flags __rte_unused, + uint64_t *action_flags __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + rte_errno =3D ENOTSUP; + return NULL; +} + +static int +flow_null_translate(struct rte_eth_dev *dev __rte_unused, + struct mlx5_flow *dev_flow __rte_unused, + const struct rte_flow_attr *attr __rte_unused, + const struct rte_flow_item items[] __rte_unused, + const struct rte_flow_action actions[] __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + rte_errno =3D ENOTSUP; + return -rte_errno; +} + +static int +flow_null_apply(struct rte_eth_dev *dev __rte_unused, + struct rte_flow *flow __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + rte_errno =3D ENOTSUP; + return -rte_errno; +} + +static void +flow_null_remove(struct rte_eth_dev *dev __rte_unused, + struct rte_flow *flow __rte_unused) +{ +} + +static void +flow_null_destroy(struct rte_eth_dev *dev __rte_unused, + struct rte_flow *flow __rte_unused) +{ +} + +/* Void driver to protect from null pointer reference. */ +const struct mlx5_flow_driver_ops mlx5_flow_null_drv_ops =3D { + .validate =3D flow_null_validate, + .prepare =3D flow_null_prepare, + .translate =3D flow_null_translate, + .apply =3D flow_null_apply, + .remove =3D flow_null_remove, + .destroy =3D flow_null_destroy, +}; + +/** + * Select flow driver type according to flow attributes and device + * configuration. + * + * @param[in] dev + * Pointer to the dev structure. + * @param[in] attr + * Pointer to the flow attributes. + * + * @return + * flow driver type if supported, MLX5_FLOW_TYPE_MAX otherwise. + */ +static enum mlx5_flow_drv_type +flow_get_drv_type(struct rte_eth_dev *dev __rte_unused, + const struct rte_flow_attr *attr) +{ + struct priv *priv __rte_unused =3D dev->data->dev_private; + enum mlx5_flow_drv_type type =3D MLX5_FLOW_TYPE_MAX; + + if (!attr->transfer) { +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + type =3D priv->config.dv_flow_en ? MLX5_FLOW_TYPE_DV : + MLX5_FLOW_TYPE_VERBS; +#else + type =3D MLX5_FLOW_TYPE_VERBS; +#endif + } + return type; +} + +#define flow_get_drv_ops(type) flow_drv_ops[type] + +/** + * Flow driver validation API. This abstracts calling driver specific func= tions. + * The type of flow driver is determined according to flow attributes. + * + * @param[in] dev + * Pointer to the dev structure. + * @param[in] attr + * Pointer to the flow attributes. + * @param[in] items + * Pointer to the list of items. + * @param[in] actions + * Pointer to the list of actions. + * @param[out] error + * Pointer to the error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_ernno is set. + */ +static inline int +flow_drv_validate(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + const struct mlx5_flow_driver_ops *fops; + enum mlx5_flow_drv_type type =3D flow_get_drv_type(dev, attr); + + fops =3D flow_get_drv_ops(type); + return fops->validate(dev, attr, items, actions, error); +} + +/** + * Flow driver preparation API. This abstracts calling driver specific + * functions. Parent flow (rte_flow) should have driver type (drv_type). I= t + * calculates the size of memory required for device flow, allocates the m= emory, + * initializes the device flow and returns the pointer. + * + * @param[in] attr + * Pointer to the flow attributes. + * @param[in] items + * Pointer to the list of items. + * @param[in] actions + * Pointer to the list of actions. + * @param[out] item_flags + * Pointer to bit mask of all items detected. + * @param[out] action_flags + * Pointer to bit mask of all actions detected. + * @param[out] error + * Pointer to the error structure. + * + * @return + * Pointer to device flow on success, otherwise NULL and rte_ernno is se= t. + */ +static inline struct mlx5_flow * +flow_drv_prepare(struct rte_flow *flow, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + uint64_t *item_flags, + uint64_t *action_flags, + struct rte_flow_error *error) +{ + const struct mlx5_flow_driver_ops *fops; + enum mlx5_flow_drv_type type =3D flow->drv_type; + + assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX); + fops =3D flow_get_drv_ops(type); + return fops->prepare(attr, items, actions, item_flags, action_flags, + error); +} + +/** + * Flow driver translation API. This abstracts calling driver specific + * functions. Parent flow (rte_flow) should have driver type (drv_type). I= t + * translates a generic flow into a driver flow. flow_drv_prepare() must + * precede. + * + * + * @param[in] dev + * Pointer to the rte dev structure. + * @param[in, out] dev_flow + * Pointer to the mlx5 flow. + * @param[in] attr + * Pointer to the flow attributes. + * @param[in] items + * Pointer to the list of items. + * @param[in] actions + * Pointer to the list of actions. + * @param[out] error + * Pointer to the error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_ernno is set. + */ +static inline int +flow_drv_translate(struct rte_eth_dev *dev, struct mlx5_flow *dev_flow, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + const struct mlx5_flow_driver_ops *fops; + enum mlx5_flow_drv_type type =3D dev_flow->flow->drv_type; + + assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX); + fops =3D flow_get_drv_ops(type); + return fops->translate(dev, dev_flow, attr, items, actions, error); +} + +/** + * Flow driver apply API. This abstracts calling driver specific functions= . + * Parent flow (rte_flow) should have driver type (drv_type). It applies + * translated driver flows on to device. flow_drv_translate() must precede= . + * + * @param[in] dev + * Pointer to Ethernet device structure. + * @param[in, out] flow + * Pointer to flow structure. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static inline int +flow_drv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, + struct rte_flow_error *error) +{ + const struct mlx5_flow_driver_ops *fops; + enum mlx5_flow_drv_type type =3D flow->drv_type; + + assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX); + fops =3D flow_get_drv_ops(type); + return fops->apply(dev, flow, error); +} + +/** + * Flow driver remove API. This abstracts calling driver specific function= s. + * Parent flow (rte_flow) should have driver type (drv_type). It removes a= flow + * on device. All the resources of the flow should be freed by calling + * flow_dv_destroy(). + * + * @param[in] dev + * Pointer to Ethernet device. + * @param[in, out] flow + * Pointer to flow structure. + */ +static inline void +flow_drv_remove(struct rte_eth_dev *dev, struct rte_flow *flow) +{ + const struct mlx5_flow_driver_ops *fops; + enum mlx5_flow_drv_type type =3D flow->drv_type; + + assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX); + fops =3D flow_get_drv_ops(type); + fops->remove(dev, flow); +} + +/** + * Flow driver destroy API. This abstracts calling driver specific functio= ns. + * Parent flow (rte_flow) should have driver type (drv_type). It removes a= flow + * on device and releases resources of the flow. + * + * @param[in] dev + * Pointer to Ethernet device. + * @param[in, out] flow + * Pointer to flow structure. + */ +static inline void +flow_drv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow) +{ + const struct mlx5_flow_driver_ops *fops; + enum mlx5_flow_drv_type type =3D flow->drv_type; + + assert(type > MLX5_FLOW_TYPE_MIN && type < MLX5_FLOW_TYPE_MAX); + fops =3D flow_get_drv_ops(type); + fops->destroy(dev, flow); +} + /** * Validate a flow supported by the NIC. * @@ -1526,7 +1818,7 @@ mlx5_flow_validate(struct rte_eth_dev *dev, { int ret; =20 - ret =3D nic_ops.validate(dev, attr, items, actions, error); + ret =3D flow_drv_validate(dev, attr, items, actions, error); if (ret < 0) return ret; return 0; @@ -1616,7 +1908,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, uint32_t i; uint32_t flow_size; =20 - ret =3D mlx5_flow_validate(dev, attr, items, actions, error); + ret =3D flow_drv_validate(dev, attr, items, actions, error); if (ret < 0) return NULL; flow_size =3D sizeof(struct rte_flow); @@ -1627,6 +1919,9 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, else flow_size +=3D RTE_ALIGN_CEIL(sizeof(uint16_t), sizeof(void *)); flow =3D rte_calloc(__func__, 1, flow_size, 0); + flow->drv_type =3D flow_get_drv_type(dev, attr); + assert(flow->drv_type > MLX5_FLOW_TYPE_MIN && + flow->drv_type < MLX5_FLOW_TYPE_MAX); flow->queue =3D (void *)(flow + 1); LIST_INIT(&flow->dev_flows); if (rss && rss->types) { @@ -1644,21 +1939,21 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, buf->entry[0].pattern =3D (void *)(uintptr_t)items; } for (i =3D 0; i < buf->entries; ++i) { - dev_flow =3D nic_ops.prepare(attr, buf->entry[i].pattern, - actions, &item_flags, - &action_flags, error); + dev_flow =3D flow_drv_prepare(flow, attr, buf->entry[i].pattern, + actions, &item_flags, &action_flags, + error); if (!dev_flow) goto error; dev_flow->flow =3D flow; LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next); - ret =3D nic_ops.translate(dev, dev_flow, attr, - buf->entry[i].pattern, - actions, error); + ret =3D flow_drv_translate(dev, dev_flow, attr, + buf->entry[i].pattern, + actions, error); if (ret < 0) goto error; } if (dev->data->dev_started) { - ret =3D nic_ops.apply(dev, flow, error); + ret =3D flow_drv_apply(dev, flow, error); if (ret < 0) goto error; } @@ -1668,7 +1963,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, error: ret =3D rte_errno; /* Save rte_errno before cleanup. */ assert(flow); - nic_ops.destroy(dev, flow); + flow_drv_destroy(dev, flow); rte_free(flow); rte_errno =3D ret; /* Restore rte_errno. */ return NULL; @@ -1706,7 +2001,7 @@ static void mlx5_flow_list_destroy(struct rte_eth_dev *dev, struct mlx5_flows *list, struct rte_flow *flow) { - nic_ops.destroy(dev, flow); + flow_drv_destroy(dev, flow); TAILQ_REMOVE(list, flow, next); /* * Update RX queue flags only if port is started, otherwise it is @@ -1750,7 +2045,7 @@ mlx5_flow_stop(struct rte_eth_dev *dev, struct mlx5_f= lows *list) struct rte_flow *flow; =20 TAILQ_FOREACH_REVERSE(flow, list, mlx5_flows, next) - nic_ops.remove(dev, flow); + flow_drv_remove(dev, flow); mlx5_flow_rxq_flags_clear(dev); } =20 @@ -1773,7 +2068,7 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_= flows *list) int ret =3D 0; =20 TAILQ_FOREACH(flow, list, next) { - ret =3D nic_ops.apply(dev, flow, &error); + ret =3D flow_drv_apply(dev, flow, &error); if (ret < 0) goto error; mlx5_flow_rxq_flags_set(dev, flow); @@ -2464,24 +2759,3 @@ mlx5_dev_filter_ctrl(struct rte_eth_dev *dev, } return 0; } - -/** - * Init the driver ops structure. - * - * @param dev - * Pointer to Ethernet device structure. - */ -void -mlx5_flow_init_driver_ops(struct rte_eth_dev *dev) -{ - struct priv *priv __rte_unused =3D dev->data->dev_private; - -#ifdef HAVE_IBV_FLOW_DV_SUPPORT - if (priv->config.dv_flow_en) - mlx5_flow_dv_get_driver_ops(&nic_ops); - else - mlx5_flow_verbs_get_driver_ops(&nic_ops); -#else - mlx5_flow_verbs_get_driver_ops(&nic_ops); -#endif -} diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 53c0eeb56..2bc3bee8c 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -128,6 +128,13 @@ /* Max number of actions per DV flow. */ #define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8 =20 +enum mlx5_flow_drv_type { + MLX5_FLOW_TYPE_MIN, + MLX5_FLOW_TYPE_DV, + MLX5_FLOW_TYPE_VERBS, + MLX5_FLOW_TYPE_MAX, +}; + /* Matcher PRM representation */ struct mlx5_flow_dv_match_params { size_t size; @@ -210,7 +217,7 @@ struct mlx5_flow_counter { /* Flow structure. */ struct rte_flow { TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ - struct rte_flow_attr attributes; /**< User flow attribute. */ + enum mlx5_flow_drv_type drv_type; /**< Drvier type. */ uint32_t layers; /**< Bit-fields of present layers see MLX5_FLOW_LAYER_*. */ struct mlx5_flow_counter *counter; /**< Holds flow counter. */ @@ -314,13 +321,5 @@ int mlx5_flow_validate_item_vxlan_gpe(const struct rte= _flow_item *item, uint64_t item_flags, struct rte_eth_dev *dev, struct rte_flow_error *error); -void mlx5_flow_init_driver_ops(struct rte_eth_dev *dev); - -/* mlx5_flow_dv.c */ -void mlx5_flow_dv_get_driver_ops(struct mlx5_flow_driver_ops *flow_ops); - -/* mlx5_flow_verbs.c */ - -void mlx5_flow_verbs_get_driver_ops(struct mlx5_flow_driver_ops *flow_ops)= ; =20 #endif /* RTE_PMD_MLX5_FLOW_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_d= v.c index 71af410b2..cf663cdb8 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1351,23 +1351,13 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte= _flow *flow) } } =20 -/** - * Fills the flow_ops with the function pointers. - * - * @param[out] flow_ops - * Pointer to driver_ops structure. - */ -void -mlx5_flow_dv_get_driver_ops(struct mlx5_flow_driver_ops *flow_ops) -{ - *flow_ops =3D (struct mlx5_flow_driver_ops) { - .validate =3D flow_dv_validate, - .prepare =3D flow_dv_prepare, - .translate =3D flow_dv_translate, - .apply =3D flow_dv_apply, - .remove =3D flow_dv_remove, - .destroy =3D flow_dv_destroy, - }; -} +const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops =3D { + .validate =3D flow_dv_validate, + .prepare =3D flow_dv_prepare, + .translate =3D flow_dv_translate, + .apply =3D flow_dv_apply, + .remove =3D flow_dv_remove, + .destroy =3D flow_dv_destroy, +}; =20 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */ diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flo= w_verbs.c index f4a264232..05ab5fdad 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -1638,15 +1638,11 @@ flow_verbs_apply(struct rte_eth_dev *dev, struct rt= e_flow *flow, return -rte_errno; } =20 -void -mlx5_flow_verbs_get_driver_ops(struct mlx5_flow_driver_ops *flow_ops) -{ - *flow_ops =3D (struct mlx5_flow_driver_ops) { - .validate =3D flow_verbs_validate, - .prepare =3D flow_verbs_prepare, - .translate =3D flow_verbs_translate, - .apply =3D flow_verbs_apply, - .remove =3D flow_verbs_remove, - .destroy =3D flow_verbs_destroy, - }; -} +const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops =3D { + .validate =3D flow_verbs_validate, + .prepare =3D flow_verbs_prepare, + .translate =3D flow_verbs_translate, + .apply =3D flow_verbs_apply, + .remove =3D flow_verbs_remove, + .destroy =3D flow_verbs_destroy, +}; --=20 2.11.0