/**
*   @file       Eth_43_PFE.h
*
*   @brief   AUTOSAR Eth driver interface header file
*   @details Implementation of the AUTOSAR Ethernet driver
*
*   @addtogroup ETH_43_PFE_DRIVER
*   @{
*/
/*==================================================================================================
 *  Project              : AUTOSAR 4.4 MCAL
 *  Peripheral           : PFE
 *
 *  Autosar Version      : 4.4.0
 *  Autosar Revision     : ASR_REL_4_4_REV_0000
 *
 *  (c) Copyright 2006-2016 Freescale Semiconductor, Inc.
 *      Copyright 2017-2022 NXP
 *  NXP Confidential. This software is owned or controlled by NXP and may only
 *  be used strictly in accordance with the applicable license terms. By
 *  expressly accepting such terms or by downloading, installing, activating
 *  and/or otherwise using the software, you are agreeing that you have read,
 *  and that you agree to comply with and are bound by, such license terms. If
 *  you do not agree to be bound by the applicable license terms, then you may
 *  not retain, install, activate or otherwise use the software.
 *  <<< PFE Restricted Software >>>
 *
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/

#ifndef ETH_43_PFE_H
#define ETH_43_PFE_H

#ifdef __cplusplus
extern "C"{
#endif

/*==================================================================================================
*                                     FILE VERSION CHECK
==================================================================================================*/
#ifdef PFE_SRC_VERSION_CHECK
    #if (PFE_SRC_VERSION_CHECK != 43100440)
        #error "This header file was included from incompatible source file (different SW version)"
    #endif
#else
    #define PFE_SRC_VERSION_CHECK 43100440
#endif

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Eth_GeneralTypes.h"  /* Mandatory include - see the SWS */
#include "pfe_cfg.h"
#include "oal_types.h"
#include "pfe_emac.h"
#include "pfe_tmu.h"
#include "Eth_43_PFE_Cfg.h" /* Mandatory include - see the SWS */
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ETH_43_PFE_VENDOR_ID                    43
#define ETH_43_PFE_MODULE_ID                    88
#define ETH_43_PFE_SW_MAJOR_VERSION             1
#define ETH_43_PFE_SW_MINOR_VERSION             0
#define ETH_43_PFE_SW_PATCH_VERSION             0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/

/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/
/* Service IDs definition */
#define ETH_43_PFE_SID_INIT                    0x01
#define ETH_43_PFE_SID_SETCONTROLLERMODE       0x03
#define ETH_43_PFE_SID_GETCONTROLLERMODE       0x04
#define ETH_43_PFE_SID_GETPHYSADDR             0x08
#define ETH_43_PFE_SID_WRITEMII                0x05
#define ETH_43_PFE_SID_READMII                 0x06
#define ETH_43_PFE_SID_PROVIDETXBUFFER         0x09
#define ETH_43_PFE_SID_TRANSMIT                0x0A
#define ETH_43_PFE_SID_RECEIVE                 0x0B
#define ETH_43_PFE_SID_TXCONFIRMATION          0x0C
#define ETH_43_PFE_SID_GETVERSIONINFO          0x0D
#define ETH_43_PFE_SID_SETPHYSADDR             0x13
#define ETH_43_PFE_SID_UPDATEADDRFILTER        0x12
#define ETH_43_PFE_SID_GETCOUNTERVALUE         0x14
#define ETH_43_PFE_SID_GETRXSTATS              0x15
#define ETH_43_PFE_SID_GETCURRENTTIME          0x16
#define ETH_43_PFE_SID_ENABLEEGRESSTIMESTAMP   0x17
#define ETH_43_PFE_SID_GETEGRESSTIMESTAMP      0x18
#define ETH_43_PFE_SID_GETINGRESSTIMESTAMP     0x19
#define ETH_43_PFE_SID_SETCORRECTIONTIME       0x1A
#define ETH_43_PFE_SID_SETGLOBALTIME           0x1B
#define ETH_43_PFE_SID_GETTXSTATS              0x1C
#define ETH_43_PFE_SID_GETTXERRORCOUNTERVALUE  0x1D
#if STD_ON == ETH_43_PFE_CTRL_USE_45_MDIO_API
    #define ETH_43_PFE_SID_WRITEMII45          0x1E
    #define ETH_43_PFE_SID_READMII45           0x1F
#endif /* STD_ON == ETH_43_PFE_CTRL_USE_45_MDIO_API */
#define ETH_43_PFE_SID_MAINFUNCTION            0x20
#define ETH_43_PFE_SID_PREINIT                 0x21
#define ETH_43_PFE_SID_GETPLATFORM             0x22

/* DET error codes */
#if STD_ON == ETH_43_PFE_DEV_ERROR_DETECT
#define ETH_43_PFE_E_INV_CTRL_IDX      ((uint8)0x01)
#define ETH_43_PFE_E_UNINIT            ((uint8)0x02)
#define ETH_43_PFE_E_PARAM_POINTER     ((uint8)0x03)
#define ETH_43_PFE_E_INV_PARAM         ((uint8)0x04)
#define ETH_43_PFE_E_INV_MODE          ((uint8)0x05)
#endif
/* Define Specific Error code for Std_ReturnType */
#define ETH_43_PFE_E_NO_ACCESS         ((uint8)0x03U)

/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/
#define ETH_43_PFE_PHY_ADDR_MAX              0x1FU
#define ETH_43_PFE_PHY_REG_ADDR_MII22_MAX    0x1FU
#define ETH_43_PFE_PHY_DEV_MII45_MAX         0x1FU

/*==================================================================================================
*                                             ENUMS
==================================================================================================*/

/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/

/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/
#define ETH_43_PFE_START_SEC_VAR_INIT_UNSPECIFIED
#include "Eth_43_PFE_MemMap.h"

/* Eth_43_PFE_CtrlState: Used to store state of Eth controller(s). */
extern volatile Eth_StateType Eth_43_PFE_CtrlState[ETH_43_PFE_MAXCTRLS_SUPPORTED];

#define ETH_43_PFE_STOP_SEC_VAR_INIT_UNSPECIFIED
#include "Eth_43_PFE_MemMap.h"

#define ETH_43_PFE_START_SEC_VAR_INIT_UNSPECIFIED
#include "Eth_43_PFE_MemMap.h"
extern const Eth_43_PFE_ConfigType * Eth_43_PFE_InternalCfgPtr;
#define ETH_43_PFE_STOP_SEC_VAR_INIT_UNSPECIFIED
#include "Eth_43_PFE_MemMap.h"

/*==================================================================================================
*                                    FUNCTION PROTOTYPES
==================================================================================================*/
#define ETH_43_PFE_START_SEC_CODE
#include "Eth_43_PFE_MemMap.h"

extern void Eth_43_PFE_PreInit(const Eth_43_PFE_ConfigType * CfgPtr);
extern void Eth_43_PFE_Init(const Eth_43_PFE_ConfigType * CfgPtr);
extern Std_ReturnType Eth_43_PFE_SetControllerMode ( \
                                    uint8 u8CtrlIdx, \
                                    Eth_ModeType CtrlMode \
                                                            );
extern Std_ReturnType Eth_43_PFE_GetControllerMode ( \
                                    uint8 u8CtrlIdx, \
                                    Eth_ModeType * CtrlModePtr \
                                                            );
extern void Eth_43_PFE_GetPhysAddr ( \
                        uint8 u8CtrlIdx, \
                        uint8 * PhysAddrPtr \
                                            );
extern void Eth_43_PFE_SetPhysAddr(uint8 u8CtrlIdx, const uint8 * PhysAddrPtr);

extern Std_ReturnType Eth_43_PFE_UpdatePhysAddrFilter ( \
                                    uint8 u8CtrlIdx, \
                                    const uint8 * PhysAddrPtr, \
									Eth_FilterActionType Action \
                                                            );

extern BufReq_ReturnType Eth_43_PFE_ProvideTxBuffer( \
                                uint8 u8CtrlIdx, \
                                uint8 Priority, \
                                Eth_BufIdxType * BufIdxPtr, \
                                uint8 **BufPtr, \
                                uint16 * LenBytePtr \
                                                            );
extern Std_ReturnType Eth_43_PFE_Transmit  (
                            uint8 u8CtrlIdx,
                            Eth_BufIdxType BufIdx,
                            Eth_FrameType FrameType,
                            boolean TxConfirmation,
                            uint16 LenByte,
                            const uint8 * PhysAddrPtr
                                                    );
extern void Eth_43_PFE_Receive(uint8 u8CtrlIdx, \
                                    uint8 FifoIdx,  \
                                    Eth_RxStatusType * RxStatusPtr   \
                                 ) ;
extern void Eth_43_PFE_TxConfirmation(uint8 u8CtrlIdx);

#if STD_ON == ETH_43_PFE_CTRLENABLE_MII
extern Std_ReturnType Eth_43_PFE_WriteMii(uint8 u8CtrlIdx, \
                                            uint8 u8TrcvIdx, \
                                            uint8 u8RegIdx, \
                                            uint16 u16RegVal
                                        );

extern Std_ReturnType Eth_43_PFE_ReadMii(uint8 u8CtrlIdx, \
                                            uint8 u8TrcvIdx, \
                                            uint8 u8RegIdx, \
                                            uint16 * pu16RegValPtr
                                        );

#if STD_ON == ETH_43_PFE_CTRL_USE_45_MDIO_API
extern Std_ReturnType Eth_43_PFE_WriteMii45(uint8 u8CtrlIdx, \
                                            uint8 u8TrcvIdx, \
                                            uint8 u8DevIdx, \
                                            uint16 u16RegIdx, \
                                            uint16 u16RegVal
                                        );

extern Std_ReturnType Eth_43_PFE_ReadMii45(uint8 u8CtrlIdx, \
                                            uint8 u8TrcvIdx, \
                                            uint8 u8DevIdx, \
                                            uint16 u16RegIdx, \
                                            uint16 * pu16RegValPtr
                                        );
#endif /* STD_ON == ETH_43_PFE_CTRL_USE_45_MDIO_API */
#endif /* STD_OFF == ETH_43_PFE_CTRLENABLE_MII */

#if STD_ON == ETH_43_GET_COUNTER_API
extern Std_ReturnType Eth_43_PFE_GetCounterValues(uint8 u8CtrlIdx, \
                                            Eth_CounterType * CounterPtr
                                        );
#endif /* STD_ON == ETH_43_GET_COUNTER_API */

#if STD_ON == ETH_43_GET_RXSTATS_API
extern Std_ReturnType Eth_43_PFE_GetRxStats(uint8 u8CtrlIdx, \
                                            Eth_RxStatsType * RxStatsPtr
                                        );
#endif /* STD_ON == ETH_43_GET_RXSTATS_API */

#if STD_ON == ETH_43_GET_TXSTATS_API
extern Std_ReturnType Eth_43_PFE_GetTxStats(uint8 u8CtrlIdx, \
                                            Eth_TxStatsType * TxStatsPtr
                                        );
#endif /* STD_ON == ETH_43_GET_TXSTATS_API */

#if STD_ON == ETH_43_GET_TXERROR_COUNTER_API
extern Std_ReturnType Eth_43_PFE_GetTxErrorCounterValues(uint8 u8CtrlIdx, \
                                            Eth_TxErrorCounterValuesType * TxErrorCounterValuesPtr
                                        );
#endif /* STD_ON == ETH_43_GET_TXERROR_COUNTER_API */

#if STD_ON == ETH_43_PFE_VERSION_INFO_API
    #if STD_OFF == ETH_43_PFE_VERSION_INFO_API_MACRO
        extern void Eth_43_PFE_GetVersionInfo(Std_VersionInfoType * VersionInfoPtr);
    #endif /* ETH_43_PFE_VERSION_INFO_API_MACRO */
#endif /* ETH_43_PFE_VERSION_INFO_API */
extern void Eth_43_PFE_MainFunction(void);
extern void * Eth_43_PFE_GetPlatform(void);

#if STD_ON == ETH_43_PFE_GLOBALTIME_SUPPORT
#ifdef PFE_CFG_PFE_MASTER
extern Std_ReturnType Eth_43_PFE_SetGlobalTime(uint8 u8CtrlIdx, Eth_TimeStampType *timeStampPtr);
extern Std_ReturnType Eth_43_PFE_SetCorrectionTime  (   uint8 u8CtrlIdx, \
                                                        const Eth_TimeIntDiffType *timeOffsetPtr, \
                                                        const Eth_RateRatioType *rateRatioPtr \
                                                    );
extern Std_ReturnType Eth_43_PFE_GetCurrentTime (   uint8 u8CtrlIdx, \
                                                    Eth_TimeStampQualType *timeQualPtr, \
                                                    Eth_TimeStampType *timeStampPtr \
                                                );
#endif
extern Std_ReturnType Eth_43_PFE_GetEgressTimeStamp (   uint8 u8CtrlIdx, \
                                                        Eth_BufIdxType BufIdx, \
                                                        Eth_TimeStampQualType *timeQualPtr, \
                                                        Eth_TimeStampType *timeStampPtr \
                                                    );
extern Std_ReturnType Eth_43_PFE_GetIngressTimeStamp(   uint8 u8CtrlIdx, \
                                                        const Eth_DataType *DataPtr, \
                                                        Eth_TimeStampQualType *timeQualPtr, \
                                                        Eth_TimeStampType *timeStampPtr \
                                                    );
extern void Eth_43_PFE_EnableEgressTimeStamp(uint8 u8CtrlIdx, Eth_BufIdxType BufIdx);
#endif /* ETH_43_PFE_GLOBALTIME_SUPPORT */

#define ETH_43_PFE_STOP_SEC_CODE
#include "Eth_43_PFE_MemMap.h"

#ifdef __cplusplus
}
#endif

#endif /* ETH_43_PFE_H */

/** @} */
