dld_node.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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Data-Link Driver
*/
#include <sys/dld_impl.h>
static int node_constructor(void *, void *, int);
static void node_destructor(void *, void *);
static void node_destroy(dld_node_t *);
static int node_insert(dld_node_t *);
static void node_remove(dld_node_t *);
static dld_node_t *node_find_byname(const char *);
static kmem_cache_t *node_cachep;
static ght_t node_byminor_hash;
static ght_t node_byname_hash;
/*
* Initialize this module's data structures.
*/
void
dld_node_init(void)
{
int err;
/*
* Create a cache of dld_node_t structures.
*/
/*
* Create a scalar hash to be keyed by minor number.
*/
/*
* Create a string hash to be keyed by name.
*/
}
/*
* Tear down this module's data structures.
*/
int
dld_node_fini(void)
{
int err;
/*
* Check to make sure that the hash tables are empty.
*/
if (ght_count(node_byname_hash) != 0)
return (EBUSY);
return (0);
}
/*
* Find an existing node of the given style or create one if none is found.
* Bump a reference count on the node to note that fact that a reference to
* it is now held.
*/
{
int err;
return (NULL);
}
if (err != 0) {
return (NULL);
}
} else {
/*
* Make sure it's the right style.
*/
return (NULL);
}
}
return (dnp);
}
/*
* Look up a node by minor number. No reference count is bumped in this case
* because of the transient nature of how the reference is used. (See
* drv_open()).
*/
{
return (dnp);
}
/*
* Release a previously held reference to a dld_node_t.
*/
void
{
}
}
/*
* kmem_cache constructor function: see kmem_cache_create(9f).
*/
/*ARGSUSED*/
static int
{
/*
* Reserve a minor number for this node.
*/
return (-1);
return (0);
}
/*
* kmem_cache destructor function.
*/
/*ARGSUSED*/
static void
{
/*
* Release the minor number.
*/
}
/*
* Create a new dld_node_t object.
*/
static dld_node_t *
{
char *buf;
int err;
#define SUFFIX "_ppa_hash"
/*
* For style 2 nodes we need to create a private hash table
* to manage the multiple PPAs.
*/
}
/*
* Create a dev_t in the file system with the given name.
*/
goto failed;
return (dnp);
return (NULL);
}
/*
* Destroy a dld_node_t object.
*/
static void
{
int err;
/*
* This was a style 2 node so we must destroy the private
* hash table.
*/
}
/*
* Remove the dev_t from the file system.
*/
/*
* Work around an apparent bug in devfs where /devices is not
* kept up-to-date.
*/
}
/*
* Insert a node into both global hash tables.
*/
static int
{
int err;
/*
* Allocate a new entry for the 'by minor' hash table.
*/
return (ENOMEM);
/*
* Fill in the information.
*/
/*
* Insert the node into the table.
*/
return (err);
}
/*
* Allocate a new node for the 'by name' hash table.
*/
goto failed;
/*
* Fill in the information.
*/
/*
* Insert the node into the table.
*/
goto failed;
}
return (0);
return (err);
}
/*
* Remove a node from both the global hash tables.
*/
static void
{
/*
* Remove the node from the 'by name' hash table and free.
*/
/*
* Remove the node from the 'by minor' hash table and free.
*/
}
/*
* Look up a node in the 'by minor' table.
*/
static dld_node_t *
{
return (NULL);
}
/*
* Look up a node in the 'by name' table.
*/
static dld_node_t *
node_find_byname(const char *name)
{
return (NULL);
}
/*
* Add a PPA to a node.
*/
int
{
int err;
/*
* Only a single PPA can be added to a style 1 node so we
* insist that the index number argument is set to -1.
*/
/*
* Check to see if there is an existing PPA.
*/
return (EEXIST);
return (0);
}
/*
* Multiple PPAs can be added to a style 2 node and so we
* insist that the index number argument is zero or greater.
*/
/*
* Allocate an entry for the private hash table.
*/
/*
* Fill in the information.
*/
/*
* Lock the table.
*/
/*
* Insert the node into the table.
*/
/*
* Unlock the table.
*/
return (err);
}
/*
* Remove a PPA from the node.
*/
int
{
int err;
return (ENOENT);
return (0);
}
&hte)) == 0) {
}
return (err);
}
/*
* Look up a dld_ppa_t from a dld_node_t.
*/
{
}
return (NULL);
}
}