Introducing sensor APIs to PMD driver for PAC N3000 card.
Those sensor APIs:
1. opae_mgr_for_each_sensor()
2. opae_mgr_get_sensor_by_name()
3. opae_mgr_get_sensor_by_id()
4. opae_mgr_get_sensor_value_by_name()
5. opae_mgr_get_sensor_value_by_id()
6. opae_mgr_get_sensor_value()
Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com>
Signed-off-by: Andy Pei <andy.pei@intel.com>
return 0;
}
+static int ifpga_mgr_get_sensor_value(struct opae_manager *mgr,
+ struct opae_sensor_info *sensor,
+ unsigned int *value)
+{
+ struct ifpga_fme_hw *fme = mgr->data;
+
+ return fme_mgr_get_sensor_value(fme, sensor, value);
+}
+
struct opae_manager_ops ifpga_mgr_ops = {
.flash = ifpga_mgr_flash,
.get_eth_group_region_info = ifpga_mgr_get_eth_group_region_info,
+ .get_sensor_value = ifpga_mgr_get_sensor_value,
};
static int ifpga_mgr_read_mac_rom(struct opae_manager *mgr, int offset,
struct opae_retimer_info *info);
int fme_mgr_get_retimer_status(struct ifpga_fme_hw *fme,
struct opae_retimer_status *status);
+int fme_mgr_get_sensor_value(struct ifpga_fme_hw *fme,
+ struct opae_sensor_info *sensor,
+ unsigned int *value);
#endif /* _IFPGA_FEATURE_DEV_H_ */
return 0;
}
+
+int fme_mgr_get_sensor_value(struct ifpga_fme_hw *fme,
+ struct opae_sensor_info *sensor,
+ unsigned int *value)
+{
+ struct intel_max10_device *dev;
+
+ dev = (struct intel_max10_device *)fme->max10_dev;
+ if (!dev)
+ return -ENODEV;
+
+ if (max10_reg_read(sensor->value_reg, value)) {
+ dev_err(dev, "%s: read sensor value register 0x%x fail\n",
+ __func__, sensor->value_reg);
+ return -EINVAL;
+ }
+
+ *value *= sensor->multiplier;
+
+ return 0;
+}
return -ENOENT;
}
+
+/**
+ * opae_manager_get_sensor_by_id - get sensor device
+ * @id: the id of the sensor
+ *
+ * Return: the pointer of the opae_sensor_info
+ */
+struct opae_sensor_info *
+opae_mgr_get_sensor_by_id(unsigned int id)
+{
+ struct opae_sensor_info *sensor;
+
+ opae_mgr_for_each_sensor(sensor)
+ if (sensor->id == id)
+ return sensor;
+
+ return NULL;
+}
+
+/**
+ * opae_manager_get_sensor_by_name - get sensor device
+ * @name: the name of the sensor
+ *
+ * Return: the pointer of the opae_sensor_info
+ */
+struct opae_sensor_info *
+opae_mgr_get_sensor_by_name(const char *name)
+{
+ struct opae_sensor_info *sensor;
+
+ opae_mgr_for_each_sensor(sensor)
+ if (!strcmp(sensor->name, name))
+ return sensor;
+
+ return NULL;
+}
+
+/**
+ * opae_manager_get_sensor_value_by_name - find the sensor by name and read out
+ * the value
+ * @mgr: opae_manager for sensor.
+ * @name: the name of the sensor
+ * @value: the readout sensor value
+ *
+ * Return: 0 on success, otherwise error code
+ */
+int
+opae_mgr_get_sensor_value_by_name(struct opae_manager *mgr,
+ const char *name, unsigned int *value)
+{
+ struct opae_sensor_info *sensor;
+
+ if (!mgr)
+ return -EINVAL;
+
+ sensor = opae_mgr_get_sensor_by_name(name);
+ if (!sensor)
+ return -ENODEV;
+
+ if (mgr->ops && mgr->ops->get_sensor_value)
+ return mgr->ops->get_sensor_value(mgr, sensor, value);
+
+ return -ENOENT;
+}
+
+/**
+ * opae_manager_get_sensor_value_by_id - find the sensor by id and readout the
+ * value
+ * @mgr: opae_manager for sensor
+ * @id: the id of the sensor
+ * @value: the readout sensor value
+ *
+ * Return: 0 on success, otherwise error code
+ */
+int
+opae_mgr_get_sensor_value_by_id(struct opae_manager *mgr,
+ unsigned int id, unsigned int *value)
+{
+ struct opae_sensor_info *sensor;
+
+ if (!mgr)
+ return -EINVAL;
+
+ sensor = opae_mgr_get_sensor_by_id(id);
+ if (!sensor)
+ return -ENODEV;
+
+ if (mgr->ops && mgr->ops->get_sensor_value)
+ return mgr->ops->get_sensor_value(mgr, sensor, value);
+
+ return -ENOENT;
+}
+
+/**
+ * opae_manager_get_sensor_value - get the current
+ * sensor value
+ * @mgr: opae_manager for sensor
+ * @sensor: opae_sensor_info for sensor
+ * @value: the readout sensor value
+ *
+ * Return: 0 on success, otherwise error code
+ */
+int
+opae_mgr_get_sensor_value(struct opae_manager *mgr,
+ struct opae_sensor_info *sensor,
+ unsigned int *value)
+{
+ if (!mgr || !sensor)
+ return -EINVAL;
+
+ if (mgr->ops && mgr->ops->get_sensor_value)
+ return mgr->ops->get_sensor_value(mgr, sensor, value);
+
+ return -ENOENT;
+}
u32 size, u64 *status);
int (*get_eth_group_region_info)(struct opae_manager *mgr,
struct opae_eth_group_region_info *info);
+ int (*get_sensor_value)(struct opae_manager *mgr,
+ struct opae_sensor_info *sensor,
+ unsigned int *value);
};
/* networking management ops in FME */
struct opae_retimer_status *status);
};
+extern struct opae_sensor_list opae_sensor_list;
+#define opae_mgr_for_each_sensor(sensor) \
+ TAILQ_FOREACH(sensor, &opae_sensor_list, node)
+
/* OPAE Manager APIs */
struct opae_manager *
opae_manager_alloc(const char *name, struct opae_manager_ops *ops,
u32 size, u64 *status);
int opae_manager_get_eth_group_region_info(struct opae_manager *mgr,
u8 group_id, struct opae_eth_group_region_info *info);
+struct opae_sensor_info *opae_mgr_get_sensor_by_name(const char *name);
+struct opae_sensor_info *opae_mgr_get_sensor_by_id(unsigned int id);
+int opae_mgr_get_sensor_value_by_name(struct opae_manager *mgr,
+ const char *name, unsigned int *value);
+int opae_mgr_get_sensor_value_by_id(struct opae_manager *mgr,
+ unsigned int id, unsigned int *value);
+int opae_mgr_get_sensor_value(struct opae_manager *mgr,
+ struct opae_sensor_info *sensor,
+ unsigned int *value);
/* OPAE Bridge Data Structure */
struct opae_bridge_ops;