hwmtm.c 55 KB

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