Commit df535f4c authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

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: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c25f08ac
...@@ -30,6 +30,7 @@ struct mlxsw_sib { ...@@ -30,6 +30,7 @@ struct mlxsw_sib {
struct mlxsw_sib_port **ports; struct mlxsw_sib_port **ports;
struct mlxsw_core *core; struct mlxsw_core *core;
const struct mlxsw_bus_info *bus_info; const struct mlxsw_bus_info *bus_info;
u8 hw_id[ETH_ALEN];
}; };
struct mlxsw_sib_port { struct mlxsw_sib_port {
...@@ -102,6 +103,18 @@ mlxsw_sib_tx_v1_hdr_construct(struct sk_buff *skb, ...@@ -102,6 +103,18 @@ mlxsw_sib_tx_v1_hdr_construct(struct sk_buff *skb,
mlxsw_tx_v1_hdr_type_set(txhdr, MLXSW_TXHDR_TYPE_CONTROL); mlxsw_tx_v1_hdr_type_set(txhdr, MLXSW_TXHDR_TYPE_CONTROL);
} }
static int mlxsw_sib_hw_id_get(struct mlxsw_sib *mlxsw_sib)
{
char spad_pl[MLXSW_REG_SPAD_LEN] = {0};
int err;
err = mlxsw_reg_query(mlxsw_sib->core, MLXSW_REG(spad), spad_pl);
if (err)
return err;
mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sib->hw_id);
return 0;
}
static int static int
mlxsw_sib_port_admin_status_set(struct mlxsw_sib_port *mlxsw_sib_port, mlxsw_sib_port_admin_status_set(struct mlxsw_sib_port *mlxsw_sib_port,
bool is_up) bool is_up)
...@@ -268,7 +281,8 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port, ...@@ -268,7 +281,8 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port,
int err; int err;
err = mlxsw_core_port_init(mlxsw_sib->core, local_port, err = mlxsw_core_port_init(mlxsw_sib->core, local_port,
module + 1, false, 0, NULL, 0); module + 1, false, 0,
mlxsw_sib->hw_id, sizeof(mlxsw_sib->hw_id));
if (err) { if (err) {
dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n", dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n",
local_port); local_port);
...@@ -440,6 +454,12 @@ static int mlxsw_sib_init(struct mlxsw_core *mlxsw_core, ...@@ -440,6 +454,12 @@ static int mlxsw_sib_init(struct mlxsw_core *mlxsw_core,
mlxsw_sib->core = mlxsw_core; mlxsw_sib->core = mlxsw_core;
mlxsw_sib->bus_info = mlxsw_bus_info; mlxsw_sib->bus_info = mlxsw_bus_info;
err = mlxsw_sib_hw_id_get(mlxsw_sib);
if (err) {
dev_err(mlxsw_sib->bus_info->dev, "Failed to get switch HW ID\n");
return err;
}
err = mlxsw_sib_ports_create(mlxsw_sib); err = mlxsw_sib_ports_create(mlxsw_sib);
if (err) { if (err) {
dev_err(mlxsw_sib->bus_info->dev, "Failed to create ports\n"); dev_err(mlxsw_sib->bus_info->dev, "Failed to create ports\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment