From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id C416DA05D3 for ; Tue, 26 Mar 2019 13:02:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E072D4C93; Tue, 26 Mar 2019 13:01:55 +0100 (CET) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20059.outbound.protection.outlook.com [40.107.2.59]) by dpdk.org (Postfix) with ESMTP id 438953256 for ; Tue, 26 Mar 2019 13:01:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6KRgdSpIW8YLDlUwoKFRYNL56NpRXAxATyRpp6QE59I=; b=xp+zflx0ZQs41xExzxw1CRFrvYEHEqxxlnRoNS8lMky5riX7mbI1APcXPUmXghcv2slI7TSEZ3cwMibm8cXcK6K0awOZjGmTLjDBkKbv43ut4NOTvaJEITrErUs+1kqHlPNqUZ+lC2KXBMZHQysEYcYZwgQ3qIjS6rUecfDmIr0= Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com (10.168.65.19) by VI1PR0401MB2366.eurprd04.prod.outlook.com (10.169.134.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Tue, 26 Mar 2019 12:01:48 +0000 Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::18e3:39b6:c61d:3f18]) by VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::18e3:39b6:c61d:3f18%12]) with mapi id 15.20.1730.019; Tue, 26 Mar 2019 12:01:48 +0000 From: Hemant Agrawal To: "dev@dpdk.org" CC: "ferruh.yigit@intel.com" , Shreyansh Jain Thread-Topic: [PATCH 4/4] net/dpaa2: add support for flow table flush Thread-Index: AQHU48uwXrMaD1l0YkmMu3NuayfAOQ== Date: Tue, 26 Mar 2019 12:01:48 +0000 Message-ID: <20190326115952.26278-4-hemant.agrawal@nxp.com> References: <20190326115952.26278-1-hemant.agrawal@nxp.com> In-Reply-To: <20190326115952.26278-1-hemant.agrawal@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [92.120.1.72] x-mailer: git-send-email 2.17.1 x-clientproxiedby: BM1PR01CA0157.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::27) To VI1PR0401MB2541.eurprd04.prod.outlook.com (2603:10a6:800:56::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f5192a29-8185-4d52-d23e-08d6b1e2d2f4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR0401MB2366; x-ms-traffictypediagnostic: VI1PR0401MB2366: x-microsoft-antispam-prvs: x-forefront-prvs: 09888BC01D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(136003)(346002)(39860400002)(376002)(199004)(189003)(71190400001)(86362001)(256004)(44832011)(6916009)(26005)(5660300002)(81156014)(2351001)(2501003)(1076003)(66066001)(2906002)(6116002)(3846002)(14454004)(486006)(6506007)(1730700003)(71200400001)(316002)(14444005)(105586002)(478600001)(97736004)(8676002)(186003)(6512007)(7736002)(106356001)(8936002)(52116002)(81166006)(25786009)(50226002)(99286004)(6436002)(5640700003)(11346002)(446003)(2616005)(305945005)(68736007)(386003)(4326008)(102836004)(476003)(36756003)(76176011)(6486002)(54906003)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2366; H:VI1PR0401MB2541.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Pb0a91j6S5yahKk74omLXyAgFxgNSUKQjuAeu/6dizPOgMH0uJnmEmE5niCBI4ql2PjdnofDP8Ex8IZiBny+mJ0ltLHj+d4uKfDngZ2zEUGAy/JWu8oEP9Tc2LuSF1CB1gGZKJwrVTj/zeeSnhViCTETsNjpnupFv2s/2M+i2Cu7TdQYeWeyZEsSlxiGn4ML2W8OB+vAcwOpz5ad293Sd3kCEB1/TnMUIkXuZo9T6QWFzirFOo3knyJrWRIw2VBDvkaXIuSMNlAMh0hNABOfdTWYt7MHBx05AWLJPmJC/JBkYMQPSZVjf58Y0BdcbY3S683uQxsxscgAjlOMoY8NSmQj7+6WMiabK+CMAx2f2jJkuU4p/DpEXLzsSaNR3Y6c4lRa9sPW0A199vPY4U6UDSLypkYg+KDJNyODBUwyygE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5192a29-8185-4d52-d23e-08d6b1e2d2f4 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Mar 2019 12:01:48.2361 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2366 Subject: [dpdk-dev] [PATCH 4/4] net/dpaa2: add support for flow table flush 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190326120148.fi9c70B2weknNk7L-Xm3XKuBdmJU67r5NNs3UiUX8gA@z> Signed-off-by: Hemant Agrawal --- drivers/net/dpaa2/dpaa2_ethdev.c | 2 + drivers/net/dpaa2/dpaa2_ethdev.h | 2 + drivers/net/dpaa2/dpaa2_flow.c | 118 +++++++++++++++++++++---------- 3 files changed, 85 insertions(+), 37 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_eth= dev.c index c92edecf3..3fbc82977 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -971,6 +971,8 @@ dpaa2_dev_close(struct rte_eth_dev *dev) =20 PMD_INIT_FUNC_TRACE(); =20 + dpaa2_flow_clean(dev); + /* Clean the device first */ ret =3D dpni_reset(dpni, CMD_PRI_LOW, priv->token); if (ret) { diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_eth= dev.h index 0ef1bf368..33b1506aa 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -126,6 +126,7 @@ struct dpaa2_dev_priv { uint64_t qos_extract_param; uint64_t fs_extract_param[MAX_TCS]; } extract; + LIST_HEAD(, rte_flow) flows; /**< Configured flow rule handles. */ }; =20 int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set, @@ -172,5 +173,6 @@ uint16_t dpaa2_dev_tx_ordered(void *queue, struct rte_m= buf **bufs, uint16_t nb_pkts); uint16_t dummy_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkt= s); void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci); +void dpaa2_flow_clean(struct rte_eth_dev *dev); =20 #endif /* _DPAA2_ETHDEV_H */ diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.= c index 20de3da53..c94c7ef6b 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -24,6 +24,7 @@ #include =20 struct rte_flow { + LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ struct dpni_rule_cfg rule; uint8_t key_size; uint8_t tc_id; @@ -1347,6 +1348,7 @@ dpaa2_generic_flow_set(struct rte_flow *flow, struct dpaa2_dev_priv *priv =3D dev->data->dev_private; struct fsl_mc_io *dpni =3D (struct fsl_mc_io *)priv->hw; size_t param; + struct rte_flow *curr =3D LIST_FIRST(&priv->flows); =20 /* Parse pattern list to get the matching parameters */ while (!end_of_list) { @@ -1625,6 +1627,16 @@ dpaa2_generic_flow_set(struct rte_flow *flow, j++; } =20 + if (!ret) { + /* New rules are inserted. */ + if (!curr) { + LIST_INSERT_HEAD(&priv->flows, flow, next); + } else { + while (LIST_NEXT(curr, next)) + curr =3D LIST_NEXT(curr, next); + LIST_INSERT_AFTER(curr, flow, next); + } + } return ret; } =20 @@ -1764,7 +1776,7 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *flow_attr, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], - struct rte_flow_error *error __rte_unused) + struct rte_flow_error *error) { struct dpaa2_dev_priv *priv =3D dev->data->dev_private; struct dpni_attr dpni_attr; @@ -1778,6 +1790,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev, DPAA2_PMD_ERR( "Failure to get dpni@%p attribute, err code %d\n", dpni, ret); + rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_ATTR, + flow_attr, "invalid"); return ret; } =20 @@ -1786,6 +1801,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev, if (ret < 0) { DPAA2_PMD_ERR( "Invalid attributes are given\n"); + rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_ATTR, + flow_attr, "invalid"); goto not_valid_params; } /* Verify input pattern list */ @@ -1793,6 +1811,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev, if (ret < 0) { DPAA2_PMD_ERR( "Invalid pattern list is given\n"); + rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_ITEM, + pattern, "invalid"); goto not_valid_params; } /* Verify input action list */ @@ -1800,6 +1821,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev, if (ret < 0) { DPAA2_PMD_ERR( "Invalid action list is given\n"); + rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, "invalid"); goto not_valid_params; } not_valid_params: @@ -1820,20 +1844,20 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_d= ev *dev, flow =3D rte_malloc(NULL, sizeof(struct rte_flow), RTE_CACHE_LINE_SIZE); if (!flow) { DPAA2_PMD_ERR("Failure to allocate memory for flow"); - return NULL; + goto mem_failure; } /* Allocate DMA'ble memory to write the rules */ key_iova =3D (size_t)rte_malloc(NULL, 256, 64); if (!key_iova) { DPAA2_PMD_ERR( "Memory allocation failure for rule configration\n"); - goto creation_error; + goto mem_failure; } mask_iova =3D (size_t)rte_malloc(NULL, 256, 64); if (!mask_iova) { DPAA2_PMD_ERR( "Memory allocation failure for rule configration\n"); - goto creation_error; + goto mem_failure; } =20 flow->rule.key_iova =3D key_iova; @@ -1845,6 +1869,10 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_de= v *dev, ret =3D dpaa2_generic_flow_set(flow, dev, attr, pattern, actions, error); if (ret < 0) { + if (error->type > RTE_FLOW_ERROR_TYPE_ACTION) + rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + attr, "unknown"); DPAA2_PMD_ERR( "Failure to create flow, return code (%d)", ret); goto creation_error; @@ -1857,21 +1885,22 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_d= ev *dev, } =20 return flow; - +mem_failure: + rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "memory alloc"); creation_error: - if (flow) - rte_free((void *)flow); - if (key_iova) - rte_free((void *)key_iova); - if (mask_iova) - rte_free((void *)mask_iova); + rte_free((void *)flow); + rte_free((void *)key_iova); + rte_free((void *)mask_iova); + return NULL; } =20 static int dpaa2_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, - struct rte_flow_error *error __rte_unused) + struct rte_flow_error *error) { int ret =3D 0; struct dpaa2_dev_priv *priv =3D dev->data->dev_private; @@ -1913,44 +1942,40 @@ int dpaa2_flow_destroy(struct rte_eth_dev *dev, break; } =20 + LIST_REMOVE(flow, next); /* Now free the flow */ rte_free(flow); =20 error: + if (ret) + rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "unknown"); return ret; } =20 +/** + * Destroy user-configured flow rules. + * + * This function skips internal flows rules. + * + * @see rte_flow_flush() + * @see rte_flow_ops + */ static int dpaa2_flow_flush(struct rte_eth_dev *dev, - struct rte_flow_error *error __rte_unused) + struct rte_flow_error *error) { - int ret =3D 0, tc_id; - struct dpni_rx_tc_dist_cfg tc_cfg; - struct dpni_qos_tbl_cfg qos_cfg; struct dpaa2_dev_priv *priv =3D dev->data->dev_private; - struct fsl_mc_io *dpni =3D (struct fsl_mc_io *)priv->hw; + struct rte_flow *flow =3D LIST_FIRST(&priv->flows); =20 - /* Reset QoS table */ - qos_cfg.default_tc =3D 0; - qos_cfg.discard_on_miss =3D false; - qos_cfg.keep_entries =3D false; - qos_cfg.key_cfg_iova =3D priv->extract.qos_extract_param; - ret =3D dpni_set_qos_table(dpni, CMD_PRI_LOW, priv->token, &qos_cfg); - if (ret < 0) - DPAA2_PMD_ERR( - "QoS table is not reset to default: %d\n", ret); - - for (tc_id =3D 0; tc_id < priv->num_rx_tc; tc_id++) { - /* Reset FS table */ - memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg)); - ret =3D dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, - tc_id, &tc_cfg); - if (ret < 0) - DPAA2_PMD_ERR( - "Error (%d) in flushing entries for TC (%d)", - ret, tc_id); + while (flow) { + struct rte_flow *next =3D LIST_NEXT(flow, next); + + dpaa2_flow_destroy(dev, flow, error); + flow =3D next; } - return ret; + return 0; } =20 static int @@ -1963,6 +1988,25 @@ dpaa2_flow_query(struct rte_eth_dev *dev __rte_unuse= d, return 0; } =20 +/** + * Clean up all flow rules. + * + * Unlike dpaa2_flow_flush(), this function takes care of all remaining fl= ow + * rules regardless of whether they are internal or user-configured. + * + * @param priv + * Pointer to private structure. + */ +void +dpaa2_flow_clean(struct rte_eth_dev *dev) +{ + struct rte_flow *flow; + struct dpaa2_dev_priv *priv =3D dev->data->dev_private; + + while ((flow =3D LIST_FIRST(&priv->flows))) + dpaa2_flow_destroy(dev, flow, NULL); +} + const struct rte_flow_ops dpaa2_flow_ops =3D { .create =3D dpaa2_flow_create, .validate =3D dpaa2_flow_validate, --=20 2.17.1