Add compact numeric sensor PDR definitions

Add compact numeric sensor PDR definitions base on section "28.25
Compact Numeric Sensor PDR" in DSP0248 1.2.1 specification.

Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I7dd6143c025a3866f9f304575e8731ff2fd5fe3f
diff --git a/include/libpldm/platform.h b/include/libpldm/platform.h
index e03d8c2..8ef0f76 100644
--- a/include/libpldm/platform.h
+++ b/include/libpldm/platform.h
@@ -148,6 +148,7 @@
 	PLDM_INTERRUPT_ASSOCIATION_PDR = 18,
 	PLDM_EVENT_LOG_PDR = 19,
 	PLDM_PDR_FRU_RECORD_SET = 20,
+	PLDM_COMPACT_NUMERIC_SENSOR_PDR = 21,
 	PLDM_OEM_DEVICE_PDR = 126,
 	PLDM_OEM_PDR = 127,
 };
@@ -282,6 +283,108 @@
 	PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE
 };
 
+/** @brief PLDM DSP0248 1.2.1 table 74 sensorUnits enumeration
+ */
+enum pldm_sensor_units {
+	PLDM_SENSOR_UNIT_NONE = 0x00,
+	PLDM_SENSOR_UNIT_UNSPECIFIED,
+	PLDM_SENSOR_UNIT_DEGRESS_C,
+	PLDM_SENSOR_UNIT_DEGRESS_F,
+	PLDM_SENSOR_UNIT_KELVINS,
+	PLDM_SENSOR_UNIT_VOLTS,
+	PLDM_SENSOR_UNIT_AMPS,
+	PLDM_SENSOR_UNIT_WATTS,
+	PLDM_SENSOR_UNIT_JOULES,
+	PLDM_SENSOR_UNIT_COULOMBS,
+	PLDM_SENSOR_UNIT_VA,
+	PLDM_SENSOR_UNIT_NITS,
+	PLDM_SENSOR_UNIT_LUMENS,
+	PLDM_SENSOR_UNIT_LUX,
+	PLDM_SENSOR_UNIT_CANDELAS,
+	PLDM_SENSOR_UNIT_KPA,
+	PLDM_SENSOR_UNIT_PSI,
+	PLDM_SENSOR_UNIT_NEWTONS,
+	PLDM_SENSOR_UNIT_CFM,
+	PLDM_SENSOR_UNIT_RPM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T_COLOR_TEMPERATURE_DEGRESS_K,
+	PLDM_SENSOR_UNIT_BITS,
+	PLDM_SENSOR_UNIT_BYTES,
+	PLDM_SENSOR_UNIT_WORDS,
+	PLDM_SENSOR_UNIT_DOUBLE_WORDS,
+	PLDM_SENSOR_UNIT_QUAD_WORDS,
+	PLDM_SENSOR_UNIT_PERCENTAGE,
+	PLDM_SENSOR_UNIT_PASCALS,
+	PLDM_SENSOR_UNIT_COUNTS,
+	PLDM_SENSOR_UNIT_GRAMS,
+	PLDM_SENSOR_UNIT_NEWTON_METERS,
+	PLDM_SENSOR_UNIT_HITS,
+	PLDM_SENSOR_UNIT_MISSES,
+	PLDM_SENSOR_UNIT_RETRIES,
+	PLDM_SENSOR_UNIT_OVERRUNS_OVERFLOWS,
+	PLDM_SENSOR_UNIT_UNDERRUNS,
+	PLDM_SENSOR_UNIT_COLLISIONS,
+	PLDM_SENSOR_UNIT_PACKETS,
+	PLDM_SENSOR_UNIT_MESSAGES,
+	PLDM_SENSOR_UNIT_CHARATERS,
+	PLDM_SENSOR_UNIT_ERRORS,
+	PLDM_SENSOR_UNIT_CORRECTED_ERRORS,
+	PLDM_SENSOR_UNIT_UNCORRECTABLE_ERRORS,
+	PLDM_SENSOR_UNIT_SQUARE_MILS,
+	PLDM_SENSOR_UNIT_SQUARE_INCHES,
+	PLDM_SENSOR_UNIT_SQUARE_FEET,
+	PLDM_SENSOR_UNIT_SQUARE_CENTIMETERS,
+	PLDM_SENSOR_UNIT_SQUARE_METERS,
+	PLDM_SENSOR_UNIT_OEMUNIT = 255
+};
+
+enum pldm_occurrence_rate {
+	PLDM_RATE_UNIT_NONE = 0x0,
+	PLDM_RATE_UNIT_PER_MICRO_SECOND,
+	PLDM_RATE_UNIT_PER_MILLI_SECOND,
+	PLDM_RATE_UNIT_PER_SECOND,
+	PLDM_RATE_UNIT_PER_MINUTE,
+	PLDM_RATE_UNIT_PER_HOUR
+};
+
 /** @brief PLDM respository state */
 enum pldm_repository_state {
 	PLDM_AVAILABLE,
@@ -400,6 +503,31 @@
 	uint8_t possible_states[1];
 } __attribute__((packed));
 
+/** @struct pldm_compact_nummeric_sensor_pdr
+ *
+ *  Structure representing PLDM compact nummeric sensor PDR
+ */
+struct pldm_compact_nummeric_sensor_pdr {
+	struct pldm_pdr_hdr hdr;
+	uint16_t terminus_handle;
+	uint16_t sensor_id;
+	uint16_t entity_type;
+	uint16_t entity_instance;
+	uint16_t container_id;
+	uint8_t sensor_name_length;
+	uint8_t base_unit;
+	int8_t unit_modifier;
+	uint8_t occurrence_rate;
+	bitfield8_t range_field_support;
+	int32_t warning_high;
+	int32_t warning_low;
+	int32_t critical_high;
+	int32_t critical_low;
+	int32_t fatal_high;
+	int32_t fatal_low;
+	uint8_t sensor_name[1];
+} __attribute__((packed));
+
 /** @brief Encode PLDM state sensor PDR
  *
  * @param[in/out] sensor                 Structure to encode. All members of