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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*ff550d0eSmasputra * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * gld - Generic LAN Driver support system for DLPI drivers. 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifndef _SYS_GLD_H 327c478bd9Sstevel@tonic-gate #define _SYS_GLD_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/ethernet.h> 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 * Media specific MIB-II counters/statistics 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * This only includes those that aren't in the legacy counters. 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate typedef union media_stats { 497c478bd9Sstevel@tonic-gate struct dot3stat { 507c478bd9Sstevel@tonic-gate /* Ethernet: RFC1643 Dot3Stats (subset) */ 517c478bd9Sstevel@tonic-gate uint32_t first_coll; /* SingleCollisionFrames */ 527c478bd9Sstevel@tonic-gate uint32_t multi_coll; /* MultipleCollisionFrames */ 537c478bd9Sstevel@tonic-gate uint32_t sqe_error; /* SQETestErrors */ 547c478bd9Sstevel@tonic-gate uint32_t mac_xmt_error; /* InternalMacTransmitErrors */ 557c478bd9Sstevel@tonic-gate uint32_t frame_too_long; /* FrameTooLongs */ 567c478bd9Sstevel@tonic-gate uint32_t mac_rcv_error; /* InternalMacReceiveErrors */ 577c478bd9Sstevel@tonic-gate } dot3; 587c478bd9Sstevel@tonic-gate struct dot5stat { 597c478bd9Sstevel@tonic-gate /* Token Ring: RFC1748 Dot5Stats (subset) */ 607c478bd9Sstevel@tonic-gate uint32_t ace_error; 617c478bd9Sstevel@tonic-gate uint32_t internal_error; 627c478bd9Sstevel@tonic-gate uint32_t lost_frame_error; 637c478bd9Sstevel@tonic-gate uint32_t frame_copied_error; 647c478bd9Sstevel@tonic-gate uint32_t token_error; 657c478bd9Sstevel@tonic-gate uint32_t freq_error; 667c478bd9Sstevel@tonic-gate } dot5; 677c478bd9Sstevel@tonic-gate struct fddistat { 687c478bd9Sstevel@tonic-gate /* FDDI: RFC1512 (subset) */ 697c478bd9Sstevel@tonic-gate uint32_t mac_error; 707c478bd9Sstevel@tonic-gate uint32_t mac_lost; 717c478bd9Sstevel@tonic-gate uint32_t mac_token; 727c478bd9Sstevel@tonic-gate uint32_t mac_tvx_expired; 737c478bd9Sstevel@tonic-gate uint32_t mac_late; 747c478bd9Sstevel@tonic-gate uint32_t mac_ring_op; 757c478bd9Sstevel@tonic-gate } fddi; 767c478bd9Sstevel@tonic-gate uint32_t pad[16]; 777c478bd9Sstevel@tonic-gate } media_stats_t; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #define glds_dot3_first_coll glds_media_specific.dot3.first_coll 807c478bd9Sstevel@tonic-gate #define glds_dot3_multi_coll glds_media_specific.dot3.multi_coll 817c478bd9Sstevel@tonic-gate #define glds_dot3_sqe_error glds_media_specific.dot3.sqe_error 827c478bd9Sstevel@tonic-gate #define glds_dot3_mac_xmt_error glds_media_specific.dot3.mac_xmt_error 837c478bd9Sstevel@tonic-gate #define glds_dot3_mac_rcv_error glds_media_specific.dot3.mac_rcv_error 847c478bd9Sstevel@tonic-gate #define glds_dot3_frame_too_long glds_media_specific.dot3.frame_too_long 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #define glds_dot5_line_error glds_crc 877c478bd9Sstevel@tonic-gate #define glds_dot5_burst_error glds_frame 887c478bd9Sstevel@tonic-gate #define glds_dot5_ace_error glds_media_specific.dot5.ace_error 897c478bd9Sstevel@tonic-gate #define glds_dot5_internal_error glds_media_specific.dot5.internal_error 907c478bd9Sstevel@tonic-gate #define glds_dot5_lost_frame_error glds_media_specific.dot5.lost_frame_error 917c478bd9Sstevel@tonic-gate #define glds_dot5_frame_copied_error glds_media_specific.dot5.frame_copied_error 927c478bd9Sstevel@tonic-gate #define glds_dot5_token_error glds_media_specific.dot5.token_error 937c478bd9Sstevel@tonic-gate #define glds_dot5_signal_loss glds_nocarrier 947c478bd9Sstevel@tonic-gate #define glds_dot5_freq_error glds_media_specific.dot5.freq_error 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define glds_fddi_mac_error glds_media_specific.fddi.mac_error 977c478bd9Sstevel@tonic-gate #define glds_fddi_mac_lost glds_media_specific.fddi.mac_lost 987c478bd9Sstevel@tonic-gate #define glds_fddi_mac_token glds_media_specific.fddi.mac_token 997c478bd9Sstevel@tonic-gate #define glds_fddi_mac_tvx_expired glds_media_specific.fddi.mac_tvx_expired 1007c478bd9Sstevel@tonic-gate #define glds_fddi_mac_late glds_media_specific.fddi.mac_late 1017c478bd9Sstevel@tonic-gate #define glds_fddi_mac_ring_op glds_media_specific.fddi.mac_ring_op 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * structure for driver statistics 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate struct gld_stats { 1077c478bd9Sstevel@tonic-gate ulong_t glds_multixmt; /* (G) ifOutMulticastPkts */ 1087c478bd9Sstevel@tonic-gate ulong_t glds_multircv; /* (G) ifInMulticastPkts */ 1097c478bd9Sstevel@tonic-gate ulong_t glds_brdcstxmt; /* (G) ifOutBroadcastPkts */ 1107c478bd9Sstevel@tonic-gate ulong_t glds_brdcstrcv; /* (G) ifInBroadcastPkts */ 1117c478bd9Sstevel@tonic-gate uint32_t glds_blocked; /* (G) discard: upstream flow cntrl */ 1127c478bd9Sstevel@tonic-gate uint32_t glds_reserved1; 1137c478bd9Sstevel@tonic-gate uint32_t glds_reserved2; 1147c478bd9Sstevel@tonic-gate uint32_t glds_reserved3; 1157c478bd9Sstevel@tonic-gate uint32_t glds_reserved4; 1167c478bd9Sstevel@tonic-gate uint32_t glds_errxmt; /* (D) ifOutErrors */ 1177c478bd9Sstevel@tonic-gate uint32_t glds_errrcv; /* (D) ifInErrors */ 1187c478bd9Sstevel@tonic-gate uint32_t glds_collisions; /* (e) Sun MIB's rsIfCollisions */ 1197c478bd9Sstevel@tonic-gate uint32_t glds_excoll; /* (e) dot3StatsExcessiveCollisions */ 1207c478bd9Sstevel@tonic-gate uint32_t glds_defer; /* (e) dot3StatsDeferredTransmissions */ 1217c478bd9Sstevel@tonic-gate uint32_t glds_frame; /* (e) dot3StatsAlignErrors */ 1227c478bd9Sstevel@tonic-gate uint32_t glds_crc; /* (e) dot3StatsFCSErrors */ 1237c478bd9Sstevel@tonic-gate uint32_t glds_overflow; /* (D) */ 1247c478bd9Sstevel@tonic-gate uint32_t glds_underflow; /* (D) */ 1257c478bd9Sstevel@tonic-gate uint32_t glds_short; /* (e) */ 1267c478bd9Sstevel@tonic-gate uint32_t glds_missed; /* (D) */ 1277c478bd9Sstevel@tonic-gate uint32_t glds_xmtlatecoll; /* (e) dot3StatsLateCollisions */ 1287c478bd9Sstevel@tonic-gate uint32_t glds_nocarrier; /* (e) dot3StatsCarrierSenseErrors */ 1297c478bd9Sstevel@tonic-gate uint32_t glds_noxmtbuf; /* (G) ifOutDiscards */ 1307c478bd9Sstevel@tonic-gate uint32_t glds_norcvbuf; /* (D) ifInDiscards */ 1317c478bd9Sstevel@tonic-gate uint32_t glds_intr; /* (D) */ 1327c478bd9Sstevel@tonic-gate uint32_t glds_xmtretry; /* (G) */ 1337c478bd9Sstevel@tonic-gate uint64_t glds_pktxmt64; /* (G) 64-bit rsIfOutPackets */ 1347c478bd9Sstevel@tonic-gate uint64_t glds_pktrcv64; /* (G) 64-bit rsIfInPackets */ 1357c478bd9Sstevel@tonic-gate uint64_t glds_bytexmt64; /* (G) ifHCOutOctets */ 1367c478bd9Sstevel@tonic-gate uint64_t glds_bytercv64; /* (G) ifHCInOctets */ 1377c478bd9Sstevel@tonic-gate uint64_t glds_speed; /* (D) ifSpeed */ 1387c478bd9Sstevel@tonic-gate uint32_t glds_duplex; /* (e) Invented for GLD */ 1397c478bd9Sstevel@tonic-gate uint32_t glds_media; /* (D) Invented for GLD */ 1407c478bd9Sstevel@tonic-gate uint32_t glds_unknowns; /* (G) ifInUnknownProtos */ 1417c478bd9Sstevel@tonic-gate uint32_t reserved[19]; 1427c478bd9Sstevel@tonic-gate media_stats_t glds_media_specific; 1437c478bd9Sstevel@tonic-gate uint32_t glds_xmtbadinterp; /* (G) bad packet len/format */ 1447c478bd9Sstevel@tonic-gate uint32_t glds_rcvbadinterp; /* (G) bad packet len/format */ 1457c478bd9Sstevel@tonic-gate uint32_t glds_gldnorcvbuf; /* (G) norcvbuf from inside GLD */ 1467c478bd9Sstevel@tonic-gate }; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* 1497c478bd9Sstevel@tonic-gate * gld_mac_info structure. Used to define the per-board data for all 1507c478bd9Sstevel@tonic-gate * drivers. 1517c478bd9Sstevel@tonic-gate * 1527c478bd9Sstevel@tonic-gate * The below definition of gld_mac_info contains GLD PRIVATE entries that must 1537c478bd9Sstevel@tonic-gate * not be used by the device driver. Only entries marked SET BY DRIVER should 1547c478bd9Sstevel@tonic-gate * be modified. 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate #define GLD_STATS_SIZE_ORIG (sizeof (uint32_t) * 26) /* don't change */ 1587c478bd9Sstevel@tonic-gate #define GLD_KSTAT_SIZE_ORIG (sizeof (kstat_named_t) * 26) /* don't change */ 1597c478bd9Sstevel@tonic-gate #define GLD_PAD ((int)GLD_KSTAT_SIZE_ORIG + (int)GLD_STATS_SIZE_ORIG) 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate typedef union gld_lock { 1627c478bd9Sstevel@tonic-gate kmutex_t reserved; 1637c478bd9Sstevel@tonic-gate krwlock_t gldl_rw_lock; 1647c478bd9Sstevel@tonic-gate } gld_lock_t; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate typedef struct gld_mac_info { 1677c478bd9Sstevel@tonic-gate struct gld_mac_info *gldm_next; /* GLD PRIVATE */ 1687c478bd9Sstevel@tonic-gate struct gld_mac_info *gldm_prev; /* GLD PRIVATE */ 1697c478bd9Sstevel@tonic-gate caddr_t reserved1; /* GLD PRIVATE */ 1707c478bd9Sstevel@tonic-gate caddr_t reserved2; /* GLD PRIVATE */ 1717c478bd9Sstevel@tonic-gate uint16_t gldm_driver_version; /* GLD PRIVATE */ 1727c478bd9Sstevel@tonic-gate uint16_t gldm_GLD_version; /* GLD PRIVATE */ 1737c478bd9Sstevel@tonic-gate uint16_t gldm_GLD_flags; /* GLD PRIVATE */ 1747c478bd9Sstevel@tonic-gate uint16_t gldm_options; /* GLD_PRIVATE */ 1757c478bd9Sstevel@tonic-gate dev_info_t *gldm_devinfo; /* SET BY DRIVER */ 1767c478bd9Sstevel@tonic-gate uchar_t *gldm_vendor_addr; /* SET BY DRIVER */ 1777c478bd9Sstevel@tonic-gate uchar_t *gldm_broadcast_addr; /* SET BY DRIVER */ 1787c478bd9Sstevel@tonic-gate gld_lock_t gldm_lock; /* GLD PRIVATE */ 1797c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t gldm_cookie; /* SET BY DRIVER */ 1807c478bd9Sstevel@tonic-gate uint32_t reserved3; /* GLD PRIVATE */ 1817c478bd9Sstevel@tonic-gate uint32_t reserved4; /* GLD PRIVATE */ 1827c478bd9Sstevel@tonic-gate uint32_t gldm_maxpkt; /* SET BY DRIVER */ 1837c478bd9Sstevel@tonic-gate uint32_t gldm_minpkt; /* SET BY DRIVER */ 1847c478bd9Sstevel@tonic-gate char *gldm_ident; /* SET BY DRIVER */ 1857c478bd9Sstevel@tonic-gate uint32_t gldm_type; /* SET BY DRIVER */ 1867c478bd9Sstevel@tonic-gate uint32_t reserved5; /* GLD PRIVATE */ 1877c478bd9Sstevel@tonic-gate uint32_t gldm_addrlen; /* SET BY DRIVER */ 1887c478bd9Sstevel@tonic-gate int32_t gldm_saplen; /* SET BY DRIVER */ 1897c478bd9Sstevel@tonic-gate /* NOTE: MUST BE -2 */ 1907c478bd9Sstevel@tonic-gate unsigned char reserved7[ETHERADDRL]; /* GLD PRIVATE */ 1917c478bd9Sstevel@tonic-gate unsigned char reserved8[ETHERADDRL]; /* GLD PRIVATE */ 1927c478bd9Sstevel@tonic-gate unsigned char reserved9[ETHERADDRL]; /* GLD PRIVATE */ 1937c478bd9Sstevel@tonic-gate t_uscalar_t gldm_ppa; /* SET BY DRIVER */ 1947c478bd9Sstevel@tonic-gate int32_t reserved10; /* GLD PRIVATE */ 1957c478bd9Sstevel@tonic-gate uint32_t gldm_capabilities; /* SET BY DRIVER */ 1967c478bd9Sstevel@tonic-gate int32_t gldm_linkstate; /* GLD PRIVATE */ 1977c478bd9Sstevel@tonic-gate uint32_t reserved11; /* GLD PRIVATE */ 1987c478bd9Sstevel@tonic-gate caddr_t reserved12; /* GLD PRIVATE */ 1997c478bd9Sstevel@tonic-gate int32_t reserved13; /* GLD PRIVATE */ 2007c478bd9Sstevel@tonic-gate uint32_t reserved14; /* GLD PRIVATE */ 2017c478bd9Sstevel@tonic-gate int32_t reserved15; /* GLD PRIVATE */ 2027c478bd9Sstevel@tonic-gate caddr_t gldm_mac_pvt; /* GLD PRIVATE */ 2037c478bd9Sstevel@tonic-gate caddr_t reserved16; /* GLD PRIVATE */ 2047c478bd9Sstevel@tonic-gate char reserved17[GLD_PAD]; /* GLD PRIVATE */ 2057c478bd9Sstevel@tonic-gate caddr_t reserved18; /* GLD PRIVATE */ 2067c478bd9Sstevel@tonic-gate caddr_t gldm_private; /* GLD PRIVATE */ 2077c478bd9Sstevel@tonic-gate int (*gldm_reset)(); /* SET BY DRIVER */ 2087c478bd9Sstevel@tonic-gate int (*gldm_start)(); /* SET BY DRIVER */ 2097c478bd9Sstevel@tonic-gate int (*gldm_stop)(); /* SET BY DRIVER */ 2107c478bd9Sstevel@tonic-gate int (*gldm_set_mac_addr)(); /* SET BY DRIVER */ 2117c478bd9Sstevel@tonic-gate int (*gldm_send)(); /* SET BY DRIVER */ 2127c478bd9Sstevel@tonic-gate int (*gldm_set_promiscuous)(); /* SET BY DRIVER */ 2137c478bd9Sstevel@tonic-gate int (*gldm_get_stats)(); /* SET BY DRIVER */ 2147c478bd9Sstevel@tonic-gate int (*gldm_ioctl)(); /* SET BY DRIVER */ 2157c478bd9Sstevel@tonic-gate int (*gldm_set_multicast)(); /* SET BY DRIVER */ 2167c478bd9Sstevel@tonic-gate uint_t (*gldm_intr)(); /* SET BY DRIVER */ 2177c478bd9Sstevel@tonic-gate int (*gldm_mctl)(); /* SET BY DRIVER */ 2187c478bd9Sstevel@tonic-gate int (*gldm_send_tagged)(); /* SET BY DRIVER */ 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate * The following MDT related entry points are Sun private, 2217c478bd9Sstevel@tonic-gate * meant only for use by Sun's IPoIB (ibd) driver. 2227c478bd9Sstevel@tonic-gate */ 2237c478bd9Sstevel@tonic-gate int (*gldm_mdt_pre)(); /* SET BY DRIVER */ 2247c478bd9Sstevel@tonic-gate void (*gldm_mdt_send)(); /* SET BY DRIVER */ 2257c478bd9Sstevel@tonic-gate void (*gldm_mdt_post)(); /* SET BY DRIVER */ 2267c478bd9Sstevel@tonic-gate int gldm_mdt_sgl; /* SET BY DRIVER */ 2277c478bd9Sstevel@tonic-gate int gldm_mdt_segs; /* SET BY DRIVER */ 2287c478bd9Sstevel@tonic-gate } gld_mac_info_t; 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate /* flags for physical promiscuous state */ 2317c478bd9Sstevel@tonic-gate #define GLD_MAC_PROMISC_NOOP -1 /* leave mode unchanged */ 2327c478bd9Sstevel@tonic-gate #define GLD_MAC_PROMISC_NONE 0 /* promiscuous mode(s) OFF */ 2337c478bd9Sstevel@tonic-gate #define GLD_MAC_PROMISC_PHYS 1 /* receive all packets */ 2347c478bd9Sstevel@tonic-gate #define GLD_MAC_PROMISC_MULTI 2 /* receive all multicast packets */ 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate #define GLD_MULTI_ENABLE 1 2377c478bd9Sstevel@tonic-gate #define GLD_MULTI_DISABLE 0 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate /* flags for gldm_capabilities */ 2407c478bd9Sstevel@tonic-gate #define GLD_CAP_LINKSTATE 0x00000001 /* will call gld_linkstate() */ 2417c478bd9Sstevel@tonic-gate #define GLD_CAP_CKSUM_IPHDR 0x00000008 /* IP checksum offload */ 2427c478bd9Sstevel@tonic-gate #define GLD_CAP_CKSUM_PARTIAL 0x00000010 /* TCP/UDP partial */ 243*ff550d0eSmasputra #define GLD_CAP_CKSUM_FULL_V4 0x00000020 /* TCP/UDP full for IPv4 */ 2447c478bd9Sstevel@tonic-gate #define GLD_CAP_ZEROCOPY 0x00000040 /* zerocopy */ 245*ff550d0eSmasputra #define GLD_CAP_CKSUM_FULL_V6 0x00000080 /* TCP/UDP full for IPv6 */ 246*ff550d0eSmasputra #define GLD_CAP_CKSUM_ANY \ 247*ff550d0eSmasputra (GLD_CAP_CKSUM_IPHDR|GLD_CAP_CKSUM_PARTIAL| \ 248*ff550d0eSmasputra GLD_CAP_CKSUM_FULL_V4|GLD_CAP_CKSUM_FULL_V6) 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate /* values of gldm_linkstate, as passed to gld_linkstate() */ 2517c478bd9Sstevel@tonic-gate #define GLD_LINKSTATE_DOWN -1 2527c478bd9Sstevel@tonic-gate #define GLD_LINKSTATE_UNKNOWN 0 2537c478bd9Sstevel@tonic-gate #define GLD_LINKSTATE_UP 1 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate /* 2567c478bd9Sstevel@tonic-gate * media type: this identifies the media/connector currently used by the 2577c478bd9Sstevel@tonic-gate * driver. Possible types will be defined for each DLPI type defined in 2587c478bd9Sstevel@tonic-gate * gldm_type. The below definitions should be used by the device dependent 2597c478bd9Sstevel@tonic-gate * drivers to set glds_media. 2607c478bd9Sstevel@tonic-gate */ 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate /* if driver cannot determine media/connector type */ 2637c478bd9Sstevel@tonic-gate #define GLDM_UNKNOWN 0 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate #define GLDM_AUI 1 2667c478bd9Sstevel@tonic-gate #define GLDM_BNC 2 2677c478bd9Sstevel@tonic-gate #define GLDM_TP 3 2687c478bd9Sstevel@tonic-gate #define GLDM_FIBER 4 2697c478bd9Sstevel@tonic-gate #define GLDM_100BT 5 2707c478bd9Sstevel@tonic-gate #define GLDM_VGANYLAN 6 2717c478bd9Sstevel@tonic-gate #define GLDM_10BT 7 2727c478bd9Sstevel@tonic-gate #define GLDM_RING4 8 2737c478bd9Sstevel@tonic-gate #define GLDM_RING16 9 2747c478bd9Sstevel@tonic-gate #define GLDM_PHYMII 10 2757c478bd9Sstevel@tonic-gate #define GLDM_100BTX 11 2767c478bd9Sstevel@tonic-gate #define GLDM_100BT4 12 2777c478bd9Sstevel@tonic-gate #define GLDM_IB 14 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate /* defines for possible duplex states (glds_duplex) */ 2807c478bd9Sstevel@tonic-gate #define GLD_DUPLEX_UNKNOWN 0 2817c478bd9Sstevel@tonic-gate #define GLD_DUPLEX_HALF 1 2827c478bd9Sstevel@tonic-gate #define GLD_DUPLEX_FULL 2 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate /* Values returned from driver entry points */ 2857c478bd9Sstevel@tonic-gate #define GLD_SUCCESS 0 2867c478bd9Sstevel@tonic-gate #define GLD_NORESOURCES 1 2877c478bd9Sstevel@tonic-gate #define GLD_NOTSUPPORTED 2 2887c478bd9Sstevel@tonic-gate #define GLD_BADARG 3 2897c478bd9Sstevel@tonic-gate #define GLD_NOLINK 4 2907c478bd9Sstevel@tonic-gate #define GLD_RETRY 5 2917c478bd9Sstevel@tonic-gate #define GLD_FAILURE (-1) 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 2947c478bd9Sstevel@tonic-gate /* Functions exported to drivers */ 2957c478bd9Sstevel@tonic-gate extern gld_mac_info_t *gld_mac_alloc(dev_info_t *); 2967c478bd9Sstevel@tonic-gate extern void gld_mac_free(gld_mac_info_t *); 2977c478bd9Sstevel@tonic-gate extern int gld_register(dev_info_t *, char *, gld_mac_info_t *); 2987c478bd9Sstevel@tonic-gate extern int gld_unregister(gld_mac_info_t *); 2997c478bd9Sstevel@tonic-gate extern void gld_recv(gld_mac_info_t *, mblk_t *); 3007c478bd9Sstevel@tonic-gate extern void gld_recv_tagged(gld_mac_info_t *, mblk_t *, uint32_t); 3017c478bd9Sstevel@tonic-gate extern void gld_linkstate(gld_mac_info_t *, int32_t); 3027c478bd9Sstevel@tonic-gate extern void gld_sched(gld_mac_info_t *); 3037c478bd9Sstevel@tonic-gate extern uint_t gld_intr(); 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate extern int gld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); 3067c478bd9Sstevel@tonic-gate extern int gld_open(queue_t *, dev_t *, int, int, cred_t *); 3077c478bd9Sstevel@tonic-gate extern int gld_close(queue_t *, int, cred_t *); 3087c478bd9Sstevel@tonic-gate extern int gld_wput(queue_t *, mblk_t *); 3097c478bd9Sstevel@tonic-gate extern int gld_wsrv(queue_t *); 3107c478bd9Sstevel@tonic-gate extern int gld_rsrv(queue_t *); 3117c478bd9Sstevel@tonic-gate #endif 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* 3147c478bd9Sstevel@tonic-gate * VLAN tag macros 3157c478bd9Sstevel@tonic-gate * 3167c478bd9Sstevel@tonic-gate * Per IEEE802.1Q, a VLAN tag is made up of a 2-byte Tagged Protocol 3177c478bd9Sstevel@tonic-gate * Identifier (TPID) and two bytes of Tag/Control information (TCI). 3187c478bd9Sstevel@tonic-gate * All fields should be treated as unsigned, and so a VTAG is held as 3197c478bd9Sstevel@tonic-gate * a 'uint32_t' 3207c478bd9Sstevel@tonic-gate */ 3217c478bd9Sstevel@tonic-gate #define VTAG_SIZE 4 /* bytes (octets) */ 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate #define VLAN_TPID_MASK 0xffff0000u 3247c478bd9Sstevel@tonic-gate #define VLAN_TPID_SHIFT 16 3257c478bd9Sstevel@tonic-gate #define VLAN_TCI_MASK 0x0000ffffu 3267c478bd9Sstevel@tonic-gate #define VLAN_TCI_SHIFT 0 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate #define VLAN_PRI_MASK 0x0000e000u 3297c478bd9Sstevel@tonic-gate #define VLAN_PRI_SHIFT 13 3307c478bd9Sstevel@tonic-gate #define VLAN_CFI_MASK 0x00001000u 3317c478bd9Sstevel@tonic-gate #define VLAN_CFI_SHIFT 12 3327c478bd9Sstevel@tonic-gate #define VLAN_VID_MASK 0x00000fffu 3337c478bd9Sstevel@tonic-gate #define VLAN_VID_SHIFT 0 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate #define VLAN_TPID 0x8100u /* Per IEEE 802.1Q standard */ 3367c478bd9Sstevel@tonic-gate #define VLAN_CFI_ETHER 0 /* CFI on Ethernet must be 0 */ 3377c478bd9Sstevel@tonic-gate #define VLAN_PRI_DFLT 0 3387c478bd9Sstevel@tonic-gate #define VLAN_PRI_MAX 7 3397c478bd9Sstevel@tonic-gate #define VLAN_VID_NONE 0 /* Not a valid VID */ 3407c478bd9Sstevel@tonic-gate #define VLAN_VID_MIN 1 3417c478bd9Sstevel@tonic-gate #define VLAN_VID_MAX 4094 /* IEEE std; 4095 is reserved */ 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate #define VLAN_VTAG_NONE 0 /* Special case: "untagged" */ 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate /* 3467c478bd9Sstevel@tonic-gate * Macros to construct a TCI or VTAG. The user must ensure values are in 3477c478bd9Sstevel@tonic-gate * range. In particular, VID 0 is not a valid argument to these constructor 3487c478bd9Sstevel@tonic-gate * macros; when the VID is 0 (VLAN_VID_NONE), the whole VTAG should be 0 3497c478bd9Sstevel@tonic-gate * (VLAN_VTAG_NONE), not 0x81000000. 3507c478bd9Sstevel@tonic-gate */ 3517c478bd9Sstevel@tonic-gate #define GLD_MAKE_TCI(pri, cfi, vid) (((pri) << VLAN_PRI_SHIFT) | \ 3527c478bd9Sstevel@tonic-gate ((cfi) << VLAN_CFI_SHIFT) | \ 3537c478bd9Sstevel@tonic-gate ((vid) << VLAN_VID_SHIFT)) 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate #define GLD_MAKE_VTAG(tci) ((VLAN_TPID << VLAN_TPID_SHIFT) | (tci)) 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate /* 3587c478bd9Sstevel@tonic-gate * Macros to construct a prototype TCI/VTAG and then convert it to a real one 3597c478bd9Sstevel@tonic-gate */ 3607c478bd9Sstevel@tonic-gate #define GLD_MK_PTCI(cfi, vid) GLD_MAKE_TCI(VLAN_PRI_MAX, cfi, vid) 3617c478bd9Sstevel@tonic-gate #define GLD_MK_PTAG(cfi, vid) GLD_MAKE_VTAG(GLD_MK_PTCI(cfi, vid)) 3627c478bd9Sstevel@tonic-gate #define GLD_MK_PMSK(pri) (((pri) << VLAN_PRI_SHIFT) | ~VLAN_PRI_MASK) 3637c478bd9Sstevel@tonic-gate #define GLD_MK_VTAG(ptag, pri) ((ptag) & GLD_MK_PMSK(pri)) 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate /* 3667c478bd9Sstevel@tonic-gate * Deconstruct a VTAG ... 3677c478bd9Sstevel@tonic-gate */ 3687c478bd9Sstevel@tonic-gate #define GLD_VTAG_TPID(vtag) (((vtag) & VLAN_TPID_MASK) >> VLAN_TPID_SHIFT) 3697c478bd9Sstevel@tonic-gate #define GLD_VTAG_TCI(vtag) (((vtag) & VLAN_TCI_MASK) >> VLAN_TCI_SHIFT) 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate #define GLD_VTAG_PRI(vtag) (((vtag) & VLAN_PRI_MASK) >> VLAN_PRI_SHIFT) 3727c478bd9Sstevel@tonic-gate #define GLD_VTAG_CFI(vtag) (((vtag) & VLAN_CFI_MASK) >> VLAN_CFI_SHIFT) 3737c478bd9Sstevel@tonic-gate #define GLD_VTAG_VID(vtag) (((vtag) & VLAN_VID_MASK) >> VLAN_VID_SHIFT) 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3767c478bd9Sstevel@tonic-gate } 3777c478bd9Sstevel@tonic-gate #endif 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate #endif /* _SYS_GLD_H */ 380