| .. | .. |
|---|
| 1 | | -/** |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 2 | +/* |
|---|
| 2 | 3 | * drivers/net/ethernet/micrel/ksx884x.c - Micrel KSZ8841/2 PCI Ethernet driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2009-2010 Micrel, Inc. |
|---|
| 5 | 6 | * Tristram Ha <Tristram.Ha@micrel.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 9 | | - * published by the Free Software Foundation. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | 7 | */ |
|---|
| 16 | 8 | |
|---|
| 17 | 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 967 | 959 | * struct ksz_dma_buf - OS dependent DMA buffer data structure |
|---|
| 968 | 960 | * @skb: Associated socket buffer. |
|---|
| 969 | 961 | * @dma: Associated physical DMA address. |
|---|
| 970 | | - * len: Actual len used. |
|---|
| 962 | + * @len: Actual len used. |
|---|
| 971 | 963 | */ |
|---|
| 972 | 964 | struct ksz_dma_buf { |
|---|
| 973 | 965 | struct sk_buff *skb; |
|---|
| .. | .. |
|---|
| 1262 | 1254 | * @multi_list_size: Multicast address list size. |
|---|
| 1263 | 1255 | * @enabled: Indication of hardware enabled. |
|---|
| 1264 | 1256 | * @rx_stop: Indication of receive process stop. |
|---|
| 1257 | + * @reserved2: none |
|---|
| 1265 | 1258 | * @features: Hardware features to enable. |
|---|
| 1266 | 1259 | * @overrides: Hardware features to override. |
|---|
| 1267 | 1260 | * @parent: Pointer to parent, network device private structure. |
|---|
| .. | .. |
|---|
| 1455 | 1448 | * struct dev_priv - Network device private data structure |
|---|
| 1456 | 1449 | * @adapter: Adapter device information. |
|---|
| 1457 | 1450 | * @port: Port information. |
|---|
| 1458 | | - * @monitor_time_info: Timer to monitor ports. |
|---|
| 1451 | + * @monitor_timer_info: Timer to monitor ports. |
|---|
| 1459 | 1452 | * @proc_sem: Semaphore for proc accessing. |
|---|
| 1460 | 1453 | * @id: Device ID. |
|---|
| 1461 | 1454 | * @mii_if: MII interface information. |
|---|
| .. | .. |
|---|
| 1574 | 1567 | |
|---|
| 1575 | 1568 | /** |
|---|
| 1576 | 1569 | * hw_block_intr - block hardware interrupts |
|---|
| 1570 | + * @hw: The hardware instance. |
|---|
| 1577 | 1571 | * |
|---|
| 1578 | 1572 | * This function blocks all interrupts of the hardware and returns the current |
|---|
| 1579 | 1573 | * interrupt enable mask so that interrupts can be restored later. |
|---|
| .. | .. |
|---|
| 1826 | 1820 | * port_r_mib_pkt - read dropped packet counts |
|---|
| 1827 | 1821 | * @hw: The hardware instance. |
|---|
| 1828 | 1822 | * @port: The port index. |
|---|
| 1823 | + * @last: last one |
|---|
| 1829 | 1824 | * @cnt: Buffer to store the receive and transmit dropped packet counts. |
|---|
| 1830 | 1825 | * |
|---|
| 1831 | 1826 | * This routine reads the dropped packet counts of the port. |
|---|
| .. | .. |
|---|
| 1979 | 1974 | * port_chk_shift - check port bit |
|---|
| 1980 | 1975 | * @hw: The hardware instance. |
|---|
| 1981 | 1976 | * @port: The port index. |
|---|
| 1982 | | - * @offset: The offset of the register. |
|---|
| 1977 | + * @addr: The offset of the register. |
|---|
| 1983 | 1978 | * @shift: Number of bits to shift. |
|---|
| 1984 | 1979 | * |
|---|
| 1985 | 1980 | * This function checks whether the specified port is set in the register or |
|---|
| .. | .. |
|---|
| 2001 | 1996 | * port_cfg_shift - set port bit |
|---|
| 2002 | 1997 | * @hw: The hardware instance. |
|---|
| 2003 | 1998 | * @port: The port index. |
|---|
| 2004 | | - * @offset: The offset of the register. |
|---|
| 1999 | + * @addr: The offset of the register. |
|---|
| 2005 | 2000 | * @shift: Number of bits to shift. |
|---|
| 2006 | 2001 | * @set: The flag indicating whether the port is to be set or not. |
|---|
| 2007 | 2002 | * |
|---|
| .. | .. |
|---|
| 2173 | 2168 | num = (data & BROADCAST_STORM_RATE_HI); |
|---|
| 2174 | 2169 | num <<= 8; |
|---|
| 2175 | 2170 | num |= (data & BROADCAST_STORM_RATE_LO) >> 8; |
|---|
| 2176 | | - num = (num * 100 + BROADCAST_STORM_VALUE / 2) / BROADCAST_STORM_VALUE; |
|---|
| 2171 | + num = DIV_ROUND_CLOSEST(num * 100, BROADCAST_STORM_VALUE); |
|---|
| 2177 | 2172 | *percent = (u8) num; |
|---|
| 2178 | 2173 | } |
|---|
| 2179 | 2174 | |
|---|
| .. | .. |
|---|
| 4397 | 4392 | DESC_ALIGNMENT; |
|---|
| 4398 | 4393 | |
|---|
| 4399 | 4394 | adapter->desc_pool.alloc_virt = |
|---|
| 4400 | | - pci_zalloc_consistent(adapter->pdev, |
|---|
| 4401 | | - adapter->desc_pool.alloc_size, |
|---|
| 4402 | | - &adapter->desc_pool.dma_addr); |
|---|
| 4395 | + dma_alloc_coherent(&adapter->pdev->dev, |
|---|
| 4396 | + adapter->desc_pool.alloc_size, |
|---|
| 4397 | + &adapter->desc_pool.dma_addr, GFP_KERNEL); |
|---|
| 4403 | 4398 | if (adapter->desc_pool.alloc_virt == NULL) { |
|---|
| 4404 | 4399 | adapter->desc_pool.alloc_size = 0; |
|---|
| 4405 | 4400 | return 1; |
|---|
| .. | .. |
|---|
| 4432 | 4427 | /** |
|---|
| 4433 | 4428 | * free_dma_buf - release DMA buffer resources |
|---|
| 4434 | 4429 | * @adapter: Adapter information structure. |
|---|
| 4430 | + * @dma_buf: pointer to buf |
|---|
| 4431 | + * @direction: to or from device |
|---|
| 4435 | 4432 | * |
|---|
| 4436 | 4433 | * This routine is just a helper function to release the DMA buffer resources. |
|---|
| 4437 | 4434 | */ |
|---|
| 4438 | 4435 | static void free_dma_buf(struct dev_info *adapter, struct ksz_dma_buf *dma_buf, |
|---|
| 4439 | 4436 | int direction) |
|---|
| 4440 | 4437 | { |
|---|
| 4441 | | - pci_unmap_single(adapter->pdev, dma_buf->dma, dma_buf->len, direction); |
|---|
| 4438 | + dma_unmap_single(&adapter->pdev->dev, dma_buf->dma, dma_buf->len, |
|---|
| 4439 | + direction); |
|---|
| 4442 | 4440 | dev_kfree_skb(dma_buf->skb); |
|---|
| 4443 | 4441 | dma_buf->skb = NULL; |
|---|
| 4444 | 4442 | dma_buf->dma = 0; |
|---|
| .. | .. |
|---|
| 4463 | 4461 | |
|---|
| 4464 | 4462 | dma_buf = DMA_BUFFER(desc); |
|---|
| 4465 | 4463 | if (dma_buf->skb && dma_buf->len != adapter->mtu) |
|---|
| 4466 | | - free_dma_buf(adapter, dma_buf, PCI_DMA_FROMDEVICE); |
|---|
| 4464 | + free_dma_buf(adapter, dma_buf, DMA_FROM_DEVICE); |
|---|
| 4467 | 4465 | dma_buf->len = adapter->mtu; |
|---|
| 4468 | 4466 | if (!dma_buf->skb) |
|---|
| 4469 | 4467 | dma_buf->skb = alloc_skb(dma_buf->len, GFP_ATOMIC); |
|---|
| 4470 | 4468 | if (dma_buf->skb && !dma_buf->dma) |
|---|
| 4471 | | - dma_buf->dma = pci_map_single( |
|---|
| 4472 | | - adapter->pdev, |
|---|
| 4473 | | - skb_tail_pointer(dma_buf->skb), |
|---|
| 4474 | | - dma_buf->len, |
|---|
| 4475 | | - PCI_DMA_FROMDEVICE); |
|---|
| 4469 | + dma_buf->dma = dma_map_single(&adapter->pdev->dev, |
|---|
| 4470 | + skb_tail_pointer(dma_buf->skb), |
|---|
| 4471 | + dma_buf->len, |
|---|
| 4472 | + DMA_FROM_DEVICE); |
|---|
| 4476 | 4473 | |
|---|
| 4477 | 4474 | /* Set descriptor. */ |
|---|
| 4478 | 4475 | set_rx_buf(desc, dma_buf->dma); |
|---|
| .. | .. |
|---|
| 4550 | 4547 | |
|---|
| 4551 | 4548 | /* Free memory. */ |
|---|
| 4552 | 4549 | if (adapter->desc_pool.alloc_virt) |
|---|
| 4553 | | - pci_free_consistent( |
|---|
| 4554 | | - adapter->pdev, |
|---|
| 4555 | | - adapter->desc_pool.alloc_size, |
|---|
| 4556 | | - adapter->desc_pool.alloc_virt, |
|---|
| 4557 | | - adapter->desc_pool.dma_addr); |
|---|
| 4550 | + dma_free_coherent(&adapter->pdev->dev, |
|---|
| 4551 | + adapter->desc_pool.alloc_size, |
|---|
| 4552 | + adapter->desc_pool.alloc_virt, |
|---|
| 4553 | + adapter->desc_pool.dma_addr); |
|---|
| 4558 | 4554 | |
|---|
| 4559 | 4555 | /* Reset resource pool. */ |
|---|
| 4560 | 4556 | adapter->desc_pool.alloc_size = 0; |
|---|
| .. | .. |
|---|
| 4570 | 4566 | * ksz_free_buffers - free buffers used in the descriptors |
|---|
| 4571 | 4567 | * @adapter: Adapter information structure. |
|---|
| 4572 | 4568 | * @desc_info: Descriptor information structure. |
|---|
| 4569 | + * @direction: to or from device |
|---|
| 4573 | 4570 | * |
|---|
| 4574 | 4571 | * This local routine frees buffers used in the DMA buffers. |
|---|
| 4575 | 4572 | */ |
|---|
| .. | .. |
|---|
| 4597 | 4594 | static void ksz_free_mem(struct dev_info *adapter) |
|---|
| 4598 | 4595 | { |
|---|
| 4599 | 4596 | /* Free transmit buffers. */ |
|---|
| 4600 | | - ksz_free_buffers(adapter, &adapter->hw.tx_desc_info, |
|---|
| 4601 | | - PCI_DMA_TODEVICE); |
|---|
| 4597 | + ksz_free_buffers(adapter, &adapter->hw.tx_desc_info, DMA_TO_DEVICE); |
|---|
| 4602 | 4598 | |
|---|
| 4603 | 4599 | /* Free receive buffers. */ |
|---|
| 4604 | | - ksz_free_buffers(adapter, &adapter->hw.rx_desc_info, |
|---|
| 4605 | | - PCI_DMA_FROMDEVICE); |
|---|
| 4600 | + ksz_free_buffers(adapter, &adapter->hw.rx_desc_info, DMA_FROM_DEVICE); |
|---|
| 4606 | 4601 | |
|---|
| 4607 | 4602 | /* Free descriptors. */ |
|---|
| 4608 | 4603 | ksz_free_desc(adapter); |
|---|
| .. | .. |
|---|
| 4664 | 4659 | |
|---|
| 4665 | 4660 | dma_buf->len = skb_headlen(skb); |
|---|
| 4666 | 4661 | |
|---|
| 4667 | | - dma_buf->dma = pci_map_single( |
|---|
| 4668 | | - hw_priv->pdev, skb->data, dma_buf->len, |
|---|
| 4669 | | - PCI_DMA_TODEVICE); |
|---|
| 4662 | + dma_buf->dma = dma_map_single(&hw_priv->pdev->dev, skb->data, |
|---|
| 4663 | + dma_buf->len, DMA_TO_DEVICE); |
|---|
| 4670 | 4664 | set_tx_buf(desc, dma_buf->dma); |
|---|
| 4671 | 4665 | set_tx_len(desc, dma_buf->len); |
|---|
| 4672 | 4666 | |
|---|
| .. | .. |
|---|
| 4683 | 4677 | dma_buf = DMA_BUFFER(desc); |
|---|
| 4684 | 4678 | dma_buf->len = skb_frag_size(this_frag); |
|---|
| 4685 | 4679 | |
|---|
| 4686 | | - dma_buf->dma = pci_map_single( |
|---|
| 4687 | | - hw_priv->pdev, |
|---|
| 4688 | | - skb_frag_address(this_frag), |
|---|
| 4689 | | - dma_buf->len, |
|---|
| 4690 | | - PCI_DMA_TODEVICE); |
|---|
| 4680 | + dma_buf->dma = dma_map_single(&hw_priv->pdev->dev, |
|---|
| 4681 | + skb_frag_address(this_frag), |
|---|
| 4682 | + dma_buf->len, |
|---|
| 4683 | + DMA_TO_DEVICE); |
|---|
| 4691 | 4684 | set_tx_buf(desc, dma_buf->dma); |
|---|
| 4692 | 4685 | set_tx_len(desc, dma_buf->len); |
|---|
| 4693 | 4686 | |
|---|
| .. | .. |
|---|
| 4707 | 4700 | } else { |
|---|
| 4708 | 4701 | dma_buf->len = len; |
|---|
| 4709 | 4702 | |
|---|
| 4710 | | - dma_buf->dma = pci_map_single( |
|---|
| 4711 | | - hw_priv->pdev, skb->data, dma_buf->len, |
|---|
| 4712 | | - PCI_DMA_TODEVICE); |
|---|
| 4703 | + dma_buf->dma = dma_map_single(&hw_priv->pdev->dev, skb->data, |
|---|
| 4704 | + dma_buf->len, DMA_TO_DEVICE); |
|---|
| 4713 | 4705 | set_tx_buf(desc, dma_buf->dma); |
|---|
| 4714 | 4706 | set_tx_len(desc, dma_buf->len); |
|---|
| 4715 | 4707 | } |
|---|
| .. | .. |
|---|
| 4734 | 4726 | |
|---|
| 4735 | 4727 | /** |
|---|
| 4736 | 4728 | * transmit_cleanup - clean up transmit descriptors |
|---|
| 4737 | | - * @dev: Network device. |
|---|
| 4729 | + * @hw_priv: Network device. |
|---|
| 4730 | + * @normal: break if owned |
|---|
| 4738 | 4731 | * |
|---|
| 4739 | 4732 | * This routine is called to clean up the transmitted buffers. |
|---|
| 4740 | 4733 | */ |
|---|
| .. | .. |
|---|
| 4763 | 4756 | } |
|---|
| 4764 | 4757 | |
|---|
| 4765 | 4758 | dma_buf = DMA_BUFFER(desc); |
|---|
| 4766 | | - pci_unmap_single( |
|---|
| 4767 | | - hw_priv->pdev, dma_buf->dma, dma_buf->len, |
|---|
| 4768 | | - PCI_DMA_TODEVICE); |
|---|
| 4759 | + dma_unmap_single(&hw_priv->pdev->dev, dma_buf->dma, |
|---|
| 4760 | + dma_buf->len, DMA_TO_DEVICE); |
|---|
| 4769 | 4761 | |
|---|
| 4770 | 4762 | /* This descriptor contains the last buffer in the packet. */ |
|---|
| 4771 | 4763 | if (dma_buf->skb) { |
|---|
| .. | .. |
|---|
| 4791 | 4783 | |
|---|
| 4792 | 4784 | /** |
|---|
| 4793 | 4785 | * transmit_done - transmit done processing |
|---|
| 4794 | | - * @dev: Network device. |
|---|
| 4786 | + * @hw_priv: Network device. |
|---|
| 4795 | 4787 | * |
|---|
| 4796 | 4788 | * This routine is called when the transmit interrupt is triggered, indicating |
|---|
| 4797 | 4789 | * either a packet is sent successfully or there are transmit errors. |
|---|
| .. | .. |
|---|
| 4897 | 4889 | /** |
|---|
| 4898 | 4890 | * netdev_tx_timeout - transmit timeout processing |
|---|
| 4899 | 4891 | * @dev: Network device. |
|---|
| 4892 | + * @txqueue: index of hanging queue |
|---|
| 4900 | 4893 | * |
|---|
| 4901 | 4894 | * This routine is called when the transmit timer expires. That indicates the |
|---|
| 4902 | 4895 | * hardware is not running correctly because transmit interrupts are not |
|---|
| 4903 | 4896 | * triggered to free up resources so that the transmit routine can continue |
|---|
| 4904 | 4897 | * sending out packets. The hardware is reset to correct the problem. |
|---|
| 4905 | 4898 | */ |
|---|
| 4906 | | -static void netdev_tx_timeout(struct net_device *dev) |
|---|
| 4899 | +static void netdev_tx_timeout(struct net_device *dev, unsigned int txqueue) |
|---|
| 4907 | 4900 | { |
|---|
| 4908 | 4901 | static unsigned long last_reset; |
|---|
| 4909 | 4902 | |
|---|
| .. | .. |
|---|
| 4992 | 4985 | struct dev_info *hw_priv = priv->adapter; |
|---|
| 4993 | 4986 | struct ksz_dma_buf *dma_buf; |
|---|
| 4994 | 4987 | struct sk_buff *skb; |
|---|
| 4995 | | - int rx_status; |
|---|
| 4996 | 4988 | |
|---|
| 4997 | 4989 | /* Received length includes 4-byte CRC. */ |
|---|
| 4998 | 4990 | packet_len = status.rx.frame_len - 4; |
|---|
| 4999 | 4991 | |
|---|
| 5000 | 4992 | dma_buf = DMA_BUFFER(desc); |
|---|
| 5001 | | - pci_dma_sync_single_for_cpu( |
|---|
| 5002 | | - hw_priv->pdev, dma_buf->dma, packet_len + 4, |
|---|
| 5003 | | - PCI_DMA_FROMDEVICE); |
|---|
| 4993 | + dma_sync_single_for_cpu(&hw_priv->pdev->dev, dma_buf->dma, |
|---|
| 4994 | + packet_len + 4, DMA_FROM_DEVICE); |
|---|
| 5004 | 4995 | |
|---|
| 5005 | 4996 | do { |
|---|
| 5006 | 4997 | /* skb->data != skb->head */ |
|---|
| .. | .. |
|---|
| 5029 | 5020 | dev->stats.rx_bytes += packet_len; |
|---|
| 5030 | 5021 | |
|---|
| 5031 | 5022 | /* Notify upper layer for received packet. */ |
|---|
| 5032 | | - rx_status = netif_rx(skb); |
|---|
| 5023 | + netif_rx(skb); |
|---|
| 5033 | 5024 | |
|---|
| 5034 | 5025 | return 0; |
|---|
| 5035 | 5026 | } |
|---|
| .. | .. |
|---|
| 5174 | 5165 | return received; |
|---|
| 5175 | 5166 | } |
|---|
| 5176 | 5167 | |
|---|
| 5177 | | -static void rx_proc_task(unsigned long data) |
|---|
| 5168 | +static void rx_proc_task(struct tasklet_struct *t) |
|---|
| 5178 | 5169 | { |
|---|
| 5179 | | - struct dev_info *hw_priv = (struct dev_info *) data; |
|---|
| 5170 | + struct dev_info *hw_priv = from_tasklet(hw_priv, t, rx_tasklet); |
|---|
| 5180 | 5171 | struct ksz_hw *hw = &hw_priv->hw; |
|---|
| 5181 | 5172 | |
|---|
| 5182 | 5173 | if (!hw->enabled) |
|---|
| .. | .. |
|---|
| 5196 | 5187 | } |
|---|
| 5197 | 5188 | } |
|---|
| 5198 | 5189 | |
|---|
| 5199 | | -static void tx_proc_task(unsigned long data) |
|---|
| 5190 | +static void tx_proc_task(struct tasklet_struct *t) |
|---|
| 5200 | 5191 | { |
|---|
| 5201 | | - struct dev_info *hw_priv = (struct dev_info *) data; |
|---|
| 5192 | + struct dev_info *hw_priv = from_tasklet(hw_priv, t, tx_tasklet); |
|---|
| 5202 | 5193 | struct ksz_hw *hw = &hw_priv->hw; |
|---|
| 5203 | 5194 | |
|---|
| 5204 | 5195 | hw_ack_intr(hw, KS884X_INT_TX_MASK); |
|---|
| .. | .. |
|---|
| 5451 | 5442 | rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev); |
|---|
| 5452 | 5443 | if (rc) |
|---|
| 5453 | 5444 | return rc; |
|---|
| 5454 | | - tasklet_init(&hw_priv->rx_tasklet, rx_proc_task, |
|---|
| 5455 | | - (unsigned long) hw_priv); |
|---|
| 5456 | | - tasklet_init(&hw_priv->tx_tasklet, tx_proc_task, |
|---|
| 5457 | | - (unsigned long) hw_priv); |
|---|
| 5445 | + tasklet_setup(&hw_priv->rx_tasklet, rx_proc_task); |
|---|
| 5446 | + tasklet_setup(&hw_priv->tx_tasklet, tx_proc_task); |
|---|
| 5458 | 5447 | |
|---|
| 5459 | 5448 | hw->promiscuous = 0; |
|---|
| 5460 | 5449 | hw->all_multi = 0; |
|---|
| .. | .. |
|---|
| 5701 | 5690 | * from the bridge. |
|---|
| 5702 | 5691 | */ |
|---|
| 5703 | 5692 | if ((hw->features & STP_SUPPORT) && !promiscuous && |
|---|
| 5704 | | - (dev->priv_flags & IFF_BRIDGE_PORT)) { |
|---|
| 5693 | + netif_is_bridge_port(dev)) { |
|---|
| 5705 | 5694 | struct ksz_switch *sw = hw->ksz_switch; |
|---|
| 5706 | 5695 | int port = priv->port.first_port; |
|---|
| 5707 | 5696 | |
|---|
| .. | .. |
|---|
| 5844 | 5833 | /* Get address of MII PHY in use. */ |
|---|
| 5845 | 5834 | case SIOCGMIIPHY: |
|---|
| 5846 | 5835 | data->phy_id = priv->id; |
|---|
| 5847 | | - |
|---|
| 5848 | | - /* Fallthrough... */ |
|---|
| 5836 | + fallthrough; |
|---|
| 5849 | 5837 | |
|---|
| 5850 | 5838 | /* Read MII PHY register. */ |
|---|
| 5851 | 5839 | case SIOCGMIIREG: |
|---|
| .. | .. |
|---|
| 6093 | 6081 | sizeof(info->bus_info)); |
|---|
| 6094 | 6082 | } |
|---|
| 6095 | 6083 | |
|---|
| 6096 | | -/** |
|---|
| 6097 | | - * netdev_get_regs_len - get length of register dump |
|---|
| 6098 | | - * @dev: Network device. |
|---|
| 6099 | | - * |
|---|
| 6100 | | - * This function returns the length of the register dump. |
|---|
| 6101 | | - * |
|---|
| 6102 | | - * Return length of the register dump. |
|---|
| 6103 | | - */ |
|---|
| 6104 | 6084 | static struct hw_regs { |
|---|
| 6105 | 6085 | int start; |
|---|
| 6106 | 6086 | int end; |
|---|
| .. | .. |
|---|
| 6114 | 6094 | { 0, 0 } |
|---|
| 6115 | 6095 | }; |
|---|
| 6116 | 6096 | |
|---|
| 6097 | +/** |
|---|
| 6098 | + * netdev_get_regs_len - get length of register dump |
|---|
| 6099 | + * @dev: Network device. |
|---|
| 6100 | + * |
|---|
| 6101 | + * This function returns the length of the register dump. |
|---|
| 6102 | + * |
|---|
| 6103 | + * Return length of the register dump. |
|---|
| 6104 | + */ |
|---|
| 6117 | 6105 | static int netdev_get_regs_len(struct net_device *dev) |
|---|
| 6118 | 6106 | { |
|---|
| 6119 | 6107 | struct hw_regs *range = hw_regs_range; |
|---|
| .. | .. |
|---|
| 6255 | 6243 | return EEPROM_SIZE * 2; |
|---|
| 6256 | 6244 | } |
|---|
| 6257 | 6245 | |
|---|
| 6246 | +#define EEPROM_MAGIC 0x10A18842 |
|---|
| 6247 | + |
|---|
| 6258 | 6248 | /** |
|---|
| 6259 | 6249 | * netdev_get_eeprom - get EEPROM data |
|---|
| 6260 | 6250 | * @dev: Network device. |
|---|
| .. | .. |
|---|
| 6265 | 6255 | * |
|---|
| 6266 | 6256 | * Return 0 if successful; otherwise an error code. |
|---|
| 6267 | 6257 | */ |
|---|
| 6268 | | -#define EEPROM_MAGIC 0x10A18842 |
|---|
| 6269 | | - |
|---|
| 6270 | 6258 | static int netdev_get_eeprom(struct net_device *dev, |
|---|
| 6271 | 6259 | struct ethtool_eeprom *eeprom, u8 *data) |
|---|
| 6272 | 6260 | { |
|---|
| .. | .. |
|---|
| 6403 | 6391 | /** |
|---|
| 6404 | 6392 | * netdev_get_ringparam - get tx/rx ring parameters |
|---|
| 6405 | 6393 | * @dev: Network device. |
|---|
| 6406 | | - * @pause: Ethtool RING settings data structure. |
|---|
| 6394 | + * @ring: Ethtool RING settings data structure. |
|---|
| 6407 | 6395 | * |
|---|
| 6408 | 6396 | * This procedure returns the TX/RX ring settings. |
|---|
| 6409 | 6397 | */ |
|---|
| .. | .. |
|---|
| 6524 | 6512 | int i; |
|---|
| 6525 | 6513 | int n; |
|---|
| 6526 | 6514 | int p; |
|---|
| 6527 | | - int rc; |
|---|
| 6528 | 6515 | u64 counter[TOTAL_PORT_COUNTER_NUM]; |
|---|
| 6529 | 6516 | |
|---|
| 6530 | 6517 | mutex_lock(&hw_priv->lock); |
|---|
| .. | .. |
|---|
| 6545 | 6532 | |
|---|
| 6546 | 6533 | if (1 == port->mib_port_cnt && n < SWITCH_PORT_NUM) { |
|---|
| 6547 | 6534 | p = n; |
|---|
| 6548 | | - rc = wait_event_interruptible_timeout( |
|---|
| 6535 | + wait_event_interruptible_timeout( |
|---|
| 6549 | 6536 | hw_priv->counter[p].counter, |
|---|
| 6550 | 6537 | 2 == hw_priv->counter[p].read, |
|---|
| 6551 | 6538 | HZ * 1); |
|---|
| 6552 | 6539 | } else |
|---|
| 6553 | 6540 | for (i = 0, p = n; i < port->mib_port_cnt - n; i++, p++) { |
|---|
| 6554 | 6541 | if (0 == i) { |
|---|
| 6555 | | - rc = wait_event_interruptible_timeout( |
|---|
| 6542 | + wait_event_interruptible_timeout( |
|---|
| 6556 | 6543 | hw_priv->counter[p].counter, |
|---|
| 6557 | 6544 | 2 == hw_priv->counter[p].read, |
|---|
| 6558 | 6545 | HZ * 2); |
|---|
| 6559 | 6546 | } else if (hw->port_mib[p].cnt_ptr) { |
|---|
| 6560 | | - rc = wait_event_interruptible_timeout( |
|---|
| 6547 | + wait_event_interruptible_timeout( |
|---|
| 6561 | 6548 | hw_priv->counter[p].counter, |
|---|
| 6562 | 6549 | 2 == hw_priv->counter[p].read, |
|---|
| 6563 | 6550 | HZ * 1); |
|---|
| .. | .. |
|---|
| 6708 | 6695 | |
|---|
| 6709 | 6696 | /** |
|---|
| 6710 | 6697 | * dev_monitor - periodic monitoring |
|---|
| 6711 | | - * @ptr: Network device pointer. |
|---|
| 6698 | + * @t: timer list containing a network device pointer. |
|---|
| 6712 | 6699 | * |
|---|
| 6713 | 6700 | * This routine is run in a kernel timer to monitor the network device. |
|---|
| 6714 | 6701 | */ |
|---|
| .. | .. |
|---|
| 6936 | 6923 | char banner[sizeof(version)]; |
|---|
| 6937 | 6924 | struct ksz_switch *sw = NULL; |
|---|
| 6938 | 6925 | |
|---|
| 6939 | | - result = pci_enable_device(pdev); |
|---|
| 6926 | + result = pcim_enable_device(pdev); |
|---|
| 6940 | 6927 | if (result) |
|---|
| 6941 | 6928 | return result; |
|---|
| 6942 | 6929 | |
|---|
| 6943 | 6930 | result = -ENODEV; |
|---|
| 6944 | 6931 | |
|---|
| 6945 | | - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) || |
|---|
| 6946 | | - pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) |
|---|
| 6932 | + if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) || |
|---|
| 6933 | + dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) |
|---|
| 6947 | 6934 | return result; |
|---|
| 6948 | 6935 | |
|---|
| 6949 | 6936 | reg_base = pci_resource_start(pdev, 0); |
|---|
| .. | .. |
|---|
| 7162 | 7149 | kfree(info); |
|---|
| 7163 | 7150 | } |
|---|
| 7164 | 7151 | |
|---|
| 7165 | | -#ifdef CONFIG_PM |
|---|
| 7166 | | -static int pcidev_resume(struct pci_dev *pdev) |
|---|
| 7152 | +static int __maybe_unused pcidev_resume(struct device *dev_d) |
|---|
| 7167 | 7153 | { |
|---|
| 7168 | 7154 | int i; |
|---|
| 7169 | | - struct platform_info *info = pci_get_drvdata(pdev); |
|---|
| 7155 | + struct platform_info *info = dev_get_drvdata(dev_d); |
|---|
| 7170 | 7156 | struct dev_info *hw_priv = &info->dev_info; |
|---|
| 7171 | 7157 | struct ksz_hw *hw = &hw_priv->hw; |
|---|
| 7172 | 7158 | |
|---|
| 7173 | | - pci_set_power_state(pdev, PCI_D0); |
|---|
| 7174 | | - pci_restore_state(pdev); |
|---|
| 7175 | | - pci_enable_wake(pdev, PCI_D0, 0); |
|---|
| 7159 | + device_wakeup_disable(dev_d); |
|---|
| 7176 | 7160 | |
|---|
| 7177 | 7161 | if (hw_priv->wol_enable) |
|---|
| 7178 | 7162 | hw_cfg_wol_pme(hw, 0); |
|---|
| .. | .. |
|---|
| 7189 | 7173 | return 0; |
|---|
| 7190 | 7174 | } |
|---|
| 7191 | 7175 | |
|---|
| 7192 | | -static int pcidev_suspend(struct pci_dev *pdev, pm_message_t state) |
|---|
| 7176 | +static int __maybe_unused pcidev_suspend(struct device *dev_d) |
|---|
| 7193 | 7177 | { |
|---|
| 7194 | 7178 | int i; |
|---|
| 7195 | | - struct platform_info *info = pci_get_drvdata(pdev); |
|---|
| 7179 | + struct platform_info *info = dev_get_drvdata(dev_d); |
|---|
| 7196 | 7180 | struct dev_info *hw_priv = &info->dev_info; |
|---|
| 7197 | 7181 | struct ksz_hw *hw = &hw_priv->hw; |
|---|
| 7198 | 7182 | |
|---|
| .. | .. |
|---|
| 7214 | 7198 | hw_cfg_wol_pme(hw, 1); |
|---|
| 7215 | 7199 | } |
|---|
| 7216 | 7200 | |
|---|
| 7217 | | - pci_save_state(pdev); |
|---|
| 7218 | | - pci_enable_wake(pdev, pci_choose_state(pdev, state), 1); |
|---|
| 7219 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
|---|
| 7201 | + device_wakeup_enable(dev_d); |
|---|
| 7220 | 7202 | return 0; |
|---|
| 7221 | 7203 | } |
|---|
| 7222 | | -#endif |
|---|
| 7223 | 7204 | |
|---|
| 7224 | 7205 | static char pcidev_name[] = "ksz884xp"; |
|---|
| 7225 | 7206 | |
|---|
| .. | .. |
|---|
| 7233 | 7214 | |
|---|
| 7234 | 7215 | MODULE_DEVICE_TABLE(pci, pcidev_table); |
|---|
| 7235 | 7216 | |
|---|
| 7217 | +static SIMPLE_DEV_PM_OPS(pcidev_pm_ops, pcidev_suspend, pcidev_resume); |
|---|
| 7218 | + |
|---|
| 7236 | 7219 | static struct pci_driver pci_device_driver = { |
|---|
| 7237 | | -#ifdef CONFIG_PM |
|---|
| 7238 | | - .suspend = pcidev_suspend, |
|---|
| 7239 | | - .resume = pcidev_resume, |
|---|
| 7240 | | -#endif |
|---|
| 7220 | + .driver.pm = &pcidev_pm_ops, |
|---|
| 7241 | 7221 | .name = pcidev_name, |
|---|
| 7242 | 7222 | .id_table = pcidev_table, |
|---|
| 7243 | 7223 | .probe = pcidev_init, |
|---|