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