Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2807969lqt; Tue, 23 Apr 2024 02:07:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCqGw/9v8wVMizYuRbcJUEOTkXIqOyymgIe/5x2+c6jaGWLxFg5qinfJ7bBzNgC+P9lw9jclXYtPh/fSNBcHtGnDyAZx8dEDUPtp7Yuw== X-Google-Smtp-Source: AGHT+IFNiAKu0AzlbFD8jA5RnPdoUTpyDrYx6zqvMy0epbWg/R018xB7C91vYVitb5KQkyVtAvNw X-Received: by 2002:a50:d7d6:0:b0:56e:34e0:4699 with SMTP id m22-20020a50d7d6000000b0056e34e04699mr8444765edj.30.1713863225569; Tue, 23 Apr 2024 02:07:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713863225; cv=pass; d=google.com; s=arc-20160816; b=fG2HmyLuEpmebqGXAkRY7QHLdqFol3WTKWWAVBDsw7P/p6Lcb4C2hDlGPiO1rfMHUh IIcIUC7BSvWGCtM7XwZM0cel3eVn6P0HhckGckssVvZnAPfpblIXAxMWhPHWcXJCkK8D 3lQycCn1Lf2OdMrWsrjZ3bNdhDto6Q4NP4BwogRnrDJkIH6A771y84U9xwfaI9mRPbX0 LnWpUpu5XifdPz5nYkZ/0rz6yRWE3a2fwYb4a2aVIz2Orq5S4DSTPshpy05wXE/Y18MO Sr7DUCSuB0fn3jsS24N4NWRsT5cC6DI/HRvZnbHCi1aDxLBhxfuL+78dX3V+S95uWPbt x/Cg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=cv8IAJl5ZT2KI5eGTFuxjLT4/JyU5BmA9vKpIsy+9T4=; fh=VZ2HRIlU26AKgxtunD0Vpmk5KWsUR/ziQj0CipkWWb4=; b=ljM0f5EgjBg6WScETnvn34wPbSM5pDZAg741e7ub4uv7Fp3Nv4g/JPe3ey5HoktuV3 L4njY4IpX5ftutk7ZbGwEPyJsUjYx8nehacs5qG1Q9NjJIZezH3OuY2zdFHAM3QaToEG dFxDZca8krEldY3Ija/f9AnBeQbUtqBwzA1sPgVAZxPQ6YDbU8rbR1BudqcRHtLNaUd5 v/Psj/gD1BWcJVPRv54s+lofcCwRxYUl6Lh95bCB2E9EwQnSmTJ10dyyQhpIfuiloq6F qalqM4EytznpaCw14NAN8WmcUabcxhv1bW4GD2n05qZ5O35Y0tMkxSBo8guMKN8FfrLY qwLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lw3ZPOpI; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-154755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a21-20020a05640233d500b0056e04418a90si6535830edc.57.2024.04.23.02.07.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 02:07:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lw3ZPOpI; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-154755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A6E141F21958 for ; Tue, 23 Apr 2024 09:06:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 617D559B4D; Tue, 23 Apr 2024 09:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="lw3ZPOpI" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40AE056768; Tue, 23 Apr 2024 09:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713863177; cv=none; b=ttgA89+xrVc4MEKvQhSC8Fx5xsI7Tu6s06QrRflujCwXQO7Py0+tt/dEzrrc6X+2Ojqp880/OFNifp2opPMy7SV15obdqdsx8PUIaQ0DDBmzwRjq2oeyw5QCZOOdR4mU/7hPFbmCLSuFdx5S+KlvZb64kVd5LqlXa9Ynpw9o2m8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713863177; c=relaxed/simple; bh=30B4AtuolDboQHql5UUskhU5+dDy3nL0iec2d0X9dt8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iQYQIfeLsqthI2MHRHq2Uno4mplE1GdgjnAENcsS5St3Aw143VBpu8E1Tasc/OZJWie4P3kzPwPkXDuaOXEsukqV+27fGrxzIHD/62rc9cWrn/WWFtHGZ2D73Ug0Zxyvh23GCEdKh7fOvyH/pQSeXKfbye26uoV8z8XFIRH6clA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=lw3ZPOpI; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id EC8E1E000C; Tue, 23 Apr 2024 09:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713863173; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cv8IAJl5ZT2KI5eGTFuxjLT4/JyU5BmA9vKpIsy+9T4=; b=lw3ZPOpIlG9Fdutzqsus7l0rnv1YaZPTZG6ilDrD10+Y+ehMjx1ZfFsUz9HorVTwjrs1FS ySKZnf/lzXcoZFhBY4PEkQ4ShTs46TZ+i/NpG7XhoSOxfvkHsCrO2HcB5G6IHGOf9SbybB cgLM6Y5pMP2kxphxQp9kwGYBcVqZFwawNgwUuJzBspjnD8uBzW5hhf/RmRSMgsordwMaz8 kEEnqgsf12ep5U+DkiYEU8GFMJmys/Y9fKpYBvRkrKQPxDEd58q5T+ikCwjtOrGZzKmXZd O/K+ykd67xIBRpMZd4TE57pmgey46rW7GJGRQ1oIphD6iHLjSkhNpHIXQuTM4Q== From: Kory Maincent Date: Tue, 23 Apr 2024 11:05:42 +0200 Subject: [PATCH ethtool-next 2/2] ethtool: pse-pd: Add support for Power over Ethernet (clause 33) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240423-feature_poe-v1-2-9e12136a8674@bootlin.com> References: <20240423-feature_poe-v1-0-9e12136a8674@bootlin.com> In-Reply-To: <20240423-feature_poe-v1-0-9e12136a8674@bootlin.com> To: Oleksij Rempel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Michal Kubecek Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Swenson , Kory Maincent X-Mailer: b4 0.14-dev X-GND-Sasl: kory.maincent@bootlin.com From: Kory Maincent (Dent Project) This update extends PSE support to include Power over Ethernet (clause 33), encompassing standards 802.3af, 802.3at, and 802.3bt infrastructure. Signed-off-by: Kory Maincent --- ethtool.c | 1 + netlink/pse-pd.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/ethtool.c b/ethtool.c index e587597..d85a57a 100644 --- a/ethtool.c +++ b/ethtool.c @@ -6216,6 +6216,7 @@ static const struct option args[] = { .nlfunc = nl_spse, .help = "Set Power Sourcing Equipment settings", .xhelp = " [ podl-pse-admin-control enable|disable ]\n" + " [ c33-pse-admin-control enable|disable ]\n" }, { .opts = "-h|--help", diff --git a/netlink/pse-pd.c b/netlink/pse-pd.c index d6faff8..2c8dd89 100644 --- a/netlink/pse-pd.c +++ b/netlink/pse-pd.c @@ -54,6 +54,41 @@ static const char *podl_pse_pw_d_status_name(u32 val) } } +static const char *c33_pse_admin_state_name(u32 val) +{ + switch (val) { + case ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN: + return "unknown"; + case ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED: + return "disabled"; + case ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED: + return "enabled"; + default: + return "unsupported"; + } +} + +static const char *c33_pse_pw_d_status_name(u32 val) +{ + switch (val) { + case ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN: + return "unknown"; + case ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED: + return "disabled"; + case ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING: + return "searching"; + case ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING: + return "delivering power"; + case ETHTOOL_C33_PSE_PW_D_STATUS_TEST: + return "test"; + case ETHTOOL_C33_PSE_PW_D_STATUS_FAULT: + return "fault"; + case ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT: + return "otherfault"; + default: + return "unsupported"; + } +} int pse_reply_cb(const struct nlmsghdr *nlhdr, void *data) { const struct nlattr *tb[ETHTOOL_A_PSE_MAX + 1] = {}; @@ -98,6 +133,24 @@ int pse_reply_cb(const struct nlmsghdr *nlhdr, void *data) podl_pse_pw_d_status_name(val)); } + if (tb[ETHTOOL_A_C33_PSE_ADMIN_STATE]) { + u32 val; + + val = mnl_attr_get_u32(tb[ETHTOOL_A_C33_PSE_ADMIN_STATE]); + print_string(PRINT_ANY, "c33-pse-admin-state", + "Clause 33 PSE Admin State: %s\n", + c33_pse_admin_state_name(val)); + } + + if (tb[ETHTOOL_A_C33_PSE_PW_D_STATUS]) { + u32 val; + + val = mnl_attr_get_u32(tb[ETHTOOL_A_C33_PSE_PW_D_STATUS]); + print_string(PRINT_ANY, "c33-pse-power-detection-status", + "Clause 33 PSE Power Detection Status: %s\n", + c33_pse_pw_d_status_name(val)); + } + close_json_object(); return MNL_CB_OK; @@ -138,6 +191,12 @@ static const struct lookup_entry_u32 podl_pse_admin_control_values[] = { {} }; +static const struct lookup_entry_u32 c33_pse_admin_control_values[] = { + { .arg = "enable", .val = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED }, + { .arg = "disable", .val = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED }, + {} +}; + static const struct param_parser spse_params[] = { { .arg = "podl-pse-admin-control", @@ -146,6 +205,13 @@ static const struct param_parser spse_params[] = { .handler_data = podl_pse_admin_control_values, .min_argc = 1, }, + { + .arg = "c33-pse-admin-control", + .type = ETHTOOL_A_C33_PSE_ADMIN_CONTROL, + .handler = nl_parse_lookup_u32, + .handler_data = c33_pse_admin_control_values, + .min_argc = 1, + }, {} }; -- 2.34.1