7 * The Tigon uses 64-bit host addresses, regardless of their actual
8 * length, and it expects a big-endian format. For 32 bit systems the
9 * upper 32 bits of the address are simply ignored (zero), however for
10 * little endian 64 bit systems (Alpha) this looks strange with the
11 * two parts of the address word being swapped.
13 * The addresses are split in two 32 bit words for all architectures
14 * as some of them are in PCI shared memory and it is necessary to use
15 * readl/writel to access them.
17 * The addressing code is derived from Pete Wyckoff's work, but
18 * modified to deal properly with readl/writel usage.
27 static inline void set_aceaddr(aceaddr
*aa
, volatile void *addr
)
29 unsigned long baddr
= virt_to_bus((void *)addr
);
30 #if (BITS_PER_LONG == 64)
31 aa
->addrlo
= baddr
& 0xffffffff;
32 aa
->addrhi
= baddr
>> 32;
34 /* Don't bother setting zero every time */
41 static inline void set_aceaddr_bus(aceaddr
*aa
, volatile void *addr
)
43 unsigned long baddr
= (unsigned long)addr
;
44 #if (BITS_PER_LONG == 64)
45 aa
->addrlo
= baddr
& 0xffffffff;
46 aa
->addrhi
= baddr
>> 32;
48 /* Don't bother setting zero every time */
55 static inline void *get_aceaddr(aceaddr
*aa
)
59 #if (BITS_PER_LONG == 64)
60 addr
= (u64
)aa
->addrhi
<< 32 | aa
->addrlo
;
64 return bus_to_virt(addr
);
68 static inline void *get_aceaddr_bus(aceaddr
*aa
)
72 #if (BITS_PER_LONG == 64)
73 addr
= (u64
)aa
->addrhi
<< 32 | aa
->addrlo
;
82 u32 pad0
[16]; /* PCI control registers */
84 u32 HostCtrl
; /* 0x40 */
89 u32 MiscCfg
; /* 0x50 */
95 u32 pad3
[2]; /* 0x60 */
100 u32 pad4
[12]; /* 0x70 */
102 u32 DmaWriteState
; /* 0xa0 */
104 u32 DmaReadState
; /* 0xb0 */
110 u32 pad7
[8]; /* 0x120 */
112 u32 CpuCtrl
; /* 0x140 */
117 u32 SramAddr
; /* 0x154 */
122 u32 MacRxState
; /* 0x220 */
126 u32 CpuBCtrl
; /* 0x240 */
131 u32 SramBAddr
; /* 0x254 */
136 u32 pad13
[32]; /* 0x400 */
139 u32 Mb0Hi
; /* 0x500 */
146 u32 RxStdPrd
; /* RxStdPrd */
148 u32 RxJumboPrd
; /* RxJumboPrd */
174 u32 MacAddrHi
; /* 0x600 */
178 u32 MultiCastHi
; /* 0x610 */
182 u32 DmaWriteCfg
; /* 0x620 */
186 u32 TuneRxCoalTicks
;/* 0x630 */
190 u32 TuneMaxRxDesc
; /* 0x640 */
194 u32 TracePtr
; /* 0x650 */
198 u32 IfMtu
; /* 0x660 */
202 u32 pad16
[4]; /* 0x670 */
203 u32 RxRetCsm
; /* 0x680 */
207 u32 CmdRng
[64]; /* 0x700 */
211 #define ACE_WINDOW_SIZE 0x800
213 #define ACE_JUMBO_MTU 9000
214 #define ACE_STD_MTU 1500
216 #define ACE_TRACE_SIZE 0x8000
219 * Host control register bits.
224 #define BYTE_SWAP 0x10
225 #define WORD_SWAP 0x20
226 #define MASK_INTS 0x40
229 * Local control register bits.
232 #define EEPROM_DATA_IN 0x800000
233 #define EEPROM_DATA_OUT 0x400000
234 #define EEPROM_WRITE_ENABLE 0x200000
235 #define EEPROM_CLK_OUT 0x100000
237 #define EEPROM_BASE 0xa0000000
239 #define EEPROM_WRITE_SELECT 0xa0
240 #define EEPROM_READ_SELECT 0xa1
242 #define SRAM_BANK_512K 0x200
249 #define SYNC_SRAM_TIMING 0x100000
256 #define CPU_RESET 0x01
257 #define CPU_TRACE 0x02
258 #define CPU_PROM_FAILED 0x10
259 #define CPU_HALT 0x00010000
260 #define CPU_HALTED 0xffff0000
267 #define DMA_READ_MAX_4 0x04
268 #define DMA_READ_MAX_16 0x08
269 #define DMA_READ_MAX_32 0x0c
270 #define DMA_READ_MAX_64 0x10
271 #define DMA_READ_MAX_128 0x14
272 #define DMA_READ_MAX_256 0x18
273 #define DMA_READ_MAX_1K 0x1c
274 #define DMA_WRITE_MAX_4 0x20
275 #define DMA_WRITE_MAX_16 0x40
276 #define DMA_WRITE_MAX_32 0x60
277 #define DMA_WRITE_MAX_64 0x80
278 #define DMA_WRITE_MAX_128 0xa0
279 #define DMA_WRITE_MAX_256 0xc0
280 #define DMA_WRITE_MAX_1K 0xe0
281 #define MEM_READ_MULTIPLE 0x00020000
282 #define PCI_66MHZ 0x00080000
283 #define DMA_WRITE_ALL_ALIGN 0x00800000
284 #define READ_CMD_MEM 0x06000000
285 #define WRITE_CMD_MEM 0x70000000
292 #define ACE_BYTE_SWAP_DATA 0x10
293 #define ACE_WARN 0x08
294 #define ACE_WORD_SWAP 0x04
295 #define ACE_NO_JUMBO_FRAG 0x200
296 #define ACE_FATAL 0x40000000
303 #define DMA_THRESH_8W 0x80
310 #define TICKS_PER_SEC 1000000
317 #define LNK_PREF 0x00008000
318 #define LNK_10MB 0x00010000
319 #define LNK_100MB 0x00020000
320 #define LNK_1000MB 0x00040000
321 #define LNK_FULL_DUPLEX 0x00080000
322 #define LNK_HALF_DUPLEX 0x00100000
323 #define LNK_TX_FLOW_CTL_Y 0x00200000
324 #define LNK_NEG_ADVANCED 0x00400000
325 #define LNK_RX_FLOW_CTL_Y 0x00800000
326 #define LNK_NIC 0x01000000
327 #define LNK_JAM 0x02000000
328 #define LNK_JUMBO 0x04000000
329 #define LNK_ALTEON 0x08000000
330 #define LNK_NEG_FCTL 0x10000000
331 #define LNK_NEGOTIATE 0x20000000
332 #define LNK_ENABLE 0x40000000
333 #define LNK_UP 0x80000000
340 #define EVT_RING_ENTRIES 256
341 #define EVT_RING_SIZE (EVT_RING_ENTRIES * sizeof(struct event))
344 #ifdef __LITTLE_ENDIAN
361 #define E_FW_RUNNING 0x01
362 #define E_STATS_UPDATED 0x04
364 #define E_STATS_UPDATE 0x04
366 #define E_LNK_STATE 0x06
367 #define E_C_LINK_UP 0x01
368 #define E_C_LINK_DOWN 0x02
369 #define E_C_LINK_UP_FAST 0x03
372 #define E_C_ERR_INVAL_CMD 0x01
373 #define E_C_ERR_UNIMP_CMD 0x02
374 #define E_C_ERR_BAD_CFG 0x03
376 #define E_MCAST_LIST 0x08
377 #define E_C_MCAST_ADDR_ADD 0x01
378 #define E_C_MCAST_ADDR_DEL 0x02
380 #define E_RESET_JUMBO_RNG 0x09
387 #define CMD_RING_ENTRIES 64
390 #ifdef __LITTLE_ENDIAN
402 #define C_HOST_STATE 0x01
403 #define C_C_STACK_UP 0x01
404 #define C_C_STACK_DOWN 0x02
406 #define C_FDR_FILTERING 0x02
407 #define C_C_FDR_FILT_ENABLE 0x01
408 #define C_C_FDR_FILT_DISABLE 0x02
410 #define C_SET_RX_PRD_IDX 0x03
411 #define C_UPDATE_STATS 0x04
412 #define C_RESET_JUMBO_RNG 0x05
413 #define C_ADD_MULTICAST_ADDR 0x08
414 #define C_DEL_MULTICAST_ADDR 0x09
416 #define C_SET_PROMISC_MODE 0x0a
417 #define C_C_PROMISC_ENABLE 0x01
418 #define C_C_PROMISC_DISABLE 0x02
420 #define C_LNK_NEGOTIATION 0x0b
421 #define C_C_NEGOTIATE_BOTH 0x00
422 #define C_C_NEGOTIATE_GIG 0x01
423 #define C_C_NEGOTIATE_10_100 0x02
425 #define C_SET_MAC_ADDR 0x0c
426 #define C_CLEAR_PROFILE 0x0d
428 #define C_SET_MULTICAST_MODE 0x0e
429 #define C_C_MCAST_ENABLE 0x01
430 #define C_C_MCAST_DISABLE 0x02
432 #define C_CLEAR_STATS 0x0f
433 #define C_SET_RX_JUMBO_PRD_IDX 0x10
434 #define C_REFRESH_STATS 0x11
440 #define BD_FLG_TCP_UDP_SUM 0x01
441 #define BD_FLG_IP_SUM 0x02
442 #define BD_FLG_END 0x04
443 #define BD_FLG_JUMBO 0x10
444 #define BD_FLG_MINI 0x1000
448 * Ring Control block flags
450 #define RCB_FLG_TCP_UDP_SUM 0x01
451 #define RCB_FLG_IP_SUM 0x02
452 #define RCB_FLG_VLAN_ASSIST 0x10
453 #define RCB_FLG_COAL_INT_ONLY 0x20
454 #define RCB_FLG_IEEE_SNAP_SUM 0x80
455 #define RCB_FLG_EXT_RX_BD 0x100
456 #define RCB_FLG_RNG_DISABLE 0x200
462 #define TX_RING_ENTRIES 128
463 #define TX_RING_SIZE (TX_RING_ENTRIES * sizeof(struct tx_desc))
464 #define TX_RING_BASE 0x3800
471 * This is in PCI shared mem and must be accessed with readl/writel
490 #define RX_STD_RING_ENTRIES 512
491 #define RX_STD_RING_SIZE (RX_STD_RING_ENTRIES * sizeof(struct rx_desc))
493 #define RX_JUMBO_RING_ENTRIES 256
494 #define RX_JUMBO_RING_SIZE (RX_JUMBO_RING_ENTRIES *sizeof(struct rx_desc))
496 #define RX_MINI_RING_ENTRIES 1024
497 #define RX_MINI_RING_SIZE (RX_MINI_RING_ENTRIES *sizeof(struct rx_desc))
499 #define RX_RETURN_RING_ENTRIES 2048
500 #define RX_RETURN_RING_SIZE (RX_MAX_RETURN_RING_ENTRIES * \
501 sizeof(struct rx_desc))
505 #ifdef __LITTLE_ENDIAN
512 #ifdef __LITTLE_ENDIAN
519 #ifdef __LITTLE_ENDIAN
526 #ifdef __LITTLE_ENDIAN
539 * This struct is shared with the NIC firmware.
543 #ifdef __LITTLE_ENDIAN
554 struct ace_mac_stats
{
592 struct ring_ctrl evt_ctrl
;
593 struct ring_ctrl cmd_ctrl
;
594 struct ring_ctrl tx_ctrl
;
595 struct ring_ctrl rx_std_ctrl
;
596 struct ring_ctrl rx_jumbo_ctrl
;
597 struct ring_ctrl rx_mini_ctrl
;
598 struct ring_ctrl rx_return_ctrl
;
600 aceaddr rx_ret_prd_ptr
;
607 * struct ace_skb holding the rings of skb's. This is an awful lot of
608 * pointers, but I don't see any other smart mode to do this in an
609 * efficient manner ;-(
613 struct sk_buff
*tx_skbuff
[TX_RING_ENTRIES
];
614 struct sk_buff
*rx_std_skbuff
[RX_STD_RING_ENTRIES
];
615 struct sk_buff
*rx_mini_skbuff
[RX_MINI_RING_ENTRIES
];
616 struct sk_buff
*rx_jumbo_skbuff
[RX_JUMBO_RING_ENTRIES
];
621 * Struct private for the AceNIC.
623 * Elements are grouped so variables used by the tx handling goes
624 * together, and will go into the same cache lines etc. in order to
625 * avoid cache line contention between the rx and tx handling on SMP.
627 * Frequently accessed variables are put at the beginning of the
628 * struct to help the compiler generate better/shorter code.
633 struct ace_regs
*regs
; /* register base */
634 int version
, fw_running
, fw_up
, link
;
635 int promisc
, mcast_all
;
637 * The send ring is located in the shared memory window
639 struct ace_info
*info
;
640 struct tx_desc
*tx_ring
;
641 u32 tx_prd
, tx_full
, tx_ret_csm
;
642 struct timer_list timer
;
644 unsigned long std_refill_busy
645 __attribute__ ((aligned (L1_CACHE_BYTES
)));
646 unsigned long mini_refill_busy
, jumbo_refill_busy
;
647 atomic_t cur_rx_bufs
,
650 u32 rx_std_skbprd
, rx_mini_skbprd
, rx_jumbo_skbprd
;
652 struct tq_struct immediate
;
653 int bh_pending
, jumbo
;
654 struct rx_desc rx_std_ring
[RX_STD_RING_ENTRIES
]
655 __attribute__ ((aligned (L1_CACHE_BYTES
)));
656 struct rx_desc rx_jumbo_ring
[RX_JUMBO_RING_ENTRIES
];
657 struct rx_desc rx_mini_ring
[RX_MINI_RING_ENTRIES
];
658 struct rx_desc rx_return_ring
[RX_RETURN_RING_ENTRIES
];
659 struct event evt_ring
[EVT_RING_ENTRIES
];
661 __attribute__ ((aligned (L1_CACHE_BYTES
)));
662 volatile u32 rx_ret_prd
663 __attribute__ ((aligned (L1_CACHE_BYTES
)));
665 __attribute__ ((aligned (L1_CACHE_BYTES
)));
666 unsigned char *trace_buf
;
667 struct pci_dev
*pdev
;
668 struct net_device
*next
;
672 struct net_device_stats stats
;
678 static int ace_init(struct net_device
*dev
, int board_idx
);
679 static void ace_load_std_rx_ring(struct ace_private
*ap
, int nr_bufs
);
680 static void ace_load_mini_rx_ring(struct ace_private
*ap
, int nr_bufs
);
681 static void ace_load_jumbo_rx_ring(struct ace_private
*ap
, int nr_bufs
);
682 static int ace_flush_jumbo_rx_ring(struct net_device
*dev
);
683 static void ace_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
684 static int ace_load_firmware(struct net_device
*dev
);
685 static int ace_open(struct net_device
*dev
);
686 static int ace_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
687 static int ace_close(struct net_device
*dev
);
688 static void ace_timer(unsigned long data
);
689 static void ace_bh(struct net_device
*dev
);
690 static void ace_dump_trace(struct ace_private
*ap
);
691 static void ace_set_multicast_list(struct net_device
*dev
);
692 static int ace_change_mtu(struct net_device
*dev
, int new_mtu
);
694 extern int ace_recycle(struct sk_buff
*skb
);
696 static int ace_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
);
697 static int ace_set_mac_addr(struct net_device
*dev
, void *p
);
698 static struct net_device_stats
*ace_get_stats(struct net_device
*dev
);
699 static u8
read_eeprom_byte(struct ace_regs
*regs
, unsigned long offset
);
701 #endif /* _ACENIC_H_ */