dls_mgmt.h revision 10491:8893b747ecdf
126159Sse/*
226159Sse * CDDL HEADER START
366529Smsmith *
466529Smsmith * The contents of this file are subject to the terms of the
526159Sse * Common Development and Distribution License (the "License").
626159Sse * You may not use this file except in compliance with the License.
726159Sse *
826159Sse * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
926159Sse * or http://www.opensolaris.org/os/licensing.
1026159Sse * See the License for the specific language governing permissions
1126159Sse * and limitations under the License.
1226159Sse *
1326159Sse * When distributing Covered Code, include this CDDL HEADER in each
1426159Sse * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1526159Sse * If applicable, add the following below this CDDL HEADER, with the
1626159Sse * fields enclosed by brackets "[]" replaced with your own identifying
1726159Sse * information: Portions Copyright [yyyy] [name of copyright owner]
1826159Sse *
1926159Sse * CDDL HEADER END
2026159Sse */
2126159Sse/*
2226159Sse * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
2326159Sse * Use is subject to license terms.
2426159Sse */
2526159Sse
2626159Sse#ifndef	_DLS_MGMT_H
2726159Sse#define	_DLS_MGMT_H
2850477Speter
2926159Sse#include <sys/types.h>
3026159Sse#include <sys/param.h>
316104Sse
3266529Smsmith/*
336734Sbde * Data-Link Services Module
3447307Speter */
3547307Speter
3661994Smsmith#ifdef	__cplusplus
3765304Speterextern "C" {
3867185Simp#endif
3967185Simp
4067185Simptypedef enum {
416104Sse	DATALINK_CLASS_PHYS		= 0x01,
4248832Smsmith	DATALINK_CLASS_VLAN		= 0x02,
4361994Smsmith	DATALINK_CLASS_AGGR		= 0x04,
4466416Speter	DATALINK_CLASS_VNIC		= 0x08,
4566529Smsmith	DATALINK_CLASS_ETHERSTUB	= 0x10,
4659294Smsmith	DATALINK_CLASS_SIMNET		= 0x20,
4759294Smsmith	DATALINK_CLASS_BRIDGE		= 0x40
4859294Smsmith} datalink_class_t;
4969783Smsmith
5069783Smsmith#define	DATALINK_CLASS_ALL	(DATALINK_CLASS_PHYS |	\
5169783Smsmith	DATALINK_CLASS_VLAN | DATALINK_CLASS_AGGR | DATALINK_CLASS_VNIC | \
5269783Smsmith	DATALINK_CLASS_ETHERSTUB | DATALINK_CLASS_SIMNET | \
5365176Sdfr	DATALINK_CLASS_BRIDGE)
5465176Sdfr
5582441Simp/*
5682441Simp * A combination of flags and media.
5726159Sse *   flags is the higher 32 bits, and if it is 0x01, it indicates all media
5826159Sse *   types can be accepted; otherwise, only the given media type (specified
5959294Smsmith *   in the lower 32 bits) is accepted.
6082035Simp */
616104Ssetypedef uint64_t	datalink_media_t;
6282035Simp
6382035Simp#define	DATALINK_ANY_MEDIATYPE		\
6468218Smsmith	((datalink_media_t)(((datalink_media_t)0x01) << 32))
6568218Smsmith
6668218Smsmith#define	DATALINK_MEDIA_ACCEPTED(dmedia, media)				\
6768218Smsmith	(((uint32_t)(((dmedia) >> 32) & 0xfffffffful) & 0x01) ?		\
6868218Smsmith	B_TRUE : ((uint32_t)((dmedia) & 0xfffffffful) == (media)))
6966529Smsmith
7066529Smsmith#define	MAXLINKATTRLEN		32
7159294Smsmith#define	MAXLINKATTRVALLEN	1024
7266529Smsmith
7366529Smsmith/*
7459294Smsmith * Link attributes used by the kernel.
7559294Smsmith */
7668218Smsmith/*
7767185Simp * The major number and instance number of the underlying physical device
7867185Simp * are kept as FPHYMAJ and FPHYINST (major, instance + 1).
7982026Speter *
8082026Speter * Set for physical links only.
8182026Speter */
8282026Speter#define	FPHYMAJ		"phymaj"	/* uint64_t */
8382026Speter#define	FPHYINST	"phyinst"	/* uint64_t */
8482026Speter
8582026Speter/*
8682026Speter * The devname of the physical link. For example, bge0, ce1. Set for physical
8782026Speter * links only.
8882026Speter */
8982026Speter#define	FDEVNAME	"devname"	/* string */
9082026Speter
9182026Speter/*
9282441Simp * The door file for the dlmgmtd (data-link management) daemon.
9382441Simp */
9482441Simp#define	DLMGMT_DOOR	"/etc/svc/volatile/dladm/dlmgmt_door"
9582441Simp
9682441Simp/*
9782441Simp * Door upcall commands.
9882441Simp */
9982441Simp#define	DLMGMT_CMD_DLS_CREATE		1
10082441Simp#define	DLMGMT_CMD_DLS_GETATTR		2
10182441Simp#define	DLMGMT_CMD_DLS_DESTROY		3
10282441Simp#define	DLMGMT_CMD_GETNAME		4
10382441Simp#define	DLMGMT_CMD_GETLINKID		5
10482441Simp#define	DLMGMT_CMD_GETNEXT		6
10582441Simp#define	DLMGMT_CMD_DLS_UPDATE		7
10682441Simp#define	DLMGMT_CMD_LINKPROP_INIT	8
10782441Simp#define	DLMGMT_CMD_BASE			128
10882441Simp
10982441Simp/*
11082441Simp * Indicate the link mapping is active or persistent
11182441Simp */
11282441Simp#define	DLMGMT_ACTIVE		0x01
11366529Smsmith#define	DLMGMT_PERSIST		0x02
11466529Smsmith
11566529Smsmith/* upcall argument */
11666529Smsmithtypedef struct dlmgmt_door_arg {
11766529Smsmith	uint_t			ld_cmd;
11859294Smsmith} dlmgmt_door_arg_t;
11967185Simp
12067185Simptypedef struct dlmgmt_upcall_arg_create {
12167185Simp	int			ld_cmd;
12267185Simp	datalink_class_t	ld_class;
12367185Simp	uint32_t		ld_media;
12465176Sdfr	boolean_t		ld_persist;
12566529Smsmith	uint64_t		ld_phymaj;
12666529Smsmith	uint64_t		ld_phyinst;
12766529Smsmith	char			ld_devname[MAXNAMELEN];
12866529Smsmith} dlmgmt_upcall_arg_create_t;
12966529Smsmith
13066529Smsmith/*
13166529Smsmith * Note: ld_padding is necessary to keep the size of the structure the
13266529Smsmith * same on amd64 and i386.  The same note applies to other ld_padding
13366529Smsmith * and lr_paddding fields in structures throughout this file.
13466529Smsmith */
13567185Simptypedef struct dlmgmt_upcall_arg_destroy {
13667185Simp	int			ld_cmd;
13767185Simp	datalink_id_t		ld_linkid;
13867185Simp	boolean_t		ld_persist;
13982441Simp	int			ld_padding;
14082441Simp} dlmgmt_upcall_arg_destroy_t;
14182441Simp
14267185Simptypedef struct dlmgmt_upcall_arg_update {
14367185Simp	int			ld_cmd;
14467185Simp	boolean_t		ld_novanity;
14567185Simp	uint32_t		ld_media;
14667185Simp	uint32_t		ld_padding;
14768218Smsmith	char			ld_devname[MAXNAMELEN];
14867185Simp} dlmgmt_upcall_arg_update_t;
14967185Simp
15067185Simptypedef struct dlmgmt_upcall_arg_getattr {
15167185Simp	int			ld_cmd;
15267185Simp	datalink_id_t		ld_linkid;
15366529Smsmith	char			ld_attr[MAXLINKATTRLEN];
15466529Smsmith} dlmgmt_upcall_arg_getattr_t;
15559294Smsmith
15659294Smsmithtypedef struct dlmgmt_door_getname {
15766529Smsmith	int			ld_cmd;
15869783Smsmith	datalink_id_t		ld_linkid;
15966529Smsmith} dlmgmt_door_getname_t;
16071237Speter
16169783Smsmithtypedef struct dlmgmt_door_getlinkid {
16259294Smsmith	int			ld_cmd;
16366529Smsmith	char			ld_link[MAXLINKNAMELEN];
16466529Smsmith} dlmgmt_door_getlinkid_t;
16566529Smsmith
16659294Smsmithtypedef struct dlmgmt_door_getnext_s {
16759294Smsmith	int			ld_cmd;
16869783Smsmith	datalink_id_t		ld_linkid;
16969783Smsmith	datalink_class_t	ld_class;
17069783Smsmith	uint32_t		ld_flags;
17169783Smsmith	datalink_media_t	ld_dmedia;
17269783Smsmith} dlmgmt_door_getnext_t;
17369783Smsmith
17469783Smsmithtypedef struct dlmgmt_door_linkprop_init {
17569783Smsmith	int			ld_cmd;
17669783Smsmith	datalink_id_t		ld_linkid;
17769783Smsmith} dlmgmt_door_linkprop_init_t;
17869783Smsmith
17970953Sbmilekic/* upcall return value */
18069783Smsmithtypedef struct dlmgmt_retval_s {
18169783Smsmith	uint_t			lr_err; /* return error code */
18269783Smsmith} dlmgmt_retval_t;
18369783Smsmith
18469783Smsmithtypedef dlmgmt_retval_t	dlmgmt_destroy_retval_t,
18569783Smsmith			dlmgmt_linkprop_init_retval_t;
18669783Smsmith
18769783Smsmithstruct dlmgmt_linkid_retval_s {
18869783Smsmith	uint_t			lr_err;
18969783Smsmith	datalink_id_t		lr_linkid;
19069783Smsmith	uint32_t		lr_flags;
19169783Smsmith	datalink_class_t	lr_class;
19269783Smsmith	uint32_t		lr_media;
19369783Smsmith	uint32_t		lr_padding;
19469783Smsmith};
19569783Smsmith
19669783Smsmithtypedef struct dlmgmt_linkid_retval_s	dlmgmt_create_retval_t,
19769783Smsmith					dlmgmt_update_retval_t,
19869783Smsmith					dlmgmt_getlinkid_retval_t,
19969783Smsmith					dlmgmt_getnext_retval_t;
20069783Smsmith
20169783Smsmithtypedef struct dlmgmt_getname_retval_s {
20269783Smsmith	uint_t			lr_err;
20369783Smsmith	char			lr_link[MAXLINKNAMELEN];
20469783Smsmith	datalink_class_t	lr_class;
20569783Smsmith	uint32_t		lr_media;
20669783Smsmith	uint32_t		lr_flags;
20769783Smsmith} dlmgmt_getname_retval_t;
20869783Smsmith
20969783Smsmithtypedef struct dlmgmt_getattr_retval_s {
21069783Smsmith	uint_t			lr_err;
21169783Smsmith	uint_t			lr_type;
21269783Smsmith	uint_t			lr_attrsz;
21369783Smsmith	uint_t			lr_padding;
21466529Smsmith	char			lr_attrval[MAXLINKATTRVALLEN];
21566529Smsmith} dlmgmt_getattr_retval_t;
21666529Smsmith
21766529Smsmith#ifdef	__cplusplus
21866529Smsmith}
21959294Smsmith#endif
22066529Smsmith
22166529Smsmith#endif	/* _DLS_MGMT_H */
22266529Smsmith