hwmtm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /******************************************************************************
  3. *
  4. * (C)Copyright 1998,1999 SysKonnect,
  5. * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
  6. *
  7. * The information in this file is provided "AS IS" without warranty.
  8. *
  9. ******************************************************************************/
  10. #ifndef _HWM_
  11. #define _HWM_
  12. #include "mbuf.h"
  13. /*
  14. * MACRO for DMA synchronization:
  15. * The descriptor 'desc' is flushed for the device 'flag'.
  16. * Devices are the CPU (DDI_DMA_SYNC_FORCPU) and the
  17. * adapter (DDI_DMA_SYNC_FORDEV).
  18. *
  19. * 'desc' Pointer to a Rx or Tx descriptor.
  20. * 'flag' Flag for direction (view for CPU or DEVICE) that
  21. * should be synchronized.
  22. *
  23. * Empty macros and defines are specified here. The real macro
  24. * is os-specific and should be defined in osdef1st.h.
  25. */
  26. #ifndef DRV_BUF_FLUSH
  27. #define DRV_BUF_FLUSH(desc,flag)
  28. #define DDI_DMA_SYNC_FORCPU
  29. #define DDI_DMA_SYNC_FORDEV
  30. #endif
  31. /*
  32. * hardware modul dependent receive modes
  33. */
  34. #define RX_ENABLE_PASS_SMT 21
  35. #define RX_DISABLE_PASS_SMT 22
  36. #define RX_ENABLE_PASS_NSA 23
  37. #define RX_DISABLE_PASS_NSA 24
  38. #define RX_ENABLE_PASS_DB 25
  39. #define RX_DISABLE_PASS_DB 26
  40. #define RX_DISABLE_PASS_ALL 27
  41. #define RX_DISABLE_LLC_PROMISC 28
  42. #define RX_ENABLE_LLC_PROMISC 29
  43. #ifndef DMA_RD
  44. #define DMA_RD 1 /* memory -> hw */
  45. #endif
  46. #ifndef DMA_WR
  47. #define DMA_WR 2 /* hw -> memory */
  48. #endif
  49. #define SMT_BUF 0x80
  50. /*
  51. * bits of the frame status byte
  52. */
  53. #define EN_IRQ_EOF 0x02 /* get IRQ after end of frame transmission */
  54. #define LOC_TX 0x04 /* send frame to the local SMT */
  55. #define LAST_FRAG 0x08 /* last TxD of the frame */
  56. #define FIRST_FRAG 0x10 /* first TxD of the frame */
  57. #define LAN_TX 0x20 /* send frame to network if set */
  58. #define RING_DOWN 0x40 /* error: unable to send, ring down */
  59. #define OUT_OF_TXD 0x80 /* error: not enough TxDs available */
  60. #ifndef NULL
  61. #define NULL 0
  62. #endif
  63. #define C_INDIC (1L<<25)
  64. #define A_INDIC (1L<<26)
  65. #define RD_FS_LOCAL 0x80
  66. /*
  67. * DEBUG FLAGS
  68. */
  69. #define DEBUG_SMTF 1
  70. #define DEBUG_SMT 2
  71. #define DEBUG_ECM 3
  72. #define DEBUG_RMT 4
  73. #define DEBUG_CFM 5
  74. #define DEBUG_PCM 6
  75. #define DEBUG_SBA 7
  76. #define DEBUG_ESS 8
  77. #define DB_HWM_RX 10
  78. #define DB_HWM_TX 11
  79. #define DB_HWM_GEN 12
  80. struct s_mbuf_pool {
  81. #ifndef MB_OUTSIDE_SMC
  82. SMbuf mb[MAX_MBUF] ; /* mbuf pool */
  83. #endif
  84. SMbuf *mb_start ; /* points to the first mb */
  85. SMbuf *mb_free ; /* free queue */
  86. } ;
  87. struct hwm_r {
  88. /*
  89. * hardware modul specific receive variables
  90. */
  91. u_int len ; /* length of the whole frame */
  92. char *mb_pos ; /* SMbuf receive position */
  93. } ;
  94. struct hw_modul {
  95. /*
  96. * All hardware modul specific variables
  97. */
  98. struct s_mbuf_pool mbuf_pool ;
  99. struct hwm_r r ;
  100. union s_fp_descr volatile *descr_p ; /* points to the desriptor area */
  101. u_short pass_SMT ; /* pass SMT frames */
  102. u_short pass_NSA ; /* pass all NSA frames */
  103. u_short pass_DB ; /* pass Direct Beacon Frames */
  104. u_short pass_llc_promisc ; /* pass all llc frames (default ON) */
  105. SMbuf *llc_rx_pipe ; /* points to the first queued llc fr */
  106. SMbuf *llc_rx_tail ; /* points to the last queued llc fr */
  107. int queued_rx_frames ; /* number of queued frames */
  108. SMbuf *txd_tx_pipe ; /* points to first mb in the txd ring */
  109. SMbuf *txd_tx_tail ; /* points to last mb in the txd ring */
  110. int queued_txd_mb ; /* number of SMT MBufs in txd ring */
  111. int rx_break ; /* rev. was breaked because ind. off */
  112. int leave_isr ; /* leave fddi_isr immedeately if set */
  113. int isr_flag ; /* set, when HWM is entered from isr */
  114. /*
  115. * variables for the current transmit frame
  116. */
  117. struct s_smt_tx_queue *tx_p ; /* pointer to the transmit queue */
  118. u_long tx_descr ; /* tx descriptor for FORMAC+ */
  119. int tx_len ; /* tx frame length */
  120. SMbuf *tx_mb ; /* SMT tx MBuf pointer */
  121. char *tx_data ; /* data pointer to the SMT tx Mbuf */
  122. int detec_count ; /* counter for out of RxD condition */
  123. u_long rx_len_error ; /* rx len FORMAC != sum of fragments */
  124. } ;
  125. /*
  126. * DEBUG structs and macros
  127. */
  128. #ifdef DEBUG
  129. struct os_debug {
  130. int hwm_rx ;
  131. int hwm_tx ;
  132. int hwm_gen ;
  133. } ;
  134. #endif
  135. #ifdef DEBUG
  136. #ifdef DEBUG_BRD
  137. #define DB_P smc->debug
  138. #else
  139. #define DB_P debug
  140. #endif
  141. #define DB_RX(lev, fmt, ...) \
  142. do { \
  143. if (DB_P.d_os.hwm_rx >= (lev)) \
  144. printf(fmt "\n", ##__VA_ARGS__); \
  145. } while (0)
  146. #define DB_TX(lev, fmt, ...) \
  147. do { \
  148. if (DB_P.d_os.hwm_tx >= (lev)) \
  149. printf(fmt "\n", ##__VA_ARGS__); \
  150. } while (0)
  151. #define DB_GEN(lev, fmt, ...) \
  152. do { \
  153. if (DB_P.d_os.hwm_gen >= (lev)) \
  154. printf(fmt "\n", ##__VA_ARGS__); \
  155. } while (0)
  156. #else /* DEBUG */
  157. #define DB_RX(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)
  158. #define DB_TX(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)
  159. #define DB_GEN(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)
  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. * 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