dld_drv.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 void drv_init(void);
static int drv_fini(void);
static void drv_uw_srv(queue_t *);
/* node is open */
/* unloading */
static struct module_info drv_info = {
0, /* mi_idnum */
DLD_DRIVER_NAME, /* mi_idname */
0, /* mi_minpsz */
(64 * 1024), /* mi_maxpsz */
1, /* mi_hiwat */
0 /* mi_lowat */
};
static struct qinit drv_ur_init = {
NULL, /* qi_putp */
NULL, /* qi_srvp */
drv_open, /* qi_qopen */
drv_close, /* qi_qclose */
NULL, /* qi_qadmin */
&drv_info, /* qi_minfo */
NULL /* qi_mstat */
};
static struct qinit drv_uw_init = {
NULL, /* qi_qopen */
NULL, /* qi_qclose */
NULL, /* qi_qadmin */
&drv_info, /* qi_minfo */
NULL /* qi_mstat */
};
static struct streamtab drv_stream = {
&drv_ur_init, /* st_rdinit */
&drv_uw_init, /* st_wrinit */
NULL, /* st_muxrinit */
NULL /* st_muxwinit */
};
/*
* Module linkage information for the kernel.
*/
extern struct mod_ops mod_driverops;
static struct modldrv drv_modldrv = {
};
static struct modlinkage drv_modlinkage = {
};
int
_init(void)
{
int err;
return (err);
#ifdef DEBUG
#endif /* DEBUG */
return (0);
}
int
_fini(void)
{
int err;
if (!dld_aul)
return (ENOTSUP);
return (err);
#ifdef DEBUG
#endif /* DEBUG */
return (err);
}
int
{
}
/*
* Initialize compoment modules.
*/
static void
drv_init(void)
{
dld_str_init();
dld_ppa_init();
}
static int
drv_fini(void)
{
int err;
if ((err = dld_ppa_fini()) != 0)
return (err);
err = dld_str_fini();
err = dld_node_fini();
err = dld_minor_fini();
return (0);
}
/*
* devo_getinfo: getinfo(9e)
*/
/*ARGSUSED*/
static int
{
return (DDI_FAILURE);
switch (cmd) {
case DDI_INFO_DEVT2INSTANCE:
*resp = (void *)0;
break;
case DDI_INFO_DEVT2DEVINFO:
break;
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* Check properties to set options. (See dld.h for property definitions).
*/
static void
{
DLD_PROP_NO_STYLE1, 0) != 0) {
#ifdef DEBUG
#endif /* DEBUG */
}
DLD_PROP_NO_FASTPATH, 0) != 0) {
#ifdef DEBUG
#endif /* DEBUG */
}
DLD_PROP_NO_POLL, 0) != 0) {
#ifdef DEBUG
#endif /* DEBUG */
}
DLD_PROP_NO_ZEROCOPY, 0) != 0) {
#ifdef DEBUG
#endif /* DEBUG */
}
}
/*
* devo_attach: attach(9e)
*/
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
drv_init();
/*
* Create control node. DLPI provider nodes will be created on demand.
*/
return (DDI_FAILURE);
/*
* Log the fact that the driver is now attached.
*/
return (DDI_SUCCESS);
}
/*
* devo_detach: detach(9e)
*/
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
if (drv_fini() != 0)
return (DDI_FAILURE);
/*
* Remove the control node.
*/
return (DDI_SUCCESS);
}
/*
* qi_qopen: open(9e)
*/
/*ARGSUSED*/
static int
{
int err;
/*
* This is a cloning driver and therefore each queue should only
* ever get opened once.
*/
return (EBUSY);
/*
* Grab the minor number of the dev_t that was opened. Because this
* is a cloning driver this will be distinct from the actual minor
* of the dev_t handed back.
*/
/*
* Create a new dld_str_t for the stream. This will grab a new minor
* number that will be handed back in the cloned dev_t.
*/
if (minor != DLD_CONTROL_MINOR) {
/*
* This is not the control node, so look up the DLPI
* provider node that is being opened.
*/
goto failed;
}
/*
* This is a style 1 provider node so we have a
* non-ambiguous PPA.
*/
goto failed;
}
} else {
/*
* This is the control node. It is exclusive-access so
* verify that it is not already open.
*/
if (dld_open) {
goto failed;
}
}
/*
* Enable the queue srv(9e) routine.
*/
/*
* Construct a cloned dev_t to hand back.
*/
return (0);
return (err);
}
/*
* qi_qclose: close(9e)
*/
static int
{
/*
* Disable the queue srv(9e) routine.
*/
/*
* This stream was open to a provider node. Check to see
* if it has been cleanly shut down.
*/
/*
* The stream is either open to a style 1 provider or
* this is not clean shutdown. Detach from the PPA.
* (This is still ok even in the style 1 case).
*/
}
} else {
/*
* This stream was open to the control node. Clear the flag
* to allow another stream access.
*/
}
return (0);
}
/*
* qi_qputp: put(9e)
*/
static void
{
/*
* Call the put(9e) processor.
*/
}
/*
* qi_srvp: srv(9e)
*/
static void
{
mblk_t *p;
/*
* Loop round and pull a chain of messages from the queue.
*/
*pp = p;
/*
* If there was nothing on the queue then there's nothing to do.
*/
return;
/*
* Call the srv(9e) processor.
*/
}