Skip to content

Commit b10d10a

Browse files
committed
Merge tag 'mlx5-updates-2023-07-24' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2023-07-24 1) Generalize devcom implementation to be independent of number of ports or device's GUID. 2) Save memory on command interface statistics. 3) General code cleanups * tag 'mlx5-updates-2023-07-24' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5: Give esw_offloads_load/unload_rep() "mlx5_" prefix net/mlx5: Make mlx5_eswitch_load/unload_vport() static net/mlx5: Make mlx5_esw_offloads_rep_load/unload() static net/mlx5: Remove pointless devlink_rate checks net/mlx5: Don't check vport->enabled in port ops net/mlx5e: Make flow classification filters static net/mlx5e: Remove duplicate code for user flow net/mlx5: Allocate command stats with xarray net/mlx5: split mlx5_cmd_init() to probe and reload routines net/mlx5: Remove redundant cmdif revision check net/mlx5: Re-organize mlx5_cmd struct net/mlx5e: E-Switch, Allow devcom initialization on more vports net/mlx5e: E-Switch, Register devcom device with switch id key net/mlx5: Devcom, Infrastructure changes net/mlx5: Use shared code for checking lag is supported ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 97d0dca + 9eca8bb commit b10d10a

File tree

21 files changed

+579
-538
lines changed

21 files changed

+579
-538
lines changed

drivers/net/ethernet/mellanox/mlx5/core/cmd.c

Lines changed: 114 additions & 109 deletions
Large diffs are not rendered by default.

drivers/net/ethernet/mellanox/mlx5/core/debugfs.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ static ssize_t slots_read(struct file *filp, char __user *buf, size_t count,
176176
int ret;
177177

178178
cmd = filp->private_data;
179-
weight = bitmap_weight(&cmd->bitmask, cmd->max_reg_cmds);
180-
field = cmd->max_reg_cmds - weight;
179+
weight = bitmap_weight(&cmd->vars.bitmask, cmd->vars.max_reg_cmds);
180+
field = cmd->vars.max_reg_cmds - weight;
181181
ret = snprintf(tbuf, sizeof(tbuf), "%d\n", field);
182182
return simple_read_from_buffer(buf, count, pos, tbuf, ret);
183183
}
@@ -188,6 +188,24 @@ static const struct file_operations slots_fops = {
188188
.read = slots_read,
189189
};
190190

191+
static struct mlx5_cmd_stats *
192+
mlx5_cmdif_alloc_stats(struct xarray *stats_xa, int opcode)
193+
{
194+
struct mlx5_cmd_stats *stats = kzalloc(sizeof(*stats), GFP_KERNEL);
195+
int err;
196+
197+
if (!stats)
198+
return NULL;
199+
200+
err = xa_insert(stats_xa, opcode, stats, GFP_KERNEL);
201+
if (err) {
202+
kfree(stats);
203+
return NULL;
204+
}
205+
spin_lock_init(&stats->lock);
206+
return stats;
207+
}
208+
191209
void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev)
192210
{
193211
struct mlx5_cmd_stats *stats;
@@ -200,10 +218,14 @@ void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev)
200218

201219
debugfs_create_file("slots_inuse", 0400, *cmd, &dev->cmd, &slots_fops);
202220

221+
xa_init(&dev->cmd.stats);
222+
203223
for (i = 0; i < MLX5_CMD_OP_MAX; i++) {
204-
stats = &dev->cmd.stats[i];
205224
namep = mlx5_command_str(i);
206225
if (strcmp(namep, "unknown command opcode")) {
226+
stats = mlx5_cmdif_alloc_stats(&dev->cmd.stats, i);
227+
if (!stats)
228+
continue;
207229
stats->root = debugfs_create_dir(namep, *cmd);
208230

209231
debugfs_create_file("average", 0400, stats->root, stats,
@@ -224,7 +246,13 @@ void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev)
224246

225247
void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev)
226248
{
249+
struct mlx5_cmd_stats *stats;
250+
unsigned long i;
251+
227252
debugfs_remove_recursive(dev->priv.dbg.cmdif_debugfs);
253+
xa_for_each(&dev->cmd.stats, i, stats)
254+
kfree(stats);
255+
xa_destroy(&dev->cmd.stats);
228256
}
229257

230258
void mlx5_cq_debugfs_init(struct mlx5_core_dev *dev)

drivers/net/ethernet/mellanox/mlx5/core/dev.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/mlx5/vport.h>
3737
#include "mlx5_core.h"
3838
#include "devlink.h"
39+
#include "lag/lag.h"
3940

4041
/* intf dev list mutex */
4142
static DEFINE_MUTEX(mlx5_intf_mutex);
@@ -587,10 +588,7 @@ static int next_phys_dev_lag(struct device *dev, const void *data)
587588
if (!mdev)
588589
return 0;
589590

590-
if (!MLX5_CAP_GEN(mdev, vport_group_manager) ||
591-
!MLX5_CAP_GEN(mdev, lag_master) ||
592-
(MLX5_CAP_GEN(mdev, num_lag_ports) > MLX5_MAX_PORTS ||
593-
MLX5_CAP_GEN(mdev, num_lag_ports) <= 1))
591+
if (!mlx5_lag_is_supported(mdev))
594592
return 0;
595593

596594
return _next_phys_dev(mdev, data);

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,6 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
11671167
int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc);
11681168
int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, const u8 *key,
11691169
const u8 hfunc);
1170-
int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
1171-
u32 *rule_locs);
1172-
int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd);
11731170
u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv);
11741171
u32 mlx5e_ethtool_get_rxfh_indir_size(struct mlx5e_priv *priv);
11751172
int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,8 +2163,8 @@ static u32 mlx5e_get_priv_flags(struct net_device *netdev)
21632163
return priv->channels.params.pflags;
21642164
}
21652165

2166-
int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
2167-
u32 *rule_locs)
2166+
static int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
2167+
u32 *rule_locs)
21682168
{
21692169
struct mlx5e_priv *priv = netdev_priv(dev);
21702170

@@ -2181,7 +2181,7 @@ int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
21812181
return mlx5e_ethtool_get_rxnfc(priv, info, rule_locs);
21822182
}
21832183

2184-
int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
2184+
static int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
21852185
{
21862186
struct mlx5e_priv *priv = netdev_priv(dev);
21872187

drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv,
9696
case UDP_V4_FLOW:
9797
case TCP_V6_FLOW:
9898
case UDP_V6_FLOW:
99-
max_tuples = ETHTOOL_NUM_L3_L4_FTS;
100-
prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
101-
eth_ft = &ethtool->l3_l4_ft[prio];
102-
break;
10399
case IP_USER_FLOW:
104100
case IPV6_USER_FLOW:
105101
max_tuples = ETHTOOL_NUM_L3_L4_FTS;

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,13 @@ static void mlx5e_sqs2vport_stop(struct mlx5_eswitch *esw,
399399
}
400400

401401
static int mlx5e_sqs2vport_add_peers_rules(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep,
402-
struct mlx5_devcom *devcom,
403402
struct mlx5e_rep_sq *rep_sq, int i)
404403
{
405-
struct mlx5_eswitch *peer_esw = NULL;
406404
struct mlx5_flow_handle *flow_rule;
407-
int tmp;
405+
struct mlx5_devcom_comp_dev *tmp;
406+
struct mlx5_eswitch *peer_esw;
408407

409-
mlx5_devcom_for_each_peer_entry(devcom, MLX5_DEVCOM_ESW_OFFLOADS,
410-
peer_esw, tmp) {
408+
mlx5_devcom_for_each_peer_entry(esw->devcom, peer_esw, tmp) {
411409
u16 peer_rule_idx = MLX5_CAP_GEN(peer_esw->dev, vhca_id);
412410
struct mlx5e_rep_sq_peer *sq_peer;
413411
int err;
@@ -443,18 +441,17 @@ static int mlx5e_sqs2vport_start(struct mlx5_eswitch *esw,
443441
struct mlx5_flow_handle *flow_rule;
444442
struct mlx5e_rep_priv *rpriv;
445443
struct mlx5e_rep_sq *rep_sq;
446-
struct mlx5_devcom *devcom;
447444
bool devcom_locked = false;
448445
int err;
449446
int i;
450447

451448
if (esw->mode != MLX5_ESWITCH_OFFLOADS)
452449
return 0;
453450

454-
devcom = esw->dev->priv.devcom;
455451
rpriv = mlx5e_rep_to_rep_priv(rep);
456-
if (mlx5_devcom_comp_is_ready(devcom, MLX5_DEVCOM_ESW_OFFLOADS) &&
457-
mlx5_devcom_for_each_peer_begin(devcom, MLX5_DEVCOM_ESW_OFFLOADS))
452+
453+
if (mlx5_devcom_comp_is_ready(esw->devcom) &&
454+
mlx5_devcom_for_each_peer_begin(esw->devcom))
458455
devcom_locked = true;
459456

460457
for (i = 0; i < sqns_num; i++) {
@@ -477,7 +474,7 @@ static int mlx5e_sqs2vport_start(struct mlx5_eswitch *esw,
477474

478475
xa_init(&rep_sq->sq_peer);
479476
if (devcom_locked) {
480-
err = mlx5e_sqs2vport_add_peers_rules(esw, rep, devcom, rep_sq, i);
477+
err = mlx5e_sqs2vport_add_peers_rules(esw, rep, rep_sq, i);
481478
if (err) {
482479
mlx5_eswitch_del_send_to_vport_rule(rep_sq->send_to_vport_rule);
483480
xa_destroy(&rep_sq->sq_peer);
@@ -490,15 +487,15 @@ static int mlx5e_sqs2vport_start(struct mlx5_eswitch *esw,
490487
}
491488

492489
if (devcom_locked)
493-
mlx5_devcom_for_each_peer_end(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
490+
mlx5_devcom_for_each_peer_end(esw->devcom);
494491

495492
return 0;
496493

497494
out_err:
498495
mlx5e_sqs2vport_stop(esw, rep);
499496

500497
if (devcom_locked)
501-
mlx5_devcom_for_each_peer_end(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
498+
mlx5_devcom_for_each_peer_end(esw->devcom);
502499

503500
return err;
504501
}

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,11 +1668,10 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
16681668
{
16691669
struct mlx5e_priv *out_priv, *route_priv;
16701670
struct mlx5_core_dev *route_mdev;
1671-
struct mlx5_devcom *devcom;
1671+
struct mlx5_devcom_comp_dev *pos;
16721672
struct mlx5_eswitch *esw;
16731673
u16 vhca_id;
16741674
int err;
1675-
int i;
16761675

16771676
out_priv = netdev_priv(out_dev);
16781677
esw = out_priv->mdev->priv.eswitch;
@@ -1688,10 +1687,8 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
16881687
return err;
16891688

16901689
rcu_read_lock();
1691-
devcom = out_priv->mdev->priv.devcom;
16921690
err = -ENODEV;
1693-
mlx5_devcom_for_each_peer_entry_rcu(devcom, MLX5_DEVCOM_ESW_OFFLOADS,
1694-
esw, i) {
1691+
mlx5_devcom_for_each_peer_entry_rcu(esw->devcom, esw, pos) {
16951692
err = mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
16961693
if (!err)
16971694
break;
@@ -2031,15 +2028,15 @@ static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
20312028
struct mlx5e_tc_flow *flow)
20322029
{
20332030
if (mlx5e_is_eswitch_flow(flow)) {
2034-
struct mlx5_devcom *devcom = flow->priv->mdev->priv.devcom;
2031+
struct mlx5_devcom_comp_dev *devcom = flow->priv->mdev->priv.eswitch->devcom;
20352032

2036-
if (!mlx5_devcom_for_each_peer_begin(devcom, MLX5_DEVCOM_ESW_OFFLOADS)) {
2033+
if (!mlx5_devcom_for_each_peer_begin(devcom)) {
20372034
mlx5e_tc_del_fdb_flow(priv, flow);
20382035
return;
20392036
}
20402037

20412038
mlx5e_tc_del_fdb_peers_flow(flow);
2042-
mlx5_devcom_for_each_peer_end(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
2039+
mlx5_devcom_for_each_peer_end(devcom);
20432040
mlx5e_tc_del_fdb_flow(priv, flow);
20442041
} else {
20452042
mlx5e_tc_del_nic_flow(priv, flow);
@@ -4216,8 +4213,7 @@ static bool is_peer_flow_needed(struct mlx5e_tc_flow *flow)
42164213
flow_flag_test(flow, INGRESS);
42174214
bool act_is_encap = !!(attr->action &
42184215
MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT);
4219-
bool esw_paired = mlx5_devcom_comp_is_ready(esw_attr->in_mdev->priv.devcom,
4220-
MLX5_DEVCOM_ESW_OFFLOADS);
4216+
bool esw_paired = mlx5_devcom_comp_is_ready(esw_attr->in_mdev->priv.eswitch->devcom);
42214217

42224218
if (!esw_paired)
42234219
return false;
@@ -4471,14 +4467,13 @@ mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
44714467
struct net_device *filter_dev,
44724468
struct mlx5e_tc_flow **__flow)
44734469
{
4474-
struct mlx5_devcom *devcom = priv->mdev->priv.devcom;
4470+
struct mlx5_devcom_comp_dev *devcom = priv->mdev->priv.eswitch->devcom, *pos;
44754471
struct mlx5e_rep_priv *rpriv = priv->ppriv;
44764472
struct mlx5_eswitch_rep *in_rep = rpriv->rep;
44774473
struct mlx5_core_dev *in_mdev = priv->mdev;
44784474
struct mlx5_eswitch *peer_esw;
44794475
struct mlx5e_tc_flow *flow;
44804476
int err;
4481-
int i;
44824477

44834478
flow = __mlx5e_add_fdb_flow(priv, f, flow_flags, filter_dev, in_rep,
44844479
in_mdev);
@@ -4490,27 +4485,25 @@ mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
44904485
return 0;
44914486
}
44924487

4493-
if (!mlx5_devcom_for_each_peer_begin(devcom, MLX5_DEVCOM_ESW_OFFLOADS)) {
4488+
if (!mlx5_devcom_for_each_peer_begin(devcom)) {
44944489
err = -ENODEV;
44954490
goto clean_flow;
44964491
}
44974492

4498-
mlx5_devcom_for_each_peer_entry(devcom,
4499-
MLX5_DEVCOM_ESW_OFFLOADS,
4500-
peer_esw, i) {
4493+
mlx5_devcom_for_each_peer_entry(devcom, peer_esw, pos) {
45014494
err = mlx5e_tc_add_fdb_peer_flow(f, flow, flow_flags, peer_esw);
45024495
if (err)
45034496
goto peer_clean;
45044497
}
45054498

4506-
mlx5_devcom_for_each_peer_end(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
4499+
mlx5_devcom_for_each_peer_end(devcom);
45074500

45084501
*__flow = flow;
45094502
return 0;
45104503

45114504
peer_clean:
45124505
mlx5e_tc_del_fdb_peers_flow(flow);
4513-
mlx5_devcom_for_each_peer_end(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
4506+
mlx5_devcom_for_each_peer_end(devcom);
45144507
clean_flow:
45154508
mlx5e_tc_del_fdb_flow(priv, flow);
45164509
return err;
@@ -4728,7 +4721,7 @@ int mlx5e_tc_fill_action_stats(struct mlx5e_priv *priv,
47284721
int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
47294722
struct flow_cls_offload *f, unsigned long flags)
47304723
{
4731-
struct mlx5_devcom *devcom = priv->mdev->priv.devcom;
4724+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
47324725
struct rhashtable *tc_ht = get_tc_ht(priv, flags);
47334726
struct mlx5e_tc_flow *flow;
47344727
struct mlx5_fc *counter;
@@ -4764,7 +4757,7 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
47644757
/* Under multipath it's possible for one rule to be currently
47654758
* un-offloaded while the other rule is offloaded.
47664759
*/
4767-
if (!mlx5_devcom_for_each_peer_begin(devcom, MLX5_DEVCOM_ESW_OFFLOADS))
4760+
if (esw && !mlx5_devcom_for_each_peer_begin(esw->devcom))
47684761
goto out;
47694762

47704763
if (flow_flag_test(flow, DUP)) {
@@ -4795,7 +4788,8 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
47954788
}
47964789

47974790
no_peer_counter:
4798-
mlx5_devcom_for_each_peer_end(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
4791+
if (esw)
4792+
mlx5_devcom_for_each_peer_end(esw->devcom);
47994793
out:
48004794
flow_stats_update(&f->stats, bytes, packets, 0, lastuse,
48014795
FLOW_ACTION_HW_STATS_DELAYED);
@@ -5200,11 +5194,12 @@ void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht)
52005194
int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
52015195
{
52025196
const size_t sz_enc_opts = sizeof(struct tunnel_match_enc_opts);
5197+
struct netdev_phys_item_id ppid;
52035198
struct mlx5e_rep_priv *rpriv;
52045199
struct mapping_ctx *mapping;
52055200
struct mlx5_eswitch *esw;
52065201
struct mlx5e_priv *priv;
5207-
u64 mapping_id;
5202+
u64 mapping_id, key;
52085203
int err = 0;
52095204

52105205
rpriv = container_of(uplink_priv, struct mlx5e_rep_priv, uplink_priv);
@@ -5258,7 +5253,11 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
52585253
goto err_action_counter;
52595254
}
52605255

5261-
mlx5_esw_offloads_devcom_init(esw);
5256+
err = dev_get_port_parent_id(priv->netdev, &ppid, false);
5257+
if (!err) {
5258+
memcpy(&key, &ppid.id, sizeof(key));
5259+
mlx5_esw_offloads_devcom_init(esw, key);
5260+
}
52625261

52635262
return 0;
52645263

0 commit comments

Comments
 (0)