softmac_dev.c revision ee94b1c37a34b758315666dcd0bc7c46d1aea15c
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/softmac_impl.h>
static kmem_cache_t *softmac_upper_cachep;
/*
* This function is a generic open(9E) entry point into the softmac for
* both the softmac module and the softmac driver.
*/
/*
* The following softmac_mod_xxx() functions are (9E) entry point functions for
* the softmac module.
*/
static int softmac_mod_close(queue_t *);
static void softmac_mod_wsrv(queue_t *);
/*
* The following softmac_drv_xxx() functions are (9E) entry point functions for
* the softmac driver.
*/
static int softmac_drv_close(queue_t *);
static void softmac_drv_wsrv(queue_t *);
static struct module_info softmac_modinfo = {
0,
0,
65536,
1024
};
/*
* hi-water mark is 1 because of the flow control mechanism implemented in
* dld. Refer to the comments in dld_str.c for details.
*/
static struct module_info softmac_dld_modinfo = {
0,
0,
1,
0
};
static struct qinit softmac_urinit = {
softmac_cmn_open, /* qi_qopen */
softmac_mod_close, /* qi_qclose */
NULL, /* qi_qadmin */
&softmac_modinfo /* qi_minfo */
};
static struct qinit softmac_uwinit = {
NULL, /* qi_qopen */
NULL, /* qi_qclose */
NULL, /* qi_qadmin */
&softmac_modinfo /* qi_minfo */
};
static struct streamtab softmac_tab = {
&softmac_urinit, /* st_rdinit */
&softmac_uwinit /* st_wrinit */
};
static struct qinit softmac_dld_r_qinit = {
};
static struct qinit softmac_dld_w_qinit = {
};
static struct fmodsw softmac_fmodsw = {
};
static struct modldrv softmac_modldrv = {
"softmac driver",
};
static struct modlstrmod softmac_modlstrmod = {
"softmac module",
};
static struct modlinkage softmac_modlinkage = {
};
/*ARGSUSED*/
static int
{
return (0);
}
/*ARGSUSED*/
static void
{
}
int
_init(void)
{
int err;
softmac_init();
sizeof (softmac_upper_t), 0, softmac_upper_constructor,
softmac_fini();
return (err);
}
return (0);
}
int
_fini(void)
{
int err;
if (softmac_busy())
return (EBUSY);
return (err);
softmac_fini();
return (0);
}
int
{
}
static int
{
/*
* This is a self-cloning driver so that each queue should only
* get opened once.
*/
return (EBUSY);
/*
* This is the softmac module pushed over an underlying
* legacy device. Initialize the lower structure.
*/
return (ENOMEM);
return (0);
}
/*
* Regular device open of a softmac DLPI node. We modify
* the queues' q_qinfo pointer such that all future STREAMS
* operations will go through another set of entry points
*/
}
static int
{
/*
* Call the appropriate delete routine depending on whether this is
* a module or device.
*/
return (0);
}
static void
{
union DL_primitives *dlp;
/*
* This is the softmac module.
*/
case M_DATA: {
/*
* If sl_rxinfo is non-NULL. This is dedicated-lower-stream
* created for fastpath. Directly call the rx callback.
*/
break;
}
/*
* A shared-lower-stream. Some driver starts to send up
* packets even it not in the DL_IDLE state, where
* sl_softmac is not set yet. Drop the packet in this case.
*/
return;
}
/*
* If this message is looped back from the legacy devices,
* drop it as the Nemo framework will be responsible for
* looping it back by the mac_txloop() function.
*/
return;
}
/*
* This is the most common case.
*/
return;
} else {
}
break;
}
case M_PROTO:
case M_PCPROTO:
break;
}
break;
}
break;
}
/*FALLTHROUGH*/
default:
break;
}
}
static void
{
/*
* This is the softmac module
*/
case M_IOCTL: {
case SMAC_IOC_START: {
break;
}
/*
* Assign the devname and perstream handle of the
* specific lower stream and return it as a part
* of the ioctl.
*/
break;
}
default:
break;
}
break;
}
default:
break;
}
}
static void
{
/*
* This is the softmac module
*/
/*
* Inform that the tx resource is available; mac_tx_update() will
* inform all the upper streams sharing this lower stream.
*/
}
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
softmac_dip = dip;
return (DDI_SUCCESS);
}
/* ARGSUSED */
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
softmac_dip = NULL;
return (DDI_SUCCESS);
}
/* ARGSUSED */
static int
{
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
if (softmac_dip != NULL) {
*result = softmac_dip;
return (DDI_SUCCESS);
}
break;
case DDI_INFO_DEVT2INSTANCE:
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
/*ARGSUSED*/
static void
{
if (canputnext(rq))
else
}
/*ARGSUSED*/
static int
{
int err = 0;
/*
* This is a softmac device created for a legacy device, find the
* associated softmac and initialize the softmac_upper_t structure.
*/
return (err);
goto fail;
}
goto fail;
}
goto fail;
}
return (0);
fail:
return (err);
}
static int
{
/*
* Wait until the pending request are processed by the worker thread.
*/
while (sup->su_dlpi_pending)
}
softmac->smac_nactive--;
}
return (dld_str_close(rq));
}
static void
{
case M_DATA:
case M_MULTIDATA:
break;
case M_PROTO:
case M_PCPROTO:
return;
}
if (prim == DL_UNITDATA_REQ) {
return;
}
break;
default:
break;
}
}
static void
{
/*
* Bump su_tx_inprocess so that su_mode won't change.
*/
sup->su_tx_inprocess++;
if (--sup->su_tx_inprocess == 0)
/*
* The flow-conctol of the dedicated-lower-stream is
* relieved. If DLD_CAPAB_DIRECT is enabled, call tx_notify
* callback to relieve the flow-control of the specific client,
* otherwise relieve the flow-control of all the upper-stream
* using the traditional STREAM mechanism.
*/
sup->su_tx_inprocess++;
if (--sup->su_tx_inprocess == 0)
}
}
}