mlxsw: reg: Add Management General Peripheral Information Register
authorVadim Pasternak <vadimp@mellanox.com>
Wed, 29 May 2019 08:47:19 +0000 (11:47 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 May 2019 19:59:46 +0000 (12:59 -0700)
Add MGPIR - Management General Peripheral Information Register, which
allows software to query the hardware and firmware general information
of peripheral entities as Gearboxes etc.

Signed-off-by: Vadim Pasternak <vadimp@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 a689bf991dbde61a7ffb3ecfecd6f4d90952e05d..ec1ae66a0b3673f6a634b8f0b3c77cbf080e382e 100644 (file)
@@ -9044,6 +9044,57 @@ static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
        mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
 }
 
+/* MGPIR - Management General Peripheral Information Register
+ * ----------------------------------------------------------
+ * MGPIR register allows software to query the hardware and
+ * firmware general information of peripheral entities.
+ */
+#define MLXSW_REG_MGPIR_ID 0x9100
+#define MLXSW_REG_MGPIR_LEN 0xA0
+
+MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
+
+enum mlxsw_reg_mgpir_device_type {
+       MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
+       MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
+};
+
+/* device_type
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
+
+/* devices_per_flash
+ * Number of devices of device_type per flash (can be shared by few devices).
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
+
+/* num_of_devices
+ * Number of devices of device_type.
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
+
+static inline void mlxsw_reg_mgpir_pack(char *payload)
+{
+       MLXSW_REG_ZERO(mgpir, payload);
+}
+
+static inline void
+mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
+                      enum mlxsw_reg_mgpir_device_type *device_type,
+                      u8 *devices_per_flash)
+{
+       if (num_of_devices)
+               *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
+       if (device_type)
+               *device_type = mlxsw_reg_mgpir_device_type_get(payload);
+       if (devices_per_flash)
+               *devices_per_flash =
+                               mlxsw_reg_mgpir_devices_per_flash_get(payload);
+}
+
 /* TNGCR - Tunneling NVE General Configuration Register
  * ----------------------------------------------------
  * The TNGCR register is used for setting up the NVE Tunneling configuration.
@@ -10059,6 +10110,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
        MLXSW_REG(mcda),
        MLXSW_REG(mgpc),
        MLXSW_REG(mprs),
+       MLXSW_REG(mgpir),
        MLXSW_REG(tngcr),
        MLXSW_REG(tnumt),
        MLXSW_REG(tnqcr),