From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8E324A0A02; Thu, 20 Oct 2022 04:21:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 255FB42C69; Thu, 20 Oct 2022 04:21:08 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2096.outbound.protection.outlook.com [40.107.101.96]) by mails.dpdk.org (Postfix) with ESMTP id 819AB42C4E for ; Thu, 20 Oct 2022 04:21:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PYKaNXxPLaUy3fvxrMXFWvcXHEPNIEIol+jmzHtwUms4KWV7R2xFhYZ/JE4bvRPWYcnHGPwPbzGAH/Fs4AE135HlcBVU0+k/itjKLb2x2pKtloVP/J6rkmSiz1h58G7C4L6US4dY7njsCvdqKHJwEh+K/tvHkaV56FjwulxSxuF7yKadSlgYI2c8OHH7rBuU42wQJ1st4IB4GDpGRUdUyN5U/853vAoUaNoSh3t7D7YokEdGhfLXS2AZ8pCqtk5nd3vaS5h4VaCHZeUKD+7QqGRxal+frs8D2Nmhq7fJn9DZ7CX6aVwJdydXa77A38R36hhK804z3PpbZM575hapEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SyUxpD4QFNFMm/yZ/hX7v45U0qWjEkIwVk24lks50y4=; b=aftakk6Xic7Rgq4O3N7k74tl9Hdri80vkA6+zSW64YpFE9rTLPt572j+4l4igjGZEpkCQuNq+1+Oha+Z9PDbtbcDclSYsMGy85muBgLdQ/5N/rZwAniNcBUg/68M1qmtiRExMRNrMD+1FgBYJgCebxMJH5AotrWPZYY/gbiLPyhOwfyt10iE4KQpToGPbcRlEcNtE9ZOwfvZmQo5uVaa6HVM8omthwNMfMi7eOSnEoEr1dG4nYvVg0q6HIsnwrFZZ7/NlQ8pZw4Bad3aVWCW2X6b6vYCDhtiFBzl1rTE8Tezg4AZdoTpRblZIFrJ/1flyfR6CydQyB7RfX4fc24NVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SyUxpD4QFNFMm/yZ/hX7v45U0qWjEkIwVk24lks50y4=; b=OZXH0VZXnzdAeeCO/MA1EZCMh8ESFbwv6Xne7kFfZBY6vv4p49j7PqhDd77FkUs1tmjYkvcPAGI9tkkOY/FgoKsTA2vwJnvB0AMStMZTD2XEuCbKTJkAgEnxVYpm3c6WCeGe5G0Mwow2DHQWJ2HLWMi04oYwJ8K0UvYqqBPpZXA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by DM4PR13MB5906.namprd13.prod.outlook.com (2603:10b6:8:4c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16; Thu, 20 Oct 2022 02:21:02 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b%4]) with mapi id 15.20.5723.014; Thu, 20 Oct 2022 02:21:02 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v5 04/25] net/nfp: add the flow APIs of nfp PMD Date: Thu, 20 Oct 2022 10:19:30 +0800 Message-Id: <1666232391-29152-5-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> References: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> <1666232391-29152-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:196::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DM4PR13MB5906:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f5aed14-53a2-44ab-8fea-08dab241bbe0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yCZnzIXEzcNBZwske/FvtfHvJEYZIZ87BC7q+L1Wn4ARpREWn7ps/VnRn8WKAiAKv28lg+n9/0ENFvf3f9/W78WWtySn7FcWAC317PQoDvY2vhW5rWszn9ZYKakkl5VV+AxwYCr1CtMZz4uoDjq9roMEr3EXP9vslDmZP67QwhFfKL2qdYCMnbZoxVYGIqRKXI7q/2nGoCmwQZnQZZEIIqb5yu4d/+yKKu0zf/kEu5wpEIeCyUvYb5JEFQNqW6ExkaLtcAn/tLnBg8TgdH2SjONYkv527nXiSGRK27vJryw43UEFS7R4rI9BIR5K1jv2lF6gyxxxj5f9aCOa41G4q1A/Dhz7idylKyD4D34fGFvbzOqCoIvII1xzr+Cgx7suy0i1bYz9H8k97PkPJvW34n/jSIATfpjft6bw8AZ6l9bNv+Flhli7rV5+WLGl02X3H8lFYoITJapm1FUv4AQhQOUM42m9SiPVSJM4Xn87jCft4Epn5YQGzDIeXRqNs3NuRWDjdSwplwPsG9DvdoEYexWwcQIG0eJDfavj/Ozss1vAvXdOserpkZmWZ0aIr6h2qrp/06dTytGJfDPHmUMpZcHPs2Lk6FFPEx5yqtbTsaTTSwaSbpSNMLxPaHGi6rIa4NhJnf9na/4GK91Np0F3v8xEBzRNaJl5/7Ib5qf+aymEEkCngYc+st242toMzhwJW63Ogth49+KvBfz2zj01QLJDmFuDu4v7vHTWDEiXUeKdKHV6Aagg7lxdnRlbtLkHtAjctDBx+24Tb42GFnzB2fmZM/wNJZLjzEtjzWo+dJgLqbzTQ2uhe3pFQsMUj8DP X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(376002)(39840400004)(346002)(396003)(366004)(451199015)(38100700002)(478600001)(38350700002)(316002)(6916009)(2906002)(186003)(66476007)(52116002)(66556008)(6666004)(66946007)(107886003)(4326008)(6506007)(2616005)(41300700001)(5660300002)(36756003)(8676002)(6486002)(8936002)(26005)(66574015)(44832011)(86362001)(30864003)(83380400001)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TVJDNHZoTmNNcHA3dUpxUTZMMkpCdUluVFNwaUJBUGM4dWwxdGl3eTNPejVm?= =?utf-8?B?N3h5YlZPazhqR2ltL1lsdk5qM01tZEZIeHVyUEF0QmNTVnRhN3NHdGNVZlFx?= =?utf-8?B?Q2ljOEhMM3NVczZJY28vcWJZaGNlanZvWTNBeEU2LzFTTFFXbWhxZ0RYN2h3?= =?utf-8?B?OE9BMlJyRnZ2NUtMMGNOUmNZL1ZzV25Xb2Z3UExxZEJLVlVhdmhiTFhEREJw?= =?utf-8?B?ZGxtcVR5WjhSSlR0V1doUXlOWTVCYUhJL3I0aU9XcTB0RjRMVUZSSWhQOXF2?= =?utf-8?B?NGlhR3VBc1RKTG1RMjZIaEdmdXdPc2N0UkF0MXMzWVZiREZidVJZT2d5YUd3?= =?utf-8?B?cDdpK0xGTEk4L0dRazBQY2luR2picmJWUHhPR01XQ213dXIzWGp6NFBia0Ri?= =?utf-8?B?ZXRJaDBiNmdNeUF6RG1oRUxFcGlkRkxjNk5uMkt5ajR1TFFPWjBBQWh4UXRz?= =?utf-8?B?cUdYSHpMWVNoaExuL1MxOWxva1lGUFlXR0NqaGUrOFgyV25zY3ZGcjFUWDJD?= =?utf-8?B?U3VlUGRDSjZyUlAxUHM4L1pQMDlqOVdGbnRUbVRzMUtyQVRsWXNTS2k2MGR2?= =?utf-8?B?KzF4QmNNWDlKN09pNkl0VWRTemFZdSs2U3ZhZCtRMzBVUWZjTnBxTWhIN0x5?= =?utf-8?B?eXBkc3c3U2t3cVdpNS9uUU85OXNHNUx3OWtpSGNBNEgvQmtnQ1hiQTQ0THYx?= =?utf-8?B?elo3Y2RMTm1sZGo1L1F5WVNQN0tRc09zTHJsSXBnUm4vdzltQjZTWTUzQUNp?= =?utf-8?B?K2RRcVlUVEM2NjVnUHpmaDdOUnM0OEljQ0YwKy9NRFJxMDNnN1A2djg3aEZ0?= =?utf-8?B?am5KdENHUWhOeGdOWVE1bnVCbmFuVGVoemxtcnc4bmhuWTFTTmxJYXY4RWpQ?= =?utf-8?B?ZHRjamtJKzdmYzNKRzhkUVNRT0E4NGNjandXdmFIZlRlcmxJK1VibW1Zb1NX?= =?utf-8?B?U0FwZmtRQnBkNnc5WlVwTjFwRHZPY2U3Zk9aSWpmdkRRTXA2WTk5bmVZeUFW?= =?utf-8?B?ZFNmYjRKeVU5NHhVTG9FUkoxYU81RmJjSlJoZkt1Z2hFeVZYek1iM3dqcVoz?= =?utf-8?B?bk5iMFdFTENWY0lWRmE1Y2JTVkFPbEVpWDBibldncjV6SDE1ZC85MUE5MFB2?= =?utf-8?B?ZEhJQkRLbnRHTkdpdjhMZFZkek85T2hTcjB5WWxCUHNKTityem1TOHkxZmtz?= =?utf-8?B?a2lzV2FXejNpODRTTGFNNEg2ZTNsWkxtVDF5Y1VNTnFrWjg1ZDlHQ3dWLzZw?= =?utf-8?B?UVRZNnFyQlpQTW1hWkYzaDBiclpLc0xrZysyc21RWXNnM1AxQm55Q2gyUncz?= =?utf-8?B?cFo5a0V1d3NUeTJQOHNJeTVBMmV1QmRHWGNpNGsrOEFiTEhVSU9zdUY1T2dy?= =?utf-8?B?blVEdk9wYTRiTzNCRldCOXdBT2pIb1ZuR2w2T2hINFlEQXBKQXVubXovd0xJ?= =?utf-8?B?cG1QL3prR0drbmxiZjAvd2k0M3hTZkU0UFd1R0g4WWcyaWpXajZFVG1qS0kx?= =?utf-8?B?MGpwUW9kQzBGOGlXdTQzV3pOTEJVaGJDbks3aXNOT3VQRm8wWFFkNnVnVUEx?= =?utf-8?B?Vm1mYlMxanhUS0xESloycTRhTlhFSDN1YlNLamFiRy93dytDcGxxS2JHbGlQ?= =?utf-8?B?QkxnZHVHK1o2RldtaENKYk1kZTNjblBqSFVlYnJBZDEyRzlXa3dkbXFVVlM1?= =?utf-8?B?TkJ6ajRlK3F2aDdNdzFPS2pXRU01ai9DZXl1UjBGWTR1ekNwZzZsRVJub2pZ?= =?utf-8?B?OEl0WHlOaXdmaldWSHpkemRGOVE1Zmoyenk1WW40aldaRlZBZVhqcHA2SUxh?= =?utf-8?B?SXVZUE9NTUlldk1jY1g1S1NHVzRRUU1ITXByOHczbjlzRGtINGZkM1VKanNt?= =?utf-8?B?aVk1UmQwVTJiUTVmZVAzMjNJWHROMzRTZGFKUldZaXpHd3dadUd2UkNzL2NP?= =?utf-8?B?VDlEeE5QOXU5eVNLZGZ1QUUzTVNDSm5YMzk1ZWZvNzltZFdwS0hQYmpPdS91?= =?utf-8?B?d2pyZFVvSmNqWU5rSWpMb3gvbjN5bTlrVDFlQ0Q0Zi9ONU92N2c3Z205MVU0?= =?utf-8?B?dXhhWGw4ZnlNdXhVenJRa3NXT25NRmZJd2ltTzdEWU5VOFVGb3AxUm9MWlpr?= =?utf-8?B?WVdFdllIWThQQktUcmlaL2Jrdk9MU2E4MjRpUlU4NDZZQ00wbHJ1dFByOHFy?= =?utf-8?B?K0E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f5aed14-53a2-44ab-8fea-08dab241bbe0 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2022 02:21:02.3208 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3WMupPolGMv1DRU5Sd75YZhPtacI2liT0wAnSIGGbufRFcQtoSgaBa8bhRwq7PynVPwSEMQyDbXwSL94M53E5ue54UP65izqwID5g2vXub0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR13MB5906 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add the flow validate/create/query/destroy/flush API of nfp PMD. The flow create API construct a control cmsg and send it to firmware, then add this flow to the hash table. The flow query API get flow stats from the flow_priv structure. Note there exist an rte_spin_lock to prevent the update and query action occur at the same time. The flow destroy API construct a control cmsg and send it to firmware, then adelete this flow from the hash table. The flow flush API just iterate the flows in hash table and call the flow destroy API. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 69 +++ drivers/net/nfp/flower/nfp_flower_cmsg.h | 48 ++ drivers/net/nfp/flower/nfp_flower_representor.c | 3 + drivers/net/nfp/nfp_flow.c | 592 +++++++++++++++++++++++- drivers/net/nfp/nfp_flow.h | 28 ++ 5 files changed, 731 insertions(+), 9 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 750a629..15d8381 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -6,6 +6,7 @@ #include "../nfpcore/nfp_nsp.h" #include "../nfp_logs.h" #include "../nfp_common.h" +#include "../nfp_flow.h" #include "nfp_flower.h" #include "nfp_flower_cmsg.h" #include "nfp_flower_ctrl.h" @@ -177,3 +178,71 @@ return 0; } + +int +nfp_flower_cmsg_flow_delete(struct nfp_app_fw_flower *app_fw_flower, + struct rte_flow *flow) +{ + char *msg; + uint16_t cnt; + uint32_t msg_len; + struct rte_mbuf *mbuf; + struct nfp_fl_rule_metadata *nfp_flow_meta; + + mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool); + if (mbuf == NULL) { + PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for flow delete."); + return -ENOMEM; + } + + /* Copy the flow to mbuf */ + nfp_flow_meta = flow->payload.meta; + msg_len = (nfp_flow_meta->key_len + nfp_flow_meta->mask_len + + nfp_flow_meta->act_len) << NFP_FL_LW_SIZ; + msg_len += sizeof(struct nfp_fl_rule_metadata); + msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_FLOW_DEL, msg_len); + rte_memcpy(msg, flow->payload.meta, msg_len); + + cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf); + if (cnt == 0) { + PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed."); + rte_pktmbuf_free(mbuf); + return -EIO; + } + + return 0; +} + +int +nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower, + struct rte_flow *flow) +{ + char *msg; + uint16_t cnt; + uint32_t msg_len; + struct rte_mbuf *mbuf; + struct nfp_fl_rule_metadata *nfp_flow_meta; + + mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool); + if (mbuf == NULL) { + PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for flow add."); + return -ENOMEM; + } + + /* copy the flow to mbuf */ + nfp_flow_meta = flow->payload.meta; + msg_len = (nfp_flow_meta->key_len + nfp_flow_meta->mask_len + + nfp_flow_meta->act_len) << NFP_FL_LW_SIZ; + msg_len += sizeof(struct nfp_fl_rule_metadata); + msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_FLOW_ADD, msg_len); + rte_memcpy(msg, flow->payload.meta, msg_len); + + cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf); + if (cnt == 0) { + PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed."); + rte_pktmbuf_free(mbuf); + return -EIO; + } + + return 0; +} diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 5c28363..6045bb0 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -189,10 +189,58 @@ enum nfp_flower_cmsg_port_vnic_type { return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN; } +/* + * Metadata with L2 (1W/4B) + * ---------------------------------------------------------------- + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | key_type | mask_id | PCP |p| vlan outermost VID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * ^ ^ + * NOTE: | TCI | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_flower_meta_tci { + uint8_t nfp_flow_key_layer; + uint8_t mask_id; + rte_be16_t tci; +}; + +/* + * Extended metadata for additional key_layers (1W/4B) + * ---------------------------------------------------------------- + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | nfp_flow_key_layer2 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_flower_ext_meta { + rte_be32_t nfp_flow_key_layer2; +}; + +/* + * L1 Port details (1W/4B) + * ---------------------------------------------------------------- + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | port_ingress | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_flower_in_port { + rte_be32_t in_port; +}; + int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower); int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower, struct nfp_flower_representor *repr); int nfp_flower_cmsg_port_mod(struct nfp_app_fw_flower *app_fw_flower, uint32_t port_id, bool carrier_ok); +int nfp_flower_cmsg_flow_delete(struct nfp_app_fw_flower *app_fw_flower, + struct rte_flow *flow); +int nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower, + struct rte_flow *flow); #endif /* _NFP_CMSG_H_ */ diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 0e60f50..f1cd298 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -10,6 +10,7 @@ #include "../nfp_logs.h" #include "../nfp_ctrl.h" #include "../nfp_rxtx.h" +#include "../nfp_flow.h" #include "../nfpcore/nfp_mip.h" #include "../nfpcore/nfp_rtsym.h" #include "../nfpcore/nfp_nsp.h" @@ -590,6 +591,8 @@ .promiscuous_disable = nfp_flower_repr_promiscuous_disable, .mac_addr_set = nfp_flower_repr_mac_addr_set, + + .flow_ops_get = nfp_net_flow_ops_get, }; static uint32_t diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 8c36e97..eb1e42c 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -7,11 +7,15 @@ #include #include #include +#include #include "nfp_common.h" #include "nfp_flow.h" #include "nfp_logs.h" #include "flower/nfp_flower.h" +#include "flower/nfp_flower_cmsg.h" +#include "flower/nfp_flower_ctrl.h" +#include "flower/nfp_flower_representor.h" #include "nfpcore/nfp_mip.h" #include "nfpcore/nfp_rtsym.h" @@ -21,6 +25,15 @@ struct nfp_mask_id_entry { uint8_t mask_id; }; +static inline struct nfp_flow_priv * +nfp_flow_dev_to_priv(struct rte_eth_dev *dev) +{ + struct nfp_flower_representor *repr; + + repr = (struct nfp_flower_representor *)dev->data->dev_private; + return repr->app_fw_flower->flow_priv; +} + static int nfp_mask_id_alloc(struct nfp_flow_priv *priv, uint8_t *mask_id) { @@ -160,7 +173,7 @@ struct nfp_mask_id_entry { return entry; } -__rte_unused static bool +static bool nfp_check_mask_add(struct nfp_flow_priv *priv, char *mask_data, uint32_t mask_len, @@ -187,7 +200,7 @@ struct nfp_mask_id_entry { return true; } -__rte_unused static bool +static bool nfp_check_mask_remove(struct nfp_flow_priv *priv, char *mask_data, uint32_t mask_len, @@ -215,7 +228,7 @@ struct nfp_mask_id_entry { return true; } -__rte_unused static int +static int nfp_flow_table_add(struct nfp_flow_priv *priv, struct rte_flow *nfp_flow) { @@ -230,7 +243,7 @@ struct nfp_mask_id_entry { return 0; } -__rte_unused static int +static int nfp_flow_table_delete(struct nfp_flow_priv *priv, struct rte_flow *nfp_flow) { @@ -245,7 +258,7 @@ struct nfp_mask_id_entry { return 0; } -__rte_unused static struct rte_flow * +static struct rte_flow * nfp_flow_table_search(struct nfp_flow_priv *priv, struct rte_flow *nfp_flow) { @@ -262,7 +275,7 @@ struct nfp_mask_id_entry { return flow_find; } -__rte_unused static struct rte_flow * +static struct rte_flow * nfp_flow_alloc(struct nfp_fl_key_ls *key_layer) { char *tmp; @@ -295,14 +308,14 @@ struct nfp_mask_id_entry { return NULL; } -__rte_unused static void +static void nfp_flow_free(struct rte_flow *nfp_flow) { rte_free(nfp_flow->payload.meta); rte_free(nfp_flow); } -__rte_unused static int +static int nfp_stats_id_alloc(struct nfp_flow_priv *priv, uint32_t *ctx) { struct circ_buf *ring; @@ -337,7 +350,7 @@ struct nfp_mask_id_entry { return 0; } -__rte_unused static int +static int nfp_stats_id_free(struct nfp_flow_priv *priv, uint32_t ctx) { struct circ_buf *ring; @@ -355,6 +368,567 @@ struct nfp_mask_id_entry { return 0; } +static void +nfp_flower_compile_meta_tci(char *mbuf_off, struct nfp_fl_key_ls *key_layer) +{ + struct nfp_flower_meta_tci *tci_meta; + + tci_meta = (struct nfp_flower_meta_tci *)mbuf_off; + tci_meta->nfp_flow_key_layer = key_layer->key_layer; + tci_meta->mask_id = ~0; + tci_meta->tci = rte_cpu_to_be_16(key_layer->vlan); +} + +static void +nfp_flower_update_meta_tci(char *exact, uint8_t mask_id) +{ + struct nfp_flower_meta_tci *meta_tci; + + meta_tci = (struct nfp_flower_meta_tci *)exact; + meta_tci->mask_id = mask_id; +} + +static void +nfp_flower_compile_ext_meta(char *mbuf_off, struct nfp_fl_key_ls *key_layer) +{ + struct nfp_flower_ext_meta *ext_meta; + + ext_meta = (struct nfp_flower_ext_meta *)mbuf_off; + ext_meta->nfp_flow_key_layer2 = rte_cpu_to_be_32(key_layer->key_layer_two); +} + +static void +nfp_compile_meta_port(char *mbuf_off, + struct nfp_fl_key_ls *key_layer, + bool is_mask) +{ + struct nfp_flower_in_port *port_meta; + + port_meta = (struct nfp_flower_in_port *)mbuf_off; + + if (is_mask) + port_meta->in_port = rte_cpu_to_be_32(~0); + else if (key_layer->tun_type) + port_meta->in_port = rte_cpu_to_be_32(NFP_FL_PORT_TYPE_TUN | + key_layer->tun_type); + else + port_meta->in_port = rte_cpu_to_be_32(key_layer->port); +} + +static void +nfp_flow_compile_metadata(struct nfp_flow_priv *priv, + struct rte_flow *nfp_flow, + struct nfp_fl_key_ls *key_layer, + uint32_t stats_ctx) +{ + struct nfp_fl_rule_metadata *nfp_flow_meta; + char *mbuf_off_exact; + char *mbuf_off_mask; + + /* + * Convert to long words as firmware expects + * lengths in units of NFP_FL_LW_SIZ. + */ + nfp_flow_meta = nfp_flow->payload.meta; + nfp_flow_meta->key_len = key_layer->key_size >> NFP_FL_LW_SIZ; + nfp_flow_meta->mask_len = key_layer->key_size >> NFP_FL_LW_SIZ; + nfp_flow_meta->act_len = key_layer->act_size >> NFP_FL_LW_SIZ; + nfp_flow_meta->flags = 0; + nfp_flow_meta->host_ctx_id = rte_cpu_to_be_32(stats_ctx); + nfp_flow_meta->host_cookie = rte_rand(); + nfp_flow_meta->flow_version = rte_cpu_to_be_64(priv->flower_version); + + mbuf_off_exact = nfp_flow->payload.unmasked_data; + mbuf_off_mask = nfp_flow->payload.mask_data; + + /* Populate Metadata */ + nfp_flower_compile_meta_tci(mbuf_off_exact, key_layer); + nfp_flower_compile_meta_tci(mbuf_off_mask, key_layer); + mbuf_off_exact += sizeof(struct nfp_flower_meta_tci); + mbuf_off_mask += sizeof(struct nfp_flower_meta_tci); + + /* Populate Extended Metadata if required */ + if (key_layer->key_layer & NFP_FLOWER_LAYER_EXT_META) { + nfp_flower_compile_ext_meta(mbuf_off_exact, key_layer); + nfp_flower_compile_ext_meta(mbuf_off_mask, key_layer); + mbuf_off_exact += sizeof(struct nfp_flower_ext_meta); + mbuf_off_mask += sizeof(struct nfp_flower_ext_meta); + } + + /* Populate Port Data */ + nfp_compile_meta_port(mbuf_off_exact, key_layer, false); + nfp_compile_meta_port(mbuf_off_mask, key_layer, true); + mbuf_off_exact += sizeof(struct nfp_flower_in_port); + mbuf_off_mask += sizeof(struct nfp_flower_in_port); +} + +static int +nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], + __rte_unused struct nfp_fl_key_ls *key_ls) +{ + const struct rte_flow_item *item; + + for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) { + switch (item->type) { + default: + PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type); + return -ENOTSUP; + } + } + + return 0; +} + +static int +nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], + struct nfp_fl_key_ls *key_ls) +{ + int ret = 0; + const struct rte_flow_action *action; + + for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { + /* Make sure actions length no longer than NFP_FL_MAX_A_SIZ */ + if (key_ls->act_size > NFP_FL_MAX_A_SIZ) { + PMD_DRV_LOG(ERR, "The action list is too long."); + ret = -ERANGE; + break; + } + + switch (action->type) { + case RTE_FLOW_ACTION_TYPE_VOID: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_VOID detected"); + break; + default: + PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type); + return -ENOTSUP; + } + } + + return ret; +} + +static int +nfp_flow_key_layers_calculate(const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct nfp_fl_key_ls *key_ls) +{ + int ret = 0; + + key_ls->key_layer_two = 0; + key_ls->key_layer = NFP_FLOWER_LAYER_PORT; + key_ls->key_size = sizeof(struct nfp_flower_meta_tci) + + sizeof(struct nfp_flower_in_port); + key_ls->act_size = 0; + key_ls->port = ~0; + key_ls->vlan = 0; + key_ls->tun_type = NFP_FL_TUN_NONE; + + ret |= nfp_flow_key_layers_calculate_items(items, key_ls); + ret |= nfp_flow_key_layers_calculate_actions(actions, key_ls); + + return ret; +} + +static struct rte_flow * +nfp_flow_process(struct nfp_flower_representor *representor, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + bool validate_flag) +{ + int ret; + char *hash_data; + char *mask_data; + uint32_t mask_len; + uint32_t stats_ctx = 0; + uint8_t new_mask_id = 0; + struct rte_flow *nfp_flow; + struct rte_flow *flow_find; + struct nfp_flow_priv *priv; + struct nfp_fl_key_ls key_layer; + struct nfp_fl_rule_metadata *nfp_flow_meta; + + ret = nfp_flow_key_layers_calculate(items, actions, &key_layer); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Key layers calculate failed."); + return NULL; + } + + if (key_layer.port == (uint32_t)~0) + key_layer.port = representor->port_id; + + priv = representor->app_fw_flower->flow_priv; + ret = nfp_stats_id_alloc(priv, &stats_ctx); + if (ret != 0) { + PMD_DRV_LOG(ERR, "nfp stats id alloc failed."); + return NULL; + } + + nfp_flow = nfp_flow_alloc(&key_layer); + if (nfp_flow == NULL) { + PMD_DRV_LOG(ERR, "Alloc nfp flow failed."); + goto free_stats; + } + + nfp_flow->install_flag = true; + + nfp_flow_compile_metadata(priv, nfp_flow, &key_layer, stats_ctx); + + nfp_flow_meta = nfp_flow->payload.meta; + mask_data = nfp_flow->payload.mask_data; + mask_len = key_layer.key_size; + if (!nfp_check_mask_add(priv, mask_data, mask_len, + &nfp_flow_meta->flags, &new_mask_id)) { + PMD_DRV_LOG(ERR, "nfp mask add check failed."); + goto free_flow; + } + + /* Once we have a mask_id, update the meta tci */ + nfp_flower_update_meta_tci(nfp_flow->payload.unmasked_data, new_mask_id); + + /* Calculate and store the hask_key for later use */ + hash_data = (char *)(nfp_flow->payload.unmasked_data); + nfp_flow->hash_key = rte_jhash(hash_data, nfp_flow->length, priv->hash_seed); + + /* Find the flow in hash table */ + flow_find = nfp_flow_table_search(priv, nfp_flow); + if (flow_find != NULL) { + PMD_DRV_LOG(ERR, "This flow is already exist."); + if (!nfp_check_mask_remove(priv, mask_data, mask_len, + &nfp_flow_meta->flags)) { + PMD_DRV_LOG(ERR, "nfp mask del check failed."); + } + goto free_flow; + } + + /* Flow validate should not update the flower version */ + if (!validate_flag) + priv->flower_version++; + + return nfp_flow; + +free_flow: + nfp_flow_free(nfp_flow); +free_stats: + nfp_stats_id_free(priv, stats_ctx); + + return NULL; +} + +static struct rte_flow * +nfp_flow_setup(struct nfp_flower_representor *representor, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct rte_flow_error *error, + bool validate_flag) +{ + if (attr->group != 0) + PMD_DRV_LOG(INFO, "Pretend we support group attribute."); + + if (attr->priority != 0) + PMD_DRV_LOG(INFO, "Pretend we support priority attribute."); + + if (attr->transfer != 0) + PMD_DRV_LOG(INFO, "Pretend we support transfer attribute."); + + if (attr->egress != 0) { + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, + NULL, "Egress is not supported."); + return NULL; + } + + if (attr->ingress == 0) { + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, + NULL, "Only ingress is supported."); + return NULL; + } + + return nfp_flow_process(representor, items, actions, validate_flag); +} + +static int +nfp_flow_teardown(struct nfp_flow_priv *priv, + struct rte_flow *nfp_flow, + bool validate_flag) +{ + char *mask_data; + uint32_t mask_len; + uint32_t stats_ctx; + struct nfp_fl_rule_metadata *nfp_flow_meta; + + nfp_flow_meta = nfp_flow->payload.meta; + mask_data = nfp_flow->payload.mask_data; + mask_len = nfp_flow_meta->mask_len << NFP_FL_LW_SIZ; + if (!nfp_check_mask_remove(priv, mask_data, mask_len, + &nfp_flow_meta->flags)) { + PMD_DRV_LOG(ERR, "nfp mask del check failed."); + return -EINVAL; + } + + nfp_flow_meta->flow_version = rte_cpu_to_be_64(priv->flower_version); + + /* Flow validate should not update the flower version */ + if (!validate_flag) + priv->flower_version++; + + stats_ctx = rte_be_to_cpu_32(nfp_flow_meta->host_ctx_id); + return nfp_stats_id_free(priv, stats_ctx); +} + +static int +nfp_flow_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) +{ + int ret; + struct rte_flow *nfp_flow; + struct nfp_flow_priv *priv; + struct nfp_flower_representor *representor; + + representor = (struct nfp_flower_representor *)dev->data->dev_private; + priv = representor->app_fw_flower->flow_priv; + + nfp_flow = nfp_flow_setup(representor, attr, items, actions, error, true); + if (nfp_flow == NULL) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "This flow can not be offloaded."); + } + + ret = nfp_flow_teardown(priv, nfp_flow, true); + if (ret != 0) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Flow resource free failed."); + } + + nfp_flow_free(nfp_flow); + + return 0; +} + +static struct rte_flow * +nfp_flow_create(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) +{ + int ret; + struct rte_flow *nfp_flow; + struct nfp_flow_priv *priv; + struct nfp_app_fw_flower *app_fw_flower; + struct nfp_flower_representor *representor; + + representor = (struct nfp_flower_representor *)dev->data->dev_private; + app_fw_flower = representor->app_fw_flower; + priv = app_fw_flower->flow_priv; + + nfp_flow = nfp_flow_setup(representor, attr, items, actions, error, false); + if (nfp_flow == NULL) { + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "This flow can not be offloaded."); + return NULL; + } + + /* Add the flow to hardware */ + if (nfp_flow->install_flag) { + ret = nfp_flower_cmsg_flow_add(app_fw_flower, nfp_flow); + if (ret != 0) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Add flow to firmware failed."); + goto flow_teardown; + } + } + + /* Add the flow to flow hash table */ + ret = nfp_flow_table_add(priv, nfp_flow); + if (ret != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Add flow to the flow table failed."); + goto flow_teardown; + } + + return nfp_flow; + +flow_teardown: + nfp_flow_teardown(priv, nfp_flow, false); + nfp_flow_free(nfp_flow); + + return NULL; +} + +static int +nfp_flow_destroy(struct rte_eth_dev *dev, + struct rte_flow *nfp_flow, + struct rte_flow_error *error) +{ + int ret; + struct rte_flow *flow_find; + struct nfp_flow_priv *priv; + struct nfp_app_fw_flower *app_fw_flower; + struct nfp_flower_representor *representor; + + representor = (struct nfp_flower_representor *)dev->data->dev_private; + app_fw_flower = representor->app_fw_flower; + priv = app_fw_flower->flow_priv; + + /* Find the flow in flow hash table */ + flow_find = nfp_flow_table_search(priv, nfp_flow); + if (flow_find == NULL) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Flow does not exist."); + ret = -EINVAL; + goto exit; + } + + /* Update flow */ + ret = nfp_flow_teardown(priv, nfp_flow, false); + if (ret != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Flow teardown failed."); + ret = -EINVAL; + goto exit; + } + + /* Delete the flow from hardware */ + if (nfp_flow->install_flag) { + ret = nfp_flower_cmsg_flow_delete(app_fw_flower, nfp_flow); + if (ret != 0) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Delete flow from firmware failed."); + ret = -EINVAL; + goto exit; + } + } + + /* Delete the flow from flow hash table */ + ret = nfp_flow_table_delete(priv, nfp_flow); + if (ret != 0) { + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Delete flow from the flow table failed."); + ret = -EINVAL; + goto exit; + } + +exit: + nfp_flow_free(nfp_flow); + + return ret; +} + +static int +nfp_flow_flush(struct rte_eth_dev *dev, + struct rte_flow_error *error) +{ + int ret = 0; + void *next_data; + uint32_t iter = 0; + const void *next_key; + struct nfp_flow_priv *priv; + + priv = nfp_flow_dev_to_priv(dev); + + while (rte_hash_iterate(priv->flow_table, &next_key, &next_data, &iter) >= 0) { + ret = nfp_flow_destroy(dev, (struct rte_flow *)next_data, error); + if (ret != 0) + break; + } + + return ret; +} + +static void +nfp_flow_stats_get(struct rte_eth_dev *dev, + struct rte_flow *nfp_flow, + void *data) +{ + uint32_t ctx_id; + struct rte_flow *flow; + struct nfp_flow_priv *priv; + struct nfp_fl_stats *stats; + struct rte_flow_query_count *query; + + priv = nfp_flow_dev_to_priv(dev); + flow = nfp_flow_table_search(priv, nfp_flow); + if (flow == NULL) { + PMD_DRV_LOG(ERR, "Can not find statistics for this flow."); + return; + } + + query = (struct rte_flow_query_count *)data; + memset(query, 0, sizeof(*query)); + + ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id); + stats = &priv->stats[ctx_id]; + + rte_spinlock_lock(&priv->stats_lock); + if (stats->pkts != 0 && stats->bytes != 0) { + query->hits = stats->pkts; + query->bytes = stats->bytes; + query->hits_set = 1; + query->bytes_set = 1; + if (query->reset != 0) { + stats->pkts = 0; + stats->bytes = 0; + } + } + rte_spinlock_unlock(&priv->stats_lock); +} + +static int +nfp_flow_query(struct rte_eth_dev *dev, + struct rte_flow *nfp_flow, + const struct rte_flow_action *actions, + void *data, + struct rte_flow_error *error) +{ + const struct rte_flow_action *action; + + for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { + switch (action->type) { + case RTE_FLOW_ACTION_TYPE_VOID: + break; + case RTE_FLOW_ACTION_TYPE_COUNT: + nfp_flow_stats_get(dev, nfp_flow, data); + break; + default: + rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Unsupported action type for flow query."); + return -ENOTSUP; + } + } + + return 0; +} + +static const struct rte_flow_ops nfp_flow_ops = { + .validate = nfp_flow_validate, + .create = nfp_flow_create, + .destroy = nfp_flow_destroy, + .flush = nfp_flow_flush, + .query = nfp_flow_query, +}; + +int +nfp_net_flow_ops_get(struct rte_eth_dev *dev, + const struct rte_flow_ops **ops) +{ + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) { + *ops = NULL; + PMD_DRV_LOG(ERR, "Port is not a representor."); + return -EINVAL; + } + + *ops = &nfp_flow_ops; + + return 0; +} + int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev) { diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h index e8fd22a..6fa1b3e 100644 --- a/drivers/net/nfp/nfp_flow.h +++ b/drivers/net/nfp/nfp_flow.h @@ -6,10 +6,36 @@ #ifndef _NFP_FLOW_H_ #define _NFP_FLOW_H_ +#include + +#define NFP_FLOWER_LAYER_EXT_META (1 << 0) +#define NFP_FLOWER_LAYER_PORT (1 << 1) +#define NFP_FLOWER_LAYER_MAC (1 << 2) +#define NFP_FLOWER_LAYER_TP (1 << 3) +#define NFP_FLOWER_LAYER_IPV4 (1 << 4) +#define NFP_FLOWER_LAYER_IPV6 (1 << 5) +#define NFP_FLOWER_LAYER_CT (1 << 6) +#define NFP_FLOWER_LAYER_VXLAN (1 << 7) + +#define NFP_FLOWER_LAYER2_GRE (1 << 0) +#define NFP_FLOWER_LAYER2_QINQ (1 << 4) +#define NFP_FLOWER_LAYER2_GENEVE (1 << 5) +#define NFP_FLOWER_LAYER2_GENEVE_OP (1 << 6) +#define NFP_FLOWER_LAYER2_TUN_IPV6 (1 << 7) + #define NFP_FL_META_FLAG_MANAGE_MASK (1 << 7) #define NFP_MASK_TABLE_ENTRIES 1024 +/* The maximum action list size (in bytes) supported by the NFP. */ +#define NFP_FL_MAX_A_SIZ 1216 + +/* The firmware expects lengths in units of long words */ +#define NFP_FL_LW_SIZ 2 + +/* Tunnel ports */ +#define NFP_FL_PORT_TYPE_TUN 0x50000000 + enum nfp_flower_tun_type { NFP_FL_TUN_NONE = 0, NFP_FL_TUN_GRE = 1, @@ -75,6 +101,7 @@ struct nfp_fl_stats { struct nfp_flow_priv { uint32_t hash_seed; /**< Hash seed for hash tables in this structure. */ + uint64_t flower_version; /**< Flow version, always increase. */ /* mask hash table */ struct nfp_fl_mask_id mask_ids; /**< Entry for mask hash table */ struct rte_hash *mask_table; /**< Hash table to store mask ids. */ @@ -98,5 +125,6 @@ struct rte_flow { int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev); void nfp_flow_priv_uninit(struct nfp_pf_dev *pf_dev); +int nfp_net_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops); #endif /* _NFP_FLOW_H_ */ -- 1.8.3.1