Path: blob/main/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.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 tgec.h3536@Description FM 10G MAC ...37*//***************************************************************************/38#ifndef __TGEC_H39#define __TGEC_H4041#include "std_ext.h"42#include "error_ext.h"43#include "list_ext.h"44#include "enet_ext.h"4546#include "tgec_mii_acc.h"47#include "fm_mac.h"484950#define DEFAULT_exceptions \51((uint32_t)(TGEC_IMASK_MDIO_SCAN_EVENT | \52TGEC_IMASK_REM_FAULT | \53TGEC_IMASK_LOC_FAULT | \54TGEC_IMASK_TX_ECC_ER | \55TGEC_IMASK_TX_FIFO_UNFL | \56TGEC_IMASK_TX_FIFO_OVFL | \57TGEC_IMASK_TX_ER | \58TGEC_IMASK_RX_FIFO_OVFL | \59TGEC_IMASK_RX_ECC_ER | \60TGEC_IMASK_RX_JAB_FRM | \61TGEC_IMASK_RX_OVRSZ_FRM | \62TGEC_IMASK_RX_RUNT_FRM | \63TGEC_IMASK_RX_FRAG_FRM | \64TGEC_IMASK_RX_CRC_ER | \65TGEC_IMASK_RX_ALIGN_ER))6667#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \68case e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO: \69bitMask = TGEC_IMASK_MDIO_SCAN_EVENT ; break; \70case e_FM_MAC_EX_10G_MDIO_CMD_CMPL: \71bitMask = TGEC_IMASK_MDIO_CMD_CMPL ; break; \72case e_FM_MAC_EX_10G_REM_FAULT: \73bitMask = TGEC_IMASK_REM_FAULT ; break; \74case e_FM_MAC_EX_10G_LOC_FAULT: \75bitMask = TGEC_IMASK_LOC_FAULT ; break; \76case e_FM_MAC_EX_10G_1TX_ECC_ER: \77bitMask = TGEC_IMASK_TX_ECC_ER ; break; \78case e_FM_MAC_EX_10G_TX_FIFO_UNFL: \79bitMask = TGEC_IMASK_TX_FIFO_UNFL ; break; \80case e_FM_MAC_EX_10G_TX_FIFO_OVFL: \81bitMask = TGEC_IMASK_TX_FIFO_OVFL ; break; \82case e_FM_MAC_EX_10G_TX_ER: \83bitMask = TGEC_IMASK_TX_ER ; break; \84case e_FM_MAC_EX_10G_RX_FIFO_OVFL: \85bitMask = TGEC_IMASK_RX_FIFO_OVFL ; break; \86case e_FM_MAC_EX_10G_RX_ECC_ER: \87bitMask = TGEC_IMASK_RX_ECC_ER ; break; \88case e_FM_MAC_EX_10G_RX_JAB_FRM: \89bitMask = TGEC_IMASK_RX_JAB_FRM ; break; \90case e_FM_MAC_EX_10G_RX_OVRSZ_FRM: \91bitMask = TGEC_IMASK_RX_OVRSZ_FRM ; break; \92case e_FM_MAC_EX_10G_RX_RUNT_FRM: \93bitMask = TGEC_IMASK_RX_RUNT_FRM ; break; \94case e_FM_MAC_EX_10G_RX_FRAG_FRM: \95bitMask = TGEC_IMASK_RX_FRAG_FRM ; break; \96case e_FM_MAC_EX_10G_RX_LEN_ER: \97bitMask = TGEC_IMASK_RX_LEN_ER ; break; \98case e_FM_MAC_EX_10G_RX_CRC_ER: \99bitMask = TGEC_IMASK_RX_CRC_ER ; break; \100case e_FM_MAC_EX_10G_RX_ALIGN_ER: \101bitMask = TGEC_IMASK_RX_ALIGN_ER ; break; \102default: bitMask = 0;break;}103104#define MAX_PACKET_ALIGNMENT 31105#define MAX_INTER_PACKET_GAP 0x7f106#define MAX_INTER_PALTERNATE_BEB 0x0f107#define MAX_RETRANSMISSION 0x0f108#define MAX_COLLISION_WINDOW 0x03ff109110#define TGEC_NUM_OF_PADDRS 1 /* number of pattern match registers (entries) */111112#define GROUP_ADDRESS 0x0000010000000000LL /* Group address bit indication */113114#define HASH_TABLE_SIZE 512 /* Hash table size (= 32 bits * 8 regs) */115116#define TGEC_TO_MII_OFFSET 0x1030 /* Offset from the MEM map to the MDIO mem map */117118/* 10-gigabit Ethernet MAC Controller ID (10GEC_ID) */119#define TGEC_ID_ID 0xffff0000120#define TGEC_ID_MAC_VERSION 0x0000FF00121#define TGEC_ID_MAC_REV 0x000000ff122123124typedef struct {125t_FmMacControllerDriver fmMacControllerDriver; /**< Upper Mac control block */126t_Handle h_App; /**< Handle to the upper layer application */127struct tgec_regs *p_MemMap; /**< pointer to 10G memory mapped registers. */128t_TgecMiiAccessMemMap *p_MiiMemMap; /**< pointer to MII memory mapped registers. */129uint64_t addr; /**< MAC address of device; */130e_EnetMode enetMode; /**< Ethernet physical interface */131t_FmMacExceptionCallback *f_Exception;132int mdioIrq;133t_FmMacExceptionCallback *f_Event;134bool indAddrRegUsed[TGEC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */135uint64_t paddr[TGEC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */136uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */137t_EthHash *p_MulticastAddrHash; /**< pointer to driver's global address hash table */138t_EthHash *p_UnicastAddrHash; /**< pointer to driver's individual address hash table */139bool debugMode;140uint8_t macId;141uint32_t exceptions;142struct tgec_cfg *p_TgecDriverParam;143} t_Tgec;144145146t_Error TGEC_MII_WritePhyReg(t_Handle h_Tgec, uint8_t phyAddr, uint8_t reg, uint16_t data);147t_Error TGEC_MII_ReadPhyReg(t_Handle h_Tgec, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);148149150#endif /* __TGEC_H */151152153