dld_drv.c revision e7801d59e8ceda0cde8ebdfdddd7582ee2ea96ef
/*
* 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"
/*
* 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 *);
#define NAUTOPUSH 32
static mod_hash_t *dld_ap_hashp;
static krwlock_t dld_ap_hash_lock;
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();
/*
* Create a hash table for autopush configuration.
*/
}
/* ARGSUSED */
static uint_t
{
return (MH_WALK_TERMINATE);
}
static int
drv_fini(void)
{
int err;
if (exist)
return (EBUSY);
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);
}
/*
* DLDIOC_ATTR
*/
static void
{
int err;
goto failed;
goto failed;
goto failed;
}
return;
}
/*
* DLDIOC_PHYS_ATTR
*/
static void
{
int err;
goto failed;
/*
* Every physical link should have its physical dev_t kept in the
* daemon. If not, it is not a valid physical link.
*/
goto failed;
}
/*
* Although this is a valid physical link, it might already be removed
* by DR or during system shutdown. softmac_hold_device() would return
* ENOENT in this case.
*/
goto failed;
/*
* Although this is an active physical link, its link type is
* not supported by GLDv3, and therefore it does not have
* vanity naming support.
*/
} else {
}
/*
* Get the physical device name from the major number and the instance
* number derived from phydev.
*/
return;
}
/*
* DLDIOCSETPROP
*/
static void
{
goto done;
goto done;
goto done;
goto done;
goto done;
}
if (set)
else
done:
if (err == 0)
else
}
static void
{
}
static void
{
}
/*
* DLDIOC_CREATE_VLAN
*/
static void
{
int err;
goto failed;
goto failed;
}
return;
}
/*
* DLDIOC_DELETE_VLAN
*/
static void
{
int err;
goto done;
done:
if (err == 0)
else
}
/*
* DLDIOC_VLAN_ATTR
*/
static void
{
int err;
goto failed;
/*
* Hold this link to prevent it from being deleted.
*/
if (err != 0)
goto failed;
goto failed;
}
if (err != 0) {
goto failed;
}
return;
}
/*
* DLDIOC_RENAME.
*
* This function handles two cases of link renaming. See more in comments above
* dls_datalink_rename().
*/
static void
{
int err;
goto done;
goto done;
}
goto done;
/*
* if dir_linkid2 is not DATALINK_INVALID_LINKID, it means this
* renaming request is to rename a valid physical link (dir_linkid1)
* to a "removed" physical link (dir_linkid2, which is removed by DR
* or during system shutdown). In this case, the link (specified by
* dir_linkid1) would inherit all the configuration of dir_linkid2,
* and dir_linkid1 and its configuration would be lost.
*
* Remove per-link autopush configuration of dir_linkid1 in this case.
*/
goto done;
}
done:
if (err == 0)
else
}
/*
* DLDIOC_SETAUTOPUSH
*/
static void
{
int i, err;
goto failed;
goto failed;
}
/*
* Validate that the specified list of modules exist.
*/
goto failed;
}
}
goto failed;
}
}
/*
* Update the configuration.
*/
FMNAMESZ + 1);
}
return;
}
/*
* DLDIOC_GETAUTOPUSH
*/
static void
{
int i, err;
goto failed;
(mod_hash_val_t *)&dap) != 0) {
goto failed;
}
/*
* Retrieve the configuration.
*/
FMNAMESZ + 1);
}
return;
}
/*
* DLDIOC_CLRAUTOPUSH
*/
static void
{
int err;
goto done;
goto done;
}
done:
if (err == 0)
else
}
/*
* DLDIOC_DOORSERVER
*/
static void
{
int err;
goto done;
done:
if (err == 0)
else
}
/*
* DLDIOC_SETZID
*/
static void
{
int err;
goto done;
done:
if (err == 0)
else
}
/*
* DLDIOC_GETZID
*/
static void
{
int err;
goto done;
done:
if (err == 0)
else
}
/*
* Process an IOCTL message received by the control node.
*/
static void
{
switch (cmd) {
case DLDIOC_ATTR:
return;
case DLDIOC_PHYS_ATTR:
return;
case DLDIOC_SECOBJ_SET:
return;
case DLDIOC_SECOBJ_GET:
return;
case DLDIOC_SECOBJ_UNSET:
return;
case DLDIOCSETPROP:
return;
case DLDIOCGETPROP:
return;
case DLDIOC_CREATE_VLAN:
return;
case DLDIOC_DELETE_VLAN:
return;
case DLDIOC_VLAN_ATTR:
return;
case DLDIOC_SETAUTOPUSH:
return;
case DLDIOC_GETAUTOPUSH:
return;
case DLDIOC_CLRAUTOPUSH:
return;
case DLDIOC_DOORSERVER:
return;
case DLDIOC_SETZID:
return;
case DLDIOC_GETZID:
return;
case DLDIOC_RENAME:
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);
}
/*
* Check for GLDv3 autopush information. There are three cases:
*
* 1. If devp points to a GLDv3 datalink and it has autopush configuration,
* fill dlap in with that information and return 0.
*
* 2. If devp points to a GLDv3 datalink but it doesn't have autopush
* configuration, then replace devp with the physical device (if one
* exists) and return 1. This allows stropen() to find the old-school
* per-driver autopush configuration. (For softmac, the result is that
* the softmac dev_t is replaced with the legacy device's dev_t).
*
* 3. If neither of the above apply, don't touch the args and return -1.
*/
int
{
return (-1);
/*
* Find the linkid by the link's dev_t.
*/
return (-1);
/*
* Find the autopush configuration associated with the linkid.
*/
(mod_hash_val_t *)&dap) == 0) {
return (0);
}
return (-1);
return (1);
}
/*
* 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;
}