Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /******************************************************************************
0003  *
0004  *  (C)Copyright 1998,1999 SysKonnect,
0005  *  a business unit of Schneider & Koch & Co. Datensysteme GmbH.
0006  *
0007  *  The information in this file is provided "AS IS" without warranty.
0008  *
0009  ******************************************************************************/
0010 
0011 #ifndef _HWM_
0012 #define _HWM_
0013 
0014 #include "mbuf.h"
0015 
0016 /*
0017  * MACRO for DMA synchronization:
0018  *  The descriptor 'desc' is flushed for the device 'flag'.
0019  *  Devices are the CPU (DDI_DMA_SYNC_FORCPU) and the
0020  *  adapter (DDI_DMA_SYNC_FORDEV).
0021  *
0022  *  'desc'  Pointer to a Rx or Tx descriptor.
0023  *  'flag'  Flag for direction (view for CPU or DEVICE) that
0024  *      should be synchronized.
0025  *
0026  *  Empty macros and defines are specified here. The real macro
0027  *  is os-specific and should be defined in osdef1st.h.
0028  */
0029 #ifndef DRV_BUF_FLUSH
0030 #define DRV_BUF_FLUSH(desc,flag)
0031 #define DDI_DMA_SYNC_FORCPU
0032 #define DDI_DMA_SYNC_FORDEV
0033 #endif
0034 
0035     /*
0036      * hardware modul dependent receive modes
0037      */
0038 #define RX_ENABLE_PASS_SMT  21
0039 #define RX_DISABLE_PASS_SMT 22
0040 #define RX_ENABLE_PASS_NSA  23
0041 #define RX_DISABLE_PASS_NSA 24
0042 #define RX_ENABLE_PASS_DB   25
0043 #define RX_DISABLE_PASS_DB  26
0044 #define RX_DISABLE_PASS_ALL 27
0045 #define RX_DISABLE_LLC_PROMISC  28
0046 #define RX_ENABLE_LLC_PROMISC   29
0047 
0048 
0049 #ifndef DMA_RD
0050 #define DMA_RD      1   /* memory -> hw */
0051 #endif
0052 #ifndef DMA_WR
0053 #define DMA_WR      2   /* hw -> memory */
0054 #endif
0055 #define SMT_BUF     0x80
0056 
0057     /*
0058      * bits of the frame status byte
0059      */
0060 #define EN_IRQ_EOF  0x02    /* get IRQ after end of frame transmission */
0061 #define LOC_TX      0x04    /* send frame to the local SMT */
0062 #define LAST_FRAG   0x08    /* last TxD of the frame */
0063 #define FIRST_FRAG  0x10    /* first TxD of the frame */
0064 #define LAN_TX      0x20    /* send frame to network if set */
0065 #define RING_DOWN   0x40    /* error: unable to send, ring down */
0066 #define OUT_OF_TXD  0x80    /* error: not enough TxDs available */
0067 
0068 
0069 #ifndef NULL
0070 #define NULL        0
0071 #endif
0072 
0073 #define C_INDIC     (1L<<25)
0074 #define A_INDIC     (1L<<26)
0075 #define RD_FS_LOCAL 0x80
0076 
0077     /*
0078      * DEBUG FLAGS
0079      */
0080 #define DEBUG_SMTF  1
0081 #define DEBUG_SMT   2
0082 #define DEBUG_ECM   3
0083 #define DEBUG_RMT   4
0084 #define DEBUG_CFM   5
0085 #define DEBUG_PCM   6
0086 #define DEBUG_SBA   7
0087 #define DEBUG_ESS   8
0088 
0089 #define DB_HWM_RX   10
0090 #define DB_HWM_TX   11
0091 #define DB_HWM_GEN  12
0092 
0093 struct s_mbuf_pool {
0094 #ifndef MB_OUTSIDE_SMC
0095     SMbuf       mb[MAX_MBUF] ;      /* mbuf pool */
0096 #endif
0097     SMbuf       *mb_start ;     /* points to the first mb */
0098     SMbuf       *mb_free ;      /* free queue */
0099 } ;
0100 
0101 struct hwm_r {
0102     /*
0103      * hardware modul specific receive variables
0104      */
0105     u_int           len ;       /* length of the whole frame */
0106     char            *mb_pos ;   /* SMbuf receive position */
0107 } ;
0108 
0109 struct hw_modul {
0110     /*
0111      * All hardware modul specific variables
0112      */
0113     struct  s_mbuf_pool mbuf_pool ;
0114     struct  hwm_r   r ;
0115 
0116     union s_fp_descr volatile *descr_p ; /* points to the desriptor area */
0117 
0118     u_short pass_SMT ;      /* pass SMT frames */
0119     u_short pass_NSA ;      /* pass all NSA frames */
0120     u_short pass_DB ;       /* pass Direct Beacon Frames */
0121     u_short pass_llc_promisc ;  /* pass all llc frames (default ON) */
0122 
0123     SMbuf   *llc_rx_pipe ;      /* points to the first queued llc fr */
0124     SMbuf   *llc_rx_tail ;      /* points to the last queued llc fr */
0125     int queued_rx_frames ;  /* number of queued frames */
0126 
0127     SMbuf   *txd_tx_pipe ;      /* points to first mb in the txd ring */
0128     SMbuf   *txd_tx_tail ;      /* points to last mb in the txd ring */
0129     int queued_txd_mb ;     /* number of SMT MBufs in txd ring */
0130 
0131     int rx_break ;      /* rev. was breaked because ind. off */
0132     int leave_isr ;     /* leave fddi_isr immedeately if set */
0133     int isr_flag ;      /* set, when HWM is entered from isr */
0134     /*
0135      * variables for the current transmit frame
0136      */
0137     struct s_smt_tx_queue *tx_p ;   /* pointer to the transmit queue */
0138     u_long  tx_descr ;      /* tx descriptor for FORMAC+ */
0139     int tx_len ;        /* tx frame length */
0140     SMbuf   *tx_mb ;        /* SMT tx MBuf pointer */
0141     char    *tx_data ;      /* data pointer to the SMT tx Mbuf */
0142 
0143     int detec_count ;       /* counter for out of RxD condition */
0144     u_long  rx_len_error ;      /* rx len FORMAC != sum of fragments */
0145 } ;
0146 
0147 
0148 /*
0149  * DEBUG structs and macros
0150  */
0151 
0152 #ifdef  DEBUG
0153 struct os_debug {
0154     int hwm_rx ;
0155     int hwm_tx ;
0156     int hwm_gen ;
0157 } ;
0158 #endif
0159 
0160 #ifdef  DEBUG
0161 #ifdef  DEBUG_BRD
0162 #define DB_P    smc->debug
0163 #else
0164 #define DB_P    debug
0165 #endif
0166 
0167 #define DB_RX(lev, fmt, ...)                        \
0168 do {                                    \
0169     if (DB_P.d_os.hwm_rx >= (lev))                  \
0170         printf(fmt "\n", ##__VA_ARGS__);            \
0171 } while (0)
0172 #define DB_TX(lev, fmt, ...)                        \
0173 do {                                    \
0174     if (DB_P.d_os.hwm_tx >= (lev))                  \
0175         printf(fmt "\n", ##__VA_ARGS__);            \
0176 } while (0)
0177 #define DB_GEN(lev, fmt, ...)                       \
0178 do {                                    \
0179     if (DB_P.d_os.hwm_gen >= (lev))                 \
0180         printf(fmt "\n", ##__VA_ARGS__);            \
0181 } while (0)
0182 #else   /* DEBUG */
0183 #define DB_RX(lev, fmt, ...)    no_printk(fmt "\n", ##__VA_ARGS__)
0184 #define DB_TX(lev, fmt, ...)    no_printk(fmt "\n", ##__VA_ARGS__)
0185 #define DB_GEN(lev, fmt, ...)   no_printk(fmt "\n", ##__VA_ARGS__)
0186 #endif  /* DEBUG */
0187 
0188 #ifndef SK_BREAK
0189 #define SK_BREAK()
0190 #endif
0191 
0192 
0193 /*
0194  * HWM Macros
0195  */
0196 
0197 /*
0198  *  BEGIN_MANUAL_ENTRY(HWM_GET_TX_PHYS)
0199  *  u_long HWM_GET_TX_PHYS(txd)
0200  *
0201  * function MACRO       (hardware module, hwmtm.h)
0202  *      This macro may be invoked by the OS-specific module to read
0203  *      the physical address of the specified TxD.
0204  *
0205  * para txd pointer to the TxD
0206  *
0207  *  END_MANUAL_ENTRY
0208  */
0209 #define HWM_GET_TX_PHYS(txd)        (u_long)AIX_REVERSE((txd)->txd_tbadr)
0210 
0211 /*
0212  *  BEGIN_MANUAL_ENTRY(HWM_GET_TX_LEN)
0213  *  int HWM_GET_TX_LEN(txd)
0214  *
0215  * function MACRO       (hardware module, hwmtm.h)
0216  *      This macro may be invoked by the OS-specific module to read
0217  *      the fragment length of the specified TxD
0218  *
0219  * para rxd pointer to the TxD
0220  *
0221  * return   the length of the fragment in bytes
0222  *
0223  *  END_MANUAL_ENTRY
0224  */
0225 #define HWM_GET_TX_LEN(txd) ((int)AIX_REVERSE((txd)->txd_tbctrl)& RD_LENGTH)
0226 
0227 /*
0228  *  BEGIN_MANUAL_ENTRY(HWM_GET_TX_USED)
0229  *  txd *HWM_GET_TX_USED(smc,queue)
0230  *
0231  * function MACRO       (hardware module, hwmtm.h)
0232  *      This macro may be invoked by the OS-specific module to get the
0233  *      number of used TxDs for the queue, specified by the index.
0234  *
0235  * para queue   the number of the send queue: Can be specified by
0236  *      QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)
0237  *
0238  * return   number of used TxDs for this send queue
0239  *
0240  *  END_MANUAL_ENTRY
0241  */
0242 #define HWM_GET_TX_USED(smc,queue)  (int) (smc)->hw.fp.tx_q[queue].tx_used
0243 
0244 /*
0245  *  BEGIN_MANUAL_ENTRY(HWM_GET_CURR_TXD)
0246  *  txd *HWM_GET_CURR_TXD(smc,queue)
0247  *
0248  * function MACRO       (hardware module, hwmtm.h)
0249  *      This macro may be invoked by the OS-specific module to get the
0250  *      pointer to the TxD which points to the current queue put
0251  *      position.
0252  *
0253  * para queue   the number of the send queue: Can be specified by
0254  *      QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)
0255  *
0256  * return   pointer to the current TxD
0257  *
0258  *  END_MANUAL_ENTRY
0259  */
0260 #define HWM_GET_CURR_TXD(smc,queue) (struct s_smt_fp_txd volatile *)\
0261                     (smc)->hw.fp.tx_q[queue].tx_curr_put
0262 
0263 /*
0264  *  BEGIN_MANUAL_ENTRY(HWM_GET_RX_FRAG_LEN)
0265  *  int HWM_GET_RX_FRAG_LEN(rxd)
0266  *
0267  * function MACRO       (hardware module, hwmtm.h)
0268  *      This macro may be invoked by the OS-specific module to read
0269  *      the fragment length of the specified RxD
0270  *
0271  * para rxd pointer to the RxD
0272  *
0273  * return   the length of the fragment in bytes
0274  *
0275  *  END_MANUAL_ENTRY
0276  */
0277 #define HWM_GET_RX_FRAG_LEN(rxd)    ((int)AIX_REVERSE((rxd)->rxd_rbctrl)& \
0278                 RD_LENGTH)
0279 
0280 /*
0281  *  BEGIN_MANUAL_ENTRY(HWM_GET_RX_PHYS)
0282  *  u_long HWM_GET_RX_PHYS(rxd)
0283  *
0284  * function MACRO       (hardware module, hwmtm.h)
0285  *      This macro may be invoked by the OS-specific module to read
0286  *      the physical address of the specified RxD.
0287  *
0288  * para rxd pointer to the RxD
0289  *
0290  * return   the RxD's physical pointer to the data fragment
0291  *
0292  *  END_MANUAL_ENTRY
0293  */
0294 #define HWM_GET_RX_PHYS(rxd)    (u_long)AIX_REVERSE((rxd)->rxd_rbadr)
0295 
0296 /*
0297  *  BEGIN_MANUAL_ENTRY(HWM_GET_RX_USED)
0298  *  int HWM_GET_RX_USED(smc)
0299  *
0300  * function MACRO       (hardware module, hwmtm.h)
0301  *      This macro may be invoked by the OS-specific module to get
0302  *      the count of used RXDs in receive queue 1.
0303  *
0304  * return   the used RXD count of receive queue 1
0305  *
0306  * NOTE: Remember, because of an ASIC bug at least one RXD should be unused
0307  *   in the descriptor ring !
0308  *
0309  *  END_MANUAL_ENTRY
0310  */
0311 #define HWM_GET_RX_USED(smc)    ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_used)
0312 
0313 /*
0314  *  BEGIN_MANUAL_ENTRY(HWM_GET_RX_FREE)
0315  *  int HWM_GET_RX_FREE(smc)
0316  *
0317  * function MACRO       (hardware module, hwmtm.h)
0318  *      This macro may be invoked by the OS-specific module to get
0319  *      the rxd_free count of receive queue 1.
0320  *
0321  * return   the rxd_free count of receive queue 1
0322  *
0323  *  END_MANUAL_ENTRY
0324  */
0325 #define HWM_GET_RX_FREE(smc)    ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_free-1)
0326 
0327 /*
0328  *  BEGIN_MANUAL_ENTRY(HWM_GET_CURR_RXD)
0329  *  rxd *HWM_GET_CURR_RXD(smc)
0330  *
0331  * function MACRO       (hardware module, hwmtm.h)
0332  *      This macro may be invoked by the OS-specific module to get the
0333  *      pointer to the RxD which points to the current queue put
0334  *      position.
0335  *
0336  * return   pointer to the current RxD
0337  *
0338  *  END_MANUAL_ENTRY
0339  */
0340 #define HWM_GET_CURR_RXD(smc)   (struct s_smt_fp_rxd volatile *)\
0341                 (smc)->hw.fp.rx_q[QUEUE_R1].rx_curr_put
0342 
0343 /*
0344  *  BEGIN_MANUAL_ENTRY(HWM_RX_CHECK)
0345  *  void HWM_RX_CHECK(smc,low_water)
0346  *
0347  * function MACRO       (hardware module, hwmtm.h)
0348  *      This macro is invoked by the OS-specific before it left the
0349  *      function mac_drv_rx_complete. This macro calls mac_drv_fill_rxd
0350  *      if the number of used RxDs is equal or lower than the
0351  *      given low water mark.
0352  *
0353  * para low_water   low water mark of used RxD's
0354  *
0355  *  END_MANUAL_ENTRY
0356  */
0357 #ifndef HWM_NO_FLOW_CTL
0358 #define HWM_RX_CHECK(smc,low_water) {\
0359     if ((low_water) >= (smc)->hw.fp.rx_q[QUEUE_R1].rx_used) {\
0360         mac_drv_fill_rxd(smc) ;\
0361     }\
0362 }
0363 #else
0364 #define HWM_RX_CHECK(smc,low_water)     mac_drv_fill_rxd(smc)
0365 #endif
0366 
0367 #ifndef HWM_EBASE
0368 #define HWM_EBASE   500
0369 #endif
0370 
0371 #define HWM_E0001   HWM_EBASE + 1
0372 #define HWM_E0001_MSG   "HWM: Wrong size of s_rxd_os struct"
0373 #define HWM_E0002   HWM_EBASE + 2
0374 #define HWM_E0002_MSG   "HWM: Wrong size of s_txd_os struct"
0375 #define HWM_E0003   HWM_EBASE + 3
0376 #define HWM_E0003_MSG   "HWM: smt_free_mbuf() called with NULL pointer"
0377 #define HWM_E0004   HWM_EBASE + 4
0378 #define HWM_E0004_MSG   "HWM: Parity error rx queue 1"
0379 #define HWM_E0005   HWM_EBASE + 5
0380 #define HWM_E0005_MSG   "HWM: Encoding error rx queue 1"
0381 #define HWM_E0006   HWM_EBASE + 6
0382 #define HWM_E0006_MSG   "HWM: Encoding error async tx queue"
0383 #define HWM_E0007   HWM_EBASE + 7
0384 #define HWM_E0007_MSG   "HWM: Encoding error sync tx queue"
0385 #define HWM_E0008   HWM_EBASE + 8
0386 #define HWM_E0008_MSG   ""
0387 #define HWM_E0009   HWM_EBASE + 9
0388 #define HWM_E0009_MSG   "HWM: Out of RxD condition detected"
0389 #define HWM_E0010   HWM_EBASE + 10
0390 #define HWM_E0010_MSG   "HWM: A protocol layer has tried to send a frame with an invalid frame control"
0391 #define HWM_E0011   HWM_EBASE + 11
0392 #define HWM_E0011_MSG   "HWM: mac_drv_clear_tx_queue was called although the hardware wasn't stopped"
0393 #define HWM_E0012   HWM_EBASE + 12
0394 #define HWM_E0012_MSG   "HWM: mac_drv_clear_rx_queue was called although the hardware wasn't stopped"
0395 #define HWM_E0013   HWM_EBASE + 13
0396 #define HWM_E0013_MSG   "HWM: mac_drv_repair_descr was called although the hardware wasn't stopped"
0397 
0398 #endif