hwmtm.h 11 KB

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