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 2006 Sun Microsystems, Inc. All rights reserved.
|
---|
24 | * Use is subject to license terms.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef _SYS_MAC_H
|
---|
28 | #define _SYS_MAC_H
|
---|
29 |
|
---|
30 | #pragma ident "@(#)mac.h 1.21 06/12/06 SMI"
|
---|
31 |
|
---|
32 | #include <sys/ddi.h>
|
---|
33 | #include <sys/sunddi.h>
|
---|
34 | #include <sys/stream.h>
|
---|
35 | #include <sys/flow.h>
|
---|
36 |
|
---|
37 | #ifdef _KERNEL
|
---|
38 | #include <sys/flow_impl.h>
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * MAC Services Module
|
---|
43 | */
|
---|
44 |
|
---|
45 | #ifdef __cplusplus
|
---|
46 | extern "C" {
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | /*
|
---|
50 | * MAC Information (text emitted by modinfo(1m))
|
---|
51 | */
|
---|
52 | #define MAC_INFO "MAC Services v1.21"
|
---|
53 |
|
---|
54 | /*
|
---|
55 | * MAC version identifier. This is used by mac_alloc() mac_register() to
|
---|
56 | * verify that incompatible drivers don't register.
|
---|
57 | */
|
---|
58 | #define MAC_VERSION 0x1
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * MAC-Type version identifier. This is used by mactype_alloc() and
|
---|
62 | * mactype_register() to verify that incompatible MAC-Type plugins don't
|
---|
63 | * register.
|
---|
64 | */
|
---|
65 | #define MACTYPE_VERSION 0x1
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * Statistics
|
---|
69 | */
|
---|
70 |
|
---|
71 | #define XCVR_UNDEFINED 0
|
---|
72 | #define XCVR_NONE 1
|
---|
73 | #define XCVR_10 2
|
---|
74 | #define XCVR_100T4 3
|
---|
75 | #define XCVR_100X 4
|
---|
76 | #define XCVR_100T2 5
|
---|
77 | #define XCVR_1000X 6
|
---|
78 | #define XCVR_1000T 7
|
---|
79 |
|
---|
80 | typedef enum {
|
---|
81 | LINK_STATE_UNKNOWN = -1,
|
---|
82 | LINK_STATE_DOWN,
|
---|
83 | LINK_STATE_UP
|
---|
84 | } link_state_t;
|
---|
85 |
|
---|
86 | typedef enum {
|
---|
87 | LINK_DUPLEX_UNKNOWN = 0,
|
---|
88 | LINK_DUPLEX_HALF,
|
---|
89 | LINK_DUPLEX_FULL
|
---|
90 | } link_duplex_t;
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * Maximum MAC address length
|
---|
94 | */
|
---|
95 | #define MAXMACADDRLEN 20
|
---|
96 |
|
---|
97 | #ifdef _KERNEL
|
---|
98 |
|
---|
99 | typedef struct mac_stat_info_s {
|
---|
100 | uint_t msi_stat;
|
---|
101 | char *msi_name;
|
---|
102 | uint_t msi_type; /* as defined in kstat_named_init(9F) */
|
---|
103 | uint64_t msi_default;
|
---|
104 | } mac_stat_info_t;
|
---|
105 |
|
---|
106 | /*
|
---|
107 | * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are
|
---|
108 | * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 -
|
---|
109 | * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and
|
---|
110 | * maintained by each driver. MACTYPE_STAT_MIN and above are statistics
|
---|
111 | * defined by MAC-Type plugins and maintained by each driver.
|
---|
112 | */
|
---|
113 | #define MAC_STAT_MIN 1000
|
---|
114 | #define MACTYPE_STAT_MIN 2000
|
---|
115 |
|
---|
116 | #define IS_MAC_STAT(stat) \
|
---|
117 | (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN)
|
---|
118 | #define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN)
|
---|
119 |
|
---|
120 | enum mac_driver_stat {
|
---|
121 | /* MIB-II stats (RFC 1213 and RFC 1573) */
|
---|
122 | MAC_STAT_IFSPEED = MAC_STAT_MIN,
|
---|
123 | MAC_STAT_MULTIRCV,
|
---|
124 | MAC_STAT_BRDCSTRCV,
|
---|
125 | MAC_STAT_MULTIXMT,
|
---|
126 | MAC_STAT_BRDCSTXMT,
|
---|
127 | MAC_STAT_NORCVBUF,
|
---|
128 | MAC_STAT_IERRORS,
|
---|
129 | MAC_STAT_UNKNOWNS,
|
---|
130 | MAC_STAT_NOXMTBUF,
|
---|
131 | MAC_STAT_OERRORS,
|
---|
132 | MAC_STAT_COLLISIONS,
|
---|
133 | MAC_STAT_RBYTES,
|
---|
134 | MAC_STAT_IPACKETS,
|
---|
135 | MAC_STAT_OBYTES,
|
---|
136 | MAC_STAT_OPACKETS
|
---|
137 | };
|
---|
138 |
|
---|
139 | #define MAC_NSTAT (MAC_STAT_OPACKETS - MAC_STAT_IFSPEED + 1)
|
---|
140 |
|
---|
141 | #define MAC_STAT_ISACOUNTER(_stat) ( \
|
---|
142 | (_stat) == MAC_STAT_MULTIRCV || \
|
---|
143 | (_stat) == MAC_STAT_BRDCSTRCV || \
|
---|
144 | (_stat) == MAC_STAT_MULTIXMT || \
|
---|
145 | (_stat) == MAC_STAT_BRDCSTXMT || \
|
---|
146 | (_stat) == MAC_STAT_NORCVBUF || \
|
---|
147 | (_stat) == MAC_STAT_IERRORS || \
|
---|
148 | (_stat) == MAC_STAT_UNKNOWNS || \
|
---|
149 | (_stat) == MAC_STAT_NOXMTBUF || \
|
---|
150 | (_stat) == MAC_STAT_OERRORS || \
|
---|
151 | (_stat) == MAC_STAT_COLLISIONS || \
|
---|
152 | (_stat) == MAC_STAT_RBYTES || \
|
---|
153 | (_stat) == MAC_STAT_IPACKETS || \
|
---|
154 | (_stat) == MAC_STAT_OBYTES || \
|
---|
155 | (_stat) == MAC_STAT_OPACKETS)
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * Immutable information. (This may not be modified after registration).
|
---|
159 | */
|
---|
160 | typedef struct mac_info_s {
|
---|
161 | uint_t mi_media;
|
---|
162 | uint_t mi_sdu_min;
|
---|
163 | uint_t mi_sdu_max;
|
---|
164 | uint_t mi_addr_length;
|
---|
165 | uint8_t *mi_unicst_addr;
|
---|
166 | uint8_t *mi_brdcst_addr;
|
---|
167 | } mac_info_t;
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * MAC layer capabilities. These capabilities are handled by the drivers'
|
---|
171 | * mc_capab_get() callbacks. Some capabilities require the driver to fill
|
---|
172 | * in a given data structure, and others are simply boolean capabilities.
|
---|
173 | * Note that capability values must be powers of 2 so that consumers and
|
---|
174 | * providers of this interface can keep track of which capabilities they
|
---|
175 | * care about by keeping a bitfield of these things around somewhere.
|
---|
176 | */
|
---|
177 | typedef enum {
|
---|
178 | MAC_CAPAB_HCKSUM = 0x01, /* data is a uint32_t for the txflags */
|
---|
179 | MAC_CAPAB_POLL = 0x02, /* boolean only, no data */
|
---|
180 | MAC_CAPAB_MULTIADDRESS = 0x04, /* data is multiaddress_capab_t */
|
---|
181 | MAC_CAPAB_RX_CLASSIFY = 0x08 /* data is mac_rx_classify_t */
|
---|
182 |
|
---|
183 | /* add new capabilities here */
|
---|
184 | } mac_capab_t;
|
---|
185 |
|
---|
186 | typedef int mac_addr_slot_t;
|
---|
187 |
|
---|
188 | /* mma_flags values */
|
---|
189 | #define MMAC_SLOT_USED 0x1 /* address slot used */
|
---|
190 | #define MMAC_SLOT_UNUSED 0x2 /* free address slot */
|
---|
191 | #define MMAC_VENDOR_ADDR 0x4 /* address returned is vendor supplied */
|
---|
192 |
|
---|
193 | typedef struct mac_multi_address_s {
|
---|
194 | mac_addr_slot_t mma_slot; /* slot for add/remove/get/set */
|
---|
195 | uint_t mma_addrlen;
|
---|
196 | uint8_t mma_addr[MAXMACADDRLEN];
|
---|
197 | uint_t mma_flags;
|
---|
198 | } mac_multi_addr_t;
|
---|
199 |
|
---|
200 | typedef int (*maddr_reserve_t)(void *, mac_multi_addr_t *);
|
---|
201 | typedef int (*maddr_add_t)(void *, mac_multi_addr_t *);
|
---|
202 | typedef int (*maddr_remove_t)(void *, mac_addr_slot_t);
|
---|
203 | typedef int (*maddr_modify_t)(void *, mac_multi_addr_t *);
|
---|
204 | typedef int (*maddr_get_t)(void *, mac_multi_addr_t *);
|
---|
205 |
|
---|
206 | /* maddr_flag values */
|
---|
207 | #define MADDR_VENDOR_ADDR 0x01 /* addr returned is vendor supplied */
|
---|
208 |
|
---|
209 | /* multiple mac address: add/remove/set/get mac address */
|
---|
210 | typedef struct multiaddress_capab_s {
|
---|
211 | int maddr_naddr; /* total addresses */
|
---|
212 | int maddr_naddrfree; /* free address slots */
|
---|
213 | uint_t maddr_flag; /* MADDR_VENDOR_ADDR bit can be set */
|
---|
214 | /* driver entry points */
|
---|
215 | void *maddr_handle; /* cookie to be used for the calls */
|
---|
216 | maddr_reserve_t maddr_reserve; /* reserve a factory address */
|
---|
217 | maddr_add_t maddr_add; /* add a new unicst address */
|
---|
218 | maddr_remove_t maddr_remove; /* remove an added address */
|
---|
219 | maddr_modify_t maddr_modify; /* modify an added address */
|
---|
220 | maddr_get_t maddr_get; /* get address from specified slot */
|
---|
221 | } multiaddress_capab_t;
|
---|
222 |
|
---|
223 | /*
|
---|
224 | * MAC driver entry point types.
|
---|
225 | */
|
---|
226 | typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *);
|
---|
227 | typedef int (*mac_start_t)(void *);
|
---|
228 | typedef void (*mac_stop_t)(void *);
|
---|
229 | typedef int (*mac_setpromisc_t)(void *, boolean_t);
|
---|
230 | typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *);
|
---|
231 | typedef int (*mac_unicst_t)(void *, const uint8_t *);
|
---|
232 | typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *);
|
---|
233 | typedef void (*mac_resources_t)(void *);
|
---|
234 | typedef mblk_t *(*mac_tx_t)(void *, mblk_t *);
|
---|
235 | typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *);
|
---|
236 |
|
---|
237 | /*
|
---|
238 | * Drivers must set all of these callbacks except for mc_resources,
|
---|
239 | * mc_ioctl, and mc_getcapab, which are optional. If any of these optional
|
---|
240 | * callbacks are set, their appropriate flags must be set in mc_callbacks.
|
---|
241 | * Any future additions to this list must also be accompanied by an
|
---|
242 | * associated mc_callbacks flag so that the framework can grow without
|
---|
243 | * affecting the binary compatibility of the interface.
|
---|
244 | */
|
---|
245 | typedef struct mac_callbacks_s {
|
---|
246 | uint_t mc_callbacks; /* Denotes which callbacks are set */
|
---|
247 | mac_getstat_t mc_getstat; /* Get the value of a statistic */
|
---|
248 | mac_start_t mc_start; /* Start the device */
|
---|
249 | mac_stop_t mc_stop; /* Stop the device */
|
---|
250 | mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */
|
---|
251 | mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */
|
---|
252 | mac_unicst_t mc_unicst; /* Set the unicast MAC address */
|
---|
253 | mac_tx_t mc_tx; /* Transmit a packet */
|
---|
254 | mac_resources_t mc_resources; /* Get the device resources */
|
---|
255 | mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */
|
---|
256 | mac_getcapab_t mc_getcapab; /* Get capability information */
|
---|
257 | } mac_callbacks_t;
|
---|
258 |
|
---|
259 |
|
---|
260 | /* MAC classification capabilities */
|
---|
261 |
|
---|
262 | typedef enum {
|
---|
263 | MAC_HW_CLASSIFIER,
|
---|
264 | MAC_SW_CLASSIFIER,
|
---|
265 | MAC_NO_CLASSIFIER
|
---|
266 | } mac_classify_status_t;
|
---|
267 |
|
---|
268 | typedef void (*mac_rx_func_t)(void *, mac_resource_handle_t,
|
---|
269 | mblk_t *);
|
---|
270 |
|
---|
271 | typedef int (*mac_rx_classify_add_t)(void *, mac_resource_handle_t,
|
---|
272 | flow_desc_t *, mac_rx_func_t, void *,
|
---|
273 | mac_resource_handle_t, mac_rule_handle_t *);
|
---|
274 |
|
---|
275 | typedef int (*mac_rx_classify_remove_t)(void *,
|
---|
276 | mac_resource_handle_t, mac_rule_handle_t);
|
---|
277 |
|
---|
278 | typedef void (*mac_rx_classify_update_t)(void *, mac_rx_func_t,
|
---|
279 | void *, mac_resource_handle_t);
|
---|
280 |
|
---|
281 | typedef struct mac_rx_classify_s {
|
---|
282 | flow_mask_t mrc_flow_classes;
|
---|
283 | mac_rx_classify_add_t mrc_addrulefn; /* adding a rule */
|
---|
284 | mac_rx_classify_remove_t mrc_remrulefn; /* removing a rule */
|
---|
285 | mac_rx_classify_update_t mrc_updatefn; /* Updating a ring */
|
---|
286 | } mac_rx_classify_t;
|
---|
287 |
|
---|
288 | /*
|
---|
289 | * Flags for mc_callbacks. Requiring drivers to set the flags associated
|
---|
290 | * with optional callbacks initialized in the structure allows the mac
|
---|
291 | * module to add optional callbacks in the future without requiring drivers
|
---|
292 | * to recompile.
|
---|
293 | */
|
---|
294 | #define MC_RESOURCES 0x001
|
---|
295 | #define MC_IOCTL 0x002
|
---|
296 | #define MC_GETCAPAB 0x004
|
---|
297 |
|
---|
298 | typedef struct mac_register_s {
|
---|
299 | uint_t m_version; /* set by mac_alloc() */
|
---|
300 | const char *m_type_ident;
|
---|
301 | void *m_driver; /* Driver private data */
|
---|
302 | dev_info_t *m_dip;
|
---|
303 | uint_t m_instance;
|
---|
304 | uint8_t *m_src_addr;
|
---|
305 | uint8_t *m_dst_addr;
|
---|
306 | mac_callbacks_t *m_callbacks;
|
---|
307 | uint_t m_min_sdu;
|
---|
308 | uint_t m_max_sdu;
|
---|
309 | void *m_pdata;
|
---|
310 | size_t m_pdata_size;
|
---|
311 | } mac_register_t;
|
---|
312 |
|
---|
313 | /*
|
---|
314 | * MAC interface callback types.
|
---|
315 | */
|
---|
316 | typedef enum {
|
---|
317 | MAC_NOTE_LINK,
|
---|
318 | MAC_NOTE_PROMISC,
|
---|
319 | MAC_NOTE_UNICST,
|
---|
320 | MAC_NOTE_TX,
|
---|
321 | MAC_NOTE_RESOURCE,
|
---|
322 | MAC_NOTE_DEVPROMISC,
|
---|
323 | MAC_NOTE_FASTPATH_FLUSH,
|
---|
324 | MAC_NOTE_VNIC,
|
---|
325 | MAC_NNOTE /* must be the last entry */
|
---|
326 | } mac_notify_type_t;
|
---|
327 |
|
---|
328 | typedef void (*mac_notify_t)(void *, mac_notify_type_t);
|
---|
329 | typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *);
|
---|
330 | typedef void (*mac_txloop_t)(void *, mblk_t *);
|
---|
331 | typedef void (*mac_blank_t)(void *, time_t, uint_t, int);
|
---|
332 | typedef mblk_t *(*mac_receive_t)(void *, int);
|
---|
333 |
|
---|
334 | /*
|
---|
335 | * MAC promiscuous types
|
---|
336 | */
|
---|
337 | typedef enum {
|
---|
338 | MAC_PROMISC = 0x01, /* MAC instance is promiscuous */
|
---|
339 | MAC_DEVPROMISC = 0x02 /* Device is promiscuous */
|
---|
340 | } mac_promisc_type_t;
|
---|
341 |
|
---|
342 | /*
|
---|
343 | * MAC resource types
|
---|
344 | */
|
---|
345 | typedef enum {
|
---|
346 | MAC_RX_FIFO = 1
|
---|
347 | } mac_resource_type_t;
|
---|
348 |
|
---|
349 | typedef struct mac_rx_fifo_s {
|
---|
350 | mac_resource_type_t mrf_type; /* MAC_RX_FIFO */
|
---|
351 | mac_blank_t mrf_blank;
|
---|
352 | mac_receive_t mrf_receive;
|
---|
353 | void *mrf_arg;
|
---|
354 | time_t mrf_normal_blank_time;
|
---|
355 | uint_t mrf_normal_pkt_count;
|
---|
356 | uint32_t mrf_bw_limit;
|
---|
357 | uint32_t mrf_bw_guarantee;
|
---|
358 | uint32_t mrf_bw_shares;
|
---|
359 | uint32_t mrf_flow_priority;
|
---|
360 | uint32_t mrf_bw_control_type;
|
---|
361 |
|
---|
362 | /*
|
---|
363 | * The CPU this flow is to be processed on. With intrd and future
|
---|
364 | * things, we should know which CPU the flow needs to be processed
|
---|
365 | * and get a squeue assigned on that CPU.
|
---|
366 | */
|
---|
367 | uint_t mrf_cpu_id;
|
---|
368 | flow_desc_t mrf_flow_desc; /* Flow desc for this ring */
|
---|
369 | } mac_rx_fifo_t;
|
---|
370 |
|
---|
371 | typedef struct mac_txinfo_s {
|
---|
372 | mac_tx_t mt_fn;
|
---|
373 | void *mt_arg;
|
---|
374 | } mac_txinfo_t;
|
---|
375 |
|
---|
376 | typedef union mac_resource_u {
|
---|
377 | mac_resource_type_t mr_type;
|
---|
378 | mac_rx_fifo_t mr_fifo;
|
---|
379 | } mac_resource_t;
|
---|
380 |
|
---|
381 | typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *);
|
---|
382 | typedef int (*mac_resource_bind_t)(void *,
|
---|
383 | mac_resource_handle_t, processorid_t);
|
---|
384 |
|
---|
385 | typedef enum {
|
---|
386 | MAC_ADDRTYPE_UNICAST,
|
---|
387 | MAC_ADDRTYPE_MULTICAST,
|
---|
388 | MAC_ADDRTYPE_BROADCAST
|
---|
389 | } mac_addrtype_t;
|
---|
390 |
|
---|
391 | typedef struct mac_header_info_s {
|
---|
392 | size_t mhi_hdrsize;
|
---|
393 | size_t mhi_pktsize;
|
---|
394 | const uint8_t *mhi_daddr;
|
---|
395 | const uint8_t *mhi_saddr;
|
---|
396 | uint32_t mhi_origsap;
|
---|
397 | uint32_t mhi_bindsap;
|
---|
398 | mac_addrtype_t mhi_dsttype;
|
---|
399 | } mac_header_info_t;
|
---|
400 |
|
---|
401 | /*
|
---|
402 | * MAC-Type plugin interfaces
|
---|
403 | */
|
---|
404 |
|
---|
405 | typedef int (*mtops_addr_verify_t)(const void *, void *);
|
---|
406 | typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *);
|
---|
407 | typedef mblk_t *(*mtops_header_t)(const void *, const void *,
|
---|
408 | uint32_t, void *, mblk_t *, size_t);
|
---|
409 | typedef int (*mtops_header_info_t)(mblk_t *, void *,
|
---|
410 | mac_header_info_t *);
|
---|
411 | typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t);
|
---|
412 | typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *);
|
---|
413 |
|
---|
414 | typedef struct mactype_ops_s {
|
---|
415 | uint_t mtops_ops;
|
---|
416 | /*
|
---|
417 | * mtops_unicst_verify() returns 0 if the given address is a valid
|
---|
418 | * unicast address, or a non-zero errno otherwise.
|
---|
419 | */
|
---|
420 | mtops_addr_verify_t mtops_unicst_verify;
|
---|
421 | /*
|
---|
422 | * mtops_multicst_verify() returns 0 if the given address is a
|
---|
423 | * valid multicast address, or a non-zero errno otherwise. If the
|
---|
424 | * media doesn't support multicast, ENOTSUP should be returned (for
|
---|
425 | * example).
|
---|
426 | */
|
---|
427 | mtops_addr_verify_t mtops_multicst_verify;
|
---|
428 | /*
|
---|
429 | * mtops_sap_verify() returns B_TRUE if the given SAP is a valid
|
---|
430 | * SAP value, or B_FALSE otherwise.
|
---|
431 | */
|
---|
432 | mtops_sap_verify_t mtops_sap_verify;
|
---|
433 | /*
|
---|
434 | * mtops_header() is used to allocate and construct a MAC header.
|
---|
435 | */
|
---|
436 | mtops_header_t mtops_header;
|
---|
437 | /*
|
---|
438 | * mtops_header_info() is used to gather information on a given MAC
|
---|
439 | * header.
|
---|
440 | */
|
---|
441 | mtops_header_info_t mtops_header_info;
|
---|
442 | /*
|
---|
443 | * mtops_pdata_verify() is used to verify the validity of MAC
|
---|
444 | * plugin data. It is called by mac_register() if the driver has
|
---|
445 | * supplied MAC plugin data, and also by mac_pdata_update() when
|
---|
446 | * drivers update the data.
|
---|
447 | */
|
---|
448 | mtops_pdata_verify_t mtops_pdata_verify;
|
---|
449 | /*
|
---|
450 | * mtops_header_cook() is an optional callback that converts (or
|
---|
451 | * "cooks") the given raw header (as sent by a raw DLPI consumer)
|
---|
452 | * into one that is appropriate to send down to the MAC driver.
|
---|
453 | * Following the example above, an Ethernet header sent down by a
|
---|
454 | * DLPI consumer would be converted to whatever header the MAC
|
---|
455 | * driver expects.
|
---|
456 | */
|
---|
457 | mtops_header_modify_t mtops_header_cook;
|
---|
458 | /*
|
---|
459 | * mtops_header_uncook() is an optional callback that does the
|
---|
460 | * opposite of mtops_header_cook(). It "uncooks" a given MAC
|
---|
461 | * header (as received from the driver) for consumption by raw DLPI
|
---|
462 | * consumers. For example, for a non-Ethernet plugin that wants
|
---|
463 | * raw DLPI consumers to be fooled into thinking that the device
|
---|
464 | * provides Ethernet access, this callback would modify the given
|
---|
465 | * mblk_t such that the MAC header is converted to an Ethernet
|
---|
466 | * header.
|
---|
467 | */
|
---|
468 | mtops_header_modify_t mtops_header_uncook;
|
---|
469 | } mactype_ops_t;
|
---|
470 |
|
---|
471 | /*
|
---|
472 | * mtops_ops exists for the plugin to enumerate the optional callback
|
---|
473 | * entrypoints it has defined. This allows the mac module to define
|
---|
474 | * additional plugin entrypoints in mactype_ops_t without breaking backward
|
---|
475 | * compatibility with old plugins.
|
---|
476 | */
|
---|
477 | #define MTOPS_PDATA_VERIFY 0x001
|
---|
478 | #define MTOPS_HEADER_COOK 0x002
|
---|
479 | #define MTOPS_HEADER_UNCOOK 0x004
|
---|
480 |
|
---|
481 | typedef struct mactype_register_s {
|
---|
482 | uint_t mtr_version; /* set by mactype_alloc() */
|
---|
483 | const char *mtr_ident;
|
---|
484 | mactype_ops_t *mtr_ops;
|
---|
485 | uint_t mtr_mactype;
|
---|
486 | uint_t mtr_addrlen;
|
---|
487 | uint8_t *mtr_brdcst_addr;
|
---|
488 | mac_stat_info_t *mtr_stats;
|
---|
489 | size_t mtr_statcount;
|
---|
490 | } mactype_register_t;
|
---|
491 |
|
---|
492 | /*
|
---|
493 | * MAC classification
|
---|
494 | */
|
---|
495 |
|
---|
496 | typedef struct mac_rxclassify_fn_t {
|
---|
497 | mac_rx_classify_t mcf_classify; /* classif'n capabilities */
|
---|
498 | void *mcf_arg; /* rule add func first arg */
|
---|
499 | } mac_rxclassify_fn_t;
|
---|
500 |
|
---|
501 | #define mcf_flow_classes mcf_classify.mrc_flow_classes
|
---|
502 | #define mcf_addrulefn mcf_classify.mrc_addrulefn
|
---|
503 | #define mcf_remrulefn mcf_classify.mrc_remrulefn
|
---|
504 | #define mcf_updatefn mcf_classify.mrc_updatefn
|
---|
505 |
|
---|
506 | /*
|
---|
507 | * Structure describing the receive ring. It has:
|
---|
508 | * . the type of classification to dispatch traffic for this ring,
|
---|
509 | * . the driver's ring mac_resource_t with the driver's ring handle and its
|
---|
510 | * polling/blanking access functions.
|
---|
511 | * . handle to the stack's ring's client (e.g ill_ring)
|
---|
512 | * . pointer to the flow entry controlling this ring.
|
---|
513 | * XXX This needs REHHOLD()'ing.
|
---|
514 | */
|
---|
515 | struct mac_rx_ring_desc_s {
|
---|
516 | mac_classify_status_t mrd_classify_type;
|
---|
517 | mac_resource_t mrd_driver_rx;
|
---|
518 | mac_resource_handle_t mrd_client_handle;
|
---|
519 | flow_entry_t *mrd_flow_entry;
|
---|
520 | void *mrd_sringp;
|
---|
521 | };
|
---|
522 |
|
---|
523 | /*
|
---|
524 | * Client interface functions.
|
---|
525 | */
|
---|
526 | extern int mac_open(const char *, uint_t, mac_handle_t *);
|
---|
527 | extern void mac_close(mac_handle_t);
|
---|
528 | extern const mac_info_t *mac_info(mac_handle_t);
|
---|
529 | extern processorid_t mac_intr_cpuid(mac_handle_t);
|
---|
530 | extern boolean_t mac_info_get(const char *, mac_info_t *);
|
---|
531 | extern uint64_t mac_stat_get(mac_handle_t, uint_t);
|
---|
532 | extern int mac_start(mac_handle_t);
|
---|
533 | extern void mac_stop(mac_handle_t);
|
---|
534 | extern int mac_promisc_set(mac_handle_t, boolean_t,
|
---|
535 | mac_promisc_type_t);
|
---|
536 | extern boolean_t mac_promisc_get(mac_handle_t,
|
---|
537 | mac_promisc_type_t);
|
---|
538 | extern int mac_multicst_add(mac_handle_t, const uint8_t *);
|
---|
539 | extern int mac_multicst_remove(mac_handle_t,
|
---|
540 | const uint8_t *);
|
---|
541 | extern boolean_t mac_unicst_verify(mac_handle_t,
|
---|
542 | const uint8_t *, uint_t);
|
---|
543 | extern int mac_unicst_set(mac_handle_t, const uint8_t *);
|
---|
544 | extern void mac_unicst_get(mac_handle_t, uint8_t *);
|
---|
545 | extern void mac_dest_get(mac_handle_t, uint8_t *);
|
---|
546 | extern void mac_resources(mac_handle_t);
|
---|
547 | extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *);
|
---|
548 | extern const mac_txinfo_t *mac_tx_get(mac_handle_t);
|
---|
549 | extern const mac_txinfo_t *mac_vnic_tx_get(mac_handle_t);
|
---|
550 | extern link_state_t mac_link_get(mac_handle_t);
|
---|
551 | extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t,
|
---|
552 | void *);
|
---|
553 | extern void mac_notify_remove(mac_handle_t,
|
---|
554 | mac_notify_handle_t);
|
---|
555 | extern void mac_notify(mac_handle_t);
|
---|
556 | extern mac_rx_handle_t mac_rx_add(mac_handle_t, mac_rx_t, void *);
|
---|
557 | extern mac_rx_handle_t mac_active_rx_add(mac_handle_t, mac_rx_t,
|
---|
558 | void *);
|
---|
559 | extern void mac_rx_remove(mac_handle_t, mac_rx_handle_t,
|
---|
560 | boolean_t);
|
---|
561 | extern void mac_rx_remove_wait(mac_handle_t);
|
---|
562 | extern mblk_t *mac_txloop(void *, mblk_t *);
|
---|
563 | extern mac_txloop_handle_t mac_txloop_add(mac_handle_t, mac_txloop_t,
|
---|
564 | void *);
|
---|
565 | extern void mac_txloop_remove(mac_handle_t,
|
---|
566 | mac_txloop_handle_t);
|
---|
567 | extern boolean_t mac_active_set(mac_handle_t);
|
---|
568 | extern boolean_t mac_active_shareable_set(mac_handle_t);
|
---|
569 | extern void mac_active_clear(mac_handle_t);
|
---|
570 | extern void mac_active_rx(void *, mac_resource_handle_t,
|
---|
571 | mblk_t *);
|
---|
572 | extern boolean_t mac_vnic_set(mac_handle_t, mac_txinfo_t *,
|
---|
573 | mac_getcapab_t, void *);
|
---|
574 | extern void mac_vnic_clear(mac_handle_t);
|
---|
575 | extern void mac_resource_set(mac_handle_t,
|
---|
576 | mac_resource_add_t, mac_resource_bind_t, void *);
|
---|
577 | extern void mac_get_cpus(mac_handle_t, net_bind_cpu_t *);
|
---|
578 | extern void mac_set_cpus(mac_handle_t, net_bind_cpu_t *);
|
---|
579 | mac_rx_ring_desc_t *mac_get_ring_desc(mac_handle_t);
|
---|
580 | extern dev_info_t *mac_devinfo_get(mac_handle_t);
|
---|
581 | extern boolean_t mac_capab_get(mac_handle_t, mac_capab_t,
|
---|
582 | void *);
|
---|
583 | extern boolean_t mac_vnic_capab_get(mac_handle_t, mac_capab_t,
|
---|
584 | void *);
|
---|
585 | extern boolean_t mac_sap_verify(mac_handle_t, uint32_t,
|
---|
586 | uint32_t *);
|
---|
587 | extern mblk_t *mac_header(mac_handle_t, const uint8_t *,
|
---|
588 | uint32_t, mblk_t *, size_t);
|
---|
589 | extern int mac_header_info(mac_handle_t, mblk_t *,
|
---|
590 | mac_header_info_t *);
|
---|
591 | extern mblk_t *mac_header_cook(mac_handle_t, mblk_t *);
|
---|
592 | extern mblk_t *mac_header_uncook(mac_handle_t, mblk_t *);
|
---|
593 |
|
---|
594 | /*
|
---|
595 | * Driver interface functions.
|
---|
596 | */
|
---|
597 | extern mac_register_t *mac_alloc(uint_t);
|
---|
598 | extern void mac_free(mac_register_t *);
|
---|
599 | extern int mac_register(mac_register_t *, mac_handle_t *);
|
---|
600 | extern int mac_unregister(mac_handle_t);
|
---|
601 | extern int mac_disable(mac_handle_t);
|
---|
602 | extern void mac_rx(mac_handle_t, mac_resource_handle_t,
|
---|
603 | mblk_t *);
|
---|
604 | extern void mac_rx_default(mac_handle_t,
|
---|
605 | mac_resource_handle_t, mblk_t *, boolean_t);
|
---|
606 | extern void mac_link_update(mac_handle_t, link_state_t);
|
---|
607 | extern void mac_unicst_update(mac_handle_t,
|
---|
608 | const uint8_t *);
|
---|
609 | extern void mac_tx_update(mac_handle_t);
|
---|
610 | extern void mac_resource_update(mac_handle_t);
|
---|
611 | extern mac_resource_handle_t mac_client_resource_add(mac_handle_t,
|
---|
612 | mac_resource_t *);
|
---|
613 | extern mac_resource_handle_t mac_resource_add(mac_handle_t,
|
---|
614 | mac_resource_t *);
|
---|
615 | extern int mac_resource_bind(mac_handle_t,
|
---|
616 | mac_resource_handle_t, processorid_t);
|
---|
617 | extern int mac_pdata_update(mac_handle_t, void *,
|
---|
618 | size_t);
|
---|
619 | extern void mac_multicst_refresh(mac_handle_t,
|
---|
620 | mac_multicst_t, void *, boolean_t);
|
---|
621 | extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t,
|
---|
622 | void *);
|
---|
623 | extern void mac_promisc_refresh(mac_handle_t,
|
---|
624 | mac_setpromisc_t, void *);
|
---|
625 | extern void mac_init_ops(struct dev_ops *, const char *);
|
---|
626 | extern void mac_fini_ops(struct dev_ops *);
|
---|
627 | extern mactype_register_t *mactype_alloc(uint_t);
|
---|
628 | extern void mactype_free(mactype_register_t *);
|
---|
629 | extern int mactype_register(mactype_register_t *);
|
---|
630 | extern int mactype_unregister(const char *);
|
---|
631 | extern mac_classify_status_t mac_rx_classify_flow_add(mac_handle_t,
|
---|
632 | flow_entry_t *, boolean_t, mac_rx_func_t, void *,
|
---|
633 | mac_resource_handle_t, net_bind_cpu_t *);
|
---|
634 |
|
---|
635 | extern int mac_rx_classify_flow_rem(mac_handle_t,
|
---|
636 | flow_entry_t *);
|
---|
637 | extern int mac_rx_classify_flow_update(mac_handle_t,
|
---|
638 | flow_entry_t *, mac_rx_func_t, void *, mac_resource_handle_t, boolean_t);
|
---|
639 |
|
---|
640 | #endif /* _KERNEL */
|
---|
641 |
|
---|
642 | #ifdef __cplusplus
|
---|
643 | }
|
---|
644 | #endif
|
---|
645 |
|
---|
646 | #endif /* _SYS_MAC_H */
|
---|