]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
mlxsw: switch_ib: Pass valid HW id down to mlxsw_core_port_init()
authorJiri Pirko <jiri@mellanox.com>
Wed, 3 Apr 2019 12:24:25 +0000 (14:24 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Apr 2019 00:42:36 +0000 (17:42 -0700)
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>
drivers/net/ethernet/mellanox/mlxsw/switchib.c

index b22caa154310fe6351789f5e59f468ee275a6b2d..0d9356b3f65d8b89f3f2eb15f82cbacf3faea14c 100644 (file)
@@ -30,6 +30,7 @@ struct mlxsw_sib {
        struct mlxsw_sib_port **ports;
        struct mlxsw_core *core;
        const struct mlxsw_bus_info *bus_info;
+       u8 hw_id[ETH_ALEN];
 };
 
 struct mlxsw_sib_port {
@@ -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);
 }
 
+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
 mlxsw_sib_port_admin_status_set(struct mlxsw_sib_port *mlxsw_sib_port,
                                bool is_up)
@@ -268,7 +281,8 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port,
        int err;
 
        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) {
                dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n",
                        local_port);
@@ -440,6 +454,12 @@ static int mlxsw_sib_init(struct mlxsw_core *mlxsw_core,
        mlxsw_sib->core = mlxsw_core;
        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);
        if (err) {
                dev_err(mlxsw_sib->bus_info->dev, "Failed to create ports\n");