New operational status and OID Header APIs

The following new APIs are introduced:

onlp_<subsystem>_status_get()
- Retreives only the operational status (PRESENT, FAILED, UNPLUGGED) of the object
  Useful for improving the performance of the platform manager, whose primary concern
  is the operational status, not the object information itself.

onlp_<subsystem>_hdr_get()
- Retrieves the OID header (description, parent, children) only.
  Improved performance of OID iteration by avoiding collection of all
  of the unused object information during execution.

If a platform does not implement these functions they will be simulated using
calls to the existing onlp_<subsystem>_info_get(), which reduces to the
original performance level.
This commit is contained in:
Jeffrey Townsend
2016-12-12 20:09:04 +00:00
parent 65529d39fe
commit 97f1dcbc58
18 changed files with 256 additions and 20 deletions

View File

@@ -113,6 +113,22 @@ int onlp_fan_init(void);
*/
int onlp_fan_info_get(onlp_oid_t id, onlp_fan_info_t* rv);
/**
* @brief Retrieve the fan's operational status.
* @param id The fan OID.
* @param rv [out] Receives the fan's operations status flags.
* @notes Only operational state needs to be returned -
* PRESENT/FAILED
*/
int onlp_fan_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Retrieve the fan's OID hdr.
* @param id The fan OID.
* @param rv [out] Receives the OID header.
*/
int onlp_fan_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr);
/**
* @brief Set the fan speed in RPMs.
* @param id The fan OID.

View File

@@ -112,6 +112,20 @@ int onlp_led_init(void);
*/
int onlp_led_info_get(onlp_oid_t id, onlp_led_info_t* rv);
/**
* @brief Get the LED operational status.
* @param id The LED OID
* @param rv [out] Receives the operational status.
*/
int onlp_led_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Get the LED header.
* @param id The LED OID
* @param rv [out] Receives the header.
*/
int onlp_led_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv);
/**
* @brief Turn an LED on or off.
* @param id The LED OID

View File

@@ -49,6 +49,10 @@ typedef enum onlp_status_e {
} \
} while(0)
#define ONLP_FAILURE(_rv) ((_rv) < 0)
#define ONLP_SUCCESS(_rv) (!(ONLP_FAILURE(_rv)))
#define ONLP_UNSUPPORTED(_rv) \
((_rv) == ONLP_STATUS_E_UNSUPPORTED)
/**
* @brief Initialize all subsystems.

View File

@@ -39,6 +39,22 @@ int onlp_fani_init(void);
*/
int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv);
/**
* @brief Retrieve the fan's operational status.
* @param id The fan OID.
* @param rv [out] Receives the fan's operations status flags.
* @notes Only operational state needs to be returned -
* PRESENT/FAILED
*/
int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Retrieve the fan's OID hdr.
* @param id The fan OID.
* @param rv [out] Receives the OID header.
*/
int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr);
/**
* @brief Set the fan speed in RPM.
* @param id The fan OID

View File

@@ -39,6 +39,20 @@ int onlp_ledi_init(void);
*/
int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* rv);
/**
* @brief Get the LED operational status.
* @param id The LED OID
* @param rv [out] Receives the operational status.
*/
int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Get the LED header.
* @param id The LED OID
* @param rv [out] Receives the header.
*/
int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv);
/**
* @brief Turn an LED on or off
* @param id The LED OID

View File

@@ -39,6 +39,20 @@ int onlp_psui_init(void);
*/
int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* rv);
/**
* @brief Get the PSU's operational status.
* @param id The PSU OID.
* @param rv [out] Receives the operational status.
*/
int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Get the PSU's oid header.
* @param id The PSU OID.
* @param rv [out] Receives the header.
*/
int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv);
/**
* @brief Generic PSU ioctl
* @param id The PSU OID

View File

@@ -40,6 +40,20 @@ int onlp_thermali_init(void);
*/
int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv);
/**
* @brief Retrieve the thermal's operational status.
* @param id The thermal oid.
* @param rv [out] Receives the operational status.
*/
int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Retrieve the thermal's oid header.
* @param id The thermal oid.
* @param rv [out] Receives the header.
*/
int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv);
/**
* @brief Generic ioctl.
*/

View File

@@ -96,6 +96,20 @@ int onlp_psu_init(void);
*/
int onlp_psu_info_get(onlp_oid_t id, onlp_psu_info_t* rv);
/**
* @brief Get the PSU's operational status.
* @param id The PSU OID.
* @param rv [out] Receives the operational status.
*/
int onlp_psu_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Get the PSU's oid header.
* @param id The PSU OID.
* @param rv [out] Receives the header.
*/
int onlp_psu_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv);
/**
* @brief Issue a PSU ioctl.
* @param id The PSU OID

View File

@@ -115,6 +115,19 @@ int onlp_thermal_init(void);
*/
int onlp_thermal_info_get(onlp_oid_t id, onlp_thermal_info_t* rv);
/**
* @brief Retrieve the thermal's operational status.
* @param id The thermal oid.
* @param rv [out] Receives the operational status.
*/
int onlp_thermal_status_get(onlp_oid_t id, uint32_t* rv);
/**
* @brief Retrieve the thermal's oid header.
* @param id The thermal oid.
* @param rv [out] Receives the header.
*/
int onlp_thermal_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv);
/**
* @brief Thermal driver ioctl.

View File

@@ -119,6 +119,37 @@ onlp_fan_info_get_locked__(onlp_oid_t oid, onlp_fan_info_t* fip)
}
ONLP_LOCKED_API2(onlp_fan_info_get, onlp_oid_t, oid, onlp_fan_info_t*, fip);
static int
onlp_fan_status_get_locked__(onlp_oid_t oid, uint32_t* status)
{
int rv = onlp_fani_status_get(oid, status);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_fan_info_t fi;
rv = onlp_fani_info_get(oid, &fi);
*status = fi.status;
}
return rv;
}
ONLP_LOCKED_API2(onlp_fan_status_get, onlp_oid_t, oid, uint32_t*, status);
static int
onlp_fan_hdr_get_locked__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
{
int rv = onlp_fani_hdr_get(oid, hdr);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_fan_info_t fi;
rv = onlp_fani_info_get(oid, &fi);
memcpy(hdr, &fi.hdr, sizeof(fi.hdr));
}
return rv;
}
ONLP_LOCKED_API2(onlp_fan_hdr_get, onlp_oid_t, oid, onlp_oid_hdr_t*, hdr);
static int
onlp_fan_present__(onlp_oid_t id, onlp_fan_info_t* info)

View File

@@ -84,6 +84,38 @@ onlp_led_info_get_locked__(onlp_oid_t id, onlp_led_info_t* info)
}
ONLP_LOCKED_API2(onlp_led_info_get, onlp_oid_t, id, onlp_led_info_t*, info);
static int
onlp_led_status_get_locked__(onlp_oid_t id, uint32_t* status)
{
int rv = onlp_ledi_status_get(id, status);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_led_info_t li;
rv = onlp_ledi_info_get(id, &li);
*status = li.status;
}
return rv;
}
ONLP_LOCKED_API2(onlp_led_status_get, onlp_oid_t, id, uint32_t*, status);
static int
onlp_led_hdr_get_locked__(onlp_oid_t id, onlp_oid_hdr_t* hdr)
{
int rv = onlp_ledi_hdr_get(id, hdr);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_led_info_t li;
rv = onlp_ledi_info_get(id, &li);
memcpy(hdr, &li.hdr, sizeof(li.hdr));
}
return rv;
}
ONLP_LOCKED_API2(onlp_led_hdr_get, onlp_oid_t, id, onlp_oid_hdr_t*, hdr);
static int
onlp_led_set_locked__(onlp_oid_t id, int on_or_off)
{

View File

@@ -90,41 +90,25 @@ oid_type_SYS_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
static int
oid_type_THERMAL_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
{
int rv;
onlp_thermal_info_t ti;
rv = onlp_thermal_info_get(oid, &ti);
memcpy(hdr, &ti.hdr, sizeof(ti.hdr));
return rv;
return onlp_thermal_hdr_get(oid, hdr);
}
static int
oid_type_FAN_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
{
int rv;
onlp_fan_info_t fi;
rv = onlp_fan_info_get(oid, &fi);
memcpy(hdr, &fi.hdr, sizeof(fi.hdr));
return rv;
return onlp_fan_hdr_get(oid, hdr);
}
static int
oid_type_LED_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
{
int rv;
onlp_led_info_t li;
rv = onlp_led_info_get(oid, &li);
memcpy(hdr, &li.hdr, sizeof(li.hdr));
return rv;
return onlp_led_hdr_get(oid, hdr);
}
static int
oid_type_PSU_hdr_get__(onlp_oid_t oid, onlp_oid_hdr_t* hdr)
{
int rv;
onlp_psu_info_t pi;
rv = onlp_psu_info_get(oid, &pi);
memcpy(hdr, &pi.hdr, sizeof(pi.hdr));
return rv;
return onlp_psu_hdr_get(oid, hdr);
}
static int

View File

@@ -60,6 +60,37 @@ onlp_psu_info_get_locked__(onlp_oid_t id, onlp_psu_info_t* info)
}
ONLP_LOCKED_API2(onlp_psu_info_get, onlp_oid_t, id, onlp_psu_info_t*, info);
static int
onlp_psu_status_get_locked__(onlp_oid_t id, uint32_t* status)
{
int rv = onlp_psui_status_get(id, status);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_psu_info_t pi;
rv = onlp_psu_info_get(id, &pi);
*status = pi.status;
}
return rv;
}
ONLP_LOCKED_API2(onlp_psu_status_get, onlp_oid_t, id, uint32_t*, status);
static int
onlp_psu_hdr_get_locked__(onlp_oid_t id, onlp_oid_hdr_t* hdr)
{
int rv = onlp_psui_hdr_get(id, hdr);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_psu_info_t pi;
rv = onlp_psui_info_get(id, &pi);
memcpy(hdr, &pi.hdr, sizeof(pi.hdr));
}
return rv;
}
ONLP_LOCKED_API2(onlp_psu_hdr_get, onlp_oid_t, id, onlp_oid_hdr_t*, hdr);
int
onlp_psu_vioctl_locked__(onlp_oid_t id, va_list vargs)
{

View File

@@ -96,6 +96,37 @@ onlp_thermal_info_get_locked__(onlp_oid_t oid, onlp_thermal_info_t* info)
}
ONLP_LOCKED_API2(onlp_thermal_info_get, onlp_oid_t, oid, onlp_thermal_info_t*, info);
static int
onlp_thermal_status_get_locked__(onlp_oid_t id, uint32_t* status)
{
int rv = onlp_thermali_status_get(id, status);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_thermal_info_t ti;
rv = onlp_thermali_info_get(id, &ti);
*status = ti.status;
}
return rv;
}
ONLP_LOCKED_API2(onlp_thermal_status_get, onlp_oid_t, id, uint32_t*, status);
static int
onlp_thermal_hdr_get_locked__(onlp_oid_t id, onlp_oid_hdr_t* hdr)
{
int rv = onlp_thermali_hdr_get(id, hdr);
if(ONLP_SUCCESS(rv)) {
return rv;
}
if(ONLP_UNSUPPORTED(rv)) {
onlp_thermal_info_t ti;
rv = onlp_thermali_info_get(id, &ti);
memcpy(hdr, &ti.hdr, sizeof(ti.hdr));
}
return rv;
}
ONLP_LOCKED_API2(onlp_thermal_hdr_get, onlp_oid_t, id, onlp_oid_hdr_t*, hdr);
int
onlp_thermal_ioctl(int code, ...)
{

View File

@@ -32,6 +32,8 @@
*/
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_init(void));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_status_get(onlp_oid_t id, uint32_t* status));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_rpm_set(onlp_oid_t id, int rpm));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_percentage_set(onlp_oid_t id, int p));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode));

View File

@@ -27,6 +27,8 @@
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_init(void));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_set(onlp_oid_t id, int on_or_off));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_ioctl(onlp_oid_t id, va_list vargs));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode));

View File

@@ -28,4 +28,6 @@
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_init(void));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_status_get(onlp_oid_t id, uint32_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_psui_ioctl(onlp_oid_t pid, va_list vargs));

View File

@@ -28,4 +28,6 @@
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_init(void));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_thermali_ioctl(int code, va_list vargs));