Emulex Logo
OneCore™ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
elxu_mgmt.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 #ifndef __ELXU_MGMT_H__
34 #define __ELXU_MGMT_H__
35 
36 #include "elxu_device.h"
37 
38 /* Structures and functions used by driver / device management */
39 
40 /**
41  * @brief mgmt_property is a name / value pair
42  */
43 typedef struct mgmt_property {
44  char *name;
45  char *value;
46  char *access;
47  struct mgmt_property *next;
49 
50 /**
51  * @brief mgmt_object is a list of properties
52  */
53 typedef struct mgmt_object {
54  struct mgmt_property *head;
55  struct mgmt_object *next;
57 
58 /**
59  * @brief mgmt_list is a linked list of objects
60  */
61 typedef struct mgmt_list {
62  struct mgmt_object *head;
63 } mgmt_list_t;
64 
65 extern char* mgmt_get_value(elxu_device_t *device, char *name);
66 extern int mgmt_set_value(elxu_device_t *device, char *name, char *value);
67 extern mgmt_list_t* mgmt_get_all(elxu_device_t* device);
68 extern int mgmt_exec(elxu_device_t *device, char *name, void* arg_in, int arg_in_len, void* arg_out, int arg_out_len);
69 void elxu_mgmt_info(elxu_device_t *device);
70 
71 /* Helper functions */
72 extern mgmt_list_t* mgmt_new_list();
73 extern void mgmt_delete_list(mgmt_list_t *list);
74 extern void mgmt_list_add(mgmt_list_t *list, mgmt_object_t *object);
75 extern mgmt_object_t *mgmt_list_remove(mgmt_list_t *list, char *name);
76 extern void mgmt_list_sort(mgmt_list_t *list);
77 extern int mgmt_list_is_empty(mgmt_list_t *list);
78 
79 extern mgmt_property_t *mgmt_new_property(char *name, char *value, char *access);
80 extern void mgmt_delete_property(mgmt_property_t *prop);
81 
83 extern void mgmt_delete_object(mgmt_object_t *obj);
84 extern void mgmt_object_add_property(mgmt_object_t *obj, char *name, char *value, char *access);
85 
86 #endif
87 
88 /**
89 * @page dev_mgmt.html Device Management API
90 *
91 * \li @ref mgmt_status
92 * \li @ref mgmt_config
93 * \li @ref mgmt_actions
94 * \li @ref data_formats
95 * \li @ref list_properties
96 * \li @ref ident_indiv_prop
97 * \li @ref data_structures
98 *
99 * The elxu_mgmt.c file contains helper functions for accessing the driver's device management API.
100 * Functions are provided to retrieve the various lists, parse and display results, and get
101 * individual status and configuration values.
102 *
103 * The OneCore Storage drivers provide an interface for managing the driver and the
104 * controlled device. This device management API consists of a set of seven IOCTL commands which can be
105 * used to query the driver for current state, update configuration values, and request that
106 * the driver perform management actions.
107 *
108 * @section mgmt_status Management Status
109 *
110 * A Status item is read-only information provided by the driver. This might include
111 * information about the driver, about the device being controlled by the driver, or
112 * dynamic information, such as currently open connections.
113 *
114 * The IOCTLs used to list and get status include:
115 * <ul class="devmgmt"><li>The OCS_IOCTL_CMD_GET_STATUS_LIST command returns a list of
116 * the available status items.</li>
117 * <li>The OCS_IOCTL_CMD_GET_STATUS command returns the current value for
118 * a particular status item.</li></ul>
119 *
120 * @section mgmt_config Management Configuration
121 *
122 * Configuration items are those which can be written or updated by the user. This might
123 * include debug settings, MAC addresses, world wide names, port speed, topology, and
124 * so on.
125 *
126 * The IOCTLs used to list, get status, and set values include:
127 * <ul class="devmgmt"><li>The OCS_IOCTL_CMD_GET_CONFIG_LIST command
128 * returns a list of the available configuration items.</li>
129 * <li>The OCS_IOCTL_CMD_GET_CONFIG command returns the current value for
130 * a particular configuration item.</li>
131 * <li>The OCS_IOCTL_CMD_SET_CONFIG command is used to provide a new
132 * value for a configuration item.</li></ul>
133 *
134 * @section mgmt_actions Management Actions
135 *
136 * Actions are functions which the driver can perform when requested by the user.
137 * Examples include firmware download, dump retrieval, and the starting and stopping
138 * of links.
139 *
140 * The IOCTLs used to list and perform actions include:
141 * <ul class="devmgmt"><li>The OCS_IOCTL_CMD_GET_ACTION_LIST command returns a list of
142 * the available actions.</li>
143 * <li>The OCS_IOCTL_CMD_DO_ACTION command runs a particular action.</li></ul>
144 *
145 * @section data_formats Data Formats
146 *
147 * Information passed from the driver to the user is presented in the form of an XML
148 * document. The user provides a buffer into which to store the response and the driver
149 * fills in the buffer. The structure of the XML document mirrors that of the OneCore
150 * Storage driver stack, which is a hierarchy of ocs, domain, node, sport, and IO.
151 *
152 * The XML document is made up of two kinds of elements: “section” and “property”. A
153 * “section” represents a collection of other elements, and can contain properties and
154 * other sections. A “property” has a name and a value.
155 *
156 * @subsection section_tags Section Tags
157 *
158 * The section tag contains the name of the section as an attribute, and is used to represent
159 * a level in the driver hierarchy: ocs, domain, node, and so on. The section name may
160 * have a number designating a particular instance of that type of section. For example, a
161 * sport could have three nodes named node0, node1, and node2.
162 *
163 * @subsubsection section_tags_eg Examples of Section Tags
164 *
165 * <tt><section name="ocs"></tt>
166 * @n <tt><section name="node2"></tt>
167 *
168 *
169 * @subsection property_tags Property Tags
170 *
171 * The property tag has a name attribute that indicates the name of the property. The
172 * contents of the tag are optional and, if present, contain the value of the property. Values
173 * can be in one of three formats: integer, boolean, or text. A text value is surrounded by
174 * quotes, a boolean is either “false” or “true”, and an integer value is a number with an
175 * optional leading “0x” to indicate hexadecimal.
176 *
177 * <b>Examples of Property Tags with Values</b>
178 * @n <tt><property name="is_loop">false</property></tt>
179 * @n <tt><property name="pci_vendor">0x10df</property></tt>
180 * @n <tt><property name="sn”>”FC23130739"</property></tt>
181 *
182 * <b>Examples of Property Tags without Values</b>
183 * @n <tt><property name="ox_id"&nbsp;/></tt>
184 * @n <tt><property name="wwpn"&nbsp;/></tt>
185 *
186 * @section list_properties Lists of Properties
187 *
188 * The APIs that request a list of items (OCS_IOCTL_CMD_GET_STATUS_LIST(),
189 * OCS_IOCTL_CMD_GET_CONFIG_LIST(), OCS_IOCTL_CMD_GET_ACTION_LIST())
190 * return a document which contains all of the available section names and property
191 * names, but no values.
192 * Example
193 *
194 * <b>Example</b>
195 *
196 * The following figure shows the driver's structure
197 * @image html driver_structure.jpg "Figure - Driver Structure"
198 *
199 * The following list shows the result of OCS_IOCTL_CMD_GET_STATUS_LIST() for the
200 * driver structure:
201 *
202 * <tt><section name="ocs">
203 * @n <property name="desc"&nbsp;/>
204 * @n <property name="fw_rev"&nbsp;/>
205 * @n <property name="wwnn"&nbsp;/>
206 * @n <property name="wwpn"&nbsp;/>
207 * @n <property name="sn"&nbsp;/>
208 * @n <section name="domain0">
209 * @n <property name="indicator"&nbsp;/>
210 * @n <property name="attached"&nbsp;/>
211 * @n <property name="is_loop"&nbsp;/>
212 * @n <property name="display_name"&nbsp;/>
213 * @n <section name="sport0">
214 * @n <property name="display_name"&nbsp;/>
215 * @n <property name="is_vport"&nbsp;/>
216 * @n <property name="enable_ini"&nbsp;/>
217 * @n <property name="enable_tgt"&nbsp;/>
218 * @n <property name="p2p"&nbsp;/>
219 * @n <section name="node0">
220 * @n <property name="display_name"&nbsp;/>
221 * @n <property name="indicator"&nbsp;/>
222 * @n <property name="fc_id"&nbsp;/>
223 * @n <property name="attached"&nbsp;/>
224 * @n </section>
225 * @n <section name="node1">
226 * @n <property name="display_name"&nbsp;/>
227 * @n <property name="indicator"&nbsp;/>
228 * @n <property name="fc_id"&nbsp;/>
229 * @n <property name="attached"&nbsp;/>
230 * @n </section>
231 * @n </section>
232 * @n </section>
233 * @n </section></tt>
234 *
235 *
236 * @section ident_indiv_prop Identifying Individual Properties
237 *
238 * The user can specify a particular property in the structure by listing the path to that
239 * property, using a period as a level separator. Using the example in @ref list_properties,
240 * the user can refer to the display_name property for node1 as
241 * “ocs.domain0.sport0.node1.display_name”.
242 * This is used for OCS_IOCTL_CMD_GET_STATUS(), OCS_IOCTL_CMD_GET_CONFIG(),
243 * OCS_IOCTL_CMD_SET_CONFIG(), and OCS_IOCTL_CMD_DO_ACTION() functions.
244 *
245 *
246 * @section data_structures Data Structures
247 * The following data structures are used to pass data between the user application and
248 * the driver.
249 *
250 * @subsection ocs_ioctl_mgmt_buffer_structure ocs_ioctl_mgmt_buffer_t
251 *
252 * <tt>typedef struct {
253 * @n uint8_t *user_buffer;
254 * @n uint32_t user_buffer_len;
255 * @n uint32_t bytes_written;
256 * @n } ocs_ioctl_mgmt_buffer_t;</tt>
257 *
258 * This structure is used by the list functions OCS_IOCTL_CMD_GET_STATUS_LIST(),
259 * OCS_IOCTL_CMD_GET_CONFIG_LIST(), and
260 * OCS_IOCTL_CMD_GET_ACTION_LIST() functions. The user provides a pointer to a buffer and
261 * the length of the buffer. The ioctl writes an XML document into the buffer and set
262 * bytes_written to the size of the response.
263 *
264 * @subsection ocs_ioctl_cmd_get_structure ocs_ioctl_cmd_get_t
265 *
266 * <tt>typedef struct {
267 * @n uint8_t *name;
268 * @n uint8_t *value;
269 * @n uint32_t value_length;
270 * @n } ocs_ioctl_cmd_get_t;</tt>
271 *
272 * This structure is used by the OCS_IOCTL_CMD_GET_STATUS() and
273 * OCS_IOCTL_CMD_GET_CONFIG() functions. The user provides the name of the
274 * property to retrieve, a buffer into which to put the response, and the size of the buffer.
275 * The ioctl fills the buffer with an XML document containing only that property along
276 * with its containing hierarchy.
277 *
278 * @subsection ocs_ioctl_cmd_set_structure ocs_ioctl_cmd_set_t
279 *
280 * <tt>typedef struct {
281 * @n uint8_t *name;
282 * @n uint8_t *value;
283 * @n uint32_tresult;
284 * @n } ocs_ioctl_cmd_set_t;</tt>
285 *
286 * This structure is used by the OCS_IOCTL_CMD_SET_CONFIG() function. The user
287 * provides the name of a property and the new value for that property. The function sets
288 * the result field to 0 on success or non-zero if the operation failed.
289 *
290 * @subsection ocs_ioctl_cmd_action_structure ocs_ioctl_cmd_action_t
291 *
292 * <tt>typedef struct {
293 * @n uint8_t*name;
294 * @n void*arg_in;
295 * @n uint32_targ_in_length;
296 * @n void*arg_out;
297 * @n uint32_targ_out_length;
298 * @n uint32_tresult;
299 * @n } ocs_ioctl_action_t;</tt>
300 *
301 * This structure is used by the OCS_IOCTL_CMD_DO_ACTION() function. The user
302 * provides the name of the action, a buffer with input arguments, and a buffer for output
303 * arguments. Depending on the action the buffers may be NULL if they are not used. For
304 * example, the “gendump” action requires no arguments so arg_in and arg_out are
305 * NULL. The “firmware_write” action requires a firmware image so arg_in points to that
306 * image and arg_out is NULL.
307 *
308 * On completion of the action, the result field is 0 for success and non-zero for an error.
309 */
mgmt_property_t * mgmt_new_property(char *name, char *value, char *access)
mgmt_new_property: Create a new property with the given name and value
Definition: elxu_mgmt.c:255
struct mgmt_object * head
Definition: elxu_mgmt.h:62
void mgmt_delete_object(mgmt_object_t *obj)
mgmt_delete_object: Delete a mgmt object
Definition: elxu_mgmt.c:308
mgmt_object_t * mgmt_new_object()
mgmt_new_object: Create a new mgmt object
Definition: elxu_mgmt.c:290
char * value
Definition: elxu_mgmt.h:45
struct mgmt_property * next
Definition: elxu_mgmt.h:47
int mgmt_exec(elxu_device_t *device, char *name, void *arg_in, int arg_in_len, void *arg_out, int arg_out_len)
Definition: elxu_mgmt.c:466
void elxu_mgmt_info(elxu_device_t *device)
Definition: elxu_mgmt.c:59
void mgmt_delete_property(mgmt_property_t *prop)
mgmt_delete_property: delete a property, freeing the name and value
Definition: elxu_mgmt.c:273
mgmt_object_t * mgmt_list_remove(mgmt_list_t *list, char *name)
Remove an object from a list.
Definition: elxu_mgmt.c:164
struct mgmt_object * next
Definition: elxu_mgmt.h:55
int mgmt_set_value(elxu_device_t *device, char *name, char *value)
Definition: elxu_mgmt.c:447
void mgmt_delete_list(mgmt_list_t *list)
mgmt_delete_list Delete a linked list and free its contents
Definition: elxu_mgmt.c:111
mgmt_list is a linked list of objects
Definition: elxu_mgmt.h:61
void mgmt_object_add_property(mgmt_object_t *obj, char *name, char *value, char *access)
mgmt_object_add_property: Add a name/value pair to an object as a new property
Definition: elxu_mgmt.c:329
char * access
Definition: elxu_mgmt.h:46
mgmt_list_t * mgmt_get_all(elxu_device_t *device)
Definition: elxu_mgmt.c:482
mgmt_object is a list of properties
Definition: elxu_mgmt.h:53
mgmt_list_t * mgmt_new_list()
mgmt_new_list: Create a new empty linked list
Definition: elxu_mgmt.c:96
void mgmt_list_sort(mgmt_list_t *list)
Definition: elxu_mgmt.c:211
mgmt_property is a name / value pair
Definition: elxu_mgmt.h:43
int mgmt_list_is_empty(mgmt_list_t *list)
Definition: elxu_mgmt.c:206
struct mgmt_property * head
Definition: elxu_mgmt.h:54
char * mgmt_get_value(elxu_device_t *device, char *name)
Definition: elxu_mgmt.c:354
void mgmt_list_add(mgmt_list_t *list, mgmt_object_t *object)
mgmt_list_add: Add an object to the tail of a list
Definition: elxu_mgmt.c:131