Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.h
48524 views
1
/*
2
* Copyright 2008-2012 Freescale Semiconductor Inc.
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
/******************************************************************************
35
@File fm_mac.h
36
37
@Description FM MAC ...
38
*//***************************************************************************/
39
#ifndef __FM_MAC_H
40
#define __FM_MAC_H
41
42
#include "std_ext.h"
43
#include "error_ext.h"
44
#include "list_ext.h"
45
#include "fm_mac_ext.h"
46
#include "fm_common.h"
47
48
49
#define __ERR_MODULE__ MODULE_FM_MAC
50
51
/**************************************************************************//**
52
@Description defaults
53
*//***************************************************************************/
54
55
56
#define DEFAULT_halfDuplex FALSE
57
#define DEFAULT_padAndCrcEnable TRUE
58
#define DEFAULT_resetOnInit FALSE
59
60
61
typedef struct {
62
uint64_t addr; /* Ethernet Address */
63
t_List node;
64
} t_EthHashEntry;
65
#define ETH_HASH_ENTRY_OBJ(ptr) NCSW_LIST_OBJECT(ptr, t_EthHashEntry, node)
66
67
typedef struct {
68
uint16_t size;
69
t_List *p_Lsts;
70
} t_EthHash;
71
72
typedef struct {
73
t_Error (*f_FM_MAC_Init) (t_Handle h_FmMac);
74
t_Error (*f_FM_MAC_Free) (t_Handle h_FmMac);
75
76
t_Error (*f_FM_MAC_SetStatistics) (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);
77
t_Error (*f_FM_MAC_ConfigLoopback) (t_Handle h_FmMac, bool newVal);
78
t_Error (*f_FM_MAC_ConfigMaxFrameLength) (t_Handle h_FmMac, uint16_t newVal);
79
t_Error (*f_FM_MAC_ConfigWan) (t_Handle h_FmMac, bool flag);
80
t_Error (*f_FM_MAC_ConfigPadAndCrc) (t_Handle h_FmMac, bool newVal);
81
t_Error (*f_FM_MAC_ConfigHalfDuplex) (t_Handle h_FmMac, bool newVal);
82
t_Error (*f_FM_MAC_ConfigLengthCheck) (t_Handle h_FmMac, bool newVal);
83
t_Error (*f_FM_MAC_ConfigTbiPhyAddr) (t_Handle h_FmMac, uint8_t newVal);
84
t_Error (*f_FM_MAC_ConfigException) (t_Handle h_FmMac, e_FmMacExceptions, bool enable);
85
t_Error (*f_FM_MAC_ConfigResetOnInit) (t_Handle h_FmMac, bool enable);
86
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
87
t_Error (*f_FM_MAC_ConfigSkipFman11Workaround) (t_Handle h_FmMac);
88
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
89
90
t_Error (*f_FM_MAC_SetException) (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);
91
92
t_Error (*f_FM_MAC_Enable) (t_Handle h_FmMac, e_CommMode mode);
93
t_Error (*f_FM_MAC_Disable) (t_Handle h_FmMac, e_CommMode mode);
94
t_Error (*f_FM_MAC_Resume) (t_Handle h_FmMac);
95
t_Error (*f_FM_MAC_Enable1588TimeStamp) (t_Handle h_FmMac);
96
t_Error (*f_FM_MAC_Disable1588TimeStamp) (t_Handle h_FmMac);
97
t_Error (*f_FM_MAC_Reset) (t_Handle h_FmMac, bool wait);
98
99
t_Error (*f_FM_MAC_SetTxAutoPauseFrames) (t_Handle h_FmMac,
100
uint16_t pauseTime);
101
t_Error (*f_FM_MAC_SetTxPauseFrames) (t_Handle h_FmMac,
102
uint8_t priority,
103
uint16_t pauseTime,
104
uint16_t threshTime);
105
t_Error (*f_FM_MAC_SetRxIgnorePauseFrames) (t_Handle h_FmMac, bool en);
106
107
t_Error (*f_FM_MAC_ResetCounters) (t_Handle h_FmMac);
108
t_Error (*f_FM_MAC_GetStatistics) (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
109
110
t_Error (*f_FM_MAC_ModifyMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
111
t_Error (*f_FM_MAC_AddHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
112
t_Error (*f_FM_MAC_RemoveHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
113
t_Error (*f_FM_MAC_AddExactMatchMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
114
t_Error (*f_FM_MAC_RemovelExactMatchMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
115
116
t_Error (*f_FM_MAC_SetPromiscuous) (t_Handle h_FmMac, bool newVal);
117
t_Error (*f_FM_MAC_AdjustLink) (t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
118
t_Error (*f_FM_MAC_RestartAutoneg) (t_Handle h_FmMac);
119
120
t_Error (*f_FM_MAC_SetWakeOnLan) (t_Handle h_FmMac, bool en);
121
122
t_Error (*f_FM_MAC_GetId) (t_Handle h_FmMac, uint32_t *macId);
123
124
t_Error (*f_FM_MAC_GetVersion) (t_Handle h_FmMac, uint32_t *macVersion);
125
126
uint16_t (*f_FM_MAC_GetMaxFrameLength) (t_Handle h_FmMac);
127
128
t_Error (*f_FM_MAC_MII_WritePhyReg)(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);
129
t_Error (*f_FM_MAC_MII_ReadPhyReg)(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
130
131
#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
132
t_Error (*f_FM_MAC_DumpRegs) (t_Handle h_FmMac);
133
#endif /* (defined(DEBUG_ERRORS) && ... */
134
135
t_Handle h_Fm;
136
t_FmRevisionInfo fmRevInfo;
137
e_EnetMode enetMode;
138
uint8_t macId;
139
bool resetOnInit;
140
uint16_t clkFreq;
141
} t_FmMacControllerDriver;
142
143
144
#if (DPAA_VERSION == 10)
145
t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam);
146
t_Handle TGEC_Config(t_FmMacParams *p_FmMacParams);
147
#else
148
t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam);
149
#endif /* (DPAA_VERSION == 10) */
150
uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);
151
152
153
/* ........................................................................... */
154
155
static __inline__ t_EthHashEntry *DequeueAddrFromHashEntry(t_List *p_AddrLst)
156
{
157
t_EthHashEntry *p_HashEntry = NULL;
158
if (!NCSW_LIST_IsEmpty(p_AddrLst))
159
{
160
p_HashEntry = ETH_HASH_ENTRY_OBJ(p_AddrLst->p_Next);
161
NCSW_LIST_DelAndInit(&p_HashEntry->node);
162
}
163
return p_HashEntry;
164
}
165
166
/* ........................................................................... */
167
168
static __inline__ void FreeHashTable(t_EthHash *p_Hash)
169
{
170
t_EthHashEntry *p_HashEntry;
171
int i = 0;
172
173
if (p_Hash)
174
{
175
if (p_Hash->p_Lsts)
176
{
177
for (i=0; i<p_Hash->size; i++)
178
{
179
p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
180
while (p_HashEntry)
181
{
182
XX_Free(p_HashEntry);
183
p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
184
}
185
}
186
187
XX_Free(p_Hash->p_Lsts);
188
}
189
190
XX_Free(p_Hash);
191
}
192
}
193
194
/* ........................................................................... */
195
196
static __inline__ t_EthHash * AllocHashTable(uint16_t size)
197
{
198
uint32_t i;
199
t_EthHash *p_Hash;
200
201
/* Allocate address hash table */
202
p_Hash = (t_EthHash *)XX_Malloc(sizeof(t_EthHash));
203
if (!p_Hash)
204
{
205
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));
206
return NULL;
207
}
208
p_Hash->size = size;
209
210
p_Hash->p_Lsts = (t_List *)XX_Malloc(p_Hash->size*sizeof(t_List));
211
if (!p_Hash->p_Lsts)
212
{
213
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));
214
XX_Free(p_Hash);
215
return NULL;
216
}
217
218
for (i=0 ; i<p_Hash->size; i++)
219
INIT_LIST(&p_Hash->p_Lsts[i]);
220
221
return p_Hash;
222
}
223
224
225
#endif /* __FM_MAC_H */
226
227