ClearCore Library
Loading...
Searching...
No Matches
EthernetApi.h
1/*
2 * Copyright (c) 2020 Teknic, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#ifndef HIDE_FROM_DOXYGEN
33#ifndef __ETHERNETAPI_H__
34#define __ETHERNETAPI_H__
35
36#include <stdint.h>
37
38#ifndef TX_BUFF_CNT
39#define TX_BUFF_CNT (8)
40#endif
41
42#ifndef RX_BUFF_CNT
43#define RX_BUFF_CNT (16)
44#endif
45
46#ifndef TX_BUFFER_SIZE
47#define TX_BUFFER_SIZE (520)
48#endif
49
50#ifndef RX_BUFFER_SIZE
51#define RX_BUFFER_SIZE (128)
52#endif
53
59typedef union {
60 struct {
61uint32_t OWN :
62 1;
63uint32_t WRAP :
64 1;
65uint32_t ADDR :
66 30;
67uint32_t LEN :
68 13;
69uint32_t FCS :
70 1;
71uint32_t SF :
72 1;
73 uint32_t EF : 1;
74 uint32_t CFI : 1;
75 uint32_t VLAN : 3;
76 uint32_t PTAG : 1;
77 uint32_t VTAG : 1;
78uint32_t CSM :
79 2;
80uint32_t SNAP :
81 1;
82uint32_t SPAMI :
83 2;
84uint32_t SPAM :
85 1;
86 uint32_t: 1;
87 uint32_t UHM : 1;
88 uint32_t MHM : 1;
89 uint32_t GAO : 1;
90 } bit;
91 uint32_t reg[2];
92} GMAC_RX_DESC;
93
99typedef union {
100 struct {
101 uint32_t ADDR : 32;
102 uint32_t LEN : 14;
103 uint32_t: 1;
104 uint32_t LB : 1;
105uint32_t CRC :
106 1;
107 uint32_t: 3;
108uint32_t CSER :
109 3;
110 uint32_t: 3;
111uint32_t LCERR :
112 1;
113uint32_t FCERR :
114 1;
115 uint32_t: 1;
116uint32_t RLERR :
117 1;
118uint32_t WRAP :
119 1;
120 uint32_t OWN : 1;
121 } bit;
122 uint32_t reg[2];
123} GMAC_TX_DESC;
124
131typedef struct {
132 GMAC_RX_DESC *rxDesc; /* Receive buffer descriptor address */
133 GMAC_TX_DESC *txDesc; /* Transmit buffer descriptor address */
134 uint8_t *rxBuffIndex; /* Receive buffer index */
135 uint16_t *txBuffIndex; /* Transmit buffer index */
136 uint8_t mac[6]; /* MAC address */
137} ethInt;
138
139typedef struct netif netInt;
140typedef struct pbuf packetBuf;
141
142#endif // !__ETHERNETAPI_H__
143#endif // !HIDE_FROM_DOXYGEN