Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue

Jeff Kirsher says:

====================
Intel Wired LAN Driver Updates 2018-12-20

This series contains updates to e100, igb, ixgbe, i40e and ice drivers.

I replaced spinlocks for mutex locks to reduce the latency on CPU0 for
igb when updating the statistics. This work was based off a patch
provided by Jan Jablonsky, which was against an older version of the igb
driver.

Jesus adjusts the receive packet buffer size from 32K to 30K when
running in QAV mode, to stay within 60K for total packet buffer size for
igb.

Vinicius adds igb kernel documentation regarding the CBS algorithm and
its implementation in the i210 family of NICs.

YueHaibing from Huawei fixed the e100 driver that was potentially
passing a NULL pointer, so use the kernel macro IS_ERR_OR_NULL()
instead.

Konstantin Khorenko fixes i40e where we were not setting up the
neigh_priv_len in our net_device, which caused the driver to read beyond
the neighbor entry allocated memory.

Miroslav Lichvar extends the PTP gettime() to read the system clock by
adding support for PTP_SYS_OFFSET_EXTENDED ioctl in i40e.

Young Xiao fixed the ice driver to only enable NAPI on q_vectors that
actually have transmit and receive rings.

Kai-Heng Feng fixes an igb issue that when placed in suspend mode, the
NIC does not wake up when a cable is plugged in. This was due to the
driver not setting PME during runtime suspend.

Stephen Douthit enables the ixgbe driver allow DSA devices to use the
MII interface to talk to switches.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+392 -26
+19
Documentation/networking/device_drivers/intel/igb.rst
··· 177 177 IProute2 tool from Sourceforge if your version does not have all the features 178 178 you require. 179 179 180 + Credit Based Shaper (Qav Mode) 181 + ------------------------------ 182 + When enabling the CBS qdisc in the hardware offload mode, traffic shaping using 183 + the CBS (described in the IEEE 802.1Q-2018 Section 8.6.8.2 and discussed in the 184 + Annex L) algorithm will run in the i210 controller, so it's more accurate and 185 + uses less CPU. 186 + 187 + When using offloaded CBS, and the traffic rate obeys the configured rate 188 + (doesn't go above it), CBS should have little to no effect in the latency. 189 + 190 + The offloaded version of the algorithm has some limits, caused by how the idle 191 + slope is expressed in the adapter's registers. It can only represent idle slopes 192 + in 16.38431 kbps units, which means that if a idle slope of 2576kbps is 193 + requested, the controller will be configured to use a idle slope of ~2589 kbps, 194 + because the driver rounds the value up. For more details, see the comments on 195 + :c:func:`igb_config_tx_modes()`. 196 + 197 + NOTE: This feature is exclusive to i210 models. 198 + 180 199 181 200 Support 182 201 =======
+1
drivers/net/ethernet/intel/Kconfig
··· 159 159 tristate "Intel(R) 10GbE PCI Express adapters support" 160 160 depends on PCI 161 161 select MDIO 162 + select MDIO_DEVICE 162 163 imply PTP_1588_CLOCK 163 164 ---help--- 164 165 This driver supports Intel(R) 10GbE PCI Express family of
+2 -2
drivers/net/ethernet/intel/e100.c
··· 1345 1345 1346 1346 fw = e100_request_firmware(nic); 1347 1347 /* If it's NULL, then no ucode is required */ 1348 - if (!fw || IS_ERR(fw)) 1349 - return PTR_ERR(fw); 1348 + if (IS_ERR_OR_NULL(fw)) 1349 + return PTR_ERR_OR_ZERO(fw); 1350 1350 1351 1351 if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode))) 1352 1352 netif_err(nic, probe, nic->netdev,
+3
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 12339 12339 ether_addr_copy(netdev->dev_addr, mac_addr); 12340 12340 ether_addr_copy(netdev->perm_addr, mac_addr); 12341 12341 12342 + /* i40iw_net_event() reads 16 bytes from neigh->primary_key */ 12343 + netdev->neigh_priv_len = sizeof(u32) * 4; 12344 + 12342 12345 netdev->priv_flags |= IFF_UNICAST_FLT; 12343 12346 netdev->priv_flags |= IFF_SUPP_NOFCS; 12344 12347 /* Setup netdev TC information */
+12 -6
drivers/net/ethernet/intel/i40e/i40e_ptp.c
··· 28 28 * i40e_ptp_read - Read the PHC time from the device 29 29 * @pf: Board private structure 30 30 * @ts: timespec structure to hold the current time value 31 + * @sts: structure to hold the system time before and after reading the PHC 31 32 * 32 33 * This function reads the PRTTSYN_TIME registers and stores them in a 33 34 * timespec. However, since the registers are 64 bits of nanoseconds, we must 34 35 * convert the result to a timespec before we can return. 35 36 **/ 36 - static void i40e_ptp_read(struct i40e_pf *pf, struct timespec64 *ts) 37 + static void i40e_ptp_read(struct i40e_pf *pf, struct timespec64 *ts, 38 + struct ptp_system_timestamp *sts) 37 39 { 38 40 struct i40e_hw *hw = &pf->hw; 39 41 u32 hi, lo; 40 42 u64 ns; 41 43 42 44 /* The timer latches on the lowest register read. */ 45 + ptp_read_system_prets(sts); 43 46 lo = rd32(hw, I40E_PRTTSYN_TIME_L); 47 + ptp_read_system_postts(sts); 44 48 hi = rd32(hw, I40E_PRTTSYN_TIME_H); 45 49 46 50 ns = (((u64)hi) << 32) | lo; ··· 150 146 151 147 mutex_lock(&pf->tmreg_lock); 152 148 153 - i40e_ptp_read(pf, &now); 149 + i40e_ptp_read(pf, &now, NULL); 154 150 timespec64_add_ns(&now, delta); 155 151 i40e_ptp_write(pf, (const struct timespec64 *)&now); 156 152 ··· 160 156 } 161 157 162 158 /** 163 - * i40e_ptp_gettime - Get the time of the PHC 159 + * i40e_ptp_gettimex - Get the time of the PHC 164 160 * @ptp: The PTP clock structure 165 161 * @ts: timespec structure to hold the current time value 162 + * @sts: structure to hold the system time before and after reading the PHC 166 163 * 167 164 * Read the device clock and return the correct value on ns, after converting it 168 165 * into a timespec struct. 169 166 **/ 170 - static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) 167 + static int i40e_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts, 168 + struct ptp_system_timestamp *sts) 171 169 { 172 170 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); 173 171 174 172 mutex_lock(&pf->tmreg_lock); 175 - i40e_ptp_read(pf, ts); 173 + i40e_ptp_read(pf, ts, sts); 176 174 mutex_unlock(&pf->tmreg_lock); 177 175 178 176 return 0; ··· 708 702 pf->ptp_caps.pps = 0; 709 703 pf->ptp_caps.adjfreq = i40e_ptp_adjfreq; 710 704 pf->ptp_caps.adjtime = i40e_ptp_adjtime; 711 - pf->ptp_caps.gettime64 = i40e_ptp_gettime; 705 + pf->ptp_caps.gettimex64 = i40e_ptp_gettimex; 712 706 pf->ptp_caps.settime64 = i40e_ptp_settime; 713 707 pf->ptp_caps.enable = i40e_ptp_feature_enable; 714 708
+12 -4
drivers/net/ethernet/intel/ice/ice_main.c
··· 2564 2564 if (!vsi->netdev) 2565 2565 return; 2566 2566 2567 - for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) 2568 - napi_enable(&vsi->q_vectors[q_idx]->napi); 2567 + for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) { 2568 + struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; 2569 + 2570 + if (q_vector->rx.ring || q_vector->tx.ring) 2571 + napi_enable(&q_vector->napi); 2572 + } 2569 2573 } 2570 2574 2571 2575 /** ··· 2936 2932 if (!vsi->netdev) 2937 2933 return; 2938 2934 2939 - for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) 2940 - napi_disable(&vsi->q_vectors[q_idx]->napi); 2935 + for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) { 2936 + struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; 2937 + 2938 + if (q_vector->rx.ring || q_vector->tx.ring) 2939 + napi_disable(&q_vector->napi); 2940 + } 2941 2941 } 2942 2942 2943 2943 /**
+1
drivers/net/ethernet/intel/igb/e1000_defines.h
··· 334 334 335 335 #define I210_RXPBSIZE_DEFAULT 0x000000A2 /* RXPBSIZE default */ 336 336 #define I210_RXPBSIZE_MASK 0x0000003F 337 + #define I210_RXPBSIZE_PB_30KB 0x0000001E 337 338 #define I210_RXPBSIZE_PB_32KB 0x00000020 338 339 #define I210_TXPBSIZE_DEFAULT 0x04000014 /* TXPBSIZE default */ 339 340 #define I210_TXPBSIZE_MASK 0xC0FFFFFF
+1 -1
drivers/net/ethernet/intel/igb/igb.h
··· 515 515 /* OS defined structs */ 516 516 struct pci_dev *pdev; 517 517 518 - spinlock_t stats64_lock; 518 + struct mutex stats64_lock; 519 519 struct rtnl_link_stats64 stats64; 520 520 521 521 /* structs defined in e1000_hw.h */
+2 -2
drivers/net/ethernet/intel/igb/igb_ethtool.c
··· 2295 2295 int i, j; 2296 2296 char *p; 2297 2297 2298 - spin_lock(&adapter->stats64_lock); 2298 + mutex_lock(&adapter->stats64_lock); 2299 2299 igb_update_stats(adapter); 2300 2300 2301 2301 for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) { ··· 2338 2338 } while (u64_stats_fetch_retry_irq(&ring->rx_syncp, start)); 2339 2339 i += IGB_RX_QUEUE_STATS_LEN; 2340 2340 } 2341 - spin_unlock(&adapter->stats64_lock); 2341 + mutex_unlock(&adapter->stats64_lock); 2342 2342 } 2343 2343 2344 2344 static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
+13 -11
drivers/net/ethernet/intel/igb/igb_main.c
··· 1934 1934 1935 1935 val = rd32(E1000_RXPBS); 1936 1936 val &= ~I210_RXPBSIZE_MASK; 1937 - val |= I210_RXPBSIZE_PB_32KB; 1937 + val |= I210_RXPBSIZE_PB_30KB; 1938 1938 wr32(E1000_RXPBS, val); 1939 1939 1940 1940 /* Section 8.12.9 states that MAX_TPKT_SIZE from DTXMXPKTSZ ··· 2203 2203 del_timer_sync(&adapter->phy_info_timer); 2204 2204 2205 2205 /* record the stats before reset*/ 2206 - spin_lock(&adapter->stats64_lock); 2206 + mutex_lock(&adapter->stats64_lock); 2207 2207 igb_update_stats(adapter); 2208 - spin_unlock(&adapter->stats64_lock); 2208 + mutex_unlock(&adapter->stats64_lock); 2209 2209 2210 2210 adapter->link_speed = 0; 2211 2211 adapter->link_duplex = 0; ··· 3840 3840 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 3841 3841 3842 3842 spin_lock_init(&adapter->nfc_lock); 3843 - spin_lock_init(&adapter->stats64_lock); 3843 + mutex_init(&adapter->stats64_lock); 3844 3844 #ifdef CONFIG_PCI_IOV 3845 3845 switch (hw->mac.type) { 3846 3846 case e1000_82576: ··· 5406 5406 } 5407 5407 } 5408 5408 5409 - spin_lock(&adapter->stats64_lock); 5409 + mutex_lock(&adapter->stats64_lock); 5410 5410 igb_update_stats(adapter); 5411 - spin_unlock(&adapter->stats64_lock); 5411 + mutex_unlock(&adapter->stats64_lock); 5412 5412 5413 5413 for (i = 0; i < adapter->num_tx_queues; i++) { 5414 5414 struct igb_ring *tx_ring = adapter->tx_ring[i]; ··· 6235 6235 { 6236 6236 struct igb_adapter *adapter = netdev_priv(netdev); 6237 6237 6238 - spin_lock(&adapter->stats64_lock); 6238 + mutex_lock(&adapter->stats64_lock); 6239 6239 igb_update_stats(adapter); 6240 6240 memcpy(stats, &adapter->stats64, sizeof(*stats)); 6241 - spin_unlock(&adapter->stats64_lock); 6241 + mutex_unlock(&adapter->stats64_lock); 6242 6242 } 6243 6243 6244 6244 /** ··· 8771 8771 rtnl_unlock(); 8772 8772 8773 8773 #ifdef CONFIG_PM 8774 - retval = pci_save_state(pdev); 8775 - if (retval) 8776 - return retval; 8774 + if (!runtime) { 8775 + retval = pci_save_state(pdev); 8776 + if (retval) 8777 + return retval; 8778 + } 8777 8779 #endif 8778 8780 8779 8781 status = rd32(E1000_STATUS);
+2
drivers/net/ethernet/intel/ixgbe/ixgbe.h
··· 12 12 #include <linux/aer.h> 13 13 #include <linux/if_vlan.h> 14 14 #include <linux/jiffies.h> 15 + #include <linux/phy.h> 15 16 16 17 #include <linux/timecounter.h> 17 18 #include <linux/net_tstamp.h> ··· 562 561 struct net_device *netdev; 563 562 struct bpf_prog *xdp_prog; 564 563 struct pci_dev *pdev; 564 + struct mii_bus *mii_bus; 565 565 566 566 unsigned long state; 567 567
+23
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 39 39 #include "ixgbe.h" 40 40 #include "ixgbe_common.h" 41 41 #include "ixgbe_dcb_82599.h" 42 + #include "ixgbe_phy.h" 42 43 #include "ixgbe_sriov.h" 43 44 #include "ixgbe_model.h" 44 45 #include "ixgbe_txrx_common.h" ··· 8791 8790 u16 value; 8792 8791 int rc; 8793 8792 8793 + if (adapter->mii_bus) { 8794 + int regnum = addr; 8795 + 8796 + if (devad != MDIO_DEVAD_NONE) 8797 + regnum |= (devad << 16) | MII_ADDR_C45; 8798 + 8799 + return mdiobus_read(adapter->mii_bus, prtad, regnum); 8800 + } 8801 + 8794 8802 if (prtad != hw->phy.mdio.prtad) 8795 8803 return -EINVAL; 8796 8804 rc = hw->phy.ops.read_reg(hw, addr, devad, &value); ··· 8813 8803 { 8814 8804 struct ixgbe_adapter *adapter = netdev_priv(netdev); 8815 8805 struct ixgbe_hw *hw = &adapter->hw; 8806 + 8807 + if (adapter->mii_bus) { 8808 + int regnum = addr; 8809 + 8810 + if (devad != MDIO_DEVAD_NONE) 8811 + regnum |= (devad << 16) | MII_ADDR_C45; 8812 + 8813 + return mdiobus_write(adapter->mii_bus, prtad, regnum, value); 8814 + } 8816 8815 8817 8816 if (prtad != hw->phy.mdio.prtad) 8818 8817 return -EINVAL; ··· 11141 11122 IXGBE_LINK_SPEED_10GB_FULL | IXGBE_LINK_SPEED_1GB_FULL, 11142 11123 true); 11143 11124 11125 + ixgbe_mii_bus_init(hw); 11126 + 11144 11127 return 0; 11145 11128 11146 11129 err_register: ··· 11193 11172 set_bit(__IXGBE_REMOVING, &adapter->state); 11194 11173 cancel_work_sync(&adapter->service_task); 11195 11174 11175 + if (adapter->mii_bus) 11176 + mdiobus_unregister(adapter->mii_bus); 11196 11177 11197 11178 #ifdef CONFIG_IXGBE_DCA 11198 11179 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) {
+299
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
··· 3 3 4 4 #include <linux/pci.h> 5 5 #include <linux/delay.h> 6 + #include <linux/iopoll.h> 6 7 #include <linux/sched.h> 7 8 8 9 #include "ixgbe.h" ··· 657 656 } 658 657 659 658 return status; 659 + } 660 + 661 + #define IXGBE_HW_READ_REG(addr) IXGBE_READ_REG(hw, addr) 662 + 663 + /** 664 + * ixgbe_msca_cmd - Write the command register and poll for completion/timeout 665 + * @hw: pointer to hardware structure 666 + * @cmd: command register value to write 667 + **/ 668 + static s32 ixgbe_msca_cmd(struct ixgbe_hw *hw, u32 cmd) 669 + { 670 + IXGBE_WRITE_REG(hw, IXGBE_MSCA, cmd); 671 + 672 + return readx_poll_timeout(IXGBE_HW_READ_REG, IXGBE_MSCA, cmd, 673 + !(cmd & IXGBE_MSCA_MDI_COMMAND), 10, 674 + 10 * IXGBE_MDIO_COMMAND_TIMEOUT); 675 + } 676 + 677 + /** 678 + * ixgbe_mii_bus_read_generic - Read a clause 22/45 register with gssr flags 679 + * @hw: pointer to hardware structure 680 + * @addr: address 681 + * @regnum: register number 682 + * @gssr: semaphore flags to acquire 683 + **/ 684 + static s32 ixgbe_mii_bus_read_generic(struct ixgbe_hw *hw, int addr, 685 + int regnum, u32 gssr) 686 + { 687 + u32 hwaddr, cmd; 688 + s32 data; 689 + 690 + if (hw->mac.ops.acquire_swfw_sync(hw, gssr)) 691 + return -EBUSY; 692 + 693 + hwaddr = addr << IXGBE_MSCA_PHY_ADDR_SHIFT; 694 + if (regnum & MII_ADDR_C45) { 695 + hwaddr |= regnum & GENMASK(21, 0); 696 + cmd = hwaddr | IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND; 697 + } else { 698 + hwaddr |= (regnum & GENMASK(5, 0)) << IXGBE_MSCA_DEV_TYPE_SHIFT; 699 + cmd = hwaddr | IXGBE_MSCA_OLD_PROTOCOL | 700 + IXGBE_MSCA_READ_AUTOINC | IXGBE_MSCA_MDI_COMMAND; 701 + } 702 + 703 + data = ixgbe_msca_cmd(hw, cmd); 704 + if (data < 0) 705 + goto mii_bus_read_done; 706 + 707 + /* For a clause 45 access the address cycle just completed, we still 708 + * need to do the read command, otherwise just get the data 709 + */ 710 + if (!(regnum & MII_ADDR_C45)) 711 + goto do_mii_bus_read; 712 + 713 + cmd = hwaddr | IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND; 714 + data = ixgbe_msca_cmd(hw, cmd); 715 + if (data < 0) 716 + goto mii_bus_read_done; 717 + 718 + do_mii_bus_read: 719 + data = IXGBE_READ_REG(hw, IXGBE_MSRWD); 720 + data = (data >> IXGBE_MSRWD_READ_DATA_SHIFT) & GENMASK(16, 0); 721 + 722 + mii_bus_read_done: 723 + hw->mac.ops.release_swfw_sync(hw, gssr); 724 + return data; 725 + } 726 + 727 + /** 728 + * ixgbe_mii_bus_write_generic - Write a clause 22/45 register with gssr flags 729 + * @hw: pointer to hardware structure 730 + * @addr: address 731 + * @regnum: register number 732 + * @val: value to write 733 + * @gssr: semaphore flags to acquire 734 + **/ 735 + static s32 ixgbe_mii_bus_write_generic(struct ixgbe_hw *hw, int addr, 736 + int regnum, u16 val, u32 gssr) 737 + { 738 + u32 hwaddr, cmd; 739 + s32 err; 740 + 741 + if (hw->mac.ops.acquire_swfw_sync(hw, gssr)) 742 + return -EBUSY; 743 + 744 + IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)val); 745 + 746 + hwaddr = addr << IXGBE_MSCA_PHY_ADDR_SHIFT; 747 + if (regnum & MII_ADDR_C45) { 748 + hwaddr |= regnum & GENMASK(21, 0); 749 + cmd = hwaddr | IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND; 750 + } else { 751 + hwaddr |= (regnum & GENMASK(5, 0)) << IXGBE_MSCA_DEV_TYPE_SHIFT; 752 + cmd = hwaddr | IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_WRITE | 753 + IXGBE_MSCA_MDI_COMMAND; 754 + } 755 + 756 + /* For clause 45 this is an address cycle, for clause 22 this is the 757 + * entire transaction 758 + */ 759 + err = ixgbe_msca_cmd(hw, cmd); 760 + if (err < 0 || !(regnum & MII_ADDR_C45)) 761 + goto mii_bus_write_done; 762 + 763 + cmd = hwaddr | IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND; 764 + err = ixgbe_msca_cmd(hw, cmd); 765 + 766 + mii_bus_write_done: 767 + hw->mac.ops.release_swfw_sync(hw, gssr); 768 + return err; 769 + } 770 + 771 + /** 772 + * ixgbe_mii_bus_read - Read a clause 22/45 register 773 + * @hw: pointer to hardware structure 774 + * @addr: address 775 + * @regnum: register number 776 + **/ 777 + static s32 ixgbe_mii_bus_read(struct mii_bus *bus, int addr, int regnum) 778 + { 779 + struct ixgbe_adapter *adapter = bus->priv; 780 + struct ixgbe_hw *hw = &adapter->hw; 781 + u32 gssr = hw->phy.phy_semaphore_mask; 782 + 783 + return ixgbe_mii_bus_read_generic(hw, addr, regnum, gssr); 784 + } 785 + 786 + /** 787 + * ixgbe_mii_bus_write - Write a clause 22/45 register 788 + * @hw: pointer to hardware structure 789 + * @addr: address 790 + * @regnum: register number 791 + * @val: value to write 792 + **/ 793 + static s32 ixgbe_mii_bus_write(struct mii_bus *bus, int addr, int regnum, 794 + u16 val) 795 + { 796 + struct ixgbe_adapter *adapter = bus->priv; 797 + struct ixgbe_hw *hw = &adapter->hw; 798 + u32 gssr = hw->phy.phy_semaphore_mask; 799 + 800 + return ixgbe_mii_bus_write_generic(hw, addr, regnum, val, gssr); 801 + } 802 + 803 + /** 804 + * ixgbe_x550em_a_mii_bus_read - Read a clause 22/45 register on x550em_a 805 + * @hw: pointer to hardware structure 806 + * @addr: address 807 + * @regnum: register number 808 + **/ 809 + static s32 ixgbe_x550em_a_mii_bus_read(struct mii_bus *bus, int addr, 810 + int regnum) 811 + { 812 + struct ixgbe_adapter *adapter = bus->priv; 813 + struct ixgbe_hw *hw = &adapter->hw; 814 + u32 gssr = hw->phy.phy_semaphore_mask; 815 + 816 + gssr |= IXGBE_GSSR_TOKEN_SM | IXGBE_GSSR_PHY0_SM; 817 + return ixgbe_mii_bus_read_generic(hw, addr, regnum, gssr); 818 + } 819 + 820 + /** 821 + * ixgbe_x550em_a_mii_bus_write - Write a clause 22/45 register on x550em_a 822 + * @hw: pointer to hardware structure 823 + * @addr: address 824 + * @regnum: register number 825 + * @val: value to write 826 + **/ 827 + static s32 ixgbe_x550em_a_mii_bus_write(struct mii_bus *bus, int addr, 828 + int regnum, u16 val) 829 + { 830 + struct ixgbe_adapter *adapter = bus->priv; 831 + struct ixgbe_hw *hw = &adapter->hw; 832 + u32 gssr = hw->phy.phy_semaphore_mask; 833 + 834 + gssr |= IXGBE_GSSR_TOKEN_SM | IXGBE_GSSR_PHY0_SM; 835 + return ixgbe_mii_bus_write_generic(hw, addr, regnum, val, gssr); 836 + } 837 + 838 + /** 839 + * ixgbe_get_first_secondary_devfn - get first device downstream of root port 840 + * @devfn: PCI_DEVFN of root port on domain 0, bus 0 841 + * 842 + * Returns pci_dev pointer to PCI_DEVFN(0, 0) on subordinate side of root 843 + * on domain 0, bus 0, devfn = 'devfn' 844 + **/ 845 + static struct pci_dev *ixgbe_get_first_secondary_devfn(unsigned int devfn) 846 + { 847 + struct pci_dev *rp_pdev; 848 + int bus; 849 + 850 + rp_pdev = pci_get_domain_bus_and_slot(0, 0, devfn); 851 + if (rp_pdev && rp_pdev->subordinate) { 852 + bus = rp_pdev->subordinate->number; 853 + return pci_get_domain_bus_and_slot(0, bus, 0); 854 + } 855 + 856 + return NULL; 857 + } 858 + 859 + /** 860 + * ixgbe_x550em_a_has_mii - is this the first ixgbe x550em_a PCI function? 861 + * @hw: pointer to hardware structure 862 + * 863 + * Returns true if hw points to lowest numbered PCI B:D.F x550_em_a device in 864 + * the SoC. There are up to 4 MACs sharing a single MDIO bus on the x550em_a, 865 + * but we only want to register one MDIO bus. 866 + **/ 867 + static bool ixgbe_x550em_a_has_mii(struct ixgbe_hw *hw) 868 + { 869 + struct ixgbe_adapter *adapter = hw->back; 870 + struct pci_dev *pdev = adapter->pdev; 871 + struct pci_dev *func0_pdev; 872 + 873 + /* For the C3000 family of SoCs (x550em_a) the internal ixgbe devices 874 + * are always downstream of root ports @ 0000:00:16.0 & 0000:00:17.0 875 + * It's not valid for function 0 to be disabled and function 1 is up, 876 + * so the lowest numbered ixgbe dev will be device 0 function 0 on one 877 + * of those two root ports 878 + */ 879 + func0_pdev = ixgbe_get_first_secondary_devfn(PCI_DEVFN(0x16, 0)); 880 + if (func0_pdev) { 881 + if (func0_pdev == pdev) 882 + return true; 883 + else 884 + return false; 885 + } 886 + func0_pdev = ixgbe_get_first_secondary_devfn(PCI_DEVFN(0x17, 0)); 887 + if (func0_pdev == pdev) 888 + return true; 889 + 890 + return false; 891 + } 892 + 893 + /** 894 + * ixgbe_mii_bus_init - mii_bus structure setup 895 + * @hw: pointer to hardware structure 896 + * 897 + * Returns 0 on success, negative on failure 898 + * 899 + * ixgbe_mii_bus_init initializes a mii_bus structure in adapter 900 + **/ 901 + s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw) 902 + { 903 + struct ixgbe_adapter *adapter = hw->back; 904 + struct pci_dev *pdev = adapter->pdev; 905 + struct device *dev = &adapter->netdev->dev; 906 + struct mii_bus *bus; 907 + 908 + adapter->mii_bus = devm_mdiobus_alloc(dev); 909 + if (!adapter->mii_bus) 910 + return -ENOMEM; 911 + 912 + bus = adapter->mii_bus; 913 + 914 + switch (hw->device_id) { 915 + /* C3000 SoCs */ 916 + case IXGBE_DEV_ID_X550EM_A_KR: 917 + case IXGBE_DEV_ID_X550EM_A_KR_L: 918 + case IXGBE_DEV_ID_X550EM_A_SFP_N: 919 + case IXGBE_DEV_ID_X550EM_A_SGMII: 920 + case IXGBE_DEV_ID_X550EM_A_SGMII_L: 921 + case IXGBE_DEV_ID_X550EM_A_10G_T: 922 + case IXGBE_DEV_ID_X550EM_A_SFP: 923 + case IXGBE_DEV_ID_X550EM_A_1G_T: 924 + case IXGBE_DEV_ID_X550EM_A_1G_T_L: 925 + if (!ixgbe_x550em_a_has_mii(hw)) 926 + goto ixgbe_no_mii_bus; 927 + bus->read = &ixgbe_x550em_a_mii_bus_read; 928 + bus->write = &ixgbe_x550em_a_mii_bus_write; 929 + break; 930 + default: 931 + bus->read = &ixgbe_mii_bus_read; 932 + bus->write = &ixgbe_mii_bus_write; 933 + break; 934 + } 935 + 936 + /* Use the position of the device in the PCI hierarchy as the id */ 937 + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mdio-%s", ixgbe_driver_name, 938 + pci_name(pdev)); 939 + 940 + bus->name = "ixgbe-mdio"; 941 + bus->priv = adapter; 942 + bus->parent = dev; 943 + bus->phy_mask = GENMASK(31, 0); 944 + 945 + /* Support clause 22/45 natively. ixgbe_probe() sets MDIO_EMULATE_C22 946 + * unfortunately that causes some clause 22 frames to be sent with 947 + * clause 45 addressing. We don't want that. 948 + */ 949 + hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22; 950 + 951 + return mdiobus_register(bus); 952 + 953 + ixgbe_no_mii_bus: 954 + devm_mdiobus_free(dev, bus); 955 + adapter->mii_bus = NULL; 956 + return -ENODEV; 660 957 } 661 958 662 959 /**
+2
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
··· 120 120 /* SFP+ SFF-8472 Compliance code */ 121 121 #define IXGBE_SFF_SFF_8472_UNSUP 0x00 122 122 123 + s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw); 124 + 123 125 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw); 124 126 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw); 125 127 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,