Skip to content

Commit

Permalink
Merge tag 'mlx5-updates-2023-02-07' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5-updates-2023-02-07

1) Minor and trivial code Cleanups

2) Minor fixes for net-next

3) From Shay: dynamic FW trace strings update.

* tag 'mlx5-updates-2023-02-07' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux:
  net/mlx5: fw_tracer, Add support for unrecognized string
  net/mlx5: fw_tracer, Add support for strings DB update event
  net/mlx5: fw_tracer, allow 0 size string DBs
  net/mlx5: fw_tracer: Fix debug print
  net/mlx5: fs, Remove redundant assignment of size
  net/mlx5: fs_core, Remove redundant variable err
  net/mlx5: Fix memory leak in error flow of port set buffer
  net/mlx5e: Remove incorrect debugfs_create_dir NULL check in TLS
  net/mlx5e: Remove incorrect debugfs_create_dir NULL check in hairpin
  net/mlx5: fs, Remove redundant vport_number assignment
  net/mlx5e: Remove redundant code for handling vlan actions
  net/mlx5e: Don't listen to remove flows event
  net/mlx5: fw reset: Skip device ID check if PCI link up failed
  net/mlx5: Remove redundant health work lock
  mlx5: reduce stack usage in mlx5_setup_tc
====================

Link: https://lore.kernel.org/r/20230208003712.68386-1-saeed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Feb 9, 2023
2 parents e6ebe6c + f713313 commit 7eadc0a
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 299 deletions.
79 changes: 70 additions & 9 deletions drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ static int mlx5_fw_tracer_allocate_strings_db(struct mlx5_fw_tracer *tracer)
int i;

for (i = 0; i < num_string_db; i++) {
if (!string_db_size_out[i])
continue;
tracer->str_db.buffer[i] = kzalloc(string_db_size_out[i], GFP_KERNEL);
if (!tracer->str_db.buffer[i])
goto free_strings_db;
Expand Down Expand Up @@ -278,6 +280,8 @@ static void mlx5_tracer_read_strings_db(struct work_struct *work)
}

for (i = 0; i < num_string_db; i++) {
if (!tracer->str_db.size_out[i])
continue;
offset = 0;
MLX5_SET(mtrc_stdb, in, string_db_index, i);
num_of_reads = tracer->str_db.size_out[i] /
Expand Down Expand Up @@ -384,6 +388,8 @@ static struct tracer_string_format *mlx5_tracer_get_string(struct mlx5_fw_tracer
str_ptr = tracer_event->string_event.string_param;

for (i = 0; i < tracer->str_db.num_string_db; i++) {
if (!tracer->str_db.size_out[i])
continue;
if (str_ptr > tracer->str_db.base_address_out[i] &&
str_ptr < tracer->str_db.base_address_out[i] +
tracer->str_db.size_out[i]) {
Expand Down Expand Up @@ -459,6 +465,7 @@ static void poll_trace(struct mlx5_fw_tracer *tracer,

tracer_event->event_id = MLX5_GET(tracer_event, trace, event_id);
tracer_event->lost_event = MLX5_GET(tracer_event, trace, lost);
tracer_event->out = trace;

switch (tracer_event->event_id) {
case TRACER_EVENT_TYPE_TIMESTAMP:
Expand Down Expand Up @@ -581,6 +588,26 @@ void mlx5_tracer_print_trace(struct tracer_string_format *str_frmt,
mlx5_tracer_clean_message(str_frmt);
}

static int mlx5_tracer_handle_raw_string(struct mlx5_fw_tracer *tracer,
struct tracer_event *tracer_event)
{
struct tracer_string_format *cur_string;

cur_string = mlx5_tracer_message_insert(tracer, tracer_event);
if (!cur_string)
return -1;

cur_string->event_id = tracer_event->event_id;
cur_string->timestamp = tracer_event->string_event.timestamp;
cur_string->lost = tracer_event->lost_event;
cur_string->string = "0x%08x%08x";
cur_string->num_of_params = 2;
cur_string->params[0] = upper_32_bits(*tracer_event->out);
cur_string->params[1] = lower_32_bits(*tracer_event->out);
list_add_tail(&cur_string->list, &tracer->ready_strings_list);
return 0;
}

static int mlx5_tracer_handle_string_trace(struct mlx5_fw_tracer *tracer,
struct tracer_event *tracer_event)
{
Expand All @@ -589,7 +616,7 @@ static int mlx5_tracer_handle_string_trace(struct mlx5_fw_tracer *tracer,
if (tracer_event->string_event.tdsn == 0) {
cur_string = mlx5_tracer_get_string(tracer, tracer_event);
if (!cur_string)
return -1;
return mlx5_tracer_handle_raw_string(tracer, tracer_event);

cur_string->num_of_params = mlx5_tracer_get_num_of_params(cur_string->string);
cur_string->last_param_num = 0;
Expand All @@ -602,9 +629,9 @@ static int mlx5_tracer_handle_string_trace(struct mlx5_fw_tracer *tracer,
} else {
cur_string = mlx5_tracer_message_get(tracer, tracer_event);
if (!cur_string) {
pr_debug("%s Got string event for unknown string tdsm: %d\n",
pr_debug("%s Got string event for unknown string tmsn: %d\n",
__func__, tracer_event->string_event.tmsn);
return -1;
return mlx5_tracer_handle_raw_string(tracer, tracer_event);
}
cur_string->last_param_num += 1;
if (cur_string->last_param_num > TRACER_MAX_PARAMS) {
Expand Down Expand Up @@ -930,6 +957,14 @@ int mlx5_fw_tracer_get_saved_traces_objects(struct mlx5_fw_tracer *tracer,
return err;
}

static void mlx5_fw_tracer_update_db(struct work_struct *work)
{
struct mlx5_fw_tracer *tracer =
container_of(work, struct mlx5_fw_tracer, update_db_work);

mlx5_fw_tracer_reload(tracer);
}

/* Create software resources (Buffers, etc ..) */
struct mlx5_fw_tracer *mlx5_fw_tracer_create(struct mlx5_core_dev *dev)
{
Expand Down Expand Up @@ -957,6 +992,8 @@ struct mlx5_fw_tracer *mlx5_fw_tracer_create(struct mlx5_core_dev *dev)
INIT_WORK(&tracer->ownership_change_work, mlx5_fw_tracer_ownership_change);
INIT_WORK(&tracer->read_fw_strings_work, mlx5_tracer_read_strings_db);
INIT_WORK(&tracer->handle_traces_work, mlx5_fw_tracer_handle_traces);
INIT_WORK(&tracer->update_db_work, mlx5_fw_tracer_update_db);
mutex_init(&tracer->state_lock);


err = mlx5_query_mtrc_caps(tracer);
Expand Down Expand Up @@ -1003,11 +1040,15 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)
if (IS_ERR_OR_NULL(tracer))
return 0;

dev = tracer->dev;

if (!tracer->str_db.loaded)
queue_work(tracer->work_queue, &tracer->read_fw_strings_work);

mutex_lock(&tracer->state_lock);
if (test_and_set_bit(MLX5_TRACER_STATE_UP, &tracer->state))
goto unlock;

dev = tracer->dev;

err = mlx5_core_alloc_pd(dev, &tracer->buff.pdn);
if (err) {
mlx5_core_warn(dev, "FWTracer: Failed to allocate PD %d\n", err);
Expand All @@ -1028,6 +1069,8 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)
mlx5_core_warn(dev, "FWTracer: Failed to start tracer %d\n", err);
goto err_notifier_unregister;
}
unlock:
mutex_unlock(&tracer->state_lock);
return 0;

err_notifier_unregister:
Expand All @@ -1037,6 +1080,7 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)
mlx5_core_dealloc_pd(dev, tracer->buff.pdn);
err_cancel_work:
cancel_work_sync(&tracer->read_fw_strings_work);
mutex_unlock(&tracer->state_lock);
return err;
}

Expand All @@ -1046,17 +1090,27 @@ void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer)
if (IS_ERR_OR_NULL(tracer))
return;

mutex_lock(&tracer->state_lock);
if (!test_and_clear_bit(MLX5_TRACER_STATE_UP, &tracer->state))
goto unlock;

mlx5_core_dbg(tracer->dev, "FWTracer: Cleanup, is owner ? (%d)\n",
tracer->owner);
mlx5_eq_notifier_unregister(tracer->dev, &tracer->nb);
cancel_work_sync(&tracer->ownership_change_work);
cancel_work_sync(&tracer->handle_traces_work);
/* It is valid to get here from update_db_work. Hence, don't wait for
* update_db_work to finished.
*/
cancel_work(&tracer->update_db_work);

if (tracer->owner)
mlx5_fw_tracer_ownership_release(tracer);

mlx5_core_destroy_mkey(tracer->dev, tracer->buff.mkey);
mlx5_core_dealloc_pd(tracer->dev, tracer->buff.pdn);
unlock:
mutex_unlock(&tracer->state_lock);
}

/* Free software resources (Buffers, etc ..) */
Expand All @@ -1073,6 +1127,7 @@ void mlx5_fw_tracer_destroy(struct mlx5_fw_tracer *tracer)
mlx5_fw_tracer_clean_saved_traces_array(tracer);
mlx5_fw_tracer_free_strings_db(tracer);
mlx5_fw_tracer_destroy_log_buf(tracer);
mutex_destroy(&tracer->state_lock);
destroy_workqueue(tracer->work_queue);
kvfree(tracer);
}
Expand All @@ -1082,6 +1137,8 @@ static int mlx5_fw_tracer_recreate_strings_db(struct mlx5_fw_tracer *tracer)
struct mlx5_core_dev *dev;
int err;

if (test_and_set_bit(MLX5_TRACER_RECREATE_DB, &tracer->state))
return 0;
cancel_work_sync(&tracer->read_fw_strings_work);
mlx5_fw_tracer_clean_ready_list(tracer);
mlx5_fw_tracer_clean_print_hash(tracer);
Expand All @@ -1092,17 +1149,18 @@ static int mlx5_fw_tracer_recreate_strings_db(struct mlx5_fw_tracer *tracer)
err = mlx5_query_mtrc_caps(tracer);
if (err) {
mlx5_core_dbg(dev, "FWTracer: Failed to query capabilities %d\n", err);
return err;
goto out;
}

err = mlx5_fw_tracer_allocate_strings_db(tracer);
if (err) {
mlx5_core_warn(dev, "FWTracer: Allocate strings DB failed %d\n", err);
return err;
goto out;
}
mlx5_fw_tracer_init_saved_traces_array(tracer);

return 0;
out:
clear_bit(MLX5_TRACER_RECREATE_DB, &tracer->state);
return err;
}

int mlx5_fw_tracer_reload(struct mlx5_fw_tracer *tracer)
Expand Down Expand Up @@ -1142,6 +1200,9 @@ static int fw_tracer_event(struct notifier_block *nb, unsigned long action, void
case MLX5_TRACER_SUBTYPE_TRACES_AVAILABLE:
queue_work(tracer->work_queue, &tracer->handle_traces_work);
break;
case MLX5_TRACER_SUBTYPE_STRINGS_DB_UPDATE:
queue_work(tracer->work_queue, &tracer->update_db_work);
break;
default:
mlx5_core_dbg(dev, "FWTracer: Event with unrecognized subtype: sub_type %d\n",
eqe->sub_type);
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ struct mlx5_fw_trace_data {
char msg[TRACE_STR_MSG];
};

enum mlx5_fw_tracer_state {
MLX5_TRACER_STATE_UP = BIT(0),
MLX5_TRACER_RECREATE_DB = BIT(1),
};

struct mlx5_fw_tracer {
struct mlx5_core_dev *dev;
struct mlx5_nb nb;
Expand Down Expand Up @@ -104,6 +109,9 @@ struct mlx5_fw_tracer {
struct work_struct handle_traces_work;
struct hlist_head hash[MESSAGE_HASH_SIZE];
struct list_head ready_strings_list;
struct work_struct update_db_work;
struct mutex state_lock; /* Synchronize update work with reload flows */
unsigned long state;
};

struct tracer_string_format {
Expand Down Expand Up @@ -158,6 +166,7 @@ struct tracer_event {
struct tracer_string_event string_event;
struct tracer_timestamp_event timestamp_event;
};
u64 *out;
};

struct mlx5_ifc_tracer_event_bits {
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ static int port_set_buffer(struct mlx5e_priv *priv,
err = port_update_shared_buffer(priv->mdev, current_headroom_size,
new_headroom_size);
if (err)
return err;
goto out;

err = port_update_pool_cfg(priv->mdev, port_buffer);
if (err)
return err;
goto out;

err = mlx5e_port_set_pbmc(mdev, in);
out:
Expand Down
35 changes: 9 additions & 26 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,17 @@ parse_tc_vlan_action(struct mlx5e_priv *priv,
return -EOPNOTSUPP;
}

if (!mlx5_eswitch_vlan_actions_supported(priv->mdev, vlan_idx)) {
NL_SET_ERR_MSG_MOD(extack, "firmware vlan actions is not supported");
return -EOPNOTSUPP;
}

switch (act->id) {
case FLOW_ACTION_VLAN_POP:
if (vlan_idx) {
if (!mlx5_eswitch_vlan_actions_supported(priv->mdev,
MLX5_FS_VLAN_DEPTH)) {
NL_SET_ERR_MSG_MOD(extack, "vlan pop action is not supported");
return -EOPNOTSUPP;
}

if (vlan_idx)
*action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP_2;
} else {
else
*action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
}
break;
case FLOW_ACTION_VLAN_PUSH:
attr->vlan_vid[vlan_idx] = act->vlan.vid;
Expand All @@ -65,25 +63,10 @@ parse_tc_vlan_action(struct mlx5e_priv *priv,
if (!attr->vlan_proto[vlan_idx])
attr->vlan_proto[vlan_idx] = htons(ETH_P_8021Q);

if (vlan_idx) {
if (!mlx5_eswitch_vlan_actions_supported(priv->mdev,
MLX5_FS_VLAN_DEPTH)) {
NL_SET_ERR_MSG_MOD(extack,
"vlan push action is not supported for vlan depth > 1");
return -EOPNOTSUPP;
}

if (vlan_idx)
*action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH_2;
} else {
if (!mlx5_eswitch_vlan_actions_supported(priv->mdev, 1) &&
(act->vlan.proto != htons(ETH_P_8021Q) ||
act->vlan.prio)) {
NL_SET_ERR_MSG_MOD(extack, "vlan push action is not supported");
return -EOPNOTSUPP;
}

else
*action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH;
}
break;
case FLOW_ACTION_VLAN_POP_ETH:
parse_state->eth_pop = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ static void mlx5e_ipsec_packet_setup(void *obj, u32 pdn,
MLX5_SET(ipsec_aso, aso_ctx, remove_flow_pkt_cnt,
lower_32_bits(attrs->hard_packet_limit));
MLX5_SET(ipsec_aso, aso_ctx, hard_lft_arm, 1);
MLX5_SET(ipsec_aso, aso_ctx, remove_flow_enable, 1);
}

if (attrs->soft_packet_limit != XFRM_INF) {
Expand Down Expand Up @@ -329,8 +328,7 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work)

if (attrs->soft_packet_limit != XFRM_INF)
if (!MLX5_GET(ipsec_aso, aso->ctx, soft_lft_arm) ||
!MLX5_GET(ipsec_aso, aso->ctx, hard_lft_arm) ||
!MLX5_GET(ipsec_aso, aso->ctx, remove_flow_enable))
!MLX5_GET(ipsec_aso, aso->ctx, hard_lft_arm))
xfrm_state_check_expire(sa_entry->x);

unlock:
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,6 @@ static void mlx5e_tls_tx_debugfs_init(struct mlx5e_tls *tls,
return;

tls->debugfs.dfs_tx = debugfs_create_dir("tx", dfs_root);
if (!tls->debugfs.dfs_tx)
return;

debugfs_create_size_t("pool_size", 0400, tls->debugfs.dfs_tx,
&tls->tx_pool->size);
Expand Down
17 changes: 11 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3002,32 +3002,37 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
mlx5e_fp_preactivate preactivate,
void *context, bool reset)
{
struct mlx5e_channels new_chs = {};
struct mlx5e_channels *new_chs;
int err;

reset &= test_bit(MLX5E_STATE_OPENED, &priv->state);
if (!reset)
return mlx5e_switch_priv_params(priv, params, preactivate, context);

new_chs.params = *params;
new_chs = kzalloc(sizeof(*new_chs), GFP_KERNEL);
if (!new_chs)
return -ENOMEM;
new_chs->params = *params;

mlx5e_selq_prepare_params(&priv->selq, &new_chs.params);
mlx5e_selq_prepare_params(&priv->selq, &new_chs->params);

err = mlx5e_open_channels(priv, &new_chs);
err = mlx5e_open_channels(priv, new_chs);
if (err)
goto err_cancel_selq;

err = mlx5e_switch_priv_channels(priv, &new_chs, preactivate, context);
err = mlx5e_switch_priv_channels(priv, new_chs, preactivate, context);
if (err)
goto err_close;

kfree(new_chs);
return 0;

err_close:
mlx5e_close_channels(&new_chs);
mlx5e_close_channels(new_chs);

err_cancel_selq:
mlx5e_selq_cancel(&priv->selq);
kfree(new_chs);
return err;
}

Expand Down
Loading

0 comments on commit 7eadc0a

Please sign in to comment.