18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2003 - 2009 NetXen, Inc. 48c2ecf20Sopenharmony_ci * Copyright (C) 2009 - QLogic Corporation. 58c2ecf20Sopenharmony_ci * All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _NETXEN_NIC_H_ 98c2ecf20Sopenharmony_ci#define _NETXEN_NIC_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/module.h> 128c2ecf20Sopenharmony_ci#include <linux/kernel.h> 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci#include <linux/ioport.h> 158c2ecf20Sopenharmony_ci#include <linux/pci.h> 168c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 178c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 188c2ecf20Sopenharmony_ci#include <linux/ip.h> 198c2ecf20Sopenharmony_ci#include <linux/in.h> 208c2ecf20Sopenharmony_ci#include <linux/tcp.h> 218c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 228c2ecf20Sopenharmony_ci#include <linux/firmware.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 258c2ecf20Sopenharmony_ci#include <linux/mii.h> 268c2ecf20Sopenharmony_ci#include <linux/timer.h> 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include <asm/io.h> 318c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#include "netxen_nic_hdr.h" 348c2ecf20Sopenharmony_ci#include "netxen_nic_hw.h" 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define _NETXEN_NIC_LINUX_MAJOR 4 378c2ecf20Sopenharmony_ci#define _NETXEN_NIC_LINUX_MINOR 0 388c2ecf20Sopenharmony_ci#define _NETXEN_NIC_LINUX_SUBVERSION 82 398c2ecf20Sopenharmony_ci#define NETXEN_NIC_LINUX_VERSIONID "4.0.82" 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) 428c2ecf20Sopenharmony_ci#define _major(v) (((v) >> 24) & 0xff) 438c2ecf20Sopenharmony_ci#define _minor(v) (((v) >> 16) & 0xff) 448c2ecf20Sopenharmony_ci#define _build(v) ((v) & 0xffff) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* version in image has weird encoding: 478c2ecf20Sopenharmony_ci * 7:0 - major 488c2ecf20Sopenharmony_ci * 15:8 - minor 498c2ecf20Sopenharmony_ci * 31:16 - build (little endian) 508c2ecf20Sopenharmony_ci */ 518c2ecf20Sopenharmony_ci#define NETXEN_DECODE_VERSION(v) \ 528c2ecf20Sopenharmony_ci NETXEN_VERSION_CODE(((v) & 0xff), (((v) >> 8) & 0xff), ((v) >> 16)) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define NETXEN_NUM_FLASH_SECTORS (64) 558c2ecf20Sopenharmony_ci#define NETXEN_FLASH_SECTOR_SIZE (64 * 1024) 568c2ecf20Sopenharmony_ci#define NETXEN_FLASH_TOTAL_SIZE (NETXEN_NUM_FLASH_SECTORS \ 578c2ecf20Sopenharmony_ci * NETXEN_FLASH_SECTOR_SIZE) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define RCV_DESC_RINGSIZE(rds_ring) \ 608c2ecf20Sopenharmony_ci (sizeof(struct rcv_desc) * (rds_ring)->num_desc) 618c2ecf20Sopenharmony_ci#define RCV_BUFF_RINGSIZE(rds_ring) \ 628c2ecf20Sopenharmony_ci (sizeof(struct netxen_rx_buffer) * rds_ring->num_desc) 638c2ecf20Sopenharmony_ci#define STATUS_DESC_RINGSIZE(sds_ring) \ 648c2ecf20Sopenharmony_ci (sizeof(struct status_desc) * (sds_ring)->num_desc) 658c2ecf20Sopenharmony_ci#define TX_BUFF_RINGSIZE(tx_ring) \ 668c2ecf20Sopenharmony_ci (sizeof(struct netxen_cmd_buffer) * tx_ring->num_desc) 678c2ecf20Sopenharmony_ci#define TX_DESC_RINGSIZE(tx_ring) \ 688c2ecf20Sopenharmony_ci (sizeof(struct cmd_desc_type0) * tx_ring->num_desc) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define NETXEN_RCV_PRODUCER_OFFSET 0 738c2ecf20Sopenharmony_ci#define NETXEN_RCV_PEG_DB_ID 2 748c2ecf20Sopenharmony_ci#define NETXEN_HOST_DUMMY_DMA_SIZE 1024 758c2ecf20Sopenharmony_ci#define FLASH_SUCCESS 0 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define ADDR_IN_WINDOW1(off) \ 788c2ecf20Sopenharmony_ci ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define ADDR_IN_RANGE(addr, low, high) \ 818c2ecf20Sopenharmony_ci (((addr) < (high)) && ((addr) >= (low))) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* 848c2ecf20Sopenharmony_ci * normalize a 64MB crb address to 32MB PCI window 858c2ecf20Sopenharmony_ci * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 868c2ecf20Sopenharmony_ci */ 878c2ecf20Sopenharmony_ci#define NETXEN_CRB_NORMAL(reg) \ 888c2ecf20Sopenharmony_ci ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define NETXEN_CRB_NORMALIZE(adapter, reg) \ 918c2ecf20Sopenharmony_ci pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define DB_NORMALIZE(adapter, off) \ 948c2ecf20Sopenharmony_ci (adapter->ahw.db_base + (off)) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#define NX_P2_C0 0x24 978c2ecf20Sopenharmony_ci#define NX_P2_C1 0x25 988c2ecf20Sopenharmony_ci#define NX_P3_A0 0x30 998c2ecf20Sopenharmony_ci#define NX_P3_A2 0x30 1008c2ecf20Sopenharmony_ci#define NX_P3_B0 0x40 1018c2ecf20Sopenharmony_ci#define NX_P3_B1 0x41 1028c2ecf20Sopenharmony_ci#define NX_P3_B2 0x42 1038c2ecf20Sopenharmony_ci#define NX_P3P_A0 0x50 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#define NX_IS_REVISION_P2(REVISION) (REVISION <= NX_P2_C1) 1068c2ecf20Sopenharmony_ci#define NX_IS_REVISION_P3(REVISION) (REVISION >= NX_P3_A0) 1078c2ecf20Sopenharmony_ci#define NX_IS_REVISION_P3P(REVISION) (REVISION >= NX_P3P_A0) 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define FIRST_PAGE_GROUP_START 0 1108c2ecf20Sopenharmony_ci#define FIRST_PAGE_GROUP_END 0x100000 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci#define SECOND_PAGE_GROUP_START 0x6000000 1138c2ecf20Sopenharmony_ci#define SECOND_PAGE_GROUP_END 0x68BC000 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci#define THIRD_PAGE_GROUP_START 0x70E4000 1168c2ecf20Sopenharmony_ci#define THIRD_PAGE_GROUP_END 0x8000000 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#define FIRST_PAGE_GROUP_SIZE FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START 1198c2ecf20Sopenharmony_ci#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START 1208c2ecf20Sopenharmony_ci#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define P2_MAX_MTU (8000) 1238c2ecf20Sopenharmony_ci#define P3_MAX_MTU (9600) 1248c2ecf20Sopenharmony_ci#define NX_ETHERMTU 1500 1258c2ecf20Sopenharmony_ci#define NX_MAX_ETHERHDR 32 /* This contains some padding */ 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define NX_P2_RX_BUF_MAX_LEN 1760 1288c2ecf20Sopenharmony_ci#define NX_P3_RX_BUF_MAX_LEN (NX_MAX_ETHERHDR + NX_ETHERMTU) 1298c2ecf20Sopenharmony_ci#define NX_P2_RX_JUMBO_BUF_MAX_LEN (NX_MAX_ETHERHDR + P2_MAX_MTU) 1308c2ecf20Sopenharmony_ci#define NX_P3_RX_JUMBO_BUF_MAX_LEN (NX_MAX_ETHERHDR + P3_MAX_MTU) 1318c2ecf20Sopenharmony_ci#define NX_CT_DEFAULT_RX_BUF_LEN 2048 1328c2ecf20Sopenharmony_ci#define NX_LRO_BUFFER_EXTRA 2048 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define NX_RX_LRO_BUFFER_LENGTH (8060) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* 1378c2ecf20Sopenharmony_ci * Maximum number of ring contexts 1388c2ecf20Sopenharmony_ci */ 1398c2ecf20Sopenharmony_ci#define MAX_RING_CTX 1 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* Opcodes to be used with the commands */ 1428c2ecf20Sopenharmony_ci#define TX_ETHER_PKT 0x01 1438c2ecf20Sopenharmony_ci#define TX_TCP_PKT 0x02 1448c2ecf20Sopenharmony_ci#define TX_UDP_PKT 0x03 1458c2ecf20Sopenharmony_ci#define TX_IP_PKT 0x04 1468c2ecf20Sopenharmony_ci#define TX_TCP_LSO 0x05 1478c2ecf20Sopenharmony_ci#define TX_TCP_LSO6 0x06 1488c2ecf20Sopenharmony_ci#define TX_IPSEC 0x07 1498c2ecf20Sopenharmony_ci#define TX_IPSEC_CMD 0x0a 1508c2ecf20Sopenharmony_ci#define TX_TCPV6_PKT 0x0b 1518c2ecf20Sopenharmony_ci#define TX_UDPV6_PKT 0x0c 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci/* The following opcodes are for internal consumption. */ 1548c2ecf20Sopenharmony_ci#define NETXEN_CONTROL_OP 0x10 1558c2ecf20Sopenharmony_ci#define PEGNET_REQUEST 0x11 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#define MAX_NUM_CARDS 4 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#define NETXEN_MAX_FRAGS_PER_TX 14 1608c2ecf20Sopenharmony_ci#define MAX_TSO_HEADER_DESC 2 1618c2ecf20Sopenharmony_ci#define MGMT_CMD_DESC_RESV 4 1628c2ecf20Sopenharmony_ci#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ 1638c2ecf20Sopenharmony_ci + MGMT_CMD_DESC_RESV) 1648c2ecf20Sopenharmony_ci#define NX_MAX_TX_TIMEOUTS 2 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci/* 1678c2ecf20Sopenharmony_ci * Following are the states of the Phantom. Phantom will set them and 1688c2ecf20Sopenharmony_ci * Host will read to check if the fields are correct. 1698c2ecf20Sopenharmony_ci */ 1708c2ecf20Sopenharmony_ci#define PHAN_INITIALIZE_START 0xff00 1718c2ecf20Sopenharmony_ci#define PHAN_INITIALIZE_FAILED 0xffff 1728c2ecf20Sopenharmony_ci#define PHAN_INITIALIZE_COMPLETE 0xff01 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* Host writes the following to notify that it has done the init-handshake */ 1758c2ecf20Sopenharmony_ci#define PHAN_INITIALIZE_ACK 0xf00f 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci#define NUM_RCV_DESC_RINGS 3 1788c2ecf20Sopenharmony_ci#define NUM_STS_DESC_RINGS 4 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci#define RCV_RING_NORMAL 0 1818c2ecf20Sopenharmony_ci#define RCV_RING_JUMBO 1 1828c2ecf20Sopenharmony_ci#define RCV_RING_LRO 2 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci#define MIN_CMD_DESCRIPTORS 64 1858c2ecf20Sopenharmony_ci#define MIN_RCV_DESCRIPTORS 64 1868c2ecf20Sopenharmony_ci#define MIN_JUMBO_DESCRIPTORS 32 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci#define MAX_CMD_DESCRIPTORS 1024 1898c2ecf20Sopenharmony_ci#define MAX_RCV_DESCRIPTORS_1G 4096 1908c2ecf20Sopenharmony_ci#define MAX_RCV_DESCRIPTORS_10G 8192 1918c2ecf20Sopenharmony_ci#define MAX_JUMBO_RCV_DESCRIPTORS_1G 512 1928c2ecf20Sopenharmony_ci#define MAX_JUMBO_RCV_DESCRIPTORS_10G 1024 1938c2ecf20Sopenharmony_ci#define MAX_LRO_RCV_DESCRIPTORS 8 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci#define DEFAULT_RCV_DESCRIPTORS_1G 2048 1968c2ecf20Sopenharmony_ci#define DEFAULT_RCV_DESCRIPTORS_10G 4096 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#define NETXEN_CTX_SIGNATURE 0xdee0 1998c2ecf20Sopenharmony_ci#define NETXEN_CTX_SIGNATURE_V2 0x0002dee0 2008c2ecf20Sopenharmony_ci#define NETXEN_CTX_RESET 0xbad0 2018c2ecf20Sopenharmony_ci#define NETXEN_CTX_D3_RESET 0xacc0 2028c2ecf20Sopenharmony_ci#define NETXEN_RCV_PRODUCER(ringid) (ringid) 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci#define PHAN_PEG_RCV_INITIALIZED 0xff01 2058c2ecf20Sopenharmony_ci#define PHAN_PEG_RCV_START_INITIALIZE 0xff00 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci#define get_next_index(index, length) \ 2088c2ecf20Sopenharmony_ci (((index) + 1) & ((length) - 1)) 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci#define get_index_range(index,length,count) \ 2118c2ecf20Sopenharmony_ci (((index) + (count)) & ((length) - 1)) 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#define MPORT_SINGLE_FUNCTION_MODE 0x1111 2148c2ecf20Sopenharmony_ci#define MPORT_MULTI_FUNCTION_MODE 0x2222 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#define NX_MAX_PCI_FUNC 8 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci/* 2198c2ecf20Sopenharmony_ci * NetXen host-peg signal message structure 2208c2ecf20Sopenharmony_ci * 2218c2ecf20Sopenharmony_ci * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx 2228c2ecf20Sopenharmony_ci * Bit 2 : priv_id => must be 1 2238c2ecf20Sopenharmony_ci * Bit 3-17 : count => for doorbell 2248c2ecf20Sopenharmony_ci * Bit 18-27 : ctx_id => Context id 2258c2ecf20Sopenharmony_ci * Bit 28-31 : opcode 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_citypedef u32 netxen_ctx_msg; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#define netxen_set_msg_peg_id(config_word, val) \ 2318c2ecf20Sopenharmony_ci ((config_word) &= ~3, (config_word) |= val & 3) 2328c2ecf20Sopenharmony_ci#define netxen_set_msg_privid(config_word) \ 2338c2ecf20Sopenharmony_ci ((config_word) |= 1 << 2) 2348c2ecf20Sopenharmony_ci#define netxen_set_msg_count(config_word, val) \ 2358c2ecf20Sopenharmony_ci ((config_word) &= ~(0x7fff<<3), (config_word) |= (val & 0x7fff) << 3) 2368c2ecf20Sopenharmony_ci#define netxen_set_msg_ctxid(config_word, val) \ 2378c2ecf20Sopenharmony_ci ((config_word) &= ~(0x3ff<<18), (config_word) |= (val & 0x3ff) << 18) 2388c2ecf20Sopenharmony_ci#define netxen_set_msg_opcode(config_word, val) \ 2398c2ecf20Sopenharmony_ci ((config_word) &= ~(0xf<<28), (config_word) |= (val & 0xf) << 28) 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_cistruct netxen_rcv_ring { 2428c2ecf20Sopenharmony_ci __le64 addr; 2438c2ecf20Sopenharmony_ci __le32 size; 2448c2ecf20Sopenharmony_ci __le32 rsrvd; 2458c2ecf20Sopenharmony_ci}; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_cistruct netxen_sts_ring { 2488c2ecf20Sopenharmony_ci __le64 addr; 2498c2ecf20Sopenharmony_ci __le32 size; 2508c2ecf20Sopenharmony_ci __le16 msi_index; 2518c2ecf20Sopenharmony_ci __le16 rsvd; 2528c2ecf20Sopenharmony_ci} ; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_cistruct netxen_ring_ctx { 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci /* one command ring */ 2578c2ecf20Sopenharmony_ci __le64 cmd_consumer_offset; 2588c2ecf20Sopenharmony_ci __le64 cmd_ring_addr; 2598c2ecf20Sopenharmony_ci __le32 cmd_ring_size; 2608c2ecf20Sopenharmony_ci __le32 rsrvd; 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci /* three receive rings */ 2638c2ecf20Sopenharmony_ci struct netxen_rcv_ring rcv_rings[NUM_RCV_DESC_RINGS]; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci __le64 sts_ring_addr; 2668c2ecf20Sopenharmony_ci __le32 sts_ring_size; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci __le32 ctx_id; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci __le64 rsrvd_2[3]; 2718c2ecf20Sopenharmony_ci __le32 sts_ring_count; 2728c2ecf20Sopenharmony_ci __le32 rsrvd_3; 2738c2ecf20Sopenharmony_ci struct netxen_sts_ring sts_rings[NUM_STS_DESC_RINGS]; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci} __attribute__ ((aligned(64))); 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci/* 2788c2ecf20Sopenharmony_ci * Following data structures describe the descriptors that will be used. 2798c2ecf20Sopenharmony_ci * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when 2808c2ecf20Sopenharmony_ci * we are doing LSO (above the 1500 size packet) only. 2818c2ecf20Sopenharmony_ci */ 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci/* 2848c2ecf20Sopenharmony_ci * The size of reference handle been changed to 16 bits to pass the MSS fields 2858c2ecf20Sopenharmony_ci * for the LSO packet 2868c2ecf20Sopenharmony_ci */ 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci#define FLAGS_CHECKSUM_ENABLED 0x01 2898c2ecf20Sopenharmony_ci#define FLAGS_LSO_ENABLED 0x02 2908c2ecf20Sopenharmony_ci#define FLAGS_IPSEC_SA_ADD 0x04 2918c2ecf20Sopenharmony_ci#define FLAGS_IPSEC_SA_DELETE 0x08 2928c2ecf20Sopenharmony_ci#define FLAGS_VLAN_TAGGED 0x10 2938c2ecf20Sopenharmony_ci#define FLAGS_VLAN_OOB 0x40 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci#define netxen_set_tx_vlan_tci(cmd_desc, v) \ 2968c2ecf20Sopenharmony_ci (cmd_desc)->vlan_TCI = cpu_to_le16(v); 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci#define netxen_set_cmd_desc_port(cmd_desc, var) \ 2998c2ecf20Sopenharmony_ci ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) 3008c2ecf20Sopenharmony_ci#define netxen_set_cmd_desc_ctxid(cmd_desc, var) \ 3018c2ecf20Sopenharmony_ci ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0)) 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci#define netxen_set_tx_port(_desc, _port) \ 3048c2ecf20Sopenharmony_ci (_desc)->port_ctxid = ((_port) & 0xf) | (((_port) << 4) & 0xf0) 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci#define netxen_set_tx_flags_opcode(_desc, _flags, _opcode) \ 3078c2ecf20Sopenharmony_ci (_desc)->flags_opcode = \ 3088c2ecf20Sopenharmony_ci cpu_to_le16(((_flags) & 0x7f) | (((_opcode) & 0x3f) << 7)) 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci#define netxen_set_tx_frags_len(_desc, _frags, _len) \ 3118c2ecf20Sopenharmony_ci (_desc)->nfrags__length = \ 3128c2ecf20Sopenharmony_ci cpu_to_le32(((_frags) & 0xff) | (((_len) & 0xffffff) << 8)) 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_cistruct cmd_desc_type0 { 3158c2ecf20Sopenharmony_ci u8 tcp_hdr_offset; /* For LSO only */ 3168c2ecf20Sopenharmony_ci u8 ip_hdr_offset; /* For LSO only */ 3178c2ecf20Sopenharmony_ci __le16 flags_opcode; /* 15:13 unused, 12:7 opcode, 6:0 flags */ 3188c2ecf20Sopenharmony_ci __le32 nfrags__length; /* 31:8 total len, 7:0 frag count */ 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci __le64 addr_buffer2; 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci __le16 reference_handle; 3238c2ecf20Sopenharmony_ci __le16 mss; 3248c2ecf20Sopenharmony_ci u8 port_ctxid; /* 7:4 ctxid 3:0 port */ 3258c2ecf20Sopenharmony_ci u8 total_hdr_length; /* LSO only : MAC+IP+TCP Hdr size */ 3268c2ecf20Sopenharmony_ci __le16 conn_id; /* IPSec offoad only */ 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci __le64 addr_buffer3; 3298c2ecf20Sopenharmony_ci __le64 addr_buffer1; 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci __le16 buffer_length[4]; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci __le64 addr_buffer4; 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci __le32 reserved2; 3368c2ecf20Sopenharmony_ci __le16 reserved; 3378c2ecf20Sopenharmony_ci __le16 vlan_TCI; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci} __attribute__ ((aligned(64))); 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci/* Note: sizeof(rcv_desc) should always be a multiple of 2 */ 3428c2ecf20Sopenharmony_cistruct rcv_desc { 3438c2ecf20Sopenharmony_ci __le16 reference_handle; 3448c2ecf20Sopenharmony_ci __le16 reserved; 3458c2ecf20Sopenharmony_ci __le32 buffer_length; /* allocated buffer length (usually 2K) */ 3468c2ecf20Sopenharmony_ci __le64 addr_buffer; 3478c2ecf20Sopenharmony_ci}; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci/* opcode field in status_desc */ 3508c2ecf20Sopenharmony_ci#define NETXEN_NIC_SYN_OFFLOAD 0x03 3518c2ecf20Sopenharmony_ci#define NETXEN_NIC_RXPKT_DESC 0x04 3528c2ecf20Sopenharmony_ci#define NETXEN_OLD_RXPKT_DESC 0x3f 3538c2ecf20Sopenharmony_ci#define NETXEN_NIC_RESPONSE_DESC 0x05 3548c2ecf20Sopenharmony_ci#define NETXEN_NIC_LRO_DESC 0x12 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci/* for status field in status_desc */ 3578c2ecf20Sopenharmony_ci#define STATUS_NEED_CKSUM (1) 3588c2ecf20Sopenharmony_ci#define STATUS_CKSUM_OK (2) 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci/* owner bits of status_desc */ 3618c2ecf20Sopenharmony_ci#define STATUS_OWNER_HOST (0x1ULL << 56) 3628c2ecf20Sopenharmony_ci#define STATUS_OWNER_PHANTOM (0x2ULL << 56) 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci/* Status descriptor: 3658c2ecf20Sopenharmony_ci 0-3 port, 4-7 status, 8-11 type, 12-27 total_length 3668c2ecf20Sopenharmony_ci 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset 3678c2ecf20Sopenharmony_ci 53-55 desc_cnt, 56-57 owner, 58-63 opcode 3688c2ecf20Sopenharmony_ci */ 3698c2ecf20Sopenharmony_ci#define netxen_get_sts_port(sts_data) \ 3708c2ecf20Sopenharmony_ci ((sts_data) & 0x0F) 3718c2ecf20Sopenharmony_ci#define netxen_get_sts_status(sts_data) \ 3728c2ecf20Sopenharmony_ci (((sts_data) >> 4) & 0x0F) 3738c2ecf20Sopenharmony_ci#define netxen_get_sts_type(sts_data) \ 3748c2ecf20Sopenharmony_ci (((sts_data) >> 8) & 0x0F) 3758c2ecf20Sopenharmony_ci#define netxen_get_sts_totallength(sts_data) \ 3768c2ecf20Sopenharmony_ci (((sts_data) >> 12) & 0xFFFF) 3778c2ecf20Sopenharmony_ci#define netxen_get_sts_refhandle(sts_data) \ 3788c2ecf20Sopenharmony_ci (((sts_data) >> 28) & 0xFFFF) 3798c2ecf20Sopenharmony_ci#define netxen_get_sts_prot(sts_data) \ 3808c2ecf20Sopenharmony_ci (((sts_data) >> 44) & 0x0F) 3818c2ecf20Sopenharmony_ci#define netxen_get_sts_pkt_offset(sts_data) \ 3828c2ecf20Sopenharmony_ci (((sts_data) >> 48) & 0x1F) 3838c2ecf20Sopenharmony_ci#define netxen_get_sts_desc_cnt(sts_data) \ 3848c2ecf20Sopenharmony_ci (((sts_data) >> 53) & 0x7) 3858c2ecf20Sopenharmony_ci#define netxen_get_sts_opcode(sts_data) \ 3868c2ecf20Sopenharmony_ci (((sts_data) >> 58) & 0x03F) 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_refhandle(sts_data) \ 3898c2ecf20Sopenharmony_ci ((sts_data) & 0x0FFFF) 3908c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_length(sts_data) \ 3918c2ecf20Sopenharmony_ci (((sts_data) >> 16) & 0x0FFFF) 3928c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_l2_hdr_offset(sts_data) \ 3938c2ecf20Sopenharmony_ci (((sts_data) >> 32) & 0x0FF) 3948c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_l4_hdr_offset(sts_data) \ 3958c2ecf20Sopenharmony_ci (((sts_data) >> 40) & 0x0FF) 3968c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_timestamp(sts_data) \ 3978c2ecf20Sopenharmony_ci (((sts_data) >> 48) & 0x1) 3988c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_type(sts_data) \ 3998c2ecf20Sopenharmony_ci (((sts_data) >> 49) & 0x7) 4008c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_push_flag(sts_data) \ 4018c2ecf20Sopenharmony_ci (((sts_data) >> 52) & 0x1) 4028c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_seq_number(sts_data) \ 4038c2ecf20Sopenharmony_ci ((sts_data) & 0x0FFFFFFFF) 4048c2ecf20Sopenharmony_ci#define netxen_get_lro_sts_mss(sts_data1) \ 4058c2ecf20Sopenharmony_ci ((sts_data1 >> 32) & 0x0FFFF) 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_cistruct status_desc { 4098c2ecf20Sopenharmony_ci __le64 status_desc_data[2]; 4108c2ecf20Sopenharmony_ci} __attribute__ ((aligned(16))); 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci/* UNIFIED ROMIMAGE *************************/ 4138c2ecf20Sopenharmony_ci#define NX_UNI_DIR_SECT_PRODUCT_TBL 0x0 4148c2ecf20Sopenharmony_ci#define NX_UNI_DIR_SECT_BOOTLD 0x6 4158c2ecf20Sopenharmony_ci#define NX_UNI_DIR_SECT_FW 0x7 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci/*Offsets */ 4188c2ecf20Sopenharmony_ci#define NX_UNI_CHIP_REV_OFF 10 4198c2ecf20Sopenharmony_ci#define NX_UNI_FLAGS_OFF 11 4208c2ecf20Sopenharmony_ci#define NX_UNI_BIOS_VERSION_OFF 12 4218c2ecf20Sopenharmony_ci#define NX_UNI_BOOTLD_IDX_OFF 27 4228c2ecf20Sopenharmony_ci#define NX_UNI_FIRMWARE_IDX_OFF 29 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_cistruct uni_table_desc{ 4258c2ecf20Sopenharmony_ci uint32_t findex; 4268c2ecf20Sopenharmony_ci uint32_t num_entries; 4278c2ecf20Sopenharmony_ci uint32_t entry_size; 4288c2ecf20Sopenharmony_ci uint32_t reserved[5]; 4298c2ecf20Sopenharmony_ci}; 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_cistruct uni_data_desc{ 4328c2ecf20Sopenharmony_ci uint32_t findex; 4338c2ecf20Sopenharmony_ci uint32_t size; 4348c2ecf20Sopenharmony_ci uint32_t reserved[5]; 4358c2ecf20Sopenharmony_ci}; 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci/* UNIFIED ROMIMAGE *************************/ 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci/* The version of the main data structure */ 4408c2ecf20Sopenharmony_ci#define NETXEN_BDINFO_VERSION 1 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_ci/* Magic number to let user know flash is programmed */ 4438c2ecf20Sopenharmony_ci#define NETXEN_BDINFO_MAGIC 0x12345678 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci/* Max number of Gig ports on a Phantom board */ 4468c2ecf20Sopenharmony_ci#define NETXEN_MAX_PORTS 4 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P1_BD 0x0000 4498c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P1_SB 0x0001 4508c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P1_SMAX 0x0002 4518c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P1_SOCK 0x0003 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SOCK_31 0x0008 4548c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SOCK_35 0x0009 4558c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SB35_4G 0x000a 4568c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SB31_10G 0x000b 4578c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SB31_2G 0x000c 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SB31_10G_IMEZ 0x000d 4608c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SB31_10G_HMEZ 0x000e 4618c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P2_SB31_10G_CX4 0x000f 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_REF_QG 0x0021 4648c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_HMEZ 0x0022 4658c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10G_CX4_LP 0x0023 4668c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_4_GB 0x0024 4678c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_IMEZ 0x0025 4688c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10G_SFP_PLUS 0x0026 4698c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10000_BASE_T 0x0027 4708c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_XG_LOM 0x0028 4718c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_4_GB_MM 0x0029 4728c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10G_SFP_CT 0x002a 4738c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10G_SFP_QT 0x002b 4748c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10G_CX4 0x0031 4758c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10G_XFP 0x0032 4768c2ecf20Sopenharmony_ci#define NETXEN_BRDTYPE_P3_10G_TP 0x0080 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci/* Flash memory map */ 4798c2ecf20Sopenharmony_ci#define NETXEN_CRBINIT_START 0 /* crbinit section */ 4808c2ecf20Sopenharmony_ci#define NETXEN_BRDCFG_START 0x4000 /* board config */ 4818c2ecf20Sopenharmony_ci#define NETXEN_INITCODE_START 0x6000 /* pegtune code */ 4828c2ecf20Sopenharmony_ci#define NETXEN_BOOTLD_START 0x10000 /* bootld */ 4838c2ecf20Sopenharmony_ci#define NETXEN_IMAGE_START 0x43000 /* compressed image */ 4848c2ecf20Sopenharmony_ci#define NETXEN_SECONDARY_START 0x200000 /* backup images */ 4858c2ecf20Sopenharmony_ci#define NETXEN_PXE_START 0x3E0000 /* PXE boot rom */ 4868c2ecf20Sopenharmony_ci#define NETXEN_USER_START 0x3E8000 /* Firmware info */ 4878c2ecf20Sopenharmony_ci#define NETXEN_FIXED_START 0x3F0000 /* backup of crbinit */ 4888c2ecf20Sopenharmony_ci#define NETXEN_USER_START_OLD NETXEN_PXE_START /* very old flash */ 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci#define NX_OLD_MAC_ADDR_OFFSET (NETXEN_USER_START) 4918c2ecf20Sopenharmony_ci#define NX_FW_VERSION_OFFSET (NETXEN_USER_START+0x408) 4928c2ecf20Sopenharmony_ci#define NX_FW_SIZE_OFFSET (NETXEN_USER_START+0x40c) 4938c2ecf20Sopenharmony_ci#define NX_FW_MAC_ADDR_OFFSET (NETXEN_USER_START+0x418) 4948c2ecf20Sopenharmony_ci#define NX_FW_SERIAL_NUM_OFFSET (NETXEN_USER_START+0x81c) 4958c2ecf20Sopenharmony_ci#define NX_BIOS_VERSION_OFFSET (NETXEN_USER_START+0x83c) 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci#define NX_HDR_VERSION_OFFSET (NETXEN_BRDCFG_START) 4988c2ecf20Sopenharmony_ci#define NX_BRDTYPE_OFFSET (NETXEN_BRDCFG_START+0x8) 4998c2ecf20Sopenharmony_ci#define NX_FW_MAGIC_OFFSET (NETXEN_BRDCFG_START+0x128) 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci#define NX_FW_MIN_SIZE (0x3fffff) 5028c2ecf20Sopenharmony_ci#define NX_P2_MN_ROMIMAGE 0 5038c2ecf20Sopenharmony_ci#define NX_P3_CT_ROMIMAGE 1 5048c2ecf20Sopenharmony_ci#define NX_P3_MN_ROMIMAGE 2 5058c2ecf20Sopenharmony_ci#define NX_UNIFIED_ROMIMAGE 3 5068c2ecf20Sopenharmony_ci#define NX_FLASH_ROMIMAGE 4 5078c2ecf20Sopenharmony_ci#define NX_UNKNOWN_ROMIMAGE 0xff 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci#define NX_P2_MN_ROMIMAGE_NAME "nxromimg.bin" 5108c2ecf20Sopenharmony_ci#define NX_P3_CT_ROMIMAGE_NAME "nx3fwct.bin" 5118c2ecf20Sopenharmony_ci#define NX_P3_MN_ROMIMAGE_NAME "nx3fwmn.bin" 5128c2ecf20Sopenharmony_ci#define NX_UNIFIED_ROMIMAGE_NAME "phanfw.bin" 5138c2ecf20Sopenharmony_ci#define NX_FLASH_ROMIMAGE_NAME "flash" 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ciextern char netxen_nic_driver_name[]; 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ci/* Number of status descriptors to handle per interrupt */ 5188c2ecf20Sopenharmony_ci#define MAX_STATUS_HANDLE (64) 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci/* 5218c2ecf20Sopenharmony_ci * netxen_skb_frag{} is to contain mapping info for each SG list. This 5228c2ecf20Sopenharmony_ci * has to be freed when DMA is complete. This is part of netxen_tx_buffer{}. 5238c2ecf20Sopenharmony_ci */ 5248c2ecf20Sopenharmony_cistruct netxen_skb_frag { 5258c2ecf20Sopenharmony_ci u64 dma; 5268c2ecf20Sopenharmony_ci u64 length; 5278c2ecf20Sopenharmony_ci}; 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_cistruct netxen_recv_crb { 5308c2ecf20Sopenharmony_ci u32 crb_rcv_producer[NUM_RCV_DESC_RINGS]; 5318c2ecf20Sopenharmony_ci u32 crb_sts_consumer[NUM_STS_DESC_RINGS]; 5328c2ecf20Sopenharmony_ci u32 sw_int_mask[NUM_STS_DESC_RINGS]; 5338c2ecf20Sopenharmony_ci}; 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci/* Following defines are for the state of the buffers */ 5368c2ecf20Sopenharmony_ci#define NETXEN_BUFFER_FREE 0 5378c2ecf20Sopenharmony_ci#define NETXEN_BUFFER_BUSY 1 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci/* 5408c2ecf20Sopenharmony_ci * There will be one netxen_buffer per skb packet. These will be 5418c2ecf20Sopenharmony_ci * used to save the dma info for pci_unmap_page() 5428c2ecf20Sopenharmony_ci */ 5438c2ecf20Sopenharmony_cistruct netxen_cmd_buffer { 5448c2ecf20Sopenharmony_ci struct sk_buff *skb; 5458c2ecf20Sopenharmony_ci struct netxen_skb_frag frag_array[MAX_SKB_FRAGS + 1]; 5468c2ecf20Sopenharmony_ci u32 frag_count; 5478c2ecf20Sopenharmony_ci}; 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci/* In rx_buffer, we do not need multiple fragments as is a single buffer */ 5508c2ecf20Sopenharmony_cistruct netxen_rx_buffer { 5518c2ecf20Sopenharmony_ci struct list_head list; 5528c2ecf20Sopenharmony_ci struct sk_buff *skb; 5538c2ecf20Sopenharmony_ci u64 dma; 5548c2ecf20Sopenharmony_ci u16 ref_handle; 5558c2ecf20Sopenharmony_ci u16 state; 5568c2ecf20Sopenharmony_ci}; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci/* Board types */ 5598c2ecf20Sopenharmony_ci#define NETXEN_NIC_GBE 0x01 5608c2ecf20Sopenharmony_ci#define NETXEN_NIC_XGBE 0x02 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci/* 5638c2ecf20Sopenharmony_ci * One hardware_context{} per adapter 5648c2ecf20Sopenharmony_ci * contains interrupt info as well shared hardware info. 5658c2ecf20Sopenharmony_ci */ 5668c2ecf20Sopenharmony_cistruct netxen_hardware_context { 5678c2ecf20Sopenharmony_ci void __iomem *pci_base0; 5688c2ecf20Sopenharmony_ci void __iomem *pci_base1; 5698c2ecf20Sopenharmony_ci void __iomem *pci_base2; 5708c2ecf20Sopenharmony_ci void __iomem *db_base; 5718c2ecf20Sopenharmony_ci void __iomem *ocm_win_crb; 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci unsigned long db_len; 5748c2ecf20Sopenharmony_ci unsigned long pci_len0; 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci u32 ocm_win; 5778c2ecf20Sopenharmony_ci u32 crb_win; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci rwlock_t crb_lock; 5808c2ecf20Sopenharmony_ci spinlock_t mem_lock; 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci u8 cut_through; 5838c2ecf20Sopenharmony_ci u8 revision_id; 5848c2ecf20Sopenharmony_ci u8 pci_func; 5858c2ecf20Sopenharmony_ci u8 linkup; 5868c2ecf20Sopenharmony_ci u16 port_type; 5878c2ecf20Sopenharmony_ci u16 board_type; 5888c2ecf20Sopenharmony_ci}; 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ 5918c2ecf20Sopenharmony_ci#define ETHERNET_FCS_SIZE 4 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_cistruct netxen_adapter_stats { 5948c2ecf20Sopenharmony_ci u64 xmitcalled; 5958c2ecf20Sopenharmony_ci u64 xmitfinished; 5968c2ecf20Sopenharmony_ci u64 rxdropped; 5978c2ecf20Sopenharmony_ci u64 txdropped; 5988c2ecf20Sopenharmony_ci u64 csummed; 5998c2ecf20Sopenharmony_ci u64 rx_pkts; 6008c2ecf20Sopenharmony_ci u64 lro_pkts; 6018c2ecf20Sopenharmony_ci u64 rxbytes; 6028c2ecf20Sopenharmony_ci u64 txbytes; 6038c2ecf20Sopenharmony_ci}; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci/* 6068c2ecf20Sopenharmony_ci * Rcv Descriptor Context. One such per Rcv Descriptor. There may 6078c2ecf20Sopenharmony_ci * be one Rcv Descriptor for normal packets, one for jumbo and may be others. 6088c2ecf20Sopenharmony_ci */ 6098c2ecf20Sopenharmony_cistruct nx_host_rds_ring { 6108c2ecf20Sopenharmony_ci u32 producer; 6118c2ecf20Sopenharmony_ci u32 num_desc; 6128c2ecf20Sopenharmony_ci u32 dma_size; 6138c2ecf20Sopenharmony_ci u32 skb_size; 6148c2ecf20Sopenharmony_ci u32 flags; 6158c2ecf20Sopenharmony_ci void __iomem *crb_rcv_producer; 6168c2ecf20Sopenharmony_ci struct rcv_desc *desc_head; 6178c2ecf20Sopenharmony_ci struct netxen_rx_buffer *rx_buf_arr; 6188c2ecf20Sopenharmony_ci struct list_head free_list; 6198c2ecf20Sopenharmony_ci spinlock_t lock; 6208c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 6218c2ecf20Sopenharmony_ci}; 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_cistruct nx_host_sds_ring { 6248c2ecf20Sopenharmony_ci u32 consumer; 6258c2ecf20Sopenharmony_ci u32 num_desc; 6268c2ecf20Sopenharmony_ci void __iomem *crb_sts_consumer; 6278c2ecf20Sopenharmony_ci void __iomem *crb_intr_mask; 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci struct status_desc *desc_head; 6308c2ecf20Sopenharmony_ci struct netxen_adapter *adapter; 6318c2ecf20Sopenharmony_ci struct napi_struct napi; 6328c2ecf20Sopenharmony_ci struct list_head free_list[NUM_RCV_DESC_RINGS]; 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_ci int irq; 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 6378c2ecf20Sopenharmony_ci char name[IFNAMSIZ+4]; 6388c2ecf20Sopenharmony_ci}; 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_cistruct nx_host_tx_ring { 6418c2ecf20Sopenharmony_ci u32 producer; 6428c2ecf20Sopenharmony_ci __le32 *hw_consumer; 6438c2ecf20Sopenharmony_ci u32 sw_consumer; 6448c2ecf20Sopenharmony_ci void __iomem *crb_cmd_producer; 6458c2ecf20Sopenharmony_ci void __iomem *crb_cmd_consumer; 6468c2ecf20Sopenharmony_ci u32 num_desc; 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci struct netdev_queue *txq; 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ci struct netxen_cmd_buffer *cmd_buf_arr; 6518c2ecf20Sopenharmony_ci struct cmd_desc_type0 *desc_head; 6528c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 6538c2ecf20Sopenharmony_ci}; 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci/* 6568c2ecf20Sopenharmony_ci * Receive context. There is one such structure per instance of the 6578c2ecf20Sopenharmony_ci * receive processing. Any state information that is relevant to 6588c2ecf20Sopenharmony_ci * the receive, and is must be in this structure. The global data may be 6598c2ecf20Sopenharmony_ci * present elsewhere. 6608c2ecf20Sopenharmony_ci */ 6618c2ecf20Sopenharmony_cistruct netxen_recv_context { 6628c2ecf20Sopenharmony_ci u32 state; 6638c2ecf20Sopenharmony_ci u16 context_id; 6648c2ecf20Sopenharmony_ci u16 virt_port; 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_ci struct nx_host_rds_ring *rds_rings; 6678c2ecf20Sopenharmony_ci struct nx_host_sds_ring *sds_rings; 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci struct netxen_ring_ctx *hwctx; 6708c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 6718c2ecf20Sopenharmony_ci}; 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_cistruct _cdrp_cmd { 6748c2ecf20Sopenharmony_ci u32 cmd; 6758c2ecf20Sopenharmony_ci u32 arg1; 6768c2ecf20Sopenharmony_ci u32 arg2; 6778c2ecf20Sopenharmony_ci u32 arg3; 6788c2ecf20Sopenharmony_ci}; 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_cistruct netxen_cmd_args { 6818c2ecf20Sopenharmony_ci struct _cdrp_cmd req; 6828c2ecf20Sopenharmony_ci struct _cdrp_cmd rsp; 6838c2ecf20Sopenharmony_ci}; 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci/* New HW context creation */ 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci#define NX_OS_CRB_RETRY_COUNT 4000 6888c2ecf20Sopenharmony_ci#define NX_CDRP_SIGNATURE_MAKE(pcifn, version) \ 6898c2ecf20Sopenharmony_ci (((pcifn) & 0xff) | (((version) & 0xff) << 8) | (0xcafe << 16)) 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci#define NX_CDRP_CLEAR 0x00000000 6928c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_BIT 0x80000000 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci/* 6958c2ecf20Sopenharmony_ci * All responses must have the NX_CDRP_CMD_BIT cleared 6968c2ecf20Sopenharmony_ci * in the crb NX_CDRP_CRB_OFFSET. 6978c2ecf20Sopenharmony_ci */ 6988c2ecf20Sopenharmony_ci#define NX_CDRP_FORM_RSP(rsp) (rsp) 6998c2ecf20Sopenharmony_ci#define NX_CDRP_IS_RSP(rsp) (((rsp) & NX_CDRP_CMD_BIT) == 0) 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ci#define NX_CDRP_RSP_OK 0x00000001 7028c2ecf20Sopenharmony_ci#define NX_CDRP_RSP_FAIL 0x00000002 7038c2ecf20Sopenharmony_ci#define NX_CDRP_RSP_TIMEOUT 0x00000003 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci/* 7068c2ecf20Sopenharmony_ci * All commands must have the NX_CDRP_CMD_BIT set in 7078c2ecf20Sopenharmony_ci * the crb NX_CDRP_CRB_OFFSET. 7088c2ecf20Sopenharmony_ci */ 7098c2ecf20Sopenharmony_ci#define NX_CDRP_FORM_CMD(cmd) (NX_CDRP_CMD_BIT | (cmd)) 7108c2ecf20Sopenharmony_ci#define NX_CDRP_IS_CMD(cmd) (((cmd) & NX_CDRP_CMD_BIT) != 0) 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_SUBMIT_CAPABILITIES 0x00000001 7138c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_RDS_PER_CTX 0x00000002 7148c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_SDS_PER_CTX 0x00000003 7158c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_RULES_PER_CTX 0x00000004 7168c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_RX_CTX 0x00000005 7178c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_TX_CTX 0x00000006 7188c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_CREATE_RX_CTX 0x00000007 7198c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_DESTROY_RX_CTX 0x00000008 7208c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_CREATE_TX_CTX 0x00000009 7218c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_DESTROY_TX_CTX 0x0000000a 7228c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_SETUP_STATISTICS 0x0000000e 7238c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_GET_STATISTICS 0x0000000f 7248c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_DELETE_STATISTICS 0x00000010 7258c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_SET_MTU 0x00000012 7268c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_PHY 0x00000013 7278c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_WRITE_PHY 0x00000014 7288c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_HW_REG 0x00000015 7298c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_GET_FLOW_CTL 0x00000016 7308c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_SET_FLOW_CTL 0x00000017 7318c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_MTU 0x00000018 7328c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_LRO 0x00000019 7338c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_CONFIGURE_TOE 0x0000001a 7348c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_FUNC_ATTRIB 0x0000001b 7358c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_PEXQ_PARAMETERS 0x0000001c 7368c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_GET_LIC_CAPABILITIES 0x0000001d 7378c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_READ_MAX_LRO_PER_BOARD 0x0000001e 7388c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_CONFIG_GBE_PORT 0x0000001f 7398c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_MAX 0x00000020 7408c2ecf20Sopenharmony_ci 7418c2ecf20Sopenharmony_ci#define NX_RCODE_SUCCESS 0 7428c2ecf20Sopenharmony_ci#define NX_RCODE_NO_HOST_MEM 1 7438c2ecf20Sopenharmony_ci#define NX_RCODE_NO_HOST_RESOURCE 2 7448c2ecf20Sopenharmony_ci#define NX_RCODE_NO_CARD_CRB 3 7458c2ecf20Sopenharmony_ci#define NX_RCODE_NO_CARD_MEM 4 7468c2ecf20Sopenharmony_ci#define NX_RCODE_NO_CARD_RESOURCE 5 7478c2ecf20Sopenharmony_ci#define NX_RCODE_INVALID_ARGS 6 7488c2ecf20Sopenharmony_ci#define NX_RCODE_INVALID_ACTION 7 7498c2ecf20Sopenharmony_ci#define NX_RCODE_INVALID_STATE 8 7508c2ecf20Sopenharmony_ci#define NX_RCODE_NOT_SUPPORTED 9 7518c2ecf20Sopenharmony_ci#define NX_RCODE_NOT_PERMITTED 10 7528c2ecf20Sopenharmony_ci#define NX_RCODE_NOT_READY 11 7538c2ecf20Sopenharmony_ci#define NX_RCODE_DOES_NOT_EXIST 12 7548c2ecf20Sopenharmony_ci#define NX_RCODE_ALREADY_EXISTS 13 7558c2ecf20Sopenharmony_ci#define NX_RCODE_BAD_SIGNATURE 14 7568c2ecf20Sopenharmony_ci#define NX_RCODE_CMD_NOT_IMPL 15 7578c2ecf20Sopenharmony_ci#define NX_RCODE_CMD_INVALID 16 7588c2ecf20Sopenharmony_ci#define NX_RCODE_TIMEOUT 17 7598c2ecf20Sopenharmony_ci#define NX_RCODE_CMD_FAILED 18 7608c2ecf20Sopenharmony_ci#define NX_RCODE_MAX_EXCEEDED 19 7618c2ecf20Sopenharmony_ci#define NX_RCODE_MAX 20 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci#define NX_DESTROY_CTX_RESET 0 7648c2ecf20Sopenharmony_ci#define NX_DESTROY_CTX_D3_RESET 1 7658c2ecf20Sopenharmony_ci#define NX_DESTROY_CTX_MAX 2 7668c2ecf20Sopenharmony_ci 7678c2ecf20Sopenharmony_ci/* 7688c2ecf20Sopenharmony_ci * Capabilities 7698c2ecf20Sopenharmony_ci */ 7708c2ecf20Sopenharmony_ci#define NX_CAP_BIT(class, bit) (1 << bit) 7718c2ecf20Sopenharmony_ci#define NX_CAP0_LEGACY_CONTEXT NX_CAP_BIT(0, 0) 7728c2ecf20Sopenharmony_ci#define NX_CAP0_MULTI_CONTEXT NX_CAP_BIT(0, 1) 7738c2ecf20Sopenharmony_ci#define NX_CAP0_LEGACY_MN NX_CAP_BIT(0, 2) 7748c2ecf20Sopenharmony_ci#define NX_CAP0_LEGACY_MS NX_CAP_BIT(0, 3) 7758c2ecf20Sopenharmony_ci#define NX_CAP0_CUT_THROUGH NX_CAP_BIT(0, 4) 7768c2ecf20Sopenharmony_ci#define NX_CAP0_LRO NX_CAP_BIT(0, 5) 7778c2ecf20Sopenharmony_ci#define NX_CAP0_LSO NX_CAP_BIT(0, 6) 7788c2ecf20Sopenharmony_ci#define NX_CAP0_JUMBO_CONTIGUOUS NX_CAP_BIT(0, 7) 7798c2ecf20Sopenharmony_ci#define NX_CAP0_LRO_CONTIGUOUS NX_CAP_BIT(0, 8) 7808c2ecf20Sopenharmony_ci#define NX_CAP0_HW_LRO NX_CAP_BIT(0, 10) 7818c2ecf20Sopenharmony_ci#define NX_CAP0_HW_LRO_MSS NX_CAP_BIT(0, 21) 7828c2ecf20Sopenharmony_ci 7838c2ecf20Sopenharmony_ci/* 7848c2ecf20Sopenharmony_ci * Context state 7858c2ecf20Sopenharmony_ci */ 7868c2ecf20Sopenharmony_ci#define NX_HOST_CTX_STATE_FREED 0 7878c2ecf20Sopenharmony_ci#define NX_HOST_CTX_STATE_ALLOCATED 1 7888c2ecf20Sopenharmony_ci#define NX_HOST_CTX_STATE_ACTIVE 2 7898c2ecf20Sopenharmony_ci#define NX_HOST_CTX_STATE_DISABLED 3 7908c2ecf20Sopenharmony_ci#define NX_HOST_CTX_STATE_QUIESCED 4 7918c2ecf20Sopenharmony_ci#define NX_HOST_CTX_STATE_MAX 5 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci/* 7948c2ecf20Sopenharmony_ci * Rx context 7958c2ecf20Sopenharmony_ci */ 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_citypedef struct { 7988c2ecf20Sopenharmony_ci __le64 host_phys_addr; /* Ring base addr */ 7998c2ecf20Sopenharmony_ci __le32 ring_size; /* Ring entries */ 8008c2ecf20Sopenharmony_ci __le16 msi_index; 8018c2ecf20Sopenharmony_ci __le16 rsvd; /* Padding */ 8028c2ecf20Sopenharmony_ci} nx_hostrq_sds_ring_t; 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_citypedef struct { 8058c2ecf20Sopenharmony_ci __le64 host_phys_addr; /* Ring base addr */ 8068c2ecf20Sopenharmony_ci __le64 buff_size; /* Packet buffer size */ 8078c2ecf20Sopenharmony_ci __le32 ring_size; /* Ring entries */ 8088c2ecf20Sopenharmony_ci __le32 ring_kind; /* Class of ring */ 8098c2ecf20Sopenharmony_ci} nx_hostrq_rds_ring_t; 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_citypedef struct { 8128c2ecf20Sopenharmony_ci __le64 host_rsp_dma_addr; /* Response dma'd here */ 8138c2ecf20Sopenharmony_ci __le32 capabilities[4]; /* Flag bit vector */ 8148c2ecf20Sopenharmony_ci __le32 host_int_crb_mode; /* Interrupt crb usage */ 8158c2ecf20Sopenharmony_ci __le32 host_rds_crb_mode; /* RDS crb usage */ 8168c2ecf20Sopenharmony_ci /* These ring offsets are relative to data[0] below */ 8178c2ecf20Sopenharmony_ci __le32 rds_ring_offset; /* Offset to RDS config */ 8188c2ecf20Sopenharmony_ci __le32 sds_ring_offset; /* Offset to SDS config */ 8198c2ecf20Sopenharmony_ci __le16 num_rds_rings; /* Count of RDS rings */ 8208c2ecf20Sopenharmony_ci __le16 num_sds_rings; /* Count of SDS rings */ 8218c2ecf20Sopenharmony_ci __le16 rsvd1; /* Padding */ 8228c2ecf20Sopenharmony_ci __le16 rsvd2; /* Padding */ 8238c2ecf20Sopenharmony_ci u8 reserved[128]; /* reserve space for future expansion*/ 8248c2ecf20Sopenharmony_ci /* MUST BE 64-bit aligned. 8258c2ecf20Sopenharmony_ci The following is packed: 8268c2ecf20Sopenharmony_ci - N hostrq_rds_rings 8278c2ecf20Sopenharmony_ci - N hostrq_sds_rings */ 8288c2ecf20Sopenharmony_ci char data[0]; 8298c2ecf20Sopenharmony_ci} nx_hostrq_rx_ctx_t; 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_citypedef struct { 8328c2ecf20Sopenharmony_ci __le32 host_producer_crb; /* Crb to use */ 8338c2ecf20Sopenharmony_ci __le32 rsvd1; /* Padding */ 8348c2ecf20Sopenharmony_ci} nx_cardrsp_rds_ring_t; 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_citypedef struct { 8378c2ecf20Sopenharmony_ci __le32 host_consumer_crb; /* Crb to use */ 8388c2ecf20Sopenharmony_ci __le32 interrupt_crb; /* Crb to use */ 8398c2ecf20Sopenharmony_ci} nx_cardrsp_sds_ring_t; 8408c2ecf20Sopenharmony_ci 8418c2ecf20Sopenharmony_citypedef struct { 8428c2ecf20Sopenharmony_ci /* These ring offsets are relative to data[0] below */ 8438c2ecf20Sopenharmony_ci __le32 rds_ring_offset; /* Offset to RDS config */ 8448c2ecf20Sopenharmony_ci __le32 sds_ring_offset; /* Offset to SDS config */ 8458c2ecf20Sopenharmony_ci __le32 host_ctx_state; /* Starting State */ 8468c2ecf20Sopenharmony_ci __le32 num_fn_per_port; /* How many PCI fn share the port */ 8478c2ecf20Sopenharmony_ci __le16 num_rds_rings; /* Count of RDS rings */ 8488c2ecf20Sopenharmony_ci __le16 num_sds_rings; /* Count of SDS rings */ 8498c2ecf20Sopenharmony_ci __le16 context_id; /* Handle for context */ 8508c2ecf20Sopenharmony_ci u8 phys_port; /* Physical id of port */ 8518c2ecf20Sopenharmony_ci u8 virt_port; /* Virtual/Logical id of port */ 8528c2ecf20Sopenharmony_ci u8 reserved[128]; /* save space for future expansion */ 8538c2ecf20Sopenharmony_ci /* MUST BE 64-bit aligned. 8548c2ecf20Sopenharmony_ci The following is packed: 8558c2ecf20Sopenharmony_ci - N cardrsp_rds_rings 8568c2ecf20Sopenharmony_ci - N cardrs_sds_rings */ 8578c2ecf20Sopenharmony_ci char data[0]; 8588c2ecf20Sopenharmony_ci} nx_cardrsp_rx_ctx_t; 8598c2ecf20Sopenharmony_ci 8608c2ecf20Sopenharmony_ci#define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \ 8618c2ecf20Sopenharmony_ci (sizeof(HOSTRQ_RX) + \ 8628c2ecf20Sopenharmony_ci (rds_rings)*(sizeof(nx_hostrq_rds_ring_t)) + \ 8638c2ecf20Sopenharmony_ci (sds_rings)*(sizeof(nx_hostrq_sds_ring_t))) 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ci#define SIZEOF_CARDRSP_RX(CARDRSP_RX, rds_rings, sds_rings) \ 8668c2ecf20Sopenharmony_ci (sizeof(CARDRSP_RX) + \ 8678c2ecf20Sopenharmony_ci (rds_rings)*(sizeof(nx_cardrsp_rds_ring_t)) + \ 8688c2ecf20Sopenharmony_ci (sds_rings)*(sizeof(nx_cardrsp_sds_ring_t))) 8698c2ecf20Sopenharmony_ci 8708c2ecf20Sopenharmony_ci/* 8718c2ecf20Sopenharmony_ci * Tx context 8728c2ecf20Sopenharmony_ci */ 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_citypedef struct { 8758c2ecf20Sopenharmony_ci __le64 host_phys_addr; /* Ring base addr */ 8768c2ecf20Sopenharmony_ci __le32 ring_size; /* Ring entries */ 8778c2ecf20Sopenharmony_ci __le32 rsvd; /* Padding */ 8788c2ecf20Sopenharmony_ci} nx_hostrq_cds_ring_t; 8798c2ecf20Sopenharmony_ci 8808c2ecf20Sopenharmony_citypedef struct { 8818c2ecf20Sopenharmony_ci __le64 host_rsp_dma_addr; /* Response dma'd here */ 8828c2ecf20Sopenharmony_ci __le64 cmd_cons_dma_addr; /* */ 8838c2ecf20Sopenharmony_ci __le64 dummy_dma_addr; /* */ 8848c2ecf20Sopenharmony_ci __le32 capabilities[4]; /* Flag bit vector */ 8858c2ecf20Sopenharmony_ci __le32 host_int_crb_mode; /* Interrupt crb usage */ 8868c2ecf20Sopenharmony_ci __le32 rsvd1; /* Padding */ 8878c2ecf20Sopenharmony_ci __le16 rsvd2; /* Padding */ 8888c2ecf20Sopenharmony_ci __le16 interrupt_ctl; 8898c2ecf20Sopenharmony_ci __le16 msi_index; 8908c2ecf20Sopenharmony_ci __le16 rsvd3; /* Padding */ 8918c2ecf20Sopenharmony_ci nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */ 8928c2ecf20Sopenharmony_ci u8 reserved[128]; /* future expansion */ 8938c2ecf20Sopenharmony_ci} nx_hostrq_tx_ctx_t; 8948c2ecf20Sopenharmony_ci 8958c2ecf20Sopenharmony_citypedef struct { 8968c2ecf20Sopenharmony_ci __le32 host_producer_crb; /* Crb to use */ 8978c2ecf20Sopenharmony_ci __le32 interrupt_crb; /* Crb to use */ 8988c2ecf20Sopenharmony_ci} nx_cardrsp_cds_ring_t; 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_citypedef struct { 9018c2ecf20Sopenharmony_ci __le32 host_ctx_state; /* Starting state */ 9028c2ecf20Sopenharmony_ci __le16 context_id; /* Handle for context */ 9038c2ecf20Sopenharmony_ci u8 phys_port; /* Physical id of port */ 9048c2ecf20Sopenharmony_ci u8 virt_port; /* Virtual/Logical id of port */ 9058c2ecf20Sopenharmony_ci nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */ 9068c2ecf20Sopenharmony_ci u8 reserved[128]; /* future expansion */ 9078c2ecf20Sopenharmony_ci} nx_cardrsp_tx_ctx_t; 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_ci#define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) (sizeof(HOSTRQ_TX)) 9108c2ecf20Sopenharmony_ci#define SIZEOF_CARDRSP_TX(CARDRSP_TX) (sizeof(CARDRSP_TX)) 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci/* CRB */ 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci#define NX_HOST_RDS_CRB_MODE_UNIQUE 0 9158c2ecf20Sopenharmony_ci#define NX_HOST_RDS_CRB_MODE_SHARED 1 9168c2ecf20Sopenharmony_ci#define NX_HOST_RDS_CRB_MODE_CUSTOM 2 9178c2ecf20Sopenharmony_ci#define NX_HOST_RDS_CRB_MODE_MAX 3 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_ci#define NX_HOST_INT_CRB_MODE_UNIQUE 0 9208c2ecf20Sopenharmony_ci#define NX_HOST_INT_CRB_MODE_SHARED 1 9218c2ecf20Sopenharmony_ci#define NX_HOST_INT_CRB_MODE_NORX 2 9228c2ecf20Sopenharmony_ci#define NX_HOST_INT_CRB_MODE_NOTX 3 9238c2ecf20Sopenharmony_ci#define NX_HOST_INT_CRB_MODE_NORXTX 4 9248c2ecf20Sopenharmony_ci 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci/* MAC */ 9278c2ecf20Sopenharmony_ci 9288c2ecf20Sopenharmony_ci#define MC_COUNT_P2 16 9298c2ecf20Sopenharmony_ci#define MC_COUNT_P3 38 9308c2ecf20Sopenharmony_ci 9318c2ecf20Sopenharmony_ci#define NETXEN_MAC_NOOP 0 9328c2ecf20Sopenharmony_ci#define NETXEN_MAC_ADD 1 9338c2ecf20Sopenharmony_ci#define NETXEN_MAC_DEL 2 9348c2ecf20Sopenharmony_ci 9358c2ecf20Sopenharmony_citypedef struct nx_mac_list_s { 9368c2ecf20Sopenharmony_ci struct list_head list; 9378c2ecf20Sopenharmony_ci uint8_t mac_addr[ETH_ALEN+2]; 9388c2ecf20Sopenharmony_ci} nx_mac_list_t; 9398c2ecf20Sopenharmony_ci 9408c2ecf20Sopenharmony_cistruct nx_ip_list { 9418c2ecf20Sopenharmony_ci struct list_head list; 9428c2ecf20Sopenharmony_ci __be32 ip_addr; 9438c2ecf20Sopenharmony_ci bool master; 9448c2ecf20Sopenharmony_ci}; 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ci/* 9478c2ecf20Sopenharmony_ci * Interrupt coalescing defaults. The defaults are for 1500 MTU. It is 9488c2ecf20Sopenharmony_ci * adjusted based on configured MTU. 9498c2ecf20Sopenharmony_ci */ 9508c2ecf20Sopenharmony_ci#define NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US 3 9518c2ecf20Sopenharmony_ci#define NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS 256 9528c2ecf20Sopenharmony_ci#define NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS 64 9538c2ecf20Sopenharmony_ci#define NETXEN_DEFAULT_INTR_COALESCE_TX_TIME_US 4 9548c2ecf20Sopenharmony_ci 9558c2ecf20Sopenharmony_ci#define NETXEN_NIC_INTR_DEFAULT 0x04 9568c2ecf20Sopenharmony_ci 9578c2ecf20Sopenharmony_citypedef union { 9588c2ecf20Sopenharmony_ci struct { 9598c2ecf20Sopenharmony_ci uint16_t rx_packets; 9608c2ecf20Sopenharmony_ci uint16_t rx_time_us; 9618c2ecf20Sopenharmony_ci uint16_t tx_packets; 9628c2ecf20Sopenharmony_ci uint16_t tx_time_us; 9638c2ecf20Sopenharmony_ci } data; 9648c2ecf20Sopenharmony_ci uint64_t word; 9658c2ecf20Sopenharmony_ci} nx_nic_intr_coalesce_data_t; 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_citypedef struct { 9688c2ecf20Sopenharmony_ci uint16_t stats_time_us; 9698c2ecf20Sopenharmony_ci uint16_t rate_sample_time; 9708c2ecf20Sopenharmony_ci uint16_t flags; 9718c2ecf20Sopenharmony_ci uint16_t rsvd_1; 9728c2ecf20Sopenharmony_ci uint32_t low_threshold; 9738c2ecf20Sopenharmony_ci uint32_t high_threshold; 9748c2ecf20Sopenharmony_ci nx_nic_intr_coalesce_data_t normal; 9758c2ecf20Sopenharmony_ci nx_nic_intr_coalesce_data_t low; 9768c2ecf20Sopenharmony_ci nx_nic_intr_coalesce_data_t high; 9778c2ecf20Sopenharmony_ci nx_nic_intr_coalesce_data_t irq; 9788c2ecf20Sopenharmony_ci} nx_nic_intr_coalesce_t; 9798c2ecf20Sopenharmony_ci 9808c2ecf20Sopenharmony_ci#define NX_HOST_REQUEST 0x13 9818c2ecf20Sopenharmony_ci#define NX_NIC_REQUEST 0x14 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_ci#define NX_MAC_EVENT 0x1 9848c2ecf20Sopenharmony_ci 9858c2ecf20Sopenharmony_ci#define NX_IP_UP 2 9868c2ecf20Sopenharmony_ci#define NX_IP_DOWN 3 9878c2ecf20Sopenharmony_ci 9888c2ecf20Sopenharmony_ci/* 9898c2ecf20Sopenharmony_ci * Driver --> Firmware 9908c2ecf20Sopenharmony_ci */ 9918c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_START 0 9928c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_RSS 1 9938c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_RSS_TBL 2 9948c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_INTR_COALESCE 3 9958c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_LED 4 9968c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_PROMISCUOUS 5 9978c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_L2_MAC 6 9988c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_LRO_REQUEST 7 9998c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_GET_SNMP_STATS 8 10008c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_PROXY_START_REQUEST 9 10018c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_PROXY_STOP_REQUEST 10 10028c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_PROXY_SET_MTU 11 10038c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE 12 10048c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_GET_FINGER_PRINT_REQUEST 13 10058c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_INSTALL_LICENSE_REQUEST 14 10068c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_GET_LICENSE_CAPABILITY_REQUEST 15 10078c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_GET_NET_STATS 16 10088c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_PROXY_UPDATE_P2V 17 10098c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_IPADDR 18 10108c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_LOOPBACK 19 10118c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_PROXY_STOP_DONE 20 10128c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_GET_LINKEVENT 21 10138c2ecf20Sopenharmony_ci#define NX_NIC_C2C_OPCODE 22 10148c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_BRIDGING 23 10158c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_CONFIG_HW_LRO 24 10168c2ecf20Sopenharmony_ci#define NX_NIC_H2C_OPCODE_LAST 25 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_ci/* 10198c2ecf20Sopenharmony_ci * Firmware --> Driver 10208c2ecf20Sopenharmony_ci */ 10218c2ecf20Sopenharmony_ci 10228c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_START 128 10238c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_CONFIG_RSS_RESPONSE 129 10248c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_CONFIG_RSS_TBL_RESPONSE 130 10258c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_CONFIG_MAC_RESPONSE 131 10268c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_CONFIG_PROMISCUOUS_RESPONSE 132 10278c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_CONFIG_L2_MAC_RESPONSE 133 10288c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_LRO_DELETE_RESPONSE 134 10298c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_LRO_ADD_FAILURE_RESPONSE 135 10308c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_GET_SNMP_STATS 136 10318c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_GET_FINGER_PRINT_REPLY 137 10328c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_INSTALL_LICENSE_REPLY 138 10338c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_GET_LICENSE_CAPABILITIES_REPLY 139 10348c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_GET_NET_STATS_RESPONSE 140 10358c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE 141 10368c2ecf20Sopenharmony_ci#define NX_NIC_C2H_OPCODE_LAST 142 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci#define VPORT_MISS_MODE_DROP 0 /* drop all unmatched */ 10398c2ecf20Sopenharmony_ci#define VPORT_MISS_MODE_ACCEPT_ALL 1 /* accept all packets */ 10408c2ecf20Sopenharmony_ci#define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */ 10418c2ecf20Sopenharmony_ci 10428c2ecf20Sopenharmony_ci#define NX_NIC_LRO_REQUEST_FIRST 0 10438c2ecf20Sopenharmony_ci#define NX_NIC_LRO_REQUEST_ADD_FLOW 1 10448c2ecf20Sopenharmony_ci#define NX_NIC_LRO_REQUEST_DELETE_FLOW 2 10458c2ecf20Sopenharmony_ci#define NX_NIC_LRO_REQUEST_TIMER 3 10468c2ecf20Sopenharmony_ci#define NX_NIC_LRO_REQUEST_CLEANUP 4 10478c2ecf20Sopenharmony_ci#define NX_NIC_LRO_REQUEST_ADD_FLOW_SCHEDULED 5 10488c2ecf20Sopenharmony_ci#define NX_TOE_LRO_REQUEST_ADD_FLOW 6 10498c2ecf20Sopenharmony_ci#define NX_TOE_LRO_REQUEST_ADD_FLOW_RESPONSE 7 10508c2ecf20Sopenharmony_ci#define NX_TOE_LRO_REQUEST_DELETE_FLOW 8 10518c2ecf20Sopenharmony_ci#define NX_TOE_LRO_REQUEST_DELETE_FLOW_RESPONSE 9 10528c2ecf20Sopenharmony_ci#define NX_TOE_LRO_REQUEST_TIMER 10 10538c2ecf20Sopenharmony_ci#define NX_NIC_LRO_REQUEST_LAST 11 10548c2ecf20Sopenharmony_ci 10558c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_LINK_NOTIFICATION (1 << 5) 10568c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_SWITCHING (1 << 6) 10578c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_PEXQ (1 << 7) 10588c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_BDG (1 << 8) 10598c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_FVLANTX (1 << 9) 10608c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_HW_LRO (1 << 10) 10618c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_GBE_LINK_CFG (1 << 11) 10628c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_MORE_CAPS (1 << 31) 10638c2ecf20Sopenharmony_ci#define NX_FW_CAPABILITY_2_LRO_MAX_TCP_SEG (1 << 2) 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci/* module types */ 10668c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_NOT_PRESENT 1 10678c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_UNKNOWN 2 10688c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_SRLR 3 10698c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_LRM 4 10708c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_OPTICAL_SFP_1G 5 10718c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE 6 10728c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN 7 10738c2ecf20Sopenharmony_ci#define LINKEVENT_MODULE_TWINAX 8 10748c2ecf20Sopenharmony_ci 10758c2ecf20Sopenharmony_ci#define LINKSPEED_10GBPS 10000 10768c2ecf20Sopenharmony_ci#define LINKSPEED_1GBPS 1000 10778c2ecf20Sopenharmony_ci#define LINKSPEED_100MBPS 100 10788c2ecf20Sopenharmony_ci#define LINKSPEED_10MBPS 10 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_ci#define LINKSPEED_ENCODED_10MBPS 0 10818c2ecf20Sopenharmony_ci#define LINKSPEED_ENCODED_100MBPS 1 10828c2ecf20Sopenharmony_ci#define LINKSPEED_ENCODED_1GBPS 2 10838c2ecf20Sopenharmony_ci 10848c2ecf20Sopenharmony_ci#define LINKEVENT_AUTONEG_DISABLED 0 10858c2ecf20Sopenharmony_ci#define LINKEVENT_AUTONEG_ENABLED 1 10868c2ecf20Sopenharmony_ci 10878c2ecf20Sopenharmony_ci#define LINKEVENT_HALF_DUPLEX 0 10888c2ecf20Sopenharmony_ci#define LINKEVENT_FULL_DUPLEX 1 10898c2ecf20Sopenharmony_ci 10908c2ecf20Sopenharmony_ci#define LINKEVENT_LINKSPEED_MBPS 0 10918c2ecf20Sopenharmony_ci#define LINKEVENT_LINKSPEED_ENCODED 1 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_ci#define AUTO_FW_RESET_ENABLED 0xEF10AF12 10948c2ecf20Sopenharmony_ci#define AUTO_FW_RESET_DISABLED 0xDCBAAF12 10958c2ecf20Sopenharmony_ci 10968c2ecf20Sopenharmony_ci/* firmware response header: 10978c2ecf20Sopenharmony_ci * 63:58 - message type 10988c2ecf20Sopenharmony_ci * 57:56 - owner 10998c2ecf20Sopenharmony_ci * 55:53 - desc count 11008c2ecf20Sopenharmony_ci * 52:48 - reserved 11018c2ecf20Sopenharmony_ci * 47:40 - completion id 11028c2ecf20Sopenharmony_ci * 39:32 - opcode 11038c2ecf20Sopenharmony_ci * 31:16 - error code 11048c2ecf20Sopenharmony_ci * 15:00 - reserved 11058c2ecf20Sopenharmony_ci */ 11068c2ecf20Sopenharmony_ci#define netxen_get_nic_msgtype(msg_hdr) \ 11078c2ecf20Sopenharmony_ci ((msg_hdr >> 58) & 0x3F) 11088c2ecf20Sopenharmony_ci#define netxen_get_nic_msg_compid(msg_hdr) \ 11098c2ecf20Sopenharmony_ci ((msg_hdr >> 40) & 0xFF) 11108c2ecf20Sopenharmony_ci#define netxen_get_nic_msg_opcode(msg_hdr) \ 11118c2ecf20Sopenharmony_ci ((msg_hdr >> 32) & 0xFF) 11128c2ecf20Sopenharmony_ci#define netxen_get_nic_msg_errcode(msg_hdr) \ 11138c2ecf20Sopenharmony_ci ((msg_hdr >> 16) & 0xFFFF) 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_citypedef struct { 11168c2ecf20Sopenharmony_ci union { 11178c2ecf20Sopenharmony_ci struct { 11188c2ecf20Sopenharmony_ci u64 hdr; 11198c2ecf20Sopenharmony_ci u64 body[7]; 11208c2ecf20Sopenharmony_ci }; 11218c2ecf20Sopenharmony_ci u64 words[8]; 11228c2ecf20Sopenharmony_ci }; 11238c2ecf20Sopenharmony_ci} nx_fw_msg_t; 11248c2ecf20Sopenharmony_ci 11258c2ecf20Sopenharmony_citypedef struct { 11268c2ecf20Sopenharmony_ci __le64 qhdr; 11278c2ecf20Sopenharmony_ci __le64 req_hdr; 11288c2ecf20Sopenharmony_ci __le64 words[6]; 11298c2ecf20Sopenharmony_ci} nx_nic_req_t; 11308c2ecf20Sopenharmony_ci 11318c2ecf20Sopenharmony_citypedef struct { 11328c2ecf20Sopenharmony_ci u8 op; 11338c2ecf20Sopenharmony_ci u8 tag; 11348c2ecf20Sopenharmony_ci u8 mac_addr[6]; 11358c2ecf20Sopenharmony_ci} nx_mac_req_t; 11368c2ecf20Sopenharmony_ci 11378c2ecf20Sopenharmony_ci#define MAX_PENDING_DESC_BLOCK_SIZE 64 11388c2ecf20Sopenharmony_ci 11398c2ecf20Sopenharmony_ci#define NETXEN_NIC_MSI_ENABLED 0x02 11408c2ecf20Sopenharmony_ci#define NETXEN_NIC_MSIX_ENABLED 0x04 11418c2ecf20Sopenharmony_ci#define NETXEN_NIC_LRO_ENABLED 0x08 11428c2ecf20Sopenharmony_ci#define NETXEN_NIC_LRO_DISABLED 0x00 11438c2ecf20Sopenharmony_ci#define NETXEN_NIC_BRIDGE_ENABLED 0X10 11448c2ecf20Sopenharmony_ci#define NETXEN_NIC_DIAG_ENABLED 0x20 11458c2ecf20Sopenharmony_ci#define NETXEN_FW_RESET_OWNER 0x40 11468c2ecf20Sopenharmony_ci#define NETXEN_FW_MSS_CAP 0x80 11478c2ecf20Sopenharmony_ci#define NETXEN_IS_MSI_FAMILY(adapter) \ 11488c2ecf20Sopenharmony_ci ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED)) 11498c2ecf20Sopenharmony_ci 11508c2ecf20Sopenharmony_ci#define MSIX_ENTRIES_PER_ADAPTER NUM_STS_DESC_RINGS 11518c2ecf20Sopenharmony_ci#define NETXEN_MSIX_TBL_SPACE 8192 11528c2ecf20Sopenharmony_ci#define NETXEN_PCI_REG_MSIX_TBL 0x44 11538c2ecf20Sopenharmony_ci 11548c2ecf20Sopenharmony_ci#define NETXEN_DB_MAPSIZE_BYTES 0x1000 11558c2ecf20Sopenharmony_ci 11568c2ecf20Sopenharmony_ci#define NETXEN_ADAPTER_UP_MAGIC 777 11578c2ecf20Sopenharmony_ci#define NETXEN_NIC_PEG_TUNE 0 11588c2ecf20Sopenharmony_ci 11598c2ecf20Sopenharmony_ci#define __NX_FW_ATTACHED 0 11608c2ecf20Sopenharmony_ci#define __NX_DEV_UP 1 11618c2ecf20Sopenharmony_ci#define __NX_RESETTING 2 11628c2ecf20Sopenharmony_ci 11638c2ecf20Sopenharmony_ci/* Mini Coredump FW supported version */ 11648c2ecf20Sopenharmony_ci#define NX_MD_SUPPORT_MAJOR 4 11658c2ecf20Sopenharmony_ci#define NX_MD_SUPPORT_MINOR 0 11668c2ecf20Sopenharmony_ci#define NX_MD_SUPPORT_SUBVERSION 579 11678c2ecf20Sopenharmony_ci 11688c2ecf20Sopenharmony_ci#define LSW(x) ((uint16_t)(x)) 11698c2ecf20Sopenharmony_ci#define LSD(x) ((uint32_t)((uint64_t)(x))) 11708c2ecf20Sopenharmony_ci#define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16)) 11718c2ecf20Sopenharmony_ci 11728c2ecf20Sopenharmony_ci/* Mini Coredump mask level */ 11738c2ecf20Sopenharmony_ci#define NX_DUMP_MASK_MIN 0x03 11748c2ecf20Sopenharmony_ci#define NX_DUMP_MASK_DEF 0x1f 11758c2ecf20Sopenharmony_ci#define NX_DUMP_MASK_MAX 0xff 11768c2ecf20Sopenharmony_ci 11778c2ecf20Sopenharmony_ci/* Mini Coredump CDRP commands */ 11788c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_TEMP_SIZE 0x0000002f 11798c2ecf20Sopenharmony_ci#define NX_CDRP_CMD_GET_TEMP_HDR 0x00000030 11808c2ecf20Sopenharmony_ci 11818c2ecf20Sopenharmony_ci 11828c2ecf20Sopenharmony_ci#define NX_DUMP_STATE_ARRAY_LEN 16 11838c2ecf20Sopenharmony_ci#define NX_DUMP_CAP_SIZE_ARRAY_LEN 8 11848c2ecf20Sopenharmony_ci 11858c2ecf20Sopenharmony_ci/* Mini Coredump sysfs entries flags*/ 11868c2ecf20Sopenharmony_ci#define NX_FORCE_FW_DUMP_KEY 0xdeadfeed 11878c2ecf20Sopenharmony_ci#define NX_ENABLE_FW_DUMP 0xaddfeed 11888c2ecf20Sopenharmony_ci#define NX_DISABLE_FW_DUMP 0xbadfeed 11898c2ecf20Sopenharmony_ci#define NX_FORCE_FW_RESET 0xdeaddead 11908c2ecf20Sopenharmony_ci 11918c2ecf20Sopenharmony_ci 11928c2ecf20Sopenharmony_ci/* Flash read/write address */ 11938c2ecf20Sopenharmony_ci#define NX_FW_DUMP_REG1 0x00130060 11948c2ecf20Sopenharmony_ci#define NX_FW_DUMP_REG2 0x001e0000 11958c2ecf20Sopenharmony_ci#define NX_FLASH_SEM2_LK 0x0013C010 11968c2ecf20Sopenharmony_ci#define NX_FLASH_SEM2_ULK 0x0013C014 11978c2ecf20Sopenharmony_ci#define NX_FLASH_LOCK_ID 0x001B2100 11988c2ecf20Sopenharmony_ci#define FLASH_ROM_WINDOW 0x42110030 11998c2ecf20Sopenharmony_ci#define FLASH_ROM_DATA 0x42150000 12008c2ecf20Sopenharmony_ci 12018c2ecf20Sopenharmony_ci/* Mini Coredump register read/write routine */ 12028c2ecf20Sopenharmony_ci#define NX_RD_DUMP_REG(addr, bar0, data) do { \ 12038c2ecf20Sopenharmony_ci writel((addr & 0xFFFF0000), (void __iomem *) (bar0 + \ 12048c2ecf20Sopenharmony_ci NX_FW_DUMP_REG1)); \ 12058c2ecf20Sopenharmony_ci readl((void __iomem *) (bar0 + NX_FW_DUMP_REG1)); \ 12068c2ecf20Sopenharmony_ci *data = readl((void __iomem *) (bar0 + NX_FW_DUMP_REG2 + \ 12078c2ecf20Sopenharmony_ci LSW(addr))); \ 12088c2ecf20Sopenharmony_ci} while (0) 12098c2ecf20Sopenharmony_ci 12108c2ecf20Sopenharmony_ci#define NX_WR_DUMP_REG(addr, bar0, data) do { \ 12118c2ecf20Sopenharmony_ci writel((addr & 0xFFFF0000), (void __iomem *) (bar0 + \ 12128c2ecf20Sopenharmony_ci NX_FW_DUMP_REG1)); \ 12138c2ecf20Sopenharmony_ci readl((void __iomem *) (bar0 + NX_FW_DUMP_REG1)); \ 12148c2ecf20Sopenharmony_ci writel(data, (void __iomem *) (bar0 + NX_FW_DUMP_REG2 + LSW(addr)));\ 12158c2ecf20Sopenharmony_ci readl((void __iomem *) (bar0 + NX_FW_DUMP_REG2 + LSW(addr))); \ 12168c2ecf20Sopenharmony_ci} while (0) 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_ci 12198c2ecf20Sopenharmony_ci/* 12208c2ecf20Sopenharmony_ciEntry Type Defines 12218c2ecf20Sopenharmony_ci*/ 12228c2ecf20Sopenharmony_ci 12238c2ecf20Sopenharmony_ci#define RDNOP 0 12248c2ecf20Sopenharmony_ci#define RDCRB 1 12258c2ecf20Sopenharmony_ci#define RDMUX 2 12268c2ecf20Sopenharmony_ci#define QUEUE 3 12278c2ecf20Sopenharmony_ci#define BOARD 4 12288c2ecf20Sopenharmony_ci#define RDSRE 5 12298c2ecf20Sopenharmony_ci#define RDOCM 6 12308c2ecf20Sopenharmony_ci#define PREGS 7 12318c2ecf20Sopenharmony_ci#define L1DTG 8 12328c2ecf20Sopenharmony_ci#define L1ITG 9 12338c2ecf20Sopenharmony_ci#define CACHE 10 12348c2ecf20Sopenharmony_ci 12358c2ecf20Sopenharmony_ci#define L1DAT 11 12368c2ecf20Sopenharmony_ci#define L1INS 12 12378c2ecf20Sopenharmony_ci#define RDSTK 13 12388c2ecf20Sopenharmony_ci#define RDCON 14 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_ci#define L2DTG 21 12418c2ecf20Sopenharmony_ci#define L2ITG 22 12428c2ecf20Sopenharmony_ci#define L2DAT 23 12438c2ecf20Sopenharmony_ci#define L2INS 24 12448c2ecf20Sopenharmony_ci#define RDOC3 25 12458c2ecf20Sopenharmony_ci 12468c2ecf20Sopenharmony_ci#define MEMBK 32 12478c2ecf20Sopenharmony_ci 12488c2ecf20Sopenharmony_ci#define RDROM 71 12498c2ecf20Sopenharmony_ci#define RDMEM 72 12508c2ecf20Sopenharmony_ci#define RDMN 73 12518c2ecf20Sopenharmony_ci 12528c2ecf20Sopenharmony_ci#define INFOR 81 12538c2ecf20Sopenharmony_ci#define CNTRL 98 12548c2ecf20Sopenharmony_ci 12558c2ecf20Sopenharmony_ci#define TLHDR 99 12568c2ecf20Sopenharmony_ci#define RDEND 255 12578c2ecf20Sopenharmony_ci 12588c2ecf20Sopenharmony_ci#define PRIMQ 103 12598c2ecf20Sopenharmony_ci#define SQG2Q 104 12608c2ecf20Sopenharmony_ci#define SQG3Q 105 12618c2ecf20Sopenharmony_ci 12628c2ecf20Sopenharmony_ci/* 12638c2ecf20Sopenharmony_ci* Opcodes for Control Entries. 12648c2ecf20Sopenharmony_ci* These Flags are bit fields. 12658c2ecf20Sopenharmony_ci*/ 12668c2ecf20Sopenharmony_ci#define NX_DUMP_WCRB 0x01 12678c2ecf20Sopenharmony_ci#define NX_DUMP_RWCRB 0x02 12688c2ecf20Sopenharmony_ci#define NX_DUMP_ANDCRB 0x04 12698c2ecf20Sopenharmony_ci#define NX_DUMP_ORCRB 0x08 12708c2ecf20Sopenharmony_ci#define NX_DUMP_POLLCRB 0x10 12718c2ecf20Sopenharmony_ci#define NX_DUMP_RD_SAVE 0x20 12728c2ecf20Sopenharmony_ci#define NX_DUMP_WRT_SAVED 0x40 12738c2ecf20Sopenharmony_ci#define NX_DUMP_MOD_SAVE_ST 0x80 12748c2ecf20Sopenharmony_ci 12758c2ecf20Sopenharmony_ci/* Driver Flags */ 12768c2ecf20Sopenharmony_ci#define NX_DUMP_SKIP 0x80 /* driver skipped this entry */ 12778c2ecf20Sopenharmony_ci#define NX_DUMP_SIZE_ERR 0x40 /*entry size vs capture size mismatch*/ 12788c2ecf20Sopenharmony_ci 12798c2ecf20Sopenharmony_ci#define NX_PCI_READ_32(ADDR) readl((ADDR)) 12808c2ecf20Sopenharmony_ci#define NX_PCI_WRITE_32(DATA, ADDR) writel(DATA, (ADDR)) 12818c2ecf20Sopenharmony_ci 12828c2ecf20Sopenharmony_ci 12838c2ecf20Sopenharmony_ci 12848c2ecf20Sopenharmony_cistruct netxen_minidump { 12858c2ecf20Sopenharmony_ci u32 pos; /* position in the dump buffer */ 12868c2ecf20Sopenharmony_ci u8 fw_supports_md; /* FW supports Mini cordump */ 12878c2ecf20Sopenharmony_ci u8 has_valid_dump; /* indicates valid dump */ 12888c2ecf20Sopenharmony_ci u8 md_capture_mask; /* driver capture mask */ 12898c2ecf20Sopenharmony_ci u8 md_enabled; /* Turn Mini Coredump on/off */ 12908c2ecf20Sopenharmony_ci u32 md_dump_size; /* Total FW Mini Coredump size */ 12918c2ecf20Sopenharmony_ci u32 md_capture_size; /* FW dump capture size */ 12928c2ecf20Sopenharmony_ci u32 md_template_size; /* FW template size */ 12938c2ecf20Sopenharmony_ci u32 md_template_ver; /* FW template version */ 12948c2ecf20Sopenharmony_ci u64 md_timestamp; /* FW Mini dump timestamp */ 12958c2ecf20Sopenharmony_ci void *md_template; /* FW template will be stored */ 12968c2ecf20Sopenharmony_ci void *md_capture_buff; /* FW dump will be stored */ 12978c2ecf20Sopenharmony_ci}; 12988c2ecf20Sopenharmony_ci 12998c2ecf20Sopenharmony_ci 13008c2ecf20Sopenharmony_ci 13018c2ecf20Sopenharmony_cistruct netxen_minidump_template_hdr { 13028c2ecf20Sopenharmony_ci u32 entry_type; 13038c2ecf20Sopenharmony_ci u32 first_entry_offset; 13048c2ecf20Sopenharmony_ci u32 size_of_template; 13058c2ecf20Sopenharmony_ci u32 capture_mask; 13068c2ecf20Sopenharmony_ci u32 num_of_entries; 13078c2ecf20Sopenharmony_ci u32 version; 13088c2ecf20Sopenharmony_ci u32 driver_timestamp; 13098c2ecf20Sopenharmony_ci u32 checksum; 13108c2ecf20Sopenharmony_ci u32 driver_capture_mask; 13118c2ecf20Sopenharmony_ci u32 driver_info_word2; 13128c2ecf20Sopenharmony_ci u32 driver_info_word3; 13138c2ecf20Sopenharmony_ci u32 driver_info_word4; 13148c2ecf20Sopenharmony_ci u32 saved_state_array[NX_DUMP_STATE_ARRAY_LEN]; 13158c2ecf20Sopenharmony_ci u32 capture_size_array[NX_DUMP_CAP_SIZE_ARRAY_LEN]; 13168c2ecf20Sopenharmony_ci u32 rsvd[]; 13178c2ecf20Sopenharmony_ci}; 13188c2ecf20Sopenharmony_ci 13198c2ecf20Sopenharmony_ci/* Common Entry Header: Common to All Entry Types */ 13208c2ecf20Sopenharmony_ci/* 13218c2ecf20Sopenharmony_ci * Driver Code is for driver to write some info about the entry. 13228c2ecf20Sopenharmony_ci * Currently not used. 13238c2ecf20Sopenharmony_ci */ 13248c2ecf20Sopenharmony_ci 13258c2ecf20Sopenharmony_cistruct netxen_common_entry_hdr { 13268c2ecf20Sopenharmony_ci u32 entry_type; 13278c2ecf20Sopenharmony_ci u32 entry_size; 13288c2ecf20Sopenharmony_ci u32 entry_capture_size; 13298c2ecf20Sopenharmony_ci union { 13308c2ecf20Sopenharmony_ci struct { 13318c2ecf20Sopenharmony_ci u8 entry_capture_mask; 13328c2ecf20Sopenharmony_ci u8 entry_code; 13338c2ecf20Sopenharmony_ci u8 driver_code; 13348c2ecf20Sopenharmony_ci u8 driver_flags; 13358c2ecf20Sopenharmony_ci }; 13368c2ecf20Sopenharmony_ci u32 entry_ctrl_word; 13378c2ecf20Sopenharmony_ci }; 13388c2ecf20Sopenharmony_ci}; 13398c2ecf20Sopenharmony_ci 13408c2ecf20Sopenharmony_ci 13418c2ecf20Sopenharmony_ci/* Generic Entry Including Header */ 13428c2ecf20Sopenharmony_cistruct netxen_minidump_entry { 13438c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr hdr; 13448c2ecf20Sopenharmony_ci u32 entry_data00; 13458c2ecf20Sopenharmony_ci u32 entry_data01; 13468c2ecf20Sopenharmony_ci u32 entry_data02; 13478c2ecf20Sopenharmony_ci u32 entry_data03; 13488c2ecf20Sopenharmony_ci u32 entry_data04; 13498c2ecf20Sopenharmony_ci u32 entry_data05; 13508c2ecf20Sopenharmony_ci u32 entry_data06; 13518c2ecf20Sopenharmony_ci u32 entry_data07; 13528c2ecf20Sopenharmony_ci}; 13538c2ecf20Sopenharmony_ci 13548c2ecf20Sopenharmony_ci/* Read ROM Header */ 13558c2ecf20Sopenharmony_cistruct netxen_minidump_entry_rdrom { 13568c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr h; 13578c2ecf20Sopenharmony_ci union { 13588c2ecf20Sopenharmony_ci struct { 13598c2ecf20Sopenharmony_ci u32 select_addr_reg; 13608c2ecf20Sopenharmony_ci }; 13618c2ecf20Sopenharmony_ci u32 rsvd_0; 13628c2ecf20Sopenharmony_ci }; 13638c2ecf20Sopenharmony_ci union { 13648c2ecf20Sopenharmony_ci struct { 13658c2ecf20Sopenharmony_ci u8 addr_stride; 13668c2ecf20Sopenharmony_ci u8 addr_cnt; 13678c2ecf20Sopenharmony_ci u16 data_size; 13688c2ecf20Sopenharmony_ci }; 13698c2ecf20Sopenharmony_ci u32 rsvd_1; 13708c2ecf20Sopenharmony_ci }; 13718c2ecf20Sopenharmony_ci union { 13728c2ecf20Sopenharmony_ci struct { 13738c2ecf20Sopenharmony_ci u32 op_count; 13748c2ecf20Sopenharmony_ci }; 13758c2ecf20Sopenharmony_ci u32 rsvd_2; 13768c2ecf20Sopenharmony_ci }; 13778c2ecf20Sopenharmony_ci union { 13788c2ecf20Sopenharmony_ci struct { 13798c2ecf20Sopenharmony_ci u32 read_addr_reg; 13808c2ecf20Sopenharmony_ci }; 13818c2ecf20Sopenharmony_ci u32 rsvd_3; 13828c2ecf20Sopenharmony_ci }; 13838c2ecf20Sopenharmony_ci union { 13848c2ecf20Sopenharmony_ci struct { 13858c2ecf20Sopenharmony_ci u32 write_mask; 13868c2ecf20Sopenharmony_ci }; 13878c2ecf20Sopenharmony_ci u32 rsvd_4; 13888c2ecf20Sopenharmony_ci }; 13898c2ecf20Sopenharmony_ci union { 13908c2ecf20Sopenharmony_ci struct { 13918c2ecf20Sopenharmony_ci u32 read_mask; 13928c2ecf20Sopenharmony_ci }; 13938c2ecf20Sopenharmony_ci u32 rsvd_5; 13948c2ecf20Sopenharmony_ci }; 13958c2ecf20Sopenharmony_ci u32 read_addr; 13968c2ecf20Sopenharmony_ci u32 read_data_size; 13978c2ecf20Sopenharmony_ci}; 13988c2ecf20Sopenharmony_ci 13998c2ecf20Sopenharmony_ci 14008c2ecf20Sopenharmony_ci/* Read CRB and Control Entry Header */ 14018c2ecf20Sopenharmony_cistruct netxen_minidump_entry_crb { 14028c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr h; 14038c2ecf20Sopenharmony_ci u32 addr; 14048c2ecf20Sopenharmony_ci union { 14058c2ecf20Sopenharmony_ci struct { 14068c2ecf20Sopenharmony_ci u8 addr_stride; 14078c2ecf20Sopenharmony_ci u8 state_index_a; 14088c2ecf20Sopenharmony_ci u16 poll_timeout; 14098c2ecf20Sopenharmony_ci }; 14108c2ecf20Sopenharmony_ci u32 addr_cntrl; 14118c2ecf20Sopenharmony_ci }; 14128c2ecf20Sopenharmony_ci u32 data_size; 14138c2ecf20Sopenharmony_ci u32 op_count; 14148c2ecf20Sopenharmony_ci union { 14158c2ecf20Sopenharmony_ci struct { 14168c2ecf20Sopenharmony_ci u8 opcode; 14178c2ecf20Sopenharmony_ci u8 state_index_v; 14188c2ecf20Sopenharmony_ci u8 shl; 14198c2ecf20Sopenharmony_ci u8 shr; 14208c2ecf20Sopenharmony_ci }; 14218c2ecf20Sopenharmony_ci u32 control_value; 14228c2ecf20Sopenharmony_ci }; 14238c2ecf20Sopenharmony_ci u32 value_1; 14248c2ecf20Sopenharmony_ci u32 value_2; 14258c2ecf20Sopenharmony_ci u32 value_3; 14268c2ecf20Sopenharmony_ci}; 14278c2ecf20Sopenharmony_ci 14288c2ecf20Sopenharmony_ci/* Read Memory and MN Header */ 14298c2ecf20Sopenharmony_cistruct netxen_minidump_entry_rdmem { 14308c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr h; 14318c2ecf20Sopenharmony_ci union { 14328c2ecf20Sopenharmony_ci struct { 14338c2ecf20Sopenharmony_ci u32 select_addr_reg; 14348c2ecf20Sopenharmony_ci }; 14358c2ecf20Sopenharmony_ci u32 rsvd_0; 14368c2ecf20Sopenharmony_ci }; 14378c2ecf20Sopenharmony_ci union { 14388c2ecf20Sopenharmony_ci struct { 14398c2ecf20Sopenharmony_ci u8 addr_stride; 14408c2ecf20Sopenharmony_ci u8 addr_cnt; 14418c2ecf20Sopenharmony_ci u16 data_size; 14428c2ecf20Sopenharmony_ci }; 14438c2ecf20Sopenharmony_ci u32 rsvd_1; 14448c2ecf20Sopenharmony_ci }; 14458c2ecf20Sopenharmony_ci union { 14468c2ecf20Sopenharmony_ci struct { 14478c2ecf20Sopenharmony_ci u32 op_count; 14488c2ecf20Sopenharmony_ci }; 14498c2ecf20Sopenharmony_ci u32 rsvd_2; 14508c2ecf20Sopenharmony_ci }; 14518c2ecf20Sopenharmony_ci union { 14528c2ecf20Sopenharmony_ci struct { 14538c2ecf20Sopenharmony_ci u32 read_addr_reg; 14548c2ecf20Sopenharmony_ci }; 14558c2ecf20Sopenharmony_ci u32 rsvd_3; 14568c2ecf20Sopenharmony_ci }; 14578c2ecf20Sopenharmony_ci union { 14588c2ecf20Sopenharmony_ci struct { 14598c2ecf20Sopenharmony_ci u32 cntrl_addr_reg; 14608c2ecf20Sopenharmony_ci }; 14618c2ecf20Sopenharmony_ci u32 rsvd_4; 14628c2ecf20Sopenharmony_ci }; 14638c2ecf20Sopenharmony_ci union { 14648c2ecf20Sopenharmony_ci struct { 14658c2ecf20Sopenharmony_ci u8 wr_byte0; 14668c2ecf20Sopenharmony_ci u8 wr_byte1; 14678c2ecf20Sopenharmony_ci u8 poll_mask; 14688c2ecf20Sopenharmony_ci u8 poll_cnt; 14698c2ecf20Sopenharmony_ci }; 14708c2ecf20Sopenharmony_ci u32 rsvd_5; 14718c2ecf20Sopenharmony_ci }; 14728c2ecf20Sopenharmony_ci u32 read_addr; 14738c2ecf20Sopenharmony_ci u32 read_data_size; 14748c2ecf20Sopenharmony_ci}; 14758c2ecf20Sopenharmony_ci 14768c2ecf20Sopenharmony_ci/* Read Cache L1 and L2 Header */ 14778c2ecf20Sopenharmony_cistruct netxen_minidump_entry_cache { 14788c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr h; 14798c2ecf20Sopenharmony_ci u32 tag_reg_addr; 14808c2ecf20Sopenharmony_ci union { 14818c2ecf20Sopenharmony_ci struct { 14828c2ecf20Sopenharmony_ci u16 tag_value_stride; 14838c2ecf20Sopenharmony_ci u16 init_tag_value; 14848c2ecf20Sopenharmony_ci }; 14858c2ecf20Sopenharmony_ci u32 select_addr_cntrl; 14868c2ecf20Sopenharmony_ci }; 14878c2ecf20Sopenharmony_ci u32 data_size; 14888c2ecf20Sopenharmony_ci u32 op_count; 14898c2ecf20Sopenharmony_ci u32 control_addr; 14908c2ecf20Sopenharmony_ci union { 14918c2ecf20Sopenharmony_ci struct { 14928c2ecf20Sopenharmony_ci u16 write_value; 14938c2ecf20Sopenharmony_ci u8 poll_mask; 14948c2ecf20Sopenharmony_ci u8 poll_wait; 14958c2ecf20Sopenharmony_ci }; 14968c2ecf20Sopenharmony_ci u32 control_value; 14978c2ecf20Sopenharmony_ci }; 14988c2ecf20Sopenharmony_ci u32 read_addr; 14998c2ecf20Sopenharmony_ci union { 15008c2ecf20Sopenharmony_ci struct { 15018c2ecf20Sopenharmony_ci u8 read_addr_stride; 15028c2ecf20Sopenharmony_ci u8 read_addr_cnt; 15038c2ecf20Sopenharmony_ci u16 rsvd_1; 15048c2ecf20Sopenharmony_ci }; 15058c2ecf20Sopenharmony_ci u32 read_addr_cntrl; 15068c2ecf20Sopenharmony_ci }; 15078c2ecf20Sopenharmony_ci}; 15088c2ecf20Sopenharmony_ci 15098c2ecf20Sopenharmony_ci/* Read OCM Header */ 15108c2ecf20Sopenharmony_cistruct netxen_minidump_entry_rdocm { 15118c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr h; 15128c2ecf20Sopenharmony_ci u32 rsvd_0; 15138c2ecf20Sopenharmony_ci union { 15148c2ecf20Sopenharmony_ci struct { 15158c2ecf20Sopenharmony_ci u32 rsvd_1; 15168c2ecf20Sopenharmony_ci }; 15178c2ecf20Sopenharmony_ci u32 select_addr_cntrl; 15188c2ecf20Sopenharmony_ci }; 15198c2ecf20Sopenharmony_ci u32 data_size; 15208c2ecf20Sopenharmony_ci u32 op_count; 15218c2ecf20Sopenharmony_ci u32 rsvd_2; 15228c2ecf20Sopenharmony_ci u32 rsvd_3; 15238c2ecf20Sopenharmony_ci u32 read_addr; 15248c2ecf20Sopenharmony_ci union { 15258c2ecf20Sopenharmony_ci struct { 15268c2ecf20Sopenharmony_ci u32 read_addr_stride; 15278c2ecf20Sopenharmony_ci }; 15288c2ecf20Sopenharmony_ci u32 read_addr_cntrl; 15298c2ecf20Sopenharmony_ci }; 15308c2ecf20Sopenharmony_ci}; 15318c2ecf20Sopenharmony_ci 15328c2ecf20Sopenharmony_ci/* Read MUX Header */ 15338c2ecf20Sopenharmony_cistruct netxen_minidump_entry_mux { 15348c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr h; 15358c2ecf20Sopenharmony_ci u32 select_addr; 15368c2ecf20Sopenharmony_ci union { 15378c2ecf20Sopenharmony_ci struct { 15388c2ecf20Sopenharmony_ci u32 rsvd_0; 15398c2ecf20Sopenharmony_ci }; 15408c2ecf20Sopenharmony_ci u32 select_addr_cntrl; 15418c2ecf20Sopenharmony_ci }; 15428c2ecf20Sopenharmony_ci u32 data_size; 15438c2ecf20Sopenharmony_ci u32 op_count; 15448c2ecf20Sopenharmony_ci u32 select_value; 15458c2ecf20Sopenharmony_ci u32 select_value_stride; 15468c2ecf20Sopenharmony_ci u32 read_addr; 15478c2ecf20Sopenharmony_ci u32 rsvd_1; 15488c2ecf20Sopenharmony_ci}; 15498c2ecf20Sopenharmony_ci 15508c2ecf20Sopenharmony_ci/* Read Queue Header */ 15518c2ecf20Sopenharmony_cistruct netxen_minidump_entry_queue { 15528c2ecf20Sopenharmony_ci struct netxen_common_entry_hdr h; 15538c2ecf20Sopenharmony_ci u32 select_addr; 15548c2ecf20Sopenharmony_ci union { 15558c2ecf20Sopenharmony_ci struct { 15568c2ecf20Sopenharmony_ci u16 queue_id_stride; 15578c2ecf20Sopenharmony_ci u16 rsvd_0; 15588c2ecf20Sopenharmony_ci }; 15598c2ecf20Sopenharmony_ci u32 select_addr_cntrl; 15608c2ecf20Sopenharmony_ci }; 15618c2ecf20Sopenharmony_ci u32 data_size; 15628c2ecf20Sopenharmony_ci u32 op_count; 15638c2ecf20Sopenharmony_ci u32 rsvd_1; 15648c2ecf20Sopenharmony_ci u32 rsvd_2; 15658c2ecf20Sopenharmony_ci u32 read_addr; 15668c2ecf20Sopenharmony_ci union { 15678c2ecf20Sopenharmony_ci struct { 15688c2ecf20Sopenharmony_ci u8 read_addr_stride; 15698c2ecf20Sopenharmony_ci u8 read_addr_cnt; 15708c2ecf20Sopenharmony_ci u16 rsvd_3; 15718c2ecf20Sopenharmony_ci }; 15728c2ecf20Sopenharmony_ci u32 read_addr_cntrl; 15738c2ecf20Sopenharmony_ci }; 15748c2ecf20Sopenharmony_ci}; 15758c2ecf20Sopenharmony_ci 15768c2ecf20Sopenharmony_cistruct netxen_dummy_dma { 15778c2ecf20Sopenharmony_ci void *addr; 15788c2ecf20Sopenharmony_ci dma_addr_t phys_addr; 15798c2ecf20Sopenharmony_ci}; 15808c2ecf20Sopenharmony_ci 15818c2ecf20Sopenharmony_cistruct netxen_adapter { 15828c2ecf20Sopenharmony_ci struct netxen_hardware_context ahw; 15838c2ecf20Sopenharmony_ci 15848c2ecf20Sopenharmony_ci struct net_device *netdev; 15858c2ecf20Sopenharmony_ci struct pci_dev *pdev; 15868c2ecf20Sopenharmony_ci struct list_head mac_list; 15878c2ecf20Sopenharmony_ci struct list_head ip_list; 15888c2ecf20Sopenharmony_ci 15898c2ecf20Sopenharmony_ci spinlock_t tx_clean_lock; 15908c2ecf20Sopenharmony_ci 15918c2ecf20Sopenharmony_ci u16 num_txd; 15928c2ecf20Sopenharmony_ci u16 num_rxd; 15938c2ecf20Sopenharmony_ci u16 num_jumbo_rxd; 15948c2ecf20Sopenharmony_ci u16 num_lro_rxd; 15958c2ecf20Sopenharmony_ci 15968c2ecf20Sopenharmony_ci u8 max_rds_rings; 15978c2ecf20Sopenharmony_ci u8 max_sds_rings; 15988c2ecf20Sopenharmony_ci u8 driver_mismatch; 15998c2ecf20Sopenharmony_ci u8 msix_supported; 16008c2ecf20Sopenharmony_ci u8 __pad; 16018c2ecf20Sopenharmony_ci u8 pci_using_dac; 16028c2ecf20Sopenharmony_ci u8 portnum; 16038c2ecf20Sopenharmony_ci u8 physical_port; 16048c2ecf20Sopenharmony_ci 16058c2ecf20Sopenharmony_ci u8 mc_enabled; 16068c2ecf20Sopenharmony_ci u8 max_mc_count; 16078c2ecf20Sopenharmony_ci u8 rss_supported; 16088c2ecf20Sopenharmony_ci u8 link_changed; 16098c2ecf20Sopenharmony_ci u8 fw_wait_cnt; 16108c2ecf20Sopenharmony_ci u8 fw_fail_cnt; 16118c2ecf20Sopenharmony_ci u8 tx_timeo_cnt; 16128c2ecf20Sopenharmony_ci u8 need_fw_reset; 16138c2ecf20Sopenharmony_ci 16148c2ecf20Sopenharmony_ci u8 has_link_events; 16158c2ecf20Sopenharmony_ci u8 fw_type; 16168c2ecf20Sopenharmony_ci u16 tx_context_id; 16178c2ecf20Sopenharmony_ci u16 mtu; 16188c2ecf20Sopenharmony_ci u16 is_up; 16198c2ecf20Sopenharmony_ci 16208c2ecf20Sopenharmony_ci u16 link_speed; 16218c2ecf20Sopenharmony_ci u16 link_duplex; 16228c2ecf20Sopenharmony_ci u16 link_autoneg; 16238c2ecf20Sopenharmony_ci u16 module_type; 16248c2ecf20Sopenharmony_ci 16258c2ecf20Sopenharmony_ci u32 capabilities; 16268c2ecf20Sopenharmony_ci u32 flags; 16278c2ecf20Sopenharmony_ci u32 irq; 16288c2ecf20Sopenharmony_ci u32 temp; 16298c2ecf20Sopenharmony_ci 16308c2ecf20Sopenharmony_ci u32 int_vec_bit; 16318c2ecf20Sopenharmony_ci u32 heartbit; 16328c2ecf20Sopenharmony_ci 16338c2ecf20Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 16348c2ecf20Sopenharmony_ci 16358c2ecf20Sopenharmony_ci struct netxen_adapter_stats stats; 16368c2ecf20Sopenharmony_ci 16378c2ecf20Sopenharmony_ci struct netxen_recv_context recv_ctx; 16388c2ecf20Sopenharmony_ci struct nx_host_tx_ring *tx_ring; 16398c2ecf20Sopenharmony_ci 16408c2ecf20Sopenharmony_ci int (*macaddr_set) (struct netxen_adapter *, u8 *); 16418c2ecf20Sopenharmony_ci int (*set_mtu) (struct netxen_adapter *, int); 16428c2ecf20Sopenharmony_ci int (*set_promisc) (struct netxen_adapter *, u32); 16438c2ecf20Sopenharmony_ci void (*set_multi) (struct net_device *); 16448c2ecf20Sopenharmony_ci int (*phy_read) (struct netxen_adapter *, u32 reg, u32 *); 16458c2ecf20Sopenharmony_ci int (*phy_write) (struct netxen_adapter *, u32 reg, u32 val); 16468c2ecf20Sopenharmony_ci int (*init_port) (struct netxen_adapter *, int); 16478c2ecf20Sopenharmony_ci int (*stop_port) (struct netxen_adapter *); 16488c2ecf20Sopenharmony_ci 16498c2ecf20Sopenharmony_ci u32 (*crb_read)(struct netxen_adapter *, ulong); 16508c2ecf20Sopenharmony_ci int (*crb_write)(struct netxen_adapter *, ulong, u32); 16518c2ecf20Sopenharmony_ci 16528c2ecf20Sopenharmony_ci int (*pci_mem_read)(struct netxen_adapter *, u64, u64 *); 16538c2ecf20Sopenharmony_ci int (*pci_mem_write)(struct netxen_adapter *, u64, u64); 16548c2ecf20Sopenharmony_ci 16558c2ecf20Sopenharmony_ci int (*pci_set_window)(struct netxen_adapter *, u64, u32 *); 16568c2ecf20Sopenharmony_ci 16578c2ecf20Sopenharmony_ci u32 (*io_read)(struct netxen_adapter *, void __iomem *); 16588c2ecf20Sopenharmony_ci void (*io_write)(struct netxen_adapter *, void __iomem *, u32); 16598c2ecf20Sopenharmony_ci 16608c2ecf20Sopenharmony_ci void __iomem *tgt_mask_reg; 16618c2ecf20Sopenharmony_ci void __iomem *pci_int_reg; 16628c2ecf20Sopenharmony_ci void __iomem *tgt_status_reg; 16638c2ecf20Sopenharmony_ci void __iomem *crb_int_state_reg; 16648c2ecf20Sopenharmony_ci void __iomem *isr_int_vec; 16658c2ecf20Sopenharmony_ci 16668c2ecf20Sopenharmony_ci struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER]; 16678c2ecf20Sopenharmony_ci 16688c2ecf20Sopenharmony_ci struct netxen_dummy_dma dummy_dma; 16698c2ecf20Sopenharmony_ci 16708c2ecf20Sopenharmony_ci struct delayed_work fw_work; 16718c2ecf20Sopenharmony_ci 16728c2ecf20Sopenharmony_ci struct work_struct tx_timeout_task; 16738c2ecf20Sopenharmony_ci 16748c2ecf20Sopenharmony_ci nx_nic_intr_coalesce_t coal; 16758c2ecf20Sopenharmony_ci 16768c2ecf20Sopenharmony_ci unsigned long state; 16778c2ecf20Sopenharmony_ci __le32 file_prd_off; /*File fw product offset*/ 16788c2ecf20Sopenharmony_ci u32 fw_version; 16798c2ecf20Sopenharmony_ci const struct firmware *fw; 16808c2ecf20Sopenharmony_ci struct netxen_minidump mdump; /* mdump ptr */ 16818c2ecf20Sopenharmony_ci int fw_mdump_rdy; /* for mdump ready */ 16828c2ecf20Sopenharmony_ci}; 16838c2ecf20Sopenharmony_ci 16848c2ecf20Sopenharmony_ciint nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val); 16858c2ecf20Sopenharmony_ciint nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val); 16868c2ecf20Sopenharmony_ci 16878c2ecf20Sopenharmony_ci#define NXRD32(adapter, off) \ 16888c2ecf20Sopenharmony_ci (adapter->crb_read(adapter, off)) 16898c2ecf20Sopenharmony_ci#define NXWR32(adapter, off, val) \ 16908c2ecf20Sopenharmony_ci (adapter->crb_write(adapter, off, val)) 16918c2ecf20Sopenharmony_ci#define NXRDIO(adapter, addr) \ 16928c2ecf20Sopenharmony_ci (adapter->io_read(adapter, addr)) 16938c2ecf20Sopenharmony_ci#define NXWRIO(adapter, addr, val) \ 16948c2ecf20Sopenharmony_ci (adapter->io_write(adapter, addr, val)) 16958c2ecf20Sopenharmony_ci 16968c2ecf20Sopenharmony_ciint netxen_pcie_sem_lock(struct netxen_adapter *, int, u32); 16978c2ecf20Sopenharmony_civoid netxen_pcie_sem_unlock(struct netxen_adapter *, int); 16988c2ecf20Sopenharmony_ci 16998c2ecf20Sopenharmony_ci#define netxen_rom_lock(a) \ 17008c2ecf20Sopenharmony_ci netxen_pcie_sem_lock((a), 2, NETXEN_ROM_LOCK_ID) 17018c2ecf20Sopenharmony_ci#define netxen_rom_unlock(a) \ 17028c2ecf20Sopenharmony_ci netxen_pcie_sem_unlock((a), 2) 17038c2ecf20Sopenharmony_ci#define netxen_phy_lock(a) \ 17048c2ecf20Sopenharmony_ci netxen_pcie_sem_lock((a), 3, NETXEN_PHY_LOCK_ID) 17058c2ecf20Sopenharmony_ci#define netxen_phy_unlock(a) \ 17068c2ecf20Sopenharmony_ci netxen_pcie_sem_unlock((a), 3) 17078c2ecf20Sopenharmony_ci#define netxen_api_lock(a) \ 17088c2ecf20Sopenharmony_ci netxen_pcie_sem_lock((a), 5, 0) 17098c2ecf20Sopenharmony_ci#define netxen_api_unlock(a) \ 17108c2ecf20Sopenharmony_ci netxen_pcie_sem_unlock((a), 5) 17118c2ecf20Sopenharmony_ci#define netxen_sw_lock(a) \ 17128c2ecf20Sopenharmony_ci netxen_pcie_sem_lock((a), 6, 0) 17138c2ecf20Sopenharmony_ci#define netxen_sw_unlock(a) \ 17148c2ecf20Sopenharmony_ci netxen_pcie_sem_unlock((a), 6) 17158c2ecf20Sopenharmony_ci#define crb_win_lock(a) \ 17168c2ecf20Sopenharmony_ci netxen_pcie_sem_lock((a), 7, NETXEN_CRB_WIN_LOCK_ID) 17178c2ecf20Sopenharmony_ci#define crb_win_unlock(a) \ 17188c2ecf20Sopenharmony_ci netxen_pcie_sem_unlock((a), 7) 17198c2ecf20Sopenharmony_ci 17208c2ecf20Sopenharmony_ciint netxen_nic_get_board_info(struct netxen_adapter *adapter); 17218c2ecf20Sopenharmony_ciint netxen_nic_wol_supported(struct netxen_adapter *adapter); 17228c2ecf20Sopenharmony_ci 17238c2ecf20Sopenharmony_ci/* Functions from netxen_nic_init.c */ 17248c2ecf20Sopenharmony_ciint netxen_init_dummy_dma(struct netxen_adapter *adapter); 17258c2ecf20Sopenharmony_civoid netxen_free_dummy_dma(struct netxen_adapter *adapter); 17268c2ecf20Sopenharmony_ci 17278c2ecf20Sopenharmony_ciint netxen_check_flash_fw_compatibility(struct netxen_adapter *adapter); 17288c2ecf20Sopenharmony_ciint netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); 17298c2ecf20Sopenharmony_ciint netxen_load_firmware(struct netxen_adapter *adapter); 17308c2ecf20Sopenharmony_ciint netxen_need_fw_reset(struct netxen_adapter *adapter); 17318c2ecf20Sopenharmony_civoid netxen_request_firmware(struct netxen_adapter *adapter); 17328c2ecf20Sopenharmony_civoid netxen_release_firmware(struct netxen_adapter *adapter); 17338c2ecf20Sopenharmony_ciint netxen_pinit_from_rom(struct netxen_adapter *adapter); 17348c2ecf20Sopenharmony_ci 17358c2ecf20Sopenharmony_ciint netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp); 17368c2ecf20Sopenharmony_ciint netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, 17378c2ecf20Sopenharmony_ci u8 *bytes, size_t size); 17388c2ecf20Sopenharmony_ciint netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, 17398c2ecf20Sopenharmony_ci u8 *bytes, size_t size); 17408c2ecf20Sopenharmony_ciint netxen_flash_unlock(struct netxen_adapter *adapter); 17418c2ecf20Sopenharmony_ciint netxen_backup_crbinit(struct netxen_adapter *adapter); 17428c2ecf20Sopenharmony_ciint netxen_flash_erase_secondary(struct netxen_adapter *adapter); 17438c2ecf20Sopenharmony_ciint netxen_flash_erase_primary(struct netxen_adapter *adapter); 17448c2ecf20Sopenharmony_civoid netxen_halt_pegs(struct netxen_adapter *adapter); 17458c2ecf20Sopenharmony_ci 17468c2ecf20Sopenharmony_ciint netxen_rom_se(struct netxen_adapter *adapter, int addr); 17478c2ecf20Sopenharmony_ci 17488c2ecf20Sopenharmony_ciint netxen_alloc_sw_resources(struct netxen_adapter *adapter); 17498c2ecf20Sopenharmony_civoid netxen_free_sw_resources(struct netxen_adapter *adapter); 17508c2ecf20Sopenharmony_ci 17518c2ecf20Sopenharmony_civoid netxen_setup_hwops(struct netxen_adapter *adapter); 17528c2ecf20Sopenharmony_civoid __iomem *netxen_get_ioaddr(struct netxen_adapter *, u32); 17538c2ecf20Sopenharmony_ci 17548c2ecf20Sopenharmony_ciint netxen_alloc_hw_resources(struct netxen_adapter *adapter); 17558c2ecf20Sopenharmony_civoid netxen_free_hw_resources(struct netxen_adapter *adapter); 17568c2ecf20Sopenharmony_ci 17578c2ecf20Sopenharmony_civoid netxen_release_rx_buffers(struct netxen_adapter *adapter); 17588c2ecf20Sopenharmony_civoid netxen_release_tx_buffers(struct netxen_adapter *adapter); 17598c2ecf20Sopenharmony_ci 17608c2ecf20Sopenharmony_ciint netxen_init_firmware(struct netxen_adapter *adapter); 17618c2ecf20Sopenharmony_civoid netxen_nic_clear_stats(struct netxen_adapter *adapter); 17628c2ecf20Sopenharmony_civoid netxen_watchdog_task(struct work_struct *work); 17638c2ecf20Sopenharmony_civoid netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid, 17648c2ecf20Sopenharmony_ci struct nx_host_rds_ring *rds_ring); 17658c2ecf20Sopenharmony_ciint netxen_process_cmd_ring(struct netxen_adapter *adapter); 17668c2ecf20Sopenharmony_ciint netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max); 17678c2ecf20Sopenharmony_ci 17688c2ecf20Sopenharmony_civoid netxen_p3_free_mac_list(struct netxen_adapter *adapter); 17698c2ecf20Sopenharmony_ciint netxen_config_intr_coalesce(struct netxen_adapter *adapter); 17708c2ecf20Sopenharmony_ciint netxen_config_rss(struct netxen_adapter *adapter, int enable); 17718c2ecf20Sopenharmony_ciint netxen_config_ipaddr(struct netxen_adapter *adapter, __be32 ip, int cmd); 17728c2ecf20Sopenharmony_ciint netxen_linkevent_request(struct netxen_adapter *adapter, int enable); 17738c2ecf20Sopenharmony_civoid netxen_advert_link_change(struct netxen_adapter *adapter, int linkup); 17748c2ecf20Sopenharmony_civoid netxen_pci_camqm_read_2M(struct netxen_adapter *, u64, u64 *); 17758c2ecf20Sopenharmony_civoid netxen_pci_camqm_write_2M(struct netxen_adapter *, u64, u64); 17768c2ecf20Sopenharmony_ci 17778c2ecf20Sopenharmony_ciint nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter, 17788c2ecf20Sopenharmony_ci u32 speed, u32 duplex, u32 autoneg); 17798c2ecf20Sopenharmony_ciint nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu); 17808c2ecf20Sopenharmony_ciint netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); 17818c2ecf20Sopenharmony_ciint netxen_config_hw_lro(struct netxen_adapter *adapter, int enable); 17828c2ecf20Sopenharmony_ciint netxen_config_bridged_mode(struct netxen_adapter *adapter, int enable); 17838c2ecf20Sopenharmony_ciint netxen_send_lro_cleanup(struct netxen_adapter *adapter); 17848c2ecf20Sopenharmony_ciint netxen_setup_minidump(struct netxen_adapter *adapter); 17858c2ecf20Sopenharmony_civoid netxen_dump_fw(struct netxen_adapter *adapter); 17868c2ecf20Sopenharmony_civoid netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, 17878c2ecf20Sopenharmony_ci struct nx_host_tx_ring *tx_ring); 17888c2ecf20Sopenharmony_ci 17898c2ecf20Sopenharmony_ci/* Functions from netxen_nic_main.c */ 17908c2ecf20Sopenharmony_ciint netxen_nic_reset_context(struct netxen_adapter *); 17918c2ecf20Sopenharmony_ci 17928c2ecf20Sopenharmony_ciint nx_dev_request_reset(struct netxen_adapter *adapter); 17938c2ecf20Sopenharmony_ci 17948c2ecf20Sopenharmony_ci/* 17958c2ecf20Sopenharmony_ci * NetXen Board information 17968c2ecf20Sopenharmony_ci */ 17978c2ecf20Sopenharmony_ci 17988c2ecf20Sopenharmony_ci#define NETXEN_MAX_SHORT_NAME 32 17998c2ecf20Sopenharmony_cistruct netxen_brdinfo { 18008c2ecf20Sopenharmony_ci int brdtype; /* type of board */ 18018c2ecf20Sopenharmony_ci long ports; /* max no of physical ports */ 18028c2ecf20Sopenharmony_ci char short_name[NETXEN_MAX_SHORT_NAME]; 18038c2ecf20Sopenharmony_ci}; 18048c2ecf20Sopenharmony_ci 18058c2ecf20Sopenharmony_cistruct netxen_dimm_cfg { 18068c2ecf20Sopenharmony_ci u8 presence; 18078c2ecf20Sopenharmony_ci u8 mem_type; 18088c2ecf20Sopenharmony_ci u8 dimm_type; 18098c2ecf20Sopenharmony_ci u32 size; 18108c2ecf20Sopenharmony_ci}; 18118c2ecf20Sopenharmony_ci 18128c2ecf20Sopenharmony_cistatic const struct netxen_brdinfo netxen_boards[] = { 18138c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"}, 18148c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"}, 18158c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"}, 18168c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"}, 18178c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"}, 18188c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"}, 18198c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_REF_QG, 4, "Reference Quad Gig "}, 18208c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_HMEZ, 2, "Dual XGb HMEZ"}, 18218c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_10G_CX4_LP, 2, "Dual XGb CX4 LP"}, 18228c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_4_GB, 4, "Quad Gig LP"}, 18238c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_IMEZ, 2, "Dual XGb IMEZ"}, 18248c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_10G_SFP_PLUS, 2, "Dual XGb SFP+ LP"}, 18258c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_10000_BASE_T, 1, "XGB 10G BaseT LP"}, 18268c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_XG_LOM, 2, "Dual XGb LOM"}, 18278c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_4_GB_MM, 4, "NX3031 Gigabit Ethernet"}, 18288c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_10G_SFP_CT, 2, "NX3031 10 Gigabit Ethernet"}, 18298c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_10G_SFP_QT, 2, "Quanta Dual XGb SFP+"}, 18308c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_10G_CX4, 2, "Reference Dual CX4 Option"}, 18318c2ecf20Sopenharmony_ci {NETXEN_BRDTYPE_P3_10G_XFP, 1, "Reference Single XFP Option"} 18328c2ecf20Sopenharmony_ci}; 18338c2ecf20Sopenharmony_ci 18348c2ecf20Sopenharmony_ci#define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards) 18358c2ecf20Sopenharmony_ci 18368c2ecf20Sopenharmony_cistatic inline int netxen_nic_get_brd_name_by_type(u32 type, char *name) 18378c2ecf20Sopenharmony_ci{ 18388c2ecf20Sopenharmony_ci int i, found = 0; 18398c2ecf20Sopenharmony_ci for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) { 18408c2ecf20Sopenharmony_ci if (netxen_boards[i].brdtype == type) { 18418c2ecf20Sopenharmony_ci strcpy(name, netxen_boards[i].short_name); 18428c2ecf20Sopenharmony_ci found = 1; 18438c2ecf20Sopenharmony_ci break; 18448c2ecf20Sopenharmony_ci } 18458c2ecf20Sopenharmony_ci } 18468c2ecf20Sopenharmony_ci 18478c2ecf20Sopenharmony_ci if (!found) { 18488c2ecf20Sopenharmony_ci strcpy(name, "Unknown"); 18498c2ecf20Sopenharmony_ci return -EINVAL; 18508c2ecf20Sopenharmony_ci } 18518c2ecf20Sopenharmony_ci 18528c2ecf20Sopenharmony_ci return 0; 18538c2ecf20Sopenharmony_ci} 18548c2ecf20Sopenharmony_ci 18558c2ecf20Sopenharmony_cistatic inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring) 18568c2ecf20Sopenharmony_ci{ 18578c2ecf20Sopenharmony_ci smp_mb(); 18588c2ecf20Sopenharmony_ci return find_diff_among(tx_ring->producer, 18598c2ecf20Sopenharmony_ci tx_ring->sw_consumer, tx_ring->num_desc); 18608c2ecf20Sopenharmony_ci 18618c2ecf20Sopenharmony_ci} 18628c2ecf20Sopenharmony_ci 18638c2ecf20Sopenharmony_ciint netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 *mac); 18648c2ecf20Sopenharmony_ciint netxen_p3_get_mac_addr(struct netxen_adapter *adapter, u64 *mac); 18658c2ecf20Sopenharmony_civoid netxen_change_ringparam(struct netxen_adapter *adapter); 18668c2ecf20Sopenharmony_ciint netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp); 18678c2ecf20Sopenharmony_ci 18688c2ecf20Sopenharmony_ciextern const struct ethtool_ops netxen_nic_ethtool_ops; 18698c2ecf20Sopenharmony_ci 18708c2ecf20Sopenharmony_ci#endif /* __NETXEN_NIC_H_ */ 1871