From nobody Thu Oct 2 14:27:44 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 D7EA327FD6D; Mon, 15 Sep 2025 17:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956038; cv=none; b=LQglTrzgigp/I3ddWs45DSeDaoPmt25lgX3E1qkM9YLUell6lNg/4+u2KfOXWekAvLb2KnKMr6nmbGA18vgNgbeJ3Q46kqNfjnq9IS2fdLE5OJTCetucyG5cp2x4n2tDI0sUJjCMoqWRDPi7hA/mC/55oiKgTanGMbqfj1XFGao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956038; c=relaxed/simple; bh=eI1aiFNYryO+t5nHeumpPB+dsVNw8uOQsJ0Hivfxi60=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T4E+EGLs9noLo3t1SFuSFeisAJ5lTPP3ieAWRlHQuFzIHgIxHiXJmAxn1dAXlfNOnrmAW56f+QVIUXe5PZw+rAsD2/zX0nGQzQFlroMmrJsuFWodPCfDdwddm0wBEJxQQfloIrbinyOXKw5rSBaBDT4OVU0GsFR046uzGaowwsI= 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=gwXZjCJA; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="gwXZjCJA" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id E1C411A0E16; Mon, 15 Sep 2025 17:07:08 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B7BF36063F; Mon, 15 Sep 2025 17:07:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A4615102F2AC9; Mon, 15 Sep 2025 19:07:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757956027; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=G5hFWIHn9ebEQkKaq4cychymeANjC1DTgGmjV0wrK34=; b=gwXZjCJAl2Bi3wAyCQradf8Md2OBAKMei6tUtWuDnoTWGUiXZ41Hhcp4wfbjQ3UUG2gcly B2ktxdr49H2jv0OY3ca7u1KtH5VWARNddHeRAfb7Kzb64IDj8T8pUUPkWwcIUSzq6d08v+ 38vvD3d9mYCHzwsFQ5xogPt/FN5iQJQpLJEpvYofsG9LkZ1X2xSx/oAo8oMKkRtJRQmEsR VE7QJUrb14032Lv+19sS9uMJN1o2UxvJhOrm/TXACdy1ZXy1eRNzoxRoc59Ymr/iVAaKFn rAcax5xDh3elN6o2BC6vdTWLkFlGEAvXMuCugW2/qOdU1SVR7CcAlIMj09EmAQ== From: Kory Maincent Date: Mon, 15 Sep 2025 19:06:26 +0200 Subject: [PATCH net-next v3 1/5] net: pse-pd: pd692x0: Replace __free macro with explicit kfree calls 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: quoted-printable Message-Id: <20250915-feature_poe_permanent_conf-v3-1-78871151088b@bootlin.com> References: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> In-Reply-To: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> To: Oleksij Rempel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Jonathan Corbet , Donald Hunter Cc: kernel@pengutronix.de, Dent Project , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Chevallier , linux-doc@vger.kernel.org, Kyle Swenson , "Kory Maincent (Dent Project)" X-Mailer: b4 0.15-dev-8cb71 X-Last-TLS-Session-Version: TLSv1.3 From: Kory Maincent (Dent Project) Replace __free(kfree) with explicit kfree() calls to follow the net subsystem policy of avoiding automatic cleanup macros as described in the documentation. Signed-off-by: Kory Maincent --- Changes in v2: - New patch --- drivers/net/pse-pd/pd692x0.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c index f4e91ba64a666..055e925c853ef 100644 --- a/drivers/net/pse-pd/pd692x0.c +++ b/drivers/net/pse-pd/pd692x0.c @@ -1200,9 +1200,9 @@ static void pd692x0_managers_free_pw_budget(struct pd= 692x0_priv *priv) =20 static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) { - struct pd692x0_manager *manager __free(kfree) =3D NULL; struct pd692x0_priv *priv =3D to_pd692x0_priv(pcdev); struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]; + struct pd692x0_manager *manager; int ret, nmanagers; =20 /* Should we flash the port matrix */ @@ -1216,7 +1216,7 @@ static int pd692x0_setup_pi_matrix(struct pse_control= ler_dev *pcdev) =20 ret =3D pd692x0_of_get_managers(priv, manager); if (ret < 0) - return ret; + goto err_free_manager; =20 nmanagers =3D ret; ret =3D pd692x0_register_managers_regulator(priv, manager, nmanagers); @@ -1236,12 +1236,15 @@ static int pd692x0_setup_pi_matrix(struct pse_contr= oller_dev *pcdev) goto err_managers_req_pw; =20 pd692x0_of_put_managers(priv, manager, nmanagers); + kfree(manager); return 0; =20 err_managers_req_pw: pd692x0_managers_free_pw_budget(priv); err_of_managers: pd692x0_of_put_managers(priv, manager, nmanagers); +err_free_manager: + kfree(manager); return ret; } =20 --=20 2.43.0 From nobody Thu Oct 2 14:27:44 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 745E5288C08 for ; Mon, 15 Sep 2025 17:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956040; cv=none; b=YLJu9eNK3Syiwouon07ff6imOITQYE5GJ3aGV0Sv0NV0bVt8YHheG4Oevs+NsAzzGIMi43Gwm7lcjjpMGlS1Uqt1YEVyXSxP/7FJo1P4iYGlTvocjHGmrBXJLLFSSjRu/vDpnH6C8p5/Vht+fmSHQ3LTJcKqZ6qvmOGOuyQJO3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956040; c=relaxed/simple; bh=dJwjUPn034iFwJen1qZi+xOnmiXvVUMA6OruI/pptho=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P6GU9nEIMtDMxyrUKkKvqyj2skI619QKn5iBOd4VCQXC53xOEBsl252s6keZiSKPTgZQjmn9cufdgydAY0AIclhZzDYD4j0cOFqQC45QV91Cmzqkut8DxrE776+kdRJsXIkKBQF3OKysey4yFqj7+eiwnDtzZUABrnFB9uMVEy8= 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=J4VSKv87; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="J4VSKv87" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id F09C64E40C50; Mon, 15 Sep 2025 17:07:10 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C74166063F; Mon, 15 Sep 2025 17:07:10 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C693D102F2B11; Mon, 15 Sep 2025 19:07:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757956029; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=MP2NOP/U31hvh9wbH1Enlv9gdxa7zblBpEyR64wWxPQ=; b=J4VSKv87tXb27+pOJ7xuaddXR1kPia3PMxdTAQgAL4Tu7gWPTdLAA3w+RkOpnkyFrIc4+3 CdCUUhEWVLpVxgDhOKdObSMXcPiHombNWM2I00sVyy3XcucSZJ7kwPzvCZk0j7yxqPd0oI eHm9HKhizvBk/6+KH89v1jVHWxa5UdPh/d93AguyjRSgsVeCedLXSgFZ8Xw4bd9qYVs00w RdWlvyPLQ34SQnMD5euV0AMrxAYDXi3LqOTyCmkUELyzvXrtbqYXfhUgDqOyTFpmeEz0fv lfgmH/2vbA9ek4NXB5FvyFvaHcktRCoPE6KIBn29VLjDLIjDhunClm1r2zb36A== From: Kory Maincent Date: Mon, 15 Sep 2025 19:06:27 +0200 Subject: [PATCH net-next v3 2/5] net: pse-pd: pd692x0: Separate configuration parsing from hardware setup 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: quoted-printable Message-Id: <20250915-feature_poe_permanent_conf-v3-2-78871151088b@bootlin.com> References: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> In-Reply-To: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> To: Oleksij Rempel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Jonathan Corbet , Donald Hunter Cc: kernel@pengutronix.de, Dent Project , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Chevallier , linux-doc@vger.kernel.org, Kyle Swenson , "Kory Maincent (Dent Project)" X-Mailer: b4 0.15-dev-8cb71 X-Last-TLS-Session-Version: TLSv1.3 From: Kory Maincent (Dent Project) Cache the port matrix configuration in driver private data to enable PSE controller reconfiguration. This refactoring separates device tree parsing from hardware configuration application, allowing settings to be reapplied without reparsing the device tree. This prepares for upcoming permanent configuration support where cached settings can be restored after device resets or firmware updates. Signed-off-by: Kory Maincent --- drivers/net/pse-pd/pd692x0.c | 115 ++++++++++++++++++++++++++++-----------= ---- 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c index 055e925c853ef..782b1abf94cb1 100644 --- a/drivers/net/pse-pd/pd692x0.c +++ b/drivers/net/pse-pd/pd692x0.c @@ -85,6 +85,11 @@ enum { PD692X0_MSG_CNT }; =20 +struct pd692x0_matrix { + u8 hw_port_a; + u8 hw_port_b; +}; + struct pd692x0_priv { struct i2c_client *client; struct pse_controller_dev pcdev; @@ -101,6 +106,8 @@ struct pd692x0_priv { enum ethtool_c33_pse_admin_state admin_state[PD692X0_MAX_PIS]; struct regulator_dev *manager_reg[PD692X0_MAX_MANAGERS]; int manager_pw_budget[PD692X0_MAX_MANAGERS]; + int nmanagers; + struct pd692x0_matrix *port_matrix; }; =20 /* Template list of communication messages. The non-null bytes defined here @@ -809,11 +816,6 @@ struct pd692x0_manager { int nports; }; =20 -struct pd692x0_matrix { - u8 hw_port_a; - u8 hw_port_b; -}; - static int pd692x0_of_get_ports_manager(struct pd692x0_priv *priv, struct pd692x0_manager *manager, @@ -903,7 +905,8 @@ pd692x0_of_get_managers(struct pd692x0_priv *priv, } =20 of_node_put(managers_node); - return nmanagers; + priv->nmanagers =3D nmanagers; + return 0; =20 out: for (i =3D 0; i < nmanagers; i++) { @@ -963,8 +966,7 @@ pd692x0_register_manager_regulator(struct device *dev, = char *reg_name, =20 static int pd692x0_register_managers_regulator(struct pd692x0_priv *priv, - const struct pd692x0_manager *manager, - int nmanagers) + const struct pd692x0_manager *manager) { struct device *dev =3D &priv->client->dev; size_t reg_name_len; @@ -975,7 +977,7 @@ pd692x0_register_managers_regulator(struct pd692x0_priv= *priv, */ reg_name_len =3D strlen(dev_name(dev)) + 23; =20 - for (i =3D 0; i < nmanagers; i++) { + for (i =3D 0; i < priv->nmanagers; i++) { static const char * const regulators[] =3D { "vaux5", "vaux3p3" }; struct regulator_dev *rdev; char *reg_name; @@ -1008,10 +1010,14 @@ pd692x0_register_managers_regulator(struct pd692x0_= priv *priv, } =20 static int -pd692x0_conf_manager_power_budget(struct pd692x0_priv *priv, int id, int p= w) +pd692x0_conf_manager_power_budget(struct pd692x0_priv *priv, int id) { struct pd692x0_msg msg, buf; - int ret, pw_mW =3D pw / 1000; + int ret, pw_mW; + + pw_mW =3D priv->manager_pw_budget[id] / 1000; + if (!pw_mW) + return 0; =20 msg =3D pd692x0_msg_template_list[PD692X0_MSG_GET_POWER_BANK]; msg.data[0] =3D id; @@ -1032,11 +1038,11 @@ pd692x0_conf_manager_power_budget(struct pd692x0_pr= iv *priv, int id, int pw) } =20 static int -pd692x0_configure_managers(struct pd692x0_priv *priv, int nmanagers) +pd692x0_req_managers_pw_budget(struct pd692x0_priv *priv) { int i, ret; =20 - for (i =3D 0; i < nmanagers; i++) { + for (i =3D 0; i < priv->nmanagers; i++) { struct regulator *supply =3D priv->manager_reg[i]->supply; int pw_budget; =20 @@ -1053,7 +1059,18 @@ pd692x0_configure_managers(struct pd692x0_priv *priv= , int nmanagers) return ret; =20 priv->manager_pw_budget[i] =3D pw_budget; - ret =3D pd692x0_conf_manager_power_budget(priv, i, pw_budget); + } + + return 0; +} + +static int +pd692x0_configure_managers(struct pd692x0_priv *priv) +{ + int i, ret; + + for (i =3D 0; i < priv->nmanagers; i++) { + ret =3D pd692x0_conf_manager_power_budget(priv, i); if (ret < 0) return ret; } @@ -1101,10 +1118,9 @@ pd692x0_set_port_matrix(const struct pse_pi_pairset = *pairset, =20 static int pd692x0_set_ports_matrix(struct pd692x0_priv *priv, - const struct pd692x0_manager *manager, - int nmanagers, - struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]) + const struct pd692x0_manager *manager) { + struct pd692x0_matrix *port_matrix =3D priv->port_matrix; struct pse_controller_dev *pcdev =3D &priv->pcdev; int i, ret; =20 @@ -1117,7 +1133,7 @@ pd692x0_set_ports_matrix(struct pd692x0_priv *priv, /* Update with values for every PSE PIs */ for (i =3D 0; i < pcdev->nr_lines; i++) { ret =3D pd692x0_set_port_matrix(&pcdev->pi[i].pairset[0], - manager, nmanagers, + manager, priv->nmanagers, &port_matrix[i]); if (ret) { dev_err(&priv->client->dev, @@ -1126,7 +1142,7 @@ pd692x0_set_ports_matrix(struct pd692x0_priv *priv, } =20 ret =3D pd692x0_set_port_matrix(&pcdev->pi[i].pairset[1], - manager, nmanagers, + manager, priv->nmanagers, &port_matrix[i]); if (ret) { dev_err(&priv->client->dev, @@ -1139,9 +1155,9 @@ pd692x0_set_ports_matrix(struct pd692x0_priv *priv, } =20 static int -pd692x0_write_ports_matrix(struct pd692x0_priv *priv, - const struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]) +pd692x0_write_ports_matrix(struct pd692x0_priv *priv) { + struct pd692x0_matrix *port_matrix =3D priv->port_matrix; struct pd692x0_msg msg, buf; int ret, i; =20 @@ -1166,13 +1182,32 @@ pd692x0_write_ports_matrix(struct pd692x0_priv *pri= v, return 0; } =20 +static int pd692x0_hw_conf_init(struct pd692x0_priv *priv) +{ + int ret; + + /* Is PD692x0 ready to be configured? */ + if (priv->fw_state !=3D PD692X0_FW_OK && + priv->fw_state !=3D PD692X0_FW_COMPLETE) + return 0; + + ret =3D pd692x0_configure_managers(priv); + if (ret) + return ret; + + ret =3D pd692x0_write_ports_matrix(priv); + if (ret) + return ret; + + return 0; +} + static void pd692x0_of_put_managers(struct pd692x0_priv *priv, - struct pd692x0_manager *manager, - int nmanagers) + struct pd692x0_manager *manager) { int i, j; =20 - for (i =3D 0; i < nmanagers; i++) { + for (i =3D 0; i < priv->nmanagers; i++) { for (j =3D 0; j < manager[i].nports; j++) of_node_put(manager[i].port_node[j]); of_node_put(manager[i].node); @@ -1201,48 +1236,50 @@ static void pd692x0_managers_free_pw_budget(struct = pd692x0_priv *priv) static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) { struct pd692x0_priv *priv =3D to_pd692x0_priv(pcdev); - struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]; + struct pd692x0_matrix *port_matrix; struct pd692x0_manager *manager; - int ret, nmanagers; - - /* Should we flash the port matrix */ - if (priv->fw_state !=3D PD692X0_FW_OK && - priv->fw_state !=3D PD692X0_FW_COMPLETE) - return 0; + int ret; =20 manager =3D kcalloc(PD692X0_MAX_MANAGERS, sizeof(*manager), GFP_KERNEL); if (!manager) return -ENOMEM; =20 + port_matrix =3D devm_kcalloc(&priv->client->dev, PD692X0_MAX_PIS, + sizeof(*port_matrix), GFP_KERNEL); + if (!port_matrix) { + ret =3D -ENOMEM; + goto err_free_manager; + } + priv->port_matrix =3D port_matrix; + ret =3D pd692x0_of_get_managers(priv, manager); if (ret < 0) goto err_free_manager; =20 - nmanagers =3D ret; - ret =3D pd692x0_register_managers_regulator(priv, manager, nmanagers); + ret =3D pd692x0_register_managers_regulator(priv, manager); if (ret) goto err_of_managers; =20 - ret =3D pd692x0_configure_managers(priv, nmanagers); + ret =3D pd692x0_req_managers_pw_budget(priv); if (ret) goto err_of_managers; =20 - ret =3D pd692x0_set_ports_matrix(priv, manager, nmanagers, port_matrix); + ret =3D pd692x0_set_ports_matrix(priv, manager); if (ret) goto err_managers_req_pw; =20 - ret =3D pd692x0_write_ports_matrix(priv, port_matrix); + ret =3D pd692x0_hw_conf_init(priv); if (ret) goto err_managers_req_pw; =20 - pd692x0_of_put_managers(priv, manager, nmanagers); + pd692x0_of_put_managers(priv, manager); kfree(manager); return 0; =20 err_managers_req_pw: pd692x0_managers_free_pw_budget(priv); err_of_managers: - pd692x0_of_put_managers(priv, manager, nmanagers); + pd692x0_of_put_managers(priv, manager); err_free_manager: kfree(manager); return ret; @@ -1647,7 +1684,7 @@ static enum fw_upload_err pd692x0_fw_poll_complete(st= ruct fw_upload *fwl) return FW_UPLOAD_ERR_FW_INVALID; } =20 - ret =3D pd692x0_setup_pi_matrix(&priv->pcdev); + ret =3D pd692x0_hw_conf_init(priv); if (ret < 0) { dev_err(&client->dev, "Error configuring ports matrix (%pe)\n", ERR_PTR(ret)); --=20 2.43.0 From nobody Thu Oct 2 14:27:44 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 EDB6B26E71B for ; Mon, 15 Sep 2025 17:07:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956036; cv=none; b=umCw4lf/PJFA90TYtt2k85Ssh7hm3vgcgHTePBdnL7Vl9xd3fxR/Rh9TakZC8GQbU5DU50rB2bnU/6z3QUy1+ODYaUcZPMyL7/zcdFkObFWbJow/FL3xu2wf85Tg60nrr/1a1uUdrewHhsqxEXC7LmAQhCclr4zcpBxUtahRUYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956036; c=relaxed/simple; bh=1fC6qPHhw0+ReUKx7i0sZJqlysF67p/4YIgETaU4kAA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V7eNyaWujZHU3cGFU8cmDt6jocsiTEDJDA+v9ayGTb1NdF103tcNiJ070ajHx9uOn8tVaqLgJOad6nZF7MLvf6OIeTL+nCNeAAUCxo8VYJK/ovt6yMxfq4egM2ScEoa9GMBBJnpMG60k6eauY8hQajHPmxSHcNtAK6tm7HgCaEk= 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=0RBnXz3y; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="0RBnXz3y" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id D8476C8F450; Mon, 15 Sep 2025 17:06:56 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 30E336063F; Mon, 15 Sep 2025 17:07:13 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id F0C3D102F2AEE; Mon, 15 Sep 2025 19:07:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757956031; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=7Z/vVaiwPDqUIpffCxIZ4JsTPL7u+izJHcekcnCQ+bw=; b=0RBnXz3yzSj4Wd59ElaLcVjrbrd4sqPuOgxh6gPpKNjxNPi9sDXJVmfN+As+7qCfMr5yTu Ttz/nCe8z7rRmvqZVjFKpEA2NAqw/kpJfOXJybZ4y22IYxmp+mJvz6Y6cmJZG9fmgoTHl2 Lzc9LA7LPi7trV3K3KWIXlUZZ97fbbX1zMU4Sh6kADsImquztNa5dpePXL+Jv5FzirSs8t CO+VhHAOcaoaqAhBPayQELonWrzyf8xjsIENWKM1U59OSdi9J95URpFo8/1jM25mrQDZyH BmK19/1MDDieKjYPgX/Vs+240gpTrxvwaE0ncDRAufCJ0YM0z97bbd9/myvLPg== From: Kory Maincent Date: Mon, 15 Sep 2025 19:06:28 +0200 Subject: [PATCH net-next v3 3/5] docs: devlink: Sort table of contents alphabetically 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: quoted-printable Message-Id: <20250915-feature_poe_permanent_conf-v3-3-78871151088b@bootlin.com> References: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> In-Reply-To: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> To: Oleksij Rempel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Jonathan Corbet , Donald Hunter Cc: kernel@pengutronix.de, Dent Project , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Chevallier , linux-doc@vger.kernel.org, Kyle Swenson , "Kory Maincent (Dent Project)" X-Mailer: b4 0.15-dev-8cb71 X-Last-TLS-Session-Version: TLSv1.3 From: Kory Maincent (Dent Project) Sort devlink documentation table of contents alphabetically to improve readability and make it easier to locate specific chapters. Signed-off-by: Kory Maincent --- Changes in v2: - New patch --- Documentation/networking/devlink/index.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/networking/devlink/index.rst b/Documentation/net= working/devlink/index.rst index 270a65a014111..0c58e5c729d92 100644 --- a/Documentation/networking/devlink/index.rst +++ b/Documentation/networking/devlink/index.rst @@ -56,18 +56,18 @@ general. :maxdepth: 1 =20 devlink-dpipe + devlink-eswitch-attr + devlink-flash devlink-health devlink-info - devlink-flash + devlink-linecard devlink-params devlink-port devlink-region - devlink-resource devlink-reload + devlink-resource devlink-selftests devlink-trap - devlink-linecard - devlink-eswitch-attr =20 Driver-specific documentation ----------------------------- @@ -78,12 +78,14 @@ parameters, info versions, and other features it suppor= ts. .. toctree:: :maxdepth: 1 =20 + am65-nuss-cpsw-switch bnxt etas_es58x hns3 i40e - ionic ice + ionic + iosm ixgbe kvaser_pciefd kvaser_usb @@ -93,11 +95,9 @@ parameters, info versions, and other features it support= s. mv88e6xxx netdevsim nfp - qed - ti-cpsw-switch - am65-nuss-cpsw-switch - prestera - iosm octeontx2 + prestera + qed sfc + ti-cpsw-switch zl3073x --=20 2.43.0 From nobody Thu Oct 2 14:27:44 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 36AFA28504D; Mon, 15 Sep 2025 17:07:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956039; cv=none; b=UH/eDUDvGx6jf+1vPxxoyt+gFPyqWBrMssBpwzM9qUyqBU35U6dWlpuYIYt2sivDDX1e3dTZPqHJxRyxz4e7J1e/6zXwGCnhnNUjH/BcGLd9ueICDb42tmNjjxN1BZEgS9YFyp5AxnXnYi1lkuNmyKzwANf5/a4RB2jXZ/MdTWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956039; c=relaxed/simple; bh=ZllPKJmOopZErDj9wtEyccp3PlVYrDDwwQXK/gNCSi4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hUq1fpsgGWX3dFYSYXZSxL//9/oo5hg5wkANsHo6olsB1SIIxzAiCnUPghdHSSikDhzxmqn2xYXKeVrm1wULkfccZJdS0krk3sZfcIXzxxJXRedw+PEVSCzThHdunJLR+SLTtK2DQwteroao732ELHsXW4UYUxBniyIQm9thLc4= 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=WKArIyPr; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WKArIyPr" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id B829D1A0E24; Mon, 15 Sep 2025 17:07:15 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8CC746063F; Mon, 15 Sep 2025 17:07:15 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4602C102F2AC9; Mon, 15 Sep 2025 19:07:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757956034; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=RbT/67VUQWDst0vtW16bTCia0o5hBTJsAvPw7EYhrNw=; b=WKArIyPrnEL/6eOJ7OzalcsLwDkElpUnzQUA/BXwjOhFvqZ/KQLPUyAFOtH0w7bKXODJ7i +93/I3zaRqm82kb9JkH3oueRitExCvBzNxMZy2i6U1dMUGGK+oG6gJAa5Y7NAKHQSShsEx /S8FHISNWLDbE4BFilC2plraSSG3OrNCnzmWIRFOgI+8i4ulJfdor3VQr0/ie7BLnGHZbA LkdxB9rXl8DH1dacBQXIMlikhEeq8+Jp/Hne5oa4GVNmUY+Y6Niipeo+e12kWiMBTC6OxU ulTLrwUBp+0GHbuX1415tZrd0zEQVHzJ+Mszs3qLTGq39LV/QgAl3oBWnhUlfw== From: Kory Maincent Date: Mon, 15 Sep 2025 19:06:29 +0200 Subject: [PATCH net-next v3 4/5] devlink: Add devlink-conf uAPI for NV memory management 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: quoted-printable Message-Id: <20250915-feature_poe_permanent_conf-v3-4-78871151088b@bootlin.com> References: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> In-Reply-To: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> To: Oleksij Rempel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Jonathan Corbet , Donald Hunter Cc: kernel@pengutronix.de, Dent Project , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Chevallier , linux-doc@vger.kernel.org, Kyle Swenson , "Kory Maincent (Dent Project)" X-Mailer: b4 0.15-dev-8cb71 X-Last-TLS-Session-Version: TLSv1.3 From: Kory Maincent (Dent Project) Introduce a new devlink-conf uAPI to manage device configuration stored in non-volatile memory. This provides a standardized interface for devices that need to persist configuration changes across reboots. Add two new devlink operations: - conf_save: Save current configuration to non-volatile memory - conf_reset: Reset configuration in non-volatile memory to factory defaults The uAPI is designed to be generic and can be used by any device driver that manages persistent configuration storage. Signed-off-by: Kory Maincent --- After two NAKs on sysfs and devlink-param design choices due to uAPI not being appropriate, I moved to this new design approach. Also, the choice of saving the configuration to NVM on every config change seemed inappropriate as the save and the reset processes would be in two different Kernel framework. The new design intend to extend devlink uAPI with a devlink-conf interface. This uAPI is designed to be generic. While currently only one driver implements it, controllers that manage non-volatile memory to save configuration are not uncommon. Change in v3: - New patch. --- Documentation/netlink/specs/devlink.yaml | 23 +++++++++++++++++ Documentation/networking/devlink/devlink-conf.rst | 22 ++++++++++++++++ Documentation/networking/devlink/index.rst | 1 + MAINTAINERS | 2 ++ include/net/devlink.h | 20 +++++++++++++++ include/uapi/linux/devlink.h | 4 +++ net/devlink/Makefile | 3 ++- net/devlink/conf.c | 31 +++++++++++++++++++= ++++ net/devlink/netlink.c | 2 +- net/devlink/netlink_gen.c | 20 ++++++++++++++- net/devlink/netlink_gen.h | 3 ++- 11 files changed, 127 insertions(+), 4 deletions(-) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netli= nk/specs/devlink.yaml index 3db59c9658694..27db92457e886 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -857,6 +857,14 @@ attribute-sets: name: health-reporter-burst-period type: u64 doc: Time (in msec) for recoveries before starting the grace perio= d. + - + name: conf-save + type: flag + doc: Save device configuration to non-volatile memory. + - + name: conf-reset + type: flag + doc: Reset device configuration located in non-volatile memory. - name: dl-dev-stats subset-of: devlink @@ -2325,3 +2333,18 @@ operations: - bus-name - dev-name - port-index + - + name: conf-set + doc: Manage device configuration. + attribute-set: devlink + dont-validate: [strict] + flags: [admin-perm] + do: + pre: devlink-nl-pre-doit + post: devlink-nl-post-doit + request: + attributes: + - bus-name + - dev-name + - conf-save + - conf-reset diff --git a/Documentation/networking/devlink/devlink-conf.rst b/Documentat= ion/networking/devlink/devlink-conf.rst new file mode 100644 index 0000000000000..34f866f2f9594 --- /dev/null +++ b/Documentation/networking/devlink/devlink-conf.rst @@ -0,0 +1,22 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Devlink Conf +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The ``devlink-conf`` API allows saving the device configuration as +permanent writing it to a non-volatile memory. + +Drivers are expected to implement ``devlink-conf`` functionality through +``conf_save`` and ``conf_reset`` devlink operations. + +example usage +------------- + +.. code:: shell + + $ devlink dev conf help + $ devlink dev conf DEV [ save | reset ] + + # Run conf command for saving configuration to non-volatile memory: + $ devlink dev conf i2c/1-003c save diff --git a/Documentation/networking/devlink/index.rst b/Documentation/net= working/devlink/index.rst index 0c58e5c729d92..ba381ecadc3dc 100644 --- a/Documentation/networking/devlink/index.rst +++ b/Documentation/networking/devlink/index.rst @@ -56,6 +56,7 @@ general. :maxdepth: 1 =20 devlink-dpipe + devlink-conf devlink-eswitch-attr devlink-flash devlink-health diff --git a/MAINTAINERS b/MAINTAINERS index b81595e9ea955..429303a9447f3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20299,7 +20299,9 @@ M: Kory Maincent L: netdev@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/net/pse-pd/ +F: Documentation/networking/devlink/devlink-conf.rst F: drivers/net/pse-pd/ +F: net/devlink/conf.c F: net/ethtool/pse-pd.c =20 PSTORE FILESYSTEM diff --git a/include/net/devlink.h b/include/net/devlink.h index 5f44e702c25ca..04256d1973417 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1551,6 +1551,26 @@ struct devlink_ops { enum devlink_selftest_status (*selftest_run)(struct devlink *devlink, unsigned int id, struct netlink_ext_ack *extack); + + /** + * conf_save - Save configuration to non-volatile memory + * @devlink: Devlink instance + * @extack: extack for reporting error messages + * + * Return: 0 on success, negative value otherwise. + */ + int (*conf_save)(struct devlink *devlink, + struct netlink_ext_ack *extack); + + /** + * conf_reset - Reset configuration located in non-volatile memory + * @devlink: Devlink instance + * @extack: extack for reporting error messages + * + * Return: 0 on success, negative value otherwise. + */ + int (*conf_reset)(struct devlink *devlink, + struct netlink_ext_ack *extack); }; =20 void *devlink_priv(struct devlink *devlink); diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index bcad11a787a55..ce9192e772d93 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -141,6 +141,8 @@ enum devlink_command { =20 DEVLINK_CMD_NOTIFY_FILTER_SET, =20 + DEVLINK_CMD_CONF_SET, + /* add new commands above here */ __DEVLINK_CMD_MAX, DEVLINK_CMD_MAX =3D __DEVLINK_CMD_MAX - 1 @@ -638,6 +640,8 @@ enum devlink_attr { =20 DEVLINK_ATTR_HEALTH_REPORTER_BURST_PERIOD, /* u64 */ =20 + DEVLINK_ATTR_CONF_SAVE, /* u8 */ + DEVLINK_ATTR_CONF_RESET, /* u8 */ /* Add new attributes above here, update the spec in * Documentation/netlink/specs/devlink.yaml and re-generate * net/devlink/netlink_gen.c. diff --git a/net/devlink/Makefile b/net/devlink/Makefile index 000da622116a3..e4ff40fc65ef2 100644 --- a/net/devlink/Makefile +++ b/net/devlink/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 =20 obj-y :=3D core.o netlink.o netlink_gen.o dev.o port.o sb.o dpipe.o \ - resource.o param.o region.o health.o trap.o rate.o linecard.o + resource.o param.o region.o health.o trap.o rate.o linecard.o \ + conf.o diff --git a/net/devlink/conf.c b/net/devlink/conf.c new file mode 100644 index 0000000000000..09cec798d5e48 --- /dev/null +++ b/net/devlink/conf.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2025 Bootlin, Kory Maincent + */ + +#include "devl_internal.h" + +int devlink_nl_conf_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct devlink *devlink =3D info->user_ptr[0]; + struct nlattr **tb =3D info->attrs; + const struct devlink_ops *ops; + + ops =3D devlink->ops; + if (!ops->conf_save || !ops->conf_reset) + return -EOPNOTSUPP; + + if (tb[DEVLINK_ATTR_CONF_SAVE] && tb[DEVLINK_ATTR_CONF_RESET]) { + NL_SET_ERR_MSG_MOD(info->extack, + "Can't save and reset the configuration simultaneously"); + return -EINVAL; + } + + if (tb[DEVLINK_ATTR_CONF_SAVE]) + return ops->conf_save(devlink, info->extack); + + if (tb[DEVLINK_ATTR_CONF_RESET]) + return ops->conf_reset(devlink, info->extack); + + return 0; +} diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index 593605c1b1ef4..e22f5bfaba931 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -367,7 +367,7 @@ struct genl_family devlink_nl_family __ro_after_init = =3D { .module =3D THIS_MODULE, .split_ops =3D devlink_nl_ops, .n_split_ops =3D ARRAY_SIZE(devlink_nl_ops), - .resv_start_op =3D DEVLINK_CMD_SELFTESTS_RUN + 1, + .resv_start_op =3D DEVLINK_CMD_MAX + 1, .mcgrps =3D devlink_nl_mcgrps, .n_mcgrps =3D ARRAY_SIZE(devlink_nl_mcgrps), .sock_priv_size =3D sizeof(struct devlink_nl_sock_priv), diff --git a/net/devlink/netlink_gen.c b/net/devlink/netlink_gen.c index 9fd00977d59e3..51a1f55c7063d 100644 --- a/net/devlink/netlink_gen.c +++ b/net/devlink/netlink_gen.c @@ -602,8 +602,16 @@ static const struct nla_policy devlink_notify_filter_s= et_nl_policy[DEVLINK_ATTR_ [DEVLINK_ATTR_PORT_INDEX] =3D { .type =3D NLA_U32, }, }; =20 +/* DEVLINK_CMD_CONF_SET - do */ +static const struct nla_policy devlink_conf_set_nl_policy[DEVLINK_ATTR_CON= F_RESET + 1] =3D { + [DEVLINK_ATTR_BUS_NAME] =3D { .type =3D NLA_NUL_STRING, }, + [DEVLINK_ATTR_DEV_NAME] =3D { .type =3D NLA_NUL_STRING, }, + [DEVLINK_ATTR_CONF_SAVE] =3D { .type =3D NLA_FLAG, }, + [DEVLINK_ATTR_CONF_RESET] =3D { .type =3D NLA_FLAG, }, +}; + /* Ops table for devlink */ -const struct genl_split_ops devlink_nl_ops[74] =3D { +const struct genl_split_ops devlink_nl_ops[75] =3D { { .cmd =3D DEVLINK_CMD_GET, .validate =3D GENL_DONT_VALIDATE_STRICT, @@ -1282,4 +1290,14 @@ const struct genl_split_ops devlink_nl_ops[74] =3D { .maxattr =3D DEVLINK_ATTR_PORT_INDEX, .flags =3D GENL_CMD_CAP_DO, }, + { + .cmd =3D DEVLINK_CMD_CONF_SET, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .pre_doit =3D devlink_nl_pre_doit, + .doit =3D devlink_nl_conf_set_doit, + .post_doit =3D devlink_nl_post_doit, + .policy =3D devlink_conf_set_nl_policy, + .maxattr =3D DEVLINK_ATTR_CONF_RESET, + .flags =3D GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, }; diff --git a/net/devlink/netlink_gen.h b/net/devlink/netlink_gen.h index 09cc6f264ccfa..9e99528bd36c7 100644 --- a/net/devlink/netlink_gen.h +++ b/net/devlink/netlink_gen.h @@ -17,7 +17,7 @@ extern const struct nla_policy devlink_dl_rate_tc_bws_nl_= policy[DEVLINK_RATE_TC_ extern const struct nla_policy devlink_dl_selftest_id_nl_policy[DEVLINK_AT= TR_SELFTEST_ID_FLASH + 1]; =20 /* Ops table for devlink */ -extern const struct genl_split_ops devlink_nl_ops[74]; +extern const struct genl_split_ops devlink_nl_ops[75]; =20 int devlink_nl_pre_doit(const struct genl_split_ops *ops, struct sk_buff *= skb, struct genl_info *info); @@ -145,5 +145,6 @@ int devlink_nl_selftests_get_dumpit(struct sk_buff *skb, int devlink_nl_selftests_run_doit(struct sk_buff *skb, struct genl_info *i= nfo); int devlink_nl_notify_filter_set_doit(struct sk_buff *skb, struct genl_info *info); +int devlink_nl_conf_set_doit(struct sk_buff *skb, struct genl_info *info); =20 #endif /* _LINUX_DEVLINK_GEN_H */ --=20 2.43.0 From nobody Thu Oct 2 14:27:44 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 6CCA4261B91; Mon, 15 Sep 2025 17:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956041; cv=none; b=imTkhgZ0yNyuXulqYZ4ydRWbqYCxpLOrTKBn3+Z9zhOV4dAHHLiPySS31fj7IYkCUGkK8rq4L0QAyoQGbqbHBYob0f12zLFJ1tv1Xvy7GIBAtfx6Zql1O2Fpex6knZwhJb5VEG0yGRKWQPMlB6qrdOpbvwAEpM+fAP2WP43mTWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956041; c=relaxed/simple; bh=qeilsRwEs9JHRw0hX35gdC10jXev2u0uQOZPOb523R4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qI2wL8WXgiw6hJFraoYGHd8GZy2dmLNPWtSo5ndYPj3ZjzXDCUJZJRTMMff4WA5iPWyHzvN0AgfkWfIjawkgDoH+C4OiK9tf2ZDSscZQY6Mdik6VCmPRHo0DB7Jr9IA05xduKdobatyt2/+nck8fRR1VAjiWqqKWGuP9PZIuzLs= 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=ZPA5f6y/; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZPA5f6y/" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8FEEA1A09DD; Mon, 15 Sep 2025 17:07:17 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 65D846063F; Mon, 15 Sep 2025 17:07:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 888B1102F2B16; Mon, 15 Sep 2025 19:07:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757956036; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=HeSRne8hf27jj3oT7aSQnAmbULkaO0oyiQdL/Xcz6pM=; b=ZPA5f6y/wzeqN5lzuTsmgHwpkehQ90DXybdmcaKg5wqqIfOlJRdtPyakGdPAXOvy+5B3CN JxIpgH/Br4gEKHyqkoXhboxFViHE+GHcnfi5E4hJ+X8CWH5INQDXYSlZaI5kTaBJoI/fRY 7fyABa0nGHBDQP+aS+ECFNe/taYx5WHpMUQ7b4mRCd9lNIAjFZZFj/pSMZhwdA8XCK8t93 VKyrYOKjawdx+cC9LM14vu55sEf+HWlBXVQsUzIFkNb89e0bBBaM2D42eeBNQ2ZnbaN8z6 aW0l1kcaK0DdKog8R5IoOahwpa7Z1PwSESgsLH6+W5wg8TjQv2Pygai0gQjNXg== From: Kory Maincent Date: Mon, 15 Sep 2025 19:06:30 +0200 Subject: [PATCH net-next v3 5/5] net: pse-pd: pd692x0: Add devlink interface for configuration save/reset 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: quoted-printable Message-Id: <20250915-feature_poe_permanent_conf-v3-5-78871151088b@bootlin.com> References: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> In-Reply-To: <20250915-feature_poe_permanent_conf-v3-0-78871151088b@bootlin.com> To: Oleksij Rempel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Jonathan Corbet , Donald Hunter Cc: kernel@pengutronix.de, Dent Project , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Chevallier , linux-doc@vger.kernel.org, Kyle Swenson , "Kory Maincent (Dent Project)" X-Mailer: b4 0.15-dev-8cb71 X-Last-TLS-Session-Version: TLSv1.3 From: Kory Maincent (Dent Project) Add devlink conf_save and conf_reset ops to enable userspace management of the PSE's permanent configuration stored in non-volatile memory. The save_conf allows saving the current configuration to non-volatile memory. The reset_conf attribute restores factory defaults configurations. Skip hardware configuration initialization on probe when a saved configuration is already present in non-volatile memory (detected via user byte set to 42). Signed-off-by: Kory Maincent --- Changes in v2: - Move on from sysfs to devlink param for userspace management. Changes in v3: - Move on from devlink param to new devlink conf uAPI. --- Documentation/networking/devlink/index.rst | 1 + Documentation/networking/devlink/pd692x0.rst | 24 ++++ MAINTAINERS | 1 + drivers/net/pse-pd/pd692x0.c | 160 +++++++++++++++++++++++= +++- 4 files changed, 183 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/devlink/index.rst b/Documentation/net= working/devlink/index.rst index ba381ecadc3dc..336b4cc00bd14 100644 --- a/Documentation/networking/devlink/index.rst +++ b/Documentation/networking/devlink/index.rst @@ -97,6 +97,7 @@ parameters, info versions, and other features it supports. netdevsim nfp octeontx2 + pd692x0 prestera qed sfc diff --git a/Documentation/networking/devlink/pd692x0.rst b/Documentation/n= etworking/devlink/pd692x0.rst new file mode 100644 index 0000000000000..d7166f6f3ba91 --- /dev/null +++ b/Documentation/networking/devlink/pd692x0.rst @@ -0,0 +1,24 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D +PSE PD692x0 devlink support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D + +This document describes the devlink features implemented by the PSE +``PD692x0`` device drivers. + +Operations +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The ``PD692x0`` drivers implement the following devlink operations. + +.. list-table:: Devlink ops implemented + :widths: 5 85 + + * - Name + - Description + * - ``conf_save`` + - Save the current configuration to non-volatile memory. + * - ``conf_reset`` + - Reset the current and saved configuration located the non-volatile + memory. diff --git a/MAINTAINERS b/MAINTAINERS index 429303a9447f3..cc6f7a8986b04 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20300,6 +20300,7 @@ L: netdev@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/net/pse-pd/ F: Documentation/networking/devlink/devlink-conf.rst +F: Documentation/networking/devlink/pd692x0.rst F: drivers/net/pse-pd/ F: net/devlink/conf.c F: net/ethtool/pse-pd.c diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c index 782b1abf94cb1..97f9c0648fdb6 100644 --- a/drivers/net/pse-pd/pd692x0.c +++ b/drivers/net/pse-pd/pd692x0.c @@ -14,6 +14,7 @@ #include #include #include +#include =20 #define PD692X0_PSE_NAME "pd692x0_pse" =20 @@ -30,6 +31,8 @@ #define PD692X0_FW_MIN_VER 5 #define PD692X0_FW_PATCH_VER 5 =20 +#define PD692X0_USER_BYTE 42 + enum pd692x0_fw_state { PD692X0_FW_UNKNOWN, PD692X0_FW_OK, @@ -80,6 +83,9 @@ enum { PD692X0_MSG_GET_PORT_PARAM, PD692X0_MSG_GET_POWER_BANK, PD692X0_MSG_SET_POWER_BANK, + PD692X0_MSG_SET_USER_BYTE, + PD692X0_MSG_SAVE_SYS_SETTINGS, + PD692X0_MSG_RESTORE_FACTORY, =20 /* add new message above here */ PD692X0_MSG_CNT @@ -103,11 +109,13 @@ struct pd692x0_priv { bool last_cmd_key; unsigned long last_cmd_key_time; =20 + bool cfg_saved; enum ethtool_c33_pse_admin_state admin_state[PD692X0_MAX_PIS]; struct regulator_dev *manager_reg[PD692X0_MAX_MANAGERS]; int manager_pw_budget[PD692X0_MAX_MANAGERS]; int nmanagers; struct pd692x0_matrix *port_matrix; + struct devlink *dl; }; =20 /* Template list of communication messages. The non-null bytes defined here @@ -193,6 +201,24 @@ static const struct pd692x0_msg pd692x0_msg_template_l= ist[PD692X0_MSG_CNT] =3D { .key =3D PD692X0_KEY_CMD, .sub =3D {0x07, 0x0b, 0x57}, }, + [PD692X0_MSG_SET_USER_BYTE] =3D { + .key =3D PD692X0_KEY_PRG, + .sub =3D {0x41, PD692X0_USER_BYTE}, + .data =3D {0x4e, 0x4e, 0x4e, 0x4e, + 0x4e, 0x4e, 0x4e, 0x4e}, + }, + [PD692X0_MSG_SAVE_SYS_SETTINGS] =3D { + .key =3D PD692X0_KEY_PRG, + .sub =3D {0x06, 0x0f}, + .data =3D {0x4e, 0x4e, 0x4e, 0x4e, + 0x4e, 0x4e, 0x4e, 0x4e}, + }, + [PD692X0_MSG_RESTORE_FACTORY] =3D { + .key =3D PD692X0_KEY_PRG, + .sub =3D {0x2d, 0x4e}, + .data =3D {0x4e, 0x4e, 0x4e, 0x4e, + 0x4e, 0x4e, 0x4e, 0x4e}, + }, }; =20 static u8 pd692x0_build_msg(struct pd692x0_msg *msg, u8 echo) @@ -1268,9 +1294,12 @@ static int pd692x0_setup_pi_matrix(struct pse_contro= ller_dev *pcdev) if (ret) goto err_managers_req_pw; =20 - ret =3D pd692x0_hw_conf_init(priv); - if (ret) - goto err_managers_req_pw; + /* Do not init the conf if it is already saved */ + if (!priv->cfg_saved) { + ret =3D pd692x0_hw_conf_init(priv); + if (ret) + goto err_managers_req_pw; + } =20 pd692x0_of_put_managers(priv, manager); kfree(manager); @@ -1727,14 +1756,118 @@ static const struct fw_upload_ops pd692x0_fw_ops = =3D { .cleanup =3D pd692x0_fw_cleanup, }; =20 +/* Devlink Params APIs */ +enum pd692x0_devlink_param_id { + PD692X0_DEVLINK_PARAM_ID_BASE =3D DEVLINK_PARAM_GENERIC_ID_MAX, + PD692X0_DEVLINK_PARAM_ID_SAVE_CONF, + PD692X0_DEVLINK_PARAM_ID_RESET_CONF, +}; + +struct pd692x0_devlink { + struct pd692x0_priv *priv; +}; + +static int pd692x0_dl_conf_save(struct devlink *devlink, + struct netlink_ext_ack *extack) +{ + struct pd692x0_devlink *dl =3D devlink_priv(devlink); + struct pd692x0_priv *priv =3D dl->priv; + struct pd692x0_msg msg, buf =3D {0}; + int ret; + + mutex_lock(&priv->pcdev.lock); + ret =3D pd692x0_fw_unavailable(priv); + if (ret) + goto out; + + msg =3D pd692x0_msg_template_list[PD692X0_MSG_SET_USER_BYTE]; + ret =3D pd692x0_sendrecv_msg(priv, &msg, &buf); + if (ret) + goto out; + + msg =3D pd692x0_msg_template_list[PD692X0_MSG_SAVE_SYS_SETTINGS]; + ret =3D pd692x0_send_msg(priv, &msg); + if (ret) { + dev_err(&priv->client->dev, + "Failed to save the configuration (%pe)\n", + ERR_PTR(ret)); + goto out; + } + + msleep(50); /* Sleep 50ms as described in the datasheet */ + + ret =3D i2c_master_recv(priv->client, (u8 *)&buf, sizeof(buf)); + if (ret !=3D sizeof(buf)) { + if (ret >=3D 0) + ret =3D -EIO; + goto out; + } + + ret =3D 0; + +out: + mutex_unlock(&priv->pcdev.lock); + return ret; +} + +static int pd692x0_dl_conf_reset(struct devlink *devlink, + struct netlink_ext_ack *extack) +{ + struct pd692x0_devlink *dl =3D devlink_priv(devlink); + struct pd692x0_priv *priv =3D dl->priv; + struct pd692x0_msg msg, buf =3D {0}; + int ret; + + mutex_lock(&priv->pcdev.lock); + ret =3D pd692x0_fw_unavailable(priv); + if (ret) + goto out; + + msg =3D pd692x0_msg_template_list[PD692X0_MSG_RESTORE_FACTORY]; + ret =3D pd692x0_send_msg(priv, &msg); + if (ret) { + dev_err(&priv->client->dev, + "Failed to reset the configuration (%pe)\n", + ERR_PTR(ret)); + goto out; + } + + msleep(100); /* Sleep 100ms as described in the datasheet */ + + ret =3D i2c_master_recv(priv->client, (u8 *)&buf, sizeof(buf)); + if (ret !=3D sizeof(buf)) { + if (ret >=3D 0) + ret =3D -EIO; + goto out; + } + + ret =3D pd692x0_hw_conf_init(priv); + if (ret) { + dev_err(&priv->client->dev, + "Error configuring ports matrix (%pe)\n", + ERR_PTR(ret)); + } + +out: + mutex_unlock(&priv->pcdev.lock); + return ret; +} + +static const struct devlink_ops pd692x0_dl_ops =3D { + .conf_save =3D pd692x0_dl_conf_save, + .conf_reset =3D pd692x0_dl_conf_reset, +}; + static int pd692x0_i2c_probe(struct i2c_client *client) { static const char * const regulators[] =3D { "vdd", "vdda" }; struct pd692x0_msg msg, buf =3D {0}, zero =3D {0}; + struct pd692x0_devlink *pd692x0_dl; struct device *dev =3D &client->dev; struct pd692x0_msg_ver ver; struct pd692x0_priv *priv; struct fw_upload *fwl; + struct devlink *dl; int ret; =20 ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), @@ -1793,6 +1926,9 @@ static int pd692x0_i2c_probe(struct i2c_client *clien= t) } } =20 + if (buf.data[2] =3D=3D PD692X0_USER_BYTE) + priv->cfg_saved =3D true; + priv->np =3D dev->of_node; priv->pcdev.nr_lines =3D PD692X0_MAX_PIS; priv->pcdev.owner =3D THIS_MODULE; @@ -1813,7 +1949,24 @@ static int pd692x0_i2c_probe(struct i2c_client *clie= nt) "failed to register to the Firmware Upload API\n"); priv->fwl =3D fwl; =20 + dl =3D devlink_alloc(&pd692x0_dl_ops, sizeof(*pd692x0_dl), dev); + if (!dl) { + dev_err(dev, "devlink_alloc failed\n"); + ret =3D -ENOMEM; + goto err_unregister_fw; + } + + pd692x0_dl =3D devlink_priv(dl); + pd692x0_dl->priv =3D priv; + priv->dl =3D dl; + devlink_register(dl); + return 0; + +err_unregister_fw: + firmware_upload_unregister(priv->fwl); + + return ret; } =20 static void pd692x0_i2c_remove(struct i2c_client *client) @@ -1821,6 +1974,7 @@ static void pd692x0_i2c_remove(struct i2c_client *cli= ent) struct pd692x0_priv *priv =3D i2c_get_clientdata(client); =20 pd692x0_managers_free_pw_budget(priv); + devlink_unregister(priv->dl); firmware_upload_unregister(priv->fwl); } =20 --=20 2.43.0