Skip to content

Commit

Permalink
net/mlx5: Devcom, extend mlx5_devcom_send_event to work with more tha…
Browse files Browse the repository at this point in the history
…n two devices

mlx5_devcom_send_event is used to send event from one eswitch to the
other. In other words, only one event is sent, which means, no error
mechanism is needed.
However, In case devcom have more than two eswitches, a proper error
mechanism is needed. Hence, in case of error, devcom will perform the
error unwind, since devcom knows how many events were successful.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Shay Drory authored and Saeed Mahameed committed Jun 2, 2023
1 parent 90ca127 commit e2a82bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
Original file line number Diff line number Diff line change
Expand Up @@ -2892,7 +2892,8 @@ void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw)
esw->num_peers = 0;
mlx5_devcom_send_event(devcom,
MLX5_DEVCOM_ESW_OFFLOADS,
ESW_OFFLOADS_DEVCOM_PAIR, esw);
ESW_OFFLOADS_DEVCOM_PAIR,
ESW_OFFLOADS_DEVCOM_UNPAIR, esw);
}

void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw)
Expand All @@ -2906,6 +2907,7 @@ void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw)
return;

mlx5_devcom_send_event(devcom, MLX5_DEVCOM_ESW_OFFLOADS,
ESW_OFFLOADS_DEVCOM_UNPAIR,
ESW_OFFLOADS_DEVCOM_UNPAIR, esw);

mlx5_devcom_unregister_component(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
Expand Down
17 changes: 15 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void mlx5_devcom_unregister_component(struct mlx5_devcom *devcom,

int mlx5_devcom_send_event(struct mlx5_devcom *devcom,
enum mlx5_devcom_components id,
int event,
int event, int rollback_event,
void *event_data)
{
struct mlx5_devcom_component *comp;
Expand All @@ -210,10 +210,23 @@ int mlx5_devcom_send_event(struct mlx5_devcom *devcom,

if (i != devcom->idx && data) {
err = comp->handler(event, data, event_data);
break;
if (err)
goto rollback;
}
}

up_write(&comp->sem);
return 0;

rollback:
while (i--) {
void *data = rcu_dereference_protected(comp->device[i].data,
lockdep_is_held(&comp->sem));

if (i != devcom->idx && data)
comp->handler(rollback_event, data, event_data);
}

up_write(&comp->sem);
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void mlx5_devcom_unregister_component(struct mlx5_devcom *devcom,

int mlx5_devcom_send_event(struct mlx5_devcom *devcom,
enum mlx5_devcom_components id,
int event,
int event, int rollback_event,
void *event_data);

void mlx5_devcom_comp_set_ready(struct mlx5_devcom *devcom,
Expand Down

0 comments on commit e2a82bf

Please sign in to comment.