From: Erni Sri Satya Vennela <ernis@linux.microsoft.com>
To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
longli@microsoft.com, kotaranov@microsoft.com, horms@kernel.org,
brett.creeley@amd.com, ernis@linux.microsoft.com,
surenb@google.com, schakrabarti@linux.microsoft.com,
kent.overstreet@linux.dev, shradhagupta@linux.microsoft.com,
erick.archer@outlook.com, rosenp@gmail.com,
linux-hyperv@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [PATCH 2/3] net: mana: Implement set_link_ksettings in ethtool for speed
Date: Thu, 20 Mar 2025 05:22:20 -0700 [thread overview]
Message-ID: <1742473341-15262-3-git-send-email-ernis@linux.microsoft.com> (raw)
In-Reply-To: <1742473341-15262-1-git-send-email-ernis@linux.microsoft.com>
Add support for ethtool_set_link_ksettings for mana.
Set speed information of the port using ethtool. This
feature is not supported by all hardware.
Before the change:
$ethtool -s enP30832s1 speed 100
>netlink error: Operation not supported
$ethtool enP30832s1
>Settings for enP30832s1:
Supported ports: [ ]
Supported link modes: Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: Unknown!
Duplex: Full
Auto-negotiation: off
Port: Other
PHYAD: 0
Transceiver: internal
Link detected: yes
After the change:
$ethtool -s enP30832s1 speed 100
$ethtool enP30832s1
>Settings for enP30832s1:
Supported ports: [ ]
Supported link modes: Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 100Mb/s
Duplex: Full
Auto-negotiation: off
Port: Other
PHYAD: 0
Transceiver: internal
Link detected: yes
Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 39 +++++++++++++++++++
.../ethernet/microsoft/mana/mana_ethtool.c | 13 +++++++
include/net/mana/mana.h | 16 ++++++++
3 files changed, 68 insertions(+)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 5fa8e1e2ff9a..bcc273427423 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -1203,6 +1203,45 @@ int mana_query_link_cfg(struct mana_port_context *apc)
return err;
}
+int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed)
+{
+ struct mana_set_bw_clamp_req req = {};
+ struct mana_set_bw_clamp_resp resp = {};
+ struct net_device *ndev = apc->ndev;
+ int err;
+
+ mana_gd_init_req_hdr(&req.hdr, MANA_SET_BW_CLAMP,
+ sizeof(req), sizeof(resp));
+ req.vport = apc->port_handle;
+ req.link_speed = speed;
+ req.enable_clamping = TRI_STATE_TRUE;
+
+ err = mana_send_request(apc->ac, &req, sizeof(req), &resp,
+ sizeof(resp));
+
+ if (err) {
+ netdev_err(ndev, "Failed to set bandwidth clamp for speed %u, err = %d",
+ speed, err);
+ return err;
+ }
+
+ err = mana_verify_resp_hdr(&resp.hdr, MANA_SET_BW_CLAMP,
+ sizeof(resp));
+
+ if (err || resp.hdr.status) {
+ netdev_err(ndev, "Failed to set bandwidth clamp: %d, 0x%x\n", err,
+ resp.hdr.status);
+ if (!err)
+ err = -EPROTO;
+ return err;
+ }
+
+ if (resp.qos_unconfigured)
+ netdev_info(ndev, "QoS is unconfigured\n");
+
+ return 0;
+}
+
int mana_create_wq_obj(struct mana_port_context *apc,
mana_handle_t vport,
u32 wq_type, struct mana_obj_spec *wq_spec,
diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
index 48234a738d26..b29d0fe0a201 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
@@ -439,6 +439,18 @@ static int mana_get_link_ksettings(struct net_device *ndev,
return 0;
}
+static int mana_set_link_ksettings(struct net_device *ndev,
+ const struct ethtool_link_ksettings *cmd)
+{
+ struct mana_port_context *apc = netdev_priv(ndev);
+ int err;
+
+ err = mana_set_bw_clamp(apc, cmd->base.speed);
+
+ apc->speed = (err) ? apc->speed : cmd->base.speed;
+ return 0;
+}
+
const struct ethtool_ops mana_ethtool_ops = {
.get_ethtool_stats = mana_get_ethtool_stats,
.get_sset_count = mana_get_sset_count,
@@ -453,5 +465,6 @@ const struct ethtool_ops mana_ethtool_ops = {
.get_ringparam = mana_get_ringparam,
.set_ringparam = mana_set_ringparam,
.get_link_ksettings = mana_get_link_ksettings,
+ .set_link_ksettings = mana_set_link_ksettings,
.get_link = ethtool_op_get_link,
};
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index 5f039ce99ade..b4c66ce9ee3a 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -500,6 +500,7 @@ void mana_chn_setxdp(struct mana_port_context *apc, struct bpf_prog *prog);
int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf);
void mana_query_gf_stats(struct mana_port_context *apc);
int mana_query_link_cfg(struct mana_port_context *apc);
+int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed);
int mana_pre_alloc_rxbufs(struct mana_port_context *apc, int mtu, int num_queues);
void mana_pre_dealloc_rxbufs(struct mana_port_context *apc);
@@ -527,6 +528,7 @@ enum mana_command_code {
MANA_CONFIG_VPORT_RX = 0x20007,
MANA_QUERY_VPORT_CONFIG = 0x20008,
MANA_QUERY_LINK_CONFIG = 0x2000A,
+ MANA_SET_BW_CLAMP = 0x2000B,
/* Privileged commands for the PF mode */
MANA_REGISTER_FILTER = 0x28000,
@@ -548,6 +550,20 @@ struct mana_query_link_config_resp {
u8 reserved[3];
}; /* HW DATA */
+/* Set Bandwidth Clamp*/
+struct mana_set_bw_clamp_req {
+ struct gdma_req_hdr hdr;
+ mana_handle_t vport;
+ enum TRI_STATE enable_clamping;
+ u32 link_speed;
+}; /* HW DATA */
+
+struct mana_set_bw_clamp_resp {
+ struct gdma_resp_hdr hdr;
+ bool qos_unconfigured;
+ u8 reserved[7];
+}; /* HW DATA */
+
/* Query Device Configuration */
struct mana_query_device_cfg_req {
struct gdma_req_hdr hdr;
--
2.34.1
next prev parent reply other threads:[~2025-03-20 12:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 12:22 [PATCH 0/3] Add support for speed in MANA ethtool Erni Sri Satya Vennela
2025-03-20 12:22 ` [PATCH 1/3] net: mana: Add speed support in mana_get_link_ksettings Erni Sri Satya Vennela
2025-03-20 13:37 ` Andrew Lunn
2025-03-24 17:43 ` Erni Sri Satya Vennela
2025-03-24 18:44 ` Andrew Lunn
2025-03-25 16:25 ` Erni Sri Satya Vennela
2025-03-25 16:43 ` Andrew Lunn
2025-03-20 12:22 ` Erni Sri Satya Vennela [this message]
2025-03-20 13:43 ` [PATCH 2/3] net: mana: Implement set_link_ksettings in ethtool for speed Andrew Lunn
2025-03-25 17:09 ` Erni Sri Satya Vennela
2025-03-25 17:52 ` Andrew Lunn
2025-03-25 19:21 ` Jakub Kicinski
2025-03-25 19:53 ` [EXTERNAL] " Haiyang Zhang
2025-03-25 19:58 ` Andrew Lunn
2025-03-25 20:28 ` Haiyang Zhang
2025-03-25 20:38 ` Andrew Lunn
2025-03-31 9:08 ` Erni Sri Satya Vennela
2025-04-17 8:12 ` Erni Sri Satya Vennela
2025-03-20 12:22 ` [PATCH 3/3] net: mana: Handle unsupported HWC commands Erni Sri Satya Vennela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1742473341-15262-3-git-send-email-ernis@linux.microsoft.com \
--to=ernis@linux.microsoft.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=erick.archer@outlook.com \
--cc=haiyangz@microsoft.com \
--cc=horms@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=kotaranov@microsoft.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rosenp@gmail.com \
--cc=schakrabarti@linux.microsoft.com \
--cc=shradhagupta@linux.microsoft.com \
--cc=surenb@google.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).