18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 58c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 68c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 78c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 88c2ecf20Sopenharmony_ci * OpenIB.org BSD license below: 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or 118c2ecf20Sopenharmony_ci * without modification, are permitted provided that the following 128c2ecf20Sopenharmony_ci * conditions are met: 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above 158c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 168c2ecf20Sopenharmony_ci * disclaimer. 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above 198c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 208c2ecf20Sopenharmony_ci * disclaimer in the documentation and/or other materials 218c2ecf20Sopenharmony_ci * provided with the distribution. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 248c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 258c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 268c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 278c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 288c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 298c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 308c2ecf20Sopenharmony_ci * SOFTWARE. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci#ifndef __CHELSIO_COMMON_H 338c2ecf20Sopenharmony_ci#define __CHELSIO_COMMON_H 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#include <linux/kernel.h> 368c2ecf20Sopenharmony_ci#include <linux/types.h> 378c2ecf20Sopenharmony_ci#include <linux/ctype.h> 388c2ecf20Sopenharmony_ci#include <linux/delay.h> 398c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 408c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 418c2ecf20Sopenharmony_ci#include <linux/mdio.h> 428c2ecf20Sopenharmony_ci#include "version.h" 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ##__VA_ARGS__) 458c2ecf20Sopenharmony_ci#define CH_WARN(adap, fmt, ...) dev_warn(&adap->pdev->dev, fmt, ##__VA_ARGS__) 468c2ecf20Sopenharmony_ci#define CH_ALERT(adap, fmt, ...) dev_alert(&adap->pdev->dev, fmt, ##__VA_ARGS__) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* 498c2ecf20Sopenharmony_ci * More powerful macro that selectively prints messages based on msg_enable. 508c2ecf20Sopenharmony_ci * For info and debugging messages. 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci#define CH_MSG(adapter, level, category, fmt, ...) do { \ 538c2ecf20Sopenharmony_ci if ((adapter)->msg_enable & NETIF_MSG_##category) \ 548c2ecf20Sopenharmony_ci dev_printk(KERN_##level, &adapter->pdev->dev, fmt, \ 558c2ecf20Sopenharmony_ci ## __VA_ARGS__); \ 568c2ecf20Sopenharmony_ci} while (0) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#ifdef DEBUG 598c2ecf20Sopenharmony_ci# define CH_DBG(adapter, category, fmt, ...) \ 608c2ecf20Sopenharmony_ci CH_MSG(adapter, DEBUG, category, fmt, ## __VA_ARGS__) 618c2ecf20Sopenharmony_ci#else 628c2ecf20Sopenharmony_ci# define CH_DBG(adapter, category, fmt, ...) 638c2ecf20Sopenharmony_ci#endif 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Additional NETIF_MSG_* categories */ 668c2ecf20Sopenharmony_ci#define NETIF_MSG_MMIO 0x8000000 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cienum { 698c2ecf20Sopenharmony_ci MAX_NPORTS = 2, /* max # of ports */ 708c2ecf20Sopenharmony_ci MAX_FRAME_SIZE = 10240, /* max MAC frame size, including header + FCS */ 718c2ecf20Sopenharmony_ci EEPROMSIZE = 8192, /* Serial EEPROM size */ 728c2ecf20Sopenharmony_ci SERNUM_LEN = 16, /* Serial # length */ 738c2ecf20Sopenharmony_ci RSS_TABLE_SIZE = 64, /* size of RSS lookup and mapping tables */ 748c2ecf20Sopenharmony_ci TCB_SIZE = 128, /* TCB size */ 758c2ecf20Sopenharmony_ci NMTUS = 16, /* size of MTU table */ 768c2ecf20Sopenharmony_ci NCCTRL_WIN = 32, /* # of congestion control windows */ 778c2ecf20Sopenharmony_ci PROTO_SRAM_LINES = 128, /* size of TP sram */ 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define MAX_RX_COALESCING_LEN 12288U 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cienum { 838c2ecf20Sopenharmony_ci PAUSE_RX = 1 << 0, 848c2ecf20Sopenharmony_ci PAUSE_TX = 1 << 1, 858c2ecf20Sopenharmony_ci PAUSE_AUTONEG = 1 << 2 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cienum { 898c2ecf20Sopenharmony_ci SUPPORTED_IRQ = 1 << 24 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cienum { /* adapter interrupt-maintained statistics */ 938c2ecf20Sopenharmony_ci STAT_ULP_CH0_PBL_OOB, 948c2ecf20Sopenharmony_ci STAT_ULP_CH1_PBL_OOB, 958c2ecf20Sopenharmony_ci STAT_PCI_CORR_ECC, 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci IRQ_NUM_STATS /* keep last */ 988c2ecf20Sopenharmony_ci}; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define TP_VERSION_MAJOR 1 1018c2ecf20Sopenharmony_ci#define TP_VERSION_MINOR 1 1028c2ecf20Sopenharmony_ci#define TP_VERSION_MICRO 0 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#define S_TP_VERSION_MAJOR 16 1058c2ecf20Sopenharmony_ci#define M_TP_VERSION_MAJOR 0xFF 1068c2ecf20Sopenharmony_ci#define V_TP_VERSION_MAJOR(x) ((x) << S_TP_VERSION_MAJOR) 1078c2ecf20Sopenharmony_ci#define G_TP_VERSION_MAJOR(x) \ 1088c2ecf20Sopenharmony_ci (((x) >> S_TP_VERSION_MAJOR) & M_TP_VERSION_MAJOR) 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci#define S_TP_VERSION_MINOR 8 1118c2ecf20Sopenharmony_ci#define M_TP_VERSION_MINOR 0xFF 1128c2ecf20Sopenharmony_ci#define V_TP_VERSION_MINOR(x) ((x) << S_TP_VERSION_MINOR) 1138c2ecf20Sopenharmony_ci#define G_TP_VERSION_MINOR(x) \ 1148c2ecf20Sopenharmony_ci (((x) >> S_TP_VERSION_MINOR) & M_TP_VERSION_MINOR) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define S_TP_VERSION_MICRO 0 1178c2ecf20Sopenharmony_ci#define M_TP_VERSION_MICRO 0xFF 1188c2ecf20Sopenharmony_ci#define V_TP_VERSION_MICRO(x) ((x) << S_TP_VERSION_MICRO) 1198c2ecf20Sopenharmony_ci#define G_TP_VERSION_MICRO(x) \ 1208c2ecf20Sopenharmony_ci (((x) >> S_TP_VERSION_MICRO) & M_TP_VERSION_MICRO) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cienum { 1238c2ecf20Sopenharmony_ci SGE_QSETS = 8, /* # of SGE Tx/Rx/RspQ sets */ 1248c2ecf20Sopenharmony_ci SGE_RXQ_PER_SET = 2, /* # of Rx queues per set */ 1258c2ecf20Sopenharmony_ci SGE_TXQ_PER_SET = 3 /* # of Tx queues per set */ 1268c2ecf20Sopenharmony_ci}; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cienum sge_context_type { /* SGE egress context types */ 1298c2ecf20Sopenharmony_ci SGE_CNTXT_RDMA = 0, 1308c2ecf20Sopenharmony_ci SGE_CNTXT_ETH = 2, 1318c2ecf20Sopenharmony_ci SGE_CNTXT_OFLD = 4, 1328c2ecf20Sopenharmony_ci SGE_CNTXT_CTRL = 5 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cienum { 1368c2ecf20Sopenharmony_ci AN_PKT_SIZE = 32, /* async notification packet size */ 1378c2ecf20Sopenharmony_ci IMMED_PKT_SIZE = 48 /* packet size for immediate data */ 1388c2ecf20Sopenharmony_ci}; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cistruct sg_ent { /* SGE scatter/gather entry */ 1418c2ecf20Sopenharmony_ci __be32 len[2]; 1428c2ecf20Sopenharmony_ci __be64 addr[2]; 1438c2ecf20Sopenharmony_ci}; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci#ifndef SGE_NUM_GENBITS 1468c2ecf20Sopenharmony_ci/* Must be 1 or 2 */ 1478c2ecf20Sopenharmony_ci# define SGE_NUM_GENBITS 2 1488c2ecf20Sopenharmony_ci#endif 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci#define TX_DESC_FLITS 16U 1518c2ecf20Sopenharmony_ci#define WR_FLITS (TX_DESC_FLITS + 1 - SGE_NUM_GENBITS) 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_cistruct cphy; 1548c2ecf20Sopenharmony_cistruct adapter; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistruct mdio_ops { 1578c2ecf20Sopenharmony_ci int (*read)(struct net_device *dev, int phy_addr, int mmd_addr, 1588c2ecf20Sopenharmony_ci u16 reg_addr); 1598c2ecf20Sopenharmony_ci int (*write)(struct net_device *dev, int phy_addr, int mmd_addr, 1608c2ecf20Sopenharmony_ci u16 reg_addr, u16 val); 1618c2ecf20Sopenharmony_ci unsigned mode_support; 1628c2ecf20Sopenharmony_ci}; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_cistruct adapter_info { 1658c2ecf20Sopenharmony_ci unsigned char nports0; /* # of ports on channel 0 */ 1668c2ecf20Sopenharmony_ci unsigned char nports1; /* # of ports on channel 1 */ 1678c2ecf20Sopenharmony_ci unsigned char phy_base_addr; /* MDIO PHY base address */ 1688c2ecf20Sopenharmony_ci unsigned int gpio_out; /* GPIO output settings */ 1698c2ecf20Sopenharmony_ci unsigned char gpio_intr[MAX_NPORTS]; /* GPIO PHY IRQ pins */ 1708c2ecf20Sopenharmony_ci unsigned long caps; /* adapter capabilities */ 1718c2ecf20Sopenharmony_ci const struct mdio_ops *mdio_ops; /* MDIO operations */ 1728c2ecf20Sopenharmony_ci const char *desc; /* product description */ 1738c2ecf20Sopenharmony_ci}; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_cistruct mc5_stats { 1768c2ecf20Sopenharmony_ci unsigned long parity_err; 1778c2ecf20Sopenharmony_ci unsigned long active_rgn_full; 1788c2ecf20Sopenharmony_ci unsigned long nfa_srch_err; 1798c2ecf20Sopenharmony_ci unsigned long unknown_cmd; 1808c2ecf20Sopenharmony_ci unsigned long reqq_parity_err; 1818c2ecf20Sopenharmony_ci unsigned long dispq_parity_err; 1828c2ecf20Sopenharmony_ci unsigned long del_act_empty; 1838c2ecf20Sopenharmony_ci}; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_cistruct mc7_stats { 1868c2ecf20Sopenharmony_ci unsigned long corr_err; 1878c2ecf20Sopenharmony_ci unsigned long uncorr_err; 1888c2ecf20Sopenharmony_ci unsigned long parity_err; 1898c2ecf20Sopenharmony_ci unsigned long addr_err; 1908c2ecf20Sopenharmony_ci}; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_cistruct mac_stats { 1938c2ecf20Sopenharmony_ci u64 tx_octets; /* total # of octets in good frames */ 1948c2ecf20Sopenharmony_ci u64 tx_octets_bad; /* total # of octets in error frames */ 1958c2ecf20Sopenharmony_ci u64 tx_frames; /* all good frames */ 1968c2ecf20Sopenharmony_ci u64 tx_mcast_frames; /* good multicast frames */ 1978c2ecf20Sopenharmony_ci u64 tx_bcast_frames; /* good broadcast frames */ 1988c2ecf20Sopenharmony_ci u64 tx_pause; /* # of transmitted pause frames */ 1998c2ecf20Sopenharmony_ci u64 tx_deferred; /* frames with deferred transmissions */ 2008c2ecf20Sopenharmony_ci u64 tx_late_collisions; /* # of late collisions */ 2018c2ecf20Sopenharmony_ci u64 tx_total_collisions; /* # of total collisions */ 2028c2ecf20Sopenharmony_ci u64 tx_excess_collisions; /* frame errors from excessive collissions */ 2038c2ecf20Sopenharmony_ci u64 tx_underrun; /* # of Tx FIFO underruns */ 2048c2ecf20Sopenharmony_ci u64 tx_len_errs; /* # of Tx length errors */ 2058c2ecf20Sopenharmony_ci u64 tx_mac_internal_errs; /* # of internal MAC errors on Tx */ 2068c2ecf20Sopenharmony_ci u64 tx_excess_deferral; /* # of frames with excessive deferral */ 2078c2ecf20Sopenharmony_ci u64 tx_fcs_errs; /* # of frames with bad FCS */ 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci u64 tx_frames_64; /* # of Tx frames in a particular range */ 2108c2ecf20Sopenharmony_ci u64 tx_frames_65_127; 2118c2ecf20Sopenharmony_ci u64 tx_frames_128_255; 2128c2ecf20Sopenharmony_ci u64 tx_frames_256_511; 2138c2ecf20Sopenharmony_ci u64 tx_frames_512_1023; 2148c2ecf20Sopenharmony_ci u64 tx_frames_1024_1518; 2158c2ecf20Sopenharmony_ci u64 tx_frames_1519_max; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci u64 rx_octets; /* total # of octets in good frames */ 2188c2ecf20Sopenharmony_ci u64 rx_octets_bad; /* total # of octets in error frames */ 2198c2ecf20Sopenharmony_ci u64 rx_frames; /* all good frames */ 2208c2ecf20Sopenharmony_ci u64 rx_mcast_frames; /* good multicast frames */ 2218c2ecf20Sopenharmony_ci u64 rx_bcast_frames; /* good broadcast frames */ 2228c2ecf20Sopenharmony_ci u64 rx_pause; /* # of received pause frames */ 2238c2ecf20Sopenharmony_ci u64 rx_fcs_errs; /* # of received frames with bad FCS */ 2248c2ecf20Sopenharmony_ci u64 rx_align_errs; /* alignment errors */ 2258c2ecf20Sopenharmony_ci u64 rx_symbol_errs; /* symbol errors */ 2268c2ecf20Sopenharmony_ci u64 rx_data_errs; /* data errors */ 2278c2ecf20Sopenharmony_ci u64 rx_sequence_errs; /* sequence errors */ 2288c2ecf20Sopenharmony_ci u64 rx_runt; /* # of runt frames */ 2298c2ecf20Sopenharmony_ci u64 rx_jabber; /* # of jabber frames */ 2308c2ecf20Sopenharmony_ci u64 rx_short; /* # of short frames */ 2318c2ecf20Sopenharmony_ci u64 rx_too_long; /* # of oversized frames */ 2328c2ecf20Sopenharmony_ci u64 rx_mac_internal_errs; /* # of internal MAC errors on Rx */ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci u64 rx_frames_64; /* # of Rx frames in a particular range */ 2358c2ecf20Sopenharmony_ci u64 rx_frames_65_127; 2368c2ecf20Sopenharmony_ci u64 rx_frames_128_255; 2378c2ecf20Sopenharmony_ci u64 rx_frames_256_511; 2388c2ecf20Sopenharmony_ci u64 rx_frames_512_1023; 2398c2ecf20Sopenharmony_ci u64 rx_frames_1024_1518; 2408c2ecf20Sopenharmony_ci u64 rx_frames_1519_max; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci u64 rx_cong_drops; /* # of Rx drops due to SGE congestion */ 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci unsigned long tx_fifo_parity_err; 2458c2ecf20Sopenharmony_ci unsigned long rx_fifo_parity_err; 2468c2ecf20Sopenharmony_ci unsigned long tx_fifo_urun; 2478c2ecf20Sopenharmony_ci unsigned long rx_fifo_ovfl; 2488c2ecf20Sopenharmony_ci unsigned long serdes_signal_loss; 2498c2ecf20Sopenharmony_ci unsigned long xaui_pcs_ctc_err; 2508c2ecf20Sopenharmony_ci unsigned long xaui_pcs_align_change; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci unsigned long num_toggled; /* # times toggled TxEn due to stuck TX */ 2538c2ecf20Sopenharmony_ci unsigned long num_resets; /* # times reset due to stuck TX */ 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci unsigned long link_faults; /* # detected link faults */ 2568c2ecf20Sopenharmony_ci}; 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_cistruct tp_mib_stats { 2598c2ecf20Sopenharmony_ci u32 ipInReceive_hi; 2608c2ecf20Sopenharmony_ci u32 ipInReceive_lo; 2618c2ecf20Sopenharmony_ci u32 ipInHdrErrors_hi; 2628c2ecf20Sopenharmony_ci u32 ipInHdrErrors_lo; 2638c2ecf20Sopenharmony_ci u32 ipInAddrErrors_hi; 2648c2ecf20Sopenharmony_ci u32 ipInAddrErrors_lo; 2658c2ecf20Sopenharmony_ci u32 ipInUnknownProtos_hi; 2668c2ecf20Sopenharmony_ci u32 ipInUnknownProtos_lo; 2678c2ecf20Sopenharmony_ci u32 ipInDiscards_hi; 2688c2ecf20Sopenharmony_ci u32 ipInDiscards_lo; 2698c2ecf20Sopenharmony_ci u32 ipInDelivers_hi; 2708c2ecf20Sopenharmony_ci u32 ipInDelivers_lo; 2718c2ecf20Sopenharmony_ci u32 ipOutRequests_hi; 2728c2ecf20Sopenharmony_ci u32 ipOutRequests_lo; 2738c2ecf20Sopenharmony_ci u32 ipOutDiscards_hi; 2748c2ecf20Sopenharmony_ci u32 ipOutDiscards_lo; 2758c2ecf20Sopenharmony_ci u32 ipOutNoRoutes_hi; 2768c2ecf20Sopenharmony_ci u32 ipOutNoRoutes_lo; 2778c2ecf20Sopenharmony_ci u32 ipReasmTimeout; 2788c2ecf20Sopenharmony_ci u32 ipReasmReqds; 2798c2ecf20Sopenharmony_ci u32 ipReasmOKs; 2808c2ecf20Sopenharmony_ci u32 ipReasmFails; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci u32 reserved[8]; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci u32 tcpActiveOpens; 2858c2ecf20Sopenharmony_ci u32 tcpPassiveOpens; 2868c2ecf20Sopenharmony_ci u32 tcpAttemptFails; 2878c2ecf20Sopenharmony_ci u32 tcpEstabResets; 2888c2ecf20Sopenharmony_ci u32 tcpOutRsts; 2898c2ecf20Sopenharmony_ci u32 tcpCurrEstab; 2908c2ecf20Sopenharmony_ci u32 tcpInSegs_hi; 2918c2ecf20Sopenharmony_ci u32 tcpInSegs_lo; 2928c2ecf20Sopenharmony_ci u32 tcpOutSegs_hi; 2938c2ecf20Sopenharmony_ci u32 tcpOutSegs_lo; 2948c2ecf20Sopenharmony_ci u32 tcpRetransSeg_hi; 2958c2ecf20Sopenharmony_ci u32 tcpRetransSeg_lo; 2968c2ecf20Sopenharmony_ci u32 tcpInErrs_hi; 2978c2ecf20Sopenharmony_ci u32 tcpInErrs_lo; 2988c2ecf20Sopenharmony_ci u32 tcpRtoMin; 2998c2ecf20Sopenharmony_ci u32 tcpRtoMax; 3008c2ecf20Sopenharmony_ci}; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cistruct tp_params { 3038c2ecf20Sopenharmony_ci unsigned int nchan; /* # of channels */ 3048c2ecf20Sopenharmony_ci unsigned int pmrx_size; /* total PMRX capacity */ 3058c2ecf20Sopenharmony_ci unsigned int pmtx_size; /* total PMTX capacity */ 3068c2ecf20Sopenharmony_ci unsigned int cm_size; /* total CM capacity */ 3078c2ecf20Sopenharmony_ci unsigned int chan_rx_size; /* per channel Rx size */ 3088c2ecf20Sopenharmony_ci unsigned int chan_tx_size; /* per channel Tx size */ 3098c2ecf20Sopenharmony_ci unsigned int rx_pg_size; /* Rx page size */ 3108c2ecf20Sopenharmony_ci unsigned int tx_pg_size; /* Tx page size */ 3118c2ecf20Sopenharmony_ci unsigned int rx_num_pgs; /* # of Rx pages */ 3128c2ecf20Sopenharmony_ci unsigned int tx_num_pgs; /* # of Tx pages */ 3138c2ecf20Sopenharmony_ci unsigned int ntimer_qs; /* # of timer queues */ 3148c2ecf20Sopenharmony_ci}; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_cistruct qset_params { /* SGE queue set parameters */ 3178c2ecf20Sopenharmony_ci unsigned int polling; /* polling/interrupt service for rspq */ 3188c2ecf20Sopenharmony_ci unsigned int coalesce_usecs; /* irq coalescing timer */ 3198c2ecf20Sopenharmony_ci unsigned int rspq_size; /* # of entries in response queue */ 3208c2ecf20Sopenharmony_ci unsigned int fl_size; /* # of entries in regular free list */ 3218c2ecf20Sopenharmony_ci unsigned int jumbo_size; /* # of entries in jumbo free list */ 3228c2ecf20Sopenharmony_ci unsigned int txq_size[SGE_TXQ_PER_SET]; /* Tx queue sizes */ 3238c2ecf20Sopenharmony_ci unsigned int cong_thres; /* FL congestion threshold */ 3248c2ecf20Sopenharmony_ci unsigned int vector; /* Interrupt (line or vector) number */ 3258c2ecf20Sopenharmony_ci}; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_cistruct sge_params { 3288c2ecf20Sopenharmony_ci unsigned int max_pkt_size; /* max offload pkt size */ 3298c2ecf20Sopenharmony_ci struct qset_params qset[SGE_QSETS]; 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistruct mc5_params { 3338c2ecf20Sopenharmony_ci unsigned int mode; /* selects MC5 width */ 3348c2ecf20Sopenharmony_ci unsigned int nservers; /* size of server region */ 3358c2ecf20Sopenharmony_ci unsigned int nfilters; /* size of filter region */ 3368c2ecf20Sopenharmony_ci unsigned int nroutes; /* size of routing region */ 3378c2ecf20Sopenharmony_ci}; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci/* Default MC5 region sizes */ 3408c2ecf20Sopenharmony_cienum { 3418c2ecf20Sopenharmony_ci DEFAULT_NSERVERS = 512, 3428c2ecf20Sopenharmony_ci DEFAULT_NFILTERS = 128 3438c2ecf20Sopenharmony_ci}; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci/* MC5 modes, these must be non-0 */ 3468c2ecf20Sopenharmony_cienum { 3478c2ecf20Sopenharmony_ci MC5_MODE_144_BIT = 1, 3488c2ecf20Sopenharmony_ci MC5_MODE_72_BIT = 2 3498c2ecf20Sopenharmony_ci}; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci/* MC5 min active region size */ 3528c2ecf20Sopenharmony_cienum { MC5_MIN_TIDS = 16 }; 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_cistruct vpd_params { 3558c2ecf20Sopenharmony_ci unsigned int cclk; 3568c2ecf20Sopenharmony_ci unsigned int mclk; 3578c2ecf20Sopenharmony_ci unsigned int uclk; 3588c2ecf20Sopenharmony_ci unsigned int mdc; 3598c2ecf20Sopenharmony_ci unsigned int mem_timing; 3608c2ecf20Sopenharmony_ci u8 sn[SERNUM_LEN + 1]; 3618c2ecf20Sopenharmony_ci u8 eth_base[6]; 3628c2ecf20Sopenharmony_ci u8 port_type[MAX_NPORTS]; 3638c2ecf20Sopenharmony_ci unsigned short xauicfg[2]; 3648c2ecf20Sopenharmony_ci}; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_cistruct pci_params { 3678c2ecf20Sopenharmony_ci unsigned int vpd_cap_addr; 3688c2ecf20Sopenharmony_ci unsigned short speed; 3698c2ecf20Sopenharmony_ci unsigned char width; 3708c2ecf20Sopenharmony_ci unsigned char variant; 3718c2ecf20Sopenharmony_ci}; 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_cienum { 3748c2ecf20Sopenharmony_ci PCI_VARIANT_PCI, 3758c2ecf20Sopenharmony_ci PCI_VARIANT_PCIX_MODE1_PARITY, 3768c2ecf20Sopenharmony_ci PCI_VARIANT_PCIX_MODE1_ECC, 3778c2ecf20Sopenharmony_ci PCI_VARIANT_PCIX_266_MODE2, 3788c2ecf20Sopenharmony_ci PCI_VARIANT_PCIE 3798c2ecf20Sopenharmony_ci}; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_cistruct adapter_params { 3828c2ecf20Sopenharmony_ci struct sge_params sge; 3838c2ecf20Sopenharmony_ci struct mc5_params mc5; 3848c2ecf20Sopenharmony_ci struct tp_params tp; 3858c2ecf20Sopenharmony_ci struct vpd_params vpd; 3868c2ecf20Sopenharmony_ci struct pci_params pci; 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci const struct adapter_info *info; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci unsigned short mtus[NMTUS]; 3918c2ecf20Sopenharmony_ci unsigned short a_wnd[NCCTRL_WIN]; 3928c2ecf20Sopenharmony_ci unsigned short b_wnd[NCCTRL_WIN]; 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci unsigned int nports; /* # of ethernet ports */ 3958c2ecf20Sopenharmony_ci unsigned int chan_map; /* bitmap of in-use Tx channels */ 3968c2ecf20Sopenharmony_ci unsigned int stats_update_period; /* MAC stats accumulation period */ 3978c2ecf20Sopenharmony_ci unsigned int linkpoll_period; /* link poll period in 0.1s */ 3988c2ecf20Sopenharmony_ci unsigned int rev; /* chip revision */ 3998c2ecf20Sopenharmony_ci unsigned int offload; 4008c2ecf20Sopenharmony_ci}; 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_cienum { /* chip revisions */ 4038c2ecf20Sopenharmony_ci T3_REV_A = 0, 4048c2ecf20Sopenharmony_ci T3_REV_B = 2, 4058c2ecf20Sopenharmony_ci T3_REV_B2 = 3, 4068c2ecf20Sopenharmony_ci T3_REV_C = 4, 4078c2ecf20Sopenharmony_ci}; 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_cistruct trace_params { 4108c2ecf20Sopenharmony_ci u32 sip; 4118c2ecf20Sopenharmony_ci u32 sip_mask; 4128c2ecf20Sopenharmony_ci u32 dip; 4138c2ecf20Sopenharmony_ci u32 dip_mask; 4148c2ecf20Sopenharmony_ci u16 sport; 4158c2ecf20Sopenharmony_ci u16 sport_mask; 4168c2ecf20Sopenharmony_ci u16 dport; 4178c2ecf20Sopenharmony_ci u16 dport_mask; 4188c2ecf20Sopenharmony_ci u32 vlan:12; 4198c2ecf20Sopenharmony_ci u32 vlan_mask:12; 4208c2ecf20Sopenharmony_ci u32 intf:4; 4218c2ecf20Sopenharmony_ci u32 intf_mask:4; 4228c2ecf20Sopenharmony_ci u8 proto; 4238c2ecf20Sopenharmony_ci u8 proto_mask; 4248c2ecf20Sopenharmony_ci}; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_cistruct link_config { 4278c2ecf20Sopenharmony_ci unsigned int supported; /* link capabilities */ 4288c2ecf20Sopenharmony_ci unsigned int advertising; /* advertised capabilities */ 4298c2ecf20Sopenharmony_ci unsigned short requested_speed; /* speed user has requested */ 4308c2ecf20Sopenharmony_ci unsigned short speed; /* actual link speed */ 4318c2ecf20Sopenharmony_ci unsigned char requested_duplex; /* duplex user has requested */ 4328c2ecf20Sopenharmony_ci unsigned char duplex; /* actual link duplex */ 4338c2ecf20Sopenharmony_ci unsigned char requested_fc; /* flow control user has requested */ 4348c2ecf20Sopenharmony_ci unsigned char fc; /* actual link flow control */ 4358c2ecf20Sopenharmony_ci unsigned char autoneg; /* autonegotiating? */ 4368c2ecf20Sopenharmony_ci unsigned int link_ok; /* link up? */ 4378c2ecf20Sopenharmony_ci}; 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci#define SPEED_INVALID 0xffff 4408c2ecf20Sopenharmony_ci#define DUPLEX_INVALID 0xff 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_cistruct mc5 { 4438c2ecf20Sopenharmony_ci struct adapter *adapter; 4448c2ecf20Sopenharmony_ci unsigned int tcam_size; 4458c2ecf20Sopenharmony_ci unsigned char part_type; 4468c2ecf20Sopenharmony_ci unsigned char parity_enabled; 4478c2ecf20Sopenharmony_ci unsigned char mode; 4488c2ecf20Sopenharmony_ci struct mc5_stats stats; 4498c2ecf20Sopenharmony_ci}; 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_cistatic inline unsigned int t3_mc5_size(const struct mc5 *p) 4528c2ecf20Sopenharmony_ci{ 4538c2ecf20Sopenharmony_ci return p->tcam_size; 4548c2ecf20Sopenharmony_ci} 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_cistruct mc7 { 4578c2ecf20Sopenharmony_ci struct adapter *adapter; /* backpointer to adapter */ 4588c2ecf20Sopenharmony_ci unsigned int size; /* memory size in bytes */ 4598c2ecf20Sopenharmony_ci unsigned int width; /* MC7 interface width */ 4608c2ecf20Sopenharmony_ci unsigned int offset; /* register address offset for MC7 instance */ 4618c2ecf20Sopenharmony_ci const char *name; /* name of MC7 instance */ 4628c2ecf20Sopenharmony_ci struct mc7_stats stats; /* MC7 statistics */ 4638c2ecf20Sopenharmony_ci}; 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_cistatic inline unsigned int t3_mc7_size(const struct mc7 *p) 4668c2ecf20Sopenharmony_ci{ 4678c2ecf20Sopenharmony_ci return p->size; 4688c2ecf20Sopenharmony_ci} 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_cistruct cmac { 4718c2ecf20Sopenharmony_ci struct adapter *adapter; 4728c2ecf20Sopenharmony_ci unsigned int offset; 4738c2ecf20Sopenharmony_ci unsigned int nucast; /* # of address filters for unicast MACs */ 4748c2ecf20Sopenharmony_ci unsigned int tx_tcnt; 4758c2ecf20Sopenharmony_ci unsigned int tx_xcnt; 4768c2ecf20Sopenharmony_ci u64 tx_mcnt; 4778c2ecf20Sopenharmony_ci unsigned int rx_xcnt; 4788c2ecf20Sopenharmony_ci unsigned int rx_ocnt; 4798c2ecf20Sopenharmony_ci u64 rx_mcnt; 4808c2ecf20Sopenharmony_ci unsigned int toggle_cnt; 4818c2ecf20Sopenharmony_ci unsigned int txen; 4828c2ecf20Sopenharmony_ci u64 rx_pause; 4838c2ecf20Sopenharmony_ci struct mac_stats stats; 4848c2ecf20Sopenharmony_ci}; 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_cienum { 4878c2ecf20Sopenharmony_ci MAC_DIRECTION_RX = 1, 4888c2ecf20Sopenharmony_ci MAC_DIRECTION_TX = 2, 4898c2ecf20Sopenharmony_ci MAC_RXFIFO_SIZE = 32768 4908c2ecf20Sopenharmony_ci}; 4918c2ecf20Sopenharmony_ci 4928c2ecf20Sopenharmony_ci/* PHY loopback direction */ 4938c2ecf20Sopenharmony_cienum { 4948c2ecf20Sopenharmony_ci PHY_LOOPBACK_TX = 1, 4958c2ecf20Sopenharmony_ci PHY_LOOPBACK_RX = 2 4968c2ecf20Sopenharmony_ci}; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci/* PHY interrupt types */ 4998c2ecf20Sopenharmony_cienum { 5008c2ecf20Sopenharmony_ci cphy_cause_link_change = 1, 5018c2ecf20Sopenharmony_ci cphy_cause_fifo_error = 2, 5028c2ecf20Sopenharmony_ci cphy_cause_module_change = 4, 5038c2ecf20Sopenharmony_ci}; 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci/* PHY module types */ 5068c2ecf20Sopenharmony_cienum { 5078c2ecf20Sopenharmony_ci phy_modtype_none, 5088c2ecf20Sopenharmony_ci phy_modtype_sr, 5098c2ecf20Sopenharmony_ci phy_modtype_lr, 5108c2ecf20Sopenharmony_ci phy_modtype_lrm, 5118c2ecf20Sopenharmony_ci phy_modtype_twinax, 5128c2ecf20Sopenharmony_ci phy_modtype_twinax_long, 5138c2ecf20Sopenharmony_ci phy_modtype_unknown 5148c2ecf20Sopenharmony_ci}; 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci/* PHY operations */ 5178c2ecf20Sopenharmony_cistruct cphy_ops { 5188c2ecf20Sopenharmony_ci int (*reset)(struct cphy *phy, int wait); 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci int (*intr_enable)(struct cphy *phy); 5218c2ecf20Sopenharmony_ci int (*intr_disable)(struct cphy *phy); 5228c2ecf20Sopenharmony_ci int (*intr_clear)(struct cphy *phy); 5238c2ecf20Sopenharmony_ci int (*intr_handler)(struct cphy *phy); 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci int (*autoneg_enable)(struct cphy *phy); 5268c2ecf20Sopenharmony_ci int (*autoneg_restart)(struct cphy *phy); 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci int (*advertise)(struct cphy *phy, unsigned int advertise_map); 5298c2ecf20Sopenharmony_ci int (*set_loopback)(struct cphy *phy, int mmd, int dir, int enable); 5308c2ecf20Sopenharmony_ci int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex); 5318c2ecf20Sopenharmony_ci int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed, 5328c2ecf20Sopenharmony_ci int *duplex, int *fc); 5338c2ecf20Sopenharmony_ci int (*power_down)(struct cphy *phy, int enable); 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci u32 mmds; 5368c2ecf20Sopenharmony_ci}; 5378c2ecf20Sopenharmony_cienum { 5388c2ecf20Sopenharmony_ci EDC_OPT_AEL2005 = 0, 5398c2ecf20Sopenharmony_ci EDC_OPT_AEL2005_SIZE = 1084, 5408c2ecf20Sopenharmony_ci EDC_TWX_AEL2005 = 1, 5418c2ecf20Sopenharmony_ci EDC_TWX_AEL2005_SIZE = 1464, 5428c2ecf20Sopenharmony_ci EDC_TWX_AEL2020 = 2, 5438c2ecf20Sopenharmony_ci EDC_TWX_AEL2020_SIZE = 1628, 5448c2ecf20Sopenharmony_ci EDC_MAX_SIZE = EDC_TWX_AEL2020_SIZE, /* Max cache size */ 5458c2ecf20Sopenharmony_ci}; 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci/* A PHY instance */ 5488c2ecf20Sopenharmony_cistruct cphy { 5498c2ecf20Sopenharmony_ci u8 modtype; /* PHY module type */ 5508c2ecf20Sopenharmony_ci short priv; /* scratch pad */ 5518c2ecf20Sopenharmony_ci unsigned int caps; /* PHY capabilities */ 5528c2ecf20Sopenharmony_ci struct adapter *adapter; /* associated adapter */ 5538c2ecf20Sopenharmony_ci const char *desc; /* PHY description */ 5548c2ecf20Sopenharmony_ci unsigned long fifo_errors; /* FIFO over/under-flows */ 5558c2ecf20Sopenharmony_ci const struct cphy_ops *ops; /* PHY operations */ 5568c2ecf20Sopenharmony_ci struct mdio_if_info mdio; 5578c2ecf20Sopenharmony_ci u16 phy_cache[EDC_MAX_SIZE]; /* EDC cache */ 5588c2ecf20Sopenharmony_ci}; 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci/* Convenience MDIO read/write wrappers */ 5618c2ecf20Sopenharmony_cistatic inline int t3_mdio_read(struct cphy *phy, int mmd, int reg, 5628c2ecf20Sopenharmony_ci unsigned int *valp) 5638c2ecf20Sopenharmony_ci{ 5648c2ecf20Sopenharmony_ci int rc = phy->mdio.mdio_read(phy->mdio.dev, phy->mdio.prtad, mmd, reg); 5658c2ecf20Sopenharmony_ci *valp = (rc >= 0) ? rc : -1; 5668c2ecf20Sopenharmony_ci return (rc >= 0) ? 0 : rc; 5678c2ecf20Sopenharmony_ci} 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_cistatic inline int t3_mdio_write(struct cphy *phy, int mmd, int reg, 5708c2ecf20Sopenharmony_ci unsigned int val) 5718c2ecf20Sopenharmony_ci{ 5728c2ecf20Sopenharmony_ci return phy->mdio.mdio_write(phy->mdio.dev, phy->mdio.prtad, mmd, 5738c2ecf20Sopenharmony_ci reg, val); 5748c2ecf20Sopenharmony_ci} 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci/* Convenience initializer */ 5778c2ecf20Sopenharmony_cistatic inline void cphy_init(struct cphy *phy, struct adapter *adapter, 5788c2ecf20Sopenharmony_ci int phy_addr, const struct cphy_ops *phy_ops, 5798c2ecf20Sopenharmony_ci const struct mdio_ops *mdio_ops, 5808c2ecf20Sopenharmony_ci unsigned int caps, const char *desc) 5818c2ecf20Sopenharmony_ci{ 5828c2ecf20Sopenharmony_ci phy->caps = caps; 5838c2ecf20Sopenharmony_ci phy->adapter = adapter; 5848c2ecf20Sopenharmony_ci phy->desc = desc; 5858c2ecf20Sopenharmony_ci phy->ops = phy_ops; 5868c2ecf20Sopenharmony_ci if (mdio_ops) { 5878c2ecf20Sopenharmony_ci phy->mdio.prtad = phy_addr; 5888c2ecf20Sopenharmony_ci phy->mdio.mmds = phy_ops->mmds; 5898c2ecf20Sopenharmony_ci phy->mdio.mode_support = mdio_ops->mode_support; 5908c2ecf20Sopenharmony_ci phy->mdio.mdio_read = mdio_ops->read; 5918c2ecf20Sopenharmony_ci phy->mdio.mdio_write = mdio_ops->write; 5928c2ecf20Sopenharmony_ci } 5938c2ecf20Sopenharmony_ci} 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci/* Accumulate MAC statistics every 180 seconds. For 1G we multiply by 10. */ 5968c2ecf20Sopenharmony_ci#define MAC_STATS_ACCUM_SECS 180 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci#define XGM_REG(reg_addr, idx) \ 5998c2ecf20Sopenharmony_ci ((reg_addr) + (idx) * (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR)) 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_cistruct addr_val_pair { 6028c2ecf20Sopenharmony_ci unsigned int reg_addr; 6038c2ecf20Sopenharmony_ci unsigned int val; 6048c2ecf20Sopenharmony_ci}; 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci#include "adapter.h" 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci#ifndef PCI_VENDOR_ID_CHELSIO 6098c2ecf20Sopenharmony_ci# define PCI_VENDOR_ID_CHELSIO 0x1425 6108c2ecf20Sopenharmony_ci#endif 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci#define for_each_port(adapter, iter) \ 6138c2ecf20Sopenharmony_ci for (iter = 0; iter < (adapter)->params.nports; ++iter) 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci#define adapter_info(adap) ((adap)->params.info) 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_cistatic inline int uses_xaui(const struct adapter *adap) 6188c2ecf20Sopenharmony_ci{ 6198c2ecf20Sopenharmony_ci return adapter_info(adap)->caps & SUPPORTED_AUI; 6208c2ecf20Sopenharmony_ci} 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_cistatic inline int is_10G(const struct adapter *adap) 6238c2ecf20Sopenharmony_ci{ 6248c2ecf20Sopenharmony_ci return adapter_info(adap)->caps & SUPPORTED_10000baseT_Full; 6258c2ecf20Sopenharmony_ci} 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_cistatic inline int is_offload(const struct adapter *adap) 6288c2ecf20Sopenharmony_ci{ 6298c2ecf20Sopenharmony_ci return adap->params.offload; 6308c2ecf20Sopenharmony_ci} 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_cistatic inline unsigned int core_ticks_per_usec(const struct adapter *adap) 6338c2ecf20Sopenharmony_ci{ 6348c2ecf20Sopenharmony_ci return adap->params.vpd.cclk / 1000; 6358c2ecf20Sopenharmony_ci} 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_cistatic inline unsigned int is_pcie(const struct adapter *adap) 6388c2ecf20Sopenharmony_ci{ 6398c2ecf20Sopenharmony_ci return adap->params.pci.variant == PCI_VARIANT_PCIE; 6408c2ecf20Sopenharmony_ci} 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_civoid t3_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask, 6438c2ecf20Sopenharmony_ci u32 val); 6448c2ecf20Sopenharmony_civoid t3_write_regs(struct adapter *adapter, const struct addr_val_pair *p, 6458c2ecf20Sopenharmony_ci int n, unsigned int offset); 6468c2ecf20Sopenharmony_ciint t3_wait_op_done_val(struct adapter *adapter, int reg, u32 mask, 6478c2ecf20Sopenharmony_ci int polarity, int attempts, int delay, u32 *valp); 6488c2ecf20Sopenharmony_cistatic inline int t3_wait_op_done(struct adapter *adapter, int reg, u32 mask, 6498c2ecf20Sopenharmony_ci int polarity, int attempts, int delay) 6508c2ecf20Sopenharmony_ci{ 6518c2ecf20Sopenharmony_ci return t3_wait_op_done_val(adapter, reg, mask, polarity, attempts, 6528c2ecf20Sopenharmony_ci delay, NULL); 6538c2ecf20Sopenharmony_ci} 6548c2ecf20Sopenharmony_ciint t3_mdio_change_bits(struct cphy *phy, int mmd, int reg, unsigned int clear, 6558c2ecf20Sopenharmony_ci unsigned int set); 6568c2ecf20Sopenharmony_ciint t3_phy_reset(struct cphy *phy, int mmd, int wait); 6578c2ecf20Sopenharmony_ciint t3_phy_advertise(struct cphy *phy, unsigned int advert); 6588c2ecf20Sopenharmony_ciint t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert); 6598c2ecf20Sopenharmony_ciint t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex); 6608c2ecf20Sopenharmony_ciint t3_phy_lasi_intr_enable(struct cphy *phy); 6618c2ecf20Sopenharmony_ciint t3_phy_lasi_intr_disable(struct cphy *phy); 6628c2ecf20Sopenharmony_ciint t3_phy_lasi_intr_clear(struct cphy *phy); 6638c2ecf20Sopenharmony_ciint t3_phy_lasi_intr_handler(struct cphy *phy); 6648c2ecf20Sopenharmony_ci 6658c2ecf20Sopenharmony_civoid t3_intr_enable(struct adapter *adapter); 6668c2ecf20Sopenharmony_civoid t3_intr_disable(struct adapter *adapter); 6678c2ecf20Sopenharmony_civoid t3_intr_clear(struct adapter *adapter); 6688c2ecf20Sopenharmony_civoid t3_xgm_intr_enable(struct adapter *adapter, int idx); 6698c2ecf20Sopenharmony_civoid t3_xgm_intr_disable(struct adapter *adapter, int idx); 6708c2ecf20Sopenharmony_civoid t3_port_intr_enable(struct adapter *adapter, int idx); 6718c2ecf20Sopenharmony_civoid t3_port_intr_disable(struct adapter *adapter, int idx); 6728c2ecf20Sopenharmony_ciint t3_slow_intr_handler(struct adapter *adapter); 6738c2ecf20Sopenharmony_ciint t3_phy_intr_handler(struct adapter *adapter); 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_civoid t3_link_changed(struct adapter *adapter, int port_id); 6768c2ecf20Sopenharmony_civoid t3_link_fault(struct adapter *adapter, int port_id); 6778c2ecf20Sopenharmony_ciint t3_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc); 6788c2ecf20Sopenharmony_ciconst struct adapter_info *t3_get_adapter_info(unsigned int board_id); 6798c2ecf20Sopenharmony_ciint t3_seeprom_read(struct adapter *adapter, u32 addr, __le32 *data); 6808c2ecf20Sopenharmony_ciint t3_seeprom_write(struct adapter *adapter, u32 addr, __le32 data); 6818c2ecf20Sopenharmony_ciint t3_seeprom_wp(struct adapter *adapter, int enable); 6828c2ecf20Sopenharmony_ciint t3_get_tp_version(struct adapter *adapter, u32 *vers); 6838c2ecf20Sopenharmony_ciint t3_check_tpsram_version(struct adapter *adapter); 6848c2ecf20Sopenharmony_ciint t3_check_tpsram(struct adapter *adapter, const u8 *tp_ram, 6858c2ecf20Sopenharmony_ci unsigned int size); 6868c2ecf20Sopenharmony_ciint t3_set_proto_sram(struct adapter *adap, const u8 *data); 6878c2ecf20Sopenharmony_ciint t3_load_fw(struct adapter *adapter, const u8 * fw_data, unsigned int size); 6888c2ecf20Sopenharmony_ciint t3_get_fw_version(struct adapter *adapter, u32 *vers); 6898c2ecf20Sopenharmony_ciint t3_check_fw_version(struct adapter *adapter); 6908c2ecf20Sopenharmony_ciint t3_init_hw(struct adapter *adapter, u32 fw_params); 6918c2ecf20Sopenharmony_ciint t3_reset_adapter(struct adapter *adapter); 6928c2ecf20Sopenharmony_ciint t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, 6938c2ecf20Sopenharmony_ci int reset); 6948c2ecf20Sopenharmony_ciint t3_replay_prep_adapter(struct adapter *adapter); 6958c2ecf20Sopenharmony_civoid t3_led_ready(struct adapter *adapter); 6968c2ecf20Sopenharmony_civoid t3_fatal_err(struct adapter *adapter); 6978c2ecf20Sopenharmony_civoid t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on); 6988c2ecf20Sopenharmony_civoid t3_config_rss(struct adapter *adapter, unsigned int rss_config, 6998c2ecf20Sopenharmony_ci const u8 * cpus, const u16 *rspq); 7008c2ecf20Sopenharmony_ciint t3_cim_ctl_blk_read(struct adapter *adap, unsigned int addr, 7018c2ecf20Sopenharmony_ci unsigned int n, unsigned int *valp); 7028c2ecf20Sopenharmony_ciint t3_mc7_bd_read(struct mc7 *mc7, unsigned int start, unsigned int n, 7038c2ecf20Sopenharmony_ci u64 *buf); 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ciint t3_mac_reset(struct cmac *mac); 7068c2ecf20Sopenharmony_civoid t3b_pcs_reset(struct cmac *mac); 7078c2ecf20Sopenharmony_civoid t3_mac_disable_exact_filters(struct cmac *mac); 7088c2ecf20Sopenharmony_civoid t3_mac_enable_exact_filters(struct cmac *mac); 7098c2ecf20Sopenharmony_ciint t3_mac_enable(struct cmac *mac, int which); 7108c2ecf20Sopenharmony_ciint t3_mac_disable(struct cmac *mac, int which); 7118c2ecf20Sopenharmony_ciint t3_mac_set_mtu(struct cmac *mac, unsigned int mtu); 7128c2ecf20Sopenharmony_ciint t3_mac_set_rx_mode(struct cmac *mac, struct net_device *dev); 7138c2ecf20Sopenharmony_ciint t3_mac_set_address(struct cmac *mac, unsigned int idx, u8 addr[6]); 7148c2ecf20Sopenharmony_ciint t3_mac_set_num_ucast(struct cmac *mac, int n); 7158c2ecf20Sopenharmony_ciconst struct mac_stats *t3_mac_update_stats(struct cmac *mac); 7168c2ecf20Sopenharmony_ciint t3_mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex, int fc); 7178c2ecf20Sopenharmony_ciint t3b2_mac_watchdog_task(struct cmac *mac); 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_civoid t3_mc5_prep(struct adapter *adapter, struct mc5 *mc5, int mode); 7208c2ecf20Sopenharmony_ciint t3_mc5_init(struct mc5 *mc5, unsigned int nservers, unsigned int nfilters, 7218c2ecf20Sopenharmony_ci unsigned int nroutes); 7228c2ecf20Sopenharmony_civoid t3_mc5_intr_handler(struct mc5 *mc5); 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_civoid t3_tp_set_offload_mode(struct adapter *adap, int enable); 7258c2ecf20Sopenharmony_civoid t3_tp_get_mib_stats(struct adapter *adap, struct tp_mib_stats *tps); 7268c2ecf20Sopenharmony_civoid t3_load_mtus(struct adapter *adap, unsigned short mtus[NMTUS], 7278c2ecf20Sopenharmony_ci unsigned short alpha[NCCTRL_WIN], 7288c2ecf20Sopenharmony_ci unsigned short beta[NCCTRL_WIN], unsigned short mtu_cap); 7298c2ecf20Sopenharmony_civoid t3_config_trace_filter(struct adapter *adapter, 7308c2ecf20Sopenharmony_ci const struct trace_params *tp, int filter_index, 7318c2ecf20Sopenharmony_ci int invert, int enable); 7328c2ecf20Sopenharmony_ciint t3_config_sched(struct adapter *adap, unsigned int kbps, int sched); 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_civoid t3_sge_prep(struct adapter *adap, struct sge_params *p); 7358c2ecf20Sopenharmony_civoid t3_sge_init(struct adapter *adap, struct sge_params *p); 7368c2ecf20Sopenharmony_ciint t3_sge_init_ecntxt(struct adapter *adapter, unsigned int id, int gts_enable, 7378c2ecf20Sopenharmony_ci enum sge_context_type type, int respq, u64 base_addr, 7388c2ecf20Sopenharmony_ci unsigned int size, unsigned int token, int gen, 7398c2ecf20Sopenharmony_ci unsigned int cidx); 7408c2ecf20Sopenharmony_ciint t3_sge_init_flcntxt(struct adapter *adapter, unsigned int id, 7418c2ecf20Sopenharmony_ci int gts_enable, u64 base_addr, unsigned int size, 7428c2ecf20Sopenharmony_ci unsigned int esize, unsigned int cong_thres, int gen, 7438c2ecf20Sopenharmony_ci unsigned int cidx); 7448c2ecf20Sopenharmony_ciint t3_sge_init_rspcntxt(struct adapter *adapter, unsigned int id, 7458c2ecf20Sopenharmony_ci int irq_vec_idx, u64 base_addr, unsigned int size, 7468c2ecf20Sopenharmony_ci unsigned int fl_thres, int gen, unsigned int cidx); 7478c2ecf20Sopenharmony_ciint t3_sge_init_cqcntxt(struct adapter *adapter, unsigned int id, u64 base_addr, 7488c2ecf20Sopenharmony_ci unsigned int size, int rspq, int ovfl_mode, 7498c2ecf20Sopenharmony_ci unsigned int credits, unsigned int credit_thres); 7508c2ecf20Sopenharmony_ciint t3_sge_enable_ecntxt(struct adapter *adapter, unsigned int id, int enable); 7518c2ecf20Sopenharmony_ciint t3_sge_disable_fl(struct adapter *adapter, unsigned int id); 7528c2ecf20Sopenharmony_ciint t3_sge_disable_rspcntxt(struct adapter *adapter, unsigned int id); 7538c2ecf20Sopenharmony_ciint t3_sge_disable_cqcntxt(struct adapter *adapter, unsigned int id); 7548c2ecf20Sopenharmony_ciint t3_sge_cqcntxt_op(struct adapter *adapter, unsigned int id, unsigned int op, 7558c2ecf20Sopenharmony_ci unsigned int credits); 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ciint t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter, 7588c2ecf20Sopenharmony_ci int phy_addr, const struct mdio_ops *mdio_ops); 7598c2ecf20Sopenharmony_ciint t3_ael1002_phy_prep(struct cphy *phy, struct adapter *adapter, 7608c2ecf20Sopenharmony_ci int phy_addr, const struct mdio_ops *mdio_ops); 7618c2ecf20Sopenharmony_ciint t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter, 7628c2ecf20Sopenharmony_ci int phy_addr, const struct mdio_ops *mdio_ops); 7638c2ecf20Sopenharmony_ciint t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter, 7648c2ecf20Sopenharmony_ci int phy_addr, const struct mdio_ops *mdio_ops); 7658c2ecf20Sopenharmony_ciint t3_ael2020_phy_prep(struct cphy *phy, struct adapter *adapter, 7668c2ecf20Sopenharmony_ci int phy_addr, const struct mdio_ops *mdio_ops); 7678c2ecf20Sopenharmony_ciint t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, 7688c2ecf20Sopenharmony_ci const struct mdio_ops *mdio_ops); 7698c2ecf20Sopenharmony_ciint t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, 7708c2ecf20Sopenharmony_ci int phy_addr, const struct mdio_ops *mdio_ops); 7718c2ecf20Sopenharmony_ciint t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter, 7728c2ecf20Sopenharmony_ci int phy_addr, const struct mdio_ops *mdio_ops); 7738c2ecf20Sopenharmony_ci#endif /* __CHELSIO_COMMON_H */ 774