aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Bloch <markb@mellanox.com>2017-09-27 03:24:18 -0400
committerSaeed Mahameed <saeedm@mellanox.com>2018-02-23 15:36:38 -0500
commit22215908d81f61d293e8b128e819a8437f37cc20 (patch)
tree8e8d611f25da99c0ac2537fd8e810b6c52cb6854
parent388ca8be00370db132464e27f745b8a0add19fcb (diff)
net/mlx5: E-Switch, Add callback to get representor device
Add a callback interface to get a protocol device (per representor type). The Ethernet representors will expose their netdev via this interface. This functionality can be later used by IB representor in order to find the corresponding net device representor. 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>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rep.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.h5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c24
3 files changed, 40 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 363d8dcb7f17..ea4b255380a2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -1156,6 +1156,15 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
1156 kfree(ppriv); /* mlx5e_rep_priv */ 1156 kfree(ppriv); /* mlx5e_rep_priv */
1157} 1157}
1158 1158
1159static void *mlx5e_vport_rep_get_proto_dev(struct mlx5_eswitch_rep *rep)
1160{
1161 struct mlx5e_rep_priv *rpriv;
1162
1163 rpriv = mlx5e_rep_to_rep_priv(rep);
1164
1165 return rpriv->netdev;
1166}
1167
1159static void mlx5e_rep_register_vf_vports(struct mlx5e_priv *priv) 1168static void mlx5e_rep_register_vf_vports(struct mlx5e_priv *priv)
1160{ 1169{
1161 struct mlx5_core_dev *mdev = priv->mdev; 1170 struct mlx5_core_dev *mdev = priv->mdev;
@@ -1168,6 +1177,7 @@ static void mlx5e_rep_register_vf_vports(struct mlx5e_priv *priv)
1168 1177
1169 rep_if.load = mlx5e_vport_rep_load; 1178 rep_if.load = mlx5e_vport_rep_load;
1170 rep_if.unload = mlx5e_vport_rep_unload; 1179 rep_if.unload = mlx5e_vport_rep_unload;
1180 rep_if.get_proto_dev = mlx5e_vport_rep_get_proto_dev;
1171 mlx5_eswitch_register_vport_rep(esw, vport, &rep_if, REP_ETH); 1181 mlx5_eswitch_register_vport_rep(esw, vport, &rep_if, REP_ETH);
1172 } 1182 }
1173} 1183}
@@ -1195,6 +1205,7 @@ void mlx5e_register_vport_reps(struct mlx5e_priv *priv)
1195 1205
1196 rep_if.load = mlx5e_nic_rep_load; 1206 rep_if.load = mlx5e_nic_rep_load;
1197 rep_if.unload = mlx5e_nic_rep_unload; 1207 rep_if.unload = mlx5e_nic_rep_unload;
1208 rep_if.get_proto_dev = mlx5e_vport_rep_get_proto_dev;
1198 rep_if.priv = rpriv; 1209 rep_if.priv = rpriv;
1199 INIT_LIST_HEAD(&rpriv->vport_sqs_list); 1210 INIT_LIST_HEAD(&rpriv->vport_sqs_list);
1200 mlx5_eswitch_register_vport_rep(esw, 0, &rep_if, REP_ETH); /* UPLINK PF vport*/ 1211 mlx5_eswitch_register_vport_rep(esw, 0, &rep_if, REP_ETH); /* UPLINK PF vport*/
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 2fa037066b2f..4dfb1da435a4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -150,6 +150,7 @@ struct mlx5_eswitch_rep_if {
150 int (*load)(struct mlx5_core_dev *dev, 150 int (*load)(struct mlx5_core_dev *dev,
151 struct mlx5_eswitch_rep *rep); 151 struct mlx5_eswitch_rep *rep);
152 void (*unload)(struct mlx5_eswitch_rep *rep); 152 void (*unload)(struct mlx5_eswitch_rep *rep);
153 void *(*get_proto_dev)(struct mlx5_eswitch_rep *rep);
153 void *priv; 154 void *priv;
154 bool valid; 155 bool valid;
155}; 156};
@@ -286,6 +287,10 @@ void mlx5_eswitch_unregister_vport_rep(struct mlx5_eswitch *esw,
286 int vport_index, 287 int vport_index,
287 u8 rep_type); 288 u8 rep_type);
288void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type); 289void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type);
290void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw,
291 int vport,
292 u8 rep_type);
293void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type);
289 294
290int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, 295int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,
291 struct mlx5_esw_flow_attr *attr); 296 struct mlx5_esw_flow_attr *attr);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 99f583a15cc3..06623c8e92a2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -1160,6 +1160,7 @@ void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw,
1160 1160
1161 rep_if->load = __rep_if->load; 1161 rep_if->load = __rep_if->load;
1162 rep_if->unload = __rep_if->unload; 1162 rep_if->unload = __rep_if->unload;
1163 rep_if->get_proto_dev = __rep_if->get_proto_dev;
1163 rep_if->priv = __rep_if->priv; 1164 rep_if->priv = __rep_if->priv;
1164 1165
1165 rep_if->valid = true; 1166 rep_if->valid = true;
@@ -1188,3 +1189,26 @@ void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type)
1188 rep = &offloads->vport_reps[UPLINK_REP_INDEX]; 1189 rep = &offloads->vport_reps[UPLINK_REP_INDEX];
1189 return rep->rep_if[rep_type].priv; 1190 return rep->rep_if[rep_type].priv;
1190} 1191}
1192
1193void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw,
1194 int vport,
1195 u8 rep_type)
1196{
1197 struct mlx5_esw_offload *offloads = &esw->offloads;
1198 struct mlx5_eswitch_rep *rep;
1199
1200 if (vport == FDB_UPLINK_VPORT)
1201 vport = UPLINK_REP_INDEX;
1202
1203 rep = &offloads->vport_reps[vport];
1204
1205 if (rep->rep_if[rep_type].valid &&
1206 rep->rep_if[rep_type].get_proto_dev)
1207 return rep->rep_if[rep_type].get_proto_dev(rep);
1208 return NULL;
1209}
1210
1211void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type)
1212{
1213 return mlx5_eswitch_get_proto_dev(esw, UPLINK_REP_INDEX, rep_type);
1214}