| 1 | /*
|
|---|
| 2 | * Copyright (c) 2011 Radim Vansa
|
|---|
| 3 | * Copyright (c) 2011 Jiri Michalec
|
|---|
| 4 | * All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 7 | * modification, are permitted provided that the following conditions
|
|---|
| 8 | * are met:
|
|---|
| 9 | *
|
|---|
| 10 | * - Redistributions of source code must retain the above copyright
|
|---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 14 | * documentation and/or other materials provided with the distribution.
|
|---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 16 | * derived from this software without specific prior written permission.
|
|---|
| 17 | *
|
|---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | #ifndef LIBC_NET_ETH_PHYS_H_
|
|---|
| 31 | #define LIBC_NET_ETH_PHYS_H_
|
|---|
| 32 |
|
|---|
| 33 | #include <sys/types.h>
|
|---|
| 34 |
|
|---|
| 35 | /*****************************************************/
|
|---|
| 36 | /* Definitions of possible supported physical layers */
|
|---|
| 37 | /*****************************************************/
|
|---|
| 38 |
|
|---|
| 39 | /* Ethernet physical layers */
|
|---|
| 40 | #define ETH_OLD 0
|
|---|
| 41 | #define ETH_10M 1
|
|---|
| 42 | #define ETH_100M 2
|
|---|
| 43 | #define ETH_1000M 3
|
|---|
| 44 | #define ETH_10G 4
|
|---|
| 45 | #define ETH_40G_100G 5
|
|---|
| 46 | /* 6, 7 reserved for future use */
|
|---|
| 47 | #define ETH_PHYS_LAYERS 8
|
|---|
| 48 |
|
|---|
| 49 | /* < 10Mbs ethernets */
|
|---|
| 50 | #define ETH_EXPERIMENTAL 0x0001
|
|---|
| 51 | #define ETH_1BASE5 0x0002
|
|---|
| 52 | /* 10Mbs ethernets */
|
|---|
| 53 | #define ETH_10BASE5 0x0001
|
|---|
| 54 | #define ETH_10BASE2 0x0002
|
|---|
| 55 | #define ETH_10BROAD36 0x0004
|
|---|
| 56 | #define ETH_STARLAN_10 0x0008
|
|---|
| 57 | #define ETH_LATTISNET 0x0010
|
|---|
| 58 | #define ETH_10BASE_T 0x0020
|
|---|
| 59 | #define ETH_FOIRL 0x0040
|
|---|
| 60 | #define ETH_10BASE_FL 0x0080
|
|---|
| 61 | #define ETH_10BASE_FB 0x0100
|
|---|
| 62 | #define ETH_10BASE_FP 0x0200
|
|---|
| 63 | /* 100Mbs (fast) ethernets */
|
|---|
| 64 | #define ETH_100BASE_TX 0x0001
|
|---|
| 65 | #define ETH_100BASE_T4 0x0002
|
|---|
| 66 | #define ETH_100BASE_T2 0x0004
|
|---|
| 67 | #define ETH_100BASE_FX 0x0008
|
|---|
| 68 | #define ETH_100BASE_SX 0x0010
|
|---|
| 69 | #define ETH_100BASE_BX10 0x0020
|
|---|
| 70 | #define ETH_100BASE_LX10 0x0040
|
|---|
| 71 | #define ETH_100BASE_VG 0x0080
|
|---|
| 72 | /* 1000Mbs (gigabit) ethernets */
|
|---|
| 73 | #define ETH_1000BASE_T 0x0001
|
|---|
| 74 | #define ETH_1000BASE_TX 0x0002
|
|---|
| 75 | #define ETH_1000BASE_SX 0x0004
|
|---|
| 76 | #define ETH_1000BASE_LX 0x0008
|
|---|
| 77 | #define ETH_1000BASE_LH 0x0010
|
|---|
| 78 | #define ETH_1000BASE_CX 0x0020
|
|---|
| 79 | #define ETH_1000BASE_BX10 0x0040
|
|---|
| 80 | #define ETH_1000BASE_LX10 0x0080
|
|---|
| 81 | #define ETH_1000BASE_PX10_D 0x0100
|
|---|
| 82 | #define ETH_1000BASE_PX10_U 0x0200
|
|---|
| 83 | #define ETH_1000BASE_PX20_D 0x0400
|
|---|
| 84 | #define ETH_1000BASE_PX20_U 0x0800
|
|---|
| 85 | #define ETH_1000BASE_ZX 0x1000
|
|---|
| 86 | #define ETH_1000BASE_KX 0x2000
|
|---|
| 87 | /* 10Gbs ethernets */
|
|---|
| 88 | #define ETH_10GBASE_SR 0x0001
|
|---|
| 89 | #define ETH_10GBASE_LX4 0x0002
|
|---|
| 90 | #define ETH_10GBASE_LR 0x0004
|
|---|
| 91 | #define ETH_10GBASE_ER 0x0008
|
|---|
| 92 | #define ETH_10GBASE_SW 0x0010
|
|---|
| 93 | #define ETH_10GBASE_LW 0x0020
|
|---|
| 94 | #define ETH_10GBASE_EW 0x0040
|
|---|
| 95 | #define ETH_10GBASE_CX4 0x0080
|
|---|
| 96 | #define ETH_10GBASE_T 0x0100
|
|---|
| 97 | #define ETH_10GBASE_LRM 0x0200
|
|---|
| 98 | #define ETH_10GBASE_KX4 0x0400
|
|---|
| 99 | #define ETH_10GBASE_KR 0x0800
|
|---|
| 100 | /* 40Gbs and 100Gbs ethernets */
|
|---|
| 101 | #define ETH_40GBASE_SR4 0x0001
|
|---|
| 102 | #define ETH_40GBASE_LR4 0x0002
|
|---|
| 103 | #define ETH_40GBASE_CR4 0x0004
|
|---|
| 104 | #define ETH_40GBASE_KR4 0x0008
|
|---|
| 105 | #define ETH_100GBASE_SR10 0x0010
|
|---|
| 106 | #define ETH_100GBASE_LR4 0x0020
|
|---|
| 107 | #define ETH_100GBASE_ER4 0x0040
|
|---|
| 108 | #define ETH_100GBASE_CR10 0x0080
|
|---|
| 109 |
|
|---|
| 110 | /******************************************/
|
|---|
| 111 | /* Auto-negotiation advertisement options */
|
|---|
| 112 | /******************************************/
|
|---|
| 113 |
|
|---|
| 114 | #define ETH_AUTONEG_10BASE_T_HALF UINT32_C(0x00000001)
|
|---|
| 115 | #define ETH_AUTONEG_10BASE_T_FULL UINT32_C(0x00000002)
|
|---|
| 116 | #define ETH_AUTONEG_100BASE_TX_HALF UINT32_C(0x00000004)
|
|---|
| 117 | #define ETH_AUTONEG_100BASE_T4_HALF UINT32_C(0x00000008)
|
|---|
| 118 | #define ETH_AUTONEG_100BASE_T2_HALF UINT32_C(0x00000010)
|
|---|
| 119 | #define ETH_AUTONEG_100BASE_TX_FULL UINT32_C(0x00000020)
|
|---|
| 120 | #define ETH_AUTONEG_100BASE_T2_FULL UINT32_C(0x00000040)
|
|---|
| 121 | #define ETH_AUTONEG_1000BASE_T_HALF UINT32_C(0x00000080)
|
|---|
| 122 | #define ETH_AUTONEG_1000BASE_T_FULL UINT32_C(0x00000100)
|
|---|
| 123 |
|
|---|
| 124 | /** Symetric pause packet (802.3x standard) */
|
|---|
| 125 | #define ETH_AUTONEG_PAUSE_SYMETRIC UINT32_C(0x10000000)
|
|---|
| 126 | /** Asymetric pause packet (802.3z standard, gigabit ethernet) */
|
|---|
| 127 | #define ETH_AUTONEG_PAUSE_ASYMETRIC UINT32_C(0x20000000)
|
|---|
| 128 |
|
|---|
| 129 | #define ETH_AUTONEG_MODE_MASK UINT32_C(0x0FFFFFFF)
|
|---|
| 130 | #define ETH_AUTONEG_FEATURES_MASK UINT32_C(~(ETH_AUTONEG_MODE_MASK))
|
|---|
| 131 |
|
|---|
| 132 | #define ETH_AUTONEG_MODES 9
|
|---|
| 133 |
|
|---|
| 134 | struct eth_autoneg_map {
|
|---|
| 135 | uint32_t value;
|
|---|
| 136 | const char *name;
|
|---|
| 137 | };
|
|---|
| 138 |
|
|---|
| 139 | extern const char *ethernet_names[8][17];
|
|---|
| 140 | extern const struct eth_autoneg_map ethernet_autoneg_mapping[ETH_AUTONEG_MODES];
|
|---|
| 141 |
|
|---|
| 142 | #endif
|
|---|