Lines Matching defs:smc

21 #include "h/smc.h"
70 static void queue_llc_rx(struct s_smc *smc, SMbuf *mb);
71 static void smt_to_llc(struct s_smc *smc, SMbuf *mb);
72 static void init_txd_ring(struct s_smc *smc);
73 static void init_rxd_ring(struct s_smc *smc);
74 static void queue_txd_mb(struct s_smc *smc, SMbuf *mb);
75 static u_long init_descr_ring(struct s_smc *smc, union s_fp_descr volatile *start,
77 static u_long repair_txd_ring(struct s_smc *smc, struct s_smt_tx_queue *queue);
78 static u_long repair_rxd_ring(struct s_smc *smc, struct s_smt_rx_queue *queue);
79 static SMbuf* get_llc_rx(struct s_smc *smc);
80 static SMbuf* get_txd_mb(struct s_smc *smc);
81 static void mac_drv_clear_txd(struct s_smc *smc);
90 extern void* mac_drv_get_space(struct s_smc *smc, unsigned int size);
91 extern void* mac_drv_get_desc_mem(struct s_smc *smc, unsigned int size);
92 extern void mac_drv_fill_rxd(struct s_smc *smc);
93 extern void mac_drv_tx_complete(struct s_smc *smc,
95 extern void mac_drv_rx_complete(struct s_smc *smc,
98 extern void mac_drv_requeue_rxd(struct s_smc *smc,
101 extern void mac_drv_clear_rxd(struct s_smc *smc,
113 extern u_long mac_drv_virt2phys(struct s_smc *smc, void *virt);
114 extern u_long dma_master(struct s_smc *smc, void *virt, int len, int flag);
119 extern void dma_complete(struct s_smc *smc, volatile union s_fp_descr *descr,
123 extern int mac_drv_rx_init(struct s_smc *smc, int len, int fc, char *look_ahead,
131 void process_receive(struct s_smc *smc);
132 void fddi_isr(struct s_smc *smc);
133 void smt_free_mbuf(struct s_smc *smc, SMbuf *mb);
134 void init_driver_fplus(struct s_smc *smc);
135 void mac_drv_rx_mode(struct s_smc *smc, int mode);
136 void init_fddi_driver(struct s_smc *smc, u_char *mac_addr);
137 void mac_drv_clear_tx_queue(struct s_smc *smc);
138 void mac_drv_clear_rx_queue(struct s_smc *smc);
139 void hwm_tx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
141 void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
144 int mac_drv_init(struct s_smc *smc);
145 int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count, int frame_len,
150 SMbuf* smt_get_mbuf(struct s_smc *smc);
153 void mac_drv_debug_lev(struct s_smc *smc, int flag, int lev);
170 #define MA smc->hw.fddi_canon_addr.a
173 #define MA smc->hw.fddi_home_addr.a
242 * void mac_drv_init(smc)
251 int mac_drv_init(struct s_smc *smc)
254 SMT_PANIC(smc,HWM_E0001,HWM_E0001_MSG) ;
257 SMT_PANIC(smc,HWM_E0002,HWM_E0002_MSG) ;
263 if (!(smc->os.hwm.descr_p = (union s_fp_descr volatile *)
264 mac_drv_get_desc_mem(smc,(u_int)
273 smc->os.hwm.mbuf_pool.mb_start=(SMbuf *)(&smc->os.hwm.mbuf_pool.mb[0]) ;
276 if (!(smc->os.hwm.mbuf_pool.mb_start = (SMbuf *) mac_drv_get_space(smc,
282 if (!(mb_start = (SMbuf *) mac_drv_get_space(smc,
294 * init_driver_fplus(smc)
301 void init_driver_fplus(struct s_smc *smc)
303 smc->hw.fp.mdr2init = FM_LSB | FM_BMMODE | FM_ENNPRQ | FM_ENHSRQ | 3 ;
306 smc->hw.fp.mdr2init |= FM_CHKPAR | FM_PARITY ;
308 smc->hw.fp.mdr3init = FM_MENRQAUNLCK | FM_MENRS ;
312 smc->hw.fp.frselreg_init = FM_ENXMTADSWAP | FM_ENRCVADSWAP ;
316 static u_long init_descr_ring(struct s_smc *smc,
331 phys = mac_drv_virt2phys(smc,(void *)d1) ;
337 phys = mac_drv_virt2phys(smc,(void *)start) ;
347 static void init_txd_ring(struct s_smc *smc)
356 ds = (struct s_smt_fp_txd volatile *) ((char *)smc->os.hwm.descr_p +
358 queue = smc->hw.fp.tx[QUEUE_A0] ;
360 (void)init_descr_ring(smc,(union s_fp_descr volatile *)ds,
372 queue = smc->hw.fp.tx[QUEUE_S] ;
374 (void)init_descr_ring(smc,(union s_fp_descr volatile *)ds,
384 static void init_rxd_ring(struct s_smc *smc)
393 ds = (struct s_smt_fp_rxd volatile *) smc->os.hwm.descr_p ;
394 queue = smc->hw.fp.rx[QUEUE_R1] ;
396 (void)init_descr_ring(smc,(union s_fp_descr volatile *)ds,
408 * void init_fddi_driver(smc,mac_addr)
414 void init_fddi_driver(struct s_smc *smc, u_char *mac_addr)
419 init_board(smc,mac_addr) ;
420 (void)init_fplus(smc) ;
426 mb = smc->os.hwm.mbuf_pool.mb_start ;
427 smc->os.hwm.mbuf_pool.mb_free = (SMbuf *)NULL ;
430 smt_free_mbuf(smc,mb) ;
439 smt_free_mbuf(smc,mb) ;
449 smc->os.hwm.llc_rx_pipe = smc->os.hwm.llc_rx_tail = (SMbuf *)NULL ;
450 smc->os.hwm.txd_tx_pipe = smc->os.hwm.txd_tx_tail = NULL ;
451 smc->os.hwm.pass_SMT = smc->os.hwm.pass_NSA = smc->os.hwm.pass_DB = 0 ;
452 smc->os.hwm.pass_llc_promisc = TRUE ;
453 smc->os.hwm.queued_rx_frames = smc->os.hwm.queued_txd_mb = 0 ;
454 smc->os.hwm.detec_count = 0 ;
455 smc->os.hwm.rx_break = 0 ;
456 smc->os.hwm.rx_len_error = 0 ;
457 smc->os.hwm.isr_flag = FALSE ;
462 i = 16 - ((long)smc->os.hwm.descr_p & 0xf) ;
465 smc->os.hwm.descr_p = (union s_fp_descr volatile *)
466 ((char *)smc->os.hwm.descr_p+i) ;
468 DB_GEN(3, "pt to descr area = %p", smc->os.hwm.descr_p);
470 init_txd_ring(smc) ;
471 init_rxd_ring(smc) ;
472 mac_drv_fill_rxd(smc) ;
474 init_plc(smc) ;
478 SMbuf *smt_get_mbuf(struct s_smc *smc)
483 mb = smc->os.hwm.mbuf_pool.mb_free ;
489 smc->os.hwm.mbuf_pool.mb_free = mb->sm_next ;
500 void smt_free_mbuf(struct s_smc *smc, SMbuf *mb)
514 mb->sm_next = smc->os.hwm.mbuf_pool.mb_free ;
515 smc->os.hwm.mbuf_pool.mb_free = mb ;
523 SMT_PANIC(smc,HWM_E0003,HWM_E0003_MSG) ;
529 * void mac_drv_repair_descr(smc)
546 void mac_drv_repair_descr(struct s_smc *smc)
550 if (smc->hw.hw_state != STOPPED) {
552 SMT_PANIC(smc,HWM_E0013,HWM_E0013_MSG) ;
559 phys = repair_txd_ring(smc,smc->hw.fp.tx[QUEUE_A0]) ;
561 if (smc->hw.fp.tx_q[QUEUE_A0].tx_used) {
564 phys = repair_txd_ring(smc,smc->hw.fp.tx[QUEUE_S]) ;
566 if (smc->hw.fp.tx_q[QUEUE_S].tx_used) {
573 phys = repair_rxd_ring(smc,smc->hw.fp.rx[QUEUE_R1]) ;
578 static u_long repair_txd_ring(struct s_smc *smc, struct s_smt_tx_queue *queue)
586 SK_UNUSED(smc) ;
630 static u_long repair_rxd_ring(struct s_smc *smc, struct s_smt_rx_queue *queue)
638 SK_UNUSED(smc) ;
680 * void fddi_isr(smc)
695 * We have to force and Timer IRQ if 'smc->os.hwm.leave_isr' AND
701 void fddi_isr(struct s_smc *smc)
712 if (smc->os.hwm.rx_break) {
713 mac_drv_fill_rxd(smc) ;
714 if (smc->hw.fp.rx_q[QUEUE_R1].rx_used > 0) {
715 smc->os.hwm.rx_break = 0 ;
716 process_receive(smc) ;
719 smc->os.hwm.detec_count = 0 ;
720 smt_force_irq(smc) ;
724 smc->os.hwm.isr_flag = TRUE ;
728 if (smc->os.hwm.leave_isr) {
729 smc->os.hwm.leave_isr = FALSE ;
730 process_receive(smc) ;
741 plc1_irq(smc) ;
744 plc2_irq(smc) ;
750 mac1_irq(smc,stu,stl) ;
757 mac2_irq(smc,stu,stl) ;
763 mac3_irq(smc,stu,stl) ;
766 timer_irq(smc) ;
773 if (++smc->os.hwm.detec_count > 4) {
777 process_receive(smc) ;
781 rtm_irq(smc) ;
786 SMT_PANIC(smc,HWM_E0004,HWM_E0004_MSG) ;
791 SMT_PANIC(smc,HWM_E0005,HWM_E0005_MSG) ;
796 SMT_PANIC(smc,HWM_E0006,HWM_E0006_MSG) ;
801 SMT_PANIC(smc,HWM_E0007,HWM_E0007_MSG) ;
816 mac_drv_clear_txd(smc) ;
817 llc_restart_tx(smc) ;
828 process_receive(smc) ;
830 process_receive(smc) ;
831 if (smc->os.hwm.leave_isr) {
835 process_receive(smc) ;
841 while ((mb = get_llc_rx(smc))) {
842 smt_to_llc(smc,mb) ;
848 while (!offDepth && (mb = get_llc_rx(smc))) {
849 smt_to_llc(smc,mb) ;
852 if (!offDepth && smc->os.hwm.rx_break) {
853 process_receive(smc) ;
856 if (smc->q.ev_get != smc->q.ev_put) {
858 ev_dispatcher(smc) ;
867 if (smc->os.hwm.leave_isr) {
876 if (smc->os.hwm.leave_isr && force_irq) {
877 smt_force_irq(smc) ;
880 smc->os.hwm.isr_flag = FALSE ;
894 * void mac_drv_rx_mode(smc,mode)
984 void mac_drv_rx_mode(struct s_smc *smc, int mode)
988 smc->os.hwm.pass_SMT = TRUE ;
991 smc->os.hwm.pass_SMT = FALSE ;
994 smc->os.hwm.pass_NSA = TRUE ;
997 smc->os.hwm.pass_NSA = FALSE ;
1000 smc->os.hwm.pass_DB = TRUE ;
1003 smc->os.hwm.pass_DB = FALSE ;
1006 smc->os.hwm.pass_SMT = smc->os.hwm.pass_NSA = FALSE ;
1007 smc->os.hwm.pass_DB = FALSE ;
1008 smc->os.hwm.pass_llc_promisc = TRUE ;
1009 mac_set_rx_mode(smc,RX_DISABLE_NSA) ;
1012 smc->os.hwm.pass_llc_promisc = FALSE ;
1015 smc->os.hwm.pass_llc_promisc = TRUE ;
1024 mac_set_rx_mode(smc,mode) ;
1033 void process_receive(struct s_smc *smc)
1051 smc->os.hwm.detec_count = 0 ;
1052 queue = smc->hw.fp.rx[QUEUE_R1] ;
1060 if (smc->os.hwm.leave_isr) {
1066 smc->os.hwm.rx_break = 1 ;
1069 smc->os.hwm.rx_break = 0 ;
1072 if (smc->os.hwm.rx_break) {
1092 SMT_PANIC(smc,HWM_E0009,HWM_E0009_MSG) ;
1096 smc->hw.hw_state = STOPPED ;
1097 mac_drv_clear_rx_queue(smc) ;
1098 smc->hw.hw_state = STARTED ;
1099 mac_drv_fill_rxd(smc) ;
1100 smc->os.hwm.detec_count = 0 ;
1160 dma_complete(smc,(union s_fp_descr volatile *)r,DMA_WR);
1162 smc->hw.fp.err_stats.err_valid++ ;
1163 smc->mib.m[MAC0].fddiMACCopied_Ct++ ;
1175 smc->hw.fp.err_stats.err_abort++ ;
1182 smc->hw.fp.err_stats.err_e_indicator++ ;
1186 smc->hw.fp.err_stats.err_crc++ ;
1190 smc->hw.fp.err_stats.err_imp_frame++ ;
1196 smc->hw.fp.err_stats.err_too_long++ ;
1210 smc->os.hwm.rx_len_error++ ;
1237 if (!smc->os.hwm.pass_llc_promisc) {
1255 mac_drv_rx_complete(smc,rxd,frag_count,len) ;
1258 if (!(mb = smt_get_mbuf(smc))) {
1259 smc->hw.fp.err_stats.err_no_buf++ ;
1288 smc->hw.fp.err_stats.err_smt_frame++ ;
1291 if (smc->os.hwm.pass_SMT) {
1293 mac_drv_rx_complete(smc, rxd,
1298 mac_drv_requeue_rxd(smc,rxd,frag_count);
1301 smt_received_pack(smc,mb,(int)(rfsw>>25)) ;
1304 smc->hw.fp.err_stats.err_smt_frame++ ;
1310 if (smc->os.hwm.pass_NSA ||
1311 (smc->os.hwm.pass_SMT &&
1314 mac_drv_rx_complete(smc, rxd,
1319 mac_drv_requeue_rxd(smc,rxd,frag_count);
1322 smt_received_pack(smc,mb,(int)(rfsw>>25)) ;
1325 if (smc->os.hwm.pass_DB) {
1327 mac_drv_rx_complete(smc, rxd,
1332 mac_drv_requeue_rxd(smc,rxd,frag_count);
1334 smt_free_mbuf(smc,mb) ;
1341 smt_free_mbuf(smc,mb) ;
1343 mac_drv_requeue_rxd(smc,rxd,frag_count) ;
1345 smc->hw.fp.err_stats.err_mac_frame++ ;
1347 smc->hw.fp.err_stats.err_imp_frame++ ;
1360 mac_drv_requeue_rxd(smc,rxd,frag_count) ;
1367 mac_drv_all_receives_complete(smc) ;
1372 static void smt_to_llc(struct s_smc *smc, SMbuf *mb)
1377 smc->os.hwm.r.len = mb->sm_len ;
1378 smc->os.hwm.r.mb_pos = smtod(mb,char *) ;
1379 fc = *smc->os.hwm.r.mb_pos ;
1380 (void)mac_drv_rx_init(smc,(int)mb->sm_len,(int)fc,
1381 smc->os.hwm.r.mb_pos,(int)mb->sm_len) ;
1382 smt_free_mbuf(smc,mb) ;
1387 * void hwm_rx_frag(smc,virt,phys,len,frame_status)
1407 void hwm_rx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
1415 r = smc->hw.fp.rx_q[QUEUE_R1].rx_curr_put ;
1426 smc->hw.fp.rx_q[QUEUE_R1].rx_free-- ;
1427 smc->hw.fp.rx_q[QUEUE_R1].rx_used++ ;
1428 smc->hw.fp.rx_q[QUEUE_R1].rx_curr_put = r->rxd_next ;
1435 * void mac_drv_clear_rx_queue(smc)
1436 * struct s_smc *smc ;
1455 void mac_drv_clear_rx_queue(struct s_smc *smc)
1463 if (smc->hw.hw_state != STOPPED) {
1465 SMT_PANIC(smc,HWM_E0012,HWM_E0012_MSG) ;
1469 queue = smc->hw.fp.rx[QUEUE_R1] ;
1498 dma_complete(smc,(union s_fp_descr volatile *)r,DMA_WR);
1503 mac_drv_clear_rxd(smc,queue->rx_curr_get,frag_count) ;
1520 * int hwm_tx_init(smc,fc,frag_count,frame_len,frame_status)
1542 int hwm_tx_init(struct s_smc *smc, u_char fc, int frag_count, int frame_len,
1546 smc->os.hwm.tx_p = smc->hw.fp.tx[frame_status & QUEUE_A0] ;
1547 smc->os.hwm.tx_descr = TX_DESCRIPTOR | (((u_long)(frame_len-1)&3)<<27) ;
1548 smc->os.hwm.tx_len = frame_len ;
1566 SMT_PANIC(smc,HWM_E0010,HWM_E0010_MSG) ;
1569 if (!smc->hw.mac_ring_is_up) {
1574 if (frag_count > smc->os.hwm.tx_p->tx_free) {
1576 mac_drv_clear_txd(smc) ;
1577 if (frag_count > smc->os.hwm.tx_p->tx_free) {
1589 NDD_TRACE("THiE",frame_status,smc->os.hwm.tx_p->tx_free,0) ;
1595 * void hwm_tx_frag(smc,virt,phys,len,frame_status)
1620 void hwm_tx_frag(struct s_smc *smc, char far *virt, u_long phys, int len,
1627 queue = smc->os.hwm.tx_p ;
1642 t->txd_txdscr = cpu_to_le32(smc->os.hwm.tx_descr) ;
1665 smc->mib.m[MAC0].fddiMACTransmit_Ct++ ;
1671 if(!(smc->os.hwm.tx_mb = smt_get_mbuf(smc))) {
1672 smc->hw.fp.err_stats.err_no_buf++ ;
1676 smc->os.hwm.tx_data =
1677 smtod(smc->os.hwm.tx_mb,char *) - 1 ;
1680 hwm_cpy_txd2mb(t,smc->os.hwm.tx_data,
1681 smc->os.hwm.tx_len) ;
1686 if (smc->os.hwm.tx_mb) {
1689 memcpy(smc->os.hwm.tx_data,virt,len) ;
1690 smc->os.hwm.tx_data += len ;
1702 hwm_cpy_txd2mb(t,smc->os.hwm.tx_data,
1703 smc->os.hwm.tx_len) ;
1706 smc->os.hwm.tx_data =
1707 smtod(smc->os.hwm.tx_mb,char *) - 1 ;
1708 *(char *)smc->os.hwm.tx_mb->sm_data =
1709 *smc->os.hwm.tx_data ;
1710 smc->os.hwm.tx_data++ ;
1711 smc->os.hwm.tx_mb->sm_len =
1712 smc->os.hwm.tx_len - 1 ;
1714 smt_received_pack(smc,smc->os.hwm.tx_mb,
1726 static void queue_llc_rx(struct s_smc *smc, SMbuf *mb)
1729 smc->os.hwm.queued_rx_frames++ ;
1731 if (smc->os.hwm.llc_rx_pipe == NULL) {
1732 smc->os.hwm.llc_rx_pipe = mb ;
1735 smc->os.hwm.llc_rx_tail->sm_next = mb ;
1737 smc->os.hwm.llc_rx_tail = mb ;
1742 if (!smc->os.hwm.isr_flag) {
1743 smt_force_irq(smc) ;
1750 static SMbuf *get_llc_rx(struct s_smc *smc)
1754 if ((mb = smc->os.hwm.llc_rx_pipe)) {
1755 smc->os.hwm.queued_rx_frames-- ;
1756 smc->os.hwm.llc_rx_pipe = mb->sm_next ;
1766 static void queue_txd_mb(struct s_smc *smc, SMbuf *mb)
1769 smc->os.hwm.queued_txd_mb++ ;
1771 if (smc->os.hwm.txd_tx_pipe == NULL) {
1772 smc->os.hwm.txd_tx_pipe = mb ;
1775 smc->os.hwm.txd_tx_tail->sm_next = mb ;
1777 smc->os.hwm.txd_tx_tail = mb ;
1783 static SMbuf *get_txd_mb(struct s_smc *smc)
1787 if ((mb = smc->os.hwm.txd_tx_pipe)) {
1788 smc->os.hwm.queued_txd_mb-- ;
1789 smc->os.hwm.txd_tx_pipe = mb->sm_next ;
1798 void smt_send_mbuf(struct s_smc *smc, SMbuf *mb, int fc)
1844 queue = smc->hw.fp.tx[QUEUE_A0] ;
1850 if ((smc->os.hwm.pass_NSA &&(fc == FC_SMT_NSA)) ||
1851 (smc->os.hwm.pass_SMT &&(fc == FC_SMT_INFO)))
1855 if (!smc->hw.mac_ring_is_up || frag_count > queue->tx_free) {
1862 smt_free_mbuf(smc,mb) ;
1883 phys = dma_master(smc, (void far *)virt[i],
1902 smc->mib.m[MAC0].fddiMACTransmit_Ct++ ;
1903 queue_txd_mb(smc,mb) ;
1908 queue_llc_rx(smc,mb) ;
1915 mac_drv_clear_txd(smc) ;
1920 * void mac_drv_clear_txd(smc)
1933 static void mac_drv_clear_txd(struct s_smc *smc)
1946 queue = smc->hw.fp.tx[i] ;
1969 dma_complete(smc,
1978 mb = get_txd_mb(smc) ;
1979 smt_free_mbuf(smc,mb) ;
1984 mac_drv_tx_complete(smc,t2) ;
1988 mac_drv_tx_complete(smc,queue->tx_curr_get) ;
2003 * void mac_drv_clear_tx_queue(smc)
2004 * struct s_smc *smc ;
2023 void mac_drv_clear_tx_queue(struct s_smc *smc)
2030 if (smc->hw.hw_state != STOPPED) {
2032 SMT_PANIC(smc,HWM_E0011,HWM_E0011_MSG) ;
2037 queue = smc->hw.fp.tx[i] ;
2058 mac_drv_clear_txd(smc) ;
2061 queue = smc->hw.fp.tx[i] ;
2091 * void mac_drv_debug_lev(smc,flag,lev)
2115 void mac_drv_debug_lev(struct s_smc *smc, int flag, int lev)