1f7917c00SJeff Kirsher /* 2f7917c00SJeff Kirsher * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved. 3f7917c00SJeff Kirsher * 4f7917c00SJeff Kirsher * This software is available to you under a choice of one of two 5f7917c00SJeff Kirsher * licenses. You may choose to be licensed under the terms of the GNU 6f7917c00SJeff Kirsher * General Public License (GPL) Version 2, available from the file 7f7917c00SJeff Kirsher * COPYING in the main directory of this source tree, or the 8f7917c00SJeff Kirsher * OpenIB.org BSD license below: 9f7917c00SJeff Kirsher * 10f7917c00SJeff Kirsher * Redistribution and use in source and binary forms, with or 11f7917c00SJeff Kirsher * without modification, are permitted provided that the following 12f7917c00SJeff Kirsher * conditions are met: 13f7917c00SJeff Kirsher * 14f7917c00SJeff Kirsher * - Redistributions of source code must retain the above 15f7917c00SJeff Kirsher * copyright notice, this list of conditions and the following 16f7917c00SJeff Kirsher * disclaimer. 17f7917c00SJeff Kirsher * 18f7917c00SJeff Kirsher * - Redistributions in binary form must reproduce the above 19f7917c00SJeff Kirsher * copyright notice, this list of conditions and the following 20f7917c00SJeff Kirsher * disclaimer in the documentation and/or other materials 21f7917c00SJeff Kirsher * provided with the distribution. 22f7917c00SJeff Kirsher * 23f7917c00SJeff Kirsher * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24f7917c00SJeff Kirsher * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25f7917c00SJeff Kirsher * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26f7917c00SJeff Kirsher * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27f7917c00SJeff Kirsher * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28f7917c00SJeff Kirsher * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29f7917c00SJeff Kirsher * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30f7917c00SJeff Kirsher * SOFTWARE. 31f7917c00SJeff Kirsher */ 32f7917c00SJeff Kirsher #ifndef __CHELSIO_COMMON_H 33f7917c00SJeff Kirsher #define __CHELSIO_COMMON_H 34f7917c00SJeff Kirsher 35f7917c00SJeff Kirsher #include <linux/kernel.h> 36f7917c00SJeff Kirsher #include <linux/types.h> 37f7917c00SJeff Kirsher #include <linux/ctype.h> 38f7917c00SJeff Kirsher #include <linux/delay.h> 39f7917c00SJeff Kirsher #include <linux/init.h> 40f7917c00SJeff Kirsher #include <linux/netdevice.h> 41f7917c00SJeff Kirsher #include <linux/ethtool.h> 42f7917c00SJeff Kirsher #include <linux/mdio.h> 43f7917c00SJeff Kirsher #include "version.h" 44f7917c00SJeff Kirsher 45f7917c00SJeff Kirsher #define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ##__VA_ARGS__) 46f7917c00SJeff Kirsher #define CH_WARN(adap, fmt, ...) dev_warn(&adap->pdev->dev, fmt, ##__VA_ARGS__) 47*f7b4fb22SJoe Perches #define CH_ALERT(adap, fmt, ...) dev_alert(&adap->pdev->dev, fmt, ##__VA_ARGS__) 48f7917c00SJeff Kirsher 49f7917c00SJeff Kirsher /* 50f7917c00SJeff Kirsher * More powerful macro that selectively prints messages based on msg_enable. 51f7917c00SJeff Kirsher * For info and debugging messages. 52f7917c00SJeff Kirsher */ 53f7917c00SJeff Kirsher #define CH_MSG(adapter, level, category, fmt, ...) do { \ 54f7917c00SJeff Kirsher if ((adapter)->msg_enable & NETIF_MSG_##category) \ 55f7917c00SJeff Kirsher dev_printk(KERN_##level, &adapter->pdev->dev, fmt, \ 56f7917c00SJeff Kirsher ## __VA_ARGS__); \ 57f7917c00SJeff Kirsher } while (0) 58f7917c00SJeff Kirsher 59f7917c00SJeff Kirsher #ifdef DEBUG 60f7917c00SJeff Kirsher # define CH_DBG(adapter, category, fmt, ...) \ 61f7917c00SJeff Kirsher CH_MSG(adapter, DEBUG, category, fmt, ## __VA_ARGS__) 62f7917c00SJeff Kirsher #else 63f7917c00SJeff Kirsher # define CH_DBG(adapter, category, fmt, ...) 64f7917c00SJeff Kirsher #endif 65f7917c00SJeff Kirsher 66f7917c00SJeff Kirsher /* Additional NETIF_MSG_* categories */ 67f7917c00SJeff Kirsher #define NETIF_MSG_MMIO 0x8000000 68f7917c00SJeff Kirsher 69f7917c00SJeff Kirsher enum { 70f7917c00SJeff Kirsher MAX_NPORTS = 2, /* max # of ports */ 71f7917c00SJeff Kirsher MAX_FRAME_SIZE = 10240, /* max MAC frame size, including header + FCS */ 72f7917c00SJeff Kirsher EEPROMSIZE = 8192, /* Serial EEPROM size */ 73f7917c00SJeff Kirsher SERNUM_LEN = 16, /* Serial # length */ 74f7917c00SJeff Kirsher RSS_TABLE_SIZE = 64, /* size of RSS lookup and mapping tables */ 75f7917c00SJeff Kirsher TCB_SIZE = 128, /* TCB size */ 76f7917c00SJeff Kirsher NMTUS = 16, /* size of MTU table */ 77f7917c00SJeff Kirsher NCCTRL_WIN = 32, /* # of congestion control windows */ 78f7917c00SJeff Kirsher PROTO_SRAM_LINES = 128, /* size of TP sram */ 79f7917c00SJeff Kirsher }; 80f7917c00SJeff Kirsher 81f7917c00SJeff Kirsher #define MAX_RX_COALESCING_LEN 12288U 82f7917c00SJeff Kirsher 83f7917c00SJeff Kirsher enum { 84f7917c00SJeff Kirsher PAUSE_RX = 1 << 0, 85f7917c00SJeff Kirsher PAUSE_TX = 1 << 1, 86f7917c00SJeff Kirsher PAUSE_AUTONEG = 1 << 2 87f7917c00SJeff Kirsher }; 88f7917c00SJeff Kirsher 89f7917c00SJeff Kirsher enum { 90f7917c00SJeff Kirsher SUPPORTED_IRQ = 1 << 24 91f7917c00SJeff Kirsher }; 92f7917c00SJeff Kirsher 93f7917c00SJeff Kirsher enum { /* adapter interrupt-maintained statistics */ 94f7917c00SJeff Kirsher STAT_ULP_CH0_PBL_OOB, 95f7917c00SJeff Kirsher STAT_ULP_CH1_PBL_OOB, 96f7917c00SJeff Kirsher STAT_PCI_CORR_ECC, 97f7917c00SJeff Kirsher 98f7917c00SJeff Kirsher IRQ_NUM_STATS /* keep last */ 99f7917c00SJeff Kirsher }; 100f7917c00SJeff Kirsher 101f7917c00SJeff Kirsher #define TP_VERSION_MAJOR 1 102f7917c00SJeff Kirsher #define TP_VERSION_MINOR 1 103f7917c00SJeff Kirsher #define TP_VERSION_MICRO 0 104f7917c00SJeff Kirsher 105f7917c00SJeff Kirsher #define S_TP_VERSION_MAJOR 16 106f7917c00SJeff Kirsher #define M_TP_VERSION_MAJOR 0xFF 107f7917c00SJeff Kirsher #define V_TP_VERSION_MAJOR(x) ((x) << S_TP_VERSION_MAJOR) 108f7917c00SJeff Kirsher #define G_TP_VERSION_MAJOR(x) \ 109f7917c00SJeff Kirsher (((x) >> S_TP_VERSION_MAJOR) & M_TP_VERSION_MAJOR) 110f7917c00SJeff Kirsher 111f7917c00SJeff Kirsher #define S_TP_VERSION_MINOR 8 112f7917c00SJeff Kirsher #define M_TP_VERSION_MINOR 0xFF 113f7917c00SJeff Kirsher #define V_TP_VERSION_MINOR(x) ((x) << S_TP_VERSION_MINOR) 114f7917c00SJeff Kirsher #define G_TP_VERSION_MINOR(x) \ 115f7917c00SJeff Kirsher (((x) >> S_TP_VERSION_MINOR) & M_TP_VERSION_MINOR) 116f7917c00SJeff Kirsher 117f7917c00SJeff Kirsher #define S_TP_VERSION_MICRO 0 118f7917c00SJeff Kirsher #define M_TP_VERSION_MICRO 0xFF 119f7917c00SJeff Kirsher #define V_TP_VERSION_MICRO(x) ((x) << S_TP_VERSION_MICRO) 120f7917c00SJeff Kirsher #define G_TP_VERSION_MICRO(x) \ 121f7917c00SJeff Kirsher (((x) >> S_TP_VERSION_MICRO) & M_TP_VERSION_MICRO) 122f7917c00SJeff Kirsher 123f7917c00SJeff Kirsher enum { 124f7917c00SJeff Kirsher SGE_QSETS = 8, /* # of SGE Tx/Rx/RspQ sets */ 125f7917c00SJeff Kirsher SGE_RXQ_PER_SET = 2, /* # of Rx queues per set */ 126f7917c00SJeff Kirsher SGE_TXQ_PER_SET = 3 /* # of Tx queues per set */ 127f7917c00SJeff Kirsher }; 128f7917c00SJeff Kirsher 129f7917c00SJeff Kirsher enum sge_context_type { /* SGE egress context types */ 130f7917c00SJeff Kirsher SGE_CNTXT_RDMA = 0, 131f7917c00SJeff Kirsher SGE_CNTXT_ETH = 2, 132f7917c00SJeff Kirsher SGE_CNTXT_OFLD = 4, 133f7917c00SJeff Kirsher SGE_CNTXT_CTRL = 5 134f7917c00SJeff Kirsher }; 135f7917c00SJeff Kirsher 136f7917c00SJeff Kirsher enum { 137f7917c00SJeff Kirsher AN_PKT_SIZE = 32, /* async notification packet size */ 138f7917c00SJeff Kirsher IMMED_PKT_SIZE = 48 /* packet size for immediate data */ 139f7917c00SJeff Kirsher }; 140f7917c00SJeff Kirsher 141f7917c00SJeff Kirsher struct sg_ent { /* SGE scatter/gather entry */ 142f7917c00SJeff Kirsher __be32 len[2]; 143f7917c00SJeff Kirsher __be64 addr[2]; 144f7917c00SJeff Kirsher }; 145f7917c00SJeff Kirsher 146f7917c00SJeff Kirsher #ifndef SGE_NUM_GENBITS 147f7917c00SJeff Kirsher /* Must be 1 or 2 */ 148f7917c00SJeff Kirsher # define SGE_NUM_GENBITS 2 149f7917c00SJeff Kirsher #endif 150f7917c00SJeff Kirsher 151f7917c00SJeff Kirsher #define TX_DESC_FLITS 16U 152f7917c00SJeff Kirsher #define WR_FLITS (TX_DESC_FLITS + 1 - SGE_NUM_GENBITS) 153f7917c00SJeff Kirsher 154f7917c00SJeff Kirsher struct cphy; 155f7917c00SJeff Kirsher struct adapter; 156f7917c00SJeff Kirsher 157f7917c00SJeff Kirsher struct mdio_ops { 158f7917c00SJeff Kirsher int (*read)(struct net_device *dev, int phy_addr, int mmd_addr, 159f7917c00SJeff Kirsher u16 reg_addr); 160f7917c00SJeff Kirsher int (*write)(struct net_device *dev, int phy_addr, int mmd_addr, 161f7917c00SJeff Kirsher u16 reg_addr, u16 val); 162f7917c00SJeff Kirsher unsigned mode_support; 163f7917c00SJeff Kirsher }; 164f7917c00SJeff Kirsher 165f7917c00SJeff Kirsher struct adapter_info { 166f7917c00SJeff Kirsher unsigned char nports0; /* # of ports on channel 0 */ 167f7917c00SJeff Kirsher unsigned char nports1; /* # of ports on channel 1 */ 168f7917c00SJeff Kirsher unsigned char phy_base_addr; /* MDIO PHY base address */ 169f7917c00SJeff Kirsher unsigned int gpio_out; /* GPIO output settings */ 170f7917c00SJeff Kirsher unsigned char gpio_intr[MAX_NPORTS]; /* GPIO PHY IRQ pins */ 171f7917c00SJeff Kirsher unsigned long caps; /* adapter capabilities */ 172f7917c00SJeff Kirsher const struct mdio_ops *mdio_ops; /* MDIO operations */ 173f7917c00SJeff Kirsher const char *desc; /* product description */ 174f7917c00SJeff Kirsher }; 175f7917c00SJeff Kirsher 176f7917c00SJeff Kirsher struct mc5_stats { 177f7917c00SJeff Kirsher unsigned long parity_err; 178f7917c00SJeff Kirsher unsigned long active_rgn_full; 179f7917c00SJeff Kirsher unsigned long nfa_srch_err; 180f7917c00SJeff Kirsher unsigned long unknown_cmd; 181f7917c00SJeff Kirsher unsigned long reqq_parity_err; 182f7917c00SJeff Kirsher unsigned long dispq_parity_err; 183f7917c00SJeff Kirsher unsigned long del_act_empty; 184f7917c00SJeff Kirsher }; 185f7917c00SJeff Kirsher 186f7917c00SJeff Kirsher struct mc7_stats { 187f7917c00SJeff Kirsher unsigned long corr_err; 188f7917c00SJeff Kirsher unsigned long uncorr_err; 189f7917c00SJeff Kirsher unsigned long parity_err; 190f7917c00SJeff Kirsher unsigned long addr_err; 191f7917c00SJeff Kirsher }; 192f7917c00SJeff Kirsher 193f7917c00SJeff Kirsher struct mac_stats { 194f7917c00SJeff Kirsher u64 tx_octets; /* total # of octets in good frames */ 195f7917c00SJeff Kirsher u64 tx_octets_bad; /* total # of octets in error frames */ 196f7917c00SJeff Kirsher u64 tx_frames; /* all good frames */ 197f7917c00SJeff Kirsher u64 tx_mcast_frames; /* good multicast frames */ 198f7917c00SJeff Kirsher u64 tx_bcast_frames; /* good broadcast frames */ 199f7917c00SJeff Kirsher u64 tx_pause; /* # of transmitted pause frames */ 200f7917c00SJeff Kirsher u64 tx_deferred; /* frames with deferred transmissions */ 201f7917c00SJeff Kirsher u64 tx_late_collisions; /* # of late collisions */ 202f7917c00SJeff Kirsher u64 tx_total_collisions; /* # of total collisions */ 203f7917c00SJeff Kirsher u64 tx_excess_collisions; /* frame errors from excessive collissions */ 204f7917c00SJeff Kirsher u64 tx_underrun; /* # of Tx FIFO underruns */ 205f7917c00SJeff Kirsher u64 tx_len_errs; /* # of Tx length errors */ 206f7917c00SJeff Kirsher u64 tx_mac_internal_errs; /* # of internal MAC errors on Tx */ 207f7917c00SJeff Kirsher u64 tx_excess_deferral; /* # of frames with excessive deferral */ 208f7917c00SJeff Kirsher u64 tx_fcs_errs; /* # of frames with bad FCS */ 209f7917c00SJeff Kirsher 210f7917c00SJeff Kirsher u64 tx_frames_64; /* # of Tx frames in a particular range */ 211f7917c00SJeff Kirsher u64 tx_frames_65_127; 212f7917c00SJeff Kirsher u64 tx_frames_128_255; 213f7917c00SJeff Kirsher u64 tx_frames_256_511; 214f7917c00SJeff Kirsher u64 tx_frames_512_1023; 215f7917c00SJeff Kirsher u64 tx_frames_1024_1518; 216f7917c00SJeff Kirsher u64 tx_frames_1519_max; 217f7917c00SJeff Kirsher 218f7917c00SJeff Kirsher u64 rx_octets; /* total # of octets in good frames */ 219f7917c00SJeff Kirsher u64 rx_octets_bad; /* total # of octets in error frames */ 220f7917c00SJeff Kirsher u64 rx_frames; /* all good frames */ 221f7917c00SJeff Kirsher u64 rx_mcast_frames; /* good multicast frames */ 222f7917c00SJeff Kirsher u64 rx_bcast_frames; /* good broadcast frames */ 223f7917c00SJeff Kirsher u64 rx_pause; /* # of received pause frames */ 224f7917c00SJeff Kirsher u64 rx_fcs_errs; /* # of received frames with bad FCS */ 225f7917c00SJeff Kirsher u64 rx_align_errs; /* alignment errors */ 226f7917c00SJeff Kirsher u64 rx_symbol_errs; /* symbol errors */ 227f7917c00SJeff Kirsher u64 rx_data_errs; /* data errors */ 228f7917c00SJeff Kirsher u64 rx_sequence_errs; /* sequence errors */ 229f7917c00SJeff Kirsher u64 rx_runt; /* # of runt frames */ 230f7917c00SJeff Kirsher u64 rx_jabber; /* # of jabber frames */ 231f7917c00SJeff Kirsher u64 rx_short; /* # of short frames */ 232f7917c00SJeff Kirsher u64 rx_too_long; /* # of oversized frames */ 233f7917c00SJeff Kirsher u64 rx_mac_internal_errs; /* # of internal MAC errors on Rx */ 234f7917c00SJeff Kirsher 235f7917c00SJeff Kirsher u64 rx_frames_64; /* # of Rx frames in a particular range */ 236f7917c00SJeff Kirsher u64 rx_frames_65_127; 237f7917c00SJeff Kirsher u64 rx_frames_128_255; 238f7917c00SJeff Kirsher u64 rx_frames_256_511; 239f7917c00SJeff Kirsher u64 rx_frames_512_1023; 240f7917c00SJeff Kirsher u64 rx_frames_1024_1518; 241f7917c00SJeff Kirsher u64 rx_frames_1519_max; 242f7917c00SJeff Kirsher 243f7917c00SJeff Kirsher u64 rx_cong_drops; /* # of Rx drops due to SGE congestion */ 244f7917c00SJeff Kirsher 245f7917c00SJeff Kirsher unsigned long tx_fifo_parity_err; 246f7917c00SJeff Kirsher unsigned long rx_fifo_parity_err; 247f7917c00SJeff Kirsher unsigned long tx_fifo_urun; 248f7917c00SJeff Kirsher unsigned long rx_fifo_ovfl; 249f7917c00SJeff Kirsher unsigned long serdes_signal_loss; 250f7917c00SJeff Kirsher unsigned long xaui_pcs_ctc_err; 251f7917c00SJeff Kirsher unsigned long xaui_pcs_align_change; 252f7917c00SJeff Kirsher 253f7917c00SJeff Kirsher unsigned long num_toggled; /* # times toggled TxEn due to stuck TX */ 254f7917c00SJeff Kirsher unsigned long num_resets; /* # times reset due to stuck TX */ 255f7917c00SJeff Kirsher 256f7917c00SJeff Kirsher unsigned long link_faults; /* # detected link faults */ 257f7917c00SJeff Kirsher }; 258f7917c00SJeff Kirsher 259f7917c00SJeff Kirsher struct tp_mib_stats { 260f7917c00SJeff Kirsher u32 ipInReceive_hi; 261f7917c00SJeff Kirsher u32 ipInReceive_lo; 262f7917c00SJeff Kirsher u32 ipInHdrErrors_hi; 263f7917c00SJeff Kirsher u32 ipInHdrErrors_lo; 264f7917c00SJeff Kirsher u32 ipInAddrErrors_hi; 265f7917c00SJeff Kirsher u32 ipInAddrErrors_lo; 266f7917c00SJeff Kirsher u32 ipInUnknownProtos_hi; 267f7917c00SJeff Kirsher u32 ipInUnknownProtos_lo; 268f7917c00SJeff Kirsher u32 ipInDiscards_hi; 269f7917c00SJeff Kirsher u32 ipInDiscards_lo; 270f7917c00SJeff Kirsher u32 ipInDelivers_hi; 271f7917c00SJeff Kirsher u32 ipInDelivers_lo; 272f7917c00SJeff Kirsher u32 ipOutRequests_hi; 273f7917c00SJeff Kirsher u32 ipOutRequests_lo; 274f7917c00SJeff Kirsher u32 ipOutDiscards_hi; 275f7917c00SJeff Kirsher u32 ipOutDiscards_lo; 276f7917c00SJeff Kirsher u32 ipOutNoRoutes_hi; 277f7917c00SJeff Kirsher u32 ipOutNoRoutes_lo; 278f7917c00SJeff Kirsher u32 ipReasmTimeout; 279f7917c00SJeff Kirsher u32 ipReasmReqds; 280f7917c00SJeff Kirsher u32 ipReasmOKs; 281f7917c00SJeff Kirsher u32 ipReasmFails; 282f7917c00SJeff Kirsher 283f7917c00SJeff Kirsher u32 reserved[8]; 284f7917c00SJeff Kirsher 285f7917c00SJeff Kirsher u32 tcpActiveOpens; 286f7917c00SJeff Kirsher u32 tcpPassiveOpens; 287f7917c00SJeff Kirsher u32 tcpAttemptFails; 288f7917c00SJeff Kirsher u32 tcpEstabResets; 289f7917c00SJeff Kirsher u32 tcpOutRsts; 290f7917c00SJeff Kirsher u32 tcpCurrEstab; 291f7917c00SJeff Kirsher u32 tcpInSegs_hi; 292f7917c00SJeff Kirsher u32 tcpInSegs_lo; 293f7917c00SJeff Kirsher u32 tcpOutSegs_hi; 294f7917c00SJeff Kirsher u32 tcpOutSegs_lo; 295f7917c00SJeff Kirsher u32 tcpRetransSeg_hi; 296f7917c00SJeff Kirsher u32 tcpRetransSeg_lo; 297f7917c00SJeff Kirsher u32 tcpInErrs_hi; 298f7917c00SJeff Kirsher u32 tcpInErrs_lo; 299f7917c00SJeff Kirsher u32 tcpRtoMin; 300f7917c00SJeff Kirsher u32 tcpRtoMax; 301f7917c00SJeff Kirsher }; 302f7917c00SJeff Kirsher 303f7917c00SJeff Kirsher struct tp_params { 304f7917c00SJeff Kirsher unsigned int nchan; /* # of channels */ 305f7917c00SJeff Kirsher unsigned int pmrx_size; /* total PMRX capacity */ 306f7917c00SJeff Kirsher unsigned int pmtx_size; /* total PMTX capacity */ 307f7917c00SJeff Kirsher unsigned int cm_size; /* total CM capacity */ 308f7917c00SJeff Kirsher unsigned int chan_rx_size; /* per channel Rx size */ 309f7917c00SJeff Kirsher unsigned int chan_tx_size; /* per channel Tx size */ 310f7917c00SJeff Kirsher unsigned int rx_pg_size; /* Rx page size */ 311f7917c00SJeff Kirsher unsigned int tx_pg_size; /* Tx page size */ 312f7917c00SJeff Kirsher unsigned int rx_num_pgs; /* # of Rx pages */ 313f7917c00SJeff Kirsher unsigned int tx_num_pgs; /* # of Tx pages */ 314f7917c00SJeff Kirsher unsigned int ntimer_qs; /* # of timer queues */ 315f7917c00SJeff Kirsher }; 316f7917c00SJeff Kirsher 317f7917c00SJeff Kirsher struct qset_params { /* SGE queue set parameters */ 318f7917c00SJeff Kirsher unsigned int polling; /* polling/interrupt service for rspq */ 319f7917c00SJeff Kirsher unsigned int coalesce_usecs; /* irq coalescing timer */ 320f7917c00SJeff Kirsher unsigned int rspq_size; /* # of entries in response queue */ 321f7917c00SJeff Kirsher unsigned int fl_size; /* # of entries in regular free list */ 322f7917c00SJeff Kirsher unsigned int jumbo_size; /* # of entries in jumbo free list */ 323f7917c00SJeff Kirsher unsigned int txq_size[SGE_TXQ_PER_SET]; /* Tx queue sizes */ 324f7917c00SJeff Kirsher unsigned int cong_thres; /* FL congestion threshold */ 325f7917c00SJeff Kirsher unsigned int vector; /* Interrupt (line or vector) number */ 326f7917c00SJeff Kirsher }; 327f7917c00SJeff Kirsher 328f7917c00SJeff Kirsher struct sge_params { 329f7917c00SJeff Kirsher unsigned int max_pkt_size; /* max offload pkt size */ 330f7917c00SJeff Kirsher struct qset_params qset[SGE_QSETS]; 331f7917c00SJeff Kirsher }; 332f7917c00SJeff Kirsher 333f7917c00SJeff Kirsher struct mc5_params { 334f7917c00SJeff Kirsher unsigned int mode; /* selects MC5 width */ 335f7917c00SJeff Kirsher unsigned int nservers; /* size of server region */ 336f7917c00SJeff Kirsher unsigned int nfilters; /* size of filter region */ 337f7917c00SJeff Kirsher unsigned int nroutes; /* size of routing region */ 338f7917c00SJeff Kirsher }; 339f7917c00SJeff Kirsher 340f7917c00SJeff Kirsher /* Default MC5 region sizes */ 341f7917c00SJeff Kirsher enum { 342f7917c00SJeff Kirsher DEFAULT_NSERVERS = 512, 343f7917c00SJeff Kirsher DEFAULT_NFILTERS = 128 344f7917c00SJeff Kirsher }; 345f7917c00SJeff Kirsher 346f7917c00SJeff Kirsher /* MC5 modes, these must be non-0 */ 347f7917c00SJeff Kirsher enum { 348f7917c00SJeff Kirsher MC5_MODE_144_BIT = 1, 349f7917c00SJeff Kirsher MC5_MODE_72_BIT = 2 350f7917c00SJeff Kirsher }; 351f7917c00SJeff Kirsher 352f7917c00SJeff Kirsher /* MC5 min active region size */ 353f7917c00SJeff Kirsher enum { MC5_MIN_TIDS = 16 }; 354f7917c00SJeff Kirsher 355f7917c00SJeff Kirsher struct vpd_params { 356f7917c00SJeff Kirsher unsigned int cclk; 357f7917c00SJeff Kirsher unsigned int mclk; 358f7917c00SJeff Kirsher unsigned int uclk; 359f7917c00SJeff Kirsher unsigned int mdc; 360f7917c00SJeff Kirsher unsigned int mem_timing; 361f7917c00SJeff Kirsher u8 sn[SERNUM_LEN + 1]; 362f7917c00SJeff Kirsher u8 eth_base[6]; 363f7917c00SJeff Kirsher u8 port_type[MAX_NPORTS]; 364f7917c00SJeff Kirsher unsigned short xauicfg[2]; 365f7917c00SJeff Kirsher }; 366f7917c00SJeff Kirsher 367f7917c00SJeff Kirsher struct pci_params { 368f7917c00SJeff Kirsher unsigned int vpd_cap_addr; 369f7917c00SJeff Kirsher unsigned short speed; 370f7917c00SJeff Kirsher unsigned char width; 371f7917c00SJeff Kirsher unsigned char variant; 372f7917c00SJeff Kirsher }; 373f7917c00SJeff Kirsher 374f7917c00SJeff Kirsher enum { 375f7917c00SJeff Kirsher PCI_VARIANT_PCI, 376f7917c00SJeff Kirsher PCI_VARIANT_PCIX_MODE1_PARITY, 377f7917c00SJeff Kirsher PCI_VARIANT_PCIX_MODE1_ECC, 378f7917c00SJeff Kirsher PCI_VARIANT_PCIX_266_MODE2, 379f7917c00SJeff Kirsher PCI_VARIANT_PCIE 380f7917c00SJeff Kirsher }; 381f7917c00SJeff Kirsher 382f7917c00SJeff Kirsher struct adapter_params { 383f7917c00SJeff Kirsher struct sge_params sge; 384f7917c00SJeff Kirsher struct mc5_params mc5; 385f7917c00SJeff Kirsher struct tp_params tp; 386f7917c00SJeff Kirsher struct vpd_params vpd; 387f7917c00SJeff Kirsher struct pci_params pci; 388f7917c00SJeff Kirsher 389f7917c00SJeff Kirsher const struct adapter_info *info; 390f7917c00SJeff Kirsher 391f7917c00SJeff Kirsher unsigned short mtus[NMTUS]; 392f7917c00SJeff Kirsher unsigned short a_wnd[NCCTRL_WIN]; 393f7917c00SJeff Kirsher unsigned short b_wnd[NCCTRL_WIN]; 394f7917c00SJeff Kirsher 395f7917c00SJeff Kirsher unsigned int nports; /* # of ethernet ports */ 396f7917c00SJeff Kirsher unsigned int chan_map; /* bitmap of in-use Tx channels */ 397f7917c00SJeff Kirsher unsigned int stats_update_period; /* MAC stats accumulation period */ 398f7917c00SJeff Kirsher unsigned int linkpoll_period; /* link poll period in 0.1s */ 399f7917c00SJeff Kirsher unsigned int rev; /* chip revision */ 400f7917c00SJeff Kirsher unsigned int offload; 401f7917c00SJeff Kirsher }; 402f7917c00SJeff Kirsher 403f7917c00SJeff Kirsher enum { /* chip revisions */ 404f7917c00SJeff Kirsher T3_REV_A = 0, 405f7917c00SJeff Kirsher T3_REV_B = 2, 406f7917c00SJeff Kirsher T3_REV_B2 = 3, 407f7917c00SJeff Kirsher T3_REV_C = 4, 408f7917c00SJeff Kirsher }; 409f7917c00SJeff Kirsher 410f7917c00SJeff Kirsher struct trace_params { 411f7917c00SJeff Kirsher u32 sip; 412f7917c00SJeff Kirsher u32 sip_mask; 413f7917c00SJeff Kirsher u32 dip; 414f7917c00SJeff Kirsher u32 dip_mask; 415f7917c00SJeff Kirsher u16 sport; 416f7917c00SJeff Kirsher u16 sport_mask; 417f7917c00SJeff Kirsher u16 dport; 418f7917c00SJeff Kirsher u16 dport_mask; 419f7917c00SJeff Kirsher u32 vlan:12; 420f7917c00SJeff Kirsher u32 vlan_mask:12; 421f7917c00SJeff Kirsher u32 intf:4; 422f7917c00SJeff Kirsher u32 intf_mask:4; 423f7917c00SJeff Kirsher u8 proto; 424f7917c00SJeff Kirsher u8 proto_mask; 425f7917c00SJeff Kirsher }; 426f7917c00SJeff Kirsher 427f7917c00SJeff Kirsher struct link_config { 428f7917c00SJeff Kirsher unsigned int supported; /* link capabilities */ 429f7917c00SJeff Kirsher unsigned int advertising; /* advertised capabilities */ 430f7917c00SJeff Kirsher unsigned short requested_speed; /* speed user has requested */ 431f7917c00SJeff Kirsher unsigned short speed; /* actual link speed */ 432f7917c00SJeff Kirsher unsigned char requested_duplex; /* duplex user has requested */ 433f7917c00SJeff Kirsher unsigned char duplex; /* actual link duplex */ 434f7917c00SJeff Kirsher unsigned char requested_fc; /* flow control user has requested */ 435f7917c00SJeff Kirsher unsigned char fc; /* actual link flow control */ 436f7917c00SJeff Kirsher unsigned char autoneg; /* autonegotiating? */ 437f7917c00SJeff Kirsher unsigned int link_ok; /* link up? */ 438f7917c00SJeff Kirsher }; 439f7917c00SJeff Kirsher 440f7917c00SJeff Kirsher #define SPEED_INVALID 0xffff 441f7917c00SJeff Kirsher #define DUPLEX_INVALID 0xff 442f7917c00SJeff Kirsher 443f7917c00SJeff Kirsher struct mc5 { 444f7917c00SJeff Kirsher struct adapter *adapter; 445f7917c00SJeff Kirsher unsigned int tcam_size; 446f7917c00SJeff Kirsher unsigned char part_type; 447f7917c00SJeff Kirsher unsigned char parity_enabled; 448f7917c00SJeff Kirsher unsigned char mode; 449f7917c00SJeff Kirsher struct mc5_stats stats; 450f7917c00SJeff Kirsher }; 451f7917c00SJeff Kirsher 452f7917c00SJeff Kirsher static inline unsigned int t3_mc5_size(const struct mc5 *p) 453f7917c00SJeff Kirsher { 454f7917c00SJeff Kirsher return p->tcam_size; 455f7917c00SJeff Kirsher } 456f7917c00SJeff Kirsher 457f7917c00SJeff Kirsher struct mc7 { 458f7917c00SJeff Kirsher struct adapter *adapter; /* backpointer to adapter */ 459f7917c00SJeff Kirsher unsigned int size; /* memory size in bytes */ 460f7917c00SJeff Kirsher unsigned int width; /* MC7 interface width */ 461f7917c00SJeff Kirsher unsigned int offset; /* register address offset for MC7 instance */ 462f7917c00SJeff Kirsher const char *name; /* name of MC7 instance */ 463f7917c00SJeff Kirsher struct mc7_stats stats; /* MC7 statistics */ 464f7917c00SJeff Kirsher }; 465f7917c00SJeff Kirsher 466f7917c00SJeff Kirsher static inline unsigned int t3_mc7_size(const struct mc7 *p) 467f7917c00SJeff Kirsher { 468f7917c00SJeff Kirsher return p->size; 469f7917c00SJeff Kirsher } 470f7917c00SJeff Kirsher 471f7917c00SJeff Kirsher struct cmac { 472f7917c00SJeff Kirsher struct adapter *adapter; 473f7917c00SJeff Kirsher unsigned int offset; 474f7917c00SJeff Kirsher unsigned int nucast; /* # of address filters for unicast MACs */ 475f7917c00SJeff Kirsher unsigned int tx_tcnt; 476f7917c00SJeff Kirsher unsigned int tx_xcnt; 477f7917c00SJeff Kirsher u64 tx_mcnt; 478f7917c00SJeff Kirsher unsigned int rx_xcnt; 479f7917c00SJeff Kirsher unsigned int rx_ocnt; 480f7917c00SJeff Kirsher u64 rx_mcnt; 481f7917c00SJeff Kirsher unsigned int toggle_cnt; 482f7917c00SJeff Kirsher unsigned int txen; 483f7917c00SJeff Kirsher u64 rx_pause; 484f7917c00SJeff Kirsher struct mac_stats stats; 485f7917c00SJeff Kirsher }; 486f7917c00SJeff Kirsher 487f7917c00SJeff Kirsher enum { 488f7917c00SJeff Kirsher MAC_DIRECTION_RX = 1, 489f7917c00SJeff Kirsher MAC_DIRECTION_TX = 2, 490f7917c00SJeff Kirsher MAC_RXFIFO_SIZE = 32768 491f7917c00SJeff Kirsher }; 492f7917c00SJeff Kirsher 493f7917c00SJeff Kirsher /* PHY loopback direction */ 494f7917c00SJeff Kirsher enum { 495f7917c00SJeff Kirsher PHY_LOOPBACK_TX = 1, 496f7917c00SJeff Kirsher PHY_LOOPBACK_RX = 2 497f7917c00SJeff Kirsher }; 498f7917c00SJeff Kirsher 499f7917c00SJeff Kirsher /* PHY interrupt types */ 500f7917c00SJeff Kirsher enum { 501f7917c00SJeff Kirsher cphy_cause_link_change = 1, 502f7917c00SJeff Kirsher cphy_cause_fifo_error = 2, 503f7917c00SJeff Kirsher cphy_cause_module_change = 4, 504f7917c00SJeff Kirsher }; 505f7917c00SJeff Kirsher 506f7917c00SJeff Kirsher /* PHY module types */ 507f7917c00SJeff Kirsher enum { 508f7917c00SJeff Kirsher phy_modtype_none, 509f7917c00SJeff Kirsher phy_modtype_sr, 510f7917c00SJeff Kirsher phy_modtype_lr, 511f7917c00SJeff Kirsher phy_modtype_lrm, 512f7917c00SJeff Kirsher phy_modtype_twinax, 513f7917c00SJeff Kirsher phy_modtype_twinax_long, 514f7917c00SJeff Kirsher phy_modtype_unknown 515f7917c00SJeff Kirsher }; 516f7917c00SJeff Kirsher 517f7917c00SJeff Kirsher /* PHY operations */ 518f7917c00SJeff Kirsher struct cphy_ops { 519f7917c00SJeff Kirsher int (*reset)(struct cphy *phy, int wait); 520f7917c00SJeff Kirsher 521f7917c00SJeff Kirsher int (*intr_enable)(struct cphy *phy); 522f7917c00SJeff Kirsher int (*intr_disable)(struct cphy *phy); 523f7917c00SJeff Kirsher int (*intr_clear)(struct cphy *phy); 524f7917c00SJeff Kirsher int (*intr_handler)(struct cphy *phy); 525f7917c00SJeff Kirsher 526f7917c00SJeff Kirsher int (*autoneg_enable)(struct cphy *phy); 527f7917c00SJeff Kirsher int (*autoneg_restart)(struct cphy *phy); 528f7917c00SJeff Kirsher 529f7917c00SJeff Kirsher int (*advertise)(struct cphy *phy, unsigned int advertise_map); 530f7917c00SJeff Kirsher int (*set_loopback)(struct cphy *phy, int mmd, int dir, int enable); 531f7917c00SJeff Kirsher int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex); 532f7917c00SJeff Kirsher int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed, 533f7917c00SJeff Kirsher int *duplex, int *fc); 534f7917c00SJeff Kirsher int (*power_down)(struct cphy *phy, int enable); 535f7917c00SJeff Kirsher 536f7917c00SJeff Kirsher u32 mmds; 537f7917c00SJeff Kirsher }; 538f7917c00SJeff Kirsher enum { 539f7917c00SJeff Kirsher EDC_OPT_AEL2005 = 0, 540f7917c00SJeff Kirsher EDC_OPT_AEL2005_SIZE = 1084, 541f7917c00SJeff Kirsher EDC_TWX_AEL2005 = 1, 542f7917c00SJeff Kirsher EDC_TWX_AEL2005_SIZE = 1464, 543f7917c00SJeff Kirsher EDC_TWX_AEL2020 = 2, 544f7917c00SJeff Kirsher EDC_TWX_AEL2020_SIZE = 1628, 545f7917c00SJeff Kirsher EDC_MAX_SIZE = EDC_TWX_AEL2020_SIZE, /* Max cache size */ 546f7917c00SJeff Kirsher }; 547f7917c00SJeff Kirsher 548f7917c00SJeff Kirsher /* A PHY instance */ 549f7917c00SJeff Kirsher struct cphy { 550f7917c00SJeff Kirsher u8 modtype; /* PHY module type */ 551f7917c00SJeff Kirsher short priv; /* scratch pad */ 552f7917c00SJeff Kirsher unsigned int caps; /* PHY capabilities */ 553f7917c00SJeff Kirsher struct adapter *adapter; /* associated adapter */ 554f7917c00SJeff Kirsher const char *desc; /* PHY description */ 555f7917c00SJeff Kirsher unsigned long fifo_errors; /* FIFO over/under-flows */ 556f7917c00SJeff Kirsher const struct cphy_ops *ops; /* PHY operations */ 557f7917c00SJeff Kirsher struct mdio_if_info mdio; 558f7917c00SJeff Kirsher u16 phy_cache[EDC_MAX_SIZE]; /* EDC cache */ 559f7917c00SJeff Kirsher }; 560f7917c00SJeff Kirsher 561f7917c00SJeff Kirsher /* Convenience MDIO read/write wrappers */ 562f7917c00SJeff Kirsher static inline int t3_mdio_read(struct cphy *phy, int mmd, int reg, 563f7917c00SJeff Kirsher unsigned int *valp) 564f7917c00SJeff Kirsher { 565f7917c00SJeff Kirsher int rc = phy->mdio.mdio_read(phy->mdio.dev, phy->mdio.prtad, mmd, reg); 566f7917c00SJeff Kirsher *valp = (rc >= 0) ? rc : -1; 567f7917c00SJeff Kirsher return (rc >= 0) ? 0 : rc; 568f7917c00SJeff Kirsher } 569f7917c00SJeff Kirsher 570f7917c00SJeff Kirsher static inline int t3_mdio_write(struct cphy *phy, int mmd, int reg, 571f7917c00SJeff Kirsher unsigned int val) 572f7917c00SJeff Kirsher { 573f7917c00SJeff Kirsher return phy->mdio.mdio_write(phy->mdio.dev, phy->mdio.prtad, mmd, 574f7917c00SJeff Kirsher reg, val); 575f7917c00SJeff Kirsher } 576f7917c00SJeff Kirsher 577f7917c00SJeff Kirsher /* Convenience initializer */ 578f7917c00SJeff Kirsher static inline void cphy_init(struct cphy *phy, struct adapter *adapter, 579f7917c00SJeff Kirsher int phy_addr, struct cphy_ops *phy_ops, 580f7917c00SJeff Kirsher const struct mdio_ops *mdio_ops, 581f7917c00SJeff Kirsher unsigned int caps, const char *desc) 582f7917c00SJeff Kirsher { 583f7917c00SJeff Kirsher phy->caps = caps; 584f7917c00SJeff Kirsher phy->adapter = adapter; 585f7917c00SJeff Kirsher phy->desc = desc; 586f7917c00SJeff Kirsher phy->ops = phy_ops; 587f7917c00SJeff Kirsher if (mdio_ops) { 588f7917c00SJeff Kirsher phy->mdio.prtad = phy_addr; 589f7917c00SJeff Kirsher phy->mdio.mmds = phy_ops->mmds; 590f7917c00SJeff Kirsher phy->mdio.mode_support = mdio_ops->mode_support; 591f7917c00SJeff Kirsher phy->mdio.mdio_read = mdio_ops->read; 592f7917c00SJeff Kirsher phy->mdio.mdio_write = mdio_ops->write; 593f7917c00SJeff Kirsher } 594f7917c00SJeff Kirsher } 595f7917c00SJeff Kirsher 596f7917c00SJeff Kirsher /* Accumulate MAC statistics every 180 seconds. For 1G we multiply by 10. */ 597f7917c00SJeff Kirsher #define MAC_STATS_ACCUM_SECS 180 598f7917c00SJeff Kirsher 599f7917c00SJeff Kirsher #define XGM_REG(reg_addr, idx) \ 600f7917c00SJeff Kirsher ((reg_addr) + (idx) * (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR)) 601f7917c00SJeff Kirsher 602f7917c00SJeff Kirsher struct addr_val_pair { 603f7917c00SJeff Kirsher unsigned int reg_addr; 604f7917c00SJeff Kirsher unsigned int val; 605f7917c00SJeff Kirsher }; 606f7917c00SJeff Kirsher 607f7917c00SJeff Kirsher #include "adapter.h" 608f7917c00SJeff Kirsher 609f7917c00SJeff Kirsher #ifndef PCI_VENDOR_ID_CHELSIO 610f7917c00SJeff Kirsher # define PCI_VENDOR_ID_CHELSIO 0x1425 611f7917c00SJeff Kirsher #endif 612f7917c00SJeff Kirsher 613f7917c00SJeff Kirsher #define for_each_port(adapter, iter) \ 614f7917c00SJeff Kirsher for (iter = 0; iter < (adapter)->params.nports; ++iter) 615f7917c00SJeff Kirsher 616f7917c00SJeff Kirsher #define adapter_info(adap) ((adap)->params.info) 617f7917c00SJeff Kirsher 618f7917c00SJeff Kirsher static inline int uses_xaui(const struct adapter *adap) 619f7917c00SJeff Kirsher { 620f7917c00SJeff Kirsher return adapter_info(adap)->caps & SUPPORTED_AUI; 621f7917c00SJeff Kirsher } 622f7917c00SJeff Kirsher 623f7917c00SJeff Kirsher static inline int is_10G(const struct adapter *adap) 624f7917c00SJeff Kirsher { 625f7917c00SJeff Kirsher return adapter_info(adap)->caps & SUPPORTED_10000baseT_Full; 626f7917c00SJeff Kirsher } 627f7917c00SJeff Kirsher 628f7917c00SJeff Kirsher static inline int is_offload(const struct adapter *adap) 629f7917c00SJeff Kirsher { 630f7917c00SJeff Kirsher return adap->params.offload; 631f7917c00SJeff Kirsher } 632f7917c00SJeff Kirsher 633f7917c00SJeff Kirsher static inline unsigned int core_ticks_per_usec(const struct adapter *adap) 634f7917c00SJeff Kirsher { 635f7917c00SJeff Kirsher return adap->params.vpd.cclk / 1000; 636f7917c00SJeff Kirsher } 637f7917c00SJeff Kirsher 638f7917c00SJeff Kirsher static inline unsigned int is_pcie(const struct adapter *adap) 639f7917c00SJeff Kirsher { 640f7917c00SJeff Kirsher return adap->params.pci.variant == PCI_VARIANT_PCIE; 641f7917c00SJeff Kirsher } 642f7917c00SJeff Kirsher 643f7917c00SJeff Kirsher void t3_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask, 644f7917c00SJeff Kirsher u32 val); 645f7917c00SJeff Kirsher void t3_write_regs(struct adapter *adapter, const struct addr_val_pair *p, 646f7917c00SJeff Kirsher int n, unsigned int offset); 647f7917c00SJeff Kirsher int t3_wait_op_done_val(struct adapter *adapter, int reg, u32 mask, 648f7917c00SJeff Kirsher int polarity, int attempts, int delay, u32 *valp); 649f7917c00SJeff Kirsher static inline int t3_wait_op_done(struct adapter *adapter, int reg, u32 mask, 650f7917c00SJeff Kirsher int polarity, int attempts, int delay) 651f7917c00SJeff Kirsher { 652f7917c00SJeff Kirsher return t3_wait_op_done_val(adapter, reg, mask, polarity, attempts, 653f7917c00SJeff Kirsher delay, NULL); 654f7917c00SJeff Kirsher } 655f7917c00SJeff Kirsher int t3_mdio_change_bits(struct cphy *phy, int mmd, int reg, unsigned int clear, 656f7917c00SJeff Kirsher unsigned int set); 657f7917c00SJeff Kirsher int t3_phy_reset(struct cphy *phy, int mmd, int wait); 658f7917c00SJeff Kirsher int t3_phy_advertise(struct cphy *phy, unsigned int advert); 659f7917c00SJeff Kirsher int t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert); 660f7917c00SJeff Kirsher int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex); 661f7917c00SJeff Kirsher int t3_phy_lasi_intr_enable(struct cphy *phy); 662f7917c00SJeff Kirsher int t3_phy_lasi_intr_disable(struct cphy *phy); 663f7917c00SJeff Kirsher int t3_phy_lasi_intr_clear(struct cphy *phy); 664f7917c00SJeff Kirsher int t3_phy_lasi_intr_handler(struct cphy *phy); 665f7917c00SJeff Kirsher 666f7917c00SJeff Kirsher void t3_intr_enable(struct adapter *adapter); 667f7917c00SJeff Kirsher void t3_intr_disable(struct adapter *adapter); 668f7917c00SJeff Kirsher void t3_intr_clear(struct adapter *adapter); 669f7917c00SJeff Kirsher void t3_xgm_intr_enable(struct adapter *adapter, int idx); 670f7917c00SJeff Kirsher void t3_xgm_intr_disable(struct adapter *adapter, int idx); 671f7917c00SJeff Kirsher void t3_port_intr_enable(struct adapter *adapter, int idx); 672f7917c00SJeff Kirsher void t3_port_intr_disable(struct adapter *adapter, int idx); 673f7917c00SJeff Kirsher int t3_slow_intr_handler(struct adapter *adapter); 674f7917c00SJeff Kirsher int t3_phy_intr_handler(struct adapter *adapter); 675f7917c00SJeff Kirsher 676f7917c00SJeff Kirsher void t3_link_changed(struct adapter *adapter, int port_id); 677f7917c00SJeff Kirsher void t3_link_fault(struct adapter *adapter, int port_id); 678f7917c00SJeff Kirsher int t3_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc); 679f7917c00SJeff Kirsher const struct adapter_info *t3_get_adapter_info(unsigned int board_id); 680f7917c00SJeff Kirsher int t3_seeprom_read(struct adapter *adapter, u32 addr, __le32 *data); 681f7917c00SJeff Kirsher int t3_seeprom_write(struct adapter *adapter, u32 addr, __le32 data); 682f7917c00SJeff Kirsher int t3_seeprom_wp(struct adapter *adapter, int enable); 683f7917c00SJeff Kirsher int t3_get_tp_version(struct adapter *adapter, u32 *vers); 684f7917c00SJeff Kirsher int t3_check_tpsram_version(struct adapter *adapter); 685f7917c00SJeff Kirsher int t3_check_tpsram(struct adapter *adapter, const u8 *tp_ram, 686f7917c00SJeff Kirsher unsigned int size); 687f7917c00SJeff Kirsher int t3_set_proto_sram(struct adapter *adap, const u8 *data); 688f7917c00SJeff Kirsher int t3_load_fw(struct adapter *adapter, const u8 * fw_data, unsigned int size); 689f7917c00SJeff Kirsher int t3_get_fw_version(struct adapter *adapter, u32 *vers); 690f7917c00SJeff Kirsher int t3_check_fw_version(struct adapter *adapter); 691f7917c00SJeff Kirsher int t3_init_hw(struct adapter *adapter, u32 fw_params); 692f7917c00SJeff Kirsher int t3_reset_adapter(struct adapter *adapter); 693f7917c00SJeff Kirsher int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, 694f7917c00SJeff Kirsher int reset); 695f7917c00SJeff Kirsher int t3_replay_prep_adapter(struct adapter *adapter); 696f7917c00SJeff Kirsher void t3_led_ready(struct adapter *adapter); 697f7917c00SJeff Kirsher void t3_fatal_err(struct adapter *adapter); 698f7917c00SJeff Kirsher void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on); 699f7917c00SJeff Kirsher void t3_config_rss(struct adapter *adapter, unsigned int rss_config, 700f7917c00SJeff Kirsher const u8 * cpus, const u16 *rspq); 701f7917c00SJeff Kirsher int t3_cim_ctl_blk_read(struct adapter *adap, unsigned int addr, 702f7917c00SJeff Kirsher unsigned int n, unsigned int *valp); 703f7917c00SJeff Kirsher int t3_mc7_bd_read(struct mc7 *mc7, unsigned int start, unsigned int n, 704f7917c00SJeff Kirsher u64 *buf); 705f7917c00SJeff Kirsher 706f7917c00SJeff Kirsher int t3_mac_reset(struct cmac *mac); 707f7917c00SJeff Kirsher void t3b_pcs_reset(struct cmac *mac); 708f7917c00SJeff Kirsher void t3_mac_disable_exact_filters(struct cmac *mac); 709f7917c00SJeff Kirsher void t3_mac_enable_exact_filters(struct cmac *mac); 710f7917c00SJeff Kirsher int t3_mac_enable(struct cmac *mac, int which); 711f7917c00SJeff Kirsher int t3_mac_disable(struct cmac *mac, int which); 712f7917c00SJeff Kirsher int t3_mac_set_mtu(struct cmac *mac, unsigned int mtu); 713f7917c00SJeff Kirsher int t3_mac_set_rx_mode(struct cmac *mac, struct net_device *dev); 714f7917c00SJeff Kirsher int t3_mac_set_address(struct cmac *mac, unsigned int idx, u8 addr[6]); 715f7917c00SJeff Kirsher int t3_mac_set_num_ucast(struct cmac *mac, int n); 716f7917c00SJeff Kirsher const struct mac_stats *t3_mac_update_stats(struct cmac *mac); 717f7917c00SJeff Kirsher int t3_mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex, int fc); 718f7917c00SJeff Kirsher int t3b2_mac_watchdog_task(struct cmac *mac); 719f7917c00SJeff Kirsher 720f7917c00SJeff Kirsher void t3_mc5_prep(struct adapter *adapter, struct mc5 *mc5, int mode); 721f7917c00SJeff Kirsher int t3_mc5_init(struct mc5 *mc5, unsigned int nservers, unsigned int nfilters, 722f7917c00SJeff Kirsher unsigned int nroutes); 723f7917c00SJeff Kirsher void t3_mc5_intr_handler(struct mc5 *mc5); 724f7917c00SJeff Kirsher 725f7917c00SJeff Kirsher void t3_tp_set_offload_mode(struct adapter *adap, int enable); 726f7917c00SJeff Kirsher void t3_tp_get_mib_stats(struct adapter *adap, struct tp_mib_stats *tps); 727f7917c00SJeff Kirsher void t3_load_mtus(struct adapter *adap, unsigned short mtus[NMTUS], 728f7917c00SJeff Kirsher unsigned short alpha[NCCTRL_WIN], 729f7917c00SJeff Kirsher unsigned short beta[NCCTRL_WIN], unsigned short mtu_cap); 730f7917c00SJeff Kirsher void t3_config_trace_filter(struct adapter *adapter, 731f7917c00SJeff Kirsher const struct trace_params *tp, int filter_index, 732f7917c00SJeff Kirsher int invert, int enable); 733f7917c00SJeff Kirsher int t3_config_sched(struct adapter *adap, unsigned int kbps, int sched); 734f7917c00SJeff Kirsher 735f7917c00SJeff Kirsher void t3_sge_prep(struct adapter *adap, struct sge_params *p); 736f7917c00SJeff Kirsher void t3_sge_init(struct adapter *adap, struct sge_params *p); 737f7917c00SJeff Kirsher int t3_sge_init_ecntxt(struct adapter *adapter, unsigned int id, int gts_enable, 738f7917c00SJeff Kirsher enum sge_context_type type, int respq, u64 base_addr, 739f7917c00SJeff Kirsher unsigned int size, unsigned int token, int gen, 740f7917c00SJeff Kirsher unsigned int cidx); 741f7917c00SJeff Kirsher int t3_sge_init_flcntxt(struct adapter *adapter, unsigned int id, 742f7917c00SJeff Kirsher int gts_enable, u64 base_addr, unsigned int size, 743f7917c00SJeff Kirsher unsigned int esize, unsigned int cong_thres, int gen, 744f7917c00SJeff Kirsher unsigned int cidx); 745f7917c00SJeff Kirsher int t3_sge_init_rspcntxt(struct adapter *adapter, unsigned int id, 746f7917c00SJeff Kirsher int irq_vec_idx, u64 base_addr, unsigned int size, 747f7917c00SJeff Kirsher unsigned int fl_thres, int gen, unsigned int cidx); 748f7917c00SJeff Kirsher int t3_sge_init_cqcntxt(struct adapter *adapter, unsigned int id, u64 base_addr, 749f7917c00SJeff Kirsher unsigned int size, int rspq, int ovfl_mode, 750f7917c00SJeff Kirsher unsigned int credits, unsigned int credit_thres); 751f7917c00SJeff Kirsher int t3_sge_enable_ecntxt(struct adapter *adapter, unsigned int id, int enable); 752f7917c00SJeff Kirsher int t3_sge_disable_fl(struct adapter *adapter, unsigned int id); 753f7917c00SJeff Kirsher int t3_sge_disable_rspcntxt(struct adapter *adapter, unsigned int id); 754f7917c00SJeff Kirsher int t3_sge_disable_cqcntxt(struct adapter *adapter, unsigned int id); 755f7917c00SJeff Kirsher int t3_sge_cqcntxt_op(struct adapter *adapter, unsigned int id, unsigned int op, 756f7917c00SJeff Kirsher unsigned int credits); 757f7917c00SJeff Kirsher 758f7917c00SJeff Kirsher int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter, 759f7917c00SJeff Kirsher int phy_addr, const struct mdio_ops *mdio_ops); 760f7917c00SJeff Kirsher int t3_ael1002_phy_prep(struct cphy *phy, struct adapter *adapter, 761f7917c00SJeff Kirsher int phy_addr, const struct mdio_ops *mdio_ops); 762f7917c00SJeff Kirsher int t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter, 763f7917c00SJeff Kirsher int phy_addr, const struct mdio_ops *mdio_ops); 764f7917c00SJeff Kirsher int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter, 765f7917c00SJeff Kirsher int phy_addr, const struct mdio_ops *mdio_ops); 766f7917c00SJeff Kirsher int t3_ael2020_phy_prep(struct cphy *phy, struct adapter *adapter, 767f7917c00SJeff Kirsher int phy_addr, const struct mdio_ops *mdio_ops); 768f7917c00SJeff Kirsher int t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, 769f7917c00SJeff Kirsher const struct mdio_ops *mdio_ops); 770f7917c00SJeff Kirsher int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, 771f7917c00SJeff Kirsher int phy_addr, const struct mdio_ops *mdio_ops); 772f7917c00SJeff Kirsher int t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter, 773f7917c00SJeff Kirsher int phy_addr, const struct mdio_ops *mdio_ops); 774f7917c00SJeff Kirsher #endif /* __CHELSIO_COMMON_H */ 775