cfga_list.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "cfga_scsi.h"
/* Structure for walking the tree */
typedef struct {
char *hba_logp;
int l_errno;
} scfga_list_t;
typedef struct {
const char *ntype;
const char *name;
/* The TYPE field is parseable and should not contain spaces */
#define SCFGA_BUS_TYPE "scsi-bus"
/* Function prototypes */
static char *get_device_type(di_node_t);
static scfga_devtype_t device_list[] = {
};
ldata_list_t **llpp,
int *nelemp,
char **errstring)
{
walkarg_t u;
int init_flag;
return (SCFGA_ERR);
}
/* Create the HBA logid (also base component of logical ap_id) */
return (SCFGA_ERR);
}
/*
* For all list commands, the bus and 1 or more devices
* needs to be stat'ed
*/
/*
* By default we use DINFOCACHE to get a "full" snapshot
* This much faster than DINFOFORCE which actually
* attaches devices. DINFOFORCE used only if caller
* explicitly requests it via a private option.
*/
limited_bus_stat = 0;
case SCFGA_STAT_DEV:
/*FALLTHRU*/
case SCFGA_STAT_ALL:
break;
case SCFGA_STAT_BUS:
/* limited_bus_stat = 0 and no DINFOCACHE/DINFOFORCE */
init_flag = 0;
break;
default:
goto out;
}
/*
* DINFOCACHE implies DINFOCPYALL. DINFOCPYALL shouldn't
* be ORed with DINFOCACHE, else libdevinfo will return
* error
*/
if (init_flag != DINFOCACHE)
init_flag |= DINFOCPYALL;
goto out;
}
#ifdef DEBUG
if (limited_bus_stat) {
} else {
}
#endif
/* Assume that the bus has no configured children */
/*
* If stat'ing a specific device, we don't know if it exists yet.
* If stat'ing a bus or a bus and child devices, we have at least the
* bus stat data at this point.
*/
} else {
}
/* we need to stat at least 1 device for all commands */
/*
* Subtree is ALWAYS rooted at the HBA (not at the device) as
* otherwise deadlock may occur if bus is disconnected.
*/
if (ret != SCFGA_APID_NOEXIST) {
}
goto out;
}
n = 0;
ret = SCFGA_LIB_ERR;
goto out;
}
*nelemp = n;
/* FALLTHROUGH */
out:
return (ret);
}
static scfga_ret_t
const ldata_list_t *listp,
int *np)
{
int i;
*np = 0;
return (SCFGA_ERR);
}
hba_ldatap = NULL;
i++;
/* A bus stat data */
#ifdef DEBUG
} else {
#endif
}
}
switch (cmd) {
case SCFGA_STAT_DEV:
return (SCFGA_LIB_ERR);
}
break;
case SCFGA_STAT_BUS:
return (SCFGA_LIB_ERR);
}
break;
case SCFGA_STAT_ALL:
return (SCFGA_LIB_ERR);
}
break;
default:
return (SCFGA_LIB_ERR);
}
*np = i;
/* Fill in the occupant (child) state. */
if (hba_ldatap != NULL) {
}
return (SCFGA_OK);
}
static int
{
/* Skip stub nodes */
if (IS_STUB_NODE(node)) {
return (DI_WALK_CONTINUE);
}
/* Skip partial nodes */
if (!known_state(node)) {
return (DI_WALK_CONTINUE);
}
goto out;
}
goto out;
}
/* Skip node if it is HBA */
match_minor = 0;
goto out;
}
/* If stat'ing a specific device, is this that device */
goto out;
}
}
/*
* If stat'ing a bus only, we look at device nodes only to get
* bus configuration status. So a limited stat will suffice.
*/
limited_dev_stat = 1;
} else {
limited_dev_stat = 0;
}
/*
* Ignore errors if stat'ing a bus or listing all
*/
} else {
}
goto out;
}
/* Are we done ? */
/*
* If stat'ing a specific device, we are done at this point.
*/
}
/*FALLTHRU*/
out:
return (rv);
}
static scfga_ret_t
{
int l_errno = 0;
uint_t devinfo_state = 0;
walkarg_t u;
/* Get bus state */
} else {
}
if (limited_bus_stat) {
/* We only want to know bus(receptacle) connect status */
return (SCFGA_OK);
}
return (SCFGA_LIB_ERR);
}
/* Link it in */
return (SCFGA_OK);
}
static int
{
return (DI_WALK_TERMINATE);
}
static scfga_ret_t
const char *nodepath,
int limited_dev_stat)
{
uint_t devinfo_state = 0;
/* If child device is configured, record it */
if (ostate == CFGA_STAT_CONFIGURED) {
}
if (limited_dev_stat) {
/* We only want to know device config state */
return (SCFGA_OK);
}
return (SCFGA_LIB_ERR);
}
/* Create the dynamic component */
return (ret);
}
/* Create logical and physical ap_id */
/* Link it in */
return (SCFGA_OK);
}
/* fill in device type, vid, pid from properties */
static void
{
/*
* Fill in type information
*/
}
/*
* Fill in vendor and product ID.
*/
}
}
/*
* Get dtype from "inquiry-device-type" property. If not present,
* derive it from minor node type
*/
static char *
{
int *inq_dtype;
int i;
/* first, derive type based on inquiry property */
&inq_dtype) == 1) {
for (i = 0; i < N_DEVICE_TYPES; i++) {
continue;
break;
}
}
}
/* if property fails, use minor nodetype */
char *nodetype;
if ((minor != DI_MINOR_NIL) &&
for (i = 0; i < N_DEVICE_TYPES; i++) {
if (device_list[i].ntype &&
== 0)) {
break;
}
}
}
}
name = "unknown";
return (name);
}
/* Transform linked list into an array */
ldata_list_t **llpp,
int nelem,
int *nlistp,
char **errstring)
{
int i = -1;
*ap_id_list = NULL;
*nlistp = 0;
return (SCFGA_LIB_ERR);
}
if (nelem == 0) {
return (SCFGA_APID_NOEXIST);
}
return (SCFGA_LIB_ERR);
}
/* Extract the list_data structures from the linked list */
}
return (SCFGA_LIB_ERR);
}
*ap_id_list = ldatap;
return (SCFGA_OK);
}
/*
* Convert bus state to receptacle state
*/
static cfga_stat_t
{
switch (bus_di_state) {
case DI_BUS_QUIESCED:
case DI_BUS_DOWN:
break;
/*
* NOTE: An explicit flag for active should probably be added to
* libdevinfo.
*/
default:
break;
}
return (rs);
}
/*
* Convert device state to occupant state
*/
static cfga_stat_t
{
/* Driver attached ? */
return (CFGA_STAT_CONFIGURED);
}
return (CFGA_STAT_UNCONFIGURED);
} else {
return (CFGA_STAT_NONE);
}
}