| .. | .. |
|---|
| 8 | 8 | #include <linux/crc32.h> |
|---|
| 9 | 9 | #include <linux/microchipphy.h> |
|---|
| 10 | 10 | #include <linux/net_tstamp.h> |
|---|
| 11 | +#include <linux/of_mdio.h> |
|---|
| 12 | +#include <linux/of_net.h> |
|---|
| 11 | 13 | #include <linux/phy.h> |
|---|
| 14 | +#include <linux/phy_fixed.h> |
|---|
| 12 | 15 | #include <linux/rtnetlink.h> |
|---|
| 13 | 16 | #include <linux/iopoll.h> |
|---|
| 14 | 17 | #include <linux/crc16.h> |
|---|
| .. | .. |
|---|
| 78 | 81 | |
|---|
| 79 | 82 | return readx_poll_timeout(LAN743X_CSR_READ_OP, HW_CFG, data, |
|---|
| 80 | 83 | !(data & HW_CFG_LRST_), 100000, 10000000); |
|---|
| 84 | +} |
|---|
| 85 | + |
|---|
| 86 | +static int lan743x_csr_wait_for_bit_atomic(struct lan743x_adapter *adapter, |
|---|
| 87 | + int offset, u32 bit_mask, |
|---|
| 88 | + int target_value, int udelay_min, |
|---|
| 89 | + int udelay_max, int count) |
|---|
| 90 | +{ |
|---|
| 91 | + u32 data; |
|---|
| 92 | + |
|---|
| 93 | + return readx_poll_timeout_atomic(LAN743X_CSR_READ_OP, offset, data, |
|---|
| 94 | + target_value == !!(data & bit_mask), |
|---|
| 95 | + udelay_max, udelay_min * count); |
|---|
| 81 | 96 | } |
|---|
| 82 | 97 | |
|---|
| 83 | 98 | static int lan743x_csr_wait_for_bit(struct lan743x_adapter *adapter, |
|---|
| .. | .. |
|---|
| 675 | 690 | u32 dp_sel; |
|---|
| 676 | 691 | int i; |
|---|
| 677 | 692 | |
|---|
| 678 | | - if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_, |
|---|
| 679 | | - 1, 40, 100, 100)) |
|---|
| 693 | + if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, DP_SEL_DPRDY_, |
|---|
| 694 | + 1, 40, 100, 100)) |
|---|
| 680 | 695 | return -EIO; |
|---|
| 681 | 696 | dp_sel = lan743x_csr_read(adapter, DP_SEL); |
|---|
| 682 | 697 | dp_sel &= ~DP_SEL_MASK_; |
|---|
| .. | .. |
|---|
| 687 | 702 | lan743x_csr_write(adapter, DP_ADDR, addr + i); |
|---|
| 688 | 703 | lan743x_csr_write(adapter, DP_DATA_0, buf[i]); |
|---|
| 689 | 704 | lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_); |
|---|
| 690 | | - if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_, |
|---|
| 691 | | - 1, 40, 100, 100)) |
|---|
| 705 | + if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, |
|---|
| 706 | + DP_SEL_DPRDY_, |
|---|
| 707 | + 1, 40, 100, 100)) |
|---|
| 692 | 708 | return -EIO; |
|---|
| 693 | 709 | } |
|---|
| 694 | 710 | |
|---|
| .. | .. |
|---|
| 793 | 809 | |
|---|
| 794 | 810 | netdev = adapter->netdev; |
|---|
| 795 | 811 | |
|---|
| 796 | | - /* setup auto duplex, and speed detection */ |
|---|
| 812 | + /* disable auto duplex, and speed detection. Phylib does that */ |
|---|
| 797 | 813 | data = lan743x_csr_read(adapter, MAC_CR); |
|---|
| 798 | | - data |= MAC_CR_ADD_ | MAC_CR_ASD_; |
|---|
| 814 | + data &= ~(MAC_CR_ADD_ | MAC_CR_ASD_); |
|---|
| 799 | 815 | data |= MAC_CR_CNTR_RST_; |
|---|
| 800 | 816 | lan743x_csr_write(adapter, MAC_CR, data); |
|---|
| 801 | 817 | |
|---|
| 802 | | - mac_addr_hi = lan743x_csr_read(adapter, MAC_RX_ADDRH); |
|---|
| 803 | | - mac_addr_lo = lan743x_csr_read(adapter, MAC_RX_ADDRL); |
|---|
| 804 | | - adapter->mac_address[0] = mac_addr_lo & 0xFF; |
|---|
| 805 | | - adapter->mac_address[1] = (mac_addr_lo >> 8) & 0xFF; |
|---|
| 806 | | - adapter->mac_address[2] = (mac_addr_lo >> 16) & 0xFF; |
|---|
| 807 | | - adapter->mac_address[3] = (mac_addr_lo >> 24) & 0xFF; |
|---|
| 808 | | - adapter->mac_address[4] = mac_addr_hi & 0xFF; |
|---|
| 809 | | - adapter->mac_address[5] = (mac_addr_hi >> 8) & 0xFF; |
|---|
| 818 | + if (!is_valid_ether_addr(adapter->mac_address)) { |
|---|
| 819 | + mac_addr_hi = lan743x_csr_read(adapter, MAC_RX_ADDRH); |
|---|
| 820 | + mac_addr_lo = lan743x_csr_read(adapter, MAC_RX_ADDRL); |
|---|
| 821 | + adapter->mac_address[0] = mac_addr_lo & 0xFF; |
|---|
| 822 | + adapter->mac_address[1] = (mac_addr_lo >> 8) & 0xFF; |
|---|
| 823 | + adapter->mac_address[2] = (mac_addr_lo >> 16) & 0xFF; |
|---|
| 824 | + adapter->mac_address[3] = (mac_addr_lo >> 24) & 0xFF; |
|---|
| 825 | + adapter->mac_address[4] = mac_addr_hi & 0xFF; |
|---|
| 826 | + adapter->mac_address[5] = (mac_addr_hi >> 8) & 0xFF; |
|---|
| 810 | 827 | |
|---|
| 811 | | - if (((mac_addr_hi & 0x0000FFFF) == 0x0000FFFF) && |
|---|
| 812 | | - mac_addr_lo == 0xFFFFFFFF) { |
|---|
| 813 | | - mac_address_valid = false; |
|---|
| 814 | | - } else if (!is_valid_ether_addr(adapter->mac_address)) { |
|---|
| 815 | | - mac_address_valid = false; |
|---|
| 828 | + if (((mac_addr_hi & 0x0000FFFF) == 0x0000FFFF) && |
|---|
| 829 | + mac_addr_lo == 0xFFFFFFFF) { |
|---|
| 830 | + mac_address_valid = false; |
|---|
| 831 | + } else if (!is_valid_ether_addr(adapter->mac_address)) { |
|---|
| 832 | + mac_address_valid = false; |
|---|
| 833 | + } |
|---|
| 834 | + |
|---|
| 835 | + if (!mac_address_valid) |
|---|
| 836 | + eth_random_addr(adapter->mac_address); |
|---|
| 816 | 837 | } |
|---|
| 817 | | - |
|---|
| 818 | | - if (!mac_address_valid) |
|---|
| 819 | | - eth_random_addr(adapter->mac_address); |
|---|
| 820 | 838 | lan743x_mac_set_address(adapter, adapter->mac_address); |
|---|
| 821 | 839 | ether_addr_copy(netdev->dev_addr, adapter->mac_address); |
|---|
| 840 | + |
|---|
| 822 | 841 | return 0; |
|---|
| 823 | 842 | } |
|---|
| 824 | 843 | |
|---|
| .. | .. |
|---|
| 916 | 935 | } |
|---|
| 917 | 936 | |
|---|
| 918 | 937 | static void lan743x_phy_update_flowcontrol(struct lan743x_adapter *adapter, |
|---|
| 919 | | - u8 duplex, u16 local_adv, |
|---|
| 920 | | - u16 remote_adv) |
|---|
| 938 | + u16 local_adv, u16 remote_adv) |
|---|
| 921 | 939 | { |
|---|
| 922 | 940 | struct lan743x_phy *phy = &adapter->phy; |
|---|
| 923 | 941 | u8 cap; |
|---|
| .. | .. |
|---|
| 941 | 959 | { |
|---|
| 942 | 960 | struct lan743x_adapter *adapter = netdev_priv(netdev); |
|---|
| 943 | 961 | struct phy_device *phydev = netdev->phydev; |
|---|
| 962 | + u32 data; |
|---|
| 944 | 963 | |
|---|
| 945 | 964 | phy_print_status(phydev); |
|---|
| 946 | 965 | if (phydev->state == PHY_RUNNING) { |
|---|
| 947 | | - struct ethtool_link_ksettings ksettings; |
|---|
| 948 | 966 | int remote_advertisement = 0; |
|---|
| 949 | 967 | int local_advertisement = 0; |
|---|
| 950 | 968 | |
|---|
| 951 | | - memset(&ksettings, 0, sizeof(ksettings)); |
|---|
| 952 | | - phy_ethtool_get_link_ksettings(netdev, &ksettings); |
|---|
| 953 | | - local_advertisement = |
|---|
| 954 | | - ethtool_adv_to_mii_adv_t(phydev->advertising); |
|---|
| 955 | | - remote_advertisement = |
|---|
| 956 | | - ethtool_adv_to_mii_adv_t(phydev->lp_advertising); |
|---|
| 969 | + data = lan743x_csr_read(adapter, MAC_CR); |
|---|
| 957 | 970 | |
|---|
| 958 | | - lan743x_phy_update_flowcontrol(adapter, |
|---|
| 959 | | - ksettings.base.duplex, |
|---|
| 960 | | - local_advertisement, |
|---|
| 971 | + /* set interface mode */ |
|---|
| 972 | + if (phy_interface_mode_is_rgmii(adapter->phy_mode)) |
|---|
| 973 | + /* RGMII */ |
|---|
| 974 | + data &= ~MAC_CR_MII_EN_; |
|---|
| 975 | + else |
|---|
| 976 | + /* GMII */ |
|---|
| 977 | + data |= MAC_CR_MII_EN_; |
|---|
| 978 | + |
|---|
| 979 | + /* set duplex mode */ |
|---|
| 980 | + if (phydev->duplex) |
|---|
| 981 | + data |= MAC_CR_DPX_; |
|---|
| 982 | + else |
|---|
| 983 | + data &= ~MAC_CR_DPX_; |
|---|
| 984 | + |
|---|
| 985 | + /* set bus speed */ |
|---|
| 986 | + switch (phydev->speed) { |
|---|
| 987 | + case SPEED_10: |
|---|
| 988 | + data &= ~MAC_CR_CFG_H_; |
|---|
| 989 | + data &= ~MAC_CR_CFG_L_; |
|---|
| 990 | + break; |
|---|
| 991 | + case SPEED_100: |
|---|
| 992 | + data &= ~MAC_CR_CFG_H_; |
|---|
| 993 | + data |= MAC_CR_CFG_L_; |
|---|
| 994 | + break; |
|---|
| 995 | + case SPEED_1000: |
|---|
| 996 | + data |= MAC_CR_CFG_H_; |
|---|
| 997 | + data &= ~MAC_CR_CFG_L_; |
|---|
| 998 | + break; |
|---|
| 999 | + } |
|---|
| 1000 | + lan743x_csr_write(adapter, MAC_CR, data); |
|---|
| 1001 | + |
|---|
| 1002 | + local_advertisement = |
|---|
| 1003 | + linkmode_adv_to_mii_adv_t(phydev->advertising); |
|---|
| 1004 | + remote_advertisement = |
|---|
| 1005 | + linkmode_adv_to_mii_adv_t(phydev->lp_advertising); |
|---|
| 1006 | + |
|---|
| 1007 | + lan743x_phy_update_flowcontrol(adapter, local_advertisement, |
|---|
| 961 | 1008 | remote_advertisement); |
|---|
| 962 | | - lan743x_ptp_update_latency(adapter, ksettings.base.speed); |
|---|
| 1009 | + lan743x_ptp_update_latency(adapter, phydev->speed); |
|---|
| 963 | 1010 | } |
|---|
| 964 | 1011 | } |
|---|
| 965 | 1012 | |
|---|
| .. | .. |
|---|
| 975 | 1022 | static int lan743x_phy_open(struct lan743x_adapter *adapter) |
|---|
| 976 | 1023 | { |
|---|
| 977 | 1024 | struct lan743x_phy *phy = &adapter->phy; |
|---|
| 978 | | - struct phy_device *phydev; |
|---|
| 1025 | + struct phy_device *phydev = NULL; |
|---|
| 1026 | + struct device_node *phynode; |
|---|
| 979 | 1027 | struct net_device *netdev; |
|---|
| 980 | 1028 | int ret = -EIO; |
|---|
| 981 | | - u32 mii_adv; |
|---|
| 982 | 1029 | |
|---|
| 983 | 1030 | netdev = adapter->netdev; |
|---|
| 984 | | - phydev = phy_find_first(adapter->mdiobus); |
|---|
| 985 | | - if (!phydev) |
|---|
| 986 | | - goto return_error; |
|---|
| 1031 | + phynode = of_node_get(adapter->pdev->dev.of_node); |
|---|
| 987 | 1032 | |
|---|
| 988 | | - ret = phy_connect_direct(netdev, phydev, |
|---|
| 989 | | - lan743x_phy_link_status_change, |
|---|
| 990 | | - PHY_INTERFACE_MODE_GMII); |
|---|
| 991 | | - if (ret) |
|---|
| 992 | | - goto return_error; |
|---|
| 1033 | + if (phynode) { |
|---|
| 1034 | + /* try devicetree phy, or fixed link */ |
|---|
| 1035 | + of_get_phy_mode(phynode, &adapter->phy_mode); |
|---|
| 1036 | + |
|---|
| 1037 | + if (of_phy_is_fixed_link(phynode)) { |
|---|
| 1038 | + ret = of_phy_register_fixed_link(phynode); |
|---|
| 1039 | + if (ret) { |
|---|
| 1040 | + netdev_err(netdev, |
|---|
| 1041 | + "cannot register fixed PHY\n"); |
|---|
| 1042 | + of_node_put(phynode); |
|---|
| 1043 | + goto return_error; |
|---|
| 1044 | + } |
|---|
| 1045 | + } |
|---|
| 1046 | + phydev = of_phy_connect(netdev, phynode, |
|---|
| 1047 | + lan743x_phy_link_status_change, 0, |
|---|
| 1048 | + adapter->phy_mode); |
|---|
| 1049 | + of_node_put(phynode); |
|---|
| 1050 | + } |
|---|
| 1051 | + |
|---|
| 1052 | + if (!phydev) { |
|---|
| 1053 | + /* try internal phy */ |
|---|
| 1054 | + phydev = phy_find_first(adapter->mdiobus); |
|---|
| 1055 | + if (!phydev) |
|---|
| 1056 | + goto return_error; |
|---|
| 1057 | + |
|---|
| 1058 | + adapter->phy_mode = PHY_INTERFACE_MODE_GMII; |
|---|
| 1059 | + ret = phy_connect_direct(netdev, phydev, |
|---|
| 1060 | + lan743x_phy_link_status_change, |
|---|
| 1061 | + adapter->phy_mode); |
|---|
| 1062 | + if (ret) |
|---|
| 1063 | + goto return_error; |
|---|
| 1064 | + } |
|---|
| 993 | 1065 | |
|---|
| 994 | 1066 | /* MAC doesn't support 1000T Half */ |
|---|
| 995 | | - phydev->supported &= ~SUPPORTED_1000baseT_Half; |
|---|
| 1067 | + phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT); |
|---|
| 996 | 1068 | |
|---|
| 997 | 1069 | /* support both flow controls */ |
|---|
| 1070 | + phy_support_asym_pause(phydev); |
|---|
| 998 | 1071 | phy->fc_request_control = (FLOW_CTRL_RX | FLOW_CTRL_TX); |
|---|
| 999 | | - phydev->advertising &= ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause); |
|---|
| 1000 | | - mii_adv = (u32)mii_advertise_flowctrl(phy->fc_request_control); |
|---|
| 1001 | | - phydev->advertising |= mii_adv_to_ethtool_adv_t(mii_adv); |
|---|
| 1002 | 1072 | phy->fc_autoneg = phydev->autoneg; |
|---|
| 1003 | 1073 | |
|---|
| 1004 | 1074 | phy_start(phydev); |
|---|
| .. | .. |
|---|
| 1217 | 1287 | if (!(buffer_info->flags & TX_BUFFER_INFO_FLAG_ACTIVE)) |
|---|
| 1218 | 1288 | goto done; |
|---|
| 1219 | 1289 | |
|---|
| 1220 | | - descriptor_type = (descriptor->data0) & |
|---|
| 1290 | + descriptor_type = le32_to_cpu(descriptor->data0) & |
|---|
| 1221 | 1291 | TX_DESC_DATA0_DTYPE_MASK_; |
|---|
| 1222 | 1292 | if (descriptor_type == TX_DESC_DATA0_DTYPE_DATA_) |
|---|
| 1223 | 1293 | goto clean_up_data_descriptor; |
|---|
| .. | .. |
|---|
| 1277 | 1347 | |
|---|
| 1278 | 1348 | static void lan743x_tx_release_completed_descriptors(struct lan743x_tx *tx) |
|---|
| 1279 | 1349 | { |
|---|
| 1280 | | - while ((*tx->head_cpu_ptr) != (tx->last_head)) { |
|---|
| 1350 | + while (le32_to_cpu(*tx->head_cpu_ptr) != (tx->last_head)) { |
|---|
| 1281 | 1351 | lan743x_tx_release_desc(tx, tx->last_head, false); |
|---|
| 1282 | 1352 | tx->last_head = lan743x_tx_next_index(tx, tx->last_head); |
|---|
| 1283 | 1353 | } |
|---|
| .. | .. |
|---|
| 1363 | 1433 | if (dma_mapping_error(dev, dma_ptr)) |
|---|
| 1364 | 1434 | return -ENOMEM; |
|---|
| 1365 | 1435 | |
|---|
| 1366 | | - tx_descriptor->data1 = DMA_ADDR_LOW32(dma_ptr); |
|---|
| 1367 | | - tx_descriptor->data2 = DMA_ADDR_HIGH32(dma_ptr); |
|---|
| 1368 | | - tx_descriptor->data3 = (frame_length << 16) & |
|---|
| 1369 | | - TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_; |
|---|
| 1436 | + tx_descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(dma_ptr)); |
|---|
| 1437 | + tx_descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(dma_ptr)); |
|---|
| 1438 | + tx_descriptor->data3 = cpu_to_le32((frame_length << 16) & |
|---|
| 1439 | + TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_); |
|---|
| 1370 | 1440 | |
|---|
| 1371 | 1441 | buffer_info->skb = NULL; |
|---|
| 1372 | 1442 | buffer_info->dma_ptr = dma_ptr; |
|---|
| .. | .. |
|---|
| 1407 | 1477 | tx->frame_data0 |= TX_DESC_DATA0_IOC_; |
|---|
| 1408 | 1478 | } |
|---|
| 1409 | 1479 | tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; |
|---|
| 1410 | | - tx_descriptor->data0 = tx->frame_data0; |
|---|
| 1480 | + tx_descriptor->data0 = cpu_to_le32(tx->frame_data0); |
|---|
| 1411 | 1481 | |
|---|
| 1412 | 1482 | /* move to next descriptor */ |
|---|
| 1413 | 1483 | tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail); |
|---|
| .. | .. |
|---|
| 1432 | 1502 | } |
|---|
| 1433 | 1503 | |
|---|
| 1434 | 1504 | static int lan743x_tx_frame_add_fragment(struct lan743x_tx *tx, |
|---|
| 1435 | | - const struct skb_frag_struct *fragment, |
|---|
| 1505 | + const skb_frag_t *fragment, |
|---|
| 1436 | 1506 | unsigned int frame_length) |
|---|
| 1437 | 1507 | { |
|---|
| 1438 | 1508 | /* called only from within lan743x_tx_xmit_frame |
|---|
| .. | .. |
|---|
| 1451 | 1521 | |
|---|
| 1452 | 1522 | /* wrap up previous descriptor */ |
|---|
| 1453 | 1523 | tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail]; |
|---|
| 1454 | | - tx_descriptor->data0 = tx->frame_data0; |
|---|
| 1524 | + tx_descriptor->data0 = cpu_to_le32(tx->frame_data0); |
|---|
| 1455 | 1525 | |
|---|
| 1456 | 1526 | /* move to next descriptor */ |
|---|
| 1457 | 1527 | tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail); |
|---|
| .. | .. |
|---|
| 1477 | 1547 | return -ENOMEM; |
|---|
| 1478 | 1548 | } |
|---|
| 1479 | 1549 | |
|---|
| 1480 | | - tx_descriptor->data1 = DMA_ADDR_LOW32(dma_ptr); |
|---|
| 1481 | | - tx_descriptor->data2 = DMA_ADDR_HIGH32(dma_ptr); |
|---|
| 1482 | | - tx_descriptor->data3 = (frame_length << 16) & |
|---|
| 1483 | | - TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_; |
|---|
| 1550 | + tx_descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(dma_ptr)); |
|---|
| 1551 | + tx_descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(dma_ptr)); |
|---|
| 1552 | + tx_descriptor->data3 = cpu_to_le32((frame_length << 16) & |
|---|
| 1553 | + TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_); |
|---|
| 1484 | 1554 | |
|---|
| 1485 | 1555 | buffer_info->skb = NULL; |
|---|
| 1486 | 1556 | buffer_info->dma_ptr = dma_ptr; |
|---|
| .. | .. |
|---|
| 1524 | 1594 | if (ignore_sync) |
|---|
| 1525 | 1595 | buffer_info->flags |= TX_BUFFER_INFO_FLAG_IGNORE_SYNC; |
|---|
| 1526 | 1596 | |
|---|
| 1527 | | - tx_descriptor->data0 = tx->frame_data0; |
|---|
| 1597 | + tx_descriptor->data0 = cpu_to_le32(tx->frame_data0); |
|---|
| 1528 | 1598 | tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail); |
|---|
| 1529 | 1599 | tx->last_tail = tx->frame_tail; |
|---|
| 1530 | 1600 | |
|---|
| .. | .. |
|---|
| 1605 | 1675 | goto finish; |
|---|
| 1606 | 1676 | |
|---|
| 1607 | 1677 | for (j = 0; j < nr_frags; j++) { |
|---|
| 1608 | | - const struct skb_frag_struct *frag; |
|---|
| 1678 | + const skb_frag_t *frag = &(skb_shinfo(skb)->frags[j]); |
|---|
| 1609 | 1679 | |
|---|
| 1610 | | - frag = &(skb_shinfo(skb)->frags[j]); |
|---|
| 1611 | 1680 | if (lan743x_tx_frame_add_fragment(tx, frag, frame_length)) { |
|---|
| 1612 | 1681 | /* upon error no need to call |
|---|
| 1613 | 1682 | * lan743x_tx_frame_end |
|---|
| .. | .. |
|---|
| 1676 | 1745 | static void lan743x_tx_ring_cleanup(struct lan743x_tx *tx) |
|---|
| 1677 | 1746 | { |
|---|
| 1678 | 1747 | if (tx->head_cpu_ptr) { |
|---|
| 1679 | | - pci_free_consistent(tx->adapter->pdev, |
|---|
| 1680 | | - sizeof(*tx->head_cpu_ptr), |
|---|
| 1681 | | - (void *)(tx->head_cpu_ptr), |
|---|
| 1682 | | - tx->head_dma_ptr); |
|---|
| 1748 | + dma_free_coherent(&tx->adapter->pdev->dev, |
|---|
| 1749 | + sizeof(*tx->head_cpu_ptr), tx->head_cpu_ptr, |
|---|
| 1750 | + tx->head_dma_ptr); |
|---|
| 1683 | 1751 | tx->head_cpu_ptr = NULL; |
|---|
| 1684 | 1752 | tx->head_dma_ptr = 0; |
|---|
| 1685 | 1753 | } |
|---|
| .. | .. |
|---|
| 1687 | 1755 | tx->buffer_info = NULL; |
|---|
| 1688 | 1756 | |
|---|
| 1689 | 1757 | if (tx->ring_cpu_ptr) { |
|---|
| 1690 | | - pci_free_consistent(tx->adapter->pdev, |
|---|
| 1691 | | - tx->ring_allocation_size, |
|---|
| 1692 | | - tx->ring_cpu_ptr, |
|---|
| 1693 | | - tx->ring_dma_ptr); |
|---|
| 1758 | + dma_free_coherent(&tx->adapter->pdev->dev, |
|---|
| 1759 | + tx->ring_allocation_size, tx->ring_cpu_ptr, |
|---|
| 1760 | + tx->ring_dma_ptr); |
|---|
| 1694 | 1761 | tx->ring_allocation_size = 0; |
|---|
| 1695 | 1762 | tx->ring_cpu_ptr = NULL; |
|---|
| 1696 | 1763 | tx->ring_dma_ptr = 0; |
|---|
| .. | .. |
|---|
| 1724 | 1791 | sizeof(struct lan743x_tx_descriptor), |
|---|
| 1725 | 1792 | PAGE_SIZE); |
|---|
| 1726 | 1793 | dma_ptr = 0; |
|---|
| 1727 | | - cpu_ptr = pci_zalloc_consistent(tx->adapter->pdev, |
|---|
| 1728 | | - ring_allocation_size, &dma_ptr); |
|---|
| 1794 | + cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, |
|---|
| 1795 | + ring_allocation_size, &dma_ptr, GFP_KERNEL); |
|---|
| 1729 | 1796 | if (!cpu_ptr) { |
|---|
| 1730 | 1797 | ret = -ENOMEM; |
|---|
| 1731 | 1798 | goto cleanup; |
|---|
| .. | .. |
|---|
| 1742 | 1809 | } |
|---|
| 1743 | 1810 | tx->buffer_info = (struct lan743x_tx_buffer_info *)cpu_ptr; |
|---|
| 1744 | 1811 | dma_ptr = 0; |
|---|
| 1745 | | - cpu_ptr = pci_zalloc_consistent(tx->adapter->pdev, |
|---|
| 1746 | | - sizeof(*tx->head_cpu_ptr), &dma_ptr); |
|---|
| 1812 | + cpu_ptr = dma_alloc_coherent(&tx->adapter->pdev->dev, |
|---|
| 1813 | + sizeof(*tx->head_cpu_ptr), &dma_ptr, |
|---|
| 1814 | + GFP_KERNEL); |
|---|
| 1747 | 1815 | if (!cpu_ptr) { |
|---|
| 1748 | 1816 | ret = -ENOMEM; |
|---|
| 1749 | 1817 | goto cleanup; |
|---|
| .. | .. |
|---|
| 1902 | 1970 | return ((++index) % rx->ring_size); |
|---|
| 1903 | 1971 | } |
|---|
| 1904 | 1972 | |
|---|
| 1905 | | -static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx) |
|---|
| 1973 | +static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx, gfp_t gfp) |
|---|
| 1906 | 1974 | { |
|---|
| 1907 | 1975 | int length = 0; |
|---|
| 1908 | 1976 | |
|---|
| 1909 | 1977 | length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING); |
|---|
| 1910 | 1978 | return __netdev_alloc_skb(rx->adapter->netdev, |
|---|
| 1911 | | - length, GFP_ATOMIC | GFP_DMA); |
|---|
| 1979 | + length, gfp); |
|---|
| 1980 | +} |
|---|
| 1981 | + |
|---|
| 1982 | +static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) |
|---|
| 1983 | +{ |
|---|
| 1984 | + /* update the tail once per 8 descriptors */ |
|---|
| 1985 | + if ((index & 7) == 7) |
|---|
| 1986 | + lan743x_csr_write(rx->adapter, RX_TAIL(rx->channel_number), |
|---|
| 1987 | + index); |
|---|
| 1912 | 1988 | } |
|---|
| 1913 | 1989 | |
|---|
| 1914 | 1990 | static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, |
|---|
| .. | .. |
|---|
| 1935 | 2011 | } |
|---|
| 1936 | 2012 | |
|---|
| 1937 | 2013 | buffer_info->buffer_length = length; |
|---|
| 1938 | | - descriptor->data1 = DMA_ADDR_LOW32(buffer_info->dma_ptr); |
|---|
| 1939 | | - descriptor->data2 = DMA_ADDR_HIGH32(buffer_info->dma_ptr); |
|---|
| 2014 | + descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(buffer_info->dma_ptr)); |
|---|
| 2015 | + descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(buffer_info->dma_ptr)); |
|---|
| 1940 | 2016 | descriptor->data3 = 0; |
|---|
| 1941 | | - descriptor->data0 = (RX_DESC_DATA0_OWN_ | |
|---|
| 1942 | | - (length & RX_DESC_DATA0_BUF_LENGTH_MASK_)); |
|---|
| 2017 | + descriptor->data0 = cpu_to_le32((RX_DESC_DATA0_OWN_ | |
|---|
| 2018 | + (length & RX_DESC_DATA0_BUF_LENGTH_MASK_))); |
|---|
| 1943 | 2019 | skb_reserve(buffer_info->skb, RX_HEAD_PADDING); |
|---|
| 2020 | + lan743x_rx_update_tail(rx, index); |
|---|
| 1944 | 2021 | |
|---|
| 1945 | 2022 | return 0; |
|---|
| 1946 | 2023 | } |
|---|
| .. | .. |
|---|
| 1953 | 2030 | descriptor = &rx->ring_cpu_ptr[index]; |
|---|
| 1954 | 2031 | buffer_info = &rx->buffer_info[index]; |
|---|
| 1955 | 2032 | |
|---|
| 1956 | | - descriptor->data1 = DMA_ADDR_LOW32(buffer_info->dma_ptr); |
|---|
| 1957 | | - descriptor->data2 = DMA_ADDR_HIGH32(buffer_info->dma_ptr); |
|---|
| 2033 | + descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(buffer_info->dma_ptr)); |
|---|
| 2034 | + descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(buffer_info->dma_ptr)); |
|---|
| 1958 | 2035 | descriptor->data3 = 0; |
|---|
| 1959 | | - descriptor->data0 = (RX_DESC_DATA0_OWN_ | |
|---|
| 2036 | + descriptor->data0 = cpu_to_le32((RX_DESC_DATA0_OWN_ | |
|---|
| 1960 | 2037 | ((buffer_info->buffer_length) & |
|---|
| 1961 | | - RX_DESC_DATA0_BUF_LENGTH_MASK_)); |
|---|
| 2038 | + RX_DESC_DATA0_BUF_LENGTH_MASK_))); |
|---|
| 2039 | + lan743x_rx_update_tail(rx, index); |
|---|
| 1962 | 2040 | } |
|---|
| 1963 | 2041 | |
|---|
| 1964 | 2042 | static void lan743x_rx_release_ring_element(struct lan743x_rx *rx, int index) |
|---|
| .. | .. |
|---|
| 1991 | 2069 | { |
|---|
| 1992 | 2070 | struct skb_shared_hwtstamps *hwtstamps = NULL; |
|---|
| 1993 | 2071 | int result = RX_PROCESS_RESULT_NOTHING_TO_DO; |
|---|
| 2072 | + int current_head_index = le32_to_cpu(*rx->head_cpu_ptr); |
|---|
| 1994 | 2073 | struct lan743x_rx_buffer_info *buffer_info; |
|---|
| 1995 | 2074 | struct lan743x_rx_descriptor *descriptor; |
|---|
| 1996 | | - int current_head_index = -1; |
|---|
| 1997 | 2075 | int extension_index = -1; |
|---|
| 1998 | 2076 | int first_index = -1; |
|---|
| 1999 | 2077 | int last_index = -1; |
|---|
| 2000 | 2078 | |
|---|
| 2001 | | - current_head_index = *rx->head_cpu_ptr; |
|---|
| 2002 | 2079 | if (current_head_index < 0 || current_head_index >= rx->ring_size) |
|---|
| 2003 | 2080 | goto done; |
|---|
| 2004 | 2081 | |
|---|
| .. | .. |
|---|
| 2007 | 2084 | |
|---|
| 2008 | 2085 | if (rx->last_head != current_head_index) { |
|---|
| 2009 | 2086 | descriptor = &rx->ring_cpu_ptr[rx->last_head]; |
|---|
| 2010 | | - if (descriptor->data0 & RX_DESC_DATA0_OWN_) |
|---|
| 2087 | + if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_OWN_) |
|---|
| 2011 | 2088 | goto done; |
|---|
| 2012 | 2089 | |
|---|
| 2013 | | - if (!(descriptor->data0 & RX_DESC_DATA0_FS_)) |
|---|
| 2090 | + if (!(le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_FS_)) |
|---|
| 2014 | 2091 | goto done; |
|---|
| 2015 | 2092 | |
|---|
| 2016 | 2093 | first_index = rx->last_head; |
|---|
| 2017 | | - if (descriptor->data0 & RX_DESC_DATA0_LS_) { |
|---|
| 2094 | + if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_LS_) { |
|---|
| 2018 | 2095 | last_index = rx->last_head; |
|---|
| 2019 | 2096 | } else { |
|---|
| 2020 | 2097 | int index; |
|---|
| .. | .. |
|---|
| 2022 | 2099 | index = lan743x_rx_next_index(rx, first_index); |
|---|
| 2023 | 2100 | while (index != current_head_index) { |
|---|
| 2024 | 2101 | descriptor = &rx->ring_cpu_ptr[index]; |
|---|
| 2025 | | - if (descriptor->data0 & RX_DESC_DATA0_OWN_) |
|---|
| 2102 | + if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_OWN_) |
|---|
| 2026 | 2103 | goto done; |
|---|
| 2027 | 2104 | |
|---|
| 2028 | | - if (descriptor->data0 & RX_DESC_DATA0_LS_) { |
|---|
| 2105 | + if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_LS_) { |
|---|
| 2029 | 2106 | last_index = index; |
|---|
| 2030 | 2107 | break; |
|---|
| 2031 | 2108 | } |
|---|
| .. | .. |
|---|
| 2034 | 2111 | } |
|---|
| 2035 | 2112 | if (last_index >= 0) { |
|---|
| 2036 | 2113 | descriptor = &rx->ring_cpu_ptr[last_index]; |
|---|
| 2037 | | - if (descriptor->data0 & RX_DESC_DATA0_EXT_) { |
|---|
| 2114 | + if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_EXT_) { |
|---|
| 2038 | 2115 | /* extension is expected to follow */ |
|---|
| 2039 | 2116 | int index = lan743x_rx_next_index(rx, |
|---|
| 2040 | 2117 | last_index); |
|---|
| 2041 | 2118 | if (index != current_head_index) { |
|---|
| 2042 | 2119 | descriptor = &rx->ring_cpu_ptr[index]; |
|---|
| 2043 | | - if (descriptor->data0 & |
|---|
| 2120 | + if (le32_to_cpu(descriptor->data0) & |
|---|
| 2044 | 2121 | RX_DESC_DATA0_OWN_) { |
|---|
| 2045 | 2122 | goto done; |
|---|
| 2046 | 2123 | } |
|---|
| 2047 | | - if (descriptor->data0 & |
|---|
| 2124 | + if (le32_to_cpu(descriptor->data0) & |
|---|
| 2048 | 2125 | RX_DESC_DATA0_EXT_) { |
|---|
| 2049 | 2126 | extension_index = index; |
|---|
| 2050 | 2127 | } else { |
|---|
| .. | .. |
|---|
| 2071 | 2148 | struct sk_buff *new_skb = NULL; |
|---|
| 2072 | 2149 | int packet_length; |
|---|
| 2073 | 2150 | |
|---|
| 2074 | | - new_skb = lan743x_rx_allocate_skb(rx); |
|---|
| 2151 | + new_skb = lan743x_rx_allocate_skb(rx, |
|---|
| 2152 | + GFP_ATOMIC | GFP_DMA); |
|---|
| 2075 | 2153 | if (!new_skb) { |
|---|
| 2076 | 2154 | /* failed to allocate next skb. |
|---|
| 2077 | 2155 | * Memory is very low. |
|---|
| .. | .. |
|---|
| 2096 | 2174 | } |
|---|
| 2097 | 2175 | buffer_info->skb = NULL; |
|---|
| 2098 | 2176 | packet_length = RX_DESC_DATA0_FRAME_LENGTH_GET_ |
|---|
| 2099 | | - (descriptor->data0); |
|---|
| 2177 | + (le32_to_cpu(descriptor->data0)); |
|---|
| 2100 | 2178 | skb_put(skb, packet_length - 4); |
|---|
| 2101 | 2179 | skb->protocol = eth_type_trans(skb, |
|---|
| 2102 | 2180 | rx->adapter->netdev); |
|---|
| .. | .. |
|---|
| 2134 | 2212 | descriptor = &rx->ring_cpu_ptr[extension_index]; |
|---|
| 2135 | 2213 | buffer_info = &rx->buffer_info[extension_index]; |
|---|
| 2136 | 2214 | |
|---|
| 2137 | | - ts_sec = descriptor->data1; |
|---|
| 2138 | | - ts_nsec = (descriptor->data2 & |
|---|
| 2215 | + ts_sec = le32_to_cpu(descriptor->data1); |
|---|
| 2216 | + ts_nsec = (le32_to_cpu(descriptor->data2) & |
|---|
| 2139 | 2217 | RX_DESC_DATA2_TS_NS_MASK_); |
|---|
| 2140 | 2218 | lan743x_rx_reuse_ring_element(rx, extension_index); |
|---|
| 2141 | 2219 | real_last_index = extension_index; |
|---|
| .. | .. |
|---|
| 2170 | 2248 | { |
|---|
| 2171 | 2249 | struct lan743x_rx *rx = container_of(napi, struct lan743x_rx, napi); |
|---|
| 2172 | 2250 | struct lan743x_adapter *adapter = rx->adapter; |
|---|
| 2251 | + int result = RX_PROCESS_RESULT_NOTHING_TO_DO; |
|---|
| 2173 | 2252 | u32 rx_tail_flags = 0; |
|---|
| 2174 | 2253 | int count; |
|---|
| 2175 | 2254 | |
|---|
| .. | .. |
|---|
| 2178 | 2257 | lan743x_csr_write(adapter, DMAC_INT_STS, |
|---|
| 2179 | 2258 | DMAC_INT_BIT_RXFRM_(rx->channel_number)); |
|---|
| 2180 | 2259 | } |
|---|
| 2181 | | - count = 0; |
|---|
| 2182 | | - while (count < weight) { |
|---|
| 2183 | | - int rx_process_result = -1; |
|---|
| 2184 | | - |
|---|
| 2185 | | - rx_process_result = lan743x_rx_process_packet(rx); |
|---|
| 2186 | | - if (rx_process_result == RX_PROCESS_RESULT_PACKET_RECEIVED) { |
|---|
| 2187 | | - count++; |
|---|
| 2188 | | - } else if (rx_process_result == |
|---|
| 2189 | | - RX_PROCESS_RESULT_NOTHING_TO_DO) { |
|---|
| 2260 | + for (count = 0; count < weight; count++) { |
|---|
| 2261 | + result = lan743x_rx_process_packet(rx); |
|---|
| 2262 | + if (result == RX_PROCESS_RESULT_NOTHING_TO_DO) |
|---|
| 2190 | 2263 | break; |
|---|
| 2191 | | - } else if (rx_process_result == |
|---|
| 2192 | | - RX_PROCESS_RESULT_PACKET_DROPPED) { |
|---|
| 2193 | | - continue; |
|---|
| 2194 | | - } |
|---|
| 2195 | 2264 | } |
|---|
| 2196 | 2265 | rx->frame_count += count; |
|---|
| 2197 | | - if (count == weight) |
|---|
| 2198 | | - goto done; |
|---|
| 2266 | + if (count == weight || result == RX_PROCESS_RESULT_PACKET_RECEIVED) |
|---|
| 2267 | + return weight; |
|---|
| 2199 | 2268 | |
|---|
| 2200 | 2269 | if (!napi_complete_done(napi, count)) |
|---|
| 2201 | | - goto done; |
|---|
| 2270 | + return count; |
|---|
| 2202 | 2271 | |
|---|
| 2272 | + /* re-arm interrupts, must write to rx tail on some chip variants */ |
|---|
| 2203 | 2273 | if (rx->vector_flags & LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET) |
|---|
| 2204 | 2274 | rx_tail_flags |= RX_TAIL_SET_TOP_INT_VEC_EN_; |
|---|
| 2205 | 2275 | if (rx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET) { |
|---|
| .. | .. |
|---|
| 2209 | 2279 | INT_BIT_DMA_RX_(rx->channel_number)); |
|---|
| 2210 | 2280 | } |
|---|
| 2211 | 2281 | |
|---|
| 2212 | | - /* update RX_TAIL */ |
|---|
| 2213 | | - lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), |
|---|
| 2214 | | - rx_tail_flags | rx->last_tail); |
|---|
| 2215 | | -done: |
|---|
| 2282 | + if (rx_tail_flags) |
|---|
| 2283 | + lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), |
|---|
| 2284 | + rx_tail_flags | rx->last_tail); |
|---|
| 2285 | + |
|---|
| 2216 | 2286 | return count; |
|---|
| 2217 | 2287 | } |
|---|
| 2218 | 2288 | |
|---|
| .. | .. |
|---|
| 2226 | 2296 | } |
|---|
| 2227 | 2297 | |
|---|
| 2228 | 2298 | if (rx->head_cpu_ptr) { |
|---|
| 2229 | | - pci_free_consistent(rx->adapter->pdev, |
|---|
| 2230 | | - sizeof(*rx->head_cpu_ptr), |
|---|
| 2231 | | - rx->head_cpu_ptr, |
|---|
| 2232 | | - rx->head_dma_ptr); |
|---|
| 2299 | + dma_free_coherent(&rx->adapter->pdev->dev, |
|---|
| 2300 | + sizeof(*rx->head_cpu_ptr), rx->head_cpu_ptr, |
|---|
| 2301 | + rx->head_dma_ptr); |
|---|
| 2233 | 2302 | rx->head_cpu_ptr = NULL; |
|---|
| 2234 | 2303 | rx->head_dma_ptr = 0; |
|---|
| 2235 | 2304 | } |
|---|
| .. | .. |
|---|
| 2238 | 2307 | rx->buffer_info = NULL; |
|---|
| 2239 | 2308 | |
|---|
| 2240 | 2309 | if (rx->ring_cpu_ptr) { |
|---|
| 2241 | | - pci_free_consistent(rx->adapter->pdev, |
|---|
| 2242 | | - rx->ring_allocation_size, |
|---|
| 2243 | | - rx->ring_cpu_ptr, |
|---|
| 2244 | | - rx->ring_dma_ptr); |
|---|
| 2310 | + dma_free_coherent(&rx->adapter->pdev->dev, |
|---|
| 2311 | + rx->ring_allocation_size, rx->ring_cpu_ptr, |
|---|
| 2312 | + rx->ring_dma_ptr); |
|---|
| 2245 | 2313 | rx->ring_allocation_size = 0; |
|---|
| 2246 | 2314 | rx->ring_cpu_ptr = NULL; |
|---|
| 2247 | 2315 | rx->ring_dma_ptr = 0; |
|---|
| .. | .. |
|---|
| 2282 | 2350 | sizeof(struct lan743x_rx_descriptor), |
|---|
| 2283 | 2351 | PAGE_SIZE); |
|---|
| 2284 | 2352 | dma_ptr = 0; |
|---|
| 2285 | | - cpu_ptr = pci_zalloc_consistent(rx->adapter->pdev, |
|---|
| 2286 | | - ring_allocation_size, &dma_ptr); |
|---|
| 2353 | + cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, |
|---|
| 2354 | + ring_allocation_size, &dma_ptr, GFP_KERNEL); |
|---|
| 2287 | 2355 | if (!cpu_ptr) { |
|---|
| 2288 | 2356 | ret = -ENOMEM; |
|---|
| 2289 | 2357 | goto cleanup; |
|---|
| .. | .. |
|---|
| 2300 | 2368 | } |
|---|
| 2301 | 2369 | rx->buffer_info = (struct lan743x_rx_buffer_info *)cpu_ptr; |
|---|
| 2302 | 2370 | dma_ptr = 0; |
|---|
| 2303 | | - cpu_ptr = pci_zalloc_consistent(rx->adapter->pdev, |
|---|
| 2304 | | - sizeof(*rx->head_cpu_ptr), &dma_ptr); |
|---|
| 2371 | + cpu_ptr = dma_alloc_coherent(&rx->adapter->pdev->dev, |
|---|
| 2372 | + sizeof(*rx->head_cpu_ptr), &dma_ptr, |
|---|
| 2373 | + GFP_KERNEL); |
|---|
| 2305 | 2374 | if (!cpu_ptr) { |
|---|
| 2306 | 2375 | ret = -ENOMEM; |
|---|
| 2307 | 2376 | goto cleanup; |
|---|
| .. | .. |
|---|
| 2316 | 2385 | |
|---|
| 2317 | 2386 | rx->last_head = 0; |
|---|
| 2318 | 2387 | for (index = 0; index < rx->ring_size; index++) { |
|---|
| 2319 | | - struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx); |
|---|
| 2388 | + struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx, |
|---|
| 2389 | + GFP_KERNEL); |
|---|
| 2320 | 2390 | |
|---|
| 2321 | 2391 | ret = lan743x_rx_init_ring_element(rx, index, new_skb); |
|---|
| 2322 | 2392 | if (ret) |
|---|
| .. | .. |
|---|
| 2367 | 2437 | |
|---|
| 2368 | 2438 | netif_napi_add(adapter->netdev, |
|---|
| 2369 | 2439 | &rx->napi, lan743x_rx_napi_poll, |
|---|
| 2370 | | - rx->ring_size - 1); |
|---|
| 2440 | + NAPI_POLL_WEIGHT); |
|---|
| 2371 | 2441 | |
|---|
| 2372 | 2442 | lan743x_csr_write(adapter, DMAC_CMD, |
|---|
| 2373 | 2443 | DMAC_CMD_RX_SWR_(rx->channel_number)); |
|---|
| .. | .. |
|---|
| 2774 | 2844 | { |
|---|
| 2775 | 2845 | struct lan743x_adapter *adapter = NULL; |
|---|
| 2776 | 2846 | struct net_device *netdev = NULL; |
|---|
| 2847 | + const void *mac_addr; |
|---|
| 2777 | 2848 | int ret = -ENODEV; |
|---|
| 2778 | 2849 | |
|---|
| 2779 | 2850 | netdev = devm_alloc_etherdev(&pdev->dev, |
|---|
| .. | .. |
|---|
| 2789 | 2860 | NETIF_MSG_LINK | NETIF_MSG_IFUP | |
|---|
| 2790 | 2861 | NETIF_MSG_IFDOWN | NETIF_MSG_TX_QUEUED; |
|---|
| 2791 | 2862 | netdev->max_mtu = LAN743X_MAX_FRAME_SIZE; |
|---|
| 2863 | + |
|---|
| 2864 | + mac_addr = of_get_mac_address(pdev->dev.of_node); |
|---|
| 2865 | + if (!IS_ERR(mac_addr)) |
|---|
| 2866 | + ether_addr_copy(adapter->mac_address, mac_addr); |
|---|
| 2792 | 2867 | |
|---|
| 2793 | 2868 | ret = lan743x_pci_init(adapter, pdev); |
|---|
| 2794 | 2869 | if (ret) |
|---|
| .. | .. |
|---|
| 2990 | 3065 | struct pci_dev *pdev = to_pci_dev(dev); |
|---|
| 2991 | 3066 | struct net_device *netdev = pci_get_drvdata(pdev); |
|---|
| 2992 | 3067 | struct lan743x_adapter *adapter = netdev_priv(netdev); |
|---|
| 2993 | | - int ret; |
|---|
| 2994 | 3068 | |
|---|
| 2995 | 3069 | lan743x_pcidev_shutdown(pdev); |
|---|
| 2996 | 3070 | |
|---|
| .. | .. |
|---|
| 3003 | 3077 | lan743x_pm_set_wol(adapter); |
|---|
| 3004 | 3078 | |
|---|
| 3005 | 3079 | /* Host sets PME_En, put D3hot */ |
|---|
| 3006 | | - ret = pci_prepare_to_sleep(pdev); |
|---|
| 3007 | | - |
|---|
| 3008 | | - return 0; |
|---|
| 3080 | + return pci_prepare_to_sleep(pdev);; |
|---|
| 3009 | 3081 | } |
|---|
| 3010 | 3082 | |
|---|
| 3011 | 3083 | static int lan743x_pm_resume(struct device *dev) |
|---|
| .. | .. |
|---|
| 3050 | 3122 | { 0, } |
|---|
| 3051 | 3123 | }; |
|---|
| 3052 | 3124 | |
|---|
| 3125 | +MODULE_DEVICE_TABLE(pci, lan743x_pcidev_tbl); |
|---|
| 3126 | + |
|---|
| 3053 | 3127 | static struct pci_driver lan743x_pcidev_driver = { |
|---|
| 3054 | 3128 | .name = DRIVER_NAME, |
|---|
| 3055 | 3129 | .id_table = lan743x_pcidev_tbl, |
|---|