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(8)
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 nvlist_free(user_nvlist
);
584 devctl_release(devctl_hdl
);
590 * ib_setup_for_devctl_cmd
592 * ap_id - Attachment point for the IB device in question
593 * use_static_ap_id - Whether to use static ap_id or not flag
595 * devctl_hdl - Handler to devctl
596 * user_nvlistp - Name-value-pair list pointer
598 * CFGA_IB_OK if it succeeds or an appropriate error.
600 * For any IB device that is doing a cfgadm operation this function
601 * sets up a devctl_hdl and allocates a nvlist_t. The devctl_hdl
602 * is acquired using libdevice APIs. The nvlist_t is filled up with
603 * the ap_id (as a string). This nvlist_t is looked up in the kernel
604 * to figure out which ap_id we are currently dealing with.
606 * "use_static_ap_id" flag tells if one should do a devctl_ap_acquire
607 * with IB_STATIC_APID or not. NOTE: We need an actual file-system
608 * vnode to do a devctl_ap_acquire.
610 * NOTE: always call ib_cleanup_after_devctl_cmd() after this function.
613 ib_setup_for_devctl_cmd(char *ap_id
, boolean_t use_static_ap_id
,
614 devctl_hdl_t
*devctl_hdl
, nvlist_t
**user_nvlistp
)
616 char *apid
= (use_static_ap_id
== B_TRUE
) ? IB_STATIC_APID
: ap_id
;
618 /* Get a handle to the ap */
619 if ((*devctl_hdl
= devctl_ap_acquire(apid
, 0)) == NULL
) {
620 DPRINTF("ib_setup_for_devctl_cmd: devctl_ap_acquire "
621 "errno: %d\n", errno
);
622 ib_cleanup_after_devctl_cmd(*devctl_hdl
, *user_nvlistp
);
623 return (CFGA_IB_DEVCTL_ERR
);
626 /* Set up to pass dynamic ap_id down to driver */
627 if (nvlist_alloc(user_nvlistp
, NV_UNIQUE_NAME_TYPE
, 0) != 0) {
628 DPRINTF("ib_setup_for_devctl: nvlist_alloc errno: %d\n", errno
);
629 *user_nvlistp
= NULL
; /* Prevent possible incorrect free in */
630 /* ib_cleanup_after_devctl_cmd */
631 ib_cleanup_after_devctl_cmd(*devctl_hdl
, *user_nvlistp
);
632 return (CFGA_IB_NVLIST_ERR
);
635 /* create a "string" entry */
636 if (nvlist_add_string(*user_nvlistp
, IB_APID
, ap_id
) == -1) {
637 DPRINTF("ib_setup_for_devctl_cmd: nvlist_add_string failed. "
638 "errno: %d\n", errno
);
639 ib_cleanup_after_devctl_cmd(*devctl_hdl
, *user_nvlistp
);
640 return (CFGA_IB_NVLIST_ERR
);
649 * ib_device_configured
651 * hdl - Handler to devctl
652 * nvl - Name-value-pair list pointer
654 * rstate - Receptacle state for the apid
656 * CFGA_IB_OK if it succeeds or an appropriate error.
658 * Checks if there is a device actually configured to the ap? If so,
659 * issues a "devctl" to get the Receptacle state for that ap_id.
660 * If the ap_id is already configured it returns CFGA_IB_OK.
661 * Otherwise it returns a failure.
664 ib_device_configured(devctl_hdl_t hdl
, nvlist_t
*nvl
, ap_rstate_t
*rstate
)
667 devctl_ap_state_t devctl_ap_state
;
669 /* get ap_id's "devctl_ap_state" first */
670 if (devctl_ap_getstate(hdl
, nvl
, &devctl_ap_state
) == -1) {
671 DPRINTF("ib_device_configured failed, errno: %d\n", errno
);
672 return (CFGA_IB_DEVCTL_ERR
);
675 rv
= CFGA_IB_ALREADY_CONFIGURED
;
676 *rstate
= devctl_ap_state
.ap_rstate
;
677 if (devctl_ap_state
.ap_ostate
!= AP_OSTATE_CONFIGURED
) {
678 return (CFGA_IB_NOT_CONFIGURED
);
687 * ib_device_connected
689 * hdl - Handler to devctl
690 * nvl - Name-value-pair list pointer
692 * ostate - Occupant state for the apid
694 * CFGA_IB_OK if it succeeds or an appropriate error.
696 * Checks if there is a device actually connected to the ap? If so,
697 * issues a "devctl" to get the Occupant state for that ap_id.
698 * If the ap_id is already connected it returns CFGA_IB_OK.
699 * Otherwise it returns a failure.
702 ib_device_connected(devctl_hdl_t hdl
, nvlist_t
*list
, ap_ostate_t
*ostate
)
704 cfga_ib_ret_t rv
= CFGA_IB_ALREADY_CONNECTED
;
705 devctl_ap_state_t devctl_ap_state
;
707 if (devctl_ap_getstate(hdl
, list
, &devctl_ap_state
) == -1) {
708 DPRINTF("ib_device_connected failed, errno: %d\n", errno
);
709 return (CFGA_IB_DEVCTL_ERR
);
712 *ostate
= devctl_ap_state
.ap_ostate
;
713 if (devctl_ap_state
.ap_rstate
!= AP_RSTATE_CONNECTED
) {
714 return (CFGA_IB_NOT_CONNECTED
);
723 * ib_do_control_ioctl
725 * ap_id - The dynamic attachment point of an IB device
726 * sub_cmd1 - Sub Command 1 to DEVCTL_AP_CONTROL devctl
727 * sub_cmd2 - Sub Command 2 to DEVCTL_AP_CONTROL devctl
728 * (Mandatory except for IBNEX_NUM_HCA_NODES,
729 * IBNEX_NUM_DEVICE_NODES,
730 * IBNEX_UPDATE_PKEY_TBLS &
731 * IBNEX_UPDATE_IOC_CONF)
732 * misc_arg - optional arguments to DEVCTL_AP_CONTROL devctl
734 * descrp - Buffer containing data back from kernel
735 * sizep - Length of the buffer back from kernel
737 * CFGA_IB_OK if it succeeds or an appropriate error.
739 * Issues DEVCTL_AP_CONTROL devctl with sub_cmd1 first which actually
740 * queries the IBNEX module in the kernel on the size of the data to
743 * Next issues DEVCTL_AP_CONTROL devctl with a buffer of that much
744 * size and gets the actual data back.
745 * Passes the data and the size back to caller.
748 ib_do_control_ioctl(char *ap_id
, uint_t sub_cmd1
, uint_t sub_cmd2
,
749 uint_t misc_arg
, void **descrp
, size_t *sizep
)
752 uint32_t local_size
= 0;
753 cfga_ib_ret_t rv
= CFGA_IB_OK
;
754 struct ibnex_ioctl_data ioctl_data
;
756 /* try to open the ONLY static ap_id */
757 if ((fd
= open(IB_STATIC_APID
, O_RDONLY
)) == -1) {
758 DPRINTF("ib_do_control_ioctl: open failed: "
759 "errno = %d\n", errno
);
760 /* Provides a more useful error msg */
761 rv
= (errno
== EBUSY
) ? CFGA_IB_BUSY_ERR
: CFGA_IB_OPEN_ERR
;
766 * Find out first how large a buffer is needed?
767 * NOTE: Ioctls only accept/return a 32-bit int for a get_size
768 * to avoid 32/64 and BE/LE issues.
770 ioctl_data
.cmd
= sub_cmd1
;
771 ioctl_data
.misc_arg
= (uint_t
)misc_arg
;
772 ioctl_data
.buf
= (caddr_t
)&local_size
;
773 ioctl_data
.bufsiz
= sizeof (local_size
);
775 /* Pass "ap_id" up for all other commands */
776 if (sub_cmd1
!= IBNEX_NUM_DEVICE_NODES
&&
777 sub_cmd1
!= IBNEX_NUM_HCA_NODES
&&
778 sub_cmd1
!= IBNEX_UPDATE_PKEY_TBLS
) {
779 ioctl_data
.ap_id
= (caddr_t
)ap_id
;
780 ioctl_data
.ap_id_len
= strlen(ap_id
);
783 ioctl_data
.ap_id
= NULL
;
784 ioctl_data
.ap_id_len
= 0;
787 if (ioctl(fd
, DEVCTL_AP_CONTROL
, &ioctl_data
) != 0) {
788 DPRINTF("ib_do_control_ioctl: size ioctl ERR, errno: %d\n",
791 rv
= (errno
== EBUSY
) ? CFGA_IB_BUSY_ERR
: CFGA_IB_IOCTL_ERR
;
797 * Don't do the second ioctl only in these cases
798 * (NOTE: the data is returned in the first ioctl itself; if any)
800 if (sub_cmd1
== IBNEX_NUM_DEVICE_NODES
||
801 sub_cmd1
== IBNEX_NUM_HCA_NODES
||
802 sub_cmd1
== IBNEX_UPDATE_PKEY_TBLS
||
803 sub_cmd1
== IBNEX_UPDATE_IOC_CONF
) {
808 if (local_size
== 0 || (*descrp
= malloc(*sizep
)) == NULL
) {
809 DPRINTF("ib_do_control_ioctl: malloc failed\n");
811 return (CFGA_IB_ALLOC_FAIL
);
815 ioctl_data
.cmd
= sub_cmd2
;
816 ioctl_data
.buf
= (caddr_t
)*descrp
;
817 ioctl_data
.bufsiz
= *sizep
;
819 if (ioctl(fd
, DEVCTL_AP_CONTROL
, &ioctl_data
) != 0) {
820 DPRINTF("ib_do_control_ioctl: ioctl failed: errno:%d\n", errno
);
821 if (*descrp
!= NULL
) {
825 rv
= (errno
== EBUSY
) ? CFGA_IB_BUSY_ERR
: CFGA_IB_IOCTL_ERR
;
833 /* ========================================================================== */
840 * state_change_cmd - Argument to the cfgadm -c command
841 * ap_id - The attachment point of an IB fabric
842 * options - State Change command options passed by the cfgadm(8)
843 * confp - Whether this command requires confirmation?
844 * msgp - cfgadm error message for this plugin
845 * errstring - This contains error msg if command fails
846 * flags - Cfgadm(1m) flags
850 * If the command succeeded perform the cfgadm -c <cmd>;
851 * otherwise emit an error
857 cfga_change_state(cfga_cmd_t state_change_cmd
, const char *ap_id
,
858 const char *options
, struct cfga_confirm
*confp
, struct cfga_msg
*msgp
,
859 char **errstring
, cfga_flags_t flags
)
863 nvlist_t
*nvl
= NULL
;
864 boolean_t static_ap_id
= B_TRUE
;
867 devctl_hdl_t hdl
= NULL
;
868 cfga_ib_ret_t rv
= CFGA_IB_OK
;
870 if ((rv
= ib_verify_params(ap_id
, options
, errstring
)) != CFGA_IB_OK
) {
871 (void) cfga_help(msgp
, options
, flags
);
872 return (ib_err_msg(errstring
, CFGA_IB_INVAL_APID_ERR
,
877 * All subcommands which can change state of device require
880 if (geteuid() != 0) {
881 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
, errno
));
884 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) == NULL
)
885 static_ap_id
= B_FALSE
;
887 if ((rv
= ib_setup_for_devctl_cmd((char *)ap_id
, static_ap_id
,
888 &hdl
, &nvl
)) != CFGA_IB_OK
) {
889 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
890 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
893 switch (state_change_cmd
) {
894 case CFGA_CMD_CONFIGURE
:
895 rv
= ib_device_connected(hdl
, nvl
, &ostate
);
896 if (rv
!= CFGA_IB_ALREADY_CONNECTED
) {
897 ret
= (rv
!= CFGA_IB_NOT_CONNECTED
) ?
898 CFGA_IB_CONFIG_OP_ERR
: rv
;
899 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
900 return (ib_err_msg(errstring
, ret
, ap_id
, errno
));
903 if (rv
== CFGA_IB_ALREADY_CONNECTED
) {
905 * special case handling for
906 * SLM based cfgadm disconnects
908 if (ostate
== AP_OSTATE_CONFIGURED
) {
909 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
910 return (ib_err_msg(errstring
,
911 CFGA_IB_ALREADY_CONFIGURED
, ap_id
,
917 rv
= CFGA_IB_OK
; /* Other status don't matter */
919 if (devctl_ap_configure(hdl
, nvl
) != 0) {
920 DPRINTF("cfga_change_state: devctl_ap_configure "
921 "failed. errno: %d\n", errno
);
922 rv
= CFGA_IB_CONFIG_OP_ERR
;
926 devpath
= ib_get_devicepath(ap_id
);
927 if (devpath
== NULL
) {
931 * try for some time as IB hotplug thread
932 * takes a while to create the path
933 * and then eventually give up
936 i
< IB_RETRY_DEVPATH
&& (devpath
== NULL
); i
++) {
937 sleep(IB_MAX_DEVPATH_DELAY
);
938 devpath
= ib_get_devicepath(ap_id
);
941 if (devpath
== NULL
) {
942 DPRINTF("cfga_change_state: get device "
943 "path failed i = %d\n", i
);
944 rv
= CFGA_IB_CONFIG_OP_ERR
;
951 case CFGA_CMD_UNCONFIGURE
:
952 if ((rv
= ib_device_connected(hdl
, nvl
, &ostate
)) !=
953 CFGA_IB_ALREADY_CONNECTED
) {
954 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
955 if (rv
== CFGA_IB_DEVCTL_ERR
)
956 rv
= CFGA_IB_INVALID_OP_ERR
;
957 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
960 /* check if it is already unconfigured */
961 if ((rv
= ib_device_configured(hdl
, nvl
, &rstate
)) ==
962 CFGA_IB_NOT_CONFIGURED
) {
963 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
964 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
967 rv
= CFGA_IB_OK
; /* Other statuses don't matter */
969 if (!ib_confirm(confp
, IB_CONFIRM1
)) {
970 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
974 devpath
= ib_get_devicepath(ap_id
);
975 if (devpath
== NULL
) {
976 DPRINTF("cfga_change_state: get device path failed\n");
977 rv
= CFGA_IB_UNCONFIG_OP_ERR
;
981 if ((rv
= ib_rcm_offline(ap_id
, errstring
, devpath
, flags
)) !=
987 ret
= devctl_ap_unconfigure(hdl
, nvl
);
989 DPRINTF("cfga_change_state: devctl_ap_unconfigure "
990 "failed with errno: %d\n", errno
);
991 rv
= CFGA_IB_UNCONFIG_OP_ERR
;
992 if (errno
== EBUSY
) {
993 rv
= CFGA_IB_BUSY_ERR
;
995 (void) ib_rcm_online(ap_id
, errstring
, devpath
, flags
);
998 (void) ib_rcm_remove(ap_id
, errstring
, devpath
, flags
);
1005 case CFGA_CMD_UNLOAD
:
1006 case CFGA_CMD_CONNECT
:
1007 case CFGA_CMD_DISCONNECT
:
1008 (void) cfga_help(msgp
, options
, flags
);
1009 rv
= CFGA_IB_OPNOTSUPP
;
1014 (void) cfga_help(msgp
, options
, flags
);
1015 rv
= CFGA_IB_INTERNAL_ERR
;
1018 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1019 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1027 * func - The private function (passed w/ -x option)
1028 * ap_id - The attachment point of an IB fabric
1029 * options - Private function command options passed
1031 * confp - Whether this command requires confirmation?
1032 * msgp - cfgadm error message for this plugin
1033 * errstring - This contains error msg if command fails
1034 * flags - Cfgadm(1m) flags
1038 * If the command succeeded perform the 'cfgadm -x <func>'; otherwise
1041 * Do cfgadm -x <func>
1045 cfga_private_func(const char *func
, const char *ap_id
, const char *options
,
1046 struct cfga_confirm
*confp
, struct cfga_msg
*msgp
, char **errstring
,
1049 int len
, ret
, count
= 0;
1050 char *clnt_name
= NULL
, *alt_hca
= NULL
;
1051 char *clnt_apid
= NULL
, *clnt_devpath
= NULL
;
1052 char *name
, *msg
= NULL
;
1053 char *fab_apid
= strstr((char *)ap_id
, IBNEX_FABRIC
);
1054 size_t info_len
= 0;
1055 uchar_t
*info
= NULL
;
1057 nvpair_t
*nvp
= NULL
;
1059 devctl_hdl_t hdl
= NULL
;
1062 if ((rv
= ib_verify_params(ap_id
, NULL
, errstring
)) != CFGA_IB_OK
) {
1063 DPRINTF("cfga_private_func: ib_verify_params "
1064 "failed with rv: %d\n", rv
);
1065 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1069 DPRINTF("cfga_private_func: func is NULL\n");
1070 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
, ap_id
,
1075 * check first if IB static ap_id is "configured" for use
1077 if (fab_apid
!= NULL
) {
1078 if ((rv
= ib_setup_for_devctl_cmd(fab_apid
, B_TRUE
, &hdl
,
1079 &nvl
)) != CFGA_IB_OK
) {
1080 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1081 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1083 if ((rv
= ib_device_configured(hdl
, nvl
, &rstate
)) ==
1084 CFGA_IB_NOT_CONFIGURED
) {
1085 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1087 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1091 DPRINTF("cfga_private_func: func is %s\n", func
);
1092 if (strcmp(func
, IB_LIST_HCA_CLIENTS
) == 0) { /* -x list_clients */
1094 /* only supported on HCA ap_ids */
1095 if (fab_apid
!= NULL
) {
1096 DPRINTF("cfga_private_func: fabric apid supplied\n");
1097 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1101 if ((msg
= (char *)calloc(256, 1)) == NULL
) {
1102 DPRINTF("cfga_private_func: malloc for msg failed. "
1103 "errno: %d\n", errno
);
1104 return (ib_err_msg(errstring
, CFGA_IB_ALLOC_FAIL
,
1108 if ((rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_HCA_LIST_SZ
,
1109 IBNEX_HCA_LIST_INFO
, 0, (void **)&info
, &info_len
)) != 0) {
1110 DPRINTF("cfga_private_func: "
1111 "ib_do_control_ioctl list failed :%d\n", rv
);
1113 return (ib_err_msg(errstring
, CFGA_IB_HCA_LIST_ERR
,
1117 if (nvlist_unpack((char *)info
, info_len
, &nvl
, 0)) {
1118 DPRINTF("cfga_private_func: "
1119 "nvlist_unpack 2 failed %p\n", info
);
1122 return (ib_err_msg(errstring
, CFGA_IB_NVLIST_ERR
, ap_id
,
1126 (void) snprintf(msg
, 256, "Ap_Id\t\t\t IB Client\t\t "
1128 cfga_msg(msgp
, msg
);
1130 /* Walk the NVPAIR data */
1131 while (nvp
= nvlist_next_nvpair(nvl
, nvp
)) {
1132 name
= nvpair_name(nvp
);
1133 if (strcmp(name
, "Client") == 0) {
1134 (void) nvpair_value_string(nvp
, &clnt_name
);
1136 } else if (strcmp(name
, "Alt_HCA") == 0) {
1137 (void) nvpair_value_string(nvp
, &alt_hca
);
1139 } else if (strcmp(name
, "ApID") == 0) {
1140 (void) nvpair_value_string(nvp
, &clnt_apid
);
1144 /* check at the end; print message per client found */
1147 (void) snprintf(msg
, 256, "%-30s %-25s %s\n",
1148 clnt_apid
, clnt_name
, alt_hca
);
1149 cfga_msg(msgp
, msg
);
1151 } /* end of while */
1157 /* -x unconfig_clients */
1158 } else if (strcmp(func
, IB_UNCONFIG_HCA_CLIENTS
) == 0) {
1160 * -x unconfig_clients changes state by calling into RCM.
1161 * It needs root privileges.
1163 if (geteuid() != 0) {
1164 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1168 /* only supported on HCA ap_ids */
1169 if (fab_apid
!= NULL
) {
1170 DPRINTF("cfga_private_func: fabric apid supplied\n");
1171 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1176 * Check w/ user if it is ok to do this operation
1177 * If the user fails to confirm, bailout
1179 if (!ib_confirm(confp
, IB_CONFIRM3
))
1182 /* Get device-paths of all the IOC/Port/Pseudo devices */
1183 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_UNCFG_CLNTS_SZ
,
1184 IBNEX_UNCFG_CLNTS_INFO
, 0, (void **)&info
, &info_len
);
1186 DPRINTF("cfga_private_func: ib_do_control_ioctl "
1187 "failed :%d\n", rv
);
1188 return (ib_err_msg(errstring
, CFGA_IB_HCA_UNCONFIG_ERR
,
1192 if (nvlist_unpack((char *)info
, info_len
, &nvl
, 0)) {
1193 DPRINTF("cfga_private_func: nvlist_unpack failed %p\n",
1196 return (ib_err_msg(errstring
, CFGA_IB_NVLIST_ERR
, ap_id
,
1202 /* Call RCM Offline on all device paths */
1203 while (nvp
= nvlist_next_nvpair(nvl
, nvp
)) {
1204 name
= nvpair_name(nvp
);
1205 if (strcmp(name
, "devpath") == 0) {
1206 (void) nvpair_value_string(nvp
, &clnt_devpath
);
1208 } else if (strcmp(name
, "ApID") == 0) {
1209 (void) nvpair_value_string(nvp
, &clnt_apid
);
1213 /* handle the client unconfigure now */
1215 count
= 0; /* reset count */
1217 DPRINTF("cfga_private_func: client apid = %s, "
1218 "DevPath = %s\n", clnt_apid
, clnt_devpath
);
1219 if ((rv
= ib_setup_for_devctl_cmd(clnt_apid
,
1220 B_TRUE
, &hdl
, &nvl
)) != CFGA_IB_OK
) {
1221 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1222 return (ib_err_msg(errstring
, rv
,
1226 if ((rv
= ib_device_configured(hdl
, nvl
,
1227 &rstate
)) == CFGA_IB_NOT_CONFIGURED
)
1230 if ((rv
= ib_rcm_offline(clnt_apid
, errstring
,
1231 clnt_devpath
, flags
)) != CFGA_IB_OK
) {
1232 DPRINTF("cfga_private_func: client rcm "
1233 "offline failed for %s, with %d\n",
1239 if (devctl_ap_unconfigure(hdl
, nvl
) != 0) {
1240 DPRINTF("cfga_private_func: client "
1241 "unconfigure failed: errno %d\n",
1243 ret
= CFGA_IB_UNCONFIG_OP_ERR
;
1245 ret
= CFGA_IB_BUSY_ERR
;
1246 (void) ib_rcm_online(clnt_apid
,
1247 errstring
, clnt_devpath
, flags
);
1250 (void) ib_rcm_remove(clnt_apid
,
1251 errstring
, clnt_devpath
, flags
);
1253 ib_cleanup_after_devctl_cmd(hdl
, nvl
);
1255 } /* end of if count == 2 */
1257 } /* end of while */
1262 DPRINTF("cfga_private_func: unconfig_clients of %s "
1263 "failed with %d\n", ap_id
, ret
);
1264 return (ib_err_msg(errstring
, CFGA_IB_UCFG_CLNTS_ERR
,
1268 /* -x update_pkey_tbls */
1269 } else if (strcmp(func
, IB_UPDATE_PKEY_TBLS
) == 0) {
1271 * Check for root privileges.
1273 if (geteuid() != 0) {
1274 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1278 /* CHECK: Only supported on fabric ap_ids */
1279 if (fab_apid
== NULL
|| strcmp(fab_apid
, IBNEX_FABRIC
) != 0) {
1280 DPRINTF("cfga_private_func: fabric apid needed\n");
1281 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1285 /* Check w/ user if it is ok to do this operation */
1286 len
= strlen(IB_CONFIRM4
) + 10;
1287 if ((msg
= (char *)calloc(len
, 1)) != NULL
) {
1288 (void) snprintf(msg
, len
, "%s\nContinue", IB_CONFIRM4
);
1291 /* If the user fails to confirm, return */
1292 if (!ib_confirm(confp
, msg
)) {
1298 /* Update P_Key tables for all ports of all HCAs */
1299 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_UPDATE_PKEY_TBLS
,
1300 0, 0, 0, &info_len
);
1303 DPRINTF("cfga_private_func: ib_do_control_ioctl "
1304 "failed :%d\n", rv
);
1305 return (ib_err_msg(errstring
, CFGA_IB_UPD_PKEY_TBLS_ERR
,
1309 /* -x [add_service|delete_service] */
1310 } else if ((strncmp(func
, IB_ADD_SERVICE
, 12) == 0) ||
1311 (strncmp(func
, IB_DELETE_SERVICE
, 15) == 0)) {
1312 char *subopts
, *val
;
1315 /* check: Only supported on fabric ap_ids */
1316 if (fab_apid
== NULL
|| strcmp(fab_apid
, IBNEX_FABRIC
) != 0) {
1317 DPRINTF("cfga_private_func: fabric apid needed\n");
1318 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1322 /* Check for root privileges. */
1323 if (geteuid() != 0) {
1324 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1328 /* return error if no options are specified */
1329 subopts
= (char *)options
;
1330 if (subopts
== NULL
) {
1331 DPRINTF("cfga_private_func: no sub-options\n");
1332 (void) cfga_help(msgp
, options
, flags
);
1333 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
,
1337 /* parse options specified */
1338 while (*subopts
!= '\0') {
1339 switch (getsubopt(&subopts
, ib_service_subopts
, &val
)) {
1342 (void) cfga_help(msgp
, options
, flags
);
1343 S_FREE(service_name
);
1344 return (ib_err_msg(errstring
,
1345 CFGA_IB_INVAL_ARG_ERR
,
1348 comm_name
= strdup(val
);
1349 if (comm_name
== NULL
) {
1350 DPRINTF("comm sub-opt invalid "
1352 S_FREE(service_name
);
1353 return (ib_err_msg(errstring
,
1354 CFGA_IB_COMM_INVAL_ERR
,
1360 case 1: /* service */
1362 (void) cfga_help(msgp
, options
, flags
);
1364 return (ib_err_msg(errstring
,
1365 CFGA_IB_INVAL_ARG_ERR
,
1368 /* service can be upto 4 long */
1369 if (strlen(val
) == 0 ||
1371 DPRINTF("comm sub-opt invalid "
1372 "service passed\n");
1374 return (ib_err_msg(errstring
,
1375 CFGA_IB_SVC_LEN_ERR
,
1378 service_name
= strdup(val
);
1379 if (service_name
== NULL
) {
1380 DPRINTF("comm sub-opt "
1381 "internal error\n");
1383 return (ib_err_msg(errstring
,
1384 CFGA_IB_SVC_INVAL_ERR
,
1391 (void) cfga_help(msgp
, options
, flags
);
1393 S_FREE(service_name
);
1394 return (ib_err_msg(errstring
,
1395 CFGA_IB_INVAL_ARG_ERR
, ap_id
, errno
));
1399 /* figure out the "operation" */
1400 if (strncasecmp(func
, IB_ADD_SERVICE
, 11) == 0)
1401 cmd
= IBCONF_ADD_ENTRY
;
1402 else if (strncasecmp(func
, IB_DELETE_SERVICE
, 14) == 0)
1403 cmd
= IBCONF_DELETE_ENTRY
;
1404 DPRINTF("Service = %s, Comm = %s, Operation = %s\n",
1405 service_name
, comm_name
, func
);
1407 if (strncasecmp(comm_name
, IBNEX_PORT_STR
, 4) == 0)
1408 service_type
= IB_PORT_SERVICE
;
1409 else if (strncasecmp(comm_name
, IBNEX_VPPA_STR
, 4) == 0)
1410 service_type
= IB_VPPA_SERVICE
;
1411 else if (strncasecmp(comm_name
, IBNEX_HCASVC_STR
, 4) == 0)
1412 service_type
= IB_HCASVC_SERVICE
;
1414 (void) cfga_help(msgp
, options
, flags
);
1416 S_FREE(service_name
);
1417 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
,
1421 /* do the add/delete entry to the service */
1422 if (cmd
== IBCONF_ADD_ENTRY
) {
1423 if ((rv
= ib_add_service(errstring
)) != CFGA_IB_OK
)
1424 DPRINTF("cfga_private_func: add failed\n");
1425 } else if (cmd
== IBCONF_DELETE_ENTRY
) {
1426 if ((rv
= ib_delete_service(errstring
)) != CFGA_IB_OK
)
1427 DPRINTF("cfga_private_func: delete failed\n");
1431 S_FREE(service_name
);
1432 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1434 } else if (strncmp(func
, IB_LIST_SERVICES
, 13) == 0) {
1436 /* check: Only supported on fabric ap_ids */
1437 if (fab_apid
== NULL
|| strcmp(fab_apid
, IBNEX_FABRIC
) != 0) {
1438 DPRINTF("cfga_private_func: fabric apid needed\n");
1439 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1443 /* do the list services */
1444 rv
= ib_list_services(msgp
, errstring
);
1445 if (rv
!= CFGA_IB_OK
) {
1446 DPRINTF("cfga_private_func: ib_list_services failed\n");
1447 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1450 /* -x update_ioc_conf */
1451 } else if (strncmp(func
, IB_UPDATE_IOC_CONF
, 17) == 0) {
1454 /* Supported only with root privilege */
1455 if (geteuid() != 0) {
1456 return (ib_err_msg(errstring
, CFGA_IB_PRIV_ERR
, ap_id
,
1461 * check: Only supported on fabric ap_id or IOC APID
1462 * IOC APID does not have any commas in it.
1464 if (fab_apid
== NULL
||
1465 (fab_apid
!= NULL
&& strstr(fab_apid
, ",") != NULL
)) {
1466 DPRINTF("cfga_private_func: fabric/IOC apid needed\n");
1467 return (ib_err_msg(errstring
, CFGA_IB_INVALID_OP_ERR
,
1471 /* Check w/ user if it is ok to do this operation */
1472 len
= strlen(IB_CONFIRM5
) + 10;
1473 if ((msg
= (char *)calloc(len
, 1)) != NULL
) {
1474 (void) snprintf(msg
, len
, "%s\nContinue", IB_CONFIRM5
);
1477 /* If the user fails to confirm, return */
1478 if (!ib_confirm(confp
, msg
)) {
1484 misc_arg
= (strcmp(fab_apid
, IBNEX_FABRIC
) == 0) ?
1485 IBNEX_BASE_APID
: IBNEX_DYN_APID
;
1487 /* Reprobe and update IOC(s) configuration */
1488 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_UPDATE_IOC_CONF
,
1489 0, misc_arg
, 0, &info_len
);
1492 DPRINTF("cfga_private_func: ib_do_control_ioctl "
1493 "failed :%d\n", rv
);
1494 return (ib_err_msg(errstring
, CFGA_IB_DEVCTL_ERR
,
1498 DPRINTF("cfga_private_func: unrecognized command.\n");
1499 (void) cfga_help(msgp
, options
, flags
);
1501 return (CFGA_INVAL
);
1504 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1512 * ap_id - The attachment point of an IB fabric
1513 * options - Test command options passed by the cfgadm(8)
1514 * msgp - cfgadm error message for this plugin
1515 * errstring - This contains error msg if command fails
1516 * flags - Cfgadm(1m) flags
1526 cfga_test(const char *ap_id
, const char *options
, struct cfga_msg
*msgp
,
1527 char **errstring
, cfga_flags_t flags
)
1529 (void) cfga_help(msgp
, options
, flags
);
1530 return (CFGA_OPNOTSUPP
);
1536 * ib_fill_static_apids
1538 * ap_id - The static attachment point of an IB device
1539 * clp - The returned "list" information array
1543 * Fills up the "list" information array for the static attachment point
1545 * IB fabric supports two types of static attachment points.
1546 * One is fabric and other is for the HCAs. This fills up
1547 * "cfga_list_data_t" for static attachment points.
1549 static cfga_ib_ret_t
1550 ib_fill_static_apids(char *ap_id
, cfga_list_data_t
*clp
)
1553 char *ap_id_log
= NULL
;
1555 /* Get /dev/cfg path to corresponding to the physical ap_id */
1556 /* Remember ap_id_log must be freed */
1557 if (ib_physpath_to_devlink(ap_id
, &ap_id_log
,
1558 &l_err
) != ICFGA_OK
) {
1559 DPRINTF("ib_fill_static_apids: "
1560 "ib_physpath_to_devlink failed\n");
1561 return (CFGA_IB_DEVLINK_ERR
);
1563 assert(ap_id_log
!= NULL
);
1565 /* Get logical ap-id corresponding to the physical */
1566 if (strstr(ap_id_log
, CFGA_DEV_DIR
) == NULL
) {
1567 DPRINTF("ib_fill_static_apids: devlink doesn't contain "
1570 return (CFGA_IB_DEVLINK_ERR
);
1573 clp
->ap_cond
= CFGA_COND_OK
;
1574 clp
->ap_r_state
= CFGA_STAT_CONNECTED
;
1575 clp
->ap_o_state
= CFGA_STAT_CONFIGURED
;
1576 clp
->ap_class
[0] = '\0'; /* Filled by libcfgadm */
1578 clp
->ap_status_time
= (time_t)-1;
1579 (void) snprintf(clp
->ap_log_id
, sizeof (clp
->ap_log_id
), "%s",
1580 /* Strip off /dev/cfg/ */ ap_id_log
+ strlen(CFGA_DEV_DIR
) + 1);
1581 (void) strlcpy(clp
->ap_phys_id
, ap_id
, sizeof (clp
->ap_phys_id
));
1583 /* Static IB apid */
1584 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
) {
1585 (void) strlcpy(clp
->ap_type
, IB_FABRIC_TYPE
,
1586 sizeof (clp
->ap_type
)); /* Fill in type */
1587 (void) strlcpy(clp
->ap_info
, IB_FABRIC_INFO
,
1588 sizeof (clp
->ap_info
));
1590 } else { /* Static HCA apid */
1592 uchar_t
*data
= NULL
;
1594 (void) strlcpy(clp
->ap_type
, IB_HCA_TYPE
,
1595 sizeof (clp
->ap_type
)); /* Fill in type */
1597 rv
= ib_do_control_ioctl(ap_id
, IBNEX_HCA_VERBOSE_SZ
,
1598 IBNEX_HCA_VERBOSE_INFO
, 0, (void **)&data
, &size
);
1600 DPRINTF("ib_fill_static_apids: ib_do_control_ioctl "
1601 "failed :%d\n", rv
);
1604 return (CFGA_IB_IOCTL_ERR
);
1607 (void) strlcpy(clp
->ap_info
, (char *)data
,
1608 sizeof (clp
->ap_info
));
1612 return (CFGA_IB_OK
);
1620 * ap_id - The attachment point of an IB fabric
1621 * ap_id_list - The returned "list" information array
1622 * nlistp - Number of elements in the "list" information array
1623 * options - List command options passed by the cfgadm(8)
1624 * listopts - "-s" specific options
1625 * errstring - This contains error msg if command fails
1626 * flags - Cfgadm(1m) flags
1630 * If the command succeeded, cfgadm -l output otherwise an error
1636 cfga_list_ext(const char *ap_id
, cfga_list_data_t
**ap_id_list
, int *nlistp
,
1637 const char *options
, const char *listopts
, char **errstring
,
1641 int i
, index
, count
;
1642 int show_dynamic
= 0;
1643 size_t num_devices
= 0;
1644 size_t num_hcas
= 0;
1645 size_t snap_size
= 0;
1646 uchar_t
*snap_data
= NULL
;
1647 nvpair_t
*nvp
= NULL
; /* for lint purposes */
1648 nvlist_t
*nvl
= NULL
;
1649 boolean_t apid_matched
= B_FALSE
; /* for valid ap_id */
1650 cfga_ib_ret_t rv
= CFGA_IB_OK
;
1651 cfga_list_data_t
*clp
= NULL
;
1653 if ((rv
= ib_verify_params(ap_id
, options
, errstring
)) != CFGA_IB_OK
) {
1654 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1657 /* make sure we have a valid ap_id_list */
1658 if (ap_id_list
== NULL
|| nlistp
== NULL
) {
1659 DPRINTF("cfga_list_ext: list = NULL or nlistp = NULL\n");
1660 return (ib_err_msg(errstring
, CFGA_IB_INVAL_ARG_ERR
,
1664 DPRINTF("cfga_list_ext: ap_id = %s\n", ap_id
);
1666 if ((flags
& CFGA_FLAG_LIST_ALL
) == CFGA_FLAG_LIST_ALL
) {
1667 expand
= 1; /* -a flag passed */
1670 if (GET_DYN(ap_id
) != NULL
) {
1674 if ((expand
== 1) && /* -a option passed */
1675 (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
)) {
1677 * Figure out how many IOC/Port/Pseudo
1678 * devices exist in the system?
1680 if ((rv
= ib_do_control_ioctl((char *)ap_id
,
1681 IBNEX_NUM_DEVICE_NODES
, 0, 0, 0, &num_devices
)) !=
1683 DPRINTF("cfga_list_ext: ib_do_control_ioctl "
1684 "IBNEX_NUM_DEVICE_NODES failed :%d\n", rv
);
1685 if (errno
== ENOENT
)
1686 return (CFGA_APID_NOEXIST
);
1687 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1690 DPRINTF("cfga_list_ext: num_devices = %d\n", num_devices
);
1693 /* Figure out how many HCA nodes exist in the system. */
1694 if ((rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_NUM_HCA_NODES
, 0, 0,
1695 0, &num_hcas
)) != CFGA_IB_OK
) {
1696 DPRINTF("cfga_list_ext: ib_do_control_ioctl "
1697 "IBNEX_NUM_HCA_NODES failed :%d\n", rv
);
1698 if (errno
== ENOENT
)
1699 return (CFGA_APID_NOEXIST
);
1700 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1702 DPRINTF("cfga_list_ext: num_hcas = %d\n", num_hcas
);
1705 * No HCAs or IOC/VPPA/Port/HCA_SVC/Pseudo devices seen (non-IB system)
1707 if (!(num_hcas
|| num_devices
)) {
1708 DPRINTF("cfga_list_ext: no IB devices found\n");
1709 return (CFGA_APID_NOEXIST
);
1713 * *nlistp contains to how many APIDs to show w/ cfgadm -l.
1714 * If ap_id is "fabric" then
1715 * *nlistp is all Dynamic Apids + One more for "fabric"
1716 * If ap_id is "HCA" ap_id then
1718 * Note that each HCA is a static APID, so nlistp will be 1 always
1719 * and this function will be called N times for each of the N HCAs
1722 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
) {
1723 *nlistp
= num_devices
+ 1;
1726 /* Assume it as a HCA ap_id */
1730 /* Allocate storage for passing "list" info back */
1731 if ((*ap_id_list
= (cfga_list_data_t
*)calloc(*nlistp
,
1732 sizeof (cfga_list_data_t
))) == NULL
) {
1733 DPRINTF("cfga_list_ext: malloc for cfga_list_data_t failed. "
1734 "errno: %d\n", errno
);
1735 return (ib_err_msg(errstring
, CFGA_IB_ALLOC_FAIL
,
1740 * Only static ap_id is ib_fabric:
1741 * If -a options isn't specified then only show the static ap_id.
1743 if (!show_dynamic
) {
1744 clp
= &(*ap_id_list
[0]);
1746 if ((rv
= ib_fill_static_apids((char *)ap_id
, clp
)) !=
1748 S_FREE(*ap_id_list
);
1749 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1751 apid_matched
= B_TRUE
;
1756 * No HCAs or IOC/VPPA/HCA_SVC/Port/Pseudo devices seen (non-IB system)
1758 if (!expand
|| (!num_hcas
&& !num_devices
)) {
1763 if (strstr((char *)ap_id
, IB_FABRIC_APID_STR
) != NULL
) {
1764 rv
= ib_do_control_ioctl((char *)ap_id
, IBNEX_SNAPSHOT_SIZE
,
1765 IBNEX_GET_SNAPSHOT
, IBNEX_DONOT_PROBE_FLAG
,
1766 (void **)&snap_data
, &snap_size
);
1768 DPRINTF("cfga_list_ext: ib_do_control_ioctl "
1769 "failed :%d\n", rv
);
1770 S_FREE(*ap_id_list
);
1772 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1775 if (nvlist_unpack((char *)snap_data
, snap_size
, &nvl
, 0)) {
1776 DPRINTF("cfga_list_ext: nvlist_unpack 1 failed %p\n",
1778 S_FREE(*ap_id_list
);
1780 return (ib_err_msg(errstring
, CFGA_IB_NVLIST_ERR
,
1785 * In kernel a nvlist is build per ap_id which contains
1786 * information that is displayed using cfgadm -l.
1787 * For IB devices only these 6 items are shown:
1788 * ap_id, type, occupant, receptacle, condition and info
1790 * In addition, one could specify a dynamic ap_id from
1791 * command-line. Then cfgadm -l should show only that
1792 * ap_id and skip rest.
1794 index
= 1; count
= 0;
1795 while (nvp
= nvlist_next_nvpair(nvl
, nvp
)) {
1800 char *name
= nvpair_name(nvp
);
1802 /* start of with next device */
1803 if (count
== IB_NUM_NVPAIRS
) {
1809 * Check if the index doesn't go beyond the
1810 * device number. If it goes, stop the loop
1811 * here not to cause the heap corruption.
1813 if (show_dynamic
== 0 && index
> num_devices
)
1816 /* fill up data into "clp" */
1817 clp
= (show_dynamic
!= 0) ? &(*ap_id_list
[0]) :
1818 &(ap_id_list
[0][index
]);
1820 /* First nvlist entry is "ap_id" always */
1821 if (strcmp(name
, IBNEX_NODE_APID_NVL
) == 0) {
1822 (void) nvpair_value_string(nvp
, &nv_apid
);
1823 DPRINTF("cfga_list_ext: Name = %s, apid = %s\n",
1827 * If a dynamic ap_id is specified in the
1828 * command-line, skip all entries until
1829 * the one needed matches.
1832 strstr(ap_id
, nv_apid
) == NULL
) {
1833 DPRINTF("cfga_list_ext: NO MATCH\n");
1836 * skip rest of the entries of this
1839 for (i
= 0; i
< IB_NUM_NVPAIRS
- 1; i
++)
1840 nvp
= nvlist_next_nvpair(nvl
,
1842 count
= 0; /* reset it */
1846 apid_matched
= B_TRUE
;
1848 /* build the physical ap_id */
1849 if (strstr(ap_id
, DYN_SEP
) == NULL
) {
1850 (void) snprintf(clp
->ap_phys_id
,
1851 sizeof (clp
->ap_phys_id
), "%s%s%s",
1852 ap_id
, DYN_SEP
, nv_apid
);
1854 (void) snprintf(clp
->ap_phys_id
,
1855 sizeof (clp
->ap_phys_id
), "%s",
1859 /* ensure that this is a valid apid */
1860 if (ib_verify_valid_apid(clp
->ap_phys_id
) !=
1862 DPRINTF("cfga_list_ext: "
1863 "not a valid IB ap_id\n");
1864 S_FREE(*ap_id_list
);
1867 return (ib_err_msg(errstring
,
1868 CFGA_IB_AP_ERR
, ap_id
, errno
));
1871 /* build the logical ap_id */
1872 (void) snprintf(clp
->ap_log_id
,
1873 sizeof (clp
->ap_log_id
), "ib%s%s",
1875 DPRINTF("cfga_list_ext: ap_pi = %s, ap_li = %s,"
1876 "\nap_info = %s\n", clp
->ap_phys_id
,
1877 clp
->ap_log_id
, clp
->ap_info
);
1880 } else if (strcmp(name
, IBNEX_NODE_INFO_NVL
) == 0) {
1881 (void) nvpair_value_string(nvp
, &info
);
1882 DPRINTF("cfga_list_ext: Name = %s, info = %s\n",
1884 (void) snprintf(clp
->ap_info
,
1885 sizeof (clp
->ap_info
), "%s", info
);
1888 } else if (strcmp(name
, IBNEX_NODE_TYPE_NVL
) == 0) {
1889 (void) nvpair_value_int32(nvp
, &node_type
);
1890 if (node_type
== IBNEX_PORT_NODE_TYPE
) {
1891 (void) snprintf(clp
->ap_type
,
1892 sizeof (clp
->ap_type
), "%s",
1894 } else if (node_type
== IBNEX_VPPA_NODE_TYPE
) {
1895 (void) snprintf(clp
->ap_type
,
1896 sizeof (clp
->ap_type
), "%s",
1898 } else if (node_type
==
1899 IBNEX_HCASVC_NODE_TYPE
) {
1900 (void) snprintf(clp
->ap_type
,
1901 sizeof (clp
->ap_type
), "%s",
1903 } else if (node_type
== IBNEX_IOC_NODE_TYPE
) {
1904 (void) snprintf(clp
->ap_type
,
1905 sizeof (clp
->ap_type
), "%s",
1907 } else if (node_type
==
1908 IBNEX_PSEUDO_NODE_TYPE
) {
1909 (void) snprintf(clp
->ap_type
,
1910 sizeof (clp
->ap_type
), "%s",
1913 DPRINTF("cfga_list_ext: Name = %s, type = %x\n",
1917 } else if (strcmp(name
, IBNEX_NODE_RSTATE_NVL
) == 0) {
1918 (void) nvpair_value_int32(nvp
, &intval
);
1920 if (intval
== AP_RSTATE_EMPTY
)
1921 clp
->ap_r_state
= CFGA_STAT_EMPTY
;
1922 else if (intval
== AP_RSTATE_DISCONNECTED
)
1924 CFGA_STAT_DISCONNECTED
;
1925 else if (intval
== AP_RSTATE_CONNECTED
)
1926 clp
->ap_r_state
= CFGA_STAT_CONNECTED
;
1927 DPRINTF("cfga_list_ext: Name = %s, "
1928 "rstate = %x\n", name
, intval
);
1931 } else if (strcmp(name
, IBNEX_NODE_OSTATE_NVL
) == 0) {
1932 (void) nvpair_value_int32(nvp
, &intval
);
1934 if (intval
== AP_OSTATE_CONFIGURED
)
1935 clp
->ap_o_state
= CFGA_STAT_CONFIGURED
;
1936 else if (intval
== AP_OSTATE_UNCONFIGURED
)
1938 CFGA_STAT_UNCONFIGURED
;
1939 DPRINTF("cfga_list_ext: Name = %s, "
1940 "ostate = %x\n", name
, intval
);
1943 } else if (strcmp(name
, IBNEX_NODE_COND_NVL
) == 0) {
1944 (void) nvpair_value_int32(nvp
, &intval
);
1946 if (intval
== AP_COND_OK
)
1947 clp
->ap_cond
= CFGA_COND_OK
;
1948 else if (intval
== AP_COND_FAILING
)
1949 clp
->ap_cond
= CFGA_COND_FAILING
;
1950 else if (intval
== AP_COND_FAILED
)
1951 clp
->ap_cond
= CFGA_COND_FAILED
;
1952 else if (intval
== AP_COND_UNUSABLE
)
1953 clp
->ap_cond
= CFGA_COND_UNUSABLE
;
1954 else if (intval
== AP_COND_UNKNOWN
)
1955 clp
->ap_cond
= CFGA_COND_UNKNOWN
;
1956 DPRINTF("cfga_list_ext: Name = %s, "
1957 "condition = %x\n", name
, intval
);
1961 clp
->ap_class
[0] = '\0'; /* Filled by libcfgadm */
1963 clp
->ap_status_time
= (time_t)-1;
1964 } /* end of while */
1971 * if a cmdline specified ap_id doesn't match the known list of ap_ids
1972 * then report an error right away
1974 rv
= (apid_matched
== B_TRUE
) ? CFGA_IB_OK
: CFGA_IB_AP_ERR
;
1975 return (ib_err_msg(errstring
, rv
, ap_id
, errno
));
1983 * msgp - cfgadm error message for this plugin
1984 * str - string to be passed on to the message
1990 * This routine accepts a variable number of message IDs and
1991 * constructs a corresponding error string which is printed
1992 * via the message print routine argument.
1995 cfga_msg(struct cfga_msg
*msgp
, const char *str
)
2000 if (msgp
== NULL
|| msgp
->message_routine
== NULL
) {
2001 DPRINTF("cfga_msg: msg\n");
2005 if ((len
= strlen(str
)) == 0) {
2006 DPRINTF("cfga_msg: null str\n");
2010 if ((q
= (char *)calloc(len
+ 1, 1)) == NULL
) {
2011 DPRINTF("cfga_msg: null q\n");
2015 (void) strlcpy(q
, str
, len
+ 1);
2016 (*msgp
->message_routine
)(msgp
->appdata_ptr
, q
);
2026 * msgp - Help message passed on to cfgadm(8)
2027 * options - Help message options passed on to cfgadm(8)
2028 * flags - Cfgadm(1m) flags
2032 * Were we able to print cfgadm help or not for this plugin
2034 * Print cfgadm help for this plugin
2038 cfga_help(struct cfga_msg
*msgp
, const char *options
, cfga_flags_t flags
)
2040 DPRINTF("cfga_help:\n");
2043 cfga_msg(msgp
, dgettext(TEXT_DOMAIN
, ib_help
[
2044 CFGA_IB_HELP_UNKNOWN
]));
2045 cfga_msg(msgp
, options
);
2048 /* Print messages array */
2049 cfga_msg(msgp
, dgettext(TEXT_DOMAIN
, ib_help
[CFGA_IB_HELP_HEADER
]));
2050 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_CONFIG
]);
2051 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_LIST
]);
2052 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_UPD_PKEY
]);
2053 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_CONF_FILE1
]);
2054 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_CONF_FILE2
]);
2055 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_UPD_IOC_CONF
]);
2056 cfga_msg(msgp
, ib_help
[CFGA_IB_HELP_UNCFG_CLNTS
]);
2066 * confp - The "cfga" structure that confirms a cfgadm query
2067 * msg - The message that needs confirmation
2071 * If a user entered YES or NO
2073 * Queries a user if it is ok to proceed with an operation or not.
2074 * Returns user's response.
2077 ib_confirm(struct cfga_confirm
*confp
, char *msg
)
2081 /* check that "confirm" function exists */
2082 if (confp
== NULL
|| confp
->confirm
== NULL
) {
2086 /* Call cfgadm provided "confirm" function */
2087 rval
= (*confp
->confirm
)(confp
->appdata_ptr
, msg
);
2088 DPRINTF("ib_confirm: %d\n", rval
);
2098 * ap_id - The dynamic attachment point of an IB device
2102 * devpath if it exists; otherwise NULL
2104 * Returns the devicepath for a dynamic attachment point of an IB device
2107 ib_get_devicepath(const char *ap_id
)
2109 char *devpath
= NULL
;
2112 /* Get device path sizes */
2113 if (ib_do_control_ioctl((char *)ap_id
, IBNEX_DEVICE_PATH_SZ
,
2114 IBNEX_GET_DEVICE_PATH
, 0, (void **)&devpath
, &size
) == CFGA_IB_OK
) {
2115 DPRINTF("ib_get_devicepath: get device path ioctl ok\n");
2119 DPRINTF("ib_get_devicepath: get device path ioctl failed\n");