hwmtm.c 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187
  1. /******************************************************************************
  2. *
  3. * (C)Copyright 1998,1999 SysKonnect,
  4. * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
  5. *
  6. * See the file "skfddi.c" for further information.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * The information in this file is provided "AS IS" without warranty.
  14. *
  15. ******************************************************************************/
  16. #ifndef lint
  17. static char const ID_sccs[] = "@(#)hwmtm.c 1.40 99/05/31 (C) SK" ;
  18. #endif
  19. #define HWMTM
  20. #ifndef FDDI
  21. #define FDDI
  22. #endif
  23. #include "h/types.h"
  24. #include "h/fddi.h"
  25. #include "h/smc.h"
  26. #include "h/supern_2.h"
  27. #include "h/skfbiinc.h"
  28. /*
  29. -------------------------------------------------------------
  30. DOCUMENTATION
  31. -------------------------------------------------------------
  32. BEGIN_MANUAL_ENTRY(DOCUMENTATION)
  33. T B D
  34. END_MANUAL_ENTRY
  35. */
  36. /*
  37. -------------------------------------------------------------
  38. LOCAL VARIABLES:
  39. -------------------------------------------------------------
  40. */
  41. #ifdef COMMON_MB_POOL
  42. static SMbuf *mb_start = 0 ;
  43. static SMbuf *mb_free = 0 ;
  44. static int mb_init = FALSE ;
  45. static int call_count = 0 ;
  46. #endif
  47. /*
  48. -------------------------------------------------------------
  49. EXTERNE VARIABLES:
  50. -------------------------------------------------------------
  51. */
  52. #ifdef DEBUG
  53. #ifndef DEBUG_BRD
  54. extern struct smt_debug debug ;
  55. #endif
  56. #endif
  57. #ifdef NDIS_OS2
  58. extern u_char offDepth ;
  59. extern u_char force_irq_pending ;
  60. #endif
  61. /*
  62. -------------------------------------------------------------
  63. LOCAL FUNCTIONS:
  64. -------------------------------------------------------------
  65. */
  66. static void queue_llc_rx(struct s_smc *smc, SMbuf *mb);
  67. static void smt_to_llc(struct s_smc *smc, SMbuf *mb);
  68. static void init_txd_ring(struct s_smc *smc);
  69. static void init_rxd_ring(struct s_smc *smc);
  70. static void queue_txd_mb(struct s_smc *smc, SMbuf *mb);
  71. static u_long init_descr_ring(struct s_smc *smc, union s_fp_descr volatile *start,
  72. int count);
  73. static u_long repair_txd_ring(struct s_smc *smc, struct s_smt_tx_queue *queue);
  74. static u_long repair_rxd_ring(struct s_smc *smc, struct s_smt_rx_queue *queue);
  75. static SMbuf* get_llc_rx(struct s_smc *smc);
  76. static SMbuf* get_txd_mb(struct s_smc *smc);
  77. static void mac_drv_clear_txd(struct s_smc *smc);
  78. /*
  79. -------------------------------------------------------------
  80. EXTERNAL FUNCTIONS:
  81. -------------------------------------------------------------
  82. */
  83. /* The external SMT functions are listed in cmtdef.h */
  84. extern void* mac_drv_get_space(struct s_smc *smc, unsigned int size);
  85. extern void* mac_drv_get_desc_mem(struct s_smc *smc, unsigned int size);
  86. extern void init_board(struct s_smc *smc, u_char *mac_addr);
  87. extern void mac_drv_fill_rxd(struct s_smc *smc);
  88. extern void plc1_irq(struct s_smc *smc);
  89. extern void mac_drv_tx_complete(struct s_smc *smc,
  90. volatile struct s_smt_fp_txd *txd);
  91. extern void plc2_irq(struct s_smc *smc);
  92. extern void mac1_irq(struct s_smc *smc, u_short stu, u_short stl);
  93. extern void mac2_irq(struct s_smc *smc, u_short code_s2u, u_short code_s2l);
  94. extern void mac3_irq(struct s_smc *smc, u_short code_s3u, u_short code_s3l);
  95. extern void timer_irq(struct s_smc *smc);
  96. extern void mac_drv_rx_complete(struct s_smc *smc,
  97. volatile struct s_smt_fp_rxd *rxd,
  98. int frag_count, int len);
  99. extern void mac_drv_requeue_rxd(struct s_smc *smc,
  100. volatile struct s_smt_fp_rxd *rxd,
  101. int frag_count);
  102. extern void init_plc(struct s_smc *smc);
  103. extern void mac_drv_clear_rxd(struct s_smc *smc,
  104. volatile struct s_smt_fp_rxd *rxd, int frag_count);
  105. #ifdef USE_OS_CPY
  106. extern void hwm_cpy_rxd2mb(void);
  107. extern void hwm_cpy_txd2mb(void);
  108. #endif
  109. #ifdef ALL_RX_COMPLETE
  110. extern void mac_drv_all_receives_complete(void);
  111. #endif
  112. extern u_long mac_drv_virt2phys(struct s_smc *smc, void *virt);
  113. extern u_long dma_master(struct s_smc *smc, void *virt, int len, int flag);
  114. #ifdef NDIS_OS2
  115. extern void post_proc(void);
  116. #else
  117. extern void dma_complete(struct s_smc *smc, volatile union s_fp_descr *descr,
  118. int flag);
  119. #endif
  120. extern int init_fplus(struct s_smc *smc);
  121. extern int mac_drv_rx_init(struct s_smc *smc, int len, int fc, char *look_ahead,
  122. int la_len);
  123. /*
  124. -------------------------------------------------------------
  125. PUBLIC FUNCTIONS:
  126. -------------------------------------------------------------
  127. */
  128. void process_receive(struct s_smc *smc);
  129. void fddi_isr(struct s_smc *smc);
  130. void smt_free_mbuf(struct s_smc *smc, SMbuf *mb);
  131. void init_driver_fplus(struct s_smc *smc);
  132. void mac_drv_rx_mode(struct s_smc *smc, int mode);
  133. void init_fddi_driver(struct s_smc *smc, u_char *mac_addr);
  134. void mac_drv_clear_tx_queue(struct s_smc *smc);
  135. void mac_drv_clear_rx_queue(struct s_smc *smc);
  136. void hwm_tx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
  137. int frame_status);
  138. void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
  139. int frame_status);
  140. int mac_drv_init(struct s_smc *smc);
  141. int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count, int frame_len,
  142. int frame_status);
  143. u_int mac_drv_check_space(void);
  144. SMbuf* smt_get_mbuf(struct s_smc *smc);
  145. #ifdef DEBUG
  146. void mac_drv_debug_lev(void);
  147. #endif
  148. /*
  149. -------------------------------------------------------------
  150. MACROS:
  151. -------------------------------------------------------------
  152. */
  153. #ifndef UNUSED
  154. #ifdef lint
  155. #define UNUSED(x) (x) = (x)
  156. #else
  157. #define UNUSED(x)
  158. #endif
  159. #endif
  160. #ifdef USE_CAN_ADDR
  161. #define MA smc->hw.fddi_canon_addr.a
  162. #define GROUP_ADDR_BIT 0x01
  163. #else
  164. #define MA smc->hw.fddi_home_addr.a
  165. #define GROUP_ADDR_BIT 0x80
  166. #endif
  167. #define RXD_TXD_COUNT (HWM_ASYNC_TXD_COUNT+HWM_SYNC_TXD_COUNT+\
  168. SMT_R1_RXD_COUNT+SMT_R2_RXD_COUNT)
  169. #ifdef MB_OUTSIDE_SMC
  170. #define EXT_VIRT_MEM ((RXD_TXD_COUNT+1)*sizeof(struct s_smt_fp_txd) +\
  171. MAX_MBUF*sizeof(SMbuf))
  172. #define EXT_VIRT_MEM_2 ((RXD_TXD_COUNT+1)*sizeof(struct s_smt_fp_txd))
  173. #else
  174. #define EXT_VIRT_MEM ((RXD_TXD_COUNT+1)*sizeof(struct s_smt_fp_txd))
  175. #endif
  176. /*
  177. * define critical read for 16 Bit drivers
  178. */
  179. #if defined(NDIS_OS2) || defined(ODI2)
  180. #define CR_READ(var) ((var) & 0xffff0000 | ((var) & 0xffff))
  181. #else
  182. #define CR_READ(var) (__le32)(var)
  183. #endif
  184. #define IMASK_SLOW (IS_PLINT1 | IS_PLINT2 | IS_TIMINT | IS_TOKEN | \
  185. IS_MINTR1 | IS_MINTR2 | IS_MINTR3 | IS_R1_P | \
  186. IS_R1_C | IS_XA_C | IS_XS_C)
  187. /*
  188. -------------------------------------------------------------
  189. INIT- AND SMT FUNCTIONS:
  190. -------------------------------------------------------------
  191. */
  192. /*
  193. * BEGIN_MANUAL_ENTRY(mac_drv_check_space)
  194. * u_int mac_drv_check_space()
  195. *
  196. * function DOWNCALL (drvsr.c)
  197. * This function calculates the needed non virtual
  198. * memory for MBufs, RxD and TxD descriptors etc.
  199. * needed by the driver.
  200. *
  201. * return u_int memory in bytes
  202. *
  203. * END_MANUAL_ENTRY
  204. */
  205. u_int mac_drv_check_space(void)
  206. {
  207. #ifdef MB_OUTSIDE_SMC
  208. #ifdef COMMON_MB_POOL
  209. call_count++ ;
  210. if (call_count == 1) {
  211. return(EXT_VIRT_MEM) ;
  212. }
  213. else {
  214. return(EXT_VIRT_MEM_2) ;
  215. }
  216. #else
  217. return (EXT_VIRT_MEM) ;
  218. #endif
  219. #else
  220. return (0) ;
  221. #endif
  222. }
  223. /*
  224. * BEGIN_MANUAL_ENTRY(mac_drv_init)
  225. * void mac_drv_init(smc)
  226. *
  227. * function DOWNCALL (drvsr.c)
  228. * In this function the hardware module allocates it's
  229. * memory.
  230. * The operating system dependent module should call
  231. * mac_drv_init once, after the adatper is detected.
  232. * END_MANUAL_ENTRY
  233. */
  234. int mac_drv_init(struct s_smc *smc)
  235. {
  236. if (sizeof(struct s_smt_fp_rxd) % 16) {
  237. SMT_PANIC(smc,HWM_E0001,HWM_E0001_MSG) ;
  238. }
  239. if (sizeof(struct s_smt_fp_txd) % 16) {
  240. SMT_PANIC(smc,HWM_E0002,HWM_E0002_MSG) ;
  241. }
  242. /*
  243. * get the required memory for the RxDs and TxDs
  244. */
  245. if (!(smc->os.hwm.descr_p = (union s_fp_descr volatile *)
  246. mac_drv_get_desc_mem(smc,(u_int)
  247. (RXD_TXD_COUNT+1)*sizeof(struct s_smt_fp_txd)))) {
  248. return(1) ; /* no space the hwm modul can't work */
  249. }
  250. /*
  251. * get the memory for the SMT MBufs
  252. */
  253. #ifndef MB_OUTSIDE_SMC
  254. smc->os.hwm.mbuf_pool.mb_start=(SMbuf *)(&smc->os.hwm.mbuf_pool.mb[0]) ;
  255. #else
  256. #ifndef COMMON_MB_POOL
  257. if (!(smc->os.hwm.mbuf_pool.mb_start = (SMbuf *) mac_drv_get_space(smc,
  258. MAX_MBUF*sizeof(SMbuf)))) {
  259. return(1) ; /* no space the hwm modul can't work */
  260. }
  261. #else
  262. if (!mb_start) {
  263. if (!(mb_start = (SMbuf *) mac_drv_get_space(smc,
  264. MAX_MBUF*sizeof(SMbuf)))) {
  265. return(1) ; /* no space the hwm modul can't work */
  266. }
  267. }
  268. #endif
  269. #endif
  270. return (0) ;
  271. }
  272. /*
  273. * BEGIN_MANUAL_ENTRY(init_driver_fplus)
  274. * init_driver_fplus(smc)
  275. *
  276. * Sets hardware modul specific values for the mode register 2
  277. * (e.g. the byte alignment for the received frames, the position of the
  278. * least significant byte etc.)
  279. * END_MANUAL_ENTRY
  280. */
  281. void init_driver_fplus(struct s_smc *smc)
  282. {
  283. smc->hw.fp.mdr2init = FM_LSB | FM_BMMODE | FM_ENNPRQ | FM_ENHSRQ | 3 ;
  284. #ifdef PCI
  285. smc->hw.fp.mdr2init |= FM_CHKPAR | FM_PARITY ;
  286. #endif
  287. smc->hw.fp.mdr3init = FM_MENRQAUNLCK | FM_MENRS ;
  288. #ifdef USE_CAN_ADDR
  289. /* enable address bit swapping */
  290. smc->hw.fp.frselreg_init = FM_ENXMTADSWAP | FM_ENRCVADSWAP ;
  291. #endif
  292. }
  293. static u_long init_descr_ring(struct s_smc *smc,
  294. union s_fp_descr volatile *start,
  295. int count)
  296. {
  297. int i ;
  298. union s_fp_descr volatile *d1 ;
  299. union s_fp_descr volatile *d2 ;
  300. u_long phys ;
  301. DB_GEN("descr ring starts at = %x ",(void *)start,0,3) ;
  302. for (i=count-1, d1=start; i ; i--) {
  303. d2 = d1 ;
  304. d1++ ; /* descr is owned by the host */
  305. d2->r.rxd_rbctrl = cpu_to_le32(BMU_CHECK) ;
  306. d2->r.rxd_next = &d1->r ;
  307. phys = mac_drv_virt2phys(smc,(void *)d1) ;
  308. d2->r.rxd_nrdadr = cpu_to_le32(phys) ;
  309. }
  310. DB_GEN("descr ring ends at = %x ",(void *)d1,0,3) ;
  311. d1->r.rxd_rbctrl = cpu_to_le32(BMU_CHECK) ;
  312. d1->r.rxd_next = &start->r ;
  313. phys = mac_drv_virt2phys(smc,(void *)start) ;
  314. d1->r.rxd_nrdadr = cpu_to_le32(phys) ;
  315. for (i=count, d1=start; i ; i--) {
  316. DRV_BUF_FLUSH(&d1->r,DDI_DMA_SYNC_FORDEV) ;
  317. d1++;
  318. }
  319. return(phys) ;
  320. }
  321. static void init_txd_ring(struct s_smc *smc)
  322. {
  323. struct s_smt_fp_txd volatile *ds ;
  324. struct s_smt_tx_queue *queue ;
  325. u_long phys ;
  326. /*
  327. * initialize the transmit descriptors
  328. */
  329. ds = (struct s_smt_fp_txd volatile *) ((char *)smc->os.hwm.descr_p +
  330. SMT_R1_RXD_COUNT*sizeof(struct s_smt_fp_rxd)) ;
  331. queue = smc->hw.fp.tx[QUEUE_A0] ;
  332. DB_GEN("Init async TxD ring, %d TxDs ",HWM_ASYNC_TXD_COUNT,0,3) ;
  333. (void)init_descr_ring(smc,(union s_fp_descr volatile *)ds,
  334. HWM_ASYNC_TXD_COUNT) ;
  335. phys = le32_to_cpu(ds->txd_ntdadr) ;
  336. ds++ ;
  337. queue->tx_curr_put = queue->tx_curr_get = ds ;
  338. ds-- ;
  339. queue->tx_free = HWM_ASYNC_TXD_COUNT ;
  340. queue->tx_used = 0 ;
  341. outpd(ADDR(B5_XA_DA),phys) ;
  342. ds = (struct s_smt_fp_txd volatile *) ((char *)ds +
  343. HWM_ASYNC_TXD_COUNT*sizeof(struct s_smt_fp_txd)) ;
  344. queue = smc->hw.fp.tx[QUEUE_S] ;
  345. DB_GEN("Init sync TxD ring, %d TxDs ",HWM_SYNC_TXD_COUNT,0,3) ;
  346. (void)init_descr_ring(smc,(union s_fp_descr volatile *)ds,
  347. HWM_SYNC_TXD_COUNT) ;
  348. phys = le32_to_cpu(ds->txd_ntdadr) ;
  349. ds++ ;
  350. queue->tx_curr_put = queue->tx_curr_get = ds ;
  351. queue->tx_free = HWM_SYNC_TXD_COUNT ;
  352. queue->tx_used = 0 ;
  353. outpd(ADDR(B5_XS_DA),phys) ;
  354. }
  355. static void init_rxd_ring(struct s_smc *smc)
  356. {
  357. struct s_smt_fp_rxd volatile *ds ;
  358. struct s_smt_rx_queue *queue ;
  359. u_long phys ;
  360. /*
  361. * initialize the receive descriptors
  362. */
  363. ds = (struct s_smt_fp_rxd volatile *) smc->os.hwm.descr_p ;
  364. queue = smc->hw.fp.rx[QUEUE_R1] ;
  365. DB_GEN("Init RxD ring, %d RxDs ",SMT_R1_RXD_COUNT,0,3) ;
  366. (void)init_descr_ring(smc,(union s_fp_descr volatile *)ds,
  367. SMT_R1_RXD_COUNT) ;
  368. phys = le32_to_cpu(ds->rxd_nrdadr) ;
  369. ds++ ;
  370. queue->rx_curr_put = queue->rx_curr_get = ds ;
  371. queue->rx_free = SMT_R1_RXD_COUNT ;
  372. queue->rx_used = 0 ;
  373. outpd(ADDR(B4_R1_DA),phys) ;
  374. }
  375. /*
  376. * BEGIN_MANUAL_ENTRY(init_fddi_driver)
  377. * void init_fddi_driver(smc,mac_addr)
  378. *
  379. * initializes the driver and it's variables
  380. *
  381. * END_MANUAL_ENTRY
  382. */
  383. void init_fddi_driver(struct s_smc *smc, u_char *mac_addr)
  384. {
  385. SMbuf *mb ;
  386. int i ;
  387. init_board(smc,mac_addr) ;
  388. (void)init_fplus(smc) ;
  389. /*
  390. * initialize the SMbufs for the SMT
  391. */
  392. #ifndef COMMON_MB_POOL
  393. mb = smc->os.hwm.mbuf_pool.mb_start ;
  394. smc->os.hwm.mbuf_pool.mb_free = (SMbuf *)NULL ;
  395. for (i = 0; i < MAX_MBUF; i++) {
  396. mb->sm_use_count = 1 ;
  397. smt_free_mbuf(smc,mb) ;
  398. mb++ ;
  399. }
  400. #else
  401. mb = mb_start ;
  402. if (!mb_init) {
  403. mb_free = 0 ;
  404. for (i = 0; i < MAX_MBUF; i++) {
  405. mb->sm_use_count = 1 ;
  406. smt_free_mbuf(smc,mb) ;
  407. mb++ ;
  408. }
  409. mb_init = TRUE ;
  410. }
  411. #endif
  412. /*
  413. * initialize the other variables
  414. */
  415. smc->os.hwm.llc_rx_pipe = smc->os.hwm.llc_rx_tail = (SMbuf *)NULL ;
  416. smc->os.hwm.txd_tx_pipe = smc->os.hwm.txd_tx_tail = NULL ;
  417. smc->os.hwm.pass_SMT = smc->os.hwm.pass_NSA = smc->os.hwm.pass_DB = 0 ;
  418. smc->os.hwm.pass_llc_promisc = TRUE ;
  419. smc->os.hwm.queued_rx_frames = smc->os.hwm.queued_txd_mb = 0 ;
  420. smc->os.hwm.detec_count = 0 ;
  421. smc->os.hwm.rx_break = 0 ;
  422. smc->os.hwm.rx_len_error = 0 ;
  423. smc->os.hwm.isr_flag = FALSE ;
  424. /*
  425. * make sure that the start pointer is 16 byte aligned
  426. */
  427. i = 16 - ((long)smc->os.hwm.descr_p & 0xf) ;
  428. if (i != 16) {
  429. DB_GEN("i = %d",i,0,3) ;
  430. smc->os.hwm.descr_p = (union s_fp_descr volatile *)
  431. ((char *)smc->os.hwm.descr_p+i) ;
  432. }
  433. DB_GEN("pt to descr area = %x",(void *)smc->os.hwm.descr_p,0,3) ;
  434. init_txd_ring(smc) ;
  435. init_rxd_ring(smc) ;
  436. mac_drv_fill_rxd(smc) ;
  437. init_plc(smc) ;
  438. }
  439. SMbuf *smt_get_mbuf(struct s_smc *smc)
  440. {
  441. register SMbuf *mb ;
  442. #ifndef COMMON_MB_POOL
  443. mb = smc->os.hwm.mbuf_pool.mb_free ;
  444. #else
  445. mb = mb_free ;
  446. #endif
  447. if (mb) {
  448. #ifndef COMMON_MB_POOL
  449. smc->os.hwm.mbuf_pool.mb_free = mb->sm_next ;
  450. #else
  451. mb_free = mb->sm_next ;
  452. #endif
  453. mb->sm_off = 8 ;
  454. mb->sm_use_count = 1 ;
  455. }
  456. DB_GEN("get SMbuf: mb = %x",(void *)mb,0,3) ;
  457. return (mb) ; /* May be NULL */
  458. }
  459. void smt_free_mbuf(struct s_smc *smc, SMbuf *mb)
  460. {
  461. if (mb) {
  462. mb->sm_use_count-- ;
  463. DB_GEN("free_mbuf: sm_use_count = %d",mb->sm_use_count,0,3) ;
  464. /*
  465. * If the use_count is != zero the MBuf is queued
  466. * more than once and must not queued into the
  467. * free MBuf queue
  468. */
  469. if (!mb->sm_use_count) {
  470. DB_GEN("free SMbuf: mb = %x",(void *)mb,0,3) ;
  471. #ifndef COMMON_MB_POOL
  472. mb->sm_next = smc->os.hwm.mbuf_pool.mb_free ;
  473. smc->os.hwm.mbuf_pool.mb_free = mb ;
  474. #else
  475. mb->sm_next = mb_free ;
  476. mb_free = mb ;
  477. #endif
  478. }
  479. }
  480. else
  481. SMT_PANIC(smc,HWM_E0003,HWM_E0003_MSG) ;
  482. }
  483. /*
  484. * BEGIN_MANUAL_ENTRY(mac_drv_repair_descr)
  485. * void mac_drv_repair_descr(smc)
  486. *
  487. * function called from SMT (HWM / hwmtm.c)
  488. * The BMU is idle when this function is called.
  489. * Mac_drv_repair_descr sets up the physical address
  490. * for all receive and transmit queues where the BMU
  491. * should continue.
  492. * It may be that the BMU was reseted during a fragmented
  493. * transfer. In this case there are some fragments which will
  494. * never completed by the BMU. The OWN bit of this fragments
  495. * must be switched to be owned by the host.
  496. *
  497. * Give a start command to the receive BMU.
  498. * Start the transmit BMUs if transmit frames pending.
  499. *
  500. * END_MANUAL_ENTRY
  501. */
  502. void mac_drv_repair_descr(struct s_smc *smc)
  503. {
  504. u_long phys ;
  505. if (smc->hw.hw_state != STOPPED) {
  506. SK_BREAK() ;
  507. SMT_PANIC(smc,HWM_E0013,HWM_E0013_MSG) ;
  508. return ;
  509. }
  510. /*
  511. * repair tx queues: don't start
  512. */
  513. phys = repair_txd_ring(smc,smc->hw.fp.tx[QUEUE_A0]) ;
  514. outpd(ADDR(B5_XA_DA),phys) ;
  515. if (smc->hw.fp.tx_q[QUEUE_A0].tx_used) {
  516. outpd(ADDR(B0_XA_CSR),CSR_START) ;
  517. }
  518. phys = repair_txd_ring(smc,smc->hw.fp.tx[QUEUE_S]) ;
  519. outpd(ADDR(B5_XS_DA),phys) ;
  520. if (smc->hw.fp.tx_q[QUEUE_S].tx_used) {
  521. outpd(ADDR(B0_XS_CSR),CSR_START) ;
  522. }
  523. /*
  524. * repair rx queues
  525. */
  526. phys = repair_rxd_ring(smc,smc->hw.fp.rx[QUEUE_R1]) ;
  527. outpd(ADDR(B4_R1_DA),phys) ;
  528. outpd(ADDR(B0_R1_CSR),CSR_START) ;
  529. }
  530. static u_long repair_txd_ring(struct s_smc *smc, struct s_smt_tx_queue *queue)
  531. {
  532. int i ;
  533. int tx_used ;
  534. u_long phys ;
  535. u_long tbctrl ;
  536. struct s_smt_fp_txd volatile *t ;
  537. SK_UNUSED(smc) ;
  538. t = queue->tx_curr_get ;
  539. tx_used = queue->tx_used ;
  540. for (i = tx_used+queue->tx_free-1 ; i ; i-- ) {
  541. t = t->txd_next ;
  542. }
  543. phys = le32_to_cpu(t->txd_ntdadr) ;
  544. t = queue->tx_curr_get ;
  545. while (tx_used) {
  546. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORCPU) ;
  547. tbctrl = le32_to_cpu(t->txd_tbctrl) ;
  548. if (tbctrl & BMU_OWN) {
  549. if (tbctrl & BMU_STF) {
  550. break ; /* exit the loop */
  551. }
  552. else {
  553. /*
  554. * repair the descriptor
  555. */
  556. t->txd_tbctrl &= ~cpu_to_le32(BMU_OWN) ;
  557. }
  558. }
  559. phys = le32_to_cpu(t->txd_ntdadr) ;
  560. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  561. t = t->txd_next ;
  562. tx_used-- ;
  563. }
  564. return(phys) ;
  565. }
  566. /*
  567. * Repairs the receive descriptor ring and returns the physical address
  568. * where the BMU should continue working.
  569. *
  570. * o The physical address where the BMU was stopped has to be
  571. * determined. This is the next RxD after rx_curr_get with an OWN
  572. * bit set.
  573. * o The BMU should start working at beginning of the next frame.
  574. * RxDs with an OWN bit set but with a reset STF bit should be
  575. * skipped and owned by the driver (OWN = 0).
  576. */
  577. static u_long repair_rxd_ring(struct s_smc *smc, struct s_smt_rx_queue *queue)
  578. {
  579. int i ;
  580. int rx_used ;
  581. u_long phys ;
  582. u_long rbctrl ;
  583. struct s_smt_fp_rxd volatile *r ;
  584. SK_UNUSED(smc) ;
  585. r = queue->rx_curr_get ;
  586. rx_used = queue->rx_used ;
  587. for (i = SMT_R1_RXD_COUNT-1 ; i ; i-- ) {
  588. r = r->rxd_next ;
  589. }
  590. phys = le32_to_cpu(r->rxd_nrdadr) ;
  591. r = queue->rx_curr_get ;
  592. while (rx_used) {
  593. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  594. rbctrl = le32_to_cpu(r->rxd_rbctrl) ;
  595. if (rbctrl & BMU_OWN) {
  596. if (rbctrl & BMU_STF) {
  597. break ; /* exit the loop */
  598. }
  599. else {
  600. /*
  601. * repair the descriptor
  602. */
  603. r->rxd_rbctrl &= ~cpu_to_le32(BMU_OWN) ;
  604. }
  605. }
  606. phys = le32_to_cpu(r->rxd_nrdadr) ;
  607. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORDEV) ;
  608. r = r->rxd_next ;
  609. rx_used-- ;
  610. }
  611. return(phys) ;
  612. }
  613. /*
  614. -------------------------------------------------------------
  615. INTERRUPT SERVICE ROUTINE:
  616. -------------------------------------------------------------
  617. */
  618. /*
  619. * BEGIN_MANUAL_ENTRY(fddi_isr)
  620. * void fddi_isr(smc)
  621. *
  622. * function DOWNCALL (drvsr.c)
  623. * interrupt service routine, handles the interrupt requests
  624. * generated by the FDDI adapter.
  625. *
  626. * NOTE: The operating system dependent module must garantee that the
  627. * interrupts of the adapter are disabled when it calls fddi_isr.
  628. *
  629. * About the USE_BREAK_ISR mechanismn:
  630. *
  631. * The main requirement of this mechanismn is to force an timer IRQ when
  632. * leaving process_receive() with leave_isr set. process_receive() may
  633. * be called at any time from anywhere!
  634. * To be sure we don't miss such event we set 'force_irq' per default.
  635. * We have to force and Timer IRQ if 'smc->os.hwm.leave_isr' AND
  636. * 'force_irq' are set. 'force_irq' may be reset if a receive complete
  637. * IRQ is pending.
  638. *
  639. * END_MANUAL_ENTRY
  640. */
  641. void fddi_isr(struct s_smc *smc)
  642. {
  643. u_long is ; /* ISR source */
  644. u_short stu, stl ;
  645. SMbuf *mb ;
  646. #ifdef USE_BREAK_ISR
  647. int force_irq ;
  648. #endif
  649. #ifdef ODI2
  650. if (smc->os.hwm.rx_break) {
  651. mac_drv_fill_rxd(smc) ;
  652. if (smc->hw.fp.rx_q[QUEUE_R1].rx_used > 0) {
  653. smc->os.hwm.rx_break = 0 ;
  654. process_receive(smc) ;
  655. }
  656. else {
  657. smc->os.hwm.detec_count = 0 ;
  658. smt_force_irq(smc) ;
  659. }
  660. }
  661. #endif
  662. smc->os.hwm.isr_flag = TRUE ;
  663. #ifdef USE_BREAK_ISR
  664. force_irq = TRUE ;
  665. if (smc->os.hwm.leave_isr) {
  666. smc->os.hwm.leave_isr = FALSE ;
  667. process_receive(smc) ;
  668. }
  669. #endif
  670. while ((is = GET_ISR() & ISR_MASK)) {
  671. NDD_TRACE("CH0B",is,0,0) ;
  672. DB_GEN("ISA = 0x%x",is,0,7) ;
  673. if (is & IMASK_SLOW) {
  674. NDD_TRACE("CH1b",is,0,0) ;
  675. if (is & IS_PLINT1) { /* PLC1 */
  676. plc1_irq(smc) ;
  677. }
  678. if (is & IS_PLINT2) { /* PLC2 */
  679. plc2_irq(smc) ;
  680. }
  681. if (is & IS_MINTR1) { /* FORMAC+ STU1(U/L) */
  682. stu = inpw(FM_A(FM_ST1U)) ;
  683. stl = inpw(FM_A(FM_ST1L)) ;
  684. DB_GEN("Slow transmit complete",0,0,6) ;
  685. mac1_irq(smc,stu,stl) ;
  686. }
  687. if (is & IS_MINTR2) { /* FORMAC+ STU2(U/L) */
  688. stu= inpw(FM_A(FM_ST2U)) ;
  689. stl= inpw(FM_A(FM_ST2L)) ;
  690. DB_GEN("Slow receive complete",0,0,6) ;
  691. DB_GEN("stl = %x : stu = %x",stl,stu,7) ;
  692. mac2_irq(smc,stu,stl) ;
  693. }
  694. if (is & IS_MINTR3) { /* FORMAC+ STU3(U/L) */
  695. stu= inpw(FM_A(FM_ST3U)) ;
  696. stl= inpw(FM_A(FM_ST3L)) ;
  697. DB_GEN("FORMAC Mode Register 3",0,0,6) ;
  698. mac3_irq(smc,stu,stl) ;
  699. }
  700. if (is & IS_TIMINT) { /* Timer 82C54-2 */
  701. timer_irq(smc) ;
  702. #ifdef NDIS_OS2
  703. force_irq_pending = 0 ;
  704. #endif
  705. /*
  706. * out of RxD detection
  707. */
  708. if (++smc->os.hwm.detec_count > 4) {
  709. /*
  710. * check out of RxD condition
  711. */
  712. process_receive(smc) ;
  713. }
  714. }
  715. if (is & IS_TOKEN) { /* Restricted Token Monitor */
  716. rtm_irq(smc) ;
  717. }
  718. if (is & IS_R1_P) { /* Parity error rx queue 1 */
  719. /* clear IRQ */
  720. outpd(ADDR(B4_R1_CSR),CSR_IRQ_CL_P) ;
  721. SMT_PANIC(smc,HWM_E0004,HWM_E0004_MSG) ;
  722. }
  723. if (is & IS_R1_C) { /* Encoding error rx queue 1 */
  724. /* clear IRQ */
  725. outpd(ADDR(B4_R1_CSR),CSR_IRQ_CL_C) ;
  726. SMT_PANIC(smc,HWM_E0005,HWM_E0005_MSG) ;
  727. }
  728. if (is & IS_XA_C) { /* Encoding error async tx q */
  729. /* clear IRQ */
  730. outpd(ADDR(B5_XA_CSR),CSR_IRQ_CL_C) ;
  731. SMT_PANIC(smc,HWM_E0006,HWM_E0006_MSG) ;
  732. }
  733. if (is & IS_XS_C) { /* Encoding error sync tx q */
  734. /* clear IRQ */
  735. outpd(ADDR(B5_XS_CSR),CSR_IRQ_CL_C) ;
  736. SMT_PANIC(smc,HWM_E0007,HWM_E0007_MSG) ;
  737. }
  738. }
  739. /*
  740. * Fast Tx complete Async/Sync Queue (BMU service)
  741. */
  742. if (is & (IS_XS_F|IS_XA_F)) {
  743. DB_GEN("Fast tx complete queue",0,0,6) ;
  744. /*
  745. * clear IRQ, Note: no IRQ is lost, because
  746. * we always service both queues
  747. */
  748. outpd(ADDR(B5_XS_CSR),CSR_IRQ_CL_F) ;
  749. outpd(ADDR(B5_XA_CSR),CSR_IRQ_CL_F) ;
  750. mac_drv_clear_txd(smc) ;
  751. llc_restart_tx(smc) ;
  752. }
  753. /*
  754. * Fast Rx Complete (BMU service)
  755. */
  756. if (is & IS_R1_F) {
  757. DB_GEN("Fast receive complete",0,0,6) ;
  758. /* clear IRQ */
  759. #ifndef USE_BREAK_ISR
  760. outpd(ADDR(B4_R1_CSR),CSR_IRQ_CL_F) ;
  761. process_receive(smc) ;
  762. #else
  763. process_receive(smc) ;
  764. if (smc->os.hwm.leave_isr) {
  765. force_irq = FALSE ;
  766. } else {
  767. outpd(ADDR(B4_R1_CSR),CSR_IRQ_CL_F) ;
  768. process_receive(smc) ;
  769. }
  770. #endif
  771. }
  772. #ifndef NDIS_OS2
  773. while ((mb = get_llc_rx(smc))) {
  774. smt_to_llc(smc,mb) ;
  775. }
  776. #else
  777. if (offDepth)
  778. post_proc() ;
  779. while (!offDepth && (mb = get_llc_rx(smc))) {
  780. smt_to_llc(smc,mb) ;
  781. }
  782. if (!offDepth && smc->os.hwm.rx_break) {
  783. process_receive(smc) ;
  784. }
  785. #endif
  786. if (smc->q.ev_get != smc->q.ev_put) {
  787. NDD_TRACE("CH2a",0,0,0) ;
  788. ev_dispatcher(smc) ;
  789. }
  790. #ifdef NDIS_OS2
  791. post_proc() ;
  792. if (offDepth) { /* leave fddi_isr because */
  793. break ; /* indications not allowed */
  794. }
  795. #endif
  796. #ifdef USE_BREAK_ISR
  797. if (smc->os.hwm.leave_isr) {
  798. break ; /* leave fddi_isr */
  799. }
  800. #endif
  801. /* NOTE: when the isr is left, no rx is pending */
  802. } /* end of interrupt source polling loop */
  803. #ifdef USE_BREAK_ISR
  804. if (smc->os.hwm.leave_isr && force_irq) {
  805. smt_force_irq(smc) ;
  806. }
  807. #endif
  808. smc->os.hwm.isr_flag = FALSE ;
  809. NDD_TRACE("CH0E",0,0,0) ;
  810. }
  811. /*
  812. -------------------------------------------------------------
  813. RECEIVE FUNCTIONS:
  814. -------------------------------------------------------------
  815. */
  816. #ifndef NDIS_OS2
  817. /*
  818. * BEGIN_MANUAL_ENTRY(mac_drv_rx_mode)
  819. * void mac_drv_rx_mode(smc,mode)
  820. *
  821. * function DOWNCALL (fplus.c)
  822. * Corresponding to the parameter mode, the operating system
  823. * dependent module can activate several receive modes.
  824. *
  825. * para mode = 1: RX_ENABLE_ALLMULTI enable all multicasts
  826. * = 2: RX_DISABLE_ALLMULTI disable "enable all multicasts"
  827. * = 3: RX_ENABLE_PROMISC enable promiscuous
  828. * = 4: RX_DISABLE_PROMISC disable promiscuous
  829. * = 5: RX_ENABLE_NSA enable rec. of all NSA frames
  830. * (disabled after 'driver reset' & 'set station address')
  831. * = 6: RX_DISABLE_NSA disable rec. of all NSA frames
  832. *
  833. * = 21: RX_ENABLE_PASS_SMT ( see description )
  834. * = 22: RX_DISABLE_PASS_SMT ( " " )
  835. * = 23: RX_ENABLE_PASS_NSA ( " " )
  836. * = 24: RX_DISABLE_PASS_NSA ( " " )
  837. * = 25: RX_ENABLE_PASS_DB ( " " )
  838. * = 26: RX_DISABLE_PASS_DB ( " " )
  839. * = 27: RX_DISABLE_PASS_ALL ( " " )
  840. * = 28: RX_DISABLE_LLC_PROMISC ( " " )
  841. * = 29: RX_ENABLE_LLC_PROMISC ( " " )
  842. *
  843. *
  844. * RX_ENABLE_PASS_SMT / RX_DISABLE_PASS_SMT
  845. *
  846. * If the operating system dependent module activates the
  847. * mode RX_ENABLE_PASS_SMT, the hardware module
  848. * duplicates all SMT frames with the frame control
  849. * FC_SMT_INFO and passes them to the LLC receive channel
  850. * by calling mac_drv_rx_init.
  851. * The SMT Frames which are sent by the local SMT and the NSA
  852. * frames whose A- and C-Indicator is not set are also duplicated
  853. * and passed.
  854. * The receive mode RX_DISABLE_PASS_SMT disables the passing
  855. * of SMT frames.
  856. *
  857. * RX_ENABLE_PASS_NSA / RX_DISABLE_PASS_NSA
  858. *
  859. * If the operating system dependent module activates the
  860. * mode RX_ENABLE_PASS_NSA, the hardware module
  861. * duplicates all NSA frames with frame control FC_SMT_NSA
  862. * and a set A-Indicator and passed them to the LLC
  863. * receive channel by calling mac_drv_rx_init.
  864. * All NSA Frames which are sent by the local SMT
  865. * are also duplicated and passed.
  866. * The receive mode RX_DISABLE_PASS_NSA disables the passing
  867. * of NSA frames with the A- or C-Indicator set.
  868. *
  869. * NOTE: For fear that the hardware module receives NSA frames with
  870. * a reset A-Indicator, the operating system dependent module
  871. * has to call mac_drv_rx_mode with the mode RX_ENABLE_NSA
  872. * before activate the RX_ENABLE_PASS_NSA mode and after every
  873. * 'driver reset' and 'set station address'.
  874. *
  875. * RX_ENABLE_PASS_DB / RX_DISABLE_PASS_DB
  876. *
  877. * If the operating system dependent module activates the
  878. * mode RX_ENABLE_PASS_DB, direct BEACON frames
  879. * (FC_BEACON frame control) are passed to the LLC receive
  880. * channel by mac_drv_rx_init.
  881. * The receive mode RX_DISABLE_PASS_DB disables the passing
  882. * of direct BEACON frames.
  883. *
  884. * RX_DISABLE_PASS_ALL
  885. *
  886. * Disables all special receives modes. It is equal to
  887. * call mac_drv_set_rx_mode successively with the
  888. * parameters RX_DISABLE_NSA, RX_DISABLE_PASS_SMT,
  889. * RX_DISABLE_PASS_NSA and RX_DISABLE_PASS_DB.
  890. *
  891. * RX_ENABLE_LLC_PROMISC
  892. *
  893. * (default) all received LLC frames and all SMT/NSA/DBEACON
  894. * frames depending on the attitude of the flags
  895. * PASS_SMT/PASS_NSA/PASS_DBEACON will be delivered to the
  896. * LLC layer
  897. *
  898. * RX_DISABLE_LLC_PROMISC
  899. *
  900. * all received SMT/NSA/DBEACON frames depending on the
  901. * attitude of the flags PASS_SMT/PASS_NSA/PASS_DBEACON
  902. * will be delivered to the LLC layer.
  903. * all received LLC frames with a directed address, Multicast
  904. * or Broadcast address will be delivered to the LLC
  905. * layer too.
  906. *
  907. * END_MANUAL_ENTRY
  908. */
  909. void mac_drv_rx_mode(struct s_smc *smc, int mode)
  910. {
  911. switch(mode) {
  912. case RX_ENABLE_PASS_SMT:
  913. smc->os.hwm.pass_SMT = TRUE ;
  914. break ;
  915. case RX_DISABLE_PASS_SMT:
  916. smc->os.hwm.pass_SMT = FALSE ;
  917. break ;
  918. case RX_ENABLE_PASS_NSA:
  919. smc->os.hwm.pass_NSA = TRUE ;
  920. break ;
  921. case RX_DISABLE_PASS_NSA:
  922. smc->os.hwm.pass_NSA = FALSE ;
  923. break ;
  924. case RX_ENABLE_PASS_DB:
  925. smc->os.hwm.pass_DB = TRUE ;
  926. break ;
  927. case RX_DISABLE_PASS_DB:
  928. smc->os.hwm.pass_DB = FALSE ;
  929. break ;
  930. case RX_DISABLE_PASS_ALL:
  931. smc->os.hwm.pass_SMT = smc->os.hwm.pass_NSA = FALSE ;
  932. smc->os.hwm.pass_DB = FALSE ;
  933. smc->os.hwm.pass_llc_promisc = TRUE ;
  934. mac_set_rx_mode(smc,RX_DISABLE_NSA) ;
  935. break ;
  936. case RX_DISABLE_LLC_PROMISC:
  937. smc->os.hwm.pass_llc_promisc = FALSE ;
  938. break ;
  939. case RX_ENABLE_LLC_PROMISC:
  940. smc->os.hwm.pass_llc_promisc = TRUE ;
  941. break ;
  942. case RX_ENABLE_ALLMULTI:
  943. case RX_DISABLE_ALLMULTI:
  944. case RX_ENABLE_PROMISC:
  945. case RX_DISABLE_PROMISC:
  946. case RX_ENABLE_NSA:
  947. case RX_DISABLE_NSA:
  948. default:
  949. mac_set_rx_mode(smc,mode) ;
  950. break ;
  951. }
  952. }
  953. #endif /* ifndef NDIS_OS2 */
  954. /*
  955. * process receive queue
  956. */
  957. void process_receive(struct s_smc *smc)
  958. {
  959. int i ;
  960. int n ;
  961. int frag_count ; /* number of RxDs of the curr rx buf */
  962. int used_frags ; /* number of RxDs of the curr frame */
  963. struct s_smt_rx_queue *queue ; /* points to the queue ctl struct */
  964. struct s_smt_fp_rxd volatile *r ; /* rxd pointer */
  965. struct s_smt_fp_rxd volatile *rxd ; /* first rxd of rx frame */
  966. u_long rbctrl ; /* receive buffer control word */
  967. u_long rfsw ; /* receive frame status word */
  968. u_short rx_used ;
  969. u_char far *virt ;
  970. char far *data ;
  971. SMbuf *mb ;
  972. u_char fc ; /* Frame control */
  973. int len ; /* Frame length */
  974. smc->os.hwm.detec_count = 0 ;
  975. queue = smc->hw.fp.rx[QUEUE_R1] ;
  976. NDD_TRACE("RHxB",0,0,0) ;
  977. for ( ; ; ) {
  978. r = queue->rx_curr_get ;
  979. rx_used = queue->rx_used ;
  980. frag_count = 0 ;
  981. #ifdef USE_BREAK_ISR
  982. if (smc->os.hwm.leave_isr) {
  983. goto rx_end ;
  984. }
  985. #endif
  986. #ifdef NDIS_OS2
  987. if (offDepth) {
  988. smc->os.hwm.rx_break = 1 ;
  989. goto rx_end ;
  990. }
  991. smc->os.hwm.rx_break = 0 ;
  992. #endif
  993. #ifdef ODI2
  994. if (smc->os.hwm.rx_break) {
  995. goto rx_end ;
  996. }
  997. #endif
  998. n = 0 ;
  999. do {
  1000. DB_RX("Check RxD %x for OWN and EOF",(void *)r,0,5) ;
  1001. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1002. rbctrl = le32_to_cpu(CR_READ(r->rxd_rbctrl));
  1003. if (rbctrl & BMU_OWN) {
  1004. NDD_TRACE("RHxE",r,rfsw,rbctrl) ;
  1005. DB_RX("End of RxDs",0,0,4) ;
  1006. goto rx_end ;
  1007. }
  1008. /*
  1009. * out of RxD detection
  1010. */
  1011. if (!rx_used) {
  1012. SK_BREAK() ;
  1013. SMT_PANIC(smc,HWM_E0009,HWM_E0009_MSG) ;
  1014. /* Either we don't have an RxD or all
  1015. * RxDs are filled. Therefore it's allowed
  1016. * for to set the STOPPED flag */
  1017. smc->hw.hw_state = STOPPED ;
  1018. mac_drv_clear_rx_queue(smc) ;
  1019. smc->hw.hw_state = STARTED ;
  1020. mac_drv_fill_rxd(smc) ;
  1021. smc->os.hwm.detec_count = 0 ;
  1022. goto rx_end ;
  1023. }
  1024. rfsw = le32_to_cpu(r->rxd_rfsw) ;
  1025. if ((rbctrl & BMU_STF) != ((rbctrl & BMU_ST_BUF) <<5)) {
  1026. /*
  1027. * The BMU_STF bit is deleted, 1 frame is
  1028. * placed into more than 1 rx buffer
  1029. *
  1030. * skip frame by setting the rx len to 0
  1031. *
  1032. * if fragment count == 0
  1033. * The missing STF bit belongs to the
  1034. * current frame, search for the
  1035. * EOF bit to complete the frame
  1036. * else
  1037. * the fragment belongs to the next frame,
  1038. * exit the loop and process the frame
  1039. */
  1040. SK_BREAK() ;
  1041. rfsw = 0 ;
  1042. if (frag_count) {
  1043. break ;
  1044. }
  1045. }
  1046. n += rbctrl & 0xffff ;
  1047. r = r->rxd_next ;
  1048. frag_count++ ;
  1049. rx_used-- ;
  1050. } while (!(rbctrl & BMU_EOF)) ;
  1051. used_frags = frag_count ;
  1052. DB_RX("EOF set in RxD, used_frags = %d ",used_frags,0,5) ;
  1053. /* may be next 2 DRV_BUF_FLUSH() can be skipped, because */
  1054. /* BMU_ST_BUF will not be changed by the ASIC */
  1055. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1056. while (rx_used && !(r->rxd_rbctrl & cpu_to_le32(BMU_ST_BUF))) {
  1057. DB_RX("Check STF bit in %x",(void *)r,0,5) ;
  1058. r = r->rxd_next ;
  1059. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1060. frag_count++ ;
  1061. rx_used-- ;
  1062. }
  1063. DB_RX("STF bit found",0,0,5) ;
  1064. /*
  1065. * The received frame is finished for the process receive
  1066. */
  1067. rxd = queue->rx_curr_get ;
  1068. queue->rx_curr_get = r ;
  1069. queue->rx_free += frag_count ;
  1070. queue->rx_used = rx_used ;
  1071. /*
  1072. * ASIC Errata no. 7 (STF - Bit Bug)
  1073. */
  1074. rxd->rxd_rbctrl &= cpu_to_le32(~BMU_STF) ;
  1075. for (r=rxd, i=frag_count ; i ; r=r->rxd_next, i--){
  1076. DB_RX("dma_complete for RxD %x",(void *)r,0,5) ;
  1077. dma_complete(smc,(union s_fp_descr volatile *)r,DMA_WR);
  1078. }
  1079. smc->hw.fp.err_stats.err_valid++ ;
  1080. smc->mib.m[MAC0].fddiMACCopied_Ct++ ;
  1081. /* the length of the data including the FC */
  1082. len = (rfsw & RD_LENGTH) - 4 ;
  1083. DB_RX("frame length = %d",len,0,4) ;
  1084. /*
  1085. * check the frame_length and all error flags
  1086. */
  1087. if (rfsw & (RX_MSRABT|RX_FS_E|RX_FS_CRC|RX_FS_IMPL)){
  1088. if (rfsw & RD_S_MSRABT) {
  1089. DB_RX("Frame aborted by the FORMAC",0,0,2) ;
  1090. smc->hw.fp.err_stats.err_abort++ ;
  1091. }
  1092. /*
  1093. * check frame status
  1094. */
  1095. if (rfsw & RD_S_SEAC2) {
  1096. DB_RX("E-Indicator set",0,0,2) ;
  1097. smc->hw.fp.err_stats.err_e_indicator++ ;
  1098. }
  1099. if (rfsw & RD_S_SFRMERR) {
  1100. DB_RX("CRC error",0,0,2) ;
  1101. smc->hw.fp.err_stats.err_crc++ ;
  1102. }
  1103. if (rfsw & RX_FS_IMPL) {
  1104. DB_RX("Implementer frame",0,0,2) ;
  1105. smc->hw.fp.err_stats.err_imp_frame++ ;
  1106. }
  1107. goto abort_frame ;
  1108. }
  1109. if (len > FDDI_RAW_MTU-4) {
  1110. DB_RX("Frame too long error",0,0,2) ;
  1111. smc->hw.fp.err_stats.err_too_long++ ;
  1112. goto abort_frame ;
  1113. }
  1114. /*
  1115. * SUPERNET 3 Bug: FORMAC delivers status words
  1116. * of aborded frames to the BMU
  1117. */
  1118. if (len <= 4) {
  1119. DB_RX("Frame length = 0",0,0,2) ;
  1120. goto abort_frame ;
  1121. }
  1122. if (len != (n-4)) {
  1123. DB_RX("BMU: rx len differs: [%d:%d]",len,n,4);
  1124. smc->os.hwm.rx_len_error++ ;
  1125. goto abort_frame ;
  1126. }
  1127. /*
  1128. * Check SA == MA
  1129. */
  1130. virt = (u_char far *) rxd->rxd_virt ;
  1131. DB_RX("FC = %x",*virt,0,2) ;
  1132. if (virt[12] == MA[5] &&
  1133. virt[11] == MA[4] &&
  1134. virt[10] == MA[3] &&
  1135. virt[9] == MA[2] &&
  1136. virt[8] == MA[1] &&
  1137. (virt[7] & ~GROUP_ADDR_BIT) == MA[0]) {
  1138. goto abort_frame ;
  1139. }
  1140. /*
  1141. * test if LLC frame
  1142. */
  1143. if (rfsw & RX_FS_LLC) {
  1144. /*
  1145. * if pass_llc_promisc is disable
  1146. * if DA != Multicast or Broadcast or DA!=MA
  1147. * abort the frame
  1148. */
  1149. if (!smc->os.hwm.pass_llc_promisc) {
  1150. if(!(virt[1] & GROUP_ADDR_BIT)) {
  1151. if (virt[6] != MA[5] ||
  1152. virt[5] != MA[4] ||
  1153. virt[4] != MA[3] ||
  1154. virt[3] != MA[2] ||
  1155. virt[2] != MA[1] ||
  1156. virt[1] != MA[0]) {
  1157. DB_RX("DA != MA and not multi- or broadcast",0,0,2) ;
  1158. goto abort_frame ;
  1159. }
  1160. }
  1161. }
  1162. /*
  1163. * LLC frame received
  1164. */
  1165. DB_RX("LLC - receive",0,0,4) ;
  1166. mac_drv_rx_complete(smc,rxd,frag_count,len) ;
  1167. }
  1168. else {
  1169. if (!(mb = smt_get_mbuf(smc))) {
  1170. smc->hw.fp.err_stats.err_no_buf++ ;
  1171. DB_RX("No SMbuf; receive terminated",0,0,4) ;
  1172. goto abort_frame ;
  1173. }
  1174. data = smtod(mb,char *) - 1 ;
  1175. /*
  1176. * copy the frame into a SMT_MBuf
  1177. */
  1178. #ifdef USE_OS_CPY
  1179. hwm_cpy_rxd2mb(rxd,data,len) ;
  1180. #else
  1181. for (r=rxd, i=used_frags ; i ; r=r->rxd_next, i--){
  1182. n = le32_to_cpu(r->rxd_rbctrl) & RD_LENGTH ;
  1183. DB_RX("cp SMT frame to mb: len = %d",n,0,6) ;
  1184. memcpy(data,r->rxd_virt,n) ;
  1185. data += n ;
  1186. }
  1187. data = smtod(mb,char *) - 1 ;
  1188. #endif
  1189. fc = *(char *)mb->sm_data = *data ;
  1190. mb->sm_len = len - 1 ; /* len - fc */
  1191. data++ ;
  1192. /*
  1193. * SMT frame received
  1194. */
  1195. switch(fc) {
  1196. case FC_SMT_INFO :
  1197. smc->hw.fp.err_stats.err_smt_frame++ ;
  1198. DB_RX("SMT frame received ",0,0,5) ;
  1199. if (smc->os.hwm.pass_SMT) {
  1200. DB_RX("pass SMT frame ",0,0,5) ;
  1201. mac_drv_rx_complete(smc, rxd,
  1202. frag_count,len) ;
  1203. }
  1204. else {
  1205. DB_RX("requeue RxD",0,0,5) ;
  1206. mac_drv_requeue_rxd(smc,rxd,frag_count);
  1207. }
  1208. smt_received_pack(smc,mb,(int)(rfsw>>25)) ;
  1209. break ;
  1210. case FC_SMT_NSA :
  1211. smc->hw.fp.err_stats.err_smt_frame++ ;
  1212. DB_RX("SMT frame received ",0,0,5) ;
  1213. /* if pass_NSA set pass the NSA frame or */
  1214. /* pass_SMT set and the A-Indicator */
  1215. /* is not set, pass the NSA frame */
  1216. if (smc->os.hwm.pass_NSA ||
  1217. (smc->os.hwm.pass_SMT &&
  1218. !(rfsw & A_INDIC))) {
  1219. DB_RX("pass SMT frame ",0,0,5) ;
  1220. mac_drv_rx_complete(smc, rxd,
  1221. frag_count,len) ;
  1222. }
  1223. else {
  1224. DB_RX("requeue RxD",0,0,5) ;
  1225. mac_drv_requeue_rxd(smc,rxd,frag_count);
  1226. }
  1227. smt_received_pack(smc,mb,(int)(rfsw>>25)) ;
  1228. break ;
  1229. case FC_BEACON :
  1230. if (smc->os.hwm.pass_DB) {
  1231. DB_RX("pass DB frame ",0,0,5) ;
  1232. mac_drv_rx_complete(smc, rxd,
  1233. frag_count,len) ;
  1234. }
  1235. else {
  1236. DB_RX("requeue RxD",0,0,5) ;
  1237. mac_drv_requeue_rxd(smc,rxd,frag_count);
  1238. }
  1239. smt_free_mbuf(smc,mb) ;
  1240. break ;
  1241. default :
  1242. /*
  1243. * unknown FC abord the frame
  1244. */
  1245. DB_RX("unknown FC error",0,0,2) ;
  1246. smt_free_mbuf(smc,mb) ;
  1247. DB_RX("requeue RxD",0,0,5) ;
  1248. mac_drv_requeue_rxd(smc,rxd,frag_count) ;
  1249. if ((fc & 0xf0) == FC_MAC)
  1250. smc->hw.fp.err_stats.err_mac_frame++ ;
  1251. else
  1252. smc->hw.fp.err_stats.err_imp_frame++ ;
  1253. break ;
  1254. }
  1255. }
  1256. DB_RX("next RxD is %x ",queue->rx_curr_get,0,3) ;
  1257. NDD_TRACE("RHx1",queue->rx_curr_get,0,0) ;
  1258. continue ;
  1259. /*--------------------------------------------------------------------*/
  1260. abort_frame:
  1261. DB_RX("requeue RxD",0,0,5) ;
  1262. mac_drv_requeue_rxd(smc,rxd,frag_count) ;
  1263. DB_RX("next RxD is %x ",queue->rx_curr_get,0,3) ;
  1264. NDD_TRACE("RHx2",queue->rx_curr_get,0,0) ;
  1265. }
  1266. rx_end:
  1267. #ifdef ALL_RX_COMPLETE
  1268. mac_drv_all_receives_complete(smc) ;
  1269. #endif
  1270. return ; /* lint bug: needs return detect end of function */
  1271. }
  1272. static void smt_to_llc(struct s_smc *smc, SMbuf *mb)
  1273. {
  1274. u_char fc ;
  1275. DB_RX("send a queued frame to the llc layer",0,0,4) ;
  1276. smc->os.hwm.r.len = mb->sm_len ;
  1277. smc->os.hwm.r.mb_pos = smtod(mb,char *) ;
  1278. fc = *smc->os.hwm.r.mb_pos ;
  1279. (void)mac_drv_rx_init(smc,(int)mb->sm_len,(int)fc,
  1280. smc->os.hwm.r.mb_pos,(int)mb->sm_len) ;
  1281. smt_free_mbuf(smc,mb) ;
  1282. }
  1283. /*
  1284. * BEGIN_MANUAL_ENTRY(hwm_rx_frag)
  1285. * void hwm_rx_frag(smc,virt,phys,len,frame_status)
  1286. *
  1287. * function MACRO (hardware module, hwmtm.h)
  1288. * This function calls dma_master for preparing the
  1289. * system hardware for the DMA transfer and initializes
  1290. * the current RxD with the length and the physical and
  1291. * virtual address of the fragment. Furthermore, it sets the
  1292. * STF and EOF bits depending on the frame status byte,
  1293. * switches the OWN flag of the RxD, so that it is owned by the
  1294. * adapter and issues an rx_start.
  1295. *
  1296. * para virt virtual pointer to the fragment
  1297. * len the length of the fragment
  1298. * frame_status status of the frame, see design description
  1299. *
  1300. * NOTE: It is possible to call this function with a fragment length
  1301. * of zero.
  1302. *
  1303. * END_MANUAL_ENTRY
  1304. */
  1305. void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
  1306. int frame_status)
  1307. {
  1308. struct s_smt_fp_rxd volatile *r ;
  1309. __le32 rbctrl;
  1310. NDD_TRACE("RHfB",virt,len,frame_status) ;
  1311. DB_RX("hwm_rx_frag: len = %d, frame_status = %x\n",len,frame_status,2) ;
  1312. r = smc->hw.fp.rx_q[QUEUE_R1].rx_curr_put ;
  1313. r->rxd_virt = virt ;
  1314. r->rxd_rbadr = cpu_to_le32(phys) ;
  1315. rbctrl = cpu_to_le32( (((__u32)frame_status &
  1316. (FIRST_FRAG|LAST_FRAG))<<26) |
  1317. (((u_long) frame_status & FIRST_FRAG) << 21) |
  1318. BMU_OWN | BMU_CHECK | BMU_EN_IRQ_EOF | len) ;
  1319. r->rxd_rbctrl = rbctrl ;
  1320. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORDEV) ;
  1321. outpd(ADDR(B0_R1_CSR),CSR_START) ;
  1322. smc->hw.fp.rx_q[QUEUE_R1].rx_free-- ;
  1323. smc->hw.fp.rx_q[QUEUE_R1].rx_used++ ;
  1324. smc->hw.fp.rx_q[QUEUE_R1].rx_curr_put = r->rxd_next ;
  1325. NDD_TRACE("RHfE",r,le32_to_cpu(r->rxd_rbadr),0) ;
  1326. }
  1327. /*
  1328. * BEGINN_MANUAL_ENTRY(mac_drv_clear_rx_queue)
  1329. *
  1330. * void mac_drv_clear_rx_queue(smc)
  1331. * struct s_smc *smc ;
  1332. *
  1333. * function DOWNCALL (hardware module, hwmtm.c)
  1334. * mac_drv_clear_rx_queue is called by the OS-specific module
  1335. * after it has issued a card_stop.
  1336. * In this case, the frames in the receive queue are obsolete and
  1337. * should be removed. For removing mac_drv_clear_rx_queue
  1338. * calls dma_master for each RxD and mac_drv_clear_rxd for each
  1339. * receive buffer.
  1340. *
  1341. * NOTE: calling sequence card_stop:
  1342. * CLI_FBI(), card_stop(),
  1343. * mac_drv_clear_tx_queue(), mac_drv_clear_rx_queue(),
  1344. *
  1345. * NOTE: The caller is responsible that the BMUs are idle
  1346. * when this function is called.
  1347. *
  1348. * END_MANUAL_ENTRY
  1349. */
  1350. void mac_drv_clear_rx_queue(struct s_smc *smc)
  1351. {
  1352. struct s_smt_fp_rxd volatile *r ;
  1353. struct s_smt_fp_rxd volatile *next_rxd ;
  1354. struct s_smt_rx_queue *queue ;
  1355. int frag_count ;
  1356. int i ;
  1357. if (smc->hw.hw_state != STOPPED) {
  1358. SK_BREAK() ;
  1359. SMT_PANIC(smc,HWM_E0012,HWM_E0012_MSG) ;
  1360. return ;
  1361. }
  1362. queue = smc->hw.fp.rx[QUEUE_R1] ;
  1363. DB_RX("clear_rx_queue",0,0,5) ;
  1364. /*
  1365. * dma_complete and mac_drv_clear_rxd for all RxDs / receive buffers
  1366. */
  1367. r = queue->rx_curr_get ;
  1368. while (queue->rx_used) {
  1369. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1370. DB_RX("switch OWN bit of RxD 0x%x ",r,0,5) ;
  1371. r->rxd_rbctrl &= ~cpu_to_le32(BMU_OWN) ;
  1372. frag_count = 1 ;
  1373. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORDEV) ;
  1374. r = r->rxd_next ;
  1375. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1376. while (r != queue->rx_curr_put &&
  1377. !(r->rxd_rbctrl & cpu_to_le32(BMU_ST_BUF))) {
  1378. DB_RX("Check STF bit in %x",(void *)r,0,5) ;
  1379. r->rxd_rbctrl &= ~cpu_to_le32(BMU_OWN) ;
  1380. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORDEV) ;
  1381. r = r->rxd_next ;
  1382. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1383. frag_count++ ;
  1384. }
  1385. DB_RX("STF bit found",0,0,5) ;
  1386. next_rxd = r ;
  1387. for (r=queue->rx_curr_get,i=frag_count; i ; r=r->rxd_next,i--){
  1388. DB_RX("dma_complete for RxD %x",(void *)r,0,5) ;
  1389. dma_complete(smc,(union s_fp_descr volatile *)r,DMA_WR);
  1390. }
  1391. DB_RX("mac_drv_clear_rxd: RxD %x frag_count %d ",
  1392. (void *)queue->rx_curr_get,frag_count,5) ;
  1393. mac_drv_clear_rxd(smc,queue->rx_curr_get,frag_count) ;
  1394. queue->rx_curr_get = next_rxd ;
  1395. queue->rx_used -= frag_count ;
  1396. queue->rx_free += frag_count ;
  1397. }
  1398. }
  1399. /*
  1400. -------------------------------------------------------------
  1401. SEND FUNCTIONS:
  1402. -------------------------------------------------------------
  1403. */
  1404. /*
  1405. * BEGIN_MANUAL_ENTRY(hwm_tx_init)
  1406. * int hwm_tx_init(smc,fc,frag_count,frame_len,frame_status)
  1407. *
  1408. * function DOWN_CALL (hardware module, hwmtm.c)
  1409. * hwm_tx_init checks if the frame can be sent through the
  1410. * corresponding send queue.
  1411. *
  1412. * para fc the frame control. To determine through which
  1413. * send queue the frame should be transmitted.
  1414. * 0x50 - 0x57: asynchronous LLC frame
  1415. * 0xD0 - 0xD7: synchronous LLC frame
  1416. * 0x41, 0x4F: SMT frame to the network
  1417. * 0x42: SMT frame to the network and to the local SMT
  1418. * 0x43: SMT frame to the local SMT
  1419. * frag_count count of the fragments for this frame
  1420. * frame_len length of the frame
  1421. * frame_status status of the frame, the send queue bit is already
  1422. * specified
  1423. *
  1424. * return frame_status
  1425. *
  1426. * END_MANUAL_ENTRY
  1427. */
  1428. int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count, int frame_len,
  1429. int frame_status)
  1430. {
  1431. NDD_TRACE("THiB",fc,frag_count,frame_len) ;
  1432. smc->os.hwm.tx_p = smc->hw.fp.tx[frame_status & QUEUE_A0] ;
  1433. smc->os.hwm.tx_descr = TX_DESCRIPTOR | (((u_long)(frame_len-1)&3)<<27) ;
  1434. smc->os.hwm.tx_len = frame_len ;
  1435. DB_TX("hwm_tx_init: fc = %x, len = %d",fc,frame_len,3) ;
  1436. if ((fc & ~(FC_SYNC_BIT|FC_LLC_PRIOR)) == FC_ASYNC_LLC) {
  1437. frame_status |= LAN_TX ;
  1438. }
  1439. else {
  1440. switch (fc) {
  1441. case FC_SMT_INFO :
  1442. case FC_SMT_NSA :
  1443. frame_status |= LAN_TX ;
  1444. break ;
  1445. case FC_SMT_LOC :
  1446. frame_status |= LOC_TX ;
  1447. break ;
  1448. case FC_SMT_LAN_LOC :
  1449. frame_status |= LAN_TX | LOC_TX ;
  1450. break ;
  1451. default :
  1452. SMT_PANIC(smc,HWM_E0010,HWM_E0010_MSG) ;
  1453. }
  1454. }
  1455. if (!smc->hw.mac_ring_is_up) {
  1456. frame_status &= ~LAN_TX ;
  1457. frame_status |= RING_DOWN ;
  1458. DB_TX("Ring is down: terminate LAN_TX",0,0,2) ;
  1459. }
  1460. if (frag_count > smc->os.hwm.tx_p->tx_free) {
  1461. #ifndef NDIS_OS2
  1462. mac_drv_clear_txd(smc) ;
  1463. if (frag_count > smc->os.hwm.tx_p->tx_free) {
  1464. DB_TX("Out of TxDs, terminate LAN_TX",0,0,2) ;
  1465. frame_status &= ~LAN_TX ;
  1466. frame_status |= OUT_OF_TXD ;
  1467. }
  1468. #else
  1469. DB_TX("Out of TxDs, terminate LAN_TX",0,0,2) ;
  1470. frame_status &= ~LAN_TX ;
  1471. frame_status |= OUT_OF_TXD ;
  1472. #endif
  1473. }
  1474. DB_TX("frame_status = %x",frame_status,0,3) ;
  1475. NDD_TRACE("THiE",frame_status,smc->os.hwm.tx_p->tx_free,0) ;
  1476. return(frame_status) ;
  1477. }
  1478. /*
  1479. * BEGIN_MANUAL_ENTRY(hwm_tx_frag)
  1480. * void hwm_tx_frag(smc,virt,phys,len,frame_status)
  1481. *
  1482. * function DOWNCALL (hardware module, hwmtm.c)
  1483. * If the frame should be sent to the LAN, this function calls
  1484. * dma_master, fills the current TxD with the virtual and the
  1485. * physical address, sets the STF and EOF bits dependent on
  1486. * the frame status, and requests the BMU to start the
  1487. * transmit.
  1488. * If the frame should be sent to the local SMT, an SMT_MBuf
  1489. * is allocated if the FIRST_FRAG bit is set in the frame_status.
  1490. * The fragment of the frame is copied into the SMT MBuf.
  1491. * The function smt_received_pack is called if the LAST_FRAG
  1492. * bit is set in the frame_status word.
  1493. *
  1494. * para virt virtual pointer to the fragment
  1495. * len the length of the fragment
  1496. * frame_status status of the frame, see design description
  1497. *
  1498. * return nothing returned, no parameter is modified
  1499. *
  1500. * NOTE: It is possible to invoke this macro with a fragment length
  1501. * of zero.
  1502. *
  1503. * END_MANUAL_ENTRY
  1504. */
  1505. void hwm_tx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
  1506. int frame_status)
  1507. {
  1508. struct s_smt_fp_txd volatile *t ;
  1509. struct s_smt_tx_queue *queue ;
  1510. __le32 tbctrl ;
  1511. queue = smc->os.hwm.tx_p ;
  1512. NDD_TRACE("THfB",virt,len,frame_status) ;
  1513. /* Bug fix: AF / May 31 1999 (#missing)
  1514. * snmpinfo problem reported by IBM is caused by invalid
  1515. * t-pointer (txd) if LAN_TX is not set but LOC_TX only.
  1516. * Set: t = queue->tx_curr_put here !
  1517. */
  1518. t = queue->tx_curr_put ;
  1519. DB_TX("hwm_tx_frag: len = %d, frame_status = %x ",len,frame_status,2) ;
  1520. if (frame_status & LAN_TX) {
  1521. /* '*t' is already defined */
  1522. DB_TX("LAN_TX: TxD = %x, virt = %x ",t,virt,3) ;
  1523. t->txd_virt = virt ;
  1524. t->txd_txdscr = cpu_to_le32(smc->os.hwm.tx_descr) ;
  1525. t->txd_tbadr = cpu_to_le32(phys) ;
  1526. tbctrl = cpu_to_le32((((__u32)frame_status &
  1527. (FIRST_FRAG|LAST_FRAG|EN_IRQ_EOF))<< 26) |
  1528. BMU_OWN|BMU_CHECK |len) ;
  1529. t->txd_tbctrl = tbctrl ;
  1530. #ifndef AIX
  1531. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1532. outpd(queue->tx_bmu_ctl,CSR_START) ;
  1533. #else /* ifndef AIX */
  1534. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1535. if (frame_status & QUEUE_A0) {
  1536. outpd(ADDR(B0_XA_CSR),CSR_START) ;
  1537. }
  1538. else {
  1539. outpd(ADDR(B0_XS_CSR),CSR_START) ;
  1540. }
  1541. #endif
  1542. queue->tx_free-- ;
  1543. queue->tx_used++ ;
  1544. queue->tx_curr_put = t->txd_next ;
  1545. if (frame_status & LAST_FRAG) {
  1546. smc->mib.m[MAC0].fddiMACTransmit_Ct++ ;
  1547. }
  1548. }
  1549. if (frame_status & LOC_TX) {
  1550. DB_TX("LOC_TX: ",0,0,3) ;
  1551. if (frame_status & FIRST_FRAG) {
  1552. if(!(smc->os.hwm.tx_mb = smt_get_mbuf(smc))) {
  1553. smc->hw.fp.err_stats.err_no_buf++ ;
  1554. DB_TX("No SMbuf; transmit terminated",0,0,4) ;
  1555. }
  1556. else {
  1557. smc->os.hwm.tx_data =
  1558. smtod(smc->os.hwm.tx_mb,char *) - 1 ;
  1559. #ifdef USE_OS_CPY
  1560. #ifdef PASS_1ST_TXD_2_TX_COMP
  1561. hwm_cpy_txd2mb(t,smc->os.hwm.tx_data,
  1562. smc->os.hwm.tx_len) ;
  1563. #endif
  1564. #endif
  1565. }
  1566. }
  1567. if (smc->os.hwm.tx_mb) {
  1568. #ifndef USE_OS_CPY
  1569. DB_TX("copy fragment into MBuf ",0,0,3) ;
  1570. memcpy(smc->os.hwm.tx_data,virt,len) ;
  1571. smc->os.hwm.tx_data += len ;
  1572. #endif
  1573. if (frame_status & LAST_FRAG) {
  1574. #ifdef USE_OS_CPY
  1575. #ifndef PASS_1ST_TXD_2_TX_COMP
  1576. /*
  1577. * hwm_cpy_txd2mb(txd,data,len) copies 'len'
  1578. * bytes from the virtual pointer in 'rxd'
  1579. * to 'data'. The virtual pointer of the
  1580. * os-specific tx-buffer should be written
  1581. * in the LAST txd.
  1582. */
  1583. hwm_cpy_txd2mb(t,smc->os.hwm.tx_data,
  1584. smc->os.hwm.tx_len) ;
  1585. #endif /* nPASS_1ST_TXD_2_TX_COMP */
  1586. #endif /* USE_OS_CPY */
  1587. smc->os.hwm.tx_data =
  1588. smtod(smc->os.hwm.tx_mb,char *) - 1 ;
  1589. *(char *)smc->os.hwm.tx_mb->sm_data =
  1590. *smc->os.hwm.tx_data ;
  1591. smc->os.hwm.tx_data++ ;
  1592. smc->os.hwm.tx_mb->sm_len =
  1593. smc->os.hwm.tx_len - 1 ;
  1594. DB_TX("pass LLC frame to SMT ",0,0,3) ;
  1595. smt_received_pack(smc,smc->os.hwm.tx_mb,
  1596. RD_FS_LOCAL) ;
  1597. }
  1598. }
  1599. }
  1600. NDD_TRACE("THfE",t,queue->tx_free,0) ;
  1601. }
  1602. /*
  1603. * queues a receive for later send
  1604. */
  1605. static void queue_llc_rx(struct s_smc *smc, SMbuf *mb)
  1606. {
  1607. DB_GEN("queue_llc_rx: mb = %x",(void *)mb,0,4) ;
  1608. smc->os.hwm.queued_rx_frames++ ;
  1609. mb->sm_next = (SMbuf *)NULL ;
  1610. if (smc->os.hwm.llc_rx_pipe == NULL) {
  1611. smc->os.hwm.llc_rx_pipe = mb ;
  1612. }
  1613. else {
  1614. smc->os.hwm.llc_rx_tail->sm_next = mb ;
  1615. }
  1616. smc->os.hwm.llc_rx_tail = mb ;
  1617. /*
  1618. * force an timer IRQ to receive the data
  1619. */
  1620. if (!smc->os.hwm.isr_flag) {
  1621. smt_force_irq(smc) ;
  1622. }
  1623. }
  1624. /*
  1625. * get a SMbuf from the llc_rx_queue
  1626. */
  1627. static SMbuf *get_llc_rx(struct s_smc *smc)
  1628. {
  1629. SMbuf *mb ;
  1630. if ((mb = smc->os.hwm.llc_rx_pipe)) {
  1631. smc->os.hwm.queued_rx_frames-- ;
  1632. smc->os.hwm.llc_rx_pipe = mb->sm_next ;
  1633. }
  1634. DB_GEN("get_llc_rx: mb = 0x%x",(void *)mb,0,4) ;
  1635. return(mb) ;
  1636. }
  1637. /*
  1638. * queues a transmit SMT MBuf during the time were the MBuf is
  1639. * queued the TxD ring
  1640. */
  1641. static void queue_txd_mb(struct s_smc *smc, SMbuf *mb)
  1642. {
  1643. DB_GEN("_rx: queue_txd_mb = %x",(void *)mb,0,4) ;
  1644. smc->os.hwm.queued_txd_mb++ ;
  1645. mb->sm_next = (SMbuf *)NULL ;
  1646. if (smc->os.hwm.txd_tx_pipe == NULL) {
  1647. smc->os.hwm.txd_tx_pipe = mb ;
  1648. }
  1649. else {
  1650. smc->os.hwm.txd_tx_tail->sm_next = mb ;
  1651. }
  1652. smc->os.hwm.txd_tx_tail = mb ;
  1653. }
  1654. /*
  1655. * get a SMbuf from the txd_tx_queue
  1656. */
  1657. static SMbuf *get_txd_mb(struct s_smc *smc)
  1658. {
  1659. SMbuf *mb ;
  1660. if ((mb = smc->os.hwm.txd_tx_pipe)) {
  1661. smc->os.hwm.queued_txd_mb-- ;
  1662. smc->os.hwm.txd_tx_pipe = mb->sm_next ;
  1663. }
  1664. DB_GEN("get_txd_mb: mb = 0x%x",(void *)mb,0,4) ;
  1665. return(mb) ;
  1666. }
  1667. /*
  1668. * SMT Send function
  1669. */
  1670. void smt_send_mbuf(struct s_smc *smc, SMbuf *mb, int fc)
  1671. {
  1672. char far *data ;
  1673. int len ;
  1674. int n ;
  1675. int i ;
  1676. int frag_count ;
  1677. int frame_status ;
  1678. SK_LOC_DECL(char far,*virt[3]) ;
  1679. int frag_len[3] ;
  1680. struct s_smt_tx_queue *queue ;
  1681. struct s_smt_fp_txd volatile *t ;
  1682. u_long phys ;
  1683. __le32 tbctrl;
  1684. NDD_TRACE("THSB",mb,fc,0) ;
  1685. DB_TX("smt_send_mbuf: mb = 0x%x, fc = 0x%x",mb,fc,4) ;
  1686. mb->sm_off-- ; /* set to fc */
  1687. mb->sm_len++ ; /* + fc */
  1688. data = smtod(mb,char *) ;
  1689. *data = fc ;
  1690. if (fc == FC_SMT_LOC)
  1691. *data = FC_SMT_INFO ;
  1692. /*
  1693. * determine the frag count and the virt addresses of the frags
  1694. */
  1695. frag_count = 0 ;
  1696. len = mb->sm_len ;
  1697. while (len) {
  1698. n = SMT_PAGESIZE - ((long)data & (SMT_PAGESIZE-1)) ;
  1699. if (n >= len) {
  1700. n = len ;
  1701. }
  1702. DB_TX("frag: virt/len = 0x%x/%d ",(void *)data,n,5) ;
  1703. virt[frag_count] = data ;
  1704. frag_len[frag_count] = n ;
  1705. frag_count++ ;
  1706. len -= n ;
  1707. data += n ;
  1708. }
  1709. /*
  1710. * determine the frame status
  1711. */
  1712. queue = smc->hw.fp.tx[QUEUE_A0] ;
  1713. if (fc == FC_BEACON || fc == FC_SMT_LOC) {
  1714. frame_status = LOC_TX ;
  1715. }
  1716. else {
  1717. frame_status = LAN_TX ;
  1718. if ((smc->os.hwm.pass_NSA &&(fc == FC_SMT_NSA)) ||
  1719. (smc->os.hwm.pass_SMT &&(fc == FC_SMT_INFO)))
  1720. frame_status |= LOC_TX ;
  1721. }
  1722. if (!smc->hw.mac_ring_is_up || frag_count > queue->tx_free) {
  1723. frame_status &= ~LAN_TX;
  1724. if (frame_status) {
  1725. DB_TX("Ring is down: terminate LAN_TX",0,0,2) ;
  1726. }
  1727. else {
  1728. DB_TX("Ring is down: terminate transmission",0,0,2) ;
  1729. smt_free_mbuf(smc,mb) ;
  1730. return ;
  1731. }
  1732. }
  1733. DB_TX("frame_status = 0x%x ",frame_status,0,5) ;
  1734. if ((frame_status & LAN_TX) && (frame_status & LOC_TX)) {
  1735. mb->sm_use_count = 2 ;
  1736. }
  1737. if (frame_status & LAN_TX) {
  1738. t = queue->tx_curr_put ;
  1739. frame_status |= FIRST_FRAG ;
  1740. for (i = 0; i < frag_count; i++) {
  1741. DB_TX("init TxD = 0x%x",(void *)t,0,5) ;
  1742. if (i == frag_count-1) {
  1743. frame_status |= LAST_FRAG ;
  1744. t->txd_txdscr = cpu_to_le32(TX_DESCRIPTOR |
  1745. (((__u32)(mb->sm_len-1)&3) << 27)) ;
  1746. }
  1747. t->txd_virt = virt[i] ;
  1748. phys = dma_master(smc, (void far *)virt[i],
  1749. frag_len[i], DMA_RD|SMT_BUF) ;
  1750. t->txd_tbadr = cpu_to_le32(phys) ;
  1751. tbctrl = cpu_to_le32((((__u32)frame_status &
  1752. (FIRST_FRAG|LAST_FRAG)) << 26) |
  1753. BMU_OWN | BMU_CHECK | BMU_SMT_TX |frag_len[i]) ;
  1754. t->txd_tbctrl = tbctrl ;
  1755. #ifndef AIX
  1756. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1757. outpd(queue->tx_bmu_ctl,CSR_START) ;
  1758. #else
  1759. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1760. outpd(ADDR(B0_XA_CSR),CSR_START) ;
  1761. #endif
  1762. frame_status &= ~FIRST_FRAG ;
  1763. queue->tx_curr_put = t = t->txd_next ;
  1764. queue->tx_free-- ;
  1765. queue->tx_used++ ;
  1766. }
  1767. smc->mib.m[MAC0].fddiMACTransmit_Ct++ ;
  1768. queue_txd_mb(smc,mb) ;
  1769. }
  1770. if (frame_status & LOC_TX) {
  1771. DB_TX("pass Mbuf to LLC queue",0,0,5) ;
  1772. queue_llc_rx(smc,mb) ;
  1773. }
  1774. /*
  1775. * We need to unqueue the free SMT_MBUFs here, because it may
  1776. * be that the SMT want's to send more than 1 frame for one down call
  1777. */
  1778. mac_drv_clear_txd(smc) ;
  1779. NDD_TRACE("THSE",t,queue->tx_free,frag_count) ;
  1780. }
  1781. /* BEGIN_MANUAL_ENTRY(mac_drv_clear_txd)
  1782. * void mac_drv_clear_txd(smc)
  1783. *
  1784. * function DOWNCALL (hardware module, hwmtm.c)
  1785. * mac_drv_clear_txd searches in both send queues for TxD's
  1786. * which were finished by the adapter. It calls dma_complete
  1787. * for each TxD. If the last fragment of an LLC frame is
  1788. * reached, it calls mac_drv_tx_complete to release the
  1789. * send buffer.
  1790. *
  1791. * return nothing
  1792. *
  1793. * END_MANUAL_ENTRY
  1794. */
  1795. static void mac_drv_clear_txd(struct s_smc *smc)
  1796. {
  1797. struct s_smt_tx_queue *queue ;
  1798. struct s_smt_fp_txd volatile *t1 ;
  1799. struct s_smt_fp_txd volatile *t2 = NULL ;
  1800. SMbuf *mb ;
  1801. u_long tbctrl ;
  1802. int i ;
  1803. int frag_count ;
  1804. int n ;
  1805. NDD_TRACE("THcB",0,0,0) ;
  1806. for (i = QUEUE_S; i <= QUEUE_A0; i++) {
  1807. queue = smc->hw.fp.tx[i] ;
  1808. t1 = queue->tx_curr_get ;
  1809. DB_TX("clear_txd: QUEUE = %d (0=sync/1=async)",i,0,5) ;
  1810. for ( ; ; ) {
  1811. frag_count = 0 ;
  1812. do {
  1813. DRV_BUF_FLUSH(t1,DDI_DMA_SYNC_FORCPU) ;
  1814. DB_TX("check OWN/EOF bit of TxD 0x%x",t1,0,5) ;
  1815. tbctrl = le32_to_cpu(CR_READ(t1->txd_tbctrl));
  1816. if (tbctrl & BMU_OWN || !queue->tx_used){
  1817. DB_TX("End of TxDs queue %d",i,0,4) ;
  1818. goto free_next_queue ; /* next queue */
  1819. }
  1820. t1 = t1->txd_next ;
  1821. frag_count++ ;
  1822. } while (!(tbctrl & BMU_EOF)) ;
  1823. t1 = queue->tx_curr_get ;
  1824. for (n = frag_count; n; n--) {
  1825. tbctrl = le32_to_cpu(t1->txd_tbctrl) ;
  1826. dma_complete(smc,
  1827. (union s_fp_descr volatile *) t1,
  1828. (int) (DMA_RD |
  1829. ((tbctrl & BMU_SMT_TX) >> 18))) ;
  1830. t2 = t1 ;
  1831. t1 = t1->txd_next ;
  1832. }
  1833. if (tbctrl & BMU_SMT_TX) {
  1834. mb = get_txd_mb(smc) ;
  1835. smt_free_mbuf(smc,mb) ;
  1836. }
  1837. else {
  1838. #ifndef PASS_1ST_TXD_2_TX_COMP
  1839. DB_TX("mac_drv_tx_comp for TxD 0x%x",t2,0,4) ;
  1840. mac_drv_tx_complete(smc,t2) ;
  1841. #else
  1842. DB_TX("mac_drv_tx_comp for TxD 0x%x",
  1843. queue->tx_curr_get,0,4) ;
  1844. mac_drv_tx_complete(smc,queue->tx_curr_get) ;
  1845. #endif
  1846. }
  1847. queue->tx_curr_get = t1 ;
  1848. queue->tx_free += frag_count ;
  1849. queue->tx_used -= frag_count ;
  1850. }
  1851. free_next_queue: ;
  1852. }
  1853. NDD_TRACE("THcE",0,0,0) ;
  1854. }
  1855. /*
  1856. * BEGINN_MANUAL_ENTRY(mac_drv_clear_tx_queue)
  1857. *
  1858. * void mac_drv_clear_tx_queue(smc)
  1859. * struct s_smc *smc ;
  1860. *
  1861. * function DOWNCALL (hardware module, hwmtm.c)
  1862. * mac_drv_clear_tx_queue is called from the SMT when
  1863. * the RMT state machine has entered the ISOLATE state.
  1864. * This function is also called by the os-specific module
  1865. * after it has called the function card_stop().
  1866. * In this case, the frames in the send queues are obsolete and
  1867. * should be removed.
  1868. *
  1869. * note calling sequence:
  1870. * CLI_FBI(), card_stop(),
  1871. * mac_drv_clear_tx_queue(), mac_drv_clear_rx_queue(),
  1872. *
  1873. * NOTE: The caller is responsible that the BMUs are idle
  1874. * when this function is called.
  1875. *
  1876. * END_MANUAL_ENTRY
  1877. */
  1878. void mac_drv_clear_tx_queue(struct s_smc *smc)
  1879. {
  1880. struct s_smt_fp_txd volatile *t ;
  1881. struct s_smt_tx_queue *queue ;
  1882. int tx_used ;
  1883. int i ;
  1884. if (smc->hw.hw_state != STOPPED) {
  1885. SK_BREAK() ;
  1886. SMT_PANIC(smc,HWM_E0011,HWM_E0011_MSG) ;
  1887. return ;
  1888. }
  1889. for (i = QUEUE_S; i <= QUEUE_A0; i++) {
  1890. queue = smc->hw.fp.tx[i] ;
  1891. DB_TX("clear_tx_queue: QUEUE = %d (0=sync/1=async)",i,0,5) ;
  1892. /*
  1893. * switch the OWN bit of all pending frames to the host
  1894. */
  1895. t = queue->tx_curr_get ;
  1896. tx_used = queue->tx_used ;
  1897. while (tx_used) {
  1898. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORCPU) ;
  1899. DB_TX("switch OWN bit of TxD 0x%x ",t,0,5) ;
  1900. t->txd_tbctrl &= ~cpu_to_le32(BMU_OWN) ;
  1901. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1902. t = t->txd_next ;
  1903. tx_used-- ;
  1904. }
  1905. }
  1906. /*
  1907. * release all TxD's for both send queues
  1908. */
  1909. mac_drv_clear_txd(smc) ;
  1910. for (i = QUEUE_S; i <= QUEUE_A0; i++) {
  1911. queue = smc->hw.fp.tx[i] ;
  1912. t = queue->tx_curr_get ;
  1913. /*
  1914. * write the phys pointer of the NEXT descriptor into the
  1915. * BMU's current address descriptor pointer and set
  1916. * tx_curr_get and tx_curr_put to this position
  1917. */
  1918. if (i == QUEUE_S) {
  1919. outpd(ADDR(B5_XS_DA),le32_to_cpu(t->txd_ntdadr)) ;
  1920. }
  1921. else {
  1922. outpd(ADDR(B5_XA_DA),le32_to_cpu(t->txd_ntdadr)) ;
  1923. }
  1924. queue->tx_curr_put = queue->tx_curr_get->txd_next ;
  1925. queue->tx_curr_get = queue->tx_curr_put ;
  1926. }
  1927. }
  1928. /*
  1929. -------------------------------------------------------------
  1930. TEST FUNCTIONS:
  1931. -------------------------------------------------------------
  1932. */
  1933. #ifdef DEBUG
  1934. /*
  1935. * BEGIN_MANUAL_ENTRY(mac_drv_debug_lev)
  1936. * void mac_drv_debug_lev(smc,flag,lev)
  1937. *
  1938. * function DOWNCALL (drvsr.c)
  1939. * To get a special debug info the user can assign a debug level
  1940. * to any debug flag.
  1941. *
  1942. * para flag debug flag, possible values are:
  1943. * = 0: reset all debug flags (the defined level is
  1944. * ignored)
  1945. * = 1: debug.d_smtf
  1946. * = 2: debug.d_smt
  1947. * = 3: debug.d_ecm
  1948. * = 4: debug.d_rmt
  1949. * = 5: debug.d_cfm
  1950. * = 6: debug.d_pcm
  1951. *
  1952. * = 10: debug.d_os.hwm_rx (hardware module receive path)
  1953. * = 11: debug.d_os.hwm_tx(hardware module transmit path)
  1954. * = 12: debug.d_os.hwm_gen(hardware module general flag)
  1955. *
  1956. * lev debug level
  1957. *
  1958. * END_MANUAL_ENTRY
  1959. */
  1960. void mac_drv_debug_lev(struct s_smc *smc, int flag, int lev)
  1961. {
  1962. switch(flag) {
  1963. case (int)NULL:
  1964. DB_P.d_smtf = DB_P.d_smt = DB_P.d_ecm = DB_P.d_rmt = 0 ;
  1965. DB_P.d_cfm = 0 ;
  1966. DB_P.d_os.hwm_rx = DB_P.d_os.hwm_tx = DB_P.d_os.hwm_gen = 0 ;
  1967. #ifdef SBA
  1968. DB_P.d_sba = 0 ;
  1969. #endif
  1970. #ifdef ESS
  1971. DB_P.d_ess = 0 ;
  1972. #endif
  1973. break ;
  1974. case DEBUG_SMTF:
  1975. DB_P.d_smtf = lev ;
  1976. break ;
  1977. case DEBUG_SMT:
  1978. DB_P.d_smt = lev ;
  1979. break ;
  1980. case DEBUG_ECM:
  1981. DB_P.d_ecm = lev ;
  1982. break ;
  1983. case DEBUG_RMT:
  1984. DB_P.d_rmt = lev ;
  1985. break ;
  1986. case DEBUG_CFM:
  1987. DB_P.d_cfm = lev ;
  1988. break ;
  1989. case DEBUG_PCM:
  1990. DB_P.d_pcm = lev ;
  1991. break ;
  1992. case DEBUG_SBA:
  1993. #ifdef SBA
  1994. DB_P.d_sba = lev ;
  1995. #endif
  1996. break ;
  1997. case DEBUG_ESS:
  1998. #ifdef ESS
  1999. DB_P.d_ess = lev ;
  2000. #endif
  2001. break ;
  2002. case DB_HWM_RX:
  2003. DB_P.d_os.hwm_rx = lev ;
  2004. break ;
  2005. case DB_HWM_TX:
  2006. DB_P.d_os.hwm_tx = lev ;
  2007. break ;
  2008. case DB_HWM_GEN:
  2009. DB_P.d_os.hwm_gen = lev ;
  2010. break ;
  2011. default:
  2012. break ;
  2013. }
  2014. }
  2015. #endif