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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
31 * All cfgadm entry points that are defined in the config_admin(3X)
32 * needed for InfiniBand support are described here. These cfgadm
33 * interfaces issue ioctl(s) to the IB nexus driver. Attachment points
34 * supported are - IOC, VPPA, Port, HCA_SVC and Pseudo dynamic ap_ids,
35 * the HCA static ap_id, and the IB static ap_id.
37 * Given InfiniBand bus is fabric based, #of dynamic ap_ids present are
38 * unknown at any given point of time. Hence this plugin uses a
39 * packed nvlist data structure to hold ap_id related information.
40 * The IB nexus driver allocates the nvlist data in the kernel
41 * and this plugin processes the data (it is freed by IB nexus driver).
45 /* function prototypes */
46 static int ib_get_link(di_devlink_t
, void *);
47 static icfga_ret_t
ib_physpath_to_devlink(char *, char **, int *);
48 static const char *ib_get_msg(uint_t
, msgcvt_t
*, uint_t
);
49 static void ib_set_msg(char **, ...);
50 static cfga_err_t
ib_err_msg(char **, cfga_ib_ret_t
, const char *, int);
51 static int ib_verify_valid_apid(const char *);
52 static cfga_ib_ret_t
ib_verify_params(const char *, const char *, char **);
53 static void ib_cleanup_after_devctl_cmd(devctl_hdl_t
, nvlist_t
*);
54 static cfga_ib_ret_t
ib_setup_for_devctl_cmd(char *, boolean_t
,
55 devctl_hdl_t
*, nvlist_t
**);
56 static cfga_ib_ret_t
ib_device_configured(devctl_hdl_t
, nvlist_t
*,
58 static cfga_ib_ret_t
ib_device_connected(devctl_hdl_t
, nvlist_t
*,
60 static cfga_ib_ret_t
ib_do_control_ioctl(char *, uint_t
, uint_t
, uint_t
,
62 cfga_err_t
cfga_change_state(cfga_cmd_t
, const char *,
63 const char *, struct cfga_confirm
*,
64 struct cfga_msg
*, char **, cfga_flags_t
);
65 cfga_err_t
cfga_private_func(const char *, const char *,
66 const char *, struct cfga_confirm
*,
67 struct cfga_msg
*, char **, cfga_flags_t
);
68 cfga_err_t
cfga_test(const char *, const char *, struct cfga_msg
*,
69 char **, cfga_flags_t
);
70 static cfga_ib_ret_t
ib_fill_static_apids(char *, cfga_list_data_t
*);
71 cfga_err_t
cfga_list_ext(const char *, cfga_list_data_t
**, int *,
72 const char *, const char *, char **, cfga_flags_t
);
73 void cfga_msg(struct cfga_msg
*, const char *);
74 cfga_err_t
cfga_help(struct cfga_msg
*, const char *,
76 static int ib_confirm(struct cfga_confirm
*, char *);
77 static char *ib_get_devicepath(const char *);
80 /* External function prototypes */
81 extern cfga_ib_ret_t
ib_rcm_offline(const char *, char **, char *,
83 extern cfga_ib_ret_t
ib_rcm_online(const char *, char **, char *,
85 extern cfga_ib_ret_t
ib_rcm_remove(const char *, char **, char *,
87 extern int ib_add_service(char **);
88 extern int ib_delete_service(char **);
89 extern int ib_list_services(struct cfga_msg
*, char **);
93 int cfga_version
= CFGA_HSL_V2
; /* Set the version number for */
94 /* the cfgadm library's use. */
96 static char *ib_help
[] = { /* Help messages */
98 /* CFGA_IB_HELP_HEADER */ "IB specific commands:\n",
99 /* CFGA_IB_HELP_CONFIG */ "cfgadm -c [configure|unconfigure] "
100 "ap_id [ap_id...]\n",
101 /* CFGA_IB_HELP_LIST */ "cfgadm -x list_clients hca_ap_id "
103 /* CFGA_IB_HELP_UPD_PKEY */ "cfgadm -x update_pkey_tbls ib\n",
104 /* CFGA_IB_HELP_CONF_FILE1 */ "cfgadm -o comm=[port|vppa|hca-svc],"
105 "service=<name> -x [add_service|delete_service] ib\n",
106 /* CFGA_IB_HELP_CONF_FILE2 */ "cfgadm -x list_services ib\n",
107 /* CFGA_IB_HELP_UPD_IOC_CONF */ "cfgadm -x update_ioc_config "
109 /* CFGA_IB_HELP_UNCFG_CLNTS */ "cfgadm -x unconfig_clients hca_ap_id "
111 /* CFGA_IB_HELP_UNKNOWN */ "\tunknown command or option: ",
115 static msgcvt_t ib_error_msgs
[] = { /* Error messages */
116 /* CFGA_IB_OK */ { CVT
, CFGA_OK
, "ok" },
117 /* CFGA_IB_UNKNOWN */ { CVT
, CFGA_LIB_ERROR
,
118 "Unknown message; internal error " },
119 /* CFGA_IB_INTERNAL_ERR */ { CVT
, CFGA_LIB_ERROR
,
121 /* CFGA_IB_INVAL_ARG_ERR */ { CVT
, CFGA_LIB_ERROR
,
122 "Invalid input args " },
123 /* CFGA_IB_OPTIONS_ERR */ { CVT
, CFGA_ERROR
,
124 "Hardware specific options not supported " },
125 /* CFGA_IB_AP_ERR */ { CVT
, CFGA_APID_NOEXIST
, "" },
126 /* CFGA_IB_DEVCTL_ERR */ { CVT
, CFGA_LIB_ERROR
,
127 "Cannot issue devctl to " },
128 /* CFGA_IB_NOT_CONNECTED */ { CVT
, CFGA_INSUFFICENT_CONDITION
,
129 "No device connected to " },
130 /* CFGA_IB_NOT_CONFIGURED */ { CVT
, CFGA_INSUFFICENT_CONDITION
,
131 "No device configured to " },
132 /* CFGA_IB_ALREADY_CONNECTED */ { CVT
, CFGA_INSUFFICENT_CONDITION
,
133 "already connected; cannot connect again " },
134 /* CFGA_IB_ALREADY_CONFIGURED */ { CVT
, CFGA_INSUFFICENT_CONDITION
,
135 "already configured " },
136 /* CFGA_IB_CONFIG_OP_ERR */ { CVT
, CFGA_ERROR
,
137 "configure operation failed " },
138 /* CFGA_IB_UNCONFIG_OP_ERR */ { CVT
, CFGA_ERROR
,
139 "unconfigure operation failed " },
140 /* CFGA_IB_OPEN_ERR */ { CVT
, CFGA_LIB_ERROR
, "Cannot open " },
141 /* CFGA_IB_IOCTL_ERR */ { CVT
, CFGA_LIB_ERROR
,
142 "Driver ioctl failed " },
143 /* CFGA_IB_BUSY_ERR */ { CVT
, CFGA_SYSTEM_BUSY
, " " },
144 /* CFGA_IB_ALLOC_FAIL */ { CVT
, CFGA_LIB_ERROR
,
145 "Memory allocation failure " },
146 /* CFGA_IB_OPNOTSUPP */ { CVT
, CFGA_OPNOTSUPP
,
147 "Operation not supported " },
148 /* CFGA_IB_INVAL_APID_ERR */ { CVT
, CFGA_LIB_ERROR
,
149 "Invalid ap_id supplied " },
150 /* CFGA_IB_DEVLINK_ERR */ { CVT
, CFGA_LIB_ERROR
,
151 "Could not find /dev/cfg link for " },
152 /* CFGA_IB_PRIV_ERR */ { CVT
, CFGA_PRIV
, " " },
153 /* CFGA_IB_NVLIST_ERR */ { CVT
, CFGA_ERROR
,
154 "Internal error (nvlist) " },
155 /* CFGA_IB_HCA_LIST_ERR */ { CVT
, CFGA_ERROR
,
156 "Listing HCA's clients failed " },
157 /* CFGA_IB_HCA_UNCONFIG_ERR */ { CVT
, CFGA_ERROR
,
158 "Unconfiguring HCA's clients failed " },
159 /* CFGA_IB_UPD_PKEY_TBLS_ERR */ { CVT
, CFGA_ERROR
,
160 "Updating P_Key tables failed " },
161 /* CFGA_IB_RCM_HANDLE_ERR */ { CVT
, CFGA_ERROR
,
162 "Opening ib.conf file failed " },
163 /* CFGA_IB_LOCK_FILE_ERR */ { CVT
, CFGA_LIB_ERROR
,
164 "Locking ib.conf file failed " },
165 /* CFGA_IB_UNLOCK_FILE_ERR */ { CVT
, CFGA_LIB_ERROR
,
166 "Unlocking ib.conf file failed " },
167 /* CFGA_IB_COMM_INVAL_ERR */ { CVT
, CFGA_INVAL
,
168 "Communication type incorrectly specified " },
169 /* CFGA_IB_SVC_INVAL_ERR */ { CVT
, CFGA_INVAL
,
170 "Service name incorrectly specified " },
171 /* CFGA_IB_SVC_LEN_ERR_ERR */ { CVT
, CFGA_INVAL
,
172 "Service name len should be <= to 4, " },
173 /* CFGA_IB_SVC_EXISTS_ERR */ { CVT
, CFGA_INVAL
, " "},
174 /* CFGA_IB_SVC_NO_EXIST_ERR */ { CVT
, CFGA_INVAL
, " " },
175 /* CFGA_IB_UCFG_CLNTS_ERR */ { CVT
, CFGA_INVAL
,
176 "unconfig_clients failed for HCA " },
177 /* CFGA_IB_INVALID_OP_ERR */ { CVT
, CFGA_OPNOTSUPP
, "on " },
178 /* CFGA_IB_RCM_HANDLE */ { CVT
, CFGA_ERROR
,
179 "cannot get RCM handle "},
180 /* CFGA_IB_RCM_ONLINE_ERR */ { CVT
, CFGA_SYSTEM_BUSY
,
181 "failed to online: "},
182 /* CFGA_IB_RCM_OFFLINE_ERR */ { CVT
, CFGA_SYSTEM_BUSY
,
183 "failed to offline: "}
187 * these are the only valid sub-options for services.
189 static char *ib_service_subopts
[] = {
195 /* Communication Service name : "port" or "vppa" or "hca-svc" */
196 static char *comm_name
= NULL
;
198 char *service_name
= NULL
; /* service name */
199 ib_service_type_t service_type
= IB_NONE
; /* service type */
202 /* ========================================================================= */
204 * The next two funcs are imported from cfgadm_scsi.
205 * ib_physpath_to_devlink is the only func directly used by cfgadm_ib.
206 * ib_get_link supports it.
213 * devlink - devlink for the device path
214 * arg - argument passed to this "walker" function
218 * Continue "walking" or not
220 * Routine to search the /dev directory or a subtree of /dev.
223 ib_get_link(di_devlink_t devlink
, void *arg
)
225 walk_link_t
*larg
= (walk_link_t
*)arg
;
228 * When path is specified, it's the node path without minor
229 * name. Therefore, the ../.. prefixes needs to be stripped.
232 char *content
= (char *)di_devlink_content(devlink
);
233 char *start
= strstr(content
, "/devices/");
235 /* line content must have minor node */
237 strncmp(start
, larg
->path
, larg
->len
) != 0 ||
238 start
[larg
->len
] != ':') {
239 return (DI_WALK_CONTINUE
);
243 *(larg
->linkpp
) = strdup(di_devlink_path(devlink
));
244 return (DI_WALK_TERMINATE
);
250 * ib_physpath_to_devlink
252 * node_path - Physical path of the ap_id node
254 * logpp - Logical path to the ap_id node
257 * ICFGA_OK if everything was fine; otherwise an error with
260 * Given a physical path to an ap_id ensure that it exists
264 ib_physpath_to_devlink(char *node_path
, char **logpp
, int *l_errnop
)
268 di_devlink_handle_t hdl
;
270 if ((hdl
= di_devlink_init(NULL
, 0)) == NULL
) {
272 return (ICFGA_LIB_ERR
);
277 minor_path
= (char *)node_path
+ strlen("/devices");
281 (void) di_devlink_walk(hdl
, "^cfg/", minor_path
, DI_PRIMARY_LINK
,
282 (void *)&larg
, ib_get_link
);
284 di_devlink_fini(&hdl
);
286 if (*logpp
== NULL
) {
288 return (ICFGA_LIB_ERR
);
295 /* ========================================================================= */
302 * msg_index - Index into the message table
303 * msg_tbl - the message table
304 * tbl_size - size of the message table
308 * Message string if valid, otherwise an error
310 * Given the index into a table (msgcvt_t) of messages,
311 * get the message string, converting it to the proper
312 * locale if necessary.
314 * NOTE: See cfga_ib.h
317 ib_get_msg(uint_t msg_index
, msgcvt_t
*msg_tbl
, uint_t tbl_size
)
319 if (msg_index
>= tbl_size
) {
320 DPRINTF("get_error_msg: bad error msg index: %d\n", msg_index
);
321 msg_index
= CFGA_IB_UNKNOWN
;
324 return ((msg_tbl
[msg_index
].intl
) ?
325 dgettext(TEXT_DOMAIN
, msg_tbl
[msg_index
].msgstr
) :
326 msg_tbl
[msg_index
].msgstr
);
336 * ret_str - Returned "message" string.
340 * Allocates and creates a message string (in *ret_str),
341 * by concatenating all the (char *) args together, in order.
342 * Last arg MUST be NULL.
345 ib_set_msg(char **ret_str
, ...)
348 size_t total_len
, ret_str_len
;
351 va_start(valist
, ret_str
);
353 total_len
= (*ret_str
== NULL
) ? 0 : strlen(*ret_str
);
355 while ((str
= va_arg(valist
, char *)) != NULL
) {
356 size_t len
= strlen(str
);
357 char *old_str
= *ret_str
;
359 ret_str_len
= total_len
+ len
+ 1;
360 *ret_str
= (char *)realloc(*ret_str
, ret_str_len
);
361 if (*ret_str
== NULL
) {
363 DPRINTF("ib_set_msg: realloc failed.\n");
368 (void) strlcpy(*ret_str
+ total_len
, str
, ret_str_len
);
380 * ap_id - The attachment point of an IB fabric
382 * errstring - Fill in the error msg string
383 * l_errno - The "errno" to be filled in.
385 * CFGA_IB_OK if we are able to fill in error msg;
386 * otherwise emit an error.
388 * Error message handling.
390 * For the rv passed in, looks up the corresponding error message
391 * string(s), internationalized it if necessary, and concatenates
392 * it into a new memory buffer, and points *errstring to it.
393 * Note not all "rv"s will result in an error message return, as
394 * not all error conditions warrant a IB-specific error message.
396 * Some messages may display ap_id or errno, which is why they are
400 ib_err_msg(char **errstring
, cfga_ib_ret_t rv
, const char *ap_id
, int l_errno
)
404 if (errstring
== NULL
) {
405 return (ib_error_msgs
[rv
].cfga_err
);
408 /* Generate the appropriate IB-specific error message(s) (if any). */
410 case CFGA_IB_OK
: /* Special case - do nothing. */
413 case CFGA_IB_UNKNOWN
:
414 case CFGA_IB_INTERNAL_ERR
:
415 case CFGA_IB_OPTIONS_ERR
:
416 case CFGA_IB_ALLOC_FAIL
:
417 /* These messages require no additional strings passed. */
418 ib_set_msg(errstring
, ERR_STR(rv
), NULL
);
420 case CFGA_IB_NOT_CONNECTED
:
421 case CFGA_IB_NOT_CONFIGURED
:
422 case CFGA_IB_ALREADY_CONNECTED
:
423 case CFGA_IB_ALREADY_CONFIGURED
:
424 case CFGA_IB_CONFIG_OP_ERR
:
425 case CFGA_IB_UNCONFIG_OP_ERR
:
426 case CFGA_IB_BUSY_ERR
:
427 case CFGA_IB_DEVLINK_ERR
:
428 case CFGA_IB_RCM_HANDLE_ERR
:
429 case CFGA_IB_RCM_ONLINE_ERR
:
430 case CFGA_IB_RCM_OFFLINE_ERR
:
431 case CFGA_IB_DEVCTL_ERR
:
432 case CFGA_IB_COMM_INVAL_ERR
:
433 case CFGA_IB_SVC_INVAL_ERR
:
434 case CFGA_IB_SVC_LEN_ERR
:
435 case CFGA_IB_SVC_EXISTS_ERR
:
436 case CFGA_IB_SVC_NO_EXIST_ERR
:
437 case CFGA_IB_LOCK_FILE_ERR
:
438 case CFGA_IB_CONFIG_FILE_ERR
:
439 case CFGA_IB_UNLOCK_FILE_ERR
:
440 case CFGA_IB_UCFG_CLNTS_ERR
:
441 case CFGA_IB_INVALID_OP_ERR
:
442 /* These messages also print ap_id. */
443 ib_set_msg(errstring
, ERR_STR(rv
), "ap_id: ", ap_id
, "", NULL
);
445 case CFGA_IB_IOCTL_ERR
: /* These messages also print errno. */
446 case CFGA_IB_NVLIST_ERR
:
447 errno_str
= l_errno
? strerror(l_errno
) : "";
448 ib_set_msg(errstring
, ERR_STR(rv
), errno_str
,
449 l_errno
? "\n" : "", NULL
);
451 case CFGA_IB_OPEN_ERR
: /* This messages also prints apid and errno. */
452 case CFGA_IB_PRIV_ERR
:
453 case CFGA_IB_HCA_LIST_ERR
:
454 case CFGA_IB_OPNOTSUPP
:
455 case CFGA_IB_INVAL_ARG_ERR
:
456 case CFGA_IB_INVAL_APID_ERR
:
457 case CFGA_IB_HCA_UNCONFIG_ERR
:
458 case CFGA_IB_UPD_PKEY_TBLS_ERR
:
459 errno_str
= l_errno
? strerror(l_errno
) : "";
460 ib_set_msg(errstring
, ERR_STR(rv
), "ap_id: ", ap_id
, "\n",
461 errno_str
, l_errno
? "\n" : "", NULL
);
464 DPRINTF("ib_err_msg: Unrecognized message index: %d\n", rv
);
465 ib_set_msg(errstring
, ERR_STR(CFGA_IB_INTERNAL_ERR
), NULL
);
469 * Determine the proper error code to send back to the cfgadm library.
471 return (ib_error_msgs
[rv
].cfga_err
);
477 * ib_verify_valid_apid
479 * ap_id - The attachment point of an IB fabric
483 * 0 if ap_id is valid; otherwise -1
485 * Check if ap_id is valid or not.
486 * Ensure the ap_id passed is in the correct (physical ap_id) form:
487 * path/device:xx[.xx]+
488 * where xx is a one or two-digit number.
490 * Note the library always calls the plugin with a physical ap_id.
491 * Called by ib_verify_params().
494 ib_verify_valid_apid(const char *ap_id
)
502 l_ap_id
= strchr(ap_id
, *MINOR_SEP
);
506 if (strstr((char *)ap_id
, IBNEX_FABRIC
) != NULL
) {
507 DPRINTF("ib_valid_apid: l_apid = %s\n", l_ap_id
);
508 /* if the ap_id is "ib::" then report an error */
509 if ((strlen(l_ap_id
) == strlen(IBNEX_FABRIC
) + 1) ||
510 (strlen(l_ap_id
) == strlen(IBNEX_FABRIC
) + 2)) {
514 if (strstr(l_ap_id
, "...") != NULL
) {
518 } else { /* HCA ap_ids */
519 /* ap_id has 1..2 or more than 2 dots */
520 if (strstr(l_ap_id
, "..") != NULL
) {
533 * ap_id - The attachment point of an IB fabric
534 * options - command options passed by the cfgadm(1M)
535 * errstring - This contains error msg if command fails
539 * CFGA_IB_OK if parameters are valid; otherwise emit an error.
541 * Check if "options" and "errstring" are valid and if ap_id is
545 ib_verify_params(const char *ap_id
, const char *options
, char **errstring
)
547 if (errstring
!= NULL
) {
551 if (options
!= NULL
) {
552 DPRINTF("ib_verify_params: h/w-specific options not "
554 return (CFGA_IB_OPTIONS_ERR
);
557 if (ib_verify_valid_apid(ap_id
) != 0) {
558 DPRINTF("ib_verify_params: not an IB ap_id.\n");
559 return (CFGA_IB_AP_ERR
);
567 * ib_cleanup_after_devctl_cmd
569 * devctl_hdl - Handler to devctl
570 * user_nvlistp - Name-value-pair list pointer
576 * Cleanup an initialization/setup done in the next function i.e.
577 * ib_setup_for_devctl_cmd().
580 ib_cleanup_after_devctl_cmd(devctl_hdl_t devctl_hdl
, nvlist_t
*user_nvlist
)
582 if (user_nvlist
!= NULL
) {
583 nvlist_free(user_nvlist
);
586 if (devctl_hdl
!= NULL
) {
587 devctl_release(devctl_hdl
);
594 * ib_setup_for_devctl_cmd
596 * ap_id - Attachment point for the IB device in question
597 * use_static_ap_id - Whether to use static ap_id or not flag
599 * devctl_hdl - Handler to devctl
600 * user_nvlistp - Name-value-pair list pointer
602 * CFGA_IB_OK if it succeeds or an appropriate error.
604 * For any IB device that is doing a cfgadm operation this function
605 * sets up a devctl_hdl and allocates a nvlist_t. The devctl_hdl
606 * is acquired using libdevice APIs. The nvlist_t is filled up with
607 * the ap_id (as a string). This nvlist_t is looked up in the kernel
608 * to figure out which ap_id we are currently dealing with.
610 * "use_static_ap_id" flag tells if one should do a devctl_ap_acquire
611 * with IB_STATIC_APID or not. NOTE: We need an actual file-system
612 * vnode to do a devctl_ap_acquire.
614 * NOTE: always call ib_cleanup_after_devctl_cmd() after this function.
617 ib_setup_for_devctl_cmd(char *ap_id
, boolean_t use_static_ap_id
,
618 devctl_hdl_t
*devctl_hdl
, nvlist_t
**user_nvlistp
)
620 char *apid
= (use_static_ap_id
== B_TRUE
) ? IB_STATIC_APID
: ap_id
;
622 /* Get a handle to the ap */
623 if ((*devctl_hdl
= devctl_ap_acquire(apid
, NULL
)) == NULL
) {
624 DPRINTF("ib_setup_for_devctl_cmd: devctl_ap_acquire "
625 "errno: %d\n", errno
);
626 ib_cleanup_after_devctl_cmd(*devctl_hdl
, *user_nvlistp
);
627 return (CFGA_IB_DEVCTL_ERR
);
630 /* Set up to pass dynamic ap_id down to driver */
631 if (nvlist_alloc(user_nvlistp
, NV_UNIQUE_NAME_TYPE
, NULL
) != 0) {
632 DPRINTF("ib_setup_for_devctl: nvlist_alloc errno: %d\n", errno
);
633 *user_nvlistp
= NULL
; /* Prevent possible incorrect free in */
634 /* ib_cleanup_after_devctl_cmd */
635 ib_cleanup_after_devctl_cmd(*devctl_hdl
, *user_nvlistp
);
636 return (CFGA_IB_NVLIST_ERR
);
639 /* create a "string" entry */
640 if (nvlist_add_string(*user_nvlistp
, IB_APID
, ap_id
) == -1) {
641 DPRINTF("ib_setup_for_devctl_cmd: nvlist_add_string failed. "
642 "errno: %d\n", errno
);
643 ib_cleanup_after_devctl_cmd(*devctl_hdl
, *user_nvlistp
);
644 return (CFGA_IB_NVLIST_ERR
);
653 * ib_device_configured
655 * hdl - Handler to devctl
656 * nvl - Name-value-pair list pointer
658 * rstate - Receptacle state for the apid
660 * CFGA_IB_OK if it succeeds or an appropriate error.
662 * Checks if there is a device actually configured to the ap? If so,
663 * issues a "devctl" to get the Receptacle state for that ap_id.
664 * If the ap_id is already configured it returns CFGA_IB_OK.
665 * Otherwise it returns a failure.
668 ib_device_configured(devctl_hdl_t hdl
, nvlist_t
*nvl
, ap_rstate_t
*rstate
)
671 devctl_ap_state_t devctl_ap_state
;
673 /* get ap_id's "devctl_ap_state" first */
674 if (devctl_ap_getstate(hdl
, nvl
, &devctl_ap_state
) == -1) {
675 DPRINTF("ib_device_configured failed, errno: %d\n", errno
);
676 return (CFGA_IB_DEVCTL_ERR
);
679 rv
= CFGA_IB_ALREADY_CONFIGURED
;
680 *rstate
= devctl_ap_state
.ap_rstate
;
681 if (devctl_ap_state
.ap_ostate
!= AP_OSTATE_CONFIGURED
) {
682 return (CFGA_IB_NOT_CONFIGURED
);
691 * ib_device_connected
693 * hdl - Handler to devctl
694 * nvl - Name-value-pair list pointer
696 * ostate - Occupant state for the apid
698 * CFGA_IB_OK if it succeeds or an appropriate error.
700 * Checks if there is a device actually connected to the ap? If so,
701 * issues a "devctl" to get the Occupant state for that ap_id.
702 * If the ap_id is already connected it returns CFGA_IB_OK.
703 * Otherwise it returns a failure.
706 ib_device_connected(devctl_hdl_t hdl
, nvlist_t
*list
, ap_ostate_t
*ostate
)
708 cfga_ib_ret_t rv
= CFGA_IB_ALREADY_CONNECTED
;
709 devctl_ap_state_t devctl_ap_state
;
711 if (devctl_ap_getstate(hdl
, list
, &devctl_ap_state
) == -1) {
712 DPRINTF("ib_device_connected failed, errno: %d\n", errno
);
713 return (CFGA_IB_DEVCTL_ERR
);
716 *ostate
= devctl_ap_state
.ap_ostate
;
717 if (devctl_ap_state
.ap_rstate
!= AP_RSTATE_CONNECTED
) {
718 return (CFGA_IB_NOT_CONNECTED
);
727 * ib_do_control_ioctl
729 * ap_id - The dynamic attachment point of an IB device
730 * sub_cmd1 - Sub Command 1 to DEVCTL_AP_CONTROL devctl
731 * sub_cmd2 - Sub Command 2 to DEVCTL_AP_CONTROL devctl
732 * (Mandatory except for IBNEX_NUM_HCA_NODES,
733 * IBNEX_NUM_DEVICE_NODES,
734 * IBNEX_UPDATE_PKEY_TBLS &
735 * IBNEX_UPDATE_IOC_CONF)
736 * misc_arg - optional arguments to DEVCTL_AP_CONTROL devctl
738 * descrp - Buffer containing data back from kernel
739 * sizep - Length of the buffer back from kernel
741 * CFGA_IB_OK if it succeeds or an appropriate error.
743 * Issues DEVCTL_AP_CONTROL devctl with sub_cmd1 first which actually
744 * queries the IBNEX module in the kernel on the size of the data to
747 * Next issues DEVCTL_AP_CONTROL devctl with a buffer of that much
748 * size and gets the actual data back.
749 * Passes the data and the size back to caller.
752 ib_do_control_ioctl(char *ap_id
, uint_t sub_cmd1
, uint_t sub_cmd2
,
753 uint_t misc_arg
, void **descrp
, size_t *sizep
)
756 uint32_t local_size
= 0;
757 cfga_ib_ret_t rv
= CFGA_IB_OK
;
758 struct ibnex_ioctl_data ioctl_data
;
760 /* try to open the ONLY static ap_id */
761 if ((fd
= open(IB_STATIC_APID
, O_RDONLY
)) == -1) {
762 DPRINTF("ib_do_control_ioctl: open failed: "
763 "errno = %d\n", errno
);
764 /* Provides a more useful error msg */
765 rv
= (errno
== EBUSY
) ? CFGA_IB_BUSY_ERR
: CFGA_IB_OPEN_ERR
;
770 * Find out first how large a buffer is needed?
771 * NOTE: Ioctls only accept/return a 32-bit int for a get_size
772 * to avoid 32/64 and BE/LE issues.
774 ioctl_data
.cmd
= sub_cmd1
;
775 ioctl_data
.misc_arg
= (uint_t
)misc_arg
;
776 ioctl_data
.buf
= (caddr_t
)&local_size
;
777 ioctl_data
.bufsiz
= sizeof (local_size
);
779 /* Pass "ap_id" up for all other commands */
780 if (sub_cmd1
!= IBNEX_NUM_DEVICE_NODES
&&
781 sub_cmd1
!= IBNEX_NUM_HCA_NODES
&&
782 sub_cmd1
!= IBNEX_UPDATE_PKEY_TBLS
) {
783 ioctl_data
.ap_id
= (caddr_t
)ap_id
;
784 ioctl_data
.ap_id_len
= strlen(ap_id
);
787 ioctl_data
.ap_id
= NULL
;
788 ioctl_data
.ap_id_len
= 0;
791 if (ioctl(fd
, DEVCTL_AP_CONTROL
, &ioctl_data
) != 0) {
792 DPRINTF("ib_do_control_ioctl: size ioctl ERR, errno: %d\n",
795 rv
= (errno
== EBUSY
) ? CFGA_IB_BUSY_ERR
: CFGA_IB_IOCTL_ERR
;
801 * Don't do the second ioctl only in these cases
802 * (NOTE: the data is returned in the first ioctl itself; if any)
804 if (sub_cmd1
== IBNEX_NUM_DEVICE_NODES
||
805 sub_cmd1
== IBNEX_NUM_HCA_NODES
||
806 sub_cmd1
== IBNEX_UPDATE_PKEY_TBLS
||
807 sub_cmd1
== IBNEX_UPDATE_IOC_CONF
) {
812 if (local_size
== 0 || (*descrp
= malloc(*sizep
)) == NULL
) {
813 DPRINTF("ib_do_control_ioctl: malloc failed\n");
815 return (CFGA_IB_ALLOC_FAIL
);
819 ioctl_data
.cmd
= sub_cmd2
;
820 ioctl_data
.buf
= (caddr_t
)*descrp
;
821 ioctl_data
.bufsiz
= *sizep
;
823 if (ioctl(fd
, DEVCTL_AP_CONTROL
, &ioctl_data
) != 0) {
824 DPRINTF("ib_do_control_ioctl: ioctl failed: errno:%d\n", errno
);
825 if (*descrp
!= NULL
) {
829 rv
= (errno
== EBUSY
) ? CFGA_IB_BUSY_ERR
: CFGA_IB_IOCTL_ERR
;
837 /* ========================================================================== */
844 * state_change_cmd - Argument to the cfgadm -c command
845 * ap_id - The attachment point of an IB fabric
846 * options - State Change command options passed by the cfgadm(1M)
847 * confp - Whether this command requires confirmation?
848 * msgp - cfgadm error message for this plugin
849 * errstring - This contains error msg if command fails
850 * flags - Cfgadm(1m) flags
854 * If the command succeeded perform the cfgadm -c <cmd>;
855 * otherwise emit an error
861 cfga_change_state(cfga_cmd_t state_change_cmd
, const char *ap_id
,
862 const char *options
, struct cfga_confirm
*confp
, struct cfga_msg
*msgp
,
863 char **errstring
, cfga_flags_t flags
)
867 nvlist_t
*nvl
= NULL
;
868 boolean_t static_ap_id
= B_TRUE
;
871 devctl_hdl_t hdl
= NULL
;
872 cfga_ib_ret_t rv
= CFGA_IB_OK
;
874 if ((rv
= ib_verify_params(ap_id
, options
, errstring
)) != CFGA_IB_OK
) {
875 (void) cfga_help(msgp
, options
, flags
);
876 return (ib_err_msg(errstring
, CFGA_IB_INVAL_APID_ERR
,
881 * All subcommands which can change state of device require
884 if (geteuid() != 0) {
885 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
, errno
));
888 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) == NULL
)
889 static_ap_id
= B_FALSE
;
891 if ((rv
= ib_setup_for_devctl_cmd((char *)ap_id
, static_ap_id
,
892 &hdl
, &nvl
)) != CFGA_IB_OK
) {
893 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
894 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
897 switch (state_change_cmd
) {
898 case CFGA_CMD_CONFIGURE
:
899 rv
= ib_device_connected(hdl
, nvl
, &ostate
);
900 if (rv
!= CFGA_IB_ALREADY_CONNECTED
) {
901 ret
= (rv
!= CFGA_IB_NOT_CONNECTED
) ?
902 CFGA_IB_CONFIG_OP_ERR
: rv
;
903 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
904 return (ib_err_msg(errstring
, ret
, ap_id
, errno
));
907 if (rv
== CFGA_IB_ALREADY_CONNECTED
) {
909 * special case handling for
910 * SLM based cfgadm disconnects
912 if (ostate
== AP_OSTATE_CONFIGURED
) {
913 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
914 return (ib_err_msg(errstring
,
915 CFGA_IB_ALREADY_CONFIGURED
, ap_id
,
921 rv
= CFGA_IB_OK
; /* Other status don't matter */
923 if (devctl_ap_configure(hdl
, nvl
) != 0) {
924 DPRINTF("cfga_change_state: devctl_ap_configure "
925 "failed. errno: %d\n", errno
);
926 rv
= CFGA_IB_CONFIG_OP_ERR
;
930 devpath
= ib_get_devicepath(ap_id
);
931 if (devpath
== NULL
) {
935 * try for some time as IB hotplug thread
936 * takes a while to create the path
937 * and then eventually give up
940 i
< IB_RETRY_DEVPATH
&& (devpath
== NULL
); i
++) {
941 sleep(IB_MAX_DEVPATH_DELAY
);
942 devpath
= ib_get_devicepath(ap_id
);
945 if (devpath
== NULL
) {
946 DPRINTF("cfga_change_state: get device "
947 "path failed i = %d\n", i
);
948 rv
= CFGA_IB_CONFIG_OP_ERR
;
955 case CFGA_CMD_UNCONFIGURE
:
956 if ((rv
= ib_device_connected(hdl
, nvl
, &ostate
)) !=
957 CFGA_IB_ALREADY_CONNECTED
) {
958 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
959 if (rv
== CFGA_IB_DEVCTL_ERR
)
960 rv
= CFGA_IB_INVALID_OP_ERR
;
961 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
964 /* check if it is already unconfigured */
965 if ((rv
= ib_device_configured(hdl
, nvl
, &rstate
)) ==
966 CFGA_IB_NOT_CONFIGURED
) {
967 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
968 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
971 rv
= CFGA_IB_OK
; /* Other statuses don't matter */
973 if (!ib_confirm(confp
, IB_CONFIRM1
)) {
974 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
978 devpath
= ib_get_devicepath(ap_id
);
979 if (devpath
== NULL
) {
980 DPRINTF("cfga_change_state: get device path failed\n");
981 rv
= CFGA_IB_UNCONFIG_OP_ERR
;
985 if ((rv
= ib_rcm_offline(ap_id
, errstring
, devpath
, flags
)) !=
991 ret
= devctl_ap_unconfigure(hdl
, nvl
);
993 DPRINTF("cfga_change_state: devctl_ap_unconfigure "
994 "failed with errno: %d\n", errno
);
995 rv
= CFGA_IB_UNCONFIG_OP_ERR
;
996 if (errno
== EBUSY
) {
997 rv
= CFGA_IB_BUSY_ERR
;
999 (void) ib_rcm_online(ap_id
, errstring
, devpath
, flags
);
1002 (void) ib_rcm_remove(ap_id
, errstring
, devpath
, flags
);
1009 case CFGA_CMD_UNLOAD
:
1010 case CFGA_CMD_CONNECT
:
1011 case CFGA_CMD_DISCONNECT
:
1012 (void) cfga_help(msgp
, options
, flags
);
1013 rv
= CFGA_IB_OPNOTSUPP
;
1018 (void) cfga_help(msgp
, options
, flags
);
1019 rv
= CFGA_IB_INTERNAL_ERR
;
1022 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1023 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1031 * func - The private function (passed w/ -x option)
1032 * ap_id - The attachment point of an IB fabric
1033 * options - Private function command options passed
1035 * confp - Whether this command requires confirmation?
1036 * msgp - cfgadm error message for this plugin
1037 * errstring - This contains error msg if command fails
1038 * flags - Cfgadm(1m) flags
1042 * If the command succeeded perform the 'cfgadm -x <func>'; otherwise
1045 * Do cfgadm -x <func>
1049 cfga_private_func(const char *func
, const char *ap_id
, const char *options
,
1050 struct cfga_confirm
*confp
, struct cfga_msg
*msgp
, char **errstring
,
1053 int len
, ret
, count
= 0;
1054 char *clnt_name
= NULL
, *alt_hca
= NULL
;
1055 char *clnt_apid
= NULL
, *clnt_devpath
= NULL
;
1056 char *name
, *msg
= NULL
;
1057 char *fab_apid
= strstr((char *)ap_id
, IBNEX_FABRIC
);
1058 size_t info_len
= 0;
1059 uchar_t
*info
= NULL
;
1061 nvpair_t
*nvp
= NULL
;
1063 devctl_hdl_t hdl
= NULL
;
1066 if ((rv
= ib_verify_params(ap_id
, NULL
, errstring
)) != CFGA_IB_OK
) {
1067 DPRINTF("cfga_private_func: ib_verify_params "
1068 "failed with rv: %d\n", rv
);
1069 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1073 DPRINTF("cfga_private_func: func is NULL\n");
1074 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
, ap_id
,
1079 * check first if IB static ap_id is "configured" for use
1081 if (fab_apid
!= NULL
) {
1082 if ((rv
= ib_setup_for_devctl_cmd(fab_apid
, B_TRUE
, &hdl
,
1083 &nvl
)) != CFGA_IB_OK
) {
1084 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1085 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1087 if ((rv
= ib_device_configured(hdl
, nvl
, &rstate
)) ==
1088 CFGA_IB_NOT_CONFIGURED
) {
1089 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1091 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1095 DPRINTF("cfga_private_func: func is %s\n", func
);
1096 if (strcmp(func
, IB_LIST_HCA_CLIENTS
) == 0) { /* -x list_clients */
1098 /* only supported on HCA ap_ids */
1099 if (fab_apid
!= NULL
) {
1100 DPRINTF("cfga_private_func: fabric apid supplied\n");
1101 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1105 if ((msg
= (char *)calloc(256, 1)) == NULL
) {
1106 DPRINTF("cfga_private_func: malloc for msg failed. "
1107 "errno: %d\n", errno
);
1108 return (ib_err_msg(errstring
, CFGA_IB_ALLOC_FAIL
,
1112 if ((rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_HCA_LIST_SZ
,
1113 IBNEX_HCA_LIST_INFO
, 0, (void **)&info
, &info_len
)) != 0) {
1114 DPRINTF("cfga_private_func: "
1115 "ib_do_control_ioctl list failed :%d\n", rv
);
1117 return (ib_err_msg(errstring
, CFGA_IB_HCA_LIST_ERR
,
1121 if (nvlist_unpack((char *)info
, info_len
, &nvl
, 0)) {
1122 DPRINTF("cfga_private_func: "
1123 "nvlist_unpack 2 failed %p\n", info
);
1126 return (ib_err_msg(errstring
, CFGA_IB_NVLIST_ERR
, ap_id
,
1130 (void) snprintf(msg
, 256, "Ap_Id\t\t\t IB Client\t\t "
1132 cfga_msg(msgp
, msg
);
1134 /* Walk the NVPAIR data */
1135 while (nvp
= nvlist_next_nvpair(nvl
, nvp
)) {
1136 name
= nvpair_name(nvp
);
1137 if (strcmp(name
, "Client") == 0) {
1138 (void) nvpair_value_string(nvp
, &clnt_name
);
1140 } else if (strcmp(name
, "Alt_HCA") == 0) {
1141 (void) nvpair_value_string(nvp
, &alt_hca
);
1143 } else if (strcmp(name
, "ApID") == 0) {
1144 (void) nvpair_value_string(nvp
, &clnt_apid
);
1148 /* check at the end; print message per client found */
1151 (void) snprintf(msg
, 256, "%-30s %-25s %s\n",
1152 clnt_apid
, clnt_name
, alt_hca
);
1153 cfga_msg(msgp
, msg
);
1155 } /* end of while */
1161 /* -x unconfig_clients */
1162 } else if (strcmp(func
, IB_UNCONFIG_HCA_CLIENTS
) == 0) {
1164 * -x unconfig_clients changes state by calling into RCM.
1165 * It needs root privileges.
1167 if (geteuid() != 0) {
1168 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1172 /* only supported on HCA ap_ids */
1173 if (fab_apid
!= NULL
) {
1174 DPRINTF("cfga_private_func: fabric apid supplied\n");
1175 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1180 * Check w/ user if it is ok to do this operation
1181 * If the user fails to confirm, bailout
1183 if (!ib_confirm(confp
, IB_CONFIRM3
))
1186 /* Get device-paths of all the IOC/Port/Pseudo devices */
1187 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_UNCFG_CLNTS_SZ
,
1188 IBNEX_UNCFG_CLNTS_INFO
, 0, (void **)&info
, &info_len
);
1190 DPRINTF("cfga_private_func: ib_do_control_ioctl "
1191 "failed :%d\n", rv
);
1192 return (ib_err_msg(errstring
, CFGA_IB_HCA_UNCONFIG_ERR
,
1196 if (nvlist_unpack((char *)info
, info_len
, &nvl
, 0)) {
1197 DPRINTF("cfga_private_func: nvlist_unpack failed %p\n",
1200 return (ib_err_msg(errstring
, CFGA_IB_NVLIST_ERR
, ap_id
,
1206 /* Call RCM Offline on all device paths */
1207 while (nvp
= nvlist_next_nvpair(nvl
, nvp
)) {
1208 name
= nvpair_name(nvp
);
1209 if (strcmp(name
, "devpath") == 0) {
1210 (void) nvpair_value_string(nvp
, &clnt_devpath
);
1212 } else if (strcmp(name
, "ApID") == 0) {
1213 (void) nvpair_value_string(nvp
, &clnt_apid
);
1217 /* handle the client unconfigure now */
1219 count
= 0; /* reset count */
1221 DPRINTF("cfga_private_func: client apid = %s, "
1222 "DevPath = %s\n", clnt_apid
, clnt_devpath
);
1223 if ((rv
= ib_setup_for_devctl_cmd(clnt_apid
,
1224 B_TRUE
, &hdl
, &nvl
)) != CFGA_IB_OK
) {
1225 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1226 return (ib_err_msg(errstring
, rv
,
1230 if ((rv
= ib_device_configured(hdl
, nvl
,
1231 &rstate
)) == CFGA_IB_NOT_CONFIGURED
)
1234 if ((rv
= ib_rcm_offline(clnt_apid
, errstring
,
1235 clnt_devpath
, flags
)) != CFGA_IB_OK
) {
1236 DPRINTF("cfga_private_func: client rcm "
1237 "offline failed for %s, with %d\n",
1243 if (devctl_ap_unconfigure(hdl
, nvl
) != 0) {
1244 DPRINTF("cfga_private_func: client "
1245 "unconfigure failed: errno %d\n",
1247 ret
= CFGA_IB_UNCONFIG_OP_ERR
;
1249 ret
= CFGA_IB_BUSY_ERR
;
1250 (void) ib_rcm_online(clnt_apid
,
1251 errstring
, clnt_devpath
, flags
);
1254 (void) ib_rcm_remove(clnt_apid
,
1255 errstring
, clnt_devpath
, flags
);
1257 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1259 } /* end of if count == 2 */
1261 } /* end of while */
1266 DPRINTF("cfga_private_func: unconfig_clients of %s "
1267 "failed with %d\n", ap_id
, ret
);
1268 return (ib_err_msg(errstring
, CFGA_IB_UCFG_CLNTS_ERR
,
1272 /* -x update_pkey_tbls */
1273 } else if (strcmp(func
, IB_UPDATE_PKEY_TBLS
) == 0) {
1275 * Check for root privileges.
1277 if (geteuid() != 0) {
1278 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1282 /* CHECK: Only supported on fabric ap_ids */
1283 if (fab_apid
== NULL
|| strcmp(fab_apid
, IBNEX_FABRIC
) != 0) {
1284 DPRINTF("cfga_private_func: fabric apid needed\n");
1285 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1289 /* Check w/ user if it is ok to do this operation */
1290 len
= strlen(IB_CONFIRM4
) + 10;
1291 if ((msg
= (char *)calloc(len
, 1)) != NULL
) {
1292 (void) snprintf(msg
, len
, "%s\nContinue", IB_CONFIRM4
);
1295 /* If the user fails to confirm, return */
1296 if (!ib_confirm(confp
, msg
)) {
1302 /* Update P_Key tables for all ports of all HCAs */
1303 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_UPDATE_PKEY_TBLS
,
1304 0, 0, 0, &info_len
);
1307 DPRINTF("cfga_private_func: ib_do_control_ioctl "
1308 "failed :%d\n", rv
);
1309 return (ib_err_msg(errstring
, CFGA_IB_UPD_PKEY_TBLS_ERR
,
1313 /* -x [add_service|delete_service] */
1314 } else if ((strncmp(func
, IB_ADD_SERVICE
, 12) == 0) ||
1315 (strncmp(func
, IB_DELETE_SERVICE
, 15) == 0)) {
1316 char *subopts
, *val
;
1319 /* check: Only supported on fabric ap_ids */
1320 if (fab_apid
== NULL
|| strcmp(fab_apid
, IBNEX_FABRIC
) != 0) {
1321 DPRINTF("cfga_private_func: fabric apid needed\n");
1322 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1326 /* Check for root privileges. */
1327 if (geteuid() != 0) {
1328 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1332 /* return error if no options are specified */
1333 subopts
= (char *)options
;
1334 if (subopts
== (char *)NULL
) {
1335 DPRINTF("cfga_private_func: no sub-options\n");
1336 (void) cfga_help(msgp
, options
, flags
);
1337 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
,
1341 /* parse options specified */
1342 while (*subopts
!= '\0') {
1343 switch (getsubopt(&subopts
, ib_service_subopts
, &val
)) {
1346 (void) cfga_help(msgp
, options
, flags
);
1347 S_FREE(service_name
);
1348 return (ib_err_msg(errstring
,
1349 CFGA_IB_INVAL_ARG_ERR
,
1352 comm_name
= strdup(val
);
1353 if (comm_name
== NULL
) {
1354 DPRINTF("comm sub-opt invalid "
1356 S_FREE(service_name
);
1357 return (ib_err_msg(errstring
,
1358 CFGA_IB_COMM_INVAL_ERR
,
1364 case 1: /* service */
1366 (void) cfga_help(msgp
, options
, flags
);
1368 return (ib_err_msg(errstring
,
1369 CFGA_IB_INVAL_ARG_ERR
,
1372 /* service can be upto 4 long */
1373 if (strlen(val
) == 0 ||
1375 DPRINTF("comm sub-opt invalid "
1376 "service passed\n");
1378 return (ib_err_msg(errstring
,
1379 CFGA_IB_SVC_LEN_ERR
,
1382 service_name
= strdup(val
);
1383 if (service_name
== NULL
) {
1384 DPRINTF("comm sub-opt "
1385 "internal error\n");
1387 return (ib_err_msg(errstring
,
1388 CFGA_IB_SVC_INVAL_ERR
,
1395 (void) cfga_help(msgp
, options
, flags
);
1397 S_FREE(service_name
);
1398 return (ib_err_msg(errstring
,
1399 CFGA_IB_INVAL_ARG_ERR
, ap_id
, errno
));
1403 /* figure out the "operation" */
1404 if (strncasecmp(func
, IB_ADD_SERVICE
, 11) == 0)
1405 cmd
= IBCONF_ADD_ENTRY
;
1406 else if (strncasecmp(func
, IB_DELETE_SERVICE
, 14) == 0)
1407 cmd
= IBCONF_DELETE_ENTRY
;
1408 DPRINTF("Service = %s, Comm = %s, Operation = %s\n",
1409 service_name
, comm_name
, func
);
1411 if (strncasecmp(comm_name
, IBNEX_PORT_STR
, 4) == 0)
1412 service_type
= IB_PORT_SERVICE
;
1413 else if (strncasecmp(comm_name
, IBNEX_VPPA_STR
, 4) == 0)
1414 service_type
= IB_VPPA_SERVICE
;
1415 else if (strncasecmp(comm_name
, IBNEX_HCASVC_STR
, 4) == 0)
1416 service_type
= IB_HCASVC_SERVICE
;
1418 (void) cfga_help(msgp
, options
, flags
);
1420 S_FREE(service_name
);
1421 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
,
1425 /* do the add/delete entry to the service */
1426 if (cmd
== IBCONF_ADD_ENTRY
) {
1427 if ((rv
= ib_add_service(errstring
)) != CFGA_IB_OK
)
1428 DPRINTF("cfga_private_func: add failed\n");
1429 } else if (cmd
== IBCONF_DELETE_ENTRY
) {
1430 if ((rv
= ib_delete_service(errstring
)) != CFGA_IB_OK
)
1431 DPRINTF("cfga_private_func: delete failed\n");
1435 S_FREE(service_name
);
1436 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1438 } else if (strncmp(func
, IB_LIST_SERVICES
, 13) == 0) {
1440 /* check: Only supported on fabric ap_ids */
1441 if (fab_apid
== NULL
|| strcmp(fab_apid
, IBNEX_FABRIC
) != 0) {
1442 DPRINTF("cfga_private_func: fabric apid needed\n");
1443 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1447 /* do the list services */
1448 rv
= ib_list_services(msgp
, errstring
);
1449 if (rv
!= CFGA_IB_OK
) {
1450 DPRINTF("cfga_private_func: ib_list_services failed\n");
1451 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1454 /* -x update_ioc_conf */
1455 } else if (strncmp(func
, IB_UPDATE_IOC_CONF
, 17) == 0) {
1458 /* Supported only with root privilege */
1459 if (geteuid() != 0) {
1460 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1465 * check: Only supported on fabric ap_id or IOC APID
1466 * IOC APID does not have any commas in it.
1468 if (fab_apid
== NULL
||
1469 (fab_apid
!= NULL
&& strstr(fab_apid
, ",") != NULL
)) {
1470 DPRINTF("cfga_private_func: fabric/IOC apid needed\n");
1471 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1475 /* Check w/ user if it is ok to do this operation */
1476 len
= strlen(IB_CONFIRM5
) + 10;
1477 if ((msg
= (char *)calloc(len
, 1)) != NULL
) {
1478 (void) snprintf(msg
, len
, "%s\nContinue", IB_CONFIRM5
);
1481 /* If the user fails to confirm, return */
1482 if (!ib_confirm(confp
, msg
)) {
1488 misc_arg
= (strcmp(fab_apid
, IBNEX_FABRIC
) == 0) ?
1489 IBNEX_BASE_APID
: IBNEX_DYN_APID
;
1491 /* Reprobe and update IOC(s) configuration */
1492 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_UPDATE_IOC_CONF
,
1493 0, misc_arg
, 0, &info_len
);
1496 DPRINTF("cfga_private_func: ib_do_control_ioctl "
1497 "failed :%d\n", rv
);
1498 return (ib_err_msg(errstring
, CFGA_IB_DEVCTL_ERR
,
1502 DPRINTF("cfga_private_func: unrecognized command.\n");
1503 (void) cfga_help(msgp
, options
, flags
);
1505 return (CFGA_INVAL
);
1508 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1516 * ap_id - The attachment point of an IB fabric
1517 * options - Test command options passed by the cfgadm(1M)
1518 * msgp - cfgadm error message for this plugin
1519 * errstring - This contains error msg if command fails
1520 * flags - Cfgadm(1m) flags
1530 cfga_test(const char *ap_id
, const char *options
, struct cfga_msg
*msgp
,
1531 char **errstring
, cfga_flags_t flags
)
1533 (void) cfga_help(msgp
, options
, flags
);
1534 return (CFGA_OPNOTSUPP
);
1540 * ib_fill_static_apids
1542 * ap_id - The static attachment point of an IB device
1543 * clp - The returned "list" information array
1547 * Fills up the "list" information array for the static attachment point
1549 * IB fabric supports two types of static attachment points.
1550 * One is fabric and other is for the HCAs. This fills up
1551 * "cfga_list_data_t" for static attachment points.
1553 static cfga_ib_ret_t
1554 ib_fill_static_apids(char *ap_id
, cfga_list_data_t
*clp
)
1557 char *ap_id_log
= NULL
;
1559 /* Get /dev/cfg path to corresponding to the physical ap_id */
1560 /* Remember ap_id_log must be freed */
1561 if (ib_physpath_to_devlink(ap_id
, &ap_id_log
,
1562 &l_err
) != ICFGA_OK
) {
1563 DPRINTF("ib_fill_static_apids: "
1564 "ib_physpath_to_devlink failed\n");
1565 return (CFGA_IB_DEVLINK_ERR
);
1567 assert(ap_id_log
!= NULL
);
1569 /* Get logical ap-id corresponding to the physical */
1570 if (strstr(ap_id_log
, CFGA_DEV_DIR
) == NULL
) {
1571 DPRINTF("ib_fill_static_apids: devlink doesn't contain "
1574 return (CFGA_IB_DEVLINK_ERR
);
1577 clp
->ap_cond
= CFGA_COND_OK
;
1578 clp
->ap_r_state
= CFGA_STAT_CONNECTED
;
1579 clp
->ap_o_state
= CFGA_STAT_CONFIGURED
;
1580 clp
->ap_class
[0] = '\0'; /* Filled by libcfgadm */
1582 clp
->ap_status_time
= (time_t)-1;
1583 (void) snprintf(clp
->ap_log_id
, sizeof (clp
->ap_log_id
), "%s",
1584 /* Strip off /dev/cfg/ */ ap_id_log
+ strlen(CFGA_DEV_DIR
) + 1);
1585 (void) strlcpy(clp
->ap_phys_id
, ap_id
, sizeof (clp
->ap_phys_id
));
1587 /* Static IB apid */
1588 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
) {
1589 (void) strlcpy(clp
->ap_type
, IB_FABRIC_TYPE
,
1590 sizeof (clp
->ap_type
)); /* Fill in type */
1591 (void) strlcpy(clp
->ap_info
, IB_FABRIC_INFO
,
1592 sizeof (clp
->ap_info
));
1594 } else { /* Static HCA apid */
1596 uchar_t
*data
= NULL
;
1598 (void) strlcpy(clp
->ap_type
, IB_HCA_TYPE
,
1599 sizeof (clp
->ap_type
)); /* Fill in type */
1601 rv
= ib_do_control_ioctl(ap_id
, IBNEX_HCA_VERBOSE_SZ
,
1602 IBNEX_HCA_VERBOSE_INFO
, 0, (void **)&data
, &size
);
1604 DPRINTF("ib_fill_static_apids: ib_do_control_ioctl "
1605 "failed :%d\n", rv
);
1608 return (CFGA_IB_IOCTL_ERR
);
1611 (void) strlcpy(clp
->ap_info
, (char *)data
,
1612 sizeof (clp
->ap_info
));
1616 return (CFGA_IB_OK
);
1624 * ap_id - The attachment point of an IB fabric
1625 * ap_id_list - The returned "list" information array
1626 * nlistp - Number of elements in the "list" information array
1627 * options - List command options passed by the cfgadm(1M)
1628 * listopts - "-s" specific options
1629 * errstring - This contains error msg if command fails
1630 * flags - Cfgadm(1m) flags
1634 * If the command succeeded, cfgadm -l output otherwise an error
1640 cfga_list_ext(const char *ap_id
, cfga_list_data_t
**ap_id_list
, int *nlistp
,
1641 const char *options
, const char *listopts
, char **errstring
,
1645 int i
, index
, count
;
1646 int show_dynamic
= 0;
1647 size_t num_devices
= 0;
1648 size_t num_hcas
= 0;
1649 size_t snap_size
= 0;
1650 uchar_t
*snap_data
= NULL
;
1651 nvpair_t
*nvp
= NULL
; /* for lint purposes */
1652 nvlist_t
*nvl
= NULL
;
1653 boolean_t apid_matched
= B_FALSE
; /* for valid ap_id */
1654 cfga_ib_ret_t rv
= CFGA_IB_OK
;
1655 cfga_list_data_t
*clp
= NULL
;
1657 if ((rv
= ib_verify_params(ap_id
, options
, errstring
)) != CFGA_IB_OK
) {
1658 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1661 /* make sure we have a valid ap_id_list */
1662 if (ap_id_list
== NULL
|| nlistp
== NULL
) {
1663 DPRINTF("cfga_list_ext: list = NULL or nlistp = NULL\n");
1664 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
,
1668 DPRINTF("cfga_list_ext: ap_id = %s\n", ap_id
);
1670 if ((flags
& CFGA_FLAG_LIST_ALL
) == CFGA_FLAG_LIST_ALL
) {
1671 expand
= 1; /* -a flag passed */
1674 if (GET_DYN(ap_id
) != NULL
) {
1678 if ((expand
== 1) && /* -a option passed */
1679 (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
)) {
1681 * Figure out how many IOC/Port/Pseudo
1682 * devices exist in the system?
1684 if ((rv
= ib_do_control_ioctl((char *)ap_id
,
1685 IBNEX_NUM_DEVICE_NODES
, 0, 0, 0, &num_devices
)) !=
1687 DPRINTF("cfga_list_ext: ib_do_control_ioctl "
1688 "IBNEX_NUM_DEVICE_NODES failed :%d\n", rv
);
1689 if (errno
== ENOENT
)
1690 return (CFGA_APID_NOEXIST
);
1691 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1694 DPRINTF("cfga_list_ext: num_devices = %d\n", num_devices
);
1697 /* Figure out how many HCA nodes exist in the system. */
1698 if ((rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_NUM_HCA_NODES
, 0, 0,
1699 0, &num_hcas
)) != CFGA_IB_OK
) {
1700 DPRINTF("cfga_list_ext: ib_do_control_ioctl "
1701 "IBNEX_NUM_HCA_NODES failed :%d\n", rv
);
1702 if (errno
== ENOENT
)
1703 return (CFGA_APID_NOEXIST
);
1704 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1706 DPRINTF("cfga_list_ext: num_hcas = %d\n", num_hcas
);
1709 * No HCAs or IOC/VPPA/Port/HCA_SVC/Pseudo devices seen (non-IB system)
1711 if (!(num_hcas
|| num_devices
)) {
1712 DPRINTF("cfga_list_ext: no IB devices found\n");
1713 return (CFGA_APID_NOEXIST
);
1717 * *nlistp contains to how many APIDs to show w/ cfgadm -l.
1718 * If ap_id is "fabric" then
1719 * *nlistp is all Dynamic Apids + One more for "fabric"
1720 * If ap_id is "HCA" ap_id then
1722 * Note that each HCA is a static APID, so nlistp will be 1 always
1723 * and this function will be called N times for each of the N HCAs
1726 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
) {
1727 *nlistp
= num_devices
+ 1;
1730 /* Assume it as a HCA ap_id */
1734 /* Allocate storage for passing "list" info back */
1735 if ((*ap_id_list
= (cfga_list_data_t
*)calloc(*nlistp
,
1736 sizeof (cfga_list_data_t
))) == NULL
) {
1737 DPRINTF("cfga_list_ext: malloc for cfga_list_data_t failed. "
1738 "errno: %d\n", errno
);
1739 return (ib_err_msg(errstring
, CFGA_IB_ALLOC_FAIL
,
1744 * Only static ap_id is ib_fabric:
1745 * If -a options isn't specified then only show the static ap_id.
1747 if (!show_dynamic
) {
1748 clp
= &(*ap_id_list
[0]);
1750 if ((rv
= ib_fill_static_apids((char *)ap_id
, clp
)) !=
1752 S_FREE(*ap_id_list
);
1753 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1755 apid_matched
= B_TRUE
;
1760 * No HCAs or IOC/VPPA/HCA_SVC/Port/Pseudo devices seen (non-IB system)
1762 if (!expand
|| (!num_hcas
&& !num_devices
)) {
1767 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
) {
1768 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_SNAPSHOT_SIZE
,
1769 IBNEX_GET_SNAPSHOT
, IBNEX_DONOT_PROBE_FLAG
,
1770 (void **)&snap_data
, &snap_size
);
1772 DPRINTF("cfga_list_ext: ib_do_control_ioctl "
1773 "failed :%d\n", rv
);
1774 S_FREE(*ap_id_list
);
1776 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1779 if (nvlist_unpack((char *)snap_data
, snap_size
, &nvl
, 0)) {
1780 DPRINTF("cfga_list_ext: nvlist_unpack 1 failed %p\n",
1782 S_FREE(*ap_id_list
);
1784 return (ib_err_msg(errstring
, CFGA_IB_NVLIST_ERR
,
1789 * In kernel a nvlist is build per ap_id which contains
1790 * information that is displayed using cfgadm -l.
1791 * For IB devices only these 6 items are shown:
1792 * ap_id, type, occupant, receptacle, condition and info
1794 * In addition, one could specify a dynamic ap_id from
1795 * command-line. Then cfgadm -l should show only that
1796 * ap_id and skip rest.
1798 index
= 1; count
= 0;
1799 while (nvp
= nvlist_next_nvpair(nvl
, nvp
)) {
1804 char *name
= nvpair_name(nvp
);
1806 /* start of with next device */
1807 if (count
== IB_NUM_NVPAIRS
) {
1813 * Check if the index doesn't go beyond the
1814 * device number. If it goes, stop the loop
1815 * here not to cause the heap corruption.
1817 if (show_dynamic
== 0 && index
> num_devices
)
1820 /* fill up data into "clp" */
1821 clp
= (show_dynamic
!= 0) ? &(*ap_id_list
[0]) :
1822 &(ap_id_list
[0][index
]);
1824 /* First nvlist entry is "ap_id" always */
1825 if (strcmp(name
, IBNEX_NODE_APID_NVL
) == 0) {
1826 (void) nvpair_value_string(nvp
, &nv_apid
);
1827 DPRINTF("cfga_list_ext: Name = %s, apid = %s\n",
1831 * If a dynamic ap_id is specified in the
1832 * command-line, skip all entries until
1833 * the one needed matches.
1836 strstr(ap_id
, nv_apid
) == NULL
) {
1837 DPRINTF("cfga_list_ext: NO MATCH\n");
1840 * skip rest of the entries of this
1843 for (i
= 0; i
< IB_NUM_NVPAIRS
- 1; i
++)
1844 nvp
= nvlist_next_nvpair(nvl
,
1846 count
= 0; /* reset it */
1850 apid_matched
= B_TRUE
;
1852 /* build the physical ap_id */
1853 if (strstr(ap_id
, DYN_SEP
) == NULL
) {
1854 (void) snprintf(clp
->ap_phys_id
,
1855 sizeof (clp
->ap_phys_id
), "%s%s%s",
1856 ap_id
, DYN_SEP
, nv_apid
);
1858 (void) snprintf(clp
->ap_phys_id
,
1859 sizeof (clp
->ap_phys_id
), "%s",
1863 /* ensure that this is a valid apid */
1864 if (ib_verify_valid_apid(clp
->ap_phys_id
) !=
1866 DPRINTF("cfga_list_ext: "
1867 "not a valid IB ap_id\n");
1868 S_FREE(*ap_id_list
);
1871 return (ib_err_msg(errstring
,
1872 CFGA_IB_AP_ERR
, ap_id
, errno
));
1875 /* build the logical ap_id */
1876 (void) snprintf(clp
->ap_log_id
,
1877 sizeof (clp
->ap_log_id
), "ib%s%s",
1879 DPRINTF("cfga_list_ext: ap_pi = %s, ap_li = %s,"
1880 "\nap_info = %s\n", clp
->ap_phys_id
,
1881 clp
->ap_log_id
, clp
->ap_info
);
1884 } else if (strcmp(name
, IBNEX_NODE_INFO_NVL
) == 0) {
1885 (void) nvpair_value_string(nvp
, &info
);
1886 DPRINTF("cfga_list_ext: Name = %s, info = %s\n",
1888 (void) snprintf(clp
->ap_info
,
1889 sizeof (clp
->ap_info
), "%s", info
);
1892 } else if (strcmp(name
, IBNEX_NODE_TYPE_NVL
) == 0) {
1893 (void) nvpair_value_int32(nvp
, &node_type
);
1894 if (node_type
== IBNEX_PORT_NODE_TYPE
) {
1895 (void) snprintf(clp
->ap_type
,
1896 sizeof (clp
->ap_type
), "%s",
1898 } else if (node_type
== IBNEX_VPPA_NODE_TYPE
) {
1899 (void) snprintf(clp
->ap_type
,
1900 sizeof (clp
->ap_type
), "%s",
1902 } else if (node_type
==
1903 IBNEX_HCASVC_NODE_TYPE
) {
1904 (void) snprintf(clp
->ap_type
,
1905 sizeof (clp
->ap_type
), "%s",
1907 } else if (node_type
== IBNEX_IOC_NODE_TYPE
) {
1908 (void) snprintf(clp
->ap_type
,
1909 sizeof (clp
->ap_type
), "%s",
1911 } else if (node_type
==
1912 IBNEX_PSEUDO_NODE_TYPE
) {
1913 (void) snprintf(clp
->ap_type
,
1914 sizeof (clp
->ap_type
), "%s",
1917 DPRINTF("cfga_list_ext: Name = %s, type = %x\n",
1921 } else if (strcmp(name
, IBNEX_NODE_RSTATE_NVL
) == 0) {
1922 (void) nvpair_value_int32(nvp
, &intval
);
1924 if (intval
== AP_RSTATE_EMPTY
)
1925 clp
->ap_r_state
= CFGA_STAT_EMPTY
;
1926 else if (intval
== AP_RSTATE_DISCONNECTED
)
1928 CFGA_STAT_DISCONNECTED
;
1929 else if (intval
== AP_RSTATE_CONNECTED
)
1930 clp
->ap_r_state
= CFGA_STAT_CONNECTED
;
1931 DPRINTF("cfga_list_ext: Name = %s, "
1932 "rstate = %x\n", name
, intval
);
1935 } else if (strcmp(name
, IBNEX_NODE_OSTATE_NVL
) == 0) {
1936 (void) nvpair_value_int32(nvp
, &intval
);
1938 if (intval
== AP_OSTATE_CONFIGURED
)
1939 clp
->ap_o_state
= CFGA_STAT_CONFIGURED
;
1940 else if (intval
== AP_OSTATE_UNCONFIGURED
)
1942 CFGA_STAT_UNCONFIGURED
;
1943 DPRINTF("cfga_list_ext: Name = %s, "
1944 "ostate = %x\n", name
, intval
);
1947 } else if (strcmp(name
, IBNEX_NODE_COND_NVL
) == 0) {
1948 (void) nvpair_value_int32(nvp
, &intval
);
1950 if (intval
== AP_COND_OK
)
1951 clp
->ap_cond
= CFGA_COND_OK
;
1952 else if (intval
== AP_COND_FAILING
)
1953 clp
->ap_cond
= CFGA_COND_FAILING
;
1954 else if (intval
== AP_COND_FAILED
)
1955 clp
->ap_cond
= CFGA_COND_FAILED
;
1956 else if (intval
== AP_COND_UNUSABLE
)
1957 clp
->ap_cond
= CFGA_COND_UNUSABLE
;
1958 else if (intval
== AP_COND_UNKNOWN
)
1959 clp
->ap_cond
= CFGA_COND_UNKNOWN
;
1960 DPRINTF("cfga_list_ext: Name = %s, "
1961 "condition = %x\n", name
, intval
);
1965 clp
->ap_class
[0] = '\0'; /* Filled by libcfgadm */
1967 clp
->ap_status_time
= (time_t)-1;
1968 } /* end of while */
1975 * if a cmdline specified ap_id doesn't match the known list of ap_ids
1976 * then report an error right away
1978 rv
= (apid_matched
== B_TRUE
) ? CFGA_IB_OK
: CFGA_IB_AP_ERR
;
1979 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1987 * msgp - cfgadm error message for this plugin
1988 * str - string to be passed on to the message
1994 * This routine accepts a variable number of message IDs and
1995 * constructs a corresponding error string which is printed
1996 * via the message print routine argument.
1999 cfga_msg(struct cfga_msg
*msgp
, const char *str
)
2004 if (msgp
== NULL
|| msgp
->message_routine
== NULL
) {
2005 DPRINTF("cfga_msg: msg\n");
2009 if ((len
= strlen(str
)) == 0) {
2010 DPRINTF("cfga_msg: null str\n");
2014 if ((q
= (char *)calloc(len
+ 1, 1)) == NULL
) {
2015 DPRINTF("cfga_msg: null q\n");
2019 (void) strlcpy(q
, str
, len
+ 1);
2020 (*msgp
->message_routine
)(msgp
->appdata_ptr
, q
);
2030 * msgp - Help message passed on to cfgadm(1M)
2031 * options - Help message options passed on to cfgadm(1M)
2032 * flags - Cfgadm(1m) flags
2036 * Were we able to print cfgadm help or not for this plugin
2038 * Print cfgadm help for this plugin
2042 cfga_help(struct cfga_msg
*msgp
, const char *options
, cfga_flags_t flags
)
2044 DPRINTF("cfga_help:\n");
2047 cfga_msg(msgp
, dgettext(TEXT_DOMAIN
, ib_help
[
2048 CFGA_IB_HELP_UNKNOWN
]));
2049 cfga_msg(msgp
, options
);
2052 /* Print messages array */
2053 cfga_msg(msgp
, dgettext(TEXT_DOMAIN
, ib_help
[CFGA_IB_HELP_HEADER
]));
2054 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_CONFIG
]);
2055 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_LIST
]);
2056 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_UPD_PKEY
]);
2057 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_CONF_FILE1
]);
2058 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_CONF_FILE2
]);
2059 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_UPD_IOC_CONF
]);
2060 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_UNCFG_CLNTS
]);
2070 * confp - The "cfga" structure that confirms a cfgadm query
2071 * msg - The message that needs confirmation
2075 * If a user entered YES or NO
2077 * Queries a user if it is ok to proceed with an operation or not.
2078 * Returns user's response.
2081 ib_confirm(struct cfga_confirm
*confp
, char *msg
)
2085 /* check that "confirm" function exists */
2086 if (confp
== NULL
|| confp
->confirm
== NULL
) {
2090 /* Call cfgadm provided "confirm" function */
2091 rval
= (*confp
->confirm
)(confp
->appdata_ptr
, msg
);
2092 DPRINTF("ib_confirm: %d\n", rval
);
2102 * ap_id - The dynamic attachment point of an IB device
2106 * devpath if it exists; otherwise NULL
2108 * Returns the devicepath for a dynamic attachment point of an IB device
2111 ib_get_devicepath(const char *ap_id
)
2113 char *devpath
= NULL
;
2116 /* Get device path sizes */
2117 if (ib_do_control_ioctl((char *)ap_id
, IBNEX_DEVICE_PATH_SZ
,
2118 IBNEX_GET_DEVICE_PATH
, 0, (void **)&devpath
, &size
) == CFGA_IB_OK
) {
2119 DPRINTF("ib_get_devicepath: get device path ioctl ok\n");
2123 DPRINTF("ib_get_devicepath: get device path ioctl failed\n");
2124 return ((char *)NULL
);