18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * QLogic qlcnic NIC Driver 48c2ecf20Sopenharmony_ci * Copyright (c) 2009-2013 QLogic Corporation 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _QLCNIC_H_ 88c2ecf20Sopenharmony_ci#define _QLCNIC_H_ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/module.h> 118c2ecf20Sopenharmony_ci#include <linux/kernel.h> 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci#include <linux/ioport.h> 148c2ecf20Sopenharmony_ci#include <linux/pci.h> 158c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 168c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 178c2ecf20Sopenharmony_ci#include <linux/ip.h> 188c2ecf20Sopenharmony_ci#include <linux/in.h> 198c2ecf20Sopenharmony_ci#include <linux/tcp.h> 208c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 218c2ecf20Sopenharmony_ci#include <linux/firmware.h> 228c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 238c2ecf20Sopenharmony_ci#include <linux/mii.h> 248c2ecf20Sopenharmony_ci#include <linux/timer.h> 258c2ecf20Sopenharmony_ci#include <linux/irq.h> 268c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 278c2ecf20Sopenharmony_ci#include <linux/io.h> 288c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 298c2ecf20Sopenharmony_ci#include <linux/bitops.h> 308c2ecf20Sopenharmony_ci#include <linux/if_vlan.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include "qlcnic_hdr.h" 338c2ecf20Sopenharmony_ci#include "qlcnic_hw.h" 348c2ecf20Sopenharmony_ci#include "qlcnic_83xx_hw.h" 358c2ecf20Sopenharmony_ci#include "qlcnic_dcb.h" 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define _QLCNIC_LINUX_MAJOR 5 388c2ecf20Sopenharmony_ci#define _QLCNIC_LINUX_MINOR 3 398c2ecf20Sopenharmony_ci#define _QLCNIC_LINUX_SUBVERSION 66 408c2ecf20Sopenharmony_ci#define QLCNIC_LINUX_VERSIONID "5.3.66" 418c2ecf20Sopenharmony_ci#define QLCNIC_DRV_IDC_VER 0x01 428c2ecf20Sopenharmony_ci#define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ 438c2ecf20Sopenharmony_ci (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define QLCNIC_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) 468c2ecf20Sopenharmony_ci#define _major(v) (((v) >> 24) & 0xff) 478c2ecf20Sopenharmony_ci#define _minor(v) (((v) >> 16) & 0xff) 488c2ecf20Sopenharmony_ci#define _build(v) ((v) & 0xffff) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* version in image has weird encoding: 518c2ecf20Sopenharmony_ci * 7:0 - major 528c2ecf20Sopenharmony_ci * 15:8 - minor 538c2ecf20Sopenharmony_ci * 31:16 - build (little endian) 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci#define QLCNIC_DECODE_VERSION(v) \ 568c2ecf20Sopenharmony_ci QLCNIC_VERSION_CODE(((v) & 0xff), (((v) >> 8) & 0xff), ((v) >> 16)) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define QLCNIC_MIN_FW_VERSION QLCNIC_VERSION_CODE(4, 4, 2) 598c2ecf20Sopenharmony_ci#define QLCNIC_NUM_FLASH_SECTORS (64) 608c2ecf20Sopenharmony_ci#define QLCNIC_FLASH_SECTOR_SIZE (64 * 1024) 618c2ecf20Sopenharmony_ci#define QLCNIC_FLASH_TOTAL_SIZE (QLCNIC_NUM_FLASH_SECTORS \ 628c2ecf20Sopenharmony_ci * QLCNIC_FLASH_SECTOR_SIZE) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define RCV_DESC_RINGSIZE(rds_ring) \ 658c2ecf20Sopenharmony_ci (sizeof(struct rcv_desc) * (rds_ring)->num_desc) 668c2ecf20Sopenharmony_ci#define RCV_BUFF_RINGSIZE(rds_ring) \ 678c2ecf20Sopenharmony_ci (sizeof(struct qlcnic_rx_buffer) * rds_ring->num_desc) 688c2ecf20Sopenharmony_ci#define STATUS_DESC_RINGSIZE(sds_ring) \ 698c2ecf20Sopenharmony_ci (sizeof(struct status_desc) * (sds_ring)->num_desc) 708c2ecf20Sopenharmony_ci#define TX_BUFF_RINGSIZE(tx_ring) \ 718c2ecf20Sopenharmony_ci (sizeof(struct qlcnic_cmd_buffer) * tx_ring->num_desc) 728c2ecf20Sopenharmony_ci#define TX_DESC_RINGSIZE(tx_ring) \ 738c2ecf20Sopenharmony_ci (sizeof(struct cmd_desc_type0) * tx_ring->num_desc) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define QLCNIC_P3P_A0 0x50 768c2ecf20Sopenharmony_ci#define QLCNIC_P3P_C0 0x58 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define QLCNIC_IS_REVISION_P3P(REVISION) (REVISION >= QLCNIC_P3P_A0) 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define FIRST_PAGE_GROUP_START 0 818c2ecf20Sopenharmony_ci#define FIRST_PAGE_GROUP_END 0x100000 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define P3P_MAX_MTU (9600) 848c2ecf20Sopenharmony_ci#define P3P_MIN_MTU (68) 858c2ecf20Sopenharmony_ci#define QLCNIC_MAX_ETHERHDR 32 /* This contains some padding */ 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define QLCNIC_P3P_RX_BUF_MAX_LEN (QLCNIC_MAX_ETHERHDR + ETH_DATA_LEN) 888c2ecf20Sopenharmony_ci#define QLCNIC_P3P_RX_JUMBO_BUF_MAX_LEN (QLCNIC_MAX_ETHERHDR + P3P_MAX_MTU) 898c2ecf20Sopenharmony_ci#define QLCNIC_CT_DEFAULT_RX_BUF_LEN 2048 908c2ecf20Sopenharmony_ci#define QLCNIC_LRO_BUFFER_EXTRA 2048 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* Tx defines */ 938c2ecf20Sopenharmony_ci#define QLCNIC_MAX_FRAGS_PER_TX 14 948c2ecf20Sopenharmony_ci#define MAX_TSO_HEADER_DESC 2 958c2ecf20Sopenharmony_ci#define MGMT_CMD_DESC_RESV 4 968c2ecf20Sopenharmony_ci#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ 978c2ecf20Sopenharmony_ci + MGMT_CMD_DESC_RESV) 988c2ecf20Sopenharmony_ci#define QLCNIC_MAX_TX_TIMEOUTS 2 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci/* Driver will use 1 Tx ring in INT-x/MSI/SRIOV mode. */ 1018c2ecf20Sopenharmony_ci#define QLCNIC_SINGLE_RING 1 1028c2ecf20Sopenharmony_ci#define QLCNIC_DEF_SDS_RINGS 4 1038c2ecf20Sopenharmony_ci#define QLCNIC_DEF_TX_RINGS 4 1048c2ecf20Sopenharmony_ci#define QLCNIC_MAX_VNIC_TX_RINGS 4 1058c2ecf20Sopenharmony_ci#define QLCNIC_MAX_VNIC_SDS_RINGS 4 1068c2ecf20Sopenharmony_ci#define QLCNIC_83XX_MINIMUM_VECTOR 3 1078c2ecf20Sopenharmony_ci#define QLCNIC_82XX_MINIMUM_VECTOR 2 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cienum qlcnic_queue_type { 1108c2ecf20Sopenharmony_ci QLCNIC_TX_QUEUE = 1, 1118c2ecf20Sopenharmony_ci QLCNIC_RX_QUEUE, 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* Operational mode for driver */ 1158c2ecf20Sopenharmony_ci#define QLCNIC_VNIC_MODE 0xFF 1168c2ecf20Sopenharmony_ci#define QLCNIC_DEFAULT_MODE 0x0 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci/* Virtual NIC function count */ 1198c2ecf20Sopenharmony_ci#define QLC_DEFAULT_VNIC_COUNT 8 1208c2ecf20Sopenharmony_ci#define QLC_84XX_VNIC_COUNT 16 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* 1238c2ecf20Sopenharmony_ci * Following are the states of the Phantom. Phantom will set them and 1248c2ecf20Sopenharmony_ci * Host will read to check if the fields are correct. 1258c2ecf20Sopenharmony_ci */ 1268c2ecf20Sopenharmony_ci#define PHAN_INITIALIZE_FAILED 0xffff 1278c2ecf20Sopenharmony_ci#define PHAN_INITIALIZE_COMPLETE 0xff01 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/* Host writes the following to notify that it has done the init-handshake */ 1308c2ecf20Sopenharmony_ci#define PHAN_INITIALIZE_ACK 0xf00f 1318c2ecf20Sopenharmony_ci#define PHAN_PEG_RCV_INITIALIZED 0xff01 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#define NUM_RCV_DESC_RINGS 3 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci#define RCV_RING_NORMAL 0 1368c2ecf20Sopenharmony_ci#define RCV_RING_JUMBO 1 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci#define MIN_CMD_DESCRIPTORS 64 1398c2ecf20Sopenharmony_ci#define MIN_RCV_DESCRIPTORS 64 1408c2ecf20Sopenharmony_ci#define MIN_JUMBO_DESCRIPTORS 32 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci#define MAX_CMD_DESCRIPTORS 1024 1438c2ecf20Sopenharmony_ci#define MAX_RCV_DESCRIPTORS_1G 4096 1448c2ecf20Sopenharmony_ci#define MAX_RCV_DESCRIPTORS_10G 8192 1458c2ecf20Sopenharmony_ci#define MAX_RCV_DESCRIPTORS_VF 2048 1468c2ecf20Sopenharmony_ci#define MAX_JUMBO_RCV_DESCRIPTORS_1G 512 1478c2ecf20Sopenharmony_ci#define MAX_JUMBO_RCV_DESCRIPTORS_10G 1024 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define DEFAULT_RCV_DESCRIPTORS_1G 2048 1508c2ecf20Sopenharmony_ci#define DEFAULT_RCV_DESCRIPTORS_10G 4096 1518c2ecf20Sopenharmony_ci#define DEFAULT_RCV_DESCRIPTORS_VF 1024 1528c2ecf20Sopenharmony_ci#define MAX_RDS_RINGS 2 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#define get_next_index(index, length) \ 1558c2ecf20Sopenharmony_ci (((index) + 1) & ((length) - 1)) 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci/* 1588c2ecf20Sopenharmony_ci * Following data structures describe the descriptors that will be used. 1598c2ecf20Sopenharmony_ci * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when 1608c2ecf20Sopenharmony_ci * we are doing LSO (above the 1500 size packet) only. 1618c2ecf20Sopenharmony_ci */ 1628c2ecf20Sopenharmony_cistruct cmd_desc_type0 { 1638c2ecf20Sopenharmony_ci u8 tcp_hdr_offset; /* For LSO only */ 1648c2ecf20Sopenharmony_ci u8 ip_hdr_offset; /* For LSO only */ 1658c2ecf20Sopenharmony_ci __le16 flags_opcode; /* 15:13 unused, 12:7 opcode, 6:0 flags */ 1668c2ecf20Sopenharmony_ci __le32 nfrags__length; /* 31:8 total len, 7:0 frag count */ 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci __le64 addr_buffer2; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci __le16 encap_descr; /* 15:10 offset of outer L3 header, 1718c2ecf20Sopenharmony_ci * 9:6 number of 32bit words in outer L3 header, 1728c2ecf20Sopenharmony_ci * 5 offload outer L4 checksum, 1738c2ecf20Sopenharmony_ci * 4 offload outer L3 checksum, 1748c2ecf20Sopenharmony_ci * 3 Inner L4 type, TCP=0, UDP=1, 1758c2ecf20Sopenharmony_ci * 2 Inner L3 type, IPv4=0, IPv6=1, 1768c2ecf20Sopenharmony_ci * 1 Outer L3 type,IPv4=0, IPv6=1, 1778c2ecf20Sopenharmony_ci * 0 type of encapsulation, GRE=0, VXLAN=1 1788c2ecf20Sopenharmony_ci */ 1798c2ecf20Sopenharmony_ci __le16 mss; 1808c2ecf20Sopenharmony_ci u8 port_ctxid; /* 7:4 ctxid 3:0 port */ 1818c2ecf20Sopenharmony_ci u8 hdr_length; /* LSO only : MAC+IP+TCP Hdr size */ 1828c2ecf20Sopenharmony_ci u8 outer_hdr_length; /* Encapsulation only */ 1838c2ecf20Sopenharmony_ci u8 rsvd1; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci __le64 addr_buffer3; 1868c2ecf20Sopenharmony_ci __le64 addr_buffer1; 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci __le16 buffer_length[4]; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci __le64 addr_buffer4; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci u8 eth_addr[ETH_ALEN]; 1938c2ecf20Sopenharmony_ci __le16 vlan_TCI; /* In case of encapsulation, 1948c2ecf20Sopenharmony_ci * this is for outer VLAN 1958c2ecf20Sopenharmony_ci */ 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci} __attribute__ ((aligned(64))); 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci/* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ 2008c2ecf20Sopenharmony_cistruct rcv_desc { 2018c2ecf20Sopenharmony_ci __le16 reference_handle; 2028c2ecf20Sopenharmony_ci __le16 reserved; 2038c2ecf20Sopenharmony_ci __le32 buffer_length; /* allocated buffer length (usually 2K) */ 2048c2ecf20Sopenharmony_ci __le64 addr_buffer; 2058c2ecf20Sopenharmony_ci} __packed; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_cistruct status_desc { 2088c2ecf20Sopenharmony_ci __le64 status_desc_data[2]; 2098c2ecf20Sopenharmony_ci} __attribute__ ((aligned(16))); 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci/* UNIFIED ROMIMAGE */ 2128c2ecf20Sopenharmony_ci#define QLCNIC_UNI_FW_MIN_SIZE 0xc8000 2138c2ecf20Sopenharmony_ci#define QLCNIC_UNI_DIR_SECT_PRODUCT_TBL 0x0 2148c2ecf20Sopenharmony_ci#define QLCNIC_UNI_DIR_SECT_BOOTLD 0x6 2158c2ecf20Sopenharmony_ci#define QLCNIC_UNI_DIR_SECT_FW 0x7 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci/*Offsets */ 2188c2ecf20Sopenharmony_ci#define QLCNIC_UNI_CHIP_REV_OFF 10 2198c2ecf20Sopenharmony_ci#define QLCNIC_UNI_FLAGS_OFF 11 2208c2ecf20Sopenharmony_ci#define QLCNIC_UNI_BIOS_VERSION_OFF 12 2218c2ecf20Sopenharmony_ci#define QLCNIC_UNI_BOOTLD_IDX_OFF 27 2228c2ecf20Sopenharmony_ci#define QLCNIC_UNI_FIRMWARE_IDX_OFF 29 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_cistruct uni_table_desc{ 2258c2ecf20Sopenharmony_ci __le32 findex; 2268c2ecf20Sopenharmony_ci __le32 num_entries; 2278c2ecf20Sopenharmony_ci __le32 entry_size; 2288c2ecf20Sopenharmony_ci __le32 reserved[5]; 2298c2ecf20Sopenharmony_ci}; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_cistruct uni_data_desc{ 2328c2ecf20Sopenharmony_ci __le32 findex; 2338c2ecf20Sopenharmony_ci __le32 size; 2348c2ecf20Sopenharmony_ci __le32 reserved[5]; 2358c2ecf20Sopenharmony_ci}; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci/* Flash Defines and Structures */ 2388c2ecf20Sopenharmony_ci#define QLCNIC_FLT_LOCATION 0x3F1000 2398c2ecf20Sopenharmony_ci#define QLCNIC_FDT_LOCATION 0x3F0000 2408c2ecf20Sopenharmony_ci#define QLCNIC_B0_FW_IMAGE_REGION 0x74 2418c2ecf20Sopenharmony_ci#define QLCNIC_C0_FW_IMAGE_REGION 0x97 2428c2ecf20Sopenharmony_ci#define QLCNIC_BOOTLD_REGION 0X72 2438c2ecf20Sopenharmony_cistruct qlcnic_flt_header { 2448c2ecf20Sopenharmony_ci u16 version; 2458c2ecf20Sopenharmony_ci u16 len; 2468c2ecf20Sopenharmony_ci u16 checksum; 2478c2ecf20Sopenharmony_ci u16 reserved; 2488c2ecf20Sopenharmony_ci}; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_cistruct qlcnic_flt_entry { 2518c2ecf20Sopenharmony_ci u8 region; 2528c2ecf20Sopenharmony_ci u8 reserved0; 2538c2ecf20Sopenharmony_ci u8 attrib; 2548c2ecf20Sopenharmony_ci u8 reserved1; 2558c2ecf20Sopenharmony_ci u32 size; 2568c2ecf20Sopenharmony_ci u32 start_addr; 2578c2ecf20Sopenharmony_ci u32 end_addr; 2588c2ecf20Sopenharmony_ci}; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci/* Flash Descriptor Table */ 2618c2ecf20Sopenharmony_cistruct qlcnic_fdt { 2628c2ecf20Sopenharmony_ci u32 valid; 2638c2ecf20Sopenharmony_ci u16 ver; 2648c2ecf20Sopenharmony_ci u16 len; 2658c2ecf20Sopenharmony_ci u16 cksum; 2668c2ecf20Sopenharmony_ci u16 unused; 2678c2ecf20Sopenharmony_ci u8 model[16]; 2688c2ecf20Sopenharmony_ci u8 mfg_id; 2698c2ecf20Sopenharmony_ci u16 id; 2708c2ecf20Sopenharmony_ci u8 flag; 2718c2ecf20Sopenharmony_ci u8 erase_cmd; 2728c2ecf20Sopenharmony_ci u8 alt_erase_cmd; 2738c2ecf20Sopenharmony_ci u8 write_enable_cmd; 2748c2ecf20Sopenharmony_ci u8 write_enable_bits; 2758c2ecf20Sopenharmony_ci u8 write_statusreg_cmd; 2768c2ecf20Sopenharmony_ci u8 unprotected_sec_cmd; 2778c2ecf20Sopenharmony_ci u8 read_manuf_cmd; 2788c2ecf20Sopenharmony_ci u32 block_size; 2798c2ecf20Sopenharmony_ci u32 alt_block_size; 2808c2ecf20Sopenharmony_ci u32 flash_size; 2818c2ecf20Sopenharmony_ci u32 write_enable_data; 2828c2ecf20Sopenharmony_ci u8 readid_addr_len; 2838c2ecf20Sopenharmony_ci u8 write_disable_bits; 2848c2ecf20Sopenharmony_ci u8 read_dev_id_len; 2858c2ecf20Sopenharmony_ci u8 chip_erase_cmd; 2868c2ecf20Sopenharmony_ci u16 read_timeo; 2878c2ecf20Sopenharmony_ci u8 protected_sec_cmd; 2888c2ecf20Sopenharmony_ci u8 resvd[65]; 2898c2ecf20Sopenharmony_ci}; 2908c2ecf20Sopenharmony_ci/* Magic number to let user know flash is programmed */ 2918c2ecf20Sopenharmony_ci#define QLCNIC_BDINFO_MAGIC 0x12345678 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_REF_QG 0x0021 2948c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_HMEZ 0x0022 2958c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10G_CX4_LP 0x0023 2968c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_4_GB 0x0024 2978c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_IMEZ 0x0025 2988c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10G_SFP_PLUS 0x0026 2998c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10000_BASE_T 0x0027 3008c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_XG_LOM 0x0028 3018c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_4_GB_MM 0x0029 3028c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10G_SFP_CT 0x002a 3038c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10G_SFP_QT 0x002b 3048c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10G_CX4 0x0031 3058c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10G_XFP 0x0032 3068c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_P3P_10G_TP 0x0080 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci#define QLCNIC_MSIX_TABLE_OFFSET 0x44 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci/* Flash memory map */ 3118c2ecf20Sopenharmony_ci#define QLCNIC_BRDCFG_START 0x4000 /* board config */ 3128c2ecf20Sopenharmony_ci#define QLCNIC_BOOTLD_START 0x10000 /* bootld */ 3138c2ecf20Sopenharmony_ci#define QLCNIC_IMAGE_START 0x43000 /* compressed image */ 3148c2ecf20Sopenharmony_ci#define QLCNIC_USER_START 0x3E8000 /* Firmware info */ 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci#define QLCNIC_FW_VERSION_OFFSET (QLCNIC_USER_START+0x408) 3178c2ecf20Sopenharmony_ci#define QLCNIC_FW_SIZE_OFFSET (QLCNIC_USER_START+0x40c) 3188c2ecf20Sopenharmony_ci#define QLCNIC_FW_SERIAL_NUM_OFFSET (QLCNIC_USER_START+0x81c) 3198c2ecf20Sopenharmony_ci#define QLCNIC_BIOS_VERSION_OFFSET (QLCNIC_USER_START+0x83c) 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci#define QLCNIC_BRDTYPE_OFFSET (QLCNIC_BRDCFG_START+0x8) 3228c2ecf20Sopenharmony_ci#define QLCNIC_FW_MAGIC_OFFSET (QLCNIC_BRDCFG_START+0x128) 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci#define QLCNIC_FW_MIN_SIZE (0x3fffff) 3258c2ecf20Sopenharmony_ci#define QLCNIC_UNIFIED_ROMIMAGE 0 3268c2ecf20Sopenharmony_ci#define QLCNIC_FLASH_ROMIMAGE 1 3278c2ecf20Sopenharmony_ci#define QLCNIC_UNKNOWN_ROMIMAGE 0xff 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci#define QLCNIC_UNIFIED_ROMIMAGE_NAME "phanfw.bin" 3308c2ecf20Sopenharmony_ci#define QLCNIC_FLASH_ROMIMAGE_NAME "flash" 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ciextern char qlcnic_driver_name[]; 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ciextern int qlcnic_use_msi; 3358c2ecf20Sopenharmony_ciextern int qlcnic_use_msi_x; 3368c2ecf20Sopenharmony_ciextern int qlcnic_auto_fw_reset; 3378c2ecf20Sopenharmony_ciextern int qlcnic_load_fw_file; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci/* Number of status descriptors to handle per interrupt */ 3408c2ecf20Sopenharmony_ci#define MAX_STATUS_HANDLE (64) 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci/* 3438c2ecf20Sopenharmony_ci * qlcnic_skb_frag{} is to contain mapping info for each SG list. This 3448c2ecf20Sopenharmony_ci * has to be freed when DMA is complete. This is part of qlcnic_tx_buffer{}. 3458c2ecf20Sopenharmony_ci */ 3468c2ecf20Sopenharmony_cistruct qlcnic_skb_frag { 3478c2ecf20Sopenharmony_ci u64 dma; 3488c2ecf20Sopenharmony_ci u64 length; 3498c2ecf20Sopenharmony_ci}; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci/* Following defines are for the state of the buffers */ 3528c2ecf20Sopenharmony_ci#define QLCNIC_BUFFER_FREE 0 3538c2ecf20Sopenharmony_ci#define QLCNIC_BUFFER_BUSY 1 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci/* 3568c2ecf20Sopenharmony_ci * There will be one qlcnic_buffer per skb packet. These will be 3578c2ecf20Sopenharmony_ci * used to save the dma info for pci_unmap_page() 3588c2ecf20Sopenharmony_ci */ 3598c2ecf20Sopenharmony_cistruct qlcnic_cmd_buffer { 3608c2ecf20Sopenharmony_ci struct sk_buff *skb; 3618c2ecf20Sopenharmony_ci struct qlcnic_skb_frag frag_array[MAX_SKB_FRAGS + 1]; 3628c2ecf20Sopenharmony_ci u32 frag_count; 3638c2ecf20Sopenharmony_ci}; 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci/* In rx_buffer, we do not need multiple fragments as is a single buffer */ 3668c2ecf20Sopenharmony_cistruct qlcnic_rx_buffer { 3678c2ecf20Sopenharmony_ci u16 ref_handle; 3688c2ecf20Sopenharmony_ci struct sk_buff *skb; 3698c2ecf20Sopenharmony_ci struct list_head list; 3708c2ecf20Sopenharmony_ci u64 dma; 3718c2ecf20Sopenharmony_ci}; 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci/* Board types */ 3748c2ecf20Sopenharmony_ci#define QLCNIC_GBE 0x01 3758c2ecf20Sopenharmony_ci#define QLCNIC_XGBE 0x02 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci/* 3788c2ecf20Sopenharmony_ci * Interrupt coalescing defaults. The defaults are for 1500 MTU. It is 3798c2ecf20Sopenharmony_ci * adjusted based on configured MTU. 3808c2ecf20Sopenharmony_ci */ 3818c2ecf20Sopenharmony_ci#define QLCNIC_INTR_COAL_TYPE_RX 1 3828c2ecf20Sopenharmony_ci#define QLCNIC_INTR_COAL_TYPE_TX 2 3838c2ecf20Sopenharmony_ci#define QLCNIC_INTR_COAL_TYPE_RX_TX 3 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci#define QLCNIC_DEF_INTR_COALESCE_RX_TIME_US 3 3868c2ecf20Sopenharmony_ci#define QLCNIC_DEF_INTR_COALESCE_RX_PACKETS 256 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci#define QLCNIC_DEF_INTR_COALESCE_TX_TIME_US 64 3898c2ecf20Sopenharmony_ci#define QLCNIC_DEF_INTR_COALESCE_TX_PACKETS 64 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci#define QLCNIC_INTR_DEFAULT 0x04 3928c2ecf20Sopenharmony_ci#define QLCNIC_CONFIG_INTR_COALESCE 3 3938c2ecf20Sopenharmony_ci#define QLCNIC_DEV_INFO_SIZE 2 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistruct qlcnic_nic_intr_coalesce { 3968c2ecf20Sopenharmony_ci u8 type; 3978c2ecf20Sopenharmony_ci u8 sts_ring_mask; 3988c2ecf20Sopenharmony_ci u16 rx_packets; 3998c2ecf20Sopenharmony_ci u16 rx_time_us; 4008c2ecf20Sopenharmony_ci u16 tx_packets; 4018c2ecf20Sopenharmony_ci u16 tx_time_us; 4028c2ecf20Sopenharmony_ci u16 flag; 4038c2ecf20Sopenharmony_ci u32 timer_out; 4048c2ecf20Sopenharmony_ci}; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_cistruct qlcnic_83xx_dump_template_hdr { 4078c2ecf20Sopenharmony_ci u32 type; 4088c2ecf20Sopenharmony_ci u32 offset; 4098c2ecf20Sopenharmony_ci u32 size; 4108c2ecf20Sopenharmony_ci u32 cap_mask; 4118c2ecf20Sopenharmony_ci u32 num_entries; 4128c2ecf20Sopenharmony_ci u32 version; 4138c2ecf20Sopenharmony_ci u32 timestamp; 4148c2ecf20Sopenharmony_ci u32 checksum; 4158c2ecf20Sopenharmony_ci u32 drv_cap_mask; 4168c2ecf20Sopenharmony_ci u32 sys_info[3]; 4178c2ecf20Sopenharmony_ci u32 saved_state[16]; 4188c2ecf20Sopenharmony_ci u32 cap_sizes[8]; 4198c2ecf20Sopenharmony_ci u32 ocm_wnd_reg[16]; 4208c2ecf20Sopenharmony_ci u32 rsvd[]; 4218c2ecf20Sopenharmony_ci}; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_cistruct qlcnic_82xx_dump_template_hdr { 4248c2ecf20Sopenharmony_ci u32 type; 4258c2ecf20Sopenharmony_ci u32 offset; 4268c2ecf20Sopenharmony_ci u32 size; 4278c2ecf20Sopenharmony_ci u32 cap_mask; 4288c2ecf20Sopenharmony_ci u32 num_entries; 4298c2ecf20Sopenharmony_ci u32 version; 4308c2ecf20Sopenharmony_ci u32 timestamp; 4318c2ecf20Sopenharmony_ci u32 checksum; 4328c2ecf20Sopenharmony_ci u32 drv_cap_mask; 4338c2ecf20Sopenharmony_ci u32 sys_info[3]; 4348c2ecf20Sopenharmony_ci u32 saved_state[16]; 4358c2ecf20Sopenharmony_ci u32 cap_sizes[8]; 4368c2ecf20Sopenharmony_ci u32 rsvd[7]; 4378c2ecf20Sopenharmony_ci u32 capabilities; 4388c2ecf20Sopenharmony_ci u32 rsvd1[]; 4398c2ecf20Sopenharmony_ci}; 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ci#define QLC_PEX_DMA_READ_SIZE (PAGE_SIZE * 16) 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_cistruct qlcnic_fw_dump { 4448c2ecf20Sopenharmony_ci u8 clr; /* flag to indicate if dump is cleared */ 4458c2ecf20Sopenharmony_ci bool enable; /* enable/disable dump */ 4468c2ecf20Sopenharmony_ci u32 size; /* total size of the dump */ 4478c2ecf20Sopenharmony_ci u32 cap_mask; /* Current capture mask */ 4488c2ecf20Sopenharmony_ci void *data; /* dump data area */ 4498c2ecf20Sopenharmony_ci void *tmpl_hdr; 4508c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 4518c2ecf20Sopenharmony_ci void *dma_buffer; 4528c2ecf20Sopenharmony_ci bool use_pex_dma; 4538c2ecf20Sopenharmony_ci /* Read only elements which are common between 82xx and 83xx 4548c2ecf20Sopenharmony_ci * template header. Update these values immediately after we read 4558c2ecf20Sopenharmony_ci * template header from Firmware 4568c2ecf20Sopenharmony_ci */ 4578c2ecf20Sopenharmony_ci u32 tmpl_hdr_size; 4588c2ecf20Sopenharmony_ci u32 version; 4598c2ecf20Sopenharmony_ci u32 num_entries; 4608c2ecf20Sopenharmony_ci u32 offset; 4618c2ecf20Sopenharmony_ci}; 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci/* 4648c2ecf20Sopenharmony_ci * One hardware_context{} per adapter 4658c2ecf20Sopenharmony_ci * contains interrupt info as well shared hardware info. 4668c2ecf20Sopenharmony_ci */ 4678c2ecf20Sopenharmony_cistruct qlcnic_hardware_context { 4688c2ecf20Sopenharmony_ci void __iomem *pci_base0; 4698c2ecf20Sopenharmony_ci void __iomem *ocm_win_crb; 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci unsigned long pci_len0; 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci rwlock_t crb_lock; 4748c2ecf20Sopenharmony_ci struct mutex mem_lock; 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci u8 revision_id; 4778c2ecf20Sopenharmony_ci u8 pci_func; 4788c2ecf20Sopenharmony_ci u8 linkup; 4798c2ecf20Sopenharmony_ci u8 loopback_state; 4808c2ecf20Sopenharmony_ci u8 beacon_state; 4818c2ecf20Sopenharmony_ci u8 has_link_events; 4828c2ecf20Sopenharmony_ci u8 fw_type; 4838c2ecf20Sopenharmony_ci u8 physical_port; 4848c2ecf20Sopenharmony_ci u8 reset_context; 4858c2ecf20Sopenharmony_ci u8 msix_supported; 4868c2ecf20Sopenharmony_ci u8 max_mac_filters; 4878c2ecf20Sopenharmony_ci u8 mc_enabled; 4888c2ecf20Sopenharmony_ci u8 max_mc_count; 4898c2ecf20Sopenharmony_ci u8 diag_test; 4908c2ecf20Sopenharmony_ci u8 num_msix; 4918c2ecf20Sopenharmony_ci u8 nic_mode; 4928c2ecf20Sopenharmony_ci int diag_cnt; 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci u16 max_uc_count; 4958c2ecf20Sopenharmony_ci u16 port_type; 4968c2ecf20Sopenharmony_ci u16 board_type; 4978c2ecf20Sopenharmony_ci u16 supported_type; 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci u32 link_speed; 5008c2ecf20Sopenharmony_ci u16 link_duplex; 5018c2ecf20Sopenharmony_ci u16 link_autoneg; 5028c2ecf20Sopenharmony_ci u16 module_type; 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci u16 op_mode; 5058c2ecf20Sopenharmony_ci u16 switch_mode; 5068c2ecf20Sopenharmony_ci u16 max_tx_ques; 5078c2ecf20Sopenharmony_ci u16 max_rx_ques; 5088c2ecf20Sopenharmony_ci u16 max_mtu; 5098c2ecf20Sopenharmony_ci u32 msg_enable; 5108c2ecf20Sopenharmony_ci u16 total_nic_func; 5118c2ecf20Sopenharmony_ci u16 max_pci_func; 5128c2ecf20Sopenharmony_ci u32 max_vnic_func; 5138c2ecf20Sopenharmony_ci u32 total_pci_func; 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci u32 capabilities; 5168c2ecf20Sopenharmony_ci u32 extra_capability[3]; 5178c2ecf20Sopenharmony_ci u32 temp; 5188c2ecf20Sopenharmony_ci u32 int_vec_bit; 5198c2ecf20Sopenharmony_ci u32 fw_hal_version; 5208c2ecf20Sopenharmony_ci u32 port_config; 5218c2ecf20Sopenharmony_ci struct qlcnic_hardware_ops *hw_ops; 5228c2ecf20Sopenharmony_ci struct qlcnic_nic_intr_coalesce coal; 5238c2ecf20Sopenharmony_ci struct qlcnic_fw_dump fw_dump; 5248c2ecf20Sopenharmony_ci struct qlcnic_fdt fdt; 5258c2ecf20Sopenharmony_ci struct qlc_83xx_reset reset; 5268c2ecf20Sopenharmony_ci struct qlc_83xx_idc idc; 5278c2ecf20Sopenharmony_ci struct qlc_83xx_fw_info *fw_info; 5288c2ecf20Sopenharmony_ci struct qlcnic_intrpt_config *intr_tbl; 5298c2ecf20Sopenharmony_ci struct qlcnic_sriov *sriov; 5308c2ecf20Sopenharmony_ci u32 *reg_tbl; 5318c2ecf20Sopenharmony_ci u32 *ext_reg_tbl; 5328c2ecf20Sopenharmony_ci u32 mbox_aen[QLC_83XX_MBX_AEN_CNT]; 5338c2ecf20Sopenharmony_ci u32 mbox_reg[4]; 5348c2ecf20Sopenharmony_ci struct qlcnic_mailbox *mailbox; 5358c2ecf20Sopenharmony_ci u8 extend_lb_time; 5368c2ecf20Sopenharmony_ci u8 phys_port_id[ETH_ALEN]; 5378c2ecf20Sopenharmony_ci u8 lb_mode; 5388c2ecf20Sopenharmony_ci struct device *hwmon_dev; 5398c2ecf20Sopenharmony_ci u32 post_mode; 5408c2ecf20Sopenharmony_ci bool run_post; 5418c2ecf20Sopenharmony_ci}; 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_cistruct qlcnic_adapter_stats { 5448c2ecf20Sopenharmony_ci u64 xmitcalled; 5458c2ecf20Sopenharmony_ci u64 xmitfinished; 5468c2ecf20Sopenharmony_ci u64 rxdropped; 5478c2ecf20Sopenharmony_ci u64 txdropped; 5488c2ecf20Sopenharmony_ci u64 csummed; 5498c2ecf20Sopenharmony_ci u64 rx_pkts; 5508c2ecf20Sopenharmony_ci u64 lro_pkts; 5518c2ecf20Sopenharmony_ci u64 rxbytes; 5528c2ecf20Sopenharmony_ci u64 txbytes; 5538c2ecf20Sopenharmony_ci u64 lrobytes; 5548c2ecf20Sopenharmony_ci u64 lso_frames; 5558c2ecf20Sopenharmony_ci u64 encap_lso_frames; 5568c2ecf20Sopenharmony_ci u64 encap_tx_csummed; 5578c2ecf20Sopenharmony_ci u64 encap_rx_csummed; 5588c2ecf20Sopenharmony_ci u64 xmit_on; 5598c2ecf20Sopenharmony_ci u64 xmit_off; 5608c2ecf20Sopenharmony_ci u64 skb_alloc_failure; 5618c2ecf20Sopenharmony_ci u64 null_rxbuf; 5628c2ecf20Sopenharmony_ci u64 rx_dma_map_error; 5638c2ecf20Sopenharmony_ci u64 tx_dma_map_error; 5648c2ecf20Sopenharmony_ci u64 spurious_intr; 5658c2ecf20Sopenharmony_ci u64 mac_filter_limit_overrun; 5668c2ecf20Sopenharmony_ci u64 mbx_spurious_intr; 5678c2ecf20Sopenharmony_ci}; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci/* 5708c2ecf20Sopenharmony_ci * Rcv Descriptor Context. One such per Rcv Descriptor. There may 5718c2ecf20Sopenharmony_ci * be one Rcv Descriptor for normal packets, one for jumbo and may be others. 5728c2ecf20Sopenharmony_ci */ 5738c2ecf20Sopenharmony_cistruct qlcnic_host_rds_ring { 5748c2ecf20Sopenharmony_ci void __iomem *crb_rcv_producer; 5758c2ecf20Sopenharmony_ci struct rcv_desc *desc_head; 5768c2ecf20Sopenharmony_ci struct qlcnic_rx_buffer *rx_buf_arr; 5778c2ecf20Sopenharmony_ci u32 num_desc; 5788c2ecf20Sopenharmony_ci u32 producer; 5798c2ecf20Sopenharmony_ci u32 dma_size; 5808c2ecf20Sopenharmony_ci u32 skb_size; 5818c2ecf20Sopenharmony_ci u32 flags; 5828c2ecf20Sopenharmony_ci struct list_head free_list; 5838c2ecf20Sopenharmony_ci spinlock_t lock; 5848c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 5858c2ecf20Sopenharmony_ci} ____cacheline_internodealigned_in_smp; 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_cistruct qlcnic_host_sds_ring { 5888c2ecf20Sopenharmony_ci u32 consumer; 5898c2ecf20Sopenharmony_ci u32 num_desc; 5908c2ecf20Sopenharmony_ci void __iomem *crb_sts_consumer; 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring; 5938c2ecf20Sopenharmony_ci struct status_desc *desc_head; 5948c2ecf20Sopenharmony_ci struct qlcnic_adapter *adapter; 5958c2ecf20Sopenharmony_ci struct napi_struct napi; 5968c2ecf20Sopenharmony_ci struct list_head free_list[NUM_RCV_DESC_RINGS]; 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci void __iomem *crb_intr_mask; 5998c2ecf20Sopenharmony_ci int irq; 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 6028c2ecf20Sopenharmony_ci char name[IFNAMSIZ + 12]; 6038c2ecf20Sopenharmony_ci} ____cacheline_internodealigned_in_smp; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_cistruct qlcnic_tx_queue_stats { 6068c2ecf20Sopenharmony_ci u64 xmit_on; 6078c2ecf20Sopenharmony_ci u64 xmit_off; 6088c2ecf20Sopenharmony_ci u64 xmit_called; 6098c2ecf20Sopenharmony_ci u64 xmit_finished; 6108c2ecf20Sopenharmony_ci u64 tx_bytes; 6118c2ecf20Sopenharmony_ci}; 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_cistruct qlcnic_host_tx_ring { 6148c2ecf20Sopenharmony_ci int irq; 6158c2ecf20Sopenharmony_ci void __iomem *crb_intr_mask; 6168c2ecf20Sopenharmony_ci char name[IFNAMSIZ + 12]; 6178c2ecf20Sopenharmony_ci u16 ctx_id; 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci u32 state; 6208c2ecf20Sopenharmony_ci u32 producer; 6218c2ecf20Sopenharmony_ci u32 sw_consumer; 6228c2ecf20Sopenharmony_ci u32 num_desc; 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci struct qlcnic_tx_queue_stats tx_stats; 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci void __iomem *crb_cmd_producer; 6278c2ecf20Sopenharmony_ci struct cmd_desc_type0 *desc_head; 6288c2ecf20Sopenharmony_ci struct qlcnic_adapter *adapter; 6298c2ecf20Sopenharmony_ci struct napi_struct napi; 6308c2ecf20Sopenharmony_ci struct qlcnic_cmd_buffer *cmd_buf_arr; 6318c2ecf20Sopenharmony_ci __le32 *hw_consumer; 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 6348c2ecf20Sopenharmony_ci dma_addr_t hw_cons_phys_addr; 6358c2ecf20Sopenharmony_ci struct netdev_queue *txq; 6368c2ecf20Sopenharmony_ci /* Lock to protect Tx descriptors cleanup */ 6378c2ecf20Sopenharmony_ci spinlock_t tx_clean_lock; 6388c2ecf20Sopenharmony_ci} ____cacheline_internodealigned_in_smp; 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci/* 6418c2ecf20Sopenharmony_ci * Receive context. There is one such structure per instance of the 6428c2ecf20Sopenharmony_ci * receive processing. Any state information that is relevant to 6438c2ecf20Sopenharmony_ci * the receive, and is must be in this structure. The global data may be 6448c2ecf20Sopenharmony_ci * present elsewhere. 6458c2ecf20Sopenharmony_ci */ 6468c2ecf20Sopenharmony_cistruct qlcnic_recv_context { 6478c2ecf20Sopenharmony_ci struct qlcnic_host_rds_ring *rds_rings; 6488c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *sds_rings; 6498c2ecf20Sopenharmony_ci u32 state; 6508c2ecf20Sopenharmony_ci u16 context_id; 6518c2ecf20Sopenharmony_ci u16 virt_port; 6528c2ecf20Sopenharmony_ci}; 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci/* HW context creation */ 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci#define QLCNIC_OS_CRB_RETRY_COUNT 4000 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci#define QLCNIC_CDRP_CMD_BIT 0x80000000 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci/* 6618c2ecf20Sopenharmony_ci * All responses must have the QLCNIC_CDRP_CMD_BIT cleared 6628c2ecf20Sopenharmony_ci * in the crb QLCNIC_CDRP_CRB_OFFSET. 6638c2ecf20Sopenharmony_ci */ 6648c2ecf20Sopenharmony_ci#define QLCNIC_CDRP_FORM_RSP(rsp) (rsp) 6658c2ecf20Sopenharmony_ci#define QLCNIC_CDRP_IS_RSP(rsp) (((rsp) & QLCNIC_CDRP_CMD_BIT) == 0) 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci#define QLCNIC_CDRP_RSP_OK 0x00000001 6688c2ecf20Sopenharmony_ci#define QLCNIC_CDRP_RSP_FAIL 0x00000002 6698c2ecf20Sopenharmony_ci#define QLCNIC_CDRP_RSP_TIMEOUT 0x00000003 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ci/* 6728c2ecf20Sopenharmony_ci * All commands must have the QLCNIC_CDRP_CMD_BIT set in 6738c2ecf20Sopenharmony_ci * the crb QLCNIC_CDRP_CRB_OFFSET. 6748c2ecf20Sopenharmony_ci */ 6758c2ecf20Sopenharmony_ci#define QLCNIC_CDRP_FORM_CMD(cmd) (QLCNIC_CDRP_CMD_BIT | (cmd)) 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci#define QLCNIC_RCODE_SUCCESS 0 6788c2ecf20Sopenharmony_ci#define QLCNIC_RCODE_INVALID_ARGS 6 6798c2ecf20Sopenharmony_ci#define QLCNIC_RCODE_NOT_SUPPORTED 9 6808c2ecf20Sopenharmony_ci#define QLCNIC_RCODE_NOT_PERMITTED 10 6818c2ecf20Sopenharmony_ci#define QLCNIC_RCODE_NOT_IMPL 15 6828c2ecf20Sopenharmony_ci#define QLCNIC_RCODE_INVALID 16 6838c2ecf20Sopenharmony_ci#define QLCNIC_RCODE_TIMEOUT 17 6848c2ecf20Sopenharmony_ci#define QLCNIC_DESTROY_CTX_RESET 0 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ci/* 6878c2ecf20Sopenharmony_ci * Capabilities Announced 6888c2ecf20Sopenharmony_ci */ 6898c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_LEGACY_CONTEXT (1) 6908c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_LEGACY_MN (1 << 2) 6918c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_LSO (1 << 6) 6928c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_JUMBO_CONTIGUOUS (1 << 7) 6938c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_LRO_CONTIGUOUS (1 << 8) 6948c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_VALIDOFF (1 << 11) 6958c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_LRO_MSS (1 << 21) 6968c2ecf20Sopenharmony_ci#define QLCNIC_CAP0_TX_MULTI (1 << 22) 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci/* 6998c2ecf20Sopenharmony_ci * Context state 7008c2ecf20Sopenharmony_ci */ 7018c2ecf20Sopenharmony_ci#define QLCNIC_HOST_CTX_STATE_FREED 0 7028c2ecf20Sopenharmony_ci#define QLCNIC_HOST_CTX_STATE_ACTIVE 2 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci/* 7058c2ecf20Sopenharmony_ci * Rx context 7068c2ecf20Sopenharmony_ci */ 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_cistruct qlcnic_hostrq_sds_ring { 7098c2ecf20Sopenharmony_ci __le64 host_phys_addr; /* Ring base addr */ 7108c2ecf20Sopenharmony_ci __le32 ring_size; /* Ring entries */ 7118c2ecf20Sopenharmony_ci __le16 msi_index; 7128c2ecf20Sopenharmony_ci __le16 rsvd; /* Padding */ 7138c2ecf20Sopenharmony_ci} __packed; 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_cistruct qlcnic_hostrq_rds_ring { 7168c2ecf20Sopenharmony_ci __le64 host_phys_addr; /* Ring base addr */ 7178c2ecf20Sopenharmony_ci __le64 buff_size; /* Packet buffer size */ 7188c2ecf20Sopenharmony_ci __le32 ring_size; /* Ring entries */ 7198c2ecf20Sopenharmony_ci __le32 ring_kind; /* Class of ring */ 7208c2ecf20Sopenharmony_ci} __packed; 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_cistruct qlcnic_hostrq_rx_ctx { 7238c2ecf20Sopenharmony_ci __le64 host_rsp_dma_addr; /* Response dma'd here */ 7248c2ecf20Sopenharmony_ci __le32 capabilities[4]; /* Flag bit vector */ 7258c2ecf20Sopenharmony_ci __le32 host_int_crb_mode; /* Interrupt crb usage */ 7268c2ecf20Sopenharmony_ci __le32 host_rds_crb_mode; /* RDS crb usage */ 7278c2ecf20Sopenharmony_ci /* These ring offsets are relative to data[0] below */ 7288c2ecf20Sopenharmony_ci __le32 rds_ring_offset; /* Offset to RDS config */ 7298c2ecf20Sopenharmony_ci __le32 sds_ring_offset; /* Offset to SDS config */ 7308c2ecf20Sopenharmony_ci __le16 num_rds_rings; /* Count of RDS rings */ 7318c2ecf20Sopenharmony_ci __le16 num_sds_rings; /* Count of SDS rings */ 7328c2ecf20Sopenharmony_ci __le16 valid_field_offset; 7338c2ecf20Sopenharmony_ci u8 txrx_sds_binding; 7348c2ecf20Sopenharmony_ci u8 msix_handler; 7358c2ecf20Sopenharmony_ci u8 reserved[128]; /* reserve space for future expansion*/ 7368c2ecf20Sopenharmony_ci /* MUST BE 64-bit aligned. 7378c2ecf20Sopenharmony_ci The following is packed: 7388c2ecf20Sopenharmony_ci - N hostrq_rds_rings 7398c2ecf20Sopenharmony_ci - N hostrq_sds_rings */ 7408c2ecf20Sopenharmony_ci char data[]; 7418c2ecf20Sopenharmony_ci} __packed; 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_cistruct qlcnic_cardrsp_rds_ring{ 7448c2ecf20Sopenharmony_ci __le32 host_producer_crb; /* Crb to use */ 7458c2ecf20Sopenharmony_ci __le32 rsvd1; /* Padding */ 7468c2ecf20Sopenharmony_ci} __packed; 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_cistruct qlcnic_cardrsp_sds_ring { 7498c2ecf20Sopenharmony_ci __le32 host_consumer_crb; /* Crb to use */ 7508c2ecf20Sopenharmony_ci __le32 interrupt_crb; /* Crb to use */ 7518c2ecf20Sopenharmony_ci} __packed; 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_cistruct qlcnic_cardrsp_rx_ctx { 7548c2ecf20Sopenharmony_ci /* These ring offsets are relative to data[0] below */ 7558c2ecf20Sopenharmony_ci __le32 rds_ring_offset; /* Offset to RDS config */ 7568c2ecf20Sopenharmony_ci __le32 sds_ring_offset; /* Offset to SDS config */ 7578c2ecf20Sopenharmony_ci __le32 host_ctx_state; /* Starting State */ 7588c2ecf20Sopenharmony_ci __le32 num_fn_per_port; /* How many PCI fn share the port */ 7598c2ecf20Sopenharmony_ci __le16 num_rds_rings; /* Count of RDS rings */ 7608c2ecf20Sopenharmony_ci __le16 num_sds_rings; /* Count of SDS rings */ 7618c2ecf20Sopenharmony_ci __le16 context_id; /* Handle for context */ 7628c2ecf20Sopenharmony_ci u8 phys_port; /* Physical id of port */ 7638c2ecf20Sopenharmony_ci u8 virt_port; /* Virtual/Logical id of port */ 7648c2ecf20Sopenharmony_ci u8 reserved[128]; /* save space for future expansion */ 7658c2ecf20Sopenharmony_ci /* MUST BE 64-bit aligned. 7668c2ecf20Sopenharmony_ci The following is packed: 7678c2ecf20Sopenharmony_ci - N cardrsp_rds_rings 7688c2ecf20Sopenharmony_ci - N cardrs_sds_rings */ 7698c2ecf20Sopenharmony_ci char data[]; 7708c2ecf20Sopenharmony_ci} __packed; 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ci#define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \ 7738c2ecf20Sopenharmony_ci (sizeof(HOSTRQ_RX) + \ 7748c2ecf20Sopenharmony_ci (rds_rings)*(sizeof(struct qlcnic_hostrq_rds_ring)) + \ 7758c2ecf20Sopenharmony_ci (sds_rings)*(sizeof(struct qlcnic_hostrq_sds_ring))) 7768c2ecf20Sopenharmony_ci 7778c2ecf20Sopenharmony_ci#define SIZEOF_CARDRSP_RX(CARDRSP_RX, rds_rings, sds_rings) \ 7788c2ecf20Sopenharmony_ci (sizeof(CARDRSP_RX) + \ 7798c2ecf20Sopenharmony_ci (rds_rings)*(sizeof(struct qlcnic_cardrsp_rds_ring)) + \ 7808c2ecf20Sopenharmony_ci (sds_rings)*(sizeof(struct qlcnic_cardrsp_sds_ring))) 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_ci/* 7838c2ecf20Sopenharmony_ci * Tx context 7848c2ecf20Sopenharmony_ci */ 7858c2ecf20Sopenharmony_ci 7868c2ecf20Sopenharmony_cistruct qlcnic_hostrq_cds_ring { 7878c2ecf20Sopenharmony_ci __le64 host_phys_addr; /* Ring base addr */ 7888c2ecf20Sopenharmony_ci __le32 ring_size; /* Ring entries */ 7898c2ecf20Sopenharmony_ci __le32 rsvd; /* Padding */ 7908c2ecf20Sopenharmony_ci} __packed; 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_cistruct qlcnic_hostrq_tx_ctx { 7938c2ecf20Sopenharmony_ci __le64 host_rsp_dma_addr; /* Response dma'd here */ 7948c2ecf20Sopenharmony_ci __le64 cmd_cons_dma_addr; /* */ 7958c2ecf20Sopenharmony_ci __le64 dummy_dma_addr; /* */ 7968c2ecf20Sopenharmony_ci __le32 capabilities[4]; /* Flag bit vector */ 7978c2ecf20Sopenharmony_ci __le32 host_int_crb_mode; /* Interrupt crb usage */ 7988c2ecf20Sopenharmony_ci __le32 rsvd1; /* Padding */ 7998c2ecf20Sopenharmony_ci __le16 rsvd2; /* Padding */ 8008c2ecf20Sopenharmony_ci __le16 interrupt_ctl; 8018c2ecf20Sopenharmony_ci __le16 msi_index; 8028c2ecf20Sopenharmony_ci __le16 rsvd3; /* Padding */ 8038c2ecf20Sopenharmony_ci struct qlcnic_hostrq_cds_ring cds_ring; /* Desc of cds ring */ 8048c2ecf20Sopenharmony_ci u8 reserved[128]; /* future expansion */ 8058c2ecf20Sopenharmony_ci} __packed; 8068c2ecf20Sopenharmony_ci 8078c2ecf20Sopenharmony_cistruct qlcnic_cardrsp_cds_ring { 8088c2ecf20Sopenharmony_ci __le32 host_producer_crb; /* Crb to use */ 8098c2ecf20Sopenharmony_ci __le32 interrupt_crb; /* Crb to use */ 8108c2ecf20Sopenharmony_ci} __packed; 8118c2ecf20Sopenharmony_ci 8128c2ecf20Sopenharmony_cistruct qlcnic_cardrsp_tx_ctx { 8138c2ecf20Sopenharmony_ci __le32 host_ctx_state; /* Starting state */ 8148c2ecf20Sopenharmony_ci __le16 context_id; /* Handle for context */ 8158c2ecf20Sopenharmony_ci u8 phys_port; /* Physical id of port */ 8168c2ecf20Sopenharmony_ci u8 virt_port; /* Virtual/Logical id of port */ 8178c2ecf20Sopenharmony_ci struct qlcnic_cardrsp_cds_ring cds_ring; /* Card cds settings */ 8188c2ecf20Sopenharmony_ci u8 reserved[128]; /* future expansion */ 8198c2ecf20Sopenharmony_ci} __packed; 8208c2ecf20Sopenharmony_ci 8218c2ecf20Sopenharmony_ci#define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) (sizeof(HOSTRQ_TX)) 8228c2ecf20Sopenharmony_ci#define SIZEOF_CARDRSP_TX(CARDRSP_TX) (sizeof(CARDRSP_TX)) 8238c2ecf20Sopenharmony_ci 8248c2ecf20Sopenharmony_ci/* CRB */ 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ci#define QLCNIC_HOST_RDS_CRB_MODE_UNIQUE 0 8278c2ecf20Sopenharmony_ci#define QLCNIC_HOST_RDS_CRB_MODE_SHARED 1 8288c2ecf20Sopenharmony_ci#define QLCNIC_HOST_RDS_CRB_MODE_CUSTOM 2 8298c2ecf20Sopenharmony_ci#define QLCNIC_HOST_RDS_CRB_MODE_MAX 3 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_ci#define QLCNIC_HOST_INT_CRB_MODE_UNIQUE 0 8328c2ecf20Sopenharmony_ci#define QLCNIC_HOST_INT_CRB_MODE_SHARED 1 8338c2ecf20Sopenharmony_ci#define QLCNIC_HOST_INT_CRB_MODE_NORX 2 8348c2ecf20Sopenharmony_ci#define QLCNIC_HOST_INT_CRB_MODE_NOTX 3 8358c2ecf20Sopenharmony_ci#define QLCNIC_HOST_INT_CRB_MODE_NORXTX 4 8368c2ecf20Sopenharmony_ci 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci/* MAC */ 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ci#define MC_COUNT_P3P 38 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci#define QLCNIC_MAC_NOOP 0 8438c2ecf20Sopenharmony_ci#define QLCNIC_MAC_ADD 1 8448c2ecf20Sopenharmony_ci#define QLCNIC_MAC_DEL 2 8458c2ecf20Sopenharmony_ci#define QLCNIC_MAC_VLAN_ADD 3 8468c2ecf20Sopenharmony_ci#define QLCNIC_MAC_VLAN_DEL 4 8478c2ecf20Sopenharmony_ci 8488c2ecf20Sopenharmony_cienum qlcnic_mac_type { 8498c2ecf20Sopenharmony_ci QLCNIC_UNICAST_MAC, 8508c2ecf20Sopenharmony_ci QLCNIC_MULTICAST_MAC, 8518c2ecf20Sopenharmony_ci QLCNIC_BROADCAST_MAC, 8528c2ecf20Sopenharmony_ci}; 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_cistruct qlcnic_mac_vlan_list { 8558c2ecf20Sopenharmony_ci struct list_head list; 8568c2ecf20Sopenharmony_ci uint8_t mac_addr[ETH_ALEN+2]; 8578c2ecf20Sopenharmony_ci u16 vlan_id; 8588c2ecf20Sopenharmony_ci enum qlcnic_mac_type mac_type; 8598c2ecf20Sopenharmony_ci}; 8608c2ecf20Sopenharmony_ci 8618c2ecf20Sopenharmony_ci/* MAC Learn */ 8628c2ecf20Sopenharmony_ci#define NO_MAC_LEARN 0 8638c2ecf20Sopenharmony_ci#define DRV_MAC_LEARN 1 8648c2ecf20Sopenharmony_ci#define FDB_MAC_LEARN 2 8658c2ecf20Sopenharmony_ci 8668c2ecf20Sopenharmony_ci#define QLCNIC_HOST_REQUEST 0x13 8678c2ecf20Sopenharmony_ci#define QLCNIC_REQUEST 0x14 8688c2ecf20Sopenharmony_ci 8698c2ecf20Sopenharmony_ci#define QLCNIC_MAC_EVENT 0x1 8708c2ecf20Sopenharmony_ci 8718c2ecf20Sopenharmony_ci#define QLCNIC_IP_UP 2 8728c2ecf20Sopenharmony_ci#define QLCNIC_IP_DOWN 3 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_ci#define QLCNIC_ILB_MODE 0x1 8758c2ecf20Sopenharmony_ci#define QLCNIC_ELB_MODE 0x2 8768c2ecf20Sopenharmony_ci#define QLCNIC_LB_MODE_MASK 0x3 8778c2ecf20Sopenharmony_ci 8788c2ecf20Sopenharmony_ci#define QLCNIC_LINKEVENT 0x1 8798c2ecf20Sopenharmony_ci#define QLCNIC_LB_RESPONSE 0x2 8808c2ecf20Sopenharmony_ci#define QLCNIC_IS_LB_CONFIGURED(VAL) \ 8818c2ecf20Sopenharmony_ci (VAL == (QLCNIC_LINKEVENT | QLCNIC_LB_RESPONSE)) 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ci/* 8848c2ecf20Sopenharmony_ci * Driver --> Firmware 8858c2ecf20Sopenharmony_ci */ 8868c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_CONFIG_RSS 0x1 8878c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_CONFIG_INTR_COALESCE 0x3 8888c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_CONFIG_LED 0x4 8898c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_LRO_REQUEST 0x7 8908c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_SET_MAC_RECEIVE_MODE 0xc 8918c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_CONFIG_IPADDR 0x12 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_GET_LINKEVENT 0x15 8948c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_CONFIG_BRIDGING 0x17 8958c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_CONFIG_HW_LRO 0x18 8968c2ecf20Sopenharmony_ci#define QLCNIC_H2C_OPCODE_CONFIG_LOOPBACK 0x13 8978c2ecf20Sopenharmony_ci 8988c2ecf20Sopenharmony_ci/* 8998c2ecf20Sopenharmony_ci * Firmware --> Driver 9008c2ecf20Sopenharmony_ci */ 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_ci#define QLCNIC_C2H_OPCODE_CONFIG_LOOPBACK 0x8f 9038c2ecf20Sopenharmony_ci#define QLCNIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE 0x8D 9048c2ecf20Sopenharmony_ci#define QLCNIC_C2H_OPCODE_GET_DCB_AEN 0x90 9058c2ecf20Sopenharmony_ci 9068c2ecf20Sopenharmony_ci#define VPORT_MISS_MODE_DROP 0 /* drop all unmatched */ 9078c2ecf20Sopenharmony_ci#define VPORT_MISS_MODE_ACCEPT_ALL 1 /* accept all packets */ 9088c2ecf20Sopenharmony_ci#define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */ 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci#define QLCNIC_LRO_REQUEST_CLEANUP 4 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci/* Capabilites received */ 9138c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_TSO BIT_1 9148c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_BDG BIT_8 9158c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_FVLANTX BIT_9 9168c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_HW_LRO BIT_10 9178c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_2_MULTI_TX BIT_4 9188c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_MULTI_LOOPBACK BIT_27 9198c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_MORE_CAPS BIT_31 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_2_LRO_MAX_TCP_SEG BIT_2 9228c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAP2_HW_LRO_IPV6 BIT_3 9238c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_SET_DRV_VER BIT_5 9248c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_2_BEACON BIT_7 9258c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_2_PER_PORT_ESWITCH_CFG BIT_9 9268c2ecf20Sopenharmony_ci#define QLCNIC_FW_CAPABILITY_2_EXT_ISCSI_DUMP BIT_13 9278c2ecf20Sopenharmony_ci 9288c2ecf20Sopenharmony_ci#define QLCNIC_83XX_FW_CAPAB_ENCAP_RX_OFFLOAD BIT_0 9298c2ecf20Sopenharmony_ci#define QLCNIC_83XX_FW_CAPAB_ENCAP_TX_OFFLOAD BIT_1 9308c2ecf20Sopenharmony_ci#define QLCNIC_83XX_FW_CAPAB_ENCAP_CKO_OFFLOAD BIT_4 9318c2ecf20Sopenharmony_ci 9328c2ecf20Sopenharmony_ci/* module types */ 9338c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_NOT_PRESENT 1 9348c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_UNKNOWN 2 9358c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_SRLR 3 9368c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_LRM 4 9378c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_SFP_1G 5 9388c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE 6 9398c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN 7 9408c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_TWINAX 8 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_ci#define LINKSPEED_10GBPS 10000 9438c2ecf20Sopenharmony_ci#define LINKSPEED_1GBPS 1000 9448c2ecf20Sopenharmony_ci#define LINKSPEED_100MBPS 100 9458c2ecf20Sopenharmony_ci#define LINKSPEED_10MBPS 10 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_ci#define LINKSPEED_ENCODED_10MBPS 0 9488c2ecf20Sopenharmony_ci#define LINKSPEED_ENCODED_100MBPS 1 9498c2ecf20Sopenharmony_ci#define LINKSPEED_ENCODED_1GBPS 2 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci#define LINKEVENT_AUTONEG_DISABLED 0 9528c2ecf20Sopenharmony_ci#define LINKEVENT_AUTONEG_ENABLED 1 9538c2ecf20Sopenharmony_ci 9548c2ecf20Sopenharmony_ci#define LINKEVENT_HALF_DUPLEX 0 9558c2ecf20Sopenharmony_ci#define LINKEVENT_FULL_DUPLEX 1 9568c2ecf20Sopenharmony_ci 9578c2ecf20Sopenharmony_ci#define LINKEVENT_LINKSPEED_MBPS 0 9588c2ecf20Sopenharmony_ci#define LINKEVENT_LINKSPEED_ENCODED 1 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_ci/* firmware response header: 9618c2ecf20Sopenharmony_ci * 63:58 - message type 9628c2ecf20Sopenharmony_ci * 57:56 - owner 9638c2ecf20Sopenharmony_ci * 55:53 - desc count 9648c2ecf20Sopenharmony_ci * 52:48 - reserved 9658c2ecf20Sopenharmony_ci * 47:40 - completion id 9668c2ecf20Sopenharmony_ci * 39:32 - opcode 9678c2ecf20Sopenharmony_ci * 31:16 - error code 9688c2ecf20Sopenharmony_ci * 15:00 - reserved 9698c2ecf20Sopenharmony_ci */ 9708c2ecf20Sopenharmony_ci#define qlcnic_get_nic_msg_opcode(msg_hdr) \ 9718c2ecf20Sopenharmony_ci ((msg_hdr >> 32) & 0xFF) 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_cistruct qlcnic_fw_msg { 9748c2ecf20Sopenharmony_ci union { 9758c2ecf20Sopenharmony_ci struct { 9768c2ecf20Sopenharmony_ci u64 hdr; 9778c2ecf20Sopenharmony_ci u64 body[7]; 9788c2ecf20Sopenharmony_ci }; 9798c2ecf20Sopenharmony_ci u64 words[8]; 9808c2ecf20Sopenharmony_ci }; 9818c2ecf20Sopenharmony_ci}; 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_cistruct qlcnic_nic_req { 9848c2ecf20Sopenharmony_ci __le64 qhdr; 9858c2ecf20Sopenharmony_ci __le64 req_hdr; 9868c2ecf20Sopenharmony_ci __le64 words[6]; 9878c2ecf20Sopenharmony_ci} __packed; 9888c2ecf20Sopenharmony_ci 9898c2ecf20Sopenharmony_cistruct qlcnic_mac_req { 9908c2ecf20Sopenharmony_ci u8 op; 9918c2ecf20Sopenharmony_ci u8 tag; 9928c2ecf20Sopenharmony_ci u8 mac_addr[6]; 9938c2ecf20Sopenharmony_ci}; 9948c2ecf20Sopenharmony_ci 9958c2ecf20Sopenharmony_cistruct qlcnic_vlan_req { 9968c2ecf20Sopenharmony_ci __le16 vlan_id; 9978c2ecf20Sopenharmony_ci __le16 rsvd[3]; 9988c2ecf20Sopenharmony_ci} __packed; 9998c2ecf20Sopenharmony_ci 10008c2ecf20Sopenharmony_cistruct qlcnic_ipaddr { 10018c2ecf20Sopenharmony_ci __be32 ipv4; 10028c2ecf20Sopenharmony_ci __be32 ipv6[4]; 10038c2ecf20Sopenharmony_ci}; 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_ci#define QLCNIC_MSI_ENABLED 0x02 10068c2ecf20Sopenharmony_ci#define QLCNIC_MSIX_ENABLED 0x04 10078c2ecf20Sopenharmony_ci#define QLCNIC_LRO_ENABLED 0x01 10088c2ecf20Sopenharmony_ci#define QLCNIC_LRO_DISABLED 0x00 10098c2ecf20Sopenharmony_ci#define QLCNIC_BRIDGE_ENABLED 0X10 10108c2ecf20Sopenharmony_ci#define QLCNIC_DIAG_ENABLED 0x20 10118c2ecf20Sopenharmony_ci#define QLCNIC_ESWITCH_ENABLED 0x40 10128c2ecf20Sopenharmony_ci#define QLCNIC_ADAPTER_INITIALIZED 0x80 10138c2ecf20Sopenharmony_ci#define QLCNIC_TAGGING_ENABLED 0x100 10148c2ecf20Sopenharmony_ci#define QLCNIC_MACSPOOF 0x200 10158c2ecf20Sopenharmony_ci#define QLCNIC_MAC_OVERRIDE_DISABLED 0x400 10168c2ecf20Sopenharmony_ci#define QLCNIC_PROMISC_DISABLED 0x800 10178c2ecf20Sopenharmony_ci#define QLCNIC_NEED_FLR 0x1000 10188c2ecf20Sopenharmony_ci#define QLCNIC_FW_RESET_OWNER 0x2000 10198c2ecf20Sopenharmony_ci#define QLCNIC_FW_HANG 0x4000 10208c2ecf20Sopenharmony_ci#define QLCNIC_FW_LRO_MSS_CAP 0x8000 10218c2ecf20Sopenharmony_ci#define QLCNIC_TX_INTR_SHARED 0x10000 10228c2ecf20Sopenharmony_ci#define QLCNIC_APP_CHANGED_FLAGS 0x20000 10238c2ecf20Sopenharmony_ci#define QLCNIC_HAS_PHYS_PORT_ID 0x40000 10248c2ecf20Sopenharmony_ci#define QLCNIC_TSS_RSS 0x80000 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_ci#define QLCNIC_VLAN_FILTERING 0x800000 10278c2ecf20Sopenharmony_ci 10288c2ecf20Sopenharmony_ci#define QLCNIC_IS_MSI_FAMILY(adapter) \ 10298c2ecf20Sopenharmony_ci ((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED)) 10308c2ecf20Sopenharmony_ci#define QLCNIC_IS_TSO_CAPABLE(adapter) \ 10318c2ecf20Sopenharmony_ci ((adapter)->ahw->capabilities & QLCNIC_FW_CAPABILITY_TSO) 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci#define QLCNIC_BEACON_EANBLE 0xC 10348c2ecf20Sopenharmony_ci#define QLCNIC_BEACON_DISABLE 0xD 10358c2ecf20Sopenharmony_ci 10368c2ecf20Sopenharmony_ci#define QLCNIC_BEACON_ON 2 10378c2ecf20Sopenharmony_ci#define QLCNIC_BEACON_OFF 0 10388c2ecf20Sopenharmony_ci 10398c2ecf20Sopenharmony_ci#define QLCNIC_MSIX_TBL_SPACE 8192 10408c2ecf20Sopenharmony_ci#define QLCNIC_PCI_REG_MSIX_TBL 0x44 10418c2ecf20Sopenharmony_ci#define QLCNIC_MSIX_TBL_PGSIZE 4096 10428c2ecf20Sopenharmony_ci 10438c2ecf20Sopenharmony_ci#define QLCNIC_ADAPTER_UP_MAGIC 777 10448c2ecf20Sopenharmony_ci 10458c2ecf20Sopenharmony_ci#define __QLCNIC_FW_ATTACHED 0 10468c2ecf20Sopenharmony_ci#define __QLCNIC_DEV_UP 1 10478c2ecf20Sopenharmony_ci#define __QLCNIC_RESETTING 2 10488c2ecf20Sopenharmony_ci#define __QLCNIC_START_FW 4 10498c2ecf20Sopenharmony_ci#define __QLCNIC_AER 5 10508c2ecf20Sopenharmony_ci#define __QLCNIC_DIAG_RES_ALLOC 6 10518c2ecf20Sopenharmony_ci#define __QLCNIC_LED_ENABLE 7 10528c2ecf20Sopenharmony_ci#define __QLCNIC_ELB_INPROGRESS 8 10538c2ecf20Sopenharmony_ci#define __QLCNIC_MULTI_TX_UNIQUE 9 10548c2ecf20Sopenharmony_ci#define __QLCNIC_SRIOV_ENABLE 10 10558c2ecf20Sopenharmony_ci#define __QLCNIC_SRIOV_CAPABLE 11 10568c2ecf20Sopenharmony_ci#define __QLCNIC_MBX_POLL_ENABLE 12 10578c2ecf20Sopenharmony_ci#define __QLCNIC_DIAG_MODE 13 10588c2ecf20Sopenharmony_ci#define __QLCNIC_MAINTENANCE_MODE 16 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci#define QLCNIC_INTERRUPT_TEST 1 10618c2ecf20Sopenharmony_ci#define QLCNIC_LOOPBACK_TEST 2 10628c2ecf20Sopenharmony_ci#define QLCNIC_LED_TEST 3 10638c2ecf20Sopenharmony_ci 10648c2ecf20Sopenharmony_ci#define QLCNIC_FILTER_AGE 80 10658c2ecf20Sopenharmony_ci#define QLCNIC_READD_AGE 20 10668c2ecf20Sopenharmony_ci#define QLCNIC_LB_MAX_FILTERS 64 10678c2ecf20Sopenharmony_ci#define QLCNIC_LB_BUCKET_SIZE 32 10688c2ecf20Sopenharmony_ci#define QLCNIC_ILB_MAX_RCV_LOOP 10 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_cistruct qlcnic_filter { 10718c2ecf20Sopenharmony_ci struct hlist_node fnode; 10728c2ecf20Sopenharmony_ci u8 faddr[ETH_ALEN]; 10738c2ecf20Sopenharmony_ci u16 vlan_id; 10748c2ecf20Sopenharmony_ci unsigned long ftime; 10758c2ecf20Sopenharmony_ci}; 10768c2ecf20Sopenharmony_ci 10778c2ecf20Sopenharmony_cistruct qlcnic_filter_hash { 10788c2ecf20Sopenharmony_ci struct hlist_head *fhead; 10798c2ecf20Sopenharmony_ci u8 fnum; 10808c2ecf20Sopenharmony_ci u16 fmax; 10818c2ecf20Sopenharmony_ci u16 fbucket_size; 10828c2ecf20Sopenharmony_ci}; 10838c2ecf20Sopenharmony_ci 10848c2ecf20Sopenharmony_ci/* Mailbox specific data structures */ 10858c2ecf20Sopenharmony_cistruct qlcnic_mailbox { 10868c2ecf20Sopenharmony_ci struct workqueue_struct *work_q; 10878c2ecf20Sopenharmony_ci struct qlcnic_adapter *adapter; 10888c2ecf20Sopenharmony_ci const struct qlcnic_mbx_ops *ops; 10898c2ecf20Sopenharmony_ci struct work_struct work; 10908c2ecf20Sopenharmony_ci struct completion completion; 10918c2ecf20Sopenharmony_ci struct list_head cmd_q; 10928c2ecf20Sopenharmony_ci unsigned long status; 10938c2ecf20Sopenharmony_ci spinlock_t queue_lock; /* Mailbox queue lock */ 10948c2ecf20Sopenharmony_ci spinlock_t aen_lock; /* Mailbox response/AEN lock */ 10958c2ecf20Sopenharmony_ci u32 rsp_status; 10968c2ecf20Sopenharmony_ci u32 num_cmds; 10978c2ecf20Sopenharmony_ci}; 10988c2ecf20Sopenharmony_ci 10998c2ecf20Sopenharmony_cistruct qlcnic_adapter { 11008c2ecf20Sopenharmony_ci struct qlcnic_hardware_context *ahw; 11018c2ecf20Sopenharmony_ci struct qlcnic_recv_context *recv_ctx; 11028c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring; 11038c2ecf20Sopenharmony_ci struct net_device *netdev; 11048c2ecf20Sopenharmony_ci struct pci_dev *pdev; 11058c2ecf20Sopenharmony_ci 11068c2ecf20Sopenharmony_ci unsigned long state; 11078c2ecf20Sopenharmony_ci u32 flags; 11088c2ecf20Sopenharmony_ci 11098c2ecf20Sopenharmony_ci u16 num_txd; 11108c2ecf20Sopenharmony_ci u16 num_rxd; 11118c2ecf20Sopenharmony_ci u16 num_jumbo_rxd; 11128c2ecf20Sopenharmony_ci u16 max_rxd; 11138c2ecf20Sopenharmony_ci u16 max_jumbo_rxd; 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_ci u8 max_rds_rings; 11168c2ecf20Sopenharmony_ci 11178c2ecf20Sopenharmony_ci u8 max_sds_rings; /* max sds rings supported by adapter */ 11188c2ecf20Sopenharmony_ci u8 max_tx_rings; /* max tx rings supported by adapter */ 11198c2ecf20Sopenharmony_ci 11208c2ecf20Sopenharmony_ci u8 drv_tx_rings; /* max tx rings supported by driver */ 11218c2ecf20Sopenharmony_ci u8 drv_sds_rings; /* max sds rings supported by driver */ 11228c2ecf20Sopenharmony_ci 11238c2ecf20Sopenharmony_ci u8 drv_tss_rings; /* tss ring input */ 11248c2ecf20Sopenharmony_ci u8 drv_rss_rings; /* rss ring input */ 11258c2ecf20Sopenharmony_ci 11268c2ecf20Sopenharmony_ci u8 rx_csum; 11278c2ecf20Sopenharmony_ci u8 portnum; 11288c2ecf20Sopenharmony_ci 11298c2ecf20Sopenharmony_ci u8 fw_wait_cnt; 11308c2ecf20Sopenharmony_ci u8 fw_fail_cnt; 11318c2ecf20Sopenharmony_ci u8 tx_timeo_cnt; 11328c2ecf20Sopenharmony_ci u8 need_fw_reset; 11338c2ecf20Sopenharmony_ci u8 reset_ctx_cnt; 11348c2ecf20Sopenharmony_ci 11358c2ecf20Sopenharmony_ci u16 is_up; 11368c2ecf20Sopenharmony_ci u16 rx_pvid; 11378c2ecf20Sopenharmony_ci u16 tx_pvid; 11388c2ecf20Sopenharmony_ci 11398c2ecf20Sopenharmony_ci u32 irq; 11408c2ecf20Sopenharmony_ci u32 heartbeat; 11418c2ecf20Sopenharmony_ci 11428c2ecf20Sopenharmony_ci u8 dev_state; 11438c2ecf20Sopenharmony_ci u8 reset_ack_timeo; 11448c2ecf20Sopenharmony_ci u8 dev_init_timeo; 11458c2ecf20Sopenharmony_ci 11468c2ecf20Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 11478c2ecf20Sopenharmony_ci 11488c2ecf20Sopenharmony_ci u64 dev_rst_time; 11498c2ecf20Sopenharmony_ci bool drv_mac_learn; 11508c2ecf20Sopenharmony_ci bool fdb_mac_learn; 11518c2ecf20Sopenharmony_ci bool rx_mac_learn; 11528c2ecf20Sopenharmony_ci unsigned long vlans[BITS_TO_LONGS(VLAN_N_VID)]; 11538c2ecf20Sopenharmony_ci u8 flash_mfg_id; 11548c2ecf20Sopenharmony_ci struct qlcnic_npar_info *npars; 11558c2ecf20Sopenharmony_ci struct qlcnic_eswitch *eswitch; 11568c2ecf20Sopenharmony_ci struct qlcnic_nic_template *nic_ops; 11578c2ecf20Sopenharmony_ci 11588c2ecf20Sopenharmony_ci struct qlcnic_adapter_stats stats; 11598c2ecf20Sopenharmony_ci struct list_head mac_list; 11608c2ecf20Sopenharmony_ci 11618c2ecf20Sopenharmony_ci void __iomem *tgt_mask_reg; 11628c2ecf20Sopenharmony_ci void __iomem *tgt_status_reg; 11638c2ecf20Sopenharmony_ci void __iomem *crb_int_state_reg; 11648c2ecf20Sopenharmony_ci void __iomem *isr_int_vec; 11658c2ecf20Sopenharmony_ci 11668c2ecf20Sopenharmony_ci struct msix_entry *msix_entries; 11678c2ecf20Sopenharmony_ci struct workqueue_struct *qlcnic_wq; 11688c2ecf20Sopenharmony_ci struct delayed_work fw_work; 11698c2ecf20Sopenharmony_ci struct delayed_work idc_aen_work; 11708c2ecf20Sopenharmony_ci struct delayed_work mbx_poll_work; 11718c2ecf20Sopenharmony_ci struct qlcnic_dcb *dcb; 11728c2ecf20Sopenharmony_ci 11738c2ecf20Sopenharmony_ci struct qlcnic_filter_hash fhash; 11748c2ecf20Sopenharmony_ci struct qlcnic_filter_hash rx_fhash; 11758c2ecf20Sopenharmony_ci struct list_head vf_mc_list; 11768c2ecf20Sopenharmony_ci 11778c2ecf20Sopenharmony_ci spinlock_t mac_learn_lock; 11788c2ecf20Sopenharmony_ci /* spinlock for catching rcv filters for eswitch traffic */ 11798c2ecf20Sopenharmony_ci spinlock_t rx_mac_learn_lock; 11808c2ecf20Sopenharmony_ci u32 file_prd_off; /*File fw product offset*/ 11818c2ecf20Sopenharmony_ci u32 fw_version; 11828c2ecf20Sopenharmony_ci u32 offload_flags; 11838c2ecf20Sopenharmony_ci const struct firmware *fw; 11848c2ecf20Sopenharmony_ci}; 11858c2ecf20Sopenharmony_ci 11868c2ecf20Sopenharmony_cistruct qlcnic_info_le { 11878c2ecf20Sopenharmony_ci __le16 pci_func; 11888c2ecf20Sopenharmony_ci __le16 op_mode; /* 1 = Priv, 2 = NP, 3 = NP passthru */ 11898c2ecf20Sopenharmony_ci __le16 phys_port; 11908c2ecf20Sopenharmony_ci __le16 switch_mode; /* 0 = disabled, 1 = int, 2 = ext */ 11918c2ecf20Sopenharmony_ci 11928c2ecf20Sopenharmony_ci __le32 capabilities; 11938c2ecf20Sopenharmony_ci u8 max_mac_filters; 11948c2ecf20Sopenharmony_ci u8 reserved1; 11958c2ecf20Sopenharmony_ci __le16 max_mtu; 11968c2ecf20Sopenharmony_ci 11978c2ecf20Sopenharmony_ci __le16 max_tx_ques; 11988c2ecf20Sopenharmony_ci __le16 max_rx_ques; 11998c2ecf20Sopenharmony_ci __le16 min_tx_bw; 12008c2ecf20Sopenharmony_ci __le16 max_tx_bw; 12018c2ecf20Sopenharmony_ci __le32 op_type; 12028c2ecf20Sopenharmony_ci __le16 max_bw_reg_offset; 12038c2ecf20Sopenharmony_ci __le16 max_linkspeed_reg_offset; 12048c2ecf20Sopenharmony_ci __le32 capability1; 12058c2ecf20Sopenharmony_ci __le32 capability2; 12068c2ecf20Sopenharmony_ci __le32 capability3; 12078c2ecf20Sopenharmony_ci __le16 max_tx_mac_filters; 12088c2ecf20Sopenharmony_ci __le16 max_rx_mcast_mac_filters; 12098c2ecf20Sopenharmony_ci __le16 max_rx_ucast_mac_filters; 12108c2ecf20Sopenharmony_ci __le16 max_rx_ip_addr; 12118c2ecf20Sopenharmony_ci __le16 max_rx_lro_flow; 12128c2ecf20Sopenharmony_ci __le16 max_rx_status_rings; 12138c2ecf20Sopenharmony_ci __le16 max_rx_buf_rings; 12148c2ecf20Sopenharmony_ci __le16 max_tx_vlan_keys; 12158c2ecf20Sopenharmony_ci u8 total_pf; 12168c2ecf20Sopenharmony_ci u8 total_rss_engines; 12178c2ecf20Sopenharmony_ci __le16 max_vports; 12188c2ecf20Sopenharmony_ci __le16 linkstate_reg_offset; 12198c2ecf20Sopenharmony_ci __le16 bit_offsets; 12208c2ecf20Sopenharmony_ci __le16 max_local_ipv6_addrs; 12218c2ecf20Sopenharmony_ci __le16 max_remote_ipv6_addrs; 12228c2ecf20Sopenharmony_ci u8 reserved2[56]; 12238c2ecf20Sopenharmony_ci} __packed; 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_cistruct qlcnic_info { 12268c2ecf20Sopenharmony_ci u16 pci_func; 12278c2ecf20Sopenharmony_ci u16 op_mode; 12288c2ecf20Sopenharmony_ci u16 phys_port; 12298c2ecf20Sopenharmony_ci u16 switch_mode; 12308c2ecf20Sopenharmony_ci u32 capabilities; 12318c2ecf20Sopenharmony_ci u8 max_mac_filters; 12328c2ecf20Sopenharmony_ci u16 max_mtu; 12338c2ecf20Sopenharmony_ci u16 max_tx_ques; 12348c2ecf20Sopenharmony_ci u16 max_rx_ques; 12358c2ecf20Sopenharmony_ci u16 min_tx_bw; 12368c2ecf20Sopenharmony_ci u16 max_tx_bw; 12378c2ecf20Sopenharmony_ci u32 op_type; 12388c2ecf20Sopenharmony_ci u16 max_bw_reg_offset; 12398c2ecf20Sopenharmony_ci u16 max_linkspeed_reg_offset; 12408c2ecf20Sopenharmony_ci u32 capability1; 12418c2ecf20Sopenharmony_ci u32 capability2; 12428c2ecf20Sopenharmony_ci u32 capability3; 12438c2ecf20Sopenharmony_ci u16 max_tx_mac_filters; 12448c2ecf20Sopenharmony_ci u16 max_rx_mcast_mac_filters; 12458c2ecf20Sopenharmony_ci u16 max_rx_ucast_mac_filters; 12468c2ecf20Sopenharmony_ci u16 max_rx_ip_addr; 12478c2ecf20Sopenharmony_ci u16 max_rx_lro_flow; 12488c2ecf20Sopenharmony_ci u16 max_rx_status_rings; 12498c2ecf20Sopenharmony_ci u16 max_rx_buf_rings; 12508c2ecf20Sopenharmony_ci u16 max_tx_vlan_keys; 12518c2ecf20Sopenharmony_ci u8 total_pf; 12528c2ecf20Sopenharmony_ci u8 total_rss_engines; 12538c2ecf20Sopenharmony_ci u16 max_vports; 12548c2ecf20Sopenharmony_ci u16 linkstate_reg_offset; 12558c2ecf20Sopenharmony_ci u16 bit_offsets; 12568c2ecf20Sopenharmony_ci u16 max_local_ipv6_addrs; 12578c2ecf20Sopenharmony_ci u16 max_remote_ipv6_addrs; 12588c2ecf20Sopenharmony_ci}; 12598c2ecf20Sopenharmony_ci 12608c2ecf20Sopenharmony_cistruct qlcnic_pci_info_le { 12618c2ecf20Sopenharmony_ci __le16 id; /* pci function id */ 12628c2ecf20Sopenharmony_ci __le16 active; /* 1 = Enabled */ 12638c2ecf20Sopenharmony_ci __le16 type; /* 1 = NIC, 2 = FCoE, 3 = iSCSI */ 12648c2ecf20Sopenharmony_ci __le16 default_port; /* default port number */ 12658c2ecf20Sopenharmony_ci 12668c2ecf20Sopenharmony_ci __le16 tx_min_bw; /* Multiple of 100mbpc */ 12678c2ecf20Sopenharmony_ci __le16 tx_max_bw; 12688c2ecf20Sopenharmony_ci __le16 reserved1[2]; 12698c2ecf20Sopenharmony_ci 12708c2ecf20Sopenharmony_ci u8 mac[ETH_ALEN]; 12718c2ecf20Sopenharmony_ci __le16 func_count; 12728c2ecf20Sopenharmony_ci u8 reserved2[104]; 12738c2ecf20Sopenharmony_ci 12748c2ecf20Sopenharmony_ci} __packed; 12758c2ecf20Sopenharmony_ci 12768c2ecf20Sopenharmony_cistruct qlcnic_pci_info { 12778c2ecf20Sopenharmony_ci u16 id; 12788c2ecf20Sopenharmony_ci u16 active; 12798c2ecf20Sopenharmony_ci u16 type; 12808c2ecf20Sopenharmony_ci u16 default_port; 12818c2ecf20Sopenharmony_ci u16 tx_min_bw; 12828c2ecf20Sopenharmony_ci u16 tx_max_bw; 12838c2ecf20Sopenharmony_ci u8 mac[ETH_ALEN]; 12848c2ecf20Sopenharmony_ci u16 func_count; 12858c2ecf20Sopenharmony_ci}; 12868c2ecf20Sopenharmony_ci 12878c2ecf20Sopenharmony_cistruct qlcnic_npar_info { 12888c2ecf20Sopenharmony_ci bool eswitch_status; 12898c2ecf20Sopenharmony_ci u16 pvid; 12908c2ecf20Sopenharmony_ci u16 min_bw; 12918c2ecf20Sopenharmony_ci u16 max_bw; 12928c2ecf20Sopenharmony_ci u8 phy_port; 12938c2ecf20Sopenharmony_ci u8 type; 12948c2ecf20Sopenharmony_ci u8 active; 12958c2ecf20Sopenharmony_ci u8 enable_pm; 12968c2ecf20Sopenharmony_ci u8 dest_npar; 12978c2ecf20Sopenharmony_ci u8 discard_tagged; 12988c2ecf20Sopenharmony_ci u8 mac_override; 12998c2ecf20Sopenharmony_ci u8 mac_anti_spoof; 13008c2ecf20Sopenharmony_ci u8 promisc_mode; 13018c2ecf20Sopenharmony_ci u8 offload_flags; 13028c2ecf20Sopenharmony_ci u8 pci_func; 13038c2ecf20Sopenharmony_ci u8 mac[ETH_ALEN]; 13048c2ecf20Sopenharmony_ci}; 13058c2ecf20Sopenharmony_ci 13068c2ecf20Sopenharmony_cistruct qlcnic_eswitch { 13078c2ecf20Sopenharmony_ci u8 port; 13088c2ecf20Sopenharmony_ci u8 active_vports; 13098c2ecf20Sopenharmony_ci u8 active_vlans; 13108c2ecf20Sopenharmony_ci u8 active_ucast_filters; 13118c2ecf20Sopenharmony_ci u8 max_ucast_filters; 13128c2ecf20Sopenharmony_ci u8 max_active_vlans; 13138c2ecf20Sopenharmony_ci 13148c2ecf20Sopenharmony_ci u32 flags; 13158c2ecf20Sopenharmony_ci#define QLCNIC_SWITCH_ENABLE BIT_1 13168c2ecf20Sopenharmony_ci#define QLCNIC_SWITCH_VLAN_FILTERING BIT_2 13178c2ecf20Sopenharmony_ci#define QLCNIC_SWITCH_PROMISC_MODE BIT_3 13188c2ecf20Sopenharmony_ci#define QLCNIC_SWITCH_PORT_MIRRORING BIT_4 13198c2ecf20Sopenharmony_ci}; 13208c2ecf20Sopenharmony_ci 13218c2ecf20Sopenharmony_ci 13228c2ecf20Sopenharmony_ci#define MAX_BW 100 /* % of link speed */ 13238c2ecf20Sopenharmony_ci#define MIN_BW 1 /* % of link speed */ 13248c2ecf20Sopenharmony_ci#define MAX_VLAN_ID 4095 13258c2ecf20Sopenharmony_ci#define MIN_VLAN_ID 2 13268c2ecf20Sopenharmony_ci#define DEFAULT_MAC_LEARN 1 13278c2ecf20Sopenharmony_ci 13288c2ecf20Sopenharmony_ci#define IS_VALID_VLAN(vlan) (vlan >= MIN_VLAN_ID && vlan < MAX_VLAN_ID) 13298c2ecf20Sopenharmony_ci#define IS_VALID_BW(bw) (bw <= MAX_BW) 13308c2ecf20Sopenharmony_ci 13318c2ecf20Sopenharmony_cistruct qlcnic_pci_func_cfg { 13328c2ecf20Sopenharmony_ci u16 func_type; 13338c2ecf20Sopenharmony_ci u16 min_bw; 13348c2ecf20Sopenharmony_ci u16 max_bw; 13358c2ecf20Sopenharmony_ci u16 port_num; 13368c2ecf20Sopenharmony_ci u8 pci_func; 13378c2ecf20Sopenharmony_ci u8 func_state; 13388c2ecf20Sopenharmony_ci u8 def_mac_addr[ETH_ALEN]; 13398c2ecf20Sopenharmony_ci}; 13408c2ecf20Sopenharmony_ci 13418c2ecf20Sopenharmony_cistruct qlcnic_npar_func_cfg { 13428c2ecf20Sopenharmony_ci u32 fw_capab; 13438c2ecf20Sopenharmony_ci u16 port_num; 13448c2ecf20Sopenharmony_ci u16 min_bw; 13458c2ecf20Sopenharmony_ci u16 max_bw; 13468c2ecf20Sopenharmony_ci u16 max_tx_queues; 13478c2ecf20Sopenharmony_ci u16 max_rx_queues; 13488c2ecf20Sopenharmony_ci u8 pci_func; 13498c2ecf20Sopenharmony_ci u8 op_mode; 13508c2ecf20Sopenharmony_ci}; 13518c2ecf20Sopenharmony_ci 13528c2ecf20Sopenharmony_cistruct qlcnic_pm_func_cfg { 13538c2ecf20Sopenharmony_ci u8 pci_func; 13548c2ecf20Sopenharmony_ci u8 action; 13558c2ecf20Sopenharmony_ci u8 dest_npar; 13568c2ecf20Sopenharmony_ci u8 reserved[5]; 13578c2ecf20Sopenharmony_ci}; 13588c2ecf20Sopenharmony_ci 13598c2ecf20Sopenharmony_cistruct qlcnic_esw_func_cfg { 13608c2ecf20Sopenharmony_ci u16 vlan_id; 13618c2ecf20Sopenharmony_ci u8 op_mode; 13628c2ecf20Sopenharmony_ci u8 op_type; 13638c2ecf20Sopenharmony_ci u8 pci_func; 13648c2ecf20Sopenharmony_ci u8 host_vlan_tag; 13658c2ecf20Sopenharmony_ci u8 promisc_mode; 13668c2ecf20Sopenharmony_ci u8 discard_tagged; 13678c2ecf20Sopenharmony_ci u8 mac_override; 13688c2ecf20Sopenharmony_ci u8 mac_anti_spoof; 13698c2ecf20Sopenharmony_ci u8 offload_flags; 13708c2ecf20Sopenharmony_ci u8 reserved[5]; 13718c2ecf20Sopenharmony_ci}; 13728c2ecf20Sopenharmony_ci 13738c2ecf20Sopenharmony_ci#define QLCNIC_STATS_VERSION 1 13748c2ecf20Sopenharmony_ci#define QLCNIC_STATS_PORT 1 13758c2ecf20Sopenharmony_ci#define QLCNIC_STATS_ESWITCH 2 13768c2ecf20Sopenharmony_ci#define QLCNIC_QUERY_RX_COUNTER 0 13778c2ecf20Sopenharmony_ci#define QLCNIC_QUERY_TX_COUNTER 1 13788c2ecf20Sopenharmony_ci#define QLCNIC_STATS_NOT_AVAIL 0xffffffffffffffffULL 13798c2ecf20Sopenharmony_ci#define QLCNIC_FILL_STATS(VAL1) \ 13808c2ecf20Sopenharmony_ci (((VAL1) == QLCNIC_STATS_NOT_AVAIL) ? 0 : VAL1) 13818c2ecf20Sopenharmony_ci#define QLCNIC_MAC_STATS 1 13828c2ecf20Sopenharmony_ci#define QLCNIC_ESW_STATS 2 13838c2ecf20Sopenharmony_ci 13848c2ecf20Sopenharmony_ci#define QLCNIC_ADD_ESW_STATS(VAL1, VAL2)\ 13858c2ecf20Sopenharmony_cido { \ 13868c2ecf20Sopenharmony_ci if (((VAL1) == QLCNIC_STATS_NOT_AVAIL) && \ 13878c2ecf20Sopenharmony_ci ((VAL2) != QLCNIC_STATS_NOT_AVAIL)) \ 13888c2ecf20Sopenharmony_ci (VAL1) = (VAL2); \ 13898c2ecf20Sopenharmony_ci else if (((VAL1) != QLCNIC_STATS_NOT_AVAIL) && \ 13908c2ecf20Sopenharmony_ci ((VAL2) != QLCNIC_STATS_NOT_AVAIL)) \ 13918c2ecf20Sopenharmony_ci (VAL1) += (VAL2); \ 13928c2ecf20Sopenharmony_ci} while (0) 13938c2ecf20Sopenharmony_ci 13948c2ecf20Sopenharmony_cistruct qlcnic_mac_statistics_le { 13958c2ecf20Sopenharmony_ci __le64 mac_tx_frames; 13968c2ecf20Sopenharmony_ci __le64 mac_tx_bytes; 13978c2ecf20Sopenharmony_ci __le64 mac_tx_mcast_pkts; 13988c2ecf20Sopenharmony_ci __le64 mac_tx_bcast_pkts; 13998c2ecf20Sopenharmony_ci __le64 mac_tx_pause_cnt; 14008c2ecf20Sopenharmony_ci __le64 mac_tx_ctrl_pkt; 14018c2ecf20Sopenharmony_ci __le64 mac_tx_lt_64b_pkts; 14028c2ecf20Sopenharmony_ci __le64 mac_tx_lt_127b_pkts; 14038c2ecf20Sopenharmony_ci __le64 mac_tx_lt_255b_pkts; 14048c2ecf20Sopenharmony_ci __le64 mac_tx_lt_511b_pkts; 14058c2ecf20Sopenharmony_ci __le64 mac_tx_lt_1023b_pkts; 14068c2ecf20Sopenharmony_ci __le64 mac_tx_lt_1518b_pkts; 14078c2ecf20Sopenharmony_ci __le64 mac_tx_gt_1518b_pkts; 14088c2ecf20Sopenharmony_ci __le64 rsvd1[3]; 14098c2ecf20Sopenharmony_ci 14108c2ecf20Sopenharmony_ci __le64 mac_rx_frames; 14118c2ecf20Sopenharmony_ci __le64 mac_rx_bytes; 14128c2ecf20Sopenharmony_ci __le64 mac_rx_mcast_pkts; 14138c2ecf20Sopenharmony_ci __le64 mac_rx_bcast_pkts; 14148c2ecf20Sopenharmony_ci __le64 mac_rx_pause_cnt; 14158c2ecf20Sopenharmony_ci __le64 mac_rx_ctrl_pkt; 14168c2ecf20Sopenharmony_ci __le64 mac_rx_lt_64b_pkts; 14178c2ecf20Sopenharmony_ci __le64 mac_rx_lt_127b_pkts; 14188c2ecf20Sopenharmony_ci __le64 mac_rx_lt_255b_pkts; 14198c2ecf20Sopenharmony_ci __le64 mac_rx_lt_511b_pkts; 14208c2ecf20Sopenharmony_ci __le64 mac_rx_lt_1023b_pkts; 14218c2ecf20Sopenharmony_ci __le64 mac_rx_lt_1518b_pkts; 14228c2ecf20Sopenharmony_ci __le64 mac_rx_gt_1518b_pkts; 14238c2ecf20Sopenharmony_ci __le64 rsvd2[3]; 14248c2ecf20Sopenharmony_ci 14258c2ecf20Sopenharmony_ci __le64 mac_rx_length_error; 14268c2ecf20Sopenharmony_ci __le64 mac_rx_length_small; 14278c2ecf20Sopenharmony_ci __le64 mac_rx_length_large; 14288c2ecf20Sopenharmony_ci __le64 mac_rx_jabber; 14298c2ecf20Sopenharmony_ci __le64 mac_rx_dropped; 14308c2ecf20Sopenharmony_ci __le64 mac_rx_crc_error; 14318c2ecf20Sopenharmony_ci __le64 mac_align_error; 14328c2ecf20Sopenharmony_ci} __packed; 14338c2ecf20Sopenharmony_ci 14348c2ecf20Sopenharmony_cistruct qlcnic_mac_statistics { 14358c2ecf20Sopenharmony_ci u64 mac_tx_frames; 14368c2ecf20Sopenharmony_ci u64 mac_tx_bytes; 14378c2ecf20Sopenharmony_ci u64 mac_tx_mcast_pkts; 14388c2ecf20Sopenharmony_ci u64 mac_tx_bcast_pkts; 14398c2ecf20Sopenharmony_ci u64 mac_tx_pause_cnt; 14408c2ecf20Sopenharmony_ci u64 mac_tx_ctrl_pkt; 14418c2ecf20Sopenharmony_ci u64 mac_tx_lt_64b_pkts; 14428c2ecf20Sopenharmony_ci u64 mac_tx_lt_127b_pkts; 14438c2ecf20Sopenharmony_ci u64 mac_tx_lt_255b_pkts; 14448c2ecf20Sopenharmony_ci u64 mac_tx_lt_511b_pkts; 14458c2ecf20Sopenharmony_ci u64 mac_tx_lt_1023b_pkts; 14468c2ecf20Sopenharmony_ci u64 mac_tx_lt_1518b_pkts; 14478c2ecf20Sopenharmony_ci u64 mac_tx_gt_1518b_pkts; 14488c2ecf20Sopenharmony_ci u64 rsvd1[3]; 14498c2ecf20Sopenharmony_ci u64 mac_rx_frames; 14508c2ecf20Sopenharmony_ci u64 mac_rx_bytes; 14518c2ecf20Sopenharmony_ci u64 mac_rx_mcast_pkts; 14528c2ecf20Sopenharmony_ci u64 mac_rx_bcast_pkts; 14538c2ecf20Sopenharmony_ci u64 mac_rx_pause_cnt; 14548c2ecf20Sopenharmony_ci u64 mac_rx_ctrl_pkt; 14558c2ecf20Sopenharmony_ci u64 mac_rx_lt_64b_pkts; 14568c2ecf20Sopenharmony_ci u64 mac_rx_lt_127b_pkts; 14578c2ecf20Sopenharmony_ci u64 mac_rx_lt_255b_pkts; 14588c2ecf20Sopenharmony_ci u64 mac_rx_lt_511b_pkts; 14598c2ecf20Sopenharmony_ci u64 mac_rx_lt_1023b_pkts; 14608c2ecf20Sopenharmony_ci u64 mac_rx_lt_1518b_pkts; 14618c2ecf20Sopenharmony_ci u64 mac_rx_gt_1518b_pkts; 14628c2ecf20Sopenharmony_ci u64 rsvd2[3]; 14638c2ecf20Sopenharmony_ci u64 mac_rx_length_error; 14648c2ecf20Sopenharmony_ci u64 mac_rx_length_small; 14658c2ecf20Sopenharmony_ci u64 mac_rx_length_large; 14668c2ecf20Sopenharmony_ci u64 mac_rx_jabber; 14678c2ecf20Sopenharmony_ci u64 mac_rx_dropped; 14688c2ecf20Sopenharmony_ci u64 mac_rx_crc_error; 14698c2ecf20Sopenharmony_ci u64 mac_align_error; 14708c2ecf20Sopenharmony_ci}; 14718c2ecf20Sopenharmony_ci 14728c2ecf20Sopenharmony_cistruct qlcnic_esw_stats_le { 14738c2ecf20Sopenharmony_ci __le16 context_id; 14748c2ecf20Sopenharmony_ci __le16 version; 14758c2ecf20Sopenharmony_ci __le16 size; 14768c2ecf20Sopenharmony_ci __le16 unused; 14778c2ecf20Sopenharmony_ci __le64 unicast_frames; 14788c2ecf20Sopenharmony_ci __le64 multicast_frames; 14798c2ecf20Sopenharmony_ci __le64 broadcast_frames; 14808c2ecf20Sopenharmony_ci __le64 dropped_frames; 14818c2ecf20Sopenharmony_ci __le64 errors; 14828c2ecf20Sopenharmony_ci __le64 local_frames; 14838c2ecf20Sopenharmony_ci __le64 numbytes; 14848c2ecf20Sopenharmony_ci __le64 rsvd[3]; 14858c2ecf20Sopenharmony_ci} __packed; 14868c2ecf20Sopenharmony_ci 14878c2ecf20Sopenharmony_cistruct __qlcnic_esw_statistics { 14888c2ecf20Sopenharmony_ci u16 context_id; 14898c2ecf20Sopenharmony_ci u16 version; 14908c2ecf20Sopenharmony_ci u16 size; 14918c2ecf20Sopenharmony_ci u16 unused; 14928c2ecf20Sopenharmony_ci u64 unicast_frames; 14938c2ecf20Sopenharmony_ci u64 multicast_frames; 14948c2ecf20Sopenharmony_ci u64 broadcast_frames; 14958c2ecf20Sopenharmony_ci u64 dropped_frames; 14968c2ecf20Sopenharmony_ci u64 errors; 14978c2ecf20Sopenharmony_ci u64 local_frames; 14988c2ecf20Sopenharmony_ci u64 numbytes; 14998c2ecf20Sopenharmony_ci u64 rsvd[3]; 15008c2ecf20Sopenharmony_ci}; 15018c2ecf20Sopenharmony_ci 15028c2ecf20Sopenharmony_cistruct qlcnic_esw_statistics { 15038c2ecf20Sopenharmony_ci struct __qlcnic_esw_statistics rx; 15048c2ecf20Sopenharmony_ci struct __qlcnic_esw_statistics tx; 15058c2ecf20Sopenharmony_ci}; 15068c2ecf20Sopenharmony_ci 15078c2ecf20Sopenharmony_ci#define QLCNIC_FORCE_FW_DUMP_KEY 0xdeadfeed 15088c2ecf20Sopenharmony_ci#define QLCNIC_ENABLE_FW_DUMP 0xaddfeed 15098c2ecf20Sopenharmony_ci#define QLCNIC_DISABLE_FW_DUMP 0xbadfeed 15108c2ecf20Sopenharmony_ci#define QLCNIC_FORCE_FW_RESET 0xdeaddead 15118c2ecf20Sopenharmony_ci#define QLCNIC_SET_QUIESCENT 0xadd00010 15128c2ecf20Sopenharmony_ci#define QLCNIC_RESET_QUIESCENT 0xadd00020 15138c2ecf20Sopenharmony_ci 15148c2ecf20Sopenharmony_cistruct _cdrp_cmd { 15158c2ecf20Sopenharmony_ci u32 num; 15168c2ecf20Sopenharmony_ci u32 *arg; 15178c2ecf20Sopenharmony_ci}; 15188c2ecf20Sopenharmony_ci 15198c2ecf20Sopenharmony_cistruct qlcnic_cmd_args { 15208c2ecf20Sopenharmony_ci struct completion completion; 15218c2ecf20Sopenharmony_ci struct list_head list; 15228c2ecf20Sopenharmony_ci struct _cdrp_cmd req; 15238c2ecf20Sopenharmony_ci struct _cdrp_cmd rsp; 15248c2ecf20Sopenharmony_ci atomic_t rsp_status; 15258c2ecf20Sopenharmony_ci int pay_size; 15268c2ecf20Sopenharmony_ci u32 rsp_opcode; 15278c2ecf20Sopenharmony_ci u32 total_cmds; 15288c2ecf20Sopenharmony_ci u32 op_type; 15298c2ecf20Sopenharmony_ci u32 type; 15308c2ecf20Sopenharmony_ci u32 cmd_op; 15318c2ecf20Sopenharmony_ci u32 *hdr; /* Back channel message header */ 15328c2ecf20Sopenharmony_ci u32 *pay; /* Back channel message payload */ 15338c2ecf20Sopenharmony_ci u8 func_num; 15348c2ecf20Sopenharmony_ci}; 15358c2ecf20Sopenharmony_ci 15368c2ecf20Sopenharmony_ciint qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter); 15378c2ecf20Sopenharmony_ciint qlcnic_fw_cmd_set_port(struct qlcnic_adapter *adapter, u32 config); 15388c2ecf20Sopenharmony_ciint qlcnic_pci_mem_write_2M(struct qlcnic_adapter *, u64 off, u64 data); 15398c2ecf20Sopenharmony_ciint qlcnic_pci_mem_read_2M(struct qlcnic_adapter *, u64 off, u64 *data); 15408c2ecf20Sopenharmony_ci 15418c2ecf20Sopenharmony_ci#define ADDR_IN_RANGE(addr, low, high) \ 15428c2ecf20Sopenharmony_ci (((addr) < (high)) && ((addr) >= (low))) 15438c2ecf20Sopenharmony_ci 15448c2ecf20Sopenharmony_ci#define QLCRD32(adapter, off, err) \ 15458c2ecf20Sopenharmony_ci (adapter->ahw->hw_ops->read_reg)(adapter, off, err) 15468c2ecf20Sopenharmony_ci 15478c2ecf20Sopenharmony_ci#define QLCWR32(adapter, off, val) \ 15488c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->write_reg(adapter, off, val) 15498c2ecf20Sopenharmony_ci 15508c2ecf20Sopenharmony_ciint qlcnic_pcie_sem_lock(struct qlcnic_adapter *, int, u32); 15518c2ecf20Sopenharmony_civoid qlcnic_pcie_sem_unlock(struct qlcnic_adapter *, int); 15528c2ecf20Sopenharmony_ci 15538c2ecf20Sopenharmony_ci#define qlcnic_rom_lock(a) \ 15548c2ecf20Sopenharmony_ci qlcnic_pcie_sem_lock((a), 2, QLCNIC_ROM_LOCK_ID) 15558c2ecf20Sopenharmony_ci#define qlcnic_rom_unlock(a) \ 15568c2ecf20Sopenharmony_ci qlcnic_pcie_sem_unlock((a), 2) 15578c2ecf20Sopenharmony_ci#define qlcnic_phy_lock(a) \ 15588c2ecf20Sopenharmony_ci qlcnic_pcie_sem_lock((a), 3, QLCNIC_PHY_LOCK_ID) 15598c2ecf20Sopenharmony_ci#define qlcnic_phy_unlock(a) \ 15608c2ecf20Sopenharmony_ci qlcnic_pcie_sem_unlock((a), 3) 15618c2ecf20Sopenharmony_ci#define qlcnic_sw_lock(a) \ 15628c2ecf20Sopenharmony_ci qlcnic_pcie_sem_lock((a), 6, 0) 15638c2ecf20Sopenharmony_ci#define qlcnic_sw_unlock(a) \ 15648c2ecf20Sopenharmony_ci qlcnic_pcie_sem_unlock((a), 6) 15658c2ecf20Sopenharmony_ci#define crb_win_lock(a) \ 15668c2ecf20Sopenharmony_ci qlcnic_pcie_sem_lock((a), 7, QLCNIC_CRB_WIN_LOCK_ID) 15678c2ecf20Sopenharmony_ci#define crb_win_unlock(a) \ 15688c2ecf20Sopenharmony_ci qlcnic_pcie_sem_unlock((a), 7) 15698c2ecf20Sopenharmony_ci 15708c2ecf20Sopenharmony_ci#define __QLCNIC_MAX_LED_RATE 0xf 15718c2ecf20Sopenharmony_ci#define __QLCNIC_MAX_LED_STATE 0x2 15728c2ecf20Sopenharmony_ci 15738c2ecf20Sopenharmony_ci#define MAX_CTL_CHECK 1000 15748c2ecf20Sopenharmony_ci 15758c2ecf20Sopenharmony_civoid qlcnic_prune_lb_filters(struct qlcnic_adapter *adapter); 15768c2ecf20Sopenharmony_civoid qlcnic_delete_lb_filters(struct qlcnic_adapter *adapter); 15778c2ecf20Sopenharmony_ciint qlcnic_dump_fw(struct qlcnic_adapter *); 15788c2ecf20Sopenharmony_ciint qlcnic_enable_fw_dump_state(struct qlcnic_adapter *); 15798c2ecf20Sopenharmony_cibool qlcnic_check_fw_dump_state(struct qlcnic_adapter *); 15808c2ecf20Sopenharmony_ci 15818c2ecf20Sopenharmony_ci/* Functions from qlcnic_init.c */ 15828c2ecf20Sopenharmony_civoid qlcnic_schedule_work(struct qlcnic_adapter *, work_func_t, int); 15838c2ecf20Sopenharmony_ciint qlcnic_load_firmware(struct qlcnic_adapter *adapter); 15848c2ecf20Sopenharmony_ciint qlcnic_need_fw_reset(struct qlcnic_adapter *adapter); 15858c2ecf20Sopenharmony_civoid qlcnic_request_firmware(struct qlcnic_adapter *adapter); 15868c2ecf20Sopenharmony_civoid qlcnic_release_firmware(struct qlcnic_adapter *adapter); 15878c2ecf20Sopenharmony_ciint qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter); 15888c2ecf20Sopenharmony_ciint qlcnic_setup_idc_param(struct qlcnic_adapter *adapter); 15898c2ecf20Sopenharmony_ciint qlcnic_check_flash_fw_ver(struct qlcnic_adapter *adapter); 15908c2ecf20Sopenharmony_ci 15918c2ecf20Sopenharmony_ciint qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, u32 addr, u32 *valp); 15928c2ecf20Sopenharmony_ciint qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr, 15938c2ecf20Sopenharmony_ci u8 *bytes, size_t size); 15948c2ecf20Sopenharmony_ciint qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter); 15958c2ecf20Sopenharmony_civoid qlcnic_free_sw_resources(struct qlcnic_adapter *adapter); 15968c2ecf20Sopenharmony_ci 15978c2ecf20Sopenharmony_civoid __iomem *qlcnic_get_ioaddr(struct qlcnic_hardware_context *, u32); 15988c2ecf20Sopenharmony_ci 15998c2ecf20Sopenharmony_ciint qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter); 16008c2ecf20Sopenharmony_civoid qlcnic_free_hw_resources(struct qlcnic_adapter *adapter); 16018c2ecf20Sopenharmony_ci 16028c2ecf20Sopenharmony_ciint qlcnic_fw_create_ctx(struct qlcnic_adapter *adapter); 16038c2ecf20Sopenharmony_civoid qlcnic_fw_destroy_ctx(struct qlcnic_adapter *adapter); 16048c2ecf20Sopenharmony_ci 16058c2ecf20Sopenharmony_civoid qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter); 16068c2ecf20Sopenharmony_civoid qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter); 16078c2ecf20Sopenharmony_civoid qlcnic_release_tx_buffers(struct qlcnic_adapter *, 16088c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *); 16098c2ecf20Sopenharmony_ci 16108c2ecf20Sopenharmony_ciint qlcnic_check_fw_status(struct qlcnic_adapter *adapter); 16118c2ecf20Sopenharmony_civoid qlcnic_watchdog_task(struct work_struct *work); 16128c2ecf20Sopenharmony_civoid qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, 16138c2ecf20Sopenharmony_ci struct qlcnic_host_rds_ring *rds_ring, u8 ring_id); 16148c2ecf20Sopenharmony_civoid qlcnic_set_multi(struct net_device *netdev); 16158c2ecf20Sopenharmony_civoid qlcnic_flush_mcast_mac(struct qlcnic_adapter *); 16168c2ecf20Sopenharmony_ciint qlcnic_nic_add_mac(struct qlcnic_adapter *, const u8 *, u16, 16178c2ecf20Sopenharmony_ci enum qlcnic_mac_type); 16188c2ecf20Sopenharmony_ciint qlcnic_nic_del_mac(struct qlcnic_adapter *, const u8 *); 16198c2ecf20Sopenharmony_civoid qlcnic_82xx_free_mac_list(struct qlcnic_adapter *adapter); 16208c2ecf20Sopenharmony_ciint qlcnic_82xx_read_phys_port_id(struct qlcnic_adapter *); 16218c2ecf20Sopenharmony_ci 16228c2ecf20Sopenharmony_ciint qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu); 16238c2ecf20Sopenharmony_ciint qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *, u32); 16248c2ecf20Sopenharmony_ciint qlcnic_change_mtu(struct net_device *netdev, int new_mtu); 16258c2ecf20Sopenharmony_cinetdev_features_t qlcnic_fix_features(struct net_device *netdev, 16268c2ecf20Sopenharmony_ci netdev_features_t features); 16278c2ecf20Sopenharmony_ciint qlcnic_set_features(struct net_device *netdev, netdev_features_t features); 16288c2ecf20Sopenharmony_ciint qlcnic_config_bridged_mode(struct qlcnic_adapter *adapter, u32 enable); 16298c2ecf20Sopenharmony_civoid qlcnic_update_cmd_producer(struct qlcnic_host_tx_ring *); 16308c2ecf20Sopenharmony_ci 16318c2ecf20Sopenharmony_ci/* Functions from qlcnic_ethtool.c */ 16328c2ecf20Sopenharmony_ciint qlcnic_check_loopback_buff(unsigned char *, u8 []); 16338c2ecf20Sopenharmony_ciint qlcnic_do_lb_test(struct qlcnic_adapter *, u8); 16348c2ecf20Sopenharmony_ci 16358c2ecf20Sopenharmony_ci/* Functions from qlcnic_main.c */ 16368c2ecf20Sopenharmony_ciint qlcnic_reset_context(struct qlcnic_adapter *); 16378c2ecf20Sopenharmony_civoid qlcnic_diag_free_res(struct net_device *netdev, int); 16388c2ecf20Sopenharmony_ciint qlcnic_diag_alloc_res(struct net_device *netdev, int); 16398c2ecf20Sopenharmony_cinetdev_tx_t qlcnic_xmit_frame(struct sk_buff *, struct net_device *); 16408c2ecf20Sopenharmony_civoid qlcnic_set_tx_ring_count(struct qlcnic_adapter *, u8); 16418c2ecf20Sopenharmony_civoid qlcnic_set_sds_ring_count(struct qlcnic_adapter *, u8); 16428c2ecf20Sopenharmony_ciint qlcnic_setup_rings(struct qlcnic_adapter *); 16438c2ecf20Sopenharmony_ciint qlcnic_validate_rings(struct qlcnic_adapter *, __u32, int); 16448c2ecf20Sopenharmony_civoid qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter); 16458c2ecf20Sopenharmony_ciint qlcnic_enable_msix(struct qlcnic_adapter *, u32); 16468c2ecf20Sopenharmony_civoid qlcnic_set_drv_version(struct qlcnic_adapter *); 16478c2ecf20Sopenharmony_ci 16488c2ecf20Sopenharmony_ci/* eSwitch management functions */ 16498c2ecf20Sopenharmony_ciint qlcnic_config_switch_port(struct qlcnic_adapter *, 16508c2ecf20Sopenharmony_ci struct qlcnic_esw_func_cfg *); 16518c2ecf20Sopenharmony_ci 16528c2ecf20Sopenharmony_ciint qlcnic_get_eswitch_port_config(struct qlcnic_adapter *, 16538c2ecf20Sopenharmony_ci struct qlcnic_esw_func_cfg *); 16548c2ecf20Sopenharmony_ciint qlcnic_config_port_mirroring(struct qlcnic_adapter *, u8, u8, u8); 16558c2ecf20Sopenharmony_ciint qlcnic_get_port_stats(struct qlcnic_adapter *, const u8, const u8, 16568c2ecf20Sopenharmony_ci struct __qlcnic_esw_statistics *); 16578c2ecf20Sopenharmony_ciint qlcnic_get_eswitch_stats(struct qlcnic_adapter *, const u8, u8, 16588c2ecf20Sopenharmony_ci struct __qlcnic_esw_statistics *); 16598c2ecf20Sopenharmony_ciint qlcnic_clear_esw_stats(struct qlcnic_adapter *adapter, u8, u8, u8); 16608c2ecf20Sopenharmony_ciint qlcnic_get_mac_stats(struct qlcnic_adapter *, struct qlcnic_mac_statistics *); 16618c2ecf20Sopenharmony_ci 16628c2ecf20Sopenharmony_civoid qlcnic_free_mbx_args(struct qlcnic_cmd_args *cmd); 16638c2ecf20Sopenharmony_ci 16648c2ecf20Sopenharmony_ciint qlcnic_alloc_sds_rings(struct qlcnic_recv_context *, int); 16658c2ecf20Sopenharmony_civoid qlcnic_free_sds_rings(struct qlcnic_recv_context *); 16668c2ecf20Sopenharmony_civoid qlcnic_advert_link_change(struct qlcnic_adapter *, int); 16678c2ecf20Sopenharmony_civoid qlcnic_free_tx_rings(struct qlcnic_adapter *); 16688c2ecf20Sopenharmony_ciint qlcnic_alloc_tx_rings(struct qlcnic_adapter *, struct net_device *); 16698c2ecf20Sopenharmony_civoid qlcnic_dump_mbx(struct qlcnic_adapter *, struct qlcnic_cmd_args *); 16708c2ecf20Sopenharmony_ci 16718c2ecf20Sopenharmony_civoid qlcnic_create_sysfs_entries(struct qlcnic_adapter *adapter); 16728c2ecf20Sopenharmony_civoid qlcnic_remove_sysfs_entries(struct qlcnic_adapter *adapter); 16738c2ecf20Sopenharmony_civoid qlcnic_82xx_add_sysfs(struct qlcnic_adapter *adapter); 16748c2ecf20Sopenharmony_civoid qlcnic_82xx_remove_sysfs(struct qlcnic_adapter *adapter); 16758c2ecf20Sopenharmony_ci 16768c2ecf20Sopenharmony_ciint qlcnicvf_config_bridged_mode(struct qlcnic_adapter *, u32); 16778c2ecf20Sopenharmony_ciint qlcnicvf_config_led(struct qlcnic_adapter *, u32, u32); 16788c2ecf20Sopenharmony_civoid qlcnic_set_vlan_config(struct qlcnic_adapter *, 16798c2ecf20Sopenharmony_ci struct qlcnic_esw_func_cfg *); 16808c2ecf20Sopenharmony_civoid qlcnic_set_eswitch_port_features(struct qlcnic_adapter *, 16818c2ecf20Sopenharmony_ci struct qlcnic_esw_func_cfg *); 16828c2ecf20Sopenharmony_ciint qlcnic_setup_tss_rss_intr(struct qlcnic_adapter *); 16838c2ecf20Sopenharmony_civoid qlcnic_down(struct qlcnic_adapter *, struct net_device *); 16848c2ecf20Sopenharmony_ciint qlcnic_up(struct qlcnic_adapter *, struct net_device *); 16858c2ecf20Sopenharmony_civoid __qlcnic_down(struct qlcnic_adapter *, struct net_device *); 16868c2ecf20Sopenharmony_civoid qlcnic_detach(struct qlcnic_adapter *); 16878c2ecf20Sopenharmony_civoid qlcnic_teardown_intr(struct qlcnic_adapter *); 16888c2ecf20Sopenharmony_ciint qlcnic_attach(struct qlcnic_adapter *); 16898c2ecf20Sopenharmony_ciint __qlcnic_up(struct qlcnic_adapter *, struct net_device *); 16908c2ecf20Sopenharmony_civoid qlcnic_restore_indev_addr(struct net_device *, unsigned long); 16918c2ecf20Sopenharmony_ci 16928c2ecf20Sopenharmony_ciint qlcnic_check_temp(struct qlcnic_adapter *); 16938c2ecf20Sopenharmony_ciint qlcnic_init_pci_info(struct qlcnic_adapter *); 16948c2ecf20Sopenharmony_ciint qlcnic_set_default_offload_settings(struct qlcnic_adapter *); 16958c2ecf20Sopenharmony_ciint qlcnic_reset_npar_config(struct qlcnic_adapter *); 16968c2ecf20Sopenharmony_ciint qlcnic_set_eswitch_port_config(struct qlcnic_adapter *); 16978c2ecf20Sopenharmony_ciint qlcnic_set_vxlan_port(struct qlcnic_adapter *adapter, u16 port); 16988c2ecf20Sopenharmony_ciint qlcnic_set_vxlan_parsing(struct qlcnic_adapter *adapter, u16 port); 16998c2ecf20Sopenharmony_ciint qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter); 17008c2ecf20Sopenharmony_ciint qlcnic_read_mac_addr(struct qlcnic_adapter *); 17018c2ecf20Sopenharmony_ciint qlcnic_setup_netdev(struct qlcnic_adapter *, struct net_device *, int); 17028c2ecf20Sopenharmony_civoid qlcnic_set_netdev_features(struct qlcnic_adapter *, 17038c2ecf20Sopenharmony_ci struct qlcnic_esw_func_cfg *); 17048c2ecf20Sopenharmony_civoid qlcnic_sriov_vf_set_multi(struct net_device *); 17058c2ecf20Sopenharmony_ciint qlcnic_is_valid_nic_func(struct qlcnic_adapter *, u8); 17068c2ecf20Sopenharmony_ciint qlcnic_get_pci_func_type(struct qlcnic_adapter *, u16, u16 *, u16 *, 17078c2ecf20Sopenharmony_ci u16 *); 17088c2ecf20Sopenharmony_ci 17098c2ecf20Sopenharmony_ci/* 17108c2ecf20Sopenharmony_ci * QLOGIC Board information 17118c2ecf20Sopenharmony_ci */ 17128c2ecf20Sopenharmony_ci 17138c2ecf20Sopenharmony_ci#define QLCNIC_MAX_BOARD_NAME_LEN 100 17148c2ecf20Sopenharmony_cistruct qlcnic_board_info { 17158c2ecf20Sopenharmony_ci unsigned short vendor; 17168c2ecf20Sopenharmony_ci unsigned short device; 17178c2ecf20Sopenharmony_ci unsigned short sub_vendor; 17188c2ecf20Sopenharmony_ci unsigned short sub_device; 17198c2ecf20Sopenharmony_ci char short_name[QLCNIC_MAX_BOARD_NAME_LEN]; 17208c2ecf20Sopenharmony_ci}; 17218c2ecf20Sopenharmony_ci 17228c2ecf20Sopenharmony_cistatic inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring) 17238c2ecf20Sopenharmony_ci{ 17248c2ecf20Sopenharmony_ci if (likely(tx_ring->producer < tx_ring->sw_consumer)) 17258c2ecf20Sopenharmony_ci return tx_ring->sw_consumer - tx_ring->producer; 17268c2ecf20Sopenharmony_ci else 17278c2ecf20Sopenharmony_ci return tx_ring->sw_consumer + tx_ring->num_desc - 17288c2ecf20Sopenharmony_ci tx_ring->producer; 17298c2ecf20Sopenharmony_ci} 17308c2ecf20Sopenharmony_ci 17318c2ecf20Sopenharmony_cistruct qlcnic_nic_template { 17328c2ecf20Sopenharmony_ci int (*config_bridged_mode) (struct qlcnic_adapter *, u32); 17338c2ecf20Sopenharmony_ci int (*config_led) (struct qlcnic_adapter *, u32, u32); 17348c2ecf20Sopenharmony_ci int (*start_firmware) (struct qlcnic_adapter *); 17358c2ecf20Sopenharmony_ci int (*init_driver) (struct qlcnic_adapter *); 17368c2ecf20Sopenharmony_ci void (*request_reset) (struct qlcnic_adapter *, u32); 17378c2ecf20Sopenharmony_ci void (*cancel_idc_work) (struct qlcnic_adapter *); 17388c2ecf20Sopenharmony_ci int (*napi_add)(struct qlcnic_adapter *, struct net_device *); 17398c2ecf20Sopenharmony_ci void (*napi_del)(struct qlcnic_adapter *); 17408c2ecf20Sopenharmony_ci void (*config_ipaddr)(struct qlcnic_adapter *, __be32, int); 17418c2ecf20Sopenharmony_ci irqreturn_t (*clear_legacy_intr)(struct qlcnic_adapter *); 17428c2ecf20Sopenharmony_ci int (*shutdown)(struct pci_dev *); 17438c2ecf20Sopenharmony_ci int (*resume)(struct qlcnic_adapter *); 17448c2ecf20Sopenharmony_ci}; 17458c2ecf20Sopenharmony_ci 17468c2ecf20Sopenharmony_cistruct qlcnic_mbx_ops { 17478c2ecf20Sopenharmony_ci int (*enqueue_cmd) (struct qlcnic_adapter *, 17488c2ecf20Sopenharmony_ci struct qlcnic_cmd_args *, unsigned long *); 17498c2ecf20Sopenharmony_ci void (*dequeue_cmd) (struct qlcnic_adapter *, struct qlcnic_cmd_args *); 17508c2ecf20Sopenharmony_ci void (*decode_resp) (struct qlcnic_adapter *, struct qlcnic_cmd_args *); 17518c2ecf20Sopenharmony_ci void (*encode_cmd) (struct qlcnic_adapter *, struct qlcnic_cmd_args *); 17528c2ecf20Sopenharmony_ci void (*nofity_fw) (struct qlcnic_adapter *, u8); 17538c2ecf20Sopenharmony_ci}; 17548c2ecf20Sopenharmony_ci 17558c2ecf20Sopenharmony_ciint qlcnic_83xx_init_mailbox_work(struct qlcnic_adapter *); 17568c2ecf20Sopenharmony_civoid qlcnic_83xx_detach_mailbox_work(struct qlcnic_adapter *); 17578c2ecf20Sopenharmony_civoid qlcnic_83xx_reinit_mbx_work(struct qlcnic_mailbox *mbx); 17588c2ecf20Sopenharmony_civoid qlcnic_83xx_free_mailbox(struct qlcnic_mailbox *mbx); 17598c2ecf20Sopenharmony_civoid qlcnic_update_stats(struct qlcnic_adapter *); 17608c2ecf20Sopenharmony_ci 17618c2ecf20Sopenharmony_ci/* Adapter hardware abstraction */ 17628c2ecf20Sopenharmony_cistruct qlcnic_hardware_ops { 17638c2ecf20Sopenharmony_ci void (*read_crb) (struct qlcnic_adapter *, char *, loff_t, size_t); 17648c2ecf20Sopenharmony_ci void (*write_crb) (struct qlcnic_adapter *, char *, loff_t, size_t); 17658c2ecf20Sopenharmony_ci int (*read_reg) (struct qlcnic_adapter *, ulong, int *); 17668c2ecf20Sopenharmony_ci int (*write_reg) (struct qlcnic_adapter *, ulong, u32); 17678c2ecf20Sopenharmony_ci void (*get_ocm_win) (struct qlcnic_hardware_context *); 17688c2ecf20Sopenharmony_ci int (*get_mac_address) (struct qlcnic_adapter *, u8 *, u8); 17698c2ecf20Sopenharmony_ci int (*setup_intr) (struct qlcnic_adapter *); 17708c2ecf20Sopenharmony_ci int (*alloc_mbx_args)(struct qlcnic_cmd_args *, 17718c2ecf20Sopenharmony_ci struct qlcnic_adapter *, u32); 17728c2ecf20Sopenharmony_ci int (*mbx_cmd) (struct qlcnic_adapter *, struct qlcnic_cmd_args *); 17738c2ecf20Sopenharmony_ci void (*get_func_no) (struct qlcnic_adapter *); 17748c2ecf20Sopenharmony_ci int (*api_lock) (struct qlcnic_adapter *); 17758c2ecf20Sopenharmony_ci void (*api_unlock) (struct qlcnic_adapter *); 17768c2ecf20Sopenharmony_ci void (*add_sysfs) (struct qlcnic_adapter *); 17778c2ecf20Sopenharmony_ci void (*remove_sysfs) (struct qlcnic_adapter *); 17788c2ecf20Sopenharmony_ci void (*process_lb_rcv_ring_diag) (struct qlcnic_host_sds_ring *); 17798c2ecf20Sopenharmony_ci int (*create_rx_ctx) (struct qlcnic_adapter *); 17808c2ecf20Sopenharmony_ci int (*create_tx_ctx) (struct qlcnic_adapter *, 17818c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *, int); 17828c2ecf20Sopenharmony_ci void (*del_rx_ctx) (struct qlcnic_adapter *); 17838c2ecf20Sopenharmony_ci void (*del_tx_ctx) (struct qlcnic_adapter *, 17848c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *); 17858c2ecf20Sopenharmony_ci int (*setup_link_event) (struct qlcnic_adapter *, int); 17868c2ecf20Sopenharmony_ci int (*get_nic_info) (struct qlcnic_adapter *, struct qlcnic_info *, u8); 17878c2ecf20Sopenharmony_ci int (*get_pci_info) (struct qlcnic_adapter *, struct qlcnic_pci_info *); 17888c2ecf20Sopenharmony_ci int (*set_nic_info) (struct qlcnic_adapter *, struct qlcnic_info *); 17898c2ecf20Sopenharmony_ci int (*change_macvlan) (struct qlcnic_adapter *, u8*, u16, u8); 17908c2ecf20Sopenharmony_ci void (*napi_enable) (struct qlcnic_adapter *); 17918c2ecf20Sopenharmony_ci void (*napi_disable) (struct qlcnic_adapter *); 17928c2ecf20Sopenharmony_ci int (*config_intr_coal) (struct qlcnic_adapter *, 17938c2ecf20Sopenharmony_ci struct ethtool_coalesce *); 17948c2ecf20Sopenharmony_ci int (*config_rss) (struct qlcnic_adapter *, int); 17958c2ecf20Sopenharmony_ci int (*config_hw_lro) (struct qlcnic_adapter *, int); 17968c2ecf20Sopenharmony_ci int (*config_loopback) (struct qlcnic_adapter *, u8); 17978c2ecf20Sopenharmony_ci int (*clear_loopback) (struct qlcnic_adapter *, u8); 17988c2ecf20Sopenharmony_ci int (*config_promisc_mode) (struct qlcnic_adapter *, u32); 17998c2ecf20Sopenharmony_ci void (*change_l2_filter)(struct qlcnic_adapter *adapter, u64 *addr, 18008c2ecf20Sopenharmony_ci u16 vlan, struct qlcnic_host_tx_ring *tx_ring); 18018c2ecf20Sopenharmony_ci int (*get_board_info) (struct qlcnic_adapter *); 18028c2ecf20Sopenharmony_ci void (*set_mac_filter_count) (struct qlcnic_adapter *); 18038c2ecf20Sopenharmony_ci void (*free_mac_list) (struct qlcnic_adapter *); 18048c2ecf20Sopenharmony_ci int (*read_phys_port_id) (struct qlcnic_adapter *); 18058c2ecf20Sopenharmony_ci pci_ers_result_t (*io_error_detected) (struct pci_dev *, 18068c2ecf20Sopenharmony_ci pci_channel_state_t); 18078c2ecf20Sopenharmony_ci pci_ers_result_t (*io_slot_reset) (struct pci_dev *); 18088c2ecf20Sopenharmony_ci void (*io_resume) (struct pci_dev *); 18098c2ecf20Sopenharmony_ci void (*get_beacon_state)(struct qlcnic_adapter *); 18108c2ecf20Sopenharmony_ci void (*enable_sds_intr) (struct qlcnic_adapter *, 18118c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *); 18128c2ecf20Sopenharmony_ci void (*disable_sds_intr) (struct qlcnic_adapter *, 18138c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *); 18148c2ecf20Sopenharmony_ci void (*enable_tx_intr) (struct qlcnic_adapter *, 18158c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *); 18168c2ecf20Sopenharmony_ci void (*disable_tx_intr) (struct qlcnic_adapter *, 18178c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *); 18188c2ecf20Sopenharmony_ci u32 (*get_saved_state)(void *, u32); 18198c2ecf20Sopenharmony_ci void (*set_saved_state)(void *, u32, u32); 18208c2ecf20Sopenharmony_ci void (*cache_tmpl_hdr_values)(struct qlcnic_fw_dump *); 18218c2ecf20Sopenharmony_ci u32 (*get_cap_size)(void *, int); 18228c2ecf20Sopenharmony_ci void (*set_sys_info)(void *, int, u32); 18238c2ecf20Sopenharmony_ci void (*store_cap_mask)(void *, u32); 18248c2ecf20Sopenharmony_ci bool (*encap_rx_offload) (struct qlcnic_adapter *adapter); 18258c2ecf20Sopenharmony_ci bool (*encap_tx_offload) (struct qlcnic_adapter *adapter); 18268c2ecf20Sopenharmony_ci}; 18278c2ecf20Sopenharmony_ci 18288c2ecf20Sopenharmony_ciextern struct qlcnic_nic_template qlcnic_vf_ops; 18298c2ecf20Sopenharmony_ci 18308c2ecf20Sopenharmony_cistatic inline bool qlcnic_83xx_encap_tx_offload(struct qlcnic_adapter *adapter) 18318c2ecf20Sopenharmony_ci{ 18328c2ecf20Sopenharmony_ci return adapter->ahw->extra_capability[0] & 18338c2ecf20Sopenharmony_ci QLCNIC_83XX_FW_CAPAB_ENCAP_TX_OFFLOAD; 18348c2ecf20Sopenharmony_ci} 18358c2ecf20Sopenharmony_ci 18368c2ecf20Sopenharmony_cistatic inline bool qlcnic_83xx_encap_rx_offload(struct qlcnic_adapter *adapter) 18378c2ecf20Sopenharmony_ci{ 18388c2ecf20Sopenharmony_ci return adapter->ahw->extra_capability[0] & 18398c2ecf20Sopenharmony_ci QLCNIC_83XX_FW_CAPAB_ENCAP_RX_OFFLOAD; 18408c2ecf20Sopenharmony_ci} 18418c2ecf20Sopenharmony_ci 18428c2ecf20Sopenharmony_cistatic inline bool qlcnic_82xx_encap_tx_offload(struct qlcnic_adapter *adapter) 18438c2ecf20Sopenharmony_ci{ 18448c2ecf20Sopenharmony_ci return false; 18458c2ecf20Sopenharmony_ci} 18468c2ecf20Sopenharmony_ci 18478c2ecf20Sopenharmony_cistatic inline bool qlcnic_82xx_encap_rx_offload(struct qlcnic_adapter *adapter) 18488c2ecf20Sopenharmony_ci{ 18498c2ecf20Sopenharmony_ci return false; 18508c2ecf20Sopenharmony_ci} 18518c2ecf20Sopenharmony_ci 18528c2ecf20Sopenharmony_cistatic inline bool qlcnic_encap_rx_offload(struct qlcnic_adapter *adapter) 18538c2ecf20Sopenharmony_ci{ 18548c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->encap_rx_offload(adapter); 18558c2ecf20Sopenharmony_ci} 18568c2ecf20Sopenharmony_ci 18578c2ecf20Sopenharmony_cistatic inline bool qlcnic_encap_tx_offload(struct qlcnic_adapter *adapter) 18588c2ecf20Sopenharmony_ci{ 18598c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->encap_tx_offload(adapter); 18608c2ecf20Sopenharmony_ci} 18618c2ecf20Sopenharmony_ci 18628c2ecf20Sopenharmony_cistatic inline int qlcnic_start_firmware(struct qlcnic_adapter *adapter) 18638c2ecf20Sopenharmony_ci{ 18648c2ecf20Sopenharmony_ci return adapter->nic_ops->start_firmware(adapter); 18658c2ecf20Sopenharmony_ci} 18668c2ecf20Sopenharmony_ci 18678c2ecf20Sopenharmony_cistatic inline void qlcnic_read_crb(struct qlcnic_adapter *adapter, char *buf, 18688c2ecf20Sopenharmony_ci loff_t offset, size_t size) 18698c2ecf20Sopenharmony_ci{ 18708c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->read_crb(adapter, buf, offset, size); 18718c2ecf20Sopenharmony_ci} 18728c2ecf20Sopenharmony_ci 18738c2ecf20Sopenharmony_cistatic inline void qlcnic_write_crb(struct qlcnic_adapter *adapter, char *buf, 18748c2ecf20Sopenharmony_ci loff_t offset, size_t size) 18758c2ecf20Sopenharmony_ci{ 18768c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->write_crb(adapter, buf, offset, size); 18778c2ecf20Sopenharmony_ci} 18788c2ecf20Sopenharmony_ci 18798c2ecf20Sopenharmony_cistatic inline int qlcnic_get_mac_address(struct qlcnic_adapter *adapter, 18808c2ecf20Sopenharmony_ci u8 *mac, u8 function) 18818c2ecf20Sopenharmony_ci{ 18828c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->get_mac_address(adapter, mac, function); 18838c2ecf20Sopenharmony_ci} 18848c2ecf20Sopenharmony_ci 18858c2ecf20Sopenharmony_cistatic inline int qlcnic_setup_intr(struct qlcnic_adapter *adapter) 18868c2ecf20Sopenharmony_ci{ 18878c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->setup_intr(adapter); 18888c2ecf20Sopenharmony_ci} 18898c2ecf20Sopenharmony_ci 18908c2ecf20Sopenharmony_cistatic inline int qlcnic_alloc_mbx_args(struct qlcnic_cmd_args *mbx, 18918c2ecf20Sopenharmony_ci struct qlcnic_adapter *adapter, u32 arg) 18928c2ecf20Sopenharmony_ci{ 18938c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->alloc_mbx_args(mbx, adapter, arg); 18948c2ecf20Sopenharmony_ci} 18958c2ecf20Sopenharmony_ci 18968c2ecf20Sopenharmony_cistatic inline int qlcnic_issue_cmd(struct qlcnic_adapter *adapter, 18978c2ecf20Sopenharmony_ci struct qlcnic_cmd_args *cmd) 18988c2ecf20Sopenharmony_ci{ 18998c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->mbx_cmd) 19008c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->mbx_cmd(adapter, cmd); 19018c2ecf20Sopenharmony_ci 19028c2ecf20Sopenharmony_ci return -EIO; 19038c2ecf20Sopenharmony_ci} 19048c2ecf20Sopenharmony_ci 19058c2ecf20Sopenharmony_cistatic inline void qlcnic_get_func_no(struct qlcnic_adapter *adapter) 19068c2ecf20Sopenharmony_ci{ 19078c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->get_func_no(adapter); 19088c2ecf20Sopenharmony_ci} 19098c2ecf20Sopenharmony_ci 19108c2ecf20Sopenharmony_cistatic inline int qlcnic_api_lock(struct qlcnic_adapter *adapter) 19118c2ecf20Sopenharmony_ci{ 19128c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->api_lock(adapter); 19138c2ecf20Sopenharmony_ci} 19148c2ecf20Sopenharmony_ci 19158c2ecf20Sopenharmony_cistatic inline void qlcnic_api_unlock(struct qlcnic_adapter *adapter) 19168c2ecf20Sopenharmony_ci{ 19178c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->api_unlock(adapter); 19188c2ecf20Sopenharmony_ci} 19198c2ecf20Sopenharmony_ci 19208c2ecf20Sopenharmony_cistatic inline void qlcnic_add_sysfs(struct qlcnic_adapter *adapter) 19218c2ecf20Sopenharmony_ci{ 19228c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->add_sysfs) 19238c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->add_sysfs(adapter); 19248c2ecf20Sopenharmony_ci} 19258c2ecf20Sopenharmony_ci 19268c2ecf20Sopenharmony_cistatic inline void qlcnic_remove_sysfs(struct qlcnic_adapter *adapter) 19278c2ecf20Sopenharmony_ci{ 19288c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->remove_sysfs) 19298c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->remove_sysfs(adapter); 19308c2ecf20Sopenharmony_ci} 19318c2ecf20Sopenharmony_ci 19328c2ecf20Sopenharmony_cistatic inline void 19338c2ecf20Sopenharmony_ciqlcnic_process_rcv_ring_diag(struct qlcnic_host_sds_ring *sds_ring) 19348c2ecf20Sopenharmony_ci{ 19358c2ecf20Sopenharmony_ci sds_ring->adapter->ahw->hw_ops->process_lb_rcv_ring_diag(sds_ring); 19368c2ecf20Sopenharmony_ci} 19378c2ecf20Sopenharmony_ci 19388c2ecf20Sopenharmony_cistatic inline int qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) 19398c2ecf20Sopenharmony_ci{ 19408c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->create_rx_ctx(adapter); 19418c2ecf20Sopenharmony_ci} 19428c2ecf20Sopenharmony_ci 19438c2ecf20Sopenharmony_cistatic inline int qlcnic_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter, 19448c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *ptr, 19458c2ecf20Sopenharmony_ci int ring) 19468c2ecf20Sopenharmony_ci{ 19478c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->create_tx_ctx(adapter, ptr, ring); 19488c2ecf20Sopenharmony_ci} 19498c2ecf20Sopenharmony_ci 19508c2ecf20Sopenharmony_cistatic inline void qlcnic_fw_cmd_del_rx_ctx(struct qlcnic_adapter *adapter) 19518c2ecf20Sopenharmony_ci{ 19528c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->del_rx_ctx(adapter); 19538c2ecf20Sopenharmony_ci} 19548c2ecf20Sopenharmony_ci 19558c2ecf20Sopenharmony_cistatic inline void qlcnic_fw_cmd_del_tx_ctx(struct qlcnic_adapter *adapter, 19568c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *ptr) 19578c2ecf20Sopenharmony_ci{ 19588c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->del_tx_ctx(adapter, ptr); 19598c2ecf20Sopenharmony_ci} 19608c2ecf20Sopenharmony_ci 19618c2ecf20Sopenharmony_cistatic inline int qlcnic_linkevent_request(struct qlcnic_adapter *adapter, 19628c2ecf20Sopenharmony_ci int enable) 19638c2ecf20Sopenharmony_ci{ 19648c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->setup_link_event(adapter, enable); 19658c2ecf20Sopenharmony_ci} 19668c2ecf20Sopenharmony_ci 19678c2ecf20Sopenharmony_cistatic inline int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, 19688c2ecf20Sopenharmony_ci struct qlcnic_info *info, u8 id) 19698c2ecf20Sopenharmony_ci{ 19708c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->get_nic_info(adapter, info, id); 19718c2ecf20Sopenharmony_ci} 19728c2ecf20Sopenharmony_ci 19738c2ecf20Sopenharmony_cistatic inline int qlcnic_get_pci_info(struct qlcnic_adapter *adapter, 19748c2ecf20Sopenharmony_ci struct qlcnic_pci_info *info) 19758c2ecf20Sopenharmony_ci{ 19768c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->get_pci_info(adapter, info); 19778c2ecf20Sopenharmony_ci} 19788c2ecf20Sopenharmony_ci 19798c2ecf20Sopenharmony_cistatic inline int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, 19808c2ecf20Sopenharmony_ci struct qlcnic_info *info) 19818c2ecf20Sopenharmony_ci{ 19828c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->set_nic_info(adapter, info); 19838c2ecf20Sopenharmony_ci} 19848c2ecf20Sopenharmony_ci 19858c2ecf20Sopenharmony_cistatic inline int qlcnic_sre_macaddr_change(struct qlcnic_adapter *adapter, 19868c2ecf20Sopenharmony_ci u8 *addr, u16 id, u8 cmd) 19878c2ecf20Sopenharmony_ci{ 19888c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->change_macvlan(adapter, addr, id, cmd); 19898c2ecf20Sopenharmony_ci} 19908c2ecf20Sopenharmony_ci 19918c2ecf20Sopenharmony_cistatic inline int qlcnic_napi_add(struct qlcnic_adapter *adapter, 19928c2ecf20Sopenharmony_ci struct net_device *netdev) 19938c2ecf20Sopenharmony_ci{ 19948c2ecf20Sopenharmony_ci return adapter->nic_ops->napi_add(adapter, netdev); 19958c2ecf20Sopenharmony_ci} 19968c2ecf20Sopenharmony_ci 19978c2ecf20Sopenharmony_cistatic inline void qlcnic_napi_del(struct qlcnic_adapter *adapter) 19988c2ecf20Sopenharmony_ci{ 19998c2ecf20Sopenharmony_ci adapter->nic_ops->napi_del(adapter); 20008c2ecf20Sopenharmony_ci} 20018c2ecf20Sopenharmony_ci 20028c2ecf20Sopenharmony_cistatic inline void qlcnic_napi_enable(struct qlcnic_adapter *adapter) 20038c2ecf20Sopenharmony_ci{ 20048c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->napi_enable(adapter); 20058c2ecf20Sopenharmony_ci} 20068c2ecf20Sopenharmony_ci 20078c2ecf20Sopenharmony_cistatic inline int __qlcnic_shutdown(struct pci_dev *pdev) 20088c2ecf20Sopenharmony_ci{ 20098c2ecf20Sopenharmony_ci struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); 20108c2ecf20Sopenharmony_ci 20118c2ecf20Sopenharmony_ci return adapter->nic_ops->shutdown(pdev); 20128c2ecf20Sopenharmony_ci} 20138c2ecf20Sopenharmony_ci 20148c2ecf20Sopenharmony_cistatic inline int __qlcnic_resume(struct qlcnic_adapter *adapter) 20158c2ecf20Sopenharmony_ci{ 20168c2ecf20Sopenharmony_ci return adapter->nic_ops->resume(adapter); 20178c2ecf20Sopenharmony_ci} 20188c2ecf20Sopenharmony_ci 20198c2ecf20Sopenharmony_cistatic inline void qlcnic_napi_disable(struct qlcnic_adapter *adapter) 20208c2ecf20Sopenharmony_ci{ 20218c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->napi_disable(adapter); 20228c2ecf20Sopenharmony_ci} 20238c2ecf20Sopenharmony_ci 20248c2ecf20Sopenharmony_cistatic inline int qlcnic_config_intr_coalesce(struct qlcnic_adapter *adapter, 20258c2ecf20Sopenharmony_ci struct ethtool_coalesce *ethcoal) 20268c2ecf20Sopenharmony_ci{ 20278c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->config_intr_coal(adapter, ethcoal); 20288c2ecf20Sopenharmony_ci} 20298c2ecf20Sopenharmony_ci 20308c2ecf20Sopenharmony_cistatic inline int qlcnic_config_rss(struct qlcnic_adapter *adapter, int enable) 20318c2ecf20Sopenharmony_ci{ 20328c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->config_rss(adapter, enable); 20338c2ecf20Sopenharmony_ci} 20348c2ecf20Sopenharmony_ci 20358c2ecf20Sopenharmony_cistatic inline int qlcnic_config_hw_lro(struct qlcnic_adapter *adapter, 20368c2ecf20Sopenharmony_ci int enable) 20378c2ecf20Sopenharmony_ci{ 20388c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->config_hw_lro(adapter, enable); 20398c2ecf20Sopenharmony_ci} 20408c2ecf20Sopenharmony_ci 20418c2ecf20Sopenharmony_cistatic inline int qlcnic_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode) 20428c2ecf20Sopenharmony_ci{ 20438c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->config_loopback(adapter, mode); 20448c2ecf20Sopenharmony_ci} 20458c2ecf20Sopenharmony_ci 20468c2ecf20Sopenharmony_cistatic inline int qlcnic_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode) 20478c2ecf20Sopenharmony_ci{ 20488c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->clear_loopback(adapter, mode); 20498c2ecf20Sopenharmony_ci} 20508c2ecf20Sopenharmony_ci 20518c2ecf20Sopenharmony_cistatic inline int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, 20528c2ecf20Sopenharmony_ci u32 mode) 20538c2ecf20Sopenharmony_ci{ 20548c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->config_promisc_mode(adapter, mode); 20558c2ecf20Sopenharmony_ci} 20568c2ecf20Sopenharmony_ci 20578c2ecf20Sopenharmony_cistatic inline void qlcnic_change_filter(struct qlcnic_adapter *adapter, 20588c2ecf20Sopenharmony_ci u64 *addr, u16 vlan, 20598c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring) 20608c2ecf20Sopenharmony_ci{ 20618c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->change_l2_filter(adapter, addr, vlan, tx_ring); 20628c2ecf20Sopenharmony_ci} 20638c2ecf20Sopenharmony_ci 20648c2ecf20Sopenharmony_cistatic inline int qlcnic_get_board_info(struct qlcnic_adapter *adapter) 20658c2ecf20Sopenharmony_ci{ 20668c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->get_board_info(adapter); 20678c2ecf20Sopenharmony_ci} 20688c2ecf20Sopenharmony_ci 20698c2ecf20Sopenharmony_cistatic inline void qlcnic_free_mac_list(struct qlcnic_adapter *adapter) 20708c2ecf20Sopenharmony_ci{ 20718c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->free_mac_list(adapter); 20728c2ecf20Sopenharmony_ci} 20738c2ecf20Sopenharmony_ci 20748c2ecf20Sopenharmony_cistatic inline void qlcnic_set_mac_filter_count(struct qlcnic_adapter *adapter) 20758c2ecf20Sopenharmony_ci{ 20768c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->set_mac_filter_count) 20778c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->set_mac_filter_count(adapter); 20788c2ecf20Sopenharmony_ci} 20798c2ecf20Sopenharmony_ci 20808c2ecf20Sopenharmony_cistatic inline void qlcnic_get_beacon_state(struct qlcnic_adapter *adapter) 20818c2ecf20Sopenharmony_ci{ 20828c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->get_beacon_state(adapter); 20838c2ecf20Sopenharmony_ci} 20848c2ecf20Sopenharmony_ci 20858c2ecf20Sopenharmony_cistatic inline void qlcnic_read_phys_port_id(struct qlcnic_adapter *adapter) 20868c2ecf20Sopenharmony_ci{ 20878c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->read_phys_port_id) 20888c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->read_phys_port_id(adapter); 20898c2ecf20Sopenharmony_ci} 20908c2ecf20Sopenharmony_ci 20918c2ecf20Sopenharmony_cistatic inline u32 qlcnic_get_saved_state(struct qlcnic_adapter *adapter, 20928c2ecf20Sopenharmony_ci void *t_hdr, u32 index) 20938c2ecf20Sopenharmony_ci{ 20948c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->get_saved_state(t_hdr, index); 20958c2ecf20Sopenharmony_ci} 20968c2ecf20Sopenharmony_ci 20978c2ecf20Sopenharmony_cistatic inline void qlcnic_set_saved_state(struct qlcnic_adapter *adapter, 20988c2ecf20Sopenharmony_ci void *t_hdr, u32 index, u32 value) 20998c2ecf20Sopenharmony_ci{ 21008c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->set_saved_state(t_hdr, index, value); 21018c2ecf20Sopenharmony_ci} 21028c2ecf20Sopenharmony_ci 21038c2ecf20Sopenharmony_cistatic inline void qlcnic_cache_tmpl_hdr_values(struct qlcnic_adapter *adapter, 21048c2ecf20Sopenharmony_ci struct qlcnic_fw_dump *fw_dump) 21058c2ecf20Sopenharmony_ci{ 21068c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->cache_tmpl_hdr_values(fw_dump); 21078c2ecf20Sopenharmony_ci} 21088c2ecf20Sopenharmony_ci 21098c2ecf20Sopenharmony_cistatic inline u32 qlcnic_get_cap_size(struct qlcnic_adapter *adapter, 21108c2ecf20Sopenharmony_ci void *tmpl_hdr, int index) 21118c2ecf20Sopenharmony_ci{ 21128c2ecf20Sopenharmony_ci return adapter->ahw->hw_ops->get_cap_size(tmpl_hdr, index); 21138c2ecf20Sopenharmony_ci} 21148c2ecf20Sopenharmony_ci 21158c2ecf20Sopenharmony_cistatic inline void qlcnic_set_sys_info(struct qlcnic_adapter *adapter, 21168c2ecf20Sopenharmony_ci void *tmpl_hdr, int idx, u32 value) 21178c2ecf20Sopenharmony_ci{ 21188c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->set_sys_info(tmpl_hdr, idx, value); 21198c2ecf20Sopenharmony_ci} 21208c2ecf20Sopenharmony_ci 21218c2ecf20Sopenharmony_cistatic inline void qlcnic_store_cap_mask(struct qlcnic_adapter *adapter, 21228c2ecf20Sopenharmony_ci void *tmpl_hdr, u32 mask) 21238c2ecf20Sopenharmony_ci{ 21248c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->store_cap_mask(tmpl_hdr, mask); 21258c2ecf20Sopenharmony_ci} 21268c2ecf20Sopenharmony_ci 21278c2ecf20Sopenharmony_cistatic inline void qlcnic_dev_request_reset(struct qlcnic_adapter *adapter, 21288c2ecf20Sopenharmony_ci u32 key) 21298c2ecf20Sopenharmony_ci{ 21308c2ecf20Sopenharmony_ci if (adapter->nic_ops->request_reset) 21318c2ecf20Sopenharmony_ci adapter->nic_ops->request_reset(adapter, key); 21328c2ecf20Sopenharmony_ci} 21338c2ecf20Sopenharmony_ci 21348c2ecf20Sopenharmony_cistatic inline void qlcnic_cancel_idc_work(struct qlcnic_adapter *adapter) 21358c2ecf20Sopenharmony_ci{ 21368c2ecf20Sopenharmony_ci if (adapter->nic_ops->cancel_idc_work) 21378c2ecf20Sopenharmony_ci adapter->nic_ops->cancel_idc_work(adapter); 21388c2ecf20Sopenharmony_ci} 21398c2ecf20Sopenharmony_ci 21408c2ecf20Sopenharmony_cistatic inline irqreturn_t 21418c2ecf20Sopenharmony_ciqlcnic_clear_legacy_intr(struct qlcnic_adapter *adapter) 21428c2ecf20Sopenharmony_ci{ 21438c2ecf20Sopenharmony_ci return adapter->nic_ops->clear_legacy_intr(adapter); 21448c2ecf20Sopenharmony_ci} 21458c2ecf20Sopenharmony_ci 21468c2ecf20Sopenharmony_cistatic inline int qlcnic_config_led(struct qlcnic_adapter *adapter, u32 state, 21478c2ecf20Sopenharmony_ci u32 rate) 21488c2ecf20Sopenharmony_ci{ 21498c2ecf20Sopenharmony_ci return adapter->nic_ops->config_led(adapter, state, rate); 21508c2ecf20Sopenharmony_ci} 21518c2ecf20Sopenharmony_ci 21528c2ecf20Sopenharmony_cistatic inline void qlcnic_config_ipaddr(struct qlcnic_adapter *adapter, 21538c2ecf20Sopenharmony_ci __be32 ip, int cmd) 21548c2ecf20Sopenharmony_ci{ 21558c2ecf20Sopenharmony_ci adapter->nic_ops->config_ipaddr(adapter, ip, cmd); 21568c2ecf20Sopenharmony_ci} 21578c2ecf20Sopenharmony_ci 21588c2ecf20Sopenharmony_cistatic inline bool qlcnic_check_multi_tx(struct qlcnic_adapter *adapter) 21598c2ecf20Sopenharmony_ci{ 21608c2ecf20Sopenharmony_ci return test_bit(__QLCNIC_MULTI_TX_UNIQUE, &adapter->state); 21618c2ecf20Sopenharmony_ci} 21628c2ecf20Sopenharmony_ci 21638c2ecf20Sopenharmony_cistatic inline void 21648c2ecf20Sopenharmony_ciqlcnic_82xx_enable_tx_intr(struct qlcnic_adapter *adapter, 21658c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring) 21668c2ecf20Sopenharmony_ci{ 21678c2ecf20Sopenharmony_ci if (qlcnic_check_multi_tx(adapter) && 21688c2ecf20Sopenharmony_ci !adapter->ahw->diag_test) 21698c2ecf20Sopenharmony_ci writel(0x0, tx_ring->crb_intr_mask); 21708c2ecf20Sopenharmony_ci} 21718c2ecf20Sopenharmony_ci 21728c2ecf20Sopenharmony_cistatic inline void 21738c2ecf20Sopenharmony_ciqlcnic_82xx_disable_tx_intr(struct qlcnic_adapter *adapter, 21748c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring) 21758c2ecf20Sopenharmony_ci{ 21768c2ecf20Sopenharmony_ci if (qlcnic_check_multi_tx(adapter) && 21778c2ecf20Sopenharmony_ci !adapter->ahw->diag_test) 21788c2ecf20Sopenharmony_ci writel(1, tx_ring->crb_intr_mask); 21798c2ecf20Sopenharmony_ci} 21808c2ecf20Sopenharmony_ci 21818c2ecf20Sopenharmony_cistatic inline void 21828c2ecf20Sopenharmony_ciqlcnic_83xx_enable_tx_intr(struct qlcnic_adapter *adapter, 21838c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring) 21848c2ecf20Sopenharmony_ci{ 21858c2ecf20Sopenharmony_ci writel(0, tx_ring->crb_intr_mask); 21868c2ecf20Sopenharmony_ci} 21878c2ecf20Sopenharmony_ci 21888c2ecf20Sopenharmony_cistatic inline void 21898c2ecf20Sopenharmony_ciqlcnic_83xx_disable_tx_intr(struct qlcnic_adapter *adapter, 21908c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring) 21918c2ecf20Sopenharmony_ci{ 21928c2ecf20Sopenharmony_ci writel(1, tx_ring->crb_intr_mask); 21938c2ecf20Sopenharmony_ci} 21948c2ecf20Sopenharmony_ci 21958c2ecf20Sopenharmony_ci/* Enable MSI-x and INT-x interrupts */ 21968c2ecf20Sopenharmony_cistatic inline void 21978c2ecf20Sopenharmony_ciqlcnic_83xx_enable_sds_intr(struct qlcnic_adapter *adapter, 21988c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *sds_ring) 21998c2ecf20Sopenharmony_ci{ 22008c2ecf20Sopenharmony_ci writel(0, sds_ring->crb_intr_mask); 22018c2ecf20Sopenharmony_ci} 22028c2ecf20Sopenharmony_ci 22038c2ecf20Sopenharmony_ci/* Disable MSI-x and INT-x interrupts */ 22048c2ecf20Sopenharmony_cistatic inline void 22058c2ecf20Sopenharmony_ciqlcnic_83xx_disable_sds_intr(struct qlcnic_adapter *adapter, 22068c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *sds_ring) 22078c2ecf20Sopenharmony_ci{ 22088c2ecf20Sopenharmony_ci writel(1, sds_ring->crb_intr_mask); 22098c2ecf20Sopenharmony_ci} 22108c2ecf20Sopenharmony_ci 22118c2ecf20Sopenharmony_cistatic inline void qlcnic_disable_multi_tx(struct qlcnic_adapter *adapter) 22128c2ecf20Sopenharmony_ci{ 22138c2ecf20Sopenharmony_ci test_and_clear_bit(__QLCNIC_MULTI_TX_UNIQUE, &adapter->state); 22148c2ecf20Sopenharmony_ci adapter->drv_tx_rings = QLCNIC_SINGLE_RING; 22158c2ecf20Sopenharmony_ci} 22168c2ecf20Sopenharmony_ci 22178c2ecf20Sopenharmony_ci/* When operating in a muti tx mode, driver needs to write 0x1 22188c2ecf20Sopenharmony_ci * to src register, instead of 0x0 to disable receiving interrupt. 22198c2ecf20Sopenharmony_ci */ 22208c2ecf20Sopenharmony_cistatic inline void 22218c2ecf20Sopenharmony_ciqlcnic_82xx_disable_sds_intr(struct qlcnic_adapter *adapter, 22228c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *sds_ring) 22238c2ecf20Sopenharmony_ci{ 22248c2ecf20Sopenharmony_ci if (qlcnic_check_multi_tx(adapter) && 22258c2ecf20Sopenharmony_ci !adapter->ahw->diag_test && 22268c2ecf20Sopenharmony_ci (adapter->flags & QLCNIC_MSIX_ENABLED)) 22278c2ecf20Sopenharmony_ci writel(0x1, sds_ring->crb_intr_mask); 22288c2ecf20Sopenharmony_ci else 22298c2ecf20Sopenharmony_ci writel(0, sds_ring->crb_intr_mask); 22308c2ecf20Sopenharmony_ci} 22318c2ecf20Sopenharmony_ci 22328c2ecf20Sopenharmony_cistatic inline void qlcnic_enable_sds_intr(struct qlcnic_adapter *adapter, 22338c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *sds_ring) 22348c2ecf20Sopenharmony_ci{ 22358c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->enable_sds_intr) 22368c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->enable_sds_intr(adapter, sds_ring); 22378c2ecf20Sopenharmony_ci} 22388c2ecf20Sopenharmony_ci 22398c2ecf20Sopenharmony_cistatic inline void 22408c2ecf20Sopenharmony_ciqlcnic_disable_sds_intr(struct qlcnic_adapter *adapter, 22418c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *sds_ring) 22428c2ecf20Sopenharmony_ci{ 22438c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->disable_sds_intr) 22448c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->disable_sds_intr(adapter, sds_ring); 22458c2ecf20Sopenharmony_ci} 22468c2ecf20Sopenharmony_ci 22478c2ecf20Sopenharmony_cistatic inline void qlcnic_enable_tx_intr(struct qlcnic_adapter *adapter, 22488c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring) 22498c2ecf20Sopenharmony_ci{ 22508c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->enable_tx_intr) 22518c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->enable_tx_intr(adapter, tx_ring); 22528c2ecf20Sopenharmony_ci} 22538c2ecf20Sopenharmony_ci 22548c2ecf20Sopenharmony_cistatic inline void qlcnic_disable_tx_intr(struct qlcnic_adapter *adapter, 22558c2ecf20Sopenharmony_ci struct qlcnic_host_tx_ring *tx_ring) 22568c2ecf20Sopenharmony_ci{ 22578c2ecf20Sopenharmony_ci if (adapter->ahw->hw_ops->disable_tx_intr) 22588c2ecf20Sopenharmony_ci adapter->ahw->hw_ops->disable_tx_intr(adapter, tx_ring); 22598c2ecf20Sopenharmony_ci} 22608c2ecf20Sopenharmony_ci 22618c2ecf20Sopenharmony_ci/* When operating in a muti tx mode, driver needs to write 0x0 22628c2ecf20Sopenharmony_ci * to src register, instead of 0x1 to enable receiving interrupts. 22638c2ecf20Sopenharmony_ci */ 22648c2ecf20Sopenharmony_cistatic inline void 22658c2ecf20Sopenharmony_ciqlcnic_82xx_enable_sds_intr(struct qlcnic_adapter *adapter, 22668c2ecf20Sopenharmony_ci struct qlcnic_host_sds_ring *sds_ring) 22678c2ecf20Sopenharmony_ci{ 22688c2ecf20Sopenharmony_ci if (qlcnic_check_multi_tx(adapter) && 22698c2ecf20Sopenharmony_ci !adapter->ahw->diag_test && 22708c2ecf20Sopenharmony_ci (adapter->flags & QLCNIC_MSIX_ENABLED)) 22718c2ecf20Sopenharmony_ci writel(0, sds_ring->crb_intr_mask); 22728c2ecf20Sopenharmony_ci else 22738c2ecf20Sopenharmony_ci writel(0x1, sds_ring->crb_intr_mask); 22748c2ecf20Sopenharmony_ci 22758c2ecf20Sopenharmony_ci if (!QLCNIC_IS_MSI_FAMILY(adapter)) 22768c2ecf20Sopenharmony_ci writel(0xfbff, adapter->tgt_mask_reg); 22778c2ecf20Sopenharmony_ci} 22788c2ecf20Sopenharmony_ci 22798c2ecf20Sopenharmony_cistatic inline int qlcnic_get_diag_lock(struct qlcnic_adapter *adapter) 22808c2ecf20Sopenharmony_ci{ 22818c2ecf20Sopenharmony_ci return test_and_set_bit(__QLCNIC_DIAG_MODE, &adapter->state); 22828c2ecf20Sopenharmony_ci} 22838c2ecf20Sopenharmony_ci 22848c2ecf20Sopenharmony_cistatic inline void qlcnic_release_diag_lock(struct qlcnic_adapter *adapter) 22858c2ecf20Sopenharmony_ci{ 22868c2ecf20Sopenharmony_ci clear_bit(__QLCNIC_DIAG_MODE, &adapter->state); 22878c2ecf20Sopenharmony_ci} 22888c2ecf20Sopenharmony_ci 22898c2ecf20Sopenharmony_cistatic inline int qlcnic_check_diag_status(struct qlcnic_adapter *adapter) 22908c2ecf20Sopenharmony_ci{ 22918c2ecf20Sopenharmony_ci return test_bit(__QLCNIC_DIAG_MODE, &adapter->state); 22928c2ecf20Sopenharmony_ci} 22938c2ecf20Sopenharmony_ci 22948c2ecf20Sopenharmony_ciextern const struct ethtool_ops qlcnic_sriov_vf_ethtool_ops; 22958c2ecf20Sopenharmony_ciextern const struct ethtool_ops qlcnic_ethtool_ops; 22968c2ecf20Sopenharmony_ciextern const struct ethtool_ops qlcnic_ethtool_failed_ops; 22978c2ecf20Sopenharmony_ci 22988c2ecf20Sopenharmony_ci#define QLCDB(adapter, lvl, _fmt, _args...) do { \ 22998c2ecf20Sopenharmony_ci if (NETIF_MSG_##lvl & adapter->ahw->msg_enable) \ 23008c2ecf20Sopenharmony_ci printk(KERN_INFO "%s: %s: " _fmt, \ 23018c2ecf20Sopenharmony_ci dev_name(&adapter->pdev->dev), \ 23028c2ecf20Sopenharmony_ci __func__, ##_args); \ 23038c2ecf20Sopenharmony_ci } while (0) 23048c2ecf20Sopenharmony_ci 23058c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_QLE824X 0x8020 23068c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_QLE834X 0x8030 23078c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_VF_QLE834X 0x8430 23088c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_QLE8830 0x8830 23098c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_VF_QLE8C30 0x8C30 23108c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_QLE844X 0x8040 23118c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_VF_QLE844X 0x8440 23128c2ecf20Sopenharmony_ci 23138c2ecf20Sopenharmony_cistatic inline bool qlcnic_82xx_check(struct qlcnic_adapter *adapter) 23148c2ecf20Sopenharmony_ci{ 23158c2ecf20Sopenharmony_ci unsigned short device = adapter->pdev->device; 23168c2ecf20Sopenharmony_ci return (device == PCI_DEVICE_ID_QLOGIC_QLE824X) ? true : false; 23178c2ecf20Sopenharmony_ci} 23188c2ecf20Sopenharmony_ci 23198c2ecf20Sopenharmony_cistatic inline bool qlcnic_84xx_check(struct qlcnic_adapter *adapter) 23208c2ecf20Sopenharmony_ci{ 23218c2ecf20Sopenharmony_ci unsigned short device = adapter->pdev->device; 23228c2ecf20Sopenharmony_ci 23238c2ecf20Sopenharmony_ci return ((device == PCI_DEVICE_ID_QLOGIC_QLE844X) || 23248c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_VF_QLE844X)) ? true : false; 23258c2ecf20Sopenharmony_ci} 23268c2ecf20Sopenharmony_ci 23278c2ecf20Sopenharmony_cistatic inline bool qlcnic_83xx_check(struct qlcnic_adapter *adapter) 23288c2ecf20Sopenharmony_ci{ 23298c2ecf20Sopenharmony_ci unsigned short device = adapter->pdev->device; 23308c2ecf20Sopenharmony_ci bool status; 23318c2ecf20Sopenharmony_ci 23328c2ecf20Sopenharmony_ci status = ((device == PCI_DEVICE_ID_QLOGIC_QLE834X) || 23338c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_QLE8830) || 23348c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_QLE844X) || 23358c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_VF_QLE844X) || 23368c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X) || 23378c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_VF_QLE8C30)) ? true : false; 23388c2ecf20Sopenharmony_ci 23398c2ecf20Sopenharmony_ci return status; 23408c2ecf20Sopenharmony_ci} 23418c2ecf20Sopenharmony_ci 23428c2ecf20Sopenharmony_cistatic inline bool qlcnic_sriov_pf_check(struct qlcnic_adapter *adapter) 23438c2ecf20Sopenharmony_ci{ 23448c2ecf20Sopenharmony_ci return (adapter->ahw->op_mode == QLCNIC_SRIOV_PF_FUNC) ? true : false; 23458c2ecf20Sopenharmony_ci} 23468c2ecf20Sopenharmony_ci 23478c2ecf20Sopenharmony_cistatic inline bool qlcnic_sriov_vf_check(struct qlcnic_adapter *adapter) 23488c2ecf20Sopenharmony_ci{ 23498c2ecf20Sopenharmony_ci unsigned short device = adapter->pdev->device; 23508c2ecf20Sopenharmony_ci bool status; 23518c2ecf20Sopenharmony_ci 23528c2ecf20Sopenharmony_ci status = ((device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X) || 23538c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_VF_QLE844X) || 23548c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_VF_QLE8C30)) ? true : false; 23558c2ecf20Sopenharmony_ci 23568c2ecf20Sopenharmony_ci return status; 23578c2ecf20Sopenharmony_ci} 23588c2ecf20Sopenharmony_ci 23598c2ecf20Sopenharmony_cistatic inline bool qlcnic_83xx_pf_check(struct qlcnic_adapter *adapter) 23608c2ecf20Sopenharmony_ci{ 23618c2ecf20Sopenharmony_ci unsigned short device = adapter->pdev->device; 23628c2ecf20Sopenharmony_ci 23638c2ecf20Sopenharmony_ci return (device == PCI_DEVICE_ID_QLOGIC_QLE834X) ? true : false; 23648c2ecf20Sopenharmony_ci} 23658c2ecf20Sopenharmony_ci 23668c2ecf20Sopenharmony_cistatic inline bool qlcnic_83xx_vf_check(struct qlcnic_adapter *adapter) 23678c2ecf20Sopenharmony_ci{ 23688c2ecf20Sopenharmony_ci unsigned short device = adapter->pdev->device; 23698c2ecf20Sopenharmony_ci 23708c2ecf20Sopenharmony_ci return ((device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X) || 23718c2ecf20Sopenharmony_ci (device == PCI_DEVICE_ID_QLOGIC_VF_QLE8C30)) ? true : false; 23728c2ecf20Sopenharmony_ci} 23738c2ecf20Sopenharmony_ci 23748c2ecf20Sopenharmony_cistatic inline bool qlcnic_sriov_check(struct qlcnic_adapter *adapter) 23758c2ecf20Sopenharmony_ci{ 23768c2ecf20Sopenharmony_ci bool status; 23778c2ecf20Sopenharmony_ci 23788c2ecf20Sopenharmony_ci status = (qlcnic_sriov_pf_check(adapter) || 23798c2ecf20Sopenharmony_ci qlcnic_sriov_vf_check(adapter)) ? true : false; 23808c2ecf20Sopenharmony_ci 23818c2ecf20Sopenharmony_ci return status; 23828c2ecf20Sopenharmony_ci} 23838c2ecf20Sopenharmony_ci 23848c2ecf20Sopenharmony_cistatic inline u32 qlcnic_get_vnic_func_count(struct qlcnic_adapter *adapter) 23858c2ecf20Sopenharmony_ci{ 23868c2ecf20Sopenharmony_ci if (qlcnic_84xx_check(adapter)) 23878c2ecf20Sopenharmony_ci return QLC_84XX_VNIC_COUNT; 23888c2ecf20Sopenharmony_ci else 23898c2ecf20Sopenharmony_ci return QLC_DEFAULT_VNIC_COUNT; 23908c2ecf20Sopenharmony_ci} 23918c2ecf20Sopenharmony_ci 23928c2ecf20Sopenharmony_cistatic inline void qlcnic_swap32_buffer(u32 *buffer, int count) 23938c2ecf20Sopenharmony_ci{ 23948c2ecf20Sopenharmony_ci#if defined(__BIG_ENDIAN) 23958c2ecf20Sopenharmony_ci u32 *tmp = buffer; 23968c2ecf20Sopenharmony_ci int i; 23978c2ecf20Sopenharmony_ci 23988c2ecf20Sopenharmony_ci for (i = 0; i < count; i++) { 23998c2ecf20Sopenharmony_ci *tmp = swab32(*tmp); 24008c2ecf20Sopenharmony_ci tmp++; 24018c2ecf20Sopenharmony_ci } 24028c2ecf20Sopenharmony_ci#endif 24038c2ecf20Sopenharmony_ci} 24048c2ecf20Sopenharmony_ci 24058c2ecf20Sopenharmony_ci#ifdef CONFIG_QLCNIC_HWMON 24068c2ecf20Sopenharmony_civoid qlcnic_register_hwmon_dev(struct qlcnic_adapter *); 24078c2ecf20Sopenharmony_civoid qlcnic_unregister_hwmon_dev(struct qlcnic_adapter *); 24088c2ecf20Sopenharmony_ci#else 24098c2ecf20Sopenharmony_cistatic inline void qlcnic_register_hwmon_dev(struct qlcnic_adapter *adapter) 24108c2ecf20Sopenharmony_ci{ 24118c2ecf20Sopenharmony_ci return; 24128c2ecf20Sopenharmony_ci} 24138c2ecf20Sopenharmony_cistatic inline void qlcnic_unregister_hwmon_dev(struct qlcnic_adapter *adapter) 24148c2ecf20Sopenharmony_ci{ 24158c2ecf20Sopenharmony_ci return; 24168c2ecf20Sopenharmony_ci} 24178c2ecf20Sopenharmony_ci#endif 24188c2ecf20Sopenharmony_ci#endif /* __QLCNIC_H_ */ 2419