399 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later */2/******************************************************************************3 *4 * (C)Copyright 1998,1999 SysKonnect,5 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.6 *7 * The information in this file is provided "AS IS" without warranty.8 *9 ******************************************************************************/10 11#ifndef _HWM_12#define _HWM_13 14#include "mbuf.h"15 16/*17 * MACRO for DMA synchronization:18 * The descriptor 'desc' is flushed for the device 'flag'.19 * Devices are the CPU (DDI_DMA_SYNC_FORCPU) and the20 * adapter (DDI_DMA_SYNC_FORDEV).21 *22 * 'desc' Pointer to a Rx or Tx descriptor.23 * 'flag' Flag for direction (view for CPU or DEVICE) that24 * should be synchronized.25 *26 * Empty macros and defines are specified here. The real macro27 * is os-specific and should be defined in osdef1st.h.28 */29#ifndef DRV_BUF_FLUSH30#define DRV_BUF_FLUSH(desc,flag)31#define DDI_DMA_SYNC_FORCPU32#define DDI_DMA_SYNC_FORDEV33#endif34 35 /*36 * hardware modul dependent receive modes37 */38#define RX_ENABLE_PASS_SMT 2139#define RX_DISABLE_PASS_SMT 2240#define RX_ENABLE_PASS_NSA 2341#define RX_DISABLE_PASS_NSA 2442#define RX_ENABLE_PASS_DB 2543#define RX_DISABLE_PASS_DB 2644#define RX_DISABLE_PASS_ALL 2745#define RX_DISABLE_LLC_PROMISC 2846#define RX_ENABLE_LLC_PROMISC 2947 48 49#ifndef DMA_RD50#define DMA_RD 1 /* memory -> hw */51#endif52#ifndef DMA_WR53#define DMA_WR 2 /* hw -> memory */54#endif55#define SMT_BUF 0x8056 57 /*58 * bits of the frame status byte59 */60#define EN_IRQ_EOF 0x02 /* get IRQ after end of frame transmission */61#define LOC_TX 0x04 /* send frame to the local SMT */62#define LAST_FRAG 0x08 /* last TxD of the frame */63#define FIRST_FRAG 0x10 /* first TxD of the frame */64#define LAN_TX 0x20 /* send frame to network if set */65#define RING_DOWN 0x40 /* error: unable to send, ring down */66#define OUT_OF_TXD 0x80 /* error: not enough TxDs available */67 68 69#ifndef NULL70#define NULL 071#endif72 73#define C_INDIC (1L<<25)74#define A_INDIC (1L<<26)75#define RD_FS_LOCAL 0x8076 77 /*78 * DEBUG FLAGS79 */80#define DEBUG_SMTF 181#define DEBUG_SMT 282#define DEBUG_ECM 383#define DEBUG_RMT 484#define DEBUG_CFM 585#define DEBUG_PCM 686#define DEBUG_SBA 787#define DEBUG_ESS 888 89#define DB_HWM_RX 1090#define DB_HWM_TX 1191#define DB_HWM_GEN 1292 93struct s_mbuf_pool {94#ifndef MB_OUTSIDE_SMC95 SMbuf mb[MAX_MBUF] ; /* mbuf pool */96#endif97 SMbuf *mb_start ; /* points to the first mb */98 SMbuf *mb_free ; /* free queue */99} ;100 101struct hwm_r {102 /*103 * hardware modul specific receive variables104 */105 u_int len ; /* length of the whole frame */106 char *mb_pos ; /* SMbuf receive position */107} ;108 109struct hw_modul {110 /*111 * All hardware modul specific variables112 */113 struct s_mbuf_pool mbuf_pool ;114 struct hwm_r r ;115 116 union s_fp_descr volatile *descr_p ; /* points to the desriptor area */117 118 u_short pass_SMT ; /* pass SMT frames */119 u_short pass_NSA ; /* pass all NSA frames */120 u_short pass_DB ; /* pass Direct Beacon Frames */121 u_short pass_llc_promisc ; /* pass all llc frames (default ON) */122 123 SMbuf *llc_rx_pipe ; /* points to the first queued llc fr */124 SMbuf *llc_rx_tail ; /* points to the last queued llc fr */125 int queued_rx_frames ; /* number of queued frames */126 127 SMbuf *txd_tx_pipe ; /* points to first mb in the txd ring */128 SMbuf *txd_tx_tail ; /* points to last mb in the txd ring */129 int queued_txd_mb ; /* number of SMT MBufs in txd ring */130 131 int rx_break ; /* rev. was breaked because ind. off */132 int leave_isr ; /* leave fddi_isr immedeately if set */133 int isr_flag ; /* set, when HWM is entered from isr */134 /*135 * variables for the current transmit frame136 */137 struct s_smt_tx_queue *tx_p ; /* pointer to the transmit queue */138 u_long tx_descr ; /* tx descriptor for FORMAC+ */139 int tx_len ; /* tx frame length */140 SMbuf *tx_mb ; /* SMT tx MBuf pointer */141 char *tx_data ; /* data pointer to the SMT tx Mbuf */142 143 int detec_count ; /* counter for out of RxD condition */144 u_long rx_len_error ; /* rx len FORMAC != sum of fragments */145} ;146 147 148/*149 * DEBUG structs and macros150 */151 152#ifdef DEBUG153struct os_debug {154 int hwm_rx ;155 int hwm_tx ;156 int hwm_gen ;157} ;158#endif159 160#ifdef DEBUG161#ifdef DEBUG_BRD162#define DB_P smc->debug163#else164#define DB_P debug165#endif166 167#define DB_RX(lev, fmt, ...) \168do { \169 if (DB_P.d_os.hwm_rx >= (lev)) \170 printf(fmt "\n", ##__VA_ARGS__); \171} while (0)172#define DB_TX(lev, fmt, ...) \173do { \174 if (DB_P.d_os.hwm_tx >= (lev)) \175 printf(fmt "\n", ##__VA_ARGS__); \176} while (0)177#define DB_GEN(lev, fmt, ...) \178do { \179 if (DB_P.d_os.hwm_gen >= (lev)) \180 printf(fmt "\n", ##__VA_ARGS__); \181} while (0)182#else /* DEBUG */183#define DB_RX(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)184#define DB_TX(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)185#define DB_GEN(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)186#endif /* DEBUG */187 188#ifndef SK_BREAK189#define SK_BREAK()190#endif191 192 193/*194 * HWM Macros195 */196 197/*198 * BEGIN_MANUAL_ENTRY(HWM_GET_TX_PHYS)199 * u_long HWM_GET_TX_PHYS(txd)200 *201 * function MACRO (hardware module, hwmtm.h)202 * This macro may be invoked by the OS-specific module to read203 * the physical address of the specified TxD.204 *205 * para txd pointer to the TxD206 *207 * END_MANUAL_ENTRY208 */209#define HWM_GET_TX_PHYS(txd) (u_long)AIX_REVERSE((txd)->txd_tbadr)210 211/*212 * BEGIN_MANUAL_ENTRY(HWM_GET_TX_LEN)213 * int HWM_GET_TX_LEN(txd)214 *215 * function MACRO (hardware module, hwmtm.h)216 * This macro may be invoked by the OS-specific module to read217 * the fragment length of the specified TxD218 *219 * para rxd pointer to the TxD220 *221 * return the length of the fragment in bytes222 *223 * END_MANUAL_ENTRY224 */225#define HWM_GET_TX_LEN(txd) ((int)AIX_REVERSE((txd)->txd_tbctrl)& RD_LENGTH)226 227/*228 * BEGIN_MANUAL_ENTRY(HWM_GET_TX_USED)229 * txd *HWM_GET_TX_USED(smc,queue)230 *231 * function MACRO (hardware module, hwmtm.h)232 * This macro may be invoked by the OS-specific module to get the233 * number of used TxDs for the queue, specified by the index.234 *235 * para queue the number of the send queue: Can be specified by236 * QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)237 *238 * return number of used TxDs for this send queue239 *240 * END_MANUAL_ENTRY241 */242#define HWM_GET_TX_USED(smc,queue) (int) (smc)->hw.fp.tx_q[queue].tx_used243 244/*245 * BEGIN_MANUAL_ENTRY(HWM_GET_CURR_TXD)246 * txd *HWM_GET_CURR_TXD(smc,queue)247 *248 * function MACRO (hardware module, hwmtm.h)249 * This macro may be invoked by the OS-specific module to get the250 * pointer to the TxD which points to the current queue put251 * position.252 *253 * para queue the number of the send queue: Can be specified by254 * QUEUE_A0, QUEUE_S or (frame_status & QUEUE_A0)255 *256 * return pointer to the current TxD257 *258 * END_MANUAL_ENTRY259 */260#define HWM_GET_CURR_TXD(smc,queue) (struct s_smt_fp_txd volatile *)\261 (smc)->hw.fp.tx_q[queue].tx_curr_put262 263/*264 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FRAG_LEN)265 * int HWM_GET_RX_FRAG_LEN(rxd)266 *267 * function MACRO (hardware module, hwmtm.h)268 * This macro may be invoked by the OS-specific module to read269 * the fragment length of the specified RxD270 *271 * para rxd pointer to the RxD272 *273 * return the length of the fragment in bytes274 *275 * END_MANUAL_ENTRY276 */277#define HWM_GET_RX_FRAG_LEN(rxd) ((int)AIX_REVERSE((rxd)->rxd_rbctrl)& \278 RD_LENGTH)279 280/*281 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_PHYS)282 * u_long HWM_GET_RX_PHYS(rxd)283 *284 * function MACRO (hardware module, hwmtm.h)285 * This macro may be invoked by the OS-specific module to read286 * the physical address of the specified RxD.287 *288 * para rxd pointer to the RxD289 *290 * return the RxD's physical pointer to the data fragment291 *292 * END_MANUAL_ENTRY293 */294#define HWM_GET_RX_PHYS(rxd) (u_long)AIX_REVERSE((rxd)->rxd_rbadr)295 296/*297 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_USED)298 * int HWM_GET_RX_USED(smc)299 *300 * function MACRO (hardware module, hwmtm.h)301 * This macro may be invoked by the OS-specific module to get302 * the count of used RXDs in receive queue 1.303 *304 * return the used RXD count of receive queue 1305 *306 * NOTE: Remember, because of an ASIC bug at least one RXD should be unused307 * in the descriptor ring !308 *309 * END_MANUAL_ENTRY310 */311#define HWM_GET_RX_USED(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_used)312 313/*314 * BEGIN_MANUAL_ENTRY(HWM_GET_RX_FREE)315 * int HWM_GET_RX_FREE(smc)316 *317 * function MACRO (hardware module, hwmtm.h)318 * This macro may be invoked by the OS-specific module to get319 * the rxd_free count of receive queue 1.320 *321 * return the rxd_free count of receive queue 1322 *323 * END_MANUAL_ENTRY324 */325#define HWM_GET_RX_FREE(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_free-1)326 327/*328 * BEGIN_MANUAL_ENTRY(HWM_GET_CURR_RXD)329 * rxd *HWM_GET_CURR_RXD(smc)330 *331 * function MACRO (hardware module, hwmtm.h)332 * This macro may be invoked by the OS-specific module to get the333 * pointer to the RxD which points to the current queue put334 * position.335 *336 * return pointer to the current RxD337 *338 * END_MANUAL_ENTRY339 */340#define HWM_GET_CURR_RXD(smc) (struct s_smt_fp_rxd volatile *)\341 (smc)->hw.fp.rx_q[QUEUE_R1].rx_curr_put342 343/*344 * BEGIN_MANUAL_ENTRY(HWM_RX_CHECK)345 * void HWM_RX_CHECK(smc,low_water)346 *347 * function MACRO (hardware module, hwmtm.h)348 * This macro is invoked by the OS-specific before it left the349 * function mac_drv_rx_complete. This macro calls mac_drv_fill_rxd350 * if the number of used RxDs is equal or lower than the351 * given low water mark.352 *353 * para low_water low water mark of used RxD's354 *355 * END_MANUAL_ENTRY356 */357#ifndef HWM_NO_FLOW_CTL358#define HWM_RX_CHECK(smc,low_water) {\359 if ((low_water) >= (smc)->hw.fp.rx_q[QUEUE_R1].rx_used) {\360 mac_drv_fill_rxd(smc) ;\361 }\362}363#else364#define HWM_RX_CHECK(smc,low_water) mac_drv_fill_rxd(smc)365#endif366 367#ifndef HWM_EBASE368#define HWM_EBASE 500369#endif370 371#define HWM_E0001 HWM_EBASE + 1372#define HWM_E0001_MSG "HWM: Wrong size of s_rxd_os struct"373#define HWM_E0002 HWM_EBASE + 2374#define HWM_E0002_MSG "HWM: Wrong size of s_txd_os struct"375#define HWM_E0003 HWM_EBASE + 3376#define HWM_E0003_MSG "HWM: smt_free_mbuf() called with NULL pointer"377#define HWM_E0004 HWM_EBASE + 4378#define HWM_E0004_MSG "HWM: Parity error rx queue 1"379#define HWM_E0005 HWM_EBASE + 5380#define HWM_E0005_MSG "HWM: Encoding error rx queue 1"381#define HWM_E0006 HWM_EBASE + 6382#define HWM_E0006_MSG "HWM: Encoding error async tx queue"383#define HWM_E0007 HWM_EBASE + 7384#define HWM_E0007_MSG "HWM: Encoding error sync tx queue"385#define HWM_E0008 HWM_EBASE + 8386#define HWM_E0008_MSG ""387#define HWM_E0009 HWM_EBASE + 9388#define HWM_E0009_MSG "HWM: Out of RxD condition detected"389#define HWM_E0010 HWM_EBASE + 10390#define HWM_E0010_MSG "HWM: A protocol layer has tried to send a frame with an invalid frame control"391#define HWM_E0011 HWM_EBASE + 11392#define HWM_E0011_MSG "HWM: mac_drv_clear_tx_queue was called although the hardware wasn't stopped"393#define HWM_E0012 HWM_EBASE + 12394#define HWM_E0012_MSG "HWM: mac_drv_clear_rx_queue was called although the hardware wasn't stopped"395#define HWM_E0013 HWM_EBASE + 13396#define HWM_E0013_MSG "HWM: mac_drv_repair_descr was called although the hardware wasn't stopped"397 398#endif399