2 * Copyright (c) 2017 Broadcom. All rights reserved.
3 * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
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.
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.
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.
36 * Declarations for the common functions used by ocs_mgmt.
40 #if !defined(__OCS_MGMT_H__)
41 #define __OCS_MGMT_H__
43 #include "ocs_utils.h"
45 #define OCS_MGMT_MAX_NAME 128
46 #define OCS_MGMT_MAX_VALUE 128
48 #define MGMT_MODE_RD 4
49 #define MGMT_MODE_WR 2
50 #define MGMT_MODE_EX 1
51 #define MGMT_MODE_RW (MGMT_MODE_RD | MGMT_MODE_WR)
53 #define FW_WRITE_BUFSIZE 64*1024
55 typedef struct ocs_mgmt_fw_write_result {
59 uint32_t change_status;
60 } ocs_mgmt_fw_write_result_t;
64 * This structure is used in constructing a table of internal handler functions.
66 typedef void (*ocs_mgmt_get_func)(ocs_t *, char *, ocs_textbuf_t*);
67 typedef int (*ocs_mgmt_set_func)(ocs_t *, char *, char *);
68 typedef int (*ocs_mgmt_action_func)(ocs_t *, char *, void *, uint32_t, void *, uint32_t);
69 typedef struct ocs_mgmt_table_entry_s {
71 ocs_mgmt_get_func get_handler;
72 ocs_mgmt_set_func set_handler;
73 ocs_mgmt_action_func action_handler;
74 } ocs_mgmt_table_entry_t;
77 * This structure is used when defining the top level management handlers for
78 * different types of objects (sport, node, domain, etc)
80 typedef void (*ocs_mgmt_get_list_handler)(ocs_textbuf_t *textbuf, void* object);
81 typedef void (*ocs_mgmt_get_all_handler)(ocs_textbuf_t *textbuf, void* object);
82 typedef int (*ocs_mgmt_get_handler)(ocs_textbuf_t *, char *parent, char *name, void *object);
83 typedef int (*ocs_mgmt_set_handler)(char *parent, char *name, char *value, void *object);
84 typedef int (*ocs_mgmt_exec_handler)(char *parent, char *action, void *arg_in, uint32_t arg_in_length,
85 void *arg_out, uint32_t arg_out_length, void *object);
87 typedef struct ocs_mgmt_functions_s {
88 ocs_mgmt_get_list_handler get_list_handler;
89 ocs_mgmt_get_handler get_handler;
90 ocs_mgmt_get_all_handler get_all_handler;
91 ocs_mgmt_set_handler set_handler;
92 ocs_mgmt_exec_handler exec_handler;
93 } ocs_mgmt_functions_t;
96 /* Helper functions */
97 extern void ocs_mgmt_start_section(ocs_textbuf_t *textbuf, const char *name, int index);
98 extern void ocs_mgmt_start_unnumbered_section(ocs_textbuf_t *textbuf, const char *name);
99 extern void ocs_mgmt_end_section(ocs_textbuf_t *textbuf, const char *name, int index);
100 extern void ocs_mgmt_end_unnumbered_section(ocs_textbuf_t *textbuf, const char *name);
101 extern void ocs_mgmt_emit_property_name(ocs_textbuf_t *textbuf, int access, const char *name);
102 extern void ocs_mgmt_emit_string(ocs_textbuf_t *textbuf, int access, const char *name, const char *value);
103 __attribute__((format(printf,4,5)))
104 extern void ocs_mgmt_emit_int(ocs_textbuf_t *textbuf, int access, const char *name, const char *fmt, ...);
105 extern void ocs_mgmt_emit_boolean(ocs_textbuf_t *textbuf, int access, const char *name, const int value);
106 extern int parse_wwn(char *wwn_in, uint64_t *wwn_out);
108 /* Top level management functions - called by the ioctl */
109 extern void ocs_mgmt_get_list(ocs_t *ocs, ocs_textbuf_t *textbuf);
110 extern void ocs_mgmt_get_all(ocs_t *ocs, ocs_textbuf_t *textbuf);
111 extern int ocs_mgmt_get(ocs_t *ocs, char *name, ocs_textbuf_t *textbuf);
112 extern int ocs_mgmt_set(ocs_t *ocs, char *name, char *value);
113 extern int ocs_mgmt_exec(ocs_t *ocs, char *action, void *arg_in, uint32_t arg_in_length,
114 void *arg_out, uint32_t arg_out_length);
116 extern int set_req_wwnn(ocs_t*, char*, char*);
117 extern int set_req_wwpn(ocs_t*, char*, char*);
118 extern int set_configured_speed(ocs_t*, char*, char*);
119 extern int set_configured_topology(ocs_t*, char*, char*);