diff options
author | Or Gerlitz <ogerlitz@mellanox.com> | 2016-08-18 14:09:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-19 19:09:56 -0400 |
commit | ef78618b9d29d40c95ca7092493545b8487e226c (patch) | |
tree | 5b157b49ffeb9257e92035176f83c5b069d6be5d | |
parent | dbe413e3bb93e0634f6d8d00b01cda6f141e0acd (diff) |
net/mlx5: E-Switch, Return the correct devlink e-switch mode
Since mlx5 has also the NONE e-switch mode, we must translate from mlx5
mode to devlink mode on the devlink eswitch mode get call, do that.
While here, remove the mlx5_ prefix from the static function helpers
that deal with the mode to comply with the rest of the code.
Fixes: c930a3ad7453 ('net/mlx5e: Add devlink based SRIOV mode change')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index a357e8eeeed8..1a3ccbf2dffd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | |||
@@ -535,7 +535,7 @@ void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports) | |||
535 | esw_destroy_offloads_fdb_table(esw); | 535 | esw_destroy_offloads_fdb_table(esw); |
536 | } | 536 | } |
537 | 537 | ||
538 | static int mlx5_esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) | 538 | static int esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) |
539 | { | 539 | { |
540 | switch (mode) { | 540 | switch (mode) { |
541 | case DEVLINK_ESWITCH_MODE_LEGACY: | 541 | case DEVLINK_ESWITCH_MODE_LEGACY: |
@@ -551,6 +551,22 @@ static int mlx5_esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) | |||
551 | return 0; | 551 | return 0; |
552 | } | 552 | } |
553 | 553 | ||
554 | static int esw_mode_to_devlink(u16 mlx5_mode, u16 *mode) | ||
555 | { | ||
556 | switch (mlx5_mode) { | ||
557 | case SRIOV_LEGACY: | ||
558 | *mode = DEVLINK_ESWITCH_MODE_LEGACY; | ||
559 | break; | ||
560 | case SRIOV_OFFLOADS: | ||
561 | *mode = DEVLINK_ESWITCH_MODE_SWITCHDEV; | ||
562 | break; | ||
563 | default: | ||
564 | return -EINVAL; | ||
565 | } | ||
566 | |||
567 | return 0; | ||
568 | } | ||
569 | |||
554 | int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode) | 570 | int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode) |
555 | { | 571 | { |
556 | struct mlx5_core_dev *dev; | 572 | struct mlx5_core_dev *dev; |
@@ -566,7 +582,7 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode) | |||
566 | if (cur_mlx5_mode == SRIOV_NONE) | 582 | if (cur_mlx5_mode == SRIOV_NONE) |
567 | return -EOPNOTSUPP; | 583 | return -EOPNOTSUPP; |
568 | 584 | ||
569 | if (mlx5_esw_mode_from_devlink(mode, &mlx5_mode)) | 585 | if (esw_mode_from_devlink(mode, &mlx5_mode)) |
570 | return -EINVAL; | 586 | return -EINVAL; |
571 | 587 | ||
572 | if (cur_mlx5_mode == mlx5_mode) | 588 | if (cur_mlx5_mode == mlx5_mode) |
@@ -592,9 +608,7 @@ int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode) | |||
592 | if (dev->priv.eswitch->mode == SRIOV_NONE) | 608 | if (dev->priv.eswitch->mode == SRIOV_NONE) |
593 | return -EOPNOTSUPP; | 609 | return -EOPNOTSUPP; |
594 | 610 | ||
595 | *mode = dev->priv.eswitch->mode; | 611 | return esw_mode_to_devlink(dev->priv.eswitch->mode, mode); |
596 | |||
597 | return 0; | ||
598 | } | 612 | } |
599 | 613 | ||
600 | void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw, | 614 | void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw, |