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 0999944111; Thu, 30 May 2024 16:52:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1F6842DC4; Thu, 30 May 2024 16:50:19 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 220E042D92 for ; Thu, 30 May 2024 16:50:16 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2105.outbound.protection.outlook.com [104.47.18.105]) by mx-outbound15-68.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 30 May 2024 14:50:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L5x+4WUmzLI8xX3Zc1r8dcXj7UxfhDUqK4BVCPKCDGNAEBQnKnoQFz+PuX1lYJ8f563N/gINWkoQ7dJucHyhRERVkaduIkvv/jrp2pLFeecZktC0u66A8j+SETu9Vxfxqm2g4RxKnv+V44thNZD+2q+4H45eZg/5mmXlPLFOjlZM35Yw0IGwbzOc/0Uwnkv57TF+XWN5PCKrEeZj8CKcpIEH9a/pjywzg6fAdKdkOlhruRBkupv6K2YQjlF9BOepW6H7wBQzzs3T2TWmKqgLMxLst/LSq8lsOgHuNxo3tC+ALLsHMHgRFtgz72386f3WAqlnFRBblZ+oJm7iGt8VtQ== 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=RYAvaPc0Su0zgCR9wrImFwRsWnIWdGxGsPG/Aa6LPKo=; b=RHZT3L4MsjfMDy1OtPGj1/6SBwKyDBvOZDiwu5M+NwgObpaFKoyByHhcXHbEcNAHUJQaPGPx9OKKqhUJLPvMNxDq4DrwHbuJ+LnJra5qk2eCwqKtS8tvUuCzqZHKeA5w+rQEA0Y0S58ZfJhrDxm0Npi3xRtg7otX5E/4m26TjZ9eoLBLZ0WqyankDU2yWXYRqw/5iwgB1C1AdSTyjiGfeyvn5vwCDadaL897TW95El/T+HcAu6XgLfCMOK2KkxrIsT4xagyp0IgvXkKNESwhE7pWMTYIBrZOl/t0RPXaJI/s4+hOBgub0l+lHheK0/o2izAO2JtrBFxWvUJl64NL6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RYAvaPc0Su0zgCR9wrImFwRsWnIWdGxGsPG/Aa6LPKo=; b=Oqz29rP1e0P/vlq7ABMbMEp6E5rDl5YrxMUiqaBXjYxM4jpkxwqSoSRZD2+REpSzKaWRz8RBFJS/NXNnkxJs88ybM1jqh0AzO5DUIau4h0PyCdaSYYL1nCu5cYIpOAdI1TMndsm551wRxw5iKhOigDsknZwYi33XvGqzX94vcQU= Received: from DU6P191CA0037.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53f::16) by AM7P190MB0742.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:122::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Thu, 30 May 2024 14:50:04 +0000 Received: from DB1PEPF000509EB.eurprd03.prod.outlook.com (2603:10a6:10:53f:cafe::e7) by DU6P191CA0037.outlook.office365.com (2603:10a6:10:53f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21 via Frontend Transport; Thu, 30 May 2024 14:50:04 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DB1PEPF000509EB.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server id 15.20.7633.15 via Frontend Transport; Thu, 30 May 2024 14:50:04 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com Subject: [PATCH v1 15/17] net/ntnic: add link management module Date: Thu, 30 May 2024 16:49:12 +0200 Message-ID: <20240530144929.4127931-15-sil-plv@napatech.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240530144929.4127931-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509EB:EE_|AM7P190MB0742:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: fa34c8c3-fead-4a3f-9b6a-08dc80b7ca70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cwJJs3zMB20x9ohnzxB/Krh5miGViICydD8F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oe83jY5eNuqdvNBh5XFLR8zhwwTbct6wtNllo0i7NnO61MHXVXjGSEH?= =?us-ascii?Q?IJxXMzpue6+uc1LNgUXGW6Jamrmggt0esfL7Zntznv0jWom+i3z+XXxI/QWd?= =?us-ascii?Q?Jj/ytnXESDWIMdWYwBpu3oArpgkFDVgrmAmgnkS6ey0hVMyiPta1Y/m/aG++?= =?us-ascii?Q?JzRlu1bL4aThJeOLEOcTpLmW3ID2Qru9o5i1gZJjiq08R2Rh7dTEwKmuOf78?= =?us-ascii?Q?E0VuZrbtQArY8OVckE64IqASbaBmZE2PKAqfdrQgNRD4hIMEB/AIoWNmO6NX?= =?us-ascii?Q?id24EIa/lxHFbF3vs8wfGExOcZR48SQ97GjFfCn7mlwS7EDYCPLkUhg/6ZJl?= =?us-ascii?Q?BstrRgLmW5B8ZR+YJ75jAEQzxrz8FHm0lO8ireMQXfMdNWpWK7JzL2MD8NHo?= =?us-ascii?Q?gIvGx2/0MS/i/spxYXiiE65AqAwqr3Kvz6h3b87K/wimr1y1b0svD87yxyNp?= =?us-ascii?Q?rMAB2tDL/rJWwlRjJ7fubFaSoyKX?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(82310400017)(36860700004)(376005)(1800799015); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: TD4hRCHxKoNwC3iqZVRbFxPx2AISep09xVNilomhZdh9HKb1OaYdQEs9cID5qgkbQvuy6YiZ/gQse24FbxMhCuACdUSs7vzkQyt89KarRJkLc5LViLxWyLxBQB2fNxESLsiZzw598f8kzhHdBbZN5zXW0oY8wqg7oKkPPO5GCDHdgg66BbktT80U/D5UbUxMWVz6V4bS1xw2gi27Zmz7YW4HPb5BBjJobkBPZbEcUuLoXG7X8pcltPMy7UvWKJ9qBoAalFNTWNaS6gGkSrbz1f6jDKHxg07Zm4JowR998P2xzMrOjyaqf1xNi4CdmX/wUhzxNnIFqrzDdkqmadBIlLFXqVs/nhN9LqfnLuoZ8jXr6R+gNaK52ej4+3Xzuw8P258kIrhhb0yf1+0xOF7UG6lXThrJTKm9zCLfftcu6fPI2sGnpxncr2Q3whU/0mxLFd+ht/V/+o7SCvvyMP1urYOCBcDRb9rNyB5+/VCiyNnThFbN0gCOWSo6Cs1hTs3H8yoZc+WCvee5e1X5av3MEcUHSOzBKuFUFWesARp8iFJ/xI303xBugVbzD8l99c6wuqm4AkyyGL+ciTdPdjBCO6m1A/sQknkfSfk8BaKf4C9mR/kIqCbCNHYGOf/L1uX+JMhqzahI4LJPHQ5bqTO8lQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 14:50:04.1015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa34c8c3-fead-4a3f-9b6a-08dc80b7ca70 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509EB.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0742 X-BESS-ID: 1717080606-303908-12708-38232-2 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.18.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuamZqZAVgZQ0NjUNMXc0jwt1T gpxcTIPMnYxDLVMskoxcg8MTEtMdVUqTYWAKh0xBRBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256603 [from cloudscan14-194.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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 ntnic link control. Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/link_mgmt/nt4ga_link.c | 264 +++++++++++++++++++++++ 1 file changed, 264 insertions(+) create mode 100644 drivers/net/ntnic/link_mgmt/nt4ga_link.c diff --git a/drivers/net/ntnic/link_mgmt/nt4ga_link.c b/drivers/net/ntnic/link_mgmt/nt4ga_link.c new file mode 100644 index 0000000000..bbe8881f93 --- /dev/null +++ b/drivers/net/ntnic/link_mgmt/nt4ga_link.c @@ -0,0 +1,264 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include +#include +#include +#include + +#include "ntlog.h" +#include "nthw_drv.h" +#include "nt4ga_adapter.h" +#include "ntnic_mod_reg.h" + +#include "nt4ga_link.h" +#include "nt_util.h" +#include "i2c_nim.h" + +static bool nt4ga_port_get_nim_present(struct adapter_info_s *p, int port); + +/* + * port:s link mode + */ +static void nt4ga_port_set_adm_state(struct adapter_info_s *p, int port, bool adm_state); +static bool nt4ga_port_get_adm_state(struct adapter_info_s *p, int port); + +/* + * port:s link status + */ +static void nt4ga_port_set_link_status(struct adapter_info_s *p, int port, bool status); +static bool nt4ga_port_get_link_status(struct adapter_info_s *p, int port); + +/* + * port: link autoneg + */ +static void nt4ga_port_set_link_autoneg(struct adapter_info_s *p, int port, bool autoneg); +static bool nt4ga_port_get_link_autoneg(struct adapter_info_s *p, int port); + +/* + * port: link speed + */ +static void nt4ga_port_set_link_speed(struct adapter_info_s *p, int port, nt_link_speed_t speed); +static nt_link_speed_t nt4ga_port_get_link_speed(struct adapter_info_s *p, int port); + +/* + * port: link duplex + */ +static void +nt4ga_port_set_link_duplex(struct adapter_info_s *p, int port, nt_link_duplex_t duplex); +static nt_link_duplex_t nt4ga_port_get_link_duplex(struct adapter_info_s *p, int port); + +/* + * port: loopback mode + */ +static void nt4ga_port_set_loopback_mode(struct adapter_info_s *p, int port, uint32_t mode); +static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port); + +static uint32_t nt4ga_port_get_link_speed_capabilities(struct adapter_info_s *p, int port); + +/* + * port: tx power + */ +static int nt4ga_port_tx_power(struct adapter_info_s *p, int port, bool disable); + +/* + * port: speed capabilitoes + * This is actually an adapter capability mapped onto every port + */ +static uint32_t nt4ga_port_get_link_speed_capabilities(struct adapter_info_s *p, int port) +{ + (void)p; + (void)port; + nt4ga_link_t *const p_link = &p->nt4ga_link; + const uint32_t nt_link_speed_capa = p_link->speed_capa; + return nt_link_speed_capa; +} + +/* + * port: nim present + */ +static bool nt4ga_port_get_nim_present(struct adapter_info_s *p, int port) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + const bool nim_present = p_link->link_state[port].nim_present; + return nim_present; +} + +/* + * port: link mode + */ +static void nt4ga_port_set_adm_state(struct adapter_info_s *p, int port, bool adm_state) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + p_link->port_action[port].port_disable = !adm_state; +} + +static bool nt4ga_port_get_adm_state(struct adapter_info_s *p, int port) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + const bool adm_state = !p_link->port_action[port].port_disable; + return adm_state; +} + +/* + * port: link status + */ +static void nt4ga_port_set_link_status(struct adapter_info_s *p, int port, bool link_status) +{ + /* Setting link state/status is (currently) the same as controlling the port adm state */ + nt4ga_port_set_adm_state(p, port, link_status); +} + +static bool nt4ga_port_get_link_status(struct adapter_info_s *p, int port) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + bool status = p_link->link_state[port].link_up; + return status; +} + +/* + * port: link speed + */ +static void nt4ga_port_set_link_speed(struct adapter_info_s *p, int port, nt_link_speed_t speed) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + p_link->port_action[port].port_speed = speed; + p_link->link_info[port].link_speed = speed; +} + +static nt_link_speed_t nt4ga_port_get_link_speed(struct adapter_info_s *p, int port) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + nt_link_speed_t speed = p_link->link_info[port].link_speed; + return speed; +} + +/* + * port: link autoneg + * Currently not fully supported by link code + */ +static void nt4ga_port_set_link_autoneg(struct adapter_info_s *p, int port, bool autoneg) +{ + (void)p; + (void)port; + (void)autoneg; + nt4ga_link_t *const p_link = &p->nt4ga_link; + (void)p_link; +} + +static bool nt4ga_port_get_link_autoneg(struct adapter_info_s *p, int port) +{ + (void)p; + (void)port; + nt4ga_link_t *const p_link = &p->nt4ga_link; + (void)p_link; + return true; +} + +/* + * port: link duplex + * Currently not fully supported by link code + */ +static void nt4ga_port_set_link_duplex(struct adapter_info_s *p, int port, nt_link_duplex_t duplex) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + p_link->port_action[port].port_duplex = duplex; +} + +static nt_link_duplex_t nt4ga_port_get_link_duplex(struct adapter_info_s *p, int port) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + nt_link_duplex_t duplex = p_link->link_info[port].link_duplex; + return duplex; +} + +/* + * port: loopback mode + */ +static void nt4ga_port_set_loopback_mode(struct adapter_info_s *p, int port, uint32_t mode) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + p_link->port_action[port].port_lpbk_mode = mode; +} + +static uint32_t nt4ga_port_get_loopback_mode(struct adapter_info_s *p, int port) +{ + nt4ga_link_t *const p_link = &p->nt4ga_link; + return p_link->port_action[port].port_lpbk_mode; +} + +/* + * port: tx power + */ +static int nt4ga_port_tx_power(struct adapter_info_s *p, int port, bool disable) +{ + nt4ga_link_t *link_info = &p->nt4ga_link; + + if (link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_SR4 || + link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28 || + link_info->u.nim_ctx[port].port_type == NT_PORT_TYPE_QSFP28_LR4) { + nim_i2c_ctx_t *nim_ctx = &link_info->u.var100g.nim_ctx[port]; + + if (!nim_ctx->specific_u.qsfp.rx_only) { + if (nim_qsfp_plus_nim_set_tx_laser_disable(nim_ctx, disable, -1) != 0) + return 1; + } + } + + return 0; +} + +static const struct port_ops ops = { + .get_nim_present = nt4ga_port_get_nim_present, + + /* + * port:s link mode + */ + .set_adm_state = nt4ga_port_set_adm_state, + .get_adm_state = nt4ga_port_get_adm_state, + + /* + * port:s link status + */ + .set_link_status = nt4ga_port_set_link_status, + .get_link_status = nt4ga_port_get_link_status, + + /* + * port: link autoneg + */ + .set_link_autoneg = nt4ga_port_set_link_autoneg, + .get_link_autoneg = nt4ga_port_get_link_autoneg, + + /* + * port: link speed + */ + .set_link_speed = nt4ga_port_set_link_speed, + .get_link_speed = nt4ga_port_get_link_speed, + + /* + * port: link duplex + */ + .set_link_duplex = nt4ga_port_set_link_duplex, + .get_link_duplex = nt4ga_port_get_link_duplex, + + /* + * port: loopback mode + */ + .set_loopback_mode = nt4ga_port_set_loopback_mode, + .get_loopback_mode = nt4ga_port_get_loopback_mode, + + .get_link_speed_capabilities = nt4ga_port_get_link_speed_capabilities, + + /* + * port: tx power + */ + .tx_power = nt4ga_port_tx_power, +}; + +static void __attribute__((constructor(65535))) port_init(void) +{ + register_port_ops(&ops); +} -- 2.44.0