hwmtm.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189
  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) (u_long)(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 = AIX_REVERSE(BMU_CHECK) ;
  306. d2->r.rxd_next = &d1->r ;
  307. phys = mac_drv_virt2phys(smc,(void *)d1) ;
  308. d2->r.rxd_nrdadr = AIX_REVERSE(phys) ;
  309. }
  310. DB_GEN("descr ring ends at = %x ",(void *)d1,0,3) ;
  311. d1->r.rxd_rbctrl = AIX_REVERSE(BMU_CHECK) ;
  312. d1->r.rxd_next = &start->r ;
  313. phys = mac_drv_virt2phys(smc,(void *)start) ;
  314. d1->r.rxd_nrdadr = AIX_REVERSE(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 = AIX_REVERSE(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 = AIX_REVERSE(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 = AIX_REVERSE(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 = AIX_REVERSE(t->txd_ntdadr) ;
  544. t = queue->tx_curr_get ;
  545. while (tx_used) {
  546. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORCPU) ;
  547. tbctrl = AIX_REVERSE(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 &= AIX_REVERSE(~BMU_OWN) ;
  557. }
  558. }
  559. phys = AIX_REVERSE(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 = AIX_REVERSE(r->rxd_nrdadr) ;
  591. r = queue->rx_curr_get ;
  592. while (rx_used) {
  593. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  594. rbctrl = AIX_REVERSE(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 &= AIX_REVERSE(~BMU_OWN) ;
  604. }
  605. }
  606. phys = AIX_REVERSE(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 = CR_READ(r->rxd_rbctrl) ;
  1003. rbctrl = AIX_REVERSE(rbctrl) ;
  1004. if (rbctrl & BMU_OWN) {
  1005. NDD_TRACE("RHxE",r,rfsw,rbctrl) ;
  1006. DB_RX("End of RxDs",0,0,4) ;
  1007. goto rx_end ;
  1008. }
  1009. /*
  1010. * out of RxD detection
  1011. */
  1012. if (!rx_used) {
  1013. SK_BREAK() ;
  1014. SMT_PANIC(smc,HWM_E0009,HWM_E0009_MSG) ;
  1015. /* Either we don't have an RxD or all
  1016. * RxDs are filled. Therefore it's allowed
  1017. * for to set the STOPPED flag */
  1018. smc->hw.hw_state = STOPPED ;
  1019. mac_drv_clear_rx_queue(smc) ;
  1020. smc->hw.hw_state = STARTED ;
  1021. mac_drv_fill_rxd(smc) ;
  1022. smc->os.hwm.detec_count = 0 ;
  1023. goto rx_end ;
  1024. }
  1025. rfsw = AIX_REVERSE(r->rxd_rfsw) ;
  1026. if ((rbctrl & BMU_STF) != ((rbctrl & BMU_ST_BUF) <<5)) {
  1027. /*
  1028. * The BMU_STF bit is deleted, 1 frame is
  1029. * placed into more than 1 rx buffer
  1030. *
  1031. * skip frame by setting the rx len to 0
  1032. *
  1033. * if fragment count == 0
  1034. * The missing STF bit belongs to the
  1035. * current frame, search for the
  1036. * EOF bit to complete the frame
  1037. * else
  1038. * the fragment belongs to the next frame,
  1039. * exit the loop and process the frame
  1040. */
  1041. SK_BREAK() ;
  1042. rfsw = 0 ;
  1043. if (frag_count) {
  1044. break ;
  1045. }
  1046. }
  1047. n += rbctrl & 0xffff ;
  1048. r = r->rxd_next ;
  1049. frag_count++ ;
  1050. rx_used-- ;
  1051. } while (!(rbctrl & BMU_EOF)) ;
  1052. used_frags = frag_count ;
  1053. DB_RX("EOF set in RxD, used_frags = %d ",used_frags,0,5) ;
  1054. /* may be next 2 DRV_BUF_FLUSH() can be skipped, because */
  1055. /* BMU_ST_BUF will not be changed by the ASIC */
  1056. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1057. while (rx_used && !(r->rxd_rbctrl & AIX_REVERSE(BMU_ST_BUF))) {
  1058. DB_RX("Check STF bit in %x",(void *)r,0,5) ;
  1059. r = r->rxd_next ;
  1060. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1061. frag_count++ ;
  1062. rx_used-- ;
  1063. }
  1064. DB_RX("STF bit found",0,0,5) ;
  1065. /*
  1066. * The received frame is finished for the process receive
  1067. */
  1068. rxd = queue->rx_curr_get ;
  1069. queue->rx_curr_get = r ;
  1070. queue->rx_free += frag_count ;
  1071. queue->rx_used = rx_used ;
  1072. /*
  1073. * ASIC Errata no. 7 (STF - Bit Bug)
  1074. */
  1075. rxd->rxd_rbctrl &= AIX_REVERSE(~BMU_STF) ;
  1076. for (r=rxd, i=frag_count ; i ; r=r->rxd_next, i--){
  1077. DB_RX("dma_complete for RxD %x",(void *)r,0,5) ;
  1078. dma_complete(smc,(union s_fp_descr volatile *)r,DMA_WR);
  1079. }
  1080. smc->hw.fp.err_stats.err_valid++ ;
  1081. smc->mib.m[MAC0].fddiMACCopied_Ct++ ;
  1082. /* the length of the data including the FC */
  1083. len = (rfsw & RD_LENGTH) - 4 ;
  1084. DB_RX("frame length = %d",len,0,4) ;
  1085. /*
  1086. * check the frame_lenght and all error flags
  1087. */
  1088. if (rfsw & (RX_MSRABT|RX_FS_E|RX_FS_CRC|RX_FS_IMPL)){
  1089. if (rfsw & RD_S_MSRABT) {
  1090. DB_RX("Frame aborted by the FORMAC",0,0,2) ;
  1091. smc->hw.fp.err_stats.err_abort++ ;
  1092. }
  1093. /*
  1094. * check frame status
  1095. */
  1096. if (rfsw & RD_S_SEAC2) {
  1097. DB_RX("E-Indicator set",0,0,2) ;
  1098. smc->hw.fp.err_stats.err_e_indicator++ ;
  1099. }
  1100. if (rfsw & RD_S_SFRMERR) {
  1101. DB_RX("CRC error",0,0,2) ;
  1102. smc->hw.fp.err_stats.err_crc++ ;
  1103. }
  1104. if (rfsw & RX_FS_IMPL) {
  1105. DB_RX("Implementer frame",0,0,2) ;
  1106. smc->hw.fp.err_stats.err_imp_frame++ ;
  1107. }
  1108. goto abort_frame ;
  1109. }
  1110. if (len > FDDI_RAW_MTU-4) {
  1111. DB_RX("Frame too long error",0,0,2) ;
  1112. smc->hw.fp.err_stats.err_too_long++ ;
  1113. goto abort_frame ;
  1114. }
  1115. /*
  1116. * SUPERNET 3 Bug: FORMAC delivers status words
  1117. * of aborded frames to the BMU
  1118. */
  1119. if (len <= 4) {
  1120. DB_RX("Frame length = 0",0,0,2) ;
  1121. goto abort_frame ;
  1122. }
  1123. if (len != (n-4)) {
  1124. DB_RX("BMU: rx len differs: [%d:%d]",len,n,4);
  1125. smc->os.hwm.rx_len_error++ ;
  1126. goto abort_frame ;
  1127. }
  1128. /*
  1129. * Check SA == MA
  1130. */
  1131. virt = (u_char far *) rxd->rxd_virt ;
  1132. DB_RX("FC = %x",*virt,0,2) ;
  1133. if (virt[12] == MA[5] &&
  1134. virt[11] == MA[4] &&
  1135. virt[10] == MA[3] &&
  1136. virt[9] == MA[2] &&
  1137. virt[8] == MA[1] &&
  1138. (virt[7] & ~GROUP_ADDR_BIT) == MA[0]) {
  1139. goto abort_frame ;
  1140. }
  1141. /*
  1142. * test if LLC frame
  1143. */
  1144. if (rfsw & RX_FS_LLC) {
  1145. /*
  1146. * if pass_llc_promisc is disable
  1147. * if DA != Multicast or Broadcast or DA!=MA
  1148. * abort the frame
  1149. */
  1150. if (!smc->os.hwm.pass_llc_promisc) {
  1151. if(!(virt[1] & GROUP_ADDR_BIT)) {
  1152. if (virt[6] != MA[5] ||
  1153. virt[5] != MA[4] ||
  1154. virt[4] != MA[3] ||
  1155. virt[3] != MA[2] ||
  1156. virt[2] != MA[1] ||
  1157. virt[1] != MA[0]) {
  1158. DB_RX("DA != MA and not multi- or broadcast",0,0,2) ;
  1159. goto abort_frame ;
  1160. }
  1161. }
  1162. }
  1163. /*
  1164. * LLC frame received
  1165. */
  1166. DB_RX("LLC - receive",0,0,4) ;
  1167. mac_drv_rx_complete(smc,rxd,frag_count,len) ;
  1168. }
  1169. else {
  1170. if (!(mb = smt_get_mbuf(smc))) {
  1171. smc->hw.fp.err_stats.err_no_buf++ ;
  1172. DB_RX("No SMbuf; receive terminated",0,0,4) ;
  1173. goto abort_frame ;
  1174. }
  1175. data = smtod(mb,char *) - 1 ;
  1176. /*
  1177. * copy the frame into a SMT_MBuf
  1178. */
  1179. #ifdef USE_OS_CPY
  1180. hwm_cpy_rxd2mb(rxd,data,len) ;
  1181. #else
  1182. for (r=rxd, i=used_frags ; i ; r=r->rxd_next, i--){
  1183. n = AIX_REVERSE(r->rxd_rbctrl) & RD_LENGTH ;
  1184. DB_RX("cp SMT frame to mb: len = %d",n,0,6) ;
  1185. memcpy(data,r->rxd_virt,n) ;
  1186. data += n ;
  1187. }
  1188. data = smtod(mb,char *) - 1 ;
  1189. #endif
  1190. fc = *(char *)mb->sm_data = *data ;
  1191. mb->sm_len = len - 1 ; /* len - fc */
  1192. data++ ;
  1193. /*
  1194. * SMT frame received
  1195. */
  1196. switch(fc) {
  1197. case FC_SMT_INFO :
  1198. smc->hw.fp.err_stats.err_smt_frame++ ;
  1199. DB_RX("SMT frame received ",0,0,5) ;
  1200. if (smc->os.hwm.pass_SMT) {
  1201. DB_RX("pass SMT frame ",0,0,5) ;
  1202. mac_drv_rx_complete(smc, rxd,
  1203. frag_count,len) ;
  1204. }
  1205. else {
  1206. DB_RX("requeue RxD",0,0,5) ;
  1207. mac_drv_requeue_rxd(smc,rxd,frag_count);
  1208. }
  1209. smt_received_pack(smc,mb,(int)(rfsw>>25)) ;
  1210. break ;
  1211. case FC_SMT_NSA :
  1212. smc->hw.fp.err_stats.err_smt_frame++ ;
  1213. DB_RX("SMT frame received ",0,0,5) ;
  1214. /* if pass_NSA set pass the NSA frame or */
  1215. /* pass_SMT set and the A-Indicator */
  1216. /* is not set, pass the NSA frame */
  1217. if (smc->os.hwm.pass_NSA ||
  1218. (smc->os.hwm.pass_SMT &&
  1219. !(rfsw & A_INDIC))) {
  1220. DB_RX("pass SMT frame ",0,0,5) ;
  1221. mac_drv_rx_complete(smc, rxd,
  1222. frag_count,len) ;
  1223. }
  1224. else {
  1225. DB_RX("requeue RxD",0,0,5) ;
  1226. mac_drv_requeue_rxd(smc,rxd,frag_count);
  1227. }
  1228. smt_received_pack(smc,mb,(int)(rfsw>>25)) ;
  1229. break ;
  1230. case FC_BEACON :
  1231. if (smc->os.hwm.pass_DB) {
  1232. DB_RX("pass DB frame ",0,0,5) ;
  1233. mac_drv_rx_complete(smc, rxd,
  1234. frag_count,len) ;
  1235. }
  1236. else {
  1237. DB_RX("requeue RxD",0,0,5) ;
  1238. mac_drv_requeue_rxd(smc,rxd,frag_count);
  1239. }
  1240. smt_free_mbuf(smc,mb) ;
  1241. break ;
  1242. default :
  1243. /*
  1244. * unknown FC abord the frame
  1245. */
  1246. DB_RX("unknown FC error",0,0,2) ;
  1247. smt_free_mbuf(smc,mb) ;
  1248. DB_RX("requeue RxD",0,0,5) ;
  1249. mac_drv_requeue_rxd(smc,rxd,frag_count) ;
  1250. if ((fc & 0xf0) == FC_MAC)
  1251. smc->hw.fp.err_stats.err_mac_frame++ ;
  1252. else
  1253. smc->hw.fp.err_stats.err_imp_frame++ ;
  1254. break ;
  1255. }
  1256. }
  1257. DB_RX("next RxD is %x ",queue->rx_curr_get,0,3) ;
  1258. NDD_TRACE("RHx1",queue->rx_curr_get,0,0) ;
  1259. continue ;
  1260. /*--------------------------------------------------------------------*/
  1261. abort_frame:
  1262. DB_RX("requeue RxD",0,0,5) ;
  1263. mac_drv_requeue_rxd(smc,rxd,frag_count) ;
  1264. DB_RX("next RxD is %x ",queue->rx_curr_get,0,3) ;
  1265. NDD_TRACE("RHx2",queue->rx_curr_get,0,0) ;
  1266. }
  1267. rx_end:
  1268. #ifdef ALL_RX_COMPLETE
  1269. mac_drv_all_receives_complete(smc) ;
  1270. #endif
  1271. return ; /* lint bug: needs return detect end of function */
  1272. }
  1273. static void smt_to_llc(struct s_smc *smc, SMbuf *mb)
  1274. {
  1275. u_char fc ;
  1276. DB_RX("send a queued frame to the llc layer",0,0,4) ;
  1277. smc->os.hwm.r.len = mb->sm_len ;
  1278. smc->os.hwm.r.mb_pos = smtod(mb,char *) ;
  1279. fc = *smc->os.hwm.r.mb_pos ;
  1280. (void)mac_drv_rx_init(smc,(int)mb->sm_len,(int)fc,
  1281. smc->os.hwm.r.mb_pos,(int)mb->sm_len) ;
  1282. smt_free_mbuf(smc,mb) ;
  1283. }
  1284. /*
  1285. * BEGIN_MANUAL_ENTRY(hwm_rx_frag)
  1286. * void hwm_rx_frag(smc,virt,phys,len,frame_status)
  1287. *
  1288. * function MACRO (hardware module, hwmtm.h)
  1289. * This function calls dma_master for preparing the
  1290. * system hardware for the DMA transfer and initializes
  1291. * the current RxD with the length and the physical and
  1292. * virtual address of the fragment. Furthermore, it sets the
  1293. * STF and EOF bits depending on the frame status byte,
  1294. * switches the OWN flag of the RxD, so that it is owned by the
  1295. * adapter and issues an rx_start.
  1296. *
  1297. * para virt virtual pointer to the fragment
  1298. * len the length of the fragment
  1299. * frame_status status of the frame, see design description
  1300. *
  1301. * NOTE: It is possible to call this function with a fragment length
  1302. * of zero.
  1303. *
  1304. * END_MANUAL_ENTRY
  1305. */
  1306. void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
  1307. int frame_status)
  1308. {
  1309. struct s_smt_fp_rxd volatile *r ;
  1310. u_int rbctrl ;
  1311. NDD_TRACE("RHfB",virt,len,frame_status) ;
  1312. DB_RX("hwm_rx_frag: len = %d, frame_status = %x\n",len,frame_status,2) ;
  1313. r = smc->hw.fp.rx_q[QUEUE_R1].rx_curr_put ;
  1314. r->rxd_virt = virt ;
  1315. r->rxd_rbadr = AIX_REVERSE(phys) ;
  1316. rbctrl = AIX_REVERSE( (((u_long)frame_status &
  1317. (FIRST_FRAG|LAST_FRAG))<<26) |
  1318. (((u_long) frame_status & FIRST_FRAG) << 21) |
  1319. BMU_OWN | BMU_CHECK | BMU_EN_IRQ_EOF | len) ;
  1320. r->rxd_rbctrl = rbctrl ;
  1321. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORDEV) ;
  1322. outpd(ADDR(B0_R1_CSR),CSR_START) ;
  1323. smc->hw.fp.rx_q[QUEUE_R1].rx_free-- ;
  1324. smc->hw.fp.rx_q[QUEUE_R1].rx_used++ ;
  1325. smc->hw.fp.rx_q[QUEUE_R1].rx_curr_put = r->rxd_next ;
  1326. NDD_TRACE("RHfE",r,AIX_REVERSE(r->rxd_rbadr),0) ;
  1327. }
  1328. /*
  1329. * BEGINN_MANUAL_ENTRY(mac_drv_clear_rx_queue)
  1330. *
  1331. * void mac_drv_clear_rx_queue(smc)
  1332. * struct s_smc *smc ;
  1333. *
  1334. * function DOWNCALL (hardware module, hwmtm.c)
  1335. * mac_drv_clear_rx_queue is called by the OS-specific module
  1336. * after it has issued a card_stop.
  1337. * In this case, the frames in the receive queue are obsolete and
  1338. * should be removed. For removing mac_drv_clear_rx_queue
  1339. * calls dma_master for each RxD and mac_drv_clear_rxd for each
  1340. * receive buffer.
  1341. *
  1342. * NOTE: calling sequence card_stop:
  1343. * CLI_FBI(), card_stop(),
  1344. * mac_drv_clear_tx_queue(), mac_drv_clear_rx_queue(),
  1345. *
  1346. * NOTE: The caller is responsible that the BMUs are idle
  1347. * when this function is called.
  1348. *
  1349. * END_MANUAL_ENTRY
  1350. */
  1351. void mac_drv_clear_rx_queue(struct s_smc *smc)
  1352. {
  1353. struct s_smt_fp_rxd volatile *r ;
  1354. struct s_smt_fp_rxd volatile *next_rxd ;
  1355. struct s_smt_rx_queue *queue ;
  1356. int frag_count ;
  1357. int i ;
  1358. if (smc->hw.hw_state != STOPPED) {
  1359. SK_BREAK() ;
  1360. SMT_PANIC(smc,HWM_E0012,HWM_E0012_MSG) ;
  1361. return ;
  1362. }
  1363. queue = smc->hw.fp.rx[QUEUE_R1] ;
  1364. DB_RX("clear_rx_queue",0,0,5) ;
  1365. /*
  1366. * dma_complete and mac_drv_clear_rxd for all RxDs / receive buffers
  1367. */
  1368. r = queue->rx_curr_get ;
  1369. while (queue->rx_used) {
  1370. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1371. DB_RX("switch OWN bit of RxD 0x%x ",r,0,5) ;
  1372. r->rxd_rbctrl &= AIX_REVERSE(~BMU_OWN) ;
  1373. frag_count = 1 ;
  1374. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORDEV) ;
  1375. r = r->rxd_next ;
  1376. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1377. while (r != queue->rx_curr_put &&
  1378. !(r->rxd_rbctrl & AIX_REVERSE(BMU_ST_BUF))) {
  1379. DB_RX("Check STF bit in %x",(void *)r,0,5) ;
  1380. r->rxd_rbctrl &= AIX_REVERSE(~BMU_OWN) ;
  1381. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORDEV) ;
  1382. r = r->rxd_next ;
  1383. DRV_BUF_FLUSH(r,DDI_DMA_SYNC_FORCPU) ;
  1384. frag_count++ ;
  1385. }
  1386. DB_RX("STF bit found",0,0,5) ;
  1387. next_rxd = r ;
  1388. for (r=queue->rx_curr_get,i=frag_count; i ; r=r->rxd_next,i--){
  1389. DB_RX("dma_complete for RxD %x",(void *)r,0,5) ;
  1390. dma_complete(smc,(union s_fp_descr volatile *)r,DMA_WR);
  1391. }
  1392. DB_RX("mac_drv_clear_rxd: RxD %x frag_count %d ",
  1393. (void *)queue->rx_curr_get,frag_count,5) ;
  1394. mac_drv_clear_rxd(smc,queue->rx_curr_get,frag_count) ;
  1395. queue->rx_curr_get = next_rxd ;
  1396. queue->rx_used -= frag_count ;
  1397. queue->rx_free += frag_count ;
  1398. }
  1399. }
  1400. /*
  1401. -------------------------------------------------------------
  1402. SEND FUNCTIONS:
  1403. -------------------------------------------------------------
  1404. */
  1405. /*
  1406. * BEGIN_MANUAL_ENTRY(hwm_tx_init)
  1407. * int hwm_tx_init(smc,fc,frag_count,frame_len,frame_status)
  1408. *
  1409. * function DOWN_CALL (hardware module, hwmtm.c)
  1410. * hwm_tx_init checks if the frame can be sent through the
  1411. * corresponding send queue.
  1412. *
  1413. * para fc the frame control. To determine through which
  1414. * send queue the frame should be transmitted.
  1415. * 0x50 - 0x57: asynchronous LLC frame
  1416. * 0xD0 - 0xD7: synchronous LLC frame
  1417. * 0x41, 0x4F: SMT frame to the network
  1418. * 0x42: SMT frame to the network and to the local SMT
  1419. * 0x43: SMT frame to the local SMT
  1420. * frag_count count of the fragments for this frame
  1421. * frame_len length of the frame
  1422. * frame_status status of the frame, the send queue bit is already
  1423. * specified
  1424. *
  1425. * return frame_status
  1426. *
  1427. * END_MANUAL_ENTRY
  1428. */
  1429. int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count, int frame_len,
  1430. int frame_status)
  1431. {
  1432. NDD_TRACE("THiB",fc,frag_count,frame_len) ;
  1433. smc->os.hwm.tx_p = smc->hw.fp.tx[frame_status & QUEUE_A0] ;
  1434. smc->os.hwm.tx_descr = TX_DESCRIPTOR | (((u_long)(frame_len-1)&3)<<27) ;
  1435. smc->os.hwm.tx_len = frame_len ;
  1436. DB_TX("hwm_tx_init: fc = %x, len = %d",fc,frame_len,3) ;
  1437. if ((fc & ~(FC_SYNC_BIT|FC_LLC_PRIOR)) == FC_ASYNC_LLC) {
  1438. frame_status |= LAN_TX ;
  1439. }
  1440. else {
  1441. switch (fc) {
  1442. case FC_SMT_INFO :
  1443. case FC_SMT_NSA :
  1444. frame_status |= LAN_TX ;
  1445. break ;
  1446. case FC_SMT_LOC :
  1447. frame_status |= LOC_TX ;
  1448. break ;
  1449. case FC_SMT_LAN_LOC :
  1450. frame_status |= LAN_TX | LOC_TX ;
  1451. break ;
  1452. default :
  1453. SMT_PANIC(smc,HWM_E0010,HWM_E0010_MSG) ;
  1454. }
  1455. }
  1456. if (!smc->hw.mac_ring_is_up) {
  1457. frame_status &= ~LAN_TX ;
  1458. frame_status |= RING_DOWN ;
  1459. DB_TX("Ring is down: terminate LAN_TX",0,0,2) ;
  1460. }
  1461. if (frag_count > smc->os.hwm.tx_p->tx_free) {
  1462. #ifndef NDIS_OS2
  1463. mac_drv_clear_txd(smc) ;
  1464. if (frag_count > smc->os.hwm.tx_p->tx_free) {
  1465. DB_TX("Out of TxDs, terminate LAN_TX",0,0,2) ;
  1466. frame_status &= ~LAN_TX ;
  1467. frame_status |= OUT_OF_TXD ;
  1468. }
  1469. #else
  1470. DB_TX("Out of TxDs, terminate LAN_TX",0,0,2) ;
  1471. frame_status &= ~LAN_TX ;
  1472. frame_status |= OUT_OF_TXD ;
  1473. #endif
  1474. }
  1475. DB_TX("frame_status = %x",frame_status,0,3) ;
  1476. NDD_TRACE("THiE",frame_status,smc->os.hwm.tx_p->tx_free,0) ;
  1477. return(frame_status) ;
  1478. }
  1479. /*
  1480. * BEGIN_MANUAL_ENTRY(hwm_tx_frag)
  1481. * void hwm_tx_frag(smc,virt,phys,len,frame_status)
  1482. *
  1483. * function DOWNCALL (hardware module, hwmtm.c)
  1484. * If the frame should be sent to the LAN, this function calls
  1485. * dma_master, fills the current TxD with the virtual and the
  1486. * physical address, sets the STF and EOF bits dependent on
  1487. * the frame status, and requests the BMU to start the
  1488. * transmit.
  1489. * If the frame should be sent to the local SMT, an SMT_MBuf
  1490. * is allocated if the FIRST_FRAG bit is set in the frame_status.
  1491. * The fragment of the frame is copied into the SMT MBuf.
  1492. * The function smt_received_pack is called if the LAST_FRAG
  1493. * bit is set in the frame_status word.
  1494. *
  1495. * para virt virtual pointer to the fragment
  1496. * len the length of the fragment
  1497. * frame_status status of the frame, see design description
  1498. *
  1499. * return nothing returned, no parameter is modified
  1500. *
  1501. * NOTE: It is possible to invoke this macro with a fragment length
  1502. * of zero.
  1503. *
  1504. * END_MANUAL_ENTRY
  1505. */
  1506. void hwm_tx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
  1507. int frame_status)
  1508. {
  1509. struct s_smt_fp_txd volatile *t ;
  1510. struct s_smt_tx_queue *queue ;
  1511. u_int tbctrl ;
  1512. queue = smc->os.hwm.tx_p ;
  1513. NDD_TRACE("THfB",virt,len,frame_status) ;
  1514. /* Bug fix: AF / May 31 1999 (#missing)
  1515. * snmpinfo problem reported by IBM is caused by invalid
  1516. * t-pointer (txd) if LAN_TX is not set but LOC_TX only.
  1517. * Set: t = queue->tx_curr_put here !
  1518. */
  1519. t = queue->tx_curr_put ;
  1520. DB_TX("hwm_tx_frag: len = %d, frame_status = %x ",len,frame_status,2) ;
  1521. if (frame_status & LAN_TX) {
  1522. /* '*t' is already defined */
  1523. DB_TX("LAN_TX: TxD = %x, virt = %x ",t,virt,3) ;
  1524. t->txd_virt = virt ;
  1525. t->txd_txdscr = AIX_REVERSE(smc->os.hwm.tx_descr) ;
  1526. t->txd_tbadr = AIX_REVERSE(phys) ;
  1527. tbctrl = AIX_REVERSE((((u_long)frame_status &
  1528. (FIRST_FRAG|LAST_FRAG|EN_IRQ_EOF))<< 26) |
  1529. BMU_OWN|BMU_CHECK |len) ;
  1530. t->txd_tbctrl = tbctrl ;
  1531. #ifndef AIX
  1532. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1533. outpd(queue->tx_bmu_ctl,CSR_START) ;
  1534. #else /* ifndef AIX */
  1535. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1536. if (frame_status & QUEUE_A0) {
  1537. outpd(ADDR(B0_XA_CSR),CSR_START) ;
  1538. }
  1539. else {
  1540. outpd(ADDR(B0_XS_CSR),CSR_START) ;
  1541. }
  1542. #endif
  1543. queue->tx_free-- ;
  1544. queue->tx_used++ ;
  1545. queue->tx_curr_put = t->txd_next ;
  1546. if (frame_status & LAST_FRAG) {
  1547. smc->mib.m[MAC0].fddiMACTransmit_Ct++ ;
  1548. }
  1549. }
  1550. if (frame_status & LOC_TX) {
  1551. DB_TX("LOC_TX: ",0,0,3) ;
  1552. if (frame_status & FIRST_FRAG) {
  1553. if(!(smc->os.hwm.tx_mb = smt_get_mbuf(smc))) {
  1554. smc->hw.fp.err_stats.err_no_buf++ ;
  1555. DB_TX("No SMbuf; transmit terminated",0,0,4) ;
  1556. }
  1557. else {
  1558. smc->os.hwm.tx_data =
  1559. smtod(smc->os.hwm.tx_mb,char *) - 1 ;
  1560. #ifdef USE_OS_CPY
  1561. #ifdef PASS_1ST_TXD_2_TX_COMP
  1562. hwm_cpy_txd2mb(t,smc->os.hwm.tx_data,
  1563. smc->os.hwm.tx_len) ;
  1564. #endif
  1565. #endif
  1566. }
  1567. }
  1568. if (smc->os.hwm.tx_mb) {
  1569. #ifndef USE_OS_CPY
  1570. DB_TX("copy fragment into MBuf ",0,0,3) ;
  1571. memcpy(smc->os.hwm.tx_data,virt,len) ;
  1572. smc->os.hwm.tx_data += len ;
  1573. #endif
  1574. if (frame_status & LAST_FRAG) {
  1575. #ifdef USE_OS_CPY
  1576. #ifndef PASS_1ST_TXD_2_TX_COMP
  1577. /*
  1578. * hwm_cpy_txd2mb(txd,data,len) copies 'len'
  1579. * bytes from the virtual pointer in 'rxd'
  1580. * to 'data'. The virtual pointer of the
  1581. * os-specific tx-buffer should be written
  1582. * in the LAST txd.
  1583. */
  1584. hwm_cpy_txd2mb(t,smc->os.hwm.tx_data,
  1585. smc->os.hwm.tx_len) ;
  1586. #endif /* nPASS_1ST_TXD_2_TX_COMP */
  1587. #endif /* USE_OS_CPY */
  1588. smc->os.hwm.tx_data =
  1589. smtod(smc->os.hwm.tx_mb,char *) - 1 ;
  1590. *(char *)smc->os.hwm.tx_mb->sm_data =
  1591. *smc->os.hwm.tx_data ;
  1592. smc->os.hwm.tx_data++ ;
  1593. smc->os.hwm.tx_mb->sm_len =
  1594. smc->os.hwm.tx_len - 1 ;
  1595. DB_TX("pass LLC frame to SMT ",0,0,3) ;
  1596. smt_received_pack(smc,smc->os.hwm.tx_mb,
  1597. RD_FS_LOCAL) ;
  1598. }
  1599. }
  1600. }
  1601. NDD_TRACE("THfE",t,queue->tx_free,0) ;
  1602. }
  1603. /*
  1604. * queues a receive for later send
  1605. */
  1606. static void queue_llc_rx(struct s_smc *smc, SMbuf *mb)
  1607. {
  1608. DB_GEN("queue_llc_rx: mb = %x",(void *)mb,0,4) ;
  1609. smc->os.hwm.queued_rx_frames++ ;
  1610. mb->sm_next = (SMbuf *)NULL ;
  1611. if (smc->os.hwm.llc_rx_pipe == 0) {
  1612. smc->os.hwm.llc_rx_pipe = mb ;
  1613. }
  1614. else {
  1615. smc->os.hwm.llc_rx_tail->sm_next = mb ;
  1616. }
  1617. smc->os.hwm.llc_rx_tail = mb ;
  1618. /*
  1619. * force an timer IRQ to receive the data
  1620. */
  1621. if (!smc->os.hwm.isr_flag) {
  1622. smt_force_irq(smc) ;
  1623. }
  1624. }
  1625. /*
  1626. * get a SMbuf from the llc_rx_queue
  1627. */
  1628. static SMbuf *get_llc_rx(struct s_smc *smc)
  1629. {
  1630. SMbuf *mb ;
  1631. if ((mb = smc->os.hwm.llc_rx_pipe)) {
  1632. smc->os.hwm.queued_rx_frames-- ;
  1633. smc->os.hwm.llc_rx_pipe = mb->sm_next ;
  1634. }
  1635. DB_GEN("get_llc_rx: mb = 0x%x",(void *)mb,0,4) ;
  1636. return(mb) ;
  1637. }
  1638. /*
  1639. * queues a transmit SMT MBuf during the time were the MBuf is
  1640. * queued the TxD ring
  1641. */
  1642. static void queue_txd_mb(struct s_smc *smc, SMbuf *mb)
  1643. {
  1644. DB_GEN("_rx: queue_txd_mb = %x",(void *)mb,0,4) ;
  1645. smc->os.hwm.queued_txd_mb++ ;
  1646. mb->sm_next = (SMbuf *)NULL ;
  1647. if (smc->os.hwm.txd_tx_pipe == 0) {
  1648. smc->os.hwm.txd_tx_pipe = mb ;
  1649. }
  1650. else {
  1651. smc->os.hwm.txd_tx_tail->sm_next = mb ;
  1652. }
  1653. smc->os.hwm.txd_tx_tail = mb ;
  1654. }
  1655. /*
  1656. * get a SMbuf from the txd_tx_queue
  1657. */
  1658. static SMbuf *get_txd_mb(struct s_smc *smc)
  1659. {
  1660. SMbuf *mb ;
  1661. if ((mb = smc->os.hwm.txd_tx_pipe)) {
  1662. smc->os.hwm.queued_txd_mb-- ;
  1663. smc->os.hwm.txd_tx_pipe = mb->sm_next ;
  1664. }
  1665. DB_GEN("get_txd_mb: mb = 0x%x",(void *)mb,0,4) ;
  1666. return(mb) ;
  1667. }
  1668. /*
  1669. * SMT Send function
  1670. */
  1671. void smt_send_mbuf(struct s_smc *smc, SMbuf *mb, int fc)
  1672. {
  1673. char far *data ;
  1674. int len ;
  1675. int n ;
  1676. int i ;
  1677. int frag_count ;
  1678. int frame_status ;
  1679. SK_LOC_DECL(char far,*virt[3]) ;
  1680. int frag_len[3] ;
  1681. struct s_smt_tx_queue *queue ;
  1682. struct s_smt_fp_txd volatile *t ;
  1683. u_long phys ;
  1684. u_int tbctrl ;
  1685. NDD_TRACE("THSB",mb,fc,0) ;
  1686. DB_TX("smt_send_mbuf: mb = 0x%x, fc = 0x%x",mb,fc,4) ;
  1687. mb->sm_off-- ; /* set to fc */
  1688. mb->sm_len++ ; /* + fc */
  1689. data = smtod(mb,char *) ;
  1690. *data = fc ;
  1691. if (fc == FC_SMT_LOC)
  1692. *data = FC_SMT_INFO ;
  1693. /*
  1694. * determine the frag count and the virt addresses of the frags
  1695. */
  1696. frag_count = 0 ;
  1697. len = mb->sm_len ;
  1698. while (len) {
  1699. n = SMT_PAGESIZE - ((long)data & (SMT_PAGESIZE-1)) ;
  1700. if (n >= len) {
  1701. n = len ;
  1702. }
  1703. DB_TX("frag: virt/len = 0x%x/%d ",(void *)data,n,5) ;
  1704. virt[frag_count] = data ;
  1705. frag_len[frag_count] = n ;
  1706. frag_count++ ;
  1707. len -= n ;
  1708. data += n ;
  1709. }
  1710. /*
  1711. * determine the frame status
  1712. */
  1713. queue = smc->hw.fp.tx[QUEUE_A0] ;
  1714. if (fc == FC_BEACON || fc == FC_SMT_LOC) {
  1715. frame_status = LOC_TX ;
  1716. }
  1717. else {
  1718. frame_status = LAN_TX ;
  1719. if ((smc->os.hwm.pass_NSA &&(fc == FC_SMT_NSA)) ||
  1720. (smc->os.hwm.pass_SMT &&(fc == FC_SMT_INFO)))
  1721. frame_status |= LOC_TX ;
  1722. }
  1723. if (!smc->hw.mac_ring_is_up || frag_count > queue->tx_free) {
  1724. frame_status &= ~LAN_TX;
  1725. if (frame_status) {
  1726. DB_TX("Ring is down: terminate LAN_TX",0,0,2) ;
  1727. }
  1728. else {
  1729. DB_TX("Ring is down: terminate transmission",0,0,2) ;
  1730. smt_free_mbuf(smc,mb) ;
  1731. return ;
  1732. }
  1733. }
  1734. DB_TX("frame_status = 0x%x ",frame_status,0,5) ;
  1735. if ((frame_status & LAN_TX) && (frame_status & LOC_TX)) {
  1736. mb->sm_use_count = 2 ;
  1737. }
  1738. if (frame_status & LAN_TX) {
  1739. t = queue->tx_curr_put ;
  1740. frame_status |= FIRST_FRAG ;
  1741. for (i = 0; i < frag_count; i++) {
  1742. DB_TX("init TxD = 0x%x",(void *)t,0,5) ;
  1743. if (i == frag_count-1) {
  1744. frame_status |= LAST_FRAG ;
  1745. t->txd_txdscr = AIX_REVERSE(TX_DESCRIPTOR |
  1746. (((u_long)(mb->sm_len-1)&3) << 27)) ;
  1747. }
  1748. t->txd_virt = virt[i] ;
  1749. phys = dma_master(smc, (void far *)virt[i],
  1750. frag_len[i], DMA_RD|SMT_BUF) ;
  1751. t->txd_tbadr = AIX_REVERSE(phys) ;
  1752. tbctrl = AIX_REVERSE((((u_long) frame_status &
  1753. (FIRST_FRAG|LAST_FRAG)) << 26) |
  1754. BMU_OWN | BMU_CHECK | BMU_SMT_TX |frag_len[i]) ;
  1755. t->txd_tbctrl = tbctrl ;
  1756. #ifndef AIX
  1757. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1758. outpd(queue->tx_bmu_ctl,CSR_START) ;
  1759. #else
  1760. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1761. outpd(ADDR(B0_XA_CSR),CSR_START) ;
  1762. #endif
  1763. frame_status &= ~FIRST_FRAG ;
  1764. queue->tx_curr_put = t = t->txd_next ;
  1765. queue->tx_free-- ;
  1766. queue->tx_used++ ;
  1767. }
  1768. smc->mib.m[MAC0].fddiMACTransmit_Ct++ ;
  1769. queue_txd_mb(smc,mb) ;
  1770. }
  1771. if (frame_status & LOC_TX) {
  1772. DB_TX("pass Mbuf to LLC queue",0,0,5) ;
  1773. queue_llc_rx(smc,mb) ;
  1774. }
  1775. /*
  1776. * We need to unqueue the free SMT_MBUFs here, because it may
  1777. * be that the SMT want's to send more than 1 frame for one down call
  1778. */
  1779. mac_drv_clear_txd(smc) ;
  1780. NDD_TRACE("THSE",t,queue->tx_free,frag_count) ;
  1781. }
  1782. /* BEGIN_MANUAL_ENTRY(mac_drv_clear_txd)
  1783. * void mac_drv_clear_txd(smc)
  1784. *
  1785. * function DOWNCALL (hardware module, hwmtm.c)
  1786. * mac_drv_clear_txd searches in both send queues for TxD's
  1787. * which were finished by the adapter. It calls dma_complete
  1788. * for each TxD. If the last fragment of an LLC frame is
  1789. * reached, it calls mac_drv_tx_complete to release the
  1790. * send buffer.
  1791. *
  1792. * return nothing
  1793. *
  1794. * END_MANUAL_ENTRY
  1795. */
  1796. static void mac_drv_clear_txd(struct s_smc *smc)
  1797. {
  1798. struct s_smt_tx_queue *queue ;
  1799. struct s_smt_fp_txd volatile *t1 ;
  1800. struct s_smt_fp_txd volatile *t2 = NULL ;
  1801. SMbuf *mb ;
  1802. u_long tbctrl ;
  1803. int i ;
  1804. int frag_count ;
  1805. int n ;
  1806. NDD_TRACE("THcB",0,0,0) ;
  1807. for (i = QUEUE_S; i <= QUEUE_A0; i++) {
  1808. queue = smc->hw.fp.tx[i] ;
  1809. t1 = queue->tx_curr_get ;
  1810. DB_TX("clear_txd: QUEUE = %d (0=sync/1=async)",i,0,5) ;
  1811. for ( ; ; ) {
  1812. frag_count = 0 ;
  1813. do {
  1814. DRV_BUF_FLUSH(t1,DDI_DMA_SYNC_FORCPU) ;
  1815. DB_TX("check OWN/EOF bit of TxD 0x%x",t1,0,5) ;
  1816. tbctrl = CR_READ(t1->txd_tbctrl) ;
  1817. tbctrl = AIX_REVERSE(tbctrl) ;
  1818. if (tbctrl & BMU_OWN || !queue->tx_used){
  1819. DB_TX("End of TxDs queue %d",i,0,4) ;
  1820. goto free_next_queue ; /* next queue */
  1821. }
  1822. t1 = t1->txd_next ;
  1823. frag_count++ ;
  1824. } while (!(tbctrl & BMU_EOF)) ;
  1825. t1 = queue->tx_curr_get ;
  1826. for (n = frag_count; n; n--) {
  1827. tbctrl = AIX_REVERSE(t1->txd_tbctrl) ;
  1828. dma_complete(smc,
  1829. (union s_fp_descr volatile *) t1,
  1830. (int) (DMA_RD |
  1831. ((tbctrl & BMU_SMT_TX) >> 18))) ;
  1832. t2 = t1 ;
  1833. t1 = t1->txd_next ;
  1834. }
  1835. if (tbctrl & BMU_SMT_TX) {
  1836. mb = get_txd_mb(smc) ;
  1837. smt_free_mbuf(smc,mb) ;
  1838. }
  1839. else {
  1840. #ifndef PASS_1ST_TXD_2_TX_COMP
  1841. DB_TX("mac_drv_tx_comp for TxD 0x%x",t2,0,4) ;
  1842. mac_drv_tx_complete(smc,t2) ;
  1843. #else
  1844. DB_TX("mac_drv_tx_comp for TxD 0x%x",
  1845. queue->tx_curr_get,0,4) ;
  1846. mac_drv_tx_complete(smc,queue->tx_curr_get) ;
  1847. #endif
  1848. }
  1849. queue->tx_curr_get = t1 ;
  1850. queue->tx_free += frag_count ;
  1851. queue->tx_used -= frag_count ;
  1852. }
  1853. free_next_queue: ;
  1854. }
  1855. NDD_TRACE("THcE",0,0,0) ;
  1856. }
  1857. /*
  1858. * BEGINN_MANUAL_ENTRY(mac_drv_clear_tx_queue)
  1859. *
  1860. * void mac_drv_clear_tx_queue(smc)
  1861. * struct s_smc *smc ;
  1862. *
  1863. * function DOWNCALL (hardware module, hwmtm.c)
  1864. * mac_drv_clear_tx_queue is called from the SMT when
  1865. * the RMT state machine has entered the ISOLATE state.
  1866. * This function is also called by the os-specific module
  1867. * after it has called the function card_stop().
  1868. * In this case, the frames in the send queues are obsolete and
  1869. * should be removed.
  1870. *
  1871. * note calling sequence:
  1872. * CLI_FBI(), card_stop(),
  1873. * mac_drv_clear_tx_queue(), mac_drv_clear_rx_queue(),
  1874. *
  1875. * NOTE: The caller is responsible that the BMUs are idle
  1876. * when this function is called.
  1877. *
  1878. * END_MANUAL_ENTRY
  1879. */
  1880. void mac_drv_clear_tx_queue(struct s_smc *smc)
  1881. {
  1882. struct s_smt_fp_txd volatile *t ;
  1883. struct s_smt_tx_queue *queue ;
  1884. int tx_used ;
  1885. int i ;
  1886. if (smc->hw.hw_state != STOPPED) {
  1887. SK_BREAK() ;
  1888. SMT_PANIC(smc,HWM_E0011,HWM_E0011_MSG) ;
  1889. return ;
  1890. }
  1891. for (i = QUEUE_S; i <= QUEUE_A0; i++) {
  1892. queue = smc->hw.fp.tx[i] ;
  1893. DB_TX("clear_tx_queue: QUEUE = %d (0=sync/1=async)",i,0,5) ;
  1894. /*
  1895. * switch the OWN bit of all pending frames to the host
  1896. */
  1897. t = queue->tx_curr_get ;
  1898. tx_used = queue->tx_used ;
  1899. while (tx_used) {
  1900. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORCPU) ;
  1901. DB_TX("switch OWN bit of TxD 0x%x ",t,0,5) ;
  1902. t->txd_tbctrl &= AIX_REVERSE(~BMU_OWN) ;
  1903. DRV_BUF_FLUSH(t,DDI_DMA_SYNC_FORDEV) ;
  1904. t = t->txd_next ;
  1905. tx_used-- ;
  1906. }
  1907. }
  1908. /*
  1909. * release all TxD's for both send queues
  1910. */
  1911. mac_drv_clear_txd(smc) ;
  1912. for (i = QUEUE_S; i <= QUEUE_A0; i++) {
  1913. queue = smc->hw.fp.tx[i] ;
  1914. t = queue->tx_curr_get ;
  1915. /*
  1916. * write the phys pointer of the NEXT descriptor into the
  1917. * BMU's current address descriptor pointer and set
  1918. * tx_curr_get and tx_curr_put to this position
  1919. */
  1920. if (i == QUEUE_S) {
  1921. outpd(ADDR(B5_XS_DA),AIX_REVERSE(t->txd_ntdadr)) ;
  1922. }
  1923. else {
  1924. outpd(ADDR(B5_XA_DA),AIX_REVERSE(t->txd_ntdadr)) ;
  1925. }
  1926. queue->tx_curr_put = queue->tx_curr_get->txd_next ;
  1927. queue->tx_curr_get = queue->tx_curr_put ;
  1928. }
  1929. }
  1930. /*
  1931. -------------------------------------------------------------
  1932. TEST FUNCTIONS:
  1933. -------------------------------------------------------------
  1934. */
  1935. #ifdef DEBUG
  1936. /*
  1937. * BEGIN_MANUAL_ENTRY(mac_drv_debug_lev)
  1938. * void mac_drv_debug_lev(smc,flag,lev)
  1939. *
  1940. * function DOWNCALL (drvsr.c)
  1941. * To get a special debug info the user can assign a debug level
  1942. * to any debug flag.
  1943. *
  1944. * para flag debug flag, possible values are:
  1945. * = 0: reset all debug flags (the defined level is
  1946. * ignored)
  1947. * = 1: debug.d_smtf
  1948. * = 2: debug.d_smt
  1949. * = 3: debug.d_ecm
  1950. * = 4: debug.d_rmt
  1951. * = 5: debug.d_cfm
  1952. * = 6: debug.d_pcm
  1953. *
  1954. * = 10: debug.d_os.hwm_rx (hardware module receive path)
  1955. * = 11: debug.d_os.hwm_tx(hardware module transmit path)
  1956. * = 12: debug.d_os.hwm_gen(hardware module general flag)
  1957. *
  1958. * lev debug level
  1959. *
  1960. * END_MANUAL_ENTRY
  1961. */
  1962. void mac_drv_debug_lev(struct s_smc *smc, int flag, int lev)
  1963. {
  1964. switch(flag) {
  1965. case (int)NULL:
  1966. DB_P.d_smtf = DB_P.d_smt = DB_P.d_ecm = DB_P.d_rmt = 0 ;
  1967. DB_P.d_cfm = 0 ;
  1968. DB_P.d_os.hwm_rx = DB_P.d_os.hwm_tx = DB_P.d_os.hwm_gen = 0 ;
  1969. #ifdef SBA
  1970. DB_P.d_sba = 0 ;
  1971. #endif
  1972. #ifdef ESS
  1973. DB_P.d_ess = 0 ;
  1974. #endif
  1975. break ;
  1976. case DEBUG_SMTF:
  1977. DB_P.d_smtf = lev ;
  1978. break ;
  1979. case DEBUG_SMT:
  1980. DB_P.d_smt = lev ;
  1981. break ;
  1982. case DEBUG_ECM:
  1983. DB_P.d_ecm = lev ;
  1984. break ;
  1985. case DEBUG_RMT:
  1986. DB_P.d_rmt = lev ;
  1987. break ;
  1988. case DEBUG_CFM:
  1989. DB_P.d_cfm = lev ;
  1990. break ;
  1991. case DEBUG_PCM:
  1992. DB_P.d_pcm = lev ;
  1993. break ;
  1994. case DEBUG_SBA:
  1995. #ifdef SBA
  1996. DB_P.d_sba = lev ;
  1997. #endif
  1998. break ;
  1999. case DEBUG_ESS:
  2000. #ifdef ESS
  2001. DB_P.d_ess = lev ;
  2002. #endif
  2003. break ;
  2004. case DB_HWM_RX:
  2005. DB_P.d_os.hwm_rx = lev ;
  2006. break ;
  2007. case DB_HWM_TX:
  2008. DB_P.d_os.hwm_tx = lev ;
  2009. break ;
  2010. case DB_HWM_GEN:
  2011. DB_P.d_os.hwm_gen = lev ;
  2012. break ;
  2013. default:
  2014. break ;
  2015. }
  2016. }
  2017. #endif