1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 * Copyright 2018 Joyent, Inc. 26 * Copyright 2025 Oxide Computer Company 27 */ 28 29 /* 30 * This file contains *private* MAC API definitions. This header file 31 * should only be included by kernel components which are part of the 32 * GLDv3 stack (dld, dls, aggr, softmac). 33 */ 34 35 #ifndef _SYS_MAC_CLIENT_PRIV_H 36 #define _SYS_MAC_CLIENT_PRIV_H 37 38 #include <sys/mac.h> 39 #include <sys/mac_flow.h> 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 #ifdef _KERNEL 46 47 #ifdef DEBUG 48 #define MAC_PERIM_HELD(mph) mac_perim_held(mph) 49 #else 50 #define MAC_PERIM_HELD(mph) 51 #endif 52 53 extern boolean_t mac_rx_bypass_set(mac_client_handle_t, mac_direct_rx_t, 54 void *, boolean_t); 55 extern void mac_rx_bypass_enable(mac_client_handle_t); 56 extern void mac_rx_bypass_disable(mac_client_handle_t); 57 58 extern const mac_info_t *mac_info(mac_handle_t); 59 extern boolean_t mac_info_get(const char *, mac_info_t *); 60 extern boolean_t mac_promisc_get(mac_handle_t); 61 62 extern int mac_start(mac_handle_t); 63 extern void mac_stop(mac_handle_t); 64 65 extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *); 66 extern link_state_t mac_link_get(mac_handle_t); 67 extern void mac_resource_set(mac_client_handle_t, mac_resource_add_t, void *); 68 extern dev_info_t *mac_devinfo_get(mac_handle_t); 69 extern void *mac_driver(mac_handle_t); 70 extern boolean_t mac_capab_get(mac_handle_t, mac_capab_t, void *); 71 extern boolean_t mac_sap_verify(mac_handle_t, uint32_t, uint32_t *); 72 extern mblk_t *mac_header(mac_handle_t, const uint8_t *, uint32_t, mblk_t *, 73 size_t); 74 extern int mac_header_info(mac_handle_t, mblk_t *, mac_header_info_t *); 75 extern int mac_vlan_header_info(mac_handle_t, mblk_t *, mac_header_info_t *); 76 extern mblk_t *mac_header_cook(mac_handle_t, mblk_t *); 77 extern mblk_t *mac_header_uncook(mac_handle_t, mblk_t *); 78 79 extern void mac_resource_set_common(mac_client_handle_t, 80 mac_resource_add_t, mac_resource_remove_t, mac_resource_quiesce_t, 81 mac_resource_restart_t, mac_resource_bind_t, void *); 82 83 extern void mac_perim_enter_by_mh(mac_handle_t, mac_perim_handle_t *); 84 extern int mac_perim_enter_by_macname(const char *, mac_perim_handle_t *); 85 extern int mac_perim_enter_by_linkid(datalink_id_t, mac_perim_handle_t *); 86 extern void mac_perim_exit(mac_perim_handle_t); 87 extern boolean_t mac_perim_held(mac_handle_t); 88 89 extern uint16_t mac_client_vid(mac_client_handle_t); 90 extern int mac_vnic_unicast_set(mac_client_handle_t, const uint8_t *); 91 extern boolean_t mac_client_is_vlan_vnic(mac_client_handle_t); 92 93 extern void mac_client_poll_enable(mac_client_handle_t); 94 extern void mac_client_poll_disable(mac_client_handle_t); 95 96 /* 97 * Flow-related APIs for MAC clients. 98 */ 99 100 extern void mac_link_init_flows(mac_client_handle_t); 101 extern void mac_link_release_flows(mac_client_handle_t); 102 extern int mac_link_flow_add(datalink_id_t, char *, flow_desc_t *, 103 mac_resource_props_t *); 104 extern int mac_link_flow_remove(char *); 105 extern int mac_link_flow_modify(char *, mac_resource_props_t *); 106 extern boolean_t mac_link_has_flows(mac_client_handle_t); 107 108 typedef struct { 109 char fi_flow_name[MAXFLOWNAMELEN]; 110 datalink_id_t fi_link_id; 111 flow_desc_t fi_flow_desc; 112 mac_resource_props_t fi_resource_props; 113 } mac_flowinfo_t; 114 115 extern int mac_link_flow_walk(datalink_id_t, 116 int (*)(mac_flowinfo_t *, void *), void *); 117 extern int mac_link_flow_info(char *, mac_flowinfo_t *); 118 119 extern void mac_rx_client_quiesce(mac_client_handle_t); 120 extern void mac_rx_client_restart(mac_client_handle_t); 121 extern void mac_tx_client_quiesce(mac_client_handle_t); 122 extern void mac_tx_client_condemn(mac_client_handle_t); 123 extern void mac_tx_client_restart(mac_client_handle_t); 124 extern void mac_srs_perm_quiesce(mac_client_handle_t, boolean_t); 125 extern uint_t mac_hwrings_idx_get(mac_handle_t, uint_t, mac_group_handle_t *, 126 mac_ring_handle_t *, mac_ring_type_t); 127 extern int mac_hwrings_get(mac_client_handle_t, mac_group_handle_t *, 128 mac_ring_handle_t *, mac_ring_type_t); 129 extern uint_t mac_hwring_getinfo(mac_ring_handle_t); 130 extern void mac_hwring_set_passthru(mac_ring_handle_t, mac_rx_t, void *, 131 mac_resource_handle_t); 132 extern void mac_hwring_clear_passthru(mac_ring_handle_t); 133 extern void mac_client_set_flow_cb(mac_client_handle_t, mac_rx_t, void *); 134 extern void mac_client_clear_flow_cb(mac_client_handle_t); 135 136 extern void mac_hwring_setup(mac_ring_handle_t, mac_resource_handle_t, 137 mac_ring_handle_t); 138 extern void mac_hwring_teardown(mac_ring_handle_t); 139 extern int mac_hwring_disable_intr(mac_ring_handle_t); 140 extern int mac_hwring_enable_intr(mac_ring_handle_t); 141 extern int mac_hwring_start(mac_ring_handle_t); 142 extern void mac_hwring_stop(mac_ring_handle_t); 143 extern int mac_hwring_activate(mac_ring_handle_t); 144 extern void mac_hwring_quiesce(mac_ring_handle_t); 145 extern mblk_t *mac_hwring_poll(mac_ring_handle_t, int); 146 extern mblk_t *mac_hwring_tx(mac_ring_handle_t, mblk_t *); 147 extern int mac_hwring_getstat(mac_ring_handle_t, uint_t, uint64_t *); 148 extern mblk_t *mac_hwring_send_priv(mac_client_handle_t, 149 mac_ring_handle_t, mblk_t *); 150 extern void mac_hwring_set_default(mac_handle_t, mac_ring_handle_t); 151 152 #define MAC_HWRING_POLL(ring, bytes) \ 153 (((ring)->mr_info.mri_poll) \ 154 ((ring)->mr_info.mri_driver, (bytes))) 155 156 extern int mac_hwgroup_addmac(mac_group_handle_t, const uint8_t *); 157 extern int mac_hwgroup_remmac(mac_group_handle_t, const uint8_t *); 158 extern int mac_hwgroup_addvlan(mac_group_handle_t, uint16_t); 159 extern int mac_hwgroup_remvlan(mac_group_handle_t, uint16_t); 160 161 extern boolean_t mac_has_hw_vlan(mac_handle_t); 162 163 extern uint_t mac_get_num_rx_groups(mac_handle_t); 164 extern int mac_set_promisc(mac_handle_t, boolean_t); 165 166 extern void mac_set_upper_mac(mac_client_handle_t, mac_handle_t, 167 mac_resource_props_t *); 168 169 extern int mac_mark_exclusive(mac_handle_t); 170 extern void mac_unmark_exclusive(mac_handle_t); 171 172 extern uint_t mac_hwgrp_num(mac_handle_t, int); 173 extern void mac_get_hwrxgrp_info(mac_handle_t, int, uint_t *, uint_t *, 174 uint_t *, uint_t *, uint_t *, char *); 175 extern void mac_get_hwtxgrp_info(mac_handle_t, int, uint_t *, uint_t *, 176 uint_t *, uint_t *, uint_t *, char *); 177 178 extern uint_t mac_txavail_get(mac_handle_t); 179 extern uint_t mac_rxavail_get(mac_handle_t); 180 extern uint_t mac_txrsvd_get(mac_handle_t); 181 extern uint_t mac_rxrsvd_get(mac_handle_t); 182 extern uint_t mac_rxhwlnksavail_get(mac_handle_t); 183 extern uint_t mac_rxhwlnksrsvd_get(mac_handle_t); 184 extern uint_t mac_txhwlnksavail_get(mac_handle_t); 185 extern uint_t mac_txhwlnksrsvd_get(mac_handle_t); 186 187 extern int32_t mac_client_intr_cpu(mac_client_handle_t); 188 extern void mac_client_set_intr_cpu(void *, mac_client_handle_t, int32_t); 189 extern void *mac_get_devinfo(mac_handle_t); 190 191 extern boolean_t mac_is_vnic(mac_handle_t); 192 extern boolean_t mac_is_overlay(mac_handle_t); 193 extern uint32_t mac_no_notification(mac_handle_t); 194 195 extern int mac_set_prop(mac_handle_t, mac_prop_id_t, char *, void *, uint_t); 196 extern int mac_get_prop(mac_handle_t, mac_prop_id_t, char *, void *, uint_t); 197 extern int mac_prop_info(mac_handle_t, mac_prop_id_t, char *, void *, 198 uint_t, mac_propval_range_t *, uint_t *); 199 extern boolean_t mac_prop_check_size(mac_prop_id_t, uint_t, boolean_t); 200 201 extern uint64_t mac_pseudo_rx_ring_stat_get(mac_ring_handle_t, uint_t); 202 extern uint64_t mac_pseudo_tx_ring_stat_get(mac_ring_handle_t, uint_t); 203 204 #endif /* _KERNEL */ 205 206 #ifdef __cplusplus 207 } 208 #endif 209 210 #endif /* _SYS_MAC_CLIENT_PRIV_H */ 211