xref: /freebsd/sys/contrib/ncsw/inc/enet_ext.h (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
1 /* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above copyright
9  *       notice, this list of conditions and the following disclaimer in the
10  *       documentation and/or other materials provided with the distribution.
11  *     * Neither the name of Freescale Semiconductor nor the
12  *       names of its contributors may be used to endorse or promote products
13  *       derived from this software without specific prior written permission.
14  *
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /**************************************************************************//**
34  @File          enet_ext.h
35 
36  @Description   Ethernet generic definitions and enums.
37 *//***************************************************************************/
38 
39 #ifndef __ENET_EXT_H
40 #define __ENET_EXT_H
41 
42 
43 #define ENET_NUM_OCTETS_PER_ADDRESS 6     /**< Number of octets (8-bit bytes) in an ethernet address */
44 #define ENET_GROUP_ADDR             0x01  /**< Group address mask for ethernet addresses */
45 
46 
47 /**************************************************************************//**
48  @Description   Ethernet Address
49 *//***************************************************************************/
50 typedef uint8_t t_EnetAddr[ENET_NUM_OCTETS_PER_ADDRESS];
51 
52 /**************************************************************************//**
53  @Description   Ethernet Address Type.
54 *//***************************************************************************/
55 typedef enum e_EnetAddrType
56 {
57     e_ENET_ADDR_TYPE_INDIVIDUAL,    /**< Individual (unicast) address */
58     e_ENET_ADDR_TYPE_GROUP,         /**< Group (multicast) address */
59     e_ENET_ADDR_TYPE_BROADCAST      /**< Broadcast address */
60 } e_EnetAddrType;
61 
62 
63 /**************************************************************************//**
64  @Description   Ethernet MAC-PHY Interface
65 *//***************************************************************************/
66 typedef enum e_EnetInterface
67 {
68     e_ENET_IF_MII   = 0x00010000,   /**< MII interface */
69     e_ENET_IF_RMII  = 0x00020000,   /**< RMII interface */
70     e_ENET_IF_SMII  = 0x00030000,   /**< SMII interface */
71     e_ENET_IF_GMII  = 0x00040000,   /**< GMII interface */
72     e_ENET_IF_RGMII = 0x00050000,   /**< RGMII interface */
73     e_ENET_IF_TBI   = 0x00060000,   /**< TBI interface */
74     e_ENET_IF_RTBI  = 0x00070000,   /**< RTBI interface */
75     e_ENET_IF_SGMII = 0x00080000,   /**< SGMII interface */
76     e_ENET_IF_XGMII = 0x00090000,   /**< XGMII interface */
77     e_ENET_IF_QSGMII= 0x000a0000    /**< QSGMII interface */
78 } e_EnetInterface;
79 
80 /**************************************************************************//**
81  @Description   Ethernet Duplex Mode
82 *//***************************************************************************/
83 typedef enum e_EnetDuplexMode
84 {
85     e_ENET_HALF_DUPLEX,             /**< Half-Duplex mode */
86     e_ENET_FULL_DUPLEX              /**< Full-Duplex mode */
87 } e_EnetDuplexMode;
88 
89 /**************************************************************************//**
90  @Description   Ethernet Speed (nominal data rate)
91 *//***************************************************************************/
92 typedef enum e_EnetSpeed
93 {
94     e_ENET_SPEED_10     = 10,       /**< 10 Mbps */
95     e_ENET_SPEED_100    = 100,      /**< 100 Mbps */
96     e_ENET_SPEED_1000   = 1000,     /**< 1000 Mbps = 1 Gbps */
97     e_ENET_SPEED_10000  = 10000     /**< 10000 Mbps = 10 Gbps */
98 } e_EnetSpeed;
99 
100 /**************************************************************************//**
101  @Description   Ethernet mode (combination of MAC-PHY interface and speed)
102 *//***************************************************************************/
103 typedef enum e_EnetMode
104 {
105     e_ENET_MODE_INVALID     = 0,                                        /**< Invalid Ethernet mode */
106     e_ENET_MODE_MII_10      = (e_ENET_IF_MII   | e_ENET_SPEED_10),      /**<    10 Mbps MII   */
107     e_ENET_MODE_MII_100     = (e_ENET_IF_MII   | e_ENET_SPEED_100),     /**<   100 Mbps MII   */
108     e_ENET_MODE_RMII_10     = (e_ENET_IF_RMII  | e_ENET_SPEED_10),      /**<    10 Mbps RMII  */
109     e_ENET_MODE_RMII_100    = (e_ENET_IF_RMII  | e_ENET_SPEED_100),     /**<   100 Mbps RMII  */
110     e_ENET_MODE_SMII_10     = (e_ENET_IF_SMII  | e_ENET_SPEED_10),      /**<    10 Mbps SMII  */
111     e_ENET_MODE_SMII_100    = (e_ENET_IF_SMII  | e_ENET_SPEED_100),     /**<   100 Mbps SMII  */
112     e_ENET_MODE_GMII_1000   = (e_ENET_IF_GMII  | e_ENET_SPEED_1000),    /**<  1000 Mbps GMII  */
113     e_ENET_MODE_RGMII_10    = (e_ENET_IF_RGMII | e_ENET_SPEED_10),      /**<    10 Mbps RGMII */
114     e_ENET_MODE_RGMII_100   = (e_ENET_IF_RGMII | e_ENET_SPEED_100),     /**<   100 Mbps RGMII */
115     e_ENET_MODE_RGMII_1000  = (e_ENET_IF_RGMII | e_ENET_SPEED_1000),    /**<  1000 Mbps RGMII */
116     e_ENET_MODE_TBI_1000    = (e_ENET_IF_TBI   | e_ENET_SPEED_1000),    /**<  1000 Mbps TBI   */
117     e_ENET_MODE_RTBI_1000   = (e_ENET_IF_RTBI  | e_ENET_SPEED_1000),    /**<  1000 Mbps RTBI  */
118     e_ENET_MODE_SGMII_10    = (e_ENET_IF_SGMII | e_ENET_SPEED_10),      /**<    10 Mbps SGMII */
119     e_ENET_MODE_SGMII_100   = (e_ENET_IF_SGMII | e_ENET_SPEED_100),     /**<   100 Mbps SGMII */
120     e_ENET_MODE_SGMII_1000  = (e_ENET_IF_SGMII | e_ENET_SPEED_1000),    /**<  1000 Mbps SGMII */
121     e_ENET_MODE_XGMII_10000 = (e_ENET_IF_XGMII | e_ENET_SPEED_10000),    /**< 10000 Mbps XGMII */
122     e_ENET_MODE_QSGMII_1000 = (e_ENET_IF_QSGMII| e_ENET_SPEED_1000)    /**<  1000 Mbps QSGMII */
123 } e_EnetMode;
124 
125 
126 #define IS_ENET_MODE_VALID(mode) \
127         (((mode) == e_ENET_MODE_MII_10     ) || \
128          ((mode) == e_ENET_MODE_MII_100    ) || \
129          ((mode) == e_ENET_MODE_RMII_10    ) || \
130          ((mode) == e_ENET_MODE_RMII_100   ) || \
131          ((mode) == e_ENET_MODE_SMII_10    ) || \
132          ((mode) == e_ENET_MODE_SMII_100   ) || \
133          ((mode) == e_ENET_MODE_GMII_1000  ) || \
134          ((mode) == e_ENET_MODE_RGMII_10   ) || \
135          ((mode) == e_ENET_MODE_RGMII_100  ) || \
136          ((mode) == e_ENET_MODE_RGMII_1000 ) || \
137          ((mode) == e_ENET_MODE_TBI_1000   ) || \
138          ((mode) == e_ENET_MODE_RTBI_1000  ) || \
139          ((mode) == e_ENET_MODE_SGMII_10   ) || \
140          ((mode) == e_ENET_MODE_SGMII_100  ) || \
141          ((mode) == e_ENET_MODE_SGMII_1000 ) || \
142          ((mode) == e_ENET_MODE_XGMII_10000) || \
143          ((mode) == e_ENET_MODE_QSGMII_1000))
144 
145 
146 #define MAKE_ENET_MODE(_interface, _speed)     (e_EnetMode)((_interface) | (_speed))
147 
148 #define ENET_INTERFACE_FROM_MODE(mode)          (e_EnetInterface)((mode) & 0xFFFF0000)
149 #define ENET_SPEED_FROM_MODE(mode)              (e_EnetSpeed)((mode) & 0x0000FFFF)
150 
151 
152 
153 #endif /* __ENET_EXT_H */
154 
155