sad_conf.c revision 2ea701aa039ac7c64509e62bb4a333fb79e9b069
/*
* 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"
/*
* Config dependent data structures for the Streams Administrative Driver
* (or "Ballad of the SAD Cafe").
*/
#include <sys/sysmacros.h>
/*
* Currently we store all the sad data in a hash table keyed by major
* number. This is far from ideal. It means that if a single device
* starts using lots of SAP_ONE entries all its entries will hash
* to the same bucket and we'll get very long chains for that bucket.
*
* Unfortunately, it's not possible to hash by a different key or to easily
* break up our one hash into seperate hashs. The reason is because
* the hash contains mixed data types. Ie, it has three different
* types of autopush nodes in it: SAP_ALL, SAP_RANGE, SAP_ONE. Not
* only does the hash table contain nodes of different types, but we
* have to be able to search the table with a node of one type that
* might match another node with a different type. (ie, we might search
* for a SAP_ONE node with a value that matches a SAP_ALL node in the
* hash, or vice versa.)
*
* An ideal solution would probably be an AVL tree sorted by major
* numbers. Each node in the AVL tree would have the following optional
* data associated with it:
* - a single SAP_ALL autopush node
* - an or avl tree or hash table of SAP_RANGE and SAP_ONE autopush
* nodes indexed by minor numbers. perhaps two separate tables,
* one for each type of autopush nodes.
*
* Note that regardless of how the data is stored there can't be any overlap
* stored between autopush nodes. For example, if there is a SAP_ALL node
* for a given major number then there can't be any SAP_RANGE or SAP_ONE
* nodes for that same major number.
*/
/*
* Private Internal Interfaces
*/
/*ARGSUSED*/
static uint_t
{
}
/*
* Compare hash keys based off of major, minor, lastminor, and type.
*/
static int
{
/* Filter out cases where the major number doesn't match. */
return (1);
/* If either type is SAP_ALL then we're done. */
return (0);
/* Deal with the case where both types are SAP_ONE. */
/* Check if the minor numbers match. */
}
/* Deal with the case where both types are SAP_RANGE. */
/* Check for overlapping ranges. */
return (1);
return (0);
}
/*
* We know that one type is SAP_ONE and the other is SAP_RANGE.
* So now let's do range matching.
*/
return (1);
} else {
return (1);
}
return (0);
}
/*ARGSUSED*/
static uint_t
{
return (MH_WALK_CONTINUE);
}
/*
* External Interfaces
*/
int
{
/* sanity check the number of modules to push */
return (EINVAL);
/* Check for NODEV major vaule */
return (EINVAL);
case SAP_ALL:
case SAP_ONE:
/*
* Really, we'd like to be strict here and make sure that
* apc_lastminor is 0 (since setting apc_lastminor for
* SAP_ALL and SAP_ONE commands doesn't make any sense),
* but we can't since historically apc_lastminor has been
* silently ignored for non-SAP_RANGE commands.
*/
break;
case SAP_RANGE:
return (ERANGE);
break;
default:
return (EINVAL);
}
return (0);
}
int
{
int ret, i;
return (ret);
/*
* Validate that the specified list of modules exist. Note that
* ap_npush has already been sanity checked by sad_apc_verify().
*/
return (EINVAL);
}
return (0);
}
struct autopush *
sad_ap_alloc(void)
{
return (ap_new);
}
void
{
} else {
}
}
void
{
}
void
{
(mod_hash_val_t *)&ap_removed);
}
struct autopush *
{
(mod_hash_val_t *)&ap_result);
return (ap_result);
}
struct autopush *
{
/* prepare an apcommon structure to search with */
/*
* the following values must be set but initialized to have a
* valid apcommon struct, but since we're only using this
* structure to do a query the values are never actually used.
*/
apc.apc_lastminor = 0;
return (ap_result);
}
void
{
KM_SLEEP);
}
void
{
}