Lines Matching +full:mac +full:- +full:address

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2015 - 2022 Beijing WangXun Technology Co., Ltd. */
23 if (wx->mac.type == wx_mac_sp) { in wx_intr_disable()
37 if (wx->mac.type == wx_mac_sp) { in wx_intr_enable()
46 * wx_irq_disable - Mask off interrupt generation on the NIC
51 struct pci_dev *pdev = wx->pdev; in wx_irq_disable()
56 if (pdev->msix_enabled) { in wx_irq_disable()
59 for (vector = 0; vector < wx->num_q_vectors; vector++) in wx_irq_disable()
60 synchronize_irq(wx->msix_entries[vector].vector); in wx_irq_disable()
62 synchronize_irq(wx->msix_entries[vector].vector); in wx_irq_disable()
64 synchronize_irq(pdev->irq); in wx_irq_disable()
70 * 1. to be sector address, when implemented erase sector command
71 * 2. to be flash address when implemented read, write flash address
129 * wx_mng_present - returns 0 when management capability is present
140 return -EACCES; in wx_mng_present()
148 * wx_release_sw_sync - Release SW semaphore
163 * wx_acquire_sw_sync - Acquire SW semaphore
190 * wx_host_interface_command - Issue command to manageability block
214 return -EINVAL; in wx_host_interface_command()
224 status = -EINVAL; in wx_host_interface_command()
251 status = -EINVAL; in wx_host_interface_command()
256 status = -EINVAL; in wx_host_interface_command()
281 buf_len = ((struct wx_hic_hdr *)buffer)->buf_len; in wx_host_interface_command()
287 status = -EFAULT; in wx_host_interface_command()
307 * wx_read_ee_hostif_data - Read EEPROM word using a host interface cmd
326 buffer.address = (__force u32)cpu_to_be32(offset * 2); in wx_read_ee_hostif_data()
342 * wx_read_ee_hostif - Read EEPROM word using a host interface cmd
364 * wx_read_ee_hostif_buffer- Read EEPROM word(s) using hostif
399 buffer.address = (__force u32)cpu_to_be32((offset + current_word) * 2); in wx_read_ee_hostif_buffer()
425 words -= words_to_read; in wx_read_ee_hostif_buffer()
435 * wx_init_eeprom_params - Initialize EEPROM params
443 struct wx_eeprom_info *eeprom = &wx->eeprom; in wx_init_eeprom_params()
447 if (eeprom->type == wx_eeprom_uninitialized) { in wx_init_eeprom_params()
448 eeprom->semaphore_delay = 10; in wx_init_eeprom_params()
449 eeprom->type = wx_eeprom_none; in wx_init_eeprom_params()
453 eeprom->type = wx_flash; in wx_init_eeprom_params()
456 eeprom->word_size = eeprom_size >> 1; in wx_init_eeprom_params()
459 eeprom->type, eeprom->word_size); in wx_init_eeprom_params()
463 if (wx->mac.type == wx_mac_sp) { in wx_init_eeprom_params()
471 eeprom->sw_region_offset = data; in wx_init_eeprom_params()
476 * wx_get_mac_addr - Generic get MAC address
478 * @mac_addr: Adapter MAC address
480 * Reads the adapter's MAC address from first Receive Address Register (RAR0)
482 * in order for the MAC address to have been loaded from the EEPROM into RAR0
495 mac_addr[i] = (u8)(rar_high >> (1 - i) * 8); in wx_get_mac_addr()
498 mac_addr[i + 2] = (u8)(rar_low >> (3 - i) * 8); in wx_get_mac_addr()
503 * wx_set_rar - Set Rx address register
505 * @index: Receive address register to write
506 * @addr: Address to put into receive address register
508 * @enable_addr: set flag that address is active
510 * Puts an ethernet address into a receive address register.
515 u32 rar_entries = wx->mac.num_rar_entries; in wx_set_rar()
521 return -EINVAL; in wx_set_rar()
524 /* select the MAC address */ in wx_set_rar()
529 if (wx->mac.type == wx_mac_sp) in wx_set_rar()
537 * of the address and the address valid bit. in wx_set_rar()
559 * wx_clear_rar - Remove Rx address register
561 * @index: Receive address register to write
563 * Clears an ethernet address from a receive address register.
567 u32 rar_entries = wx->mac.num_rar_entries; in wx_clear_rar()
572 return -EINVAL; in wx_clear_rar()
577 * of the address and the address valid bit. in wx_clear_rar()
595 * wx_clear_vmdq - Disassociate a VMDq pool index from a rx address
597 * @rar: receive address register index to disassociate
602 u32 rar_entries = wx->mac.num_rar_entries; in wx_clear_vmdq()
608 return -EINVAL; in wx_clear_vmdq()
626 * wx_init_uta_tables - Initialize the Unicast Table Array
640 * wx_init_rx_addrs - Initializes receive address filters.
643 * Places the MAC address in receive address register 0 and clears the rest
644 * of the receive address registers. Clears the multicast table. Assumes
649 u32 rar_entries = wx->mac.num_rar_entries; in wx_init_rx_addrs()
653 /* If the current mac address is valid, assume it is a software override in wx_init_rx_addrs()
654 * to the permanent address. in wx_init_rx_addrs()
655 * Otherwise, use the permanent address from the eeprom. in wx_init_rx_addrs()
657 if (!is_valid_ether_addr(wx->mac.addr)) { in wx_init_rx_addrs()
658 /* Get the MAC address from the RAR0 for later reference */ in wx_init_rx_addrs()
659 wx_get_mac_addr(wx, wx->mac.addr); in wx_init_rx_addrs()
660 wx_dbg(wx, "Keeping Current RAR0 Addr = %pM\n", wx->mac.addr); in wx_init_rx_addrs()
662 /* Setup the receive address. */ in wx_init_rx_addrs()
663 wx_dbg(wx, "Overriding MAC Address in RAR[0]\n"); in wx_init_rx_addrs()
664 wx_dbg(wx, "New MAC Addr = %pM\n", wx->mac.addr); in wx_init_rx_addrs()
666 wx_set_rar(wx, 0, wx->mac.addr, 0, WX_PSR_MAC_SWC_AD_H_AV); in wx_init_rx_addrs()
668 if (wx->mac.type == wx_mac_sp) { in wx_init_rx_addrs()
675 wx_dbg(wx, "Clearing RAR[1-%d]\n", rar_entries - 1); in wx_init_rx_addrs()
683 wx->addr_ctrl.mta_in_use = 0; in wx_init_rx_addrs()
686 psrctl |= wx->mac.mc_filter_type << WX_PSR_CTL_MO_SHIFT; in wx_init_rx_addrs()
689 for (i = 0; i < wx->mac.mcft_size; i++) in wx_init_rx_addrs()
700 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_sync_mac_table()
701 if (wx->mac_table[i].state & WX_MAC_STATE_MODIFIED) { in wx_sync_mac_table()
702 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) { in wx_sync_mac_table()
704 wx->mac_table[i].addr, in wx_sync_mac_table()
705 wx->mac_table[i].pools, in wx_sync_mac_table()
710 wx->mac_table[i].state &= ~(WX_MAC_STATE_MODIFIED); in wx_sync_mac_table()
718 memcpy(&wx->mac_table[0].addr, addr, ETH_ALEN); in wx_mac_set_default_filter()
719 wx->mac_table[0].pools = 1ULL; in wx_mac_set_default_filter()
720 wx->mac_table[0].state = (WX_MAC_STATE_DEFAULT | WX_MAC_STATE_IN_USE); in wx_mac_set_default_filter()
721 wx_set_rar(wx, 0, wx->mac_table[0].addr, in wx_mac_set_default_filter()
722 wx->mac_table[0].pools, in wx_mac_set_default_filter()
731 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_flush_sw_mac_table()
732 if (!(wx->mac_table[i].state & WX_MAC_STATE_IN_USE)) in wx_flush_sw_mac_table()
735 wx->mac_table[i].state |= WX_MAC_STATE_MODIFIED; in wx_flush_sw_mac_table()
736 wx->mac_table[i].state &= ~WX_MAC_STATE_IN_USE; in wx_flush_sw_mac_table()
737 memset(wx->mac_table[i].addr, 0, ETH_ALEN); in wx_flush_sw_mac_table()
738 wx->mac_table[i].pools = 0; in wx_flush_sw_mac_table()
749 return -EINVAL; in wx_add_mac_filter()
751 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_add_mac_filter()
752 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) { in wx_add_mac_filter()
753 if (ether_addr_equal(addr, wx->mac_table[i].addr)) { in wx_add_mac_filter()
754 if (wx->mac_table[i].pools != (1ULL << pool)) { in wx_add_mac_filter()
755 memcpy(wx->mac_table[i].addr, addr, ETH_ALEN); in wx_add_mac_filter()
756 wx->mac_table[i].pools |= (1ULL << pool); in wx_add_mac_filter()
763 if (wx->mac_table[i].state & WX_MAC_STATE_IN_USE) in wx_add_mac_filter()
765 wx->mac_table[i].state |= (WX_MAC_STATE_MODIFIED | in wx_add_mac_filter()
767 memcpy(wx->mac_table[i].addr, addr, ETH_ALEN); in wx_add_mac_filter()
768 wx->mac_table[i].pools |= (1ULL << pool); in wx_add_mac_filter()
772 return -ENOMEM; in wx_add_mac_filter()
780 return -EINVAL; in wx_del_mac_filter()
783 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_del_mac_filter()
784 if (!ether_addr_equal(addr, wx->mac_table[i].addr)) in wx_del_mac_filter()
787 wx->mac_table[i].state |= WX_MAC_STATE_MODIFIED; in wx_del_mac_filter()
788 wx->mac_table[i].pools &= ~(1ULL << pool); in wx_del_mac_filter()
789 if (!wx->mac_table[i].pools) { in wx_del_mac_filter()
790 wx->mac_table[i].state &= ~WX_MAC_STATE_IN_USE; in wx_del_mac_filter()
791 memset(wx->mac_table[i].addr, 0, ETH_ALEN); in wx_del_mac_filter()
796 return -ENOMEM; in wx_del_mac_filter()
803 for (i = 0; i < wx->mac.num_rar_entries; i++) { in wx_available_rars()
804 if (wx->mac_table[i].state == 0) in wx_available_rars()
812 * wx_write_uc_addr_list - write unicast addresses to RAR table
814 * @pool: index for mac table
816 * Writes unicast address list to the RAR table.
817 * Returns: -ENOMEM on failure/insufficient address space
828 return -ENOMEM; in wx_write_uc_addr_list()
834 wx_del_mac_filter(wx, ha->addr, pool); in wx_write_uc_addr_list()
835 wx_add_mac_filter(wx, ha->addr, pool); in wx_write_uc_addr_list()
843 * wx_mta_vector - Determines bit-vector in multicast table to set
845 * @mc_addr: the multicast address
847 * Extracts the 12 bits, from a multicast address, to determine which
848 * bit-vector to set in the multicast table. The hardware uses 12 bits, from
849 * incoming rx multicast addresses, to determine the bit-vector to check in
850 * the MTA. Which of the 4 combination, of 12-bits, the hardware uses is set
858 switch (wx->mac.mc_filter_type) { in wx_mta_vector()
859 case 0: /* use bits [47:36] of the address */ in wx_mta_vector()
862 case 1: /* use bits [46:35] of the address */ in wx_mta_vector()
865 case 2: /* use bits [45:34] of the address */ in wx_mta_vector()
868 case 3: /* use bits [43:32] of the address */ in wx_mta_vector()
876 /* vector can only be 12-bits or boundary will be exceeded */ in wx_mta_vector()
882 * wx_set_mta - Set bit-vector in multicast table
884 * @mc_addr: Multicast address
886 * Sets the bit-vector in the multicast table.
892 wx->addr_ctrl.mta_in_use++; in wx_set_mta()
895 wx_dbg(wx, " bit-vector = 0x%03X\n", vector); in wx_set_mta()
897 /* The MTA is a register array of 128 32-bit registers. It is treated in wx_set_mta()
907 wx->mac.mta_shadow[vector_reg] |= (1 << vector_bit); in wx_set_mta()
911 * wx_update_mc_addr_list - Updates MAC list of multicast addresses
916 * address registers and the multicast table. Uses unused receive address
928 wx->addr_ctrl.num_mc_addrs = netdev_mc_count(netdev); in wx_update_mc_addr_list()
929 wx->addr_ctrl.mta_in_use = 0; in wx_update_mc_addr_list()
933 memset(&wx->mac.mta_shadow, 0, sizeof(wx->mac.mta_shadow)); in wx_update_mc_addr_list()
938 wx_set_mta(wx, ha->addr); in wx_update_mc_addr_list()
942 for (i = 0; i < wx->mac.mcft_size; i++) in wx_update_mc_addr_list()
944 wx->mac.mta_shadow[i]); in wx_update_mc_addr_list()
946 if (wx->addr_ctrl.mta_in_use > 0) { in wx_update_mc_addr_list()
950 (wx->mac.mc_filter_type << WX_PSR_CTL_MO_SHIFT); in wx_update_mc_addr_list()
958 * wx_write_mc_addr_list - write multicast addresses to MTA
961 * Writes multicast address list to the MTA hash table.
978 * wx_set_mac - Change the Ethernet Address of the NIC
980 * @p: pointer to an address structure
994 wx_del_mac_filter(wx, wx->mac.addr, 0); in wx_set_mac()
995 eth_hw_addr_set(netdev, addr->sa_data); in wx_set_mac()
996 memcpy(wx->mac.addr, addr->sa_data, netdev->addr_len); in wx_set_mac()
998 wx_mac_set_default_filter(wx, wx->mac.addr); in wx_set_mac()
1015 wx->mac.set_lben = true; in wx_disable_rx()
1017 wx->mac.set_lben = false; in wx_disable_rx()
1022 if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) || in wx_disable_rx()
1023 ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) { in wx_disable_rx()
1024 /* disable mac receiver */ in wx_disable_rx()
1036 /* enable mac receiver */ in wx_enable_rx()
1043 if (wx->mac.set_lben) { in wx_enable_rx()
1047 wx->mac.set_lben = false; in wx_enable_rx()
1052 * wx_set_rxpba - Initialize Rx packet buffer
1059 rxpktsize = wx->mac.rx_pb_size << WX_RDB_PB_SZ_SHIFT; in wx_set_rxpba()
1063 txpktsize = wx->mac.tx_pb_size; in wx_set_rxpba()
1064 txpbthresh = (txpktsize / 1024) - WX_TXPKT_SIZE_MAX; in wx_set_rxpba()
1081 wx->tpid[0] = ETH_P_8021Q; in wx_configure_port()
1082 wx->tpid[1] = ETH_P_8021AD; in wx_configure_port()
1087 wx->tpid[i] = ETH_P_8021Q; in wx_configure_port()
1091 * wx_disable_sec_rx_path - Stops the receive data path
1109 * wx_enable_sec_rx_path - Enables the receive data path
1124 for (i = 0; i < wx->num_rx_queues; i++) { in wx_vlan_strip_control()
1125 struct wx_ring *ring = wx->rx_ring[i]; in wx_vlan_strip_control()
1127 j = ring->reg_idx; in wx_vlan_strip_control()
1140 features = netdev->features; in wx_set_rx_mode()
1160 wx->addr_ctrl.user_set_promisc = false; in wx_set_rx_mode()
1161 if (netdev->flags & IFF_PROMISC) { in wx_set_rx_mode()
1162 wx->addr_ctrl.user_set_promisc = true; in wx_set_rx_mode()
1169 if (netdev->flags & IFF_ALLMULTI) { in wx_set_rx_mode()
1174 if (netdev->features & NETIF_F_RXALL) { in wx_set_rx_mode()
1220 struct net_device *netdev = wx->netdev; in wx_set_rx_buffer_len()
1223 max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; in wx_set_rx_buffer_len()
1234 * wx_change_mtu - Change the Maximum Transfer Unit
1244 netdev->mtu = new_mtu; in wx_change_mtu()
1254 u8 reg_idx = ring->reg_idx; in wx_disable_rx_queue()
1266 if (ret == -ETIMEDOUT) { in wx_disable_rx_queue()
1277 u8 reg_idx = ring->reg_idx; in wx_enable_rx_queue()
1284 if (ret == -ETIMEDOUT) { in wx_enable_rx_queue()
1295 u16 reg_idx = rx_ring->reg_idx; in wx_configure_srrctl()
1315 u8 reg_idx = ring->reg_idx; in wx_configure_tx_ring()
1316 u64 tdba = ring->dma; in wx_configure_tx_ring()
1329 ring->tail = wx->hw_addr + WX_PX_TR_WP(reg_idx); in wx_configure_tx_ring()
1331 if (ring->count < WX_MAX_TXD) in wx_configure_tx_ring()
1332 txdctl |= ring->count / 128 << WX_PX_TR_CFG_TR_SIZE_SHIFT; in wx_configure_tx_ring()
1336 memset(ring->tx_buffer_info, 0, in wx_configure_tx_ring()
1337 sizeof(struct wx_tx_buffer) * ring->count); in wx_configure_tx_ring()
1345 if (ret == -ETIMEDOUT) in wx_configure_tx_ring()
1352 u16 reg_idx = ring->reg_idx; in wx_configure_rx_ring()
1354 u64 rdba = ring->dma; in wx_configure_rx_ring()
1364 if (ring->count == WX_MAX_RXD) in wx_configure_rx_ring()
1367 rxdctl |= (ring->count / 128) << WX_PX_RR_CFG_RR_SIZE_SHIFT; in wx_configure_rx_ring()
1375 ring->tail = wx->hw_addr + WX_PX_RR_WP(reg_idx); in wx_configure_rx_ring()
1380 memset(ring->rx_buffer_info, 0, in wx_configure_rx_ring()
1381 sizeof(struct wx_rx_buffer) * ring->count); in wx_configure_rx_ring()
1385 rx_desc->wb.upper.length = 0; in wx_configure_rx_ring()
1396 * wx_configure_tx - Configure Transmit Unit after Reset
1399 * Configure the Tx unit of the MAC after a reset.
1410 for (i = 0; i < wx->num_tx_queues; i++) in wx_configure_tx()
1411 wx_configure_tx_ring(wx, wx->tx_ring[i]); in wx_configure_tx()
1415 if (wx->mac.type == wx_mac_em) in wx_configure_tx()
1418 /* enable mac transmitter */ in wx_configure_tx()
1427 wx_vlan_rx_add_vid(wx->netdev, htons(ETH_P_8021Q), 0); in wx_restore_vlan()
1429 for_each_set_bit_from(vid, wx->active_vlans, VLAN_N_VID) in wx_restore_vlan()
1430 wx_vlan_rx_add_vid(wx->netdev, htons(ETH_P_8021Q), vid); in wx_restore_vlan()
1434 * wx_configure_rx - Configure Receive Unit after Reset
1437 * Configure the Rx unit of the MAC after a reset.
1455 if (wx->mac.type == wx_mac_sp) { in wx_configure_rx()
1471 for (i = 0; i < wx->num_rx_queues; i++) in wx_configure_rx()
1472 wx_configure_rx_ring(wx, wx->rx_ring[i]); in wx_configure_rx()
1486 /* set ISB Address */ in wx_configure_isb()
1487 wr32(wx, WX_PX_ISB_ADDR_L, wx->isb_dma & DMA_BIT_MASK(32)); in wx_configure_isb()
1489 wr32(wx, WX_PX_ISB_ADDR_H, upper_32_bits(wx->isb_dma)); in wx_configure_isb()
1497 wx_set_rx_mode(wx->netdev); in wx_configure()
1508 * wx_disable_pcie_master - Disable PCI-express master access
1511 * Disables PCI-Express master access and verifies there are no pending
1520 pci_clear_master(wx->pdev); in wx_disable_pcie_master()
1537 * wx_stop_adapter - Generic stop Tx/Rx units
1552 wx->adapter_stopped = true; in wx_stop_adapter()
1565 for (i = 0; i < wx->mac.max_tx_queues; i++) { in wx_stop_adapter()
1572 for (i = 0; i < wx->mac.max_rx_queues; i++) { in wx_stop_adapter()
1580 /* Prevent the PCI-E bus from hanging by disabling PCI-E master in wx_stop_adapter()
1620 /* set pause frame dst mac addr */ in wx_reset_misc()
1627 * wx_get_pcie_msix_counts - Gets MSI-X vector count
1630 * @max_msix_count: number of MSI interrupts that mac need
1632 * Read PCIe configuration space, and get the MSI-X vector count from
1637 struct pci_dev *pdev = wx->pdev; in wx_get_pcie_msix_counts()
1638 struct device *dev = &pdev->dev; in wx_get_pcie_msix_counts()
1644 dev_err(dev, "Unable to find MSI-X Capabilities\n"); in wx_get_pcie_msix_counts()
1645 return -EINVAL; in wx_get_pcie_msix_counts()
1651 /* MSI-X count is zero-based in HW */ in wx_get_pcie_msix_counts()
1663 struct pci_dev *pdev = wx->pdev; in wx_sw_init()
1667 wx->vendor_id = pdev->vendor; in wx_sw_init()
1668 wx->device_id = pdev->device; in wx_sw_init()
1669 wx->revision_id = pdev->revision; in wx_sw_init()
1670 wx->oem_svid = pdev->subsystem_vendor; in wx_sw_init()
1671 wx->oem_ssid = pdev->subsystem_device; in wx_sw_init()
1672 wx->bus.device = PCI_SLOT(pdev->devfn); in wx_sw_init()
1673 wx->bus.func = PCI_FUNC(pdev->devfn); in wx_sw_init()
1675 if (wx->oem_svid == PCI_VENDOR_ID_WANGXUN) { in wx_sw_init()
1676 wx->subsystem_vendor_id = pdev->subsystem_vendor; in wx_sw_init()
1677 wx->subsystem_device_id = pdev->subsystem_device; in wx_sw_init()
1681 wx->subsystem_device_id = swab16((u16)ssid); in wx_sw_init()
1686 wx->mac_table = kcalloc(wx->mac.num_rar_entries, in wx_sw_init()
1689 if (!wx->mac_table) { in wx_sw_init()
1691 return -ENOMEM; in wx_sw_init()
1699 * wx_find_vlvf_slot - find the vlanid or the first empty slot
1731 regindex = -ENOMEM; in wx_find_vlvf_slot()
1738 * wx_set_vlvf - Set VLAN Pool Filter
1778 bits |= (1 << (vind - 32)); in wx_set_vlvf()
1790 bits &= ~(1 << (vind - 32)); in wx_set_vlvf()
1808 * wx_set_vfta - Set VLAN filter table
1822 /* this is a 2 part operation - first the VFTA, then the in wx_set_vfta()
1828 * The VFTA is a bitstring made up of 128 32-bit registers in wx_set_vfta()
1830 * bits[11-5]: which register in wx_set_vfta()
1831 * bits[4-0]: which bit in the register in wx_set_vfta()
1837 vfta = wx->mac.vft_shadow[regindex]; in wx_set_vfta()
1858 wx->mac.vft_shadow[regindex] = vfta; in wx_set_vfta()
1864 * wx_clear_vfta - Clear VLAN filter table
1873 for (offset = 0; offset < wx->mac.vft_size; offset++) { in wx_clear_vfta()
1875 wx->mac.vft_shadow[offset] = 0; in wx_clear_vfta()
1893 set_bit(vid, wx->active_vlans); in wx_vlan_rx_add_vid()
1906 clear_bit(vid, wx->active_vlans); in wx_vlan_rx_kill_vid()
1913 * wx_start_hw - Prepare hardware for Tx/Rx
1918 * Then performs revision-specific operations, if any.
1928 for (i = 0; i < wx->mac.max_tx_queues; i++) { in wx_start_hw()