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