123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
#ifndef _HWM_
#define _HWM_
#include "mbuf.h"
#ifndef DRV_BUF_FLUSH
#define DRV_BUF_FLUSH(desc,flag)
#define DDI_DMA_SYNC_FORCPU
#define DDI_DMA_SYNC_FORDEV
#endif
#define RX_ENABLE_PASS_SMT 21
#define RX_DISABLE_PASS_SMT 22
#define RX_ENABLE_PASS_NSA 23
#define RX_DISABLE_PASS_NSA 24
#define RX_ENABLE_PASS_DB 25
#define RX_DISABLE_PASS_DB 26
#define RX_DISABLE_PASS_ALL 27
#define RX_DISABLE_LLC_PROMISC 28
#define RX_ENABLE_LLC_PROMISC 29
#ifndef DMA_RD
#define DMA_RD 1 /* memory -> hw */
#endif
#ifndef DMA_WR
#define DMA_WR 2 /* hw -> memory */
#endif
#define SMT_BUF 0x80
#define EN_IRQ_EOF 0x02 /* get IRQ after end of frame transmission */
#define LOC_TX 0x04 /* send frame to the local SMT */
#define LAST_FRAG 0x08 /* last TxD of the frame */
#define FIRST_FRAG 0x10 /* first TxD of the frame */
#define LAN_TX 0x20 /* send frame to network if set */
#define RING_DOWN 0x40 /* error: unable to send, ring down */
#define OUT_OF_TXD 0x80 /* error: not enough TxDs available */
#ifndef NULL
#define NULL 0
#endif
#define C_INDIC (1L<<25)
#define A_INDIC (1L<<26)
#define RD_FS_LOCAL 0x80
#define DEBUG_SMTF 1
#define DEBUG_SMT 2
#define DEBUG_ECM 3
#define DEBUG_RMT 4
#define DEBUG_CFM 5
#define DEBUG_PCM 6
#define DEBUG_SBA 7
#define DEBUG_ESS 8
#define DB_HWM_RX 10
#define DB_HWM_TX 11
#define DB_HWM_GEN 12
struct s_mbuf_pool {
#ifndef MB_OUTSIDE_SMC
SMbuf mb[MAX_MBUF] ;
#endif
SMbuf *mb_start ;
SMbuf *mb_free ;
} ;
struct hwm_r {
u_int len ;
char *mb_pos ;
} ;
struct hw_modul {
struct s_mbuf_pool mbuf_pool ;
struct hwm_r r ;
union s_fp_descr volatile *descr_p ;
u_short pass_SMT ;
u_short pass_NSA ;
u_short pass_DB ;
u_short pass_llc_promisc ;
SMbuf *llc_rx_pipe ;
SMbuf *llc_rx_tail ;
int queued_rx_frames ;
SMbuf *txd_tx_pipe ;
SMbuf *txd_tx_tail ;
int queued_txd_mb ;
int rx_break ;
int leave_isr ;
int isr_flag ;
struct s_smt_tx_queue *tx_p ;
u_long tx_descr ;
int tx_len ;
SMbuf *tx_mb ;
char *tx_data ;
int detec_count ;
u_long rx_len_error ;
} ;
#ifdef DEBUG
struct os_debug {
int hwm_rx ;
int hwm_tx ;
int hwm_gen ;
} ;
#endif
#ifdef DEBUG
#ifdef DEBUG_BRD
#define DB_P smc->debug
#else
#define DB_P debug
#endif
#define DB_RX(lev, fmt, ...) \
do { \
if (DB_P.d_os.hwm_rx >= (lev)) \
printf(fmt "\n", ##__VA_ARGS__); \
} while (0)
#define DB_TX(lev, fmt, ...) \
do { \
if (DB_P.d_os.hwm_tx >= (lev)) \
printf(fmt "\n", ##__VA_ARGS__); \
} while (0)
#define DB_GEN(lev, fmt, ...) \
do { \
if (DB_P.d_os.hwm_gen >= (lev)) \
printf(fmt "\n", ##__VA_ARGS__); \
} while (0)
#else /* DEBUG */
#define DB_RX(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)
#define DB_TX(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)
#define DB_GEN(lev, fmt, ...) no_printk(fmt "\n", ##__VA_ARGS__)
#endif /* DEBUG */
#ifndef SK_BREAK
#define SK_BREAK()
#endif
#define HWM_GET_TX_PHYS(txd) (u_long)AIX_REVERSE((txd)->txd_tbadr)
#define HWM_GET_TX_LEN(txd) ((int)AIX_REVERSE((txd)->txd_tbctrl)& RD_LENGTH)
#define HWM_GET_TX_USED(smc,queue) (int) (smc)->hw.fp.tx_q[queue].tx_used
#define HWM_GET_CURR_TXD(smc,queue) (struct s_smt_fp_txd volatile *)\
(smc)->hw.fp.tx_q[queue].tx_curr_put
#define HWM_GET_RX_FRAG_LEN(rxd) ((int)AIX_REVERSE((rxd)->rxd_rbctrl)& \
RD_LENGTH)
#define HWM_GET_RX_PHYS(rxd) (u_long)AIX_REVERSE((rxd)->rxd_rbadr)
#define HWM_GET_RX_USED(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_used)
#define HWM_GET_RX_FREE(smc) ((int)(smc)->hw.fp.rx_q[QUEUE_R1].rx_free-1)
#define HWM_GET_CURR_RXD(smc) (struct s_smt_fp_rxd volatile *)\
(smc)->hw.fp.rx_q[QUEUE_R1].rx_curr_put
#ifndef HWM_NO_FLOW_CTL
#define HWM_RX_CHECK(smc,low_water) {\
if ((low_water) >= (smc)->hw.fp.rx_q[QUEUE_R1].rx_used) {\
mac_drv_fill_rxd(smc) ;\
}\
}
#else
#define HWM_RX_CHECK(smc,low_water) mac_drv_fill_rxd(smc)
#endif
#ifndef HWM_EBASE
#define HWM_EBASE 500
#endif
#define HWM_E0001 HWM_EBASE + 1
#define HWM_E0001_MSG "HWM: Wrong size of s_rxd_os struct"
#define HWM_E0002 HWM_EBASE + 2
#define HWM_E0002_MSG "HWM: Wrong size of s_txd_os struct"
#define HWM_E0003 HWM_EBASE + 3
#define HWM_E0003_MSG "HWM: smt_free_mbuf() called with NULL pointer"
#define HWM_E0004 HWM_EBASE + 4
#define HWM_E0004_MSG "HWM: Parity error rx queue 1"
#define HWM_E0005 HWM_EBASE + 5
#define HWM_E0005_MSG "HWM: Encoding error rx queue 1"
#define HWM_E0006 HWM_EBASE + 6
#define HWM_E0006_MSG "HWM: Encoding error async tx queue"
#define HWM_E0007 HWM_EBASE + 7
#define HWM_E0007_MSG "HWM: Encoding error sync tx queue"
#define HWM_E0008 HWM_EBASE + 8
#define HWM_E0008_MSG ""
#define HWM_E0009 HWM_EBASE + 9
#define HWM_E0009_MSG "HWM: Out of RxD condition detected"
#define HWM_E0010 HWM_EBASE + 10
#define HWM_E0010_MSG "HWM: A protocol layer has tried to send a frame with an invalid frame control"
#define HWM_E0011 HWM_EBASE + 11
#define HWM_E0011_MSG "HWM: mac_drv_clear_tx_queue was called although the hardware wasn't stopped"
#define HWM_E0012 HWM_EBASE + 12
#define HWM_E0012_MSG "HWM: mac_drv_clear_rx_queue was called although the hardware wasn't stopped"
#define HWM_E0013 HWM_EBASE + 13
#define HWM_E0013_MSG "HWM: mac_drv_repair_descr was called although the hardware wasn't stopped"
#endif