-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IB/mlx5: Add basic regiser/unregister representors code
Create the basic infrastructure of registering and unregistering IB representors. The load/unload callbacks are left empty and proper implementation will be introduced in following patches. Signed-off-by: Mark Bloch <markb@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
- Loading branch information
Mark Bloch
authored and
Saeed Mahameed
committed
Feb 23, 2018
1 parent
5e65b02
commit fc385b7
Showing
5 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ | ||
/* | ||
* Copyright (c) 2018 Mellanox Technologies. All rights reserved. | ||
*/ | ||
|
||
#include "ib_rep.h" | ||
|
||
static int | ||
mlx5_ib_nic_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) | ||
{ | ||
return 0; | ||
} | ||
|
||
static void | ||
mlx5_ib_nic_rep_unload(struct mlx5_eswitch_rep *rep) | ||
{ | ||
} | ||
|
||
static int | ||
mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) | ||
{ | ||
return 0; | ||
} | ||
|
||
static void | ||
mlx5_ib_vport_rep_unload(struct mlx5_eswitch_rep *rep) | ||
{ | ||
} | ||
|
||
static void *mlx5_ib_vport_get_proto_dev(struct mlx5_eswitch_rep *rep) | ||
{ | ||
return mlx5_ib_rep_to_dev(rep); | ||
} | ||
|
||
static void mlx5_ib_rep_register_vf_vports(struct mlx5_ib_dev *dev) | ||
{ | ||
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch; | ||
int total_vfs = MLX5_TOTAL_VPORTS(dev->mdev); | ||
int vport; | ||
|
||
for (vport = 1; vport < total_vfs; vport++) { | ||
struct mlx5_eswitch_rep_if rep_if = {}; | ||
|
||
rep_if.load = mlx5_ib_vport_rep_load; | ||
rep_if.unload = mlx5_ib_vport_rep_unload; | ||
rep_if.get_proto_dev = mlx5_ib_vport_get_proto_dev; | ||
mlx5_eswitch_register_vport_rep(esw, vport, &rep_if, REP_IB); | ||
} | ||
} | ||
|
||
static void mlx5_ib_rep_unregister_vf_vports(struct mlx5_ib_dev *dev) | ||
{ | ||
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch; | ||
int total_vfs = MLX5_TOTAL_VPORTS(dev->mdev); | ||
int vport; | ||
|
||
for (vport = 1; vport < total_vfs; vport++) | ||
mlx5_eswitch_unregister_vport_rep(esw, vport, REP_IB); | ||
} | ||
|
||
void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev) | ||
{ | ||
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch; | ||
struct mlx5_eswitch_rep_if rep_if = {}; | ||
|
||
rep_if.load = mlx5_ib_nic_rep_load; | ||
rep_if.unload = mlx5_ib_nic_rep_unload; | ||
rep_if.get_proto_dev = mlx5_ib_vport_get_proto_dev; | ||
rep_if.priv = dev; | ||
|
||
mlx5_eswitch_register_vport_rep(esw, 0, &rep_if, REP_IB); | ||
|
||
mlx5_ib_rep_register_vf_vports(dev); | ||
} | ||
|
||
void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev) | ||
{ | ||
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch; | ||
|
||
mlx5_ib_rep_unregister_vf_vports(dev); /* VFs vports */ | ||
mlx5_eswitch_unregister_vport_rep(esw, 0, REP_IB); /* UPLINK PF*/ | ||
} | ||
|
||
u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw) | ||
{ | ||
return mlx5_eswitch_mode(esw); | ||
} | ||
|
||
struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, | ||
int vport_index) | ||
{ | ||
return mlx5_eswitch_get_proto_dev(esw, vport_index, REP_IB); | ||
} | ||
|
||
struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, | ||
int vport_index) | ||
{ | ||
return mlx5_eswitch_get_proto_dev(esw, vport_index, REP_ETH); | ||
} | ||
|
||
struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport) | ||
{ | ||
return mlx5_eswitch_vport_rep(esw, vport); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ | ||
/* | ||
* Copyright (c) 2018 Mellanox Technologies. All rights reserved. | ||
*/ | ||
|
||
#ifndef __MLX5_IB_REP_H__ | ||
#define __MLX5_IB_REP_H__ | ||
|
||
#include <linux/mlx5/eswitch.h> | ||
#include "mlx5_ib.h" | ||
|
||
#ifdef CONFIG_MLX5_ESWITCH | ||
u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw); | ||
struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, | ||
int vport_index); | ||
struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, | ||
int vport_index); | ||
void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev); | ||
void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev); | ||
#else /* CONFIG_MLX5_ESWITCH */ | ||
static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw) | ||
{ | ||
return SRIOV_NONE; | ||
} | ||
|
||
static inline | ||
struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, | ||
int vport_index) | ||
{ | ||
return NULL; | ||
} | ||
|
||
static inline | ||
struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, | ||
int vport_index) | ||
{ | ||
return NULL; | ||
} | ||
|
||
static inline void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev) {} | ||
static inline void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev) {} | ||
#endif | ||
|
||
static inline | ||
struct mlx5_ib_dev *mlx5_ib_rep_to_dev(struct mlx5_eswitch_rep *rep) | ||
{ | ||
return (struct mlx5_ib_dev *)rep->rep_if[REP_IB].priv; | ||
} | ||
#endif /* __MLX5_IB_REP_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters