/* ================================================================== >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< ------------------------------------------------------------------ Copyright (c) 2024-2024 by Lattice Semiconductor Corporation ALL RIGHTS RESERVED ------------------------------------------------------------------ IMPORTANT: THIS FILE IS USED BY OR GENERATED BY the LATTICE PROPELâ„¢ DEVELOPMENT SUITE, WHICH INCLUDES PROPEL BUILDER AND PROPEL SDK. Lattice grants permission to use this code pursuant to the terms of the Lattice Propel License Agreement. DISCLAIMER: LATTICE MAKES NO WARRANTIES ON THIS FILE OR ITS CONTENTS, WHETHER EXPRESSED, IMPLIED, STATUTORY, OR IN ANY PROVISION OF THE LATTICE PROPEL LICENSE AGREEMENT OR COMMUNICATION WITH LICENSEE, AND LATTICE SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. LATTICE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED HEREIN WILL MEET LICENSEE 'S REQUIREMENTS, OR THAT LICENSEE' S OPERATION OF ANY DEVICE, SOFTWARE OR SYSTEM USING THIS FILE OR ITS CONTENTS WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS HEREIN WILL BE CORRECTED. LICENSEE ASSUMES RESPONSIBILITY FOR SELECTION OF MATERIALS TO ACHIEVE ITS INTENDED RESULTS, AND FOR THE PROPER INSTALLATION, USE, AND RESULTS OBTAINED THEREFROM. LICENSEE ASSUMES THE ENTIRE RISK OF THE FILE AND ITS CONTENTS PROVING DEFECTIVE OR FAILING TO PERFORM PROPERLY AND IN SUCH EVENT, LICENSEE SHALL ASSUME THE ENTIRE COST AND RISK OF ANY REPAIR, SERVICE, CORRECTION, OR ANY OTHER LIABILITIES OR DAMAGES CAUSED BY OR ASSOCIATED WITH THE SOFTWARE.IN NO EVENT SHALL LATTICE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS FILE OR ITS CONTENTS, EVEN IF LATTICE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. LATTICE 'S SOLE LIABILITY, AND LICENSEE' S SOLE REMEDY, IS SET FORTH ABOVE. LATTICE DOES NOT WARRANT OR REPRESENT THAT THIS FILE, ITS CONTENTS OR USE THEREOF DOES NOT INFRINGE ON THIRD PARTIES' INTELLECTUAL PROPERTY RIGHTS, INCLUDING ANY PATENT. IT IS THE USER' S RESPONSIBILITY TO VERIFY THE USER SOFTWARE DESIGN FOR CONSISTENCY AND FUNCTIONALITY THROUGH THE USE OF FORMAL SOFTWARE VALIDATION METHODS. ------------------------------------------------------------------ ================================================================== */ #ifndef _TEN_G_ETHERNET_H_ #define _TEN_G_ETHERNET_H_ #include "bit.h" #define XG_ETHERNET_CONTROLLER_DRV_VER "v2024.01.00" /** * @brief : Control registers offset */ #define TEN_G_MODE 0x000 #define TEN_G_TX_CTL 0x004 #define TEN_G_RX_CTL 0x008 #define TEN_G_MAX_PKT_LNGTH 0x00C #define TEN_G_IPG_VAL 0x010 #define TEN_G_MAC_ADDR_0 0x014 #define TEN_G_MAC_ADDR_1 0x018 #define TEN_G_TX_RX_STS 0x01C #define TEN_G_VLAN_TAG 0x020 #define TEN_G_MC_TABLE_0 0x024 #define TEN_G_MC_TABLE_1 0x028 #define TEN_G_PAUSE_OPCODE 0x02C #define TEN_G_MAC_CTL 0x030 #define TEN_G_PAUSE_TM 0x034 /** * @brief : The bit description for the TEN_G_MODE register */ #define MODE_TX_EN BIT(0) #define MODE_RX_EN BIT(1) /** * @brief : The bit description for the TEN_G_TX_CTL register */ #define TX_PASS_FCS BIT(0) #define TX_FC_EN BIT(1) #define TX_IPG_STRETCH BIT(2) #define TX_TRANSMIT_SHORT BIT(3) #define TX_PASS_PREARM BIT(4) /** * @brief : The bit description for the TEN_G_RX_CTL register */ #define RX_PRMS BIT(0) #define RX_PASS_FCS BIT(1) #define RX_PAUSE_EN BIT(2) #define RX_ALL_MC BIT(3) #define RX_BC BIT(4) #define RX_SHORT BIT(5) #define RX_DROP_MAC_CTRL BIT(6) #define RX_PASS_PREARM BIT(7) /** * @brief : The bit description for the TEN_G_TX_RX_STS register */ #define RX_IDLE BIT(0) #define TX_IDLE BIT(1) /** * @brief : The description for the TX CTL OPTIONS */ #define MAC_CFG_OPTION_TX_PASS_PREARM BIT(0) #define MAC_CFG_OPTION_TX_SHORT BIT(1) #define MAC_CFG_OPTION_TX_IPG_STRETCH BIT(2) #define MAC_CFG_OPTION_TX_FC_EN BIT(3) #define MAC_CFG_OPTION_TX_PASS_FCS BIT(4) /** * @brief : The description for the RX CTL OPTIONS */ #define MAC_CFG_OPTION_RX_PASS_REARM BIT(5) #define MAC_CFG_OPTION_DROP_MAC_CTRL BIT(6) #define MAC_CFG_OPTION_RX_SHORT BIT(7) #define MAC_CFG_OPTION_RX_BC BIT(8) #define MAC_CFG_OPTION_RX_ALL_MC BIT(9) #define MAC_CFG_OPTION_RX_PAUSE_EN BIT(10) #define MAC_CFG_OPTION_RX_PASS_FCS BIT(11) #define MAC_CFG_OPTION_PRMS BIT(12) /** * @brief : The description for the PHY OPTIONS */ #define IP_CFG_OPTION_PHY_XGMII BIT(0) #define IP_CFG_OPTION_PHY_8_BITS_GMII BIT(1) #define IP_CFG_OPTION_PHY_16_BITS_GMII BIT(2) #define IP_CFG_OPTION_PHY_MII BIT(3) /** * @brief : The description for the MAC configuration OPTIONS */ #define IP_CFG_OPTION_MULTICAST_ADDRESS_FILTERING BIT(4) #define IP_CFG_OPTION_STATISTICS_COUNTER_REGISTERS BIT(5) #define IP_CFG_OPTION_TX_PAUSE_FRAME_GENERATION BIT(6) /** * @brief : The description for the Statistics Counter Configuration */ #define IP_CFG_OPTION_COUNTER_WIDTH_32_BITS BIT(7) #define IP_CFG_OPTION_COUNTER_WIDTH_64_BITS BIT(8) #define IP_CFG_OPTION_TX_STATISTICS BIT(9) #define IP_CFG_OPTION_RX_STATISTICS BIT(10) #define SUCCESS 0 #define FAILURE 1 typedef struct { unsigned int base_address; unsigned int ip_cfg_options; }xg_ethernet_config; typedef struct { xg_ethernet_config config; unsigned char phy; unsigned int mac_cfg_options; }xg_ethernet_instance; int xg_ethernet_init(xg_ethernet_instance *this_xg_ethernet, xg_ethernet_config *config); int xg_ethernet_start(xg_ethernet_instance *this_xg_ethernet); int xg_ethernet_stop(xg_ethernet_instance *this_xg_ethernet); int xg_ethernet_reset(xg_ethernet_instance *this_xg_ethernet, xg_ethernet_config *config); int xg_ethernet_set_mac_options(xg_ethernet_instance *this_xg_ethernet, unsigned int options); int xg_ethernet_clear_mac_options(xg_ethernet_instance *this_xg_ethernet, unsigned int options); int xg_ethernet_set_mac_address(xg_ethernet_instance *this_xg_ethernet, char *mac_address); int xg_ethernet_get_mac_address(xg_ethernet_instance *this_xg_ethernet, char *mac_address); int xg_ethernet_conv_mac_to_crc(char *mac_address); int xg_ethernet_multicast_bit_modify(xg_ethernet_instance *this_xg_ethernet, unsigned int crc, unsigned char isSet); int xg_ethernet_set_multicast_filter(xg_ethernet_instance *this_xg_ethernet, char *mac_address); int xg_ethernet_clear_multicast_filter(xg_ethernet_instance *this_xg_ethernet, char *mac_address); int xg_ethernet_get_rx_vlan_tag(xg_ethernet_instance *this_xg_ethernet, unsigned int *vlan_tag); int xg_ethernet_get_rx_idle(xg_ethernet_instance *this_xg_ethernet, unsigned char *rx_idle); int xg_ethernet_get_tx_idle(xg_ethernet_instance *this_xg_ethernet, unsigned char *tx_idle); int xg_ethernet_set_flow_control(xg_ethernet_instance *this_xg_ethernet); int xg_ethernet_set_rx_pause_en(xg_ethernet_instance *this_xg_ethernet); int xg_ethernet_set_pause_tm(xg_ethernet_instance *this_xg_ethernet, int pause_time); int xg_ethernet_tx_pause_frm(xg_ethernet_instance *this_xg_ethernet); int xg_ethernet_set_ipg_val(xg_ethernet_instance *this_xg_ethernet, int ipg_val); int xg_ethernet_set_ipg_stretch_mode(xg_ethernet_instance *this_xg_ethernet); int xg_ethernet_get_statistic_counter(xg_ethernet_instance *this_xg_ethernet, unsigned int reg_offset, unsigned long long *counter_val); int xg_ethernet_print_statistic_counter(xg_ethernet_instance *this_xg_ethernet, unsigned int reg_offset); #endif