net/mlx5: Implement get_module_eeprom_by_page()
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / port.c
index 9b9f870..522a41f 100644 (file)
@@ -428,6 +428,47 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
 }
 EXPORT_SYMBOL_GPL(mlx5_query_module_eeprom);
 
+int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,
+                                    struct mlx5_module_eeprom_query_params *params,
+                                    u8 *data)
+{
+       u8 module_id;
+       int err;
+
+       err = mlx5_query_module_num(dev, &params->module_number);
+       if (err)
+               return err;
+
+       err = mlx5_query_module_id(dev, params->module_number, &module_id);
+       if (err)
+               return err;
+
+       switch (module_id) {
+       case MLX5_MODULE_ID_SFP:
+               if (params->page > 0)
+                       return -EINVAL;
+               break;
+       case MLX5_MODULE_ID_QSFP:
+       case MLX5_MODULE_ID_QSFP28:
+       case MLX5_MODULE_ID_QSFP_PLUS:
+               if (params->page > 3)
+                       return -EINVAL;
+               break;
+       default:
+               mlx5_core_err(dev, "Module ID not recognized: 0x%x\n", module_id);
+               return -EINVAL;
+       }
+
+       if (params->i2c_address != MLX5_I2C_ADDR_HIGH &&
+           params->i2c_address != MLX5_I2C_ADDR_LOW) {
+               mlx5_core_err(dev, "I2C address not recognized: 0x%x\n", params->i2c_address);
+               return -EINVAL;
+       }
+
+       return mlx5_query_mcia(dev, params, data);
+}
+EXPORT_SYMBOL_GPL(mlx5_query_module_eeprom_by_page);
+
 static int mlx5_query_port_pvlc(struct mlx5_core_dev *dev, u32 *pvlc,
                                int pvlc_size,  u8 local_port)
 {