text: /*
   * Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
   *
   * $COPYRIGHT$
   *
   * Additional copyrights may follow
   *
   * $HEADER$
   */
  /**
   * @file
   *
   * IPMI resource manager sensor
   */
  #ifndef ORTE_SENSOR_IPMI_DECLS_H
  #define ORTE_SENSOR_IPMI_DECLS_H
  
  #define uchar unsigned char
  #define GET_ACPI_POWER          (0x07 | (NETFN_APP << 8))
  #define GET_BMC_IP_CMD          0x03
  
  // The total number of parameters that need to be gathered for each node
  // Eventually this number should equal the items under ipmi_property_t
  #define TOTAL_PROPERTIES_PER_NODE   14
  #define TOTAL_FLOAT_METRICS     250
  #define MAX_UNIT_LENGTH         20
  #define MAX_METRIC_NAME         20
  
  #define MAX_FRU_DEVICES  254
  #define MAX_IPMI_RESPONSE 256
  /*Seconds between the epoch (1/1/1970) and IPMI's start time (1/1/1996)*/
  #define EPOCH_IPMI_DIFF_TIME 820454400
  /*
  The element of the return array where the data starts
  ignoring date/time
  */
  #define BOARD_INFO_DATA_START 6
  
  #include "ipmi_parser_interface.h"
  
  unsigned char disable_ipmi;
  
  // GET_DEVICE_ID
  typedef struct {
      uchar   dev_id;
      uchar   dev_rev;
      uchar   fw_rev_1;
      uchar   fw_rev_2;
      uchar   ipmi_ver;
      uchar   dev_support;
      uchar   manufacturer_id[3];
      uchar   product_id [2];
      uchar   aux_fw_rev[4];
  } _device_id_t;
  
  typedef union {
      uchar           raw[16];
      _device_id_t    bits;
  } device_id_t;
  
  // GET_ACPI_STATE
  typedef struct {
      uchar   sys_power_state;
      uchar   dev_power_state;
  } _acpi_power_state_t;
  
  typedef union {
      uchar   raw[3];
      _acpi_power_state_t bits;
  } acpi_power_state_t;
  
  // Node Details
  typedef struct {
      char name[64];
      char bmc_ip[16];
      char host_ip[16];
      char device_id[16];
      char user[16];
      char pasw[16];
      int auth;
      int priv;
      int ciph;
  } ipmi_node_details_t;
  
  // Node Properties
  typedef struct {
      char bmc_rev[16];
      char ipmi_ver[16];
      char man_id[16];
      char baseboard_manuf_date[11];
      char baseboard_manufacturer[30];
      char baseboard_name[16];
      char baseboard_serial[16];
      char baseboard_part[16];
      char sys_power_state[16];
      char dev_power_state[16];
      int total_metrics;
      /* Metric string identifiers*/
      char metric_label[TOTAL_FLOAT_METRICS][MAX_METRIC_NAME];
  
      float collection_metrics[TOTAL_FLOAT_METRICS];  /* Array to store all non-string metrics */
      char collection_metrics_units[TOTAL_FLOAT_METRICS][MAX_UNIT_LENGTH]; /* Array to store units for all non-string metrics */
      /* SEL records */
      opal_list_t* collected_sel_records;
  } ipmi_properties_t;
  
  typedef struct {
      // Node Details
      ipmi_node_details_t node;
      // Node Capabilities
      unsigned char capability[TOTAL_PROPERTIES_PER_NODE];
      // Node Properties
      ipmi_properties_t prop;
  } ipmi_capsule_t;
  
  typedef struct _orcm_sensor_hosts_t {
      opal_list_item_t super;
      ipmi_capsule_t  capsule;
  }orcm_sensor_hosts_t;
  
  // List of all properties to be scanned by the IPMI Plugin
  // This total number should correspond to the value TOTAL_PROPERTIES_PER_NODE!!
  typedef enum {
      /* Add non-string numeric metrics under this section */
      PS1_USAGE = 0,
      PS1_TEMP = 1,
      PS2_USAGE = 2,
      PS2_TEMP = 3,
      FAN1_CPU_RPM = 4,
      FAN2_CPU_RPM = 5,
      FAN1_SYS_RPM = 6,
      FAN2_SYS_RPM = 7,
  
      /*Add string/character metrics under this section */
      BMC_REV = 8,
      IPMI_VER = 9,
      MAN_ID = 10,
      BASEBOARD_SERIAL = 11,
      SYS_POWER_STATE = 12,
      DEV_POWER_STATE = 13,
  } ipmi_property_t;
  
  // Function Declarations
  void orcm_sensor_ipmi_get_system_power_state(uchar in, char* str, int str_size);
  void orcm_sensor_ipmi_get_device_power_state(uchar in, char* str, int str_size);
  int orcm_sensor_ipmi_found(char *nodename, opal_list_t *host_list);
  unsigned int orcm_sensor_ipmi_counthosts(void);
  int orcm_sensor_ipmi_addhost(ipmi_collector* ic, opal_list_t *host_list);
  
  int orcm_sensor_ipmi_label_found(char * tag);
  int orcm_sensor_get_fru_inv(orcm_sensor_hosts_t *host);
  int orcm_sensor_get_fru_data(int id, long int fru_area, orcm_sensor_hosts_t *host);
  
  void orcm_sensor_ipmi_get_sensor_reading(ipmi_capsule_t *cap);
  void orcm_sensor_ipmi_get_device_id(ipmi_capsule_t *cap);
  void orcm_sensor_ipmi_get_power_states(ipmi_capsule_t *cap);
  int orcm_sensor_ipmi_get_manuf_date(unsigned char fru_offset, unsigned char *rdata, orcm_sensor_hosts_t *host);
  int orcm_sensor_ipmi_get_manuf_name(unsigned char fru_offset, unsigned char *rdata, orcm_sensor_hosts_t *host);
  int orcm_sensor_ipmi_get_product_name(unsigned char fru_offset, unsigned char *rdata, orcm_sensor_hosts_t *host);
  int orcm_sensor_ipmi_get_serial_number(unsigned char fru_offset, unsigned char *rdata, orcm_sensor_hosts_t *host);
  int orcm_sensor_ipmi_get_board_part(unsigned char fru_offset, unsigned char *rdata, orcm_sensor_hosts_t *host);
  
  #endif
  