aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2019-04-03 08:24:25 -0400
committerDavid S. Miller <davem@davemloft.net>2019-04-04 20:42:36 -0400
commitdf535f4c47a60fd6bf8f1327e9f87628e581e136 (patch)
tree87de2060cd847ac110ee8cde152cdab0e70b1818
parentc25f08ac65e4e6a308babd2b39d89b362e9086c6 (diff)
mlxsw: switch_ib: Pass valid HW id down to mlxsw_core_port_init()
Obtain HW id and pass it down to mlxsw_core_port_init() as it would be used as switch_id in devlink and exposed to user. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/switchib.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchib.c b/drivers/net/ethernet/mellanox/mlxsw/switchib.c
index b22caa154310..0d9356b3f65d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchib.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchib.c
@@ -30,6 +30,7 @@ struct mlxsw_sib {
30 struct mlxsw_sib_port **ports; 30 struct mlxsw_sib_port **ports;
31 struct mlxsw_core *core; 31 struct mlxsw_core *core;
32 const struct mlxsw_bus_info *bus_info; 32 const struct mlxsw_bus_info *bus_info;
33 u8 hw_id[ETH_ALEN];
33}; 34};
34 35
35struct mlxsw_sib_port { 36struct mlxsw_sib_port {
@@ -102,6 +103,18 @@ mlxsw_sib_tx_v1_hdr_construct(struct sk_buff *skb,
102 mlxsw_tx_v1_hdr_type_set(txhdr, MLXSW_TXHDR_TYPE_CONTROL); 103 mlxsw_tx_v1_hdr_type_set(txhdr, MLXSW_TXHDR_TYPE_CONTROL);
103} 104}
104 105
106static int mlxsw_sib_hw_id_get(struct mlxsw_sib *mlxsw_sib)
107{
108 char spad_pl[MLXSW_REG_SPAD_LEN] = {0};
109 int err;
110
111 err = mlxsw_reg_query(mlxsw_sib->core, MLXSW_REG(spad), spad_pl);
112 if (err)
113 return err;
114 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sib->hw_id);
115 return 0;
116}
117
105static int 118static int
106mlxsw_sib_port_admin_status_set(struct mlxsw_sib_port *mlxsw_sib_port, 119mlxsw_sib_port_admin_status_set(struct mlxsw_sib_port *mlxsw_sib_port,
107 bool is_up) 120 bool is_up)
@@ -268,7 +281,8 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port,
268 int err; 281 int err;
269 282
270 err = mlxsw_core_port_init(mlxsw_sib->core, local_port, 283 err = mlxsw_core_port_init(mlxsw_sib->core, local_port,
271 module + 1, false, 0, NULL, 0); 284 module + 1, false, 0,
285 mlxsw_sib->hw_id, sizeof(mlxsw_sib->hw_id));
272 if (err) { 286 if (err) {
273 dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n", 287 dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n",
274 local_port); 288 local_port);
@@ -440,6 +454,12 @@ static int mlxsw_sib_init(struct mlxsw_core *mlxsw_core,
440 mlxsw_sib->core = mlxsw_core; 454 mlxsw_sib->core = mlxsw_core;
441 mlxsw_sib->bus_info = mlxsw_bus_info; 455 mlxsw_sib->bus_info = mlxsw_bus_info;
442 456
457 err = mlxsw_sib_hw_id_get(mlxsw_sib);
458 if (err) {
459 dev_err(mlxsw_sib->bus_info->dev, "Failed to get switch HW ID\n");
460 return err;
461 }
462
443 err = mlxsw_sib_ports_create(mlxsw_sib); 463 err = mlxsw_sib_ports_create(mlxsw_sib);
444 if (err) { 464 if (err) {
445 dev_err(mlxsw_sib->bus_info->dev, "Failed to create ports\n"); 465 dev_err(mlxsw_sib->bus_info->dev, "Failed to create ports\n");