Lines Matching full:mac
38 static inline int macidx(const struct cmac *mac) in macidx() argument
40 return mac->offset / (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR); in macidx()
44 * Returns a reasonable A_XGM_RESET_CTRL value for the mac specified.
46 static inline int xgm_reset_ctrl(const struct cmac *mac) in xgm_reset_ctrl() argument
48 adapter_t *adap = mac->adapter; in xgm_reset_ctrl()
52 int cfg = t3_read_reg(adap, A_XGM_PORT_CFG + mac->offset); in xgm_reset_ctrl()
65 static void xaui_serdes_reset(struct cmac *mac) in xaui_serdes_reset() argument
73 adapter_t *adap = mac->adapter; in xaui_serdes_reset()
74 u32 ctrl = A_XGM_SERDES_CTRL0 + mac->offset; in xaui_serdes_reset()
76 t3_write_reg(adap, ctrl, adap->params.vpd.xauicfg[macidx(mac)] | in xaui_serdes_reset()
91 * @mac: the XGMAC handle
95 void t3b_pcs_reset(struct cmac *mac) in t3b_pcs_reset() argument
97 t3_set_reg_field(mac->adapter, A_XGM_RESET_CTRL + mac->offset, in t3b_pcs_reset()
102 t3_set_reg_field(mac->adapter, A_XGM_RESET_CTRL + mac->offset, 0, in t3b_pcs_reset()
106 void t3c_pcs_force_los(struct cmac *mac) in t3c_pcs_force_los() argument
108 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT0 + mac->offset, in t3c_pcs_force_los()
111 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT1 + mac->offset, in t3c_pcs_force_los()
114 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT2 + mac->offset, in t3c_pcs_force_los()
117 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT3 + mac->offset, in t3c_pcs_force_los()
123 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT0 + mac->offset, in t3c_pcs_force_los()
125 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT1 + mac->offset, in t3c_pcs_force_los()
127 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT2 + mac->offset, in t3c_pcs_force_los()
129 t3_set_reg_field(mac->adapter, A_XGM_SERDES_STAT3 + mac->offset, in t3c_pcs_force_los()
134 * t3_mac_init - initialize a MAC
135 * @mac: the MAC to initialize
137 * Initialize the given MAC.
139 int t3_mac_init(struct cmac *mac) in t3_mac_init() argument
159 adapter_t *adap = mac->adapter; in t3_mac_init()
160 unsigned int oft = mac->offset; in t3_mac_init()
178 "MAC %d XAUI SERDES CMU lock failed\n", in t3_mac_init()
179 macidx(mac)); in t3_mac_init()
185 xaui_serdes_reset(mac); in t3_mac_init()
189 if (mac->multiport) { in t3_mac_init()
207 val = xgm_reset_ctrl(mac); in t3_mac_init()
212 t3b_pcs_reset(mac); in t3_mac_init()
215 memset(&mac->stats, 0, sizeof(mac->stats)); in t3_mac_init()
219 static int t3_mac_reset(struct cmac *mac, int portspeed) in t3_mac_reset() argument
222 adapter_t *adap = mac->adapter; in t3_mac_reset()
223 unsigned int oft = mac->offset; in t3_mac_reset()
224 int idx = macidx(mac); in t3_mac_reset()
258 CH_ERR(adap, "MAC %d Rx fifo drain failed\n", idx); in t3_mac_reset()
276 t3_mac_init(mac); in t3_mac_reset()
281 t3_write_reg(adap, A_XGM_RESET_CTRL + oft, 0); /*MAC in reset*/ in t3_mac_reset()
284 val = xgm_reset_ctrl(mac); in t3_mac_reset()
289 t3b_pcs_reset(mac); in t3_mac_reset()
313 static void set_addr_filter(struct cmac *mac, int idx, const u8 *addr) in set_addr_filter() argument
316 unsigned int oft = mac->offset + idx * 8; in set_addr_filter()
321 t3_write_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_LOW_1 + oft, addr_lo); in set_addr_filter()
322 t3_write_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_HIGH_1 + oft, addr_hi); in set_addr_filter()
326 * t3_mac_set_address - set one of the station's unicast MAC addresses
327 * @mac: the MAC handle
331 * Set one of the station's unicast MAC addresses.
333 int t3_mac_set_address(struct cmac *mac, unsigned int idx, u8 addr[6]) in t3_mac_set_address() argument
335 if (mac->multiport) in t3_mac_set_address()
336 idx = mac->ext_port + idx * mac->adapter->params.nports; in t3_mac_set_address()
337 if (idx >= mac->nucast) in t3_mac_set_address()
339 set_addr_filter(mac, idx, addr); in t3_mac_set_address()
340 if (mac->multiport && idx < mac->adapter->params.nports) in t3_mac_set_address()
341 t3_vsc7323_set_addr(mac->adapter, addr, idx); in t3_mac_set_address()
347 * @mac: the MAC handle
357 int t3_mac_set_num_ucast(struct cmac *mac, unsigned char n) in t3_mac_set_num_ucast() argument
361 mac->nucast = n; in t3_mac_set_num_ucast()
365 void t3_mac_disable_exact_filters(struct cmac *mac) in t3_mac_disable_exact_filters() argument
367 unsigned int i, reg = mac->offset + A_XGM_RX_EXACT_MATCH_LOW_1; in t3_mac_disable_exact_filters()
370 u32 v = t3_read_reg(mac->adapter, reg); in t3_mac_disable_exact_filters()
371 t3_write_reg(mac->adapter, reg, v); in t3_mac_disable_exact_filters()
373 t3_read_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_LOW_1); /* flush */ in t3_mac_disable_exact_filters()
376 void t3_mac_enable_exact_filters(struct cmac *mac) in t3_mac_enable_exact_filters() argument
378 unsigned int i, reg = mac->offset + A_XGM_RX_EXACT_MATCH_HIGH_1; in t3_mac_enable_exact_filters()
381 u32 v = t3_read_reg(mac->adapter, reg); in t3_mac_enable_exact_filters()
382 t3_write_reg(mac->adapter, reg, v); in t3_mac_enable_exact_filters()
384 t3_read_reg(mac->adapter, A_XGM_RX_EXACT_MATCH_LOW_1); /* flush */ in t3_mac_enable_exact_filters()
403 * @mac: the MAC to configure
404 * @rm: structure containing the Rx mode and MAC addresses needed
406 * Configures the MAC Rx mode (promiscuity, etc) and exact and hash
410 struct cmac *mac; member
420 if (ctx->mac->nucast + cnt < EXACT_ADDR_FILTERS) in t3_hash_maddr()
421 set_addr_filter(ctx->mac, ctx->mac->nucast + cnt, LLADDR(sdl)); in t3_hash_maddr()
432 int t3_mac_set_rx_mode(struct cmac *mac, struct t3_rx_mode *rm) in t3_mac_set_rx_mode() argument
435 adapter_t *adap = mac->adapter; in t3_mac_set_rx_mode()
436 unsigned int oft = mac->offset; in t3_mac_set_rx_mode()
439 mac->promisc_map |= 1 << mac->ext_port; in t3_mac_set_rx_mode()
441 mac->promisc_map &= ~(1 << mac->ext_port); in t3_mac_set_rx_mode()
443 mac->promisc_map ? F_COPYALLFRAMES : 0); in t3_mac_set_rx_mode()
445 if (allmulti_rx_mode(rm) || mac->multiport) in t3_mac_set_rx_mode()
448 ctx.mac = mac; in t3_mac_set_rx_mode()
467 * t3_mac_set_mtu - set the MAC MTU
468 * @mac: the MAC to configure
471 * Sets the MAC MTU and adjusts the FIFO PAUSE watermarks accordingly.
473 int t3_mac_set_mtu(struct cmac *mac, unsigned int mtu) in t3_mac_set_mtu() argument
478 adapter_t *adap = mac->adapter; in t3_mac_set_mtu()
479 unsigned port_type = adap->params.vpd.port_type[macidx(mac)]; in t3_mac_set_mtu()
487 if (mac->multiport) in t3_mac_set_mtu()
491 if (mac->multiport) in t3_mac_set_mtu()
492 return t3_vsc7323_set_mtu(adap, mtu - 4, mac->ext_port); in t3_mac_set_mtu()
496 int err = t3_vsc8211_fifo_depth(adap,orig_mtu,macidx(mac)); in t3_mac_set_mtu()
503 (t3_read_reg(adap, A_XGM_RX_CTRL + mac->offset) & F_RXEN)) { in t3_mac_set_mtu()
504 t3_mac_disable_exact_filters(mac); in t3_mac_set_mtu()
505 v = t3_read_reg(adap, A_XGM_RX_CFG + mac->offset); in t3_mac_set_mtu()
506 t3_set_reg_field(adap, A_XGM_RX_CFG + mac->offset, in t3_mac_set_mtu()
513 if (t3_wait_op_done(adap, reg + mac->offset, in t3_mac_set_mtu()
515 t3_write_reg(adap, A_XGM_RX_CFG + mac->offset, v); in t3_mac_set_mtu()
516 t3_mac_enable_exact_filters(mac); in t3_mac_set_mtu()
519 t3_set_reg_field(adap, A_XGM_RX_MAX_PKT_SIZE + mac->offset, in t3_mac_set_mtu()
522 t3_write_reg(adap, A_XGM_RX_CFG + mac->offset, v); in t3_mac_set_mtu()
523 t3_mac_enable_exact_filters(mac); in t3_mac_set_mtu()
525 t3_set_reg_field(adap, A_XGM_RX_MAX_PKT_SIZE + mac->offset, in t3_mac_set_mtu()
534 v = t3_read_reg(adap, A_XGM_RXFIFO_CFG + mac->offset); in t3_mac_set_mtu()
541 t3_write_reg(adap, A_XGM_RXFIFO_CFG + mac->offset, v); in t3_mac_set_mtu()
551 t3_set_reg_field(adap, A_XGM_TXFIFO_CFG + mac->offset, in t3_mac_set_mtu()
558 * t3_mac_set_speed_duplex_fc - set MAC speed, duplex and flow control
559 * @mac: the MAC to configure
564 * Set the MAC speed, duplex (actually only full-duplex is supported), and
566 * MAC setting is left at its current value.
568 int t3_mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex, int fc) in t3_mac_set_speed_duplex_fc() argument
571 adapter_t *adap = mac->adapter; in t3_mac_set_speed_duplex_fc()
572 unsigned int oft = mac->offset; in t3_mac_set_speed_duplex_fc()
579 t3_write_reg(adap, A_XGM_TX_PAUSE_QUANTA + mac->offset, in t3_mac_set_speed_duplex_fc()
581 t3_write_reg(adap, A_XGM_PAUSE_TIMER + mac->offset, in t3_mac_set_speed_duplex_fc()
584 if (mac->multiport) { in t3_mac_set_speed_duplex_fc()
595 return t3_vsc7323_set_speed_fc(adap, speed, fc, mac->ext_port); in t3_mac_set_speed_duplex_fc()
616 t3_mac_reset(mac, val); in t3_mac_set_speed_duplex_fc()
617 mac->was_reset = 1; in t3_mac_set_speed_duplex_fc()
638 * t3_mac_enable - enable the MAC in the given directions
639 * @mac: the MAC to configure
642 * Enables the MAC for operation in the given directions.
646 int t3_mac_enable(struct cmac *mac, int which) in t3_mac_enable() argument
648 int idx = macidx(mac); in t3_mac_enable()
649 adapter_t *adap = mac->adapter; in t3_mac_enable()
650 unsigned int oft = mac->offset; in t3_mac_enable()
651 struct mac_stats *s = &mac->stats; in t3_mac_enable()
653 if (mac->multiport) in t3_mac_enable()
654 return t3_vsc7323_enable(adap, mac->ext_port, which); in t3_mac_enable()
669 mac->tx_mcnt = s->tx_frames; in t3_mac_enable()
670 mac->tx_tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap, in t3_mac_enable()
672 mac->tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap, in t3_mac_enable()
675 mac->rx_mcnt = s->rx_frames; in t3_mac_enable()
676 mac->rx_pause = s->rx_pause; in t3_mac_enable()
677 mac->rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap, in t3_mac_enable()
680 mac->rx_ocnt = s->rx_fifo_ovfl; in t3_mac_enable()
681 mac->txen = F_TXEN; in t3_mac_enable()
682 mac->toggle_cnt = 0; in t3_mac_enable()
690 * t3_mac_disable - disable the MAC in the given directions
691 * @mac: the MAC to configure
694 * Disables the MAC in the given directions.
698 int t3_mac_disable(struct cmac *mac, int which) in t3_mac_disable() argument
700 adapter_t *adap = mac->adapter; in t3_mac_disable()
702 if (mac->multiport) in t3_mac_disable()
703 return t3_vsc7323_disable(adap, mac->ext_port, which); in t3_mac_disable()
706 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0); in t3_mac_disable()
707 mac->txen = 0; in t3_mac_disable()
710 int val = xgm_reset_ctrl(mac); in t3_mac_disable()
712 t3_set_reg_field(mac->adapter, A_XGM_RESET_CTRL + mac->offset, in t3_mac_disable()
715 t3_write_reg(adap, A_XGM_RX_CTRL + mac->offset, 0); in t3_mac_disable()
716 t3_write_reg(mac->adapter, A_XGM_RESET_CTRL + mac->offset, val); in t3_mac_disable()
721 int t3b2_mac_watchdog_task(struct cmac *mac) in t3b2_mac_watchdog_task() argument
725 adapter_t *adap = mac->adapter; in t3b2_mac_watchdog_task()
726 struct mac_stats *s = &mac->stats; in t3b2_mac_watchdog_task()
729 if (mac->multiport) in t3b2_mac_watchdog_task()
734 tx_tcnt = mac->tx_tcnt; /* If tx_mcnt is progressing ignore tx_tcnt*/ in t3b2_mac_watchdog_task()
735 if (tx_mcnt == mac->tx_mcnt && mac->rx_pause == s->rx_pause) { in t3b2_mac_watchdog_task()
740 mac->offset))); in t3b2_mac_watchdog_task()
742 active = macidx(mac) ? cfg & F_PORT1ACTIVE : cfg & F_PORT0ACTIVE; in t3b2_mac_watchdog_task()
746 A_TP_TX_DROP_CNT_CH0 + macidx(mac)); in t3b2_mac_watchdog_task()
753 mac->toggle_cnt = 0; in t3b2_mac_watchdog_task()
757 if ((tx_tcnt != mac->tx_tcnt) && (mac->tx_xcnt == 0)) { in t3b2_mac_watchdog_task()
758 if (mac->toggle_cnt > 4) { in t3b2_mac_watchdog_task()
766 mac->toggle_cnt = 0; in t3b2_mac_watchdog_task()
771 mac->tx_tcnt = tx_tcnt; in t3b2_mac_watchdog_task()
772 mac->tx_xcnt = tx_xcnt; in t3b2_mac_watchdog_task()
773 mac->tx_mcnt = s->tx_frames; in t3b2_mac_watchdog_task()
774 mac->rx_pause = s->rx_pause; in t3b2_mac_watchdog_task()
776 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0); in t3b2_mac_watchdog_task()
777 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset); /* flush */ in t3b2_mac_watchdog_task()
778 t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, mac->txen); in t3b2_mac_watchdog_task()
779 t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset); /* flush */ in t3b2_mac_watchdog_task()
780 mac->toggle_cnt++; in t3b2_mac_watchdog_task()
782 t3_mac_reset(mac, -1); in t3b2_mac_watchdog_task()
783 mac->toggle_cnt = 0; in t3b2_mac_watchdog_task()
789 * t3_mac_update_stats - accumulate MAC statistics
790 * @mac: the MAC handle
798 const struct mac_stats *t3_mac_update_stats(struct cmac *mac) in t3_mac_update_stats() argument
800 #define RMON_READ(mac, addr) t3_read_reg(mac->adapter, addr + mac->offset) in t3_mac_update_stats() argument
801 #define RMON_UPDATE(mac, name, reg) \ in t3_mac_update_stats() argument
802 (mac)->stats.name += (u64)RMON_READ(mac, A_XGM_STAT_##reg) in t3_mac_update_stats()
803 #define RMON_UPDATE64(mac, name, reg_lo, reg_hi) \ in t3_mac_update_stats() argument
804 (mac)->stats.name += RMON_READ(mac, A_XGM_STAT_##reg_lo) + \ in t3_mac_update_stats()
805 ((u64)RMON_READ(mac, A_XGM_STAT_##reg_hi) << 32) in t3_mac_update_stats()
809 if (mac->multiport) in t3_mac_update_stats()
810 return t3_vsc7323_update_stats(mac); in t3_mac_update_stats()
812 RMON_UPDATE64(mac, rx_octets, RX_BYTES_LOW, RX_BYTES_HIGH); in t3_mac_update_stats()
813 RMON_UPDATE64(mac, rx_frames, RX_FRAMES_LOW, RX_FRAMES_HIGH); in t3_mac_update_stats()
814 RMON_UPDATE(mac, rx_mcast_frames, RX_MCAST_FRAMES); in t3_mac_update_stats()
815 RMON_UPDATE(mac, rx_bcast_frames, RX_BCAST_FRAMES); in t3_mac_update_stats()
816 RMON_UPDATE(mac, rx_fcs_errs, RX_CRC_ERR_FRAMES); in t3_mac_update_stats()
817 RMON_UPDATE(mac, rx_pause, RX_PAUSE_FRAMES); in t3_mac_update_stats()
818 RMON_UPDATE(mac, rx_jabber, RX_JABBER_FRAMES); in t3_mac_update_stats()
819 RMON_UPDATE(mac, rx_short, RX_SHORT_FRAMES); in t3_mac_update_stats()
820 RMON_UPDATE(mac, rx_symbol_errs, RX_SYM_CODE_ERR_FRAMES); in t3_mac_update_stats()
822 RMON_UPDATE(mac, rx_too_long, RX_OVERSIZE_FRAMES); in t3_mac_update_stats()
824 v = RMON_READ(mac, A_XGM_RX_MAX_PKT_SIZE_ERR_CNT); in t3_mac_update_stats()
825 if (mac->adapter->params.rev == T3_REV_B2) in t3_mac_update_stats()
827 mac->stats.rx_too_long += v; in t3_mac_update_stats()
829 RMON_UPDATE(mac, rx_frames_64, RX_64B_FRAMES); in t3_mac_update_stats()
830 RMON_UPDATE(mac, rx_frames_65_127, RX_65_127B_FRAMES); in t3_mac_update_stats()
831 RMON_UPDATE(mac, rx_frames_128_255, RX_128_255B_FRAMES); in t3_mac_update_stats()
832 RMON_UPDATE(mac, rx_frames_256_511, RX_256_511B_FRAMES); in t3_mac_update_stats()
833 RMON_UPDATE(mac, rx_frames_512_1023, RX_512_1023B_FRAMES); in t3_mac_update_stats()
834 RMON_UPDATE(mac, rx_frames_1024_1518, RX_1024_1518B_FRAMES); in t3_mac_update_stats()
835 RMON_UPDATE(mac, rx_frames_1519_max, RX_1519_MAXB_FRAMES); in t3_mac_update_stats()
837 RMON_UPDATE64(mac, tx_octets, TX_BYTE_LOW, TX_BYTE_HIGH); in t3_mac_update_stats()
838 RMON_UPDATE64(mac, tx_frames, TX_FRAME_LOW, TX_FRAME_HIGH); in t3_mac_update_stats()
839 RMON_UPDATE(mac, tx_mcast_frames, TX_MCAST); in t3_mac_update_stats()
840 RMON_UPDATE(mac, tx_bcast_frames, TX_BCAST); in t3_mac_update_stats()
841 RMON_UPDATE(mac, tx_pause, TX_PAUSE); in t3_mac_update_stats()
843 RMON_UPDATE(mac, tx_underrun, TX_ERR_FRAMES); in t3_mac_update_stats()
845 RMON_UPDATE(mac, tx_frames_64, TX_64B_FRAMES); in t3_mac_update_stats()
846 RMON_UPDATE(mac, tx_frames_65_127, TX_65_127B_FRAMES); in t3_mac_update_stats()
847 RMON_UPDATE(mac, tx_frames_128_255, TX_128_255B_FRAMES); in t3_mac_update_stats()
848 RMON_UPDATE(mac, tx_frames_256_511, TX_256_511B_FRAMES); in t3_mac_update_stats()
849 RMON_UPDATE(mac, tx_frames_512_1023, TX_512_1023B_FRAMES); in t3_mac_update_stats()
850 RMON_UPDATE(mac, tx_frames_1024_1518, TX_1024_1518B_FRAMES); in t3_mac_update_stats()
851 RMON_UPDATE(mac, tx_frames_1519_max, TX_1519_MAXB_FRAMES); in t3_mac_update_stats()
854 t3_write_reg(mac->adapter, A_TP_MIB_INDEX, mac->offset ? 51 : 50); in t3_mac_update_stats()
855 v = t3_read_reg(mac->adapter, A_TP_MIB_RDATA); in t3_mac_update_stats()
856 lo = (u32)mac->stats.rx_cong_drops; in t3_mac_update_stats()
857 mac->stats.rx_cong_drops += (u64)(v - lo); in t3_mac_update_stats()
859 return &mac->stats; in t3_mac_update_stats()