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 574A9A0560; Tue, 18 Oct 2022 13:27:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15DDB41611; Tue, 18 Oct 2022 13:27:42 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2100.outbound.protection.outlook.com [40.107.236.100]) by mails.dpdk.org (Postfix) with ESMTP id AC40840E03 for ; Tue, 18 Oct 2022 13:27:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XDTJd3EoMINO6EDvcT3mibziNIMkD+Vum53tX/9zt9CWTSF82gM+cjR2U8ztkBe6SOaOpEoPoL/MCJJdXyTxzJBq/Ub0EPKRd9BaCmVGVlAXN/rB0Qsivp0TNat0xe/d6gTfdQwNeOkBj6ftHXJao5oDbX/lcwtqOYugAc3pbOPdWEq7aIcTQGmW0j/tjDakEk9gdzbi9A4LkyP7tpq9jwIVKXiDj1sv6/WrK6jvI27ayrXVyN27PmdIP5qv21jzUJ2ndlWkl7lo5aVYIdQzC3NHoQ0f0/hW9EeFMjdKBu9c4s8HDlzNWQ5DAcC2r3nltYwiaNHtNdFoXdrVb1oAow== 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=RZuv/6Z/Kdj9UCeqLm2zGm5JKDpZU1rL+8rKteg8cFQ=; b=BXj9VzdqCu+kCJzWjqNv6zdcbseU/Vak3TzamEMDp8QrBG1FSZGpsSvtM3rkEkS1eK1G2X3fdOzpGSERphp8M3wSjQLvShvtYkV5Q8n8hO62tPFfotuUUL3mpAdCWvb+Nzoc2ok8qQ4kUGE0UH22Mxg4J4adivmjZSiaYb8FDTCg5U2dGeXfJV8vi6ERwLw7UkxphcRVwuN7ZqzJ1itTwlCYJhI6J97k3m++7cv+6AszMTLFhdwTdBgNltEyogB1/q+NaXUNz9KA80XQLoX5/nF8U6Rz+Z92wKiMDlsWQykczGR1jnyNBt9jzmP/WEpIXkjPAfdvU5xSRrfNOP5vWw== 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=RZuv/6Z/Kdj9UCeqLm2zGm5JKDpZU1rL+8rKteg8cFQ=; b=dGKNLuFNqUFF7FPy8JZbLtR6mvPrBBCp8cJ6HwFo2HW9+ldAm/+0035i/DiPM56W3ChwYH1t43dzXKR52Nz1svj6v0nw5+TPc1qGT9IEUf8qNxj0FB4azfllNrzw9652ZM0e7GL79vffRugx4KVhWrF+VFtYcyDQrSY50Ipr/GI= 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 CO3PR13MB5686.namprd13.prod.outlook.com (2603:10b6:303:179::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16; Tue, 18 Oct 2022 11:27:38 +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; Tue, 18 Oct 2022 11:27:38 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v4 03/25] net/nfp: add the stats process logic in ctrl VNIC service Date: Tue, 18 Oct 2022 19:26:52 +0800 Message-Id: <1666092434-10357-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> References: <1666092434-10357-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR02CA0052.apcprd02.prod.outlook.com (2603:1096:4:54::16) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO3PR13MB5686:EE_ X-MS-Office365-Filtering-Correlation-Id: 34954507-63ba-42b2-94f0-08dab0fbc315 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xz4hlaisuk/6Ecm/UkDnj9CrskwCipT9sqee83JwtoLep7WlvJzcF+MlTe0NvjcD8qng2P65U0h+ZOtouKjQg8cFVV3Gya+9KL7MdVCwJhfjMsZ9Djhy5hW7txBrAbd5pE8suLqp/NeV1txT+gqxrKKGrYsF9eeTcXaf2J3dXkLKMFMBN/1XFaQolWwywWiCbX0I9bA7a95kpPvEC8SlTO83DOnLu8rbPTyooyeSrZP6LS5q9xT44iIh4pjzJIkm/06M+0grslhvgcBb9oHFMT8a/lVdBqnWzTLzoPOF7w2Yh/jvHAhGWHmaD2sldk/uEQLcPRAbVTjIOts60QAiUbCt3P7drvdV+ONqxXkTlEcwgz9Ar/u44f+V/d82UhZHKO2Pn/+DNVuk55JCdAO1qF22fMYoUj5ibAcrO3IYw204jE8jja8aVQ3kp9lLtJ06ceKuF2Ek8Fq72ch5pVvnD6fsFSieySlYhiuqSxOp5plvwu/xvgnh5RTOdK1XAf+hdOBzm6kNpGo3vHoHw92F52qxR+yS74KhVHv6OFGzXGHCS6bxwWSrFyys49cZXOOWFADAt62a3fwHBFMIs6GwzEwT0we1vQznlEzTy/ldGLXzErHpvXuv/yHm1PxTDneHBXfjShrsKehy79w3zfTP8eL5J8w2UemLdFsgmHqMQBM1HJQd/mvxi3y1MWzYqIRLMaRD/M9bFH3F4dFrZoUXfLv6g+BbXtss82sc5VNJrp1sBduOzZV75nEdYargT1um8QWB4pv7qQN+VGE4+6PxtbdsxWSVR0vKxrIGv3Mgmn5SHkS6vf/2CN/WamrvXvA2 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)(346002)(366004)(39840400004)(396003)(136003)(376002)(451199015)(38350700002)(38100700002)(2906002)(66574015)(41300700001)(316002)(66946007)(66556008)(66476007)(83380400001)(4326008)(8676002)(6916009)(86362001)(44832011)(2616005)(8936002)(186003)(36756003)(5660300002)(6506007)(107886003)(6666004)(66899015)(6486002)(478600001)(26005)(6512007)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VWJiOEJud3hHaGlDY1F2alJqMmhyOU9jQVNlWlVoM0xjZTJrOTVQd2dwNzNK?= =?utf-8?B?K090cTBDVzhjaDZRWmVsNzhMQ3MyM29NUnFQV01wbzZqRHlPMk5VWlgxMjFJ?= =?utf-8?B?cDNaTzZrZEpmcHBuY2xjZVlIbVNuSlJIalhNRXYzTFNXMkVnMkpQcVh5NFVJ?= =?utf-8?B?SlV6QVc1K2NKbkZuMGhEUGNSNzdYVjFIUFVGaEhQK2dUMmtaQ0dMcjUzN2Iz?= =?utf-8?B?SW1EaDc1W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XK0E4RnQwUnhpR1FEa254T2l6THVTbXpM?= =?utf-8?B?S0hVQUZabm1lcGxiTHNvTEZPYmxZUDRUWExCWENlYytWbU5yVExMa1dVdGxK?= =?utf-8?B?WUkrNUIvSlFpSzk0bW5hNEJIeW95ZDA3WFl6bXR0OGNpM2t4TlVLQkM1SDZ2?= =?utf-8?B?N3c9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34954507-63ba-42b2-94f0-08dab0fbc315 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 11:27:38.3847 (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: njvTqrXuYiGrrQBlY0Jab5j0byQt8qCvF/pMsCdQJCpiQ02+a/GjhKBCXp5SGiV0skU0iJ6oaMephQotvg4BD88oqa0ZWYIkiD+g9h966Ds= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5686 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_cmsg.h | 25 +++++++++++ drivers/net/nfp/flower/nfp_flower_ctrl.c | 73 ++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 4 deletions(-) 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); } } } -- 1.8.3.1