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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
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>
49 #define CFGA_PLUGIN_LIB
50 #include <config_admin.h>
57 #define DPRINTF printf
63 /* for walking links */
64 typedef struct walk_link
{
72 * Stuff carried over for the routines borrowed from cfgadm/SCSI.
74 #define MATCH_MINOR_NAME 1
75 #define S_FREE(x) (free(x), (x) = NULL)
77 /* Return/error codes */
89 int intl
; /* Flag: if 1, internationalize */
90 cfga_err_t cfga_err
; /* Error code for libcfgadm */
98 #define MSG_TBL_SZ(table) (sizeof ((table)) / sizeof (msgcvt_t))
101 /* Error message ids (and indices into ib_error_msgs) "cfga_err values " */
103 CFGA_IB_OK
= 0, /* Plugin Related Errors */
105 CFGA_IB_INTERNAL_ERR
,
106 CFGA_IB_INVAL_ARG_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
,
121 CFGA_IB_INVAL_APID_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
,
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
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"
186 #define IB_LIST_HCA_CLIENTS "list_clients" /* list HCA's */
188 #define IB_UNCONFIG_HCA_CLIENTS "unconfig_clients" /* unconfig */
191 #define IB_UPDATE_PKEY_TBLS "update_pkey_tbls" /* re-read */
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 */
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
228 #endif /* _CFGA_IB_H */