8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / cfgadm_plugins / ib / common / cfga_ib.h
blob1c07e5c013976d1fe18b897556c9658b1b74c579
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _CFGA_IB_H
27 #define _CFGA_IB_H
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 #include <stdlib.h>
34 #include <strings.h>
35 #include <fcntl.h>
36 #include <ctype.h>
37 #include <unistd.h>
38 #include <libintl.h>
39 #include <sys/types32.h>
40 #include <sys/varargs.h>
41 #include <sys/ib/ibnex/ibnex_devctl.h>
42 #include <libdevinfo.h>
43 #include <libdevice.h>
44 #include <librcm.h>
45 #include <synch.h>
46 #include <thread.h>
47 #include <assert.h>
49 #define CFGA_PLUGIN_LIB
50 #include <config_admin.h>
54 * Debug stuff.
56 #ifdef DEBUG
57 #define DPRINTF printf
58 #else
59 #define DPRINTF 0 &&
60 #endif /* DEBUG */
63 /* for walking links */
64 typedef struct walk_link {
65 char *path;
66 char len;
67 char **linkpp;
68 } walk_link_t;
72 * Stuff carried over for the routines borrowed from cfgadm/SCSI.
74 #define MATCH_MINOR_NAME 1
75 #define S_FREE(x) (((x) != NULL) ? (free(x), (x) = NULL) : (void *)0)
77 /* Return/error codes */
78 typedef enum {
79 ICFGA_ERR = -2,
80 ICFGA_LIB_ERR,
81 ICFGA_OK,
82 ICFGA_BUSY,
83 ICFGA_NO_REC
84 } icfga_ret_t;
87 /* Error Messages */
88 typedef struct {
89 int intl; /* Flag: if 1, internationalize */
90 cfga_err_t cfga_err; /* Error code for libcfgadm */
91 const char *msgstr;
92 } msgcvt_t;
94 /* "intl" defines */
95 #define NO_CVT 0
96 #define CVT 1
98 #define MSG_TBL_SZ(table) (sizeof ((table)) / sizeof (msgcvt_t))
101 /* Error message ids (and indices into ib_error_msgs) "cfga_err values " */
102 typedef enum {
103 CFGA_IB_OK = 0, /* Plugin Related Errors */
104 CFGA_IB_UNKNOWN,
105 CFGA_IB_INTERNAL_ERR,
106 CFGA_IB_INVAL_ARG_ERR,
107 CFGA_IB_OPTIONS_ERR,
108 CFGA_IB_AP_ERR,
109 CFGA_IB_DEVCTL_ERR,
110 CFGA_IB_NOT_CONNECTED,
111 CFGA_IB_NOT_CONFIGURED,
112 CFGA_IB_ALREADY_CONNECTED,
113 CFGA_IB_ALREADY_CONFIGURED,
114 CFGA_IB_CONFIG_OP_ERR,
115 CFGA_IB_UNCONFIG_OP_ERR,
116 CFGA_IB_OPEN_ERR,
117 CFGA_IB_IOCTL_ERR,
118 CFGA_IB_BUSY_ERR,
119 CFGA_IB_ALLOC_FAIL,
120 CFGA_IB_OPNOTSUPP,
121 CFGA_IB_INVAL_APID_ERR,
122 CFGA_IB_DEVLINK_ERR,
123 CFGA_IB_PRIV_ERR,
124 CFGA_IB_NVLIST_ERR,
125 CFGA_IB_HCA_LIST_ERR,
126 CFGA_IB_HCA_UNCONFIG_ERR,
127 CFGA_IB_UPD_PKEY_TBLS_ERR,
128 CFGA_IB_CONFIG_FILE_ERR,
129 CFGA_IB_LOCK_FILE_ERR,
130 CFGA_IB_UNLOCK_FILE_ERR,
131 CFGA_IB_COMM_INVAL_ERR,
132 CFGA_IB_SVC_INVAL_ERR,
133 CFGA_IB_SVC_LEN_ERR,
134 CFGA_IB_SVC_EXISTS_ERR,
135 CFGA_IB_SVC_NO_EXIST_ERR,
136 CFGA_IB_UCFG_CLNTS_ERR,
137 CFGA_IB_INVALID_OP_ERR,
139 CFGA_IB_RCM_HANDLE_ERR, /* Plugin's RCM Related Errors */
140 CFGA_IB_RCM_ONLINE_ERR,
141 CFGA_IB_RCM_OFFLINE_ERR
142 } cfga_ib_ret_t;
146 * Given an error msg index, look up the associated string, and
147 * convert it to the current locale if required.
149 #define ERR_STR(msg_idx) \
150 (ib_get_msg((msg_idx), ib_error_msgs, MSG_TBL_SZ(ib_error_msgs)))
152 /* Defines for "usage" */
153 #define CFGA_IB_HELP_HEADER 1 /* Header only */
154 #define CFGA_IB_HELP_CONFIG 2 /* -c usage help */
155 #define CFGA_IB_HELP_LIST 3 /* -x list_clients usage help */
156 #define CFGA_IB_HELP_UPD_PKEY 4 /* -x update_pkey_tbls usage help */
157 #define CFGA_IB_HELP_CONF_FILE1 5 /* -x [add_service|delete_service] */
158 #define CFGA_IB_HELP_CONF_FILE2 6 /* -x list_services help */
159 #define CFGA_IB_HELP_UPD_IOC_CONF \
160 7 /* -x update_ioc_config help */
161 #define CFGA_IB_HELP_UNCFG_CLNTS \
162 8 /* -x unconfig_clients usage help */
163 #define CFGA_IB_HELP_UNKNOWN 9 /* unknown help */
165 #define IB_RETRY_DEVPATH 12 /* devicepath show up: retry count */
166 #define IB_MAX_DEVPATH_DELAY 6 /* sleep for 6 seconds */
167 #define IB_NUM_NVPAIRS 6 /* for "info", "ap_id" etc. */
169 /* Misc text strings */
170 #define CFGA_DEV_DIR "/dev/cfg"
171 #define IB_STATIC_APID "/dev/cfg/ib"
172 #define MINOR_SEP ":"
173 #define IB_APID "apid"
174 #define IB_CFGADM_DEFAULT_AP_TYPE "unknown"
175 #define IB_PORT_TYPE "IB-PORT"
176 #define IB_FABRIC_INFO "InfiniBand Fabric"
177 #define IB_HCA_TYPE "IB-HCA"
178 #define IB_IOC_TYPE "IB-IOC"
179 #define IB_VPPA_TYPE "IB-VPPA"
180 #define IB_HCASVC_TYPE "IB-HCA_SVC"
181 #define IB_PSEUDO_TYPE "IB-PSEUDO"
182 #define IB_FABRIC_TYPE "IB-Fabric"
183 #define IB_FABRIC_APID_STR "ib:fabric"
185 /* -x commands */
186 #define IB_LIST_HCA_CLIENTS "list_clients" /* list HCA's */
187 /* clients */
188 #define IB_UNCONFIG_HCA_CLIENTS "unconfig_clients" /* unconfig */
189 /* HCA's */
190 /* clients */
191 #define IB_UPDATE_PKEY_TBLS "update_pkey_tbls" /* re-read */
192 /* P_Keys */
193 #define IB_ADD_SERVICE "add_service" /* add svc */
194 #define IB_DELETE_SERVICE "delete_service" /* delete svc */
195 #define IB_LIST_SERVICES "list_services" /* list svcs */
196 #define IB_UPDATE_IOC_CONF "update_ioc_config" /* update IOC */
197 /* config */
199 /* for confirm operation */
200 #define IB_CONFIRM1 \
201 "This operation will suspend activity on the IB device\nContinue"
202 #define IB_CONFIRM3 \
203 "This operation will unconfigure IB clients of this HCA\nContinue"
204 #define IB_CONFIRM4 \
205 "This operation will update P_Key tables for all ports of all HCAs"
206 #define IB_CONFIRM5 \
207 "This operation can update properties of IOC devices."
210 * Export "node_type"s from ibnex_node_type_t (see ibnex.h) to
211 * cfgadm in user land. NOTE: If ibnex_node_type_t changes in
212 * ibnex.h; do not forget to update these values here as well.
214 #define IBNEX_PORT_NODE_TYPE 0
215 #define IBNEX_VPPA_NODE_TYPE 1
216 #define IBNEX_HCASVC_NODE_TYPE 2
217 #define IBNEX_IOC_NODE_TYPE 3
218 #define IBNEX_PSEUDO_NODE_TYPE 4
220 /* for ib.conf file support */
221 #define IBCONF_ADD_ENTRY 1
222 #define IBCONF_DELETE_ENTRY 2
224 #ifdef __cplusplus
226 #endif
228 #endif /* _CFGA_IB_H */