mlxsw: reg: Add MGIR register
authorShalom Toledo <shalomt@mellanox.com>
Mon, 8 Apr 2019 06:59:34 +0000 (06:59 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Apr 2019 23:28:01 +0000 (16:28 -0700)
Add MGIR register. MGIR, Management General Information Register, allows
software to query the hardware and firmware general information.

Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/reg.h

index eb4c5e8964cd6210af966d5347cedf9fb64cc53d..e1ee7f4994dbf9014de35c958498e74b927a7c1d 100644 (file)
@@ -8534,6 +8534,60 @@ static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
        mlxsw_reg_mpar_pa_id_set(payload, pa_id);
 }
 
+/* MGIR - Management General Information Register
+ * ----------------------------------------------
+ * MGIR register allows software to query the hardware and firmware general
+ * information.
+ */
+#define MLXSW_REG_MGIR_ID 0x9020
+#define MLXSW_REG_MGIR_LEN 0x9C
+
+MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
+
+/* reg_mgir_hw_info_device_hw_revision
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
+
+#define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
+
+/* reg_mgir_fw_info_psid
+ * PSID (ASCII string).
+ * Access: RO
+ */
+MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
+
+/* reg_mgir_fw_info_extended_major
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
+
+/* reg_mgir_fw_info_extended_minor
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
+
+/* reg_mgir_fw_info_extended_sub_minor
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
+
+static inline void mlxsw_reg_mgir_pack(char *payload)
+{
+       MLXSW_REG_ZERO(mgir, payload);
+}
+
+static inline void
+mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
+                     u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
+{
+       *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
+       mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
+       *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
+       *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
+       *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
+}
+
 /* MRSR - Management Reset and Shutdown Register
  * ---------------------------------------------
  * MRSR register is used to reset or shutdown the switch or
@@ -9958,6 +10012,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
        MLXSW_REG(mcia),
        MLXSW_REG(mpat),
        MLXSW_REG(mpar),
+       MLXSW_REG(mgir),
        MLXSW_REG(mrsr),
        MLXSW_REG(mlcr),
        MLXSW_REG(mpsc),