cfga_ib.c revision 8b2e16e76f55405c78218b9f08c6aefaf13c9e24
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "cfga_ib.h"
/*
* cfga_ib.c:
* All cfgadm entry points that are defined in the config_admin(3X)
* needed for InfiniBand support are described here. These cfgadm
* interfaces issue ioctl(s) to the IB nexus driver. Attachment points
* supported are - IOC, VPPA, Port, HCA_SVC and Pseudo dynamic ap_ids,
* the HCA static ap_id, and the IB static ap_id.
*
* Given InfiniBand bus is fabric based, #of dynamic ap_ids present are
* unknown at any given point of time. Hence this plugin uses a
* packed nvlist data structure to hold ap_id related information.
* The IB nexus driver allocates the nvlist data in the kernel
* and this plugin processes the data (it is freed by IB nexus driver).
*/
/* function prototypes */
static int ib_get_link(di_devlink_t, void *);
static icfga_ret_t ib_physpath_to_devlink(char *, char **, int *);
static void ib_set_msg(char **, ...);
static int ib_verify_valid_apid(const char *);
static cfga_ib_ret_t ib_verify_params(const char *, const char *, char **);
devctl_hdl_t *, nvlist_t **);
ap_rstate_t *);
ap_ostate_t *);
void **, size_t *);
const char *, struct cfga_confirm *,
struct cfga_msg *, char **, cfga_flags_t);
cfga_err_t cfga_private_func(const char *, const char *,
const char *, struct cfga_confirm *,
struct cfga_msg *, char **, cfga_flags_t);
char **, cfga_flags_t);
const char *, const char *, char **, cfga_flags_t);
static int ib_confirm(struct cfga_confirm *, char *);
static char *ib_get_devicepath(const char *);
/* External function prototypes */
extern cfga_ib_ret_t ib_rcm_offline(const char *, char **, char *,
extern cfga_ib_ret_t ib_rcm_online(const char *, char **, char *,
extern cfga_ib_ret_t ib_rcm_remove(const char *, char **, char *,
extern int ib_add_service(char **);
extern int ib_delete_service(char **);
extern int ib_list_services(struct cfga_msg *, char **);
/* Globals */
/* the cfgadm library's use. */
static char *ib_help[] = { /* Help messages */
NULL,
/* CFGA_IB_HELP_HEADER */ "IB specific commands:\n",
/* CFGA_IB_HELP_CONFIG */ "cfgadm -c [configure|unconfigure] "
"ap_id [ap_id...]\n",
/* CFGA_IB_HELP_LIST */ "cfgadm -x list_clients hca_ap_id "
"[hca_ap_id...]\n",
/* CFGA_IB_HELP_UPD_PKEY */ "cfgadm -x update_pkey_tbls ib\n",
/* CFGA_IB_HELP_CONF_FILE1 */ "cfgadm -o comm=[port|vppa|hca-svc],"
"service=<name> -x [add_service|delete_service] ib\n",
/* CFGA_IB_HELP_CONF_FILE2 */ "cfgadm -x list_services ib\n",
/* CFGA_IB_HELP_UPD_IOC_CONF */ "cfgadm -x update_ioc_config "
"[ib | ioc_apid]\n",
/* CFGA_IB_HELP_UNCFG_CLNTS */ "cfgadm -x unconfig_clients hca_ap_id "
"[hca_ap_id...]\n",
/* CFGA_IB_HELP_UNKNOWN */ "\tunknown command or option: ",
};
"Unknown message; internal error " },
"Internal error " },
"Invalid input args " },
"Hardware specific options not supported " },
"Cannot issue devctl to " },
"No device connected to " },
"No device configured to " },
"already connected; cannot connect again " },
"already configured " },
"configure operation failed " },
"unconfigure operation failed " },
"Driver ioctl failed " },
"Memory allocation failure " },
"Operation not supported " },
"Invalid ap_id supplied " },
"Internal error (nvlist) " },
"Listing HCA's clients failed " },
"Unconfiguring HCA's clients failed " },
"Updating P_Key tables failed " },
"Opening ib.conf file failed " },
"Locking ib.conf file failed " },
"Unlocking ib.conf file failed " },
"Communication type incorrectly specified " },
"Service name incorrectly specified " },
"Service name len should be <= to 4, " },
"unconfig_clients failed for HCA " },
"cannot get RCM handle "},
"failed to online: "},
"failed to offline: "}
};
/*
* these are the only valid sub-options for services.
*/
static char *ib_service_subopts[] = {
"comm",
"service",
};
/* Communication Service name : "port" or "vppa" or "hca-svc" */
/* ========================================================================= */
/*
* The next two funcs are imported from cfgadm_scsi.
* ib_physpath_to_devlink is the only func directly used by cfgadm_ib.
* ib_get_link supports it.
*/
/*
* Function:
* ib_get_link
* Input:
* devlink - devlink for the device path
* arg - argument passed to this "walker" function
* Output:
* NONE
* Returns:
* Continue "walking" or not
* Description:
* Routine to search the /dev directory or a subtree of /dev.
*/
static int
{
/*
* When path is specified, it's the node path without minor
* name. Therefore, the ../.. prefixes needs to be stripped.
*/
/* line content must have minor node */
return (DI_WALK_CONTINUE);
}
}
return (DI_WALK_TERMINATE);
}
/*
* Function:
* ib_physpath_to_devlink
* Input:
* node_path - Physical path of the ap_id node
* Output:
* logpp - Logical path to the ap_id node
* l_errnop - "errno"
* Returns:
* ICFGA_OK if everything was fine; otherwise an error with
* l_errnop set.
* Description:
* Given a physical path to an ap_id ensure that it exists
*/
/* ARGSUSED */
static icfga_ret_t
{
char *minor_path;
return (ICFGA_LIB_ERR);
}
(void *)&larg, ib_get_link);
return (ICFGA_LIB_ERR);
}
return (ICFGA_OK);
}
/* ========================================================================= */
/* Utilities */
/*
* Function:
* ib_get_msg
* Input:
* msg_index - Index into the message table
* msg_tbl - the message table
* tbl_size - size of the message table
* Output:
* NONE
* Returns:
* Message string if valid, otherwise an error
* Description:
* Given the index into a table (msgcvt_t) of messages,
* get the message string, converting it to the proper
* locale if necessary.
*
* NOTE: See cfga_ib.h
*/
static const char *
{
}
}
/*
* Function:
* ib_set_msg
* Input:
* NONE
* Output:
* ret_str - Returned "message" string.
* Returns:
* NONE
* Description:
* Allocates and creates a message string (in *ret_str),
* by concatenating all the (char *) args together, in order.
* Last arg MUST be NULL.
*/
static void
ib_set_msg(char **ret_str, ...)
{
char *str;
DPRINTF("ib_set_msg: realloc failed.\n");
return;
}
}
}
/*
* Function:
* ib_err_msg
* Input:
* ap_id - The attachment point of an IB fabric
* Output:
* errstring - Fill in the error msg string
* l_errno - The "errno" to be filled in.
* Returns:
* CFGA_IB_OK if we are able to fill in error msg;
* otherwise emit an error.
* Description:
* Error message handling.
*
* For the rv passed in, looks up the corresponding error message
* string(s), internationalized it if necessary, and concatenates
* it into a new memory buffer, and points *errstring to it.
* Note not all "rv"s will result in an error message return, as
* not all error conditions warrant a IB-specific error message.
*
* Some messages may display ap_id or errno, which is why they are
* passed in.
*/
static cfga_err_t
{
char *errno_str;
}
/* Generate the appropriate IB-specific error message(s) (if any). */
switch (rv) {
case CFGA_IB_OK: /* Special case - do nothing. */
break;
case CFGA_IB_AP_ERR:
case CFGA_IB_UNKNOWN:
case CFGA_IB_INTERNAL_ERR:
case CFGA_IB_OPTIONS_ERR:
case CFGA_IB_ALLOC_FAIL:
/* These messages require no additional strings passed. */
break;
case CFGA_IB_NOT_CONNECTED:
case CFGA_IB_NOT_CONFIGURED:
case CFGA_IB_CONFIG_OP_ERR:
case CFGA_IB_UNCONFIG_OP_ERR:
case CFGA_IB_BUSY_ERR:
case CFGA_IB_DEVLINK_ERR:
case CFGA_IB_RCM_HANDLE_ERR:
case CFGA_IB_RCM_ONLINE_ERR:
case CFGA_IB_RCM_OFFLINE_ERR:
case CFGA_IB_DEVCTL_ERR:
case CFGA_IB_COMM_INVAL_ERR:
case CFGA_IB_SVC_INVAL_ERR:
case CFGA_IB_SVC_LEN_ERR:
case CFGA_IB_SVC_EXISTS_ERR:
case CFGA_IB_SVC_NO_EXIST_ERR:
case CFGA_IB_LOCK_FILE_ERR:
case CFGA_IB_CONFIG_FILE_ERR:
case CFGA_IB_UNLOCK_FILE_ERR:
case CFGA_IB_UCFG_CLNTS_ERR:
case CFGA_IB_INVALID_OP_ERR:
/* These messages also print ap_id. */
break;
case CFGA_IB_IOCTL_ERR: /* These messages also print errno. */
case CFGA_IB_NVLIST_ERR:
break;
case CFGA_IB_OPEN_ERR: /* This messages also prints apid and errno. */
case CFGA_IB_PRIV_ERR:
case CFGA_IB_HCA_LIST_ERR:
case CFGA_IB_OPNOTSUPP:
case CFGA_IB_INVAL_ARG_ERR:
case CFGA_IB_INVAL_APID_ERR:
case CFGA_IB_HCA_UNCONFIG_ERR:
break;
default:
}
/*
* Determine the proper error code to send back to the cfgadm library.
*/
}
/*
* Function:
* ib_verify_valid_apid
* Input:
* ap_id - The attachment point of an IB fabric
* Output:
* NONE
* Returns:
* 0 if ap_id is valid; otherwise -1
* Description:
* Check if ap_id is valid or not.
* Ensure the ap_id passed is in the correct (physical ap_id) form:
* where xx is a one or two-digit number.
*
* Note the library always calls the plugin with a physical ap_id.
* Called by ib_verify_params().
*/
static int
ib_verify_valid_apid(const char *ap_id)
{
char *l_ap_id;
return (-1);
}
l_ap_id++;
/* fabric apids */
/* if the ap_id is "ib::" then report an error */
return (-1);
}
return (-1);
}
} else { /* HCA ap_ids */
/* ap_id has 1..2 or more than 2 dots */
return (-1);
}
}
return (0);
}
/*
* Function:
* ib_verify_params
* Input:
* ap_id - The attachment point of an IB fabric
* options - command options passed by the cfgadm(1M)
* errstring - This contains error msg if command fails
* Output:
* NONE
* Returns:
* CFGA_IB_OK if parameters are valid; otherwise emit an error.
* Description:
* Check if "options" and "errstring" are valid and if ap_id is
* valid or not.
*/
static cfga_ib_ret_t
{
}
DPRINTF("ib_verify_params: h/w-specific options not "
"supported.\n");
return (CFGA_IB_OPTIONS_ERR);
}
if (ib_verify_valid_apid(ap_id) != 0) {
DPRINTF("ib_verify_params: not an IB ap_id.\n");
return (CFGA_IB_AP_ERR);
}
return (CFGA_IB_OK);
}
/*
* Function:
* ib_cleanup_after_devctl_cmd
* Input:
* devctl_hdl - Handler to devctl
* user_nvlistp - Name-value-pair list pointer
* Output:
* NONE
* Returns:
* NONE
* Description:
* Cleanup an initialization/setup done in the next function i.e.
* ib_setup_for_devctl_cmd().
*/
static void
{
if (user_nvlist != NULL) {
}
if (devctl_hdl != NULL) {
}
}
/*
* Function:
* ib_setup_for_devctl_cmd
* Input:
* ap_id - Attachment point for the IB device in question
* use_static_ap_id - Whether to use static ap_id or not flag
* Output:
* devctl_hdl - Handler to devctl
* user_nvlistp - Name-value-pair list pointer
* Returns:
* CFGA_IB_OK if it succeeds or an appropriate error.
* Description:
* For any IB device that is doing a cfgadm operation this function
* sets up a devctl_hdl and allocates a nvlist_t. The devctl_hdl
* is acquired using libdevice APIs. The nvlist_t is filled up with
* the ap_id (as a string). This nvlist_t is looked up in the kernel
* to figure out which ap_id we are currently dealing with.
*
* "use_static_ap_id" flag tells if one should do a devctl_ap_acquire
* with IB_STATIC_APID or not. NOTE: We need an actual file-system
* vnode to do a devctl_ap_acquire.
*
* NOTE: always call ib_cleanup_after_devctl_cmd() after this function.
*/
static cfga_ib_ret_t
{
/* Get a handle to the ap */
DPRINTF("ib_setup_for_devctl_cmd: devctl_ap_acquire "
"errno: %d\n", errno);
return (CFGA_IB_DEVCTL_ERR);
}
/* Set up to pass dynamic ap_id down to driver */
/* ib_cleanup_after_devctl_cmd */
return (CFGA_IB_NVLIST_ERR);
}
/* create a "string" entry */
DPRINTF("ib_setup_for_devctl_cmd: nvlist_add_string failed. "
"errno: %d\n", errno);
return (CFGA_IB_NVLIST_ERR);
}
return (CFGA_IB_OK);
}
/*
* Function:
* ib_device_configured
* Input:
* hdl - Handler to devctl
* nvl - Name-value-pair list pointer
* Output:
* rstate - Receptacle state for the apid
* Returns:
* CFGA_IB_OK if it succeeds or an appropriate error.
* Description:
* Checks if there is a device actually configured to the ap? If so,
* issues a "devctl" to get the Receptacle state for that ap_id.
* If the ap_id is already configured it returns CFGA_IB_OK.
* Otherwise it returns a failure.
*/
static cfga_ib_ret_t
{
/* get ap_id's "devctl_ap_state" first */
return (CFGA_IB_DEVCTL_ERR);
}
return (CFGA_IB_NOT_CONFIGURED);
}
return (rv);
}
/*
* Function:
* ib_device_connected
* Input:
* hdl - Handler to devctl
* nvl - Name-value-pair list pointer
* Output:
* ostate - Occupant state for the apid
* Returns:
* CFGA_IB_OK if it succeeds or an appropriate error.
* Description:
* Checks if there is a device actually connected to the ap? If so,
* issues a "devctl" to get the Occupant state for that ap_id.
* If the ap_id is already connected it returns CFGA_IB_OK.
* Otherwise it returns a failure.
*/
static cfga_ib_ret_t
{
return (CFGA_IB_DEVCTL_ERR);
}
return (CFGA_IB_NOT_CONNECTED);
}
return (rv);
}
/*
* Function:
* ib_do_control_ioctl
* Input:
* ap_id - The dynamic attachment point of an IB device
* sub_cmd1 - Sub Command 1 to DEVCTL_AP_CONTROL devctl
* sub_cmd2 - Sub Command 2 to DEVCTL_AP_CONTROL devctl
* (Mandatory except for IBNEX_NUM_HCA_NODES,
* IBNEX_NUM_DEVICE_NODES,
* IBNEX_UPDATE_PKEY_TBLS &
* IBNEX_UPDATE_IOC_CONF)
* misc_arg - optional arguments to DEVCTL_AP_CONTROL devctl
* Output:
* descrp - Buffer containing data back from kernel
* sizep - Length of the buffer back from kernel
* Returns:
* CFGA_IB_OK if it succeeds or an appropriate error.
* Description:
* Issues DEVCTL_AP_CONTROL devctl with sub_cmd1 first which actually
* queries the IBNEX module in the kernel on the size of the data to
* be returned.
*
* Next issues DEVCTL_AP_CONTROL devctl with a buffer of that much
* size and gets the actual data back.
* Passes the data and the size back to caller.
*/
static cfga_ib_ret_t
{
int fd = -1;
uint32_t local_size = 0;
struct ibnex_ioctl_data ioctl_data;
/* try to open the ONLY static ap_id */
DPRINTF("ib_do_control_ioctl: open failed: "
"errno = %d\n", errno);
/* Provides a more useful error msg */
return (rv);
}
/*
* Find out first how large a buffer is needed?
*/
/* Pass "ap_id" up for all other commands */
if (sub_cmd1 != IBNEX_NUM_DEVICE_NODES &&
sub_cmd1 != IBNEX_NUM_HCA_NODES &&
} else {
ioctl_data.ap_id_len = 0;
}
DPRINTF("ib_do_control_ioctl: size ioctl ERR, errno: %d\n",
errno);
return (rv);
}
*sizep = local_size;
/*
* Don't do the second ioctl only in these cases
* (NOTE: the data is returned in the first ioctl itself; if any)
*/
if (sub_cmd1 == IBNEX_NUM_DEVICE_NODES ||
sub_cmd1 == IBNEX_NUM_HCA_NODES ||
return (rv);
}
DPRINTF("ib_do_control_ioctl: malloc failed\n");
return (CFGA_IB_ALLOC_FAIL);
}
/* Get the data */
}
}
return (rv);
}
/* ========================================================================== */
/* Entry points */
/*
* Function:
* cfga_change_state
* Input:
* state_change_cmd - Argument to the cfgadm -c command
* ap_id - The attachment point of an IB fabric
* options - State Change command options passed by the cfgadm(1M)
* confp - Whether this command requires confirmation?
* msgp - cfgadm error message for this plugin
* errstring - This contains error msg if command fails
* flags - Cfgadm(1m) flags
* Output:
* NONE
* Returns:
* If the command succeeded perform the cfgadm -c <cmd>;
* otherwise emit an error
* Description:
* Do cfgadm -c <cmd>
*/
/*ARGSUSED*/
{
int ret;
int len;
char *msg;
char *devpath;
}
/*
* All subcommands which can change state of device require
* root privileges.
*/
if (geteuid() != 0) {
}
}
switch (state_change_cmd) {
case CFGA_CMD_CONFIGURE:
if (rv != CFGA_IB_ALREADY_CONNECTED) {
}
if (rv == CFGA_IB_ALREADY_CONNECTED) {
/*
* special case handling for
* SLM based cfgadm disconnects
*/
if (ostate == AP_OSTATE_CONFIGURED) {
return (ib_err_msg(errstring,
errno));
}
}
}
return (CFGA_NACK);
}
DPRINTF("cfga_change_state: devctl_ap_configure "
"failed. errno: %d\n", errno);
break;
}
int i;
/*
* try for some time as IB hotplug thread
* takes a while to create the path
* and then eventually give up
*/
for (i = 0;
}
DPRINTF("cfga_change_state: get device "
"path failed i = %d\n", i);
break;
}
}
break;
case CFGA_CMD_UNCONFIGURE:
if (rv == CFGA_IB_DEVCTL_ERR)
}
/* check if it is already unconfigured */
}
}
return (CFGA_NACK);
}
DPRINTF("cfga_change_state: get device path failed\n");
break;
}
CFGA_IB_OK) {
break;
}
if (ret != 0) {
DPRINTF("cfga_change_state: devctl_ap_unconfigure "
"failed with errno: %d\n", errno);
}
} else {
}
break;
case CFGA_CMD_LOAD:
case CFGA_CMD_UNLOAD:
case CFGA_CMD_CONNECT:
case CFGA_CMD_DISCONNECT:
break;
case CFGA_CMD_NONE:
default:
}
}
/*
* Function:
* cfga_private_func
* Input:
* func - The private function (passed w/ -x option)
* ap_id - The attachment point of an IB fabric
* options - Private function command options passed
* by the cfgadm(1M)
* confp - Whether this command requires confirmation?
* msgp - cfgadm error message for this plugin
* errstring - This contains error msg if command fails
* flags - Cfgadm(1m) flags
* Output:
* NONE
* Returns:
* If the command succeeded perform the 'cfgadm -x <func>'; otherwise
* return failure.
* Description:
* Do cfgadm -x <func>
*/
/*ARGSUSED*/
{
DPRINTF("cfga_private_func: ib_verify_params "
"failed with rv: %d\n", rv);
}
DPRINTF("cfga_private_func: func is NULL\n");
errno));
}
/*
* check first if IB static ap_id is "configured" for use
*/
&nvl)) != CFGA_IB_OK) {
}
}
}
rv = CFGA_IB_OK;
/* only supported on HCA ap_ids */
DPRINTF("cfga_private_func: fabric apid supplied\n");
}
DPRINTF("cfga_private_func: malloc for msg failed. "
"errno: %d\n", errno);
}
DPRINTF("cfga_private_func: "
"ib_do_control_ioctl list failed :%d\n", rv);
}
DPRINTF("cfga_private_func: "
"nvlist_unpack 2 failed %p\n", info);
errno));
}
"Alternate HCA\n");
/* Walk the NVPAIR data */
++count;
++count;
++count;
}
/* check at the end; print message per client found */
if (count == 3) {
count = 0;
}
} /* end of while */
/* -x unconfig_clients */
/*
* -x unconfig_clients changes state by calling into RCM.
* It needs root privileges.
*/
if (geteuid() != 0) {
errno));
}
/* only supported on HCA ap_ids */
DPRINTF("cfga_private_func: fabric apid supplied\n");
}
/* Check w/ user if it is ok to do this operation */
}
/* If the user fails to confirm, bailout */
return (CFGA_NACK);
}
if (rv != 0) {
DPRINTF("cfga_private_func: ib_do_control_ioctl "
"failed :%d\n", rv);
}
DPRINTF("cfga_private_func: nvlist_unpack failed %p\n",
info);
errno));
}
ret = 0;
/* Call RCM Offline on all device paths */
++count;
++count;
}
/* handle the client unconfigure now */
if (count == 2) {
count = 0; /* reset count */
DPRINTF("cfga_private_func: client apid = %s, "
}
&rstate)) == CFGA_IB_NOT_CONFIGURED)
continue;
DPRINTF("cfga_private_func: client rcm "
"offline failed for %s, with %d\n",
clnt_devpath, rv);
continue;
}
DPRINTF("cfga_private_func: client "
"unconfigure failed: errno %d\n",
errno);
(void) ib_rcm_online(clnt_apid,
continue;
} else {
(void) ib_rcm_remove(clnt_apid,
}
} /* end of if count == 2 */
} /* end of while */
if (ret) {
DPRINTF("cfga_private_func: unconfig_clients of %s "
}
/* -x update_pkey_tbls */
/*
* Check for root privileges.
*/
if (geteuid() != 0) {
errno));
}
/* CHECK: Only supported on fabric ap_ids */
DPRINTF("cfga_private_func: fabric apid needed\n");
}
/* Check w/ user if it is ok to do this operation */
}
/* If the user fails to confirm, return */
return (CFGA_NACK);
}
/* Update P_Key tables for all ports of all HCAs */
0, 0, 0, &info_len);
if (rv != 0) {
DPRINTF("cfga_private_func: ib_do_control_ioctl "
"failed :%d\n", rv);
}
/* -x [add_service|delete_service] */
/* check: Only supported on fabric ap_ids */
DPRINTF("cfga_private_func: fabric apid needed\n");
}
/* Check for root privileges. */
if (geteuid() != 0) {
errno));
}
/* return error if no options are specified */
DPRINTF("cfga_private_func: no sub-options\n");
}
/* parse options specified */
while (*subopts != '\0') {
case 0: /* comm */
return (ib_err_msg(errstring,
} else {
DPRINTF("comm sub-opt invalid "
"arg\n");
return (ib_err_msg(errstring,
}
}
break;
case 1: /* service */
return (ib_err_msg(errstring,
} else {
/* service can be upto 4 long */
DPRINTF("comm sub-opt invalid "
"service passed\n");
return (ib_err_msg(errstring,
}
if (service_name == NULL) {
DPRINTF("comm sub-opt "
"internal error\n");
return (ib_err_msg(errstring,
}
}
break;
default:
return (ib_err_msg(errstring,
}
}
/* figure out the "operation" */
DPRINTF("Service = %s, Comm = %s, Operation = %s\n",
else {
}
if (cmd == IBCONF_ADD_ENTRY) {
DPRINTF("cfga_private_func: add failed\n");
} else if (cmd == IBCONF_DELETE_ENTRY) {
DPRINTF("cfga_private_func: delete failed\n");
}
/* check: Only supported on fabric ap_ids */
DPRINTF("cfga_private_func: fabric apid needed\n");
}
/* do the list services */
if (rv != CFGA_IB_OK) {
DPRINTF("cfga_private_func: ib_list_services failed\n");
}
/* -x update_ioc_conf */
/* Supported only with root privilege */
if (geteuid() != 0) {
errno));
}
/*
* check: Only supported on fabric ap_id or IOC APID
* IOC APID does not have any commas in it.
*/
}
/* Check w/ user if it is ok to do this operation */
}
/* If the user fails to confirm, return */
return (CFGA_NACK);
}
/* Reprobe and update IOC(s) configuration */
if (rv != 0) {
DPRINTF("cfga_private_func: ib_do_control_ioctl "
"failed :%d\n", rv);
}
} else {
DPRINTF("cfga_private_func: unrecognized command.\n");
return (CFGA_INVAL);
}
}
/*
* Function:
* cfga_test
* Input:
* ap_id - The attachment point of an IB fabric
* options - Test command options passed by the cfgadm(1M)
* msgp - cfgadm error message for this plugin
* errstring - This contains error msg if command fails
* flags - Cfgadm(1m) flags
* Output:
* NONE
* Returns:
* CFGA_OPNOTSUPP
* Description:
* Do "cfgadm -t"
*/
/*ARGSUSED*/
{
return (CFGA_OPNOTSUPP);
}
/*
* Function:
* ib_fill_static_apids
* Input:
* ap_id - The static attachment point of an IB device
* clp - The returned "list" information array
* Output:
* NONE
* Returns:
* Fills up the "list" information array for the static attachment point
* Description:
* IB fabric supports two types of static attachment points.
* One is fabric and other is for the HCAs. This fills up
* "cfga_list_data_t" for static attachment points.
*/
static cfga_ib_ret_t
{
/* Remember ap_id_log must be freed */
DPRINTF("ib_fill_static_apids: "
"ib_physpath_to_devlink failed\n");
return (CFGA_IB_DEVLINK_ERR);
}
/* Get logical ap-id corresponding to the physical */
DPRINTF("ib_fill_static_apids: devlink doesn't contain "
return (CFGA_IB_DEVLINK_ERR);
}
/* Static IB apid */
} else { /* Static HCA apid */
if (rv != 0) {
DPRINTF("ib_fill_static_apids: ib_do_control_ioctl "
"failed :%d\n", rv);
return (CFGA_IB_IOCTL_ERR);
}
}
return (CFGA_IB_OK);
}
/*
* Function:
* cfga_list_ext
* Input:
* ap_id - The attachment point of an IB fabric
* ap_id_list - The returned "list" information array
* nlistp - Number of elements in the "list" information array
* options - List command options passed by the cfgadm(1M)
* listopts - "-s" specific options
* errstring - This contains error msg if command fails
* flags - Cfgadm(1m) flags
* Output:
* NONE
* Returns:
* If the command succeeded, cfgadm -l output otherwise an error
* Description:
* Do cfgadm -l
*/
/*ARGSUSED*/
{
int expand = 0;
int show_dynamic = 0;
size_t num_devices = 0;
}
/* make sure we have a valid ap_id_list */
DPRINTF("cfga_list_ext: list = NULL or nlistp = NULL\n");
}
}
show_dynamic = 1;
}
/*
* devices exist in the system?
*/
IBNEX_NUM_DEVICE_NODES, 0, 0, 0, &num_devices)) !=
CFGA_IB_OK) {
DPRINTF("cfga_list_ext: ib_do_control_ioctl "
"IBNEX_NUM_DEVICE_NODES failed :%d\n", rv);
return (CFGA_APID_NOEXIST);
}
}
/* Figure out how many HCA nodes exist in the system. */
0, &num_hcas)) != CFGA_IB_OK) {
DPRINTF("cfga_list_ext: ib_do_control_ioctl "
"IBNEX_NUM_HCA_NODES failed :%d\n", rv);
return (CFGA_APID_NOEXIST);
}
/*
*/
if (!(num_hcas || num_devices)) {
DPRINTF("cfga_list_ext: no IB devices found\n");
return (CFGA_APID_NOEXIST);
}
/*
* *nlistp contains to how many APIDs to show w/ cfgadm -l.
* If ap_id is "fabric" then
* *nlistp is all Dynamic Apids + One more for "fabric"
* If ap_id is "HCA" ap_id then
* *nlistp is 1
* Note that each HCA is a static APID, so nlistp will be 1 always
* and this function will be called N times for each of the N HCAs
* in the host.
*/
} else {
/* Assume it as a HCA ap_id */
*nlistp = 1;
}
/* Allocate storage for passing "list" info back */
sizeof (cfga_list_data_t))) == NULL) {
DPRINTF("cfga_list_ext: malloc for cfga_list_data_t failed. "
"errno: %d\n", errno);
}
/*
* Only static ap_id is ib_fabric:
* If -a options isn't specified then only show the static ap_id.
*/
if (!show_dynamic) {
clp = &(*ap_id_list[0]);
CFGA_IB_OK) {
S_FREE(*ap_id_list);
}
}
/*
* No -a specified
*/
if (!show_dynamic)
return (CFGA_OK);
}
if (rv != 0) {
DPRINTF("cfga_list_ext: ib_do_control_ioctl "
"failed :%d\n", rv);
S_FREE(*ap_id_list);
}
DPRINTF("cfga_list_ext: nvlist_unpack 1 failed %p\n",
S_FREE(*ap_id_list);
}
/*
* In kernel a nvlist is build per ap_id which contains
* information that is displayed using cfgadm -l.
* For IB devices only these 6 items are shown:
* ap_id, type, occupant, receptacle, condition and info
*
* In addition, one could specify a dynamic ap_id from
* command-line. Then cfgadm -l should show only that
* ap_id and skip rest.
*/
char *info;
char *nv_apid;
/* start of with next device */
if (count == IB_NUM_NVPAIRS) {
count = 0;
++index;
}
/*
* Check if the index doesn't go beyond the
* device number. If it goes, stop the loop
* here not to cause the heap corruption.
*/
break;
/* fill up data into "clp" */
&(ap_id_list[0][index]);
/* First nvlist entry is "ap_id" always */
DPRINTF("cfga_list_ext: Name = %s, apid = %s\n",
/*
* If a dynamic ap_id is specified in the
* command-line, skip all entries until
* the one needed matches.
*/
if (show_dynamic &&
DPRINTF("cfga_list_ext: NO MATCH\n");
/*
* skip rest of the entries of this
* device.
*/
for (i = 0; i < IB_NUM_NVPAIRS - 1; i++)
nvp);
count = 0; /* reset it */
continue;
}
/* build the physical ap_id */
} else {
ap_id);
}
/* ensure that this is a valid apid */
0) {
DPRINTF("cfga_list_ext: "
"not a valid IB ap_id\n");
S_FREE(*ap_id_list);
return (ib_err_msg(errstring,
}
/* build the logical ap_id */
DPRINTF("cfga_list_ext: ap_pi = %s, ap_li = %s,"
++count;
DPRINTF("cfga_list_ext: Name = %s, info = %s\n",
++count;
if (node_type == IBNEX_PORT_NODE_TYPE) {
} else if (node_type == IBNEX_VPPA_NODE_TYPE) {
} else if (node_type ==
} else if (node_type == IBNEX_IOC_NODE_TYPE) {
} else if (node_type ==
}
DPRINTF("cfga_list_ext: Name = %s, type = %x\n",
++count;
if (intval == AP_RSTATE_EMPTY)
else if (intval == AP_RSTATE_DISCONNECTED)
clp->ap_r_state =
else if (intval == AP_RSTATE_CONNECTED)
DPRINTF("cfga_list_ext: Name = %s, "
++count;
if (intval == AP_OSTATE_CONFIGURED)
else if (intval == AP_OSTATE_UNCONFIGURED)
clp->ap_o_state =
DPRINTF("cfga_list_ext: Name = %s, "
++count;
if (intval == AP_COND_OK)
else if (intval == AP_COND_FAILING)
else if (intval == AP_COND_FAILED)
else if (intval == AP_COND_UNUSABLE)
else if (intval == AP_COND_UNKNOWN)
DPRINTF("cfga_list_ext: Name = %s, "
++count;
}
} /* end of while */
}
if (nvl)
/*
* if a cmdline specified ap_id doesn't match the known list of ap_ids
* then report an error right away
*/
}
/*
* Function:
* cfga_msg
* Input:
* msgp - cfgadm error message for this plugin
* str - string to be passed on to the message
* Output:
* NONE
* Returns:
* NONE
* Description:
* This routine accepts a variable number of message IDs and
* constructs a corresponding error string which is printed
* via the message print routine argument.
*/
void
{
int len;
char *q;
DPRINTF("cfga_msg: msg\n");
return;
}
DPRINTF("cfga_msg: null str\n");
return;
}
DPRINTF("cfga_msg: null q\n");
return;
}
free(q);
}
/*
* Function:
* cfga_help
* Input:
* msgp - Help message passed on to cfgadm(1M)
* options - Help message options passed on to cfgadm(1M)
* flags - Cfgadm(1m) flags
* Output:
* NONE
* Returns:
* Were we able to print cfgadm help or not for this plugin
* Description:
* Print cfgadm help for this plugin
*/
/* ARGSUSED */
{
DPRINTF("cfga_help:\n");
if (options) {
}
/* Print messages array */
return (CFGA_OK);
}
/*
* Function:
* ib_confirm
* Input:
* confp - The "cfga" structure that confirms a cfgadm query
* msg - The message that needs confirmation
* Output:
* None
* Returns:
* If a user entered YES or NO
* Description:
* Queries a user if it is ok to proceed with an operation or not.
* Returns user's response.
*/
static int
{
int rval;
/* check that "confirm" function exists */
return (0);
}
/* Call cfgadm provided "confirm" function */
return (rval);
}
/*
* Function:
* ib_get_devicepath
* Input:
* ap_id - The dynamic attachment point of an IB device
* Output:
* None
* Returns:
* devpath if it exists; otherwise NULL
* Description:
* Returns the devicepath for a dynamic attachment point of an IB device
*/
static char *
ib_get_devicepath(const char *ap_id)
{
/* Get device path sizes */
DPRINTF("ib_get_devicepath: get device path ioctl ok\n");
return (devpath);
} else {
DPRINTF("ib_get_devicepath: get device path ioctl failed\n");
return ((char *)NULL);
}
}