From patchwork Tue Sep 26 02:49:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaoyong He X-Patchwork-Id: 131901 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 148DF4263C; Tue, 26 Sep 2023 04:50:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 723D0402D1; Tue, 26 Sep 2023 04:50:36 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2099.outbound.protection.outlook.com [40.107.243.99]) by mails.dpdk.org (Postfix) with ESMTP id 64C90402B7 for ; Tue, 26 Sep 2023 04:50:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emyDFjpofHTT37eYul4HfMipmVPD8YNuLXZMzbInEJBAf2sdxSj9U4GGNWLSdabF4doIRPaDtSLnDMvwtUiwRGGuCPbKaM++2w3Yt50a5fly5cWklSgxM589xZaFgAAbpj02zGsvWOJYpjMU/sGSYJ3LVbTw1ubYulIh36zgZ1FgqmUM3OcwBrINY5V6RAKYT3nLYKW2R1S2T/Yql9rLm+mhUIDe5R4UcgqDZ+OIJJ2dDleeqE9B2hdlwkL6aXXyZWGAutU/vAkvUCWxEbC4GPb6frqQOjQKX/kswlBoScvz9G341VS3aqDn+FBkeEg9wDaCfjP1/SkQQXjeK14CLA== 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=tbZkNvIPVm/dq+cfppB3sOgfIfONfcQ4BD5wQ6tamYQ=; b=eR4nKWgScMmASopJQIbGPzVO/oMxCK9sDeZxELD72zKV4QxBEhmZrCXmwreafa0jExqqmjuL/OhyHG1pXniQkTYMiVCNrmcsgvHLSooF+O/z/mjqGrnZy+W5NgqEtUVhfYHLEhtcMAQKzFZcQQX/yhDsKUfxlMKnOJ8/uuKy6FqBh5Fms+Vhobg/OtKeE4jpsJflPlN1apLhEZcjHuUJQtTPOwmn391dboACeZJ+MrAILaAxa79ZlaXIGVivfLctF/gYswguxwL/KpsXtCQQD5MTqWR+1TNsAnGmKRrqP2Aa9KCJSLBVOaIZ463wtEG26nNwi970RIk2Oxq1pQHfyg== 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=tbZkNvIPVm/dq+cfppB3sOgfIfONfcQ4BD5wQ6tamYQ=; b=u0XI4MCEckcAclb6u/eUO4e6k1w9O5h1n9WYJhb3CN+kHLH5hvxBAtahqIG+nRI5501afSwwtx5g/cGacbB49M9jv5/0HnRZFg+PlfdFty8adczgWItz/AfcRGCc6WLfvB9wsNgZHS+/yWx3KXsUN+7OPbNE0G89DTxTXYcfuRc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB5568.namprd13.prod.outlook.com (2603:10b6:510:12b::16) by SA3PR13MB6516.namprd13.prod.outlook.com (2603:10b6:806:39c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Tue, 26 Sep 2023 02:50:32 +0000 Received: from PH0PR13MB5568.namprd13.prod.outlook.com ([fe80::b070:92e1:931e:fee7]) by PH0PR13MB5568.namprd13.prod.outlook.com ([fe80::b070:92e1:931e:fee7%4]) with mapi id 15.20.6792.026; Tue, 26 Sep 2023 02:50:32 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Shihong Wang , Chang Miao , Chaoyong He Subject: [PATCH v2 02/10] net/nfp: add TLVs capability parsing Date: Tue, 26 Sep 2023 10:49:51 +0800 Message-Id: <20230926024959.207098-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230926024959.207098-1-chaoyong.he@corigine.com> References: <20230925060644.1458598-1-chaoyong.he@corigine.com> <20230926024959.207098-1-chaoyong.he@corigine.com> X-ClientProxiedBy: BYAPR05CA0020.namprd05.prod.outlook.com (2603:10b6:a03:c0::33) To PH0PR13MB5568.namprd13.prod.outlook.com (2603:10b6:510:12b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB5568:EE_|SA3PR13MB6516:EE_ X-MS-Office365-Filtering-Correlation-Id: 55f72134-b74e-42ec-6d85-08dbbe3b59d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i0ledwS+QneEr+CyfQyj867gBepYs9FlL+2wlWW9QeZETmisZuCi1NCm6nZ7FF8FZ138EgiglNZL+wHoWhMpqcKFfmUJfoWBdjW0HGzzFEhHFDC8TkU8kKBGLZFEq+nV9hq+Hga+Vcfc51BjSs2uQZ41t9UV5tq8w9H2nszkodT6GxDOaWAcVDWtL4KhnSUgyuuPSlAG8YXwESUsT3SrRWOTIQwXPImLD5EjfXNySAR9uInGfbBn+D7NVZbsqfDxIRwLO7B/OB54dlEUItI545XkmYZgr49x673i9rtr9fToDykHWDVuSFRp3Fa1M80G/VuDyuF+SFczgBqGJG02N35Yjj4wK6pFC5tjlOcnfRmO0N9OnsN2gY7DFMoJexTT6Rj0lEfXWgBzGoz5kM/oQQqMeg71vWwX0RuhrdMvWTw7iWt6Xg/9f1ZKuI646NEZJbwvv0XwFZADfRS/UkI7ImUPw3j5A5M3yvESoHFUP0Ds5aMQ5/fRO1Qjvwx8J3qhbAXOr9G+A0sFAJfZfQ6Y1k2U51t4HeC7OdIs5kumwgbH3fyhYRLN3zL1tdLmCqoDnUgykNOr642bKHLG0uPKbmkUZcApchfhXeLzYdtNvLyQxKcoQgXPNizTRf3O3jj1XhAhdw7PRRyUISEjeDr1OlaGbKYIffXacRrFZjBppgs= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB5568.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39830400003)(136003)(366004)(346002)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(4326008)(83380400001)(2616005)(6486002)(6506007)(52116002)(478600001)(6666004)(86362001)(36756003)(38100700002)(1076003)(30864003)(26005)(66476007)(8936002)(66556008)(6916009)(6512007)(2906002)(38350700002)(66946007)(41300700001)(107886003)(316002)(44832011)(8676002)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7pWwyojetFfYjtVYYSRhWYPNNY6V04e3DswpYNBXhv6KfmQzIC9U4JUGrLD6kFZZ7xexUaGdghDfmkv1nNG19Uhe9m+cVpOOomtrNU9ww8U1ouzbBH/swg+1F3xTQupuaNFlAlcczl07tgyU5FVU/JSAh9r4AWd1meCIvlQTKUfZEpqMMDyVJnMLvlm9EknIW5D7aZWhQSe9diXMycK5B+uzVPCUsBiWAptSadv3u2AZ8TW2htgpWHgjvFoNafgJIwiyeZHD8rxMO3u97uYQHepgXYf+xHEb6TNPq9lC4gl1KP9kBqyJ/kbSpREGH+rmPD3O1dfZcuXcMRUa0EDXP3w0aRlKy3rfT6UsK+Jl22Ig6iloQq6XcDnDH5SptZ8KBLAPs5D9SqD01yBy+4VOD2n691j2koCjjDCkppgEzfEIOzO/WUx5sCmtBAdrvwwD/OkaezybihZBZyvQcAsatozhRhkoMq7G+QX1hR+FafpORavZ5ie8y7rYriT/7h0FrjUGtvAosI36IqT4qOHFkG/aNDTSErqUfSufqEXKBWQynsHuvFz+DsvKQ7HyQdC/6b+NvYN/kW/XVKOhYYRVXjzyHiMKhJTyI/fbqnzTspyiNwcO4ReqRxykd0PHZ0o+NE85mDmR6aoFh7wxJZwti6JapamZJ2OWtpMrS2O1uUfbaarhnrGve9cSqR/sbpZseASGlfgWHsi6jS3+i5Wc6k3kQnREvnnmot+ydmn6PCKYx+c4xnQ8xs9PbnRfEM2YpsoBhsRFd58JNL1/6b+xGNwszUwOquxhxLM7DihzCmG9EpNqyBopVQMXybzhSKWf2rL0xCl+qFjCr7bFgR9zQPTzc4KOrYxrqtymKVYw9CIJz5mdif43MGD7WVtHcqzUHYoIP26kKv8HaX0TeXe1p1a6vUwqQioLt/Me+Kdpe+GzzvvBZaF9Ac/HANHdWoA5gDZrfYfsBiBUwxcSgw2IJFmCr5zcpN2Ontp5LR7dc1LDcFTrMX7/1gF5TQcDQT/m4Op/zH7E9cSmhjkzaXdvJfVJl6KgNpttgT5YNm+nsNsKo0tVCrieByvEPC0H6LjHOtU6XOY55t3DsfUTDpf47atlXbhxsN33GPt76FfScz08EJ2hgNeUNpkPhiLMTwA7RtJJMkojUVFytC56dH8lPY7A18iiI4qoLDqKVjURf+8PvqlJyiDpk9XDT5RzF5t5BcD0+VX6k8zUfa0Sa8Q6sKRE9vggZys/X22QgYK4WA/frQJ1X2kuhtluzbf9lTYG/BZCzW9PaRid2SB6NIKhx++2GHToNotxhjQpxHYIGbfoj1m447aW5aMkksilo/E65a3L6CRUvWoMjSa9EgMGRiCI2MS8i+3Ohd/9GaOQcf3EH5m79Aa7y94n5HVBLQmUCg3qE/SD2gjBwbGNMTrxzDroH1e5jP4MUzPOtFgrPENWqCUsnGKFEdMXGL/7KF9imZ5uC79dhTRurEpQ0l6dXFqC9TY4E/A3SH4LZpAHmH+Plx3jXoLx/PdIf81xWAyTXj3Vf5Lh+3IoKfN7u/jqIeOQskuuISgtGc/DCu2AW9yi0v8eTxGsrEziucOi5mmVHlZfV1eitfsCNsa9vTquNA== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55f72134-b74e-42ec-6d85-08dbbe3b59d1 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB5568.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2023 02:50:32.5611 (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: 9m5qPJX/DitPrqlupp4bHVeOk7eMZHtoyZfi6dkqmEalwaXKPwchD7FnhI+qyz/8ynybh0UvLEt+TtktR0QiwCX/+THnpHfYj6Gq9Y0GfN4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR13MB6516 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: Shihong Wang Add TLV capabilities to the BAR, TLVs is fit for expressing capabilities of applications running on programmable hardware. Declares a TLV capability start at offset 0x58, up to 0x0d90. The used space can be wrapped with RESERVED. Signed-off-by: Shihong Wang Signed-off-by: Chang Miao Reviewed-by: Chaoyong He --- drivers/net/nfp/meson.build | 1 + drivers/net/nfp/nfp_common.h | 13 +++ drivers/net/nfp/nfp_ctrl.c | 153 +++++++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_ctrl.h | 121 +++++++++++++++++++++++++++ drivers/net/nfp/nfp_ethdev.c | 6 ++ 5 files changed, 294 insertions(+) create mode 100644 drivers/net/nfp/nfp_ctrl.c diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index d422269c4b..e78bcb8b75 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -27,6 +27,7 @@ sources = files( 'nfpcore/nfp_target.c', 'nfpcore/nfp6000_pcie.c', 'nfp_common.c', + 'nfp_ctrl.c', 'nfp_rxtx.c', 'nfp_cpp_bridge.c', 'nfp_ethdev_vf.c', diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index b0372c3dc6..4a19c18466 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -64,6 +64,17 @@ enum nfp_net_meta_format { NFP_NET_METAFORMAT_CHAINED, }; +/* Parsed control BAR TLV capabilities */ +struct nfp_net_tlv_caps { + uint32_t me_freq_mhz; /**< ME clock_freq (MHz) */ + uint32_t mbox_off; /**< VNIC mailbox area offset */ + uint32_t mbox_len; /**< VNIC mailbox area length */ + uint32_t repr_cap; /**< Capabilities for representors */ + uint32_t mbox_cmsg_types; /**< Cmsgs which can be passed through the mailbox */ + uint32_t vnic_stats_off; /**< Offset of vNIC stats area */ + uint32_t vnic_stats_cnt; /**< Number of vNIC stats */ +}; + struct nfp_pf_dev { /* Backpointer to associated pci device */ struct rte_pci_device *pci_dev; @@ -163,6 +174,8 @@ struct nfp_net_hw { uint8_t idx; /* Internal port number as seen from NFP */ uint8_t nfp_idx; + + struct nfp_net_tlv_caps tlv_caps; }; struct nfp_net_adapter { diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_ctrl.c new file mode 100644 index 0000000000..c61d3fd158 --- /dev/null +++ b/drivers/net/nfp/nfp_ctrl.c @@ -0,0 +1,153 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2023 Corigine Systems, Inc. + * All rights reserved. + */ + +#include "nfp_ctrl.h" + +#include + +#include "nfpcore/nfp_platform.h" + +#include "nfp_common.h" +#include "nfp_logs.h" + +/* Mailbox Me clock freq */ +#define NFP_NET_CFG_MBOX_FREQ_MHZ 1200 + +static void +nfp_net_tlv_caps_reset(struct nfp_net_tlv_caps *caps) +{ + memset(caps, 0, sizeof(*caps)); + caps->me_freq_mhz = NFP_NET_CFG_MBOX_FREQ_MHZ; + caps->mbox_off = NFP_NET_CFG_MBOX_BASE; + caps->mbox_len = NFP_NET_CFG_MBOX_VAL_MAX_SZ; +} + +int +nfp_net_tlv_caps_parse(struct rte_eth_dev *dev) +{ + uint32_t hdr; + uint8_t *end; + uint8_t *data; + uint32_t length; + uint32_t offset; + uint32_t tlv_type; + uint32_t tlv_offset; + struct nfp_net_hw *hw; + struct nfp_net_tlv_caps *caps; + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + caps = &hw->tlv_caps; + nfp_net_tlv_caps_reset(caps); + + data = hw->ctrl_bar + NFP_NET_CFG_TLV_BASE; + end = hw->ctrl_bar + NFP_NET_CFG_BAR_SZ; + + hdr = rte_read32(data); + if (hdr == 0) { + PMD_DRV_LOG(INFO, "TLV is empty!"); + return 0; + } + + for (; ; data += length) { + offset = data - hw->ctrl_bar; + + if (data + NFP_NET_CFG_TLV_VALUE > end) { + PMD_DRV_LOG(ERR, "Reached end of BAR without END TLV"); + return -EINVAL; + } + + hdr = rte_read32(data); + + length = FIELD_GET(NFP_NET_CFG_TLV_HEADER_LENGTH, hdr); + if ((length & (NFP_NET_CFG_TLV_LENGTH_INC - 1)) != 0) { + PMD_DRV_LOG(ERR, "TLV size not multiple of 4B len: %u", length); + return -EINVAL; + } + + /* Advance past the header */ + data += NFP_NET_CFG_TLV_VALUE; + if (data + length > end) { + PMD_DRV_LOG(ERR, "Oversized TLV offset: %u len: %u", + offset, length); + return -EINVAL; + } + + tlv_type = FIELD_GET(NFP_NET_CFG_TLV_HEADER_TYPE, hdr); + + switch (tlv_type) { + case NFP_NET_CFG_TLV_TYPE_UNKNOWN: + PMD_DRV_LOG(ERR, "Unknown TLV at offset: %u", offset); + return -EINVAL; + case NFP_NET_CFG_TLV_TYPE_RESERVED: + break; + case NFP_NET_CFG_TLV_TYPE_END: + if (length == 0) + return 0; + + PMD_DRV_LOG(ERR, "END TLV should be empty, has len: %u", length); + return -EINVAL; + case NFP_NET_CFG_TLV_TYPE_ME_FREQ: + if (length != NFP_NET_CFG_TLV_LENGTH_INC) { + PMD_DRV_LOG(ERR, "ME FREQ TLV should be 4B, is %u", length); + return -EINVAL; + } + + caps->me_freq_mhz = rte_read32(data); + break; + case NFP_NET_CFG_TLV_TYPE_MBOX: + caps->mbox_len = length; + + if (length != 0) + caps->mbox_off = data - hw->ctrl_bar; + else + caps->mbox_off = 0; + break; + case NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL0: + /* FALLTHROUGH */ + case NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL1: + PMD_DRV_LOG(ERR, "Experimental TLV type: %u offset: %u len: %u", + tlv_type, offset, length); + /* Skip, not process */ + break; + case NFP_NET_CFG_TLV_TYPE_REPR_CAP: + if (length == 0) { + PMD_DRV_LOG(ERR, "REPR CAP TLV with length 0"); + return -EINVAL; + } + + caps->repr_cap = rte_read32(data); + break; + case NFP_NET_CFG_TLV_TYPE_MBOX_CMSG_TYPES: + if (length != 0) + caps->mbox_cmsg_types = rte_read32(data); + break; + case NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS: + break; + case NFP_NET_CFG_TLV_TYPE_VNIC_STATS: + tlv_offset = data - hw->ctrl_bar; + if ((tlv_offset & (NFP_NET_CFG_TLV_STATS_OFFSET - 1)) != 0) { + PMD_DRV_LOG(ERR, "VNIC STATS TLV misaligned, ignoring offset: %u len: %u", + offset, length); + break; + } + + caps->vnic_stats_off = tlv_offset; + caps->vnic_stats_cnt = length / 10; + break; + case NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS_RX_SCAN: + break; + default: + if (FIELD_GET(NFP_NET_CFG_TLV_HEADER_REQUIRED, hdr) == 0) + break; + + PMD_DRV_LOG(ERR, "Unknown TLV type: %u offset: %u len: %u", + tlv_type, offset, length); + return -EINVAL; + } + } + + PMD_DRV_LOG(ERR, "Reached end of BAR without END TLV"); + return -EINVAL; +} diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h index 53727992a9..80a4196bea 100644 --- a/drivers/net/nfp/nfp_ctrl.h +++ b/drivers/net/nfp/nfp_ctrl.h @@ -8,6 +8,8 @@ #include +#include + /* * Configuration BAR size. * @@ -207,6 +209,9 @@ struct nfp_net_fw_ver { #define NFP_NET_CFG_RX_OFFSET 0x0050 #define NFP_NET_CFG_RX_OFFSET_DYNAMIC 0 /* Prepend mode */ +/* Start anchor of the TLV area */ +#define NFP_NET_CFG_TLV_BASE 0x0058 + /** * Reuse spare address to contain the offset from the start of * the host buffer where the first byte of the received frame @@ -434,6 +439,122 @@ struct nfp_net_fw_ver { #define NFP_PF_CSR_SLICE_SIZE (32 * 1024) +/* + * General use mailbox area (0x1800 - 0x19ff) + * 4B used for update command and 4B return code followed by + * a max of 504B of variable length value. + */ +#define NFP_NET_CFG_MBOX_BASE 0x1800 +#define NFP_NET_CFG_MBOX_VAL 0x1808 +#define NFP_NET_CFG_MBOX_VAL_MAX_SZ 0x1F8 + +/* + * TLV capabilities + * @NFP_NET_CFG_TLV_TYPE: Offset of type within the TLV + * @NFP_NET_CFG_TLV_TYPE_REQUIRED: Driver must be able to parse the TLV + * @NFP_NET_CFG_TLV_LENGTH: Offset of length within the TLV + * @NFP_NET_CFG_TLV_LENGTH_INC: TLV length increments + * @NFP_NET_CFG_TLV_VALUE: Offset of value with the TLV + * @NFP_NET_CFG_TLV_STATS_OFFSET: Length of TLV stats offset + * + * List of simple TLV structures, first one starts at @NFP_NET_CFG_TLV_BASE. + * Last structure must be of type @NFP_NET_CFG_TLV_TYPE_END. Presence of TLVs + * is indicated by @NFP_NET_CFG_TLV_BASE being non-zero. TLV structures may + * fill the entire remainder of the BAR or be shorter. FW must make sure TLVs + * don't conflict with other features which allocate space beyond + * @NFP_NET_CFG_TLV_BASE. @NFP_NET_CFG_TLV_TYPE_RESERVED should be used to wrap + * space used by such features. + * + * Note that the 4 byte TLV header is not counted in %NFP_NET_CFG_TLV_LENGTH. + */ +#define NFP_NET_CFG_TLV_TYPE 0x00 +#define NFP_NET_CFG_TLV_TYPE_REQUIRED 0x8000 +#define NFP_NET_CFG_TLV_LENGTH 0x02 +#define NFP_NET_CFG_TLV_LENGTH_INC 4 +#define NFP_NET_CFG_TLV_VALUE 0x04 +#define NFP_NET_CFG_TLV_STATS_OFFSET 0x08 + +#define NFP_NET_CFG_TLV_HEADER_REQUIRED 0x80000000 +#define NFP_NET_CFG_TLV_HEADER_TYPE 0x7fff0000 +#define NFP_NET_CFG_TLV_HEADER_LENGTH 0x0000ffff + +/* + * Capability TLV types + * + * @NFP_NET_CFG_TLV_TYPE_UNKNOWN: + * Special TLV type to catch bugs, should never be encountered. Drivers should + * treat encountering this type as error and refuse to probe. + * + * @NFP_NET_CFG_TLV_TYPE_RESERVED: + * Reserved space, may contain legacy fixed-offset fields, or be used for + * padding. The use of this type should be otherwise avoided. + * + * @NFP_NET_CFG_TLV_TYPE_END: + * Empty, end of TLV list. Must be the last TLV. Drivers will stop processing + * further TLVs when encountered. + * + * @NFP_NET_CFG_TLV_TYPE_ME_FREQ: + * Single word, ME frequency in MHz as used in calculation for + * @NFP_NET_CFG_RXR_IRQ_MOD and @NFP_NET_CFG_TXR_IRQ_MOD. + * + * @NFP_NET_CFG_TLV_TYPE_MBOX: + * Variable, mailbox area. Overwrites the default location which is + * @NFP_NET_CFG_MBOX_BASE and length @NFP_NET_CFG_MBOX_VAL_MAX_SZ. + * + * @NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL0: + * @NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL1: + * Variable, experimental IDs. IDs designated for internal development and + * experiments before a stable TLV ID has been allocated to a feature. Should + * never be present in production FW. + * + * @NFP_NET_CFG_TLV_TYPE_REPR_CAP: + * Single word, equivalent of %NFP_NET_CFG_CAP for representors, features which + * can be used on representors. + * + * @NFP_NET_CFG_TLV_TYPE_MBOX_CMSG_TYPES: + * Variable, bitmap of control message types supported by the mailbox handler. + * Bit 0 corresponds to message type 0, bit 1 to 1, etc. Control messages are + * encapsulated into simple TLVs, with an end TLV and written to the Mailbox. + * + * @NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS: + * 8 words, bitmaps of supported and enabled crypto operations. + * First 16B (4 words) contains a bitmap of supported crypto operations, + * and next 16B contain the enabled operations. + * This capability is obsoleted by ones with better sync methods. + * + * @NFP_NET_CFG_TLV_TYPE_VNIC_STATS: + * Variable, per-vNIC statistics, data should be 8B aligned (FW should insert + * zero-length RESERVED TLV to pad). + * TLV data has two sections. First is an array of statistics' IDs (2B each). + * Second 8B statistics themselves. Statistics are 8B aligned, meaning there + * may be a padding between sections. + * Number of statistics can be determined as floor(tlv.length / (2 + 8)). + * This TLV overwrites %NFP_NET_CFG_STATS_* values (statistics in this TLV + * duplicate the old ones, so driver should be careful not to unnecessarily + * render both). + * + * @NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS_RX_SCAN: + * Same as %NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS, but crypto TLS does stream scan + * RX sync, rather than kernel-assisted sync. + * + * @NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS_LENGTH: + * CRYPTO OPS TLV should be at least 32B. + */ +#define NFP_NET_CFG_TLV_TYPE_UNKNOWN 0 +#define NFP_NET_CFG_TLV_TYPE_RESERVED 1 +#define NFP_NET_CFG_TLV_TYPE_END 2 +#define NFP_NET_CFG_TLV_TYPE_ME_FREQ 3 +#define NFP_NET_CFG_TLV_TYPE_MBOX 4 +#define NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL0 5 +#define NFP_NET_CFG_TLV_TYPE_EXPERIMENTAL1 6 +#define NFP_NET_CFG_TLV_TYPE_REPR_CAP 7 +#define NFP_NET_CFG_TLV_TYPE_MBOX_CMSG_TYPES 10 +#define NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS 11 +#define NFP_NET_CFG_TLV_TYPE_VNIC_STATS 12 +#define NFP_NET_CFG_TLV_TYPE_CRYPTO_OPS_RX_SCAN 13 + +int nfp_net_tlv_caps_parse(struct rte_eth_dev *dev); + /* * nfp_net_cfg_ctrl_rss() - Get RSS flag based on firmware's capability * @hw_cap: The firmware's capabilities diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 241595be9d..7dc93f7c43 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -549,6 +549,12 @@ nfp_net_init(struct rte_eth_dev *eth_dev) if (err != 0) return err; + err = nfp_net_tlv_caps_parse(eth_dev); + if (err != 0) { + PMD_INIT_LOG(ERR, "Failed to parser TLV caps"); + return err; + } + nfp_net_ethdev_ops_mount(hw, eth_dev); hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *