Lines Matching +full:save +full:- +full:mac +full:- +full:address
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2015 - 2022 Beijing WangXun Technology Co., Ltd. */
17 struct wx *wx = bus->priv; in wx_phy_read_reg_mdi()
21 /* setup and write the address cycle command */ in wx_phy_read_reg_mdi()
28 if (wx->mac.type == wx_mac_em) in wx_phy_read_reg_mdi()
46 struct wx *wx = bus->priv; in wx_phy_write_reg_mdi()
50 /* setup and write the address cycle command */ in wx_phy_write_reg_mdi()
57 if (wx->mac.type == wx_mac_em) in wx_phy_write_reg_mdi()
72 struct wx *wx = bus->priv; in wx_phy_read_reg_mdi_c22()
81 struct wx *wx = bus->priv; in wx_phy_write_reg_mdi_c22()
90 struct wx *wx = bus->priv; in wx_phy_read_reg_mdi_c45()
100 struct wx *wx = bus->priv; in wx_phy_write_reg_mdi_c45()
115 if (wx->mac.type == wx_mac_sp) { in wx_intr_disable()
129 if (wx->mac.type == wx_mac_sp) { in wx_intr_enable()
138 * wx_irq_disable - Mask off interrupt generation on the NIC
143 struct pci_dev *pdev = wx->pdev; in wx_irq_disable()
148 if (pdev->msix_enabled) { in wx_irq_disable()
151 for (vector = 0; vector < wx->num_q_vectors; vector++) in wx_irq_disable()
152 synchronize_irq(wx->msix_q_entries[vector].vector); in wx_irq_disable()
154 synchronize_irq(wx->msix_entry->vector); in wx_irq_disable()
156 synchronize_irq(pdev->irq); in wx_irq_disable()
162 * 1. to be sector address, when implemented erase sector command
163 * 2. to be flash address when implemented read, write flash address
221 * wx_mng_present - returns 0 when management capability is present
232 return -EACCES; in wx_mng_present()
240 * wx_release_sw_sync - Release SW semaphore
255 * wx_acquire_sw_sync - Acquire SW semaphore
282 * wx_host_interface_command - Issue command to manageability block
306 return -EINVAL; in wx_host_interface_command()
316 status = -EINVAL; in wx_host_interface_command()
343 status = -EINVAL; in wx_host_interface_command()
348 status = -EINVAL; in wx_host_interface_command()
373 buf_len = ((struct wx_hic_hdr *)buffer)->buf_len; in wx_host_interface_command()
379 status = -EFAULT; in wx_host_interface_command()
399 * wx_read_ee_hostif_data - Read EEPROM word using a host interface cmd
418 buffer.address = (__force u32)cpu_to_be32(offset * 2); in wx_read_ee_hostif_data()
434 * wx_read_ee_hostif - Read EEPROM word using a host interface cmd
456 * wx_read_ee_hostif_buffer- Read EEPROM word(s) using hostif
491 buffer.address = (__force u32)cpu_to_be32((offset + current_word) * 2); in wx_read_ee_hostif_buffer()
517 words -= words_to_read; in wx_read_ee_hostif_buffer()
527 * wx_init_eeprom_params - Initialize EEPROM params
535 struct wx_eeprom_info *eeprom = &wx->eeprom; in wx_init_eeprom_params()
539 if (eeprom->type == wx_eeprom_uninitialized) { in wx_init_eeprom_params()
540 eeprom->semaphore_delay = 10; in wx_init_eeprom_params()
541 eeprom->type = wx_eeprom_none; in wx_init_eeprom_params()
545 eeprom->type = wx_flash; in wx_init_eeprom_params()
548 eeprom->word_size = eeprom_size >> 1; in wx_init_eeprom_params()
551 eeprom->type, eeprom->word_size); in wx_init_eeprom_params()
555 if (wx->mac.type == wx_mac_sp) { in wx_init_eeprom_params()
563 eeprom->sw_region_offset = data; in wx_init_eeprom_params()
568 * wx_get_mac_addr - Generic get MAC address
570 * @mac_addr: Adapter MAC address
572 * Reads the adapter's MAC address from first Receive Address Register (RAR0)
574 * in order for the MAC address to have been loaded from the EEPROM into RAR0
587 mac_addr[i] = (u8)(rar_high >> (1 - i) * 8); in wx_get_mac_addr()
590 mac_addr[i + 2] = (u8)(rar_low >> (3 - i) * 8); in wx_get_mac_addr()
595 * wx_set_rar - Set Rx address register
597 * @index: Receive address register to write
598 * @addr: Address to put into receive address register
600 * @enable_addr: set flag that address is active
602 * Puts an ethernet address into a receive address register.
607 u32 rar_entries = wx->mac.num_rar_entries; in wx_set_rar()
613 return -EINVAL; in wx_set_rar()
616 /* select the MAC address */ in wx_set_rar()
621 if (wx->mac.type == wx_mac_sp) in wx_set_rar()
628 * so save everything except the lower 16 bits that hold part in wx_set_rar()
629 * of the address and the address valid bit. in wx_set_rar()
651 * wx_clear_rar - Remove Rx address register
653 * @index: Receive address register to write
655 * Clears an ethernet address from a receive address register.
659 u32 rar_entries = wx->mac.num_rar_entries; in wx_clear_rar()
664 return -EINVAL; in wx_clear_rar()
668 * so save everything except the lower 16 bits that hold part in wx_clear_rar()
669 * of the address and the address valid bit. in wx_clear_rar()
687 * wx_clear_vmdq - Disassociate a VMDq pool index from a rx address
689 * @rar: receive address register index to disassociate
694 u32 rar_entries = wx->mac.num_rar_entries; in wx_clear_vmdq()
700 return -EINVAL; in wx_clear_vmdq()
718 * wx_init_uta_tables - Initialize the Unicast Table Array
732 * wx_init_rx_addrs - Initializes receive address filters.
735 * Places the MAC address in receive address register 0 and clears the rest
736 * of the receive address registers. Clears the multicast table. Assumes
741 u32 rar_entries = wx->mac.num_rar_entries; in wx_init_rx_addrs()
745 /* If the current mac address is valid, assume it is a software override in wx_init_rx_addrs()
746 * to the permanent address. in wx_init_rx_addrs()
747 * Otherwise, use the permanent address from the eeprom. in wx_init_rx_addrs()
749 if (!is_valid_ether_addr(wx->mac.addr)) { in wx_init_rx_addrs()
750 /* Get the MAC address from the RAR0 for later reference */ in wx_init_rx_addrs()
751 wx_get_mac_addr(wx, wx->mac.addr); in wx_init_rx_addrs()
752 wx_dbg(wx, "Keeping Current RAR0 Addr = %pM\n", wx->mac.addr); in wx_init_rx_addrs()
754 /* Setup the receive address. */ in wx_init_rx_addrs()
755 wx_dbg(wx, "Overriding MAC Address in RAR[0]\n"); in wx_init_rx_addrs()
756 wx_dbg(wx, "New MAC Addr = %pM\n", wx->mac.addr); in wx_init_rx_addrs()
758 wx_set_rar(wx, 0, wx->mac.addr, 0, WX_PSR_MAC_SWC_AD_H_AV); in wx_init_rx_addrs()
760 if (wx->mac.type == wx_mac_sp) { in wx_init_rx_addrs()
767 wx_dbg(wx, "Clearing RAR[1-%d]\n", rar_entries - 1); in wx_init_rx_addrs()
775 wx->addr_ctrl.mta_in_use = 0; in wx_init_rx_addrs()
778 psrctl |= wx->mac.mc_filter_type << WX_PSR_CTL_MO_SHIFT; in wx_init_rx_addrs()
781 for (i = 0; i < wx->mac.mcft_size; i++) in wx_init_rx_addrs()
792 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_sync_mac_table()
793 if (wx->mac_table[i].state & WX_MAC_STATE_MODIFIED) { in wx_sync_mac_table()
794 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) { in wx_sync_mac_table()
796 wx->mac_table[i].addr, in wx_sync_mac_table()
797 wx->mac_table[i].pools, in wx_sync_mac_table()
802 wx->mac_table[i].state &= ~(WX_MAC_STATE_MODIFIED); in wx_sync_mac_table()
810 memcpy(&wx->mac_table[0].addr, addr, ETH_ALEN); in wx_mac_set_default_filter()
811 wx->mac_table[0].pools = 1ULL; in wx_mac_set_default_filter()
812 wx->mac_table[0].state = (WX_MAC_STATE_DEFAULT | WX_MAC_STATE_IN_USE); in wx_mac_set_default_filter()
813 wx_set_rar(wx, 0, wx->mac_table[0].addr, in wx_mac_set_default_filter()
814 wx->mac_table[0].pools, in wx_mac_set_default_filter()
823 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_flush_sw_mac_table()
824 if (!(wx->mac_table[i].state & WX_MAC_STATE_IN_USE)) in wx_flush_sw_mac_table()
827 wx->mac_table[i].state |= WX_MAC_STATE_MODIFIED; in wx_flush_sw_mac_table()
828 wx->mac_table[i].state &= ~WX_MAC_STATE_IN_USE; in wx_flush_sw_mac_table()
829 memset(wx->mac_table[i].addr, 0, ETH_ALEN); in wx_flush_sw_mac_table()
830 wx->mac_table[i].pools = 0; in wx_flush_sw_mac_table()
841 return -EINVAL; in wx_add_mac_filter()
843 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_add_mac_filter()
844 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) { in wx_add_mac_filter()
845 if (ether_addr_equal(addr, wx->mac_table[i].addr)) { in wx_add_mac_filter()
846 if (wx->mac_table[i].pools != (1ULL << pool)) { in wx_add_mac_filter()
847 memcpy(wx->mac_table[i].addr, addr, ETH_ALEN); in wx_add_mac_filter()
848 wx->mac_table[i].pools |= (1ULL << pool); in wx_add_mac_filter()
855 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) in wx_add_mac_filter()
857 wx->mac_table[i].state |= (WX_MAC_STATE_MODIFIED | in wx_add_mac_filter()
859 memcpy(wx->mac_table[i].addr, addr, ETH_ALEN); in wx_add_mac_filter()
860 wx->mac_table[i].pools |= (1ULL << pool); in wx_add_mac_filter()
864 return -ENOMEM; in wx_add_mac_filter()
872 return -EINVAL; in wx_del_mac_filter()
875 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_del_mac_filter()
876 if (!ether_addr_equal(addr, wx->mac_table[i].addr)) in wx_del_mac_filter()
879 wx->mac_table[i].state |= WX_MAC_STATE_MODIFIED; in wx_del_mac_filter()
880 wx->mac_table[i].pools &= ~(1ULL << pool); in wx_del_mac_filter()
881 if (!wx->mac_table[i].pools) { in wx_del_mac_filter()
882 wx->mac_table[i].state &= ~WX_MAC_STATE_IN_USE; in wx_del_mac_filter()
883 memset(wx->mac_table[i].addr, 0, ETH_ALEN); in wx_del_mac_filter()
888 return -ENOMEM; in wx_del_mac_filter()
895 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_available_rars()
896 if (wx->mac_table[i].state == 0) in wx_available_rars()
904 * wx_write_uc_addr_list - write unicast addresses to RAR table
906 * @pool: index for mac table
908 * Writes unicast address list to the RAR table.
909 * Returns: -ENOMEM on failure/insufficient address space
920 return -ENOMEM; in wx_write_uc_addr_list()
926 wx_del_mac_filter(wx, ha->addr, pool); in wx_write_uc_addr_list()
927 wx_add_mac_filter(wx, ha->addr, pool); in wx_write_uc_addr_list()
935 * wx_mta_vector - Determines bit-vector in multicast table to set
937 * @mc_addr: the multicast address
939 * Extracts the 12 bits, from a multicast address, to determine which
940 * bit-vector to set in the multicast table. The hardware uses 12 bits, from
941 * incoming rx multicast addresses, to determine the bit-vector to check in
942 * the MTA. Which of the 4 combination, of 12-bits, the hardware uses is set
950 switch (wx->mac.mc_filter_type) { in wx_mta_vector()
951 case 0: /* use bits [47:36] of the address */ in wx_mta_vector()
954 case 1: /* use bits [46:35] of the address */ in wx_mta_vector()
957 case 2: /* use bits [45:34] of the address */ in wx_mta_vector()
960 case 3: /* use bits [43:32] of the address */ in wx_mta_vector()
968 /* vector can only be 12-bits or boundary will be exceeded */ in wx_mta_vector()
974 * wx_set_mta - Set bit-vector in multicast table
976 * @mc_addr: Multicast address
978 * Sets the bit-vector in the multicast table.
984 wx->addr_ctrl.mta_in_use++; in wx_set_mta()
987 wx_dbg(wx, " bit-vector = 0x%03X\n", vector); in wx_set_mta()
989 /* The MTA is a register array of 128 32-bit registers. It is treated in wx_set_mta()
999 wx->mac.mta_shadow[vector_reg] |= (1 << vector_bit); in wx_set_mta()
1003 * wx_update_mc_addr_list - Updates MAC list of multicast addresses
1008 * address registers and the multicast table. Uses unused receive address
1020 wx->addr_ctrl.num_mc_addrs = netdev_mc_count(netdev); in wx_update_mc_addr_list()
1021 wx->addr_ctrl.mta_in_use = 0; in wx_update_mc_addr_list()
1025 memset(&wx->mac.mta_shadow, 0, sizeof(wx->mac.mta_shadow)); in wx_update_mc_addr_list()
1030 wx_set_mta(wx, ha->addr); in wx_update_mc_addr_list()
1034 for (i = 0; i < wx->mac.mcft_size; i++) in wx_update_mc_addr_list()
1036 wx->mac.mta_shadow[i]); in wx_update_mc_addr_list()
1038 if (wx->addr_ctrl.mta_in_use > 0) { in wx_update_mc_addr_list()
1042 (wx->mac.mc_filter_type << WX_PSR_CTL_MO_SHIFT); in wx_update_mc_addr_list()
1050 * wx_write_mc_addr_list - write multicast addresses to MTA
1053 * Writes multicast address list to the MTA hash table.
1070 * wx_set_mac - Change the Ethernet Address of the NIC
1072 * @p: pointer to an address structure
1086 wx_del_mac_filter(wx, wx->mac.addr, 0); in wx_set_mac()
1087 eth_hw_addr_set(netdev, addr->sa_data); in wx_set_mac()
1088 memcpy(wx->mac.addr, addr->sa_data, netdev->addr_len); in wx_set_mac()
1090 wx_mac_set_default_filter(wx, wx->mac.addr); in wx_set_mac()
1107 wx->mac.set_lben = true; in wx_disable_rx()
1109 wx->mac.set_lben = false; in wx_disable_rx()
1114 if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) || in wx_disable_rx()
1115 ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) { in wx_disable_rx()
1116 /* disable mac receiver */ in wx_disable_rx()
1128 /* enable mac receiver */ in wx_enable_rx()
1135 if (wx->mac.set_lben) { in wx_enable_rx()
1139 wx->mac.set_lben = false; in wx_enable_rx()
1144 * wx_set_rxpba - Initialize Rx packet buffer
1150 u32 pbsize = wx->mac.rx_pb_size; in wx_set_rxpba()
1152 if (test_bit(WX_FLAG_FDIR_CAPABLE, wx->flags)) { in wx_set_rxpba()
1153 if (test_bit(WX_FLAG_FDIR_HASH, wx->flags) || in wx_set_rxpba()
1154 test_bit(WX_FLAG_FDIR_PERFECT, wx->flags)) in wx_set_rxpba()
1155 pbsize -= 64; /* Default 64KB */ in wx_set_rxpba()
1162 txpktsize = wx->mac.tx_pb_size; in wx_set_rxpba()
1163 txpbthresh = (txpktsize / 1024) - WX_TXPKT_SIZE_MAX; in wx_set_rxpba()
1171 * wx_hpbthresh - calculate high water mark for flow control
1177 struct net_device *dev = wx->netdev; in wx_hpbthresh()
1182 link = dev->mtu + ETH_HLEN + ETH_FCS_LEN + WX_ETH_FRAMING; in wx_hpbthresh()
1192 marker = rx_pba - kb; in wx_hpbthresh()
1199 dev_warn(&wx->pdev->dev, in wx_hpbthresh()
1208 * wx_lpbthresh - calculate low water mark for flow control
1214 struct net_device *dev = wx->netdev; in wx_lpbthresh()
1219 tc = dev->mtu + ETH_HLEN + ETH_FCS_LEN; in wx_lpbthresh()
1229 * wx_pbthresh_setup - calculate and setup high low water marks
1235 wx->fc.high_water = wx_hpbthresh(wx); in wx_pbthresh_setup()
1236 wx->fc.low_water = wx_lpbthresh(wx); in wx_pbthresh_setup()
1239 if (wx->fc.low_water > wx->fc.high_water) in wx_pbthresh_setup()
1240 wx->fc.low_water = 0; in wx_pbthresh_setup()
1255 wx->tpid[0] = ETH_P_8021Q; in wx_configure_port()
1256 wx->tpid[1] = ETH_P_8021AD; in wx_configure_port()
1261 wx->tpid[i] = ETH_P_8021Q; in wx_configure_port()
1265 * wx_disable_sec_rx_path - Stops the receive data path
1284 * wx_enable_sec_rx_path - Enables the receive data path
1300 for (i = 0; i < wx->num_rx_queues; i++) { in wx_vlan_strip_control()
1301 struct wx_ring *ring = wx->rx_ring[i]; in wx_vlan_strip_control()
1303 j = ring->reg_idx; in wx_vlan_strip_control()
1316 features = netdev->features; in wx_set_rx_mode()
1336 wx->addr_ctrl.user_set_promisc = false; in wx_set_rx_mode()
1337 if (netdev->flags & IFF_PROMISC) { in wx_set_rx_mode()
1338 wx->addr_ctrl.user_set_promisc = true; in wx_set_rx_mode()
1345 if (netdev->flags & IFF_ALLMULTI) { in wx_set_rx_mode()
1350 if (netdev->features & NETIF_F_RXALL) { in wx_set_rx_mode()
1396 struct net_device *netdev = wx->netdev; in wx_set_rx_buffer_len()
1399 max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; in wx_set_rx_buffer_len()
1410 * wx_change_mtu - Change the Maximum Transfer Unit
1420 WRITE_ONCE(netdev->mtu, new_mtu); in wx_change_mtu()
1430 u8 reg_idx = ring->reg_idx; in wx_disable_rx_queue()
1442 if (ret == -ETIMEDOUT) { in wx_disable_rx_queue()
1453 u8 reg_idx = ring->reg_idx; in wx_enable_rx_queue()
1460 if (ret == -ETIMEDOUT) { in wx_enable_rx_queue()
1471 u16 reg_idx = rx_ring->reg_idx; in wx_configure_srrctl()
1491 u8 reg_idx = ring->reg_idx; in wx_configure_tx_ring()
1492 u64 tdba = ring->dma; in wx_configure_tx_ring()
1505 ring->tail = wx->hw_addr + WX_PX_TR_WP(reg_idx); in wx_configure_tx_ring()
1507 if (ring->count < WX_MAX_TXD) in wx_configure_tx_ring()
1508 txdctl |= ring->count / 128 << WX_PX_TR_CFG_TR_SIZE_SHIFT; in wx_configure_tx_ring()
1511 ring->atr_count = 0; in wx_configure_tx_ring()
1512 if (test_bit(WX_FLAG_FDIR_CAPABLE, wx->flags) && in wx_configure_tx_ring()
1513 test_bit(WX_FLAG_FDIR_HASH, wx->flags)) in wx_configure_tx_ring()
1514 ring->atr_sample_rate = wx->atr_sample_rate; in wx_configure_tx_ring()
1516 ring->atr_sample_rate = 0; in wx_configure_tx_ring()
1519 memset(ring->tx_buffer_info, 0, in wx_configure_tx_ring()
1520 sizeof(struct wx_tx_buffer) * ring->count); in wx_configure_tx_ring()
1528 if (ret == -ETIMEDOUT) in wx_configure_tx_ring()
1535 u16 reg_idx = ring->reg_idx; in wx_configure_rx_ring()
1537 u64 rdba = ring->dma; in wx_configure_rx_ring()
1547 if (ring->count == WX_MAX_RXD) in wx_configure_rx_ring()
1550 rxdctl |= (ring->count / 128) << WX_PX_RR_CFG_RR_SIZE_SHIFT; in wx_configure_rx_ring()
1558 ring->tail = wx->hw_addr + WX_PX_RR_WP(reg_idx); in wx_configure_rx_ring()
1563 memset(ring->rx_buffer_info, 0, in wx_configure_rx_ring()
1564 sizeof(struct wx_rx_buffer) * ring->count); in wx_configure_rx_ring()
1568 rx_desc->wb.upper.length = 0; in wx_configure_rx_ring()
1579 * wx_configure_tx - Configure Transmit Unit after Reset
1582 * Configure the Tx unit of the MAC after a reset.
1593 for (i = 0; i < wx->num_tx_queues; i++) in wx_configure_tx()
1594 wx_configure_tx_ring(wx, wx->tx_ring[i]); in wx_configure_tx()
1598 if (wx->mac.type == wx_mac_em) in wx_configure_tx()
1601 /* enable mac transmitter */ in wx_configure_tx()
1610 wx_vlan_rx_add_vid(wx->netdev, htons(ETH_P_8021Q), 0); in wx_restore_vlan()
1612 for_each_set_bit_from(vid, wx->active_vlans, VLAN_N_VID) in wx_restore_vlan()
1613 wx_vlan_rx_add_vid(wx->netdev, htons(ETH_P_8021Q), vid); in wx_restore_vlan()
1618 u8 *indir_tbl = wx->rss_indir_tbl; in wx_store_reta()
1623 * - 8 bit wide entries containing 4 bit RSS index in wx_store_reta()
1636 u16 rss_i = wx->ring_feature[RING_F_RSS].indices; in wx_setup_reta()
1642 wr32(wx, WX_RDB_RSSRK(i), wx->rss_key[i]); in wx_setup_reta()
1645 memset(wx->rss_indir_tbl, 0, sizeof(wx->rss_indir_tbl)); in wx_setup_reta()
1651 wx->rss_indir_tbl[i] = j; in wx_setup_reta()
1672 netdev_rss_key_fill(wx->rss_key, sizeof(wx->rss_key)); in wx_setup_mrqc()
1676 if (wx->rss_enabled) in wx_setup_mrqc()
1683 * wx_configure_rx - Configure Receive Unit after Reset
1686 * Configure the Rx unit of the MAC after a reset.
1704 if (wx->mac.type == wx_mac_sp) { in wx_configure_rx()
1722 for (i = 0; i < wx->num_rx_queues; i++) in wx_configure_rx()
1723 wx_configure_rx_ring(wx, wx->rx_ring[i]); in wx_configure_rx()
1737 /* set ISB Address */ in wx_configure_isb()
1738 wr32(wx, WX_PX_ISB_ADDR_L, wx->isb_dma & DMA_BIT_MASK(32)); in wx_configure_isb()
1740 wr32(wx, WX_PX_ISB_ADDR_H, upper_32_bits(wx->isb_dma)); in wx_configure_isb()
1749 wx_set_rx_mode(wx->netdev); in wx_configure()
1752 if (test_bit(WX_FLAG_FDIR_CAPABLE, wx->flags)) in wx_configure()
1753 wx->configure_fdir(wx); in wx_configure()
1762 * wx_disable_pcie_master - Disable PCI-express master access
1765 * Disables PCI-Express master access and verifies there are no pending
1774 pci_clear_master(wx->pdev); in wx_disable_pcie_master()
1791 * wx_stop_adapter - Generic stop Tx/Rx units
1806 wx->adapter_stopped = true; in wx_stop_adapter()
1819 for (i = 0; i < wx->mac.max_tx_queues; i++) { in wx_stop_adapter()
1826 for (i = 0; i < wx->mac.max_rx_queues; i++) { in wx_stop_adapter()
1834 /* Prevent the PCI-E bus from hanging by disabling PCI-E master in wx_stop_adapter()
1874 /* set pause frame dst mac addr */ in wx_reset_misc()
1881 * wx_get_pcie_msix_counts - Gets MSI-X vector count
1884 * @max_msix_count: number of MSI interrupts that mac need
1886 * Read PCIe configuration space, and get the MSI-X vector count from
1891 struct pci_dev *pdev = wx->pdev; in wx_get_pcie_msix_counts()
1892 struct device *dev = &pdev->dev; in wx_get_pcie_msix_counts()
1898 dev_err(dev, "Unable to find MSI-X Capabilities\n"); in wx_get_pcie_msix_counts()
1899 return -EINVAL; in wx_get_pcie_msix_counts()
1905 /* MSI-X count is zero-based in HW */ in wx_get_pcie_msix_counts()
1916 * wx_init_rss_key - Initialize wx RSS key
1925 if (!wx->rss_key) { in wx_init_rss_key()
1928 return -ENOMEM; in wx_init_rss_key()
1931 wx->rss_key = rss_key; in wx_init_rss_key()
1939 struct pci_dev *pdev = wx->pdev; in wx_sw_init()
1943 wx->vendor_id = pdev->vendor; in wx_sw_init()
1944 wx->device_id = pdev->device; in wx_sw_init()
1945 wx->revision_id = pdev->revision; in wx_sw_init()
1946 wx->oem_svid = pdev->subsystem_vendor; in wx_sw_init()
1947 wx->oem_ssid = pdev->subsystem_device; in wx_sw_init()
1948 wx->bus.device = PCI_SLOT(pdev->devfn); in wx_sw_init()
1949 wx->bus.func = PCI_FUNC(pdev->devfn); in wx_sw_init()
1951 if (wx->oem_svid == PCI_VENDOR_ID_WANGXUN) { in wx_sw_init()
1952 wx->subsystem_vendor_id = pdev->subsystem_vendor; in wx_sw_init()
1953 wx->subsystem_device_id = pdev->subsystem_device; in wx_sw_init()
1961 wx->subsystem_device_id = swab16((u16)ssid); in wx_sw_init()
1970 wx->mac_table = kcalloc(wx->mac.num_rar_entries, in wx_sw_init()
1973 if (!wx->mac_table) { in wx_sw_init()
1975 kfree(wx->rss_key); in wx_sw_init()
1976 return -ENOMEM; in wx_sw_init()
1979 bitmap_zero(wx->state, WX_STATE_NBITS); in wx_sw_init()
1980 bitmap_zero(wx->flags, WX_PF_FLAGS_NBITS); in wx_sw_init()
1981 wx->misc_irq_domain = false; in wx_sw_init()
1988 * wx_find_vlvf_slot - find the vlanid or the first empty slot
2004 /* Search for the vlan id in the VLVF entries. Save off the first empty in wx_find_vlvf_slot()
2020 regindex = -ENOMEM; in wx_find_vlvf_slot()
2027 * wx_set_vlvf - Set VLAN Pool Filter
2067 bits |= (1 << (vind - 32)); in wx_set_vlvf()
2079 bits &= ~(1 << (vind - 32)); in wx_set_vlvf()
2097 * wx_set_vfta - Set VLAN filter table
2111 /* this is a 2 part operation - first the VFTA, then the in wx_set_vfta()
2117 * The VFTA is a bitstring made up of 128 32-bit registers in wx_set_vfta()
2119 * bits[11-5]: which register in wx_set_vfta()
2120 * bits[4-0]: which bit in the register in wx_set_vfta()
2126 vfta = wx->mac.vft_shadow[regindex]; in wx_set_vfta()
2147 wx->mac.vft_shadow[regindex] = vfta; in wx_set_vfta()
2153 * wx_clear_vfta - Clear VLAN filter table
2162 for (offset = 0; offset < wx->mac.vft_size; offset++) { in wx_clear_vfta()
2164 wx->mac.vft_shadow[offset] = 0; in wx_clear_vfta()
2182 set_bit(vid, wx->active_vlans); in wx_vlan_rx_add_vid()
2195 clear_bit(vid, wx->active_vlans); in wx_vlan_rx_kill_vid()
2203 u16 reg_idx = ring->reg_idx; in wx_enable_rx_drop()
2214 u16 reg_idx = ring->reg_idx; in wx_disable_rx_drop()
2231 if (tx_pause && wx->fc.high_water) { in wx_fc_enable()
2232 if (!wx->fc.low_water || wx->fc.low_water >= wx->fc.high_water) { in wx_fc_enable()
2234 return -EINVAL; in wx_fc_enable()
2255 if (tx_pause && wx->fc.high_water) { in wx_fc_enable()
2256 fcrtl = (wx->fc.low_water << 10) | WX_RDB_RFCL_XONE; in wx_fc_enable()
2258 fcrth = (wx->fc.high_water << 10) | WX_RDB_RFCH_XOFFE; in wx_fc_enable()
2263 * to the Rx packet buffer size - 24KB. This allows in wx_fc_enable()
2267 fcrth = rd32(wx, WX_RDB_PB_SZ(0)) - 24576; in wx_fc_enable()
2285 if (wx->num_rx_queues > 1 && !tx_pause) { in wx_fc_enable()
2286 for (i = 0; i < wx->num_rx_queues; i++) in wx_fc_enable()
2287 wx_enable_rx_drop(wx, wx->rx_ring[i]); in wx_fc_enable()
2289 for (i = 0; i < wx->num_rx_queues; i++) in wx_fc_enable()
2290 wx_disable_rx_drop(wx, wx->rx_ring[i]); in wx_fc_enable()
2298 * wx_update_stats - Update the board statistics counters.
2303 struct wx_hw_stats *hwstats = &wx->stats; in wx_update_stats()
2311 for (i = 0; i < wx->num_rx_queues; i++) { in wx_update_stats()
2312 struct wx_ring *rx_ring = wx->rx_ring[i]; in wx_update_stats()
2314 non_eop_descs += rx_ring->rx_stats.non_eop_descs; in wx_update_stats()
2315 alloc_rx_buff_failed += rx_ring->rx_stats.alloc_rx_buff_failed; in wx_update_stats()
2316 hw_csum_rx_good += rx_ring->rx_stats.csum_good_cnt; in wx_update_stats()
2317 hw_csum_rx_error += rx_ring->rx_stats.csum_err; in wx_update_stats()
2319 wx->non_eop_descs = non_eop_descs; in wx_update_stats()
2320 wx->alloc_rx_buff_failed = alloc_rx_buff_failed; in wx_update_stats()
2321 wx->hw_csum_rx_error = hw_csum_rx_error; in wx_update_stats()
2322 wx->hw_csum_rx_good = hw_csum_rx_good; in wx_update_stats()
2324 for (i = 0; i < wx->num_tx_queues; i++) { in wx_update_stats()
2325 struct wx_ring *tx_ring = wx->tx_ring[i]; in wx_update_stats()
2327 restart_queue += tx_ring->tx_stats.restart_queue; in wx_update_stats()
2328 tx_busy += tx_ring->tx_stats.tx_busy; in wx_update_stats()
2330 wx->restart_queue = restart_queue; in wx_update_stats()
2331 wx->tx_busy = tx_busy; in wx_update_stats()
2333 hwstats->gprc += rd32(wx, WX_RDM_PKT_CNT); in wx_update_stats()
2334 hwstats->gptc += rd32(wx, WX_TDM_PKT_CNT); in wx_update_stats()
2335 hwstats->gorc += rd64(wx, WX_RDM_BYTE_CNT_LSB); in wx_update_stats()
2336 hwstats->gotc += rd64(wx, WX_TDM_BYTE_CNT_LSB); in wx_update_stats()
2337 hwstats->tpr += rd64(wx, WX_RX_FRAME_CNT_GOOD_BAD_L); in wx_update_stats()
2338 hwstats->tpt += rd64(wx, WX_TX_FRAME_CNT_GOOD_BAD_L); in wx_update_stats()
2339 hwstats->crcerrs += rd64(wx, WX_RX_CRC_ERROR_FRAMES_L); in wx_update_stats()
2340 hwstats->rlec += rd64(wx, WX_RX_LEN_ERROR_FRAMES_L); in wx_update_stats()
2341 hwstats->bprc += rd64(wx, WX_RX_BC_FRAMES_GOOD_L); in wx_update_stats()
2342 hwstats->bptc += rd64(wx, WX_TX_BC_FRAMES_GOOD_L); in wx_update_stats()
2343 hwstats->mprc += rd64(wx, WX_RX_MC_FRAMES_GOOD_L); in wx_update_stats()
2344 hwstats->mptc += rd64(wx, WX_TX_MC_FRAMES_GOOD_L); in wx_update_stats()
2345 hwstats->roc += rd32(wx, WX_RX_OVERSIZE_FRAMES_GOOD); in wx_update_stats()
2346 hwstats->ruc += rd32(wx, WX_RX_UNDERSIZE_FRAMES_GOOD); in wx_update_stats()
2347 hwstats->lxonoffrxc += rd32(wx, WX_MAC_LXONOFFRXC); in wx_update_stats()
2348 hwstats->lxontxc += rd32(wx, WX_RDB_LXONTXC); in wx_update_stats()
2349 hwstats->lxofftxc += rd32(wx, WX_RDB_LXOFFTXC); in wx_update_stats()
2350 hwstats->o2bgptc += rd32(wx, WX_TDM_OS2BMC_CNT); in wx_update_stats()
2351 hwstats->b2ospc += rd32(wx, WX_MNG_BMC2OS_CNT); in wx_update_stats()
2352 hwstats->o2bspc += rd32(wx, WX_MNG_OS2BMC_CNT); in wx_update_stats()
2353 hwstats->b2ogprc += rd32(wx, WX_RDM_BMC2OS_CNT); in wx_update_stats()
2354 hwstats->rdmdrop += rd32(wx, WX_RDM_DRP_PKT); in wx_update_stats()
2356 if (wx->mac.type == wx_mac_sp) { in wx_update_stats()
2357 hwstats->fdirmatch += rd32(wx, WX_RDB_FDIR_MATCH); in wx_update_stats()
2358 hwstats->fdirmiss += rd32(wx, WX_RDB_FDIR_MISS); in wx_update_stats()
2361 for (i = 0; i < wx->mac.max_rx_queues; i++) in wx_update_stats()
2362 hwstats->qmprc += rd32(wx, WX_PX_MPRC(i)); in wx_update_stats()
2367 * wx_clear_hw_cntrs - Generic clear hardware counters
2377 for (i = 0; i < wx->mac.max_rx_queues; i++) in wx_clear_hw_cntrs()
2402 * wx_start_hw - Prepare hardware for Tx/Rx
2407 * Then performs revision-specific operations, if any.
2417 for (i = 0; i < wx->mac.max_tx_queues; i++) { in wx_start_hw()