162306a36Sopenharmony_ci/* Broadcom NetXtreme-C/E network driver. 262306a36Sopenharmony_ci * 362306a36Sopenharmony_ci * Copyright (c) 2014-2016 Broadcom Corporation 462306a36Sopenharmony_ci * Copyright (c) 2016-2018 Broadcom Limited 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 762306a36Sopenharmony_ci * it under the terms of the GNU General Public License as published by 862306a36Sopenharmony_ci * the Free Software Foundation. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifndef BNXT_H 1262306a36Sopenharmony_ci#define BNXT_H 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define DRV_MODULE_NAME "bnxt_en" 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* DO NOT CHANGE DRV_VER_* defines 1762306a36Sopenharmony_ci * FIXME: Delete them 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_ci#define DRV_VER_MAJ 1 2062306a36Sopenharmony_ci#define DRV_VER_MIN 10 2162306a36Sopenharmony_ci#define DRV_VER_UPD 2 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#include <linux/ethtool.h> 2462306a36Sopenharmony_ci#include <linux/interrupt.h> 2562306a36Sopenharmony_ci#include <linux/rhashtable.h> 2662306a36Sopenharmony_ci#include <linux/crash_dump.h> 2762306a36Sopenharmony_ci#include <linux/auxiliary_bus.h> 2862306a36Sopenharmony_ci#include <net/devlink.h> 2962306a36Sopenharmony_ci#include <net/dst_metadata.h> 3062306a36Sopenharmony_ci#include <net/xdp.h> 3162306a36Sopenharmony_ci#include <linux/dim.h> 3262306a36Sopenharmony_ci#include <linux/io-64-nonatomic-lo-hi.h> 3362306a36Sopenharmony_ci#ifdef CONFIG_TEE_BNXT_FW 3462306a36Sopenharmony_ci#include <linux/firmware/broadcom/tee_bnxt_fw.h> 3562306a36Sopenharmony_ci#endif 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ciextern struct list_head bnxt_block_cb_list; 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cistruct page_pool; 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cistruct tx_bd { 4262306a36Sopenharmony_ci __le32 tx_bd_len_flags_type; 4362306a36Sopenharmony_ci #define TX_BD_TYPE (0x3f << 0) 4462306a36Sopenharmony_ci #define TX_BD_TYPE_SHORT_TX_BD (0x00 << 0) 4562306a36Sopenharmony_ci #define TX_BD_TYPE_LONG_TX_BD (0x10 << 0) 4662306a36Sopenharmony_ci #define TX_BD_FLAGS_PACKET_END (1 << 6) 4762306a36Sopenharmony_ci #define TX_BD_FLAGS_NO_CMPL (1 << 7) 4862306a36Sopenharmony_ci #define TX_BD_FLAGS_BD_CNT (0x1f << 8) 4962306a36Sopenharmony_ci #define TX_BD_FLAGS_BD_CNT_SHIFT 8 5062306a36Sopenharmony_ci #define TX_BD_FLAGS_LHINT (3 << 13) 5162306a36Sopenharmony_ci #define TX_BD_FLAGS_LHINT_SHIFT 13 5262306a36Sopenharmony_ci #define TX_BD_FLAGS_LHINT_512_AND_SMALLER (0 << 13) 5362306a36Sopenharmony_ci #define TX_BD_FLAGS_LHINT_512_TO_1023 (1 << 13) 5462306a36Sopenharmony_ci #define TX_BD_FLAGS_LHINT_1024_TO_2047 (2 << 13) 5562306a36Sopenharmony_ci #define TX_BD_FLAGS_LHINT_2048_AND_LARGER (3 << 13) 5662306a36Sopenharmony_ci #define TX_BD_FLAGS_COAL_NOW (1 << 15) 5762306a36Sopenharmony_ci #define TX_BD_LEN (0xffff << 16) 5862306a36Sopenharmony_ci #define TX_BD_LEN_SHIFT 16 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci u32 tx_bd_opaque; 6162306a36Sopenharmony_ci __le64 tx_bd_haddr; 6262306a36Sopenharmony_ci} __packed; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_cistruct tx_bd_ext { 6562306a36Sopenharmony_ci __le32 tx_bd_hsize_lflags; 6662306a36Sopenharmony_ci #define TX_BD_FLAGS_TCP_UDP_CHKSUM (1 << 0) 6762306a36Sopenharmony_ci #define TX_BD_FLAGS_IP_CKSUM (1 << 1) 6862306a36Sopenharmony_ci #define TX_BD_FLAGS_NO_CRC (1 << 2) 6962306a36Sopenharmony_ci #define TX_BD_FLAGS_STAMP (1 << 3) 7062306a36Sopenharmony_ci #define TX_BD_FLAGS_T_IP_CHKSUM (1 << 4) 7162306a36Sopenharmony_ci #define TX_BD_FLAGS_LSO (1 << 5) 7262306a36Sopenharmony_ci #define TX_BD_FLAGS_IPID_FMT (1 << 6) 7362306a36Sopenharmony_ci #define TX_BD_FLAGS_T_IPID (1 << 7) 7462306a36Sopenharmony_ci #define TX_BD_HSIZE (0xff << 16) 7562306a36Sopenharmony_ci #define TX_BD_HSIZE_SHIFT 16 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci __le32 tx_bd_mss; 7862306a36Sopenharmony_ci __le32 tx_bd_cfa_action; 7962306a36Sopenharmony_ci #define TX_BD_CFA_ACTION (0xffff << 16) 8062306a36Sopenharmony_ci #define TX_BD_CFA_ACTION_SHIFT 16 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci __le32 tx_bd_cfa_meta; 8362306a36Sopenharmony_ci #define TX_BD_CFA_META_MASK 0xfffffff 8462306a36Sopenharmony_ci #define TX_BD_CFA_META_VID_MASK 0xfff 8562306a36Sopenharmony_ci #define TX_BD_CFA_META_PRI_MASK (0xf << 12) 8662306a36Sopenharmony_ci #define TX_BD_CFA_META_PRI_SHIFT 12 8762306a36Sopenharmony_ci #define TX_BD_CFA_META_TPID_MASK (3 << 16) 8862306a36Sopenharmony_ci #define TX_BD_CFA_META_TPID_SHIFT 16 8962306a36Sopenharmony_ci #define TX_BD_CFA_META_KEY (0xf << 28) 9062306a36Sopenharmony_ci #define TX_BD_CFA_META_KEY_SHIFT 28 9162306a36Sopenharmony_ci #define TX_BD_CFA_META_KEY_VLAN (1 << 28) 9262306a36Sopenharmony_ci}; 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#define BNXT_TX_PTP_IS_SET(lflags) ((lflags) & cpu_to_le32(TX_BD_FLAGS_STAMP)) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_cistruct rx_bd { 9762306a36Sopenharmony_ci __le32 rx_bd_len_flags_type; 9862306a36Sopenharmony_ci #define RX_BD_TYPE (0x3f << 0) 9962306a36Sopenharmony_ci #define RX_BD_TYPE_RX_PACKET_BD 0x4 10062306a36Sopenharmony_ci #define RX_BD_TYPE_RX_BUFFER_BD 0x5 10162306a36Sopenharmony_ci #define RX_BD_TYPE_RX_AGG_BD 0x6 10262306a36Sopenharmony_ci #define RX_BD_TYPE_16B_BD_SIZE (0 << 4) 10362306a36Sopenharmony_ci #define RX_BD_TYPE_32B_BD_SIZE (1 << 4) 10462306a36Sopenharmony_ci #define RX_BD_TYPE_48B_BD_SIZE (2 << 4) 10562306a36Sopenharmony_ci #define RX_BD_TYPE_64B_BD_SIZE (3 << 4) 10662306a36Sopenharmony_ci #define RX_BD_FLAGS_SOP (1 << 6) 10762306a36Sopenharmony_ci #define RX_BD_FLAGS_EOP (1 << 7) 10862306a36Sopenharmony_ci #define RX_BD_FLAGS_BUFFERS (3 << 8) 10962306a36Sopenharmony_ci #define RX_BD_FLAGS_1_BUFFER_PACKET (0 << 8) 11062306a36Sopenharmony_ci #define RX_BD_FLAGS_2_BUFFER_PACKET (1 << 8) 11162306a36Sopenharmony_ci #define RX_BD_FLAGS_3_BUFFER_PACKET (2 << 8) 11262306a36Sopenharmony_ci #define RX_BD_FLAGS_4_BUFFER_PACKET (3 << 8) 11362306a36Sopenharmony_ci #define RX_BD_LEN (0xffff << 16) 11462306a36Sopenharmony_ci #define RX_BD_LEN_SHIFT 16 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci u32 rx_bd_opaque; 11762306a36Sopenharmony_ci __le64 rx_bd_haddr; 11862306a36Sopenharmony_ci}; 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_cistruct tx_cmp { 12162306a36Sopenharmony_ci __le32 tx_cmp_flags_type; 12262306a36Sopenharmony_ci #define CMP_TYPE (0x3f << 0) 12362306a36Sopenharmony_ci #define CMP_TYPE_TX_L2_CMP 0 12462306a36Sopenharmony_ci #define CMP_TYPE_RX_L2_CMP 17 12562306a36Sopenharmony_ci #define CMP_TYPE_RX_AGG_CMP 18 12662306a36Sopenharmony_ci #define CMP_TYPE_RX_L2_TPA_START_CMP 19 12762306a36Sopenharmony_ci #define CMP_TYPE_RX_L2_TPA_END_CMP 21 12862306a36Sopenharmony_ci #define CMP_TYPE_RX_TPA_AGG_CMP 22 12962306a36Sopenharmony_ci #define CMP_TYPE_STATUS_CMP 32 13062306a36Sopenharmony_ci #define CMP_TYPE_REMOTE_DRIVER_REQ 34 13162306a36Sopenharmony_ci #define CMP_TYPE_REMOTE_DRIVER_RESP 36 13262306a36Sopenharmony_ci #define CMP_TYPE_ERROR_STATUS 48 13362306a36Sopenharmony_ci #define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL 13462306a36Sopenharmony_ci #define CMPL_BASE_TYPE_HWRM_DONE 0x20UL 13562306a36Sopenharmony_ci #define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL 13662306a36Sopenharmony_ci #define CMPL_BASE_TYPE_HWRM_FWD_RESP 0x24UL 13762306a36Sopenharmony_ci #define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci #define TX_CMP_FLAGS_ERROR (1 << 6) 14062306a36Sopenharmony_ci #define TX_CMP_FLAGS_PUSH (1 << 7) 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci u32 tx_cmp_opaque; 14362306a36Sopenharmony_ci __le32 tx_cmp_errors_v; 14462306a36Sopenharmony_ci #define TX_CMP_V (1 << 0) 14562306a36Sopenharmony_ci #define TX_CMP_ERRORS_BUFFER_ERROR (7 << 1) 14662306a36Sopenharmony_ci #define TX_CMP_ERRORS_BUFFER_ERROR_NO_ERROR 0 14762306a36Sopenharmony_ci #define TX_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT 2 14862306a36Sopenharmony_ci #define TX_CMP_ERRORS_BUFFER_ERROR_INVALID_STAG 4 14962306a36Sopenharmony_ci #define TX_CMP_ERRORS_BUFFER_ERROR_STAG_BOUNDS 5 15062306a36Sopenharmony_ci #define TX_CMP_ERRORS_ZERO_LENGTH_PKT (1 << 4) 15162306a36Sopenharmony_ci #define TX_CMP_ERRORS_EXCESSIVE_BD_LEN (1 << 5) 15262306a36Sopenharmony_ci #define TX_CMP_ERRORS_DMA_ERROR (1 << 6) 15362306a36Sopenharmony_ci #define TX_CMP_ERRORS_HINT_TOO_SHORT (1 << 7) 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci __le32 tx_cmp_unsed_3; 15662306a36Sopenharmony_ci}; 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_cistruct rx_cmp { 15962306a36Sopenharmony_ci __le32 rx_cmp_len_flags_type; 16062306a36Sopenharmony_ci #define RX_CMP_CMP_TYPE (0x3f << 0) 16162306a36Sopenharmony_ci #define RX_CMP_FLAGS_ERROR (1 << 6) 16262306a36Sopenharmony_ci #define RX_CMP_FLAGS_PLACEMENT (7 << 7) 16362306a36Sopenharmony_ci #define RX_CMP_FLAGS_RSS_VALID (1 << 10) 16462306a36Sopenharmony_ci #define RX_CMP_FLAGS_PKT_METADATA_PRESENT (1 << 11) 16562306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPES_SHIFT 12 16662306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPES_MASK 0xf000 16762306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12) 16862306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_IP (1 << 12) 16962306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_TCP (2 << 12) 17062306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_UDP (3 << 12) 17162306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12) 17262306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12) 17362306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12) 17462306a36Sopenharmony_ci #define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12) 17562306a36Sopenharmony_ci #define RX_CMP_LEN (0xffff << 16) 17662306a36Sopenharmony_ci #define RX_CMP_LEN_SHIFT 16 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci u32 rx_cmp_opaque; 17962306a36Sopenharmony_ci __le32 rx_cmp_misc_v1; 18062306a36Sopenharmony_ci #define RX_CMP_V1 (1 << 0) 18162306a36Sopenharmony_ci #define RX_CMP_AGG_BUFS (0x1f << 1) 18262306a36Sopenharmony_ci #define RX_CMP_AGG_BUFS_SHIFT 1 18362306a36Sopenharmony_ci #define RX_CMP_RSS_HASH_TYPE (0x7f << 9) 18462306a36Sopenharmony_ci #define RX_CMP_RSS_HASH_TYPE_SHIFT 9 18562306a36Sopenharmony_ci #define RX_CMP_PAYLOAD_OFFSET (0xff << 16) 18662306a36Sopenharmony_ci #define RX_CMP_PAYLOAD_OFFSET_SHIFT 16 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci __le32 rx_cmp_rss_hash; 18962306a36Sopenharmony_ci}; 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci#define BNXT_PTP_RX_TS_VALID(flags) \ 19262306a36Sopenharmony_ci (((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS) 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci#define BNXT_ALL_RX_TS_VALID(flags) \ 19562306a36Sopenharmony_ci !((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT) 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci#define RX_CMP_HASH_VALID(rxcmp) \ 19862306a36Sopenharmony_ci ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID)) 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci#define RSS_PROFILE_ID_MASK 0x1f 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci#define RX_CMP_HASH_TYPE(rxcmp) \ 20362306a36Sopenharmony_ci (((le32_to_cpu((rxcmp)->rx_cmp_misc_v1) & RX_CMP_RSS_HASH_TYPE) >>\ 20462306a36Sopenharmony_ci RX_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK) 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_cistruct rx_cmp_ext { 20762306a36Sopenharmony_ci __le32 rx_cmp_flags2; 20862306a36Sopenharmony_ci #define RX_CMP_FLAGS2_IP_CS_CALC 0x1 20962306a36Sopenharmony_ci #define RX_CMP_FLAGS2_L4_CS_CALC (0x1 << 1) 21062306a36Sopenharmony_ci #define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2) 21162306a36Sopenharmony_ci #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3) 21262306a36Sopenharmony_ci #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4) 21362306a36Sopenharmony_ci __le32 rx_cmp_meta_data; 21462306a36Sopenharmony_ci #define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff 21562306a36Sopenharmony_ci #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff 21662306a36Sopenharmony_ci #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000 21762306a36Sopenharmony_ci #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16 21862306a36Sopenharmony_ci __le32 rx_cmp_cfa_code_errors_v2; 21962306a36Sopenharmony_ci #define RX_CMP_V (1 << 0) 22062306a36Sopenharmony_ci #define RX_CMPL_ERRORS_MASK (0x7fff << 1) 22162306a36Sopenharmony_ci #define RX_CMPL_ERRORS_SFT 1 22262306a36Sopenharmony_ci #define RX_CMPL_ERRORS_BUFFER_ERROR_MASK (0x7 << 1) 22362306a36Sopenharmony_ci #define RX_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) 22462306a36Sopenharmony_ci #define RX_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1 << 1) 22562306a36Sopenharmony_ci #define RX_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1) 22662306a36Sopenharmony_ci #define RX_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) 22762306a36Sopenharmony_ci #define RX_CMPL_ERRORS_IP_CS_ERROR (0x1 << 4) 22862306a36Sopenharmony_ci #define RX_CMPL_ERRORS_L4_CS_ERROR (0x1 << 5) 22962306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_IP_CS_ERROR (0x1 << 6) 23062306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_L4_CS_ERROR (0x1 << 7) 23162306a36Sopenharmony_ci #define RX_CMPL_ERRORS_CRC_ERROR (0x1 << 8) 23262306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_MASK (0x7 << 9) 23362306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_NO_ERROR (0x0 << 9) 23462306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1 << 9) 23562306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2 << 9) 23662306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3 << 9) 23762306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4 << 9) 23862306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5 << 9) 23962306a36Sopenharmony_ci #define RX_CMPL_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6 << 9) 24062306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_MASK (0xf << 12) 24162306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_NO_ERROR (0x0 << 12) 24262306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1 << 12) 24362306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2 << 12) 24462306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3 << 12) 24562306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4 << 12) 24662306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5 << 12) 24762306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6 << 12) 24862306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7 << 12) 24962306a36Sopenharmony_ci #define RX_CMPL_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8 << 12) 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci #define RX_CMPL_CFA_CODE_MASK (0xffff << 16) 25262306a36Sopenharmony_ci #define RX_CMPL_CFA_CODE_SFT 16 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci __le32 rx_cmp_timestamp; 25562306a36Sopenharmony_ci}; 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci#define RX_CMP_L2_ERRORS \ 25862306a36Sopenharmony_ci cpu_to_le32(RX_CMPL_ERRORS_BUFFER_ERROR_MASK | RX_CMPL_ERRORS_CRC_ERROR) 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ci#define RX_CMP_L4_CS_BITS \ 26162306a36Sopenharmony_ci (cpu_to_le32(RX_CMP_FLAGS2_L4_CS_CALC | RX_CMP_FLAGS2_T_L4_CS_CALC)) 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci#define RX_CMP_L4_CS_ERR_BITS \ 26462306a36Sopenharmony_ci (cpu_to_le32(RX_CMPL_ERRORS_L4_CS_ERROR | RX_CMPL_ERRORS_T_L4_CS_ERROR)) 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci#define RX_CMP_L4_CS_OK(rxcmp1) \ 26762306a36Sopenharmony_ci (((rxcmp1)->rx_cmp_flags2 & RX_CMP_L4_CS_BITS) && \ 26862306a36Sopenharmony_ci !((rxcmp1)->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS)) 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci#define RX_CMP_ENCAP(rxcmp1) \ 27162306a36Sopenharmony_ci ((le32_to_cpu((rxcmp1)->rx_cmp_flags2) & \ 27262306a36Sopenharmony_ci RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3) 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci#define RX_CMP_CFA_CODE(rxcmpl1) \ 27562306a36Sopenharmony_ci ((le32_to_cpu((rxcmpl1)->rx_cmp_cfa_code_errors_v2) & \ 27662306a36Sopenharmony_ci RX_CMPL_CFA_CODE_MASK) >> RX_CMPL_CFA_CODE_SFT) 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_cistruct rx_agg_cmp { 27962306a36Sopenharmony_ci __le32 rx_agg_cmp_len_flags_type; 28062306a36Sopenharmony_ci #define RX_AGG_CMP_TYPE (0x3f << 0) 28162306a36Sopenharmony_ci #define RX_AGG_CMP_LEN (0xffff << 16) 28262306a36Sopenharmony_ci #define RX_AGG_CMP_LEN_SHIFT 16 28362306a36Sopenharmony_ci u32 rx_agg_cmp_opaque; 28462306a36Sopenharmony_ci __le32 rx_agg_cmp_v; 28562306a36Sopenharmony_ci #define RX_AGG_CMP_V (1 << 0) 28662306a36Sopenharmony_ci #define RX_AGG_CMP_AGG_ID (0xffff << 16) 28762306a36Sopenharmony_ci #define RX_AGG_CMP_AGG_ID_SHIFT 16 28862306a36Sopenharmony_ci __le32 rx_agg_cmp_unused; 28962306a36Sopenharmony_ci}; 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci#define TPA_AGG_AGG_ID(rx_agg) \ 29262306a36Sopenharmony_ci ((le32_to_cpu((rx_agg)->rx_agg_cmp_v) & \ 29362306a36Sopenharmony_ci RX_AGG_CMP_AGG_ID) >> RX_AGG_CMP_AGG_ID_SHIFT) 29462306a36Sopenharmony_ci 29562306a36Sopenharmony_cistruct rx_tpa_start_cmp { 29662306a36Sopenharmony_ci __le32 rx_tpa_start_cmp_len_flags_type; 29762306a36Sopenharmony_ci #define RX_TPA_START_CMP_TYPE (0x3f << 0) 29862306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS (0x3ff << 6) 29962306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_SHIFT 6 30062306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_ERROR (0x1 << 6) 30162306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_PLACEMENT (0x7 << 7) 30262306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_PLACEMENT_SHIFT 7 30362306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7) 30462306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7) 30562306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7) 30662306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7) 30762306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_RSS_VALID (0x1 << 10) 30862306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_TIMESTAMP (0x1 << 11) 30962306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_ITYPES (0xf << 12) 31062306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_ITYPES_SHIFT 12 31162306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS_ITYPE_TCP (0x2 << 12) 31262306a36Sopenharmony_ci #define RX_TPA_START_CMP_LEN (0xffff << 16) 31362306a36Sopenharmony_ci #define RX_TPA_START_CMP_LEN_SHIFT 16 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci u32 rx_tpa_start_cmp_opaque; 31662306a36Sopenharmony_ci __le32 rx_tpa_start_cmp_misc_v1; 31762306a36Sopenharmony_ci #define RX_TPA_START_CMP_V1 (0x1 << 0) 31862306a36Sopenharmony_ci #define RX_TPA_START_CMP_RSS_HASH_TYPE (0x7f << 9) 31962306a36Sopenharmony_ci #define RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT 9 32062306a36Sopenharmony_ci #define RX_TPA_START_CMP_AGG_ID (0x7f << 25) 32162306a36Sopenharmony_ci #define RX_TPA_START_CMP_AGG_ID_SHIFT 25 32262306a36Sopenharmony_ci #define RX_TPA_START_CMP_AGG_ID_P5 (0xffff << 16) 32362306a36Sopenharmony_ci #define RX_TPA_START_CMP_AGG_ID_SHIFT_P5 16 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ci __le32 rx_tpa_start_cmp_rss_hash; 32662306a36Sopenharmony_ci}; 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci#define TPA_START_HASH_VALID(rx_tpa_start) \ 32962306a36Sopenharmony_ci ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \ 33062306a36Sopenharmony_ci cpu_to_le32(RX_TPA_START_CMP_FLAGS_RSS_VALID)) 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci#define TPA_START_HASH_TYPE(rx_tpa_start) \ 33362306a36Sopenharmony_ci (((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ 33462306a36Sopenharmony_ci RX_TPA_START_CMP_RSS_HASH_TYPE) >> \ 33562306a36Sopenharmony_ci RX_TPA_START_CMP_RSS_HASH_TYPE_SHIFT) & RSS_PROFILE_ID_MASK) 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_ci#define TPA_START_AGG_ID(rx_tpa_start) \ 33862306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ 33962306a36Sopenharmony_ci RX_TPA_START_CMP_AGG_ID) >> RX_TPA_START_CMP_AGG_ID_SHIFT) 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci#define TPA_START_AGG_ID_P5(rx_tpa_start) \ 34262306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_misc_v1) & \ 34362306a36Sopenharmony_ci RX_TPA_START_CMP_AGG_ID_P5) >> RX_TPA_START_CMP_AGG_ID_SHIFT_P5) 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci#define TPA_START_ERROR(rx_tpa_start) \ 34662306a36Sopenharmony_ci ((rx_tpa_start)->rx_tpa_start_cmp_len_flags_type & \ 34762306a36Sopenharmony_ci cpu_to_le32(RX_TPA_START_CMP_FLAGS_ERROR)) 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_cistruct rx_tpa_start_cmp_ext { 35062306a36Sopenharmony_ci __le32 rx_tpa_start_cmp_flags2; 35162306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_IP_CS_CALC (0x1 << 0) 35262306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_L4_CS_CALC (0x1 << 1) 35362306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2) 35462306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3) 35562306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_IP_TYPE (0x1 << 8) 35662306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_VALID (0x1 << 9) 35762306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT (0x3 << 10) 35862306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_EXT_META_FORMAT_SHIFT 10 35962306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL (0xffff << 16) 36062306a36Sopenharmony_ci #define RX_TPA_START_CMP_FLAGS2_CSUM_CMPL_SHIFT 16 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci __le32 rx_tpa_start_cmp_metadata; 36362306a36Sopenharmony_ci __le32 rx_tpa_start_cmp_cfa_code_v2; 36462306a36Sopenharmony_ci #define RX_TPA_START_CMP_V2 (0x1 << 0) 36562306a36Sopenharmony_ci #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK (0x7 << 1) 36662306a36Sopenharmony_ci #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT 1 36762306a36Sopenharmony_ci #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) 36862306a36Sopenharmony_ci #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) 36962306a36Sopenharmony_ci #define RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1) 37062306a36Sopenharmony_ci #define RX_TPA_START_CMP_CFA_CODE (0xffff << 16) 37162306a36Sopenharmony_ci #define RX_TPA_START_CMPL_CFA_CODE_SHIFT 16 37262306a36Sopenharmony_ci __le32 rx_tpa_start_cmp_hdr_info; 37362306a36Sopenharmony_ci}; 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ci#define TPA_START_CFA_CODE(rx_tpa_start) \ 37662306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \ 37762306a36Sopenharmony_ci RX_TPA_START_CMP_CFA_CODE) >> RX_TPA_START_CMPL_CFA_CODE_SHIFT) 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci#define TPA_START_IS_IPV6(rx_tpa_start) \ 38062306a36Sopenharmony_ci (!!((rx_tpa_start)->rx_tpa_start_cmp_flags2 & \ 38162306a36Sopenharmony_ci cpu_to_le32(RX_TPA_START_CMP_FLAGS2_IP_TYPE))) 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci#define TPA_START_ERROR_CODE(rx_tpa_start) \ 38462306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_start)->rx_tpa_start_cmp_cfa_code_v2) & \ 38562306a36Sopenharmony_ci RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_MASK) >> \ 38662306a36Sopenharmony_ci RX_TPA_START_CMP_ERRORS_BUFFER_ERROR_SHIFT) 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_cistruct rx_tpa_end_cmp { 38962306a36Sopenharmony_ci __le32 rx_tpa_end_cmp_len_flags_type; 39062306a36Sopenharmony_ci #define RX_TPA_END_CMP_TYPE (0x3f << 0) 39162306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS (0x3ff << 6) 39262306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_SHIFT 6 39362306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_PLACEMENT (0x7 << 7) 39462306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_PLACEMENT_SHIFT 7 39562306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_PLACEMENT_JUMBO (0x1 << 7) 39662306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_PLACEMENT_HDS (0x2 << 7) 39762306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO (0x5 << 7) 39862306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS (0x6 << 7) 39962306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_RSS_VALID (0x1 << 10) 40062306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_ITYPES (0xf << 12) 40162306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_ITYPES_SHIFT 12 40262306a36Sopenharmony_ci #define RX_TPA_END_CMP_FLAGS_ITYPE_TCP (0x2 << 12) 40362306a36Sopenharmony_ci #define RX_TPA_END_CMP_LEN (0xffff << 16) 40462306a36Sopenharmony_ci #define RX_TPA_END_CMP_LEN_SHIFT 16 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci u32 rx_tpa_end_cmp_opaque; 40762306a36Sopenharmony_ci __le32 rx_tpa_end_cmp_misc_v1; 40862306a36Sopenharmony_ci #define RX_TPA_END_CMP_V1 (0x1 << 0) 40962306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_BUFS (0x3f << 1) 41062306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_BUFS_SHIFT 1 41162306a36Sopenharmony_ci #define RX_TPA_END_CMP_TPA_SEGS (0xff << 8) 41262306a36Sopenharmony_ci #define RX_TPA_END_CMP_TPA_SEGS_SHIFT 8 41362306a36Sopenharmony_ci #define RX_TPA_END_CMP_PAYLOAD_OFFSET (0xff << 16) 41462306a36Sopenharmony_ci #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT 16 41562306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_ID (0x7f << 25) 41662306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_ID_SHIFT 25 41762306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_ID_P5 (0xffff << 16) 41862306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_ID_SHIFT_P5 16 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci __le32 rx_tpa_end_cmp_tsdelta; 42162306a36Sopenharmony_ci #define RX_TPA_END_GRO_TS (0x1 << 31) 42262306a36Sopenharmony_ci}; 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ci#define TPA_END_AGG_ID(rx_tpa_end) \ 42562306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ 42662306a36Sopenharmony_ci RX_TPA_END_CMP_AGG_ID) >> RX_TPA_END_CMP_AGG_ID_SHIFT) 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci#define TPA_END_AGG_ID_P5(rx_tpa_end) \ 42962306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ 43062306a36Sopenharmony_ci RX_TPA_END_CMP_AGG_ID_P5) >> RX_TPA_END_CMP_AGG_ID_SHIFT_P5) 43162306a36Sopenharmony_ci 43262306a36Sopenharmony_ci#define TPA_END_PAYLOAD_OFF(rx_tpa_end) \ 43362306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ 43462306a36Sopenharmony_ci RX_TPA_END_CMP_PAYLOAD_OFFSET) >> RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT) 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_ci#define TPA_END_AGG_BUFS(rx_tpa_end) \ 43762306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ 43862306a36Sopenharmony_ci RX_TPA_END_CMP_AGG_BUFS) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT) 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci#define TPA_END_TPA_SEGS(rx_tpa_end) \ 44162306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_end)->rx_tpa_end_cmp_misc_v1) & \ 44262306a36Sopenharmony_ci RX_TPA_END_CMP_TPA_SEGS) >> RX_TPA_END_CMP_TPA_SEGS_SHIFT) 44362306a36Sopenharmony_ci 44462306a36Sopenharmony_ci#define RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO \ 44562306a36Sopenharmony_ci cpu_to_le32(RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_JUMBO & \ 44662306a36Sopenharmony_ci RX_TPA_END_CMP_FLAGS_PLACEMENT_GRO_HDS) 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_ci#define TPA_END_GRO(rx_tpa_end) \ 44962306a36Sopenharmony_ci ((rx_tpa_end)->rx_tpa_end_cmp_len_flags_type & \ 45062306a36Sopenharmony_ci RX_TPA_END_CMP_FLAGS_PLACEMENT_ANY_GRO) 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci#define TPA_END_GRO_TS(rx_tpa_end) \ 45362306a36Sopenharmony_ci (!!((rx_tpa_end)->rx_tpa_end_cmp_tsdelta & \ 45462306a36Sopenharmony_ci cpu_to_le32(RX_TPA_END_GRO_TS))) 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_cistruct rx_tpa_end_cmp_ext { 45762306a36Sopenharmony_ci __le32 rx_tpa_end_cmp_dup_acks; 45862306a36Sopenharmony_ci #define RX_TPA_END_CMP_TPA_DUP_ACKS (0xf << 0) 45962306a36Sopenharmony_ci #define RX_TPA_END_CMP_PAYLOAD_OFFSET_P5 (0xff << 16) 46062306a36Sopenharmony_ci #define RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5 16 46162306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_BUFS_P5 (0xff << 24) 46262306a36Sopenharmony_ci #define RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5 24 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci __le32 rx_tpa_end_cmp_seg_len; 46562306a36Sopenharmony_ci #define RX_TPA_END_CMP_TPA_SEG_LEN (0xffff << 0) 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci __le32 rx_tpa_end_cmp_errors_v2; 46862306a36Sopenharmony_ci #define RX_TPA_END_CMP_V2 (0x1 << 0) 46962306a36Sopenharmony_ci #define RX_TPA_END_CMP_ERRORS (0x3 << 1) 47062306a36Sopenharmony_ci #define RX_TPA_END_CMP_ERRORS_P5 (0x7 << 1) 47162306a36Sopenharmony_ci #define RX_TPA_END_CMPL_ERRORS_SHIFT 1 47262306a36Sopenharmony_ci #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0 << 1) 47362306a36Sopenharmony_ci #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2 << 1) 47462306a36Sopenharmony_ci #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3 << 1) 47562306a36Sopenharmony_ci #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_RSV_ERROR (0x4 << 1) 47662306a36Sopenharmony_ci #define RX_TPA_END_CMP_ERRORS_BUFFER_ERROR_FLUSH (0x5 << 1) 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_ci u32 rx_tpa_end_cmp_start_opaque; 47962306a36Sopenharmony_ci}; 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_ci#define TPA_END_ERRORS(rx_tpa_end_ext) \ 48262306a36Sopenharmony_ci ((rx_tpa_end_ext)->rx_tpa_end_cmp_errors_v2 & \ 48362306a36Sopenharmony_ci cpu_to_le32(RX_TPA_END_CMP_ERRORS)) 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci#define TPA_END_PAYLOAD_OFF_P5(rx_tpa_end_ext) \ 48662306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \ 48762306a36Sopenharmony_ci RX_TPA_END_CMP_PAYLOAD_OFFSET_P5) >> \ 48862306a36Sopenharmony_ci RX_TPA_END_CMP_PAYLOAD_OFFSET_SHIFT_P5) 48962306a36Sopenharmony_ci 49062306a36Sopenharmony_ci#define TPA_END_AGG_BUFS_P5(rx_tpa_end_ext) \ 49162306a36Sopenharmony_ci ((le32_to_cpu((rx_tpa_end_ext)->rx_tpa_end_cmp_dup_acks) & \ 49262306a36Sopenharmony_ci RX_TPA_END_CMP_AGG_BUFS_P5) >> RX_TPA_END_CMP_AGG_BUFS_SHIFT_P5) 49362306a36Sopenharmony_ci 49462306a36Sopenharmony_ci#define EVENT_DATA1_RESET_NOTIFY_FATAL(data1) \ 49562306a36Sopenharmony_ci (((data1) & \ 49662306a36Sopenharmony_ci ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\ 49762306a36Sopenharmony_ci ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL) 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_ci#define EVENT_DATA1_RESET_NOTIFY_FW_ACTIVATION(data1) \ 50062306a36Sopenharmony_ci (((data1) & \ 50162306a36Sopenharmony_ci ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\ 50262306a36Sopenharmony_ci ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_ACTIVATION) 50362306a36Sopenharmony_ci 50462306a36Sopenharmony_ci#define EVENT_DATA2_RESET_NOTIFY_FW_STATUS_CODE(data2) \ 50562306a36Sopenharmony_ci ((data2) & \ 50662306a36Sopenharmony_ci ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_MASK) 50762306a36Sopenharmony_ci 50862306a36Sopenharmony_ci#define EVENT_DATA1_RECOVERY_MASTER_FUNC(data1) \ 50962306a36Sopenharmony_ci !!((data1) & \ 51062306a36Sopenharmony_ci ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC) 51162306a36Sopenharmony_ci 51262306a36Sopenharmony_ci#define EVENT_DATA1_RECOVERY_ENABLED(data1) \ 51362306a36Sopenharmony_ci !!((data1) & \ 51462306a36Sopenharmony_ci ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED) 51562306a36Sopenharmony_ci 51662306a36Sopenharmony_ci#define BNXT_EVENT_ERROR_REPORT_TYPE(data1) \ 51762306a36Sopenharmony_ci (((data1) & \ 51862306a36Sopenharmony_ci ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_MASK) >>\ 51962306a36Sopenharmony_ci ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_SFT) 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ci#define BNXT_EVENT_INVALID_SIGNAL_DATA(data2) \ 52262306a36Sopenharmony_ci (((data2) & \ 52362306a36Sopenharmony_ci ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_MASK) >>\ 52462306a36Sopenharmony_ci ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_SFT) 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_cistruct nqe_cn { 52762306a36Sopenharmony_ci __le16 type; 52862306a36Sopenharmony_ci #define NQ_CN_TYPE_MASK 0x3fUL 52962306a36Sopenharmony_ci #define NQ_CN_TYPE_SFT 0 53062306a36Sopenharmony_ci #define NQ_CN_TYPE_CQ_NOTIFICATION 0x30UL 53162306a36Sopenharmony_ci #define NQ_CN_TYPE_LAST NQ_CN_TYPE_CQ_NOTIFICATION 53262306a36Sopenharmony_ci __le16 reserved16; 53362306a36Sopenharmony_ci __le32 cq_handle_low; 53462306a36Sopenharmony_ci __le32 v; 53562306a36Sopenharmony_ci #define NQ_CN_V 0x1UL 53662306a36Sopenharmony_ci __le32 cq_handle_high; 53762306a36Sopenharmony_ci}; 53862306a36Sopenharmony_ci 53962306a36Sopenharmony_ci#define DB_IDX_MASK 0xffffff 54062306a36Sopenharmony_ci#define DB_IDX_VALID (0x1 << 26) 54162306a36Sopenharmony_ci#define DB_IRQ_DIS (0x1 << 27) 54262306a36Sopenharmony_ci#define DB_KEY_TX (0x0 << 28) 54362306a36Sopenharmony_ci#define DB_KEY_RX (0x1 << 28) 54462306a36Sopenharmony_ci#define DB_KEY_CP (0x2 << 28) 54562306a36Sopenharmony_ci#define DB_KEY_ST (0x3 << 28) 54662306a36Sopenharmony_ci#define DB_KEY_TX_PUSH (0x4 << 28) 54762306a36Sopenharmony_ci#define DB_LONG_TX_PUSH (0x2 << 24) 54862306a36Sopenharmony_ci 54962306a36Sopenharmony_ci#define BNXT_MIN_ROCE_CP_RINGS 2 55062306a36Sopenharmony_ci#define BNXT_MIN_ROCE_STAT_CTXS 1 55162306a36Sopenharmony_ci 55262306a36Sopenharmony_ci/* 64-bit doorbell */ 55362306a36Sopenharmony_ci#define DBR_INDEX_MASK 0x0000000000ffffffULL 55462306a36Sopenharmony_ci#define DBR_XID_MASK 0x000fffff00000000ULL 55562306a36Sopenharmony_ci#define DBR_XID_SFT 32 55662306a36Sopenharmony_ci#define DBR_PATH_L2 (0x1ULL << 56) 55762306a36Sopenharmony_ci#define DBR_TYPE_SQ (0x0ULL << 60) 55862306a36Sopenharmony_ci#define DBR_TYPE_RQ (0x1ULL << 60) 55962306a36Sopenharmony_ci#define DBR_TYPE_SRQ (0x2ULL << 60) 56062306a36Sopenharmony_ci#define DBR_TYPE_SRQ_ARM (0x3ULL << 60) 56162306a36Sopenharmony_ci#define DBR_TYPE_CQ (0x4ULL << 60) 56262306a36Sopenharmony_ci#define DBR_TYPE_CQ_ARMSE (0x5ULL << 60) 56362306a36Sopenharmony_ci#define DBR_TYPE_CQ_ARMALL (0x6ULL << 60) 56462306a36Sopenharmony_ci#define DBR_TYPE_CQ_ARMENA (0x7ULL << 60) 56562306a36Sopenharmony_ci#define DBR_TYPE_SRQ_ARMENA (0x8ULL << 60) 56662306a36Sopenharmony_ci#define DBR_TYPE_CQ_CUTOFF_ACK (0x9ULL << 60) 56762306a36Sopenharmony_ci#define DBR_TYPE_NQ (0xaULL << 60) 56862306a36Sopenharmony_ci#define DBR_TYPE_NQ_ARM (0xbULL << 60) 56962306a36Sopenharmony_ci#define DBR_TYPE_NULL (0xfULL << 60) 57062306a36Sopenharmony_ci 57162306a36Sopenharmony_ci#define DB_PF_OFFSET_P5 0x10000 57262306a36Sopenharmony_ci#define DB_VF_OFFSET_P5 0x4000 57362306a36Sopenharmony_ci 57462306a36Sopenharmony_ci#define INVALID_HW_RING_ID ((u16)-1) 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_ci/* The hardware supports certain page sizes. Use the supported page sizes 57762306a36Sopenharmony_ci * to allocate the rings. 57862306a36Sopenharmony_ci */ 57962306a36Sopenharmony_ci#if (PAGE_SHIFT < 12) 58062306a36Sopenharmony_ci#define BNXT_PAGE_SHIFT 12 58162306a36Sopenharmony_ci#elif (PAGE_SHIFT <= 13) 58262306a36Sopenharmony_ci#define BNXT_PAGE_SHIFT PAGE_SHIFT 58362306a36Sopenharmony_ci#elif (PAGE_SHIFT < 16) 58462306a36Sopenharmony_ci#define BNXT_PAGE_SHIFT 13 58562306a36Sopenharmony_ci#else 58662306a36Sopenharmony_ci#define BNXT_PAGE_SHIFT 16 58762306a36Sopenharmony_ci#endif 58862306a36Sopenharmony_ci 58962306a36Sopenharmony_ci#define BNXT_PAGE_SIZE (1 << BNXT_PAGE_SHIFT) 59062306a36Sopenharmony_ci 59162306a36Sopenharmony_ci/* The RXBD length is 16-bit so we can only support page sizes < 64K */ 59262306a36Sopenharmony_ci#if (PAGE_SHIFT > 15) 59362306a36Sopenharmony_ci#define BNXT_RX_PAGE_SHIFT 15 59462306a36Sopenharmony_ci#else 59562306a36Sopenharmony_ci#define BNXT_RX_PAGE_SHIFT PAGE_SHIFT 59662306a36Sopenharmony_ci#endif 59762306a36Sopenharmony_ci 59862306a36Sopenharmony_ci#define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT) 59962306a36Sopenharmony_ci 60062306a36Sopenharmony_ci#define BNXT_MAX_MTU 9500 60162306a36Sopenharmony_ci 60262306a36Sopenharmony_ci/* First RX buffer page in XDP multi-buf mode 60362306a36Sopenharmony_ci * 60462306a36Sopenharmony_ci * +-------------------------------------------------------------------------+ 60562306a36Sopenharmony_ci * | XDP_PACKET_HEADROOM | bp->rx_buf_use_size | skb_shared_info| 60662306a36Sopenharmony_ci * | (bp->rx_dma_offset) | | | 60762306a36Sopenharmony_ci * +-------------------------------------------------------------------------+ 60862306a36Sopenharmony_ci */ 60962306a36Sopenharmony_ci#define BNXT_MAX_PAGE_MODE_MTU_SBUF \ 61062306a36Sopenharmony_ci ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ 61162306a36Sopenharmony_ci XDP_PACKET_HEADROOM) 61262306a36Sopenharmony_ci#define BNXT_MAX_PAGE_MODE_MTU \ 61362306a36Sopenharmony_ci (BNXT_MAX_PAGE_MODE_MTU_SBUF - \ 61462306a36Sopenharmony_ci SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info))) 61562306a36Sopenharmony_ci 61662306a36Sopenharmony_ci#define BNXT_MIN_PKT_SIZE 52 61762306a36Sopenharmony_ci 61862306a36Sopenharmony_ci#define BNXT_DEFAULT_RX_RING_SIZE 511 61962306a36Sopenharmony_ci#define BNXT_DEFAULT_TX_RING_SIZE 511 62062306a36Sopenharmony_ci 62162306a36Sopenharmony_ci#define MAX_TPA 64 62262306a36Sopenharmony_ci#define MAX_TPA_P5 256 62362306a36Sopenharmony_ci#define MAX_TPA_P5_MASK (MAX_TPA_P5 - 1) 62462306a36Sopenharmony_ci#define MAX_TPA_SEGS_P5 0x3f 62562306a36Sopenharmony_ci 62662306a36Sopenharmony_ci#if (BNXT_PAGE_SHIFT == 16) 62762306a36Sopenharmony_ci#define MAX_RX_PAGES_AGG_ENA 1 62862306a36Sopenharmony_ci#define MAX_RX_PAGES 4 62962306a36Sopenharmony_ci#define MAX_RX_AGG_PAGES 4 63062306a36Sopenharmony_ci#define MAX_TX_PAGES 1 63162306a36Sopenharmony_ci#define MAX_CP_PAGES 16 63262306a36Sopenharmony_ci#else 63362306a36Sopenharmony_ci#define MAX_RX_PAGES_AGG_ENA 8 63462306a36Sopenharmony_ci#define MAX_RX_PAGES 32 63562306a36Sopenharmony_ci#define MAX_RX_AGG_PAGES 32 63662306a36Sopenharmony_ci#define MAX_TX_PAGES 8 63762306a36Sopenharmony_ci#define MAX_CP_PAGES 128 63862306a36Sopenharmony_ci#endif 63962306a36Sopenharmony_ci 64062306a36Sopenharmony_ci#define RX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct rx_bd)) 64162306a36Sopenharmony_ci#define TX_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_bd)) 64262306a36Sopenharmony_ci#define CP_DESC_CNT (BNXT_PAGE_SIZE / sizeof(struct tx_cmp)) 64362306a36Sopenharmony_ci 64462306a36Sopenharmony_ci#define SW_RXBD_RING_SIZE (sizeof(struct bnxt_sw_rx_bd) * RX_DESC_CNT) 64562306a36Sopenharmony_ci#define HW_RXBD_RING_SIZE (sizeof(struct rx_bd) * RX_DESC_CNT) 64662306a36Sopenharmony_ci 64762306a36Sopenharmony_ci#define SW_RXBD_AGG_RING_SIZE (sizeof(struct bnxt_sw_rx_agg_bd) * RX_DESC_CNT) 64862306a36Sopenharmony_ci 64962306a36Sopenharmony_ci#define SW_TXBD_RING_SIZE (sizeof(struct bnxt_sw_tx_bd) * TX_DESC_CNT) 65062306a36Sopenharmony_ci#define HW_TXBD_RING_SIZE (sizeof(struct tx_bd) * TX_DESC_CNT) 65162306a36Sopenharmony_ci 65262306a36Sopenharmony_ci#define HW_CMPD_RING_SIZE (sizeof(struct tx_cmp) * CP_DESC_CNT) 65362306a36Sopenharmony_ci 65462306a36Sopenharmony_ci#define BNXT_MAX_RX_DESC_CNT (RX_DESC_CNT * MAX_RX_PAGES - 1) 65562306a36Sopenharmony_ci#define BNXT_MAX_RX_DESC_CNT_JUM_ENA (RX_DESC_CNT * MAX_RX_PAGES_AGG_ENA - 1) 65662306a36Sopenharmony_ci#define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1) 65762306a36Sopenharmony_ci#define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1) 65862306a36Sopenharmony_ci 65962306a36Sopenharmony_ci/* Minimum TX BDs for a TX packet with MAX_SKB_FRAGS + 1. We need one extra 66062306a36Sopenharmony_ci * BD because the first TX BD is always a long BD. 66162306a36Sopenharmony_ci */ 66262306a36Sopenharmony_ci#define BNXT_MIN_TX_DESC_CNT (MAX_SKB_FRAGS + 2) 66362306a36Sopenharmony_ci 66462306a36Sopenharmony_ci#define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) 66562306a36Sopenharmony_ci#define RX_IDX(x) ((x) & (RX_DESC_CNT - 1)) 66662306a36Sopenharmony_ci 66762306a36Sopenharmony_ci#define TX_RING(x) (((x) & ~(TX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) 66862306a36Sopenharmony_ci#define TX_IDX(x) ((x) & (TX_DESC_CNT - 1)) 66962306a36Sopenharmony_ci 67062306a36Sopenharmony_ci#define CP_RING(x) (((x) & ~(CP_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) 67162306a36Sopenharmony_ci#define CP_IDX(x) ((x) & (CP_DESC_CNT - 1)) 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_ci#define TX_CMP_VALID(txcmp, raw_cons) \ 67462306a36Sopenharmony_ci (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) == \ 67562306a36Sopenharmony_ci !((raw_cons) & bp->cp_bit)) 67662306a36Sopenharmony_ci 67762306a36Sopenharmony_ci#define RX_CMP_VALID(rxcmp1, raw_cons) \ 67862306a36Sopenharmony_ci (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\ 67962306a36Sopenharmony_ci !((raw_cons) & bp->cp_bit)) 68062306a36Sopenharmony_ci 68162306a36Sopenharmony_ci#define RX_AGG_CMP_VALID(agg, raw_cons) \ 68262306a36Sopenharmony_ci (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \ 68362306a36Sopenharmony_ci !((raw_cons) & bp->cp_bit)) 68462306a36Sopenharmony_ci 68562306a36Sopenharmony_ci#define NQ_CMP_VALID(nqcmp, raw_cons) \ 68662306a36Sopenharmony_ci (!!((nqcmp)->v & cpu_to_le32(NQ_CN_V)) == !((raw_cons) & bp->cp_bit)) 68762306a36Sopenharmony_ci 68862306a36Sopenharmony_ci#define TX_CMP_TYPE(txcmp) \ 68962306a36Sopenharmony_ci (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE) 69062306a36Sopenharmony_ci 69162306a36Sopenharmony_ci#define RX_CMP_TYPE(rxcmp) \ 69262306a36Sopenharmony_ci (le32_to_cpu((rxcmp)->rx_cmp_len_flags_type) & RX_CMP_CMP_TYPE) 69362306a36Sopenharmony_ci 69462306a36Sopenharmony_ci#define NEXT_RX(idx) (((idx) + 1) & bp->rx_ring_mask) 69562306a36Sopenharmony_ci 69662306a36Sopenharmony_ci#define NEXT_RX_AGG(idx) (((idx) + 1) & bp->rx_agg_ring_mask) 69762306a36Sopenharmony_ci 69862306a36Sopenharmony_ci#define NEXT_TX(idx) (((idx) + 1) & bp->tx_ring_mask) 69962306a36Sopenharmony_ci 70062306a36Sopenharmony_ci#define ADV_RAW_CMP(idx, n) ((idx) + (n)) 70162306a36Sopenharmony_ci#define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1) 70262306a36Sopenharmony_ci#define RING_CMP(idx) ((idx) & bp->cp_ring_mask) 70362306a36Sopenharmony_ci#define NEXT_CMP(idx) RING_CMP(ADV_RAW_CMP(idx, 1)) 70462306a36Sopenharmony_ci 70562306a36Sopenharmony_ci#define DFLT_HWRM_CMD_TIMEOUT 500 70662306a36Sopenharmony_ci 70762306a36Sopenharmony_ci#define BNXT_RX_EVENT 1 70862306a36Sopenharmony_ci#define BNXT_AGG_EVENT 2 70962306a36Sopenharmony_ci#define BNXT_TX_EVENT 4 71062306a36Sopenharmony_ci#define BNXT_REDIRECT_EVENT 8 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_cistruct bnxt_sw_tx_bd { 71362306a36Sopenharmony_ci union { 71462306a36Sopenharmony_ci struct sk_buff *skb; 71562306a36Sopenharmony_ci struct xdp_frame *xdpf; 71662306a36Sopenharmony_ci }; 71762306a36Sopenharmony_ci DEFINE_DMA_UNMAP_ADDR(mapping); 71862306a36Sopenharmony_ci DEFINE_DMA_UNMAP_LEN(len); 71962306a36Sopenharmony_ci struct page *page; 72062306a36Sopenharmony_ci u8 is_gso; 72162306a36Sopenharmony_ci u8 is_push; 72262306a36Sopenharmony_ci u8 action; 72362306a36Sopenharmony_ci unsigned short nr_frags; 72462306a36Sopenharmony_ci u16 rx_prod; 72562306a36Sopenharmony_ci}; 72662306a36Sopenharmony_ci 72762306a36Sopenharmony_cistruct bnxt_sw_rx_bd { 72862306a36Sopenharmony_ci void *data; 72962306a36Sopenharmony_ci u8 *data_ptr; 73062306a36Sopenharmony_ci dma_addr_t mapping; 73162306a36Sopenharmony_ci}; 73262306a36Sopenharmony_ci 73362306a36Sopenharmony_cistruct bnxt_sw_rx_agg_bd { 73462306a36Sopenharmony_ci struct page *page; 73562306a36Sopenharmony_ci unsigned int offset; 73662306a36Sopenharmony_ci dma_addr_t mapping; 73762306a36Sopenharmony_ci}; 73862306a36Sopenharmony_ci 73962306a36Sopenharmony_cistruct bnxt_mem_init { 74062306a36Sopenharmony_ci u8 init_val; 74162306a36Sopenharmony_ci u16 offset; 74262306a36Sopenharmony_ci#define BNXT_MEM_INVALID_OFFSET 0xffff 74362306a36Sopenharmony_ci u16 size; 74462306a36Sopenharmony_ci}; 74562306a36Sopenharmony_ci 74662306a36Sopenharmony_cistruct bnxt_ring_mem_info { 74762306a36Sopenharmony_ci int nr_pages; 74862306a36Sopenharmony_ci int page_size; 74962306a36Sopenharmony_ci u16 flags; 75062306a36Sopenharmony_ci#define BNXT_RMEM_VALID_PTE_FLAG 1 75162306a36Sopenharmony_ci#define BNXT_RMEM_RING_PTE_FLAG 2 75262306a36Sopenharmony_ci#define BNXT_RMEM_USE_FULL_PAGE_FLAG 4 75362306a36Sopenharmony_ci 75462306a36Sopenharmony_ci u16 depth; 75562306a36Sopenharmony_ci struct bnxt_mem_init *mem_init; 75662306a36Sopenharmony_ci 75762306a36Sopenharmony_ci void **pg_arr; 75862306a36Sopenharmony_ci dma_addr_t *dma_arr; 75962306a36Sopenharmony_ci 76062306a36Sopenharmony_ci __le64 *pg_tbl; 76162306a36Sopenharmony_ci dma_addr_t pg_tbl_map; 76262306a36Sopenharmony_ci 76362306a36Sopenharmony_ci int vmem_size; 76462306a36Sopenharmony_ci void **vmem; 76562306a36Sopenharmony_ci}; 76662306a36Sopenharmony_ci 76762306a36Sopenharmony_cistruct bnxt_ring_struct { 76862306a36Sopenharmony_ci struct bnxt_ring_mem_info ring_mem; 76962306a36Sopenharmony_ci 77062306a36Sopenharmony_ci u16 fw_ring_id; /* Ring id filled by Chimp FW */ 77162306a36Sopenharmony_ci union { 77262306a36Sopenharmony_ci u16 grp_idx; 77362306a36Sopenharmony_ci u16 map_idx; /* Used by cmpl rings */ 77462306a36Sopenharmony_ci }; 77562306a36Sopenharmony_ci u32 handle; 77662306a36Sopenharmony_ci u8 queue_id; 77762306a36Sopenharmony_ci}; 77862306a36Sopenharmony_ci 77962306a36Sopenharmony_cistruct tx_push_bd { 78062306a36Sopenharmony_ci __le32 doorbell; 78162306a36Sopenharmony_ci __le32 tx_bd_len_flags_type; 78262306a36Sopenharmony_ci u32 tx_bd_opaque; 78362306a36Sopenharmony_ci struct tx_bd_ext txbd2; 78462306a36Sopenharmony_ci}; 78562306a36Sopenharmony_ci 78662306a36Sopenharmony_cistruct tx_push_buffer { 78762306a36Sopenharmony_ci struct tx_push_bd push_bd; 78862306a36Sopenharmony_ci u32 data[25]; 78962306a36Sopenharmony_ci}; 79062306a36Sopenharmony_ci 79162306a36Sopenharmony_cistruct bnxt_db_info { 79262306a36Sopenharmony_ci void __iomem *doorbell; 79362306a36Sopenharmony_ci union { 79462306a36Sopenharmony_ci u64 db_key64; 79562306a36Sopenharmony_ci u32 db_key32; 79662306a36Sopenharmony_ci }; 79762306a36Sopenharmony_ci}; 79862306a36Sopenharmony_ci 79962306a36Sopenharmony_cistruct bnxt_tx_ring_info { 80062306a36Sopenharmony_ci struct bnxt_napi *bnapi; 80162306a36Sopenharmony_ci u16 tx_prod; 80262306a36Sopenharmony_ci u16 tx_cons; 80362306a36Sopenharmony_ci u16 txq_index; 80462306a36Sopenharmony_ci u8 kick_pending; 80562306a36Sopenharmony_ci struct bnxt_db_info tx_db; 80662306a36Sopenharmony_ci 80762306a36Sopenharmony_ci struct tx_bd *tx_desc_ring[MAX_TX_PAGES]; 80862306a36Sopenharmony_ci struct bnxt_sw_tx_bd *tx_buf_ring; 80962306a36Sopenharmony_ci 81062306a36Sopenharmony_ci dma_addr_t tx_desc_mapping[MAX_TX_PAGES]; 81162306a36Sopenharmony_ci 81262306a36Sopenharmony_ci struct tx_push_buffer *tx_push; 81362306a36Sopenharmony_ci dma_addr_t tx_push_mapping; 81462306a36Sopenharmony_ci __le64 data_mapping; 81562306a36Sopenharmony_ci 81662306a36Sopenharmony_ci#define BNXT_DEV_STATE_CLOSING 0x1 81762306a36Sopenharmony_ci u32 dev_state; 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_ci struct bnxt_ring_struct tx_ring_struct; 82062306a36Sopenharmony_ci /* Synchronize simultaneous xdp_xmit on same ring */ 82162306a36Sopenharmony_ci spinlock_t xdp_tx_lock; 82262306a36Sopenharmony_ci}; 82362306a36Sopenharmony_ci 82462306a36Sopenharmony_ci#define BNXT_LEGACY_COAL_CMPL_PARAMS \ 82562306a36Sopenharmony_ci (RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MIN | \ 82662306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_INT_LAT_TMR_MAX | \ 82762306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_TIMER_RESET | \ 82862306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_RING_IDLE | \ 82962306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR | \ 83062306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_DMA_AGGR_DURING_INT | \ 83162306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR | \ 83262306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_CMPL_AGGR_DMA_TMR_DURING_INT | \ 83362306a36Sopenharmony_ci RING_AGGINT_QCAPS_RESP_CMPL_PARAMS_NUM_CMPL_AGGR_INT) 83462306a36Sopenharmony_ci 83562306a36Sopenharmony_ci#define BNXT_COAL_CMPL_ENABLES \ 83662306a36Sopenharmony_ci (RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR | \ 83762306a36Sopenharmony_ci RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_CMPL_AGGR_DMA_TMR | \ 83862306a36Sopenharmony_ci RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MAX | \ 83962306a36Sopenharmony_ci RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_AGGR_INT) 84062306a36Sopenharmony_ci 84162306a36Sopenharmony_ci#define BNXT_COAL_CMPL_MIN_TMR_ENABLE \ 84262306a36Sopenharmony_ci RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_INT_LAT_TMR_MIN 84362306a36Sopenharmony_ci 84462306a36Sopenharmony_ci#define BNXT_COAL_CMPL_AGGR_TMR_DURING_INT_ENABLE \ 84562306a36Sopenharmony_ci RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_ENABLES_NUM_CMPL_DMA_AGGR_DURING_INT 84662306a36Sopenharmony_ci 84762306a36Sopenharmony_cistruct bnxt_coal_cap { 84862306a36Sopenharmony_ci u32 cmpl_params; 84962306a36Sopenharmony_ci u32 nq_params; 85062306a36Sopenharmony_ci u16 num_cmpl_dma_aggr_max; 85162306a36Sopenharmony_ci u16 num_cmpl_dma_aggr_during_int_max; 85262306a36Sopenharmony_ci u16 cmpl_aggr_dma_tmr_max; 85362306a36Sopenharmony_ci u16 cmpl_aggr_dma_tmr_during_int_max; 85462306a36Sopenharmony_ci u16 int_lat_tmr_min_max; 85562306a36Sopenharmony_ci u16 int_lat_tmr_max_max; 85662306a36Sopenharmony_ci u16 num_cmpl_aggr_int_max; 85762306a36Sopenharmony_ci u16 timer_units; 85862306a36Sopenharmony_ci}; 85962306a36Sopenharmony_ci 86062306a36Sopenharmony_cistruct bnxt_coal { 86162306a36Sopenharmony_ci u16 coal_ticks; 86262306a36Sopenharmony_ci u16 coal_ticks_irq; 86362306a36Sopenharmony_ci u16 coal_bufs; 86462306a36Sopenharmony_ci u16 coal_bufs_irq; 86562306a36Sopenharmony_ci /* RING_IDLE enabled when coal ticks < idle_thresh */ 86662306a36Sopenharmony_ci u16 idle_thresh; 86762306a36Sopenharmony_ci u8 bufs_per_record; 86862306a36Sopenharmony_ci u8 budget; 86962306a36Sopenharmony_ci u16 flags; 87062306a36Sopenharmony_ci}; 87162306a36Sopenharmony_ci 87262306a36Sopenharmony_cistruct bnxt_tpa_info { 87362306a36Sopenharmony_ci void *data; 87462306a36Sopenharmony_ci u8 *data_ptr; 87562306a36Sopenharmony_ci dma_addr_t mapping; 87662306a36Sopenharmony_ci u16 len; 87762306a36Sopenharmony_ci unsigned short gso_type; 87862306a36Sopenharmony_ci u32 flags2; 87962306a36Sopenharmony_ci u32 metadata; 88062306a36Sopenharmony_ci enum pkt_hash_types hash_type; 88162306a36Sopenharmony_ci u32 rss_hash; 88262306a36Sopenharmony_ci u32 hdr_info; 88362306a36Sopenharmony_ci 88462306a36Sopenharmony_ci#define BNXT_TPA_L4_SIZE(hdr_info) \ 88562306a36Sopenharmony_ci (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32) 88662306a36Sopenharmony_ci 88762306a36Sopenharmony_ci#define BNXT_TPA_INNER_L3_OFF(hdr_info) \ 88862306a36Sopenharmony_ci (((hdr_info) >> 18) & 0x1ff) 88962306a36Sopenharmony_ci 89062306a36Sopenharmony_ci#define BNXT_TPA_INNER_L2_OFF(hdr_info) \ 89162306a36Sopenharmony_ci (((hdr_info) >> 9) & 0x1ff) 89262306a36Sopenharmony_ci 89362306a36Sopenharmony_ci#define BNXT_TPA_OUTER_L3_OFF(hdr_info) \ 89462306a36Sopenharmony_ci ((hdr_info) & 0x1ff) 89562306a36Sopenharmony_ci 89662306a36Sopenharmony_ci u16 cfa_code; /* cfa_code in TPA start compl */ 89762306a36Sopenharmony_ci u8 agg_count; 89862306a36Sopenharmony_ci struct rx_agg_cmp *agg_arr; 89962306a36Sopenharmony_ci}; 90062306a36Sopenharmony_ci 90162306a36Sopenharmony_ci#define BNXT_AGG_IDX_BMAP_SIZE (MAX_TPA_P5 / BITS_PER_LONG) 90262306a36Sopenharmony_ci 90362306a36Sopenharmony_cistruct bnxt_tpa_idx_map { 90462306a36Sopenharmony_ci u16 agg_id_tbl[1024]; 90562306a36Sopenharmony_ci unsigned long agg_idx_bmap[BNXT_AGG_IDX_BMAP_SIZE]; 90662306a36Sopenharmony_ci}; 90762306a36Sopenharmony_ci 90862306a36Sopenharmony_cistruct bnxt_rx_ring_info { 90962306a36Sopenharmony_ci struct bnxt_napi *bnapi; 91062306a36Sopenharmony_ci u16 rx_prod; 91162306a36Sopenharmony_ci u16 rx_agg_prod; 91262306a36Sopenharmony_ci u16 rx_sw_agg_prod; 91362306a36Sopenharmony_ci u16 rx_next_cons; 91462306a36Sopenharmony_ci struct bnxt_db_info rx_db; 91562306a36Sopenharmony_ci struct bnxt_db_info rx_agg_db; 91662306a36Sopenharmony_ci 91762306a36Sopenharmony_ci struct bpf_prog *xdp_prog; 91862306a36Sopenharmony_ci 91962306a36Sopenharmony_ci struct rx_bd *rx_desc_ring[MAX_RX_PAGES]; 92062306a36Sopenharmony_ci struct bnxt_sw_rx_bd *rx_buf_ring; 92162306a36Sopenharmony_ci 92262306a36Sopenharmony_ci struct rx_bd *rx_agg_desc_ring[MAX_RX_AGG_PAGES]; 92362306a36Sopenharmony_ci struct bnxt_sw_rx_agg_bd *rx_agg_ring; 92462306a36Sopenharmony_ci 92562306a36Sopenharmony_ci unsigned long *rx_agg_bmap; 92662306a36Sopenharmony_ci u16 rx_agg_bmap_size; 92762306a36Sopenharmony_ci 92862306a36Sopenharmony_ci dma_addr_t rx_desc_mapping[MAX_RX_PAGES]; 92962306a36Sopenharmony_ci dma_addr_t rx_agg_desc_mapping[MAX_RX_AGG_PAGES]; 93062306a36Sopenharmony_ci 93162306a36Sopenharmony_ci struct bnxt_tpa_info *rx_tpa; 93262306a36Sopenharmony_ci struct bnxt_tpa_idx_map *rx_tpa_idx_map; 93362306a36Sopenharmony_ci 93462306a36Sopenharmony_ci struct bnxt_ring_struct rx_ring_struct; 93562306a36Sopenharmony_ci struct bnxt_ring_struct rx_agg_ring_struct; 93662306a36Sopenharmony_ci struct xdp_rxq_info xdp_rxq; 93762306a36Sopenharmony_ci struct page_pool *page_pool; 93862306a36Sopenharmony_ci}; 93962306a36Sopenharmony_ci 94062306a36Sopenharmony_cistruct bnxt_rx_sw_stats { 94162306a36Sopenharmony_ci u64 rx_l4_csum_errors; 94262306a36Sopenharmony_ci u64 rx_resets; 94362306a36Sopenharmony_ci u64 rx_buf_errors; 94462306a36Sopenharmony_ci u64 rx_oom_discards; 94562306a36Sopenharmony_ci u64 rx_netpoll_discards; 94662306a36Sopenharmony_ci}; 94762306a36Sopenharmony_ci 94862306a36Sopenharmony_cistruct bnxt_tx_sw_stats { 94962306a36Sopenharmony_ci u64 tx_resets; 95062306a36Sopenharmony_ci}; 95162306a36Sopenharmony_ci 95262306a36Sopenharmony_cistruct bnxt_cmn_sw_stats { 95362306a36Sopenharmony_ci u64 missed_irqs; 95462306a36Sopenharmony_ci}; 95562306a36Sopenharmony_ci 95662306a36Sopenharmony_cistruct bnxt_sw_stats { 95762306a36Sopenharmony_ci struct bnxt_rx_sw_stats rx; 95862306a36Sopenharmony_ci struct bnxt_tx_sw_stats tx; 95962306a36Sopenharmony_ci struct bnxt_cmn_sw_stats cmn; 96062306a36Sopenharmony_ci}; 96162306a36Sopenharmony_ci 96262306a36Sopenharmony_cistruct bnxt_total_ring_err_stats { 96362306a36Sopenharmony_ci u64 rx_total_l4_csum_errors; 96462306a36Sopenharmony_ci u64 rx_total_resets; 96562306a36Sopenharmony_ci u64 rx_total_buf_errors; 96662306a36Sopenharmony_ci u64 rx_total_oom_discards; 96762306a36Sopenharmony_ci u64 rx_total_netpoll_discards; 96862306a36Sopenharmony_ci u64 rx_total_ring_discards; 96962306a36Sopenharmony_ci u64 tx_total_resets; 97062306a36Sopenharmony_ci u64 tx_total_ring_discards; 97162306a36Sopenharmony_ci u64 total_missed_irqs; 97262306a36Sopenharmony_ci}; 97362306a36Sopenharmony_ci 97462306a36Sopenharmony_cistruct bnxt_stats_mem { 97562306a36Sopenharmony_ci u64 *sw_stats; 97662306a36Sopenharmony_ci u64 *hw_masks; 97762306a36Sopenharmony_ci void *hw_stats; 97862306a36Sopenharmony_ci dma_addr_t hw_stats_map; 97962306a36Sopenharmony_ci int len; 98062306a36Sopenharmony_ci}; 98162306a36Sopenharmony_ci 98262306a36Sopenharmony_cistruct bnxt_cp_ring_info { 98362306a36Sopenharmony_ci struct bnxt_napi *bnapi; 98462306a36Sopenharmony_ci u32 cp_raw_cons; 98562306a36Sopenharmony_ci struct bnxt_db_info cp_db; 98662306a36Sopenharmony_ci 98762306a36Sopenharmony_ci u8 had_work_done:1; 98862306a36Sopenharmony_ci u8 has_more_work:1; 98962306a36Sopenharmony_ci 99062306a36Sopenharmony_ci u32 last_cp_raw_cons; 99162306a36Sopenharmony_ci 99262306a36Sopenharmony_ci struct bnxt_coal rx_ring_coal; 99362306a36Sopenharmony_ci u64 rx_packets; 99462306a36Sopenharmony_ci u64 rx_bytes; 99562306a36Sopenharmony_ci u64 event_ctr; 99662306a36Sopenharmony_ci 99762306a36Sopenharmony_ci struct dim dim; 99862306a36Sopenharmony_ci 99962306a36Sopenharmony_ci union { 100062306a36Sopenharmony_ci struct tx_cmp **cp_desc_ring; 100162306a36Sopenharmony_ci struct nqe_cn **nq_desc_ring; 100262306a36Sopenharmony_ci }; 100362306a36Sopenharmony_ci 100462306a36Sopenharmony_ci dma_addr_t *cp_desc_mapping; 100562306a36Sopenharmony_ci 100662306a36Sopenharmony_ci struct bnxt_stats_mem stats; 100762306a36Sopenharmony_ci u32 hw_stats_ctx_id; 100862306a36Sopenharmony_ci 100962306a36Sopenharmony_ci struct bnxt_sw_stats sw_stats; 101062306a36Sopenharmony_ci 101162306a36Sopenharmony_ci struct bnxt_ring_struct cp_ring_struct; 101262306a36Sopenharmony_ci 101362306a36Sopenharmony_ci struct bnxt_cp_ring_info *cp_ring_arr[2]; 101462306a36Sopenharmony_ci#define BNXT_RX_HDL 0 101562306a36Sopenharmony_ci#define BNXT_TX_HDL 1 101662306a36Sopenharmony_ci}; 101762306a36Sopenharmony_ci 101862306a36Sopenharmony_cistruct bnxt_napi { 101962306a36Sopenharmony_ci struct napi_struct napi; 102062306a36Sopenharmony_ci struct bnxt *bp; 102162306a36Sopenharmony_ci 102262306a36Sopenharmony_ci int index; 102362306a36Sopenharmony_ci struct bnxt_cp_ring_info cp_ring; 102462306a36Sopenharmony_ci struct bnxt_rx_ring_info *rx_ring; 102562306a36Sopenharmony_ci struct bnxt_tx_ring_info *tx_ring; 102662306a36Sopenharmony_ci 102762306a36Sopenharmony_ci void (*tx_int)(struct bnxt *, struct bnxt_napi *, 102862306a36Sopenharmony_ci int budget); 102962306a36Sopenharmony_ci int tx_pkts; 103062306a36Sopenharmony_ci u8 events; 103162306a36Sopenharmony_ci u8 tx_fault:1; 103262306a36Sopenharmony_ci 103362306a36Sopenharmony_ci u32 flags; 103462306a36Sopenharmony_ci#define BNXT_NAPI_FLAG_XDP 0x1 103562306a36Sopenharmony_ci 103662306a36Sopenharmony_ci bool in_reset; 103762306a36Sopenharmony_ci}; 103862306a36Sopenharmony_ci 103962306a36Sopenharmony_cistruct bnxt_irq { 104062306a36Sopenharmony_ci irq_handler_t handler; 104162306a36Sopenharmony_ci unsigned int vector; 104262306a36Sopenharmony_ci u8 requested:1; 104362306a36Sopenharmony_ci u8 have_cpumask:1; 104462306a36Sopenharmony_ci char name[IFNAMSIZ + 2]; 104562306a36Sopenharmony_ci cpumask_var_t cpu_mask; 104662306a36Sopenharmony_ci}; 104762306a36Sopenharmony_ci 104862306a36Sopenharmony_ci#define HWRM_RING_ALLOC_TX 0x1 104962306a36Sopenharmony_ci#define HWRM_RING_ALLOC_RX 0x2 105062306a36Sopenharmony_ci#define HWRM_RING_ALLOC_AGG 0x4 105162306a36Sopenharmony_ci#define HWRM_RING_ALLOC_CMPL 0x8 105262306a36Sopenharmony_ci#define HWRM_RING_ALLOC_NQ 0x10 105362306a36Sopenharmony_ci 105462306a36Sopenharmony_ci#define INVALID_STATS_CTX_ID -1 105562306a36Sopenharmony_ci 105662306a36Sopenharmony_cistruct bnxt_ring_grp_info { 105762306a36Sopenharmony_ci u16 fw_stats_ctx; 105862306a36Sopenharmony_ci u16 fw_grp_id; 105962306a36Sopenharmony_ci u16 rx_fw_ring_id; 106062306a36Sopenharmony_ci u16 agg_fw_ring_id; 106162306a36Sopenharmony_ci u16 cp_fw_ring_id; 106262306a36Sopenharmony_ci}; 106362306a36Sopenharmony_ci 106462306a36Sopenharmony_cistruct bnxt_vnic_info { 106562306a36Sopenharmony_ci u16 fw_vnic_id; /* returned by Chimp during alloc */ 106662306a36Sopenharmony_ci#define BNXT_MAX_CTX_PER_VNIC 8 106762306a36Sopenharmony_ci u16 fw_rss_cos_lb_ctx[BNXT_MAX_CTX_PER_VNIC]; 106862306a36Sopenharmony_ci u16 fw_l2_ctx_id; 106962306a36Sopenharmony_ci#define BNXT_MAX_UC_ADDRS 4 107062306a36Sopenharmony_ci __le64 fw_l2_filter_id[BNXT_MAX_UC_ADDRS]; 107162306a36Sopenharmony_ci /* index 0 always dev_addr */ 107262306a36Sopenharmony_ci u16 uc_filter_count; 107362306a36Sopenharmony_ci u8 *uc_list; 107462306a36Sopenharmony_ci 107562306a36Sopenharmony_ci u16 *fw_grp_ids; 107662306a36Sopenharmony_ci dma_addr_t rss_table_dma_addr; 107762306a36Sopenharmony_ci __le16 *rss_table; 107862306a36Sopenharmony_ci dma_addr_t rss_hash_key_dma_addr; 107962306a36Sopenharmony_ci u64 *rss_hash_key; 108062306a36Sopenharmony_ci int rss_table_size; 108162306a36Sopenharmony_ci#define BNXT_RSS_TABLE_ENTRIES_P5 64 108262306a36Sopenharmony_ci#define BNXT_RSS_TABLE_SIZE_P5 (BNXT_RSS_TABLE_ENTRIES_P5 * 4) 108362306a36Sopenharmony_ci#define BNXT_RSS_TABLE_MAX_TBL_P5 8 108462306a36Sopenharmony_ci#define BNXT_MAX_RSS_TABLE_SIZE_P5 \ 108562306a36Sopenharmony_ci (BNXT_RSS_TABLE_SIZE_P5 * BNXT_RSS_TABLE_MAX_TBL_P5) 108662306a36Sopenharmony_ci#define BNXT_MAX_RSS_TABLE_ENTRIES_P5 \ 108762306a36Sopenharmony_ci (BNXT_RSS_TABLE_ENTRIES_P5 * BNXT_RSS_TABLE_MAX_TBL_P5) 108862306a36Sopenharmony_ci 108962306a36Sopenharmony_ci u32 rx_mask; 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_ci u8 *mc_list; 109262306a36Sopenharmony_ci int mc_list_size; 109362306a36Sopenharmony_ci int mc_list_count; 109462306a36Sopenharmony_ci dma_addr_t mc_list_mapping; 109562306a36Sopenharmony_ci#define BNXT_MAX_MC_ADDRS 16 109662306a36Sopenharmony_ci 109762306a36Sopenharmony_ci u32 flags; 109862306a36Sopenharmony_ci#define BNXT_VNIC_RSS_FLAG 1 109962306a36Sopenharmony_ci#define BNXT_VNIC_RFS_FLAG 2 110062306a36Sopenharmony_ci#define BNXT_VNIC_MCAST_FLAG 4 110162306a36Sopenharmony_ci#define BNXT_VNIC_UCAST_FLAG 8 110262306a36Sopenharmony_ci#define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10 110362306a36Sopenharmony_ci}; 110462306a36Sopenharmony_ci 110562306a36Sopenharmony_cistruct bnxt_hw_resc { 110662306a36Sopenharmony_ci u16 min_rsscos_ctxs; 110762306a36Sopenharmony_ci u16 max_rsscos_ctxs; 110862306a36Sopenharmony_ci u16 min_cp_rings; 110962306a36Sopenharmony_ci u16 max_cp_rings; 111062306a36Sopenharmony_ci u16 resv_cp_rings; 111162306a36Sopenharmony_ci u16 min_tx_rings; 111262306a36Sopenharmony_ci u16 max_tx_rings; 111362306a36Sopenharmony_ci u16 resv_tx_rings; 111462306a36Sopenharmony_ci u16 max_tx_sch_inputs; 111562306a36Sopenharmony_ci u16 min_rx_rings; 111662306a36Sopenharmony_ci u16 max_rx_rings; 111762306a36Sopenharmony_ci u16 resv_rx_rings; 111862306a36Sopenharmony_ci u16 min_hw_ring_grps; 111962306a36Sopenharmony_ci u16 max_hw_ring_grps; 112062306a36Sopenharmony_ci u16 resv_hw_ring_grps; 112162306a36Sopenharmony_ci u16 min_l2_ctxs; 112262306a36Sopenharmony_ci u16 max_l2_ctxs; 112362306a36Sopenharmony_ci u16 min_vnics; 112462306a36Sopenharmony_ci u16 max_vnics; 112562306a36Sopenharmony_ci u16 resv_vnics; 112662306a36Sopenharmony_ci u16 min_stat_ctxs; 112762306a36Sopenharmony_ci u16 max_stat_ctxs; 112862306a36Sopenharmony_ci u16 resv_stat_ctxs; 112962306a36Sopenharmony_ci u16 max_nqs; 113062306a36Sopenharmony_ci u16 max_irqs; 113162306a36Sopenharmony_ci u16 resv_irqs; 113262306a36Sopenharmony_ci}; 113362306a36Sopenharmony_ci 113462306a36Sopenharmony_ci#if defined(CONFIG_BNXT_SRIOV) 113562306a36Sopenharmony_cistruct bnxt_vf_info { 113662306a36Sopenharmony_ci u16 fw_fid; 113762306a36Sopenharmony_ci u8 mac_addr[ETH_ALEN]; /* PF assigned MAC Address */ 113862306a36Sopenharmony_ci u8 vf_mac_addr[ETH_ALEN]; /* VF assigned MAC address, only 113962306a36Sopenharmony_ci * stored by PF. 114062306a36Sopenharmony_ci */ 114162306a36Sopenharmony_ci u16 vlan; 114262306a36Sopenharmony_ci u16 func_qcfg_flags; 114362306a36Sopenharmony_ci u32 flags; 114462306a36Sopenharmony_ci#define BNXT_VF_QOS 0x1 114562306a36Sopenharmony_ci#define BNXT_VF_SPOOFCHK 0x2 114662306a36Sopenharmony_ci#define BNXT_VF_LINK_FORCED 0x4 114762306a36Sopenharmony_ci#define BNXT_VF_LINK_UP 0x8 114862306a36Sopenharmony_ci#define BNXT_VF_TRUST 0x10 114962306a36Sopenharmony_ci u32 min_tx_rate; 115062306a36Sopenharmony_ci u32 max_tx_rate; 115162306a36Sopenharmony_ci void *hwrm_cmd_req_addr; 115262306a36Sopenharmony_ci dma_addr_t hwrm_cmd_req_dma_addr; 115362306a36Sopenharmony_ci}; 115462306a36Sopenharmony_ci#endif 115562306a36Sopenharmony_ci 115662306a36Sopenharmony_cistruct bnxt_pf_info { 115762306a36Sopenharmony_ci#define BNXT_FIRST_PF_FID 1 115862306a36Sopenharmony_ci#define BNXT_FIRST_VF_FID 128 115962306a36Sopenharmony_ci u16 fw_fid; 116062306a36Sopenharmony_ci u16 port_id; 116162306a36Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 116262306a36Sopenharmony_ci u32 first_vf_id; 116362306a36Sopenharmony_ci u16 active_vfs; 116462306a36Sopenharmony_ci u16 registered_vfs; 116562306a36Sopenharmony_ci u16 max_vfs; 116662306a36Sopenharmony_ci u32 max_encap_records; 116762306a36Sopenharmony_ci u32 max_decap_records; 116862306a36Sopenharmony_ci u32 max_tx_em_flows; 116962306a36Sopenharmony_ci u32 max_tx_wm_flows; 117062306a36Sopenharmony_ci u32 max_rx_em_flows; 117162306a36Sopenharmony_ci u32 max_rx_wm_flows; 117262306a36Sopenharmony_ci unsigned long *vf_event_bmap; 117362306a36Sopenharmony_ci u16 hwrm_cmd_req_pages; 117462306a36Sopenharmony_ci u8 vf_resv_strategy; 117562306a36Sopenharmony_ci#define BNXT_VF_RESV_STRATEGY_MAXIMAL 0 117662306a36Sopenharmony_ci#define BNXT_VF_RESV_STRATEGY_MINIMAL 1 117762306a36Sopenharmony_ci#define BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC 2 117862306a36Sopenharmony_ci void *hwrm_cmd_req_addr[4]; 117962306a36Sopenharmony_ci dma_addr_t hwrm_cmd_req_dma_addr[4]; 118062306a36Sopenharmony_ci struct bnxt_vf_info *vf; 118162306a36Sopenharmony_ci}; 118262306a36Sopenharmony_ci 118362306a36Sopenharmony_cistruct bnxt_ntuple_filter { 118462306a36Sopenharmony_ci struct hlist_node hash; 118562306a36Sopenharmony_ci u8 dst_mac_addr[ETH_ALEN]; 118662306a36Sopenharmony_ci u8 src_mac_addr[ETH_ALEN]; 118762306a36Sopenharmony_ci struct flow_keys fkeys; 118862306a36Sopenharmony_ci __le64 filter_id; 118962306a36Sopenharmony_ci u16 sw_id; 119062306a36Sopenharmony_ci u8 l2_fltr_idx; 119162306a36Sopenharmony_ci u16 rxq; 119262306a36Sopenharmony_ci u32 flow_id; 119362306a36Sopenharmony_ci unsigned long state; 119462306a36Sopenharmony_ci#define BNXT_FLTR_VALID 0 119562306a36Sopenharmony_ci#define BNXT_FLTR_UPDATE 1 119662306a36Sopenharmony_ci}; 119762306a36Sopenharmony_ci 119862306a36Sopenharmony_cistruct bnxt_link_info { 119962306a36Sopenharmony_ci u8 phy_type; 120062306a36Sopenharmony_ci u8 media_type; 120162306a36Sopenharmony_ci u8 transceiver; 120262306a36Sopenharmony_ci u8 phy_addr; 120362306a36Sopenharmony_ci u8 phy_link_status; 120462306a36Sopenharmony_ci#define BNXT_LINK_NO_LINK PORT_PHY_QCFG_RESP_LINK_NO_LINK 120562306a36Sopenharmony_ci#define BNXT_LINK_SIGNAL PORT_PHY_QCFG_RESP_LINK_SIGNAL 120662306a36Sopenharmony_ci#define BNXT_LINK_LINK PORT_PHY_QCFG_RESP_LINK_LINK 120762306a36Sopenharmony_ci u8 wire_speed; 120862306a36Sopenharmony_ci u8 phy_state; 120962306a36Sopenharmony_ci#define BNXT_PHY_STATE_ENABLED 0 121062306a36Sopenharmony_ci#define BNXT_PHY_STATE_DISABLED 1 121162306a36Sopenharmony_ci 121262306a36Sopenharmony_ci u8 link_state; 121362306a36Sopenharmony_ci#define BNXT_LINK_STATE_UNKNOWN 0 121462306a36Sopenharmony_ci#define BNXT_LINK_STATE_DOWN 1 121562306a36Sopenharmony_ci#define BNXT_LINK_STATE_UP 2 121662306a36Sopenharmony_ci#define BNXT_LINK_IS_UP(bp) ((bp)->link_info.link_state == BNXT_LINK_STATE_UP) 121762306a36Sopenharmony_ci u8 duplex; 121862306a36Sopenharmony_ci#define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF 121962306a36Sopenharmony_ci#define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL 122062306a36Sopenharmony_ci u8 pause; 122162306a36Sopenharmony_ci#define BNXT_LINK_PAUSE_TX PORT_PHY_QCFG_RESP_PAUSE_TX 122262306a36Sopenharmony_ci#define BNXT_LINK_PAUSE_RX PORT_PHY_QCFG_RESP_PAUSE_RX 122362306a36Sopenharmony_ci#define BNXT_LINK_PAUSE_BOTH (PORT_PHY_QCFG_RESP_PAUSE_RX | \ 122462306a36Sopenharmony_ci PORT_PHY_QCFG_RESP_PAUSE_TX) 122562306a36Sopenharmony_ci u8 lp_pause; 122662306a36Sopenharmony_ci u8 auto_pause_setting; 122762306a36Sopenharmony_ci u8 force_pause_setting; 122862306a36Sopenharmony_ci u8 duplex_setting; 122962306a36Sopenharmony_ci u8 auto_mode; 123062306a36Sopenharmony_ci#define BNXT_AUTO_MODE(mode) ((mode) > BNXT_LINK_AUTO_NONE && \ 123162306a36Sopenharmony_ci (mode) <= BNXT_LINK_AUTO_MSK) 123262306a36Sopenharmony_ci#define BNXT_LINK_AUTO_NONE PORT_PHY_QCFG_RESP_AUTO_MODE_NONE 123362306a36Sopenharmony_ci#define BNXT_LINK_AUTO_ALLSPDS PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS 123462306a36Sopenharmony_ci#define BNXT_LINK_AUTO_ONESPD PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED 123562306a36Sopenharmony_ci#define BNXT_LINK_AUTO_ONEORBELOW PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW 123662306a36Sopenharmony_ci#define BNXT_LINK_AUTO_MSK PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK 123762306a36Sopenharmony_ci#define PHY_VER_LEN 3 123862306a36Sopenharmony_ci u8 phy_ver[PHY_VER_LEN]; 123962306a36Sopenharmony_ci u16 link_speed; 124062306a36Sopenharmony_ci#define BNXT_LINK_SPEED_100MB PORT_PHY_QCFG_RESP_LINK_SPEED_100MB 124162306a36Sopenharmony_ci#define BNXT_LINK_SPEED_1GB PORT_PHY_QCFG_RESP_LINK_SPEED_1GB 124262306a36Sopenharmony_ci#define BNXT_LINK_SPEED_2GB PORT_PHY_QCFG_RESP_LINK_SPEED_2GB 124362306a36Sopenharmony_ci#define BNXT_LINK_SPEED_2_5GB PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB 124462306a36Sopenharmony_ci#define BNXT_LINK_SPEED_10GB PORT_PHY_QCFG_RESP_LINK_SPEED_10GB 124562306a36Sopenharmony_ci#define BNXT_LINK_SPEED_20GB PORT_PHY_QCFG_RESP_LINK_SPEED_20GB 124662306a36Sopenharmony_ci#define BNXT_LINK_SPEED_25GB PORT_PHY_QCFG_RESP_LINK_SPEED_25GB 124762306a36Sopenharmony_ci#define BNXT_LINK_SPEED_40GB PORT_PHY_QCFG_RESP_LINK_SPEED_40GB 124862306a36Sopenharmony_ci#define BNXT_LINK_SPEED_50GB PORT_PHY_QCFG_RESP_LINK_SPEED_50GB 124962306a36Sopenharmony_ci#define BNXT_LINK_SPEED_100GB PORT_PHY_QCFG_RESP_LINK_SPEED_100GB 125062306a36Sopenharmony_ci#define BNXT_LINK_SPEED_200GB PORT_PHY_QCFG_RESP_LINK_SPEED_200GB 125162306a36Sopenharmony_ci u16 support_speeds; 125262306a36Sopenharmony_ci u16 support_pam4_speeds; 125362306a36Sopenharmony_ci u16 auto_link_speeds; /* fw adv setting */ 125462306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_100MB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB 125562306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_1GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB 125662306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_2GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB 125762306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_10GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB 125862306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_2_5GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB 125962306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_20GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB 126062306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_25GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB 126162306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_40GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB 126262306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB 126362306a36Sopenharmony_ci#define BNXT_LINK_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB 126462306a36Sopenharmony_ci u16 auto_pam4_link_speeds; 126562306a36Sopenharmony_ci#define BNXT_LINK_PAM4_SPEED_MSK_50GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_50G 126662306a36Sopenharmony_ci#define BNXT_LINK_PAM4_SPEED_MSK_100GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_100G 126762306a36Sopenharmony_ci#define BNXT_LINK_PAM4_SPEED_MSK_200GB PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_200G 126862306a36Sopenharmony_ci u16 support_auto_speeds; 126962306a36Sopenharmony_ci u16 support_pam4_auto_speeds; 127062306a36Sopenharmony_ci u16 lp_auto_link_speeds; 127162306a36Sopenharmony_ci u16 lp_auto_pam4_link_speeds; 127262306a36Sopenharmony_ci u16 force_link_speed; 127362306a36Sopenharmony_ci u16 force_pam4_link_speed; 127462306a36Sopenharmony_ci u32 preemphasis; 127562306a36Sopenharmony_ci u8 module_status; 127662306a36Sopenharmony_ci u8 active_fec_sig_mode; 127762306a36Sopenharmony_ci u16 fec_cfg; 127862306a36Sopenharmony_ci#define BNXT_FEC_NONE PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED 127962306a36Sopenharmony_ci#define BNXT_FEC_AUTONEG_CAP PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_SUPPORTED 128062306a36Sopenharmony_ci#define BNXT_FEC_AUTONEG PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED 128162306a36Sopenharmony_ci#define BNXT_FEC_ENC_BASE_R_CAP \ 128262306a36Sopenharmony_ci PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_SUPPORTED 128362306a36Sopenharmony_ci#define BNXT_FEC_ENC_BASE_R PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED 128462306a36Sopenharmony_ci#define BNXT_FEC_ENC_RS_CAP \ 128562306a36Sopenharmony_ci PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_SUPPORTED 128662306a36Sopenharmony_ci#define BNXT_FEC_ENC_LLRS_CAP \ 128762306a36Sopenharmony_ci (PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_SUPPORTED | \ 128862306a36Sopenharmony_ci PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_SUPPORTED) 128962306a36Sopenharmony_ci#define BNXT_FEC_ENC_RS \ 129062306a36Sopenharmony_ci (PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED | \ 129162306a36Sopenharmony_ci PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_1XN_ENABLED | \ 129262306a36Sopenharmony_ci PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_IEEE_ENABLED) 129362306a36Sopenharmony_ci#define BNXT_FEC_ENC_LLRS \ 129462306a36Sopenharmony_ci (PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_ENABLED | \ 129562306a36Sopenharmony_ci PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_ENABLED) 129662306a36Sopenharmony_ci 129762306a36Sopenharmony_ci /* copy of requested setting from ethtool cmd */ 129862306a36Sopenharmony_ci u8 autoneg; 129962306a36Sopenharmony_ci#define BNXT_AUTONEG_SPEED 1 130062306a36Sopenharmony_ci#define BNXT_AUTONEG_FLOW_CTRL 2 130162306a36Sopenharmony_ci u8 req_signal_mode; 130262306a36Sopenharmony_ci#define BNXT_SIG_MODE_NRZ PORT_PHY_QCFG_RESP_SIGNAL_MODE_NRZ 130362306a36Sopenharmony_ci#define BNXT_SIG_MODE_PAM4 PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4 130462306a36Sopenharmony_ci u8 req_duplex; 130562306a36Sopenharmony_ci u8 req_flow_ctrl; 130662306a36Sopenharmony_ci u16 req_link_speed; 130762306a36Sopenharmony_ci u16 advertising; /* user adv setting */ 130862306a36Sopenharmony_ci u16 advertising_pam4; 130962306a36Sopenharmony_ci bool force_link_chng; 131062306a36Sopenharmony_ci 131162306a36Sopenharmony_ci bool phy_retry; 131262306a36Sopenharmony_ci unsigned long phy_retry_expires; 131362306a36Sopenharmony_ci 131462306a36Sopenharmony_ci /* a copy of phy_qcfg output used to report link 131562306a36Sopenharmony_ci * info to VF 131662306a36Sopenharmony_ci */ 131762306a36Sopenharmony_ci struct hwrm_port_phy_qcfg_output phy_qcfg_resp; 131862306a36Sopenharmony_ci}; 131962306a36Sopenharmony_ci 132062306a36Sopenharmony_ci#define BNXT_FEC_RS544_ON \ 132162306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_ENABLE | \ 132262306a36Sopenharmony_ci PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_ENABLE) 132362306a36Sopenharmony_ci 132462306a36Sopenharmony_ci#define BNXT_FEC_RS544_OFF \ 132562306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_DISABLE | \ 132662306a36Sopenharmony_ci PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_DISABLE) 132762306a36Sopenharmony_ci 132862306a36Sopenharmony_ci#define BNXT_FEC_RS272_ON \ 132962306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_ENABLE | \ 133062306a36Sopenharmony_ci PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_ENABLE) 133162306a36Sopenharmony_ci 133262306a36Sopenharmony_ci#define BNXT_FEC_RS272_OFF \ 133362306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_DISABLE | \ 133462306a36Sopenharmony_ci PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_DISABLE) 133562306a36Sopenharmony_ci 133662306a36Sopenharmony_ci#define BNXT_PAM4_SUPPORTED(link_info) \ 133762306a36Sopenharmony_ci ((link_info)->support_pam4_speeds) 133862306a36Sopenharmony_ci 133962306a36Sopenharmony_ci#define BNXT_FEC_RS_ON(link_info) \ 134062306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_ENABLE | \ 134162306a36Sopenharmony_ci PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \ 134262306a36Sopenharmony_ci (BNXT_PAM4_SUPPORTED(link_info) ? \ 134362306a36Sopenharmony_ci (BNXT_FEC_RS544_ON | BNXT_FEC_RS272_OFF) : 0)) 134462306a36Sopenharmony_ci 134562306a36Sopenharmony_ci#define BNXT_FEC_LLRS_ON \ 134662306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_ENABLE | \ 134762306a36Sopenharmony_ci PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \ 134862306a36Sopenharmony_ci BNXT_FEC_RS272_ON | BNXT_FEC_RS544_OFF) 134962306a36Sopenharmony_ci 135062306a36Sopenharmony_ci#define BNXT_FEC_RS_OFF(link_info) \ 135162306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_DISABLE | \ 135262306a36Sopenharmony_ci (BNXT_PAM4_SUPPORTED(link_info) ? \ 135362306a36Sopenharmony_ci (BNXT_FEC_RS544_OFF | BNXT_FEC_RS272_OFF) : 0)) 135462306a36Sopenharmony_ci 135562306a36Sopenharmony_ci#define BNXT_FEC_BASE_R_ON(link_info) \ 135662306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_ENABLE | \ 135762306a36Sopenharmony_ci BNXT_FEC_RS_OFF(link_info)) 135862306a36Sopenharmony_ci 135962306a36Sopenharmony_ci#define BNXT_FEC_ALL_OFF(link_info) \ 136062306a36Sopenharmony_ci (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \ 136162306a36Sopenharmony_ci BNXT_FEC_RS_OFF(link_info)) 136262306a36Sopenharmony_ci 136362306a36Sopenharmony_ci#define BNXT_MAX_QUEUE 8 136462306a36Sopenharmony_ci 136562306a36Sopenharmony_cistruct bnxt_queue_info { 136662306a36Sopenharmony_ci u8 queue_id; 136762306a36Sopenharmony_ci u8 queue_profile; 136862306a36Sopenharmony_ci}; 136962306a36Sopenharmony_ci 137062306a36Sopenharmony_ci#define BNXT_MAX_LED 4 137162306a36Sopenharmony_ci 137262306a36Sopenharmony_cistruct bnxt_led_info { 137362306a36Sopenharmony_ci u8 led_id; 137462306a36Sopenharmony_ci u8 led_type; 137562306a36Sopenharmony_ci u8 led_group_id; 137662306a36Sopenharmony_ci u8 unused; 137762306a36Sopenharmony_ci __le16 led_state_caps; 137862306a36Sopenharmony_ci#define BNXT_LED_ALT_BLINK_CAP(x) ((x) & \ 137962306a36Sopenharmony_ci cpu_to_le16(PORT_LED_QCAPS_RESP_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED)) 138062306a36Sopenharmony_ci 138162306a36Sopenharmony_ci __le16 led_color_caps; 138262306a36Sopenharmony_ci}; 138362306a36Sopenharmony_ci 138462306a36Sopenharmony_ci#define BNXT_MAX_TEST 8 138562306a36Sopenharmony_ci 138662306a36Sopenharmony_cistruct bnxt_test_info { 138762306a36Sopenharmony_ci u8 offline_mask; 138862306a36Sopenharmony_ci u16 timeout; 138962306a36Sopenharmony_ci char string[BNXT_MAX_TEST][ETH_GSTRING_LEN]; 139062306a36Sopenharmony_ci}; 139162306a36Sopenharmony_ci 139262306a36Sopenharmony_ci#define CHIMP_REG_VIEW_ADDR \ 139362306a36Sopenharmony_ci ((bp->flags & BNXT_FLAG_CHIP_P5) ? 0x80000000 : 0xb1000000) 139462306a36Sopenharmony_ci 139562306a36Sopenharmony_ci#define BNXT_GRCPF_REG_CHIMP_COMM 0x0 139662306a36Sopenharmony_ci#define BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER 0x100 139762306a36Sopenharmony_ci#define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400 139862306a36Sopenharmony_ci#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014 139962306a36Sopenharmony_ci#define BNXT_CAG_REG_BASE 0x300000 140062306a36Sopenharmony_ci 140162306a36Sopenharmony_ci#define BNXT_GRC_REG_STATUS_P5 0x520 140262306a36Sopenharmony_ci 140362306a36Sopenharmony_ci#define BNXT_GRCPF_REG_KONG_COMM 0xA00 140462306a36Sopenharmony_ci#define BNXT_GRCPF_REG_KONG_COMM_TRIGGER 0xB00 140562306a36Sopenharmony_ci 140662306a36Sopenharmony_ci#define BNXT_GRC_REG_CHIP_NUM 0x48 140762306a36Sopenharmony_ci#define BNXT_GRC_REG_BASE 0x260000 140862306a36Sopenharmony_ci 140962306a36Sopenharmony_ci#define BNXT_TS_REG_TIMESYNC_TS0_LOWER 0x640180c 141062306a36Sopenharmony_ci#define BNXT_TS_REG_TIMESYNC_TS0_UPPER 0x6401810 141162306a36Sopenharmony_ci 141262306a36Sopenharmony_ci#define BNXT_GRC_BASE_MASK 0xfffff000 141362306a36Sopenharmony_ci#define BNXT_GRC_OFFSET_MASK 0x00000ffc 141462306a36Sopenharmony_ci 141562306a36Sopenharmony_cistruct bnxt_tc_flow_stats { 141662306a36Sopenharmony_ci u64 packets; 141762306a36Sopenharmony_ci u64 bytes; 141862306a36Sopenharmony_ci}; 141962306a36Sopenharmony_ci 142062306a36Sopenharmony_ci#ifdef CONFIG_BNXT_FLOWER_OFFLOAD 142162306a36Sopenharmony_cistruct bnxt_flower_indr_block_cb_priv { 142262306a36Sopenharmony_ci struct net_device *tunnel_netdev; 142362306a36Sopenharmony_ci struct bnxt *bp; 142462306a36Sopenharmony_ci struct list_head list; 142562306a36Sopenharmony_ci}; 142662306a36Sopenharmony_ci#endif 142762306a36Sopenharmony_ci 142862306a36Sopenharmony_cistruct bnxt_tc_info { 142962306a36Sopenharmony_ci bool enabled; 143062306a36Sopenharmony_ci 143162306a36Sopenharmony_ci /* hash table to store TC offloaded flows */ 143262306a36Sopenharmony_ci struct rhashtable flow_table; 143362306a36Sopenharmony_ci struct rhashtable_params flow_ht_params; 143462306a36Sopenharmony_ci 143562306a36Sopenharmony_ci /* hash table to store L2 keys of TC flows */ 143662306a36Sopenharmony_ci struct rhashtable l2_table; 143762306a36Sopenharmony_ci struct rhashtable_params l2_ht_params; 143862306a36Sopenharmony_ci /* hash table to store L2 keys for TC tunnel decap */ 143962306a36Sopenharmony_ci struct rhashtable decap_l2_table; 144062306a36Sopenharmony_ci struct rhashtable_params decap_l2_ht_params; 144162306a36Sopenharmony_ci /* hash table to store tunnel decap entries */ 144262306a36Sopenharmony_ci struct rhashtable decap_table; 144362306a36Sopenharmony_ci struct rhashtable_params decap_ht_params; 144462306a36Sopenharmony_ci /* hash table to store tunnel encap entries */ 144562306a36Sopenharmony_ci struct rhashtable encap_table; 144662306a36Sopenharmony_ci struct rhashtable_params encap_ht_params; 144762306a36Sopenharmony_ci 144862306a36Sopenharmony_ci /* lock to atomically add/del an l2 node when a flow is 144962306a36Sopenharmony_ci * added or deleted. 145062306a36Sopenharmony_ci */ 145162306a36Sopenharmony_ci struct mutex lock; 145262306a36Sopenharmony_ci 145362306a36Sopenharmony_ci /* Fields used for batching stats query */ 145462306a36Sopenharmony_ci struct rhashtable_iter iter; 145562306a36Sopenharmony_ci#define BNXT_FLOW_STATS_BATCH_MAX 10 145662306a36Sopenharmony_ci struct bnxt_tc_stats_batch { 145762306a36Sopenharmony_ci void *flow_node; 145862306a36Sopenharmony_ci struct bnxt_tc_flow_stats hw_stats; 145962306a36Sopenharmony_ci } stats_batch[BNXT_FLOW_STATS_BATCH_MAX]; 146062306a36Sopenharmony_ci 146162306a36Sopenharmony_ci /* Stat counter mask (width) */ 146262306a36Sopenharmony_ci u64 bytes_mask; 146362306a36Sopenharmony_ci u64 packets_mask; 146462306a36Sopenharmony_ci}; 146562306a36Sopenharmony_ci 146662306a36Sopenharmony_cistruct bnxt_vf_rep_stats { 146762306a36Sopenharmony_ci u64 packets; 146862306a36Sopenharmony_ci u64 bytes; 146962306a36Sopenharmony_ci u64 dropped; 147062306a36Sopenharmony_ci}; 147162306a36Sopenharmony_ci 147262306a36Sopenharmony_cistruct bnxt_vf_rep { 147362306a36Sopenharmony_ci struct bnxt *bp; 147462306a36Sopenharmony_ci struct net_device *dev; 147562306a36Sopenharmony_ci struct metadata_dst *dst; 147662306a36Sopenharmony_ci u16 vf_idx; 147762306a36Sopenharmony_ci u16 tx_cfa_action; 147862306a36Sopenharmony_ci u16 rx_cfa_code; 147962306a36Sopenharmony_ci 148062306a36Sopenharmony_ci struct bnxt_vf_rep_stats rx_stats; 148162306a36Sopenharmony_ci struct bnxt_vf_rep_stats tx_stats; 148262306a36Sopenharmony_ci}; 148362306a36Sopenharmony_ci 148462306a36Sopenharmony_ci#define PTU_PTE_VALID 0x1UL 148562306a36Sopenharmony_ci#define PTU_PTE_LAST 0x2UL 148662306a36Sopenharmony_ci#define PTU_PTE_NEXT_TO_LAST 0x4UL 148762306a36Sopenharmony_ci 148862306a36Sopenharmony_ci#define MAX_CTX_PAGES (BNXT_PAGE_SIZE / 8) 148962306a36Sopenharmony_ci#define MAX_CTX_TOTAL_PAGES (MAX_CTX_PAGES * MAX_CTX_PAGES) 149062306a36Sopenharmony_ci 149162306a36Sopenharmony_cistruct bnxt_ctx_pg_info { 149262306a36Sopenharmony_ci u32 entries; 149362306a36Sopenharmony_ci u32 nr_pages; 149462306a36Sopenharmony_ci void *ctx_pg_arr[MAX_CTX_PAGES]; 149562306a36Sopenharmony_ci dma_addr_t ctx_dma_arr[MAX_CTX_PAGES]; 149662306a36Sopenharmony_ci struct bnxt_ring_mem_info ring_mem; 149762306a36Sopenharmony_ci struct bnxt_ctx_pg_info **ctx_pg_tbl; 149862306a36Sopenharmony_ci}; 149962306a36Sopenharmony_ci 150062306a36Sopenharmony_ci#define BNXT_MAX_TQM_SP_RINGS 1 150162306a36Sopenharmony_ci#define BNXT_MAX_TQM_FP_RINGS 8 150262306a36Sopenharmony_ci#define BNXT_MAX_TQM_RINGS \ 150362306a36Sopenharmony_ci (BNXT_MAX_TQM_SP_RINGS + BNXT_MAX_TQM_FP_RINGS) 150462306a36Sopenharmony_ci 150562306a36Sopenharmony_ci#define BNXT_BACKING_STORE_CFG_LEGACY_LEN 256 150662306a36Sopenharmony_ci 150762306a36Sopenharmony_ci#define BNXT_SET_CTX_PAGE_ATTR(attr) \ 150862306a36Sopenharmony_cido { \ 150962306a36Sopenharmony_ci if (BNXT_PAGE_SIZE == 0x2000) \ 151062306a36Sopenharmony_ci attr = FUNC_BACKING_STORE_CFG_REQ_SRQ_PG_SIZE_PG_8K; \ 151162306a36Sopenharmony_ci else if (BNXT_PAGE_SIZE == 0x10000) \ 151262306a36Sopenharmony_ci attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_64K; \ 151362306a36Sopenharmony_ci else \ 151462306a36Sopenharmony_ci attr = FUNC_BACKING_STORE_CFG_REQ_QPC_PG_SIZE_PG_4K; \ 151562306a36Sopenharmony_ci} while (0) 151662306a36Sopenharmony_ci 151762306a36Sopenharmony_cistruct bnxt_ctx_mem_info { 151862306a36Sopenharmony_ci u32 qp_max_entries; 151962306a36Sopenharmony_ci u16 qp_min_qp1_entries; 152062306a36Sopenharmony_ci u16 qp_max_l2_entries; 152162306a36Sopenharmony_ci u16 qp_entry_size; 152262306a36Sopenharmony_ci u16 srq_max_l2_entries; 152362306a36Sopenharmony_ci u32 srq_max_entries; 152462306a36Sopenharmony_ci u16 srq_entry_size; 152562306a36Sopenharmony_ci u16 cq_max_l2_entries; 152662306a36Sopenharmony_ci u32 cq_max_entries; 152762306a36Sopenharmony_ci u16 cq_entry_size; 152862306a36Sopenharmony_ci u16 vnic_max_vnic_entries; 152962306a36Sopenharmony_ci u16 vnic_max_ring_table_entries; 153062306a36Sopenharmony_ci u16 vnic_entry_size; 153162306a36Sopenharmony_ci u32 stat_max_entries; 153262306a36Sopenharmony_ci u16 stat_entry_size; 153362306a36Sopenharmony_ci u16 tqm_entry_size; 153462306a36Sopenharmony_ci u32 tqm_min_entries_per_ring; 153562306a36Sopenharmony_ci u32 tqm_max_entries_per_ring; 153662306a36Sopenharmony_ci u32 mrav_max_entries; 153762306a36Sopenharmony_ci u16 mrav_entry_size; 153862306a36Sopenharmony_ci u16 tim_entry_size; 153962306a36Sopenharmony_ci u32 tim_max_entries; 154062306a36Sopenharmony_ci u16 mrav_num_entries_units; 154162306a36Sopenharmony_ci u8 tqm_entries_multiple; 154262306a36Sopenharmony_ci u8 tqm_fp_rings_count; 154362306a36Sopenharmony_ci 154462306a36Sopenharmony_ci u32 flags; 154562306a36Sopenharmony_ci #define BNXT_CTX_FLAG_INITED 0x01 154662306a36Sopenharmony_ci 154762306a36Sopenharmony_ci struct bnxt_ctx_pg_info qp_mem; 154862306a36Sopenharmony_ci struct bnxt_ctx_pg_info srq_mem; 154962306a36Sopenharmony_ci struct bnxt_ctx_pg_info cq_mem; 155062306a36Sopenharmony_ci struct bnxt_ctx_pg_info vnic_mem; 155162306a36Sopenharmony_ci struct bnxt_ctx_pg_info stat_mem; 155262306a36Sopenharmony_ci struct bnxt_ctx_pg_info mrav_mem; 155362306a36Sopenharmony_ci struct bnxt_ctx_pg_info tim_mem; 155462306a36Sopenharmony_ci struct bnxt_ctx_pg_info *tqm_mem[BNXT_MAX_TQM_RINGS]; 155562306a36Sopenharmony_ci 155662306a36Sopenharmony_ci#define BNXT_CTX_MEM_INIT_QP 0 155762306a36Sopenharmony_ci#define BNXT_CTX_MEM_INIT_SRQ 1 155862306a36Sopenharmony_ci#define BNXT_CTX_MEM_INIT_CQ 2 155962306a36Sopenharmony_ci#define BNXT_CTX_MEM_INIT_VNIC 3 156062306a36Sopenharmony_ci#define BNXT_CTX_MEM_INIT_STAT 4 156162306a36Sopenharmony_ci#define BNXT_CTX_MEM_INIT_MRAV 5 156262306a36Sopenharmony_ci#define BNXT_CTX_MEM_INIT_MAX 6 156362306a36Sopenharmony_ci struct bnxt_mem_init mem_init[BNXT_CTX_MEM_INIT_MAX]; 156462306a36Sopenharmony_ci}; 156562306a36Sopenharmony_ci 156662306a36Sopenharmony_cienum bnxt_health_severity { 156762306a36Sopenharmony_ci SEVERITY_NORMAL = 0, 156862306a36Sopenharmony_ci SEVERITY_WARNING, 156962306a36Sopenharmony_ci SEVERITY_RECOVERABLE, 157062306a36Sopenharmony_ci SEVERITY_FATAL, 157162306a36Sopenharmony_ci}; 157262306a36Sopenharmony_ci 157362306a36Sopenharmony_cienum bnxt_health_remedy { 157462306a36Sopenharmony_ci REMEDY_DEVLINK_RECOVER, 157562306a36Sopenharmony_ci REMEDY_POWER_CYCLE_DEVICE, 157662306a36Sopenharmony_ci REMEDY_POWER_CYCLE_HOST, 157762306a36Sopenharmony_ci REMEDY_FW_UPDATE, 157862306a36Sopenharmony_ci REMEDY_HW_REPLACE, 157962306a36Sopenharmony_ci}; 158062306a36Sopenharmony_ci 158162306a36Sopenharmony_cistruct bnxt_fw_health { 158262306a36Sopenharmony_ci u32 flags; 158362306a36Sopenharmony_ci u32 polling_dsecs; 158462306a36Sopenharmony_ci u32 master_func_wait_dsecs; 158562306a36Sopenharmony_ci u32 normal_func_wait_dsecs; 158662306a36Sopenharmony_ci u32 post_reset_wait_dsecs; 158762306a36Sopenharmony_ci u32 post_reset_max_wait_dsecs; 158862306a36Sopenharmony_ci u32 regs[4]; 158962306a36Sopenharmony_ci u32 mapped_regs[4]; 159062306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG 0 159162306a36Sopenharmony_ci#define BNXT_FW_HEARTBEAT_REG 1 159262306a36Sopenharmony_ci#define BNXT_FW_RESET_CNT_REG 2 159362306a36Sopenharmony_ci#define BNXT_FW_RESET_INPROG_REG 3 159462306a36Sopenharmony_ci u32 fw_reset_inprog_reg_mask; 159562306a36Sopenharmony_ci u32 last_fw_heartbeat; 159662306a36Sopenharmony_ci u32 last_fw_reset_cnt; 159762306a36Sopenharmony_ci u8 enabled:1; 159862306a36Sopenharmony_ci u8 primary:1; 159962306a36Sopenharmony_ci u8 status_reliable:1; 160062306a36Sopenharmony_ci u8 resets_reliable:1; 160162306a36Sopenharmony_ci u8 tmr_multiplier; 160262306a36Sopenharmony_ci u8 tmr_counter; 160362306a36Sopenharmony_ci u8 fw_reset_seq_cnt; 160462306a36Sopenharmony_ci u32 fw_reset_seq_regs[16]; 160562306a36Sopenharmony_ci u32 fw_reset_seq_vals[16]; 160662306a36Sopenharmony_ci u32 fw_reset_seq_delay_msec[16]; 160762306a36Sopenharmony_ci u32 echo_req_data1; 160862306a36Sopenharmony_ci u32 echo_req_data2; 160962306a36Sopenharmony_ci struct devlink_health_reporter *fw_reporter; 161062306a36Sopenharmony_ci /* Protects severity and remedy */ 161162306a36Sopenharmony_ci struct mutex lock; 161262306a36Sopenharmony_ci enum bnxt_health_severity severity; 161362306a36Sopenharmony_ci enum bnxt_health_remedy remedy; 161462306a36Sopenharmony_ci u32 arrests; 161562306a36Sopenharmony_ci u32 discoveries; 161662306a36Sopenharmony_ci u32 survivals; 161762306a36Sopenharmony_ci u32 fatalities; 161862306a36Sopenharmony_ci u32 diagnoses; 161962306a36Sopenharmony_ci}; 162062306a36Sopenharmony_ci 162162306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG_TYPE_MASK 3 162262306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG_TYPE_CFG 0 162362306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG_TYPE_GRC 1 162462306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG_TYPE_BAR0 2 162562306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG_TYPE_BAR1 3 162662306a36Sopenharmony_ci 162762306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG_TYPE(reg) ((reg) & BNXT_FW_HEALTH_REG_TYPE_MASK) 162862306a36Sopenharmony_ci#define BNXT_FW_HEALTH_REG_OFF(reg) ((reg) & ~BNXT_FW_HEALTH_REG_TYPE_MASK) 162962306a36Sopenharmony_ci 163062306a36Sopenharmony_ci#define BNXT_FW_HEALTH_WIN_BASE 0x3000 163162306a36Sopenharmony_ci#define BNXT_FW_HEALTH_WIN_MAP_OFF 8 163262306a36Sopenharmony_ci 163362306a36Sopenharmony_ci#define BNXT_FW_HEALTH_WIN_OFF(reg) (BNXT_FW_HEALTH_WIN_BASE + \ 163462306a36Sopenharmony_ci ((reg) & BNXT_GRC_OFFSET_MASK)) 163562306a36Sopenharmony_ci 163662306a36Sopenharmony_ci#define BNXT_FW_STATUS_HEALTH_MSK 0xffff 163762306a36Sopenharmony_ci#define BNXT_FW_STATUS_HEALTHY 0x8000 163862306a36Sopenharmony_ci#define BNXT_FW_STATUS_SHUTDOWN 0x100000 163962306a36Sopenharmony_ci#define BNXT_FW_STATUS_RECOVERING 0x400000 164062306a36Sopenharmony_ci 164162306a36Sopenharmony_ci#define BNXT_FW_IS_HEALTHY(sts) (((sts) & BNXT_FW_STATUS_HEALTH_MSK) ==\ 164262306a36Sopenharmony_ci BNXT_FW_STATUS_HEALTHY) 164362306a36Sopenharmony_ci 164462306a36Sopenharmony_ci#define BNXT_FW_IS_BOOTING(sts) (((sts) & BNXT_FW_STATUS_HEALTH_MSK) < \ 164562306a36Sopenharmony_ci BNXT_FW_STATUS_HEALTHY) 164662306a36Sopenharmony_ci 164762306a36Sopenharmony_ci#define BNXT_FW_IS_ERR(sts) (((sts) & BNXT_FW_STATUS_HEALTH_MSK) > \ 164862306a36Sopenharmony_ci BNXT_FW_STATUS_HEALTHY) 164962306a36Sopenharmony_ci 165062306a36Sopenharmony_ci#define BNXT_FW_IS_RECOVERING(sts) (BNXT_FW_IS_ERR(sts) && \ 165162306a36Sopenharmony_ci ((sts) & BNXT_FW_STATUS_RECOVERING)) 165262306a36Sopenharmony_ci 165362306a36Sopenharmony_ci#define BNXT_FW_RETRY 5 165462306a36Sopenharmony_ci#define BNXT_FW_IF_RETRY 10 165562306a36Sopenharmony_ci#define BNXT_FW_SLOT_RESET_RETRY 4 165662306a36Sopenharmony_ci 165762306a36Sopenharmony_cistruct bnxt_aux_priv { 165862306a36Sopenharmony_ci struct auxiliary_device aux_dev; 165962306a36Sopenharmony_ci struct bnxt_en_dev *edev; 166062306a36Sopenharmony_ci int id; 166162306a36Sopenharmony_ci}; 166262306a36Sopenharmony_ci 166362306a36Sopenharmony_cienum board_idx { 166462306a36Sopenharmony_ci BCM57301, 166562306a36Sopenharmony_ci BCM57302, 166662306a36Sopenharmony_ci BCM57304, 166762306a36Sopenharmony_ci BCM57417_NPAR, 166862306a36Sopenharmony_ci BCM58700, 166962306a36Sopenharmony_ci BCM57311, 167062306a36Sopenharmony_ci BCM57312, 167162306a36Sopenharmony_ci BCM57402, 167262306a36Sopenharmony_ci BCM57404, 167362306a36Sopenharmony_ci BCM57406, 167462306a36Sopenharmony_ci BCM57402_NPAR, 167562306a36Sopenharmony_ci BCM57407, 167662306a36Sopenharmony_ci BCM57412, 167762306a36Sopenharmony_ci BCM57414, 167862306a36Sopenharmony_ci BCM57416, 167962306a36Sopenharmony_ci BCM57417, 168062306a36Sopenharmony_ci BCM57412_NPAR, 168162306a36Sopenharmony_ci BCM57314, 168262306a36Sopenharmony_ci BCM57417_SFP, 168362306a36Sopenharmony_ci BCM57416_SFP, 168462306a36Sopenharmony_ci BCM57404_NPAR, 168562306a36Sopenharmony_ci BCM57406_NPAR, 168662306a36Sopenharmony_ci BCM57407_SFP, 168762306a36Sopenharmony_ci BCM57407_NPAR, 168862306a36Sopenharmony_ci BCM57414_NPAR, 168962306a36Sopenharmony_ci BCM57416_NPAR, 169062306a36Sopenharmony_ci BCM57452, 169162306a36Sopenharmony_ci BCM57454, 169262306a36Sopenharmony_ci BCM5745x_NPAR, 169362306a36Sopenharmony_ci BCM57508, 169462306a36Sopenharmony_ci BCM57504, 169562306a36Sopenharmony_ci BCM57502, 169662306a36Sopenharmony_ci BCM57508_NPAR, 169762306a36Sopenharmony_ci BCM57504_NPAR, 169862306a36Sopenharmony_ci BCM57502_NPAR, 169962306a36Sopenharmony_ci BCM58802, 170062306a36Sopenharmony_ci BCM58804, 170162306a36Sopenharmony_ci BCM58808, 170262306a36Sopenharmony_ci NETXTREME_E_VF, 170362306a36Sopenharmony_ci NETXTREME_C_VF, 170462306a36Sopenharmony_ci NETXTREME_S_VF, 170562306a36Sopenharmony_ci NETXTREME_C_VF_HV, 170662306a36Sopenharmony_ci NETXTREME_E_VF_HV, 170762306a36Sopenharmony_ci NETXTREME_E_P5_VF, 170862306a36Sopenharmony_ci NETXTREME_E_P5_VF_HV, 170962306a36Sopenharmony_ci}; 171062306a36Sopenharmony_ci 171162306a36Sopenharmony_cistruct bnxt { 171262306a36Sopenharmony_ci void __iomem *bar0; 171362306a36Sopenharmony_ci void __iomem *bar1; 171462306a36Sopenharmony_ci void __iomem *bar2; 171562306a36Sopenharmony_ci 171662306a36Sopenharmony_ci u32 reg_base; 171762306a36Sopenharmony_ci u16 chip_num; 171862306a36Sopenharmony_ci#define CHIP_NUM_57301 0x16c8 171962306a36Sopenharmony_ci#define CHIP_NUM_57302 0x16c9 172062306a36Sopenharmony_ci#define CHIP_NUM_57304 0x16ca 172162306a36Sopenharmony_ci#define CHIP_NUM_58700 0x16cd 172262306a36Sopenharmony_ci#define CHIP_NUM_57402 0x16d0 172362306a36Sopenharmony_ci#define CHIP_NUM_57404 0x16d1 172462306a36Sopenharmony_ci#define CHIP_NUM_57406 0x16d2 172562306a36Sopenharmony_ci#define CHIP_NUM_57407 0x16d5 172662306a36Sopenharmony_ci 172762306a36Sopenharmony_ci#define CHIP_NUM_57311 0x16ce 172862306a36Sopenharmony_ci#define CHIP_NUM_57312 0x16cf 172962306a36Sopenharmony_ci#define CHIP_NUM_57314 0x16df 173062306a36Sopenharmony_ci#define CHIP_NUM_57317 0x16e0 173162306a36Sopenharmony_ci#define CHIP_NUM_57412 0x16d6 173262306a36Sopenharmony_ci#define CHIP_NUM_57414 0x16d7 173362306a36Sopenharmony_ci#define CHIP_NUM_57416 0x16d8 173462306a36Sopenharmony_ci#define CHIP_NUM_57417 0x16d9 173562306a36Sopenharmony_ci#define CHIP_NUM_57412L 0x16da 173662306a36Sopenharmony_ci#define CHIP_NUM_57414L 0x16db 173762306a36Sopenharmony_ci 173862306a36Sopenharmony_ci#define CHIP_NUM_5745X 0xd730 173962306a36Sopenharmony_ci#define CHIP_NUM_57452 0xc452 174062306a36Sopenharmony_ci#define CHIP_NUM_57454 0xc454 174162306a36Sopenharmony_ci 174262306a36Sopenharmony_ci#define CHIP_NUM_57508 0x1750 174362306a36Sopenharmony_ci#define CHIP_NUM_57504 0x1751 174462306a36Sopenharmony_ci#define CHIP_NUM_57502 0x1752 174562306a36Sopenharmony_ci 174662306a36Sopenharmony_ci#define CHIP_NUM_58802 0xd802 174762306a36Sopenharmony_ci#define CHIP_NUM_58804 0xd804 174862306a36Sopenharmony_ci#define CHIP_NUM_58808 0xd808 174962306a36Sopenharmony_ci 175062306a36Sopenharmony_ci u8 chip_rev; 175162306a36Sopenharmony_ci 175262306a36Sopenharmony_ci#define CHIP_NUM_58818 0xd818 175362306a36Sopenharmony_ci 175462306a36Sopenharmony_ci#define BNXT_CHIP_NUM_5730X(chip_num) \ 175562306a36Sopenharmony_ci ((chip_num) >= CHIP_NUM_57301 && \ 175662306a36Sopenharmony_ci (chip_num) <= CHIP_NUM_57304) 175762306a36Sopenharmony_ci 175862306a36Sopenharmony_ci#define BNXT_CHIP_NUM_5740X(chip_num) \ 175962306a36Sopenharmony_ci (((chip_num) >= CHIP_NUM_57402 && \ 176062306a36Sopenharmony_ci (chip_num) <= CHIP_NUM_57406) || \ 176162306a36Sopenharmony_ci (chip_num) == CHIP_NUM_57407) 176262306a36Sopenharmony_ci 176362306a36Sopenharmony_ci#define BNXT_CHIP_NUM_5731X(chip_num) \ 176462306a36Sopenharmony_ci ((chip_num) == CHIP_NUM_57311 || \ 176562306a36Sopenharmony_ci (chip_num) == CHIP_NUM_57312 || \ 176662306a36Sopenharmony_ci (chip_num) == CHIP_NUM_57314 || \ 176762306a36Sopenharmony_ci (chip_num) == CHIP_NUM_57317) 176862306a36Sopenharmony_ci 176962306a36Sopenharmony_ci#define BNXT_CHIP_NUM_5741X(chip_num) \ 177062306a36Sopenharmony_ci ((chip_num) >= CHIP_NUM_57412 && \ 177162306a36Sopenharmony_ci (chip_num) <= CHIP_NUM_57414L) 177262306a36Sopenharmony_ci 177362306a36Sopenharmony_ci#define BNXT_CHIP_NUM_58700(chip_num) \ 177462306a36Sopenharmony_ci ((chip_num) == CHIP_NUM_58700) 177562306a36Sopenharmony_ci 177662306a36Sopenharmony_ci#define BNXT_CHIP_NUM_5745X(chip_num) \ 177762306a36Sopenharmony_ci ((chip_num) == CHIP_NUM_5745X || \ 177862306a36Sopenharmony_ci (chip_num) == CHIP_NUM_57452 || \ 177962306a36Sopenharmony_ci (chip_num) == CHIP_NUM_57454) 178062306a36Sopenharmony_ci 178162306a36Sopenharmony_ci 178262306a36Sopenharmony_ci#define BNXT_CHIP_NUM_57X0X(chip_num) \ 178362306a36Sopenharmony_ci (BNXT_CHIP_NUM_5730X(chip_num) || BNXT_CHIP_NUM_5740X(chip_num)) 178462306a36Sopenharmony_ci 178562306a36Sopenharmony_ci#define BNXT_CHIP_NUM_57X1X(chip_num) \ 178662306a36Sopenharmony_ci (BNXT_CHIP_NUM_5731X(chip_num) || BNXT_CHIP_NUM_5741X(chip_num)) 178762306a36Sopenharmony_ci 178862306a36Sopenharmony_ci#define BNXT_CHIP_NUM_588XX(chip_num) \ 178962306a36Sopenharmony_ci ((chip_num) == CHIP_NUM_58802 || \ 179062306a36Sopenharmony_ci (chip_num) == CHIP_NUM_58804 || \ 179162306a36Sopenharmony_ci (chip_num) == CHIP_NUM_58808) 179262306a36Sopenharmony_ci 179362306a36Sopenharmony_ci#define BNXT_VPD_FLD_LEN 32 179462306a36Sopenharmony_ci char board_partno[BNXT_VPD_FLD_LEN]; 179562306a36Sopenharmony_ci char board_serialno[BNXT_VPD_FLD_LEN]; 179662306a36Sopenharmony_ci 179762306a36Sopenharmony_ci struct net_device *dev; 179862306a36Sopenharmony_ci struct pci_dev *pdev; 179962306a36Sopenharmony_ci 180062306a36Sopenharmony_ci atomic_t intr_sem; 180162306a36Sopenharmony_ci 180262306a36Sopenharmony_ci u32 flags; 180362306a36Sopenharmony_ci #define BNXT_FLAG_CHIP_P5 0x1 180462306a36Sopenharmony_ci #define BNXT_FLAG_VF 0x2 180562306a36Sopenharmony_ci #define BNXT_FLAG_LRO 0x4 180662306a36Sopenharmony_ci#ifdef CONFIG_INET 180762306a36Sopenharmony_ci #define BNXT_FLAG_GRO 0x8 180862306a36Sopenharmony_ci#else 180962306a36Sopenharmony_ci /* Cannot support hardware GRO if CONFIG_INET is not set */ 181062306a36Sopenharmony_ci #define BNXT_FLAG_GRO 0x0 181162306a36Sopenharmony_ci#endif 181262306a36Sopenharmony_ci #define BNXT_FLAG_TPA (BNXT_FLAG_LRO | BNXT_FLAG_GRO) 181362306a36Sopenharmony_ci #define BNXT_FLAG_JUMBO 0x10 181462306a36Sopenharmony_ci #define BNXT_FLAG_STRIP_VLAN 0x20 181562306a36Sopenharmony_ci #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \ 181662306a36Sopenharmony_ci BNXT_FLAG_LRO) 181762306a36Sopenharmony_ci #define BNXT_FLAG_USING_MSIX 0x40 181862306a36Sopenharmony_ci #define BNXT_FLAG_MSIX_CAP 0x80 181962306a36Sopenharmony_ci #define BNXT_FLAG_RFS 0x100 182062306a36Sopenharmony_ci #define BNXT_FLAG_SHARED_RINGS 0x200 182162306a36Sopenharmony_ci #define BNXT_FLAG_PORT_STATS 0x400 182262306a36Sopenharmony_ci #define BNXT_FLAG_UDP_RSS_CAP 0x800 182362306a36Sopenharmony_ci #define BNXT_FLAG_NEW_RSS_CAP 0x2000 182462306a36Sopenharmony_ci #define BNXT_FLAG_WOL_CAP 0x4000 182562306a36Sopenharmony_ci #define BNXT_FLAG_ROCEV1_CAP 0x8000 182662306a36Sopenharmony_ci #define BNXT_FLAG_ROCEV2_CAP 0x10000 182762306a36Sopenharmony_ci #define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \ 182862306a36Sopenharmony_ci BNXT_FLAG_ROCEV2_CAP) 182962306a36Sopenharmony_ci #define BNXT_FLAG_NO_AGG_RINGS 0x20000 183062306a36Sopenharmony_ci #define BNXT_FLAG_RX_PAGE_MODE 0x40000 183162306a36Sopenharmony_ci #define BNXT_FLAG_CHIP_SR2 0x80000 183262306a36Sopenharmony_ci #define BNXT_FLAG_MULTI_HOST 0x100000 183362306a36Sopenharmony_ci #define BNXT_FLAG_DSN_VALID 0x200000 183462306a36Sopenharmony_ci #define BNXT_FLAG_DOUBLE_DB 0x400000 183562306a36Sopenharmony_ci #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000 183662306a36Sopenharmony_ci #define BNXT_FLAG_DIM 0x2000000 183762306a36Sopenharmony_ci #define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000 183862306a36Sopenharmony_ci #define BNXT_FLAG_PORT_STATS_EXT 0x10000000 183962306a36Sopenharmony_ci 184062306a36Sopenharmony_ci #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ 184162306a36Sopenharmony_ci BNXT_FLAG_RFS | \ 184262306a36Sopenharmony_ci BNXT_FLAG_STRIP_VLAN) 184362306a36Sopenharmony_ci 184462306a36Sopenharmony_ci#define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF)) 184562306a36Sopenharmony_ci#define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF) 184662306a36Sopenharmony_ci#define BNXT_NPAR(bp) ((bp)->port_partition_type) 184762306a36Sopenharmony_ci#define BNXT_MH(bp) ((bp)->flags & BNXT_FLAG_MULTI_HOST) 184862306a36Sopenharmony_ci#define BNXT_SINGLE_PF(bp) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp)) 184962306a36Sopenharmony_ci#define BNXT_SH_PORT_CFG_OK(bp) (BNXT_PF(bp) && \ 185062306a36Sopenharmony_ci ((bp)->phy_flags & BNXT_PHY_FL_SHARED_PORT_CFG)) 185162306a36Sopenharmony_ci#define BNXT_PHY_CFG_ABLE(bp) ((BNXT_SINGLE_PF(bp) || \ 185262306a36Sopenharmony_ci BNXT_SH_PORT_CFG_OK(bp)) && \ 185362306a36Sopenharmony_ci (bp)->link_info.phy_state == BNXT_PHY_STATE_ENABLED) 185462306a36Sopenharmony_ci#define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0) 185562306a36Sopenharmony_ci#define BNXT_RX_PAGE_MODE(bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE) 185662306a36Sopenharmony_ci#define BNXT_SUPPORTS_TPA(bp) (!BNXT_CHIP_TYPE_NITRO_A0(bp) && \ 185762306a36Sopenharmony_ci (!((bp)->flags & BNXT_FLAG_CHIP_P5) || \ 185862306a36Sopenharmony_ci (bp)->max_tpa_v2) && !is_kdump_kernel()) 185962306a36Sopenharmony_ci#define BNXT_RX_JUMBO_MODE(bp) ((bp)->flags & BNXT_FLAG_JUMBO) 186062306a36Sopenharmony_ci 186162306a36Sopenharmony_ci#define BNXT_CHIP_SR2(bp) \ 186262306a36Sopenharmony_ci ((bp)->chip_num == CHIP_NUM_58818) 186362306a36Sopenharmony_ci 186462306a36Sopenharmony_ci#define BNXT_CHIP_P5_THOR(bp) \ 186562306a36Sopenharmony_ci ((bp)->chip_num == CHIP_NUM_57508 || \ 186662306a36Sopenharmony_ci (bp)->chip_num == CHIP_NUM_57504 || \ 186762306a36Sopenharmony_ci (bp)->chip_num == CHIP_NUM_57502) 186862306a36Sopenharmony_ci 186962306a36Sopenharmony_ci/* Chip class phase 5 */ 187062306a36Sopenharmony_ci#define BNXT_CHIP_P5(bp) \ 187162306a36Sopenharmony_ci (BNXT_CHIP_P5_THOR(bp) || BNXT_CHIP_SR2(bp)) 187262306a36Sopenharmony_ci 187362306a36Sopenharmony_ci/* Chip class phase 4.x */ 187462306a36Sopenharmony_ci#define BNXT_CHIP_P4(bp) \ 187562306a36Sopenharmony_ci (BNXT_CHIP_NUM_57X1X((bp)->chip_num) || \ 187662306a36Sopenharmony_ci BNXT_CHIP_NUM_5745X((bp)->chip_num) || \ 187762306a36Sopenharmony_ci BNXT_CHIP_NUM_588XX((bp)->chip_num) || \ 187862306a36Sopenharmony_ci (BNXT_CHIP_NUM_58700((bp)->chip_num) && \ 187962306a36Sopenharmony_ci !BNXT_CHIP_TYPE_NITRO_A0(bp))) 188062306a36Sopenharmony_ci 188162306a36Sopenharmony_ci#define BNXT_CHIP_P4_PLUS(bp) \ 188262306a36Sopenharmony_ci (BNXT_CHIP_P4(bp) || BNXT_CHIP_P5(bp)) 188362306a36Sopenharmony_ci 188462306a36Sopenharmony_ci struct bnxt_aux_priv *aux_priv; 188562306a36Sopenharmony_ci struct bnxt_en_dev *edev; 188662306a36Sopenharmony_ci 188762306a36Sopenharmony_ci struct bnxt_napi **bnapi; 188862306a36Sopenharmony_ci 188962306a36Sopenharmony_ci struct bnxt_rx_ring_info *rx_ring; 189062306a36Sopenharmony_ci struct bnxt_tx_ring_info *tx_ring; 189162306a36Sopenharmony_ci u16 *tx_ring_map; 189262306a36Sopenharmony_ci 189362306a36Sopenharmony_ci struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int, 189462306a36Sopenharmony_ci struct sk_buff *); 189562306a36Sopenharmony_ci 189662306a36Sopenharmony_ci struct sk_buff * (*rx_skb_func)(struct bnxt *, 189762306a36Sopenharmony_ci struct bnxt_rx_ring_info *, 189862306a36Sopenharmony_ci u16, void *, u8 *, dma_addr_t, 189962306a36Sopenharmony_ci unsigned int); 190062306a36Sopenharmony_ci 190162306a36Sopenharmony_ci u16 max_tpa_v2; 190262306a36Sopenharmony_ci u16 max_tpa; 190362306a36Sopenharmony_ci u32 rx_buf_size; 190462306a36Sopenharmony_ci u32 rx_buf_use_size; /* useable size */ 190562306a36Sopenharmony_ci u16 rx_offset; 190662306a36Sopenharmony_ci u16 rx_dma_offset; 190762306a36Sopenharmony_ci enum dma_data_direction rx_dir; 190862306a36Sopenharmony_ci u32 rx_ring_size; 190962306a36Sopenharmony_ci u32 rx_agg_ring_size; 191062306a36Sopenharmony_ci u32 rx_copy_thresh; 191162306a36Sopenharmony_ci u32 rx_ring_mask; 191262306a36Sopenharmony_ci u32 rx_agg_ring_mask; 191362306a36Sopenharmony_ci int rx_nr_pages; 191462306a36Sopenharmony_ci int rx_agg_nr_pages; 191562306a36Sopenharmony_ci int rx_nr_rings; 191662306a36Sopenharmony_ci int rsscos_nr_ctxs; 191762306a36Sopenharmony_ci 191862306a36Sopenharmony_ci u32 tx_ring_size; 191962306a36Sopenharmony_ci u32 tx_ring_mask; 192062306a36Sopenharmony_ci int tx_nr_pages; 192162306a36Sopenharmony_ci int tx_nr_rings; 192262306a36Sopenharmony_ci int tx_nr_rings_per_tc; 192362306a36Sopenharmony_ci int tx_nr_rings_xdp; 192462306a36Sopenharmony_ci 192562306a36Sopenharmony_ci int tx_wake_thresh; 192662306a36Sopenharmony_ci int tx_push_thresh; 192762306a36Sopenharmony_ci int tx_push_size; 192862306a36Sopenharmony_ci 192962306a36Sopenharmony_ci u32 cp_ring_size; 193062306a36Sopenharmony_ci u32 cp_ring_mask; 193162306a36Sopenharmony_ci u32 cp_bit; 193262306a36Sopenharmony_ci int cp_nr_pages; 193362306a36Sopenharmony_ci int cp_nr_rings; 193462306a36Sopenharmony_ci 193562306a36Sopenharmony_ci /* grp_info indexed by completion ring index */ 193662306a36Sopenharmony_ci struct bnxt_ring_grp_info *grp_info; 193762306a36Sopenharmony_ci struct bnxt_vnic_info *vnic_info; 193862306a36Sopenharmony_ci int nr_vnics; 193962306a36Sopenharmony_ci u16 *rss_indir_tbl; 194062306a36Sopenharmony_ci u16 rss_indir_tbl_entries; 194162306a36Sopenharmony_ci u32 rss_hash_cfg; 194262306a36Sopenharmony_ci u32 rss_hash_delta; 194362306a36Sopenharmony_ci 194462306a36Sopenharmony_ci u16 max_mtu; 194562306a36Sopenharmony_ci u8 max_tc; 194662306a36Sopenharmony_ci u8 max_lltc; /* lossless TCs */ 194762306a36Sopenharmony_ci struct bnxt_queue_info q_info[BNXT_MAX_QUEUE]; 194862306a36Sopenharmony_ci u8 tc_to_qidx[BNXT_MAX_QUEUE]; 194962306a36Sopenharmony_ci u8 q_ids[BNXT_MAX_QUEUE]; 195062306a36Sopenharmony_ci u8 max_q; 195162306a36Sopenharmony_ci 195262306a36Sopenharmony_ci unsigned int current_interval; 195362306a36Sopenharmony_ci#define BNXT_TIMER_INTERVAL HZ 195462306a36Sopenharmony_ci 195562306a36Sopenharmony_ci struct timer_list timer; 195662306a36Sopenharmony_ci 195762306a36Sopenharmony_ci unsigned long state; 195862306a36Sopenharmony_ci#define BNXT_STATE_OPEN 0 195962306a36Sopenharmony_ci#define BNXT_STATE_IN_SP_TASK 1 196062306a36Sopenharmony_ci#define BNXT_STATE_READ_STATS 2 196162306a36Sopenharmony_ci#define BNXT_STATE_FW_RESET_DET 3 196262306a36Sopenharmony_ci#define BNXT_STATE_IN_FW_RESET 4 196362306a36Sopenharmony_ci#define BNXT_STATE_ABORT_ERR 5 196462306a36Sopenharmony_ci#define BNXT_STATE_FW_FATAL_COND 6 196562306a36Sopenharmony_ci#define BNXT_STATE_DRV_REGISTERED 7 196662306a36Sopenharmony_ci#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8 196762306a36Sopenharmony_ci#define BNXT_STATE_NAPI_DISABLED 9 196862306a36Sopenharmony_ci#define BNXT_STATE_L2_FILTER_RETRY 10 196962306a36Sopenharmony_ci#define BNXT_STATE_FW_ACTIVATE 11 197062306a36Sopenharmony_ci#define BNXT_STATE_RECOVER 12 197162306a36Sopenharmony_ci#define BNXT_STATE_FW_NON_FATAL_COND 13 197262306a36Sopenharmony_ci#define BNXT_STATE_FW_ACTIVATE_RESET 14 197362306a36Sopenharmony_ci#define BNXT_STATE_HALF_OPEN 15 /* For offline ethtool tests */ 197462306a36Sopenharmony_ci 197562306a36Sopenharmony_ci#define BNXT_NO_FW_ACCESS(bp) \ 197662306a36Sopenharmony_ci (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \ 197762306a36Sopenharmony_ci pci_channel_offline((bp)->pdev)) 197862306a36Sopenharmony_ci 197962306a36Sopenharmony_ci struct bnxt_irq *irq_tbl; 198062306a36Sopenharmony_ci int total_irqs; 198162306a36Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 198262306a36Sopenharmony_ci 198362306a36Sopenharmony_ci#ifdef CONFIG_BNXT_DCB 198462306a36Sopenharmony_ci struct ieee_pfc *ieee_pfc; 198562306a36Sopenharmony_ci struct ieee_ets *ieee_ets; 198662306a36Sopenharmony_ci u8 dcbx_cap; 198762306a36Sopenharmony_ci u8 default_pri; 198862306a36Sopenharmony_ci u8 max_dscp_value; 198962306a36Sopenharmony_ci#endif /* CONFIG_BNXT_DCB */ 199062306a36Sopenharmony_ci 199162306a36Sopenharmony_ci u32 msg_enable; 199262306a36Sopenharmony_ci 199362306a36Sopenharmony_ci u64 fw_cap; 199462306a36Sopenharmony_ci #define BNXT_FW_CAP_SHORT_CMD BIT_ULL(0) 199562306a36Sopenharmony_ci #define BNXT_FW_CAP_LLDP_AGENT BIT_ULL(1) 199662306a36Sopenharmony_ci #define BNXT_FW_CAP_DCBX_AGENT BIT_ULL(2) 199762306a36Sopenharmony_ci #define BNXT_FW_CAP_NEW_RM BIT_ULL(3) 199862306a36Sopenharmony_ci #define BNXT_FW_CAP_IF_CHANGE BIT_ULL(4) 199962306a36Sopenharmony_ci #define BNXT_FW_CAP_KONG_MB_CHNL BIT_ULL(7) 200062306a36Sopenharmony_ci #define BNXT_FW_CAP_OVS_64BIT_HANDLE BIT_ULL(10) 200162306a36Sopenharmony_ci #define BNXT_FW_CAP_TRUSTED_VF BIT_ULL(11) 200262306a36Sopenharmony_ci #define BNXT_FW_CAP_ERROR_RECOVERY BIT_ULL(13) 200362306a36Sopenharmony_ci #define BNXT_FW_CAP_PKG_VER BIT_ULL(14) 200462306a36Sopenharmony_ci #define BNXT_FW_CAP_CFA_ADV_FLOW BIT_ULL(15) 200562306a36Sopenharmony_ci #define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2 BIT_ULL(16) 200662306a36Sopenharmony_ci #define BNXT_FW_CAP_PCIE_STATS_SUPPORTED BIT_ULL(17) 200762306a36Sopenharmony_ci #define BNXT_FW_CAP_EXT_STATS_SUPPORTED BIT_ULL(18) 200862306a36Sopenharmony_ci #define BNXT_FW_CAP_RSS_HASH_TYPE_DELTA BIT_ULL(19) 200962306a36Sopenharmony_ci #define BNXT_FW_CAP_ERR_RECOVER_RELOAD BIT_ULL(20) 201062306a36Sopenharmony_ci #define BNXT_FW_CAP_HOT_RESET BIT_ULL(21) 201162306a36Sopenharmony_ci #define BNXT_FW_CAP_PTP_RTC BIT_ULL(22) 201262306a36Sopenharmony_ci #define BNXT_FW_CAP_RX_ALL_PKT_TS BIT_ULL(23) 201362306a36Sopenharmony_ci #define BNXT_FW_CAP_VLAN_RX_STRIP BIT_ULL(24) 201462306a36Sopenharmony_ci #define BNXT_FW_CAP_VLAN_TX_INSERT BIT_ULL(25) 201562306a36Sopenharmony_ci #define BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED BIT_ULL(26) 201662306a36Sopenharmony_ci #define BNXT_FW_CAP_LIVEPATCH BIT_ULL(27) 201762306a36Sopenharmony_ci #define BNXT_FW_CAP_PTP_PPS BIT_ULL(28) 201862306a36Sopenharmony_ci #define BNXT_FW_CAP_HOT_RESET_IF BIT_ULL(29) 201962306a36Sopenharmony_ci #define BNXT_FW_CAP_RING_MONITOR BIT_ULL(30) 202062306a36Sopenharmony_ci #define BNXT_FW_CAP_DBG_QCAPS BIT_ULL(31) 202162306a36Sopenharmony_ci #define BNXT_FW_CAP_PTP BIT_ULL(32) 202262306a36Sopenharmony_ci 202362306a36Sopenharmony_ci u32 fw_dbg_cap; 202462306a36Sopenharmony_ci 202562306a36Sopenharmony_ci#define BNXT_NEW_RM(bp) ((bp)->fw_cap & BNXT_FW_CAP_NEW_RM) 202662306a36Sopenharmony_ci#define BNXT_PTP_USE_RTC(bp) (!BNXT_MH(bp) && \ 202762306a36Sopenharmony_ci ((bp)->fw_cap & BNXT_FW_CAP_PTP_RTC)) 202862306a36Sopenharmony_ci u32 hwrm_spec_code; 202962306a36Sopenharmony_ci u16 hwrm_cmd_seq; 203062306a36Sopenharmony_ci u16 hwrm_cmd_kong_seq; 203162306a36Sopenharmony_ci struct dma_pool *hwrm_dma_pool; 203262306a36Sopenharmony_ci struct hlist_head hwrm_pending_list; 203362306a36Sopenharmony_ci 203462306a36Sopenharmony_ci struct rtnl_link_stats64 net_stats_prev; 203562306a36Sopenharmony_ci struct bnxt_stats_mem port_stats; 203662306a36Sopenharmony_ci struct bnxt_stats_mem rx_port_stats_ext; 203762306a36Sopenharmony_ci struct bnxt_stats_mem tx_port_stats_ext; 203862306a36Sopenharmony_ci u16 fw_rx_stats_ext_size; 203962306a36Sopenharmony_ci u16 fw_tx_stats_ext_size; 204062306a36Sopenharmony_ci u16 hw_ring_stats_size; 204162306a36Sopenharmony_ci u8 pri2cos_idx[8]; 204262306a36Sopenharmony_ci u8 pri2cos_valid; 204362306a36Sopenharmony_ci 204462306a36Sopenharmony_ci struct bnxt_total_ring_err_stats ring_err_stats_prev; 204562306a36Sopenharmony_ci 204662306a36Sopenharmony_ci u16 hwrm_max_req_len; 204762306a36Sopenharmony_ci u16 hwrm_max_ext_req_len; 204862306a36Sopenharmony_ci unsigned int hwrm_cmd_timeout; 204962306a36Sopenharmony_ci unsigned int hwrm_cmd_max_timeout; 205062306a36Sopenharmony_ci struct mutex hwrm_cmd_lock; /* serialize hwrm messages */ 205162306a36Sopenharmony_ci struct hwrm_ver_get_output ver_resp; 205262306a36Sopenharmony_ci#define FW_VER_STR_LEN 32 205362306a36Sopenharmony_ci#define BC_HWRM_STR_LEN 21 205462306a36Sopenharmony_ci#define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN) 205562306a36Sopenharmony_ci char fw_ver_str[FW_VER_STR_LEN]; 205662306a36Sopenharmony_ci char hwrm_ver_supp[FW_VER_STR_LEN]; 205762306a36Sopenharmony_ci char nvm_cfg_ver[FW_VER_STR_LEN]; 205862306a36Sopenharmony_ci u64 fw_ver_code; 205962306a36Sopenharmony_ci#define BNXT_FW_VER_CODE(maj, min, bld, rsv) \ 206062306a36Sopenharmony_ci ((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv)) 206162306a36Sopenharmony_ci#define BNXT_FW_MAJ(bp) ((bp)->fw_ver_code >> 48) 206262306a36Sopenharmony_ci 206362306a36Sopenharmony_ci u16 vxlan_fw_dst_port_id; 206462306a36Sopenharmony_ci u16 nge_fw_dst_port_id; 206562306a36Sopenharmony_ci __be16 vxlan_port; 206662306a36Sopenharmony_ci __be16 nge_port; 206762306a36Sopenharmony_ci u8 port_partition_type; 206862306a36Sopenharmony_ci u8 port_count; 206962306a36Sopenharmony_ci u16 br_mode; 207062306a36Sopenharmony_ci 207162306a36Sopenharmony_ci struct bnxt_coal_cap coal_cap; 207262306a36Sopenharmony_ci struct bnxt_coal rx_coal; 207362306a36Sopenharmony_ci struct bnxt_coal tx_coal; 207462306a36Sopenharmony_ci 207562306a36Sopenharmony_ci u32 stats_coal_ticks; 207662306a36Sopenharmony_ci#define BNXT_DEF_STATS_COAL_TICKS 1000000 207762306a36Sopenharmony_ci#define BNXT_MIN_STATS_COAL_TICKS 250000 207862306a36Sopenharmony_ci#define BNXT_MAX_STATS_COAL_TICKS 1000000 207962306a36Sopenharmony_ci 208062306a36Sopenharmony_ci struct work_struct sp_task; 208162306a36Sopenharmony_ci unsigned long sp_event; 208262306a36Sopenharmony_ci#define BNXT_RX_MASK_SP_EVENT 0 208362306a36Sopenharmony_ci#define BNXT_RX_NTP_FLTR_SP_EVENT 1 208462306a36Sopenharmony_ci#define BNXT_LINK_CHNG_SP_EVENT 2 208562306a36Sopenharmony_ci#define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT 3 208662306a36Sopenharmony_ci#define BNXT_RESET_TASK_SP_EVENT 6 208762306a36Sopenharmony_ci#define BNXT_RST_RING_SP_EVENT 7 208862306a36Sopenharmony_ci#define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8 208962306a36Sopenharmony_ci#define BNXT_PERIODIC_STATS_SP_EVENT 9 209062306a36Sopenharmony_ci#define BNXT_HWRM_PORT_MODULE_SP_EVENT 10 209162306a36Sopenharmony_ci#define BNXT_RESET_TASK_SILENT_SP_EVENT 11 209262306a36Sopenharmony_ci#define BNXT_LINK_SPEED_CHNG_SP_EVENT 14 209362306a36Sopenharmony_ci#define BNXT_FLOW_STATS_SP_EVENT 15 209462306a36Sopenharmony_ci#define BNXT_UPDATE_PHY_SP_EVENT 16 209562306a36Sopenharmony_ci#define BNXT_RING_COAL_NOW_SP_EVENT 17 209662306a36Sopenharmony_ci#define BNXT_FW_RESET_NOTIFY_SP_EVENT 18 209762306a36Sopenharmony_ci#define BNXT_FW_EXCEPTION_SP_EVENT 19 209862306a36Sopenharmony_ci#define BNXT_LINK_CFG_CHANGE_SP_EVENT 21 209962306a36Sopenharmony_ci#define BNXT_FW_ECHO_REQUEST_SP_EVENT 23 210062306a36Sopenharmony_ci 210162306a36Sopenharmony_ci struct delayed_work fw_reset_task; 210262306a36Sopenharmony_ci int fw_reset_state; 210362306a36Sopenharmony_ci#define BNXT_FW_RESET_STATE_POLL_VF 1 210462306a36Sopenharmony_ci#define BNXT_FW_RESET_STATE_RESET_FW 2 210562306a36Sopenharmony_ci#define BNXT_FW_RESET_STATE_ENABLE_DEV 3 210662306a36Sopenharmony_ci#define BNXT_FW_RESET_STATE_POLL_FW 4 210762306a36Sopenharmony_ci#define BNXT_FW_RESET_STATE_OPENING 5 210862306a36Sopenharmony_ci#define BNXT_FW_RESET_STATE_POLL_FW_DOWN 6 210962306a36Sopenharmony_ci 211062306a36Sopenharmony_ci u16 fw_reset_min_dsecs; 211162306a36Sopenharmony_ci#define BNXT_DFLT_FW_RST_MIN_DSECS 20 211262306a36Sopenharmony_ci u16 fw_reset_max_dsecs; 211362306a36Sopenharmony_ci#define BNXT_DFLT_FW_RST_MAX_DSECS 60 211462306a36Sopenharmony_ci unsigned long fw_reset_timestamp; 211562306a36Sopenharmony_ci 211662306a36Sopenharmony_ci struct bnxt_fw_health *fw_health; 211762306a36Sopenharmony_ci 211862306a36Sopenharmony_ci struct bnxt_hw_resc hw_resc; 211962306a36Sopenharmony_ci struct bnxt_pf_info pf; 212062306a36Sopenharmony_ci struct bnxt_ctx_mem_info *ctx; 212162306a36Sopenharmony_ci#ifdef CONFIG_BNXT_SRIOV 212262306a36Sopenharmony_ci int nr_vfs; 212362306a36Sopenharmony_ci struct bnxt_vf_info vf; 212462306a36Sopenharmony_ci wait_queue_head_t sriov_cfg_wait; 212562306a36Sopenharmony_ci bool sriov_cfg; 212662306a36Sopenharmony_ci#define BNXT_SRIOV_CFG_WAIT_TMO msecs_to_jiffies(10000) 212762306a36Sopenharmony_ci#endif 212862306a36Sopenharmony_ci 212962306a36Sopenharmony_ci#if BITS_PER_LONG == 32 213062306a36Sopenharmony_ci /* ensure atomic 64-bit doorbell writes on 32-bit systems. */ 213162306a36Sopenharmony_ci spinlock_t db_lock; 213262306a36Sopenharmony_ci#endif 213362306a36Sopenharmony_ci int db_size; 213462306a36Sopenharmony_ci 213562306a36Sopenharmony_ci#define BNXT_NTP_FLTR_MAX_FLTR 4096 213662306a36Sopenharmony_ci#define BNXT_NTP_FLTR_HASH_SIZE 512 213762306a36Sopenharmony_ci#define BNXT_NTP_FLTR_HASH_MASK (BNXT_NTP_FLTR_HASH_SIZE - 1) 213862306a36Sopenharmony_ci struct hlist_head ntp_fltr_hash_tbl[BNXT_NTP_FLTR_HASH_SIZE]; 213962306a36Sopenharmony_ci spinlock_t ntp_fltr_lock; /* for hash table add, del */ 214062306a36Sopenharmony_ci 214162306a36Sopenharmony_ci unsigned long *ntp_fltr_bmap; 214262306a36Sopenharmony_ci int ntp_fltr_count; 214362306a36Sopenharmony_ci 214462306a36Sopenharmony_ci /* To protect link related settings during link changes and 214562306a36Sopenharmony_ci * ethtool settings changes. 214662306a36Sopenharmony_ci */ 214762306a36Sopenharmony_ci struct mutex link_lock; 214862306a36Sopenharmony_ci struct bnxt_link_info link_info; 214962306a36Sopenharmony_ci struct ethtool_eee eee; 215062306a36Sopenharmony_ci u32 lpi_tmr_lo; 215162306a36Sopenharmony_ci u32 lpi_tmr_hi; 215262306a36Sopenharmony_ci 215362306a36Sopenharmony_ci /* copied from flags and flags2 in hwrm_port_phy_qcaps_output */ 215462306a36Sopenharmony_ci u32 phy_flags; 215562306a36Sopenharmony_ci#define BNXT_PHY_FL_EEE_CAP PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED 215662306a36Sopenharmony_ci#define BNXT_PHY_FL_EXT_LPBK PORT_PHY_QCAPS_RESP_FLAGS_EXTERNAL_LPBK_SUPPORTED 215762306a36Sopenharmony_ci#define BNXT_PHY_FL_AN_PHY_LPBK PORT_PHY_QCAPS_RESP_FLAGS_AUTONEG_LPBK_SUPPORTED 215862306a36Sopenharmony_ci#define BNXT_PHY_FL_SHARED_PORT_CFG PORT_PHY_QCAPS_RESP_FLAGS_SHARED_PHY_CFG_SUPPORTED 215962306a36Sopenharmony_ci#define BNXT_PHY_FL_PORT_STATS_NO_RESET PORT_PHY_QCAPS_RESP_FLAGS_CUMULATIVE_COUNTERS_ON_RESET 216062306a36Sopenharmony_ci#define BNXT_PHY_FL_NO_PHY_LPBK PORT_PHY_QCAPS_RESP_FLAGS_LOCAL_LPBK_NOT_SUPPORTED 216162306a36Sopenharmony_ci#define BNXT_PHY_FL_FW_MANAGED_LKDN PORT_PHY_QCAPS_RESP_FLAGS_FW_MANAGED_LINK_DOWN 216262306a36Sopenharmony_ci#define BNXT_PHY_FL_NO_FCS PORT_PHY_QCAPS_RESP_FLAGS_NO_FCS 216362306a36Sopenharmony_ci#define BNXT_PHY_FL_NO_PAUSE (PORT_PHY_QCAPS_RESP_FLAGS2_PAUSE_UNSUPPORTED << 8) 216462306a36Sopenharmony_ci#define BNXT_PHY_FL_NO_PFC (PORT_PHY_QCAPS_RESP_FLAGS2_PFC_UNSUPPORTED << 8) 216562306a36Sopenharmony_ci#define BNXT_PHY_FL_BANK_SEL (PORT_PHY_QCAPS_RESP_FLAGS2_BANK_ADDR_SUPPORTED << 8) 216662306a36Sopenharmony_ci 216762306a36Sopenharmony_ci u8 num_tests; 216862306a36Sopenharmony_ci struct bnxt_test_info *test_info; 216962306a36Sopenharmony_ci 217062306a36Sopenharmony_ci u8 wol_filter_id; 217162306a36Sopenharmony_ci u8 wol; 217262306a36Sopenharmony_ci 217362306a36Sopenharmony_ci u8 num_leds; 217462306a36Sopenharmony_ci struct bnxt_led_info leds[BNXT_MAX_LED]; 217562306a36Sopenharmony_ci u16 dump_flag; 217662306a36Sopenharmony_ci#define BNXT_DUMP_LIVE 0 217762306a36Sopenharmony_ci#define BNXT_DUMP_CRASH 1 217862306a36Sopenharmony_ci 217962306a36Sopenharmony_ci struct bpf_prog *xdp_prog; 218062306a36Sopenharmony_ci 218162306a36Sopenharmony_ci struct bnxt_ptp_cfg *ptp_cfg; 218262306a36Sopenharmony_ci u8 ptp_all_rx_tstamp; 218362306a36Sopenharmony_ci 218462306a36Sopenharmony_ci /* devlink interface and vf-rep structs */ 218562306a36Sopenharmony_ci struct devlink *dl; 218662306a36Sopenharmony_ci struct devlink_port dl_port; 218762306a36Sopenharmony_ci enum devlink_eswitch_mode eswitch_mode; 218862306a36Sopenharmony_ci struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */ 218962306a36Sopenharmony_ci u16 *cfa_code_map; /* cfa_code -> vf_idx map */ 219062306a36Sopenharmony_ci u8 dsn[8]; 219162306a36Sopenharmony_ci struct bnxt_tc_info *tc_info; 219262306a36Sopenharmony_ci struct list_head tc_indr_block_list; 219362306a36Sopenharmony_ci struct dentry *debugfs_pdev; 219462306a36Sopenharmony_ci struct device *hwmon_dev; 219562306a36Sopenharmony_ci enum board_idx board_idx; 219662306a36Sopenharmony_ci}; 219762306a36Sopenharmony_ci 219862306a36Sopenharmony_ci#define BNXT_NUM_RX_RING_STATS 8 219962306a36Sopenharmony_ci#define BNXT_NUM_TX_RING_STATS 8 220062306a36Sopenharmony_ci#define BNXT_NUM_TPA_RING_STATS 4 220162306a36Sopenharmony_ci#define BNXT_NUM_TPA_RING_STATS_P5 5 220262306a36Sopenharmony_ci#define BNXT_NUM_TPA_RING_STATS_P5_SR2 6 220362306a36Sopenharmony_ci 220462306a36Sopenharmony_ci#define BNXT_RING_STATS_SIZE_P5 \ 220562306a36Sopenharmony_ci ((BNXT_NUM_RX_RING_STATS + BNXT_NUM_TX_RING_STATS + \ 220662306a36Sopenharmony_ci BNXT_NUM_TPA_RING_STATS_P5) * 8) 220762306a36Sopenharmony_ci 220862306a36Sopenharmony_ci#define BNXT_RING_STATS_SIZE_P5_SR2 \ 220962306a36Sopenharmony_ci ((BNXT_NUM_RX_RING_STATS + BNXT_NUM_TX_RING_STATS + \ 221062306a36Sopenharmony_ci BNXT_NUM_TPA_RING_STATS_P5_SR2) * 8) 221162306a36Sopenharmony_ci 221262306a36Sopenharmony_ci#define BNXT_GET_RING_STATS64(sw, counter) \ 221362306a36Sopenharmony_ci (*((sw) + offsetof(struct ctx_hw_stats, counter) / 8)) 221462306a36Sopenharmony_ci 221562306a36Sopenharmony_ci#define BNXT_GET_RX_PORT_STATS64(sw, counter) \ 221662306a36Sopenharmony_ci (*((sw) + offsetof(struct rx_port_stats, counter) / 8)) 221762306a36Sopenharmony_ci 221862306a36Sopenharmony_ci#define BNXT_GET_TX_PORT_STATS64(sw, counter) \ 221962306a36Sopenharmony_ci (*((sw) + offsetof(struct tx_port_stats, counter) / 8)) 222062306a36Sopenharmony_ci 222162306a36Sopenharmony_ci#define BNXT_PORT_STATS_SIZE \ 222262306a36Sopenharmony_ci (sizeof(struct rx_port_stats) + sizeof(struct tx_port_stats) + 1024) 222362306a36Sopenharmony_ci 222462306a36Sopenharmony_ci#define BNXT_TX_PORT_STATS_BYTE_OFFSET \ 222562306a36Sopenharmony_ci (sizeof(struct rx_port_stats) + 512) 222662306a36Sopenharmony_ci 222762306a36Sopenharmony_ci#define BNXT_RX_STATS_OFFSET(counter) \ 222862306a36Sopenharmony_ci (offsetof(struct rx_port_stats, counter) / 8) 222962306a36Sopenharmony_ci 223062306a36Sopenharmony_ci#define BNXT_TX_STATS_OFFSET(counter) \ 223162306a36Sopenharmony_ci ((offsetof(struct tx_port_stats, counter) + \ 223262306a36Sopenharmony_ci BNXT_TX_PORT_STATS_BYTE_OFFSET) / 8) 223362306a36Sopenharmony_ci 223462306a36Sopenharmony_ci#define BNXT_RX_STATS_EXT_OFFSET(counter) \ 223562306a36Sopenharmony_ci (offsetof(struct rx_port_stats_ext, counter) / 8) 223662306a36Sopenharmony_ci 223762306a36Sopenharmony_ci#define BNXT_RX_STATS_EXT_NUM_LEGACY \ 223862306a36Sopenharmony_ci BNXT_RX_STATS_EXT_OFFSET(rx_fec_corrected_blocks) 223962306a36Sopenharmony_ci 224062306a36Sopenharmony_ci#define BNXT_TX_STATS_EXT_OFFSET(counter) \ 224162306a36Sopenharmony_ci (offsetof(struct tx_port_stats_ext, counter) / 8) 224262306a36Sopenharmony_ci 224362306a36Sopenharmony_ci#define BNXT_HW_FEATURE_VLAN_ALL_RX \ 224462306a36Sopenharmony_ci (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX) 224562306a36Sopenharmony_ci#define BNXT_HW_FEATURE_VLAN_ALL_TX \ 224662306a36Sopenharmony_ci (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX) 224762306a36Sopenharmony_ci 224862306a36Sopenharmony_ci#define I2C_DEV_ADDR_A0 0xa0 224962306a36Sopenharmony_ci#define I2C_DEV_ADDR_A2 0xa2 225062306a36Sopenharmony_ci#define SFF_DIAG_SUPPORT_OFFSET 0x5c 225162306a36Sopenharmony_ci#define SFF_MODULE_ID_SFP 0x3 225262306a36Sopenharmony_ci#define SFF_MODULE_ID_QSFP 0xc 225362306a36Sopenharmony_ci#define SFF_MODULE_ID_QSFP_PLUS 0xd 225462306a36Sopenharmony_ci#define SFF_MODULE_ID_QSFP28 0x11 225562306a36Sopenharmony_ci#define BNXT_MAX_PHY_I2C_RESP_SIZE 64 225662306a36Sopenharmony_ci 225762306a36Sopenharmony_cistatic inline u32 bnxt_tx_avail(struct bnxt *bp, 225862306a36Sopenharmony_ci const struct bnxt_tx_ring_info *txr) 225962306a36Sopenharmony_ci{ 226062306a36Sopenharmony_ci u32 used = READ_ONCE(txr->tx_prod) - READ_ONCE(txr->tx_cons); 226162306a36Sopenharmony_ci 226262306a36Sopenharmony_ci return bp->tx_ring_size - (used & bp->tx_ring_mask); 226362306a36Sopenharmony_ci} 226462306a36Sopenharmony_ci 226562306a36Sopenharmony_cistatic inline void bnxt_writeq(struct bnxt *bp, u64 val, 226662306a36Sopenharmony_ci volatile void __iomem *addr) 226762306a36Sopenharmony_ci{ 226862306a36Sopenharmony_ci#if BITS_PER_LONG == 32 226962306a36Sopenharmony_ci spin_lock(&bp->db_lock); 227062306a36Sopenharmony_ci lo_hi_writeq(val, addr); 227162306a36Sopenharmony_ci spin_unlock(&bp->db_lock); 227262306a36Sopenharmony_ci#else 227362306a36Sopenharmony_ci writeq(val, addr); 227462306a36Sopenharmony_ci#endif 227562306a36Sopenharmony_ci} 227662306a36Sopenharmony_ci 227762306a36Sopenharmony_cistatic inline void bnxt_writeq_relaxed(struct bnxt *bp, u64 val, 227862306a36Sopenharmony_ci volatile void __iomem *addr) 227962306a36Sopenharmony_ci{ 228062306a36Sopenharmony_ci#if BITS_PER_LONG == 32 228162306a36Sopenharmony_ci spin_lock(&bp->db_lock); 228262306a36Sopenharmony_ci lo_hi_writeq_relaxed(val, addr); 228362306a36Sopenharmony_ci spin_unlock(&bp->db_lock); 228462306a36Sopenharmony_ci#else 228562306a36Sopenharmony_ci writeq_relaxed(val, addr); 228662306a36Sopenharmony_ci#endif 228762306a36Sopenharmony_ci} 228862306a36Sopenharmony_ci 228962306a36Sopenharmony_ci/* For TX and RX ring doorbells with no ordering guarantee*/ 229062306a36Sopenharmony_cistatic inline void bnxt_db_write_relaxed(struct bnxt *bp, 229162306a36Sopenharmony_ci struct bnxt_db_info *db, u32 idx) 229262306a36Sopenharmony_ci{ 229362306a36Sopenharmony_ci if (bp->flags & BNXT_FLAG_CHIP_P5) { 229462306a36Sopenharmony_ci bnxt_writeq_relaxed(bp, db->db_key64 | idx, db->doorbell); 229562306a36Sopenharmony_ci } else { 229662306a36Sopenharmony_ci u32 db_val = db->db_key32 | idx; 229762306a36Sopenharmony_ci 229862306a36Sopenharmony_ci writel_relaxed(db_val, db->doorbell); 229962306a36Sopenharmony_ci if (bp->flags & BNXT_FLAG_DOUBLE_DB) 230062306a36Sopenharmony_ci writel_relaxed(db_val, db->doorbell); 230162306a36Sopenharmony_ci } 230262306a36Sopenharmony_ci} 230362306a36Sopenharmony_ci 230462306a36Sopenharmony_ci/* For TX and RX ring doorbells */ 230562306a36Sopenharmony_cistatic inline void bnxt_db_write(struct bnxt *bp, struct bnxt_db_info *db, 230662306a36Sopenharmony_ci u32 idx) 230762306a36Sopenharmony_ci{ 230862306a36Sopenharmony_ci if (bp->flags & BNXT_FLAG_CHIP_P5) { 230962306a36Sopenharmony_ci bnxt_writeq(bp, db->db_key64 | idx, db->doorbell); 231062306a36Sopenharmony_ci } else { 231162306a36Sopenharmony_ci u32 db_val = db->db_key32 | idx; 231262306a36Sopenharmony_ci 231362306a36Sopenharmony_ci writel(db_val, db->doorbell); 231462306a36Sopenharmony_ci if (bp->flags & BNXT_FLAG_DOUBLE_DB) 231562306a36Sopenharmony_ci writel(db_val, db->doorbell); 231662306a36Sopenharmony_ci } 231762306a36Sopenharmony_ci} 231862306a36Sopenharmony_ci 231962306a36Sopenharmony_ci/* Must hold rtnl_lock */ 232062306a36Sopenharmony_cistatic inline bool bnxt_sriov_cfg(struct bnxt *bp) 232162306a36Sopenharmony_ci{ 232262306a36Sopenharmony_ci#if defined(CONFIG_BNXT_SRIOV) 232362306a36Sopenharmony_ci return BNXT_PF(bp) && (bp->pf.active_vfs || bp->sriov_cfg); 232462306a36Sopenharmony_ci#else 232562306a36Sopenharmony_ci return false; 232662306a36Sopenharmony_ci#endif 232762306a36Sopenharmony_ci} 232862306a36Sopenharmony_ci 232962306a36Sopenharmony_ciextern const u16 bnxt_lhint_arr[]; 233062306a36Sopenharmony_ci 233162306a36Sopenharmony_ciint bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, 233262306a36Sopenharmony_ci u16 prod, gfp_t gfp); 233362306a36Sopenharmony_civoid bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data); 233462306a36Sopenharmony_ciu32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx); 233562306a36Sopenharmony_civoid bnxt_set_tpa_flags(struct bnxt *bp); 233662306a36Sopenharmony_civoid bnxt_set_ring_params(struct bnxt *); 233762306a36Sopenharmony_ciint bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); 233862306a36Sopenharmony_ciint bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, 233962306a36Sopenharmony_ci int bmap_size, bool async_only); 234062306a36Sopenharmony_ciint bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp); 234162306a36Sopenharmony_ciint bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings); 234262306a36Sopenharmony_ciint bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id); 234362306a36Sopenharmony_ciint __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings); 234462306a36Sopenharmony_ciint bnxt_nq_rings_in_use(struct bnxt *bp); 234562306a36Sopenharmony_ciint bnxt_hwrm_set_coal(struct bnxt *); 234662306a36Sopenharmony_civoid bnxt_free_ctx_mem(struct bnxt *bp); 234762306a36Sopenharmony_ciunsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp); 234862306a36Sopenharmony_ciunsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp); 234962306a36Sopenharmony_ciunsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp); 235062306a36Sopenharmony_ciunsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp); 235162306a36Sopenharmony_ciint bnxt_get_avail_msix(struct bnxt *bp, int num); 235262306a36Sopenharmony_ciint bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init); 235362306a36Sopenharmony_civoid bnxt_tx_disable(struct bnxt *bp); 235462306a36Sopenharmony_civoid bnxt_tx_enable(struct bnxt *bp); 235562306a36Sopenharmony_civoid bnxt_sched_reset_txr(struct bnxt *bp, struct bnxt_tx_ring_info *txr, 235662306a36Sopenharmony_ci int idx); 235762306a36Sopenharmony_civoid bnxt_report_link(struct bnxt *bp); 235862306a36Sopenharmony_ciint bnxt_update_link(struct bnxt *bp, bool chng_link_state); 235962306a36Sopenharmony_ciint bnxt_hwrm_set_pause(struct bnxt *); 236062306a36Sopenharmony_ciint bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool); 236162306a36Sopenharmony_ciint bnxt_cancel_reservations(struct bnxt *bp, bool fw_reset); 236262306a36Sopenharmony_ciint bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp); 236362306a36Sopenharmony_ciint bnxt_hwrm_free_wol_fltr(struct bnxt *bp); 236462306a36Sopenharmony_ciint bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all); 236562306a36Sopenharmony_ciint bnxt_hwrm_func_qcaps(struct bnxt *bp); 236662306a36Sopenharmony_ciint bnxt_hwrm_fw_set_time(struct bnxt *); 236762306a36Sopenharmony_ciint bnxt_open_nic(struct bnxt *, bool, bool); 236862306a36Sopenharmony_ciint bnxt_half_open_nic(struct bnxt *bp); 236962306a36Sopenharmony_civoid bnxt_half_close_nic(struct bnxt *bp); 237062306a36Sopenharmony_civoid bnxt_reenable_sriov(struct bnxt *bp); 237162306a36Sopenharmony_civoid bnxt_close_nic(struct bnxt *, bool, bool); 237262306a36Sopenharmony_civoid bnxt_get_ring_err_stats(struct bnxt *bp, 237362306a36Sopenharmony_ci struct bnxt_total_ring_err_stats *stats); 237462306a36Sopenharmony_ciint bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words, 237562306a36Sopenharmony_ci u32 *reg_buf); 237662306a36Sopenharmony_civoid bnxt_fw_exception(struct bnxt *bp); 237762306a36Sopenharmony_civoid bnxt_fw_reset(struct bnxt *bp); 237862306a36Sopenharmony_ciint bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, 237962306a36Sopenharmony_ci int tx_xdp); 238062306a36Sopenharmony_ciint bnxt_fw_init_one(struct bnxt *bp); 238162306a36Sopenharmony_cibool bnxt_hwrm_reset_permitted(struct bnxt *bp); 238262306a36Sopenharmony_ciint bnxt_setup_mq_tc(struct net_device *dev, u8 tc); 238362306a36Sopenharmony_ciint bnxt_get_max_rings(struct bnxt *, int *, int *, bool); 238462306a36Sopenharmony_ciint bnxt_restore_pf_fw_resources(struct bnxt *bp); 238562306a36Sopenharmony_ciint bnxt_get_port_parent_id(struct net_device *dev, 238662306a36Sopenharmony_ci struct netdev_phys_item_id *ppid); 238762306a36Sopenharmony_civoid bnxt_dim_work(struct work_struct *work); 238862306a36Sopenharmony_ciint bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi); 238962306a36Sopenharmony_civoid bnxt_print_device_info(struct bnxt *bp); 239062306a36Sopenharmony_ci#endif 2391