mlx5 technical debt of hairpin params
Subsystems (7)
cover mlx5 technical debt of hairpin params
From: Saeed Mahameed <[email protected]>
Hi Jakub,
As previously discussed, this series provides the switch from debugfs to devlink params for hairpin.
Per the discussion in [1], move the hairpin queues control (number and size) from debugfs to devlink.
Expose two devlink params:
- hairpin_num_queues: control the number of hairpin queues
- hairpin_queue_size: control the size (in packets) of the hairpin queues
[1] https://lore.kernel.org/all/[email protected]/
Disclaimer: I personally don't prefer devlink over debugfs, but since this is something that you requested, I'm submitting this series.
Sorry for the late submission, I know we are on merge window, and in case you don't plan to submit further pull requests to liuns, then maybe it's a good idea to take only the first patch (revert debugfs) and push it through your next net PR.
Thanks,
Saeed.
Gal Pressman (4):
net/mlx5e: Remove hairpin write debugfs files net/mlx5: Move needed PTYS functions to core layer net/mlx5e: Add devlink hairpin queues parameters net/mlx5e: Add more information to hairpin table dump
.../ethernet/mellanox/mlx5/devlink.rst | 35 ++++ Documentation/networking/devlink/mlx5.rst | 12 ++ .../net/ethernet/mellanox/mlx5/core/devlink.c | 66 ++++++++ .../net/ethernet/mellanox/mlx5/core/devlink.h | 2 + .../ethernet/mellanox/mlx5/core/en/params.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en/port.c | 157 +----------------- .../net/ethernet/mellanox/mlx5/core/en/port.h | 14 -- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 12 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 117 +++---------- .../net/ethernet/mellanox/mlx5/core/esw/qos.c | 2 +- .../net/ethernet/mellanox/mlx5/core/port.c | 151 +++++++++++++++++ include/linux/mlx5/port.h | 16 ++ 12 files changed, 318 insertions(+), 268 deletions(-)
Signature · 1 line
2.39.1
PATCH 1/4 net/mlx5e: Remove hairpin write debugfs files
From: Gal Pressman <[email protected]>
Per the discussion in [1], hairpin parameters will be exposed using devlink, remove the debugfs files.
[1] https://lore.kernel.org/all/[email protected]/
Issue: 3222646
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 59 ------------------- 1 file changed, 59 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -59
@@ -1048,61 +1048,6 @@ static int mlx5e_hairpin_get_prio(struct mlx5e_priv *priv,return 0 ; } -static int debugfs_hairpin_queues_set (void *data,u64 val) -{ -struct mlx5e_hairpin_params *hp = data; - -if (!val) { -mlx5_core_err (hp->mdev, -"Number of hairpin queues must be > 0\n" ); -return -EINVAL ; - } - - hp->num_queues = val; - -return 0 ; -} - -static int debugfs_hairpin_queues_get (void *data,u64 *val) -{ -struct mlx5e_hairpin_params *hp = data; - - *val = hp->num_queues; - -return 0 ; -} -DEFINE_DEBUGFS_ATTRIBUTE (fops_hairpin_queues, debugfs_hairpin_queues_get, - debugfs_hairpin_queues_set,"%llu\n" ); - -static int debugfs_hairpin_queue_size_set (void *data,u64 val) -{ -struct mlx5e_hairpin_params *hp = data; - -if (val >BIT (MLX5_CAP_GEN (hp->mdev, log_max_hairpin_num_packets))) { -mlx5_core_err (hp->mdev, -"Invalid hairpin queue size, must be <= %lu\n" , -BIT (MLX5_CAP_GEN (hp->mdev, - log_max_hairpin_num_packets))); -return -EINVAL ; - } - - hp->queue_size =roundup_pow_of_two (val); - -return 0 ; -} - -static int debugfs_hairpin_queue_size_get (void *data,u64 *val) -{ -struct mlx5e_hairpin_params *hp = data; - - *val = hp->queue_size; - -return 0 ; -} -DEFINE_DEBUGFS_ATTRIBUTE (fops_hairpin_queue_size, - debugfs_hairpin_queue_size_get, - debugfs_hairpin_queue_size_set,"%llu\n" ); -static int debugfs_hairpin_num_active_get (void *data,u64 *val) {struct mlx5e_tc_table *tc = data;
@@ -1148,10 +1093,6 @@ static void mlx5e_tc_debugfs_init(struct mlx5e_tc_table *tc, tc->dfs_root =debugfs_create_dir ("tc" , dfs_root); -debugfs_create_file ("hairpin_num_queues" ,0644 , tc->dfs_root, - &tc->hairpin_params, &fops_hairpin_queues); -debugfs_create_file ("hairpin_queue_size" ,0644 , tc->dfs_root, - &tc->hairpin_params, &fops_hairpin_queue_size);debugfs_create_file ("hairpin_num_active" ,0444 , tc->dfs_root, tc, &fops_hairpin_num_active); debugfs_create_file("hairpin_table_dump", 0444, tc->dfs_root, tc,
Signature · 1 line
2.39.1
PATCH 2/4 net/mlx5: Move needed PTYS functions to core layer
In reply to Saeed MahameedFrom: Gal Pressman <[email protected]>
Downstream patches require devlink params to access the PTYS register, move the needed functions from mlx5e to the core layer.
Issue: 3222646
--- .../ethernet/mellanox/mlx5/core/en/params.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en/port.c | 157 +----------------- .../net/ethernet/mellanox/mlx5/core/en/port.h | 14 -- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 12 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- .../net/ethernet/mellanox/mlx5/core/esw/qos.c | 2 +- .../net/ethernet/mellanox/mlx5/core/port.c | 151 +++++++++++++++++ include/linux/mlx5/port.h | 16 ++ 8 files changed, 179 insertions(+), 177 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +1 -1
@@ -553,7 +553,7 @@ bool slow_pci_heuristic(struct mlx5_core_dev *mdev)u32 link_speed =0 ;u32 pci_bw =0 ; -mlx5e_port_max_linkspeed (mdev, &link_speed); +mlx5_port_max_linkspeed (mdev, &link_speed); pci_bw =pcie_bandwidth_available (mdev->pdev,NULL ,NULL ,NULL );mlx5_core_dbg_once (mdev,"Max link speed = %d, PCI BW = %d\n" , link_speed, pci_bw);
drivers/net/ethernet/mellanox/mlx5/core/en/port.c +3 -154
187 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/port.h +0 -14
@@ -36,25 +36,11 @@#include <linux/mlx5/driver.h> #include "en.h" -struct mlx5e_port_eth_proto { -u32 cap; -u32 admin; -u32 oper; -}; - -int mlx5_port_query_eth_proto (struct mlx5_core_dev *dev,u8 port,bool ext, -struct mlx5e_port_eth_proto *eproto);void mlx5_port_query_eth_autoneg (struct mlx5_core_dev *dev,u8 *an_status,u8 *an_disable_cap,u8 *an_disable_admin);int mlx5_port_set_eth_ptys (struct mlx5_core_dev *dev,bool an_disable,u32 proto_admin,bool ext); -u32 mlx5e_port_ptys2speed (struct mlx5_core_dev *mdev,u32 eth_proto_oper, -bool force_legacy);int mlx5e_port_linkspeed (struct mlx5_core_dev *mdev,u32 *speed); -int mlx5e_port_max_linkspeed (struct mlx5_core_dev *mdev,u32 *speed); -u32 mlx5e_port_speed2linkmodes (struct mlx5_core_dev *mdev,u32 speed, -bool force_legacy); -bool mlx5e_ptys_ext_supported (struct mlx5_core_dev *mdev);int mlx5e_port_query_pbmc (struct mlx5_core_dev *mdev,void *out);int mlx5e_port_set_pbmc (struct mlx5_core_dev *mdev,void *in); int mlx5e_port_query_sbpr(struct mlx5_core_dev *mdev, u32 desc, u8 dir,
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +6 -6
@@ -220,7 +220,7 @@ static void mlx5e_ethtool_get_speed_arr(struct mlx5_core_dev *mdev,struct ptys2ethtool_config **arr, u32 *size) { - bool ext = mlx5e_ptys_ext_supported(mdev); + bool ext = mlx5_ptys_ext_supported(mdev); *arr = ext ? ptys2ext_ethtool_table : ptys2legacy_ethtool_table; *size = ext ? ARRAY_SIZE(ptys2ext_ethtool_table) :
@@ -895,7 +895,7 @@ static void get_speed_duplex(struct net_device *netdev,if (!netif_carrier_ok (netdev)) goto out; - speed =mlx5e_port_ptys2speed (priv->mdev, eth_proto_oper, force_legacy); + speed =mlx5_port_ptys2speed (priv->mdev, eth_proto_oper, force_legacy);if (!speed) {if (data_rate_oper) speed =100 * data_rate_oper;
@@ -980,7 +980,7 @@ static void get_lp_advertising(struct mlx5_core_dev *mdev, u32 eth_proto_lp, struct ethtool_link_ksettings *link_ksettings) {unsigned long *lp_advertising = link_ksettings->link_modes.lp_advertising; -bool ext =mlx5e_ptys_ext_supported (mdev); +bool ext =mlx5_ptys_ext_supported (mdev);ptys2ethtool_adver_link (lp_advertising, eth_proto_lp, ext); }
@@ -1160,7 +1160,7 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, const struct ethtool_link_ksettings *link_ksettings) {struct mlx5_core_dev *mdev = priv->mdev; -struct mlx5e_port_eth_proto eproto; +struct mlx5_port_eth_proto eproto;const unsigned long *adver;bool an_changes = false;u8 an_disable_admin;
@@ -1180,7 +1180,7 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, autoneg = link_ksettings->base.autoneg; speed = link_ksettings->base.speed; - ext_supported =mlx5e_ptys_ext_supported (mdev); + ext_supported =mlx5_ptys_ext_supported (mdev); ext =ext_requested (autoneg, adver, ext_supported);if (!ext_supported && ext)return -EOPNOTSUPP ;
@@ -1194,7 +1194,7 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, goto out; } link_modes = autoneg ==AUTONEG_ENABLE ?ethtool2ptys_adver_func (adver) : -mlx5e_port_speed2linkmodes (mdev, speed, !ext); +mlx5_port_speed2linkmodes (mdev, speed, !ext); err =mlx5e_speed_validate (priv->netdev, ext, link_modes, autoneg);if (err)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -1
@@ -1108,7 +1108,7 @@ mlx5e_hairpin_params_init(struct mlx5e_hairpin_params *hairpin_params, hairpin_params->mdev = mdev;/* set hairpin pair per each 50Gbs share of the link */ -mlx5e_port_max_linkspeed (mdev, &link_speed); +mlx5_port_max_linkspeed (mdev, &link_speed); link_speed =max_t (u32, link_speed,50000 ); link_speed64 = link_speed;do_div (link_speed64,50000 );
drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c +1 -1
@@ -744,7 +744,7 @@ static int esw_qos_devlink_rate_to_mbps(struct mlx5_core_dev *mdev, const char *u64 value;int err; - err =mlx5e_port_max_linkspeed (mdev, &link_speed_max); + err =mlx5_port_max_linkspeed (mdev, &link_speed_max);if (err) {NL_SET_ERR_MSG_MOD (extack,"Failed to get link maximum speed" );return err;
drivers/net/ethernet/mellanox/mlx5/core/port.c +151 -0
154 lines not on this page · raw message
include/linux/mlx5/port.h +16 -0
@@ -141,6 +141,12 @@ enum mlx5_ptys_width { MLX5_PTYS_WIDTH_12X = 1 << 4, }; +struct mlx5_port_eth_proto { +u32 cap; +u32 admin; +u32 oper; +}; +#define MLX5E_PROT_MASK (link_mode) (1U << link_mode)#define MLX5_GET_ETH_PROTO (reg, out, ext, field) \ (ext ? MLX5_GET(reg, out, ext_##field) : \
@@ -218,4 +224,14 @@ int mlx5_set_trust_state(struct mlx5_core_dev *mdev, u8 trust_state);int mlx5_query_trust_state (struct mlx5_core_dev *mdev,u8 *trust_state);int mlx5_set_dscp2prio (struct mlx5_core_dev *mdev,u8 dscp,u8 prio);int mlx5_query_dscp2prio (struct mlx5_core_dev *mdev,u8 *dscp2prio); + +int mlx5_port_query_eth_proto (struct mlx5_core_dev *dev,u8 port,bool ext, +struct mlx5_port_eth_proto *eproto); +bool mlx5_ptys_ext_supported (struct mlx5_core_dev *mdev); +u32 mlx5_port_ptys2speed (struct mlx5_core_dev *mdev,u32 eth_proto_oper, +bool force_legacy); +u32 mlx5_port_speed2linkmodes (struct mlx5_core_dev *mdev,u32 speed, +bool force_legacy); +int mlx5_port_max_linkspeed (struct mlx5_core_dev *mdev,u32 *speed); +#endif /* __MLX5_PORT_H__ */
Signature · 1 line
2.39.1
PATCH 4/4 net/mlx5e: Add more information to hairpin table dump
In reply to Saeed MahameedFrom: Gal Pressman <[email protected]>
Print the number of hairpin queues and size as part of the hairpin table dump.
Issue: 3222646
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -2
@@ -583,6 +583,7 @@ struct mlx5e_hairpin {struct mlx5e_tir direct_tir;int num_channels; +u8 log_num_packets;struct mlx5e_rqt indir_rqt;struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS ];struct mlx5_ttc_table *ttc;
@@ -929,6 +930,7 @@ mlx5e_hairpin_create(struct mlx5e_priv *priv, struct mlx5_hairpin_params *params hp->func_mdev = func_mdev; hp->func_priv = priv; hp->num_channels = params->num_channels; + hp->log_num_packets = params->log_num_packets; err =mlx5e_hairpin_create_transport (hp);if (err)
@@ -1070,9 +1072,11 @@ static int debugfs_hairpin_table_dump_show(struct seq_file *file, void *priv)mutex_lock (&tc->hairpin_tbl_lock);hash_for_each (tc->hairpin_tbl, bkt, hpe, hairpin_hlist) -seq_printf (file,"Hairpin peer_vhca_id %u prio %u refcnt %u\n" , +seq_printf (file, +"Hairpin peer_vhca_id %u prio %u refcnt %u num_channels %u num_packets %lu\n" , hpe->peer_vhca_id, hpe->prio, -refcount_read (&hpe->refcnt)); +refcount_read (&hpe->refcnt), hpe->hp->num_channels, +BIT (hpe->hp->log_num_packets));mutex_unlock (&tc->hairpin_tbl_lock);return 0 ;
Signature · 1 line
2.39.1
PATCH 3/4 net/mlx5e: Add devlink hairpin queues parameters
In reply to Saeed MahameedFrom: Gal Pressman <[email protected]>
We refer to a TC NIC rule that involves forwarding as "hairpin". Hairpin queues are mlx5 hardware specific implementation for hardware forwarding of such packets.
Per the discussion in [1], move the hairpin queues control (number and size) from debugfs to devlink.
Expose two devlink params:
- hairpin_num_queues: control the number of hairpin queues
- hairpin_queue_size: control the size (in packets) of the hairpin queues
[1] https://lore.kernel.org/all/[email protected]/
Issue: 3222646
--- .../ethernet/mellanox/mlx5/devlink.rst | 35 ++++++++++ Documentation/networking/devlink/mlx5.rst | 12 ++++ .../net/ethernet/mellanox/mlx5/core/devlink.c | 66 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/devlink.h | 2 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 50 ++++++-------- 5 files changed, 134 insertions(+), 31 deletions(-)
Documentation/networking/device_drivers/ethernet/mellanox/mlx5/devlink.rst +35 -0
@@ -122,6 +122,41 @@ users try to enable them. $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev +hairpin_num_queues: Number of hairpin queues +-------------------------------------------- +We refer to a TC NIC rule that involves forwarding as "hairpin". + +Hairpin queues are mlx5 hardware specific implementation for hardware +forwarding of such packets. + +- Show the number of hairpin queues:: + + $ devlink dev param show pci/0000:06:00.0 name hairpin_num_queues + pci/0000:06:00.0: + name hairpin_num_queues type driver-specific + values: + cmode driverinit value 2 + +- Change the number of hairpin queues:: + + $ devlink dev param set pci/0000:06:00.0 name hairpin_num_queues value 4 cmode driverinit + +hairpin_queue_size: Size of the hairpin queues +---------------------------------------------- +Control the size of the hairpin queues. + +- Show the size of the hairpin queues:: + + $ devlink dev param show pci/0000:06:00.0 name hairpin_queue_size + pci/0000:06:00.0: + name hairpin_queue_size type driver-specific + values: + cmode driverinit value 1024 + +- Change the size (in packets) of the hairpin queues:: + + $ devlink dev param set pci/0000:06:00.0 name hairpin_queue_size value 512 cmode driverinit + Health reporters ================
Documentation/networking/devlink/mlx5.rst +12 -0
@@ -72,6 +72,18 @@ parameters. Default: disabled + * - ``hairpin_num_queues`` + - u32 + - driverinit + - We refer to a TC NIC rule that involves forwarding as "hairpin". + Hairpin queues are mlx5 hardware specific implementation for hardware + forwarding of such packets. + + Control the number of hairpin queues. + * - ``hairpin_queue_size`` + - u32 + - driverinit + - Control the size (in packets) of the hairpin queues. The ``mlx5`` driver supports reloading via ``DEVLINK_CMD_RELOAD``
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +66 -0
84 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/devlink.h +2 -0
@@ -12,6 +12,8 @@ enum mlx5_devlink_param_id {MLX5_DEVLINK_PARAM_ID_ESW_LARGE_GROUP_NUM ,MLX5_DEVLINK_PARAM_ID_ESW_PORT_METADATA ,MLX5_DEVLINK_PARAM_ID_ESW_MULTIPORT , +MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES , + MLX5_DEVLINK_PARAM_ID_HAIRPIN_QUEUE_SIZE, }; struct mlx5_trap_ctx {
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +19 -31
99 lines not on this page · raw message
Signature · 1 line
2.39.1