Path: blob/main/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.h
48524 views
/*1* Copyright 2008-2012 Freescale Semiconductor Inc.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions are met:5* * Redistributions of source code must retain the above copyright6* notice, this list of conditions and the following disclaimer.7* * Redistributions in binary form must reproduce the above copyright8* notice, this list of conditions and the following disclaimer in the9* documentation and/or other materials provided with the distribution.10* * Neither the name of Freescale Semiconductor nor the11* names of its contributors may be used to endorse or promote products12* derived from this software without specific prior written permission.13*14*15* ALTERNATIVELY, this software may be distributed under the terms of the16* GNU General Public License ("GPL") as published by the Free Software17* Foundation, either version 2 of that License or (at your option) any18* later version.19*20* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY21* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED22* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE23* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY24* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES25* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;26* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND27* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT28* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS29* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30*/313233/******************************************************************************34@File fm_mac.h3536@Description FM MAC ...37*//***************************************************************************/38#ifndef __FM_MAC_H39#define __FM_MAC_H4041#include "std_ext.h"42#include "error_ext.h"43#include "list_ext.h"44#include "fm_mac_ext.h"45#include "fm_common.h"464748#define __ERR_MODULE__ MODULE_FM_MAC4950/**************************************************************************//**51@Description defaults52*//***************************************************************************/535455#define DEFAULT_halfDuplex FALSE56#define DEFAULT_padAndCrcEnable TRUE57#define DEFAULT_resetOnInit FALSE585960typedef struct {61uint64_t addr; /* Ethernet Address */62t_List node;63} t_EthHashEntry;64#define ETH_HASH_ENTRY_OBJ(ptr) NCSW_LIST_OBJECT(ptr, t_EthHashEntry, node)6566typedef struct {67uint16_t size;68t_List *p_Lsts;69} t_EthHash;7071typedef struct {72t_Error (*f_FM_MAC_Init) (t_Handle h_FmMac);73t_Error (*f_FM_MAC_Free) (t_Handle h_FmMac);7475t_Error (*f_FM_MAC_SetStatistics) (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);76t_Error (*f_FM_MAC_ConfigLoopback) (t_Handle h_FmMac, bool newVal);77t_Error (*f_FM_MAC_ConfigMaxFrameLength) (t_Handle h_FmMac, uint16_t newVal);78t_Error (*f_FM_MAC_ConfigWan) (t_Handle h_FmMac, bool flag);79t_Error (*f_FM_MAC_ConfigPadAndCrc) (t_Handle h_FmMac, bool newVal);80t_Error (*f_FM_MAC_ConfigHalfDuplex) (t_Handle h_FmMac, bool newVal);81t_Error (*f_FM_MAC_ConfigLengthCheck) (t_Handle h_FmMac, bool newVal);82t_Error (*f_FM_MAC_ConfigTbiPhyAddr) (t_Handle h_FmMac, uint8_t newVal);83t_Error (*f_FM_MAC_ConfigException) (t_Handle h_FmMac, e_FmMacExceptions, bool enable);84t_Error (*f_FM_MAC_ConfigResetOnInit) (t_Handle h_FmMac, bool enable);85#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A00486t_Error (*f_FM_MAC_ConfigSkipFman11Workaround) (t_Handle h_FmMac);87#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */8889t_Error (*f_FM_MAC_SetException) (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);9091t_Error (*f_FM_MAC_Enable) (t_Handle h_FmMac, e_CommMode mode);92t_Error (*f_FM_MAC_Disable) (t_Handle h_FmMac, e_CommMode mode);93t_Error (*f_FM_MAC_Resume) (t_Handle h_FmMac);94t_Error (*f_FM_MAC_Enable1588TimeStamp) (t_Handle h_FmMac);95t_Error (*f_FM_MAC_Disable1588TimeStamp) (t_Handle h_FmMac);96t_Error (*f_FM_MAC_Reset) (t_Handle h_FmMac, bool wait);9798t_Error (*f_FM_MAC_SetTxAutoPauseFrames) (t_Handle h_FmMac,99uint16_t pauseTime);100t_Error (*f_FM_MAC_SetTxPauseFrames) (t_Handle h_FmMac,101uint8_t priority,102uint16_t pauseTime,103uint16_t threshTime);104t_Error (*f_FM_MAC_SetRxIgnorePauseFrames) (t_Handle h_FmMac, bool en);105106t_Error (*f_FM_MAC_ResetCounters) (t_Handle h_FmMac);107t_Error (*f_FM_MAC_GetStatistics) (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);108109t_Error (*f_FM_MAC_ModifyMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);110t_Error (*f_FM_MAC_AddHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);111t_Error (*f_FM_MAC_RemoveHashMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);112t_Error (*f_FM_MAC_AddExactMatchMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);113t_Error (*f_FM_MAC_RemovelExactMatchMacAddr) (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);114115t_Error (*f_FM_MAC_SetPromiscuous) (t_Handle h_FmMac, bool newVal);116t_Error (*f_FM_MAC_AdjustLink) (t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);117t_Error (*f_FM_MAC_RestartAutoneg) (t_Handle h_FmMac);118119t_Error (*f_FM_MAC_SetWakeOnLan) (t_Handle h_FmMac, bool en);120121t_Error (*f_FM_MAC_GetId) (t_Handle h_FmMac, uint32_t *macId);122123t_Error (*f_FM_MAC_GetVersion) (t_Handle h_FmMac, uint32_t *macVersion);124125uint16_t (*f_FM_MAC_GetMaxFrameLength) (t_Handle h_FmMac);126127t_Error (*f_FM_MAC_MII_WritePhyReg)(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);128t_Error (*f_FM_MAC_MII_ReadPhyReg)(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);129130#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))131t_Error (*f_FM_MAC_DumpRegs) (t_Handle h_FmMac);132#endif /* (defined(DEBUG_ERRORS) && ... */133134t_Handle h_Fm;135t_FmRevisionInfo fmRevInfo;136e_EnetMode enetMode;137uint8_t macId;138bool resetOnInit;139uint16_t clkFreq;140} t_FmMacControllerDriver;141142143#if (DPAA_VERSION == 10)144t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam);145t_Handle TGEC_Config(t_FmMacParams *p_FmMacParams);146#else147t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam);148#endif /* (DPAA_VERSION == 10) */149uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);150151152/* ........................................................................... */153154static __inline__ t_EthHashEntry *DequeueAddrFromHashEntry(t_List *p_AddrLst)155{156t_EthHashEntry *p_HashEntry = NULL;157if (!NCSW_LIST_IsEmpty(p_AddrLst))158{159p_HashEntry = ETH_HASH_ENTRY_OBJ(p_AddrLst->p_Next);160NCSW_LIST_DelAndInit(&p_HashEntry->node);161}162return p_HashEntry;163}164165/* ........................................................................... */166167static __inline__ void FreeHashTable(t_EthHash *p_Hash)168{169t_EthHashEntry *p_HashEntry;170int i = 0;171172if (p_Hash)173{174if (p_Hash->p_Lsts)175{176for (i=0; i<p_Hash->size; i++)177{178p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);179while (p_HashEntry)180{181XX_Free(p_HashEntry);182p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);183}184}185186XX_Free(p_Hash->p_Lsts);187}188189XX_Free(p_Hash);190}191}192193/* ........................................................................... */194195static __inline__ t_EthHash * AllocHashTable(uint16_t size)196{197uint32_t i;198t_EthHash *p_Hash;199200/* Allocate address hash table */201p_Hash = (t_EthHash *)XX_Malloc(sizeof(t_EthHash));202if (!p_Hash)203{204REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));205return NULL;206}207p_Hash->size = size;208209p_Hash->p_Lsts = (t_List *)XX_Malloc(p_Hash->size*sizeof(t_List));210if (!p_Hash->p_Lsts)211{212REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));213XX_Free(p_Hash);214return NULL;215}216217for (i=0 ; i<p_Hash->size; i++)218INIT_LIST(&p_Hash->p_Lsts[i]);219220return p_Hash;221}222223224#endif /* __FM_MAC_H */225226227