hwmtm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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. #ifndef _HWM_
  15. #define _HWM_
  16. #include "mbuf.h"
  17. /*
  18. * MACRO for DMA synchronization:
  19. * The descriptor 'desc' is flushed for the device 'flag'.
  20. * Devices are the CPU (DDI_DMA_SYNC_FORCPU) and the
  21. * adapter (DDI_DMA_SYNC_FORDEV).
  22. *
  23. * 'desc' Pointer to a Rx or Tx descriptor.
  24. * 'flag' Flag for direction (view for CPU or DEVICE) that
  25. * should be synchronized.
  26. *
  27. * Empty macros and defines are specified here. The real macro
  28. * is os-specific and should be defined in osdef1st.h.
  29. */
  30. #ifndef DRV_BUF_FLUSH
  31. #define DRV_BUF_FLUSH(desc,flag)
  32. #define DDI_DMA_SYNC_FORCPU
  33. #define DDI_DMA_SYNC_FORDEV
  34. #endif
  35. /*
  36. * hardware modul dependent receive modes
  37. */
  38. #define RX_ENABLE_PASS_SMT 21
  39. #define RX_DISABLE_PASS_SMT 22
  40. #define RX_ENABLE_PASS_NSA 23
  41. #define RX_DISABLE_PASS_NSA 24
  42. #define RX_ENABLE_PASS_DB 25
  43. #define RX_DISABLE_PASS_DB 26
  44. #define RX_DISABLE_PASS_ALL 27
  45. #define RX_DISABLE_LLC_PROMISC 28
  46. #define RX_ENABLE_LLC_PROMISC 29
  47. #ifndef DMA_RD
  48. #define DMA_RD 1 /* memory -> hw */
  49. #endif
  50. #ifndef DMA_WR
  51. #define DMA_WR 2 /* hw -> memory */
  52. #endif
  53. #define SMT_BUF 0x80
  54. /*
  55. * bits of the frame status byte
  56. */
  57. #define EN_IRQ_EOF 0x02 /* get IRQ after end of frame transmission */
  58. #define LOC_TX 0x04 /* send frame to the local SMT */
  59. #define LAST_FRAG 0x08 /* last TxD of the frame */
  60. #define FIRST_FRAG 0x10 /* first TxD of the frame */
  61. #define LAN_TX 0x20 /* send frame to network if set */
  62. #define RING_DOWN 0x40 /* error: unable to send, ring down */
  63. #define OUT_OF_TXD 0x80 /* error: not enough TxDs available */
  64. #ifndef NULL
  65. #define NULL 0
  66. #endif
  67. #ifdef LITTLE_ENDIAN
  68. #define HWM_REVERSE(x) (x)
  69. #else
  70. #define HWM_REVERSE(x) ((((x)<<24L)&0xff000000L) + \
  71. (((x)<< 8L)&0x00ff0000L) + \
  72. (((x)>> 8L)&0x0000ff00L) + \
  73. (((x)>>24L)&0x000000ffL))
  74. #endif
  75. #define C_INDIC (1L<<25)
  76. #define A_INDIC (1L<<26)
  77. #define RD_FS_LOCAL 0x80
  78. /*
  79. * DEBUG FLAGS
  80. */
  81. #define DEBUG_SMTF 1
  82. #define DEBUG_SMT 2
  83. #define DEBUG_ECM 3
  84. #define DEBUG_RMT 4
  85. #define DEBUG_CFM 5
  86. #define DEBUG_PCM 6
  87. #define DEBUG_SBA 7
  88. #define DEBUG_ESS 8
  89. #define DB_HWM_RX 10
  90. #define DB_HWM_TX 11
  91. #define DB_HWM_GEN 12
  92. struct s_mbuf_pool {
  93. #ifndef MB_OUTSIDE_SMC
  94. SMbuf mb[MAX_MBUF] ; /* mbuf pool */
  95. #endif
  96. SMbuf *mb_start ; /* points to the first mb */
  97. SMbuf *mb_free ; /* free queue */
  98. } ;
  99. struct hwm_r {
  100. /*
  101. * hardware modul specific receive variables
  102. */
  103. u_int len ; /* length of the whole frame */
  104. char *mb_pos ; /* SMbuf receive position */
  105. } ;
  106. struct hw_modul {
  107. /*
  108. * All hardware modul specific variables
  109. */
  110. struct s_mbuf_pool mbuf_pool ;
  111. struct hwm_r r ;
  112. union s_fp_descr volatile *descr_p ; /* points to the desriptor area */
  113. u_short pass_SMT ; /* pass SMT frames */
  114. u_short pass_NSA ; /* pass all NSA frames */
  115. u_short pass_DB ; /* pass Direct Beacon Frames */
  116. u_short pass_llc_promisc ; /* pass all llc frames (default ON) */
  117. SMbuf *llc_rx_pipe ; /* points to the first queued llc fr */
  118. SMbuf *llc_rx_tail ; /* points to the last queued llc fr */
  119. int queued_rx_frames ; /* number of queued frames */
  120. SMbuf *txd_tx_pipe ; /* points to first mb in the txd ring */
  121. SMbuf *txd_tx_tail ; /* points to last mb in the txd ring */
  122. int queued_txd_mb ; /* number of SMT MBufs in txd ring */
  123. int rx_break ; /* rev. was breaked because ind. off */
  124. int leave_isr ; /* leave fddi_isr immedeately if set */
  125. int isr_flag ; /* set, when HWM is entered from isr */
  126. /*
  127. * variables for the current transmit frame
  128. */
  129. struct s_smt_tx_queue *tx_p ; /* pointer to the transmit queue */
  130. u_long tx_descr ; /* tx descriptor for FORMAC+ */
  131. int tx_len ; /* tx frame length */
  132. SMbuf *tx_mb ; /* SMT tx MBuf pointer */
  133. char *tx_data ; /* data pointer to the SMT tx Mbuf */
  134. int detec_count ; /* counter for out of RxD condition */
  135. u_long rx_len_error ; /* rx len FORMAC != sum of fragments */
  136. } ;
  137. /*
  138. * DEBUG structs and macros
  139. */
  140. #ifdef DEBUG
  141. struct os_debug {
  142. int hwm_rx ;
  143. int hwm_tx ;
  144. int hwm_gen ;
  145. } ;
  146. #endif
  147. #ifdef DEBUG
  148. #ifdef DEBUG_BRD
  149. #define DB_P smc->debug
  150. #else
  151. #define DB_P debug
  152. #endif
  153. #define DB_RX(a,b,c,lev) if (DB_P.d_os.hwm_rx >= (lev)) printf(a,b,c)
  154. #define DB_TX(a,b,c,lev) if (DB_P.d_os.hwm_tx >= (lev)) printf(a,b,c)
  155. #define DB_GEN(a,b,c,lev) if (DB_P.d_os.hwm_gen >= (lev)) printf(a,b,c)
  156. #else /* DEBUG */
  157. #define DB_RX(a,b,c,lev)
  158. #define DB_TX(a,b,c,lev)
  159. #define DB_GEN(a,b,c,lev)
  160. #endif /* DEBUG */
  161. #ifndef SK_BREAK
  162. #define SK_BREAK()
  163. #endif
  164. /*
  165. * HWM Macros
  166. */
  167. /*
  168. * BEGIN_MANUAL_ENTRY(HWM_GET_TX_PHYS)
  169. * u_long HWM_GET_TX_PHYS(txd)
  170. *
  171. * function MACRO (hardware module, hwmtm.h)
  172. * This macro may be invoked by the OS-specific module to read
  173. * the physical address of the specified TxD.
  174. *
  175. * para txd pointer to the TxD
  176. *
  177. * END_MANUAL_ENTRY
  178. */
  179. #define HWM_GET_TX_PHYS(txd) (u_long)AIX_REVERSE((txd)->txd_tbadr)
  180. /*
  181. * BEGIN_MANUAL_ENTRY(HWM_GET_TX_LEN)
  182. * int HWM_GET_TX_LEN(txd)
  183. *
  184. * function MACRO (hardware module, hwmtm.h)
  185. * This macro may be invoked by the OS-specific module to read
  186. * the fragment length of the specified TxD
  187. *
  188. * para rxd pointer to the TxD
  189. *
  190. * return the length of the fragment in bytes
  191. *
  192. * END_MANUAL_ENTRY
  193. */
  194. #define HWM_GET_TX_LEN(txd) ((int)AIX_REVERSE((txd)->txd_tbctrl)& RD_LENGTH)
  195. /*
  196. * BEGIN_MANUAL_ENTRY(HWM_GET_TX_USED)
  197. * txd *HWM_GET_TX_USED(smc,queue)
  198. *
  199. * function MACRO (hardware module, hwmtm.h)
  200. * This macro may be invoked by the OS-specific module to get the
  201. * number of used TxDs for the queue, specified by the index.
  202. *
  203. * para queue the number of the send queue: Can be specified by
  204. * QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)
  205. *
  206. * return number of used TxDs for this send queue
  207. *
  208. * END_MANUAL_ENTRY
  209. */
  210. #define HWM_GET_TX_USED(smc,queue) (int) (smc)->hw.fp.tx_q[queue].tx_used
  211. /*
  212. * BEGIN_MANUAL_ENTRY(HWM_GET_CURR_TXD)
  213. * txd *HWM_GET_CURR_TXD(smc,queue)
  214. *
  215. * function MACRO (hardware module, hwmtm.h)
  216. * This macro may be invoked by the OS-specific module to get the
  217. * pointer to the TxD which points to the current queue put
  218. * position.
  219. *
  220. * para queue the number of the send queue: Can be specified by
  221. * QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)
  222. *
  223. * return pointer to the current TxD
  224. *
  225. * END_MANUAL_ENTRY
  226. */
  227. #define HWM_GET_CURR_TXD(smc,queue) (struct s_smt_fp_txd volatile *)\
  228. (smc)->hw.fp.tx_q[queue].tx_curr_put
  229. /*
  230. * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FRAG_LEN)
  231. * int HWM_GET_RX_FRAG_LEN(rxd)
  232. *
  233. * function MACRO (hardware module, hwmtm.h)
  234. * This macro may be invoked by the OS-specific module to read
  235. * the fragment length of the specified RxD
  236. *
  237. * para rxd pointer to the RxD
  238. *
  239. * return the length of the fragment in bytes
  240. *
  241. * END_MANUAL_ENTRY
  242. */
  243. #define HWM_GET_RX_FRAG_LEN(rxd) ((int)AIX_REVERSE((rxd)->rxd_rbctrl)& \
  244. RD_LENGTH)
  245. /*
  246. * BEGIN_MANUAL_ENTRY(HWM_GET_RX_PHYS)
  247. * u_long HWM_GET_RX_PHYS(rxd)
  248. *
  249. * function MACRO (hardware module, hwmtm.h)
  250. * This macro may be invoked by the OS-specific module to read
  251. * the physical address of the specified RxD.
  252. *
  253. * para rxd pointer to the RxD
  254. *
  255. * return the RxD's physical pointer to the data fragment
  256. *
  257. * END_MANUAL_ENTRY
  258. */
  259. #define HWM_GET_RX_PHYS(rxd) (u_long)AIX_REVERSE((rxd)->rxd_rbadr)
  260. /*
  261. * BEGIN_MANUAL_ENTRY(HWM_GET_RX_USED)
  262. * int HWM_GET_RX_USED(smc)
  263. *
  264. * function MACRO (hardware module, hwmtm.h)
  265. * This macro may be invoked by the OS-specific module to get
  266. * the count of used RXDs in receive queue 1.
  267. *
  268. * return the used RXD count of receive queue 1
  269. *
  270. * NOTE: Remember, because of an ASIC bug at least one RXD should be unused
  271. * in the descriptor ring !
  272. *
  273. * END_MANUAL_ENTRY
  274. */
  275. #define HWM_GET_RX_USED(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_used)
  276. /*
  277. * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FREE)
  278. * int HWM_GET_RX_FREE(smc)
  279. *
  280. * function MACRO (hardware module, hwmtm.h)
  281. * This macro may be invoked by the OS-specific module to get
  282. * the rxd_free count of receive queue 1.
  283. *
  284. * return the rxd_free count of receive queue 1
  285. *
  286. * END_MANUAL_ENTRY
  287. */
  288. #define HWM_GET_RX_FREE(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_free-1)
  289. /*
  290. * BEGIN_MANUAL_ENTRY(HWM_GET_CURR_RXD)
  291. * rxd *HWM_GET_CURR_RXD(smc)
  292. *
  293. * function MACRO (hardware module, hwmtm.h)
  294. * This macro may be invoked by the OS-specific module to get the
  295. * pointer to the RxD which points to the current queue put
  296. * position.
  297. *
  298. * return pointer to the current RxD
  299. *
  300. * END_MANUAL_ENTRY
  301. */
  302. #define HWM_GET_CURR_RXD(smc) (struct s_smt_fp_rxd volatile *)\
  303. (smc)->hw.fp.rx_q[QUEUE_R1].rx_curr_put
  304. /*
  305. * BEGIN_MANUAL_ENTRY(HWM_RX_CHECK)
  306. * void HWM_RX_CHECK(smc,low_water)
  307. *
  308. * function MACRO (hardware module, hwmtm.h)
  309. * This macro is invoked by the OS-specific before it left the
  310. * function mac_drv_rx_complete. This macro calls mac_drv_fill_rxd
  311. * if the number of used RxDs is equal or lower than the
  312. * the given low water mark.
  313. *
  314. * para low_water low water mark of used RxD's
  315. *
  316. * END_MANUAL_ENTRY
  317. */
  318. #ifndef HWM_NO_FLOW_CTL
  319. #define HWM_RX_CHECK(smc,low_water) {\
  320. if ((low_water) >= (smc)->hw.fp.rx_q[QUEUE_R1].rx_used) {\
  321. mac_drv_fill_rxd(smc) ;\
  322. }\
  323. }
  324. #else
  325. #define HWM_RX_CHECK(smc,low_water) mac_drv_fill_rxd(smc)
  326. #endif
  327. #ifndef HWM_EBASE
  328. #define HWM_EBASE 500
  329. #endif
  330. #define HWM_E0001 HWM_EBASE + 1
  331. #define HWM_E0001_MSG "HWM: Wrong size of s_rxd_os struct"
  332. #define HWM_E0002 HWM_EBASE + 2
  333. #define HWM_E0002_MSG "HWM: Wrong size of s_txd_os struct"
  334. #define HWM_E0003 HWM_EBASE + 3
  335. #define HWM_E0003_MSG "HWM: smt_free_mbuf() called with NULL pointer"
  336. #define HWM_E0004 HWM_EBASE + 4
  337. #define HWM_E0004_MSG "HWM: Parity error rx queue 1"
  338. #define HWM_E0005 HWM_EBASE + 5
  339. #define HWM_E0005_MSG "HWM: Encoding error rx queue 1"
  340. #define HWM_E0006 HWM_EBASE + 6
  341. #define HWM_E0006_MSG "HWM: Encoding error async tx queue"
  342. #define HWM_E0007 HWM_EBASE + 7
  343. #define HWM_E0007_MSG "HWM: Encoding error sync tx queue"
  344. #define HWM_E0008 HWM_EBASE + 8
  345. #define HWM_E0008_MSG ""
  346. #define HWM_E0009 HWM_EBASE + 9
  347. #define HWM_E0009_MSG "HWM: Out of RxD condition detected"
  348. #define HWM_E0010 HWM_EBASE + 10
  349. #define HWM_E0010_MSG "HWM: A protocol layer has tried to send a frame with an invalid frame control"
  350. #define HWM_E0011 HWM_EBASE + 11
  351. #define HWM_E0011_MSG "HWM: mac_drv_clear_tx_queue was called although the hardware wasn't stopped"
  352. #define HWM_E0012 HWM_EBASE + 12
  353. #define HWM_E0012_MSG "HWM: mac_drv_clear_rx_queue was called although the hardware wasn't stopped"
  354. #define HWM_E0013 HWM_EBASE + 13
  355. #define HWM_E0013_MSG "HWM: mac_drv_repair_descr was called although the hardware wasn't stopped"
  356. #endif