/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _FORE200E_H2#define _FORE200E_H34#ifdef __KERNEL__56/* rx buffer sizes */78#define SMALL_BUFFER_SIZE 384 /* size of small buffers (multiple of 48 (PCA) and 64 (SBA) bytes) */9#define LARGE_BUFFER_SIZE 4032 /* size of large buffers (multiple of 48 (PCA) and 64 (SBA) bytes) */101112#define RBD_BLK_SIZE 32 /* nbr of supplied rx buffers per rbd */131415#define MAX_PDU_SIZE 65535 /* maximum PDU size supported by AALs */161718#define BUFFER_S1_SIZE SMALL_BUFFER_SIZE /* size of small buffers, scheme 1 */19#define BUFFER_L1_SIZE LARGE_BUFFER_SIZE /* size of large buffers, scheme 1 */2021#define BUFFER_S2_SIZE SMALL_BUFFER_SIZE /* size of small buffers, scheme 2 */22#define BUFFER_L2_SIZE LARGE_BUFFER_SIZE /* size of large buffers, scheme 2 */2324#define BUFFER_S1_NBR (RBD_BLK_SIZE * 6)25#define BUFFER_L1_NBR (RBD_BLK_SIZE * 4)2627#define BUFFER_S2_NBR (RBD_BLK_SIZE * 6)28#define BUFFER_L2_NBR (RBD_BLK_SIZE * 4)293031#define QUEUE_SIZE_CMD 16 /* command queue capacity */32#define QUEUE_SIZE_RX 64 /* receive queue capacity */33#define QUEUE_SIZE_TX 256 /* transmit queue capacity */34#define QUEUE_SIZE_BS 32 /* buffer supply queue capacity */3536#define FORE200E_VPI_BITS 037#define FORE200E_VCI_BITS 1038#define NBR_CONNECT (1 << (FORE200E_VPI_BITS + FORE200E_VCI_BITS)) /* number of connections */394041#define TSD_FIXED 242#define TSD_EXTENSION 043#define TSD_NBR (TSD_FIXED + TSD_EXTENSION)444546/* the cp starts putting a received PDU into one *small* buffer,47then it uses a number of *large* buffers for the trailing data.48we compute here the total number of receive segment descriptors49required to hold the largest possible PDU */5051#define RSD_REQUIRED (((MAX_PDU_SIZE - SMALL_BUFFER_SIZE + LARGE_BUFFER_SIZE) / LARGE_BUFFER_SIZE) + 1)5253#define RSD_FIXED 35455/* RSD_REQUIRED receive segment descriptors are enough to describe a max-sized PDU,56but we have to keep the size of the receive PDU descriptor multiple of 32 bytes,57so we add one extra RSD to RSD_EXTENSION58(WARNING: THIS MAY CHANGE IF BUFFER SIZES ARE MODIFIED) */5960#define RSD_EXTENSION ((RSD_REQUIRED - RSD_FIXED) + 1)61#define RSD_NBR (RSD_FIXED + RSD_EXTENSION)626364#define FORE200E_DEV(d) ((struct fore200e*)((d)->dev_data))65#define FORE200E_VCC(d) ((struct fore200e_vcc*)((d)->dev_data))6667/* bitfields endian games */6869#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;81#else82#error unknown bitfield endianess83#endif848586/* ATM cell header (minus HEC byte) */8788typedef struct atm_header {89BITFIELD5(90u32 clp : 1, /* cell loss priority */91u32 plt : 3, /* payload type */92u32 vci : 16, /* virtual channel identifier */93u32 vpi : 8, /* virtual path identifier */94u32 gfc : 4 /* generic flow control */95)96} atm_header_t;979899/* ATM adaptation layer id */100101typedef enum fore200e_aal {102FORE200E_AAL0 = 0,103FORE200E_AAL34 = 4,104FORE200E_AAL5 = 5,105} fore200e_aal_t;106107108/* transmit PDU descriptor specification */109110typedef struct tpd_spec {111BITFIELD4(112u32 length : 16, /* total PDU length */113u32 nseg : 8, /* number of transmit segments */114enum fore200e_aal aal : 4, /* adaptation layer */115u32 intr : 4 /* interrupt requested */116)117} tpd_spec_t;118119120/* transmit PDU rate control */121122typedef struct tpd_rate123{124BITFIELD2(125u32 idle_cells : 16, /* number of idle cells to insert */126u32 data_cells : 16 /* number of data cells to transmit */127)128} tpd_rate_t;129130131/* transmit segment descriptor */132133typedef struct tsd {134u32 buffer; /* transmit buffer DMA address */135u32 length; /* number of bytes in buffer */136} tsd_t;137138139/* transmit PDU descriptor */140141typedef struct tpd {142struct atm_header atm_header; /* ATM header minus HEC byte */143struct tpd_spec spec; /* tpd specification */144struct tpd_rate rate; /* tpd rate control */145u32 pad; /* reserved */146struct tsd tsd[ TSD_NBR ]; /* transmit segment descriptors */147} tpd_t;148149150/* receive segment descriptor */151152typedef struct rsd {153u32 handle; /* host supplied receive buffer handle */154u32 length; /* number of bytes in buffer */155} rsd_t;156157158/* receive PDU descriptor */159160typedef struct rpd {161struct atm_header atm_header; /* ATM header minus HEC byte */162u32 nseg; /* number of receive segments */163struct rsd rsd[ RSD_NBR ]; /* receive segment descriptors */164} rpd_t;165166167/* buffer scheme */168169typedef enum buffer_scheme {170BUFFER_SCHEME_ONE,171BUFFER_SCHEME_TWO,172BUFFER_SCHEME_NBR /* always last */173} buffer_scheme_t;174175176/* buffer magnitude */177178typedef enum buffer_magn {179BUFFER_MAGN_SMALL,180BUFFER_MAGN_LARGE,181BUFFER_MAGN_NBR /* always last */182} buffer_magn_t;183184185/* receive buffer descriptor */186187typedef struct rbd {188u32 handle; /* host supplied handle */189u32 buffer_haddr; /* host DMA address of host buffer */190} rbd_t;191192193/* receive buffer descriptor block */194195typedef struct rbd_block {196struct rbd rbd[ RBD_BLK_SIZE ]; /* receive buffer descriptor */197} rbd_block_t;198199200/* tpd DMA address */201202typedef struct tpd_haddr {203BITFIELD3(204u32 size : 4, /* tpd size expressed in 32 byte blocks */205u32 pad : 1, /* reserved */206u32 haddr : 27 /* tpd DMA addr aligned on 32 byte boundary */207)208} tpd_haddr_t;209210#define TPD_HADDR_SHIFT 5 /* addr aligned on 32 byte boundary */211212/* cp resident transmit queue entry */213214typedef struct cp_txq_entry {215struct tpd_haddr tpd_haddr; /* host DMA address of tpd */216u32 status_haddr; /* host DMA address of completion status */217} cp_txq_entry_t;218219220/* cp resident receive queue entry */221222typedef struct cp_rxq_entry {223u32 rpd_haddr; /* host DMA address of rpd */224u32 status_haddr; /* host DMA address of completion status */225} cp_rxq_entry_t;226227228/* cp resident buffer supply queue entry */229230typedef struct cp_bsq_entry {231u32 rbd_block_haddr; /* host DMA address of rbd block */232u32 status_haddr; /* host DMA address of completion status */233} cp_bsq_entry_t;234235236/* completion status */237238typedef volatile enum status {239STATUS_PENDING = (1<<0), /* initial status (written by host) */240STATUS_COMPLETE = (1<<1), /* completion status (written by cp) */241STATUS_FREE = (1<<2), /* initial status (written by host) */242STATUS_ERROR = (1<<3) /* completion status (written by cp) */243} status_t;244245246/* cp operation code */247248typedef enum opcode {249OPCODE_INITIALIZE = 1, /* initialize board */250OPCODE_ACTIVATE_VCIN, /* activate incoming VCI */251OPCODE_ACTIVATE_VCOUT, /* activate outgoing VCI */252OPCODE_DEACTIVATE_VCIN, /* deactivate incoming VCI */253OPCODE_DEACTIVATE_VCOUT, /* deactivate incoing VCI */254OPCODE_GET_STATS, /* get board statistics */255OPCODE_SET_OC3, /* set OC-3 registers */256OPCODE_GET_OC3, /* get OC-3 registers */257OPCODE_RESET_STATS, /* reset board statistics */258OPCODE_GET_PROM, /* get expansion PROM data (PCI specific) */259OPCODE_SET_VPI_BITS, /* set x bits of those decoded by the260firmware to be low order bits from261the VPI field of the ATM cell header */262OPCODE_REQUEST_INTR = (1<<7) /* request interrupt */263} opcode_t;264265266/* virtual path / virtual channel identifiers */267268typedef struct vpvc {269BITFIELD3(270u32 vci : 16, /* virtual channel identifier */271u32 vpi : 8, /* virtual path identifier */272u32 pad : 8 /* reserved */273)274} vpvc_t;275276277/* activate VC command opcode */278279typedef struct activate_opcode {280BITFIELD4(281enum opcode opcode : 8, /* cp opcode */282enum fore200e_aal aal : 8, /* adaptation layer */283enum buffer_scheme scheme : 8, /* buffer scheme */284u32 pad : 8 /* reserved */285)286} activate_opcode_t;287288289/* activate VC command block */290291typedef struct activate_block {292struct activate_opcode opcode; /* activate VC command opcode */293struct vpvc vpvc; /* VPI/VCI */294u32 mtu; /* for AAL0 only */295296} activate_block_t;297298299/* deactivate VC command opcode */300301typedef struct deactivate_opcode {302BITFIELD2(303enum opcode opcode : 8, /* cp opcode */304u32 pad : 24 /* reserved */305)306} deactivate_opcode_t;307308309/* deactivate VC command block */310311typedef struct deactivate_block {312struct deactivate_opcode opcode; /* deactivate VC command opcode */313struct vpvc vpvc; /* VPI/VCI */314} deactivate_block_t;315316317/* OC-3 registers */318319typedef struct oc3_regs {320u32 reg[ 128 ]; /* see the PMC Sierra PC5346 S/UNI-155-Lite321Saturn User Network Interface documentation322for a description of the OC-3 chip registers */323} oc3_regs_t;324325326/* set/get OC-3 regs command opcode */327328typedef struct oc3_opcode {329BITFIELD4(330enum opcode opcode : 8, /* cp opcode */331u32 reg : 8, /* register index */332u32 value : 8, /* register value */333u32 mask : 8 /* register mask that specifies which334bits of the register value field335are significant */336)337} oc3_opcode_t;338339340/* set/get OC-3 regs command block */341342typedef struct oc3_block {343struct oc3_opcode opcode; /* set/get OC-3 regs command opcode */344u32 regs_haddr; /* host DMA address of OC-3 regs buffer */345} oc3_block_t;346347348/* physical encoding statistics */349350typedef struct stats_phy {351__be32 crc_header_errors; /* cells received with bad header CRC */352__be32 framing_errors; /* cells received with bad framing */353__be32 pad[ 2 ]; /* i960 padding */354} stats_phy_t;355356357/* OC-3 statistics */358359typedef struct stats_oc3 {360__be32 section_bip8_errors; /* section 8 bit interleaved parity */361__be32 path_bip8_errors; /* path 8 bit interleaved parity */362__be32 line_bip24_errors; /* line 24 bit interleaved parity */363__be32 line_febe_errors; /* line far end block errors */364__be32 path_febe_errors; /* path far end block errors */365__be32 corr_hcs_errors; /* correctable header check sequence */366__be32 ucorr_hcs_errors; /* uncorrectable header check sequence */367__be32 pad[ 1 ]; /* i960 padding */368} stats_oc3_t;369370371/* ATM statistics */372373typedef struct stats_atm {374__be32 cells_transmitted; /* cells transmitted */375__be32 cells_received; /* cells received */376__be32 vpi_bad_range; /* cell drops: VPI out of range */377__be32 vpi_no_conn; /* cell drops: no connection for VPI */378__be32 vci_bad_range; /* cell drops: VCI out of range */379__be32 vci_no_conn; /* cell drops: no connection for VCI */380__be32 pad[ 2 ]; /* i960 padding */381} stats_atm_t;382383/* AAL0 statistics */384385typedef struct stats_aal0 {386__be32 cells_transmitted; /* cells transmitted */387__be32 cells_received; /* cells received */388__be32 cells_dropped; /* cells dropped */389__be32 pad[ 1 ]; /* i960 padding */390} stats_aal0_t;391392393/* AAL3/4 statistics */394395typedef struct stats_aal34 {396__be32 cells_transmitted; /* cells transmitted from segmented PDUs */397__be32 cells_received; /* cells reassembled into PDUs */398__be32 cells_crc_errors; /* payload CRC error count */399__be32 cells_protocol_errors; /* SAR or CS layer protocol errors */400__be32 cells_dropped; /* cells dropped: partial reassembly */401__be32 cspdus_transmitted; /* CS PDUs transmitted */402__be32 cspdus_received; /* CS PDUs received */403__be32 cspdus_protocol_errors; /* CS layer protocol errors */404__be32 cspdus_dropped; /* reassembled PDUs drop'd (in cells) */405__be32 pad[ 3 ]; /* i960 padding */406} stats_aal34_t;407408409/* AAL5 statistics */410411typedef struct stats_aal5 {412__be32 cells_transmitted; /* cells transmitted from segmented SDUs */413__be32 cells_received; /* cells reassembled into SDUs */414__be32 cells_dropped; /* reassembled PDUs dropped (in cells) */415__be32 congestion_experienced; /* CRC error and length wrong */416__be32 cspdus_transmitted; /* CS PDUs transmitted */417__be32 cspdus_received; /* CS PDUs received */418__be32 cspdus_crc_errors; /* CS PDUs CRC errors */419__be32 cspdus_protocol_errors; /* CS layer protocol errors */420__be32 cspdus_dropped; /* reassembled PDUs dropped */421__be32 pad[ 3 ]; /* i960 padding */422} stats_aal5_t;423424425/* auxiliary statistics */426427typedef struct stats_aux {428__be32 small_b1_failed; /* receive BD allocation failures */429__be32 large_b1_failed; /* receive BD allocation failures */430__be32 small_b2_failed; /* receive BD allocation failures */431__be32 large_b2_failed; /* receive BD allocation failures */432__be32 rpd_alloc_failed; /* receive PDU allocation failures */433__be32 receive_carrier; /* no carrier = 0, carrier = 1 */434__be32 pad[ 2 ]; /* i960 padding */435} stats_aux_t;436437438/* whole statistics buffer */439440typedef struct stats {441struct stats_phy phy; /* physical encoding statistics */442struct stats_oc3 oc3; /* OC-3 statistics */443struct stats_atm atm; /* ATM statistics */444struct stats_aal0 aal0; /* AAL0 statistics */445struct stats_aal34 aal34; /* AAL3/4 statistics */446struct stats_aal5 aal5; /* AAL5 statistics */447struct stats_aux aux; /* auxiliary statistics */448} stats_t;449450451/* get statistics command opcode */452453typedef struct stats_opcode {454BITFIELD2(455enum opcode opcode : 8, /* cp opcode */456u32 pad : 24 /* reserved */457)458} stats_opcode_t;459460461/* get statistics command block */462463typedef struct stats_block {464struct stats_opcode opcode; /* get statistics command opcode */465u32 stats_haddr; /* host DMA address of stats buffer */466} stats_block_t;467468469/* expansion PROM data (PCI specific) */470471typedef struct prom_data {472u32 hw_revision; /* hardware revision */473u32 serial_number; /* board serial number */474u8 mac_addr[ 8 ]; /* board MAC address */475} prom_data_t;476477478/* get expansion PROM data command opcode */479480typedef struct prom_opcode {481BITFIELD2(482enum opcode opcode : 8, /* cp opcode */483u32 pad : 24 /* reserved */484)485} prom_opcode_t;486487488/* get expansion PROM data command block */489490typedef struct prom_block {491struct prom_opcode opcode; /* get PROM data command opcode */492u32 prom_haddr; /* host DMA address of PROM buffer */493} prom_block_t;494495496/* cp command */497498typedef union cmd {499enum opcode opcode; /* operation code */500struct activate_block activate_block; /* activate VC */501struct deactivate_block deactivate_block; /* deactivate VC */502struct stats_block stats_block; /* get statistics */503struct prom_block prom_block; /* get expansion PROM data */504struct oc3_block oc3_block; /* get/set OC-3 registers */505u32 pad[ 4 ]; /* i960 padding */506} cmd_t;507508509/* cp resident command queue */510511typedef struct cp_cmdq_entry {512union cmd cmd; /* command */513u32 status_haddr; /* host DMA address of completion status */514u32 pad[ 3 ]; /* i960 padding */515} cp_cmdq_entry_t;516517518/* host resident transmit queue entry */519520typedef struct host_txq_entry {521struct cp_txq_entry __iomem *cp_entry; /* addr of cp resident tx queue entry */522enum status* status; /* addr of host resident status */523struct tpd* tpd; /* addr of transmit PDU descriptor */524u32 tpd_dma; /* DMA address of tpd */525struct sk_buff* skb; /* related skb */526void* data; /* copy of misaligned data */527unsigned long incarn; /* vc_map incarnation when submitted for tx */528struct fore200e_vc_map* vc_map;529530} host_txq_entry_t;531532533/* host resident receive queue entry */534535typedef struct host_rxq_entry {536struct cp_rxq_entry __iomem *cp_entry; /* addr of cp resident rx queue entry */537enum status* status; /* addr of host resident status */538struct rpd* rpd; /* addr of receive PDU descriptor */539u32 rpd_dma; /* DMA address of rpd */540} host_rxq_entry_t;541542543/* host resident buffer supply queue entry */544545typedef struct host_bsq_entry {546struct cp_bsq_entry __iomem *cp_entry; /* addr of cp resident buffer supply queue entry */547enum status* status; /* addr of host resident status */548struct rbd_block* rbd_block; /* addr of receive buffer descriptor block */549u32 rbd_block_dma; /* DMA address od rdb */550} host_bsq_entry_t;551552553/* host resident command queue entry */554555typedef struct host_cmdq_entry {556struct cp_cmdq_entry __iomem *cp_entry; /* addr of cp resident cmd queue entry */557enum status *status; /* addr of host resident status */558} host_cmdq_entry_t;559560561/* chunk of memory */562563typedef struct chunk {564void* alloc_addr; /* base address of allocated chunk */565void* align_addr; /* base address of aligned chunk */566dma_addr_t dma_addr; /* DMA address of aligned chunk */567int direction; /* direction of DMA mapping */568u32 alloc_size; /* length of allocated chunk */569u32 align_size; /* length of aligned chunk */570} chunk_t;571572#define dma_size align_size /* DMA useable size */573574575/* host resident receive buffer */576577typedef struct buffer {578struct buffer* next; /* next receive buffer */579enum buffer_scheme scheme; /* buffer scheme */580enum buffer_magn magn; /* buffer magnitude */581struct chunk data; /* data buffer */582#ifdef FORE200E_BSQ_DEBUG583unsigned long index; /* buffer # in queue */584int supplied; /* 'buffer supplied' flag */585#endif586} buffer_t;587588589#if (BITS_PER_LONG == 32)590#define FORE200E_BUF2HDL(buffer) ((u32)(buffer))591#define FORE200E_HDL2BUF(handle) ((struct buffer*)(handle))592#else /* deal with 64 bit pointers */593#define FORE200E_BUF2HDL(buffer) ((u32)((u64)(buffer)))594#define FORE200E_HDL2BUF(handle) ((struct buffer*)(((u64)(handle)) | PAGE_OFFSET))595#endif596597598/* host resident command queue */599600typedef struct host_cmdq {601struct host_cmdq_entry host_entry[ QUEUE_SIZE_CMD ]; /* host resident cmd queue entries */602int head; /* head of cmd queue */603struct chunk status; /* array of completion status */604} host_cmdq_t;605606607/* host resident transmit queue */608609typedef struct host_txq {610struct host_txq_entry host_entry[ QUEUE_SIZE_TX ]; /* host resident tx queue entries */611int head; /* head of tx queue */612int tail; /* tail of tx queue */613struct chunk tpd; /* array of tpds */614struct chunk status; /* arry of completion status */615int txing; /* number of pending PDUs in tx queue */616} host_txq_t;617618619/* host resident receive queue */620621typedef struct host_rxq {622struct host_rxq_entry host_entry[ QUEUE_SIZE_RX ]; /* host resident rx queue entries */623int head; /* head of rx queue */624struct chunk rpd; /* array of rpds */625struct chunk status; /* array of completion status */626} host_rxq_t;627628629/* host resident buffer supply queues */630631typedef struct host_bsq {632struct host_bsq_entry host_entry[ QUEUE_SIZE_BS ]; /* host resident buffer supply queue entries */633int head; /* head of buffer supply queue */634struct chunk rbd_block; /* array of rbds */635struct chunk status; /* array of completion status */636struct buffer* buffer; /* array of rx buffers */637struct buffer* freebuf; /* list of free rx buffers */638volatile int freebuf_count; /* count of free rx buffers */639} host_bsq_t;640641642/* header of the firmware image */643644typedef struct fw_header {645__le32 magic; /* magic number */646__le32 version; /* firmware version id */647__le32 load_offset; /* fw load offset in board memory */648__le32 start_offset; /* fw execution start address in board memory */649} fw_header_t;650651#define FW_HEADER_MAGIC 0x65726f66 /* 'fore' */652653654/* receive buffer supply queues scheme specification */655656typedef struct bs_spec {657u32 queue_length; /* queue capacity */658u32 buffer_size; /* host buffer size */659u32 pool_size; /* number of rbds */660u32 supply_blksize; /* num of rbds in I/O block (multiple661of 4 between 4 and 124 inclusive) */662} bs_spec_t;663664665/* initialization command block (one-time command, not in cmd queue) */666667typedef struct init_block {668enum opcode opcode; /* initialize command */669enum status status; /* related status word */670u32 receive_threshold; /* not used */671u32 num_connect; /* ATM connections */672u32 cmd_queue_len; /* length of command queue */673u32 tx_queue_len; /* length of transmit queue */674u32 rx_queue_len; /* length of receive queue */675u32 rsd_extension; /* number of extra 32 byte blocks */676u32 tsd_extension; /* number of extra 32 byte blocks */677u32 conless_vpvc; /* not used */678u32 pad[ 2 ]; /* force quad alignment */679struct bs_spec bs_spec[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ]; /* buffer supply queues spec */680} init_block_t;681682683typedef enum media_type {684MEDIA_TYPE_CAT5_UTP = 0x06, /* unshielded twisted pair */685MEDIA_TYPE_MM_OC3_ST = 0x16, /* multimode fiber ST */686MEDIA_TYPE_MM_OC3_SC = 0x26, /* multimode fiber SC */687MEDIA_TYPE_SM_OC3_ST = 0x36, /* single-mode fiber ST */688MEDIA_TYPE_SM_OC3_SC = 0x46 /* single-mode fiber SC */689} media_type_t;690691#define FORE200E_MEDIA_INDEX(media_type) ((media_type)>>4)692693694/* cp resident queues */695696typedef struct cp_queues {697u32 cp_cmdq; /* command queue */698u32 cp_txq; /* transmit queue */699u32 cp_rxq; /* receive queue */700u32 cp_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ]; /* buffer supply queues */701u32 imask; /* 1 enables cp to host interrupts */702u32 istat; /* 1 for interrupt posted */703u32 heap_base; /* offset form beginning of ram */704u32 heap_size; /* space available for queues */705u32 hlogger; /* non zero for host logging */706u32 heartbeat; /* cp heartbeat */707u32 fw_release; /* firmware version */708u32 mon960_release; /* i960 monitor version */709u32 tq_plen; /* transmit throughput measurements */710/* make sure the init block remains on a quad word boundary */711struct init_block init; /* one time cmd, not in cmd queue */712enum media_type media_type; /* media type id */713u32 oc3_revision; /* OC-3 revision number */714} cp_queues_t;715716717/* boot status */718719typedef enum boot_status {720BSTAT_COLD_START = (u32) 0xc01dc01d, /* cold start */721BSTAT_SELFTEST_OK = (u32) 0x02201958, /* self-test ok */722BSTAT_SELFTEST_FAIL = (u32) 0xadbadbad, /* self-test failed */723BSTAT_CP_RUNNING = (u32) 0xce11feed, /* cp is running */724BSTAT_MON_TOO_BIG = (u32) 0x10aded00 /* i960 monitor is too big */725} boot_status_t;726727728/* software UART */729730typedef struct soft_uart {731u32 send; /* write register */732u32 recv; /* read register */733} soft_uart_t;734735#define FORE200E_CP_MONITOR_UART_FREE 0x00000000736#define FORE200E_CP_MONITOR_UART_AVAIL 0x01000000737738739/* i960 monitor */740741typedef struct cp_monitor {742struct soft_uart soft_uart; /* software UART */743enum boot_status bstat; /* boot status */744u32 app_base; /* application base offset */745u32 mon_version; /* i960 monitor version */746} cp_monitor_t;747748749/* device state */750751typedef enum fore200e_state {752FORE200E_STATE_BLANK, /* initial state */753FORE200E_STATE_REGISTER, /* device registered */754FORE200E_STATE_CONFIGURE, /* bus interface configured */755FORE200E_STATE_MAP, /* board space mapped in host memory */756FORE200E_STATE_RESET, /* board resetted */757FORE200E_STATE_START_FW, /* firmware started */758FORE200E_STATE_INITIALIZE, /* initialize command successful */759FORE200E_STATE_INIT_CMDQ, /* command queue initialized */760FORE200E_STATE_INIT_TXQ, /* transmit queue initialized */761FORE200E_STATE_INIT_RXQ, /* receive queue initialized */762FORE200E_STATE_INIT_BSQ, /* buffer supply queue initialized */763FORE200E_STATE_ALLOC_BUF, /* receive buffers allocated */764FORE200E_STATE_IRQ, /* host interrupt requested */765FORE200E_STATE_COMPLETE /* initialization completed */766} fore200e_state;767768769/* PCA-200E registers */770771typedef struct fore200e_pca_regs {772volatile u32 __iomem * hcr; /* address of host control register */773volatile u32 __iomem * imr; /* address of host interrupt mask register */774volatile u32 __iomem * psr; /* address of PCI specific register */775} fore200e_pca_regs_t;776777778/* SBA-200E registers */779780typedef struct fore200e_sba_regs {781u32 __iomem *hcr; /* address of host control register */782u32 __iomem *bsr; /* address of burst transfer size register */783u32 __iomem *isr; /* address of interrupt level selection register */784} fore200e_sba_regs_t;785786787/* model-specific registers */788789typedef union fore200e_regs {790struct fore200e_pca_regs pca; /* PCA-200E registers */791struct fore200e_sba_regs sba; /* SBA-200E registers */792} fore200e_regs;793794795struct fore200e;796797/* bus-dependent data */798799typedef struct fore200e_bus {800char* model_name; /* board model name */801char* proc_name; /* board name under /proc/atm */802int descr_alignment; /* tpd/rpd/rbd DMA alignment requirement */803int buffer_alignment; /* rx buffers DMA alignment requirement */804int status_alignment; /* status words DMA alignment requirement */805u32 (*read)(volatile u32 __iomem *);806void (*write)(u32, volatile u32 __iomem *);807int (*configure)(struct fore200e*);808int (*map)(struct fore200e*);809void (*reset)(struct fore200e*);810int (*prom_read)(struct fore200e*, struct prom_data*);811void (*unmap)(struct fore200e*);812void (*irq_enable)(struct fore200e*);813int (*irq_check)(struct fore200e*);814void (*irq_ack)(struct fore200e*);815int (*proc_read)(struct fore200e*, char*);816} fore200e_bus_t;817818/* vc mapping */819820typedef struct fore200e_vc_map {821struct atm_vcc* vcc; /* vcc entry */822unsigned long incarn; /* vcc incarnation number */823} fore200e_vc_map_t;824825#define FORE200E_VC_MAP(fore200e, vpi, vci) \826(& (fore200e)->vc_map[ ((vpi) << FORE200E_VCI_BITS) | (vci) ])827828829/* per-device data */830831typedef struct fore200e {832const struct fore200e_bus* bus; /* bus-dependent code and data */833union fore200e_regs regs; /* bus-dependent registers */834struct atm_dev* atm_dev; /* ATM device */835836enum fore200e_state state; /* device state */837838char name[16]; /* device name */839struct device *dev;840int irq; /* irq number */841unsigned long phys_base; /* physical base address */842void __iomem * virt_base; /* virtual base address */843844unsigned char esi[ ESI_LEN ]; /* end system identifier */845846struct cp_monitor __iomem * cp_monitor; /* i960 monitor address */847struct cp_queues __iomem * cp_queues; /* cp resident queues */848struct host_cmdq host_cmdq; /* host resident cmd queue */849struct host_txq host_txq; /* host resident tx queue */850struct host_rxq host_rxq; /* host resident rx queue */851/* host resident buffer supply queues */852struct host_bsq host_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ];853854u32 available_cell_rate; /* remaining pseudo-CBR bw on link */855856int loop_mode; /* S/UNI loopback mode */857858struct stats* stats; /* last snapshot of the stats */859860struct mutex rate_mtx; /* protects rate reservation ops */861spinlock_t q_lock; /* protects queue ops */862#ifdef FORE200E_USE_TASKLET863struct tasklet_struct tx_tasklet; /* performs tx interrupt work */864struct tasklet_struct rx_tasklet; /* performs rx interrupt work */865#endif866unsigned long tx_sat; /* tx queue saturation count */867868unsigned long incarn_count;869struct fore200e_vc_map vc_map[ NBR_CONNECT ]; /* vc mapping */870} fore200e_t;871872873/* per-vcc data */874875typedef struct fore200e_vcc {876enum buffer_scheme scheme; /* rx buffer scheme */877struct tpd_rate rate; /* tx rate control data */878int rx_min_pdu; /* size of smallest PDU received */879int rx_max_pdu; /* size of largest PDU received */880int tx_min_pdu; /* size of smallest PDU transmitted */881int tx_max_pdu; /* size of largest PDU transmitted */882unsigned long tx_pdu; /* nbr of tx pdus */883unsigned long rx_pdu; /* nbr of rx pdus */884} fore200e_vcc_t;885886887888/* 200E-series common memory layout */889890#define FORE200E_CP_MONITOR_OFFSET 0x00000400 /* i960 monitor interface */891#define FORE200E_CP_QUEUES_OFFSET 0x00004d40 /* cp resident queues */892893894/* PCA-200E memory layout */895896#define PCA200E_IOSPACE_LENGTH 0x00200000897898#define PCA200E_HCR_OFFSET 0x00100000 /* board control register */899#define PCA200E_IMR_OFFSET 0x00100004 /* host IRQ mask register */900#define PCA200E_PSR_OFFSET 0x00100008 /* PCI specific register */901902903/* PCA-200E host control register */904905#define PCA200E_HCR_RESET (1<<0) /* read / write */906#define PCA200E_HCR_HOLD_LOCK (1<<1) /* read / write */907#define PCA200E_HCR_I960FAIL (1<<2) /* read */908#define PCA200E_HCR_INTRB (1<<2) /* write */909#define PCA200E_HCR_HOLD_ACK (1<<3) /* read */910#define PCA200E_HCR_INTRA (1<<3) /* write */911#define PCA200E_HCR_OUTFULL (1<<4) /* read */912#define PCA200E_HCR_CLRINTR (1<<4) /* write */913#define PCA200E_HCR_ESPHOLD (1<<5) /* read */914#define PCA200E_HCR_INFULL (1<<6) /* read */915#define PCA200E_HCR_TESTMODE (1<<7) /* read */916917918/* PCA-200E PCI bus interface regs (offsets in PCI config space) */919920#define PCA200E_PCI_LATENCY 0x40 /* maximum slave latenty */921#define PCA200E_PCI_MASTER_CTRL 0x41 /* master control */922#define PCA200E_PCI_THRESHOLD 0x42 /* burst / continuous req threshold */923924/* PBI master control register */925926#define PCA200E_CTRL_DIS_CACHE_RD (1<<0) /* disable cache-line reads */927#define PCA200E_CTRL_DIS_WRT_INVAL (1<<1) /* disable writes and invalidates */928#define PCA200E_CTRL_2_CACHE_WRT_INVAL (1<<2) /* require 2 cache-lines for writes and invalidates */929#define PCA200E_CTRL_IGN_LAT_TIMER (1<<3) /* ignore the latency timer */930#define PCA200E_CTRL_ENA_CONT_REQ_MODE (1<<4) /* enable continuous request mode */931#define PCA200E_CTRL_LARGE_PCI_BURSTS (1<<5) /* force large PCI bus bursts */932#define PCA200E_CTRL_CONVERT_ENDIAN (1<<6) /* convert endianess of slave RAM accesses */933934935936#define SBA200E_PROM_NAME "FORE,sba-200e" /* device name in openprom tree */937938939/* size of SBA-200E registers */940941#define SBA200E_HCR_LENGTH 4942#define SBA200E_BSR_LENGTH 4943#define SBA200E_ISR_LENGTH 4944#define SBA200E_RAM_LENGTH 0x40000945946947/* SBA-200E SBUS burst transfer size register */948949#define SBA200E_BSR_BURST4 0x04950#define SBA200E_BSR_BURST8 0x08951#define SBA200E_BSR_BURST16 0x10952953954/* SBA-200E host control register */955956#define SBA200E_HCR_RESET (1<<0) /* read / write (sticky) */957#define SBA200E_HCR_HOLD_LOCK (1<<1) /* read / write (sticky) */958#define SBA200E_HCR_I960FAIL (1<<2) /* read */959#define SBA200E_HCR_I960SETINTR (1<<2) /* write */960#define SBA200E_HCR_OUTFULL (1<<3) /* read */961#define SBA200E_HCR_INTR_CLR (1<<3) /* write */962#define SBA200E_HCR_INTR_ENA (1<<4) /* read / write (sticky) */963#define SBA200E_HCR_ESPHOLD (1<<5) /* read */964#define SBA200E_HCR_INFULL (1<<6) /* read */965#define SBA200E_HCR_TESTMODE (1<<7) /* read */966#define SBA200E_HCR_INTR_REQ (1<<8) /* read */967968#define SBA200E_HCR_STICKY (SBA200E_HCR_RESET | SBA200E_HCR_HOLD_LOCK | SBA200E_HCR_INTR_ENA)969970971#endif /* __KERNEL__ */972#endif /* _FORE200E_H */973974975