ibnex.c revision f9edfba4e2ac2531f0e52d0c4007976054e1023d
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The InfiniBand Nexus driver (IB nexus) is a bus nexus driver for IB bus.
* It supports Port nodes, Virtual Physical Point of Attachment nodes (VPPA)
* for HCAs registered with IBTL and IOC nodes for all the IOCs present in
* the IB fabric (that are accessible to the host). It also supports Pseudo
* device children to be enumerated using their .conf file(s). All Port nodes
* and VPPA nodes are children of HCA drivers. All the IOC nodes and the Pseudo
* device nodes are children of the IB nexus driver.
*
* IB nexus driver provides bus nexus entry points to all the HCA drivers.
*
* IB nexus driver registers with InfiniBand Device Manager (IBDM) to get
* information about all the HCA ports and I/O Controllers (IOCs) connected
* to the IB fabric. Based on that information, IB nexus will create all the
* device tree nodes.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/mdi_impldefs.h>
/* Function prototypes */
void *, void **);
static int ibnex_busctl(dev_info_t *,
dev_info_t *, ddi_ctl_enum_t, void *, void *);
static int ibnex_map_fault(dev_info_t *,
static int ibnex_init_child(dev_info_t *);
static void ibnex_comm_svc_fini();
ibdm_port_attr_t *, int, int, ib_pkey_t, int *,
int);
static void ibnex_delete_port_node_data(ibnex_node_data_t *);
int ibnex_get_dip_from_guid(ib_guid_t, int,
ib_pkey_t, dev_info_t **);
void *, int, ib_pkey_t);
int, ib_pkey_t);
static int ibnex_create_port_node_prop(ibdm_port_attr_t *,
dev_info_t *, char *, ib_pkey_t);
void ibnex_dm_callback(void *, ibdm_events_t);
static int ibnex_create_port_compatible_prop(dev_info_t *,
char *, ibdm_port_attr_t *);
static int ibnex_create_ioc_srv_props(
dev_info_t *, ibdm_ioc_info_t *);
static int ibnex_get_eventcookie(dev_info_t *,
dev_info_t *, char *, ddi_eventcookie_t *);
ddi_eventcookie_t, void (*)(dev_info_t *,
ddi_eventcookie_t, void *, void *),
static int ibnex_remove_eventcall(dev_info_t *,
ddi_eventcookie_t, void *);
ddi_bus_config_op_t, void *, dev_info_t **);
static int ibnex_bus_unconfig(dev_info_t *,
uint_t, ddi_bus_config_op_t, void *);
static int ibnex_get_pkey_commsvc_index_portnum(
static void ibnex_config_all_children(dev_info_t *);
static int ibnex_devname_to_portnum(char *, uint8_t *);
static void ibnex_create_vppa_nodes(
dev_info_t *, ibdm_port_attr_t *);
static void ibnex_create_port_nodes(
dev_info_t *, ibdm_port_attr_t *);
static void ibnex_create_hcasvc_nodes(
dev_info_t *, ibdm_port_attr_t *);
static int ibnex_config_root_iocnode(dev_info_t *, char *);
static int ibnex_devname2port(char *, int *);
static int ibnex_config_ioc_node(char *, dev_info_t *);
static int ibnex_devname_to_node_n_ioc_guids(
static int ibnex_is_ioc_present(ib_guid_t);
static void ibnex_ioc_node_cleanup();
static void ibnex_delete_ioc_node_data(ibnex_node_data_t *);
int ibnex_ioc_initnode(ibdm_ioc_info_t *, int,
dev_info_t *);
static int ibnex_create_ioc_node_prop(
ibdm_ioc_info_t *, dev_info_t *);
static int ibnex_create_ioc_compatible_prop(
uint64_t ibnex_str2hex(char *, int, int *);
static int ibnex_str2int(char *, int, int *);
static int ibnex_create_ioc_portgid_prop(
dev_info_t *, ibdm_ioc_info_t *);
static void ibnex_wakeup_reprobe_ioc(ibnex_node_data_t *, int);
static void ibnex_wakeup_reprobe_all();
static int ibnex_prom_devname_to_pkey_n_portnum(
void ibnex_pseudo_initnodes(void);
static char *ibnex_lookup_named_prop(ddi_prop_t *, char *);
static void ibnex_pseudo_node_cleanup(void);
static int ibnex_name_child(dev_info_t *, char *, int);
static int ibnex_name_pseudo_child(dev_info_t *, char *);
void ibnex_reprobe_ioc_dev(void *);
void ibnex_reprobe_ioc_all();
static void ibnex_update_prop(ibnex_node_data_t *,
ibdm_ioc_info_t *);
static ibnex_rval_t ibnex_unique_svcname(char *);
static void ibnex_handle_reprobe_dev(void *arg);
extern int ibnex_offline_childdip(dev_info_t *);
static int ibnex_ioc_create_pi(
dev_info_t *);
static int ibnex_bus_power(dev_info_t *, void *,
pm_bus_power_op_t, void *, void *);
dev_info_t *);
static int ibnex_pseudo_config_one(
ibnex_node_data_t *, char *, dev_info_t *);
static int ibnex_pseudo_mdi_config_one(int, void *, dev_info_t **,
char *, char *);
static void ibnex_config_pseudo_all(dev_info_t *);
ddi_bus_config_op_t, void *, dev_info_t **, int *);
static int ibnex_is_merge_node(dev_info_t *);
static void ibnex_hw_in_dev_tree(char *);
/*
* The bus_ops structure defines the capabilities of HCA nexus driver.
*/
struct bus_ops ibnex_ci_busops = {
nullbusmap, /* bus_map */
NULL, /* bus_get_intrspec */
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
ibnex_map_fault, /* Map Fault */
ddi_no_dma_map, /* DMA related entry points */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
ibnex_busctl, /* bus_ctl */
ddi_bus_prop_op, /* bus_prop_op */
NULL, /* bus_get_eventcookie */
NULL, /* bus_add_eventcall */
NULL, /* bus_remove_eventcall */
NULL, /* bus_post_event */
NULL,
ibnex_bus_config, /* bus config */
ibnex_bus_unconfig /* bus unconfig */
};
/*
* Prototype declarations for the VHCI options
*/
/*
* Functions registered with the mpxio framework
*/
mdi_pathinfo_state_t, uint32_t, int);
static mdi_vhci_ops_t ibnex_vhci_ops = {
};
/*
* The bus_ops structure defines the capabilities of IB nexus driver.
* IB nexus drivers does not support any DMA operations for its children
* as there is no such concept in Infiniband. All the memory operations
* and DMA operations required by the child drivers can be performed using
* the IBTF API.
*/
struct bus_ops ibnex_bus_ops = {
nullbusmap, /* bus_map */
NULL, /* bus_get_intrspec */
NULL, /* bus_add_intrspec */
NULL, /* bus_remove_intrspec */
ibnex_map_fault, /* Map Fault */
ddi_no_dma_map, /* DMA related entry points */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
ibnex_busctl, /* bus_ctl */
ddi_bus_prop_op, /* bus_prop_op */
ibnex_get_eventcookie, /* bus_get_eventcookie */
ibnex_add_eventcall, /* bus_add_eventcall */
ibnex_remove_eventcall, /* bus_remove_eventcall */
ibnex_post_event, /* bus_post_event */
NULL,
ibnex_bus_config, /* bus config */
ibnex_bus_unconfig, /* bus unconfig */
NULL, /* bus fm init */
NULL, /* bus fm fini */
NULL, /* bus fm access enter */
NULL, /* bus fm access exit */
ibnex_bus_power /* bus power */
};
/* ibnex cb_ops */
static struct cb_ops ibnex_cbops = {
ibnex_open, /* open */
ibnex_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
ibnex_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* prop_op */
NULL, /* stream */
D_MP, /* cb_flag */
CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
/*
* Device options
* Note: ddi_no_info needs to change during devfs time frame. The drivers
* with 1 to 1 mapping between minor node and instance should use
* ddi_1to1_info. (See bug id 4424752)
*/
DEVO_REV, /* devo_rev, */
0, /* refcnt */
ibnex_getinfo, /* info */
nulldev, /* identify */
nulldev, /* probe */
ibnex_attach, /* attach */
ibnex_detach, /* detach */
nodev, /* reset */
&ibnex_cbops, /* driver ops - devctl interfaces */
&ibnex_bus_ops, /* bus operations */
nulldev /* power */
};
/* Module linkage information for the kernel. */
&mod_driverops, /* Driver module */
"IB nexus %I%", /* Driver name and version */
&ibnex_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
};
/*
* Global per-instance IB Nexus data.
* There is only one instance of IB Nexus supported.
*/
#ifdef __lock_lint
#endif
/* The port settling time in seconds */
int ibnex_port_settling_time = 8;
/* create an array of properties supported, easier to add new ones here */
static struct ibnex_property {
char *name;
} ibnex_properties[] = {
{ "port-svc-list", IBNEX_PORT_COMMSVC_NODE},
{ "vppa-svc-list", IBNEX_VPPA_COMMSVC_NODE},
{ "hca-svc-list", IBNEX_HCASVC_COMMSVC_NODE}
};
#define N_IBNEX_PROPS (sizeof (ibnex_properties))/ \
(sizeof (struct ibnex_property))
/*
* Event Definition
* Single event, event name defined in ibti_common.h.
* Event posted to specific child handler. Event posted
* at kernel priority.
*/
static ndi_event_definition_t ibnex_ndi_event_defs[] = {
};
#define IB_N_NDI_EVENTS \
(sizeof (ibnex_ndi_event_defs) / sizeof (ndi_event_definition_t))
static ndi_event_set_t ib_ndi_events = {
static int ibnex_hw_status = IBNEX_DEVTREE_NOT_CHECKED;
/*
* _init
* Loadable module init, called before any other module.
*/
int
_init(void)
{
int error;
char **hca_driver_list;
int i, ndrivers;
if (ibnex_hw_status == IBNEX_DEVTREE_NOT_CHECKED) {
for (i = 0; i < ndrivers; i++) {
if (ibnex_hw_status == IBNEX_HW_IN_DEVTREE)
break;
}
}
/*
* IB Nexus _init can be called while force attaching
* IB Nexus driver or when a HCA is hotplugged.
*
* If IB HW is not in device tree or if no HCA driver
* has been attached, fail IB Nexus _init().
*/
if (ibnex_hw_status == IBNEX_HW_NOT_IN_DEVTREE &&
ibt_hw_is_present() == 0) {
return (DDI_FAILURE);
}
} else {
}
return (error);
}
/*
* _fini
* Prepares a module for unloading.
*/
int
_fini(void)
{
int error;
return (error);
}
return (0);
}
/*
* _info
* Returns information about loadable module.
*/
int
{
}
/*
* ibnex_attach
* Configure and attach an instance of the IB Nexus driver
* Only one instance of IB Nexus is supported
* Create a minor node for cfgadm purpose
* Initialize communication services
* Register callback with IBDM
* Register callback with IBTL
*/
static int
{
int i;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/* Fail attach for more than one instance */
return (DDI_FAILURE);
}
/* Register with MPxIO framework */
!= MDI_SUCCESS) {
IBTF_DPRINTF_L2("ibnex",
"\tattach: mdi_vhci_register() failed");
return (DDI_FAILURE);
}
/*
* Create the "fabric" devctl minor-node for IB DR support.
* The minor number for the "devctl" node is in the same format
* as the AP minor nodes.
*/
DDI_NT_IB_ATTACHMENT_POINT, 0) != DDI_SUCCESS) {
IBTF_DPRINTF_L2("ibnex",
"\tattach: failed to create fabric minornode");
(void) mdi_vhci_unregister(dip, 0);
return (DDI_FAILURE);
}
/*
* Set pm-want-child-notification property for
* power management of the phci and client
*/
IBTF_DPRINTF_L2("ibnex",
"_attach: create pm-want-child-notification failed");
(void) mdi_vhci_unregister(dip, 0);
return (DDI_FAILURE);
}
/*
* Event Handling: Definition and Binding.
*/
NDI_SLEEP) != NDI_SUCCESS) {
IBTF_DPRINTF_L2("ibnex",
"_attach: ndi_event_alloc_hdl failed");
(void) mdi_vhci_unregister(dip, 0);
return (DDI_FAILURE);
}
NDI_SLEEP) != NDI_SUCCESS) {
IBTF_DPRINTF_L2("ibnex",
"_attach: ndi_event_bind_set failed");
(void) mdi_vhci_unregister(dip, 0);
return (DDI_FAILURE);
}
for (i = 0; i < N_IBNEX_PROPS; i++) {
(void) ndi_event_free_hdl(
(void) mdi_vhci_unregister(dip, 0);
return (DDI_FAILURE);
}
}
/*
* before anything else comes up:
* Initialize the internal list of pseudo device nodes by
* getting all pseudo children of "ib" and processing them.
*/
return (DDI_SUCCESS);
}
/*
* ibnex_getinfo()
* Given the device number, return the devinfo pointer or the
* instance number.
* Note: always succeed DDI_INFO_DEVT2INSTANCE, even before attach.
*/
/*ARGSUSED*/
static int
{
int ret = DDI_SUCCESS;
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
else {
ret = DDI_FAILURE;
}
break;
case DDI_INFO_DEVT2INSTANCE:
*result = 0;
break;
default:
ret = DDI_FAILURE;
}
return (ret);
}
/*
* ibnex_detach
* Unregister callback with the IBDM
* Unregister callback with the IBTL
* Uninitialize the communication entries
* Remove all the minor nodes created by this instance
*/
static int
{
switch (cmd) {
case DDI_DETACH:
break;
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
if (ibt_hw_is_present()) {
IBTF_DPRINTF_L2("ibnex",
"\tdetach: IB HW is present ");
return (DDI_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tdetach: ndi_event_free_hdl() failed");
return (DDI_FAILURE);
}
(void) mdi_vhci_unregister(dip, 0);
return (DDI_SUCCESS);
}
/*
* ibnex_pseudo_node_cleanup()
* This checks if all the "dips" have been deallocated (implying
* that all the children have been unconfigured) first.
* If not, it just returns.
* If yes, then it frees up memory allocated for devi_name,
* node_addr, and property list.
*/
static void
{
return;
if (pseudo->pseudo_node_addr) {
}
if (pseudo->pseudo_devi_name) {
}
if (pseudo->pseudo_unit_addr) {
}
}
}
/*
* This functions wakes up any reprobe requests waiting for completion
* of reprobe of this IOC. It also send an NDI event, if :
*
* notify_flag is set. This is set if :
* ibt_reprobe_ioc has returned with SUCCESS
* IBTF client has not been notified for this node.
* node_data->node_dip != NULL
* node_state has IBNEX_NODE_REPROBE_NOTIFY_ALWAYS set
* An NDI event cookie has been registered.
*/
static void
{
(node_data->node_reprobe_state != 0)) {
(node_data->node_state &
(evt_cookie != NULL)) {
IBTF_DPRINTF_L2("ibnex",
"\tndi_post_event failed\n");
}
node_data->node_reprobe_state = 0;
}
node_data->node_reprobe_state = 0;
}
/*
* This function wakes up any reprobe request waiting for completion
* of reprobe of all IOCs.
*/
static void
{
/* Notify if another reprobe_all is pending */
ibnex.ibnex_reprobe_state = 0;
}
ibnex.ibnex_reprobe_state = 0;
/*
* The IOC may be hot-removed after the reprobe request.
* Reset the reprobe states for such IOCs.
*/
if (ioc_node->node_reprobe_state != 0) {
}
}
}
/*
* ibnex_ibnex_callback:
* IBTL_IBNEX_IBC_INIT:
* Called from ibc_init() which is called from
* HCA driver _init entry point
* Initializes the HCA dev_ops structure with default
* IB nexus structure.
* IBTL_IBNEX_IBC_FINI:
* Called from ibc_fini() which is called from
* HCA driver _fini entry point
* Un-Initializes the HCA dev_ops structure with default
* IB nexus strucuture.
* Returns IBT_SUCCESS
*/
{
int retval = IBT_SUCCESS;
struct dev_ops *hca_dev_ops;
case IBTL_IBNEX_IBC_INIT:
/*
* Get the devops structure of the HCA,
* and put IB nexus default busops vector in its place.
*/
hca_dev_ops = ((struct modldrv *)
break;
case IBTL_IBNEX_IBC_FINI:
hca_dev_ops = ((struct modldrv *)
break;
/* IBTL pass down request for ibt_reprobe_dev */
/* Reprobe for IOC nodes only */
/*
* Start the reprobe. This could sleep as it is not
* from interrupt context.
*/
IBTF_DPRINTF_L2("ibnex",
"ibnex_ibtl_callback: taskq_dispatch failed");
return (IBT_INSUFF_KERNEL_RESOURCE);
}
return (IBT_SUCCESS);
}
return (retval);
}
/*
* Bus-ops entry points
*/
/*
* ibnex_map_fault
* IOC drivers need not map memory. Return failure to fail any
* such calls.
*/
/*ARGSUSED*/
static int
{
return (DDI_FAILURE);
}
/*
* ibnex_busctl
* bus_ctl bus_ops entry point
*/
/*ARGSUSED*/
static int
{
IBTF_DPRINTF_L4("ibnex",
switch (ctlop) {
case DDI_CTLOPS_REPORTDEV:
return (DDI_FAILURE);
}
/* Log the relevant details of dip to sysbuf */
return (DDI_SUCCESS);
case DDI_CTLOPS_INITCHILD:
return (ibnex_init_child(child_dip));
case DDI_CTLOPS_UNINITCHILD:
return (DDI_SUCCESS);
case DDI_CTLOPS_ATTACH:
case DDI_CTLOPS_DETACH:
case DDI_CTLOPS_POWER :
return (DDI_SUCCESS);
case DDI_CTLOPS_SIDDEV:
/*
* DDI_FAILURE for the nodes enumerated by a Pseudo file.
*/
return (ndi_dev_is_persistent_node(rdip) ?
case DDI_CTLOPS_IOMIN:
/*
* Return DDI_SUCCESS, so that consistent buf alloc
* gets the default DMA IO minimum for the platform
*/
return (DDI_SUCCESS);
/*
* These ops correspond to functions that "shouldn't" be
* called by IB Nexus driver.
*/
case DDI_CTLOPS_DMAPMAPC:
case DDI_CTLOPS_REPORTINT:
case DDI_CTLOPS_REGSIZE:
case DDI_CTLOPS_NREGS:
case DDI_CTLOPS_SLAVEONLY:
case DDI_CTLOPS_AFFINITY:
case DDI_CTLOPS_POKE:
case DDI_CTLOPS_PEEK:
IBTF_DPRINTF_L2("ibnex",
"%s%d: invalid op (%d) from %s inst%d",
return (DDI_FAILURE);
/*
* Everything else (PTOB/BTOP/BTOPR/DVMAPAGESIZE requests) we
* pass up
*/
default:
}
}
/*
* ibnex_init_child()
*
* Initialize a child device node. This is called for the DDI_CTLOPS_INITCHILD
* entry. Function returns DDI_SUCCESS, DDI_FAILURE or DDI_NOT_WELL_FORMED.
*/
static int
{
int ret;
char name[MAXNAMELEN];
/* Handle Pseudo nodes of client children */
if (ndi_dev_is_persistent_node(child) == 0) {
/* Skip nodes without ib-node-type="merge" */
return (DDI_FAILURE);
return (DDI_FAILURE);
/*
* Merge the .conf node
*/
if (ndi_merge_node(child,
ibnex_name_child) == DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_NOT_WELL_FORMED);
}
return (ret);
return (DDI_SUCCESS);
}
int
{
char **unit_addr;
uint_t n;
IBTF_DPRINTF_L4("ibnex",
"\tname_pseudo_child: cannot find unit-address in %s.conf",
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*ARGSUSED*/
int
{
if (node_datap == NULL) {
return (DDI_NOT_WELL_FORMED);
}
switch (node_datap->node_type) {
case IBNEX_PORT_COMMSVC_NODE:
break;
case IBNEX_VPPA_COMMSVC_NODE:
break;
break;
case IBNEX_IOC_NODE:
break;
case IBNEX_PSEUDO_NODE:
break;
default:
return (DDI_NOT_WELL_FORMED);
}
return (DDI_SUCCESS);
}
/*
* ibnex_bus_config()
*
* BUS_CONFIG_ONE:
* Enumerate the exact instance of the driver. Use the device node name
* to locate the exact instance.
* Query IBDM to find whether the hardware exits for the instance of the
* driver. If exists, create a device node and return NDI_SUCCESS.
*
* BUS_CONFIG_ALL:
* Enumerate all the instances of all the possible children (seen before
* and never seen before).
*
* BUS_CONFIG_DRIVER:
* Enumerate all the instances of a particular driver.
*/
static int
{
char *device_name1;
int use_mdi_devi_locking = 0;
/* Set use_mdi_devi_locking appropriately */
use_mdi_devi_locking = 1;
}
if (use_mdi_devi_locking)
else
switch (op) {
case BUS_CONFIG_ONE:
"parent %p", parent);
if (use_mdi_devi_locking)
else
return (NDI_FAILURE);
}
/*
* i_ddi_parse_name() strips of the address portion
* of the device name. Recreate device name for
* ndi_devi_findchild
*/
IBTF_DPRINTF_L4("ibnex",
/* Node is not present */
if (use_mdi_devi_locking)
else
if (!need_bus_config) {
return (ret);
}
if (use_mdi_devi_locking)
else
IBNEX_IBPORT_CNAME, 6) == 0) &&
if (cdip)
ret = IBNEX_SUCCESS;
else
ret = IBNEX_FAILURE;
} else {
/*
* if not IOC or PORT device then always
* assume a Pseudo child
*
* if IB Nexus is the parent, call MDI.
* else if HCA is the parent, enumerate
* the Pseudo node.
*/
ret = IBNEX_SUCCESS;
if (use_mdi_devi_locking)
else
caddr);
return (ret);
}
}
}
/* Allows enumeration under PHCI */
flag |= NDI_MDI_FALLBACK;
}
break;
case BUS_CONFIG_OBP_ARGS:
if (cdip) {
/*
* Boot case.
* Special handling because the "devname"
* format for the enumerated device is
* different.
*/
srvname =
"ibport@%x,%x,%s",
}
} else {
IBTF_DPRINTF_L2("ibnex",
"\tbus_config: CONFIG_OBP_ARGS : invalid state!!");
ret = IBNEX_FAILURE;
}
break;
case BUS_CONFIG_ALL:
/*FALLTHRU*/
case BUS_CONFIG_DRIVER:
if (op == BUS_CONFIG_ALL)
"parent %p", parent);
else
", parent %p", parent);
/*
* No locks to be held while calling mdi_vhci_bus_config()
* ibnex_config_all_children() holds appropriate locks.
*/
if (use_mdi_devi_locking)
else
/*
* Drive CONFIG requests for IB Nexus parent through
* MDI. This is needed to load the HCA drivers in x86 SRP
* boot case.
*
* CONFIG Requests with HCA parent will probe devices using
* ibdm and configure all children.
*/
return (ret);
} else {
if (use_mdi_devi_locking)
else
}
break;
default:
ret = IBNEX_FAILURE;
break;
}
if (use_mdi_devi_locking)
else
if (ret == IBNEX_SUCCESS) {
if (op == BUS_CONFIG_OBP_ARGS)
op = BUS_CONFIG_ONE;
"ndi_busop_bus_config : retval %d", ret);
return (ret);
}
return (NDI_FAILURE);
}
/*
* ibnex_config_root_iocnode()
* Configures one particular instance of the IOC driver.
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
char *portstr;
IBTF_DPRINTF_L4("ibnex",
"\tconfig_root_iocnode: name %s", device_name);
return (IBNEX_FAILURE);
}
return (IBNEX_FAILURE);
}
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tconfig_root_iocnode: Port does not exist");
return (IBNEX_FAILURE);
}
/* Wait until "port is up" */
if ((port_attr = ibdm_ibnex_probe_hcaport(
return (IBNEX_FAILURE);
}
if (iter++ == 400) {
}
}
}
"Port is initialized");
return (IBNEX_FAILURE);
}
ret = IBNEX_SUCCESS;
} else
parent);
return (ret);
}
static int
{
char *temp;
int ret = IBNEX_FAILURE;
temp++;
}
return (ret);
}
/*
* ibnex_config_all_children()
* Wait for lata SM initialization case before enumerating the nodes
* Get list of HCA's and HCA port information
* Create device device nodes and its node properties
* for port nodes and VPPA nodes
* Get list of all the IOC node information
* Create device nodes and its properties for all the IOCs
* if not created already
* Bind drivers for all the newly created device nodes
* Support Pseudo nodes enumerated using their .conf file
*/
static void
{
int ii;
int circ;
/*
* Enumerate children of this HCA, port nodes,
* VPPA & HCA_SVC nodes. Use ndi_devi_enter() for
* locking. IB Nexus is enumerating the children
* of HCA, not MPXIO clients.
*/
if (wait_time) {
}
return;
}
}
/*
* Use mdi_devi_enter() for locking. IB Nexus is
* enumerating MPXIO clients.
*/
/* Enumerate all the IOC's */
0, &ibnex_port_settling_time);
if (wait_time)
while (ioc_list) {
if (ibnex_is_ioc_present(
(void) ibnex_ioc_initnode(ioc_list,
}
}
/* Config IBTF Pseudo clients */
}
/*
* ibnex_create_port_nodes:
* Creates a device node per each communication service defined
* in the "port-commsvc-list" property per HCA port
*/
static void
{
int idx;
int rval;
if (rval != IBNEX_SUCCESS) {
IBNEX_PORT_COMMSVC_NODE, 0, &rval,
}
}
}
/*
* ibnex_create_vppa_nodes:
* Creates a device node per each communication service defined
* in the "vppa-commsvc-list" property and per each PKEY that
* this particular port supports and per HCA port
*/
static void
{
int rval;
return;
}
if (IBNEX_INVALID_PKEY(pkey)) {
continue;
}
if (rval != IBNEX_SUCCESS) {
"commsvc_initnode failed rval %x", rval);
}
}
}
}
/*
* ibnex_create_hcasvc_nodes:
* Creates a device node per each communication service defined
* in the "port-commsvc-list" property per HCA port
*/
static void
{
int idx;
int rval;
if (rval != IBNEX_SUCCESS) {
"commsvc_initnode failed, rval %x", rval);
}
}
}
/*
* ibnex_is_ioc_present()
* Returns IBNEX_SUCCESS if an entry found in the global linked list
* Returns IBNEX_FAILURE, if no match found
*/
static int
{
int ret = IBNEX_FAILURE;
while (head) {
break;
}
if (head)
ret = IBNEX_SUCCESS;
return (ret);
}
/*
* ibnex_bus_unconfig()
*
* Unconfigure a particular device node or all instance of a device
* driver device or all children of IBnex
*/
static int
{
}
/*
* ibnex_config_port_node()
*
* Configures a particular port / HCA node for a particular
* communication service.
* The format of the device_name is
* ibport@<Port#>,<pkey>,<service name>
* where pkey = 0 for port communication service nodes
* Port# = 0 for HCA_SVC communication service nodes
* Returns "dev_info_t" of the "child" node just created
* NULL when failed to enumerate the child node
*/
static dev_info_t *
{
int rval;
IBTF_DPRINTF_L2("ibnex",
"\tconfig_port_node: Invalid Service Name");
return (NULL);
}
if (port_num == 0) {
/*
* Use the dummy port attribute for HCA node in hca_list
* Note : pa_state is always IBT_PORT_ACTIVE.
*/
} else {
if ((port_attr = ibdm_ibnex_probe_hcaport(
IBTF_DPRINTF_L2("ibnex",
"\tconfig_port_node: Port does not exist");
return (NULL);
}
if (wait_time) {
}
if ((port_attr = ibdm_ibnex_probe_hcaport(
return (NULL);
}
}
}
&cdip)) == IBNEX_SUCCESS) {
if (port_num != 0)
else
return (cdip);
}
IBTF_DPRINTF_L5("ibnex",
"\t ibnex_commsvc_initnode rval %x", rval);
IBTF_DPRINTF_L5("ibnex",
"\t ibnex_commsvc_initnode rval %x", rval);
} else {
return (NULL);
}
IBTF_DPRINTF_L5("ibnex",
"\t ibnex_commsvc_initnode rval %x", rval);
break;
}
}
}
if (port_num != 0)
else
return (cdip);
}
/*
* ibnex_config_obp_args()
* Configures a particular port node for a IP over IB communication
* service.
* The format of the input string "devname" is
* port=x,pkey=y,protocol=ip,<wanboot options>
* Thr format of the node name created here is
* ibport@<Port#>,<pkey>,<service name>
* where pkey = 0 for port communication service nodes
* Returns "dev_info_t" of the "child" node just created
* NULL when failed to enumerate the child node
*
*/
static dev_info_t *
{
char *temp;
/* Is this OBP node for IPoIB ? */
do {
break;
break;
} else {
break;
}
temp++;
} while (temp);
return (NULL);
return (NULL);
}
"ipib") == 0) {
break;
}
}
if ((port_attr = ibdm_ibnex_probe_hcaport(
IBTF_DPRINTF_L2("ibnex",
"\tconfig_port_node: Port does not exist");
return (NULL);
}
/* Wait until "port is up" */
if ((port_attr = ibdm_ibnex_probe_hcaport(
return (NULL);
}
if (iter++ == 400) {
}
}
}
&cdip)) == IBNEX_SUCCESS) {
return (cdip);
}
IBTF_DPRINTF_L5("ibnex",
"\t ibnex_commsvc_initnode rval %x", rval);
break;
}
}
return (cdip);
}
/*
* ibnex_prom_devname_to_pkey_n_portnum()
* Parses the device node name and extracts "PKEY" and "port#"
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
int ret = IBNEX_SUCCESS;
} else
ret = IBNEX_FAILURE;
if ((ret == IBNEX_SUCCESS) &&
} else
ret = IBNEX_FAILURE;
return (ret);
}
/*
* ibnex_get_pkey_commsvc_index_portnum()
* Parses the device node name and extracts PKEY, communication
* service index & Port #.
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
IBTF_DPRINTF_L2("ibnex",
"\tget_pkey_commsvc_index_portnum: Invalid PortGuid");
return (NULL);
}
if (srv == 0)
return (IBNEX_FAILURE);
srv++;
if (temp == 0)
return (IBNEX_FAILURE);
temp++;
if (ret != IBNEX_SUCCESS)
return (ret);
} else {
}
break;
}
}
return (IBNEX_FAILURE);
return (IBNEX_SUCCESS);
}
/*
* ibnex_devname_to_portnum()
* Get portguid from device name
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
int ret;
return (IBNEX_FAILURE);
}
return (IBNEX_FAILURE);
temp1++;
return (ret);
}
/*
* ibnex_config_ioc_node()
* Configures one particular instance of the IOC driver.
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
int ret;
return (IBNEX_FAILURE);
}
if (wait_time)
NULL) {
return (IBNEX_FAILURE);
}
ret = IBNEX_SUCCESS;
} else
pdip);
return (ret);
}
/*
* ibnex_devname_to_node_n_ioc_guids()
* Get node guid and ioc guid from the device name
* Format of the device node name is:
* ioc@<IOC GUID>,<IOU GUID>
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
char **ioc_guid_strp)
{
char *ioc_guid_str;
"Device Name %s", device_name);
return (IBNEX_FAILURE);
}
return (IBNEX_FAILURE);
}
if (ret == IBNEX_SUCCESS) {
if (ioc_guid_strp) {
}
}
return (ret);
}
/*ARGSUSED*/
/*
* ibnex_ioc_initnode()
* Allocate a pathinfo node for the IOC
* Initialize the device node
* Bind driver to the node
* Update IBnex global data
* Returns IBNEX_SUCCESS/IBNEX_FAILURE/IBNEX_BUSY
*/
int
{
int rval;
(void *)ioc_info, 0, 0);
/*
* prevent any races
* we have seen this node_data and it has been initialized
* Note that node_dip is already NULL if unconfigure is in
* progress.
*/
ioc_info, 0, 0);
}
/*
* Return EBUSY if another configure/unconfigure
* operation is in progress
*/
return (IBNEX_BUSY);
}
if (rval == IBNEX_SUCCESS)
return (rval);
}
/*
* ibnex_config_pseudo_all()
* Configure all the pseudo nodes
*/
static void
{
}
}
/*
* ibnex_pseudo_config_one()
*/
static int
{
int rval;
caddr);
/*
* This function is now called with PHCI / HCA driver
* as parent. The format of devicename is :
* <driver_name>@<driver_name>,<unit_address>
* The "caddr" part of the devicename matches the
* format of pseudo_node_addr.
*
* Use "caddr" to find a matching Pseudo node entry.
*/
(void *)caddr, 0, 0);
}
/*
* Do not enumerate nodes with ib-node-type set as "merge"
*/
== 1) {
return (IBNEX_FAILURE);
}
/*
* prevent any races
* we have seen this node_data and it has been initialized
* Note that node_dip is already NULL if unconfigure is in
* progress.
*/
return (IBNEX_FAILURE);
}
/*
* Return EBUSY if another configure/unconfigure
* operation is in progress
*/
return (IBNEX_BUSY);
}
return (IBNEX_SUCCESS);
/*
* Prevent configuring pseudo nodes specifically unconfigured
* by cfgadm. This is done by checking if this is a newly
* created node, not yet configured by BUS_CONFIG or cfgadm
*/
return (IBNEX_FAILURE);
if (rval == IBNEX_SUCCESS)
else {
}
return (rval);
}
/*
* ibnex_pseudo_mdi_config_one()
* This is similar to ibnex_pseudo_config_one. Few
* differences :
* 1. parent device lock not held(no ndi_devi_enter)
* 2. Called for IB Nexus as parent, not IB HCA as
* parent.
* 3. Calls mdi_vhci_bus_config()
* This function skips checks for node_state, initializing
* node_state, node_dip, etc. These checks and initializations
* are done when BUS_CONFIG is called with PHCI as the parent.
*/
static int
{
char *node_addr;
(void *)node_addr, 0, 0);
IBTF_DPRINTF_L2("ibnex",
"\tpseudo_mdi_config_one: Invalid node");
return (IBNEX_FAILURE);
}
return (rval);
}
/*
* ibnex_pseudo_create_pi()
* Create a path info node for each pseudo entry
*/
int
{
/*
* For CONFIG_ONE requests through HCA dip, alloc
* for HCA dip driving BUS_CONFIG request.
*/
continue;
if (rval != MDI_SUCCESS) {
(void) ibnex_offline_childdip(cdip);
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L4("ibnex",
"\tpseudo_create_pi: New dip %p", cdip);
if (rval != MDI_SUCCESS) {
"mdi_pi_online: failed for pseudo dip %p,"
(void) ibnex_offline_childdip(cdip);
break;
} else
break;
}
if (head)
return (rval);
}
/*
* ibnex_ioc_create_pi()
* Create a pathinfo node for the ioc node
*/
static int
{
int rval = DDI_FAILURE;
int flag = 1;
/*
* For CONFIG_ONE requests through HCA dip, alloc
* for HCA dip driving BUS_CONFIG request.
*/
continue;
if (rval != MDI_SUCCESS) {
(void) ibnex_offline_childdip(cdip);
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L4("ibnex",
"\tioc_create_pi: New IOC dip %p", cdip);
if (flag) {
if ((rval = ibnex_create_ioc_node_prop(
(void) ibnex_offline_childdip(cdip);
return (IBNEX_FAILURE);
}
flag = 0;
}
if (rval != MDI_SUCCESS) {
"mdi_pi_online() failed ioc dip %p, rval %d",
(void) ibnex_offline_childdip(cdip);
break;
} else
break;
}
return (rval);
}
/*
* ibnex_create_ioc_node_prop()
* Create IOC device node properties
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
ioc_profile) != IBNEX_SUCCESS) {
return (IBNEX_FAILURE);
}
if ((ioc_info->ioc_iou_dc_valid) &&
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: iou-diagcode create failed");
return (IBNEX_FAILURE);
}
"ioc-diagcode create failed");
return (IBNEX_FAILURE);
}
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: rdma-queue-depth create failed");
return (IBNEX_FAILURE);
}
"rdma-transfer-size create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: send-message-size create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: send-queue-depth create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: capabilities create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: id-string failed");
return (IBNEX_FAILURE);
}
/*
* Create properties to represent all the service entries supported
* by the IOC. Each service entry consists of 1) Service ID (64 bits)
* and 2) Service name (40 bytes). The service entry table is
* represented by two properties, service-ids and service-names. The
* service-id property is a array of int64's and service names is
* array of strings. The first element in the "service-ids" property
* corresponds to first string in the "service-names" and so on.
*/
if ((ioc_profile->ioc_service_entries != 0) &&
return (IBNEX_FAILURE);
/* Create destination port GID properties */
return (IBNEX_FAILURE);
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: protocol-version create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: protocol create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: subclass create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: class prop create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: subsys_id create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: subsystem vendor create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: protocol create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: product-id create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: product-id create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_node_prop: vendor-id create failed");
return (IBNEX_FAILURE);
}
return (IBNEX_SUCCESS);
}
/*
* ibnex_create_ioc_portgid_prop()
* Creates "port-entries", "port-list" properties
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
int prop_len;
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_portgid_prop: port-list create failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_portgid_prop: port-entries create failed");
return (IBNEX_FAILURE);
}
return (IBNEX_SUCCESS);
}
/*
* ibnex_create_ioc_srv_props()
* Creates "service-name" and "service-id" properties
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
}
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_srv_props: service-id create failed");
return (IBNEX_FAILURE);
}
"service-name", (char **)srv_names,
IBTF_DPRINTF_L2("ibnex",
"\tcreate_ioc_srv_props: service-name create failed");
return (IBNEX_FAILURE);
}
return (IBNEX_SUCCESS);
}
/*
* ibnex_create_ioc_compatible_prop()
* Creates "compatible" property values
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
char *temp;
char *compatible[IBNEX_MAX_COMPAT_NAMES];
/*
* Initialize the "compatible" property string as below:
* Compatible Strings :
* 1. ib.V<vid>P<pid>S<subsys vid>s<subsys id>v<ver>
* 2. ib.V<vid>P<pid>S<subsys vid>s<subsys id>
* 3. ib.V<vid>P<pid>v<ver>
* 4. ib.V<vid>P<pid>
* 5. ib.C<Class>c<Subclass>p<protocol>r<protocol ver>
* 6. ib.C<Class>c<Subclass>p<protocol>
*
* Note:
* All leading zeros must be present
* All numeric values must specified in hex without prefix "0x"
*/
"ib.V%06xP%08xS%06xs%08xv%04x",
"ib.V%06xP%08xS%06xs%08x",
"ib.V%06xP%08xv%04x",
"ib.V%06xP%08x",
"ib.C%04xc%04xp%04xr%04x",
"ib.C%04xc%04xp%04x",
/* Create the compatible property for child cdip */
if (rval != DDI_PROP_SUCCESS) {
return (IBNEX_FAILURE);
}
return (IBNEX_SUCCESS);
}
static void
{
}
}
/*
* ibnex_delete_ioc_node_data()
* Delete IOC node from the list
*/
static void
{
} else {
}
}
/*
* ibnex_dm_callback()
*
* This routine is registered with the IBDM during IB nexus attach. It
* is called by the IBDM module when it discovers
* New HCA port
* HCA port removal
* New HCA added
* HCA removed
*/
void
{
char hca_guid[IBNEX_HCAGUID_STRSZ];
switch (flag) {
case IBDM_EVENT_HCA_ADDED:
(*(longlong_t *)arg));
/* Create a devctl minor node for the HCA's port */
DDI_NT_IB_ATTACHMENT_POINT, 0) != DDI_SUCCESS) {
"create minor node for port w/ guid %s", hca_guid);
}
break;
case IBDM_EVENT_HCA_REMOVED:
(*(longlong_t *)arg));
break;
break;
while (ioc_list) {
if ((node_data = ibnex_is_node_data_present(
}
}
}
}
/*
* ibnex_get_dip_from_guid()
*
* Searches the linked list of the port nodes and returns the dip for
* the of the Port / Node guid requested.
* Returns NULL if not found
*/
int
dev_info_t **dip)
{
int node_index;
IBTF_DPRINTF_L4("ibnex",
"\tget_dip_from_guid: guid = %llX", guid);
/* Search for a matching entry in internal lists */
while (node_data) {
break;
}
}
/* matching found with a valid dip */
return (IBNEX_SUCCESS);
return (IBNEX_SUCCESS);
}
/* no match found */
return (IBNEX_FAILURE);
}
/*
* ibnex_comm_svc_init()
* Read the property and cache the values in the global
* structure.
* Check for max allowed length (4 bytes) of service name
* (each element of the property)
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static ibnex_rval_t
{
int ncomm_svcs;
char **comm_svcp;
/* lookup the string array property */
return (IBNEX_SUCCESS);
}
if (nservices)
/* first read the file to get a count of valid service entries */
int j;
"Service name %s invalid : length %d",
continue;
}
"Service name %s invalid : Not unique",
continue;
}
/*
* ibnex_unique_svcname checks for uniqueness in service names
* communication services fully initialized. Check uniqueness
* in service names currently initialized.
*/
for (j = 0; j < count; j++)
servicep[j], 4) == 0) {
"Service name %s invalid : Not unique",
continue;
}
ncomm_svcs++;
}
/* if no valid entries found, bailout */
if (nservices == 0 || ncomm_svcs == 0) {
if (valid)
return (IBNEX_SUCCESS);
}
if (type == IBNEX_PORT_COMMSVC_NODE) {
} else if (type == IBNEX_VPPA_COMMSVC_NODE) {
} else if (type == IBNEX_HCASVC_COMMSVC_NODE) {
}
/* copy the services into an array of strings */
continue;
IBTF_DPRINTF_L4("ibnex",
"\t\tService [%d]: %s", i, comm_svcp[i]);
++i;
}
return (IBNEX_SUCCESS);
}
/*
* ibnex_comm_svc_fini()
* Deallocate all the memory allocated for the communication
* service arrays.
*/
static void
{
int index;
}
if (ibnex.ibnex_comm_svc_names) {
ibnex.ibnex_num_comm_svcs * sizeof (char *));
}
}
if (ibnex.ibnex_vppa_comm_svc_names) {
ibnex.ibnex_nvppa_comm_svcs * sizeof (char *));
}
}
if (ibnex.ibnex_hcasvc_comm_svc_names) {
ibnex.ibnex_nhcasvc_comm_svcs * sizeof (char *));
}
ibnex.ibnex_num_comm_svcs = 0;
}
/*
* ibnex_commsvc_initnode()
* Creates a device node for the comm service specified by commsvc_index
* Creates all the device node properties
* Allocates and initializes the node specific data
* Binds the device driver of the device node
* Returns "dev_info_t" of the child node or NULL in case of failure
* Sets IBNEX_SUCCESS/IBNEX_FAILURE/IBNEX_BUSY in "rval" to reflect
* if the operation was successful, failed or was not performed.
*/
{
int ret;
char *svcname;
*rval = IBNEX_SUCCESS;
/*
* prevent any races
* we have seen this node_data and it has been initialized
* Note that node_dip is already NULL if unconfigure is in
* progress.
*/
/*
* Return NULL if another configure
* operation is in progress
*/
*rval = IBNEX_BUSY;
return (NULL);
} else {
}
/* allocate a new ibnex_node_data_t */
}
/*
* Return NULL if another unconfigure operation is in progress
*/
*rval = IBNEX_BUSY;
return (NULL);
}
switch (node_type) {
case IBNEX_VPPA_COMMSVC_NODE :
break;
case IBNEX_HCASVC_COMMSVC_NODE :
break;
case IBNEX_PORT_COMMSVC_NODE :
break;
default :
"\tInvalid Node type");
*rval = IBNEX_FAILURE;
(void) ndi_devi_free(cdip);
return (NULL);
}
if (flag == IBNEX_DEVFS_ENUMERATE)
else
if (ret == NDI_SUCCESS) {
return (cdip);
}
}
*rval = IBNEX_FAILURE;
(void) ndi_devi_free(cdip);
return (NULL);
}
/*
* ibnex_create_port_node_prop()
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: compatible update failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: port-num update failed");
return (IBNEX_FAILURE);
}
/*
* For HCA_SVC device nodes, port_num will be 0.
* Do not create the "port-number" & "port-guid" properties.
*/
if (port_attr->pa_port_num != 0) {
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: port-num update failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: port-guid update failed");
return (IBNEX_FAILURE);
}
} else {
/*
* HCA_SVC nodes require "num-ports" & "port-guids"
* properties.
*
* To create the num-ports & port-guids attribute :
* 1. Get HCA list (ibdm_ibnex_get_hca_info_by_guid)
* 2. Form the array of port GUIDs.
*/
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: hca_info_by_guid failed");
return (IBNEX_FAILURE);
}
KM_SLEEP);
portnum++) {
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: port-guids "
"create failed");
sizeof (ib_guid_t));
return (IBNEX_FAILURE);
}
sizeof (ib_guid_t));
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: num-ports update failed");
return (IBNEX_FAILURE);
}
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: hca-guid update failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: product-id update failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: vendor-id update failed");
return (IBNEX_FAILURE);
}
IBTF_DPRINTF_L2("ibnex",
"\tcreate_port_node_prop: device-version update failed");
return (IBNEX_FAILURE);
}
return (IBNEX_SUCCESS);
}
/*
* ibnex_str2int()
* Utility function that converts a string of length "len" to
* integer.
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
*ret = IBNEX_SUCCESS;
else {
IBTF_DPRINTF_L2("ibnex",
"\tstr2int: Invalid integer string %s..", c);
*ret = IBNEX_FAILURE;
break;
}
}
return (intval);
}
/*
* ibnex_str2hex()
* Utility functions that converts a string of length "len" to
* hex value. Note. This function does not handle strings which
* string length more than 8 bytes.
*
*/
{
*ret = IBNEX_SUCCESS;
else {
IBTF_DPRINTF_L2("ibnex",
"\tstr2hex: Invalid integer string");
*ret = IBNEX_FAILURE;
break;
}
}
return (hex);
}
/*
* ibnex_create_port_compatible_prop()
* Creates 'Compatibility' property for port / HCA_SVC device nodes
* Returns IBNEX_SUCCESS/IBNEX_FAILURE
*/
static int
{
int rval, i;
char *temp;
/*
* Initialize the "compatible" property string as below:
* Compatible Strings :
* 1. ib.V<vid>P<pid>v<revision>.<service name>.
* 2. ib.V<vid>P<pid>.<service name>.
* 3. ib.<service name>
* Leading zeros must be present
*/
for (i = 0; i < IBNEX_MAX_IBPORT_COMPAT_NAMES; i++) {
}
"ib.V%06xP%08xv%04x.%s",
"ib.V%06xP%08x.%s",
"ib.%s", comm_svcp);
for (i = 0; i < IBNEX_MAX_IBPORT_COMPAT_NAMES; i++)
if (rval != DDI_PROP_SUCCESS) {
return (IBNEX_FAILURE);
}
return (IBNEX_SUCCESS);
}
/*
* ibnex_delete_port_node_data()
* Delete the parent private node data from the linked list
* Deallocate the memory of the node data
*/
static void
{
} else {
}
}
/*
* ibnex_is_node_data_present()
* Checks whether ibnex_node_t is created already
* Returns ibnex_node_data_t if found, otherwise NULL
*/
static ibnex_node_data_t *
{
if (node_type == IBNEX_IOC_NODE) {
return (nodep);
}
}
} else if (node_type == IBNEX_PSEUDO_NODE) {
pseudo_node_addr, (char *)attr) == 0)
return (nodep);
} else {
pattrp->pa_port_guid) &&
index) &&
return (nodep);
}
}
}
return (NULL);
}
/*
* ibnex_lookup_unit_address_prop:
*
* If property with name is found, return its value
* otherwise return NULL.
*/
static char *
{
/* Search the list of properties for name */
continue;
/* named property should be valid and have a value */
break;
}
return ((char *)0);
}
/*
* ibnex_pseudo_initnodes()
* This routine is specific to pseudo node information handling
* Creates a ibnex_node_data_t all pseudo nodes children of ibnex
*/
void
{
char *node_type;
/*
* get a list of all "pseudo" children of "ib".
* for these children initialize/allocate an internal
* ibnex_node_data_t.
*/
continue;
/* Check "ib-node-type" property for IOC .conf */
/* "unit-address" property should be present */
continue;
IBNEX_PSEUDO_NODE, (void *)node_addr, 0, 0);
if (nodep) {
continue;
}
(void *)spec->hwc_devi_name, 0, 0);
/* Mark this as a new psuedo node */
}
}
/*
* ibnex_init_child_nodedata()
*
* Allocate memory for the parent private data for device node
* Initializes the parent private child device node data.
* Returns pointer to the parent private data
*/
static ibnex_node_data_t *
{
char *devi_name;
if (node_type == IBNEX_IOC_NODE) {
(char *)ioc_profile->ioc_id_string,
if (ibnex.ibnex_ioc_node_head)
} else if (node_type == IBNEX_PSEUDO_NODE) {
} else {
}
return (node_data);
}
static int
{
int rc;
if (rc == NDI_SUCCESS) {
}
return (rc);
}
static int
{
IBTF_DPRINTF_L4("ibnex",
"ibnex_add_eventcall(%p, %p, 0x%X, %p, %p, %p)",
}
static int
{
cb_id));
}
static int
{
cookie, bus_impldata));
}
/*
* ibnex_reprobe_ioc_dev()
*
* This could be called as a result of ibt_reprobe_dev request or
* cfgadm command. The function is called from a taskq in case of
* ibt_reprobe_dev and from user context for cfgadm command.
*
* This function reprobes the properties for one IOC dip.
*
* node_reprobe_state should be set before calling this function.
*/
void
ibnex_reprobe_ioc_dev(void *arg)
{
/* ASSERT(NO_LOCKS_HELD); */
return;
}
/* Reprobe the IOC */
1);
return;
}
}
/*
* ibnex_reprobe_all()
*
* This could be called as a result of cfgadm command. The function
* is called from user context.
*
* This function reprobes the properties for all IOC dips.
*
* ibnex_reprobe_state should be set before calling this function.
*/
void
{
/* ASSERT(NO_LOCKS_HELD); */
/* Sweep the fabric */
if (ioc_info_list == NULL) {
return;
}
while (ioc_info_list) {
ioc_info_list, 0, 0)) != NULL &&
}
}
}
/*
* Update the properties, if it has modified and notify IBTF client.
*/
static void
{
/*
* For a disconnected IOC :
* Store the ioc_profile for supplying cfgadm info
* ibdm maintains no info of disconnected IOC
*
* For reconnected IOC :
* ibdm has info of previous service entries
* ioc_profile maintained by ibnexus is used to
* update ib_srv_prop_updated.
* Free the ibnex maintained ioc_profile
*/
if (ioc_info->ioc_nportgids == 0) {
IBTF_DPRINTF_L4("ibnex",
"\tupdate_prop: IOC disconnected");
sizeof (ib_dm_ioc_ctrl_profile_t), KM_SLEEP);
sizeof (ib_dm_ioc_ctrl_profile_t));
IBTF_DPRINTF_L4("ibnex",
"\tupdate_prop: IOC reconnected");
}
/* Update the properties that have changed */
if (evt_data.ib_gid_prop_updated) {
return;
}
}
if (evt_data.ib_srv_prop_updated) {
IBNEX_SUCCESS)) {
return;
"service-id");
"service-name");
}
}
/*
* Post an event if :
* 1. Properites have changed or NOTIFY_ALWAYS is set.
* 2. child dip is configured and a valid cookie for
* IB_PROP_UPDATE_EVENT.
*/
if ((evt_data.ib_prop_updated != 0 ||
(evt_cookie != NULL))) {
IBTF_DPRINTF_L2("ibnex",
"\tndi_post_event failed\n");
}
/*
* Cleanup node_reprobe_state, for ibt_reprobe_dev
* requests, when reprobe all / node reprobe is in
* progress. ibnex_reprobe_ioc_dev is not called
* in this case.
*/
if (node_data->node_reprobe_state ==
}
static ibnex_rval_t
ibnex_unique_svcname(char *svcname)
{
int i;
/* Check Port Services */
for (i = 0; i < ibnex.ibnex_num_comm_svcs; i++)
return (IBNEX_FAILURE);
/* Check VPPA Services */
for (i = 0; i < ibnex.ibnex_nvppa_comm_svcs; i++)
return (IBNEX_FAILURE);
/* Check HCA_SVC Services */
for (i = 0; i < ibnex.ibnex_nhcasvc_comm_svcs; i++)
return (IBNEX_FAILURE);
return (IBNEX_SUCCESS);
}
static void
ibnex_handle_reprobe_dev(void *arg)
{
/*
* Return success if:
* 1. Reprobe for all nodes are in progress
* 2. Reprobe for this node is in progress.
* The reprobe in progress will complete eventually and
* update the properties, if required.
*/
if (ibnex.ibnex_reprobe_state != 0 ||
node_data->node_reprobe_state != 0) {
/*
* Setting NOTIFY_ALWAYS to ensure that
* DDI event is delivered always for
* ibt_reprobe_dev
*/
return;
}
}
/*
* MPxIO pathmangement routines. Currently IB nexus does not support
* any kind of pathmangement. So, just return success to make MPxIO
* framework happy.
*/
/*ARGSUSED*/
static int
{
return (MDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (MDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
IBTF_DPRINTF_L4("ibnex",
return (MDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (MDI_SUCCESS);
}
static int
{
int ret = DDI_SUCCESS;
/*
* Generic processing in MPxIO framework
*/
switch (ret) {
case MDI_SUCCESS:
ret = DDI_SUCCESS;
break;
case MDI_FAILURE:
ret = DDI_FAILURE;
break;
default:
break;
}
return (ret);
}
/*
* If enumerated as a child of IB Nexus / VHCI, call mdi_vhci_bus_config.
* ndi_devi_enter is not held during this call. mdi_vhci_bus_config()
* will have called ndi_busop_bus_config(), no need for the caller to call
* ndi_busop_bus_config() again.
*
* If enumerated as a child of HCA device, this could be a case for
* Sparc boot or device enumeration from PHCI, driven by MDI.
* Hold parent lock (ndi_devi_enter). The caller will have to call
* ndi_busop_bus_config() if this function returns SUCCESS.
*
* if the device name contains ":port", then it is the Sparc boot case.
* Handle this as before.
*
* If the device name does *not* contain the ":port", then :
* 1. ibdm to probe IOC
* 2. Create a pathinfo only if the IOC is reachable from the parent dip.
*/
static int
int *need_bus_config)
{
char *ioc_guid_str;
*need_bus_config = 1;
&ioc_guid_str) != IBNEX_SUCCESS) {
return (ret);
}
if (ret == MDI_SUCCESS)
*need_bus_config = 0;
} else {
} else {
}
}
return (ret);
}
static int
{
char *node;
int ret = IBNEX_INVALID_NODE;
return (IBNEX_FAILURE);
}
ret = IBNEX_SUCCESS;
else {
IBTF_DPRINTF_L4("ibnex",
"\tis_merge_node: ib-node-type = %s", node);
}
}
return (ret);
}
/*
* Checks if the dn_head for the driver has already
* initialized by the prom tree.
*/
void
ibnex_hw_in_dev_tree(char *driver_name)
{
return;
if (major == -1)
return;
}