| .. | .. |
|---|
| 367 | 367 | |
|---|
| 368 | 368 | struct RxFD { |
|---|
| 369 | 369 | struct FDesc fd; |
|---|
| 370 | | - struct BDesc bd[0]; /* variable length */ |
|---|
| 370 | + struct BDesc bd[]; /* variable length */ |
|---|
| 371 | 371 | }; |
|---|
| 372 | 372 | |
|---|
| 373 | 373 | struct FrFD { |
|---|
| .. | .. |
|---|
| 454 | 454 | skb = netdev_alloc_skb(dev, RX_BUF_SIZE); |
|---|
| 455 | 455 | if (!skb) |
|---|
| 456 | 456 | return NULL; |
|---|
| 457 | | - *dma_handle = pci_map_single(hwdev, skb->data, RX_BUF_SIZE, |
|---|
| 458 | | - PCI_DMA_FROMDEVICE); |
|---|
| 459 | | - if (pci_dma_mapping_error(hwdev, *dma_handle)) { |
|---|
| 457 | + *dma_handle = dma_map_single(&hwdev->dev, skb->data, RX_BUF_SIZE, |
|---|
| 458 | + DMA_FROM_DEVICE); |
|---|
| 459 | + if (dma_mapping_error(&hwdev->dev, *dma_handle)) { |
|---|
| 460 | 460 | dev_kfree_skb_any(skb); |
|---|
| 461 | 461 | return NULL; |
|---|
| 462 | 462 | } |
|---|
| .. | .. |
|---|
| 466 | 466 | |
|---|
| 467 | 467 | static void free_rxbuf_skb(struct pci_dev *hwdev, struct sk_buff *skb, dma_addr_t dma_handle) |
|---|
| 468 | 468 | { |
|---|
| 469 | | - pci_unmap_single(hwdev, dma_handle, RX_BUF_SIZE, |
|---|
| 470 | | - PCI_DMA_FROMDEVICE); |
|---|
| 469 | + dma_unmap_single(&hwdev->dev, dma_handle, RX_BUF_SIZE, |
|---|
| 470 | + DMA_FROM_DEVICE); |
|---|
| 471 | 471 | dev_kfree_skb_any(skb); |
|---|
| 472 | 472 | } |
|---|
| 473 | 473 | |
|---|
| .. | .. |
|---|
| 483 | 483 | static int tc35815_close(struct net_device *dev); |
|---|
| 484 | 484 | static struct net_device_stats *tc35815_get_stats(struct net_device *dev); |
|---|
| 485 | 485 | static void tc35815_set_multicast_list(struct net_device *dev); |
|---|
| 486 | | -static void tc35815_tx_timeout(struct net_device *dev); |
|---|
| 487 | | -static int tc35815_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
|---|
| 486 | +static void tc35815_tx_timeout(struct net_device *dev, unsigned int txqueue); |
|---|
| 488 | 487 | #ifdef CONFIG_NET_POLL_CONTROLLER |
|---|
| 489 | 488 | static void tc35815_poll_controller(struct net_device *dev); |
|---|
| 490 | 489 | #endif |
|---|
| .. | .. |
|---|
| 607 | 606 | |
|---|
| 608 | 607 | static int tc_mii_probe(struct net_device *dev) |
|---|
| 609 | 608 | { |
|---|
| 609 | + __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
|---|
| 610 | 610 | struct tc35815_local *lp = netdev_priv(dev); |
|---|
| 611 | 611 | struct phy_device *phydev; |
|---|
| 612 | | - u32 dropmask; |
|---|
| 613 | 612 | |
|---|
| 614 | 613 | phydev = phy_find_first(lp->mii_bus); |
|---|
| 615 | 614 | if (!phydev) { |
|---|
| .. | .. |
|---|
| 629 | 628 | phy_attached_info(phydev); |
|---|
| 630 | 629 | |
|---|
| 631 | 630 | /* mask with MAC supported features */ |
|---|
| 632 | | - phydev->supported &= PHY_BASIC_FEATURES; |
|---|
| 633 | | - dropmask = 0; |
|---|
| 634 | | - if (options.speed == 10) |
|---|
| 635 | | - dropmask |= SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full; |
|---|
| 636 | | - else if (options.speed == 100) |
|---|
| 637 | | - dropmask |= SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full; |
|---|
| 638 | | - if (options.duplex == 1) |
|---|
| 639 | | - dropmask |= SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Full; |
|---|
| 640 | | - else if (options.duplex == 2) |
|---|
| 641 | | - dropmask |= SUPPORTED_10baseT_Half | SUPPORTED_100baseT_Half; |
|---|
| 642 | | - phydev->supported &= ~dropmask; |
|---|
| 643 | | - phydev->advertising = phydev->supported; |
|---|
| 631 | + phy_set_max_speed(phydev, SPEED_100); |
|---|
| 632 | + if (options.speed == 10) { |
|---|
| 633 | + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask); |
|---|
| 634 | + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, mask); |
|---|
| 635 | + } else if (options.speed == 100) { |
|---|
| 636 | + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, mask); |
|---|
| 637 | + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, mask); |
|---|
| 638 | + } |
|---|
| 639 | + if (options.duplex == 1) { |
|---|
| 640 | + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, mask); |
|---|
| 641 | + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, mask); |
|---|
| 642 | + } else if (options.duplex == 2) { |
|---|
| 643 | + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, mask); |
|---|
| 644 | + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask); |
|---|
| 645 | + } |
|---|
| 646 | + linkmode_andnot(phydev->supported, phydev->supported, mask); |
|---|
| 647 | + linkmode_copy(phydev->advertising, phydev->supported); |
|---|
| 644 | 648 | |
|---|
| 645 | 649 | lp->link = 0; |
|---|
| 646 | 650 | lp->speed = 0; |
|---|
| .. | .. |
|---|
| 689 | 693 | * should provide a "tc35815-mac" device with a MAC address in its |
|---|
| 690 | 694 | * platform_data. |
|---|
| 691 | 695 | */ |
|---|
| 692 | | -static int tc35815_mac_match(struct device *dev, void *data) |
|---|
| 696 | +static int tc35815_mac_match(struct device *dev, const void *data) |
|---|
| 693 | 697 | { |
|---|
| 694 | 698 | struct platform_device *plat_dev = to_platform_device(dev); |
|---|
| 695 | | - struct pci_dev *pci_dev = data; |
|---|
| 699 | + const struct pci_dev *pci_dev = data; |
|---|
| 696 | 700 | unsigned int id = pci_dev->irq; |
|---|
| 697 | 701 | return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id; |
|---|
| 698 | 702 | } |
|---|
| .. | .. |
|---|
| 746 | 750 | .ndo_get_stats = tc35815_get_stats, |
|---|
| 747 | 751 | .ndo_set_rx_mode = tc35815_set_multicast_list, |
|---|
| 748 | 752 | .ndo_tx_timeout = tc35815_tx_timeout, |
|---|
| 749 | | - .ndo_do_ioctl = tc35815_ioctl, |
|---|
| 753 | + .ndo_do_ioctl = phy_do_ioctl_running, |
|---|
| 750 | 754 | .ndo_validate_addr = eth_validate_addr, |
|---|
| 751 | 755 | .ndo_set_mac_address = eth_mac_addr, |
|---|
| 752 | 756 | #ifdef CONFIG_NET_POLL_CONTROLLER |
|---|
| .. | .. |
|---|
| 872 | 876 | sizeof(struct TxFD) * TX_FD_NUM > |
|---|
| 873 | 877 | PAGE_SIZE * FD_PAGE_NUM); |
|---|
| 874 | 878 | |
|---|
| 875 | | - lp->fd_buf = pci_alloc_consistent(lp->pci_dev, |
|---|
| 876 | | - PAGE_SIZE * FD_PAGE_NUM, |
|---|
| 877 | | - &lp->fd_buf_dma); |
|---|
| 879 | + lp->fd_buf = dma_alloc_coherent(&lp->pci_dev->dev, |
|---|
| 880 | + PAGE_SIZE * FD_PAGE_NUM, |
|---|
| 881 | + &lp->fd_buf_dma, GFP_ATOMIC); |
|---|
| 878 | 882 | if (!lp->fd_buf) |
|---|
| 879 | 883 | return -ENOMEM; |
|---|
| 880 | 884 | for (i = 0; i < RX_BUF_NUM; i++) { |
|---|
| .. | .. |
|---|
| 888 | 892 | lp->rx_skbs[i].skb_dma); |
|---|
| 889 | 893 | lp->rx_skbs[i].skb = NULL; |
|---|
| 890 | 894 | } |
|---|
| 891 | | - pci_free_consistent(lp->pci_dev, |
|---|
| 892 | | - PAGE_SIZE * FD_PAGE_NUM, |
|---|
| 893 | | - lp->fd_buf, |
|---|
| 894 | | - lp->fd_buf_dma); |
|---|
| 895 | + dma_free_coherent(&lp->pci_dev->dev, |
|---|
| 896 | + PAGE_SIZE * FD_PAGE_NUM, |
|---|
| 897 | + lp->fd_buf, lp->fd_buf_dma); |
|---|
| 895 | 898 | lp->fd_buf = NULL; |
|---|
| 896 | 899 | return -ENOMEM; |
|---|
| 897 | 900 | } |
|---|
| .. | .. |
|---|
| 986 | 989 | BUG_ON(lp->tx_skbs[i].skb != skb); |
|---|
| 987 | 990 | #endif |
|---|
| 988 | 991 | if (skb) { |
|---|
| 989 | | - pci_unmap_single(lp->pci_dev, lp->tx_skbs[i].skb_dma, skb->len, PCI_DMA_TODEVICE); |
|---|
| 992 | + dma_unmap_single(&lp->pci_dev->dev, |
|---|
| 993 | + lp->tx_skbs[i].skb_dma, skb->len, |
|---|
| 994 | + DMA_TO_DEVICE); |
|---|
| 990 | 995 | lp->tx_skbs[i].skb = NULL; |
|---|
| 991 | 996 | lp->tx_skbs[i].skb_dma = 0; |
|---|
| 992 | 997 | dev_kfree_skb_any(skb); |
|---|
| .. | .. |
|---|
| 1018 | 1023 | BUG_ON(lp->tx_skbs[i].skb != skb); |
|---|
| 1019 | 1024 | #endif |
|---|
| 1020 | 1025 | if (skb) { |
|---|
| 1021 | | - pci_unmap_single(lp->pci_dev, lp->tx_skbs[i].skb_dma, skb->len, PCI_DMA_TODEVICE); |
|---|
| 1026 | + dma_unmap_single(&lp->pci_dev->dev, |
|---|
| 1027 | + lp->tx_skbs[i].skb_dma, |
|---|
| 1028 | + skb->len, DMA_TO_DEVICE); |
|---|
| 1022 | 1029 | dev_kfree_skb(skb); |
|---|
| 1023 | 1030 | lp->tx_skbs[i].skb = NULL; |
|---|
| 1024 | 1031 | lp->tx_skbs[i].skb_dma = 0; |
|---|
| .. | .. |
|---|
| 1040 | 1047 | } |
|---|
| 1041 | 1048 | } |
|---|
| 1042 | 1049 | if (lp->fd_buf) { |
|---|
| 1043 | | - pci_free_consistent(lp->pci_dev, PAGE_SIZE * FD_PAGE_NUM, |
|---|
| 1044 | | - lp->fd_buf, lp->fd_buf_dma); |
|---|
| 1050 | + dma_free_coherent(&lp->pci_dev->dev, PAGE_SIZE * FD_PAGE_NUM, |
|---|
| 1051 | + lp->fd_buf, lp->fd_buf_dma); |
|---|
| 1045 | 1052 | lp->fd_buf = NULL; |
|---|
| 1046 | 1053 | } |
|---|
| 1047 | 1054 | } |
|---|
| .. | .. |
|---|
| 1184 | 1191 | spin_unlock_irqrestore(&lp->lock, flags); |
|---|
| 1185 | 1192 | } |
|---|
| 1186 | 1193 | |
|---|
| 1187 | | -static void tc35815_tx_timeout(struct net_device *dev) |
|---|
| 1194 | +static void tc35815_tx_timeout(struct net_device *dev, unsigned int txqueue) |
|---|
| 1188 | 1195 | { |
|---|
| 1189 | 1196 | struct tc35815_regs __iomem *tr = |
|---|
| 1190 | 1197 | (struct tc35815_regs __iomem *)dev->base_addr; |
|---|
| .. | .. |
|---|
| 1288 | 1295 | BUG_ON(lp->tx_skbs[lp->tfd_start].skb); |
|---|
| 1289 | 1296 | #endif |
|---|
| 1290 | 1297 | lp->tx_skbs[lp->tfd_start].skb = skb; |
|---|
| 1291 | | - lp->tx_skbs[lp->tfd_start].skb_dma = pci_map_single(lp->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE); |
|---|
| 1298 | + lp->tx_skbs[lp->tfd_start].skb_dma = dma_map_single(&lp->pci_dev->dev, |
|---|
| 1299 | + skb->data, |
|---|
| 1300 | + skb->len, |
|---|
| 1301 | + DMA_TO_DEVICE); |
|---|
| 1292 | 1302 | |
|---|
| 1293 | 1303 | /*add to ring */ |
|---|
| 1294 | 1304 | txfd = &lp->tfd_base[lp->tfd_start]; |
|---|
| .. | .. |
|---|
| 1496 | 1506 | skb = lp->rx_skbs[cur_bd].skb; |
|---|
| 1497 | 1507 | prefetch(skb->data); |
|---|
| 1498 | 1508 | lp->rx_skbs[cur_bd].skb = NULL; |
|---|
| 1499 | | - pci_unmap_single(lp->pci_dev, |
|---|
| 1509 | + dma_unmap_single(&lp->pci_dev->dev, |
|---|
| 1500 | 1510 | lp->rx_skbs[cur_bd].skb_dma, |
|---|
| 1501 | | - RX_BUF_SIZE, PCI_DMA_FROMDEVICE); |
|---|
| 1511 | + RX_BUF_SIZE, DMA_FROM_DEVICE); |
|---|
| 1502 | 1512 | if (!HAVE_DMA_RXALIGN(lp) && NET_IP_ALIGN != 0) |
|---|
| 1503 | 1513 | memmove(skb->data, skb->data - NET_IP_ALIGN, |
|---|
| 1504 | 1514 | pkt_len); |
|---|
| .. | .. |
|---|
| 1752 | 1762 | #endif |
|---|
| 1753 | 1763 | if (skb) { |
|---|
| 1754 | 1764 | dev->stats.tx_bytes += skb->len; |
|---|
| 1755 | | - pci_unmap_single(lp->pci_dev, lp->tx_skbs[lp->tfd_end].skb_dma, skb->len, PCI_DMA_TODEVICE); |
|---|
| 1765 | + dma_unmap_single(&lp->pci_dev->dev, |
|---|
| 1766 | + lp->tx_skbs[lp->tfd_end].skb_dma, |
|---|
| 1767 | + skb->len, DMA_TO_DEVICE); |
|---|
| 1756 | 1768 | lp->tx_skbs[lp->tfd_end].skb = NULL; |
|---|
| 1757 | 1769 | lp->tx_skbs[lp->tfd_end].skb_dma = 0; |
|---|
| 1758 | 1770 | dev_kfree_skb_any(skb); |
|---|
| .. | .. |
|---|
| 2003 | 2015 | .get_link_ksettings = phy_ethtool_get_link_ksettings, |
|---|
| 2004 | 2016 | .set_link_ksettings = phy_ethtool_set_link_ksettings, |
|---|
| 2005 | 2017 | }; |
|---|
| 2006 | | - |
|---|
| 2007 | | -static int tc35815_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
|---|
| 2008 | | -{ |
|---|
| 2009 | | - if (!netif_running(dev)) |
|---|
| 2010 | | - return -EINVAL; |
|---|
| 2011 | | - if (!dev->phydev) |
|---|
| 2012 | | - return -ENODEV; |
|---|
| 2013 | | - return phy_mii_ioctl(dev->phydev, rq, cmd); |
|---|
| 2014 | | -} |
|---|
| 2015 | 2018 | |
|---|
| 2016 | 2019 | static void tc35815_chip_reset(struct net_device *dev) |
|---|
| 2017 | 2020 | { |
|---|