IPMI from drive to application (next)

Source: Internet
Author: User

Continuing with the Apple told above, we need to understand the structure of the OPENIPMI code and the process and characteristics of the OPENIPMI program before using the OpenIPMI ready-made libraries and example programs.

The purpose of OPENIPMI is to block the details of the IPMI protocol and provide the user with a framework and interface for quickly implementing SMS. As a result, it internally implements the various types (data structures) mentioned in the IPMI protocol, such as Sensor,sdr,sel,mc,sel,entity and so on, and uses object-oriented thinking to provide many ways to query and set up these data structures. Of course, in order to block different platforms and interface differences, OpenIPMI himself in the user layer encapsulated a layer of timer mechanism, lock synchronization mechanism. In addition, in order to provide users with a unified approach to operations, OPENIPMI has customized some additional data structures, such as domain,connection and so on. Combining the analysis of the document and the original code, we can see that the data structure of OPENIPMI is more complex and interrelated:


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/AA/wKiom1YDgMaAVmAxAAPPdssEQnc062.jpg "title=" Openipmi_structure.jpg "alt=" Wkiom1ydgmaavmaxaappdsseqnc062.jpg "/>


From the diagram above, we can see the middle of the ipmi_domain_t, which is associated with the BMC itself related to the mc,sdr,sensor,entity and other data structures, these members are to be initialized after the domain is established. The os_handler_s data structure on the top left side of the graph above is the encapsulation of different memory management and timer mechanism. The IPMI_CON_S data structure below it is a different interface to the BMC, such as the KCS/LAN/IPMB package, to provide the user with a unified command send, link established interface. The data structure associated with the BMC itself is mainly ipmi_mc_s, which includes sel/sdr/sensor/control information and functions for processing OEM differences, while Sel/sdr/sensor/control and other information data correspond to the corresponding entity structure. Each entity structure includes real physical information, and OPENIPMI provides many settings and query operations for this purpose. As an example of ipmi_sensor_s, which itself includes basic information such as lun/sensor number, OPENIPMI provides many of its operations:

|| Ipmi_sensor_convert_from_raw
|| Stand_ipmi_sensor_convert_to_raw
|| Stand_ipmi_sensor_get_tolerance
|| Stand_ipmi_sensor_get_accuracy
|| Stand_ipmi_sensor_reading_name_string
|| Ipmi_sensor_get_callbacks
|| Ipmi_sensor_set_callbacks
|| Ipmi_sensor_set_event_enables
|| Ipmi_sensor_enable_events
|| Ipmi_sensor_disable_events
|| Ipmi_sensor_rearm
|| Ipmi_sensor_get_event_enables
|| Ipmi_sensor_get_hysteresis
|| Ipmi_sensor_set_hysteresis
|| Ipmi_sensor_get_thresholds
|| Ipmi_sensor_set_thresholds
|| Ipmi_sensor_get_reading
|| Ipmi_sensor_get_states

Users can quickly and efficiently build their own SMS by using the mechanisms provided by the OPENIPMI to call correctly in a function-defined format. For example, we need to check that all sensor readings on the system exceed the threshold every 5 seconds, and can take advantage of the timer mechanism, callback mechanism, and out-of-the-box function interface implementations that OPENIPMI has already provided. The specific process is as follows:
1. Execute the Framework code: build up a unified OS handler, initialize the IPMI library, associate connection and OS handler, open a domain, and specify additional initialization functions;
2. Initializing the timer provided by the TIMER:OPENIPM is equivalent to a timed trigger, and the process associated with it is executed once every time. Specifically, you need to initialize a timeval and os_hnd_timer_id_t data structure, set the time-out interval, and specify the function to execute after the timeout. This specifies the function that scans the system for all sensor functions as a function that executes after a timeout. Then start the timer via OS handler. When the setting is complete, the specified function executes once the timer expires. However, it is important to note that the function will only be executed once because the timer does not start automatically after the timeout. To allow the specified function to execute periodically at regular intervals, the thread needs to be exploited.
3. Create a thread from the OS handler call Creat_thread, which executes the main loop of the OpenIPMI event-driven model, which includes a restart timer.
4. Use the OPENIPMI callback mechanism to implement the sensor scan: The function that enumerates the sensor is called first in the function that executes after the timeout:
Ipmi_entity_iterate_sensors (myentity, Iterate_sensor, NULL);
Note that the second parameter of this function is a callback function that requires user customization, and it has a fixed parameter format:
Static Iterate_sensor (ipmi_entity_t *ent, ipmi_sensor_t *sensor, void * b_data)
In particular, it is not necessary to emphasize that after the ipmi_entity_interate_sensors () function is executed, the iterate_sensor is executed immediately, and the former has undergone a three or four-level callback within the OPENIPMI, and when executed to the latter , its first two parameters just point to the ipmi_entity_t and ipmi_sensor_t structure of the currently traversed sensor, so that the user can directly access both parameters as needed. As for how the bottom layer sends IPMI sensor reading requests and reads the response values from the/DEV/IPMI0 device through the IOCTL, the OPENIPMI has been processed so that the user does not need to worry about it. Similarly, if the user needs to traverse all the entity, call the Ipmi_domain_iterate_entities () function and implement the corresponding handle_entity () callback function. It is worth noting that the user can pass arguments to the callback function through the third argument void * Cb_data of the enumeration function ipmi_domain_iterate_xxxx, but the callback function cannot want to bring the information back to the upper layer.
5. Call the function provided by OPENIPMI to query the status of the sensor: OPENIPMI provides a number of functions to set sensor and query sensor, such as Ipmi_is_state_set (), ipmi_set_initial_update _in_progress () and so on. Users can call these functions directly to check whether certain state bits or threshold bits have been set.

Based on the above analysis, it is not difficult to see that with the timer method provided by OPENIPMI, the callback mechanism and the many interfaces provided, the user no longer needs to have a detailed understanding of the driver, the IPMI protocol, or even the need to develop any function to access the BMC, can quickly build their own SMS, This is increasingly accelerating product replacement today, will undoubtedly greatly improve production efficiency, speed up the product line progress.

This article from "Storage Chef" blog, declined reprint!

IPMI from drive to application (next)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.