xref: /titanic_51/usr/src/uts/common/sys/mac_client_priv.h (revision 09b7f21a0999a8ceb9f3e517fff7c39c52405ba2)
1da14cebeSEric Cheng /*
2da14cebeSEric Cheng  * CDDL HEADER START
3da14cebeSEric Cheng  *
4da14cebeSEric Cheng  * The contents of this file are subject to the terms of the
5da14cebeSEric Cheng  * Common Development and Distribution License (the "License").
6da14cebeSEric Cheng  * You may not use this file except in compliance with the License.
7da14cebeSEric Cheng  *
8da14cebeSEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da14cebeSEric Cheng  * or http://www.opensolaris.org/os/licensing.
10da14cebeSEric Cheng  * See the License for the specific language governing permissions
11da14cebeSEric Cheng  * and limitations under the License.
12da14cebeSEric Cheng  *
13da14cebeSEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
14da14cebeSEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da14cebeSEric Cheng  * If applicable, add the following below this CDDL HEADER, with the
16da14cebeSEric Cheng  * fields enclosed by brackets "[]" replaced with your own identifying
17da14cebeSEric Cheng  * information: Portions Copyright [yyyy] [name of copyright owner]
18da14cebeSEric Cheng  *
19da14cebeSEric Cheng  * CDDL HEADER END
20da14cebeSEric Cheng  */
21da14cebeSEric Cheng 
22da14cebeSEric Cheng /*
230dc2366fSVenugopal Iyer  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24da14cebeSEric Cheng  * Use is subject to license terms.
251a41ca23SJerry Jelinek  * Copyright 2013 Joyent, Inc.  All rights reserved.
26da14cebeSEric Cheng  */
27da14cebeSEric Cheng 
28da14cebeSEric Cheng /*
29da14cebeSEric Cheng  * This file contains *private* MAC API definitions. This header file
30da14cebeSEric Cheng  * should only be included by kernel components which are part of the
31da14cebeSEric Cheng  * GLDv3 stack (dld, dls, aggr, softmac).
32da14cebeSEric Cheng  */
33da14cebeSEric Cheng 
34da14cebeSEric Cheng #ifndef	_SYS_MAC_CLIENT_PRIV_H
35da14cebeSEric Cheng #define	_SYS_MAC_CLIENT_PRIV_H
36da14cebeSEric Cheng 
37da14cebeSEric Cheng #include <sys/mac.h>
38da14cebeSEric Cheng #include <sys/mac_flow.h>
39da14cebeSEric Cheng 
40da14cebeSEric Cheng #ifdef	__cplusplus
41da14cebeSEric Cheng extern "C" {
42da14cebeSEric Cheng #endif
43da14cebeSEric Cheng 
44da14cebeSEric Cheng #ifdef	_KERNEL
45da14cebeSEric Cheng 
46da14cebeSEric Cheng #ifdef DEBUG
47da14cebeSEric Cheng #define	MAC_PERIM_HELD(mph)		mac_perim_held(mph)
48da14cebeSEric Cheng #else
49da14cebeSEric Cheng #define	MAC_PERIM_HELD(mph)
50da14cebeSEric Cheng #endif
51da14cebeSEric Cheng 
52da14cebeSEric Cheng extern boolean_t mac_rx_bypass_set(mac_client_handle_t, mac_direct_rx_t,
53da14cebeSEric Cheng     void *);
548d4cf8d8S extern void mac_rx_bypass_enable(mac_client_handle_t);
558d4cf8d8S extern void mac_rx_bypass_disable(mac_client_handle_t);
56da14cebeSEric Cheng 
57da14cebeSEric Cheng extern const mac_info_t *mac_info(mac_handle_t);
58da14cebeSEric Cheng extern boolean_t mac_info_get(const char *, mac_info_t *);
59d91a22bfSGirish Moodalbail extern boolean_t mac_promisc_get(mac_handle_t);
60da14cebeSEric Cheng 
613bdd2dd4SMichael Lim extern int mac_start(mac_handle_t);
623bdd2dd4SMichael Lim extern void mac_stop(mac_handle_t);
633bdd2dd4SMichael Lim 
64da14cebeSEric Cheng extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *);
65da14cebeSEric Cheng extern link_state_t mac_link_get(mac_handle_t);
66da14cebeSEric Cheng extern void mac_resource_set(mac_client_handle_t, mac_resource_add_t, void *);
67da14cebeSEric Cheng extern dev_info_t *mac_devinfo_get(mac_handle_t);
685d460eafSCathy Zhou extern void *mac_driver(mac_handle_t);
69da14cebeSEric Cheng extern boolean_t mac_capab_get(mac_handle_t, mac_capab_t, void *);
70da14cebeSEric Cheng extern boolean_t mac_sap_verify(mac_handle_t, uint32_t, uint32_t *);
71da14cebeSEric Cheng extern mblk_t *mac_header(mac_handle_t, const uint8_t *, uint32_t, mblk_t *,
72da14cebeSEric Cheng     size_t);
73da14cebeSEric Cheng extern int mac_header_info(mac_handle_t, mblk_t *, mac_header_info_t *);
7425ec3e3dSEric Cheng extern int mac_vlan_header_info(mac_handle_t, mblk_t *, mac_header_info_t *);
75da14cebeSEric Cheng extern mblk_t *mac_header_cook(mac_handle_t, mblk_t *);
76da14cebeSEric Cheng extern mblk_t *mac_header_uncook(mac_handle_t, mblk_t *);
77da14cebeSEric Cheng 
78da14cebeSEric Cheng extern void mac_resource_set_common(mac_client_handle_t,
79da14cebeSEric Cheng     mac_resource_add_t, mac_resource_remove_t, mac_resource_quiesce_t,
80da14cebeSEric Cheng     mac_resource_restart_t, mac_resource_bind_t, void *);
81da14cebeSEric Cheng 
82da14cebeSEric Cheng extern	void mac_perim_enter_by_mh(mac_handle_t, mac_perim_handle_t *);
83da14cebeSEric Cheng extern	int mac_perim_enter_by_macname(const char *, mac_perim_handle_t *);
84da14cebeSEric Cheng extern	int mac_perim_enter_by_linkid(datalink_id_t, mac_perim_handle_t *);
85da14cebeSEric Cheng extern	void mac_perim_exit(mac_perim_handle_t);
86da14cebeSEric Cheng extern	boolean_t mac_perim_held(mac_handle_t);
87da14cebeSEric Cheng 
88da14cebeSEric Cheng extern	uint16_t mac_client_vid(mac_client_handle_t);
89da14cebeSEric Cheng extern int mac_vnic_unicast_set(mac_client_handle_t, const uint8_t *);
9072782355SNicolas Droux extern boolean_t mac_client_is_vlan_vnic(mac_client_handle_t);
91da14cebeSEric Cheng 
92da14cebeSEric Cheng extern void mac_client_poll_enable(mac_client_handle_t);
93da14cebeSEric Cheng extern void mac_client_poll_disable(mac_client_handle_t);
94da14cebeSEric Cheng 
95da14cebeSEric Cheng /*
96da14cebeSEric Cheng  * Flow-related APIs for MAC clients.
97da14cebeSEric Cheng  */
98da14cebeSEric Cheng 
99da14cebeSEric Cheng extern void mac_link_init_flows(mac_client_handle_t);
100da14cebeSEric Cheng extern void mac_link_release_flows(mac_client_handle_t);
101da14cebeSEric Cheng extern int mac_link_flow_add(datalink_id_t, char *, flow_desc_t *,
102da14cebeSEric Cheng     mac_resource_props_t *);
103da14cebeSEric Cheng extern int mac_link_flow_remove(char *);
104da14cebeSEric Cheng extern int mac_link_flow_modify(char *, mac_resource_props_t *);
105da14cebeSEric Cheng extern boolean_t mac_link_has_flows(mac_client_handle_t);
106da14cebeSEric Cheng 
107da14cebeSEric Cheng typedef struct {
108da000602SGirish Moodalbail 	char			fi_flow_name[MAXFLOWNAMELEN];
109da14cebeSEric Cheng 	datalink_id_t		fi_link_id;
110da14cebeSEric Cheng 	flow_desc_t		fi_flow_desc;
111da14cebeSEric Cheng 	mac_resource_props_t	fi_resource_props;
112da14cebeSEric Cheng } mac_flowinfo_t;
113da14cebeSEric Cheng 
114da14cebeSEric Cheng extern int mac_link_flow_walk(datalink_id_t,
115da14cebeSEric Cheng     int (*)(mac_flowinfo_t *, void *), void *);
116da14cebeSEric Cheng extern int mac_link_flow_info(char *, mac_flowinfo_t *);
117da14cebeSEric Cheng 
118da14cebeSEric Cheng extern void mac_rx_client_quiesce(mac_client_handle_t);
119da14cebeSEric Cheng extern void mac_rx_client_restart(mac_client_handle_t);
1200dc2366fSVenugopal Iyer extern void mac_tx_client_quiesce(mac_client_handle_t);
1210dc2366fSVenugopal Iyer extern void mac_tx_client_condemn(mac_client_handle_t);
1220dc2366fSVenugopal Iyer extern void mac_tx_client_restart(mac_client_handle_t);
123da14cebeSEric Cheng extern void mac_srs_perm_quiesce(mac_client_handle_t, boolean_t);
124da14cebeSEric Cheng extern int mac_hwrings_get(mac_client_handle_t, mac_group_handle_t *,
12563f531d1SSriharsha Basavapatna     mac_ring_handle_t *, mac_ring_type_t);
1260dc2366fSVenugopal Iyer extern uint_t mac_hwring_getinfo(mac_ring_handle_t);
1270dc2366fSVenugopal Iyer extern void mac_hwring_setup(mac_ring_handle_t, mac_resource_handle_t,
1280dc2366fSVenugopal Iyer     mac_ring_handle_t);
129da14cebeSEric Cheng extern void mac_hwring_teardown(mac_ring_handle_t);
130da14cebeSEric Cheng extern int mac_hwring_disable_intr(mac_ring_handle_t);
131da14cebeSEric Cheng extern int mac_hwring_enable_intr(mac_ring_handle_t);
132da14cebeSEric Cheng extern int mac_hwring_start(mac_ring_handle_t);
133da14cebeSEric Cheng extern void mac_hwring_stop(mac_ring_handle_t);
134da14cebeSEric Cheng extern mblk_t *mac_hwring_poll(mac_ring_handle_t, int);
1350dc2366fSVenugopal Iyer extern mblk_t *mac_hwring_tx(mac_ring_handle_t, mblk_t *);
1360dc2366fSVenugopal Iyer extern int mac_hwring_getstat(mac_ring_handle_t, uint_t, uint64_t *);
1370dc2366fSVenugopal Iyer extern mblk_t *mac_hwring_send_priv(mac_client_handle_t,
1380dc2366fSVenugopal Iyer     mac_ring_handle_t, mblk_t *);
139*09b7f21aSRobert Mustacchi extern void mac_hwring_set_default(mac_handle_t, mac_ring_handle_t);
1400dc2366fSVenugopal Iyer 
141da14cebeSEric Cheng #define	MAC_HWRING_POLL(ring, bytes)			\
142da14cebeSEric Cheng 	(((ring)->mr_info.mri_poll)			\
143da14cebeSEric Cheng 	((ring)->mr_info.mri_driver, (bytes)))
144da14cebeSEric Cheng 
145da14cebeSEric Cheng extern int mac_hwgroup_addmac(mac_group_handle_t, const uint8_t *);
146da14cebeSEric Cheng extern int mac_hwgroup_remmac(mac_group_handle_t, const uint8_t *);
147da14cebeSEric Cheng 
1480dc2366fSVenugopal Iyer extern void mac_set_upper_mac(mac_client_handle_t, mac_handle_t,
1490dc2366fSVenugopal Iyer     mac_resource_props_t *);
150da14cebeSEric Cheng 
151da14cebeSEric Cheng extern int mac_mark_exclusive(mac_handle_t);
152da14cebeSEric Cheng extern void mac_unmark_exclusive(mac_handle_t);
153da14cebeSEric Cheng 
1540dc2366fSVenugopal Iyer extern uint_t mac_hwgrp_num(mac_handle_t, int);
1550dc2366fSVenugopal Iyer extern void mac_get_hwrxgrp_info(mac_handle_t, int, uint_t *, uint_t *,
1560dc2366fSVenugopal Iyer     uint_t *, uint_t *, uint_t *, char *);
1570dc2366fSVenugopal Iyer extern void mac_get_hwtxgrp_info(mac_handle_t, int, uint_t *, uint_t *,
1580dc2366fSVenugopal Iyer     uint_t *, uint_t *, uint_t *, char *);
1590dc2366fSVenugopal Iyer 
1600dc2366fSVenugopal Iyer extern uint_t mac_txavail_get(mac_handle_t);
1610dc2366fSVenugopal Iyer extern uint_t mac_rxavail_get(mac_handle_t);
1620dc2366fSVenugopal Iyer extern uint_t mac_txrsvd_get(mac_handle_t);
1630dc2366fSVenugopal Iyer extern uint_t mac_rxrsvd_get(mac_handle_t);
1640dc2366fSVenugopal Iyer extern uint_t mac_rxhwlnksavail_get(mac_handle_t);
1650dc2366fSVenugopal Iyer extern uint_t mac_rxhwlnksrsvd_get(mac_handle_t);
1660dc2366fSVenugopal Iyer extern uint_t mac_txhwlnksavail_get(mac_handle_t);
1670dc2366fSVenugopal Iyer extern uint_t mac_txhwlnksrsvd_get(mac_handle_t);
1680dc2366fSVenugopal Iyer 
169da14cebeSEric Cheng extern int32_t mac_client_intr_cpu(mac_client_handle_t);
170da14cebeSEric Cheng extern void mac_client_set_intr_cpu(void *, mac_client_handle_t, int32_t);
171da14cebeSEric Cheng extern void *mac_get_devinfo(mac_handle_t);
172da14cebeSEric Cheng 
1730dc2366fSVenugopal Iyer extern boolean_t mac_is_vnic(mac_handle_t);
1740dc2366fSVenugopal Iyer extern uint32_t mac_no_notification(mac_handle_t);
1750dc2366fSVenugopal Iyer 
1760dc2366fSVenugopal Iyer extern int mac_set_prop(mac_handle_t, mac_prop_id_t, char *, void *, uint_t);
1770dc2366fSVenugopal Iyer extern int mac_get_prop(mac_handle_t, mac_prop_id_t, char *, void *, uint_t);
1780dc2366fSVenugopal Iyer extern int mac_prop_info(mac_handle_t, mac_prop_id_t, char *, void *,
1790dc2366fSVenugopal Iyer     uint_t, mac_propval_range_t *, uint_t *);
1800dc2366fSVenugopal Iyer extern boolean_t mac_prop_check_size(mac_prop_id_t, uint_t, boolean_t);
1810dc2366fSVenugopal Iyer 
1820dc2366fSVenugopal Iyer extern uint64_t mac_pseudo_rx_ring_stat_get(mac_ring_handle_t, uint_t);
1830dc2366fSVenugopal Iyer extern uint64_t mac_pseudo_tx_ring_stat_get(mac_ring_handle_t, uint_t);
1840dc2366fSVenugopal Iyer 
185da14cebeSEric Cheng #endif	/* _KERNEL */
186da14cebeSEric Cheng 
187da14cebeSEric Cheng #ifdef	__cplusplus
188da14cebeSEric Cheng }
189da14cebeSEric Cheng #endif
190da14cebeSEric Cheng 
191da14cebeSEric Cheng #endif /* _SYS_MAC_CLIENT_PRIV_H */
192