dld_drv.c revision 9c1751294cd1ff9c27007f40ee6aacc943076cbf
/*
* 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 2007 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>
#include <sys/dls_impl.h>
/*
* dld control node state, one per open control node session.
*/
typedef struct dld_ctl_str_s {
static void drv_init(void);
static int drv_fini(void);
/*
* Secure objects declarations
*/
#define SECOBJ_WEP_HASHSZ 67
static krwlock_t drv_secobj_lock;
static kmem_cache_t *drv_secobj_cachep;
static mod_hash_t *drv_secobj_hash;
static void drv_secobj_init(void);
static void drv_secobj_fini(void);
/*
* The following entry points are private to dld and are used for control
* operations only. The entry points exported to mac drivers are defined
*/
static void drv_uw_srv(queue_t *);
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;
drv_init();
return (err);
return (0);
}
int
_fini(void)
{
int err;
return (err);
if (drv_fini() != 0) {
(void) mod_install(&drv_modlinkage);
return (DDI_FAILURE);
}
return (err);
}
int
{
}
/*
* Initialize component modules.
*/
static void
drv_init(void)
{
dld_str_init();
}
static int
drv_fini(void)
{
int err;
if ((err = dld_str_fini()) != 0)
return (err);
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_FASTPATH, 0) != 0) {
}
DLD_PROP_NO_POLL, 0) != 0) {
}
DLD_PROP_NO_ZEROCOPY, 0) != 0) {
}
DLD_PROP_NO_SOFTRING, 0) != 0) {
}
}
/*
* devo_attach: attach(9e)
*/
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
/*
* 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);
/*
* Remove the control node.
*/
return (DDI_SUCCESS);
}
/*
* dld control node open procedure.
*/
/*ARGSUSED*/
static int
{
return (ENOTSUP);
/*
* This is a cloning driver and therefore each queue should only
* ever get opened once.
*/
return (EBUSY);
if (minor == 0)
return (ENOMEM);
return (ENOMEM);
}
/*
* Enable the queue srv(9e) routine.
*/
/*
* Construct a cloned dev_t to hand back.
*/
return (0);
}
/*
* dld control node close procedure.
*/
static int
{
/*
* Disable the queue srv(9e) routine.
*/
return (0);
}
/*
* DLDIOCATTR
*/
static void
{
int err;
goto failed;
goto failed;
}
return;
char devname[MAXNAMELEN];
/*
* Try to detect if the specified device is gldv3
* and return ENODEV if it is not.
*/
}
}
/*
* DLDIOCVLAN
*/
typedef struct dld_ioc_vlan_state {
static int
{
/*
* passed buffer space is limited to 65536 bytes. So
* copy only the vlans associated with the passed link.
*/
return (ENOSPC);
}
return (0);
}
static void
{
goto failed;
goto failed;
if (err != 0)
goto failed;
return;
}
/*
* DLDIOCHOLDVLAN
*/
static void
{
char mac[MAXNAMELEN];
goto failed;
/*
* When a device instance without opens is detached, its
* dls_vlan_t will be destroyed. A subsequent DLDIOCHOLDVLAN
* invoked on this device instance will fail because
* dls_vlan_hold() does not create non-tagged vlans on demand.
* To handle this problem, we must force the creation of the
* dls_vlan_t (if it doesn't already exist) by calling
* ddi_hold_devi_by_instance() before calling dls_vlan_hold().
*/
goto failed;
goto failed;
}
if (err != 0)
goto failed;
dhv->dhv_docheck)) != 0) {
goto failed;
} else {
return;
}
}
/*
* DLDIOCRELEVLAN
*/
static void
{
int err;
return;
}
dhv->dhv_docheck)) != 0) {
return;
}
return;
}
}
/*
* DLDIOCZIDGET
*/
static void
{
int err;
return;
}
else
}
/*
* Process an IOCTL message received by the control node.
*/
static void
{
switch (cmd) {
case DLDIOCATTR:
return;
case DLDIOCVLAN:
return;
case DLDIOCSECOBJSET:
return;
case DLDIOCSECOBJGET:
return;
case DLDIOCSECOBJUNSET:
return;
case DLDIOCHOLDVLAN:
return;
case DLDIOCRELEVLAN:
return;
case DLDIOCZIDGET:
return;
default:
return;
}
}
/*
* Write side put routine of the dld control node.
*/
static void
{
case M_IOCTL:
break;
default:
break;
}
}
/*
* Write-side service procedure.
*/
void
drv_uw_srv(queue_t *q)
{
drv_uw_put(q, mp);
}
/*
* Secure objects implementation
*/
/* ARGSUSED */
static int
{
return (0);
}
static void
drv_secobj_init(void)
{
}
static void
drv_secobj_fini(void)
{
}
static void
{
goto failed;
goto failed;
goto failed;
(mod_hash_val_t *)&objp);
if (err == 0) {
goto failed;
}
} else {
goto failed;
}
}
return;
}
typedef struct dld_secobj_state {
int ss_rc;
/* ARGSUSED */
static uint_t
{
return (MH_WALK_TERMINATE);
}
return (MH_WALK_CONTINUE);
}
static void
{
goto failed;
goto failed;
goto failed;
if (err != 0) {
goto failed;
}
} else {
goto failed;
}
}
return;
}
static void
{
goto failed;
goto failed;
(mod_hash_val_t *)&objp);
if (err != 0) {
goto failed;
}
(mod_hash_val_t *)&val);
return;
}