#ifndef _FORE200E_H1#define _FORE200E_H23#ifdef __KERNEL__45/* rx buffer sizes */67#define SMALL_BUFFER_SIZE 384 /* size of small buffers (multiple of 48 (PCA) and 64 (SBA) bytes) */8#define LARGE_BUFFER_SIZE 4032 /* size of large buffers (multiple of 48 (PCA) and 64 (SBA) bytes) */91011#define RBD_BLK_SIZE 32 /* nbr of supplied rx buffers per rbd */121314#define MAX_PDU_SIZE 65535 /* maximum PDU size supported by AALs */151617#define BUFFER_S1_SIZE SMALL_BUFFER_SIZE /* size of small buffers, scheme 1 */18#define BUFFER_L1_SIZE LARGE_BUFFER_SIZE /* size of large buffers, scheme 1 */1920#define BUFFER_S2_SIZE SMALL_BUFFER_SIZE /* size of small buffers, scheme 2 */21#define BUFFER_L2_SIZE LARGE_BUFFER_SIZE /* size of large buffers, scheme 2 */2223#define BUFFER_S1_NBR (RBD_BLK_SIZE * 6)24#define BUFFER_L1_NBR (RBD_BLK_SIZE * 4)2526#define BUFFER_S2_NBR (RBD_BLK_SIZE * 6)27#define BUFFER_L2_NBR (RBD_BLK_SIZE * 4)282930#define QUEUE_SIZE_CMD 16 /* command queue capacity */31#define QUEUE_SIZE_RX 64 /* receive queue capacity */32#define QUEUE_SIZE_TX 256 /* transmit queue capacity */33#define QUEUE_SIZE_BS 32 /* buffer supply queue capacity */3435#define FORE200E_VPI_BITS 036#define FORE200E_VCI_BITS 1037#define NBR_CONNECT (1 << (FORE200E_VPI_BITS + FORE200E_VCI_BITS)) /* number of connections */383940#define TSD_FIXED 241#define TSD_EXTENSION 042#define TSD_NBR (TSD_FIXED + TSD_EXTENSION)434445/* the cp starts putting a received PDU into one *small* buffer,46then it uses a number of *large* buffers for the trailing data.47we compute here the total number of receive segment descriptors48required to hold the largest possible PDU */4950#define RSD_REQUIRED (((MAX_PDU_SIZE - SMALL_BUFFER_SIZE + LARGE_BUFFER_SIZE) / LARGE_BUFFER_SIZE) + 1)5152#define RSD_FIXED 35354/* RSD_REQUIRED receive segment descriptors are enough to describe a max-sized PDU,55but we have to keep the size of the receive PDU descriptor multiple of 32 bytes,56so we add one extra RSD to RSD_EXTENSION57(WARNING: THIS MAY CHANGE IF BUFFER SIZES ARE MODIFIED) */5859#define RSD_EXTENSION ((RSD_REQUIRED - RSD_FIXED) + 1)60#define RSD_NBR (RSD_FIXED + RSD_EXTENSION)616263#define FORE200E_DEV(d) ((struct fore200e*)((d)->dev_data))64#define FORE200E_VCC(d) ((struct fore200e_vcc*)((d)->dev_data))6566/* bitfields endian games */6768#if defined(__LITTLE_ENDIAN_BITFIELD)69#define BITFIELD2(b1, b2) b1; b2;70#define BITFIELD3(b1, b2, b3) b1; b2; b3;71#define BITFIELD4(b1, b2, b3, b4) b1; b2; b3; b4;72#define BITFIELD5(b1, b2, b3, b4, b5) b1; b2; b3; b4; b5;73#define BITFIELD6(b1, b2, b3, b4, b5, b6) b1; b2; b3; b4; b5; b6;74#elif defined(__BIG_ENDIAN_BITFIELD)75#define BITFIELD2(b1, b2) b2; b1;76#define BITFIELD3(b1, b2, b3) b3; b2; b1;77#define BITFIELD4(b1, b2, b3, b4) b4; b3; b2; b1;78#define BITFIELD5(b1, b2, b3, b4, b5) b5; b4; b3; b2; b1;79#define BITFIELD6(b1, b2, b3, b4, b5, b6) b6; b5; b4; b3; b2; b1;80#else81#error unknown bitfield endianess82#endif838485/* ATM cell header (minus HEC byte) */8687typedef struct atm_header {88BITFIELD5(89u32 clp : 1, /* cell loss priority */90u32 plt : 3, /* payload type */91u32 vci : 16, /* virtual channel identifier */92u32 vpi : 8, /* virtual path identifier */93u32 gfc : 4 /* generic flow control */94)95} atm_header_t;969798/* ATM adaptation layer id */99100typedef enum fore200e_aal {101FORE200E_AAL0 = 0,102FORE200E_AAL34 = 4,103FORE200E_AAL5 = 5,104} fore200e_aal_t;105106107/* transmit PDU descriptor specification */108109typedef struct tpd_spec {110BITFIELD4(111u32 length : 16, /* total PDU length */112u32 nseg : 8, /* number of transmit segments */113enum fore200e_aal aal : 4, /* adaptation layer */114u32 intr : 4 /* interrupt requested */115)116} tpd_spec_t;117118119/* transmit PDU rate control */120121typedef struct tpd_rate122{123BITFIELD2(124u32 idle_cells : 16, /* number of idle cells to insert */125u32 data_cells : 16 /* number of data cells to transmit */126)127} tpd_rate_t;128129130/* transmit segment descriptor */131132typedef struct tsd {133u32 buffer; /* transmit buffer DMA address */134u32 length; /* number of bytes in buffer */135} tsd_t;136137138/* transmit PDU descriptor */139140typedef struct tpd {141struct atm_header atm_header; /* ATM header minus HEC byte */142struct tpd_spec spec; /* tpd specification */143struct tpd_rate rate; /* tpd rate control */144u32 pad; /* reserved */145struct tsd tsd[ TSD_NBR ]; /* transmit segment descriptors */146} tpd_t;147148149/* receive segment descriptor */150151typedef struct rsd {152u32 handle; /* host supplied receive buffer handle */153u32 length; /* number of bytes in buffer */154} rsd_t;155156157/* receive PDU descriptor */158159typedef struct rpd {160struct atm_header atm_header; /* ATM header minus HEC byte */161u32 nseg; /* number of receive segments */162struct rsd rsd[ RSD_NBR ]; /* receive segment descriptors */163} rpd_t;164165166/* buffer scheme */167168typedef enum buffer_scheme {169BUFFER_SCHEME_ONE,170BUFFER_SCHEME_TWO,171BUFFER_SCHEME_NBR /* always last */172} buffer_scheme_t;173174175/* buffer magnitude */176177typedef enum buffer_magn {178BUFFER_MAGN_SMALL,179BUFFER_MAGN_LARGE,180BUFFER_MAGN_NBR /* always last */181} buffer_magn_t;182183184/* receive buffer descriptor */185186typedef struct rbd {187u32 handle; /* host supplied handle */188u32 buffer_haddr; /* host DMA address of host buffer */189} rbd_t;190191192/* receive buffer descriptor block */193194typedef struct rbd_block {195struct rbd rbd[ RBD_BLK_SIZE ]; /* receive buffer descriptor */196} rbd_block_t;197198199/* tpd DMA address */200201typedef struct tpd_haddr {202BITFIELD3(203u32 size : 4, /* tpd size expressed in 32 byte blocks */204u32 pad : 1, /* reserved */205u32 haddr : 27 /* tpd DMA addr aligned on 32 byte boundary */206)207} tpd_haddr_t;208209#define TPD_HADDR_SHIFT 5 /* addr aligned on 32 byte boundary */210211/* cp resident transmit queue entry */212213typedef struct cp_txq_entry {214struct tpd_haddr tpd_haddr; /* host DMA address of tpd */215u32 status_haddr; /* host DMA address of completion status */216} cp_txq_entry_t;217218219/* cp resident receive queue entry */220221typedef struct cp_rxq_entry {222u32 rpd_haddr; /* host DMA address of rpd */223u32 status_haddr; /* host DMA address of completion status */224} cp_rxq_entry_t;225226227/* cp resident buffer supply queue entry */228229typedef struct cp_bsq_entry {230u32 rbd_block_haddr; /* host DMA address of rbd block */231u32 status_haddr; /* host DMA address of completion status */232} cp_bsq_entry_t;233234235/* completion status */236237typedef volatile enum status {238STATUS_PENDING = (1<<0), /* initial status (written by host) */239STATUS_COMPLETE = (1<<1), /* completion status (written by cp) */240STATUS_FREE = (1<<2), /* initial status (written by host) */241STATUS_ERROR = (1<<3) /* completion status (written by cp) */242} status_t;243244245/* cp operation code */246247typedef enum opcode {248OPCODE_INITIALIZE = 1, /* initialize board */249OPCODE_ACTIVATE_VCIN, /* activate incoming VCI */250OPCODE_ACTIVATE_VCOUT, /* activate outgoing VCI */251OPCODE_DEACTIVATE_VCIN, /* deactivate incoming VCI */252OPCODE_DEACTIVATE_VCOUT, /* deactivate incoing VCI */253OPCODE_GET_STATS, /* get board statistics */254OPCODE_SET_OC3, /* set OC-3 registers */255OPCODE_GET_OC3, /* get OC-3 registers */256OPCODE_RESET_STATS, /* reset board statistics */257OPCODE_GET_PROM, /* get expansion PROM data (PCI specific) */258OPCODE_SET_VPI_BITS, /* set x bits of those decoded by the259firmware to be low order bits from260the VPI field of the ATM cell header */261OPCODE_REQUEST_INTR = (1<<7) /* request interrupt */262} opcode_t;263264265/* virtual path / virtual channel identifiers */266267typedef struct vpvc {268BITFIELD3(269u32 vci : 16, /* virtual channel identifier */270u32 vpi : 8, /* virtual path identifier */271u32 pad : 8 /* reserved */272)273} vpvc_t;274275276/* activate VC command opcode */277278typedef struct activate_opcode {279BITFIELD4(280enum opcode opcode : 8, /* cp opcode */281enum fore200e_aal aal : 8, /* adaptation layer */282enum buffer_scheme scheme : 8, /* buffer scheme */283u32 pad : 8 /* reserved */284)285} activate_opcode_t;286287288/* activate VC command block */289290typedef struct activate_block {291struct activate_opcode opcode; /* activate VC command opcode */292struct vpvc vpvc; /* VPI/VCI */293u32 mtu; /* for AAL0 only */294295} activate_block_t;296297298/* deactivate VC command opcode */299300typedef struct deactivate_opcode {301BITFIELD2(302enum opcode opcode : 8, /* cp opcode */303u32 pad : 24 /* reserved */304)305} deactivate_opcode_t;306307308/* deactivate VC command block */309310typedef struct deactivate_block {311struct deactivate_opcode opcode; /* deactivate VC command opcode */312struct vpvc vpvc; /* VPI/VCI */313} deactivate_block_t;314315316/* OC-3 registers */317318typedef struct oc3_regs {319u32 reg[ 128 ]; /* see the PMC Sierra PC5346 S/UNI-155-Lite320Saturn User Network Interface documentation321for a description of the OC-3 chip registers */322} oc3_regs_t;323324325/* set/get OC-3 regs command opcode */326327typedef struct oc3_opcode {328BITFIELD4(329enum opcode opcode : 8, /* cp opcode */330u32 reg : 8, /* register index */331u32 value : 8, /* register value */332u32 mask : 8 /* register mask that specifies which333bits of the register value field334are significant */335)336} oc3_opcode_t;337338339/* set/get OC-3 regs command block */340341typedef struct oc3_block {342struct oc3_opcode opcode; /* set/get OC-3 regs command opcode */343u32 regs_haddr; /* host DMA address of OC-3 regs buffer */344} oc3_block_t;345346347/* physical encoding statistics */348349typedef struct stats_phy {350__be32 crc_header_errors; /* cells received with bad header CRC */351__be32 framing_errors; /* cells received with bad framing */352__be32 pad[ 2 ]; /* i960 padding */353} stats_phy_t;354355356/* OC-3 statistics */357358typedef struct stats_oc3 {359__be32 section_bip8_errors; /* section 8 bit interleaved parity */360__be32 path_bip8_errors; /* path 8 bit interleaved parity */361__be32 line_bip24_errors; /* line 24 bit interleaved parity */362__be32 line_febe_errors; /* line far end block errors */363__be32 path_febe_errors; /* path far end block errors */364__be32 corr_hcs_errors; /* correctable header check sequence */365__be32 ucorr_hcs_errors; /* uncorrectable header check sequence */366__be32 pad[ 1 ]; /* i960 padding */367} stats_oc3_t;368369370/* ATM statistics */371372typedef struct stats_atm {373__be32 cells_transmitted; /* cells transmitted */374__be32 cells_received; /* cells received */375__be32 vpi_bad_range; /* cell drops: VPI out of range */376__be32 vpi_no_conn; /* cell drops: no connection for VPI */377__be32 vci_bad_range; /* cell drops: VCI out of range */378__be32 vci_no_conn; /* cell drops: no connection for VCI */379__be32 pad[ 2 ]; /* i960 padding */380} stats_atm_t;381382/* AAL0 statistics */383384typedef struct stats_aal0 {385__be32 cells_transmitted; /* cells transmitted */386__be32 cells_received; /* cells received */387__be32 cells_dropped; /* cells dropped */388__be32 pad[ 1 ]; /* i960 padding */389} stats_aal0_t;390391392/* AAL3/4 statistics */393394typedef struct stats_aal34 {395__be32 cells_transmitted; /* cells transmitted from segmented PDUs */396__be32 cells_received; /* cells reassembled into PDUs */397__be32 cells_crc_errors; /* payload CRC error count */398__be32 cells_protocol_errors; /* SAR or CS layer protocol errors */399__be32 cells_dropped; /* cells dropped: partial reassembly */400__be32 cspdus_transmitted; /* CS PDUs transmitted */401__be32 cspdus_received; /* CS PDUs received */402__be32 cspdus_protocol_errors; /* CS layer protocol errors */403__be32 cspdus_dropped; /* reassembled PDUs drop'd (in cells) */404__be32 pad[ 3 ]; /* i960 padding */405} stats_aal34_t;406407408/* AAL5 statistics */409410typedef struct stats_aal5 {411__be32 cells_transmitted; /* cells transmitted from segmented SDUs */412__be32 cells_received; /* cells reassembled into SDUs */413__be32 cells_dropped; /* reassembled PDUs dropped (in cells) */414__be32 congestion_experienced; /* CRC error and length wrong */415__be32 cspdus_transmitted; /* CS PDUs transmitted */416__be32 cspdus_received; /* CS PDUs received */417__be32 cspdus_crc_errors; /* CS PDUs CRC errors */418__be32 cspdus_protocol_errors; /* CS layer protocol errors */419__be32 cspdus_dropped; /* reassembled PDUs dropped */420__be32 pad[ 3 ]; /* i960 padding */421} stats_aal5_t;422423424/* auxiliary statistics */425426typedef struct stats_aux {427__be32 small_b1_failed; /* receive BD allocation failures */428__be32 large_b1_failed; /* receive BD allocation failures */429__be32 small_b2_failed; /* receive BD allocation failures */430__be32 large_b2_failed; /* receive BD allocation failures */431__be32 rpd_alloc_failed; /* receive PDU allocation failures */432__be32 receive_carrier; /* no carrier = 0, carrier = 1 */433__be32 pad[ 2 ]; /* i960 padding */434} stats_aux_t;435436437/* whole statistics buffer */438439typedef struct stats {440struct stats_phy phy; /* physical encoding statistics */441struct stats_oc3 oc3; /* OC-3 statistics */442struct stats_atm atm; /* ATM statistics */443struct stats_aal0 aal0; /* AAL0 statistics */444struct stats_aal34 aal34; /* AAL3/4 statistics */445struct stats_aal5 aal5; /* AAL5 statistics */446struct stats_aux aux; /* auxiliary statistics */447} stats_t;448449450/* get statistics command opcode */451452typedef struct stats_opcode {453BITFIELD2(454enum opcode opcode : 8, /* cp opcode */455u32 pad : 24 /* reserved */456)457} stats_opcode_t;458459460/* get statistics command block */461462typedef struct stats_block {463struct stats_opcode opcode; /* get statistics command opcode */464u32 stats_haddr; /* host DMA address of stats buffer */465} stats_block_t;466467468/* expansion PROM data (PCI specific) */469470typedef struct prom_data {471u32 hw_revision; /* hardware revision */472u32 serial_number; /* board serial number */473u8 mac_addr[ 8 ]; /* board MAC address */474} prom_data_t;475476477/* get expansion PROM data command opcode */478479typedef struct prom_opcode {480BITFIELD2(481enum opcode opcode : 8, /* cp opcode */482u32 pad : 24 /* reserved */483)484} prom_opcode_t;485486487/* get expansion PROM data command block */488489typedef struct prom_block {490struct prom_opcode opcode; /* get PROM data command opcode */491u32 prom_haddr; /* host DMA address of PROM buffer */492} prom_block_t;493494495/* cp command */496497typedef union cmd {498enum opcode opcode; /* operation code */499struct activate_block activate_block; /* activate VC */500struct deactivate_block deactivate_block; /* deactivate VC */501struct stats_block stats_block; /* get statistics */502struct prom_block prom_block; /* get expansion PROM data */503struct oc3_block oc3_block; /* get/set OC-3 registers */504u32 pad[ 4 ]; /* i960 padding */505} cmd_t;506507508/* cp resident command queue */509510typedef struct cp_cmdq_entry {511union cmd cmd; /* command */512u32 status_haddr; /* host DMA address of completion status */513u32 pad[ 3 ]; /* i960 padding */514} cp_cmdq_entry_t;515516517/* host resident transmit queue entry */518519typedef struct host_txq_entry {520struct cp_txq_entry __iomem *cp_entry; /* addr of cp resident tx queue entry */521enum status* status; /* addr of host resident status */522struct tpd* tpd; /* addr of transmit PDU descriptor */523u32 tpd_dma; /* DMA address of tpd */524struct sk_buff* skb; /* related skb */525void* data; /* copy of misaligned data */526unsigned long incarn; /* vc_map incarnation when submitted for tx */527struct fore200e_vc_map* vc_map;528529} host_txq_entry_t;530531532/* host resident receive queue entry */533534typedef struct host_rxq_entry {535struct cp_rxq_entry __iomem *cp_entry; /* addr of cp resident rx queue entry */536enum status* status; /* addr of host resident status */537struct rpd* rpd; /* addr of receive PDU descriptor */538u32 rpd_dma; /* DMA address of rpd */539} host_rxq_entry_t;540541542/* host resident buffer supply queue entry */543544typedef struct host_bsq_entry {545struct cp_bsq_entry __iomem *cp_entry; /* addr of cp resident buffer supply queue entry */546enum status* status; /* addr of host resident status */547struct rbd_block* rbd_block; /* addr of receive buffer descriptor block */548u32 rbd_block_dma; /* DMA address od rdb */549} host_bsq_entry_t;550551552/* host resident command queue entry */553554typedef struct host_cmdq_entry {555struct cp_cmdq_entry __iomem *cp_entry; /* addr of cp resident cmd queue entry */556enum status *status; /* addr of host resident status */557} host_cmdq_entry_t;558559560/* chunk of memory */561562typedef struct chunk {563void* alloc_addr; /* base address of allocated chunk */564void* align_addr; /* base address of aligned chunk */565dma_addr_t dma_addr; /* DMA address of aligned chunk */566int direction; /* direction of DMA mapping */567u32 alloc_size; /* length of allocated chunk */568u32 align_size; /* length of aligned chunk */569} chunk_t;570571#define dma_size align_size /* DMA useable size */572573574/* host resident receive buffer */575576typedef struct buffer {577struct buffer* next; /* next receive buffer */578enum buffer_scheme scheme; /* buffer scheme */579enum buffer_magn magn; /* buffer magnitude */580struct chunk data; /* data buffer */581#ifdef FORE200E_BSQ_DEBUG582unsigned long index; /* buffer # in queue */583int supplied; /* 'buffer supplied' flag */584#endif585} buffer_t;586587588#if (BITS_PER_LONG == 32)589#define FORE200E_BUF2HDL(buffer) ((u32)(buffer))590#define FORE200E_HDL2BUF(handle) ((struct buffer*)(handle))591#else /* deal with 64 bit pointers */592#define FORE200E_BUF2HDL(buffer) ((u32)((u64)(buffer)))593#define FORE200E_HDL2BUF(handle) ((struct buffer*)(((u64)(handle)) | PAGE_OFFSET))594#endif595596597/* host resident command queue */598599typedef struct host_cmdq {600struct host_cmdq_entry host_entry[ QUEUE_SIZE_CMD ]; /* host resident cmd queue entries */601int head; /* head of cmd queue */602struct chunk status; /* array of completion status */603} host_cmdq_t;604605606/* host resident transmit queue */607608typedef struct host_txq {609struct host_txq_entry host_entry[ QUEUE_SIZE_TX ]; /* host resident tx queue entries */610int head; /* head of tx queue */611int tail; /* tail of tx queue */612struct chunk tpd; /* array of tpds */613struct chunk status; /* arry of completion status */614int txing; /* number of pending PDUs in tx queue */615} host_txq_t;616617618/* host resident receive queue */619620typedef struct host_rxq {621struct host_rxq_entry host_entry[ QUEUE_SIZE_RX ]; /* host resident rx queue entries */622int head; /* head of rx queue */623struct chunk rpd; /* array of rpds */624struct chunk status; /* array of completion status */625} host_rxq_t;626627628/* host resident buffer supply queues */629630typedef struct host_bsq {631struct host_bsq_entry host_entry[ QUEUE_SIZE_BS ]; /* host resident buffer supply queue entries */632int head; /* head of buffer supply queue */633struct chunk rbd_block; /* array of rbds */634struct chunk status; /* array of completion status */635struct buffer* buffer; /* array of rx buffers */636struct buffer* freebuf; /* list of free rx buffers */637volatile int freebuf_count; /* count of free rx buffers */638} host_bsq_t;639640641/* header of the firmware image */642643typedef struct fw_header {644__le32 magic; /* magic number */645__le32 version; /* firmware version id */646__le32 load_offset; /* fw load offset in board memory */647__le32 start_offset; /* fw execution start address in board memory */648} fw_header_t;649650#define FW_HEADER_MAGIC 0x65726f66 /* 'fore' */651652653/* receive buffer supply queues scheme specification */654655typedef struct bs_spec {656u32 queue_length; /* queue capacity */657u32 buffer_size; /* host buffer size */658u32 pool_size; /* number of rbds */659u32 supply_blksize; /* num of rbds in I/O block (multiple660of 4 between 4 and 124 inclusive) */661} bs_spec_t;662663664/* initialization command block (one-time command, not in cmd queue) */665666typedef struct init_block {667enum opcode opcode; /* initialize command */668enum status status; /* related status word */669u32 receive_threshold; /* not used */670u32 num_connect; /* ATM connections */671u32 cmd_queue_len; /* length of command queue */672u32 tx_queue_len; /* length of transmit queue */673u32 rx_queue_len; /* length of receive queue */674u32 rsd_extension; /* number of extra 32 byte blocks */675u32 tsd_extension; /* number of extra 32 byte blocks */676u32 conless_vpvc; /* not used */677u32 pad[ 2 ]; /* force quad alignment */678struct bs_spec bs_spec[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ]; /* buffer supply queues spec */679} init_block_t;680681682typedef enum media_type {683MEDIA_TYPE_CAT5_UTP = 0x06, /* unshielded twisted pair */684MEDIA_TYPE_MM_OC3_ST = 0x16, /* multimode fiber ST */685MEDIA_TYPE_MM_OC3_SC = 0x26, /* multimode fiber SC */686MEDIA_TYPE_SM_OC3_ST = 0x36, /* single-mode fiber ST */687MEDIA_TYPE_SM_OC3_SC = 0x46 /* single-mode fiber SC */688} media_type_t;689690#define FORE200E_MEDIA_INDEX(media_type) ((media_type)>>4)691692693/* cp resident queues */694695typedef struct cp_queues {696u32 cp_cmdq; /* command queue */697u32 cp_txq; /* transmit queue */698u32 cp_rxq; /* receive queue */699u32 cp_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ]; /* buffer supply queues */700u32 imask; /* 1 enables cp to host interrupts */701u32 istat; /* 1 for interrupt posted */702u32 heap_base; /* offset form beginning of ram */703u32 heap_size; /* space available for queues */704u32 hlogger; /* non zero for host logging */705u32 heartbeat; /* cp heartbeat */706u32 fw_release; /* firmware version */707u32 mon960_release; /* i960 monitor version */708u32 tq_plen; /* transmit throughput measurements */709/* make sure the init block remains on a quad word boundary */710struct init_block init; /* one time cmd, not in cmd queue */711enum media_type media_type; /* media type id */712u32 oc3_revision; /* OC-3 revision number */713} cp_queues_t;714715716/* boot status */717718typedef enum boot_status {719BSTAT_COLD_START = (u32) 0xc01dc01d, /* cold start */720BSTAT_SELFTEST_OK = (u32) 0x02201958, /* self-test ok */721BSTAT_SELFTEST_FAIL = (u32) 0xadbadbad, /* self-test failed */722BSTAT_CP_RUNNING = (u32) 0xce11feed, /* cp is running */723BSTAT_MON_TOO_BIG = (u32) 0x10aded00 /* i960 monitor is too big */724} boot_status_t;725726727/* software UART */728729typedef struct soft_uart {730u32 send; /* write register */731u32 recv; /* read register */732} soft_uart_t;733734#define FORE200E_CP_MONITOR_UART_FREE 0x00000000735#define FORE200E_CP_MONITOR_UART_AVAIL 0x01000000736737738/* i960 monitor */739740typedef struct cp_monitor {741struct soft_uart soft_uart; /* software UART */742enum boot_status bstat; /* boot status */743u32 app_base; /* application base offset */744u32 mon_version; /* i960 monitor version */745} cp_monitor_t;746747748/* device state */749750typedef enum fore200e_state {751FORE200E_STATE_BLANK, /* initial state */752FORE200E_STATE_REGISTER, /* device registered */753FORE200E_STATE_CONFIGURE, /* bus interface configured */754FORE200E_STATE_MAP, /* board space mapped in host memory */755FORE200E_STATE_RESET, /* board resetted */756FORE200E_STATE_START_FW, /* firmware started */757FORE200E_STATE_INITIALIZE, /* initialize command successful */758FORE200E_STATE_INIT_CMDQ, /* command queue initialized */759FORE200E_STATE_INIT_TXQ, /* transmit queue initialized */760FORE200E_STATE_INIT_RXQ, /* receive queue initialized */761FORE200E_STATE_INIT_BSQ, /* buffer supply queue initialized */762FORE200E_STATE_ALLOC_BUF, /* receive buffers allocated */763FORE200E_STATE_IRQ, /* host interrupt requested */764FORE200E_STATE_COMPLETE /* initialization completed */765} fore200e_state;766767768/* PCA-200E registers */769770typedef struct fore200e_pca_regs {771volatile u32 __iomem * hcr; /* address of host control register */772volatile u32 __iomem * imr; /* address of host interrupt mask register */773volatile u32 __iomem * psr; /* address of PCI specific register */774} fore200e_pca_regs_t;775776777/* SBA-200E registers */778779typedef struct fore200e_sba_regs {780u32 __iomem *hcr; /* address of host control register */781u32 __iomem *bsr; /* address of burst transfer size register */782u32 __iomem *isr; /* address of interrupt level selection register */783} fore200e_sba_regs_t;784785786/* model-specific registers */787788typedef union fore200e_regs {789struct fore200e_pca_regs pca; /* PCA-200E registers */790struct fore200e_sba_regs sba; /* SBA-200E registers */791} fore200e_regs;792793794struct fore200e;795796/* bus-dependent data */797798typedef struct fore200e_bus {799char* model_name; /* board model name */800char* proc_name; /* board name under /proc/atm */801int descr_alignment; /* tpd/rpd/rbd DMA alignment requirement */802int buffer_alignment; /* rx buffers DMA alignment requirement */803int status_alignment; /* status words DMA alignment requirement */804u32 (*read)(volatile u32 __iomem *);805void (*write)(u32, volatile u32 __iomem *);806u32 (*dma_map)(struct fore200e*, void*, int, int);807void (*dma_unmap)(struct fore200e*, u32, int, int);808void (*dma_sync_for_cpu)(struct fore200e*, u32, int, int);809void (*dma_sync_for_device)(struct fore200e*, u32, int, int);810int (*dma_chunk_alloc)(struct fore200e*, struct chunk*, int, int, int);811void (*dma_chunk_free)(struct fore200e*, struct chunk*);812int (*configure)(struct fore200e*);813int (*map)(struct fore200e*);814void (*reset)(struct fore200e*);815int (*prom_read)(struct fore200e*, struct prom_data*);816void (*unmap)(struct fore200e*);817void (*irq_enable)(struct fore200e*);818int (*irq_check)(struct fore200e*);819void (*irq_ack)(struct fore200e*);820int (*proc_read)(struct fore200e*, char*);821} fore200e_bus_t;822823/* vc mapping */824825typedef struct fore200e_vc_map {826struct atm_vcc* vcc; /* vcc entry */827unsigned long incarn; /* vcc incarnation number */828} fore200e_vc_map_t;829830#define FORE200E_VC_MAP(fore200e, vpi, vci) \831(& (fore200e)->vc_map[ ((vpi) << FORE200E_VCI_BITS) | (vci) ])832833834/* per-device data */835836typedef struct fore200e {837struct list_head entry; /* next device */838const struct fore200e_bus* bus; /* bus-dependent code and data */839union fore200e_regs regs; /* bus-dependent registers */840struct atm_dev* atm_dev; /* ATM device */841842enum fore200e_state state; /* device state */843844char name[16]; /* device name */845void* bus_dev; /* bus-specific kernel data */846int irq; /* irq number */847unsigned long phys_base; /* physical base address */848void __iomem * virt_base; /* virtual base address */849850unsigned char esi[ ESI_LEN ]; /* end system identifier */851852struct cp_monitor __iomem * cp_monitor; /* i960 monitor address */853struct cp_queues __iomem * cp_queues; /* cp resident queues */854struct host_cmdq host_cmdq; /* host resident cmd queue */855struct host_txq host_txq; /* host resident tx queue */856struct host_rxq host_rxq; /* host resident rx queue */857/* host resident buffer supply queues */858struct host_bsq host_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ];859860u32 available_cell_rate; /* remaining pseudo-CBR bw on link */861862int loop_mode; /* S/UNI loopback mode */863864struct stats* stats; /* last snapshot of the stats */865866struct mutex rate_mtx; /* protects rate reservation ops */867spinlock_t q_lock; /* protects queue ops */868#ifdef FORE200E_USE_TASKLET869struct tasklet_struct tx_tasklet; /* performs tx interrupt work */870struct tasklet_struct rx_tasklet; /* performs rx interrupt work */871#endif872unsigned long tx_sat; /* tx queue saturation count */873874unsigned long incarn_count;875struct fore200e_vc_map vc_map[ NBR_CONNECT ]; /* vc mapping */876} fore200e_t;877878879/* per-vcc data */880881typedef struct fore200e_vcc {882enum buffer_scheme scheme; /* rx buffer scheme */883struct tpd_rate rate; /* tx rate control data */884int rx_min_pdu; /* size of smallest PDU received */885int rx_max_pdu; /* size of largest PDU received */886int tx_min_pdu; /* size of smallest PDU transmitted */887int tx_max_pdu; /* size of largest PDU transmitted */888unsigned long tx_pdu; /* nbr of tx pdus */889unsigned long rx_pdu; /* nbr of rx pdus */890} fore200e_vcc_t;891892893894/* 200E-series common memory layout */895896#define FORE200E_CP_MONITOR_OFFSET 0x00000400 /* i960 monitor interface */897#define FORE200E_CP_QUEUES_OFFSET 0x00004d40 /* cp resident queues */898899900/* PCA-200E memory layout */901902#define PCA200E_IOSPACE_LENGTH 0x00200000903904#define PCA200E_HCR_OFFSET 0x00100000 /* board control register */905#define PCA200E_IMR_OFFSET 0x00100004 /* host IRQ mask register */906#define PCA200E_PSR_OFFSET 0x00100008 /* PCI specific register */907908909/* PCA-200E host control register */910911#define PCA200E_HCR_RESET (1<<0) /* read / write */912#define PCA200E_HCR_HOLD_LOCK (1<<1) /* read / write */913#define PCA200E_HCR_I960FAIL (1<<2) /* read */914#define PCA200E_HCR_INTRB (1<<2) /* write */915#define PCA200E_HCR_HOLD_ACK (1<<3) /* read */916#define PCA200E_HCR_INTRA (1<<3) /* write */917#define PCA200E_HCR_OUTFULL (1<<4) /* read */918#define PCA200E_HCR_CLRINTR (1<<4) /* write */919#define PCA200E_HCR_ESPHOLD (1<<5) /* read */920#define PCA200E_HCR_INFULL (1<<6) /* read */921#define PCA200E_HCR_TESTMODE (1<<7) /* read */922923924/* PCA-200E PCI bus interface regs (offsets in PCI config space) */925926#define PCA200E_PCI_LATENCY 0x40 /* maximum slave latenty */927#define PCA200E_PCI_MASTER_CTRL 0x41 /* master control */928#define PCA200E_PCI_THRESHOLD 0x42 /* burst / continuous req threshold */929930/* PBI master control register */931932#define PCA200E_CTRL_DIS_CACHE_RD (1<<0) /* disable cache-line reads */933#define PCA200E_CTRL_DIS_WRT_INVAL (1<<1) /* disable writes and invalidates */934#define PCA200E_CTRL_2_CACHE_WRT_INVAL (1<<2) /* require 2 cache-lines for writes and invalidates */935#define PCA200E_CTRL_IGN_LAT_TIMER (1<<3) /* ignore the latency timer */936#define PCA200E_CTRL_ENA_CONT_REQ_MODE (1<<4) /* enable continuous request mode */937#define PCA200E_CTRL_LARGE_PCI_BURSTS (1<<5) /* force large PCI bus bursts */938#define PCA200E_CTRL_CONVERT_ENDIAN (1<<6) /* convert endianess of slave RAM accesses */939940941942#define SBA200E_PROM_NAME "FORE,sba-200e" /* device name in openprom tree */943944945/* size of SBA-200E registers */946947#define SBA200E_HCR_LENGTH 4948#define SBA200E_BSR_LENGTH 4949#define SBA200E_ISR_LENGTH 4950#define SBA200E_RAM_LENGTH 0x40000951952953/* SBA-200E SBUS burst transfer size register */954955#define SBA200E_BSR_BURST4 0x04956#define SBA200E_BSR_BURST8 0x08957#define SBA200E_BSR_BURST16 0x10958959960/* SBA-200E host control register */961962#define SBA200E_HCR_RESET (1<<0) /* read / write (sticky) */963#define SBA200E_HCR_HOLD_LOCK (1<<1) /* read / write (sticky) */964#define SBA200E_HCR_I960FAIL (1<<2) /* read */965#define SBA200E_HCR_I960SETINTR (1<<2) /* write */966#define SBA200E_HCR_OUTFULL (1<<3) /* read */967#define SBA200E_HCR_INTR_CLR (1<<3) /* write */968#define SBA200E_HCR_INTR_ENA (1<<4) /* read / write (sticky) */969#define SBA200E_HCR_ESPHOLD (1<<5) /* read */970#define SBA200E_HCR_INFULL (1<<6) /* read */971#define SBA200E_HCR_TESTMODE (1<<7) /* read */972#define SBA200E_HCR_INTR_REQ (1<<8) /* read */973974#define SBA200E_HCR_STICKY (SBA200E_HCR_RESET | SBA200E_HCR_HOLD_LOCK | SBA200E_HCR_INTR_ENA)975976977#endif /* __KERNEL__ */978#endif /* _FORE200E_H */979980981