Lines Matching refs:mac
41 static inline int macidx(const struct cmac *mac) in macidx() argument
43 return mac->offset / (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR); in macidx()
46 static void xaui_serdes_reset(struct cmac *mac) in xaui_serdes_reset() argument
54 struct adapter *adap = mac->adapter; in xaui_serdes_reset()
55 u32 ctrl = A_XGM_SERDES_CTRL0 + mac->offset; in xaui_serdes_reset()
57 t3_write_reg(adap, ctrl, adap->params.vpd.xauicfg[macidx(mac)] | in xaui_serdes_reset()
70 void t3b_pcs_reset(struct cmac *mac) in t3b_pcs_reset() argument
72 t3_set_reg_field(mac->adapter, A_XGM_RESET_CTRL + mac->offset, in t3b_pcs_reset()
75 t3_set_reg_field(mac->adapter, A_XGM_RESET_CTRL + mac->offset, 0, in t3b_pcs_reset()
79 int t3_mac_reset(struct cmac *mac) in t3_mac_reset() argument
99 struct adapter *adap = mac->adapter; in t3_mac_reset()
100 unsigned int oft = mac->offset; in t3_mac_reset()
119 macidx(mac)); in t3_mac_reset()
125 xaui_serdes_reset(mac); in t3_mac_reset()
143 t3b_pcs_reset(mac); in t3_mac_reset()
146 memset(&mac->stats, 0, sizeof(mac->stats)); in t3_mac_reset()
150 static int t3b2_mac_reset(struct cmac *mac) in t3b2_mac_reset() argument
152 struct adapter *adap = mac->adapter; in t3b2_mac_reset()
153 unsigned int oft = mac->offset, store; in t3b2_mac_reset()
154 int idx = macidx(mac); in t3b2_mac_reset()
157 if (!macidx(mac)) in t3b2_mac_reset()
185 macidx(mac)); in t3b2_mac_reset()
203 t3b_pcs_reset(mac); in t3b2_mac_reset()
230 static void set_addr_filter(struct cmac *mac, int idx, const u8 * addr) in set_addr_filter() argument
233 unsigned int oft = mac->offset + idx * 8; in set_addr_filter()
238 t3_write_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_LOW_1 + oft, addr_lo); in set_addr_filter()
239 t3_write_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_HIGH_1 + oft, addr_hi); in set_addr_filter()
243 int t3_mac_set_address(struct cmac *mac, unsigned int idx, const u8 addr[6]) in t3_mac_set_address() argument
245 if (idx >= mac->nucast) in t3_mac_set_address()
247 set_addr_filter(mac, idx, addr); in t3_mac_set_address()
256 int t3_mac_set_num_ucast(struct cmac *mac, int n) in t3_mac_set_num_ucast() argument
260 mac->nucast = n; in t3_mac_set_num_ucast()
264 void t3_mac_disable_exact_filters(struct cmac *mac) in t3_mac_disable_exact_filters() argument
266 unsigned int i, reg = mac->offset + A_XGM_RX_EXACT_MATCH_LOW_1; in t3_mac_disable_exact_filters()
269 u32 v = t3_read_reg(mac->adapter, reg); in t3_mac_disable_exact_filters()
270 t3_write_reg(mac->adapter, reg, v); in t3_mac_disable_exact_filters()
272 t3_read_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_LOW_1); /* flush */ in t3_mac_disable_exact_filters()
275 void t3_mac_enable_exact_filters(struct cmac *mac) in t3_mac_enable_exact_filters() argument
277 unsigned int i, reg = mac->offset + A_XGM_RX_EXACT_MATCH_HIGH_1; in t3_mac_enable_exact_filters()
280 u32 v = t3_read_reg(mac->adapter, reg); in t3_mac_enable_exact_filters()
281 t3_write_reg(mac->adapter, reg, v); in t3_mac_enable_exact_filters()
283 t3_read_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_LOW_1); /* flush */ in t3_mac_enable_exact_filters()
300 int t3_mac_set_rx_mode(struct cmac *mac, struct net_device *dev) in t3_mac_set_rx_mode() argument
303 struct adapter *adap = mac->adapter; in t3_mac_set_rx_mode()
304 unsigned int oft = mac->offset; in t3_mac_set_rx_mode()
315 int exact_addr_idx = mac->nucast; in t3_mac_set_rx_mode()
320 set_addr_filter(mac, exact_addr_idx++, in t3_mac_set_rx_mode()
345 int t3_mac_set_mtu(struct cmac *mac, unsigned int mtu) in t3_mac_set_mtu() argument
350 struct adapter *adap = mac->adapter; in t3_mac_set_mtu()
362 t3_write_reg(adap, A_XGM_RX_MAX_PKT_SIZE + mac->offset, mtu); in t3_mac_set_mtu()
365 (t3_read_reg(adap, A_XGM_RX_CTRL + mac->offset) & F_RXEN)) { in t3_mac_set_mtu()
366 t3_mac_disable_exact_filters(mac); in t3_mac_set_mtu()
367 v = t3_read_reg(adap, A_XGM_RX_CFG + mac->offset); in t3_mac_set_mtu()
368 t3_set_reg_field(adap, A_XGM_RX_CFG + mac->offset, in t3_mac_set_mtu()
375 if (t3_wait_op_done(adap, reg + mac->offset, in t3_mac_set_mtu()
377 t3_write_reg(adap, A_XGM_RX_CFG + mac->offset, v); in t3_mac_set_mtu()
378 t3_mac_enable_exact_filters(mac); in t3_mac_set_mtu()
381 t3_set_reg_field(adap, A_XGM_RX_MAX_PKT_SIZE + mac->offset, in t3_mac_set_mtu()
384 t3_write_reg(adap, A_XGM_RX_CFG + mac->offset, v); in t3_mac_set_mtu()
385 t3_mac_enable_exact_filters(mac); in t3_mac_set_mtu()
387 t3_set_reg_field(adap, A_XGM_RX_MAX_PKT_SIZE + mac->offset, in t3_mac_set_mtu()
397 v = t3_read_reg(adap, A_XGM_RXFIFO_CFG + mac->offset); in t3_mac_set_mtu()
404 t3_write_reg(adap, A_XGM_RXFIFO_CFG + mac->offset, v); in t3_mac_set_mtu()
414 t3_set_reg_field(adap, A_XGM_TXFIFO_CFG + mac->offset, in t3_mac_set_mtu()
420 t3_write_reg(adap, A_XGM_PAUSE_TIMER + mac->offset, in t3_mac_set_mtu()
423 t3_write_reg(adap, A_XGM_TX_PAUSE_QUANTA + mac->offset, in t3_mac_set_mtu()
428 int t3_mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex, int fc) in t3_mac_set_speed_duplex_fc() argument
431 struct adapter *adap = mac->adapter; in t3_mac_set_speed_duplex_fc()
432 unsigned int oft = mac->offset; in t3_mac_set_speed_duplex_fc()
467 int t3_mac_enable(struct cmac *mac, int which) in t3_mac_enable() argument
469 int idx = macidx(mac); in t3_mac_enable()
470 struct adapter *adap = mac->adapter; in t3_mac_enable()
471 unsigned int oft = mac->offset; in t3_mac_enable()
472 struct mac_stats *s = &mac->stats; in t3_mac_enable()
486 mac->tx_mcnt = s->tx_frames; in t3_mac_enable()
487 mac->tx_tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap, in t3_mac_enable()
489 mac->tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap, in t3_mac_enable()
492 mac->rx_mcnt = s->rx_frames; in t3_mac_enable()
493 mac->rx_pause = s->rx_pause; in t3_mac_enable()
494 mac->rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap, in t3_mac_enable()
497 mac->rx_ocnt = s->rx_fifo_ovfl; in t3_mac_enable()
498 mac->txen = F_TXEN; in t3_mac_enable()
499 mac->toggle_cnt = 0; in t3_mac_enable()
506 int t3_mac_disable(struct cmac *mac, int which) in t3_mac_disable() argument
508 struct adapter *adap = mac->adapter; in t3_mac_disable()
511 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0); in t3_mac_disable()
512 mac->txen = 0; in t3_mac_disable()
517 t3_set_reg_field(mac->adapter, A_XGM_RESET_CTRL + mac->offset, in t3_mac_disable()
520 t3_write_reg(adap, A_XGM_RX_CTRL + mac->offset, 0); in t3_mac_disable()
527 t3_write_reg(mac->adapter, A_XGM_RESET_CTRL + mac->offset, val); in t3_mac_disable()
532 int t3b2_mac_watchdog_task(struct cmac *mac) in t3b2_mac_watchdog_task() argument
534 struct adapter *adap = mac->adapter; in t3b2_mac_watchdog_task()
535 struct mac_stats *s = &mac->stats; in t3b2_mac_watchdog_task()
542 tx_tcnt = mac->tx_tcnt; /* If tx_mcnt is progressing ignore tx_tcnt */ in t3b2_mac_watchdog_task()
543 if (tx_mcnt == mac->tx_mcnt && mac->rx_pause == s->rx_pause) { in t3b2_mac_watchdog_task()
546 mac->offset))); in t3b2_mac_watchdog_task()
549 A_TP_TX_DROP_CNT_CH0 + macidx(mac)); in t3b2_mac_watchdog_task()
556 mac->toggle_cnt = 0; in t3b2_mac_watchdog_task()
560 if ((tx_tcnt != mac->tx_tcnt) && (mac->tx_xcnt == 0)) { in t3b2_mac_watchdog_task()
561 if (mac->toggle_cnt > 4) { in t3b2_mac_watchdog_task()
569 mac->toggle_cnt = 0; in t3b2_mac_watchdog_task()
574 mac->tx_tcnt = tx_tcnt; in t3b2_mac_watchdog_task()
575 mac->tx_xcnt = tx_xcnt; in t3b2_mac_watchdog_task()
576 mac->tx_mcnt = s->tx_frames; in t3b2_mac_watchdog_task()
577 mac->rx_pause = s->rx_pause; in t3b2_mac_watchdog_task()
579 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0); in t3b2_mac_watchdog_task()
580 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset); /* flush */ in t3b2_mac_watchdog_task()
581 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, mac->txen); in t3b2_mac_watchdog_task()
582 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset); /* flush */ in t3b2_mac_watchdog_task()
583 mac->toggle_cnt++; in t3b2_mac_watchdog_task()
585 t3b2_mac_reset(mac); in t3b2_mac_watchdog_task()
586 mac->toggle_cnt = 0; in t3b2_mac_watchdog_task()
598 const struct mac_stats *t3_mac_update_stats(struct cmac *mac) in t3_mac_update_stats() argument
600 #define RMON_READ(mac, addr) t3_read_reg(mac->adapter, addr + mac->offset) in t3_mac_update_stats() argument
601 #define RMON_UPDATE(mac, name, reg) \ in t3_mac_update_stats() argument
602 (mac)->stats.name += (u64)RMON_READ(mac, A_XGM_STAT_##reg) in t3_mac_update_stats()
603 #define RMON_UPDATE64(mac, name, reg_lo, reg_hi) \ in t3_mac_update_stats() argument
604 (mac)->stats.name += RMON_READ(mac, A_XGM_STAT_##reg_lo) + \ in t3_mac_update_stats()
605 ((u64)RMON_READ(mac, A_XGM_STAT_##reg_hi) << 32) in t3_mac_update_stats()
609 RMON_UPDATE64(mac, rx_octets, RX_BYTES_LOW, RX_BYTES_HIGH); in t3_mac_update_stats()
610 RMON_UPDATE64(mac, rx_frames, RX_FRAMES_LOW, RX_FRAMES_HIGH); in t3_mac_update_stats()
611 RMON_UPDATE(mac, rx_mcast_frames, RX_MCAST_FRAMES); in t3_mac_update_stats()
612 RMON_UPDATE(mac, rx_bcast_frames, RX_BCAST_FRAMES); in t3_mac_update_stats()
613 RMON_UPDATE(mac, rx_fcs_errs, RX_CRC_ERR_FRAMES); in t3_mac_update_stats()
614 RMON_UPDATE(mac, rx_pause, RX_PAUSE_FRAMES); in t3_mac_update_stats()
615 RMON_UPDATE(mac, rx_jabber, RX_JABBER_FRAMES); in t3_mac_update_stats()
616 RMON_UPDATE(mac, rx_short, RX_SHORT_FRAMES); in t3_mac_update_stats()
617 RMON_UPDATE(mac, rx_symbol_errs, RX_SYM_CODE_ERR_FRAMES); in t3_mac_update_stats()
619 RMON_UPDATE(mac, rx_too_long, RX_OVERSIZE_FRAMES); in t3_mac_update_stats()
621 v = RMON_READ(mac, A_XGM_RX_MAX_PKT_SIZE_ERR_CNT); in t3_mac_update_stats()
622 if (mac->adapter->params.rev == T3_REV_B2) in t3_mac_update_stats()
624 mac->stats.rx_too_long += v; in t3_mac_update_stats()
626 RMON_UPDATE(mac, rx_frames_64, RX_64B_FRAMES); in t3_mac_update_stats()
627 RMON_UPDATE(mac, rx_frames_65_127, RX_65_127B_FRAMES); in t3_mac_update_stats()
628 RMON_UPDATE(mac, rx_frames_128_255, RX_128_255B_FRAMES); in t3_mac_update_stats()
629 RMON_UPDATE(mac, rx_frames_256_511, RX_256_511B_FRAMES); in t3_mac_update_stats()
630 RMON_UPDATE(mac, rx_frames_512_1023, RX_512_1023B_FRAMES); in t3_mac_update_stats()
631 RMON_UPDATE(mac, rx_frames_1024_1518, RX_1024_1518B_FRAMES); in t3_mac_update_stats()
632 RMON_UPDATE(mac, rx_frames_1519_max, RX_1519_MAXB_FRAMES); in t3_mac_update_stats()
634 RMON_UPDATE64(mac, tx_octets, TX_BYTE_LOW, TX_BYTE_HIGH); in t3_mac_update_stats()
635 RMON_UPDATE64(mac, tx_frames, TX_FRAME_LOW, TX_FRAME_HIGH); in t3_mac_update_stats()
636 RMON_UPDATE(mac, tx_mcast_frames, TX_MCAST); in t3_mac_update_stats()
637 RMON_UPDATE(mac, tx_bcast_frames, TX_BCAST); in t3_mac_update_stats()
638 RMON_UPDATE(mac, tx_pause, TX_PAUSE); in t3_mac_update_stats()
640 RMON_UPDATE(mac, tx_underrun, TX_ERR_FRAMES); in t3_mac_update_stats()
642 RMON_UPDATE(mac, tx_frames_64, TX_64B_FRAMES); in t3_mac_update_stats()
643 RMON_UPDATE(mac, tx_frames_65_127, TX_65_127B_FRAMES); in t3_mac_update_stats()
644 RMON_UPDATE(mac, tx_frames_128_255, TX_128_255B_FRAMES); in t3_mac_update_stats()
645 RMON_UPDATE(mac, tx_frames_256_511, TX_256_511B_FRAMES); in t3_mac_update_stats()
646 RMON_UPDATE(mac, tx_frames_512_1023, TX_512_1023B_FRAMES); in t3_mac_update_stats()
647 RMON_UPDATE(mac, tx_frames_1024_1518, TX_1024_1518B_FRAMES); in t3_mac_update_stats()
648 RMON_UPDATE(mac, tx_frames_1519_max, TX_1519_MAXB_FRAMES); in t3_mac_update_stats()
651 t3_write_reg(mac->adapter, A_TP_MIB_INDEX, mac->offset ? 51 : 50); in t3_mac_update_stats()
652 v = t3_read_reg(mac->adapter, A_TP_MIB_RDATA); in t3_mac_update_stats()
653 lo = (u32) mac->stats.rx_cong_drops; in t3_mac_update_stats()
654 mac->stats.rx_cong_drops += (u64) (v - lo); in t3_mac_update_stats()
656 return &mac->stats; in t3_mac_update_stats()