OSDN Git Service

mlxsw: core: Reduce buffer size in transactions for SFP modules temperature readout
authorVadim Pasternak <vadimp@mellanox.com>
Wed, 29 May 2019 08:47:22 +0000 (11:47 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 May 2019 19:59:46 +0000 (12:59 -0700)
Obtain SFP modules temperatures through MTMP register instead of MTBR
register, because the first one utilizes shorter transaction buffer size
for request. It improves performance in case low frequency interface
(I2C) is used for communication with a chip.

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/core_env.c
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

index 72539a9..d2c7ce6 100644 (file)
@@ -92,33 +92,20 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
                u16 temp;
        } temp_thresh;
        char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
-       char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
-       u16 module_temp;
+       char mtmp_pl[MLXSW_REG_MTMP_LEN];
+       unsigned int module_temp;
        bool qsfp;
        int err;
 
-       mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
-                           1);
-       err = mlxsw_reg_query(core, MLXSW_REG(mtbr), mtbr_pl);
+       mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
+                           false, false);
+       err = mlxsw_reg_query(core, MLXSW_REG(mtmp), mtmp_pl);
        if (err)
                return err;
-
-       /* Don't read temperature thresholds for module with no valid info. */
-       mlxsw_reg_mtbr_temp_unpack(mtbr_pl, 0, &module_temp, NULL);
-       switch (module_temp) {
-       case MLXSW_REG_MTBR_BAD_SENS_INFO: /* fall-through */
-       case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
-       case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
-       case MLXSW_REG_MTBR_INDEX_NA:
+       mlxsw_reg_mtmp_unpack(mtmp_pl, &module_temp, NULL, NULL);
+       if (!module_temp) {
                *temp = 0;
                return 0;
-       default:
-               /* Do not consider thresholds for zero temperature. */
-               if (MLXSW_REG_MTMP_TEMP_TO_MC(module_temp) == 0) {
-                       *temp = 0;
-                       return 0;
-               }
-               break;
        }
 
        /* Read Free Side Device Temperature Thresholds from page 03h
index 8cd4468..056e3f5 100644 (file)
@@ -214,38 +214,18 @@ static ssize_t mlxsw_hwmon_module_temp_show(struct device *dev,
        struct mlxsw_hwmon_attr *mlwsw_hwmon_attr =
                        container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
        struct mlxsw_hwmon *mlxsw_hwmon = mlwsw_hwmon_attr->hwmon;
-       char mtbr_pl[MLXSW_REG_MTBR_LEN] = {0};
-       u16 temp;
+       char mtmp_pl[MLXSW_REG_MTMP_LEN];
+       unsigned int temp;
        u8 module;
        int err;
 
        module = mlwsw_hwmon_attr->type_index - mlxsw_hwmon->sensor_count;
-       mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX + module,
-                           1);
-       err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtbr), mtbr_pl);
-       if (err) {
-               dev_err(dev, "Failed to query module temperature sensor\n");
+       mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
+                           false, false);
+       err = mlxsw_reg_query(mlxsw_hwmon->core, MLXSW_REG(mtmp), mtmp_pl);
+       if (err)
                return err;
-       }
-
-       mlxsw_reg_mtbr_temp_unpack(mtbr_pl, 0, &temp, NULL);
-       /* Update status and temperature cache. */
-       switch (temp) {
-       case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
-       case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
-       case MLXSW_REG_MTBR_INDEX_NA:
-               temp = 0;
-               break;
-       case MLXSW_REG_MTBR_BAD_SENS_INFO:
-               /* Untrusted cable is connected. Reading temperature from its
-                * sensor is faulty.
-                */
-               temp = 0;
-               break;
-       default:
-               temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
-               break;
-       }
+       mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
 
        return sprintf(buf, "%u\n", temp);
 }
index d3e851e..cfab0e3 100644 (file)
@@ -449,39 +449,31 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
        struct mlxsw_thermal_module *tz = tzdev->devdata;
        struct mlxsw_thermal *thermal = tz->parent;
        struct device *dev = thermal->bus_info->dev;
-       char mtbr_pl[MLXSW_REG_MTBR_LEN];
-       u16 temp;
+       char mtmp_pl[MLXSW_REG_MTMP_LEN];
+       unsigned int temp;
        int err;
 
        /* Read module temperature. */
-       mlxsw_reg_mtbr_pack(mtbr_pl, MLXSW_REG_MTBR_BASE_MODULE_INDEX +
-                           tz->module, 1);
-       err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtbr), mtbr_pl);
-       if (err)
-               return err;
-
-       mlxsw_reg_mtbr_temp_unpack(mtbr_pl, 0, &temp, NULL);
-       /* Update temperature. */
-       switch (temp) {
-       case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
-       case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
-       case MLXSW_REG_MTBR_INDEX_NA: /* fall-through */
-       case MLXSW_REG_MTBR_BAD_SENS_INFO:
+       mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN +
+                           tz->module, false, false);
+       err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl);
+       if (err) {
+               /* Do not return error - in case of broken module's sensor
+                * it will cause error message flooding.
+                */
                temp = 0;
-               break;
-       default:
-               temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
-               /* Reset all trip point. */
-               mlxsw_thermal_module_trips_reset(tz);
-               /* Update trip points. */
-               err = mlxsw_thermal_module_trips_update(dev, thermal->core,
-                                                       tz);
-               if (err)
-                       return err;
-               break;
+               *p_temp = (int) temp;
+               return 0;
        }
-
+       mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL);
        *p_temp = (int) temp;
+
+       if (!temp)
+               return 0;
+
+       /* Update trip points. */
+       mlxsw_thermal_module_trips_update(dev, thermal->core, tz);
+
        return 0;
 }