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 D6859A0544; Mon, 10 Oct 2022 08:09:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CFF3441141; Mon, 10 Oct 2022 08:09:24 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2095.outbound.protection.outlook.com [40.107.96.95]) by mails.dpdk.org (Postfix) with ESMTP id 46FED40E50 for ; Mon, 10 Oct 2022 08:09:23 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dYxsJA9jTKUg90Zxv43ZP5VbiOkjYEhERenI/Q2Y4IuO7RhsCQ8updsopA//zy3keM33r0PycLOpsx2oxtUyFfMGjjMrAeAMiEWHYkw39iFwcIyF76/ULAl3DNCWCriCk2zHd+cTEJvgcfsphhCtHC2k2AR88covMLiuXW7Zq+BUDGDWNgp3bxzjZN8gd2ggShsSSqOylg+iTdOw3TAmKwtVaW/LSh6OQJXyct429GHFWc5cpohkyw5QOEOXYHPCYAe1B9ChXLM2rDeBdP/WuiHgO5tNHYNrujkb53MNVC+NPjBIVwtV4OXXclOCfwlxz99BzZO2jU+EetqZbjtybA== 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=3o0nJvqiKXah5AQmS+ARFr3R1UJlNOp53PMEGKH5WYE=; b=VmgdS2xTlIt77RynaPVMkG/F2t+OYZ6R2mtay+GYkkozsvfSgUIP2FhIVZTFR6Z7/06LuyTcIiNuk1jfiAXzmbcv1gk0DbP7/6jFgHjHzjMis2CpGEx+vVU2jWzgT9+RblgS5mLYjKbvluF2K50N3UVX9/w71YsvBRXZLruXYCwKY+ncuZ6VjuQpLRd53HVhs2klmi8spWoY1okyWezPhhpdJaZQZnrsaYJctFpBcMi+IZCCu0AiSBUW3hBznwTNXbb0uuTgaOSfCGirf2i4bOe5TQhvpzp9pP62/d2raDfbkqB05TqVGdIRs4F7OiZvqV1rqDAu0z/ww0noxhp3cw== 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=3o0nJvqiKXah5AQmS+ARFr3R1UJlNOp53PMEGKH5WYE=; b=Hy5sL7otgCwtDjehQ2tn05O/0/m7VZujcazbgigEbw+qtPLamhGMLB4mCPyOw1tqOQJ/T+SrX+NlPqXcDqVdHp2kl9j3UeKvkxE3/7Ivx1V6azAV3MtqCTLJCzhheBXwLJV5IbMynh8rUCNdG1G1QuisB/WhVkRc40iGA9HLQqA= 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 SN4PR13MB5296.namprd13.prod.outlook.com (2603:10b6:806:207::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.14; Mon, 10 Oct 2022 06:09:21 +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; Mon, 10 Oct 2022 06:09:21 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 01/24] net/nfp: add the stats process logic in ctrl VNIC service Date: Mon, 10 Oct 2022 14:08:39 +0800 Message-Id: <1665382142-21684-2-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1665382142-21684-1-git-send-email-chaoyong.he@corigine.com> References: <1665382142-21684-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0051.apcprd01.prod.exchangelabs.com (2603:1096:4:193::6) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SN4PR13MB5296:EE_ X-MS-Office365-Filtering-Correlation-Id: f024948d-d291-48cb-b418-08daaa85f928 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NcPzSx4lnf+hVU4AnDV5sxlgF1yBAR9wG6o1sq9sd1dbeu00NHtQetZkBNuydVnfzaAklytsW6HcbXtij8NBGurfrwaoOArrKul22M6PmmZ+uaCpX1xD35qvNHlHgXkTax+YIIG1oeqjiLwWvcbnP4kaS1TtQ+eBaNCHNryTEfVol35GptA+BrfuSacCHAJf/Dkb8mTuD3RDG8/m4fM2DjnRqFYLZ0ElO+uLsABtbPtalWPpsEYwz7I8Z6vb2PC7ncegGjn15/0c1L922H5jHSFti5fpmB7ILOS45xi0SP2dvFuM8BXeXdGXrlR7MnOr4a1p6lvVKvpPxwZPFlol9oNDLqNiLdpZCdPXq9tOvVvWEfKk3MnyyGrU3P4advRefMfnJWvrw1AFmcB+tOM9tDbgLTMEeW88H+L3XVGjkE4/O6A2laNhu8zY2Ha/mlSOYTfotZDFy9wcbeDPIKl5hwR3CFsJJRy+pvd0VsgRUhYPM7cw1pjnHi9aNMcLM3R2sPk7xzV7H+XwzXFR4wSI/1vRetPB4FGmoEmsTZgQptZgxLbeD3XKdspk8MnXX5nfqLRRAvsaPUCSMC4FAmrW8A+cxjuq5559XB6VyOMkcfukZhb8uARLp4XY/JTYfG5F6z73sDn/S8RQuymdE1Tm2NOXfeH/WJ+rDdy4zgjJkTz5MuxcMUlUHRfuI7GVMLAF47wUrgl50c8560W2SrkP2/MTp8NfXlb5NkOXGeg2hTdG+3QdF/q+2OkwJR3OV3IDauaY+ETPlkIml26vo0ze0tK0pJ1leBTPqYW2sg3pAPjDkhgWKQrqOldmHllR37ji 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)(366004)(396003)(346002)(376002)(136003)(39830400003)(451199015)(6916009)(66899015)(316002)(2906002)(186003)(6486002)(2616005)(66476007)(6666004)(107886003)(66556008)(41300700001)(66946007)(83380400001)(8936002)(8676002)(4326008)(5660300002)(66574015)(44832011)(26005)(6506007)(6512007)(52116002)(86362001)(478600001)(36756003)(38350700002)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aXpocjhCTDhNYzZaYmNmTStlWlJiMXNUVXZRbXp1bFZYOWFUSGw0T0tJOHZl?= =?utf-8?B?ZzFxVVJUR2FNaUVVOGhrYlZSc0I5cDNLbFowNGhLNGZZcmJPQnBHbHJRbG1C?= =?utf-8?B?R0d0c2N3T2VXTVo0cU4zSENQTTA3SUYvOENsYnRmRkNKUGJLeGNHK0xOejJo?= =?utf-8?B?dWhRSU9iVzhtTnh1dCtaeDQ0VDBoNTNXYms2Wm1qZkZsUUFRQWFxakw3YnVJ?= =?utf-8?B?N0hOUy9SWXZWR2duaDdlUXlydVcxR2FocVZzM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ybUVvYnd3eUYzb3pIQ2FEcEFpS1l1YjFWZVZmcm43TG96NW4wR1BYUjVF?= =?utf-8?B?c1MyTTlHSm5EMGZnSWVOdENWaW5Xd2dsVktIV0ZEMmFMMWJPUkJOSDZNSUho?= =?utf-8?B?OFE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f024948d-d291-48cb-b418-08daaa85f928 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2022 06:09:21.6881 (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: 7zX+QjybwJcMtZ8GuSaO3Es2k1Jd2XChTSixJb/LFokX9etidiqtu1Ahic9u78nqW/XGvliew2O09mowPhzZSkIBFqE+z94yyH09VZvtxYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR13MB5296 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 stats process logic in the ctrl VNIC service. The flower firmware pass the flow stats to nfp driver through control message, we store them in the flow_priv structure. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.h | 2 + drivers/net/nfp/flower/nfp_flower_cmsg.h | 25 +++++++++++ drivers/net/nfp/flower/nfp_flower_ctrl.c | 73 ++++++++++++++++++++++++++++++-- drivers/net/nfp/nfp_flow.h | 20 +++++++++ 4 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 drivers/net/nfp/nfp_flow.h diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index 48f597a..b90391c 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -51,6 +51,8 @@ struct nfp_app_fw_flower { /* PF representor */ struct nfp_flower_representor *pf_repr; + + struct nfp_flow_priv *flow_priv; }; int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev); diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 0bf8fc8..5c28363 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -129,6 +129,31 @@ struct nfp_flower_cmsg_port_mod { rte_be16_t mtu; }; +/* + * NFP_FLOWER_CMSG_TYPE_FLOW_STATS + * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * -----\ 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 + * Word +---------------+-----------------------------------------------+ + * 0 | Reserved | Host Context | + * +---------------+-----------------------------------------------+ + * 1 | Packet Count | + * +---------------------------------------------------------------+ + * 2 | Byte Count | + * +---------------------------------------------------------------+ + * 2 | Byte Count | + * +---------------------------------------------------------------+ + * 3 | Host Cookie | + * +---------------------------------------------------------------+ + * 4 | Host Cookie | + * +---------------------------------------------------------------+ + */ +struct nfp_flower_stats_frame { + rte_be32_t stats_con_id; + rte_be32_t pkt_count; + rte_be64_t byte_count; + rte_be64_t stats_cookie; +}; + enum nfp_flower_cmsg_port_type { NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC, NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT, diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index df908ef..bb9efe1 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -10,8 +10,10 @@ #include "../nfp_logs.h" #include "../nfp_ctrl.h" #include "../nfp_rxtx.h" +#include "nfp_flow.h" #include "nfp_flower.h" #include "nfp_flower_ctrl.h" +#include "nfp_flower_cmsg.h" #define MAX_PKT_BURST 32 @@ -222,10 +224,74 @@ return cnt; } +static void +nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv, + struct rte_mbuf *mbuf) +{ + char *msg; + uint16_t i; + uint16_t count; + uint16_t msg_len; + uint32_t ctx_id; + struct nfp_flower_stats_frame *stats; + + msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN; + msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN; + count = msg_len / sizeof(struct nfp_flower_stats_frame); + + rte_spinlock_lock(&flow_priv->stats_lock); + for (i = 0; i < count; i++) { + stats = (struct nfp_flower_stats_frame *)msg + i; + ctx_id = rte_be_to_cpu_32(stats->stats_con_id); + flow_priv->stats[ctx_id].pkts += rte_be_to_cpu_32(stats->pkt_count); + flow_priv->stats[ctx_id].bytes += rte_be_to_cpu_64(stats->byte_count); + } + rte_spinlock_unlock(&flow_priv->stats_lock); +} + +static void +nfp_flower_cmsg_rx(struct nfp_flow_priv *flow_priv, + struct rte_mbuf **pkts_burst, + uint16_t count) +{ + uint16_t i; + char *meta; + uint32_t meta_type; + uint32_t meta_info; + struct nfp_flower_cmsg_hdr *cmsg_hdr; + + for (i = 0; i < count; i++) { + meta = rte_pktmbuf_mtod(pkts_burst[i], char *); + + /* Free the unsupported ctrl packet */ + meta_type = rte_be_to_cpu_32(*(uint32_t *)(meta - 8)); + meta_info = rte_be_to_cpu_32(*(uint32_t *)(meta - 4)); + if (meta_type != NFP_NET_META_PORTID || + meta_info != NFP_META_PORT_ID_CTRL) { + PMD_DRV_LOG(ERR, "Incorrect metadata for ctrl packet!"); + rte_pktmbuf_free(pkts_burst[i]); + continue; + } + + cmsg_hdr = (struct nfp_flower_cmsg_hdr *)meta; + if (unlikely(cmsg_hdr->version != NFP_FLOWER_CMSG_VER1)) { + PMD_DRV_LOG(ERR, "Incorrect repr control version!"); + rte_pktmbuf_free(pkts_burst[i]); + continue; + } + + if (cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_FLOW_STATS) { + /* We need to deal with stats updates from HW asap */ + nfp_flower_cmsg_rx_stats(flow_priv, pkts_burst[i]); + } + + rte_pktmbuf_free(pkts_burst[i]); + } +} + void nfp_flower_ctrl_vnic_poll(struct nfp_app_fw_flower *app_fw_flower) { - uint16_t i; uint16_t count; struct nfp_net_rxq *rxq; struct nfp_net_hw *ctrl_hw; @@ -242,9 +308,8 @@ count = nfp_flower_ctrl_vnic_recv(rxq, pkts_burst, MAX_PKT_BURST); if (count != 0) { app_fw_flower->ctrl_vnic_rx_count += count; - /* Process cmsgs here, only free for now */ - for (i = 0; i < count; i++) - rte_pktmbuf_free(pkts_burst[i]); + /* Process cmsgs here */ + nfp_flower_cmsg_rx(app_fw_flower->flow_priv, pkts_burst, count); } } } diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h new file mode 100644 index 0000000..971ba69 --- /dev/null +++ b/drivers/net/nfp/nfp_flow.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Corigine, Inc. + * All rights reserved. + */ + +#ifndef _NFP_FLOW_H_ +#define _NFP_FLOW_H_ + +struct nfp_fl_stats { + uint64_t pkts; + uint64_t bytes; +}; + +struct nfp_flow_priv { + /* flow stats */ + struct nfp_fl_stats *stats; /**< Store stats of flow. */ + rte_spinlock_t stats_lock; /** < Lock the update of 'stats' field. */ +}; + +#endif /* _NFP_FLOW_H_ */ -- 1.8.3.1