From patchwork Sun May 26 10:18:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 53701 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 787452B8E; Sun, 26 May 2019 12:18:26 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140050.outbound.protection.outlook.com [40.107.14.50]) by dpdk.org (Postfix) with ESMTP id 3B9B01DBD for ; Sun, 26 May 2019 12:18:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2pQlfVdmS/IM5n00CrF0Fg0woyUUVhT6hFFcFMbEPm8=; b=kPX9ZS4HFk/et/hvIKlDSjC+QJd6YPe34C8NcjFHOJLf+E3FLqjgivSFqvrPQVPGvrJm48H2mu++k+FMZcVhv0hXn7XIZbSW4lo7S/epRiVGvukdVpPlNr7S70jPSucQ61mxBBtSZJOk/3Z8bonCHKv3Gn2J8YS7AVY27sdQAFM= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.39.139) by AM0PR0502MB4067.eurprd05.prod.outlook.com (52.133.37.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.16; Sun, 26 May 2019 10:18:24 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::c5e8:f7ec:d77:5269]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::c5e8:f7ec:d77:5269%4]) with mapi id 15.20.1922.018; Sun, 26 May 2019 10:18:24 +0000 From: Matan Azrad To: Adrien Mazarguil , "dev@dpdk.org" Thread-Topic: [PATCH] [RFC] ethdev: support flow aging Thread-Index: AQHVE6xZdRJnMnCt1UOalpFSEqCNWA== Date: Sun, 26 May 2019 10:18:23 +0000 Message-ID: <1558865893-23381-1-git-send-email-matan@mellanox.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.8.3.1 x-clientproxiedby: LO2P123CA0009.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:a6::21) To AM0PR0502MB4019.eurprd05.prod.outlook.com (2603:10a6:208:f::11) authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1a57b3ad-90ae-437e-7f9a-08d6e1c37bc6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR0502MB4067; x-ms-traffictypediagnostic: AM0PR0502MB4067: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 0049B3F387 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(396003)(136003)(366004)(376002)(189003)(199004)(6506007)(386003)(8676002)(99286004)(81156014)(81166006)(52116002)(186003)(8936002)(2501003)(50226002)(110136005)(26005)(68736007)(5660300002)(36756003)(86362001)(7736002)(71190400001)(71200400001)(316002)(2616005)(476003)(486006)(53936002)(6116002)(3846002)(6486002)(305945005)(6512007)(4720700003)(2906002)(14454004)(66066001)(478600001)(66946007)(73956011)(102836004)(14444005)(256004)(6436002)(66446008)(64756008)(66556008)(66476007)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB4067; H:AM0PR0502MB4019.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: j2Wooi68MTMYzQX5yvIY8fOpPDf2ayASgI5GRrd6mT/Eg07wTI3lNuYnATVLe3GdPmQcrn5n/B+RjIf75WA52DKQToCU+uFclvIUw+dqaYou0tGtksB6fPFgonkg4V0xTvV88Faa6Sgs/L3KWy00QcvkJ6CTIdOuNn0EkFN5BJbhFP/7St2ceqNYYGz5HsC1a335KobOTgI4TPcvuNG5CzruAxJZ0qmr2h9AFgPNtOPM8hsO4S28o1bs4d6LH+A40ltJxym722E9nu95Gytme6NjrCO4BiA453PB8WQQoumCSnpmNadmcIyjaJU5vRMOjLpJfXhVU1wmKtUl9Y9LUGKQ4PwfhtqTd5PBaYW+Y/dg153F+KITBn84nKG+uxqgH08plDEm+fkXYIK6z69++LbROwVcGOLvE7FHHz8dfu8= MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a57b3ad-90ae-437e-7f9a-08d6e1c37bc6 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2019 10:18:24.0667 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: matan@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB4067 Subject: [dpdk-dev] [PATCH] [RFC] ethdev: support flow aging 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" One of the reasons to destroy a flow is the fact that no packet matches the flow for "timeout" time. For example, when TCP\UDP sessions are suddenly closed. Currently, there is no any dpdk mechanism for flow aging and the applications use there own ways to detect and destroy aged-out flows. This RFC introduces flow aging APIs to offload the flow aging task from the application to the port. Design: - A new rte_flow action: RTE_FLOW_ACTION_TYPE_AGE to set the timeout and the application flow context for each flow. - A new ethdev event: RTE_ETH_EVENT_FLOW_AGED for the driver to report that there are new aged-out flows. - A new rte_flow API: rte_flow_get_aged_flows to get the aged-out flows contexts from the port. By this design each PMD can use its best way to do the aging with the device offloads supported by its HW. Signed-off-by: Matan Azrad --- lib/librte_ethdev/rte_ethdev.h | 1 + lib/librte_ethdev/rte_flow.h | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 1f35e1d..6fc1531 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2771,6 +2771,7 @@ enum rte_eth_event_type { RTE_ETH_EVENT_NEW, /**< port is probed */ RTE_ETH_EVENT_DESTROY, /**< port is released */ RTE_ETH_EVENT_IPSEC, /**< IPsec offload related event */ + RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows detected in the port */ RTE_ETH_EVENT_MAX /**< max value of this enum */ }; diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 63f84fc..757e65f 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -1650,6 +1650,12 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_mac. */ RTE_FLOW_ACTION_TYPE_SET_MAC_DST, + /** + * Report as aged-out if timeout passed without any matching on the flow. + * + * See struct rte_flow_action_age. + */ + RTE_FLOW_ACTION_TYPE_AGE, }; /** @@ -2131,6 +2137,22 @@ struct rte_flow_action_set_mac { uint8_t mac_addr[ETHER_ADDR_LEN]; }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_AGE + * + * Report as aged-out if timeout passed without any matching on the flow. + * + * The flow context and the flow handle will be reported by the + * rte_flow_get_aged_flows API. + */ +struct rte_flow_action_age { + uint16_t timeout; /**< Time in seconds. */ + void *context; /**< The user flow context. */ +}; + /* * Definition of a single action. * @@ -2686,6 +2708,40 @@ struct rte_flow_desc { const void *src, struct rte_flow_error *error); +/** + * Get aged-out flows of a given port. + * + * RTE_ETH_EVENT_FLOW_AGED is triggered when a port detects aged-out flows. + * This function can be called to get the aged flows usynchronously from the + * event callback or synchronously when the user wants it. + * The callback synchronization is on the user responsibility. + * + * @param port_id + * Port identifier of Ethernet device. + * @param[in/out] flows + * An allocated array to get the aged-out flows handles. + * NULL indicates the flow handles should not be reported. + * @param[in/out] contexts + * An allocated array to get the aged-out flows contexts. + * NULL indicates the flow contexts should not be reported. + * @param[in] n + * The allocated array entries number of @p flows and @p contexts if exist. + * @param[out] error + * Perform verbose error reporting if not NULL. Initialized in case of + * error only. + * + * @return + * 0 in case there are not any aged-out flows, otherwise if positive + * is the number of the reported aged-out flows to @p flows and/or + * @p contexts, a negative errno value otherwise and rte_errno is set. + * + * @see rte_flow_action_age + */ +__rte_experimental +int +rte_flow_get_aged_flows(uint16_t port_id, struct rte_flow *flows[], + void *contexts[], int n, struct rte_flow_error *error); + #ifdef __cplusplus } #endif