2 * Copyright 2008-2012 Freescale Semiconductor Inc.
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.
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
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.
34 /******************************************************************************
37 @Description FM MAC ...
38 *//***************************************************************************/
43 #include "error_ext.h"
45 #include "fm_mac_ext.h"
46 #include "fm_common.h"
49 #define __ERR_MODULE__ MODULE_FM_MAC
51 /**************************************************************************//**
53 *//***************************************************************************/
56 #define DEFAULT_halfDuplex FALSE
57 #define DEFAULT_padAndCrcEnable TRUE
58 #define DEFAULT_resetOnInit FALSE
62 uint64_t addr; /* Ethernet Address */
65 #define ETH_HASH_ENTRY_OBJ(ptr) NCSW_LIST_OBJECT(ptr, t_EthHashEntry, node)
73 t_Error (*f_FM_MAC_Init) (t_Handle h_FmMac);
74 t_Error (*f_FM_MAC_Free) (t_Handle h_FmMac);
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 */
90 t_Error (*f_FM_MAC_SetException) (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);
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);
99 t_Error (*f_FM_MAC_SetTxAutoPauseFrames) (t_Handle h_FmMac,
101 t_Error (*f_FM_MAC_SetTxPauseFrames) (t_Handle h_FmMac,
104 uint16_t threshTime);
105 t_Error (*f_FM_MAC_SetRxIgnorePauseFrames) (t_Handle h_FmMac, bool en);
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);
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);
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);
120 t_Error (*f_FM_MAC_SetWakeOnLan) (t_Handle h_FmMac, bool en);
122 t_Error (*f_FM_MAC_GetId) (t_Handle h_FmMac, uint32_t *macId);
124 t_Error (*f_FM_MAC_GetVersion) (t_Handle h_FmMac, uint32_t *macVersion);
126 uint16_t (*f_FM_MAC_GetMaxFrameLength) (t_Handle h_FmMac);
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);
131 #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
132 t_Error (*f_FM_MAC_DumpRegs) (t_Handle h_FmMac);
133 #endif /* (defined(DEBUG_ERRORS) && ... */
136 t_FmRevisionInfo fmRevInfo;
141 } t_FmMacControllerDriver;
144 #if (DPAA_VERSION == 10)
145 t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam);
146 t_Handle TGEC_Config(t_FmMacParams *p_FmMacParams);
148 t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam);
149 #endif /* (DPAA_VERSION == 10) */
150 uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);
153 /* ........................................................................... */
155 static __inline__ t_EthHashEntry *DequeueAddrFromHashEntry(t_List *p_AddrLst)
157 t_EthHashEntry *p_HashEntry = NULL;
158 if (!NCSW_LIST_IsEmpty(p_AddrLst))
160 p_HashEntry = ETH_HASH_ENTRY_OBJ(p_AddrLst->p_Next);
161 NCSW_LIST_DelAndInit(&p_HashEntry->node);
166 /* ........................................................................... */
168 static __inline__ void FreeHashTable(t_EthHash *p_Hash)
170 t_EthHashEntry *p_HashEntry;
177 for (i=0; i<p_Hash->size; i++)
179 p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
182 XX_Free(p_HashEntry);
183 p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
187 XX_Free(p_Hash->p_Lsts);
194 /* ........................................................................... */
196 static __inline__ t_EthHash * AllocHashTable(uint16_t size)
201 /* Allocate address hash table */
202 p_Hash = (t_EthHash *)XX_Malloc(sizeof(t_EthHash));
205 REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));
210 p_Hash->p_Lsts = (t_List *)XX_Malloc(p_Hash->size*sizeof(t_List));
213 REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));
218 for (i=0 ; i<p_Hash->size; i++)
219 INIT_LIST(&p_Hash->p_Lsts[i]);
225 #endif /* __FM_MAC_H */