mikroSDK Reference Manual
am64x_eth_driver.h
Go to the documentation of this file.
1
31#ifndef _AM64X_ETH_DRIVER_H
32#define _AM64X_ETH_DRIVER_H
33
34//Dependencies
35#include "core/nic.h"
36
37//CPSW ports
38#define CPSW_PORT0 0
39#define CPSW_PORT1 1
40#define CPSW_PORT2 2
41
42//CPSW channels
43#define CPSW_CH0 0
44#define CPSW_CH1 1
45#define CPSW_CH2 2
46#define CPSW_CH3 3
47#define CPSW_CH4 4
48#define CPSW_CH5 5
49#define CPSW_CH6 6
50#define CPSW_CH7 7
51
52//Number of entries in the ALE table
53#define CPSW_ALE_MAX_ENTRIES 512
54
55//ALE table entry
56#define CPSW_ALE_WORD1_ENTRY_TYPE_MASK (3 << 28)
57#define CPSW_ALE_WORD1_ENTRY_TYPE_FREE (0 << 28)
58#define CPSW_ALE_WORD1_ENTRY_TYPE_ADDR (1 << 28)
59#define CPSW_ALE_WORD1_ENTRY_TYPE_VLAN (2 << 28)
60#define CPSW_ALE_WORD1_ENTRY_TYPE_VLAN_ADDR (3 << 28)
61#define CPSW_ALE_WORD1_MULTICAST (1 << 8)
62
63//Unicast address table entry
64#define CPSW_ALE_WORD2_TRUNK (1 << 4)
65#define CPSW_ALE_WORD2_PORT_NUMBER_MASK (3 << 2)
66#define CPSW_ALE_WORD2_PORT_NUMBER(n) ((n) << 2)
67#define CPSW_ALE_WORD2_BLOCK (1 << 1)
68#define CPSW_ALE_WORD2_SECURE (1 << 0)
69#define CPSW_ALE_WORD1_UNICAST_TYPE_MASK (3 << 30)
70#define CPSW_ALE_WORD1_UNICAST_TYPE(n) ((n) << 30)
71
72//Multicast address table entry
73#define CPSW_ALE_WORD2_PORT_MASK_MASK (3 << 2)
74#define CPSW_ALE_WORD2_PORT_MASK(n) ((n) << 2)
75#define CPSW_ALE_WORD2_SUPER (1 << 1)
76#define CPSW_ALE_WORD1_MCAST_FWD_STATE_MASK (3 << 30)
77#define CPSW_ALE_WORD1_MCAST_FWD_STATE(n) ((n) << 30)
78
79//VLAN table entry
80#define CPSW_ALE_WORD2_NO_LEARN_MASK_MASK (7 << 2)
81#define CPSW_ALE_WORD2_NO_LEARN_MASK(n) ((n) << 2)
82#define CPSW_ALE_WORD2_VLAN_FORCE_INGRESS_CHECK (7 << 1)
83#define CPSW_ALE_WORD1_VLAN_ID_MASK (4095 << 16)
84#define CPSW_ALE_WORD1_VLAN_ID(n) ((n) << 16)
85#define CPSW_ALE_WORD1_NOFRAG (1 << 15)
86#define CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX_MASK (7 << 4)
87#define CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX(n) ((n) << 4)
88#define CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS_MASK (7 << 24)
89#define CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS(n) ((n) << 24)
90#define CPSW_ALE_WORD0_LMTNXTHDR (1 << 23)
91#define CPSW_ALE_WORD0_UREGMSK_MASK (7 << 12)
92#define CPSW_ALE_WORD0_UREGMSK(n) ((n) << 12)
93#define CPSW_ALE_WORD0_VLAN_MEMBER_LIST_MASK (7 << 0)
94#define CPSW_ALE_WORD0_VLAN_MEMBER_LIST(n) ((n) << 0)
95
96//C++ guard
97#ifdef __cplusplus
98extern "C" {
99#endif
100
101
106typedef struct
107{
108 uint32_t word2;
109 uint32_t word1;
110 uint32_t word0;
112
113
118typedef struct
119{
120 uint32_t tdes0;
121 uint32_t tdes1;
122 uint32_t tdes2;
123 uint32_t tdes3;
124 uint32_t tdes4;
125 uint32_t tdes5;
126 uint32_t tdes6;
127 uint32_t tdes7;
129
130
135typedef struct
136{
137 uint32_t rdes0;
138 uint32_t rdes1;
139 uint32_t rdes2;
140 uint32_t rdes3;
141 uint32_t rdes4;
142 uint32_t rdes5;
143 uint32_t rdes6;
144 uint32_t rdes7;
146
147
148//AM64x Ethernet MAC driver
149extern const NicDriver am64xEthPort1Driver;
150extern const NicDriver am64xEthPort2Driver;
151
152//AM64x Ethernet MAC related functions
153error_t am64xEthInitPort1(NetInterface *interface);
154error_t am64xEthInitPort2(NetInterface *interface);
155void am64xEthInitInstance(NetInterface *interface);
156void am64xEthInitGpio(NetInterface *interface);
157
158void am64xEthTick(NetInterface *interface);
159
160void am64xEthEnableIrq(NetInterface *interface);
161void am64xEthDisableIrq(NetInterface *interface);
162void am64xEthRxIrqHandler(void *arg);
163void am64xEthEventHandler(NetInterface *interface);
164
165error_t am64xEthSendPacket(NetInterface *interface,
166 const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
167
168error_t am64xEthUpdateMacAddrFilter(NetInterface *interface);
169error_t am64xEthUpdateMacConfig(NetInterface *interface);
170
171void am64xEthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
172 uint8_t regAddr, uint16_t data);
173
174uint16_t am64xEthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
175 uint8_t regAddr);
176
177void am64xEthWriteEntry(uint_t index, const Am64xAleEntry *entry);
178void am64xEthReadEntry(uint_t index, Am64xAleEntry *entry);
179
180uint_t am64xEthFindFreeEntry(void);
181uint_t am64xEthFindVlanEntry(uint_t vlanId);
182uint_t am64xEthFindVlanAddrEntry(uint_t vlanId, MacAddr *macAddr);
183
184error_t am64xEthAddVlanEntry(uint_t port, uint_t vlanId);
185error_t am64xEthAddVlanAddrEntry(uint_t port, uint_t vlanId, MacAddr *macAddr);
186error_t am64xEthDeleteVlanAddrEntry(uint_t port, uint_t vlanId, MacAddr *macAddr);
187
188//C++ guard
189#ifdef __cplusplus
190}
191#endif
192
193#endif
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
ALE table entry.
Definition am64x_eth_driver.h:107
Enhanced RX DMA descriptor.
Definition am64x_eth_driver.h:136
Enhanced TX DMA descriptor.
Definition am64x_eth_driver.h:119
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89
NIC driver.
Definition nic.h:283