/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) * * Copyright 2010-2012 Freescale Semiconductor, Inc. * All rights reserved. * */ #ifndef __FMAN_H #define __FMAN_H #include #include #include #include #include #ifndef FMAN_DEVICE_PATH #define FMAN_DEVICE_PATH "/dev/mem" #endif #define MEMAC_NUM_OF_PADDRS 7 /* Num of additional exact match MAC adr regs */ /* Control and Configuration Register (COMMAND_CONFIG) for MEMAC */ #define CMD_CFG_LOOPBACK_EN 0x00000400 /**< 21 XGMII/GMII loopback enable */ #define CMD_CFG_PROMIS_EN 0x00000010 /**< 27 Promiscuous operation enable */ #define CMD_CFG_PAUSE_IGNORE 0x00000100 /**< 23 Ignore Pause frame quanta */ /* Statistics Configuration Register (STATN_CONFIG) */ #define STATS_CFG_CLR 0x00000004 /**< 29 Reset all counters */ #define STATS_CFG_CLR_ON_RD 0x00000002 /**< 30 Clear on read */ #define STATS_CFG_SATURATE 0x00000001 /**< 31 Saturate at the maximum val */ /**< Max receive frame length mask */ #define MAXFRM_SIZE_MEMAC 0x00007fe0 #define MAXFRM_RX_MASK 0x0000ffff /**< Interface Mode Register Register for MEMAC */ #define IF_MODE_RLP 0x00000820 /**< Pool Limits */ #define FMAN_PORT_MAX_EXT_POOLS_NUM 8 #define FMAN_PORT_OBS_EXT_POOLS_NUM 2 #define FMAN_PORT_CG_MAP_NUM 8 #define FMAN_PORT_PRS_RESULT_WORDS_NUM 8 #define FMAN_PORT_BMI_FIFO_UNITS 0x100 #define FMAN_PORT_IC_OFFSET_UNITS 0x10 #define FMAN_ENABLE_BPOOL_DEPLETION 0xF00000F0 #define HASH_CTRL_MCAST_EN 0x00000100 #define GROUP_ADDRESS 0x0000010000000000LL #define HASH_CTRL_ADDR_MASK 0x0000003F /* Pre definitions of FMAN interface and Bpool structures */ struct __fman_if; struct fman_if_bpool; /* Lists of fman interfaces and bpools */ TAILQ_HEAD(rte_fman_if_list, __fman_if); /* Represents the different flavour of network interface */ enum fman_mac_type { fman_offline = 0, fman_mac_1g, fman_mac_10g, }; struct mac_addr { uint32_t mac_addr_l; /**< Lower 32 bits of 48-bit MAC address */ uint32_t mac_addr_u; /**< Upper 16 bits of 48-bit MAC address */ }; struct memac_regs { /* General Control and Status */ uint32_t res0000[2]; uint32_t command_config; /**< 0x008 Ctrl and cfg */ struct mac_addr mac_addr0; /**< 0x00C-0x010 MAC_ADDR_0...1 */ uint32_t maxfrm; /**< 0x014 Max frame length */ uint32_t res0018[5]; uint32_t hashtable_ctrl; /**< 0x02C Hash table control */ uint32_t res0030[4]; uint32_t ievent; /**< 0x040 Interrupt event */ uint32_t tx_ipg_length; /**< 0x044 Transmitter inter-packet-gap */ uint32_t res0048; uint32_t imask; /**< 0x04C Interrupt mask */ uint32_t res0050; uint32_t pause_quanta[4]; /**< 0x054 Pause quanta */ uint32_t pause_thresh[4]; /**< 0x064 Pause quanta threshold */ uint32_t rx_pause_status; /**< 0x074 Receive pause status */ uint32_t res0078[2]; struct mac_addr mac_addr[MEMAC_NUM_OF_PADDRS]; /**< 0x80-0x0B4 mac padr */ uint32_t lpwake_timer; /**< 0x0B8 Low Power Wakeup Timer */ uint32_t sleep_timer; /**< 0x0BC Transmit EEE Low Power Timer */ uint32_t res00c0[8]; uint32_t statn_config; /**< 0x0E0 Statistics configuration */ uint32_t res00e4[7]; /* Rx Statistics Counter */ uint32_t reoct_l; /**bpid); * [...] * } */ #define fman_if_for_each_bpool(bp, __if) \ list_for_each_entry(bp, &(__if)->bpool_list, node) #define FMAN_ERR(rc, fmt, args...) \ do { \ _errno = (rc); \ DPAA_BUS_LOG(ERR, fmt "(%d)", ##args, errno); \ } while (0) #define FMAN_IP_REV_1 0xC30C4 #define FMAN_IP_REV_1_MAJOR_MASK 0x0000FF00 #define FMAN_IP_REV_1_MAJOR_SHIFT 8 #define FMAN_V3 0x06 #define FMAN_V3_CONTEXTA_EN_A2V 0x10000000 #define FMAN_V3_CONTEXTA_EN_OVOM 0x02000000 #define FMAN_V3_CONTEXTA_EN_EBD 0x80000000 #define FMAN_CONTEXTA_DIS_CHECKSUM 0x7ull #define FMAN_CONTEXTA_SET_OPCODE11 0x2000000b00000000 extern u16 fman_ip_rev; extern u32 fman_dealloc_bufs_mask_hi; extern u32 fman_dealloc_bufs_mask_lo; /** * Initialize the FMAN driver * * @args void * @return * 0 for success; error OTHERWISE */ int fman_init(void); /** * Teardown the FMAN driver * * @args void * @return void */ void fman_finish(void); #endif /* __FMAN_H */