4 #include <linux/interrupt.h>
6 #if ((BITS_PER_LONG != 32) && (BITS_PER_LONG != 64))
7 #error "BITS_PER_LONG not defined or not valid"
20 /* Timer increments every 0.97 micro-seconds (unsigned int) */
51 u32 DmaWriteIPchecksum
;
55 u32 DmaReadIPchecksum
;
117 /* The ULA is in two registers the high order two bytes of the first
118 * word contain the RunCode features.
119 * ula0 res res byte0 byte1
120 * ula1 byte2 byte3 byte4 byte5
168 * Host control register bits.
172 #define RR_CLEAR_INT 0x02
173 #define NO_SWAP 0x04000004
174 #define NO_SWAP1 0x00000004
175 #define PCI_RESET_NIC 0x08
176 #define HALT_NIC 0x10
177 #define SSTEP_NIC 0x20
178 #define MEM_READ_MULTI 0x40
179 #define NIC_HALTED 0x100
180 #define HALT_INST 0x200
181 #define PARITY_ERR 0x400
182 #define INVALID_INST_B 0x800
183 #define RR_REV_2 0x20000000
184 #define RR_REV_MASK 0xf0000000
187 * Local control register bits.
190 #define INTA_STATE 0x01
191 #define CLEAR_INTA 0x02
192 #define FAST_EEPROM_ACCESS 0x08
193 #define ENABLE_EXTRA_SRAM 0x100
194 #define ENABLE_EXTRA_DESC 0x200
195 #define ENABLE_PARITY 0x400
196 #define FORCE_DMA_PARITY_ERROR 0x800
197 #define ENABLE_EEPROM_WRITE 0x1000
198 #define ENABLE_DATA_CACHE 0x2000
199 #define SRAM_LO_PARITY_ERR 0x4000
200 #define SRAM_HI_PARITY_ERR 0x8000
206 #define FORCE_PCI_RESET 0x01
207 #define PROVIDE_LENGTH 0x02
208 #define MASK_DMA_READ_MAX 0x1C
209 #define RBURST_DISABLE 0x00
210 #define RBURST_4 0x04
211 #define RBURST_16 0x08
212 #define RBURST_32 0x0C
213 #define RBURST_64 0x10
214 #define RBURST_128 0x14
215 #define RBURST_256 0x18
216 #define RBURST_1024 0x1C
217 #define MASK_DMA_WRITE_MAX 0xE0
218 #define WBURST_DISABLE 0x00
219 #define WBURST_4 0x20
220 #define WBURST_16 0x40
221 #define WBURST_32 0x60
222 #define WBURST_64 0x80
223 #define WBURST_128 0xa0
224 #define WBURST_256 0xc0
225 #define WBURST_1024 0xe0
226 #define MASK_MIN_DMA 0xFF00
227 #define FIFO_RETRY_ENABLE 0x10000
233 #define DMA_WRITE_DONE 0x10000
234 #define DMA_READ_DONE 0x20000
235 #define DMA_WRITE_ERR 0x40000
236 #define DMA_READ_ERR 0x80000
241 * RoadRunner HIPPI Receive State Register controls and monitors the
242 * HIPPI receive interface in the NIC. Look at err bits when a HIPPI
243 * receive Error Event occurs.
246 #define ENABLE_NEW_CON 0x01
247 #define RESET_RECV 0x02
248 #define RECV_ALL 0x00
253 #define RECV_16K 0xa0
254 #define RECV_32K 0xc0
255 #define RECV_64K 0xe0
261 #define ENA_XMIT 0x01
262 #define PERM_CON 0x02
268 #define RESET_DMA 0x01
269 #define NO_SWAP_DMA 0x02
270 #define DMA_ACTIVE 0x04
271 #define THRESH_MASK 0x1F
272 #define DMA_ERROR_MASK 0xff000000
275 * Gooddies stored in the ULA registers.
278 #define TRACE_ON_WHAT_BIT 0x00020000 /* Traces on */
279 #define ONEM_BUF_WHAT_BIT 0x00040000 /* 1Meg vs 256K */
280 #define CHAR_API_WHAT_BIT 0x00080000 /* Char API vs network only */
281 #define CMD_EVT_WHAT_BIT 0x00200000 /* Command event */
282 #define LONG_TX_WHAT_BIT 0x00400000
283 #define LONG_RX_WHAT_BIT 0x00800000
284 #define WHAT_BIT_MASK 0xFFFD0000 /* Feature bit mask */
290 #define EVENT_OVFL 0x80000000
291 #define FATAL_ERR 0x40000000
292 #define LOOP_BACK 0x01
295 #define PTR64BIT 0x04
296 #define PTR32BIT 0x00
297 #define PTR_WD_SWAP 0x08
298 #define PTR_WD_NOSWAP 0x00
299 #define POST_WARN_EVENT 0x10
300 #define ERR_TERM 0x20
301 #define DIRECT_CONN 0x40
302 #define NO_NIC_WATCHDOG 0x80
303 #define SWAP_DATA 0x100
304 #define SWAP_CONTROL 0x200
305 #define NIC_HALT_ON_ERR 0x400
306 #define NIC_NO_RESTART 0x800
307 #define HALF_DUP_TX 0x1000
308 #define HALF_DUP_RX 0x2000
315 /* Host Error Codes - values of fail1 */
316 #define ERR_UNKNOWN_MBOX 0x1001
317 #define ERR_UNKNOWN_CMD 0x1002
318 #define ERR_MAX_RING 0x1003
319 #define ERR_RING_CLOSED 0x1004
320 #define ERR_RING_OPEN 0x1005
321 /* Firmware internal errors */
322 #define ERR_EVENT_RING_FULL 0x01
323 #define ERR_DW_PEND_CMND_FULL 0x02
324 #define ERR_DR_PEND_CMND_FULL 0x03
325 #define ERR_DW_PEND_DATA_FULL 0x04
326 #define ERR_DR_PEND_DATA_FULL 0x05
327 #define ERR_ILLEGAL_JUMP 0x06
328 #define ERR_UNIMPLEMENTED 0x07
329 #define ERR_TX_INFO_FULL 0x08
330 #define ERR_RX_INFO_FULL 0x09
331 #define ERR_ILLEGAL_MODE 0x0A
332 #define ERR_MAIN_TIMEOUT 0x0B
333 #define ERR_EVENT_BITS 0x0C
334 #define ERR_UNPEND_FULL 0x0D
335 #define ERR_TIMER_QUEUE_FULL 0x0E
336 #define ERR_TIMER_QUEUE_EMPTY 0x0F
337 #define ERR_TIMER_NO_FREE 0x10
338 #define ERR_INTR_START 0x11
339 #define ERR_BAD_STARTUP 0x12
340 #define ERR_NO_PKT_END 0x13
341 #define ERR_HALTED_ON_ERR 0x14
342 /* Hardware NIC Errors */
343 #define ERR_WRITE_DMA 0x0101
344 #define ERR_READ_DMA 0x0102
345 #define ERR_EXT_SERIAL 0x0103
346 #define ERR_TX_INT_PARITY 0x0104
353 #define EVT_RING_ENTRIES 64
354 #define EVT_RING_SIZE (EVT_RING_ENTRIES * sizeof(struct event))
357 #ifdef __LITTLE_ENDIAN
373 #define E_NIC_UP 0x01
374 #define E_WATCHDOG 0x02
376 #define E_STAT_UPD 0x04
377 #define E_INVAL_CMD 0x05
378 #define E_SET_CMD_CONS 0x06
379 #define E_LINK_ON 0x07
380 #define E_LINK_OFF 0x08
381 #define E_INTERN_ERR 0x09
382 #define E_HOST_ERR 0x0A
383 #define E_STATS_UPDATE 0x0B
384 #define E_REJECTING 0x0C
389 #define E_CON_REJ 0x13
390 #define E_CON_TMOUT 0x14
391 #define E_CON_NC_TMOUT 0x15 /* I , Connection No Campon Timeout */
392 #define E_DISC_ERR 0x16
393 #define E_INT_PRTY 0x17
394 #define E_TX_IDLE 0x18
395 #define E_TX_LINK_DROP 0x19
396 #define E_TX_INV_RNG 0x1A
397 #define E_TX_INV_BUF 0x1B
398 #define E_TX_INV_DSC 0x1C
404 * General Receive events
406 #define E_VAL_RNG 0x20
407 #define E_RX_RNG_ENER 0x21
408 #define E_INV_RNG 0x22
409 #define E_RX_RNG_SPC 0x23
410 #define E_RX_RNG_OUT 0x24
411 #define E_PKT_DISCARD 0x25
412 #define E_INFO_EVT 0x27
415 * Data corrupted events
417 #define E_RX_PAR_ERR 0x2B
418 #define E_RX_LLRC_ERR 0x2C
419 #define E_IP_CKSM_ERR 0x2D
420 #define E_DTA_CKSM_ERR 0x2E
421 #define E_SHT_BST 0x2F
426 #define E_LST_LNK_ERR 0x30
427 #define E_FLG_SYN_ERR 0x31
428 #define E_FRM_ERR 0x32
429 #define E_RX_IDLE 0x33
430 #define E_PKT_LN_ERR 0x34
431 #define E_STATE_ERR 0x35
432 #define E_UNEXP_DATA 0x3C
437 #define E_RX_INV_BUF 0x36
438 #define E_RX_INV_DSC 0x37
439 #define E_RNG_BLK 0x38
445 #define E_BFR_SPC 0x3A
446 #define E_INV_ULP 0x3B
448 #define E_NOT_IMPLEMENTED 0x40
455 #define CMD_RING_ENTRIES 16
458 #ifdef __LITTLE_ENDIAN
469 #define C_START_FW 0x01
470 #define C_UPD_STAT 0x02
471 #define C_WATCHDOG 0x05
472 #define C_DEL_RNG 0x09
473 #define C_NEW_RNG 0x0A
481 #define PACKET_BAD 0x01 /* Packet had link-layer error */
482 #define INTERRUPT 0x02
483 #define TX_IP_CKSUM 0x04
484 #define PACKET_END 0x08
485 #define PACKET_START 0x10
486 #define SAME_IFIELD 0x80
490 #if (BITS_PER_LONG == 64)
499 static inline void set_rraddr(rraddr
*ra
, dma_addr_t addr
)
501 unsigned long baddr
= addr
;
502 #if (BITS_PER_LONG == 64)
505 /* Don't bother setting zero every time */
512 static inline void set_rxaddr(struct rr_regs __iomem
*regs
, volatile dma_addr_t addr
)
514 unsigned long baddr
= addr
;
515 #if (BITS_PER_LONG == 64) && defined(__LITTLE_ENDIAN)
516 writel(baddr
& 0xffffffff, ®s
->RxRingHi
);
517 writel(baddr
>> 32, ®s
->RxRingLo
);
518 #elif (BITS_PER_LONG == 64)
519 writel(baddr
>> 32, ®s
->RxRingHi
);
520 writel(baddr
& 0xffffffff, ®s
->RxRingLo
);
522 writel(0, ®s
->RxRingHi
);
523 writel(baddr
, ®s
->RxRingLo
);
529 static inline void set_infoaddr(struct rr_regs __iomem
*regs
, volatile dma_addr_t addr
)
531 unsigned long baddr
= addr
;
532 #if (BITS_PER_LONG == 64) && defined(__LITTLE_ENDIAN)
533 writel(baddr
& 0xffffffff, ®s
->InfoPtrHi
);
534 writel(baddr
>> 32, ®s
->InfoPtrLo
);
535 #elif (BITS_PER_LONG == 64)
536 writel(baddr
>> 32, ®s
->InfoPtrHi
);
537 writel(baddr
& 0xffffffff, ®s
->InfoPtrLo
);
539 writel(0, ®s
->InfoPtrHi
);
540 writel(baddr
, ®s
->InfoPtrLo
);
550 #ifdef CONFIG_ROADRUNNER_LARGE_RINGS
551 #define TX_RING_ENTRIES 32
553 #define TX_RING_ENTRIES 16
555 #define TX_TOTAL_SIZE (TX_RING_ENTRIES * sizeof(struct tx_desc))
560 #ifdef __LITTLE_ENDIAN
572 #ifdef CONFIG_ROADRUNNER_LARGE_RINGS
573 #define RX_RING_ENTRIES 32
575 #define RX_RING_ENTRIES 16
577 #define RX_TOTAL_SIZE (RX_RING_ENTRIES * sizeof(struct rx_desc))
582 #ifdef __LITTLE_ENDIAN
598 #define SIOCRRPFW SIOCDEVPRIVATE /* put firmware */
599 #define SIOCRRGFW SIOCDEVPRIVATE+1 /* get firmware */
600 #define SIOCRRID SIOCDEVPRIVATE+2 /* identify */
610 #define EEPROM_BASE 0x80000000
611 #define EEPROM_WORDS 8192
612 #define EEPROM_BYTES (EEPROM_WORDS * sizeof(u32))
618 struct seg_hdr loader
;
640 char PalCodeFile
[12];
652 struct eeprom_phase_info
{
662 struct eeprom_rncd_info
{
672 /* Phase 1 region (starts are word offset 0x80) */
676 struct seg_hdr phase2Seg
;
680 struct eeprom_boot boot
;
682 struct eeprom_manf manf
;
683 struct eeprom_phase_info phase_info
;
684 struct eeprom_rncd_info rncd_info
;
687 struct phase1_hdr phase1
;
761 * This struct is shared with the NIC firmware.
765 #ifdef __LITTLE_ENDIAN
782 struct rr_stats stats
;
785 struct ring_ctrl evt_ctrl
;
786 struct ring_ctrl cmd_ctrl
;
787 struct ring_ctrl tx_ctrl
;
793 * The linux structure for the RoadRunner.
795 * RX/TX descriptors are put first to make sure they are properly
796 * aligned and do not cross cache-line boundaries.
801 struct rx_desc
*rx_ring
;
802 struct tx_desc
*tx_ring
;
803 struct event
*evt_ring
;
804 dma_addr_t tx_ring_dma
;
805 dma_addr_t rx_ring_dma
;
806 dma_addr_t evt_ring_dma
;
808 struct sk_buff
*rx_skbuff
[RX_RING_ENTRIES
];
809 struct sk_buff
*tx_skbuff
[TX_RING_ENTRIES
];
810 struct rr_regs __iomem
*regs
; /* Register base */
811 struct ring_ctrl
*rx_ctrl
; /* Receive ring control */
812 struct rr_info
*info
; /* Shared info page */
813 dma_addr_t rx_ctrl_dma
;
816 struct timer_list timer
;
817 u32 cur_rx
, cur_cmd
, cur_evt
;
818 u32 dirty_rx
, dirty_tx
;
821 volatile short fw_running
;
822 struct net_device_stats stats
;
823 struct pci_dev
*pci_dev
;
830 static int rr_init(struct net_device
*dev
);
831 static int rr_init1(struct net_device
*dev
);
832 static irqreturn_t
rr_interrupt(int irq
, void *dev_id
);
834 static int rr_open(struct net_device
*dev
);
835 static int rr_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
836 static int rr_close(struct net_device
*dev
);
837 static struct net_device_stats
*rr_get_stats(struct net_device
*dev
);
838 static int rr_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
);
839 static unsigned int rr_read_eeprom(struct rr_private
*rrpriv
,
840 unsigned long offset
,
842 unsigned long length
);
843 static u32
rr_read_eeprom_word(struct rr_private
*rrpriv
, void * offset
);
844 static int rr_load_firmware(struct net_device
*dev
);
845 static inline void rr_raz_tx(struct rr_private
*, struct net_device
*);
846 static inline void rr_raz_rx(struct rr_private
*, struct net_device
*);
847 #endif /* _RRUNNER_H_ */