1 /******************************************************************************
3 * (C)Copyright 1998,1999 SysKonnect,
4 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * The information in this file is provided "AS IS" without warranty.
13 ******************************************************************************/
21 * MACRO for DMA synchronization:
22 * The descriptor 'desc' is flushed for the device 'flag'.
23 * Devices are the CPU (DDI_DMA_SYNC_FORCPU) and the
24 * adapter (DDI_DMA_SYNC_FORDEV).
26 * 'desc' Pointer to a Rx or Tx descriptor.
27 * 'flag' Flag for direction (view for CPU or DEVICE) that
28 * should be synchronized.
30 * Empty macros and defines are specified here. The real macro
31 * is os-specific and should be defined in osdef1st.h.
34 #define DRV_BUF_FLUSH(desc,flag)
35 #define DDI_DMA_SYNC_FORCPU
36 #define DDI_DMA_SYNC_FORDEV
40 * hardware modul dependent receive modes
42 #define RX_ENABLE_PASS_SMT 21
43 #define RX_DISABLE_PASS_SMT 22
44 #define RX_ENABLE_PASS_NSA 23
45 #define RX_DISABLE_PASS_NSA 24
46 #define RX_ENABLE_PASS_DB 25
47 #define RX_DISABLE_PASS_DB 26
48 #define RX_DISABLE_PASS_ALL 27
49 #define RX_DISABLE_LLC_PROMISC 28
50 #define RX_ENABLE_LLC_PROMISC 29
54 #define DMA_RD 1 /* memory -> hw */
57 #define DMA_WR 2 /* hw -> memory */
62 * bits of the frame status byte
64 #define EN_IRQ_EOF 0x02 /* get IRQ after end of frame transmission */
65 #define LOC_TX 0x04 /* send frame to the local SMT */
66 #define LAST_FRAG 0x08 /* last TxD of the frame */
67 #define FIRST_FRAG 0x10 /* first TxD of the frame */
68 #define LAN_TX 0x20 /* send frame to network if set */
69 #define RING_DOWN 0x40 /* error: unable to send, ring down */
70 #define OUT_OF_TXD 0x80 /* error: not enough TxDs available */
77 #define C_INDIC (1L<<25)
78 #define A_INDIC (1L<<26)
79 #define RD_FS_LOCAL 0x80
98 #ifndef MB_OUTSIDE_SMC
99 SMbuf mb[MAX_MBUF] ; /* mbuf pool */
101 SMbuf *mb_start ; /* points to the first mb */
102 SMbuf *mb_free ; /* free queue */
107 * hardware modul specific receive variables
109 u_int len ; /* length of the whole frame */
110 char *mb_pos ; /* SMbuf receive position */
115 * All hardware modul specific variables
117 struct s_mbuf_pool mbuf_pool ;
120 union s_fp_descr volatile *descr_p ; /* points to the desriptor area */
122 u_short pass_SMT ; /* pass SMT frames */
123 u_short pass_NSA ; /* pass all NSA frames */
124 u_short pass_DB ; /* pass Direct Beacon Frames */
125 u_short pass_llc_promisc ; /* pass all llc frames (default ON) */
127 SMbuf *llc_rx_pipe ; /* points to the first queued llc fr */
128 SMbuf *llc_rx_tail ; /* points to the last queued llc fr */
129 int queued_rx_frames ; /* number of queued frames */
131 SMbuf *txd_tx_pipe ; /* points to first mb in the txd ring */
132 SMbuf *txd_tx_tail ; /* points to last mb in the txd ring */
133 int queued_txd_mb ; /* number of SMT MBufs in txd ring */
135 int rx_break ; /* rev. was breaked because ind. off */
136 int leave_isr ; /* leave fddi_isr immedeately if set */
137 int isr_flag ; /* set, when HWM is entered from isr */
139 * variables for the current transmit frame
141 struct s_smt_tx_queue *tx_p ; /* pointer to the transmit queue */
142 u_long tx_descr ; /* tx descriptor for FORMAC+ */
143 int tx_len ; /* tx frame length */
144 SMbuf *tx_mb ; /* SMT tx MBuf pointer */
145 char *tx_data ; /* data pointer to the SMT tx Mbuf */
147 int detec_count ; /* counter for out of RxD condition */
148 u_long rx_len_error ; /* rx len FORMAC != sum of fragments */
153 * DEBUG structs and macros
166 #define DB_P smc->debug
171 #define DB_RX(a,b,c,lev) if (DB_P.d_os.hwm_rx >= (lev)) printf(a,b,c)
172 #define DB_TX(a,b,c,lev) if (DB_P.d_os.hwm_tx >= (lev)) printf(a,b,c)
173 #define DB_GEN(a,b,c,lev) if (DB_P.d_os.hwm_gen >= (lev)) printf(a,b,c)
175 #define DB_RX(a,b,c,lev)
176 #define DB_TX(a,b,c,lev)
177 #define DB_GEN(a,b,c,lev)
190 * BEGIN_MANUAL_ENTRY(HWM_GET_TX_PHYS)
191 * u_long HWM_GET_TX_PHYS(txd)
193 * function MACRO (hardware module, hwmtm.h)
194 * This macro may be invoked by the OS-specific module to read
195 * the physical address of the specified TxD.
197 * para txd pointer to the TxD
201 #define HWM_GET_TX_PHYS(txd) (u_long)AIX_REVERSE((txd)->txd_tbadr)
204 * BEGIN_MANUAL_ENTRY(HWM_GET_TX_LEN)
205 * int HWM_GET_TX_LEN(txd)
207 * function MACRO (hardware module, hwmtm.h)
208 * This macro may be invoked by the OS-specific module to read
209 * the fragment length of the specified TxD
211 * para rxd pointer to the TxD
213 * return the length of the fragment in bytes
217 #define HWM_GET_TX_LEN(txd) ((int)AIX_REVERSE((txd)->txd_tbctrl)& RD_LENGTH)
220 * BEGIN_MANUAL_ENTRY(HWM_GET_TX_USED)
221 * txd *HWM_GET_TX_USED(smc,queue)
223 * function MACRO (hardware module, hwmtm.h)
224 * This macro may be invoked by the OS-specific module to get the
225 * number of used TxDs for the queue, specified by the index.
227 * para queue the number of the send queue: Can be specified by
228 * QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)
230 * return number of used TxDs for this send queue
234 #define HWM_GET_TX_USED(smc,queue) (int) (smc)->hw.fp.tx_q[queue].tx_used
237 * BEGIN_MANUAL_ENTRY(HWM_GET_CURR_TXD)
238 * txd *HWM_GET_CURR_TXD(smc,queue)
240 * function MACRO (hardware module, hwmtm.h)
241 * This macro may be invoked by the OS-specific module to get the
242 * pointer to the TxD which points to the current queue put
245 * para queue the number of the send queue: Can be specified by
246 * QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)
248 * return pointer to the current TxD
252 #define HWM_GET_CURR_TXD(smc,queue) (struct s_smt_fp_txd volatile *)\
253 (smc)->hw.fp.tx_q[queue].tx_curr_put
256 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FRAG_LEN)
257 * int HWM_GET_RX_FRAG_LEN(rxd)
259 * function MACRO (hardware module, hwmtm.h)
260 * This macro may be invoked by the OS-specific module to read
261 * the fragment length of the specified RxD
263 * para rxd pointer to the RxD
265 * return the length of the fragment in bytes
269 #define HWM_GET_RX_FRAG_LEN(rxd) ((int)AIX_REVERSE((rxd)->rxd_rbctrl)& \
273 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_PHYS)
274 * u_long HWM_GET_RX_PHYS(rxd)
276 * function MACRO (hardware module, hwmtm.h)
277 * This macro may be invoked by the OS-specific module to read
278 * the physical address of the specified RxD.
280 * para rxd pointer to the RxD
282 * return the RxD's physical pointer to the data fragment
286 #define HWM_GET_RX_PHYS(rxd) (u_long)AIX_REVERSE((rxd)->rxd_rbadr)
289 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_USED)
290 * int HWM_GET_RX_USED(smc)
292 * function MACRO (hardware module, hwmtm.h)
293 * This macro may be invoked by the OS-specific module to get
294 * the count of used RXDs in receive queue 1.
296 * return the used RXD count of receive queue 1
298 * NOTE: Remember, because of an ASIC bug at least one RXD should be unused
299 * in the descriptor ring !
303 #define HWM_GET_RX_USED(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_used)
306 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FREE)
307 * int HWM_GET_RX_FREE(smc)
309 * function MACRO (hardware module, hwmtm.h)
310 * This macro may be invoked by the OS-specific module to get
311 * the rxd_free count of receive queue 1.
313 * return the rxd_free count of receive queue 1
317 #define HWM_GET_RX_FREE(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_free-1)
320 * BEGIN_MANUAL_ENTRY(HWM_GET_CURR_RXD)
321 * rxd *HWM_GET_CURR_RXD(smc)
323 * function MACRO (hardware module, hwmtm.h)
324 * This macro may be invoked by the OS-specific module to get the
325 * pointer to the RxD which points to the current queue put
328 * return pointer to the current RxD
332 #define HWM_GET_CURR_RXD(smc) (struct s_smt_fp_rxd volatile *)\
333 (smc)->hw.fp.rx_q[QUEUE_R1].rx_curr_put
336 * BEGIN_MANUAL_ENTRY(HWM_RX_CHECK)
337 * void HWM_RX_CHECK(smc,low_water)
339 * function MACRO (hardware module, hwmtm.h)
340 * This macro is invoked by the OS-specific before it left the
341 * function mac_drv_rx_complete. This macro calls mac_drv_fill_rxd
342 * if the number of used RxDs is equal or lower than the
343 * the given low water mark.
345 * para low_water low water mark of used RxD's
349 #ifndef HWM_NO_FLOW_CTL
350 #define HWM_RX_CHECK(smc,low_water) {\
351 if ((low_water) >= (smc)->hw.fp.rx_q[QUEUE_R1].rx_used) {\
352 mac_drv_fill_rxd(smc) ;\
356 #define HWM_RX_CHECK(smc,low_water) mac_drv_fill_rxd(smc)
360 #define HWM_EBASE 500
363 #define HWM_E0001 HWM_EBASE + 1
364 #define HWM_E0001_MSG "HWM: Wrong size of s_rxd_os struct"
365 #define HWM_E0002 HWM_EBASE + 2
366 #define HWM_E0002_MSG "HWM: Wrong size of s_txd_os struct"
367 #define HWM_E0003 HWM_EBASE + 3
368 #define HWM_E0003_MSG "HWM: smt_free_mbuf() called with NULL pointer"
369 #define HWM_E0004 HWM_EBASE + 4
370 #define HWM_E0004_MSG "HWM: Parity error rx queue 1"
371 #define HWM_E0005 HWM_EBASE + 5
372 #define HWM_E0005_MSG "HWM: Encoding error rx queue 1"
373 #define HWM_E0006 HWM_EBASE + 6
374 #define HWM_E0006_MSG "HWM: Encoding error async tx queue"
375 #define HWM_E0007 HWM_EBASE + 7
376 #define HWM_E0007_MSG "HWM: Encoding error sync tx queue"
377 #define HWM_E0008 HWM_EBASE + 8
378 #define HWM_E0008_MSG ""
379 #define HWM_E0009 HWM_EBASE + 9
380 #define HWM_E0009_MSG "HWM: Out of RxD condition detected"
381 #define HWM_E0010 HWM_EBASE + 10
382 #define HWM_E0010_MSG "HWM: A protocol layer has tried to send a frame with an invalid frame control"
383 #define HWM_E0011 HWM_EBASE + 11
384 #define HWM_E0011_MSG "HWM: mac_drv_clear_tx_queue was called although the hardware wasn't stopped"
385 #define HWM_E0012 HWM_EBASE + 12
386 #define HWM_E0012_MSG "HWM: mac_drv_clear_rx_queue was called although the hardware wasn't stopped"
387 #define HWM_E0013 HWM_EBASE + 13
388 #define HWM_E0013_MSG "HWM: mac_drv_repair_descr was called although the hardware wasn't stopped"