* [PATCH net-next v2 1/4] net: mana: Fix potential deadlocks in mana napi ops
2025-06-13 11:20 [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Erni Sri Satya Vennela
@ 2025-06-13 11:20 ` Erni Sri Satya Vennela
2025-06-13 17:01 ` Long Li
2025-06-13 11:20 ` [PATCH net-next v2 2/4] net: mana: Add support for net_shaper_ops Erni Sri Satya Vennela
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Erni Sri Satya Vennela @ 2025-06-13 11:20 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, andrew+netdev, davem, edumazet,
kuba, pabeni, longli, kotaranov, horms, shirazsaleem, leon, ernis,
shradhagupta, schakrabarti, gerhard, rosenp, sdf, linux-hyperv,
netdev, linux-kernel, linux-rdma
When net_shaper_ops are enabled for MANA, netdev_ops_lock
becomes active.
MANA VF setup/teardown by netvsc follows this call chain:
netvsc_vf_setup()
dev_change_flags()
...
__dev_open() OR __dev_close()
dev_change_flags() holds the netdev mutex via netdev_lock_ops.
Meanwhile, mana_create_txq() and mana_create_rxq() in mana_open()
path call NAPI APIs (netif_napi_add_tx(), netif_napi_add_weight(),
napi_enable()), which also try to acquire the same lock, risking
deadlock.
Similarly in the teardown path (mana_close()), netif_napi_disable()
and netif_napi_del(), contend for the same lock.
Switch to the _locked variants of these APIs to avoid deadlocks
when the netdev_ops_lock is held.
Fixes: d4c22ec680c8 ("net: hold netdev instance lock during ndo_open/ndo_stop")
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>
Reviewed-by: Saurabh Singh Sengar <ssengar@linux.microsoft.com>
---
Changes in v2:
* Use netdev_lock_ops_to_full() instead of if...else statements for napi
APIs.
* Edit commit message.
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 30 +++++++++++++------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index e68b8190bb7a..ca5e9c3d374b 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -1912,8 +1912,11 @@ static void mana_destroy_txq(struct mana_port_context *apc)
napi = &apc->tx_qp[i].tx_cq.napi;
if (apc->tx_qp[i].txq.napi_initialized) {
napi_synchronize(napi);
- napi_disable(napi);
- netif_napi_del(napi);
+ netdev_lock_ops_to_full(napi->dev);
+ napi_disable_locked(napi);
+ netif_napi_del_locked(napi);
+ netdev_unlock_full_to_ops(napi->dev);
apc->tx_qp[i].txq.napi_initialized = false;
}
mana_destroy_wq_obj(apc, GDMA_SQ, apc->tx_qp[i].tx_object);
@@ -2065,8 +2068,11 @@ static int mana_create_txq(struct mana_port_context *apc,
mana_create_txq_debugfs(apc, i);
- netif_napi_add_tx(net, &cq->napi, mana_poll);
- napi_enable(&cq->napi);
+ set_bit(NAPI_STATE_NO_BUSY_POLL, &cq->napi.state);
+ netdev_lock_ops_to_full(net);
+ netif_napi_add_locked(net, &cq->napi, mana_poll);
+ napi_enable_locked(&cq->napi);
+ netdev_unlock_full_to_ops(net);
txq->napi_initialized = true;
mana_gd_ring_cq(cq->gdma_cq, SET_ARM_BIT);
@@ -2102,9 +2108,11 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
if (napi_initialized) {
napi_synchronize(napi);
- napi_disable(napi);
-
- netif_napi_del(napi);
+ netdev_lock_ops_to_full(napi->dev);
+ napi_disable_locked(napi);
+ netif_napi_del_locked(napi);
+ netdev_unlock_full_to_ops(napi->dev);
}
xdp_rxq_info_unreg(&rxq->xdp_rxq);
@@ -2355,14 +2363,18 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
gc->cq_table[cq->gdma_id] = cq->gdma_cq;
- netif_napi_add_weight(ndev, &cq->napi, mana_poll, 1);
+ netdev_lock_ops_to_full(ndev);
+ netif_napi_add_weight_locked(ndev, &cq->napi, mana_poll, 1);
+ netdev_unlock_full_to_ops(ndev);
WARN_ON(xdp_rxq_info_reg(&rxq->xdp_rxq, ndev, rxq_idx,
cq->napi.napi_id));
WARN_ON(xdp_rxq_info_reg_mem_model(&rxq->xdp_rxq, MEM_TYPE_PAGE_POOL,
rxq->page_pool));
- napi_enable(&cq->napi);
+ netdev_lock_ops_to_full(ndev);
+ napi_enable_locked(&cq->napi);
+ netdev_unlock_full_to_ops(ndev);
mana_gd_ring_cq(cq->gdma_cq, SET_ARM_BIT);
out:
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH net-next v2 1/4] net: mana: Fix potential deadlocks in mana napi ops
2025-06-13 11:20 ` [PATCH net-next v2 1/4] net: mana: Fix potential deadlocks in mana napi ops Erni Sri Satya Vennela
@ 2025-06-13 17:01 ` Long Li
0 siblings, 0 replies; 9+ messages in thread
From: Long Li @ 2025-06-13 17:01 UTC (permalink / raw)
To: Erni Sri Satya Vennela, KY Srinivasan, Haiyang Zhang,
wei.liu@kernel.org, Dexuan Cui, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, Konstantin Taranov, horms@kernel.org,
Shiraz Saleem, leon@kernel.org, shradhagupta@linux.microsoft.com,
schakrabarti@linux.microsoft.com, gerhard@engleder-embedded.com,
rosenp@gmail.com, sdf@fomichev.me, linux-hyperv@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org
> Subject: [PATCH net-next v2 1/4] net: mana: Fix potential deadlocks in mana napi
> ops
>
> When net_shaper_ops are enabled for MANA, netdev_ops_lock becomes active.
>
> MANA VF setup/teardown by netvsc follows this call chain:
>
> netvsc_vf_setup()
> dev_change_flags()
> ...
> __dev_open() OR __dev_close()
>
> dev_change_flags() holds the netdev mutex via netdev_lock_ops.
>
> Meanwhile, mana_create_txq() and mana_create_rxq() in mana_open() path call
> NAPI APIs (netif_napi_add_tx(), netif_napi_add_weight(), napi_enable()), which
> also try to acquire the same lock, risking deadlock.
>
> Similarly in the teardown path (mana_close()), netif_napi_disable() and
> netif_napi_del(), contend for the same lock.
>
> Switch to the _locked variants of these APIs to avoid deadlocks when the
> netdev_ops_lock is held.
>
> Fixes: d4c22ec680c8 ("net: hold netdev instance lock during
> ndo_open/ndo_stop")
> 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>
> Reviewed-by: Saurabh Singh Sengar <ssengar@linux.microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
> ---
> Changes in v2:
> * Use netdev_lock_ops_to_full() instead of if...else statements for napi
> APIs.
> * Edit commit message.
> ---
> drivers/net/ethernet/microsoft/mana/mana_en.c | 30 +++++++++++++------
> 1 file changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c
> b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index e68b8190bb7a..ca5e9c3d374b 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -1912,8 +1912,11 @@ static void mana_destroy_txq(struct
> mana_port_context *apc)
> napi = &apc->tx_qp[i].tx_cq.napi;
> if (apc->tx_qp[i].txq.napi_initialized) {
> napi_synchronize(napi);
> - napi_disable(napi);
> - netif_napi_del(napi);
> + netdev_lock_ops_to_full(napi->dev);
> + napi_disable_locked(napi);
> + netif_napi_del_locked(napi);
> + netdev_unlock_full_to_ops(napi->dev);
> apc->tx_qp[i].txq.napi_initialized = false;
> }
> mana_destroy_wq_obj(apc, GDMA_SQ, apc-
> >tx_qp[i].tx_object); @@ -2065,8 +2068,11 @@ static int
> mana_create_txq(struct mana_port_context *apc,
>
> mana_create_txq_debugfs(apc, i);
>
> - netif_napi_add_tx(net, &cq->napi, mana_poll);
> - napi_enable(&cq->napi);
> + set_bit(NAPI_STATE_NO_BUSY_POLL, &cq->napi.state);
> + netdev_lock_ops_to_full(net);
> + netif_napi_add_locked(net, &cq->napi, mana_poll);
> + napi_enable_locked(&cq->napi);
> + netdev_unlock_full_to_ops(net);
> txq->napi_initialized = true;
>
> mana_gd_ring_cq(cq->gdma_cq, SET_ARM_BIT); @@ -2102,9
> +2108,11 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
> if (napi_initialized) {
> napi_synchronize(napi);
>
> - napi_disable(napi);
> -
> - netif_napi_del(napi);
> + netdev_lock_ops_to_full(napi->dev);
> + napi_disable_locked(napi);
> + netif_napi_del_locked(napi);
> + netdev_unlock_full_to_ops(napi->dev);
> }
> xdp_rxq_info_unreg(&rxq->xdp_rxq);
>
> @@ -2355,14 +2363,18 @@ static struct mana_rxq *mana_create_rxq(struct
> mana_port_context *apc,
>
> gc->cq_table[cq->gdma_id] = cq->gdma_cq;
>
> - netif_napi_add_weight(ndev, &cq->napi, mana_poll, 1);
> + netdev_lock_ops_to_full(ndev);
> + netif_napi_add_weight_locked(ndev, &cq->napi, mana_poll, 1);
> + netdev_unlock_full_to_ops(ndev);
>
> WARN_ON(xdp_rxq_info_reg(&rxq->xdp_rxq, ndev, rxq_idx,
> cq->napi.napi_id));
> WARN_ON(xdp_rxq_info_reg_mem_model(&rxq->xdp_rxq,
> MEM_TYPE_PAGE_POOL,
> rxq->page_pool));
>
> - napi_enable(&cq->napi);
> + netdev_lock_ops_to_full(ndev);
> + napi_enable_locked(&cq->napi);
> + netdev_unlock_full_to_ops(ndev);
>
> mana_gd_ring_cq(cq->gdma_cq, SET_ARM_BIT);
> out:
> --
> 2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next v2 2/4] net: mana: Add support for net_shaper_ops
2025-06-13 11:20 [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Erni Sri Satya Vennela
2025-06-13 11:20 ` [PATCH net-next v2 1/4] net: mana: Fix potential deadlocks in mana napi ops Erni Sri Satya Vennela
@ 2025-06-13 11:20 ` Erni Sri Satya Vennela
2025-06-13 17:04 ` Long Li
2025-06-13 11:20 ` [PATCH net-next v2 3/4] net: mana: Add speed support in mana_get_link_ksettings Erni Sri Satya Vennela
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Erni Sri Satya Vennela @ 2025-06-13 11:20 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, andrew+netdev, davem, edumazet,
kuba, pabeni, longli, kotaranov, horms, shirazsaleem, leon, ernis,
shradhagupta, schakrabarti, gerhard, rosenp, sdf, linux-hyperv,
netdev, linux-kernel, linux-rdma
Introduce support for net_shaper_ops in the MANA driver,
enabling configuration of rate limiting on the MANA NIC.
To apply rate limiting, the driver issues a HWC command via
mana_set_bw_clamp() and updates the corresponding shaper object
in the net_shaper cache. If an error occurs during this process,
the driver restores the previous speed by querying the current link
configuration using mana_query_link_cfg().
The minimum supported bandwidth is 100 Mbps, and only values that are
exact multiples of 100 Mbps are allowed. Any other values are rejected.
To remove a shaper, the driver resets the bandwidth to the maximum
supported by the SKU using mana_set_bw_clamp() and clears the
associated cache entry. If an error occurs during this process,
the shaper details are retained.
On the hardware that does not support these APIs, the net-shaper
calls to set speed would fail.
Set the speed:
./tools/net/ynl/pyynl/cli.py \
--spec Documentation/netlink/specs/net_shaper.yaml \
--do set --json '{"ifindex":'$IFINDEX',
"handle":{"scope": "netdev", "id":'$ID' },
"bw-max": 200000000 }'
Get the shaper details:
./tools/net/ynl/pyynl/cli.py \
--spec Documentation/netlink/specs/net_shaper.yaml \
--do get --json '{"ifindex":'$IFINDEX',
"handle":{"scope": "netdev", "id":'$ID' }}'
> {'bw-max': 200000000,
> 'handle': {'scope': 'netdev'},
> 'ifindex': $IFINDEX,
> 'metric': 'bps'}
Delete the shaper object:
./tools/net/ynl/pyynl/cli.py \
--spec Documentation/netlink/specs/net_shaper.yaml \
--do delete --json '{"ifindex":'$IFINDEX',
"handle":{"scope": "netdev","id":'$ID' }}'
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>
Reviewed-by: Saurabh Singh Sengar <ssengar@linux.microsoft.com>
---
Changes in v2:
* No change.
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 155 ++++++++++++++++++
include/net/mana/mana.h | 40 +++++
2 files changed, 195 insertions(+)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index ca5e9c3d374b..7e8bc2c6a194 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -719,6 +719,78 @@ static int mana_change_mtu(struct net_device *ndev, int new_mtu)
return err;
}
+static int mana_shaper_set(struct net_shaper_binding *binding,
+ const struct net_shaper *shaper,
+ struct netlink_ext_ack *extack)
+{
+ struct mana_port_context *apc = netdev_priv(binding->netdev);
+ u32 old_speed, rate;
+ int err;
+
+ if (shaper->handle.scope != NET_SHAPER_SCOPE_NETDEV) {
+ NL_SET_ERR_MSG_MOD(extack, "net shaper scope should be netdev");
+ return -EINVAL;
+ }
+
+ if (apc->handle.id && shaper->handle.id != apc->handle.id) {
+ NL_SET_ERR_MSG_MOD(extack, "Cannot create multiple shapers");
+ return -EOPNOTSUPP;
+ }
+
+ if (!shaper->bw_max || (shaper->bw_max % 100000000)) {
+ NL_SET_ERR_MSG_MOD(extack, "Please use multiples of 100Mbps for bandwidth");
+ return -EINVAL;
+ }
+
+ rate = div_u64(shaper->bw_max, 1000); /* Convert bps to Kbps */
+ rate = div_u64(rate, 1000); /* Convert Kbps to Mbps */
+
+ /* Get current speed */
+ err = mana_query_link_cfg(apc);
+ old_speed = (err) ? SPEED_UNKNOWN : apc->speed;
+
+ if (!err) {
+ err = mana_set_bw_clamp(apc, rate, TRI_STATE_TRUE);
+ apc->speed = (err) ? old_speed : rate;
+ apc->handle = (err) ? apc->handle : shaper->handle;
+ }
+
+ return err;
+}
+
+static int mana_shaper_del(struct net_shaper_binding *binding,
+ const struct net_shaper_handle *handle,
+ struct netlink_ext_ack *extack)
+{
+ struct mana_port_context *apc = netdev_priv(binding->netdev);
+ int err;
+
+ err = mana_set_bw_clamp(apc, 0, TRI_STATE_FALSE);
+
+ if (!err) {
+ /* Reset mana port context parameters */
+ apc->handle.id = 0;
+ apc->handle.scope = NET_SHAPER_SCOPE_UNSPEC;
+ apc->speed = 0;
+ }
+
+ return err;
+}
+
+static void mana_shaper_cap(struct net_shaper_binding *binding,
+ enum net_shaper_scope scope,
+ unsigned long *flags)
+{
+ *flags = BIT(NET_SHAPER_A_CAPS_SUPPORT_BW_MAX) |
+ BIT(NET_SHAPER_A_CAPS_SUPPORT_METRIC_BPS);
+}
+
+static const struct net_shaper_ops mana_shaper_ops = {
+ .set = mana_shaper_set,
+ .delete = mana_shaper_del,
+ .capabilities = mana_shaper_cap,
+};
+
static const struct net_device_ops mana_devops = {
.ndo_open = mana_open,
.ndo_stop = mana_close,
@@ -729,6 +801,7 @@ static const struct net_device_ops mana_devops = {
.ndo_bpf = mana_bpf,
.ndo_xdp_xmit = mana_xdp_xmit,
.ndo_change_mtu = mana_change_mtu,
+ .net_shaper_ops = &mana_shaper_ops,
};
static void mana_cleanup_port_context(struct mana_port_context *apc)
@@ -1162,6 +1235,86 @@ static int mana_cfg_vport_steering(struct mana_port_context *apc,
return err;
}
+int mana_query_link_cfg(struct mana_port_context *apc)
+{
+ struct net_device *ndev = apc->ndev;
+ struct mana_query_link_config_resp resp = {};
+ struct mana_query_link_config_req req = {};
+ int err;
+
+ mana_gd_init_req_hdr(&req.hdr, MANA_QUERY_LINK_CONFIG,
+ sizeof(req), sizeof(resp));
+
+ req.vport = apc->port_handle;
+ req.hdr.resp.msg_version = GDMA_MESSAGE_V2;
+
+ err = mana_send_request(apc->ac, &req, sizeof(req), &resp,
+ sizeof(resp));
+
+ if (err) {
+ netdev_err(ndev, "Failed to query link config: %d\n", err);
+ return err;
+ }
+
+ err = mana_verify_resp_hdr(&resp.hdr, MANA_QUERY_LINK_CONFIG,
+ sizeof(resp));
+
+ if (err || resp.hdr.status) {
+ netdev_err(ndev, "Failed to query link config: %d, 0x%x\n", err,
+ resp.hdr.status);
+ if (!err)
+ err = -EOPNOTSUPP;
+ return err;
+ }
+
+ if (resp.qos_unconfigured) {
+ err = -EINVAL;
+ return err;
+ }
+ apc->speed = resp.link_speed_mbps;
+ return 0;
+}
+
+int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed,
+ int enable_clamping)
+{
+ struct mana_set_bw_clamp_resp resp = {};
+ struct mana_set_bw_clamp_req req = {};
+ 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_mbps = speed;
+ req.enable_clamping = enable_clamping;
+
+ 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 = -EOPNOTSUPP;
+ 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,
@@ -3013,6 +3166,8 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,
goto free_indir;
}
+ debugfs_create_u32("current_speed", 0400, apc->mana_port_debugfs, &apc->speed);
+
return 0;
free_indir:
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index 4176edf1be71..038b18340e51 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -5,6 +5,7 @@
#define _MANA_H
#include <net/xdp.h>
+#include <net/net_shaper.h>
#include "gdma.h"
#include "hw_channel.h"
@@ -526,7 +527,12 @@ struct mana_port_context {
struct mutex vport_mutex;
int vport_use_count;
+ /* Net shaper handle*/
+ struct net_shaper_handle handle;
+
u16 port_idx;
+ /* Currently configured speed (mbps) */
+ u32 speed;
bool port_is_up;
bool port_st_save; /* Saved port state */
@@ -562,6 +568,9 @@ struct bpf_prog *mana_xdp_get(struct mana_port_context *apc);
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 enable_clamping);
void mana_query_phy_stats(struct mana_port_context *apc);
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);
@@ -589,6 +598,8 @@ enum mana_command_code {
MANA_FENCE_RQ = 0x20006,
MANA_CONFIG_VPORT_RX = 0x20007,
MANA_QUERY_VPORT_CONFIG = 0x20008,
+ MANA_QUERY_LINK_CONFIG = 0x2000A,
+ MANA_SET_BW_CLAMP = 0x2000B,
MANA_QUERY_PHY_STAT = 0x2000c,
/* Privileged commands for the PF mode */
@@ -598,6 +609,35 @@ enum mana_command_code {
MANA_DEREGISTER_HW_PORT = 0x28004,
};
+/* Query Link Configuration*/
+struct mana_query_link_config_req {
+ struct gdma_req_hdr hdr;
+ mana_handle_t vport;
+}; /* HW DATA */
+
+struct mana_query_link_config_resp {
+ struct gdma_resp_hdr hdr;
+ u32 qos_speed_mbps;
+ u8 qos_unconfigured;
+ u8 reserved1[3];
+ u32 link_speed_mbps;
+ u8 reserved2[4];
+}; /* 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_mbps;
+}; /* HW DATA */
+
+struct mana_set_bw_clamp_resp {
+ struct gdma_resp_hdr hdr;
+ u8 qos_unconfigured;
+ u8 reserved[7];
+}; /* HW DATA */
+
/* Query Device Configuration */
struct mana_query_device_cfg_req {
struct gdma_req_hdr hdr;
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH net-next v2 2/4] net: mana: Add support for net_shaper_ops
2025-06-13 11:20 ` [PATCH net-next v2 2/4] net: mana: Add support for net_shaper_ops Erni Sri Satya Vennela
@ 2025-06-13 17:04 ` Long Li
0 siblings, 0 replies; 9+ messages in thread
From: Long Li @ 2025-06-13 17:04 UTC (permalink / raw)
To: Erni Sri Satya Vennela, KY Srinivasan, Haiyang Zhang,
wei.liu@kernel.org, Dexuan Cui, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, Konstantin Taranov, horms@kernel.org,
Shiraz Saleem, leon@kernel.org, shradhagupta@linux.microsoft.com,
schakrabarti@linux.microsoft.com, gerhard@engleder-embedded.com,
rosenp@gmail.com, sdf@fomichev.me, linux-hyperv@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org
> Subject: [PATCH net-next v2 2/4] net: mana: Add support for net_shaper_ops
>
> Introduce support for net_shaper_ops in the MANA driver, enabling configuration
> of rate limiting on the MANA NIC.
>
> To apply rate limiting, the driver issues a HWC command via
> mana_set_bw_clamp() and updates the corresponding shaper object in the
> net_shaper cache. If an error occurs during this process, the driver restores the
> previous speed by querying the current link configuration using
> mana_query_link_cfg().
>
> The minimum supported bandwidth is 100 Mbps, and only values that are exact
> multiples of 100 Mbps are allowed. Any other values are rejected.
>
> To remove a shaper, the driver resets the bandwidth to the maximum supported
> by the SKU using mana_set_bw_clamp() and clears the associated cache entry. If
> an error occurs during this process, the shaper details are retained.
>
> On the hardware that does not support these APIs, the net-shaper calls to set
> speed would fail.
>
> Set the speed:
> ./tools/net/ynl/pyynl/cli.py \
> --spec Documentation/netlink/specs/net_shaper.yaml \ --do set --json
> '{"ifindex":'$IFINDEX',
> "handle":{"scope": "netdev", "id":'$ID' },
> "bw-max": 200000000 }'
>
> Get the shaper details:
> ./tools/net/ynl/pyynl/cli.py \
> --spec Documentation/netlink/specs/net_shaper.yaml \ --do get --json
> '{"ifindex":'$IFINDEX',
> "handle":{"scope": "netdev", "id":'$ID' }}'
>
> > {'bw-max': 200000000,
> > 'handle': {'scope': 'netdev'},
> > 'ifindex': $IFINDEX,
> > 'metric': 'bps'}
>
> Delete the shaper object:
> ./tools/net/ynl/pyynl/cli.py \
> --spec Documentation/netlink/specs/net_shaper.yaml \ --do delete --json
> '{"ifindex":'$IFINDEX',
> "handle":{"scope": "netdev","id":'$ID' }}'
>
> 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>
> Reviewed-by: Saurabh Singh Sengar <ssengar@linux.microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
> ---
> Changes in v2:
> * No change.
> ---
> drivers/net/ethernet/microsoft/mana/mana_en.c | 155 ++++++++++++++++++
> include/net/mana/mana.h | 40 +++++
> 2 files changed, 195 insertions(+)
>
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c
> b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index ca5e9c3d374b..7e8bc2c6a194 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -719,6 +719,78 @@ static int mana_change_mtu(struct net_device *ndev,
> int new_mtu)
> return err;
> }
>
> +static int mana_shaper_set(struct net_shaper_binding *binding,
> + const struct net_shaper *shaper,
> + struct netlink_ext_ack *extack)
> +{
> + struct mana_port_context *apc = netdev_priv(binding->netdev);
> + u32 old_speed, rate;
> + int err;
> +
> + if (shaper->handle.scope != NET_SHAPER_SCOPE_NETDEV) {
> + NL_SET_ERR_MSG_MOD(extack, "net shaper scope should be
> netdev");
> + return -EINVAL;
> + }
> +
> + if (apc->handle.id && shaper->handle.id != apc->handle.id) {
> + NL_SET_ERR_MSG_MOD(extack, "Cannot create multiple
> shapers");
> + return -EOPNOTSUPP;
> + }
> +
> + if (!shaper->bw_max || (shaper->bw_max % 100000000)) {
> + NL_SET_ERR_MSG_MOD(extack, "Please use multiples of
> 100Mbps for bandwidth");
> + return -EINVAL;
> + }
> +
> + rate = div_u64(shaper->bw_max, 1000); /* Convert bps to Kbps */
> + rate = div_u64(rate, 1000); /* Convert Kbps to Mbps */
> +
> + /* Get current speed */
> + err = mana_query_link_cfg(apc);
> + old_speed = (err) ? SPEED_UNKNOWN : apc->speed;
> +
> + if (!err) {
> + err = mana_set_bw_clamp(apc, rate, TRI_STATE_TRUE);
> + apc->speed = (err) ? old_speed : rate;
> + apc->handle = (err) ? apc->handle : shaper->handle;
> + }
> +
> + return err;
> +}
> +
> +static int mana_shaper_del(struct net_shaper_binding *binding,
> + const struct net_shaper_handle *handle,
> + struct netlink_ext_ack *extack)
> +{
> + struct mana_port_context *apc = netdev_priv(binding->netdev);
> + int err;
> +
> + err = mana_set_bw_clamp(apc, 0, TRI_STATE_FALSE);
> +
> + if (!err) {
> + /* Reset mana port context parameters */
> + apc->handle.id = 0;
> + apc->handle.scope = NET_SHAPER_SCOPE_UNSPEC;
> + apc->speed = 0;
> + }
> +
> + return err;
> +}
> +
> +static void mana_shaper_cap(struct net_shaper_binding *binding,
> + enum net_shaper_scope scope,
> + unsigned long *flags)
> +{
> + *flags = BIT(NET_SHAPER_A_CAPS_SUPPORT_BW_MAX) |
> + BIT(NET_SHAPER_A_CAPS_SUPPORT_METRIC_BPS);
> +}
> +
> +static const struct net_shaper_ops mana_shaper_ops = {
> + .set = mana_shaper_set,
> + .delete = mana_shaper_del,
> + .capabilities = mana_shaper_cap,
> +};
> +
> static const struct net_device_ops mana_devops = {
> .ndo_open = mana_open,
> .ndo_stop = mana_close,
> @@ -729,6 +801,7 @@ static const struct net_device_ops mana_devops = {
> .ndo_bpf = mana_bpf,
> .ndo_xdp_xmit = mana_xdp_xmit,
> .ndo_change_mtu = mana_change_mtu,
> + .net_shaper_ops = &mana_shaper_ops,
> };
>
> static void mana_cleanup_port_context(struct mana_port_context *apc) @@ -
> 1162,6 +1235,86 @@ static int mana_cfg_vport_steering(struct
> mana_port_context *apc,
> return err;
> }
>
> +int mana_query_link_cfg(struct mana_port_context *apc) {
> + struct net_device *ndev = apc->ndev;
> + struct mana_query_link_config_resp resp = {};
> + struct mana_query_link_config_req req = {};
> + int err;
> +
> + mana_gd_init_req_hdr(&req.hdr, MANA_QUERY_LINK_CONFIG,
> + sizeof(req), sizeof(resp));
> +
> + req.vport = apc->port_handle;
> + req.hdr.resp.msg_version = GDMA_MESSAGE_V2;
> +
> + err = mana_send_request(apc->ac, &req, sizeof(req), &resp,
> + sizeof(resp));
> +
> + if (err) {
> + netdev_err(ndev, "Failed to query link config: %d\n", err);
> + return err;
> + }
> +
> + err = mana_verify_resp_hdr(&resp.hdr, MANA_QUERY_LINK_CONFIG,
> + sizeof(resp));
> +
> + if (err || resp.hdr.status) {
> + netdev_err(ndev, "Failed to query link config: %d, 0x%x\n", err,
> + resp.hdr.status);
> + if (!err)
> + err = -EOPNOTSUPP;
> + return err;
> + }
> +
> + if (resp.qos_unconfigured) {
> + err = -EINVAL;
> + return err;
> + }
> + apc->speed = resp.link_speed_mbps;
> + return 0;
> +}
> +
> +int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed,
> + int enable_clamping)
> +{
> + struct mana_set_bw_clamp_resp resp = {};
> + struct mana_set_bw_clamp_req req = {};
> + 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_mbps = speed;
> + req.enable_clamping = enable_clamping;
> +
> + 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 = -EOPNOTSUPP;
> + 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, @@ -3013,6
> +3166,8 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,
> goto free_indir;
> }
>
> + debugfs_create_u32("current_speed", 0400, apc->mana_port_debugfs,
> +&apc->speed);
> +
> return 0;
>
> free_indir:
> diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h index
> 4176edf1be71..038b18340e51 100644
> --- a/include/net/mana/mana.h
> +++ b/include/net/mana/mana.h
> @@ -5,6 +5,7 @@
> #define _MANA_H
>
> #include <net/xdp.h>
> +#include <net/net_shaper.h>
>
> #include "gdma.h"
> #include "hw_channel.h"
> @@ -526,7 +527,12 @@ struct mana_port_context {
> struct mutex vport_mutex;
> int vport_use_count;
>
> + /* Net shaper handle*/
> + struct net_shaper_handle handle;
> +
> u16 port_idx;
> + /* Currently configured speed (mbps) */
> + u32 speed;
>
> bool port_is_up;
> bool port_st_save; /* Saved port state */ @@ -562,6 +568,9 @@ struct
> bpf_prog *mana_xdp_get(struct mana_port_context *apc); 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 enable_clamping);
> void mana_query_phy_stats(struct mana_port_context *apc); 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);
> @@ -589,6 +598,8 @@ enum mana_command_code {
> MANA_FENCE_RQ = 0x20006,
> MANA_CONFIG_VPORT_RX = 0x20007,
> MANA_QUERY_VPORT_CONFIG = 0x20008,
> + MANA_QUERY_LINK_CONFIG = 0x2000A,
> + MANA_SET_BW_CLAMP = 0x2000B,
> MANA_QUERY_PHY_STAT = 0x2000c,
>
> /* Privileged commands for the PF mode */ @@ -598,6 +609,35 @@
> enum mana_command_code {
> MANA_DEREGISTER_HW_PORT = 0x28004,
> };
>
> +/* Query Link Configuration*/
> +struct mana_query_link_config_req {
> + struct gdma_req_hdr hdr;
> + mana_handle_t vport;
> +}; /* HW DATA */
> +
> +struct mana_query_link_config_resp {
> + struct gdma_resp_hdr hdr;
> + u32 qos_speed_mbps;
> + u8 qos_unconfigured;
> + u8 reserved1[3];
> + u32 link_speed_mbps;
> + u8 reserved2[4];
> +}; /* 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_mbps;
> +}; /* HW DATA */
> +
> +struct mana_set_bw_clamp_resp {
> + struct gdma_resp_hdr hdr;
> + u8 qos_unconfigured;
> + u8 reserved[7];
> +}; /* HW DATA */
> +
> /* Query Device Configuration */
> struct mana_query_device_cfg_req {
> struct gdma_req_hdr hdr;
> --
> 2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next v2 3/4] net: mana: Add speed support in mana_get_link_ksettings
2025-06-13 11:20 [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Erni Sri Satya Vennela
2025-06-13 11:20 ` [PATCH net-next v2 1/4] net: mana: Fix potential deadlocks in mana napi ops Erni Sri Satya Vennela
2025-06-13 11:20 ` [PATCH net-next v2 2/4] net: mana: Add support for net_shaper_ops Erni Sri Satya Vennela
@ 2025-06-13 11:20 ` Erni Sri Satya Vennela
2025-06-13 11:20 ` [PATCH net-next v2 4/4] net: mana: Handle unsupported HWC commands Erni Sri Satya Vennela
2025-06-14 20:03 ` [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Jakub Kicinski
4 siblings, 0 replies; 9+ messages in thread
From: Erni Sri Satya Vennela @ 2025-06-13 11:20 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, andrew+netdev, davem, edumazet,
kuba, pabeni, longli, kotaranov, horms, shirazsaleem, leon, ernis,
shradhagupta, schakrabarti, gerhard, rosenp, sdf, linux-hyperv,
netdev, linux-kernel, linux-rdma
Allow mana ethtool get_link_ksettings operation to report
the maximum speed supported by the SKU in mbps.
The driver retrieves this information by issuing a
HWC command to the hardware via mana_query_link_cfg(),
which retrieves the SKU's maximum supported speed.
These APIs when invoked on hardware that are older/do
not support these APIs, the speed would be reported as UNKNOWN.
Before:
$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:
$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: 16000Mb/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>
Reviewed-by: Saurabh Singh Sengar <ssengar@linux.microsoft.com>
---
Changes in v2:
* No change.
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 1 +
drivers/net/ethernet/microsoft/mana/mana_ethtool.c | 6 ++++++
include/net/mana/mana.h | 2 ++
3 files changed, 9 insertions(+)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 7e8bc2c6a194..54a86c233948 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -1272,6 +1272,7 @@ int mana_query_link_cfg(struct mana_port_context *apc)
return err;
}
apc->speed = resp.link_speed_mbps;
+ apc->max_speed = resp.qos_speed_mbps;
return 0;
}
diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
index 4fb3a04994a2..a1afa75a9463 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
@@ -495,6 +495,12 @@ static int mana_set_ringparam(struct net_device *ndev,
static int mana_get_link_ksettings(struct net_device *ndev,
struct ethtool_link_ksettings *cmd)
{
+ struct mana_port_context *apc = netdev_priv(ndev);
+ int err;
+
+ err = mana_query_link_cfg(apc);
+ cmd->base.speed = (err) ? SPEED_UNKNOWN : apc->max_speed;
+
cmd->base.duplex = DUPLEX_FULL;
cmd->base.port = PORT_OTHER;
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index 038b18340e51..e1030a7d2daa 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -533,6 +533,8 @@ struct mana_port_context {
u16 port_idx;
/* Currently configured speed (mbps) */
u32 speed;
+ /* Maximum speed supported by the SKU (mbps) */
+ u32 max_speed;
bool port_is_up;
bool port_st_save; /* Saved port state */
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 4/4] net: mana: Handle unsupported HWC commands
2025-06-13 11:20 [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Erni Sri Satya Vennela
` (2 preceding siblings ...)
2025-06-13 11:20 ` [PATCH net-next v2 3/4] net: mana: Add speed support in mana_get_link_ksettings Erni Sri Satya Vennela
@ 2025-06-13 11:20 ` Erni Sri Satya Vennela
2025-06-14 20:03 ` [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Jakub Kicinski
4 siblings, 0 replies; 9+ messages in thread
From: Erni Sri Satya Vennela @ 2025-06-13 11:20 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, andrew+netdev, davem, edumazet,
kuba, pabeni, longli, kotaranov, horms, shirazsaleem, leon, ernis,
shradhagupta, schakrabarti, gerhard, rosenp, sdf, linux-hyperv,
netdev, linux-kernel, linux-rdma
If any of the HWC commands are not recognized by the
underlying hardware, the hardware returns the response
header status of -1. Log the information using
netdev_info_once to avoid multiple error logs in dmesg.
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>
Reviewed-by: Saurabh Singh Sengar <ssengar@linux.microsoft.com>
Reviewed-by: Dipayaan Roy <dipayanroy@linux.microsoft.com>
---
Changes in v2:
* Define GDMA_STATUS_CMD_UNSUPPORTED for unsupported HWC status code
instead of using -1.
---
drivers/net/ethernet/microsoft/mana/hw_channel.c | 4 ++++
drivers/net/ethernet/microsoft/mana/mana_en.c | 11 +++++++++++
include/net/mana/gdma.h | 1 +
3 files changed, 16 insertions(+)
diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
index 3d3677c0d014..650d22654d49 100644
--- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
+++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
@@ -891,6 +891,10 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
}
if (ctx->status_code && ctx->status_code != GDMA_STATUS_MORE_ENTRIES) {
+ if (ctx->status_code == GDMA_STATUS_CMD_UNSUPPORTED) {
+ err = -EOPNOTSUPP;
+ goto out;
+ }
if (req_msg->req.msg_type != MANA_QUERY_PHY_STAT)
dev_err(hwc->dev, "HWC: Failed hw_channel req: 0x%x\n",
ctx->status_code);
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 54a86c233948..50a947859bd0 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -847,6 +847,9 @@ static int mana_send_request(struct mana_context *ac, void *in_buf,
err = mana_gd_send_request(gc, in_len, in_buf, out_len,
out_buf);
if (err || resp->status) {
+ if (err == -EOPNOTSUPP)
+ return err;
+
if (req->req.msg_type != MANA_QUERY_PHY_STAT)
dev_err(dev, "Failed to send mana message: %d, 0x%x\n",
err, resp->status);
@@ -1252,6 +1255,10 @@ int mana_query_link_cfg(struct mana_port_context *apc)
sizeof(resp));
if (err) {
+ if (err == -EOPNOTSUPP) {
+ netdev_info_once(ndev, "MANA_QUERY_LINK_CONFIG not supported\n");
+ return err;
+ }
netdev_err(ndev, "Failed to query link config: %d\n", err);
return err;
}
@@ -1294,6 +1301,10 @@ int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed,
sizeof(resp));
if (err) {
+ if (err == -EOPNOTSUPP) {
+ netdev_info_once(ndev, "MANA_SET_BW_CLAMP not supported\n");
+ return err;
+ }
netdev_err(ndev, "Failed to set bandwidth clamp for speed %u, err = %d",
speed, err);
return err;
diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h
index 3ce56a816425..7752ab0a55cf 100644
--- a/include/net/mana/gdma.h
+++ b/include/net/mana/gdma.h
@@ -10,6 +10,7 @@
#include "shm_channel.h"
#define GDMA_STATUS_MORE_ENTRIES 0x00000105
+#define GDMA_STATUS_CMD_UNSUPPORTED 0xffffffff
/* Structures labeled with "HW DATA" are exchanged with the hardware. All of
* them are naturally aligned and hence don't need __packed.
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers
2025-06-13 11:20 [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Erni Sri Satya Vennela
` (3 preceding siblings ...)
2025-06-13 11:20 ` [PATCH net-next v2 4/4] net: mana: Handle unsupported HWC commands Erni Sri Satya Vennela
@ 2025-06-14 20:03 ` Jakub Kicinski
2025-06-17 6:16 ` Erni Sri Satya Vennela
4 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2025-06-14 20:03 UTC (permalink / raw)
To: Erni Sri Satya Vennela
Cc: kys, haiyangz, wei.liu, decui, andrew+netdev, davem, edumazet,
pabeni, longli, kotaranov, horms, shirazsaleem, leon,
shradhagupta, schakrabarti, gerhard, rosenp, sdf, linux-hyperv,
netdev, linux-kernel, linux-rdma
On Fri, 13 Jun 2025 04:20:23 -0700 Erni Sri Satya Vennela wrote:
> This patchset introduces hardware-backed bandwidth rate limiting
> for MANA NICs via the net_shaper_ops interface, enabling efficient and
> fine-grained traffic shaping directly on the device.
>
> Previously, MANA lacked a mechanism for user-configurable bandwidth
> control. With this addition, users can now configure shaping parameters,
> allowing better traffic management and performance isolation.
>
> The implementation includes the net_shaper_ops callbacks in the MANA
> driver and supports one shaper per vport. Add shaping support via
> mana_set_bw_clamp(), allowing the configuration of bandwidth rates
> in 100 Mbps increments (minimum 100 Mbps). The driver validates input
> and rejects unsupported values. On failure, it restores the previous
> configuration which is queried using mana_query_link_cfg() or
> retains the current state.
>
> To prevent potential deadlocks introduced by net_shaper_ops, switch to
> _locked variants of NAPI APIs when netdevops_lock is held during
> VF setup and teardown.
>
> Also, Add support for ethtool get_link_ksettings to report the maximum
> link speed supported by the SKU in mbps.
>
> These APIs when invoked on hardware that are older or that do
> not support these APIs, the speed would be reported as UNKNOWN and
> the net-shaper calls to set speed would fail.
Failed to apply patch:
Applying: net: mana: Fix potential deadlocks in mana napi ops
error: patch fragment without header at line 23: @@ -2102,9 +2108,11 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 net: mana: Fix potential deadlocks in mana napi ops
please rebase
--
pw-bot: cr
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers
2025-06-14 20:03 ` [PATCH net-next v2 0/4] Support bandwidth clamping in mana using net shapers Jakub Kicinski
@ 2025-06-17 6:16 ` Erni Sri Satya Vennela
0 siblings, 0 replies; 9+ messages in thread
From: Erni Sri Satya Vennela @ 2025-06-17 6:16 UTC (permalink / raw)
To: Jakub Kicinski
Cc: kys, haiyangz, wei.liu, decui, andrew+netdev, davem, edumazet,
pabeni, longli, kotaranov, horms, shirazsaleem, leon,
shradhagupta, schakrabarti, gerhard, rosenp, sdf, linux-hyperv,
netdev, linux-kernel, linux-rdma
On Sat, Jun 14, 2025 at 01:03:54PM -0700, Jakub Kicinski wrote:
> On Fri, 13 Jun 2025 04:20:23 -0700 Erni Sri Satya Vennela wrote:
> > This patchset introduces hardware-backed bandwidth rate limiting
> > for MANA NICs via the net_shaper_ops interface, enabling efficient and
> > fine-grained traffic shaping directly on the device.
> >
> > Previously, MANA lacked a mechanism for user-configurable bandwidth
> > control. With this addition, users can now configure shaping parameters,
> > allowing better traffic management and performance isolation.
> >
> > The implementation includes the net_shaper_ops callbacks in the MANA
> > driver and supports one shaper per vport. Add shaping support via
> > mana_set_bw_clamp(), allowing the configuration of bandwidth rates
> > in 100 Mbps increments (minimum 100 Mbps). The driver validates input
> > and rejects unsupported values. On failure, it restores the previous
> > configuration which is queried using mana_query_link_cfg() or
> > retains the current state.
> >
> > To prevent potential deadlocks introduced by net_shaper_ops, switch to
> > _locked variants of NAPI APIs when netdevops_lock is held during
> > VF setup and teardown.
> >
> > Also, Add support for ethtool get_link_ksettings to report the maximum
> > link speed supported by the SKU in mbps.
> >
> > These APIs when invoked on hardware that are older or that do
> > not support these APIs, the speed would be reported as UNKNOWN and
> > the net-shaper calls to set speed would fail.
>
> Failed to apply patch:
> Applying: net: mana: Fix potential deadlocks in mana napi ops
> error: patch fragment without header at line 23: @@ -2102,9 +2108,11 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
> error: could not build fake ancestor
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> hint: When you have resolved this problem, run "git am --continue".
> hint: If you prefer to skip this patch, run "git am --skip" instead.
> hint: To restore the original branch and stop patching, run "git am --abort".
> hint: Disable this message with "git config set advice.mergeConflict false"
> Patch failed at 0001 net: mana: Fix potential deadlocks in mana napi ops
>
> please rebase
Hi Jakub,
Thank you for your reply. I will rebase and repost.
- Vennela
> --
> pw-bot: cr
^ permalink raw reply [flat|nested] 9+ messages in thread