firestream.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:15k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* drivers/atm/firestream.h - FireStream 155 (MB86697) and
  2.  *                            FireStream  50 (MB86695) device driver 
  3.  */
  4.  
  5. /* Written & (C) 2000 by R.E.Wolff@BitWizard.nl 
  6.  * Copied snippets from zatm.c by Werner Almesberger, EPFL LRC/ICA 
  7.  * and ambassador.c Copyright (C) 1995-1999  Madge Networks Ltd 
  8.  */
  9. /*
  10.   This program is free software; you can redistribute it and/or modify
  11.   it under the terms of the GNU General Public License as published by
  12.   the Free Software Foundation; either version 2 of the License, or
  13.   (at your option) any later version.
  14.   This program is distributed in the hope that it will be useful,
  15.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.   GNU General Public License for more details.
  18.   You should have received a copy of the GNU General Public License
  19.   along with this program; if not, write to the Free Software
  20.   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.   The GNU GPL is contained in /usr/doc/copyright/GPL on a Debian
  22.   system and in the file COPYING in the Linux kernel source.
  23. */
  24. /***********************************************************************
  25.  *                  first the defines for the chip.                    *
  26.  ***********************************************************************/
  27. /********************* General chip parameters. ************************/
  28. #define FS_NR_FREE_POOLS   8
  29. #define FS_NR_RX_QUEUES    4
  30. /********************* queues and queue access macros ******************/
  31. /* A queue entry. */
  32. struct FS_QENTRY {
  33. u32 cmd;
  34. u32 p0, p1, p2;
  35. };
  36. /* A freepool entry. */
  37. struct FS_BPENTRY {
  38. u32 flags;
  39. u32 next;
  40. u32 bsa;
  41. u32 aal_bufsize;
  42. /* The hardware doesn't look at this, but we need the SKB somewhere... */
  43. struct sk_buff *skb;
  44. struct freepool *fp;
  45. struct fs_dev *dev;
  46. };
  47. #define STATUS_CODE(qe)  ((qe->cmd >> 22) & 0x3f)
  48. /* OFFSETS against the base of a QUEUE... */
  49. #define QSA     0x00
  50. #define QEA     0x04
  51. #define QRP     0x08
  52. #define QWP     0x0c
  53. #define QCNF    0x10   /* Only for Release queues! */
  54. /* Not for the transmit pending queue. */
  55. /* OFFSETS against the base of a FREE POOL... */
  56. #define FPCNF   0x00
  57. #define FPSA    0x04
  58. #define FPEA    0x08
  59. #define FPCNT   0x0c
  60. #define FPCTU   0x10
  61. #define Q_SA(b)     (b + QSA )
  62. #define Q_EA(b)     (b + QEA )
  63. #define Q_RP(b)     (b + QRP )
  64. #define Q_WP(b)     (b + QWP )
  65. #define Q_CNF(b)    (b + QCNF)
  66. #define FP_CNF(b)   (b + FPCNF)
  67. #define FP_SA(b)    (b + FPSA)
  68. #define FP_EA(b)    (b + FPEA)
  69. #define FP_CNT(b)   (b + FPCNT)
  70. #define FP_CTU(b)   (b + FPCTU)
  71. /* bits in a queue register. */
  72. #define Q_FULL      0x1
  73. #define Q_EMPTY     0x2
  74. #define Q_INCWRAP   0x4
  75. #define Q_ADDR_MASK 0xfffffff0
  76. /* bits in a FreePool config register */
  77. #define RBFP_RBS    (0x1 << 16)
  78. #define RBFP_RBSVAL (0x1 << 15)
  79. #define RBFP_CME    (0x1 << 12)
  80. #define RBFP_DLP    (0x1 << 11)
  81. #define RBFP_BFPWT  (0x1 <<  0)
  82. /* FireStream commands. */
  83. #define QE_CMD_NULL             (0x00 << 22)
  84. #define QE_CMD_REG_RD           (0x01 << 22)
  85. #define QE_CMD_REG_RDM          (0x02 << 22)
  86. #define QE_CMD_REG_WR           (0x03 << 22)
  87. #define QE_CMD_REG_WRM          (0x04 << 22)
  88. #define QE_CMD_CONFIG_TX        (0x05 << 22)
  89. #define QE_CMD_CONFIG_RX        (0x06 << 22)
  90. #define QE_CMD_PRP_RD           (0x07 << 22)
  91. #define QE_CMD_PRP_RDM          (0x2a << 22)
  92. #define QE_CMD_PRP_WR           (0x09 << 22)
  93. #define QE_CMD_PRP_WRM          (0x2b << 22)
  94. #define QE_CMD_RX_EN            (0x0a << 22)
  95. #define QE_CMD_RX_PURGE         (0x0b << 22)
  96. #define QE_CMD_RX_PURGE_INH     (0x0c << 22)
  97. #define QE_CMD_TX_EN            (0x0d << 22)
  98. #define QE_CMD_TX_PURGE         (0x0e << 22)
  99. #define QE_CMD_TX_PURGE_INH     (0x0f << 22)
  100. #define QE_CMD_RST_CG           (0x10 << 22)
  101. #define QE_CMD_SET_CG           (0x11 << 22)
  102. #define QE_CMD_RST_CLP          (0x12 << 22)
  103. #define QE_CMD_SET_CLP          (0x13 << 22)
  104. #define QE_CMD_OVERRIDE         (0x14 << 22)
  105. #define QE_CMD_ADD_BFP          (0x15 << 22)
  106. #define QE_CMD_DUMP_TX          (0x16 << 22)
  107. #define QE_CMD_DUMP_RX          (0x17 << 22)
  108. #define QE_CMD_LRAM_RD          (0x18 << 22)
  109. #define QE_CMD_LRAM_RDM         (0x28 << 22)
  110. #define QE_CMD_LRAM_WR          (0x19 << 22)
  111. #define QE_CMD_LRAM_WRM         (0x29 << 22)
  112. #define QE_CMD_LRAM_BSET        (0x1a << 22)
  113. #define QE_CMD_LRAM_BCLR        (0x1b << 22)
  114. #define QE_CMD_CONFIG_SEGM      (0x1c << 22)
  115. #define QE_CMD_READ_SEGM        (0x1d << 22)
  116. #define QE_CMD_CONFIG_ROUT      (0x1e << 22)
  117. #define QE_CMD_READ_ROUT        (0x1f << 22)
  118. #define QE_CMD_CONFIG_TM        (0x20 << 22)
  119. #define QE_CMD_READ_TM          (0x21 << 22)
  120. #define QE_CMD_CONFIG_TXBM      (0x22 << 22)
  121. #define QE_CMD_READ_TXBM        (0x23 << 22)
  122. #define QE_CMD_CONFIG_RXBM      (0x24 << 22)
  123. #define QE_CMD_READ_RXBM        (0x25 << 22)
  124. #define QE_CMD_CONFIG_REAS      (0x26 << 22)
  125. #define QE_CMD_READ_REAS        (0x27 << 22)
  126. #define QE_TRANSMIT_DE          (0x0 << 30)
  127. #define QE_CMD_LINKED           (0x1 << 30)
  128. #define QE_CMD_IMM              (0x2 << 30)
  129. #define QE_CMD_IMM_INQ          (0x3 << 30)
  130. #define TD_EPI                  (0x1 << 27)
  131. #define TD_COMMAND              (0x1 << 28)
  132. #define TD_DATA                 (0x0 << 29)
  133. #define TD_RM_CELL              (0x1 << 29)
  134. #define TD_OAM_CELL             (0x2 << 29)
  135. #define TD_OAM_CELL_SEGMENT     (0x3 << 29)
  136. #define TD_BPI                  (0x1 << 20)
  137. #define FP_FLAGS_EPI            (0x1 << 27)
  138. #define TX_PQ(i)  (0x00  + (i) * 0x10)
  139. #define TXB_RQ    (0x20)
  140. #define ST_Q      (0x48)
  141. #define RXB_FP(i) (0x90  + (i) * 0x14)
  142. #define RXB_RQ(i) (0x134 + (i) * 0x14)
  143. #define TXQ_HP 0
  144. #define TXQ_LP 1
  145. /* Phew. You don't want to know how many revisions these simple queue
  146.  * address macros went through before I got them nice and compact as
  147.  * they are now. -- REW
  148.  */
  149. /* And now for something completely different: 
  150.  * The rest of the registers... */
  151. #define CMDR0 0x34
  152. #define CMDR1 0x38
  153. #define CMDR2 0x3c
  154. #define CMDR3 0x40
  155. #define SARMODE0     0x5c
  156. #define SARMODE0_TXVCS_0    (0x0 << 0)
  157. #define SARMODE0_TXVCS_1k   (0x1 << 0)
  158. #define SARMODE0_TXVCS_2k   (0x2 << 0)
  159. #define SARMODE0_TXVCS_4k   (0x3 << 0)
  160. #define SARMODE0_TXVCS_8k   (0x4 << 0)
  161. #define SARMODE0_TXVCS_16k  (0x5 << 0)
  162. #define SARMODE0_TXVCS_32k  (0x6 << 0)
  163. #define SARMODE0_TXVCS_64k  (0x7 << 0)
  164. #define SARMODE0_TXVCS_32   (0x8 << 0)
  165. #define SARMODE0_ABRVCS_0   (0x0 << 4)
  166. #define SARMODE0_ABRVCS_512 (0x1 << 4)
  167. #define SARMODE0_ABRVCS_1k  (0x2 << 4)
  168. #define SARMODE0_ABRVCS_2k  (0x3 << 4)
  169. #define SARMODE0_ABRVCS_4k  (0x4 << 4)
  170. #define SARMODE0_ABRVCS_8k  (0x5 << 4)
  171. #define SARMODE0_ABRVCS_16k (0x6 << 4)
  172. #define SARMODE0_ABRVCS_32k (0x7 << 4)
  173. #define SARMODE0_ABRVCS_32  (0x9 << 4) /* The others are "8", this one really has to 
  174.   be 9. Tell me you don't believe me. -- REW */
  175. #define SARMODE0_RXVCS_0    (0x0 << 8)
  176. #define SARMODE0_RXVCS_1k   (0x1 << 8)
  177. #define SARMODE0_RXVCS_2k   (0x2 << 8)
  178. #define SARMODE0_RXVCS_4k   (0x3 << 8)
  179. #define SARMODE0_RXVCS_8k   (0x4 << 8)
  180. #define SARMODE0_RXVCS_16k  (0x5 << 8)
  181. #define SARMODE0_RXVCS_32k  (0x6 << 8)
  182. #define SARMODE0_RXVCS_64k  (0x7 << 8)
  183. #define SARMODE0_RXVCS_32   (0x8 << 8) 
  184. #define SARMODE0_CALSUP_1  (0x0 << 12)
  185. #define SARMODE0_CALSUP_2  (0x1 << 12)
  186. #define SARMODE0_CALSUP_3  (0x2 << 12)
  187. #define SARMODE0_CALSUP_4  (0x3 << 12)
  188. #define SARMODE0_PRPWT_FS50_0  (0x0 << 14)
  189. #define SARMODE0_PRPWT_FS50_2  (0x1 << 14)
  190. #define SARMODE0_PRPWT_FS50_5  (0x2 << 14)
  191. #define SARMODE0_PRPWT_FS50_11 (0x3 << 14)
  192. #define SARMODE0_PRPWT_FS155_0 (0x0 << 14)
  193. #define SARMODE0_PRPWT_FS155_1 (0x1 << 14)
  194. #define SARMODE0_PRPWT_FS155_2 (0x2 << 14)
  195. #define SARMODE0_PRPWT_FS155_3 (0x3 << 14)
  196. #define SARMODE0_SRTS0     (0x1 << 23)
  197. #define SARMODE0_SRTS1     (0x1 << 24)
  198. #define SARMODE0_RUN       (0x1 << 25)
  199. #define SARMODE0_UNLOCK    (0x1 << 26)
  200. #define SARMODE0_CWRE      (0x1 << 27)
  201. #define SARMODE0_INTMODE_READCLEAR          (0x0 << 28)
  202. #define SARMODE0_INTMODE_READNOCLEAR        (0x1 << 28)
  203. #define SARMODE0_INTMODE_READNOCLEARINHIBIT (0x2 << 28)
  204. #define SARMODE0_INTMODE_READCLEARINHIBIT   (0x3 << 28)  /* Tell me you don't believe me. */
  205. #define SARMODE0_GINT      (0x1 << 30)
  206. #define SARMODE0_SHADEN    (0x1 << 31)
  207. #define SARMODE1     0x60
  208. #define SARMODE1_TRTL_SHIFT 0   /* Program to 0 */
  209. #define SARMODE1_RRTL_SHIFT 4   /* Program to 0 */
  210. #define SARMODE1_TAGM       (0x1 <<  8)  /* Program to 0 */
  211. #define SARMODE1_HECM0      (0x1 <<  9)
  212. #define SARMODE1_HECM1      (0x1 << 10)
  213. #define SARMODE1_HECM2      (0x1 << 11)
  214. #define SARMODE1_GFCE       (0x1 << 14)
  215. #define SARMODE1_GFCR       (0x1 << 15)
  216. #define SARMODE1_PMS        (0x1 << 18)
  217. #define SARMODE1_GPRI       (0x1 << 19)
  218. #define SARMODE1_GPAS       (0x1 << 20)
  219. #define SARMODE1_GVAS       (0x1 << 21)
  220. #define SARMODE1_GNAM       (0x1 << 22)
  221. #define SARMODE1_GPLEN      (0x1 << 23)
  222. #define SARMODE1_DUMPE      (0x1 << 24)
  223. #define SARMODE1_OAMCRC     (0x1 << 25)
  224. #define SARMODE1_DCOAM      (0x1 << 26)
  225. #define SARMODE1_DCRM       (0x1 << 27)
  226. #define SARMODE1_TSTLP      (0x1 << 28)
  227. #define SARMODE1_DEFHEC     (0x1 << 29)
  228. #define ISR      0x64
  229. #define IUSR     0x68
  230. #define IMR      0x6c
  231. #define ISR_LPCO          (0x1 <<  0)
  232. #define ISR_DPCO          (0x1 <<  1)
  233. #define ISR_RBRQ0_W       (0x1 <<  2)
  234. #define ISR_RBRQ1_W       (0x1 <<  3)
  235. #define ISR_RBRQ2_W       (0x1 <<  4)
  236. #define ISR_RBRQ3_W       (0x1 <<  5)
  237. #define ISR_RBRQ0_NF      (0x1 <<  6)
  238. #define ISR_RBRQ1_NF      (0x1 <<  7)
  239. #define ISR_RBRQ2_NF      (0x1 <<  8)
  240. #define ISR_RBRQ3_NF      (0x1 <<  9)
  241. #define ISR_BFP_SC        (0x1 << 10)
  242. #define ISR_INIT          (0x1 << 11)
  243. #define ISR_INIT_ERR      (0x1 << 12) /* Documented as "reserved" */
  244. #define ISR_USCEO         (0x1 << 13)
  245. #define ISR_UPEC0         (0x1 << 14)
  246. #define ISR_VPFCO         (0x1 << 15)
  247. #define ISR_CRCCO         (0x1 << 16)
  248. #define ISR_HECO          (0x1 << 17)
  249. #define ISR_TBRQ_W        (0x1 << 18)
  250. #define ISR_TBRQ_NF       (0x1 << 19)
  251. #define ISR_CTPQ_E        (0x1 << 20)
  252. #define ISR_GFC_C0        (0x1 << 21)
  253. #define ISR_PCI_FTL       (0x1 << 22)
  254. #define ISR_CSQ_W         (0x1 << 23)
  255. #define ISR_CSQ_NF        (0x1 << 24)
  256. #define ISR_EXT_INT       (0x1 << 25)
  257. #define ISR_RXDMA_S       (0x1 << 26)
  258. #define TMCONF 0x78
  259. /* Bits? */
  260. #define CALPRESCALE 0x7c
  261. /* Bits? */
  262. #define CELLOSCONF 0x84
  263. #define CELLOSCONF_COTS   (0x1 << 28)
  264. #define CELLOSCONF_CEN    (0x1 << 27)
  265. #define CELLOSCONF_SC8    (0x3 << 24)
  266. #define CELLOSCONF_SC4    (0x2 << 24)
  267. #define CELLOSCONF_SC2    (0x1 << 24)
  268. #define CELLOSCONF_SC1    (0x0 << 24)
  269. #define CELLOSCONF_COBS   (0x1 << 16)
  270. #define CELLOSCONF_COPK   (0x1 <<  8)
  271. #define CELLOSCONF_COST   (0x1 <<  0)
  272. /* Bits? */
  273. #define RAS0 0x1bc
  274. #define RAS0_DCD_XHLT (0x1 << 31)
  275. #define RAS0_VPSEL    (0x1 << 16)
  276. #define RAS0_VCSEL    (0x1 <<  0)
  277. #define RAS1 0x1c0
  278. #define RAS1_UTREG    (0x1 << 5)
  279. #define DMAMR 0x1cc
  280. #define DMAMR_TX_MODE_FULL (0x0 << 0)
  281. #define DMAMR_TX_MODE_PART (0x1 << 0)
  282. #define DMAMR_TX_MODE_NONE (0x2 << 0) /* And 3 */
  283. #define RAS2 0x280
  284. #define RAS2_NNI  (0x1 << 0)
  285. #define RAS2_USEL (0x1 << 1)
  286. #define RAS2_UBS  (0x1 << 2)
  287. struct fs_transmit_config {
  288. u32 flags;
  289. u32 atm_hdr;
  290. u32 TMC[4];
  291. u32 spec;
  292. u32 rtag[3];
  293. };
  294. #define TC_FLAGS_AAL5      (0x0 << 29)
  295. #define TC_FLAGS_TRANSPARENT_PAYLOAD (0x1 << 29)
  296. #define TC_FLAGS_TRANSPARENT_CELL    (0x2 << 29)
  297. #define TC_FLAGS_STREAMING (0x1 << 28)
  298. #define TC_FLAGS_PACKET    (0x0) 
  299. #define TC_FLAGS_TYPE_ABR  (0x0 << 22)
  300. #define TC_FLAGS_TYPE_CBR  (0x1 << 22)
  301. #define TC_FLAGS_TYPE_VBR  (0x2 << 22)
  302. #define TC_FLAGS_TYPE_UBR  (0x3 << 22)
  303. #define TC_FLAGS_CAL0      (0x0 << 20)
  304. #define TC_FLAGS_CAL1      (0x1 << 20)
  305. #define TC_FLAGS_CAL2      (0x2 << 20)
  306. #define TC_FLAGS_CAL3      (0x3 << 20)
  307. #define RC_FLAGS_NAM        (0x1 << 13)
  308. #define RC_FLAGS_RXBM_PSB   (0x0 << 14)
  309. #define RC_FLAGS_RXBM_CIF   (0x1 << 14)
  310. #define RC_FLAGS_RXBM_PMB   (0x2 << 14)
  311. #define RC_FLAGS_RXBM_STR   (0x4 << 14)
  312. #define RC_FLAGS_RXBM_SAF   (0x6 << 14)
  313. #define RC_FLAGS_RXBM_POS   (0x6 << 14)
  314. #define RC_FLAGS_BFPS       (0x1 << 17)
  315. #define RC_FLAGS_BFPS_BFP   (0x1 << 17)
  316. #define RC_FLAGS_BFPS_BFP0  (0x0 << 17)
  317. #define RC_FLAGS_BFPS_BFP1  (0x1 << 17)
  318. #define RC_FLAGS_BFPS_BFP2  (0x2 << 17)
  319. #define RC_FLAGS_BFPS_BFP3  (0x3 << 17)
  320. #define RC_FLAGS_BFPS_BFP4  (0x4 << 17)
  321. #define RC_FLAGS_BFPS_BFP5  (0x5 << 17)
  322. #define RC_FLAGS_BFPS_BFP6  (0x6 << 17)
  323. #define RC_FLAGS_BFPS_BFP7  (0x7 << 17)
  324. #define RC_FLAGS_BFPS_BFP01 (0x8 << 17)
  325. #define RC_FLAGS_BFPS_BFP23 (0x9 << 17)
  326. #define RC_FLAGS_BFPS_BFP45 (0xa << 17)
  327. #define RC_FLAGS_BFPS_BFP67 (0xb << 17)
  328. #define RC_FLAGS_BFPS_BFP07 (0xc << 17)
  329. #define RC_FLAGS_BFPS_BFP27 (0xd << 17)
  330. #define RC_FLAGS_BFPS_BFP47 (0xe << 17)
  331. #define RC_FLAGS_BFPS       (0x1 << 17)
  332. #define RC_FLAGS_BFPP       (0x1 << 21)
  333. #define RC_FLAGS_TEVC       (0x1 << 22)
  334. #define RC_FLAGS_TEP        (0x1 << 23)
  335. #define RC_FLAGS_AAL5       (0x0 << 24)
  336. #define RC_FLAGS_TRANSP     (0x1 << 24)
  337. #define RC_FLAGS_TRANSC     (0x2 << 24)
  338. #define RC_FLAGS_ML         (0x1 << 27)
  339. #define RC_FLAGS_TRBRM      (0x1 << 28)
  340. #define RC_FLAGS_PRI        (0x1 << 29)
  341. #define RC_FLAGS_HOAM       (0x1 << 30)
  342. #define RC_FLAGS_CRC10      (0x1 << 31)
  343. #define RAC 0x1c8
  344. #define RAM 0x1c4
  345. /************************************************************************
  346.  *         Then the datastructures that the DRIVER uses.                *
  347.  ************************************************************************/
  348. #define TXQ_NENTRIES  32
  349. #define RXRQ_NENTRIES 1024
  350. struct fs_vcc {
  351. int channo;
  352. wait_queue_head_t close_wait;
  353. struct sk_buff *last_skb;
  354. };
  355. struct queue {
  356. struct FS_QENTRY *sa, *ea;  
  357. int offset;
  358. };
  359. struct freepool {
  360. int offset;
  361. int bufsize;
  362. int nr_buffers;
  363. int n;
  364. };
  365. struct fs_dev {
  366. struct fs_dev *next; /* other FS devices */
  367. int flags;
  368. unsigned char irq; /* IRQ */
  369. struct pci_dev *pci_dev; /* PCI stuff */
  370. struct atm_dev *atm_dev;
  371. struct timer_list timer;
  372. unsigned long hw_base; /* mem base address */
  373. unsigned long base;             /* Mapping of base address */
  374. int channo;
  375. unsigned long channel_mask;
  376. struct queue    hp_txq, lp_txq, tx_relq, st_q;
  377. struct freepool rx_fp[FS_NR_FREE_POOLS];
  378. struct queue    rx_rq[FS_NR_RX_QUEUES];
  379. int nchannels;
  380. struct atm_vcc **atm_vccs;
  381. void *tx_inuse;
  382. int ntxpckts;
  383. };
  384. /* Number of channesl that the FS50 supports. */
  385. #define FS50_CHANNEL_BITS  5
  386. #define FS50_NR_CHANNELS      (1 << FS50_CHANNEL_BITS)
  387.          
  388. #define FS_DEV(atm_dev) ((struct fs_dev *) (atm_dev)->dev_data)
  389. #define FS_VCC(atm_vcc) ((struct fs_vcc *) (atm_vcc)->dev_data)
  390. #define FS_IS50  0x1
  391. #define FS_IS155 0x2
  392. #define IS_FS50(dev)  (dev->flags & FS_IS50)
  393. #define IS_FS155(dev) (dev->flags & FS_IS155)
  394.  
  395. /* Within limits this is user-configurable. */
  396. /* Note: Currently the sum (10 -> 1k channels) is hardcoded in the driver. */
  397. #define FS155_VPI_BITS 4
  398. #define FS155_VCI_BITS 6
  399. #define FS155_CHANNEL_BITS  (FS155_VPI_BITS + FS155_VCI_BITS)
  400. #define FS155_NR_CHANNELS   (1 << FS155_CHANNEL_BITS)