Path: blob/main/sys/contrib/alpine-hal/eth/al_hal_eth.h
48255 views
/*-1*******************************************************************************2Copyright (C) 2015 Annapurna Labs Ltd.34This file may be licensed under the terms of the Annapurna Labs Commercial5License Agreement.67Alternatively, this file can be distributed under the terms of the GNU General8Public License V2 as published by the Free Software Foundation and can be9found at http://www.gnu.org/licenses/gpl-2.0.html1011Alternatively, redistribution and use in source and binary forms, with or12without modification, are permitted provided that the following conditions are13met:1415* Redistributions of source code must retain the above copyright notice,16this list of conditions and the following disclaimer.1718* Redistributions in binary form must reproduce the above copyright19notice, this list of conditions and the following disclaimer in20the documentation and/or other materials provided with the21distribution.2223THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND24ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED25WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE26DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR27ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES28(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;29LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON30ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT31(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS32SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.3334*******************************************************************************/3536/**37* @defgroup group_eth_api API38* Ethernet Controller HAL driver API39* @ingroup group_eth40* @{41* @file al_hal_eth.h42*43* @brief Header file for Unified GbE and 10GbE Ethernet Controllers This is a44* common header file that covers both Standard and Advanced Controller45*46*47*/4849#ifndef __AL_HAL_ETH_H__50#define __AL_HAL_ETH_H__5152#include "al_hal_common.h"53#include "al_hal_udma.h"54#include "al_hal_eth_alu.h"55#ifdef AL_ETH_EX56#include "al_hal_eth_ex.h"57#include "al_hal_eth_ex_internal.h"58#endif5960/* *INDENT-OFF* */61#ifdef __cplusplus62extern "C" {63#endif64/* *INDENT-ON* */6566#ifndef AL_ETH_PKT_MAX_BUFS67#ifndef AL_ETH_EX68#define AL_ETH_PKT_MAX_BUFS 1969#else70#define AL_ETH_PKT_MAX_BUFS 3071#endif72#endif7374#define AL_ETH_UDMA_TX_QUEUES 475#define AL_ETH_UDMA_RX_QUEUES 47677/* PCI Adapter Device/Revision ID */78#define AL_ETH_DEV_ID_STANDARD 0x000179#define AL_ETH_DEV_ID_ADVANCED 0x000280#define AL_ETH_REV_ID_0 0 /* Alpine V1 Rev 0 */81#define AL_ETH_REV_ID_1 1 /* Alpine V1 Rev 1 */82#define AL_ETH_REV_ID_2 2 /* Alpine V2 basic */83#define AL_ETH_REV_ID_3 3 /* Alpine V2 advanced */8485/* PCI BARs */86#define AL_ETH_UDMA_BAR 087#define AL_ETH_EC_BAR 488#define AL_ETH_MAC_BAR 28990#define AL_ETH_MAX_FRAME_LEN 1000091#define AL_ETH_MIN_FRAME_LEN 609293#define AL_ETH_TSO_MSS_MAX_IDX 894#define AL_ETH_TSO_MSS_MIN_VAL 195/*TODO: update with correct value*/96#define AL_ETH_TSO_MSS_MAX_VAL (AL_ETH_MAX_FRAME_LEN - 200)9798enum AL_ETH_PROTO_ID {99AL_ETH_PROTO_ID_UNKNOWN = 0,100AL_ETH_PROTO_ID_IPv4 = 8,101AL_ETH_PROTO_ID_IPv6 = 11,102AL_ETH_PROTO_ID_TCP = 12,103AL_ETH_PROTO_ID_UDP = 13,104AL_ETH_PROTO_ID_FCOE = 21,105AL_ETH_PROTO_ID_GRH = 22, /** RoCE l3 header */106AL_ETH_PROTO_ID_BTH = 23, /** RoCE l4 header */107AL_ETH_PROTO_ID_ANY = 32, /**< for sw usage only */108};109#define AL_ETH_PROTOCOLS_NUM (AL_ETH_PROTO_ID_ANY)110111enum AL_ETH_TX_TUNNEL_MODE {112AL_ETH_NO_TUNNELING = 0,113AL_ETH_TUNNEL_NO_UDP = 1, /* NVGRE / IP over IP */114AL_ETH_TUNNEL_WITH_UDP = 3, /* VXLAN */115};116117#define AL_ETH_RX_THASH_TABLE_SIZE (1 << 8)118#define AL_ETH_RX_FSM_TABLE_SIZE (1 << 7)119#define AL_ETH_RX_CTRL_TABLE_SIZE (1 << 11)120#define AL_ETH_RX_HASH_KEY_NUM 10121#define AL_ETH_FWD_MAC_NUM 32122#define AL_ETH_FWD_MAC_HASH_NUM 256123#define AL_ETH_FWD_PBITS_TABLE_NUM (1 << 3)124#define AL_ETH_FWD_PRIO_TABLE_NUM (1 << 3)125#define AL_ETH_FWD_VID_TABLE_NUM (1 << 12)126#define AL_ETH_FWD_DSCP_TABLE_NUM (1 << 8)127#define AL_ETH_FWD_TC_TABLE_NUM (1 << 8)128129/** MAC media mode */130enum al_eth_mac_mode {131AL_ETH_MAC_MODE_RGMII,132AL_ETH_MAC_MODE_SGMII,133AL_ETH_MAC_MODE_SGMII_2_5G,134AL_ETH_MAC_MODE_10GbE_Serial, /**< Applies to XFI and KR modes */135AL_ETH_MAC_MODE_10G_SGMII, /**< SGMII using the 10G MAC, don't use*/136AL_ETH_MAC_MODE_XLG_LL_40G, /**< applies to 40G mode using the 40G low latency (LL) MAC */137AL_ETH_MAC_MODE_KR_LL_25G, /**< applies to 25G mode using the 10/25G low latency (LL) MAC */138AL_ETH_MAC_MODE_XLG_LL_50G, /**< applies to 50G mode using the 40/50G low latency (LL) MAC */139AL_ETH_MAC_MODE_XLG_LL_25G /**< applies to 25G mode using the 40/50G low latency (LL) MAC */140};141142struct al_eth_capabilities {143al_bool speed_10_HD;144al_bool speed_10_FD;145al_bool speed_100_HD;146al_bool speed_100_FD;147al_bool speed_1000_HD;148al_bool speed_1000_FD;149al_bool speed_10000_HD;150al_bool speed_10000_FD;151al_bool pfc; /**< priority flow control */152al_bool eee; /**< Energy Efficient Ethernet */153};154155/** interface type used for MDIO */156enum al_eth_mdio_if {157AL_ETH_MDIO_IF_1G_MAC = 0,158AL_ETH_MDIO_IF_10G_MAC = 1159};160161/** MDIO protocol type */162enum al_eth_mdio_type {163AL_ETH_MDIO_TYPE_CLAUSE_22 = 0,164AL_ETH_MDIO_TYPE_CLAUSE_45 = 1165};166167/** flow control mode */168enum al_eth_flow_control_type {169AL_ETH_FLOW_CONTROL_TYPE_LINK_PAUSE,170AL_ETH_FLOW_CONTROL_TYPE_PFC171};172173/** Tx to Rx switching decision type */174enum al_eth_tx_switch_dec_type {175AL_ETH_TX_SWITCH_TYPE_MAC = 0,176AL_ETH_TX_SWITCH_TYPE_VLAN_TABLE = 1,177AL_ETH_TX_SWITCH_TYPE_VLAN_TABLE_AND_MAC = 2,178AL_ETH_TX_SWITCH_TYPE_BITMAP = 3179};180181/** Tx to Rx VLAN ID selection type */182enum al_eth_tx_switch_vid_sel_type {183AL_ETH_TX_SWITCH_VID_SEL_TYPE_VLAN1 = 0,184AL_ETH_TX_SWITCH_VID_SEL_TYPE_VLAN2 = 1,185AL_ETH_TX_SWITCH_VID_SEL_TYPE_NEW_VLAN1 = 2,186AL_ETH_TX_SWITCH_VID_SEL_TYPE_NEW_VLAN2 = 3,187AL_ETH_TX_SWITCH_VID_SEL_TYPE_DEFAULT_VLAN1 = 4,188AL_ETH_TX_SWITCH_VID_SEL_TYPE_FINAL_VLAN1 = 5189};190191/** Rx descriptor configurations */192/* Note: when selecting rx descriptor field to inner packet, then that field193* will be set according to inner packet when packet is tunneled, for non-tunneled194* packets, the field will be set according to the packets header */195196/** selection of the LRO_context_value result in the Metadata */197enum al_eth_rx_desc_lro_context_val_res {198AL_ETH_LRO_CONTEXT_VALUE = 0, /**< LRO_context_value */199AL_ETH_L4_OFFSET = 1, /**< L4_offset */200};201202/** selection of the L4 offset in the Metadata */203enum al_eth_rx_desc_l4_offset_sel {204AL_ETH_L4_OFFSET_OUTER = 0, /**< set L4 offset of the outer packet */205AL_ETH_L4_OFFSET_INNER = 1, /**< set L4 offset of the inner packet */206};207208/** selection of the L4 checksum result in the Metadata */209enum al_eth_rx_desc_l4_chk_res_sel {210AL_ETH_L4_INNER_CHK = 0, /**< L4 checksum */211AL_ETH_L4_INNER_OUTER_CHK = 1, /**< Logic AND between outer and inner212L4 checksum result */213};214215/** selection of the L3 checksum result in the Metadata */216enum al_eth_rx_desc_l3_chk_res_sel {217AL_ETH_L3_CHK_TYPE_0 = 0, /**< L3 checksum */218AL_ETH_L3_CHK_TYPE_1 = 1, /**< L3 checksum or RoCE/FCoE CRC,219based on outer header */220AL_ETH_L3_CHK_TYPE_2 = 2, /**< If tunnel exist = 0,221L3 checksum or RoCE/FCoE CRC,222based on outer header.223Else,224logic AND between outer L3 checksum225(Ipv4) and inner CRC (RoCE or FcoE) */226AL_ETH_L3_CHK_TYPE_3 = 3, /**< combination of the L3 checksum result and227CRC result,based on the checksum and228RoCE/FCoE CRC input selections. */229};230231/** selection of the L3 protocol index in the Metadata */232enum al_eth_rx_desc_l3_proto_idx_sel {233AL_ETH_L3_PROTO_IDX_OUTER = 0, /**< set L3 proto index of the outer packet */234AL_ETH_L3_PROTO_IDX_INNER = 1, /**< set L3 proto index of the inner packet */235};236237/** selection of the L3 offset in the Metadata */238enum al_eth_rx_desc_l3_offset_sel {239AL_ETH_L3_OFFSET_OUTER = 0, /**< set L3 offset of the outer packet */240AL_ETH_L3_OFFSET_INNER = 1, /**< set L3 offset of the inner packet */241};242243244/** selection of the L4 protocol index in the Metadata */245enum al_eth_rx_desc_l4_proto_idx_sel {246AL_ETH_L4_PROTO_IDX_OUTER = 0, /**< set L4 proto index of the outer packet */247AL_ETH_L4_PROTO_IDX_INNER = 1, /**< set L4 proto index of the inner packet */248};249250/** selection of the frag indication in the Metadata */251enum al_eth_rx_desc_frag_sel {252AL_ETH_FRAG_OUTER = 0, /**< set frag of the outer packet */253AL_ETH_FRAG_INNER = 1, /**< set frag of the inner packet */254};255256/** Ethernet Rx completion descriptor */257typedef struct {258uint32_t ctrl_meta;259uint32_t len;260uint32_t word2;261uint32_t word3;262} al_eth_rx_cdesc;263264/** Flow Contol parameters */265struct al_eth_flow_control_params{266enum al_eth_flow_control_type type; /**< flow control type */267al_bool obay_enable; /**< stop tx when pause received */268al_bool gen_enable; /**< generate pause frames */269uint16_t rx_fifo_th_high;270uint16_t rx_fifo_th_low;271uint16_t quanta;272uint16_t quanta_th;273uint8_t prio_q_map[4][8]; /**< for each UDMA, defines the mapping between274* PFC priority and queues(in bit mask).275* same mapping used for obay and generation.276* for example:277* if prio_q_map[1][7] = 0xC, then TX queues 2278* and 3 of UDMA 1 will be stopped when pause279* received with priority 7, also, when RX queues280* 2 and 3 of UDMA 1 become almost full, then281* pause frame with priority 7 will be sent.282*283*note:284* 1) if specific a queue is not used, the caller must285* make set the prio_q_map to 0 otherwise that queue286* will make the controller keep sending PAUSE packets.287* 2) queues of unused UDMA must be treated as above.288* 3) when working in LINK PAUSE mode, only entries at289* priority 0 will be considered.290*/291};292293/* Packet Tx flags */294#define AL_ETH_TX_FLAGS_TSO AL_BIT(7) /**< Enable TCP/UDP segmentation offloading */295#define AL_ETH_TX_FLAGS_IPV4_L3_CSUM AL_BIT(13) /**< Enable IPv4 header checksum calculation */296#define AL_ETH_TX_FLAGS_L4_CSUM AL_BIT(14) /**< Enable TCP/UDP checksum calculation */297#define AL_ETH_TX_FLAGS_L4_PARTIAL_CSUM AL_BIT(17) /**< L4 partial checksum calculation */298#define AL_ETH_TX_FLAGS_L2_MACSEC_PKT AL_BIT(16) /**< L2 Packet type 802_3 or 802_3_MACSEC, V2 */299#define AL_ETH_TX_FLAGS_ENCRYPT AL_BIT(16) /**< Enable TX packet encryption, V3 */300#define AL_ETH_TX_FLAGS_L2_DIS_FCS AL_BIT(15) /**< Disable CRC calculation*/301#define AL_ETH_TX_FLAGS_TS AL_BIT(21) /**< Timestamp the packet */302303#define AL_ETH_TX_FLAGS_INT AL_M2S_DESC_INT_EN304#define AL_ETH_TX_FLAGS_NO_SNOOP AL_M2S_DESC_NO_SNOOP_H305306/** this structure used for tx packet meta data */307struct al_eth_meta_data{308uint8_t store :1; /**< store the meta into the queues cache */309uint8_t words_valid :4; /**< valid bit per word */310311uint8_t vlan1_cfi_sel:2;312uint8_t vlan2_vid_sel:2;313uint8_t vlan2_cfi_sel:2;314uint8_t vlan2_pbits_sel:2;315uint8_t vlan2_ether_sel:2;316317uint16_t vlan1_new_vid:12;318uint8_t vlan1_new_cfi :1;319uint8_t vlan1_new_pbits :3;320uint16_t vlan2_new_vid:12;321uint8_t vlan2_new_cfi :1;322uint8_t vlan2_new_pbits :3;323324uint8_t l3_header_len; /**< in bytes */325uint8_t l3_header_offset;326uint8_t l4_header_len; /**< in words(32-bits) */327328/* rev 0 specific */329uint8_t mss_idx_sel:3; /**< for TSO, select the register that holds the MSS */330331/* rev 1 specific */332uint8_t ts_index:4; /**< index of regiser where to store the tx timestamp */333uint16_t mss_val :14; /**< for TSO, set the mss value */334uint8_t outer_l3_offset; /**< for tunneling mode. up to 64 bytes */335uint8_t outer_l3_len; /**< for tunneling mode. up to 128 bytes */336};337338/* Packet Rx flags when adding buffer to receive queue */339340/**<341* Target-ID to be assigned to the packet descriptors342* Requires Target-ID in descriptor to be enabled for the specific UDMA343* queue.344*/345#define AL_ETH_RX_FLAGS_TGTID_MASK AL_FIELD_MASK(15, 0)346#define AL_ETH_RX_FLAGS_NO_SNOOP AL_M2S_DESC_NO_SNOOP_H347#define AL_ETH_RX_FLAGS_INT AL_M2S_DESC_INT_EN348#define AL_ETH_RX_FLAGS_DUAL_BUF AL_BIT(31)349350/* Packet Rx flags set by HW when receiving packet */351#define AL_ETH_RX_ERROR AL_BIT(16) /**< layer 2 errors (FCS, bad len, etc) */352#define AL_ETH_RX_FLAGS_L4_CSUM_ERR AL_BIT(14)353#define AL_ETH_RX_FLAGS_L3_CSUM_ERR AL_BIT(13)354355/* Packet Rx flags - word 3 in Rx completion descriptor */356#define AL_ETH_RX_FLAGS_CRC AL_BIT(31)357#define AL_ETH_RX_FLAGS_L3_CSUM_2 AL_BIT(30)358#define AL_ETH_RX_FLAGS_L4_CSUM_2 AL_BIT(29)359#define AL_ETH_RX_FLAGS_SW_SRC_PORT_SHIFT 13360#define AL_ETH_RX_FLAGS_SW_SRC_PORT_MASK AL_FIELD_MASK(15, 13)361#define AL_ETH_RX_FLAGS_LRO_CONTEXT_VAL_SHIFT 3362#define AL_ETH_RX_FLAGS_LRO_CONTEXT_VAL_MASK AL_FIELD_MASK(10, 3)363#define AL_ETH_RX_FLAGS_L4_OFFSET_SHIFT 3364#define AL_ETH_RX_FLAGS_L4_OFFSET_MASK AL_FIELD_MASK(10, 3)365#define AL_ETH_RX_FLAGS_PRIORITY_SHIFT 0366#define AL_ETH_RX_FLAGS_PRIORITY_MASK AL_FIELD_MASK(2, 0)367368/** packet structure. used for packet transmission and reception */369struct al_eth_pkt{370uint32_t flags; /**< see flags above, depends on context(tx or rx) */371enum AL_ETH_PROTO_ID l3_proto_idx;372enum AL_ETH_PROTO_ID l4_proto_idx;373uint8_t source_vlan_count:2;374uint8_t vlan_mod_add_count:2;375uint8_t vlan_mod_del_count:2;376uint8_t vlan_mod_v1_ether_sel:2;377uint8_t vlan_mod_v1_vid_sel:2;378uint8_t vlan_mod_v1_pbits_sel:2;379380/* rev 1 specific */381enum AL_ETH_TX_TUNNEL_MODE tunnel_mode;382enum AL_ETH_PROTO_ID outer_l3_proto_idx; /**< for tunneling mode */383384/**<385* Target-ID to be assigned to the packet descriptors386* Requires Target-ID in descriptor to be enabled for the specific UDMA387* queue.388*/389uint16_t tgtid;390391uint32_t rx_header_len; /**< header buffer length of rx packet, not used */392struct al_eth_meta_data *meta; /**< if null, then no meta added */393#ifdef AL_ETH_RX_DESC_RAW_GET394uint32_t rx_desc_raw[4];395#endif396uint16_t rxhash;397uint16_t l3_offset;398399#ifdef AL_ETH_EX400struct al_eth_ext_metadata *ext_meta_data;401#endif402403uint8_t num_of_bufs;404struct al_buf bufs[AL_ETH_PKT_MAX_BUFS];405};406407struct al_ec_regs;408409410/** Ethernet Adapter private data structure used by this driver */411struct al_hal_eth_adapter{412uint8_t rev_id; /**<PCI adapter revision ID */413uint8_t udma_id; /**< the id of the UDMA used by this adapter */414struct unit_regs __iomem * unit_regs;415void __iomem *udma_regs_base;416struct al_ec_regs __iomem *ec_regs_base;417void __iomem *ec_ints_base;418struct al_eth_mac_regs __iomem *mac_regs_base;419struct interrupt_controller_ctrl __iomem *mac_ints_base;420421char *name; /**< the upper layer must keep the string area */422423struct al_udma tx_udma;424/* uint8_t tx_queues;*//* number of tx queues */425struct al_udma rx_udma;426/* uint8_t rx_queues;*//* number of tx queues */427428uint8_t enable_rx_parser; /**< config and enable rx parsing */429430enum al_eth_flow_control_type fc_type; /**< flow control*/431432enum al_eth_mac_mode mac_mode;433enum al_eth_mdio_if mdio_if; /**< which mac mdio interface to use */434enum al_eth_mdio_type mdio_type; /**< mdio protocol type */435al_bool shared_mdio_if; /**< when AL_TRUE, the mdio interface is shared with other controllers.*/436uint8_t curr_lt_unit;437uint8_t serdes_lane;438#ifdef AL_ETH_EX439struct al_eth_ex_state ex_state;440#endif441};442443/** parameters from upper layer */444struct al_eth_adapter_params{445uint8_t rev_id; /**<PCI adapter revision ID */446uint8_t udma_id; /**< the id of the UDMA used by this adapter */447uint8_t enable_rx_parser; /**< when true, the rx epe parser will be enabled */448void __iomem *udma_regs_base; /**< UDMA register base address */449void __iomem *ec_regs_base; /**< Ethernet controller registers base address450* can be null if the function is virtual451*/452void __iomem *mac_regs_base; /**< Ethernet MAC registers base address453* can be null if the function is virtual454*/455char *name; /**< the upper layer must keep the string area */456457uint8_t serdes_lane; /**< serdes lane (relevant to 25G macs only) */458};459460/* adapter management */461/**462* initialize the ethernet adapter's DMA463* - initialize the adapter data structure464* - initialize the Tx and Rx UDMA465* - enable the Tx and Rx UDMA, the rings will be still disabled at this point.466*467* @param adapter pointer to the private structure468* @param params the parameters passed from upper layer469*470* @return 0 on success. otherwise on failure.471*/472int al_eth_adapter_init(struct al_hal_eth_adapter *adapter, struct al_eth_adapter_params *params);473474/**475* stop the DMA of the ethernet adapter476*477* @param adapter pointer to the private structure478*479* @return 0 on success. otherwise on failure.480*/481int al_eth_adapter_stop(struct al_hal_eth_adapter *adapter);482483int al_eth_adapter_reset(struct al_hal_eth_adapter *adapter);484485/**486* enable the ec and mac interrupts487*488* @param adapter pointer to the private structure489*490* @return 0 on success. otherwise on failure.491*/492int al_eth_ec_mac_ints_config(struct al_hal_eth_adapter *adapter);493494/**495* ec and mac interrupt service routine496* read and print asserted interrupts497*498* @param adapter pointer to the private structure499*500* @return 0 on success. otherwise on failure.501*/502int al_eth_ec_mac_isr(struct al_hal_eth_adapter *adapter);503504/* Q management */505/**506* Configure and enable a queue ring507*508* @param adapter pointer to the private structure509* @param type tx or rx510* @param qid queue index511* @param q_params queue parameters512*513* @return 0 on success. otherwise on failure.514*/515int al_eth_queue_config(struct al_hal_eth_adapter *adapter, enum al_udma_type type, uint32_t qid,516struct al_udma_q_params *q_params);517518519/**520* enable a queue if it was previously disabled521*522* @param adapter pointer to the private structure523* @param type tx or rx524* @param qid queue index525*526* @return -EPERM (not implemented yet).527*/528int al_eth_queue_enable(struct al_hal_eth_adapter *adapter, enum al_udma_type type, uint32_t qid);529530/**531* disable a queue532* @param adapter pointer to the private structure533* @param type tx or rx534* @param qid queue index535*536* @return -EPERM (not implemented yet).537*/538int al_eth_queue_disable(struct al_hal_eth_adapter *adapter, enum al_udma_type type, uint32_t qid);539540/* MAC layer */541542/**543* configure the mac media type.544* this function only sets the mode, but not the speed as certain mac modes545* support multiple speeds as will be negotiated by the link layer.546* @param adapter pointer to the private structure.547* @param mode media mode548*549* @return 0 on success. negative errno on failure.550*/551int al_eth_mac_config(struct al_hal_eth_adapter *adapter, enum al_eth_mac_mode mode);552553/**554* stop the mac tx and rx paths.555* @param adapter pointer to the private structure.556*557* @return 0 on success. negative error on failure.558*/559int al_eth_mac_stop(struct al_hal_eth_adapter *adapter);560561/**562* start the mac tx and rx paths.563* @param adapter pointer to the private structure.564*565* @return 0 on success. negative error on failure.566*/567int al_eth_mac_start(struct al_hal_eth_adapter *adapter);568569/**570* Perform gearbox reset for tx lanes And/Or Rx lanes.571* applicable only when the controller is connected to srds25G.572* This reset should be performed after each operation that changes the clocks573* (such as serdes reset, mac stop, etc.)574*575* @param adapter pointer to the private structure.576* @param tx_reset assert and de-assert reset for tx lanes577* @param rx_reset assert and de-assert reset for rx lanes578*/579void al_eth_gearbox_reset(struct al_hal_eth_adapter *adapter, al_bool tx_reset, al_bool rx_reset);580581/**582* Enable / Disable forward error correction (FEC)583*584* @param adapter pointer to the private structure.585* @param enable true to enable FEC. false to disable FEC.586*587* @return 0 on success. negative error on failure.588*/589int al_eth_fec_enable(struct al_hal_eth_adapter *adapter, al_bool enable);590591/**592* Get forward error correction (FEC) statistics593*594* @param adapter pointer to the private structure.595* @param corrected number of bits been corrected by the FEC596* @param uncorrectable number of bits that FEC couldn't correct.597*598* @return 0 on success. negative error on failure.599*/600int al_eth_fec_stats_get(struct al_hal_eth_adapter *adapter,601uint32_t *corrected, uint32_t *uncorrectable);602603/**604* get the adapter capabilities (speed, duplex,..)605* this function must not be called before configuring the mac mode using al_eth_mac_config()606* @param adapter pointer to the private structure.607* @param caps pointer to structure that will be updated by this function608*609* @return 0 on success. negative errno on failure.610*/611int al_eth_capabilities_get(struct al_hal_eth_adapter *adapter, struct al_eth_capabilities *caps);612613/**614* update link auto negotiation speed and duplex mode615* this function assumes the mac mode already set using the al_eth_mac_config()616* function.617*618* @param adapter pointer to the private structure619* @param force_1000_base_x set to AL_TRUE to force the mac to work on 1000baseX620* (not relevant to RGMII)621* @param an_enable set to AL_TRUE to enable auto negotiation622* (not relevant to RGMII)623* @param speed in mega bits, e.g 1000 stands for 1Gbps (relevant only in case624* an_enable is AL_FALSE)625* @param full_duplex set to AL_TRUE to enable full duplex mode (relevant only626* in case an_enable is AL_FALSE)627*628* @return 0 on success. otherwise on failure.629*/630int al_eth_mac_link_config(struct al_hal_eth_adapter *adapter,631al_bool force_1000_base_x,632al_bool an_enable,633uint32_t speed,634al_bool full_duplex);635/**636* Enable/Disable Loopback mode637*638* @param adapter pointer to the private structure639* @param enable set to AL_TRUE to enable full duplex mode640*641* @return 0 on success. otherwise on failure.642*/643int al_eth_mac_loopback_config(struct al_hal_eth_adapter *adapter, int enable);644645/**646* configure minimum and maximum rx packet length647*648* @param adapter pointer to the private structure649* @param min_rx_len minimum rx packet length650* @param max_rx_len maximum rx packet length651* both length limits in bytes and it includes the MAC Layer header and FCS.652* @return 0 on success, otherwise on failure.653*/654int al_eth_rx_pkt_limit_config(struct al_hal_eth_adapter *adapter, uint32_t min_rx_len, uint32_t max_rx_len);655656657/* MDIO */658659/* Reference clock frequency (platform specific) */660enum al_eth_ref_clk_freq {661AL_ETH_REF_FREQ_375_MHZ = 0,662AL_ETH_REF_FREQ_187_5_MHZ = 1,663AL_ETH_REF_FREQ_250_MHZ = 2,664AL_ETH_REF_FREQ_500_MHZ = 3,665AL_ETH_REF_FREQ_428_MHZ = 4,666};667668/**669* configure the MDIO hardware interface670* @param adapter pointer to the private structure671* @param mdio_type clause type672* @param shared_mdio_if set to AL_TRUE if multiple controllers using the same673* @param ref_clk_freq reference clock frequency674* @param mdio_clk_freq_khz the required MDC/MDIO clock frequency [Khz]675* MDIO pins of the chip.676*677* @return 0 on success, otherwise on failure.678*/679int al_eth_mdio_config(struct al_hal_eth_adapter *adapter,680enum al_eth_mdio_type mdio_type,681al_bool shared_mdio_if,682enum al_eth_ref_clk_freq ref_clk_freq,683unsigned int mdio_clk_freq_khz);684685/**686* read mdio register687* this function uses polling mode, and as the mdio is slow interface, it might688* block the cpu for long time (milliseconds).689* @param adapter pointer to the private structure690* @param phy_addr address of mdio phy691* @param device address of mdio device (used only in CLAUSE 45)692* @param reg index of the register693* @param val pointer for read value of the register694*695* @return 0 on success, negative errno on failure696*/697int al_eth_mdio_read(struct al_hal_eth_adapter *adapter, uint32_t phy_addr,698uint32_t device, uint32_t reg, uint16_t *val);699700/**701* write mdio register702* this function uses polling mode, and as the mdio is slow interface, it might703* block the cpu for long time (milliseconds).704* @param adapter pointer to the private structure705* @param phy_addr address of mdio phy706* @param device address of mdio device (used only in CLAUSE 45)707* @param reg index of the register708* @param val value to write709*710* @return 0 on success, negative errno on failure711*/712int al_eth_mdio_write(struct al_hal_eth_adapter *adapter, uint32_t phy_addr,713uint32_t device, uint32_t reg, uint16_t val);714715/* TX */716/**717* get number of free tx descriptors718*719* @param adapter adapter handle720* @param qid queue index721*722* @return num of free descriptors.723*/724static INLINE uint32_t al_eth_tx_available_get(struct al_hal_eth_adapter *adapter,725uint32_t qid)726{727struct al_udma_q *udma_q;728729al_udma_q_handle_get(&adapter->tx_udma, qid, &udma_q);730731return al_udma_available_get(udma_q);732}733734/**735* prepare packet descriptors in tx queue.736*737* This functions prepares the descriptors for the given packet in the tx738* submission ring. the caller must call al_eth_tx_pkt_action() below739* in order to notify the hardware about the new descriptors.740*741* @param tx_dma_q pointer to UDMA tx queue742* @param pkt the packet to transmit743*744* @return number of descriptors used for this packet, 0 if no free745* room in the descriptors ring746*/747int al_eth_tx_pkt_prepare(struct al_udma_q *tx_dma_q, struct al_eth_pkt *pkt);748749750/**751* Trigger the DMA about previously added tx descriptors.752*753* @param tx_dma_q pointer to UDMA tx queue754* @param tx_descs number of descriptors to notify the DMA about.755* the tx_descs can be sum of descriptor numbers of multiple prepared packets,756* this way the caller can use this function to notify the DMA about multiple757* packets.758*/759void al_eth_tx_dma_action(struct al_udma_q *tx_dma_q, uint32_t tx_descs);760761/**762* get number of completed tx descriptors, upper layer should derive from763* this information which packets were completed.764*765* @param tx_dma_q pointer to UDMA tx queue766*767* @return number of completed tx descriptors.768*/769int al_eth_comp_tx_get(struct al_udma_q *tx_dma_q);770771/**772* configure a TSO MSS val773*774* the TSO MSS vals are preconfigured values for MSS stored in hardware and the775* packet could use them when not working in MSS explicit mode.776* @param adapter pointer to the private structure777* @param idx the mss index778* @param mss_val the MSS value779*780* @return 0 on success. otherwise on failure.781*/782int al_eth_tso_mss_config(struct al_hal_eth_adapter *adapter, uint8_t idx, uint32_t mss_val);783784/* RX */785/**786* Config the RX descriptor fields787*788* @param adapter pointer to the private structure789* @param lro_sel select LRO context or l4 offset790* @param l4_offset_sel select l4 offset source791* @param l4_sel select the l4 checksum result792* @param l3_sel select the l3 checksum result793* @param l3_proto_sel select the l3 protocol index source794* @param l4_proto_sel select the l4 protocol index source795* @param frag_sel select the frag indication source796*/797void al_eth_rx_desc_config(798struct al_hal_eth_adapter *adapter,799enum al_eth_rx_desc_lro_context_val_res lro_sel,800enum al_eth_rx_desc_l4_offset_sel l4_offset_sel,801enum al_eth_rx_desc_l3_offset_sel l3_offset_sel,802enum al_eth_rx_desc_l4_chk_res_sel l4_sel,803enum al_eth_rx_desc_l3_chk_res_sel l3_sel,804enum al_eth_rx_desc_l3_proto_idx_sel l3_proto_sel,805enum al_eth_rx_desc_l4_proto_idx_sel l4_proto_sel,806enum al_eth_rx_desc_frag_sel frag_sel);807808/**809* Configure RX header split810*811* @param adapter pointer to the private structure812* @param enable header split when AL_TRUE813* @param header_split_len length in bytes of the header split, this value used when814* CTRL TABLE header split len select is set to815* AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_REG, in this case the controller will816* store the first header_split_len bytes into buf2, then the rest (if any) into buf1.817* when CTRL_TABLE header split len select set to other value, then the header_len818* determined according to the parser, and the header_split_len parameter is not819* used.820*821* return 0 on success. otherwise on failure.822*/823int al_eth_rx_header_split_config(struct al_hal_eth_adapter *adapter, al_bool enable, uint32_t header_len);824825/**826* enable / disable header split in the udma queue.827* length will be taken from the udma configuration to enable different length per queue.828*829* @param adapter pointer to the private structure830* @param enable header split when AL_TRUE831* @param qid the queue id to enable/disable header split832* @param header_len in what len the udma will cut the header833*834* return 0 on success.835*/836int al_eth_rx_header_split_force_len_config(struct al_hal_eth_adapter *adapter,837al_bool enable,838uint32_t qid,839uint32_t header_len);840841/**842* add buffer to receive queue843*844* @param rx_dma_q pointer to UDMA rx queue845* @param buf pointer to data buffer846* @param flags bitwise of AL_ETH_RX_FLAGS847* @param header_buf this is not used for far and header_buf should be set to848* NULL.849*850* @return 0 on success. otherwise on failure.851*/852int al_eth_rx_buffer_add(struct al_udma_q *rx_dma_q,853struct al_buf *buf, uint32_t flags,854struct al_buf *header_buf);855856/**857* notify the hw engine about rx descriptors that were added to the receive queue858*859* @param rx_dma_q pointer to UDMA rx queue860* @param descs_num number of rx descriptors861*/862void al_eth_rx_buffer_action(struct al_udma_q *rx_dma_q,863uint32_t descs_num);864865/**866* get packet from RX completion ring867*868* @param rx_dma_q pointer to UDMA rx queue869* @param pkt pointer to a packet data structure, this function fills this870* structure with the information about the received packet. the buffers871* structures filled only with the length of the data written into the buffer,872* the address fields are not updated as the upper layer can retrieve this873* information by itself because the hardware uses the buffers in the same order874* were those buffers inserted into the ring of the receive queue.875* this structure should be allocated by the caller function.876*877* @return return number of descriptors or 0 if no completed packet found.878*/879uint32_t al_eth_pkt_rx(struct al_udma_q *rx_dma_q, struct al_eth_pkt *pkt);880881882/* RX parser table */883struct al_eth_epe_p_reg_entry {884uint32_t data;885uint32_t mask;886uint32_t ctrl;887};888889struct al_eth_epe_control_entry {890uint32_t data[6];891};892893/**894* update rx parser entry895*896* @param adapter pointer to the private structure897* @param idx the protocol index to update898* @param reg_entry contents of parser register entry899* @param control entry contents of control table entry900*901* @return 0 on success. otherwise on failure.902*/903int al_eth_rx_parser_entry_update(struct al_hal_eth_adapter *adapter, uint32_t idx,904struct al_eth_epe_p_reg_entry *reg_entry,905struct al_eth_epe_control_entry *control_entry);906907/* Flow Steering and filtering */908int al_eth_thash_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint8_t udma, uint32_t queue);909910/* FSM table bits */911/** FSM table has 7 bits input address:912* bits[2:0] are the outer packet's type (IPv4, TCP...)913* bits[5:3] are the inner packet's type914* bit[6] is set when packet is tunneled.915*916* The output of each entry:917* bits[1:0] - input selection: selects the input for the thash (2/4 tuple, inner/outer)918* bit[2] - selects whether to use thash output, or default values for the queue and udma919* bits[6:3] default UDMA mask: the UDMAs to select when bit 2 above was unset920* bits[9:5] defualt queue: the queue index to select when bit 2 above was unset921*/922923#define AL_ETH_FSM_ENTRY_IPV4_TCP 0924#define AL_ETH_FSM_ENTRY_IPV4_UDP 1925#define AL_ETH_FSM_ENTRY_IPV6_TCP 2926#define AL_ETH_FSM_ENTRY_IPV6_UDP 3927#define AL_ETH_FSM_ENTRY_IPV6_NO_UDP_TCP 4928#define AL_ETH_FSM_ENTRY_IPV4_NO_UDP_TCP 5929#define AL_ETH_FSM_ENTRY_IPV4_FRAGMENTED 6930#define AL_ETH_FSM_ENTRY_NOT_IP 7931932#define AL_ETH_FSM_ENTRY_OUTER(idx) ((idx) & 7)933#define AL_ETH_FSM_ENTRY_INNER(idx) (((idx) >> 3) & 7)934#define AL_ETH_FSM_ENTRY_TUNNELED(idx) (((idx) >> 6) & 1)935936/* FSM DATA format */937#define AL_ETH_FSM_DATA_OUTER_2_TUPLE 0938#define AL_ETH_FSM_DATA_OUTER_4_TUPLE 1939#define AL_ETH_FSM_DATA_INNER_2_TUPLE 2940#define AL_ETH_FSM_DATA_INNER_4_TUPLE 3941942#define AL_ETH_FSM_DATA_HASH_SEL (1 << 2)943944#define AL_ETH_FSM_DATA_DEFAULT_Q_SHIFT 5945#define AL_ETH_FSM_DATA_DEFAULT_UDMA_SHIFT 3946947/* set fsm table entry */948int al_eth_fsm_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint32_t entry);949950enum AL_ETH_FWD_CTRL_IDX_VLAN_TABLE_OUT {951AL_ETH_FWD_CTRL_IDX_VLAN_TABLE_OUT_0 = 0,952AL_ETH_FWD_CTRL_IDX_VLAN_TABLE_OUT_1 = 1,953AL_ETH_FWD_CTRL_IDX_VLAN_TABLE_OUT_ANY = 2,954};955956enum AL_ETH_FWD_CTRL_IDX_TUNNEL {957AL_ETH_FWD_CTRL_IDX_TUNNEL_NOT_EXIST = 0,958AL_ETH_FWD_CTRL_IDX_TUNNEL_EXIST = 1,959AL_ETH_FWD_CTRL_IDX_TUNNEL_ANY = 2,960};961962enum AL_ETH_FWD_CTRL_IDX_VLAN {963AL_ETH_FWD_CTRL_IDX_VLAN_NOT_EXIST = 0,964AL_ETH_FWD_CTRL_IDX_VLAN_EXIST = 1,965AL_ETH_FWD_CTRL_IDX_VLAN_ANY = 2,966};967968enum AL_ETH_FWD_CTRL_IDX_MAC_TABLE {969AL_ETH_FWD_CTRL_IDX_MAC_TABLE_NO_MATCH = 0,970AL_ETH_FWD_CTRL_IDX_MAC_TABLE_MATCH = 1,971AL_ETH_FWD_CTRL_IDX_MAC_TABLE_ANY = 2,972};973974enum AL_ETH_FWD_CTRL_IDX_MAC_DA_TYPE {975AL_ETH_FWD_CTRL_IDX_MAC_DA_TYPE_UC = 0, /**< unicast */976AL_ETH_FWD_CTRL_IDX_MAC_DA_TYPE_MC = 1, /**< multicast */977AL_ETH_FWD_CTRL_IDX_MAC_DA_TYPE_BC = 2, /**< broadcast */978AL_ETH_FWD_CTRL_IDX_MAC_DA_TYPE_ANY = 4, /**< for sw usage */979};980981/**982* This structure defines the index or group of indeces within the control table.983* each field has special enum value (with _ANY postfix) that indicates all984* possible values of that field.985*/986struct al_eth_fwd_ctrl_table_index {987enum AL_ETH_FWD_CTRL_IDX_VLAN_TABLE_OUT vlan_table_out;988enum AL_ETH_FWD_CTRL_IDX_TUNNEL tunnel_exist;989enum AL_ETH_FWD_CTRL_IDX_VLAN vlan_exist;990enum AL_ETH_FWD_CTRL_IDX_MAC_TABLE mac_table_match;991enum AL_ETH_PROTO_ID protocol_id;992enum AL_ETH_FWD_CTRL_IDX_MAC_DA_TYPE mac_type;993};994995enum AL_ETH_CTRL_TABLE_PRIO_SEL {996AL_ETH_CTRL_TABLE_PRIO_SEL_PBITS_TABLE = 0,997AL_ETH_CTRL_TABLE_PRIO_SEL_DSCP_TABLE = 1,998AL_ETH_CTRL_TABLE_PRIO_SEL_TC_TABLE = 2,999AL_ETH_CTRL_TABLE_PRIO_SEL_REG1 = 3,1000AL_ETH_CTRL_TABLE_PRIO_SEL_REG2 = 4,1001AL_ETH_CTRL_TABLE_PRIO_SEL_REG3 = 5,1002AL_ETH_CTRL_TABLE_PRIO_SEL_REG4 = 6,1003AL_ETH_CTRL_TABLE_PRIO_SEL_REG5 = 7,1004AL_ETH_CTRL_TABLE_PRIO_SEL_REG6 = 7,1005AL_ETH_CTRL_TABLE_PRIO_SEL_REG7 = 9,1006AL_ETH_CTRL_TABLE_PRIO_SEL_REG8 = 10,1007AL_ETH_CTRL_TABLE_PRIO_SEL_VAL_3 = 11,1008AL_ETH_CTRL_TABLE_PRIO_SEL_VAL_0 = 12,1009};1010/** where to select the initial queue from */1011enum AL_ETH_CTRL_TABLE_QUEUE_SEL_1 {1012AL_ETH_CTRL_TABLE_QUEUE_SEL_1_PRIO_TABLE = 0,1013AL_ETH_CTRL_TABLE_QUEUE_SEL_1_THASH_TABLE = 1,1014AL_ETH_CTRL_TABLE_QUEUE_SEL_1_MAC_TABLE = 2,1015AL_ETH_CTRL_TABLE_QUEUE_SEL_1_MHASH_TABLE = 3,1016AL_ETH_CTRL_TABLE_QUEUE_SEL_1_REG1 = 4,1017AL_ETH_CTRL_TABLE_QUEUE_SEL_1_REG2 = 5,1018AL_ETH_CTRL_TABLE_QUEUE_SEL_1_REG3 = 6,1019AL_ETH_CTRL_TABLE_QUEUE_SEL_1_REG4 = 7,1020AL_ETH_CTRL_TABLE_QUEUE_SEL_1_VAL_3 = 12,1021AL_ETH_CTRL_TABLE_QUEUE_SEL_1_VAL_0 = 13,1022};10231024/** target queue will be built up from the priority and initial queue */1025enum AL_ETH_CTRL_TABLE_QUEUE_SEL_2 {1026AL_ETH_CTRL_TABLE_QUEUE_SEL_2_PRIO_TABLE = 0, /**< target queue is the output of priority table */1027AL_ETH_CTRL_TABLE_QUEUE_SEL_2_PRIO = 1, /**< target queue is the priority */1028AL_ETH_CTRL_TABLE_QUEUE_SEL_2_PRIO_QUEUE = 2, /**< target queue is initial queue[0], priority[1] */1029AL_ETH_CTRL_TABLE_QUEUE_SEL_2_NO_PRIO = 3, /**< target queue is the initial */1030};10311032enum AL_ETH_CTRL_TABLE_UDMA_SEL {1033AL_ETH_CTRL_TABLE_UDMA_SEL_THASH_TABLE = 0,1034AL_ETH_CTRL_TABLE_UDMA_SEL_THASH_AND_VLAN = 1,1035AL_ETH_CTRL_TABLE_UDMA_SEL_VLAN_TABLE = 2,1036AL_ETH_CTRL_TABLE_UDMA_SEL_VLAN_AND_MAC = 3,1037AL_ETH_CTRL_TABLE_UDMA_SEL_MAC_TABLE = 4,1038AL_ETH_CTRL_TABLE_UDMA_SEL_MAC_AND_MHASH = 5,1039AL_ETH_CTRL_TABLE_UDMA_SEL_MHASH_TABLE = 6,1040AL_ETH_CTRL_TABLE_UDMA_SEL_REG1 = 7,1041AL_ETH_CTRL_TABLE_UDMA_SEL_REG2 = 8,1042AL_ETH_CTRL_TABLE_UDMA_SEL_REG3 = 9,1043AL_ETH_CTRL_TABLE_UDMA_SEL_REG4 = 10,1044AL_ETH_CTRL_TABLE_UDMA_SEL_REG5 = 11,1045AL_ETH_CTRL_TABLE_UDMA_SEL_REG6 = 12,1046AL_ETH_CTRL_TABLE_UDMA_SEL_REG7 = 13,1047AL_ETH_CTRL_TABLE_UDMA_SEL_REG8 = 14,1048AL_ETH_CTRL_TABLE_UDMA_SEL_VAL_0 = 15,1049};10501051enum AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL {1052AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_0 = 0,1053AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_REG = 1, /**< select header len from the hdr_split register (set by al_eth_rx_header_split_config())*/1054AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_OUTER_L3_OFFSET = 2,1055AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_OUTER_L4_OFFSET = 3,1056AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_TUNNEL_START_OFFSET = 4,1057AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_INNER_L3_OFFSET = 5,1058AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL_INNER_L4_OFFSET = 6,1059};10601061struct al_eth_fwd_ctrl_table_entry {1062enum AL_ETH_CTRL_TABLE_PRIO_SEL prio_sel;1063enum AL_ETH_CTRL_TABLE_QUEUE_SEL_1 queue_sel_1; /**< queue id source */1064enum AL_ETH_CTRL_TABLE_QUEUE_SEL_2 queue_sel_2; /**< mix queue id with priority */1065enum AL_ETH_CTRL_TABLE_UDMA_SEL udma_sel;1066enum AL_ETH_CTRL_TABLE_HDR_SPLIT_LEN_SEL hdr_split_len_sel;1067al_bool filter; /**< set to AL_TRUE to enable filtering */1068};1069/**1070* Configure default control table entry1071*1072* @param adapter pointer to the private structure1073* @param use_table set to AL_TRUE if control table is used, when set to AL_FALSE1074* then control table will be bypassed and the entry value will be used.1075* @param entry defines the value to be used when bypassing control table.1076*1077* @return 0 on success. otherwise on failure.1078*/1079int al_eth_ctrl_table_def_set(struct al_hal_eth_adapter *adapter,1080al_bool use_table,1081struct al_eth_fwd_ctrl_table_entry *entry);10821083/**1084* Configure control table entry1085*1086* @param adapter pointer to the private structure1087* @param index the entry index within the control table.1088* @param entry the value to write to the control table entry1089*1090* @return 0 on success. otherwise on failure.1091*/1092int al_eth_ctrl_table_set(struct al_hal_eth_adapter *adapter,1093struct al_eth_fwd_ctrl_table_index *index,1094struct al_eth_fwd_ctrl_table_entry *entry);10951096int al_eth_ctrl_table_raw_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint32_t entry);1097int al_eth_ctrl_table_def_raw_set(struct al_hal_eth_adapter *adapter, uint32_t val);10981099/**1100* Configure hash key initial registers1101* Those registers define the initial key values, those values used for1102* the THASH and MHASH hash functions.1103*1104* @param adapter pointer to the private structure1105* @param idx the register index1106* @param val the register value1107*1108* @return 0 on success. otherwise on failure.1109*/1110int al_eth_hash_key_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint32_t val);11111112struct al_eth_fwd_mac_table_entry {1113uint8_t addr[6]; /**< byte 0 is the first byte seen on the wire */1114uint8_t mask[6];1115al_bool tx_valid;1116uint8_t tx_target;1117al_bool rx_valid;1118uint8_t udma_mask; /**< target udma */1119uint8_t qid; /**< target queue */1120al_bool filter; /**< set to AL_TRUE to enable filtering */1121};11221123/**1124* Configure mac table entry1125* The HW traverse this table and looks for match from lowest index,1126* when the packets MAC DA & mask == addr, and the valid bit is set, then match occurs.1127*1128* @param adapter pointer to the private structure1129* @param idx the entry index within the mac table.1130* @param entry the contents of the MAC table entry1131*1132* @return 0 on success. otherwise on failure.1133*/1134int al_eth_fwd_mac_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx,1135struct al_eth_fwd_mac_table_entry *entry);11361137int al_eth_fwd_mac_addr_raw_set(struct al_hal_eth_adapter *adapter, uint32_t idx,1138uint32_t addr_lo, uint32_t addr_hi, uint32_t mask_lo, uint32_t mask_hi);1139int al_eth_fwd_mac_ctrl_raw_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint32_t ctrl);11401141int al_eth_mac_addr_store(void * __iomem ec_base, uint32_t idx, uint8_t *addr);1142int al_eth_mac_addr_read(void * __iomem ec_base, uint32_t idx, uint8_t *addr);11431144/**1145* Configure pbits table entry1146* The HW uses this table to translate between vlan pbits field to priority.1147* The vlan pbits is used as the index of this table.1148*1149* @param adapter pointer to the private structure1150* @param idx the entry index within the table.1151* @param prio the priority to set for this entry1152*1153* @return 0 on success. otherwise on failure.1154*/1155int al_eth_fwd_pbits_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint8_t prio);11561157/**1158* Configure priority table entry1159* The HW uses this table to translate between priority to queue index.1160* The priority is used as the index of this table.1161*1162* @param adapter pointer to the private structure1163* @param prio the entry index within the table.1164* @param qid the queue index to set for this entry (priority).1165*1166* @return 0 on success. otherwise on failure.1167*/1168int al_eth_fwd_priority_table_set(struct al_hal_eth_adapter *adapter, uint8_t prio, uint8_t qid);11691170/**1171* Configure DSCP table entry1172* The HW uses this table to translate between IPv4 DSCP field to priority.1173* The IPv4 byte 1 (DSCP+ECN) used as index to this table.1174*1175* @param adapter pointer to the private structure1176* @param idx the entry index within the table.1177* @param prio the queue index to set for this entry (priority).1178*1179* @return 0 on success. otherwise on failure.1180*/1181int al_eth_fwd_dscp_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint8_t prio);11821183/**1184* Configure TC table entry1185* The HW uses this table to translate between IPv6 TC field to priority.1186* The IPv6 TC used as index to this table.1187*1188* @param adapter pointer to the private structure1189* @param idx the entry index within the table.1190* @param prio the queue index to set for this entry (priority).1191*1192* @return 0 on success. otherwise on failure.1193*/1194int al_eth_fwd_tc_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint8_t prio);11951196/**1197* Configure MAC HASH table entry1198* The HW uses 8 bits from the hash result on the MAC DA as index to this table.1199*1200* @param adapter pointer to the private structure1201* @param idx the entry index within the table.1202* @param udma_mask the target udma to set for this entry.1203* @param qid the target queue index to set for this entry.1204*1205* @return 0 on success. otherwise on failure.1206*/1207int al_eth_fwd_mhash_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint8_t udma_mask, uint8_t qid);12081209struct al_eth_fwd_vid_table_entry {1210uint8_t control:1; /**< used as input for the control table */1211uint8_t filter:1; /**< set to 1 to enable filtering */1212uint8_t udma_mask:4; /**< target udmas */1213};12141215/**1216* Configure default vlan table entry1217*1218* @param adapter pointer to the private structure1219* @param use_table set to AL_TRUE if vlan table is used, when set to AL_FALSE1220* then vid table will be bypassed and the default_entry value will be used.1221* @param default_entry defines the value to be used when bypassing vid table.1222* @param default_vlan defines the value will be used when untagget packet1223* received. this value will be used only for steering and filtering control,1224* the packet's data will not be changed.1225*1226* @return 0 on success. otherwise on failure.1227*/1228int al_eth_fwd_vid_config_set(struct al_hal_eth_adapter *adapter, al_bool use_table,1229struct al_eth_fwd_vid_table_entry *default_entry,1230uint32_t default_vlan);1231/**1232* Configure vlan table entry1233*1234* @param adapter pointer to the private structure1235* @param idx the entry index within the vlan table. The HW uses the vlan id1236* field of the packet when accessing this table.1237* @param entry the value to write to the vlan table entry1238*1239* @return 0 on success. otherwise on failure.1240*/1241int al_eth_fwd_vid_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx,1242struct al_eth_fwd_vid_table_entry *entry);124312441245/**1246* Configure default UDMA register1247* When the control table entry udma selection set to AL_ETH_CTRL_TABLE_UDMA_SEL_REG<n>,1248* then the target UDMA will be set according to the register n of the default1249* UDMA registers.1250*1251* @param adapter pointer to the private structure1252* @param idx the index of the default register.1253* @param udma_mask the value of the register.1254*1255* @return 0 on success. otherwise on failure.1256*/1257int al_eth_fwd_default_udma_config(struct al_hal_eth_adapter *adapter, uint32_t idx,1258uint8_t udma_mask);12591260/**1261* Configure default queue register1262* When the control table entry queue selection 1 set to AL_ETH_CTRL_TABLE_QUEUE_SEL_1_REG<n>,1263* then the target queue will be set according to the register n of the default1264* queue registers.1265*1266* @param adapter pointer to the private structure1267* @param idx the index of the default register.1268* @param qid the value of the register.1269*1270* @return 0 on success. otherwise on failure.1271*/1272int al_eth_fwd_default_queue_config(struct al_hal_eth_adapter *adapter, uint32_t idx,1273uint8_t qid);12741275/**1276* Configure default priority register1277* When the control table entry queue selection 1 set to AL_ETH_CTRL_TABLE_PRIO_SEL_1_REG<n>,1278* then the target priority will be set according to the register n of the default1279* priority registers.1280*1281* @param adapter pointer to the private structure1282* @param idx the index of the default register.1283* @param prio the value of the register.1284*1285* @return 0 on success. otherwise on failure.1286*/1287int al_eth_fwd_default_priority_config(struct al_hal_eth_adapter *adapter, uint32_t idx,1288uint8_t prio);1289129012911292/* filter undetected MAC DA */1293#define AL_ETH_RFW_FILTER_UNDET_MAC (1 << 0)1294/* filter specific MAC DA based on MAC table output */1295#define AL_ETH_RFW_FILTER_DET_MAC (1 << 1)1296/* filter all tagged */1297#define AL_ETH_RFW_FILTER_TAGGED (1 << 2)1298/* filter all untagged */1299#define AL_ETH_RFW_FILTER_UNTAGGED (1 << 3)1300/* filter all broadcast */1301#define AL_ETH_RFW_FILTER_BC (1 << 4)1302/* filter all multicast */1303#define AL_ETH_RFW_FILTER_MC (1 << 5)1304/* filter packet based on parser drop */1305#define AL_ETH_RFW_FILTER_PARSE (1 << 6)1306/* filter packet based on VLAN table output */1307#define AL_ETH_RFW_FILTER_VLAN_VID (1 << 7)1308/* filter packet based on control table output */1309#define AL_ETH_RFW_FILTER_CTRL_TABLE (1 << 8)1310/* filter packet based on protocol index */1311#define AL_ETH_RFW_FILTER_PROT_INDEX (1 << 9)1312/* filter packet based on WoL decision */1313#define AL_ETH_RFW_FILTER_WOL (1 << 10)131413151316struct al_eth_filter_params {1317al_bool enable;1318uint32_t filters; /**< bitmask of AL_ETH_RFW_FILTER.. for filters to enable */1319al_bool filter_proto[AL_ETH_PROTOCOLS_NUM]; /**< set AL_TRUE for protocols to filter */1320};13211322struct al_eth_filter_override_params {1323uint32_t filters; /**< bitmask of AL_ETH_RFW_FILTER.. for filters to override */1324uint8_t udma; /**< target udma id */1325uint8_t qid; /**< target queue id */1326};13271328/**1329* Configure the receive filters1330* this function enables/disables filtering packets and which filtering1331* types to apply.1332* filters that indicated in tables (MAC table, VLAN and Control tables)1333* are not configured by this function. This functions only enables/disables1334* respecting the filter indication from those tables.1335*1336* @param adapter pointer to the private structure1337* @param params the parameters passed from upper layer1338*1339* @return 0 on success. otherwise on failure.1340*/1341int al_eth_filter_config(struct al_hal_eth_adapter *adapter, struct al_eth_filter_params *params);13421343/**1344* Configure the receive override filters1345* This function controls whither to force forwarding filtered packets1346* to a specific UDMA/queue. The override filters apply only for1347* filters that enabled by al_eth_filter_config().1348*1349* @param adapter pointer to the private structure1350* @param params override config parameters1351*1352* @return 0 on success. otherwise on failure.1353*/1354int al_eth_filter_override_config(struct al_hal_eth_adapter *adapter,1355struct al_eth_filter_override_params *params);135613571358int al_eth_switching_config_set(struct al_hal_eth_adapter *adapter, uint8_t udma_id, uint8_t forward_all_to_mac, uint8_t enable_int_switching,1359enum al_eth_tx_switch_vid_sel_type vid_sel_type,1360enum al_eth_tx_switch_dec_type uc_dec,1361enum al_eth_tx_switch_dec_type mc_dec,1362enum al_eth_tx_switch_dec_type bc_dec);1363int al_eth_switching_default_bitmap_set(struct al_hal_eth_adapter *adapter, uint8_t udma_id, uint8_t udma_uc_bitmask,1364uint8_t udma_mc_bitmask,uint8_t udma_bc_bitmask);1365int al_eth_flow_control_config(struct al_hal_eth_adapter *adapter, struct al_eth_flow_control_params *params);13661367struct al_eth_eee_params{1368uint8_t enable;1369uint32_t tx_eee_timer; /**< time in cycles the interface delays prior to entering eee state */1370uint32_t min_interval; /**< minimum interval in cycles between two eee states */1371uint32_t stop_cnt; /**< time in cycles to stop Tx mac i/f after getting out of eee state */1372al_bool fast_wake; /**< fast_wake is only applicable to 40/50G, otherwise the mode is deep_sleep */1373};13741375/**1376* configure EEE mode1377* @param adapter pointer to the private structure.1378* @param params pointer to the eee input parameters.1379*1380* @return return 0 on success. otherwise on failure.1381*/1382int al_eth_eee_config(struct al_hal_eth_adapter *adapter, struct al_eth_eee_params *params);13831384/**1385* get EEE configuration1386* @param adapter pointer to the private structure.1387* @param params pointer to the eee output parameters.1388*1389* @return return 0 on success. otherwise on failure.1390*/1391int al_eth_eee_get(struct al_hal_eth_adapter *adapter, struct al_eth_eee_params *params);13921393int al_eth_vlan_mod_config(struct al_hal_eth_adapter *adapter, uint8_t udma_id, uint16_t udma_etype, uint16_t vlan1_data, uint16_t vlan2_data);13941395/* Timestamp1396* This is a generic time-stamp mechanism that can be used as generic to1397* time-stamp every received or transmit packet it can also support IEEE 1588v21398* PTP time synchronization protocol.1399* In addition to time-stamp, an internal system time is maintained. For1400* further accuracy, the chip support transmit/receive clock synchronization1401* including recovery of master clock from one of the ports and distributing it1402* to the rest of the ports - that is outside the scope of the Ethernet1403* Controller - please refer to Annapurna Labs Alpine Hardware Wiki1404*/14051406/* Timestamp management APIs */14071408/**1409* prepare the adapter for timestamping packets.1410* Rx timestamps requires using 8 words (8x4 bytes) rx completion descriptor1411* size as the timestamp value added into word 4.1412*1413* This function should be called after al_eth_mac_config() and before1414* enabling the queues.1415* @param adapter pointer to the private structure.1416* @return 0 on success. otherwise on failure.1417*/1418int al_eth_ts_init(struct al_hal_eth_adapter *adapter);14191420/* Timestamp data path APIs */14211422/*1423* This is the size of the on-chip array that keeps the time-stamp of the1424* latest transmitted packets1425*/1426#define AL_ETH_PTH_TX_SAMPLES_NUM 1614271428/**1429* read Timestamp sample value of previously transmitted packet.1430*1431* The adapter includes AL_ETH_PTH_TX_SAMPLES_NUM timestamp samples for tx1432* packets, those samples shared for all the UDMAs and queues. the al_eth_pkt1433* data structure includes the index of which sample to use for the packet1434* to transmit. It's the caller's responsibility to manage those samples,1435* for example, when using an index, the caller must make sure the packet1436* is completed and the tx time is sampled before using that index for1437* another packet.1438*1439* This function should be called after the completion indication of the1440* tx packet. however, there is a little chance that the timestamp sample1441* won't be updated yet, thus this function must be called again when it1442* returns -EAGAIN.1443* @param adapter pointer to the private structure.1444* @param ts_index the index (out of 16) of the timestamp register1445* @param timestamp the timestamp value in 2^18 femtoseconds resolution.1446* @return -EAGAIN if the sample was not updated yet. 0 when the sample1447* was updated and no errors found.1448*/1449int al_eth_tx_ts_val_get(struct al_hal_eth_adapter *adapter, uint8_t ts_index,1450uint32_t *timestamp);14511452/* Timestamp PTH (PTP Timestamp Handler) control and times management */1453/** structure for describing PTH epoch time */1454struct al_eth_pth_time {1455uint32_t seconds; /**< seconds */1456uint64_t femto; /**< femto seconds */1457};14581459/**1460* Read the systime value1461* This API should not be used to get the timestamp of packets.1462* The HW maintains 50 bits for the sub-seconds portion in femto resolution,1463* but this function reads only the 32 MSB bits since the LSB provides1464* sub-nanoseconds accuracy, which is not needed.1465* @param adapter pointer to the private structure.1466* @param systime pointer to structure where the time will be stored.1467* @return 0 on success. otherwise on failure.1468*/1469int al_eth_pth_systime_read(struct al_hal_eth_adapter *adapter,1470struct al_eth_pth_time *systime);14711472/**1473* Set the clock period to a given value.1474* The systime will be incremented by this value on each posedge of the1475* adapters internal clock which driven by the SouthBridge clock.1476* @param adapter pointer to the private structure.1477* @param clk_period the clock period in femto seconds.1478* @return 0 on success. otherwise on failure.1479*/1480int al_eth_pth_clk_period_write(struct al_hal_eth_adapter *adapter,1481uint64_t clk_period);14821483/**< enum for methods when updating systime using triggers */1484enum al_eth_pth_update_method {1485AL_ETH_PTH_UPDATE_METHOD_SET = 0, /**< Set the time in int/ext update time */1486AL_ETH_PTH_UPDATE_METHOD_INC = 1, /**< increment */1487AL_ETH_PTH_UPDATE_METHOD_DEC = 2, /**< decrement */1488AL_ETH_PTH_UPDATE_METHOD_ADD_TO_LAST = 3, /**< Set to last time + int/ext update time.*/1489};14901491/**< systime internal update trigger types */1492enum al_eth_pth_int_trig {1493AL_ETH_PTH_INT_TRIG_OUT_PULSE_0 = 0, /**< use output pulse as trigger */1494AL_ETH_PTH_INT_TRIG_REG_WRITE = 1, /**< use the int update register1495* write as a trigger1496*/1497};14981499/**< parameters for internal trigger update */1500struct al_eth_pth_int_update_params {1501al_bool enable; /**< enable internal trigger update */1502enum al_eth_pth_update_method method; /**< internal trigger update1503* method1504*/1505enum al_eth_pth_int_trig trigger; /**< which internal trigger to1506* use1507*/1508};15091510/**1511* Configure the systime internal update1512*1513* @param adapter pointer to the private structure.1514* @param params the configuration of the internal update.1515* @return 0 on success. otherwise on failure.1516*/1517int al_eth_pth_int_update_config(struct al_hal_eth_adapter *adapter,1518struct al_eth_pth_int_update_params *params);15191520/**1521* set internal update time1522*1523* The update time used when updating the systime with1524* internal update method.1525*1526* @param adapter pointer to the private structure.1527* @param time the internal update time value1528* @return 0 on success. otherwise on failure.1529*/1530int al_eth_pth_int_update_time_set(struct al_hal_eth_adapter *adapter,1531struct al_eth_pth_time *time);15321533/**< parameters for external trigger update */1534struct al_eth_pth_ext_update_params {1535uint8_t triggers; /**< bitmask of external triggers to enable */1536enum al_eth_pth_update_method method; /**< external trigger update1537* method1538*/1539};15401541/**1542* Configure the systime external update.1543* external update triggered by external signals such as GPIO or pulses1544* from other eth controllers on the SoC.1545*1546* @param adapter pointer to the private structure.1547* @param params the configuration of the external update.1548* @return 0 on success. otherwise on failure.1549*/1550int al_eth_pth_ext_update_config(struct al_hal_eth_adapter *adapter,1551struct al_eth_pth_ext_update_params *params);15521553/**1554* set external update time1555*1556* The update time used when updating the systime with1557* external update method.1558* @param adapter pointer to the private structure.1559* @param time the external update time value1560* @return 0 on success. otherwise on failure.1561*/1562int al_eth_pth_ext_update_time_set(struct al_hal_eth_adapter *adapter,1563struct al_eth_pth_time *time);1564/**1565* set the read compensation delay1566*1567* When reading the systime, the HW adds this value to compensate1568* read latency.1569*1570* @param adapter pointer to the private structure.1571* @param subseconds the read latency delay in femto seconds.1572* @return 0 on success. otherwise on failure.1573*/1574int al_eth_pth_read_compensation_set(struct al_hal_eth_adapter *adapter,1575uint64_t subseconds);1576/**1577* set the internal write compensation delay1578*1579* When updating the systime due to an internal trigger's event, the HW adds1580* this value to compensate latency.1581*1582* @param adapter pointer to the private structure.1583* @param subseconds the write latency delay in femto seconds.1584* @return 0 on success. otherwise on failure.1585*/1586int al_eth_pth_int_write_compensation_set(struct al_hal_eth_adapter *adapter,1587uint64_t subseconds);15881589/**1590* set the external write compensation delay1591*1592* When updating the systime due to an external trigger's event, the HW adds1593* this value to compensate pulse propagation latency.1594*1595* @param adapter pointer to the private structure.1596* @param subseconds the write latency delay in femto seconds.1597* @return 0 on success. otherwise on failure.1598*/1599int al_eth_pth_ext_write_compensation_set(struct al_hal_eth_adapter *adapter,1600uint64_t subseconds);16011602/**1603* set the sync compensation delay1604*1605* When the adapter passes systime from PTH to MAC to do the packets1606* timestamping, the sync compensation delay is added to systime value to1607* compensate the latency between the PTH and the MAC.1608*1609* @param adapter pointer to the private structure.1610* @param subseconds the sync latency delay in femto seconds.1611* @return 0 on success. otherwise on failure.1612*/1613int al_eth_pth_sync_compensation_set(struct al_hal_eth_adapter *adapter,1614uint64_t subseconds);16151616#define AL_ETH_PTH_PULSE_OUT_NUM 81617struct al_eth_pth_pulse_out_params {1618uint8_t index; /**< id of the pulse (0..7) */1619al_bool enable;1620al_bool periodic; /**< when true, generate periodic pulse (PPS) */1621uint8_t period_sec; /**< for periodic pulse, this is seconds1622* portion of the period time1623*/1624uint32_t period_us; /**< this is microseconds portion of the1625* period1626*/1627struct al_eth_pth_time start_time; /**< when to start pulse triggering */1628uint64_t pulse_width; /**< pulse width in femto seconds */1629};16301631/**1632* Configure an output pulse1633* This function configures an output pulse coming from the internal System1634* Time. This is typically a 1Hhz pulse that is used to synchronize the1635* rest of the components of the system. This API configure the Ethernet1636* Controller pulse. An additional set up is required to configure the chip1637* General Purpose I/O (GPIO) to enable the chip output pin.1638*1639* @param adapter pointer to the private structure.1640* @param params output pulse configuration.1641* @return 0 on success. otherwise on failure.1642*/1643int al_eth_pth_pulse_out_config(struct al_hal_eth_adapter *adapter,1644struct al_eth_pth_pulse_out_params *params);16451646/* link */1647struct al_eth_link_status {1648al_bool link_up;1649al_bool local_fault;1650al_bool remote_fault;1651};16521653/**1654* get link status1655*1656* this function should be used when no external phy is used to get1657* information about the link1658*1659* @param adapter pointer to the private structure.1660* @param status pointer to struct where to set link information1661*1662* @return return 0 on success. otherwise on failure.1663*/1664int al_eth_link_status_get(struct al_hal_eth_adapter *adapter,1665struct al_eth_link_status *status);16661667/**1668* clear link status1669*1670* this function clear latched status of the link.1671*1672* @param adapter pointer to the private structure.1673*1674* @return return 0 if supported.1675*/1676int al_eth_link_status_clear(struct al_hal_eth_adapter *adapter);16771678/**1679* Set LEDs to represent link status.1680*1681* @param adapter pointer to the private structure.1682* @param link_is_up boolean indicating current link status.1683* In case link is down the leds will be turned off.1684* In case link is up the leds will be turned on, that means1685* leds will be blinking on traffic and will be constantly lighting1686* on inactive link1687* @return return 0 on success. otherwise on failure.1688*/1689int al_eth_led_set(struct al_hal_eth_adapter *adapter, al_bool link_is_up);16901691/* get statistics */16921693struct al_eth_mac_stats{1694/* sum the data and padding octets (i.e. without header and FCS) received with a valid frame. */1695uint64_t aOctetsReceivedOK;1696/* sum of Payload and padding octets of frames transmitted without error*/1697uint64_t aOctetsTransmittedOK;1698/* total number of packets received. Good and bad packets */1699uint32_t etherStatsPkts;1700/* number of received unicast packets */1701uint32_t ifInUcastPkts;1702/* number of received multicast packets */1703uint32_t ifInMulticastPkts;1704/* number of received broadcast packets */1705uint32_t ifInBroadcastPkts;1706/* Number of frames received with FIFO Overflow, CRC, Payload Length, Jabber and Oversized, Alignment or PHY/PCS error indication */1707uint32_t ifInErrors;17081709/* number of transmitted unicast packets */1710uint32_t ifOutUcastPkts;1711/* number of transmitted multicast packets */1712uint32_t ifOutMulticastPkts;1713/* number of transmitted broadcast packets */1714uint32_t ifOutBroadcastPkts;1715/* number of frames transmitted with FIFO Overflow, FIFO Underflow or Controller indicated error */1716uint32_t ifOutErrors;17171718/* number of Frame received without error (Including Pause Frames). */1719uint32_t aFramesReceivedOK;1720/* number of Frames transmitter without error (Including Pause Frames) */1721uint32_t aFramesTransmittedOK;1722/* number of packets received with less than 64 octets */1723uint32_t etherStatsUndersizePkts;1724/* Too short frames with CRC error, available only for RGMII and 1G Serial modes */1725uint32_t etherStatsFragments;1726/* Too long frames with CRC error */1727uint32_t etherStatsJabbers;1728/* packet that exceeds the valid maximum programmed frame length */1729uint32_t etherStatsOversizePkts;1730/* number of frames received with a CRC error */1731uint32_t aFrameCheckSequenceErrors;1732/* number of frames received with alignment error */1733uint32_t aAlignmentErrors;1734/* number of dropped packets due to FIFO overflow */1735uint32_t etherStatsDropEvents;1736/* number of transmitted pause frames. */1737uint32_t aPAUSEMACCtrlFramesTransmitted;1738/* number of received pause frames. */1739uint32_t aPAUSEMACCtrlFramesReceived;1740/* frame received exceeded the maximum length programmed with register FRM_LGTH, available only for 10G modes */1741uint32_t aFrameTooLongErrors;1742/* received frame with bad length/type (between 46 and 0x600 or less1743* than 46 for packets longer than 64), available only for 10G modes */1744uint32_t aInRangeLengthErrors;1745/* Valid VLAN tagged frames transmitted */1746uint32_t VLANTransmittedOK;1747/* Valid VLAN tagged frames received */1748uint32_t VLANReceivedOK;1749/* Total number of octets received. Good and bad packets */1750uint32_t etherStatsOctets;17511752/* packets of 64 octets length is received (good and bad frames are counted) */1753uint32_t etherStatsPkts64Octets;1754/* Frames (good and bad) with 65 to 127 octets */1755uint32_t etherStatsPkts65to127Octets;1756/* Frames (good and bad) with 128 to 255 octets */1757uint32_t etherStatsPkts128to255Octets;1758/* Frames (good and bad) with 256 to 511 octets */1759uint32_t etherStatsPkts256to511Octets;1760/* Frames (good and bad) with 512 to 1023 octets */1761uint32_t etherStatsPkts512to1023Octets;1762/* Frames (good and bad) with 1024 to 1518 octets */1763uint32_t etherStatsPkts1024to1518Octets;1764/* frames with 1519 bytes to the maximum length programmed in the register FRAME_LENGTH. */1765uint32_t etherStatsPkts1519toX;17661767uint32_t eee_in;1768uint32_t eee_out;1769};17701771/**1772* get mac statistics1773* @param adapter pointer to the private structure.1774* @param stats pointer to structure that will be filled with statistics.1775*1776* @return return 0 on success. otherwise on failure.1777*/1778int al_eth_mac_stats_get(struct al_hal_eth_adapter *adapter, struct al_eth_mac_stats *stats);17791780struct al_eth_ec_stats{1781/* Rx Frequency adjust FIFO input packets */1782uint32_t faf_in_rx_pkt;1783/* Rx Frequency adjust FIFO input short error packets */1784uint32_t faf_in_rx_short;1785/* Rx Frequency adjust FIFO input long error packets */1786uint32_t faf_in_rx_long;1787/* Rx Frequency adjust FIFO output packets */1788uint32_t faf_out_rx_pkt;1789/* Rx Frequency adjust FIFO output short error packets */1790uint32_t faf_out_rx_short;1791/* Rx Frequency adjust FIFO output long error packets */1792uint32_t faf_out_rx_long;1793/* Rx Frequency adjust FIFO output drop packets */1794uint32_t faf_out_drop;1795/* Number of packets written into the Rx FIFO (without FIFO error indication) */1796uint32_t rxf_in_rx_pkt;1797/* Number of error packets written into the Rx FIFO (with FIFO error indication, */1798/* FIFO full indication during packet reception) */1799uint32_t rxf_in_fifo_err;1800/* Number of packets read from Rx FIFO 1 */1801uint32_t lbf_in_rx_pkt;1802/* Number of packets read from Rx FIFO 2 (loopback FIFO) */1803uint32_t lbf_in_fifo_err;1804/* Rx FIFO output drop packets from FIFO 1 */1805uint32_t rxf_out_rx_1_pkt;1806/* Rx FIFO output drop packets from FIFO 2 (loop back) */1807uint32_t rxf_out_rx_2_pkt;1808/* Rx FIFO output drop packets from FIFO 1 */1809uint32_t rxf_out_drop_1_pkt;1810/* Rx FIFO output drop packets from FIFO 2 (loop back) */1811uint32_t rxf_out_drop_2_pkt;1812/* Rx Parser 1, input packet counter */1813uint32_t rpe_1_in_rx_pkt;1814/* Rx Parser 1, output packet counter */1815uint32_t rpe_1_out_rx_pkt;1816/* Rx Parser 2, input packet counter */1817uint32_t rpe_2_in_rx_pkt;1818/* Rx Parser 2, output packet counter */1819uint32_t rpe_2_out_rx_pkt;1820/* Rx Parser 3 (MACsec), input packet counter */1821uint32_t rpe_3_in_rx_pkt;1822/* Rx Parser 3 (MACsec), output packet counter */1823uint32_t rpe_3_out_rx_pkt;1824/* Tx parser, input packet counter */1825uint32_t tpe_in_tx_pkt;1826/* Tx parser, output packet counter */1827uint32_t tpe_out_tx_pkt;1828/* Tx packet modification, input packet counter */1829uint32_t tpm_tx_pkt;1830/* Tx forwarding input packet counter */1831uint32_t tfw_in_tx_pkt;1832/* Tx forwarding input packet counter */1833uint32_t tfw_out_tx_pkt;1834/* Rx forwarding input packet counter */1835uint32_t rfw_in_rx_pkt;1836/* Rx Forwarding, packet with VLAN command drop indication */1837uint32_t rfw_in_vlan_drop;1838/* Rx Forwarding, packets with parse drop indication */1839uint32_t rfw_in_parse_drop;1840/* Rx Forwarding, multicast packets */1841uint32_t rfw_in_mc;1842/* Rx Forwarding, broadcast packets */1843uint32_t rfw_in_bc;1844/* Rx Forwarding, tagged packets */1845uint32_t rfw_in_vlan_exist;1846/* Rx Forwarding, untagged packets */1847uint32_t rfw_in_vlan_nexist;1848/* Rx Forwarding, packets with MAC address drop indication (from the MAC address table) */1849uint32_t rfw_in_mac_drop;1850/* Rx Forwarding, packets with undetected MAC address */1851uint32_t rfw_in_mac_ndet_drop;1852/* Rx Forwarding, packets with drop indication from the control table */1853uint32_t rfw_in_ctrl_drop;1854/* Rx Forwarding, packets with L3_protocol_index drop indication */1855uint32_t rfw_in_prot_i_drop;1856/* EEE, number of times the system went into EEE state */1857uint32_t eee_in;1858};18591860/**1861* get ec statistics1862* @param adapter pointer to the private structure.1863* @param stats pointer to structure that will be filled with statistics.1864*1865* @return return 0 on success. otherwise on failure.1866*/1867int al_eth_ec_stats_get(struct al_hal_eth_adapter *adapter, struct al_eth_ec_stats *stats);18681869struct al_eth_ec_stat_udma{1870/* Rx forwarding output packet counter */1871uint32_t rfw_out_rx_pkt;1872/* Rx forwarding output drop packet counter */1873uint32_t rfw_out_drop;1874/* Multi-stream write, number of Rx packets */1875uint32_t msw_in_rx_pkt;1876/* Multi-stream write, number of dropped packets at SOP, Q full indication */1877uint32_t msw_drop_q_full;1878/* Multi-stream write, number of dropped packets at SOP */1879uint32_t msw_drop_sop;1880/* Multi-stream write, number of dropped packets at EOP, */1881/*EOP was written with error indication (not all packet data was written) */1882uint32_t msw_drop_eop;1883/* Multi-stream write, number of packets written to the stream FIFO with EOP and without packet loss */1884uint32_t msw_wr_eop;1885/* Multi-stream write, number of packets read from the FIFO into the stream */1886uint32_t msw_out_rx_pkt;1887/* Number of transmitted packets without TSO enabled */1888uint32_t tso_no_tso_pkt;1889/* Number of transmitted packets with TSO enabled */1890uint32_t tso_tso_pkt;1891/* Number of TSO segments that were generated */1892uint32_t tso_seg_pkt;1893/* Number of TSO segments that required padding */1894uint32_t tso_pad_pkt;1895/* Tx Packet modification, MAC SA spoof error */1896uint32_t tpm_tx_spoof;1897/* Tx MAC interface, input packet counter */1898uint32_t tmi_in_tx_pkt;1899/* Tx MAC interface, number of packets forwarded to the MAC */1900uint32_t tmi_out_to_mac;1901/* Tx MAC interface, number of packets forwarded to the Rx data path */1902uint32_t tmi_out_to_rx;1903/* Tx MAC interface, number of transmitted bytes */1904uint32_t tx_q0_bytes;1905/* Tx MAC interface, number of transmitted bytes */1906uint32_t tx_q1_bytes;1907/* Tx MAC interface, number of transmitted bytes */1908uint32_t tx_q2_bytes;1909/* Tx MAC interface, number of transmitted bytes */1910uint32_t tx_q3_bytes;1911/* Tx MAC interface, number of transmitted packets */1912uint32_t tx_q0_pkts;1913/* Tx MAC interface, number of transmitted packets */1914uint32_t tx_q1_pkts;1915/* Tx MAC interface, number of transmitted packets */1916uint32_t tx_q2_pkts;1917/* Tx MAC interface, number of transmitted packets */1918uint32_t tx_q3_pkts;1919};19201921/**1922* get per_udma statistics1923* @param adapter pointer to the private structure.1924* @param idx udma_id value1925* @param stats pointer to structure that will be filled with statistics.1926*1927* @return return 0 on success. otherwise on failure.1928*/1929int al_eth_ec_stat_udma_get(struct al_hal_eth_adapter *adapter, uint8_t idx, struct al_eth_ec_stat_udma *stats);19301931/* trafic control */19321933/**1934* perform Function Level Reset RMN1935*1936* Addressing RMN: 7141937*1938* @param pci_read_config_u32 pointer to function that reads register from pci header1939* @param pci_write_config_u32 pointer to function that writes register from pci header1940* @param handle pointer passes to the above functions as first parameter1941* @param mac_base base address of the MAC registers1942*1943* @return 0.1944*/1945int al_eth_flr_rmn(int (* pci_read_config_u32)(void *handle, int where, uint32_t *val),1946int (* pci_write_config_u32)(void *handle, int where, uint32_t val),1947void *handle,1948void __iomem *mac_base);19491950/**1951* perform Function Level Reset RMN but restore registers that contain board specific data1952*1953* the data that save and restored is the board params and mac addresses1954*1955* @param pci_read_config_u32 pointer to function that reads register from pci header1956* @param pci_write_config_u32 pointer to function that writes register from pci header1957* @param handle pointer passes to the above functions as first parameter1958* @param mac_base base address of the MAC registers1959* @param ec_base base address of the Ethernet Controller registers1960* @param mac_addresses_num number of mac addresses to restore1961*1962* @return 0.1963*/1964int al_eth_flr_rmn_restore_params(int (* pci_read_config_u32)(void *handle, int where, uint32_t *val),1965int (* pci_write_config_u32)(void *handle, int where, uint32_t val),1966void *handle,1967void __iomem *mac_base,1968void __iomem *ec_base,1969int mac_addresses_num);19701971/* board specific information (media type, phy address, etc.. */197219731974enum al_eth_board_media_type {1975AL_ETH_BOARD_MEDIA_TYPE_AUTO_DETECT = 0,1976AL_ETH_BOARD_MEDIA_TYPE_RGMII = 1,1977AL_ETH_BOARD_MEDIA_TYPE_10GBASE_SR = 2,1978AL_ETH_BOARD_MEDIA_TYPE_SGMII = 3,1979AL_ETH_BOARD_MEDIA_TYPE_1000BASE_X = 4,1980AL_ETH_BOARD_MEDIA_TYPE_AUTO_DETECT_AUTO_SPEED = 5,1981AL_ETH_BOARD_MEDIA_TYPE_SGMII_2_5G = 6,1982AL_ETH_BOARD_MEDIA_TYPE_NBASE_T = 7,1983AL_ETH_BOARD_MEDIA_TYPE_25G = 8,1984};19851986enum al_eth_board_mdio_freq {1987AL_ETH_BOARD_MDIO_FREQ_2_5_MHZ = 0,1988AL_ETH_BOARD_MDIO_FREQ_1_MHZ = 1,1989};19901991enum al_eth_board_ext_phy_if {1992AL_ETH_BOARD_PHY_IF_MDIO = 0,1993AL_ETH_BOARD_PHY_IF_XMDIO = 1,1994AL_ETH_BOARD_PHY_IF_I2C = 2,19951996};19971998enum al_eth_board_auto_neg_mode {1999AL_ETH_BOARD_AUTONEG_OUT_OF_BAND = 0,2000AL_ETH_BOARD_AUTONEG_IN_BAND = 1,20012002};20032004/* declare the 1G mac active speed when auto negotiation disabled */2005enum al_eth_board_1g_speed {2006AL_ETH_BOARD_1G_SPEED_1000M = 0,2007AL_ETH_BOARD_1G_SPEED_100M = 1,2008AL_ETH_BOARD_1G_SPEED_10M = 2,2009};20102011enum al_eth_retimer_channel {2012AL_ETH_RETIMER_CHANNEL_A = 0,2013AL_ETH_RETIMER_CHANNEL_B = 1,2014AL_ETH_RETIMER_CHANNEL_C = 2,2015AL_ETH_RETIMER_CHANNEL_D = 3,2016AL_ETH_RETIMER_CHANNEL_E = 4,2017AL_ETH_RETIMER_CHANNEL_F = 5,2018AL_ETH_RETIMER_CHANNEL_G = 6,2019AL_ETH_RETIMER_CHANNEL_H = 7,2020AL_ETH_RETIMER_CHANNEL_MAX = 82021};20222023/* list of supported retimers */2024enum al_eth_retimer_type {2025AL_ETH_RETIMER_BR_210 = 0,2026AL_ETH_RETIMER_BR_410 = 1,2027AL_ETH_RETIMER_DS_25 = 2,20282029AL_ETH_RETIMER_TYPE_MAX = 4,2030};20312032/** structure represents the board information. this info set by boot loader2033* and read by OS driver.2034*/2035struct al_eth_board_params {2036enum al_eth_board_media_type media_type;2037al_bool phy_exist; /**< external phy exist */2038uint8_t phy_mdio_addr; /**< mdio address of external phy */2039al_bool sfp_plus_module_exist; /**< SFP+ module connected */2040al_bool autoneg_enable; /**< enable Auto-Negotiation */2041al_bool kr_lt_enable; /**< enable KR Link-Training */2042al_bool kr_fec_enable; /**< enable KR FEC */2043enum al_eth_board_mdio_freq mdio_freq; /**< MDIO frequency */2044uint8_t i2c_adapter_id; /**< identifier for the i2c adapter to use to access SFP+ module */2045enum al_eth_board_ext_phy_if phy_if; /**< phy interface */2046enum al_eth_board_auto_neg_mode an_mode; /**< auto-negotiation mode (in-band / out-of-band) */2047uint8_t serdes_grp; /**< serdes's group id */2048uint8_t serdes_lane; /**< serdes's lane id */2049enum al_eth_ref_clk_freq ref_clk_freq; /**< reference clock frequency */2050al_bool dont_override_serdes; /**< prevent override serdes parameters */2051al_bool force_1000_base_x; /**< set mac to 1000 base-x mode (instead sgmii) */2052al_bool an_disable; /**< disable auto negotiation */2053enum al_eth_board_1g_speed speed; /**< port speed if AN disabled */2054al_bool half_duplex; /**< force half duplex if AN disabled */2055al_bool fc_disable; /**< disable flow control */2056al_bool retimer_exist; /**< retimer is exist on the board */2057uint8_t retimer_bus_id; /**< in what i2c bus the retimer is on */2058uint8_t retimer_i2c_addr; /**< i2c address of the retimer */2059enum al_eth_retimer_channel retimer_channel; /**< what channel connected to this port (Rx) */2060al_bool dac; /**< assume direct attached cable is connected if auto detect is off or failed */2061uint8_t dac_len; /**< assume this cable length if auto detect is off or failed */2062enum al_eth_retimer_type retimer_type; /**< the type of the specific retimer */2063enum al_eth_retimer_channel retimer_tx_channel; /**< what channel connected to this port (Tx) */2064uint8_t gpio_sfp_present; /**< gpio number of sfp present for this port. 0 if not exist */2065};20662067/**2068* set board parameter of the eth port2069* this function used to set the board parameters into scratchpad2070* registers. those paramters can be read later by OS driver.2071*2072* @param mac_base the virtual address of the mac registers (PCI BAR 2)2073* @param params pointer to structure the includes the paramters2074*2075* @return 0 on success. otherwise on failure.2076*/2077int al_eth_board_params_set(void * __iomem mac_base, struct al_eth_board_params *params);20782079/**2080* get board parameter of the eth port2081* this function used to get the board parameters from scratchpad2082* registers.2083*2084* @param mac_base the virtual address of the mac registers (PCI BAR 2)2085* @param params pointer to structure where the parameters will be stored.2086*2087* @return 0 on success. otherwise on failure.2088*/2089int al_eth_board_params_get(void * __iomem mac_base, struct al_eth_board_params *params);20902091/*2092* Wake-On-Lan (WoL)2093*2094* The following few functions configure the Wake-On-Lan packet detection2095* inside the Integrated Ethernet MAC.2096*2097* There are other alternative ways to set WoL, such using the2098* external 1000Base-T transceiver to set WoL mode.2099*2100* These APIs do not set the system-wide power-state, nor responsible on the2101* transition from Sleep to Normal power state.2102*2103* For system level considerations, please refer to Annapurna Labs Alpine Wiki.2104*/2105/* Interrupt enable WoL MAC DA Unicast detected packet */2106#define AL_ETH_WOL_INT_UNICAST AL_BIT(0)2107/* Interrupt enable WoL L2 Multicast detected packet */2108#define AL_ETH_WOL_INT_MULTICAST AL_BIT(1)2109/* Interrupt enable WoL L2 Broadcast detected packet */2110#define AL_ETH_WOL_INT_BROADCAST AL_BIT(2)2111/* Interrupt enable WoL IPv4 detected packet */2112#define AL_ETH_WOL_INT_IPV4 AL_BIT(3)2113/* Interrupt enable WoL IPv6 detected packet */2114#define AL_ETH_WOL_INT_IPV6 AL_BIT(4)2115/* Interrupt enable WoL EtherType+MAC DA detected packet */2116#define AL_ETH_WOL_INT_ETHERTYPE_DA AL_BIT(5)2117/* Interrupt enable WoL EtherType+L2 Broadcast detected packet */2118#define AL_ETH_WOL_INT_ETHERTYPE_BC AL_BIT(6)2119/* Interrupt enable WoL parser detected packet */2120#define AL_ETH_WOL_INT_PARSER AL_BIT(7)2121/* Interrupt enable WoL magic detected packet */2122#define AL_ETH_WOL_INT_MAGIC AL_BIT(8)2123/* Interrupt enable WoL magic+password detected packet */2124#define AL_ETH_WOL_INT_MAGIC_PSWD AL_BIT(9)21252126/* Forward enable WoL MAC DA Unicast detected packet */2127#define AL_ETH_WOL_FWRD_UNICAST AL_BIT(0)2128/* Forward enable WoL L2 Multicast detected packet */2129#define AL_ETH_WOL_FWRD_MULTICAST AL_BIT(1)2130/* Forward enable WoL L2 Broadcast detected packet */2131#define AL_ETH_WOL_FWRD_BROADCAST AL_BIT(2)2132/* Forward enable WoL IPv4 detected packet */2133#define AL_ETH_WOL_FWRD_IPV4 AL_BIT(3)2134/* Forward enable WoL IPv6 detected packet */2135#define AL_ETH_WOL_FWRD_IPV6 AL_BIT(4)2136/* Forward enable WoL EtherType+MAC DA detected packet */2137#define AL_ETH_WOL_FWRD_ETHERTYPE_DA AL_BIT(5)2138/* Forward enable WoL EtherType+L2 Broadcast detected packet */2139#define AL_ETH_WOL_FWRD_ETHERTYPE_BC AL_BIT(6)2140/* Forward enable WoL parser detected packet */2141#define AL_ETH_WOL_FWRD_PARSER AL_BIT(7)21422143struct al_eth_wol_params {2144uint8_t *dest_addr; /**< 6 bytes array of destanation address for2145magic packet detection */2146uint8_t *pswd; /**< 6 bytes array of the password to use */2147uint8_t *ipv4; /**< 4 bytes array of the ipv4 to use.2148example: for ip = 192.168.1.22149ipv4[0]=2, ipv4[1]=1, ipv4[2]=168, ipv4[3]=192 */2150uint8_t *ipv6; /** 16 bytes array of the ipv6 to use.2151example: ip = 2607:f0d0:1002:0051:0000:0000:5231:12342152ipv6[0]=34, ipv6[1]=12, ipv6[2]=31 .. */2153uint16_t ethr_type1; /**< first ethertype to use */2154uint16_t ethr_type2; /**< secound ethertype to use */2155uint16_t forward_mask; /**< bitmask of AL_ETH_WOL_FWRD_* of the packet2156types needed to be forward. */2157uint16_t int_mask; /**< bitmask of AL_ETH_WOL_INT_* of the packet types2158that will send interrupt to wake the system. */2159};21602161/**2162* enable the wol mechanism2163* set what type of packets will wake up the system and what type of packets2164* neet to forward after the system is up2165*2166* beside this function wol filter also need to be set by2167* calling al_eth_filter_config with AL_ETH_RFW_FILTER_WOL2168*2169* @param adapter pointer to the private structure2170* @param wol the parameters needed to configure the wol2171*2172* @return 0 on success. otherwise on failure.2173*/2174int al_eth_wol_enable(2175struct al_hal_eth_adapter *adapter,2176struct al_eth_wol_params *wol);21772178/**2179* Disable the WoL mechnism.2180*2181* @param adapter pointer to the private structure2182*2183* @return 0 on success. otherwise on failure.2184*/2185int al_eth_wol_disable(2186struct al_hal_eth_adapter *adapter);21872188/**2189* Configure tx fwd vlan table entry2190*2191* @param adapter pointer to the private structure2192* @param idx the entry index within the vlan table. The HW uses the vlan id2193* field of the packet when accessing this table.2194* @param udma_mask vlan table value that indicates that the packet should be forward back to2195* the udmas, through the Rx path (udma_mask is one-hot representation)2196* @param fwd_to_mac vlan table value that indicates that the packet should be forward to mac2197*2198* @return 0 on success. otherwise on failure.2199*/2200int al_eth_tx_fwd_vid_table_set(struct al_hal_eth_adapter *adapter, uint32_t idx, uint8_t udma_mask, al_bool fwd_to_mac);22012202/** Tx Generic protocol detect Cam compare table entry */2203struct al_eth_tx_gpd_cam_entry {2204enum AL_ETH_PROTO_ID l3_proto_idx;2205enum AL_ETH_PROTO_ID l4_proto_idx;2206enum AL_ETH_TX_TUNNEL_MODE tunnel_control;2207uint8_t source_vlan_count:2;2208uint8_t tx_gpd_cam_ctrl:1;2209uint8_t l3_proto_idx_mask:5;2210uint8_t l4_proto_idx_mask:5;2211uint8_t tunnel_control_mask:3;2212uint8_t source_vlan_count_mask:2;2213};22142215/** Rx Generic protocol detect Cam compare table entry */2216struct al_eth_rx_gpd_cam_entry {2217enum AL_ETH_PROTO_ID outer_l3_proto_idx;2218enum AL_ETH_PROTO_ID outer_l4_proto_idx;2219enum AL_ETH_PROTO_ID inner_l3_proto_idx;2220enum AL_ETH_PROTO_ID inner_l4_proto_idx;2221uint8_t parse_ctrl;2222uint8_t outer_l3_len;2223uint8_t l3_priority;2224uint8_t l4_dst_port_lsb;2225uint8_t rx_gpd_cam_ctrl:1;2226uint8_t outer_l3_proto_idx_mask:5;2227uint8_t outer_l4_proto_idx_mask:5;2228uint8_t inner_l3_proto_idx_mask:5;2229uint8_t inner_l4_proto_idx_mask:5;2230uint8_t parse_ctrl_mask;2231uint8_t outer_l3_len_mask;2232uint8_t l3_priority_mask;2233uint8_t l4_dst_port_lsb_mask;2234};22352236enum AL_ETH_TX_GCP_ALU_OPSEL {2237AL_ETH_TX_GCP_ALU_L3_OFFSET = 0,2238AL_ETH_TX_GCP_ALU_OUTER_L3_OFFSET = 1,2239AL_ETH_TX_GCP_ALU_L3_LEN = 2,2240AL_ETH_TX_GCP_ALU_OUTER_L3_LEN = 3,2241AL_ETH_TX_GCP_ALU_L4_OFFSET = 4,2242AL_ETH_TX_GCP_ALU_L4_LEN = 5,2243AL_ETH_TX_GCP_ALU_TABLE_VAL = 102244};22452246enum AL_ETH_RX_GCP_ALU_OPSEL {2247AL_ETH_RX_GCP_ALU_OUTER_L3_OFFSET = 0,2248AL_ETH_RX_GCP_ALU_INNER_L3_OFFSET = 1,2249AL_ETH_RX_GCP_ALU_OUTER_L4_OFFSET = 2,2250AL_ETH_RX_GCP_ALU_INNER_L4_OFFSET = 3,2251AL_ETH_RX_GCP_ALU_OUTER_L3_HDR_LEN_LAT = 4,2252AL_ETH_RX_GCP_ALU_INNER_L3_HDR_LEN_LAT = 5,2253AL_ETH_RX_GCP_ALU_OUTER_L3_HDR_LEN_SEL = 6,2254AL_ETH_RX_GCP_ALU_INNER_L3_HDR_LEN_SEL = 7,2255AL_ETH_RX_GCP_ALU_PARSE_RESULT_VECTOR_OFFSET_1 = 8,2256AL_ETH_RX_GCP_ALU_PARSE_RESULT_VECTOR_OFFSET_2 = 9,2257AL_ETH_RX_GCP_ALU_TABLE_VAL = 102258};22592260/** Tx Generic crc prameters table entry */22612262struct al_eth_tx_gcp_table_entry {2263uint8_t poly_sel:1;2264uint8_t crc32_bit_comp:1;2265uint8_t crc32_bit_swap:1;2266uint8_t crc32_byte_swap:1;2267uint8_t data_bit_swap:1;2268uint8_t data_byte_swap:1;2269uint8_t trail_size:4;2270uint8_t head_size:8;2271uint8_t head_calc:1;2272uint8_t mask_polarity:1;2273enum AL_ETH_ALU_OPCODE tx_alu_opcode_1;2274enum AL_ETH_ALU_OPCODE tx_alu_opcode_2;2275enum AL_ETH_ALU_OPCODE tx_alu_opcode_3;2276enum AL_ETH_TX_GCP_ALU_OPSEL tx_alu_opsel_1;2277enum AL_ETH_TX_GCP_ALU_OPSEL tx_alu_opsel_2;2278enum AL_ETH_TX_GCP_ALU_OPSEL tx_alu_opsel_3;2279enum AL_ETH_TX_GCP_ALU_OPSEL tx_alu_opsel_4;2280uint32_t gcp_mask[6];2281uint32_t crc_init;2282uint8_t gcp_table_res:7;2283uint16_t alu_val:9;2284};22852286/** Rx Generic crc prameters table entry */22872288struct al_eth_rx_gcp_table_entry {2289uint8_t poly_sel:1;2290uint8_t crc32_bit_comp:1;2291uint8_t crc32_bit_swap:1;2292uint8_t crc32_byte_swap:1;2293uint8_t data_bit_swap:1;2294uint8_t data_byte_swap:1;2295uint8_t trail_size:4;2296uint8_t head_size:8;2297uint8_t head_calc:1;2298uint8_t mask_polarity:1;2299enum AL_ETH_ALU_OPCODE rx_alu_opcode_1;2300enum AL_ETH_ALU_OPCODE rx_alu_opcode_2;2301enum AL_ETH_ALU_OPCODE rx_alu_opcode_3;2302enum AL_ETH_RX_GCP_ALU_OPSEL rx_alu_opsel_1;2303enum AL_ETH_RX_GCP_ALU_OPSEL rx_alu_opsel_2;2304enum AL_ETH_RX_GCP_ALU_OPSEL rx_alu_opsel_3;2305enum AL_ETH_RX_GCP_ALU_OPSEL rx_alu_opsel_4;2306uint32_t gcp_mask[6];2307uint32_t crc_init;2308uint32_t gcp_table_res:27;2309uint16_t alu_val:9;2310};23112312/** Tx per_protocol_number crc & l3_checksum & l4_checksum command table entry */23132314struct al_eth_tx_crc_chksum_replace_cmd_for_protocol_num_entry {2315al_bool crc_en_00; /*from Tx_buffer_descriptor: enable_l4_checksum is 0 ,enable_l3_checksum is 0 */2316al_bool crc_en_01; /*from Tx_buffer_descriptor: enable_l4_checksum is 0 ,enable_l3_checksum is 1 */2317al_bool crc_en_10; /*from Tx_buffer_descriptor: enable_l4_checksum is 1 ,enable_l3_checksum is 0 */2318al_bool crc_en_11; /*from Tx_buffer_descriptor: enable_l4_checksum is 1 ,enable_l3_checksum is 1 */2319al_bool l4_csum_en_00; /*from Tx_buffer_descriptor: enable_l4_checksum is 0 ,enable_l3_checksum is 0 */2320al_bool l4_csum_en_01; /*from Tx_buffer_descriptor: enable_l4_checksum is 0 ,enable_l3_checksum is 1 */2321al_bool l4_csum_en_10; /*from Tx_buffer_descriptor: enable_l4_checksum is 1 ,enable_l3_checksum is 0 */2322al_bool l4_csum_en_11; /*from Tx_buffer_descriptor: enable_l4_checksum is 1 ,enable_l3_checksum is 1 */2323al_bool l3_csum_en_00; /*from Tx_buffer_descriptor: enable_l4_checksum is 0 ,enable_l3_checksum is 0 */2324al_bool l3_csum_en_01; /*from Tx_buffer_descriptor: enable_l4_checksum is 0 ,enable_l3_checksum is 1 */2325al_bool l3_csum_en_10; /*from Tx_buffer_descriptor: enable_l4_checksum is 1 ,enable_l3_checksum is 0 */2326al_bool l3_csum_en_11; /*from Tx_buffer_descriptor: enable_l4_checksum is 1 ,enable_l3_checksum is 1 */2327};23282329/**2330* Configure tx_gpd_entry2331*2332* @param adapter pointer to the private structure2333* @param idx the entry index2334* @param tx_gpd_entry entry data for the Tx protocol detect Cam compare table2335*2336* @return 0 on success. otherwise on failure.2337*2338*/2339int al_eth_tx_protocol_detect_table_entry_set(struct al_hal_eth_adapter *adapter, uint32_t idx,2340struct al_eth_tx_gpd_cam_entry *tx_gpd_entry);23412342/**2343* Configure tx_gcp_entry2344*2345* @param adapter pointer to the private structure2346* @param idx the entry index2347* @param tx_gcp_entry entry data for the Tx Generic crc prameters table2348*2349* @return 0 on success. otherwise on failure.2350*2351*/2352int al_eth_tx_generic_crc_table_entry_set(struct al_hal_eth_adapter *adapter, uint32_t idx,2353struct al_eth_tx_gcp_table_entry *tx_gcp_entry);23542355/**2356* Configure tx_crc_chksum_replace_cmd_entry2357*2358* @param adapter pointer to the private structure2359* @param idx the entry index2360* @param tx_replace_entry entry data for the Tx crc_&_l3_checksum_&_l4_checksum replace command table2361*2362* @return 0 on success. otherwise on failure.2363*2364*/2365int al_eth_tx_crc_chksum_replace_cmd_entry_set(struct al_hal_eth_adapter *adapter, uint32_t idx,2366struct al_eth_tx_crc_chksum_replace_cmd_for_protocol_num_entry *tx_replace_entry);23672368/**2369* Configure rx_gpd_entry2370*2371* @param adapter pointer to the private structure2372* @param idx the entry index2373* @param rx_gpd_entry entry data for the Tx protocol detect Cam compare table2374*2375* @return 0 on success. otherwise on failure.2376*2377*/2378int al_eth_rx_protocol_detect_table_entry_set(struct al_hal_eth_adapter *adapter, uint32_t idx,2379struct al_eth_rx_gpd_cam_entry *rx_gpd_entry);23802381/**2382* Configure rx_gcp_entry2383*2384* @param adapter pointer to the private structure2385* @param idx the entry index2386* @param rx_gpd_entry entry data for the Tx protocol detect Cam compare table2387* @param rx_gcp_entry entry data for the Tx Generic crc prameters table2388*2389* @return 0 on success. otherwise on failure.2390*2391*/2392int al_eth_rx_generic_crc_table_entry_set(struct al_hal_eth_adapter *adapter, uint32_t idx,2393struct al_eth_rx_gcp_table_entry *rx_gcp_entry);23942395/**2396* Configure tx_gpd_table and regs2397*2398* @param adapter pointer to the private structure2399*2400*/2401int al_eth_tx_protocol_detect_table_init(struct al_hal_eth_adapter *adapter);24022403/**2404* Configure crc_chksum_replace_cmd_table2405*2406* @param adapter pointer to the private structure2407*2408*/2409int al_eth_tx_crc_chksum_replace_cmd_init(struct al_hal_eth_adapter *adapter);24102411/**2412* Configure tx_gcp_table and regs2413*2414* @param adapter pointer to the private structure2415*2416*/2417int al_eth_tx_generic_crc_table_init(struct al_hal_eth_adapter *adapter);24182419/**2420* Configure rx_gpd_table and regs2421*2422* @param adapter pointer to the private structure2423*2424*/2425int al_eth_rx_protocol_detect_table_init(struct al_hal_eth_adapter *adapter);24262427/**2428* Configure rx_gcp_table and regs2429*2430* @param adapter pointer to the private structure2431*2432*/2433int al_eth_rx_generic_crc_table_init(struct al_hal_eth_adapter *adapter);24342435#ifdef __cplusplus2436}2437#endif2438/* *INDENT-ON* */2439#endif /* __AL_HAL_ETH_H__ */2440/** @} end of Ethernet group */244124422443