xref: /titanic_50/usr/src/uts/common/sys/dls.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5c0192a57Sericheng  * Common Development and Distribution License (the "License").
6c0192a57Sericheng  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
225ecc58b1SGirish Moodalbail  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_DLS_H
277c478bd9Sstevel@tonic-gate #define	_SYS_DLS_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/stream.h>
31da14cebeSEric Cheng #include <sys/mac_client.h>
32da14cebeSEric Cheng #include <sys/dls_mgmt.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * Data-Link Services Module
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Module name.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate #define	DLS_MODULE_NAME	"dls"
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  * Data-Link Services Information (text emitted by modinfo(1m))
497c478bd9Sstevel@tonic-gate  */
5039b361b2SRichard Bean #define	DLS_INFO	"Data-Link Services"
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
53ba2e4443Sseb  * Macros for converting ppas to instance #s, Vlan ID, or minor.
54210db224Sericheng  */
55210db224Sericheng #define	DLS_PPA2INST(ppa)	((int)((ppa) % 1000))
56da14cebeSEric Cheng #define	DLS_PPA2VID(ppa)	((uint16_t)((ppa) / 1000))
57da14cebeSEric Cheng #define	DLS_PPA2MINOR(ppa)	((minor_t)((DLS_PPA2INST(ppa)) + 1))
58da14cebeSEric Cheng 
59da14cebeSEric Cheng /*
60da14cebeSEric Cheng  * Maps a (VID, INST) pair to ppa
61da14cebeSEric Cheng  */
62da14cebeSEric Cheng #define	DLS_VIDINST2PPA(vid, inst)	((minor_t)((vid) * 1000 + (inst)))
63f4b3ec61Sdh155122 
64f4b3ec61Sdh155122 /*
65c0192a57Sericheng  * Converts a minor to an instance#; makes sense only when minor <= 1000.
66c0192a57Sericheng  */
67c0192a57Sericheng #define	DLS_MINOR2INST(minor)	((int)((minor) - 1))
68210db224Sericheng 
697c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
707c478bd9Sstevel@tonic-gate 
71d62bc4baSyz147064 #define	DLS_MAX_PPA	999
72d62bc4baSyz147064 #define	DLS_MAX_MINOR	(DLS_MAX_PPA + 1)
737c478bd9Sstevel@tonic-gate 
74da14cebeSEric Cheng typedef void    (*dls_rx_t)(void *, mac_resource_handle_t, mblk_t *,
75da14cebeSEric Cheng 		    mac_header_info_t *);
767c478bd9Sstevel@tonic-gate 
77da14cebeSEric Cheng typedef struct dld_str_s	dld_str_t;
78da14cebeSEric Cheng typedef struct dls_devnet_s	*dls_dl_handle_t;
79da14cebeSEric Cheng typedef struct dls_dev_t	*dls_dev_handle_t;
80da14cebeSEric Cheng typedef struct dls_link_s	dls_link_t;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #define	DLS_SAP_LLC	0
837c478bd9Sstevel@tonic-gate #define	DLS_SAP_PROMISC	(1 << 16)
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #define	DLS_PROMISC_SAP		0x00000001
867c478bd9Sstevel@tonic-gate #define	DLS_PROMISC_MULTI	0x00000002
877c478bd9Sstevel@tonic-gate #define	DLS_PROMISC_PHYS	0x00000004
887c478bd9Sstevel@tonic-gate 
89da14cebeSEric Cheng extern int	dls_open(dls_link_t *, dls_dl_handle_t, dld_str_t *);
90da14cebeSEric Cheng extern void	dls_close(dld_str_t *);
91da14cebeSEric Cheng extern int	dls_bind(dld_str_t *, uint32_t);
925ecc58b1SGirish Moodalbail extern void	dls_unbind(dld_str_t *);
937c478bd9Sstevel@tonic-gate 
94da14cebeSEric Cheng extern int	dls_promisc(dld_str_t *, uint32_t);
957c478bd9Sstevel@tonic-gate 
96da14cebeSEric Cheng extern int	dls_multicst_add(dld_str_t *, const uint8_t *);
97da14cebeSEric Cheng extern int	dls_multicst_remove(dld_str_t *, const uint8_t *);
98da14cebeSEric Cheng 
99da14cebeSEric Cheng extern mblk_t	*dls_header(dld_str_t *, const uint8_t *,
100d62bc4baSyz147064 		    uint16_t, uint_t, mblk_t **);
1017c478bd9Sstevel@tonic-gate 
102da14cebeSEric Cheng extern void	dls_rx_set(dld_str_t *, dls_rx_t, void *);
103da14cebeSEric Cheng extern dld_str_t *dls_rx_get(char *, flow_desc_t *, size_t *);
1047c478bd9Sstevel@tonic-gate 
105da14cebeSEric Cheng extern void	str_notify(void *, mac_notify_type_t);
106d62bc4baSyz147064 
107d62bc4baSyz147064 extern int		dls_devnet_open(const char *,
108d62bc4baSyz147064 			    dls_dl_handle_t *, dev_t *);
109d62bc4baSyz147064 extern void		dls_devnet_close(dls_dl_handle_t);
110d62bc4baSyz147064 extern boolean_t	dls_devnet_rebuild();
111d62bc4baSyz147064 
112d62bc4baSyz147064 extern int		dls_devnet_rename(datalink_id_t, datalink_id_t,
113d62bc4baSyz147064 			    const char *);
114*2b24ab6bSSebastien Roy extern int		dls_devnet_create(mac_handle_t, datalink_id_t,
115*2b24ab6bSSebastien Roy 			    zoneid_t);
116da14cebeSEric Cheng extern int		dls_devnet_destroy(mac_handle_t, datalink_id_t *,
117da14cebeSEric Cheng 			    boolean_t);
118d62bc4baSyz147064 extern int		dls_devnet_recreate(mac_handle_t, datalink_id_t);
119d62bc4baSyz147064 extern int		dls_devnet_hold_tmp(datalink_id_t, dls_dl_handle_t *);
120d62bc4baSyz147064 extern void		dls_devnet_rele_tmp(dls_dl_handle_t);
121da14cebeSEric Cheng extern int		dls_devnet_hold_by_dev(dev_t, dls_dl_handle_t *);
122da14cebeSEric Cheng extern void		dls_devnet_rele(dls_dl_handle_t);
12330890389Sartem extern void		dls_devnet_prop_task_wait(dls_dl_handle_t);
124d62bc4baSyz147064 
125d62bc4baSyz147064 extern const char	*dls_devnet_mac(dls_dl_handle_t);
126d62bc4baSyz147064 extern uint16_t		dls_devnet_vid(dls_dl_handle_t);
127d62bc4baSyz147064 extern datalink_id_t	dls_devnet_linkid(dls_dl_handle_t);
128d62bc4baSyz147064 extern int		dls_devnet_dev2linkid(dev_t, datalink_id_t *);
129d62bc4baSyz147064 extern int		dls_devnet_phydev(datalink_id_t, dev_t *);
130*2b24ab6bSSebastien Roy extern int		dls_devnet_setzid(dls_dl_handle_t, zoneid_t);
131*2b24ab6bSSebastien Roy extern zoneid_t		dls_devnet_getzid(dls_dl_handle_t);
132*2b24ab6bSSebastien Roy extern zoneid_t		dls_devnet_getownerzid(dls_dl_handle_t);
133*2b24ab6bSSebastien Roy extern boolean_t	dls_devnet_islinkvisible(datalink_id_t, zoneid_t);
134d62bc4baSyz147064 
135d62bc4baSyz147064 extern int		dls_mgmt_door_set(boolean_t);
136d62bc4baSyz147064 extern int		dls_mgmt_create(const char *, dev_t, datalink_class_t,
137d62bc4baSyz147064 			    uint32_t, boolean_t, datalink_id_t *);
138d62bc4baSyz147064 extern int		dls_mgmt_destroy(datalink_id_t, boolean_t);
139d62bc4baSyz147064 extern int		dls_mgmt_update(const char *, uint32_t, boolean_t,
140d62bc4baSyz147064 			    uint32_t *, datalink_id_t *);
141d62bc4baSyz147064 extern int		dls_mgmt_get_linkinfo(datalink_id_t, char *,
142d62bc4baSyz147064 			    datalink_class_t *, uint32_t *, uint32_t *);
143d62bc4baSyz147064 extern int		dls_mgmt_get_linkid(const char *, datalink_id_t *);
144d62bc4baSyz147064 extern datalink_id_t	dls_mgmt_get_next(datalink_id_t, datalink_class_t,
145d62bc4baSyz147064 			    datalink_media_t, uint32_t);
146da14cebeSEric Cheng extern int		dls_devnet_macname2linkid(const char *,
147da14cebeSEric Cheng 			    datalink_id_t *);
148d62bc4baSyz147064 
1497c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1527c478bd9Sstevel@tonic-gate }
1537c478bd9Sstevel@tonic-gate #endif
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate #endif	/* _SYS_DLS_H */
156