4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * IEEE 802.3ad Link Aggregation.
31 #include <sys/modctl.h>
33 #include <sys/aggr_impl.h>
35 /* module description */
36 #define AGGR_LINKINFO "Link Aggregation MAC"
38 /* device info ptr, only one for instance 0 */
39 dev_info_t
*aggr_dip
= NULL
;
41 static int aggr_getinfo(dev_info_t
*, ddi_info_cmd_t
, void *, void **);
42 static int aggr_attach(dev_info_t
*, ddi_attach_cmd_t
);
43 static int aggr_detach(dev_info_t
*, ddi_detach_cmd_t
);
45 DDI_DEFINE_STREAM_OPS(aggr_dev_ops
, nulldev
, nulldev
, aggr_attach
, aggr_detach
,
46 nodev
, aggr_getinfo
, D_MP
, NULL
, ddi_quiesce_not_supported
);
48 static struct modldrv aggr_modldrv
= {
49 &mod_driverops
, /* Type of module. This one is a driver */
50 AGGR_LINKINFO
, /* short description */
51 &aggr_dev_ops
/* driver specific ops */
54 static struct modlinkage modlinkage
= {
55 MODREV_1
, &aggr_modldrv
, NULL
63 mac_init_ops(&aggr_dev_ops
, "aggr");
64 if ((err
= mod_install(&modlinkage
)) != 0)
65 mac_fini_ops(&aggr_dev_ops
);
74 if ((err
= mod_remove(&modlinkage
)) == 0)
75 mac_fini_ops(&aggr_dev_ops
);
80 _info(struct modinfo
*modinfop
)
82 return (mod_info(&modlinkage
, modinfop
));
87 aggr_getinfo(dev_info_t
*dip
, ddi_info_cmd_t infocmd
, void *arg
,
91 case DDI_INFO_DEVT2DEVINFO
:
94 case DDI_INFO_DEVT2INSTANCE
:
102 aggr_attach(dev_info_t
*dip
, ddi_attach_cmd_t cmd
)
106 if (ddi_get_instance(dip
) != 0) {
107 /* we only allow instance 0 to attach */
108 return (DDI_FAILURE
);
110 if (aggr_ioc_init() != 0)
111 return (DDI_FAILURE
);
116 return (DDI_SUCCESS
);
119 return (DDI_SUCCESS
);
122 return (DDI_FAILURE
);
128 aggr_detach(dev_info_t
*dip
, ddi_detach_cmd_t cmd
)
132 if (aggr_grp_count() > 0)
133 return (DDI_FAILURE
);
140 return (DDI_SUCCESS
);
143 return (DDI_SUCCESS
);
146 return (DDI_FAILURE
);