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 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* 27 * gldpriv.h - Private interfaces/structures needed by gld.c 28 * 29 * The definitions in this file are private to GLD and may change at any time. 30 * They must not be used by any driver. 31 */ 32 33 #ifndef _SYS_GLDPRIV_H 34 #define _SYS_GLDPRIV_H 35 36 #pragma ident "%Z%%M% %I% %E% SMI" 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #ifdef DEBUG 43 #define GLD_DEBUG 1 44 #endif 45 46 /* 47 * The version number should not be changed. 48 */ 49 #define GLD_VERSION_200 0x200 /* version 2.0 */ 50 #define GLD_VERSION GLD_VERSION_200 /* current version */ 51 #define GLD_VERSION_STRING "v2" /* in modinfo string */ 52 53 /* gld_global_options bits */ 54 #define GLD_OPT_NO_IPQ 0x00000001 /* don't use IP shortcut */ 55 #define GLD_OPT_NO_FASTPATH 0x00000002 /* don't implement fastpath */ 56 #define GLD_OPT_NO_ETHRXSNAP 0x00000008 /* don't interp SNAP on ether */ 57 58 /* gld per instance options */ 59 #define GLDOPT_FAST_RECV 0x40 60 #define GLDOPT_CANONICAL_ADDR 0x08 61 #define GLDOPT_MDT 0x100 62 63 /* 64 * This version of GLD allows a "Virtual-LAN-PPA" to be specified in 65 * the same manner as Cassini: the virtual PPA number is composed of 66 * the VLAN tag number (1-4094), multiplied by 1000(!), plus the real 67 * (hardware) PPA. Thus "bge23001" refers to the "device" which 68 * transports packets with tag VLAN "23" over the hardware of "bge1". 69 * 70 * This scheme limits the number of physical devices of a single type to 71 * 1000 e.g. bge0 .. bge999 (since bge1000 would instead be interpreted 72 * as VLAN1 over bge0). 73 */ 74 #define GLD_VLAN_SCALE 1000 75 #define GLD_MAX_PPA (GLD_VLAN_SCALE-1) 76 77 /* 78 * Minor numbers: 79 * 80 * For each device type, GLD creates a single "style 2" node with minor 0. 81 * For each instance of that device type, GLD also creates a "style 1" 82 * node with minor number one greater than the PPA. Thus, nodes with 83 * minor numbers 0..1000 may exist in the /dev* filesystem. 84 * 85 * So, on open: 86 * 87 * Minor 0 implies DLPI "style 2": the STREAM is not intrinsically 88 * associated with any particular device/PPA. The association is set 89 * (and may be changed) dynamically, by DLPI_ATTACH/DETACH messages. 90 * 91 * Minors 1..1000 are "style 1", where the PPA is entirely defined by 92 * the minor; GLD defines the mapping as PPA=minor-1 (minor=PPA+1). 93 * Note that the upper bound of 1000 is (now) limited by the VLAN 94 * mapping scheme set out above. 95 * 96 * GLD devices are "self-cloning": each new open will cause a new minor 97 * number to be allocated; these are selected from the range 1001..0x3ffff. 98 * This minor number is only associated with the open stream and doesn't 99 * appear in the /dev* filesystem; manually created nodes with minors in 100 * this range will be rejected by gld_open(). 101 */ 102 #define GLD_USE_STYLE2 0 103 104 #define GLD_MIN_STYLE1_MINOR 1 105 #define GLD_MAX_STYLE1_MINOR (GLD_MAX_PPA+1) 106 107 #define GLD_STYLE1_MINOR_TO_PPA(minor) (minor - 1) 108 #define GLD_STYLE1_PPA_TO_MINOR(ppa) (ppa + 1) 109 110 #define GLD_MIN_CLONE_MINOR (GLD_MAX_STYLE1_MINOR+1) 111 #define GLD_MAX_CLONE_MINOR 0x3ffff 112 113 /* gldm_GLD_flags */ 114 #define GLD_MAC_READY 0x0001 /* this mac has succeeded gld_register */ 115 #define GLD_INTR_READY 0x0001 /* v0 compat name */ 116 #define GLD_INTR_WAIT 0x0002 /* v1: waiting for interrupt to do scheduling */ 117 #define GLD_LOCK_INITED 0x0004 /* maclock is currently initialized */ 118 #define GLD_UNREGISTERED 0x0008 /* this mac has succeeded gld_unregister */ 119 120 /* This is the largest macaddr currently supported by GLD */ 121 #define GLD_MAX_ADDRLEN 32 /* Largest mac addr in all media */ 122 123 #define GLD_MAX_MULTICAST 64 /* default multicast table size */ 124 125 /* multicast structures */ 126 typedef struct gld_multicast_addr { 127 int gldm_refcnt; /* number of streams referring */ 128 /* to this per-mac entry */ 129 unsigned char gldm_addr[GLD_MAX_ADDRLEN]; 130 } gld_mcast_t; 131 132 /* gld_flag bits -- GLD PRIVATE */ 133 #define GLD_RAW 0x0001 /* lower stream is in RAW mode */ 134 #define GLD_FAST 0x0002 /* use "fast" path */ 135 #define GLD_PROM_PHYS 0x0004 /* stream is in physical promiscuous mode */ 136 #define GLD_PROM_SAP 0x0008 137 #define GLD_PROM_MULT 0x0010 138 #define GLD_STR_CLOSING 0x0020 /* stream is closing; don't putnext */ 139 140 /* 141 * gld structure. Used to define the per-stream information required to 142 * implement DLPI. 143 */ 144 typedef struct gld { 145 struct gld *gld_next, *gld_prev; 146 caddr_t gld_dummy1; 147 int32_t gld_state; /* DL_UNATTACHED, DL_UNBOUND, DL_IDLE */ 148 int32_t gld_style; /* open style 1 or style 2 */ 149 int32_t gld_minor; /* cloned minor number */ 150 int32_t gld_type; /* DL_ETHER, DL_TPR, DL_FDDI, etc */ 151 int32_t gld_sap; /* Bound SAP */ 152 int32_t gld_flags; /* flags defined in gldpriv.h */ 153 int32_t gld_multicnt; /* # of stream multicast addresses */ 154 gld_mcast_t **gld_mcast; /* multicast table or NULL */ 155 queue_t *gld_qptr; /* pointer to streams queue */ 156 caddr_t gld_dummy2; 157 caddr_t gld_dummy3; 158 struct gld_mac_info *gld_mac_info; /* if not DL_UNATTACHED */ 159 caddr_t gld_dummy4; 160 struct glddevice *gld_device; /* per-major structure */ 161 162 volatile boolean_t gld_xwait; /* want an xmit qenable */ 163 volatile boolean_t gld_sched_ran; /* gld_sched examined this Q */ 164 volatile boolean_t gld_in_unbind; /* DL_UNBIND in progress */ 165 volatile uint32_t gld_wput_count; /* number of threads in wput=>start */ 166 volatile boolean_t gld_in_wsrv; /* Q thread currently running in wsrv */ 167 168 boolean_t gld_ethertype; /* ethertype/LLC stream */ 169 uint32_t gld_notifications; 170 uint32_t gld_upri; /* user priority */ 171 void *gld_vlan; 172 int (*gld_send)(); 173 } gld_t; 174 175 /* 176 * definitions for the per driver class structure 177 */ 178 typedef struct glddevice { 179 struct glddevice *gld_next, *gld_prev; 180 int gld_ndevice; /* number of mac devices linked */ 181 gld_mac_info_t *gld_mac_next, *gld_mac_prev; /* the various macs */ 182 gld_t *gld_str_next, *gld_str_prev; /* open, unattached, */ 183 /* style 2 streams */ 184 char gld_name[16]; /* name of device */ 185 kmutex_t gld_devlock; /* used to serialize read/write locks */ 186 int gld_nextminor; /* next unused minor number for clone */ 187 int gld_major; /* device's major number */ 188 int gld_multisize; /* # of multicast entries to alloc */ 189 int gld_type; /* for use before attach */ 190 int gld_minsdu; 191 int gld_maxsdu; 192 int gld_addrlen; /* physical address length */ 193 int gld_saplen; /* sap length, neg appends */ 194 unsigned char *gld_broadcast; /* pointer to broadcast address */ 195 int gld_styles; /* provider styles */ 196 } glddev_t; 197 198 typedef struct pktinfo { 199 uint_t isBroadcast:1; 200 uint_t isMulticast:1; 201 uint_t isLooped:1; 202 uint_t isForMe:1; 203 uint_t isLLC:1; 204 uint_t user_pri:3; 205 uint_t cfi:1; 206 uint_t vid:12; 207 uint_t wasAccepted:1; 208 uint_t nosource:1; 209 uint_t isTagged:1; 210 uint_t macLen; 211 uint_t hdrLen; 212 uint_t pktLen; 213 uchar_t dhost[GLD_MAX_ADDRLEN]; 214 uchar_t shost[GLD_MAX_ADDRLEN]; 215 uint_t ethertype; 216 } pktinfo_t; 217 218 /* 219 * Flags input to the gld_interpret_*() interpreter routines. 220 */ 221 typedef enum packet_flag { 222 GLD_RXQUICK, 223 GLD_RXLOOP, 224 GLD_RX, 225 GLD_TX 226 } packet_flag_t; 227 228 /* 229 * Flags input to the gld_interpret_mdt_*() interpreter routines. 230 */ 231 typedef enum mdt_packet_flag { 232 GLD_MDT_TX, 233 GLD_MDT_TXPKT, 234 GLD_MDT_RXLOOP 235 } mdt_packet_flag_t; 236 237 /* 238 * Describes characteristics of the Media Access Layer. 239 * The mac_type is one of the supported DLPI media types (see <sys/dlpi.h>). 240 * The mtu_size is the size of the largest frame. 241 * The interpreter is the function that "knows" how to interpret the frame. 242 * The interpreter_mdt routine knows how to interpret/format MDT packets. 243 * Other routines create and/or add headers to packets. 244 */ 245 typedef struct { 246 uint_t mac_type; 247 uint_t mtu_size; 248 int hdr_size; 249 int (*interpreter)(gld_mac_info_t *, mblk_t *, pktinfo_t *, 250 packet_flag_t); 251 void (*interpreter_mdt)(gld_mac_info_t *, mblk_t *, 252 struct pdescinfo_s *, pktinfo_t *, mdt_packet_flag_t); 253 mblk_t *(*mkfastpath)(gld_t *, mblk_t *); 254 mblk_t *(*mkunitdata)(gld_t *, mblk_t *); 255 void (*init)(gld_mac_info_t *); 256 void (*uninit)(gld_mac_info_t *); 257 char *mac_string; 258 } gld_interface_t; 259 260 /* 261 * structure for names stat structure usage as required by "netstat" 262 */ 263 typedef union media_kstats { 264 struct dot3kstat { 265 kstat_named_t first_coll; 266 kstat_named_t multi_coll; 267 kstat_named_t sqe_error; 268 kstat_named_t mac_xmt_error; 269 kstat_named_t frame_too_long; 270 kstat_named_t mac_rcv_error; 271 } dot3; 272 struct dot5kstat { 273 kstat_named_t ace_error; 274 kstat_named_t internal_error; 275 kstat_named_t lost_frame_error; 276 kstat_named_t frame_copied_error; 277 kstat_named_t token_error; 278 kstat_named_t freq_error; 279 } dot5; 280 struct fddikstat { 281 kstat_named_t mac_error; 282 kstat_named_t mac_lost; 283 kstat_named_t mac_token; 284 kstat_named_t mac_tvx_expired; 285 kstat_named_t mac_late; 286 kstat_named_t mac_ring_op; 287 } fddi; 288 } media_kstats_t; 289 290 struct gldkstats { 291 kstat_named_t glds_pktxmt; 292 kstat_named_t glds_pktrcv; 293 kstat_named_t glds_errxmt; 294 kstat_named_t glds_errrcv; 295 kstat_named_t glds_collisions; 296 kstat_named_t glds_bytexmt; 297 kstat_named_t glds_bytercv; 298 kstat_named_t glds_multixmt; 299 kstat_named_t glds_multircv; /* multicast but not broadcast */ 300 kstat_named_t glds_brdcstxmt; 301 kstat_named_t glds_brdcstrcv; 302 kstat_named_t glds_unknowns; 303 kstat_named_t glds_blocked; /* discard due to upstream flow */ 304 /* control */ 305 kstat_named_t glds_excoll; 306 kstat_named_t glds_defer; 307 kstat_named_t glds_frame; 308 kstat_named_t glds_crc; 309 kstat_named_t glds_overflow; 310 kstat_named_t glds_underflow; 311 kstat_named_t glds_short; 312 kstat_named_t glds_missed; 313 kstat_named_t glds_xmtlatecoll; 314 kstat_named_t glds_nocarrier; 315 kstat_named_t glds_noxmtbuf; 316 kstat_named_t glds_norcvbuf; 317 kstat_named_t glds_xmtbadinterp; 318 kstat_named_t glds_rcvbadinterp; 319 kstat_named_t glds_intr; 320 kstat_named_t glds_xmtretry; 321 kstat_named_t glds_pktxmt64; 322 kstat_named_t glds_pktrcv64; 323 kstat_named_t glds_bytexmt64; 324 kstat_named_t glds_bytercv64; 325 kstat_named_t glds_speed; 326 kstat_named_t glds_duplex; 327 kstat_named_t glds_media; 328 kstat_named_t glds_prom; 329 media_kstats_t glds_media_specific; 330 }; 331 332 typedef struct gld_mac_pvt gld_mac_pvt_t; 333 334 typedef struct gld_vlan { 335 struct gld_vlan *gldv_next, *gldv_prev; 336 uint32_t gldv_id; 337 uint32_t gldv_ptag; 338 int gldv_nstreams; 339 gld_mac_info_t *gldv_mac; 340 queue_t *gldv_ipq; 341 queue_t *gldv_ipv6q; 342 struct gld *gldv_str_next; /* list of attached streams */ 343 struct gld *gldv_str_prev; 344 kstat_t *gldv_kstatp; 345 struct gld_stats *gldv_stats; 346 /* The number of streams that are in promiscous mode */ 347 uint_t gldv_nprom; 348 /* The number of streams that are interested in VLAN tagged packets. */ 349 uint_t gldv_nvlan_sap; 350 } gld_vlan_t; 351 352 #define VLAN_HASHSZ 23 353 354 /* Per-mac info used by GLD */ 355 struct gld_mac_pvt { 356 gld_interface_t *interfacep; 357 kmutex_t datalock; /* data lock for "data" */ 358 caddr_t data; /* media specific private data */ 359 gld_vlan_t *vlan_hash[VLAN_HASHSZ]; 360 struct gld *last_sched; /* last scheduled stream */ 361 struct glddevice *major_dev; /* per-major device struct */ 362 int nvlan; /* VLANs in use on this mac */ 363 int nprom; /* num streams in promiscuous mode */ 364 int nprom_multi; /* streams in promiscuous multicast */ 365 gld_mcast_t *mcast_table; /* per device multicast table */ 366 unsigned char *curr_macaddr; /* Currently programmed mac address */ 367 kstat_t *kstatp; 368 struct gld_stats *statistics; /* The ones the driver updates */ 369 int rde_enabled; /* RDE (Source Routing) Enabled */ 370 int rde_str_indicator_ste; /* use STE when no SR info */ 371 int rde_timeout; /* route link inactivity timeout */ 372 uint32_t notifications; /* DL_NOTE options supported */ 373 boolean_t started; /* Has the MAC been started? */ 374 }; 375 376 /* return values from gld_cmds */ 377 #define GLDE_OK (-1) /* internal procedure status is OK */ 378 #define GLDE_RETRY 0x1002 /* want to retry later */ 379 380 /* caller argument to gld_start */ 381 #define GLD_WPUT 0 382 #define GLD_WSRV 1 383 384 #define GLD_MAX_802_SAP 0xff 385 386 /* 387 * definitions for debug tracing 388 */ 389 #define GLDTRACE 0x0001 /* basic procedure level tracing */ 390 #define GLDERRS 0x0002 /* trace errors */ 391 #define GLDRECV 0x0004 /* trace receive path */ 392 #define GLDSEND 0x0008 /* trace send path */ 393 #define GLDPROT 0x0010 /* trace DLPI protocol */ 394 #define GLDNOBR 0x0020 /* do not show broadcast messages */ 395 #define GLDETRACE 0x0040 /* trace "normal case" errors */ 396 #define GLDRDE 0x0080 /* netstat -k dump routing table */ 397 398 /* 399 * Lock manipulation macros for GLDM_LOCK. Conceptually, the 400 * GLD layer treats the lock as a rw lock; for v0 binary and 401 * semantic compatibility, the underlying implementation still 402 * uses a mutex, whereas for v2 drivers, the more scalable rwlock 403 * is used instead. See notes in gld.h. 404 */ 405 #define GLDM_LOCK_INIT(macinfo) \ 406 rw_init(&(macinfo)->gldm_lock.gldl_rw_lock, NULL, \ 407 RW_DRIVER, (macinfo)->gldm_cookie); \ 408 (macinfo)->gldm_GLD_flags |= GLD_LOCK_INITED 409 410 #define GLDM_LOCK_INITED(macinfo) \ 411 ((macinfo)->gldm_GLD_flags & GLD_LOCK_INITED) 412 413 #define GLDM_LOCK_DESTROY(macinfo) \ 414 if ((macinfo)->gldm_GLD_flags & GLD_LOCK_INITED) { \ 415 rw_destroy(&(macinfo)->gldm_lock.gldl_rw_lock); \ 416 (macinfo)->gldm_GLD_flags &= ~GLD_LOCK_INITED; \ 417 } 418 419 #define GLDM_LOCK(macinfo, rw) \ 420 rw_enter(&(macinfo)->gldm_lock.gldl_rw_lock, (rw)) 421 422 #define GLDM_UNLOCK(macinfo) \ 423 rw_exit(&(macinfo)->gldm_lock.gldl_rw_lock) 424 425 #define GLDM_TRYLOCK(macinfo, rw) \ 426 rw_tryenter(&(macinfo)->gldm_lock.gldl_rw_lock, (rw)) 427 428 /* lock held in read or write mode? */ 429 #define GLDM_LOCK_HELD(macinfo) \ 430 rw_lock_held(&(macinfo)->gldm_lock.gldl_rw_lock) 431 432 /* lock held in write mode? */ 433 #define GLDM_LOCK_HELD_WRITE(macinfo) \ 434 rw_write_held(&(macinfo)->gldm_lock.gldl_rw_lock) 435 436 /* 437 * Compare/copy two MAC addresses. 438 * Note that unlike bcmp, we return zero if they are different. 439 */ 440 #define mac_eq(a, b, l) (bcmp((caddr_t)(a), (caddr_t)(b), (l)) == 0) 441 #define mac_copy(a, b, l) (bcopy((caddr_t)(a), (caddr_t)(b), (l))) 442 /* copy a mac address to/from canonical form */ 443 #define cmac_copy(a, b, l, macinfo) { \ 444 if ((macinfo)->gldm_options & GLDOPT_CANONICAL_ADDR) \ 445 gld_bitrevcopy((caddr_t)(a), (caddr_t)(b), (l)); \ 446 else \ 447 mac_copy((a), (b), (l)); \ 448 } 449 450 /* 451 * Macros to access possibly-unaligned variables 452 */ 453 454 #if (_ALIGNMENT_REQUIRED == 0) 455 456 #define REF_HOST_USHORT(lvalue) (lvalue) 457 #define REF_NET_USHORT(lvalue) (ntohs(lvalue)) 458 #define SET_NET_USHORT(lvalue, val) ((lvalue) = htons(val)) 459 460 #else /* ALIGNMENT_REQUIRED */ 461 462 #define REF_NET_USHORT(lvalue) \ 463 ((ushort_t)((((uchar_t *)(&(lvalue)))[0]<<8) | \ 464 ((uchar_t *)(&(lvalue)))[1])) 465 466 #define SET_NET_USHORT(lvalue, val) { \ 467 ((uchar_t *)(&(lvalue)))[0] = (uchar_t)((val)>>8); \ 468 ((uchar_t *)(&(lvalue)))[1] = (uchar_t)(val); \ 469 } 470 471 #if defined(_LITTLE_ENDIAN) 472 473 #define REF_HOST_USHORT(lvalue) \ 474 ((ushort_t)((((uchar_t *)(&(lvalue)))[1]<<8) | \ 475 ((uchar_t *)(&(lvalue)))[0])) 476 477 #elif defined(_BIG_ENDIAN) 478 479 #define REF_HOST_USHORT(lvalue) \ 480 ((ushort_t)((((uchar_t *)(&(lvalue)))[0]<<8) | \ 481 ((uchar_t *)(&(lvalue)))[1])) 482 483 #else /* unknown endian */ 484 #error "what endian is this machine?" 485 #endif /* endian */ 486 487 #endif /* ALIGNMENT_REQUIRED */ 488 489 /* ================================================================ */ 490 /* Route Determination Entity definitions (IEEE 802.2 1994 edition) */ 491 /* ================================================================ */ 492 493 struct rde_pdu { 494 uchar_t rde_ver; 495 uchar_t rde_ptype; 496 uchar_t rde_target_mac[6]; 497 uchar_t rde_orig_mac[6]; 498 uchar_t rde_target_sap; 499 uchar_t rde_orig_sap; 500 }; 501 502 #define LSAP_RDE 0xa6 /* IEEE 802.2 section 3.3.1.2 */ 503 #define RDE_RQC 0x01 /* Route Query Command */ 504 #define RDE_RQR 0x02 /* Route Query Response */ 505 #define RDE_RS 0x03 /* Route Selected */ 506 507 /* ============================================================= */ 508 /* Source Routing fields and definitions (IEEE 802.2 and 802.1D) */ 509 /* ============================================================= */ 510 511 #define MAX_RDFLDS 14 /* changed to 14 from 8 as per IEEE */ 512 513 /* 514 * Source Routing Route Information field. 515 */ 516 struct gld_ri { 517 #if defined(_BIT_FIELDS_LTOH) 518 uchar_t len:5; /* length */ 519 uchar_t rt:3; /* routing type */ 520 uchar_t res:4; /* reserved */ 521 uchar_t mtu:3; /* largest frame */ 522 uchar_t dir:1; /* direction bit */ 523 struct tr_rd { /* route designator fields */ 524 ushort_t bridge:4; /* Note: assumes network order... */ 525 ushort_t ring:12; /* ...(Big Endian) -- needs ntohs() */ 526 } rd[MAX_RDFLDS]; 527 #elif defined(_BIT_FIELDS_HTOL) 528 uchar_t rt:3; /* routing type */ 529 uchar_t len:5; /* length */ 530 uchar_t dir:1; /* direction bit */ 531 uchar_t mtu:3; /* largest frame */ 532 uchar_t res:4; /* reserved */ 533 struct tr_rd { /* route designator fields */ 534 ushort_t ring:12; 535 ushort_t bridge:4; 536 } rd[MAX_RDFLDS]; 537 #else 538 #error "which way do bit fields get allocated?" 539 #endif 540 }; 541 542 #define RT_SRF 0x0 /* 0xx: specifically routed frame */ 543 #define RT_ARE 0x4 /* 10x: all routes explorer frame */ 544 #define RT_STE 0x6 /* 11x: spanning tree explorer frame */ 545 546 #define RT_MTU_MAX 0x7 /* Max MTU field (base only) */ 547 548 /* 549 * Source route table info 550 */ 551 struct srtab { 552 struct srtab *sr_next; /* next in linked list */ 553 uchar_t sr_mac[6]; /* MAC address */ 554 struct gld_ri sr_ri; /* routing information */ 555 clock_t sr_timer; 556 }; 557 558 #define SR_HASH_SIZE 256 /* Number of bins */ 559 560 /* ================================================================= */ 561 /* Media dependent defines for media dependent routines in gldutil.c */ 562 /* ================================================================= */ 563 564 /* 565 * Some "semi-generic" defines used by ether, token, and fddi, 566 * and probably anything else with addrlen == 6 && saplen == -2. 567 */ 568 569 struct gld_dlsap { 570 unsigned char glda_addr[ETHERADDRL]; 571 unsigned short glda_sap; 572 }; 573 574 #define DLSAP(p, offset) ((struct gld_dlsap *)((caddr_t)(p)+offset)) 575 576 typedef uchar_t mac_addr_t[ETHERADDRL]; 577 578 struct llc_snap_hdr { 579 uchar_t d_lsap; /* destination service access point */ 580 uchar_t s_lsap; /* source link service access point */ 581 uchar_t control; /* short control field */ 582 uchar_t org[3]; /* Ethernet style organization field */ 583 ushort_t type; /* Ethernet style type field */ 584 }; 585 586 #define LLC_HDR1_LEN 3 /* Length of the LLC1 header */ 587 #define LLC_SNAP_HDR_LEN 8 /* Full length of SNAP header */ 588 #define LSAP_SNAP 0xaa /* SAP for SubNet Access Protocol */ 589 #define CNTL_LLC_UI 0x03 /* un-numbered information packet */ 590 591 /* ======================== */ 592 /* FDDI related definitions */ 593 /* ======================== */ 594 595 struct fddi_mac_frm { 596 uchar_t fddi_fc; 597 mac_addr_t fddi_dhost; 598 mac_addr_t fddi_shost; 599 }; 600 601 /* ============================== */ 602 /* Token Ring related definitions */ 603 /* ============================== */ 604 605 struct tr_mac_frm_nori { 606 uchar_t tr_ac; 607 uchar_t tr_fc; 608 mac_addr_t tr_dhost; 609 mac_addr_t tr_shost; 610 }; 611 612 struct tr_mac_frm { 613 uchar_t tr_ac; 614 uchar_t tr_fc; 615 mac_addr_t tr_dhost; 616 mac_addr_t tr_shost; 617 struct gld_ri tr_ri; /* Routing Information Field */ 618 }; 619 620 /* 621 * Note that the pad field is used to save the value of tci. 622 */ 623 #define GLD_SAVE_MBLK_VTAG(mp, vtag) (DB_TCI(mp) = GLD_VTAG_TCI(vtag)) 624 #define GLD_CLEAR_MBLK_VTAG(mp) GLD_SAVE_MBLK_VTAG(mp, 0) 625 #define GLD_GET_MBLK_VTAG(mp) GLD_TCI2VTAG(DB_TCI(mp)) 626 627 int gld_interpret_ether(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); 628 int gld_interpret_fddi(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); 629 int gld_interpret_tr(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); 630 int gld_interpret_ib(gld_mac_info_t *, mblk_t *, pktinfo_t *, packet_flag_t); 631 void gld_interpret_mdt_ib(gld_mac_info_t *, mblk_t *, pdescinfo_t *, 632 pktinfo_t *, mdt_packet_flag_t); 633 634 mblk_t *gld_fastpath_ether(gld_t *, mblk_t *); 635 mblk_t *gld_fastpath_fddi(gld_t *, mblk_t *); 636 mblk_t *gld_fastpath_tr(gld_t *, mblk_t *); 637 mblk_t *gld_fastpath_ib(gld_t *, mblk_t *); 638 639 mblk_t *gld_insert_vtag_ether(mblk_t *, uint32_t); 640 641 mblk_t *gld_unitdata_ether(gld_t *, mblk_t *); 642 mblk_t *gld_unitdata_fddi(gld_t *, mblk_t *); 643 mblk_t *gld_unitdata_tr(gld_t *, mblk_t *); 644 mblk_t *gld_unitdata_ib(gld_t *, mblk_t *); 645 646 void gld_init_ether(gld_mac_info_t *); 647 void gld_init_fddi(gld_mac_info_t *); 648 void gld_init_tr(gld_mac_info_t *); 649 void gld_init_ib(gld_mac_info_t *); 650 651 void gld_uninit_ether(gld_mac_info_t *); 652 void gld_uninit_fddi(gld_mac_info_t *); 653 void gld_uninit_tr(gld_mac_info_t *); 654 void gld_uninit_ib(gld_mac_info_t *); 655 656 #ifdef __cplusplus 657 } 658 #endif 659 660 #endif /* _SYS_GLDPRIV_H */ 661