8 #define SMALL_BUFFER_SIZE 384
9 #define LARGE_BUFFER_SIZE 4032
12 #define RBD_BLK_SIZE 32
15 #define MAX_PDU_SIZE 65535
18 #define BUFFER_S1_SIZE SMALL_BUFFER_SIZE
19 #define BUFFER_L1_SIZE LARGE_BUFFER_SIZE
21 #define BUFFER_S2_SIZE SMALL_BUFFER_SIZE
22 #define BUFFER_L2_SIZE LARGE_BUFFER_SIZE
24 #define BUFFER_S1_NBR (RBD_BLK_SIZE * 6)
25 #define BUFFER_L1_NBR (RBD_BLK_SIZE * 4)
27 #define BUFFER_S2_NBR (RBD_BLK_SIZE * 6)
28 #define BUFFER_L2_NBR (RBD_BLK_SIZE * 4)
31 #define QUEUE_SIZE_CMD 16
32 #define QUEUE_SIZE_RX 64
33 #define QUEUE_SIZE_TX 256
34 #define QUEUE_SIZE_BS 32
36 #define FORE200E_VPI_BITS 0
37 #define FORE200E_VCI_BITS 10
38 #define NBR_CONNECT (1 << (FORE200E_VPI_BITS + FORE200E_VCI_BITS))
42 #define TSD_EXTENSION 0
43 #define TSD_NBR (TSD_FIXED + TSD_EXTENSION)
51 #define RSD_REQUIRED (((MAX_PDU_SIZE - SMALL_BUFFER_SIZE + LARGE_BUFFER_SIZE) / LARGE_BUFFER_SIZE) + 1)
60 #define RSD_EXTENSION ((RSD_REQUIRED - RSD_FIXED) + 1)
61 #define RSD_NBR (RSD_FIXED + RSD_EXTENSION)
64 #define FORE200E_DEV(d) ((struct fore200e*)((d)->dev_data))
65 #define FORE200E_VCC(d) ((struct fore200e_vcc*)((d)->dev_data))
69 #if defined(__LITTLE_ENDIAN_BITFIELD)
70 #define BITFIELD2(b1, b2) b1; b2;
71 #define BITFIELD3(b1, b2, b3) b1; b2; b3;
72 #define BITFIELD4(b1, b2, b3, b4) b1; b2; b3; b4;
73 #define BITFIELD5(b1, b2, b3, b4, b5) b1; b2; b3; b4; b5;
74 #define BITFIELD6(b1, b2, b3, b4, b5, b6) b1; b2; b3; b4; b5; b6;
75 #elif defined(__BIG_ENDIAN_BITFIELD)
76 #define BITFIELD2(b1, b2) b2; b1;
77 #define BITFIELD3(b1, b2, b3) b3; b2; b1;
78 #define BITFIELD4(b1, b2, b3, b4) b4; b3; b2; b1;
79 #define BITFIELD5(b1, b2, b3, b4, b5) b5; b4; b3; b2; b1;
80 #define BITFIELD6(b1, b2, b3, b4, b5, b6) b6; b5; b4; b3; b2; b1;
82 #error unknown bitfield endianess
88 typedef struct atm_header {
101 typedef enum fore200e_aal {
110 typedef struct tpd_spec {
114 enum fore200e_aal aal : 4,
122 typedef struct tpd_rate
142 struct atm_header atm_header;
143 struct tpd_spec spec;
144 struct tpd_rate
rate;
146 struct tsd tsd[ TSD_NBR ];
161 struct atm_header atm_header;
163 struct rsd rsd[ RSD_NBR ];
169 typedef enum buffer_scheme {
178 typedef enum buffer_magn {
195 typedef struct rbd_block {
196 struct rbd rbd[ RBD_BLK_SIZE ];
202 typedef struct tpd_haddr {
210 #define TPD_HADDR_SHIFT 5
214 typedef struct cp_txq_entry {
215 struct tpd_haddr tpd_haddr;
222 typedef struct cp_rxq_entry {
230 typedef struct cp_bsq_entry {
238 typedef volatile enum status {
240 STATUS_COMPLETE = (1<<1),
249 OPCODE_INITIALIZE = 1,
250 OPCODE_ACTIVATE_VCIN,
251 OPCODE_ACTIVATE_VCOUT,
252 OPCODE_DEACTIVATE_VCIN,
253 OPCODE_DEACTIVATE_VCOUT,
262 OPCODE_REQUEST_INTR = (1<<7)
268 typedef struct vpvc {
279 typedef struct activate_opcode {
282 enum fore200e_aal aal : 8,
283 enum buffer_scheme scheme : 8,
291 typedef struct activate_block {
292 struct activate_opcode
opcode;
301 typedef struct deactivate_opcode {
306 } deactivate_opcode_t;
311 typedef struct deactivate_block {
312 struct deactivate_opcode
opcode;
314 } deactivate_block_t;
319 typedef struct oc3_regs {
328 typedef struct oc3_opcode {
342 typedef struct oc3_block {
350 typedef struct stats_phy {
359 typedef struct stats_oc3 {
360 __be32 section_bip8_errors;
373 typedef struct stats_atm {
385 typedef struct stats_aal0 {
395 typedef struct stats_aal34 {
399 __be32 cells_protocol_errors;
401 __be32 cspdus_transmitted;
403 __be32 cspdus_protocol_errors;
411 typedef struct stats_aal5 {
415 __be32 congestion_experienced;
416 __be32 cspdus_transmitted;
419 __be32 cspdus_protocol_errors;
427 typedef struct stats_aux {
440 typedef struct stats {
441 struct stats_phy
phy;
442 struct stats_oc3 oc3;
443 struct stats_atm atm;
444 struct stats_aal0
aal0;
445 struct stats_aal34
aal34;
446 struct stats_aal5
aal5;
447 struct stats_aux
aux;
453 typedef struct stats_opcode {
463 typedef struct stats_block {
464 struct stats_opcode
opcode;
471 typedef struct prom_data {
480 typedef struct prom_opcode {
490 typedef struct prom_block {
491 struct prom_opcode
opcode;
500 struct activate_block activate_block;
501 struct deactivate_block deactivate_block;
502 struct stats_block stats_block;
503 struct prom_block prom_block;
504 struct oc3_block oc3_block;
511 typedef struct cp_cmdq_entry {
520 typedef struct host_txq_entry {
521 struct cp_txq_entry
__iomem *cp_entry;
527 unsigned long incarn;
528 struct fore200e_vc_map*
vc_map;
535 typedef struct host_rxq_entry {
536 struct cp_rxq_entry
__iomem *cp_entry;
545 typedef struct host_bsq_entry {
546 struct cp_bsq_entry
__iomem *cp_entry;
548 struct rbd_block* rbd_block;
555 typedef struct host_cmdq_entry {
556 struct cp_cmdq_entry
__iomem *cp_entry;
563 typedef struct chunk {
572 #define dma_size align_size
579 enum buffer_scheme scheme;
580 enum buffer_magn magn;
582 #ifdef FORE200E_BSQ_DEBUG
589 #if (BITS_PER_LONG == 32)
590 #define FORE200E_BUF2HDL(buffer) ((u32)(buffer))
591 #define FORE200E_HDL2BUF(handle) ((struct buffer*)(handle))
593 #define FORE200E_BUF2HDL(buffer) ((u32)((u64)(buffer)))
594 #define FORE200E_HDL2BUF(handle) ((struct buffer*)(((u64)(handle)) | PAGE_OFFSET))
600 typedef struct host_cmdq {
601 struct host_cmdq_entry host_entry[ QUEUE_SIZE_CMD ];
609 typedef struct host_txq {
610 struct host_txq_entry host_entry[ QUEUE_SIZE_TX ];
621 typedef struct host_rxq {
622 struct host_rxq_entry host_entry[ QUEUE_SIZE_RX ];
631 typedef struct host_bsq {
632 struct host_bsq_entry host_entry[ QUEUE_SIZE_BS ];
634 struct chunk rbd_block;
638 volatile int freebuf_count;
651 #define FW_HEADER_MAGIC 0x65726f66
656 typedef struct bs_spec {
670 u32 receive_threshold;
679 struct bs_spec bs_spec[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ];
684 MEDIA_TYPE_CAT5_UTP = 0x06,
685 MEDIA_TYPE_MM_OC3_ST = 0x16,
686 MEDIA_TYPE_MM_OC3_SC = 0x26,
687 MEDIA_TYPE_SM_OC3_ST = 0x36,
688 MEDIA_TYPE_SM_OC3_SC = 0x46
691 #define FORE200E_MEDIA_INDEX(media_type) ((media_type)>>4)
696 typedef struct cp_queues {
700 u32 cp_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ];
720 BSTAT_COLD_START = (
u32) 0xc01dc01d,
721 BSTAT_SELFTEST_OK = (
u32) 0x02201958,
722 BSTAT_SELFTEST_FAIL = (
u32) 0xadbadbad,
723 BSTAT_CP_RUNNING = (
u32) 0xce11feed,
724 BSTAT_MON_TOO_BIG = (
u32) 0x10aded00
730 typedef struct soft_uart {
735 #define FORE200E_CP_MONITOR_UART_FREE 0x00000000
736 #define FORE200E_CP_MONITOR_UART_AVAIL 0x01000000
741 typedef struct cp_monitor {
742 struct soft_uart soft_uart;
751 typedef enum fore200e_state {
752 FORE200E_STATE_BLANK,
753 FORE200E_STATE_REGISTER,
754 FORE200E_STATE_CONFIGURE,
756 FORE200E_STATE_RESET,
757 FORE200E_STATE_START_FW,
758 FORE200E_STATE_INITIALIZE,
759 FORE200E_STATE_INIT_CMDQ,
760 FORE200E_STATE_INIT_TXQ,
761 FORE200E_STATE_INIT_RXQ,
762 FORE200E_STATE_INIT_BSQ,
763 FORE200E_STATE_ALLOC_BUF,
765 FORE200E_STATE_COMPLETE
771 typedef struct fore200e_pca_regs {
775 } fore200e_pca_regs_t;
780 typedef struct fore200e_sba_regs {
784 } fore200e_sba_regs_t;
789 typedef union fore200e_regs {
790 struct fore200e_pca_regs pca;
791 struct fore200e_sba_regs
sba;
799 typedef struct fore200e_bus {
803 int buffer_alignment;
804 int status_alignment;
807 u32 (*dma_map)(
struct fore200e*,
void*,
int,
int);
810 void (*dma_sync_for_device)(
struct fore200e*,
u32,
int,
int);
812 void (*dma_chunk_free)(
struct fore200e*,
struct chunk*);
813 int (*configure)(
struct fore200e*);
814 int (*
map)(
struct fore200e*);
815 void (*reset)(
struct fore200e*);
816 int (*prom_read)(
struct fore200e*,
struct prom_data*);
819 int (*irq_check)(
struct fore200e*);
821 int (*proc_read)(
struct fore200e*,
char*);
826 typedef struct fore200e_vc_map {
828 unsigned long incarn;
831 #define FORE200E_VC_MAP(fore200e, vpi, vci) \
832 (& (fore200e)->vc_map[ ((vpi) << FORE200E_VCI_BITS) | (vci) ])
837 typedef struct fore200e {
839 const struct fore200e_bus*
bus;
840 union fore200e_regs
regs;
843 enum fore200e_state
state;
853 struct cp_monitor
__iomem * cp_monitor;
854 struct cp_queues
__iomem * cp_queues;
855 struct host_cmdq host_cmdq;
856 struct host_txq host_txq;
857 struct host_rxq host_rxq;
859 struct host_bsq host_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ];
861 u32 available_cell_rate;
867 struct mutex rate_mtx;
869 #ifdef FORE200E_USE_TASKLET
873 unsigned long tx_sat;
875 unsigned long incarn_count;
876 struct fore200e_vc_map
vc_map[ NBR_CONNECT ];
882 typedef struct fore200e_vcc {
883 enum buffer_scheme scheme;
884 struct tpd_rate
rate;
889 unsigned long tx_pdu;
890 unsigned long rx_pdu;
897 #define FORE200E_CP_MONITOR_OFFSET 0x00000400
898 #define FORE200E_CP_QUEUES_OFFSET 0x00004d40
903 #define PCA200E_IOSPACE_LENGTH 0x00200000
905 #define PCA200E_HCR_OFFSET 0x00100000
906 #define PCA200E_IMR_OFFSET 0x00100004
907 #define PCA200E_PSR_OFFSET 0x00100008
912 #define PCA200E_HCR_RESET (1<<0)
913 #define PCA200E_HCR_HOLD_LOCK (1<<1)
914 #define PCA200E_HCR_I960FAIL (1<<2)
915 #define PCA200E_HCR_INTRB (1<<2)
916 #define PCA200E_HCR_HOLD_ACK (1<<3)
917 #define PCA200E_HCR_INTRA (1<<3)
918 #define PCA200E_HCR_OUTFULL (1<<4)
919 #define PCA200E_HCR_CLRINTR (1<<4)
920 #define PCA200E_HCR_ESPHOLD (1<<5)
921 #define PCA200E_HCR_INFULL (1<<6)
922 #define PCA200E_HCR_TESTMODE (1<<7)
927 #define PCA200E_PCI_LATENCY 0x40
928 #define PCA200E_PCI_MASTER_CTRL 0x41
929 #define PCA200E_PCI_THRESHOLD 0x42
933 #define PCA200E_CTRL_DIS_CACHE_RD (1<<0)
934 #define PCA200E_CTRL_DIS_WRT_INVAL (1<<1)
935 #define PCA200E_CTRL_2_CACHE_WRT_INVAL (1<<2)
936 #define PCA200E_CTRL_IGN_LAT_TIMER (1<<3)
937 #define PCA200E_CTRL_ENA_CONT_REQ_MODE (1<<4)
938 #define PCA200E_CTRL_LARGE_PCI_BURSTS (1<<5)
939 #define PCA200E_CTRL_CONVERT_ENDIAN (1<<6)
943 #define SBA200E_PROM_NAME "FORE,sba-200e"
948 #define SBA200E_HCR_LENGTH 4
949 #define SBA200E_BSR_LENGTH 4
950 #define SBA200E_ISR_LENGTH 4
951 #define SBA200E_RAM_LENGTH 0x40000
956 #define SBA200E_BSR_BURST4 0x04
957 #define SBA200E_BSR_BURST8 0x08
958 #define SBA200E_BSR_BURST16 0x10
963 #define SBA200E_HCR_RESET (1<<0)
964 #define SBA200E_HCR_HOLD_LOCK (1<<1)
965 #define SBA200E_HCR_I960FAIL (1<<2)
966 #define SBA200E_HCR_I960SETINTR (1<<2)
967 #define SBA200E_HCR_OUTFULL (1<<3)
968 #define SBA200E_HCR_INTR_CLR (1<<3)
969 #define SBA200E_HCR_INTR_ENA (1<<4)
970 #define SBA200E_HCR_ESPHOLD (1<<5)
971 #define SBA200E_HCR_INFULL (1<<6)
972 #define SBA200E_HCR_TESTMODE (1<<7)
973 #define SBA200E_HCR_INTR_REQ (1<<8)
975 #define SBA200E_HCR_STICKY (SBA200E_HCR_RESET | SBA200E_HCR_HOLD_LOCK | SBA200E_HCR_INTR_ENA)