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 B69E04414A; Mon, 3 Jun 2024 18:19:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C4E342E88; Mon, 3 Jun 2024 18:18:48 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 283B142E9E for ; Mon, 3 Jun 2024 18:18:45 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2234.outbound.protection.outlook.com [104.47.11.234]) by mx-outbound43-249.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 03 Jun 2024 16:18:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gRsKAhZmrNOoAvSJSPR2cPoCj3obxB6NPCqUhd/AoBmRektkF3HTdRDkzbUrdI/+2hhJ5NqgKvfKxdnyKjLrqMRbS9uBMHhJbmL/EpB4UTaPccEjyYNrpplrsNsJx/5vlUc+6r7LQt+1hagMCC57M91zG+stToAMknPD+VnjNPv0XPyYOLIK6De9QUJCyaezBut4dt4DkrjNbpVQo/uuUwYzE/Gv/zqv0o+2ixcndhz0gbW8r9WEzM+hknn9Z3N/lkWN7qYRHRUCnpqktT6a52Ibcf58e9iaY18Hedk0g0Ka8NSAfLgxCsK44/Oet8KEZ/k3p+uT3KrEg2+MzRtGOw== 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=DspWN4688TJ6yROWp97y4rAG/qb8OWo2Wh+3l6U8M58=; b=STLYcb7RT0b8vt6crTZkpTFFuC6jiafxYLFmo0I8PBhwGuIyIu6zilbBzWBbCoLI7OcGZ6J99Aq8SaoER4bSaMhb2KpL/BzLeDJ1kDY959onYAoxV+90SnS/GTHRAb/87lpmDdGVTpfSRjghmGcJnbUvE87LrN49ipN7nQYu6UpjI9YopmWyNOapdmWNmMkxv6sbQnXvwBedhTk2jGpfPVzFPlek2qhppyXyOUyIByhqQPQPFdTy+KvsGKtkRrDh7PNi9Kg3gG24/aTxXxHe/LTxGVBVcyD5LkBsYRsFIZZXq3ENgDLYkg75zRGRmuHEs9tWU4vWG0GnkXccxjrNPQ== 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=DspWN4688TJ6yROWp97y4rAG/qb8OWo2Wh+3l6U8M58=; b=e15pLjNbl5epM+KrsIQXQD2pgMbVNheRMaViBlPC8U9OlEDlg1EP/e28bxP3XApy+0cKET8K+GZ8uZqJ6bv6a6rMgPpHw8Z77YJ71e7peDijVryMo/FAeHwrlhYBHZZeYbDZI3m6pX2VHPw+8dTedurmvqdRzRjOzNhZR9ENkOI= Received: from AM6P191CA0082.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::23) by PA1P190MB2143.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:449::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Mon, 3 Jun 2024 16:18:43 +0000 Received: from AMS0EPF00000196.eurprd05.prod.outlook.com (2603:10a6:209:8a:cafe::68) by AM6P191CA0082.outlook.office365.com (2603:10a6:209:8a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.30 via Frontend Transport; Mon, 3 Jun 2024 16:18:42 +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 AMS0EPF00000196.mail.protection.outlook.com (10.167.16.217) with Microsoft SMTP Server id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 16:18:42 +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 v3 15/17] net/ntnic: add link management module Date: Mon, 3 Jun 2024 18:18:12 +0200 Message-ID: <20240603161822.59552-15-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240603161822.59552-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240603161822.59552-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000196:EE_|PA1P190MB2143:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b24e4e9e-9661-4e97-472b-08dc83e8d630 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UMZjOpyt8cY8u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?Q?xTU4RZrUSZw9Usjtyd6vFE5wyIb+b+Ybo5r/ls9/PcWk3PLlRjzwoW04klzt?= =?us-ascii?Q?2yJqNVhlrTKWGBstnOs4c8mwqERlur3qfFK2pD1IM+VxyRYWVy3TEmIOWk4M?= =?us-ascii?Q?6m9ZIESq/BN81EVheoZ5sU7xgmu0JL/3GXgqzOo6K1ybXm9y2A0fXAY048ix?= =?us-ascii?Q?MOlBfVAVSA/EN3gV5neXexsx4gJXV3FtZYc/gs2ZPW+bJ+vo3cRUFiWFJ/K9?= =?us-ascii?Q?BfJP49GBEv8UUcD8NPc6GeJLMi7IHJnBcr5A7o22WuLxfI6Z97xqOeiYI2JK?= =?us-ascii?Q?UTrE32qWuzZwZWFcaymuhdcbk/2AXX8DDEoUvJCx8AduNGNDNXhgofQk0dev?= =?us-ascii?Q?nbh6afNxKBTXbRDccwPzgZ6Yd1hsC3KUJZHnxCQAYX29NTQAc0VlDGsW+CWD?= =?us-ascii?Q?nBC0Uw8M5z6Bixx0w7X0hSKM+LlQW7RFpiwIdraTdZxeNNdI3Ef52CoIv0ZB?= =?us-ascii?Q?1i2Yhuc6oO1Ql0RT5BLOtDCEnfbF?= 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)(36860700004)(376005)(82310400017)(1800799015); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: FdoaVqdkp8bqoymhOLcJFwnGrd4GpDXCjOdJiDoH7RsNW4tqVwIORYirsLUQrzLtvq46tLAl6H4npUyYOOZwIbrQmPCLpcgoMVoU6fxwOvhlgl/ghspyZrmydbiMf4M5HbFpsiEOI7sIfr7mx5jHcaSyyussuXiYvi/pur4U7Vhive/zsXaNdC4iANzTV7YwCm9X7MthFrLHkuvJzlVBPzuYaJ4AYpREgxycUPmutEFMQoyNjDNjEMONG1mSoogGQj5Ok1rmqnezLuj0Yv3v4CA88HSzMmQlgxZmVpYUGNuJGWv9E2ZfodkLjM605fXXIsotMsvMR67kzSZ8DFe6/XPDiln8RwkiV8/SPYY0n1r7YeY7r/GdmK4IGyP2P9iyySJ3S6hw+Fgg4PhnZJRgOYgrWru+sauoNJR9VJ4dA57h9ZzIF00rJKvlcbRqmwPpnjLnvOxRRsdEE6sJXOHivAVCbkTVZTeaRYQdu0cse+DgeugLxaaTi3rjCXcaQrxKjeOCUEgbcKRguDqTiq7kth90EpWDIplrmliiqW96xzJoPGKovHOa/r4sTZH63plxaEljBBZuy7bDe4WIC64TOnPQG8eyOKVzNsIR77LSb0hSfvkPXZXntepihRe1tasmCnQbb2Bf8PkEnVh4EfL0RQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 16:18:42.7657 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b24e4e9e-9661-4e97-472b-08dc83e8d630 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: AMS0EPF00000196.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1P190MB2143 X-BESS-ID: 1717431524-311257-12787-8280-1 X-BESS-VER: 2019.1_20240530.1612 X-BESS-Apparent-Source-IP: 104.47.11.234 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuam5qZAVgZQ0CLN0tTIItnANN XQwNLYMDklLS3F0tg8LSUlzSI1OSVZqTYWAOEhrqlBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256698 [from cloudscan14-3.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 --- v2: * Fixed unused header --- drivers/net/ntnic/link_mgmt/nt4ga_link.c | 263 +++++++++++++++++++++++ 1 file changed, 263 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..765029bcd5 --- /dev/null +++ b/drivers/net/ntnic/link_mgmt/nt4ga_link.c @@ -0,0 +1,263 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#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.45.0