Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Tehuti Networks(R) Network Driver |
| 3 | * Copyright (C) 2007 Tehuti Networks Ltd. All rights reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | */ |
| 10 | |
| 11 | #ifndef _TEHUTI_H |
| 12 | #define _TEHUTI_H |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/netdevice.h> |
| 17 | #include <linux/etherdevice.h> |
| 18 | #include <linux/pci.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/ethtool.h> |
| 21 | #include <linux/mii.h> |
| 22 | #include <linux/crc32.h> |
| 23 | #include <linux/uaccess.h> |
| 24 | #include <linux/in.h> |
| 25 | #include <linux/ip.h> |
| 26 | #include <linux/tcp.h> |
| 27 | #include <linux/sched.h> |
| 28 | #include <linux/tty.h> |
| 29 | #include <linux/if_vlan.h> |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 30 | #include <linux/interrupt.h> |
| 31 | #include <linux/vmalloc.h> |
Ben Hutchings | 06e1f9f | 2009-02-26 23:20:56 -0800 | [diff] [blame] | 32 | #include <linux/firmware.h> |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 33 | #include <asm/byteorder.h> |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 34 | #include <linux/dma-mapping.h> |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 35 | |
| 36 | /* Compile Time Switches */ |
| 37 | /* start */ |
| 38 | #define BDX_TSO |
| 39 | #define BDX_LLTX |
| 40 | #define BDX_DELAY_WPTR |
| 41 | /* #define BDX_MSI */ |
| 42 | /* end */ |
| 43 | |
| 44 | #if !defined CONFIG_PCI_MSI |
| 45 | # undef BDX_MSI |
| 46 | #endif |
| 47 | |
| 48 | #define BDX_DEF_MSG_ENABLE (NETIF_MSG_DRV | \ |
| 49 | NETIF_MSG_PROBE | \ |
| 50 | NETIF_MSG_LINK) |
| 51 | |
| 52 | /* ioctl ops */ |
| 53 | #define BDX_OP_READ 1 |
| 54 | #define BDX_OP_WRITE 2 |
| 55 | |
| 56 | /* RX copy break size */ |
| 57 | #define BDX_COPYBREAK 257 |
| 58 | |
| 59 | #define DRIVER_AUTHOR "Tehuti Networks(R)" |
| 60 | #define BDX_DRV_DESC "Tehuti Networks(R) Network Driver" |
| 61 | #define BDX_DRV_NAME "tehuti" |
| 62 | #define BDX_NIC_NAME "Tehuti 10 Giga TOE SmartNIC" |
| 63 | #define BDX_NIC2PORT_NAME "Tehuti 2-Port 10 Giga TOE SmartNIC" |
| 64 | #define BDX_DRV_VERSION "7.29.3" |
| 65 | |
| 66 | #ifdef BDX_MSI |
| 67 | # define BDX_MSI_STRING "msi " |
| 68 | #else |
| 69 | # define BDX_MSI_STRING "" |
| 70 | #endif |
| 71 | |
| 72 | /* netdev tx queue len for Luxor. default value is, btw, 1000 |
| 73 | * ifcontig eth1 txqueuelen 3000 - to change it at runtime */ |
| 74 | #define BDX_NDEV_TXQ_LEN 3000 |
| 75 | |
| 76 | #define FIFO_SIZE 4096 |
| 77 | #define FIFO_EXTRA_SPACE 1024 |
| 78 | |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 79 | #if BITS_PER_LONG == 64 |
| 80 | # define H32_64(x) (u32) ((u64)(x) >> 32) |
| 81 | # define L32_64(x) (u32) ((u64)(x) & 0xffffffff) |
| 82 | #elif BITS_PER_LONG == 32 |
| 83 | # define H32_64(x) 0 |
| 84 | # define L32_64(x) ((u32) (x)) |
| 85 | #else /* BITS_PER_LONG == ?? */ |
| 86 | # error BITS_PER_LONG is undefined. Must be 64 or 32 |
| 87 | #endif /* BITS_PER_LONG */ |
| 88 | |
| 89 | #ifdef __BIG_ENDIAN |
| 90 | # define CPU_CHIP_SWAP32(x) swab32(x) |
| 91 | # define CPU_CHIP_SWAP16(x) swab16(x) |
| 92 | #else |
| 93 | # define CPU_CHIP_SWAP32(x) (x) |
| 94 | # define CPU_CHIP_SWAP16(x) (x) |
| 95 | #endif |
| 96 | |
| 97 | #define READ_REG(pp, reg) readl(pp->pBdxRegs + reg) |
| 98 | #define WRITE_REG(pp, reg, val) writel(val, pp->pBdxRegs + reg) |
| 99 | |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 100 | #ifndef NET_IP_ALIGN |
| 101 | # define NET_IP_ALIGN 2 |
| 102 | #endif |
| 103 | |
| 104 | #ifndef NETDEV_TX_OK |
| 105 | # define NETDEV_TX_OK 0 |
| 106 | #endif |
| 107 | |
| 108 | #define LUXOR_MAX_PORT 2 |
| 109 | #define BDX_MAX_RX_DONE 150 |
| 110 | #define BDX_TXF_DESC_SZ 16 |
| 111 | #define BDX_MAX_TX_LEVEL (priv->txd_fifo0.m.memsz - 16) |
| 112 | #define BDX_MIN_TX_LEVEL 256 |
| 113 | #define BDX_NO_UPD_PACKETS 40 |
| 114 | |
| 115 | struct pci_nic { |
| 116 | int port_num; |
| 117 | void __iomem *regs; |
| 118 | int irq_type; |
| 119 | struct bdx_priv *priv[LUXOR_MAX_PORT]; |
| 120 | }; |
| 121 | |
| 122 | enum { IRQ_INTX, IRQ_MSI, IRQ_MSIX }; |
| 123 | |
| 124 | #define PCK_TH_MULT 128 |
| 125 | #define INT_COAL_MULT 2 |
| 126 | |
| 127 | #define BITS_MASK(nbits) ((1<<nbits)-1) |
| 128 | #define GET_BITS_SHIFT(x, nbits, nshift) (((x)>>nshift)&BITS_MASK(nbits)) |
| 129 | #define BITS_SHIFT_MASK(nbits, nshift) (BITS_MASK(nbits)<<nshift) |
| 130 | #define BITS_SHIFT_VAL(x, nbits, nshift) (((x)&BITS_MASK(nbits))<<nshift) |
| 131 | #define BITS_SHIFT_CLEAR(x, nbits, nshift) \ |
| 132 | ((x)&(~BITS_SHIFT_MASK(nbits, nshift))) |
| 133 | |
| 134 | #define GET_INT_COAL(x) GET_BITS_SHIFT(x, 15, 0) |
| 135 | #define GET_INT_COAL_RC(x) GET_BITS_SHIFT(x, 1, 15) |
| 136 | #define GET_RXF_TH(x) GET_BITS_SHIFT(x, 4, 16) |
| 137 | #define GET_PCK_TH(x) GET_BITS_SHIFT(x, 4, 20) |
| 138 | |
| 139 | #define INT_REG_VAL(coal, coal_rc, rxf_th, pck_th) \ |
| 140 | ((coal)|((coal_rc)<<15)|((rxf_th)<<16)|((pck_th)<<20)) |
| 141 | |
| 142 | struct fifo { |
| 143 | dma_addr_t da; /* physical address of fifo (used by HW) */ |
| 144 | char *va; /* virtual address of fifo (used by SW) */ |
| 145 | u32 rptr, wptr; /* cached values of RPTR and WPTR registers, |
| 146 | they're 32 bits on both 32 and 64 archs */ |
| 147 | u16 reg_CFG0, reg_CFG1; |
| 148 | u16 reg_RPTR, reg_WPTR; |
| 149 | u16 memsz; /* memory size allocated for fifo */ |
| 150 | u16 size_mask; |
| 151 | u16 pktsz; /* skb packet size to allocate */ |
| 152 | u16 rcvno; /* number of buffers that come from this RXF */ |
| 153 | }; |
| 154 | |
| 155 | struct txf_fifo { |
| 156 | struct fifo m; /* minimal set of variables used by all fifos */ |
| 157 | }; |
| 158 | |
| 159 | struct txd_fifo { |
| 160 | struct fifo m; /* minimal set of variables used by all fifos */ |
| 161 | }; |
| 162 | |
| 163 | struct rxf_fifo { |
| 164 | struct fifo m; /* minimal set of variables used by all fifos */ |
| 165 | }; |
| 166 | |
| 167 | struct rxd_fifo { |
| 168 | struct fifo m; /* minimal set of variables used by all fifos */ |
| 169 | }; |
| 170 | |
| 171 | struct rx_map { |
| 172 | u64 dma; |
| 173 | struct sk_buff *skb; |
| 174 | }; |
| 175 | |
| 176 | struct rxdb { |
| 177 | int *stack; |
| 178 | struct rx_map *elems; |
| 179 | int nelem; |
| 180 | int top; |
| 181 | }; |
| 182 | |
| 183 | union bdx_dma_addr { |
| 184 | dma_addr_t dma; |
| 185 | struct sk_buff *skb; |
| 186 | }; |
| 187 | |
| 188 | /* Entry in the db. |
| 189 | * if len == 0 addr is dma |
| 190 | * if len != 0 addr is skb */ |
| 191 | struct tx_map { |
| 192 | union bdx_dma_addr addr; |
| 193 | int len; |
| 194 | }; |
| 195 | |
| 196 | /* tx database - implemented as circular fifo buffer*/ |
| 197 | struct txdb { |
| 198 | struct tx_map *start; /* points to the first element */ |
| 199 | struct tx_map *end; /* points just AFTER the last element */ |
| 200 | struct tx_map *rptr; /* points to the next element to read */ |
| 201 | struct tx_map *wptr; /* points to the next element to write */ |
| 202 | int size; /* number of elements in the db */ |
| 203 | }; |
| 204 | |
| 205 | /*Internal stats structure*/ |
| 206 | struct bdx_stats { |
| 207 | u64 InUCast; /* 0x7200 */ |
| 208 | u64 InMCast; /* 0x7210 */ |
| 209 | u64 InBCast; /* 0x7220 */ |
| 210 | u64 InPkts; /* 0x7230 */ |
| 211 | u64 InErrors; /* 0x7240 */ |
| 212 | u64 InDropped; /* 0x7250 */ |
| 213 | u64 FrameTooLong; /* 0x7260 */ |
| 214 | u64 FrameSequenceErrors; /* 0x7270 */ |
| 215 | u64 InVLAN; /* 0x7280 */ |
| 216 | u64 InDroppedDFE; /* 0x7290 */ |
| 217 | u64 InDroppedIntFull; /* 0x72A0 */ |
| 218 | u64 InFrameAlignErrors; /* 0x72B0 */ |
| 219 | |
| 220 | /* 0x72C0-0x72E0 RSRV */ |
| 221 | |
| 222 | u64 OutUCast; /* 0x72F0 */ |
| 223 | u64 OutMCast; /* 0x7300 */ |
| 224 | u64 OutBCast; /* 0x7310 */ |
| 225 | u64 OutPkts; /* 0x7320 */ |
| 226 | |
| 227 | /* 0x7330-0x7360 RSRV */ |
| 228 | |
| 229 | u64 OutVLAN; /* 0x7370 */ |
| 230 | u64 InUCastOctects; /* 0x7380 */ |
| 231 | u64 OutUCastOctects; /* 0x7390 */ |
| 232 | |
| 233 | /* 0x73A0-0x73B0 RSRV */ |
| 234 | |
| 235 | u64 InBCastOctects; /* 0x73C0 */ |
| 236 | u64 OutBCastOctects; /* 0x73D0 */ |
| 237 | u64 InOctects; /* 0x73E0 */ |
| 238 | u64 OutOctects; /* 0x73F0 */ |
| 239 | }; |
| 240 | |
| 241 | struct bdx_priv { |
| 242 | void __iomem *pBdxRegs; |
| 243 | struct net_device *ndev; |
| 244 | |
| 245 | struct napi_struct napi; |
| 246 | |
| 247 | /* RX FIFOs: 1 for data (full) descs, and 2 for free descs */ |
| 248 | struct rxd_fifo rxd_fifo0; |
| 249 | struct rxf_fifo rxf_fifo0; |
| 250 | struct rxdb *rxdb; /* rx dbs to store skb pointers */ |
| 251 | int napi_stop; |
| 252 | struct vlan_group *vlgrp; |
| 253 | |
| 254 | /* Tx FIFOs: 1 for data desc, 1 for empty (acks) desc */ |
| 255 | struct txd_fifo txd_fifo0; |
| 256 | struct txf_fifo txf_fifo0; |
| 257 | |
| 258 | struct txdb txdb; |
| 259 | int tx_level; |
| 260 | #ifdef BDX_DELAY_WPTR |
| 261 | int tx_update_mark; |
| 262 | int tx_noupd; |
| 263 | #endif |
| 264 | spinlock_t tx_lock; /* NETIF_F_LLTX mode */ |
| 265 | |
| 266 | /* rarely used */ |
| 267 | u8 port; |
| 268 | u32 msg_enable; |
| 269 | int stats_flag; |
| 270 | struct bdx_stats hw_stats; |
| 271 | struct net_device_stats net_stats; |
| 272 | struct pci_dev *pdev; |
| 273 | |
| 274 | struct pci_nic *nic; |
| 275 | |
| 276 | u8 txd_size; |
| 277 | u8 txf_size; |
| 278 | u8 rxd_size; |
| 279 | u8 rxf_size; |
| 280 | u32 rdintcm; |
| 281 | u32 tdintcm; |
| 282 | }; |
| 283 | |
| 284 | /* RX FREE descriptor - 64bit*/ |
| 285 | struct rxf_desc { |
| 286 | u32 info; /* Buffer Count + Info - described below */ |
| 287 | u32 va_lo; /* VAdr[31:0] */ |
| 288 | u32 va_hi; /* VAdr[63:32] */ |
| 289 | u32 pa_lo; /* PAdr[31:0] */ |
| 290 | u32 pa_hi; /* PAdr[63:32] */ |
| 291 | u32 len; /* Buffer Length */ |
| 292 | }; |
| 293 | |
| 294 | #define GET_RXD_BC(x) GET_BITS_SHIFT((x), 5, 0) |
| 295 | #define GET_RXD_RXFQ(x) GET_BITS_SHIFT((x), 2, 8) |
| 296 | #define GET_RXD_TO(x) GET_BITS_SHIFT((x), 1, 15) |
| 297 | #define GET_RXD_TYPE(x) GET_BITS_SHIFT((x), 4, 16) |
| 298 | #define GET_RXD_ERR(x) GET_BITS_SHIFT((x), 6, 21) |
| 299 | #define GET_RXD_RXP(x) GET_BITS_SHIFT((x), 1, 27) |
| 300 | #define GET_RXD_PKT_ID(x) GET_BITS_SHIFT((x), 3, 28) |
| 301 | #define GET_RXD_VTAG(x) GET_BITS_SHIFT((x), 1, 31) |
| 302 | #define GET_RXD_VLAN_ID(x) GET_BITS_SHIFT((x), 12, 0) |
Patrick McHardy | 38b2219 | 2008-07-06 20:48:41 -0700 | [diff] [blame] | 303 | #define GET_RXD_VLAN_TCI(x) GET_BITS_SHIFT((x), 16, 0) |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 304 | #define GET_RXD_CFI(x) GET_BITS_SHIFT((x), 1, 12) |
| 305 | #define GET_RXD_PRIO(x) GET_BITS_SHIFT((x), 3, 13) |
| 306 | |
| 307 | struct rxd_desc { |
| 308 | u32 rxd_val1; |
| 309 | u16 len; |
| 310 | u16 rxd_vlan; |
| 311 | u32 va_lo; |
| 312 | u32 va_hi; |
| 313 | }; |
| 314 | |
| 315 | /* PBL describes each virtual buffer to be */ |
| 316 | /* transmitted from the host.*/ |
| 317 | struct pbl { |
| 318 | u32 pa_lo; |
| 319 | u32 pa_hi; |
| 320 | u32 len; |
| 321 | }; |
| 322 | |
| 323 | /* First word for TXD descriptor. It means: type = 3 for regular Tx packet, |
| 324 | * hw_csum = 7 for ip+udp+tcp hw checksums */ |
| 325 | #define TXD_W1_VAL(bc, checksum, vtag, lgsnd, vlan_id) \ |
| 326 | ((bc) | ((checksum)<<5) | ((vtag)<<8) | \ |
| 327 | ((lgsnd)<<9) | (0x30000) | ((vlan_id)<<20)) |
| 328 | |
| 329 | struct txd_desc { |
| 330 | u32 txd_val1; |
| 331 | u16 mss; |
| 332 | u16 length; |
| 333 | u32 va_lo; |
| 334 | u32 va_hi; |
| 335 | struct pbl pbl[0]; /* Fragments */ |
| 336 | } __attribute__ ((packed)); |
| 337 | |
| 338 | /* Register region size */ |
| 339 | #define BDX_REGS_SIZE 0x1000 |
| 340 | |
| 341 | /* Registers from 0x0000-0x00fc were remapped to 0x4000-0x40fc */ |
| 342 | #define regTXD_CFG1_0 0x4000 |
| 343 | #define regRXF_CFG1_0 0x4010 |
| 344 | #define regRXD_CFG1_0 0x4020 |
| 345 | #define regTXF_CFG1_0 0x4030 |
| 346 | #define regTXD_CFG0_0 0x4040 |
| 347 | #define regRXF_CFG0_0 0x4050 |
| 348 | #define regRXD_CFG0_0 0x4060 |
| 349 | #define regTXF_CFG0_0 0x4070 |
| 350 | #define regTXD_WPTR_0 0x4080 |
| 351 | #define regRXF_WPTR_0 0x4090 |
| 352 | #define regRXD_WPTR_0 0x40A0 |
| 353 | #define regTXF_WPTR_0 0x40B0 |
| 354 | #define regTXD_RPTR_0 0x40C0 |
| 355 | #define regRXF_RPTR_0 0x40D0 |
| 356 | #define regRXD_RPTR_0 0x40E0 |
| 357 | #define regTXF_RPTR_0 0x40F0 |
| 358 | #define regTXF_RPTR_3 0x40FC |
| 359 | |
| 360 | /* hardware versioning */ |
| 361 | #define FW_VER 0x5010 |
| 362 | #define SROM_VER 0x5020 |
| 363 | #define FPGA_VER 0x5030 |
| 364 | #define FPGA_SEED 0x5040 |
| 365 | |
| 366 | /* Registers from 0x0100-0x0150 were remapped to 0x5100-0x5150 */ |
| 367 | #define regISR regISR0 |
| 368 | #define regISR0 0x5100 |
| 369 | |
| 370 | #define regIMR regIMR0 |
| 371 | #define regIMR0 0x5110 |
| 372 | |
| 373 | #define regRDINTCM0 0x5120 |
| 374 | #define regRDINTCM2 0x5128 |
| 375 | |
| 376 | #define regTDINTCM0 0x5130 |
| 377 | |
| 378 | #define regISR_MSK0 0x5140 |
| 379 | |
| 380 | #define regINIT_SEMAPHORE 0x5170 |
| 381 | #define regINIT_STATUS 0x5180 |
| 382 | |
| 383 | #define regMAC_LNK_STAT 0x0200 |
| 384 | #define MAC_LINK_STAT 0x4 /* Link state */ |
| 385 | |
| 386 | #define regGMAC_RXF_A 0x1240 |
| 387 | |
| 388 | #define regUNC_MAC0_A 0x1250 |
| 389 | #define regUNC_MAC1_A 0x1260 |
| 390 | #define regUNC_MAC2_A 0x1270 |
| 391 | |
| 392 | #define regVLAN_0 0x1800 |
| 393 | |
| 394 | #define regMAX_FRAME_A 0x12C0 |
| 395 | |
| 396 | #define regRX_MAC_MCST0 0x1A80 |
| 397 | #define regRX_MAC_MCST1 0x1A84 |
| 398 | #define MAC_MCST_NUM 15 |
| 399 | #define regRX_MCST_HASH0 0x1A00 |
| 400 | #define MAC_MCST_HASH_NUM 8 |
| 401 | |
| 402 | #define regVPC 0x2300 |
| 403 | #define regVIC 0x2320 |
| 404 | #define regVGLB 0x2340 |
| 405 | |
| 406 | #define regCLKPLL 0x5000 |
| 407 | |
| 408 | /*for 10G only*/ |
| 409 | #define regREVISION 0x6000 |
| 410 | #define regSCRATCH 0x6004 |
| 411 | #define regCTRLST 0x6008 |
| 412 | #define regMAC_ADDR_0 0x600C |
| 413 | #define regMAC_ADDR_1 0x6010 |
| 414 | #define regFRM_LENGTH 0x6014 |
| 415 | #define regPAUSE_QUANT 0x6018 |
| 416 | #define regRX_FIFO_SECTION 0x601C |
| 417 | #define regTX_FIFO_SECTION 0x6020 |
| 418 | #define regRX_FULLNESS 0x6024 |
| 419 | #define regTX_FULLNESS 0x6028 |
| 420 | #define regHASHTABLE 0x602C |
| 421 | #define regMDIO_ST 0x6030 |
| 422 | #define regMDIO_CTL 0x6034 |
| 423 | #define regMDIO_DATA 0x6038 |
| 424 | #define regMDIO_ADDR 0x603C |
| 425 | |
| 426 | #define regRST_PORT 0x7000 |
| 427 | #define regDIS_PORT 0x7010 |
| 428 | #define regRST_QU 0x7020 |
| 429 | #define regDIS_QU 0x7030 |
| 430 | |
| 431 | #define regCTRLST_TX_ENA 0x0001 |
| 432 | #define regCTRLST_RX_ENA 0x0002 |
| 433 | #define regCTRLST_PRM_ENA 0x0010 |
| 434 | #define regCTRLST_PAD_ENA 0x0020 |
| 435 | |
| 436 | #define regCTRLST_BASE (regCTRLST_PAD_ENA|regCTRLST_PRM_ENA) |
| 437 | |
| 438 | #define regRX_FLT 0x1400 |
| 439 | |
| 440 | /* TXD TXF RXF RXD CONFIG 0x0000 --- 0x007c*/ |
| 441 | #define TX_RX_CFG1_BASE 0xffffffff /*0-31 */ |
| 442 | #define TX_RX_CFG0_BASE 0xfffff000 /*31:12 */ |
| 443 | #define TX_RX_CFG0_RSVD 0x0ffc /*11:2 */ |
| 444 | #define TX_RX_CFG0_SIZE 0x0003 /*1:0 */ |
| 445 | |
| 446 | /* TXD TXF RXF RXD WRITE 0x0080 --- 0x00BC */ |
| 447 | #define TXF_WPTR_WR_PTR 0x7ff8 /*14:3 */ |
| 448 | |
| 449 | /* TXD TXF RXF RXD READ 0x00CO --- 0x00FC */ |
| 450 | #define TXF_RPTR_RD_PTR 0x7ff8 /*14:3 */ |
| 451 | |
| 452 | #define TXF_WPTR_MASK 0x7ff0 /* last 4 bits are dropped |
| 453 | * size is rounded to 16 */ |
| 454 | |
| 455 | /* regISR 0x0100 */ |
| 456 | /* regIMR 0x0110 */ |
| 457 | #define IMR_INPROG 0x80000000 /*31 */ |
| 458 | #define IR_LNKCHG1 0x10000000 /*28 */ |
| 459 | #define IR_LNKCHG0 0x08000000 /*27 */ |
| 460 | #define IR_GPIO 0x04000000 /*26 */ |
| 461 | #define IR_RFRSH 0x02000000 /*25 */ |
| 462 | #define IR_RSVD 0x01000000 /*24 */ |
| 463 | #define IR_SWI 0x00800000 /*23 */ |
| 464 | #define IR_RX_FREE_3 0x00400000 /*22 */ |
| 465 | #define IR_RX_FREE_2 0x00200000 /*21 */ |
| 466 | #define IR_RX_FREE_1 0x00100000 /*20 */ |
| 467 | #define IR_RX_FREE_0 0x00080000 /*19 */ |
| 468 | #define IR_TX_FREE_3 0x00040000 /*18 */ |
| 469 | #define IR_TX_FREE_2 0x00020000 /*17 */ |
| 470 | #define IR_TX_FREE_1 0x00010000 /*16 */ |
| 471 | #define IR_TX_FREE_0 0x00008000 /*15 */ |
| 472 | #define IR_RX_DESC_3 0x00004000 /*14 */ |
| 473 | #define IR_RX_DESC_2 0x00002000 /*13 */ |
| 474 | #define IR_RX_DESC_1 0x00001000 /*12 */ |
| 475 | #define IR_RX_DESC_0 0x00000800 /*11 */ |
| 476 | #define IR_PSE 0x00000400 /*10 */ |
| 477 | #define IR_TMR3 0x00000200 /*9 */ |
| 478 | #define IR_TMR2 0x00000100 /*8 */ |
| 479 | #define IR_TMR1 0x00000080 /*7 */ |
| 480 | #define IR_TMR0 0x00000040 /*6 */ |
| 481 | #define IR_VNT 0x00000020 /*5 */ |
| 482 | #define IR_RxFL 0x00000010 /*4 */ |
| 483 | #define IR_SDPERR 0x00000008 /*3 */ |
| 484 | #define IR_TR 0x00000004 /*2 */ |
| 485 | #define IR_PCIE_LINK 0x00000002 /*1 */ |
| 486 | #define IR_PCIE_TOUT 0x00000001 /*0 */ |
| 487 | |
| 488 | #define IR_EXTRA (IR_RX_FREE_0 | IR_LNKCHG0 | IR_PSE | \ |
| 489 | IR_TMR0 | IR_PCIE_LINK | IR_PCIE_TOUT) |
| 490 | #define IR_RUN (IR_EXTRA | IR_RX_DESC_0 | IR_TX_FREE_0) |
| 491 | #define IR_ALL 0xfdfffff7 |
| 492 | |
| 493 | #define IR_LNKCHG0_ofst 27 |
| 494 | |
| 495 | #define GMAC_RX_FILTER_OSEN 0x1000 /* shared OS enable */ |
| 496 | #define GMAC_RX_FILTER_TXFC 0x0400 /* Tx flow control */ |
| 497 | #define GMAC_RX_FILTER_RSV0 0x0200 /* reserved */ |
| 498 | #define GMAC_RX_FILTER_FDA 0x0100 /* filter out direct address */ |
| 499 | #define GMAC_RX_FILTER_AOF 0x0080 /* accept over run */ |
| 500 | #define GMAC_RX_FILTER_ACF 0x0040 /* accept control frames */ |
| 501 | #define GMAC_RX_FILTER_ARUNT 0x0020 /* accept under run */ |
| 502 | #define GMAC_RX_FILTER_ACRC 0x0010 /* accept crc error */ |
| 503 | #define GMAC_RX_FILTER_AM 0x0008 /* accept multicast */ |
| 504 | #define GMAC_RX_FILTER_AB 0x0004 /* accept broadcast */ |
| 505 | #define GMAC_RX_FILTER_PRM 0x0001 /* [0:1] promiscous mode */ |
| 506 | |
| 507 | #define MAX_FRAME_AB_VAL 0x3fff /* 13:0 */ |
| 508 | |
| 509 | #define CLKPLL_PLLLKD 0x0200 /*9 */ |
| 510 | #define CLKPLL_RSTEND 0x0100 /*8 */ |
| 511 | #define CLKPLL_SFTRST 0x0001 /*0 */ |
| 512 | |
| 513 | #define CLKPLL_LKD (CLKPLL_PLLLKD|CLKPLL_RSTEND) |
| 514 | |
| 515 | /* |
| 516 | * PCI-E Device Control Register (Offset 0x88) |
| 517 | * Source: Luxor Data Sheet, 7.1.3.3.3 |
| 518 | */ |
| 519 | #define PCI_DEV_CTRL_REG 0x88 |
| 520 | #define GET_DEV_CTRL_MAXPL(x) GET_BITS_SHIFT(x, 3, 5) |
| 521 | #define GET_DEV_CTRL_MRRS(x) GET_BITS_SHIFT(x, 3, 12) |
| 522 | |
| 523 | /* |
| 524 | * PCI-E Link Status Register (Offset 0x92) |
| 525 | * Source: Luxor Data Sheet, 7.1.3.3.7 |
| 526 | */ |
| 527 | #define PCI_LINK_STATUS_REG 0x92 |
| 528 | #define GET_LINK_STATUS_LANES(x) GET_BITS_SHIFT(x, 6, 4) |
| 529 | |
| 530 | /* Debugging Macros */ |
| 531 | |
Joe Perches | 865a21a | 2010-02-15 08:34:22 +0000 | [diff] [blame] | 532 | #define DBG2(fmt, args...) \ |
| 533 | pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args) |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 534 | |
| 535 | #define BDX_ASSERT(x) BUG_ON(x) |
| 536 | |
| 537 | #ifdef DEBUG |
| 538 | |
Joe Perches | 865a21a | 2010-02-15 08:34:22 +0000 | [diff] [blame] | 539 | #define ENTER \ |
| 540 | do { \ |
| 541 | pr_err("%s:%-5d: ENTER\n", __func__, __LINE__); \ |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 542 | } while (0) |
| 543 | |
Joe Perches | 865a21a | 2010-02-15 08:34:22 +0000 | [diff] [blame] | 544 | #define RET(args...) \ |
| 545 | do { \ |
| 546 | pr_err("%s:%-5d: RETURN\n", __func__, __LINE__); \ |
| 547 | return args; \ |
| 548 | } while (0) |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 549 | |
Joe Perches | 865a21a | 2010-02-15 08:34:22 +0000 | [diff] [blame] | 550 | #define DBG(fmt, args...) \ |
| 551 | pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args) |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 552 | #else |
Joe Perches | 865a21a | 2010-02-15 08:34:22 +0000 | [diff] [blame] | 553 | #define ENTER do { } while (0) |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 554 | #define RET(args...) return args |
Joe Perches | 865a21a | 2010-02-15 08:34:22 +0000 | [diff] [blame] | 555 | #define DBG(fmt, args...) \ |
| 556 | do { \ |
| 557 | if (0) \ |
| 558 | pr_err(fmt, ##args); \ |
| 559 | } while (0) |
Andy Gospodarek | 1a348cc | 2007-09-17 18:50:36 -0700 | [diff] [blame] | 560 | #endif |
| 561 | |
| 562 | #endif /* _BDX__H */ |