Path: blob/main/sys/contrib/ncsw/Peripherals/FM/MAC/memac.c
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 memac.c3536@Description FM mEMAC driver37*//***************************************************************************/3839#include "std_ext.h"40#include "string_ext.h"41#include "error_ext.h"42#include "xx_ext.h"43#include "endian_ext.h"44#include "debug_ext.h"4546#include "fm_common.h"47#include "memac.h"484950/*****************************************************************************/51/* Internal routines */52/*****************************************************************************/5354/* ......................................................................... */5556static uint32_t GetMacAddrHashCode(uint64_t ethAddr)57{58uint64_t mask1, mask2;59uint32_t xorVal = 0;60uint8_t i, j;6162for (i=0; i<6; i++)63{64mask1 = ethAddr & (uint64_t)0x01;65ethAddr >>= 1;6667for (j=0; j<7; j++)68{69mask2 = ethAddr & (uint64_t)0x01;70mask1 ^= mask2;71ethAddr >>= 1;72}7374xorVal |= (mask1 << (5-i));75}7677return xorVal;78}7980/* ......................................................................... */8182static void SetupSgmiiInternalPhy(t_Memac *p_Memac, uint8_t phyAddr)83{84uint16_t tmpReg16;85e_EnetMode enetMode;8687/* In case the higher MACs are used (i.e. the MACs that should support 10G),88speed=10000 is provided for SGMII ports. Temporary modify enet mode89to 1G one, so MII functions can work correctly. */90enetMode = p_Memac->enetMode;9192/* SGMII mode + AN enable */93tmpReg16 = PHY_SGMII_IF_MODE_AN | PHY_SGMII_IF_MODE_SGMII;94if ((p_Memac->enetMode) == e_ENET_MODE_SGMII_2500)95tmpReg16 = PHY_SGMII_CR_PHY_RESET | PHY_SGMII_IF_SPEED_GIGABIT | PHY_SGMII_IF_MODE_SGMII;9697p_Memac->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Memac->enetMode), e_ENET_SPEED_1000);98MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x14, tmpReg16);99100/* Device ability according to SGMII specification */101tmpReg16 = PHY_SGMII_DEV_ABILITY_SGMII;102MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x4, tmpReg16);103104/* Adjust link timer for SGMII -105According to Cisco SGMII specification the timer should be 1.6 ms.106The link_timer register is configured in units of the clock.107- When running as 1G SGMII, Serdes clock is 125 MHz, so108unit = 1 / (125*10^6 Hz) = 8 ns.1091.6 ms in units of 8 ns = 1.6ms / 8ns = 2 * 10^5 = 0x30d40110- When running as 2.5G SGMII, Serdes clock is 312.5 MHz, so111unit = 1 / (312.5*10^6 Hz) = 3.2 ns.1121.6 ms in units of 3.2 ns = 1.6ms / 3.2ns = 5 * 10^5 = 0x7a120.113Since link_timer value of 1G SGMII will be too short for 2.5 SGMII,114we always set up here a value of 2.5 SGMII. */115MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x13, 0x0007);116MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x12, 0xa120);117118/* Restart AN */119tmpReg16 = PHY_SGMII_CR_DEF_VAL | PHY_SGMII_CR_RESET_AN;120MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x0, tmpReg16);121122/* Restore original enet mode */123p_Memac->enetMode = enetMode;124}125126/* ......................................................................... */127128static void SetupSgmiiInternalPhyBaseX(t_Memac *p_Memac, uint8_t phyAddr)129{130uint16_t tmpReg16;131e_EnetMode enetMode;132133/* In case the higher MACs are used (i.e. the MACs that should support 10G),134speed=10000 is provided for SGMII ports. Temporary modify enet mode135to 1G one, so MII functions can work correctly. */136enetMode = p_Memac->enetMode;137p_Memac->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Memac->enetMode), e_ENET_SPEED_1000);138139/* 1000BaseX mode */140tmpReg16 = PHY_SGMII_IF_MODE_1000X;141MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x14, tmpReg16);142143/* AN Device capability */144tmpReg16 = PHY_SGMII_DEV_ABILITY_1000X;145MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x4, tmpReg16);146147/* Adjust link timer for SGMII -148For Serdes 1000BaseX auto-negotiation the timer should be 10 ms.149The link_timer register is configured in units of the clock.150- When running as 1G SGMII, Serdes clock is 125 MHz, so151unit = 1 / (125*10^6 Hz) = 8 ns.15210 ms in units of 8 ns = 10ms / 8ns = 1250000 = 0x1312d0153- When running as 2.5G SGMII, Serdes clock is 312.5 MHz, so154unit = 1 / (312.5*10^6 Hz) = 3.2 ns.15510 ms in units of 3.2 ns = 10ms / 3.2ns = 3125000 = 0x2faf08.156Since link_timer value of 1G SGMII will be too short for 2.5 SGMII,157we always set up here a value of 2.5 SGMII. */158MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x13, 0x002f);159MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x12, 0xaf08);160161/* Restart AN */162tmpReg16 = PHY_SGMII_CR_DEF_VAL | PHY_SGMII_CR_RESET_AN;163MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x0, tmpReg16);164165/* Restore original enet mode */166p_Memac->enetMode = enetMode;167}168169/* ......................................................................... */170171static t_Error CheckInitParameters(t_Memac *p_Memac)172{173e_FmMacType portType;174175portType = ((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);176177#if (FM_MAX_NUM_OF_10G_MACS > 0)178if ((portType == e_FM_MAC_10G) && (p_Memac->macId >= FM_MAX_NUM_OF_10G_MACS))179RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("10G MAC ID must be less than %d", FM_MAX_NUM_OF_10G_MACS));180#endif /* (FM_MAX_NUM_OF_10G_MACS > 0) */181182if ((portType == e_FM_MAC_1G) && (p_Memac->macId >= FM_MAX_NUM_OF_1G_MACS))183RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("1G MAC ID must be less than %d", FM_MAX_NUM_OF_1G_MACS));184if (p_Memac->addr == 0)185RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet MAC must have a valid MAC address"));186if (!p_Memac->f_Exception)187RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Uninitialized f_Exception"));188if (!p_Memac->f_Event)189RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Uninitialized f_Event"));190#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002191if (!p_Memac->p_MemacDriverParam->no_length_check_enable)192RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));193#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */194195return E_OK;196}197198/* ........................................................................... */199200static void MemacErrException(t_Handle h_Memac)201{202t_Memac *p_Memac = (t_Memac *)h_Memac;203uint32_t event, imask;204205event = fman_memac_get_event(p_Memac->p_MemMap, 0xffffffff);206imask = fman_memac_get_interrupt_mask(p_Memac->p_MemMap);207208/* Imask include both error and notification/event bits.209Leaving only error bits enabled by imask.210The imask error bits are shifted by 16 bits offset from211their corresponding location in the ievent - hence the >> 16 */212event &= ((imask & MEMAC_ALL_ERRS_IMASK) >> 16);213214fman_memac_ack_event(p_Memac->p_MemMap, event);215216if (event & MEMAC_IEVNT_TS_ECC_ER)217p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_TS_FIFO_ECC_ERR);218if (event & MEMAC_IEVNT_TX_ECC_ER)219p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_1TX_ECC_ER);220if (event & MEMAC_IEVNT_RX_ECC_ER)221p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_RX_ECC_ER);222}223224static void MemacException(t_Handle h_Memac)225{226t_Memac *p_Memac = (t_Memac *)h_Memac;227uint32_t event, imask;228229event = fman_memac_get_event(p_Memac->p_MemMap, 0xffffffff);230imask = fman_memac_get_interrupt_mask(p_Memac->p_MemMap);231232/* Imask include both error and notification/event bits.233Leaving only error bits enabled by imask.234The imask error bits are shifted by 16 bits offset from235their corresponding location in the ievent - hence the >> 16 */236event &= ((imask & MEMAC_ALL_ERRS_IMASK) >> 16);237238fman_memac_ack_event(p_Memac->p_MemMap, event);239240if (event & MEMAC_IEVNT_MGI)241p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_MAGIC_PACKET_INDICATION);242}243244/* ......................................................................... */245246static void FreeInitResources(t_Memac *p_Memac)247{248e_FmMacType portType;249250portType =251((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);252253if (portType == e_FM_MAC_10G)254FmUnregisterIntr(p_Memac->fmMacControllerDriver.h_Fm, e_FM_MOD_10G_MAC, p_Memac->macId, e_FM_INTR_TYPE_ERR);255else256FmUnregisterIntr(p_Memac->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Memac->macId, e_FM_INTR_TYPE_ERR);257258/* release the driver's group hash table */259FreeHashTable(p_Memac->p_MulticastAddrHash);260p_Memac->p_MulticastAddrHash = NULL;261262/* release the driver's individual hash table */263FreeHashTable(p_Memac->p_UnicastAddrHash);264p_Memac->p_UnicastAddrHash = NULL;265}266267268/*****************************************************************************/269/* mEMAC API routines */270/*****************************************************************************/271272/* ......................................................................... */273274static t_Error MemacEnable(t_Handle h_Memac, e_CommMode mode)275{276t_Memac *p_Memac = (t_Memac *)h_Memac;277278SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);279SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);280281fman_memac_enable(p_Memac->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));282283return E_OK;284}285286/* ......................................................................... */287288static t_Error MemacDisable (t_Handle h_Memac, e_CommMode mode)289{290t_Memac *p_Memac = (t_Memac *)h_Memac;291292SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);293SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);294295fman_memac_disable(p_Memac->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));296297return E_OK;298}299300/* ......................................................................... */301302static t_Error MemacSetPromiscuous(t_Handle h_Memac, bool newVal)303{304t_Memac *p_Memac = (t_Memac *)h_Memac;305306SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);307SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);308309fman_memac_set_promiscuous(p_Memac->p_MemMap, newVal);310311return E_OK;312}313314/* .............................................................................. */315316static t_Error MemacAdjustLink(t_Handle h_Memac, e_EnetSpeed speed, bool fullDuplex)317{318t_Memac *p_Memac = (t_Memac *)h_Memac;319320SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);321SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);322323if ((speed >= e_ENET_SPEED_1000) && (!fullDuplex))324RETURN_ERROR(MAJOR, E_CONFLICT,325("Ethernet MAC 1G or 10G does not support half-duplex"));326327fman_memac_adjust_link(p_Memac->p_MemMap,328(enum enet_interface)ENET_INTERFACE_FROM_MODE(p_Memac->enetMode),329(enum enet_speed)speed,330fullDuplex);331return E_OK;332}333334335/*****************************************************************************/336/* Memac Configs modification functions */337/*****************************************************************************/338339/* ......................................................................... */340341static t_Error MemacConfigLoopback(t_Handle h_Memac, bool newVal)342{343t_Memac *p_Memac = (t_Memac *)h_Memac;344345SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);346SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);347348p_Memac->p_MemacDriverParam->loopback_enable = newVal;349350return E_OK;351}352353/* ......................................................................... */354355static t_Error MemacConfigWan(t_Handle h_Memac, bool newVal)356{357t_Memac *p_Memac = (t_Memac *)h_Memac;358359SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);360SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);361362p_Memac->p_MemacDriverParam->wan_mode_enable = newVal;363364return E_OK;365}366367/* ......................................................................... */368369static t_Error MemacConfigMaxFrameLength(t_Handle h_Memac, uint16_t newVal)370{371t_Memac *p_Memac = (t_Memac *)h_Memac;372373SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);374SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);375376p_Memac->p_MemacDriverParam->max_frame_length = newVal;377378return E_OK;379}380381/* ......................................................................... */382383static t_Error MemacConfigPad(t_Handle h_Memac, bool newVal)384{385t_Memac *p_Memac = (t_Memac *)h_Memac;386387SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);388SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);389390p_Memac->p_MemacDriverParam->pad_enable = newVal;391392return E_OK;393}394395/* ......................................................................... */396397static t_Error MemacConfigLengthCheck(t_Handle h_Memac, bool newVal)398{399t_Memac *p_Memac = (t_Memac *)h_Memac;400401SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);402SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);403404p_Memac->p_MemacDriverParam->no_length_check_enable = !newVal;405406return E_OK;407}408409/* ......................................................................... */410411static t_Error MemacConfigException(t_Handle h_Memac, e_FmMacExceptions exception, bool enable)412{413t_Memac *p_Memac = (t_Memac *)h_Memac;414uint32_t bitMask = 0;415416SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);417SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);418419GET_EXCEPTION_FLAG(bitMask, exception);420if (bitMask)421{422if (enable)423p_Memac->exceptions |= bitMask;424else425p_Memac->exceptions &= ~bitMask;426}427else428RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));429430return E_OK;431}432433/* ......................................................................... */434435static t_Error MemacConfigResetOnInit(t_Handle h_Memac, bool enable)436{437t_Memac *p_Memac = (t_Memac *)h_Memac;438439SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);440SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);441442p_Memac->p_MemacDriverParam->reset_on_init = enable;443444return E_OK;445}446447448/*****************************************************************************/449/* Memac Run Time API functions */450/*****************************************************************************/451452/* ......................................................................... */453454static t_Error MemacSetTxPauseFrames(t_Handle h_Memac,455uint8_t priority,456uint16_t pauseTime,457uint16_t threshTime)458{459t_Memac *p_Memac = (t_Memac *)h_Memac;460461SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);462SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);463464if (priority != 0xFF)465{466bool PortConfigured, PreFetchEnabled;467468if (FmGetTnumAgingPeriod(p_Memac->fmMacControllerDriver.h_Fm) == 0)469RETURN_ERROR(MAJOR, E_CONFLICT, ("For PFC operation, TNUM aging must be enabled"));470471FmGetPortPreFetchConfiguration(p_Memac->fmMacControllerDriver.h_Fm,472p_Memac->fmMacControllerDriver.macId,473&PortConfigured,474&PreFetchEnabled);475476if ((ENET_SPEED_FROM_MODE(p_Memac->fmMacControllerDriver.enetMode) == e_ENET_SPEED_1000) && !PortConfigured)477DBG(INFO, ("For PFC correct operation, prefetch must be configured on the FM Tx PORT"));478479if ((ENET_SPEED_FROM_MODE(p_Memac->fmMacControllerDriver.enetMode) == e_ENET_SPEED_1000) && PortConfigured && !PreFetchEnabled)480DBG(WARNING, ("For PFC correct operation, prefetch must be configured on the FM Tx PORT"));481}482483fman_memac_set_tx_pause_frames(p_Memac->p_MemMap, priority, pauseTime, threshTime);484485return E_OK;486}487488/* ......................................................................... */489490static t_Error MemacSetTxAutoPauseFrames(t_Handle h_Memac,491uint16_t pauseTime)492{493return MemacSetTxPauseFrames(h_Memac, FM_MAC_NO_PFC, pauseTime, 0);494}495496/* ......................................................................... */497498static t_Error MemacSetRxIgnorePauseFrames(t_Handle h_Memac, bool en)499{500t_Memac *p_Memac = (t_Memac *)h_Memac;501502SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);503SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);504505fman_memac_set_rx_ignore_pause_frames(p_Memac->p_MemMap, en);506507return E_OK;508}509510/* ......................................................................... */511512static t_Error MemacSetWakeOnLan(t_Handle h_Memac, bool en)513{514t_Memac *p_Memac = (t_Memac *)h_Memac;515516SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);517SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);518519fman_memac_set_wol(p_Memac->p_MemMap, en);520521return E_OK;522}523524/* .............................................................................. */525526static t_Error MemacEnable1588TimeStamp(t_Handle h_Memac)527{528t_Memac *p_Memac = (t_Memac *)h_Memac;529530SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);531SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);532UNUSED(p_Memac);533DBG(WARNING, ("mEMAC has 1588 always enabled!"));534535return E_OK;536}537538/* Counters handling */539/* ......................................................................... */540541static t_Error MemacGetStatistics(t_Handle h_Memac, t_FmMacStatistics *p_Statistics)542{543t_Memac *p_Memac = (t_Memac *)h_Memac;544545SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);546SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);547SANITY_CHECK_RETURN_ERROR(p_Statistics, E_NULL_POINTER);548549p_Statistics->eStatPkts64 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R64);550p_Statistics->eStatPkts65to127 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R127);551p_Statistics->eStatPkts128to255 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R255);552p_Statistics->eStatPkts256to511 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R511);553p_Statistics->eStatPkts512to1023 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1023);554p_Statistics->eStatPkts1024to1518 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1518);555p_Statistics->eStatPkts1519to1522 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1519X);556/* */557p_Statistics->eStatFragments = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RFRG);558p_Statistics->eStatJabbers = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RJBR);559560p_Statistics->eStatsDropEvents = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RDRP);561p_Statistics->eStatCRCAlignErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RALN);562563p_Statistics->eStatUndersizePkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TUND);564p_Statistics->eStatOversizePkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_ROVR);565/* Pause */566p_Statistics->reStatPause = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RXPF);567p_Statistics->teStatPause = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TXPF);568569/* MIB II */570p_Statistics->ifInOctets = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_ROCT);571p_Statistics->ifInUcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RUCA);572p_Statistics->ifInMcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RMCA);573p_Statistics->ifInBcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RBCA);574p_Statistics->ifInPkts = p_Statistics->ifInUcastPkts575+ p_Statistics->ifInMcastPkts576+ p_Statistics->ifInBcastPkts;577p_Statistics->ifInDiscards = 0;578p_Statistics->ifInErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RERR);579580p_Statistics->ifOutOctets = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TOCT);581p_Statistics->ifOutUcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TUCA);582p_Statistics->ifOutMcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TMCA);583p_Statistics->ifOutBcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TBCA);584p_Statistics->ifOutPkts = p_Statistics->ifOutUcastPkts585+ p_Statistics->ifOutMcastPkts586+ p_Statistics->ifOutBcastPkts;587p_Statistics->ifOutDiscards = 0;588p_Statistics->ifOutErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TERR);589590return E_OK;591}592593/* ......................................................................... */594595static t_Error MemacModifyMacAddress (t_Handle h_Memac, t_EnetAddr *p_EnetAddr)596{597t_Memac *p_Memac = (t_Memac *)h_Memac;598599SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);600SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);601602fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t *)(*p_EnetAddr), 0);603604return E_OK;605}606607/* ......................................................................... */608609static t_Error MemacResetCounters (t_Handle h_Memac)610{611t_Memac *p_Memac = (t_Memac *)h_Memac;612613SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);614SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);615616fman_memac_reset_stat(p_Memac->p_MemMap);617618return E_OK;619}620621/* ......................................................................... */622623static t_Error MemacAddExactMatchMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)624{625t_Memac *p_Memac = (t_Memac *) h_Memac;626uint64_t ethAddr;627uint8_t paddrNum;628629SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);630SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);631632ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);633634if (ethAddr & GROUP_ADDRESS)635/* Multicast address has no effect in PADDR */636RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Multicast address"));637638/* Make sure no PADDR contains this address */639for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)640if (p_Memac->indAddrRegUsed[paddrNum])641if (p_Memac->paddr[paddrNum] == ethAddr)642RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);643644/* Find first unused PADDR */645for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)646if (!(p_Memac->indAddrRegUsed[paddrNum]))647{648/* mark this PADDR as used */649p_Memac->indAddrRegUsed[paddrNum] = TRUE;650/* store address */651p_Memac->paddr[paddrNum] = ethAddr;652653/* put in hardware */654fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t*)(*p_EthAddr), paddrNum);655p_Memac->numOfIndAddrInRegs++;656657return E_OK;658}659660/* No free PADDR */661RETURN_ERROR(MAJOR, E_FULL, NO_MSG);662}663664/* ......................................................................... */665666static t_Error MemacDelExactMatchMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)667{668t_Memac *p_Memac = (t_Memac *) h_Memac;669uint64_t ethAddr;670uint8_t paddrNum;671672SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);673SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);674675ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);676677/* Find used PADDR containing this address */678for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)679{680if ((p_Memac->indAddrRegUsed[paddrNum]) &&681(p_Memac->paddr[paddrNum] == ethAddr))682{683/* mark this PADDR as not used */684p_Memac->indAddrRegUsed[paddrNum] = FALSE;685/* clear in hardware */686fman_memac_clear_addr_in_paddr(p_Memac->p_MemMap, paddrNum);687p_Memac->numOfIndAddrInRegs--;688689return E_OK;690}691}692693RETURN_ERROR(MAJOR, E_NOT_FOUND, NO_MSG);694}695696/* ......................................................................... */697698static t_Error MemacGetId(t_Handle h_Memac, uint32_t *macId)699{700t_Memac *p_Memac = (t_Memac *)h_Memac;701702SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);703SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);704705*macId = p_Memac->macId;706707return E_OK;708}709710/* ......................................................................... */711712713static t_Error MemacAddHashMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)714{715t_Memac *p_Memac = (t_Memac *)h_Memac;716t_EthHashEntry *p_HashEntry;717uint32_t hash;718uint64_t ethAddr;719720SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);721SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);722723ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);724725if (!(ethAddr & GROUP_ADDRESS))726/* Unicast addresses not supported in hash */727RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unicast Address"));728729hash = GetMacAddrHashCode(ethAddr) & HASH_CTRL_ADDR_MASK;730731/* Create element to be added to the driver hash table */732p_HashEntry = (t_EthHashEntry *)XX_Malloc(sizeof(t_EthHashEntry));733p_HashEntry->addr = ethAddr;734INIT_LIST(&p_HashEntry->node);735736LIST_AddToTail(&(p_HashEntry->node), &(p_Memac->p_MulticastAddrHash->p_Lsts[hash]));737fman_memac_set_hash_table(p_Memac->p_MemMap, (hash | HASH_CTRL_MCAST_EN));738739return E_OK;740}741742/* ......................................................................... */743744static t_Error MemacDelHashMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)745{746t_Memac *p_Memac = (t_Memac *)h_Memac;747t_EthHashEntry *p_HashEntry = NULL;748t_List *p_Pos;749uint32_t hash;750uint64_t ethAddr;751752SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);753SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);754755ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);756757hash = GetMacAddrHashCode(ethAddr) & HASH_CTRL_ADDR_MASK;758759LIST_FOR_EACH(p_Pos, &(p_Memac->p_MulticastAddrHash->p_Lsts[hash]))760{761p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);762if (p_HashEntry->addr == ethAddr)763{764LIST_DelAndInit(&p_HashEntry->node);765XX_Free(p_HashEntry);766break;767}768}769if (LIST_IsEmpty(&p_Memac->p_MulticastAddrHash->p_Lsts[hash]))770fman_memac_set_hash_table(p_Memac->p_MemMap, (hash & ~HASH_CTRL_MCAST_EN));771772return E_OK;773}774775776/* ......................................................................... */777778static t_Error MemacSetException(t_Handle h_Memac, e_FmMacExceptions exception, bool enable)779{780t_Memac *p_Memac = (t_Memac *)h_Memac;781uint32_t bitMask = 0;782783SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);784SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);785786GET_EXCEPTION_FLAG(bitMask, exception);787if (bitMask)788{789if (enable)790p_Memac->exceptions |= bitMask;791else792p_Memac->exceptions &= ~bitMask;793}794else795RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));796797fman_memac_set_exception(p_Memac->p_MemMap, bitMask, enable);798799return E_OK;800}801802/* ......................................................................... */803804static uint16_t MemacGetMaxFrameLength(t_Handle h_Memac)805{806t_Memac *p_Memac = (t_Memac *)h_Memac;807808SANITY_CHECK_RETURN_VALUE(p_Memac, E_INVALID_HANDLE, 0);809SANITY_CHECK_RETURN_VALUE(!p_Memac->p_MemacDriverParam, E_INVALID_STATE, 0);810811return fman_memac_get_max_frame_len(p_Memac->p_MemMap);812}813814static t_Error MemacInitInternalPhy(t_Handle h_Memac)815{816t_Memac *p_Memac = (t_Memac *)h_Memac;817uint8_t i, phyAddr;818819if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_SGMII)820{821/* Configure internal SGMII PHY */822if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)823SetupSgmiiInternalPhyBaseX(p_Memac, PHY_MDIO_ADDR);824else825SetupSgmiiInternalPhy(p_Memac, PHY_MDIO_ADDR);826}827else if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_QSGMII)828{829/* Configure 4 internal SGMII PHYs */830for (i = 0; i < 4; i++)831{832/* QSGMII PHY address occupies 3 upper bits of 5-bit833phyAddress; the lower 2 bits are used to extend834register address space and access each one of 4835ports inside QSGMII. */836phyAddr = (uint8_t)((PHY_MDIO_ADDR << 2) | i);837if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)838SetupSgmiiInternalPhyBaseX(p_Memac, phyAddr);839else840SetupSgmiiInternalPhy(p_Memac, phyAddr);841}842}843return E_OK;844}845846/*****************************************************************************/847/* mEMAC Init & Free API */848/*****************************************************************************/849850/* ......................................................................... */851void *g_MemacRegs;852static t_Error MemacInit(t_Handle h_Memac)853{854t_Memac *p_Memac = (t_Memac *)h_Memac;855struct memac_cfg *p_MemacDriverParam;856enum enet_interface enet_interface;857enum enet_speed enet_speed;858t_EnetAddr ethAddr;859e_FmMacType portType;860t_Error err;861bool slow_10g_if = FALSE;862if (p_Memac->macId == 3) /* This is a quick WA */863g_MemacRegs = p_Memac->p_MemMap;864865SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);866SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);867SANITY_CHECK_RETURN_ERROR(p_Memac->fmMacControllerDriver.h_Fm, E_INVALID_HANDLE);868869FM_GetRevision(p_Memac->fmMacControllerDriver.h_Fm, &p_Memac->fmMacControllerDriver.fmRevInfo);870if (p_Memac->fmMacControllerDriver.fmRevInfo.majorRev == 6 &&871p_Memac->fmMacControllerDriver.fmRevInfo.minorRev == 4)872slow_10g_if = TRUE;873874CHECK_INIT_PARAMETERS(p_Memac, CheckInitParameters);875876p_MemacDriverParam = p_Memac->p_MemacDriverParam;877878portType =879((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);880881/* First, reset the MAC if desired. */882if (p_MemacDriverParam->reset_on_init)883fman_memac_reset(p_Memac->p_MemMap);884885/* MAC Address */886MAKE_ENET_ADDR_FROM_UINT64(p_Memac->addr, ethAddr);887fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t*)ethAddr, 0);888889enet_interface = (enum enet_interface) ENET_INTERFACE_FROM_MODE(p_Memac->enetMode);890enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Memac->enetMode);891892fman_memac_init(p_Memac->p_MemMap,893p_Memac->p_MemacDriverParam,894enet_interface,895enet_speed,896slow_10g_if,897p_Memac->exceptions);898899#ifdef FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320900{901uint32_t tmpReg = 0;902903FM_GetRevision(p_Memac->fmMacControllerDriver.h_Fm, &p_Memac->fmMacControllerDriver.fmRevInfo);904/* check the FMAN version - the bug exists only in rev1 */905if ((p_Memac->fmMacControllerDriver.fmRevInfo.majorRev == 6) &&906(p_Memac->fmMacControllerDriver.fmRevInfo.minorRev == 0))907{908/* MAC strips CRC from received frames - this workaround should909decrease the likelihood of bug appearance910*/911tmpReg = GET_UINT32(p_Memac->p_MemMap->command_config);912tmpReg &= ~CMD_CFG_CRC_FWD;913WRITE_UINT32(p_Memac->p_MemMap->command_config, tmpReg);914/* DBG(WARNING, ("mEMAC strips CRC from received frames as part of A006320 errata workaround"));*/915}916}917#endif /* FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320 */918919MemacInitInternalPhy(h_Memac);920921/* Max Frame Length */922err = FmSetMacMaxFrame(p_Memac->fmMacControllerDriver.h_Fm,923portType,924p_Memac->fmMacControllerDriver.macId,925p_MemacDriverParam->max_frame_length);926if (err)927RETURN_ERROR(MAJOR, err, ("settings Mac max frame length is FAILED"));928929p_Memac->p_MulticastAddrHash = AllocHashTable(HASH_TABLE_SIZE);930if (!p_Memac->p_MulticastAddrHash)931{932FreeInitResources(p_Memac);933RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));934}935936p_Memac->p_UnicastAddrHash = AllocHashTable(HASH_TABLE_SIZE);937if (!p_Memac->p_UnicastAddrHash)938{939FreeInitResources(p_Memac);940RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));941}942943FmRegisterIntr(p_Memac->fmMacControllerDriver.h_Fm,944(portType == e_FM_MAC_10G) ? e_FM_MOD_10G_MAC : e_FM_MOD_1G_MAC,945p_Memac->macId,946e_FM_INTR_TYPE_ERR,947MemacErrException,948p_Memac);949950FmRegisterIntr(p_Memac->fmMacControllerDriver.h_Fm,951(portType == e_FM_MAC_10G) ? e_FM_MOD_10G_MAC : e_FM_MOD_1G_MAC,952p_Memac->macId,953e_FM_INTR_TYPE_NORMAL,954MemacException,955p_Memac);956957XX_Free(p_MemacDriverParam);958p_Memac->p_MemacDriverParam = NULL;959960return E_OK;961}962963/* ......................................................................... */964965static t_Error MemacFree(t_Handle h_Memac)966{967t_Memac *p_Memac = (t_Memac *)h_Memac;968969SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);970971if (p_Memac->p_MemacDriverParam)972{973/* Called after config */974XX_Free(p_Memac->p_MemacDriverParam);975p_Memac->p_MemacDriverParam = NULL;976}977else978/* Called after init */979FreeInitResources(p_Memac);980981XX_Free(p_Memac);982983return E_OK;984}985986/* ......................................................................... */987988static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacControllerDriver)989{990p_FmMacControllerDriver->f_FM_MAC_Init = MemacInit;991p_FmMacControllerDriver->f_FM_MAC_Free = MemacFree;992993p_FmMacControllerDriver->f_FM_MAC_SetStatistics = NULL;994p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback = MemacConfigLoopback;995p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength = MemacConfigMaxFrameLength;996997p_FmMacControllerDriver->f_FM_MAC_ConfigWan = MemacConfigWan;998999p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc = MemacConfigPad;1000p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex = NULL; /* half-duplex is detected automatically */1001p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck = MemacConfigLengthCheck;10021003p_FmMacControllerDriver->f_FM_MAC_ConfigException = MemacConfigException;1004p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit = MemacConfigResetOnInit;10051006p_FmMacControllerDriver->f_FM_MAC_SetException = MemacSetException;10071008p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp = MemacEnable1588TimeStamp; /* always enabled */1009p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp = NULL;10101011p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = MemacSetPromiscuous;1012p_FmMacControllerDriver->f_FM_MAC_AdjustLink = MemacAdjustLink;1013p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = NULL;10141015p_FmMacControllerDriver->f_FM_MAC_Enable = MemacEnable;1016p_FmMacControllerDriver->f_FM_MAC_Disable = MemacDisable;1017p_FmMacControllerDriver->f_FM_MAC_Resume = MemacInitInternalPhy;10181019p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = MemacSetTxAutoPauseFrames;1020p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = MemacSetTxPauseFrames;1021p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = MemacSetRxIgnorePauseFrames;10221023p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = MemacSetWakeOnLan;10241025p_FmMacControllerDriver->f_FM_MAC_ResetCounters = MemacResetCounters;1026p_FmMacControllerDriver->f_FM_MAC_GetStatistics = MemacGetStatistics;10271028p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = MemacModifyMacAddress;1029p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = MemacAddHashMacAddress;1030p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr = MemacDelHashMacAddress;1031p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr = MemacAddExactMatchMacAddress;1032p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr = MemacDelExactMatchMacAddress;1033p_FmMacControllerDriver->f_FM_MAC_GetId = MemacGetId;1034p_FmMacControllerDriver->f_FM_MAC_GetVersion = NULL;1035p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength = MemacGetMaxFrameLength;10361037p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg = MEMAC_MII_WritePhyReg;1038p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg = MEMAC_MII_ReadPhyReg;1039}104010411042/*****************************************************************************/1043/* mEMAC Config Main Entry */1044/*****************************************************************************/10451046/* ......................................................................... */10471048t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam)1049{1050t_Memac *p_Memac;1051struct memac_cfg *p_MemacDriverParam;1052uintptr_t baseAddr;10531054SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_NULL_POINTER, NULL);10551056baseAddr = p_FmMacParam->baseAddr;1057/* Allocate memory for the mEMAC data structure */1058p_Memac = (t_Memac *)XX_Malloc(sizeof(t_Memac));1059if (!p_Memac)1060{1061REPORT_ERROR(MAJOR, E_NO_MEMORY, ("mEMAC driver structure"));1062return NULL;1063}1064memset(p_Memac, 0, sizeof(t_Memac));1065InitFmMacControllerDriver(&p_Memac->fmMacControllerDriver);10661067/* Allocate memory for the mEMAC driver parameters data structure */1068p_MemacDriverParam = (struct memac_cfg *)XX_Malloc(sizeof(struct memac_cfg));1069if (!p_MemacDriverParam)1070{1071REPORT_ERROR(MAJOR, E_NO_MEMORY, ("mEMAC driver parameters"));1072XX_Free(p_Memac);1073return NULL;1074}1075memset(p_MemacDriverParam, 0, sizeof(struct memac_cfg));10761077/* Plant parameter structure pointer */1078p_Memac->p_MemacDriverParam = p_MemacDriverParam;10791080fman_memac_defconfig(p_MemacDriverParam);10811082p_Memac->addr = ENET_ADDR_TO_UINT64(p_FmMacParam->addr);10831084p_Memac->p_MemMap = (struct memac_regs *)UINT_TO_PTR(baseAddr);1085p_Memac->p_MiiMemMap = (struct memac_mii_access_mem_map*)UINT_TO_PTR(baseAddr + MEMAC_TO_MII_OFFSET);10861087p_Memac->enetMode = p_FmMacParam->enetMode;1088p_Memac->macId = p_FmMacParam->macId;1089p_Memac->exceptions = MEMAC_default_exceptions;1090p_Memac->f_Exception = p_FmMacParam->f_Exception;1091p_Memac->f_Event = p_FmMacParam->f_Event;1092p_Memac->h_App = p_FmMacParam->h_App;10931094return p_Memac;1095}109610971098