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 7CDEF4411D; Fri, 31 May 2024 17:49:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 363BB42DF8; Fri, 31 May 2024 17:48:02 +0200 (CEST) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id 07F4A42D99 for ; Fri, 31 May 2024 17:47:50 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2050.outbound.protection.outlook.com [104.47.12.50]) by mx-outbound20-91.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 31 May 2024 15:47:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rew92FhLHESKiQMcADLIKB0D9Vz6kUrvdhYDLhfKF2jc+fhv3yNHkmM0SrkGmr635mL1VB2X3oS8tViS1XRS4R6k0d6ku8Ls/bwKxWgk0IoW7VGhWgYM8w4kWJ/qUVgEO7OlGf2C4r4kP4mHVFoR+SlGGAjLgTsJnLAScXh+kO0+3fwthbuY4Yut3nyZpHS+gu6Tk0fQJ3hEDXtRBlNjp78tHcSuNO4TRAQoR6MUYZk3WfMfuX27PE9YLbTlJgWdL6CP4EkKijZkbkdcC6KcLoqCrXX6q8iiIxUijneKAX42sfG5dQ9SHEjrXfRJYefbyxXrt27jgx9XvfvLmSpN6g== 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=tKlJ5ZygRnaXZPfj6UGx3Pw3RR/6YbI+vqeVtsf3SdQ=; b=WqoV7dqzxTBndIgUj1+BSDfIO5cYrXP3XzO59ayAtJW1nst5R6IJvXbxzWWnt/Lz7XDyCcVFn6ZTHmbN3JHrapndtpfWFBeoPFnVHIAznlwE9hA/oFpWTbOfuyYxqGb+ZivriaAsp2vrL8OHY5GfhwX28zv90gXK90kJFQkVywFCaa6UL7lWQs6+AhjcRycm9rIPrdPBYR05jdue+GNQYWD6mjAYXOps9sB4e7Beoa9FXap35haqGmUvqO+jDBFHVG1iby2uMVixLrAbuLHGFMespFSEAG4sm+9taQuFI6QOptMkRAMo76sWEHSwIWM9UThUTUnE0HIyytiJnwqhng== 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=tKlJ5ZygRnaXZPfj6UGx3Pw3RR/6YbI+vqeVtsf3SdQ=; b=gWi9F7G06i26a/W609APNMXviI5n1O6nK9FIn+eV0TcPpE+Pnezs6PJTtNtfcPtGCpLRlYTZ1FmvBrMoIn/MlWzta/mBaDpR3ebiLycvC+v1UdCIwhfP9lEfe5C24zNJ4KdbA3I8bL4hmMKJVh4BsZIUcjPrehUPCelf0zrFG1c= Received: from AS4P251CA0020.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d3::9) by DB9P190MB1988.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:39b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Fri, 31 May 2024 15:47:46 +0000 Received: from AMS1EPF00000047.eurprd04.prod.outlook.com (2603:10a6:20b:5d3:cafe::46) by AS4P251CA0020.outlook.office365.com (2603:10a6:20b:5d3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.23 via Frontend Transport; Fri, 31 May 2024 15:47:46 +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 AMS1EPF00000047.mail.protection.outlook.com (10.167.16.135) with Microsoft SMTP Server id 15.20.7633.15 via Frontend Transport; Fri, 31 May 2024 15:47:46 +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 v2 15/17] net/ntnic: add link management module Date: Fri, 31 May 2024 17:47:19 +0200 Message-ID: <20240531154731.1856874-15-sil-plv@napatech.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240531154731.1856874-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240531154731.1856874-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF00000047:EE_|DB9P190MB1988:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 91b6a3c5-407d-4403-2808-08dc81890496 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|82310400017|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ZMF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JW64BSI?= =?us-ascii?Q?Mc1ATy7LyACzrKVu7MbyV6+DhntYurqezrkoSzReNEzvplCGMuJsXBovktjI?= =?us-ascii?Q?3seH3usFHU/KN9Qy7BtWWkugNyikcLGQMxNTrPegr8JWIIufW80CaN8FgZoZ?= =?us-ascii?Q?6Rp2TxjK84yKeyKAqRzuiVZ7weExw6ZklmFwsbqLxzLQsLF8WJYXHxO+nby5?= =?us-ascii?Q?N3CJx5RgC+C7pM5lB9ej6BHFf7SjGFwYG6SDYY3bkJ/QSo5mhTy6BMrDMltR?= =?us-ascii?Q?APsmoF9zkFEF8ERG38j/6w0hO0cnOcRu/dN1OiKzuxYbxeLwFMwY84KFDO8I?= =?us-ascii?Q?8Xi+4q53sckapEIY6sbvcpj6AAW9Ac4dIND8GfvjrSe4VRqw/uGmRYRITYZw?= =?us-ascii?Q?Vv7o4xv2mw1YjpKzqMbzMwx8ca5JMPxviiIVmgql30+eIlEjh0l0cU8o4WeR?= =?us-ascii?Q?LM2hwdPH2f9+PdPgVpLd69eh06Q5h1H3ggu9kcsb+oK6anFTZVMSlb99UeKu?= =?us-ascii?Q?AlnR2VFEkDU58rmtGPwfbU+6876N?= 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)(1800799015)(82310400017)(36860700004)(376005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ZXAy7Xv07gwxdMZk4oRoZsp1Oqv/wmBdLSCKKz+LsgTcllhXIoeP6jNAtRxfS2jpsfTzCrwbuoSHM39eSd3hdBG9gQJg2UzcM/7mdcHQ6EixfxoP2LOn/ymzO27d+EGDv+0gEDVkMrixDBZutDSyu3glXyBCUd9W1SorU8M5XS+BFa3WI7fLNaZj+bT6pFOMbgXVvTrFx/w2D88q97BQOcJ0F4ja9Wm52RL8tbx6ev6RxJCaCWRUvPIj2XecTyxlrAN8zeHsfqciL+ZVuN1XZiN+69RBjD7p6RcdM7VU8YODMNGPg4a+E15owASOvId9HA3tWl3qQaj+LocX1p5az/q5izB4NMUhHUrwpWSwxqJhuIu3cKb8K2UNDG7qP31frIiKKR0JkkwF1z2flze/grPDcvu2ObTw3m0Nvy1gaDptm5NK98r1zte8KGFh5dcyY2Odg5Xu7CI/Cfzf7RBpKmCWhOt3biLHnsK5pb+9QTjhDNl39JR8hAEuPF7GzntCvQY3kMyNpqOLLlDW3lH4mzB0DdxOwXNVEbUmnqZVMH7Fv8otfHXzYGceiO0EcIP1t6dhZE+e55AhZKr9Cl62qsy0TJE77PzBLceSlnF7JJAZYbokBSHb57kBqpDoPviPWop5fjT3Jga6YGCN47hIKw== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 15:47:46.5969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91b6a3c5-407d-4403-2808-08dc81890496 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: AMS1EPF00000047.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1988 X-BESS-ID: 1717170468-305211-12715-33313-1 X-BESS-VER: 2019.1_20240530.1612 X-BESS-Apparent-Source-IP: 104.47.12.50 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuam5qZAVgZQMMnIOCXFwtQ4yd DSzCjZxCjVLDnRMsk4ySDJMNXMMNVIqTYWAF1yQftBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256627 [from cloudscan17-35.eu-central-1b.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.44.0