diff options
Diffstat (limited to 'drivers/net')
161 files changed, 11761 insertions, 799 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 712776089b46..e19ca4bb7510 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -1741,6 +1741,7 @@ config KS8851 | |||
1741 | config KS8851_MLL | 1741 | config KS8851_MLL |
1742 | tristate "Micrel KS8851 MLL" | 1742 | tristate "Micrel KS8851 MLL" |
1743 | depends on HAS_IOMEM | 1743 | depends on HAS_IOMEM |
1744 | select MII | ||
1744 | help | 1745 | help |
1745 | This platform driver is for Micrel KS8851 Address/data bus | 1746 | This platform driver is for Micrel KS8851 Address/data bus |
1746 | multiplexed network chip. | 1747 | multiplexed network chip. |
@@ -2482,6 +2483,8 @@ config S6GMAC | |||
2482 | To compile this driver as a module, choose M here. The module | 2483 | To compile this driver as a module, choose M here. The module |
2483 | will be called s6gmac. | 2484 | will be called s6gmac. |
2484 | 2485 | ||
2486 | source "drivers/net/stmmac/Kconfig" | ||
2487 | |||
2485 | endif # NETDEV_1000 | 2488 | endif # NETDEV_1000 |
2486 | 2489 | ||
2487 | # | 2490 | # |
@@ -3230,4 +3233,12 @@ config VIRTIO_NET | |||
3230 | This is the virtual network driver for virtio. It can be used with | 3233 | This is the virtual network driver for virtio. It can be used with |
3231 | lguest or QEMU based VMMs (like KVM or Xen). Say Y or M. | 3234 | lguest or QEMU based VMMs (like KVM or Xen). Say Y or M. |
3232 | 3235 | ||
3236 | config VMXNET3 | ||
3237 | tristate "VMware VMXNET3 ethernet driver" | ||
3238 | depends on PCI && X86 && INET | ||
3239 | help | ||
3240 | This driver supports VMware's vmxnet3 virtual ethernet NIC. | ||
3241 | To compile this driver as a module, choose M here: the | ||
3242 | module will be called vmxnet3. | ||
3243 | |||
3233 | endif # NETDEVICES | 3244 | endif # NETDEVICES |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index d866b8cf65d1..246323d7f161 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -2,6 +2,10 @@ | |||
2 | # Makefile for the Linux network (ethercard) device drivers. | 2 | # Makefile for the Linux network (ethercard) device drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_MII) += mii.o | ||
6 | obj-$(CONFIG_MDIO) += mdio.o | ||
7 | obj-$(CONFIG_PHYLIB) += phy/ | ||
8 | |||
5 | obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o | 9 | obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o |
6 | 10 | ||
7 | obj-$(CONFIG_E1000) += e1000/ | 11 | obj-$(CONFIG_E1000) += e1000/ |
@@ -26,6 +30,7 @@ obj-$(CONFIG_TEHUTI) += tehuti.o | |||
26 | obj-$(CONFIG_ENIC) += enic/ | 30 | obj-$(CONFIG_ENIC) += enic/ |
27 | obj-$(CONFIG_JME) += jme.o | 31 | obj-$(CONFIG_JME) += jme.o |
28 | obj-$(CONFIG_BE2NET) += benet/ | 32 | obj-$(CONFIG_BE2NET) += benet/ |
33 | obj-$(CONFIG_VMXNET3) += vmxnet3/ | ||
29 | 34 | ||
30 | gianfar_driver-objs := gianfar.o \ | 35 | gianfar_driver-objs := gianfar.o \ |
31 | gianfar_ethtool.o \ | 36 | gianfar_ethtool.o \ |
@@ -95,15 +100,12 @@ obj-$(CONFIG_VIA_VELOCITY) += via-velocity.o | |||
95 | obj-$(CONFIG_ADAPTEC_STARFIRE) += starfire.o | 100 | obj-$(CONFIG_ADAPTEC_STARFIRE) += starfire.o |
96 | obj-$(CONFIG_RIONET) += rionet.o | 101 | obj-$(CONFIG_RIONET) += rionet.o |
97 | obj-$(CONFIG_SH_ETH) += sh_eth.o | 102 | obj-$(CONFIG_SH_ETH) += sh_eth.o |
103 | obj-$(CONFIG_STMMAC_ETH) += stmmac/ | ||
98 | 104 | ||
99 | # | 105 | # |
100 | # end link order section | 106 | # end link order section |
101 | # | 107 | # |
102 | 108 | ||
103 | obj-$(CONFIG_MII) += mii.o | ||
104 | obj-$(CONFIG_MDIO) += mdio.o | ||
105 | obj-$(CONFIG_PHYLIB) += phy/ | ||
106 | |||
107 | obj-$(CONFIG_SUNDANCE) += sundance.o | 109 | obj-$(CONFIG_SUNDANCE) += sundance.o |
108 | obj-$(CONFIG_HAMACHI) += hamachi.o | 110 | obj-$(CONFIG_HAMACHI) += hamachi.o |
109 | obj-$(CONFIG_NET) += Space.o loopback.o | 111 | obj-$(CONFIG_NET) += Space.o loopback.o |
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c index 5f0b05c2d71f..d82a9a994753 100644 --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c | |||
@@ -1209,7 +1209,8 @@ static int __devinit ace_init(struct net_device *dev) | |||
1209 | memset(ap->info, 0, sizeof(struct ace_info)); | 1209 | memset(ap->info, 0, sizeof(struct ace_info)); |
1210 | memset(ap->skb, 0, sizeof(struct ace_skb)); | 1210 | memset(ap->skb, 0, sizeof(struct ace_skb)); |
1211 | 1211 | ||
1212 | if (ace_load_firmware(dev)) | 1212 | ecode = ace_load_firmware(dev); |
1213 | if (ecode) | ||
1213 | goto init_error; | 1214 | goto init_error; |
1214 | 1215 | ||
1215 | ap->fw_running = 0; | 1216 | ap->fw_running = 0; |
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index fdf5937233fc..ce6f1ac25df8 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -34,6 +34,7 @@ | |||
34 | * | 34 | * |
35 | * | 35 | * |
36 | */ | 36 | */ |
37 | #include <linux/capability.h> | ||
37 | #include <linux/dma-mapping.h> | 38 | #include <linux/dma-mapping.h> |
38 | #include <linux/module.h> | 39 | #include <linux/module.h> |
39 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
@@ -721,7 +722,7 @@ static inline void update_rx_stats(struct net_device *dev, u32 status) | |||
721 | ps->rx_errors++; | 722 | ps->rx_errors++; |
722 | if (status & RX_MISSED_FRAME) | 723 | if (status & RX_MISSED_FRAME) |
723 | ps->rx_missed_errors++; | 724 | ps->rx_missed_errors++; |
724 | if (status & (RX_OVERLEN | RX_OVERLEN | RX_LEN_ERROR)) | 725 | if (status & (RX_OVERLEN | RX_RUNT | RX_LEN_ERROR)) |
725 | ps->rx_length_errors++; | 726 | ps->rx_length_errors++; |
726 | if (status & RX_CRC_ERROR) | 727 | if (status & RX_CRC_ERROR) |
727 | ps->rx_crc_errors++; | 728 | ps->rx_crc_errors++; |
@@ -794,8 +795,6 @@ static int au1000_rx(struct net_device *dev) | |||
794 | printk("rx len error\n"); | 795 | printk("rx len error\n"); |
795 | if (status & RX_U_CNTRL_FRAME) | 796 | if (status & RX_U_CNTRL_FRAME) |
796 | printk("rx u control frame\n"); | 797 | printk("rx u control frame\n"); |
797 | if (status & RX_MISSED_FRAME) | ||
798 | printk("rx miss\n"); | ||
799 | } | 798 | } |
800 | } | 799 | } |
801 | prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE); | 800 | prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE); |
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 79d35d122c08..28a0eda92680 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -243,15 +243,26 @@ static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage) | |||
243 | 243 | ||
244 | int be_cmd_POST(struct be_adapter *adapter) | 244 | int be_cmd_POST(struct be_adapter *adapter) |
245 | { | 245 | { |
246 | u16 stage, error; | 246 | u16 stage; |
247 | int status, timeout = 0; | ||
247 | 248 | ||
248 | error = be_POST_stage_get(adapter, &stage); | 249 | do { |
249 | if (error || stage != POST_STAGE_ARMFW_RDY) { | 250 | status = be_POST_stage_get(adapter, &stage); |
250 | dev_err(&adapter->pdev->dev, "POST failed.\n"); | 251 | if (status) { |
251 | return -1; | 252 | dev_err(&adapter->pdev->dev, "POST error; stage=0x%x\n", |
252 | } | 253 | stage); |
254 | return -1; | ||
255 | } else if (stage != POST_STAGE_ARMFW_RDY) { | ||
256 | set_current_state(TASK_INTERRUPTIBLE); | ||
257 | schedule_timeout(2 * HZ); | ||
258 | timeout += 2; | ||
259 | } else { | ||
260 | return 0; | ||
261 | } | ||
262 | } while (timeout < 20); | ||
253 | 263 | ||
254 | return 0; | 264 | dev_err(&adapter->pdev->dev, "POST timeout; stage=0x%x\n", stage); |
265 | return -1; | ||
255 | } | 266 | } |
256 | 267 | ||
257 | static inline void *embedded_payload(struct be_mcc_wrb *wrb) | 268 | static inline void *embedded_payload(struct be_mcc_wrb *wrb) |
@@ -729,8 +740,8 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, | |||
729 | /* Create an rx filtering policy configuration on an i/f | 740 | /* Create an rx filtering policy configuration on an i/f |
730 | * Uses mbox | 741 | * Uses mbox |
731 | */ | 742 | */ |
732 | int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, | 743 | int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, |
733 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id) | 744 | u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id) |
734 | { | 745 | { |
735 | struct be_mcc_wrb *wrb; | 746 | struct be_mcc_wrb *wrb; |
736 | struct be_cmd_req_if_create *req; | 747 | struct be_cmd_req_if_create *req; |
@@ -746,8 +757,8 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, | |||
746 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 757 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
747 | OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req)); | 758 | OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req)); |
748 | 759 | ||
749 | req->capability_flags = cpu_to_le32(flags); | 760 | req->capability_flags = cpu_to_le32(cap_flags); |
750 | req->enable_flags = cpu_to_le32(flags); | 761 | req->enable_flags = cpu_to_le32(en_flags); |
751 | req->pmac_invalid = pmac_invalid; | 762 | req->pmac_invalid = pmac_invalid; |
752 | if (!pmac_invalid) | 763 | if (!pmac_invalid) |
753 | memcpy(req->mac_addr, mac, ETH_ALEN); | 764 | memcpy(req->mac_addr, mac, ETH_ALEN); |
@@ -1129,7 +1140,6 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, | |||
1129 | spin_lock_bh(&adapter->mcc_lock); | 1140 | spin_lock_bh(&adapter->mcc_lock); |
1130 | 1141 | ||
1131 | wrb = wrb_from_mccq(adapter); | 1142 | wrb = wrb_from_mccq(adapter); |
1132 | req = embedded_payload(wrb); | ||
1133 | sge = nonembedded_sgl(wrb); | 1143 | sge = nonembedded_sgl(wrb); |
1134 | 1144 | ||
1135 | be_wrb_hdr_prepare(wrb, cmd->size, false, 1); | 1145 | be_wrb_hdr_prepare(wrb, cmd->size, false, 1); |
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index 8b4c2cb9ad62..49953787e41c 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -62,7 +62,7 @@ enum { | |||
62 | MCC_STATUS_QUEUE_FLUSHING = 0x4, | 62 | MCC_STATUS_QUEUE_FLUSHING = 0x4, |
63 | /* The command is completing with a DMA error */ | 63 | /* The command is completing with a DMA error */ |
64 | MCC_STATUS_DMA_FAILED = 0x5, | 64 | MCC_STATUS_DMA_FAILED = 0x5, |
65 | MCC_STATUS_NOT_SUPPORTED = 0x66 | 65 | MCC_STATUS_NOT_SUPPORTED = 66 |
66 | }; | 66 | }; |
67 | 67 | ||
68 | #define CQE_STATUS_COMPL_MASK 0xFFFF | 68 | #define CQE_STATUS_COMPL_MASK 0xFFFF |
@@ -720,8 +720,9 @@ extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, | |||
720 | extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, | 720 | extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
721 | u32 if_id, u32 *pmac_id); | 721 | u32 if_id, u32 *pmac_id); |
722 | extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id); | 722 | extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id); |
723 | extern int be_cmd_if_create(struct be_adapter *adapter, u32 if_flags, u8 *mac, | 723 | extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, |
724 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id); | 724 | u32 en_flags, u8 *mac, bool pmac_invalid, |
725 | u32 *if_handle, u32 *pmac_id); | ||
725 | extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle); | 726 | extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle); |
726 | extern int be_cmd_eq_create(struct be_adapter *adapter, | 727 | extern int be_cmd_eq_create(struct be_adapter *adapter, |
727 | struct be_queue_info *eq, int eq_delay); | 728 | struct be_queue_info *eq, int eq_delay); |
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c index 11445df3dbc0..cda5bf2fc50a 100644 --- a/drivers/net/benet/be_ethtool.c +++ b/drivers/net/benet/be_ethtool.c | |||
@@ -358,7 +358,7 @@ const struct ethtool_ops be_ethtool_ops = { | |||
358 | .get_rx_csum = be_get_rx_csum, | 358 | .get_rx_csum = be_get_rx_csum, |
359 | .set_rx_csum = be_set_rx_csum, | 359 | .set_rx_csum = be_set_rx_csum, |
360 | .get_tx_csum = ethtool_op_get_tx_csum, | 360 | .get_tx_csum = ethtool_op_get_tx_csum, |
361 | .set_tx_csum = ethtool_op_set_tx_csum, | 361 | .set_tx_csum = ethtool_op_set_tx_hw_csum, |
362 | .get_sg = ethtool_op_get_sg, | 362 | .get_sg = ethtool_op_get_sg, |
363 | .set_sg = ethtool_op_set_sg, | 363 | .set_sg = ethtool_op_set_sg, |
364 | .get_tso = ethtool_op_get_tso, | 364 | .get_tso = ethtool_op_get_tso, |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index 2f9b50156e0c..1f941f027718 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -197,7 +197,7 @@ void netdev_stats_update(struct be_adapter *adapter) | |||
197 | /* no space available in linux */ | 197 | /* no space available in linux */ |
198 | dev_stats->tx_dropped = 0; | 198 | dev_stats->tx_dropped = 0; |
199 | 199 | ||
200 | dev_stats->multicast = port_stats->tx_multicastframes; | 200 | dev_stats->multicast = port_stats->rx_multicast_frames; |
201 | dev_stats->collisions = 0; | 201 | dev_stats->collisions = 0; |
202 | 202 | ||
203 | /* detailed tx_errors */ | 203 | /* detailed tx_errors */ |
@@ -1620,19 +1620,22 @@ static int be_open(struct net_device *netdev) | |||
1620 | static int be_setup(struct be_adapter *adapter) | 1620 | static int be_setup(struct be_adapter *adapter) |
1621 | { | 1621 | { |
1622 | struct net_device *netdev = adapter->netdev; | 1622 | struct net_device *netdev = adapter->netdev; |
1623 | u32 if_flags; | 1623 | u32 cap_flags, en_flags; |
1624 | int status; | 1624 | int status; |
1625 | 1625 | ||
1626 | if_flags = BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PROMISCUOUS | | 1626 | cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | |
1627 | BE_IF_FLAGS_MCAST_PROMISCUOUS | BE_IF_FLAGS_UNTAGGED | | 1627 | BE_IF_FLAGS_MCAST_PROMISCUOUS | |
1628 | BE_IF_FLAGS_PASS_L3L4_ERRORS; | 1628 | BE_IF_FLAGS_PROMISCUOUS | |
1629 | status = be_cmd_if_create(adapter, if_flags, netdev->dev_addr, | 1629 | BE_IF_FLAGS_PASS_L3L4_ERRORS; |
1630 | false/* pmac_invalid */, &adapter->if_handle, | 1630 | en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | |
1631 | &adapter->pmac_id); | 1631 | BE_IF_FLAGS_PASS_L3L4_ERRORS; |
1632 | |||
1633 | status = be_cmd_if_create(adapter, cap_flags, en_flags, | ||
1634 | netdev->dev_addr, false/* pmac_invalid */, | ||
1635 | &adapter->if_handle, &adapter->pmac_id); | ||
1632 | if (status != 0) | 1636 | if (status != 0) |
1633 | goto do_none; | 1637 | goto do_none; |
1634 | 1638 | ||
1635 | |||
1636 | status = be_tx_queues_create(adapter); | 1639 | status = be_tx_queues_create(adapter); |
1637 | if (status != 0) | 1640 | if (status != 0) |
1638 | goto if_destroy; | 1641 | goto if_destroy; |
@@ -1899,8 +1902,8 @@ static void be_netdev_init(struct net_device *netdev) | |||
1899 | struct be_adapter *adapter = netdev_priv(netdev); | 1902 | struct be_adapter *adapter = netdev_priv(netdev); |
1900 | 1903 | ||
1901 | netdev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_RX | NETIF_F_TSO | | 1904 | netdev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_RX | NETIF_F_TSO | |
1902 | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER | NETIF_F_IP_CSUM | | 1905 | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER | NETIF_F_HW_CSUM | |
1903 | NETIF_F_IPV6_CSUM | NETIF_F_GRO; | 1906 | NETIF_F_GRO; |
1904 | 1907 | ||
1905 | netdev->flags |= IFF_MULTICAST; | 1908 | netdev->flags |= IFF_MULTICAST; |
1906 | 1909 | ||
@@ -2055,6 +2058,10 @@ static int be_hw_up(struct be_adapter *adapter) | |||
2055 | if (status) | 2058 | if (status) |
2056 | return status; | 2059 | return status; |
2057 | 2060 | ||
2061 | status = be_cmd_reset_function(adapter); | ||
2062 | if (status) | ||
2063 | return status; | ||
2064 | |||
2058 | status = be_cmd_get_fw_ver(adapter, adapter->fw_ver); | 2065 | status = be_cmd_get_fw_ver(adapter, adapter->fw_ver); |
2059 | if (status) | 2066 | if (status) |
2060 | return status; | 2067 | return status; |
@@ -2108,10 +2115,6 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
2108 | if (status) | 2115 | if (status) |
2109 | goto free_netdev; | 2116 | goto free_netdev; |
2110 | 2117 | ||
2111 | status = be_cmd_reset_function(adapter); | ||
2112 | if (status) | ||
2113 | goto ctrl_clean; | ||
2114 | |||
2115 | status = be_stats_init(adapter); | 2118 | status = be_stats_init(adapter); |
2116 | if (status) | 2119 | if (status) |
2117 | goto ctrl_clean; | 2120 | goto ctrl_clean; |
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h index 6c7f795d12de..a4d83409f205 100644 --- a/drivers/net/bnx2.h +++ b/drivers/net/bnx2.h | |||
@@ -361,9 +361,12 @@ struct l2_fhdr { | |||
361 | #define BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_VALUE (1<<28) | 361 | #define BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_VALUE (1<<28) |
362 | 362 | ||
363 | #define BNX2_L2CTX_HOST_BDIDX 0x00000004 | 363 | #define BNX2_L2CTX_HOST_BDIDX 0x00000004 |
364 | #define BNX2_L2CTX_STATUSB_NUM_SHIFT 16 | 364 | #define BNX2_L2CTX_L5_STATUSB_NUM_SHIFT 16 |
365 | #define BNX2_L2CTX_STATUSB_NUM(sb_id) \ | 365 | #define BNX2_L2CTX_L2_STATUSB_NUM_SHIFT 24 |
366 | (((sb_id) > 0) ? (((sb_id) + 7) << BNX2_L2CTX_STATUSB_NUM_SHIFT) : 0) | 366 | #define BNX2_L2CTX_L5_STATUSB_NUM(sb_id) \ |
367 | (((sb_id) > 0) ? (((sb_id) + 7) << BNX2_L2CTX_L5_STATUSB_NUM_SHIFT) : 0) | ||
368 | #define BNX2_L2CTX_L2_STATUSB_NUM(sb_id) \ | ||
369 | (((sb_id) > 0) ? (((sb_id) + 7) << BNX2_L2CTX_L2_STATUSB_NUM_SHIFT) : 0) | ||
367 | #define BNX2_L2CTX_HOST_BSEQ 0x00000008 | 370 | #define BNX2_L2CTX_HOST_BSEQ 0x00000008 |
368 | #define BNX2_L2CTX_NX_BSEQ 0x0000000c | 371 | #define BNX2_L2CTX_NX_BSEQ 0x0000000c |
369 | #define BNX2_L2CTX_NX_BDHADDR_HI 0x00000010 | 372 | #define BNX2_L2CTX_NX_BDHADDR_HI 0x00000010 |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 69c5b15e22da..40fb5eefc72e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -691,7 +691,7 @@ static int bond_check_dev_link(struct bonding *bond, | |||
691 | struct net_device *slave_dev, int reporting) | 691 | struct net_device *slave_dev, int reporting) |
692 | { | 692 | { |
693 | const struct net_device_ops *slave_ops = slave_dev->netdev_ops; | 693 | const struct net_device_ops *slave_ops = slave_dev->netdev_ops; |
694 | static int (*ioctl)(struct net_device *, struct ifreq *, int); | 694 | int (*ioctl)(struct net_device *, struct ifreq *, int); |
695 | struct ifreq ifr; | 695 | struct ifreq ifr; |
696 | struct mii_ioctl_data *mii; | 696 | struct mii_ioctl_data *mii; |
697 | 697 | ||
@@ -3665,10 +3665,10 @@ static int bond_xmit_hash_policy_l23(struct sk_buff *skb, | |||
3665 | 3665 | ||
3666 | if (skb->protocol == htons(ETH_P_IP)) { | 3666 | if (skb->protocol == htons(ETH_P_IP)) { |
3667 | return ((ntohl(iph->saddr ^ iph->daddr) & 0xffff) ^ | 3667 | return ((ntohl(iph->saddr ^ iph->daddr) & 0xffff) ^ |
3668 | (data->h_dest[5] ^ bond_dev->dev_addr[5])) % count; | 3668 | (data->h_dest[5] ^ data->h_source[5])) % count; |
3669 | } | 3669 | } |
3670 | 3670 | ||
3671 | return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count; | 3671 | return (data->h_dest[5] ^ data->h_source[5]) % count; |
3672 | } | 3672 | } |
3673 | 3673 | ||
3674 | /* | 3674 | /* |
@@ -3695,7 +3695,7 @@ static int bond_xmit_hash_policy_l34(struct sk_buff *skb, | |||
3695 | 3695 | ||
3696 | } | 3696 | } |
3697 | 3697 | ||
3698 | return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count; | 3698 | return (data->h_dest[5] ^ data->h_source[5]) % count; |
3699 | } | 3699 | } |
3700 | 3700 | ||
3701 | /* | 3701 | /* |
@@ -3706,7 +3706,7 @@ static int bond_xmit_hash_policy_l2(struct sk_buff *skb, | |||
3706 | { | 3706 | { |
3707 | struct ethhdr *data = (struct ethhdr *)skb->data; | 3707 | struct ethhdr *data = (struct ethhdr *)skb->data; |
3708 | 3708 | ||
3709 | return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count; | 3709 | return (data->h_dest[5] ^ data->h_source[5]) % count; |
3710 | } | 3710 | } |
3711 | 3711 | ||
3712 | /*-------------------------- Device entry points ----------------------------*/ | 3712 | /*-------------------------- Device entry points ----------------------------*/ |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index ff449de6f3c0..8762a27a2a18 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/sched.h> | ||
25 | #include <linux/sysdev.h> | 26 | #include <linux/sysdev.h> |
26 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
27 | #include <linux/types.h> | 28 | #include <linux/types.h> |
diff --git a/drivers/net/can/sja1000/sja1000_of_platform.c b/drivers/net/can/sja1000/sja1000_of_platform.c index 3373560405ba..9dd076a626a5 100644 --- a/drivers/net/can/sja1000/sja1000_of_platform.c +++ b/drivers/net/can/sja1000/sja1000_of_platform.c | |||
@@ -213,6 +213,7 @@ static struct of_device_id __devinitdata sja1000_ofp_table[] = { | |||
213 | {.compatible = "nxp,sja1000"}, | 213 | {.compatible = "nxp,sja1000"}, |
214 | {}, | 214 | {}, |
215 | }; | 215 | }; |
216 | MODULE_DEVICE_TABLE(of, sja1000_ofp_table); | ||
216 | 217 | ||
217 | static struct of_platform_driver sja1000_ofp_driver = { | 218 | static struct of_platform_driver sja1000_ofp_driver = { |
218 | .owner = THIS_MODULE, | 219 | .owner = THIS_MODULE, |
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 46c87ec7960c..3bf1b04f2cab 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
@@ -2264,9 +2264,9 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev) | |||
2264 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_CTX_TYPE, val); | 2264 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_CTX_TYPE, val); |
2265 | 2265 | ||
2266 | if (sb_id == 0) | 2266 | if (sb_id == 0) |
2267 | val = 2 << BNX2_L2CTX_STATUSB_NUM_SHIFT; | 2267 | val = 2 << BNX2_L2CTX_L2_STATUSB_NUM_SHIFT; |
2268 | else | 2268 | else |
2269 | val = BNX2_L2CTX_STATUSB_NUM(sb_id); | 2269 | val = BNX2_L2CTX_L2_STATUSB_NUM(sb_id); |
2270 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_HOST_BDIDX, val); | 2270 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_HOST_BDIDX, val); |
2271 | 2271 | ||
2272 | rxbd = (struct rx_bd *) (cp->l2_ring + BCM_PAGE_SIZE); | 2272 | rxbd = (struct rx_bd *) (cp->l2_ring + BCM_PAGE_SIZE); |
@@ -2423,7 +2423,7 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev) | |||
2423 | cp->int_num = 0; | 2423 | cp->int_num = 0; |
2424 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { | 2424 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { |
2425 | u32 sb_id = cp->status_blk_num; | 2425 | u32 sb_id = cp->status_blk_num; |
2426 | u32 sb = BNX2_L2CTX_STATUSB_NUM(sb_id); | 2426 | u32 sb = BNX2_L2CTX_L5_STATUSB_NUM(sb_id); |
2427 | 2427 | ||
2428 | cp->int_num = sb_id << BNX2_PCICFG_INT_ACK_CMD_INT_NUM_SHIFT; | 2428 | cp->int_num = sb_id << BNX2_PCICFG_INT_ACK_CMD_INT_NUM_SHIFT; |
2429 | cnic_ctx_wr(dev, cp->kwq_cid_addr, L5_KRNLQ_HOST_QIDX, sb); | 2429 | cnic_ctx_wr(dev, cp->kwq_cid_addr, L5_KRNLQ_HOST_QIDX, sb); |
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 65a2d0ba64e2..f72c56dec33c 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c | |||
@@ -333,6 +333,9 @@ static const char emac_version_string[] = "TI DaVinci EMAC Linux v6.1"; | |||
333 | #define EMAC_DM646X_MAC_EOI_C0_RXEN (0x01) | 333 | #define EMAC_DM646X_MAC_EOI_C0_RXEN (0x01) |
334 | #define EMAC_DM646X_MAC_EOI_C0_TXEN (0x02) | 334 | #define EMAC_DM646X_MAC_EOI_C0_TXEN (0x02) |
335 | 335 | ||
336 | /* EMAC Stats Clear Mask */ | ||
337 | #define EMAC_STATS_CLR_MASK (0xFFFFFFFF) | ||
338 | |||
336 | /** net_buf_obj: EMAC network bufferdata structure | 339 | /** net_buf_obj: EMAC network bufferdata structure |
337 | * | 340 | * |
338 | * EMAC network buffer data structure | 341 | * EMAC network buffer data structure |
@@ -2548,40 +2551,49 @@ static int emac_dev_stop(struct net_device *ndev) | |||
2548 | static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev) | 2551 | static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev) |
2549 | { | 2552 | { |
2550 | struct emac_priv *priv = netdev_priv(ndev); | 2553 | struct emac_priv *priv = netdev_priv(ndev); |
2554 | u32 mac_control; | ||
2555 | u32 stats_clear_mask; | ||
2551 | 2556 | ||
2552 | /* update emac hardware stats and reset the registers*/ | 2557 | /* update emac hardware stats and reset the registers*/ |
2553 | 2558 | ||
2559 | mac_control = emac_read(EMAC_MACCONTROL); | ||
2560 | |||
2561 | if (mac_control & EMAC_MACCONTROL_GMIIEN) | ||
2562 | stats_clear_mask = EMAC_STATS_CLR_MASK; | ||
2563 | else | ||
2564 | stats_clear_mask = 0; | ||
2565 | |||
2554 | priv->net_dev_stats.multicast += emac_read(EMAC_RXMCASTFRAMES); | 2566 | priv->net_dev_stats.multicast += emac_read(EMAC_RXMCASTFRAMES); |
2555 | emac_write(EMAC_RXMCASTFRAMES, EMAC_ALL_MULTI_REG_VALUE); | 2567 | emac_write(EMAC_RXMCASTFRAMES, stats_clear_mask); |
2556 | 2568 | ||
2557 | priv->net_dev_stats.collisions += (emac_read(EMAC_TXCOLLISION) + | 2569 | priv->net_dev_stats.collisions += (emac_read(EMAC_TXCOLLISION) + |
2558 | emac_read(EMAC_TXSINGLECOLL) + | 2570 | emac_read(EMAC_TXSINGLECOLL) + |
2559 | emac_read(EMAC_TXMULTICOLL)); | 2571 | emac_read(EMAC_TXMULTICOLL)); |
2560 | emac_write(EMAC_TXCOLLISION, EMAC_ALL_MULTI_REG_VALUE); | 2572 | emac_write(EMAC_TXCOLLISION, stats_clear_mask); |
2561 | emac_write(EMAC_TXSINGLECOLL, EMAC_ALL_MULTI_REG_VALUE); | 2573 | emac_write(EMAC_TXSINGLECOLL, stats_clear_mask); |
2562 | emac_write(EMAC_TXMULTICOLL, EMAC_ALL_MULTI_REG_VALUE); | 2574 | emac_write(EMAC_TXMULTICOLL, stats_clear_mask); |
2563 | 2575 | ||
2564 | priv->net_dev_stats.rx_length_errors += (emac_read(EMAC_RXOVERSIZED) + | 2576 | priv->net_dev_stats.rx_length_errors += (emac_read(EMAC_RXOVERSIZED) + |
2565 | emac_read(EMAC_RXJABBER) + | 2577 | emac_read(EMAC_RXJABBER) + |
2566 | emac_read(EMAC_RXUNDERSIZED)); | 2578 | emac_read(EMAC_RXUNDERSIZED)); |
2567 | emac_write(EMAC_RXOVERSIZED, EMAC_ALL_MULTI_REG_VALUE); | 2579 | emac_write(EMAC_RXOVERSIZED, stats_clear_mask); |
2568 | emac_write(EMAC_RXJABBER, EMAC_ALL_MULTI_REG_VALUE); | 2580 | emac_write(EMAC_RXJABBER, stats_clear_mask); |
2569 | emac_write(EMAC_RXUNDERSIZED, EMAC_ALL_MULTI_REG_VALUE); | 2581 | emac_write(EMAC_RXUNDERSIZED, stats_clear_mask); |
2570 | 2582 | ||
2571 | priv->net_dev_stats.rx_over_errors += (emac_read(EMAC_RXSOFOVERRUNS) + | 2583 | priv->net_dev_stats.rx_over_errors += (emac_read(EMAC_RXSOFOVERRUNS) + |
2572 | emac_read(EMAC_RXMOFOVERRUNS)); | 2584 | emac_read(EMAC_RXMOFOVERRUNS)); |
2573 | emac_write(EMAC_RXSOFOVERRUNS, EMAC_ALL_MULTI_REG_VALUE); | 2585 | emac_write(EMAC_RXSOFOVERRUNS, stats_clear_mask); |
2574 | emac_write(EMAC_RXMOFOVERRUNS, EMAC_ALL_MULTI_REG_VALUE); | 2586 | emac_write(EMAC_RXMOFOVERRUNS, stats_clear_mask); |
2575 | 2587 | ||
2576 | priv->net_dev_stats.rx_fifo_errors += emac_read(EMAC_RXDMAOVERRUNS); | 2588 | priv->net_dev_stats.rx_fifo_errors += emac_read(EMAC_RXDMAOVERRUNS); |
2577 | emac_write(EMAC_RXDMAOVERRUNS, EMAC_ALL_MULTI_REG_VALUE); | 2589 | emac_write(EMAC_RXDMAOVERRUNS, stats_clear_mask); |
2578 | 2590 | ||
2579 | priv->net_dev_stats.tx_carrier_errors += | 2591 | priv->net_dev_stats.tx_carrier_errors += |
2580 | emac_read(EMAC_TXCARRIERSENSE); | 2592 | emac_read(EMAC_TXCARRIERSENSE); |
2581 | emac_write(EMAC_TXCARRIERSENSE, EMAC_ALL_MULTI_REG_VALUE); | 2593 | emac_write(EMAC_TXCARRIERSENSE, stats_clear_mask); |
2582 | 2594 | ||
2583 | priv->net_dev_stats.tx_fifo_errors = emac_read(EMAC_TXUNDERRUN); | 2595 | priv->net_dev_stats.tx_fifo_errors = emac_read(EMAC_TXUNDERRUN); |
2584 | emac_write(EMAC_TXUNDERRUN, EMAC_ALL_MULTI_REG_VALUE); | 2596 | emac_write(EMAC_TXUNDERRUN, stats_clear_mask); |
2585 | 2597 | ||
2586 | return &priv->net_dev_stats; | 2598 | return &priv->net_dev_stats; |
2587 | } | 2599 | } |
diff --git a/drivers/net/depca.c b/drivers/net/depca.c index 9686c1fa28f1..7a3bdac84abe 100644 --- a/drivers/net/depca.c +++ b/drivers/net/depca.c | |||
@@ -237,6 +237,7 @@ | |||
237 | 237 | ||
238 | #include <linux/module.h> | 238 | #include <linux/module.h> |
239 | #include <linux/kernel.h> | 239 | #include <linux/kernel.h> |
240 | #include <linux/sched.h> | ||
240 | #include <linux/string.h> | 241 | #include <linux/string.h> |
241 | #include <linux/errno.h> | 242 | #include <linux/errno.h> |
242 | #include <linux/ioport.h> | 243 | #include <linux/ioport.h> |
diff --git a/drivers/net/dm9000.h b/drivers/net/dm9000.h index 80817c2edfb3..fb1c924d79b4 100644 --- a/drivers/net/dm9000.h +++ b/drivers/net/dm9000.h | |||
@@ -50,7 +50,7 @@ | |||
50 | #define DM9000_RCSR 0x32 | 50 | #define DM9000_RCSR 0x32 |
51 | 51 | ||
52 | #define CHIPR_DM9000A 0x19 | 52 | #define CHIPR_DM9000A 0x19 |
53 | #define CHIPR_DM9000B 0x1B | 53 | #define CHIPR_DM9000B 0x1A |
54 | 54 | ||
55 | #define DM9000_MRCMDX 0xF0 | 55 | #define DM9000_MRCMDX 0xF0 |
56 | #define DM9000_MRCMD 0xF2 | 56 | #define DM9000_MRCMD 0xF2 |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 679965c2bb86..5d2f48f02251 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -151,6 +151,7 @@ | |||
151 | #include <linux/moduleparam.h> | 151 | #include <linux/moduleparam.h> |
152 | #include <linux/kernel.h> | 152 | #include <linux/kernel.h> |
153 | #include <linux/types.h> | 153 | #include <linux/types.h> |
154 | #include <linux/sched.h> | ||
154 | #include <linux/slab.h> | 155 | #include <linux/slab.h> |
155 | #include <linux/delay.h> | 156 | #include <linux/delay.h> |
156 | #include <linux/init.h> | 157 | #include <linux/init.h> |
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c index b53b40ba88a8..d1e0563a67df 100644 --- a/drivers/net/e1000e/82571.c +++ b/drivers/net/e1000e/82571.c | |||
@@ -1803,7 +1803,7 @@ struct e1000_info e1000_82574_info = { | |||
1803 | | FLAG_HAS_AMT | 1803 | | FLAG_HAS_AMT |
1804 | | FLAG_HAS_CTRLEXT_ON_LOAD, | 1804 | | FLAG_HAS_CTRLEXT_ON_LOAD, |
1805 | .pba = 20, | 1805 | .pba = 20, |
1806 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, | 1806 | .max_hw_frame_size = DEFAULT_JUMBO, |
1807 | .get_variants = e1000_get_variants_82571, | 1807 | .get_variants = e1000_get_variants_82571, |
1808 | .mac_ops = &e82571_mac_ops, | 1808 | .mac_ops = &e82571_mac_ops, |
1809 | .phy_ops = &e82_phy_ops_bm, | 1809 | .phy_ops = &e82_phy_ops_bm, |
@@ -1820,7 +1820,7 @@ struct e1000_info e1000_82583_info = { | |||
1820 | | FLAG_HAS_AMT | 1820 | | FLAG_HAS_AMT |
1821 | | FLAG_HAS_CTRLEXT_ON_LOAD, | 1821 | | FLAG_HAS_CTRLEXT_ON_LOAD, |
1822 | .pba = 20, | 1822 | .pba = 20, |
1823 | .max_hw_frame_size = DEFAULT_JUMBO, | 1823 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, |
1824 | .get_variants = e1000_get_variants_82571, | 1824 | .get_variants = e1000_get_variants_82571, |
1825 | .mac_ops = &e82571_mac_ops, | 1825 | .mac_ops = &e82571_mac_ops, |
1826 | .phy_ops = &e82_phy_ops_bm, | 1826 | .phy_ops = &e82_phy_ops_bm, |
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index 981936c1fb46..405a144ebcad 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h | |||
@@ -519,9 +519,13 @@ extern s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw); | |||
519 | extern s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw); | 519 | extern s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw); |
520 | extern s32 e1000e_get_phy_info_igp(struct e1000_hw *hw); | 520 | extern s32 e1000e_get_phy_info_igp(struct e1000_hw *hw); |
521 | extern s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); | 521 | extern s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); |
522 | extern s32 e1000e_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, | ||
523 | u16 *data); | ||
522 | extern s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw); | 524 | extern s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw); |
523 | extern s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active); | 525 | extern s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active); |
524 | extern s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); | 526 | extern s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); |
527 | extern s32 e1000e_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, | ||
528 | u16 data); | ||
525 | extern s32 e1000e_phy_sw_reset(struct e1000_hw *hw); | 529 | extern s32 e1000e_phy_sw_reset(struct e1000_hw *hw); |
526 | extern s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw); | 530 | extern s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw); |
527 | extern s32 e1000e_get_cfg_done(struct e1000_hw *hw); | 531 | extern s32 e1000e_get_cfg_done(struct e1000_hw *hw); |
@@ -538,7 +542,11 @@ extern s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data); | |||
538 | extern s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data); | 542 | extern s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data); |
539 | extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); | 543 | extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); |
540 | extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); | 544 | extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); |
545 | extern s32 e1000e_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, | ||
546 | u16 data); | ||
541 | extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); | 547 | extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); |
548 | extern s32 e1000e_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, | ||
549 | u16 *data); | ||
542 | extern s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, | 550 | extern s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, |
543 | u32 usec_interval, bool *success); | 551 | u32 usec_interval, bool *success); |
544 | extern s32 e1000e_phy_reset_dsp(struct e1000_hw *hw); | 552 | extern s32 e1000e_phy_reset_dsp(struct e1000_hw *hw); |
@@ -546,7 +554,11 @@ extern s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data); | |||
546 | extern s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data); | 554 | extern s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data); |
547 | extern s32 e1000e_check_downshift(struct e1000_hw *hw); | 555 | extern s32 e1000e_check_downshift(struct e1000_hw *hw); |
548 | extern s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data); | 556 | extern s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data); |
557 | extern s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, | ||
558 | u16 *data); | ||
549 | extern s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data); | 559 | extern s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data); |
560 | extern s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, | ||
561 | u16 data); | ||
550 | extern s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow); | 562 | extern s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow); |
551 | extern s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw); | 563 | extern s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw); |
552 | extern s32 e1000_copper_link_setup_82577(struct e1000_hw *hw); | 564 | extern s32 e1000_copper_link_setup_82577(struct e1000_hw *hw); |
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h index fd44d9f90769..7b05cf47f7f5 100644 --- a/drivers/net/e1000e/hw.h +++ b/drivers/net/e1000e/hw.h | |||
@@ -764,11 +764,13 @@ struct e1000_phy_operations { | |||
764 | s32 (*get_cable_length)(struct e1000_hw *); | 764 | s32 (*get_cable_length)(struct e1000_hw *); |
765 | s32 (*get_phy_info)(struct e1000_hw *); | 765 | s32 (*get_phy_info)(struct e1000_hw *); |
766 | s32 (*read_phy_reg)(struct e1000_hw *, u32, u16 *); | 766 | s32 (*read_phy_reg)(struct e1000_hw *, u32, u16 *); |
767 | s32 (*read_phy_reg_locked)(struct e1000_hw *, u32, u16 *); | ||
767 | void (*release_phy)(struct e1000_hw *); | 768 | void (*release_phy)(struct e1000_hw *); |
768 | s32 (*reset_phy)(struct e1000_hw *); | 769 | s32 (*reset_phy)(struct e1000_hw *); |
769 | s32 (*set_d0_lplu_state)(struct e1000_hw *, bool); | 770 | s32 (*set_d0_lplu_state)(struct e1000_hw *, bool); |
770 | s32 (*set_d3_lplu_state)(struct e1000_hw *, bool); | 771 | s32 (*set_d3_lplu_state)(struct e1000_hw *, bool); |
771 | s32 (*write_phy_reg)(struct e1000_hw *, u32, u16); | 772 | s32 (*write_phy_reg)(struct e1000_hw *, u32, u16); |
773 | s32 (*write_phy_reg_locked)(struct e1000_hw *, u32, u16); | ||
772 | s32 (*cfg_on_link_up)(struct e1000_hw *); | 774 | s32 (*cfg_on_link_up)(struct e1000_hw *); |
773 | }; | 775 | }; |
774 | 776 | ||
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c index 99df2abf82a9..b6388b9535fd 100644 --- a/drivers/net/e1000e/ich8lan.c +++ b/drivers/net/e1000e/ich8lan.c | |||
@@ -122,6 +122,13 @@ | |||
122 | 122 | ||
123 | #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */ | 123 | #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */ |
124 | 124 | ||
125 | #define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */ | ||
126 | |||
127 | /* OEM Bits Phy Register */ | ||
128 | #define HV_OEM_BITS PHY_REG(768, 25) | ||
129 | #define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */ | ||
130 | #define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */ | ||
131 | |||
125 | /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ | 132 | /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ |
126 | /* Offset 04h HSFSTS */ | 133 | /* Offset 04h HSFSTS */ |
127 | union ich8_hws_flash_status { | 134 | union ich8_hws_flash_status { |
@@ -200,6 +207,7 @@ static s32 e1000_setup_led_pchlan(struct e1000_hw *hw); | |||
200 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw); | 207 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw); |
201 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw); | 208 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw); |
202 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw); | 209 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw); |
210 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active); | ||
203 | 211 | ||
204 | static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) | 212 | static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) |
205 | { | 213 | { |
@@ -242,7 +250,11 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) | |||
242 | 250 | ||
243 | phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan; | 251 | phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan; |
244 | phy->ops.read_phy_reg = e1000_read_phy_reg_hv; | 252 | phy->ops.read_phy_reg = e1000_read_phy_reg_hv; |
253 | phy->ops.read_phy_reg_locked = e1000_read_phy_reg_hv_locked; | ||
254 | phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan; | ||
255 | phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan; | ||
245 | phy->ops.write_phy_reg = e1000_write_phy_reg_hv; | 256 | phy->ops.write_phy_reg = e1000_write_phy_reg_hv; |
257 | phy->ops.write_phy_reg_locked = e1000_write_phy_reg_hv_locked; | ||
246 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; | 258 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
247 | 259 | ||
248 | phy->id = e1000_phy_unknown; | 260 | phy->id = e1000_phy_unknown; |
@@ -303,6 +315,8 @@ static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw) | |||
303 | case IGP03E1000_E_PHY_ID: | 315 | case IGP03E1000_E_PHY_ID: |
304 | phy->type = e1000_phy_igp_3; | 316 | phy->type = e1000_phy_igp_3; |
305 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; | 317 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
318 | phy->ops.read_phy_reg_locked = e1000e_read_phy_reg_igp_locked; | ||
319 | phy->ops.write_phy_reg_locked = e1000e_write_phy_reg_igp_locked; | ||
306 | break; | 320 | break; |
307 | case IFE_E_PHY_ID: | 321 | case IFE_E_PHY_ID: |
308 | case IFE_PLUS_E_PHY_ID: | 322 | case IFE_PLUS_E_PHY_ID: |
@@ -568,12 +582,39 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) | |||
568 | static DEFINE_MUTEX(nvm_mutex); | 582 | static DEFINE_MUTEX(nvm_mutex); |
569 | 583 | ||
570 | /** | 584 | /** |
585 | * e1000_acquire_nvm_ich8lan - Acquire NVM mutex | ||
586 | * @hw: pointer to the HW structure | ||
587 | * | ||
588 | * Acquires the mutex for performing NVM operations. | ||
589 | **/ | ||
590 | static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw) | ||
591 | { | ||
592 | mutex_lock(&nvm_mutex); | ||
593 | |||
594 | return 0; | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * e1000_release_nvm_ich8lan - Release NVM mutex | ||
599 | * @hw: pointer to the HW structure | ||
600 | * | ||
601 | * Releases the mutex used while performing NVM operations. | ||
602 | **/ | ||
603 | static void e1000_release_nvm_ich8lan(struct e1000_hw *hw) | ||
604 | { | ||
605 | mutex_unlock(&nvm_mutex); | ||
606 | |||
607 | return; | ||
608 | } | ||
609 | |||
610 | static DEFINE_MUTEX(swflag_mutex); | ||
611 | |||
612 | /** | ||
571 | * e1000_acquire_swflag_ich8lan - Acquire software control flag | 613 | * e1000_acquire_swflag_ich8lan - Acquire software control flag |
572 | * @hw: pointer to the HW structure | 614 | * @hw: pointer to the HW structure |
573 | * | 615 | * |
574 | * Acquires the software control flag for performing NVM and PHY | 616 | * Acquires the software control flag for performing PHY and select |
575 | * operations. This is a function pointer entry point only called by | 617 | * MAC CSR accesses. |
576 | * read/write routines for the PHY and NVM parts. | ||
577 | **/ | 618 | **/ |
578 | static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) | 619 | static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) |
579 | { | 620 | { |
@@ -582,7 +623,7 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) | |||
582 | 623 | ||
583 | might_sleep(); | 624 | might_sleep(); |
584 | 625 | ||
585 | mutex_lock(&nvm_mutex); | 626 | mutex_lock(&swflag_mutex); |
586 | 627 | ||
587 | while (timeout) { | 628 | while (timeout) { |
588 | extcnf_ctrl = er32(EXTCNF_CTRL); | 629 | extcnf_ctrl = er32(EXTCNF_CTRL); |
@@ -599,7 +640,7 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) | |||
599 | goto out; | 640 | goto out; |
600 | } | 641 | } |
601 | 642 | ||
602 | timeout = PHY_CFG_TIMEOUT * 2; | 643 | timeout = SW_FLAG_TIMEOUT; |
603 | 644 | ||
604 | extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; | 645 | extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; |
605 | ew32(EXTCNF_CTRL, extcnf_ctrl); | 646 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
@@ -623,7 +664,7 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) | |||
623 | 664 | ||
624 | out: | 665 | out: |
625 | if (ret_val) | 666 | if (ret_val) |
626 | mutex_unlock(&nvm_mutex); | 667 | mutex_unlock(&swflag_mutex); |
627 | 668 | ||
628 | return ret_val; | 669 | return ret_val; |
629 | } | 670 | } |
@@ -632,9 +673,8 @@ out: | |||
632 | * e1000_release_swflag_ich8lan - Release software control flag | 673 | * e1000_release_swflag_ich8lan - Release software control flag |
633 | * @hw: pointer to the HW structure | 674 | * @hw: pointer to the HW structure |
634 | * | 675 | * |
635 | * Releases the software control flag for performing NVM and PHY operations. | 676 | * Releases the software control flag for performing PHY and select |
636 | * This is a function pointer entry point only called by read/write | 677 | * MAC CSR accesses. |
637 | * routines for the PHY and NVM parts. | ||
638 | **/ | 678 | **/ |
639 | static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) | 679 | static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) |
640 | { | 680 | { |
@@ -644,7 +684,9 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) | |||
644 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; | 684 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
645 | ew32(EXTCNF_CTRL, extcnf_ctrl); | 685 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
646 | 686 | ||
647 | mutex_unlock(&nvm_mutex); | 687 | mutex_unlock(&swflag_mutex); |
688 | |||
689 | return; | ||
648 | } | 690 | } |
649 | 691 | ||
650 | /** | 692 | /** |
@@ -844,7 +886,7 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) | |||
844 | u32 i; | 886 | u32 i; |
845 | u32 data, cnf_size, cnf_base_addr, sw_cfg_mask; | 887 | u32 data, cnf_size, cnf_base_addr, sw_cfg_mask; |
846 | s32 ret_val; | 888 | s32 ret_val; |
847 | u16 word_addr, reg_data, reg_addr, phy_page = 0; | 889 | u16 reg, word_addr, reg_data, reg_addr, phy_page = 0; |
848 | 890 | ||
849 | ret_val = e1000e_phy_hw_reset_generic(hw); | 891 | ret_val = e1000e_phy_hw_reset_generic(hw); |
850 | if (ret_val) | 892 | if (ret_val) |
@@ -859,6 +901,10 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) | |||
859 | return ret_val; | 901 | return ret_val; |
860 | } | 902 | } |
861 | 903 | ||
904 | /* Dummy read to clear the phy wakeup bit after lcd reset */ | ||
905 | if (hw->mac.type == e1000_pchlan) | ||
906 | e1e_rphy(hw, BM_WUC, ®); | ||
907 | |||
862 | /* | 908 | /* |
863 | * Initialize the PHY from the NVM on ICH platforms. This | 909 | * Initialize the PHY from the NVM on ICH platforms. This |
864 | * is needed due to an issue where the NVM configuration is | 910 | * is needed due to an issue where the NVM configuration is |
@@ -1054,6 +1100,38 @@ static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw) | |||
1054 | } | 1100 | } |
1055 | 1101 | ||
1056 | /** | 1102 | /** |
1103 | * e1000_set_lplu_state_pchlan - Set Low Power Link Up state | ||
1104 | * @hw: pointer to the HW structure | ||
1105 | * @active: true to enable LPLU, false to disable | ||
1106 | * | ||
1107 | * Sets the LPLU state according to the active flag. For PCH, if OEM write | ||
1108 | * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set | ||
1109 | * the phy speed. This function will manually set the LPLU bit and restart | ||
1110 | * auto-neg as hw would do. D3 and D0 LPLU will call the same function | ||
1111 | * since it configures the same bit. | ||
1112 | **/ | ||
1113 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) | ||
1114 | { | ||
1115 | s32 ret_val = 0; | ||
1116 | u16 oem_reg; | ||
1117 | |||
1118 | ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg); | ||
1119 | if (ret_val) | ||
1120 | goto out; | ||
1121 | |||
1122 | if (active) | ||
1123 | oem_reg |= HV_OEM_BITS_LPLU; | ||
1124 | else | ||
1125 | oem_reg &= ~HV_OEM_BITS_LPLU; | ||
1126 | |||
1127 | oem_reg |= HV_OEM_BITS_RESTART_AN; | ||
1128 | ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg); | ||
1129 | |||
1130 | out: | ||
1131 | return ret_val; | ||
1132 | } | ||
1133 | |||
1134 | /** | ||
1057 | * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state | 1135 | * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state |
1058 | * @hw: pointer to the HW structure | 1136 | * @hw: pointer to the HW structure |
1059 | * @active: TRUE to enable LPLU, FALSE to disable | 1137 | * @active: TRUE to enable LPLU, FALSE to disable |
@@ -1314,12 +1392,11 @@ static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, | |||
1314 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || | 1392 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || |
1315 | (words == 0)) { | 1393 | (words == 0)) { |
1316 | hw_dbg(hw, "nvm parameter(s) out of bounds\n"); | 1394 | hw_dbg(hw, "nvm parameter(s) out of bounds\n"); |
1317 | return -E1000_ERR_NVM; | 1395 | ret_val = -E1000_ERR_NVM; |
1396 | goto out; | ||
1318 | } | 1397 | } |
1319 | 1398 | ||
1320 | ret_val = e1000_acquire_swflag_ich8lan(hw); | 1399 | nvm->ops.acquire_nvm(hw); |
1321 | if (ret_val) | ||
1322 | goto out; | ||
1323 | 1400 | ||
1324 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); | 1401 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); |
1325 | if (ret_val) { | 1402 | if (ret_val) { |
@@ -1345,7 +1422,7 @@ static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, | |||
1345 | } | 1422 | } |
1346 | } | 1423 | } |
1347 | 1424 | ||
1348 | e1000_release_swflag_ich8lan(hw); | 1425 | nvm->ops.release_nvm(hw); |
1349 | 1426 | ||
1350 | out: | 1427 | out: |
1351 | if (ret_val) | 1428 | if (ret_val) |
@@ -1603,11 +1680,15 @@ static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, | |||
1603 | return -E1000_ERR_NVM; | 1680 | return -E1000_ERR_NVM; |
1604 | } | 1681 | } |
1605 | 1682 | ||
1683 | nvm->ops.acquire_nvm(hw); | ||
1684 | |||
1606 | for (i = 0; i < words; i++) { | 1685 | for (i = 0; i < words; i++) { |
1607 | dev_spec->shadow_ram[offset+i].modified = 1; | 1686 | dev_spec->shadow_ram[offset+i].modified = 1; |
1608 | dev_spec->shadow_ram[offset+i].value = data[i]; | 1687 | dev_spec->shadow_ram[offset+i].value = data[i]; |
1609 | } | 1688 | } |
1610 | 1689 | ||
1690 | nvm->ops.release_nvm(hw); | ||
1691 | |||
1611 | return 0; | 1692 | return 0; |
1612 | } | 1693 | } |
1613 | 1694 | ||
@@ -1637,9 +1718,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1637 | if (nvm->type != e1000_nvm_flash_sw) | 1718 | if (nvm->type != e1000_nvm_flash_sw) |
1638 | goto out; | 1719 | goto out; |
1639 | 1720 | ||
1640 | ret_val = e1000_acquire_swflag_ich8lan(hw); | 1721 | nvm->ops.acquire_nvm(hw); |
1641 | if (ret_val) | ||
1642 | goto out; | ||
1643 | 1722 | ||
1644 | /* | 1723 | /* |
1645 | * We're writing to the opposite bank so if we're on bank 1, | 1724 | * We're writing to the opposite bank so if we're on bank 1, |
@@ -1657,7 +1736,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1657 | old_bank_offset = 0; | 1736 | old_bank_offset = 0; |
1658 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 1); | 1737 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 1); |
1659 | if (ret_val) { | 1738 | if (ret_val) { |
1660 | e1000_release_swflag_ich8lan(hw); | 1739 | nvm->ops.release_nvm(hw); |
1661 | goto out; | 1740 | goto out; |
1662 | } | 1741 | } |
1663 | } else { | 1742 | } else { |
@@ -1665,7 +1744,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1665 | new_bank_offset = 0; | 1744 | new_bank_offset = 0; |
1666 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 0); | 1745 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 0); |
1667 | if (ret_val) { | 1746 | if (ret_val) { |
1668 | e1000_release_swflag_ich8lan(hw); | 1747 | nvm->ops.release_nvm(hw); |
1669 | goto out; | 1748 | goto out; |
1670 | } | 1749 | } |
1671 | } | 1750 | } |
@@ -1723,7 +1802,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1723 | if (ret_val) { | 1802 | if (ret_val) { |
1724 | /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */ | 1803 | /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */ |
1725 | hw_dbg(hw, "Flash commit failed.\n"); | 1804 | hw_dbg(hw, "Flash commit failed.\n"); |
1726 | e1000_release_swflag_ich8lan(hw); | 1805 | nvm->ops.release_nvm(hw); |
1727 | goto out; | 1806 | goto out; |
1728 | } | 1807 | } |
1729 | 1808 | ||
@@ -1736,7 +1815,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1736 | act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD; | 1815 | act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD; |
1737 | ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data); | 1816 | ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data); |
1738 | if (ret_val) { | 1817 | if (ret_val) { |
1739 | e1000_release_swflag_ich8lan(hw); | 1818 | nvm->ops.release_nvm(hw); |
1740 | goto out; | 1819 | goto out; |
1741 | } | 1820 | } |
1742 | data &= 0xBFFF; | 1821 | data &= 0xBFFF; |
@@ -1744,7 +1823,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1744 | act_offset * 2 + 1, | 1823 | act_offset * 2 + 1, |
1745 | (u8)(data >> 8)); | 1824 | (u8)(data >> 8)); |
1746 | if (ret_val) { | 1825 | if (ret_val) { |
1747 | e1000_release_swflag_ich8lan(hw); | 1826 | nvm->ops.release_nvm(hw); |
1748 | goto out; | 1827 | goto out; |
1749 | } | 1828 | } |
1750 | 1829 | ||
@@ -1757,7 +1836,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1757 | act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1; | 1836 | act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1; |
1758 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0); | 1837 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0); |
1759 | if (ret_val) { | 1838 | if (ret_val) { |
1760 | e1000_release_swflag_ich8lan(hw); | 1839 | nvm->ops.release_nvm(hw); |
1761 | goto out; | 1840 | goto out; |
1762 | } | 1841 | } |
1763 | 1842 | ||
@@ -1767,7 +1846,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1767 | dev_spec->shadow_ram[i].value = 0xFFFF; | 1846 | dev_spec->shadow_ram[i].value = 0xFFFF; |
1768 | } | 1847 | } |
1769 | 1848 | ||
1770 | e1000_release_swflag_ich8lan(hw); | 1849 | nvm->ops.release_nvm(hw); |
1771 | 1850 | ||
1772 | /* | 1851 | /* |
1773 | * Reload the EEPROM, or else modifications will not appear | 1852 | * Reload the EEPROM, or else modifications will not appear |
@@ -1831,14 +1910,12 @@ static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw) | |||
1831 | **/ | 1910 | **/ |
1832 | void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw) | 1911 | void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw) |
1833 | { | 1912 | { |
1913 | struct e1000_nvm_info *nvm = &hw->nvm; | ||
1834 | union ich8_flash_protected_range pr0; | 1914 | union ich8_flash_protected_range pr0; |
1835 | union ich8_hws_flash_status hsfsts; | 1915 | union ich8_hws_flash_status hsfsts; |
1836 | u32 gfpreg; | 1916 | u32 gfpreg; |
1837 | s32 ret_val; | ||
1838 | 1917 | ||
1839 | ret_val = e1000_acquire_swflag_ich8lan(hw); | 1918 | nvm->ops.acquire_nvm(hw); |
1840 | if (ret_val) | ||
1841 | return; | ||
1842 | 1919 | ||
1843 | gfpreg = er32flash(ICH_FLASH_GFPREG); | 1920 | gfpreg = er32flash(ICH_FLASH_GFPREG); |
1844 | 1921 | ||
@@ -1859,7 +1936,7 @@ void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw) | |||
1859 | hsfsts.hsf_status.flockdn = true; | 1936 | hsfsts.hsf_status.flockdn = true; |
1860 | ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval); | 1937 | ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
1861 | 1938 | ||
1862 | e1000_release_swflag_ich8lan(hw); | 1939 | nvm->ops.release_nvm(hw); |
1863 | } | 1940 | } |
1864 | 1941 | ||
1865 | /** | 1942 | /** |
@@ -2229,6 +2306,7 @@ static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw) | |||
2229 | **/ | 2306 | **/ |
2230 | static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) | 2307 | static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) |
2231 | { | 2308 | { |
2309 | u16 reg; | ||
2232 | u32 ctrl, icr, kab; | 2310 | u32 ctrl, icr, kab; |
2233 | s32 ret_val; | 2311 | s32 ret_val; |
2234 | 2312 | ||
@@ -2304,6 +2382,9 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) | |||
2304 | hw_dbg(hw, "Auto Read Done did not complete\n"); | 2382 | hw_dbg(hw, "Auto Read Done did not complete\n"); |
2305 | } | 2383 | } |
2306 | } | 2384 | } |
2385 | /* Dummy read to clear the phy wakeup bit after lcd reset */ | ||
2386 | if (hw->mac.type == e1000_pchlan) | ||
2387 | e1e_rphy(hw, BM_WUC, ®); | ||
2307 | 2388 | ||
2308 | /* | 2389 | /* |
2309 | * For PCH, this write will make sure that any noise | 2390 | * For PCH, this write will make sure that any noise |
@@ -2843,9 +2924,8 @@ void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw) | |||
2843 | E1000_PHY_CTRL_GBE_DISABLE; | 2924 | E1000_PHY_CTRL_GBE_DISABLE; |
2844 | ew32(PHY_CTRL, phy_ctrl); | 2925 | ew32(PHY_CTRL, phy_ctrl); |
2845 | 2926 | ||
2846 | /* Workaround SWFLAG unexpectedly set during S0->Sx */ | ||
2847 | if (hw->mac.type == e1000_pchlan) | 2927 | if (hw->mac.type == e1000_pchlan) |
2848 | udelay(500); | 2928 | e1000_phy_hw_reset_ich8lan(hw); |
2849 | default: | 2929 | default: |
2850 | break; | 2930 | break; |
2851 | } | 2931 | } |
@@ -3113,9 +3193,9 @@ static struct e1000_phy_operations ich8_phy_ops = { | |||
3113 | }; | 3193 | }; |
3114 | 3194 | ||
3115 | static struct e1000_nvm_operations ich8_nvm_ops = { | 3195 | static struct e1000_nvm_operations ich8_nvm_ops = { |
3116 | .acquire_nvm = e1000_acquire_swflag_ich8lan, | 3196 | .acquire_nvm = e1000_acquire_nvm_ich8lan, |
3117 | .read_nvm = e1000_read_nvm_ich8lan, | 3197 | .read_nvm = e1000_read_nvm_ich8lan, |
3118 | .release_nvm = e1000_release_swflag_ich8lan, | 3198 | .release_nvm = e1000_release_nvm_ich8lan, |
3119 | .update_nvm = e1000_update_nvm_checksum_ich8lan, | 3199 | .update_nvm = e1000_update_nvm_checksum_ich8lan, |
3120 | .valid_led_default = e1000_valid_led_default_ich8lan, | 3200 | .valid_led_default = e1000_valid_led_default_ich8lan, |
3121 | .validate_nvm = e1000_validate_nvm_checksum_ich8lan, | 3201 | .validate_nvm = e1000_validate_nvm_checksum_ich8lan, |
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c index 994401fd0664..f9d33ab05e97 100644 --- a/drivers/net/e1000e/phy.c +++ b/drivers/net/e1000e/phy.c | |||
@@ -164,16 +164,25 @@ s32 e1000e_get_phy_id(struct e1000_hw *hw) | |||
164 | * MDIC mode. No harm in trying again in this case since | 164 | * MDIC mode. No harm in trying again in this case since |
165 | * the PHY ID is unknown at this point anyway | 165 | * the PHY ID is unknown at this point anyway |
166 | */ | 166 | */ |
167 | ret_val = phy->ops.acquire_phy(hw); | ||
168 | if (ret_val) | ||
169 | goto out; | ||
167 | ret_val = e1000_set_mdio_slow_mode_hv(hw, true); | 170 | ret_val = e1000_set_mdio_slow_mode_hv(hw, true); |
168 | if (ret_val) | 171 | if (ret_val) |
169 | goto out; | 172 | goto out; |
173 | phy->ops.release_phy(hw); | ||
170 | 174 | ||
171 | retry_count++; | 175 | retry_count++; |
172 | } | 176 | } |
173 | out: | 177 | out: |
174 | /* Revert to MDIO fast mode, if applicable */ | 178 | /* Revert to MDIO fast mode, if applicable */ |
175 | if (retry_count) | 179 | if (retry_count) { |
180 | ret_val = phy->ops.acquire_phy(hw); | ||
181 | if (ret_val) | ||
182 | return ret_val; | ||
176 | ret_val = e1000_set_mdio_slow_mode_hv(hw, false); | 183 | ret_val = e1000_set_mdio_slow_mode_hv(hw, false); |
184 | phy->ops.release_phy(hw); | ||
185 | } | ||
177 | 186 | ||
178 | return ret_val; | 187 | return ret_val; |
179 | } | 188 | } |
@@ -354,94 +363,173 @@ s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) | |||
354 | } | 363 | } |
355 | 364 | ||
356 | /** | 365 | /** |
357 | * e1000e_read_phy_reg_igp - Read igp PHY register | 366 | * __e1000e_read_phy_reg_igp - Read igp PHY register |
358 | * @hw: pointer to the HW structure | 367 | * @hw: pointer to the HW structure |
359 | * @offset: register offset to be read | 368 | * @offset: register offset to be read |
360 | * @data: pointer to the read data | 369 | * @data: pointer to the read data |
370 | * @locked: semaphore has already been acquired or not | ||
361 | * | 371 | * |
362 | * Acquires semaphore, if necessary, then reads the PHY register at offset | 372 | * Acquires semaphore, if necessary, then reads the PHY register at offset |
363 | * and storing the retrieved information in data. Release any acquired | 373 | * and stores the retrieved information in data. Release any acquired |
364 | * semaphores before exiting. | 374 | * semaphores before exiting. |
365 | **/ | 375 | **/ |
366 | s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) | 376 | static s32 __e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, |
377 | bool locked) | ||
367 | { | 378 | { |
368 | s32 ret_val; | 379 | s32 ret_val = 0; |
369 | 380 | ||
370 | ret_val = hw->phy.ops.acquire_phy(hw); | 381 | if (!locked) { |
371 | if (ret_val) | 382 | if (!(hw->phy.ops.acquire_phy)) |
372 | return ret_val; | 383 | goto out; |
384 | |||
385 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
386 | if (ret_val) | ||
387 | goto out; | ||
388 | } | ||
373 | 389 | ||
374 | if (offset > MAX_PHY_MULTI_PAGE_REG) { | 390 | if (offset > MAX_PHY_MULTI_PAGE_REG) { |
375 | ret_val = e1000e_write_phy_reg_mdic(hw, | 391 | ret_val = e1000e_write_phy_reg_mdic(hw, |
376 | IGP01E1000_PHY_PAGE_SELECT, | 392 | IGP01E1000_PHY_PAGE_SELECT, |
377 | (u16)offset); | 393 | (u16)offset); |
378 | if (ret_val) { | 394 | if (ret_val) |
379 | hw->phy.ops.release_phy(hw); | 395 | goto release; |
380 | return ret_val; | ||
381 | } | ||
382 | } | 396 | } |
383 | 397 | ||
384 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, | 398 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
385 | data); | 399 | data); |
386 | |||
387 | hw->phy.ops.release_phy(hw); | ||
388 | 400 | ||
401 | release: | ||
402 | if (!locked) | ||
403 | hw->phy.ops.release_phy(hw); | ||
404 | out: | ||
389 | return ret_val; | 405 | return ret_val; |
390 | } | 406 | } |
391 | 407 | ||
392 | /** | 408 | /** |
409 | * e1000e_read_phy_reg_igp - Read igp PHY register | ||
410 | * @hw: pointer to the HW structure | ||
411 | * @offset: register offset to be read | ||
412 | * @data: pointer to the read data | ||
413 | * | ||
414 | * Acquires semaphore then reads the PHY register at offset and stores the | ||
415 | * retrieved information in data. | ||
416 | * Release the acquired semaphore before exiting. | ||
417 | **/ | ||
418 | s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) | ||
419 | { | ||
420 | return __e1000e_read_phy_reg_igp(hw, offset, data, false); | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * e1000e_read_phy_reg_igp_locked - Read igp PHY register | ||
425 | * @hw: pointer to the HW structure | ||
426 | * @offset: register offset to be read | ||
427 | * @data: pointer to the read data | ||
428 | * | ||
429 | * Reads the PHY register at offset and stores the retrieved information | ||
430 | * in data. Assumes semaphore already acquired. | ||
431 | **/ | ||
432 | s32 e1000e_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data) | ||
433 | { | ||
434 | return __e1000e_read_phy_reg_igp(hw, offset, data, true); | ||
435 | } | ||
436 | |||
437 | /** | ||
393 | * e1000e_write_phy_reg_igp - Write igp PHY register | 438 | * e1000e_write_phy_reg_igp - Write igp PHY register |
394 | * @hw: pointer to the HW structure | 439 | * @hw: pointer to the HW structure |
395 | * @offset: register offset to write to | 440 | * @offset: register offset to write to |
396 | * @data: data to write at register offset | 441 | * @data: data to write at register offset |
442 | * @locked: semaphore has already been acquired or not | ||
397 | * | 443 | * |
398 | * Acquires semaphore, if necessary, then writes the data to PHY register | 444 | * Acquires semaphore, if necessary, then writes the data to PHY register |
399 | * at the offset. Release any acquired semaphores before exiting. | 445 | * at the offset. Release any acquired semaphores before exiting. |
400 | **/ | 446 | **/ |
401 | s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) | 447 | static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, |
448 | bool locked) | ||
402 | { | 449 | { |
403 | s32 ret_val; | 450 | s32 ret_val = 0; |
404 | 451 | ||
405 | ret_val = hw->phy.ops.acquire_phy(hw); | 452 | if (!locked) { |
406 | if (ret_val) | 453 | if (!(hw->phy.ops.acquire_phy)) |
407 | return ret_val; | 454 | goto out; |
455 | |||
456 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
457 | if (ret_val) | ||
458 | goto out; | ||
459 | } | ||
408 | 460 | ||
409 | if (offset > MAX_PHY_MULTI_PAGE_REG) { | 461 | if (offset > MAX_PHY_MULTI_PAGE_REG) { |
410 | ret_val = e1000e_write_phy_reg_mdic(hw, | 462 | ret_val = e1000e_write_phy_reg_mdic(hw, |
411 | IGP01E1000_PHY_PAGE_SELECT, | 463 | IGP01E1000_PHY_PAGE_SELECT, |
412 | (u16)offset); | 464 | (u16)offset); |
413 | if (ret_val) { | 465 | if (ret_val) |
414 | hw->phy.ops.release_phy(hw); | 466 | goto release; |
415 | return ret_val; | ||
416 | } | ||
417 | } | 467 | } |
418 | 468 | ||
419 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, | 469 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
420 | data); | 470 | data); |
421 | 471 | ||
422 | hw->phy.ops.release_phy(hw); | 472 | release: |
473 | if (!locked) | ||
474 | hw->phy.ops.release_phy(hw); | ||
423 | 475 | ||
476 | out: | ||
424 | return ret_val; | 477 | return ret_val; |
425 | } | 478 | } |
426 | 479 | ||
427 | /** | 480 | /** |
428 | * e1000e_read_kmrn_reg - Read kumeran register | 481 | * e1000e_write_phy_reg_igp - Write igp PHY register |
482 | * @hw: pointer to the HW structure | ||
483 | * @offset: register offset to write to | ||
484 | * @data: data to write at register offset | ||
485 | * | ||
486 | * Acquires semaphore then writes the data to PHY register | ||
487 | * at the offset. Release any acquired semaphores before exiting. | ||
488 | **/ | ||
489 | s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) | ||
490 | { | ||
491 | return __e1000e_write_phy_reg_igp(hw, offset, data, false); | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * e1000e_write_phy_reg_igp_locked - Write igp PHY register | ||
496 | * @hw: pointer to the HW structure | ||
497 | * @offset: register offset to write to | ||
498 | * @data: data to write at register offset | ||
499 | * | ||
500 | * Writes the data to PHY register at the offset. | ||
501 | * Assumes semaphore already acquired. | ||
502 | **/ | ||
503 | s32 e1000e_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data) | ||
504 | { | ||
505 | return __e1000e_write_phy_reg_igp(hw, offset, data, true); | ||
506 | } | ||
507 | |||
508 | /** | ||
509 | * __e1000_read_kmrn_reg - Read kumeran register | ||
429 | * @hw: pointer to the HW structure | 510 | * @hw: pointer to the HW structure |
430 | * @offset: register offset to be read | 511 | * @offset: register offset to be read |
431 | * @data: pointer to the read data | 512 | * @data: pointer to the read data |
513 | * @locked: semaphore has already been acquired or not | ||
432 | * | 514 | * |
433 | * Acquires semaphore, if necessary. Then reads the PHY register at offset | 515 | * Acquires semaphore, if necessary. Then reads the PHY register at offset |
434 | * using the kumeran interface. The information retrieved is stored in data. | 516 | * using the kumeran interface. The information retrieved is stored in data. |
435 | * Release any acquired semaphores before exiting. | 517 | * Release any acquired semaphores before exiting. |
436 | **/ | 518 | **/ |
437 | s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) | 519 | static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, |
520 | bool locked) | ||
438 | { | 521 | { |
439 | u32 kmrnctrlsta; | 522 | u32 kmrnctrlsta; |
440 | s32 ret_val; | 523 | s32 ret_val = 0; |
441 | 524 | ||
442 | ret_val = hw->phy.ops.acquire_phy(hw); | 525 | if (!locked) { |
443 | if (ret_val) | 526 | if (!(hw->phy.ops.acquire_phy)) |
444 | return ret_val; | 527 | goto out; |
528 | |||
529 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
530 | if (ret_val) | ||
531 | goto out; | ||
532 | } | ||
445 | 533 | ||
446 | kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & | 534 | kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & |
447 | E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN; | 535 | E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN; |
@@ -452,41 +540,111 @@ s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) | |||
452 | kmrnctrlsta = er32(KMRNCTRLSTA); | 540 | kmrnctrlsta = er32(KMRNCTRLSTA); |
453 | *data = (u16)kmrnctrlsta; | 541 | *data = (u16)kmrnctrlsta; |
454 | 542 | ||
455 | hw->phy.ops.release_phy(hw); | 543 | if (!locked) |
544 | hw->phy.ops.release_phy(hw); | ||
456 | 545 | ||
546 | out: | ||
457 | return ret_val; | 547 | return ret_val; |
458 | } | 548 | } |
459 | 549 | ||
460 | /** | 550 | /** |
461 | * e1000e_write_kmrn_reg - Write kumeran register | 551 | * e1000e_read_kmrn_reg - Read kumeran register |
552 | * @hw: pointer to the HW structure | ||
553 | * @offset: register offset to be read | ||
554 | * @data: pointer to the read data | ||
555 | * | ||
556 | * Acquires semaphore then reads the PHY register at offset using the | ||
557 | * kumeran interface. The information retrieved is stored in data. | ||
558 | * Release the acquired semaphore before exiting. | ||
559 | **/ | ||
560 | s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) | ||
561 | { | ||
562 | return __e1000_read_kmrn_reg(hw, offset, data, false); | ||
563 | } | ||
564 | |||
565 | /** | ||
566 | * e1000_read_kmrn_reg_locked - Read kumeran register | ||
567 | * @hw: pointer to the HW structure | ||
568 | * @offset: register offset to be read | ||
569 | * @data: pointer to the read data | ||
570 | * | ||
571 | * Reads the PHY register at offset using the kumeran interface. The | ||
572 | * information retrieved is stored in data. | ||
573 | * Assumes semaphore already acquired. | ||
574 | **/ | ||
575 | s32 e1000_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data) | ||
576 | { | ||
577 | return __e1000_read_kmrn_reg(hw, offset, data, true); | ||
578 | } | ||
579 | |||
580 | /** | ||
581 | * __e1000_write_kmrn_reg - Write kumeran register | ||
462 | * @hw: pointer to the HW structure | 582 | * @hw: pointer to the HW structure |
463 | * @offset: register offset to write to | 583 | * @offset: register offset to write to |
464 | * @data: data to write at register offset | 584 | * @data: data to write at register offset |
585 | * @locked: semaphore has already been acquired or not | ||
465 | * | 586 | * |
466 | * Acquires semaphore, if necessary. Then write the data to PHY register | 587 | * Acquires semaphore, if necessary. Then write the data to PHY register |
467 | * at the offset using the kumeran interface. Release any acquired semaphores | 588 | * at the offset using the kumeran interface. Release any acquired semaphores |
468 | * before exiting. | 589 | * before exiting. |
469 | **/ | 590 | **/ |
470 | s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) | 591 | static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, |
592 | bool locked) | ||
471 | { | 593 | { |
472 | u32 kmrnctrlsta; | 594 | u32 kmrnctrlsta; |
473 | s32 ret_val; | 595 | s32 ret_val = 0; |
474 | 596 | ||
475 | ret_val = hw->phy.ops.acquire_phy(hw); | 597 | if (!locked) { |
476 | if (ret_val) | 598 | if (!(hw->phy.ops.acquire_phy)) |
477 | return ret_val; | 599 | goto out; |
600 | |||
601 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
602 | if (ret_val) | ||
603 | goto out; | ||
604 | } | ||
478 | 605 | ||
479 | kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & | 606 | kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & |
480 | E1000_KMRNCTRLSTA_OFFSET) | data; | 607 | E1000_KMRNCTRLSTA_OFFSET) | data; |
481 | ew32(KMRNCTRLSTA, kmrnctrlsta); | 608 | ew32(KMRNCTRLSTA, kmrnctrlsta); |
482 | 609 | ||
483 | udelay(2); | 610 | udelay(2); |
484 | hw->phy.ops.release_phy(hw); | ||
485 | 611 | ||
612 | if (!locked) | ||
613 | hw->phy.ops.release_phy(hw); | ||
614 | |||
615 | out: | ||
486 | return ret_val; | 616 | return ret_val; |
487 | } | 617 | } |
488 | 618 | ||
489 | /** | 619 | /** |
620 | * e1000e_write_kmrn_reg - Write kumeran register | ||
621 | * @hw: pointer to the HW structure | ||
622 | * @offset: register offset to write to | ||
623 | * @data: data to write at register offset | ||
624 | * | ||
625 | * Acquires semaphore then writes the data to the PHY register at the offset | ||
626 | * using the kumeran interface. Release the acquired semaphore before exiting. | ||
627 | **/ | ||
628 | s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) | ||
629 | { | ||
630 | return __e1000_write_kmrn_reg(hw, offset, data, false); | ||
631 | } | ||
632 | |||
633 | /** | ||
634 | * e1000_write_kmrn_reg_locked - Write kumeran register | ||
635 | * @hw: pointer to the HW structure | ||
636 | * @offset: register offset to write to | ||
637 | * @data: data to write at register offset | ||
638 | * | ||
639 | * Write the data to PHY register at the offset using the kumeran interface. | ||
640 | * Assumes semaphore already acquired. | ||
641 | **/ | ||
642 | s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data) | ||
643 | { | ||
644 | return __e1000_write_kmrn_reg(hw, offset, data, true); | ||
645 | } | ||
646 | |||
647 | /** | ||
490 | * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link | 648 | * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link |
491 | * @hw: pointer to the HW structure | 649 | * @hw: pointer to the HW structure |
492 | * | 650 | * |
@@ -2105,6 +2263,10 @@ s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) | |||
2105 | u32 page = offset >> IGP_PAGE_SHIFT; | 2263 | u32 page = offset >> IGP_PAGE_SHIFT; |
2106 | u32 page_shift = 0; | 2264 | u32 page_shift = 0; |
2107 | 2265 | ||
2266 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2267 | if (ret_val) | ||
2268 | return ret_val; | ||
2269 | |||
2108 | /* Page 800 works differently than the rest so it has its own func */ | 2270 | /* Page 800 works differently than the rest so it has its own func */ |
2109 | if (page == BM_WUC_PAGE) { | 2271 | if (page == BM_WUC_PAGE) { |
2110 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, | 2272 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, |
@@ -2112,10 +2274,6 @@ s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) | |||
2112 | goto out; | 2274 | goto out; |
2113 | } | 2275 | } |
2114 | 2276 | ||
2115 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2116 | if (ret_val) | ||
2117 | goto out; | ||
2118 | |||
2119 | hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); | 2277 | hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); |
2120 | 2278 | ||
2121 | if (offset > MAX_PHY_MULTI_PAGE_REG) { | 2279 | if (offset > MAX_PHY_MULTI_PAGE_REG) { |
@@ -2135,18 +2293,15 @@ s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) | |||
2135 | /* Page is shifted left, PHY expects (page x 32) */ | 2293 | /* Page is shifted left, PHY expects (page x 32) */ |
2136 | ret_val = e1000e_write_phy_reg_mdic(hw, page_select, | 2294 | ret_val = e1000e_write_phy_reg_mdic(hw, page_select, |
2137 | (page << page_shift)); | 2295 | (page << page_shift)); |
2138 | if (ret_val) { | 2296 | if (ret_val) |
2139 | hw->phy.ops.release_phy(hw); | ||
2140 | goto out; | 2297 | goto out; |
2141 | } | ||
2142 | } | 2298 | } |
2143 | 2299 | ||
2144 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, | 2300 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
2145 | data); | 2301 | data); |
2146 | 2302 | ||
2147 | hw->phy.ops.release_phy(hw); | ||
2148 | |||
2149 | out: | 2303 | out: |
2304 | hw->phy.ops.release_phy(hw); | ||
2150 | return ret_val; | 2305 | return ret_val; |
2151 | } | 2306 | } |
2152 | 2307 | ||
@@ -2167,6 +2322,10 @@ s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) | |||
2167 | u32 page = offset >> IGP_PAGE_SHIFT; | 2322 | u32 page = offset >> IGP_PAGE_SHIFT; |
2168 | u32 page_shift = 0; | 2323 | u32 page_shift = 0; |
2169 | 2324 | ||
2325 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2326 | if (ret_val) | ||
2327 | return ret_val; | ||
2328 | |||
2170 | /* Page 800 works differently than the rest so it has its own func */ | 2329 | /* Page 800 works differently than the rest so it has its own func */ |
2171 | if (page == BM_WUC_PAGE) { | 2330 | if (page == BM_WUC_PAGE) { |
2172 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, | 2331 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, |
@@ -2174,10 +2333,6 @@ s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) | |||
2174 | goto out; | 2333 | goto out; |
2175 | } | 2334 | } |
2176 | 2335 | ||
2177 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2178 | if (ret_val) | ||
2179 | goto out; | ||
2180 | |||
2181 | hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); | 2336 | hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); |
2182 | 2337 | ||
2183 | if (offset > MAX_PHY_MULTI_PAGE_REG) { | 2338 | if (offset > MAX_PHY_MULTI_PAGE_REG) { |
@@ -2197,17 +2352,14 @@ s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) | |||
2197 | /* Page is shifted left, PHY expects (page x 32) */ | 2352 | /* Page is shifted left, PHY expects (page x 32) */ |
2198 | ret_val = e1000e_write_phy_reg_mdic(hw, page_select, | 2353 | ret_val = e1000e_write_phy_reg_mdic(hw, page_select, |
2199 | (page << page_shift)); | 2354 | (page << page_shift)); |
2200 | if (ret_val) { | 2355 | if (ret_val) |
2201 | hw->phy.ops.release_phy(hw); | ||
2202 | goto out; | 2356 | goto out; |
2203 | } | ||
2204 | } | 2357 | } |
2205 | 2358 | ||
2206 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, | 2359 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
2207 | data); | 2360 | data); |
2208 | hw->phy.ops.release_phy(hw); | ||
2209 | |||
2210 | out: | 2361 | out: |
2362 | hw->phy.ops.release_phy(hw); | ||
2211 | return ret_val; | 2363 | return ret_val; |
2212 | } | 2364 | } |
2213 | 2365 | ||
@@ -2226,17 +2378,17 @@ s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data) | |||
2226 | s32 ret_val; | 2378 | s32 ret_val; |
2227 | u16 page = (u16)(offset >> IGP_PAGE_SHIFT); | 2379 | u16 page = (u16)(offset >> IGP_PAGE_SHIFT); |
2228 | 2380 | ||
2381 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2382 | if (ret_val) | ||
2383 | return ret_val; | ||
2384 | |||
2229 | /* Page 800 works differently than the rest so it has its own func */ | 2385 | /* Page 800 works differently than the rest so it has its own func */ |
2230 | if (page == BM_WUC_PAGE) { | 2386 | if (page == BM_WUC_PAGE) { |
2231 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, | 2387 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, |
2232 | true); | 2388 | true); |
2233 | return ret_val; | 2389 | goto out; |
2234 | } | 2390 | } |
2235 | 2391 | ||
2236 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2237 | if (ret_val) | ||
2238 | return ret_val; | ||
2239 | |||
2240 | hw->phy.addr = 1; | 2392 | hw->phy.addr = 1; |
2241 | 2393 | ||
2242 | if (offset > MAX_PHY_MULTI_PAGE_REG) { | 2394 | if (offset > MAX_PHY_MULTI_PAGE_REG) { |
@@ -2245,16 +2397,14 @@ s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data) | |||
2245 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, | 2397 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, |
2246 | page); | 2398 | page); |
2247 | 2399 | ||
2248 | if (ret_val) { | 2400 | if (ret_val) |
2249 | hw->phy.ops.release_phy(hw); | 2401 | goto out; |
2250 | return ret_val; | ||
2251 | } | ||
2252 | } | 2402 | } |
2253 | 2403 | ||
2254 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, | 2404 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
2255 | data); | 2405 | data); |
2406 | out: | ||
2256 | hw->phy.ops.release_phy(hw); | 2407 | hw->phy.ops.release_phy(hw); |
2257 | |||
2258 | return ret_val; | 2408 | return ret_val; |
2259 | } | 2409 | } |
2260 | 2410 | ||
@@ -2272,17 +2422,17 @@ s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) | |||
2272 | s32 ret_val; | 2422 | s32 ret_val; |
2273 | u16 page = (u16)(offset >> IGP_PAGE_SHIFT); | 2423 | u16 page = (u16)(offset >> IGP_PAGE_SHIFT); |
2274 | 2424 | ||
2425 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2426 | if (ret_val) | ||
2427 | return ret_val; | ||
2428 | |||
2275 | /* Page 800 works differently than the rest so it has its own func */ | 2429 | /* Page 800 works differently than the rest so it has its own func */ |
2276 | if (page == BM_WUC_PAGE) { | 2430 | if (page == BM_WUC_PAGE) { |
2277 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, | 2431 | ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, |
2278 | false); | 2432 | false); |
2279 | return ret_val; | 2433 | goto out; |
2280 | } | 2434 | } |
2281 | 2435 | ||
2282 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2283 | if (ret_val) | ||
2284 | return ret_val; | ||
2285 | |||
2286 | hw->phy.addr = 1; | 2436 | hw->phy.addr = 1; |
2287 | 2437 | ||
2288 | if (offset > MAX_PHY_MULTI_PAGE_REG) { | 2438 | if (offset > MAX_PHY_MULTI_PAGE_REG) { |
@@ -2290,17 +2440,15 @@ s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) | |||
2290 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, | 2440 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT, |
2291 | page); | 2441 | page); |
2292 | 2442 | ||
2293 | if (ret_val) { | 2443 | if (ret_val) |
2294 | hw->phy.ops.release_phy(hw); | 2444 | goto out; |
2295 | return ret_val; | ||
2296 | } | ||
2297 | } | 2445 | } |
2298 | 2446 | ||
2299 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, | 2447 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, |
2300 | data); | 2448 | data); |
2301 | 2449 | ||
2450 | out: | ||
2302 | hw->phy.ops.release_phy(hw); | 2451 | hw->phy.ops.release_phy(hw); |
2303 | |||
2304 | return ret_val; | 2452 | return ret_val; |
2305 | } | 2453 | } |
2306 | 2454 | ||
@@ -2320,6 +2468,8 @@ s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) | |||
2320 | * 3) Write the address using the address opcode (0x11) | 2468 | * 3) Write the address using the address opcode (0x11) |
2321 | * 4) Read or write the data using the data opcode (0x12) | 2469 | * 4) Read or write the data using the data opcode (0x12) |
2322 | * 5) Restore 769_17.2 to its original value | 2470 | * 5) Restore 769_17.2 to its original value |
2471 | * | ||
2472 | * Assumes semaphore already acquired. | ||
2323 | **/ | 2473 | **/ |
2324 | static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, | 2474 | static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, |
2325 | u16 *data, bool read) | 2475 | u16 *data, bool read) |
@@ -2327,20 +2477,12 @@ static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, | |||
2327 | s32 ret_val; | 2477 | s32 ret_val; |
2328 | u16 reg = BM_PHY_REG_NUM(offset); | 2478 | u16 reg = BM_PHY_REG_NUM(offset); |
2329 | u16 phy_reg = 0; | 2479 | u16 phy_reg = 0; |
2330 | u8 phy_acquired = 1; | ||
2331 | |||
2332 | 2480 | ||
2333 | /* Gig must be disabled for MDIO accesses to page 800 */ | 2481 | /* Gig must be disabled for MDIO accesses to page 800 */ |
2334 | if ((hw->mac.type == e1000_pchlan) && | 2482 | if ((hw->mac.type == e1000_pchlan) && |
2335 | (!(er32(PHY_CTRL) & E1000_PHY_CTRL_GBE_DISABLE))) | 2483 | (!(er32(PHY_CTRL) & E1000_PHY_CTRL_GBE_DISABLE))) |
2336 | hw_dbg(hw, "Attempting to access page 800 while gig enabled\n"); | 2484 | hw_dbg(hw, "Attempting to access page 800 while gig enabled\n"); |
2337 | 2485 | ||
2338 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2339 | if (ret_val) { | ||
2340 | phy_acquired = 0; | ||
2341 | goto out; | ||
2342 | } | ||
2343 | |||
2344 | /* All operations in this function are phy address 1 */ | 2486 | /* All operations in this function are phy address 1 */ |
2345 | hw->phy.addr = 1; | 2487 | hw->phy.addr = 1; |
2346 | 2488 | ||
@@ -2397,8 +2539,6 @@ static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, | |||
2397 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg); | 2539 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg); |
2398 | 2540 | ||
2399 | out: | 2541 | out: |
2400 | if (phy_acquired == 1) | ||
2401 | hw->phy.ops.release_phy(hw); | ||
2402 | return ret_val; | 2542 | return ret_val; |
2403 | } | 2543 | } |
2404 | 2544 | ||
@@ -2439,52 +2579,63 @@ static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active) | |||
2439 | return 0; | 2579 | return 0; |
2440 | } | 2580 | } |
2441 | 2581 | ||
2582 | /** | ||
2583 | * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode | ||
2584 | * @hw: pointer to the HW structure | ||
2585 | * @slow: true for slow mode, false for normal mode | ||
2586 | * | ||
2587 | * Assumes semaphore already acquired. | ||
2588 | **/ | ||
2442 | s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow) | 2589 | s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw, bool slow) |
2443 | { | 2590 | { |
2444 | s32 ret_val = 0; | 2591 | s32 ret_val = 0; |
2445 | u16 data = 0; | 2592 | u16 data = 0; |
2446 | 2593 | ||
2447 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2448 | if (ret_val) | ||
2449 | return ret_val; | ||
2450 | |||
2451 | /* Set MDIO mode - page 769, register 16: 0x2580==slow, 0x2180==fast */ | 2594 | /* Set MDIO mode - page 769, register 16: 0x2580==slow, 0x2180==fast */ |
2452 | hw->phy.addr = 1; | 2595 | hw->phy.addr = 1; |
2453 | ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, | 2596 | ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, |
2454 | (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); | 2597 | (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); |
2455 | if (ret_val) { | 2598 | if (ret_val) |
2456 | hw->phy.ops.release_phy(hw); | 2599 | goto out; |
2457 | return ret_val; | 2600 | |
2458 | } | ||
2459 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_CS_CTRL1, | 2601 | ret_val = e1000e_write_phy_reg_mdic(hw, BM_CS_CTRL1, |
2460 | (0x2180 | (slow << 10))); | 2602 | (0x2180 | (slow << 10))); |
2603 | if (ret_val) | ||
2604 | goto out; | ||
2461 | 2605 | ||
2462 | /* dummy read when reverting to fast mode - throw away result */ | 2606 | /* dummy read when reverting to fast mode - throw away result */ |
2463 | if (!slow) | 2607 | if (!slow) |
2464 | e1000e_read_phy_reg_mdic(hw, BM_CS_CTRL1, &data); | 2608 | ret_val = e1000e_read_phy_reg_mdic(hw, BM_CS_CTRL1, &data); |
2465 | |||
2466 | hw->phy.ops.release_phy(hw); | ||
2467 | 2609 | ||
2610 | out: | ||
2468 | return ret_val; | 2611 | return ret_val; |
2469 | } | 2612 | } |
2470 | 2613 | ||
2471 | /** | 2614 | /** |
2472 | * e1000_read_phy_reg_hv - Read HV PHY register | 2615 | * __e1000_read_phy_reg_hv - Read HV PHY register |
2473 | * @hw: pointer to the HW structure | 2616 | * @hw: pointer to the HW structure |
2474 | * @offset: register offset to be read | 2617 | * @offset: register offset to be read |
2475 | * @data: pointer to the read data | 2618 | * @data: pointer to the read data |
2619 | * @locked: semaphore has already been acquired or not | ||
2476 | * | 2620 | * |
2477 | * Acquires semaphore, if necessary, then reads the PHY register at offset | 2621 | * Acquires semaphore, if necessary, then reads the PHY register at offset |
2478 | * and storing the retrieved information in data. Release any acquired | 2622 | * and stores the retrieved information in data. Release any acquired |
2479 | * semaphore before exiting. | 2623 | * semaphore before exiting. |
2480 | **/ | 2624 | **/ |
2481 | s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data) | 2625 | static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data, |
2626 | bool locked) | ||
2482 | { | 2627 | { |
2483 | s32 ret_val; | 2628 | s32 ret_val; |
2484 | u16 page = BM_PHY_REG_PAGE(offset); | 2629 | u16 page = BM_PHY_REG_PAGE(offset); |
2485 | u16 reg = BM_PHY_REG_NUM(offset); | 2630 | u16 reg = BM_PHY_REG_NUM(offset); |
2486 | bool in_slow_mode = false; | 2631 | bool in_slow_mode = false; |
2487 | 2632 | ||
2633 | if (!locked) { | ||
2634 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2635 | if (ret_val) | ||
2636 | return ret_val; | ||
2637 | } | ||
2638 | |||
2488 | /* Workaround failure in MDIO access while cable is disconnected */ | 2639 | /* Workaround failure in MDIO access while cable is disconnected */ |
2489 | if ((hw->phy.type == e1000_phy_82577) && | 2640 | if ((hw->phy.type == e1000_phy_82577) && |
2490 | !(er32(STATUS) & E1000_STATUS_LU)) { | 2641 | !(er32(STATUS) & E1000_STATUS_LU)) { |
@@ -2508,10 +2659,6 @@ s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data) | |||
2508 | goto out; | 2659 | goto out; |
2509 | } | 2660 | } |
2510 | 2661 | ||
2511 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2512 | if (ret_val) | ||
2513 | goto out; | ||
2514 | |||
2515 | hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); | 2662 | hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); |
2516 | 2663 | ||
2517 | if (page == HV_INTC_FC_PAGE_START) | 2664 | if (page == HV_INTC_FC_PAGE_START) |
@@ -2529,42 +2676,76 @@ s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data) | |||
2529 | ret_val = e1000e_write_phy_reg_mdic(hw, | 2676 | ret_val = e1000e_write_phy_reg_mdic(hw, |
2530 | IGP01E1000_PHY_PAGE_SELECT, | 2677 | IGP01E1000_PHY_PAGE_SELECT, |
2531 | (page << IGP_PAGE_SHIFT)); | 2678 | (page << IGP_PAGE_SHIFT)); |
2532 | if (ret_val) { | ||
2533 | hw->phy.ops.release_phy(hw); | ||
2534 | goto out; | ||
2535 | } | ||
2536 | hw->phy.addr = phy_addr; | 2679 | hw->phy.addr = phy_addr; |
2537 | } | 2680 | } |
2538 | } | 2681 | } |
2539 | 2682 | ||
2540 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg, | 2683 | ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg, |
2541 | data); | 2684 | data); |
2542 | hw->phy.ops.release_phy(hw); | ||
2543 | |||
2544 | out: | 2685 | out: |
2545 | /* Revert to MDIO fast mode, if applicable */ | 2686 | /* Revert to MDIO fast mode, if applicable */ |
2546 | if ((hw->phy.type == e1000_phy_82577) && in_slow_mode) | 2687 | if ((hw->phy.type == e1000_phy_82577) && in_slow_mode) |
2547 | ret_val = e1000_set_mdio_slow_mode_hv(hw, false); | 2688 | ret_val = e1000_set_mdio_slow_mode_hv(hw, false); |
2548 | 2689 | ||
2690 | if (!locked) | ||
2691 | hw->phy.ops.release_phy(hw); | ||
2692 | |||
2549 | return ret_val; | 2693 | return ret_val; |
2550 | } | 2694 | } |
2551 | 2695 | ||
2552 | /** | 2696 | /** |
2553 | * e1000_write_phy_reg_hv - Write HV PHY register | 2697 | * e1000_read_phy_reg_hv - Read HV PHY register |
2698 | * @hw: pointer to the HW structure | ||
2699 | * @offset: register offset to be read | ||
2700 | * @data: pointer to the read data | ||
2701 | * | ||
2702 | * Acquires semaphore then reads the PHY register at offset and stores | ||
2703 | * the retrieved information in data. Release the acquired semaphore | ||
2704 | * before exiting. | ||
2705 | **/ | ||
2706 | s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data) | ||
2707 | { | ||
2708 | return __e1000_read_phy_reg_hv(hw, offset, data, false); | ||
2709 | } | ||
2710 | |||
2711 | /** | ||
2712 | * e1000_read_phy_reg_hv_locked - Read HV PHY register | ||
2713 | * @hw: pointer to the HW structure | ||
2714 | * @offset: register offset to be read | ||
2715 | * @data: pointer to the read data | ||
2716 | * | ||
2717 | * Reads the PHY register at offset and stores the retrieved information | ||
2718 | * in data. Assumes semaphore already acquired. | ||
2719 | **/ | ||
2720 | s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data) | ||
2721 | { | ||
2722 | return __e1000_read_phy_reg_hv(hw, offset, data, true); | ||
2723 | } | ||
2724 | |||
2725 | /** | ||
2726 | * __e1000_write_phy_reg_hv - Write HV PHY register | ||
2554 | * @hw: pointer to the HW structure | 2727 | * @hw: pointer to the HW structure |
2555 | * @offset: register offset to write to | 2728 | * @offset: register offset to write to |
2556 | * @data: data to write at register offset | 2729 | * @data: data to write at register offset |
2730 | * @locked: semaphore has already been acquired or not | ||
2557 | * | 2731 | * |
2558 | * Acquires semaphore, if necessary, then writes the data to PHY register | 2732 | * Acquires semaphore, if necessary, then writes the data to PHY register |
2559 | * at the offset. Release any acquired semaphores before exiting. | 2733 | * at the offset. Release any acquired semaphores before exiting. |
2560 | **/ | 2734 | **/ |
2561 | s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) | 2735 | static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data, |
2736 | bool locked) | ||
2562 | { | 2737 | { |
2563 | s32 ret_val; | 2738 | s32 ret_val; |
2564 | u16 page = BM_PHY_REG_PAGE(offset); | 2739 | u16 page = BM_PHY_REG_PAGE(offset); |
2565 | u16 reg = BM_PHY_REG_NUM(offset); | 2740 | u16 reg = BM_PHY_REG_NUM(offset); |
2566 | bool in_slow_mode = false; | 2741 | bool in_slow_mode = false; |
2567 | 2742 | ||
2743 | if (!locked) { | ||
2744 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2745 | if (ret_val) | ||
2746 | return ret_val; | ||
2747 | } | ||
2748 | |||
2568 | /* Workaround failure in MDIO access while cable is disconnected */ | 2749 | /* Workaround failure in MDIO access while cable is disconnected */ |
2569 | if ((hw->phy.type == e1000_phy_82577) && | 2750 | if ((hw->phy.type == e1000_phy_82577) && |
2570 | !(er32(STATUS) & E1000_STATUS_LU)) { | 2751 | !(er32(STATUS) & E1000_STATUS_LU)) { |
@@ -2588,10 +2769,6 @@ s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) | |||
2588 | goto out; | 2769 | goto out; |
2589 | } | 2770 | } |
2590 | 2771 | ||
2591 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2592 | if (ret_val) | ||
2593 | goto out; | ||
2594 | |||
2595 | hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); | 2772 | hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); |
2596 | 2773 | ||
2597 | if (page == HV_INTC_FC_PAGE_START) | 2774 | if (page == HV_INTC_FC_PAGE_START) |
@@ -2607,15 +2784,10 @@ s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) | |||
2607 | ((MAX_PHY_REG_ADDRESS & reg) == 0) && | 2784 | ((MAX_PHY_REG_ADDRESS & reg) == 0) && |
2608 | (data & (1 << 11))) { | 2785 | (data & (1 << 11))) { |
2609 | u16 data2 = 0x7EFF; | 2786 | u16 data2 = 0x7EFF; |
2610 | hw->phy.ops.release_phy(hw); | ||
2611 | ret_val = e1000_access_phy_debug_regs_hv(hw, (1 << 6) | 0x3, | 2787 | ret_val = e1000_access_phy_debug_regs_hv(hw, (1 << 6) | 0x3, |
2612 | &data2, false); | 2788 | &data2, false); |
2613 | if (ret_val) | 2789 | if (ret_val) |
2614 | goto out; | 2790 | goto out; |
2615 | |||
2616 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2617 | if (ret_val) | ||
2618 | goto out; | ||
2619 | } | 2791 | } |
2620 | 2792 | ||
2621 | if (reg > MAX_PHY_MULTI_PAGE_REG) { | 2793 | if (reg > MAX_PHY_MULTI_PAGE_REG) { |
@@ -2630,27 +2802,53 @@ s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) | |||
2630 | ret_val = e1000e_write_phy_reg_mdic(hw, | 2802 | ret_val = e1000e_write_phy_reg_mdic(hw, |
2631 | IGP01E1000_PHY_PAGE_SELECT, | 2803 | IGP01E1000_PHY_PAGE_SELECT, |
2632 | (page << IGP_PAGE_SHIFT)); | 2804 | (page << IGP_PAGE_SHIFT)); |
2633 | if (ret_val) { | ||
2634 | hw->phy.ops.release_phy(hw); | ||
2635 | goto out; | ||
2636 | } | ||
2637 | hw->phy.addr = phy_addr; | 2805 | hw->phy.addr = phy_addr; |
2638 | } | 2806 | } |
2639 | } | 2807 | } |
2640 | 2808 | ||
2641 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg, | 2809 | ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & reg, |
2642 | data); | 2810 | data); |
2643 | hw->phy.ops.release_phy(hw); | ||
2644 | 2811 | ||
2645 | out: | 2812 | out: |
2646 | /* Revert to MDIO fast mode, if applicable */ | 2813 | /* Revert to MDIO fast mode, if applicable */ |
2647 | if ((hw->phy.type == e1000_phy_82577) && in_slow_mode) | 2814 | if ((hw->phy.type == e1000_phy_82577) && in_slow_mode) |
2648 | ret_val = e1000_set_mdio_slow_mode_hv(hw, false); | 2815 | ret_val = e1000_set_mdio_slow_mode_hv(hw, false); |
2649 | 2816 | ||
2817 | if (!locked) | ||
2818 | hw->phy.ops.release_phy(hw); | ||
2819 | |||
2650 | return ret_val; | 2820 | return ret_val; |
2651 | } | 2821 | } |
2652 | 2822 | ||
2653 | /** | 2823 | /** |
2824 | * e1000_write_phy_reg_hv - Write HV PHY register | ||
2825 | * @hw: pointer to the HW structure | ||
2826 | * @offset: register offset to write to | ||
2827 | * @data: data to write at register offset | ||
2828 | * | ||
2829 | * Acquires semaphore then writes the data to PHY register at the offset. | ||
2830 | * Release the acquired semaphores before exiting. | ||
2831 | **/ | ||
2832 | s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) | ||
2833 | { | ||
2834 | return __e1000_write_phy_reg_hv(hw, offset, data, false); | ||
2835 | } | ||
2836 | |||
2837 | /** | ||
2838 | * e1000_write_phy_reg_hv_locked - Write HV PHY register | ||
2839 | * @hw: pointer to the HW structure | ||
2840 | * @offset: register offset to write to | ||
2841 | * @data: data to write at register offset | ||
2842 | * | ||
2843 | * Writes the data to PHY register at the offset. Assumes semaphore | ||
2844 | * already acquired. | ||
2845 | **/ | ||
2846 | s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data) | ||
2847 | { | ||
2848 | return __e1000_write_phy_reg_hv(hw, offset, data, true); | ||
2849 | } | ||
2850 | |||
2851 | /** | ||
2654 | * e1000_get_phy_addr_for_hv_page - Get PHY adrress based on page | 2852 | * e1000_get_phy_addr_for_hv_page - Get PHY adrress based on page |
2655 | * @page: page to be accessed | 2853 | * @page: page to be accessed |
2656 | **/ | 2854 | **/ |
@@ -2671,10 +2869,9 @@ static u32 e1000_get_phy_addr_for_hv_page(u32 page) | |||
2671 | * @data: pointer to the data to be read or written | 2869 | * @data: pointer to the data to be read or written |
2672 | * @read: determines if operation is read or written | 2870 | * @read: determines if operation is read or written |
2673 | * | 2871 | * |
2674 | * Acquires semaphore, if necessary, then reads the PHY register at offset | 2872 | * Reads the PHY register at offset and stores the retreived information |
2675 | * and storing the retreived information in data. Release any acquired | 2873 | * in data. Assumes semaphore already acquired. Note that the procedure |
2676 | * semaphores before exiting. Note that the procedure to read these regs | 2874 | * to read these regs uses the address port and data port to read/write. |
2677 | * uses the address port and data port to read/write. | ||
2678 | **/ | 2875 | **/ |
2679 | static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, | 2876 | static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, |
2680 | u16 *data, bool read) | 2877 | u16 *data, bool read) |
@@ -2682,20 +2879,12 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, | |||
2682 | s32 ret_val; | 2879 | s32 ret_val; |
2683 | u32 addr_reg = 0; | 2880 | u32 addr_reg = 0; |
2684 | u32 data_reg = 0; | 2881 | u32 data_reg = 0; |
2685 | u8 phy_acquired = 1; | ||
2686 | 2882 | ||
2687 | /* This takes care of the difference with desktop vs mobile phy */ | 2883 | /* This takes care of the difference with desktop vs mobile phy */ |
2688 | addr_reg = (hw->phy.type == e1000_phy_82578) ? | 2884 | addr_reg = (hw->phy.type == e1000_phy_82578) ? |
2689 | I82578_ADDR_REG : I82577_ADDR_REG; | 2885 | I82578_ADDR_REG : I82577_ADDR_REG; |
2690 | data_reg = addr_reg + 1; | 2886 | data_reg = addr_reg + 1; |
2691 | 2887 | ||
2692 | ret_val = hw->phy.ops.acquire_phy(hw); | ||
2693 | if (ret_val) { | ||
2694 | hw_dbg(hw, "Could not acquire PHY\n"); | ||
2695 | phy_acquired = 0; | ||
2696 | goto out; | ||
2697 | } | ||
2698 | |||
2699 | /* All operations in this function are phy address 2 */ | 2888 | /* All operations in this function are phy address 2 */ |
2700 | hw->phy.addr = 2; | 2889 | hw->phy.addr = 2; |
2701 | 2890 | ||
@@ -2718,8 +2907,6 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, | |||
2718 | } | 2907 | } |
2719 | 2908 | ||
2720 | out: | 2909 | out: |
2721 | if (phy_acquired == 1) | ||
2722 | hw->phy.ops.release_phy(hw); | ||
2723 | return ret_val; | 2910 | return ret_val; |
2724 | } | 2911 | } |
2725 | 2912 | ||
diff --git a/drivers/net/eql.c b/drivers/net/eql.c index d4d9a3eda695..f5b96cadeb25 100644 --- a/drivers/net/eql.c +++ b/drivers/net/eql.c | |||
@@ -111,6 +111,7 @@ | |||
111 | * Sorry, I had to rewrite most of this for 2.5.x -DaveM | 111 | * Sorry, I had to rewrite most of this for 2.5.x -DaveM |
112 | */ | 112 | */ |
113 | 113 | ||
114 | #include <linux/capability.h> | ||
114 | #include <linux/module.h> | 115 | #include <linux/module.h> |
115 | #include <linux/kernel.h> | 116 | #include <linux/kernel.h> |
116 | #include <linux/init.h> | 117 | #include <linux/init.h> |
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index b7311bc00258..f7d9ac8324cb 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c | |||
@@ -17,8 +17,13 @@ | |||
17 | #include <linux/mii.h> | 17 | #include <linux/mii.h> |
18 | #include <linux/phy.h> | 18 | #include <linux/phy.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/sched.h> | ||
20 | #include <net/ethoc.h> | 21 | #include <net/ethoc.h> |
21 | 22 | ||
23 | static int buffer_size = 0x8000; /* 32 KBytes */ | ||
24 | module_param(buffer_size, int, 0); | ||
25 | MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size"); | ||
26 | |||
22 | /* register offsets */ | 27 | /* register offsets */ |
23 | #define MODER 0x00 | 28 | #define MODER 0x00 |
24 | #define INT_SOURCE 0x04 | 29 | #define INT_SOURCE 0x04 |
@@ -167,6 +172,7 @@ | |||
167 | * struct ethoc - driver-private device structure | 172 | * struct ethoc - driver-private device structure |
168 | * @iobase: pointer to I/O memory region | 173 | * @iobase: pointer to I/O memory region |
169 | * @membase: pointer to buffer memory region | 174 | * @membase: pointer to buffer memory region |
175 | * @dma_alloc: dma allocated buffer size | ||
170 | * @num_tx: number of send buffers | 176 | * @num_tx: number of send buffers |
171 | * @cur_tx: last send buffer written | 177 | * @cur_tx: last send buffer written |
172 | * @dty_tx: last buffer actually sent | 178 | * @dty_tx: last buffer actually sent |
@@ -185,6 +191,7 @@ | |||
185 | struct ethoc { | 191 | struct ethoc { |
186 | void __iomem *iobase; | 192 | void __iomem *iobase; |
187 | void __iomem *membase; | 193 | void __iomem *membase; |
194 | int dma_alloc; | ||
188 | 195 | ||
189 | unsigned int num_tx; | 196 | unsigned int num_tx; |
190 | unsigned int cur_tx; | 197 | unsigned int cur_tx; |
@@ -216,24 +223,25 @@ struct ethoc_bd { | |||
216 | u32 addr; | 223 | u32 addr; |
217 | }; | 224 | }; |
218 | 225 | ||
219 | static u32 ethoc_read(struct ethoc *dev, loff_t offset) | 226 | static inline u32 ethoc_read(struct ethoc *dev, loff_t offset) |
220 | { | 227 | { |
221 | return ioread32(dev->iobase + offset); | 228 | return ioread32(dev->iobase + offset); |
222 | } | 229 | } |
223 | 230 | ||
224 | static void ethoc_write(struct ethoc *dev, loff_t offset, u32 data) | 231 | static inline void ethoc_write(struct ethoc *dev, loff_t offset, u32 data) |
225 | { | 232 | { |
226 | iowrite32(data, dev->iobase + offset); | 233 | iowrite32(data, dev->iobase + offset); |
227 | } | 234 | } |
228 | 235 | ||
229 | static void ethoc_read_bd(struct ethoc *dev, int index, struct ethoc_bd *bd) | 236 | static inline void ethoc_read_bd(struct ethoc *dev, int index, |
237 | struct ethoc_bd *bd) | ||
230 | { | 238 | { |
231 | loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd)); | 239 | loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd)); |
232 | bd->stat = ethoc_read(dev, offset + 0); | 240 | bd->stat = ethoc_read(dev, offset + 0); |
233 | bd->addr = ethoc_read(dev, offset + 4); | 241 | bd->addr = ethoc_read(dev, offset + 4); |
234 | } | 242 | } |
235 | 243 | ||
236 | static void ethoc_write_bd(struct ethoc *dev, int index, | 244 | static inline void ethoc_write_bd(struct ethoc *dev, int index, |
237 | const struct ethoc_bd *bd) | 245 | const struct ethoc_bd *bd) |
238 | { | 246 | { |
239 | loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd)); | 247 | loff_t offset = ETHOC_BD_BASE + (index * sizeof(struct ethoc_bd)); |
@@ -241,33 +249,33 @@ static void ethoc_write_bd(struct ethoc *dev, int index, | |||
241 | ethoc_write(dev, offset + 4, bd->addr); | 249 | ethoc_write(dev, offset + 4, bd->addr); |
242 | } | 250 | } |
243 | 251 | ||
244 | static void ethoc_enable_irq(struct ethoc *dev, u32 mask) | 252 | static inline void ethoc_enable_irq(struct ethoc *dev, u32 mask) |
245 | { | 253 | { |
246 | u32 imask = ethoc_read(dev, INT_MASK); | 254 | u32 imask = ethoc_read(dev, INT_MASK); |
247 | imask |= mask; | 255 | imask |= mask; |
248 | ethoc_write(dev, INT_MASK, imask); | 256 | ethoc_write(dev, INT_MASK, imask); |
249 | } | 257 | } |
250 | 258 | ||
251 | static void ethoc_disable_irq(struct ethoc *dev, u32 mask) | 259 | static inline void ethoc_disable_irq(struct ethoc *dev, u32 mask) |
252 | { | 260 | { |
253 | u32 imask = ethoc_read(dev, INT_MASK); | 261 | u32 imask = ethoc_read(dev, INT_MASK); |
254 | imask &= ~mask; | 262 | imask &= ~mask; |
255 | ethoc_write(dev, INT_MASK, imask); | 263 | ethoc_write(dev, INT_MASK, imask); |
256 | } | 264 | } |
257 | 265 | ||
258 | static void ethoc_ack_irq(struct ethoc *dev, u32 mask) | 266 | static inline void ethoc_ack_irq(struct ethoc *dev, u32 mask) |
259 | { | 267 | { |
260 | ethoc_write(dev, INT_SOURCE, mask); | 268 | ethoc_write(dev, INT_SOURCE, mask); |
261 | } | 269 | } |
262 | 270 | ||
263 | static void ethoc_enable_rx_and_tx(struct ethoc *dev) | 271 | static inline void ethoc_enable_rx_and_tx(struct ethoc *dev) |
264 | { | 272 | { |
265 | u32 mode = ethoc_read(dev, MODER); | 273 | u32 mode = ethoc_read(dev, MODER); |
266 | mode |= MODER_RXEN | MODER_TXEN; | 274 | mode |= MODER_RXEN | MODER_TXEN; |
267 | ethoc_write(dev, MODER, mode); | 275 | ethoc_write(dev, MODER, mode); |
268 | } | 276 | } |
269 | 277 | ||
270 | static void ethoc_disable_rx_and_tx(struct ethoc *dev) | 278 | static inline void ethoc_disable_rx_and_tx(struct ethoc *dev) |
271 | { | 279 | { |
272 | u32 mode = ethoc_read(dev, MODER); | 280 | u32 mode = ethoc_read(dev, MODER); |
273 | mode &= ~(MODER_RXEN | MODER_TXEN); | 281 | mode &= ~(MODER_RXEN | MODER_TXEN); |
@@ -284,7 +292,7 @@ static int ethoc_init_ring(struct ethoc *dev) | |||
284 | dev->cur_rx = 0; | 292 | dev->cur_rx = 0; |
285 | 293 | ||
286 | /* setup transmission buffers */ | 294 | /* setup transmission buffers */ |
287 | bd.addr = 0; | 295 | bd.addr = virt_to_phys(dev->membase); |
288 | bd.stat = TX_BD_IRQ | TX_BD_CRC; | 296 | bd.stat = TX_BD_IRQ | TX_BD_CRC; |
289 | 297 | ||
290 | for (i = 0; i < dev->num_tx; i++) { | 298 | for (i = 0; i < dev->num_tx; i++) { |
@@ -295,7 +303,6 @@ static int ethoc_init_ring(struct ethoc *dev) | |||
295 | bd.addr += ETHOC_BUFSIZ; | 303 | bd.addr += ETHOC_BUFSIZ; |
296 | } | 304 | } |
297 | 305 | ||
298 | bd.addr = dev->num_tx * ETHOC_BUFSIZ; | ||
299 | bd.stat = RX_BD_EMPTY | RX_BD_IRQ; | 306 | bd.stat = RX_BD_EMPTY | RX_BD_IRQ; |
300 | 307 | ||
301 | for (i = 0; i < dev->num_rx; i++) { | 308 | for (i = 0; i < dev->num_rx; i++) { |
@@ -400,8 +407,12 @@ static int ethoc_rx(struct net_device *dev, int limit) | |||
400 | if (ethoc_update_rx_stats(priv, &bd) == 0) { | 407 | if (ethoc_update_rx_stats(priv, &bd) == 0) { |
401 | int size = bd.stat >> 16; | 408 | int size = bd.stat >> 16; |
402 | struct sk_buff *skb = netdev_alloc_skb(dev, size); | 409 | struct sk_buff *skb = netdev_alloc_skb(dev, size); |
410 | |||
411 | size -= 4; /* strip the CRC */ | ||
412 | skb_reserve(skb, 2); /* align TCP/IP header */ | ||
413 | |||
403 | if (likely(skb)) { | 414 | if (likely(skb)) { |
404 | void *src = priv->membase + bd.addr; | 415 | void *src = phys_to_virt(bd.addr); |
405 | memcpy_fromio(skb_put(skb, size), src, size); | 416 | memcpy_fromio(skb_put(skb, size), src, size); |
406 | skb->protocol = eth_type_trans(skb, dev); | 417 | skb->protocol = eth_type_trans(skb, dev); |
407 | priv->stats.rx_packets++; | 418 | priv->stats.rx_packets++; |
@@ -498,7 +509,7 @@ static irqreturn_t ethoc_interrupt(int irq, void *dev_id) | |||
498 | return IRQ_NONE; | 509 | return IRQ_NONE; |
499 | } | 510 | } |
500 | 511 | ||
501 | ethoc_ack_irq(priv, INT_MASK_ALL); | 512 | ethoc_ack_irq(priv, pending); |
502 | 513 | ||
503 | if (pending & INT_MASK_BUSY) { | 514 | if (pending & INT_MASK_BUSY) { |
504 | dev_err(&dev->dev, "packet dropped\n"); | 515 | dev_err(&dev->dev, "packet dropped\n"); |
@@ -653,9 +664,10 @@ static int ethoc_open(struct net_device *dev) | |||
653 | if (ret) | 664 | if (ret) |
654 | return ret; | 665 | return ret; |
655 | 666 | ||
656 | /* calculate the number of TX/RX buffers */ | 667 | /* calculate the number of TX/RX buffers, maximum 128 supported */ |
657 | num_bd = (dev->mem_end - dev->mem_start + 1) / ETHOC_BUFSIZ; | 668 | num_bd = min_t(unsigned int, |
658 | priv->num_tx = min(min_tx, num_bd / 4); | 669 | 128, (dev->mem_end - dev->mem_start + 1) / ETHOC_BUFSIZ); |
670 | priv->num_tx = max(min_tx, num_bd / 4); | ||
659 | priv->num_rx = num_bd - priv->num_tx; | 671 | priv->num_rx = num_bd - priv->num_tx; |
660 | ethoc_write(priv, TX_BD_NUM, priv->num_tx); | 672 | ethoc_write(priv, TX_BD_NUM, priv->num_tx); |
661 | 673 | ||
@@ -823,7 +835,7 @@ static netdev_tx_t ethoc_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
823 | else | 835 | else |
824 | bd.stat &= ~TX_BD_PAD; | 836 | bd.stat &= ~TX_BD_PAD; |
825 | 837 | ||
826 | dest = priv->membase + bd.addr; | 838 | dest = phys_to_virt(bd.addr); |
827 | memcpy_toio(dest, skb->data, skb->len); | 839 | memcpy_toio(dest, skb->data, skb->len); |
828 | 840 | ||
829 | bd.stat &= ~(TX_BD_STATS | TX_BD_LEN_MASK); | 841 | bd.stat &= ~(TX_BD_STATS | TX_BD_LEN_MASK); |
@@ -903,22 +915,19 @@ static int ethoc_probe(struct platform_device *pdev) | |||
903 | 915 | ||
904 | /* obtain buffer memory space */ | 916 | /* obtain buffer memory space */ |
905 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 917 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
906 | if (!res) { | 918 | if (res) { |
907 | dev_err(&pdev->dev, "cannot obtain memory space\n"); | 919 | mem = devm_request_mem_region(&pdev->dev, res->start, |
908 | ret = -ENXIO; | ||
909 | goto free; | ||
910 | } | ||
911 | |||
912 | mem = devm_request_mem_region(&pdev->dev, res->start, | ||
913 | res->end - res->start + 1, res->name); | 920 | res->end - res->start + 1, res->name); |
914 | if (!mem) { | 921 | if (!mem) { |
915 | dev_err(&pdev->dev, "cannot request memory space\n"); | 922 | dev_err(&pdev->dev, "cannot request memory space\n"); |
916 | ret = -ENXIO; | 923 | ret = -ENXIO; |
917 | goto free; | 924 | goto free; |
925 | } | ||
926 | |||
927 | netdev->mem_start = mem->start; | ||
928 | netdev->mem_end = mem->end; | ||
918 | } | 929 | } |
919 | 930 | ||
920 | netdev->mem_start = mem->start; | ||
921 | netdev->mem_end = mem->end; | ||
922 | 931 | ||
923 | /* obtain device IRQ number */ | 932 | /* obtain device IRQ number */ |
924 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 933 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
@@ -933,6 +942,7 @@ static int ethoc_probe(struct platform_device *pdev) | |||
933 | /* setup driver-private data */ | 942 | /* setup driver-private data */ |
934 | priv = netdev_priv(netdev); | 943 | priv = netdev_priv(netdev); |
935 | priv->netdev = netdev; | 944 | priv->netdev = netdev; |
945 | priv->dma_alloc = 0; | ||
936 | 946 | ||
937 | priv->iobase = devm_ioremap_nocache(&pdev->dev, netdev->base_addr, | 947 | priv->iobase = devm_ioremap_nocache(&pdev->dev, netdev->base_addr, |
938 | mmio->end - mmio->start + 1); | 948 | mmio->end - mmio->start + 1); |
@@ -942,12 +952,27 @@ static int ethoc_probe(struct platform_device *pdev) | |||
942 | goto error; | 952 | goto error; |
943 | } | 953 | } |
944 | 954 | ||
945 | priv->membase = devm_ioremap_nocache(&pdev->dev, netdev->mem_start, | 955 | if (netdev->mem_end) { |
946 | mem->end - mem->start + 1); | 956 | priv->membase = devm_ioremap_nocache(&pdev->dev, |
947 | if (!priv->membase) { | 957 | netdev->mem_start, mem->end - mem->start + 1); |
948 | dev_err(&pdev->dev, "cannot remap memory space\n"); | 958 | if (!priv->membase) { |
949 | ret = -ENXIO; | 959 | dev_err(&pdev->dev, "cannot remap memory space\n"); |
950 | goto error; | 960 | ret = -ENXIO; |
961 | goto error; | ||
962 | } | ||
963 | } else { | ||
964 | /* Allocate buffer memory */ | ||
965 | priv->membase = dma_alloc_coherent(NULL, | ||
966 | buffer_size, (void *)&netdev->mem_start, | ||
967 | GFP_KERNEL); | ||
968 | if (!priv->membase) { | ||
969 | dev_err(&pdev->dev, "cannot allocate %dB buffer\n", | ||
970 | buffer_size); | ||
971 | ret = -ENOMEM; | ||
972 | goto error; | ||
973 | } | ||
974 | netdev->mem_end = netdev->mem_start + buffer_size; | ||
975 | priv->dma_alloc = buffer_size; | ||
951 | } | 976 | } |
952 | 977 | ||
953 | /* Allow the platform setup code to pass in a MAC address. */ | 978 | /* Allow the platform setup code to pass in a MAC address. */ |
@@ -1034,6 +1059,9 @@ free_mdio: | |||
1034 | kfree(priv->mdio->irq); | 1059 | kfree(priv->mdio->irq); |
1035 | mdiobus_free(priv->mdio); | 1060 | mdiobus_free(priv->mdio); |
1036 | free: | 1061 | free: |
1062 | if (priv->dma_alloc) | ||
1063 | dma_free_coherent(NULL, priv->dma_alloc, priv->membase, | ||
1064 | netdev->mem_start); | ||
1037 | free_netdev(netdev); | 1065 | free_netdev(netdev); |
1038 | out: | 1066 | out: |
1039 | return ret; | 1067 | return ret; |
@@ -1059,7 +1087,9 @@ static int ethoc_remove(struct platform_device *pdev) | |||
1059 | kfree(priv->mdio->irq); | 1087 | kfree(priv->mdio->irq); |
1060 | mdiobus_free(priv->mdio); | 1088 | mdiobus_free(priv->mdio); |
1061 | } | 1089 | } |
1062 | 1090 | if (priv->dma_alloc) | |
1091 | dma_free_coherent(NULL, priv->dma_alloc, priv->membase, | ||
1092 | netdev->mem_start); | ||
1063 | unregister_netdev(netdev); | 1093 | unregister_netdev(netdev); |
1064 | free_netdev(netdev); | 1094 | free_netdev(netdev); |
1065 | } | 1095 | } |
diff --git a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c index b2a5ec8f3721..dd4ba01fd92d 100644 --- a/drivers/net/ewrk3.c +++ b/drivers/net/ewrk3.c | |||
@@ -145,6 +145,7 @@ | |||
145 | 145 | ||
146 | #include <linux/module.h> | 146 | #include <linux/module.h> |
147 | #include <linux/kernel.h> | 147 | #include <linux/kernel.h> |
148 | #include <linux/sched.h> | ||
148 | #include <linux/string.h> | 149 | #include <linux/string.h> |
149 | #include <linux/errno.h> | 150 | #include <linux/errno.h> |
150 | #include <linux/ioport.h> | 151 | #include <linux/ioport.h> |
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 29234380e6c6..16a1d58419d9 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -1654,7 +1654,7 @@ static const struct net_device_ops fec_netdev_ops = { | |||
1654 | * | 1654 | * |
1655 | * index is only used in legacy code | 1655 | * index is only used in legacy code |
1656 | */ | 1656 | */ |
1657 | int __init fec_enet_init(struct net_device *dev, int index) | 1657 | static int fec_enet_init(struct net_device *dev, int index) |
1658 | { | 1658 | { |
1659 | struct fec_enet_private *fep = netdev_priv(dev); | 1659 | struct fec_enet_private *fep = netdev_priv(dev); |
1660 | struct bufdesc *cbd_base; | 1660 | struct bufdesc *cbd_base; |
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c index c40113f58963..66dace6d324f 100644 --- a/drivers/net/fec_mpc52xx.c +++ b/drivers/net/fec_mpc52xx.c | |||
@@ -759,12 +759,6 @@ static void mpc52xx_fec_reset(struct net_device *dev) | |||
759 | 759 | ||
760 | mpc52xx_fec_hw_init(dev); | 760 | mpc52xx_fec_hw_init(dev); |
761 | 761 | ||
762 | if (priv->phydev) { | ||
763 | phy_stop(priv->phydev); | ||
764 | phy_write(priv->phydev, MII_BMCR, BMCR_RESET); | ||
765 | phy_start(priv->phydev); | ||
766 | } | ||
767 | |||
768 | bcom_fec_rx_reset(priv->rx_dmatsk); | 762 | bcom_fec_rx_reset(priv->rx_dmatsk); |
769 | bcom_fec_tx_reset(priv->tx_dmatsk); | 763 | bcom_fec_tx_reset(priv->tx_dmatsk); |
770 | 764 | ||
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c index 31e6d62b785d..ee0f3c6d3f88 100644 --- a/drivers/net/fec_mpc52xx_phy.c +++ b/drivers/net/fec_mpc52xx_phy.c | |||
@@ -155,6 +155,7 @@ static struct of_device_id mpc52xx_fec_mdio_match[] = { | |||
155 | { .compatible = "mpc5200b-fec-phy", }, | 155 | { .compatible = "mpc5200b-fec-phy", }, |
156 | {} | 156 | {} |
157 | }; | 157 | }; |
158 | MODULE_DEVICE_TABLE(of, mpc52xx_fec_mdio_match); | ||
158 | 159 | ||
159 | struct of_platform_driver mpc52xx_fec_mdio_driver = { | 160 | struct of_platform_driver mpc52xx_fec_mdio_driver = { |
160 | .name = "mpc5200b-fec-phy", | 161 | .name = "mpc5200b-fec-phy", |
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 0a1c2bb27d4d..e1da4666f204 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/netdevice.h> | 49 | #include <linux/netdevice.h> |
50 | #include <linux/etherdevice.h> | 50 | #include <linux/etherdevice.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/sched.h> | ||
52 | #include <linux/spinlock.h> | 53 | #include <linux/spinlock.h> |
53 | #include <linux/ethtool.h> | 54 | #include <linux/ethtool.h> |
54 | #include <linux/timer.h> | 55 | #include <linux/timer.h> |
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 2bc2d2b20644..ec2f5034457f 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
@@ -1110,6 +1110,7 @@ static struct of_device_id fs_enet_match[] = { | |||
1110 | #endif | 1110 | #endif |
1111 | {} | 1111 | {} |
1112 | }; | 1112 | }; |
1113 | MODULE_DEVICE_TABLE(of, fs_enet_match); | ||
1113 | 1114 | ||
1114 | static struct of_platform_driver fs_enet_driver = { | 1115 | static struct of_platform_driver fs_enet_driver = { |
1115 | .name = "fs_enet", | 1116 | .name = "fs_enet", |
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c index 93b481b0e3c7..24ff9f43a62b 100644 --- a/drivers/net/fs_enet/mii-bitbang.c +++ b/drivers/net/fs_enet/mii-bitbang.c | |||
@@ -221,6 +221,7 @@ static struct of_device_id fs_enet_mdio_bb_match[] = { | |||
221 | }, | 221 | }, |
222 | {}, | 222 | {}, |
223 | }; | 223 | }; |
224 | MODULE_DEVICE_TABLE(of, fs_enet_mdio_bb_match); | ||
224 | 225 | ||
225 | static struct of_platform_driver fs_enet_bb_mdio_driver = { | 226 | static struct of_platform_driver fs_enet_bb_mdio_driver = { |
226 | .name = "fsl-bb-mdio", | 227 | .name = "fsl-bb-mdio", |
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c index a2d69c1cd07e..96eba4280c5c 100644 --- a/drivers/net/fs_enet/mii-fec.c +++ b/drivers/net/fs_enet/mii-fec.c | |||
@@ -219,6 +219,7 @@ static struct of_device_id fs_enet_mdio_fec_match[] = { | |||
219 | #endif | 219 | #endif |
220 | {}, | 220 | {}, |
221 | }; | 221 | }; |
222 | MODULE_DEVICE_TABLE(of, fs_enet_mdio_fec_match); | ||
222 | 223 | ||
223 | static struct of_platform_driver fs_enet_fec_mdio_driver = { | 224 | static struct of_platform_driver fs_enet_fec_mdio_driver = { |
224 | .name = "fsl-fec-mdio", | 225 | .name = "fsl-fec-mdio", |
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c index d167090248e2..6ac464866972 100644 --- a/drivers/net/fsl_pq_mdio.c +++ b/drivers/net/fsl_pq_mdio.c | |||
@@ -407,6 +407,7 @@ static struct of_device_id fsl_pq_mdio_match[] = { | |||
407 | }, | 407 | }, |
408 | {}, | 408 | {}, |
409 | }; | 409 | }; |
410 | MODULE_DEVICE_TABLE(of, fsl_pq_mdio_match); | ||
410 | 411 | ||
411 | static struct of_platform_driver fsl_pq_mdio_driver = { | 412 | static struct of_platform_driver fsl_pq_mdio_driver = { |
412 | .name = "fsl-pq_mdio", | 413 | .name = "fsl-pq_mdio", |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 1e5289ffef6f..5bf31f1509c9 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -2325,9 +2325,6 @@ static irqreturn_t gfar_error(int irq, void *dev_id) | |||
2325 | return IRQ_HANDLED; | 2325 | return IRQ_HANDLED; |
2326 | } | 2326 | } |
2327 | 2327 | ||
2328 | /* work with hotplug and coldplug */ | ||
2329 | MODULE_ALIAS("platform:fsl-gianfar"); | ||
2330 | |||
2331 | static struct of_device_id gfar_match[] = | 2328 | static struct of_device_id gfar_match[] = |
2332 | { | 2329 | { |
2333 | { | 2330 | { |
@@ -2336,6 +2333,7 @@ static struct of_device_id gfar_match[] = | |||
2336 | }, | 2333 | }, |
2337 | {}, | 2334 | {}, |
2338 | }; | 2335 | }; |
2336 | MODULE_DEVICE_TABLE(of, gfar_match); | ||
2339 | 2337 | ||
2340 | /* Structure for a device driver */ | 2338 | /* Structure for a device driver */ |
2341 | static struct of_platform_driver gfar_driver = { | 2339 | static struct of_platform_driver gfar_driver = { |
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index 1d5064a09aca..f7519a594945 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c | |||
@@ -145,6 +145,7 @@ static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; | |||
145 | /* Time in jiffies before concluding the transmitter is hung. */ | 145 | /* Time in jiffies before concluding the transmitter is hung. */ |
146 | #define TX_TIMEOUT (5*HZ) | 146 | #define TX_TIMEOUT (5*HZ) |
147 | 147 | ||
148 | #include <linux/capability.h> | ||
148 | #include <linux/module.h> | 149 | #include <linux/module.h> |
149 | #include <linux/kernel.h> | 150 | #include <linux/kernel.h> |
150 | #include <linux/string.h> | 151 | #include <linux/string.h> |
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 7bcaf7c66243..e344c84c0ef9 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/module.h> | 44 | #include <linux/module.h> |
45 | #include <linux/kernel.h> | 45 | #include <linux/kernel.h> |
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <linux/sched.h> | ||
47 | #include <linux/string.h> | 48 | #include <linux/string.h> |
48 | #include <linux/workqueue.h> | 49 | #include <linux/workqueue.h> |
49 | #include <linux/fs.h> | 50 | #include <linux/fs.h> |
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c index aa4488e871b2..ed60fd664273 100644 --- a/drivers/net/hamradio/baycom_ser_fdx.c +++ b/drivers/net/hamradio/baycom_ser_fdx.c | |||
@@ -71,6 +71,7 @@ | |||
71 | 71 | ||
72 | /*****************************************************************************/ | 72 | /*****************************************************************************/ |
73 | 73 | ||
74 | #include <linux/capability.h> | ||
74 | #include <linux/module.h> | 75 | #include <linux/module.h> |
75 | #include <linux/ioport.h> | 76 | #include <linux/ioport.h> |
76 | #include <linux/string.h> | 77 | #include <linux/string.h> |
diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c index 88c593596020..1686f6dcbbce 100644 --- a/drivers/net/hamradio/baycom_ser_hdx.c +++ b/drivers/net/hamradio/baycom_ser_hdx.c | |||
@@ -61,6 +61,7 @@ | |||
61 | 61 | ||
62 | /*****************************************************************************/ | 62 | /*****************************************************************************/ |
63 | 63 | ||
64 | #include <linux/capability.h> | ||
64 | #include <linux/module.h> | 65 | #include <linux/module.h> |
65 | #include <linux/ioport.h> | 66 | #include <linux/ioport.h> |
66 | #include <linux/string.h> | 67 | #include <linux/string.h> |
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c index 0013c409782c..91c5790c9581 100644 --- a/drivers/net/hamradio/hdlcdrv.c +++ b/drivers/net/hamradio/hdlcdrv.c | |||
@@ -42,6 +42,7 @@ | |||
42 | 42 | ||
43 | /*****************************************************************************/ | 43 | /*****************************************************************************/ |
44 | 44 | ||
45 | #include <linux/capability.h> | ||
45 | #include <linux/module.h> | 46 | #include <linux/module.h> |
46 | #include <linux/types.h> | 47 | #include <linux/types.h> |
47 | #include <linux/net.h> | 48 | #include <linux/net.h> |
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c index a9a1a99f02dd..dd8665138062 100644 --- a/drivers/net/hp100.c +++ b/drivers/net/hp100.c | |||
@@ -98,6 +98,7 @@ | |||
98 | 98 | ||
99 | #include <linux/module.h> | 99 | #include <linux/module.h> |
100 | #include <linux/kernel.h> | 100 | #include <linux/kernel.h> |
101 | #include <linux/sched.h> | ||
101 | #include <linux/string.h> | 102 | #include <linux/string.h> |
102 | #include <linux/errno.h> | 103 | #include <linux/errno.h> |
103 | #include <linux/ioport.h> | 104 | #include <linux/ioport.h> |
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 89c82c5e63e4..3fae87559791 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
@@ -24,6 +24,7 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/module.h> | ||
27 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
28 | #include <linux/string.h> | 29 | #include <linux/string.h> |
29 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
@@ -443,7 +444,7 @@ static u32 __emac_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_s | |||
443 | ret |= EMAC_MR1_TFS_2K; | 444 | ret |= EMAC_MR1_TFS_2K; |
444 | break; | 445 | break; |
445 | default: | 446 | default: |
446 | printk(KERN_WARNING "%s: Unknown Rx FIFO size %d\n", | 447 | printk(KERN_WARNING "%s: Unknown Tx FIFO size %d\n", |
447 | dev->ndev->name, tx_size); | 448 | dev->ndev->name, tx_size); |
448 | } | 449 | } |
449 | 450 | ||
@@ -470,6 +471,9 @@ static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_ | |||
470 | DBG2(dev, "__emac4_calc_base_mr1" NL); | 471 | DBG2(dev, "__emac4_calc_base_mr1" NL); |
471 | 472 | ||
472 | switch(tx_size) { | 473 | switch(tx_size) { |
474 | case 16384: | ||
475 | ret |= EMAC4_MR1_TFS_16K; | ||
476 | break; | ||
473 | case 4096: | 477 | case 4096: |
474 | ret |= EMAC4_MR1_TFS_4K; | 478 | ret |= EMAC4_MR1_TFS_4K; |
475 | break; | 479 | break; |
@@ -477,7 +481,7 @@ static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_ | |||
477 | ret |= EMAC4_MR1_TFS_2K; | 481 | ret |= EMAC4_MR1_TFS_2K; |
478 | break; | 482 | break; |
479 | default: | 483 | default: |
480 | printk(KERN_WARNING "%s: Unknown Rx FIFO size %d\n", | 484 | printk(KERN_WARNING "%s: Unknown Tx FIFO size %d\n", |
481 | dev->ndev->name, tx_size); | 485 | dev->ndev->name, tx_size); |
482 | } | 486 | } |
483 | 487 | ||
@@ -2985,6 +2989,7 @@ static struct of_device_id emac_match[] = | |||
2985 | }, | 2989 | }, |
2986 | {}, | 2990 | {}, |
2987 | }; | 2991 | }; |
2992 | MODULE_DEVICE_TABLE(of, emac_match); | ||
2988 | 2993 | ||
2989 | static struct of_platform_driver emac_driver = { | 2994 | static struct of_platform_driver emac_driver = { |
2990 | .name = "emac", | 2995 | .name = "emac", |
diff --git a/drivers/net/ibm_newemac/emac.h b/drivers/net/ibm_newemac/emac.h index 0afc2cf5c52b..d34adf99fc6a 100644 --- a/drivers/net/ibm_newemac/emac.h +++ b/drivers/net/ibm_newemac/emac.h | |||
@@ -153,6 +153,7 @@ struct emac_regs { | |||
153 | #define EMAC4_MR1_RFS_16K 0x00280000 | 153 | #define EMAC4_MR1_RFS_16K 0x00280000 |
154 | #define EMAC4_MR1_TFS_2K 0x00020000 | 154 | #define EMAC4_MR1_TFS_2K 0x00020000 |
155 | #define EMAC4_MR1_TFS_4K 0x00030000 | 155 | #define EMAC4_MR1_TFS_4K 0x00030000 |
156 | #define EMAC4_MR1_TFS_16K 0x00050000 | ||
156 | #define EMAC4_MR1_TR 0x00008000 | 157 | #define EMAC4_MR1_TR 0x00008000 |
157 | #define EMAC4_MR1_MWSW_001 0x00001000 | 158 | #define EMAC4_MR1_MWSW_001 0x00001000 |
158 | #define EMAC4_MR1_JPSM 0x00000800 | 159 | #define EMAC4_MR1_JPSM 0x00000800 |
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index 801f088c134f..030913f8bd26 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c | |||
@@ -98,12 +98,13 @@ static void ri_tasklet(unsigned long dev) | |||
98 | stats->tx_packets++; | 98 | stats->tx_packets++; |
99 | stats->tx_bytes +=skb->len; | 99 | stats->tx_bytes +=skb->len; |
100 | 100 | ||
101 | skb->dev = __dev_get_by_index(&init_net, skb->iif); | 101 | skb->dev = dev_get_by_index(&init_net, skb->iif); |
102 | if (!skb->dev) { | 102 | if (!skb->dev) { |
103 | dev_kfree_skb(skb); | 103 | dev_kfree_skb(skb); |
104 | stats->tx_dropped++; | 104 | stats->tx_dropped++; |
105 | break; | 105 | break; |
106 | } | 106 | } |
107 | dev_put(skb->dev); | ||
107 | skb->iif = _dev->ifindex; | 108 | skb->iif = _dev->ifindex; |
108 | 109 | ||
109 | if (from & AT_EGRESS) { | 110 | if (from & AT_EGRESS) { |
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index d004c359244c..b243ed3b0c36 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | #include <linux/if_ether.h> | 35 | #include <linux/if_ether.h> |
36 | #include <linux/ethtool.h> | 36 | #include <linux/ethtool.h> |
37 | #include <linux/sched.h> | ||
37 | 38 | ||
38 | #include "igb.h" | 39 | #include "igb.h" |
39 | 40 | ||
@@ -731,7 +732,7 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
731 | { | 732 | { |
732 | struct igb_adapter *adapter = netdev_priv(netdev); | 733 | struct igb_adapter *adapter = netdev_priv(netdev); |
733 | struct igb_ring *temp_ring; | 734 | struct igb_ring *temp_ring; |
734 | int i, err; | 735 | int i, err = 0; |
735 | u32 new_rx_count, new_tx_count; | 736 | u32 new_rx_count, new_tx_count; |
736 | 737 | ||
737 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) | 738 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
@@ -751,18 +752,30 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
751 | return 0; | 752 | return 0; |
752 | } | 753 | } |
753 | 754 | ||
755 | while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) | ||
756 | msleep(1); | ||
757 | |||
758 | if (!netif_running(adapter->netdev)) { | ||
759 | for (i = 0; i < adapter->num_tx_queues; i++) | ||
760 | adapter->tx_ring[i].count = new_tx_count; | ||
761 | for (i = 0; i < adapter->num_rx_queues; i++) | ||
762 | adapter->rx_ring[i].count = new_rx_count; | ||
763 | adapter->tx_ring_count = new_tx_count; | ||
764 | adapter->rx_ring_count = new_rx_count; | ||
765 | goto clear_reset; | ||
766 | } | ||
767 | |||
754 | if (adapter->num_tx_queues > adapter->num_rx_queues) | 768 | if (adapter->num_tx_queues > adapter->num_rx_queues) |
755 | temp_ring = vmalloc(adapter->num_tx_queues * sizeof(struct igb_ring)); | 769 | temp_ring = vmalloc(adapter->num_tx_queues * sizeof(struct igb_ring)); |
756 | else | 770 | else |
757 | temp_ring = vmalloc(adapter->num_rx_queues * sizeof(struct igb_ring)); | 771 | temp_ring = vmalloc(adapter->num_rx_queues * sizeof(struct igb_ring)); |
758 | if (!temp_ring) | ||
759 | return -ENOMEM; | ||
760 | 772 | ||
761 | while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) | 773 | if (!temp_ring) { |
762 | msleep(1); | 774 | err = -ENOMEM; |
775 | goto clear_reset; | ||
776 | } | ||
763 | 777 | ||
764 | if (netif_running(adapter->netdev)) | 778 | igb_down(adapter); |
765 | igb_down(adapter); | ||
766 | 779 | ||
767 | /* | 780 | /* |
768 | * We can't just free everything and then setup again, | 781 | * We can't just free everything and then setup again, |
@@ -819,14 +832,11 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
819 | 832 | ||
820 | adapter->rx_ring_count = new_rx_count; | 833 | adapter->rx_ring_count = new_rx_count; |
821 | } | 834 | } |
822 | |||
823 | err = 0; | ||
824 | err_setup: | 835 | err_setup: |
825 | if (netif_running(adapter->netdev)) | 836 | igb_up(adapter); |
826 | igb_up(adapter); | ||
827 | |||
828 | clear_bit(__IGB_RESETTING, &adapter->state); | ||
829 | vfree(temp_ring); | 837 | vfree(temp_ring); |
838 | clear_reset: | ||
839 | clear_bit(__IGB_RESETTING, &adapter->state); | ||
830 | return err; | 840 | return err; |
831 | } | 841 | } |
832 | 842 | ||
diff --git a/drivers/net/igbvf/ethtool.c b/drivers/net/igbvf/ethtool.c index ee17a097d1ca..c68265bd0d1a 100644 --- a/drivers/net/igbvf/ethtool.c +++ b/drivers/net/igbvf/ethtool.c | |||
@@ -279,7 +279,7 @@ static int igbvf_set_ringparam(struct net_device *netdev, | |||
279 | { | 279 | { |
280 | struct igbvf_adapter *adapter = netdev_priv(netdev); | 280 | struct igbvf_adapter *adapter = netdev_priv(netdev); |
281 | struct igbvf_ring *temp_ring; | 281 | struct igbvf_ring *temp_ring; |
282 | int err; | 282 | int err = 0; |
283 | u32 new_rx_count, new_tx_count; | 283 | u32 new_rx_count, new_tx_count; |
284 | 284 | ||
285 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) | 285 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
@@ -299,15 +299,22 @@ static int igbvf_set_ringparam(struct net_device *netdev, | |||
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | 301 | ||
302 | temp_ring = vmalloc(sizeof(struct igbvf_ring)); | ||
303 | if (!temp_ring) | ||
304 | return -ENOMEM; | ||
305 | |||
306 | while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) | 302 | while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) |
307 | msleep(1); | 303 | msleep(1); |
308 | 304 | ||
309 | if (netif_running(adapter->netdev)) | 305 | if (!netif_running(adapter->netdev)) { |
310 | igbvf_down(adapter); | 306 | adapter->tx_ring->count = new_tx_count; |
307 | adapter->rx_ring->count = new_rx_count; | ||
308 | goto clear_reset; | ||
309 | } | ||
310 | |||
311 | temp_ring = vmalloc(sizeof(struct igbvf_ring)); | ||
312 | if (!temp_ring) { | ||
313 | err = -ENOMEM; | ||
314 | goto clear_reset; | ||
315 | } | ||
316 | |||
317 | igbvf_down(adapter); | ||
311 | 318 | ||
312 | /* | 319 | /* |
313 | * We can't just free everything and then setup again, | 320 | * We can't just free everything and then setup again, |
@@ -339,14 +346,11 @@ static int igbvf_set_ringparam(struct net_device *netdev, | |||
339 | 346 | ||
340 | memcpy(adapter->rx_ring, temp_ring,sizeof(struct igbvf_ring)); | 347 | memcpy(adapter->rx_ring, temp_ring,sizeof(struct igbvf_ring)); |
341 | } | 348 | } |
342 | |||
343 | err = 0; | ||
344 | err_setup: | 349 | err_setup: |
345 | if (netif_running(adapter->netdev)) | 350 | igbvf_up(adapter); |
346 | igbvf_up(adapter); | ||
347 | |||
348 | clear_bit(__IGBVF_RESETTING, &adapter->state); | ||
349 | vfree(temp_ring); | 351 | vfree(temp_ring); |
352 | clear_reset: | ||
353 | clear_bit(__IGBVF_RESETTING, &adapter->state); | ||
350 | return err; | 354 | return err; |
351 | } | 355 | } |
352 | 356 | ||
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c index 38bf7cf2256d..c412e8026173 100644 --- a/drivers/net/irda/sa1100_ir.c +++ b/drivers/net/irda/sa1100_ir.c | |||
@@ -232,8 +232,11 @@ static int sa1100_irda_startup(struct sa1100_irda *si) | |||
232 | /* | 232 | /* |
233 | * Ensure that the ports for this device are setup correctly. | 233 | * Ensure that the ports for this device are setup correctly. |
234 | */ | 234 | */ |
235 | if (si->pdata->startup) | 235 | if (si->pdata->startup) { |
236 | si->pdata->startup(si->dev); | 236 | ret = si->pdata->startup(si->dev); |
237 | if (ret) | ||
238 | return ret; | ||
239 | } | ||
237 | 240 | ||
238 | /* | 241 | /* |
239 | * Configure PPC for IRDA - we want to drive TXD2 low. | 242 | * Configure PPC for IRDA - we want to drive TXD2 low. |
diff --git a/drivers/net/irda/toim3232-sir.c b/drivers/net/irda/toim3232-sir.c index fcf287b749db..99e1ec02a011 100644 --- a/drivers/net/irda/toim3232-sir.c +++ b/drivers/net/irda/toim3232-sir.c | |||
@@ -120,6 +120,7 @@ | |||
120 | #include <linux/module.h> | 120 | #include <linux/module.h> |
121 | #include <linux/delay.h> | 121 | #include <linux/delay.h> |
122 | #include <linux/init.h> | 122 | #include <linux/init.h> |
123 | #include <linux/sched.h> | ||
123 | 124 | ||
124 | #include <net/irda/irda.h> | 125 | #include <net/irda/irda.h> |
125 | 126 | ||
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c index 2ec58dcdb82b..34b04924c8a1 100644 --- a/drivers/net/ixgbe/ixgbe_82599.c +++ b/drivers/net/ixgbe/ixgbe_82599.c | |||
@@ -330,6 +330,8 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw) | |||
330 | 330 | ||
331 | switch (hw->device_id) { | 331 | switch (hw->device_id) { |
332 | case IXGBE_DEV_ID_82599_KX4: | 332 | case IXGBE_DEV_ID_82599_KX4: |
333 | case IXGBE_DEV_ID_82599_KX4_MEZZ: | ||
334 | case IXGBE_DEV_ID_82599_COMBO_BACKPLANE: | ||
333 | case IXGBE_DEV_ID_82599_XAUI_LOM: | 335 | case IXGBE_DEV_ID_82599_XAUI_LOM: |
334 | /* Default device ID is mezzanine card KX/KX4 */ | 336 | /* Default device ID is mezzanine card KX/KX4 */ |
335 | media_type = ixgbe_media_type_backplane; | 337 | media_type = ixgbe_media_type_backplane; |
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c index fa314cb005a4..856c18c207f3 100644 --- a/drivers/net/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ixgbe/ixgbe_ethtool.c | |||
@@ -798,7 +798,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
798 | { | 798 | { |
799 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 799 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
800 | struct ixgbe_ring *temp_tx_ring, *temp_rx_ring; | 800 | struct ixgbe_ring *temp_tx_ring, *temp_rx_ring; |
801 | int i, err; | 801 | int i, err = 0; |
802 | u32 new_rx_count, new_tx_count; | 802 | u32 new_rx_count, new_tx_count; |
803 | bool need_update = false; | 803 | bool need_update = false; |
804 | 804 | ||
@@ -822,6 +822,16 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
822 | while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) | 822 | while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) |
823 | msleep(1); | 823 | msleep(1); |
824 | 824 | ||
825 | if (!netif_running(adapter->netdev)) { | ||
826 | for (i = 0; i < adapter->num_tx_queues; i++) | ||
827 | adapter->tx_ring[i].count = new_tx_count; | ||
828 | for (i = 0; i < adapter->num_rx_queues; i++) | ||
829 | adapter->rx_ring[i].count = new_rx_count; | ||
830 | adapter->tx_ring_count = new_tx_count; | ||
831 | adapter->rx_ring_count = new_rx_count; | ||
832 | goto err_setup; | ||
833 | } | ||
834 | |||
825 | temp_tx_ring = kcalloc(adapter->num_tx_queues, | 835 | temp_tx_ring = kcalloc(adapter->num_tx_queues, |
826 | sizeof(struct ixgbe_ring), GFP_KERNEL); | 836 | sizeof(struct ixgbe_ring), GFP_KERNEL); |
827 | if (!temp_tx_ring) { | 837 | if (!temp_tx_ring) { |
@@ -879,8 +889,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
879 | 889 | ||
880 | /* if rings need to be updated, here's the place to do it in one shot */ | 890 | /* if rings need to be updated, here's the place to do it in one shot */ |
881 | if (need_update) { | 891 | if (need_update) { |
882 | if (netif_running(netdev)) | 892 | ixgbe_down(adapter); |
883 | ixgbe_down(adapter); | ||
884 | 893 | ||
885 | /* tx */ | 894 | /* tx */ |
886 | if (new_tx_count != adapter->tx_ring_count) { | 895 | if (new_tx_count != adapter->tx_ring_count) { |
@@ -897,13 +906,8 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
897 | temp_rx_ring = NULL; | 906 | temp_rx_ring = NULL; |
898 | adapter->rx_ring_count = new_rx_count; | 907 | adapter->rx_ring_count = new_rx_count; |
899 | } | 908 | } |
900 | } | ||
901 | |||
902 | /* success! */ | ||
903 | err = 0; | ||
904 | if (netif_running(netdev)) | ||
905 | ixgbe_up(adapter); | 909 | ixgbe_up(adapter); |
906 | 910 | } | |
907 | err_setup: | 911 | err_setup: |
908 | clear_bit(__IXGBE_RESETTING, &adapter->state); | 912 | clear_bit(__IXGBE_RESETTING, &adapter->state); |
909 | return err; | 913 | return err; |
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 28fbb9d281f9..cbb143ca1eb8 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -97,8 +97,12 @@ static struct pci_device_id ixgbe_pci_tbl[] = { | |||
97 | board_82599 }, | 97 | board_82599 }, |
98 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP), | 98 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP), |
99 | board_82599 }, | 99 | board_82599 }, |
100 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_KX4_MEZZ), | ||
101 | board_82599 }, | ||
100 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_CX4), | 102 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_CX4), |
101 | board_82599 }, | 103 | board_82599 }, |
104 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_COMBO_BACKPLANE), | ||
105 | board_82599 }, | ||
102 | 106 | ||
103 | /* required last entry */ | 107 | /* required last entry */ |
104 | {0, } | 108 | {0, } |
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h index 7c93e923bf2e..ef4bdd58e016 100644 --- a/drivers/net/ixgbe/ixgbe_type.h +++ b/drivers/net/ixgbe/ixgbe_type.h | |||
@@ -49,9 +49,11 @@ | |||
49 | #define IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM 0x10E1 | 49 | #define IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM 0x10E1 |
50 | #define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4 | 50 | #define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4 |
51 | #define IXGBE_DEV_ID_82599_KX4 0x10F7 | 51 | #define IXGBE_DEV_ID_82599_KX4 0x10F7 |
52 | #define IXGBE_DEV_ID_82599_KX4_MEZZ 0x1514 | ||
52 | #define IXGBE_DEV_ID_82599_CX4 0x10F9 | 53 | #define IXGBE_DEV_ID_82599_CX4 0x10F9 |
53 | #define IXGBE_DEV_ID_82599_SFP 0x10FB | 54 | #define IXGBE_DEV_ID_82599_SFP 0x10FB |
54 | #define IXGBE_DEV_ID_82599_XAUI_LOM 0x10FC | 55 | #define IXGBE_DEV_ID_82599_XAUI_LOM 0x10FC |
56 | #define IXGBE_DEV_ID_82599_COMBO_BACKPLANE 0x10F8 | ||
55 | 57 | ||
56 | /* General Registers */ | 58 | /* General Registers */ |
57 | #define IXGBE_CTRL 0x00000 | 59 | #define IXGBE_CTRL 0x00000 |
diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c index b02a981c87a8..34a6cfd17930 100644 --- a/drivers/net/ixp2000/enp2611.c +++ b/drivers/net/ixp2000/enp2611.c | |||
@@ -119,24 +119,9 @@ static struct ixp2400_msf_parameters enp2611_msf_parameters = | |||
119 | } | 119 | } |
120 | }; | 120 | }; |
121 | 121 | ||
122 | struct enp2611_ixpdev_priv | ||
123 | { | ||
124 | struct ixpdev_priv ixpdev_priv; | ||
125 | struct net_device_stats stats; | ||
126 | }; | ||
127 | |||
128 | static struct net_device *nds[3]; | 122 | static struct net_device *nds[3]; |
129 | static struct timer_list link_check_timer; | 123 | static struct timer_list link_check_timer; |
130 | 124 | ||
131 | static struct net_device_stats *enp2611_get_stats(struct net_device *dev) | ||
132 | { | ||
133 | struct enp2611_ixpdev_priv *ip = netdev_priv(dev); | ||
134 | |||
135 | pm3386_get_stats(ip->ixpdev_priv.channel, &(ip->stats)); | ||
136 | |||
137 | return &(ip->stats); | ||
138 | } | ||
139 | |||
140 | /* @@@ Poll the SFP moddef0 line too. */ | 125 | /* @@@ Poll the SFP moddef0 line too. */ |
141 | /* @@@ Try to use the pm3386 DOOL interrupt as well. */ | 126 | /* @@@ Try to use the pm3386 DOOL interrupt as well. */ |
142 | static void enp2611_check_link_status(unsigned long __dummy) | 127 | static void enp2611_check_link_status(unsigned long __dummy) |
@@ -203,14 +188,13 @@ static int __init enp2611_init_module(void) | |||
203 | 188 | ||
204 | ports = pm3386_port_count(); | 189 | ports = pm3386_port_count(); |
205 | for (i = 0; i < ports; i++) { | 190 | for (i = 0; i < ports; i++) { |
206 | nds[i] = ixpdev_alloc(i, sizeof(struct enp2611_ixpdev_priv)); | 191 | nds[i] = ixpdev_alloc(i, sizeof(struct ixpdev_priv)); |
207 | if (nds[i] == NULL) { | 192 | if (nds[i] == NULL) { |
208 | while (--i >= 0) | 193 | while (--i >= 0) |
209 | free_netdev(nds[i]); | 194 | free_netdev(nds[i]); |
210 | return -ENOMEM; | 195 | return -ENOMEM; |
211 | } | 196 | } |
212 | 197 | ||
213 | nds[i]->get_stats = enp2611_get_stats; | ||
214 | pm3386_init_port(i); | 198 | pm3386_init_port(i); |
215 | pm3386_get_mac(i, nds[i]->dev_addr); | 199 | pm3386_get_mac(i, nds[i]->dev_addr); |
216 | } | 200 | } |
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index 127243461a51..9aee0cc922c9 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "ixp2400_tx.ucode" | 21 | #include "ixp2400_tx.ucode" |
22 | #include "ixpdev_priv.h" | 22 | #include "ixpdev_priv.h" |
23 | #include "ixpdev.h" | 23 | #include "ixpdev.h" |
24 | #include "pm3386.h" | ||
24 | 25 | ||
25 | #define DRV_MODULE_VERSION "0.2" | 26 | #define DRV_MODULE_VERSION "0.2" |
26 | 27 | ||
@@ -271,6 +272,15 @@ static int ixpdev_close(struct net_device *dev) | |||
271 | return 0; | 272 | return 0; |
272 | } | 273 | } |
273 | 274 | ||
275 | static struct net_device_stats *ixpdev_get_stats(struct net_device *dev) | ||
276 | { | ||
277 | struct ixpdev_priv *ip = netdev_priv(dev); | ||
278 | |||
279 | pm3386_get_stats(ip->channel, &(dev->stats)); | ||
280 | |||
281 | return &(dev->stats); | ||
282 | } | ||
283 | |||
274 | static const struct net_device_ops ixpdev_netdev_ops = { | 284 | static const struct net_device_ops ixpdev_netdev_ops = { |
275 | .ndo_open = ixpdev_open, | 285 | .ndo_open = ixpdev_open, |
276 | .ndo_stop = ixpdev_close, | 286 | .ndo_stop = ixpdev_close, |
@@ -278,6 +288,7 @@ static const struct net_device_ops ixpdev_netdev_ops = { | |||
278 | .ndo_change_mtu = eth_change_mtu, | 288 | .ndo_change_mtu = eth_change_mtu, |
279 | .ndo_validate_addr = eth_validate_addr, | 289 | .ndo_validate_addr = eth_validate_addr, |
280 | .ndo_set_mac_address = eth_mac_addr, | 290 | .ndo_set_mac_address = eth_mac_addr, |
291 | .ndo_get_stats = ixpdev_get_stats, | ||
281 | #ifdef CONFIG_NET_POLL_CONTROLLER | 292 | #ifdef CONFIG_NET_POLL_CONTROLLER |
282 | .ndo_poll_controller = ixpdev_poll_controller, | 293 | .ndo_poll_controller = ixpdev_poll_controller, |
283 | #endif | 294 | #endif |
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c index 237835864357..a23f739d222f 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c | |||
@@ -171,6 +171,36 @@ static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | /** | 173 | /** |
174 | * ks8851_wrreg8 - write 8bit register value to chip | ||
175 | * @ks: The chip state | ||
176 | * @reg: The register address | ||
177 | * @val: The value to write | ||
178 | * | ||
179 | * Issue a write to put the value @val into the register specified in @reg. | ||
180 | */ | ||
181 | static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val) | ||
182 | { | ||
183 | struct spi_transfer *xfer = &ks->spi_xfer1; | ||
184 | struct spi_message *msg = &ks->spi_msg1; | ||
185 | __le16 txb[2]; | ||
186 | int ret; | ||
187 | int bit; | ||
188 | |||
189 | bit = 1 << (reg & 3); | ||
190 | |||
191 | txb[0] = cpu_to_le16(MK_OP(bit, reg) | KS_SPIOP_WR); | ||
192 | txb[1] = val; | ||
193 | |||
194 | xfer->tx_buf = txb; | ||
195 | xfer->rx_buf = NULL; | ||
196 | xfer->len = 3; | ||
197 | |||
198 | ret = spi_sync(ks->spidev, msg); | ||
199 | if (ret < 0) | ||
200 | ks_err(ks, "spi_sync() failed\n"); | ||
201 | } | ||
202 | |||
203 | /** | ||
174 | * ks8851_rx_1msg - select whether to use one or two messages for spi read | 204 | * ks8851_rx_1msg - select whether to use one or two messages for spi read |
175 | * @ks: The device structure | 205 | * @ks: The device structure |
176 | * | 206 | * |
@@ -322,13 +352,12 @@ static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op) | |||
322 | static int ks8851_write_mac_addr(struct net_device *dev) | 352 | static int ks8851_write_mac_addr(struct net_device *dev) |
323 | { | 353 | { |
324 | struct ks8851_net *ks = netdev_priv(dev); | 354 | struct ks8851_net *ks = netdev_priv(dev); |
325 | u16 *mcp = (u16 *)dev->dev_addr; | 355 | int i; |
326 | 356 | ||
327 | mutex_lock(&ks->lock); | 357 | mutex_lock(&ks->lock); |
328 | 358 | ||
329 | ks8851_wrreg16(ks, KS_MARL, mcp[0]); | 359 | for (i = 0; i < ETH_ALEN; i++) |
330 | ks8851_wrreg16(ks, KS_MARM, mcp[1]); | 360 | ks8851_wrreg8(ks, KS_MAR(i), dev->dev_addr[i]); |
331 | ks8851_wrreg16(ks, KS_MARH, mcp[2]); | ||
332 | 361 | ||
333 | mutex_unlock(&ks->lock); | 362 | mutex_unlock(&ks->lock); |
334 | 363 | ||
@@ -951,7 +980,7 @@ static void ks8851_set_rx_mode(struct net_device *dev) | |||
951 | mcptr = mcptr->next; | 980 | mcptr = mcptr->next; |
952 | } | 981 | } |
953 | 982 | ||
954 | rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXAE | RXCR1_RXPAFMA; | 983 | rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXPAFMA; |
955 | } else { | 984 | } else { |
956 | /* just accept broadcast / unicast */ | 985 | /* just accept broadcast / unicast */ |
957 | rxctrl.rxcr1 = RXCR1_RXPAFMA; | 986 | rxctrl.rxcr1 = RXCR1_RXPAFMA; |
@@ -1239,6 +1268,9 @@ static int __devinit ks8851_probe(struct spi_device *spi) | |||
1239 | ndev->netdev_ops = &ks8851_netdev_ops; | 1268 | ndev->netdev_ops = &ks8851_netdev_ops; |
1240 | ndev->irq = spi->irq; | 1269 | ndev->irq = spi->irq; |
1241 | 1270 | ||
1271 | /* issue a global soft reset to reset the device. */ | ||
1272 | ks8851_soft_reset(ks, GRR_GSR); | ||
1273 | |||
1242 | /* simple check for a valid chip being connected to the bus */ | 1274 | /* simple check for a valid chip being connected to the bus */ |
1243 | 1275 | ||
1244 | if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { | 1276 | if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { |
diff --git a/drivers/net/ks8851.h b/drivers/net/ks8851.h index 85abe147afbf..f52c312cc356 100644 --- a/drivers/net/ks8851.h +++ b/drivers/net/ks8851.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #define CCR_32PIN (1 << 0) | 16 | #define CCR_32PIN (1 << 0) |
17 | 17 | ||
18 | /* MAC address registers */ | 18 | /* MAC address registers */ |
19 | #define KS_MAR(_m) 0x15 - (_m) | ||
19 | #define KS_MARL 0x10 | 20 | #define KS_MARL 0x10 |
20 | #define KS_MARM 0x12 | 21 | #define KS_MARM 0x12 |
21 | #define KS_MARH 0x14 | 22 | #define KS_MARH 0x14 |
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c index 3dd481e77f92..291a505fd4fc 100644 --- a/drivers/net/mlx4/main.c +++ b/drivers/net/mlx4/main.c | |||
@@ -1282,6 +1282,8 @@ static struct pci_device_id mlx4_pci_table[] = { | |||
1282 | { PCI_VDEVICE(MELLANOX, 0x6372) }, /* MT25458 ConnectX EN 10GBASE-T 10GigE */ | 1282 | { PCI_VDEVICE(MELLANOX, 0x6372) }, /* MT25458 ConnectX EN 10GBASE-T 10GigE */ |
1283 | { PCI_VDEVICE(MELLANOX, 0x675a) }, /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */ | 1283 | { PCI_VDEVICE(MELLANOX, 0x675a) }, /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */ |
1284 | { PCI_VDEVICE(MELLANOX, 0x6764) }, /* MT26468 ConnectX EN 10GigE PCIe gen2*/ | 1284 | { PCI_VDEVICE(MELLANOX, 0x6764) }, /* MT26468 ConnectX EN 10GigE PCIe gen2*/ |
1285 | { PCI_VDEVICE(MELLANOX, 0x6746) }, /* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */ | ||
1286 | { PCI_VDEVICE(MELLANOX, 0x676e) }, /* MT26478 ConnectX2 40GigE PCIe gen2 */ | ||
1285 | { 0, } | 1287 | { 0, } |
1286 | }; | 1288 | }; |
1287 | 1289 | ||
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index 6930c87f362e..f3624517cb0e 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -75,7 +75,7 @@ | |||
75 | #include "myri10ge_mcp.h" | 75 | #include "myri10ge_mcp.h" |
76 | #include "myri10ge_mcp_gen_header.h" | 76 | #include "myri10ge_mcp_gen_header.h" |
77 | 77 | ||
78 | #define MYRI10GE_VERSION_STR "1.5.0-1.432" | 78 | #define MYRI10GE_VERSION_STR "1.5.1-1.451" |
79 | 79 | ||
80 | MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); | 80 | MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); |
81 | MODULE_AUTHOR("Maintainer: help@myri.com"); | 81 | MODULE_AUTHOR("Maintainer: help@myri.com"); |
@@ -1624,10 +1624,21 @@ myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) | |||
1624 | return 0; | 1624 | return 0; |
1625 | } | 1625 | } |
1626 | } | 1626 | } |
1627 | if (*ptr == 'R' || *ptr == 'Q') { | 1627 | if (*ptr == '2') |
1628 | /* We've found either an XFP or quad ribbon fiber */ | 1628 | ptr++; |
1629 | if (*ptr == 'R' || *ptr == 'Q' || *ptr == 'S') { | ||
1630 | /* We've found either an XFP, quad ribbon fiber, or SFP+ */ | ||
1629 | cmd->port = PORT_FIBRE; | 1631 | cmd->port = PORT_FIBRE; |
1632 | cmd->supported |= SUPPORTED_FIBRE; | ||
1633 | cmd->advertising |= ADVERTISED_FIBRE; | ||
1634 | } else { | ||
1635 | cmd->port = PORT_OTHER; | ||
1630 | } | 1636 | } |
1637 | if (*ptr == 'R' || *ptr == 'S') | ||
1638 | cmd->transceiver = XCVR_EXTERNAL; | ||
1639 | else | ||
1640 | cmd->transceiver = XCVR_INTERNAL; | ||
1641 | |||
1631 | return 0; | 1642 | return 0; |
1632 | } | 1643 | } |
1633 | 1644 | ||
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index 7a7177421d7c..1c46da632125 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h | |||
@@ -419,6 +419,7 @@ enum { | |||
419 | #define NETXEN_CRB_ROMUSB \ | 419 | #define NETXEN_CRB_ROMUSB \ |
420 | NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_ROMUSB) | 420 | NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_ROMUSB) |
421 | #define NETXEN_CRB_I2Q NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_I2Q) | 421 | #define NETXEN_CRB_I2Q NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_I2Q) |
422 | #define NETXEN_CRB_I2C0 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_I2C0) | ||
422 | #define NETXEN_CRB_SMB NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_SMB) | 423 | #define NETXEN_CRB_SMB NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_SMB) |
423 | #define NETXEN_CRB_MAX NETXEN_PCI_CRB_WINDOW(64) | 424 | #define NETXEN_CRB_MAX NETXEN_PCI_CRB_WINDOW(64) |
424 | 425 | ||
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 32314000dfcd..3185a98b0917 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -1901,22 +1901,16 @@ netxen_setup_hwops(struct netxen_adapter *adapter) | |||
1901 | 1901 | ||
1902 | int netxen_nic_get_board_info(struct netxen_adapter *adapter) | 1902 | int netxen_nic_get_board_info(struct netxen_adapter *adapter) |
1903 | { | 1903 | { |
1904 | int offset, board_type, magic, header_version; | 1904 | int offset, board_type, magic; |
1905 | struct pci_dev *pdev = adapter->pdev; | 1905 | struct pci_dev *pdev = adapter->pdev; |
1906 | 1906 | ||
1907 | offset = NX_FW_MAGIC_OFFSET; | 1907 | offset = NX_FW_MAGIC_OFFSET; |
1908 | if (netxen_rom_fast_read(adapter, offset, &magic)) | 1908 | if (netxen_rom_fast_read(adapter, offset, &magic)) |
1909 | return -EIO; | 1909 | return -EIO; |
1910 | 1910 | ||
1911 | offset = NX_HDR_VERSION_OFFSET; | 1911 | if (magic != NETXEN_BDINFO_MAGIC) { |
1912 | if (netxen_rom_fast_read(adapter, offset, &header_version)) | 1912 | dev_err(&pdev->dev, "invalid board config, magic=%08x\n", |
1913 | return -EIO; | 1913 | magic); |
1914 | |||
1915 | if (magic != NETXEN_BDINFO_MAGIC || | ||
1916 | header_version != NETXEN_BDINFO_VERSION) { | ||
1917 | dev_err(&pdev->dev, | ||
1918 | "invalid board config, magic=%08x, version=%08x\n", | ||
1919 | magic, header_version); | ||
1920 | return -EIO; | 1914 | return -EIO; |
1921 | } | 1915 | } |
1922 | 1916 | ||
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 91c2bc61c8eb..e40b914d6faf 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -531,6 +531,8 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) | |||
531 | continue; | 531 | continue; |
532 | 532 | ||
533 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | 533 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
534 | if (off == (NETXEN_CRB_I2C0 + 0x1c)) | ||
535 | continue; | ||
534 | /* do not reset PCI */ | 536 | /* do not reset PCI */ |
535 | if (off == (ROMUSB_GLB + 0xbc)) | 537 | if (off == (ROMUSB_GLB + 0xbc)) |
536 | continue; | 538 | continue; |
@@ -553,12 +555,6 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) | |||
553 | continue; | 555 | continue; |
554 | } | 556 | } |
555 | 557 | ||
556 | if (off == NETXEN_ADDR_ERROR) { | ||
557 | printk(KERN_ERR "%s: Err: Unknown addr: 0x%08x\n", | ||
558 | netxen_nic_driver_name, buf[i].addr); | ||
559 | continue; | ||
560 | } | ||
561 | |||
562 | init_delay = 1; | 558 | init_delay = 1; |
563 | /* After writing this register, HW needs time for CRB */ | 559 | /* After writing this register, HW needs time for CRB */ |
564 | /* to quiet down (else crb_window returns 0xffffffff) */ | 560 | /* to quiet down (else crb_window returns 0xffffffff) */ |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index b5aa974827e5..0b4a56a8c8d5 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -595,7 +595,8 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) | |||
595 | void __iomem *mem_ptr2 = NULL; | 595 | void __iomem *mem_ptr2 = NULL; |
596 | void __iomem *db_ptr = NULL; | 596 | void __iomem *db_ptr = NULL; |
597 | 597 | ||
598 | unsigned long mem_base, mem_len, db_base, db_len = 0, pci_len0 = 0; | 598 | resource_size_t mem_base, db_base; |
599 | unsigned long mem_len, db_len = 0, pci_len0 = 0; | ||
599 | 600 | ||
600 | struct pci_dev *pdev = adapter->pdev; | 601 | struct pci_dev *pdev = adapter->pdev; |
601 | int pci_func = adapter->ahw.pci_func; | 602 | int pci_func = adapter->ahw.pci_func; |
@@ -1714,7 +1715,7 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1714 | /* 4 fragments per cmd des */ | 1715 | /* 4 fragments per cmd des */ |
1715 | no_of_desc = (frag_count + 3) >> 2; | 1716 | no_of_desc = (frag_count + 3) >> 2; |
1716 | 1717 | ||
1717 | if (unlikely(no_of_desc + 2) > netxen_tx_avail(tx_ring)) { | 1718 | if (unlikely(no_of_desc + 2 > netxen_tx_avail(tx_ring))) { |
1718 | netif_stop_queue(netdev); | 1719 | netif_stop_queue(netdev); |
1719 | return NETDEV_TX_BUSY; | 1720 | return NETDEV_TX_BUSY; |
1720 | } | 1721 | } |
@@ -1918,6 +1919,7 @@ static void netxen_tx_timeout_task(struct work_struct *work) | |||
1918 | 1919 | ||
1919 | request_reset: | 1920 | request_reset: |
1920 | adapter->need_fw_reset = 1; | 1921 | adapter->need_fw_reset = 1; |
1922 | clear_bit(__NX_RESETTING, &adapter->state); | ||
1921 | } | 1923 | } |
1922 | 1924 | ||
1923 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) | 1925 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index f9364d0678f2..d6c7ac68f6ea 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -3545,7 +3545,7 @@ static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np, | |||
3545 | rp->rcr_index = index; | 3545 | rp->rcr_index = index; |
3546 | 3546 | ||
3547 | skb_reserve(skb, NET_IP_ALIGN); | 3547 | skb_reserve(skb, NET_IP_ALIGN); |
3548 | __pskb_pull_tail(skb, min(len, NIU_RXPULL_MAX)); | 3548 | __pskb_pull_tail(skb, min(len, VLAN_ETH_HLEN)); |
3549 | 3549 | ||
3550 | rp->rx_packets++; | 3550 | rp->rx_packets++; |
3551 | rp->rx_bytes += skb->len; | 3551 | rp->rx_bytes += skb->len; |
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c index c594e1946476..57fd483dbb1f 100644 --- a/drivers/net/ns83820.c +++ b/drivers/net/ns83820.c | |||
@@ -111,6 +111,7 @@ | |||
111 | #include <linux/compiler.h> | 111 | #include <linux/compiler.h> |
112 | #include <linux/prefetch.h> | 112 | #include <linux/prefetch.h> |
113 | #include <linux/ethtool.h> | 113 | #include <linux/ethtool.h> |
114 | #include <linux/sched.h> | ||
114 | #include <linux/timer.h> | 115 | #include <linux/timer.h> |
115 | #include <linux/if_vlan.h> | 116 | #include <linux/if_vlan.h> |
116 | #include <linux/rtnetlink.h> | 117 | #include <linux/rtnetlink.h> |
diff --git a/drivers/net/pasemi_mac_ethtool.c b/drivers/net/pasemi_mac_ethtool.c index 064a4fe1dd90..28a86224879d 100644 --- a/drivers/net/pasemi_mac_ethtool.c +++ b/drivers/net/pasemi_mac_ethtool.c | |||
@@ -71,6 +71,9 @@ pasemi_mac_ethtool_get_settings(struct net_device *netdev, | |||
71 | struct pasemi_mac *mac = netdev_priv(netdev); | 71 | struct pasemi_mac *mac = netdev_priv(netdev); |
72 | struct phy_device *phydev = mac->phydev; | 72 | struct phy_device *phydev = mac->phydev; |
73 | 73 | ||
74 | if (!phydev) | ||
75 | return -EOPNOTSUPP; | ||
76 | |||
74 | return phy_ethtool_gset(phydev, cmd); | 77 | return phy_ethtool_gset(phydev, cmd); |
75 | } | 78 | } |
76 | 79 | ||
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index ee8ad3e180dd..b58965a2b3ae 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -251,6 +251,7 @@ static void el3_tx_timeout(struct net_device *dev); | |||
251 | static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 251 | static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
252 | static const struct ethtool_ops netdev_ethtool_ops; | 252 | static const struct ethtool_ops netdev_ethtool_ops; |
253 | static void set_rx_mode(struct net_device *dev); | 253 | static void set_rx_mode(struct net_device *dev); |
254 | static void set_multicast_list(struct net_device *dev); | ||
254 | 255 | ||
255 | static void tc574_detach(struct pcmcia_device *p_dev); | 256 | static void tc574_detach(struct pcmcia_device *p_dev); |
256 | 257 | ||
@@ -266,7 +267,7 @@ static const struct net_device_ops el3_netdev_ops = { | |||
266 | .ndo_tx_timeout = el3_tx_timeout, | 267 | .ndo_tx_timeout = el3_tx_timeout, |
267 | .ndo_get_stats = el3_get_stats, | 268 | .ndo_get_stats = el3_get_stats, |
268 | .ndo_do_ioctl = el3_ioctl, | 269 | .ndo_do_ioctl = el3_ioctl, |
269 | .ndo_set_multicast_list = set_rx_mode, | 270 | .ndo_set_multicast_list = set_multicast_list, |
270 | .ndo_change_mtu = eth_change_mtu, | 271 | .ndo_change_mtu = eth_change_mtu, |
271 | .ndo_set_mac_address = eth_mac_addr, | 272 | .ndo_set_mac_address = eth_mac_addr, |
272 | .ndo_validate_addr = eth_validate_addr, | 273 | .ndo_validate_addr = eth_validate_addr, |
@@ -1161,6 +1162,16 @@ static void set_rx_mode(struct net_device *dev) | |||
1161 | outw(SetRxFilter | RxStation | RxBroadcast, ioaddr + EL3_CMD); | 1162 | outw(SetRxFilter | RxStation | RxBroadcast, ioaddr + EL3_CMD); |
1162 | } | 1163 | } |
1163 | 1164 | ||
1165 | static void set_multicast_list(struct net_device *dev) | ||
1166 | { | ||
1167 | struct el3_private *lp = netdev_priv(dev); | ||
1168 | unsigned long flags; | ||
1169 | |||
1170 | spin_lock_irqsave(&lp->window_lock, flags); | ||
1171 | set_rx_mode(dev); | ||
1172 | spin_unlock_irqrestore(&lp->window_lock, flags); | ||
1173 | } | ||
1174 | |||
1164 | static int el3_close(struct net_device *dev) | 1175 | static int el3_close(struct net_device *dev) |
1165 | { | 1176 | { |
1166 | unsigned int ioaddr = dev->base_addr; | 1177 | unsigned int ioaddr = dev->base_addr; |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 474876c879cb..bd3447f04902 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -1754,14 +1754,14 @@ static struct pcmcia_device_id pcnet_ids[] = { | |||
1754 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"), | 1754 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"), |
1755 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"), | 1755 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"), |
1756 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"), | 1756 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"), |
1757 | PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), | 1757 | PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"), |
1758 | PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), | 1758 | PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"), |
1759 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "DP83903.cis"), | 1759 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "cis/DP83903.cis"), |
1760 | PCMCIA_DEVICE_CIS_MANF_CARD(0xc00f, 0x0002, "cis/LA-PCM.cis"), | 1760 | PCMCIA_DEVICE_CIS_MANF_CARD(0xc00f, 0x0002, "cis/LA-PCM.cis"), |
1761 | PCMCIA_DEVICE_CIS_PROD_ID12("KTI", "PE520 PLUS", 0xad180345, 0x9d58d392, "PE520.cis"), | 1761 | PCMCIA_DEVICE_CIS_PROD_ID12("KTI", "PE520 PLUS", 0xad180345, 0x9d58d392, "PE520.cis"), |
1762 | PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "NE2K.cis"), | 1762 | PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "cis/NE2K.cis"), |
1763 | PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "PE-200.cis"), | 1763 | PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "PE-200.cis"), |
1764 | PCMCIA_DEVICE_CIS_PROD_ID12("TAMARACK", "Ethernet", 0xcf434fba, 0x00b2e941, "tamarack.cis"), | 1764 | PCMCIA_DEVICE_CIS_PROD_ID12("TAMARACK", "Ethernet", 0xcf434fba, 0x00b2e941, "cis/tamarack.cis"), |
1765 | PCMCIA_DEVICE_PROD_ID12("Ethernet", "CF Size PC Card", 0x00b2e941, 0x43ac239b), | 1765 | PCMCIA_DEVICE_PROD_ID12("Ethernet", "CF Size PC Card", 0x00b2e941, 0x43ac239b), |
1766 | PCMCIA_DEVICE_PROD_ID123("Fast Ethernet", "CF Size PC Card", "1.0", | 1766 | PCMCIA_DEVICE_PROD_ID123("Fast Ethernet", "CF Size PC Card", "1.0", |
1767 | 0xb4be14e3, 0x43ac239b, 0x0877b627), | 1767 | 0xb4be14e3, 0x43ac239b, 0x0877b627), |
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index 6d28b18e7e28..c1b3f09f452c 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c | |||
@@ -31,6 +31,7 @@ static const char *const version = | |||
31 | 31 | ||
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/sched.h> | ||
34 | #include <linux/string.h> | 35 | #include <linux/string.h> |
35 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
36 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 250e10f2c35b..8659d341e769 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c | |||
@@ -238,6 +238,7 @@ static struct of_device_id mdio_ofgpio_match[] = { | |||
238 | }, | 238 | }, |
239 | {}, | 239 | {}, |
240 | }; | 240 | }; |
241 | MODULE_DEVICE_TABLE(of, mdio_ofgpio_match); | ||
241 | 242 | ||
242 | static struct of_platform_driver mdio_ofgpio_driver = { | 243 | static struct of_platform_driver mdio_ofgpio_driver = { |
243 | .name = "mdio-gpio", | 244 | .name = "mdio-gpio", |
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 7cbf6f9b51de..2559991eea6a 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -111,9 +111,6 @@ struct pppoe_net { | |||
111 | rwlock_t hash_lock; | 111 | rwlock_t hash_lock; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | /* to eliminate a race btw pppoe_flush_dev and pppoe_release */ | ||
115 | static DEFINE_SPINLOCK(flush_lock); | ||
116 | |||
117 | /* | 114 | /* |
118 | * PPPoE could be in the following stages: | 115 | * PPPoE could be in the following stages: |
119 | * 1) Discovery stage (to obtain remote MAC and Session ID) | 116 | * 1) Discovery stage (to obtain remote MAC and Session ID) |
@@ -303,45 +300,48 @@ static void pppoe_flush_dev(struct net_device *dev) | |||
303 | write_lock_bh(&pn->hash_lock); | 300 | write_lock_bh(&pn->hash_lock); |
304 | for (i = 0; i < PPPOE_HASH_SIZE; i++) { | 301 | for (i = 0; i < PPPOE_HASH_SIZE; i++) { |
305 | struct pppox_sock *po = pn->hash_table[i]; | 302 | struct pppox_sock *po = pn->hash_table[i]; |
303 | struct sock *sk; | ||
306 | 304 | ||
307 | while (po != NULL) { | 305 | while (po) { |
308 | struct sock *sk; | 306 | while (po && po->pppoe_dev != dev) { |
309 | if (po->pppoe_dev != dev) { | ||
310 | po = po->next; | 307 | po = po->next; |
311 | continue; | ||
312 | } | 308 | } |
309 | |||
310 | if (!po) | ||
311 | break; | ||
312 | |||
313 | sk = sk_pppox(po); | 313 | sk = sk_pppox(po); |
314 | spin_lock(&flush_lock); | ||
315 | po->pppoe_dev = NULL; | ||
316 | spin_unlock(&flush_lock); | ||
317 | dev_put(dev); | ||
318 | 314 | ||
319 | /* We always grab the socket lock, followed by the | 315 | /* We always grab the socket lock, followed by the |
320 | * hash_lock, in that order. Since we should | 316 | * hash_lock, in that order. Since we should hold the |
321 | * hold the sock lock while doing any unbinding, | 317 | * sock lock while doing any unbinding, we need to |
322 | * we need to release the lock we're holding. | 318 | * release the lock we're holding. Hold a reference to |
323 | * Hold a reference to the sock so it doesn't disappear | 319 | * the sock so it doesn't disappear as we're jumping |
324 | * as we're jumping between locks. | 320 | * between locks. |
325 | */ | 321 | */ |
326 | 322 | ||
327 | sock_hold(sk); | 323 | sock_hold(sk); |
328 | |||
329 | write_unlock_bh(&pn->hash_lock); | 324 | write_unlock_bh(&pn->hash_lock); |
330 | lock_sock(sk); | 325 | lock_sock(sk); |
331 | 326 | ||
332 | if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND)) { | 327 | if (po->pppoe_dev == dev |
328 | && sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND)) { | ||
333 | pppox_unbind_sock(sk); | 329 | pppox_unbind_sock(sk); |
334 | sk->sk_state = PPPOX_ZOMBIE; | 330 | sk->sk_state = PPPOX_ZOMBIE; |
335 | sk->sk_state_change(sk); | 331 | sk->sk_state_change(sk); |
332 | po->pppoe_dev = NULL; | ||
333 | dev_put(dev); | ||
336 | } | 334 | } |
337 | 335 | ||
338 | release_sock(sk); | 336 | release_sock(sk); |
339 | sock_put(sk); | 337 | sock_put(sk); |
340 | 338 | ||
341 | /* Restart scan at the beginning of this hash chain. | 339 | /* Restart the process from the start of the current |
342 | * While the lock was dropped the chain contents may | 340 | * hash chain. We dropped locks so the world may have |
343 | * have changed. | 341 | * change from underneath us. |
344 | */ | 342 | */ |
343 | |||
344 | BUG_ON(pppoe_pernet(dev_net(dev)) == NULL); | ||
345 | write_lock_bh(&pn->hash_lock); | 345 | write_lock_bh(&pn->hash_lock); |
346 | po = pn->hash_table[i]; | 346 | po = pn->hash_table[i]; |
347 | } | 347 | } |
@@ -388,11 +388,16 @@ static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb) | |||
388 | struct pppox_sock *po = pppox_sk(sk); | 388 | struct pppox_sock *po = pppox_sk(sk); |
389 | struct pppox_sock *relay_po; | 389 | struct pppox_sock *relay_po; |
390 | 390 | ||
391 | /* Backlog receive. Semantics of backlog rcv preclude any code from | ||
392 | * executing in lock_sock()/release_sock() bounds; meaning sk->sk_state | ||
393 | * can't change. | ||
394 | */ | ||
395 | |||
391 | if (sk->sk_state & PPPOX_BOUND) { | 396 | if (sk->sk_state & PPPOX_BOUND) { |
392 | ppp_input(&po->chan, skb); | 397 | ppp_input(&po->chan, skb); |
393 | } else if (sk->sk_state & PPPOX_RELAY) { | 398 | } else if (sk->sk_state & PPPOX_RELAY) { |
394 | relay_po = get_item_by_addr(dev_net(po->pppoe_dev), | 399 | relay_po = get_item_by_addr(sock_net(sk), |
395 | &po->pppoe_relay); | 400 | &po->pppoe_relay); |
396 | if (relay_po == NULL) | 401 | if (relay_po == NULL) |
397 | goto abort_kfree; | 402 | goto abort_kfree; |
398 | 403 | ||
@@ -447,6 +452,10 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
447 | goto drop; | 452 | goto drop; |
448 | 453 | ||
449 | pn = pppoe_pernet(dev_net(dev)); | 454 | pn = pppoe_pernet(dev_net(dev)); |
455 | |||
456 | /* Note that get_item does a sock_hold(), so sk_pppox(po) | ||
457 | * is known to be safe. | ||
458 | */ | ||
450 | po = get_item(pn, ph->sid, eth_hdr(skb)->h_source, dev->ifindex); | 459 | po = get_item(pn, ph->sid, eth_hdr(skb)->h_source, dev->ifindex); |
451 | if (!po) | 460 | if (!po) |
452 | goto drop; | 461 | goto drop; |
@@ -561,6 +570,7 @@ static int pppoe_release(struct socket *sock) | |||
561 | struct sock *sk = sock->sk; | 570 | struct sock *sk = sock->sk; |
562 | struct pppox_sock *po; | 571 | struct pppox_sock *po; |
563 | struct pppoe_net *pn; | 572 | struct pppoe_net *pn; |
573 | struct net *net = NULL; | ||
564 | 574 | ||
565 | if (!sk) | 575 | if (!sk) |
566 | return 0; | 576 | return 0; |
@@ -571,44 +581,28 @@ static int pppoe_release(struct socket *sock) | |||
571 | return -EBADF; | 581 | return -EBADF; |
572 | } | 582 | } |
573 | 583 | ||
584 | po = pppox_sk(sk); | ||
585 | |||
586 | if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND)) { | ||
587 | dev_put(po->pppoe_dev); | ||
588 | po->pppoe_dev = NULL; | ||
589 | } | ||
590 | |||
574 | pppox_unbind_sock(sk); | 591 | pppox_unbind_sock(sk); |
575 | 592 | ||
576 | /* Signal the death of the socket. */ | 593 | /* Signal the death of the socket. */ |
577 | sk->sk_state = PPPOX_DEAD; | 594 | sk->sk_state = PPPOX_DEAD; |
578 | 595 | ||
579 | /* | 596 | net = sock_net(sk); |
580 | * pppoe_flush_dev could lead to a race with | 597 | pn = pppoe_pernet(net); |
581 | * this routine so we use flush_lock to eliminate | ||
582 | * such a case (we only need per-net specific data) | ||
583 | */ | ||
584 | spin_lock(&flush_lock); | ||
585 | po = pppox_sk(sk); | ||
586 | if (!po->pppoe_dev) { | ||
587 | spin_unlock(&flush_lock); | ||
588 | goto out; | ||
589 | } | ||
590 | pn = pppoe_pernet(dev_net(po->pppoe_dev)); | ||
591 | spin_unlock(&flush_lock); | ||
592 | 598 | ||
593 | /* | 599 | /* |
594 | * protect "po" from concurrent updates | 600 | * protect "po" from concurrent updates |
595 | * on pppoe_flush_dev | 601 | * on pppoe_flush_dev |
596 | */ | 602 | */ |
597 | write_lock_bh(&pn->hash_lock); | 603 | delete_item(pn, po->pppoe_pa.sid, po->pppoe_pa.remote, |
604 | po->pppoe_ifindex); | ||
598 | 605 | ||
599 | po = pppox_sk(sk); | ||
600 | if (stage_session(po->pppoe_pa.sid)) | ||
601 | __delete_item(pn, po->pppoe_pa.sid, po->pppoe_pa.remote, | ||
602 | po->pppoe_ifindex); | ||
603 | |||
604 | if (po->pppoe_dev) { | ||
605 | dev_put(po->pppoe_dev); | ||
606 | po->pppoe_dev = NULL; | ||
607 | } | ||
608 | |||
609 | write_unlock_bh(&pn->hash_lock); | ||
610 | |||
611 | out: | ||
612 | sock_orphan(sk); | 606 | sock_orphan(sk); |
613 | sock->sk = NULL; | 607 | sock->sk = NULL; |
614 | 608 | ||
@@ -625,8 +619,9 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
625 | struct sock *sk = sock->sk; | 619 | struct sock *sk = sock->sk; |
626 | struct sockaddr_pppox *sp = (struct sockaddr_pppox *)uservaddr; | 620 | struct sockaddr_pppox *sp = (struct sockaddr_pppox *)uservaddr; |
627 | struct pppox_sock *po = pppox_sk(sk); | 621 | struct pppox_sock *po = pppox_sk(sk); |
628 | struct net_device *dev; | 622 | struct net_device *dev = NULL; |
629 | struct pppoe_net *pn; | 623 | struct pppoe_net *pn; |
624 | struct net *net = NULL; | ||
630 | int error; | 625 | int error; |
631 | 626 | ||
632 | lock_sock(sk); | 627 | lock_sock(sk); |
@@ -652,12 +647,14 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
652 | /* Delete the old binding */ | 647 | /* Delete the old binding */ |
653 | if (stage_session(po->pppoe_pa.sid)) { | 648 | if (stage_session(po->pppoe_pa.sid)) { |
654 | pppox_unbind_sock(sk); | 649 | pppox_unbind_sock(sk); |
650 | pn = pppoe_pernet(sock_net(sk)); | ||
651 | delete_item(pn, po->pppoe_pa.sid, | ||
652 | po->pppoe_pa.remote, po->pppoe_ifindex); | ||
655 | if (po->pppoe_dev) { | 653 | if (po->pppoe_dev) { |
656 | pn = pppoe_pernet(dev_net(po->pppoe_dev)); | ||
657 | delete_item(pn, po->pppoe_pa.sid, | ||
658 | po->pppoe_pa.remote, po->pppoe_ifindex); | ||
659 | dev_put(po->pppoe_dev); | 654 | dev_put(po->pppoe_dev); |
655 | po->pppoe_dev = NULL; | ||
660 | } | 656 | } |
657 | |||
661 | memset(sk_pppox(po) + 1, 0, | 658 | memset(sk_pppox(po) + 1, 0, |
662 | sizeof(struct pppox_sock) - sizeof(struct sock)); | 659 | sizeof(struct pppox_sock) - sizeof(struct sock)); |
663 | sk->sk_state = PPPOX_NONE; | 660 | sk->sk_state = PPPOX_NONE; |
@@ -666,16 +663,15 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
666 | /* Re-bind in session stage only */ | 663 | /* Re-bind in session stage only */ |
667 | if (stage_session(sp->sa_addr.pppoe.sid)) { | 664 | if (stage_session(sp->sa_addr.pppoe.sid)) { |
668 | error = -ENODEV; | 665 | error = -ENODEV; |
669 | dev = dev_get_by_name(sock_net(sk), sp->sa_addr.pppoe.dev); | 666 | net = sock_net(sk); |
667 | dev = dev_get_by_name(net, sp->sa_addr.pppoe.dev); | ||
670 | if (!dev) | 668 | if (!dev) |
671 | goto end; | 669 | goto err_put; |
672 | 670 | ||
673 | po->pppoe_dev = dev; | 671 | po->pppoe_dev = dev; |
674 | po->pppoe_ifindex = dev->ifindex; | 672 | po->pppoe_ifindex = dev->ifindex; |
675 | pn = pppoe_pernet(dev_net(dev)); | 673 | pn = pppoe_pernet(net); |
676 | write_lock_bh(&pn->hash_lock); | ||
677 | if (!(dev->flags & IFF_UP)) { | 674 | if (!(dev->flags & IFF_UP)) { |
678 | write_unlock_bh(&pn->hash_lock); | ||
679 | goto err_put; | 675 | goto err_put; |
680 | } | 676 | } |
681 | 677 | ||
@@ -683,6 +679,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
683 | &sp->sa_addr.pppoe, | 679 | &sp->sa_addr.pppoe, |
684 | sizeof(struct pppoe_addr)); | 680 | sizeof(struct pppoe_addr)); |
685 | 681 | ||
682 | write_lock_bh(&pn->hash_lock); | ||
686 | error = __set_item(pn, po); | 683 | error = __set_item(pn, po); |
687 | write_unlock_bh(&pn->hash_lock); | 684 | write_unlock_bh(&pn->hash_lock); |
688 | if (error < 0) | 685 | if (error < 0) |
@@ -696,8 +693,11 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
696 | po->chan.ops = &pppoe_chan_ops; | 693 | po->chan.ops = &pppoe_chan_ops; |
697 | 694 | ||
698 | error = ppp_register_net_channel(dev_net(dev), &po->chan); | 695 | error = ppp_register_net_channel(dev_net(dev), &po->chan); |
699 | if (error) | 696 | if (error) { |
697 | delete_item(pn, po->pppoe_pa.sid, | ||
698 | po->pppoe_pa.remote, po->pppoe_ifindex); | ||
700 | goto err_put; | 699 | goto err_put; |
700 | } | ||
701 | 701 | ||
702 | sk->sk_state = PPPOX_CONNECTED; | 702 | sk->sk_state = PPPOX_CONNECTED; |
703 | } | 703 | } |
@@ -915,6 +915,14 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) | |||
915 | struct pppoe_hdr *ph; | 915 | struct pppoe_hdr *ph; |
916 | int data_len = skb->len; | 916 | int data_len = skb->len; |
917 | 917 | ||
918 | /* The higher-level PPP code (ppp_unregister_channel()) ensures the PPP | ||
919 | * xmit operations conclude prior to an unregistration call. Thus | ||
920 | * sk->sk_state cannot change, so we don't need to do lock_sock(). | ||
921 | * But, we also can't do a lock_sock since that introduces a potential | ||
922 | * deadlock as we'd reverse the lock ordering used when calling | ||
923 | * ppp_unregister_channel(). | ||
924 | */ | ||
925 | |||
918 | if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) | 926 | if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) |
919 | goto abort; | 927 | goto abort; |
920 | 928 | ||
@@ -944,7 +952,6 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) | |||
944 | po->pppoe_pa.remote, NULL, data_len); | 952 | po->pppoe_pa.remote, NULL, data_len); |
945 | 953 | ||
946 | dev_queue_xmit(skb); | 954 | dev_queue_xmit(skb); |
947 | |||
948 | return 1; | 955 | return 1; |
949 | 956 | ||
950 | abort: | 957 | abort: |
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h index 30d5585beeee..c2383adcd527 100644 --- a/drivers/net/qlge/qlge.h +++ b/drivers/net/qlge/qlge.h | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/pci.h> | 10 | #include <linux/pci.h> |
11 | #include <linux/netdevice.h> | 11 | #include <linux/netdevice.h> |
12 | #include <linux/rtnetlink.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * General definitions... | 15 | * General definitions... |
@@ -94,6 +95,7 @@ enum { | |||
94 | 95 | ||
95 | /* Misc. stuff */ | 96 | /* Misc. stuff */ |
96 | MAILBOX_COUNT = 16, | 97 | MAILBOX_COUNT = 16, |
98 | MAILBOX_TIMEOUT = 5, | ||
97 | 99 | ||
98 | PROC_ADDR_RDY = (1 << 31), | 100 | PROC_ADDR_RDY = (1 << 31), |
99 | PROC_ADDR_R = (1 << 30), | 101 | PROC_ADDR_R = (1 << 30), |
@@ -135,9 +137,9 @@ enum { | |||
135 | RST_FO_TFO = (1 << 0), | 137 | RST_FO_TFO = (1 << 0), |
136 | RST_FO_RR_MASK = 0x00060000, | 138 | RST_FO_RR_MASK = 0x00060000, |
137 | RST_FO_RR_CQ_CAM = 0x00000000, | 139 | RST_FO_RR_CQ_CAM = 0x00000000, |
138 | RST_FO_RR_DROP = 0x00000001, | 140 | RST_FO_RR_DROP = 0x00000002, |
139 | RST_FO_RR_DQ = 0x00000002, | 141 | RST_FO_RR_DQ = 0x00000004, |
140 | RST_FO_RR_RCV_FUNC_CQ = 0x00000003, | 142 | RST_FO_RR_RCV_FUNC_CQ = 0x00000006, |
141 | RST_FO_FRB = (1 << 12), | 143 | RST_FO_FRB = (1 << 12), |
142 | RST_FO_MOP = (1 << 13), | 144 | RST_FO_MOP = (1 << 13), |
143 | RST_FO_REG = (1 << 14), | 145 | RST_FO_REG = (1 << 14), |
@@ -802,6 +804,12 @@ enum { | |||
802 | MB_CMD_SET_PORT_CFG = 0x00000122, | 804 | MB_CMD_SET_PORT_CFG = 0x00000122, |
803 | MB_CMD_GET_PORT_CFG = 0x00000123, | 805 | MB_CMD_GET_PORT_CFG = 0x00000123, |
804 | MB_CMD_GET_LINK_STS = 0x00000124, | 806 | MB_CMD_GET_LINK_STS = 0x00000124, |
807 | MB_CMD_SET_MGMNT_TFK_CTL = 0x00000160, /* Set Mgmnt Traffic Control */ | ||
808 | MB_SET_MPI_TFK_STOP = (1 << 0), | ||
809 | MB_SET_MPI_TFK_RESUME = (1 << 1), | ||
810 | MB_CMD_GET_MGMNT_TFK_CTL = 0x00000161, /* Get Mgmnt Traffic Control */ | ||
811 | MB_GET_MPI_TFK_STOPPED = (1 << 0), | ||
812 | MB_GET_MPI_TFK_FIFO_EMPTY = (1 << 1), | ||
805 | 813 | ||
806 | /* Mailbox Command Status. */ | 814 | /* Mailbox Command Status. */ |
807 | MB_CMD_STS_GOOD = 0x00004000, /* Success. */ | 815 | MB_CMD_STS_GOOD = 0x00004000, /* Success. */ |
@@ -1167,7 +1175,7 @@ struct ricb { | |||
1167 | #define RSS_RI6 0x40 | 1175 | #define RSS_RI6 0x40 |
1168 | #define RSS_RT6 0x80 | 1176 | #define RSS_RT6 0x80 |
1169 | __le16 mask; | 1177 | __le16 mask; |
1170 | __le32 hash_cq_id[256]; | 1178 | u8 hash_cq_id[1024]; |
1171 | __le32 ipv6_hash_key[10]; | 1179 | __le32 ipv6_hash_key[10]; |
1172 | __le32 ipv4_hash_key[4]; | 1180 | __le32 ipv4_hash_key[4]; |
1173 | } __attribute((packed)); | 1181 | } __attribute((packed)); |
@@ -1477,7 +1485,6 @@ struct ql_adapter { | |||
1477 | u32 mailbox_in; | 1485 | u32 mailbox_in; |
1478 | u32 mailbox_out; | 1486 | u32 mailbox_out; |
1479 | struct mbox_params idc_mbc; | 1487 | struct mbox_params idc_mbc; |
1480 | struct mutex mpi_mutex; | ||
1481 | 1488 | ||
1482 | int tx_ring_size; | 1489 | int tx_ring_size; |
1483 | int rx_ring_size; | 1490 | int rx_ring_size; |
@@ -1606,6 +1613,8 @@ int ql_read_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 *data); | |||
1606 | int ql_mb_about_fw(struct ql_adapter *qdev); | 1613 | int ql_mb_about_fw(struct ql_adapter *qdev); |
1607 | void ql_link_on(struct ql_adapter *qdev); | 1614 | void ql_link_on(struct ql_adapter *qdev); |
1608 | void ql_link_off(struct ql_adapter *qdev); | 1615 | void ql_link_off(struct ql_adapter *qdev); |
1616 | int ql_mb_set_mgmnt_traffic_ctl(struct ql_adapter *qdev, u32 control); | ||
1617 | int ql_wait_fifo_empty(struct ql_adapter *qdev); | ||
1609 | 1618 | ||
1610 | #if 1 | 1619 | #if 1 |
1611 | #define QL_ALL_DUMP | 1620 | #define QL_ALL_DUMP |
diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c index 68f9bd280f86..52073946bce3 100644 --- a/drivers/net/qlge/qlge_ethtool.c +++ b/drivers/net/qlge/qlge_ethtool.c | |||
@@ -45,7 +45,6 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev) | |||
45 | if (!netif_running(qdev->ndev)) | 45 | if (!netif_running(qdev->ndev)) |
46 | return status; | 46 | return status; |
47 | 47 | ||
48 | spin_lock(&qdev->hw_lock); | ||
49 | /* Skip the default queue, and update the outbound handler | 48 | /* Skip the default queue, and update the outbound handler |
50 | * queues if they changed. | 49 | * queues if they changed. |
51 | */ | 50 | */ |
@@ -92,7 +91,6 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev) | |||
92 | } | 91 | } |
93 | } | 92 | } |
94 | exit: | 93 | exit: |
95 | spin_unlock(&qdev->hw_lock); | ||
96 | return status; | 94 | return status; |
97 | } | 95 | } |
98 | 96 | ||
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c index 3d0efea32111..cea7531f4f40 100644 --- a/drivers/net/qlge/qlge_main.c +++ b/drivers/net/qlge/qlge_main.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/etherdevice.h> | 34 | #include <linux/etherdevice.h> |
35 | #include <linux/ethtool.h> | 35 | #include <linux/ethtool.h> |
36 | #include <linux/skbuff.h> | 36 | #include <linux/skbuff.h> |
37 | #include <linux/rtnetlink.h> | ||
38 | #include <linux/if_vlan.h> | 37 | #include <linux/if_vlan.h> |
39 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
40 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
@@ -321,6 +320,37 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type, | |||
321 | 320 | ||
322 | switch (type) { | 321 | switch (type) { |
323 | case MAC_ADDR_TYPE_MULTI_MAC: | 322 | case MAC_ADDR_TYPE_MULTI_MAC: |
323 | { | ||
324 | u32 upper = (addr[0] << 8) | addr[1]; | ||
325 | u32 lower = (addr[2] << 24) | (addr[3] << 16) | | ||
326 | (addr[4] << 8) | (addr[5]); | ||
327 | |||
328 | status = | ||
329 | ql_wait_reg_rdy(qdev, | ||
330 | MAC_ADDR_IDX, MAC_ADDR_MW, 0); | ||
331 | if (status) | ||
332 | goto exit; | ||
333 | ql_write32(qdev, MAC_ADDR_IDX, (offset++) | | ||
334 | (index << MAC_ADDR_IDX_SHIFT) | | ||
335 | type | MAC_ADDR_E); | ||
336 | ql_write32(qdev, MAC_ADDR_DATA, lower); | ||
337 | status = | ||
338 | ql_wait_reg_rdy(qdev, | ||
339 | MAC_ADDR_IDX, MAC_ADDR_MW, 0); | ||
340 | if (status) | ||
341 | goto exit; | ||
342 | ql_write32(qdev, MAC_ADDR_IDX, (offset++) | | ||
343 | (index << MAC_ADDR_IDX_SHIFT) | | ||
344 | type | MAC_ADDR_E); | ||
345 | |||
346 | ql_write32(qdev, MAC_ADDR_DATA, upper); | ||
347 | status = | ||
348 | ql_wait_reg_rdy(qdev, | ||
349 | MAC_ADDR_IDX, MAC_ADDR_MW, 0); | ||
350 | if (status) | ||
351 | goto exit; | ||
352 | break; | ||
353 | } | ||
324 | case MAC_ADDR_TYPE_CAM_MAC: | 354 | case MAC_ADDR_TYPE_CAM_MAC: |
325 | { | 355 | { |
326 | u32 cam_output; | 356 | u32 cam_output; |
@@ -366,16 +396,14 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type, | |||
366 | and possibly the function id. Right now we hardcode | 396 | and possibly the function id. Right now we hardcode |
367 | the route field to NIC core. | 397 | the route field to NIC core. |
368 | */ | 398 | */ |
369 | if (type == MAC_ADDR_TYPE_CAM_MAC) { | 399 | cam_output = (CAM_OUT_ROUTE_NIC | |
370 | cam_output = (CAM_OUT_ROUTE_NIC | | 400 | (qdev-> |
371 | (qdev-> | 401 | func << CAM_OUT_FUNC_SHIFT) | |
372 | func << CAM_OUT_FUNC_SHIFT) | | 402 | (0 << CAM_OUT_CQ_ID_SHIFT)); |
373 | (0 << CAM_OUT_CQ_ID_SHIFT)); | 403 | if (qdev->vlgrp) |
374 | if (qdev->vlgrp) | 404 | cam_output |= CAM_OUT_RV; |
375 | cam_output |= CAM_OUT_RV; | 405 | /* route to NIC core */ |
376 | /* route to NIC core */ | 406 | ql_write32(qdev, MAC_ADDR_DATA, cam_output); |
377 | ql_write32(qdev, MAC_ADDR_DATA, cam_output); | ||
378 | } | ||
379 | break; | 407 | break; |
380 | } | 408 | } |
381 | case MAC_ADDR_TYPE_VLAN: | 409 | case MAC_ADDR_TYPE_VLAN: |
@@ -547,14 +575,14 @@ static int ql_set_routing_reg(struct ql_adapter *qdev, u32 index, u32 mask, | |||
547 | } | 575 | } |
548 | case RT_IDX_MCAST: /* Pass up All Multicast frames. */ | 576 | case RT_IDX_MCAST: /* Pass up All Multicast frames. */ |
549 | { | 577 | { |
550 | value = RT_IDX_DST_CAM_Q | /* dest */ | 578 | value = RT_IDX_DST_DFLT_Q | /* dest */ |
551 | RT_IDX_TYPE_NICQ | /* type */ | 579 | RT_IDX_TYPE_NICQ | /* type */ |
552 | (RT_IDX_ALLMULTI_SLOT << RT_IDX_IDX_SHIFT);/* index */ | 580 | (RT_IDX_ALLMULTI_SLOT << RT_IDX_IDX_SHIFT);/* index */ |
553 | break; | 581 | break; |
554 | } | 582 | } |
555 | case RT_IDX_MCAST_MATCH: /* Pass up matched Multicast frames. */ | 583 | case RT_IDX_MCAST_MATCH: /* Pass up matched Multicast frames. */ |
556 | { | 584 | { |
557 | value = RT_IDX_DST_CAM_Q | /* dest */ | 585 | value = RT_IDX_DST_DFLT_Q | /* dest */ |
558 | RT_IDX_TYPE_NICQ | /* type */ | 586 | RT_IDX_TYPE_NICQ | /* type */ |
559 | (RT_IDX_MCAST_MATCH_SLOT << RT_IDX_IDX_SHIFT);/* index */ | 587 | (RT_IDX_MCAST_MATCH_SLOT << RT_IDX_IDX_SHIFT);/* index */ |
560 | break; | 588 | break; |
@@ -1926,12 +1954,10 @@ static void ql_vlan_rx_add_vid(struct net_device *ndev, u16 vid) | |||
1926 | status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK); | 1954 | status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK); |
1927 | if (status) | 1955 | if (status) |
1928 | return; | 1956 | return; |
1929 | spin_lock(&qdev->hw_lock); | ||
1930 | if (ql_set_mac_addr_reg | 1957 | if (ql_set_mac_addr_reg |
1931 | (qdev, (u8 *) &enable_bit, MAC_ADDR_TYPE_VLAN, vid)) { | 1958 | (qdev, (u8 *) &enable_bit, MAC_ADDR_TYPE_VLAN, vid)) { |
1932 | QPRINTK(qdev, IFUP, ERR, "Failed to init vlan address.\n"); | 1959 | QPRINTK(qdev, IFUP, ERR, "Failed to init vlan address.\n"); |
1933 | } | 1960 | } |
1934 | spin_unlock(&qdev->hw_lock); | ||
1935 | ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); | 1961 | ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); |
1936 | } | 1962 | } |
1937 | 1963 | ||
@@ -1945,12 +1971,10 @@ static void ql_vlan_rx_kill_vid(struct net_device *ndev, u16 vid) | |||
1945 | if (status) | 1971 | if (status) |
1946 | return; | 1972 | return; |
1947 | 1973 | ||
1948 | spin_lock(&qdev->hw_lock); | ||
1949 | if (ql_set_mac_addr_reg | 1974 | if (ql_set_mac_addr_reg |
1950 | (qdev, (u8 *) &enable_bit, MAC_ADDR_TYPE_VLAN, vid)) { | 1975 | (qdev, (u8 *) &enable_bit, MAC_ADDR_TYPE_VLAN, vid)) { |
1951 | QPRINTK(qdev, IFUP, ERR, "Failed to clear vlan address.\n"); | 1976 | QPRINTK(qdev, IFUP, ERR, "Failed to clear vlan address.\n"); |
1952 | } | 1977 | } |
1953 | spin_unlock(&qdev->hw_lock); | ||
1954 | ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); | 1978 | ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); |
1955 | 1979 | ||
1956 | } | 1980 | } |
@@ -2001,15 +2025,17 @@ static irqreturn_t qlge_isr(int irq, void *dev_id) | |||
2001 | /* | 2025 | /* |
2002 | * Check MPI processor activity. | 2026 | * Check MPI processor activity. |
2003 | */ | 2027 | */ |
2004 | if (var & STS_PI) { | 2028 | if ((var & STS_PI) && |
2029 | (ql_read32(qdev, INTR_MASK) & INTR_MASK_PI)) { | ||
2005 | /* | 2030 | /* |
2006 | * We've got an async event or mailbox completion. | 2031 | * We've got an async event or mailbox completion. |
2007 | * Handle it and clear the source of the interrupt. | 2032 | * Handle it and clear the source of the interrupt. |
2008 | */ | 2033 | */ |
2009 | QPRINTK(qdev, INTR, ERR, "Got MPI processor interrupt.\n"); | 2034 | QPRINTK(qdev, INTR, ERR, "Got MPI processor interrupt.\n"); |
2010 | ql_disable_completion_interrupt(qdev, intr_context->intr); | 2035 | ql_disable_completion_interrupt(qdev, intr_context->intr); |
2011 | queue_delayed_work_on(smp_processor_id(), qdev->workqueue, | 2036 | ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); |
2012 | &qdev->mpi_work, 0); | 2037 | queue_delayed_work_on(smp_processor_id(), |
2038 | qdev->workqueue, &qdev->mpi_work, 0); | ||
2013 | work_done++; | 2039 | work_done++; |
2014 | } | 2040 | } |
2015 | 2041 | ||
@@ -3080,6 +3106,12 @@ err_irq: | |||
3080 | 3106 | ||
3081 | static int ql_start_rss(struct ql_adapter *qdev) | 3107 | static int ql_start_rss(struct ql_adapter *qdev) |
3082 | { | 3108 | { |
3109 | u8 init_hash_seed[] = {0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, | ||
3110 | 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, | ||
3111 | 0xb0, 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, | ||
3112 | 0x30, 0xb4, 0x77, 0xcb, 0x2d, 0xa3, 0x80, | ||
3113 | 0x30, 0xf2, 0x0c, 0x6a, 0x42, 0xb7, 0x3b, | ||
3114 | 0xbe, 0xac, 0x01, 0xfa}; | ||
3083 | struct ricb *ricb = &qdev->ricb; | 3115 | struct ricb *ricb = &qdev->ricb; |
3084 | int status = 0; | 3116 | int status = 0; |
3085 | int i; | 3117 | int i; |
@@ -3089,21 +3121,17 @@ static int ql_start_rss(struct ql_adapter *qdev) | |||
3089 | 3121 | ||
3090 | ricb->base_cq = RSS_L4K; | 3122 | ricb->base_cq = RSS_L4K; |
3091 | ricb->flags = | 3123 | ricb->flags = |
3092 | (RSS_L6K | RSS_LI | RSS_LB | RSS_LM | RSS_RI4 | RSS_RI6 | RSS_RT4 | | 3124 | (RSS_L6K | RSS_LI | RSS_LB | RSS_LM | RSS_RT4 | RSS_RT6); |
3093 | RSS_RT6); | 3125 | ricb->mask = cpu_to_le16((u16)(0x3ff)); |
3094 | ricb->mask = cpu_to_le16(qdev->rss_ring_count - 1); | ||
3095 | 3126 | ||
3096 | /* | 3127 | /* |
3097 | * Fill out the Indirection Table. | 3128 | * Fill out the Indirection Table. |
3098 | */ | 3129 | */ |
3099 | for (i = 0; i < 256; i++) | 3130 | for (i = 0; i < 1024; i++) |
3100 | hash_id[i] = i & (qdev->rss_ring_count - 1); | 3131 | hash_id[i] = (i & (qdev->rss_ring_count - 1)); |
3101 | 3132 | ||
3102 | /* | 3133 | memcpy((void *)&ricb->ipv6_hash_key[0], init_hash_seed, 40); |
3103 | * Random values for the IPv6 and IPv4 Hash Keys. | 3134 | memcpy((void *)&ricb->ipv4_hash_key[0], init_hash_seed, 16); |
3104 | */ | ||
3105 | get_random_bytes((void *)&ricb->ipv6_hash_key[0], 40); | ||
3106 | get_random_bytes((void *)&ricb->ipv4_hash_key[0], 16); | ||
3107 | 3135 | ||
3108 | QPRINTK(qdev, IFUP, DEBUG, "Initializing RSS.\n"); | 3136 | QPRINTK(qdev, IFUP, DEBUG, "Initializing RSS.\n"); |
3109 | 3137 | ||
@@ -3242,6 +3270,13 @@ static int ql_adapter_initialize(struct ql_adapter *qdev) | |||
3242 | ql_write32(qdev, SPLT_HDR, SPLT_HDR_EP | | 3270 | ql_write32(qdev, SPLT_HDR, SPLT_HDR_EP | |
3243 | min(SMALL_BUFFER_SIZE, MAX_SPLIT_SIZE)); | 3271 | min(SMALL_BUFFER_SIZE, MAX_SPLIT_SIZE)); |
3244 | 3272 | ||
3273 | /* Set RX packet routing to use port/pci function on which the | ||
3274 | * packet arrived on in addition to usual frame routing. | ||
3275 | * This is helpful on bonding where both interfaces can have | ||
3276 | * the same MAC address. | ||
3277 | */ | ||
3278 | ql_write32(qdev, RST_FO, RST_FO_RR_MASK | RST_FO_RR_RCV_FUNC_CQ); | ||
3279 | |||
3245 | /* Start up the rx queues. */ | 3280 | /* Start up the rx queues. */ |
3246 | for (i = 0; i < qdev->rx_ring_count; i++) { | 3281 | for (i = 0; i < qdev->rx_ring_count; i++) { |
3247 | status = ql_start_rx_ring(qdev, &qdev->rx_ring[i]); | 3282 | status = ql_start_rx_ring(qdev, &qdev->rx_ring[i]); |
@@ -3314,6 +3349,13 @@ static int ql_adapter_reset(struct ql_adapter *qdev) | |||
3314 | 3349 | ||
3315 | end_jiffies = jiffies + | 3350 | end_jiffies = jiffies + |
3316 | max((unsigned long)1, usecs_to_jiffies(30)); | 3351 | max((unsigned long)1, usecs_to_jiffies(30)); |
3352 | |||
3353 | /* Stop management traffic. */ | ||
3354 | ql_mb_set_mgmnt_traffic_ctl(qdev, MB_SET_MPI_TFK_STOP); | ||
3355 | |||
3356 | /* Wait for the NIC and MGMNT FIFOs to empty. */ | ||
3357 | ql_wait_fifo_empty(qdev); | ||
3358 | |||
3317 | ql_write32(qdev, RST_FO, (RST_FO_FR << 16) | RST_FO_FR); | 3359 | ql_write32(qdev, RST_FO, (RST_FO_FR << 16) | RST_FO_FR); |
3318 | 3360 | ||
3319 | do { | 3361 | do { |
@@ -3329,6 +3371,8 @@ static int ql_adapter_reset(struct ql_adapter *qdev) | |||
3329 | status = -ETIMEDOUT; | 3371 | status = -ETIMEDOUT; |
3330 | } | 3372 | } |
3331 | 3373 | ||
3374 | /* Resume management traffic. */ | ||
3375 | ql_mb_set_mgmnt_traffic_ctl(qdev, MB_SET_MPI_TFK_RESUME); | ||
3332 | return status; | 3376 | return status; |
3333 | } | 3377 | } |
3334 | 3378 | ||
@@ -3585,7 +3629,6 @@ static void qlge_set_multicast_list(struct net_device *ndev) | |||
3585 | status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK); | 3629 | status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK); |
3586 | if (status) | 3630 | if (status) |
3587 | return; | 3631 | return; |
3588 | spin_lock(&qdev->hw_lock); | ||
3589 | /* | 3632 | /* |
3590 | * Set or clear promiscuous mode if a | 3633 | * Set or clear promiscuous mode if a |
3591 | * transition is taking place. | 3634 | * transition is taking place. |
@@ -3662,7 +3705,6 @@ static void qlge_set_multicast_list(struct net_device *ndev) | |||
3662 | } | 3705 | } |
3663 | } | 3706 | } |
3664 | exit: | 3707 | exit: |
3665 | spin_unlock(&qdev->hw_lock); | ||
3666 | ql_sem_unlock(qdev, SEM_RT_IDX_MASK); | 3708 | ql_sem_unlock(qdev, SEM_RT_IDX_MASK); |
3667 | } | 3709 | } |
3668 | 3710 | ||
@@ -3682,10 +3724,8 @@ static int qlge_set_mac_address(struct net_device *ndev, void *p) | |||
3682 | status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK); | 3724 | status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK); |
3683 | if (status) | 3725 | if (status) |
3684 | return status; | 3726 | return status; |
3685 | spin_lock(&qdev->hw_lock); | ||
3686 | status = ql_set_mac_addr_reg(qdev, (u8 *) ndev->dev_addr, | 3727 | status = ql_set_mac_addr_reg(qdev, (u8 *) ndev->dev_addr, |
3687 | MAC_ADDR_TYPE_CAM_MAC, qdev->func * MAX_CQ); | 3728 | MAC_ADDR_TYPE_CAM_MAC, qdev->func * MAX_CQ); |
3688 | spin_unlock(&qdev->hw_lock); | ||
3689 | if (status) | 3729 | if (status) |
3690 | QPRINTK(qdev, HW, ERR, "Failed to load MAC address.\n"); | 3730 | QPRINTK(qdev, HW, ERR, "Failed to load MAC address.\n"); |
3691 | ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); | 3731 | ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); |
@@ -3711,6 +3751,12 @@ static void ql_asic_reset_work(struct work_struct *work) | |||
3711 | status = ql_adapter_up(qdev); | 3751 | status = ql_adapter_up(qdev); |
3712 | if (status) | 3752 | if (status) |
3713 | goto error; | 3753 | goto error; |
3754 | |||
3755 | /* Restore rx mode. */ | ||
3756 | clear_bit(QL_ALLMULTI, &qdev->flags); | ||
3757 | clear_bit(QL_PROMISCUOUS, &qdev->flags); | ||
3758 | qlge_set_multicast_list(qdev->ndev); | ||
3759 | |||
3714 | rtnl_unlock(); | 3760 | rtnl_unlock(); |
3715 | return; | 3761 | return; |
3716 | error: | 3762 | error: |
@@ -3870,6 +3916,7 @@ static int __devinit ql_init_device(struct pci_dev *pdev, | |||
3870 | goto err_out; | 3916 | goto err_out; |
3871 | } | 3917 | } |
3872 | 3918 | ||
3919 | pci_save_state(pdev); | ||
3873 | qdev->reg_base = | 3920 | qdev->reg_base = |
3874 | ioremap_nocache(pci_resource_start(pdev, 1), | 3921 | ioremap_nocache(pci_resource_start(pdev, 1), |
3875 | pci_resource_len(pdev, 1)); | 3922 | pci_resource_len(pdev, 1)); |
@@ -3928,7 +3975,6 @@ static int __devinit ql_init_device(struct pci_dev *pdev, | |||
3928 | INIT_DELAYED_WORK(&qdev->mpi_work, ql_mpi_work); | 3975 | INIT_DELAYED_WORK(&qdev->mpi_work, ql_mpi_work); |
3929 | INIT_DELAYED_WORK(&qdev->mpi_port_cfg_work, ql_mpi_port_cfg_work); | 3976 | INIT_DELAYED_WORK(&qdev->mpi_port_cfg_work, ql_mpi_port_cfg_work); |
3930 | INIT_DELAYED_WORK(&qdev->mpi_idc_work, ql_mpi_idc_work); | 3977 | INIT_DELAYED_WORK(&qdev->mpi_idc_work, ql_mpi_idc_work); |
3931 | mutex_init(&qdev->mpi_mutex); | ||
3932 | init_completion(&qdev->ide_completion); | 3978 | init_completion(&qdev->ide_completion); |
3933 | 3979 | ||
3934 | if (!cards_found) { | 3980 | if (!cards_found) { |
@@ -4025,6 +4071,33 @@ static void __devexit qlge_remove(struct pci_dev *pdev) | |||
4025 | free_netdev(ndev); | 4071 | free_netdev(ndev); |
4026 | } | 4072 | } |
4027 | 4073 | ||
4074 | /* Clean up resources without touching hardware. */ | ||
4075 | static void ql_eeh_close(struct net_device *ndev) | ||
4076 | { | ||
4077 | int i; | ||
4078 | struct ql_adapter *qdev = netdev_priv(ndev); | ||
4079 | |||
4080 | if (netif_carrier_ok(ndev)) { | ||
4081 | netif_carrier_off(ndev); | ||
4082 | netif_stop_queue(ndev); | ||
4083 | } | ||
4084 | |||
4085 | if (test_bit(QL_ADAPTER_UP, &qdev->flags)) | ||
4086 | cancel_delayed_work_sync(&qdev->asic_reset_work); | ||
4087 | cancel_delayed_work_sync(&qdev->mpi_reset_work); | ||
4088 | cancel_delayed_work_sync(&qdev->mpi_work); | ||
4089 | cancel_delayed_work_sync(&qdev->mpi_idc_work); | ||
4090 | cancel_delayed_work_sync(&qdev->mpi_port_cfg_work); | ||
4091 | |||
4092 | for (i = 0; i < qdev->rss_ring_count; i++) | ||
4093 | netif_napi_del(&qdev->rx_ring[i].napi); | ||
4094 | |||
4095 | clear_bit(QL_ADAPTER_UP, &qdev->flags); | ||
4096 | ql_tx_ring_clean(qdev); | ||
4097 | ql_free_rx_buffers(qdev); | ||
4098 | ql_release_adapter_resources(qdev); | ||
4099 | } | ||
4100 | |||
4028 | /* | 4101 | /* |
4029 | * This callback is called by the PCI subsystem whenever | 4102 | * This callback is called by the PCI subsystem whenever |
4030 | * a PCI bus error is detected. | 4103 | * a PCI bus error is detected. |
@@ -4033,17 +4106,21 @@ static pci_ers_result_t qlge_io_error_detected(struct pci_dev *pdev, | |||
4033 | enum pci_channel_state state) | 4106 | enum pci_channel_state state) |
4034 | { | 4107 | { |
4035 | struct net_device *ndev = pci_get_drvdata(pdev); | 4108 | struct net_device *ndev = pci_get_drvdata(pdev); |
4036 | struct ql_adapter *qdev = netdev_priv(ndev); | ||
4037 | 4109 | ||
4038 | netif_device_detach(ndev); | 4110 | switch (state) { |
4039 | 4111 | case pci_channel_io_normal: | |
4040 | if (state == pci_channel_io_perm_failure) | 4112 | return PCI_ERS_RESULT_CAN_RECOVER; |
4113 | case pci_channel_io_frozen: | ||
4114 | netif_device_detach(ndev); | ||
4115 | if (netif_running(ndev)) | ||
4116 | ql_eeh_close(ndev); | ||
4117 | pci_disable_device(pdev); | ||
4118 | return PCI_ERS_RESULT_NEED_RESET; | ||
4119 | case pci_channel_io_perm_failure: | ||
4120 | dev_err(&pdev->dev, | ||
4121 | "%s: pci_channel_io_perm_failure.\n", __func__); | ||
4041 | return PCI_ERS_RESULT_DISCONNECT; | 4122 | return PCI_ERS_RESULT_DISCONNECT; |
4042 | 4123 | } | |
4043 | if (netif_running(ndev)) | ||
4044 | ql_adapter_down(qdev); | ||
4045 | |||
4046 | pci_disable_device(pdev); | ||
4047 | 4124 | ||
4048 | /* Request a slot reset. */ | 4125 | /* Request a slot reset. */ |
4049 | return PCI_ERS_RESULT_NEED_RESET; | 4126 | return PCI_ERS_RESULT_NEED_RESET; |
@@ -4060,25 +4137,15 @@ static pci_ers_result_t qlge_io_slot_reset(struct pci_dev *pdev) | |||
4060 | struct net_device *ndev = pci_get_drvdata(pdev); | 4137 | struct net_device *ndev = pci_get_drvdata(pdev); |
4061 | struct ql_adapter *qdev = netdev_priv(ndev); | 4138 | struct ql_adapter *qdev = netdev_priv(ndev); |
4062 | 4139 | ||
4140 | pdev->error_state = pci_channel_io_normal; | ||
4141 | |||
4142 | pci_restore_state(pdev); | ||
4063 | if (pci_enable_device(pdev)) { | 4143 | if (pci_enable_device(pdev)) { |
4064 | QPRINTK(qdev, IFUP, ERR, | 4144 | QPRINTK(qdev, IFUP, ERR, |
4065 | "Cannot re-enable PCI device after reset.\n"); | 4145 | "Cannot re-enable PCI device after reset.\n"); |
4066 | return PCI_ERS_RESULT_DISCONNECT; | 4146 | return PCI_ERS_RESULT_DISCONNECT; |
4067 | } | 4147 | } |
4068 | |||
4069 | pci_set_master(pdev); | 4148 | pci_set_master(pdev); |
4070 | |||
4071 | netif_carrier_off(ndev); | ||
4072 | ql_adapter_reset(qdev); | ||
4073 | |||
4074 | /* Make sure the EEPROM is good */ | ||
4075 | memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len); | ||
4076 | |||
4077 | if (!is_valid_ether_addr(ndev->perm_addr)) { | ||
4078 | QPRINTK(qdev, IFUP, ERR, "After reset, invalid MAC address.\n"); | ||
4079 | return PCI_ERS_RESULT_DISCONNECT; | ||
4080 | } | ||
4081 | |||
4082 | return PCI_ERS_RESULT_RECOVERED; | 4149 | return PCI_ERS_RESULT_RECOVERED; |
4083 | } | 4150 | } |
4084 | 4151 | ||
@@ -4086,17 +4153,21 @@ static void qlge_io_resume(struct pci_dev *pdev) | |||
4086 | { | 4153 | { |
4087 | struct net_device *ndev = pci_get_drvdata(pdev); | 4154 | struct net_device *ndev = pci_get_drvdata(pdev); |
4088 | struct ql_adapter *qdev = netdev_priv(ndev); | 4155 | struct ql_adapter *qdev = netdev_priv(ndev); |
4156 | int err = 0; | ||
4089 | 4157 | ||
4090 | pci_set_master(pdev); | 4158 | if (ql_adapter_reset(qdev)) |
4091 | 4159 | QPRINTK(qdev, DRV, ERR, "reset FAILED!\n"); | |
4092 | if (netif_running(ndev)) { | 4160 | if (netif_running(ndev)) { |
4093 | if (ql_adapter_up(qdev)) { | 4161 | err = qlge_open(ndev); |
4162 | if (err) { | ||
4094 | QPRINTK(qdev, IFUP, ERR, | 4163 | QPRINTK(qdev, IFUP, ERR, |
4095 | "Device initialization failed after reset.\n"); | 4164 | "Device initialization failed after reset.\n"); |
4096 | return; | 4165 | return; |
4097 | } | 4166 | } |
4167 | } else { | ||
4168 | QPRINTK(qdev, IFUP, ERR, | ||
4169 | "Device was not running prior to EEH.\n"); | ||
4098 | } | 4170 | } |
4099 | |||
4100 | netif_device_attach(ndev); | 4171 | netif_device_attach(ndev); |
4101 | } | 4172 | } |
4102 | 4173 | ||
diff --git a/drivers/net/qlge/qlge_mpi.c b/drivers/net/qlge/qlge_mpi.c index 6685bd97da91..bcf13c96f73f 100644 --- a/drivers/net/qlge/qlge_mpi.c +++ b/drivers/net/qlge/qlge_mpi.c | |||
@@ -470,9 +470,9 @@ end: | |||
470 | */ | 470 | */ |
471 | static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp) | 471 | static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp) |
472 | { | 472 | { |
473 | int status, count; | 473 | int status; |
474 | unsigned long count; | ||
474 | 475 | ||
475 | mutex_lock(&qdev->mpi_mutex); | ||
476 | 476 | ||
477 | /* Begin polled mode for MPI */ | 477 | /* Begin polled mode for MPI */ |
478 | ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); | 478 | ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); |
@@ -492,9 +492,9 @@ static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp) | |||
492 | /* Wait for the command to complete. We loop | 492 | /* Wait for the command to complete. We loop |
493 | * here because some AEN might arrive while | 493 | * here because some AEN might arrive while |
494 | * we're waiting for the mailbox command to | 494 | * we're waiting for the mailbox command to |
495 | * complete. If more than 5 arrive then we can | 495 | * complete. If more than 5 seconds expire we can |
496 | * assume something is wrong. */ | 496 | * assume something is wrong. */ |
497 | count = 5; | 497 | count = jiffies + HZ * MAILBOX_TIMEOUT; |
498 | do { | 498 | do { |
499 | /* Wait for the interrupt to come in. */ | 499 | /* Wait for the interrupt to come in. */ |
500 | status = ql_wait_mbx_cmd_cmplt(qdev); | 500 | status = ql_wait_mbx_cmd_cmplt(qdev); |
@@ -518,15 +518,15 @@ static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp) | |||
518 | MB_CMD_STS_GOOD) || | 518 | MB_CMD_STS_GOOD) || |
519 | ((mbcp->mbox_out[0] & 0x0000f000) == | 519 | ((mbcp->mbox_out[0] & 0x0000f000) == |
520 | MB_CMD_STS_INTRMDT)) | 520 | MB_CMD_STS_INTRMDT)) |
521 | break; | 521 | goto done; |
522 | } while (--count); | 522 | } while (time_before(jiffies, count)); |
523 | 523 | ||
524 | if (!count) { | 524 | QPRINTK(qdev, DRV, ERR, |
525 | QPRINTK(qdev, DRV, ERR, | 525 | "Timed out waiting for mailbox complete.\n"); |
526 | "Timed out waiting for mailbox complete.\n"); | 526 | status = -ETIMEDOUT; |
527 | status = -ETIMEDOUT; | 527 | goto end; |
528 | goto end; | 528 | |
529 | } | 529 | done: |
530 | 530 | ||
531 | /* Now we can clear the interrupt condition | 531 | /* Now we can clear the interrupt condition |
532 | * and look at our status. | 532 | * and look at our status. |
@@ -541,7 +541,6 @@ static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp) | |||
541 | status = -EIO; | 541 | status = -EIO; |
542 | } | 542 | } |
543 | end: | 543 | end: |
544 | mutex_unlock(&qdev->mpi_mutex); | ||
545 | /* End polled mode for MPI */ | 544 | /* End polled mode for MPI */ |
546 | ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); | 545 | ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); |
547 | return status; | 546 | return status; |
@@ -770,13 +769,104 @@ static int ql_idc_wait(struct ql_adapter *qdev) | |||
770 | return status; | 769 | return status; |
771 | } | 770 | } |
772 | 771 | ||
772 | int ql_mb_set_mgmnt_traffic_ctl(struct ql_adapter *qdev, u32 control) | ||
773 | { | ||
774 | struct mbox_params mbc; | ||
775 | struct mbox_params *mbcp = &mbc; | ||
776 | int status; | ||
777 | |||
778 | memset(mbcp, 0, sizeof(struct mbox_params)); | ||
779 | |||
780 | mbcp->in_count = 1; | ||
781 | mbcp->out_count = 2; | ||
782 | |||
783 | mbcp->mbox_in[0] = MB_CMD_SET_MGMNT_TFK_CTL; | ||
784 | mbcp->mbox_in[1] = control; | ||
785 | |||
786 | status = ql_mailbox_command(qdev, mbcp); | ||
787 | if (status) | ||
788 | return status; | ||
789 | |||
790 | if (mbcp->mbox_out[0] == MB_CMD_STS_GOOD) | ||
791 | return status; | ||
792 | |||
793 | if (mbcp->mbox_out[0] == MB_CMD_STS_INVLD_CMD) { | ||
794 | QPRINTK(qdev, DRV, ERR, | ||
795 | "Command not supported by firmware.\n"); | ||
796 | status = -EINVAL; | ||
797 | } else if (mbcp->mbox_out[0] == MB_CMD_STS_ERR) { | ||
798 | /* This indicates that the firmware is | ||
799 | * already in the state we are trying to | ||
800 | * change it to. | ||
801 | */ | ||
802 | QPRINTK(qdev, DRV, ERR, | ||
803 | "Command parameters make no change.\n"); | ||
804 | } | ||
805 | return status; | ||
806 | } | ||
807 | |||
808 | /* Returns a negative error code or the mailbox command status. */ | ||
809 | static int ql_mb_get_mgmnt_traffic_ctl(struct ql_adapter *qdev, u32 *control) | ||
810 | { | ||
811 | struct mbox_params mbc; | ||
812 | struct mbox_params *mbcp = &mbc; | ||
813 | int status; | ||
814 | |||
815 | memset(mbcp, 0, sizeof(struct mbox_params)); | ||
816 | *control = 0; | ||
817 | |||
818 | mbcp->in_count = 1; | ||
819 | mbcp->out_count = 1; | ||
820 | |||
821 | mbcp->mbox_in[0] = MB_CMD_GET_MGMNT_TFK_CTL; | ||
822 | |||
823 | status = ql_mailbox_command(qdev, mbcp); | ||
824 | if (status) | ||
825 | return status; | ||
826 | |||
827 | if (mbcp->mbox_out[0] == MB_CMD_STS_GOOD) { | ||
828 | *control = mbcp->mbox_in[1]; | ||
829 | return status; | ||
830 | } | ||
831 | |||
832 | if (mbcp->mbox_out[0] == MB_CMD_STS_INVLD_CMD) { | ||
833 | QPRINTK(qdev, DRV, ERR, | ||
834 | "Command not supported by firmware.\n"); | ||
835 | status = -EINVAL; | ||
836 | } else if (mbcp->mbox_out[0] == MB_CMD_STS_ERR) { | ||
837 | QPRINTK(qdev, DRV, ERR, | ||
838 | "Failed to get MPI traffic control.\n"); | ||
839 | status = -EIO; | ||
840 | } | ||
841 | return status; | ||
842 | } | ||
843 | |||
844 | int ql_wait_fifo_empty(struct ql_adapter *qdev) | ||
845 | { | ||
846 | int count = 5; | ||
847 | u32 mgmnt_fifo_empty; | ||
848 | u32 nic_fifo_empty; | ||
849 | |||
850 | do { | ||
851 | nic_fifo_empty = ql_read32(qdev, STS) & STS_NFE; | ||
852 | ql_mb_get_mgmnt_traffic_ctl(qdev, &mgmnt_fifo_empty); | ||
853 | mgmnt_fifo_empty &= MB_GET_MPI_TFK_FIFO_EMPTY; | ||
854 | if (nic_fifo_empty && mgmnt_fifo_empty) | ||
855 | return 0; | ||
856 | msleep(100); | ||
857 | } while (count-- > 0); | ||
858 | return -ETIMEDOUT; | ||
859 | } | ||
860 | |||
773 | /* API called in work thread context to set new TX/RX | 861 | /* API called in work thread context to set new TX/RX |
774 | * maximum frame size values to match MTU. | 862 | * maximum frame size values to match MTU. |
775 | */ | 863 | */ |
776 | static int ql_set_port_cfg(struct ql_adapter *qdev) | 864 | static int ql_set_port_cfg(struct ql_adapter *qdev) |
777 | { | 865 | { |
778 | int status; | 866 | int status; |
867 | rtnl_lock(); | ||
779 | status = ql_mb_set_port_cfg(qdev); | 868 | status = ql_mb_set_port_cfg(qdev); |
869 | rtnl_unlock(); | ||
780 | if (status) | 870 | if (status) |
781 | return status; | 871 | return status; |
782 | status = ql_idc_wait(qdev); | 872 | status = ql_idc_wait(qdev); |
@@ -797,7 +887,9 @@ void ql_mpi_port_cfg_work(struct work_struct *work) | |||
797 | container_of(work, struct ql_adapter, mpi_port_cfg_work.work); | 887 | container_of(work, struct ql_adapter, mpi_port_cfg_work.work); |
798 | int status; | 888 | int status; |
799 | 889 | ||
890 | rtnl_lock(); | ||
800 | status = ql_mb_get_port_cfg(qdev); | 891 | status = ql_mb_get_port_cfg(qdev); |
892 | rtnl_unlock(); | ||
801 | if (status) { | 893 | if (status) { |
802 | QPRINTK(qdev, DRV, ERR, | 894 | QPRINTK(qdev, DRV, ERR, |
803 | "Bug: Failed to get port config data.\n"); | 895 | "Bug: Failed to get port config data.\n"); |
@@ -855,7 +947,9 @@ void ql_mpi_idc_work(struct work_struct *work) | |||
855 | * needs to be set. | 947 | * needs to be set. |
856 | * */ | 948 | * */ |
857 | set_bit(QL_CAM_RT_SET, &qdev->flags); | 949 | set_bit(QL_CAM_RT_SET, &qdev->flags); |
950 | rtnl_lock(); | ||
858 | status = ql_mb_idc_ack(qdev); | 951 | status = ql_mb_idc_ack(qdev); |
952 | rtnl_unlock(); | ||
859 | if (status) { | 953 | if (status) { |
860 | QPRINTK(qdev, DRV, ERR, | 954 | QPRINTK(qdev, DRV, ERR, |
861 | "Bug: No pending IDC!\n"); | 955 | "Bug: No pending IDC!\n"); |
@@ -871,7 +965,9 @@ void ql_mpi_work(struct work_struct *work) | |||
871 | struct mbox_params *mbcp = &mbc; | 965 | struct mbox_params *mbcp = &mbc; |
872 | int err = 0; | 966 | int err = 0; |
873 | 967 | ||
874 | mutex_lock(&qdev->mpi_mutex); | 968 | rtnl_lock(); |
969 | /* Begin polled mode for MPI */ | ||
970 | ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); | ||
875 | 971 | ||
876 | while (ql_read32(qdev, STS) & STS_PI) { | 972 | while (ql_read32(qdev, STS) & STS_PI) { |
877 | memset(mbcp, 0, sizeof(struct mbox_params)); | 973 | memset(mbcp, 0, sizeof(struct mbox_params)); |
@@ -884,7 +980,9 @@ void ql_mpi_work(struct work_struct *work) | |||
884 | break; | 980 | break; |
885 | } | 981 | } |
886 | 982 | ||
887 | mutex_unlock(&qdev->mpi_mutex); | 983 | /* End polled mode for MPI */ |
984 | ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); | ||
985 | rtnl_unlock(); | ||
888 | ql_enable_completion_interrupt(qdev, 0); | 986 | ql_enable_completion_interrupt(qdev, 0); |
889 | } | 987 | } |
890 | 988 | ||
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 50c6a3cfe439..f98ef523f525 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -115,7 +115,9 @@ enum mac_version { | |||
115 | RTL_GIGA_MAC_VER_22 = 0x16, // 8168C | 115 | RTL_GIGA_MAC_VER_22 = 0x16, // 8168C |
116 | RTL_GIGA_MAC_VER_23 = 0x17, // 8168CP | 116 | RTL_GIGA_MAC_VER_23 = 0x17, // 8168CP |
117 | RTL_GIGA_MAC_VER_24 = 0x18, // 8168CP | 117 | RTL_GIGA_MAC_VER_24 = 0x18, // 8168CP |
118 | RTL_GIGA_MAC_VER_25 = 0x19 // 8168D | 118 | RTL_GIGA_MAC_VER_25 = 0x19, // 8168D |
119 | RTL_GIGA_MAC_VER_26 = 0x1a, // 8168D | ||
120 | RTL_GIGA_MAC_VER_27 = 0x1b // 8168DP | ||
119 | }; | 121 | }; |
120 | 122 | ||
121 | #define _R(NAME,MAC,MASK) \ | 123 | #define _R(NAME,MAC,MASK) \ |
@@ -150,7 +152,9 @@ static const struct { | |||
150 | _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_22, 0xff7e1880), // PCI-E | 152 | _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_22, 0xff7e1880), // PCI-E |
151 | _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_23, 0xff7e1880), // PCI-E | 153 | _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_23, 0xff7e1880), // PCI-E |
152 | _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_24, 0xff7e1880), // PCI-E | 154 | _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_24, 0xff7e1880), // PCI-E |
153 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_25, 0xff7e1880) // PCI-E | 155 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_25, 0xff7e1880), // PCI-E |
156 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_26, 0xff7e1880), // PCI-E | ||
157 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_27, 0xff7e1880) // PCI-E | ||
154 | }; | 158 | }; |
155 | #undef _R | 159 | #undef _R |
156 | 160 | ||
@@ -253,6 +257,13 @@ enum rtl8168_8101_registers { | |||
253 | DBG_REG = 0xd1, | 257 | DBG_REG = 0xd1, |
254 | #define FIX_NAK_1 (1 << 4) | 258 | #define FIX_NAK_1 (1 << 4) |
255 | #define FIX_NAK_2 (1 << 3) | 259 | #define FIX_NAK_2 (1 << 3) |
260 | EFUSEAR = 0xdc, | ||
261 | #define EFUSEAR_FLAG 0x80000000 | ||
262 | #define EFUSEAR_WRITE_CMD 0x80000000 | ||
263 | #define EFUSEAR_READ_CMD 0x00000000 | ||
264 | #define EFUSEAR_REG_MASK 0x03ff | ||
265 | #define EFUSEAR_REG_SHIFT 8 | ||
266 | #define EFUSEAR_DATA_MASK 0xff | ||
256 | }; | 267 | }; |
257 | 268 | ||
258 | enum rtl_register_content { | 269 | enum rtl_register_content { |
@@ -568,6 +579,14 @@ static void mdio_patch(void __iomem *ioaddr, int reg_addr, int value) | |||
568 | mdio_write(ioaddr, reg_addr, mdio_read(ioaddr, reg_addr) | value); | 579 | mdio_write(ioaddr, reg_addr, mdio_read(ioaddr, reg_addr) | value); |
569 | } | 580 | } |
570 | 581 | ||
582 | static void mdio_plus_minus(void __iomem *ioaddr, int reg_addr, int p, int m) | ||
583 | { | ||
584 | int val; | ||
585 | |||
586 | val = mdio_read(ioaddr, reg_addr); | ||
587 | mdio_write(ioaddr, reg_addr, (val | p) & ~m); | ||
588 | } | ||
589 | |||
571 | static void rtl_mdio_write(struct net_device *dev, int phy_id, int location, | 590 | static void rtl_mdio_write(struct net_device *dev, int phy_id, int location, |
572 | int val) | 591 | int val) |
573 | { | 592 | { |
@@ -651,6 +670,24 @@ static u32 rtl_csi_read(void __iomem *ioaddr, int addr) | |||
651 | return value; | 670 | return value; |
652 | } | 671 | } |
653 | 672 | ||
673 | static u8 rtl8168d_efuse_read(void __iomem *ioaddr, int reg_addr) | ||
674 | { | ||
675 | u8 value = 0xff; | ||
676 | unsigned int i; | ||
677 | |||
678 | RTL_W32(EFUSEAR, (reg_addr & EFUSEAR_REG_MASK) << EFUSEAR_REG_SHIFT); | ||
679 | |||
680 | for (i = 0; i < 300; i++) { | ||
681 | if (RTL_R32(EFUSEAR) & EFUSEAR_FLAG) { | ||
682 | value = RTL_R32(EFUSEAR) & EFUSEAR_DATA_MASK; | ||
683 | break; | ||
684 | } | ||
685 | udelay(100); | ||
686 | } | ||
687 | |||
688 | return value; | ||
689 | } | ||
690 | |||
654 | static void rtl8169_irq_mask_and_ack(void __iomem *ioaddr) | 691 | static void rtl8169_irq_mask_and_ack(void __iomem *ioaddr) |
655 | { | 692 | { |
656 | RTL_W16(IntrMask, 0x0000); | 693 | RTL_W16(IntrMask, 0x0000); |
@@ -992,7 +1029,10 @@ static void rtl8169_vlan_rx_register(struct net_device *dev, | |||
992 | 1029 | ||
993 | spin_lock_irqsave(&tp->lock, flags); | 1030 | spin_lock_irqsave(&tp->lock, flags); |
994 | tp->vlgrp = grp; | 1031 | tp->vlgrp = grp; |
995 | if (tp->vlgrp) | 1032 | /* |
1033 | * Do not disable RxVlan on 8110SCd. | ||
1034 | */ | ||
1035 | if (tp->vlgrp || (tp->mac_version == RTL_GIGA_MAC_VER_05)) | ||
996 | tp->cp_cmd |= RxVlan; | 1036 | tp->cp_cmd |= RxVlan; |
997 | else | 1037 | else |
998 | tp->cp_cmd &= ~RxVlan; | 1038 | tp->cp_cmd &= ~RxVlan; |
@@ -1243,7 +1283,10 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, | |||
1243 | int mac_version; | 1283 | int mac_version; |
1244 | } mac_info[] = { | 1284 | } mac_info[] = { |
1245 | /* 8168D family. */ | 1285 | /* 8168D family. */ |
1246 | { 0x7c800000, 0x28000000, RTL_GIGA_MAC_VER_25 }, | 1286 | { 0x7cf00000, 0x28300000, RTL_GIGA_MAC_VER_26 }, |
1287 | { 0x7cf00000, 0x28100000, RTL_GIGA_MAC_VER_25 }, | ||
1288 | { 0x7c800000, 0x28800000, RTL_GIGA_MAC_VER_27 }, | ||
1289 | { 0x7c800000, 0x28000000, RTL_GIGA_MAC_VER_26 }, | ||
1247 | 1290 | ||
1248 | /* 8168C family. */ | 1291 | /* 8168C family. */ |
1249 | { 0x7cf00000, 0x3ca00000, RTL_GIGA_MAC_VER_24 }, | 1292 | { 0x7cf00000, 0x3ca00000, RTL_GIGA_MAC_VER_24 }, |
@@ -1648,74 +1691,903 @@ static void rtl8168c_4_hw_phy_config(void __iomem *ioaddr) | |||
1648 | rtl8168c_3_hw_phy_config(ioaddr); | 1691 | rtl8168c_3_hw_phy_config(ioaddr); |
1649 | } | 1692 | } |
1650 | 1693 | ||
1651 | static void rtl8168d_hw_phy_config(void __iomem *ioaddr) | 1694 | static void rtl8168d_1_hw_phy_config(void __iomem *ioaddr) |
1652 | { | 1695 | { |
1653 | struct phy_reg phy_reg_init_0[] = { | 1696 | static struct phy_reg phy_reg_init_0[] = { |
1654 | { 0x1f, 0x0001 }, | 1697 | { 0x1f, 0x0001 }, |
1655 | { 0x09, 0x2770 }, | 1698 | { 0x06, 0x4064 }, |
1656 | { 0x08, 0x04d0 }, | 1699 | { 0x07, 0x2863 }, |
1657 | { 0x0b, 0xad15 }, | 1700 | { 0x08, 0x059c }, |
1658 | { 0x0c, 0x5bf0 }, | 1701 | { 0x09, 0x26b4 }, |
1659 | { 0x1c, 0xf101 }, | 1702 | { 0x0a, 0x6a19 }, |
1703 | { 0x0b, 0xdcc8 }, | ||
1704 | { 0x10, 0xf06d }, | ||
1705 | { 0x14, 0x7f68 }, | ||
1706 | { 0x18, 0x7fd9 }, | ||
1707 | { 0x1c, 0xf0ff }, | ||
1708 | { 0x1d, 0x3d9c }, | ||
1660 | { 0x1f, 0x0003 }, | 1709 | { 0x1f, 0x0003 }, |
1661 | { 0x14, 0x94d7 }, | 1710 | { 0x12, 0xf49f }, |
1662 | { 0x12, 0xf4d6 }, | 1711 | { 0x13, 0x070b }, |
1663 | { 0x09, 0xca0f }, | 1712 | { 0x1a, 0x05ad }, |
1664 | { 0x1f, 0x0002 }, | 1713 | { 0x14, 0x94c0 } |
1665 | { 0x0b, 0x0b10 }, | 1714 | }; |
1666 | { 0x0c, 0xd1f7 }, | 1715 | static struct phy_reg phy_reg_init_1[] = { |
1667 | { 0x1f, 0x0002 }, | ||
1668 | { 0x06, 0x5461 }, | ||
1669 | { 0x1f, 0x0002 }, | 1716 | { 0x1f, 0x0002 }, |
1670 | { 0x05, 0x6662 }, | 1717 | { 0x06, 0x5561 }, |
1718 | { 0x1f, 0x0005 }, | ||
1719 | { 0x05, 0x8332 }, | ||
1720 | { 0x06, 0x5561 } | ||
1721 | }; | ||
1722 | static struct phy_reg phy_reg_init_2[] = { | ||
1723 | { 0x1f, 0x0005 }, | ||
1724 | { 0x05, 0xffc2 }, | ||
1725 | { 0x1f, 0x0005 }, | ||
1726 | { 0x05, 0x8000 }, | ||
1727 | { 0x06, 0xf8f9 }, | ||
1728 | { 0x06, 0xfaef }, | ||
1729 | { 0x06, 0x59ee }, | ||
1730 | { 0x06, 0xf8ea }, | ||
1731 | { 0x06, 0x00ee }, | ||
1732 | { 0x06, 0xf8eb }, | ||
1733 | { 0x06, 0x00e0 }, | ||
1734 | { 0x06, 0xf87c }, | ||
1735 | { 0x06, 0xe1f8 }, | ||
1736 | { 0x06, 0x7d59 }, | ||
1737 | { 0x06, 0x0fef }, | ||
1738 | { 0x06, 0x0139 }, | ||
1739 | { 0x06, 0x029e }, | ||
1740 | { 0x06, 0x06ef }, | ||
1741 | { 0x06, 0x1039 }, | ||
1742 | { 0x06, 0x089f }, | ||
1743 | { 0x06, 0x2aee }, | ||
1744 | { 0x06, 0xf8ea }, | ||
1745 | { 0x06, 0x00ee }, | ||
1746 | { 0x06, 0xf8eb }, | ||
1747 | { 0x06, 0x01e0 }, | ||
1748 | { 0x06, 0xf87c }, | ||
1749 | { 0x06, 0xe1f8 }, | ||
1750 | { 0x06, 0x7d58 }, | ||
1751 | { 0x06, 0x409e }, | ||
1752 | { 0x06, 0x0f39 }, | ||
1753 | { 0x06, 0x46aa }, | ||
1754 | { 0x06, 0x0bbf }, | ||
1755 | { 0x06, 0x8290 }, | ||
1756 | { 0x06, 0xd682 }, | ||
1757 | { 0x06, 0x9802 }, | ||
1758 | { 0x06, 0x014f }, | ||
1759 | { 0x06, 0xae09 }, | ||
1760 | { 0x06, 0xbf82 }, | ||
1761 | { 0x06, 0x98d6 }, | ||
1762 | { 0x06, 0x82a0 }, | ||
1763 | { 0x06, 0x0201 }, | ||
1764 | { 0x06, 0x4fef }, | ||
1765 | { 0x06, 0x95fe }, | ||
1766 | { 0x06, 0xfdfc }, | ||
1767 | { 0x06, 0x05f8 }, | ||
1768 | { 0x06, 0xf9fa }, | ||
1769 | { 0x06, 0xeef8 }, | ||
1770 | { 0x06, 0xea00 }, | ||
1771 | { 0x06, 0xeef8 }, | ||
1772 | { 0x06, 0xeb00 }, | ||
1773 | { 0x06, 0xe2f8 }, | ||
1774 | { 0x06, 0x7ce3 }, | ||
1775 | { 0x06, 0xf87d }, | ||
1776 | { 0x06, 0xa511 }, | ||
1777 | { 0x06, 0x1112 }, | ||
1778 | { 0x06, 0xd240 }, | ||
1779 | { 0x06, 0xd644 }, | ||
1780 | { 0x06, 0x4402 }, | ||
1781 | { 0x06, 0x8217 }, | ||
1782 | { 0x06, 0xd2a0 }, | ||
1783 | { 0x06, 0xd6aa }, | ||
1784 | { 0x06, 0xaa02 }, | ||
1785 | { 0x06, 0x8217 }, | ||
1786 | { 0x06, 0xae0f }, | ||
1787 | { 0x06, 0xa544 }, | ||
1788 | { 0x06, 0x4402 }, | ||
1789 | { 0x06, 0xae4d }, | ||
1790 | { 0x06, 0xa5aa }, | ||
1791 | { 0x06, 0xaa02 }, | ||
1792 | { 0x06, 0xae47 }, | ||
1793 | { 0x06, 0xaf82 }, | ||
1794 | { 0x06, 0x13ee }, | ||
1795 | { 0x06, 0x834e }, | ||
1796 | { 0x06, 0x00ee }, | ||
1797 | { 0x06, 0x834d }, | ||
1798 | { 0x06, 0x0fee }, | ||
1799 | { 0x06, 0x834c }, | ||
1800 | { 0x06, 0x0fee }, | ||
1801 | { 0x06, 0x834f }, | ||
1802 | { 0x06, 0x00ee }, | ||
1803 | { 0x06, 0x8351 }, | ||
1804 | { 0x06, 0x00ee }, | ||
1805 | { 0x06, 0x834a }, | ||
1806 | { 0x06, 0xffee }, | ||
1807 | { 0x06, 0x834b }, | ||
1808 | { 0x06, 0xffe0 }, | ||
1809 | { 0x06, 0x8330 }, | ||
1810 | { 0x06, 0xe183 }, | ||
1811 | { 0x06, 0x3158 }, | ||
1812 | { 0x06, 0xfee4 }, | ||
1813 | { 0x06, 0xf88a }, | ||
1814 | { 0x06, 0xe5f8 }, | ||
1815 | { 0x06, 0x8be0 }, | ||
1816 | { 0x06, 0x8332 }, | ||
1817 | { 0x06, 0xe183 }, | ||
1818 | { 0x06, 0x3359 }, | ||
1819 | { 0x06, 0x0fe2 }, | ||
1820 | { 0x06, 0x834d }, | ||
1821 | { 0x06, 0x0c24 }, | ||
1822 | { 0x06, 0x5af0 }, | ||
1823 | { 0x06, 0x1e12 }, | ||
1824 | { 0x06, 0xe4f8 }, | ||
1825 | { 0x06, 0x8ce5 }, | ||
1826 | { 0x06, 0xf88d }, | ||
1827 | { 0x06, 0xaf82 }, | ||
1828 | { 0x06, 0x13e0 }, | ||
1829 | { 0x06, 0x834f }, | ||
1830 | { 0x06, 0x10e4 }, | ||
1831 | { 0x06, 0x834f }, | ||
1832 | { 0x06, 0xe083 }, | ||
1833 | { 0x06, 0x4e78 }, | ||
1834 | { 0x06, 0x009f }, | ||
1835 | { 0x06, 0x0ae0 }, | ||
1836 | { 0x06, 0x834f }, | ||
1837 | { 0x06, 0xa010 }, | ||
1838 | { 0x06, 0xa5ee }, | ||
1839 | { 0x06, 0x834e }, | ||
1840 | { 0x06, 0x01e0 }, | ||
1841 | { 0x06, 0x834e }, | ||
1842 | { 0x06, 0x7805 }, | ||
1843 | { 0x06, 0x9e9a }, | ||
1844 | { 0x06, 0xe083 }, | ||
1845 | { 0x06, 0x4e78 }, | ||
1846 | { 0x06, 0x049e }, | ||
1847 | { 0x06, 0x10e0 }, | ||
1848 | { 0x06, 0x834e }, | ||
1849 | { 0x06, 0x7803 }, | ||
1850 | { 0x06, 0x9e0f }, | ||
1851 | { 0x06, 0xe083 }, | ||
1852 | { 0x06, 0x4e78 }, | ||
1853 | { 0x06, 0x019e }, | ||
1854 | { 0x06, 0x05ae }, | ||
1855 | { 0x06, 0x0caf }, | ||
1856 | { 0x06, 0x81f8 }, | ||
1857 | { 0x06, 0xaf81 }, | ||
1858 | { 0x06, 0xa3af }, | ||
1859 | { 0x06, 0x81dc }, | ||
1860 | { 0x06, 0xaf82 }, | ||
1861 | { 0x06, 0x13ee }, | ||
1862 | { 0x06, 0x8348 }, | ||
1863 | { 0x06, 0x00ee }, | ||
1864 | { 0x06, 0x8349 }, | ||
1865 | { 0x06, 0x00e0 }, | ||
1866 | { 0x06, 0x8351 }, | ||
1867 | { 0x06, 0x10e4 }, | ||
1868 | { 0x06, 0x8351 }, | ||
1869 | { 0x06, 0x5801 }, | ||
1870 | { 0x06, 0x9fea }, | ||
1871 | { 0x06, 0xd000 }, | ||
1872 | { 0x06, 0xd180 }, | ||
1873 | { 0x06, 0x1f66 }, | ||
1874 | { 0x06, 0xe2f8 }, | ||
1875 | { 0x06, 0xeae3 }, | ||
1876 | { 0x06, 0xf8eb }, | ||
1877 | { 0x06, 0x5af8 }, | ||
1878 | { 0x06, 0x1e20 }, | ||
1879 | { 0x06, 0xe6f8 }, | ||
1880 | { 0x06, 0xeae5 }, | ||
1881 | { 0x06, 0xf8eb }, | ||
1882 | { 0x06, 0xd302 }, | ||
1883 | { 0x06, 0xb3fe }, | ||
1884 | { 0x06, 0xe2f8 }, | ||
1885 | { 0x06, 0x7cef }, | ||
1886 | { 0x06, 0x325b }, | ||
1887 | { 0x06, 0x80e3 }, | ||
1888 | { 0x06, 0xf87d }, | ||
1889 | { 0x06, 0x9e03 }, | ||
1890 | { 0x06, 0x7dff }, | ||
1891 | { 0x06, 0xff0d }, | ||
1892 | { 0x06, 0x581c }, | ||
1893 | { 0x06, 0x551a }, | ||
1894 | { 0x06, 0x6511 }, | ||
1895 | { 0x06, 0xa190 }, | ||
1896 | { 0x06, 0xd3e2 }, | ||
1897 | { 0x06, 0x8348 }, | ||
1898 | { 0x06, 0xe383 }, | ||
1899 | { 0x06, 0x491b }, | ||
1900 | { 0x06, 0x56ab }, | ||
1901 | { 0x06, 0x08ef }, | ||
1902 | { 0x06, 0x56e6 }, | ||
1903 | { 0x06, 0x8348 }, | ||
1904 | { 0x06, 0xe783 }, | ||
1905 | { 0x06, 0x4910 }, | ||
1906 | { 0x06, 0xd180 }, | ||
1907 | { 0x06, 0x1f66 }, | ||
1908 | { 0x06, 0xa004 }, | ||
1909 | { 0x06, 0xb9e2 }, | ||
1910 | { 0x06, 0x8348 }, | ||
1911 | { 0x06, 0xe383 }, | ||
1912 | { 0x06, 0x49ef }, | ||
1913 | { 0x06, 0x65e2 }, | ||
1914 | { 0x06, 0x834a }, | ||
1915 | { 0x06, 0xe383 }, | ||
1916 | { 0x06, 0x4b1b }, | ||
1917 | { 0x06, 0x56aa }, | ||
1918 | { 0x06, 0x0eef }, | ||
1919 | { 0x06, 0x56e6 }, | ||
1920 | { 0x06, 0x834a }, | ||
1921 | { 0x06, 0xe783 }, | ||
1922 | { 0x06, 0x4be2 }, | ||
1923 | { 0x06, 0x834d }, | ||
1924 | { 0x06, 0xe683 }, | ||
1925 | { 0x06, 0x4ce0 }, | ||
1926 | { 0x06, 0x834d }, | ||
1927 | { 0x06, 0xa000 }, | ||
1928 | { 0x06, 0x0caf }, | ||
1929 | { 0x06, 0x81dc }, | ||
1930 | { 0x06, 0xe083 }, | ||
1931 | { 0x06, 0x4d10 }, | ||
1932 | { 0x06, 0xe483 }, | ||
1933 | { 0x06, 0x4dae }, | ||
1934 | { 0x06, 0x0480 }, | ||
1935 | { 0x06, 0xe483 }, | ||
1936 | { 0x06, 0x4de0 }, | ||
1937 | { 0x06, 0x834e }, | ||
1938 | { 0x06, 0x7803 }, | ||
1939 | { 0x06, 0x9e0b }, | ||
1940 | { 0x06, 0xe083 }, | ||
1941 | { 0x06, 0x4e78 }, | ||
1942 | { 0x06, 0x049e }, | ||
1943 | { 0x06, 0x04ee }, | ||
1944 | { 0x06, 0x834e }, | ||
1945 | { 0x06, 0x02e0 }, | ||
1946 | { 0x06, 0x8332 }, | ||
1947 | { 0x06, 0xe183 }, | ||
1948 | { 0x06, 0x3359 }, | ||
1949 | { 0x06, 0x0fe2 }, | ||
1950 | { 0x06, 0x834d }, | ||
1951 | { 0x06, 0x0c24 }, | ||
1952 | { 0x06, 0x5af0 }, | ||
1953 | { 0x06, 0x1e12 }, | ||
1954 | { 0x06, 0xe4f8 }, | ||
1955 | { 0x06, 0x8ce5 }, | ||
1956 | { 0x06, 0xf88d }, | ||
1957 | { 0x06, 0xe083 }, | ||
1958 | { 0x06, 0x30e1 }, | ||
1959 | { 0x06, 0x8331 }, | ||
1960 | { 0x06, 0x6801 }, | ||
1961 | { 0x06, 0xe4f8 }, | ||
1962 | { 0x06, 0x8ae5 }, | ||
1963 | { 0x06, 0xf88b }, | ||
1964 | { 0x06, 0xae37 }, | ||
1965 | { 0x06, 0xee83 }, | ||
1966 | { 0x06, 0x4e03 }, | ||
1967 | { 0x06, 0xe083 }, | ||
1968 | { 0x06, 0x4ce1 }, | ||
1969 | { 0x06, 0x834d }, | ||
1970 | { 0x06, 0x1b01 }, | ||
1971 | { 0x06, 0x9e04 }, | ||
1972 | { 0x06, 0xaaa1 }, | ||
1973 | { 0x06, 0xaea8 }, | ||
1974 | { 0x06, 0xee83 }, | ||
1975 | { 0x06, 0x4e04 }, | ||
1976 | { 0x06, 0xee83 }, | ||
1977 | { 0x06, 0x4f00 }, | ||
1978 | { 0x06, 0xaeab }, | ||
1979 | { 0x06, 0xe083 }, | ||
1980 | { 0x06, 0x4f78 }, | ||
1981 | { 0x06, 0x039f }, | ||
1982 | { 0x06, 0x14ee }, | ||
1983 | { 0x06, 0x834e }, | ||
1984 | { 0x06, 0x05d2 }, | ||
1985 | { 0x06, 0x40d6 }, | ||
1986 | { 0x06, 0x5554 }, | ||
1987 | { 0x06, 0x0282 }, | ||
1988 | { 0x06, 0x17d2 }, | ||
1989 | { 0x06, 0xa0d6 }, | ||
1990 | { 0x06, 0xba00 }, | ||
1991 | { 0x06, 0x0282 }, | ||
1992 | { 0x06, 0x17fe }, | ||
1993 | { 0x06, 0xfdfc }, | ||
1994 | { 0x06, 0x05f8 }, | ||
1995 | { 0x06, 0xe0f8 }, | ||
1996 | { 0x06, 0x60e1 }, | ||
1997 | { 0x06, 0xf861 }, | ||
1998 | { 0x06, 0x6802 }, | ||
1999 | { 0x06, 0xe4f8 }, | ||
2000 | { 0x06, 0x60e5 }, | ||
2001 | { 0x06, 0xf861 }, | ||
2002 | { 0x06, 0xe0f8 }, | ||
2003 | { 0x06, 0x48e1 }, | ||
2004 | { 0x06, 0xf849 }, | ||
2005 | { 0x06, 0x580f }, | ||
2006 | { 0x06, 0x1e02 }, | ||
2007 | { 0x06, 0xe4f8 }, | ||
2008 | { 0x06, 0x48e5 }, | ||
2009 | { 0x06, 0xf849 }, | ||
2010 | { 0x06, 0xd000 }, | ||
2011 | { 0x06, 0x0282 }, | ||
2012 | { 0x06, 0x5bbf }, | ||
2013 | { 0x06, 0x8350 }, | ||
2014 | { 0x06, 0xef46 }, | ||
2015 | { 0x06, 0xdc19 }, | ||
2016 | { 0x06, 0xddd0 }, | ||
2017 | { 0x06, 0x0102 }, | ||
2018 | { 0x06, 0x825b }, | ||
2019 | { 0x06, 0x0282 }, | ||
2020 | { 0x06, 0x77e0 }, | ||
2021 | { 0x06, 0xf860 }, | ||
2022 | { 0x06, 0xe1f8 }, | ||
2023 | { 0x06, 0x6158 }, | ||
2024 | { 0x06, 0xfde4 }, | ||
2025 | { 0x06, 0xf860 }, | ||
2026 | { 0x06, 0xe5f8 }, | ||
2027 | { 0x06, 0x61fc }, | ||
2028 | { 0x06, 0x04f9 }, | ||
2029 | { 0x06, 0xfafb }, | ||
2030 | { 0x06, 0xc6bf }, | ||
2031 | { 0x06, 0xf840 }, | ||
2032 | { 0x06, 0xbe83 }, | ||
2033 | { 0x06, 0x50a0 }, | ||
2034 | { 0x06, 0x0101 }, | ||
2035 | { 0x06, 0x071b }, | ||
2036 | { 0x06, 0x89cf }, | ||
2037 | { 0x06, 0xd208 }, | ||
2038 | { 0x06, 0xebdb }, | ||
2039 | { 0x06, 0x19b2 }, | ||
2040 | { 0x06, 0xfbff }, | ||
2041 | { 0x06, 0xfefd }, | ||
2042 | { 0x06, 0x04f8 }, | ||
2043 | { 0x06, 0xe0f8 }, | ||
2044 | { 0x06, 0x48e1 }, | ||
2045 | { 0x06, 0xf849 }, | ||
2046 | { 0x06, 0x6808 }, | ||
2047 | { 0x06, 0xe4f8 }, | ||
2048 | { 0x06, 0x48e5 }, | ||
2049 | { 0x06, 0xf849 }, | ||
2050 | { 0x06, 0x58f7 }, | ||
2051 | { 0x06, 0xe4f8 }, | ||
2052 | { 0x06, 0x48e5 }, | ||
2053 | { 0x06, 0xf849 }, | ||
2054 | { 0x06, 0xfc04 }, | ||
2055 | { 0x06, 0x4d20 }, | ||
2056 | { 0x06, 0x0002 }, | ||
2057 | { 0x06, 0x4e22 }, | ||
2058 | { 0x06, 0x0002 }, | ||
2059 | { 0x06, 0x4ddf }, | ||
2060 | { 0x06, 0xff01 }, | ||
2061 | { 0x06, 0x4edd }, | ||
2062 | { 0x06, 0xff01 }, | ||
2063 | { 0x05, 0x83d4 }, | ||
2064 | { 0x06, 0x8000 }, | ||
2065 | { 0x05, 0x83d8 }, | ||
2066 | { 0x06, 0x8051 }, | ||
2067 | { 0x02, 0x6010 }, | ||
2068 | { 0x03, 0xdc00 }, | ||
2069 | { 0x05, 0xfff6 }, | ||
2070 | { 0x06, 0x00fc }, | ||
1671 | { 0x1f, 0x0000 }, | 2071 | { 0x1f, 0x0000 }, |
1672 | { 0x14, 0x0060 }, | 2072 | |
1673 | { 0x1f, 0x0000 }, | 2073 | { 0x1f, 0x0000 }, |
1674 | { 0x0d, 0xf8a0 }, | 2074 | { 0x0d, 0xf880 }, |
2075 | { 0x1f, 0x0000 } | ||
2076 | }; | ||
2077 | |||
2078 | rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); | ||
2079 | |||
2080 | mdio_write(ioaddr, 0x1f, 0x0002); | ||
2081 | mdio_plus_minus(ioaddr, 0x0b, 0x0010, 0x00ef); | ||
2082 | mdio_plus_minus(ioaddr, 0x0c, 0xa200, 0x5d00); | ||
2083 | |||
2084 | rtl_phy_write(ioaddr, phy_reg_init_1, ARRAY_SIZE(phy_reg_init_1)); | ||
2085 | |||
2086 | if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { | ||
2087 | struct phy_reg phy_reg_init[] = { | ||
2088 | { 0x1f, 0x0002 }, | ||
2089 | { 0x05, 0x669a }, | ||
2090 | { 0x1f, 0x0005 }, | ||
2091 | { 0x05, 0x8330 }, | ||
2092 | { 0x06, 0x669a }, | ||
2093 | { 0x1f, 0x0002 } | ||
2094 | }; | ||
2095 | int val; | ||
2096 | |||
2097 | rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
2098 | |||
2099 | val = mdio_read(ioaddr, 0x0d); | ||
2100 | |||
2101 | if ((val & 0x00ff) != 0x006c) { | ||
2102 | u32 set[] = { | ||
2103 | 0x0065, 0x0066, 0x0067, 0x0068, | ||
2104 | 0x0069, 0x006a, 0x006b, 0x006c | ||
2105 | }; | ||
2106 | int i; | ||
2107 | |||
2108 | mdio_write(ioaddr, 0x1f, 0x0002); | ||
2109 | |||
2110 | val &= 0xff00; | ||
2111 | for (i = 0; i < ARRAY_SIZE(set); i++) | ||
2112 | mdio_write(ioaddr, 0x0d, val | set[i]); | ||
2113 | } | ||
2114 | } else { | ||
2115 | struct phy_reg phy_reg_init[] = { | ||
2116 | { 0x1f, 0x0002 }, | ||
2117 | { 0x05, 0x6662 }, | ||
2118 | { 0x1f, 0x0005 }, | ||
2119 | { 0x05, 0x8330 }, | ||
2120 | { 0x06, 0x6662 } | ||
2121 | }; | ||
2122 | |||
2123 | rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
2124 | } | ||
2125 | |||
2126 | mdio_write(ioaddr, 0x1f, 0x0002); | ||
2127 | mdio_patch(ioaddr, 0x0d, 0x0300); | ||
2128 | mdio_patch(ioaddr, 0x0f, 0x0010); | ||
2129 | |||
2130 | mdio_write(ioaddr, 0x1f, 0x0002); | ||
2131 | mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600); | ||
2132 | mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000); | ||
2133 | |||
2134 | rtl_phy_write(ioaddr, phy_reg_init_2, ARRAY_SIZE(phy_reg_init_2)); | ||
2135 | } | ||
2136 | |||
2137 | static void rtl8168d_2_hw_phy_config(void __iomem *ioaddr) | ||
2138 | { | ||
2139 | static struct phy_reg phy_reg_init_0[] = { | ||
2140 | { 0x1f, 0x0001 }, | ||
2141 | { 0x06, 0x4064 }, | ||
2142 | { 0x07, 0x2863 }, | ||
2143 | { 0x08, 0x059c }, | ||
2144 | { 0x09, 0x26b4 }, | ||
2145 | { 0x0a, 0x6a19 }, | ||
2146 | { 0x0b, 0xdcc8 }, | ||
2147 | { 0x10, 0xf06d }, | ||
2148 | { 0x14, 0x7f68 }, | ||
2149 | { 0x18, 0x7fd9 }, | ||
2150 | { 0x1c, 0xf0ff }, | ||
2151 | { 0x1d, 0x3d9c }, | ||
2152 | { 0x1f, 0x0003 }, | ||
2153 | { 0x12, 0xf49f }, | ||
2154 | { 0x13, 0x070b }, | ||
2155 | { 0x1a, 0x05ad }, | ||
2156 | { 0x14, 0x94c0 }, | ||
2157 | |||
2158 | { 0x1f, 0x0002 }, | ||
2159 | { 0x06, 0x5561 }, | ||
1675 | { 0x1f, 0x0005 }, | 2160 | { 0x1f, 0x0005 }, |
1676 | { 0x05, 0xffc2 } | 2161 | { 0x05, 0x8332 }, |
2162 | { 0x06, 0x5561 } | ||
2163 | }; | ||
2164 | static struct phy_reg phy_reg_init_1[] = { | ||
2165 | { 0x1f, 0x0005 }, | ||
2166 | { 0x05, 0xffc2 }, | ||
2167 | { 0x1f, 0x0005 }, | ||
2168 | { 0x05, 0x8000 }, | ||
2169 | { 0x06, 0xf8f9 }, | ||
2170 | { 0x06, 0xfaee }, | ||
2171 | { 0x06, 0xf8ea }, | ||
2172 | { 0x06, 0x00ee }, | ||
2173 | { 0x06, 0xf8eb }, | ||
2174 | { 0x06, 0x00e2 }, | ||
2175 | { 0x06, 0xf87c }, | ||
2176 | { 0x06, 0xe3f8 }, | ||
2177 | { 0x06, 0x7da5 }, | ||
2178 | { 0x06, 0x1111 }, | ||
2179 | { 0x06, 0x12d2 }, | ||
2180 | { 0x06, 0x40d6 }, | ||
2181 | { 0x06, 0x4444 }, | ||
2182 | { 0x06, 0x0281 }, | ||
2183 | { 0x06, 0xc6d2 }, | ||
2184 | { 0x06, 0xa0d6 }, | ||
2185 | { 0x06, 0xaaaa }, | ||
2186 | { 0x06, 0x0281 }, | ||
2187 | { 0x06, 0xc6ae }, | ||
2188 | { 0x06, 0x0fa5 }, | ||
2189 | { 0x06, 0x4444 }, | ||
2190 | { 0x06, 0x02ae }, | ||
2191 | { 0x06, 0x4da5 }, | ||
2192 | { 0x06, 0xaaaa }, | ||
2193 | { 0x06, 0x02ae }, | ||
2194 | { 0x06, 0x47af }, | ||
2195 | { 0x06, 0x81c2 }, | ||
2196 | { 0x06, 0xee83 }, | ||
2197 | { 0x06, 0x4e00 }, | ||
2198 | { 0x06, 0xee83 }, | ||
2199 | { 0x06, 0x4d0f }, | ||
2200 | { 0x06, 0xee83 }, | ||
2201 | { 0x06, 0x4c0f }, | ||
2202 | { 0x06, 0xee83 }, | ||
2203 | { 0x06, 0x4f00 }, | ||
2204 | { 0x06, 0xee83 }, | ||
2205 | { 0x06, 0x5100 }, | ||
2206 | { 0x06, 0xee83 }, | ||
2207 | { 0x06, 0x4aff }, | ||
2208 | { 0x06, 0xee83 }, | ||
2209 | { 0x06, 0x4bff }, | ||
2210 | { 0x06, 0xe083 }, | ||
2211 | { 0x06, 0x30e1 }, | ||
2212 | { 0x06, 0x8331 }, | ||
2213 | { 0x06, 0x58fe }, | ||
2214 | { 0x06, 0xe4f8 }, | ||
2215 | { 0x06, 0x8ae5 }, | ||
2216 | { 0x06, 0xf88b }, | ||
2217 | { 0x06, 0xe083 }, | ||
2218 | { 0x06, 0x32e1 }, | ||
2219 | { 0x06, 0x8333 }, | ||
2220 | { 0x06, 0x590f }, | ||
2221 | { 0x06, 0xe283 }, | ||
2222 | { 0x06, 0x4d0c }, | ||
2223 | { 0x06, 0x245a }, | ||
2224 | { 0x06, 0xf01e }, | ||
2225 | { 0x06, 0x12e4 }, | ||
2226 | { 0x06, 0xf88c }, | ||
2227 | { 0x06, 0xe5f8 }, | ||
2228 | { 0x06, 0x8daf }, | ||
2229 | { 0x06, 0x81c2 }, | ||
2230 | { 0x06, 0xe083 }, | ||
2231 | { 0x06, 0x4f10 }, | ||
2232 | { 0x06, 0xe483 }, | ||
2233 | { 0x06, 0x4fe0 }, | ||
2234 | { 0x06, 0x834e }, | ||
2235 | { 0x06, 0x7800 }, | ||
2236 | { 0x06, 0x9f0a }, | ||
2237 | { 0x06, 0xe083 }, | ||
2238 | { 0x06, 0x4fa0 }, | ||
2239 | { 0x06, 0x10a5 }, | ||
2240 | { 0x06, 0xee83 }, | ||
2241 | { 0x06, 0x4e01 }, | ||
2242 | { 0x06, 0xe083 }, | ||
2243 | { 0x06, 0x4e78 }, | ||
2244 | { 0x06, 0x059e }, | ||
2245 | { 0x06, 0x9ae0 }, | ||
2246 | { 0x06, 0x834e }, | ||
2247 | { 0x06, 0x7804 }, | ||
2248 | { 0x06, 0x9e10 }, | ||
2249 | { 0x06, 0xe083 }, | ||
2250 | { 0x06, 0x4e78 }, | ||
2251 | { 0x06, 0x039e }, | ||
2252 | { 0x06, 0x0fe0 }, | ||
2253 | { 0x06, 0x834e }, | ||
2254 | { 0x06, 0x7801 }, | ||
2255 | { 0x06, 0x9e05 }, | ||
2256 | { 0x06, 0xae0c }, | ||
2257 | { 0x06, 0xaf81 }, | ||
2258 | { 0x06, 0xa7af }, | ||
2259 | { 0x06, 0x8152 }, | ||
2260 | { 0x06, 0xaf81 }, | ||
2261 | { 0x06, 0x8baf }, | ||
2262 | { 0x06, 0x81c2 }, | ||
2263 | { 0x06, 0xee83 }, | ||
2264 | { 0x06, 0x4800 }, | ||
2265 | { 0x06, 0xee83 }, | ||
2266 | { 0x06, 0x4900 }, | ||
2267 | { 0x06, 0xe083 }, | ||
2268 | { 0x06, 0x5110 }, | ||
2269 | { 0x06, 0xe483 }, | ||
2270 | { 0x06, 0x5158 }, | ||
2271 | { 0x06, 0x019f }, | ||
2272 | { 0x06, 0xead0 }, | ||
2273 | { 0x06, 0x00d1 }, | ||
2274 | { 0x06, 0x801f }, | ||
2275 | { 0x06, 0x66e2 }, | ||
2276 | { 0x06, 0xf8ea }, | ||
2277 | { 0x06, 0xe3f8 }, | ||
2278 | { 0x06, 0xeb5a }, | ||
2279 | { 0x06, 0xf81e }, | ||
2280 | { 0x06, 0x20e6 }, | ||
2281 | { 0x06, 0xf8ea }, | ||
2282 | { 0x06, 0xe5f8 }, | ||
2283 | { 0x06, 0xebd3 }, | ||
2284 | { 0x06, 0x02b3 }, | ||
2285 | { 0x06, 0xfee2 }, | ||
2286 | { 0x06, 0xf87c }, | ||
2287 | { 0x06, 0xef32 }, | ||
2288 | { 0x06, 0x5b80 }, | ||
2289 | { 0x06, 0xe3f8 }, | ||
2290 | { 0x06, 0x7d9e }, | ||
2291 | { 0x06, 0x037d }, | ||
2292 | { 0x06, 0xffff }, | ||
2293 | { 0x06, 0x0d58 }, | ||
2294 | { 0x06, 0x1c55 }, | ||
2295 | { 0x06, 0x1a65 }, | ||
2296 | { 0x06, 0x11a1 }, | ||
2297 | { 0x06, 0x90d3 }, | ||
2298 | { 0x06, 0xe283 }, | ||
2299 | { 0x06, 0x48e3 }, | ||
2300 | { 0x06, 0x8349 }, | ||
2301 | { 0x06, 0x1b56 }, | ||
2302 | { 0x06, 0xab08 }, | ||
2303 | { 0x06, 0xef56 }, | ||
2304 | { 0x06, 0xe683 }, | ||
2305 | { 0x06, 0x48e7 }, | ||
2306 | { 0x06, 0x8349 }, | ||
2307 | { 0x06, 0x10d1 }, | ||
2308 | { 0x06, 0x801f }, | ||
2309 | { 0x06, 0x66a0 }, | ||
2310 | { 0x06, 0x04b9 }, | ||
2311 | { 0x06, 0xe283 }, | ||
2312 | { 0x06, 0x48e3 }, | ||
2313 | { 0x06, 0x8349 }, | ||
2314 | { 0x06, 0xef65 }, | ||
2315 | { 0x06, 0xe283 }, | ||
2316 | { 0x06, 0x4ae3 }, | ||
2317 | { 0x06, 0x834b }, | ||
2318 | { 0x06, 0x1b56 }, | ||
2319 | { 0x06, 0xaa0e }, | ||
2320 | { 0x06, 0xef56 }, | ||
2321 | { 0x06, 0xe683 }, | ||
2322 | { 0x06, 0x4ae7 }, | ||
2323 | { 0x06, 0x834b }, | ||
2324 | { 0x06, 0xe283 }, | ||
2325 | { 0x06, 0x4de6 }, | ||
2326 | { 0x06, 0x834c }, | ||
2327 | { 0x06, 0xe083 }, | ||
2328 | { 0x06, 0x4da0 }, | ||
2329 | { 0x06, 0x000c }, | ||
2330 | { 0x06, 0xaf81 }, | ||
2331 | { 0x06, 0x8be0 }, | ||
2332 | { 0x06, 0x834d }, | ||
2333 | { 0x06, 0x10e4 }, | ||
2334 | { 0x06, 0x834d }, | ||
2335 | { 0x06, 0xae04 }, | ||
2336 | { 0x06, 0x80e4 }, | ||
2337 | { 0x06, 0x834d }, | ||
2338 | { 0x06, 0xe083 }, | ||
2339 | { 0x06, 0x4e78 }, | ||
2340 | { 0x06, 0x039e }, | ||
2341 | { 0x06, 0x0be0 }, | ||
2342 | { 0x06, 0x834e }, | ||
2343 | { 0x06, 0x7804 }, | ||
2344 | { 0x06, 0x9e04 }, | ||
2345 | { 0x06, 0xee83 }, | ||
2346 | { 0x06, 0x4e02 }, | ||
2347 | { 0x06, 0xe083 }, | ||
2348 | { 0x06, 0x32e1 }, | ||
2349 | { 0x06, 0x8333 }, | ||
2350 | { 0x06, 0x590f }, | ||
2351 | { 0x06, 0xe283 }, | ||
2352 | { 0x06, 0x4d0c }, | ||
2353 | { 0x06, 0x245a }, | ||
2354 | { 0x06, 0xf01e }, | ||
2355 | { 0x06, 0x12e4 }, | ||
2356 | { 0x06, 0xf88c }, | ||
2357 | { 0x06, 0xe5f8 }, | ||
2358 | { 0x06, 0x8de0 }, | ||
2359 | { 0x06, 0x8330 }, | ||
2360 | { 0x06, 0xe183 }, | ||
2361 | { 0x06, 0x3168 }, | ||
2362 | { 0x06, 0x01e4 }, | ||
2363 | { 0x06, 0xf88a }, | ||
2364 | { 0x06, 0xe5f8 }, | ||
2365 | { 0x06, 0x8bae }, | ||
2366 | { 0x06, 0x37ee }, | ||
2367 | { 0x06, 0x834e }, | ||
2368 | { 0x06, 0x03e0 }, | ||
2369 | { 0x06, 0x834c }, | ||
2370 | { 0x06, 0xe183 }, | ||
2371 | { 0x06, 0x4d1b }, | ||
2372 | { 0x06, 0x019e }, | ||
2373 | { 0x06, 0x04aa }, | ||
2374 | { 0x06, 0xa1ae }, | ||
2375 | { 0x06, 0xa8ee }, | ||
2376 | { 0x06, 0x834e }, | ||
2377 | { 0x06, 0x04ee }, | ||
2378 | { 0x06, 0x834f }, | ||
2379 | { 0x06, 0x00ae }, | ||
2380 | { 0x06, 0xabe0 }, | ||
2381 | { 0x06, 0x834f }, | ||
2382 | { 0x06, 0x7803 }, | ||
2383 | { 0x06, 0x9f14 }, | ||
2384 | { 0x06, 0xee83 }, | ||
2385 | { 0x06, 0x4e05 }, | ||
2386 | { 0x06, 0xd240 }, | ||
2387 | { 0x06, 0xd655 }, | ||
2388 | { 0x06, 0x5402 }, | ||
2389 | { 0x06, 0x81c6 }, | ||
2390 | { 0x06, 0xd2a0 }, | ||
2391 | { 0x06, 0xd6ba }, | ||
2392 | { 0x06, 0x0002 }, | ||
2393 | { 0x06, 0x81c6 }, | ||
2394 | { 0x06, 0xfefd }, | ||
2395 | { 0x06, 0xfc05 }, | ||
2396 | { 0x06, 0xf8e0 }, | ||
2397 | { 0x06, 0xf860 }, | ||
2398 | { 0x06, 0xe1f8 }, | ||
2399 | { 0x06, 0x6168 }, | ||
2400 | { 0x06, 0x02e4 }, | ||
2401 | { 0x06, 0xf860 }, | ||
2402 | { 0x06, 0xe5f8 }, | ||
2403 | { 0x06, 0x61e0 }, | ||
2404 | { 0x06, 0xf848 }, | ||
2405 | { 0x06, 0xe1f8 }, | ||
2406 | { 0x06, 0x4958 }, | ||
2407 | { 0x06, 0x0f1e }, | ||
2408 | { 0x06, 0x02e4 }, | ||
2409 | { 0x06, 0xf848 }, | ||
2410 | { 0x06, 0xe5f8 }, | ||
2411 | { 0x06, 0x49d0 }, | ||
2412 | { 0x06, 0x0002 }, | ||
2413 | { 0x06, 0x820a }, | ||
2414 | { 0x06, 0xbf83 }, | ||
2415 | { 0x06, 0x50ef }, | ||
2416 | { 0x06, 0x46dc }, | ||
2417 | { 0x06, 0x19dd }, | ||
2418 | { 0x06, 0xd001 }, | ||
2419 | { 0x06, 0x0282 }, | ||
2420 | { 0x06, 0x0a02 }, | ||
2421 | { 0x06, 0x8226 }, | ||
2422 | { 0x06, 0xe0f8 }, | ||
2423 | { 0x06, 0x60e1 }, | ||
2424 | { 0x06, 0xf861 }, | ||
2425 | { 0x06, 0x58fd }, | ||
2426 | { 0x06, 0xe4f8 }, | ||
2427 | { 0x06, 0x60e5 }, | ||
2428 | { 0x06, 0xf861 }, | ||
2429 | { 0x06, 0xfc04 }, | ||
2430 | { 0x06, 0xf9fa }, | ||
2431 | { 0x06, 0xfbc6 }, | ||
2432 | { 0x06, 0xbff8 }, | ||
2433 | { 0x06, 0x40be }, | ||
2434 | { 0x06, 0x8350 }, | ||
2435 | { 0x06, 0xa001 }, | ||
2436 | { 0x06, 0x0107 }, | ||
2437 | { 0x06, 0x1b89 }, | ||
2438 | { 0x06, 0xcfd2 }, | ||
2439 | { 0x06, 0x08eb }, | ||
2440 | { 0x06, 0xdb19 }, | ||
2441 | { 0x06, 0xb2fb }, | ||
2442 | { 0x06, 0xfffe }, | ||
2443 | { 0x06, 0xfd04 }, | ||
2444 | { 0x06, 0xf8e0 }, | ||
2445 | { 0x06, 0xf848 }, | ||
2446 | { 0x06, 0xe1f8 }, | ||
2447 | { 0x06, 0x4968 }, | ||
2448 | { 0x06, 0x08e4 }, | ||
2449 | { 0x06, 0xf848 }, | ||
2450 | { 0x06, 0xe5f8 }, | ||
2451 | { 0x06, 0x4958 }, | ||
2452 | { 0x06, 0xf7e4 }, | ||
2453 | { 0x06, 0xf848 }, | ||
2454 | { 0x06, 0xe5f8 }, | ||
2455 | { 0x06, 0x49fc }, | ||
2456 | { 0x06, 0x044d }, | ||
2457 | { 0x06, 0x2000 }, | ||
2458 | { 0x06, 0x024e }, | ||
2459 | { 0x06, 0x2200 }, | ||
2460 | { 0x06, 0x024d }, | ||
2461 | { 0x06, 0xdfff }, | ||
2462 | { 0x06, 0x014e }, | ||
2463 | { 0x06, 0xddff }, | ||
2464 | { 0x06, 0x0100 }, | ||
2465 | { 0x05, 0x83d8 }, | ||
2466 | { 0x06, 0x8000 }, | ||
2467 | { 0x03, 0xdc00 }, | ||
2468 | { 0x05, 0xfff6 }, | ||
2469 | { 0x06, 0x00fc }, | ||
2470 | { 0x1f, 0x0000 }, | ||
2471 | |||
2472 | { 0x1f, 0x0000 }, | ||
2473 | { 0x0d, 0xf880 }, | ||
2474 | { 0x1f, 0x0000 } | ||
1677 | }; | 2475 | }; |
1678 | 2476 | ||
1679 | rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); | 2477 | rtl_phy_write(ioaddr, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0)); |
1680 | 2478 | ||
1681 | if (mdio_read(ioaddr, 0x06) == 0xc400) { | 2479 | if (rtl8168d_efuse_read(ioaddr, 0x01) == 0xb1) { |
1682 | struct phy_reg phy_reg_init_1[] = { | 2480 | struct phy_reg phy_reg_init[] = { |
2481 | { 0x1f, 0x0002 }, | ||
2482 | { 0x05, 0x669a }, | ||
1683 | { 0x1f, 0x0005 }, | 2483 | { 0x1f, 0x0005 }, |
1684 | { 0x01, 0x0300 }, | 2484 | { 0x05, 0x8330 }, |
1685 | { 0x1f, 0x0000 }, | 2485 | { 0x06, 0x669a }, |
1686 | { 0x11, 0x401c }, | 2486 | |
1687 | { 0x16, 0x4100 }, | 2487 | { 0x1f, 0x0002 } |
2488 | }; | ||
2489 | int val; | ||
2490 | |||
2491 | rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
2492 | |||
2493 | val = mdio_read(ioaddr, 0x0d); | ||
2494 | if ((val & 0x00ff) != 0x006c) { | ||
2495 | u32 set[] = { | ||
2496 | 0x0065, 0x0066, 0x0067, 0x0068, | ||
2497 | 0x0069, 0x006a, 0x006b, 0x006c | ||
2498 | }; | ||
2499 | int i; | ||
2500 | |||
2501 | mdio_write(ioaddr, 0x1f, 0x0002); | ||
2502 | |||
2503 | val &= 0xff00; | ||
2504 | for (i = 0; i < ARRAY_SIZE(set); i++) | ||
2505 | mdio_write(ioaddr, 0x0d, val | set[i]); | ||
2506 | } | ||
2507 | } else { | ||
2508 | struct phy_reg phy_reg_init[] = { | ||
2509 | { 0x1f, 0x0002 }, | ||
2510 | { 0x05, 0x2642 }, | ||
1688 | { 0x1f, 0x0005 }, | 2511 | { 0x1f, 0x0005 }, |
1689 | { 0x07, 0x0010 }, | 2512 | { 0x05, 0x8330 }, |
1690 | { 0x05, 0x83dc }, | 2513 | { 0x06, 0x2642 } |
1691 | { 0x06, 0x087d }, | ||
1692 | { 0x05, 0x8300 }, | ||
1693 | { 0x06, 0x0101 }, | ||
1694 | { 0x06, 0x05f8 }, | ||
1695 | { 0x06, 0xf9fa }, | ||
1696 | { 0x06, 0xfbef }, | ||
1697 | { 0x06, 0x79e2 }, | ||
1698 | { 0x06, 0x835f }, | ||
1699 | { 0x06, 0xe0f8 }, | ||
1700 | { 0x06, 0x9ae1 }, | ||
1701 | { 0x06, 0xf89b }, | ||
1702 | { 0x06, 0xef31 }, | ||
1703 | { 0x06, 0x3b65 }, | ||
1704 | { 0x06, 0xaa07 }, | ||
1705 | { 0x06, 0x81e4 }, | ||
1706 | { 0x06, 0xf89a }, | ||
1707 | { 0x06, 0xe5f8 }, | ||
1708 | { 0x06, 0x9baf }, | ||
1709 | { 0x06, 0x06ae }, | ||
1710 | { 0x05, 0x83dc }, | ||
1711 | { 0x06, 0x8300 }, | ||
1712 | }; | 2514 | }; |
1713 | 2515 | ||
1714 | rtl_phy_write(ioaddr, phy_reg_init_1, | 2516 | rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); |
1715 | ARRAY_SIZE(phy_reg_init_1)); | ||
1716 | } | 2517 | } |
1717 | 2518 | ||
1718 | mdio_write(ioaddr, 0x1f, 0x0000); | 2519 | mdio_write(ioaddr, 0x1f, 0x0002); |
2520 | mdio_plus_minus(ioaddr, 0x02, 0x0100, 0x0600); | ||
2521 | mdio_plus_minus(ioaddr, 0x03, 0x0000, 0xe000); | ||
2522 | |||
2523 | mdio_write(ioaddr, 0x1f, 0x0001); | ||
2524 | mdio_write(ioaddr, 0x17, 0x0cc0); | ||
2525 | |||
2526 | mdio_write(ioaddr, 0x1f, 0x0002); | ||
2527 | mdio_patch(ioaddr, 0x0f, 0x0017); | ||
2528 | |||
2529 | rtl_phy_write(ioaddr, phy_reg_init_1, ARRAY_SIZE(phy_reg_init_1)); | ||
2530 | } | ||
2531 | |||
2532 | static void rtl8168d_3_hw_phy_config(void __iomem *ioaddr) | ||
2533 | { | ||
2534 | struct phy_reg phy_reg_init[] = { | ||
2535 | { 0x1f, 0x0002 }, | ||
2536 | { 0x10, 0x0008 }, | ||
2537 | { 0x0d, 0x006c }, | ||
2538 | |||
2539 | { 0x1f, 0x0000 }, | ||
2540 | { 0x0d, 0xf880 }, | ||
2541 | |||
2542 | { 0x1f, 0x0001 }, | ||
2543 | { 0x17, 0x0cc0 }, | ||
2544 | |||
2545 | { 0x1f, 0x0001 }, | ||
2546 | { 0x0b, 0xa4d8 }, | ||
2547 | { 0x09, 0x281c }, | ||
2548 | { 0x07, 0x2883 }, | ||
2549 | { 0x0a, 0x6b35 }, | ||
2550 | { 0x1d, 0x3da4 }, | ||
2551 | { 0x1c, 0xeffd }, | ||
2552 | { 0x14, 0x7f52 }, | ||
2553 | { 0x18, 0x7fc6 }, | ||
2554 | { 0x08, 0x0601 }, | ||
2555 | { 0x06, 0x4063 }, | ||
2556 | { 0x10, 0xf074 }, | ||
2557 | { 0x1f, 0x0003 }, | ||
2558 | { 0x13, 0x0789 }, | ||
2559 | { 0x12, 0xf4bd }, | ||
2560 | { 0x1a, 0x04fd }, | ||
2561 | { 0x14, 0x84b0 }, | ||
2562 | { 0x1f, 0x0000 }, | ||
2563 | { 0x00, 0x9200 }, | ||
2564 | |||
2565 | { 0x1f, 0x0005 }, | ||
2566 | { 0x01, 0x0340 }, | ||
2567 | { 0x1f, 0x0001 }, | ||
2568 | { 0x04, 0x4000 }, | ||
2569 | { 0x03, 0x1d21 }, | ||
2570 | { 0x02, 0x0c32 }, | ||
2571 | { 0x01, 0x0200 }, | ||
2572 | { 0x00, 0x5554 }, | ||
2573 | { 0x04, 0x4800 }, | ||
2574 | { 0x04, 0x4000 }, | ||
2575 | { 0x04, 0xf000 }, | ||
2576 | { 0x03, 0xdf01 }, | ||
2577 | { 0x02, 0xdf20 }, | ||
2578 | { 0x01, 0x101a }, | ||
2579 | { 0x00, 0xa0ff }, | ||
2580 | { 0x04, 0xf800 }, | ||
2581 | { 0x04, 0xf000 }, | ||
2582 | { 0x1f, 0x0000 }, | ||
2583 | |||
2584 | { 0x1f, 0x0007 }, | ||
2585 | { 0x1e, 0x0023 }, | ||
2586 | { 0x16, 0x0000 }, | ||
2587 | { 0x1f, 0x0000 } | ||
2588 | }; | ||
2589 | |||
2590 | rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
1719 | } | 2591 | } |
1720 | 2592 | ||
1721 | static void rtl8102e_hw_phy_config(void __iomem *ioaddr) | 2593 | static void rtl8102e_hw_phy_config(void __iomem *ioaddr) |
@@ -1792,7 +2664,13 @@ static void rtl_hw_phy_config(struct net_device *dev) | |||
1792 | rtl8168cp_2_hw_phy_config(ioaddr); | 2664 | rtl8168cp_2_hw_phy_config(ioaddr); |
1793 | break; | 2665 | break; |
1794 | case RTL_GIGA_MAC_VER_25: | 2666 | case RTL_GIGA_MAC_VER_25: |
1795 | rtl8168d_hw_phy_config(ioaddr); | 2667 | rtl8168d_1_hw_phy_config(ioaddr); |
2668 | break; | ||
2669 | case RTL_GIGA_MAC_VER_26: | ||
2670 | rtl8168d_2_hw_phy_config(ioaddr); | ||
2671 | break; | ||
2672 | case RTL_GIGA_MAC_VER_27: | ||
2673 | rtl8168d_3_hw_phy_config(ioaddr); | ||
1796 | break; | 2674 | break; |
1797 | 2675 | ||
1798 | default: | 2676 | default: |
@@ -2322,6 +3200,14 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2322 | } | 3200 | } |
2323 | 3201 | ||
2324 | rtl8169_init_phy(dev, tp); | 3202 | rtl8169_init_phy(dev, tp); |
3203 | |||
3204 | /* | ||
3205 | * Pretend we are using VLANs; This bypasses a nasty bug where | ||
3206 | * Interrupts stop flowing on high load on 8110SCd controllers. | ||
3207 | */ | ||
3208 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) | ||
3209 | RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | RxVlan); | ||
3210 | |||
2325 | device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); | 3211 | device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); |
2326 | 3212 | ||
2327 | out: | 3213 | out: |
@@ -2863,6 +3749,8 @@ static void rtl_hw_start_8168(struct net_device *dev) | |||
2863 | break; | 3749 | break; |
2864 | 3750 | ||
2865 | case RTL_GIGA_MAC_VER_25: | 3751 | case RTL_GIGA_MAC_VER_25: |
3752 | case RTL_GIGA_MAC_VER_26: | ||
3753 | case RTL_GIGA_MAC_VER_27: | ||
2866 | rtl_hw_start_8168d(ioaddr, pdev); | 3754 | rtl_hw_start_8168d(ioaddr, pdev); |
2867 | break; | 3755 | break; |
2868 | 3756 | ||
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c index ee366c5a8fa3..c9c70ab0cce0 100644 --- a/drivers/net/sb1000.c +++ b/drivers/net/sb1000.c | |||
@@ -36,6 +36,7 @@ static char version[] = "sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net)\n"; | |||
36 | 36 | ||
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <linux/kernel.h> | 38 | #include <linux/kernel.h> |
39 | #include <linux/sched.h> | ||
39 | #include <linux/string.h> | 40 | #include <linux/string.h> |
40 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
41 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c index 01f9432c31ef..98bff5ada09a 100644 --- a/drivers/net/sfc/rx.c +++ b/drivers/net/sfc/rx.c | |||
@@ -444,7 +444,8 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, | |||
444 | * the appropriate LRO method | 444 | * the appropriate LRO method |
445 | */ | 445 | */ |
446 | static void efx_rx_packet_lro(struct efx_channel *channel, | 446 | static void efx_rx_packet_lro(struct efx_channel *channel, |
447 | struct efx_rx_buffer *rx_buf) | 447 | struct efx_rx_buffer *rx_buf, |
448 | bool checksummed) | ||
448 | { | 449 | { |
449 | struct napi_struct *napi = &channel->napi_str; | 450 | struct napi_struct *napi = &channel->napi_str; |
450 | 451 | ||
@@ -466,7 +467,8 @@ static void efx_rx_packet_lro(struct efx_channel *channel, | |||
466 | skb->len = rx_buf->len; | 467 | skb->len = rx_buf->len; |
467 | skb->data_len = rx_buf->len; | 468 | skb->data_len = rx_buf->len; |
468 | skb->truesize += rx_buf->len; | 469 | skb->truesize += rx_buf->len; |
469 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 470 | skb->ip_summed = |
471 | checksummed ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE; | ||
470 | 472 | ||
471 | napi_gro_frags(napi); | 473 | napi_gro_frags(napi); |
472 | 474 | ||
@@ -475,6 +477,7 @@ out: | |||
475 | rx_buf->page = NULL; | 477 | rx_buf->page = NULL; |
476 | } else { | 478 | } else { |
477 | EFX_BUG_ON_PARANOID(!rx_buf->skb); | 479 | EFX_BUG_ON_PARANOID(!rx_buf->skb); |
480 | EFX_BUG_ON_PARANOID(!checksummed); | ||
478 | 481 | ||
479 | napi_gro_receive(napi, rx_buf->skb); | 482 | napi_gro_receive(napi, rx_buf->skb); |
480 | rx_buf->skb = NULL; | 483 | rx_buf->skb = NULL; |
@@ -570,7 +573,7 @@ void __efx_rx_packet(struct efx_channel *channel, | |||
570 | } | 573 | } |
571 | 574 | ||
572 | if (likely(checksummed || rx_buf->page)) { | 575 | if (likely(checksummed || rx_buf->page)) { |
573 | efx_rx_packet_lro(channel, rx_buf); | 576 | efx_rx_packet_lro(channel, rx_buf, checksummed); |
574 | goto done; | 577 | goto done; |
575 | } | 578 | } |
576 | 579 | ||
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index f49d0800c1d1..528b912a4b0d 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/phy.h> | 30 | #include <linux/phy.h> |
31 | #include <linux/cache.h> | 31 | #include <linux/cache.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <asm/cacheflush.h> | ||
33 | 34 | ||
34 | #include "sh_eth.h" | 35 | #include "sh_eth.h" |
35 | 36 | ||
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c index 97949d0a699b..c072f7f36acf 100644 --- a/drivers/net/sis900.c +++ b/drivers/net/sis900.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <linux/module.h> | 52 | #include <linux/module.h> |
53 | #include <linux/moduleparam.h> | 53 | #include <linux/moduleparam.h> |
54 | #include <linux/kernel.h> | 54 | #include <linux/kernel.h> |
55 | #include <linux/sched.h> | ||
55 | #include <linux/string.h> | 56 | #include <linux/string.h> |
56 | #include <linux/timer.h> | 57 | #include <linux/timer.h> |
57 | #include <linux/errno.h> | 58 | #include <linux/errno.h> |
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c index 38a508b4aad9..b27156eaf267 100644 --- a/drivers/net/skfp/skfddi.c +++ b/drivers/net/skfp/skfddi.c | |||
@@ -73,6 +73,7 @@ static const char * const boot_msg = | |||
73 | 73 | ||
74 | /* Include files */ | 74 | /* Include files */ |
75 | 75 | ||
76 | #include <linux/capability.h> | ||
76 | #include <linux/module.h> | 77 | #include <linux/module.h> |
77 | #include <linux/kernel.h> | 78 | #include <linux/kernel.h> |
78 | #include <linux/errno.h> | 79 | #include <linux/errno.h> |
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 01f6811f1324..8f5414348e86 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/crc32.h> | 37 | #include <linux/crc32.h> |
38 | #include <linux/dma-mapping.h> | 38 | #include <linux/dma-mapping.h> |
39 | #include <linux/debugfs.h> | 39 | #include <linux/debugfs.h> |
40 | #include <linux/sched.h> | ||
40 | #include <linux/seq_file.h> | 41 | #include <linux/seq_file.h> |
41 | #include <linux/mii.h> | 42 | #include <linux/mii.h> |
42 | #include <asm/irq.h> | 43 | #include <asm/irq.h> |
diff --git a/drivers/net/slip.c b/drivers/net/slip.c index e17c535a577e..fe3cebb984de 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c | |||
@@ -67,6 +67,7 @@ | |||
67 | #include <asm/system.h> | 67 | #include <asm/system.h> |
68 | #include <asm/uaccess.h> | 68 | #include <asm/uaccess.h> |
69 | #include <linux/bitops.h> | 69 | #include <linux/bitops.h> |
70 | #include <linux/sched.h> | ||
70 | #include <linux/string.h> | 71 | #include <linux/string.h> |
71 | #include <linux/mm.h> | 72 | #include <linux/mm.h> |
72 | #include <linux/interrupt.h> | 73 | #include <linux/interrupt.h> |
diff --git a/drivers/net/stmmac/Kconfig b/drivers/net/stmmac/Kconfig new file mode 100644 index 000000000000..35eaa5251d7f --- /dev/null +++ b/drivers/net/stmmac/Kconfig | |||
@@ -0,0 +1,53 @@ | |||
1 | config STMMAC_ETH | ||
2 | tristate "STMicroelectronics 10/100/1000 Ethernet driver" | ||
3 | select MII | ||
4 | select PHYLIB | ||
5 | depends on NETDEVICES && CPU_SUBTYPE_ST40 | ||
6 | help | ||
7 | This is the driver for the ST MAC 10/100/1000 on-chip Ethernet | ||
8 | controllers. ST Ethernet IPs are built around a Synopsys IP Core. | ||
9 | |||
10 | if STMMAC_ETH | ||
11 | |||
12 | config STMMAC_DA | ||
13 | bool "STMMAC DMA arbitration scheme" | ||
14 | default n | ||
15 | help | ||
16 | Selecting this option, rx has priority over Tx (only for Giga | ||
17 | Ethernet device). | ||
18 | By default, the DMA arbitration scheme is based on Round-robin | ||
19 | (rx:tx priority is 1:1). | ||
20 | |||
21 | config STMMAC_DUAL_MAC | ||
22 | bool "STMMAC: dual mac support (EXPERIMENTAL)" | ||
23 | default n | ||
24 | depends on EXPERIMENTAL && STMMAC_ETH && !STMMAC_TIMER | ||
25 | help | ||
26 | Some ST SoCs (for example the stx7141 and stx7200c2) have two | ||
27 | Ethernet Controllers. This option turns on the second Ethernet | ||
28 | device on this kind of platforms. | ||
29 | |||
30 | config STMMAC_TIMER | ||
31 | bool "STMMAC Timer optimisation" | ||
32 | default n | ||
33 | help | ||
34 | Use an external timer for mitigating the number of network | ||
35 | interrupts. | ||
36 | |||
37 | choice | ||
38 | prompt "Select Timer device" | ||
39 | depends on STMMAC_TIMER | ||
40 | |||
41 | config STMMAC_TMU_TIMER | ||
42 | bool "TMU channel 2" | ||
43 | depends on CPU_SH4 | ||
44 | help | ||
45 | |||
46 | config STMMAC_RTC_TIMER | ||
47 | bool "Real time clock" | ||
48 | depends on RTC_CLASS | ||
49 | help | ||
50 | |||
51 | endchoice | ||
52 | |||
53 | endif | ||
diff --git a/drivers/net/stmmac/Makefile b/drivers/net/stmmac/Makefile new file mode 100644 index 000000000000..b2d7a5564dfa --- /dev/null +++ b/drivers/net/stmmac/Makefile | |||
@@ -0,0 +1,4 @@ | |||
1 | obj-$(CONFIG_STMMAC_ETH) += stmmac.o | ||
2 | stmmac-$(CONFIG_STMMAC_TIMER) += stmmac_timer.o | ||
3 | stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o \ | ||
4 | mac100.o gmac.o $(stmmac-y) | ||
diff --git a/drivers/net/stmmac/common.h b/drivers/net/stmmac/common.h new file mode 100644 index 000000000000..e49e5188e887 --- /dev/null +++ b/drivers/net/stmmac/common.h | |||
@@ -0,0 +1,330 @@ | |||
1 | /******************************************************************************* | ||
2 | STMMAC Common Header File | ||
3 | |||
4 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms and conditions of the GNU General Public License, | ||
8 | version 2, as published by the Free Software Foundation. | ||
9 | |||
10 | This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License along with | ||
16 | this program; if not, write to the Free Software Foundation, Inc., | ||
17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | The full GNU General Public License is included in this distribution in | ||
20 | the file called "COPYING". | ||
21 | |||
22 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
23 | *******************************************************************************/ | ||
24 | |||
25 | #include "descs.h" | ||
26 | #include <linux/io.h> | ||
27 | |||
28 | /* ********************************************* | ||
29 | DMA CRS Control and Status Register Mapping | ||
30 | * *********************************************/ | ||
31 | #define DMA_BUS_MODE 0x00001000 /* Bus Mode */ | ||
32 | #define DMA_XMT_POLL_DEMAND 0x00001004 /* Transmit Poll Demand */ | ||
33 | #define DMA_RCV_POLL_DEMAND 0x00001008 /* Received Poll Demand */ | ||
34 | #define DMA_RCV_BASE_ADDR 0x0000100c /* Receive List Base */ | ||
35 | #define DMA_TX_BASE_ADDR 0x00001010 /* Transmit List Base */ | ||
36 | #define DMA_STATUS 0x00001014 /* Status Register */ | ||
37 | #define DMA_CONTROL 0x00001018 /* Ctrl (Operational Mode) */ | ||
38 | #define DMA_INTR_ENA 0x0000101c /* Interrupt Enable */ | ||
39 | #define DMA_MISSED_FRAME_CTR 0x00001020 /* Missed Frame Counter */ | ||
40 | #define DMA_CUR_TX_BUF_ADDR 0x00001050 /* Current Host Tx Buffer */ | ||
41 | #define DMA_CUR_RX_BUF_ADDR 0x00001054 /* Current Host Rx Buffer */ | ||
42 | |||
43 | /* ******************************** | ||
44 | DMA Control register defines | ||
45 | * ********************************/ | ||
46 | #define DMA_CONTROL_ST 0x00002000 /* Start/Stop Transmission */ | ||
47 | #define DMA_CONTROL_SR 0x00000002 /* Start/Stop Receive */ | ||
48 | |||
49 | /* ************************************** | ||
50 | DMA Interrupt Enable register defines | ||
51 | * **************************************/ | ||
52 | /**** NORMAL INTERRUPT ****/ | ||
53 | #define DMA_INTR_ENA_NIE 0x00010000 /* Normal Summary */ | ||
54 | #define DMA_INTR_ENA_TIE 0x00000001 /* Transmit Interrupt */ | ||
55 | #define DMA_INTR_ENA_TUE 0x00000004 /* Transmit Buffer Unavailable */ | ||
56 | #define DMA_INTR_ENA_RIE 0x00000040 /* Receive Interrupt */ | ||
57 | #define DMA_INTR_ENA_ERE 0x00004000 /* Early Receive */ | ||
58 | |||
59 | #define DMA_INTR_NORMAL (DMA_INTR_ENA_NIE | DMA_INTR_ENA_RIE | \ | ||
60 | DMA_INTR_ENA_TIE) | ||
61 | |||
62 | /**** ABNORMAL INTERRUPT ****/ | ||
63 | #define DMA_INTR_ENA_AIE 0x00008000 /* Abnormal Summary */ | ||
64 | #define DMA_INTR_ENA_FBE 0x00002000 /* Fatal Bus Error */ | ||
65 | #define DMA_INTR_ENA_ETE 0x00000400 /* Early Transmit */ | ||
66 | #define DMA_INTR_ENA_RWE 0x00000200 /* Receive Watchdog */ | ||
67 | #define DMA_INTR_ENA_RSE 0x00000100 /* Receive Stopped */ | ||
68 | #define DMA_INTR_ENA_RUE 0x00000080 /* Receive Buffer Unavailable */ | ||
69 | #define DMA_INTR_ENA_UNE 0x00000020 /* Tx Underflow */ | ||
70 | #define DMA_INTR_ENA_OVE 0x00000010 /* Receive Overflow */ | ||
71 | #define DMA_INTR_ENA_TJE 0x00000008 /* Transmit Jabber */ | ||
72 | #define DMA_INTR_ENA_TSE 0x00000002 /* Transmit Stopped */ | ||
73 | |||
74 | #define DMA_INTR_ABNORMAL (DMA_INTR_ENA_AIE | DMA_INTR_ENA_FBE | \ | ||
75 | DMA_INTR_ENA_UNE) | ||
76 | |||
77 | /* DMA default interrupt mask */ | ||
78 | #define DMA_INTR_DEFAULT_MASK (DMA_INTR_NORMAL | DMA_INTR_ABNORMAL) | ||
79 | |||
80 | /* **************************** | ||
81 | * DMA Status register defines | ||
82 | * ****************************/ | ||
83 | #define DMA_STATUS_GPI 0x10000000 /* PMT interrupt */ | ||
84 | #define DMA_STATUS_GMI 0x08000000 /* MMC interrupt */ | ||
85 | #define DMA_STATUS_GLI 0x04000000 /* GMAC Line interface int. */ | ||
86 | #define DMA_STATUS_GMI 0x08000000 | ||
87 | #define DMA_STATUS_GLI 0x04000000 | ||
88 | #define DMA_STATUS_EB_MASK 0x00380000 /* Error Bits Mask */ | ||
89 | #define DMA_STATUS_EB_TX_ABORT 0x00080000 /* Error Bits - TX Abort */ | ||
90 | #define DMA_STATUS_EB_RX_ABORT 0x00100000 /* Error Bits - RX Abort */ | ||
91 | #define DMA_STATUS_TS_MASK 0x00700000 /* Transmit Process State */ | ||
92 | #define DMA_STATUS_TS_SHIFT 20 | ||
93 | #define DMA_STATUS_RS_MASK 0x000e0000 /* Receive Process State */ | ||
94 | #define DMA_STATUS_RS_SHIFT 17 | ||
95 | #define DMA_STATUS_NIS 0x00010000 /* Normal Interrupt Summary */ | ||
96 | #define DMA_STATUS_AIS 0x00008000 /* Abnormal Interrupt Summary */ | ||
97 | #define DMA_STATUS_ERI 0x00004000 /* Early Receive Interrupt */ | ||
98 | #define DMA_STATUS_FBI 0x00002000 /* Fatal Bus Error Interrupt */ | ||
99 | #define DMA_STATUS_ETI 0x00000400 /* Early Transmit Interrupt */ | ||
100 | #define DMA_STATUS_RWT 0x00000200 /* Receive Watchdog Timeout */ | ||
101 | #define DMA_STATUS_RPS 0x00000100 /* Receive Process Stopped */ | ||
102 | #define DMA_STATUS_RU 0x00000080 /* Receive Buffer Unavailable */ | ||
103 | #define DMA_STATUS_RI 0x00000040 /* Receive Interrupt */ | ||
104 | #define DMA_STATUS_UNF 0x00000020 /* Transmit Underflow */ | ||
105 | #define DMA_STATUS_OVF 0x00000010 /* Receive Overflow */ | ||
106 | #define DMA_STATUS_TJT 0x00000008 /* Transmit Jabber Timeout */ | ||
107 | #define DMA_STATUS_TU 0x00000004 /* Transmit Buffer Unavailable */ | ||
108 | #define DMA_STATUS_TPS 0x00000002 /* Transmit Process Stopped */ | ||
109 | #define DMA_STATUS_TI 0x00000001 /* Transmit Interrupt */ | ||
110 | |||
111 | /* Other defines */ | ||
112 | #define HASH_TABLE_SIZE 64 | ||
113 | #define PAUSE_TIME 0x200 | ||
114 | |||
115 | /* Flow Control defines */ | ||
116 | #define FLOW_OFF 0 | ||
117 | #define FLOW_RX 1 | ||
118 | #define FLOW_TX 2 | ||
119 | #define FLOW_AUTO (FLOW_TX | FLOW_RX) | ||
120 | |||
121 | /* DMA STORE-AND-FORWARD Operation Mode */ | ||
122 | #define SF_DMA_MODE 1 | ||
123 | |||
124 | #define HW_CSUM 1 | ||
125 | #define NO_HW_CSUM 0 | ||
126 | |||
127 | /* GMAC TX FIFO is 8K, Rx FIFO is 16K */ | ||
128 | #define BUF_SIZE_16KiB 16384 | ||
129 | #define BUF_SIZE_8KiB 8192 | ||
130 | #define BUF_SIZE_4KiB 4096 | ||
131 | #define BUF_SIZE_2KiB 2048 | ||
132 | |||
133 | /* Power Down and WOL */ | ||
134 | #define PMT_NOT_SUPPORTED 0 | ||
135 | #define PMT_SUPPORTED 1 | ||
136 | |||
137 | /* Common MAC defines */ | ||
138 | #define MAC_CTRL_REG 0x00000000 /* MAC Control */ | ||
139 | #define MAC_ENABLE_TX 0x00000008 /* Transmitter Enable */ | ||
140 | #define MAC_RNABLE_RX 0x00000004 /* Receiver Enable */ | ||
141 | |||
142 | /* MAC Management Counters register */ | ||
143 | #define MMC_CONTROL 0x00000100 /* MMC Control */ | ||
144 | #define MMC_HIGH_INTR 0x00000104 /* MMC High Interrupt */ | ||
145 | #define MMC_LOW_INTR 0x00000108 /* MMC Low Interrupt */ | ||
146 | #define MMC_HIGH_INTR_MASK 0x0000010c /* MMC High Interrupt Mask */ | ||
147 | #define MMC_LOW_INTR_MASK 0x00000110 /* MMC Low Interrupt Mask */ | ||
148 | |||
149 | #define MMC_CONTROL_MAX_FRM_MASK 0x0003ff8 /* Maximum Frame Size */ | ||
150 | #define MMC_CONTROL_MAX_FRM_SHIFT 3 | ||
151 | #define MMC_CONTROL_MAX_FRAME 0x7FF | ||
152 | |||
153 | struct stmmac_extra_stats { | ||
154 | /* Transmit errors */ | ||
155 | unsigned long tx_underflow ____cacheline_aligned; | ||
156 | unsigned long tx_carrier; | ||
157 | unsigned long tx_losscarrier; | ||
158 | unsigned long tx_heartbeat; | ||
159 | unsigned long tx_deferred; | ||
160 | unsigned long tx_vlan; | ||
161 | unsigned long tx_jabber; | ||
162 | unsigned long tx_frame_flushed; | ||
163 | unsigned long tx_payload_error; | ||
164 | unsigned long tx_ip_header_error; | ||
165 | /* Receive errors */ | ||
166 | unsigned long rx_desc; | ||
167 | unsigned long rx_partial; | ||
168 | unsigned long rx_runt; | ||
169 | unsigned long rx_toolong; | ||
170 | unsigned long rx_collision; | ||
171 | unsigned long rx_crc; | ||
172 | unsigned long rx_lenght; | ||
173 | unsigned long rx_mii; | ||
174 | unsigned long rx_multicast; | ||
175 | unsigned long rx_gmac_overflow; | ||
176 | unsigned long rx_watchdog; | ||
177 | unsigned long da_rx_filter_fail; | ||
178 | unsigned long sa_rx_filter_fail; | ||
179 | unsigned long rx_missed_cntr; | ||
180 | unsigned long rx_overflow_cntr; | ||
181 | unsigned long rx_vlan; | ||
182 | /* Tx/Rx IRQ errors */ | ||
183 | unsigned long tx_undeflow_irq; | ||
184 | unsigned long tx_process_stopped_irq; | ||
185 | unsigned long tx_jabber_irq; | ||
186 | unsigned long rx_overflow_irq; | ||
187 | unsigned long rx_buf_unav_irq; | ||
188 | unsigned long rx_process_stopped_irq; | ||
189 | unsigned long rx_watchdog_irq; | ||
190 | unsigned long tx_early_irq; | ||
191 | unsigned long fatal_bus_error_irq; | ||
192 | /* Extra info */ | ||
193 | unsigned long threshold; | ||
194 | unsigned long tx_pkt_n; | ||
195 | unsigned long rx_pkt_n; | ||
196 | unsigned long poll_n; | ||
197 | unsigned long sched_timer_n; | ||
198 | unsigned long normal_irq_n; | ||
199 | }; | ||
200 | |||
201 | /* GMAC core can compute the checksums in HW. */ | ||
202 | enum rx_frame_status { | ||
203 | good_frame = 0, | ||
204 | discard_frame = 1, | ||
205 | csum_none = 2, | ||
206 | }; | ||
207 | |||
208 | static inline void stmmac_set_mac_addr(unsigned long ioaddr, u8 addr[6], | ||
209 | unsigned int high, unsigned int low) | ||
210 | { | ||
211 | unsigned long data; | ||
212 | |||
213 | data = (addr[5] << 8) | addr[4]; | ||
214 | writel(data, ioaddr + high); | ||
215 | data = (addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | addr[0]; | ||
216 | writel(data, ioaddr + low); | ||
217 | |||
218 | return; | ||
219 | } | ||
220 | |||
221 | static inline void stmmac_get_mac_addr(unsigned long ioaddr, | ||
222 | unsigned char *addr, unsigned int high, | ||
223 | unsigned int low) | ||
224 | { | ||
225 | unsigned int hi_addr, lo_addr; | ||
226 | |||
227 | /* Read the MAC address from the hardware */ | ||
228 | hi_addr = readl(ioaddr + high); | ||
229 | lo_addr = readl(ioaddr + low); | ||
230 | |||
231 | /* Extract the MAC address from the high and low words */ | ||
232 | addr[0] = lo_addr & 0xff; | ||
233 | addr[1] = (lo_addr >> 8) & 0xff; | ||
234 | addr[2] = (lo_addr >> 16) & 0xff; | ||
235 | addr[3] = (lo_addr >> 24) & 0xff; | ||
236 | addr[4] = hi_addr & 0xff; | ||
237 | addr[5] = (hi_addr >> 8) & 0xff; | ||
238 | |||
239 | return; | ||
240 | } | ||
241 | |||
242 | struct stmmac_ops { | ||
243 | /* MAC core initialization */ | ||
244 | void (*core_init) (unsigned long ioaddr) ____cacheline_aligned; | ||
245 | /* DMA core initialization */ | ||
246 | int (*dma_init) (unsigned long ioaddr, int pbl, u32 dma_tx, u32 dma_rx); | ||
247 | /* Dump MAC registers */ | ||
248 | void (*dump_mac_regs) (unsigned long ioaddr); | ||
249 | /* Dump DMA registers */ | ||
250 | void (*dump_dma_regs) (unsigned long ioaddr); | ||
251 | /* Set tx/rx threshold in the csr6 register | ||
252 | * An invalid value enables the store-and-forward mode */ | ||
253 | void (*dma_mode) (unsigned long ioaddr, int txmode, int rxmode); | ||
254 | /* To track extra statistic (if supported) */ | ||
255 | void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x, | ||
256 | unsigned long ioaddr); | ||
257 | /* RX descriptor ring initialization */ | ||
258 | void (*init_rx_desc) (struct dma_desc *p, unsigned int ring_size, | ||
259 | int disable_rx_ic); | ||
260 | /* TX descriptor ring initialization */ | ||
261 | void (*init_tx_desc) (struct dma_desc *p, unsigned int ring_size); | ||
262 | |||
263 | /* Invoked by the xmit function to prepare the tx descriptor */ | ||
264 | void (*prepare_tx_desc) (struct dma_desc *p, int is_fs, int len, | ||
265 | int csum_flag); | ||
266 | /* Set/get the owner of the descriptor */ | ||
267 | void (*set_tx_owner) (struct dma_desc *p); | ||
268 | int (*get_tx_owner) (struct dma_desc *p); | ||
269 | /* Invoked by the xmit function to close the tx descriptor */ | ||
270 | void (*close_tx_desc) (struct dma_desc *p); | ||
271 | /* Clean the tx descriptor as soon as the tx irq is received */ | ||
272 | void (*release_tx_desc) (struct dma_desc *p); | ||
273 | /* Clear interrupt on tx frame completion. When this bit is | ||
274 | * set an interrupt happens as soon as the frame is transmitted */ | ||
275 | void (*clear_tx_ic) (struct dma_desc *p); | ||
276 | /* Last tx segment reports the transmit status */ | ||
277 | int (*get_tx_ls) (struct dma_desc *p); | ||
278 | /* Return the transmit status looking at the TDES1 */ | ||
279 | int (*tx_status) (void *data, struct stmmac_extra_stats *x, | ||
280 | struct dma_desc *p, unsigned long ioaddr); | ||
281 | /* Get the buffer size from the descriptor */ | ||
282 | int (*get_tx_len) (struct dma_desc *p); | ||
283 | /* Handle extra events on specific interrupts hw dependent */ | ||
284 | void (*host_irq_status) (unsigned long ioaddr); | ||
285 | int (*get_rx_owner) (struct dma_desc *p); | ||
286 | void (*set_rx_owner) (struct dma_desc *p); | ||
287 | /* Get the receive frame size */ | ||
288 | int (*get_rx_frame_len) (struct dma_desc *p); | ||
289 | /* Return the reception status looking at the RDES1 */ | ||
290 | int (*rx_status) (void *data, struct stmmac_extra_stats *x, | ||
291 | struct dma_desc *p); | ||
292 | /* Multicast filter setting */ | ||
293 | void (*set_filter) (struct net_device *dev); | ||
294 | /* Flow control setting */ | ||
295 | void (*flow_ctrl) (unsigned long ioaddr, unsigned int duplex, | ||
296 | unsigned int fc, unsigned int pause_time); | ||
297 | /* Set power management mode (e.g. magic frame) */ | ||
298 | void (*pmt) (unsigned long ioaddr, unsigned long mode); | ||
299 | /* Set/Get Unicast MAC addresses */ | ||
300 | void (*set_umac_addr) (unsigned long ioaddr, unsigned char *addr, | ||
301 | unsigned int reg_n); | ||
302 | void (*get_umac_addr) (unsigned long ioaddr, unsigned char *addr, | ||
303 | unsigned int reg_n); | ||
304 | }; | ||
305 | |||
306 | struct mac_link { | ||
307 | int port; | ||
308 | int duplex; | ||
309 | int speed; | ||
310 | }; | ||
311 | |||
312 | struct mii_regs { | ||
313 | unsigned int addr; /* MII Address */ | ||
314 | unsigned int data; /* MII Data */ | ||
315 | }; | ||
316 | |||
317 | struct hw_cap { | ||
318 | unsigned int version; /* Core Version register (GMAC) */ | ||
319 | unsigned int pmt; /* Power-Down mode (GMAC) */ | ||
320 | struct mac_link link; | ||
321 | struct mii_regs mii; | ||
322 | }; | ||
323 | |||
324 | struct mac_device_info { | ||
325 | struct hw_cap hw; | ||
326 | struct stmmac_ops *ops; | ||
327 | }; | ||
328 | |||
329 | struct mac_device_info *gmac_setup(unsigned long addr); | ||
330 | struct mac_device_info *mac100_setup(unsigned long addr); | ||
diff --git a/drivers/net/stmmac/descs.h b/drivers/net/stmmac/descs.h new file mode 100644 index 000000000000..6d2a0b2f5e57 --- /dev/null +++ b/drivers/net/stmmac/descs.h | |||
@@ -0,0 +1,163 @@ | |||
1 | /******************************************************************************* | ||
2 | Header File to describe the DMA descriptors | ||
3 | Use enhanced descriptors in case of GMAC Cores. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify it | ||
6 | under the terms and conditions of the GNU General Public License, | ||
7 | version 2, as published by the Free Software Foundation. | ||
8 | |||
9 | This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along with | ||
15 | this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | |||
18 | The full GNU General Public License is included in this distribution in | ||
19 | the file called "COPYING". | ||
20 | |||
21 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
22 | *******************************************************************************/ | ||
23 | struct dma_desc { | ||
24 | /* Receive descriptor */ | ||
25 | union { | ||
26 | struct { | ||
27 | /* RDES0 */ | ||
28 | u32 reserved1:1; | ||
29 | u32 crc_error:1; | ||
30 | u32 dribbling:1; | ||
31 | u32 mii_error:1; | ||
32 | u32 receive_watchdog:1; | ||
33 | u32 frame_type:1; | ||
34 | u32 collision:1; | ||
35 | u32 frame_too_long:1; | ||
36 | u32 last_descriptor:1; | ||
37 | u32 first_descriptor:1; | ||
38 | u32 multicast_frame:1; | ||
39 | u32 run_frame:1; | ||
40 | u32 length_error:1; | ||
41 | u32 partial_frame_error:1; | ||
42 | u32 descriptor_error:1; | ||
43 | u32 error_summary:1; | ||
44 | u32 frame_length:14; | ||
45 | u32 filtering_fail:1; | ||
46 | u32 own:1; | ||
47 | /* RDES1 */ | ||
48 | u32 buffer1_size:11; | ||
49 | u32 buffer2_size:11; | ||
50 | u32 reserved2:2; | ||
51 | u32 second_address_chained:1; | ||
52 | u32 end_ring:1; | ||
53 | u32 reserved3:5; | ||
54 | u32 disable_ic:1; | ||
55 | } rx; | ||
56 | struct { | ||
57 | /* RDES0 */ | ||
58 | u32 payload_csum_error:1; | ||
59 | u32 crc_error:1; | ||
60 | u32 dribbling:1; | ||
61 | u32 error_gmii:1; | ||
62 | u32 receive_watchdog:1; | ||
63 | u32 frame_type:1; | ||
64 | u32 late_collision:1; | ||
65 | u32 ipc_csum_error:1; | ||
66 | u32 last_descriptor:1; | ||
67 | u32 first_descriptor:1; | ||
68 | u32 vlan_tag:1; | ||
69 | u32 overflow_error:1; | ||
70 | u32 length_error:1; | ||
71 | u32 sa_filter_fail:1; | ||
72 | u32 descriptor_error:1; | ||
73 | u32 error_summary:1; | ||
74 | u32 frame_length:14; | ||
75 | u32 da_filter_fail:1; | ||
76 | u32 own:1; | ||
77 | /* RDES1 */ | ||
78 | u32 buffer1_size:13; | ||
79 | u32 reserved1:1; | ||
80 | u32 second_address_chained:1; | ||
81 | u32 end_ring:1; | ||
82 | u32 buffer2_size:13; | ||
83 | u32 reserved2:2; | ||
84 | u32 disable_ic:1; | ||
85 | } erx; /* -- enhanced -- */ | ||
86 | |||
87 | /* Transmit descriptor */ | ||
88 | struct { | ||
89 | /* TDES0 */ | ||
90 | u32 deferred:1; | ||
91 | u32 underflow_error:1; | ||
92 | u32 excessive_deferral:1; | ||
93 | u32 collision_count:4; | ||
94 | u32 heartbeat_fail:1; | ||
95 | u32 excessive_collisions:1; | ||
96 | u32 late_collision:1; | ||
97 | u32 no_carrier:1; | ||
98 | u32 loss_carrier:1; | ||
99 | u32 reserved1:3; | ||
100 | u32 error_summary:1; | ||
101 | u32 reserved2:15; | ||
102 | u32 own:1; | ||
103 | /* TDES1 */ | ||
104 | u32 buffer1_size:11; | ||
105 | u32 buffer2_size:11; | ||
106 | u32 reserved3:1; | ||
107 | u32 disable_padding:1; | ||
108 | u32 second_address_chained:1; | ||
109 | u32 end_ring:1; | ||
110 | u32 crc_disable:1; | ||
111 | u32 reserved4:2; | ||
112 | u32 first_segment:1; | ||
113 | u32 last_segment:1; | ||
114 | u32 interrupt:1; | ||
115 | } tx; | ||
116 | struct { | ||
117 | /* TDES0 */ | ||
118 | u32 deferred:1; | ||
119 | u32 underflow_error:1; | ||
120 | u32 excessive_deferral:1; | ||
121 | u32 collision_count:4; | ||
122 | u32 vlan_frame:1; | ||
123 | u32 excessive_collisions:1; | ||
124 | u32 late_collision:1; | ||
125 | u32 no_carrier:1; | ||
126 | u32 loss_carrier:1; | ||
127 | u32 payload_error:1; | ||
128 | u32 frame_flushed:1; | ||
129 | u32 jabber_timeout:1; | ||
130 | u32 error_summary:1; | ||
131 | u32 ip_header_error:1; | ||
132 | u32 time_stamp_status:1; | ||
133 | u32 reserved1:2; | ||
134 | u32 second_address_chained:1; | ||
135 | u32 end_ring:1; | ||
136 | u32 checksum_insertion:2; | ||
137 | u32 reserved2:1; | ||
138 | u32 time_stamp_enable:1; | ||
139 | u32 disable_padding:1; | ||
140 | u32 crc_disable:1; | ||
141 | u32 first_segment:1; | ||
142 | u32 last_segment:1; | ||
143 | u32 interrupt:1; | ||
144 | u32 own:1; | ||
145 | /* TDES1 */ | ||
146 | u32 buffer1_size:13; | ||
147 | u32 reserved3:3; | ||
148 | u32 buffer2_size:13; | ||
149 | u32 reserved4:3; | ||
150 | } etx; /* -- enhanced -- */ | ||
151 | } des01; | ||
152 | unsigned int des2; | ||
153 | unsigned int des3; | ||
154 | }; | ||
155 | |||
156 | /* Transmit checksum insertion control */ | ||
157 | enum tdes_csum_insertion { | ||
158 | cic_disabled = 0, /* Checksum Insertion Control */ | ||
159 | cic_only_ip = 1, /* Only IP header */ | ||
160 | cic_no_pseudoheader = 2, /* IP header but pseudoheader | ||
161 | * is not calculated */ | ||
162 | cic_full = 3, /* IP header and pseudoheader */ | ||
163 | }; | ||
diff --git a/drivers/net/stmmac/gmac.c b/drivers/net/stmmac/gmac.c new file mode 100644 index 000000000000..b624bb5bae0a --- /dev/null +++ b/drivers/net/stmmac/gmac.c | |||
@@ -0,0 +1,693 @@ | |||
1 | /******************************************************************************* | ||
2 | This is the driver for the GMAC on-chip Ethernet controller for ST SoCs. | ||
3 | DWC Ether MAC 10/100/1000 Universal version 3.41a has been used for | ||
4 | developing this code. | ||
5 | |||
6 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify it | ||
9 | under the terms and conditions of the GNU General Public License, | ||
10 | version 2, as published by the Free Software Foundation. | ||
11 | |||
12 | This program is distributed in the hope it will be useful, but WITHOUT | ||
13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
15 | more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License along with | ||
18 | this program; if not, write to the Free Software Foundation, Inc., | ||
19 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
20 | |||
21 | The full GNU General Public License is included in this distribution in | ||
22 | the file called "COPYING". | ||
23 | |||
24 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
25 | *******************************************************************************/ | ||
26 | |||
27 | #include <linux/netdevice.h> | ||
28 | #include <linux/crc32.h> | ||
29 | #include <linux/mii.h> | ||
30 | #include <linux/phy.h> | ||
31 | |||
32 | #include "stmmac.h" | ||
33 | #include "gmac.h" | ||
34 | |||
35 | #undef GMAC_DEBUG | ||
36 | /*#define GMAC_DEBUG*/ | ||
37 | #undef FRAME_FILTER_DEBUG | ||
38 | /*#define FRAME_FILTER_DEBUG*/ | ||
39 | #ifdef GMAC_DEBUG | ||
40 | #define DBG(fmt, args...) printk(fmt, ## args) | ||
41 | #else | ||
42 | #define DBG(fmt, args...) do { } while (0) | ||
43 | #endif | ||
44 | |||
45 | static void gmac_dump_regs(unsigned long ioaddr) | ||
46 | { | ||
47 | int i; | ||
48 | pr_info("\t----------------------------------------------\n" | ||
49 | "\t GMAC registers (base addr = 0x%8x)\n" | ||
50 | "\t----------------------------------------------\n", | ||
51 | (unsigned int)ioaddr); | ||
52 | |||
53 | for (i = 0; i < 55; i++) { | ||
54 | int offset = i * 4; | ||
55 | pr_info("\tReg No. %d (offset 0x%x): 0x%08x\n", i, | ||
56 | offset, readl(ioaddr + offset)); | ||
57 | } | ||
58 | return; | ||
59 | } | ||
60 | |||
61 | static int gmac_dma_init(unsigned long ioaddr, int pbl, u32 dma_tx, u32 dma_rx) | ||
62 | { | ||
63 | u32 value = readl(ioaddr + DMA_BUS_MODE); | ||
64 | /* DMA SW reset */ | ||
65 | value |= DMA_BUS_MODE_SFT_RESET; | ||
66 | writel(value, ioaddr + DMA_BUS_MODE); | ||
67 | do {} while ((readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)); | ||
68 | |||
69 | value = /* DMA_BUS_MODE_FB | */ DMA_BUS_MODE_4PBL | | ||
70 | ((pbl << DMA_BUS_MODE_PBL_SHIFT) | | ||
71 | (pbl << DMA_BUS_MODE_RPBL_SHIFT)); | ||
72 | |||
73 | #ifdef CONFIG_STMMAC_DA | ||
74 | value |= DMA_BUS_MODE_DA; /* Rx has priority over tx */ | ||
75 | #endif | ||
76 | writel(value, ioaddr + DMA_BUS_MODE); | ||
77 | |||
78 | /* Mask interrupts by writing to CSR7 */ | ||
79 | writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA); | ||
80 | |||
81 | /* The base address of the RX/TX descriptor lists must be written into | ||
82 | * DMA CSR3 and CSR4, respectively. */ | ||
83 | writel(dma_tx, ioaddr + DMA_TX_BASE_ADDR); | ||
84 | writel(dma_rx, ioaddr + DMA_RCV_BASE_ADDR); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | /* Transmit FIFO flush operation */ | ||
90 | static void gmac_flush_tx_fifo(unsigned long ioaddr) | ||
91 | { | ||
92 | u32 csr6 = readl(ioaddr + DMA_CONTROL); | ||
93 | writel((csr6 | DMA_CONTROL_FTF), ioaddr + DMA_CONTROL); | ||
94 | |||
95 | do {} while ((readl(ioaddr + DMA_CONTROL) & DMA_CONTROL_FTF)); | ||
96 | } | ||
97 | |||
98 | static void gmac_dma_operation_mode(unsigned long ioaddr, int txmode, | ||
99 | int rxmode) | ||
100 | { | ||
101 | u32 csr6 = readl(ioaddr + DMA_CONTROL); | ||
102 | |||
103 | if (txmode == SF_DMA_MODE) { | ||
104 | DBG(KERN_DEBUG "GMAC: enabling TX store and forward mode\n"); | ||
105 | /* Transmit COE type 2 cannot be done in cut-through mode. */ | ||
106 | csr6 |= DMA_CONTROL_TSF; | ||
107 | /* Operating on second frame increase the performance | ||
108 | * especially when transmit store-and-forward is used.*/ | ||
109 | csr6 |= DMA_CONTROL_OSF; | ||
110 | } else { | ||
111 | DBG(KERN_DEBUG "GMAC: disabling TX store and forward mode" | ||
112 | " (threshold = %d)\n", txmode); | ||
113 | csr6 &= ~DMA_CONTROL_TSF; | ||
114 | csr6 &= DMA_CONTROL_TC_TX_MASK; | ||
115 | /* Set the transmit threashold */ | ||
116 | if (txmode <= 32) | ||
117 | csr6 |= DMA_CONTROL_TTC_32; | ||
118 | else if (txmode <= 64) | ||
119 | csr6 |= DMA_CONTROL_TTC_64; | ||
120 | else if (txmode <= 128) | ||
121 | csr6 |= DMA_CONTROL_TTC_128; | ||
122 | else if (txmode <= 192) | ||
123 | csr6 |= DMA_CONTROL_TTC_192; | ||
124 | else | ||
125 | csr6 |= DMA_CONTROL_TTC_256; | ||
126 | } | ||
127 | |||
128 | if (rxmode == SF_DMA_MODE) { | ||
129 | DBG(KERN_DEBUG "GMAC: enabling RX store and forward mode\n"); | ||
130 | csr6 |= DMA_CONTROL_RSF; | ||
131 | } else { | ||
132 | DBG(KERN_DEBUG "GMAC: disabling RX store and forward mode" | ||
133 | " (threshold = %d)\n", rxmode); | ||
134 | csr6 &= ~DMA_CONTROL_RSF; | ||
135 | csr6 &= DMA_CONTROL_TC_RX_MASK; | ||
136 | if (rxmode <= 32) | ||
137 | csr6 |= DMA_CONTROL_RTC_32; | ||
138 | else if (rxmode <= 64) | ||
139 | csr6 |= DMA_CONTROL_RTC_64; | ||
140 | else if (rxmode <= 96) | ||
141 | csr6 |= DMA_CONTROL_RTC_96; | ||
142 | else | ||
143 | csr6 |= DMA_CONTROL_RTC_128; | ||
144 | } | ||
145 | |||
146 | writel(csr6, ioaddr + DMA_CONTROL); | ||
147 | return; | ||
148 | } | ||
149 | |||
150 | /* Not yet implemented --- no RMON module */ | ||
151 | static void gmac_dma_diagnostic_fr(void *data, struct stmmac_extra_stats *x, | ||
152 | unsigned long ioaddr) | ||
153 | { | ||
154 | return; | ||
155 | } | ||
156 | |||
157 | static void gmac_dump_dma_regs(unsigned long ioaddr) | ||
158 | { | ||
159 | int i; | ||
160 | pr_info(" DMA registers\n"); | ||
161 | for (i = 0; i < 22; i++) { | ||
162 | if ((i < 9) || (i > 17)) { | ||
163 | int offset = i * 4; | ||
164 | pr_err("\t Reg No. %d (offset 0x%x): 0x%08x\n", i, | ||
165 | (DMA_BUS_MODE + offset), | ||
166 | readl(ioaddr + DMA_BUS_MODE + offset)); | ||
167 | } | ||
168 | } | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | static int gmac_get_tx_frame_status(void *data, struct stmmac_extra_stats *x, | ||
173 | struct dma_desc *p, unsigned long ioaddr) | ||
174 | { | ||
175 | int ret = 0; | ||
176 | struct net_device_stats *stats = (struct net_device_stats *)data; | ||
177 | |||
178 | if (unlikely(p->des01.etx.error_summary)) { | ||
179 | DBG(KERN_ERR "GMAC TX error... 0x%08x\n", p->des01.etx); | ||
180 | if (unlikely(p->des01.etx.jabber_timeout)) { | ||
181 | DBG(KERN_ERR "\tjabber_timeout error\n"); | ||
182 | x->tx_jabber++; | ||
183 | } | ||
184 | |||
185 | if (unlikely(p->des01.etx.frame_flushed)) { | ||
186 | DBG(KERN_ERR "\tframe_flushed error\n"); | ||
187 | x->tx_frame_flushed++; | ||
188 | gmac_flush_tx_fifo(ioaddr); | ||
189 | } | ||
190 | |||
191 | if (unlikely(p->des01.etx.loss_carrier)) { | ||
192 | DBG(KERN_ERR "\tloss_carrier error\n"); | ||
193 | x->tx_losscarrier++; | ||
194 | stats->tx_carrier_errors++; | ||
195 | } | ||
196 | if (unlikely(p->des01.etx.no_carrier)) { | ||
197 | DBG(KERN_ERR "\tno_carrier error\n"); | ||
198 | x->tx_carrier++; | ||
199 | stats->tx_carrier_errors++; | ||
200 | } | ||
201 | if (unlikely(p->des01.etx.late_collision)) { | ||
202 | DBG(KERN_ERR "\tlate_collision error\n"); | ||
203 | stats->collisions += p->des01.etx.collision_count; | ||
204 | } | ||
205 | if (unlikely(p->des01.etx.excessive_collisions)) { | ||
206 | DBG(KERN_ERR "\texcessive_collisions\n"); | ||
207 | stats->collisions += p->des01.etx.collision_count; | ||
208 | } | ||
209 | if (unlikely(p->des01.etx.excessive_deferral)) { | ||
210 | DBG(KERN_INFO "\texcessive tx_deferral\n"); | ||
211 | x->tx_deferred++; | ||
212 | } | ||
213 | |||
214 | if (unlikely(p->des01.etx.underflow_error)) { | ||
215 | DBG(KERN_ERR "\tunderflow error\n"); | ||
216 | gmac_flush_tx_fifo(ioaddr); | ||
217 | x->tx_underflow++; | ||
218 | } | ||
219 | |||
220 | if (unlikely(p->des01.etx.ip_header_error)) { | ||
221 | DBG(KERN_ERR "\tTX IP header csum error\n"); | ||
222 | x->tx_ip_header_error++; | ||
223 | } | ||
224 | |||
225 | if (unlikely(p->des01.etx.payload_error)) { | ||
226 | DBG(KERN_ERR "\tAddr/Payload csum error\n"); | ||
227 | x->tx_payload_error++; | ||
228 | gmac_flush_tx_fifo(ioaddr); | ||
229 | } | ||
230 | |||
231 | ret = -1; | ||
232 | } | ||
233 | |||
234 | if (unlikely(p->des01.etx.deferred)) { | ||
235 | DBG(KERN_INFO "GMAC TX status: tx deferred\n"); | ||
236 | x->tx_deferred++; | ||
237 | } | ||
238 | #ifdef STMMAC_VLAN_TAG_USED | ||
239 | if (p->des01.etx.vlan_frame) { | ||
240 | DBG(KERN_INFO "GMAC TX status: VLAN frame\n"); | ||
241 | x->tx_vlan++; | ||
242 | } | ||
243 | #endif | ||
244 | |||
245 | return ret; | ||
246 | } | ||
247 | |||
248 | static int gmac_get_tx_len(struct dma_desc *p) | ||
249 | { | ||
250 | return p->des01.etx.buffer1_size; | ||
251 | } | ||
252 | |||
253 | static int gmac_coe_rdes0(int ipc_err, int type, int payload_err) | ||
254 | { | ||
255 | int ret = good_frame; | ||
256 | u32 status = (type << 2 | ipc_err << 1 | payload_err) & 0x7; | ||
257 | |||
258 | /* bits 5 7 0 | Frame status | ||
259 | * ---------------------------------------------------------- | ||
260 | * 0 0 0 | IEEE 802.3 Type frame (lenght < 1536 octects) | ||
261 | * 1 0 0 | IPv4/6 No CSUM errorS. | ||
262 | * 1 0 1 | IPv4/6 CSUM PAYLOAD error | ||
263 | * 1 1 0 | IPv4/6 CSUM IP HR error | ||
264 | * 1 1 1 | IPv4/6 IP PAYLOAD AND HEADER errorS | ||
265 | * 0 0 1 | IPv4/6 unsupported IP PAYLOAD | ||
266 | * 0 1 1 | COE bypassed.. no IPv4/6 frame | ||
267 | * 0 1 0 | Reserved. | ||
268 | */ | ||
269 | if (status == 0x0) { | ||
270 | DBG(KERN_INFO "RX Des0 status: IEEE 802.3 Type frame.\n"); | ||
271 | ret = good_frame; | ||
272 | } else if (status == 0x4) { | ||
273 | DBG(KERN_INFO "RX Des0 status: IPv4/6 No CSUM errorS.\n"); | ||
274 | ret = good_frame; | ||
275 | } else if (status == 0x5) { | ||
276 | DBG(KERN_ERR "RX Des0 status: IPv4/6 Payload Error.\n"); | ||
277 | ret = csum_none; | ||
278 | } else if (status == 0x6) { | ||
279 | DBG(KERN_ERR "RX Des0 status: IPv4/6 Header Error.\n"); | ||
280 | ret = csum_none; | ||
281 | } else if (status == 0x7) { | ||
282 | DBG(KERN_ERR | ||
283 | "RX Des0 status: IPv4/6 Header and Payload Error.\n"); | ||
284 | ret = csum_none; | ||
285 | } else if (status == 0x1) { | ||
286 | DBG(KERN_ERR | ||
287 | "RX Des0 status: IPv4/6 unsupported IP PAYLOAD.\n"); | ||
288 | ret = discard_frame; | ||
289 | } else if (status == 0x3) { | ||
290 | DBG(KERN_ERR "RX Des0 status: No IPv4, IPv6 frame.\n"); | ||
291 | ret = discard_frame; | ||
292 | } | ||
293 | return ret; | ||
294 | } | ||
295 | |||
296 | static int gmac_get_rx_frame_status(void *data, struct stmmac_extra_stats *x, | ||
297 | struct dma_desc *p) | ||
298 | { | ||
299 | int ret = good_frame; | ||
300 | struct net_device_stats *stats = (struct net_device_stats *)data; | ||
301 | |||
302 | if (unlikely(p->des01.erx.error_summary)) { | ||
303 | DBG(KERN_ERR "GMAC RX Error Summary... 0x%08x\n", p->des01.erx); | ||
304 | if (unlikely(p->des01.erx.descriptor_error)) { | ||
305 | DBG(KERN_ERR "\tdescriptor error\n"); | ||
306 | x->rx_desc++; | ||
307 | stats->rx_length_errors++; | ||
308 | } | ||
309 | if (unlikely(p->des01.erx.overflow_error)) { | ||
310 | DBG(KERN_ERR "\toverflow error\n"); | ||
311 | x->rx_gmac_overflow++; | ||
312 | } | ||
313 | |||
314 | if (unlikely(p->des01.erx.ipc_csum_error)) | ||
315 | DBG(KERN_ERR "\tIPC Csum Error/Giant frame\n"); | ||
316 | |||
317 | if (unlikely(p->des01.erx.late_collision)) { | ||
318 | DBG(KERN_ERR "\tlate_collision error\n"); | ||
319 | stats->collisions++; | ||
320 | stats->collisions++; | ||
321 | } | ||
322 | if (unlikely(p->des01.erx.receive_watchdog)) { | ||
323 | DBG(KERN_ERR "\treceive_watchdog error\n"); | ||
324 | x->rx_watchdog++; | ||
325 | } | ||
326 | if (unlikely(p->des01.erx.error_gmii)) { | ||
327 | DBG(KERN_ERR "\tReceive Error\n"); | ||
328 | x->rx_mii++; | ||
329 | } | ||
330 | if (unlikely(p->des01.erx.crc_error)) { | ||
331 | DBG(KERN_ERR "\tCRC error\n"); | ||
332 | x->rx_crc++; | ||
333 | stats->rx_crc_errors++; | ||
334 | } | ||
335 | ret = discard_frame; | ||
336 | } | ||
337 | |||
338 | /* After a payload csum error, the ES bit is set. | ||
339 | * It doesn't match with the information reported into the databook. | ||
340 | * At any rate, we need to understand if the CSUM hw computation is ok | ||
341 | * and report this info to the upper layers. */ | ||
342 | ret = gmac_coe_rdes0(p->des01.erx.ipc_csum_error, | ||
343 | p->des01.erx.frame_type, p->des01.erx.payload_csum_error); | ||
344 | |||
345 | if (unlikely(p->des01.erx.dribbling)) { | ||
346 | DBG(KERN_ERR "GMAC RX: dribbling error\n"); | ||
347 | ret = discard_frame; | ||
348 | } | ||
349 | if (unlikely(p->des01.erx.sa_filter_fail)) { | ||
350 | DBG(KERN_ERR "GMAC RX : Source Address filter fail\n"); | ||
351 | x->sa_rx_filter_fail++; | ||
352 | ret = discard_frame; | ||
353 | } | ||
354 | if (unlikely(p->des01.erx.da_filter_fail)) { | ||
355 | DBG(KERN_ERR "GMAC RX : Destination Address filter fail\n"); | ||
356 | x->da_rx_filter_fail++; | ||
357 | ret = discard_frame; | ||
358 | } | ||
359 | if (unlikely(p->des01.erx.length_error)) { | ||
360 | DBG(KERN_ERR "GMAC RX: length_error error\n"); | ||
361 | x->rx_lenght++; | ||
362 | ret = discard_frame; | ||
363 | } | ||
364 | #ifdef STMMAC_VLAN_TAG_USED | ||
365 | if (p->des01.erx.vlan_tag) { | ||
366 | DBG(KERN_INFO "GMAC RX: VLAN frame tagged\n"); | ||
367 | x->rx_vlan++; | ||
368 | } | ||
369 | #endif | ||
370 | return ret; | ||
371 | } | ||
372 | |||
373 | static void gmac_irq_status(unsigned long ioaddr) | ||
374 | { | ||
375 | u32 intr_status = readl(ioaddr + GMAC_INT_STATUS); | ||
376 | |||
377 | /* Not used events (e.g. MMC interrupts) are not handled. */ | ||
378 | if ((intr_status & mmc_tx_irq)) | ||
379 | DBG(KERN_DEBUG "GMAC: MMC tx interrupt: 0x%08x\n", | ||
380 | readl(ioaddr + GMAC_MMC_TX_INTR)); | ||
381 | if (unlikely(intr_status & mmc_rx_irq)) | ||
382 | DBG(KERN_DEBUG "GMAC: MMC rx interrupt: 0x%08x\n", | ||
383 | readl(ioaddr + GMAC_MMC_RX_INTR)); | ||
384 | if (unlikely(intr_status & mmc_rx_csum_offload_irq)) | ||
385 | DBG(KERN_DEBUG "GMAC: MMC rx csum offload: 0x%08x\n", | ||
386 | readl(ioaddr + GMAC_MMC_RX_CSUM_OFFLOAD)); | ||
387 | if (unlikely(intr_status & pmt_irq)) { | ||
388 | DBG(KERN_DEBUG "GMAC: received Magic frame\n"); | ||
389 | /* clear the PMT bits 5 and 6 by reading the PMT | ||
390 | * status register. */ | ||
391 | readl(ioaddr + GMAC_PMT); | ||
392 | } | ||
393 | |||
394 | return; | ||
395 | } | ||
396 | |||
397 | static void gmac_core_init(unsigned long ioaddr) | ||
398 | { | ||
399 | u32 value = readl(ioaddr + GMAC_CONTROL); | ||
400 | value |= GMAC_CORE_INIT; | ||
401 | writel(value, ioaddr + GMAC_CONTROL); | ||
402 | |||
403 | /* STBus Bridge Configuration */ | ||
404 | /*writel(0xc5608, ioaddr + 0x00007000);*/ | ||
405 | |||
406 | /* Freeze MMC counters */ | ||
407 | writel(0x8, ioaddr + GMAC_MMC_CTRL); | ||
408 | /* Mask GMAC interrupts */ | ||
409 | writel(0x207, ioaddr + GMAC_INT_MASK); | ||
410 | |||
411 | #ifdef STMMAC_VLAN_TAG_USED | ||
412 | /* Tag detection without filtering */ | ||
413 | writel(0x0, ioaddr + GMAC_VLAN_TAG); | ||
414 | #endif | ||
415 | return; | ||
416 | } | ||
417 | |||
418 | static void gmac_set_umac_addr(unsigned long ioaddr, unsigned char *addr, | ||
419 | unsigned int reg_n) | ||
420 | { | ||
421 | stmmac_set_mac_addr(ioaddr, addr, GMAC_ADDR_HIGH(reg_n), | ||
422 | GMAC_ADDR_LOW(reg_n)); | ||
423 | } | ||
424 | |||
425 | static void gmac_get_umac_addr(unsigned long ioaddr, unsigned char *addr, | ||
426 | unsigned int reg_n) | ||
427 | { | ||
428 | stmmac_get_mac_addr(ioaddr, addr, GMAC_ADDR_HIGH(reg_n), | ||
429 | GMAC_ADDR_LOW(reg_n)); | ||
430 | } | ||
431 | |||
432 | static void gmac_set_filter(struct net_device *dev) | ||
433 | { | ||
434 | unsigned long ioaddr = dev->base_addr; | ||
435 | unsigned int value = 0; | ||
436 | |||
437 | DBG(KERN_INFO "%s: # mcasts %d, # unicast %d\n", | ||
438 | __func__, dev->mc_count, dev->uc_count); | ||
439 | |||
440 | if (dev->flags & IFF_PROMISC) | ||
441 | value = GMAC_FRAME_FILTER_PR; | ||
442 | else if ((dev->mc_count > HASH_TABLE_SIZE) | ||
443 | || (dev->flags & IFF_ALLMULTI)) { | ||
444 | value = GMAC_FRAME_FILTER_PM; /* pass all multi */ | ||
445 | writel(0xffffffff, ioaddr + GMAC_HASH_HIGH); | ||
446 | writel(0xffffffff, ioaddr + GMAC_HASH_LOW); | ||
447 | } else if (dev->mc_count > 0) { | ||
448 | int i; | ||
449 | u32 mc_filter[2]; | ||
450 | struct dev_mc_list *mclist; | ||
451 | |||
452 | /* Hash filter for multicast */ | ||
453 | value = GMAC_FRAME_FILTER_HMC; | ||
454 | |||
455 | memset(mc_filter, 0, sizeof(mc_filter)); | ||
456 | for (i = 0, mclist = dev->mc_list; | ||
457 | mclist && i < dev->mc_count; i++, mclist = mclist->next) { | ||
458 | /* The upper 6 bits of the calculated CRC are used to | ||
459 | index the contens of the hash table */ | ||
460 | int bit_nr = | ||
461 | bitrev32(~crc32_le(~0, mclist->dmi_addr, 6)) >> 26; | ||
462 | /* The most significant bit determines the register to | ||
463 | * use (H/L) while the other 5 bits determine the bit | ||
464 | * within the register. */ | ||
465 | mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); | ||
466 | } | ||
467 | writel(mc_filter[0], ioaddr + GMAC_HASH_LOW); | ||
468 | writel(mc_filter[1], ioaddr + GMAC_HASH_HIGH); | ||
469 | } | ||
470 | |||
471 | /* Handle multiple unicast addresses (perfect filtering)*/ | ||
472 | if (dev->uc_count > GMAC_MAX_UNICAST_ADDRESSES) | ||
473 | /* Switch to promiscuous mode is more than 16 addrs | ||
474 | are required */ | ||
475 | value |= GMAC_FRAME_FILTER_PR; | ||
476 | else { | ||
477 | int i; | ||
478 | struct dev_addr_list *uc_ptr = dev->uc_list; | ||
479 | |||
480 | for (i = 0; i < dev->uc_count; i++) { | ||
481 | gmac_set_umac_addr(ioaddr, uc_ptr->da_addr, | ||
482 | i + 1); | ||
483 | |||
484 | DBG(KERN_INFO "\t%d " | ||
485 | "- Unicast addr %02x:%02x:%02x:%02x:%02x:" | ||
486 | "%02x\n", i + 1, | ||
487 | uc_ptr->da_addr[0], uc_ptr->da_addr[1], | ||
488 | uc_ptr->da_addr[2], uc_ptr->da_addr[3], | ||
489 | uc_ptr->da_addr[4], uc_ptr->da_addr[5]); | ||
490 | uc_ptr = uc_ptr->next; | ||
491 | } | ||
492 | } | ||
493 | |||
494 | #ifdef FRAME_FILTER_DEBUG | ||
495 | /* Enable Receive all mode (to debug filtering_fail errors) */ | ||
496 | value |= GMAC_FRAME_FILTER_RA; | ||
497 | #endif | ||
498 | writel(value, ioaddr + GMAC_FRAME_FILTER); | ||
499 | |||
500 | DBG(KERN_INFO "\tFrame Filter reg: 0x%08x\n\tHash regs: " | ||
501 | "HI 0x%08x, LO 0x%08x\n", readl(ioaddr + GMAC_FRAME_FILTER), | ||
502 | readl(ioaddr + GMAC_HASH_HIGH), readl(ioaddr + GMAC_HASH_LOW)); | ||
503 | |||
504 | return; | ||
505 | } | ||
506 | |||
507 | static void gmac_flow_ctrl(unsigned long ioaddr, unsigned int duplex, | ||
508 | unsigned int fc, unsigned int pause_time) | ||
509 | { | ||
510 | unsigned int flow = 0; | ||
511 | |||
512 | DBG(KERN_DEBUG "GMAC Flow-Control:\n"); | ||
513 | if (fc & FLOW_RX) { | ||
514 | DBG(KERN_DEBUG "\tReceive Flow-Control ON\n"); | ||
515 | flow |= GMAC_FLOW_CTRL_RFE; | ||
516 | } | ||
517 | if (fc & FLOW_TX) { | ||
518 | DBG(KERN_DEBUG "\tTransmit Flow-Control ON\n"); | ||
519 | flow |= GMAC_FLOW_CTRL_TFE; | ||
520 | } | ||
521 | |||
522 | if (duplex) { | ||
523 | DBG(KERN_DEBUG "\tduplex mode: pause time: %d\n", pause_time); | ||
524 | flow |= (pause_time << GMAC_FLOW_CTRL_PT_SHIFT); | ||
525 | } | ||
526 | |||
527 | writel(flow, ioaddr + GMAC_FLOW_CTRL); | ||
528 | return; | ||
529 | } | ||
530 | |||
531 | static void gmac_pmt(unsigned long ioaddr, unsigned long mode) | ||
532 | { | ||
533 | unsigned int pmt = 0; | ||
534 | |||
535 | if (mode == WAKE_MAGIC) { | ||
536 | DBG(KERN_DEBUG "GMAC: WOL Magic frame\n"); | ||
537 | pmt |= power_down | magic_pkt_en; | ||
538 | } else if (mode == WAKE_UCAST) { | ||
539 | DBG(KERN_DEBUG "GMAC: WOL on global unicast\n"); | ||
540 | pmt |= global_unicast; | ||
541 | } | ||
542 | |||
543 | writel(pmt, ioaddr + GMAC_PMT); | ||
544 | return; | ||
545 | } | ||
546 | |||
547 | static void gmac_init_rx_desc(struct dma_desc *p, unsigned int ring_size, | ||
548 | int disable_rx_ic) | ||
549 | { | ||
550 | int i; | ||
551 | for (i = 0; i < ring_size; i++) { | ||
552 | p->des01.erx.own = 1; | ||
553 | p->des01.erx.buffer1_size = BUF_SIZE_8KiB - 1; | ||
554 | /* To support jumbo frames */ | ||
555 | p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1; | ||
556 | if (i == ring_size - 1) | ||
557 | p->des01.erx.end_ring = 1; | ||
558 | if (disable_rx_ic) | ||
559 | p->des01.erx.disable_ic = 1; | ||
560 | p++; | ||
561 | } | ||
562 | return; | ||
563 | } | ||
564 | |||
565 | static void gmac_init_tx_desc(struct dma_desc *p, unsigned int ring_size) | ||
566 | { | ||
567 | int i; | ||
568 | |||
569 | for (i = 0; i < ring_size; i++) { | ||
570 | p->des01.etx.own = 0; | ||
571 | if (i == ring_size - 1) | ||
572 | p->des01.etx.end_ring = 1; | ||
573 | p++; | ||
574 | } | ||
575 | |||
576 | return; | ||
577 | } | ||
578 | |||
579 | static int gmac_get_tx_owner(struct dma_desc *p) | ||
580 | { | ||
581 | return p->des01.etx.own; | ||
582 | } | ||
583 | |||
584 | static int gmac_get_rx_owner(struct dma_desc *p) | ||
585 | { | ||
586 | return p->des01.erx.own; | ||
587 | } | ||
588 | |||
589 | static void gmac_set_tx_owner(struct dma_desc *p) | ||
590 | { | ||
591 | p->des01.etx.own = 1; | ||
592 | } | ||
593 | |||
594 | static void gmac_set_rx_owner(struct dma_desc *p) | ||
595 | { | ||
596 | p->des01.erx.own = 1; | ||
597 | } | ||
598 | |||
599 | static int gmac_get_tx_ls(struct dma_desc *p) | ||
600 | { | ||
601 | return p->des01.etx.last_segment; | ||
602 | } | ||
603 | |||
604 | static void gmac_release_tx_desc(struct dma_desc *p) | ||
605 | { | ||
606 | int ter = p->des01.etx.end_ring; | ||
607 | |||
608 | memset(p, 0, sizeof(struct dma_desc)); | ||
609 | p->des01.etx.end_ring = ter; | ||
610 | |||
611 | return; | ||
612 | } | ||
613 | |||
614 | static void gmac_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, | ||
615 | int csum_flag) | ||
616 | { | ||
617 | p->des01.etx.first_segment = is_fs; | ||
618 | if (unlikely(len > BUF_SIZE_4KiB)) { | ||
619 | p->des01.etx.buffer1_size = BUF_SIZE_4KiB; | ||
620 | p->des01.etx.buffer2_size = len - BUF_SIZE_4KiB; | ||
621 | } else { | ||
622 | p->des01.etx.buffer1_size = len; | ||
623 | } | ||
624 | if (likely(csum_flag)) | ||
625 | p->des01.etx.checksum_insertion = cic_full; | ||
626 | } | ||
627 | |||
628 | static void gmac_clear_tx_ic(struct dma_desc *p) | ||
629 | { | ||
630 | p->des01.etx.interrupt = 0; | ||
631 | } | ||
632 | |||
633 | static void gmac_close_tx_desc(struct dma_desc *p) | ||
634 | { | ||
635 | p->des01.etx.last_segment = 1; | ||
636 | p->des01.etx.interrupt = 1; | ||
637 | } | ||
638 | |||
639 | static int gmac_get_rx_frame_len(struct dma_desc *p) | ||
640 | { | ||
641 | return p->des01.erx.frame_length; | ||
642 | } | ||
643 | |||
644 | struct stmmac_ops gmac_driver = { | ||
645 | .core_init = gmac_core_init, | ||
646 | .dump_mac_regs = gmac_dump_regs, | ||
647 | .dma_init = gmac_dma_init, | ||
648 | .dump_dma_regs = gmac_dump_dma_regs, | ||
649 | .dma_mode = gmac_dma_operation_mode, | ||
650 | .dma_diagnostic_fr = gmac_dma_diagnostic_fr, | ||
651 | .tx_status = gmac_get_tx_frame_status, | ||
652 | .rx_status = gmac_get_rx_frame_status, | ||
653 | .get_tx_len = gmac_get_tx_len, | ||
654 | .set_filter = gmac_set_filter, | ||
655 | .flow_ctrl = gmac_flow_ctrl, | ||
656 | .pmt = gmac_pmt, | ||
657 | .init_rx_desc = gmac_init_rx_desc, | ||
658 | .init_tx_desc = gmac_init_tx_desc, | ||
659 | .get_tx_owner = gmac_get_tx_owner, | ||
660 | .get_rx_owner = gmac_get_rx_owner, | ||
661 | .release_tx_desc = gmac_release_tx_desc, | ||
662 | .prepare_tx_desc = gmac_prepare_tx_desc, | ||
663 | .clear_tx_ic = gmac_clear_tx_ic, | ||
664 | .close_tx_desc = gmac_close_tx_desc, | ||
665 | .get_tx_ls = gmac_get_tx_ls, | ||
666 | .set_tx_owner = gmac_set_tx_owner, | ||
667 | .set_rx_owner = gmac_set_rx_owner, | ||
668 | .get_rx_frame_len = gmac_get_rx_frame_len, | ||
669 | .host_irq_status = gmac_irq_status, | ||
670 | .set_umac_addr = gmac_set_umac_addr, | ||
671 | .get_umac_addr = gmac_get_umac_addr, | ||
672 | }; | ||
673 | |||
674 | struct mac_device_info *gmac_setup(unsigned long ioaddr) | ||
675 | { | ||
676 | struct mac_device_info *mac; | ||
677 | u32 uid = readl(ioaddr + GMAC_VERSION); | ||
678 | |||
679 | pr_info("\tGMAC - user ID: 0x%x, Synopsys ID: 0x%x\n", | ||
680 | ((uid & 0x0000ff00) >> 8), (uid & 0x000000ff)); | ||
681 | |||
682 | mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL); | ||
683 | |||
684 | mac->ops = &gmac_driver; | ||
685 | mac->hw.pmt = PMT_SUPPORTED; | ||
686 | mac->hw.link.port = GMAC_CONTROL_PS; | ||
687 | mac->hw.link.duplex = GMAC_CONTROL_DM; | ||
688 | mac->hw.link.speed = GMAC_CONTROL_FES; | ||
689 | mac->hw.mii.addr = GMAC_MII_ADDR; | ||
690 | mac->hw.mii.data = GMAC_MII_DATA; | ||
691 | |||
692 | return mac; | ||
693 | } | ||
diff --git a/drivers/net/stmmac/gmac.h b/drivers/net/stmmac/gmac.h new file mode 100644 index 000000000000..684a363120a9 --- /dev/null +++ b/drivers/net/stmmac/gmac.h | |||
@@ -0,0 +1,204 @@ | |||
1 | /******************************************************************************* | ||
2 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify it | ||
5 | under the terms and conditions of the GNU General Public License, | ||
6 | version 2, as published by the Free Software Foundation. | ||
7 | |||
8 | This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | this program; if not, write to the Free Software Foundation, Inc., | ||
15 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
16 | |||
17 | The full GNU General Public License is included in this distribution in | ||
18 | the file called "COPYING". | ||
19 | |||
20 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
21 | *******************************************************************************/ | ||
22 | |||
23 | #define GMAC_CONTROL 0x00000000 /* Configuration */ | ||
24 | #define GMAC_FRAME_FILTER 0x00000004 /* Frame Filter */ | ||
25 | #define GMAC_HASH_HIGH 0x00000008 /* Multicast Hash Table High */ | ||
26 | #define GMAC_HASH_LOW 0x0000000c /* Multicast Hash Table Low */ | ||
27 | #define GMAC_MII_ADDR 0x00000010 /* MII Address */ | ||
28 | #define GMAC_MII_DATA 0x00000014 /* MII Data */ | ||
29 | #define GMAC_FLOW_CTRL 0x00000018 /* Flow Control */ | ||
30 | #define GMAC_VLAN_TAG 0x0000001c /* VLAN Tag */ | ||
31 | #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ | ||
32 | #define GMAC_WAKEUP_FILTER 0x00000028 /* Wake-up Frame Filter */ | ||
33 | |||
34 | #define GMAC_INT_STATUS 0x00000038 /* interrupt status register */ | ||
35 | enum gmac_irq_status { | ||
36 | time_stamp_irq = 0x0200, | ||
37 | mmc_rx_csum_offload_irq = 0x0080, | ||
38 | mmc_tx_irq = 0x0040, | ||
39 | mmc_rx_irq = 0x0020, | ||
40 | mmc_irq = 0x0010, | ||
41 | pmt_irq = 0x0008, | ||
42 | pcs_ane_irq = 0x0004, | ||
43 | pcs_link_irq = 0x0002, | ||
44 | rgmii_irq = 0x0001, | ||
45 | }; | ||
46 | #define GMAC_INT_MASK 0x0000003c /* interrupt mask register */ | ||
47 | |||
48 | /* PMT Control and Status */ | ||
49 | #define GMAC_PMT 0x0000002c | ||
50 | enum power_event { | ||
51 | pointer_reset = 0x80000000, | ||
52 | global_unicast = 0x00000200, | ||
53 | wake_up_rx_frame = 0x00000040, | ||
54 | magic_frame = 0x00000020, | ||
55 | wake_up_frame_en = 0x00000004, | ||
56 | magic_pkt_en = 0x00000002, | ||
57 | power_down = 0x00000001, | ||
58 | }; | ||
59 | |||
60 | /* GMAC HW ADDR regs */ | ||
61 | #define GMAC_ADDR_HIGH(reg) (0x00000040+(reg * 8)) | ||
62 | #define GMAC_ADDR_LOW(reg) (0x00000044+(reg * 8)) | ||
63 | #define GMAC_MAX_UNICAST_ADDRESSES 16 | ||
64 | |||
65 | #define GMAC_AN_CTRL 0x000000c0 /* AN control */ | ||
66 | #define GMAC_AN_STATUS 0x000000c4 /* AN status */ | ||
67 | #define GMAC_ANE_ADV 0x000000c8 /* Auto-Neg. Advertisement */ | ||
68 | #define GMAC_ANE_LINK 0x000000cc /* Auto-Neg. link partener ability */ | ||
69 | #define GMAC_ANE_EXP 0x000000d0 /* ANE expansion */ | ||
70 | #define GMAC_TBI 0x000000d4 /* TBI extend status */ | ||
71 | #define GMAC_GMII_STATUS 0x000000d8 /* S/R-GMII status */ | ||
72 | |||
73 | /* GMAC Configuration defines */ | ||
74 | #define GMAC_CONTROL_TC 0x01000000 /* Transmit Conf. in RGMII/SGMII */ | ||
75 | #define GMAC_CONTROL_WD 0x00800000 /* Disable Watchdog on receive */ | ||
76 | #define GMAC_CONTROL_JD 0x00400000 /* Jabber disable */ | ||
77 | #define GMAC_CONTROL_BE 0x00200000 /* Frame Burst Enable */ | ||
78 | #define GMAC_CONTROL_JE 0x00100000 /* Jumbo frame */ | ||
79 | enum inter_frame_gap { | ||
80 | GMAC_CONTROL_IFG_88 = 0x00040000, | ||
81 | GMAC_CONTROL_IFG_80 = 0x00020000, | ||
82 | GMAC_CONTROL_IFG_40 = 0x000e0000, | ||
83 | }; | ||
84 | #define GMAC_CONTROL_DCRS 0x00010000 /* Disable carrier sense during tx */ | ||
85 | #define GMAC_CONTROL_PS 0x00008000 /* Port Select 0:GMI 1:MII */ | ||
86 | #define GMAC_CONTROL_FES 0x00004000 /* Speed 0:10 1:100 */ | ||
87 | #define GMAC_CONTROL_DO 0x00002000 /* Disable Rx Own */ | ||
88 | #define GMAC_CONTROL_LM 0x00001000 /* Loop-back mode */ | ||
89 | #define GMAC_CONTROL_DM 0x00000800 /* Duplex Mode */ | ||
90 | #define GMAC_CONTROL_IPC 0x00000400 /* Checksum Offload */ | ||
91 | #define GMAC_CONTROL_DR 0x00000200 /* Disable Retry */ | ||
92 | #define GMAC_CONTROL_LUD 0x00000100 /* Link up/down */ | ||
93 | #define GMAC_CONTROL_ACS 0x00000080 /* Automatic Pad Stripping */ | ||
94 | #define GMAC_CONTROL_DC 0x00000010 /* Deferral Check */ | ||
95 | #define GMAC_CONTROL_TE 0x00000008 /* Transmitter Enable */ | ||
96 | #define GMAC_CONTROL_RE 0x00000004 /* Receiver Enable */ | ||
97 | |||
98 | #define GMAC_CORE_INIT (GMAC_CONTROL_JD | GMAC_CONTROL_PS | GMAC_CONTROL_ACS | \ | ||
99 | GMAC_CONTROL_IPC | GMAC_CONTROL_JE | GMAC_CONTROL_BE) | ||
100 | |||
101 | /* GMAC Frame Filter defines */ | ||
102 | #define GMAC_FRAME_FILTER_PR 0x00000001 /* Promiscuous Mode */ | ||
103 | #define GMAC_FRAME_FILTER_HUC 0x00000002 /* Hash Unicast */ | ||
104 | #define GMAC_FRAME_FILTER_HMC 0x00000004 /* Hash Multicast */ | ||
105 | #define GMAC_FRAME_FILTER_DAIF 0x00000008 /* DA Inverse Filtering */ | ||
106 | #define GMAC_FRAME_FILTER_PM 0x00000010 /* Pass all multicast */ | ||
107 | #define GMAC_FRAME_FILTER_DBF 0x00000020 /* Disable Broadcast frames */ | ||
108 | #define GMAC_FRAME_FILTER_SAIF 0x00000100 /* Inverse Filtering */ | ||
109 | #define GMAC_FRAME_FILTER_SAF 0x00000200 /* Source Address Filter */ | ||
110 | #define GMAC_FRAME_FILTER_HPF 0x00000400 /* Hash or perfect Filter */ | ||
111 | #define GMAC_FRAME_FILTER_RA 0x80000000 /* Receive all mode */ | ||
112 | /* GMII ADDR defines */ | ||
113 | #define GMAC_MII_ADDR_WRITE 0x00000002 /* MII Write */ | ||
114 | #define GMAC_MII_ADDR_BUSY 0x00000001 /* MII Busy */ | ||
115 | /* GMAC FLOW CTRL defines */ | ||
116 | #define GMAC_FLOW_CTRL_PT_MASK 0xffff0000 /* Pause Time Mask */ | ||
117 | #define GMAC_FLOW_CTRL_PT_SHIFT 16 | ||
118 | #define GMAC_FLOW_CTRL_RFE 0x00000004 /* Rx Flow Control Enable */ | ||
119 | #define GMAC_FLOW_CTRL_TFE 0x00000002 /* Tx Flow Control Enable */ | ||
120 | #define GMAC_FLOW_CTRL_FCB_BPA 0x00000001 /* Flow Control Busy ... */ | ||
121 | |||
122 | /*--- DMA BLOCK defines ---*/ | ||
123 | /* DMA Bus Mode register defines */ | ||
124 | #define DMA_BUS_MODE_SFT_RESET 0x00000001 /* Software Reset */ | ||
125 | #define DMA_BUS_MODE_DA 0x00000002 /* Arbitration scheme */ | ||
126 | #define DMA_BUS_MODE_DSL_MASK 0x0000007c /* Descriptor Skip Length */ | ||
127 | #define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */ | ||
128 | /* Programmable burst length (passed thorugh platform)*/ | ||
129 | #define DMA_BUS_MODE_PBL_MASK 0x00003f00 /* Programmable Burst Len */ | ||
130 | #define DMA_BUS_MODE_PBL_SHIFT 8 | ||
131 | |||
132 | enum rx_tx_priority_ratio { | ||
133 | double_ratio = 0x00004000, /*2:1 */ | ||
134 | triple_ratio = 0x00008000, /*3:1 */ | ||
135 | quadruple_ratio = 0x0000c000, /*4:1 */ | ||
136 | }; | ||
137 | |||
138 | #define DMA_BUS_MODE_FB 0x00010000 /* Fixed burst */ | ||
139 | #define DMA_BUS_MODE_RPBL_MASK 0x003e0000 /* Rx-Programmable Burst Len */ | ||
140 | #define DMA_BUS_MODE_RPBL_SHIFT 17 | ||
141 | #define DMA_BUS_MODE_USP 0x00800000 | ||
142 | #define DMA_BUS_MODE_4PBL 0x01000000 | ||
143 | #define DMA_BUS_MODE_AAL 0x02000000 | ||
144 | |||
145 | /* DMA CRS Control and Status Register Mapping */ | ||
146 | #define DMA_HOST_TX_DESC 0x00001048 /* Current Host Tx descriptor */ | ||
147 | #define DMA_HOST_RX_DESC 0x0000104c /* Current Host Rx descriptor */ | ||
148 | /* DMA Bus Mode register defines */ | ||
149 | #define DMA_BUS_PR_RATIO_MASK 0x0000c000 /* Rx/Tx priority ratio */ | ||
150 | #define DMA_BUS_PR_RATIO_SHIFT 14 | ||
151 | #define DMA_BUS_FB 0x00010000 /* Fixed Burst */ | ||
152 | |||
153 | /* DMA operation mode defines (start/stop tx/rx are placed in common header)*/ | ||
154 | #define DMA_CONTROL_DT 0x04000000 /* Disable Drop TCP/IP csum error */ | ||
155 | #define DMA_CONTROL_RSF 0x02000000 /* Receive Store and Forward */ | ||
156 | #define DMA_CONTROL_DFF 0x01000000 /* Disaable flushing */ | ||
157 | /* Theshold for Activating the FC */ | ||
158 | enum rfa { | ||
159 | act_full_minus_1 = 0x00800000, | ||
160 | act_full_minus_2 = 0x00800200, | ||
161 | act_full_minus_3 = 0x00800400, | ||
162 | act_full_minus_4 = 0x00800600, | ||
163 | }; | ||
164 | /* Theshold for Deactivating the FC */ | ||
165 | enum rfd { | ||
166 | deac_full_minus_1 = 0x00400000, | ||
167 | deac_full_minus_2 = 0x00400800, | ||
168 | deac_full_minus_3 = 0x00401000, | ||
169 | deac_full_minus_4 = 0x00401800, | ||
170 | }; | ||
171 | #define DMA_CONTROL_TSF 0x00200000 /* Transmit Store and Forward */ | ||
172 | #define DMA_CONTROL_FTF 0x00100000 /* Flush transmit FIFO */ | ||
173 | |||
174 | enum ttc_control { | ||
175 | DMA_CONTROL_TTC_64 = 0x00000000, | ||
176 | DMA_CONTROL_TTC_128 = 0x00004000, | ||
177 | DMA_CONTROL_TTC_192 = 0x00008000, | ||
178 | DMA_CONTROL_TTC_256 = 0x0000c000, | ||
179 | DMA_CONTROL_TTC_40 = 0x00010000, | ||
180 | DMA_CONTROL_TTC_32 = 0x00014000, | ||
181 | DMA_CONTROL_TTC_24 = 0x00018000, | ||
182 | DMA_CONTROL_TTC_16 = 0x0001c000, | ||
183 | }; | ||
184 | #define DMA_CONTROL_TC_TX_MASK 0xfffe3fff | ||
185 | |||
186 | #define DMA_CONTROL_EFC 0x00000100 | ||
187 | #define DMA_CONTROL_FEF 0x00000080 | ||
188 | #define DMA_CONTROL_FUF 0x00000040 | ||
189 | |||
190 | enum rtc_control { | ||
191 | DMA_CONTROL_RTC_64 = 0x00000000, | ||
192 | DMA_CONTROL_RTC_32 = 0x00000008, | ||
193 | DMA_CONTROL_RTC_96 = 0x00000010, | ||
194 | DMA_CONTROL_RTC_128 = 0x00000018, | ||
195 | }; | ||
196 | #define DMA_CONTROL_TC_RX_MASK 0xffffffe7 | ||
197 | |||
198 | #define DMA_CONTROL_OSF 0x00000004 /* Operate on second frame */ | ||
199 | |||
200 | /* MMC registers offset */ | ||
201 | #define GMAC_MMC_CTRL 0x100 | ||
202 | #define GMAC_MMC_RX_INTR 0x104 | ||
203 | #define GMAC_MMC_TX_INTR 0x108 | ||
204 | #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208 | ||
diff --git a/drivers/net/stmmac/mac100.c b/drivers/net/stmmac/mac100.c new file mode 100644 index 000000000000..625171b6062b --- /dev/null +++ b/drivers/net/stmmac/mac100.c | |||
@@ -0,0 +1,517 @@ | |||
1 | /******************************************************************************* | ||
2 | This is the driver for the MAC 10/100 on-chip Ethernet controller | ||
3 | currently tested on all the ST boards based on STb7109 and stx7200 SoCs. | ||
4 | |||
5 | DWC Ether MAC 10/100 Universal version 4.0 has been used for developing | ||
6 | this code. | ||
7 | |||
8 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify it | ||
11 | under the terms and conditions of the GNU General Public License, | ||
12 | version 2, as published by the Free Software Foundation. | ||
13 | |||
14 | This program is distributed in the hope it will be useful, but WITHOUT | ||
15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
16 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
17 | more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License along with | ||
20 | this program; if not, write to the Free Software Foundation, Inc., | ||
21 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
22 | |||
23 | The full GNU General Public License is included in this distribution in | ||
24 | the file called "COPYING". | ||
25 | |||
26 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
27 | *******************************************************************************/ | ||
28 | |||
29 | #include <linux/netdevice.h> | ||
30 | #include <linux/crc32.h> | ||
31 | #include <linux/mii.h> | ||
32 | #include <linux/phy.h> | ||
33 | |||
34 | #include "common.h" | ||
35 | #include "mac100.h" | ||
36 | |||
37 | #undef MAC100_DEBUG | ||
38 | /*#define MAC100_DEBUG*/ | ||
39 | #ifdef MAC100_DEBUG | ||
40 | #define DBG(fmt, args...) printk(fmt, ## args) | ||
41 | #else | ||
42 | #define DBG(fmt, args...) do { } while (0) | ||
43 | #endif | ||
44 | |||
45 | static void mac100_core_init(unsigned long ioaddr) | ||
46 | { | ||
47 | u32 value = readl(ioaddr + MAC_CONTROL); | ||
48 | |||
49 | writel((value | MAC_CORE_INIT), ioaddr + MAC_CONTROL); | ||
50 | |||
51 | #ifdef STMMAC_VLAN_TAG_USED | ||
52 | writel(ETH_P_8021Q, ioaddr + MAC_VLAN1); | ||
53 | #endif | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | static void mac100_dump_mac_regs(unsigned long ioaddr) | ||
58 | { | ||
59 | pr_info("\t----------------------------------------------\n" | ||
60 | "\t MAC100 CSR (base addr = 0x%8x)\n" | ||
61 | "\t----------------------------------------------\n", | ||
62 | (unsigned int)ioaddr); | ||
63 | pr_info("\tcontrol reg (offset 0x%x): 0x%08x\n", MAC_CONTROL, | ||
64 | readl(ioaddr + MAC_CONTROL)); | ||
65 | pr_info("\taddr HI (offset 0x%x): 0x%08x\n ", MAC_ADDR_HIGH, | ||
66 | readl(ioaddr + MAC_ADDR_HIGH)); | ||
67 | pr_info("\taddr LO (offset 0x%x): 0x%08x\n", MAC_ADDR_LOW, | ||
68 | readl(ioaddr + MAC_ADDR_LOW)); | ||
69 | pr_info("\tmulticast hash HI (offset 0x%x): 0x%08x\n", | ||
70 | MAC_HASH_HIGH, readl(ioaddr + MAC_HASH_HIGH)); | ||
71 | pr_info("\tmulticast hash LO (offset 0x%x): 0x%08x\n", | ||
72 | MAC_HASH_LOW, readl(ioaddr + MAC_HASH_LOW)); | ||
73 | pr_info("\tflow control (offset 0x%x): 0x%08x\n", | ||
74 | MAC_FLOW_CTRL, readl(ioaddr + MAC_FLOW_CTRL)); | ||
75 | pr_info("\tVLAN1 tag (offset 0x%x): 0x%08x\n", MAC_VLAN1, | ||
76 | readl(ioaddr + MAC_VLAN1)); | ||
77 | pr_info("\tVLAN2 tag (offset 0x%x): 0x%08x\n", MAC_VLAN2, | ||
78 | readl(ioaddr + MAC_VLAN2)); | ||
79 | pr_info("\n\tMAC management counter registers\n"); | ||
80 | pr_info("\t MMC crtl (offset 0x%x): 0x%08x\n", | ||
81 | MMC_CONTROL, readl(ioaddr + MMC_CONTROL)); | ||
82 | pr_info("\t MMC High Interrupt (offset 0x%x): 0x%08x\n", | ||
83 | MMC_HIGH_INTR, readl(ioaddr + MMC_HIGH_INTR)); | ||
84 | pr_info("\t MMC Low Interrupt (offset 0x%x): 0x%08x\n", | ||
85 | MMC_LOW_INTR, readl(ioaddr + MMC_LOW_INTR)); | ||
86 | pr_info("\t MMC High Interrupt Mask (offset 0x%x): 0x%08x\n", | ||
87 | MMC_HIGH_INTR_MASK, readl(ioaddr + MMC_HIGH_INTR_MASK)); | ||
88 | pr_info("\t MMC Low Interrupt Mask (offset 0x%x): 0x%08x\n", | ||
89 | MMC_LOW_INTR_MASK, readl(ioaddr + MMC_LOW_INTR_MASK)); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | static int mac100_dma_init(unsigned long ioaddr, int pbl, u32 dma_tx, | ||
94 | u32 dma_rx) | ||
95 | { | ||
96 | u32 value = readl(ioaddr + DMA_BUS_MODE); | ||
97 | /* DMA SW reset */ | ||
98 | value |= DMA_BUS_MODE_SFT_RESET; | ||
99 | writel(value, ioaddr + DMA_BUS_MODE); | ||
100 | do {} while ((readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)); | ||
101 | |||
102 | /* Enable Application Access by writing to DMA CSR0 */ | ||
103 | writel(DMA_BUS_MODE_DEFAULT | (pbl << DMA_BUS_MODE_PBL_SHIFT), | ||
104 | ioaddr + DMA_BUS_MODE); | ||
105 | |||
106 | /* Mask interrupts by writing to CSR7 */ | ||
107 | writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA); | ||
108 | |||
109 | /* The base address of the RX/TX descriptor lists must be written into | ||
110 | * DMA CSR3 and CSR4, respectively. */ | ||
111 | writel(dma_tx, ioaddr + DMA_TX_BASE_ADDR); | ||
112 | writel(dma_rx, ioaddr + DMA_RCV_BASE_ADDR); | ||
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | /* Store and Forward capability is not used at all.. | ||
118 | * The transmit threshold can be programmed by | ||
119 | * setting the TTC bits in the DMA control register.*/ | ||
120 | static void mac100_dma_operation_mode(unsigned long ioaddr, int txmode, | ||
121 | int rxmode) | ||
122 | { | ||
123 | u32 csr6 = readl(ioaddr + DMA_CONTROL); | ||
124 | |||
125 | if (txmode <= 32) | ||
126 | csr6 |= DMA_CONTROL_TTC_32; | ||
127 | else if (txmode <= 64) | ||
128 | csr6 |= DMA_CONTROL_TTC_64; | ||
129 | else | ||
130 | csr6 |= DMA_CONTROL_TTC_128; | ||
131 | |||
132 | writel(csr6, ioaddr + DMA_CONTROL); | ||
133 | |||
134 | return; | ||
135 | } | ||
136 | |||
137 | static void mac100_dump_dma_regs(unsigned long ioaddr) | ||
138 | { | ||
139 | int i; | ||
140 | |||
141 | DBG(KERN_DEBUG "MAC100 DMA CSR \n"); | ||
142 | for (i = 0; i < 9; i++) | ||
143 | pr_debug("\t CSR%d (offset 0x%x): 0x%08x\n", i, | ||
144 | (DMA_BUS_MODE + i * 4), | ||
145 | readl(ioaddr + DMA_BUS_MODE + i * 4)); | ||
146 | DBG(KERN_DEBUG "\t CSR20 (offset 0x%x): 0x%08x\n", | ||
147 | DMA_CUR_TX_BUF_ADDR, readl(ioaddr + DMA_CUR_TX_BUF_ADDR)); | ||
148 | DBG(KERN_DEBUG "\t CSR21 (offset 0x%x): 0x%08x\n", | ||
149 | DMA_CUR_RX_BUF_ADDR, readl(ioaddr + DMA_CUR_RX_BUF_ADDR)); | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | /* DMA controller has two counters to track the number of | ||
154 | the receive missed frames. */ | ||
155 | static void mac100_dma_diagnostic_fr(void *data, struct stmmac_extra_stats *x, | ||
156 | unsigned long ioaddr) | ||
157 | { | ||
158 | struct net_device_stats *stats = (struct net_device_stats *)data; | ||
159 | u32 csr8 = readl(ioaddr + DMA_MISSED_FRAME_CTR); | ||
160 | |||
161 | if (unlikely(csr8)) { | ||
162 | if (csr8 & DMA_MISSED_FRAME_OVE) { | ||
163 | stats->rx_over_errors += 0x800; | ||
164 | x->rx_overflow_cntr += 0x800; | ||
165 | } else { | ||
166 | unsigned int ove_cntr; | ||
167 | ove_cntr = ((csr8 & DMA_MISSED_FRAME_OVE_CNTR) >> 17); | ||
168 | stats->rx_over_errors += ove_cntr; | ||
169 | x->rx_overflow_cntr += ove_cntr; | ||
170 | } | ||
171 | |||
172 | if (csr8 & DMA_MISSED_FRAME_OVE_M) { | ||
173 | stats->rx_missed_errors += 0xffff; | ||
174 | x->rx_missed_cntr += 0xffff; | ||
175 | } else { | ||
176 | unsigned int miss_f = (csr8 & DMA_MISSED_FRAME_M_CNTR); | ||
177 | stats->rx_missed_errors += miss_f; | ||
178 | x->rx_missed_cntr += miss_f; | ||
179 | } | ||
180 | } | ||
181 | return; | ||
182 | } | ||
183 | |||
184 | static int mac100_get_tx_frame_status(void *data, struct stmmac_extra_stats *x, | ||
185 | struct dma_desc *p, unsigned long ioaddr) | ||
186 | { | ||
187 | int ret = 0; | ||
188 | struct net_device_stats *stats = (struct net_device_stats *)data; | ||
189 | |||
190 | if (unlikely(p->des01.tx.error_summary)) { | ||
191 | if (unlikely(p->des01.tx.underflow_error)) { | ||
192 | x->tx_underflow++; | ||
193 | stats->tx_fifo_errors++; | ||
194 | } | ||
195 | if (unlikely(p->des01.tx.no_carrier)) { | ||
196 | x->tx_carrier++; | ||
197 | stats->tx_carrier_errors++; | ||
198 | } | ||
199 | if (unlikely(p->des01.tx.loss_carrier)) { | ||
200 | x->tx_losscarrier++; | ||
201 | stats->tx_carrier_errors++; | ||
202 | } | ||
203 | if (unlikely((p->des01.tx.excessive_deferral) || | ||
204 | (p->des01.tx.excessive_collisions) || | ||
205 | (p->des01.tx.late_collision))) | ||
206 | stats->collisions += p->des01.tx.collision_count; | ||
207 | ret = -1; | ||
208 | } | ||
209 | if (unlikely(p->des01.tx.heartbeat_fail)) { | ||
210 | x->tx_heartbeat++; | ||
211 | stats->tx_heartbeat_errors++; | ||
212 | ret = -1; | ||
213 | } | ||
214 | if (unlikely(p->des01.tx.deferred)) | ||
215 | x->tx_deferred++; | ||
216 | |||
217 | return ret; | ||
218 | } | ||
219 | |||
220 | static int mac100_get_tx_len(struct dma_desc *p) | ||
221 | { | ||
222 | return p->des01.tx.buffer1_size; | ||
223 | } | ||
224 | |||
225 | /* This function verifies if each incoming frame has some errors | ||
226 | * and, if required, updates the multicast statistics. | ||
227 | * In case of success, it returns csum_none becasue the device | ||
228 | * is not able to compute the csum in HW. */ | ||
229 | static int mac100_get_rx_frame_status(void *data, struct stmmac_extra_stats *x, | ||
230 | struct dma_desc *p) | ||
231 | { | ||
232 | int ret = csum_none; | ||
233 | struct net_device_stats *stats = (struct net_device_stats *)data; | ||
234 | |||
235 | if (unlikely(p->des01.rx.last_descriptor == 0)) { | ||
236 | pr_warning("mac100 Error: Oversized Ethernet " | ||
237 | "frame spanned multiple buffers\n"); | ||
238 | stats->rx_length_errors++; | ||
239 | return discard_frame; | ||
240 | } | ||
241 | |||
242 | if (unlikely(p->des01.rx.error_summary)) { | ||
243 | if (unlikely(p->des01.rx.descriptor_error)) | ||
244 | x->rx_desc++; | ||
245 | if (unlikely(p->des01.rx.partial_frame_error)) | ||
246 | x->rx_partial++; | ||
247 | if (unlikely(p->des01.rx.run_frame)) | ||
248 | x->rx_runt++; | ||
249 | if (unlikely(p->des01.rx.frame_too_long)) | ||
250 | x->rx_toolong++; | ||
251 | if (unlikely(p->des01.rx.collision)) { | ||
252 | x->rx_collision++; | ||
253 | stats->collisions++; | ||
254 | } | ||
255 | if (unlikely(p->des01.rx.crc_error)) { | ||
256 | x->rx_crc++; | ||
257 | stats->rx_crc_errors++; | ||
258 | } | ||
259 | ret = discard_frame; | ||
260 | } | ||
261 | if (unlikely(p->des01.rx.dribbling)) | ||
262 | ret = discard_frame; | ||
263 | |||
264 | if (unlikely(p->des01.rx.length_error)) { | ||
265 | x->rx_lenght++; | ||
266 | ret = discard_frame; | ||
267 | } | ||
268 | if (unlikely(p->des01.rx.mii_error)) { | ||
269 | x->rx_mii++; | ||
270 | ret = discard_frame; | ||
271 | } | ||
272 | if (p->des01.rx.multicast_frame) { | ||
273 | x->rx_multicast++; | ||
274 | stats->multicast++; | ||
275 | } | ||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | static void mac100_irq_status(unsigned long ioaddr) | ||
280 | { | ||
281 | return; | ||
282 | } | ||
283 | |||
284 | static void mac100_set_umac_addr(unsigned long ioaddr, unsigned char *addr, | ||
285 | unsigned int reg_n) | ||
286 | { | ||
287 | stmmac_set_mac_addr(ioaddr, addr, MAC_ADDR_HIGH, MAC_ADDR_LOW); | ||
288 | } | ||
289 | |||
290 | static void mac100_get_umac_addr(unsigned long ioaddr, unsigned char *addr, | ||
291 | unsigned int reg_n) | ||
292 | { | ||
293 | stmmac_get_mac_addr(ioaddr, addr, MAC_ADDR_HIGH, MAC_ADDR_LOW); | ||
294 | } | ||
295 | |||
296 | static void mac100_set_filter(struct net_device *dev) | ||
297 | { | ||
298 | unsigned long ioaddr = dev->base_addr; | ||
299 | u32 value = readl(ioaddr + MAC_CONTROL); | ||
300 | |||
301 | if (dev->flags & IFF_PROMISC) { | ||
302 | value |= MAC_CONTROL_PR; | ||
303 | value &= ~(MAC_CONTROL_PM | MAC_CONTROL_IF | MAC_CONTROL_HO | | ||
304 | MAC_CONTROL_HP); | ||
305 | } else if ((dev->mc_count > HASH_TABLE_SIZE) | ||
306 | || (dev->flags & IFF_ALLMULTI)) { | ||
307 | value |= MAC_CONTROL_PM; | ||
308 | value &= ~(MAC_CONTROL_PR | MAC_CONTROL_IF | MAC_CONTROL_HO); | ||
309 | writel(0xffffffff, ioaddr + MAC_HASH_HIGH); | ||
310 | writel(0xffffffff, ioaddr + MAC_HASH_LOW); | ||
311 | } else if (dev->mc_count == 0) { /* no multicast */ | ||
312 | value &= ~(MAC_CONTROL_PM | MAC_CONTROL_PR | MAC_CONTROL_IF | | ||
313 | MAC_CONTROL_HO | MAC_CONTROL_HP); | ||
314 | } else { | ||
315 | int i; | ||
316 | u32 mc_filter[2]; | ||
317 | struct dev_mc_list *mclist; | ||
318 | |||
319 | /* Perfect filter mode for physical address and Hash | ||
320 | filter for multicast */ | ||
321 | value |= MAC_CONTROL_HP; | ||
322 | value &= ~(MAC_CONTROL_PM | MAC_CONTROL_PR | MAC_CONTROL_IF | ||
323 | | MAC_CONTROL_HO); | ||
324 | |||
325 | memset(mc_filter, 0, sizeof(mc_filter)); | ||
326 | for (i = 0, mclist = dev->mc_list; | ||
327 | mclist && i < dev->mc_count; i++, mclist = mclist->next) { | ||
328 | /* The upper 6 bits of the calculated CRC are used to | ||
329 | * index the contens of the hash table */ | ||
330 | int bit_nr = | ||
331 | ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; | ||
332 | /* The most significant bit determines the register to | ||
333 | * use (H/L) while the other 5 bits determine the bit | ||
334 | * within the register. */ | ||
335 | mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); | ||
336 | } | ||
337 | writel(mc_filter[0], ioaddr + MAC_HASH_LOW); | ||
338 | writel(mc_filter[1], ioaddr + MAC_HASH_HIGH); | ||
339 | } | ||
340 | |||
341 | writel(value, ioaddr + MAC_CONTROL); | ||
342 | |||
343 | DBG(KERN_INFO "%s: CTRL reg: 0x%08x Hash regs: " | ||
344 | "HI 0x%08x, LO 0x%08x\n", | ||
345 | __func__, readl(ioaddr + MAC_CONTROL), | ||
346 | readl(ioaddr + MAC_HASH_HIGH), readl(ioaddr + MAC_HASH_LOW)); | ||
347 | return; | ||
348 | } | ||
349 | |||
350 | static void mac100_flow_ctrl(unsigned long ioaddr, unsigned int duplex, | ||
351 | unsigned int fc, unsigned int pause_time) | ||
352 | { | ||
353 | unsigned int flow = MAC_FLOW_CTRL_ENABLE; | ||
354 | |||
355 | if (duplex) | ||
356 | flow |= (pause_time << MAC_FLOW_CTRL_PT_SHIFT); | ||
357 | writel(flow, ioaddr + MAC_FLOW_CTRL); | ||
358 | |||
359 | return; | ||
360 | } | ||
361 | |||
362 | /* No PMT module supported in our SoC for the Ethernet Controller. */ | ||
363 | static void mac100_pmt(unsigned long ioaddr, unsigned long mode) | ||
364 | { | ||
365 | return; | ||
366 | } | ||
367 | |||
368 | static void mac100_init_rx_desc(struct dma_desc *p, unsigned int ring_size, | ||
369 | int disable_rx_ic) | ||
370 | { | ||
371 | int i; | ||
372 | for (i = 0; i < ring_size; i++) { | ||
373 | p->des01.rx.own = 1; | ||
374 | p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1; | ||
375 | if (i == ring_size - 1) | ||
376 | p->des01.rx.end_ring = 1; | ||
377 | if (disable_rx_ic) | ||
378 | p->des01.rx.disable_ic = 1; | ||
379 | p++; | ||
380 | } | ||
381 | return; | ||
382 | } | ||
383 | |||
384 | static void mac100_init_tx_desc(struct dma_desc *p, unsigned int ring_size) | ||
385 | { | ||
386 | int i; | ||
387 | for (i = 0; i < ring_size; i++) { | ||
388 | p->des01.tx.own = 0; | ||
389 | if (i == ring_size - 1) | ||
390 | p->des01.tx.end_ring = 1; | ||
391 | p++; | ||
392 | } | ||
393 | return; | ||
394 | } | ||
395 | |||
396 | static int mac100_get_tx_owner(struct dma_desc *p) | ||
397 | { | ||
398 | return p->des01.tx.own; | ||
399 | } | ||
400 | |||
401 | static int mac100_get_rx_owner(struct dma_desc *p) | ||
402 | { | ||
403 | return p->des01.rx.own; | ||
404 | } | ||
405 | |||
406 | static void mac100_set_tx_owner(struct dma_desc *p) | ||
407 | { | ||
408 | p->des01.tx.own = 1; | ||
409 | } | ||
410 | |||
411 | static void mac100_set_rx_owner(struct dma_desc *p) | ||
412 | { | ||
413 | p->des01.rx.own = 1; | ||
414 | } | ||
415 | |||
416 | static int mac100_get_tx_ls(struct dma_desc *p) | ||
417 | { | ||
418 | return p->des01.tx.last_segment; | ||
419 | } | ||
420 | |||
421 | static void mac100_release_tx_desc(struct dma_desc *p) | ||
422 | { | ||
423 | int ter = p->des01.tx.end_ring; | ||
424 | |||
425 | /* clean field used within the xmit */ | ||
426 | p->des01.tx.first_segment = 0; | ||
427 | p->des01.tx.last_segment = 0; | ||
428 | p->des01.tx.buffer1_size = 0; | ||
429 | |||
430 | /* clean status reported */ | ||
431 | p->des01.tx.error_summary = 0; | ||
432 | p->des01.tx.underflow_error = 0; | ||
433 | p->des01.tx.no_carrier = 0; | ||
434 | p->des01.tx.loss_carrier = 0; | ||
435 | p->des01.tx.excessive_deferral = 0; | ||
436 | p->des01.tx.excessive_collisions = 0; | ||
437 | p->des01.tx.late_collision = 0; | ||
438 | p->des01.tx.heartbeat_fail = 0; | ||
439 | p->des01.tx.deferred = 0; | ||
440 | |||
441 | /* set termination field */ | ||
442 | p->des01.tx.end_ring = ter; | ||
443 | |||
444 | return; | ||
445 | } | ||
446 | |||
447 | static void mac100_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, | ||
448 | int csum_flag) | ||
449 | { | ||
450 | p->des01.tx.first_segment = is_fs; | ||
451 | p->des01.tx.buffer1_size = len; | ||
452 | } | ||
453 | |||
454 | static void mac100_clear_tx_ic(struct dma_desc *p) | ||
455 | { | ||
456 | p->des01.tx.interrupt = 0; | ||
457 | } | ||
458 | |||
459 | static void mac100_close_tx_desc(struct dma_desc *p) | ||
460 | { | ||
461 | p->des01.tx.last_segment = 1; | ||
462 | p->des01.tx.interrupt = 1; | ||
463 | } | ||
464 | |||
465 | static int mac100_get_rx_frame_len(struct dma_desc *p) | ||
466 | { | ||
467 | return p->des01.rx.frame_length; | ||
468 | } | ||
469 | |||
470 | struct stmmac_ops mac100_driver = { | ||
471 | .core_init = mac100_core_init, | ||
472 | .dump_mac_regs = mac100_dump_mac_regs, | ||
473 | .dma_init = mac100_dma_init, | ||
474 | .dump_dma_regs = mac100_dump_dma_regs, | ||
475 | .dma_mode = mac100_dma_operation_mode, | ||
476 | .dma_diagnostic_fr = mac100_dma_diagnostic_fr, | ||
477 | .tx_status = mac100_get_tx_frame_status, | ||
478 | .rx_status = mac100_get_rx_frame_status, | ||
479 | .get_tx_len = mac100_get_tx_len, | ||
480 | .set_filter = mac100_set_filter, | ||
481 | .flow_ctrl = mac100_flow_ctrl, | ||
482 | .pmt = mac100_pmt, | ||
483 | .init_rx_desc = mac100_init_rx_desc, | ||
484 | .init_tx_desc = mac100_init_tx_desc, | ||
485 | .get_tx_owner = mac100_get_tx_owner, | ||
486 | .get_rx_owner = mac100_get_rx_owner, | ||
487 | .release_tx_desc = mac100_release_tx_desc, | ||
488 | .prepare_tx_desc = mac100_prepare_tx_desc, | ||
489 | .clear_tx_ic = mac100_clear_tx_ic, | ||
490 | .close_tx_desc = mac100_close_tx_desc, | ||
491 | .get_tx_ls = mac100_get_tx_ls, | ||
492 | .set_tx_owner = mac100_set_tx_owner, | ||
493 | .set_rx_owner = mac100_set_rx_owner, | ||
494 | .get_rx_frame_len = mac100_get_rx_frame_len, | ||
495 | .host_irq_status = mac100_irq_status, | ||
496 | .set_umac_addr = mac100_set_umac_addr, | ||
497 | .get_umac_addr = mac100_get_umac_addr, | ||
498 | }; | ||
499 | |||
500 | struct mac_device_info *mac100_setup(unsigned long ioaddr) | ||
501 | { | ||
502 | struct mac_device_info *mac; | ||
503 | |||
504 | mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL); | ||
505 | |||
506 | pr_info("\tMAC 10/100\n"); | ||
507 | |||
508 | mac->ops = &mac100_driver; | ||
509 | mac->hw.pmt = PMT_NOT_SUPPORTED; | ||
510 | mac->hw.link.port = MAC_CONTROL_PS; | ||
511 | mac->hw.link.duplex = MAC_CONTROL_F; | ||
512 | mac->hw.link.speed = 0; | ||
513 | mac->hw.mii.addr = MAC_MII_ADDR; | ||
514 | mac->hw.mii.data = MAC_MII_DATA; | ||
515 | |||
516 | return mac; | ||
517 | } | ||
diff --git a/drivers/net/stmmac/mac100.h b/drivers/net/stmmac/mac100.h new file mode 100644 index 000000000000..0f8f110d004a --- /dev/null +++ b/drivers/net/stmmac/mac100.h | |||
@@ -0,0 +1,116 @@ | |||
1 | /******************************************************************************* | ||
2 | MAC 10/100 Header File | ||
3 | |||
4 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms and conditions of the GNU General Public License, | ||
8 | version 2, as published by the Free Software Foundation. | ||
9 | |||
10 | This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License along with | ||
16 | this program; if not, write to the Free Software Foundation, Inc., | ||
17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | The full GNU General Public License is included in this distribution in | ||
20 | the file called "COPYING". | ||
21 | |||
22 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
23 | *******************************************************************************/ | ||
24 | |||
25 | /*---------------------------------------------------------------------------- | ||
26 | * MAC BLOCK defines | ||
27 | *---------------------------------------------------------------------------*/ | ||
28 | /* MAC CSR offset */ | ||
29 | #define MAC_CONTROL 0x00000000 /* MAC Control */ | ||
30 | #define MAC_ADDR_HIGH 0x00000004 /* MAC Address High */ | ||
31 | #define MAC_ADDR_LOW 0x00000008 /* MAC Address Low */ | ||
32 | #define MAC_HASH_HIGH 0x0000000c /* Multicast Hash Table High */ | ||
33 | #define MAC_HASH_LOW 0x00000010 /* Multicast Hash Table Low */ | ||
34 | #define MAC_MII_ADDR 0x00000014 /* MII Address */ | ||
35 | #define MAC_MII_DATA 0x00000018 /* MII Data */ | ||
36 | #define MAC_FLOW_CTRL 0x0000001c /* Flow Control */ | ||
37 | #define MAC_VLAN1 0x00000020 /* VLAN1 Tag */ | ||
38 | #define MAC_VLAN2 0x00000024 /* VLAN2 Tag */ | ||
39 | |||
40 | /* MAC CTRL defines */ | ||
41 | #define MAC_CONTROL_RA 0x80000000 /* Receive All Mode */ | ||
42 | #define MAC_CONTROL_BLE 0x40000000 /* Endian Mode */ | ||
43 | #define MAC_CONTROL_HBD 0x10000000 /* Heartbeat Disable */ | ||
44 | #define MAC_CONTROL_PS 0x08000000 /* Port Select */ | ||
45 | #define MAC_CONTROL_DRO 0x00800000 /* Disable Receive Own */ | ||
46 | #define MAC_CONTROL_EXT_LOOPBACK 0x00400000 /* Reserved (ext loopback?) */ | ||
47 | #define MAC_CONTROL_OM 0x00200000 /* Loopback Operating Mode */ | ||
48 | #define MAC_CONTROL_F 0x00100000 /* Full Duplex Mode */ | ||
49 | #define MAC_CONTROL_PM 0x00080000 /* Pass All Multicast */ | ||
50 | #define MAC_CONTROL_PR 0x00040000 /* Promiscuous Mode */ | ||
51 | #define MAC_CONTROL_IF 0x00020000 /* Inverse Filtering */ | ||
52 | #define MAC_CONTROL_PB 0x00010000 /* Pass Bad Frames */ | ||
53 | #define MAC_CONTROL_HO 0x00008000 /* Hash Only Filtering Mode */ | ||
54 | #define MAC_CONTROL_HP 0x00002000 /* Hash/Perfect Filtering Mode */ | ||
55 | #define MAC_CONTROL_LCC 0x00001000 /* Late Collision Control */ | ||
56 | #define MAC_CONTROL_DBF 0x00000800 /* Disable Broadcast Frames */ | ||
57 | #define MAC_CONTROL_DRTY 0x00000400 /* Disable Retry */ | ||
58 | #define MAC_CONTROL_ASTP 0x00000100 /* Automatic Pad Stripping */ | ||
59 | #define MAC_CONTROL_BOLMT_10 0x00000000 /* Back Off Limit 10 */ | ||
60 | #define MAC_CONTROL_BOLMT_8 0x00000040 /* Back Off Limit 8 */ | ||
61 | #define MAC_CONTROL_BOLMT_4 0x00000080 /* Back Off Limit 4 */ | ||
62 | #define MAC_CONTROL_BOLMT_1 0x000000c0 /* Back Off Limit 1 */ | ||
63 | #define MAC_CONTROL_DC 0x00000020 /* Deferral Check */ | ||
64 | #define MAC_CONTROL_TE 0x00000008 /* Transmitter Enable */ | ||
65 | #define MAC_CONTROL_RE 0x00000004 /* Receiver Enable */ | ||
66 | |||
67 | #define MAC_CORE_INIT (MAC_CONTROL_HBD | MAC_CONTROL_ASTP) | ||
68 | |||
69 | /* MAC FLOW CTRL defines */ | ||
70 | #define MAC_FLOW_CTRL_PT_MASK 0xffff0000 /* Pause Time Mask */ | ||
71 | #define MAC_FLOW_CTRL_PT_SHIFT 16 | ||
72 | #define MAC_FLOW_CTRL_PASS 0x00000004 /* Pass Control Frames */ | ||
73 | #define MAC_FLOW_CTRL_ENABLE 0x00000002 /* Flow Control Enable */ | ||
74 | #define MAC_FLOW_CTRL_PAUSE 0x00000001 /* Flow Control Busy ... */ | ||
75 | |||
76 | /* MII ADDR defines */ | ||
77 | #define MAC_MII_ADDR_WRITE 0x00000002 /* MII Write */ | ||
78 | #define MAC_MII_ADDR_BUSY 0x00000001 /* MII Busy */ | ||
79 | |||
80 | /*---------------------------------------------------------------------------- | ||
81 | * DMA BLOCK defines | ||
82 | *---------------------------------------------------------------------------*/ | ||
83 | |||
84 | /* DMA Bus Mode register defines */ | ||
85 | #define DMA_BUS_MODE_DBO 0x00100000 /* Descriptor Byte Ordering */ | ||
86 | #define DMA_BUS_MODE_BLE 0x00000080 /* Big Endian/Little Endian */ | ||
87 | #define DMA_BUS_MODE_PBL_MASK 0x00003f00 /* Programmable Burst Len */ | ||
88 | #define DMA_BUS_MODE_PBL_SHIFT 8 | ||
89 | #define DMA_BUS_MODE_DSL_MASK 0x0000007c /* Descriptor Skip Length */ | ||
90 | #define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */ | ||
91 | #define DMA_BUS_MODE_BAR_BUS 0x00000002 /* Bar-Bus Arbitration */ | ||
92 | #define DMA_BUS_MODE_SFT_RESET 0x00000001 /* Software Reset */ | ||
93 | #define DMA_BUS_MODE_DEFAULT 0x00000000 | ||
94 | |||
95 | /* DMA Control register defines */ | ||
96 | #define DMA_CONTROL_SF 0x00200000 /* Store And Forward */ | ||
97 | |||
98 | /* Transmit Threshold Control */ | ||
99 | enum ttc_control { | ||
100 | DMA_CONTROL_TTC_DEFAULT = 0x00000000, /* Threshold is 32 DWORDS */ | ||
101 | DMA_CONTROL_TTC_64 = 0x00004000, /* Threshold is 64 DWORDS */ | ||
102 | DMA_CONTROL_TTC_128 = 0x00008000, /* Threshold is 128 DWORDS */ | ||
103 | DMA_CONTROL_TTC_256 = 0x0000c000, /* Threshold is 256 DWORDS */ | ||
104 | DMA_CONTROL_TTC_18 = 0x00400000, /* Threshold is 18 DWORDS */ | ||
105 | DMA_CONTROL_TTC_24 = 0x00404000, /* Threshold is 24 DWORDS */ | ||
106 | DMA_CONTROL_TTC_32 = 0x00408000, /* Threshold is 32 DWORDS */ | ||
107 | DMA_CONTROL_TTC_40 = 0x0040c000, /* Threshold is 40 DWORDS */ | ||
108 | DMA_CONTROL_SE = 0x00000008, /* Stop On Empty */ | ||
109 | DMA_CONTROL_OSF = 0x00000004, /* Operate On 2nd Frame */ | ||
110 | }; | ||
111 | |||
112 | /* STMAC110 DMA Missed Frame Counter register defines */ | ||
113 | #define DMA_MISSED_FRAME_OVE 0x10000000 /* FIFO Overflow Overflow */ | ||
114 | #define DMA_MISSED_FRAME_OVE_CNTR 0x0ffe0000 /* Overflow Frame Counter */ | ||
115 | #define DMA_MISSED_FRAME_OVE_M 0x00010000 /* Missed Frame Overflow */ | ||
116 | #define DMA_MISSED_FRAME_M_CNTR 0x0000ffff /* Missed Frame Couinter */ | ||
diff --git a/drivers/net/stmmac/stmmac.h b/drivers/net/stmmac/stmmac.h new file mode 100644 index 000000000000..6d2eae3040e5 --- /dev/null +++ b/drivers/net/stmmac/stmmac.h | |||
@@ -0,0 +1,98 @@ | |||
1 | /******************************************************************************* | ||
2 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify it | ||
5 | under the terms and conditions of the GNU General Public License, | ||
6 | version 2, as published by the Free Software Foundation. | ||
7 | |||
8 | This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | this program; if not, write to the Free Software Foundation, Inc., | ||
15 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
16 | |||
17 | The full GNU General Public License is included in this distribution in | ||
18 | the file called "COPYING". | ||
19 | |||
20 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
21 | *******************************************************************************/ | ||
22 | |||
23 | #define DRV_MODULE_VERSION "Oct_09" | ||
24 | |||
25 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | ||
26 | #define STMMAC_VLAN_TAG_USED | ||
27 | #include <linux/if_vlan.h> | ||
28 | #endif | ||
29 | |||
30 | #include "common.h" | ||
31 | #ifdef CONFIG_STMMAC_TIMER | ||
32 | #include "stmmac_timer.h" | ||
33 | #endif | ||
34 | |||
35 | struct stmmac_priv { | ||
36 | /* Frequently used values are kept adjacent for cache effect */ | ||
37 | struct dma_desc *dma_tx ____cacheline_aligned; | ||
38 | dma_addr_t dma_tx_phy; | ||
39 | struct sk_buff **tx_skbuff; | ||
40 | unsigned int cur_tx; | ||
41 | unsigned int dirty_tx; | ||
42 | unsigned int dma_tx_size; | ||
43 | int tx_coe; | ||
44 | int tx_coalesce; | ||
45 | |||
46 | struct dma_desc *dma_rx ; | ||
47 | unsigned int cur_rx; | ||
48 | unsigned int dirty_rx; | ||
49 | struct sk_buff **rx_skbuff; | ||
50 | dma_addr_t *rx_skbuff_dma; | ||
51 | struct sk_buff_head rx_recycle; | ||
52 | |||
53 | struct net_device *dev; | ||
54 | int is_gmac; | ||
55 | dma_addr_t dma_rx_phy; | ||
56 | unsigned int dma_rx_size; | ||
57 | int rx_csum; | ||
58 | unsigned int dma_buf_sz; | ||
59 | struct device *device; | ||
60 | struct mac_device_info *mac_type; | ||
61 | |||
62 | struct stmmac_extra_stats xstats; | ||
63 | struct napi_struct napi; | ||
64 | |||
65 | phy_interface_t phy_interface; | ||
66 | int pbl; | ||
67 | int bus_id; | ||
68 | int phy_addr; | ||
69 | int phy_mask; | ||
70 | int (*phy_reset) (void *priv); | ||
71 | void (*fix_mac_speed) (void *priv, unsigned int speed); | ||
72 | void *bsp_priv; | ||
73 | |||
74 | int phy_irq; | ||
75 | struct phy_device *phydev; | ||
76 | int oldlink; | ||
77 | int speed; | ||
78 | int oldduplex; | ||
79 | unsigned int flow_ctrl; | ||
80 | unsigned int pause; | ||
81 | struct mii_bus *mii; | ||
82 | |||
83 | u32 msg_enable; | ||
84 | spinlock_t lock; | ||
85 | int wolopts; | ||
86 | int wolenabled; | ||
87 | int shutdown; | ||
88 | #ifdef CONFIG_STMMAC_TIMER | ||
89 | struct stmmac_timer *tm; | ||
90 | #endif | ||
91 | #ifdef STMMAC_VLAN_TAG_USED | ||
92 | struct vlan_group *vlgrp; | ||
93 | #endif | ||
94 | }; | ||
95 | |||
96 | extern int stmmac_mdio_unregister(struct net_device *ndev); | ||
97 | extern int stmmac_mdio_register(struct net_device *ndev); | ||
98 | extern void stmmac_set_ethtool_ops(struct net_device *netdev); | ||
diff --git a/drivers/net/stmmac/stmmac_ethtool.c b/drivers/net/stmmac/stmmac_ethtool.c new file mode 100644 index 000000000000..694ebe6a0758 --- /dev/null +++ b/drivers/net/stmmac/stmmac_ethtool.c | |||
@@ -0,0 +1,395 @@ | |||
1 | /******************************************************************************* | ||
2 | STMMAC Ethtool support | ||
3 | |||
4 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms and conditions of the GNU General Public License, | ||
8 | version 2, as published by the Free Software Foundation. | ||
9 | |||
10 | This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License along with | ||
16 | this program; if not, write to the Free Software Foundation, Inc., | ||
17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | The full GNU General Public License is included in this distribution in | ||
20 | the file called "COPYING". | ||
21 | |||
22 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
23 | *******************************************************************************/ | ||
24 | |||
25 | #include <linux/etherdevice.h> | ||
26 | #include <linux/ethtool.h> | ||
27 | #include <linux/mii.h> | ||
28 | #include <linux/phy.h> | ||
29 | |||
30 | #include "stmmac.h" | ||
31 | |||
32 | #define REG_SPACE_SIZE 0x1054 | ||
33 | #define MAC100_ETHTOOL_NAME "st_mac100" | ||
34 | #define GMAC_ETHTOOL_NAME "st_gmac" | ||
35 | |||
36 | struct stmmac_stats { | ||
37 | char stat_string[ETH_GSTRING_LEN]; | ||
38 | int sizeof_stat; | ||
39 | int stat_offset; | ||
40 | }; | ||
41 | |||
42 | #define STMMAC_STAT(m) \ | ||
43 | { #m, FIELD_SIZEOF(struct stmmac_extra_stats, m), \ | ||
44 | offsetof(struct stmmac_priv, xstats.m)} | ||
45 | |||
46 | static const struct stmmac_stats stmmac_gstrings_stats[] = { | ||
47 | STMMAC_STAT(tx_underflow), | ||
48 | STMMAC_STAT(tx_carrier), | ||
49 | STMMAC_STAT(tx_losscarrier), | ||
50 | STMMAC_STAT(tx_heartbeat), | ||
51 | STMMAC_STAT(tx_deferred), | ||
52 | STMMAC_STAT(tx_vlan), | ||
53 | STMMAC_STAT(rx_vlan), | ||
54 | STMMAC_STAT(tx_jabber), | ||
55 | STMMAC_STAT(tx_frame_flushed), | ||
56 | STMMAC_STAT(tx_payload_error), | ||
57 | STMMAC_STAT(tx_ip_header_error), | ||
58 | STMMAC_STAT(rx_desc), | ||
59 | STMMAC_STAT(rx_partial), | ||
60 | STMMAC_STAT(rx_runt), | ||
61 | STMMAC_STAT(rx_toolong), | ||
62 | STMMAC_STAT(rx_collision), | ||
63 | STMMAC_STAT(rx_crc), | ||
64 | STMMAC_STAT(rx_lenght), | ||
65 | STMMAC_STAT(rx_mii), | ||
66 | STMMAC_STAT(rx_multicast), | ||
67 | STMMAC_STAT(rx_gmac_overflow), | ||
68 | STMMAC_STAT(rx_watchdog), | ||
69 | STMMAC_STAT(da_rx_filter_fail), | ||
70 | STMMAC_STAT(sa_rx_filter_fail), | ||
71 | STMMAC_STAT(rx_missed_cntr), | ||
72 | STMMAC_STAT(rx_overflow_cntr), | ||
73 | STMMAC_STAT(tx_undeflow_irq), | ||
74 | STMMAC_STAT(tx_process_stopped_irq), | ||
75 | STMMAC_STAT(tx_jabber_irq), | ||
76 | STMMAC_STAT(rx_overflow_irq), | ||
77 | STMMAC_STAT(rx_buf_unav_irq), | ||
78 | STMMAC_STAT(rx_process_stopped_irq), | ||
79 | STMMAC_STAT(rx_watchdog_irq), | ||
80 | STMMAC_STAT(tx_early_irq), | ||
81 | STMMAC_STAT(fatal_bus_error_irq), | ||
82 | STMMAC_STAT(threshold), | ||
83 | STMMAC_STAT(tx_pkt_n), | ||
84 | STMMAC_STAT(rx_pkt_n), | ||
85 | STMMAC_STAT(poll_n), | ||
86 | STMMAC_STAT(sched_timer_n), | ||
87 | STMMAC_STAT(normal_irq_n), | ||
88 | }; | ||
89 | #define STMMAC_STATS_LEN ARRAY_SIZE(stmmac_gstrings_stats) | ||
90 | |||
91 | void stmmac_ethtool_getdrvinfo(struct net_device *dev, | ||
92 | struct ethtool_drvinfo *info) | ||
93 | { | ||
94 | struct stmmac_priv *priv = netdev_priv(dev); | ||
95 | |||
96 | if (!priv->is_gmac) | ||
97 | strcpy(info->driver, MAC100_ETHTOOL_NAME); | ||
98 | else | ||
99 | strcpy(info->driver, GMAC_ETHTOOL_NAME); | ||
100 | |||
101 | strcpy(info->version, DRV_MODULE_VERSION); | ||
102 | info->fw_version[0] = '\0'; | ||
103 | info->n_stats = STMMAC_STATS_LEN; | ||
104 | return; | ||
105 | } | ||
106 | |||
107 | int stmmac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) | ||
108 | { | ||
109 | struct stmmac_priv *priv = netdev_priv(dev); | ||
110 | struct phy_device *phy = priv->phydev; | ||
111 | int rc; | ||
112 | if (phy == NULL) { | ||
113 | pr_err("%s: %s: PHY is not registered\n", | ||
114 | __func__, dev->name); | ||
115 | return -ENODEV; | ||
116 | } | ||
117 | if (!netif_running(dev)) { | ||
118 | pr_err("%s: interface is disabled: we cannot track " | ||
119 | "link speed / duplex setting\n", dev->name); | ||
120 | return -EBUSY; | ||
121 | } | ||
122 | cmd->transceiver = XCVR_INTERNAL; | ||
123 | spin_lock_irq(&priv->lock); | ||
124 | rc = phy_ethtool_gset(phy, cmd); | ||
125 | spin_unlock_irq(&priv->lock); | ||
126 | return rc; | ||
127 | } | ||
128 | |||
129 | int stmmac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd) | ||
130 | { | ||
131 | struct stmmac_priv *priv = netdev_priv(dev); | ||
132 | struct phy_device *phy = priv->phydev; | ||
133 | int rc; | ||
134 | |||
135 | spin_lock(&priv->lock); | ||
136 | rc = phy_ethtool_sset(phy, cmd); | ||
137 | spin_unlock(&priv->lock); | ||
138 | |||
139 | return rc; | ||
140 | } | ||
141 | |||
142 | u32 stmmac_ethtool_getmsglevel(struct net_device *dev) | ||
143 | { | ||
144 | struct stmmac_priv *priv = netdev_priv(dev); | ||
145 | return priv->msg_enable; | ||
146 | } | ||
147 | |||
148 | void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level) | ||
149 | { | ||
150 | struct stmmac_priv *priv = netdev_priv(dev); | ||
151 | priv->msg_enable = level; | ||
152 | |||
153 | } | ||
154 | |||
155 | int stmmac_check_if_running(struct net_device *dev) | ||
156 | { | ||
157 | if (!netif_running(dev)) | ||
158 | return -EBUSY; | ||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | int stmmac_ethtool_get_regs_len(struct net_device *dev) | ||
163 | { | ||
164 | return REG_SPACE_SIZE; | ||
165 | } | ||
166 | |||
167 | void stmmac_ethtool_gregs(struct net_device *dev, | ||
168 | struct ethtool_regs *regs, void *space) | ||
169 | { | ||
170 | int i; | ||
171 | u32 *reg_space = (u32 *) space; | ||
172 | |||
173 | struct stmmac_priv *priv = netdev_priv(dev); | ||
174 | |||
175 | memset(reg_space, 0x0, REG_SPACE_SIZE); | ||
176 | |||
177 | if (!priv->is_gmac) { | ||
178 | /* MAC registers */ | ||
179 | for (i = 0; i < 12; i++) | ||
180 | reg_space[i] = readl(dev->base_addr + (i * 4)); | ||
181 | /* DMA registers */ | ||
182 | for (i = 0; i < 9; i++) | ||
183 | reg_space[i + 12] = | ||
184 | readl(dev->base_addr + (DMA_BUS_MODE + (i * 4))); | ||
185 | reg_space[22] = readl(dev->base_addr + DMA_CUR_TX_BUF_ADDR); | ||
186 | reg_space[23] = readl(dev->base_addr + DMA_CUR_RX_BUF_ADDR); | ||
187 | } else { | ||
188 | /* MAC registers */ | ||
189 | for (i = 0; i < 55; i++) | ||
190 | reg_space[i] = readl(dev->base_addr + (i * 4)); | ||
191 | /* DMA registers */ | ||
192 | for (i = 0; i < 22; i++) | ||
193 | reg_space[i + 55] = | ||
194 | readl(dev->base_addr + (DMA_BUS_MODE + (i * 4))); | ||
195 | } | ||
196 | |||
197 | return; | ||
198 | } | ||
199 | |||
200 | int stmmac_ethtool_set_tx_csum(struct net_device *netdev, u32 data) | ||
201 | { | ||
202 | if (data) | ||
203 | netdev->features |= NETIF_F_HW_CSUM; | ||
204 | else | ||
205 | netdev->features &= ~NETIF_F_HW_CSUM; | ||
206 | |||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | u32 stmmac_ethtool_get_rx_csum(struct net_device *dev) | ||
211 | { | ||
212 | struct stmmac_priv *priv = netdev_priv(dev); | ||
213 | |||
214 | return priv->rx_csum; | ||
215 | } | ||
216 | |||
217 | static void | ||
218 | stmmac_get_pauseparam(struct net_device *netdev, | ||
219 | struct ethtool_pauseparam *pause) | ||
220 | { | ||
221 | struct stmmac_priv *priv = netdev_priv(netdev); | ||
222 | |||
223 | spin_lock(&priv->lock); | ||
224 | |||
225 | pause->rx_pause = 0; | ||
226 | pause->tx_pause = 0; | ||
227 | pause->autoneg = priv->phydev->autoneg; | ||
228 | |||
229 | if (priv->flow_ctrl & FLOW_RX) | ||
230 | pause->rx_pause = 1; | ||
231 | if (priv->flow_ctrl & FLOW_TX) | ||
232 | pause->tx_pause = 1; | ||
233 | |||
234 | spin_unlock(&priv->lock); | ||
235 | return; | ||
236 | } | ||
237 | |||
238 | static int | ||
239 | stmmac_set_pauseparam(struct net_device *netdev, | ||
240 | struct ethtool_pauseparam *pause) | ||
241 | { | ||
242 | struct stmmac_priv *priv = netdev_priv(netdev); | ||
243 | struct phy_device *phy = priv->phydev; | ||
244 | int new_pause = FLOW_OFF; | ||
245 | int ret = 0; | ||
246 | |||
247 | spin_lock(&priv->lock); | ||
248 | |||
249 | if (pause->rx_pause) | ||
250 | new_pause |= FLOW_RX; | ||
251 | if (pause->tx_pause) | ||
252 | new_pause |= FLOW_TX; | ||
253 | |||
254 | priv->flow_ctrl = new_pause; | ||
255 | |||
256 | if (phy->autoneg) { | ||
257 | if (netif_running(netdev)) { | ||
258 | struct ethtool_cmd cmd; | ||
259 | /* auto-negotiation automatically restarted */ | ||
260 | cmd.cmd = ETHTOOL_NWAY_RST; | ||
261 | cmd.supported = phy->supported; | ||
262 | cmd.advertising = phy->advertising; | ||
263 | cmd.autoneg = phy->autoneg; | ||
264 | cmd.speed = phy->speed; | ||
265 | cmd.duplex = phy->duplex; | ||
266 | cmd.phy_address = phy->addr; | ||
267 | ret = phy_ethtool_sset(phy, &cmd); | ||
268 | } | ||
269 | } else { | ||
270 | unsigned long ioaddr = netdev->base_addr; | ||
271 | priv->mac_type->ops->flow_ctrl(ioaddr, phy->duplex, | ||
272 | priv->flow_ctrl, priv->pause); | ||
273 | } | ||
274 | spin_unlock(&priv->lock); | ||
275 | return ret; | ||
276 | } | ||
277 | |||
278 | static void stmmac_get_ethtool_stats(struct net_device *dev, | ||
279 | struct ethtool_stats *dummy, u64 *data) | ||
280 | { | ||
281 | struct stmmac_priv *priv = netdev_priv(dev); | ||
282 | unsigned long ioaddr = dev->base_addr; | ||
283 | int i; | ||
284 | |||
285 | /* Update HW stats if supported */ | ||
286 | priv->mac_type->ops->dma_diagnostic_fr(&dev->stats, &priv->xstats, | ||
287 | ioaddr); | ||
288 | |||
289 | for (i = 0; i < STMMAC_STATS_LEN; i++) { | ||
290 | char *p = (char *)priv + stmmac_gstrings_stats[i].stat_offset; | ||
291 | data[i] = (stmmac_gstrings_stats[i].sizeof_stat == | ||
292 | sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); | ||
293 | } | ||
294 | |||
295 | return; | ||
296 | } | ||
297 | |||
298 | static int stmmac_get_sset_count(struct net_device *netdev, int sset) | ||
299 | { | ||
300 | switch (sset) { | ||
301 | case ETH_SS_STATS: | ||
302 | return STMMAC_STATS_LEN; | ||
303 | default: | ||
304 | return -EOPNOTSUPP; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | static void stmmac_get_strings(struct net_device *dev, u32 stringset, u8 *data) | ||
309 | { | ||
310 | int i; | ||
311 | u8 *p = data; | ||
312 | |||
313 | switch (stringset) { | ||
314 | case ETH_SS_STATS: | ||
315 | for (i = 0; i < STMMAC_STATS_LEN; i++) { | ||
316 | memcpy(p, stmmac_gstrings_stats[i].stat_string, | ||
317 | ETH_GSTRING_LEN); | ||
318 | p += ETH_GSTRING_LEN; | ||
319 | } | ||
320 | break; | ||
321 | default: | ||
322 | WARN_ON(1); | ||
323 | break; | ||
324 | } | ||
325 | return; | ||
326 | } | ||
327 | |||
328 | /* Currently only support WOL through Magic packet. */ | ||
329 | static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | ||
330 | { | ||
331 | struct stmmac_priv *priv = netdev_priv(dev); | ||
332 | |||
333 | spin_lock_irq(&priv->lock); | ||
334 | if (priv->wolenabled == PMT_SUPPORTED) { | ||
335 | wol->supported = WAKE_MAGIC; | ||
336 | wol->wolopts = priv->wolopts; | ||
337 | } | ||
338 | spin_unlock_irq(&priv->lock); | ||
339 | } | ||
340 | |||
341 | static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | ||
342 | { | ||
343 | struct stmmac_priv *priv = netdev_priv(dev); | ||
344 | u32 support = WAKE_MAGIC; | ||
345 | |||
346 | if (priv->wolenabled == PMT_NOT_SUPPORTED) | ||
347 | return -EINVAL; | ||
348 | |||
349 | if (wol->wolopts & ~support) | ||
350 | return -EINVAL; | ||
351 | |||
352 | if (wol->wolopts == 0) | ||
353 | device_set_wakeup_enable(priv->device, 0); | ||
354 | else | ||
355 | device_set_wakeup_enable(priv->device, 1); | ||
356 | |||
357 | spin_lock_irq(&priv->lock); | ||
358 | priv->wolopts = wol->wolopts; | ||
359 | spin_unlock_irq(&priv->lock); | ||
360 | |||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static struct ethtool_ops stmmac_ethtool_ops = { | ||
365 | .begin = stmmac_check_if_running, | ||
366 | .get_drvinfo = stmmac_ethtool_getdrvinfo, | ||
367 | .get_settings = stmmac_ethtool_getsettings, | ||
368 | .set_settings = stmmac_ethtool_setsettings, | ||
369 | .get_msglevel = stmmac_ethtool_getmsglevel, | ||
370 | .set_msglevel = stmmac_ethtool_setmsglevel, | ||
371 | .get_regs = stmmac_ethtool_gregs, | ||
372 | .get_regs_len = stmmac_ethtool_get_regs_len, | ||
373 | .get_link = ethtool_op_get_link, | ||
374 | .get_rx_csum = stmmac_ethtool_get_rx_csum, | ||
375 | .get_tx_csum = ethtool_op_get_tx_csum, | ||
376 | .set_tx_csum = stmmac_ethtool_set_tx_csum, | ||
377 | .get_sg = ethtool_op_get_sg, | ||
378 | .set_sg = ethtool_op_set_sg, | ||
379 | .get_pauseparam = stmmac_get_pauseparam, | ||
380 | .set_pauseparam = stmmac_set_pauseparam, | ||
381 | .get_ethtool_stats = stmmac_get_ethtool_stats, | ||
382 | .get_strings = stmmac_get_strings, | ||
383 | .get_wol = stmmac_get_wol, | ||
384 | .set_wol = stmmac_set_wol, | ||
385 | .get_sset_count = stmmac_get_sset_count, | ||
386 | #ifdef NETIF_F_TSO | ||
387 | .get_tso = ethtool_op_get_tso, | ||
388 | .set_tso = ethtool_op_set_tso, | ||
389 | #endif | ||
390 | }; | ||
391 | |||
392 | void stmmac_set_ethtool_ops(struct net_device *netdev) | ||
393 | { | ||
394 | SET_ETHTOOL_OPS(netdev, &stmmac_ethtool_ops); | ||
395 | } | ||
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c new file mode 100644 index 000000000000..c2f14dc9ba28 --- /dev/null +++ b/drivers/net/stmmac/stmmac_main.c | |||
@@ -0,0 +1,2204 @@ | |||
1 | /******************************************************************************* | ||
2 | This is the driver for the ST MAC 10/100/1000 on-chip Ethernet controllers. | ||
3 | ST Ethernet IPs are built around a Synopsys IP Core. | ||
4 | |||
5 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify it | ||
8 | under the terms and conditions of the GNU General Public License, | ||
9 | version 2, as published by the Free Software Foundation. | ||
10 | |||
11 | This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License along with | ||
17 | this program; if not, write to the Free Software Foundation, Inc., | ||
18 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | |||
20 | The full GNU General Public License is included in this distribution in | ||
21 | the file called "COPYING". | ||
22 | |||
23 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
24 | |||
25 | Documentation available at: | ||
26 | http://www.stlinux.com | ||
27 | Support available at: | ||
28 | https://bugzilla.stlinux.com/ | ||
29 | *******************************************************************************/ | ||
30 | |||
31 | #include <linux/module.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/kernel.h> | ||
34 | #include <linux/interrupt.h> | ||
35 | #include <linux/netdevice.h> | ||
36 | #include <linux/etherdevice.h> | ||
37 | #include <linux/platform_device.h> | ||
38 | #include <linux/ip.h> | ||
39 | #include <linux/tcp.h> | ||
40 | #include <linux/skbuff.h> | ||
41 | #include <linux/ethtool.h> | ||
42 | #include <linux/if_ether.h> | ||
43 | #include <linux/crc32.h> | ||
44 | #include <linux/mii.h> | ||
45 | #include <linux/phy.h> | ||
46 | #include <linux/if_vlan.h> | ||
47 | #include <linux/dma-mapping.h> | ||
48 | #include <linux/stm/soc.h> | ||
49 | #include "stmmac.h" | ||
50 | |||
51 | #define STMMAC_RESOURCE_NAME "stmmaceth" | ||
52 | #define PHY_RESOURCE_NAME "stmmacphy" | ||
53 | |||
54 | #undef STMMAC_DEBUG | ||
55 | /*#define STMMAC_DEBUG*/ | ||
56 | #ifdef STMMAC_DEBUG | ||
57 | #define DBG(nlevel, klevel, fmt, args...) \ | ||
58 | ((void)(netif_msg_##nlevel(priv) && \ | ||
59 | printk(KERN_##klevel fmt, ## args))) | ||
60 | #else | ||
61 | #define DBG(nlevel, klevel, fmt, args...) do { } while (0) | ||
62 | #endif | ||
63 | |||
64 | #undef STMMAC_RX_DEBUG | ||
65 | /*#define STMMAC_RX_DEBUG*/ | ||
66 | #ifdef STMMAC_RX_DEBUG | ||
67 | #define RX_DBG(fmt, args...) printk(fmt, ## args) | ||
68 | #else | ||
69 | #define RX_DBG(fmt, args...) do { } while (0) | ||
70 | #endif | ||
71 | |||
72 | #undef STMMAC_XMIT_DEBUG | ||
73 | /*#define STMMAC_XMIT_DEBUG*/ | ||
74 | #ifdef STMMAC_TX_DEBUG | ||
75 | #define TX_DBG(fmt, args...) printk(fmt, ## args) | ||
76 | #else | ||
77 | #define TX_DBG(fmt, args...) do { } while (0) | ||
78 | #endif | ||
79 | |||
80 | #define STMMAC_ALIGN(x) L1_CACHE_ALIGN(x) | ||
81 | #define JUMBO_LEN 9000 | ||
82 | |||
83 | /* Module parameters */ | ||
84 | #define TX_TIMEO 5000 /* default 5 seconds */ | ||
85 | static int watchdog = TX_TIMEO; | ||
86 | module_param(watchdog, int, S_IRUGO | S_IWUSR); | ||
87 | MODULE_PARM_DESC(watchdog, "Transmit timeout in milliseconds"); | ||
88 | |||
89 | static int debug = -1; /* -1: default, 0: no output, 16: all */ | ||
90 | module_param(debug, int, S_IRUGO | S_IWUSR); | ||
91 | MODULE_PARM_DESC(debug, "Message Level (0: no output, 16: all)"); | ||
92 | |||
93 | static int phyaddr = -1; | ||
94 | module_param(phyaddr, int, S_IRUGO); | ||
95 | MODULE_PARM_DESC(phyaddr, "Physical device address"); | ||
96 | |||
97 | #define DMA_TX_SIZE 256 | ||
98 | static int dma_txsize = DMA_TX_SIZE; | ||
99 | module_param(dma_txsize, int, S_IRUGO | S_IWUSR); | ||
100 | MODULE_PARM_DESC(dma_txsize, "Number of descriptors in the TX list"); | ||
101 | |||
102 | #define DMA_RX_SIZE 256 | ||
103 | static int dma_rxsize = DMA_RX_SIZE; | ||
104 | module_param(dma_rxsize, int, S_IRUGO | S_IWUSR); | ||
105 | MODULE_PARM_DESC(dma_rxsize, "Number of descriptors in the RX list"); | ||
106 | |||
107 | static int flow_ctrl = FLOW_OFF; | ||
108 | module_param(flow_ctrl, int, S_IRUGO | S_IWUSR); | ||
109 | MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off]"); | ||
110 | |||
111 | static int pause = PAUSE_TIME; | ||
112 | module_param(pause, int, S_IRUGO | S_IWUSR); | ||
113 | MODULE_PARM_DESC(pause, "Flow Control Pause Time"); | ||
114 | |||
115 | #define TC_DEFAULT 64 | ||
116 | static int tc = TC_DEFAULT; | ||
117 | module_param(tc, int, S_IRUGO | S_IWUSR); | ||
118 | MODULE_PARM_DESC(tc, "DMA threshold control value"); | ||
119 | |||
120 | #define RX_NO_COALESCE 1 /* Always interrupt on completion */ | ||
121 | #define TX_NO_COALESCE -1 /* No moderation by default */ | ||
122 | |||
123 | /* Pay attention to tune this parameter; take care of both | ||
124 | * hardware capability and network stabitily/performance impact. | ||
125 | * Many tests showed that ~4ms latency seems to be good enough. */ | ||
126 | #ifdef CONFIG_STMMAC_TIMER | ||
127 | #define DEFAULT_PERIODIC_RATE 256 | ||
128 | static int tmrate = DEFAULT_PERIODIC_RATE; | ||
129 | module_param(tmrate, int, S_IRUGO | S_IWUSR); | ||
130 | MODULE_PARM_DESC(tmrate, "External timer freq. (default: 256Hz)"); | ||
131 | #endif | ||
132 | |||
133 | #define DMA_BUFFER_SIZE BUF_SIZE_2KiB | ||
134 | static int buf_sz = DMA_BUFFER_SIZE; | ||
135 | module_param(buf_sz, int, S_IRUGO | S_IWUSR); | ||
136 | MODULE_PARM_DESC(buf_sz, "DMA buffer size"); | ||
137 | |||
138 | /* In case of Giga ETH, we can enable/disable the COE for the | ||
139 | * transmit HW checksum computation. | ||
140 | * Note that, if tx csum is off in HW, SG will be still supported. */ | ||
141 | static int tx_coe = HW_CSUM; | ||
142 | module_param(tx_coe, int, S_IRUGO | S_IWUSR); | ||
143 | MODULE_PARM_DESC(tx_coe, "GMAC COE type 2 [on/off]"); | ||
144 | |||
145 | static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE | | ||
146 | NETIF_MSG_LINK | NETIF_MSG_IFUP | | ||
147 | NETIF_MSG_IFDOWN | NETIF_MSG_TIMER); | ||
148 | |||
149 | static irqreturn_t stmmac_interrupt(int irq, void *dev_id); | ||
150 | static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev); | ||
151 | |||
152 | /** | ||
153 | * stmmac_verify_args - verify the driver parameters. | ||
154 | * Description: it verifies if some wrong parameter is passed to the driver. | ||
155 | * Note that wrong parameters are replaced with the default values. | ||
156 | */ | ||
157 | static void stmmac_verify_args(void) | ||
158 | { | ||
159 | if (unlikely(watchdog < 0)) | ||
160 | watchdog = TX_TIMEO; | ||
161 | if (unlikely(dma_rxsize < 0)) | ||
162 | dma_rxsize = DMA_RX_SIZE; | ||
163 | if (unlikely(dma_txsize < 0)) | ||
164 | dma_txsize = DMA_TX_SIZE; | ||
165 | if (unlikely((buf_sz < DMA_BUFFER_SIZE) || (buf_sz > BUF_SIZE_16KiB))) | ||
166 | buf_sz = DMA_BUFFER_SIZE; | ||
167 | if (unlikely(flow_ctrl > 1)) | ||
168 | flow_ctrl = FLOW_AUTO; | ||
169 | else if (likely(flow_ctrl < 0)) | ||
170 | flow_ctrl = FLOW_OFF; | ||
171 | if (unlikely((pause < 0) || (pause > 0xffff))) | ||
172 | pause = PAUSE_TIME; | ||
173 | |||
174 | return; | ||
175 | } | ||
176 | |||
177 | #if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG) | ||
178 | static void print_pkt(unsigned char *buf, int len) | ||
179 | { | ||
180 | int j; | ||
181 | pr_info("len = %d byte, buf addr: 0x%p", len, buf); | ||
182 | for (j = 0; j < len; j++) { | ||
183 | if ((j % 16) == 0) | ||
184 | pr_info("\n %03x:", j); | ||
185 | pr_info(" %02x", buf[j]); | ||
186 | } | ||
187 | pr_info("\n"); | ||
188 | return; | ||
189 | } | ||
190 | #endif | ||
191 | |||
192 | /* minimum number of free TX descriptors required to wake up TX process */ | ||
193 | #define STMMAC_TX_THRESH(x) (x->dma_tx_size/4) | ||
194 | |||
195 | static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) | ||
196 | { | ||
197 | return priv->dirty_tx + priv->dma_tx_size - priv->cur_tx - 1; | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * stmmac_adjust_link | ||
202 | * @dev: net device structure | ||
203 | * Description: it adjusts the link parameters. | ||
204 | */ | ||
205 | static void stmmac_adjust_link(struct net_device *dev) | ||
206 | { | ||
207 | struct stmmac_priv *priv = netdev_priv(dev); | ||
208 | struct phy_device *phydev = priv->phydev; | ||
209 | unsigned long ioaddr = dev->base_addr; | ||
210 | unsigned long flags; | ||
211 | int new_state = 0; | ||
212 | unsigned int fc = priv->flow_ctrl, pause_time = priv->pause; | ||
213 | |||
214 | if (phydev == NULL) | ||
215 | return; | ||
216 | |||
217 | DBG(probe, DEBUG, "stmmac_adjust_link: called. address %d link %d\n", | ||
218 | phydev->addr, phydev->link); | ||
219 | |||
220 | spin_lock_irqsave(&priv->lock, flags); | ||
221 | if (phydev->link) { | ||
222 | u32 ctrl = readl(ioaddr + MAC_CTRL_REG); | ||
223 | |||
224 | /* Now we make sure that we can be in full duplex mode. | ||
225 | * If not, we operate in half-duplex mode. */ | ||
226 | if (phydev->duplex != priv->oldduplex) { | ||
227 | new_state = 1; | ||
228 | if (!(phydev->duplex)) | ||
229 | ctrl &= ~priv->mac_type->hw.link.duplex; | ||
230 | else | ||
231 | ctrl |= priv->mac_type->hw.link.duplex; | ||
232 | priv->oldduplex = phydev->duplex; | ||
233 | } | ||
234 | /* Flow Control operation */ | ||
235 | if (phydev->pause) | ||
236 | priv->mac_type->ops->flow_ctrl(ioaddr, phydev->duplex, | ||
237 | fc, pause_time); | ||
238 | |||
239 | if (phydev->speed != priv->speed) { | ||
240 | new_state = 1; | ||
241 | switch (phydev->speed) { | ||
242 | case 1000: | ||
243 | if (likely(priv->is_gmac)) | ||
244 | ctrl &= ~priv->mac_type->hw.link.port; | ||
245 | break; | ||
246 | case 100: | ||
247 | case 10: | ||
248 | if (priv->is_gmac) { | ||
249 | ctrl |= priv->mac_type->hw.link.port; | ||
250 | if (phydev->speed == SPEED_100) { | ||
251 | ctrl |= | ||
252 | priv->mac_type->hw.link. | ||
253 | speed; | ||
254 | } else { | ||
255 | ctrl &= | ||
256 | ~(priv->mac_type->hw. | ||
257 | link.speed); | ||
258 | } | ||
259 | } else { | ||
260 | ctrl &= ~priv->mac_type->hw.link.port; | ||
261 | } | ||
262 | priv->fix_mac_speed(priv->bsp_priv, | ||
263 | phydev->speed); | ||
264 | break; | ||
265 | default: | ||
266 | if (netif_msg_link(priv)) | ||
267 | pr_warning("%s: Speed (%d) is not 10" | ||
268 | " or 100!\n", dev->name, phydev->speed); | ||
269 | break; | ||
270 | } | ||
271 | |||
272 | priv->speed = phydev->speed; | ||
273 | } | ||
274 | |||
275 | writel(ctrl, ioaddr + MAC_CTRL_REG); | ||
276 | |||
277 | if (!priv->oldlink) { | ||
278 | new_state = 1; | ||
279 | priv->oldlink = 1; | ||
280 | } | ||
281 | } else if (priv->oldlink) { | ||
282 | new_state = 1; | ||
283 | priv->oldlink = 0; | ||
284 | priv->speed = 0; | ||
285 | priv->oldduplex = -1; | ||
286 | } | ||
287 | |||
288 | if (new_state && netif_msg_link(priv)) | ||
289 | phy_print_status(phydev); | ||
290 | |||
291 | spin_unlock_irqrestore(&priv->lock, flags); | ||
292 | |||
293 | DBG(probe, DEBUG, "stmmac_adjust_link: exiting\n"); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * stmmac_init_phy - PHY initialization | ||
298 | * @dev: net device structure | ||
299 | * Description: it initializes the driver's PHY state, and attaches the PHY | ||
300 | * to the mac driver. | ||
301 | * Return value: | ||
302 | * 0 on success | ||
303 | */ | ||
304 | static int stmmac_init_phy(struct net_device *dev) | ||
305 | { | ||
306 | struct stmmac_priv *priv = netdev_priv(dev); | ||
307 | struct phy_device *phydev; | ||
308 | char phy_id[BUS_ID_SIZE]; /* PHY to connect */ | ||
309 | char bus_id[BUS_ID_SIZE]; | ||
310 | |||
311 | priv->oldlink = 0; | ||
312 | priv->speed = 0; | ||
313 | priv->oldduplex = -1; | ||
314 | |||
315 | if (priv->phy_addr == -1) { | ||
316 | /* We don't have a PHY, so do nothing */ | ||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | snprintf(bus_id, MII_BUS_ID_SIZE, "%x", priv->bus_id); | ||
321 | snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, bus_id, priv->phy_addr); | ||
322 | pr_debug("stmmac_init_phy: trying to attach to %s\n", phy_id); | ||
323 | |||
324 | phydev = phy_connect(dev, phy_id, &stmmac_adjust_link, 0, | ||
325 | priv->phy_interface); | ||
326 | |||
327 | if (IS_ERR(phydev)) { | ||
328 | pr_err("%s: Could not attach to PHY\n", dev->name); | ||
329 | return PTR_ERR(phydev); | ||
330 | } | ||
331 | |||
332 | /* | ||
333 | * Broken HW is sometimes missing the pull-up resistor on the | ||
334 | * MDIO line, which results in reads to non-existent devices returning | ||
335 | * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent | ||
336 | * device as well. | ||
337 | * Note: phydev->phy_id is the result of reading the UID PHY registers. | ||
338 | */ | ||
339 | if (phydev->phy_id == 0) { | ||
340 | phy_disconnect(phydev); | ||
341 | return -ENODEV; | ||
342 | } | ||
343 | pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" | ||
344 | " Link = %d\n", dev->name, phydev->phy_id, phydev->link); | ||
345 | |||
346 | priv->phydev = phydev; | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | static inline void stmmac_mac_enable_rx(unsigned long ioaddr) | ||
352 | { | ||
353 | u32 value = readl(ioaddr + MAC_CTRL_REG); | ||
354 | value |= MAC_RNABLE_RX; | ||
355 | /* Set the RE (receive enable bit into the MAC CTRL register). */ | ||
356 | writel(value, ioaddr + MAC_CTRL_REG); | ||
357 | } | ||
358 | |||
359 | static inline void stmmac_mac_enable_tx(unsigned long ioaddr) | ||
360 | { | ||
361 | u32 value = readl(ioaddr + MAC_CTRL_REG); | ||
362 | value |= MAC_ENABLE_TX; | ||
363 | /* Set the TE (transmit enable bit into the MAC CTRL register). */ | ||
364 | writel(value, ioaddr + MAC_CTRL_REG); | ||
365 | } | ||
366 | |||
367 | static inline void stmmac_mac_disable_rx(unsigned long ioaddr) | ||
368 | { | ||
369 | u32 value = readl(ioaddr + MAC_CTRL_REG); | ||
370 | value &= ~MAC_RNABLE_RX; | ||
371 | writel(value, ioaddr + MAC_CTRL_REG); | ||
372 | } | ||
373 | |||
374 | static inline void stmmac_mac_disable_tx(unsigned long ioaddr) | ||
375 | { | ||
376 | u32 value = readl(ioaddr + MAC_CTRL_REG); | ||
377 | value &= ~MAC_ENABLE_TX; | ||
378 | writel(value, ioaddr + MAC_CTRL_REG); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * display_ring | ||
383 | * @p: pointer to the ring. | ||
384 | * @size: size of the ring. | ||
385 | * Description: display all the descriptors within the ring. | ||
386 | */ | ||
387 | static void display_ring(struct dma_desc *p, int size) | ||
388 | { | ||
389 | struct tmp_s { | ||
390 | u64 a; | ||
391 | unsigned int b; | ||
392 | unsigned int c; | ||
393 | }; | ||
394 | int i; | ||
395 | for (i = 0; i < size; i++) { | ||
396 | struct tmp_s *x = (struct tmp_s *)(p + i); | ||
397 | pr_info("\t%d [0x%x]: DES0=0x%x DES1=0x%x BUF1=0x%x BUF2=0x%x", | ||
398 | i, (unsigned int)virt_to_phys(&p[i]), | ||
399 | (unsigned int)(x->a), (unsigned int)((x->a) >> 32), | ||
400 | x->b, x->c); | ||
401 | pr_info("\n"); | ||
402 | } | ||
403 | } | ||
404 | |||
405 | /** | ||
406 | * init_dma_desc_rings - init the RX/TX descriptor rings | ||
407 | * @dev: net device structure | ||
408 | * Description: this function initializes the DMA RX/TX descriptors | ||
409 | * and allocates the socket buffers. | ||
410 | */ | ||
411 | static void init_dma_desc_rings(struct net_device *dev) | ||
412 | { | ||
413 | int i; | ||
414 | struct stmmac_priv *priv = netdev_priv(dev); | ||
415 | struct sk_buff *skb; | ||
416 | unsigned int txsize = priv->dma_tx_size; | ||
417 | unsigned int rxsize = priv->dma_rx_size; | ||
418 | unsigned int bfsize = priv->dma_buf_sz; | ||
419 | int buff2_needed = 0; | ||
420 | int dis_ic = 0; | ||
421 | |||
422 | #ifdef CONFIG_STMMAC_TIMER | ||
423 | /* Using Timers disable interrupts on completion for the reception */ | ||
424 | dis_ic = 1; | ||
425 | #endif | ||
426 | /* Set the Buffer size according to the MTU; | ||
427 | * indeed, in case of jumbo we need to bump-up the buffer sizes. | ||
428 | */ | ||
429 | if (unlikely(dev->mtu >= BUF_SIZE_8KiB)) | ||
430 | bfsize = BUF_SIZE_16KiB; | ||
431 | else if (unlikely(dev->mtu >= BUF_SIZE_4KiB)) | ||
432 | bfsize = BUF_SIZE_8KiB; | ||
433 | else if (unlikely(dev->mtu >= BUF_SIZE_2KiB)) | ||
434 | bfsize = BUF_SIZE_4KiB; | ||
435 | else if (unlikely(dev->mtu >= DMA_BUFFER_SIZE)) | ||
436 | bfsize = BUF_SIZE_2KiB; | ||
437 | else | ||
438 | bfsize = DMA_BUFFER_SIZE; | ||
439 | |||
440 | /* If the MTU exceeds 8k so use the second buffer in the chain */ | ||
441 | if (bfsize >= BUF_SIZE_8KiB) | ||
442 | buff2_needed = 1; | ||
443 | |||
444 | DBG(probe, INFO, "stmmac: txsize %d, rxsize %d, bfsize %d\n", | ||
445 | txsize, rxsize, bfsize); | ||
446 | |||
447 | priv->rx_skbuff_dma = kmalloc(rxsize * sizeof(dma_addr_t), GFP_KERNEL); | ||
448 | priv->rx_skbuff = | ||
449 | kmalloc(sizeof(struct sk_buff *) * rxsize, GFP_KERNEL); | ||
450 | priv->dma_rx = | ||
451 | (struct dma_desc *)dma_alloc_coherent(priv->device, | ||
452 | rxsize * | ||
453 | sizeof(struct dma_desc), | ||
454 | &priv->dma_rx_phy, | ||
455 | GFP_KERNEL); | ||
456 | priv->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * txsize, | ||
457 | GFP_KERNEL); | ||
458 | priv->dma_tx = | ||
459 | (struct dma_desc *)dma_alloc_coherent(priv->device, | ||
460 | txsize * | ||
461 | sizeof(struct dma_desc), | ||
462 | &priv->dma_tx_phy, | ||
463 | GFP_KERNEL); | ||
464 | |||
465 | if ((priv->dma_rx == NULL) || (priv->dma_tx == NULL)) { | ||
466 | pr_err("%s:ERROR allocating the DMA Tx/Rx desc\n", __func__); | ||
467 | return; | ||
468 | } | ||
469 | |||
470 | DBG(probe, INFO, "stmmac (%s) DMA desc rings: virt addr (Rx %p, " | ||
471 | "Tx %p)\n\tDMA phy addr (Rx 0x%08x, Tx 0x%08x)\n", | ||
472 | dev->name, priv->dma_rx, priv->dma_tx, | ||
473 | (unsigned int)priv->dma_rx_phy, (unsigned int)priv->dma_tx_phy); | ||
474 | |||
475 | /* RX INITIALIZATION */ | ||
476 | DBG(probe, INFO, "stmmac: SKB addresses:\n" | ||
477 | "skb\t\tskb data\tdma data\n"); | ||
478 | |||
479 | for (i = 0; i < rxsize; i++) { | ||
480 | struct dma_desc *p = priv->dma_rx + i; | ||
481 | |||
482 | skb = netdev_alloc_skb_ip_align(dev, bfsize); | ||
483 | if (unlikely(skb == NULL)) { | ||
484 | pr_err("%s: Rx init fails; skb is NULL\n", __func__); | ||
485 | break; | ||
486 | } | ||
487 | priv->rx_skbuff[i] = skb; | ||
488 | priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data, | ||
489 | bfsize, DMA_FROM_DEVICE); | ||
490 | |||
491 | p->des2 = priv->rx_skbuff_dma[i]; | ||
492 | if (unlikely(buff2_needed)) | ||
493 | p->des3 = p->des2 + BUF_SIZE_8KiB; | ||
494 | DBG(probe, INFO, "[%p]\t[%p]\t[%x]\n", priv->rx_skbuff[i], | ||
495 | priv->rx_skbuff[i]->data, priv->rx_skbuff_dma[i]); | ||
496 | } | ||
497 | priv->cur_rx = 0; | ||
498 | priv->dirty_rx = (unsigned int)(i - rxsize); | ||
499 | priv->dma_buf_sz = bfsize; | ||
500 | buf_sz = bfsize; | ||
501 | |||
502 | /* TX INITIALIZATION */ | ||
503 | for (i = 0; i < txsize; i++) { | ||
504 | priv->tx_skbuff[i] = NULL; | ||
505 | priv->dma_tx[i].des2 = 0; | ||
506 | } | ||
507 | priv->dirty_tx = 0; | ||
508 | priv->cur_tx = 0; | ||
509 | |||
510 | /* Clear the Rx/Tx descriptors */ | ||
511 | priv->mac_type->ops->init_rx_desc(priv->dma_rx, rxsize, dis_ic); | ||
512 | priv->mac_type->ops->init_tx_desc(priv->dma_tx, txsize); | ||
513 | |||
514 | if (netif_msg_hw(priv)) { | ||
515 | pr_info("RX descriptor ring:\n"); | ||
516 | display_ring(priv->dma_rx, rxsize); | ||
517 | pr_info("TX descriptor ring:\n"); | ||
518 | display_ring(priv->dma_tx, txsize); | ||
519 | } | ||
520 | return; | ||
521 | } | ||
522 | |||
523 | static void dma_free_rx_skbufs(struct stmmac_priv *priv) | ||
524 | { | ||
525 | int i; | ||
526 | |||
527 | for (i = 0; i < priv->dma_rx_size; i++) { | ||
528 | if (priv->rx_skbuff[i]) { | ||
529 | dma_unmap_single(priv->device, priv->rx_skbuff_dma[i], | ||
530 | priv->dma_buf_sz, DMA_FROM_DEVICE); | ||
531 | dev_kfree_skb_any(priv->rx_skbuff[i]); | ||
532 | } | ||
533 | priv->rx_skbuff[i] = NULL; | ||
534 | } | ||
535 | return; | ||
536 | } | ||
537 | |||
538 | static void dma_free_tx_skbufs(struct stmmac_priv *priv) | ||
539 | { | ||
540 | int i; | ||
541 | |||
542 | for (i = 0; i < priv->dma_tx_size; i++) { | ||
543 | if (priv->tx_skbuff[i] != NULL) { | ||
544 | struct dma_desc *p = priv->dma_tx + i; | ||
545 | if (p->des2) | ||
546 | dma_unmap_single(priv->device, p->des2, | ||
547 | priv->mac_type->ops->get_tx_len(p), | ||
548 | DMA_TO_DEVICE); | ||
549 | dev_kfree_skb_any(priv->tx_skbuff[i]); | ||
550 | priv->tx_skbuff[i] = NULL; | ||
551 | } | ||
552 | } | ||
553 | return; | ||
554 | } | ||
555 | |||
556 | static void free_dma_desc_resources(struct stmmac_priv *priv) | ||
557 | { | ||
558 | /* Release the DMA TX/RX socket buffers */ | ||
559 | dma_free_rx_skbufs(priv); | ||
560 | dma_free_tx_skbufs(priv); | ||
561 | |||
562 | /* Free the region of consistent memory previously allocated for | ||
563 | * the DMA */ | ||
564 | dma_free_coherent(priv->device, | ||
565 | priv->dma_tx_size * sizeof(struct dma_desc), | ||
566 | priv->dma_tx, priv->dma_tx_phy); | ||
567 | dma_free_coherent(priv->device, | ||
568 | priv->dma_rx_size * sizeof(struct dma_desc), | ||
569 | priv->dma_rx, priv->dma_rx_phy); | ||
570 | kfree(priv->rx_skbuff_dma); | ||
571 | kfree(priv->rx_skbuff); | ||
572 | kfree(priv->tx_skbuff); | ||
573 | |||
574 | return; | ||
575 | } | ||
576 | |||
577 | /** | ||
578 | * stmmac_dma_start_tx | ||
579 | * @ioaddr: device I/O address | ||
580 | * Description: this function starts the DMA tx process. | ||
581 | */ | ||
582 | static void stmmac_dma_start_tx(unsigned long ioaddr) | ||
583 | { | ||
584 | u32 value = readl(ioaddr + DMA_CONTROL); | ||
585 | value |= DMA_CONTROL_ST; | ||
586 | writel(value, ioaddr + DMA_CONTROL); | ||
587 | return; | ||
588 | } | ||
589 | |||
590 | static void stmmac_dma_stop_tx(unsigned long ioaddr) | ||
591 | { | ||
592 | u32 value = readl(ioaddr + DMA_CONTROL); | ||
593 | value &= ~DMA_CONTROL_ST; | ||
594 | writel(value, ioaddr + DMA_CONTROL); | ||
595 | return; | ||
596 | } | ||
597 | |||
598 | /** | ||
599 | * stmmac_dma_start_rx | ||
600 | * @ioaddr: device I/O address | ||
601 | * Description: this function starts the DMA rx process. | ||
602 | */ | ||
603 | static void stmmac_dma_start_rx(unsigned long ioaddr) | ||
604 | { | ||
605 | u32 value = readl(ioaddr + DMA_CONTROL); | ||
606 | value |= DMA_CONTROL_SR; | ||
607 | writel(value, ioaddr + DMA_CONTROL); | ||
608 | |||
609 | return; | ||
610 | } | ||
611 | |||
612 | static void stmmac_dma_stop_rx(unsigned long ioaddr) | ||
613 | { | ||
614 | u32 value = readl(ioaddr + DMA_CONTROL); | ||
615 | value &= ~DMA_CONTROL_SR; | ||
616 | writel(value, ioaddr + DMA_CONTROL); | ||
617 | |||
618 | return; | ||
619 | } | ||
620 | |||
621 | /** | ||
622 | * stmmac_dma_operation_mode - HW DMA operation mode | ||
623 | * @priv : pointer to the private device structure. | ||
624 | * Description: it sets the DMA operation mode: tx/rx DMA thresholds | ||
625 | * or Store-And-Forward capability. It also verifies the COE for the | ||
626 | * transmission in case of Giga ETH. | ||
627 | */ | ||
628 | static void stmmac_dma_operation_mode(struct stmmac_priv *priv) | ||
629 | { | ||
630 | if (!priv->is_gmac) { | ||
631 | /* MAC 10/100 */ | ||
632 | priv->mac_type->ops->dma_mode(priv->dev->base_addr, tc, 0); | ||
633 | priv->tx_coe = NO_HW_CSUM; | ||
634 | } else { | ||
635 | if ((priv->dev->mtu <= ETH_DATA_LEN) && (tx_coe)) { | ||
636 | priv->mac_type->ops->dma_mode(priv->dev->base_addr, | ||
637 | SF_DMA_MODE, SF_DMA_MODE); | ||
638 | tc = SF_DMA_MODE; | ||
639 | priv->tx_coe = HW_CSUM; | ||
640 | } else { | ||
641 | /* Checksum computation is performed in software. */ | ||
642 | priv->mac_type->ops->dma_mode(priv->dev->base_addr, tc, | ||
643 | SF_DMA_MODE); | ||
644 | priv->tx_coe = NO_HW_CSUM; | ||
645 | } | ||
646 | } | ||
647 | tx_coe = priv->tx_coe; | ||
648 | |||
649 | return; | ||
650 | } | ||
651 | |||
652 | #ifdef STMMAC_DEBUG | ||
653 | /** | ||
654 | * show_tx_process_state | ||
655 | * @status: tx descriptor status field | ||
656 | * Description: it shows the Transmit Process State for CSR5[22:20] | ||
657 | */ | ||
658 | static void show_tx_process_state(unsigned int status) | ||
659 | { | ||
660 | unsigned int state; | ||
661 | state = (status & DMA_STATUS_TS_MASK) >> DMA_STATUS_TS_SHIFT; | ||
662 | |||
663 | switch (state) { | ||
664 | case 0: | ||
665 | pr_info("- TX (Stopped): Reset or Stop command\n"); | ||
666 | break; | ||
667 | case 1: | ||
668 | pr_info("- TX (Running):Fetching the Tx desc\n"); | ||
669 | break; | ||
670 | case 2: | ||
671 | pr_info("- TX (Running): Waiting for end of tx\n"); | ||
672 | break; | ||
673 | case 3: | ||
674 | pr_info("- TX (Running): Reading the data " | ||
675 | "and queuing the data into the Tx buf\n"); | ||
676 | break; | ||
677 | case 6: | ||
678 | pr_info("- TX (Suspended): Tx Buff Underflow " | ||
679 | "or an unavailable Transmit descriptor\n"); | ||
680 | break; | ||
681 | case 7: | ||
682 | pr_info("- TX (Running): Closing Tx descriptor\n"); | ||
683 | break; | ||
684 | default: | ||
685 | break; | ||
686 | } | ||
687 | return; | ||
688 | } | ||
689 | |||
690 | /** | ||
691 | * show_rx_process_state | ||
692 | * @status: rx descriptor status field | ||
693 | * Description: it shows the Receive Process State for CSR5[19:17] | ||
694 | */ | ||
695 | static void show_rx_process_state(unsigned int status) | ||
696 | { | ||
697 | unsigned int state; | ||
698 | state = (status & DMA_STATUS_RS_MASK) >> DMA_STATUS_RS_SHIFT; | ||
699 | |||
700 | switch (state) { | ||
701 | case 0: | ||
702 | pr_info("- RX (Stopped): Reset or Stop command\n"); | ||
703 | break; | ||
704 | case 1: | ||
705 | pr_info("- RX (Running): Fetching the Rx desc\n"); | ||
706 | break; | ||
707 | case 2: | ||
708 | pr_info("- RX (Running):Checking for end of pkt\n"); | ||
709 | break; | ||
710 | case 3: | ||
711 | pr_info("- RX (Running): Waiting for Rx pkt\n"); | ||
712 | break; | ||
713 | case 4: | ||
714 | pr_info("- RX (Suspended): Unavailable Rx buf\n"); | ||
715 | break; | ||
716 | case 5: | ||
717 | pr_info("- RX (Running): Closing Rx descriptor\n"); | ||
718 | break; | ||
719 | case 6: | ||
720 | pr_info("- RX(Running): Flushing the current frame" | ||
721 | " from the Rx buf\n"); | ||
722 | break; | ||
723 | case 7: | ||
724 | pr_info("- RX (Running): Queuing the Rx frame" | ||
725 | " from the Rx buf into memory\n"); | ||
726 | break; | ||
727 | default: | ||
728 | break; | ||
729 | } | ||
730 | return; | ||
731 | } | ||
732 | #endif | ||
733 | |||
734 | /** | ||
735 | * stmmac_tx: | ||
736 | * @priv: private driver structure | ||
737 | * Description: it reclaims resources after transmission completes. | ||
738 | */ | ||
739 | static void stmmac_tx(struct stmmac_priv *priv) | ||
740 | { | ||
741 | unsigned int txsize = priv->dma_tx_size; | ||
742 | unsigned long ioaddr = priv->dev->base_addr; | ||
743 | |||
744 | while (priv->dirty_tx != priv->cur_tx) { | ||
745 | int last; | ||
746 | unsigned int entry = priv->dirty_tx % txsize; | ||
747 | struct sk_buff *skb = priv->tx_skbuff[entry]; | ||
748 | struct dma_desc *p = priv->dma_tx + entry; | ||
749 | |||
750 | /* Check if the descriptor is owned by the DMA. */ | ||
751 | if (priv->mac_type->ops->get_tx_owner(p)) | ||
752 | break; | ||
753 | |||
754 | /* Verify tx error by looking at the last segment */ | ||
755 | last = priv->mac_type->ops->get_tx_ls(p); | ||
756 | if (likely(last)) { | ||
757 | int tx_error = | ||
758 | priv->mac_type->ops->tx_status(&priv->dev->stats, | ||
759 | &priv->xstats, | ||
760 | p, ioaddr); | ||
761 | if (likely(tx_error == 0)) { | ||
762 | priv->dev->stats.tx_packets++; | ||
763 | priv->xstats.tx_pkt_n++; | ||
764 | } else | ||
765 | priv->dev->stats.tx_errors++; | ||
766 | } | ||
767 | TX_DBG("%s: curr %d, dirty %d\n", __func__, | ||
768 | priv->cur_tx, priv->dirty_tx); | ||
769 | |||
770 | if (likely(p->des2)) | ||
771 | dma_unmap_single(priv->device, p->des2, | ||
772 | priv->mac_type->ops->get_tx_len(p), | ||
773 | DMA_TO_DEVICE); | ||
774 | if (unlikely(p->des3)) | ||
775 | p->des3 = 0; | ||
776 | |||
777 | if (likely(skb != NULL)) { | ||
778 | /* | ||
779 | * If there's room in the queue (limit it to size) | ||
780 | * we add this skb back into the pool, | ||
781 | * if it's the right size. | ||
782 | */ | ||
783 | if ((skb_queue_len(&priv->rx_recycle) < | ||
784 | priv->dma_rx_size) && | ||
785 | skb_recycle_check(skb, priv->dma_buf_sz)) | ||
786 | __skb_queue_head(&priv->rx_recycle, skb); | ||
787 | else | ||
788 | dev_kfree_skb(skb); | ||
789 | |||
790 | priv->tx_skbuff[entry] = NULL; | ||
791 | } | ||
792 | |||
793 | priv->mac_type->ops->release_tx_desc(p); | ||
794 | |||
795 | entry = (++priv->dirty_tx) % txsize; | ||
796 | } | ||
797 | if (unlikely(netif_queue_stopped(priv->dev) && | ||
798 | stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv))) { | ||
799 | netif_tx_lock(priv->dev); | ||
800 | if (netif_queue_stopped(priv->dev) && | ||
801 | stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv)) { | ||
802 | TX_DBG("%s: restart transmit\n", __func__); | ||
803 | netif_wake_queue(priv->dev); | ||
804 | } | ||
805 | netif_tx_unlock(priv->dev); | ||
806 | } | ||
807 | return; | ||
808 | } | ||
809 | |||
810 | static inline void stmmac_enable_irq(struct stmmac_priv *priv) | ||
811 | { | ||
812 | #ifndef CONFIG_STMMAC_TIMER | ||
813 | writel(DMA_INTR_DEFAULT_MASK, priv->dev->base_addr + DMA_INTR_ENA); | ||
814 | #else | ||
815 | priv->tm->timer_start(tmrate); | ||
816 | #endif | ||
817 | } | ||
818 | |||
819 | static inline void stmmac_disable_irq(struct stmmac_priv *priv) | ||
820 | { | ||
821 | #ifndef CONFIG_STMMAC_TIMER | ||
822 | writel(0, priv->dev->base_addr + DMA_INTR_ENA); | ||
823 | #else | ||
824 | priv->tm->timer_stop(); | ||
825 | #endif | ||
826 | } | ||
827 | |||
828 | static int stmmac_has_work(struct stmmac_priv *priv) | ||
829 | { | ||
830 | unsigned int has_work = 0; | ||
831 | int rxret, tx_work = 0; | ||
832 | |||
833 | rxret = priv->mac_type->ops->get_rx_owner(priv->dma_rx + | ||
834 | (priv->cur_rx % priv->dma_rx_size)); | ||
835 | |||
836 | if (priv->dirty_tx != priv->cur_tx) | ||
837 | tx_work = 1; | ||
838 | |||
839 | if (likely(!rxret || tx_work)) | ||
840 | has_work = 1; | ||
841 | |||
842 | return has_work; | ||
843 | } | ||
844 | |||
845 | static inline void _stmmac_schedule(struct stmmac_priv *priv) | ||
846 | { | ||
847 | if (likely(stmmac_has_work(priv))) { | ||
848 | stmmac_disable_irq(priv); | ||
849 | napi_schedule(&priv->napi); | ||
850 | } | ||
851 | } | ||
852 | |||
853 | #ifdef CONFIG_STMMAC_TIMER | ||
854 | void stmmac_schedule(struct net_device *dev) | ||
855 | { | ||
856 | struct stmmac_priv *priv = netdev_priv(dev); | ||
857 | |||
858 | priv->xstats.sched_timer_n++; | ||
859 | |||
860 | _stmmac_schedule(priv); | ||
861 | |||
862 | return; | ||
863 | } | ||
864 | |||
865 | static void stmmac_no_timer_started(unsigned int x) | ||
866 | {; | ||
867 | }; | ||
868 | |||
869 | static void stmmac_no_timer_stopped(void) | ||
870 | {; | ||
871 | }; | ||
872 | #endif | ||
873 | |||
874 | /** | ||
875 | * stmmac_tx_err: | ||
876 | * @priv: pointer to the private device structure | ||
877 | * Description: it cleans the descriptors and restarts the transmission | ||
878 | * in case of errors. | ||
879 | */ | ||
880 | static void stmmac_tx_err(struct stmmac_priv *priv) | ||
881 | { | ||
882 | netif_stop_queue(priv->dev); | ||
883 | |||
884 | stmmac_dma_stop_tx(priv->dev->base_addr); | ||
885 | dma_free_tx_skbufs(priv); | ||
886 | priv->mac_type->ops->init_tx_desc(priv->dma_tx, priv->dma_tx_size); | ||
887 | priv->dirty_tx = 0; | ||
888 | priv->cur_tx = 0; | ||
889 | stmmac_dma_start_tx(priv->dev->base_addr); | ||
890 | |||
891 | priv->dev->stats.tx_errors++; | ||
892 | netif_wake_queue(priv->dev); | ||
893 | |||
894 | return; | ||
895 | } | ||
896 | |||
897 | /** | ||
898 | * stmmac_dma_interrupt - Interrupt handler for the driver | ||
899 | * @dev: net device structure | ||
900 | * Description: Interrupt handler for the driver (DMA). | ||
901 | */ | ||
902 | static void stmmac_dma_interrupt(struct net_device *dev) | ||
903 | { | ||
904 | unsigned long ioaddr = dev->base_addr; | ||
905 | struct stmmac_priv *priv = netdev_priv(dev); | ||
906 | /* read the status register (CSR5) */ | ||
907 | u32 intr_status = readl(ioaddr + DMA_STATUS); | ||
908 | |||
909 | DBG(intr, INFO, "%s: [CSR5: 0x%08x]\n", __func__, intr_status); | ||
910 | |||
911 | #ifdef STMMAC_DEBUG | ||
912 | /* It displays the DMA transmit process state (CSR5 register) */ | ||
913 | if (netif_msg_tx_done(priv)) | ||
914 | show_tx_process_state(intr_status); | ||
915 | if (netif_msg_rx_status(priv)) | ||
916 | show_rx_process_state(intr_status); | ||
917 | #endif | ||
918 | /* ABNORMAL interrupts */ | ||
919 | if (unlikely(intr_status & DMA_STATUS_AIS)) { | ||
920 | DBG(intr, INFO, "CSR5[15] DMA ABNORMAL IRQ: "); | ||
921 | if (unlikely(intr_status & DMA_STATUS_UNF)) { | ||
922 | DBG(intr, INFO, "transmit underflow\n"); | ||
923 | if (unlikely(tc != SF_DMA_MODE) | ||
924 | && (tc <= 256)) { | ||
925 | /* Try to bump up the threshold */ | ||
926 | tc += 64; | ||
927 | priv->mac_type->ops->dma_mode(ioaddr, tc, | ||
928 | SF_DMA_MODE); | ||
929 | priv->xstats.threshold = tc; | ||
930 | } | ||
931 | stmmac_tx_err(priv); | ||
932 | priv->xstats.tx_undeflow_irq++; | ||
933 | } | ||
934 | if (unlikely(intr_status & DMA_STATUS_TJT)) { | ||
935 | DBG(intr, INFO, "transmit jabber\n"); | ||
936 | priv->xstats.tx_jabber_irq++; | ||
937 | } | ||
938 | if (unlikely(intr_status & DMA_STATUS_OVF)) { | ||
939 | DBG(intr, INFO, "recv overflow\n"); | ||
940 | priv->xstats.rx_overflow_irq++; | ||
941 | } | ||
942 | if (unlikely(intr_status & DMA_STATUS_RU)) { | ||
943 | DBG(intr, INFO, "receive buffer unavailable\n"); | ||
944 | priv->xstats.rx_buf_unav_irq++; | ||
945 | } | ||
946 | if (unlikely(intr_status & DMA_STATUS_RPS)) { | ||
947 | DBG(intr, INFO, "receive process stopped\n"); | ||
948 | priv->xstats.rx_process_stopped_irq++; | ||
949 | } | ||
950 | if (unlikely(intr_status & DMA_STATUS_RWT)) { | ||
951 | DBG(intr, INFO, "receive watchdog\n"); | ||
952 | priv->xstats.rx_watchdog_irq++; | ||
953 | } | ||
954 | if (unlikely(intr_status & DMA_STATUS_ETI)) { | ||
955 | DBG(intr, INFO, "transmit early interrupt\n"); | ||
956 | priv->xstats.tx_early_irq++; | ||
957 | } | ||
958 | if (unlikely(intr_status & DMA_STATUS_TPS)) { | ||
959 | DBG(intr, INFO, "transmit process stopped\n"); | ||
960 | priv->xstats.tx_process_stopped_irq++; | ||
961 | stmmac_tx_err(priv); | ||
962 | } | ||
963 | if (unlikely(intr_status & DMA_STATUS_FBI)) { | ||
964 | DBG(intr, INFO, "fatal bus error\n"); | ||
965 | priv->xstats.fatal_bus_error_irq++; | ||
966 | stmmac_tx_err(priv); | ||
967 | } | ||
968 | } | ||
969 | |||
970 | /* TX/RX NORMAL interrupts */ | ||
971 | if (intr_status & DMA_STATUS_NIS) { | ||
972 | priv->xstats.normal_irq_n++; | ||
973 | if (likely((intr_status & DMA_STATUS_RI) || | ||
974 | (intr_status & (DMA_STATUS_TI)))) | ||
975 | _stmmac_schedule(priv); | ||
976 | } | ||
977 | |||
978 | /* Optional hardware blocks, interrupts should be disabled */ | ||
979 | if (unlikely(intr_status & | ||
980 | (DMA_STATUS_GPI | DMA_STATUS_GMI | DMA_STATUS_GLI))) | ||
981 | pr_info("%s: unexpected status %08x\n", __func__, intr_status); | ||
982 | |||
983 | /* Clear the interrupt by writing a logic 1 to the CSR5[15-0] */ | ||
984 | writel((intr_status & 0x1ffff), ioaddr + DMA_STATUS); | ||
985 | |||
986 | DBG(intr, INFO, "\n\n"); | ||
987 | |||
988 | return; | ||
989 | } | ||
990 | |||
991 | /** | ||
992 | * stmmac_open - open entry point of the driver | ||
993 | * @dev : pointer to the device structure. | ||
994 | * Description: | ||
995 | * This function is the open entry point of the driver. | ||
996 | * Return value: | ||
997 | * 0 on success and an appropriate (-)ve integer as defined in errno.h | ||
998 | * file on failure. | ||
999 | */ | ||
1000 | static int stmmac_open(struct net_device *dev) | ||
1001 | { | ||
1002 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1003 | unsigned long ioaddr = dev->base_addr; | ||
1004 | int ret; | ||
1005 | |||
1006 | /* Check that the MAC address is valid. If its not, refuse | ||
1007 | * to bring the device up. The user must specify an | ||
1008 | * address using the following linux command: | ||
1009 | * ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx */ | ||
1010 | if (!is_valid_ether_addr(dev->dev_addr)) { | ||
1011 | random_ether_addr(dev->dev_addr); | ||
1012 | pr_warning("%s: generated random MAC address %pM\n", dev->name, | ||
1013 | dev->dev_addr); | ||
1014 | } | ||
1015 | |||
1016 | stmmac_verify_args(); | ||
1017 | |||
1018 | ret = stmmac_init_phy(dev); | ||
1019 | if (unlikely(ret)) { | ||
1020 | pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret); | ||
1021 | return ret; | ||
1022 | } | ||
1023 | |||
1024 | /* Request the IRQ lines */ | ||
1025 | ret = request_irq(dev->irq, &stmmac_interrupt, | ||
1026 | IRQF_SHARED, dev->name, dev); | ||
1027 | if (unlikely(ret < 0)) { | ||
1028 | pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n", | ||
1029 | __func__, dev->irq, ret); | ||
1030 | return ret; | ||
1031 | } | ||
1032 | |||
1033 | #ifdef CONFIG_STMMAC_TIMER | ||
1034 | priv->tm = kmalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); | ||
1035 | if (unlikely(priv->tm == NULL)) { | ||
1036 | pr_err("%s: ERROR: timer memory alloc failed \n", __func__); | ||
1037 | return -ENOMEM; | ||
1038 | } | ||
1039 | priv->tm->freq = tmrate; | ||
1040 | |||
1041 | /* Test if the HW timer can be actually used. | ||
1042 | * In case of failure continue with no timer. */ | ||
1043 | if (unlikely((stmmac_open_ext_timer(dev, priv->tm)) < 0)) { | ||
1044 | pr_warning("stmmaceth: cannot attach the HW timer\n"); | ||
1045 | tmrate = 0; | ||
1046 | priv->tm->freq = 0; | ||
1047 | priv->tm->timer_start = stmmac_no_timer_started; | ||
1048 | priv->tm->timer_stop = stmmac_no_timer_stopped; | ||
1049 | } | ||
1050 | #endif | ||
1051 | |||
1052 | /* Create and initialize the TX/RX descriptors chains. */ | ||
1053 | priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); | ||
1054 | priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); | ||
1055 | priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); | ||
1056 | init_dma_desc_rings(dev); | ||
1057 | |||
1058 | /* DMA initialization and SW reset */ | ||
1059 | if (unlikely(priv->mac_type->ops->dma_init(ioaddr, | ||
1060 | priv->pbl, priv->dma_tx_phy, priv->dma_rx_phy) < 0)) { | ||
1061 | |||
1062 | pr_err("%s: DMA initialization failed\n", __func__); | ||
1063 | return -1; | ||
1064 | } | ||
1065 | |||
1066 | /* Copy the MAC addr into the HW */ | ||
1067 | priv->mac_type->ops->set_umac_addr(ioaddr, dev->dev_addr, 0); | ||
1068 | /* Initialize the MAC Core */ | ||
1069 | priv->mac_type->ops->core_init(ioaddr); | ||
1070 | |||
1071 | priv->shutdown = 0; | ||
1072 | |||
1073 | /* Initialise the MMC (if present) to disable all interrupts. */ | ||
1074 | writel(0xffffffff, ioaddr + MMC_HIGH_INTR_MASK); | ||
1075 | writel(0xffffffff, ioaddr + MMC_LOW_INTR_MASK); | ||
1076 | |||
1077 | /* Enable the MAC Rx/Tx */ | ||
1078 | stmmac_mac_enable_rx(ioaddr); | ||
1079 | stmmac_mac_enable_tx(ioaddr); | ||
1080 | |||
1081 | /* Set the HW DMA mode and the COE */ | ||
1082 | stmmac_dma_operation_mode(priv); | ||
1083 | |||
1084 | /* Extra statistics */ | ||
1085 | memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats)); | ||
1086 | priv->xstats.threshold = tc; | ||
1087 | |||
1088 | /* Start the ball rolling... */ | ||
1089 | DBG(probe, DEBUG, "%s: DMA RX/TX processes started...\n", dev->name); | ||
1090 | stmmac_dma_start_tx(ioaddr); | ||
1091 | stmmac_dma_start_rx(ioaddr); | ||
1092 | |||
1093 | #ifdef CONFIG_STMMAC_TIMER | ||
1094 | priv->tm->timer_start(tmrate); | ||
1095 | #endif | ||
1096 | /* Dump DMA/MAC registers */ | ||
1097 | if (netif_msg_hw(priv)) { | ||
1098 | priv->mac_type->ops->dump_mac_regs(ioaddr); | ||
1099 | priv->mac_type->ops->dump_dma_regs(ioaddr); | ||
1100 | } | ||
1101 | |||
1102 | if (priv->phydev) | ||
1103 | phy_start(priv->phydev); | ||
1104 | |||
1105 | napi_enable(&priv->napi); | ||
1106 | skb_queue_head_init(&priv->rx_recycle); | ||
1107 | netif_start_queue(dev); | ||
1108 | return 0; | ||
1109 | } | ||
1110 | |||
1111 | /** | ||
1112 | * stmmac_release - close entry point of the driver | ||
1113 | * @dev : device pointer. | ||
1114 | * Description: | ||
1115 | * This is the stop entry point of the driver. | ||
1116 | */ | ||
1117 | static int stmmac_release(struct net_device *dev) | ||
1118 | { | ||
1119 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1120 | |||
1121 | /* Stop and disconnect the PHY */ | ||
1122 | if (priv->phydev) { | ||
1123 | phy_stop(priv->phydev); | ||
1124 | phy_disconnect(priv->phydev); | ||
1125 | priv->phydev = NULL; | ||
1126 | } | ||
1127 | |||
1128 | netif_stop_queue(dev); | ||
1129 | |||
1130 | #ifdef CONFIG_STMMAC_TIMER | ||
1131 | /* Stop and release the timer */ | ||
1132 | stmmac_close_ext_timer(); | ||
1133 | if (priv->tm != NULL) | ||
1134 | kfree(priv->tm); | ||
1135 | #endif | ||
1136 | napi_disable(&priv->napi); | ||
1137 | skb_queue_purge(&priv->rx_recycle); | ||
1138 | |||
1139 | /* Free the IRQ lines */ | ||
1140 | free_irq(dev->irq, dev); | ||
1141 | |||
1142 | /* Stop TX/RX DMA and clear the descriptors */ | ||
1143 | stmmac_dma_stop_tx(dev->base_addr); | ||
1144 | stmmac_dma_stop_rx(dev->base_addr); | ||
1145 | |||
1146 | /* Release and free the Rx/Tx resources */ | ||
1147 | free_dma_desc_resources(priv); | ||
1148 | |||
1149 | /* Disable the MAC core */ | ||
1150 | stmmac_mac_disable_tx(dev->base_addr); | ||
1151 | stmmac_mac_disable_rx(dev->base_addr); | ||
1152 | |||
1153 | netif_carrier_off(dev); | ||
1154 | |||
1155 | return 0; | ||
1156 | } | ||
1157 | |||
1158 | /* | ||
1159 | * To perform emulated hardware segmentation on skb. | ||
1160 | */ | ||
1161 | static int stmmac_sw_tso(struct stmmac_priv *priv, struct sk_buff *skb) | ||
1162 | { | ||
1163 | struct sk_buff *segs, *curr_skb; | ||
1164 | int gso_segs = skb_shinfo(skb)->gso_segs; | ||
1165 | |||
1166 | /* Estimate the number of fragments in the worst case */ | ||
1167 | if (unlikely(stmmac_tx_avail(priv) < gso_segs)) { | ||
1168 | netif_stop_queue(priv->dev); | ||
1169 | TX_DBG(KERN_ERR "%s: TSO BUG! Tx Ring full when queue awake\n", | ||
1170 | __func__); | ||
1171 | if (stmmac_tx_avail(priv) < gso_segs) | ||
1172 | return NETDEV_TX_BUSY; | ||
1173 | |||
1174 | netif_wake_queue(priv->dev); | ||
1175 | } | ||
1176 | TX_DBG("\tstmmac_sw_tso: segmenting: skb %p (len %d)\n", | ||
1177 | skb, skb->len); | ||
1178 | |||
1179 | segs = skb_gso_segment(skb, priv->dev->features & ~NETIF_F_TSO); | ||
1180 | if (unlikely(IS_ERR(segs))) | ||
1181 | goto sw_tso_end; | ||
1182 | |||
1183 | do { | ||
1184 | curr_skb = segs; | ||
1185 | segs = segs->next; | ||
1186 | TX_DBG("\t\tcurrent skb->len: %d, *curr %p," | ||
1187 | "*next %p\n", curr_skb->len, curr_skb, segs); | ||
1188 | curr_skb->next = NULL; | ||
1189 | stmmac_xmit(curr_skb, priv->dev); | ||
1190 | } while (segs); | ||
1191 | |||
1192 | sw_tso_end: | ||
1193 | dev_kfree_skb(skb); | ||
1194 | |||
1195 | return NETDEV_TX_OK; | ||
1196 | } | ||
1197 | |||
1198 | static unsigned int stmmac_handle_jumbo_frames(struct sk_buff *skb, | ||
1199 | struct net_device *dev, | ||
1200 | int csum_insertion) | ||
1201 | { | ||
1202 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1203 | unsigned int nopaged_len = skb_headlen(skb); | ||
1204 | unsigned int txsize = priv->dma_tx_size; | ||
1205 | unsigned int entry = priv->cur_tx % txsize; | ||
1206 | struct dma_desc *desc = priv->dma_tx + entry; | ||
1207 | |||
1208 | if (nopaged_len > BUF_SIZE_8KiB) { | ||
1209 | |||
1210 | int buf2_size = nopaged_len - BUF_SIZE_8KiB; | ||
1211 | |||
1212 | desc->des2 = dma_map_single(priv->device, skb->data, | ||
1213 | BUF_SIZE_8KiB, DMA_TO_DEVICE); | ||
1214 | desc->des3 = desc->des2 + BUF_SIZE_4KiB; | ||
1215 | priv->mac_type->ops->prepare_tx_desc(desc, 1, BUF_SIZE_8KiB, | ||
1216 | csum_insertion); | ||
1217 | |||
1218 | entry = (++priv->cur_tx) % txsize; | ||
1219 | desc = priv->dma_tx + entry; | ||
1220 | |||
1221 | desc->des2 = dma_map_single(priv->device, | ||
1222 | skb->data + BUF_SIZE_8KiB, | ||
1223 | buf2_size, DMA_TO_DEVICE); | ||
1224 | desc->des3 = desc->des2 + BUF_SIZE_4KiB; | ||
1225 | priv->mac_type->ops->prepare_tx_desc(desc, 0, | ||
1226 | buf2_size, csum_insertion); | ||
1227 | priv->mac_type->ops->set_tx_owner(desc); | ||
1228 | priv->tx_skbuff[entry] = NULL; | ||
1229 | } else { | ||
1230 | desc->des2 = dma_map_single(priv->device, skb->data, | ||
1231 | nopaged_len, DMA_TO_DEVICE); | ||
1232 | desc->des3 = desc->des2 + BUF_SIZE_4KiB; | ||
1233 | priv->mac_type->ops->prepare_tx_desc(desc, 1, nopaged_len, | ||
1234 | csum_insertion); | ||
1235 | } | ||
1236 | return entry; | ||
1237 | } | ||
1238 | |||
1239 | /** | ||
1240 | * stmmac_xmit: | ||
1241 | * @skb : the socket buffer | ||
1242 | * @dev : device pointer | ||
1243 | * Description : Tx entry point of the driver. | ||
1244 | */ | ||
1245 | static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) | ||
1246 | { | ||
1247 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1248 | unsigned int txsize = priv->dma_tx_size; | ||
1249 | unsigned int entry; | ||
1250 | int i, csum_insertion = 0; | ||
1251 | int nfrags = skb_shinfo(skb)->nr_frags; | ||
1252 | struct dma_desc *desc, *first; | ||
1253 | |||
1254 | if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) { | ||
1255 | if (!netif_queue_stopped(dev)) { | ||
1256 | netif_stop_queue(dev); | ||
1257 | /* This is a hard error, log it. */ | ||
1258 | pr_err("%s: BUG! Tx Ring full when queue awake\n", | ||
1259 | __func__); | ||
1260 | } | ||
1261 | return NETDEV_TX_BUSY; | ||
1262 | } | ||
1263 | |||
1264 | entry = priv->cur_tx % txsize; | ||
1265 | |||
1266 | #ifdef STMMAC_XMIT_DEBUG | ||
1267 | if ((skb->len > ETH_FRAME_LEN) || nfrags) | ||
1268 | pr_info("stmmac xmit:\n" | ||
1269 | "\tskb addr %p - len: %d - nopaged_len: %d\n" | ||
1270 | "\tn_frags: %d - ip_summed: %d - %s gso\n", | ||
1271 | skb, skb->len, skb_headlen(skb), nfrags, skb->ip_summed, | ||
1272 | !skb_is_gso(skb) ? "isn't" : "is"); | ||
1273 | #endif | ||
1274 | |||
1275 | if (unlikely(skb_is_gso(skb))) | ||
1276 | return stmmac_sw_tso(priv, skb); | ||
1277 | |||
1278 | if (likely((skb->ip_summed == CHECKSUM_PARTIAL))) { | ||
1279 | if (likely(priv->tx_coe == NO_HW_CSUM)) | ||
1280 | skb_checksum_help(skb); | ||
1281 | else | ||
1282 | csum_insertion = 1; | ||
1283 | } | ||
1284 | |||
1285 | desc = priv->dma_tx + entry; | ||
1286 | first = desc; | ||
1287 | |||
1288 | #ifdef STMMAC_XMIT_DEBUG | ||
1289 | if ((nfrags > 0) || (skb->len > ETH_FRAME_LEN)) | ||
1290 | pr_debug("stmmac xmit: skb len: %d, nopaged_len: %d,\n" | ||
1291 | "\t\tn_frags: %d, ip_summed: %d\n", | ||
1292 | skb->len, skb_headlen(skb), nfrags, skb->ip_summed); | ||
1293 | #endif | ||
1294 | priv->tx_skbuff[entry] = skb; | ||
1295 | if (unlikely(skb->len >= BUF_SIZE_4KiB)) { | ||
1296 | entry = stmmac_handle_jumbo_frames(skb, dev, csum_insertion); | ||
1297 | desc = priv->dma_tx + entry; | ||
1298 | } else { | ||
1299 | unsigned int nopaged_len = skb_headlen(skb); | ||
1300 | desc->des2 = dma_map_single(priv->device, skb->data, | ||
1301 | nopaged_len, DMA_TO_DEVICE); | ||
1302 | priv->mac_type->ops->prepare_tx_desc(desc, 1, nopaged_len, | ||
1303 | csum_insertion); | ||
1304 | } | ||
1305 | |||
1306 | for (i = 0; i < nfrags; i++) { | ||
1307 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
1308 | int len = frag->size; | ||
1309 | |||
1310 | entry = (++priv->cur_tx) % txsize; | ||
1311 | desc = priv->dma_tx + entry; | ||
1312 | |||
1313 | TX_DBG("\t[entry %d] segment len: %d\n", entry, len); | ||
1314 | desc->des2 = dma_map_page(priv->device, frag->page, | ||
1315 | frag->page_offset, | ||
1316 | len, DMA_TO_DEVICE); | ||
1317 | priv->tx_skbuff[entry] = NULL; | ||
1318 | priv->mac_type->ops->prepare_tx_desc(desc, 0, len, | ||
1319 | csum_insertion); | ||
1320 | priv->mac_type->ops->set_tx_owner(desc); | ||
1321 | } | ||
1322 | |||
1323 | /* Interrupt on completition only for the latest segment */ | ||
1324 | priv->mac_type->ops->close_tx_desc(desc); | ||
1325 | #ifdef CONFIG_STMMAC_TIMER | ||
1326 | /* Clean IC while using timers */ | ||
1327 | priv->mac_type->ops->clear_tx_ic(desc); | ||
1328 | #endif | ||
1329 | /* To avoid raise condition */ | ||
1330 | priv->mac_type->ops->set_tx_owner(first); | ||
1331 | |||
1332 | priv->cur_tx++; | ||
1333 | |||
1334 | #ifdef STMMAC_XMIT_DEBUG | ||
1335 | if (netif_msg_pktdata(priv)) { | ||
1336 | pr_info("stmmac xmit: current=%d, dirty=%d, entry=%d, " | ||
1337 | "first=%p, nfrags=%d\n", | ||
1338 | (priv->cur_tx % txsize), (priv->dirty_tx % txsize), | ||
1339 | entry, first, nfrags); | ||
1340 | display_ring(priv->dma_tx, txsize); | ||
1341 | pr_info(">>> frame to be transmitted: "); | ||
1342 | print_pkt(skb->data, skb->len); | ||
1343 | } | ||
1344 | #endif | ||
1345 | if (unlikely(stmmac_tx_avail(priv) <= (MAX_SKB_FRAGS + 1))) { | ||
1346 | TX_DBG("%s: stop transmitted packets\n", __func__); | ||
1347 | netif_stop_queue(dev); | ||
1348 | } | ||
1349 | |||
1350 | dev->stats.tx_bytes += skb->len; | ||
1351 | |||
1352 | /* CSR1 enables the transmit DMA to check for new descriptor */ | ||
1353 | writel(1, dev->base_addr + DMA_XMT_POLL_DEMAND); | ||
1354 | |||
1355 | return NETDEV_TX_OK; | ||
1356 | } | ||
1357 | |||
1358 | static inline void stmmac_rx_refill(struct stmmac_priv *priv) | ||
1359 | { | ||
1360 | unsigned int rxsize = priv->dma_rx_size; | ||
1361 | int bfsize = priv->dma_buf_sz; | ||
1362 | struct dma_desc *p = priv->dma_rx; | ||
1363 | |||
1364 | for (; priv->cur_rx - priv->dirty_rx > 0; priv->dirty_rx++) { | ||
1365 | unsigned int entry = priv->dirty_rx % rxsize; | ||
1366 | if (likely(priv->rx_skbuff[entry] == NULL)) { | ||
1367 | struct sk_buff *skb; | ||
1368 | |||
1369 | skb = __skb_dequeue(&priv->rx_recycle); | ||
1370 | if (skb == NULL) | ||
1371 | skb = netdev_alloc_skb_ip_align(priv->dev, | ||
1372 | bfsize); | ||
1373 | |||
1374 | if (unlikely(skb == NULL)) | ||
1375 | break; | ||
1376 | |||
1377 | priv->rx_skbuff[entry] = skb; | ||
1378 | priv->rx_skbuff_dma[entry] = | ||
1379 | dma_map_single(priv->device, skb->data, bfsize, | ||
1380 | DMA_FROM_DEVICE); | ||
1381 | |||
1382 | (p + entry)->des2 = priv->rx_skbuff_dma[entry]; | ||
1383 | if (unlikely(priv->is_gmac)) { | ||
1384 | if (bfsize >= BUF_SIZE_8KiB) | ||
1385 | (p + entry)->des3 = | ||
1386 | (p + entry)->des2 + BUF_SIZE_8KiB; | ||
1387 | } | ||
1388 | RX_DBG(KERN_INFO "\trefill entry #%d\n", entry); | ||
1389 | } | ||
1390 | priv->mac_type->ops->set_rx_owner(p + entry); | ||
1391 | } | ||
1392 | return; | ||
1393 | } | ||
1394 | |||
1395 | static int stmmac_rx(struct stmmac_priv *priv, int limit) | ||
1396 | { | ||
1397 | unsigned int rxsize = priv->dma_rx_size; | ||
1398 | unsigned int entry = priv->cur_rx % rxsize; | ||
1399 | unsigned int next_entry; | ||
1400 | unsigned int count = 0; | ||
1401 | struct dma_desc *p = priv->dma_rx + entry; | ||
1402 | struct dma_desc *p_next; | ||
1403 | |||
1404 | #ifdef STMMAC_RX_DEBUG | ||
1405 | if (netif_msg_hw(priv)) { | ||
1406 | pr_debug(">>> stmmac_rx: descriptor ring:\n"); | ||
1407 | display_ring(priv->dma_rx, rxsize); | ||
1408 | } | ||
1409 | #endif | ||
1410 | count = 0; | ||
1411 | while (!priv->mac_type->ops->get_rx_owner(p)) { | ||
1412 | int status; | ||
1413 | |||
1414 | if (count >= limit) | ||
1415 | break; | ||
1416 | |||
1417 | count++; | ||
1418 | |||
1419 | next_entry = (++priv->cur_rx) % rxsize; | ||
1420 | p_next = priv->dma_rx + next_entry; | ||
1421 | prefetch(p_next); | ||
1422 | |||
1423 | /* read the status of the incoming frame */ | ||
1424 | status = (priv->mac_type->ops->rx_status(&priv->dev->stats, | ||
1425 | &priv->xstats, p)); | ||
1426 | if (unlikely(status == discard_frame)) | ||
1427 | priv->dev->stats.rx_errors++; | ||
1428 | else { | ||
1429 | struct sk_buff *skb; | ||
1430 | /* Length should omit the CRC */ | ||
1431 | int frame_len = | ||
1432 | priv->mac_type->ops->get_rx_frame_len(p) - 4; | ||
1433 | |||
1434 | #ifdef STMMAC_RX_DEBUG | ||
1435 | if (frame_len > ETH_FRAME_LEN) | ||
1436 | pr_debug("\tRX frame size %d, COE status: %d\n", | ||
1437 | frame_len, status); | ||
1438 | |||
1439 | if (netif_msg_hw(priv)) | ||
1440 | pr_debug("\tdesc: %p [entry %d] buff=0x%x\n", | ||
1441 | p, entry, p->des2); | ||
1442 | #endif | ||
1443 | skb = priv->rx_skbuff[entry]; | ||
1444 | if (unlikely(!skb)) { | ||
1445 | pr_err("%s: Inconsistent Rx descriptor chain\n", | ||
1446 | priv->dev->name); | ||
1447 | priv->dev->stats.rx_dropped++; | ||
1448 | break; | ||
1449 | } | ||
1450 | prefetch(skb->data - NET_IP_ALIGN); | ||
1451 | priv->rx_skbuff[entry] = NULL; | ||
1452 | |||
1453 | skb_put(skb, frame_len); | ||
1454 | dma_unmap_single(priv->device, | ||
1455 | priv->rx_skbuff_dma[entry], | ||
1456 | priv->dma_buf_sz, DMA_FROM_DEVICE); | ||
1457 | #ifdef STMMAC_RX_DEBUG | ||
1458 | if (netif_msg_pktdata(priv)) { | ||
1459 | pr_info(" frame received (%dbytes)", frame_len); | ||
1460 | print_pkt(skb->data, frame_len); | ||
1461 | } | ||
1462 | #endif | ||
1463 | skb->protocol = eth_type_trans(skb, priv->dev); | ||
1464 | |||
1465 | if (unlikely(status == csum_none)) { | ||
1466 | /* always for the old mac 10/100 */ | ||
1467 | skb->ip_summed = CHECKSUM_NONE; | ||
1468 | netif_receive_skb(skb); | ||
1469 | } else { | ||
1470 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
1471 | napi_gro_receive(&priv->napi, skb); | ||
1472 | } | ||
1473 | |||
1474 | priv->dev->stats.rx_packets++; | ||
1475 | priv->dev->stats.rx_bytes += frame_len; | ||
1476 | priv->dev->last_rx = jiffies; | ||
1477 | } | ||
1478 | entry = next_entry; | ||
1479 | p = p_next; /* use prefetched values */ | ||
1480 | } | ||
1481 | |||
1482 | stmmac_rx_refill(priv); | ||
1483 | |||
1484 | priv->xstats.rx_pkt_n += count; | ||
1485 | |||
1486 | return count; | ||
1487 | } | ||
1488 | |||
1489 | /** | ||
1490 | * stmmac_poll - stmmac poll method (NAPI) | ||
1491 | * @napi : pointer to the napi structure. | ||
1492 | * @budget : maximum number of packets that the current CPU can receive from | ||
1493 | * all interfaces. | ||
1494 | * Description : | ||
1495 | * This function implements the the reception process. | ||
1496 | * Also it runs the TX completion thread | ||
1497 | */ | ||
1498 | static int stmmac_poll(struct napi_struct *napi, int budget) | ||
1499 | { | ||
1500 | struct stmmac_priv *priv = container_of(napi, struct stmmac_priv, napi); | ||
1501 | int work_done = 0; | ||
1502 | |||
1503 | priv->xstats.poll_n++; | ||
1504 | stmmac_tx(priv); | ||
1505 | work_done = stmmac_rx(priv, budget); | ||
1506 | |||
1507 | if (work_done < budget) { | ||
1508 | napi_complete(napi); | ||
1509 | stmmac_enable_irq(priv); | ||
1510 | } | ||
1511 | return work_done; | ||
1512 | } | ||
1513 | |||
1514 | /** | ||
1515 | * stmmac_tx_timeout | ||
1516 | * @dev : Pointer to net device structure | ||
1517 | * Description: this function is called when a packet transmission fails to | ||
1518 | * complete within a reasonable tmrate. The driver will mark the error in the | ||
1519 | * netdev structure and arrange for the device to be reset to a sane state | ||
1520 | * in order to transmit a new packet. | ||
1521 | */ | ||
1522 | static void stmmac_tx_timeout(struct net_device *dev) | ||
1523 | { | ||
1524 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1525 | |||
1526 | /* Clear Tx resources and restart transmitting again */ | ||
1527 | stmmac_tx_err(priv); | ||
1528 | return; | ||
1529 | } | ||
1530 | |||
1531 | /* Configuration changes (passed on by ifconfig) */ | ||
1532 | static int stmmac_config(struct net_device *dev, struct ifmap *map) | ||
1533 | { | ||
1534 | if (dev->flags & IFF_UP) /* can't act on a running interface */ | ||
1535 | return -EBUSY; | ||
1536 | |||
1537 | /* Don't allow changing the I/O address */ | ||
1538 | if (map->base_addr != dev->base_addr) { | ||
1539 | pr_warning("%s: can't change I/O address\n", dev->name); | ||
1540 | return -EOPNOTSUPP; | ||
1541 | } | ||
1542 | |||
1543 | /* Don't allow changing the IRQ */ | ||
1544 | if (map->irq != dev->irq) { | ||
1545 | pr_warning("%s: can't change IRQ number %d\n", | ||
1546 | dev->name, dev->irq); | ||
1547 | return -EOPNOTSUPP; | ||
1548 | } | ||
1549 | |||
1550 | /* ignore other fields */ | ||
1551 | return 0; | ||
1552 | } | ||
1553 | |||
1554 | /** | ||
1555 | * stmmac_multicast_list - entry point for multicast addressing | ||
1556 | * @dev : pointer to the device structure | ||
1557 | * Description: | ||
1558 | * This function is a driver entry point which gets called by the kernel | ||
1559 | * whenever multicast addresses must be enabled/disabled. | ||
1560 | * Return value: | ||
1561 | * void. | ||
1562 | */ | ||
1563 | static void stmmac_multicast_list(struct net_device *dev) | ||
1564 | { | ||
1565 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1566 | |||
1567 | spin_lock(&priv->lock); | ||
1568 | priv->mac_type->ops->set_filter(dev); | ||
1569 | spin_unlock(&priv->lock); | ||
1570 | return; | ||
1571 | } | ||
1572 | |||
1573 | /** | ||
1574 | * stmmac_change_mtu - entry point to change MTU size for the device. | ||
1575 | * @dev : device pointer. | ||
1576 | * @new_mtu : the new MTU size for the device. | ||
1577 | * Description: the Maximum Transfer Unit (MTU) is used by the network layer | ||
1578 | * to drive packet transmission. Ethernet has an MTU of 1500 octets | ||
1579 | * (ETH_DATA_LEN). This value can be changed with ifconfig. | ||
1580 | * Return value: | ||
1581 | * 0 on success and an appropriate (-)ve integer as defined in errno.h | ||
1582 | * file on failure. | ||
1583 | */ | ||
1584 | static int stmmac_change_mtu(struct net_device *dev, int new_mtu) | ||
1585 | { | ||
1586 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1587 | int max_mtu; | ||
1588 | |||
1589 | if (netif_running(dev)) { | ||
1590 | pr_err("%s: must be stopped to change its MTU\n", dev->name); | ||
1591 | return -EBUSY; | ||
1592 | } | ||
1593 | |||
1594 | if (priv->is_gmac) | ||
1595 | max_mtu = JUMBO_LEN; | ||
1596 | else | ||
1597 | max_mtu = ETH_DATA_LEN; | ||
1598 | |||
1599 | if ((new_mtu < 46) || (new_mtu > max_mtu)) { | ||
1600 | pr_err("%s: invalid MTU, max MTU is: %d\n", dev->name, max_mtu); | ||
1601 | return -EINVAL; | ||
1602 | } | ||
1603 | |||
1604 | dev->mtu = new_mtu; | ||
1605 | |||
1606 | return 0; | ||
1607 | } | ||
1608 | |||
1609 | static irqreturn_t stmmac_interrupt(int irq, void *dev_id) | ||
1610 | { | ||
1611 | struct net_device *dev = (struct net_device *)dev_id; | ||
1612 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1613 | |||
1614 | if (unlikely(!dev)) { | ||
1615 | pr_err("%s: invalid dev pointer\n", __func__); | ||
1616 | return IRQ_NONE; | ||
1617 | } | ||
1618 | |||
1619 | if (priv->is_gmac) { | ||
1620 | unsigned long ioaddr = dev->base_addr; | ||
1621 | /* To handle GMAC own interrupts */ | ||
1622 | priv->mac_type->ops->host_irq_status(ioaddr); | ||
1623 | } | ||
1624 | stmmac_dma_interrupt(dev); | ||
1625 | |||
1626 | return IRQ_HANDLED; | ||
1627 | } | ||
1628 | |||
1629 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1630 | /* Polling receive - used by NETCONSOLE and other diagnostic tools | ||
1631 | * to allow network I/O with interrupts disabled. */ | ||
1632 | static void stmmac_poll_controller(struct net_device *dev) | ||
1633 | { | ||
1634 | disable_irq(dev->irq); | ||
1635 | stmmac_interrupt(dev->irq, dev); | ||
1636 | enable_irq(dev->irq); | ||
1637 | } | ||
1638 | #endif | ||
1639 | |||
1640 | /** | ||
1641 | * stmmac_ioctl - Entry point for the Ioctl | ||
1642 | * @dev: Device pointer. | ||
1643 | * @rq: An IOCTL specefic structure, that can contain a pointer to | ||
1644 | * a proprietary structure used to pass information to the driver. | ||
1645 | * @cmd: IOCTL command | ||
1646 | * Description: | ||
1647 | * Currently there are no special functionality supported in IOCTL, just the | ||
1648 | * phy_mii_ioctl(...) can be invoked. | ||
1649 | */ | ||
1650 | static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | ||
1651 | { | ||
1652 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1653 | int ret = -EOPNOTSUPP; | ||
1654 | |||
1655 | if (!netif_running(dev)) | ||
1656 | return -EINVAL; | ||
1657 | |||
1658 | switch (cmd) { | ||
1659 | case SIOCGMIIPHY: | ||
1660 | case SIOCGMIIREG: | ||
1661 | case SIOCSMIIREG: | ||
1662 | if (!priv->phydev) | ||
1663 | return -EINVAL; | ||
1664 | |||
1665 | spin_lock(&priv->lock); | ||
1666 | ret = phy_mii_ioctl(priv->phydev, if_mii(rq), cmd); | ||
1667 | spin_unlock(&priv->lock); | ||
1668 | default: | ||
1669 | break; | ||
1670 | } | ||
1671 | return ret; | ||
1672 | } | ||
1673 | |||
1674 | #ifdef STMMAC_VLAN_TAG_USED | ||
1675 | static void stmmac_vlan_rx_register(struct net_device *dev, | ||
1676 | struct vlan_group *grp) | ||
1677 | { | ||
1678 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1679 | |||
1680 | DBG(probe, INFO, "%s: Setting vlgrp to %p\n", dev->name, grp); | ||
1681 | |||
1682 | spin_lock(&priv->lock); | ||
1683 | priv->vlgrp = grp; | ||
1684 | spin_unlock(&priv->lock); | ||
1685 | |||
1686 | return; | ||
1687 | } | ||
1688 | #endif | ||
1689 | |||
1690 | static const struct net_device_ops stmmac_netdev_ops = { | ||
1691 | .ndo_open = stmmac_open, | ||
1692 | .ndo_start_xmit = stmmac_xmit, | ||
1693 | .ndo_stop = stmmac_release, | ||
1694 | .ndo_change_mtu = stmmac_change_mtu, | ||
1695 | .ndo_set_multicast_list = stmmac_multicast_list, | ||
1696 | .ndo_tx_timeout = stmmac_tx_timeout, | ||
1697 | .ndo_do_ioctl = stmmac_ioctl, | ||
1698 | .ndo_set_config = stmmac_config, | ||
1699 | #ifdef STMMAC_VLAN_TAG_USED | ||
1700 | .ndo_vlan_rx_register = stmmac_vlan_rx_register, | ||
1701 | #endif | ||
1702 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1703 | .ndo_poll_controller = stmmac_poll_controller, | ||
1704 | #endif | ||
1705 | .ndo_set_mac_address = eth_mac_addr, | ||
1706 | }; | ||
1707 | |||
1708 | /** | ||
1709 | * stmmac_probe - Initialization of the adapter . | ||
1710 | * @dev : device pointer | ||
1711 | * Description: The function initializes the network device structure for | ||
1712 | * the STMMAC driver. It also calls the low level routines | ||
1713 | * in order to init the HW (i.e. the DMA engine) | ||
1714 | */ | ||
1715 | static int stmmac_probe(struct net_device *dev) | ||
1716 | { | ||
1717 | int ret = 0; | ||
1718 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1719 | |||
1720 | ether_setup(dev); | ||
1721 | |||
1722 | dev->netdev_ops = &stmmac_netdev_ops; | ||
1723 | stmmac_set_ethtool_ops(dev); | ||
1724 | |||
1725 | dev->features |= (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA); | ||
1726 | dev->watchdog_timeo = msecs_to_jiffies(watchdog); | ||
1727 | #ifdef STMMAC_VLAN_TAG_USED | ||
1728 | /* Both mac100 and gmac support receive VLAN tag detection */ | ||
1729 | dev->features |= NETIF_F_HW_VLAN_RX; | ||
1730 | #endif | ||
1731 | priv->msg_enable = netif_msg_init(debug, default_msg_level); | ||
1732 | |||
1733 | if (priv->is_gmac) | ||
1734 | priv->rx_csum = 1; | ||
1735 | |||
1736 | if (flow_ctrl) | ||
1737 | priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ | ||
1738 | |||
1739 | priv->pause = pause; | ||
1740 | netif_napi_add(dev, &priv->napi, stmmac_poll, 64); | ||
1741 | |||
1742 | /* Get the MAC address */ | ||
1743 | priv->mac_type->ops->get_umac_addr(dev->base_addr, dev->dev_addr, 0); | ||
1744 | |||
1745 | if (!is_valid_ether_addr(dev->dev_addr)) | ||
1746 | pr_warning("\tno valid MAC address;" | ||
1747 | "please, use ifconfig or nwhwconfig!\n"); | ||
1748 | |||
1749 | ret = register_netdev(dev); | ||
1750 | if (ret) { | ||
1751 | pr_err("%s: ERROR %i registering the device\n", | ||
1752 | __func__, ret); | ||
1753 | return -ENODEV; | ||
1754 | } | ||
1755 | |||
1756 | DBG(probe, DEBUG, "%s: Scatter/Gather: %s - HW checksums: %s\n", | ||
1757 | dev->name, (dev->features & NETIF_F_SG) ? "on" : "off", | ||
1758 | (dev->features & NETIF_F_HW_CSUM) ? "on" : "off"); | ||
1759 | |||
1760 | spin_lock_init(&priv->lock); | ||
1761 | |||
1762 | return ret; | ||
1763 | } | ||
1764 | |||
1765 | /** | ||
1766 | * stmmac_mac_device_setup | ||
1767 | * @dev : device pointer | ||
1768 | * Description: select and initialise the mac device (mac100 or Gmac). | ||
1769 | */ | ||
1770 | static int stmmac_mac_device_setup(struct net_device *dev) | ||
1771 | { | ||
1772 | struct stmmac_priv *priv = netdev_priv(dev); | ||
1773 | unsigned long ioaddr = dev->base_addr; | ||
1774 | |||
1775 | struct mac_device_info *device; | ||
1776 | |||
1777 | if (priv->is_gmac) | ||
1778 | device = gmac_setup(ioaddr); | ||
1779 | else | ||
1780 | device = mac100_setup(ioaddr); | ||
1781 | |||
1782 | if (!device) | ||
1783 | return -ENOMEM; | ||
1784 | |||
1785 | priv->mac_type = device; | ||
1786 | |||
1787 | priv->wolenabled = priv->mac_type->hw.pmt; /* PMT supported */ | ||
1788 | if (priv->wolenabled == PMT_SUPPORTED) | ||
1789 | priv->wolopts = WAKE_MAGIC; /* Magic Frame */ | ||
1790 | |||
1791 | return 0; | ||
1792 | } | ||
1793 | |||
1794 | static int stmmacphy_dvr_probe(struct platform_device *pdev) | ||
1795 | { | ||
1796 | struct plat_stmmacphy_data *plat_dat; | ||
1797 | plat_dat = (struct plat_stmmacphy_data *)((pdev->dev).platform_data); | ||
1798 | |||
1799 | pr_debug("stmmacphy_dvr_probe: added phy for bus %d\n", | ||
1800 | plat_dat->bus_id); | ||
1801 | |||
1802 | return 0; | ||
1803 | } | ||
1804 | |||
1805 | static int stmmacphy_dvr_remove(struct platform_device *pdev) | ||
1806 | { | ||
1807 | return 0; | ||
1808 | } | ||
1809 | |||
1810 | static struct platform_driver stmmacphy_driver = { | ||
1811 | .driver = { | ||
1812 | .name = PHY_RESOURCE_NAME, | ||
1813 | }, | ||
1814 | .probe = stmmacphy_dvr_probe, | ||
1815 | .remove = stmmacphy_dvr_remove, | ||
1816 | }; | ||
1817 | |||
1818 | /** | ||
1819 | * stmmac_associate_phy | ||
1820 | * @dev: pointer to device structure | ||
1821 | * @data: points to the private structure. | ||
1822 | * Description: Scans through all the PHYs we have registered and checks if | ||
1823 | * any are associated with our MAC. If so, then just fill in | ||
1824 | * the blanks in our local context structure | ||
1825 | */ | ||
1826 | static int stmmac_associate_phy(struct device *dev, void *data) | ||
1827 | { | ||
1828 | struct stmmac_priv *priv = (struct stmmac_priv *)data; | ||
1829 | struct plat_stmmacphy_data *plat_dat; | ||
1830 | |||
1831 | plat_dat = (struct plat_stmmacphy_data *)(dev->platform_data); | ||
1832 | |||
1833 | DBG(probe, DEBUG, "%s: checking phy for bus %d\n", __func__, | ||
1834 | plat_dat->bus_id); | ||
1835 | |||
1836 | /* Check that this phy is for the MAC being initialised */ | ||
1837 | if (priv->bus_id != plat_dat->bus_id) | ||
1838 | return 0; | ||
1839 | |||
1840 | /* OK, this PHY is connected to the MAC. | ||
1841 | Go ahead and get the parameters */ | ||
1842 | DBG(probe, DEBUG, "%s: OK. Found PHY config\n", __func__); | ||
1843 | priv->phy_irq = | ||
1844 | platform_get_irq_byname(to_platform_device(dev), "phyirq"); | ||
1845 | DBG(probe, DEBUG, "%s: PHY irq on bus %d is %d\n", __func__, | ||
1846 | plat_dat->bus_id, priv->phy_irq); | ||
1847 | |||
1848 | /* Override with kernel parameters if supplied XXX CRS XXX | ||
1849 | * this needs to have multiple instances */ | ||
1850 | if ((phyaddr >= 0) && (phyaddr <= 31)) | ||
1851 | plat_dat->phy_addr = phyaddr; | ||
1852 | |||
1853 | priv->phy_addr = plat_dat->phy_addr; | ||
1854 | priv->phy_mask = plat_dat->phy_mask; | ||
1855 | priv->phy_interface = plat_dat->interface; | ||
1856 | priv->phy_reset = plat_dat->phy_reset; | ||
1857 | |||
1858 | DBG(probe, DEBUG, "%s: exiting\n", __func__); | ||
1859 | return 1; /* forces exit of driver_for_each_device() */ | ||
1860 | } | ||
1861 | |||
1862 | /** | ||
1863 | * stmmac_dvr_probe | ||
1864 | * @pdev: platform device pointer | ||
1865 | * Description: the driver is initialized through platform_device. | ||
1866 | */ | ||
1867 | static int stmmac_dvr_probe(struct platform_device *pdev) | ||
1868 | { | ||
1869 | int ret = 0; | ||
1870 | struct resource *res; | ||
1871 | unsigned int *addr = NULL; | ||
1872 | struct net_device *ndev = NULL; | ||
1873 | struct stmmac_priv *priv; | ||
1874 | struct plat_stmmacenet_data *plat_dat; | ||
1875 | |||
1876 | pr_info("STMMAC driver:\n\tplatform registration... "); | ||
1877 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1878 | if (!res) { | ||
1879 | ret = -ENODEV; | ||
1880 | goto out; | ||
1881 | } | ||
1882 | pr_info("done!\n"); | ||
1883 | |||
1884 | if (!request_mem_region(res->start, (res->end - res->start), | ||
1885 | pdev->name)) { | ||
1886 | pr_err("%s: ERROR: memory allocation failed" | ||
1887 | "cannot get the I/O addr 0x%x\n", | ||
1888 | __func__, (unsigned int)res->start); | ||
1889 | ret = -EBUSY; | ||
1890 | goto out; | ||
1891 | } | ||
1892 | |||
1893 | addr = ioremap(res->start, (res->end - res->start)); | ||
1894 | if (!addr) { | ||
1895 | pr_err("%s: ERROR: memory mapping failed \n", __func__); | ||
1896 | ret = -ENOMEM; | ||
1897 | goto out; | ||
1898 | } | ||
1899 | |||
1900 | ndev = alloc_etherdev(sizeof(struct stmmac_priv)); | ||
1901 | if (!ndev) { | ||
1902 | pr_err("%s: ERROR: allocating the device\n", __func__); | ||
1903 | ret = -ENOMEM; | ||
1904 | goto out; | ||
1905 | } | ||
1906 | |||
1907 | SET_NETDEV_DEV(ndev, &pdev->dev); | ||
1908 | |||
1909 | /* Get the MAC information */ | ||
1910 | ndev->irq = platform_get_irq_byname(pdev, "macirq"); | ||
1911 | if (ndev->irq == -ENXIO) { | ||
1912 | pr_err("%s: ERROR: MAC IRQ configuration " | ||
1913 | "information not found\n", __func__); | ||
1914 | ret = -ENODEV; | ||
1915 | goto out; | ||
1916 | } | ||
1917 | |||
1918 | priv = netdev_priv(ndev); | ||
1919 | priv->device = &(pdev->dev); | ||
1920 | priv->dev = ndev; | ||
1921 | plat_dat = (struct plat_stmmacenet_data *)((pdev->dev).platform_data); | ||
1922 | priv->bus_id = plat_dat->bus_id; | ||
1923 | priv->pbl = plat_dat->pbl; /* TLI */ | ||
1924 | priv->is_gmac = plat_dat->has_gmac; /* GMAC is on board */ | ||
1925 | |||
1926 | platform_set_drvdata(pdev, ndev); | ||
1927 | |||
1928 | /* Set the I/O base addr */ | ||
1929 | ndev->base_addr = (unsigned long)addr; | ||
1930 | |||
1931 | /* MAC HW revice detection */ | ||
1932 | ret = stmmac_mac_device_setup(ndev); | ||
1933 | if (ret < 0) | ||
1934 | goto out; | ||
1935 | |||
1936 | /* Network Device Registration */ | ||
1937 | ret = stmmac_probe(ndev); | ||
1938 | if (ret < 0) | ||
1939 | goto out; | ||
1940 | |||
1941 | /* associate a PHY - it is provided by another platform bus */ | ||
1942 | if (!driver_for_each_device | ||
1943 | (&(stmmacphy_driver.driver), NULL, (void *)priv, | ||
1944 | stmmac_associate_phy)) { | ||
1945 | pr_err("No PHY device is associated with this MAC!\n"); | ||
1946 | ret = -ENODEV; | ||
1947 | goto out; | ||
1948 | } | ||
1949 | |||
1950 | priv->fix_mac_speed = plat_dat->fix_mac_speed; | ||
1951 | priv->bsp_priv = plat_dat->bsp_priv; | ||
1952 | |||
1953 | pr_info("\t%s - (dev. name: %s - id: %d, IRQ #%d\n" | ||
1954 | "\tIO base addr: 0x%08x)\n", ndev->name, pdev->name, | ||
1955 | pdev->id, ndev->irq, (unsigned int)addr); | ||
1956 | |||
1957 | /* MDIO bus Registration */ | ||
1958 | pr_debug("\tMDIO bus (id: %d)...", priv->bus_id); | ||
1959 | ret = stmmac_mdio_register(ndev); | ||
1960 | if (ret < 0) | ||
1961 | goto out; | ||
1962 | pr_debug("registered!\n"); | ||
1963 | |||
1964 | out: | ||
1965 | if (ret < 0) { | ||
1966 | platform_set_drvdata(pdev, NULL); | ||
1967 | release_mem_region(res->start, (res->end - res->start)); | ||
1968 | if (addr != NULL) | ||
1969 | iounmap(addr); | ||
1970 | } | ||
1971 | |||
1972 | return ret; | ||
1973 | } | ||
1974 | |||
1975 | /** | ||
1976 | * stmmac_dvr_remove | ||
1977 | * @pdev: platform device pointer | ||
1978 | * Description: this function resets the TX/RX processes, disables the MAC RX/TX | ||
1979 | * changes the link status, releases the DMA descriptor rings, | ||
1980 | * unregisters the MDIO bus and unmaps the allocated memory. | ||
1981 | */ | ||
1982 | static int stmmac_dvr_remove(struct platform_device *pdev) | ||
1983 | { | ||
1984 | struct net_device *ndev = platform_get_drvdata(pdev); | ||
1985 | struct resource *res; | ||
1986 | |||
1987 | pr_info("%s:\n\tremoving driver", __func__); | ||
1988 | |||
1989 | stmmac_dma_stop_rx(ndev->base_addr); | ||
1990 | stmmac_dma_stop_tx(ndev->base_addr); | ||
1991 | |||
1992 | stmmac_mac_disable_rx(ndev->base_addr); | ||
1993 | stmmac_mac_disable_tx(ndev->base_addr); | ||
1994 | |||
1995 | netif_carrier_off(ndev); | ||
1996 | |||
1997 | stmmac_mdio_unregister(ndev); | ||
1998 | |||
1999 | platform_set_drvdata(pdev, NULL); | ||
2000 | unregister_netdev(ndev); | ||
2001 | |||
2002 | iounmap((void *)ndev->base_addr); | ||
2003 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
2004 | release_mem_region(res->start, (res->end - res->start)); | ||
2005 | |||
2006 | free_netdev(ndev); | ||
2007 | |||
2008 | return 0; | ||
2009 | } | ||
2010 | |||
2011 | #ifdef CONFIG_PM | ||
2012 | static int stmmac_suspend(struct platform_device *pdev, pm_message_t state) | ||
2013 | { | ||
2014 | struct net_device *dev = platform_get_drvdata(pdev); | ||
2015 | struct stmmac_priv *priv = netdev_priv(dev); | ||
2016 | int dis_ic = 0; | ||
2017 | |||
2018 | if (!dev || !netif_running(dev)) | ||
2019 | return 0; | ||
2020 | |||
2021 | spin_lock(&priv->lock); | ||
2022 | |||
2023 | if (state.event == PM_EVENT_SUSPEND) { | ||
2024 | netif_device_detach(dev); | ||
2025 | netif_stop_queue(dev); | ||
2026 | if (priv->phydev) | ||
2027 | phy_stop(priv->phydev); | ||
2028 | |||
2029 | #ifdef CONFIG_STMMAC_TIMER | ||
2030 | priv->tm->timer_stop(); | ||
2031 | dis_ic = 1; | ||
2032 | #endif | ||
2033 | napi_disable(&priv->napi); | ||
2034 | |||
2035 | /* Stop TX/RX DMA */ | ||
2036 | stmmac_dma_stop_tx(dev->base_addr); | ||
2037 | stmmac_dma_stop_rx(dev->base_addr); | ||
2038 | /* Clear the Rx/Tx descriptors */ | ||
2039 | priv->mac_type->ops->init_rx_desc(priv->dma_rx, | ||
2040 | priv->dma_rx_size, dis_ic); | ||
2041 | priv->mac_type->ops->init_tx_desc(priv->dma_tx, | ||
2042 | priv->dma_tx_size); | ||
2043 | |||
2044 | stmmac_mac_disable_tx(dev->base_addr); | ||
2045 | |||
2046 | if (device_may_wakeup(&(pdev->dev))) { | ||
2047 | /* Enable Power down mode by programming the PMT regs */ | ||
2048 | if (priv->wolenabled == PMT_SUPPORTED) | ||
2049 | priv->mac_type->ops->pmt(dev->base_addr, | ||
2050 | priv->wolopts); | ||
2051 | } else { | ||
2052 | stmmac_mac_disable_rx(dev->base_addr); | ||
2053 | } | ||
2054 | } else { | ||
2055 | priv->shutdown = 1; | ||
2056 | /* Although this can appear slightly redundant it actually | ||
2057 | * makes fast the standby operation and guarantees the driver | ||
2058 | * working if hibernation is on media. */ | ||
2059 | stmmac_release(dev); | ||
2060 | } | ||
2061 | |||
2062 | spin_unlock(&priv->lock); | ||
2063 | return 0; | ||
2064 | } | ||
2065 | |||
2066 | static int stmmac_resume(struct platform_device *pdev) | ||
2067 | { | ||
2068 | struct net_device *dev = platform_get_drvdata(pdev); | ||
2069 | struct stmmac_priv *priv = netdev_priv(dev); | ||
2070 | unsigned long ioaddr = dev->base_addr; | ||
2071 | |||
2072 | if (!netif_running(dev)) | ||
2073 | return 0; | ||
2074 | |||
2075 | spin_lock(&priv->lock); | ||
2076 | |||
2077 | if (priv->shutdown) { | ||
2078 | /* Re-open the interface and re-init the MAC/DMA | ||
2079 | and the rings. */ | ||
2080 | stmmac_open(dev); | ||
2081 | goto out_resume; | ||
2082 | } | ||
2083 | |||
2084 | /* Power Down bit, into the PM register, is cleared | ||
2085 | * automatically as soon as a magic packet or a Wake-up frame | ||
2086 | * is received. Anyway, it's better to manually clear | ||
2087 | * this bit because it can generate problems while resuming | ||
2088 | * from another devices (e.g. serial console). */ | ||
2089 | if (device_may_wakeup(&(pdev->dev))) | ||
2090 | if (priv->wolenabled == PMT_SUPPORTED) | ||
2091 | priv->mac_type->ops->pmt(dev->base_addr, 0); | ||
2092 | |||
2093 | netif_device_attach(dev); | ||
2094 | |||
2095 | /* Enable the MAC and DMA */ | ||
2096 | stmmac_mac_enable_rx(ioaddr); | ||
2097 | stmmac_mac_enable_tx(ioaddr); | ||
2098 | stmmac_dma_start_tx(ioaddr); | ||
2099 | stmmac_dma_start_rx(ioaddr); | ||
2100 | |||
2101 | #ifdef CONFIG_STMMAC_TIMER | ||
2102 | priv->tm->timer_start(tmrate); | ||
2103 | #endif | ||
2104 | napi_enable(&priv->napi); | ||
2105 | |||
2106 | if (priv->phydev) | ||
2107 | phy_start(priv->phydev); | ||
2108 | |||
2109 | netif_start_queue(dev); | ||
2110 | |||
2111 | out_resume: | ||
2112 | spin_unlock(&priv->lock); | ||
2113 | return 0; | ||
2114 | } | ||
2115 | #endif | ||
2116 | |||
2117 | static struct platform_driver stmmac_driver = { | ||
2118 | .driver = { | ||
2119 | .name = STMMAC_RESOURCE_NAME, | ||
2120 | }, | ||
2121 | .probe = stmmac_dvr_probe, | ||
2122 | .remove = stmmac_dvr_remove, | ||
2123 | #ifdef CONFIG_PM | ||
2124 | .suspend = stmmac_suspend, | ||
2125 | .resume = stmmac_resume, | ||
2126 | #endif | ||
2127 | |||
2128 | }; | ||
2129 | |||
2130 | /** | ||
2131 | * stmmac_init_module - Entry point for the driver | ||
2132 | * Description: This function is the entry point for the driver. | ||
2133 | */ | ||
2134 | static int __init stmmac_init_module(void) | ||
2135 | { | ||
2136 | int ret; | ||
2137 | |||
2138 | if (platform_driver_register(&stmmacphy_driver)) { | ||
2139 | pr_err("No PHY devices registered!\n"); | ||
2140 | return -ENODEV; | ||
2141 | } | ||
2142 | |||
2143 | ret = platform_driver_register(&stmmac_driver); | ||
2144 | return ret; | ||
2145 | } | ||
2146 | |||
2147 | /** | ||
2148 | * stmmac_cleanup_module - Cleanup routine for the driver | ||
2149 | * Description: This function is the cleanup routine for the driver. | ||
2150 | */ | ||
2151 | static void __exit stmmac_cleanup_module(void) | ||
2152 | { | ||
2153 | platform_driver_unregister(&stmmacphy_driver); | ||
2154 | platform_driver_unregister(&stmmac_driver); | ||
2155 | } | ||
2156 | |||
2157 | #ifndef MODULE | ||
2158 | static int __init stmmac_cmdline_opt(char *str) | ||
2159 | { | ||
2160 | char *opt; | ||
2161 | |||
2162 | if (!str || !*str) | ||
2163 | return -EINVAL; | ||
2164 | while ((opt = strsep(&str, ",")) != NULL) { | ||
2165 | if (!strncmp(opt, "debug:", 6)) | ||
2166 | strict_strtoul(opt + 6, 0, (unsigned long *)&debug); | ||
2167 | else if (!strncmp(opt, "phyaddr:", 8)) | ||
2168 | strict_strtoul(opt + 8, 0, (unsigned long *)&phyaddr); | ||
2169 | else if (!strncmp(opt, "dma_txsize:", 11)) | ||
2170 | strict_strtoul(opt + 11, 0, | ||
2171 | (unsigned long *)&dma_txsize); | ||
2172 | else if (!strncmp(opt, "dma_rxsize:", 11)) | ||
2173 | strict_strtoul(opt + 11, 0, | ||
2174 | (unsigned long *)&dma_rxsize); | ||
2175 | else if (!strncmp(opt, "buf_sz:", 7)) | ||
2176 | strict_strtoul(opt + 7, 0, (unsigned long *)&buf_sz); | ||
2177 | else if (!strncmp(opt, "tc:", 3)) | ||
2178 | strict_strtoul(opt + 3, 0, (unsigned long *)&tc); | ||
2179 | else if (!strncmp(opt, "tx_coe:", 7)) | ||
2180 | strict_strtoul(opt + 7, 0, (unsigned long *)&tx_coe); | ||
2181 | else if (!strncmp(opt, "watchdog:", 9)) | ||
2182 | strict_strtoul(opt + 9, 0, (unsigned long *)&watchdog); | ||
2183 | else if (!strncmp(opt, "flow_ctrl:", 10)) | ||
2184 | strict_strtoul(opt + 10, 0, | ||
2185 | (unsigned long *)&flow_ctrl); | ||
2186 | else if (!strncmp(opt, "pause:", 6)) | ||
2187 | strict_strtoul(opt + 6, 0, (unsigned long *)&pause); | ||
2188 | #ifdef CONFIG_STMMAC_TIMER | ||
2189 | else if (!strncmp(opt, "tmrate:", 7)) | ||
2190 | strict_strtoul(opt + 7, 0, (unsigned long *)&tmrate); | ||
2191 | #endif | ||
2192 | } | ||
2193 | return 0; | ||
2194 | } | ||
2195 | |||
2196 | __setup("stmmaceth=", stmmac_cmdline_opt); | ||
2197 | #endif | ||
2198 | |||
2199 | module_init(stmmac_init_module); | ||
2200 | module_exit(stmmac_cleanup_module); | ||
2201 | |||
2202 | MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet driver"); | ||
2203 | MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); | ||
2204 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/stmmac/stmmac_mdio.c b/drivers/net/stmmac/stmmac_mdio.c new file mode 100644 index 000000000000..8498552a22fc --- /dev/null +++ b/drivers/net/stmmac/stmmac_mdio.c | |||
@@ -0,0 +1,217 @@ | |||
1 | /******************************************************************************* | ||
2 | STMMAC Ethernet Driver -- MDIO bus implementation | ||
3 | Provides Bus interface for MII registers | ||
4 | |||
5 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify it | ||
8 | under the terms and conditions of the GNU General Public License, | ||
9 | version 2, as published by the Free Software Foundation. | ||
10 | |||
11 | This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License along with | ||
17 | this program; if not, write to the Free Software Foundation, Inc., | ||
18 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | |||
20 | The full GNU General Public License is included in this distribution in | ||
21 | the file called "COPYING". | ||
22 | |||
23 | Author: Carl Shaw <carl.shaw@st.com> | ||
24 | Maintainer: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
25 | *******************************************************************************/ | ||
26 | |||
27 | #include <linux/netdevice.h> | ||
28 | #include <linux/mii.h> | ||
29 | #include <linux/phy.h> | ||
30 | |||
31 | #include "stmmac.h" | ||
32 | |||
33 | #define MII_BUSY 0x00000001 | ||
34 | #define MII_WRITE 0x00000002 | ||
35 | |||
36 | /** | ||
37 | * stmmac_mdio_read | ||
38 | * @bus: points to the mii_bus structure | ||
39 | * @phyaddr: MII addr reg bits 15-11 | ||
40 | * @phyreg: MII addr reg bits 10-6 | ||
41 | * Description: it reads data from the MII register from within the phy device. | ||
42 | * For the 7111 GMAC, we must set the bit 0 in the MII address register while | ||
43 | * accessing the PHY registers. | ||
44 | * Fortunately, it seems this has no drawback for the 7109 MAC. | ||
45 | */ | ||
46 | static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg) | ||
47 | { | ||
48 | struct net_device *ndev = bus->priv; | ||
49 | struct stmmac_priv *priv = netdev_priv(ndev); | ||
50 | unsigned long ioaddr = ndev->base_addr; | ||
51 | unsigned int mii_address = priv->mac_type->hw.mii.addr; | ||
52 | unsigned int mii_data = priv->mac_type->hw.mii.data; | ||
53 | |||
54 | int data; | ||
55 | u16 regValue = (((phyaddr << 11) & (0x0000F800)) | | ||
56 | ((phyreg << 6) & (0x000007C0))); | ||
57 | regValue |= MII_BUSY; /* in case of GMAC */ | ||
58 | |||
59 | do {} while (((readl(ioaddr + mii_address)) & MII_BUSY) == 1); | ||
60 | writel(regValue, ioaddr + mii_address); | ||
61 | do {} while (((readl(ioaddr + mii_address)) & MII_BUSY) == 1); | ||
62 | |||
63 | /* Read the data from the MII data register */ | ||
64 | data = (int)readl(ioaddr + mii_data); | ||
65 | |||
66 | return data; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * stmmac_mdio_write | ||
71 | * @bus: points to the mii_bus structure | ||
72 | * @phyaddr: MII addr reg bits 15-11 | ||
73 | * @phyreg: MII addr reg bits 10-6 | ||
74 | * @phydata: phy data | ||
75 | * Description: it writes the data into the MII register from within the device. | ||
76 | */ | ||
77 | static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg, | ||
78 | u16 phydata) | ||
79 | { | ||
80 | struct net_device *ndev = bus->priv; | ||
81 | struct stmmac_priv *priv = netdev_priv(ndev); | ||
82 | unsigned long ioaddr = ndev->base_addr; | ||
83 | unsigned int mii_address = priv->mac_type->hw.mii.addr; | ||
84 | unsigned int mii_data = priv->mac_type->hw.mii.data; | ||
85 | |||
86 | u16 value = | ||
87 | (((phyaddr << 11) & (0x0000F800)) | ((phyreg << 6) & (0x000007C0))) | ||
88 | | MII_WRITE; | ||
89 | |||
90 | value |= MII_BUSY; | ||
91 | |||
92 | /* Wait until any existing MII operation is complete */ | ||
93 | do {} while (((readl(ioaddr + mii_address)) & MII_BUSY) == 1); | ||
94 | |||
95 | /* Set the MII address register to write */ | ||
96 | writel(phydata, ioaddr + mii_data); | ||
97 | writel(value, ioaddr + mii_address); | ||
98 | |||
99 | /* Wait until any existing MII operation is complete */ | ||
100 | do {} while (((readl(ioaddr + mii_address)) & MII_BUSY) == 1); | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * stmmac_mdio_reset | ||
107 | * @bus: points to the mii_bus structure | ||
108 | * Description: reset the MII bus | ||
109 | */ | ||
110 | static int stmmac_mdio_reset(struct mii_bus *bus) | ||
111 | { | ||
112 | struct net_device *ndev = bus->priv; | ||
113 | struct stmmac_priv *priv = netdev_priv(ndev); | ||
114 | unsigned long ioaddr = ndev->base_addr; | ||
115 | unsigned int mii_address = priv->mac_type->hw.mii.addr; | ||
116 | |||
117 | if (priv->phy_reset) { | ||
118 | pr_debug("stmmac_mdio_reset: calling phy_reset\n"); | ||
119 | priv->phy_reset(priv->bsp_priv); | ||
120 | } | ||
121 | |||
122 | /* This is a workaround for problems with the STE101P PHY. | ||
123 | * It doesn't complete its reset until at least one clock cycle | ||
124 | * on MDC, so perform a dummy mdio read. | ||
125 | */ | ||
126 | writel(0, ioaddr + mii_address); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * stmmac_mdio_register | ||
133 | * @ndev: net device structure | ||
134 | * Description: it registers the MII bus | ||
135 | */ | ||
136 | int stmmac_mdio_register(struct net_device *ndev) | ||
137 | { | ||
138 | int err = 0; | ||
139 | struct mii_bus *new_bus; | ||
140 | int *irqlist; | ||
141 | struct stmmac_priv *priv = netdev_priv(ndev); | ||
142 | int addr, found; | ||
143 | |||
144 | new_bus = mdiobus_alloc(); | ||
145 | if (new_bus == NULL) | ||
146 | return -ENOMEM; | ||
147 | |||
148 | irqlist = kzalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); | ||
149 | if (irqlist == NULL) { | ||
150 | err = -ENOMEM; | ||
151 | goto irqlist_alloc_fail; | ||
152 | } | ||
153 | |||
154 | /* Assign IRQ to phy at address phy_addr */ | ||
155 | if (priv->phy_addr != -1) | ||
156 | irqlist[priv->phy_addr] = priv->phy_irq; | ||
157 | |||
158 | new_bus->name = "STMMAC MII Bus"; | ||
159 | new_bus->read = &stmmac_mdio_read; | ||
160 | new_bus->write = &stmmac_mdio_write; | ||
161 | new_bus->reset = &stmmac_mdio_reset; | ||
162 | snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", priv->bus_id); | ||
163 | new_bus->priv = ndev; | ||
164 | new_bus->irq = irqlist; | ||
165 | new_bus->phy_mask = priv->phy_mask; | ||
166 | new_bus->parent = priv->device; | ||
167 | err = mdiobus_register(new_bus); | ||
168 | if (err != 0) { | ||
169 | pr_err("%s: Cannot register as MDIO bus\n", new_bus->name); | ||
170 | goto bus_register_fail; | ||
171 | } | ||
172 | |||
173 | priv->mii = new_bus; | ||
174 | |||
175 | found = 0; | ||
176 | for (addr = 0; addr < 32; addr++) { | ||
177 | struct phy_device *phydev = new_bus->phy_map[addr]; | ||
178 | if (phydev) { | ||
179 | if (priv->phy_addr == -1) { | ||
180 | priv->phy_addr = addr; | ||
181 | phydev->irq = priv->phy_irq; | ||
182 | irqlist[addr] = priv->phy_irq; | ||
183 | } | ||
184 | pr_info("%s: PHY ID %08x at %d IRQ %d (%s)%s\n", | ||
185 | ndev->name, phydev->phy_id, addr, | ||
186 | phydev->irq, dev_name(&phydev->dev), | ||
187 | (addr == priv->phy_addr) ? " active" : ""); | ||
188 | found = 1; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | if (!found) | ||
193 | pr_warning("%s: No PHY found\n", ndev->name); | ||
194 | |||
195 | return 0; | ||
196 | bus_register_fail: | ||
197 | kfree(irqlist); | ||
198 | irqlist_alloc_fail: | ||
199 | kfree(new_bus); | ||
200 | return err; | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * stmmac_mdio_unregister | ||
205 | * @ndev: net device structure | ||
206 | * Description: it unregisters the MII bus | ||
207 | */ | ||
208 | int stmmac_mdio_unregister(struct net_device *ndev) | ||
209 | { | ||
210 | struct stmmac_priv *priv = netdev_priv(ndev); | ||
211 | |||
212 | mdiobus_unregister(priv->mii); | ||
213 | priv->mii->priv = NULL; | ||
214 | kfree(priv->mii); | ||
215 | |||
216 | return 0; | ||
217 | } | ||
diff --git a/drivers/net/stmmac/stmmac_timer.c b/drivers/net/stmmac/stmmac_timer.c new file mode 100644 index 000000000000..b838c6582077 --- /dev/null +++ b/drivers/net/stmmac/stmmac_timer.c | |||
@@ -0,0 +1,140 @@ | |||
1 | /******************************************************************************* | ||
2 | STMMAC external timer support. | ||
3 | |||
4 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms and conditions of the GNU General Public License, | ||
8 | version 2, as published by the Free Software Foundation. | ||
9 | |||
10 | This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License along with | ||
16 | this program; if not, write to the Free Software Foundation, Inc., | ||
17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | The full GNU General Public License is included in this distribution in | ||
20 | the file called "COPYING". | ||
21 | |||
22 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
23 | *******************************************************************************/ | ||
24 | |||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/etherdevice.h> | ||
27 | #include "stmmac_timer.h" | ||
28 | |||
29 | static void stmmac_timer_handler(void *data) | ||
30 | { | ||
31 | struct net_device *dev = (struct net_device *)data; | ||
32 | |||
33 | stmmac_schedule(dev); | ||
34 | |||
35 | return; | ||
36 | } | ||
37 | |||
38 | #define STMMAC_TIMER_MSG(timer, freq) \ | ||
39 | printk(KERN_INFO "stmmac_timer: %s Timer ON (freq %dHz)\n", timer, freq); | ||
40 | |||
41 | #if defined(CONFIG_STMMAC_RTC_TIMER) | ||
42 | #include <linux/rtc.h> | ||
43 | static struct rtc_device *stmmac_rtc; | ||
44 | static rtc_task_t stmmac_task; | ||
45 | |||
46 | static void stmmac_rtc_start(unsigned int new_freq) | ||
47 | { | ||
48 | rtc_irq_set_freq(stmmac_rtc, &stmmac_task, new_freq); | ||
49 | rtc_irq_set_state(stmmac_rtc, &stmmac_task, 1); | ||
50 | return; | ||
51 | } | ||
52 | |||
53 | static void stmmac_rtc_stop(void) | ||
54 | { | ||
55 | rtc_irq_set_state(stmmac_rtc, &stmmac_task, 0); | ||
56 | return; | ||
57 | } | ||
58 | |||
59 | int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm) | ||
60 | { | ||
61 | stmmac_task.private_data = dev; | ||
62 | stmmac_task.func = stmmac_timer_handler; | ||
63 | |||
64 | stmmac_rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); | ||
65 | if (stmmac_rtc == NULL) { | ||
66 | pr_error("open rtc device failed\n"); | ||
67 | return -ENODEV; | ||
68 | } | ||
69 | |||
70 | rtc_irq_register(stmmac_rtc, &stmmac_task); | ||
71 | |||
72 | /* Periodic mode is not supported */ | ||
73 | if ((rtc_irq_set_freq(stmmac_rtc, &stmmac_task, tm->freq) < 0)) { | ||
74 | pr_error("set periodic failed\n"); | ||
75 | rtc_irq_unregister(stmmac_rtc, &stmmac_task); | ||
76 | rtc_class_close(stmmac_rtc); | ||
77 | return -1; | ||
78 | } | ||
79 | |||
80 | STMMAC_TIMER_MSG(CONFIG_RTC_HCTOSYS_DEVICE, tm->freq); | ||
81 | |||
82 | tm->timer_start = stmmac_rtc_start; | ||
83 | tm->timer_stop = stmmac_rtc_stop; | ||
84 | |||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | int stmmac_close_ext_timer(void) | ||
89 | { | ||
90 | rtc_irq_set_state(stmmac_rtc, &stmmac_task, 0); | ||
91 | rtc_irq_unregister(stmmac_rtc, &stmmac_task); | ||
92 | rtc_class_close(stmmac_rtc); | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | #elif defined(CONFIG_STMMAC_TMU_TIMER) | ||
97 | #include <linux/clk.h> | ||
98 | #define TMU_CHANNEL "tmu2_clk" | ||
99 | static struct clk *timer_clock; | ||
100 | |||
101 | static void stmmac_tmu_start(unsigned int new_freq) | ||
102 | { | ||
103 | clk_set_rate(timer_clock, new_freq); | ||
104 | clk_enable(timer_clock); | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | static void stmmac_tmu_stop(void) | ||
109 | { | ||
110 | clk_disable(timer_clock); | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm) | ||
115 | { | ||
116 | timer_clock = clk_get(NULL, TMU_CHANNEL); | ||
117 | |||
118 | if (timer_clock == NULL) | ||
119 | return -1; | ||
120 | |||
121 | if (tmu2_register_user(stmmac_timer_handler, (void *)dev) < 0) { | ||
122 | timer_clock = NULL; | ||
123 | return -1; | ||
124 | } | ||
125 | |||
126 | STMMAC_TIMER_MSG("TMU2", tm->freq); | ||
127 | tm->timer_start = stmmac_tmu_start; | ||
128 | tm->timer_stop = stmmac_tmu_stop; | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | int stmmac_close_ext_timer(void) | ||
134 | { | ||
135 | clk_disable(timer_clock); | ||
136 | tmu2_unregister_user(); | ||
137 | clk_put(timer_clock); | ||
138 | return 0; | ||
139 | } | ||
140 | #endif | ||
diff --git a/drivers/net/stmmac/stmmac_timer.h b/drivers/net/stmmac/stmmac_timer.h new file mode 100644 index 000000000000..f795cae33725 --- /dev/null +++ b/drivers/net/stmmac/stmmac_timer.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /******************************************************************************* | ||
2 | STMMAC external timer Header File. | ||
3 | |||
4 | Copyright (C) 2007-2009 STMicroelectronics Ltd | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms and conditions of the GNU General Public License, | ||
8 | version 2, as published by the Free Software Foundation. | ||
9 | |||
10 | This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License along with | ||
16 | this program; if not, write to the Free Software Foundation, Inc., | ||
17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | The full GNU General Public License is included in this distribution in | ||
20 | the file called "COPYING". | ||
21 | |||
22 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
23 | *******************************************************************************/ | ||
24 | |||
25 | struct stmmac_timer { | ||
26 | void (*timer_start) (unsigned int new_freq); | ||
27 | void (*timer_stop) (void); | ||
28 | unsigned int freq; | ||
29 | }; | ||
30 | |||
31 | /* Open the HW timer device and return 0 in case of success */ | ||
32 | int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm); | ||
33 | /* Stop the timer and release it */ | ||
34 | int stmmac_close_ext_timer(void); | ||
35 | /* Function used for scheduling task within the stmmac */ | ||
36 | void stmmac_schedule(struct net_device *dev); | ||
37 | |||
38 | #if defined(CONFIG_STMMAC_TMU_TIMER) | ||
39 | extern int tmu2_register_user(void *fnt, void *data); | ||
40 | extern void tmu2_unregister_user(void); | ||
41 | #endif | ||
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 305ec3d783db..7019a0d1a82b 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
39 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
40 | #include <linux/in.h> | 40 | #include <linux/in.h> |
41 | #include <linux/sched.h> | ||
41 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
42 | #include <linux/string.h> | 43 | #include <linux/string.h> |
43 | #include <linux/delay.h> | 44 | #include <linux/delay.h> |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index f09bc5dfe8b2..ba5d3fe753b6 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -902,11 +902,12 @@ static int tg3_mdio_read(struct mii_bus *bp, int mii_id, int reg) | |||
902 | struct tg3 *tp = bp->priv; | 902 | struct tg3 *tp = bp->priv; |
903 | u32 val; | 903 | u32 val; |
904 | 904 | ||
905 | if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_PAUSED) | 905 | spin_lock_bh(&tp->lock); |
906 | return -EAGAIN; | ||
907 | 906 | ||
908 | if (tg3_readphy(tp, reg, &val)) | 907 | if (tg3_readphy(tp, reg, &val)) |
909 | return -EIO; | 908 | val = -EIO; |
909 | |||
910 | spin_unlock_bh(&tp->lock); | ||
910 | 911 | ||
911 | return val; | 912 | return val; |
912 | } | 913 | } |
@@ -914,14 +915,16 @@ static int tg3_mdio_read(struct mii_bus *bp, int mii_id, int reg) | |||
914 | static int tg3_mdio_write(struct mii_bus *bp, int mii_id, int reg, u16 val) | 915 | static int tg3_mdio_write(struct mii_bus *bp, int mii_id, int reg, u16 val) |
915 | { | 916 | { |
916 | struct tg3 *tp = bp->priv; | 917 | struct tg3 *tp = bp->priv; |
918 | u32 ret = 0; | ||
917 | 919 | ||
918 | if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_PAUSED) | 920 | spin_lock_bh(&tp->lock); |
919 | return -EAGAIN; | ||
920 | 921 | ||
921 | if (tg3_writephy(tp, reg, val)) | 922 | if (tg3_writephy(tp, reg, val)) |
922 | return -EIO; | 923 | ret = -EIO; |
923 | 924 | ||
924 | return 0; | 925 | spin_unlock_bh(&tp->lock); |
926 | |||
927 | return ret; | ||
925 | } | 928 | } |
926 | 929 | ||
927 | static int tg3_mdio_reset(struct mii_bus *bp) | 930 | static int tg3_mdio_reset(struct mii_bus *bp) |
@@ -1011,12 +1014,6 @@ static void tg3_mdio_config_5785(struct tg3 *tp) | |||
1011 | 1014 | ||
1012 | static void tg3_mdio_start(struct tg3 *tp) | 1015 | static void tg3_mdio_start(struct tg3 *tp) |
1013 | { | 1016 | { |
1014 | if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_INITED) { | ||
1015 | mutex_lock(&tp->mdio_bus->mdio_lock); | ||
1016 | tp->tg3_flags3 &= ~TG3_FLG3_MDIOBUS_PAUSED; | ||
1017 | mutex_unlock(&tp->mdio_bus->mdio_lock); | ||
1018 | } | ||
1019 | |||
1020 | tp->mi_mode &= ~MAC_MI_MODE_AUTO_POLL; | 1017 | tp->mi_mode &= ~MAC_MI_MODE_AUTO_POLL; |
1021 | tw32_f(MAC_MI_MODE, tp->mi_mode); | 1018 | tw32_f(MAC_MI_MODE, tp->mi_mode); |
1022 | udelay(80); | 1019 | udelay(80); |
@@ -1041,15 +1038,6 @@ static void tg3_mdio_start(struct tg3 *tp) | |||
1041 | tg3_mdio_config_5785(tp); | 1038 | tg3_mdio_config_5785(tp); |
1042 | } | 1039 | } |
1043 | 1040 | ||
1044 | static void tg3_mdio_stop(struct tg3 *tp) | ||
1045 | { | ||
1046 | if (tp->tg3_flags3 & TG3_FLG3_MDIOBUS_INITED) { | ||
1047 | mutex_lock(&tp->mdio_bus->mdio_lock); | ||
1048 | tp->tg3_flags3 |= TG3_FLG3_MDIOBUS_PAUSED; | ||
1049 | mutex_unlock(&tp->mdio_bus->mdio_lock); | ||
1050 | } | ||
1051 | } | ||
1052 | |||
1053 | static int tg3_mdio_init(struct tg3 *tp) | 1041 | static int tg3_mdio_init(struct tg3 *tp) |
1054 | { | 1042 | { |
1055 | int i; | 1043 | int i; |
@@ -1141,7 +1129,6 @@ static void tg3_mdio_fini(struct tg3 *tp) | |||
1141 | tp->tg3_flags3 &= ~TG3_FLG3_MDIOBUS_INITED; | 1129 | tp->tg3_flags3 &= ~TG3_FLG3_MDIOBUS_INITED; |
1142 | mdiobus_unregister(tp->mdio_bus); | 1130 | mdiobus_unregister(tp->mdio_bus); |
1143 | mdiobus_free(tp->mdio_bus); | 1131 | mdiobus_free(tp->mdio_bus); |
1144 | tp->tg3_flags3 &= ~TG3_FLG3_MDIOBUS_PAUSED; | ||
1145 | } | 1132 | } |
1146 | } | 1133 | } |
1147 | 1134 | ||
@@ -1363,7 +1350,7 @@ static void tg3_adjust_link(struct net_device *dev) | |||
1363 | struct tg3 *tp = netdev_priv(dev); | 1350 | struct tg3 *tp = netdev_priv(dev); |
1364 | struct phy_device *phydev = tp->mdio_bus->phy_map[PHY_ADDR]; | 1351 | struct phy_device *phydev = tp->mdio_bus->phy_map[PHY_ADDR]; |
1365 | 1352 | ||
1366 | spin_lock(&tp->lock); | 1353 | spin_lock_bh(&tp->lock); |
1367 | 1354 | ||
1368 | mac_mode = tp->mac_mode & ~(MAC_MODE_PORT_MODE_MASK | | 1355 | mac_mode = tp->mac_mode & ~(MAC_MODE_PORT_MODE_MASK | |
1369 | MAC_MODE_HALF_DUPLEX); | 1356 | MAC_MODE_HALF_DUPLEX); |
@@ -1431,7 +1418,7 @@ static void tg3_adjust_link(struct net_device *dev) | |||
1431 | tp->link_config.active_speed = phydev->speed; | 1418 | tp->link_config.active_speed = phydev->speed; |
1432 | tp->link_config.active_duplex = phydev->duplex; | 1419 | tp->link_config.active_duplex = phydev->duplex; |
1433 | 1420 | ||
1434 | spin_unlock(&tp->lock); | 1421 | spin_unlock_bh(&tp->lock); |
1435 | 1422 | ||
1436 | if (linkmesg) | 1423 | if (linkmesg) |
1437 | tg3_link_report(tp); | 1424 | tg3_link_report(tp); |
@@ -6392,8 +6379,6 @@ static int tg3_chip_reset(struct tg3 *tp) | |||
6392 | 6379 | ||
6393 | tg3_nvram_lock(tp); | 6380 | tg3_nvram_lock(tp); |
6394 | 6381 | ||
6395 | tg3_mdio_stop(tp); | ||
6396 | |||
6397 | tg3_ape_lock(tp, TG3_APE_LOCK_GRC); | 6382 | tg3_ape_lock(tp, TG3_APE_LOCK_GRC); |
6398 | 6383 | ||
6399 | /* No matching tg3_nvram_unlock() after this because | 6384 | /* No matching tg3_nvram_unlock() after this because |
@@ -8698,6 +8683,8 @@ static int tg3_close(struct net_device *dev) | |||
8698 | 8683 | ||
8699 | del_timer_sync(&tp->timer); | 8684 | del_timer_sync(&tp->timer); |
8700 | 8685 | ||
8686 | tg3_phy_stop(tp); | ||
8687 | |||
8701 | tg3_full_lock(tp, 1); | 8688 | tg3_full_lock(tp, 1); |
8702 | #if 0 | 8689 | #if 0 |
8703 | tg3_dump_state(tp); | 8690 | tg3_dump_state(tp); |
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 524691cd9896..bab7940158e6 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -2748,7 +2748,6 @@ struct tg3 { | |||
2748 | #define TG3_FLG3_5701_DMA_BUG 0x00000008 | 2748 | #define TG3_FLG3_5701_DMA_BUG 0x00000008 |
2749 | #define TG3_FLG3_USE_PHYLIB 0x00000010 | 2749 | #define TG3_FLG3_USE_PHYLIB 0x00000010 |
2750 | #define TG3_FLG3_MDIOBUS_INITED 0x00000020 | 2750 | #define TG3_FLG3_MDIOBUS_INITED 0x00000020 |
2751 | #define TG3_FLG3_MDIOBUS_PAUSED 0x00000040 | ||
2752 | #define TG3_FLG3_PHY_CONNECTED 0x00000080 | 2751 | #define TG3_FLG3_PHY_CONNECTED 0x00000080 |
2753 | #define TG3_FLG3_RGMII_STD_IBND_DISABLE 0x00000100 | 2752 | #define TG3_FLG3_RGMII_STD_IBND_DISABLE 0x00000100 |
2754 | #define TG3_FLG3_RGMII_EXT_IBND_RX_EN 0x00000200 | 2753 | #define TG3_FLG3_RGMII_EXT_IBND_RX_EN 0x00000200 |
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c index 525bbc5b9c9d..36cb2423bcf1 100644 --- a/drivers/net/tokenring/ibmtr.c +++ b/drivers/net/tokenring/ibmtr.c | |||
@@ -108,6 +108,7 @@ in the event that chatty debug messages are desired - jjs 12/30/98 */ | |||
108 | #define IBMTR_DEBUG_MESSAGES 0 | 108 | #define IBMTR_DEBUG_MESSAGES 0 |
109 | 109 | ||
110 | #include <linux/module.h> | 110 | #include <linux/module.h> |
111 | #include <linux/sched.h> | ||
111 | 112 | ||
112 | #ifdef PCMCIA /* required for ibmtr_cs.c to build */ | 113 | #ifdef PCMCIA /* required for ibmtr_cs.c to build */ |
113 | #undef MODULE /* yes, really */ | 114 | #undef MODULE /* yes, really */ |
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c index d6d345229fe9..5921f5bdd764 100644 --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c | |||
@@ -108,6 +108,7 @@ static const int multicast_filter_limit = 32; | |||
108 | 108 | ||
109 | #include <linux/module.h> | 109 | #include <linux/module.h> |
110 | #include <linux/kernel.h> | 110 | #include <linux/kernel.h> |
111 | #include <linux/sched.h> | ||
111 | #include <linux/string.h> | 112 | #include <linux/string.h> |
112 | #include <linux/timer.h> | 113 | #include <linux/timer.h> |
113 | #include <linux/errno.h> | 114 | #include <linux/errno.h> |
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c index 72470f77f556..a2b30a10064f 100644 --- a/drivers/net/usb/dm9601.c +++ b/drivers/net/usb/dm9601.c | |||
@@ -649,6 +649,10 @@ static const struct usb_device_id products[] = { | |||
649 | USB_DEVICE(0x0fe6, 0x8101), /* DM9601 USB to Fast Ethernet Adapter */ | 649 | USB_DEVICE(0x0fe6, 0x8101), /* DM9601 USB to Fast Ethernet Adapter */ |
650 | .driver_info = (unsigned long)&dm9601_info, | 650 | .driver_info = (unsigned long)&dm9601_info, |
651 | }, | 651 | }, |
652 | { | ||
653 | USB_DEVICE(0x0a46, 0x9000), /* DM9000E */ | ||
654 | .driver_info = (unsigned long)&dm9601_info, | ||
655 | }, | ||
652 | {}, // END | 656 | {}, // END |
653 | }; | 657 | }; |
654 | 658 | ||
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index 6fdaba8674b9..ed4a508ef262 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c | |||
@@ -62,8 +62,11 @@ static char *devid=NULL; | |||
62 | static struct usb_eth_dev usb_dev_id[] = { | 62 | static struct usb_eth_dev usb_dev_id[] = { |
63 | #define PEGASUS_DEV(pn, vid, pid, flags) \ | 63 | #define PEGASUS_DEV(pn, vid, pid, flags) \ |
64 | {.name = pn, .vendor = vid, .device = pid, .private = flags}, | 64 | {.name = pn, .vendor = vid, .device = pid, .private = flags}, |
65 | #define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \ | ||
66 | PEGASUS_DEV(pn, vid, pid, flags) | ||
65 | #include "pegasus.h" | 67 | #include "pegasus.h" |
66 | #undef PEGASUS_DEV | 68 | #undef PEGASUS_DEV |
69 | #undef PEGASUS_DEV_CLASS | ||
67 | {NULL, 0, 0, 0}, | 70 | {NULL, 0, 0, 0}, |
68 | {NULL, 0, 0, 0} | 71 | {NULL, 0, 0, 0} |
69 | }; | 72 | }; |
@@ -71,8 +74,18 @@ static struct usb_eth_dev usb_dev_id[] = { | |||
71 | static struct usb_device_id pegasus_ids[] = { | 74 | static struct usb_device_id pegasus_ids[] = { |
72 | #define PEGASUS_DEV(pn, vid, pid, flags) \ | 75 | #define PEGASUS_DEV(pn, vid, pid, flags) \ |
73 | {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid}, | 76 | {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid}, |
77 | /* | ||
78 | * The Belkin F8T012xx1 bluetooth adaptor has the same vendor and product | ||
79 | * IDs as the Belkin F5D5050, so we need to teach the pegasus driver to | ||
80 | * ignore adaptors belonging to the "Wireless" class 0xE0. For this one | ||
81 | * case anyway, seeing as the pegasus is for "Wired" adaptors. | ||
82 | */ | ||
83 | #define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \ | ||
84 | {.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS), \ | ||
85 | .idVendor = vid, .idProduct = pid, .bDeviceClass = dclass}, | ||
74 | #include "pegasus.h" | 86 | #include "pegasus.h" |
75 | #undef PEGASUS_DEV | 87 | #undef PEGASUS_DEV |
88 | #undef PEGASUS_DEV_CLASS | ||
76 | {}, | 89 | {}, |
77 | {} | 90 | {} |
78 | }; | 91 | }; |
diff --git a/drivers/net/usb/pegasus.h b/drivers/net/usb/pegasus.h index f968c834ff63..5d02f0200737 100644 --- a/drivers/net/usb/pegasus.h +++ b/drivers/net/usb/pegasus.h | |||
@@ -202,7 +202,11 @@ PEGASUS_DEV( "AEI USB Fast Ethernet Adapter", VENDOR_AEILAB, 0x1701, | |||
202 | DEFAULT_GPIO_RESET | PEGASUS_II ) | 202 | DEFAULT_GPIO_RESET | PEGASUS_II ) |
203 | PEGASUS_DEV( "Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100, | 203 | PEGASUS_DEV( "Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100, |
204 | DEFAULT_GPIO_RESET | PEGASUS_II ) | 204 | DEFAULT_GPIO_RESET | PEGASUS_II ) |
205 | PEGASUS_DEV( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, | 205 | /* |
206 | * Distinguish between this Belkin adaptor and the Belkin bluetooth adaptors | ||
207 | * with the same product IDs by checking the device class too. | ||
208 | */ | ||
209 | PEGASUS_DEV_CLASS( "Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 0x00, | ||
206 | DEFAULT_GPIO_RESET | PEGASUS_II ) | 210 | DEFAULT_GPIO_RESET | PEGASUS_II ) |
207 | PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986, | 211 | PEGASUS_DEV( "Billionton USB-100", VENDOR_BILLIONTON, 0x0986, |
208 | DEFAULT_GPIO_RESET ) | 212 | DEFAULT_GPIO_RESET ) |
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c index d032bba9bc4c..f56dec6119c3 100644 --- a/drivers/net/usb/rndis_host.c +++ b/drivers/net/usb/rndis_host.c | |||
@@ -362,12 +362,12 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) | |||
362 | retval = -EINVAL; | 362 | retval = -EINVAL; |
363 | goto halt_fail_and_release; | 363 | goto halt_fail_and_release; |
364 | } | 364 | } |
365 | dev->hard_mtu = tmp; | ||
366 | net->mtu = dev->hard_mtu - net->hard_header_len; | ||
367 | dev_warn(&intf->dev, | 365 | dev_warn(&intf->dev, |
368 | "dev can't take %u byte packets (max %u), " | 366 | "dev can't take %u byte packets (max %u), " |
369 | "adjusting MTU to %u\n", | 367 | "adjusting MTU to %u\n", |
370 | dev->hard_mtu, tmp, net->mtu); | 368 | dev->hard_mtu, tmp, tmp - net->hard_header_len); |
369 | dev->hard_mtu = tmp; | ||
370 | net->mtu = dev->hard_mtu - net->hard_header_len; | ||
371 | } | 371 | } |
372 | 372 | ||
373 | /* REVISIT: peripheral "alignment" request is ignored ... */ | 373 | /* REVISIT: peripheral "alignment" request is ignored ... */ |
@@ -418,6 +418,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) | |||
418 | goto halt_fail_and_release; | 418 | goto halt_fail_and_release; |
419 | } | 419 | } |
420 | memcpy(net->dev_addr, bp, ETH_ALEN); | 420 | memcpy(net->dev_addr, bp, ETH_ALEN); |
421 | memcpy(net->perm_addr, bp, ETH_ALEN); | ||
421 | 422 | ||
422 | /* set a nonzero filter to enable data transfers */ | 423 | /* set a nonzero filter to enable data transfers */ |
423 | memset(u.set, 0, sizeof *u.set); | 424 | memset(u.set, 0, sizeof *u.set); |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 8d009760277c..05630f2f6930 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/ethtool.h> | 22 | #include <linux/ethtool.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/virtio.h> | 24 | #include <linux/virtio.h> |
25 | #include <linux/virtio_ids.h> | ||
26 | #include <linux/virtio_net.h> | 25 | #include <linux/virtio_net.h> |
27 | #include <linux/scatterlist.h> | 26 | #include <linux/scatterlist.h> |
28 | #include <linux/if_vlan.h> | 27 | #include <linux/if_vlan.h> |
@@ -454,7 +453,7 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi) | |||
454 | vi->dev->stats.tx_bytes += skb->len; | 453 | vi->dev->stats.tx_bytes += skb->len; |
455 | vi->dev->stats.tx_packets++; | 454 | vi->dev->stats.tx_packets++; |
456 | tot_sgs += skb_vnet_hdr(skb)->num_sg; | 455 | tot_sgs += skb_vnet_hdr(skb)->num_sg; |
457 | kfree_skb(skb); | 456 | dev_kfree_skb_any(skb); |
458 | } | 457 | } |
459 | return tot_sgs; | 458 | return tot_sgs; |
460 | } | 459 | } |
@@ -517,8 +516,7 @@ again: | |||
517 | /* Free up any pending old buffers before queueing new ones. */ | 516 | /* Free up any pending old buffers before queueing new ones. */ |
518 | free_old_xmit_skbs(vi); | 517 | free_old_xmit_skbs(vi); |
519 | 518 | ||
520 | /* Put new one in send queue and do transmit */ | 519 | /* Try to transmit */ |
521 | __skb_queue_head(&vi->send, skb); | ||
522 | capacity = xmit_skb(vi, skb); | 520 | capacity = xmit_skb(vi, skb); |
523 | 521 | ||
524 | /* This can happen with OOM and indirect buffers. */ | 522 | /* This can happen with OOM and indirect buffers. */ |
@@ -532,8 +530,17 @@ again: | |||
532 | } | 530 | } |
533 | return NETDEV_TX_BUSY; | 531 | return NETDEV_TX_BUSY; |
534 | } | 532 | } |
535 | |||
536 | vi->svq->vq_ops->kick(vi->svq); | 533 | vi->svq->vq_ops->kick(vi->svq); |
534 | |||
535 | /* | ||
536 | * Put new one in send queue. You'd expect we'd need this before | ||
537 | * xmit_skb calls add_buf(), since the callback can be triggered | ||
538 | * immediately after that. But since the callback just triggers | ||
539 | * another call back here, normal network xmit locking prevents the | ||
540 | * race. | ||
541 | */ | ||
542 | __skb_queue_head(&vi->send, skb); | ||
543 | |||
537 | /* Don't wait up for transmitted skbs to be freed. */ | 544 | /* Don't wait up for transmitted skbs to be freed. */ |
538 | skb_orphan(skb); | 545 | skb_orphan(skb); |
539 | nf_reset(skb); | 546 | nf_reset(skb); |
diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile new file mode 100644 index 000000000000..880f5098eac9 --- /dev/null +++ b/drivers/net/vmxnet3/Makefile | |||
@@ -0,0 +1,35 @@ | |||
1 | ################################################################################ | ||
2 | # | ||
3 | # Linux driver for VMware's vmxnet3 ethernet NIC. | ||
4 | # | ||
5 | # Copyright (C) 2007-2009, VMware, Inc. All Rights Reserved. | ||
6 | # | ||
7 | # This program is free software; you can redistribute it and/or modify it | ||
8 | # under the terms of the GNU General Public License as published by the | ||
9 | # Free Software Foundation; version 2 of the License and no later version. | ||
10 | # | ||
11 | # This program is distributed in the hope that it will be useful, but | ||
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
14 | # NON INFRINGEMENT. See the GNU General Public License for more | ||
15 | # details. | ||
16 | # | ||
17 | # You should have received a copy of the GNU General Public License | ||
18 | # along with this program; if not, write to the Free Software | ||
19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
20 | # | ||
21 | # The full GNU General Public License is included in this distribution in | ||
22 | # the file called "COPYING". | ||
23 | # | ||
24 | # Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com> | ||
25 | # | ||
26 | # | ||
27 | ################################################################################ | ||
28 | |||
29 | # | ||
30 | # Makefile for the VMware vmxnet3 ethernet NIC driver | ||
31 | # | ||
32 | |||
33 | obj-$(CONFIG_VMXNET3) += vmxnet3.o | ||
34 | |||
35 | vmxnet3-objs := vmxnet3_drv.o vmxnet3_ethtool.o | ||
diff --git a/drivers/net/vmxnet3/upt1_defs.h b/drivers/net/vmxnet3/upt1_defs.h new file mode 100644 index 000000000000..37108fb226d3 --- /dev/null +++ b/drivers/net/vmxnet3/upt1_defs.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * Linux driver for VMware's vmxnet3 ethernet NIC. | ||
3 | * | ||
4 | * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; version 2 of the License and no later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
13 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
14 | * details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution in | ||
21 | * the file called "COPYING". | ||
22 | * | ||
23 | * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #ifndef _UPT1_DEFS_H | ||
28 | #define _UPT1_DEFS_H | ||
29 | |||
30 | struct UPT1_TxStats { | ||
31 | u64 TSOPktsTxOK; /* TSO pkts post-segmentation */ | ||
32 | u64 TSOBytesTxOK; | ||
33 | u64 ucastPktsTxOK; | ||
34 | u64 ucastBytesTxOK; | ||
35 | u64 mcastPktsTxOK; | ||
36 | u64 mcastBytesTxOK; | ||
37 | u64 bcastPktsTxOK; | ||
38 | u64 bcastBytesTxOK; | ||
39 | u64 pktsTxError; | ||
40 | u64 pktsTxDiscard; | ||
41 | }; | ||
42 | |||
43 | struct UPT1_RxStats { | ||
44 | u64 LROPktsRxOK; /* LRO pkts */ | ||
45 | u64 LROBytesRxOK; /* bytes from LRO pkts */ | ||
46 | /* the following counters are for pkts from the wire, i.e., pre-LRO */ | ||
47 | u64 ucastPktsRxOK; | ||
48 | u64 ucastBytesRxOK; | ||
49 | u64 mcastPktsRxOK; | ||
50 | u64 mcastBytesRxOK; | ||
51 | u64 bcastPktsRxOK; | ||
52 | u64 bcastBytesRxOK; | ||
53 | u64 pktsRxOutOfBuf; | ||
54 | u64 pktsRxError; | ||
55 | }; | ||
56 | |||
57 | /* interrupt moderation level */ | ||
58 | enum { | ||
59 | UPT1_IML_NONE = 0, /* no interrupt moderation */ | ||
60 | UPT1_IML_HIGHEST = 7, /* least intr generated */ | ||
61 | UPT1_IML_ADAPTIVE = 8, /* adpative intr moderation */ | ||
62 | }; | ||
63 | /* values for UPT1_RSSConf.hashFunc */ | ||
64 | enum { | ||
65 | UPT1_RSS_HASH_TYPE_NONE = 0x0, | ||
66 | UPT1_RSS_HASH_TYPE_IPV4 = 0x01, | ||
67 | UPT1_RSS_HASH_TYPE_TCP_IPV4 = 0x02, | ||
68 | UPT1_RSS_HASH_TYPE_IPV6 = 0x04, | ||
69 | UPT1_RSS_HASH_TYPE_TCP_IPV6 = 0x08, | ||
70 | }; | ||
71 | |||
72 | enum { | ||
73 | UPT1_RSS_HASH_FUNC_NONE = 0x0, | ||
74 | UPT1_RSS_HASH_FUNC_TOEPLITZ = 0x01, | ||
75 | }; | ||
76 | |||
77 | #define UPT1_RSS_MAX_KEY_SIZE 40 | ||
78 | #define UPT1_RSS_MAX_IND_TABLE_SIZE 128 | ||
79 | |||
80 | struct UPT1_RSSConf { | ||
81 | u16 hashType; | ||
82 | u16 hashFunc; | ||
83 | u16 hashKeySize; | ||
84 | u16 indTableSize; | ||
85 | u8 hashKey[UPT1_RSS_MAX_KEY_SIZE]; | ||
86 | u8 indTable[UPT1_RSS_MAX_IND_TABLE_SIZE]; | ||
87 | }; | ||
88 | |||
89 | /* features */ | ||
90 | enum { | ||
91 | UPT1_F_RXCSUM = 0x0001, /* rx csum verification */ | ||
92 | UPT1_F_RSS = 0x0002, | ||
93 | UPT1_F_RXVLAN = 0x0004, /* VLAN tag stripping */ | ||
94 | UPT1_F_LRO = 0x0008, | ||
95 | }; | ||
96 | #endif | ||
diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h b/drivers/net/vmxnet3/vmxnet3_defs.h new file mode 100644 index 000000000000..dc8ee4438a4f --- /dev/null +++ b/drivers/net/vmxnet3/vmxnet3_defs.h | |||
@@ -0,0 +1,535 @@ | |||
1 | /* | ||
2 | * Linux driver for VMware's vmxnet3 ethernet NIC. | ||
3 | * | ||
4 | * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; version 2 of the License and no later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
13 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
14 | * details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution in | ||
21 | * the file called "COPYING". | ||
22 | * | ||
23 | * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #ifndef _VMXNET3_DEFS_H_ | ||
28 | #define _VMXNET3_DEFS_H_ | ||
29 | |||
30 | #include "upt1_defs.h" | ||
31 | |||
32 | /* all registers are 32 bit wide */ | ||
33 | /* BAR 1 */ | ||
34 | enum { | ||
35 | VMXNET3_REG_VRRS = 0x0, /* Vmxnet3 Revision Report Selection */ | ||
36 | VMXNET3_REG_UVRS = 0x8, /* UPT Version Report Selection */ | ||
37 | VMXNET3_REG_DSAL = 0x10, /* Driver Shared Address Low */ | ||
38 | VMXNET3_REG_DSAH = 0x18, /* Driver Shared Address High */ | ||
39 | VMXNET3_REG_CMD = 0x20, /* Command */ | ||
40 | VMXNET3_REG_MACL = 0x28, /* MAC Address Low */ | ||
41 | VMXNET3_REG_MACH = 0x30, /* MAC Address High */ | ||
42 | VMXNET3_REG_ICR = 0x38, /* Interrupt Cause Register */ | ||
43 | VMXNET3_REG_ECR = 0x40 /* Event Cause Register */ | ||
44 | }; | ||
45 | |||
46 | /* BAR 0 */ | ||
47 | enum { | ||
48 | VMXNET3_REG_IMR = 0x0, /* Interrupt Mask Register */ | ||
49 | VMXNET3_REG_TXPROD = 0x600, /* Tx Producer Index */ | ||
50 | VMXNET3_REG_RXPROD = 0x800, /* Rx Producer Index for ring 1 */ | ||
51 | VMXNET3_REG_RXPROD2 = 0xA00 /* Rx Producer Index for ring 2 */ | ||
52 | }; | ||
53 | |||
54 | #define VMXNET3_PT_REG_SIZE 4096 /* BAR 0 */ | ||
55 | #define VMXNET3_VD_REG_SIZE 4096 /* BAR 1 */ | ||
56 | |||
57 | #define VMXNET3_REG_ALIGN 8 /* All registers are 8-byte aligned. */ | ||
58 | #define VMXNET3_REG_ALIGN_MASK 0x7 | ||
59 | |||
60 | /* I/O Mapped access to registers */ | ||
61 | #define VMXNET3_IO_TYPE_PT 0 | ||
62 | #define VMXNET3_IO_TYPE_VD 1 | ||
63 | #define VMXNET3_IO_ADDR(type, reg) (((type) << 24) | ((reg) & 0xFFFFFF)) | ||
64 | #define VMXNET3_IO_TYPE(addr) ((addr) >> 24) | ||
65 | #define VMXNET3_IO_REG(addr) ((addr) & 0xFFFFFF) | ||
66 | |||
67 | enum { | ||
68 | VMXNET3_CMD_FIRST_SET = 0xCAFE0000, | ||
69 | VMXNET3_CMD_ACTIVATE_DEV = VMXNET3_CMD_FIRST_SET, | ||
70 | VMXNET3_CMD_QUIESCE_DEV, | ||
71 | VMXNET3_CMD_RESET_DEV, | ||
72 | VMXNET3_CMD_UPDATE_RX_MODE, | ||
73 | VMXNET3_CMD_UPDATE_MAC_FILTERS, | ||
74 | VMXNET3_CMD_UPDATE_VLAN_FILTERS, | ||
75 | VMXNET3_CMD_UPDATE_RSSIDT, | ||
76 | VMXNET3_CMD_UPDATE_IML, | ||
77 | VMXNET3_CMD_UPDATE_PMCFG, | ||
78 | VMXNET3_CMD_UPDATE_FEATURE, | ||
79 | VMXNET3_CMD_LOAD_PLUGIN, | ||
80 | |||
81 | VMXNET3_CMD_FIRST_GET = 0xF00D0000, | ||
82 | VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET, | ||
83 | VMXNET3_CMD_GET_STATS, | ||
84 | VMXNET3_CMD_GET_LINK, | ||
85 | VMXNET3_CMD_GET_PERM_MAC_LO, | ||
86 | VMXNET3_CMD_GET_PERM_MAC_HI, | ||
87 | VMXNET3_CMD_GET_DID_LO, | ||
88 | VMXNET3_CMD_GET_DID_HI, | ||
89 | VMXNET3_CMD_GET_DEV_EXTRA_INFO, | ||
90 | VMXNET3_CMD_GET_CONF_INTR | ||
91 | }; | ||
92 | |||
93 | struct Vmxnet3_TxDesc { | ||
94 | u64 addr; | ||
95 | |||
96 | u32 len:14; | ||
97 | u32 gen:1; /* generation bit */ | ||
98 | u32 rsvd:1; | ||
99 | u32 dtype:1; /* descriptor type */ | ||
100 | u32 ext1:1; | ||
101 | u32 msscof:14; /* MSS, checksum offset, flags */ | ||
102 | |||
103 | u32 hlen:10; /* header len */ | ||
104 | u32 om:2; /* offload mode */ | ||
105 | u32 eop:1; /* End Of Packet */ | ||
106 | u32 cq:1; /* completion request */ | ||
107 | u32 ext2:1; | ||
108 | u32 ti:1; /* VLAN Tag Insertion */ | ||
109 | u32 tci:16; /* Tag to Insert */ | ||
110 | }; | ||
111 | |||
112 | /* TxDesc.OM values */ | ||
113 | #define VMXNET3_OM_NONE 0 | ||
114 | #define VMXNET3_OM_CSUM 2 | ||
115 | #define VMXNET3_OM_TSO 3 | ||
116 | |||
117 | /* fields in TxDesc we access w/o using bit fields */ | ||
118 | #define VMXNET3_TXD_EOP_SHIFT 12 | ||
119 | #define VMXNET3_TXD_CQ_SHIFT 13 | ||
120 | #define VMXNET3_TXD_GEN_SHIFT 14 | ||
121 | |||
122 | #define VMXNET3_TXD_CQ (1 << VMXNET3_TXD_CQ_SHIFT) | ||
123 | #define VMXNET3_TXD_EOP (1 << VMXNET3_TXD_EOP_SHIFT) | ||
124 | #define VMXNET3_TXD_GEN (1 << VMXNET3_TXD_GEN_SHIFT) | ||
125 | |||
126 | #define VMXNET3_HDR_COPY_SIZE 128 | ||
127 | |||
128 | |||
129 | struct Vmxnet3_TxDataDesc { | ||
130 | u8 data[VMXNET3_HDR_COPY_SIZE]; | ||
131 | }; | ||
132 | |||
133 | |||
134 | struct Vmxnet3_TxCompDesc { | ||
135 | u32 txdIdx:12; /* Index of the EOP TxDesc */ | ||
136 | u32 ext1:20; | ||
137 | |||
138 | u32 ext2; | ||
139 | u32 ext3; | ||
140 | |||
141 | u32 rsvd:24; | ||
142 | u32 type:7; /* completion type */ | ||
143 | u32 gen:1; /* generation bit */ | ||
144 | }; | ||
145 | |||
146 | |||
147 | struct Vmxnet3_RxDesc { | ||
148 | u64 addr; | ||
149 | |||
150 | u32 len:14; | ||
151 | u32 btype:1; /* Buffer Type */ | ||
152 | u32 dtype:1; /* Descriptor type */ | ||
153 | u32 rsvd:15; | ||
154 | u32 gen:1; /* Generation bit */ | ||
155 | |||
156 | u32 ext1; | ||
157 | }; | ||
158 | |||
159 | /* values of RXD.BTYPE */ | ||
160 | #define VMXNET3_RXD_BTYPE_HEAD 0 /* head only */ | ||
161 | #define VMXNET3_RXD_BTYPE_BODY 1 /* body only */ | ||
162 | |||
163 | /* fields in RxDesc we access w/o using bit fields */ | ||
164 | #define VMXNET3_RXD_BTYPE_SHIFT 14 | ||
165 | #define VMXNET3_RXD_GEN_SHIFT 31 | ||
166 | |||
167 | |||
168 | struct Vmxnet3_RxCompDesc { | ||
169 | u32 rxdIdx:12; /* Index of the RxDesc */ | ||
170 | u32 ext1:2; | ||
171 | u32 eop:1; /* End of Packet */ | ||
172 | u32 sop:1; /* Start of Packet */ | ||
173 | u32 rqID:10; /* rx queue/ring ID */ | ||
174 | u32 rssType:4; /* RSS hash type used */ | ||
175 | u32 cnc:1; /* Checksum Not Calculated */ | ||
176 | u32 ext2:1; | ||
177 | |||
178 | u32 rssHash; /* RSS hash value */ | ||
179 | |||
180 | u32 len:14; /* data length */ | ||
181 | u32 err:1; /* Error */ | ||
182 | u32 ts:1; /* Tag is stripped */ | ||
183 | u32 tci:16; /* Tag stripped */ | ||
184 | |||
185 | u32 csum:16; | ||
186 | u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
187 | u32 udp:1; /* UDP packet */ | ||
188 | u32 tcp:1; /* TCP packet */ | ||
189 | u32 ipc:1; /* IP Checksum Correct */ | ||
190 | u32 v6:1; /* IPv6 */ | ||
191 | u32 v4:1; /* IPv4 */ | ||
192 | u32 frg:1; /* IP Fragment */ | ||
193 | u32 fcs:1; /* Frame CRC correct */ | ||
194 | u32 type:7; /* completion type */ | ||
195 | u32 gen:1; /* generation bit */ | ||
196 | }; | ||
197 | |||
198 | /* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */ | ||
199 | #define VMXNET3_RCD_TUC_SHIFT 16 | ||
200 | #define VMXNET3_RCD_IPC_SHIFT 19 | ||
201 | |||
202 | /* fields in RxCompDesc we access via Vmxnet3_GenericDesc.qword[1] */ | ||
203 | #define VMXNET3_RCD_TYPE_SHIFT 56 | ||
204 | #define VMXNET3_RCD_GEN_SHIFT 63 | ||
205 | |||
206 | /* csum OK for TCP/UDP pkts over IP */ | ||
207 | #define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \ | ||
208 | 1 << VMXNET3_RCD_IPC_SHIFT) | ||
209 | |||
210 | /* value of RxCompDesc.rssType */ | ||
211 | enum { | ||
212 | VMXNET3_RCD_RSS_TYPE_NONE = 0, | ||
213 | VMXNET3_RCD_RSS_TYPE_IPV4 = 1, | ||
214 | VMXNET3_RCD_RSS_TYPE_TCPIPV4 = 2, | ||
215 | VMXNET3_RCD_RSS_TYPE_IPV6 = 3, | ||
216 | VMXNET3_RCD_RSS_TYPE_TCPIPV6 = 4, | ||
217 | }; | ||
218 | |||
219 | |||
220 | /* a union for accessing all cmd/completion descriptors */ | ||
221 | union Vmxnet3_GenericDesc { | ||
222 | u64 qword[2]; | ||
223 | u32 dword[4]; | ||
224 | u16 word[8]; | ||
225 | struct Vmxnet3_TxDesc txd; | ||
226 | struct Vmxnet3_RxDesc rxd; | ||
227 | struct Vmxnet3_TxCompDesc tcd; | ||
228 | struct Vmxnet3_RxCompDesc rcd; | ||
229 | }; | ||
230 | |||
231 | #define VMXNET3_INIT_GEN 1 | ||
232 | |||
233 | /* Max size of a single tx buffer */ | ||
234 | #define VMXNET3_MAX_TX_BUF_SIZE (1 << 14) | ||
235 | |||
236 | /* # of tx desc needed for a tx buffer size */ | ||
237 | #define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \ | ||
238 | VMXNET3_MAX_TX_BUF_SIZE) | ||
239 | |||
240 | /* max # of tx descs for a non-tso pkt */ | ||
241 | #define VMXNET3_MAX_TXD_PER_PKT 16 | ||
242 | |||
243 | /* Max size of a single rx buffer */ | ||
244 | #define VMXNET3_MAX_RX_BUF_SIZE ((1 << 14) - 1) | ||
245 | /* Minimum size of a type 0 buffer */ | ||
246 | #define VMXNET3_MIN_T0_BUF_SIZE 128 | ||
247 | #define VMXNET3_MAX_CSUM_OFFSET 1024 | ||
248 | |||
249 | /* Ring base address alignment */ | ||
250 | #define VMXNET3_RING_BA_ALIGN 512 | ||
251 | #define VMXNET3_RING_BA_MASK (VMXNET3_RING_BA_ALIGN - 1) | ||
252 | |||
253 | /* Ring size must be a multiple of 32 */ | ||
254 | #define VMXNET3_RING_SIZE_ALIGN 32 | ||
255 | #define VMXNET3_RING_SIZE_MASK (VMXNET3_RING_SIZE_ALIGN - 1) | ||
256 | |||
257 | /* Max ring size */ | ||
258 | #define VMXNET3_TX_RING_MAX_SIZE 4096 | ||
259 | #define VMXNET3_TC_RING_MAX_SIZE 4096 | ||
260 | #define VMXNET3_RX_RING_MAX_SIZE 4096 | ||
261 | #define VMXNET3_RC_RING_MAX_SIZE 8192 | ||
262 | |||
263 | /* a list of reasons for queue stop */ | ||
264 | |||
265 | enum { | ||
266 | VMXNET3_ERR_NOEOP = 0x80000000, /* cannot find the EOP desc of a pkt */ | ||
267 | VMXNET3_ERR_TXD_REUSE = 0x80000001, /* reuse TxDesc before tx completion */ | ||
268 | VMXNET3_ERR_BIG_PKT = 0x80000002, /* too many TxDesc for a pkt */ | ||
269 | VMXNET3_ERR_DESC_NOT_SPT = 0x80000003, /* descriptor type not supported */ | ||
270 | VMXNET3_ERR_SMALL_BUF = 0x80000004, /* type 0 buffer too small */ | ||
271 | VMXNET3_ERR_STRESS = 0x80000005, /* stress option firing in vmkernel */ | ||
272 | VMXNET3_ERR_SWITCH = 0x80000006, /* mode switch failure */ | ||
273 | VMXNET3_ERR_TXD_INVALID = 0x80000007, /* invalid TxDesc */ | ||
274 | }; | ||
275 | |||
276 | /* completion descriptor types */ | ||
277 | #define VMXNET3_CDTYPE_TXCOMP 0 /* Tx Completion Descriptor */ | ||
278 | #define VMXNET3_CDTYPE_RXCOMP 3 /* Rx Completion Descriptor */ | ||
279 | |||
280 | enum { | ||
281 | VMXNET3_GOS_BITS_UNK = 0, /* unknown */ | ||
282 | VMXNET3_GOS_BITS_32 = 1, | ||
283 | VMXNET3_GOS_BITS_64 = 2, | ||
284 | }; | ||
285 | |||
286 | #define VMXNET3_GOS_TYPE_LINUX 1 | ||
287 | |||
288 | |||
289 | struct Vmxnet3_GOSInfo { | ||
290 | u32 gosBits:2; /* 32-bit or 64-bit? */ | ||
291 | u32 gosType:4; /* which guest */ | ||
292 | u32 gosVer:16; /* gos version */ | ||
293 | u32 gosMisc:10; /* other info about gos */ | ||
294 | }; | ||
295 | |||
296 | |||
297 | struct Vmxnet3_DriverInfo { | ||
298 | u32 version; | ||
299 | struct Vmxnet3_GOSInfo gos; | ||
300 | u32 vmxnet3RevSpt; | ||
301 | u32 uptVerSpt; | ||
302 | }; | ||
303 | |||
304 | |||
305 | #define VMXNET3_REV1_MAGIC 0xbabefee1 | ||
306 | |||
307 | /* | ||
308 | * QueueDescPA must be 128 bytes aligned. It points to an array of | ||
309 | * Vmxnet3_TxQueueDesc followed by an array of Vmxnet3_RxQueueDesc. | ||
310 | * The number of Vmxnet3_TxQueueDesc/Vmxnet3_RxQueueDesc are specified by | ||
311 | * Vmxnet3_MiscConf.numTxQueues/numRxQueues, respectively. | ||
312 | */ | ||
313 | #define VMXNET3_QUEUE_DESC_ALIGN 128 | ||
314 | |||
315 | |||
316 | struct Vmxnet3_MiscConf { | ||
317 | struct Vmxnet3_DriverInfo driverInfo; | ||
318 | u64 uptFeatures; | ||
319 | u64 ddPA; /* driver data PA */ | ||
320 | u64 queueDescPA; /* queue descriptor table PA */ | ||
321 | u32 ddLen; /* driver data len */ | ||
322 | u32 queueDescLen; /* queue desc. table len in bytes */ | ||
323 | u32 mtu; | ||
324 | u16 maxNumRxSG; | ||
325 | u8 numTxQueues; | ||
326 | u8 numRxQueues; | ||
327 | u32 reserved[4]; | ||
328 | }; | ||
329 | |||
330 | |||
331 | struct Vmxnet3_TxQueueConf { | ||
332 | u64 txRingBasePA; | ||
333 | u64 dataRingBasePA; | ||
334 | u64 compRingBasePA; | ||
335 | u64 ddPA; /* driver data */ | ||
336 | u64 reserved; | ||
337 | u32 txRingSize; /* # of tx desc */ | ||
338 | u32 dataRingSize; /* # of data desc */ | ||
339 | u32 compRingSize; /* # of comp desc */ | ||
340 | u32 ddLen; /* size of driver data */ | ||
341 | u8 intrIdx; | ||
342 | u8 _pad[7]; | ||
343 | }; | ||
344 | |||
345 | |||
346 | struct Vmxnet3_RxQueueConf { | ||
347 | u64 rxRingBasePA[2]; | ||
348 | u64 compRingBasePA; | ||
349 | u64 ddPA; /* driver data */ | ||
350 | u64 reserved; | ||
351 | u32 rxRingSize[2]; /* # of rx desc */ | ||
352 | u32 compRingSize; /* # of rx comp desc */ | ||
353 | u32 ddLen; /* size of driver data */ | ||
354 | u8 intrIdx; | ||
355 | u8 _pad[7]; | ||
356 | }; | ||
357 | |||
358 | |||
359 | enum vmxnet3_intr_mask_mode { | ||
360 | VMXNET3_IMM_AUTO = 0, | ||
361 | VMXNET3_IMM_ACTIVE = 1, | ||
362 | VMXNET3_IMM_LAZY = 2 | ||
363 | }; | ||
364 | |||
365 | enum vmxnet3_intr_type { | ||
366 | VMXNET3_IT_AUTO = 0, | ||
367 | VMXNET3_IT_INTX = 1, | ||
368 | VMXNET3_IT_MSI = 2, | ||
369 | VMXNET3_IT_MSIX = 3 | ||
370 | }; | ||
371 | |||
372 | #define VMXNET3_MAX_TX_QUEUES 8 | ||
373 | #define VMXNET3_MAX_RX_QUEUES 16 | ||
374 | /* addition 1 for events */ | ||
375 | #define VMXNET3_MAX_INTRS 25 | ||
376 | |||
377 | |||
378 | struct Vmxnet3_IntrConf { | ||
379 | bool autoMask; | ||
380 | u8 numIntrs; /* # of interrupts */ | ||
381 | u8 eventIntrIdx; | ||
382 | u8 modLevels[VMXNET3_MAX_INTRS]; /* moderation level for | ||
383 | * each intr */ | ||
384 | u32 reserved[3]; | ||
385 | }; | ||
386 | |||
387 | /* one bit per VLAN ID, the size is in the units of u32 */ | ||
388 | #define VMXNET3_VFT_SIZE (4096 / (sizeof(u32) * 8)) | ||
389 | |||
390 | |||
391 | struct Vmxnet3_QueueStatus { | ||
392 | bool stopped; | ||
393 | u8 _pad[3]; | ||
394 | u32 error; | ||
395 | }; | ||
396 | |||
397 | |||
398 | struct Vmxnet3_TxQueueCtrl { | ||
399 | u32 txNumDeferred; | ||
400 | u32 txThreshold; | ||
401 | u64 reserved; | ||
402 | }; | ||
403 | |||
404 | |||
405 | struct Vmxnet3_RxQueueCtrl { | ||
406 | bool updateRxProd; | ||
407 | u8 _pad[7]; | ||
408 | u64 reserved; | ||
409 | }; | ||
410 | |||
411 | enum { | ||
412 | VMXNET3_RXM_UCAST = 0x01, /* unicast only */ | ||
413 | VMXNET3_RXM_MCAST = 0x02, /* multicast passing the filters */ | ||
414 | VMXNET3_RXM_BCAST = 0x04, /* broadcast only */ | ||
415 | VMXNET3_RXM_ALL_MULTI = 0x08, /* all multicast */ | ||
416 | VMXNET3_RXM_PROMISC = 0x10 /* promiscuous */ | ||
417 | }; | ||
418 | |||
419 | struct Vmxnet3_RxFilterConf { | ||
420 | u32 rxMode; /* VMXNET3_RXM_xxx */ | ||
421 | u16 mfTableLen; /* size of the multicast filter table */ | ||
422 | u16 _pad1; | ||
423 | u64 mfTablePA; /* PA of the multicast filters table */ | ||
424 | u32 vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */ | ||
425 | }; | ||
426 | |||
427 | |||
428 | #define VMXNET3_PM_MAX_FILTERS 6 | ||
429 | #define VMXNET3_PM_MAX_PATTERN_SIZE 128 | ||
430 | #define VMXNET3_PM_MAX_MASK_SIZE (VMXNET3_PM_MAX_PATTERN_SIZE / 8) | ||
431 | |||
432 | #define VMXNET3_PM_WAKEUP_MAGIC 0x01 /* wake up on magic pkts */ | ||
433 | #define VMXNET3_PM_WAKEUP_FILTER 0x02 /* wake up on pkts matching | ||
434 | * filters */ | ||
435 | |||
436 | |||
437 | struct Vmxnet3_PM_PktFilter { | ||
438 | u8 maskSize; | ||
439 | u8 patternSize; | ||
440 | u8 mask[VMXNET3_PM_MAX_MASK_SIZE]; | ||
441 | u8 pattern[VMXNET3_PM_MAX_PATTERN_SIZE]; | ||
442 | u8 pad[6]; | ||
443 | }; | ||
444 | |||
445 | |||
446 | struct Vmxnet3_PMConf { | ||
447 | u16 wakeUpEvents; /* VMXNET3_PM_WAKEUP_xxx */ | ||
448 | u8 numFilters; | ||
449 | u8 pad[5]; | ||
450 | struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS]; | ||
451 | }; | ||
452 | |||
453 | |||
454 | struct Vmxnet3_VariableLenConfDesc { | ||
455 | u32 confVer; | ||
456 | u32 confLen; | ||
457 | u64 confPA; | ||
458 | }; | ||
459 | |||
460 | |||
461 | struct Vmxnet3_TxQueueDesc { | ||
462 | struct Vmxnet3_TxQueueCtrl ctrl; | ||
463 | struct Vmxnet3_TxQueueConf conf; | ||
464 | |||
465 | /* Driver read after a GET command */ | ||
466 | struct Vmxnet3_QueueStatus status; | ||
467 | struct UPT1_TxStats stats; | ||
468 | u8 _pad[88]; /* 128 aligned */ | ||
469 | }; | ||
470 | |||
471 | |||
472 | struct Vmxnet3_RxQueueDesc { | ||
473 | struct Vmxnet3_RxQueueCtrl ctrl; | ||
474 | struct Vmxnet3_RxQueueConf conf; | ||
475 | /* Driver read after a GET commad */ | ||
476 | struct Vmxnet3_QueueStatus status; | ||
477 | struct UPT1_RxStats stats; | ||
478 | u8 __pad[88]; /* 128 aligned */ | ||
479 | }; | ||
480 | |||
481 | |||
482 | struct Vmxnet3_DSDevRead { | ||
483 | /* read-only region for device, read by dev in response to a SET cmd */ | ||
484 | struct Vmxnet3_MiscConf misc; | ||
485 | struct Vmxnet3_IntrConf intrConf; | ||
486 | struct Vmxnet3_RxFilterConf rxFilterConf; | ||
487 | struct Vmxnet3_VariableLenConfDesc rssConfDesc; | ||
488 | struct Vmxnet3_VariableLenConfDesc pmConfDesc; | ||
489 | struct Vmxnet3_VariableLenConfDesc pluginConfDesc; | ||
490 | }; | ||
491 | |||
492 | /* All structures in DriverShared are padded to multiples of 8 bytes */ | ||
493 | struct Vmxnet3_DriverShared { | ||
494 | u32 magic; | ||
495 | /* make devRead start at 64bit boundaries */ | ||
496 | u32 pad; | ||
497 | struct Vmxnet3_DSDevRead devRead; | ||
498 | u32 ecr; | ||
499 | u32 reserved[5]; | ||
500 | }; | ||
501 | |||
502 | |||
503 | #define VMXNET3_ECR_RQERR (1 << 0) | ||
504 | #define VMXNET3_ECR_TQERR (1 << 1) | ||
505 | #define VMXNET3_ECR_LINK (1 << 2) | ||
506 | #define VMXNET3_ECR_DIC (1 << 3) | ||
507 | #define VMXNET3_ECR_DEBUG (1 << 4) | ||
508 | |||
509 | /* flip the gen bit of a ring */ | ||
510 | #define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1) | ||
511 | |||
512 | /* only use this if moving the idx won't affect the gen bit */ | ||
513 | #define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \ | ||
514 | do {\ | ||
515 | (idx)++;\ | ||
516 | if (unlikely((idx) == (ring_size))) {\ | ||
517 | (idx) = 0;\ | ||
518 | } \ | ||
519 | } while (0) | ||
520 | |||
521 | #define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \ | ||
522 | (vfTable[vid >> 5] |= (1 << (vid & 31))) | ||
523 | #define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \ | ||
524 | (vfTable[vid >> 5] &= ~(1 << (vid & 31))) | ||
525 | |||
526 | #define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \ | ||
527 | ((vfTable[vid >> 5] & (1 << (vid & 31))) != 0) | ||
528 | |||
529 | #define VMXNET3_MAX_MTU 9000 | ||
530 | #define VMXNET3_MIN_MTU 60 | ||
531 | |||
532 | #define VMXNET3_LINK_UP (10000 << 16 | 1) /* 10 Gbps, up */ | ||
533 | #define VMXNET3_LINK_DOWN 0 | ||
534 | |||
535 | #endif /* _VMXNET3_DEFS_H_ */ | ||
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c new file mode 100644 index 000000000000..004353a46af0 --- /dev/null +++ b/drivers/net/vmxnet3/vmxnet3_drv.c | |||
@@ -0,0 +1,2574 @@ | |||
1 | /* | ||
2 | * Linux driver for VMware's vmxnet3 ethernet NIC. | ||
3 | * | ||
4 | * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; version 2 of the License and no later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
13 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
14 | * details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution in | ||
21 | * the file called "COPYING". | ||
22 | * | ||
23 | * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #include "vmxnet3_int.h" | ||
28 | |||
29 | char vmxnet3_driver_name[] = "vmxnet3"; | ||
30 | #define VMXNET3_DRIVER_DESC "VMware vmxnet3 virtual NIC driver" | ||
31 | |||
32 | |||
33 | /* | ||
34 | * PCI Device ID Table | ||
35 | * Last entry must be all 0s | ||
36 | */ | ||
37 | static const struct pci_device_id vmxnet3_pciid_table[] = { | ||
38 | {PCI_VDEVICE(VMWARE, PCI_DEVICE_ID_VMWARE_VMXNET3)}, | ||
39 | {0} | ||
40 | }; | ||
41 | |||
42 | MODULE_DEVICE_TABLE(pci, vmxnet3_pciid_table); | ||
43 | |||
44 | static atomic_t devices_found; | ||
45 | |||
46 | |||
47 | /* | ||
48 | * Enable/Disable the given intr | ||
49 | */ | ||
50 | static void | ||
51 | vmxnet3_enable_intr(struct vmxnet3_adapter *adapter, unsigned intr_idx) | ||
52 | { | ||
53 | VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_IMR + intr_idx * 8, 0); | ||
54 | } | ||
55 | |||
56 | |||
57 | static void | ||
58 | vmxnet3_disable_intr(struct vmxnet3_adapter *adapter, unsigned intr_idx) | ||
59 | { | ||
60 | VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_IMR + intr_idx * 8, 1); | ||
61 | } | ||
62 | |||
63 | |||
64 | /* | ||
65 | * Enable/Disable all intrs used by the device | ||
66 | */ | ||
67 | static void | ||
68 | vmxnet3_enable_all_intrs(struct vmxnet3_adapter *adapter) | ||
69 | { | ||
70 | int i; | ||
71 | |||
72 | for (i = 0; i < adapter->intr.num_intrs; i++) | ||
73 | vmxnet3_enable_intr(adapter, i); | ||
74 | } | ||
75 | |||
76 | |||
77 | static void | ||
78 | vmxnet3_disable_all_intrs(struct vmxnet3_adapter *adapter) | ||
79 | { | ||
80 | int i; | ||
81 | |||
82 | for (i = 0; i < adapter->intr.num_intrs; i++) | ||
83 | vmxnet3_disable_intr(adapter, i); | ||
84 | } | ||
85 | |||
86 | |||
87 | static void | ||
88 | vmxnet3_ack_events(struct vmxnet3_adapter *adapter, u32 events) | ||
89 | { | ||
90 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_ECR, events); | ||
91 | } | ||
92 | |||
93 | |||
94 | static bool | ||
95 | vmxnet3_tq_stopped(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) | ||
96 | { | ||
97 | return netif_queue_stopped(adapter->netdev); | ||
98 | } | ||
99 | |||
100 | |||
101 | static void | ||
102 | vmxnet3_tq_start(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) | ||
103 | { | ||
104 | tq->stopped = false; | ||
105 | netif_start_queue(adapter->netdev); | ||
106 | } | ||
107 | |||
108 | |||
109 | static void | ||
110 | vmxnet3_tq_wake(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) | ||
111 | { | ||
112 | tq->stopped = false; | ||
113 | netif_wake_queue(adapter->netdev); | ||
114 | } | ||
115 | |||
116 | |||
117 | static void | ||
118 | vmxnet3_tq_stop(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) | ||
119 | { | ||
120 | tq->stopped = true; | ||
121 | tq->num_stop++; | ||
122 | netif_stop_queue(adapter->netdev); | ||
123 | } | ||
124 | |||
125 | |||
126 | /* | ||
127 | * Check the link state. This may start or stop the tx queue. | ||
128 | */ | ||
129 | static void | ||
130 | vmxnet3_check_link(struct vmxnet3_adapter *adapter) | ||
131 | { | ||
132 | u32 ret; | ||
133 | |||
134 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_LINK); | ||
135 | ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); | ||
136 | adapter->link_speed = ret >> 16; | ||
137 | if (ret & 1) { /* Link is up. */ | ||
138 | printk(KERN_INFO "%s: NIC Link is Up %d Mbps\n", | ||
139 | adapter->netdev->name, adapter->link_speed); | ||
140 | if (!netif_carrier_ok(adapter->netdev)) | ||
141 | netif_carrier_on(adapter->netdev); | ||
142 | |||
143 | vmxnet3_tq_start(&adapter->tx_queue, adapter); | ||
144 | } else { | ||
145 | printk(KERN_INFO "%s: NIC Link is Down\n", | ||
146 | adapter->netdev->name); | ||
147 | if (netif_carrier_ok(adapter->netdev)) | ||
148 | netif_carrier_off(adapter->netdev); | ||
149 | |||
150 | vmxnet3_tq_stop(&adapter->tx_queue, adapter); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | |||
155 | static void | ||
156 | vmxnet3_process_events(struct vmxnet3_adapter *adapter) | ||
157 | { | ||
158 | u32 events = adapter->shared->ecr; | ||
159 | if (!events) | ||
160 | return; | ||
161 | |||
162 | vmxnet3_ack_events(adapter, events); | ||
163 | |||
164 | /* Check if link state has changed */ | ||
165 | if (events & VMXNET3_ECR_LINK) | ||
166 | vmxnet3_check_link(adapter); | ||
167 | |||
168 | /* Check if there is an error on xmit/recv queues */ | ||
169 | if (events & (VMXNET3_ECR_TQERR | VMXNET3_ECR_RQERR)) { | ||
170 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
171 | VMXNET3_CMD_GET_QUEUE_STATUS); | ||
172 | |||
173 | if (adapter->tqd_start->status.stopped) { | ||
174 | printk(KERN_ERR "%s: tq error 0x%x\n", | ||
175 | adapter->netdev->name, | ||
176 | adapter->tqd_start->status.error); | ||
177 | } | ||
178 | if (adapter->rqd_start->status.stopped) { | ||
179 | printk(KERN_ERR "%s: rq error 0x%x\n", | ||
180 | adapter->netdev->name, | ||
181 | adapter->rqd_start->status.error); | ||
182 | } | ||
183 | |||
184 | schedule_work(&adapter->work); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | |||
189 | static void | ||
190 | vmxnet3_unmap_tx_buf(struct vmxnet3_tx_buf_info *tbi, | ||
191 | struct pci_dev *pdev) | ||
192 | { | ||
193 | if (tbi->map_type == VMXNET3_MAP_SINGLE) | ||
194 | pci_unmap_single(pdev, tbi->dma_addr, tbi->len, | ||
195 | PCI_DMA_TODEVICE); | ||
196 | else if (tbi->map_type == VMXNET3_MAP_PAGE) | ||
197 | pci_unmap_page(pdev, tbi->dma_addr, tbi->len, | ||
198 | PCI_DMA_TODEVICE); | ||
199 | else | ||
200 | BUG_ON(tbi->map_type != VMXNET3_MAP_NONE); | ||
201 | |||
202 | tbi->map_type = VMXNET3_MAP_NONE; /* to help debugging */ | ||
203 | } | ||
204 | |||
205 | |||
206 | static int | ||
207 | vmxnet3_unmap_pkt(u32 eop_idx, struct vmxnet3_tx_queue *tq, | ||
208 | struct pci_dev *pdev, struct vmxnet3_adapter *adapter) | ||
209 | { | ||
210 | struct sk_buff *skb; | ||
211 | int entries = 0; | ||
212 | |||
213 | /* no out of order completion */ | ||
214 | BUG_ON(tq->buf_info[eop_idx].sop_idx != tq->tx_ring.next2comp); | ||
215 | BUG_ON(tq->tx_ring.base[eop_idx].txd.eop != 1); | ||
216 | |||
217 | skb = tq->buf_info[eop_idx].skb; | ||
218 | BUG_ON(skb == NULL); | ||
219 | tq->buf_info[eop_idx].skb = NULL; | ||
220 | |||
221 | VMXNET3_INC_RING_IDX_ONLY(eop_idx, tq->tx_ring.size); | ||
222 | |||
223 | while (tq->tx_ring.next2comp != eop_idx) { | ||
224 | vmxnet3_unmap_tx_buf(tq->buf_info + tq->tx_ring.next2comp, | ||
225 | pdev); | ||
226 | |||
227 | /* update next2comp w/o tx_lock. Since we are marking more, | ||
228 | * instead of less, tx ring entries avail, the worst case is | ||
229 | * that the tx routine incorrectly re-queues a pkt due to | ||
230 | * insufficient tx ring entries. | ||
231 | */ | ||
232 | vmxnet3_cmd_ring_adv_next2comp(&tq->tx_ring); | ||
233 | entries++; | ||
234 | } | ||
235 | |||
236 | dev_kfree_skb_any(skb); | ||
237 | return entries; | ||
238 | } | ||
239 | |||
240 | |||
241 | static int | ||
242 | vmxnet3_tq_tx_complete(struct vmxnet3_tx_queue *tq, | ||
243 | struct vmxnet3_adapter *adapter) | ||
244 | { | ||
245 | int completed = 0; | ||
246 | union Vmxnet3_GenericDesc *gdesc; | ||
247 | |||
248 | gdesc = tq->comp_ring.base + tq->comp_ring.next2proc; | ||
249 | while (gdesc->tcd.gen == tq->comp_ring.gen) { | ||
250 | completed += vmxnet3_unmap_pkt(gdesc->tcd.txdIdx, tq, | ||
251 | adapter->pdev, adapter); | ||
252 | |||
253 | vmxnet3_comp_ring_adv_next2proc(&tq->comp_ring); | ||
254 | gdesc = tq->comp_ring.base + tq->comp_ring.next2proc; | ||
255 | } | ||
256 | |||
257 | if (completed) { | ||
258 | spin_lock(&tq->tx_lock); | ||
259 | if (unlikely(vmxnet3_tq_stopped(tq, adapter) && | ||
260 | vmxnet3_cmd_ring_desc_avail(&tq->tx_ring) > | ||
261 | VMXNET3_WAKE_QUEUE_THRESHOLD(tq) && | ||
262 | netif_carrier_ok(adapter->netdev))) { | ||
263 | vmxnet3_tq_wake(tq, adapter); | ||
264 | } | ||
265 | spin_unlock(&tq->tx_lock); | ||
266 | } | ||
267 | return completed; | ||
268 | } | ||
269 | |||
270 | |||
271 | static void | ||
272 | vmxnet3_tq_cleanup(struct vmxnet3_tx_queue *tq, | ||
273 | struct vmxnet3_adapter *adapter) | ||
274 | { | ||
275 | int i; | ||
276 | |||
277 | while (tq->tx_ring.next2comp != tq->tx_ring.next2fill) { | ||
278 | struct vmxnet3_tx_buf_info *tbi; | ||
279 | union Vmxnet3_GenericDesc *gdesc; | ||
280 | |||
281 | tbi = tq->buf_info + tq->tx_ring.next2comp; | ||
282 | gdesc = tq->tx_ring.base + tq->tx_ring.next2comp; | ||
283 | |||
284 | vmxnet3_unmap_tx_buf(tbi, adapter->pdev); | ||
285 | if (tbi->skb) { | ||
286 | dev_kfree_skb_any(tbi->skb); | ||
287 | tbi->skb = NULL; | ||
288 | } | ||
289 | vmxnet3_cmd_ring_adv_next2comp(&tq->tx_ring); | ||
290 | } | ||
291 | |||
292 | /* sanity check, verify all buffers are indeed unmapped and freed */ | ||
293 | for (i = 0; i < tq->tx_ring.size; i++) { | ||
294 | BUG_ON(tq->buf_info[i].skb != NULL || | ||
295 | tq->buf_info[i].map_type != VMXNET3_MAP_NONE); | ||
296 | } | ||
297 | |||
298 | tq->tx_ring.gen = VMXNET3_INIT_GEN; | ||
299 | tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0; | ||
300 | |||
301 | tq->comp_ring.gen = VMXNET3_INIT_GEN; | ||
302 | tq->comp_ring.next2proc = 0; | ||
303 | } | ||
304 | |||
305 | |||
306 | void | ||
307 | vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq, | ||
308 | struct vmxnet3_adapter *adapter) | ||
309 | { | ||
310 | if (tq->tx_ring.base) { | ||
311 | pci_free_consistent(adapter->pdev, tq->tx_ring.size * | ||
312 | sizeof(struct Vmxnet3_TxDesc), | ||
313 | tq->tx_ring.base, tq->tx_ring.basePA); | ||
314 | tq->tx_ring.base = NULL; | ||
315 | } | ||
316 | if (tq->data_ring.base) { | ||
317 | pci_free_consistent(adapter->pdev, tq->data_ring.size * | ||
318 | sizeof(struct Vmxnet3_TxDataDesc), | ||
319 | tq->data_ring.base, tq->data_ring.basePA); | ||
320 | tq->data_ring.base = NULL; | ||
321 | } | ||
322 | if (tq->comp_ring.base) { | ||
323 | pci_free_consistent(adapter->pdev, tq->comp_ring.size * | ||
324 | sizeof(struct Vmxnet3_TxCompDesc), | ||
325 | tq->comp_ring.base, tq->comp_ring.basePA); | ||
326 | tq->comp_ring.base = NULL; | ||
327 | } | ||
328 | kfree(tq->buf_info); | ||
329 | tq->buf_info = NULL; | ||
330 | } | ||
331 | |||
332 | |||
333 | static void | ||
334 | vmxnet3_tq_init(struct vmxnet3_tx_queue *tq, | ||
335 | struct vmxnet3_adapter *adapter) | ||
336 | { | ||
337 | int i; | ||
338 | |||
339 | /* reset the tx ring contents to 0 and reset the tx ring states */ | ||
340 | memset(tq->tx_ring.base, 0, tq->tx_ring.size * | ||
341 | sizeof(struct Vmxnet3_TxDesc)); | ||
342 | tq->tx_ring.next2fill = tq->tx_ring.next2comp = 0; | ||
343 | tq->tx_ring.gen = VMXNET3_INIT_GEN; | ||
344 | |||
345 | memset(tq->data_ring.base, 0, tq->data_ring.size * | ||
346 | sizeof(struct Vmxnet3_TxDataDesc)); | ||
347 | |||
348 | /* reset the tx comp ring contents to 0 and reset comp ring states */ | ||
349 | memset(tq->comp_ring.base, 0, tq->comp_ring.size * | ||
350 | sizeof(struct Vmxnet3_TxCompDesc)); | ||
351 | tq->comp_ring.next2proc = 0; | ||
352 | tq->comp_ring.gen = VMXNET3_INIT_GEN; | ||
353 | |||
354 | /* reset the bookkeeping data */ | ||
355 | memset(tq->buf_info, 0, sizeof(tq->buf_info[0]) * tq->tx_ring.size); | ||
356 | for (i = 0; i < tq->tx_ring.size; i++) | ||
357 | tq->buf_info[i].map_type = VMXNET3_MAP_NONE; | ||
358 | |||
359 | /* stats are not reset */ | ||
360 | } | ||
361 | |||
362 | |||
363 | static int | ||
364 | vmxnet3_tq_create(struct vmxnet3_tx_queue *tq, | ||
365 | struct vmxnet3_adapter *adapter) | ||
366 | { | ||
367 | BUG_ON(tq->tx_ring.base || tq->data_ring.base || | ||
368 | tq->comp_ring.base || tq->buf_info); | ||
369 | |||
370 | tq->tx_ring.base = pci_alloc_consistent(adapter->pdev, tq->tx_ring.size | ||
371 | * sizeof(struct Vmxnet3_TxDesc), | ||
372 | &tq->tx_ring.basePA); | ||
373 | if (!tq->tx_ring.base) { | ||
374 | printk(KERN_ERR "%s: failed to allocate tx ring\n", | ||
375 | adapter->netdev->name); | ||
376 | goto err; | ||
377 | } | ||
378 | |||
379 | tq->data_ring.base = pci_alloc_consistent(adapter->pdev, | ||
380 | tq->data_ring.size * | ||
381 | sizeof(struct Vmxnet3_TxDataDesc), | ||
382 | &tq->data_ring.basePA); | ||
383 | if (!tq->data_ring.base) { | ||
384 | printk(KERN_ERR "%s: failed to allocate data ring\n", | ||
385 | adapter->netdev->name); | ||
386 | goto err; | ||
387 | } | ||
388 | |||
389 | tq->comp_ring.base = pci_alloc_consistent(adapter->pdev, | ||
390 | tq->comp_ring.size * | ||
391 | sizeof(struct Vmxnet3_TxCompDesc), | ||
392 | &tq->comp_ring.basePA); | ||
393 | if (!tq->comp_ring.base) { | ||
394 | printk(KERN_ERR "%s: failed to allocate tx comp ring\n", | ||
395 | adapter->netdev->name); | ||
396 | goto err; | ||
397 | } | ||
398 | |||
399 | tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]), | ||
400 | GFP_KERNEL); | ||
401 | if (!tq->buf_info) { | ||
402 | printk(KERN_ERR "%s: failed to allocate tx bufinfo\n", | ||
403 | adapter->netdev->name); | ||
404 | goto err; | ||
405 | } | ||
406 | |||
407 | return 0; | ||
408 | |||
409 | err: | ||
410 | vmxnet3_tq_destroy(tq, adapter); | ||
411 | return -ENOMEM; | ||
412 | } | ||
413 | |||
414 | |||
415 | /* | ||
416 | * starting from ring->next2fill, allocate rx buffers for the given ring | ||
417 | * of the rx queue and update the rx desc. stop after @num_to_alloc buffers | ||
418 | * are allocated or allocation fails | ||
419 | */ | ||
420 | |||
421 | static int | ||
422 | vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx, | ||
423 | int num_to_alloc, struct vmxnet3_adapter *adapter) | ||
424 | { | ||
425 | int num_allocated = 0; | ||
426 | struct vmxnet3_rx_buf_info *rbi_base = rq->buf_info[ring_idx]; | ||
427 | struct vmxnet3_cmd_ring *ring = &rq->rx_ring[ring_idx]; | ||
428 | u32 val; | ||
429 | |||
430 | while (num_allocated < num_to_alloc) { | ||
431 | struct vmxnet3_rx_buf_info *rbi; | ||
432 | union Vmxnet3_GenericDesc *gd; | ||
433 | |||
434 | rbi = rbi_base + ring->next2fill; | ||
435 | gd = ring->base + ring->next2fill; | ||
436 | |||
437 | if (rbi->buf_type == VMXNET3_RX_BUF_SKB) { | ||
438 | if (rbi->skb == NULL) { | ||
439 | rbi->skb = dev_alloc_skb(rbi->len + | ||
440 | NET_IP_ALIGN); | ||
441 | if (unlikely(rbi->skb == NULL)) { | ||
442 | rq->stats.rx_buf_alloc_failure++; | ||
443 | break; | ||
444 | } | ||
445 | rbi->skb->dev = adapter->netdev; | ||
446 | |||
447 | skb_reserve(rbi->skb, NET_IP_ALIGN); | ||
448 | rbi->dma_addr = pci_map_single(adapter->pdev, | ||
449 | rbi->skb->data, rbi->len, | ||
450 | PCI_DMA_FROMDEVICE); | ||
451 | } else { | ||
452 | /* rx buffer skipped by the device */ | ||
453 | } | ||
454 | val = VMXNET3_RXD_BTYPE_HEAD << VMXNET3_RXD_BTYPE_SHIFT; | ||
455 | } else { | ||
456 | BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_PAGE || | ||
457 | rbi->len != PAGE_SIZE); | ||
458 | |||
459 | if (rbi->page == NULL) { | ||
460 | rbi->page = alloc_page(GFP_ATOMIC); | ||
461 | if (unlikely(rbi->page == NULL)) { | ||
462 | rq->stats.rx_buf_alloc_failure++; | ||
463 | break; | ||
464 | } | ||
465 | rbi->dma_addr = pci_map_page(adapter->pdev, | ||
466 | rbi->page, 0, PAGE_SIZE, | ||
467 | PCI_DMA_FROMDEVICE); | ||
468 | } else { | ||
469 | /* rx buffers skipped by the device */ | ||
470 | } | ||
471 | val = VMXNET3_RXD_BTYPE_BODY << VMXNET3_RXD_BTYPE_SHIFT; | ||
472 | } | ||
473 | |||
474 | BUG_ON(rbi->dma_addr == 0); | ||
475 | gd->rxd.addr = rbi->dma_addr; | ||
476 | gd->dword[2] = (ring->gen << VMXNET3_RXD_GEN_SHIFT) | val | | ||
477 | rbi->len; | ||
478 | |||
479 | num_allocated++; | ||
480 | vmxnet3_cmd_ring_adv_next2fill(ring); | ||
481 | } | ||
482 | rq->uncommitted[ring_idx] += num_allocated; | ||
483 | |||
484 | dev_dbg(&adapter->netdev->dev, | ||
485 | "alloc_rx_buf: %d allocated, next2fill %u, next2comp " | ||
486 | "%u, uncommited %u\n", num_allocated, ring->next2fill, | ||
487 | ring->next2comp, rq->uncommitted[ring_idx]); | ||
488 | |||
489 | /* so that the device can distinguish a full ring and an empty ring */ | ||
490 | BUG_ON(num_allocated != 0 && ring->next2fill == ring->next2comp); | ||
491 | |||
492 | return num_allocated; | ||
493 | } | ||
494 | |||
495 | |||
496 | static void | ||
497 | vmxnet3_append_frag(struct sk_buff *skb, struct Vmxnet3_RxCompDesc *rcd, | ||
498 | struct vmxnet3_rx_buf_info *rbi) | ||
499 | { | ||
500 | struct skb_frag_struct *frag = skb_shinfo(skb)->frags + | ||
501 | skb_shinfo(skb)->nr_frags; | ||
502 | |||
503 | BUG_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS); | ||
504 | |||
505 | frag->page = rbi->page; | ||
506 | frag->page_offset = 0; | ||
507 | frag->size = rcd->len; | ||
508 | skb->data_len += frag->size; | ||
509 | skb_shinfo(skb)->nr_frags++; | ||
510 | } | ||
511 | |||
512 | |||
513 | static void | ||
514 | vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx *ctx, | ||
515 | struct vmxnet3_tx_queue *tq, struct pci_dev *pdev, | ||
516 | struct vmxnet3_adapter *adapter) | ||
517 | { | ||
518 | u32 dw2, len; | ||
519 | unsigned long buf_offset; | ||
520 | int i; | ||
521 | union Vmxnet3_GenericDesc *gdesc; | ||
522 | struct vmxnet3_tx_buf_info *tbi = NULL; | ||
523 | |||
524 | BUG_ON(ctx->copy_size > skb_headlen(skb)); | ||
525 | |||
526 | /* use the previous gen bit for the SOP desc */ | ||
527 | dw2 = (tq->tx_ring.gen ^ 0x1) << VMXNET3_TXD_GEN_SHIFT; | ||
528 | |||
529 | ctx->sop_txd = tq->tx_ring.base + tq->tx_ring.next2fill; | ||
530 | gdesc = ctx->sop_txd; /* both loops below can be skipped */ | ||
531 | |||
532 | /* no need to map the buffer if headers are copied */ | ||
533 | if (ctx->copy_size) { | ||
534 | ctx->sop_txd->txd.addr = tq->data_ring.basePA + | ||
535 | tq->tx_ring.next2fill * | ||
536 | sizeof(struct Vmxnet3_TxDataDesc); | ||
537 | ctx->sop_txd->dword[2] = dw2 | ctx->copy_size; | ||
538 | ctx->sop_txd->dword[3] = 0; | ||
539 | |||
540 | tbi = tq->buf_info + tq->tx_ring.next2fill; | ||
541 | tbi->map_type = VMXNET3_MAP_NONE; | ||
542 | |||
543 | dev_dbg(&adapter->netdev->dev, | ||
544 | "txd[%u]: 0x%Lx 0x%x 0x%x\n", | ||
545 | tq->tx_ring.next2fill, ctx->sop_txd->txd.addr, | ||
546 | ctx->sop_txd->dword[2], ctx->sop_txd->dword[3]); | ||
547 | vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring); | ||
548 | |||
549 | /* use the right gen for non-SOP desc */ | ||
550 | dw2 = tq->tx_ring.gen << VMXNET3_TXD_GEN_SHIFT; | ||
551 | } | ||
552 | |||
553 | /* linear part can use multiple tx desc if it's big */ | ||
554 | len = skb_headlen(skb) - ctx->copy_size; | ||
555 | buf_offset = ctx->copy_size; | ||
556 | while (len) { | ||
557 | u32 buf_size; | ||
558 | |||
559 | buf_size = len > VMXNET3_MAX_TX_BUF_SIZE ? | ||
560 | VMXNET3_MAX_TX_BUF_SIZE : len; | ||
561 | |||
562 | tbi = tq->buf_info + tq->tx_ring.next2fill; | ||
563 | tbi->map_type = VMXNET3_MAP_SINGLE; | ||
564 | tbi->dma_addr = pci_map_single(adapter->pdev, | ||
565 | skb->data + buf_offset, buf_size, | ||
566 | PCI_DMA_TODEVICE); | ||
567 | |||
568 | tbi->len = buf_size; /* this automatically convert 2^14 to 0 */ | ||
569 | |||
570 | gdesc = tq->tx_ring.base + tq->tx_ring.next2fill; | ||
571 | BUG_ON(gdesc->txd.gen == tq->tx_ring.gen); | ||
572 | |||
573 | gdesc->txd.addr = tbi->dma_addr; | ||
574 | gdesc->dword[2] = dw2 | buf_size; | ||
575 | gdesc->dword[3] = 0; | ||
576 | |||
577 | dev_dbg(&adapter->netdev->dev, | ||
578 | "txd[%u]: 0x%Lx 0x%x 0x%x\n", | ||
579 | tq->tx_ring.next2fill, gdesc->txd.addr, | ||
580 | gdesc->dword[2], gdesc->dword[3]); | ||
581 | vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring); | ||
582 | dw2 = tq->tx_ring.gen << VMXNET3_TXD_GEN_SHIFT; | ||
583 | |||
584 | len -= buf_size; | ||
585 | buf_offset += buf_size; | ||
586 | } | ||
587 | |||
588 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | ||
589 | struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i]; | ||
590 | |||
591 | tbi = tq->buf_info + tq->tx_ring.next2fill; | ||
592 | tbi->map_type = VMXNET3_MAP_PAGE; | ||
593 | tbi->dma_addr = pci_map_page(adapter->pdev, frag->page, | ||
594 | frag->page_offset, frag->size, | ||
595 | PCI_DMA_TODEVICE); | ||
596 | |||
597 | tbi->len = frag->size; | ||
598 | |||
599 | gdesc = tq->tx_ring.base + tq->tx_ring.next2fill; | ||
600 | BUG_ON(gdesc->txd.gen == tq->tx_ring.gen); | ||
601 | |||
602 | gdesc->txd.addr = tbi->dma_addr; | ||
603 | gdesc->dword[2] = dw2 | frag->size; | ||
604 | gdesc->dword[3] = 0; | ||
605 | |||
606 | dev_dbg(&adapter->netdev->dev, | ||
607 | "txd[%u]: 0x%llu %u %u\n", | ||
608 | tq->tx_ring.next2fill, gdesc->txd.addr, | ||
609 | gdesc->dword[2], gdesc->dword[3]); | ||
610 | vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring); | ||
611 | dw2 = tq->tx_ring.gen << VMXNET3_TXD_GEN_SHIFT; | ||
612 | } | ||
613 | |||
614 | ctx->eop_txd = gdesc; | ||
615 | |||
616 | /* set the last buf_info for the pkt */ | ||
617 | tbi->skb = skb; | ||
618 | tbi->sop_idx = ctx->sop_txd - tq->tx_ring.base; | ||
619 | } | ||
620 | |||
621 | |||
622 | /* | ||
623 | * parse and copy relevant protocol headers: | ||
624 | * For a tso pkt, relevant headers are L2/3/4 including options | ||
625 | * For a pkt requesting csum offloading, they are L2/3 and may include L4 | ||
626 | * if it's a TCP/UDP pkt | ||
627 | * | ||
628 | * Returns: | ||
629 | * -1: error happens during parsing | ||
630 | * 0: protocol headers parsed, but too big to be copied | ||
631 | * 1: protocol headers parsed and copied | ||
632 | * | ||
633 | * Other effects: | ||
634 | * 1. related *ctx fields are updated. | ||
635 | * 2. ctx->copy_size is # of bytes copied | ||
636 | * 3. the portion copied is guaranteed to be in the linear part | ||
637 | * | ||
638 | */ | ||
639 | static int | ||
640 | vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, | ||
641 | struct vmxnet3_tx_ctx *ctx, | ||
642 | struct vmxnet3_adapter *adapter) | ||
643 | { | ||
644 | struct Vmxnet3_TxDataDesc *tdd; | ||
645 | |||
646 | if (ctx->mss) { | ||
647 | ctx->eth_ip_hdr_size = skb_transport_offset(skb); | ||
648 | ctx->l4_hdr_size = ((struct tcphdr *) | ||
649 | skb_transport_header(skb))->doff * 4; | ||
650 | ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; | ||
651 | } else { | ||
652 | unsigned int pull_size; | ||
653 | |||
654 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | ||
655 | ctx->eth_ip_hdr_size = skb_transport_offset(skb); | ||
656 | |||
657 | if (ctx->ipv4) { | ||
658 | struct iphdr *iph = (struct iphdr *) | ||
659 | skb_network_header(skb); | ||
660 | if (iph->protocol == IPPROTO_TCP) { | ||
661 | pull_size = ctx->eth_ip_hdr_size + | ||
662 | sizeof(struct tcphdr); | ||
663 | |||
664 | if (unlikely(!pskb_may_pull(skb, | ||
665 | pull_size))) { | ||
666 | goto err; | ||
667 | } | ||
668 | ctx->l4_hdr_size = ((struct tcphdr *) | ||
669 | skb_transport_header(skb))->doff * 4; | ||
670 | } else if (iph->protocol == IPPROTO_UDP) { | ||
671 | ctx->l4_hdr_size = | ||
672 | sizeof(struct udphdr); | ||
673 | } else { | ||
674 | ctx->l4_hdr_size = 0; | ||
675 | } | ||
676 | } else { | ||
677 | /* for simplicity, don't copy L4 headers */ | ||
678 | ctx->l4_hdr_size = 0; | ||
679 | } | ||
680 | ctx->copy_size = ctx->eth_ip_hdr_size + | ||
681 | ctx->l4_hdr_size; | ||
682 | } else { | ||
683 | ctx->eth_ip_hdr_size = 0; | ||
684 | ctx->l4_hdr_size = 0; | ||
685 | /* copy as much as allowed */ | ||
686 | ctx->copy_size = min((unsigned int)VMXNET3_HDR_COPY_SIZE | ||
687 | , skb_headlen(skb)); | ||
688 | } | ||
689 | |||
690 | /* make sure headers are accessible directly */ | ||
691 | if (unlikely(!pskb_may_pull(skb, ctx->copy_size))) | ||
692 | goto err; | ||
693 | } | ||
694 | |||
695 | if (unlikely(ctx->copy_size > VMXNET3_HDR_COPY_SIZE)) { | ||
696 | tq->stats.oversized_hdr++; | ||
697 | ctx->copy_size = 0; | ||
698 | return 0; | ||
699 | } | ||
700 | |||
701 | tdd = tq->data_ring.base + tq->tx_ring.next2fill; | ||
702 | |||
703 | memcpy(tdd->data, skb->data, ctx->copy_size); | ||
704 | dev_dbg(&adapter->netdev->dev, | ||
705 | "copy %u bytes to dataRing[%u]\n", | ||
706 | ctx->copy_size, tq->tx_ring.next2fill); | ||
707 | return 1; | ||
708 | |||
709 | err: | ||
710 | return -1; | ||
711 | } | ||
712 | |||
713 | |||
714 | static void | ||
715 | vmxnet3_prepare_tso(struct sk_buff *skb, | ||
716 | struct vmxnet3_tx_ctx *ctx) | ||
717 | { | ||
718 | struct tcphdr *tcph = (struct tcphdr *)skb_transport_header(skb); | ||
719 | if (ctx->ipv4) { | ||
720 | struct iphdr *iph = (struct iphdr *)skb_network_header(skb); | ||
721 | iph->check = 0; | ||
722 | tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, | ||
723 | IPPROTO_TCP, 0); | ||
724 | } else { | ||
725 | struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header(skb); | ||
726 | tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0, | ||
727 | IPPROTO_TCP, 0); | ||
728 | } | ||
729 | } | ||
730 | |||
731 | |||
732 | /* | ||
733 | * Transmits a pkt thru a given tq | ||
734 | * Returns: | ||
735 | * NETDEV_TX_OK: descriptors are setup successfully | ||
736 | * NETDEV_TX_OK: error occured, the pkt is dropped | ||
737 | * NETDEV_TX_BUSY: tx ring is full, queue is stopped | ||
738 | * | ||
739 | * Side-effects: | ||
740 | * 1. tx ring may be changed | ||
741 | * 2. tq stats may be updated accordingly | ||
742 | * 3. shared->txNumDeferred may be updated | ||
743 | */ | ||
744 | |||
745 | static int | ||
746 | vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, | ||
747 | struct vmxnet3_adapter *adapter, struct net_device *netdev) | ||
748 | { | ||
749 | int ret; | ||
750 | u32 count; | ||
751 | unsigned long flags; | ||
752 | struct vmxnet3_tx_ctx ctx; | ||
753 | union Vmxnet3_GenericDesc *gdesc; | ||
754 | |||
755 | /* conservatively estimate # of descriptors to use */ | ||
756 | count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) + | ||
757 | skb_shinfo(skb)->nr_frags + 1; | ||
758 | |||
759 | ctx.ipv4 = (skb->protocol == __constant_ntohs(ETH_P_IP)); | ||
760 | |||
761 | ctx.mss = skb_shinfo(skb)->gso_size; | ||
762 | if (ctx.mss) { | ||
763 | if (skb_header_cloned(skb)) { | ||
764 | if (unlikely(pskb_expand_head(skb, 0, 0, | ||
765 | GFP_ATOMIC) != 0)) { | ||
766 | tq->stats.drop_tso++; | ||
767 | goto drop_pkt; | ||
768 | } | ||
769 | tq->stats.copy_skb_header++; | ||
770 | } | ||
771 | vmxnet3_prepare_tso(skb, &ctx); | ||
772 | } else { | ||
773 | if (unlikely(count > VMXNET3_MAX_TXD_PER_PKT)) { | ||
774 | |||
775 | /* non-tso pkts must not use more than | ||
776 | * VMXNET3_MAX_TXD_PER_PKT entries | ||
777 | */ | ||
778 | if (skb_linearize(skb) != 0) { | ||
779 | tq->stats.drop_too_many_frags++; | ||
780 | goto drop_pkt; | ||
781 | } | ||
782 | tq->stats.linearized++; | ||
783 | |||
784 | /* recalculate the # of descriptors to use */ | ||
785 | count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) + 1; | ||
786 | } | ||
787 | } | ||
788 | |||
789 | ret = vmxnet3_parse_and_copy_hdr(skb, tq, &ctx, adapter); | ||
790 | if (ret >= 0) { | ||
791 | BUG_ON(ret <= 0 && ctx.copy_size != 0); | ||
792 | /* hdrs parsed, check against other limits */ | ||
793 | if (ctx.mss) { | ||
794 | if (unlikely(ctx.eth_ip_hdr_size + ctx.l4_hdr_size > | ||
795 | VMXNET3_MAX_TX_BUF_SIZE)) { | ||
796 | goto hdr_too_big; | ||
797 | } | ||
798 | } else { | ||
799 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | ||
800 | if (unlikely(ctx.eth_ip_hdr_size + | ||
801 | skb->csum_offset > | ||
802 | VMXNET3_MAX_CSUM_OFFSET)) { | ||
803 | goto hdr_too_big; | ||
804 | } | ||
805 | } | ||
806 | } | ||
807 | } else { | ||
808 | tq->stats.drop_hdr_inspect_err++; | ||
809 | goto drop_pkt; | ||
810 | } | ||
811 | |||
812 | spin_lock_irqsave(&tq->tx_lock, flags); | ||
813 | |||
814 | if (count > vmxnet3_cmd_ring_desc_avail(&tq->tx_ring)) { | ||
815 | tq->stats.tx_ring_full++; | ||
816 | dev_dbg(&adapter->netdev->dev, | ||
817 | "tx queue stopped on %s, next2comp %u" | ||
818 | " next2fill %u\n", adapter->netdev->name, | ||
819 | tq->tx_ring.next2comp, tq->tx_ring.next2fill); | ||
820 | |||
821 | vmxnet3_tq_stop(tq, adapter); | ||
822 | spin_unlock_irqrestore(&tq->tx_lock, flags); | ||
823 | return NETDEV_TX_BUSY; | ||
824 | } | ||
825 | |||
826 | /* fill tx descs related to addr & len */ | ||
827 | vmxnet3_map_pkt(skb, &ctx, tq, adapter->pdev, adapter); | ||
828 | |||
829 | /* setup the EOP desc */ | ||
830 | ctx.eop_txd->dword[3] = VMXNET3_TXD_CQ | VMXNET3_TXD_EOP; | ||
831 | |||
832 | /* setup the SOP desc */ | ||
833 | gdesc = ctx.sop_txd; | ||
834 | if (ctx.mss) { | ||
835 | gdesc->txd.hlen = ctx.eth_ip_hdr_size + ctx.l4_hdr_size; | ||
836 | gdesc->txd.om = VMXNET3_OM_TSO; | ||
837 | gdesc->txd.msscof = ctx.mss; | ||
838 | tq->shared->txNumDeferred += (skb->len - gdesc->txd.hlen + | ||
839 | ctx.mss - 1) / ctx.mss; | ||
840 | } else { | ||
841 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | ||
842 | gdesc->txd.hlen = ctx.eth_ip_hdr_size; | ||
843 | gdesc->txd.om = VMXNET3_OM_CSUM; | ||
844 | gdesc->txd.msscof = ctx.eth_ip_hdr_size + | ||
845 | skb->csum_offset; | ||
846 | } else { | ||
847 | gdesc->txd.om = 0; | ||
848 | gdesc->txd.msscof = 0; | ||
849 | } | ||
850 | tq->shared->txNumDeferred++; | ||
851 | } | ||
852 | |||
853 | if (vlan_tx_tag_present(skb)) { | ||
854 | gdesc->txd.ti = 1; | ||
855 | gdesc->txd.tci = vlan_tx_tag_get(skb); | ||
856 | } | ||
857 | |||
858 | wmb(); | ||
859 | |||
860 | /* finally flips the GEN bit of the SOP desc */ | ||
861 | gdesc->dword[2] ^= VMXNET3_TXD_GEN; | ||
862 | dev_dbg(&adapter->netdev->dev, | ||
863 | "txd[%u]: SOP 0x%Lx 0x%x 0x%x\n", | ||
864 | (u32)((union Vmxnet3_GenericDesc *)ctx.sop_txd - | ||
865 | tq->tx_ring.base), gdesc->txd.addr, gdesc->dword[2], | ||
866 | gdesc->dword[3]); | ||
867 | |||
868 | spin_unlock_irqrestore(&tq->tx_lock, flags); | ||
869 | |||
870 | if (tq->shared->txNumDeferred >= tq->shared->txThreshold) { | ||
871 | tq->shared->txNumDeferred = 0; | ||
872 | VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_TXPROD, | ||
873 | tq->tx_ring.next2fill); | ||
874 | } | ||
875 | netdev->trans_start = jiffies; | ||
876 | |||
877 | return NETDEV_TX_OK; | ||
878 | |||
879 | hdr_too_big: | ||
880 | tq->stats.drop_oversized_hdr++; | ||
881 | drop_pkt: | ||
882 | tq->stats.drop_total++; | ||
883 | dev_kfree_skb(skb); | ||
884 | return NETDEV_TX_OK; | ||
885 | } | ||
886 | |||
887 | |||
888 | static netdev_tx_t | ||
889 | vmxnet3_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | ||
890 | { | ||
891 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
892 | struct vmxnet3_tx_queue *tq = &adapter->tx_queue; | ||
893 | |||
894 | return vmxnet3_tq_xmit(skb, tq, adapter, netdev); | ||
895 | } | ||
896 | |||
897 | |||
898 | static void | ||
899 | vmxnet3_rx_csum(struct vmxnet3_adapter *adapter, | ||
900 | struct sk_buff *skb, | ||
901 | union Vmxnet3_GenericDesc *gdesc) | ||
902 | { | ||
903 | if (!gdesc->rcd.cnc && adapter->rxcsum) { | ||
904 | /* typical case: TCP/UDP over IP and both csums are correct */ | ||
905 | if ((gdesc->dword[3] & VMXNET3_RCD_CSUM_OK) == | ||
906 | VMXNET3_RCD_CSUM_OK) { | ||
907 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
908 | BUG_ON(!(gdesc->rcd.tcp || gdesc->rcd.udp)); | ||
909 | BUG_ON(!(gdesc->rcd.v4 || gdesc->rcd.v6)); | ||
910 | BUG_ON(gdesc->rcd.frg); | ||
911 | } else { | ||
912 | if (gdesc->rcd.csum) { | ||
913 | skb->csum = htons(gdesc->rcd.csum); | ||
914 | skb->ip_summed = CHECKSUM_PARTIAL; | ||
915 | } else { | ||
916 | skb->ip_summed = CHECKSUM_NONE; | ||
917 | } | ||
918 | } | ||
919 | } else { | ||
920 | skb->ip_summed = CHECKSUM_NONE; | ||
921 | } | ||
922 | } | ||
923 | |||
924 | |||
925 | static void | ||
926 | vmxnet3_rx_error(struct vmxnet3_rx_queue *rq, struct Vmxnet3_RxCompDesc *rcd, | ||
927 | struct vmxnet3_rx_ctx *ctx, struct vmxnet3_adapter *adapter) | ||
928 | { | ||
929 | rq->stats.drop_err++; | ||
930 | if (!rcd->fcs) | ||
931 | rq->stats.drop_fcs++; | ||
932 | |||
933 | rq->stats.drop_total++; | ||
934 | |||
935 | /* | ||
936 | * We do not unmap and chain the rx buffer to the skb. | ||
937 | * We basically pretend this buffer is not used and will be recycled | ||
938 | * by vmxnet3_rq_alloc_rx_buf() | ||
939 | */ | ||
940 | |||
941 | /* | ||
942 | * ctx->skb may be NULL if this is the first and the only one | ||
943 | * desc for the pkt | ||
944 | */ | ||
945 | if (ctx->skb) | ||
946 | dev_kfree_skb_irq(ctx->skb); | ||
947 | |||
948 | ctx->skb = NULL; | ||
949 | } | ||
950 | |||
951 | |||
952 | static int | ||
953 | vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, | ||
954 | struct vmxnet3_adapter *adapter, int quota) | ||
955 | { | ||
956 | static u32 rxprod_reg[2] = {VMXNET3_REG_RXPROD, VMXNET3_REG_RXPROD2}; | ||
957 | u32 num_rxd = 0; | ||
958 | struct Vmxnet3_RxCompDesc *rcd; | ||
959 | struct vmxnet3_rx_ctx *ctx = &rq->rx_ctx; | ||
960 | |||
961 | rcd = &rq->comp_ring.base[rq->comp_ring.next2proc].rcd; | ||
962 | while (rcd->gen == rq->comp_ring.gen) { | ||
963 | struct vmxnet3_rx_buf_info *rbi; | ||
964 | struct sk_buff *skb; | ||
965 | int num_to_alloc; | ||
966 | struct Vmxnet3_RxDesc *rxd; | ||
967 | u32 idx, ring_idx; | ||
968 | |||
969 | if (num_rxd >= quota) { | ||
970 | /* we may stop even before we see the EOP desc of | ||
971 | * the current pkt | ||
972 | */ | ||
973 | break; | ||
974 | } | ||
975 | num_rxd++; | ||
976 | |||
977 | idx = rcd->rxdIdx; | ||
978 | ring_idx = rcd->rqID == rq->qid ? 0 : 1; | ||
979 | |||
980 | rxd = &rq->rx_ring[ring_idx].base[idx].rxd; | ||
981 | rbi = rq->buf_info[ring_idx] + idx; | ||
982 | |||
983 | BUG_ON(rxd->addr != rbi->dma_addr || rxd->len != rbi->len); | ||
984 | |||
985 | if (unlikely(rcd->eop && rcd->err)) { | ||
986 | vmxnet3_rx_error(rq, rcd, ctx, adapter); | ||
987 | goto rcd_done; | ||
988 | } | ||
989 | |||
990 | if (rcd->sop) { /* first buf of the pkt */ | ||
991 | BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_HEAD || | ||
992 | rcd->rqID != rq->qid); | ||
993 | |||
994 | BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_SKB); | ||
995 | BUG_ON(ctx->skb != NULL || rbi->skb == NULL); | ||
996 | |||
997 | if (unlikely(rcd->len == 0)) { | ||
998 | /* Pretend the rx buffer is skipped. */ | ||
999 | BUG_ON(!(rcd->sop && rcd->eop)); | ||
1000 | dev_dbg(&adapter->netdev->dev, | ||
1001 | "rxRing[%u][%u] 0 length\n", | ||
1002 | ring_idx, idx); | ||
1003 | goto rcd_done; | ||
1004 | } | ||
1005 | |||
1006 | ctx->skb = rbi->skb; | ||
1007 | rbi->skb = NULL; | ||
1008 | |||
1009 | pci_unmap_single(adapter->pdev, rbi->dma_addr, rbi->len, | ||
1010 | PCI_DMA_FROMDEVICE); | ||
1011 | |||
1012 | skb_put(ctx->skb, rcd->len); | ||
1013 | } else { | ||
1014 | BUG_ON(ctx->skb == NULL); | ||
1015 | /* non SOP buffer must be type 1 in most cases */ | ||
1016 | if (rbi->buf_type == VMXNET3_RX_BUF_PAGE) { | ||
1017 | BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_BODY); | ||
1018 | |||
1019 | if (rcd->len) { | ||
1020 | pci_unmap_page(adapter->pdev, | ||
1021 | rbi->dma_addr, rbi->len, | ||
1022 | PCI_DMA_FROMDEVICE); | ||
1023 | |||
1024 | vmxnet3_append_frag(ctx->skb, rcd, rbi); | ||
1025 | rbi->page = NULL; | ||
1026 | } | ||
1027 | } else { | ||
1028 | /* | ||
1029 | * The only time a non-SOP buffer is type 0 is | ||
1030 | * when it's EOP and error flag is raised, which | ||
1031 | * has already been handled. | ||
1032 | */ | ||
1033 | BUG_ON(true); | ||
1034 | } | ||
1035 | } | ||
1036 | |||
1037 | skb = ctx->skb; | ||
1038 | if (rcd->eop) { | ||
1039 | skb->len += skb->data_len; | ||
1040 | skb->truesize += skb->data_len; | ||
1041 | |||
1042 | vmxnet3_rx_csum(adapter, skb, | ||
1043 | (union Vmxnet3_GenericDesc *)rcd); | ||
1044 | skb->protocol = eth_type_trans(skb, adapter->netdev); | ||
1045 | |||
1046 | if (unlikely(adapter->vlan_grp && rcd->ts)) { | ||
1047 | vlan_hwaccel_receive_skb(skb, | ||
1048 | adapter->vlan_grp, rcd->tci); | ||
1049 | } else { | ||
1050 | netif_receive_skb(skb); | ||
1051 | } | ||
1052 | |||
1053 | adapter->netdev->last_rx = jiffies; | ||
1054 | ctx->skb = NULL; | ||
1055 | } | ||
1056 | |||
1057 | rcd_done: | ||
1058 | /* device may skip some rx descs */ | ||
1059 | rq->rx_ring[ring_idx].next2comp = idx; | ||
1060 | VMXNET3_INC_RING_IDX_ONLY(rq->rx_ring[ring_idx].next2comp, | ||
1061 | rq->rx_ring[ring_idx].size); | ||
1062 | |||
1063 | /* refill rx buffers frequently to avoid starving the h/w */ | ||
1064 | num_to_alloc = vmxnet3_cmd_ring_desc_avail(rq->rx_ring + | ||
1065 | ring_idx); | ||
1066 | if (unlikely(num_to_alloc > VMXNET3_RX_ALLOC_THRESHOLD(rq, | ||
1067 | ring_idx, adapter))) { | ||
1068 | vmxnet3_rq_alloc_rx_buf(rq, ring_idx, num_to_alloc, | ||
1069 | adapter); | ||
1070 | |||
1071 | /* if needed, update the register */ | ||
1072 | if (unlikely(rq->shared->updateRxProd)) { | ||
1073 | VMXNET3_WRITE_BAR0_REG(adapter, | ||
1074 | rxprod_reg[ring_idx] + rq->qid * 8, | ||
1075 | rq->rx_ring[ring_idx].next2fill); | ||
1076 | rq->uncommitted[ring_idx] = 0; | ||
1077 | } | ||
1078 | } | ||
1079 | |||
1080 | vmxnet3_comp_ring_adv_next2proc(&rq->comp_ring); | ||
1081 | rcd = &rq->comp_ring.base[rq->comp_ring.next2proc].rcd; | ||
1082 | } | ||
1083 | |||
1084 | return num_rxd; | ||
1085 | } | ||
1086 | |||
1087 | |||
1088 | static void | ||
1089 | vmxnet3_rq_cleanup(struct vmxnet3_rx_queue *rq, | ||
1090 | struct vmxnet3_adapter *adapter) | ||
1091 | { | ||
1092 | u32 i, ring_idx; | ||
1093 | struct Vmxnet3_RxDesc *rxd; | ||
1094 | |||
1095 | for (ring_idx = 0; ring_idx < 2; ring_idx++) { | ||
1096 | for (i = 0; i < rq->rx_ring[ring_idx].size; i++) { | ||
1097 | rxd = &rq->rx_ring[ring_idx].base[i].rxd; | ||
1098 | |||
1099 | if (rxd->btype == VMXNET3_RXD_BTYPE_HEAD && | ||
1100 | rq->buf_info[ring_idx][i].skb) { | ||
1101 | pci_unmap_single(adapter->pdev, rxd->addr, | ||
1102 | rxd->len, PCI_DMA_FROMDEVICE); | ||
1103 | dev_kfree_skb(rq->buf_info[ring_idx][i].skb); | ||
1104 | rq->buf_info[ring_idx][i].skb = NULL; | ||
1105 | } else if (rxd->btype == VMXNET3_RXD_BTYPE_BODY && | ||
1106 | rq->buf_info[ring_idx][i].page) { | ||
1107 | pci_unmap_page(adapter->pdev, rxd->addr, | ||
1108 | rxd->len, PCI_DMA_FROMDEVICE); | ||
1109 | put_page(rq->buf_info[ring_idx][i].page); | ||
1110 | rq->buf_info[ring_idx][i].page = NULL; | ||
1111 | } | ||
1112 | } | ||
1113 | |||
1114 | rq->rx_ring[ring_idx].gen = VMXNET3_INIT_GEN; | ||
1115 | rq->rx_ring[ring_idx].next2fill = | ||
1116 | rq->rx_ring[ring_idx].next2comp = 0; | ||
1117 | rq->uncommitted[ring_idx] = 0; | ||
1118 | } | ||
1119 | |||
1120 | rq->comp_ring.gen = VMXNET3_INIT_GEN; | ||
1121 | rq->comp_ring.next2proc = 0; | ||
1122 | } | ||
1123 | |||
1124 | |||
1125 | void vmxnet3_rq_destroy(struct vmxnet3_rx_queue *rq, | ||
1126 | struct vmxnet3_adapter *adapter) | ||
1127 | { | ||
1128 | int i; | ||
1129 | int j; | ||
1130 | |||
1131 | /* all rx buffers must have already been freed */ | ||
1132 | for (i = 0; i < 2; i++) { | ||
1133 | if (rq->buf_info[i]) { | ||
1134 | for (j = 0; j < rq->rx_ring[i].size; j++) | ||
1135 | BUG_ON(rq->buf_info[i][j].page != NULL); | ||
1136 | } | ||
1137 | } | ||
1138 | |||
1139 | |||
1140 | kfree(rq->buf_info[0]); | ||
1141 | |||
1142 | for (i = 0; i < 2; i++) { | ||
1143 | if (rq->rx_ring[i].base) { | ||
1144 | pci_free_consistent(adapter->pdev, rq->rx_ring[i].size | ||
1145 | * sizeof(struct Vmxnet3_RxDesc), | ||
1146 | rq->rx_ring[i].base, | ||
1147 | rq->rx_ring[i].basePA); | ||
1148 | rq->rx_ring[i].base = NULL; | ||
1149 | } | ||
1150 | rq->buf_info[i] = NULL; | ||
1151 | } | ||
1152 | |||
1153 | if (rq->comp_ring.base) { | ||
1154 | pci_free_consistent(adapter->pdev, rq->comp_ring.size * | ||
1155 | sizeof(struct Vmxnet3_RxCompDesc), | ||
1156 | rq->comp_ring.base, rq->comp_ring.basePA); | ||
1157 | rq->comp_ring.base = NULL; | ||
1158 | } | ||
1159 | } | ||
1160 | |||
1161 | |||
1162 | static int | ||
1163 | vmxnet3_rq_init(struct vmxnet3_rx_queue *rq, | ||
1164 | struct vmxnet3_adapter *adapter) | ||
1165 | { | ||
1166 | int i; | ||
1167 | |||
1168 | /* initialize buf_info */ | ||
1169 | for (i = 0; i < rq->rx_ring[0].size; i++) { | ||
1170 | |||
1171 | /* 1st buf for a pkt is skbuff */ | ||
1172 | if (i % adapter->rx_buf_per_pkt == 0) { | ||
1173 | rq->buf_info[0][i].buf_type = VMXNET3_RX_BUF_SKB; | ||
1174 | rq->buf_info[0][i].len = adapter->skb_buf_size; | ||
1175 | } else { /* subsequent bufs for a pkt is frag */ | ||
1176 | rq->buf_info[0][i].buf_type = VMXNET3_RX_BUF_PAGE; | ||
1177 | rq->buf_info[0][i].len = PAGE_SIZE; | ||
1178 | } | ||
1179 | } | ||
1180 | for (i = 0; i < rq->rx_ring[1].size; i++) { | ||
1181 | rq->buf_info[1][i].buf_type = VMXNET3_RX_BUF_PAGE; | ||
1182 | rq->buf_info[1][i].len = PAGE_SIZE; | ||
1183 | } | ||
1184 | |||
1185 | /* reset internal state and allocate buffers for both rings */ | ||
1186 | for (i = 0; i < 2; i++) { | ||
1187 | rq->rx_ring[i].next2fill = rq->rx_ring[i].next2comp = 0; | ||
1188 | rq->uncommitted[i] = 0; | ||
1189 | |||
1190 | memset(rq->rx_ring[i].base, 0, rq->rx_ring[i].size * | ||
1191 | sizeof(struct Vmxnet3_RxDesc)); | ||
1192 | rq->rx_ring[i].gen = VMXNET3_INIT_GEN; | ||
1193 | } | ||
1194 | if (vmxnet3_rq_alloc_rx_buf(rq, 0, rq->rx_ring[0].size - 1, | ||
1195 | adapter) == 0) { | ||
1196 | /* at least has 1 rx buffer for the 1st ring */ | ||
1197 | return -ENOMEM; | ||
1198 | } | ||
1199 | vmxnet3_rq_alloc_rx_buf(rq, 1, rq->rx_ring[1].size - 1, adapter); | ||
1200 | |||
1201 | /* reset the comp ring */ | ||
1202 | rq->comp_ring.next2proc = 0; | ||
1203 | memset(rq->comp_ring.base, 0, rq->comp_ring.size * | ||
1204 | sizeof(struct Vmxnet3_RxCompDesc)); | ||
1205 | rq->comp_ring.gen = VMXNET3_INIT_GEN; | ||
1206 | |||
1207 | /* reset rxctx */ | ||
1208 | rq->rx_ctx.skb = NULL; | ||
1209 | |||
1210 | /* stats are not reset */ | ||
1211 | return 0; | ||
1212 | } | ||
1213 | |||
1214 | |||
1215 | static int | ||
1216 | vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter) | ||
1217 | { | ||
1218 | int i; | ||
1219 | size_t sz; | ||
1220 | struct vmxnet3_rx_buf_info *bi; | ||
1221 | |||
1222 | for (i = 0; i < 2; i++) { | ||
1223 | |||
1224 | sz = rq->rx_ring[i].size * sizeof(struct Vmxnet3_RxDesc); | ||
1225 | rq->rx_ring[i].base = pci_alloc_consistent(adapter->pdev, sz, | ||
1226 | &rq->rx_ring[i].basePA); | ||
1227 | if (!rq->rx_ring[i].base) { | ||
1228 | printk(KERN_ERR "%s: failed to allocate rx ring %d\n", | ||
1229 | adapter->netdev->name, i); | ||
1230 | goto err; | ||
1231 | } | ||
1232 | } | ||
1233 | |||
1234 | sz = rq->comp_ring.size * sizeof(struct Vmxnet3_RxCompDesc); | ||
1235 | rq->comp_ring.base = pci_alloc_consistent(adapter->pdev, sz, | ||
1236 | &rq->comp_ring.basePA); | ||
1237 | if (!rq->comp_ring.base) { | ||
1238 | printk(KERN_ERR "%s: failed to allocate rx comp ring\n", | ||
1239 | adapter->netdev->name); | ||
1240 | goto err; | ||
1241 | } | ||
1242 | |||
1243 | sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size + | ||
1244 | rq->rx_ring[1].size); | ||
1245 | bi = kmalloc(sz, GFP_KERNEL); | ||
1246 | if (!bi) { | ||
1247 | printk(KERN_ERR "%s: failed to allocate rx bufinfo\n", | ||
1248 | adapter->netdev->name); | ||
1249 | goto err; | ||
1250 | } | ||
1251 | memset(bi, 0, sz); | ||
1252 | rq->buf_info[0] = bi; | ||
1253 | rq->buf_info[1] = bi + rq->rx_ring[0].size; | ||
1254 | |||
1255 | return 0; | ||
1256 | |||
1257 | err: | ||
1258 | vmxnet3_rq_destroy(rq, adapter); | ||
1259 | return -ENOMEM; | ||
1260 | } | ||
1261 | |||
1262 | |||
1263 | static int | ||
1264 | vmxnet3_do_poll(struct vmxnet3_adapter *adapter, int budget) | ||
1265 | { | ||
1266 | if (unlikely(adapter->shared->ecr)) | ||
1267 | vmxnet3_process_events(adapter); | ||
1268 | |||
1269 | vmxnet3_tq_tx_complete(&adapter->tx_queue, adapter); | ||
1270 | return vmxnet3_rq_rx_complete(&adapter->rx_queue, adapter, budget); | ||
1271 | } | ||
1272 | |||
1273 | |||
1274 | static int | ||
1275 | vmxnet3_poll(struct napi_struct *napi, int budget) | ||
1276 | { | ||
1277 | struct vmxnet3_adapter *adapter = container_of(napi, | ||
1278 | struct vmxnet3_adapter, napi); | ||
1279 | int rxd_done; | ||
1280 | |||
1281 | rxd_done = vmxnet3_do_poll(adapter, budget); | ||
1282 | |||
1283 | if (rxd_done < budget) { | ||
1284 | napi_complete(napi); | ||
1285 | vmxnet3_enable_intr(adapter, 0); | ||
1286 | } | ||
1287 | return rxd_done; | ||
1288 | } | ||
1289 | |||
1290 | |||
1291 | /* Interrupt handler for vmxnet3 */ | ||
1292 | static irqreturn_t | ||
1293 | vmxnet3_intr(int irq, void *dev_id) | ||
1294 | { | ||
1295 | struct net_device *dev = dev_id; | ||
1296 | struct vmxnet3_adapter *adapter = netdev_priv(dev); | ||
1297 | |||
1298 | if (unlikely(adapter->intr.type == VMXNET3_IT_INTX)) { | ||
1299 | u32 icr = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_ICR); | ||
1300 | if (unlikely(icr == 0)) | ||
1301 | /* not ours */ | ||
1302 | return IRQ_NONE; | ||
1303 | } | ||
1304 | |||
1305 | |||
1306 | /* disable intr if needed */ | ||
1307 | if (adapter->intr.mask_mode == VMXNET3_IMM_ACTIVE) | ||
1308 | vmxnet3_disable_intr(adapter, 0); | ||
1309 | |||
1310 | napi_schedule(&adapter->napi); | ||
1311 | |||
1312 | return IRQ_HANDLED; | ||
1313 | } | ||
1314 | |||
1315 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1316 | |||
1317 | |||
1318 | /* netpoll callback. */ | ||
1319 | static void | ||
1320 | vmxnet3_netpoll(struct net_device *netdev) | ||
1321 | { | ||
1322 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
1323 | int irq; | ||
1324 | |||
1325 | #ifdef CONFIG_PCI_MSI | ||
1326 | if (adapter->intr.type == VMXNET3_IT_MSIX) | ||
1327 | irq = adapter->intr.msix_entries[0].vector; | ||
1328 | else | ||
1329 | #endif | ||
1330 | irq = adapter->pdev->irq; | ||
1331 | |||
1332 | disable_irq(irq); | ||
1333 | vmxnet3_intr(irq, netdev); | ||
1334 | enable_irq(irq); | ||
1335 | } | ||
1336 | #endif | ||
1337 | |||
1338 | static int | ||
1339 | vmxnet3_request_irqs(struct vmxnet3_adapter *adapter) | ||
1340 | { | ||
1341 | int err; | ||
1342 | |||
1343 | #ifdef CONFIG_PCI_MSI | ||
1344 | if (adapter->intr.type == VMXNET3_IT_MSIX) { | ||
1345 | /* we only use 1 MSI-X vector */ | ||
1346 | err = request_irq(adapter->intr.msix_entries[0].vector, | ||
1347 | vmxnet3_intr, 0, adapter->netdev->name, | ||
1348 | adapter->netdev); | ||
1349 | } else | ||
1350 | #endif | ||
1351 | if (adapter->intr.type == VMXNET3_IT_MSI) { | ||
1352 | err = request_irq(adapter->pdev->irq, vmxnet3_intr, 0, | ||
1353 | adapter->netdev->name, adapter->netdev); | ||
1354 | } else { | ||
1355 | err = request_irq(adapter->pdev->irq, vmxnet3_intr, | ||
1356 | IRQF_SHARED, adapter->netdev->name, | ||
1357 | adapter->netdev); | ||
1358 | } | ||
1359 | |||
1360 | if (err) | ||
1361 | printk(KERN_ERR "Failed to request irq %s (intr type:%d), error" | ||
1362 | ":%d\n", adapter->netdev->name, adapter->intr.type, err); | ||
1363 | |||
1364 | |||
1365 | if (!err) { | ||
1366 | int i; | ||
1367 | /* init our intr settings */ | ||
1368 | for (i = 0; i < adapter->intr.num_intrs; i++) | ||
1369 | adapter->intr.mod_levels[i] = UPT1_IML_ADAPTIVE; | ||
1370 | |||
1371 | /* next setup intr index for all intr sources */ | ||
1372 | adapter->tx_queue.comp_ring.intr_idx = 0; | ||
1373 | adapter->rx_queue.comp_ring.intr_idx = 0; | ||
1374 | adapter->intr.event_intr_idx = 0; | ||
1375 | |||
1376 | printk(KERN_INFO "%s: intr type %u, mode %u, %u vectors " | ||
1377 | "allocated\n", adapter->netdev->name, adapter->intr.type, | ||
1378 | adapter->intr.mask_mode, adapter->intr.num_intrs); | ||
1379 | } | ||
1380 | |||
1381 | return err; | ||
1382 | } | ||
1383 | |||
1384 | |||
1385 | static void | ||
1386 | vmxnet3_free_irqs(struct vmxnet3_adapter *adapter) | ||
1387 | { | ||
1388 | BUG_ON(adapter->intr.type == VMXNET3_IT_AUTO || | ||
1389 | adapter->intr.num_intrs <= 0); | ||
1390 | |||
1391 | switch (adapter->intr.type) { | ||
1392 | #ifdef CONFIG_PCI_MSI | ||
1393 | case VMXNET3_IT_MSIX: | ||
1394 | { | ||
1395 | int i; | ||
1396 | |||
1397 | for (i = 0; i < adapter->intr.num_intrs; i++) | ||
1398 | free_irq(adapter->intr.msix_entries[i].vector, | ||
1399 | adapter->netdev); | ||
1400 | break; | ||
1401 | } | ||
1402 | #endif | ||
1403 | case VMXNET3_IT_MSI: | ||
1404 | free_irq(adapter->pdev->irq, adapter->netdev); | ||
1405 | break; | ||
1406 | case VMXNET3_IT_INTX: | ||
1407 | free_irq(adapter->pdev->irq, adapter->netdev); | ||
1408 | break; | ||
1409 | default: | ||
1410 | BUG_ON(true); | ||
1411 | } | ||
1412 | } | ||
1413 | |||
1414 | |||
1415 | static void | ||
1416 | vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) | ||
1417 | { | ||
1418 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
1419 | struct Vmxnet3_DriverShared *shared = adapter->shared; | ||
1420 | u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; | ||
1421 | |||
1422 | if (grp) { | ||
1423 | /* add vlan rx stripping. */ | ||
1424 | if (adapter->netdev->features & NETIF_F_HW_VLAN_RX) { | ||
1425 | int i; | ||
1426 | struct Vmxnet3_DSDevRead *devRead = &shared->devRead; | ||
1427 | adapter->vlan_grp = grp; | ||
1428 | |||
1429 | /* update FEATURES to device */ | ||
1430 | devRead->misc.uptFeatures |= UPT1_F_RXVLAN; | ||
1431 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1432 | VMXNET3_CMD_UPDATE_FEATURE); | ||
1433 | /* | ||
1434 | * Clear entire vfTable; then enable untagged pkts. | ||
1435 | * Note: setting one entry in vfTable to non-zero turns | ||
1436 | * on VLAN rx filtering. | ||
1437 | */ | ||
1438 | for (i = 0; i < VMXNET3_VFT_SIZE; i++) | ||
1439 | vfTable[i] = 0; | ||
1440 | |||
1441 | VMXNET3_SET_VFTABLE_ENTRY(vfTable, 0); | ||
1442 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1443 | VMXNET3_CMD_UPDATE_VLAN_FILTERS); | ||
1444 | } else { | ||
1445 | printk(KERN_ERR "%s: vlan_rx_register when device has " | ||
1446 | "no NETIF_F_HW_VLAN_RX\n", netdev->name); | ||
1447 | } | ||
1448 | } else { | ||
1449 | /* remove vlan rx stripping. */ | ||
1450 | struct Vmxnet3_DSDevRead *devRead = &shared->devRead; | ||
1451 | adapter->vlan_grp = NULL; | ||
1452 | |||
1453 | if (devRead->misc.uptFeatures & UPT1_F_RXVLAN) { | ||
1454 | int i; | ||
1455 | |||
1456 | for (i = 0; i < VMXNET3_VFT_SIZE; i++) { | ||
1457 | /* clear entire vfTable; this also disables | ||
1458 | * VLAN rx filtering | ||
1459 | */ | ||
1460 | vfTable[i] = 0; | ||
1461 | } | ||
1462 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1463 | VMXNET3_CMD_UPDATE_VLAN_FILTERS); | ||
1464 | |||
1465 | /* update FEATURES to device */ | ||
1466 | devRead->misc.uptFeatures &= ~UPT1_F_RXVLAN; | ||
1467 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1468 | VMXNET3_CMD_UPDATE_FEATURE); | ||
1469 | } | ||
1470 | } | ||
1471 | } | ||
1472 | |||
1473 | |||
1474 | static void | ||
1475 | vmxnet3_restore_vlan(struct vmxnet3_adapter *adapter) | ||
1476 | { | ||
1477 | if (adapter->vlan_grp) { | ||
1478 | u16 vid; | ||
1479 | u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; | ||
1480 | bool activeVlan = false; | ||
1481 | |||
1482 | for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) { | ||
1483 | if (vlan_group_get_device(adapter->vlan_grp, vid)) { | ||
1484 | VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid); | ||
1485 | activeVlan = true; | ||
1486 | } | ||
1487 | } | ||
1488 | if (activeVlan) { | ||
1489 | /* continue to allow untagged pkts */ | ||
1490 | VMXNET3_SET_VFTABLE_ENTRY(vfTable, 0); | ||
1491 | } | ||
1492 | } | ||
1493 | } | ||
1494 | |||
1495 | |||
1496 | static void | ||
1497 | vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid) | ||
1498 | { | ||
1499 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
1500 | u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; | ||
1501 | |||
1502 | VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid); | ||
1503 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1504 | VMXNET3_CMD_UPDATE_VLAN_FILTERS); | ||
1505 | } | ||
1506 | |||
1507 | |||
1508 | static void | ||
1509 | vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) | ||
1510 | { | ||
1511 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
1512 | u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; | ||
1513 | |||
1514 | VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid); | ||
1515 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1516 | VMXNET3_CMD_UPDATE_VLAN_FILTERS); | ||
1517 | } | ||
1518 | |||
1519 | |||
1520 | static u8 * | ||
1521 | vmxnet3_copy_mc(struct net_device *netdev) | ||
1522 | { | ||
1523 | u8 *buf = NULL; | ||
1524 | u32 sz = netdev->mc_count * ETH_ALEN; | ||
1525 | |||
1526 | /* struct Vmxnet3_RxFilterConf.mfTableLen is u16. */ | ||
1527 | if (sz <= 0xffff) { | ||
1528 | /* We may be called with BH disabled */ | ||
1529 | buf = kmalloc(sz, GFP_ATOMIC); | ||
1530 | if (buf) { | ||
1531 | int i; | ||
1532 | struct dev_mc_list *mc = netdev->mc_list; | ||
1533 | |||
1534 | for (i = 0; i < netdev->mc_count; i++) { | ||
1535 | BUG_ON(!mc); | ||
1536 | memcpy(buf + i * ETH_ALEN, mc->dmi_addr, | ||
1537 | ETH_ALEN); | ||
1538 | mc = mc->next; | ||
1539 | } | ||
1540 | } | ||
1541 | } | ||
1542 | return buf; | ||
1543 | } | ||
1544 | |||
1545 | |||
1546 | static void | ||
1547 | vmxnet3_set_mc(struct net_device *netdev) | ||
1548 | { | ||
1549 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
1550 | struct Vmxnet3_RxFilterConf *rxConf = | ||
1551 | &adapter->shared->devRead.rxFilterConf; | ||
1552 | u8 *new_table = NULL; | ||
1553 | u32 new_mode = VMXNET3_RXM_UCAST; | ||
1554 | |||
1555 | if (netdev->flags & IFF_PROMISC) | ||
1556 | new_mode |= VMXNET3_RXM_PROMISC; | ||
1557 | |||
1558 | if (netdev->flags & IFF_BROADCAST) | ||
1559 | new_mode |= VMXNET3_RXM_BCAST; | ||
1560 | |||
1561 | if (netdev->flags & IFF_ALLMULTI) | ||
1562 | new_mode |= VMXNET3_RXM_ALL_MULTI; | ||
1563 | else | ||
1564 | if (netdev->mc_count > 0) { | ||
1565 | new_table = vmxnet3_copy_mc(netdev); | ||
1566 | if (new_table) { | ||
1567 | new_mode |= VMXNET3_RXM_MCAST; | ||
1568 | rxConf->mfTableLen = netdev->mc_count * | ||
1569 | ETH_ALEN; | ||
1570 | rxConf->mfTablePA = virt_to_phys(new_table); | ||
1571 | } else { | ||
1572 | printk(KERN_INFO "%s: failed to copy mcast list" | ||
1573 | ", setting ALL_MULTI\n", netdev->name); | ||
1574 | new_mode |= VMXNET3_RXM_ALL_MULTI; | ||
1575 | } | ||
1576 | } | ||
1577 | |||
1578 | |||
1579 | if (!(new_mode & VMXNET3_RXM_MCAST)) { | ||
1580 | rxConf->mfTableLen = 0; | ||
1581 | rxConf->mfTablePA = 0; | ||
1582 | } | ||
1583 | |||
1584 | if (new_mode != rxConf->rxMode) { | ||
1585 | rxConf->rxMode = new_mode; | ||
1586 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1587 | VMXNET3_CMD_UPDATE_RX_MODE); | ||
1588 | } | ||
1589 | |||
1590 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1591 | VMXNET3_CMD_UPDATE_MAC_FILTERS); | ||
1592 | |||
1593 | kfree(new_table); | ||
1594 | } | ||
1595 | |||
1596 | |||
1597 | /* | ||
1598 | * Set up driver_shared based on settings in adapter. | ||
1599 | */ | ||
1600 | |||
1601 | static void | ||
1602 | vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter) | ||
1603 | { | ||
1604 | struct Vmxnet3_DriverShared *shared = adapter->shared; | ||
1605 | struct Vmxnet3_DSDevRead *devRead = &shared->devRead; | ||
1606 | struct Vmxnet3_TxQueueConf *tqc; | ||
1607 | struct Vmxnet3_RxQueueConf *rqc; | ||
1608 | int i; | ||
1609 | |||
1610 | memset(shared, 0, sizeof(*shared)); | ||
1611 | |||
1612 | /* driver settings */ | ||
1613 | shared->magic = VMXNET3_REV1_MAGIC; | ||
1614 | devRead->misc.driverInfo.version = VMXNET3_DRIVER_VERSION_NUM; | ||
1615 | devRead->misc.driverInfo.gos.gosBits = (sizeof(void *) == 4 ? | ||
1616 | VMXNET3_GOS_BITS_32 : VMXNET3_GOS_BITS_64); | ||
1617 | devRead->misc.driverInfo.gos.gosType = VMXNET3_GOS_TYPE_LINUX; | ||
1618 | devRead->misc.driverInfo.vmxnet3RevSpt = 1; | ||
1619 | devRead->misc.driverInfo.uptVerSpt = 1; | ||
1620 | |||
1621 | devRead->misc.ddPA = virt_to_phys(adapter); | ||
1622 | devRead->misc.ddLen = sizeof(struct vmxnet3_adapter); | ||
1623 | |||
1624 | /* set up feature flags */ | ||
1625 | if (adapter->rxcsum) | ||
1626 | devRead->misc.uptFeatures |= UPT1_F_RXCSUM; | ||
1627 | |||
1628 | if (adapter->lro) { | ||
1629 | devRead->misc.uptFeatures |= UPT1_F_LRO; | ||
1630 | devRead->misc.maxNumRxSG = 1 + MAX_SKB_FRAGS; | ||
1631 | } | ||
1632 | if ((adapter->netdev->features & NETIF_F_HW_VLAN_RX) | ||
1633 | && adapter->vlan_grp) { | ||
1634 | devRead->misc.uptFeatures |= UPT1_F_RXVLAN; | ||
1635 | } | ||
1636 | |||
1637 | devRead->misc.mtu = adapter->netdev->mtu; | ||
1638 | devRead->misc.queueDescPA = adapter->queue_desc_pa; | ||
1639 | devRead->misc.queueDescLen = sizeof(struct Vmxnet3_TxQueueDesc) + | ||
1640 | sizeof(struct Vmxnet3_RxQueueDesc); | ||
1641 | |||
1642 | /* tx queue settings */ | ||
1643 | BUG_ON(adapter->tx_queue.tx_ring.base == NULL); | ||
1644 | |||
1645 | devRead->misc.numTxQueues = 1; | ||
1646 | tqc = &adapter->tqd_start->conf; | ||
1647 | tqc->txRingBasePA = adapter->tx_queue.tx_ring.basePA; | ||
1648 | tqc->dataRingBasePA = adapter->tx_queue.data_ring.basePA; | ||
1649 | tqc->compRingBasePA = adapter->tx_queue.comp_ring.basePA; | ||
1650 | tqc->ddPA = virt_to_phys(adapter->tx_queue.buf_info); | ||
1651 | tqc->txRingSize = adapter->tx_queue.tx_ring.size; | ||
1652 | tqc->dataRingSize = adapter->tx_queue.data_ring.size; | ||
1653 | tqc->compRingSize = adapter->tx_queue.comp_ring.size; | ||
1654 | tqc->ddLen = sizeof(struct vmxnet3_tx_buf_info) * | ||
1655 | tqc->txRingSize; | ||
1656 | tqc->intrIdx = adapter->tx_queue.comp_ring.intr_idx; | ||
1657 | |||
1658 | /* rx queue settings */ | ||
1659 | devRead->misc.numRxQueues = 1; | ||
1660 | rqc = &adapter->rqd_start->conf; | ||
1661 | rqc->rxRingBasePA[0] = adapter->rx_queue.rx_ring[0].basePA; | ||
1662 | rqc->rxRingBasePA[1] = adapter->rx_queue.rx_ring[1].basePA; | ||
1663 | rqc->compRingBasePA = adapter->rx_queue.comp_ring.basePA; | ||
1664 | rqc->ddPA = virt_to_phys(adapter->rx_queue.buf_info); | ||
1665 | rqc->rxRingSize[0] = adapter->rx_queue.rx_ring[0].size; | ||
1666 | rqc->rxRingSize[1] = adapter->rx_queue.rx_ring[1].size; | ||
1667 | rqc->compRingSize = adapter->rx_queue.comp_ring.size; | ||
1668 | rqc->ddLen = sizeof(struct vmxnet3_rx_buf_info) * | ||
1669 | (rqc->rxRingSize[0] + rqc->rxRingSize[1]); | ||
1670 | rqc->intrIdx = adapter->rx_queue.comp_ring.intr_idx; | ||
1671 | |||
1672 | /* intr settings */ | ||
1673 | devRead->intrConf.autoMask = adapter->intr.mask_mode == | ||
1674 | VMXNET3_IMM_AUTO; | ||
1675 | devRead->intrConf.numIntrs = adapter->intr.num_intrs; | ||
1676 | for (i = 0; i < adapter->intr.num_intrs; i++) | ||
1677 | devRead->intrConf.modLevels[i] = adapter->intr.mod_levels[i]; | ||
1678 | |||
1679 | devRead->intrConf.eventIntrIdx = adapter->intr.event_intr_idx; | ||
1680 | |||
1681 | /* rx filter settings */ | ||
1682 | devRead->rxFilterConf.rxMode = 0; | ||
1683 | vmxnet3_restore_vlan(adapter); | ||
1684 | /* the rest are already zeroed */ | ||
1685 | } | ||
1686 | |||
1687 | |||
1688 | int | ||
1689 | vmxnet3_activate_dev(struct vmxnet3_adapter *adapter) | ||
1690 | { | ||
1691 | int err; | ||
1692 | u32 ret; | ||
1693 | |||
1694 | dev_dbg(&adapter->netdev->dev, | ||
1695 | "%s: skb_buf_size %d, rx_buf_per_pkt %d, ring sizes" | ||
1696 | " %u %u %u\n", adapter->netdev->name, adapter->skb_buf_size, | ||
1697 | adapter->rx_buf_per_pkt, adapter->tx_queue.tx_ring.size, | ||
1698 | adapter->rx_queue.rx_ring[0].size, | ||
1699 | adapter->rx_queue.rx_ring[1].size); | ||
1700 | |||
1701 | vmxnet3_tq_init(&adapter->tx_queue, adapter); | ||
1702 | err = vmxnet3_rq_init(&adapter->rx_queue, adapter); | ||
1703 | if (err) { | ||
1704 | printk(KERN_ERR "Failed to init rx queue for %s: error %d\n", | ||
1705 | adapter->netdev->name, err); | ||
1706 | goto rq_err; | ||
1707 | } | ||
1708 | |||
1709 | err = vmxnet3_request_irqs(adapter); | ||
1710 | if (err) { | ||
1711 | printk(KERN_ERR "Failed to setup irq for %s: error %d\n", | ||
1712 | adapter->netdev->name, err); | ||
1713 | goto irq_err; | ||
1714 | } | ||
1715 | |||
1716 | vmxnet3_setup_driver_shared(adapter); | ||
1717 | |||
1718 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAL, | ||
1719 | VMXNET3_GET_ADDR_LO(adapter->shared_pa)); | ||
1720 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAH, | ||
1721 | VMXNET3_GET_ADDR_HI(adapter->shared_pa)); | ||
1722 | |||
1723 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1724 | VMXNET3_CMD_ACTIVATE_DEV); | ||
1725 | ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); | ||
1726 | |||
1727 | if (ret != 0) { | ||
1728 | printk(KERN_ERR "Failed to activate dev %s: error %u\n", | ||
1729 | adapter->netdev->name, ret); | ||
1730 | err = -EINVAL; | ||
1731 | goto activate_err; | ||
1732 | } | ||
1733 | VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_RXPROD, | ||
1734 | adapter->rx_queue.rx_ring[0].next2fill); | ||
1735 | VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_RXPROD2, | ||
1736 | adapter->rx_queue.rx_ring[1].next2fill); | ||
1737 | |||
1738 | /* Apply the rx filter settins last. */ | ||
1739 | vmxnet3_set_mc(adapter->netdev); | ||
1740 | |||
1741 | /* | ||
1742 | * Check link state when first activating device. It will start the | ||
1743 | * tx queue if the link is up. | ||
1744 | */ | ||
1745 | vmxnet3_check_link(adapter); | ||
1746 | |||
1747 | napi_enable(&adapter->napi); | ||
1748 | vmxnet3_enable_all_intrs(adapter); | ||
1749 | clear_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state); | ||
1750 | return 0; | ||
1751 | |||
1752 | activate_err: | ||
1753 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAL, 0); | ||
1754 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAH, 0); | ||
1755 | vmxnet3_free_irqs(adapter); | ||
1756 | irq_err: | ||
1757 | rq_err: | ||
1758 | /* free up buffers we allocated */ | ||
1759 | vmxnet3_rq_cleanup(&adapter->rx_queue, adapter); | ||
1760 | return err; | ||
1761 | } | ||
1762 | |||
1763 | |||
1764 | void | ||
1765 | vmxnet3_reset_dev(struct vmxnet3_adapter *adapter) | ||
1766 | { | ||
1767 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV); | ||
1768 | } | ||
1769 | |||
1770 | |||
1771 | int | ||
1772 | vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter) | ||
1773 | { | ||
1774 | if (test_and_set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state)) | ||
1775 | return 0; | ||
1776 | |||
1777 | |||
1778 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
1779 | VMXNET3_CMD_QUIESCE_DEV); | ||
1780 | vmxnet3_disable_all_intrs(adapter); | ||
1781 | |||
1782 | napi_disable(&adapter->napi); | ||
1783 | netif_tx_disable(adapter->netdev); | ||
1784 | adapter->link_speed = 0; | ||
1785 | netif_carrier_off(adapter->netdev); | ||
1786 | |||
1787 | vmxnet3_tq_cleanup(&adapter->tx_queue, adapter); | ||
1788 | vmxnet3_rq_cleanup(&adapter->rx_queue, adapter); | ||
1789 | vmxnet3_free_irqs(adapter); | ||
1790 | return 0; | ||
1791 | } | ||
1792 | |||
1793 | |||
1794 | static void | ||
1795 | vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, u8 *mac) | ||
1796 | { | ||
1797 | u32 tmp; | ||
1798 | |||
1799 | tmp = *(u32 *)mac; | ||
1800 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_MACL, tmp); | ||
1801 | |||
1802 | tmp = (mac[5] << 8) | mac[4]; | ||
1803 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_MACH, tmp); | ||
1804 | } | ||
1805 | |||
1806 | |||
1807 | static int | ||
1808 | vmxnet3_set_mac_addr(struct net_device *netdev, void *p) | ||
1809 | { | ||
1810 | struct sockaddr *addr = p; | ||
1811 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
1812 | |||
1813 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | ||
1814 | vmxnet3_write_mac_addr(adapter, addr->sa_data); | ||
1815 | |||
1816 | return 0; | ||
1817 | } | ||
1818 | |||
1819 | |||
1820 | /* ==================== initialization and cleanup routines ============ */ | ||
1821 | |||
1822 | static int | ||
1823 | vmxnet3_alloc_pci_resources(struct vmxnet3_adapter *adapter, bool *dma64) | ||
1824 | { | ||
1825 | int err; | ||
1826 | unsigned long mmio_start, mmio_len; | ||
1827 | struct pci_dev *pdev = adapter->pdev; | ||
1828 | |||
1829 | err = pci_enable_device(pdev); | ||
1830 | if (err) { | ||
1831 | printk(KERN_ERR "Failed to enable adapter %s: error %d\n", | ||
1832 | pci_name(pdev), err); | ||
1833 | return err; | ||
1834 | } | ||
1835 | |||
1836 | if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) == 0) { | ||
1837 | if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) { | ||
1838 | printk(KERN_ERR "pci_set_consistent_dma_mask failed " | ||
1839 | "for adapter %s\n", pci_name(pdev)); | ||
1840 | err = -EIO; | ||
1841 | goto err_set_mask; | ||
1842 | } | ||
1843 | *dma64 = true; | ||
1844 | } else { | ||
1845 | if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) { | ||
1846 | printk(KERN_ERR "pci_set_dma_mask failed for adapter " | ||
1847 | "%s\n", pci_name(pdev)); | ||
1848 | err = -EIO; | ||
1849 | goto err_set_mask; | ||
1850 | } | ||
1851 | *dma64 = false; | ||
1852 | } | ||
1853 | |||
1854 | err = pci_request_selected_regions(pdev, (1 << 2) - 1, | ||
1855 | vmxnet3_driver_name); | ||
1856 | if (err) { | ||
1857 | printk(KERN_ERR "Failed to request region for adapter %s: " | ||
1858 | "error %d\n", pci_name(pdev), err); | ||
1859 | goto err_set_mask; | ||
1860 | } | ||
1861 | |||
1862 | pci_set_master(pdev); | ||
1863 | |||
1864 | mmio_start = pci_resource_start(pdev, 0); | ||
1865 | mmio_len = pci_resource_len(pdev, 0); | ||
1866 | adapter->hw_addr0 = ioremap(mmio_start, mmio_len); | ||
1867 | if (!adapter->hw_addr0) { | ||
1868 | printk(KERN_ERR "Failed to map bar0 for adapter %s\n", | ||
1869 | pci_name(pdev)); | ||
1870 | err = -EIO; | ||
1871 | goto err_ioremap; | ||
1872 | } | ||
1873 | |||
1874 | mmio_start = pci_resource_start(pdev, 1); | ||
1875 | mmio_len = pci_resource_len(pdev, 1); | ||
1876 | adapter->hw_addr1 = ioremap(mmio_start, mmio_len); | ||
1877 | if (!adapter->hw_addr1) { | ||
1878 | printk(KERN_ERR "Failed to map bar1 for adapter %s\n", | ||
1879 | pci_name(pdev)); | ||
1880 | err = -EIO; | ||
1881 | goto err_bar1; | ||
1882 | } | ||
1883 | return 0; | ||
1884 | |||
1885 | err_bar1: | ||
1886 | iounmap(adapter->hw_addr0); | ||
1887 | err_ioremap: | ||
1888 | pci_release_selected_regions(pdev, (1 << 2) - 1); | ||
1889 | err_set_mask: | ||
1890 | pci_disable_device(pdev); | ||
1891 | return err; | ||
1892 | } | ||
1893 | |||
1894 | |||
1895 | static void | ||
1896 | vmxnet3_free_pci_resources(struct vmxnet3_adapter *adapter) | ||
1897 | { | ||
1898 | BUG_ON(!adapter->pdev); | ||
1899 | |||
1900 | iounmap(adapter->hw_addr0); | ||
1901 | iounmap(adapter->hw_addr1); | ||
1902 | pci_release_selected_regions(adapter->pdev, (1 << 2) - 1); | ||
1903 | pci_disable_device(adapter->pdev); | ||
1904 | } | ||
1905 | |||
1906 | |||
1907 | static void | ||
1908 | vmxnet3_adjust_rx_ring_size(struct vmxnet3_adapter *adapter) | ||
1909 | { | ||
1910 | size_t sz; | ||
1911 | |||
1912 | if (adapter->netdev->mtu <= VMXNET3_MAX_SKB_BUF_SIZE - | ||
1913 | VMXNET3_MAX_ETH_HDR_SIZE) { | ||
1914 | adapter->skb_buf_size = adapter->netdev->mtu + | ||
1915 | VMXNET3_MAX_ETH_HDR_SIZE; | ||
1916 | if (adapter->skb_buf_size < VMXNET3_MIN_T0_BUF_SIZE) | ||
1917 | adapter->skb_buf_size = VMXNET3_MIN_T0_BUF_SIZE; | ||
1918 | |||
1919 | adapter->rx_buf_per_pkt = 1; | ||
1920 | } else { | ||
1921 | adapter->skb_buf_size = VMXNET3_MAX_SKB_BUF_SIZE; | ||
1922 | sz = adapter->netdev->mtu - VMXNET3_MAX_SKB_BUF_SIZE + | ||
1923 | VMXNET3_MAX_ETH_HDR_SIZE; | ||
1924 | adapter->rx_buf_per_pkt = 1 + (sz + PAGE_SIZE - 1) / PAGE_SIZE; | ||
1925 | } | ||
1926 | |||
1927 | /* | ||
1928 | * for simplicity, force the ring0 size to be a multiple of | ||
1929 | * rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN | ||
1930 | */ | ||
1931 | sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN; | ||
1932 | adapter->rx_queue.rx_ring[0].size = (adapter->rx_queue.rx_ring[0].size + | ||
1933 | sz - 1) / sz * sz; | ||
1934 | adapter->rx_queue.rx_ring[0].size = min_t(u32, | ||
1935 | adapter->rx_queue.rx_ring[0].size, | ||
1936 | VMXNET3_RX_RING_MAX_SIZE / sz * sz); | ||
1937 | } | ||
1938 | |||
1939 | |||
1940 | int | ||
1941 | vmxnet3_create_queues(struct vmxnet3_adapter *adapter, u32 tx_ring_size, | ||
1942 | u32 rx_ring_size, u32 rx_ring2_size) | ||
1943 | { | ||
1944 | int err; | ||
1945 | |||
1946 | adapter->tx_queue.tx_ring.size = tx_ring_size; | ||
1947 | adapter->tx_queue.data_ring.size = tx_ring_size; | ||
1948 | adapter->tx_queue.comp_ring.size = tx_ring_size; | ||
1949 | adapter->tx_queue.shared = &adapter->tqd_start->ctrl; | ||
1950 | adapter->tx_queue.stopped = true; | ||
1951 | err = vmxnet3_tq_create(&adapter->tx_queue, adapter); | ||
1952 | if (err) | ||
1953 | return err; | ||
1954 | |||
1955 | adapter->rx_queue.rx_ring[0].size = rx_ring_size; | ||
1956 | adapter->rx_queue.rx_ring[1].size = rx_ring2_size; | ||
1957 | vmxnet3_adjust_rx_ring_size(adapter); | ||
1958 | adapter->rx_queue.comp_ring.size = adapter->rx_queue.rx_ring[0].size + | ||
1959 | adapter->rx_queue.rx_ring[1].size; | ||
1960 | adapter->rx_queue.qid = 0; | ||
1961 | adapter->rx_queue.qid2 = 1; | ||
1962 | adapter->rx_queue.shared = &adapter->rqd_start->ctrl; | ||
1963 | err = vmxnet3_rq_create(&adapter->rx_queue, adapter); | ||
1964 | if (err) | ||
1965 | vmxnet3_tq_destroy(&adapter->tx_queue, adapter); | ||
1966 | |||
1967 | return err; | ||
1968 | } | ||
1969 | |||
1970 | static int | ||
1971 | vmxnet3_open(struct net_device *netdev) | ||
1972 | { | ||
1973 | struct vmxnet3_adapter *adapter; | ||
1974 | int err; | ||
1975 | |||
1976 | adapter = netdev_priv(netdev); | ||
1977 | |||
1978 | spin_lock_init(&adapter->tx_queue.tx_lock); | ||
1979 | |||
1980 | err = vmxnet3_create_queues(adapter, VMXNET3_DEF_TX_RING_SIZE, | ||
1981 | VMXNET3_DEF_RX_RING_SIZE, | ||
1982 | VMXNET3_DEF_RX_RING_SIZE); | ||
1983 | if (err) | ||
1984 | goto queue_err; | ||
1985 | |||
1986 | err = vmxnet3_activate_dev(adapter); | ||
1987 | if (err) | ||
1988 | goto activate_err; | ||
1989 | |||
1990 | return 0; | ||
1991 | |||
1992 | activate_err: | ||
1993 | vmxnet3_rq_destroy(&adapter->rx_queue, adapter); | ||
1994 | vmxnet3_tq_destroy(&adapter->tx_queue, adapter); | ||
1995 | queue_err: | ||
1996 | return err; | ||
1997 | } | ||
1998 | |||
1999 | |||
2000 | static int | ||
2001 | vmxnet3_close(struct net_device *netdev) | ||
2002 | { | ||
2003 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
2004 | |||
2005 | /* | ||
2006 | * Reset_work may be in the middle of resetting the device, wait for its | ||
2007 | * completion. | ||
2008 | */ | ||
2009 | while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) | ||
2010 | msleep(1); | ||
2011 | |||
2012 | vmxnet3_quiesce_dev(adapter); | ||
2013 | |||
2014 | vmxnet3_rq_destroy(&adapter->rx_queue, adapter); | ||
2015 | vmxnet3_tq_destroy(&adapter->tx_queue, adapter); | ||
2016 | |||
2017 | clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); | ||
2018 | |||
2019 | |||
2020 | return 0; | ||
2021 | } | ||
2022 | |||
2023 | |||
2024 | void | ||
2025 | vmxnet3_force_close(struct vmxnet3_adapter *adapter) | ||
2026 | { | ||
2027 | /* | ||
2028 | * we must clear VMXNET3_STATE_BIT_RESETTING, otherwise | ||
2029 | * vmxnet3_close() will deadlock. | ||
2030 | */ | ||
2031 | BUG_ON(test_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)); | ||
2032 | |||
2033 | /* we need to enable NAPI, otherwise dev_close will deadlock */ | ||
2034 | napi_enable(&adapter->napi); | ||
2035 | dev_close(adapter->netdev); | ||
2036 | } | ||
2037 | |||
2038 | |||
2039 | static int | ||
2040 | vmxnet3_change_mtu(struct net_device *netdev, int new_mtu) | ||
2041 | { | ||
2042 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
2043 | int err = 0; | ||
2044 | |||
2045 | if (new_mtu < VMXNET3_MIN_MTU || new_mtu > VMXNET3_MAX_MTU) | ||
2046 | return -EINVAL; | ||
2047 | |||
2048 | if (new_mtu > 1500 && !adapter->jumbo_frame) | ||
2049 | return -EINVAL; | ||
2050 | |||
2051 | netdev->mtu = new_mtu; | ||
2052 | |||
2053 | /* | ||
2054 | * Reset_work may be in the middle of resetting the device, wait for its | ||
2055 | * completion. | ||
2056 | */ | ||
2057 | while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) | ||
2058 | msleep(1); | ||
2059 | |||
2060 | if (netif_running(netdev)) { | ||
2061 | vmxnet3_quiesce_dev(adapter); | ||
2062 | vmxnet3_reset_dev(adapter); | ||
2063 | |||
2064 | /* we need to re-create the rx queue based on the new mtu */ | ||
2065 | vmxnet3_rq_destroy(&adapter->rx_queue, adapter); | ||
2066 | vmxnet3_adjust_rx_ring_size(adapter); | ||
2067 | adapter->rx_queue.comp_ring.size = | ||
2068 | adapter->rx_queue.rx_ring[0].size + | ||
2069 | adapter->rx_queue.rx_ring[1].size; | ||
2070 | err = vmxnet3_rq_create(&adapter->rx_queue, adapter); | ||
2071 | if (err) { | ||
2072 | printk(KERN_ERR "%s: failed to re-create rx queue," | ||
2073 | " error %d. Closing it.\n", netdev->name, err); | ||
2074 | goto out; | ||
2075 | } | ||
2076 | |||
2077 | err = vmxnet3_activate_dev(adapter); | ||
2078 | if (err) { | ||
2079 | printk(KERN_ERR "%s: failed to re-activate, error %d. " | ||
2080 | "Closing it\n", netdev->name, err); | ||
2081 | goto out; | ||
2082 | } | ||
2083 | } | ||
2084 | |||
2085 | out: | ||
2086 | clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); | ||
2087 | if (err) | ||
2088 | vmxnet3_force_close(adapter); | ||
2089 | |||
2090 | return err; | ||
2091 | } | ||
2092 | |||
2093 | |||
2094 | static void | ||
2095 | vmxnet3_declare_features(struct vmxnet3_adapter *adapter, bool dma64) | ||
2096 | { | ||
2097 | struct net_device *netdev = adapter->netdev; | ||
2098 | |||
2099 | netdev->features = NETIF_F_SG | | ||
2100 | NETIF_F_HW_CSUM | | ||
2101 | NETIF_F_HW_VLAN_TX | | ||
2102 | NETIF_F_HW_VLAN_RX | | ||
2103 | NETIF_F_HW_VLAN_FILTER | | ||
2104 | NETIF_F_TSO | | ||
2105 | NETIF_F_TSO6 | | ||
2106 | NETIF_F_LRO; | ||
2107 | |||
2108 | printk(KERN_INFO "features: sg csum vlan jf tso tsoIPv6 lro"); | ||
2109 | |||
2110 | adapter->rxcsum = true; | ||
2111 | adapter->jumbo_frame = true; | ||
2112 | adapter->lro = true; | ||
2113 | |||
2114 | if (dma64) { | ||
2115 | netdev->features |= NETIF_F_HIGHDMA; | ||
2116 | printk(" highDMA"); | ||
2117 | } | ||
2118 | |||
2119 | netdev->vlan_features = netdev->features; | ||
2120 | printk("\n"); | ||
2121 | } | ||
2122 | |||
2123 | |||
2124 | static void | ||
2125 | vmxnet3_read_mac_addr(struct vmxnet3_adapter *adapter, u8 *mac) | ||
2126 | { | ||
2127 | u32 tmp; | ||
2128 | |||
2129 | tmp = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACL); | ||
2130 | *(u32 *)mac = tmp; | ||
2131 | |||
2132 | tmp = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACH); | ||
2133 | mac[4] = tmp & 0xff; | ||
2134 | mac[5] = (tmp >> 8) & 0xff; | ||
2135 | } | ||
2136 | |||
2137 | |||
2138 | static void | ||
2139 | vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter) | ||
2140 | { | ||
2141 | u32 cfg; | ||
2142 | |||
2143 | /* intr settings */ | ||
2144 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
2145 | VMXNET3_CMD_GET_CONF_INTR); | ||
2146 | cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); | ||
2147 | adapter->intr.type = cfg & 0x3; | ||
2148 | adapter->intr.mask_mode = (cfg >> 2) & 0x3; | ||
2149 | |||
2150 | if (adapter->intr.type == VMXNET3_IT_AUTO) { | ||
2151 | int err; | ||
2152 | |||
2153 | #ifdef CONFIG_PCI_MSI | ||
2154 | adapter->intr.msix_entries[0].entry = 0; | ||
2155 | err = pci_enable_msix(adapter->pdev, adapter->intr.msix_entries, | ||
2156 | VMXNET3_LINUX_MAX_MSIX_VECT); | ||
2157 | if (!err) { | ||
2158 | adapter->intr.num_intrs = 1; | ||
2159 | adapter->intr.type = VMXNET3_IT_MSIX; | ||
2160 | return; | ||
2161 | } | ||
2162 | #endif | ||
2163 | |||
2164 | err = pci_enable_msi(adapter->pdev); | ||
2165 | if (!err) { | ||
2166 | adapter->intr.num_intrs = 1; | ||
2167 | adapter->intr.type = VMXNET3_IT_MSI; | ||
2168 | return; | ||
2169 | } | ||
2170 | } | ||
2171 | |||
2172 | adapter->intr.type = VMXNET3_IT_INTX; | ||
2173 | |||
2174 | /* INT-X related setting */ | ||
2175 | adapter->intr.num_intrs = 1; | ||
2176 | } | ||
2177 | |||
2178 | |||
2179 | static void | ||
2180 | vmxnet3_free_intr_resources(struct vmxnet3_adapter *adapter) | ||
2181 | { | ||
2182 | if (adapter->intr.type == VMXNET3_IT_MSIX) | ||
2183 | pci_disable_msix(adapter->pdev); | ||
2184 | else if (adapter->intr.type == VMXNET3_IT_MSI) | ||
2185 | pci_disable_msi(adapter->pdev); | ||
2186 | else | ||
2187 | BUG_ON(adapter->intr.type != VMXNET3_IT_INTX); | ||
2188 | } | ||
2189 | |||
2190 | |||
2191 | static void | ||
2192 | vmxnet3_tx_timeout(struct net_device *netdev) | ||
2193 | { | ||
2194 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
2195 | adapter->tx_timeout_count++; | ||
2196 | |||
2197 | printk(KERN_ERR "%s: tx hang\n", adapter->netdev->name); | ||
2198 | schedule_work(&adapter->work); | ||
2199 | } | ||
2200 | |||
2201 | |||
2202 | static void | ||
2203 | vmxnet3_reset_work(struct work_struct *data) | ||
2204 | { | ||
2205 | struct vmxnet3_adapter *adapter; | ||
2206 | |||
2207 | adapter = container_of(data, struct vmxnet3_adapter, work); | ||
2208 | |||
2209 | /* if another thread is resetting the device, no need to proceed */ | ||
2210 | if (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) | ||
2211 | return; | ||
2212 | |||
2213 | /* if the device is closed, we must leave it alone */ | ||
2214 | if (netif_running(adapter->netdev)) { | ||
2215 | printk(KERN_INFO "%s: resetting\n", adapter->netdev->name); | ||
2216 | vmxnet3_quiesce_dev(adapter); | ||
2217 | vmxnet3_reset_dev(adapter); | ||
2218 | vmxnet3_activate_dev(adapter); | ||
2219 | } else { | ||
2220 | printk(KERN_INFO "%s: already closed\n", adapter->netdev->name); | ||
2221 | } | ||
2222 | |||
2223 | clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); | ||
2224 | } | ||
2225 | |||
2226 | |||
2227 | static int __devinit | ||
2228 | vmxnet3_probe_device(struct pci_dev *pdev, | ||
2229 | const struct pci_device_id *id) | ||
2230 | { | ||
2231 | static const struct net_device_ops vmxnet3_netdev_ops = { | ||
2232 | .ndo_open = vmxnet3_open, | ||
2233 | .ndo_stop = vmxnet3_close, | ||
2234 | .ndo_start_xmit = vmxnet3_xmit_frame, | ||
2235 | .ndo_set_mac_address = vmxnet3_set_mac_addr, | ||
2236 | .ndo_change_mtu = vmxnet3_change_mtu, | ||
2237 | .ndo_get_stats = vmxnet3_get_stats, | ||
2238 | .ndo_tx_timeout = vmxnet3_tx_timeout, | ||
2239 | .ndo_set_multicast_list = vmxnet3_set_mc, | ||
2240 | .ndo_vlan_rx_register = vmxnet3_vlan_rx_register, | ||
2241 | .ndo_vlan_rx_add_vid = vmxnet3_vlan_rx_add_vid, | ||
2242 | .ndo_vlan_rx_kill_vid = vmxnet3_vlan_rx_kill_vid, | ||
2243 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
2244 | .ndo_poll_controller = vmxnet3_netpoll, | ||
2245 | #endif | ||
2246 | }; | ||
2247 | int err; | ||
2248 | bool dma64 = false; /* stupid gcc */ | ||
2249 | u32 ver; | ||
2250 | struct net_device *netdev; | ||
2251 | struct vmxnet3_adapter *adapter; | ||
2252 | u8 mac[ETH_ALEN]; | ||
2253 | |||
2254 | netdev = alloc_etherdev(sizeof(struct vmxnet3_adapter)); | ||
2255 | if (!netdev) { | ||
2256 | printk(KERN_ERR "Failed to alloc ethernet device for adapter " | ||
2257 | "%s\n", pci_name(pdev)); | ||
2258 | return -ENOMEM; | ||
2259 | } | ||
2260 | |||
2261 | pci_set_drvdata(pdev, netdev); | ||
2262 | adapter = netdev_priv(netdev); | ||
2263 | adapter->netdev = netdev; | ||
2264 | adapter->pdev = pdev; | ||
2265 | |||
2266 | adapter->shared = pci_alloc_consistent(adapter->pdev, | ||
2267 | sizeof(struct Vmxnet3_DriverShared), | ||
2268 | &adapter->shared_pa); | ||
2269 | if (!adapter->shared) { | ||
2270 | printk(KERN_ERR "Failed to allocate memory for %s\n", | ||
2271 | pci_name(pdev)); | ||
2272 | err = -ENOMEM; | ||
2273 | goto err_alloc_shared; | ||
2274 | } | ||
2275 | |||
2276 | adapter->tqd_start = pci_alloc_consistent(adapter->pdev, | ||
2277 | sizeof(struct Vmxnet3_TxQueueDesc) + | ||
2278 | sizeof(struct Vmxnet3_RxQueueDesc), | ||
2279 | &adapter->queue_desc_pa); | ||
2280 | |||
2281 | if (!adapter->tqd_start) { | ||
2282 | printk(KERN_ERR "Failed to allocate memory for %s\n", | ||
2283 | pci_name(pdev)); | ||
2284 | err = -ENOMEM; | ||
2285 | goto err_alloc_queue_desc; | ||
2286 | } | ||
2287 | adapter->rqd_start = (struct Vmxnet3_RxQueueDesc *)(adapter->tqd_start | ||
2288 | + 1); | ||
2289 | |||
2290 | adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL); | ||
2291 | if (adapter->pm_conf == NULL) { | ||
2292 | printk(KERN_ERR "Failed to allocate memory for %s\n", | ||
2293 | pci_name(pdev)); | ||
2294 | err = -ENOMEM; | ||
2295 | goto err_alloc_pm; | ||
2296 | } | ||
2297 | |||
2298 | err = vmxnet3_alloc_pci_resources(adapter, &dma64); | ||
2299 | if (err < 0) | ||
2300 | goto err_alloc_pci; | ||
2301 | |||
2302 | ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS); | ||
2303 | if (ver & 1) { | ||
2304 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_VRRS, 1); | ||
2305 | } else { | ||
2306 | printk(KERN_ERR "Incompatible h/w version (0x%x) for adapter" | ||
2307 | " %s\n", ver, pci_name(pdev)); | ||
2308 | err = -EBUSY; | ||
2309 | goto err_ver; | ||
2310 | } | ||
2311 | |||
2312 | ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_UVRS); | ||
2313 | if (ver & 1) { | ||
2314 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_UVRS, 1); | ||
2315 | } else { | ||
2316 | printk(KERN_ERR "Incompatible upt version (0x%x) for " | ||
2317 | "adapter %s\n", ver, pci_name(pdev)); | ||
2318 | err = -EBUSY; | ||
2319 | goto err_ver; | ||
2320 | } | ||
2321 | |||
2322 | vmxnet3_declare_features(adapter, dma64); | ||
2323 | |||
2324 | adapter->dev_number = atomic_read(&devices_found); | ||
2325 | vmxnet3_alloc_intr_resources(adapter); | ||
2326 | |||
2327 | vmxnet3_read_mac_addr(adapter, mac); | ||
2328 | memcpy(netdev->dev_addr, mac, netdev->addr_len); | ||
2329 | |||
2330 | netdev->netdev_ops = &vmxnet3_netdev_ops; | ||
2331 | netdev->watchdog_timeo = 5 * HZ; | ||
2332 | vmxnet3_set_ethtool_ops(netdev); | ||
2333 | |||
2334 | INIT_WORK(&adapter->work, vmxnet3_reset_work); | ||
2335 | |||
2336 | netif_napi_add(netdev, &adapter->napi, vmxnet3_poll, 64); | ||
2337 | SET_NETDEV_DEV(netdev, &pdev->dev); | ||
2338 | err = register_netdev(netdev); | ||
2339 | |||
2340 | if (err) { | ||
2341 | printk(KERN_ERR "Failed to register adapter %s\n", | ||
2342 | pci_name(pdev)); | ||
2343 | goto err_register; | ||
2344 | } | ||
2345 | |||
2346 | set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state); | ||
2347 | atomic_inc(&devices_found); | ||
2348 | return 0; | ||
2349 | |||
2350 | err_register: | ||
2351 | vmxnet3_free_intr_resources(adapter); | ||
2352 | err_ver: | ||
2353 | vmxnet3_free_pci_resources(adapter); | ||
2354 | err_alloc_pci: | ||
2355 | kfree(adapter->pm_conf); | ||
2356 | err_alloc_pm: | ||
2357 | pci_free_consistent(adapter->pdev, sizeof(struct Vmxnet3_TxQueueDesc) + | ||
2358 | sizeof(struct Vmxnet3_RxQueueDesc), | ||
2359 | adapter->tqd_start, adapter->queue_desc_pa); | ||
2360 | err_alloc_queue_desc: | ||
2361 | pci_free_consistent(adapter->pdev, sizeof(struct Vmxnet3_DriverShared), | ||
2362 | adapter->shared, adapter->shared_pa); | ||
2363 | err_alloc_shared: | ||
2364 | pci_set_drvdata(pdev, NULL); | ||
2365 | free_netdev(netdev); | ||
2366 | return err; | ||
2367 | } | ||
2368 | |||
2369 | |||
2370 | static void __devexit | ||
2371 | vmxnet3_remove_device(struct pci_dev *pdev) | ||
2372 | { | ||
2373 | struct net_device *netdev = pci_get_drvdata(pdev); | ||
2374 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
2375 | |||
2376 | flush_scheduled_work(); | ||
2377 | |||
2378 | unregister_netdev(netdev); | ||
2379 | |||
2380 | vmxnet3_free_intr_resources(adapter); | ||
2381 | vmxnet3_free_pci_resources(adapter); | ||
2382 | kfree(adapter->pm_conf); | ||
2383 | pci_free_consistent(adapter->pdev, sizeof(struct Vmxnet3_TxQueueDesc) + | ||
2384 | sizeof(struct Vmxnet3_RxQueueDesc), | ||
2385 | adapter->tqd_start, adapter->queue_desc_pa); | ||
2386 | pci_free_consistent(adapter->pdev, sizeof(struct Vmxnet3_DriverShared), | ||
2387 | adapter->shared, adapter->shared_pa); | ||
2388 | free_netdev(netdev); | ||
2389 | } | ||
2390 | |||
2391 | |||
2392 | #ifdef CONFIG_PM | ||
2393 | |||
2394 | static int | ||
2395 | vmxnet3_suspend(struct device *device) | ||
2396 | { | ||
2397 | struct pci_dev *pdev = to_pci_dev(device); | ||
2398 | struct net_device *netdev = pci_get_drvdata(pdev); | ||
2399 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
2400 | struct Vmxnet3_PMConf *pmConf; | ||
2401 | struct ethhdr *ehdr; | ||
2402 | struct arphdr *ahdr; | ||
2403 | u8 *arpreq; | ||
2404 | struct in_device *in_dev; | ||
2405 | struct in_ifaddr *ifa; | ||
2406 | int i = 0; | ||
2407 | |||
2408 | if (!netif_running(netdev)) | ||
2409 | return 0; | ||
2410 | |||
2411 | vmxnet3_disable_all_intrs(adapter); | ||
2412 | vmxnet3_free_irqs(adapter); | ||
2413 | vmxnet3_free_intr_resources(adapter); | ||
2414 | |||
2415 | netif_device_detach(netdev); | ||
2416 | netif_stop_queue(netdev); | ||
2417 | |||
2418 | /* Create wake-up filters. */ | ||
2419 | pmConf = adapter->pm_conf; | ||
2420 | memset(pmConf, 0, sizeof(*pmConf)); | ||
2421 | |||
2422 | if (adapter->wol & WAKE_UCAST) { | ||
2423 | pmConf->filters[i].patternSize = ETH_ALEN; | ||
2424 | pmConf->filters[i].maskSize = 1; | ||
2425 | memcpy(pmConf->filters[i].pattern, netdev->dev_addr, ETH_ALEN); | ||
2426 | pmConf->filters[i].mask[0] = 0x3F; /* LSB ETH_ALEN bits */ | ||
2427 | |||
2428 | pmConf->wakeUpEvents |= VMXNET3_PM_WAKEUP_FILTER; | ||
2429 | i++; | ||
2430 | } | ||
2431 | |||
2432 | if (adapter->wol & WAKE_ARP) { | ||
2433 | in_dev = in_dev_get(netdev); | ||
2434 | if (!in_dev) | ||
2435 | goto skip_arp; | ||
2436 | |||
2437 | ifa = (struct in_ifaddr *)in_dev->ifa_list; | ||
2438 | if (!ifa) | ||
2439 | goto skip_arp; | ||
2440 | |||
2441 | pmConf->filters[i].patternSize = ETH_HLEN + /* Ethernet header*/ | ||
2442 | sizeof(struct arphdr) + /* ARP header */ | ||
2443 | 2 * ETH_ALEN + /* 2 Ethernet addresses*/ | ||
2444 | 2 * sizeof(u32); /*2 IPv4 addresses */ | ||
2445 | pmConf->filters[i].maskSize = | ||
2446 | (pmConf->filters[i].patternSize - 1) / 8 + 1; | ||
2447 | |||
2448 | /* ETH_P_ARP in Ethernet header. */ | ||
2449 | ehdr = (struct ethhdr *)pmConf->filters[i].pattern; | ||
2450 | ehdr->h_proto = htons(ETH_P_ARP); | ||
2451 | |||
2452 | /* ARPOP_REQUEST in ARP header. */ | ||
2453 | ahdr = (struct arphdr *)&pmConf->filters[i].pattern[ETH_HLEN]; | ||
2454 | ahdr->ar_op = htons(ARPOP_REQUEST); | ||
2455 | arpreq = (u8 *)(ahdr + 1); | ||
2456 | |||
2457 | /* The Unicast IPv4 address in 'tip' field. */ | ||
2458 | arpreq += 2 * ETH_ALEN + sizeof(u32); | ||
2459 | *(u32 *)arpreq = ifa->ifa_address; | ||
2460 | |||
2461 | /* The mask for the relevant bits. */ | ||
2462 | pmConf->filters[i].mask[0] = 0x00; | ||
2463 | pmConf->filters[i].mask[1] = 0x30; /* ETH_P_ARP */ | ||
2464 | pmConf->filters[i].mask[2] = 0x30; /* ARPOP_REQUEST */ | ||
2465 | pmConf->filters[i].mask[3] = 0x00; | ||
2466 | pmConf->filters[i].mask[4] = 0xC0; /* IPv4 TIP */ | ||
2467 | pmConf->filters[i].mask[5] = 0x03; /* IPv4 TIP */ | ||
2468 | in_dev_put(in_dev); | ||
2469 | |||
2470 | pmConf->wakeUpEvents |= VMXNET3_PM_WAKEUP_FILTER; | ||
2471 | i++; | ||
2472 | } | ||
2473 | |||
2474 | skip_arp: | ||
2475 | if (adapter->wol & WAKE_MAGIC) | ||
2476 | pmConf->wakeUpEvents |= VMXNET3_PM_WAKEUP_MAGIC; | ||
2477 | |||
2478 | pmConf->numFilters = i; | ||
2479 | |||
2480 | adapter->shared->devRead.pmConfDesc.confVer = 1; | ||
2481 | adapter->shared->devRead.pmConfDesc.confLen = sizeof(*pmConf); | ||
2482 | adapter->shared->devRead.pmConfDesc.confPA = virt_to_phys(pmConf); | ||
2483 | |||
2484 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
2485 | VMXNET3_CMD_UPDATE_PMCFG); | ||
2486 | |||
2487 | pci_save_state(pdev); | ||
2488 | pci_enable_wake(pdev, pci_choose_state(pdev, PMSG_SUSPEND), | ||
2489 | adapter->wol); | ||
2490 | pci_disable_device(pdev); | ||
2491 | pci_set_power_state(pdev, pci_choose_state(pdev, PMSG_SUSPEND)); | ||
2492 | |||
2493 | return 0; | ||
2494 | } | ||
2495 | |||
2496 | |||
2497 | static int | ||
2498 | vmxnet3_resume(struct device *device) | ||
2499 | { | ||
2500 | int err; | ||
2501 | struct pci_dev *pdev = to_pci_dev(device); | ||
2502 | struct net_device *netdev = pci_get_drvdata(pdev); | ||
2503 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
2504 | struct Vmxnet3_PMConf *pmConf; | ||
2505 | |||
2506 | if (!netif_running(netdev)) | ||
2507 | return 0; | ||
2508 | |||
2509 | /* Destroy wake-up filters. */ | ||
2510 | pmConf = adapter->pm_conf; | ||
2511 | memset(pmConf, 0, sizeof(*pmConf)); | ||
2512 | |||
2513 | adapter->shared->devRead.pmConfDesc.confVer = 1; | ||
2514 | adapter->shared->devRead.pmConfDesc.confLen = sizeof(*pmConf); | ||
2515 | adapter->shared->devRead.pmConfDesc.confPA = virt_to_phys(pmConf); | ||
2516 | |||
2517 | netif_device_attach(netdev); | ||
2518 | pci_set_power_state(pdev, PCI_D0); | ||
2519 | pci_restore_state(pdev); | ||
2520 | err = pci_enable_device_mem(pdev); | ||
2521 | if (err != 0) | ||
2522 | return err; | ||
2523 | |||
2524 | pci_enable_wake(pdev, PCI_D0, 0); | ||
2525 | |||
2526 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
2527 | VMXNET3_CMD_UPDATE_PMCFG); | ||
2528 | vmxnet3_alloc_intr_resources(adapter); | ||
2529 | vmxnet3_request_irqs(adapter); | ||
2530 | vmxnet3_enable_all_intrs(adapter); | ||
2531 | |||
2532 | return 0; | ||
2533 | } | ||
2534 | |||
2535 | static struct dev_pm_ops vmxnet3_pm_ops = { | ||
2536 | .suspend = vmxnet3_suspend, | ||
2537 | .resume = vmxnet3_resume, | ||
2538 | }; | ||
2539 | #endif | ||
2540 | |||
2541 | static struct pci_driver vmxnet3_driver = { | ||
2542 | .name = vmxnet3_driver_name, | ||
2543 | .id_table = vmxnet3_pciid_table, | ||
2544 | .probe = vmxnet3_probe_device, | ||
2545 | .remove = __devexit_p(vmxnet3_remove_device), | ||
2546 | #ifdef CONFIG_PM | ||
2547 | .driver.pm = &vmxnet3_pm_ops, | ||
2548 | #endif | ||
2549 | }; | ||
2550 | |||
2551 | |||
2552 | static int __init | ||
2553 | vmxnet3_init_module(void) | ||
2554 | { | ||
2555 | printk(KERN_INFO "%s - version %s\n", VMXNET3_DRIVER_DESC, | ||
2556 | VMXNET3_DRIVER_VERSION_REPORT); | ||
2557 | return pci_register_driver(&vmxnet3_driver); | ||
2558 | } | ||
2559 | |||
2560 | module_init(vmxnet3_init_module); | ||
2561 | |||
2562 | |||
2563 | static void | ||
2564 | vmxnet3_exit_module(void) | ||
2565 | { | ||
2566 | pci_unregister_driver(&vmxnet3_driver); | ||
2567 | } | ||
2568 | |||
2569 | module_exit(vmxnet3_exit_module); | ||
2570 | |||
2571 | MODULE_AUTHOR("VMware, Inc."); | ||
2572 | MODULE_DESCRIPTION(VMXNET3_DRIVER_DESC); | ||
2573 | MODULE_LICENSE("GPL v2"); | ||
2574 | MODULE_VERSION(VMXNET3_DRIVER_VERSION_STRING); | ||
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c new file mode 100644 index 000000000000..c2c15e4cafc7 --- /dev/null +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c | |||
@@ -0,0 +1,566 @@ | |||
1 | /* | ||
2 | * Linux driver for VMware's vmxnet3 ethernet NIC. | ||
3 | * | ||
4 | * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; version 2 of the License and no later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
13 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
14 | * details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution in | ||
21 | * the file called "COPYING". | ||
22 | * | ||
23 | * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | |||
28 | #include "vmxnet3_int.h" | ||
29 | |||
30 | struct vmxnet3_stat_desc { | ||
31 | char desc[ETH_GSTRING_LEN]; | ||
32 | int offset; | ||
33 | }; | ||
34 | |||
35 | |||
36 | static u32 | ||
37 | vmxnet3_get_rx_csum(struct net_device *netdev) | ||
38 | { | ||
39 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
40 | return adapter->rxcsum; | ||
41 | } | ||
42 | |||
43 | |||
44 | static int | ||
45 | vmxnet3_set_rx_csum(struct net_device *netdev, u32 val) | ||
46 | { | ||
47 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
48 | |||
49 | if (adapter->rxcsum != val) { | ||
50 | adapter->rxcsum = val; | ||
51 | if (netif_running(netdev)) { | ||
52 | if (val) | ||
53 | adapter->shared->devRead.misc.uptFeatures |= | ||
54 | UPT1_F_RXCSUM; | ||
55 | else | ||
56 | adapter->shared->devRead.misc.uptFeatures &= | ||
57 | ~UPT1_F_RXCSUM; | ||
58 | |||
59 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
60 | VMXNET3_CMD_UPDATE_FEATURE); | ||
61 | } | ||
62 | } | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | |||
67 | /* per tq stats maintained by the device */ | ||
68 | static const struct vmxnet3_stat_desc | ||
69 | vmxnet3_tq_dev_stats[] = { | ||
70 | /* description, offset */ | ||
71 | { "TSO pkts tx", offsetof(struct UPT1_TxStats, TSOPktsTxOK) }, | ||
72 | { "TSO bytes tx", offsetof(struct UPT1_TxStats, TSOBytesTxOK) }, | ||
73 | { "ucast pkts tx", offsetof(struct UPT1_TxStats, ucastPktsTxOK) }, | ||
74 | { "ucast bytes tx", offsetof(struct UPT1_TxStats, ucastBytesTxOK) }, | ||
75 | { "mcast pkts tx", offsetof(struct UPT1_TxStats, mcastPktsTxOK) }, | ||
76 | { "mcast bytes tx", offsetof(struct UPT1_TxStats, mcastBytesTxOK) }, | ||
77 | { "bcast pkts tx", offsetof(struct UPT1_TxStats, bcastPktsTxOK) }, | ||
78 | { "bcast bytes tx", offsetof(struct UPT1_TxStats, bcastBytesTxOK) }, | ||
79 | { "pkts tx err", offsetof(struct UPT1_TxStats, pktsTxError) }, | ||
80 | { "pkts tx discard", offsetof(struct UPT1_TxStats, pktsTxDiscard) }, | ||
81 | }; | ||
82 | |||
83 | /* per tq stats maintained by the driver */ | ||
84 | static const struct vmxnet3_stat_desc | ||
85 | vmxnet3_tq_driver_stats[] = { | ||
86 | /* description, offset */ | ||
87 | {"drv dropped tx total", offsetof(struct vmxnet3_tq_driver_stats, | ||
88 | drop_total) }, | ||
89 | { " too many frags", offsetof(struct vmxnet3_tq_driver_stats, | ||
90 | drop_too_many_frags) }, | ||
91 | { " giant hdr", offsetof(struct vmxnet3_tq_driver_stats, | ||
92 | drop_oversized_hdr) }, | ||
93 | { " hdr err", offsetof(struct vmxnet3_tq_driver_stats, | ||
94 | drop_hdr_inspect_err) }, | ||
95 | { " tso", offsetof(struct vmxnet3_tq_driver_stats, | ||
96 | drop_tso) }, | ||
97 | { "ring full", offsetof(struct vmxnet3_tq_driver_stats, | ||
98 | tx_ring_full) }, | ||
99 | { "pkts linearized", offsetof(struct vmxnet3_tq_driver_stats, | ||
100 | linearized) }, | ||
101 | { "hdr cloned", offsetof(struct vmxnet3_tq_driver_stats, | ||
102 | copy_skb_header) }, | ||
103 | { "giant hdr", offsetof(struct vmxnet3_tq_driver_stats, | ||
104 | oversized_hdr) }, | ||
105 | }; | ||
106 | |||
107 | /* per rq stats maintained by the device */ | ||
108 | static const struct vmxnet3_stat_desc | ||
109 | vmxnet3_rq_dev_stats[] = { | ||
110 | { "LRO pkts rx", offsetof(struct UPT1_RxStats, LROPktsRxOK) }, | ||
111 | { "LRO byte rx", offsetof(struct UPT1_RxStats, LROBytesRxOK) }, | ||
112 | { "ucast pkts rx", offsetof(struct UPT1_RxStats, ucastPktsRxOK) }, | ||
113 | { "ucast bytes rx", offsetof(struct UPT1_RxStats, ucastBytesRxOK) }, | ||
114 | { "mcast pkts rx", offsetof(struct UPT1_RxStats, mcastPktsRxOK) }, | ||
115 | { "mcast bytes rx", offsetof(struct UPT1_RxStats, mcastBytesRxOK) }, | ||
116 | { "bcast pkts rx", offsetof(struct UPT1_RxStats, bcastPktsRxOK) }, | ||
117 | { "bcast bytes rx", offsetof(struct UPT1_RxStats, bcastBytesRxOK) }, | ||
118 | { "pkts rx out of buf", offsetof(struct UPT1_RxStats, pktsRxOutOfBuf) }, | ||
119 | { "pkts rx err", offsetof(struct UPT1_RxStats, pktsRxError) }, | ||
120 | }; | ||
121 | |||
122 | /* per rq stats maintained by the driver */ | ||
123 | static const struct vmxnet3_stat_desc | ||
124 | vmxnet3_rq_driver_stats[] = { | ||
125 | /* description, offset */ | ||
126 | { "drv dropped rx total", offsetof(struct vmxnet3_rq_driver_stats, | ||
127 | drop_total) }, | ||
128 | { " err", offsetof(struct vmxnet3_rq_driver_stats, | ||
129 | drop_err) }, | ||
130 | { " fcs", offsetof(struct vmxnet3_rq_driver_stats, | ||
131 | drop_fcs) }, | ||
132 | { "rx buf alloc fail", offsetof(struct vmxnet3_rq_driver_stats, | ||
133 | rx_buf_alloc_failure) }, | ||
134 | }; | ||
135 | |||
136 | /* gloabl stats maintained by the driver */ | ||
137 | static const struct vmxnet3_stat_desc | ||
138 | vmxnet3_global_stats[] = { | ||
139 | /* description, offset */ | ||
140 | { "tx timeout count", offsetof(struct vmxnet3_adapter, | ||
141 | tx_timeout_count) } | ||
142 | }; | ||
143 | |||
144 | |||
145 | struct net_device_stats * | ||
146 | vmxnet3_get_stats(struct net_device *netdev) | ||
147 | { | ||
148 | struct vmxnet3_adapter *adapter; | ||
149 | struct vmxnet3_tq_driver_stats *drvTxStats; | ||
150 | struct vmxnet3_rq_driver_stats *drvRxStats; | ||
151 | struct UPT1_TxStats *devTxStats; | ||
152 | struct UPT1_RxStats *devRxStats; | ||
153 | struct net_device_stats *net_stats = &netdev->stats; | ||
154 | |||
155 | adapter = netdev_priv(netdev); | ||
156 | |||
157 | /* Collect the dev stats into the shared area */ | ||
158 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); | ||
159 | |||
160 | /* Assuming that we have a single queue device */ | ||
161 | devTxStats = &adapter->tqd_start->stats; | ||
162 | devRxStats = &adapter->rqd_start->stats; | ||
163 | |||
164 | /* Get access to the driver stats per queue */ | ||
165 | drvTxStats = &adapter->tx_queue.stats; | ||
166 | drvRxStats = &adapter->rx_queue.stats; | ||
167 | |||
168 | memset(net_stats, 0, sizeof(*net_stats)); | ||
169 | |||
170 | net_stats->rx_packets = devRxStats->ucastPktsRxOK + | ||
171 | devRxStats->mcastPktsRxOK + | ||
172 | devRxStats->bcastPktsRxOK; | ||
173 | |||
174 | net_stats->tx_packets = devTxStats->ucastPktsTxOK + | ||
175 | devTxStats->mcastPktsTxOK + | ||
176 | devTxStats->bcastPktsTxOK; | ||
177 | |||
178 | net_stats->rx_bytes = devRxStats->ucastBytesRxOK + | ||
179 | devRxStats->mcastBytesRxOK + | ||
180 | devRxStats->bcastBytesRxOK; | ||
181 | |||
182 | net_stats->tx_bytes = devTxStats->ucastBytesTxOK + | ||
183 | devTxStats->mcastBytesTxOK + | ||
184 | devTxStats->bcastBytesTxOK; | ||
185 | |||
186 | net_stats->rx_errors = devRxStats->pktsRxError; | ||
187 | net_stats->tx_errors = devTxStats->pktsTxError; | ||
188 | net_stats->rx_dropped = drvRxStats->drop_total; | ||
189 | net_stats->tx_dropped = drvTxStats->drop_total; | ||
190 | net_stats->multicast = devRxStats->mcastPktsRxOK; | ||
191 | |||
192 | return net_stats; | ||
193 | } | ||
194 | |||
195 | static int | ||
196 | vmxnet3_get_sset_count(struct net_device *netdev, int sset) | ||
197 | { | ||
198 | switch (sset) { | ||
199 | case ETH_SS_STATS: | ||
200 | return ARRAY_SIZE(vmxnet3_tq_dev_stats) + | ||
201 | ARRAY_SIZE(vmxnet3_tq_driver_stats) + | ||
202 | ARRAY_SIZE(vmxnet3_rq_dev_stats) + | ||
203 | ARRAY_SIZE(vmxnet3_rq_driver_stats) + | ||
204 | ARRAY_SIZE(vmxnet3_global_stats); | ||
205 | default: | ||
206 | return -EOPNOTSUPP; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | |||
211 | static int | ||
212 | vmxnet3_get_regs_len(struct net_device *netdev) | ||
213 | { | ||
214 | return 20 * sizeof(u32); | ||
215 | } | ||
216 | |||
217 | |||
218 | static void | ||
219 | vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) | ||
220 | { | ||
221 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
222 | |||
223 | strlcpy(drvinfo->driver, vmxnet3_driver_name, sizeof(drvinfo->driver)); | ||
224 | drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; | ||
225 | |||
226 | strlcpy(drvinfo->version, VMXNET3_DRIVER_VERSION_REPORT, | ||
227 | sizeof(drvinfo->version)); | ||
228 | drvinfo->driver[sizeof(drvinfo->version) - 1] = '\0'; | ||
229 | |||
230 | strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); | ||
231 | drvinfo->fw_version[sizeof(drvinfo->fw_version) - 1] = '\0'; | ||
232 | |||
233 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
234 | ETHTOOL_BUSINFO_LEN); | ||
235 | drvinfo->n_stats = vmxnet3_get_sset_count(netdev, ETH_SS_STATS); | ||
236 | drvinfo->testinfo_len = 0; | ||
237 | drvinfo->eedump_len = 0; | ||
238 | drvinfo->regdump_len = vmxnet3_get_regs_len(netdev); | ||
239 | } | ||
240 | |||
241 | |||
242 | static void | ||
243 | vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) | ||
244 | { | ||
245 | if (stringset == ETH_SS_STATS) { | ||
246 | int i; | ||
247 | |||
248 | for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) { | ||
249 | memcpy(buf, vmxnet3_tq_dev_stats[i].desc, | ||
250 | ETH_GSTRING_LEN); | ||
251 | buf += ETH_GSTRING_LEN; | ||
252 | } | ||
253 | for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) { | ||
254 | memcpy(buf, vmxnet3_tq_driver_stats[i].desc, | ||
255 | ETH_GSTRING_LEN); | ||
256 | buf += ETH_GSTRING_LEN; | ||
257 | } | ||
258 | for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) { | ||
259 | memcpy(buf, vmxnet3_rq_dev_stats[i].desc, | ||
260 | ETH_GSTRING_LEN); | ||
261 | buf += ETH_GSTRING_LEN; | ||
262 | } | ||
263 | for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) { | ||
264 | memcpy(buf, vmxnet3_rq_driver_stats[i].desc, | ||
265 | ETH_GSTRING_LEN); | ||
266 | buf += ETH_GSTRING_LEN; | ||
267 | } | ||
268 | for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) { | ||
269 | memcpy(buf, vmxnet3_global_stats[i].desc, | ||
270 | ETH_GSTRING_LEN); | ||
271 | buf += ETH_GSTRING_LEN; | ||
272 | } | ||
273 | } | ||
274 | } | ||
275 | |||
276 | static u32 | ||
277 | vmxnet3_get_flags(struct net_device *netdev) { | ||
278 | return netdev->features; | ||
279 | } | ||
280 | |||
281 | static int | ||
282 | vmxnet3_set_flags(struct net_device *netdev, u32 data) { | ||
283 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
284 | u8 lro_requested = (data & ETH_FLAG_LRO) == 0 ? 0 : 1; | ||
285 | u8 lro_present = (netdev->features & NETIF_F_LRO) == 0 ? 0 : 1; | ||
286 | |||
287 | if (lro_requested ^ lro_present) { | ||
288 | /* toggle the LRO feature*/ | ||
289 | netdev->features ^= NETIF_F_LRO; | ||
290 | |||
291 | /* update harware LRO capability accordingly */ | ||
292 | if (lro_requested) | ||
293 | adapter->shared->devRead.misc.uptFeatures &= UPT1_F_LRO; | ||
294 | else | ||
295 | adapter->shared->devRead.misc.uptFeatures &= | ||
296 | ~UPT1_F_LRO; | ||
297 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, | ||
298 | VMXNET3_CMD_UPDATE_FEATURE); | ||
299 | } | ||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static void | ||
304 | vmxnet3_get_ethtool_stats(struct net_device *netdev, | ||
305 | struct ethtool_stats *stats, u64 *buf) | ||
306 | { | ||
307 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
308 | u8 *base; | ||
309 | int i; | ||
310 | |||
311 | VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); | ||
312 | |||
313 | /* this does assume each counter is 64-bit wide */ | ||
314 | |||
315 | base = (u8 *)&adapter->tqd_start->stats; | ||
316 | for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) | ||
317 | *buf++ = *(u64 *)(base + vmxnet3_tq_dev_stats[i].offset); | ||
318 | |||
319 | base = (u8 *)&adapter->tx_queue.stats; | ||
320 | for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) | ||
321 | *buf++ = *(u64 *)(base + vmxnet3_tq_driver_stats[i].offset); | ||
322 | |||
323 | base = (u8 *)&adapter->rqd_start->stats; | ||
324 | for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) | ||
325 | *buf++ = *(u64 *)(base + vmxnet3_rq_dev_stats[i].offset); | ||
326 | |||
327 | base = (u8 *)&adapter->rx_queue.stats; | ||
328 | for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) | ||
329 | *buf++ = *(u64 *)(base + vmxnet3_rq_driver_stats[i].offset); | ||
330 | |||
331 | base = (u8 *)adapter; | ||
332 | for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) | ||
333 | *buf++ = *(u64 *)(base + vmxnet3_global_stats[i].offset); | ||
334 | } | ||
335 | |||
336 | |||
337 | static void | ||
338 | vmxnet3_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p) | ||
339 | { | ||
340 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
341 | u32 *buf = p; | ||
342 | |||
343 | memset(p, 0, vmxnet3_get_regs_len(netdev)); | ||
344 | |||
345 | regs->version = 1; | ||
346 | |||
347 | /* Update vmxnet3_get_regs_len if we want to dump more registers */ | ||
348 | |||
349 | /* make each ring use multiple of 16 bytes */ | ||
350 | buf[0] = adapter->tx_queue.tx_ring.next2fill; | ||
351 | buf[1] = adapter->tx_queue.tx_ring.next2comp; | ||
352 | buf[2] = adapter->tx_queue.tx_ring.gen; | ||
353 | buf[3] = 0; | ||
354 | |||
355 | buf[4] = adapter->tx_queue.comp_ring.next2proc; | ||
356 | buf[5] = adapter->tx_queue.comp_ring.gen; | ||
357 | buf[6] = adapter->tx_queue.stopped; | ||
358 | buf[7] = 0; | ||
359 | |||
360 | buf[8] = adapter->rx_queue.rx_ring[0].next2fill; | ||
361 | buf[9] = adapter->rx_queue.rx_ring[0].next2comp; | ||
362 | buf[10] = adapter->rx_queue.rx_ring[0].gen; | ||
363 | buf[11] = 0; | ||
364 | |||
365 | buf[12] = adapter->rx_queue.rx_ring[1].next2fill; | ||
366 | buf[13] = adapter->rx_queue.rx_ring[1].next2comp; | ||
367 | buf[14] = adapter->rx_queue.rx_ring[1].gen; | ||
368 | buf[15] = 0; | ||
369 | |||
370 | buf[16] = adapter->rx_queue.comp_ring.next2proc; | ||
371 | buf[17] = adapter->rx_queue.comp_ring.gen; | ||
372 | buf[18] = 0; | ||
373 | buf[19] = 0; | ||
374 | } | ||
375 | |||
376 | |||
377 | static void | ||
378 | vmxnet3_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | ||
379 | { | ||
380 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
381 | |||
382 | wol->supported = WAKE_UCAST | WAKE_ARP | WAKE_MAGIC; | ||
383 | wol->wolopts = adapter->wol; | ||
384 | } | ||
385 | |||
386 | |||
387 | static int | ||
388 | vmxnet3_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | ||
389 | { | ||
390 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
391 | |||
392 | if (wol->wolopts & (WAKE_PHY | WAKE_MCAST | WAKE_BCAST | | ||
393 | WAKE_MAGICSECURE)) { | ||
394 | return -EOPNOTSUPP; | ||
395 | } | ||
396 | |||
397 | adapter->wol = wol->wolopts; | ||
398 | |||
399 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | |||
405 | static int | ||
406 | vmxnet3_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) | ||
407 | { | ||
408 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
409 | |||
410 | ecmd->supported = SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full | | ||
411 | SUPPORTED_TP; | ||
412 | ecmd->advertising = ADVERTISED_TP; | ||
413 | ecmd->port = PORT_TP; | ||
414 | ecmd->transceiver = XCVR_INTERNAL; | ||
415 | |||
416 | if (adapter->link_speed) { | ||
417 | ecmd->speed = adapter->link_speed; | ||
418 | ecmd->duplex = DUPLEX_FULL; | ||
419 | } else { | ||
420 | ecmd->speed = -1; | ||
421 | ecmd->duplex = -1; | ||
422 | } | ||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | |||
427 | static void | ||
428 | vmxnet3_get_ringparam(struct net_device *netdev, | ||
429 | struct ethtool_ringparam *param) | ||
430 | { | ||
431 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
432 | |||
433 | param->rx_max_pending = VMXNET3_RX_RING_MAX_SIZE; | ||
434 | param->tx_max_pending = VMXNET3_TX_RING_MAX_SIZE; | ||
435 | param->rx_mini_max_pending = 0; | ||
436 | param->rx_jumbo_max_pending = 0; | ||
437 | |||
438 | param->rx_pending = adapter->rx_queue.rx_ring[0].size; | ||
439 | param->tx_pending = adapter->tx_queue.tx_ring.size; | ||
440 | param->rx_mini_pending = 0; | ||
441 | param->rx_jumbo_pending = 0; | ||
442 | } | ||
443 | |||
444 | |||
445 | static int | ||
446 | vmxnet3_set_ringparam(struct net_device *netdev, | ||
447 | struct ethtool_ringparam *param) | ||
448 | { | ||
449 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | ||
450 | u32 new_tx_ring_size, new_rx_ring_size; | ||
451 | u32 sz; | ||
452 | int err = 0; | ||
453 | |||
454 | if (param->tx_pending == 0 || param->tx_pending > | ||
455 | VMXNET3_TX_RING_MAX_SIZE) | ||
456 | return -EINVAL; | ||
457 | |||
458 | if (param->rx_pending == 0 || param->rx_pending > | ||
459 | VMXNET3_RX_RING_MAX_SIZE) | ||
460 | return -EINVAL; | ||
461 | |||
462 | |||
463 | /* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */ | ||
464 | new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) & | ||
465 | ~VMXNET3_RING_SIZE_MASK; | ||
466 | new_tx_ring_size = min_t(u32, new_tx_ring_size, | ||
467 | VMXNET3_TX_RING_MAX_SIZE); | ||
468 | if (new_tx_ring_size > VMXNET3_TX_RING_MAX_SIZE || (new_tx_ring_size % | ||
469 | VMXNET3_RING_SIZE_ALIGN) != 0) | ||
470 | return -EINVAL; | ||
471 | |||
472 | /* ring0 has to be a multiple of | ||
473 | * rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN | ||
474 | */ | ||
475 | sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN; | ||
476 | new_rx_ring_size = (param->rx_pending + sz - 1) / sz * sz; | ||
477 | new_rx_ring_size = min_t(u32, new_rx_ring_size, | ||
478 | VMXNET3_RX_RING_MAX_SIZE / sz * sz); | ||
479 | if (new_rx_ring_size > VMXNET3_RX_RING_MAX_SIZE || (new_rx_ring_size % | ||
480 | sz) != 0) | ||
481 | return -EINVAL; | ||
482 | |||
483 | if (new_tx_ring_size == adapter->tx_queue.tx_ring.size && | ||
484 | new_rx_ring_size == adapter->rx_queue.rx_ring[0].size) { | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | * Reset_work may be in the middle of resetting the device, wait for its | ||
490 | * completion. | ||
491 | */ | ||
492 | while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) | ||
493 | msleep(1); | ||
494 | |||
495 | if (netif_running(netdev)) { | ||
496 | vmxnet3_quiesce_dev(adapter); | ||
497 | vmxnet3_reset_dev(adapter); | ||
498 | |||
499 | /* recreate the rx queue and the tx queue based on the | ||
500 | * new sizes */ | ||
501 | vmxnet3_tq_destroy(&adapter->tx_queue, adapter); | ||
502 | vmxnet3_rq_destroy(&adapter->rx_queue, adapter); | ||
503 | |||
504 | err = vmxnet3_create_queues(adapter, new_tx_ring_size, | ||
505 | new_rx_ring_size, VMXNET3_DEF_RX_RING_SIZE); | ||
506 | if (err) { | ||
507 | /* failed, most likely because of OOM, try default | ||
508 | * size */ | ||
509 | printk(KERN_ERR "%s: failed to apply new sizes, try the" | ||
510 | " default ones\n", netdev->name); | ||
511 | err = vmxnet3_create_queues(adapter, | ||
512 | VMXNET3_DEF_TX_RING_SIZE, | ||
513 | VMXNET3_DEF_RX_RING_SIZE, | ||
514 | VMXNET3_DEF_RX_RING_SIZE); | ||
515 | if (err) { | ||
516 | printk(KERN_ERR "%s: failed to create queues " | ||
517 | "with default sizes. Closing it\n", | ||
518 | netdev->name); | ||
519 | goto out; | ||
520 | } | ||
521 | } | ||
522 | |||
523 | err = vmxnet3_activate_dev(adapter); | ||
524 | if (err) | ||
525 | printk(KERN_ERR "%s: failed to re-activate, error %d." | ||
526 | " Closing it\n", netdev->name, err); | ||
527 | } | ||
528 | |||
529 | out: | ||
530 | clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); | ||
531 | if (err) | ||
532 | vmxnet3_force_close(adapter); | ||
533 | |||
534 | return err; | ||
535 | } | ||
536 | |||
537 | |||
538 | static struct ethtool_ops vmxnet3_ethtool_ops = { | ||
539 | .get_settings = vmxnet3_get_settings, | ||
540 | .get_drvinfo = vmxnet3_get_drvinfo, | ||
541 | .get_regs_len = vmxnet3_get_regs_len, | ||
542 | .get_regs = vmxnet3_get_regs, | ||
543 | .get_wol = vmxnet3_get_wol, | ||
544 | .set_wol = vmxnet3_set_wol, | ||
545 | .get_link = ethtool_op_get_link, | ||
546 | .get_rx_csum = vmxnet3_get_rx_csum, | ||
547 | .set_rx_csum = vmxnet3_set_rx_csum, | ||
548 | .get_tx_csum = ethtool_op_get_tx_csum, | ||
549 | .set_tx_csum = ethtool_op_set_tx_hw_csum, | ||
550 | .get_sg = ethtool_op_get_sg, | ||
551 | .set_sg = ethtool_op_set_sg, | ||
552 | .get_tso = ethtool_op_get_tso, | ||
553 | .set_tso = ethtool_op_set_tso, | ||
554 | .get_strings = vmxnet3_get_strings, | ||
555 | .get_flags = vmxnet3_get_flags, | ||
556 | .set_flags = vmxnet3_set_flags, | ||
557 | .get_sset_count = vmxnet3_get_sset_count, | ||
558 | .get_ethtool_stats = vmxnet3_get_ethtool_stats, | ||
559 | .get_ringparam = vmxnet3_get_ringparam, | ||
560 | .set_ringparam = vmxnet3_set_ringparam, | ||
561 | }; | ||
562 | |||
563 | void vmxnet3_set_ethtool_ops(struct net_device *netdev) | ||
564 | { | ||
565 | SET_ETHTOOL_OPS(netdev, &vmxnet3_ethtool_ops); | ||
566 | } | ||
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h new file mode 100644 index 000000000000..3c0d70d58111 --- /dev/null +++ b/drivers/net/vmxnet3/vmxnet3_int.h | |||
@@ -0,0 +1,389 @@ | |||
1 | /* | ||
2 | * Linux driver for VMware's vmxnet3 ethernet NIC. | ||
3 | * | ||
4 | * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; version 2 of the License and no later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
13 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
14 | * details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution in | ||
21 | * the file called "COPYING". | ||
22 | * | ||
23 | * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com> | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #ifndef _VMXNET3_INT_H | ||
28 | #define _VMXNET3_INT_H | ||
29 | |||
30 | #include <linux/types.h> | ||
31 | #include <linux/ethtool.h> | ||
32 | #include <linux/delay.h> | ||
33 | #include <linux/device.h> | ||
34 | #include <linux/netdevice.h> | ||
35 | #include <linux/pci.h> | ||
36 | #include <linux/ethtool.h> | ||
37 | #include <linux/compiler.h> | ||
38 | #include <linux/module.h> | ||
39 | #include <linux/moduleparam.h> | ||
40 | #include <linux/slab.h> | ||
41 | #include <linux/spinlock.h> | ||
42 | #include <linux/ioport.h> | ||
43 | #include <linux/highmem.h> | ||
44 | #include <linux/init.h> | ||
45 | #include <linux/timer.h> | ||
46 | #include <linux/skbuff.h> | ||
47 | #include <linux/interrupt.h> | ||
48 | #include <linux/workqueue.h> | ||
49 | #include <linux/uaccess.h> | ||
50 | #include <asm/dma.h> | ||
51 | #include <asm/page.h> | ||
52 | |||
53 | #include <linux/tcp.h> | ||
54 | #include <linux/udp.h> | ||
55 | #include <linux/ip.h> | ||
56 | #include <linux/ipv6.h> | ||
57 | #include <linux/in.h> | ||
58 | #include <linux/etherdevice.h> | ||
59 | #include <asm/checksum.h> | ||
60 | #include <linux/if_vlan.h> | ||
61 | #include <linux/if_arp.h> | ||
62 | #include <linux/inetdevice.h> | ||
63 | |||
64 | #include "vmxnet3_defs.h" | ||
65 | |||
66 | #ifdef DEBUG | ||
67 | # define VMXNET3_DRIVER_VERSION_REPORT VMXNET3_DRIVER_VERSION_STRING"-NAPI(debug)" | ||
68 | #else | ||
69 | # define VMXNET3_DRIVER_VERSION_REPORT VMXNET3_DRIVER_VERSION_STRING"-NAPI" | ||
70 | #endif | ||
71 | |||
72 | |||
73 | /* | ||
74 | * Version numbers | ||
75 | */ | ||
76 | #define VMXNET3_DRIVER_VERSION_STRING "1.0.5.0-k" | ||
77 | |||
78 | /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ | ||
79 | #define VMXNET3_DRIVER_VERSION_NUM 0x01000500 | ||
80 | |||
81 | |||
82 | /* | ||
83 | * Capabilities | ||
84 | */ | ||
85 | |||
86 | enum { | ||
87 | VMNET_CAP_SG = 0x0001, /* Can do scatter-gather transmits. */ | ||
88 | VMNET_CAP_IP4_CSUM = 0x0002, /* Can checksum only TCP/UDP over | ||
89 | * IPv4 */ | ||
90 | VMNET_CAP_HW_CSUM = 0x0004, /* Can checksum all packets. */ | ||
91 | VMNET_CAP_HIGH_DMA = 0x0008, /* Can DMA to high memory. */ | ||
92 | VMNET_CAP_TOE = 0x0010, /* Supports TCP/IP offload. */ | ||
93 | VMNET_CAP_TSO = 0x0020, /* Supports TCP Segmentation | ||
94 | * offload */ | ||
95 | VMNET_CAP_SW_TSO = 0x0040, /* Supports SW TCP Segmentation */ | ||
96 | VMNET_CAP_VMXNET_APROM = 0x0080, /* Vmxnet APROM support */ | ||
97 | VMNET_CAP_HW_TX_VLAN = 0x0100, /* Can we do VLAN tagging in HW */ | ||
98 | VMNET_CAP_HW_RX_VLAN = 0x0200, /* Can we do VLAN untagging in HW */ | ||
99 | VMNET_CAP_SW_VLAN = 0x0400, /* VLAN tagging/untagging in SW */ | ||
100 | VMNET_CAP_WAKE_PCKT_RCV = 0x0800, /* Can wake on network packet recv? */ | ||
101 | VMNET_CAP_ENABLE_INT_INLINE = 0x1000, /* Enable Interrupt Inline */ | ||
102 | VMNET_CAP_ENABLE_HEADER_COPY = 0x2000, /* copy header for vmkernel */ | ||
103 | VMNET_CAP_TX_CHAIN = 0x4000, /* Guest can use multiple tx entries | ||
104 | * for a pkt */ | ||
105 | VMNET_CAP_RX_CHAIN = 0x8000, /* pkt can span multiple rx entries */ | ||
106 | VMNET_CAP_LPD = 0x10000, /* large pkt delivery */ | ||
107 | VMNET_CAP_BPF = 0x20000, /* BPF Support in VMXNET Virtual HW*/ | ||
108 | VMNET_CAP_SG_SPAN_PAGES = 0x40000, /* Scatter-gather can span multiple*/ | ||
109 | /* pages transmits */ | ||
110 | VMNET_CAP_IP6_CSUM = 0x80000, /* Can do IPv6 csum offload. */ | ||
111 | VMNET_CAP_TSO6 = 0x100000, /* TSO seg. offload for IPv6 pkts. */ | ||
112 | VMNET_CAP_TSO256k = 0x200000, /* Can do TSO seg offload for */ | ||
113 | /* pkts up to 256kB. */ | ||
114 | VMNET_CAP_UPT = 0x400000 /* Support UPT */ | ||
115 | }; | ||
116 | |||
117 | /* | ||
118 | * PCI vendor and device IDs. | ||
119 | */ | ||
120 | #define PCI_VENDOR_ID_VMWARE 0x15AD | ||
121 | #define PCI_DEVICE_ID_VMWARE_VMXNET3 0x07B0 | ||
122 | #define MAX_ETHERNET_CARDS 10 | ||
123 | #define MAX_PCI_PASSTHRU_DEVICE 6 | ||
124 | |||
125 | struct vmxnet3_cmd_ring { | ||
126 | union Vmxnet3_GenericDesc *base; | ||
127 | u32 size; | ||
128 | u32 next2fill; | ||
129 | u32 next2comp; | ||
130 | u8 gen; | ||
131 | dma_addr_t basePA; | ||
132 | }; | ||
133 | |||
134 | static inline void | ||
135 | vmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring) | ||
136 | { | ||
137 | ring->next2fill++; | ||
138 | if (unlikely(ring->next2fill == ring->size)) { | ||
139 | ring->next2fill = 0; | ||
140 | VMXNET3_FLIP_RING_GEN(ring->gen); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | static inline void | ||
145 | vmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring) | ||
146 | { | ||
147 | VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size); | ||
148 | } | ||
149 | |||
150 | static inline int | ||
151 | vmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring) | ||
152 | { | ||
153 | return (ring->next2comp > ring->next2fill ? 0 : ring->size) + | ||
154 | ring->next2comp - ring->next2fill - 1; | ||
155 | } | ||
156 | |||
157 | struct vmxnet3_comp_ring { | ||
158 | union Vmxnet3_GenericDesc *base; | ||
159 | u32 size; | ||
160 | u32 next2proc; | ||
161 | u8 gen; | ||
162 | u8 intr_idx; | ||
163 | dma_addr_t basePA; | ||
164 | }; | ||
165 | |||
166 | static inline void | ||
167 | vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring) | ||
168 | { | ||
169 | ring->next2proc++; | ||
170 | if (unlikely(ring->next2proc == ring->size)) { | ||
171 | ring->next2proc = 0; | ||
172 | VMXNET3_FLIP_RING_GEN(ring->gen); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | struct vmxnet3_tx_data_ring { | ||
177 | struct Vmxnet3_TxDataDesc *base; | ||
178 | u32 size; | ||
179 | dma_addr_t basePA; | ||
180 | }; | ||
181 | |||
182 | enum vmxnet3_buf_map_type { | ||
183 | VMXNET3_MAP_INVALID = 0, | ||
184 | VMXNET3_MAP_NONE, | ||
185 | VMXNET3_MAP_SINGLE, | ||
186 | VMXNET3_MAP_PAGE, | ||
187 | }; | ||
188 | |||
189 | struct vmxnet3_tx_buf_info { | ||
190 | u32 map_type; | ||
191 | u16 len; | ||
192 | u16 sop_idx; | ||
193 | dma_addr_t dma_addr; | ||
194 | struct sk_buff *skb; | ||
195 | }; | ||
196 | |||
197 | struct vmxnet3_tq_driver_stats { | ||
198 | u64 drop_total; /* # of pkts dropped by the driver, the | ||
199 | * counters below track droppings due to | ||
200 | * different reasons | ||
201 | */ | ||
202 | u64 drop_too_many_frags; | ||
203 | u64 drop_oversized_hdr; | ||
204 | u64 drop_hdr_inspect_err; | ||
205 | u64 drop_tso; | ||
206 | |||
207 | u64 tx_ring_full; | ||
208 | u64 linearized; /* # of pkts linearized */ | ||
209 | u64 copy_skb_header; /* # of times we have to copy skb header */ | ||
210 | u64 oversized_hdr; | ||
211 | }; | ||
212 | |||
213 | struct vmxnet3_tx_ctx { | ||
214 | bool ipv4; | ||
215 | u16 mss; | ||
216 | u32 eth_ip_hdr_size; /* only valid for pkts requesting tso or csum | ||
217 | * offloading | ||
218 | */ | ||
219 | u32 l4_hdr_size; /* only valid if mss != 0 */ | ||
220 | u32 copy_size; /* # of bytes copied into the data ring */ | ||
221 | union Vmxnet3_GenericDesc *sop_txd; | ||
222 | union Vmxnet3_GenericDesc *eop_txd; | ||
223 | }; | ||
224 | |||
225 | struct vmxnet3_tx_queue { | ||
226 | spinlock_t tx_lock; | ||
227 | struct vmxnet3_cmd_ring tx_ring; | ||
228 | struct vmxnet3_tx_buf_info *buf_info; | ||
229 | struct vmxnet3_tx_data_ring data_ring; | ||
230 | struct vmxnet3_comp_ring comp_ring; | ||
231 | struct Vmxnet3_TxQueueCtrl *shared; | ||
232 | struct vmxnet3_tq_driver_stats stats; | ||
233 | bool stopped; | ||
234 | int num_stop; /* # of times the queue is | ||
235 | * stopped */ | ||
236 | } __attribute__((__aligned__(SMP_CACHE_BYTES))); | ||
237 | |||
238 | enum vmxnet3_rx_buf_type { | ||
239 | VMXNET3_RX_BUF_NONE = 0, | ||
240 | VMXNET3_RX_BUF_SKB = 1, | ||
241 | VMXNET3_RX_BUF_PAGE = 2 | ||
242 | }; | ||
243 | |||
244 | struct vmxnet3_rx_buf_info { | ||
245 | enum vmxnet3_rx_buf_type buf_type; | ||
246 | u16 len; | ||
247 | union { | ||
248 | struct sk_buff *skb; | ||
249 | struct page *page; | ||
250 | }; | ||
251 | dma_addr_t dma_addr; | ||
252 | }; | ||
253 | |||
254 | struct vmxnet3_rx_ctx { | ||
255 | struct sk_buff *skb; | ||
256 | u32 sop_idx; | ||
257 | }; | ||
258 | |||
259 | struct vmxnet3_rq_driver_stats { | ||
260 | u64 drop_total; | ||
261 | u64 drop_err; | ||
262 | u64 drop_fcs; | ||
263 | u64 rx_buf_alloc_failure; | ||
264 | }; | ||
265 | |||
266 | struct vmxnet3_rx_queue { | ||
267 | struct vmxnet3_cmd_ring rx_ring[2]; | ||
268 | struct vmxnet3_comp_ring comp_ring; | ||
269 | struct vmxnet3_rx_ctx rx_ctx; | ||
270 | u32 qid; /* rqID in RCD for buffer from 1st ring */ | ||
271 | u32 qid2; /* rqID in RCD for buffer from 2nd ring */ | ||
272 | u32 uncommitted[2]; /* # of buffers allocated since last RXPROD | ||
273 | * update */ | ||
274 | struct vmxnet3_rx_buf_info *buf_info[2]; | ||
275 | struct Vmxnet3_RxQueueCtrl *shared; | ||
276 | struct vmxnet3_rq_driver_stats stats; | ||
277 | } __attribute__((__aligned__(SMP_CACHE_BYTES))); | ||
278 | |||
279 | #define VMXNET3_LINUX_MAX_MSIX_VECT 1 | ||
280 | |||
281 | struct vmxnet3_intr { | ||
282 | enum vmxnet3_intr_mask_mode mask_mode; | ||
283 | enum vmxnet3_intr_type type; /* MSI-X, MSI, or INTx? */ | ||
284 | u8 num_intrs; /* # of intr vectors */ | ||
285 | u8 event_intr_idx; /* idx of the intr vector for event */ | ||
286 | u8 mod_levels[VMXNET3_LINUX_MAX_MSIX_VECT]; /* moderation level */ | ||
287 | #ifdef CONFIG_PCI_MSI | ||
288 | struct msix_entry msix_entries[VMXNET3_LINUX_MAX_MSIX_VECT]; | ||
289 | #endif | ||
290 | }; | ||
291 | |||
292 | #define VMXNET3_STATE_BIT_RESETTING 0 | ||
293 | #define VMXNET3_STATE_BIT_QUIESCED 1 | ||
294 | struct vmxnet3_adapter { | ||
295 | struct vmxnet3_tx_queue tx_queue; | ||
296 | struct vmxnet3_rx_queue rx_queue; | ||
297 | struct napi_struct napi; | ||
298 | struct vlan_group *vlan_grp; | ||
299 | |||
300 | struct vmxnet3_intr intr; | ||
301 | |||
302 | struct Vmxnet3_DriverShared *shared; | ||
303 | struct Vmxnet3_PMConf *pm_conf; | ||
304 | struct Vmxnet3_TxQueueDesc *tqd_start; /* first tx queue desc */ | ||
305 | struct Vmxnet3_RxQueueDesc *rqd_start; /* first rx queue desc */ | ||
306 | struct net_device *netdev; | ||
307 | struct pci_dev *pdev; | ||
308 | |||
309 | u8 *hw_addr0; /* for BAR 0 */ | ||
310 | u8 *hw_addr1; /* for BAR 1 */ | ||
311 | |||
312 | /* feature control */ | ||
313 | bool rxcsum; | ||
314 | bool lro; | ||
315 | bool jumbo_frame; | ||
316 | |||
317 | /* rx buffer related */ | ||
318 | unsigned skb_buf_size; | ||
319 | int rx_buf_per_pkt; /* only apply to the 1st ring */ | ||
320 | dma_addr_t shared_pa; | ||
321 | dma_addr_t queue_desc_pa; | ||
322 | |||
323 | /* Wake-on-LAN */ | ||
324 | u32 wol; | ||
325 | |||
326 | /* Link speed */ | ||
327 | u32 link_speed; /* in mbps */ | ||
328 | |||
329 | u64 tx_timeout_count; | ||
330 | struct work_struct work; | ||
331 | |||
332 | unsigned long state; /* VMXNET3_STATE_BIT_xxx */ | ||
333 | |||
334 | int dev_number; | ||
335 | }; | ||
336 | |||
337 | #define VMXNET3_WRITE_BAR0_REG(adapter, reg, val) \ | ||
338 | writel((val), (adapter)->hw_addr0 + (reg)) | ||
339 | #define VMXNET3_READ_BAR0_REG(adapter, reg) \ | ||
340 | readl((adapter)->hw_addr0 + (reg)) | ||
341 | |||
342 | #define VMXNET3_WRITE_BAR1_REG(adapter, reg, val) \ | ||
343 | writel((val), (adapter)->hw_addr1 + (reg)) | ||
344 | #define VMXNET3_READ_BAR1_REG(adapter, reg) \ | ||
345 | readl((adapter)->hw_addr1 + (reg)) | ||
346 | |||
347 | #define VMXNET3_WAKE_QUEUE_THRESHOLD(tq) (5) | ||
348 | #define VMXNET3_RX_ALLOC_THRESHOLD(rq, ring_idx, adapter) \ | ||
349 | ((rq)->rx_ring[ring_idx].size >> 3) | ||
350 | |||
351 | #define VMXNET3_GET_ADDR_LO(dma) ((u32)(dma)) | ||
352 | #define VMXNET3_GET_ADDR_HI(dma) ((u32)(((u64)(dma)) >> 32)) | ||
353 | |||
354 | /* must be a multiple of VMXNET3_RING_SIZE_ALIGN */ | ||
355 | #define VMXNET3_DEF_TX_RING_SIZE 512 | ||
356 | #define VMXNET3_DEF_RX_RING_SIZE 256 | ||
357 | |||
358 | #define VMXNET3_MAX_ETH_HDR_SIZE 22 | ||
359 | #define VMXNET3_MAX_SKB_BUF_SIZE (3*1024) | ||
360 | |||
361 | int | ||
362 | vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter); | ||
363 | |||
364 | int | ||
365 | vmxnet3_activate_dev(struct vmxnet3_adapter *adapter); | ||
366 | |||
367 | void | ||
368 | vmxnet3_force_close(struct vmxnet3_adapter *adapter); | ||
369 | |||
370 | void | ||
371 | vmxnet3_reset_dev(struct vmxnet3_adapter *adapter); | ||
372 | |||
373 | void | ||
374 | vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq, | ||
375 | struct vmxnet3_adapter *adapter); | ||
376 | |||
377 | void | ||
378 | vmxnet3_rq_destroy(struct vmxnet3_rx_queue *rq, | ||
379 | struct vmxnet3_adapter *adapter); | ||
380 | |||
381 | int | ||
382 | vmxnet3_create_queues(struct vmxnet3_adapter *adapter, | ||
383 | u32 tx_ring_size, u32 rx_ring_size, u32 rx_ring2_size); | ||
384 | |||
385 | extern void vmxnet3_set_ethtool_ops(struct net_device *netdev); | ||
386 | extern struct net_device_stats *vmxnet3_get_stats(struct net_device *netdev); | ||
387 | |||
388 | extern char vmxnet3_driver_name[]; | ||
389 | #endif | ||
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index 9693b0fd323d..0bd898c94759 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/capability.h> | ||
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/types.h> | 21 | #include <linux/types.h> |
21 | #include <linux/string.h> | 22 | #include <linux/string.h> |
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 66360a2a14c2..e2c33c06190b 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c | |||
@@ -76,6 +76,7 @@ | |||
76 | 76 | ||
77 | #include <linux/module.h> | 77 | #include <linux/module.h> |
78 | #include <linux/kernel.h> | 78 | #include <linux/kernel.h> |
79 | #include <linux/sched.h> | ||
79 | #include <linux/slab.h> | 80 | #include <linux/slab.h> |
80 | #include <linux/poll.h> | 81 | #include <linux/poll.h> |
81 | #include <linux/fs.h> | 82 | #include <linux/fs.h> |
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c index 2573c18b6aa5..cd8cb95c5bd7 100644 --- a/drivers/net/wan/cycx_x25.c +++ b/drivers/net/wan/cycx_x25.c | |||
@@ -84,6 +84,7 @@ | |||
84 | #include <linux/kernel.h> /* printk(), and other useful stuff */ | 84 | #include <linux/kernel.h> /* printk(), and other useful stuff */ |
85 | #include <linux/module.h> | 85 | #include <linux/module.h> |
86 | #include <linux/string.h> /* inline memset(), etc. */ | 86 | #include <linux/string.h> /* inline memset(), etc. */ |
87 | #include <linux/sched.h> | ||
87 | #include <linux/slab.h> /* kmalloc(), kfree() */ | 88 | #include <linux/slab.h> /* kmalloc(), kfree() */ |
88 | #include <linux/stddef.h> /* offsetof(), etc. */ | 89 | #include <linux/stddef.h> /* offsetof(), etc. */ |
89 | #include <linux/wanrouter.h> /* WAN router definitions */ | 90 | #include <linux/wanrouter.h> /* WAN router definitions */ |
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index 81c8aec9df92..07d00b4cf48a 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c | |||
@@ -81,6 +81,7 @@ | |||
81 | */ | 81 | */ |
82 | 82 | ||
83 | #include <linux/module.h> | 83 | #include <linux/module.h> |
84 | #include <linux/sched.h> | ||
84 | #include <linux/types.h> | 85 | #include <linux/types.h> |
85 | #include <linux/errno.h> | 86 | #include <linux/errno.h> |
86 | #include <linux/list.h> | 87 | #include <linux/list.h> |
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 3e90eb816181..beda387f2fc7 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/version.h> | 20 | #include <linux/version.h> |
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include <linux/sched.h> | ||
22 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
23 | #include <linux/init.h> | 24 | #include <linux/init.h> |
24 | #include <linux/if.h> | 25 | #include <linux/if.h> |
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c index cf5fd17ad707..f1bff98acd1f 100644 --- a/drivers/net/wan/hdlc_cisco.c +++ b/drivers/net/wan/hdlc_cisco.c | |||
@@ -58,8 +58,7 @@ struct cisco_state { | |||
58 | spinlock_t lock; | 58 | spinlock_t lock; |
59 | unsigned long last_poll; | 59 | unsigned long last_poll; |
60 | int up; | 60 | int up; |
61 | int request_sent; | 61 | u32 txseq; /* TX sequence number, 0 = none */ |
62 | u32 txseq; /* TX sequence number */ | ||
63 | u32 rxseq; /* RX sequence number */ | 62 | u32 rxseq; /* RX sequence number */ |
64 | }; | 63 | }; |
65 | 64 | ||
@@ -163,6 +162,7 @@ static int cisco_rx(struct sk_buff *skb) | |||
163 | struct cisco_packet *cisco_data; | 162 | struct cisco_packet *cisco_data; |
164 | struct in_device *in_dev; | 163 | struct in_device *in_dev; |
165 | __be32 addr, mask; | 164 | __be32 addr, mask; |
165 | u32 ack; | ||
166 | 166 | ||
167 | if (skb->len < sizeof(struct hdlc_header)) | 167 | if (skb->len < sizeof(struct hdlc_header)) |
168 | goto rx_error; | 168 | goto rx_error; |
@@ -223,8 +223,10 @@ static int cisco_rx(struct sk_buff *skb) | |||
223 | case CISCO_KEEPALIVE_REQ: | 223 | case CISCO_KEEPALIVE_REQ: |
224 | spin_lock(&st->lock); | 224 | spin_lock(&st->lock); |
225 | st->rxseq = ntohl(cisco_data->par1); | 225 | st->rxseq = ntohl(cisco_data->par1); |
226 | if (st->request_sent && | 226 | ack = ntohl(cisco_data->par2); |
227 | ntohl(cisco_data->par2) == st->txseq) { | 227 | if (ack && (ack == st->txseq || |
228 | /* our current REQ may be in transit */ | ||
229 | ack == st->txseq - 1)) { | ||
228 | st->last_poll = jiffies; | 230 | st->last_poll = jiffies; |
229 | if (!st->up) { | 231 | if (!st->up) { |
230 | u32 sec, min, hrs, days; | 232 | u32 sec, min, hrs, days; |
@@ -275,7 +277,6 @@ static void cisco_timer(unsigned long arg) | |||
275 | 277 | ||
276 | cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ, htonl(++st->txseq), | 278 | cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ, htonl(++st->txseq), |
277 | htonl(st->rxseq)); | 279 | htonl(st->rxseq)); |
278 | st->request_sent = 1; | ||
279 | spin_unlock(&st->lock); | 280 | spin_unlock(&st->lock); |
280 | 281 | ||
281 | st->timer.expires = jiffies + st->settings.interval * HZ; | 282 | st->timer.expires = jiffies + st->settings.interval * HZ; |
@@ -293,9 +294,7 @@ static void cisco_start(struct net_device *dev) | |||
293 | unsigned long flags; | 294 | unsigned long flags; |
294 | 295 | ||
295 | spin_lock_irqsave(&st->lock, flags); | 296 | spin_lock_irqsave(&st->lock, flags); |
296 | st->up = 0; | 297 | st->up = st->txseq = st->rxseq = 0; |
297 | st->request_sent = 0; | ||
298 | st->txseq = st->rxseq = 0; | ||
299 | spin_unlock_irqrestore(&st->lock, flags); | 298 | spin_unlock_irqrestore(&st->lock, flags); |
300 | 299 | ||
301 | init_timer(&st->timer); | 300 | init_timer(&st->timer); |
@@ -317,8 +316,7 @@ static void cisco_stop(struct net_device *dev) | |||
317 | 316 | ||
318 | spin_lock_irqsave(&st->lock, flags); | 317 | spin_lock_irqsave(&st->lock, flags); |
319 | netif_dormant_on(dev); | 318 | netif_dormant_on(dev); |
320 | st->up = 0; | 319 | st->up = st->txseq = 0; |
321 | st->request_sent = 0; | ||
322 | spin_unlock_irqrestore(&st->lock, flags); | 320 | spin_unlock_irqrestore(&st->lock, flags); |
323 | } | 321 | } |
324 | 322 | ||
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index 83da596e2052..58c66819f39b 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/capability.h> | ||
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
22 | #include <linux/types.h> | 23 | #include <linux/types.h> |
23 | #include <linux/fcntl.h> | 24 | #include <linux/fcntl.h> |
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c index a52f29c72c33..f1340faaf022 100644 --- a/drivers/net/wan/pci200syn.c +++ b/drivers/net/wan/pci200syn.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/capability.h> | ||
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/types.h> | 21 | #include <linux/types.h> |
21 | #include <linux/fcntl.h> | 22 | #include <linux/fcntl.h> |
diff --git a/drivers/net/wireless/adm8211.h b/drivers/net/wireless/adm8211.h index 4f6ab1322189..b07e4d3a6b4d 100644 --- a/drivers/net/wireless/adm8211.h +++ b/drivers/net/wireless/adm8211.h | |||
@@ -266,7 +266,7 @@ do { \ | |||
266 | #define ADM8211_SYNCTL_CS1 (1 << 28) | 266 | #define ADM8211_SYNCTL_CS1 (1 << 28) |
267 | #define ADM8211_SYNCTL_CAL (1 << 27) | 267 | #define ADM8211_SYNCTL_CAL (1 << 27) |
268 | #define ADM8211_SYNCTL_SELCAL (1 << 26) | 268 | #define ADM8211_SYNCTL_SELCAL (1 << 26) |
269 | #define ADM8211_SYNCTL_RFtype ((1 << 24) || (1 << 23) || (1 << 22)) | 269 | #define ADM8211_SYNCTL_RFtype ((1 << 24) | (1 << 23) | (1 << 22)) |
270 | #define ADM8211_SYNCTL_RFMD (1 << 22) | 270 | #define ADM8211_SYNCTL_RFMD (1 << 22) |
271 | #define ADM8211_SYNCTL_GENERAL (0x7 << 22) | 271 | #define ADM8211_SYNCTL_GENERAL (0x7 << 22) |
272 | /* SYNCTL 21:0 Data (Si4126: 18-bit data, 4-bit address) */ | 272 | /* SYNCTL 21:0 Data (Si4126: 18-bit data, 4-bit address) */ |
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 7116a1aa20ce..abf896a7390e 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -4790,9 +4790,8 @@ static int proc_stats_rid_open( struct inode *inode, | |||
4790 | static int get_dec_u16( char *buffer, int *start, int limit ) { | 4790 | static int get_dec_u16( char *buffer, int *start, int limit ) { |
4791 | u16 value; | 4791 | u16 value; |
4792 | int valid = 0; | 4792 | int valid = 0; |
4793 | for( value = 0; buffer[*start] >= '0' && | 4793 | for (value = 0; *start < limit && buffer[*start] >= '0' && |
4794 | buffer[*start] <= '9' && | 4794 | buffer[*start] <= '9'; (*start)++) { |
4795 | *start < limit; (*start)++ ) { | ||
4796 | valid = 1; | 4795 | valid = 1; |
4797 | value *= 10; | 4796 | value *= 10; |
4798 | value += buffer[*start] - '0'; | 4797 | value += buffer[*start] - '0'; |
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index fa1549a03c71..660716214d49 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h | |||
@@ -607,82 +607,7 @@ struct b43_qos_params { | |||
607 | struct ieee80211_tx_queue_params p; | 607 | struct ieee80211_tx_queue_params p; |
608 | }; | 608 | }; |
609 | 609 | ||
610 | struct b43_wldev; | 610 | struct b43_wl; |
611 | |||
612 | /* Data structure for the WLAN parts (802.11 cores) of the b43 chip. */ | ||
613 | struct b43_wl { | ||
614 | /* Pointer to the active wireless device on this chip */ | ||
615 | struct b43_wldev *current_dev; | ||
616 | /* Pointer to the ieee80211 hardware data structure */ | ||
617 | struct ieee80211_hw *hw; | ||
618 | |||
619 | /* Global driver mutex. Every operation must run with this mutex locked. */ | ||
620 | struct mutex mutex; | ||
621 | /* Hard-IRQ spinlock. This lock protects things used in the hard-IRQ | ||
622 | * handler, only. This basically is just the IRQ mask register. */ | ||
623 | spinlock_t hardirq_lock; | ||
624 | |||
625 | /* The number of queues that were registered with the mac80211 subsystem | ||
626 | * initially. This is a backup copy of hw->queues in case hw->queues has | ||
627 | * to be dynamically lowered at runtime (Firmware does not support QoS). | ||
628 | * hw->queues has to be restored to the original value before unregistering | ||
629 | * from the mac80211 subsystem. */ | ||
630 | u16 mac80211_initially_registered_queues; | ||
631 | |||
632 | /* We can only have one operating interface (802.11 core) | ||
633 | * at a time. General information about this interface follows. | ||
634 | */ | ||
635 | |||
636 | struct ieee80211_vif *vif; | ||
637 | /* The MAC address of the operating interface. */ | ||
638 | u8 mac_addr[ETH_ALEN]; | ||
639 | /* Current BSSID */ | ||
640 | u8 bssid[ETH_ALEN]; | ||
641 | /* Interface type. (NL80211_IFTYPE_XXX) */ | ||
642 | int if_type; | ||
643 | /* Is the card operating in AP, STA or IBSS mode? */ | ||
644 | bool operating; | ||
645 | /* filter flags */ | ||
646 | unsigned int filter_flags; | ||
647 | /* Stats about the wireless interface */ | ||
648 | struct ieee80211_low_level_stats ieee_stats; | ||
649 | |||
650 | #ifdef CONFIG_B43_HWRNG | ||
651 | struct hwrng rng; | ||
652 | bool rng_initialized; | ||
653 | char rng_name[30 + 1]; | ||
654 | #endif /* CONFIG_B43_HWRNG */ | ||
655 | |||
656 | /* List of all wireless devices on this chip */ | ||
657 | struct list_head devlist; | ||
658 | u8 nr_devs; | ||
659 | |||
660 | bool radiotap_enabled; | ||
661 | bool radio_enabled; | ||
662 | |||
663 | /* The beacon we are currently using (AP or IBSS mode). */ | ||
664 | struct sk_buff *current_beacon; | ||
665 | bool beacon0_uploaded; | ||
666 | bool beacon1_uploaded; | ||
667 | bool beacon_templates_virgin; /* Never wrote the templates? */ | ||
668 | struct work_struct beacon_update_trigger; | ||
669 | |||
670 | /* The current QOS parameters for the 4 queues. */ | ||
671 | struct b43_qos_params qos_params[4]; | ||
672 | |||
673 | /* Work for adjustment of the transmission power. | ||
674 | * This is scheduled when we determine that the actual TX output | ||
675 | * power doesn't match what we want. */ | ||
676 | struct work_struct txpower_adjust_work; | ||
677 | |||
678 | /* Packet transmit work */ | ||
679 | struct work_struct tx_work; | ||
680 | /* Queue of packets to be transmitted. */ | ||
681 | struct sk_buff_head tx_queue; | ||
682 | |||
683 | /* The device LEDs. */ | ||
684 | struct b43_leds leds; | ||
685 | }; | ||
686 | 611 | ||
687 | /* The type of the firmware file. */ | 612 | /* The type of the firmware file. */ |
688 | enum b43_firmware_file_type { | 613 | enum b43_firmware_file_type { |
@@ -824,6 +749,97 @@ struct b43_wldev { | |||
824 | #endif | 749 | #endif |
825 | }; | 750 | }; |
826 | 751 | ||
752 | /* | ||
753 | * Include goes here to avoid a dependency problem. | ||
754 | * A better fix would be to integrate xmit.h into b43.h. | ||
755 | */ | ||
756 | #include "xmit.h" | ||
757 | |||
758 | /* Data structure for the WLAN parts (802.11 cores) of the b43 chip. */ | ||
759 | struct b43_wl { | ||
760 | /* Pointer to the active wireless device on this chip */ | ||
761 | struct b43_wldev *current_dev; | ||
762 | /* Pointer to the ieee80211 hardware data structure */ | ||
763 | struct ieee80211_hw *hw; | ||
764 | |||
765 | /* Global driver mutex. Every operation must run with this mutex locked. */ | ||
766 | struct mutex mutex; | ||
767 | /* Hard-IRQ spinlock. This lock protects things used in the hard-IRQ | ||
768 | * handler, only. This basically is just the IRQ mask register. */ | ||
769 | spinlock_t hardirq_lock; | ||
770 | |||
771 | /* The number of queues that were registered with the mac80211 subsystem | ||
772 | * initially. This is a backup copy of hw->queues in case hw->queues has | ||
773 | * to be dynamically lowered at runtime (Firmware does not support QoS). | ||
774 | * hw->queues has to be restored to the original value before unregistering | ||
775 | * from the mac80211 subsystem. */ | ||
776 | u16 mac80211_initially_registered_queues; | ||
777 | |||
778 | /* We can only have one operating interface (802.11 core) | ||
779 | * at a time. General information about this interface follows. | ||
780 | */ | ||
781 | |||
782 | struct ieee80211_vif *vif; | ||
783 | /* The MAC address of the operating interface. */ | ||
784 | u8 mac_addr[ETH_ALEN]; | ||
785 | /* Current BSSID */ | ||
786 | u8 bssid[ETH_ALEN]; | ||
787 | /* Interface type. (NL80211_IFTYPE_XXX) */ | ||
788 | int if_type; | ||
789 | /* Is the card operating in AP, STA or IBSS mode? */ | ||
790 | bool operating; | ||
791 | /* filter flags */ | ||
792 | unsigned int filter_flags; | ||
793 | /* Stats about the wireless interface */ | ||
794 | struct ieee80211_low_level_stats ieee_stats; | ||
795 | |||
796 | #ifdef CONFIG_B43_HWRNG | ||
797 | struct hwrng rng; | ||
798 | bool rng_initialized; | ||
799 | char rng_name[30 + 1]; | ||
800 | #endif /* CONFIG_B43_HWRNG */ | ||
801 | |||
802 | /* List of all wireless devices on this chip */ | ||
803 | struct list_head devlist; | ||
804 | u8 nr_devs; | ||
805 | |||
806 | bool radiotap_enabled; | ||
807 | bool radio_enabled; | ||
808 | |||
809 | /* The beacon we are currently using (AP or IBSS mode). */ | ||
810 | struct sk_buff *current_beacon; | ||
811 | bool beacon0_uploaded; | ||
812 | bool beacon1_uploaded; | ||
813 | bool beacon_templates_virgin; /* Never wrote the templates? */ | ||
814 | struct work_struct beacon_update_trigger; | ||
815 | |||
816 | /* The current QOS parameters for the 4 queues. */ | ||
817 | struct b43_qos_params qos_params[4]; | ||
818 | |||
819 | /* Work for adjustment of the transmission power. | ||
820 | * This is scheduled when we determine that the actual TX output | ||
821 | * power doesn't match what we want. */ | ||
822 | struct work_struct txpower_adjust_work; | ||
823 | |||
824 | /* Packet transmit work */ | ||
825 | struct work_struct tx_work; | ||
826 | /* Queue of packets to be transmitted. */ | ||
827 | struct sk_buff_head tx_queue; | ||
828 | |||
829 | /* The device LEDs. */ | ||
830 | struct b43_leds leds; | ||
831 | |||
832 | #ifdef CONFIG_B43_PIO | ||
833 | /* | ||
834 | * RX/TX header/tail buffers used by the frame transmit functions. | ||
835 | */ | ||
836 | struct b43_rxhdr_fw4 rxhdr; | ||
837 | struct b43_txhdr txhdr; | ||
838 | u8 rx_tail[4]; | ||
839 | u8 tx_tail[4]; | ||
840 | #endif /* CONFIG_B43_PIO */ | ||
841 | }; | ||
842 | |||
827 | static inline struct b43_wl *hw_to_b43_wl(struct ieee80211_hw *hw) | 843 | static inline struct b43_wl *hw_to_b43_wl(struct ieee80211_hw *hw) |
828 | { | 844 | { |
829 | return hw->priv; | 845 | return hw->priv; |
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c index fbe3d4f62ce2..1e8dba488004 100644 --- a/drivers/net/wireless/b43/leds.c +++ b/drivers/net/wireless/b43/leds.c | |||
@@ -348,9 +348,9 @@ void b43_leds_register(struct b43_wldev *dev) | |||
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | void b43_leds_unregister(struct b43_wldev *dev) | 351 | void b43_leds_unregister(struct b43_wl *wl) |
352 | { | 352 | { |
353 | struct b43_leds *leds = &dev->wl->leds; | 353 | struct b43_leds *leds = &wl->leds; |
354 | 354 | ||
355 | b43_unregister_led(&leds->led_tx); | 355 | b43_unregister_led(&leds->led_tx); |
356 | b43_unregister_led(&leds->led_rx); | 356 | b43_unregister_led(&leds->led_rx); |
diff --git a/drivers/net/wireless/b43/leds.h b/drivers/net/wireless/b43/leds.h index 9592e4c5a5f5..32b66d53cdac 100644 --- a/drivers/net/wireless/b43/leds.h +++ b/drivers/net/wireless/b43/leds.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef B43_LEDS_H_ | 1 | #ifndef B43_LEDS_H_ |
2 | #define B43_LEDS_H_ | 2 | #define B43_LEDS_H_ |
3 | 3 | ||
4 | struct b43_wl; | ||
4 | struct b43_wldev; | 5 | struct b43_wldev; |
5 | 6 | ||
6 | #ifdef CONFIG_B43_LEDS | 7 | #ifdef CONFIG_B43_LEDS |
@@ -60,7 +61,7 @@ enum b43_led_behaviour { | |||
60 | }; | 61 | }; |
61 | 62 | ||
62 | void b43_leds_register(struct b43_wldev *dev); | 63 | void b43_leds_register(struct b43_wldev *dev); |
63 | void b43_leds_unregister(struct b43_wldev *dev); | 64 | void b43_leds_unregister(struct b43_wl *wl); |
64 | void b43_leds_init(struct b43_wldev *dev); | 65 | void b43_leds_init(struct b43_wldev *dev); |
65 | void b43_leds_exit(struct b43_wldev *dev); | 66 | void b43_leds_exit(struct b43_wldev *dev); |
66 | void b43_leds_stop(struct b43_wldev *dev); | 67 | void b43_leds_stop(struct b43_wldev *dev); |
@@ -76,7 +77,7 @@ struct b43_leds { | |||
76 | static inline void b43_leds_register(struct b43_wldev *dev) | 77 | static inline void b43_leds_register(struct b43_wldev *dev) |
77 | { | 78 | { |
78 | } | 79 | } |
79 | static inline void b43_leds_unregister(struct b43_wldev *dev) | 80 | static inline void b43_leds_unregister(struct b43_wl *wl) |
80 | { | 81 | { |
81 | } | 82 | } |
82 | static inline void b43_leds_init(struct b43_wldev *dev) | 83 | static inline void b43_leds_init(struct b43_wldev *dev) |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 9b907a36bb8c..86f35827f008 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -3874,6 +3874,7 @@ static struct b43_wldev * b43_wireless_core_stop(struct b43_wldev *dev) | |||
3874 | { | 3874 | { |
3875 | struct b43_wl *wl = dev->wl; | 3875 | struct b43_wl *wl = dev->wl; |
3876 | struct b43_wldev *orig_dev; | 3876 | struct b43_wldev *orig_dev; |
3877 | u32 mask; | ||
3877 | 3878 | ||
3878 | redo: | 3879 | redo: |
3879 | if (!dev || b43_status(dev) < B43_STAT_STARTED) | 3880 | if (!dev || b43_status(dev) < B43_STAT_STARTED) |
@@ -3920,7 +3921,8 @@ redo: | |||
3920 | goto redo; | 3921 | goto redo; |
3921 | return dev; | 3922 | return dev; |
3922 | } | 3923 | } |
3923 | B43_WARN_ON(b43_read32(dev, B43_MMIO_GEN_IRQ_MASK)); | 3924 | mask = b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); |
3925 | B43_WARN_ON(mask != 0xFFFFFFFF && mask); | ||
3924 | 3926 | ||
3925 | /* Drain the TX queue */ | 3927 | /* Drain the TX queue */ |
3926 | while (skb_queue_len(&wl->tx_queue)) | 3928 | while (skb_queue_len(&wl->tx_queue)) |
@@ -4997,7 +4999,7 @@ static void b43_remove(struct ssb_device *dev) | |||
4997 | 4999 | ||
4998 | if (list_empty(&wl->devlist)) { | 5000 | if (list_empty(&wl->devlist)) { |
4999 | b43_rng_exit(wl); | 5001 | b43_rng_exit(wl); |
5000 | b43_leds_unregister(wldev); | 5002 | b43_leds_unregister(wl); |
5001 | /* Last core on the chip unregistered. | 5003 | /* Last core on the chip unregistered. |
5002 | * We can destroy common struct b43_wl. | 5004 | * We can destroy common struct b43_wl. |
5003 | */ | 5005 | */ |
diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c index 9c1397996e0a..9b9044400218 100644 --- a/drivers/net/wireless/b43/pio.c +++ b/drivers/net/wireless/b43/pio.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "xmit.h" | 30 | #include "xmit.h" |
31 | 31 | ||
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/sched.h> | ||
33 | 34 | ||
34 | 35 | ||
35 | static u16 generate_cookie(struct b43_pio_txqueue *q, | 36 | static u16 generate_cookie(struct b43_pio_txqueue *q, |
@@ -331,6 +332,7 @@ static u16 tx_write_2byte_queue(struct b43_pio_txqueue *q, | |||
331 | unsigned int data_len) | 332 | unsigned int data_len) |
332 | { | 333 | { |
333 | struct b43_wldev *dev = q->dev; | 334 | struct b43_wldev *dev = q->dev; |
335 | struct b43_wl *wl = dev->wl; | ||
334 | const u8 *data = _data; | 336 | const u8 *data = _data; |
335 | 337 | ||
336 | ctl |= B43_PIO_TXCTL_WRITELO | B43_PIO_TXCTL_WRITEHI; | 338 | ctl |= B43_PIO_TXCTL_WRITELO | B43_PIO_TXCTL_WRITEHI; |
@@ -340,13 +342,12 @@ static u16 tx_write_2byte_queue(struct b43_pio_txqueue *q, | |||
340 | q->mmio_base + B43_PIO_TXDATA, | 342 | q->mmio_base + B43_PIO_TXDATA, |
341 | sizeof(u16)); | 343 | sizeof(u16)); |
342 | if (data_len & 1) { | 344 | if (data_len & 1) { |
343 | u8 tail[2] = { 0, }; | ||
344 | |||
345 | /* Write the last byte. */ | 345 | /* Write the last byte. */ |
346 | ctl &= ~B43_PIO_TXCTL_WRITEHI; | 346 | ctl &= ~B43_PIO_TXCTL_WRITEHI; |
347 | b43_piotx_write16(q, B43_PIO_TXCTL, ctl); | 347 | b43_piotx_write16(q, B43_PIO_TXCTL, ctl); |
348 | tail[0] = data[data_len - 1]; | 348 | wl->tx_tail[0] = data[data_len - 1]; |
349 | ssb_block_write(dev->dev, tail, 2, | 349 | wl->tx_tail[1] = 0; |
350 | ssb_block_write(dev->dev, wl->tx_tail, 2, | ||
350 | q->mmio_base + B43_PIO_TXDATA, | 351 | q->mmio_base + B43_PIO_TXDATA, |
351 | sizeof(u16)); | 352 | sizeof(u16)); |
352 | } | 353 | } |
@@ -381,6 +382,7 @@ static u32 tx_write_4byte_queue(struct b43_pio_txqueue *q, | |||
381 | unsigned int data_len) | 382 | unsigned int data_len) |
382 | { | 383 | { |
383 | struct b43_wldev *dev = q->dev; | 384 | struct b43_wldev *dev = q->dev; |
385 | struct b43_wl *wl = dev->wl; | ||
384 | const u8 *data = _data; | 386 | const u8 *data = _data; |
385 | 387 | ||
386 | ctl |= B43_PIO8_TXCTL_0_7 | B43_PIO8_TXCTL_8_15 | | 388 | ctl |= B43_PIO8_TXCTL_0_7 | B43_PIO8_TXCTL_8_15 | |
@@ -391,29 +393,31 @@ static u32 tx_write_4byte_queue(struct b43_pio_txqueue *q, | |||
391 | q->mmio_base + B43_PIO8_TXDATA, | 393 | q->mmio_base + B43_PIO8_TXDATA, |
392 | sizeof(u32)); | 394 | sizeof(u32)); |
393 | if (data_len & 3) { | 395 | if (data_len & 3) { |
394 | u8 tail[4] = { 0, }; | 396 | wl->tx_tail[3] = 0; |
395 | |||
396 | /* Write the last few bytes. */ | 397 | /* Write the last few bytes. */ |
397 | ctl &= ~(B43_PIO8_TXCTL_8_15 | B43_PIO8_TXCTL_16_23 | | 398 | ctl &= ~(B43_PIO8_TXCTL_8_15 | B43_PIO8_TXCTL_16_23 | |
398 | B43_PIO8_TXCTL_24_31); | 399 | B43_PIO8_TXCTL_24_31); |
399 | switch (data_len & 3) { | 400 | switch (data_len & 3) { |
400 | case 3: | 401 | case 3: |
401 | ctl |= B43_PIO8_TXCTL_16_23 | B43_PIO8_TXCTL_8_15; | 402 | ctl |= B43_PIO8_TXCTL_16_23 | B43_PIO8_TXCTL_8_15; |
402 | tail[0] = data[data_len - 3]; | 403 | wl->tx_tail[0] = data[data_len - 3]; |
403 | tail[1] = data[data_len - 2]; | 404 | wl->tx_tail[1] = data[data_len - 2]; |
404 | tail[2] = data[data_len - 1]; | 405 | wl->tx_tail[2] = data[data_len - 1]; |
405 | break; | 406 | break; |
406 | case 2: | 407 | case 2: |
407 | ctl |= B43_PIO8_TXCTL_8_15; | 408 | ctl |= B43_PIO8_TXCTL_8_15; |
408 | tail[0] = data[data_len - 2]; | 409 | wl->tx_tail[0] = data[data_len - 2]; |
409 | tail[1] = data[data_len - 1]; | 410 | wl->tx_tail[1] = data[data_len - 1]; |
411 | wl->tx_tail[2] = 0; | ||
410 | break; | 412 | break; |
411 | case 1: | 413 | case 1: |
412 | tail[0] = data[data_len - 1]; | 414 | wl->tx_tail[0] = data[data_len - 1]; |
415 | wl->tx_tail[1] = 0; | ||
416 | wl->tx_tail[2] = 0; | ||
413 | break; | 417 | break; |
414 | } | 418 | } |
415 | b43_piotx_write32(q, B43_PIO8_TXCTL, ctl); | 419 | b43_piotx_write32(q, B43_PIO8_TXCTL, ctl); |
416 | ssb_block_write(dev->dev, tail, 4, | 420 | ssb_block_write(dev->dev, wl->tx_tail, 4, |
417 | q->mmio_base + B43_PIO8_TXDATA, | 421 | q->mmio_base + B43_PIO8_TXDATA, |
418 | sizeof(u32)); | 422 | sizeof(u32)); |
419 | } | 423 | } |
@@ -445,8 +449,9 @@ static void pio_tx_frame_4byte_queue(struct b43_pio_txpacket *pack, | |||
445 | static int pio_tx_frame(struct b43_pio_txqueue *q, | 449 | static int pio_tx_frame(struct b43_pio_txqueue *q, |
446 | struct sk_buff *skb) | 450 | struct sk_buff *skb) |
447 | { | 451 | { |
452 | struct b43_wldev *dev = q->dev; | ||
453 | struct b43_wl *wl = dev->wl; | ||
448 | struct b43_pio_txpacket *pack; | 454 | struct b43_pio_txpacket *pack; |
449 | struct b43_txhdr txhdr; | ||
450 | u16 cookie; | 455 | u16 cookie; |
451 | int err; | 456 | int err; |
452 | unsigned int hdrlen; | 457 | unsigned int hdrlen; |
@@ -457,8 +462,8 @@ static int pio_tx_frame(struct b43_pio_txqueue *q, | |||
457 | struct b43_pio_txpacket, list); | 462 | struct b43_pio_txpacket, list); |
458 | 463 | ||
459 | cookie = generate_cookie(q, pack); | 464 | cookie = generate_cookie(q, pack); |
460 | hdrlen = b43_txhdr_size(q->dev); | 465 | hdrlen = b43_txhdr_size(dev); |
461 | err = b43_generate_txhdr(q->dev, (u8 *)&txhdr, skb, | 466 | err = b43_generate_txhdr(dev, (u8 *)&wl->txhdr, skb, |
462 | info, cookie); | 467 | info, cookie); |
463 | if (err) | 468 | if (err) |
464 | return err; | 469 | return err; |
@@ -466,15 +471,15 @@ static int pio_tx_frame(struct b43_pio_txqueue *q, | |||
466 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { | 471 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { |
467 | /* Tell the firmware about the cookie of the last | 472 | /* Tell the firmware about the cookie of the last |
468 | * mcast frame, so it can clear the more-data bit in it. */ | 473 | * mcast frame, so it can clear the more-data bit in it. */ |
469 | b43_shm_write16(q->dev, B43_SHM_SHARED, | 474 | b43_shm_write16(dev, B43_SHM_SHARED, |
470 | B43_SHM_SH_MCASTCOOKIE, cookie); | 475 | B43_SHM_SH_MCASTCOOKIE, cookie); |
471 | } | 476 | } |
472 | 477 | ||
473 | pack->skb = skb; | 478 | pack->skb = skb; |
474 | if (q->rev >= 8) | 479 | if (q->rev >= 8) |
475 | pio_tx_frame_4byte_queue(pack, (const u8 *)&txhdr, hdrlen); | 480 | pio_tx_frame_4byte_queue(pack, (const u8 *)&wl->txhdr, hdrlen); |
476 | else | 481 | else |
477 | pio_tx_frame_2byte_queue(pack, (const u8 *)&txhdr, hdrlen); | 482 | pio_tx_frame_2byte_queue(pack, (const u8 *)&wl->txhdr, hdrlen); |
478 | 483 | ||
479 | /* Remove it from the list of available packet slots. | 484 | /* Remove it from the list of available packet slots. |
480 | * It will be put back when we receive the status report. */ | 485 | * It will be put back when we receive the status report. */ |
@@ -614,14 +619,14 @@ void b43_pio_get_tx_stats(struct b43_wldev *dev, | |||
614 | static bool pio_rx_frame(struct b43_pio_rxqueue *q) | 619 | static bool pio_rx_frame(struct b43_pio_rxqueue *q) |
615 | { | 620 | { |
616 | struct b43_wldev *dev = q->dev; | 621 | struct b43_wldev *dev = q->dev; |
617 | struct b43_rxhdr_fw4 rxhdr; | 622 | struct b43_wl *wl = dev->wl; |
618 | u16 len; | 623 | u16 len; |
619 | u32 macstat; | 624 | u32 macstat; |
620 | unsigned int i, padding; | 625 | unsigned int i, padding; |
621 | struct sk_buff *skb; | 626 | struct sk_buff *skb; |
622 | const char *err_msg = NULL; | 627 | const char *err_msg = NULL; |
623 | 628 | ||
624 | memset(&rxhdr, 0, sizeof(rxhdr)); | 629 | memset(&wl->rxhdr, 0, sizeof(wl->rxhdr)); |
625 | 630 | ||
626 | /* Check if we have data and wait for it to get ready. */ | 631 | /* Check if we have data and wait for it to get ready. */ |
627 | if (q->rev >= 8) { | 632 | if (q->rev >= 8) { |
@@ -659,16 +664,16 @@ data_ready: | |||
659 | 664 | ||
660 | /* Get the preamble (RX header) */ | 665 | /* Get the preamble (RX header) */ |
661 | if (q->rev >= 8) { | 666 | if (q->rev >= 8) { |
662 | ssb_block_read(dev->dev, &rxhdr, sizeof(rxhdr), | 667 | ssb_block_read(dev->dev, &wl->rxhdr, sizeof(wl->rxhdr), |
663 | q->mmio_base + B43_PIO8_RXDATA, | 668 | q->mmio_base + B43_PIO8_RXDATA, |
664 | sizeof(u32)); | 669 | sizeof(u32)); |
665 | } else { | 670 | } else { |
666 | ssb_block_read(dev->dev, &rxhdr, sizeof(rxhdr), | 671 | ssb_block_read(dev->dev, &wl->rxhdr, sizeof(wl->rxhdr), |
667 | q->mmio_base + B43_PIO_RXDATA, | 672 | q->mmio_base + B43_PIO_RXDATA, |
668 | sizeof(u16)); | 673 | sizeof(u16)); |
669 | } | 674 | } |
670 | /* Sanity checks. */ | 675 | /* Sanity checks. */ |
671 | len = le16_to_cpu(rxhdr.frame_len); | 676 | len = le16_to_cpu(wl->rxhdr.frame_len); |
672 | if (unlikely(len > 0x700)) { | 677 | if (unlikely(len > 0x700)) { |
673 | err_msg = "len > 0x700"; | 678 | err_msg = "len > 0x700"; |
674 | goto rx_error; | 679 | goto rx_error; |
@@ -678,7 +683,7 @@ data_ready: | |||
678 | goto rx_error; | 683 | goto rx_error; |
679 | } | 684 | } |
680 | 685 | ||
681 | macstat = le32_to_cpu(rxhdr.mac_status); | 686 | macstat = le32_to_cpu(wl->rxhdr.mac_status); |
682 | if (macstat & B43_RX_MAC_FCSERR) { | 687 | if (macstat & B43_RX_MAC_FCSERR) { |
683 | if (!(q->dev->wl->filter_flags & FIF_FCSFAIL)) { | 688 | if (!(q->dev->wl->filter_flags & FIF_FCSFAIL)) { |
684 | /* Drop frames with failed FCS. */ | 689 | /* Drop frames with failed FCS. */ |
@@ -703,24 +708,22 @@ data_ready: | |||
703 | q->mmio_base + B43_PIO8_RXDATA, | 708 | q->mmio_base + B43_PIO8_RXDATA, |
704 | sizeof(u32)); | 709 | sizeof(u32)); |
705 | if (len & 3) { | 710 | if (len & 3) { |
706 | u8 tail[4] = { 0, }; | ||
707 | |||
708 | /* Read the last few bytes. */ | 711 | /* Read the last few bytes. */ |
709 | ssb_block_read(dev->dev, tail, 4, | 712 | ssb_block_read(dev->dev, wl->rx_tail, 4, |
710 | q->mmio_base + B43_PIO8_RXDATA, | 713 | q->mmio_base + B43_PIO8_RXDATA, |
711 | sizeof(u32)); | 714 | sizeof(u32)); |
712 | switch (len & 3) { | 715 | switch (len & 3) { |
713 | case 3: | 716 | case 3: |
714 | skb->data[len + padding - 3] = tail[0]; | 717 | skb->data[len + padding - 3] = wl->rx_tail[0]; |
715 | skb->data[len + padding - 2] = tail[1]; | 718 | skb->data[len + padding - 2] = wl->rx_tail[1]; |
716 | skb->data[len + padding - 1] = tail[2]; | 719 | skb->data[len + padding - 1] = wl->rx_tail[2]; |
717 | break; | 720 | break; |
718 | case 2: | 721 | case 2: |
719 | skb->data[len + padding - 2] = tail[0]; | 722 | skb->data[len + padding - 2] = wl->rx_tail[0]; |
720 | skb->data[len + padding - 1] = tail[1]; | 723 | skb->data[len + padding - 1] = wl->rx_tail[1]; |
721 | break; | 724 | break; |
722 | case 1: | 725 | case 1: |
723 | skb->data[len + padding - 1] = tail[0]; | 726 | skb->data[len + padding - 1] = wl->rx_tail[0]; |
724 | break; | 727 | break; |
725 | } | 728 | } |
726 | } | 729 | } |
@@ -729,17 +732,15 @@ data_ready: | |||
729 | q->mmio_base + B43_PIO_RXDATA, | 732 | q->mmio_base + B43_PIO_RXDATA, |
730 | sizeof(u16)); | 733 | sizeof(u16)); |
731 | if (len & 1) { | 734 | if (len & 1) { |
732 | u8 tail[2] = { 0, }; | ||
733 | |||
734 | /* Read the last byte. */ | 735 | /* Read the last byte. */ |
735 | ssb_block_read(dev->dev, tail, 2, | 736 | ssb_block_read(dev->dev, wl->rx_tail, 2, |
736 | q->mmio_base + B43_PIO_RXDATA, | 737 | q->mmio_base + B43_PIO_RXDATA, |
737 | sizeof(u16)); | 738 | sizeof(u16)); |
738 | skb->data[len + padding - 1] = tail[0]; | 739 | skb->data[len + padding - 1] = wl->rx_tail[0]; |
739 | } | 740 | } |
740 | } | 741 | } |
741 | 742 | ||
742 | b43_rx(q->dev, skb, &rxhdr); | 743 | b43_rx(q->dev, skb, &wl->rxhdr); |
743 | 744 | ||
744 | return 1; | 745 | return 1; |
745 | 746 | ||
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c index 7a3218c5ba7d..ffdce6f3c909 100644 --- a/drivers/net/wireless/b43/rfkill.c +++ b/drivers/net/wireless/b43/rfkill.c | |||
@@ -33,7 +33,8 @@ bool b43_is_hw_radio_enabled(struct b43_wldev *dev) | |||
33 | & B43_MMIO_RADIO_HWENABLED_HI_MASK)) | 33 | & B43_MMIO_RADIO_HWENABLED_HI_MASK)) |
34 | return 1; | 34 | return 1; |
35 | } else { | 35 | } else { |
36 | if (b43_read16(dev, B43_MMIO_RADIO_HWENABLED_LO) | 36 | if (b43_status(dev) >= B43_STAT_STARTED && |
37 | b43_read16(dev, B43_MMIO_RADIO_HWENABLED_LO) | ||
37 | & B43_MMIO_RADIO_HWENABLED_LO_MASK) | 38 | & B43_MMIO_RADIO_HWENABLED_LO_MASK) |
38 | return 1; | 39 | return 1; |
39 | } | 40 | } |
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c index ac9f600995e4..f4e9695ec186 100644 --- a/drivers/net/wireless/b43/xmit.c +++ b/drivers/net/wireless/b43/xmit.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "xmit.h" | 30 | #include "b43.h" |
31 | #include "phy_common.h" | 31 | #include "phy_common.h" |
32 | #include "dma.h" | 32 | #include "dma.h" |
33 | #include "pio.h" | 33 | #include "pio.h" |
@@ -690,7 +690,10 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) | |||
690 | } | 690 | } |
691 | 691 | ||
692 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); | 692 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); |
693 | |||
694 | local_bh_disable(); | ||
693 | ieee80211_rx(dev->wl->hw, skb); | 695 | ieee80211_rx(dev->wl->hw, skb); |
696 | local_bh_enable(); | ||
694 | 697 | ||
695 | #if B43_DEBUG | 698 | #if B43_DEBUG |
696 | dev->rx_count++; | 699 | dev->rx_count++; |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index 1d9223b3d4c4..4b60148a5e61 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/firmware.h> | 37 | #include <linux/firmware.h> |
38 | #include <linux/wireless.h> | 38 | #include <linux/wireless.h> |
39 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> |
40 | #include <linux/sched.h> | ||
40 | #include <linux/skbuff.h> | 41 | #include <linux/skbuff.h> |
41 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
42 | #include <net/dst.h> | 43 | #include <net/dst.h> |
diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c index 11319ec2d64a..aaf227203a98 100644 --- a/drivers/net/wireless/b43legacy/phy.c +++ b/drivers/net/wireless/b43legacy/phy.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/sched.h> | ||
34 | #include <linux/types.h> | 35 | #include <linux/types.h> |
35 | 36 | ||
36 | #include "b43legacy.h" | 37 | #include "b43legacy.h" |
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c index 6fa14a4e4b53..4dfb40a84c96 100644 --- a/drivers/net/wireless/hostap/hostap_info.c +++ b/drivers/net/wireless/hostap/hostap_info.c | |||
@@ -1,6 +1,7 @@ | |||
1 | /* Host AP driver Info Frame processing (part of hostap.o module) */ | 1 | /* Host AP driver Info Frame processing (part of hostap.o module) */ |
2 | 2 | ||
3 | #include <linux/if_arp.h> | 3 | #include <linux/if_arp.h> |
4 | #include <linux/sched.h> | ||
4 | #include "hostap_wlan.h" | 5 | #include "hostap_wlan.h" |
5 | #include "hostap.h" | 6 | #include "hostap.h" |
6 | #include "hostap_ap.h" | 7 | #include "hostap_ap.h" |
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index 3f2bda881a4f..9419cebca8a5 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -1,6 +1,7 @@ | |||
1 | /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */ | 1 | /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */ |
2 | 2 | ||
3 | #include <linux/types.h> | 3 | #include <linux/types.h> |
4 | #include <linux/sched.h> | ||
4 | #include <linux/ethtool.h> | 5 | #include <linux/ethtool.h> |
5 | #include <linux/if_arp.h> | 6 | #include <linux/if_arp.h> |
6 | #include <net/lib80211.h> | 7 | #include <net/lib80211.h> |
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 8d58e6ed4e7d..827824d45de9 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c | |||
@@ -30,6 +30,7 @@ | |||
30 | 30 | ||
31 | ******************************************************************************/ | 31 | ******************************************************************************/ |
32 | 32 | ||
33 | #include <linux/sched.h> | ||
33 | #include "ipw2200.h" | 34 | #include "ipw2200.h" |
34 | 35 | ||
35 | 36 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index a16bd4147eac..cbb0585083a9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -702,7 +702,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, | |||
702 | u8 sta_id = iwl_find_station(priv, hdr->addr1); | 702 | u8 sta_id = iwl_find_station(priv, hdr->addr1); |
703 | 703 | ||
704 | if (sta_id == IWL_INVALID_STATION) { | 704 | if (sta_id == IWL_INVALID_STATION) { |
705 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pm\n", | 705 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", |
706 | hdr->addr1); | 706 | hdr->addr1); |
707 | sta_id = iwl_add_station(priv, hdr->addr1, false, | 707 | sta_id = iwl_add_station(priv, hdr->addr1, false, |
708 | CMD_ASYNC, NULL); | 708 | CMD_ASYNC, NULL); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index e70c5b0af364..f059b49dc691 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
31 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/sched.h> | ||
33 | #include <linux/skbuff.h> | 34 | #include <linux/skbuff.h> |
34 | #include <linux/netdevice.h> | 35 | #include <linux/netdevice.h> |
35 | #include <linux/wireless.h> | 36 | #include <linux/wireless.h> |
@@ -610,7 +611,7 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, | |||
610 | if (rx_status.band == IEEE80211_BAND_5GHZ) | 611 | if (rx_status.band == IEEE80211_BAND_5GHZ) |
611 | rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; | 612 | rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; |
612 | 613 | ||
613 | rx_status.antenna = le16_to_cpu(rx_hdr->phy_flags & | 614 | rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & |
614 | RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; | 615 | RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; |
615 | 616 | ||
616 | /* set the preamble flag if appropriate */ | 617 | /* set the preamble flag if appropriate */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index a22a0501c190..6f703a041847 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
31 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/sched.h> | ||
33 | #include <linux/skbuff.h> | 34 | #include <linux/skbuff.h> |
34 | #include <linux/netdevice.h> | 35 | #include <linux/netdevice.h> |
35 | #include <linux/wireless.h> | 36 | #include <linux/wireless.h> |
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index eb08f4411000..6e6f516ba404 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/sched.h> | ||
32 | #include <linux/skbuff.h> | 33 | #include <linux/skbuff.h> |
33 | #include <linux/netdevice.h> | 34 | #include <linux/netdevice.h> |
34 | #include <linux/wireless.h> | 35 | #include <linux/wireless.h> |
@@ -317,7 +318,7 @@ static void iwl5000_gain_computation(struct iwl_priv *priv, | |||
317 | (s32)average_noise[i])) / 1500; | 318 | (s32)average_noise[i])) / 1500; |
318 | /* bound gain by 2 bits value max, 3rd bit is sign */ | 319 | /* bound gain by 2 bits value max, 3rd bit is sign */ |
319 | data->delta_gain_code[i] = | 320 | data->delta_gain_code[i] = |
320 | min(abs(delta_g), CHAIN_NOISE_MAX_DELTA_GAIN_CODE); | 321 | min(abs(delta_g), (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); |
321 | 322 | ||
322 | if (delta_g < 0) | 323 | if (delta_g < 0) |
323 | /* set negative sign */ | 324 | /* set negative sign */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index cdc07c477457..eaafae091f5b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/dma-mapping.h> | 34 | #include <linux/dma-mapping.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/sched.h> | ||
36 | #include <linux/skbuff.h> | 37 | #include <linux/skbuff.h> |
37 | #include <linux/netdevice.h> | 38 | #include <linux/netdevice.h> |
38 | #include <linux/wireless.h> | 39 | #include <linux/wireless.h> |
@@ -3105,8 +3106,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3105 | out_pci_disable_device: | 3106 | out_pci_disable_device: |
3106 | pci_disable_device(pdev); | 3107 | pci_disable_device(pdev); |
3107 | out_ieee80211_free_hw: | 3108 | out_ieee80211_free_hw: |
3108 | ieee80211_free_hw(priv->hw); | ||
3109 | iwl_free_traffic_mem(priv); | 3109 | iwl_free_traffic_mem(priv); |
3110 | ieee80211_free_hw(priv->hw); | ||
3110 | out: | 3111 | out: |
3111 | return err; | 3112 | return err; |
3112 | } | 3113 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 2c5c88fc38f5..4afaf773aeac 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h | |||
@@ -1154,7 +1154,7 @@ struct iwl_wep_cmd { | |||
1154 | #define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1) | 1154 | #define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1) |
1155 | #define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2) | 1155 | #define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2) |
1156 | #define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3) | 1156 | #define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3) |
1157 | #define RX_RES_PHY_FLAGS_ANTENNA_MSK cpu_to_le16(0xf0) | 1157 | #define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0 |
1158 | #define RX_RES_PHY_FLAGS_ANTENNA_POS 4 | 1158 | #define RX_RES_PHY_FLAGS_ANTENNA_POS 4 |
1159 | 1159 | ||
1160 | #define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) | 1160 | #define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 484d5c1a7312..2dc928755454 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/etherdevice.h> | 31 | #include <linux/etherdevice.h> |
32 | #include <linux/sched.h> | ||
32 | #include <net/mac80211.h> | 33 | #include <net/mac80211.h> |
33 | 34 | ||
34 | #include "iwl-eeprom.h" | 35 | #include "iwl-eeprom.h" |
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index 3d2b93a61e62..e14c9952a935 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c | |||
@@ -410,7 +410,6 @@ static int iwl_find_otp_image(struct iwl_priv *priv, | |||
410 | u16 *validblockaddr) | 410 | u16 *validblockaddr) |
411 | { | 411 | { |
412 | u16 next_link_addr = 0, link_value = 0, valid_addr; | 412 | u16 next_link_addr = 0, link_value = 0, valid_addr; |
413 | int ret = 0; | ||
414 | int usedblocks = 0; | 413 | int usedblocks = 0; |
415 | 414 | ||
416 | /* set addressing mode to absolute to traverse the link list */ | 415 | /* set addressing mode to absolute to traverse the link list */ |
@@ -430,29 +429,29 @@ static int iwl_find_otp_image(struct iwl_priv *priv, | |||
430 | * check for more block on the link list | 429 | * check for more block on the link list |
431 | */ | 430 | */ |
432 | valid_addr = next_link_addr; | 431 | valid_addr = next_link_addr; |
433 | next_link_addr = link_value; | 432 | next_link_addr = link_value * sizeof(u16); |
434 | IWL_DEBUG_INFO(priv, "OTP blocks %d addr 0x%x\n", | 433 | IWL_DEBUG_INFO(priv, "OTP blocks %d addr 0x%x\n", |
435 | usedblocks, next_link_addr); | 434 | usedblocks, next_link_addr); |
436 | if (iwl_read_otp_word(priv, next_link_addr, &link_value)) | 435 | if (iwl_read_otp_word(priv, next_link_addr, &link_value)) |
437 | return -EINVAL; | 436 | return -EINVAL; |
438 | if (!link_value) { | 437 | if (!link_value) { |
439 | /* | 438 | /* |
440 | * reach the end of link list, | 439 | * reach the end of link list, return success and |
441 | * set address point to the starting address | 440 | * set address point to the starting address |
442 | * of the image | 441 | * of the image |
443 | */ | 442 | */ |
444 | goto done; | 443 | *validblockaddr = valid_addr; |
444 | /* skip first 2 bytes (link list pointer) */ | ||
445 | *validblockaddr += 2; | ||
446 | return 0; | ||
445 | } | 447 | } |
446 | /* more in the link list, continue */ | 448 | /* more in the link list, continue */ |
447 | usedblocks++; | 449 | usedblocks++; |
448 | } while (usedblocks < priv->cfg->max_ll_items); | 450 | } while (usedblocks <= priv->cfg->max_ll_items); |
449 | /* OTP full, use last block */ | 451 | |
450 | IWL_DEBUG_INFO(priv, "OTP is full, use last block\n"); | 452 | /* OTP has no valid blocks */ |
451 | done: | 453 | IWL_DEBUG_INFO(priv, "OTP has no valid blocks\n"); |
452 | *validblockaddr = valid_addr; | 454 | return -EINVAL; |
453 | /* skip first 2 bytes (link list pointer) */ | ||
454 | *validblockaddr += 2; | ||
455 | return ret; | ||
456 | } | 455 | } |
457 | 456 | ||
458 | /** | 457 | /** |
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index 6b68db7b1b81..80b9e45d9b9c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h | |||
@@ -220,35 +220,35 @@ struct iwl_eeprom_enhanced_txpwr { | |||
220 | * Section 10: 2.4 GHz 40MHz channels: 132, 44 (_above_) | 220 | * Section 10: 2.4 GHz 40MHz channels: 132, 44 (_above_) |
221 | */ | 221 | */ |
222 | /* 2.4 GHz band: CCK */ | 222 | /* 2.4 GHz band: CCK */ |
223 | #define EEPROM_LB_CCK_20_COMMON ((0xAA)\ | 223 | #define EEPROM_LB_CCK_20_COMMON ((0xA8)\ |
224 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 8 bytes */ | 224 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 8 bytes */ |
225 | /* 2.4 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */ | 225 | /* 2.4 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */ |
226 | #define EEPROM_LB_OFDM_COMMON ((0xB2)\ | 226 | #define EEPROM_LB_OFDM_COMMON ((0xB0)\ |
227 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */ | 227 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */ |
228 | /* 5.2 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */ | 228 | /* 5.2 GHz band: 20MHz-Legacy, 20MHz-HT, 40MHz-HT */ |
229 | #define EEPROM_HB_OFDM_COMMON ((0xCA)\ | 229 | #define EEPROM_HB_OFDM_COMMON ((0xC8)\ |
230 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */ | 230 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */ |
231 | /* 2.4GHz band channels: | 231 | /* 2.4GHz band channels: |
232 | * 1Legacy, 1HT, 2Legacy, 2HT, 10Legacy, 10HT, 11Legacy, 11HT */ | 232 | * 1Legacy, 1HT, 2Legacy, 2HT, 10Legacy, 10HT, 11Legacy, 11HT */ |
233 | #define EEPROM_LB_OFDM_20_BAND ((0xE2)\ | 233 | #define EEPROM_LB_OFDM_20_BAND ((0xE0)\ |
234 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 64 bytes */ | 234 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 64 bytes */ |
235 | /* 2.4 GHz band HT40 channels: (1,+1) (2,+1) (6,+1) (7,+1) (9,+1) */ | 235 | /* 2.4 GHz band HT40 channels: (1,+1) (2,+1) (6,+1) (7,+1) (9,+1) */ |
236 | #define EEPROM_LB_OFDM_HT40_BAND ((0x122)\ | 236 | #define EEPROM_LB_OFDM_HT40_BAND ((0x120)\ |
237 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 40 bytes */ | 237 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 40 bytes */ |
238 | /* 5.2GHz band channels: 36Legacy, 36HT, 64Legacy, 64HT, 100Legacy, 100HT */ | 238 | /* 5.2GHz band channels: 36Legacy, 36HT, 64Legacy, 64HT, 100Legacy, 100HT */ |
239 | #define EEPROM_HB_OFDM_20_BAND ((0x14A)\ | 239 | #define EEPROM_HB_OFDM_20_BAND ((0x148)\ |
240 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 48 bytes */ | 240 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 48 bytes */ |
241 | /* 5.2 GHz band HT40 channels: (36,+1) (60,+1) (100,+1) */ | 241 | /* 5.2 GHz band HT40 channels: (36,+1) (60,+1) (100,+1) */ |
242 | #define EEPROM_HB_OFDM_HT40_BAND ((0x17A)\ | 242 | #define EEPROM_HB_OFDM_HT40_BAND ((0x178)\ |
243 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */ | 243 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 24 bytes */ |
244 | /* 2.4 GHz band, channnel 13: Legacy, HT */ | 244 | /* 2.4 GHz band, channnel 13: Legacy, HT */ |
245 | #define EEPROM_LB_OFDM_20_CHANNEL_13 ((0x192)\ | 245 | #define EEPROM_LB_OFDM_20_CHANNEL_13 ((0x190)\ |
246 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */ | 246 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */ |
247 | /* 5.2 GHz band, channnel 140: Legacy, HT */ | 247 | /* 5.2 GHz band, channnel 140: Legacy, HT */ |
248 | #define EEPROM_HB_OFDM_20_CHANNEL_140 ((0x1A2)\ | 248 | #define EEPROM_HB_OFDM_20_CHANNEL_140 ((0x1A0)\ |
249 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */ | 249 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */ |
250 | /* 5.2 GHz band, HT40 channnels (132,+1) (44,+1) */ | 250 | /* 5.2 GHz band, HT40 channnels (132,+1) (44,+1) */ |
251 | #define EEPROM_HB_OFDM_HT40_BAND_1 ((0x1B2)\ | 251 | #define EEPROM_HB_OFDM_HT40_BAND_1 ((0x1B0)\ |
252 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */ | 252 | | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 16 bytes */ |
253 | 253 | ||
254 | 254 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c index 532c8d6cd8da..a6856daf14cb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c +++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/sched.h> | ||
31 | #include <net/mac80211.h> | 32 | #include <net/mac80211.h> |
32 | 33 | ||
33 | #include "iwl-dev.h" /* FIXME: remove */ | 34 | #include "iwl-dev.h" /* FIXME: remove */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c index 8e1bb53c0aa3..493626bcd3ec 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c | |||
@@ -1044,7 +1044,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv, | |||
1044 | * as a bitmask. | 1044 | * as a bitmask. |
1045 | */ | 1045 | */ |
1046 | rx_status.antenna = | 1046 | rx_status.antenna = |
1047 | le16_to_cpu(phy_res->phy_flags & RX_RES_PHY_FLAGS_ANTENNA_MSK) | 1047 | (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) |
1048 | >> RX_RES_PHY_FLAGS_ANTENNA_POS; | 1048 | >> RX_RES_PHY_FLAGS_ANTENNA_POS; |
1049 | 1049 | ||
1050 | /* set the preamble flag if appropriate */ | 1050 | /* set the preamble flag if appropriate */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index c18907544701..fb9bcfa6d947 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -28,6 +28,7 @@ | |||
28 | *****************************************************************************/ | 28 | *****************************************************************************/ |
29 | 29 | ||
30 | #include <linux/etherdevice.h> | 30 | #include <linux/etherdevice.h> |
31 | #include <linux/sched.h> | ||
31 | #include <net/mac80211.h> | 32 | #include <net/mac80211.h> |
32 | #include "iwl-eeprom.h" | 33 | #include "iwl-eeprom.h" |
33 | #include "iwl-dev.h" | 34 | #include "iwl-dev.h" |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index c390dbd877e4..d00a80334095 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/dma-mapping.h> | 34 | #include <linux/dma-mapping.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/sched.h> | ||
36 | #include <linux/skbuff.h> | 37 | #include <linux/skbuff.h> |
37 | #include <linux/netdevice.h> | 38 | #include <linux/netdevice.h> |
38 | #include <linux/wireless.h> | 39 | #include <linux/wireless.h> |
@@ -4096,8 +4097,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
4096 | pci_set_drvdata(pdev, NULL); | 4097 | pci_set_drvdata(pdev, NULL); |
4097 | pci_disable_device(pdev); | 4098 | pci_disable_device(pdev); |
4098 | out_ieee80211_free_hw: | 4099 | out_ieee80211_free_hw: |
4099 | ieee80211_free_hw(priv->hw); | ||
4100 | iwl_free_traffic_mem(priv); | 4100 | iwl_free_traffic_mem(priv); |
4101 | ieee80211_free_hw(priv->hw); | ||
4101 | out: | 4102 | out: |
4102 | return err; | 4103 | return err; |
4103 | } | 4104 | } |
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c index a56a2b0ac99a..f3c55658225b 100644 --- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c +++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
26 | #include <linux/sched.h> | ||
26 | #include <linux/etherdevice.h> | 27 | #include <linux/etherdevice.h> |
27 | #include <linux/wireless.h> | 28 | #include <linux/wireless.h> |
28 | #include <linux/ieee80211.h> | 29 | #include <linux/ieee80211.h> |
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.c b/drivers/net/wireless/iwmc3200wifi/commands.c index 23b52fa2605f..84158b6d35d8 100644 --- a/drivers/net/wireless/iwmc3200wifi/commands.c +++ b/drivers/net/wireless/iwmc3200wifi/commands.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/wireless.h> | 40 | #include <linux/wireless.h> |
41 | #include <linux/etherdevice.h> | 41 | #include <linux/etherdevice.h> |
42 | #include <linux/ieee80211.h> | 42 | #include <linux/ieee80211.h> |
43 | #include <linux/sched.h> | ||
43 | 44 | ||
44 | #include "iwm.h" | 45 | #include "iwm.h" |
45 | #include "bus.h" | 46 | #include "bus.h" |
diff --git a/drivers/net/wireless/iwmc3200wifi/main.c b/drivers/net/wireless/iwmc3200wifi/main.c index d668e4756324..222eb2cf1b30 100644 --- a/drivers/net/wireless/iwmc3200wifi/main.c +++ b/drivers/net/wireless/iwmc3200wifi/main.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/netdevice.h> | 40 | #include <linux/netdevice.h> |
41 | #include <linux/sched.h> | ||
41 | #include <linux/ieee80211.h> | 42 | #include <linux/ieee80211.h> |
42 | #include <linux/wireless.h> | 43 | #include <linux/wireless.h> |
43 | 44 | ||
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c index 40dbcbc16593..771a301003c9 100644 --- a/drivers/net/wireless/iwmc3200wifi/rx.c +++ b/drivers/net/wireless/iwmc3200wifi/rx.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/netdevice.h> | 40 | #include <linux/netdevice.h> |
41 | #include <linux/sched.h> | ||
41 | #include <linux/etherdevice.h> | 42 | #include <linux/etherdevice.h> |
42 | #include <linux/wireless.h> | 43 | #include <linux/wireless.h> |
43 | #include <linux/ieee80211.h> | 44 | #include <linux/ieee80211.h> |
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 685098148e10..0a324dcd264c 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <net/iw_handler.h> | 6 | #include <net/iw_handler.h> |
7 | #include <net/lib80211.h> | 7 | #include <net/lib80211.h> |
8 | #include <linux/kfifo.h> | 8 | #include <linux/kfifo.h> |
9 | #include <linux/sched.h> | ||
9 | #include "host.h" | 10 | #include "host.h" |
10 | #include "hostcmd.h" | 11 | #include "hostcmd.h" |
11 | #include "decl.h" | 12 | #include "decl.h" |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index c42d3faa2660..23f684337fdd 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * responses as well as events generated by firmware. | 3 | * responses as well as events generated by firmware. |
4 | */ | 4 | */ |
5 | #include <linux/delay.h> | 5 | #include <linux/delay.h> |
6 | #include <linux/sched.h> | ||
6 | #include <linux/if_arp.h> | 7 | #include <linux/if_arp.h> |
7 | #include <linux/netdevice.h> | 8 | #include <linux/netdevice.h> |
8 | #include <asm/unaligned.h> | 9 | #include <asm/unaligned.h> |
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c index cb8be8d7abc1..5b3672c4d0cc 100644 --- a/drivers/net/wireless/libertas/if_spi.c +++ b/drivers/net/wireless/libertas/if_spi.c | |||
@@ -134,7 +134,7 @@ static void spu_transaction_finish(struct if_spi_card *card) | |||
134 | static int spu_write(struct if_spi_card *card, u16 reg, const u8 *buf, int len) | 134 | static int spu_write(struct if_spi_card *card, u16 reg, const u8 *buf, int len) |
135 | { | 135 | { |
136 | int err = 0; | 136 | int err = 0; |
137 | u16 reg_out = cpu_to_le16(reg | IF_SPI_WRITE_OPERATION_MASK); | 137 | __le16 reg_out = cpu_to_le16(reg | IF_SPI_WRITE_OPERATION_MASK); |
138 | struct spi_message m; | 138 | struct spi_message m; |
139 | struct spi_transfer reg_trans; | 139 | struct spi_transfer reg_trans; |
140 | struct spi_transfer data_trans; | 140 | struct spi_transfer data_trans; |
@@ -166,7 +166,7 @@ static int spu_write(struct if_spi_card *card, u16 reg, const u8 *buf, int len) | |||
166 | 166 | ||
167 | static inline int spu_write_u16(struct if_spi_card *card, u16 reg, u16 val) | 167 | static inline int spu_write_u16(struct if_spi_card *card, u16 reg, u16 val) |
168 | { | 168 | { |
169 | u16 buff; | 169 | __le16 buff; |
170 | 170 | ||
171 | buff = cpu_to_le16(val); | 171 | buff = cpu_to_le16(val); |
172 | return spu_write(card, reg, (u8 *)&buff, sizeof(u16)); | 172 | return spu_write(card, reg, (u8 *)&buff, sizeof(u16)); |
@@ -188,7 +188,7 @@ static int spu_read(struct if_spi_card *card, u16 reg, u8 *buf, int len) | |||
188 | { | 188 | { |
189 | unsigned int delay; | 189 | unsigned int delay; |
190 | int err = 0; | 190 | int err = 0; |
191 | u16 reg_out = cpu_to_le16(reg | IF_SPI_READ_OPERATION_MASK); | 191 | __le16 reg_out = cpu_to_le16(reg | IF_SPI_READ_OPERATION_MASK); |
192 | struct spi_message m; | 192 | struct spi_message m; |
193 | struct spi_transfer reg_trans; | 193 | struct spi_transfer reg_trans; |
194 | struct spi_transfer dummy_trans; | 194 | struct spi_transfer dummy_trans; |
@@ -235,7 +235,7 @@ static int spu_read(struct if_spi_card *card, u16 reg, u8 *buf, int len) | |||
235 | /* Read 16 bits from an SPI register */ | 235 | /* Read 16 bits from an SPI register */ |
236 | static inline int spu_read_u16(struct if_spi_card *card, u16 reg, u16 *val) | 236 | static inline int spu_read_u16(struct if_spi_card *card, u16 reg, u16 *val) |
237 | { | 237 | { |
238 | u16 buf; | 238 | __le16 buf; |
239 | int ret; | 239 | int ret; |
240 | 240 | ||
241 | ret = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); | 241 | ret = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); |
@@ -248,7 +248,7 @@ static inline int spu_read_u16(struct if_spi_card *card, u16 reg, u16 *val) | |||
248 | * The low 16 bits are read first. */ | 248 | * The low 16 bits are read first. */ |
249 | static int spu_read_u32(struct if_spi_card *card, u16 reg, u32 *val) | 249 | static int spu_read_u32(struct if_spi_card *card, u16 reg, u32 *val) |
250 | { | 250 | { |
251 | u32 buf; | 251 | __le32 buf; |
252 | int err; | 252 | int err; |
253 | 253 | ||
254 | err = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); | 254 | err = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); |
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c index 4c018f7a0a8d..8c3766a6e8e7 100644 --- a/drivers/net/wireless/libertas/tx.c +++ b/drivers/net/wireless/libertas/tx.c | |||
@@ -3,6 +3,7 @@ | |||
3 | */ | 3 | */ |
4 | #include <linux/netdevice.h> | 4 | #include <linux/netdevice.h> |
5 | #include <linux/etherdevice.h> | 5 | #include <linux/etherdevice.h> |
6 | #include <linux/sched.h> | ||
6 | 7 | ||
7 | #include "hostcmd.h" | 8 | #include "hostcmd.h" |
8 | #include "radiotap.h" | 9 | #include "radiotap.h" |
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index 4c97c6ad6f5d..bc08464d8323 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/capability.h> | ||
22 | #include <linux/module.h> | 23 | #include <linux/module.h> |
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
24 | #include <linux/if_arp.h> | 25 | #include <linux/if_arp.h> |
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c index e26d7b3ceab5..2505be56ae39 100644 --- a/drivers/net/wireless/prism54/islpci_dev.c +++ b/drivers/net/wireless/prism54/islpci_dev.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/netdevice.h> | 23 | #include <linux/netdevice.h> |
24 | #include <linux/ethtool.h> | 24 | #include <linux/ethtool.h> |
25 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
26 | #include <linux/sched.h> | ||
26 | #include <linux/etherdevice.h> | 27 | #include <linux/etherdevice.h> |
27 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
28 | #include <linux/if_arp.h> | 29 | #include <linux/if_arp.h> |
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c index f7c677e2094d..69d2f882fd06 100644 --- a/drivers/net/wireless/prism54/islpci_mgt.c +++ b/drivers/net/wireless/prism54/islpci_mgt.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/netdevice.h> | 20 | #include <linux/netdevice.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/pci.h> | 22 | #include <linux/pci.h> |
23 | #include <linux/sched.h> | ||
23 | 24 | ||
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
25 | #include <asm/system.h> | 26 | #include <asm/system.h> |
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 88cd58eb3b9f..1c88c2ea59aa 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -2879,7 +2879,7 @@ static int write_essid(struct file *file, const char __user *buffer, | |||
2879 | unsigned long count, void *data) | 2879 | unsigned long count, void *data) |
2880 | { | 2880 | { |
2881 | static char proc_essid[33]; | 2881 | static char proc_essid[33]; |
2882 | int len = count; | 2882 | unsigned int len = count; |
2883 | 2883 | ||
2884 | if (len > 32) | 2884 | if (len > 32) |
2885 | len = 32; | 2885 | len = 32; |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index a084077a1c61..9fe770f7d7bb 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -1994,7 +1994,7 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1994 | rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->ba_size); | 1994 | rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->ba_size); |
1995 | rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID, | 1995 | rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID, |
1996 | test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ? | 1996 | test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ? |
1997 | (skbdesc->entry->entry_idx + 1) : 0xff); | 1997 | txdesc->key_idx : 0xff); |
1998 | rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, | 1998 | rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, |
1999 | skb->len - txdesc->l2pad); | 1999 | skb->len - txdesc->l2pad); |
2000 | rt2x00_set_field32(&word, TXWI_W1_PACKETID, | 2000 | rt2x00_set_field32(&word, TXWI_W1_PACKETID, |
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c index 7b3ee8c2eaef..68bc9bb1dbf9 100644 --- a/drivers/net/wireless/rt2x00/rt2x00debug.c +++ b/drivers/net/wireless/rt2x00/rt2x00debug.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/poll.h> | 29 | #include <linux/poll.h> |
30 | #include <linux/sched.h> | ||
30 | #include <linux/uaccess.h> | 31 | #include <linux/uaccess.h> |
31 | 32 | ||
32 | #include "rt2x00.h" | 33 | #include "rt2x00.h" |
diff --git a/drivers/net/znet.c b/drivers/net/znet.c index a0384b6f09b6..b42347333750 100644 --- a/drivers/net/znet.c +++ b/drivers/net/znet.c | |||
@@ -169,7 +169,6 @@ static void znet_tx_timeout (struct net_device *dev); | |||
169 | static int znet_request_resources (struct net_device *dev) | 169 | static int znet_request_resources (struct net_device *dev) |
170 | { | 170 | { |
171 | struct znet_private *znet = netdev_priv(dev); | 171 | struct znet_private *znet = netdev_priv(dev); |
172 | unsigned long flags; | ||
173 | 172 | ||
174 | if (request_irq (dev->irq, &znet_interrupt, 0, "ZNet", dev)) | 173 | if (request_irq (dev->irq, &znet_interrupt, 0, "ZNet", dev)) |
175 | goto failed; | 174 | goto failed; |
@@ -187,13 +186,9 @@ static int znet_request_resources (struct net_device *dev) | |||
187 | free_sia: | 186 | free_sia: |
188 | release_region (znet->sia_base, znet->sia_size); | 187 | release_region (znet->sia_base, znet->sia_size); |
189 | free_tx_dma: | 188 | free_tx_dma: |
190 | flags = claim_dma_lock(); | ||
191 | free_dma (znet->tx_dma); | 189 | free_dma (znet->tx_dma); |
192 | release_dma_lock (flags); | ||
193 | free_rx_dma: | 190 | free_rx_dma: |
194 | flags = claim_dma_lock(); | ||
195 | free_dma (znet->rx_dma); | 191 | free_dma (znet->rx_dma); |
196 | release_dma_lock (flags); | ||
197 | free_irq: | 192 | free_irq: |
198 | free_irq (dev->irq, dev); | 193 | free_irq (dev->irq, dev); |
199 | failed: | 194 | failed: |
@@ -203,14 +198,11 @@ static int znet_request_resources (struct net_device *dev) | |||
203 | static void znet_release_resources (struct net_device *dev) | 198 | static void znet_release_resources (struct net_device *dev) |
204 | { | 199 | { |
205 | struct znet_private *znet = netdev_priv(dev); | 200 | struct znet_private *znet = netdev_priv(dev); |
206 | unsigned long flags; | ||
207 | 201 | ||
208 | release_region (znet->sia_base, znet->sia_size); | 202 | release_region (znet->sia_base, znet->sia_size); |
209 | release_region (dev->base_addr, znet->io_size); | 203 | release_region (dev->base_addr, znet->io_size); |
210 | flags = claim_dma_lock(); | ||
211 | free_dma (znet->tx_dma); | 204 | free_dma (znet->tx_dma); |
212 | free_dma (znet->rx_dma); | 205 | free_dma (znet->rx_dma); |
213 | release_dma_lock (flags); | ||
214 | free_irq (dev->irq, dev); | 206 | free_irq (dev->irq, dev); |
215 | } | 207 | } |
216 | 208 | ||