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 C6D59454A5; Wed, 19 Jun 2024 12:04:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 92D2042D72; Wed, 19 Jun 2024 12:04:10 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2129.outbound.protection.outlook.com [40.107.96.129]) by mails.dpdk.org (Postfix) with ESMTP id D5DBE40B99 for ; Wed, 19 Jun 2024 12:03:49 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JPxVcmSMhdXKBfD0D8WpXnyUQ4Wix1r8kSVo07j9Acl0VWUQmuUgpyHjLjg6neL0HL7UhWf/F8Boo2QGcZ8ADM61fFb6XccxGhKjujC6Ej1P+Afa0LfKryLgZ3rngX1d24MJ6R300uy0eroAsixc1th6y4TuA/6RhDxHu+cw+iqgy3liRDDOn1jPujkNqqcVNDer8K+2Ii9jwXhi68ALFq8P8+ZZvw1xt+ol8AD83yE3XJO80QHqHAiTJgQr3pxSAKLbKugOfSkIhuPKtjpEgCITmdOKsSbhAymUGAhbcZ0zdG2S4HhFDKjrTc17iclTrlPHvdllbdch6ZpCT0hcIg== 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=QwxOpAcoNH1mHcyoUpUyONePjtnAM9e5yIzno6biJgY=; b=Apc5DxdfJ2e0T2ynbsyldXknvHfNp7mac8uIlv6ch+6eqFPtOqmFwBTHVe9d75/C1eYgbdnV/7Pvd4yX/btlEeXrbWPzI5kCqEd1E4WJlr/Aes8a833QooN3/1PWPg94gQFvEz11WbC0NcVUc6YLJaikn7hgYQ6uMXtli9269nSwP3pDGeCDdEDTRzGYdqynMTc+OUt/SYDy9LkWDUnpQGEjxxC5uKfVRuXBzs8UYBVZG62PSK3+amCQAMJQPLgM3J0iomvqPj2u10/Qwx7tBKijMYdpKFJPmp8QUgLgkJn6EBQ3VQTiA5zQxi4ArQftLIc/6zqp0wDLQJ5yR+J8og== 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=QwxOpAcoNH1mHcyoUpUyONePjtnAM9e5yIzno6biJgY=; b=GhFQ1ncJiraygkW2tpfCm+dTOi8hTyfiYddFiUq6hSw7g/QglEIDubPGfKQNZW1/tlhWHZYBtlvigU3fWqHhNpIwkDEZd3PQEkCE52myaoklgVFRwNoq9NsvSb0tRPCxnW8/g+zTV18XeXFIPuTGxcCvmi7Q36OYq18y31mGiOk= 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 MWHPR13MB7153.namprd13.prod.outlook.com (2603:10b6:303:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Wed, 19 Jun 2024 10:03:47 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7677.030; Wed, 19 Jun 2024 10:03:47 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He , Peng Zhang Subject: [PATCH] net/nfp: add partial flow control message Date: Wed, 19 Jun 2024 18:03:31 +0800 Message-Id: <20240619100331.3479906-1-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR06CA0045.namprd06.prod.outlook.com (2603:10b6:a03:14b::22) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MWHPR13MB7153:EE_ X-MS-Office365-Filtering-Correlation-Id: ff0c80cd-f0c8-4d1a-dffb-08dc90471c44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|52116011|376011|1800799021|366013|38350700011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rEbgswcbw/V9ylBOsrtbmnCtNH2xYHsyWhlzplio1WtBXxmZ5trzhjI44uov?= =?us-ascii?Q?4G453mXy+nB5QIOPjpL4K31LkekfYIEVvT+NS1k7NrLfTAgdFGt4bkVRqGti?= =?us-ascii?Q?+cToYVaKBuBotzlxqQm+sujZNW0x+rrgd3GvYHl+oH/lzRa8c6dYizHqotV1?= =?us-ascii?Q?miKJ24aNpx/3hveMV+PjeHSOoIIReJwDh3a0U8YbXL2UjeWWLSPxvpq2tASp?= =?us-ascii?Q?gooMnMSnpGOWacvsjocLNOfylgH1vGAOuWksGoivAkmngaOwA4/9rcn6kjC+?= =?us-ascii?Q?x6bSy++dGMPcjhXdEWweKtZkVJdML6R/hJ+/Q6EluGly35TT8xJ5gU92IvDI?= =?us-ascii?Q?cEt5MaflK60ARWENhhowqJDToHxI+ShH5QoAfi1DhTv4zCb3RguXLEsDtTbP?= =?us-ascii?Q?WerrkZKKl03Dhw6Wz/QflYnLvmWEPKUX9yc7W6weFfFKY7AHs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MC2AhfeFFdYD1OHDOZBL+xq+nz++a0fvXCOKUyqb0p7?= =?us-ascii?Q?/VYcrq0=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(52116011)(376011)(1800799021)(366013)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aIuITH4s02kxeIKSJSBFZHwnoTGyykwshUwopFv7rwcHQTX5kj50/zTdebvC?= =?us-ascii?Q?pqohka57VWUBZKoLFLpfMM4tw90TzOOYD9VxTkErO6SMgytpHUTVd7dklUNk?= =?us-ascii?Q?7zGf6BdsNEK6r1ABBvRNF/DSVJ9rNQQ3LVaTOsyhA0U+4YLJjme88MbQMTYh?= =?us-ascii?Q?AAx8tuFOF6gsO7idYqYOjJETsAy2GUAfrKE0/Be7jEhRIT7Gm9WbSA2/LzUA?= =?us-ascii?Q?JzUD6BXlVSAPT2jKG02fz/haywg5iTbbjM+Kv2ARGxqnhOOkc4+TPERehL7r?= =?us-ascii?Q?murU821dJNZWfAwhW4xSzI5AWHI5YTf88MRCfprpDsIGxyGPunvZfqKbIX8O?= =?us-ascii?Q?h8SuLTLNDfBAq7WA0t1k42+0yKygPMEFkXJ7oyuJQI4cKvBTvXgD0HTSAOlC?= =?us-ascii?Q?hV1ELnvcqDD8+I4UKCbroya6T31f6hUtso6fDe7bw2mVMTz7Gifn4QZo3oWE?= =?us-ascii?Q?nfli9GKWJTUCP13x9nV/M8qz30xcEP7GYS+3Zy7rQ/1aGFeF+vV3CROw9GQC?= =?us-ascii?Q?ti8U5e75I9AOnnJ2h0yqxutwbzH2j4ajMbzMppv/bgruLh78HJa+jl+fapUJ?= =?us-ascii?Q?ESH4XWcAOyomiIzu1grB/Do4/+N/jNyOHrgcjPFuITPM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Kakzmn97RcnjR6lfScTp5fDsDGBnAUtMaZWvgH?= =?us-ascii?Q?NaNR5RBLtm24Dqwsim3kGdPHzDNs3h2BE33Q4TgAQyKpyjJwmIMW1wk0B8Nz?= =?us-ascii?Q?dw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff0c80cd-f0c8-4d1a-dffb-08dc90471c44 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2024 10:03:47.7936 (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: h8YGCU8jBRF+VjPRtzke88ItMdJkIHsNBQUPR3Jn+9qINFdjWauA3t3YxC8byVrHlGpmgF9hzVjspxcBqdwmVrmxmLDDUD6qaZjhLgt+Ar4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR13MB7153 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 From: Long Wu With new firmware, NFP PMD will use partial flow control message to notify firmware the configuration of mark&queue action. Moreover, if partial flow control message contains both queue&mark configuration, the whole flow control message can only contain partial flow control message. With old firmware, NFP PMD does not support queue action and still use mark flow control message to notify firmware the configuration of mark action. NFP PMD will use the 'NFP_FL_FEATS_FLOW_PARTIAL' and flower extra features to distinguish the firmware is new or old. Signed-off-by: Long Wu Signed-off-by: Chaoyong He Reviewed-by: Peng Zhang --- drivers/net/nfp/flower/nfp_conntrack.c | 42 +++--- drivers/net/nfp/flower/nfp_conntrack.h | 2 +- drivers/net/nfp/flower/nfp_flower.h | 1 + drivers/net/nfp/flower/nfp_flower_cmsg.h | 24 ++++ drivers/net/nfp/flower/nfp_flower_flow.c | 167 ++++++++++++++++++++--- drivers/net/nfp/flower/nfp_flower_flow.h | 2 +- 6 files changed, 202 insertions(+), 36 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_conntrack.c b/drivers/net/nfp/flower/nfp_conntrack.c index b0641b03d2..eff52c66ee 100644 --- a/drivers/net/nfp/flower/nfp_conntrack.c +++ b/drivers/net/nfp/flower/nfp_conntrack.c @@ -36,7 +36,7 @@ struct nfp_ct_flow_entry { LIST_ENTRY(nfp_ct_flow_entry) post_ct_list; LIST_HEAD(, nfp_ct_merge_entry) children; enum ct_entry_type type; - struct nfp_flower_representor *repr; + struct rte_eth_dev *dev; struct nfp_ct_zone_entry *ze; struct nfp_initial_flow rule; struct nfp_fl_stats stats; @@ -660,7 +660,7 @@ nfp_ct_flow_actions_copy(const struct rte_flow_action *src, static struct nfp_ct_flow_entry * nfp_ct_flow_entry_get(struct nfp_ct_zone_entry *ze, - struct nfp_flower_representor *repr, + struct rte_eth_dev *dev, const struct rte_flow_item items[], const struct rte_flow_action actions[], uint64_t cookie) @@ -672,6 +672,7 @@ nfp_ct_flow_entry_get(struct nfp_ct_zone_entry *ze, struct nfp_flow_priv *priv; struct nfp_ct_map_entry *me; struct nfp_ct_flow_entry *fe; + struct nfp_flower_representor *repr; fe = rte_zmalloc("ct_flow_entry", sizeof(*fe), 0); if (fe == NULL) { @@ -680,7 +681,7 @@ nfp_ct_flow_entry_get(struct nfp_ct_zone_entry *ze, } fe->ze = ze; - fe->repr = repr; + fe->dev = dev; fe->cookie = cookie; LIST_INIT(&fe->children); @@ -730,6 +731,7 @@ nfp_ct_flow_entry_get(struct nfp_ct_zone_entry *ze, me->cookie = fe->cookie; me->fe = fe; + repr = dev->data->dev_private; priv = repr->app_fw_flower->flow_priv; ret = nfp_ct_map_table_add(priv, me); if (!ret) { @@ -979,7 +981,7 @@ nfp_ct_zone_entry_free(struct nfp_ct_zone_entry *ze, } static int -nfp_ct_offload_add(struct nfp_flower_representor *repr, +nfp_ct_offload_add(struct rte_eth_dev *dev, struct nfp_ct_merge_entry *merge_entry) { int ret; @@ -987,12 +989,13 @@ nfp_ct_offload_add(struct nfp_flower_representor *repr, struct rte_flow *nfp_flow; struct nfp_flow_priv *priv; const struct rte_flow_item *items; + struct nfp_flower_representor *repr; const struct rte_flow_action *actions; cookie = rte_rand(); items = merge_entry->rule.items; actions = merge_entry->rule.actions; - nfp_flow = nfp_flow_process(repr, items, actions, false, cookie, true, true); + nfp_flow = nfp_flow_process(dev, items, actions, false, cookie, true, true); if (nfp_flow == NULL) { PMD_DRV_LOG(ERR, "Process the merged flow rule failed."); return -EINVAL; @@ -1001,6 +1004,7 @@ nfp_ct_offload_add(struct nfp_flower_representor *repr, merge_entry->ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id); /* Add the flow to hardware */ + repr = dev->data->dev_private; priv = repr->app_fw_flower->flow_priv; ret = nfp_flower_cmsg_flow_add(repr->app_fw_flower, nfp_flow); if (ret != 0) { @@ -1442,7 +1446,7 @@ nfp_ct_do_flow_merge(struct nfp_ct_zone_entry *ze, uint8_t cnt_same_action = 0; struct nfp_ct_merge_entry *merge_entry; - if (pre_ct_entry->repr != post_ct_entry->repr) + if (pre_ct_entry->dev != post_ct_entry->dev) return true; ret = nfp_ct_merge_items_check(pre_ct_entry->rule.items, @@ -1504,7 +1508,7 @@ nfp_ct_do_flow_merge(struct nfp_ct_zone_entry *ze, } /* Send to firmware */ - ret = nfp_ct_offload_add(pre_ct_entry->repr, merge_entry); + ret = nfp_ct_offload_add(pre_ct_entry->dev, merge_entry); if (ret != 0) { PMD_DRV_LOG(ERR, "Send the merged flow to firmware failed"); goto merge_table_del; @@ -1557,7 +1561,7 @@ nfp_ct_merge_flow_entries(struct nfp_ct_flow_entry *fe, static bool nfp_flow_handle_pre_ct(const struct rte_flow_item *ct_item, - struct nfp_flower_representor *representor, + struct rte_eth_dev *dev, const struct rte_flow_item items[], const struct rte_flow_action actions[], uint64_t cookie) @@ -1567,7 +1571,9 @@ nfp_flow_handle_pre_ct(const struct rte_flow_item *ct_item, struct nfp_ct_zone_entry *ze; struct nfp_ct_flow_entry *fe; const struct ct_data *ct = ct_item->spec; + struct nfp_flower_representor *representor; + representor = dev->data->dev_private; priv = representor->app_fw_flower->flow_priv; ze = nfp_ct_zone_entry_get(priv, ct->ct_zone, false); if (ze == NULL) { @@ -1576,7 +1582,7 @@ nfp_flow_handle_pre_ct(const struct rte_flow_item *ct_item, } /* Add entry to pre_ct_list */ - fe = nfp_ct_flow_entry_get(ze, representor, items, actions, cookie); + fe = nfp_ct_flow_entry_get(ze, dev, items, actions, cookie); if (fe == NULL) { PMD_DRV_LOG(ERR, "Could not get ct flow entry"); goto ct_zone_entry_free; @@ -1613,7 +1619,7 @@ nfp_flow_handle_pre_ct(const struct rte_flow_item *ct_item, static bool nfp_flow_handle_post_ct(const struct rte_flow_item *ct_item, - struct nfp_flower_representor *representor, + struct rte_eth_dev *dev, const struct rte_flow_item items[], const struct rte_flow_action actions[], uint64_t cookie) @@ -1626,6 +1632,7 @@ nfp_flow_handle_post_ct(const struct rte_flow_item *ct_item, struct nfp_flow_priv *priv; struct nfp_ct_zone_entry *ze; struct nfp_ct_flow_entry *fe; + struct nfp_flower_representor *representor; const struct ct_data *ct = ct_item->spec; const struct ct_data *ct_mask = ct_item->mask; @@ -1636,6 +1643,7 @@ nfp_flow_handle_post_ct(const struct rte_flow_item *ct_item, return false; } + representor = dev->data->dev_private; priv = representor->app_fw_flower->flow_priv; ze = nfp_ct_zone_entry_get(priv, ct->ct_zone, wildcard); if (ze == NULL) { @@ -1644,7 +1652,7 @@ nfp_flow_handle_post_ct(const struct rte_flow_item *ct_item, } /* Add entry to post_ct_list */ - fe = nfp_ct_flow_entry_get(ze, representor, items, actions, cookie); + fe = nfp_ct_flow_entry_get(ze, dev, items, actions, cookie); if (fe == NULL) { PMD_DRV_LOG(ERR, "Could not get ct flow entry"); goto ct_zone_entry_free; @@ -1681,7 +1689,7 @@ nfp_flow_handle_post_ct(const struct rte_flow_item *ct_item, } struct rte_flow * -nfp_ct_flow_setup(struct nfp_flower_representor *representor, +nfp_ct_flow_setup(struct rte_eth_dev *dev, const struct rte_flow_item items[], const struct rte_flow_action actions[], const struct rte_flow_item *ct_item, @@ -1696,14 +1704,14 @@ nfp_ct_flow_setup(struct nfp_flower_representor *representor, ct = ct_item->spec; if (is_ct_commit_flow(ct)) { - return nfp_flow_process(representor, &items[1], actions, + return nfp_flow_process(dev, &items[1], actions, validate_flag, cookie, false, false); } if (is_post_ct_flow(ct)) { - if (nfp_flow_handle_post_ct(ct_item, representor, &items[1], + if (nfp_flow_handle_post_ct(ct_item, dev, &items[1], actions, cookie)) { - return nfp_flow_process(representor, &items[1], actions, + return nfp_flow_process(dev, &items[1], actions, validate_flag, cookie, false, false); } @@ -1712,9 +1720,9 @@ nfp_ct_flow_setup(struct nfp_flower_representor *representor, } if (is_pre_ct_flow(ct, actions)) { - if (nfp_flow_handle_pre_ct(ct_item, representor, &items[1], + if (nfp_flow_handle_pre_ct(ct_item, dev, &items[1], actions, cookie)) { - return nfp_flow_process(representor, &items[1], actions, + return nfp_flow_process(dev, &items[1], actions, validate_flag, cookie, false, false); } diff --git a/drivers/net/nfp/flower/nfp_conntrack.h b/drivers/net/nfp/flower/nfp_conntrack.h index 9bfca236ed..39d4e4b846 100644 --- a/drivers/net/nfp/flower/nfp_conntrack.h +++ b/drivers/net/nfp/flower/nfp_conntrack.h @@ -27,7 +27,7 @@ int nfp_ct_offload_del(struct rte_eth_dev *dev, struct nfp_ct_map_entry *me, struct rte_flow_error *error); -struct rte_flow *nfp_ct_flow_setup(struct nfp_flower_representor *representor, +struct rte_flow *nfp_ct_flow_setup(struct rte_eth_dev *dev, const struct rte_flow_item items[], const struct rte_flow_action actions[], const struct rte_flow_item *ct_item, diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index ae80782df4..b0d8fb0ed4 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -21,6 +21,7 @@ #define NFP_FL_FEATS_QOS_PPS RTE_BIT64(9) #define NFP_FL_FEATS_QOS_METER RTE_BIT64(10) #define NFP_FL_FEATS_DECAP_V2 RTE_BIT64(11) +#define NFP_FL_FEATS_FLOW_PARTIAL RTE_BIT64(13) #define NFP_FL_FEATS_HOST_ACK RTE_BIT64(31) /* diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 93183153aa..5d23227c24 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -976,6 +976,30 @@ struct nfp_fl_act_mark { rte_be32_t mark; }; +/* + * Partial + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | res | opcode | res | len_lw| flag | resv1 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Mark | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | queue_id | resv2 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * flag = 0x0: only mark action + * flag = 0x1: only queue action + * flag = 0x2: mark and queue action + */ +struct nfp_fl_act_partial { + struct nfp_fl_act_head head; + uint8_t flag; + uint8_t resv1; + rte_be32_t mark; + rte_be16_t queue_id; + rte_be16_t resv2; +}; + int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower, struct nfp_pf_dev *pf_dev); int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower, diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index 0fb63013d3..8aafbe4c86 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -83,7 +83,7 @@ #define NFP_FL_ACTION_OPCODE_METER 24 #define NFP_FL_ACTION_OPCODE_CT_NAT_EXT 25 #define NFP_FL_ACTION_OPCODE_PUSH_GENEVE 26 -#define NFP_FL_ACTION_OPCODE_SET_MARK 27 +#define NFP_FL_ACTION_OPCODE_SET_PARTIAL 27 #define NFP_FL_ACTION_OPCODE_NUM 32 #define NFP_FL_OUT_FLAGS_LAST RTE_BIT32(15) @@ -151,6 +151,12 @@ struct __rte_aligned(32) nfp_pre_tun_entry { struct rte_ether_addr mac_addr; }; +static inline bool +nfp_flow_support_partial(struct nfp_flower_representor *repr) +{ + return repr->app_fw_flower->ext_features & NFP_FL_FEATS_FLOW_PARTIAL; +} + static inline struct nfp_flow_priv * nfp_flow_dev_to_priv(struct rte_eth_dev *dev) { @@ -1262,12 +1268,15 @@ struct nfp_action_flag { bool tp_set_flag; bool mac_set_flag; bool ttl_tos_flag; + bool partial_flag; + bool partial_both_flag; /**< Both means Queue and Mark action */ }; struct nfp_action_calculate_param { const struct rte_flow_action *action; struct nfp_fl_key_ls *key_ls; struct nfp_action_flag *flag; + struct rte_eth_dev *dev; }; typedef int (*nfp_flow_key_check_action_fn)(struct nfp_action_calculate_param *param); @@ -1473,21 +1482,46 @@ nfp_flow_action_check_modify(struct nfp_action_calculate_param *param) return 0; } +static int +nfp_flow_action_check_queue(struct nfp_action_calculate_param *param) +{ + struct nfp_flower_representor *repr; + const struct rte_flow_action_queue *queue; + + repr = param->dev->data->dev_private; + if (!nfp_flow_support_partial(repr)) { + PMD_DRV_LOG(ERR, "Queue action not supported"); + return -ENOTSUP; + } + + queue = param->action->conf; + if (queue->index >= param->dev->data->nb_rx_queues || + param->dev->data->rx_queues[queue->index] == NULL) { + PMD_DRV_LOG(ERR, "Queue index is illegal"); + return -EINVAL; + } + + return 0; +} + static nfp_flow_key_check_action_fn check_action_fns[] = { [RTE_FLOW_ACTION_TYPE_PORT_ID] = nfp_flow_action_check_port, [RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT] = nfp_flow_action_check_port, [RTE_FLOW_ACTION_TYPE_METER] = nfp_flow_action_check_meter, [RTE_FLOW_ACTION_TYPE_MODIFY_FIELD] = nfp_flow_action_check_modify, + [RTE_FLOW_ACTION_TYPE_QUEUE] = nfp_flow_action_check_queue, }; static int -nfp_flow_key_layers_check_actions(const struct rte_flow_action actions[]) +nfp_flow_key_layers_check_actions(struct rte_eth_dev *dev, + const struct rte_flow_action actions[]) { int ret; struct nfp_action_flag flag = {}; const struct rte_flow_action *action; struct nfp_action_calculate_param param = { .flag = &flag, + .dev = dev, }; for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { @@ -1616,7 +1650,33 @@ nfp_flow_action_calculate_meter(struct nfp_action_calculate_param *param) static void nfp_flow_action_calculate_mark(struct nfp_action_calculate_param *param) { - param->key_ls->act_size += sizeof(struct nfp_fl_act_mark); + struct nfp_flower_representor *repr; + + repr = param->dev->data->dev_private; + if (!nfp_flow_support_partial(repr)) { + param->key_ls->act_size += sizeof(struct nfp_fl_act_mark); + return; + } + + if (!param->flag->partial_flag) { + param->key_ls->act_size += sizeof(struct nfp_fl_act_partial); + param->flag->partial_flag = true; + return; + } + + param->flag->partial_both_flag = true; +} + +static void +nfp_flow_action_calculate_queue(struct nfp_action_calculate_param *param) +{ + if (!param->flag->partial_flag) { + param->key_ls->act_size += sizeof(struct nfp_fl_act_partial); + param->flag->partial_flag = true; + return; + } + + param->flag->partial_both_flag = true; } static void @@ -1691,10 +1751,12 @@ static nfp_flow_key_calculate_action_fn action_fns[] = { [RTE_FLOW_ACTION_TYPE_MARK] = nfp_flow_action_calculate_mark, [RTE_FLOW_ACTION_TYPE_RSS] = nfp_flow_action_calculate_stub, [RTE_FLOW_ACTION_TYPE_MODIFY_FIELD] = nfp_flow_action_calculate_modify, + [RTE_FLOW_ACTION_TYPE_QUEUE] = nfp_flow_action_calculate_queue, }; static int -nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], +nfp_flow_key_layers_calculate_actions(struct rte_eth_dev *dev, + const struct rte_flow_action actions[], struct nfp_fl_key_ls *key_ls) { struct nfp_action_flag flag = {}; @@ -1702,6 +1764,7 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], struct nfp_action_calculate_param param = { .key_ls = key_ls, .flag = &flag, + .dev = dev, }; for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) { @@ -1720,11 +1783,18 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], action_fns[action->type](¶m); } + if (param.flag->partial_both_flag && + key_ls->act_size != sizeof(struct nfp_fl_act_partial)) { + PMD_DRV_LOG(ERR, "Mark and Queue can not be offloaded with other actions"); + return -ENOTSUP; + } + return 0; } static int -nfp_flow_key_layers_calculate(const struct rte_flow_item items[], +nfp_flow_key_layers_calculate(struct rte_eth_dev *dev, + const struct rte_flow_item items[], const struct rte_flow_action actions[], struct nfp_fl_key_ls *key_ls) { @@ -1751,13 +1821,13 @@ nfp_flow_key_layers_calculate(const struct rte_flow_item items[], return ret; } - ret = nfp_flow_key_layers_check_actions(actions); + ret = nfp_flow_key_layers_check_actions(dev, actions); if (ret != 0) { PMD_DRV_LOG(ERR, "flow actions check failed"); return ret; } - ret = nfp_flow_key_layers_calculate_actions(actions, key_ls); + ret = nfp_flow_key_layers_calculate_actions(dev, actions, key_ls); if (ret != 0) { PMD_DRV_LOG(ERR, "flow actions check failed"); return ret; @@ -4073,7 +4143,7 @@ nfp_flow_action_mark(char *act_data, mark = action->conf; fl_mark = (struct nfp_fl_act_mark *)act_data; - fl_mark->head.jump_id = NFP_FL_ACTION_OPCODE_SET_MARK; + fl_mark->head.jump_id = NFP_FL_ACTION_OPCODE_SET_PARTIAL; fl_mark->head.len_lw = act_size >> NFP_FL_LW_SIZ; fl_mark->reserved = 0; fl_mark->mark = rte_cpu_to_be_32(mark->id); @@ -4501,11 +4571,70 @@ nfp_flow_action_compile_meter(struct nfp_action_compile_param *param) return 0; } +static void +nfp_flow_action_partial(const struct rte_flow_action *action, + char *act_data, + bool partial_flag) +{ + size_t act_size; + struct nfp_fl_act_partial *fl_partial; + const struct rte_flow_action_mark *mark; + const struct rte_flow_action_queue *queue; + + if (partial_flag) + fl_partial = (struct nfp_fl_act_partial *)act_data - 1; + else + fl_partial = (struct nfp_fl_act_partial *)act_data; + + if (action->type == RTE_FLOW_ACTION_TYPE_MARK) { + mark = action->conf; + fl_partial->mark = rte_cpu_to_be_32(mark->id); + fl_partial->flag = 0; + } else if (action->type == RTE_FLOW_ACTION_TYPE_QUEUE) { + queue = action->conf; + fl_partial->queue_id = rte_cpu_to_be_16(queue->index); + fl_partial->flag = 1; + } + + if (partial_flag) { + fl_partial->flag = 2; + return; + } + + act_size = sizeof(struct nfp_fl_act_partial); + fl_partial->head.jump_id = NFP_FL_ACTION_OPCODE_SET_PARTIAL; + fl_partial->head.len_lw = act_size >> NFP_FL_LW_SIZ; +} + static int nfp_flow_action_compile_mark(struct nfp_action_compile_param *param) { - nfp_flow_action_mark(param->position, param->action); - param->position += sizeof(struct nfp_fl_act_mark); + if (!nfp_flow_support_partial(param->repr)) { + nfp_flow_action_mark(param->position, param->action); + param->position += sizeof(struct nfp_fl_act_mark); + + return 0; + } + + nfp_flow_action_partial(param->action, param->position, param->flag->partial_flag); + + if (!param->flag->partial_flag) { + param->flag->partial_flag = true; + param->position += sizeof(struct nfp_fl_act_partial); + } + + return 0; +} + +static int +nfp_flow_action_compile_queue(struct nfp_action_compile_param *param) +{ + nfp_flow_action_partial(param->action, param->position, param->flag->partial_flag); + + if (!param->flag->partial_flag) { + param->flag->partial_flag = true; + param->position += sizeof(struct nfp_fl_act_partial); + } return 0; } @@ -4631,6 +4760,7 @@ static nfp_flow_action_compile_fn action_compile_fns[] = { [RTE_FLOW_ACTION_TYPE_MARK] = nfp_flow_action_compile_mark, [RTE_FLOW_ACTION_TYPE_RSS] = nfp_flow_action_compile_rss, [RTE_FLOW_ACTION_TYPE_MODIFY_FIELD] = nfp_flow_action_compile_modify, + [RTE_FLOW_ACTION_TYPE_QUEUE] = nfp_flow_action_compile_queue, }; static int @@ -4683,7 +4813,7 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor, } struct rte_flow * -nfp_flow_process(struct nfp_flower_representor *representor, +nfp_flow_process(struct rte_eth_dev *dev, const struct rte_flow_item items[], const struct rte_flow_action actions[], bool validate_flag, @@ -4702,13 +4832,16 @@ nfp_flow_process(struct nfp_flower_representor *representor, struct nfp_flow_priv *priv; struct nfp_fl_key_ls key_layer; struct nfp_fl_rule_metadata *nfp_flow_meta; + struct nfp_flower_representor *representor; - ret = nfp_flow_key_layers_calculate(items, actions, &key_layer); + ret = nfp_flow_key_layers_calculate(dev, items, actions, &key_layer); if (ret != 0) { PMD_DRV_LOG(ERR, "Key layers calculate failed."); return NULL; } + representor = dev->data->dev_private; + if (key_layer.port == (uint32_t)~0) key_layer.port = representor->port_id; @@ -4784,7 +4917,7 @@ nfp_flow_process(struct nfp_flower_representor *representor, } static struct rte_flow * -nfp_flow_setup(struct nfp_flower_representor *representor, +nfp_flow_setup(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], const struct rte_flow_action actions[], @@ -4813,10 +4946,10 @@ nfp_flow_setup(struct nfp_flower_representor *representor, cookie = rte_rand(); if (ct_item != NULL) - return nfp_ct_flow_setup(representor, items, actions, + return nfp_ct_flow_setup(dev, items, actions, ct_item, validate_flag, cookie); - return nfp_flow_process(representor, items, actions, validate_flag, cookie, true, false); + return nfp_flow_process(dev, items, actions, validate_flag, cookie, true, false); } int @@ -4864,7 +4997,7 @@ nfp_flow_validate(struct rte_eth_dev *dev, representor = dev->data->dev_private; - nfp_flow = nfp_flow_setup(representor, attr, items, actions, true); + nfp_flow = nfp_flow_setup(dev, attr, items, actions, true); if (nfp_flow == NULL) { return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -4900,7 +5033,7 @@ nfp_flow_create(struct rte_eth_dev *dev, app_fw_flower = representor->app_fw_flower; priv = app_fw_flower->flow_priv; - nfp_flow = nfp_flow_setup(representor, attr, items, actions, false); + nfp_flow = nfp_flow_setup(dev, attr, items, actions, false); if (nfp_flow == NULL) { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "This flow can not be offloaded."); diff --git a/drivers/net/nfp/flower/nfp_flower_flow.h b/drivers/net/nfp/flower/nfp_flower_flow.h index 5007438f67..f54ad6cf55 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.h +++ b/drivers/net/nfp/flower/nfp_flower_flow.h @@ -195,7 +195,7 @@ void nfp_flow_priv_uninit(struct nfp_pf_dev *pf_dev); int nfp_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops); bool nfp_flow_inner_item_get(const struct rte_flow_item items[], const struct rte_flow_item **inner_item); -struct rte_flow *nfp_flow_process(struct nfp_flower_representor *representor, +struct rte_flow *nfp_flow_process(struct rte_eth_dev *dev, const struct rte_flow_item items[], const struct rte_flow_action actions[], bool validate_flag, -- 2.39.1