Path: blob/main/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.h
48524 views
/*1* Copyright 2008-2013 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*/3132/******************************************************************************33@File dtsec.h3435@Description FM dTSEC ...36*//***************************************************************************/37#ifndef __DTSEC_H38#define __DTSEC_H3940#include "std_ext.h"41#include "error_ext.h"42#include "list_ext.h"43#include "enet_ext.h"4445#include "dtsec_mii_acc.h"46#include "fm_mac.h"474849#define DEFAULT_exceptions \50((uint32_t)(DTSEC_IMASK_BREN | \51DTSEC_IMASK_RXCEN | \52DTSEC_IMASK_BTEN | \53DTSEC_IMASK_TXCEN | \54DTSEC_IMASK_TXEEN | \55DTSEC_IMASK_ABRTEN | \56DTSEC_IMASK_LCEN | \57DTSEC_IMASK_CRLEN | \58DTSEC_IMASK_XFUNEN | \59DTSEC_IMASK_IFERREN | \60DTSEC_IMASK_MAGEN | \61DTSEC_IMASK_TDPEEN | \62DTSEC_IMASK_RDPEEN))6364#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \65case e_FM_MAC_EX_1G_BAB_RX: \66bitMask = DTSEC_IMASK_BREN; break; \67case e_FM_MAC_EX_1G_RX_CTL: \68bitMask = DTSEC_IMASK_RXCEN; break; \69case e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET: \70bitMask = DTSEC_IMASK_GTSCEN ; break; \71case e_FM_MAC_EX_1G_BAB_TX: \72bitMask = DTSEC_IMASK_BTEN ; break; \73case e_FM_MAC_EX_1G_TX_CTL: \74bitMask = DTSEC_IMASK_TXCEN ; break; \75case e_FM_MAC_EX_1G_TX_ERR: \76bitMask = DTSEC_IMASK_TXEEN ; break; \77case e_FM_MAC_EX_1G_LATE_COL: \78bitMask = DTSEC_IMASK_LCEN ; break; \79case e_FM_MAC_EX_1G_COL_RET_LMT: \80bitMask = DTSEC_IMASK_CRLEN ; break; \81case e_FM_MAC_EX_1G_TX_FIFO_UNDRN: \82bitMask = DTSEC_IMASK_XFUNEN ; break; \83case e_FM_MAC_EX_1G_MAG_PCKT: \84bitMask = DTSEC_IMASK_MAGEN ; break; \85case e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET: \86bitMask = DTSEC_IMASK_MMRDEN; break; \87case e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET: \88bitMask = DTSEC_IMASK_MMWREN ; break; \89case e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET: \90bitMask = DTSEC_IMASK_GRSCEN; break; \91case e_FM_MAC_EX_1G_TX_DATA_ERR: \92bitMask = DTSEC_IMASK_TDPEEN; break; \93case e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL: \94bitMask = DTSEC_IMASK_MSROEN ; break; \95default: bitMask = 0;break;}969798#define MAX_PACKET_ALIGNMENT 3199#define MAX_INTER_PACKET_GAP 0x7f100#define MAX_INTER_PALTERNATE_BEB 0x0f101#define MAX_RETRANSMISSION 0x0f102#define MAX_COLLISION_WINDOW 0x03ff103104105/********************* From mac ext ******************************************/106typedef uint32_t t_ErrorDisable;107108#define ERROR_DISABLE_TRANSMIT 0x00400000109#define ERROR_DISABLE_LATE_COLLISION 0x00040000110#define ERROR_DISABLE_COLLISION_RETRY_LIMIT 0x00020000111#define ERROR_DISABLE_TxFIFO_UNDERRUN 0x00010000112#define ERROR_DISABLE_TxABORT 0x00008000113#define ERROR_DISABLE_INTERFACE 0x00004000114#define ERROR_DISABLE_TxDATA_PARITY 0x00000002115#define ERROR_DISABLE_RxDATA_PARITY 0x00000001116117/*****************************************************************************/118#define DTSEC_NUM_OF_PADDRS 15 /* number of pattern match registers (entries) */119120#define GROUP_ADDRESS 0x0000010000000000LL /* Group address bit indication */121122#define HASH_TABLE_SIZE 256 /* Hash table size (= 32 bits * 8 regs) */123124#define HASH_TABLE_SIZE 256 /* Hash table size (32 bits * 8 regs) */125#define EXTENDED_HASH_TABLE_SIZE 512 /* Extended Hash table size (32 bits * 16 regs) */126127#define DTSEC_TO_MII_OFFSET 0x1000 /* number of pattern match registers (entries) */128129#define MAX_PHYS 32 /* maximum number of phys */130131#define VAL32BIT 0x100000000LL132#define VAL22BIT 0x00400000133#define VAL16BIT 0x00010000134#define VAL12BIT 0x00001000135136/* CAR1/2 bits */137#define CAR1_TR64 0x80000000138#define CAR1_TR127 0x40000000139#define CAR1_TR255 0x20000000140#define CAR1_TR511 0x10000000141#define CAR1_TRK1 0x08000000142#define CAR1_TRMAX 0x04000000143#define CAR1_TRMGV 0x02000000144145#define CAR1_RBYT 0x00010000146#define CAR1_RPKT 0x00008000147#define CAR1_RMCA 0x00002000148#define CAR1_RBCA 0x00001000149#define CAR1_RXPF 0x00000400150#define CAR1_RALN 0x00000100151#define CAR1_RFLR 0x00000080152#define CAR1_RCDE 0x00000040153#define CAR1_RCSE 0x00000020154#define CAR1_RUND 0x00000010155#define CAR1_ROVR 0x00000008156#define CAR1_RFRG 0x00000004157#define CAR1_RJBR 0x00000002158#define CAR1_RDRP 0x00000001159160#define CAR2_TFCS 0x00040000161#define CAR2_TBYT 0x00002000162#define CAR2_TPKT 0x00001000163#define CAR2_TMCA 0x00000800164#define CAR2_TBCA 0x00000400165#define CAR2_TXPF 0x00000200166#define CAR2_TDRP 0x00000001167168typedef struct t_InternalStatistics169{170uint64_t tr64;171uint64_t tr127;172uint64_t tr255;173uint64_t tr511;174uint64_t tr1k;175uint64_t trmax;176uint64_t trmgv;177uint64_t rfrg;178uint64_t rjbr;179uint64_t rdrp;180uint64_t raln;181uint64_t rund;182uint64_t rovr;183uint64_t rxpf;184uint64_t txpf;185uint64_t rbyt;186uint64_t rpkt;187uint64_t rmca;188uint64_t rbca;189uint64_t rflr;190uint64_t rcde;191uint64_t rcse;192uint64_t tbyt;193uint64_t tpkt;194uint64_t tmca;195uint64_t tbca;196uint64_t tdrp;197uint64_t tfcs;198} t_InternalStatistics;199200typedef struct {201t_FmMacControllerDriver fmMacControllerDriver;202t_Handle h_App; /**< Handle to the upper layer application */203struct dtsec_regs *p_MemMap; /**< pointer to dTSEC memory mapped registers. */204struct dtsec_mii_reg *p_MiiMemMap; /**< pointer to dTSEC MII memory mapped registers. */205uint64_t addr; /**< MAC address of device; */206e_EnetMode enetMode; /**< Ethernet physical interface */207t_FmMacExceptionCallback *f_Exception;208int mdioIrq;209t_FmMacExceptionCallback *f_Event;210bool indAddrRegUsed[DTSEC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */211uint64_t paddr[DTSEC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */212uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */213bool halfDuplex;214t_InternalStatistics internalStatistics;215t_EthHash *p_MulticastAddrHash; /* pointer to driver's global address hash table */216t_EthHash *p_UnicastAddrHash; /* pointer to driver's individual address hash table */217uint8_t macId;218uint8_t tbi_phy_addr;219uint32_t exceptions;220bool ptpTsuEnabled;221bool enTsuErrExeption;222e_FmMacStatisticsLevel statisticsLevel;223struct dtsec_cfg *p_DtsecDriverParam;224} t_Dtsec;225226227#endif /* __DTSEC_H */228229230