hwmtm.c 57 KB

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