Lines Matching refs:wx
14 static void wx_intr_disable(struct wx *wx, u64 qmask) in wx_intr_disable() argument
20 wr32(wx, WX_PX_IMS(0), mask); in wx_intr_disable()
22 if (wx->mac.type == wx_mac_sp) { in wx_intr_disable()
25 wr32(wx, WX_PX_IMS(1), mask); in wx_intr_disable()
29 void wx_intr_enable(struct wx *wx, u64 qmask) in wx_intr_enable() argument
35 wr32(wx, WX_PX_IMC(0), mask); in wx_intr_enable()
36 if (wx->mac.type == wx_mac_sp) { in wx_intr_enable()
39 wr32(wx, WX_PX_IMC(1), mask); in wx_intr_enable()
48 void wx_irq_disable(struct wx *wx) in wx_irq_disable() argument
50 struct pci_dev *pdev = wx->pdev; in wx_irq_disable()
52 wr32(wx, WX_PX_MISC_IEN, 0); in wx_irq_disable()
53 wx_intr_disable(wx, WX_INTR_ALL); in wx_irq_disable()
58 for (vector = 0; vector < wx->num_q_vectors; vector++) in wx_irq_disable()
59 synchronize_irq(wx->msix_entries[vector].vector); in wx_irq_disable()
61 synchronize_irq(wx->msix_entries[vector].vector); in wx_irq_disable()
72 static int wx_fmgr_cmd_op(struct wx *wx, u32 cmd, u32 cmd_addr) in wx_fmgr_cmd_op() argument
79 wr32(wx, WX_SPI_CMD, cmd_val); in wx_fmgr_cmd_op()
82 false, wx, WX_SPI_STATUS); in wx_fmgr_cmd_op()
85 static int wx_flash_read_dword(struct wx *wx, u32 addr, u32 *data) in wx_flash_read_dword() argument
89 ret = wx_fmgr_cmd_op(wx, WX_SPI_CMD_READ_DWORD, addr); in wx_flash_read_dword()
93 *data = rd32(wx, WX_SPI_DATA); in wx_flash_read_dword()
98 int wx_check_flash_load(struct wx *hw, u32 check_bit) in wx_check_flash_load()
117 void wx_control_hw(struct wx *wx, bool drv) in wx_control_hw() argument
122 wr32m(wx, WX_CFG_PORT_CTL, WX_CFG_PORT_CTL_DRV_LOAD, in wx_control_hw()
131 int wx_mng_present(struct wx *wx) in wx_mng_present() argument
135 fwsm = rd32(wx, WX_MIS_ST); in wx_mng_present()
154 static void wx_release_sw_sync(struct wx *wx, u32 mask) in wx_release_sw_sync() argument
157 wr32m(wx, WX_MNG_SWFW_SYNC, mask, 0); in wx_release_sw_sync()
169 static int wx_acquire_sw_sync(struct wx *wx, u32 mask) in wx_acquire_sw_sync() argument
176 5000, 2000000, false, wx, WX_MNG_SWFW_SYNC); in wx_acquire_sw_sync()
179 wr32(wx, WX_MNG_SWFW_SYNC, sem); in wx_acquire_sw_sync()
181 wx_err(wx, "SW Semaphore not granted: 0x%x.\n", sem); in wx_acquire_sw_sync()
202 int wx_host_interface_command(struct wx *wx, u32 *buffer, in wx_host_interface_command() argument
212 wx_err(wx, "Buffer length failure buffersize=%d.\n", length); in wx_host_interface_command()
216 status = wx_acquire_sw_sync(wx, WX_MNG_SWFW_SYNC_SW_MB); in wx_host_interface_command()
222 wx_err(wx, "Buffer length failure, not aligned to dword"); in wx_host_interface_command()
233 wr32a(wx, WX_MNG_MBOX, i, (__force u32)cpu_to_le32(buffer[i])); in wx_host_interface_command()
235 buf[i] = rd32a(wx, WX_MNG_MBOX, i); in wx_host_interface_command()
238 wr32m(wx, WX_MNG_MBOX_CTL, in wx_host_interface_command()
242 timeout * 1000, false, wx, WX_MNG_MBOX_CTL); in wx_host_interface_command()
246 wx_dbg(wx, "Command has failed with no status valid.\n"); in wx_host_interface_command()
248 buf[0] = rd32(wx, WX_MNG_MBOX); in wx_host_interface_command()
254 wx_dbg(wx, "It's unknown cmd.\n"); in wx_host_interface_command()
259 wx_dbg(wx, "write value:\n"); in wx_host_interface_command()
261 wx_dbg(wx, "%x ", buffer[i]); in wx_host_interface_command()
262 wx_dbg(wx, "read value:\n"); in wx_host_interface_command()
264 wx_dbg(wx, "%x ", buf[i]); in wx_host_interface_command()
275 buffer[bi] = rd32a(wx, WX_MNG_MBOX, bi); in wx_host_interface_command()
285 wx_err(wx, "Buffer not large enough for reply message.\n"); in wx_host_interface_command()
295 buffer[bi] = rd32a(wx, WX_MNG_MBOX, bi); in wx_host_interface_command()
300 wx_release_sw_sync(wx, WX_MNG_SWFW_SYNC_SW_MB); in wx_host_interface_command()
314 static int wx_read_ee_hostif_data(struct wx *wx, u16 offset, u16 *data) in wx_read_ee_hostif_data() argument
329 status = wx_host_interface_command(wx, (u32 *)&buffer, sizeof(buffer), in wx_read_ee_hostif_data()
335 *data = (u16)rd32a(wx, WX_MNG_MBOX, FW_NVM_DATA_OFFSET); in wx_read_ee_hostif_data()
348 int wx_read_ee_hostif(struct wx *wx, u16 offset, u16 *data) in wx_read_ee_hostif() argument
352 status = wx_acquire_sw_sync(wx, WX_MNG_SWFW_SYNC_SW_FLASH); in wx_read_ee_hostif()
354 status = wx_read_ee_hostif_data(wx, offset, data); in wx_read_ee_hostif()
355 wx_release_sw_sync(wx, WX_MNG_SWFW_SYNC_SW_FLASH); in wx_read_ee_hostif()
371 int wx_read_ee_hostif_buffer(struct wx *wx, in wx_read_ee_hostif_buffer() argument
382 status = wx_acquire_sw_sync(wx, WX_MNG_SWFW_SYNC_SW_FLASH); in wx_read_ee_hostif_buffer()
401 status = wx_host_interface_command(wx, (u32 *)&buffer, in wx_read_ee_hostif_buffer()
407 wx_err(wx, "Host interface command failed\n"); in wx_read_ee_hostif_buffer()
414 value = rd32(wx, reg); in wx_read_ee_hostif_buffer()
428 wx_release_sw_sync(wx, WX_MNG_SWFW_SYNC_SW_FLASH); in wx_read_ee_hostif_buffer()
461 int wx_reset_hostif(struct wx *wx) in wx_reset_hostif() argument
470 reset_cmd.lan_id = wx->bus.func; in wx_reset_hostif()
471 reset_cmd.reset_type = (u16)wx->reset_type; in wx_reset_hostif()
478 ret_val = wx_host_interface_command(wx, (u32 *)&reset_cmd, in wx_reset_hostif()
505 void wx_init_eeprom_params(struct wx *wx) in wx_init_eeprom_params() argument
507 struct wx_eeprom_info *eeprom = &wx->eeprom; in wx_init_eeprom_params()
515 if (!(rd32(wx, WX_SPI_STATUS) & in wx_init_eeprom_params()
522 wx_dbg(wx, "Eeprom params: type = %d, size = %d\n", in wx_init_eeprom_params()
527 if (wx->mac.type == wx_mac_sp) { in wx_init_eeprom_params()
528 if (wx_read_ee_hostif(wx, WX_SW_REGION_PTR, &data)) { in wx_init_eeprom_params()
529 wx_err(wx, "NVM Read Error\n"); in wx_init_eeprom_params()
548 void wx_get_mac_addr(struct wx *wx, u8 *mac_addr) in wx_get_mac_addr() argument
554 wr32(wx, WX_PSR_MAC_SWC_IDX, 0); in wx_get_mac_addr()
555 rar_high = rd32(wx, WX_PSR_MAC_SWC_AD_H); in wx_get_mac_addr()
556 rar_low = rd32(wx, WX_PSR_MAC_SWC_AD_L); in wx_get_mac_addr()
576 static int wx_set_rar(struct wx *wx, u32 index, u8 *addr, u64 pools, in wx_set_rar() argument
579 u32 rar_entries = wx->mac.num_rar_entries; in wx_set_rar()
584 wx_err(wx, "RAR index %d is out of range.\n", index); in wx_set_rar()
589 wr32(wx, WX_PSR_MAC_SWC_IDX, index); in wx_set_rar()
592 wr32(wx, WX_PSR_MAC_SWC_VM_L, pools & 0xFFFFFFFF); in wx_set_rar()
593 if (wx->mac.type == wx_mac_sp) in wx_set_rar()
594 wr32(wx, WX_PSR_MAC_SWC_VM_H, pools >> 32); in wx_set_rar()
612 wr32(wx, WX_PSR_MAC_SWC_AD_L, rar_low); in wx_set_rar()
613 wr32m(wx, WX_PSR_MAC_SWC_AD_H, in wx_set_rar()
629 static int wx_clear_rar(struct wx *wx, u32 index) in wx_clear_rar() argument
631 u32 rar_entries = wx->mac.num_rar_entries; in wx_clear_rar()
635 wx_err(wx, "RAR index %d is out of range.\n", index); in wx_clear_rar()
643 wr32(wx, WX_PSR_MAC_SWC_IDX, index); in wx_clear_rar()
645 wr32(wx, WX_PSR_MAC_SWC_VM_L, 0); in wx_clear_rar()
646 wr32(wx, WX_PSR_MAC_SWC_VM_H, 0); in wx_clear_rar()
648 wr32(wx, WX_PSR_MAC_SWC_AD_L, 0); in wx_clear_rar()
649 wr32m(wx, WX_PSR_MAC_SWC_AD_H, in wx_clear_rar()
664 static int wx_clear_vmdq(struct wx *wx, u32 rar, u32 __maybe_unused vmdq) in wx_clear_vmdq() argument
666 u32 rar_entries = wx->mac.num_rar_entries; in wx_clear_vmdq()
671 wx_err(wx, "RAR index %d is out of range.\n", rar); in wx_clear_vmdq()
675 wr32(wx, WX_PSR_MAC_SWC_IDX, rar); in wx_clear_vmdq()
676 mpsar_lo = rd32(wx, WX_PSR_MAC_SWC_VM_L); in wx_clear_vmdq()
677 mpsar_hi = rd32(wx, WX_PSR_MAC_SWC_VM_H); in wx_clear_vmdq()
684 wx_clear_rar(wx, rar); in wx_clear_vmdq()
693 static void wx_init_uta_tables(struct wx *wx) in wx_init_uta_tables() argument
697 wx_dbg(wx, " Clearing UTA\n"); in wx_init_uta_tables()
700 wr32(wx, WX_PSR_UC_TBL(i), 0); in wx_init_uta_tables()
711 void wx_init_rx_addrs(struct wx *wx) in wx_init_rx_addrs() argument
713 u32 rar_entries = wx->mac.num_rar_entries; in wx_init_rx_addrs()
721 if (!is_valid_ether_addr(wx->mac.addr)) { in wx_init_rx_addrs()
723 wx_get_mac_addr(wx, wx->mac.addr); in wx_init_rx_addrs()
724 wx_dbg(wx, "Keeping Current RAR0 Addr = %pM\n", wx->mac.addr); in wx_init_rx_addrs()
727 wx_dbg(wx, "Overriding MAC Address in RAR[0]\n"); in wx_init_rx_addrs()
728 wx_dbg(wx, "New MAC Addr = %pM\n", wx->mac.addr); in wx_init_rx_addrs()
730 wx_set_rar(wx, 0, wx->mac.addr, 0, WX_PSR_MAC_SWC_AD_H_AV); in wx_init_rx_addrs()
732 if (wx->mac.type == wx_mac_sp) { in wx_init_rx_addrs()
734 wx_clear_vmdq(wx, 0, WX_CLEAR_VMDQ_ALL); in wx_init_rx_addrs()
739 wx_dbg(wx, "Clearing RAR[1-%d]\n", rar_entries - 1); in wx_init_rx_addrs()
741 wr32(wx, WX_PSR_MAC_SWC_IDX, i); in wx_init_rx_addrs()
742 wr32(wx, WX_PSR_MAC_SWC_AD_L, 0); in wx_init_rx_addrs()
743 wr32(wx, WX_PSR_MAC_SWC_AD_H, 0); in wx_init_rx_addrs()
747 wx->addr_ctrl.mta_in_use = 0; in wx_init_rx_addrs()
748 psrctl = rd32(wx, WX_PSR_CTL); in wx_init_rx_addrs()
750 psrctl |= wx->mac.mc_filter_type << WX_PSR_CTL_MO_SHIFT; in wx_init_rx_addrs()
751 wr32(wx, WX_PSR_CTL, psrctl); in wx_init_rx_addrs()
752 wx_dbg(wx, " Clearing MTA\n"); in wx_init_rx_addrs()
753 for (i = 0; i < wx->mac.mcft_size; i++) in wx_init_rx_addrs()
754 wr32(wx, WX_PSR_MC_TBL(i), 0); in wx_init_rx_addrs()
756 wx_init_uta_tables(wx); in wx_init_rx_addrs()
760 static void wx_sync_mac_table(struct wx *wx) in wx_sync_mac_table() argument
764 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_sync_mac_table()
765 if (wx->mac_table[i].state & WX_MAC_STATE_MODIFIED) { in wx_sync_mac_table()
766 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) { in wx_sync_mac_table()
767 wx_set_rar(wx, i, in wx_sync_mac_table()
768 wx->mac_table[i].addr, in wx_sync_mac_table()
769 wx->mac_table[i].pools, in wx_sync_mac_table()
772 wx_clear_rar(wx, i); in wx_sync_mac_table()
774 wx->mac_table[i].state &= ~(WX_MAC_STATE_MODIFIED); in wx_sync_mac_table()
780 void wx_mac_set_default_filter(struct wx *wx, u8 *addr) in wx_mac_set_default_filter() argument
782 memcpy(&wx->mac_table[0].addr, addr, ETH_ALEN); in wx_mac_set_default_filter()
783 wx->mac_table[0].pools = 1ULL; in wx_mac_set_default_filter()
784 wx->mac_table[0].state = (WX_MAC_STATE_DEFAULT | WX_MAC_STATE_IN_USE); in wx_mac_set_default_filter()
785 wx_set_rar(wx, 0, wx->mac_table[0].addr, in wx_mac_set_default_filter()
786 wx->mac_table[0].pools, in wx_mac_set_default_filter()
791 void wx_flush_sw_mac_table(struct wx *wx) in wx_flush_sw_mac_table() argument
795 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_flush_sw_mac_table()
796 if (!(wx->mac_table[i].state & WX_MAC_STATE_IN_USE)) in wx_flush_sw_mac_table()
799 wx->mac_table[i].state |= WX_MAC_STATE_MODIFIED; in wx_flush_sw_mac_table()
800 wx->mac_table[i].state &= ~WX_MAC_STATE_IN_USE; in wx_flush_sw_mac_table()
801 memset(wx->mac_table[i].addr, 0, ETH_ALEN); in wx_flush_sw_mac_table()
802 wx->mac_table[i].pools = 0; in wx_flush_sw_mac_table()
804 wx_sync_mac_table(wx); in wx_flush_sw_mac_table()
808 static int wx_add_mac_filter(struct wx *wx, u8 *addr, u16 pool) in wx_add_mac_filter() argument
815 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_add_mac_filter()
816 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) { in wx_add_mac_filter()
817 if (ether_addr_equal(addr, wx->mac_table[i].addr)) { in wx_add_mac_filter()
818 if (wx->mac_table[i].pools != (1ULL << pool)) { in wx_add_mac_filter()
819 memcpy(wx->mac_table[i].addr, addr, ETH_ALEN); in wx_add_mac_filter()
820 wx->mac_table[i].pools |= (1ULL << pool); in wx_add_mac_filter()
821 wx_sync_mac_table(wx); in wx_add_mac_filter()
827 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) in wx_add_mac_filter()
829 wx->mac_table[i].state |= (WX_MAC_STATE_MODIFIED | in wx_add_mac_filter()
831 memcpy(wx->mac_table[i].addr, addr, ETH_ALEN); in wx_add_mac_filter()
832 wx->mac_table[i].pools |= (1ULL << pool); in wx_add_mac_filter()
833 wx_sync_mac_table(wx); in wx_add_mac_filter()
839 static int wx_del_mac_filter(struct wx *wx, u8 *addr, u16 pool) in wx_del_mac_filter() argument
847 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_del_mac_filter()
848 if (!ether_addr_equal(addr, wx->mac_table[i].addr)) in wx_del_mac_filter()
851 wx->mac_table[i].state |= WX_MAC_STATE_MODIFIED; in wx_del_mac_filter()
852 wx->mac_table[i].pools &= ~(1ULL << pool); in wx_del_mac_filter()
853 if (!wx->mac_table[i].pools) { in wx_del_mac_filter()
854 wx->mac_table[i].state &= ~WX_MAC_STATE_IN_USE; in wx_del_mac_filter()
855 memset(wx->mac_table[i].addr, 0, ETH_ALEN); in wx_del_mac_filter()
857 wx_sync_mac_table(wx); in wx_del_mac_filter()
863 static int wx_available_rars(struct wx *wx) in wx_available_rars() argument
867 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_available_rars()
868 if (wx->mac_table[i].state == 0) in wx_available_rars()
887 struct wx *wx = netdev_priv(netdev); in wx_write_uc_addr_list() local
891 if (netdev_uc_count(netdev) > wx_available_rars(wx)) in wx_write_uc_addr_list()
898 wx_del_mac_filter(wx, ha->addr, pool); in wx_write_uc_addr_list()
899 wx_add_mac_filter(wx, ha->addr, pool); in wx_write_uc_addr_list()
918 static u32 wx_mta_vector(struct wx *wx, u8 *mc_addr) in wx_mta_vector() argument
922 switch (wx->mac.mc_filter_type) { in wx_mta_vector()
936 wx_err(wx, "MC filter type param set incorrectly\n"); in wx_mta_vector()
952 static void wx_set_mta(struct wx *wx, u8 *mc_addr) in wx_set_mta() argument
956 wx->addr_ctrl.mta_in_use++; in wx_set_mta()
958 vector = wx_mta_vector(wx, mc_addr); in wx_set_mta()
959 wx_dbg(wx, " bit-vector = 0x%03X\n", vector); in wx_set_mta()
971 wx->mac.mta_shadow[vector_reg] |= (1 << vector_bit); in wx_set_mta()
984 static void wx_update_mc_addr_list(struct wx *wx, struct net_device *netdev) in wx_update_mc_addr_list() argument
992 wx->addr_ctrl.num_mc_addrs = netdev_mc_count(netdev); in wx_update_mc_addr_list()
993 wx->addr_ctrl.mta_in_use = 0; in wx_update_mc_addr_list()
996 wx_dbg(wx, " Clearing MTA\n"); in wx_update_mc_addr_list()
997 memset(&wx->mac.mta_shadow, 0, sizeof(wx->mac.mta_shadow)); in wx_update_mc_addr_list()
1001 wx_dbg(wx, " Adding the multicast addresses:\n"); in wx_update_mc_addr_list()
1002 wx_set_mta(wx, ha->addr); in wx_update_mc_addr_list()
1006 for (i = 0; i < wx->mac.mcft_size; i++) in wx_update_mc_addr_list()
1007 wr32a(wx, WX_PSR_MC_TBL(0), i, in wx_update_mc_addr_list()
1008 wx->mac.mta_shadow[i]); in wx_update_mc_addr_list()
1010 if (wx->addr_ctrl.mta_in_use > 0) { in wx_update_mc_addr_list()
1011 psrctl = rd32(wx, WX_PSR_CTL); in wx_update_mc_addr_list()
1014 (wx->mac.mc_filter_type << WX_PSR_CTL_MO_SHIFT); in wx_update_mc_addr_list()
1015 wr32(wx, WX_PSR_CTL, psrctl); in wx_update_mc_addr_list()
1018 wx_dbg(wx, "Update mc addr list Complete\n"); in wx_update_mc_addr_list()
1031 struct wx *wx = netdev_priv(netdev); in wx_write_mc_addr_list() local
1036 wx_update_mc_addr_list(wx, netdev); in wx_write_mc_addr_list()
1050 struct wx *wx = netdev_priv(netdev); in wx_set_mac() local
1058 wx_del_mac_filter(wx, wx->mac.addr, 0); in wx_set_mac()
1060 memcpy(wx->mac.addr, addr->sa_data, netdev->addr_len); in wx_set_mac()
1062 wx_mac_set_default_filter(wx, wx->mac.addr); in wx_set_mac()
1068 void wx_disable_rx(struct wx *wx) in wx_disable_rx() argument
1073 rxctrl = rd32(wx, WX_RDB_PB_CTL); in wx_disable_rx()
1075 pfdtxgswc = rd32(wx, WX_PSR_CTL); in wx_disable_rx()
1078 wr32(wx, WX_PSR_CTL, pfdtxgswc); in wx_disable_rx()
1079 wx->mac.set_lben = true; in wx_disable_rx()
1081 wx->mac.set_lben = false; in wx_disable_rx()
1084 wr32(wx, WX_RDB_PB_CTL, rxctrl); in wx_disable_rx()
1086 if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) || in wx_disable_rx()
1087 ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) { in wx_disable_rx()
1089 wr32m(wx, WX_MAC_RX_CFG, in wx_disable_rx()
1096 static void wx_enable_rx(struct wx *wx) in wx_enable_rx() argument
1101 wr32m(wx, WX_MAC_RX_CFG, in wx_enable_rx()
1104 wr32m(wx, WX_RDB_PB_CTL, in wx_enable_rx()
1107 if (wx->mac.set_lben) { in wx_enable_rx()
1108 psrctl = rd32(wx, WX_PSR_CTL); in wx_enable_rx()
1110 wr32(wx, WX_PSR_CTL, psrctl); in wx_enable_rx()
1111 wx->mac.set_lben = false; in wx_enable_rx()
1119 static void wx_set_rxpba(struct wx *wx) in wx_set_rxpba() argument
1123 rxpktsize = wx->mac.rx_pb_size << WX_RDB_PB_SZ_SHIFT; in wx_set_rxpba()
1124 wr32(wx, WX_RDB_PB_SZ(0), rxpktsize); in wx_set_rxpba()
1127 txpktsize = wx->mac.tx_pb_size; in wx_set_rxpba()
1129 wr32(wx, WX_TDB_PB_SZ(0), txpktsize); in wx_set_rxpba()
1130 wr32(wx, WX_TDM_PB_THRE(0), txpbthresh); in wx_set_rxpba()
1133 static void wx_configure_port(struct wx *wx) in wx_configure_port() argument
1138 wr32m(wx, WX_CFG_PORT_CTL, in wx_configure_port()
1143 wr32(wx, WX_CFG_TAG_TPID(0), in wx_configure_port()
1145 wx->tpid[0] = ETH_P_8021Q; in wx_configure_port()
1146 wx->tpid[1] = ETH_P_8021AD; in wx_configure_port()
1148 wr32(wx, WX_CFG_TAG_TPID(i), in wx_configure_port()
1151 wx->tpid[i] = ETH_P_8021Q; in wx_configure_port()
1161 static int wx_disable_sec_rx_path(struct wx *wx) in wx_disable_sec_rx_path() argument
1165 wr32m(wx, WX_RSC_CTL, in wx_disable_sec_rx_path()
1169 1000, 40000, false, wx, WX_RSC_ST); in wx_disable_sec_rx_path()
1178 static void wx_enable_sec_rx_path(struct wx *wx) in wx_enable_sec_rx_path() argument
1180 wr32m(wx, WX_RSC_CTL, WX_RSC_CTL_RX_DIS, 0); in wx_enable_sec_rx_path()
1181 WX_WRITE_FLUSH(wx); in wx_enable_sec_rx_path()
1186 struct wx *wx = netdev_priv(netdev); in wx_set_rx_mode() local
1191 fctrl = rd32(wx, WX_PSR_CTL); in wx_set_rx_mode()
1193 vmolr = rd32(wx, WX_PSR_VM_L2CTL(0)); in wx_set_rx_mode()
1198 vlnctrl = rd32(wx, WX_PSR_VLAN_CTL); in wx_set_rx_mode()
1208 wx->addr_ctrl.user_set_promisc = false; in wx_set_rx_mode()
1210 wx->addr_ctrl.user_set_promisc = true; in wx_set_rx_mode()
1226 wr32m(wx, WX_RSC_CTL, in wx_set_rx_mode()
1253 wr32(wx, WX_PSR_VLAN_CTL, vlnctrl); in wx_set_rx_mode()
1254 wr32(wx, WX_PSR_CTL, fctrl); in wx_set_rx_mode()
1255 wr32(wx, WX_PSR_VM_L2CTL(0), vmolr); in wx_set_rx_mode()
1259 static void wx_set_rx_buffer_len(struct wx *wx) in wx_set_rx_buffer_len() argument
1261 struct net_device *netdev = wx->netdev; in wx_set_rx_buffer_len()
1269 mhadd = rd32(wx, WX_PSR_MAX_SZ); in wx_set_rx_buffer_len()
1271 wr32(wx, WX_PSR_MAX_SZ, max_frame); in wx_set_rx_buffer_len()
1275 void wx_disable_rx_queue(struct wx *wx, struct wx_ring *ring) in wx_disable_rx_queue() argument
1282 wr32m(wx, WX_PX_RR_CFG(reg_idx), in wx_disable_rx_queue()
1287 10, 100, true, wx, WX_PX_RR_CFG(reg_idx)); in wx_disable_rx_queue()
1291 wx_err(wx, in wx_disable_rx_queue()
1298 static void wx_enable_rx_queue(struct wx *wx, struct wx_ring *ring) in wx_enable_rx_queue() argument
1305 1000, 10000, true, wx, WX_PX_RR_CFG(reg_idx)); in wx_enable_rx_queue()
1309 wx_err(wx, in wx_enable_rx_queue()
1315 static void wx_configure_srrctl(struct wx *wx, in wx_configure_srrctl() argument
1321 srrctl = rd32(wx, WX_PX_RR_CFG(reg_idx)); in wx_configure_srrctl()
1331 wr32(wx, WX_PX_RR_CFG(reg_idx), srrctl); in wx_configure_srrctl()
1334 static void wx_configure_tx_ring(struct wx *wx, in wx_configure_tx_ring() argument
1343 wr32(wx, WX_PX_TR_CFG(reg_idx), WX_PX_TR_CFG_SWFLSH); in wx_configure_tx_ring()
1344 WX_WRITE_FLUSH(wx); in wx_configure_tx_ring()
1346 wr32(wx, WX_PX_TR_BAL(reg_idx), tdba & DMA_BIT_MASK(32)); in wx_configure_tx_ring()
1347 wr32(wx, WX_PX_TR_BAH(reg_idx), upper_32_bits(tdba)); in wx_configure_tx_ring()
1350 wr32(wx, WX_PX_TR_RP(reg_idx), 0); in wx_configure_tx_ring()
1351 wr32(wx, WX_PX_TR_WP(reg_idx), 0); in wx_configure_tx_ring()
1352 ring->tail = wx->hw_addr + WX_PX_TR_WP(reg_idx); in wx_configure_tx_ring()
1363 wr32(wx, WX_PX_TR_CFG(reg_idx), txdctl); in wx_configure_tx_ring()
1367 1000, 10000, true, wx, WX_PX_TR_CFG(reg_idx)); in wx_configure_tx_ring()
1369 wx_err(wx, "Could not enable Tx Queue %d\n", reg_idx); in wx_configure_tx_ring()
1372 static void wx_configure_rx_ring(struct wx *wx, in wx_configure_rx_ring() argument
1381 rxdctl = rd32(wx, WX_PX_RR_CFG(reg_idx)); in wx_configure_rx_ring()
1382 wx_disable_rx_queue(wx, ring); in wx_configure_rx_ring()
1384 wr32(wx, WX_PX_RR_BAL(reg_idx), rdba & DMA_BIT_MASK(32)); in wx_configure_rx_ring()
1385 wr32(wx, WX_PX_RR_BAH(reg_idx), upper_32_bits(rdba)); in wx_configure_rx_ring()
1393 wr32(wx, WX_PX_RR_CFG(reg_idx), rxdctl); in wx_configure_rx_ring()
1396 wr32(wx, WX_PX_RR_RP(reg_idx), 0); in wx_configure_rx_ring()
1397 wr32(wx, WX_PX_RR_WP(reg_idx), 0); in wx_configure_rx_ring()
1398 ring->tail = wx->hw_addr + WX_PX_RR_WP(reg_idx); in wx_configure_rx_ring()
1400 wx_configure_srrctl(wx, ring); in wx_configure_rx_ring()
1411 wr32m(wx, WX_PX_RR_CFG(reg_idx), in wx_configure_rx_ring()
1414 wx_enable_rx_queue(wx, ring); in wx_configure_rx_ring()
1424 static void wx_configure_tx(struct wx *wx) in wx_configure_tx() argument
1429 wr32m(wx, WX_TDM_CTL, in wx_configure_tx()
1433 for (i = 0; i < wx->num_tx_queues; i++) in wx_configure_tx()
1434 wx_configure_tx_ring(wx, wx->tx_ring[i]); in wx_configure_tx()
1436 wr32m(wx, WX_TSC_BUF_AE, WX_TSC_BUF_AE_THR, 0x10); in wx_configure_tx()
1438 if (wx->mac.type == wx_mac_em) in wx_configure_tx()
1439 wr32m(wx, WX_TSC_CTL, WX_TSC_CTL_TX_DIS | WX_TSC_CTL_TSEC_DIS, 0x1); in wx_configure_tx()
1442 wr32m(wx, WX_MAC_TX_CFG, in wx_configure_tx()
1452 static void wx_configure_rx(struct wx *wx) in wx_configure_rx() argument
1457 wx_disable_rx(wx); in wx_configure_rx()
1464 wr32(wx, WX_RDB_PL_CFG(0), psrtype); in wx_configure_rx()
1467 wr32m(wx, WX_RSC_CTL, WX_RSC_CTL_CRC_STRIP, WX_RSC_CTL_CRC_STRIP); in wx_configure_rx()
1469 if (wx->mac.type == wx_mac_sp) { in wx_configure_rx()
1473 psrctl = rd32(wx, WX_PSR_CTL); in wx_configure_rx()
1476 wr32(wx, WX_PSR_CTL, psrctl); in wx_configure_rx()
1480 wx_set_rx_buffer_len(wx); in wx_configure_rx()
1485 for (i = 0; i < wx->num_rx_queues; i++) in wx_configure_rx()
1486 wx_configure_rx_ring(wx, wx->rx_ring[i]); in wx_configure_rx()
1489 ret = wx_disable_sec_rx_path(wx); in wx_configure_rx()
1491 wx_err(wx, "The register status is abnormal, please check device."); in wx_configure_rx()
1493 wx_enable_rx(wx); in wx_configure_rx()
1494 wx_enable_sec_rx_path(wx); in wx_configure_rx()
1497 static void wx_configure_isb(struct wx *wx) in wx_configure_isb() argument
1500 wr32(wx, WX_PX_ISB_ADDR_L, wx->isb_dma & DMA_BIT_MASK(32)); in wx_configure_isb()
1502 wr32(wx, WX_PX_ISB_ADDR_H, upper_32_bits(wx->isb_dma)); in wx_configure_isb()
1505 void wx_configure(struct wx *wx) in wx_configure() argument
1507 wx_set_rxpba(wx); in wx_configure()
1508 wx_configure_port(wx); in wx_configure()
1510 wx_set_rx_mode(wx->netdev); in wx_configure()
1512 wx_enable_sec_rx_path(wx); in wx_configure()
1514 wx_configure_tx(wx); in wx_configure()
1515 wx_configure_rx(wx); in wx_configure()
1516 wx_configure_isb(wx); in wx_configure()
1527 int wx_disable_pcie_master(struct wx *wx) in wx_disable_pcie_master() argument
1533 pci_clear_master(wx->pdev); in wx_disable_pcie_master()
1536 if (!(rd32(wx, WX_PX_TRANSACTION_PENDING))) in wx_disable_pcie_master()
1541 false, wx, WX_PX_TRANSACTION_PENDING); in wx_disable_pcie_master()
1543 wx_err(wx, "PCIe transaction pending bit did not clear.\n"); in wx_disable_pcie_master()
1558 int wx_stop_adapter(struct wx *wx) in wx_stop_adapter() argument
1565 wx->adapter_stopped = true; in wx_stop_adapter()
1568 wx_disable_rx(wx); in wx_stop_adapter()
1571 wx_intr_disable(wx, WX_INTR_ALL); in wx_stop_adapter()
1574 wr32(wx, WX_PX_MISC_IC, 0xffffffff); in wx_stop_adapter()
1575 wr32(wx, WX_BME_CTL, 0x3); in wx_stop_adapter()
1578 for (i = 0; i < wx->mac.max_tx_queues; i++) { in wx_stop_adapter()
1579 wr32m(wx, WX_PX_TR_CFG(i), in wx_stop_adapter()
1585 for (i = 0; i < wx->mac.max_rx_queues; i++) { in wx_stop_adapter()
1586 wr32m(wx, WX_PX_RR_CFG(i), in wx_stop_adapter()
1591 WX_WRITE_FLUSH(wx); in wx_stop_adapter()
1596 return wx_disable_pcie_master(wx); in wx_stop_adapter()
1600 void wx_reset_misc(struct wx *wx) in wx_reset_misc() argument
1605 wr32m(wx, WX_MAC_RX_CFG, WX_MAC_RX_CFG_JE, WX_MAC_RX_CFG_JE); in wx_reset_misc()
1608 wr32m(wx, WX_MMC_CONTROL, in wx_reset_misc()
1611 wr32m(wx, WX_MAC_RX_FLOW_CTRL, in wx_reset_misc()
1614 wr32(wx, WX_MAC_PKT_FLT, WX_MAC_PKT_FLT_PR); in wx_reset_misc()
1616 wr32m(wx, WX_MIS_RST_ST, in wx_reset_misc()
1620 wr32(wx, WX_PSR_MNG_FLEX_SEL, 0); in wx_reset_misc()
1622 wr32(wx, WX_PSR_MNG_FLEX_DW_L(i), 0); in wx_reset_misc()
1623 wr32(wx, WX_PSR_MNG_FLEX_DW_H(i), 0); in wx_reset_misc()
1624 wr32(wx, WX_PSR_MNG_FLEX_MSK(i), 0); in wx_reset_misc()
1626 wr32(wx, WX_PSR_LAN_FLEX_SEL, 0); in wx_reset_misc()
1628 wr32(wx, WX_PSR_LAN_FLEX_DW_L(i), 0); in wx_reset_misc()
1629 wr32(wx, WX_PSR_LAN_FLEX_DW_H(i), 0); in wx_reset_misc()
1630 wr32(wx, WX_PSR_LAN_FLEX_MSK(i), 0); in wx_reset_misc()
1634 wr32(wx, WX_RDB_PFCMACDAL, 0xC2000001); in wx_reset_misc()
1635 wr32(wx, WX_RDB_PFCMACDAH, 0x0180); in wx_reset_misc()
1648 int wx_get_pcie_msix_counts(struct wx *wx, u16 *msix_count, u16 max_msix_count) in wx_get_pcie_msix_counts() argument
1650 struct pci_dev *pdev = wx->pdev; in wx_get_pcie_msix_counts()
1674 int wx_sw_init(struct wx *wx) in wx_sw_init() argument
1676 struct pci_dev *pdev = wx->pdev; in wx_sw_init()
1680 wx->vendor_id = pdev->vendor; in wx_sw_init()
1681 wx->device_id = pdev->device; in wx_sw_init()
1682 wx->revision_id = pdev->revision; in wx_sw_init()
1683 wx->oem_svid = pdev->subsystem_vendor; in wx_sw_init()
1684 wx->oem_ssid = pdev->subsystem_device; in wx_sw_init()
1685 wx->bus.device = PCI_SLOT(pdev->devfn); in wx_sw_init()
1686 wx->bus.func = PCI_FUNC(pdev->devfn); in wx_sw_init()
1688 if (wx->oem_svid == PCI_VENDOR_ID_WANGXUN) { in wx_sw_init()
1689 wx->subsystem_vendor_id = pdev->subsystem_vendor; in wx_sw_init()
1690 wx->subsystem_device_id = pdev->subsystem_device; in wx_sw_init()
1692 err = wx_flash_read_dword(wx, 0xfffdc, &ssid); in wx_sw_init()
1694 wx->subsystem_device_id = swab16((u16)ssid); in wx_sw_init()
1699 wx->mac_table = kcalloc(wx->mac.num_rar_entries, in wx_sw_init()
1702 if (!wx->mac_table) { in wx_sw_init()
1703 wx_err(wx, "mac_table allocation failed\n"); in wx_sw_init()