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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /******************************************************************************
  2.  *
  3.  * (C)Copyright 1998,1999 SysKonnect,
  4.  * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * The information in this file is provided "AS IS" without warranty.
  12.  *
  13.  ******************************************************************************/
  14. /*
  15.  * AMD Fplus in tag mode data structs
  16.  * defs for fplustm.c
  17.  */
  18. #ifndef _FPLUS_
  19. #define _FPLUS_
  20. #ifndef HW_PTR
  21. #ifdef MEM_MAPPED_IO
  22. #define HW_PTR u_long
  23. #else
  24. #define HW_PTR u_short
  25. #endif
  26. #endif
  27. /*
  28.  * fplus error statistic structure
  29.  */
  30. struct err_st {
  31. u_long err_valid ; /* memory status valid */
  32. u_long err_abort ; /* memory status receive abort */
  33. u_long err_e_indicator ; /* error indicator */
  34. u_long err_crc ; /* error detected (CRC or length) */
  35. u_long err_llc_frame ; /* LLC frame */
  36. u_long err_mac_frame ; /* MAC frame */
  37. u_long err_smt_frame ; /* SMT frame */
  38. u_long err_imp_frame ; /* implementer frame */
  39. u_long err_no_buf ; /* no buffer available */
  40. u_long err_too_long ; /* longer than max. buffer */
  41. u_long err_bec_stat ; /* beacon state entered */
  42. u_long err_clm_stat ; /* claim state entered */
  43. u_long err_sifg_det ; /* short interframe gap detect */
  44. u_long err_phinv ; /* PHY invalid */
  45. u_long err_tkiss ; /* token issued */
  46. u_long err_tkerr ; /* token error */
  47. } ;
  48. #define SK_XD_ALIGN     (size_t) 32
  49. /*
  50.  * Transmit Descriptor struct
  51.  */
  52. struct s_dummy_txd {
  53.         u_int txd_tbctrl ;              /* transmit buffer control */
  54.         u_int txd_txdscr ;              /* transmit frame status word */
  55.         u_int txd_tbadr ;               /* physical tx buffer address */
  56.         u_int txd_ntdadr ;              /* physical pointer to the next TxD */
  57. #ifdef  ENA_64BIT_SUP
  58.         u_int txd_tbadr_hi ;            /* physical tx buffer addr(high dword)*/
  59. #endif 
  60.         caddr_t txd_virt ;              /* virtual pointer to the data frag */
  61.                                         /* virt pointer to the next TxD */
  62.         struct s_smt_fp_txd volatile far *txd_next ;
  63.         struct s_txd_os txd_os ;        /* OS - specific struct */ 
  64. /* No padding here! */
  65. } ;
  66. #define SK_DUMMY_TXD sizeof(struct s_dummy_txd)
  67. #define SK_TXD_PAD (((SK_DUMMY_TXD+SK_XD_ALIGN-1) 
  68. & ~(SK_XD_ALIGN-1))-SK_DUMMY_TXD)
  69. struct s_smt_fp_txd {
  70. u_int txd_tbctrl ; /* transmit buffer control */
  71. u_int txd_txdscr ; /* transmit frame status word */
  72. u_int txd_tbadr ; /* physical tx buffer address */
  73. u_int txd_ntdadr ; /* physical pointer to the next TxD */
  74. #ifdef ENA_64BIT_SUP
  75. u_int txd_tbadr_hi ; /* physical tx buffer addr(high dword)*/
  76. #endif
  77. caddr_t txd_virt ; /* virtual pointer to the data frag */
  78. /* virt pointer to the next TxD */
  79. struct s_smt_fp_txd volatile far *txd_next ;
  80. struct s_txd_os txd_os ; /* OS - specific struct */
  81. char padding[SK_TXD_PAD]; /* padding */
  82. } ;
  83. /*
  84.  * Receive Descriptor struct
  85.  */
  86. struct s_dummy_rxd {
  87.         u_int rxd_rbctrl ;              /* receive buffer control */
  88.         u_int rxd_rfsw ;                /* receive frame status word */
  89.         u_int rxd_rbadr ;               /* physical rx buffer address */
  90.         u_int rxd_nrdadr ;              /* physical pointer to the next RxD */
  91. #ifdef  ENA_64BIT_SUP
  92.         u_int rxd_rbadr_hi ;            /* physical tx buffer addr(high dword)*/
  93. #endif
  94.         caddr_t rxd_virt ;              /* virtual pointer to the data frag */
  95.                                         /* virt pointer to the next RxD */
  96.         struct s_smt_fp_rxd volatile far *rxd_next ;
  97.         struct s_rxd_os rxd_os ;        /* OS - specific struct */
  98.         /* No padding here! */
  99. } ;
  100. #define SK_DUMMY_RXD sizeof(struct s_dummy_rxd)
  101. #define SK_RXD_PAD (((SK_DUMMY_RXD+SK_XD_ALIGN-1) 
  102. & ~(SK_XD_ALIGN-1))-SK_DUMMY_RXD)
  103. struct s_smt_fp_rxd {
  104. u_int rxd_rbctrl ; /* receive buffer control */
  105. u_int rxd_rfsw ; /* receive frame status word */
  106. u_int rxd_rbadr ; /* physical rx buffer address */
  107. u_int rxd_nrdadr ; /* physical pointer to the next RxD */
  108. #ifdef ENA_64BIT_SUP
  109. u_int rxd_rbadr_hi ; /* physical tx buffer addr(high dword)*/
  110. #endif
  111. caddr_t rxd_virt ; /* virtual pointer to the data frag */
  112. /* virt pointer to the next RxD */
  113. struct s_smt_fp_rxd volatile far *rxd_next ;
  114. struct s_rxd_os rxd_os ; /* OS - specific struct */
  115. char padding[SK_RXD_PAD] ;
  116. } ;
  117. /*
  118.  * Descriptor Union Definition
  119.  */
  120. union s_fp_descr {
  121. struct s_smt_fp_txd t ; /* pointer to the TxD */
  122. struct s_smt_fp_rxd r ; /* pointer to the RxD */
  123. } ;
  124. /*
  125.  * TxD Ring Control struct
  126.  */
  127. struct s_smt_tx_queue {
  128. struct s_smt_fp_txd volatile *tx_curr_put ; /* next free TxD */
  129. struct s_smt_fp_txd volatile *tx_prev_put ; /* shadow put pointer */
  130. struct s_smt_fp_txd volatile *tx_curr_get ; /* next TxD to release*/
  131. u_short tx_free ; /* count of free TxD's */
  132. u_short tx_used ; /* count of used TxD's */
  133. HW_PTR tx_bmu_ctl ; /* BMU addr for tx start */
  134. HW_PTR tx_bmu_dsc ; /* BMU addr for curr dsc. */
  135. } ;
  136. /*
  137.  * RxD Ring Control struct
  138.  */
  139. struct s_smt_rx_queue {
  140. struct s_smt_fp_rxd volatile *rx_curr_put ; /* next RxD to queue into */
  141. struct s_smt_fp_rxd volatile *rx_prev_put ; /* shadow put pointer */
  142. struct s_smt_fp_rxd volatile *rx_curr_get ; /* next RxD to fill */
  143. u_short rx_free ; /* count of free RxD's */
  144. u_short rx_used ; /* count of used RxD's */
  145. HW_PTR rx_bmu_ctl ; /* BMU addr for rx start */
  146. HW_PTR rx_bmu_dsc ; /* BMU addr for curr dsc. */
  147. } ;
  148. #define VOID_FRAME_OFF 0x00
  149. #define CLAIM_FRAME_OFF 0x08
  150. #define BEACON_FRAME_OFF 0x10
  151. #define DBEACON_FRAME_OFF 0x18
  152. #define RX_FIFO_OFF 0x21 /* to get a prime number for */
  153. /* the RX_FIFO_SPACE */
  154. #define RBC_MEM_SIZE 0x8000
  155. #define SEND_ASYNC_AS_SYNC 0x1
  156. #define SYNC_TRAFFIC_ON 0x2
  157. /* big FIFO memory */
  158. #define RX_FIFO_SPACE 0x4000 - RX_FIFO_OFF
  159. #define TX_FIFO_SPACE 0x4000
  160. #define TX_SMALL_FIFO 0x0900
  161. #define TX_MEDIUM_FIFO TX_FIFO_SPACE / 2
  162. #define TX_LARGE_FIFO TX_FIFO_SPACE - TX_SMALL_FIFO
  163. #define RX_SMALL_FIFO 0x0900
  164. #define RX_LARGE_FIFO RX_FIFO_SPACE - RX_SMALL_FIFO
  165. struct s_smt_fifo_conf {
  166. u_short rbc_ram_start ; /* FIFO start address */
  167. u_short rbc_ram_end ; /* FIFO size */
  168. u_short rx1_fifo_start ; /* rx queue start address */
  169. u_short rx1_fifo_size ; /* rx queue size */
  170. u_short rx2_fifo_start ; /* rx queue start address */
  171. u_short rx2_fifo_size ; /* rx queue size */
  172. u_short tx_s_start ; /* sync queue start address */
  173. u_short tx_s_size ; /* sync queue size */
  174. u_short tx_a0_start ; /* async queue A0 start address */
  175. u_short tx_a0_size ; /* async queue A0 size */
  176. u_short fifo_config_mode ; /* FIFO configuration mode */
  177. } ;
  178. #define FM_ADDRX (FM_ADDET|FM_EXGPA0|FM_EXGPA1)
  179. struct s_smt_fp {
  180. u_short mdr2init ; /* mode register 2 init value */
  181. u_short mdr3init ; /* mode register 3 init value */
  182. u_short frselreg_init ; /* frame selection register init val */
  183. u_short rx_mode ; /* address mode broad/multi/promisc */
  184. u_short nsa_mode ;
  185. u_short rx_prom ;
  186. u_short exgpa ;
  187. struct err_st err_stats ; /* error statistics */
  188. /*
  189.  * MAC buffers
  190.  */
  191. struct fddi_mac_sf { /* special frame build buffer */
  192. u_char mac_fc ;
  193. struct fddi_addr mac_dest ;
  194. struct fddi_addr mac_source ;
  195. u_char mac_info[0x20] ;
  196. } mac_sfb ;
  197. /*
  198.  * queues
  199.  */
  200. #define QUEUE_S 0
  201. #define QUEUE_A0 1
  202. #define QUEUE_R1 0
  203. #define QUEUE_R2 1
  204. #define USED_QUEUES 2
  205. /*
  206.  * queue pointers; points to the queue dependent variables
  207.  */
  208. struct s_smt_tx_queue *tx[USED_QUEUES] ;
  209. struct s_smt_rx_queue *rx[USED_QUEUES] ;
  210. /*
  211.  * queue dependent variables
  212.  */
  213. struct s_smt_tx_queue tx_q[USED_QUEUES] ;
  214. struct s_smt_rx_queue rx_q[USED_QUEUES] ;
  215. /*
  216.  * FIFO configuration struct
  217.  */
  218. struct s_smt_fifo_conf fifo ;
  219. /* last formac status */
  220. u_short  s2u ;
  221. u_short  s2l ;
  222. /* calculated FORMAC+ reg.addr. */
  223. HW_PTR fm_st1u ;
  224. HW_PTR fm_st1l ;
  225. HW_PTR fm_st2u ;
  226. HW_PTR fm_st2l ;
  227. HW_PTR fm_st3u ;
  228. HW_PTR fm_st3l ;
  229. /*
  230.  * multicast table
  231.  */
  232. #define FPMAX_MULTICAST 32 
  233. #define SMT_MAX_MULTI 4
  234. struct {
  235. struct s_fpmc {
  236. struct fddi_addr a ; /* mc address */
  237. u_char n ; /* usage counter */
  238. u_char perm ; /* flag: permanent */
  239. } table[FPMAX_MULTICAST] ;
  240. } mc ;
  241. struct fddi_addr group_addr ;
  242. u_long func_addr ; /* functional address */
  243. int smt_slots_used ; /* count of table entries for the SMT */
  244. int os_slots_used ; /* count of table entries */ 
  245. /* used by the os-specific module */
  246. } ;
  247. /*
  248.  * modes for mac_set_rx_mode()
  249.  */
  250. #define RX_ENABLE_ALLMULTI 1 /* enable all multicasts */
  251. #define RX_DISABLE_ALLMULTI 2 /* disable "enable all multicasts" */
  252. #define RX_ENABLE_PROMISC 3 /* enable promiscous */
  253. #define RX_DISABLE_PROMISC 4 /* disable promiscous */
  254. #define RX_ENABLE_NSA 5 /* enable reception of NSA frames */
  255. #define RX_DISABLE_NSA 6 /* disable reception of NSA frames */
  256. /*
  257.  * support for byte reversal in AIX
  258.  * (descriptors and pointers must be byte reversed in memory
  259.  *  CPU is big endian; M-Channel is little endian)
  260.  */
  261. #ifdef AIX
  262. #define MDR_REV
  263. #define AIX_REVERSE(x) ((((x)<<24L)&0xff000000L) +
  264.  (((x)<< 8L)&0x00ff0000L) +
  265.  (((x)>> 8L)&0x0000ff00L) +
  266.  (((x)>>24L)&0x000000ffL))
  267. #else
  268. #ifndef AIX_REVERSE
  269. #define AIX_REVERSE(x) (x)
  270. #endif
  271. #endif
  272. #ifdef MDR_REV
  273. #define MDR_REVERSE(x) ((((x)<<24L)&0xff000000L) +
  274.  (((x)<< 8L)&0x00ff0000L) +
  275.  (((x)>> 8L)&0x0000ff00L) +
  276.  (((x)>>24L)&0x000000ffL))
  277. #else
  278. #ifndef MDR_REVERSE
  279. #define MDR_REVERSE(x) (x)
  280. #endif
  281. #endif
  282. #endif