diff options
Diffstat (limited to 'drivers')
284 files changed, 8767 insertions, 6294 deletions
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 106beb194f3c..1622772f802d 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <net/bluetooth/bluetooth.h> | 30 | #include <net/bluetooth/bluetooth.h> |
31 | 31 | ||
32 | #define VERSION "1.0" | 32 | #define VERSION "1.0" |
33 | #define ATH3K_FIRMWARE "ath3k-1.fw" | ||
33 | 34 | ||
34 | #define ATH3K_DNLOAD 0x01 | 35 | #define ATH3K_DNLOAD 0x01 |
35 | #define ATH3K_GETSTATE 0x05 | 36 | #define ATH3K_GETSTATE 0x05 |
@@ -400,9 +401,15 @@ static int ath3k_probe(struct usb_interface *intf, | |||
400 | return 0; | 401 | return 0; |
401 | } | 402 | } |
402 | 403 | ||
403 | if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) { | 404 | ret = request_firmware(&firmware, ATH3K_FIRMWARE, &udev->dev); |
404 | BT_ERR("Error loading firmware"); | 405 | if (ret < 0) { |
405 | return -EIO; | 406 | if (ret == -ENOENT) |
407 | BT_ERR("Firmware file \"%s\" not found", | ||
408 | ATH3K_FIRMWARE); | ||
409 | else | ||
410 | BT_ERR("Firmware file \"%s\" request failed (err=%d)", | ||
411 | ATH3K_FIRMWARE, ret); | ||
412 | return ret; | ||
406 | } | 413 | } |
407 | 414 | ||
408 | ret = ath3k_load_firmware(udev, firmware); | 415 | ret = ath3k_load_firmware(udev, firmware); |
@@ -441,4 +448,4 @@ MODULE_AUTHOR("Atheros Communications"); | |||
441 | MODULE_DESCRIPTION("Atheros AR30xx firmware driver"); | 448 | MODULE_DESCRIPTION("Atheros AR30xx firmware driver"); |
442 | MODULE_VERSION(VERSION); | 449 | MODULE_VERSION(VERSION); |
443 | MODULE_LICENSE("GPL"); | 450 | MODULE_LICENSE("GPL"); |
444 | MODULE_FIRMWARE("ath3k-1.fw"); | 451 | MODULE_FIRMWARE(ATH3K_FIRMWARE); |
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 61b591470a90..a936763b8c3d 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c | |||
@@ -751,9 +751,7 @@ static void bfusb_disconnect(struct usb_interface *intf) | |||
751 | 751 | ||
752 | bfusb_close(hdev); | 752 | bfusb_close(hdev); |
753 | 753 | ||
754 | if (hci_unregister_dev(hdev) < 0) | 754 | hci_unregister_dev(hdev); |
755 | BT_ERR("Can't unregister HCI device %s", hdev->name); | ||
756 | |||
757 | hci_free_dev(hdev); | 755 | hci_free_dev(hdev); |
758 | } | 756 | } |
759 | 757 | ||
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index aed1904ea67b..c6a0c6103743 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c | |||
@@ -844,9 +844,7 @@ static int bluecard_close(bluecard_info_t *info) | |||
844 | /* Turn FPGA off */ | 844 | /* Turn FPGA off */ |
845 | outb(0x80, iobase + 0x30); | 845 | outb(0x80, iobase + 0x30); |
846 | 846 | ||
847 | if (hci_unregister_dev(hdev) < 0) | 847 | hci_unregister_dev(hdev); |
848 | BT_ERR("Can't unregister HCI device %s", hdev->name); | ||
849 | |||
850 | hci_free_dev(hdev); | 848 | hci_free_dev(hdev); |
851 | 849 | ||
852 | return 0; | 850 | return 0; |
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 4fc01949d399..0c97e5d514b6 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -636,9 +636,7 @@ static int bt3c_close(bt3c_info_t *info) | |||
636 | 636 | ||
637 | bt3c_hci_close(hdev); | 637 | bt3c_hci_close(hdev); |
638 | 638 | ||
639 | if (hci_unregister_dev(hdev) < 0) | 639 | hci_unregister_dev(hdev); |
640 | BT_ERR("Can't unregister HCI device %s", hdev->name); | ||
641 | |||
642 | hci_free_dev(hdev); | 640 | hci_free_dev(hdev); |
643 | 641 | ||
644 | return 0; | 642 | return 0; |
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 526b61807d94..200b3a2877d6 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -565,9 +565,7 @@ static int btuart_close(btuart_info_t *info) | |||
565 | 565 | ||
566 | spin_unlock_irqrestore(&(info->lock), flags); | 566 | spin_unlock_irqrestore(&(info->lock), flags); |
567 | 567 | ||
568 | if (hci_unregister_dev(hdev) < 0) | 568 | hci_unregister_dev(hdev); |
569 | BT_ERR("Can't unregister HCI device %s", hdev->name); | ||
570 | |||
571 | hci_free_dev(hdev); | 569 | hci_free_dev(hdev); |
572 | 570 | ||
573 | return 0; | 571 | return 0; |
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index fe4ebc375b3d..2bd87d45f1c2 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -315,7 +315,8 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) | |||
315 | 315 | ||
316 | err = usb_submit_urb(urb, mem_flags); | 316 | err = usb_submit_urb(urb, mem_flags); |
317 | if (err < 0) { | 317 | if (err < 0) { |
318 | BT_ERR("%s urb %p submission failed (%d)", | 318 | if (err != -EPERM && err != -ENODEV) |
319 | BT_ERR("%s urb %p submission failed (%d)", | ||
319 | hdev->name, urb, -err); | 320 | hdev->name, urb, -err); |
320 | usb_unanchor_urb(urb); | 321 | usb_unanchor_urb(urb); |
321 | } | 322 | } |
@@ -400,7 +401,8 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags) | |||
400 | 401 | ||
401 | err = usb_submit_urb(urb, mem_flags); | 402 | err = usb_submit_urb(urb, mem_flags); |
402 | if (err < 0) { | 403 | if (err < 0) { |
403 | BT_ERR("%s urb %p submission failed (%d)", | 404 | if (err != -EPERM && err != -ENODEV) |
405 | BT_ERR("%s urb %p submission failed (%d)", | ||
404 | hdev->name, urb, -err); | 406 | hdev->name, urb, -err); |
405 | usb_unanchor_urb(urb); | 407 | usb_unanchor_urb(urb); |
406 | } | 408 | } |
@@ -523,7 +525,8 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags) | |||
523 | 525 | ||
524 | err = usb_submit_urb(urb, mem_flags); | 526 | err = usb_submit_urb(urb, mem_flags); |
525 | if (err < 0) { | 527 | if (err < 0) { |
526 | BT_ERR("%s urb %p submission failed (%d)", | 528 | if (err != -EPERM && err != -ENODEV) |
529 | BT_ERR("%s urb %p submission failed (%d)", | ||
527 | hdev->name, urb, -err); | 530 | hdev->name, urb, -err); |
528 | usb_unanchor_urb(urb); | 531 | usb_unanchor_urb(urb); |
529 | } | 532 | } |
@@ -727,6 +730,9 @@ static int btusb_send_frame(struct sk_buff *skb) | |||
727 | usb_fill_bulk_urb(urb, data->udev, pipe, | 730 | usb_fill_bulk_urb(urb, data->udev, pipe, |
728 | skb->data, skb->len, btusb_tx_complete, skb); | 731 | skb->data, skb->len, btusb_tx_complete, skb); |
729 | 732 | ||
733 | if (skb->priority >= HCI_PRIO_MAX - 1) | ||
734 | urb->transfer_flags = URB_ISO_ASAP; | ||
735 | |||
730 | hdev->stat.acl_tx++; | 736 | hdev->stat.acl_tx++; |
731 | break; | 737 | break; |
732 | 738 | ||
@@ -770,7 +776,9 @@ skip_waking: | |||
770 | 776 | ||
771 | err = usb_submit_urb(urb, GFP_ATOMIC); | 777 | err = usb_submit_urb(urb, GFP_ATOMIC); |
772 | if (err < 0) { | 778 | if (err < 0) { |
773 | BT_ERR("%s urb %p submission failed", hdev->name, urb); | 779 | if (err != -EPERM && err != -ENODEV) |
780 | BT_ERR("%s urb %p submission failed (%d)", | ||
781 | hdev->name, urb, -err); | ||
774 | kfree(urb->setup_packet); | 782 | kfree(urb->setup_packet); |
775 | usb_unanchor_urb(urb); | 783 | usb_unanchor_urb(urb); |
776 | } else { | 784 | } else { |
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 5e4c2de9fc3f..969bb22e493f 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c | |||
@@ -551,9 +551,7 @@ static int dtl1_close(dtl1_info_t *info) | |||
551 | 551 | ||
552 | spin_unlock_irqrestore(&(info->lock), flags); | 552 | spin_unlock_irqrestore(&(info->lock), flags); |
553 | 553 | ||
554 | if (hci_unregister_dev(hdev) < 0) | 554 | hci_unregister_dev(hdev); |
555 | BT_ERR("Can't unregister HCI device %s", hdev->name); | ||
556 | |||
557 | hci_free_dev(hdev); | 555 | hci_free_dev(hdev); |
558 | 556 | ||
559 | return 0; | 557 | return 0; |
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 67c180c2c1e0..2e302a11ab55 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c | |||
@@ -264,10 +264,7 @@ static int vhci_release(struct inode *inode, struct file *file) | |||
264 | struct vhci_data *data = file->private_data; | 264 | struct vhci_data *data = file->private_data; |
265 | struct hci_dev *hdev = data->hdev; | 265 | struct hci_dev *hdev = data->hdev; |
266 | 266 | ||
267 | if (hci_unregister_dev(hdev) < 0) { | 267 | hci_unregister_dev(hdev); |
268 | BT_ERR("Can't unregister HCI device %s", hdev->name); | ||
269 | } | ||
270 | |||
271 | hci_free_dev(hdev); | 268 | hci_free_dev(hdev); |
272 | 269 | ||
273 | file->private_data = NULL; | 270 | file->private_data = NULL; |
diff --git a/drivers/ieee802154/fakehard.c b/drivers/ieee802154/fakehard.c index eb0e2ccc79ae..73d453159408 100644 --- a/drivers/ieee802154/fakehard.c +++ b/drivers/ieee802154/fakehard.c | |||
@@ -343,7 +343,7 @@ static void ieee802154_fake_setup(struct net_device *dev) | |||
343 | { | 343 | { |
344 | dev->addr_len = IEEE802154_ADDR_LEN; | 344 | dev->addr_len = IEEE802154_ADDR_LEN; |
345 | memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN); | 345 | memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN); |
346 | dev->features = NETIF_F_NO_CSUM; | 346 | dev->features = NETIF_F_HW_CSUM; |
347 | dev->needed_tailroom = 2; /* FCS */ | 347 | dev->needed_tailroom = 2; /* FCS */ |
348 | dev->mtu = 127; | 348 | dev->mtu = 127; |
349 | dev->tx_queue_len = 10; | 349 | dev->tx_queue_len = 10; |
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c index c00d2f3f8966..4b3fa711a247 100644 --- a/drivers/infiniband/hw/nes/nes_nic.c +++ b/drivers/infiniband/hw/nes/nes_nic.c | |||
@@ -1589,7 +1589,7 @@ static const struct ethtool_ops nes_ethtool_ops = { | |||
1589 | .set_pauseparam = nes_netdev_set_pauseparam, | 1589 | .set_pauseparam = nes_netdev_set_pauseparam, |
1590 | }; | 1590 | }; |
1591 | 1591 | ||
1592 | static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev, u32 features) | 1592 | static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev, netdev_features_t features) |
1593 | { | 1593 | { |
1594 | struct nes_adapter *nesadapter = nesdev->nesadapter; | 1594 | struct nes_adapter *nesadapter = nesdev->nesadapter; |
1595 | u32 u32temp; | 1595 | u32 u32temp; |
@@ -1610,7 +1610,7 @@ static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev, | |||
1610 | spin_unlock_irqrestore(&nesadapter->phy_lock, flags); | 1610 | spin_unlock_irqrestore(&nesadapter->phy_lock, flags); |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | static u32 nes_fix_features(struct net_device *netdev, u32 features) | 1613 | static netdev_features_t nes_fix_features(struct net_device *netdev, netdev_features_t features) |
1614 | { | 1614 | { |
1615 | /* | 1615 | /* |
1616 | * Since there is no support for separate rx/tx vlan accel | 1616 | * Since there is no support for separate rx/tx vlan accel |
@@ -1624,7 +1624,7 @@ static u32 nes_fix_features(struct net_device *netdev, u32 features) | |||
1624 | return features; | 1624 | return features; |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | static int nes_set_features(struct net_device *netdev, u32 features) | 1627 | static int nes_set_features(struct net_device *netdev, netdev_features_t features) |
1628 | { | 1628 | { |
1629 | struct nes_vnic *nesvnic = netdev_priv(netdev); | 1629 | struct nes_vnic *nesvnic = netdev_priv(netdev); |
1630 | struct nes_device *nesdev = nesvnic->nesdev; | 1630 | struct nes_device *nesdev = nesvnic->nesdev; |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 7567b6000230..efd7a9636aff 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -171,7 +171,7 @@ static int ipoib_stop(struct net_device *dev) | |||
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | static u32 ipoib_fix_features(struct net_device *dev, u32 features) | 174 | static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_features_t features) |
175 | { | 175 | { |
176 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 176 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
177 | 177 | ||
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 0dc30ffde5ad..595d73197016 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -381,6 +381,11 @@ error: | |||
381 | return PTR_ERR(vqs[i]); | 381 | return PTR_ERR(vqs[i]); |
382 | } | 382 | } |
383 | 383 | ||
384 | static const char *lg_bus_name(struct virtio_device *vdev) | ||
385 | { | ||
386 | return ""; | ||
387 | } | ||
388 | |||
384 | /* The ops structure which hooks everything together. */ | 389 | /* The ops structure which hooks everything together. */ |
385 | static struct virtio_config_ops lguest_config_ops = { | 390 | static struct virtio_config_ops lguest_config_ops = { |
386 | .get_features = lg_get_features, | 391 | .get_features = lg_get_features, |
@@ -392,6 +397,7 @@ static struct virtio_config_ops lguest_config_ops = { | |||
392 | .reset = lg_reset, | 397 | .reset = lg_reset, |
393 | .find_vqs = lg_find_vqs, | 398 | .find_vqs = lg_find_vqs, |
394 | .del_vqs = lg_del_vqs, | 399 | .del_vqs = lg_del_vqs, |
400 | .bus_name = lg_bus_name, | ||
395 | }; | 401 | }; |
396 | 402 | ||
397 | /* | 403 | /* |
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c index 42f067347bc7..3fac67a5204c 100644 --- a/drivers/misc/sgi-xp/xpnet.c +++ b/drivers/misc/sgi-xp/xpnet.c | |||
@@ -576,7 +576,7 @@ xpnet_init(void) | |||
576 | * report an error if the data is not retrievable and the | 576 | * report an error if the data is not retrievable and the |
577 | * packet will be dropped. | 577 | * packet will be dropped. |
578 | */ | 578 | */ |
579 | xpnet_device->features = NETIF_F_NO_CSUM; | 579 | xpnet_device->features = NETIF_F_HW_CSUM; |
580 | 580 | ||
581 | result = register_netdev(xpnet_device); | 581 | result = register_netdev(xpnet_device); |
582 | if (result != 0) { | 582 | if (result != 0) { |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 654a5e94e0e7..debdf1c07c5b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -125,6 +125,8 @@ config IFB | |||
125 | 'ifb1' etc. | 125 | 'ifb1' etc. |
126 | Look at the iproute2 documentation directory for usage etc | 126 | Look at the iproute2 documentation directory for usage etc |
127 | 127 | ||
128 | source "drivers/net/team/Kconfig" | ||
129 | |||
128 | config MACVLAN | 130 | config MACVLAN |
129 | tristate "MAC-VLAN support (EXPERIMENTAL)" | 131 | tristate "MAC-VLAN support (EXPERIMENTAL)" |
130 | depends on EXPERIMENTAL | 132 | depends on EXPERIMENTAL |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index fa877cd2b139..4e4ebfe1aa53 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET) += Space.o loopback.o | |||
17 | obj-$(CONFIG_NETCONSOLE) += netconsole.o | 17 | obj-$(CONFIG_NETCONSOLE) += netconsole.o |
18 | obj-$(CONFIG_PHYLIB) += phy/ | 18 | obj-$(CONFIG_PHYLIB) += phy/ |
19 | obj-$(CONFIG_RIONET) += rionet.o | 19 | obj-$(CONFIG_RIONET) += rionet.o |
20 | obj-$(CONFIG_NET_TEAM) += team/ | ||
20 | obj-$(CONFIG_TUN) += tun.o | 21 | obj-$(CONFIG_TUN) += tun.o |
21 | obj-$(CONFIG_VETH) += veth.o | 22 | obj-$(CONFIG_VETH) += veth.o |
22 | obj-$(CONFIG_VIRTIO_NET) += virtio_net.o | 23 | obj-$(CONFIG_VIRTIO_NET) += virtio_net.o |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b0c577256487..25a44d94be17 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -1325,11 +1325,12 @@ static int bond_sethwaddr(struct net_device *bond_dev, | |||
1325 | return 0; | 1325 | return 0; |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | static u32 bond_fix_features(struct net_device *dev, u32 features) | 1328 | static netdev_features_t bond_fix_features(struct net_device *dev, |
1329 | netdev_features_t features) | ||
1329 | { | 1330 | { |
1330 | struct slave *slave; | 1331 | struct slave *slave; |
1331 | struct bonding *bond = netdev_priv(dev); | 1332 | struct bonding *bond = netdev_priv(dev); |
1332 | u32 mask; | 1333 | netdev_features_t mask; |
1333 | int i; | 1334 | int i; |
1334 | 1335 | ||
1335 | read_lock(&bond->lock); | 1336 | read_lock(&bond->lock); |
@@ -1363,7 +1364,7 @@ static void bond_compute_features(struct bonding *bond) | |||
1363 | { | 1364 | { |
1364 | struct slave *slave; | 1365 | struct slave *slave; |
1365 | struct net_device *bond_dev = bond->dev; | 1366 | struct net_device *bond_dev = bond->dev; |
1366 | u32 vlan_features = BOND_VLAN_FEATURES; | 1367 | netdev_features_t vlan_features = BOND_VLAN_FEATURES; |
1367 | unsigned short max_hard_header_len = ETH_HLEN; | 1368 | unsigned short max_hard_header_len = ETH_HLEN; |
1368 | int i; | 1369 | int i; |
1369 | 1370 | ||
@@ -1897,7 +1898,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1897 | struct bonding *bond = netdev_priv(bond_dev); | 1898 | struct bonding *bond = netdev_priv(bond_dev); |
1898 | struct slave *slave, *oldcurrent; | 1899 | struct slave *slave, *oldcurrent; |
1899 | struct sockaddr addr; | 1900 | struct sockaddr addr; |
1900 | u32 old_features = bond_dev->features; | 1901 | netdev_features_t old_features = bond_dev->features; |
1901 | 1902 | ||
1902 | /* slave is not a slave or master is not master of this slave */ | 1903 | /* slave is not a slave or master is not master of this slave */ |
1903 | if (!(slave_dev->flags & IFF_SLAVE) || | 1904 | if (!(slave_dev->flags & IFF_SLAVE) || |
@@ -4360,7 +4361,7 @@ static void bond_setup(struct net_device *bond_dev) | |||
4360 | NETIF_F_HW_VLAN_RX | | 4361 | NETIF_F_HW_VLAN_RX | |
4361 | NETIF_F_HW_VLAN_FILTER; | 4362 | NETIF_F_HW_VLAN_FILTER; |
4362 | 4363 | ||
4363 | bond_dev->hw_features &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_NO_CSUM); | 4364 | bond_dev->hw_features &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_HW_CSUM); |
4364 | bond_dev->features |= bond_dev->hw_features; | 4365 | bond_dev->features |= bond_dev->hw_features; |
4365 | } | 4366 | } |
4366 | 4367 | ||
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 25695bde0549..120f1ab5a2ce 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c | |||
@@ -454,7 +454,7 @@ static void can_setup(struct net_device *dev) | |||
454 | 454 | ||
455 | /* New-style flags. */ | 455 | /* New-style flags. */ |
456 | dev->flags = IFF_NOARP; | 456 | dev->flags = IFF_NOARP; |
457 | dev->features = NETIF_F_NO_CSUM; | 457 | dev->features = NETIF_F_HW_CSUM; |
458 | } | 458 | } |
459 | 459 | ||
460 | struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) | 460 | struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) |
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c index ec4a3119e2c9..1c82dd8b896e 100644 --- a/drivers/net/can/mscan/mscan.c +++ b/drivers/net/can/mscan/mscan.c | |||
@@ -581,7 +581,10 @@ static int mscan_open(struct net_device *dev) | |||
581 | 581 | ||
582 | priv->open_time = jiffies; | 582 | priv->open_time = jiffies; |
583 | 583 | ||
584 | clrbits8(®s->canctl1, MSCAN_LISTEN); | 584 | if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) |
585 | setbits8(®s->canctl1, MSCAN_LISTEN); | ||
586 | else | ||
587 | clrbits8(®s->canctl1, MSCAN_LISTEN); | ||
585 | 588 | ||
586 | ret = mscan_start(dev); | 589 | ret = mscan_start(dev); |
587 | if (ret) | 590 | if (ret) |
@@ -690,7 +693,8 @@ struct net_device *alloc_mscandev(void) | |||
690 | priv->can.bittiming_const = &mscan_bittiming_const; | 693 | priv->can.bittiming_const = &mscan_bittiming_const; |
691 | priv->can.do_set_bittiming = mscan_do_set_bittiming; | 694 | priv->can.do_set_bittiming = mscan_do_set_bittiming; |
692 | priv->can.do_set_mode = mscan_do_set_mode; | 695 | priv->can.do_set_mode = mscan_do_set_mode; |
693 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; | 696 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | |
697 | CAN_CTRLMODE_LISTENONLY; | ||
694 | 698 | ||
695 | for (i = 0; i < TX_QUEUE_SIZE; i++) { | 699 | for (i = 0; i < TX_QUEUE_SIZE; i++) { |
696 | priv->tx_queue[i].id = i; | 700 | priv->tx_queue[i].id = i; |
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index a979b006f459..3f1ebcc2cb83 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c | |||
@@ -387,7 +387,7 @@ static void slc_setup(struct net_device *dev) | |||
387 | 387 | ||
388 | /* New-style flags. */ | 388 | /* New-style flags. */ |
389 | dev->flags = IFF_NOARP; | 389 | dev->flags = IFF_NOARP; |
390 | dev->features = NETIF_F_NO_CSUM; | 390 | dev->features = NETIF_F_HW_CSUM; |
391 | } | 391 | } |
392 | 392 | ||
393 | /****************************************** | 393 | /****************************************** |
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index a7c5e8831e8c..087648ea1edb 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c | |||
@@ -134,7 +134,7 @@ static void dummy_setup(struct net_device *dev) | |||
134 | dev->flags |= IFF_NOARP; | 134 | dev->flags |= IFF_NOARP; |
135 | dev->flags &= ~IFF_MULTICAST; | 135 | dev->flags &= ~IFF_MULTICAST; |
136 | dev->features |= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO; | 136 | dev->features |= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO; |
137 | dev->features |= NETIF_F_NO_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX; | 137 | dev->features |= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX; |
138 | random_ether_addr(dev->dev_addr); | 138 | random_ether_addr(dev->dev_addr); |
139 | } | 139 | } |
140 | 140 | ||
diff --git a/drivers/net/ethernet/3com/3c589_cs.c b/drivers/net/ethernet/3com/3c589_cs.c index 972f80ecc510..da410f036869 100644 --- a/drivers/net/ethernet/3com/3c589_cs.c +++ b/drivers/net/ethernet/3com/3c589_cs.c | |||
@@ -468,9 +468,10 @@ static void tc589_reset(struct net_device *dev) | |||
468 | static void netdev_get_drvinfo(struct net_device *dev, | 468 | static void netdev_get_drvinfo(struct net_device *dev, |
469 | struct ethtool_drvinfo *info) | 469 | struct ethtool_drvinfo *info) |
470 | { | 470 | { |
471 | strcpy(info->driver, DRV_NAME); | 471 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
472 | strcpy(info->version, DRV_VERSION); | 472 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
473 | sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); | 473 | snprintf(info->bus_info, sizeof(info->bus_info), |
474 | "PCMCIA 0x%lx", dev->base_addr); | ||
474 | } | 475 | } |
475 | 476 | ||
476 | static const struct ethtool_ops netdev_ethtool_ops = { | 477 | static const struct ethtool_ops netdev_ethtool_ops = { |
diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c index b42c06baba89..8153a3e0a1a4 100644 --- a/drivers/net/ethernet/3com/3c59x.c +++ b/drivers/net/ethernet/3com/3c59x.c | |||
@@ -2929,15 +2929,17 @@ static void vortex_get_drvinfo(struct net_device *dev, | |||
2929 | { | 2929 | { |
2930 | struct vortex_private *vp = netdev_priv(dev); | 2930 | struct vortex_private *vp = netdev_priv(dev); |
2931 | 2931 | ||
2932 | strcpy(info->driver, DRV_NAME); | 2932 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
2933 | if (VORTEX_PCI(vp)) { | 2933 | if (VORTEX_PCI(vp)) { |
2934 | strcpy(info->bus_info, pci_name(VORTEX_PCI(vp))); | 2934 | strlcpy(info->bus_info, pci_name(VORTEX_PCI(vp)), |
2935 | sizeof(info->bus_info)); | ||
2935 | } else { | 2936 | } else { |
2936 | if (VORTEX_EISA(vp)) | 2937 | if (VORTEX_EISA(vp)) |
2937 | strcpy(info->bus_info, dev_name(vp->gendev)); | 2938 | strlcpy(info->bus_info, dev_name(vp->gendev), |
2939 | sizeof(info->bus_info)); | ||
2938 | else | 2940 | else |
2939 | sprintf(info->bus_info, "EISA 0x%lx %d", | 2941 | snprintf(info->bus_info, sizeof(info->bus_info), |
2940 | dev->base_addr, dev->irq); | 2942 | "EISA 0x%lx %d", dev->base_addr, dev->irq); |
2941 | } | 2943 | } |
2942 | } | 2944 | } |
2943 | 2945 | ||
diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c index 20ea07508ac7..6d6bc754b1a8 100644 --- a/drivers/net/ethernet/3com/typhoon.c +++ b/drivers/net/ethernet/3com/typhoon.c | |||
@@ -988,21 +988,23 @@ typhoon_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
988 | 988 | ||
989 | smp_rmb(); | 989 | smp_rmb(); |
990 | if(tp->card_state == Sleeping) { | 990 | if(tp->card_state == Sleeping) { |
991 | strcpy(info->fw_version, "Sleep image"); | 991 | strlcpy(info->fw_version, "Sleep image", |
992 | sizeof(info->fw_version)); | ||
992 | } else { | 993 | } else { |
993 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS); | 994 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS); |
994 | if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) { | 995 | if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) { |
995 | strcpy(info->fw_version, "Unknown runtime"); | 996 | strlcpy(info->fw_version, "Unknown runtime", |
997 | sizeof(info->fw_version)); | ||
996 | } else { | 998 | } else { |
997 | u32 sleep_ver = le32_to_cpu(xp_resp[0].parm2); | 999 | u32 sleep_ver = le32_to_cpu(xp_resp[0].parm2); |
998 | snprintf(info->fw_version, 32, "%02x.%03x.%03x", | 1000 | snprintf(info->fw_version, sizeof(info->fw_version), |
999 | sleep_ver >> 24, (sleep_ver >> 12) & 0xfff, | 1001 | "%02x.%03x.%03x", sleep_ver >> 24, |
1000 | sleep_ver & 0xfff); | 1002 | (sleep_ver >> 12) & 0xfff, sleep_ver & 0xfff); |
1001 | } | 1003 | } |
1002 | } | 1004 | } |
1003 | 1005 | ||
1004 | strcpy(info->driver, KBUILD_MODNAME); | 1006 | strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); |
1005 | strcpy(info->bus_info, pci_name(pci_dev)); | 1007 | strlcpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); |
1006 | } | 1008 | } |
1007 | 1009 | ||
1008 | static int | 1010 | static int |
diff --git a/drivers/net/ethernet/8390/8390.h b/drivers/net/ethernet/8390/8390.h index 58a12e4c78f9..ef325ffa1b5a 100644 --- a/drivers/net/ethernet/8390/8390.h +++ b/drivers/net/ethernet/8390/8390.h | |||
@@ -14,8 +14,6 @@ | |||
14 | 14 | ||
15 | #define TX_PAGES 12 /* Two Tx slots */ | 15 | #define TX_PAGES 12 /* Two Tx slots */ |
16 | 16 | ||
17 | #define ETHER_ADDR_LEN 6 | ||
18 | |||
19 | /* The 8390 specific per-packet-header format. */ | 17 | /* The 8390 specific per-packet-header format. */ |
20 | struct e8390_pkt_hdr { | 18 | struct e8390_pkt_hdr { |
21 | unsigned char status; /* status */ | 19 | unsigned char status; /* status */ |
diff --git a/drivers/net/ethernet/8390/apne.c b/drivers/net/ethernet/8390/apne.c index 547737340cbb..3ad5d2f9a49c 100644 --- a/drivers/net/ethernet/8390/apne.c +++ b/drivers/net/ethernet/8390/apne.c | |||
@@ -318,7 +318,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr) | |||
318 | i = request_irq(dev->irq, apne_interrupt, IRQF_SHARED, DRV_NAME, dev); | 318 | i = request_irq(dev->irq, apne_interrupt, IRQF_SHARED, DRV_NAME, dev); |
319 | if (i) return i; | 319 | if (i) return i; |
320 | 320 | ||
321 | for(i = 0; i < ETHER_ADDR_LEN; i++) | 321 | for (i = 0; i < ETH_ALEN; i++) |
322 | dev->dev_addr[i] = SA_prom[i]; | 322 | dev->dev_addr[i] = SA_prom[i]; |
323 | 323 | ||
324 | printk(" %pM\n", dev->dev_addr); | 324 | printk(" %pM\n", dev->dev_addr); |
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c index e9f8432f55b4..2a3b8c2676bd 100644 --- a/drivers/net/ethernet/8390/ax88796.c +++ b/drivers/net/ethernet/8390/ax88796.c | |||
@@ -735,15 +735,14 @@ static int ax_init_dev(struct net_device *dev) | |||
735 | if (ax->plat->flags & AXFLG_MAC_FROMDEV) { | 735 | if (ax->plat->flags & AXFLG_MAC_FROMDEV) { |
736 | ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, | 736 | ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, |
737 | ei_local->mem + E8390_CMD); /* 0x61 */ | 737 | ei_local->mem + E8390_CMD); /* 0x61 */ |
738 | for (i = 0; i < ETHER_ADDR_LEN; i++) | 738 | for (i = 0; i < ETH_ALEN; i++) |
739 | dev->dev_addr[i] = | 739 | dev->dev_addr[i] = |
740 | ei_inb(ioaddr + EN1_PHYS_SHIFT(i)); | 740 | ei_inb(ioaddr + EN1_PHYS_SHIFT(i)); |
741 | } | 741 | } |
742 | 742 | ||
743 | if ((ax->plat->flags & AXFLG_MAC_FROMPLATFORM) && | 743 | if ((ax->plat->flags & AXFLG_MAC_FROMPLATFORM) && |
744 | ax->plat->mac_addr) | 744 | ax->plat->mac_addr) |
745 | memcpy(dev->dev_addr, ax->plat->mac_addr, | 745 | memcpy(dev->dev_addr, ax->plat->mac_addr, ETH_ALEN); |
746 | ETHER_ADDR_LEN); | ||
747 | 746 | ||
748 | ax_reset_8390(dev); | 747 | ax_reset_8390(dev); |
749 | 748 | ||
diff --git a/drivers/net/ethernet/8390/es3210.c b/drivers/net/ethernet/8390/es3210.c index 7a09575ecff0..6428f9e7a554 100644 --- a/drivers/net/ethernet/8390/es3210.c +++ b/drivers/net/ethernet/8390/es3210.c | |||
@@ -195,7 +195,7 @@ static int __init es_probe1(struct net_device *dev, int ioaddr) | |||
195 | goto out; | 195 | goto out; |
196 | } | 196 | } |
197 | 197 | ||
198 | for (i = 0; i < ETHER_ADDR_LEN ; i++) | 198 | for (i = 0; i < ETH_ALEN ; i++) |
199 | dev->dev_addr[i] = inb(ioaddr + ES_SA_PROM + i); | 199 | dev->dev_addr[i] = inb(ioaddr + ES_SA_PROM + i); |
200 | 200 | ||
201 | /* Check the Racal vendor ID as well. */ | 201 | /* Check the Racal vendor ID as well. */ |
diff --git a/drivers/net/ethernet/8390/hp-plus.c b/drivers/net/ethernet/8390/hp-plus.c index eeac843dcd2d..d42938b6b596 100644 --- a/drivers/net/ethernet/8390/hp-plus.c +++ b/drivers/net/ethernet/8390/hp-plus.c | |||
@@ -202,7 +202,7 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr) | |||
202 | /* Retrieve and checksum the station address. */ | 202 | /* Retrieve and checksum the station address. */ |
203 | outw(MAC_Page, ioaddr + HP_PAGING); | 203 | outw(MAC_Page, ioaddr + HP_PAGING); |
204 | 204 | ||
205 | for(i = 0; i < ETHER_ADDR_LEN; i++) { | 205 | for(i = 0; i < ETH_ALEN; i++) { |
206 | unsigned char inval = inb(ioaddr + 8 + i); | 206 | unsigned char inval = inb(ioaddr + 8 + i); |
207 | dev->dev_addr[i] = inval; | 207 | dev->dev_addr[i] = inval; |
208 | checksum += inval; | 208 | checksum += inval; |
diff --git a/drivers/net/ethernet/8390/hp.c b/drivers/net/ethernet/8390/hp.c index 18564d4a7c04..113f1e075a26 100644 --- a/drivers/net/ethernet/8390/hp.c +++ b/drivers/net/ethernet/8390/hp.c | |||
@@ -156,7 +156,7 @@ static int __init hp_probe1(struct net_device *dev, int ioaddr) | |||
156 | 156 | ||
157 | printk("%s: %s (ID %02x) at %#3x,", dev->name, name, board_id, ioaddr); | 157 | printk("%s: %s (ID %02x) at %#3x,", dev->name, name, board_id, ioaddr); |
158 | 158 | ||
159 | for(i = 0; i < ETHER_ADDR_LEN; i++) | 159 | for(i = 0; i < ETH_ALEN; i++) |
160 | dev->dev_addr[i] = inb(ioaddr + i); | 160 | dev->dev_addr[i] = inb(ioaddr + i); |
161 | 161 | ||
162 | printk(" %pM", dev->dev_addr); | 162 | printk(" %pM", dev->dev_addr); |
diff --git a/drivers/net/ethernet/8390/hydra.c b/drivers/net/ethernet/8390/hydra.c index 3dac937a67c4..5370c884620b 100644 --- a/drivers/net/ethernet/8390/hydra.c +++ b/drivers/net/ethernet/8390/hydra.c | |||
@@ -129,7 +129,7 @@ static int __devinit hydra_init(struct zorro_dev *z) | |||
129 | if (!dev) | 129 | if (!dev) |
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
132 | for(j = 0; j < ETHER_ADDR_LEN; j++) | 132 | for (j = 0; j < ETH_ALEN; j++) |
133 | dev->dev_addr[j] = *((u8 *)(board + HYDRA_ADDRPROM + 2*j)); | 133 | dev->dev_addr[j] = *((u8 *)(board + HYDRA_ADDRPROM + 2*j)); |
134 | 134 | ||
135 | /* We must set the 8390 for word mode. */ | 135 | /* We must set the 8390 for word mode. */ |
diff --git a/drivers/net/ethernet/8390/lne390.c b/drivers/net/ethernet/8390/lne390.c index f9888d20177b..69490ae018ea 100644 --- a/drivers/net/ethernet/8390/lne390.c +++ b/drivers/net/ethernet/8390/lne390.c | |||
@@ -191,14 +191,14 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr) | |||
191 | || inb(ioaddr + LNE390_SA_PROM + 1) != LNE390_ADDR1 | 191 | || inb(ioaddr + LNE390_SA_PROM + 1) != LNE390_ADDR1 |
192 | || inb(ioaddr + LNE390_SA_PROM + 2) != LNE390_ADDR2 ) { | 192 | || inb(ioaddr + LNE390_SA_PROM + 2) != LNE390_ADDR2 ) { |
193 | printk("lne390.c: card not found"); | 193 | printk("lne390.c: card not found"); |
194 | for(i = 0; i < ETHER_ADDR_LEN; i++) | 194 | for (i = 0; i < ETH_ALEN; i++) |
195 | printk(" %02x", inb(ioaddr + LNE390_SA_PROM + i)); | 195 | printk(" %02x", inb(ioaddr + LNE390_SA_PROM + i)); |
196 | printk(" (invalid prefix).\n"); | 196 | printk(" (invalid prefix).\n"); |
197 | return -ENODEV; | 197 | return -ENODEV; |
198 | } | 198 | } |
199 | #endif | 199 | #endif |
200 | 200 | ||
201 | for(i = 0; i < ETHER_ADDR_LEN; i++) | 201 | for (i = 0; i < ETH_ALEN; i++) |
202 | dev->dev_addr[i] = inb(ioaddr + LNE390_SA_PROM + i); | 202 | dev->dev_addr[i] = inb(ioaddr + LNE390_SA_PROM + i); |
203 | printk("lne390.c: LNE390%X in EISA slot %d, address %pM.\n", | 203 | printk("lne390.c: LNE390%X in EISA slot %d, address %pM.\n", |
204 | 0xa+revision, ioaddr/0x1000, dev->dev_addr); | 204 | 0xa+revision, ioaddr/0x1000, dev->dev_addr); |
diff --git a/drivers/net/ethernet/8390/ne-h8300.c b/drivers/net/ethernet/8390/ne-h8300.c index cd36a6a5f408..9b9c77d5a65c 100644 --- a/drivers/net/ethernet/8390/ne-h8300.c +++ b/drivers/net/ethernet/8390/ne-h8300.c | |||
@@ -312,7 +312,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) | |||
312 | 312 | ||
313 | dev->base_addr = ioaddr; | 313 | dev->base_addr = ioaddr; |
314 | 314 | ||
315 | for(i = 0; i < ETHER_ADDR_LEN; i++) | 315 | for (i = 0; i < ETH_ALEN; i++) |
316 | dev->dev_addr[i] = SA_prom[i]; | 316 | dev->dev_addr[i] = SA_prom[i]; |
317 | printk(" %pM\n", dev->dev_addr); | 317 | printk(" %pM\n", dev->dev_addr); |
318 | 318 | ||
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c index 1063093b3afc..f92ea2a65a57 100644 --- a/drivers/net/ethernet/8390/ne.c +++ b/drivers/net/ethernet/8390/ne.c | |||
@@ -503,12 +503,12 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr) | |||
503 | #ifdef CONFIG_PLAT_MAPPI | 503 | #ifdef CONFIG_PLAT_MAPPI |
504 | outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP, | 504 | outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP, |
505 | ioaddr + E8390_CMD); /* 0x61 */ | 505 | ioaddr + E8390_CMD); /* 0x61 */ |
506 | for (i = 0 ; i < ETHER_ADDR_LEN ; i++) { | 506 | for (i = 0; i < ETH_ALEN; i++) { |
507 | dev->dev_addr[i] = SA_prom[i] | 507 | dev->dev_addr[i] = SA_prom[i] |
508 | = inb_p(ioaddr + EN1_PHYS_SHIFT(i)); | 508 | = inb_p(ioaddr + EN1_PHYS_SHIFT(i)); |
509 | } | 509 | } |
510 | #else | 510 | #else |
511 | for(i = 0; i < ETHER_ADDR_LEN; i++) { | 511 | for (i = 0; i < ETH_ALEN; i++) { |
512 | dev->dev_addr[i] = SA_prom[i]; | 512 | dev->dev_addr[i] = SA_prom[i]; |
513 | } | 513 | } |
514 | #endif | 514 | #endif |
diff --git a/drivers/net/ethernet/8390/ne2.c b/drivers/net/ethernet/8390/ne2.c index 70cdc6996342..922b32036c63 100644 --- a/drivers/net/ethernet/8390/ne2.c +++ b/drivers/net/ethernet/8390/ne2.c | |||
@@ -460,7 +460,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot) | |||
460 | 460 | ||
461 | dev->base_addr = base_addr; | 461 | dev->base_addr = base_addr; |
462 | 462 | ||
463 | for(i = 0; i < ETHER_ADDR_LEN; i++) | 463 | for (i = 0; i < ETH_ALEN; i++) |
464 | dev->dev_addr[i] = SA_prom[i]; | 464 | dev->dev_addr[i] = SA_prom[i]; |
465 | 465 | ||
466 | printk(" %pM\n", dev->dev_addr); | 466 | printk(" %pM\n", dev->dev_addr); |
diff --git a/drivers/net/ethernet/8390/ne2k-pci.c b/drivers/net/ethernet/8390/ne2k-pci.c index 39923425ba25..3fab04a0034a 100644 --- a/drivers/net/ethernet/8390/ne2k-pci.c +++ b/drivers/net/ethernet/8390/ne2k-pci.c | |||
@@ -639,9 +639,9 @@ static void ne2k_pci_get_drvinfo(struct net_device *dev, | |||
639 | struct ei_device *ei = netdev_priv(dev); | 639 | struct ei_device *ei = netdev_priv(dev); |
640 | struct pci_dev *pci_dev = (struct pci_dev *) ei->priv; | 640 | struct pci_dev *pci_dev = (struct pci_dev *) ei->priv; |
641 | 641 | ||
642 | strcpy(info->driver, DRV_NAME); | 642 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
643 | strcpy(info->version, DRV_VERSION); | 643 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
644 | strcpy(info->bus_info, pci_name(pci_dev)); | 644 | strlcpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); |
645 | } | 645 | } |
646 | 646 | ||
647 | static const struct ethtool_ops ne2k_pci_ethtool_ops = { | 647 | static const struct ethtool_ops ne2k_pci_ethtool_ops = { |
diff --git a/drivers/net/ethernet/8390/ne3210.c b/drivers/net/ethernet/8390/ne3210.c index 243ed2aee88e..2a3e8057feae 100644 --- a/drivers/net/ethernet/8390/ne3210.c +++ b/drivers/net/ethernet/8390/ne3210.c | |||
@@ -125,7 +125,7 @@ static int __init ne3210_eisa_probe (struct device *device) | |||
125 | #endif | 125 | #endif |
126 | 126 | ||
127 | port_index = inb(ioaddr + NE3210_CFG2) >> 6; | 127 | port_index = inb(ioaddr + NE3210_CFG2) >> 6; |
128 | for(i = 0; i < ETHER_ADDR_LEN; i++) | 128 | for (i = 0; i < ETH_ALEN; i++) |
129 | dev->dev_addr[i] = inb(ioaddr + NE3210_SA_PROM + i); | 129 | dev->dev_addr[i] = inb(ioaddr + NE3210_SA_PROM + i); |
130 | printk("ne3210.c: NE3210 in EISA slot %d, media: %s, addr: %pM.\n", | 130 | printk("ne3210.c: NE3210 in EISA slot %d, media: %s, addr: %pM.\n", |
131 | edev->slot, ifmap[port_index], dev->dev_addr); | 131 | edev->slot, ifmap[port_index], dev->dev_addr); |
diff --git a/drivers/net/ethernet/8390/stnic.c b/drivers/net/ethernet/8390/stnic.c index d85f0a84bc7b..3b903759980a 100644 --- a/drivers/net/ethernet/8390/stnic.c +++ b/drivers/net/ethernet/8390/stnic.c | |||
@@ -114,7 +114,7 @@ static int __init stnic_probe(void) | |||
114 | #ifdef CONFIG_SH_STANDARD_BIOS | 114 | #ifdef CONFIG_SH_STANDARD_BIOS |
115 | sh_bios_get_node_addr (stnic_eadr); | 115 | sh_bios_get_node_addr (stnic_eadr); |
116 | #endif | 116 | #endif |
117 | for (i = 0; i < ETHER_ADDR_LEN; i++) | 117 | for (i = 0; i < ETH_ALEN; i++) |
118 | dev->dev_addr[i] = stnic_eadr[i]; | 118 | dev->dev_addr[i] = stnic_eadr[i]; |
119 | 119 | ||
120 | /* Set the base address to point to the NIC, not the "real" base! */ | 120 | /* Set the base address to point to the NIC, not the "real" base! */ |
diff --git a/drivers/net/ethernet/8390/zorro8390.c b/drivers/net/ethernet/8390/zorro8390.c index 3aa9fe9999b5..bcd27323b203 100644 --- a/drivers/net/ethernet/8390/zorro8390.c +++ b/drivers/net/ethernet/8390/zorro8390.c | |||
@@ -365,7 +365,7 @@ static int __devinit zorro8390_init(struct net_device *dev, | |||
365 | if (i) | 365 | if (i) |
366 | return i; | 366 | return i; |
367 | 367 | ||
368 | for (i = 0; i < ETHER_ADDR_LEN; i++) | 368 | for (i = 0; i < ETH_ALEN; i++) |
369 | dev->dev_addr[i] = SA_prom[i]; | 369 | dev->dev_addr[i] = SA_prom[i]; |
370 | 370 | ||
371 | pr_debug("Found ethernet address: %pM\n", dev->dev_addr); | 371 | pr_debug("Found ethernet address: %pM\n", dev->dev_addr); |
diff --git a/drivers/net/ethernet/adaptec/starfire.c b/drivers/net/ethernet/adaptec/starfire.c index 6d9f6911000f..a446e251908b 100644 --- a/drivers/net/ethernet/adaptec/starfire.c +++ b/drivers/net/ethernet/adaptec/starfire.c | |||
@@ -1842,9 +1842,9 @@ static int check_if_running(struct net_device *dev) | |||
1842 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1842 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1843 | { | 1843 | { |
1844 | struct netdev_private *np = netdev_priv(dev); | 1844 | struct netdev_private *np = netdev_priv(dev); |
1845 | strcpy(info->driver, DRV_NAME); | 1845 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1846 | strcpy(info->version, DRV_VERSION); | 1846 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1847 | strcpy(info->bus_info, pci_name(np->pci_dev)); | 1847 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 1850 | static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c index a9745f4ddbfe..33e0a8c20f6b 100644 --- a/drivers/net/ethernet/amd/amd8111e.c +++ b/drivers/net/ethernet/amd/amd8111e.c | |||
@@ -499,7 +499,7 @@ static int amd8111e_restart(struct net_device *dev) | |||
499 | writel( VAL0 | APAD_XMT | REX_RTRY, mmio + CMD2 ); | 499 | writel( VAL0 | APAD_XMT | REX_RTRY, mmio + CMD2 ); |
500 | 500 | ||
501 | /* Setting the MAC address to the device */ | 501 | /* Setting the MAC address to the device */ |
502 | for(i = 0; i < ETH_ADDR_LEN; i++) | 502 | for (i = 0; i < ETH_ALEN; i++) |
503 | writeb( dev->dev_addr[i], mmio + PADR + i ); | 503 | writeb( dev->dev_addr[i], mmio + PADR + i ); |
504 | 504 | ||
505 | /* Enable interrupt coalesce */ | 505 | /* Enable interrupt coalesce */ |
@@ -1412,10 +1412,11 @@ static void amd8111e_get_drvinfo(struct net_device* dev, struct ethtool_drvinfo | |||
1412 | { | 1412 | { |
1413 | struct amd8111e_priv *lp = netdev_priv(dev); | 1413 | struct amd8111e_priv *lp = netdev_priv(dev); |
1414 | struct pci_dev *pci_dev = lp->pci_dev; | 1414 | struct pci_dev *pci_dev = lp->pci_dev; |
1415 | strcpy (info->driver, MODULE_NAME); | 1415 | strlcpy(info->driver, MODULE_NAME, sizeof(info->driver)); |
1416 | strcpy (info->version, MODULE_VERS); | 1416 | strlcpy(info->version, MODULE_VERS, sizeof(info->version)); |
1417 | sprintf(info->fw_version,"%u",chip_version); | 1417 | snprintf(info->fw_version, sizeof(info->fw_version), |
1418 | strcpy (info->bus_info, pci_name(pci_dev)); | 1418 | "%u", chip_version); |
1419 | strlcpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); | ||
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | static int amd8111e_get_regs_len(struct net_device *dev) | 1422 | static int amd8111e_get_regs_len(struct net_device *dev) |
@@ -1549,7 +1550,7 @@ static int amd8111e_set_mac_address(struct net_device *dev, void *p) | |||
1549 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | 1550 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); |
1550 | spin_lock_irq(&lp->lock); | 1551 | spin_lock_irq(&lp->lock); |
1551 | /* Setting the MAC address to the device */ | 1552 | /* Setting the MAC address to the device */ |
1552 | for(i = 0; i < ETH_ADDR_LEN; i++) | 1553 | for (i = 0; i < ETH_ALEN; i++) |
1553 | writeb( dev->dev_addr[i], lp->mmio + PADR + i ); | 1554 | writeb( dev->dev_addr[i], lp->mmio + PADR + i ); |
1554 | 1555 | ||
1555 | spin_unlock_irq(&lp->lock); | 1556 | spin_unlock_irq(&lp->lock); |
@@ -1885,7 +1886,7 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev, | |||
1885 | } | 1886 | } |
1886 | 1887 | ||
1887 | /* Initializing MAC address */ | 1888 | /* Initializing MAC address */ |
1888 | for(i = 0; i < ETH_ADDR_LEN; i++) | 1889 | for (i = 0; i < ETH_ALEN; i++) |
1889 | dev->dev_addr[i] = readb(lp->mmio + PADR + i); | 1890 | dev->dev_addr[i] = readb(lp->mmio + PADR + i); |
1890 | 1891 | ||
1891 | /* Setting user defined parametrs */ | 1892 | /* Setting user defined parametrs */ |
diff --git a/drivers/net/ethernet/amd/amd8111e.h b/drivers/net/ethernet/amd/amd8111e.h index 2ff2e7a12dd0..5bbb53a1999c 100644 --- a/drivers/net/ethernet/amd/amd8111e.h +++ b/drivers/net/ethernet/amd/amd8111e.h | |||
@@ -586,7 +586,6 @@ typedef enum { | |||
586 | 586 | ||
587 | #define PKT_BUFF_SZ 1536 | 587 | #define PKT_BUFF_SZ 1536 |
588 | #define MIN_PKT_LEN 60 | 588 | #define MIN_PKT_LEN 60 |
589 | #define ETH_ADDR_LEN 6 | ||
590 | 589 | ||
591 | #define AMD8111E_TX_TIMEOUT (3 * HZ)/* 3 sec */ | 590 | #define AMD8111E_TX_TIMEOUT (3 * HZ)/* 3 sec */ |
592 | #define SOFT_TIMER_FREQ 0xBEBC /* 0.5 sec */ | 591 | #define SOFT_TIMER_FREQ 0xBEBC /* 0.5 sec */ |
diff --git a/drivers/net/ethernet/amd/nmclan_cs.c b/drivers/net/ethernet/amd/nmclan_cs.c index 3accd5d21b08..6be0dd67631a 100644 --- a/drivers/net/ethernet/amd/nmclan_cs.c +++ b/drivers/net/ethernet/amd/nmclan_cs.c | |||
@@ -160,8 +160,6 @@ Include Files | |||
160 | Defines | 160 | Defines |
161 | ---------------------------------------------------------------------------- */ | 161 | ---------------------------------------------------------------------------- */ |
162 | 162 | ||
163 | #define ETHER_ADDR_LEN ETH_ALEN | ||
164 | /* 6 bytes in an Ethernet Address */ | ||
165 | #define MACE_LADRF_LEN 8 | 163 | #define MACE_LADRF_LEN 8 |
166 | /* 8 bytes in Logical Address Filter */ | 164 | /* 8 bytes in Logical Address Filter */ |
167 | 165 | ||
@@ -600,7 +598,7 @@ static int mace_init(mace_private *lp, unsigned int ioaddr, char *enet_addr) | |||
600 | } | 598 | } |
601 | } | 599 | } |
602 | /* Set PADR register */ | 600 | /* Set PADR register */ |
603 | for (i = 0; i < ETHER_ADDR_LEN; i++) | 601 | for (i = 0; i < ETH_ALEN; i++) |
604 | mace_write(lp, ioaddr, MACE_PADR, enet_addr[i]); | 602 | mace_write(lp, ioaddr, MACE_PADR, enet_addr[i]); |
605 | 603 | ||
606 | /* MAC Configuration Control Register should be written last */ | 604 | /* MAC Configuration Control Register should be written last */ |
@@ -639,11 +637,11 @@ static int nmclan_config(struct pcmcia_device *link) | |||
639 | 637 | ||
640 | /* Read the ethernet address from the CIS. */ | 638 | /* Read the ethernet address from the CIS. */ |
641 | len = pcmcia_get_tuple(link, 0x80, &buf); | 639 | len = pcmcia_get_tuple(link, 0x80, &buf); |
642 | if (!buf || len < ETHER_ADDR_LEN) { | 640 | if (!buf || len < ETH_ALEN) { |
643 | kfree(buf); | 641 | kfree(buf); |
644 | goto failed; | 642 | goto failed; |
645 | } | 643 | } |
646 | memcpy(dev->dev_addr, buf, ETHER_ADDR_LEN); | 644 | memcpy(dev->dev_addr, buf, ETH_ALEN); |
647 | kfree(buf); | 645 | kfree(buf); |
648 | 646 | ||
649 | /* Verify configuration by reading the MACE ID. */ | 647 | /* Verify configuration by reading the MACE ID. */ |
@@ -822,9 +820,10 @@ static int mace_close(struct net_device *dev) | |||
822 | static void netdev_get_drvinfo(struct net_device *dev, | 820 | static void netdev_get_drvinfo(struct net_device *dev, |
823 | struct ethtool_drvinfo *info) | 821 | struct ethtool_drvinfo *info) |
824 | { | 822 | { |
825 | strcpy(info->driver, DRV_NAME); | 823 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
826 | strcpy(info->version, DRV_VERSION); | 824 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
827 | sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); | 825 | snprintf(info->bus_info, sizeof(info->bus_info), |
826 | "PCMCIA 0x%lx", dev->base_addr); | ||
828 | } | 827 | } |
829 | 828 | ||
830 | static const struct ethtool_ops netdev_ethtool_ops = { | 829 | static const struct ethtool_ops netdev_ethtool_ops = { |
@@ -1420,7 +1419,7 @@ Output | |||
1420 | static void set_multicast_list(struct net_device *dev) | 1419 | static void set_multicast_list(struct net_device *dev) |
1421 | { | 1420 | { |
1422 | mace_private *lp = netdev_priv(dev); | 1421 | mace_private *lp = netdev_priv(dev); |
1423 | int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */ | 1422 | int adr[ETH_ALEN] = {0}; /* Ethernet address */ |
1424 | struct netdev_hw_addr *ha; | 1423 | struct netdev_hw_addr *ha; |
1425 | 1424 | ||
1426 | #ifdef PCMCIA_DEBUG | 1425 | #ifdef PCMCIA_DEBUG |
@@ -1442,7 +1441,7 @@ static void set_multicast_list(struct net_device *dev) | |||
1442 | /* Calculate multicast logical address filter */ | 1441 | /* Calculate multicast logical address filter */ |
1443 | memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN); | 1442 | memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN); |
1444 | netdev_for_each_mc_addr(ha, dev) { | 1443 | netdev_for_each_mc_addr(ha, dev) { |
1445 | memcpy(adr, ha->addr, ETHER_ADDR_LEN); | 1444 | memcpy(adr, ha->addr, ETH_ALEN); |
1446 | BuildLAF(lp->multicast_ladrf, adr); | 1445 | BuildLAF(lp->multicast_ladrf, adr); |
1447 | } | 1446 | } |
1448 | } | 1447 | } |
diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c index f92bc6e34828..20e6dab0186c 100644 --- a/drivers/net/ethernet/amd/pcnet32.c +++ b/drivers/net/ethernet/amd/pcnet32.c | |||
@@ -711,12 +711,14 @@ static void pcnet32_get_drvinfo(struct net_device *dev, | |||
711 | { | 711 | { |
712 | struct pcnet32_private *lp = netdev_priv(dev); | 712 | struct pcnet32_private *lp = netdev_priv(dev); |
713 | 713 | ||
714 | strcpy(info->driver, DRV_NAME); | 714 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
715 | strcpy(info->version, DRV_VERSION); | 715 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
716 | if (lp->pci_dev) | 716 | if (lp->pci_dev) |
717 | strcpy(info->bus_info, pci_name(lp->pci_dev)); | 717 | strlcpy(info->bus_info, pci_name(lp->pci_dev), |
718 | sizeof(info->bus_info)); | ||
718 | else | 719 | else |
719 | sprintf(info->bus_info, "VLB 0x%lx", dev->base_addr); | 720 | snprintf(info->bus_info, sizeof(info->bus_info), |
721 | "VLB 0x%lx", dev->base_addr); | ||
720 | } | 722 | } |
721 | 723 | ||
722 | static u32 pcnet32_get_link(struct net_device *dev) | 724 | static u32 pcnet32_get_link(struct net_device *dev) |
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index 02c7ed8d9eca..b8591246eb4c 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c | |||
@@ -411,7 +411,7 @@ static void atl1c_set_multi(struct net_device *netdev) | |||
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | static void __atl1c_vlan_mode(u32 features, u32 *mac_ctrl_data) | 414 | static void __atl1c_vlan_mode(netdev_features_t features, u32 *mac_ctrl_data) |
415 | { | 415 | { |
416 | if (features & NETIF_F_HW_VLAN_RX) { | 416 | if (features & NETIF_F_HW_VLAN_RX) { |
417 | /* enable VLAN tag insert/strip */ | 417 | /* enable VLAN tag insert/strip */ |
@@ -422,7 +422,8 @@ static void __atl1c_vlan_mode(u32 features, u32 *mac_ctrl_data) | |||
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | static void atl1c_vlan_mode(struct net_device *netdev, u32 features) | 425 | static void atl1c_vlan_mode(struct net_device *netdev, |
426 | netdev_features_t features) | ||
426 | { | 427 | { |
427 | struct atl1c_adapter *adapter = netdev_priv(netdev); | 428 | struct atl1c_adapter *adapter = netdev_priv(netdev); |
428 | struct pci_dev *pdev = adapter->pdev; | 429 | struct pci_dev *pdev = adapter->pdev; |
@@ -482,7 +483,8 @@ static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter, | |||
482 | roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE; | 483 | roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE; |
483 | } | 484 | } |
484 | 485 | ||
485 | static u32 atl1c_fix_features(struct net_device *netdev, u32 features) | 486 | static netdev_features_t atl1c_fix_features(struct net_device *netdev, |
487 | netdev_features_t features) | ||
486 | { | 488 | { |
487 | /* | 489 | /* |
488 | * Since there is no support for separate rx/tx vlan accel | 490 | * Since there is no support for separate rx/tx vlan accel |
@@ -499,9 +501,10 @@ static u32 atl1c_fix_features(struct net_device *netdev, u32 features) | |||
499 | return features; | 501 | return features; |
500 | } | 502 | } |
501 | 503 | ||
502 | static int atl1c_set_features(struct net_device *netdev, u32 features) | 504 | static int atl1c_set_features(struct net_device *netdev, |
505 | netdev_features_t features) | ||
503 | { | 506 | { |
504 | u32 changed = netdev->features ^ features; | 507 | netdev_features_t changed = netdev->features ^ features; |
505 | 508 | ||
506 | if (changed & NETIF_F_HW_VLAN_RX) | 509 | if (changed & NETIF_F_HW_VLAN_RX) |
507 | atl1c_vlan_mode(netdev, features); | 510 | atl1c_vlan_mode(netdev, features); |
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c index 6269438d365f..6e61f9f9ebb5 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c | |||
@@ -310,10 +310,12 @@ static void atl1e_get_drvinfo(struct net_device *netdev, | |||
310 | { | 310 | { |
311 | struct atl1e_adapter *adapter = netdev_priv(netdev); | 311 | struct atl1e_adapter *adapter = netdev_priv(netdev); |
312 | 312 | ||
313 | strncpy(drvinfo->driver, atl1e_driver_name, 32); | 313 | strlcpy(drvinfo->driver, atl1e_driver_name, sizeof(drvinfo->driver)); |
314 | strncpy(drvinfo->version, atl1e_driver_version, 32); | 314 | strlcpy(drvinfo->version, atl1e_driver_version, |
315 | strncpy(drvinfo->fw_version, "L1e", 32); | 315 | sizeof(drvinfo->version)); |
316 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | 316 | strlcpy(drvinfo->fw_version, "L1e", sizeof(drvinfo->fw_version)); |
317 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
318 | sizeof(drvinfo->bus_info)); | ||
317 | drvinfo->n_stats = 0; | 319 | drvinfo->n_stats = 0; |
318 | drvinfo->testinfo_len = 0; | 320 | drvinfo->testinfo_len = 0; |
319 | drvinfo->regdump_len = atl1e_get_regs_len(netdev); | 321 | drvinfo->regdump_len = atl1e_get_regs_len(netdev); |
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 95483bcac1d0..c915c0873810 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c | |||
@@ -313,7 +313,7 @@ static void atl1e_set_multi(struct net_device *netdev) | |||
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | static void __atl1e_vlan_mode(u32 features, u32 *mac_ctrl_data) | 316 | static void __atl1e_vlan_mode(netdev_features_t features, u32 *mac_ctrl_data) |
317 | { | 317 | { |
318 | if (features & NETIF_F_HW_VLAN_RX) { | 318 | if (features & NETIF_F_HW_VLAN_RX) { |
319 | /* enable VLAN tag insert/strip */ | 319 | /* enable VLAN tag insert/strip */ |
@@ -324,7 +324,8 @@ static void __atl1e_vlan_mode(u32 features, u32 *mac_ctrl_data) | |||
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | static void atl1e_vlan_mode(struct net_device *netdev, u32 features) | 327 | static void atl1e_vlan_mode(struct net_device *netdev, |
328 | netdev_features_t features) | ||
328 | { | 329 | { |
329 | struct atl1e_adapter *adapter = netdev_priv(netdev); | 330 | struct atl1e_adapter *adapter = netdev_priv(netdev); |
330 | u32 mac_ctrl_data = 0; | 331 | u32 mac_ctrl_data = 0; |
@@ -370,7 +371,8 @@ static int atl1e_set_mac_addr(struct net_device *netdev, void *p) | |||
370 | return 0; | 371 | return 0; |
371 | } | 372 | } |
372 | 373 | ||
373 | static u32 atl1e_fix_features(struct net_device *netdev, u32 features) | 374 | static netdev_features_t atl1e_fix_features(struct net_device *netdev, |
375 | netdev_features_t features) | ||
374 | { | 376 | { |
375 | /* | 377 | /* |
376 | * Since there is no support for separate rx/tx vlan accel | 378 | * Since there is no support for separate rx/tx vlan accel |
@@ -384,9 +386,10 @@ static u32 atl1e_fix_features(struct net_device *netdev, u32 features) | |||
384 | return features; | 386 | return features; |
385 | } | 387 | } |
386 | 388 | ||
387 | static int atl1e_set_features(struct net_device *netdev, u32 features) | 389 | static int atl1e_set_features(struct net_device *netdev, |
390 | netdev_features_t features) | ||
388 | { | 391 | { |
389 | u32 changed = netdev->features ^ features; | 392 | netdev_features_t changed = netdev->features ^ features; |
390 | 393 | ||
391 | if (changed & NETIF_F_HW_VLAN_RX) | 394 | if (changed & NETIF_F_HW_VLAN_RX) |
392 | atl1e_vlan_mode(netdev, features); | 395 | atl1e_vlan_mode(netdev, features); |
diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c index 1feae5928a4b..071f4c858969 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/drivers/net/ethernet/atheros/atlx/atl2.c | |||
@@ -361,7 +361,7 @@ static inline void atl2_irq_disable(struct atl2_adapter *adapter) | |||
361 | synchronize_irq(adapter->pdev->irq); | 361 | synchronize_irq(adapter->pdev->irq); |
362 | } | 362 | } |
363 | 363 | ||
364 | static void __atl2_vlan_mode(u32 features, u32 *ctrl) | 364 | static void __atl2_vlan_mode(netdev_features_t features, u32 *ctrl) |
365 | { | 365 | { |
366 | if (features & NETIF_F_HW_VLAN_RX) { | 366 | if (features & NETIF_F_HW_VLAN_RX) { |
367 | /* enable VLAN tag insert/strip */ | 367 | /* enable VLAN tag insert/strip */ |
@@ -372,7 +372,8 @@ static void __atl2_vlan_mode(u32 features, u32 *ctrl) | |||
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | static void atl2_vlan_mode(struct net_device *netdev, u32 features) | 375 | static void atl2_vlan_mode(struct net_device *netdev, |
376 | netdev_features_t features) | ||
376 | { | 377 | { |
377 | struct atl2_adapter *adapter = netdev_priv(netdev); | 378 | struct atl2_adapter *adapter = netdev_priv(netdev); |
378 | u32 ctrl; | 379 | u32 ctrl; |
@@ -391,7 +392,8 @@ static void atl2_restore_vlan(struct atl2_adapter *adapter) | |||
391 | atl2_vlan_mode(adapter->netdev, adapter->netdev->features); | 392 | atl2_vlan_mode(adapter->netdev, adapter->netdev->features); |
392 | } | 393 | } |
393 | 394 | ||
394 | static u32 atl2_fix_features(struct net_device *netdev, u32 features) | 395 | static netdev_features_t atl2_fix_features(struct net_device *netdev, |
396 | netdev_features_t features) | ||
395 | { | 397 | { |
396 | /* | 398 | /* |
397 | * Since there is no support for separate rx/tx vlan accel | 399 | * Since there is no support for separate rx/tx vlan accel |
@@ -405,9 +407,10 @@ static u32 atl2_fix_features(struct net_device *netdev, u32 features) | |||
405 | return features; | 407 | return features; |
406 | } | 408 | } |
407 | 409 | ||
408 | static int atl2_set_features(struct net_device *netdev, u32 features) | 410 | static int atl2_set_features(struct net_device *netdev, |
411 | netdev_features_t features) | ||
409 | { | 412 | { |
410 | u32 changed = netdev->features ^ features; | 413 | netdev_features_t changed = netdev->features ^ features; |
411 | 414 | ||
412 | if (changed & NETIF_F_HW_VLAN_RX) | 415 | if (changed & NETIF_F_HW_VLAN_RX) |
413 | atl2_vlan_mode(netdev, features); | 416 | atl2_vlan_mode(netdev, features); |
@@ -2049,10 +2052,12 @@ static void atl2_get_drvinfo(struct net_device *netdev, | |||
2049 | { | 2052 | { |
2050 | struct atl2_adapter *adapter = netdev_priv(netdev); | 2053 | struct atl2_adapter *adapter = netdev_priv(netdev); |
2051 | 2054 | ||
2052 | strncpy(drvinfo->driver, atl2_driver_name, 32); | 2055 | strlcpy(drvinfo->driver, atl2_driver_name, sizeof(drvinfo->driver)); |
2053 | strncpy(drvinfo->version, atl2_driver_version, 32); | 2056 | strlcpy(drvinfo->version, atl2_driver_version, |
2054 | strncpy(drvinfo->fw_version, "L2", 32); | 2057 | sizeof(drvinfo->version)); |
2055 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | 2058 | strlcpy(drvinfo->fw_version, "L2", sizeof(drvinfo->fw_version)); |
2059 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
2060 | sizeof(drvinfo->bus_info)); | ||
2056 | drvinfo->n_stats = 0; | 2061 | drvinfo->n_stats = 0; |
2057 | drvinfo->testinfo_len = 0; | 2062 | drvinfo->testinfo_len = 0; |
2058 | drvinfo->regdump_len = atl2_get_regs_len(netdev); | 2063 | drvinfo->regdump_len = atl2_get_regs_len(netdev); |
diff --git a/drivers/net/ethernet/atheros/atlx/atlx.c b/drivers/net/ethernet/atheros/atlx/atlx.c index aabcf4b5745a..8ff7411094d5 100644 --- a/drivers/net/ethernet/atheros/atlx/atlx.c +++ b/drivers/net/ethernet/atheros/atlx/atlx.c | |||
@@ -211,7 +211,7 @@ static void atlx_link_chg_task(struct work_struct *work) | |||
211 | spin_unlock_irqrestore(&adapter->lock, flags); | 211 | spin_unlock_irqrestore(&adapter->lock, flags); |
212 | } | 212 | } |
213 | 213 | ||
214 | static void __atlx_vlan_mode(u32 features, u32 *ctrl) | 214 | static void __atlx_vlan_mode(netdev_features_t features, u32 *ctrl) |
215 | { | 215 | { |
216 | if (features & NETIF_F_HW_VLAN_RX) { | 216 | if (features & NETIF_F_HW_VLAN_RX) { |
217 | /* enable VLAN tag insert/strip */ | 217 | /* enable VLAN tag insert/strip */ |
@@ -222,7 +222,8 @@ static void __atlx_vlan_mode(u32 features, u32 *ctrl) | |||
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | static void atlx_vlan_mode(struct net_device *netdev, u32 features) | 225 | static void atlx_vlan_mode(struct net_device *netdev, |
226 | netdev_features_t features) | ||
226 | { | 227 | { |
227 | struct atlx_adapter *adapter = netdev_priv(netdev); | 228 | struct atlx_adapter *adapter = netdev_priv(netdev); |
228 | unsigned long flags; | 229 | unsigned long flags; |
@@ -242,7 +243,8 @@ static void atlx_restore_vlan(struct atlx_adapter *adapter) | |||
242 | atlx_vlan_mode(adapter->netdev, adapter->netdev->features); | 243 | atlx_vlan_mode(adapter->netdev, adapter->netdev->features); |
243 | } | 244 | } |
244 | 245 | ||
245 | static u32 atlx_fix_features(struct net_device *netdev, u32 features) | 246 | static netdev_features_t atlx_fix_features(struct net_device *netdev, |
247 | netdev_features_t features) | ||
246 | { | 248 | { |
247 | /* | 249 | /* |
248 | * Since there is no support for separate rx/tx vlan accel | 250 | * Since there is no support for separate rx/tx vlan accel |
@@ -256,9 +258,10 @@ static u32 atlx_fix_features(struct net_device *netdev, u32 features) | |||
256 | return features; | 258 | return features; |
257 | } | 259 | } |
258 | 260 | ||
259 | static int atlx_set_features(struct net_device *netdev, u32 features) | 261 | static int atlx_set_features(struct net_device *netdev, |
262 | netdev_features_t features) | ||
260 | { | 263 | { |
261 | u32 changed = netdev->features ^ features; | 264 | netdev_features_t changed = netdev->features ^ features; |
262 | 265 | ||
263 | if (changed & NETIF_F_HW_VLAN_RX) | 266 | if (changed & NETIF_F_HW_VLAN_RX) |
264 | atlx_vlan_mode(netdev, features); | 267 | atlx_vlan_mode(netdev, features); |
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 965c7235804d..66f6e7f654c3 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c | |||
@@ -2064,21 +2064,12 @@ __acquires(&bp->phy_lock) | |||
2064 | bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg); | 2064 | bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg); |
2065 | adv1000_reg &= PHY_ALL_1000_SPEED; | 2065 | adv1000_reg &= PHY_ALL_1000_SPEED; |
2066 | 2066 | ||
2067 | if (bp->advertising & ADVERTISED_10baseT_Half) | 2067 | new_adv_reg = ethtool_adv_to_mii_100bt(bp->advertising); |
2068 | new_adv_reg |= ADVERTISE_10HALF; | ||
2069 | if (bp->advertising & ADVERTISED_10baseT_Full) | ||
2070 | new_adv_reg |= ADVERTISE_10FULL; | ||
2071 | if (bp->advertising & ADVERTISED_100baseT_Half) | ||
2072 | new_adv_reg |= ADVERTISE_100HALF; | ||
2073 | if (bp->advertising & ADVERTISED_100baseT_Full) | ||
2074 | new_adv_reg |= ADVERTISE_100FULL; | ||
2075 | if (bp->advertising & ADVERTISED_1000baseT_Full) | ||
2076 | new_adv1000_reg |= ADVERTISE_1000FULL; | ||
2077 | |||
2078 | new_adv_reg |= ADVERTISE_CSMA; | 2068 | new_adv_reg |= ADVERTISE_CSMA; |
2079 | |||
2080 | new_adv_reg |= bnx2_phy_get_pause_adv(bp); | 2069 | new_adv_reg |= bnx2_phy_get_pause_adv(bp); |
2081 | 2070 | ||
2071 | new_adv1000_reg |= ethtool_adv_to_mii_1000T(bp->advertising); | ||
2072 | |||
2082 | if ((adv1000_reg != new_adv1000_reg) || | 2073 | if ((adv1000_reg != new_adv1000_reg) || |
2083 | (adv_reg != new_adv_reg) || | 2074 | (adv_reg != new_adv_reg) || |
2084 | ((bmcr & BMCR_ANENABLE) == 0)) { | 2075 | ((bmcr & BMCR_ANENABLE) == 0)) { |
@@ -2734,31 +2725,27 @@ bnx2_free_rx_page(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index) | |||
2734 | } | 2725 | } |
2735 | 2726 | ||
2736 | static inline int | 2727 | static inline int |
2737 | bnx2_alloc_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index, gfp_t gfp) | 2728 | bnx2_alloc_rx_data(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index, gfp_t gfp) |
2738 | { | 2729 | { |
2739 | struct sk_buff *skb; | 2730 | u8 *data; |
2740 | struct sw_bd *rx_buf = &rxr->rx_buf_ring[index]; | 2731 | struct sw_bd *rx_buf = &rxr->rx_buf_ring[index]; |
2741 | dma_addr_t mapping; | 2732 | dma_addr_t mapping; |
2742 | struct rx_bd *rxbd = &rxr->rx_desc_ring[RX_RING(index)][RX_IDX(index)]; | 2733 | struct rx_bd *rxbd = &rxr->rx_desc_ring[RX_RING(index)][RX_IDX(index)]; |
2743 | unsigned long align; | ||
2744 | 2734 | ||
2745 | skb = __netdev_alloc_skb(bp->dev, bp->rx_buf_size, gfp); | 2735 | data = kmalloc(bp->rx_buf_size, gfp); |
2746 | if (skb == NULL) { | 2736 | if (!data) |
2747 | return -ENOMEM; | 2737 | return -ENOMEM; |
2748 | } | ||
2749 | |||
2750 | if (unlikely((align = (unsigned long) skb->data & (BNX2_RX_ALIGN - 1)))) | ||
2751 | skb_reserve(skb, BNX2_RX_ALIGN - align); | ||
2752 | 2738 | ||
2753 | mapping = dma_map_single(&bp->pdev->dev, skb->data, bp->rx_buf_use_size, | 2739 | mapping = dma_map_single(&bp->pdev->dev, |
2740 | get_l2_fhdr(data), | ||
2741 | bp->rx_buf_use_size, | ||
2754 | PCI_DMA_FROMDEVICE); | 2742 | PCI_DMA_FROMDEVICE); |
2755 | if (dma_mapping_error(&bp->pdev->dev, mapping)) { | 2743 | if (dma_mapping_error(&bp->pdev->dev, mapping)) { |
2756 | dev_kfree_skb(skb); | 2744 | kfree(data); |
2757 | return -EIO; | 2745 | return -EIO; |
2758 | } | 2746 | } |
2759 | 2747 | ||
2760 | rx_buf->skb = skb; | 2748 | rx_buf->data = data; |
2761 | rx_buf->desc = (struct l2_fhdr *) skb->data; | ||
2762 | dma_unmap_addr_set(rx_buf, mapping, mapping); | 2749 | dma_unmap_addr_set(rx_buf, mapping, mapping); |
2763 | 2750 | ||
2764 | rxbd->rx_bd_haddr_hi = (u64) mapping >> 32; | 2751 | rxbd->rx_bd_haddr_hi = (u64) mapping >> 32; |
@@ -2965,8 +2952,8 @@ bnx2_reuse_rx_skb_pages(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, | |||
2965 | } | 2952 | } |
2966 | 2953 | ||
2967 | static inline void | 2954 | static inline void |
2968 | bnx2_reuse_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, | 2955 | bnx2_reuse_rx_data(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, |
2969 | struct sk_buff *skb, u16 cons, u16 prod) | 2956 | u8 *data, u16 cons, u16 prod) |
2970 | { | 2957 | { |
2971 | struct sw_bd *cons_rx_buf, *prod_rx_buf; | 2958 | struct sw_bd *cons_rx_buf, *prod_rx_buf; |
2972 | struct rx_bd *cons_bd, *prod_bd; | 2959 | struct rx_bd *cons_bd, *prod_bd; |
@@ -2980,8 +2967,7 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, | |||
2980 | 2967 | ||
2981 | rxr->rx_prod_bseq += bp->rx_buf_use_size; | 2968 | rxr->rx_prod_bseq += bp->rx_buf_use_size; |
2982 | 2969 | ||
2983 | prod_rx_buf->skb = skb; | 2970 | prod_rx_buf->data = data; |
2984 | prod_rx_buf->desc = (struct l2_fhdr *) skb->data; | ||
2985 | 2971 | ||
2986 | if (cons == prod) | 2972 | if (cons == prod) |
2987 | return; | 2973 | return; |
@@ -2995,33 +2981,39 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, | |||
2995 | prod_bd->rx_bd_haddr_lo = cons_bd->rx_bd_haddr_lo; | 2981 | prod_bd->rx_bd_haddr_lo = cons_bd->rx_bd_haddr_lo; |
2996 | } | 2982 | } |
2997 | 2983 | ||
2998 | static int | 2984 | static struct sk_buff * |
2999 | bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, | 2985 | bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u8 *data, |
3000 | unsigned int len, unsigned int hdr_len, dma_addr_t dma_addr, | 2986 | unsigned int len, unsigned int hdr_len, dma_addr_t dma_addr, |
3001 | u32 ring_idx) | 2987 | u32 ring_idx) |
3002 | { | 2988 | { |
3003 | int err; | 2989 | int err; |
3004 | u16 prod = ring_idx & 0xffff; | 2990 | u16 prod = ring_idx & 0xffff; |
2991 | struct sk_buff *skb; | ||
3005 | 2992 | ||
3006 | err = bnx2_alloc_rx_skb(bp, rxr, prod, GFP_ATOMIC); | 2993 | err = bnx2_alloc_rx_data(bp, rxr, prod, GFP_ATOMIC); |
3007 | if (unlikely(err)) { | 2994 | if (unlikely(err)) { |
3008 | bnx2_reuse_rx_skb(bp, rxr, skb, (u16) (ring_idx >> 16), prod); | 2995 | bnx2_reuse_rx_data(bp, rxr, data, (u16) (ring_idx >> 16), prod); |
2996 | error: | ||
3009 | if (hdr_len) { | 2997 | if (hdr_len) { |
3010 | unsigned int raw_len = len + 4; | 2998 | unsigned int raw_len = len + 4; |
3011 | int pages = PAGE_ALIGN(raw_len - hdr_len) >> PAGE_SHIFT; | 2999 | int pages = PAGE_ALIGN(raw_len - hdr_len) >> PAGE_SHIFT; |
3012 | 3000 | ||
3013 | bnx2_reuse_rx_skb_pages(bp, rxr, NULL, pages); | 3001 | bnx2_reuse_rx_skb_pages(bp, rxr, NULL, pages); |
3014 | } | 3002 | } |
3015 | return err; | 3003 | return NULL; |
3016 | } | 3004 | } |
3017 | 3005 | ||
3018 | skb_reserve(skb, BNX2_RX_OFFSET); | ||
3019 | dma_unmap_single(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, | 3006 | dma_unmap_single(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, |
3020 | PCI_DMA_FROMDEVICE); | 3007 | PCI_DMA_FROMDEVICE); |
3021 | 3008 | skb = build_skb(data); | |
3009 | if (!skb) { | ||
3010 | kfree(data); | ||
3011 | goto error; | ||
3012 | } | ||
3013 | skb_reserve(skb, ((u8 *)get_l2_fhdr(data) - data) + BNX2_RX_OFFSET); | ||
3022 | if (hdr_len == 0) { | 3014 | if (hdr_len == 0) { |
3023 | skb_put(skb, len); | 3015 | skb_put(skb, len); |
3024 | return 0; | 3016 | return skb; |
3025 | } else { | 3017 | } else { |
3026 | unsigned int i, frag_len, frag_size, pages; | 3018 | unsigned int i, frag_len, frag_size, pages; |
3027 | struct sw_pg *rx_pg; | 3019 | struct sw_pg *rx_pg; |
@@ -3052,7 +3044,7 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, | |||
3052 | skb_frag_size_sub(frag, tail); | 3044 | skb_frag_size_sub(frag, tail); |
3053 | skb->data_len -= tail; | 3045 | skb->data_len -= tail; |
3054 | } | 3046 | } |
3055 | return 0; | 3047 | return skb; |
3056 | } | 3048 | } |
3057 | rx_pg = &rxr->rx_pg_ring[pg_cons]; | 3049 | rx_pg = &rxr->rx_pg_ring[pg_cons]; |
3058 | 3050 | ||
@@ -3074,7 +3066,7 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, | |||
3074 | rxr->rx_pg_prod = pg_prod; | 3066 | rxr->rx_pg_prod = pg_prod; |
3075 | bnx2_reuse_rx_skb_pages(bp, rxr, skb, | 3067 | bnx2_reuse_rx_skb_pages(bp, rxr, skb, |
3076 | pages - i); | 3068 | pages - i); |
3077 | return err; | 3069 | return NULL; |
3078 | } | 3070 | } |
3079 | 3071 | ||
3080 | dma_unmap_page(&bp->pdev->dev, mapping_old, | 3072 | dma_unmap_page(&bp->pdev->dev, mapping_old, |
@@ -3091,7 +3083,7 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, | |||
3091 | rxr->rx_pg_prod = pg_prod; | 3083 | rxr->rx_pg_prod = pg_prod; |
3092 | rxr->rx_pg_cons = pg_cons; | 3084 | rxr->rx_pg_cons = pg_cons; |
3093 | } | 3085 | } |
3094 | return 0; | 3086 | return skb; |
3095 | } | 3087 | } |
3096 | 3088 | ||
3097 | static inline u16 | 3089 | static inline u16 |
@@ -3130,19 +3122,17 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
3130 | struct sw_bd *rx_buf, *next_rx_buf; | 3122 | struct sw_bd *rx_buf, *next_rx_buf; |
3131 | struct sk_buff *skb; | 3123 | struct sk_buff *skb; |
3132 | dma_addr_t dma_addr; | 3124 | dma_addr_t dma_addr; |
3125 | u8 *data; | ||
3133 | 3126 | ||
3134 | sw_ring_cons = RX_RING_IDX(sw_cons); | 3127 | sw_ring_cons = RX_RING_IDX(sw_cons); |
3135 | sw_ring_prod = RX_RING_IDX(sw_prod); | 3128 | sw_ring_prod = RX_RING_IDX(sw_prod); |
3136 | 3129 | ||
3137 | rx_buf = &rxr->rx_buf_ring[sw_ring_cons]; | 3130 | rx_buf = &rxr->rx_buf_ring[sw_ring_cons]; |
3138 | skb = rx_buf->skb; | 3131 | data = rx_buf->data; |
3139 | prefetchw(skb); | 3132 | rx_buf->data = NULL; |
3140 | |||
3141 | next_rx_buf = | ||
3142 | &rxr->rx_buf_ring[RX_RING_IDX(NEXT_RX_BD(sw_cons))]; | ||
3143 | prefetch(next_rx_buf->desc); | ||
3144 | 3133 | ||
3145 | rx_buf->skb = NULL; | 3134 | rx_hdr = get_l2_fhdr(data); |
3135 | prefetch(rx_hdr); | ||
3146 | 3136 | ||
3147 | dma_addr = dma_unmap_addr(rx_buf, mapping); | 3137 | dma_addr = dma_unmap_addr(rx_buf, mapping); |
3148 | 3138 | ||
@@ -3150,7 +3140,10 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
3150 | BNX2_RX_OFFSET + BNX2_RX_COPY_THRESH, | 3140 | BNX2_RX_OFFSET + BNX2_RX_COPY_THRESH, |
3151 | PCI_DMA_FROMDEVICE); | 3141 | PCI_DMA_FROMDEVICE); |
3152 | 3142 | ||
3153 | rx_hdr = rx_buf->desc; | 3143 | next_rx_buf = |
3144 | &rxr->rx_buf_ring[RX_RING_IDX(NEXT_RX_BD(sw_cons))]; | ||
3145 | prefetch(get_l2_fhdr(next_rx_buf->data)); | ||
3146 | |||
3154 | len = rx_hdr->l2_fhdr_pkt_len; | 3147 | len = rx_hdr->l2_fhdr_pkt_len; |
3155 | status = rx_hdr->l2_fhdr_status; | 3148 | status = rx_hdr->l2_fhdr_status; |
3156 | 3149 | ||
@@ -3169,7 +3162,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
3169 | L2_FHDR_ERRORS_TOO_SHORT | | 3162 | L2_FHDR_ERRORS_TOO_SHORT | |
3170 | L2_FHDR_ERRORS_GIANT_FRAME))) { | 3163 | L2_FHDR_ERRORS_GIANT_FRAME))) { |
3171 | 3164 | ||
3172 | bnx2_reuse_rx_skb(bp, rxr, skb, sw_ring_cons, | 3165 | bnx2_reuse_rx_data(bp, rxr, data, sw_ring_cons, |
3173 | sw_ring_prod); | 3166 | sw_ring_prod); |
3174 | if (pg_ring_used) { | 3167 | if (pg_ring_used) { |
3175 | int pages; | 3168 | int pages; |
@@ -3184,30 +3177,29 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
3184 | len -= 4; | 3177 | len -= 4; |
3185 | 3178 | ||
3186 | if (len <= bp->rx_copy_thresh) { | 3179 | if (len <= bp->rx_copy_thresh) { |
3187 | struct sk_buff *new_skb; | 3180 | skb = netdev_alloc_skb(bp->dev, len + 6); |
3188 | 3181 | if (skb == NULL) { | |
3189 | new_skb = netdev_alloc_skb(bp->dev, len + 6); | 3182 | bnx2_reuse_rx_data(bp, rxr, data, sw_ring_cons, |
3190 | if (new_skb == NULL) { | ||
3191 | bnx2_reuse_rx_skb(bp, rxr, skb, sw_ring_cons, | ||
3192 | sw_ring_prod); | 3183 | sw_ring_prod); |
3193 | goto next_rx; | 3184 | goto next_rx; |
3194 | } | 3185 | } |
3195 | 3186 | ||
3196 | /* aligned copy */ | 3187 | /* aligned copy */ |
3197 | skb_copy_from_linear_data_offset(skb, | 3188 | memcpy(skb->data, |
3198 | BNX2_RX_OFFSET - 6, | 3189 | (u8 *)rx_hdr + BNX2_RX_OFFSET - 6, |
3199 | new_skb->data, len + 6); | 3190 | len + 6); |
3200 | skb_reserve(new_skb, 6); | 3191 | skb_reserve(skb, 6); |
3201 | skb_put(new_skb, len); | 3192 | skb_put(skb, len); |
3202 | 3193 | ||
3203 | bnx2_reuse_rx_skb(bp, rxr, skb, | 3194 | bnx2_reuse_rx_data(bp, rxr, data, |
3204 | sw_ring_cons, sw_ring_prod); | 3195 | sw_ring_cons, sw_ring_prod); |
3205 | 3196 | ||
3206 | skb = new_skb; | 3197 | } else { |
3207 | } else if (unlikely(bnx2_rx_skb(bp, rxr, skb, len, hdr_len, | 3198 | skb = bnx2_rx_skb(bp, rxr, data, len, hdr_len, dma_addr, |
3208 | dma_addr, (sw_ring_cons << 16) | sw_ring_prod))) | 3199 | (sw_ring_cons << 16) | sw_ring_prod); |
3209 | goto next_rx; | 3200 | if (!skb) |
3210 | 3201 | goto next_rx; | |
3202 | } | ||
3211 | if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) && | 3203 | if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) && |
3212 | !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) | 3204 | !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) |
3213 | __vlan_hwaccel_put_tag(skb, rx_hdr->l2_fhdr_vlan_tag); | 3205 | __vlan_hwaccel_put_tag(skb, rx_hdr->l2_fhdr_vlan_tag); |
@@ -5234,7 +5226,7 @@ bnx2_init_rx_ring(struct bnx2 *bp, int ring_num) | |||
5234 | 5226 | ||
5235 | ring_prod = prod = rxr->rx_prod; | 5227 | ring_prod = prod = rxr->rx_prod; |
5236 | for (i = 0; i < bp->rx_ring_size; i++) { | 5228 | for (i = 0; i < bp->rx_ring_size; i++) { |
5237 | if (bnx2_alloc_rx_skb(bp, rxr, ring_prod, GFP_KERNEL) < 0) { | 5229 | if (bnx2_alloc_rx_data(bp, rxr, ring_prod, GFP_KERNEL) < 0) { |
5238 | netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d skbs only\n", | 5230 | netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d skbs only\n", |
5239 | ring_num, i, bp->rx_ring_size); | 5231 | ring_num, i, bp->rx_ring_size); |
5240 | break; | 5232 | break; |
@@ -5329,7 +5321,7 @@ bnx2_set_rx_ring_size(struct bnx2 *bp, u32 size) | |||
5329 | rx_size = bp->dev->mtu + ETH_HLEN + BNX2_RX_OFFSET + 8; | 5321 | rx_size = bp->dev->mtu + ETH_HLEN + BNX2_RX_OFFSET + 8; |
5330 | 5322 | ||
5331 | rx_space = SKB_DATA_ALIGN(rx_size + BNX2_RX_ALIGN) + NET_SKB_PAD + | 5323 | rx_space = SKB_DATA_ALIGN(rx_size + BNX2_RX_ALIGN) + NET_SKB_PAD + |
5332 | sizeof(struct skb_shared_info); | 5324 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); |
5333 | 5325 | ||
5334 | bp->rx_copy_thresh = BNX2_RX_COPY_THRESH; | 5326 | bp->rx_copy_thresh = BNX2_RX_COPY_THRESH; |
5335 | bp->rx_pg_ring_size = 0; | 5327 | bp->rx_pg_ring_size = 0; |
@@ -5351,8 +5343,9 @@ bnx2_set_rx_ring_size(struct bnx2 *bp, u32 size) | |||
5351 | } | 5343 | } |
5352 | 5344 | ||
5353 | bp->rx_buf_use_size = rx_size; | 5345 | bp->rx_buf_use_size = rx_size; |
5354 | /* hw alignment */ | 5346 | /* hw alignment + build_skb() overhead*/ |
5355 | bp->rx_buf_size = bp->rx_buf_use_size + BNX2_RX_ALIGN; | 5347 | bp->rx_buf_size = SKB_DATA_ALIGN(bp->rx_buf_use_size + BNX2_RX_ALIGN) + |
5348 | NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); | ||
5356 | bp->rx_jumbo_thresh = rx_size - BNX2_RX_OFFSET; | 5349 | bp->rx_jumbo_thresh = rx_size - BNX2_RX_OFFSET; |
5357 | bp->rx_ring_size = size; | 5350 | bp->rx_ring_size = size; |
5358 | bp->rx_max_ring = bnx2_find_max_ring(size, MAX_RX_RINGS); | 5351 | bp->rx_max_ring = bnx2_find_max_ring(size, MAX_RX_RINGS); |
@@ -5418,9 +5411,9 @@ bnx2_free_rx_skbs(struct bnx2 *bp) | |||
5418 | 5411 | ||
5419 | for (j = 0; j < bp->rx_max_ring_idx; j++) { | 5412 | for (j = 0; j < bp->rx_max_ring_idx; j++) { |
5420 | struct sw_bd *rx_buf = &rxr->rx_buf_ring[j]; | 5413 | struct sw_bd *rx_buf = &rxr->rx_buf_ring[j]; |
5421 | struct sk_buff *skb = rx_buf->skb; | 5414 | u8 *data = rx_buf->data; |
5422 | 5415 | ||
5423 | if (skb == NULL) | 5416 | if (data == NULL) |
5424 | continue; | 5417 | continue; |
5425 | 5418 | ||
5426 | dma_unmap_single(&bp->pdev->dev, | 5419 | dma_unmap_single(&bp->pdev->dev, |
@@ -5428,9 +5421,9 @@ bnx2_free_rx_skbs(struct bnx2 *bp) | |||
5428 | bp->rx_buf_use_size, | 5421 | bp->rx_buf_use_size, |
5429 | PCI_DMA_FROMDEVICE); | 5422 | PCI_DMA_FROMDEVICE); |
5430 | 5423 | ||
5431 | rx_buf->skb = NULL; | 5424 | rx_buf->data = NULL; |
5432 | 5425 | ||
5433 | dev_kfree_skb(skb); | 5426 | kfree(data); |
5434 | } | 5427 | } |
5435 | for (j = 0; j < bp->rx_max_pg_ring_idx; j++) | 5428 | for (j = 0; j < bp->rx_max_pg_ring_idx; j++) |
5436 | bnx2_free_rx_page(bp, rxr, j); | 5429 | bnx2_free_rx_page(bp, rxr, j); |
@@ -5736,7 +5729,8 @@ static int | |||
5736 | bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | 5729 | bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) |
5737 | { | 5730 | { |
5738 | unsigned int pkt_size, num_pkts, i; | 5731 | unsigned int pkt_size, num_pkts, i; |
5739 | struct sk_buff *skb, *rx_skb; | 5732 | struct sk_buff *skb; |
5733 | u8 *data; | ||
5740 | unsigned char *packet; | 5734 | unsigned char *packet; |
5741 | u16 rx_start_idx, rx_idx; | 5735 | u16 rx_start_idx, rx_idx; |
5742 | dma_addr_t map; | 5736 | dma_addr_t map; |
@@ -5828,14 +5822,14 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
5828 | } | 5822 | } |
5829 | 5823 | ||
5830 | rx_buf = &rxr->rx_buf_ring[rx_start_idx]; | 5824 | rx_buf = &rxr->rx_buf_ring[rx_start_idx]; |
5831 | rx_skb = rx_buf->skb; | 5825 | data = rx_buf->data; |
5832 | 5826 | ||
5833 | rx_hdr = rx_buf->desc; | 5827 | rx_hdr = get_l2_fhdr(data); |
5834 | skb_reserve(rx_skb, BNX2_RX_OFFSET); | 5828 | data = (u8 *)rx_hdr + BNX2_RX_OFFSET; |
5835 | 5829 | ||
5836 | dma_sync_single_for_cpu(&bp->pdev->dev, | 5830 | dma_sync_single_for_cpu(&bp->pdev->dev, |
5837 | dma_unmap_addr(rx_buf, mapping), | 5831 | dma_unmap_addr(rx_buf, mapping), |
5838 | bp->rx_buf_size, PCI_DMA_FROMDEVICE); | 5832 | bp->rx_buf_use_size, PCI_DMA_FROMDEVICE); |
5839 | 5833 | ||
5840 | if (rx_hdr->l2_fhdr_status & | 5834 | if (rx_hdr->l2_fhdr_status & |
5841 | (L2_FHDR_ERRORS_BAD_CRC | | 5835 | (L2_FHDR_ERRORS_BAD_CRC | |
@@ -5852,7 +5846,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) | |||
5852 | } | 5846 | } |
5853 | 5847 | ||
5854 | for (i = 14; i < pkt_size; i++) { | 5848 | for (i = 14; i < pkt_size; i++) { |
5855 | if (*(rx_skb->data + i) != (unsigned char) (i & 0xff)) { | 5849 | if (*(data + i) != (unsigned char) (i & 0xff)) { |
5856 | goto loopback_test_done; | 5850 | goto loopback_test_done; |
5857 | } | 5851 | } |
5858 | } | 5852 | } |
@@ -6873,10 +6867,10 @@ bnx2_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
6873 | { | 6867 | { |
6874 | struct bnx2 *bp = netdev_priv(dev); | 6868 | struct bnx2 *bp = netdev_priv(dev); |
6875 | 6869 | ||
6876 | strcpy(info->driver, DRV_MODULE_NAME); | 6870 | strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); |
6877 | strcpy(info->version, DRV_MODULE_VERSION); | 6871 | strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); |
6878 | strcpy(info->bus_info, pci_name(bp->pdev)); | 6872 | strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); |
6879 | strcpy(info->fw_version, bp->fw_version); | 6873 | strlcpy(info->fw_version, bp->fw_version, sizeof(info->fw_version)); |
6880 | } | 6874 | } |
6881 | 6875 | ||
6882 | #define BNX2_REGDUMP_LEN (32 * 1024) | 6876 | #define BNX2_REGDUMP_LEN (32 * 1024) |
@@ -7571,8 +7565,8 @@ bnx2_set_phys_id(struct net_device *dev, enum ethtool_phys_id_state state) | |||
7571 | return 0; | 7565 | return 0; |
7572 | } | 7566 | } |
7573 | 7567 | ||
7574 | static u32 | 7568 | static netdev_features_t |
7575 | bnx2_fix_features(struct net_device *dev, u32 features) | 7569 | bnx2_fix_features(struct net_device *dev, netdev_features_t features) |
7576 | { | 7570 | { |
7577 | struct bnx2 *bp = netdev_priv(dev); | 7571 | struct bnx2 *bp = netdev_priv(dev); |
7578 | 7572 | ||
@@ -7583,7 +7577,7 @@ bnx2_fix_features(struct net_device *dev, u32 features) | |||
7583 | } | 7577 | } |
7584 | 7578 | ||
7585 | static int | 7579 | static int |
7586 | bnx2_set_features(struct net_device *dev, u32 features) | 7580 | bnx2_set_features(struct net_device *dev, netdev_features_t features) |
7587 | { | 7581 | { |
7588 | struct bnx2 *bp = netdev_priv(dev); | 7582 | struct bnx2 *bp = netdev_priv(dev); |
7589 | 7583 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2.h b/drivers/net/ethernet/broadcom/bnx2.h index 99d31a7d6aaa..1db2d51ba3f1 100644 --- a/drivers/net/ethernet/broadcom/bnx2.h +++ b/drivers/net/ethernet/broadcom/bnx2.h | |||
@@ -6563,12 +6563,25 @@ struct l2_fhdr { | |||
6563 | #define MB_TX_CID_ADDR MB_GET_CID_ADDR(TX_CID) | 6563 | #define MB_TX_CID_ADDR MB_GET_CID_ADDR(TX_CID) |
6564 | #define MB_RX_CID_ADDR MB_GET_CID_ADDR(RX_CID) | 6564 | #define MB_RX_CID_ADDR MB_GET_CID_ADDR(RX_CID) |
6565 | 6565 | ||
6566 | /* | ||
6567 | * This driver uses new build_skb() API : | ||
6568 | * RX ring buffer contains pointer to kmalloc() data only, | ||
6569 | * skb are built only after Hardware filled the frame. | ||
6570 | */ | ||
6566 | struct sw_bd { | 6571 | struct sw_bd { |
6567 | struct sk_buff *skb; | 6572 | u8 *data; |
6568 | struct l2_fhdr *desc; | ||
6569 | DEFINE_DMA_UNMAP_ADDR(mapping); | 6573 | DEFINE_DMA_UNMAP_ADDR(mapping); |
6570 | }; | 6574 | }; |
6571 | 6575 | ||
6576 | /* Its faster to compute this from data than storing it in sw_bd | ||
6577 | * (less cache misses) | ||
6578 | */ | ||
6579 | static inline struct l2_fhdr *get_l2_fhdr(u8 *data) | ||
6580 | { | ||
6581 | return (struct l2_fhdr *)(PTR_ALIGN(data, BNX2_RX_ALIGN) + NET_SKB_PAD); | ||
6582 | } | ||
6583 | |||
6584 | |||
6572 | struct sw_pg { | 6585 | struct sw_pg { |
6573 | struct page *page; | 6586 | struct page *page; |
6574 | DEFINE_DMA_UNMAP_ADDR(mapping); | 6587 | DEFINE_DMA_UNMAP_ADDR(mapping); |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index aec7212ac983..0f7b7a463eba 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | |||
@@ -23,8 +23,8 @@ | |||
23 | * (you will need to reboot afterwards) */ | 23 | * (you will need to reboot afterwards) */ |
24 | /* #define BNX2X_STOP_ON_ERROR */ | 24 | /* #define BNX2X_STOP_ON_ERROR */ |
25 | 25 | ||
26 | #define DRV_MODULE_VERSION "1.70.30-0" | 26 | #define DRV_MODULE_VERSION "1.70.35-0" |
27 | #define DRV_MODULE_RELDATE "2011/10/25" | 27 | #define DRV_MODULE_RELDATE "2011/11/10" |
28 | #define BNX2X_BC_VER 0x040200 | 28 | #define BNX2X_BC_VER 0x040200 |
29 | 29 | ||
30 | #if defined(CONFIG_DCB) | 30 | #if defined(CONFIG_DCB) |
@@ -293,8 +293,13 @@ enum { | |||
293 | #define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp)) | 293 | #define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp)) |
294 | 294 | ||
295 | /* fast path */ | 295 | /* fast path */ |
296 | /* | ||
297 | * This driver uses new build_skb() API : | ||
298 | * RX ring buffer contains pointer to kmalloc() data only, | ||
299 | * skb are built only after Hardware filled the frame. | ||
300 | */ | ||
296 | struct sw_rx_bd { | 301 | struct sw_rx_bd { |
297 | struct sk_buff *skb; | 302 | u8 *data; |
298 | DEFINE_DMA_UNMAP_ADDR(mapping); | 303 | DEFINE_DMA_UNMAP_ADDR(mapping); |
299 | }; | 304 | }; |
300 | 305 | ||
@@ -411,8 +416,7 @@ union db_prod { | |||
411 | 416 | ||
412 | 417 | ||
413 | /* Number of u64 elements in SGE mask array */ | 418 | /* Number of u64 elements in SGE mask array */ |
414 | #define RX_SGE_MASK_LEN ((NUM_RX_SGE_PAGES * RX_SGE_CNT) / \ | 419 | #define RX_SGE_MASK_LEN (NUM_RX_SGE / BIT_VEC64_ELEM_SZ) |
415 | BIT_VEC64_ELEM_SZ) | ||
416 | #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1) | 420 | #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1) |
417 | #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK) | 421 | #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK) |
418 | 422 | ||
@@ -425,8 +429,8 @@ union host_hc_status_block { | |||
425 | 429 | ||
426 | struct bnx2x_agg_info { | 430 | struct bnx2x_agg_info { |
427 | /* | 431 | /* |
428 | * First aggregation buffer is an skb, the following - are pages. | 432 | * First aggregation buffer is a data buffer, the following - are pages. |
429 | * We will preallocate the skbs for each aggregation when | 433 | * We will preallocate the data buffer for each aggregation when |
430 | * we open the interface and will replace the BD at the consumer | 434 | * we open the interface and will replace the BD at the consumer |
431 | * with this one when we receive the TPA_START CQE in order to | 435 | * with this one when we receive the TPA_START CQE in order to |
432 | * keep the Rx BD ring consistent. | 436 | * keep the Rx BD ring consistent. |
@@ -440,6 +444,7 @@ struct bnx2x_agg_info { | |||
440 | u16 parsing_flags; | 444 | u16 parsing_flags; |
441 | u16 vlan_tag; | 445 | u16 vlan_tag; |
442 | u16 len_on_bd; | 446 | u16 len_on_bd; |
447 | u32 rxhash; | ||
443 | }; | 448 | }; |
444 | 449 | ||
445 | #define Q_STATS_OFFSET32(stat_name) \ | 450 | #define Q_STATS_OFFSET32(stat_name) \ |
@@ -507,6 +512,7 @@ struct bnx2x_fastpath { | |||
507 | __le16 fp_hc_idx; | 512 | __le16 fp_hc_idx; |
508 | 513 | ||
509 | u8 index; /* number in fp array */ | 514 | u8 index; /* number in fp array */ |
515 | u8 rx_queue; /* index for skb_record */ | ||
510 | u8 cl_id; /* eth client id */ | 516 | u8 cl_id; /* eth client id */ |
511 | u8 cl_qzone_id; | 517 | u8 cl_qzone_id; |
512 | u8 fw_sb_id; /* status block number in FW */ | 518 | u8 fw_sb_id; /* status block number in FW */ |
@@ -1141,6 +1147,7 @@ struct bnx2x_fw_stats_data { | |||
1141 | enum { | 1147 | enum { |
1142 | BNX2X_SP_RTNL_SETUP_TC, | 1148 | BNX2X_SP_RTNL_SETUP_TC, |
1143 | BNX2X_SP_RTNL_TX_TIMEOUT, | 1149 | BNX2X_SP_RTNL_TX_TIMEOUT, |
1150 | BNX2X_SP_RTNL_FAN_FAILURE, | ||
1144 | }; | 1151 | }; |
1145 | 1152 | ||
1146 | 1153 | ||
@@ -1186,10 +1193,20 @@ struct bnx2x { | |||
1186 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 | 1193 | #define ETH_MAX_JUMBO_PACKET_SIZE 9600 |
1187 | 1194 | ||
1188 | /* Max supported alignment is 256 (8 shift) */ | 1195 | /* Max supported alignment is 256 (8 shift) */ |
1189 | #define BNX2X_RX_ALIGN_SHIFT ((L1_CACHE_SHIFT < 8) ? \ | 1196 | #define BNX2X_RX_ALIGN_SHIFT min(8, L1_CACHE_SHIFT) |
1190 | L1_CACHE_SHIFT : 8) | 1197 | |
1191 | /* FW use 2 Cache lines Alignment for start packet and size */ | 1198 | /* FW uses 2 Cache lines Alignment for start packet and size |
1192 | #define BNX2X_FW_RX_ALIGN (2 << BNX2X_RX_ALIGN_SHIFT) | 1199 | * |
1200 | * We assume skb_build() uses sizeof(struct skb_shared_info) bytes | ||
1201 | * at the end of skb->data, to avoid wasting a full cache line. | ||
1202 | * This reduces memory use (skb->truesize). | ||
1203 | */ | ||
1204 | #define BNX2X_FW_RX_ALIGN_START (1UL << BNX2X_RX_ALIGN_SHIFT) | ||
1205 | |||
1206 | #define BNX2X_FW_RX_ALIGN_END \ | ||
1207 | max(1UL << BNX2X_RX_ALIGN_SHIFT, \ | ||
1208 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) | ||
1209 | |||
1193 | #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5) | 1210 | #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5) |
1194 | 1211 | ||
1195 | struct host_sp_status_block *def_status_blk; | 1212 | struct host_sp_status_block *def_status_blk; |
@@ -1984,13 +2001,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, | |||
1984 | #define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \ | 2001 | #define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \ |
1985 | AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR) | 2002 | AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR) |
1986 | 2003 | ||
1987 | #define RSS_FLAGS(bp) \ | ||
1988 | (TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY | \ | ||
1989 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY | \ | ||
1990 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY | \ | ||
1991 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | \ | ||
1992 | (bp->multi_mode << \ | ||
1993 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT)) | ||
1994 | #define MULTI_MASK 0x7f | 2004 | #define MULTI_MASK 0x7f |
1995 | 2005 | ||
1996 | 2006 | ||
@@ -2055,6 +2065,8 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, | |||
2055 | #define BNX2X_VPD_LEN 128 | 2065 | #define BNX2X_VPD_LEN 128 |
2056 | #define VENDOR_ID_LEN 4 | 2066 | #define VENDOR_ID_LEN 4 |
2057 | 2067 | ||
2068 | int bnx2x_close(struct net_device *dev); | ||
2069 | |||
2058 | /* Congestion management fairness mode */ | 2070 | /* Congestion management fairness mode */ |
2059 | #define CMNG_FNS_NONE 0 | 2071 | #define CMNG_FNS_NONE 0 |
2060 | #define CMNG_FNS_MINMAX 1 | 2072 | #define CMNG_FNS_MINMAX 1 |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 580b44edb066..8336c784db49 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | |||
@@ -79,19 +79,21 @@ static inline void bnx2x_bz_fp(struct bnx2x *bp, int index) | |||
79 | * @to: destination FP index | 79 | * @to: destination FP index |
80 | * | 80 | * |
81 | * Makes sure the contents of the bp->fp[to].napi is kept | 81 | * Makes sure the contents of the bp->fp[to].napi is kept |
82 | * intact. | 82 | * intact. This is done by first copying the napi struct from |
83 | * the target to the source, and then mem copying the entire | ||
84 | * source onto the target | ||
83 | */ | 85 | */ |
84 | static inline void bnx2x_move_fp(struct bnx2x *bp, int from, int to) | 86 | static inline void bnx2x_move_fp(struct bnx2x *bp, int from, int to) |
85 | { | 87 | { |
86 | struct bnx2x_fastpath *from_fp = &bp->fp[from]; | 88 | struct bnx2x_fastpath *from_fp = &bp->fp[from]; |
87 | struct bnx2x_fastpath *to_fp = &bp->fp[to]; | 89 | struct bnx2x_fastpath *to_fp = &bp->fp[to]; |
88 | struct napi_struct orig_napi = to_fp->napi; | 90 | |
91 | /* Copy the NAPI object as it has been already initialized */ | ||
92 | from_fp->napi = to_fp->napi; | ||
93 | |||
89 | /* Move bnx2x_fastpath contents */ | 94 | /* Move bnx2x_fastpath contents */ |
90 | memcpy(to_fp, from_fp, sizeof(*to_fp)); | 95 | memcpy(to_fp, from_fp, sizeof(*to_fp)); |
91 | to_fp->index = to; | 96 | to_fp->index = to; |
92 | |||
93 | /* Restore the NAPI object as it has been already initialized */ | ||
94 | to_fp->napi = orig_napi; | ||
95 | } | 97 | } |
96 | 98 | ||
97 | int load_count[2][3] = { {0} }; /* per-path: 0-common, 1-port0, 2-port1 */ | 99 | int load_count[2][3] = { {0} }; /* per-path: 0-common, 1-port0, 2-port1 */ |
@@ -292,8 +294,21 @@ static void bnx2x_update_sge_prod(struct bnx2x_fastpath *fp, | |||
292 | fp->last_max_sge, fp->rx_sge_prod); | 294 | fp->last_max_sge, fp->rx_sge_prod); |
293 | } | 295 | } |
294 | 296 | ||
297 | /* Set Toeplitz hash value in the skb using the value from the | ||
298 | * CQE (calculated by HW). | ||
299 | */ | ||
300 | static u32 bnx2x_get_rxhash(const struct bnx2x *bp, | ||
301 | const struct eth_fast_path_rx_cqe *cqe) | ||
302 | { | ||
303 | /* Set Toeplitz hash from CQE */ | ||
304 | if ((bp->dev->features & NETIF_F_RXHASH) && | ||
305 | (cqe->status_flags & ETH_FAST_PATH_RX_CQE_RSS_HASH_FLG)) | ||
306 | return le32_to_cpu(cqe->rss_hash_result); | ||
307 | return 0; | ||
308 | } | ||
309 | |||
295 | static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, | 310 | static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, |
296 | struct sk_buff *skb, u16 cons, u16 prod, | 311 | u16 cons, u16 prod, |
297 | struct eth_fast_path_rx_cqe *cqe) | 312 | struct eth_fast_path_rx_cqe *cqe) |
298 | { | 313 | { |
299 | struct bnx2x *bp = fp->bp; | 314 | struct bnx2x *bp = fp->bp; |
@@ -308,9 +323,9 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, | |||
308 | if (tpa_info->tpa_state != BNX2X_TPA_STOP) | 323 | if (tpa_info->tpa_state != BNX2X_TPA_STOP) |
309 | BNX2X_ERR("start of bin not in stop [%d]\n", queue); | 324 | BNX2X_ERR("start of bin not in stop [%d]\n", queue); |
310 | 325 | ||
311 | /* Try to map an empty skb from the aggregation info */ | 326 | /* Try to map an empty data buffer from the aggregation info */ |
312 | mapping = dma_map_single(&bp->pdev->dev, | 327 | mapping = dma_map_single(&bp->pdev->dev, |
313 | first_buf->skb->data, | 328 | first_buf->data + NET_SKB_PAD, |
314 | fp->rx_buf_size, DMA_FROM_DEVICE); | 329 | fp->rx_buf_size, DMA_FROM_DEVICE); |
315 | /* | 330 | /* |
316 | * ...if it fails - move the skb from the consumer to the producer | 331 | * ...if it fails - move the skb from the consumer to the producer |
@@ -320,15 +335,15 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, | |||
320 | 335 | ||
321 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { | 336 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { |
322 | /* Move the BD from the consumer to the producer */ | 337 | /* Move the BD from the consumer to the producer */ |
323 | bnx2x_reuse_rx_skb(fp, cons, prod); | 338 | bnx2x_reuse_rx_data(fp, cons, prod); |
324 | tpa_info->tpa_state = BNX2X_TPA_ERROR; | 339 | tpa_info->tpa_state = BNX2X_TPA_ERROR; |
325 | return; | 340 | return; |
326 | } | 341 | } |
327 | 342 | ||
328 | /* move empty skb from pool to prod */ | 343 | /* move empty data from pool to prod */ |
329 | prod_rx_buf->skb = first_buf->skb; | 344 | prod_rx_buf->data = first_buf->data; |
330 | dma_unmap_addr_set(prod_rx_buf, mapping, mapping); | 345 | dma_unmap_addr_set(prod_rx_buf, mapping, mapping); |
331 | /* point prod_bd to new skb */ | 346 | /* point prod_bd to new data */ |
332 | prod_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); | 347 | prod_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); |
333 | prod_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); | 348 | prod_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); |
334 | 349 | ||
@@ -342,6 +357,7 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, | |||
342 | tpa_info->tpa_state = BNX2X_TPA_START; | 357 | tpa_info->tpa_state = BNX2X_TPA_START; |
343 | tpa_info->len_on_bd = le16_to_cpu(cqe->len_on_bd); | 358 | tpa_info->len_on_bd = le16_to_cpu(cqe->len_on_bd); |
344 | tpa_info->placement_offset = cqe->placement_offset; | 359 | tpa_info->placement_offset = cqe->placement_offset; |
360 | tpa_info->rxhash = bnx2x_get_rxhash(bp, cqe); | ||
345 | 361 | ||
346 | #ifdef BNX2X_STOP_ON_ERROR | 362 | #ifdef BNX2X_STOP_ON_ERROR |
347 | fp->tpa_queue_used |= (1 << queue); | 363 | fp->tpa_queue_used |= (1 << queue); |
@@ -469,11 +485,12 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, | |||
469 | { | 485 | { |
470 | struct bnx2x_agg_info *tpa_info = &fp->tpa_info[queue]; | 486 | struct bnx2x_agg_info *tpa_info = &fp->tpa_info[queue]; |
471 | struct sw_rx_bd *rx_buf = &tpa_info->first_buf; | 487 | struct sw_rx_bd *rx_buf = &tpa_info->first_buf; |
472 | u8 pad = tpa_info->placement_offset; | 488 | u32 pad = tpa_info->placement_offset; |
473 | u16 len = tpa_info->len_on_bd; | 489 | u16 len = tpa_info->len_on_bd; |
474 | struct sk_buff *skb = rx_buf->skb; | 490 | struct sk_buff *skb = NULL; |
491 | u8 *data = rx_buf->data; | ||
475 | /* alloc new skb */ | 492 | /* alloc new skb */ |
476 | struct sk_buff *new_skb; | 493 | u8 *new_data; |
477 | u8 old_tpa_state = tpa_info->tpa_state; | 494 | u8 old_tpa_state = tpa_info->tpa_state; |
478 | 495 | ||
479 | tpa_info->tpa_state = BNX2X_TPA_STOP; | 496 | tpa_info->tpa_state = BNX2X_TPA_STOP; |
@@ -484,18 +501,18 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, | |||
484 | if (old_tpa_state == BNX2X_TPA_ERROR) | 501 | if (old_tpa_state == BNX2X_TPA_ERROR) |
485 | goto drop; | 502 | goto drop; |
486 | 503 | ||
487 | /* Try to allocate the new skb */ | 504 | /* Try to allocate the new data */ |
488 | new_skb = netdev_alloc_skb(bp->dev, fp->rx_buf_size); | 505 | new_data = kmalloc(fp->rx_buf_size + NET_SKB_PAD, GFP_ATOMIC); |
489 | 506 | ||
490 | /* Unmap skb in the pool anyway, as we are going to change | 507 | /* Unmap skb in the pool anyway, as we are going to change |
491 | pool entry status to BNX2X_TPA_STOP even if new skb allocation | 508 | pool entry status to BNX2X_TPA_STOP even if new skb allocation |
492 | fails. */ | 509 | fails. */ |
493 | dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), | 510 | dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), |
494 | fp->rx_buf_size, DMA_FROM_DEVICE); | 511 | fp->rx_buf_size, DMA_FROM_DEVICE); |
512 | if (likely(new_data)) | ||
513 | skb = build_skb(data); | ||
495 | 514 | ||
496 | if (likely(new_skb)) { | 515 | if (likely(skb)) { |
497 | prefetch(skb); | ||
498 | prefetch(((char *)(skb)) + L1_CACHE_BYTES); | ||
499 | 516 | ||
500 | #ifdef BNX2X_STOP_ON_ERROR | 517 | #ifdef BNX2X_STOP_ON_ERROR |
501 | if (pad + len > fp->rx_buf_size) { | 518 | if (pad + len > fp->rx_buf_size) { |
@@ -507,8 +524,9 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, | |||
507 | } | 524 | } |
508 | #endif | 525 | #endif |
509 | 526 | ||
510 | skb_reserve(skb, pad); | 527 | skb_reserve(skb, pad + NET_SKB_PAD); |
511 | skb_put(skb, len); | 528 | skb_put(skb, len); |
529 | skb->rxhash = tpa_info->rxhash; | ||
512 | 530 | ||
513 | skb->protocol = eth_type_trans(skb, bp->dev); | 531 | skb->protocol = eth_type_trans(skb, bp->dev); |
514 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 532 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
@@ -524,8 +542,8 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, | |||
524 | } | 542 | } |
525 | 543 | ||
526 | 544 | ||
527 | /* put new skb in bin */ | 545 | /* put new data in bin */ |
528 | rx_buf->skb = new_skb; | 546 | rx_buf->data = new_data; |
529 | 547 | ||
530 | return; | 548 | return; |
531 | } | 549 | } |
@@ -537,19 +555,6 @@ drop: | |||
537 | fp->eth_q_stats.rx_skb_alloc_failed++; | 555 | fp->eth_q_stats.rx_skb_alloc_failed++; |
538 | } | 556 | } |
539 | 557 | ||
540 | /* Set Toeplitz hash value in the skb using the value from the | ||
541 | * CQE (calculated by HW). | ||
542 | */ | ||
543 | static inline void bnx2x_set_skb_rxhash(struct bnx2x *bp, union eth_rx_cqe *cqe, | ||
544 | struct sk_buff *skb) | ||
545 | { | ||
546 | /* Set Toeplitz hash from CQE */ | ||
547 | if ((bp->dev->features & NETIF_F_RXHASH) && | ||
548 | (cqe->fast_path_cqe.status_flags & | ||
549 | ETH_FAST_PATH_RX_CQE_RSS_HASH_FLG)) | ||
550 | skb->rxhash = | ||
551 | le32_to_cpu(cqe->fast_path_cqe.rss_hash_result); | ||
552 | } | ||
553 | 558 | ||
554 | int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | 559 | int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) |
555 | { | 560 | { |
@@ -592,6 +597,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | |||
592 | u8 cqe_fp_flags; | 597 | u8 cqe_fp_flags; |
593 | enum eth_rx_cqe_type cqe_fp_type; | 598 | enum eth_rx_cqe_type cqe_fp_type; |
594 | u16 len, pad; | 599 | u16 len, pad; |
600 | u8 *data; | ||
595 | 601 | ||
596 | #ifdef BNX2X_STOP_ON_ERROR | 602 | #ifdef BNX2X_STOP_ON_ERROR |
597 | if (unlikely(bp->panic)) | 603 | if (unlikely(bp->panic)) |
@@ -602,13 +608,6 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | |||
602 | bd_prod = RX_BD(bd_prod); | 608 | bd_prod = RX_BD(bd_prod); |
603 | bd_cons = RX_BD(bd_cons); | 609 | bd_cons = RX_BD(bd_cons); |
604 | 610 | ||
605 | /* Prefetch the page containing the BD descriptor | ||
606 | at producer's index. It will be needed when new skb is | ||
607 | allocated */ | ||
608 | prefetch((void *)(PAGE_ALIGN((unsigned long) | ||
609 | (&fp->rx_desc_ring[bd_prod])) - | ||
610 | PAGE_SIZE + 1)); | ||
611 | |||
612 | cqe = &fp->rx_comp_ring[comp_ring_cons]; | 611 | cqe = &fp->rx_comp_ring[comp_ring_cons]; |
613 | cqe_fp = &cqe->fast_path_cqe; | 612 | cqe_fp = &cqe->fast_path_cqe; |
614 | cqe_fp_flags = cqe_fp->type_error_flags; | 613 | cqe_fp_flags = cqe_fp->type_error_flags; |
@@ -624,125 +623,110 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | |||
624 | if (unlikely(CQE_TYPE_SLOW(cqe_fp_type))) { | 623 | if (unlikely(CQE_TYPE_SLOW(cqe_fp_type))) { |
625 | bnx2x_sp_event(fp, cqe); | 624 | bnx2x_sp_event(fp, cqe); |
626 | goto next_cqe; | 625 | goto next_cqe; |
626 | } | ||
627 | rx_buf = &fp->rx_buf_ring[bd_cons]; | ||
628 | data = rx_buf->data; | ||
627 | 629 | ||
628 | /* this is an rx packet */ | 630 | if (!CQE_TYPE_FAST(cqe_fp_type)) { |
629 | } else { | ||
630 | rx_buf = &fp->rx_buf_ring[bd_cons]; | ||
631 | skb = rx_buf->skb; | ||
632 | prefetch(skb); | ||
633 | |||
634 | if (!CQE_TYPE_FAST(cqe_fp_type)) { | ||
635 | #ifdef BNX2X_STOP_ON_ERROR | 631 | #ifdef BNX2X_STOP_ON_ERROR |
636 | /* sanity check */ | 632 | /* sanity check */ |
637 | if (fp->disable_tpa && | 633 | if (fp->disable_tpa && |
638 | (CQE_TYPE_START(cqe_fp_type) || | 634 | (CQE_TYPE_START(cqe_fp_type) || |
639 | CQE_TYPE_STOP(cqe_fp_type))) | 635 | CQE_TYPE_STOP(cqe_fp_type))) |
640 | BNX2X_ERR("START/STOP packet while " | 636 | BNX2X_ERR("START/STOP packet while " |
641 | "disable_tpa type %x\n", | 637 | "disable_tpa type %x\n", |
642 | CQE_TYPE(cqe_fp_type)); | 638 | CQE_TYPE(cqe_fp_type)); |
643 | #endif | 639 | #endif |
644 | 640 | ||
645 | if (CQE_TYPE_START(cqe_fp_type)) { | 641 | if (CQE_TYPE_START(cqe_fp_type)) { |
646 | u16 queue = cqe_fp->queue_index; | 642 | u16 queue = cqe_fp->queue_index; |
647 | DP(NETIF_MSG_RX_STATUS, | 643 | DP(NETIF_MSG_RX_STATUS, |
648 | "calling tpa_start on queue %d\n", | 644 | "calling tpa_start on queue %d\n", |
649 | queue); | 645 | queue); |
650 | |||
651 | bnx2x_tpa_start(fp, queue, skb, | ||
652 | bd_cons, bd_prod, | ||
653 | cqe_fp); | ||
654 | |||
655 | /* Set Toeplitz hash for LRO skb */ | ||
656 | bnx2x_set_skb_rxhash(bp, cqe, skb); | ||
657 | 646 | ||
658 | goto next_rx; | 647 | bnx2x_tpa_start(fp, queue, |
659 | 648 | bd_cons, bd_prod, | |
660 | } else { | 649 | cqe_fp); |
661 | u16 queue = | 650 | goto next_rx; |
662 | cqe->end_agg_cqe.queue_index; | 651 | } else { |
663 | DP(NETIF_MSG_RX_STATUS, | 652 | u16 queue = |
664 | "calling tpa_stop on queue %d\n", | 653 | cqe->end_agg_cqe.queue_index; |
665 | queue); | 654 | DP(NETIF_MSG_RX_STATUS, |
666 | 655 | "calling tpa_stop on queue %d\n", | |
667 | bnx2x_tpa_stop(bp, fp, queue, | 656 | queue); |
668 | &cqe->end_agg_cqe, | 657 | |
669 | comp_ring_cons); | 658 | bnx2x_tpa_stop(bp, fp, queue, |
659 | &cqe->end_agg_cqe, | ||
660 | comp_ring_cons); | ||
670 | #ifdef BNX2X_STOP_ON_ERROR | 661 | #ifdef BNX2X_STOP_ON_ERROR |
671 | if (bp->panic) | 662 | if (bp->panic) |
672 | return 0; | 663 | return 0; |
673 | #endif | 664 | #endif |
674 | 665 | ||
675 | bnx2x_update_sge_prod(fp, cqe_fp); | 666 | bnx2x_update_sge_prod(fp, cqe_fp); |
676 | goto next_cqe; | 667 | goto next_cqe; |
677 | } | ||
678 | } | 668 | } |
679 | /* non TPA */ | 669 | } |
680 | len = le16_to_cpu(cqe_fp->pkt_len); | 670 | /* non TPA */ |
681 | pad = cqe_fp->placement_offset; | 671 | len = le16_to_cpu(cqe_fp->pkt_len); |
682 | dma_sync_single_for_cpu(&bp->pdev->dev, | 672 | pad = cqe_fp->placement_offset; |
673 | dma_sync_single_for_cpu(&bp->pdev->dev, | ||
683 | dma_unmap_addr(rx_buf, mapping), | 674 | dma_unmap_addr(rx_buf, mapping), |
684 | pad + RX_COPY_THRESH, | 675 | pad + RX_COPY_THRESH, |
685 | DMA_FROM_DEVICE); | 676 | DMA_FROM_DEVICE); |
686 | prefetch(((char *)(skb)) + L1_CACHE_BYTES); | 677 | pad += NET_SKB_PAD; |
678 | prefetch(data + pad); /* speedup eth_type_trans() */ | ||
679 | /* is this an error packet? */ | ||
680 | if (unlikely(cqe_fp_flags & ETH_RX_ERROR_FALGS)) { | ||
681 | DP(NETIF_MSG_RX_ERR, | ||
682 | "ERROR flags %x rx packet %u\n", | ||
683 | cqe_fp_flags, sw_comp_cons); | ||
684 | fp->eth_q_stats.rx_err_discard_pkt++; | ||
685 | goto reuse_rx; | ||
686 | } | ||
687 | 687 | ||
688 | /* is this an error packet? */ | 688 | /* Since we don't have a jumbo ring |
689 | if (unlikely(cqe_fp_flags & ETH_RX_ERROR_FALGS)) { | 689 | * copy small packets if mtu > 1500 |
690 | */ | ||
691 | if ((bp->dev->mtu > ETH_MAX_PACKET_SIZE) && | ||
692 | (len <= RX_COPY_THRESH)) { | ||
693 | skb = netdev_alloc_skb_ip_align(bp->dev, len); | ||
694 | if (skb == NULL) { | ||
690 | DP(NETIF_MSG_RX_ERR, | 695 | DP(NETIF_MSG_RX_ERR, |
691 | "ERROR flags %x rx packet %u\n", | 696 | "ERROR packet dropped because of alloc failure\n"); |
692 | cqe_fp_flags, sw_comp_cons); | 697 | fp->eth_q_stats.rx_skb_alloc_failed++; |
693 | fp->eth_q_stats.rx_err_discard_pkt++; | ||
694 | goto reuse_rx; | 698 | goto reuse_rx; |
695 | } | 699 | } |
696 | 700 | memcpy(skb->data, data + pad, len); | |
697 | /* Since we don't have a jumbo ring | 701 | bnx2x_reuse_rx_data(fp, bd_cons, bd_prod); |
698 | * copy small packets if mtu > 1500 | 702 | } else { |
699 | */ | 703 | if (likely(bnx2x_alloc_rx_data(bp, fp, bd_prod) == 0)) { |
700 | if ((bp->dev->mtu > ETH_MAX_PACKET_SIZE) && | ||
701 | (len <= RX_COPY_THRESH)) { | ||
702 | struct sk_buff *new_skb; | ||
703 | |||
704 | new_skb = netdev_alloc_skb(bp->dev, len + pad); | ||
705 | if (new_skb == NULL) { | ||
706 | DP(NETIF_MSG_RX_ERR, | ||
707 | "ERROR packet dropped " | ||
708 | "because of alloc failure\n"); | ||
709 | fp->eth_q_stats.rx_skb_alloc_failed++; | ||
710 | goto reuse_rx; | ||
711 | } | ||
712 | |||
713 | /* aligned copy */ | ||
714 | skb_copy_from_linear_data_offset(skb, pad, | ||
715 | new_skb->data + pad, len); | ||
716 | skb_reserve(new_skb, pad); | ||
717 | skb_put(new_skb, len); | ||
718 | |||
719 | bnx2x_reuse_rx_skb(fp, bd_cons, bd_prod); | ||
720 | |||
721 | skb = new_skb; | ||
722 | |||
723 | } else | ||
724 | if (likely(bnx2x_alloc_rx_skb(bp, fp, bd_prod) == 0)) { | ||
725 | dma_unmap_single(&bp->pdev->dev, | 704 | dma_unmap_single(&bp->pdev->dev, |
726 | dma_unmap_addr(rx_buf, mapping), | 705 | dma_unmap_addr(rx_buf, mapping), |
727 | fp->rx_buf_size, | 706 | fp->rx_buf_size, |
728 | DMA_FROM_DEVICE); | 707 | DMA_FROM_DEVICE); |
708 | skb = build_skb(data); | ||
709 | if (unlikely(!skb)) { | ||
710 | kfree(data); | ||
711 | fp->eth_q_stats.rx_skb_alloc_failed++; | ||
712 | goto next_rx; | ||
713 | } | ||
729 | skb_reserve(skb, pad); | 714 | skb_reserve(skb, pad); |
730 | skb_put(skb, len); | ||
731 | |||
732 | } else { | 715 | } else { |
733 | DP(NETIF_MSG_RX_ERR, | 716 | DP(NETIF_MSG_RX_ERR, |
734 | "ERROR packet dropped because " | 717 | "ERROR packet dropped because " |
735 | "of alloc failure\n"); | 718 | "of alloc failure\n"); |
736 | fp->eth_q_stats.rx_skb_alloc_failed++; | 719 | fp->eth_q_stats.rx_skb_alloc_failed++; |
737 | reuse_rx: | 720 | reuse_rx: |
738 | bnx2x_reuse_rx_skb(fp, bd_cons, bd_prod); | 721 | bnx2x_reuse_rx_data(fp, bd_cons, bd_prod); |
739 | goto next_rx; | 722 | goto next_rx; |
740 | } | 723 | } |
741 | 724 | ||
725 | skb_put(skb, len); | ||
742 | skb->protocol = eth_type_trans(skb, bp->dev); | 726 | skb->protocol = eth_type_trans(skb, bp->dev); |
743 | 727 | ||
744 | /* Set Toeplitz hash for a none-LRO skb */ | 728 | /* Set Toeplitz hash for a none-LRO skb */ |
745 | bnx2x_set_skb_rxhash(bp, cqe, skb); | 729 | skb->rxhash = bnx2x_get_rxhash(bp, cqe_fp); |
746 | 730 | ||
747 | skb_checksum_none_assert(skb); | 731 | skb_checksum_none_assert(skb); |
748 | 732 | ||
@@ -755,7 +739,7 @@ reuse_rx: | |||
755 | } | 739 | } |
756 | } | 740 | } |
757 | 741 | ||
758 | skb_record_rx_queue(skb, fp->index); | 742 | skb_record_rx_queue(skb, fp->rx_queue); |
759 | 743 | ||
760 | if (le16_to_cpu(cqe_fp->pars_flags.flags) & | 744 | if (le16_to_cpu(cqe_fp->pars_flags.flags) & |
761 | PARSING_FLAGS_VLAN) | 745 | PARSING_FLAGS_VLAN) |
@@ -765,7 +749,7 @@ reuse_rx: | |||
765 | 749 | ||
766 | 750 | ||
767 | next_rx: | 751 | next_rx: |
768 | rx_buf->skb = NULL; | 752 | rx_buf->data = NULL; |
769 | 753 | ||
770 | bd_cons = NEXT_RX_IDX(bd_cons); | 754 | bd_cons = NEXT_RX_IDX(bd_cons); |
771 | bd_prod = NEXT_RX_IDX(bd_prod); | 755 | bd_prod = NEXT_RX_IDX(bd_prod); |
@@ -1011,9 +995,9 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) | |||
1011 | struct sw_rx_bd *first_buf = | 995 | struct sw_rx_bd *first_buf = |
1012 | &tpa_info->first_buf; | 996 | &tpa_info->first_buf; |
1013 | 997 | ||
1014 | first_buf->skb = netdev_alloc_skb(bp->dev, | 998 | first_buf->data = kmalloc(fp->rx_buf_size + NET_SKB_PAD, |
1015 | fp->rx_buf_size); | 999 | GFP_ATOMIC); |
1016 | if (!first_buf->skb) { | 1000 | if (!first_buf->data) { |
1017 | BNX2X_ERR("Failed to allocate TPA " | 1001 | BNX2X_ERR("Failed to allocate TPA " |
1018 | "skb pool for queue[%d] - " | 1002 | "skb pool for queue[%d] - " |
1019 | "disabling TPA on this " | 1003 | "disabling TPA on this " |
@@ -1094,13 +1078,11 @@ static void bnx2x_free_tx_skbs(struct bnx2x *bp) | |||
1094 | for_each_cos_in_tx_queue(fp, cos) { | 1078 | for_each_cos_in_tx_queue(fp, cos) { |
1095 | struct bnx2x_fp_txdata *txdata = &fp->txdata[cos]; | 1079 | struct bnx2x_fp_txdata *txdata = &fp->txdata[cos]; |
1096 | 1080 | ||
1097 | u16 bd_cons = txdata->tx_bd_cons; | ||
1098 | u16 sw_prod = txdata->tx_pkt_prod; | 1081 | u16 sw_prod = txdata->tx_pkt_prod; |
1099 | u16 sw_cons = txdata->tx_pkt_cons; | 1082 | u16 sw_cons = txdata->tx_pkt_cons; |
1100 | 1083 | ||
1101 | while (sw_cons != sw_prod) { | 1084 | while (sw_cons != sw_prod) { |
1102 | bd_cons = bnx2x_free_tx_pkt(bp, txdata, | 1085 | bnx2x_free_tx_pkt(bp, txdata, TX_BD(sw_cons)); |
1103 | TX_BD(sw_cons)); | ||
1104 | sw_cons++; | 1086 | sw_cons++; |
1105 | } | 1087 | } |
1106 | } | 1088 | } |
@@ -1118,16 +1100,16 @@ static void bnx2x_free_rx_bds(struct bnx2x_fastpath *fp) | |||
1118 | 1100 | ||
1119 | for (i = 0; i < NUM_RX_BD; i++) { | 1101 | for (i = 0; i < NUM_RX_BD; i++) { |
1120 | struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[i]; | 1102 | struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[i]; |
1121 | struct sk_buff *skb = rx_buf->skb; | 1103 | u8 *data = rx_buf->data; |
1122 | 1104 | ||
1123 | if (skb == NULL) | 1105 | if (data == NULL) |
1124 | continue; | 1106 | continue; |
1125 | dma_unmap_single(&bp->pdev->dev, | 1107 | dma_unmap_single(&bp->pdev->dev, |
1126 | dma_unmap_addr(rx_buf, mapping), | 1108 | dma_unmap_addr(rx_buf, mapping), |
1127 | fp->rx_buf_size, DMA_FROM_DEVICE); | 1109 | fp->rx_buf_size, DMA_FROM_DEVICE); |
1128 | 1110 | ||
1129 | rx_buf->skb = NULL; | 1111 | rx_buf->data = NULL; |
1130 | dev_kfree_skb(skb); | 1112 | kfree(data); |
1131 | } | 1113 | } |
1132 | } | 1114 | } |
1133 | 1115 | ||
@@ -1509,6 +1491,7 @@ static inline void bnx2x_set_rx_buf_size(struct bnx2x *bp) | |||
1509 | 1491 | ||
1510 | for_each_queue(bp, i) { | 1492 | for_each_queue(bp, i) { |
1511 | struct bnx2x_fastpath *fp = &bp->fp[i]; | 1493 | struct bnx2x_fastpath *fp = &bp->fp[i]; |
1494 | u32 mtu; | ||
1512 | 1495 | ||
1513 | /* Always use a mini-jumbo MTU for the FCoE L2 ring */ | 1496 | /* Always use a mini-jumbo MTU for the FCoE L2 ring */ |
1514 | if (IS_FCOE_IDX(i)) | 1497 | if (IS_FCOE_IDX(i)) |
@@ -1518,13 +1501,15 @@ static inline void bnx2x_set_rx_buf_size(struct bnx2x *bp) | |||
1518 | * IP_HEADER_ALIGNMENT_PADDING to prevent a buffer | 1501 | * IP_HEADER_ALIGNMENT_PADDING to prevent a buffer |
1519 | * overrun attack. | 1502 | * overrun attack. |
1520 | */ | 1503 | */ |
1521 | fp->rx_buf_size = | 1504 | mtu = BNX2X_FCOE_MINI_JUMBO_MTU; |
1522 | BNX2X_FCOE_MINI_JUMBO_MTU + ETH_OVREHEAD + | ||
1523 | BNX2X_FW_RX_ALIGN + IP_HEADER_ALIGNMENT_PADDING; | ||
1524 | else | 1505 | else |
1525 | fp->rx_buf_size = | 1506 | mtu = bp->dev->mtu; |
1526 | bp->dev->mtu + ETH_OVREHEAD + | 1507 | fp->rx_buf_size = BNX2X_FW_RX_ALIGN_START + |
1527 | BNX2X_FW_RX_ALIGN + IP_HEADER_ALIGNMENT_PADDING; | 1508 | IP_HEADER_ALIGNMENT_PADDING + |
1509 | ETH_OVREHEAD + | ||
1510 | mtu + | ||
1511 | BNX2X_FW_RX_ALIGN_END; | ||
1512 | /* Note : rx_buf_size doesnt take into account NET_SKB_PAD */ | ||
1528 | } | 1513 | } |
1529 | } | 1514 | } |
1530 | 1515 | ||
@@ -1929,13 +1914,17 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) | |||
1929 | break; | 1914 | break; |
1930 | } | 1915 | } |
1931 | 1916 | ||
1932 | if (!bp->port.pmf) | 1917 | if (bp->port.pmf) |
1918 | bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 0); | ||
1919 | else | ||
1933 | bnx2x__link_status_update(bp); | 1920 | bnx2x__link_status_update(bp); |
1934 | 1921 | ||
1935 | /* start the timer */ | 1922 | /* start the timer */ |
1936 | mod_timer(&bp->timer, jiffies + bp->current_interval); | 1923 | mod_timer(&bp->timer, jiffies + bp->current_interval); |
1937 | 1924 | ||
1938 | #ifdef BCM_CNIC | 1925 | #ifdef BCM_CNIC |
1926 | /* re-read iscsi info */ | ||
1927 | bnx2x_get_iscsi_info(bp); | ||
1939 | bnx2x_setup_cnic_irq_info(bp); | 1928 | bnx2x_setup_cnic_irq_info(bp); |
1940 | if (bp->state == BNX2X_STATE_OPEN) | 1929 | if (bp->state == BNX2X_STATE_OPEN) |
1941 | bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); | 1930 | bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); |
@@ -3409,7 +3398,8 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) | |||
3409 | return bnx2x_reload_if_running(dev); | 3398 | return bnx2x_reload_if_running(dev); |
3410 | } | 3399 | } |
3411 | 3400 | ||
3412 | u32 bnx2x_fix_features(struct net_device *dev, u32 features) | 3401 | netdev_features_t bnx2x_fix_features(struct net_device *dev, |
3402 | netdev_features_t features) | ||
3413 | { | 3403 | { |
3414 | struct bnx2x *bp = netdev_priv(dev); | 3404 | struct bnx2x *bp = netdev_priv(dev); |
3415 | 3405 | ||
@@ -3420,7 +3410,7 @@ u32 bnx2x_fix_features(struct net_device *dev, u32 features) | |||
3420 | return features; | 3410 | return features; |
3421 | } | 3411 | } |
3422 | 3412 | ||
3423 | int bnx2x_set_features(struct net_device *dev, u32 features) | 3413 | int bnx2x_set_features(struct net_device *dev, netdev_features_t features) |
3424 | { | 3414 | { |
3425 | struct bnx2x *bp = netdev_priv(dev); | 3415 | struct bnx2x *bp = netdev_priv(dev); |
3426 | u32 flags = bp->flags; | 3416 | u32 flags = bp->flags; |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 283d663da180..80c5ed08e419 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | |||
@@ -533,8 +533,9 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu); | |||
533 | */ | 533 | */ |
534 | int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type); | 534 | int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type); |
535 | #endif | 535 | #endif |
536 | u32 bnx2x_fix_features(struct net_device *dev, u32 features); | 536 | netdev_features_t bnx2x_fix_features(struct net_device *dev, |
537 | int bnx2x_set_features(struct net_device *dev, u32 features); | 537 | netdev_features_t features); |
538 | int bnx2x_set_features(struct net_device *dev, netdev_features_t features); | ||
538 | 539 | ||
539 | /** | 540 | /** |
540 | * bnx2x_tx_timeout - tx timeout netdev callback | 541 | * bnx2x_tx_timeout - tx timeout netdev callback |
@@ -874,8 +875,7 @@ static inline void bnx2x_clear_sge_mask_next_elems(struct bnx2x_fastpath *fp) | |||
874 | static inline void bnx2x_init_sge_ring_bit_mask(struct bnx2x_fastpath *fp) | 875 | static inline void bnx2x_init_sge_ring_bit_mask(struct bnx2x_fastpath *fp) |
875 | { | 876 | { |
876 | /* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */ | 877 | /* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */ |
877 | memset(fp->sge_mask, 0xff, | 878 | memset(fp->sge_mask, 0xff, sizeof(fp->sge_mask)); |
878 | (NUM_RX_SGE >> BIT_VEC64_ELEM_SHIFT)*sizeof(u64)); | ||
879 | 879 | ||
880 | /* Clear the two last indices in the page to 1: | 880 | /* Clear the two last indices in the page to 1: |
881 | these are the indices that correspond to the "next" element, | 881 | these are the indices that correspond to the "next" element, |
@@ -911,26 +911,27 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp, | |||
911 | return 0; | 911 | return 0; |
912 | } | 912 | } |
913 | 913 | ||
914 | static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp, | 914 | static inline int bnx2x_alloc_rx_data(struct bnx2x *bp, |
915 | struct bnx2x_fastpath *fp, u16 index) | 915 | struct bnx2x_fastpath *fp, u16 index) |
916 | { | 916 | { |
917 | struct sk_buff *skb; | 917 | u8 *data; |
918 | struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[index]; | 918 | struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[index]; |
919 | struct eth_rx_bd *rx_bd = &fp->rx_desc_ring[index]; | 919 | struct eth_rx_bd *rx_bd = &fp->rx_desc_ring[index]; |
920 | dma_addr_t mapping; | 920 | dma_addr_t mapping; |
921 | 921 | ||
922 | skb = netdev_alloc_skb(bp->dev, fp->rx_buf_size); | 922 | data = kmalloc(fp->rx_buf_size + NET_SKB_PAD, GFP_ATOMIC); |
923 | if (unlikely(skb == NULL)) | 923 | if (unlikely(data == NULL)) |
924 | return -ENOMEM; | 924 | return -ENOMEM; |
925 | 925 | ||
926 | mapping = dma_map_single(&bp->pdev->dev, skb->data, fp->rx_buf_size, | 926 | mapping = dma_map_single(&bp->pdev->dev, data + NET_SKB_PAD, |
927 | fp->rx_buf_size, | ||
927 | DMA_FROM_DEVICE); | 928 | DMA_FROM_DEVICE); |
928 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { | 929 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { |
929 | dev_kfree_skb_any(skb); | 930 | kfree(data); |
930 | return -ENOMEM; | 931 | return -ENOMEM; |
931 | } | 932 | } |
932 | 933 | ||
933 | rx_buf->skb = skb; | 934 | rx_buf->data = data; |
934 | dma_unmap_addr_set(rx_buf, mapping, mapping); | 935 | dma_unmap_addr_set(rx_buf, mapping, mapping); |
935 | 936 | ||
936 | rx_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); | 937 | rx_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); |
@@ -939,12 +940,12 @@ static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp, | |||
939 | return 0; | 940 | return 0; |
940 | } | 941 | } |
941 | 942 | ||
942 | /* note that we are not allocating a new skb, | 943 | /* note that we are not allocating a new buffer, |
943 | * we are just moving one from cons to prod | 944 | * we are just moving one from cons to prod |
944 | * we are not creating a new mapping, | 945 | * we are not creating a new mapping, |
945 | * so there is no need to check for dma_mapping_error(). | 946 | * so there is no need to check for dma_mapping_error(). |
946 | */ | 947 | */ |
947 | static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp, | 948 | static inline void bnx2x_reuse_rx_data(struct bnx2x_fastpath *fp, |
948 | u16 cons, u16 prod) | 949 | u16 cons, u16 prod) |
949 | { | 950 | { |
950 | struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons]; | 951 | struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons]; |
@@ -954,7 +955,7 @@ static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp, | |||
954 | 955 | ||
955 | dma_unmap_addr_set(prod_rx_buf, mapping, | 956 | dma_unmap_addr_set(prod_rx_buf, mapping, |
956 | dma_unmap_addr(cons_rx_buf, mapping)); | 957 | dma_unmap_addr(cons_rx_buf, mapping)); |
957 | prod_rx_buf->skb = cons_rx_buf->skb; | 958 | prod_rx_buf->data = cons_rx_buf->data; |
958 | *prod_bd = *cons_bd; | 959 | *prod_bd = *cons_bd; |
959 | } | 960 | } |
960 | 961 | ||
@@ -1030,9 +1031,9 @@ static inline void bnx2x_free_tpa_pool(struct bnx2x *bp, | |||
1030 | for (i = 0; i < last; i++) { | 1031 | for (i = 0; i < last; i++) { |
1031 | struct bnx2x_agg_info *tpa_info = &fp->tpa_info[i]; | 1032 | struct bnx2x_agg_info *tpa_info = &fp->tpa_info[i]; |
1032 | struct sw_rx_bd *first_buf = &tpa_info->first_buf; | 1033 | struct sw_rx_bd *first_buf = &tpa_info->first_buf; |
1033 | struct sk_buff *skb = first_buf->skb; | 1034 | u8 *data = first_buf->data; |
1034 | 1035 | ||
1035 | if (skb == NULL) { | 1036 | if (data == NULL) { |
1036 | DP(NETIF_MSG_IFDOWN, "tpa bin %d empty on free\n", i); | 1037 | DP(NETIF_MSG_IFDOWN, "tpa bin %d empty on free\n", i); |
1037 | continue; | 1038 | continue; |
1038 | } | 1039 | } |
@@ -1040,8 +1041,8 @@ static inline void bnx2x_free_tpa_pool(struct bnx2x *bp, | |||
1040 | dma_unmap_single(&bp->pdev->dev, | 1041 | dma_unmap_single(&bp->pdev->dev, |
1041 | dma_unmap_addr(first_buf, mapping), | 1042 | dma_unmap_addr(first_buf, mapping), |
1042 | fp->rx_buf_size, DMA_FROM_DEVICE); | 1043 | fp->rx_buf_size, DMA_FROM_DEVICE); |
1043 | dev_kfree_skb(skb); | 1044 | kfree(data); |
1044 | first_buf->skb = NULL; | 1045 | first_buf->data = NULL; |
1045 | } | 1046 | } |
1046 | } | 1047 | } |
1047 | 1048 | ||
@@ -1149,7 +1150,7 @@ static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp, | |||
1149 | * fp->eth_q_stats.rx_skb_alloc_failed = 0 | 1150 | * fp->eth_q_stats.rx_skb_alloc_failed = 0 |
1150 | */ | 1151 | */ |
1151 | for (i = 0; i < rx_ring_size; i++) { | 1152 | for (i = 0; i < rx_ring_size; i++) { |
1152 | if (bnx2x_alloc_rx_skb(bp, fp, ring_prod) < 0) { | 1153 | if (bnx2x_alloc_rx_data(bp, fp, ring_prod) < 0) { |
1153 | fp->eth_q_stats.rx_skb_alloc_failed++; | 1154 | fp->eth_q_stats.rx_skb_alloc_failed++; |
1154 | continue; | 1155 | continue; |
1155 | } | 1156 | } |
@@ -1318,6 +1319,7 @@ static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp) | |||
1318 | struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp); | 1319 | struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp); |
1319 | unsigned long q_type = 0; | 1320 | unsigned long q_type = 0; |
1320 | 1321 | ||
1322 | bnx2x_fcoe(bp, rx_queue) = BNX2X_NUM_ETH_QUEUES(bp); | ||
1321 | bnx2x_fcoe(bp, cl_id) = bnx2x_cnic_eth_cl_id(bp, | 1323 | bnx2x_fcoe(bp, cl_id) = bnx2x_cnic_eth_cl_id(bp, |
1322 | BNX2X_FCOE_ETH_CL_ID_IDX); | 1324 | BNX2X_FCOE_ETH_CL_ID_IDX); |
1323 | /** Current BNX2X_FCOE_ETH_CID deffinition implies not more than | 1325 | /** Current BNX2X_FCOE_ETH_CID deffinition implies not more than |
@@ -1488,4 +1490,68 @@ static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg) | |||
1488 | return max_cfg; | 1490 | return max_cfg; |
1489 | } | 1491 | } |
1490 | 1492 | ||
1493 | #ifdef BCM_CNIC | ||
1494 | /** | ||
1495 | * bnx2x_get_iscsi_info - update iSCSI params according to licensing info. | ||
1496 | * | ||
1497 | * @bp: driver handle | ||
1498 | * | ||
1499 | */ | ||
1500 | void bnx2x_get_iscsi_info(struct bnx2x *bp); | ||
1501 | #endif | ||
1502 | |||
1503 | /* returns func by VN for current port */ | ||
1504 | static inline int func_by_vn(struct bnx2x *bp, int vn) | ||
1505 | { | ||
1506 | return 2 * vn + BP_PORT(bp); | ||
1507 | } | ||
1508 | |||
1509 | /** | ||
1510 | * bnx2x_link_sync_notify - send notification to other functions. | ||
1511 | * | ||
1512 | * @bp: driver handle | ||
1513 | * | ||
1514 | */ | ||
1515 | static inline void bnx2x_link_sync_notify(struct bnx2x *bp) | ||
1516 | { | ||
1517 | int func; | ||
1518 | int vn; | ||
1519 | |||
1520 | /* Set the attention towards other drivers on the same port */ | ||
1521 | for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { | ||
1522 | if (vn == BP_VN(bp)) | ||
1523 | continue; | ||
1524 | |||
1525 | func = func_by_vn(bp, vn); | ||
1526 | REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_0 + | ||
1527 | (LINK_SYNC_ATTENTION_BIT_FUNC_0 + func)*4, 1); | ||
1528 | } | ||
1529 | } | ||
1530 | |||
1531 | /** | ||
1532 | * bnx2x_update_drv_flags - update flags in shmem | ||
1533 | * | ||
1534 | * @bp: driver handle | ||
1535 | * @flags: flags to update | ||
1536 | * @set: set or clear | ||
1537 | * | ||
1538 | */ | ||
1539 | static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set) | ||
1540 | { | ||
1541 | if (SHMEM2_HAS(bp, drv_flags)) { | ||
1542 | u32 drv_flags; | ||
1543 | bnx2x_acquire_hw_lock(bp, HW_LOCK_DRV_FLAGS); | ||
1544 | drv_flags = SHMEM2_RD(bp, drv_flags); | ||
1545 | |||
1546 | if (set) | ||
1547 | SET_FLAGS(drv_flags, flags); | ||
1548 | else | ||
1549 | RESET_FLAGS(drv_flags, flags); | ||
1550 | |||
1551 | SHMEM2_WR(bp, drv_flags, drv_flags); | ||
1552 | DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags); | ||
1553 | bnx2x_release_hw_lock(bp, HW_LOCK_DRV_FLAGS); | ||
1554 | } | ||
1555 | } | ||
1556 | |||
1491 | #endif /* BNX2X_CMN_H */ | 1557 | #endif /* BNX2X_CMN_H */ |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index 51bd7485ab18..5051cf3deb20 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | |||
@@ -685,24 +685,6 @@ int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall) | |||
685 | } | 685 | } |
686 | #endif | 686 | #endif |
687 | 687 | ||
688 | static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set) | ||
689 | { | ||
690 | if (SHMEM2_HAS(bp, drv_flags)) { | ||
691 | u32 drv_flags; | ||
692 | bnx2x_acquire_hw_lock(bp, HW_LOCK_DRV_FLAGS); | ||
693 | drv_flags = SHMEM2_RD(bp, drv_flags); | ||
694 | |||
695 | if (set) | ||
696 | SET_FLAGS(drv_flags, flags); | ||
697 | else | ||
698 | RESET_FLAGS(drv_flags, flags); | ||
699 | |||
700 | SHMEM2_WR(bp, drv_flags, drv_flags); | ||
701 | DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags); | ||
702 | bnx2x_release_hw_lock(bp, HW_LOCK_DRV_FLAGS); | ||
703 | } | ||
704 | } | ||
705 | |||
706 | static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x *bp) | 688 | static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x *bp) |
707 | { | 689 | { |
708 | u8 prio, cos; | 690 | u8 prio, cos; |
@@ -755,18 +737,26 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) | |||
755 | /* mark DCBX result for PMF migration */ | 737 | /* mark DCBX result for PMF migration */ |
756 | bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 1); | 738 | bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 1); |
757 | #ifdef BCM_DCBNL | 739 | #ifdef BCM_DCBNL |
758 | /** | 740 | /* |
759 | * Add new app tlvs to dcbnl | 741 | * Add new app tlvs to dcbnl |
760 | */ | 742 | */ |
761 | bnx2x_dcbnl_update_applist(bp, false); | 743 | bnx2x_dcbnl_update_applist(bp, false); |
762 | #endif | 744 | #endif |
763 | bnx2x_dcbx_stop_hw_tx(bp); | 745 | /* |
764 | 746 | * reconfigure the netdevice with the results of the new | |
765 | /* reconfigure the netdevice with the results of the new | ||
766 | * dcbx negotiation. | 747 | * dcbx negotiation. |
767 | */ | 748 | */ |
768 | bnx2x_dcbx_update_tc_mapping(bp); | 749 | bnx2x_dcbx_update_tc_mapping(bp); |
769 | 750 | ||
751 | /* | ||
752 | * allow other funtions to update their netdevices | ||
753 | * accordingly | ||
754 | */ | ||
755 | if (IS_MF(bp)) | ||
756 | bnx2x_link_sync_notify(bp); | ||
757 | |||
758 | bnx2x_dcbx_stop_hw_tx(bp); | ||
759 | |||
770 | return; | 760 | return; |
771 | } | 761 | } |
772 | case BNX2X_DCBX_STATE_TX_PAUSED: | 762 | case BNX2X_DCBX_STATE_TX_PAUSED: |
@@ -775,6 +765,7 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) | |||
775 | 765 | ||
776 | bnx2x_dcbx_update_ets_params(bp); | 766 | bnx2x_dcbx_update_ets_params(bp); |
777 | bnx2x_dcbx_resume_hw_tx(bp); | 767 | bnx2x_dcbx_resume_hw_tx(bp); |
768 | |||
778 | return; | 769 | return; |
779 | case BNX2X_DCBX_STATE_TX_RELEASED: | 770 | case BNX2X_DCBX_STATE_TX_RELEASED: |
780 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n"); | 771 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n"); |
@@ -883,7 +874,7 @@ static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp, | |||
883 | /*For IEEE admin_recommendation_bw_precentage | 874 | /*For IEEE admin_recommendation_bw_precentage |
884 | *For IEEE admin_recommendation_ets_pg */ | 875 | *For IEEE admin_recommendation_ets_pg */ |
885 | af->pfc.pri_en_bitmap = (u8)dp->admin_pfc_bitmap; | 876 | af->pfc.pri_en_bitmap = (u8)dp->admin_pfc_bitmap; |
886 | for (i = 0; i < 4; i++) { | 877 | for (i = 0; i < DCBX_CONFIG_MAX_APP_PROTOCOL; i++) { |
887 | if (dp->admin_priority_app_table[i].valid) { | 878 | if (dp->admin_priority_app_table[i].valid) { |
888 | struct bnx2x_admin_priority_app_table *table = | 879 | struct bnx2x_admin_priority_app_table *table = |
889 | dp->admin_priority_app_table; | 880 | dp->admin_priority_app_table; |
@@ -923,7 +914,7 @@ static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp, | |||
923 | 914 | ||
924 | void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled) | 915 | void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled) |
925 | { | 916 | { |
926 | if (!CHIP_IS_E1x(bp) && !CHIP_IS_E3(bp)) { | 917 | if (!CHIP_IS_E1x(bp)) { |
927 | bp->dcb_state = dcb_on; | 918 | bp->dcb_state = dcb_on; |
928 | bp->dcbx_enabled = dcbx_enabled; | 919 | bp->dcbx_enabled = dcbx_enabled; |
929 | } else { | 920 | } else { |
@@ -1863,7 +1854,7 @@ static void bnx2x_dcbx_fw_struct(struct bnx2x *bp, | |||
1863 | void bnx2x_dcbx_pmf_update(struct bnx2x *bp) | 1854 | void bnx2x_dcbx_pmf_update(struct bnx2x *bp) |
1864 | { | 1855 | { |
1865 | /* if we need to syncronize DCBX result from prev PMF | 1856 | /* if we need to syncronize DCBX result from prev PMF |
1866 | * read it from shmem and update bp accordingly | 1857 | * read it from shmem and update bp and netdev accordingly |
1867 | */ | 1858 | */ |
1868 | if (SHMEM2_HAS(bp, drv_flags) && | 1859 | if (SHMEM2_HAS(bp, drv_flags) && |
1869 | GET_FLAGS(SHMEM2_RD(bp, drv_flags), DRV_FLAGS_DCB_CONFIGURED)) { | 1860 | GET_FLAGS(SHMEM2_RD(bp, drv_flags), DRV_FLAGS_DCB_CONFIGURED)) { |
@@ -1875,6 +1866,22 @@ void bnx2x_dcbx_pmf_update(struct bnx2x *bp) | |||
1875 | bp->dcbx_error); | 1866 | bp->dcbx_error); |
1876 | bnx2x_get_dcbx_drv_param(bp, &bp->dcbx_local_feat, | 1867 | bnx2x_get_dcbx_drv_param(bp, &bp->dcbx_local_feat, |
1877 | bp->dcbx_error); | 1868 | bp->dcbx_error); |
1869 | #ifdef BCM_DCBNL | ||
1870 | /* | ||
1871 | * Add new app tlvs to dcbnl | ||
1872 | */ | ||
1873 | bnx2x_dcbnl_update_applist(bp, false); | ||
1874 | /* | ||
1875 | * Send a notification for the new negotiated parameters | ||
1876 | */ | ||
1877 | dcbnl_cee_notify(bp->dev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0); | ||
1878 | #endif | ||
1879 | /* | ||
1880 | * reconfigure the netdevice with the results of the new | ||
1881 | * dcbx negotiation. | ||
1882 | */ | ||
1883 | bnx2x_dcbx_update_tc_mapping(bp); | ||
1884 | |||
1878 | } | 1885 | } |
1879 | } | 1886 | } |
1880 | 1887 | ||
@@ -2242,7 +2249,7 @@ static int bnx2x_set_admin_app_up(struct bnx2x *bp, u8 idtype, u16 idval, u8 up) | |||
2242 | int i, ff; | 2249 | int i, ff; |
2243 | 2250 | ||
2244 | /* iterate over the app entries looking for idtype and idval */ | 2251 | /* iterate over the app entries looking for idtype and idval */ |
2245 | for (i = 0, ff = -1; i < 4; i++) { | 2252 | for (i = 0, ff = -1; i < DCBX_CONFIG_MAX_APP_PROTOCOL; i++) { |
2246 | struct bnx2x_admin_priority_app_table *app_ent = | 2253 | struct bnx2x_admin_priority_app_table *app_ent = |
2247 | &bp->dcbx_config_params.admin_priority_app_table[i]; | 2254 | &bp->dcbx_config_params.admin_priority_app_table[i]; |
2248 | if (bnx2x_admin_app_is_equal(app_ent, idtype, idval)) | 2255 | if (bnx2x_admin_app_is_equal(app_ent, idtype, idval)) |
@@ -2251,7 +2258,7 @@ static int bnx2x_set_admin_app_up(struct bnx2x *bp, u8 idtype, u16 idval, u8 up) | |||
2251 | if (ff < 0 && !app_ent->valid) | 2258 | if (ff < 0 && !app_ent->valid) |
2252 | ff = i; | 2259 | ff = i; |
2253 | } | 2260 | } |
2254 | if (i < 4) | 2261 | if (i < DCBX_CONFIG_MAX_APP_PROTOCOL) |
2255 | /* if found overwrite up */ | 2262 | /* if found overwrite up */ |
2256 | bp->dcbx_config_params. | 2263 | bp->dcbx_config_params. |
2257 | admin_priority_app_table[i].priority = up; | 2264 | admin_priority_app_table[i].priority = up; |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h index 2c6a3bca6f28..2ab9254e2d5e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h | |||
@@ -90,6 +90,7 @@ struct bnx2x_admin_priority_app_table { | |||
90 | u32 app_id; | 90 | u32 app_id; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | #define DCBX_CONFIG_MAX_APP_PROTOCOL 4 | ||
93 | struct bnx2x_config_dcbx_params { | 94 | struct bnx2x_config_dcbx_params { |
94 | u32 overwrite_settings; | 95 | u32 overwrite_settings; |
95 | u32 admin_dcbx_version; | 96 | u32 admin_dcbx_version; |
@@ -109,7 +110,8 @@ struct bnx2x_config_dcbx_params { | |||
109 | u32 admin_recommendation_bw_precentage[8]; | 110 | u32 admin_recommendation_bw_precentage[8]; |
110 | u32 admin_recommendation_ets_pg[8]; | 111 | u32 admin_recommendation_ets_pg[8]; |
111 | u32 admin_pfc_bitmap; | 112 | u32 admin_pfc_bitmap; |
112 | struct bnx2x_admin_priority_app_table admin_priority_app_table[4]; | 113 | struct bnx2x_admin_priority_app_table |
114 | admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL]; | ||
113 | u32 admin_default_priority; | 115 | u32 admin_default_priority; |
114 | }; | 116 | }; |
115 | 117 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index f0ca8b27a55e..ec318711f483 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | |||
@@ -761,8 +761,8 @@ static void bnx2x_get_drvinfo(struct net_device *dev, | |||
761 | struct bnx2x *bp = netdev_priv(dev); | 761 | struct bnx2x *bp = netdev_priv(dev); |
762 | u8 phy_fw_ver[PHY_FW_VER_LEN]; | 762 | u8 phy_fw_ver[PHY_FW_VER_LEN]; |
763 | 763 | ||
764 | strcpy(info->driver, DRV_MODULE_NAME); | 764 | strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); |
765 | strcpy(info->version, DRV_MODULE_VERSION); | 765 | strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); |
766 | 766 | ||
767 | phy_fw_ver[0] = '\0'; | 767 | phy_fw_ver[0] = '\0'; |
768 | if (bp->port.pmf) { | 768 | if (bp->port.pmf) { |
@@ -773,14 +773,14 @@ static void bnx2x_get_drvinfo(struct net_device *dev, | |||
773 | bnx2x_release_phy_lock(bp); | 773 | bnx2x_release_phy_lock(bp); |
774 | } | 774 | } |
775 | 775 | ||
776 | strncpy(info->fw_version, bp->fw_ver, 32); | 776 | strlcpy(info->fw_version, bp->fw_ver, sizeof(info->fw_version)); |
777 | snprintf(info->fw_version + strlen(bp->fw_ver), 32 - strlen(bp->fw_ver), | 777 | snprintf(info->fw_version + strlen(bp->fw_ver), 32 - strlen(bp->fw_ver), |
778 | "bc %d.%d.%d%s%s", | 778 | "bc %d.%d.%d%s%s", |
779 | (bp->common.bc_ver & 0xff0000) >> 16, | 779 | (bp->common.bc_ver & 0xff0000) >> 16, |
780 | (bp->common.bc_ver & 0xff00) >> 8, | 780 | (bp->common.bc_ver & 0xff00) >> 8, |
781 | (bp->common.bc_ver & 0xff), | 781 | (bp->common.bc_ver & 0xff), |
782 | ((phy_fw_ver[0] != '\0') ? " phy " : ""), phy_fw_ver); | 782 | ((phy_fw_ver[0] != '\0') ? " phy " : ""), phy_fw_ver); |
783 | strcpy(info->bus_info, pci_name(bp->pdev)); | 783 | strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); |
784 | info->n_stats = BNX2X_NUM_STATS; | 784 | info->n_stats = BNX2X_NUM_STATS; |
785 | info->testinfo_len = BNX2X_NUM_TESTS; | 785 | info->testinfo_len = BNX2X_NUM_TESTS; |
786 | info->eedump_len = bp->common.flash_size; | 786 | info->eedump_len = bp->common.flash_size; |
@@ -1740,6 +1740,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) | |||
1740 | struct sw_rx_bd *rx_buf; | 1740 | struct sw_rx_bd *rx_buf; |
1741 | u16 len; | 1741 | u16 len; |
1742 | int rc = -ENODEV; | 1742 | int rc = -ENODEV; |
1743 | u8 *data; | ||
1743 | 1744 | ||
1744 | /* check the loopback mode */ | 1745 | /* check the loopback mode */ |
1745 | switch (loopback_mode) { | 1746 | switch (loopback_mode) { |
@@ -1865,10 +1866,9 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) | |||
1865 | dma_sync_single_for_cpu(&bp->pdev->dev, | 1866 | dma_sync_single_for_cpu(&bp->pdev->dev, |
1866 | dma_unmap_addr(rx_buf, mapping), | 1867 | dma_unmap_addr(rx_buf, mapping), |
1867 | fp_rx->rx_buf_size, DMA_FROM_DEVICE); | 1868 | fp_rx->rx_buf_size, DMA_FROM_DEVICE); |
1868 | skb = rx_buf->skb; | 1869 | data = rx_buf->data + NET_SKB_PAD + cqe->fast_path_cqe.placement_offset; |
1869 | skb_reserve(skb, cqe->fast_path_cqe.placement_offset); | ||
1870 | for (i = ETH_HLEN; i < pkt_size; i++) | 1870 | for (i = ETH_HLEN; i < pkt_size; i++) |
1871 | if (*(skb->data + i) != (unsigned char) (i & 0xff)) | 1871 | if (*(data + i) != (unsigned char) (i & 0xff)) |
1872 | goto test_loopback_rx_exit; | 1872 | goto test_loopback_rx_exit; |
1873 | 1873 | ||
1874 | rc = 0; | 1874 | rc = 0; |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 2f6361e949f0..83481e20f144 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | |||
@@ -2318,12 +2318,6 @@ static void bnx2x_calc_vn_weight_sum(struct bnx2x *bp) | |||
2318 | CMNG_FLAGS_PER_PORT_FAIRNESS_VN; | 2318 | CMNG_FLAGS_PER_PORT_FAIRNESS_VN; |
2319 | } | 2319 | } |
2320 | 2320 | ||
2321 | /* returns func by VN for current port */ | ||
2322 | static inline int func_by_vn(struct bnx2x *bp, int vn) | ||
2323 | { | ||
2324 | return 2 * vn + BP_PORT(bp); | ||
2325 | } | ||
2326 | |||
2327 | static void bnx2x_init_vn_minmax(struct bnx2x *bp, int vn) | 2321 | static void bnx2x_init_vn_minmax(struct bnx2x *bp, int vn) |
2328 | { | 2322 | { |
2329 | struct rate_shaping_vars_per_vn m_rs_vn; | 2323 | struct rate_shaping_vars_per_vn m_rs_vn; |
@@ -2475,22 +2469,6 @@ static void bnx2x_cmng_fns_init(struct bnx2x *bp, u8 read_cfg, u8 cmng_type) | |||
2475 | "rate shaping and fairness are disabled\n"); | 2469 | "rate shaping and fairness are disabled\n"); |
2476 | } | 2470 | } |
2477 | 2471 | ||
2478 | static inline void bnx2x_link_sync_notify(struct bnx2x *bp) | ||
2479 | { | ||
2480 | int func; | ||
2481 | int vn; | ||
2482 | |||
2483 | /* Set the attention towards other drivers on the same port */ | ||
2484 | for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { | ||
2485 | if (vn == BP_VN(bp)) | ||
2486 | continue; | ||
2487 | |||
2488 | func = func_by_vn(bp, vn); | ||
2489 | REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_0 + | ||
2490 | (LINK_SYNC_ATTENTION_BIT_FUNC_0 + func)*4, 1); | ||
2491 | } | ||
2492 | } | ||
2493 | |||
2494 | /* This function is called upon link interrupt */ | 2472 | /* This function is called upon link interrupt */ |
2495 | static void bnx2x_link_attn(struct bnx2x *bp) | 2473 | static void bnx2x_link_attn(struct bnx2x *bp) |
2496 | { | 2474 | { |
@@ -2549,6 +2527,9 @@ void bnx2x__link_status_update(struct bnx2x *bp) | |||
2549 | if (bp->state != BNX2X_STATE_OPEN) | 2527 | if (bp->state != BNX2X_STATE_OPEN) |
2550 | return; | 2528 | return; |
2551 | 2529 | ||
2530 | /* read updated dcb configuration */ | ||
2531 | bnx2x_dcbx_pmf_update(bp); | ||
2532 | |||
2552 | bnx2x_link_status_update(&bp->link_params, &bp->link_vars); | 2533 | bnx2x_link_status_update(&bp->link_params, &bp->link_vars); |
2553 | 2534 | ||
2554 | if (bp->link_vars.link_up) | 2535 | if (bp->link_vars.link_up) |
@@ -2808,8 +2789,8 @@ static void bnx2x_pf_rx_q_prep(struct bnx2x *bp, | |||
2808 | /* This should be a maximum number of data bytes that may be | 2789 | /* This should be a maximum number of data bytes that may be |
2809 | * placed on the BD (not including paddings). | 2790 | * placed on the BD (not including paddings). |
2810 | */ | 2791 | */ |
2811 | rxq_init->buf_sz = fp->rx_buf_size - BNX2X_FW_RX_ALIGN - | 2792 | rxq_init->buf_sz = fp->rx_buf_size - BNX2X_FW_RX_ALIGN_START - |
2812 | IP_HEADER_ALIGNMENT_PADDING; | 2793 | BNX2X_FW_RX_ALIGN_END - IP_HEADER_ALIGNMENT_PADDING; |
2813 | 2794 | ||
2814 | rxq_init->cl_qzone_id = fp->cl_qzone_id; | 2795 | rxq_init->cl_qzone_id = fp->cl_qzone_id; |
2815 | rxq_init->tpa_agg_sz = tpa_agg_size; | 2796 | rxq_init->tpa_agg_sz = tpa_agg_size; |
@@ -3318,6 +3299,17 @@ static inline void bnx2x_fan_failure(struct bnx2x *bp) | |||
3318 | netdev_err(bp->dev, "Fan Failure on Network Controller has caused" | 3299 | netdev_err(bp->dev, "Fan Failure on Network Controller has caused" |
3319 | " the driver to shutdown the card to prevent permanent" | 3300 | " the driver to shutdown the card to prevent permanent" |
3320 | " damage. Please contact OEM Support for assistance\n"); | 3301 | " damage. Please contact OEM Support for assistance\n"); |
3302 | |||
3303 | /* | ||
3304 | * Scheudle device reset (unload) | ||
3305 | * This is due to some boards consuming sufficient power when driver is | ||
3306 | * up to overheat if fan fails. | ||
3307 | */ | ||
3308 | smp_mb__before_clear_bit(); | ||
3309 | set_bit(BNX2X_SP_RTNL_FAN_FAILURE, &bp->sp_rtnl_state); | ||
3310 | smp_mb__after_clear_bit(); | ||
3311 | schedule_delayed_work(&bp->sp_rtnl_task, 0); | ||
3312 | |||
3321 | } | 3313 | } |
3322 | 3314 | ||
3323 | static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) | 3315 | static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) |
@@ -5247,7 +5239,7 @@ static void bnx2x_init_eth_fp(struct bnx2x *bp, int fp_idx) | |||
5247 | u8 cos; | 5239 | u8 cos; |
5248 | unsigned long q_type = 0; | 5240 | unsigned long q_type = 0; |
5249 | u32 cids[BNX2X_MULTI_TX_COS] = { 0 }; | 5241 | u32 cids[BNX2X_MULTI_TX_COS] = { 0 }; |
5250 | 5242 | fp->rx_queue = fp_idx; | |
5251 | fp->cid = fp_idx; | 5243 | fp->cid = fp_idx; |
5252 | fp->cl_id = bnx2x_fp_cl_id(fp); | 5244 | fp->cl_id = bnx2x_fp_cl_id(fp); |
5253 | fp->fw_sb_id = bnx2x_fp_fw_sb_id(fp); | 5245 | fp->fw_sb_id = bnx2x_fp_fw_sb_id(fp); |
@@ -8522,6 +8514,17 @@ sp_rtnl_not_reset: | |||
8522 | if (test_and_clear_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state)) | 8514 | if (test_and_clear_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state)) |
8523 | bnx2x_setup_tc(bp->dev, bp->dcbx_port_params.ets.num_of_cos); | 8515 | bnx2x_setup_tc(bp->dev, bp->dcbx_port_params.ets.num_of_cos); |
8524 | 8516 | ||
8517 | /* | ||
8518 | * in case of fan failure we need to reset id if the "stop on error" | ||
8519 | * debug flag is set, since we trying to prevent permanent overheating | ||
8520 | * damage | ||
8521 | */ | ||
8522 | if (test_and_clear_bit(BNX2X_SP_RTNL_FAN_FAILURE, &bp->sp_rtnl_state)) { | ||
8523 | DP(BNX2X_MSG_SP, "fan failure detected. Unloading driver\n"); | ||
8524 | netif_device_detach(bp->dev); | ||
8525 | bnx2x_close(bp->dev); | ||
8526 | } | ||
8527 | |||
8525 | sp_rtnl_exit: | 8528 | sp_rtnl_exit: |
8526 | rtnl_unlock(); | 8529 | rtnl_unlock(); |
8527 | } | 8530 | } |
@@ -9268,21 +9271,38 @@ static void __devinit bnx2x_get_port_hwinfo(struct bnx2x *bp) | |||
9268 | } | 9271 | } |
9269 | 9272 | ||
9270 | #ifdef BCM_CNIC | 9273 | #ifdef BCM_CNIC |
9271 | static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) | 9274 | void bnx2x_get_iscsi_info(struct bnx2x *bp) |
9272 | { | 9275 | { |
9273 | int port = BP_PORT(bp); | 9276 | int port = BP_PORT(bp); |
9274 | int func = BP_ABS_FUNC(bp); | ||
9275 | 9277 | ||
9276 | u32 max_iscsi_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, | 9278 | u32 max_iscsi_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, |
9277 | drv_lic_key[port].max_iscsi_conn); | 9279 | drv_lic_key[port].max_iscsi_conn); |
9278 | u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, | ||
9279 | drv_lic_key[port].max_fcoe_conn); | ||
9280 | 9280 | ||
9281 | /* Get the number of maximum allowed iSCSI and FCoE connections */ | 9281 | /* Get the number of maximum allowed iSCSI connections */ |
9282 | bp->cnic_eth_dev.max_iscsi_conn = | 9282 | bp->cnic_eth_dev.max_iscsi_conn = |
9283 | (max_iscsi_conn & BNX2X_MAX_ISCSI_INIT_CONN_MASK) >> | 9283 | (max_iscsi_conn & BNX2X_MAX_ISCSI_INIT_CONN_MASK) >> |
9284 | BNX2X_MAX_ISCSI_INIT_CONN_SHIFT; | 9284 | BNX2X_MAX_ISCSI_INIT_CONN_SHIFT; |
9285 | 9285 | ||
9286 | BNX2X_DEV_INFO("max_iscsi_conn 0x%x\n", | ||
9287 | bp->cnic_eth_dev.max_iscsi_conn); | ||
9288 | |||
9289 | /* | ||
9290 | * If maximum allowed number of connections is zero - | ||
9291 | * disable the feature. | ||
9292 | */ | ||
9293 | if (!bp->cnic_eth_dev.max_iscsi_conn) | ||
9294 | bp->flags |= NO_ISCSI_FLAG; | ||
9295 | } | ||
9296 | |||
9297 | static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp) | ||
9298 | { | ||
9299 | int port = BP_PORT(bp); | ||
9300 | int func = BP_ABS_FUNC(bp); | ||
9301 | |||
9302 | u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, | ||
9303 | drv_lic_key[port].max_fcoe_conn); | ||
9304 | |||
9305 | /* Get the number of maximum allowed FCoE connections */ | ||
9286 | bp->cnic_eth_dev.max_fcoe_conn = | 9306 | bp->cnic_eth_dev.max_fcoe_conn = |
9287 | (max_fcoe_conn & BNX2X_MAX_FCOE_INIT_CONN_MASK) >> | 9307 | (max_fcoe_conn & BNX2X_MAX_FCOE_INIT_CONN_MASK) >> |
9288 | BNX2X_MAX_FCOE_INIT_CONN_SHIFT; | 9308 | BNX2X_MAX_FCOE_INIT_CONN_SHIFT; |
@@ -9334,20 +9354,26 @@ static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) | |||
9334 | } | 9354 | } |
9335 | } | 9355 | } |
9336 | 9356 | ||
9337 | BNX2X_DEV_INFO("max_iscsi_conn 0x%x max_fcoe_conn 0x%x\n", | 9357 | BNX2X_DEV_INFO("max_fcoe_conn 0x%x\n", bp->cnic_eth_dev.max_fcoe_conn); |
9338 | bp->cnic_eth_dev.max_iscsi_conn, | ||
9339 | bp->cnic_eth_dev.max_fcoe_conn); | ||
9340 | 9358 | ||
9341 | /* | 9359 | /* |
9342 | * If maximum allowed number of connections is zero - | 9360 | * If maximum allowed number of connections is zero - |
9343 | * disable the feature. | 9361 | * disable the feature. |
9344 | */ | 9362 | */ |
9345 | if (!bp->cnic_eth_dev.max_iscsi_conn) | ||
9346 | bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; | ||
9347 | |||
9348 | if (!bp->cnic_eth_dev.max_fcoe_conn) | 9363 | if (!bp->cnic_eth_dev.max_fcoe_conn) |
9349 | bp->flags |= NO_FCOE_FLAG; | 9364 | bp->flags |= NO_FCOE_FLAG; |
9350 | } | 9365 | } |
9366 | |||
9367 | static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) | ||
9368 | { | ||
9369 | /* | ||
9370 | * iSCSI may be dynamically disabled but reading | ||
9371 | * info here we will decrease memory usage by driver | ||
9372 | * if the feature is disabled for good | ||
9373 | */ | ||
9374 | bnx2x_get_iscsi_info(bp); | ||
9375 | bnx2x_get_fcoe_info(bp); | ||
9376 | } | ||
9351 | #endif | 9377 | #endif |
9352 | 9378 | ||
9353 | static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) | 9379 | static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) |
@@ -9965,7 +9991,7 @@ static int bnx2x_open(struct net_device *dev) | |||
9965 | } | 9991 | } |
9966 | 9992 | ||
9967 | /* called with rtnl_lock */ | 9993 | /* called with rtnl_lock */ |
9968 | static int bnx2x_close(struct net_device *dev) | 9994 | int bnx2x_close(struct net_device *dev) |
9969 | { | 9995 | { |
9970 | struct bnx2x *bp = netdev_priv(dev); | 9996 | struct bnx2x *bp = netdev_priv(dev); |
9971 | 9997 | ||
@@ -10823,8 +10849,8 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, | |||
10823 | bp->qm_cid_count = bnx2x_set_qm_cid_count(bp); | 10849 | bp->qm_cid_count = bnx2x_set_qm_cid_count(bp); |
10824 | 10850 | ||
10825 | #ifdef BCM_CNIC | 10851 | #ifdef BCM_CNIC |
10826 | /* disable FCOE L2 queue for E1x and E3*/ | 10852 | /* disable FCOE L2 queue for E1x */ |
10827 | if (CHIP_IS_E1x(bp) || CHIP_IS_E3(bp)) | 10853 | if (CHIP_IS_E1x(bp)) |
10828 | bp->flags |= NO_FCOE_FLAG; | 10854 | bp->flags |= NO_FCOE_FLAG; |
10829 | 10855 | ||
10830 | #endif | 10856 | #endif |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c index 02ac6a771bf9..3034f0e31938 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c | |||
@@ -1349,12 +1349,14 @@ void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) | |||
1349 | enum bnx2x_stats_state state; | 1349 | enum bnx2x_stats_state state; |
1350 | if (unlikely(bp->panic)) | 1350 | if (unlikely(bp->panic)) |
1351 | return; | 1351 | return; |
1352 | bnx2x_stats_stm[bp->stats_state][event].action(bp); | 1352 | |
1353 | spin_lock_bh(&bp->stats_lock); | 1353 | spin_lock_bh(&bp->stats_lock); |
1354 | state = bp->stats_state; | 1354 | state = bp->stats_state; |
1355 | bp->stats_state = bnx2x_stats_stm[state][event].next_state; | 1355 | bp->stats_state = bnx2x_stats_stm[state][event].next_state; |
1356 | spin_unlock_bh(&bp->stats_lock); | 1356 | spin_unlock_bh(&bp->stats_lock); |
1357 | 1357 | ||
1358 | bnx2x_stats_stm[state][event].action(bp); | ||
1359 | |||
1358 | if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) | 1360 | if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) |
1359 | DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", | 1361 | DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", |
1360 | state, event, bp->stats_state); | 1362 | state, event, bp->stats_state); |
diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c index 0a1d7f279fc8..aa58f9e3f913 100644 --- a/drivers/net/ethernet/broadcom/sb1250-mac.c +++ b/drivers/net/ethernet/broadcom/sb1250-mac.c | |||
@@ -163,7 +163,6 @@ enum sbmac_state { | |||
163 | #define SBMAC_MAX_TXDESCR 256 | 163 | #define SBMAC_MAX_TXDESCR 256 |
164 | #define SBMAC_MAX_RXDESCR 256 | 164 | #define SBMAC_MAX_RXDESCR 256 |
165 | 165 | ||
166 | #define ETHER_ADDR_LEN 6 | ||
167 | #define ENET_PACKET_SIZE 1518 | 166 | #define ENET_PACKET_SIZE 1518 |
168 | /*#define ENET_PACKET_SIZE 9216 */ | 167 | /*#define ENET_PACKET_SIZE 9216 */ |
169 | 168 | ||
@@ -266,7 +265,7 @@ struct sbmac_softc { | |||
266 | int sbm_pause; /* current pause setting */ | 265 | int sbm_pause; /* current pause setting */ |
267 | int sbm_link; /* current link state */ | 266 | int sbm_link; /* current link state */ |
268 | 267 | ||
269 | unsigned char sbm_hwaddr[ETHER_ADDR_LEN]; | 268 | unsigned char sbm_hwaddr[ETH_ALEN]; |
270 | 269 | ||
271 | struct sbmacdma sbm_txdma; /* only channel 0 for now */ | 270 | struct sbmacdma sbm_txdma; /* only channel 0 for now */ |
272 | struct sbmacdma sbm_rxdma; | 271 | struct sbmacdma sbm_rxdma; |
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index bf4074167d6a..024ca1d4d028 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
@@ -3594,15 +3594,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl) | |||
3594 | u32 val, new_adv; | 3594 | u32 val, new_adv; |
3595 | 3595 | ||
3596 | new_adv = ADVERTISE_CSMA; | 3596 | new_adv = ADVERTISE_CSMA; |
3597 | if (advertise & ADVERTISED_10baseT_Half) | 3597 | new_adv |= ethtool_adv_to_mii_100bt(advertise); |
3598 | new_adv |= ADVERTISE_10HALF; | ||
3599 | if (advertise & ADVERTISED_10baseT_Full) | ||
3600 | new_adv |= ADVERTISE_10FULL; | ||
3601 | if (advertise & ADVERTISED_100baseT_Half) | ||
3602 | new_adv |= ADVERTISE_100HALF; | ||
3603 | if (advertise & ADVERTISED_100baseT_Full) | ||
3604 | new_adv |= ADVERTISE_100FULL; | ||
3605 | |||
3606 | new_adv |= tg3_advert_flowctrl_1000T(flowctrl); | 3598 | new_adv |= tg3_advert_flowctrl_1000T(flowctrl); |
3607 | 3599 | ||
3608 | err = tg3_writephy(tp, MII_ADVERTISE, new_adv); | 3600 | err = tg3_writephy(tp, MII_ADVERTISE, new_adv); |
@@ -3612,11 +3604,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl) | |||
3612 | if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) | 3604 | if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) |
3613 | goto done; | 3605 | goto done; |
3614 | 3606 | ||
3615 | new_adv = 0; | 3607 | new_adv = ethtool_adv_to_mii_1000T(advertise); |
3616 | if (advertise & ADVERTISED_1000baseT_Half) | ||
3617 | new_adv |= ADVERTISE_1000HALF; | ||
3618 | if (advertise & ADVERTISED_1000baseT_Full) | ||
3619 | new_adv |= ADVERTISE_1000FULL; | ||
3620 | 3608 | ||
3621 | if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 || | 3609 | if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 || |
3622 | tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) | 3610 | tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) |
@@ -3790,14 +3778,7 @@ static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask) | |||
3790 | { | 3778 | { |
3791 | u32 adv_reg, all_mask = 0; | 3779 | u32 adv_reg, all_mask = 0; |
3792 | 3780 | ||
3793 | if (mask & ADVERTISED_10baseT_Half) | 3781 | all_mask = ethtool_adv_to_mii_100bt(mask); |
3794 | all_mask |= ADVERTISE_10HALF; | ||
3795 | if (mask & ADVERTISED_10baseT_Full) | ||
3796 | all_mask |= ADVERTISE_10FULL; | ||
3797 | if (mask & ADVERTISED_100baseT_Half) | ||
3798 | all_mask |= ADVERTISE_100HALF; | ||
3799 | if (mask & ADVERTISED_100baseT_Full) | ||
3800 | all_mask |= ADVERTISE_100FULL; | ||
3801 | 3782 | ||
3802 | if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg)) | 3783 | if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg)) |
3803 | return 0; | 3784 | return 0; |
@@ -3808,11 +3789,7 @@ static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask) | |||
3808 | if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { | 3789 | if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { |
3809 | u32 tg3_ctrl; | 3790 | u32 tg3_ctrl; |
3810 | 3791 | ||
3811 | all_mask = 0; | 3792 | all_mask = ethtool_adv_to_mii_1000T(mask); |
3812 | if (mask & ADVERTISED_1000baseT_Half) | ||
3813 | all_mask |= ADVERTISE_1000HALF; | ||
3814 | if (mask & ADVERTISED_1000baseT_Full) | ||
3815 | all_mask |= ADVERTISE_1000FULL; | ||
3816 | 3793 | ||
3817 | if (tg3_readphy(tp, MII_CTRL1000, &tg3_ctrl)) | 3794 | if (tg3_readphy(tp, MII_CTRL1000, &tg3_ctrl)) |
3818 | return 0; | 3795 | return 0; |
@@ -4903,23 +4880,19 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) | |||
4903 | (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) { | 4880 | (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) { |
4904 | /* do nothing, just check for link up at the end */ | 4881 | /* do nothing, just check for link up at the end */ |
4905 | } else if (tp->link_config.autoneg == AUTONEG_ENABLE) { | 4882 | } else if (tp->link_config.autoneg == AUTONEG_ENABLE) { |
4906 | u32 adv, new_adv; | 4883 | u32 adv, newadv; |
4907 | 4884 | ||
4908 | err |= tg3_readphy(tp, MII_ADVERTISE, &adv); | 4885 | err |= tg3_readphy(tp, MII_ADVERTISE, &adv); |
4909 | new_adv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF | | 4886 | newadv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF | |
4910 | ADVERTISE_1000XPAUSE | | 4887 | ADVERTISE_1000XPAUSE | |
4911 | ADVERTISE_1000XPSE_ASYM | | 4888 | ADVERTISE_1000XPSE_ASYM | |
4912 | ADVERTISE_SLCT); | 4889 | ADVERTISE_SLCT); |
4913 | |||
4914 | new_adv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl); | ||
4915 | 4890 | ||
4916 | if (tp->link_config.advertising & ADVERTISED_1000baseT_Half) | 4891 | newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl); |
4917 | new_adv |= ADVERTISE_1000XHALF; | 4892 | newadv |= ethtool_adv_to_mii_1000X(tp->link_config.advertising); |
4918 | if (tp->link_config.advertising & ADVERTISED_1000baseT_Full) | ||
4919 | new_adv |= ADVERTISE_1000XFULL; | ||
4920 | 4893 | ||
4921 | if ((new_adv != adv) || !(bmcr & BMCR_ANENABLE)) { | 4894 | if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) { |
4922 | tg3_writephy(tp, MII_ADVERTISE, new_adv); | 4895 | tg3_writephy(tp, MII_ADVERTISE, newadv); |
4923 | bmcr |= BMCR_ANENABLE | BMCR_ANRESTART; | 4896 | bmcr |= BMCR_ANENABLE | BMCR_ANRESTART; |
4924 | tg3_writephy(tp, MII_BMCR, bmcr); | 4897 | tg3_writephy(tp, MII_BMCR, bmcr); |
4925 | 4898 | ||
@@ -6968,7 +6941,7 @@ static int tg3_phy_lpbk_set(struct tg3 *tp, u32 speed, bool extlpbk) | |||
6968 | return 0; | 6941 | return 0; |
6969 | } | 6942 | } |
6970 | 6943 | ||
6971 | static void tg3_set_loopback(struct net_device *dev, u32 features) | 6944 | static void tg3_set_loopback(struct net_device *dev, netdev_features_t features) |
6972 | { | 6945 | { |
6973 | struct tg3 *tp = netdev_priv(dev); | 6946 | struct tg3 *tp = netdev_priv(dev); |
6974 | 6947 | ||
@@ -6994,7 +6967,8 @@ static void tg3_set_loopback(struct net_device *dev, u32 features) | |||
6994 | } | 6967 | } |
6995 | } | 6968 | } |
6996 | 6969 | ||
6997 | static u32 tg3_fix_features(struct net_device *dev, u32 features) | 6970 | static netdev_features_t tg3_fix_features(struct net_device *dev, |
6971 | netdev_features_t features) | ||
6998 | { | 6972 | { |
6999 | struct tg3 *tp = netdev_priv(dev); | 6973 | struct tg3 *tp = netdev_priv(dev); |
7000 | 6974 | ||
@@ -7004,9 +6978,9 @@ static u32 tg3_fix_features(struct net_device *dev, u32 features) | |||
7004 | return features; | 6978 | return features; |
7005 | } | 6979 | } |
7006 | 6980 | ||
7007 | static int tg3_set_features(struct net_device *dev, u32 features) | 6981 | static int tg3_set_features(struct net_device *dev, netdev_features_t features) |
7008 | { | 6982 | { |
7009 | u32 changed = dev->features ^ features; | 6983 | netdev_features_t changed = dev->features ^ features; |
7010 | 6984 | ||
7011 | if ((changed & NETIF_F_LOOPBACK) && netif_running(dev)) | 6985 | if ((changed & NETIF_F_LOOPBACK) && netif_running(dev)) |
7012 | tg3_set_loopback(dev, features); | 6986 | tg3_set_loopback(dev, features); |
@@ -10428,10 +10402,10 @@ static void tg3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
10428 | { | 10402 | { |
10429 | struct tg3 *tp = netdev_priv(dev); | 10403 | struct tg3 *tp = netdev_priv(dev); |
10430 | 10404 | ||
10431 | strcpy(info->driver, DRV_MODULE_NAME); | 10405 | strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); |
10432 | strcpy(info->version, DRV_MODULE_VERSION); | 10406 | strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); |
10433 | strcpy(info->fw_version, tp->fw_ver); | 10407 | strlcpy(info->fw_version, tp->fw_ver, sizeof(info->fw_version)); |
10434 | strcpy(info->bus_info, pci_name(tp->pdev)); | 10408 | strlcpy(info->bus_info, pci_name(tp->pdev), sizeof(info->bus_info)); |
10435 | } | 10409 | } |
10436 | 10410 | ||
10437 | static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | 10411 | static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
@@ -15313,7 +15287,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
15313 | u32 sndmbx, rcvmbx, intmbx; | 15287 | u32 sndmbx, rcvmbx, intmbx; |
15314 | char str[40]; | 15288 | char str[40]; |
15315 | u64 dma_mask, persist_dma_mask; | 15289 | u64 dma_mask, persist_dma_mask; |
15316 | u32 features = 0; | 15290 | netdev_features_t features = 0; |
15317 | 15291 | ||
15318 | printk_once(KERN_INFO "%s\n", version); | 15292 | printk_once(KERN_INFO "%s\n", version); |
15319 | 15293 | ||
diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c index fd3dcc1e9145..38d5c66075f9 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c +++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c | |||
@@ -296,8 +296,8 @@ bnad_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) | |||
296 | struct bfa_ioc_attr *ioc_attr; | 296 | struct bfa_ioc_attr *ioc_attr; |
297 | unsigned long flags; | 297 | unsigned long flags; |
298 | 298 | ||
299 | strcpy(drvinfo->driver, BNAD_NAME); | 299 | strlcpy(drvinfo->driver, BNAD_NAME, sizeof(drvinfo->driver)); |
300 | strcpy(drvinfo->version, BNAD_VERSION); | 300 | strlcpy(drvinfo->version, BNAD_VERSION, sizeof(drvinfo->version)); |
301 | 301 | ||
302 | ioc_attr = kzalloc(sizeof(*ioc_attr), GFP_KERNEL); | 302 | ioc_attr = kzalloc(sizeof(*ioc_attr), GFP_KERNEL); |
303 | if (ioc_attr) { | 303 | if (ioc_attr) { |
@@ -305,12 +305,13 @@ bnad_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) | |||
305 | bfa_nw_ioc_get_attr(&bnad->bna.ioceth.ioc, ioc_attr); | 305 | bfa_nw_ioc_get_attr(&bnad->bna.ioceth.ioc, ioc_attr); |
306 | spin_unlock_irqrestore(&bnad->bna_lock, flags); | 306 | spin_unlock_irqrestore(&bnad->bna_lock, flags); |
307 | 307 | ||
308 | strncpy(drvinfo->fw_version, ioc_attr->adapter_attr.fw_ver, | 308 | strlcpy(drvinfo->fw_version, ioc_attr->adapter_attr.fw_ver, |
309 | sizeof(drvinfo->fw_version) - 1); | 309 | sizeof(drvinfo->fw_version)); |
310 | kfree(ioc_attr); | 310 | kfree(ioc_attr); |
311 | } | 311 | } |
312 | 312 | ||
313 | strncpy(drvinfo->bus_info, pci_name(bnad->pcidev), ETHTOOL_BUSINFO_LEN); | 313 | strlcpy(drvinfo->bus_info, pci_name(bnad->pcidev), |
314 | sizeof(drvinfo->bus_info)); | ||
314 | } | 315 | } |
315 | 316 | ||
316 | static void | 317 | static void |
diff --git a/drivers/net/ethernet/brocade/bna/cna.h b/drivers/net/ethernet/brocade/bna/cna.h index 1b3e90dfbd9a..32e8f178ab76 100644 --- a/drivers/net/ethernet/brocade/bna/cna.h +++ b/drivers/net/ethernet/brocade/bna/cna.h | |||
@@ -43,8 +43,7 @@ extern char bfa_version[]; | |||
43 | 43 | ||
44 | #pragma pack(1) | 44 | #pragma pack(1) |
45 | 45 | ||
46 | #define MAC_ADDRLEN (6) | 46 | typedef struct mac { u8 mac[ETH_ALEN]; } mac_t; |
47 | typedef struct mac { u8 mac[MAC_ADDRLEN]; } mac_t; | ||
48 | 47 | ||
49 | #pragma pack() | 48 | #pragma pack() |
50 | 49 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c index ca26d97171bd..a971796b2262 100644 --- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c +++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c | |||
@@ -434,10 +434,11 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
434 | { | 434 | { |
435 | struct adapter *adapter = dev->ml_priv; | 435 | struct adapter *adapter = dev->ml_priv; |
436 | 436 | ||
437 | strcpy(info->driver, DRV_NAME); | 437 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
438 | strcpy(info->version, DRV_VERSION); | 438 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
439 | strcpy(info->fw_version, "N/A"); | 439 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
440 | strcpy(info->bus_info, pci_name(adapter->pdev)); | 440 | strlcpy(info->bus_info, pci_name(adapter->pdev), |
441 | sizeof(info->bus_info)); | ||
441 | } | 442 | } |
442 | 443 | ||
443 | static int get_sset_count(struct net_device *dev, int sset) | 444 | static int get_sset_count(struct net_device *dev, int sset) |
@@ -849,7 +850,8 @@ static int t1_set_mac_addr(struct net_device *dev, void *p) | |||
849 | return 0; | 850 | return 0; |
850 | } | 851 | } |
851 | 852 | ||
852 | static u32 t1_fix_features(struct net_device *dev, u32 features) | 853 | static netdev_features_t t1_fix_features(struct net_device *dev, |
854 | netdev_features_t features) | ||
853 | { | 855 | { |
854 | /* | 856 | /* |
855 | * Since there is no support for separate rx/tx vlan accel | 857 | * Since there is no support for separate rx/tx vlan accel |
@@ -863,9 +865,9 @@ static u32 t1_fix_features(struct net_device *dev, u32 features) | |||
863 | return features; | 865 | return features; |
864 | } | 866 | } |
865 | 867 | ||
866 | static int t1_set_features(struct net_device *dev, u32 features) | 868 | static int t1_set_features(struct net_device *dev, netdev_features_t features) |
867 | { | 869 | { |
868 | u32 changed = dev->features ^ features; | 870 | netdev_features_t changed = dev->features ^ features; |
869 | struct adapter *adapter = dev->ml_priv; | 871 | struct adapter *adapter = dev->ml_priv; |
870 | 872 | ||
871 | if (changed & NETIF_F_HW_VLAN_RX) | 873 | if (changed & NETIF_F_HW_VLAN_RX) |
diff --git a/drivers/net/ethernet/chelsio/cxgb/sge.c b/drivers/net/ethernet/chelsio/cxgb/sge.c index f9b602300040..47a84359d4e4 100644 --- a/drivers/net/ethernet/chelsio/cxgb/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb/sge.c | |||
@@ -742,7 +742,7 @@ static inline void setup_ring_params(struct adapter *adapter, u64 addr, | |||
742 | /* | 742 | /* |
743 | * Enable/disable VLAN acceleration. | 743 | * Enable/disable VLAN acceleration. |
744 | */ | 744 | */ |
745 | void t1_vlan_mode(struct adapter *adapter, u32 features) | 745 | void t1_vlan_mode(struct adapter *adapter, netdev_features_t features) |
746 | { | 746 | { |
747 | struct sge *sge = adapter->sge; | 747 | struct sge *sge = adapter->sge; |
748 | 748 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb/sge.h b/drivers/net/ethernet/chelsio/cxgb/sge.h index e03980bcdd65..b9bf16b385f7 100644 --- a/drivers/net/ethernet/chelsio/cxgb/sge.h +++ b/drivers/net/ethernet/chelsio/cxgb/sge.h | |||
@@ -79,7 +79,7 @@ irqreturn_t t1_interrupt(int irq, void *cookie); | |||
79 | int t1_poll(struct napi_struct *, int); | 79 | int t1_poll(struct napi_struct *, int); |
80 | 80 | ||
81 | netdev_tx_t t1_start_xmit(struct sk_buff *skb, struct net_device *dev); | 81 | netdev_tx_t t1_start_xmit(struct sk_buff *skb, struct net_device *dev); |
82 | void t1_vlan_mode(struct adapter *adapter, u32 features); | 82 | void t1_vlan_mode(struct adapter *adapter, netdev_features_t features); |
83 | void t1_sge_start(struct sge *); | 83 | void t1_sge_start(struct sge *); |
84 | void t1_sge_stop(struct sge *); | 84 | void t1_sge_stop(struct sge *); |
85 | int t1_sge_intr_error_handler(struct sge *); | 85 | int t1_sge_intr_error_handler(struct sge *); |
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c index 4d15c8f99c3b..63ffaa7e255f 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | |||
@@ -1576,11 +1576,12 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
1576 | t3_get_tp_version(adapter, &tp_vers); | 1576 | t3_get_tp_version(adapter, &tp_vers); |
1577 | spin_unlock(&adapter->stats_lock); | 1577 | spin_unlock(&adapter->stats_lock); |
1578 | 1578 | ||
1579 | strcpy(info->driver, DRV_NAME); | 1579 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1580 | strcpy(info->version, DRV_VERSION); | 1580 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1581 | strcpy(info->bus_info, pci_name(adapter->pdev)); | 1581 | strlcpy(info->bus_info, pci_name(adapter->pdev), |
1582 | sizeof(info->bus_info)); | ||
1582 | if (!fw_vers) | 1583 | if (!fw_vers) |
1583 | strcpy(info->fw_version, "N/A"); | 1584 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
1584 | else { | 1585 | else { |
1585 | snprintf(info->fw_version, sizeof(info->fw_version), | 1586 | snprintf(info->fw_version, sizeof(info->fw_version), |
1586 | "%s %u.%u.%u TP %u.%u.%u", | 1587 | "%s %u.%u.%u TP %u.%u.%u", |
@@ -2531,7 +2532,7 @@ static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p) | |||
2531 | } | 2532 | } |
2532 | } | 2533 | } |
2533 | 2534 | ||
2534 | static void cxgb_vlan_mode(struct net_device *dev, u32 features) | 2535 | static void cxgb_vlan_mode(struct net_device *dev, netdev_features_t features) |
2535 | { | 2536 | { |
2536 | struct port_info *pi = netdev_priv(dev); | 2537 | struct port_info *pi = netdev_priv(dev); |
2537 | struct adapter *adapter = pi->adapter; | 2538 | struct adapter *adapter = pi->adapter; |
@@ -2552,7 +2553,8 @@ static void cxgb_vlan_mode(struct net_device *dev, u32 features) | |||
2552 | t3_synchronize_rx(adapter, pi); | 2553 | t3_synchronize_rx(adapter, pi); |
2553 | } | 2554 | } |
2554 | 2555 | ||
2555 | static u32 cxgb_fix_features(struct net_device *dev, u32 features) | 2556 | static netdev_features_t cxgb_fix_features(struct net_device *dev, |
2557 | netdev_features_t features) | ||
2556 | { | 2558 | { |
2557 | /* | 2559 | /* |
2558 | * Since there is no support for separate rx/tx vlan accel | 2560 | * Since there is no support for separate rx/tx vlan accel |
@@ -2566,9 +2568,9 @@ static u32 cxgb_fix_features(struct net_device *dev, u32 features) | |||
2566 | return features; | 2568 | return features; |
2567 | } | 2569 | } |
2568 | 2570 | ||
2569 | static int cxgb_set_features(struct net_device *dev, u32 features) | 2571 | static int cxgb_set_features(struct net_device *dev, netdev_features_t features) |
2570 | { | 2572 | { |
2571 | u32 changed = dev->features ^ features; | 2573 | netdev_features_t changed = dev->features ^ features; |
2572 | 2574 | ||
2573 | if (changed & NETIF_F_HW_VLAN_RX) | 2575 | if (changed & NETIF_F_HW_VLAN_RX) |
2574 | cxgb_vlan_mode(dev, features); | 2576 | cxgb_vlan_mode(dev, features); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 4c8f42afa3c6..fd6d460ea475 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | |||
@@ -1002,12 +1002,13 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
1002 | { | 1002 | { |
1003 | struct adapter *adapter = netdev2adap(dev); | 1003 | struct adapter *adapter = netdev2adap(dev); |
1004 | 1004 | ||
1005 | strcpy(info->driver, KBUILD_MODNAME); | 1005 | strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); |
1006 | strcpy(info->version, DRV_VERSION); | 1006 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1007 | strcpy(info->bus_info, pci_name(adapter->pdev)); | 1007 | strlcpy(info->bus_info, pci_name(adapter->pdev), |
1008 | sizeof(info->bus_info)); | ||
1008 | 1009 | ||
1009 | if (!adapter->params.fw_vers) | 1010 | if (!adapter->params.fw_vers) |
1010 | strcpy(info->fw_version, "N/A"); | 1011 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
1011 | else | 1012 | else |
1012 | snprintf(info->fw_version, sizeof(info->fw_version), | 1013 | snprintf(info->fw_version, sizeof(info->fw_version), |
1013 | "%u.%u.%u.%u, TP %u.%u.%u.%u", | 1014 | "%u.%u.%u.%u, TP %u.%u.%u.%u", |
@@ -1855,10 +1856,10 @@ static int set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
1855 | return err; | 1856 | return err; |
1856 | } | 1857 | } |
1857 | 1858 | ||
1858 | static int cxgb_set_features(struct net_device *dev, u32 features) | 1859 | static int cxgb_set_features(struct net_device *dev, netdev_features_t features) |
1859 | { | 1860 | { |
1860 | const struct port_info *pi = netdev_priv(dev); | 1861 | const struct port_info *pi = netdev_priv(dev); |
1861 | u32 changed = dev->features ^ features; | 1862 | netdev_features_t changed = dev->features ^ features; |
1862 | int err; | 1863 | int err; |
1863 | 1864 | ||
1864 | if (!(changed & NETIF_F_HW_VLAN_RX)) | 1865 | if (!(changed & NETIF_F_HW_VLAN_RX)) |
@@ -3537,7 +3538,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
3537 | { | 3538 | { |
3538 | int func, i, err; | 3539 | int func, i, err; |
3539 | struct port_info *pi; | 3540 | struct port_info *pi; |
3540 | unsigned int highdma = 0; | 3541 | bool highdma = false; |
3541 | struct adapter *adapter = NULL; | 3542 | struct adapter *adapter = NULL; |
3542 | 3543 | ||
3543 | printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION); | 3544 | printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION); |
@@ -3563,7 +3564,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
3563 | } | 3564 | } |
3564 | 3565 | ||
3565 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { | 3566 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { |
3566 | highdma = NETIF_F_HIGHDMA; | 3567 | highdma = true; |
3567 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); | 3568 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); |
3568 | if (err) { | 3569 | if (err) { |
3569 | dev_err(&pdev->dev, "unable to obtain 64-bit DMA for " | 3570 | dev_err(&pdev->dev, "unable to obtain 64-bit DMA for " |
@@ -3637,7 +3638,9 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
3637 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | | 3638 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
3638 | NETIF_F_RXCSUM | NETIF_F_RXHASH | | 3639 | NETIF_F_RXCSUM | NETIF_F_RXHASH | |
3639 | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | 3640 | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; |
3640 | netdev->features |= netdev->hw_features | highdma; | 3641 | if (highdma) |
3642 | netdev->hw_features |= NETIF_F_HIGHDMA; | ||
3643 | netdev->features |= netdev->hw_features; | ||
3641 | netdev->vlan_features = netdev->features & VLAN_FEAT; | 3644 | netdev->vlan_features = netdev->features & VLAN_FEAT; |
3642 | 3645 | ||
3643 | netdev->priv_flags |= IFF_UNICAST_FLT; | 3646 | netdev->priv_flags |= IFF_UNICAST_FLT; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index da9072bfca8b..8155cfecae19 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | |||
@@ -1092,7 +1092,8 @@ static int cxgb4vf_change_mtu(struct net_device *dev, int new_mtu) | |||
1092 | return ret; | 1092 | return ret; |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | static u32 cxgb4vf_fix_features(struct net_device *dev, u32 features) | 1095 | static netdev_features_t cxgb4vf_fix_features(struct net_device *dev, |
1096 | netdev_features_t features) | ||
1096 | { | 1097 | { |
1097 | /* | 1098 | /* |
1098 | * Since there is no support for separate rx/tx vlan accel | 1099 | * Since there is no support for separate rx/tx vlan accel |
@@ -1106,10 +1107,11 @@ static u32 cxgb4vf_fix_features(struct net_device *dev, u32 features) | |||
1106 | return features; | 1107 | return features; |
1107 | } | 1108 | } |
1108 | 1109 | ||
1109 | static int cxgb4vf_set_features(struct net_device *dev, u32 features) | 1110 | static int cxgb4vf_set_features(struct net_device *dev, |
1111 | netdev_features_t features) | ||
1110 | { | 1112 | { |
1111 | struct port_info *pi = netdev_priv(dev); | 1113 | struct port_info *pi = netdev_priv(dev); |
1112 | u32 changed = dev->features ^ features; | 1114 | netdev_features_t changed = dev->features ^ features; |
1113 | 1115 | ||
1114 | if (changed & NETIF_F_HW_VLAN_RX) | 1116 | if (changed & NETIF_F_HW_VLAN_RX) |
1115 | t4vf_set_rxmode(pi->adapter, pi->viid, -1, -1, -1, -1, | 1117 | t4vf_set_rxmode(pi->adapter, pi->viid, -1, -1, -1, -1, |
@@ -1203,9 +1205,10 @@ static void cxgb4vf_get_drvinfo(struct net_device *dev, | |||
1203 | { | 1205 | { |
1204 | struct adapter *adapter = netdev2adap(dev); | 1206 | struct adapter *adapter = netdev2adap(dev); |
1205 | 1207 | ||
1206 | strcpy(drvinfo->driver, KBUILD_MODNAME); | 1208 | strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); |
1207 | strcpy(drvinfo->version, DRV_VERSION); | 1209 | strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); |
1208 | strcpy(drvinfo->bus_info, pci_name(to_pci_dev(dev->dev.parent))); | 1210 | strlcpy(drvinfo->bus_info, pci_name(to_pci_dev(dev->dev.parent)), |
1211 | sizeof(drvinfo->bus_info)); | ||
1209 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), | 1212 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), |
1210 | "%u.%u.%u.%u, TP %u.%u.%u.%u", | 1213 | "%u.%u.%u.%u, TP %u.%u.%u.%u", |
1211 | FW_HDR_FW_VER_MAJOR_GET(adapter->params.dev.fwrev), | 1214 | FW_HDR_FW_VER_MAJOR_GET(adapter->params.dev.fwrev), |
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index c3786fda11db..1fe5df0284a6 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c | |||
@@ -217,11 +217,11 @@ static void enic_get_drvinfo(struct net_device *netdev, | |||
217 | 217 | ||
218 | enic_dev_fw_info(enic, &fw_info); | 218 | enic_dev_fw_info(enic, &fw_info); |
219 | 219 | ||
220 | strncpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); | 220 | strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); |
221 | strncpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); | 221 | strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); |
222 | strncpy(drvinfo->fw_version, fw_info->fw_version, | 222 | strlcpy(drvinfo->fw_version, fw_info->fw_version, |
223 | sizeof(drvinfo->fw_version)); | 223 | sizeof(drvinfo->fw_version)); |
224 | strncpy(drvinfo->bus_info, pci_name(enic->pdev), | 224 | strlcpy(drvinfo->bus_info, pci_name(enic->pdev), |
225 | sizeof(drvinfo->bus_info)); | 225 | sizeof(drvinfo->bus_info)); |
226 | } | 226 | } |
227 | 227 | ||
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c index 438f4580bf66..26be1dfc1577 100644 --- a/drivers/net/ethernet/davicom/dm9000.c +++ b/drivers/net/ethernet/davicom/dm9000.c | |||
@@ -474,10 +474,11 @@ static int dm9000_nway_reset(struct net_device *dev) | |||
474 | return mii_nway_restart(&dm->mii); | 474 | return mii_nway_restart(&dm->mii); |
475 | } | 475 | } |
476 | 476 | ||
477 | static int dm9000_set_features(struct net_device *dev, u32 features) | 477 | static int dm9000_set_features(struct net_device *dev, |
478 | netdev_features_t features) | ||
478 | { | 479 | { |
479 | board_info_t *dm = to_dm9000_board(dev); | 480 | board_info_t *dm = to_dm9000_board(dev); |
480 | u32 changed = dev->features ^ features; | 481 | netdev_features_t changed = dev->features ^ features; |
481 | unsigned long flags; | 482 | unsigned long flags; |
482 | 483 | ||
483 | if (!(changed & NETIF_F_RXCSUM)) | 484 | if (!(changed & NETIF_F_RXCSUM)) |
diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c index 1427739d9a51..1eb46a0bb488 100644 --- a/drivers/net/ethernet/dec/tulip/de2104x.c +++ b/drivers/net/ethernet/dec/tulip/de2104x.c | |||
@@ -1598,9 +1598,9 @@ static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) | |||
1598 | { | 1598 | { |
1599 | struct de_private *de = netdev_priv(dev); | 1599 | struct de_private *de = netdev_priv(dev); |
1600 | 1600 | ||
1601 | strcpy (info->driver, DRV_NAME); | 1601 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1602 | strcpy (info->version, DRV_VERSION); | 1602 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1603 | strcpy (info->bus_info, pci_name(de->pdev)); | 1603 | strlcpy(info->bus_info, pci_name(de->pdev), sizeof(info->bus_info)); |
1604 | info->eedump_len = DE_EEPROM_SIZE; | 1604 | info->eedump_len = DE_EEPROM_SIZE; |
1605 | } | 1605 | } |
1606 | 1606 | ||
diff --git a/drivers/net/ethernet/dec/tulip/dmfe.c b/drivers/net/ethernet/dec/tulip/dmfe.c index 17b11ee1745a..51f7542eb451 100644 --- a/drivers/net/ethernet/dec/tulip/dmfe.c +++ b/drivers/net/ethernet/dec/tulip/dmfe.c | |||
@@ -1085,10 +1085,11 @@ static void dmfe_ethtool_get_drvinfo(struct net_device *dev, | |||
1085 | { | 1085 | { |
1086 | struct dmfe_board_info *np = netdev_priv(dev); | 1086 | struct dmfe_board_info *np = netdev_priv(dev); |
1087 | 1087 | ||
1088 | strcpy(info->driver, DRV_NAME); | 1088 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1089 | strcpy(info->version, DRV_VERSION); | 1089 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1090 | if (np->pdev) | 1090 | if (np->pdev) |
1091 | strcpy(info->bus_info, pci_name(np->pdev)); | 1091 | strlcpy(info->bus_info, pci_name(np->pdev), |
1092 | sizeof(info->bus_info)); | ||
1092 | else | 1093 | else |
1093 | sprintf(info->bus_info, "EISA 0x%lx %d", | 1094 | sprintf(info->bus_info, "EISA 0x%lx %d", |
1094 | dev->base_addr, dev->irq); | 1095 | dev->base_addr, dev->irq); |
diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c index 9656dd0647d9..4eb0d76145c2 100644 --- a/drivers/net/ethernet/dec/tulip/tulip_core.c +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c | |||
@@ -871,9 +871,9 @@ static struct net_device_stats *tulip_get_stats(struct net_device *dev) | |||
871 | static void tulip_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 871 | static void tulip_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
872 | { | 872 | { |
873 | struct tulip_private *np = netdev_priv(dev); | 873 | struct tulip_private *np = netdev_priv(dev); |
874 | strcpy(info->driver, DRV_NAME); | 874 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
875 | strcpy(info->version, DRV_VERSION); | 875 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
876 | strcpy(info->bus_info, pci_name(np->pdev)); | 876 | strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info)); |
877 | } | 877 | } |
878 | 878 | ||
879 | 879 | ||
diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c index 7a44a7a6adc8..48b0b6566eef 100644 --- a/drivers/net/ethernet/dec/tulip/uli526x.c +++ b/drivers/net/ethernet/dec/tulip/uli526x.c | |||
@@ -960,10 +960,11 @@ static void netdev_get_drvinfo(struct net_device *dev, | |||
960 | { | 960 | { |
961 | struct uli526x_board_info *np = netdev_priv(dev); | 961 | struct uli526x_board_info *np = netdev_priv(dev); |
962 | 962 | ||
963 | strcpy(info->driver, DRV_NAME); | 963 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
964 | strcpy(info->version, DRV_VERSION); | 964 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
965 | if (np->pdev) | 965 | if (np->pdev) |
966 | strcpy(info->bus_info, pci_name(np->pdev)); | 966 | strlcpy(info->bus_info, pci_name(np->pdev), |
967 | sizeof(info->bus_info)); | ||
967 | else | 968 | else |
968 | sprintf(info->bus_info, "EISA 0x%lx %d", | 969 | sprintf(info->bus_info, "EISA 0x%lx %d", |
969 | dev->base_addr, dev->irq); | 970 | dev->base_addr, dev->irq); |
diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c index 4d01219ba22f..52da7b2fe3b6 100644 --- a/drivers/net/ethernet/dec/tulip/winbond-840.c +++ b/drivers/net/ethernet/dec/tulip/winbond-840.c | |||
@@ -1390,9 +1390,9 @@ static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo * | |||
1390 | { | 1390 | { |
1391 | struct netdev_private *np = netdev_priv(dev); | 1391 | struct netdev_private *np = netdev_priv(dev); |
1392 | 1392 | ||
1393 | strcpy (info->driver, DRV_NAME); | 1393 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1394 | strcpy (info->version, DRV_VERSION); | 1394 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1395 | strcpy (info->bus_info, pci_name(np->pci_dev)); | 1395 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1398 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c index dcd7f7a71ad4..28a3a9b50b8b 100644 --- a/drivers/net/ethernet/dlink/sundance.c +++ b/drivers/net/ethernet/dlink/sundance.c | |||
@@ -1634,9 +1634,9 @@ static int check_if_running(struct net_device *dev) | |||
1634 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1634 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1635 | { | 1635 | { |
1636 | struct netdev_private *np = netdev_priv(dev); | 1636 | struct netdev_private *np = netdev_priv(dev); |
1637 | strcpy(info->driver, DRV_NAME); | 1637 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1638 | strcpy(info->version, DRV_VERSION); | 1638 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1639 | strcpy(info->bus_info, pci_name(np->pci_dev)); | 1639 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 1642 | static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c index c1063d1540c2..d94b9686b80c 100644 --- a/drivers/net/ethernet/dnet.c +++ b/drivers/net/ethernet/dnet.c | |||
@@ -804,9 +804,9 @@ static int dnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
804 | static void dnet_get_drvinfo(struct net_device *dev, | 804 | static void dnet_get_drvinfo(struct net_device *dev, |
805 | struct ethtool_drvinfo *info) | 805 | struct ethtool_drvinfo *info) |
806 | { | 806 | { |
807 | strcpy(info->driver, DRV_NAME); | 807 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
808 | strcpy(info->version, DRV_VERSION); | 808 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
809 | strcpy(info->bus_info, "0"); | 809 | strlcpy(info->bus_info, "0", sizeof(info->bus_info)); |
810 | } | 810 | } |
811 | 811 | ||
812 | static const struct ethtool_ops dnet_ethtool_ops = { | 812 | static const struct ethtool_ops dnet_ethtool_ops = { |
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 644e8fed8364..34f162db9f2e 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h | |||
@@ -289,14 +289,12 @@ struct be_drv_stats { | |||
289 | 289 | ||
290 | struct be_vf_cfg { | 290 | struct be_vf_cfg { |
291 | unsigned char vf_mac_addr[ETH_ALEN]; | 291 | unsigned char vf_mac_addr[ETH_ALEN]; |
292 | u32 vf_if_handle; | 292 | int vf_if_handle; |
293 | u32 vf_pmac_id; | 293 | int vf_pmac_id; |
294 | u16 vf_vlan_tag; | 294 | u16 vf_vlan_tag; |
295 | u32 vf_tx_rate; | 295 | u32 vf_tx_rate; |
296 | }; | 296 | }; |
297 | 297 | ||
298 | #define BE_INVALID_PMAC_ID 0xffffffff | ||
299 | |||
300 | struct be_adapter { | 298 | struct be_adapter { |
301 | struct pci_dev *pdev; | 299 | struct pci_dev *pdev; |
302 | struct net_device *netdev; | 300 | struct net_device *netdev; |
@@ -347,11 +345,13 @@ struct be_adapter { | |||
347 | 345 | ||
348 | /* Ethtool knobs and info */ | 346 | /* Ethtool knobs and info */ |
349 | char fw_ver[FW_VER_LEN]; | 347 | char fw_ver[FW_VER_LEN]; |
350 | u32 if_handle; /* Used to configure filtering */ | 348 | int if_handle; /* Used to configure filtering */ |
351 | u32 pmac_id; /* MAC addr handle used by BE card */ | 349 | u32 pmac_id; /* MAC addr handle used by BE card */ |
352 | u32 beacon_state; /* for set_phys_id */ | 350 | u32 beacon_state; /* for set_phys_id */ |
353 | 351 | ||
354 | bool eeh_err; | 352 | bool eeh_err; |
353 | bool ue_detected; | ||
354 | bool fw_timeout; | ||
355 | u32 port_num; | 355 | u32 port_num; |
356 | bool promiscuous; | 356 | bool promiscuous; |
357 | bool wol; | 357 | bool wol; |
@@ -359,7 +359,6 @@ struct be_adapter { | |||
359 | u32 function_caps; | 359 | u32 function_caps; |
360 | u32 rx_fc; /* Rx flow control */ | 360 | u32 rx_fc; /* Rx flow control */ |
361 | u32 tx_fc; /* Tx flow control */ | 361 | u32 tx_fc; /* Tx flow control */ |
362 | bool ue_detected; | ||
363 | bool stats_cmd_sent; | 362 | bool stats_cmd_sent; |
364 | int link_speed; | 363 | int link_speed; |
365 | u8 port_type; | 364 | u8 port_type; |
@@ -524,6 +523,11 @@ static inline bool be_multi_rxq(const struct be_adapter *adapter) | |||
524 | return adapter->num_rx_qs > 1; | 523 | return adapter->num_rx_qs > 1; |
525 | } | 524 | } |
526 | 525 | ||
526 | static inline bool be_error(struct be_adapter *adapter) | ||
527 | { | ||
528 | return adapter->eeh_err || adapter->ue_detected || adapter->fw_timeout; | ||
529 | } | ||
530 | |||
527 | extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, | 531 | extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, |
528 | u16 num_popped); | 532 | u16 num_popped); |
529 | extern void be_link_status_update(struct be_adapter *adapter, u32 link_status); | 533 | extern void be_link_status_update(struct be_adapter *adapter, u32 link_status); |
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 2c7b36673dfc..64f0c1aa1b09 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c | |||
@@ -31,11 +31,8 @@ static void be_mcc_notify(struct be_adapter *adapter) | |||
31 | struct be_queue_info *mccq = &adapter->mcc_obj.q; | 31 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
32 | u32 val = 0; | 32 | u32 val = 0; |
33 | 33 | ||
34 | if (adapter->eeh_err) { | 34 | if (be_error(adapter)) |
35 | dev_info(&adapter->pdev->dev, | ||
36 | "Error in Card Detected! Cannot issue commands\n"); | ||
37 | return; | 35 | return; |
38 | } | ||
39 | 36 | ||
40 | val |= mccq->id & DB_MCCQ_RING_ID_MASK; | 37 | val |= mccq->id & DB_MCCQ_RING_ID_MASK; |
41 | val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; | 38 | val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; |
@@ -266,10 +263,10 @@ static int be_mcc_wait_compl(struct be_adapter *adapter) | |||
266 | int i, num, status = 0; | 263 | int i, num, status = 0; |
267 | struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; | 264 | struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; |
268 | 265 | ||
269 | if (adapter->eeh_err) | ||
270 | return -EIO; | ||
271 | |||
272 | for (i = 0; i < mcc_timeout; i++) { | 266 | for (i = 0; i < mcc_timeout; i++) { |
267 | if (be_error(adapter)) | ||
268 | return -EIO; | ||
269 | |||
273 | num = be_process_mcc(adapter, &status); | 270 | num = be_process_mcc(adapter, &status); |
274 | if (num) | 271 | if (num) |
275 | be_cq_notify(adapter, mcc_obj->cq.id, | 272 | be_cq_notify(adapter, mcc_obj->cq.id, |
@@ -280,7 +277,8 @@ static int be_mcc_wait_compl(struct be_adapter *adapter) | |||
280 | udelay(100); | 277 | udelay(100); |
281 | } | 278 | } |
282 | if (i == mcc_timeout) { | 279 | if (i == mcc_timeout) { |
283 | dev_err(&adapter->pdev->dev, "mccq poll timed out\n"); | 280 | dev_err(&adapter->pdev->dev, "FW not responding\n"); |
281 | adapter->fw_timeout = true; | ||
284 | return -1; | 282 | return -1; |
285 | } | 283 | } |
286 | return status; | 284 | return status; |
@@ -298,26 +296,21 @@ static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) | |||
298 | int msecs = 0; | 296 | int msecs = 0; |
299 | u32 ready; | 297 | u32 ready; |
300 | 298 | ||
301 | if (adapter->eeh_err) { | ||
302 | dev_err(&adapter->pdev->dev, | ||
303 | "Error detected in card.Cannot issue commands\n"); | ||
304 | return -EIO; | ||
305 | } | ||
306 | |||
307 | do { | 299 | do { |
300 | if (be_error(adapter)) | ||
301 | return -EIO; | ||
302 | |||
308 | ready = ioread32(db); | 303 | ready = ioread32(db); |
309 | if (ready == 0xffffffff) { | 304 | if (ready == 0xffffffff) |
310 | dev_err(&adapter->pdev->dev, | ||
311 | "pci slot disconnected\n"); | ||
312 | return -1; | 305 | return -1; |
313 | } | ||
314 | 306 | ||
315 | ready &= MPU_MAILBOX_DB_RDY_MASK; | 307 | ready &= MPU_MAILBOX_DB_RDY_MASK; |
316 | if (ready) | 308 | if (ready) |
317 | break; | 309 | break; |
318 | 310 | ||
319 | if (msecs > 4000) { | 311 | if (msecs > 4000) { |
320 | dev_err(&adapter->pdev->dev, "mbox poll timed out\n"); | 312 | dev_err(&adapter->pdev->dev, "FW not responding\n"); |
313 | adapter->fw_timeout = true; | ||
321 | be_detect_dump_ue(adapter); | 314 | be_detect_dump_ue(adapter); |
322 | return -1; | 315 | return -1; |
323 | } | 316 | } |
@@ -555,9 +548,6 @@ int be_cmd_fw_clean(struct be_adapter *adapter) | |||
555 | u8 *wrb; | 548 | u8 *wrb; |
556 | int status; | 549 | int status; |
557 | 550 | ||
558 | if (adapter->eeh_err) | ||
559 | return -EIO; | ||
560 | |||
561 | if (mutex_lock_interruptible(&adapter->mbox_lock)) | 551 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
562 | return -1; | 552 | return -1; |
563 | 553 | ||
@@ -695,12 +685,15 @@ err: | |||
695 | } | 685 | } |
696 | 686 | ||
697 | /* Uses synchronous MCCQ */ | 687 | /* Uses synchronous MCCQ */ |
698 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id, u32 dom) | 688 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id, u32 dom) |
699 | { | 689 | { |
700 | struct be_mcc_wrb *wrb; | 690 | struct be_mcc_wrb *wrb; |
701 | struct be_cmd_req_pmac_del *req; | 691 | struct be_cmd_req_pmac_del *req; |
702 | int status; | 692 | int status; |
703 | 693 | ||
694 | if (pmac_id == -1) | ||
695 | return 0; | ||
696 | |||
704 | spin_lock_bh(&adapter->mcc_lock); | 697 | spin_lock_bh(&adapter->mcc_lock); |
705 | 698 | ||
706 | wrb = wrb_from_mccq(adapter); | 699 | wrb = wrb_from_mccq(adapter); |
@@ -923,10 +916,14 @@ int be_cmd_txq_create(struct be_adapter *adapter, | |||
923 | void *ctxt; | 916 | void *ctxt; |
924 | int status; | 917 | int status; |
925 | 918 | ||
926 | if (mutex_lock_interruptible(&adapter->mbox_lock)) | 919 | spin_lock_bh(&adapter->mcc_lock); |
927 | return -1; | 920 | |
921 | wrb = wrb_from_mccq(adapter); | ||
922 | if (!wrb) { | ||
923 | status = -EBUSY; | ||
924 | goto err; | ||
925 | } | ||
928 | 926 | ||
929 | wrb = wrb_from_mbox(adapter); | ||
930 | req = embedded_payload(wrb); | 927 | req = embedded_payload(wrb); |
931 | ctxt = &req->context; | 928 | ctxt = &req->context; |
932 | 929 | ||
@@ -952,14 +949,15 @@ int be_cmd_txq_create(struct be_adapter *adapter, | |||
952 | 949 | ||
953 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 950 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
954 | 951 | ||
955 | status = be_mbox_notify_wait(adapter); | 952 | status = be_mcc_notify_wait(adapter); |
956 | if (!status) { | 953 | if (!status) { |
957 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); | 954 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); |
958 | txq->id = le16_to_cpu(resp->cid); | 955 | txq->id = le16_to_cpu(resp->cid); |
959 | txq->created = true; | 956 | txq->created = true; |
960 | } | 957 | } |
961 | 958 | ||
962 | mutex_unlock(&adapter->mbox_lock); | 959 | err: |
960 | spin_unlock_bh(&adapter->mcc_lock); | ||
963 | 961 | ||
964 | return status; | 962 | return status; |
965 | } | 963 | } |
@@ -1018,9 +1016,6 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, | |||
1018 | u8 subsys = 0, opcode = 0; | 1016 | u8 subsys = 0, opcode = 0; |
1019 | int status; | 1017 | int status; |
1020 | 1018 | ||
1021 | if (adapter->eeh_err) | ||
1022 | return -EIO; | ||
1023 | |||
1024 | if (mutex_lock_interruptible(&adapter->mbox_lock)) | 1019 | if (mutex_lock_interruptible(&adapter->mbox_lock)) |
1025 | return -1; | 1020 | return -1; |
1026 | 1021 | ||
@@ -1136,16 +1131,13 @@ err: | |||
1136 | } | 1131 | } |
1137 | 1132 | ||
1138 | /* Uses MCCQ */ | 1133 | /* Uses MCCQ */ |
1139 | int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) | 1134 | int be_cmd_if_destroy(struct be_adapter *adapter, int interface_id, u32 domain) |
1140 | { | 1135 | { |
1141 | struct be_mcc_wrb *wrb; | 1136 | struct be_mcc_wrb *wrb; |
1142 | struct be_cmd_req_if_destroy *req; | 1137 | struct be_cmd_req_if_destroy *req; |
1143 | int status; | 1138 | int status; |
1144 | 1139 | ||
1145 | if (adapter->eeh_err) | 1140 | if (interface_id == -1) |
1146 | return -EIO; | ||
1147 | |||
1148 | if (!interface_id) | ||
1149 | return 0; | 1141 | return 0; |
1150 | 1142 | ||
1151 | spin_lock_bh(&adapter->mcc_lock); | 1143 | spin_lock_bh(&adapter->mcc_lock); |
@@ -1254,6 +1246,9 @@ int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, | |||
1254 | } | 1246 | } |
1255 | req = embedded_payload(wrb); | 1247 | req = embedded_payload(wrb); |
1256 | 1248 | ||
1249 | if (lancer_chip(adapter)) | ||
1250 | req->hdr.version = 1; | ||
1251 | |||
1257 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 1252 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
1258 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req), wrb, NULL); | 1253 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req), wrb, NULL); |
1259 | 1254 | ||
@@ -1836,6 +1831,53 @@ err_unlock: | |||
1836 | return status; | 1831 | return status; |
1837 | } | 1832 | } |
1838 | 1833 | ||
1834 | int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd, | ||
1835 | u32 data_size, u32 data_offset, const char *obj_name, | ||
1836 | u32 *data_read, u32 *eof, u8 *addn_status) | ||
1837 | { | ||
1838 | struct be_mcc_wrb *wrb; | ||
1839 | struct lancer_cmd_req_read_object *req; | ||
1840 | struct lancer_cmd_resp_read_object *resp; | ||
1841 | int status; | ||
1842 | |||
1843 | spin_lock_bh(&adapter->mcc_lock); | ||
1844 | |||
1845 | wrb = wrb_from_mccq(adapter); | ||
1846 | if (!wrb) { | ||
1847 | status = -EBUSY; | ||
1848 | goto err_unlock; | ||
1849 | } | ||
1850 | |||
1851 | req = embedded_payload(wrb); | ||
1852 | |||
1853 | be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | ||
1854 | OPCODE_COMMON_READ_OBJECT, | ||
1855 | sizeof(struct lancer_cmd_req_read_object), wrb, | ||
1856 | NULL); | ||
1857 | |||
1858 | req->desired_read_len = cpu_to_le32(data_size); | ||
1859 | req->read_offset = cpu_to_le32(data_offset); | ||
1860 | strcpy(req->object_name, obj_name); | ||
1861 | req->descriptor_count = cpu_to_le32(1); | ||
1862 | req->buf_len = cpu_to_le32(data_size); | ||
1863 | req->addr_low = cpu_to_le32((cmd->dma & 0xFFFFFFFF)); | ||
1864 | req->addr_high = cpu_to_le32(upper_32_bits(cmd->dma)); | ||
1865 | |||
1866 | status = be_mcc_notify_wait(adapter); | ||
1867 | |||
1868 | resp = embedded_payload(wrb); | ||
1869 | if (!status) { | ||
1870 | *data_read = le32_to_cpu(resp->actual_read_len); | ||
1871 | *eof = le32_to_cpu(resp->eof); | ||
1872 | } else { | ||
1873 | *addn_status = resp->additional_status; | ||
1874 | } | ||
1875 | |||
1876 | err_unlock: | ||
1877 | spin_unlock_bh(&adapter->mcc_lock); | ||
1878 | return status; | ||
1879 | } | ||
1880 | |||
1839 | int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, | 1881 | int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, |
1840 | u32 flash_type, u32 flash_opcode, u32 buf_size) | 1882 | u32 flash_type, u32 flash_opcode, u32 buf_size) |
1841 | { | 1883 | { |
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index a35cd03fac4e..ac112465e719 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h | |||
@@ -189,6 +189,7 @@ struct be_mcc_mailbox { | |||
189 | #define OPCODE_COMMON_GET_PHY_DETAILS 102 | 189 | #define OPCODE_COMMON_GET_PHY_DETAILS 102 |
190 | #define OPCODE_COMMON_SET_DRIVER_FUNCTION_CAP 103 | 190 | #define OPCODE_COMMON_SET_DRIVER_FUNCTION_CAP 103 |
191 | #define OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES 121 | 191 | #define OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES 121 |
192 | #define OPCODE_COMMON_READ_OBJECT 171 | ||
192 | #define OPCODE_COMMON_WRITE_OBJECT 172 | 193 | #define OPCODE_COMMON_WRITE_OBJECT 172 |
193 | 194 | ||
194 | #define OPCODE_ETH_RSS_CONFIG 1 | 195 | #define OPCODE_ETH_RSS_CONFIG 1 |
@@ -1161,6 +1162,38 @@ struct lancer_cmd_resp_write_object { | |||
1161 | u32 actual_write_len; | 1162 | u32 actual_write_len; |
1162 | }; | 1163 | }; |
1163 | 1164 | ||
1165 | /************************ Lancer Read FW info **************/ | ||
1166 | #define LANCER_READ_FILE_CHUNK (32*1024) | ||
1167 | #define LANCER_READ_FILE_EOF_MASK 0x80000000 | ||
1168 | |||
1169 | #define LANCER_FW_DUMP_FILE "/dbg/dump.bin" | ||
1170 | #define LANCER_VPD_PF_FILE "/vpd/ntr_pf.vpd" | ||
1171 | #define LANCER_VPD_VF_FILE "/vpd/ntr_vf.vpd" | ||
1172 | |||
1173 | struct lancer_cmd_req_read_object { | ||
1174 | struct be_cmd_req_hdr hdr; | ||
1175 | u32 desired_read_len; | ||
1176 | u32 read_offset; | ||
1177 | u8 object_name[104]; | ||
1178 | u32 descriptor_count; | ||
1179 | u32 buf_len; | ||
1180 | u32 addr_low; | ||
1181 | u32 addr_high; | ||
1182 | }; | ||
1183 | |||
1184 | struct lancer_cmd_resp_read_object { | ||
1185 | u8 opcode; | ||
1186 | u8 subsystem; | ||
1187 | u8 rsvd1[2]; | ||
1188 | u8 status; | ||
1189 | u8 additional_status; | ||
1190 | u8 rsvd2[2]; | ||
1191 | u32 resp_len; | ||
1192 | u32 actual_resp_len; | ||
1193 | u32 actual_read_len; | ||
1194 | u32 eof; | ||
1195 | }; | ||
1196 | |||
1164 | /************************ WOL *******************************/ | 1197 | /************************ WOL *******************************/ |
1165 | struct be_cmd_req_acpi_wol_magic_config{ | 1198 | struct be_cmd_req_acpi_wol_magic_config{ |
1166 | struct be_cmd_req_hdr hdr; | 1199 | struct be_cmd_req_hdr hdr; |
@@ -1417,11 +1450,11 @@ extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, | |||
1417 | extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, | 1450 | extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
1418 | u32 if_id, u32 *pmac_id, u32 domain); | 1451 | u32 if_id, u32 *pmac_id, u32 domain); |
1419 | extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, | 1452 | extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, |
1420 | u32 pmac_id, u32 domain); | 1453 | int pmac_id, u32 domain); |
1421 | extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, | 1454 | extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, |
1422 | u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id, | 1455 | u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id, |
1423 | u32 domain); | 1456 | u32 domain); |
1424 | extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle, | 1457 | extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle, |
1425 | u32 domain); | 1458 | u32 domain); |
1426 | extern int be_cmd_eq_create(struct be_adapter *adapter, | 1459 | extern int be_cmd_eq_create(struct be_adapter *adapter, |
1427 | struct be_queue_info *eq, int eq_delay); | 1460 | struct be_queue_info *eq, int eq_delay); |
@@ -1480,6 +1513,9 @@ extern int lancer_cmd_write_object(struct be_adapter *adapter, | |||
1480 | u32 data_size, u32 data_offset, | 1513 | u32 data_size, u32 data_offset, |
1481 | const char *obj_name, | 1514 | const char *obj_name, |
1482 | u32 *data_written, u8 *addn_status); | 1515 | u32 *data_written, u8 *addn_status); |
1516 | int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd, | ||
1517 | u32 data_size, u32 data_offset, const char *obj_name, | ||
1518 | u32 *data_read, u32 *eof, u8 *addn_status); | ||
1483 | int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc, | 1519 | int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc, |
1484 | int offset); | 1520 | int offset); |
1485 | extern int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac, | 1521 | extern int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac, |
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c index bf8153ea4ed8..575c78306313 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c | |||
@@ -127,8 +127,8 @@ static void be_get_drvinfo(struct net_device *netdev, | |||
127 | memset(fw_on_flash, 0 , sizeof(fw_on_flash)); | 127 | memset(fw_on_flash, 0 , sizeof(fw_on_flash)); |
128 | be_cmd_get_fw_ver(adapter, adapter->fw_ver, fw_on_flash); | 128 | be_cmd_get_fw_ver(adapter, adapter->fw_ver, fw_on_flash); |
129 | 129 | ||
130 | strcpy(drvinfo->driver, DRV_NAME); | 130 | strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); |
131 | strcpy(drvinfo->version, DRV_VER); | 131 | strlcpy(drvinfo->version, DRV_VER, sizeof(drvinfo->version)); |
132 | strncpy(drvinfo->fw_version, adapter->fw_ver, FW_VER_LEN); | 132 | strncpy(drvinfo->fw_version, adapter->fw_ver, FW_VER_LEN); |
133 | if (memcmp(adapter->fw_ver, fw_on_flash, FW_VER_LEN) != 0) { | 133 | if (memcmp(adapter->fw_ver, fw_on_flash, FW_VER_LEN) != 0) { |
134 | strcat(drvinfo->fw_version, " ["); | 134 | strcat(drvinfo->fw_version, " ["); |
@@ -136,21 +136,84 @@ static void be_get_drvinfo(struct net_device *netdev, | |||
136 | strcat(drvinfo->fw_version, "]"); | 136 | strcat(drvinfo->fw_version, "]"); |
137 | } | 137 | } |
138 | 138 | ||
139 | strcpy(drvinfo->bus_info, pci_name(adapter->pdev)); | 139 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
140 | sizeof(drvinfo->bus_info)); | ||
140 | drvinfo->testinfo_len = 0; | 141 | drvinfo->testinfo_len = 0; |
141 | drvinfo->regdump_len = 0; | 142 | drvinfo->regdump_len = 0; |
142 | drvinfo->eedump_len = 0; | 143 | drvinfo->eedump_len = 0; |
143 | } | 144 | } |
144 | 145 | ||
146 | static u32 | ||
147 | lancer_cmd_get_file_len(struct be_adapter *adapter, u8 *file_name) | ||
148 | { | ||
149 | u32 data_read = 0, eof; | ||
150 | u8 addn_status; | ||
151 | struct be_dma_mem data_len_cmd; | ||
152 | int status; | ||
153 | |||
154 | memset(&data_len_cmd, 0, sizeof(data_len_cmd)); | ||
155 | /* data_offset and data_size should be 0 to get reg len */ | ||
156 | status = lancer_cmd_read_object(adapter, &data_len_cmd, 0, 0, | ||
157 | file_name, &data_read, &eof, &addn_status); | ||
158 | |||
159 | return data_read; | ||
160 | } | ||
161 | |||
162 | static int | ||
163 | lancer_cmd_read_file(struct be_adapter *adapter, u8 *file_name, | ||
164 | u32 buf_len, void *buf) | ||
165 | { | ||
166 | struct be_dma_mem read_cmd; | ||
167 | u32 read_len = 0, total_read_len = 0, chunk_size; | ||
168 | u32 eof = 0; | ||
169 | u8 addn_status; | ||
170 | int status = 0; | ||
171 | |||
172 | read_cmd.size = LANCER_READ_FILE_CHUNK; | ||
173 | read_cmd.va = pci_alloc_consistent(adapter->pdev, read_cmd.size, | ||
174 | &read_cmd.dma); | ||
175 | |||
176 | if (!read_cmd.va) { | ||
177 | dev_err(&adapter->pdev->dev, | ||
178 | "Memory allocation failure while reading dump\n"); | ||
179 | return -ENOMEM; | ||
180 | } | ||
181 | |||
182 | while ((total_read_len < buf_len) && !eof) { | ||
183 | chunk_size = min_t(u32, (buf_len - total_read_len), | ||
184 | LANCER_READ_FILE_CHUNK); | ||
185 | chunk_size = ALIGN(chunk_size, 4); | ||
186 | status = lancer_cmd_read_object(adapter, &read_cmd, chunk_size, | ||
187 | total_read_len, file_name, &read_len, | ||
188 | &eof, &addn_status); | ||
189 | if (!status) { | ||
190 | memcpy(buf + total_read_len, read_cmd.va, read_len); | ||
191 | total_read_len += read_len; | ||
192 | eof &= LANCER_READ_FILE_EOF_MASK; | ||
193 | } else { | ||
194 | status = -EIO; | ||
195 | break; | ||
196 | } | ||
197 | } | ||
198 | pci_free_consistent(adapter->pdev, read_cmd.size, read_cmd.va, | ||
199 | read_cmd.dma); | ||
200 | |||
201 | return status; | ||
202 | } | ||
203 | |||
145 | static int | 204 | static int |
146 | be_get_reg_len(struct net_device *netdev) | 205 | be_get_reg_len(struct net_device *netdev) |
147 | { | 206 | { |
148 | struct be_adapter *adapter = netdev_priv(netdev); | 207 | struct be_adapter *adapter = netdev_priv(netdev); |
149 | u32 log_size = 0; | 208 | u32 log_size = 0; |
150 | 209 | ||
151 | if (be_physfn(adapter)) | 210 | if (be_physfn(adapter)) { |
152 | be_cmd_get_reg_len(adapter, &log_size); | 211 | if (lancer_chip(adapter)) |
153 | 212 | log_size = lancer_cmd_get_file_len(adapter, | |
213 | LANCER_FW_DUMP_FILE); | ||
214 | else | ||
215 | be_cmd_get_reg_len(adapter, &log_size); | ||
216 | } | ||
154 | return log_size; | 217 | return log_size; |
155 | } | 218 | } |
156 | 219 | ||
@@ -161,7 +224,11 @@ be_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *buf) | |||
161 | 224 | ||
162 | if (be_physfn(adapter)) { | 225 | if (be_physfn(adapter)) { |
163 | memset(buf, 0, regs->len); | 226 | memset(buf, 0, regs->len); |
164 | be_cmd_get_regs(adapter, regs->len, buf); | 227 | if (lancer_chip(adapter)) |
228 | lancer_cmd_read_file(adapter, LANCER_FW_DUMP_FILE, | ||
229 | regs->len, buf); | ||
230 | else | ||
231 | be_cmd_get_regs(adapter, regs->len, buf); | ||
165 | } | 232 | } |
166 | } | 233 | } |
167 | 234 | ||
@@ -660,7 +727,17 @@ be_do_flash(struct net_device *netdev, struct ethtool_flash *efl) | |||
660 | static int | 727 | static int |
661 | be_get_eeprom_len(struct net_device *netdev) | 728 | be_get_eeprom_len(struct net_device *netdev) |
662 | { | 729 | { |
663 | return BE_READ_SEEPROM_LEN; | 730 | struct be_adapter *adapter = netdev_priv(netdev); |
731 | if (lancer_chip(adapter)) { | ||
732 | if (be_physfn(adapter)) | ||
733 | return lancer_cmd_get_file_len(adapter, | ||
734 | LANCER_VPD_PF_FILE); | ||
735 | else | ||
736 | return lancer_cmd_get_file_len(adapter, | ||
737 | LANCER_VPD_VF_FILE); | ||
738 | } else { | ||
739 | return BE_READ_SEEPROM_LEN; | ||
740 | } | ||
664 | } | 741 | } |
665 | 742 | ||
666 | static int | 743 | static int |
@@ -675,6 +752,15 @@ be_read_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, | |||
675 | if (!eeprom->len) | 752 | if (!eeprom->len) |
676 | return -EINVAL; | 753 | return -EINVAL; |
677 | 754 | ||
755 | if (lancer_chip(adapter)) { | ||
756 | if (be_physfn(adapter)) | ||
757 | return lancer_cmd_read_file(adapter, LANCER_VPD_PF_FILE, | ||
758 | eeprom->len, data); | ||
759 | else | ||
760 | return lancer_cmd_read_file(adapter, LANCER_VPD_VF_FILE, | ||
761 | eeprom->len, data); | ||
762 | } | ||
763 | |||
678 | eeprom->magic = BE_VENDOR_ID | (adapter->pdev->device<<16); | 764 | eeprom->magic = BE_VENDOR_ID | (adapter->pdev->device<<16); |
679 | 765 | ||
680 | memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem)); | 766 | memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem)); |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index bf266a00c774..93869d457b14 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
@@ -848,15 +848,11 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) | |||
848 | if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) | 848 | if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) |
849 | return -EINVAL; | 849 | return -EINVAL; |
850 | 850 | ||
851 | if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) | 851 | status = be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle, |
852 | status = be_cmd_pmac_del(adapter, | 852 | adapter->vf_cfg[vf].vf_pmac_id, vf + 1); |
853 | adapter->vf_cfg[vf].vf_if_handle, | ||
854 | adapter->vf_cfg[vf].vf_pmac_id, vf + 1); | ||
855 | 853 | ||
856 | status = be_cmd_pmac_add(adapter, mac, | 854 | status = be_cmd_pmac_add(adapter, mac, adapter->vf_cfg[vf].vf_if_handle, |
857 | adapter->vf_cfg[vf].vf_if_handle, | ||
858 | &adapter->vf_cfg[vf].vf_pmac_id, vf + 1); | 855 | &adapter->vf_cfg[vf].vf_pmac_id, vf + 1); |
859 | |||
860 | if (status) | 856 | if (status) |
861 | dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", | 857 | dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", |
862 | mac, vf); | 858 | mac, vf); |
@@ -1693,9 +1689,6 @@ static int be_tx_queues_create(struct be_adapter *adapter) | |||
1693 | if (be_queue_alloc(adapter, q, TX_Q_LEN, | 1689 | if (be_queue_alloc(adapter, q, TX_Q_LEN, |
1694 | sizeof(struct be_eth_wrb))) | 1690 | sizeof(struct be_eth_wrb))) |
1695 | goto err; | 1691 | goto err; |
1696 | |||
1697 | if (be_cmd_txq_create(adapter, q, cq)) | ||
1698 | goto err; | ||
1699 | } | 1692 | } |
1700 | return 0; | 1693 | return 0; |
1701 | 1694 | ||
@@ -1982,6 +1975,9 @@ void be_detect_dump_ue(struct be_adapter *adapter) | |||
1982 | u32 sliport_status = 0, sliport_err1 = 0, sliport_err2 = 0; | 1975 | u32 sliport_status = 0, sliport_err1 = 0, sliport_err2 = 0; |
1983 | u32 i; | 1976 | u32 i; |
1984 | 1977 | ||
1978 | if (adapter->eeh_err || adapter->ue_detected) | ||
1979 | return; | ||
1980 | |||
1985 | if (lancer_chip(adapter)) { | 1981 | if (lancer_chip(adapter)) { |
1986 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); | 1982 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); |
1987 | if (sliport_status & SLIPORT_STATUS_ERR_MASK) { | 1983 | if (sliport_status & SLIPORT_STATUS_ERR_MASK) { |
@@ -2008,7 +2004,8 @@ void be_detect_dump_ue(struct be_adapter *adapter) | |||
2008 | sliport_status & SLIPORT_STATUS_ERR_MASK) { | 2004 | sliport_status & SLIPORT_STATUS_ERR_MASK) { |
2009 | adapter->ue_detected = true; | 2005 | adapter->ue_detected = true; |
2010 | adapter->eeh_err = true; | 2006 | adapter->eeh_err = true; |
2011 | dev_err(&adapter->pdev->dev, "UE Detected!!\n"); | 2007 | dev_err(&adapter->pdev->dev, |
2008 | "Unrecoverable error in the card\n"); | ||
2012 | } | 2009 | } |
2013 | 2010 | ||
2014 | if (ue_lo) { | 2011 | if (ue_lo) { |
@@ -2043,8 +2040,7 @@ static void be_worker(struct work_struct *work) | |||
2043 | struct be_rx_obj *rxo; | 2040 | struct be_rx_obj *rxo; |
2044 | int i; | 2041 | int i; |
2045 | 2042 | ||
2046 | if (!adapter->ue_detected) | 2043 | be_detect_dump_ue(adapter); |
2047 | be_detect_dump_ue(adapter); | ||
2048 | 2044 | ||
2049 | /* when interrupts are not yet enabled, just reap any pending | 2045 | /* when interrupts are not yet enabled, just reap any pending |
2050 | * mcc completions */ | 2046 | * mcc completions */ |
@@ -2488,17 +2484,13 @@ static void be_vf_clear(struct be_adapter *adapter) | |||
2488 | { | 2484 | { |
2489 | u32 vf; | 2485 | u32 vf; |
2490 | 2486 | ||
2491 | for (vf = 0; vf < num_vfs; vf++) { | 2487 | for (vf = 0; vf < num_vfs; vf++) |
2492 | if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) | 2488 | be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle, |
2493 | be_cmd_pmac_del(adapter, | 2489 | adapter->vf_cfg[vf].vf_pmac_id, vf + 1); |
2494 | adapter->vf_cfg[vf].vf_if_handle, | ||
2495 | adapter->vf_cfg[vf].vf_pmac_id, vf + 1); | ||
2496 | } | ||
2497 | 2490 | ||
2498 | for (vf = 0; vf < num_vfs; vf++) | 2491 | for (vf = 0; vf < num_vfs; vf++) |
2499 | if (adapter->vf_cfg[vf].vf_if_handle) | 2492 | be_cmd_if_destroy(adapter, adapter->vf_cfg[vf].vf_if_handle, |
2500 | be_cmd_if_destroy(adapter, | 2493 | vf + 1); |
2501 | adapter->vf_cfg[vf].vf_if_handle, vf + 1); | ||
2502 | } | 2494 | } |
2503 | 2495 | ||
2504 | static int be_clear(struct be_adapter *adapter) | 2496 | static int be_clear(struct be_adapter *adapter) |
@@ -2511,22 +2503,30 @@ static int be_clear(struct be_adapter *adapter) | |||
2511 | be_mcc_queues_destroy(adapter); | 2503 | be_mcc_queues_destroy(adapter); |
2512 | be_rx_queues_destroy(adapter); | 2504 | be_rx_queues_destroy(adapter); |
2513 | be_tx_queues_destroy(adapter); | 2505 | be_tx_queues_destroy(adapter); |
2514 | adapter->eq_next_idx = 0; | ||
2515 | |||
2516 | adapter->be3_native = false; | ||
2517 | adapter->promiscuous = false; | ||
2518 | 2506 | ||
2519 | /* tell fw we're done with firing cmds */ | 2507 | /* tell fw we're done with firing cmds */ |
2520 | be_cmd_fw_clean(adapter); | 2508 | be_cmd_fw_clean(adapter); |
2521 | return 0; | 2509 | return 0; |
2522 | } | 2510 | } |
2523 | 2511 | ||
2512 | static void be_vf_setup_init(struct be_adapter *adapter) | ||
2513 | { | ||
2514 | int vf; | ||
2515 | |||
2516 | for (vf = 0; vf < num_vfs; vf++) { | ||
2517 | adapter->vf_cfg[vf].vf_if_handle = -1; | ||
2518 | adapter->vf_cfg[vf].vf_pmac_id = -1; | ||
2519 | } | ||
2520 | } | ||
2521 | |||
2524 | static int be_vf_setup(struct be_adapter *adapter) | 2522 | static int be_vf_setup(struct be_adapter *adapter) |
2525 | { | 2523 | { |
2526 | u32 cap_flags, en_flags, vf; | 2524 | u32 cap_flags, en_flags, vf; |
2527 | u16 lnk_speed; | 2525 | u16 lnk_speed; |
2528 | int status; | 2526 | int status; |
2529 | 2527 | ||
2528 | be_vf_setup_init(adapter); | ||
2529 | |||
2530 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST; | 2530 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST; |
2531 | for (vf = 0; vf < num_vfs; vf++) { | 2531 | for (vf = 0; vf < num_vfs; vf++) { |
2532 | status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, | 2532 | status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, |
@@ -2534,7 +2534,6 @@ static int be_vf_setup(struct be_adapter *adapter) | |||
2534 | NULL, vf+1); | 2534 | NULL, vf+1); |
2535 | if (status) | 2535 | if (status) |
2536 | goto err; | 2536 | goto err; |
2537 | adapter->vf_cfg[vf].vf_pmac_id = BE_INVALID_PMAC_ID; | ||
2538 | } | 2537 | } |
2539 | 2538 | ||
2540 | if (!lancer_chip(adapter)) { | 2539 | if (!lancer_chip(adapter)) { |
@@ -2555,17 +2554,26 @@ err: | |||
2555 | return status; | 2554 | return status; |
2556 | } | 2555 | } |
2557 | 2556 | ||
2557 | static void be_setup_init(struct be_adapter *adapter) | ||
2558 | { | ||
2559 | adapter->vlan_prio_bmap = 0xff; | ||
2560 | adapter->link_speed = -1; | ||
2561 | adapter->if_handle = -1; | ||
2562 | adapter->be3_native = false; | ||
2563 | adapter->promiscuous = false; | ||
2564 | adapter->eq_next_idx = 0; | ||
2565 | } | ||
2566 | |||
2558 | static int be_setup(struct be_adapter *adapter) | 2567 | static int be_setup(struct be_adapter *adapter) |
2559 | { | 2568 | { |
2560 | struct net_device *netdev = adapter->netdev; | 2569 | struct net_device *netdev = adapter->netdev; |
2561 | u32 cap_flags, en_flags; | 2570 | u32 cap_flags, en_flags; |
2562 | u32 tx_fc, rx_fc; | 2571 | u32 tx_fc, rx_fc; |
2563 | int status; | 2572 | int status, i; |
2564 | u8 mac[ETH_ALEN]; | 2573 | u8 mac[ETH_ALEN]; |
2574 | struct be_tx_obj *txo; | ||
2565 | 2575 | ||
2566 | /* Allow all priorities by default. A GRP5 evt may modify this */ | 2576 | be_setup_init(adapter); |
2567 | adapter->vlan_prio_bmap = 0xff; | ||
2568 | adapter->link_speed = -1; | ||
2569 | 2577 | ||
2570 | be_cmd_req_native_mode(adapter); | 2578 | be_cmd_req_native_mode(adapter); |
2571 | 2579 | ||
@@ -2592,7 +2600,8 @@ static int be_setup(struct be_adapter *adapter) | |||
2592 | en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | | 2600 | en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | |
2593 | BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS; | 2601 | BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS; |
2594 | cap_flags = en_flags | BE_IF_FLAGS_MCAST_PROMISCUOUS | | 2602 | cap_flags = en_flags | BE_IF_FLAGS_MCAST_PROMISCUOUS | |
2595 | BE_IF_FLAGS_PROMISCUOUS; | 2603 | BE_IF_FLAGS_VLAN_PROMISCUOUS | BE_IF_FLAGS_PROMISCUOUS; |
2604 | |||
2596 | if (adapter->function_caps & BE_FUNCTION_CAPS_RSS) { | 2605 | if (adapter->function_caps & BE_FUNCTION_CAPS_RSS) { |
2597 | cap_flags |= BE_IF_FLAGS_RSS; | 2606 | cap_flags |= BE_IF_FLAGS_RSS; |
2598 | en_flags |= BE_IF_FLAGS_RSS; | 2607 | en_flags |= BE_IF_FLAGS_RSS; |
@@ -2603,6 +2612,12 @@ static int be_setup(struct be_adapter *adapter) | |||
2603 | if (status != 0) | 2612 | if (status != 0) |
2604 | goto err; | 2613 | goto err; |
2605 | 2614 | ||
2615 | for_all_tx_queues(adapter, txo, i) { | ||
2616 | status = be_cmd_txq_create(adapter, &txo->q, &txo->cq); | ||
2617 | if (status) | ||
2618 | goto err; | ||
2619 | } | ||
2620 | |||
2606 | /* For BEx, the VF's permanent mac queried from card is incorrect. | 2621 | /* For BEx, the VF's permanent mac queried from card is incorrect. |
2607 | * Query the mac configued by the PF using if_handle | 2622 | * Query the mac configued by the PF using if_handle |
2608 | */ | 2623 | */ |
@@ -3559,6 +3574,8 @@ static pci_ers_result_t be_eeh_reset(struct pci_dev *pdev) | |||
3559 | 3574 | ||
3560 | dev_info(&adapter->pdev->dev, "EEH reset\n"); | 3575 | dev_info(&adapter->pdev->dev, "EEH reset\n"); |
3561 | adapter->eeh_err = false; | 3576 | adapter->eeh_err = false; |
3577 | adapter->ue_detected = false; | ||
3578 | adapter->fw_timeout = false; | ||
3562 | 3579 | ||
3563 | status = pci_enable_device(pdev); | 3580 | status = pci_enable_device(pdev); |
3564 | if (status) | 3581 | if (status) |
diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c index 61d2bddec1fa..c82d444b582d 100644 --- a/drivers/net/ethernet/fealnx.c +++ b/drivers/net/ethernet/fealnx.c | |||
@@ -1818,9 +1818,9 @@ static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i | |||
1818 | { | 1818 | { |
1819 | struct netdev_private *np = netdev_priv(dev); | 1819 | struct netdev_private *np = netdev_priv(dev); |
1820 | 1820 | ||
1821 | strcpy(info->driver, DRV_NAME); | 1821 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1822 | strcpy(info->version, DRV_VERSION); | 1822 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1823 | strcpy(info->bus_info, pci_name(np->pci_dev)); | 1823 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
1824 | } | 1824 | } |
1825 | 1825 | ||
1826 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1826 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c index 52f4e8ad48e7..8dee1aed47e4 100644 --- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c +++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c | |||
@@ -183,28 +183,10 @@ void fsl_pq_mdio_bus_name(char *name, struct device_node *np) | |||
183 | } | 183 | } |
184 | EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name); | 184 | EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name); |
185 | 185 | ||
186 | /* Scan the bus in reverse, looking for an empty spot */ | ||
187 | static int fsl_pq_mdio_find_free(struct mii_bus *new_bus) | ||
188 | { | ||
189 | int i; | ||
190 | |||
191 | for (i = PHY_MAX_ADDR; i > 0; i--) { | ||
192 | u32 phy_id; | ||
193 | |||
194 | if (get_phy_id(new_bus, i, &phy_id)) | ||
195 | return -1; | ||
196 | |||
197 | if (phy_id == 0xffffffff) | ||
198 | break; | ||
199 | } | ||
200 | |||
201 | return i; | ||
202 | } | ||
203 | 186 | ||
204 | |||
205 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) | ||
206 | static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) | 187 | static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) |
207 | { | 188 | { |
189 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) | ||
208 | struct gfar __iomem *enet_regs; | 190 | struct gfar __iomem *enet_regs; |
209 | 191 | ||
210 | /* | 192 | /* |
@@ -220,15 +202,15 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct devi | |||
220 | } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || | 202 | } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || |
221 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { | 203 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { |
222 | return of_iomap(np, 1); | 204 | return of_iomap(np, 1); |
223 | } else | 205 | } |
224 | return NULL; | ||
225 | } | ||
226 | #endif | 206 | #endif |
207 | return NULL; | ||
208 | } | ||
227 | 209 | ||
228 | 210 | ||
229 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) | ||
230 | static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) | 211 | static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) |
231 | { | 212 | { |
213 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) | ||
232 | struct device_node *np = NULL; | 214 | struct device_node *np = NULL; |
233 | int err = 0; | 215 | int err = 0; |
234 | 216 | ||
@@ -261,9 +243,10 @@ static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) | |||
261 | return err; | 243 | return err; |
262 | else | 244 | else |
263 | return -EINVAL; | 245 | return -EINVAL; |
264 | } | 246 | #else |
247 | return -ENODEV; | ||
265 | #endif | 248 | #endif |
266 | 249 | } | |
267 | 250 | ||
268 | static int fsl_pq_mdio_probe(struct platform_device *ofdev) | 251 | static int fsl_pq_mdio_probe(struct platform_device *ofdev) |
269 | { | 252 | { |
@@ -339,19 +322,13 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) | |||
339 | of_device_is_compatible(np, "fsl,etsec2-mdio") || | 322 | of_device_is_compatible(np, "fsl,etsec2-mdio") || |
340 | of_device_is_compatible(np, "fsl,etsec2-tbi") || | 323 | of_device_is_compatible(np, "fsl,etsec2-tbi") || |
341 | of_device_is_compatible(np, "gianfar")) { | 324 | of_device_is_compatible(np, "gianfar")) { |
342 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) | ||
343 | tbipa = get_gfar_tbipa(regs, np); | 325 | tbipa = get_gfar_tbipa(regs, np); |
344 | if (!tbipa) { | 326 | if (!tbipa) { |
345 | err = -EINVAL; | 327 | err = -EINVAL; |
346 | goto err_free_irqs; | 328 | goto err_free_irqs; |
347 | } | 329 | } |
348 | #else | ||
349 | err = -ENODEV; | ||
350 | goto err_free_irqs; | ||
351 | #endif | ||
352 | } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || | 330 | } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || |
353 | of_device_is_compatible(np, "ucc_geth_phy")) { | 331 | of_device_is_compatible(np, "ucc_geth_phy")) { |
354 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) | ||
355 | u32 id; | 332 | u32 id; |
356 | static u32 mii_mng_master; | 333 | static u32 mii_mng_master; |
357 | 334 | ||
@@ -364,10 +341,6 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) | |||
364 | mii_mng_master = id; | 341 | mii_mng_master = id; |
365 | ucc_set_qe_mux_mii_mng(id - 1); | 342 | ucc_set_qe_mux_mii_mng(id - 1); |
366 | } | 343 | } |
367 | #else | ||
368 | err = -ENODEV; | ||
369 | goto err_free_irqs; | ||
370 | #endif | ||
371 | } else { | 344 | } else { |
372 | err = -ENODEV; | 345 | err = -ENODEV; |
373 | goto err_free_irqs; | 346 | goto err_free_irqs; |
@@ -383,26 +356,16 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) | |||
383 | 356 | ||
384 | if (prop) | 357 | if (prop) |
385 | tbiaddr = *prop; | 358 | tbiaddr = *prop; |
386 | } | ||
387 | |||
388 | if (tbiaddr == -1) { | ||
389 | out_be32(tbipa, 0); | ||
390 | 359 | ||
391 | tbiaddr = fsl_pq_mdio_find_free(new_bus); | 360 | if (tbiaddr == -1) { |
392 | } | 361 | err = -EBUSY; |
393 | |||
394 | /* | ||
395 | * We define TBIPA at 0 to be illegal, opting to fail for boards that | ||
396 | * have PHYs at 1-31, rather than change tbipa and rescan. | ||
397 | */ | ||
398 | if (tbiaddr == 0) { | ||
399 | err = -EBUSY; | ||
400 | 362 | ||
401 | goto err_free_irqs; | 363 | goto err_free_irqs; |
364 | } else { | ||
365 | out_be32(tbipa, tbiaddr); | ||
366 | } | ||
402 | } | 367 | } |
403 | 368 | ||
404 | out_be32(tbipa, tbiaddr); | ||
405 | |||
406 | err = of_mdiobus_register(new_bus, np); | 369 | err = of_mdiobus_register(new_bus, np); |
407 | if (err) { | 370 | if (err) { |
408 | printk (KERN_ERR "%s: Cannot register as MDIO bus\n", | 371 | printk (KERN_ERR "%s: Cannot register as MDIO bus\n", |
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 83199fd0d62b..8e21ceb3b7da 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -734,7 +734,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) | |||
734 | 734 | ||
735 | mac_addr = of_get_mac_address(np); | 735 | mac_addr = of_get_mac_address(np); |
736 | if (mac_addr) | 736 | if (mac_addr) |
737 | memcpy(dev->dev_addr, mac_addr, MAC_ADDR_LEN); | 737 | memcpy(dev->dev_addr, mac_addr, ETH_ALEN); |
738 | 738 | ||
739 | if (model && !strcasecmp(model, "TSEC")) | 739 | if (model && !strcasecmp(model, "TSEC")) |
740 | priv->device_flags = | 740 | priv->device_flags = |
@@ -2306,7 +2306,7 @@ void gfar_check_rx_parser_mode(struct gfar_private *priv) | |||
2306 | } | 2306 | } |
2307 | 2307 | ||
2308 | /* Enables and disables VLAN insertion/extraction */ | 2308 | /* Enables and disables VLAN insertion/extraction */ |
2309 | void gfar_vlan_mode(struct net_device *dev, u32 features) | 2309 | void gfar_vlan_mode(struct net_device *dev, netdev_features_t features) |
2310 | { | 2310 | { |
2311 | struct gfar_private *priv = netdev_priv(dev); | 2311 | struct gfar_private *priv = netdev_priv(dev); |
2312 | struct gfar __iomem *regs = NULL; | 2312 | struct gfar __iomem *regs = NULL; |
@@ -3114,7 +3114,7 @@ static void gfar_set_multi(struct net_device *dev) | |||
3114 | static void gfar_clear_exact_match(struct net_device *dev) | 3114 | static void gfar_clear_exact_match(struct net_device *dev) |
3115 | { | 3115 | { |
3116 | int idx; | 3116 | int idx; |
3117 | static const u8 zero_arr[MAC_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; | 3117 | static const u8 zero_arr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; |
3118 | 3118 | ||
3119 | for(idx = 1;idx < GFAR_EM_NUM + 1;idx++) | 3119 | for(idx = 1;idx < GFAR_EM_NUM + 1;idx++) |
3120 | gfar_set_mac_for_addr(dev, idx, zero_arr); | 3120 | gfar_set_mac_for_addr(dev, idx, zero_arr); |
@@ -3137,7 +3137,7 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr) | |||
3137 | { | 3137 | { |
3138 | u32 tempval; | 3138 | u32 tempval; |
3139 | struct gfar_private *priv = netdev_priv(dev); | 3139 | struct gfar_private *priv = netdev_priv(dev); |
3140 | u32 result = ether_crc(MAC_ADDR_LEN, addr); | 3140 | u32 result = ether_crc(ETH_ALEN, addr); |
3141 | int width = priv->hash_width; | 3141 | int width = priv->hash_width; |
3142 | u8 whichbit = (result >> (32 - width)) & 0x1f; | 3142 | u8 whichbit = (result >> (32 - width)) & 0x1f; |
3143 | u8 whichreg = result >> (32 - width + 5); | 3143 | u8 whichreg = result >> (32 - width + 5); |
@@ -3158,7 +3158,7 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, | |||
3158 | struct gfar_private *priv = netdev_priv(dev); | 3158 | struct gfar_private *priv = netdev_priv(dev); |
3159 | struct gfar __iomem *regs = priv->gfargrp[0].regs; | 3159 | struct gfar __iomem *regs = priv->gfargrp[0].regs; |
3160 | int idx; | 3160 | int idx; |
3161 | char tmpbuf[MAC_ADDR_LEN]; | 3161 | char tmpbuf[ETH_ALEN]; |
3162 | u32 tempval; | 3162 | u32 tempval; |
3163 | u32 __iomem *macptr = ®s->macstnaddr1; | 3163 | u32 __iomem *macptr = ®s->macstnaddr1; |
3164 | 3164 | ||
@@ -3166,8 +3166,8 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, | |||
3166 | 3166 | ||
3167 | /* Now copy it into the mac registers backwards, cuz */ | 3167 | /* Now copy it into the mac registers backwards, cuz */ |
3168 | /* little endian is silly */ | 3168 | /* little endian is silly */ |
3169 | for (idx = 0; idx < MAC_ADDR_LEN; idx++) | 3169 | for (idx = 0; idx < ETH_ALEN; idx++) |
3170 | tmpbuf[MAC_ADDR_LEN - 1 - idx] = addr[idx]; | 3170 | tmpbuf[ETH_ALEN - 1 - idx] = addr[idx]; |
3171 | 3171 | ||
3172 | gfar_write(macptr, *((u32 *) (tmpbuf))); | 3172 | gfar_write(macptr, *((u32 *) (tmpbuf))); |
3173 | 3173 | ||
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index 9aa43773e8e3..fe7ac3a83194 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h | |||
@@ -74,9 +74,6 @@ struct ethtool_rx_list { | |||
74 | * will be the next highest multiple of 512 bytes. */ | 74 | * will be the next highest multiple of 512 bytes. */ |
75 | #define INCREMENTAL_BUFFER_SIZE 512 | 75 | #define INCREMENTAL_BUFFER_SIZE 512 |
76 | 76 | ||
77 | |||
78 | #define MAC_ADDR_LEN 6 | ||
79 | |||
80 | #define PHY_INIT_TIMEOUT 100000 | 77 | #define PHY_INIT_TIMEOUT 100000 |
81 | #define GFAR_PHY_CHANGE_TIME 2 | 78 | #define GFAR_PHY_CHANGE_TIME 2 |
82 | 79 | ||
@@ -1179,9 +1176,9 @@ extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, | |||
1179 | extern void gfar_configure_coalescing(struct gfar_private *priv, | 1176 | extern void gfar_configure_coalescing(struct gfar_private *priv, |
1180 | unsigned long tx_mask, unsigned long rx_mask); | 1177 | unsigned long tx_mask, unsigned long rx_mask); |
1181 | void gfar_init_sysfs(struct net_device *dev); | 1178 | void gfar_init_sysfs(struct net_device *dev); |
1182 | int gfar_set_features(struct net_device *dev, u32 features); | 1179 | int gfar_set_features(struct net_device *dev, netdev_features_t features); |
1183 | extern void gfar_check_rx_parser_mode(struct gfar_private *priv); | 1180 | extern void gfar_check_rx_parser_mode(struct gfar_private *priv); |
1184 | extern void gfar_vlan_mode(struct net_device *dev, u32 features); | 1181 | extern void gfar_vlan_mode(struct net_device *dev, netdev_features_t features); |
1185 | 1182 | ||
1186 | extern const struct ethtool_ops gfar_ethtool_ops; | 1183 | extern const struct ethtool_ops gfar_ethtool_ops; |
1187 | 1184 | ||
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c index 212736bab6bb..1ea0eb9ee643 100644 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c | |||
@@ -519,12 +519,12 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva | |||
519 | return err; | 519 | return err; |
520 | } | 520 | } |
521 | 521 | ||
522 | int gfar_set_features(struct net_device *dev, u32 features) | 522 | int gfar_set_features(struct net_device *dev, netdev_features_t features) |
523 | { | 523 | { |
524 | struct gfar_private *priv = netdev_priv(dev); | 524 | struct gfar_private *priv = netdev_priv(dev); |
525 | unsigned long flags; | 525 | unsigned long flags; |
526 | int err = 0, i = 0; | 526 | int err = 0, i = 0; |
527 | u32 changed = dev->features ^ features; | 527 | netdev_features_t changed = dev->features ^ features; |
528 | 528 | ||
529 | if (changed & (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX)) | 529 | if (changed & (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX)) |
530 | gfar_vlan_mode(dev, features); | 530 | gfar_vlan_mode(dev, features); |
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index b5dc0273a1d1..ba2dc083bfc0 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c | |||
@@ -443,7 +443,7 @@ static void hw_add_addr_in_hash(struct ucc_geth_private *ugeth, | |||
443 | 443 | ||
444 | static inline int compare_addr(u8 **addr1, u8 **addr2) | 444 | static inline int compare_addr(u8 **addr1, u8 **addr2) |
445 | { | 445 | { |
446 | return memcmp(addr1, addr2, ENET_NUM_OCTETS_PER_ADDRESS); | 446 | return memcmp(addr1, addr2, ETH_ALEN); |
447 | } | 447 | } |
448 | 448 | ||
449 | #ifdef DEBUG | 449 | #ifdef DEBUG |
diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethernet/freescale/ucc_geth.h index d12fcad145e9..2e395a2566b8 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.h +++ b/drivers/net/ethernet/freescale/ucc_geth.h | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/list.h> | 22 | #include <linux/list.h> |
23 | #include <linux/if_ether.h> | ||
23 | 24 | ||
24 | #include <asm/immap_qe.h> | 25 | #include <asm/immap_qe.h> |
25 | #include <asm/qe.h> | 26 | #include <asm/qe.h> |
@@ -881,7 +882,6 @@ struct ucc_geth_hardware_statistics { | |||
881 | #define TX_RING_MOD_MASK(size) (size-1) | 882 | #define TX_RING_MOD_MASK(size) (size-1) |
882 | #define RX_RING_MOD_MASK(size) (size-1) | 883 | #define RX_RING_MOD_MASK(size) (size-1) |
883 | 884 | ||
884 | #define ENET_NUM_OCTETS_PER_ADDRESS 6 | ||
885 | #define ENET_GROUP_ADDR 0x01 /* Group address mask | 885 | #define ENET_GROUP_ADDR 0x01 /* Group address mask |
886 | for ethernet | 886 | for ethernet |
887 | addresses */ | 887 | addresses */ |
@@ -1051,7 +1051,7 @@ enum ucc_geth_num_of_station_addresses { | |||
1051 | 1051 | ||
1052 | /* UCC GETH 82xx Ethernet Address Container */ | 1052 | /* UCC GETH 82xx Ethernet Address Container */ |
1053 | struct enet_addr_container { | 1053 | struct enet_addr_container { |
1054 | u8 address[ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */ | 1054 | u8 address[ETH_ALEN]; /* ethernet address */ |
1055 | enum ucc_geth_enet_address_recognition_location location; /* location in | 1055 | enum ucc_geth_enet_address_recognition_location location; /* location in |
1056 | 82xx address | 1056 | 82xx address |
1057 | recognition | 1057 | recognition |
@@ -1194,7 +1194,7 @@ struct ucc_geth_private { | |||
1194 | u16 cpucount[NUM_TX_QUEUES]; | 1194 | u16 cpucount[NUM_TX_QUEUES]; |
1195 | u16 __iomem *p_cpucount[NUM_TX_QUEUES]; | 1195 | u16 __iomem *p_cpucount[NUM_TX_QUEUES]; |
1196 | int indAddrRegUsed[NUM_OF_PADDRS]; | 1196 | int indAddrRegUsed[NUM_OF_PADDRS]; |
1197 | u8 paddr[NUM_OF_PADDRS][ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */ | 1197 | u8 paddr[NUM_OF_PADDRS][ETH_ALEN]; /* ethernet address */ |
1198 | u8 numGroupAddrInHash; | 1198 | u8 numGroupAddrInHash; |
1199 | u8 numIndAddrInHash; | 1199 | u8 numIndAddrInHash; |
1200 | u8 numIndAddrInReg; | 1200 | u8 numIndAddrInReg; |
diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c index 15416752c13e..ee84b472cee6 100644 --- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c +++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c | |||
@@ -1058,9 +1058,10 @@ static void fjn_rx(struct net_device *dev) | |||
1058 | static void netdev_get_drvinfo(struct net_device *dev, | 1058 | static void netdev_get_drvinfo(struct net_device *dev, |
1059 | struct ethtool_drvinfo *info) | 1059 | struct ethtool_drvinfo *info) |
1060 | { | 1060 | { |
1061 | strcpy(info->driver, DRV_NAME); | 1061 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1062 | strcpy(info->version, DRV_VERSION); | 1062 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1063 | sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); | 1063 | snprintf(info->bus_info, sizeof(info->bus_info), |
1064 | "PCMCIA 0x%lx", dev->base_addr); | ||
1064 | } | 1065 | } |
1065 | 1066 | ||
1066 | static const struct ethtool_ops netdev_ethtool_ops = { | 1067 | static const struct ethtool_ops netdev_ethtool_ops = { |
diff --git a/drivers/net/ethernet/i825xx/eepro.c b/drivers/net/ethernet/i825xx/eepro.c index 067c46069a11..114cda7721fe 100644 --- a/drivers/net/ethernet/i825xx/eepro.c +++ b/drivers/net/ethernet/i825xx/eepro.c | |||
@@ -1726,9 +1726,10 @@ static int eepro_ethtool_get_settings(struct net_device *dev, | |||
1726 | static void eepro_ethtool_get_drvinfo(struct net_device *dev, | 1726 | static void eepro_ethtool_get_drvinfo(struct net_device *dev, |
1727 | struct ethtool_drvinfo *drvinfo) | 1727 | struct ethtool_drvinfo *drvinfo) |
1728 | { | 1728 | { |
1729 | strcpy(drvinfo->driver, DRV_NAME); | 1729 | strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); |
1730 | strcpy(drvinfo->version, DRV_VERSION); | 1730 | strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); |
1731 | sprintf(drvinfo->bus_info, "ISA 0x%lx", dev->base_addr); | 1731 | snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), |
1732 | "ISA 0x%lx", dev->base_addr); | ||
1732 | } | 1733 | } |
1733 | 1734 | ||
1734 | static const struct ethtool_ops eepro_ethtool_ops = { | 1735 | static const struct ethtool_ops eepro_ethtool_ops = { |
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index ed79b2d3ad3e..2abce965c7bd 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c | |||
@@ -2924,6 +2924,9 @@ static int __devexit emac_remove(struct platform_device *ofdev) | |||
2924 | if (emac_has_feature(dev, EMAC_FTR_HAS_ZMII)) | 2924 | if (emac_has_feature(dev, EMAC_FTR_HAS_ZMII)) |
2925 | zmii_detach(dev->zmii_dev, dev->zmii_port); | 2925 | zmii_detach(dev->zmii_dev, dev->zmii_port); |
2926 | 2926 | ||
2927 | busy_phy_map &= ~(1 << dev->phy.address); | ||
2928 | DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map); | ||
2929 | |||
2927 | mal_unregister_commac(dev->mal, &dev->commac); | 2930 | mal_unregister_commac(dev->mal, &dev->commac); |
2928 | emac_put_deps(dev); | 2931 | emac_put_deps(dev); |
2929 | 2932 | ||
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index b1cd41b9c61c..e877371680a9 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c | |||
@@ -735,7 +735,8 @@ static void netdev_get_drvinfo(struct net_device *dev, | |||
735 | sizeof(info->version) - 1); | 735 | sizeof(info->version) - 1); |
736 | } | 736 | } |
737 | 737 | ||
738 | static u32 ibmveth_fix_features(struct net_device *dev, u32 features) | 738 | static netdev_features_t ibmveth_fix_features(struct net_device *dev, |
739 | netdev_features_t features) | ||
739 | { | 740 | { |
740 | /* | 741 | /* |
741 | * Since the ibmveth firmware interface does not have the | 742 | * Since the ibmveth firmware interface does not have the |
@@ -838,7 +839,8 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) | |||
838 | return rc1 ? rc1 : rc2; | 839 | return rc1 ? rc1 : rc2; |
839 | } | 840 | } |
840 | 841 | ||
841 | static int ibmveth_set_features(struct net_device *dev, u32 features) | 842 | static int ibmveth_set_features(struct net_device *dev, |
843 | netdev_features_t features) | ||
842 | { | 844 | { |
843 | struct ibmveth_adapter *adapter = netdev_priv(dev); | 845 | struct ibmveth_adapter *adapter = netdev_priv(dev); |
844 | int rx_csum = !!(features & NETIF_F_RXCSUM); | 846 | int rx_csum = !!(features & NETIF_F_RXCSUM); |
diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 5a2fdf7a00c8..46003278ffa0 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c | |||
@@ -2376,10 +2376,11 @@ static void e100_get_drvinfo(struct net_device *netdev, | |||
2376 | struct ethtool_drvinfo *info) | 2376 | struct ethtool_drvinfo *info) |
2377 | { | 2377 | { |
2378 | struct nic *nic = netdev_priv(netdev); | 2378 | struct nic *nic = netdev_priv(netdev); |
2379 | strcpy(info->driver, DRV_NAME); | 2379 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
2380 | strcpy(info->version, DRV_VERSION); | 2380 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
2381 | strcpy(info->fw_version, "N/A"); | 2381 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
2382 | strcpy(info->bus_info, pci_name(nic->pdev)); | 2382 | strlcpy(info->bus_info, pci_name(nic->pdev), |
2383 | sizeof(info->bus_info)); | ||
2383 | } | 2384 | } |
2384 | 2385 | ||
2385 | #define E100_PHY_REGS 0x1C | 2386 | #define E100_PHY_REGS 0x1C |
diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c index 2b223ac99c42..63faec693deb 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c | |||
@@ -515,14 +515,15 @@ static void e1000_get_drvinfo(struct net_device *netdev, | |||
515 | struct ethtool_drvinfo *drvinfo) | 515 | struct ethtool_drvinfo *drvinfo) |
516 | { | 516 | { |
517 | struct e1000_adapter *adapter = netdev_priv(netdev); | 517 | struct e1000_adapter *adapter = netdev_priv(netdev); |
518 | char firmware_version[32]; | ||
519 | 518 | ||
520 | strncpy(drvinfo->driver, e1000_driver_name, 32); | 519 | strlcpy(drvinfo->driver, e1000_driver_name, |
521 | strncpy(drvinfo->version, e1000_driver_version, 32); | 520 | sizeof(drvinfo->driver)); |
521 | strlcpy(drvinfo->version, e1000_driver_version, | ||
522 | sizeof(drvinfo->version)); | ||
522 | 523 | ||
523 | sprintf(firmware_version, "N/A"); | 524 | strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); |
524 | strncpy(drvinfo->fw_version, firmware_version, 32); | 525 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
525 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | 526 | sizeof(drvinfo->bus_info)); |
526 | drvinfo->regdump_len = e1000_get_regs_len(netdev); | 527 | drvinfo->regdump_len = e1000_get_regs_len(netdev); |
527 | drvinfo->eedump_len = e1000_get_eeprom_len(netdev); | 528 | drvinfo->eedump_len = e1000_get_eeprom_len(netdev); |
528 | } | 529 | } |
diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.h b/drivers/net/ethernet/intel/e1000/e1000_hw.h index 5c9a8403668b..cf7e3c094477 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_hw.h +++ b/drivers/net/ethernet/intel/e1000/e1000_hw.h | |||
@@ -448,7 +448,6 @@ void e1000_io_write(struct e1000_hw *hw, unsigned long port, u32 value); | |||
448 | #define E1000_DEV_ID_INTEL_CE4100_GBE 0x2E6E | 448 | #define E1000_DEV_ID_INTEL_CE4100_GBE 0x2E6E |
449 | 449 | ||
450 | #define NODE_ADDRESS_SIZE 6 | 450 | #define NODE_ADDRESS_SIZE 6 |
451 | #define ETH_LENGTH_OF_ADDRESS 6 | ||
452 | 451 | ||
453 | /* MAC decode size is 128K - This is the size of BAR0 */ | 452 | /* MAC decode size is 128K - This is the size of BAR0 */ |
454 | #define MAC_DECODE_SIZE (128 * 1024) | 453 | #define MAC_DECODE_SIZE (128 * 1024) |
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index cf480b554622..82f4ef142259 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c | |||
@@ -167,7 +167,8 @@ static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, | |||
167 | struct sk_buff *skb); | 167 | struct sk_buff *skb); |
168 | 168 | ||
169 | static bool e1000_vlan_used(struct e1000_adapter *adapter); | 169 | static bool e1000_vlan_used(struct e1000_adapter *adapter); |
170 | static void e1000_vlan_mode(struct net_device *netdev, u32 features); | 170 | static void e1000_vlan_mode(struct net_device *netdev, |
171 | netdev_features_t features); | ||
171 | static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid); | 172 | static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid); |
172 | static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid); | 173 | static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid); |
173 | static void e1000_restore_vlan(struct e1000_adapter *adapter); | 174 | static void e1000_restore_vlan(struct e1000_adapter *adapter); |
@@ -806,7 +807,8 @@ static int e1000_is_need_ioport(struct pci_dev *pdev) | |||
806 | } | 807 | } |
807 | } | 808 | } |
808 | 809 | ||
809 | static u32 e1000_fix_features(struct net_device *netdev, u32 features) | 810 | static netdev_features_t e1000_fix_features(struct net_device *netdev, |
811 | netdev_features_t features) | ||
810 | { | 812 | { |
811 | /* | 813 | /* |
812 | * Since there is no support for separate rx/tx vlan accel | 814 | * Since there is no support for separate rx/tx vlan accel |
@@ -820,10 +822,11 @@ static u32 e1000_fix_features(struct net_device *netdev, u32 features) | |||
820 | return features; | 822 | return features; |
821 | } | 823 | } |
822 | 824 | ||
823 | static int e1000_set_features(struct net_device *netdev, u32 features) | 825 | static int e1000_set_features(struct net_device *netdev, |
826 | netdev_features_t features) | ||
824 | { | 827 | { |
825 | struct e1000_adapter *adapter = netdev_priv(netdev); | 828 | struct e1000_adapter *adapter = netdev_priv(netdev); |
826 | u32 changed = features ^ netdev->features; | 829 | netdev_features_t changed = features ^ netdev->features; |
827 | 830 | ||
828 | if (changed & NETIF_F_HW_VLAN_RX) | 831 | if (changed & NETIF_F_HW_VLAN_RX) |
829 | e1000_vlan_mode(netdev, features); | 832 | e1000_vlan_mode(netdev, features); |
@@ -4577,7 +4580,8 @@ static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter, | |||
4577 | e1000_irq_enable(adapter); | 4580 | e1000_irq_enable(adapter); |
4578 | } | 4581 | } |
4579 | 4582 | ||
4580 | static void e1000_vlan_mode(struct net_device *netdev, u32 features) | 4583 | static void e1000_vlan_mode(struct net_device *netdev, |
4584 | netdev_features_t features) | ||
4581 | { | 4585 | { |
4582 | struct e1000_adapter *adapter = netdev_priv(netdev); | 4586 | struct e1000_adapter *adapter = netdev_priv(netdev); |
4583 | struct e1000_hw *hw = &adapter->hw; | 4587 | struct e1000_hw *hw = &adapter->hw; |
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index 69c9d2199140..fb2c28e799a2 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c | |||
@@ -579,26 +579,24 @@ static void e1000_get_drvinfo(struct net_device *netdev, | |||
579 | struct ethtool_drvinfo *drvinfo) | 579 | struct ethtool_drvinfo *drvinfo) |
580 | { | 580 | { |
581 | struct e1000_adapter *adapter = netdev_priv(netdev); | 581 | struct e1000_adapter *adapter = netdev_priv(netdev); |
582 | char firmware_version[32]; | ||
583 | 582 | ||
584 | strncpy(drvinfo->driver, e1000e_driver_name, | 583 | strlcpy(drvinfo->driver, e1000e_driver_name, |
585 | sizeof(drvinfo->driver) - 1); | 584 | sizeof(drvinfo->driver)); |
586 | strncpy(drvinfo->version, e1000e_driver_version, | 585 | strlcpy(drvinfo->version, e1000e_driver_version, |
587 | sizeof(drvinfo->version) - 1); | 586 | sizeof(drvinfo->version)); |
588 | 587 | ||
589 | /* | 588 | /* |
590 | * EEPROM image version # is reported as firmware version # for | 589 | * EEPROM image version # is reported as firmware version # for |
591 | * PCI-E controllers | 590 | * PCI-E controllers |
592 | */ | 591 | */ |
593 | snprintf(firmware_version, sizeof(firmware_version), "%d.%d-%d", | 592 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), |
593 | "%d.%d-%d", | ||
594 | (adapter->eeprom_vers & 0xF000) >> 12, | 594 | (adapter->eeprom_vers & 0xF000) >> 12, |
595 | (adapter->eeprom_vers & 0x0FF0) >> 4, | 595 | (adapter->eeprom_vers & 0x0FF0) >> 4, |
596 | (adapter->eeprom_vers & 0x000F)); | 596 | (adapter->eeprom_vers & 0x000F)); |
597 | 597 | ||
598 | strncpy(drvinfo->fw_version, firmware_version, | 598 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
599 | sizeof(drvinfo->fw_version) - 1); | 599 | sizeof(drvinfo->bus_info)); |
600 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
601 | sizeof(drvinfo->bus_info) - 1); | ||
602 | drvinfo->regdump_len = e1000_get_regs_len(netdev); | 600 | drvinfo->regdump_len = e1000_get_regs_len(netdev); |
603 | drvinfo->eedump_len = e1000_get_eeprom_len(netdev); | 601 | drvinfo->eedump_len = e1000_get_eeprom_len(netdev); |
604 | } | 602 | } |
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index a855db1ad249..a5bd7a3dafc9 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c | |||
@@ -163,16 +163,13 @@ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo) | |||
163 | regs[n] = __er32(hw, E1000_TARC(n)); | 163 | regs[n] = __er32(hw, E1000_TARC(n)); |
164 | break; | 164 | break; |
165 | default: | 165 | default: |
166 | printk(KERN_INFO "%-15s %08x\n", | 166 | pr_info("%-15s %08x\n", |
167 | reginfo->name, __er32(hw, reginfo->ofs)); | 167 | reginfo->name, __er32(hw, reginfo->ofs)); |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | snprintf(rname, 16, "%s%s", reginfo->name, "[0-1]"); | 171 | snprintf(rname, 16, "%s%s", reginfo->name, "[0-1]"); |
172 | printk(KERN_INFO "%-15s ", rname); | 172 | pr_info("%-15s %08x %08x\n", rname, regs[0], regs[1]); |
173 | for (n = 0; n < 2; n++) | ||
174 | printk(KERN_CONT "%08x ", regs[n]); | ||
175 | printk(KERN_CONT "\n"); | ||
176 | } | 173 | } |
177 | 174 | ||
178 | /* | 175 | /* |
@@ -208,16 +205,15 @@ static void e1000e_dump(struct e1000_adapter *adapter) | |||
208 | /* Print netdevice Info */ | 205 | /* Print netdevice Info */ |
209 | if (netdev) { | 206 | if (netdev) { |
210 | dev_info(&adapter->pdev->dev, "Net device Info\n"); | 207 | dev_info(&adapter->pdev->dev, "Net device Info\n"); |
211 | printk(KERN_INFO "Device Name state " | 208 | pr_info("Device Name state trans_start last_rx\n"); |
212 | "trans_start last_rx\n"); | 209 | pr_info("%-15s %016lX %016lX %016lX\n", |
213 | printk(KERN_INFO "%-15s %016lX %016lX %016lX\n", | 210 | netdev->name, netdev->state, netdev->trans_start, |
214 | netdev->name, netdev->state, netdev->trans_start, | 211 | netdev->last_rx); |
215 | netdev->last_rx); | ||
216 | } | 212 | } |
217 | 213 | ||
218 | /* Print Registers */ | 214 | /* Print Registers */ |
219 | dev_info(&adapter->pdev->dev, "Register Dump\n"); | 215 | dev_info(&adapter->pdev->dev, "Register Dump\n"); |
220 | printk(KERN_INFO " Register Name Value\n"); | 216 | pr_info(" Register Name Value\n"); |
221 | for (reginfo = (struct e1000_reg_info *)e1000_reg_info_tbl; | 217 | for (reginfo = (struct e1000_reg_info *)e1000_reg_info_tbl; |
222 | reginfo->name; reginfo++) { | 218 | reginfo->name; reginfo++) { |
223 | e1000_regdump(hw, reginfo); | 219 | e1000_regdump(hw, reginfo); |
@@ -228,15 +224,14 @@ static void e1000e_dump(struct e1000_adapter *adapter) | |||
228 | goto exit; | 224 | goto exit; |
229 | 225 | ||
230 | dev_info(&adapter->pdev->dev, "Tx Ring Summary\n"); | 226 | dev_info(&adapter->pdev->dev, "Tx Ring Summary\n"); |
231 | printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma ]" | 227 | pr_info("Queue [NTU] [NTC] [bi(ntc)->dma ] leng ntw timestamp\n"); |
232 | " leng ntw timestamp\n"); | ||
233 | buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean]; | 228 | buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean]; |
234 | printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n", | 229 | pr_info(" %5d %5X %5X %016llX %04X %3X %016llX\n", |
235 | 0, tx_ring->next_to_use, tx_ring->next_to_clean, | 230 | 0, tx_ring->next_to_use, tx_ring->next_to_clean, |
236 | (unsigned long long)buffer_info->dma, | 231 | (unsigned long long)buffer_info->dma, |
237 | buffer_info->length, | 232 | buffer_info->length, |
238 | buffer_info->next_to_watch, | 233 | buffer_info->next_to_watch, |
239 | (unsigned long long)buffer_info->time_stamp); | 234 | (unsigned long long)buffer_info->time_stamp); |
240 | 235 | ||
241 | /* Print Tx Ring */ | 236 | /* Print Tx Ring */ |
242 | if (!netif_msg_tx_done(adapter)) | 237 | if (!netif_msg_tx_done(adapter)) |
@@ -271,37 +266,32 @@ static void e1000e_dump(struct e1000_adapter *adapter) | |||
271 | * +----------------------------------------------------------------+ | 266 | * +----------------------------------------------------------------+ |
272 | * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 | 267 | * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 |
273 | */ | 268 | */ |
274 | printk(KERN_INFO "Tl[desc] [address 63:0 ] [SpeCssSCmCsLen]" | 269 | pr_info("Tl[desc] [address 63:0 ] [SpeCssSCmCsLen] [bi->dma ] leng ntw timestamp bi->skb <-- Legacy format\n"); |
275 | " [bi->dma ] leng ntw timestamp bi->skb " | 270 | pr_info("Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma ] leng ntw timestamp bi->skb <-- Ext Context format\n"); |
276 | "<-- Legacy format\n"); | 271 | pr_info("Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen] [bi->dma ] leng ntw timestamp bi->skb <-- Ext Data format\n"); |
277 | printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen]" | ||
278 | " [bi->dma ] leng ntw timestamp bi->skb " | ||
279 | "<-- Ext Context format\n"); | ||
280 | printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen]" | ||
281 | " [bi->dma ] leng ntw timestamp bi->skb " | ||
282 | "<-- Ext Data format\n"); | ||
283 | for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { | 272 | for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { |
273 | const char *next_desc; | ||
284 | tx_desc = E1000_TX_DESC(*tx_ring, i); | 274 | tx_desc = E1000_TX_DESC(*tx_ring, i); |
285 | buffer_info = &tx_ring->buffer_info[i]; | 275 | buffer_info = &tx_ring->buffer_info[i]; |
286 | u0 = (struct my_u0 *)tx_desc; | 276 | u0 = (struct my_u0 *)tx_desc; |
287 | printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX " | ||
288 | "%04X %3X %016llX %p", | ||
289 | (!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' : | ||
290 | ((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')), i, | ||
291 | (unsigned long long)le64_to_cpu(u0->a), | ||
292 | (unsigned long long)le64_to_cpu(u0->b), | ||
293 | (unsigned long long)buffer_info->dma, | ||
294 | buffer_info->length, buffer_info->next_to_watch, | ||
295 | (unsigned long long)buffer_info->time_stamp, | ||
296 | buffer_info->skb); | ||
297 | if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean) | 277 | if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean) |
298 | printk(KERN_CONT " NTC/U\n"); | 278 | next_desc = " NTC/U"; |
299 | else if (i == tx_ring->next_to_use) | 279 | else if (i == tx_ring->next_to_use) |
300 | printk(KERN_CONT " NTU\n"); | 280 | next_desc = " NTU"; |
301 | else if (i == tx_ring->next_to_clean) | 281 | else if (i == tx_ring->next_to_clean) |
302 | printk(KERN_CONT " NTC\n"); | 282 | next_desc = " NTC"; |
303 | else | 283 | else |
304 | printk(KERN_CONT "\n"); | 284 | next_desc = ""; |
285 | pr_info("T%c[0x%03X] %016llX %016llX %016llX %04X %3X %016llX %p%s\n", | ||
286 | (!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' : | ||
287 | ((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')), | ||
288 | i, | ||
289 | (unsigned long long)le64_to_cpu(u0->a), | ||
290 | (unsigned long long)le64_to_cpu(u0->b), | ||
291 | (unsigned long long)buffer_info->dma, | ||
292 | buffer_info->length, buffer_info->next_to_watch, | ||
293 | (unsigned long long)buffer_info->time_stamp, | ||
294 | buffer_info->skb, next_desc); | ||
305 | 295 | ||
306 | if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) | 296 | if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) |
307 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, | 297 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, |
@@ -312,9 +302,9 @@ static void e1000e_dump(struct e1000_adapter *adapter) | |||
312 | /* Print Rx Ring Summary */ | 302 | /* Print Rx Ring Summary */ |
313 | rx_ring_summary: | 303 | rx_ring_summary: |
314 | dev_info(&adapter->pdev->dev, "Rx Ring Summary\n"); | 304 | dev_info(&adapter->pdev->dev, "Rx Ring Summary\n"); |
315 | printk(KERN_INFO "Queue [NTU] [NTC]\n"); | 305 | pr_info("Queue [NTU] [NTC]\n"); |
316 | printk(KERN_INFO " %5d %5X %5X\n", 0, | 306 | pr_info(" %5d %5X %5X\n", |
317 | rx_ring->next_to_use, rx_ring->next_to_clean); | 307 | 0, rx_ring->next_to_use, rx_ring->next_to_clean); |
318 | 308 | ||
319 | /* Print Rx Ring */ | 309 | /* Print Rx Ring */ |
320 | if (!netif_msg_rx_status(adapter)) | 310 | if (!netif_msg_rx_status(adapter)) |
@@ -337,10 +327,7 @@ rx_ring_summary: | |||
337 | * 24 | Buffer Address 3 [63:0] | | 327 | * 24 | Buffer Address 3 [63:0] | |
338 | * +-----------------------------------------------------+ | 328 | * +-----------------------------------------------------+ |
339 | */ | 329 | */ |
340 | printk(KERN_INFO "R [desc] [buffer 0 63:0 ] " | 330 | pr_info("R [desc] [buffer 0 63:0 ] [buffer 1 63:0 ] [buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma ] [bi->skb] <-- Ext Pkt Split format\n"); |
341 | "[buffer 1 63:0 ] " | ||
342 | "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma ] " | ||
343 | "[bi->skb] <-- Ext Pkt Split format\n"); | ||
344 | /* [Extended] Receive Descriptor (Write-Back) Format | 331 | /* [Extended] Receive Descriptor (Write-Back) Format |
345 | * | 332 | * |
346 | * 63 48 47 32 31 13 12 8 7 4 3 0 | 333 | * 63 48 47 32 31 13 12 8 7 4 3 0 |
@@ -352,35 +339,40 @@ rx_ring_summary: | |||
352 | * +------------------------------------------------------+ | 339 | * +------------------------------------------------------+ |
353 | * 63 48 47 32 31 20 19 0 | 340 | * 63 48 47 32 31 20 19 0 |
354 | */ | 341 | */ |
355 | printk(KERN_INFO "RWB[desc] [ck ipid mrqhsh] " | 342 | pr_info("RWB[desc] [ck ipid mrqhsh] [vl l0 ee es] [ l3 l2 l1 hs] [reserved ] ---------------- [bi->skb] <-- Ext Rx Write-Back format\n"); |
356 | "[vl l0 ee es] " | ||
357 | "[ l3 l2 l1 hs] [reserved ] ---------------- " | ||
358 | "[bi->skb] <-- Ext Rx Write-Back format\n"); | ||
359 | for (i = 0; i < rx_ring->count; i++) { | 343 | for (i = 0; i < rx_ring->count; i++) { |
344 | const char *next_desc; | ||
360 | buffer_info = &rx_ring->buffer_info[i]; | 345 | buffer_info = &rx_ring->buffer_info[i]; |
361 | rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i); | 346 | rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i); |
362 | u1 = (struct my_u1 *)rx_desc_ps; | 347 | u1 = (struct my_u1 *)rx_desc_ps; |
363 | staterr = | 348 | staterr = |
364 | le32_to_cpu(rx_desc_ps->wb.middle.status_error); | 349 | le32_to_cpu(rx_desc_ps->wb.middle.status_error); |
350 | |||
351 | if (i == rx_ring->next_to_use) | ||
352 | next_desc = " NTU"; | ||
353 | else if (i == rx_ring->next_to_clean) | ||
354 | next_desc = " NTC"; | ||
355 | else | ||
356 | next_desc = ""; | ||
357 | |||
365 | if (staterr & E1000_RXD_STAT_DD) { | 358 | if (staterr & E1000_RXD_STAT_DD) { |
366 | /* Descriptor Done */ | 359 | /* Descriptor Done */ |
367 | printk(KERN_INFO "RWB[0x%03X] %016llX " | 360 | pr_info("%s[0x%03X] %016llX %016llX %016llX %016llX ---------------- %p%s\n", |
368 | "%016llX %016llX %016llX " | 361 | "RWB", i, |
369 | "---------------- %p", i, | 362 | (unsigned long long)le64_to_cpu(u1->a), |
370 | (unsigned long long)le64_to_cpu(u1->a), | 363 | (unsigned long long)le64_to_cpu(u1->b), |
371 | (unsigned long long)le64_to_cpu(u1->b), | 364 | (unsigned long long)le64_to_cpu(u1->c), |
372 | (unsigned long long)le64_to_cpu(u1->c), | 365 | (unsigned long long)le64_to_cpu(u1->d), |
373 | (unsigned long long)le64_to_cpu(u1->d), | 366 | buffer_info->skb, next_desc); |
374 | buffer_info->skb); | ||
375 | } else { | 367 | } else { |
376 | printk(KERN_INFO "R [0x%03X] %016llX " | 368 | pr_info("%s[0x%03X] %016llX %016llX %016llX %016llX %016llX %p%s\n", |
377 | "%016llX %016llX %016llX %016llX %p", i, | 369 | "R ", i, |
378 | (unsigned long long)le64_to_cpu(u1->a), | 370 | (unsigned long long)le64_to_cpu(u1->a), |
379 | (unsigned long long)le64_to_cpu(u1->b), | 371 | (unsigned long long)le64_to_cpu(u1->b), |
380 | (unsigned long long)le64_to_cpu(u1->c), | 372 | (unsigned long long)le64_to_cpu(u1->c), |
381 | (unsigned long long)le64_to_cpu(u1->d), | 373 | (unsigned long long)le64_to_cpu(u1->d), |
382 | (unsigned long long)buffer_info->dma, | 374 | (unsigned long long)buffer_info->dma, |
383 | buffer_info->skb); | 375 | buffer_info->skb, next_desc); |
384 | 376 | ||
385 | if (netif_msg_pktdata(adapter)) | 377 | if (netif_msg_pktdata(adapter)) |
386 | print_hex_dump(KERN_INFO, "", | 378 | print_hex_dump(KERN_INFO, "", |
@@ -388,13 +380,6 @@ rx_ring_summary: | |||
388 | phys_to_virt(buffer_info->dma), | 380 | phys_to_virt(buffer_info->dma), |
389 | adapter->rx_ps_bsize0, true); | 381 | adapter->rx_ps_bsize0, true); |
390 | } | 382 | } |
391 | |||
392 | if (i == rx_ring->next_to_use) | ||
393 | printk(KERN_CONT " NTU\n"); | ||
394 | else if (i == rx_ring->next_to_clean) | ||
395 | printk(KERN_CONT " NTC\n"); | ||
396 | else | ||
397 | printk(KERN_CONT "\n"); | ||
398 | } | 383 | } |
399 | break; | 384 | break; |
400 | default: | 385 | default: |
@@ -407,9 +392,7 @@ rx_ring_summary: | |||
407 | * 8 | Reserved | | 392 | * 8 | Reserved | |
408 | * +-----------------------------------------------------+ | 393 | * +-----------------------------------------------------+ |
409 | */ | 394 | */ |
410 | printk(KERN_INFO "R [desc] [buf addr 63:0 ] " | 395 | pr_info("R [desc] [buf addr 63:0 ] [reserved 63:0 ] [bi->dma ] [bi->skb] <-- Ext (Read) format\n"); |
411 | "[reserved 63:0 ] [bi->dma ] " | ||
412 | "[bi->skb] <-- Ext (Read) format\n"); | ||
413 | /* Extended Receive Descriptor (Write-Back) Format | 396 | /* Extended Receive Descriptor (Write-Back) Format |
414 | * | 397 | * |
415 | * 63 48 47 32 31 24 23 4 3 0 | 398 | * 63 48 47 32 31 24 23 4 3 0 |
@@ -423,29 +406,37 @@ rx_ring_summary: | |||
423 | * +------------------------------------------------------+ | 406 | * +------------------------------------------------------+ |
424 | * 63 48 47 32 31 20 19 0 | 407 | * 63 48 47 32 31 20 19 0 |
425 | */ | 408 | */ |
426 | printk(KERN_INFO "RWB[desc] [cs ipid mrq] " | 409 | pr_info("RWB[desc] [cs ipid mrq] [vt ln xe xs] [bi->skb] <-- Ext (Write-Back) format\n"); |
427 | "[vt ln xe xs] " | ||
428 | "[bi->skb] <-- Ext (Write-Back) format\n"); | ||
429 | 410 | ||
430 | for (i = 0; i < rx_ring->count; i++) { | 411 | for (i = 0; i < rx_ring->count; i++) { |
412 | const char *next_desc; | ||
413 | |||
431 | buffer_info = &rx_ring->buffer_info[i]; | 414 | buffer_info = &rx_ring->buffer_info[i]; |
432 | rx_desc = E1000_RX_DESC_EXT(*rx_ring, i); | 415 | rx_desc = E1000_RX_DESC_EXT(*rx_ring, i); |
433 | u1 = (struct my_u1 *)rx_desc; | 416 | u1 = (struct my_u1 *)rx_desc; |
434 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); | 417 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); |
418 | |||
419 | if (i == rx_ring->next_to_use) | ||
420 | next_desc = " NTU"; | ||
421 | else if (i == rx_ring->next_to_clean) | ||
422 | next_desc = " NTC"; | ||
423 | else | ||
424 | next_desc = ""; | ||
425 | |||
435 | if (staterr & E1000_RXD_STAT_DD) { | 426 | if (staterr & E1000_RXD_STAT_DD) { |
436 | /* Descriptor Done */ | 427 | /* Descriptor Done */ |
437 | printk(KERN_INFO "RWB[0x%03X] %016llX " | 428 | pr_info("%s[0x%03X] %016llX %016llX ---------------- %p%s\n", |
438 | "%016llX ---------------- %p", i, | 429 | "RWB", i, |
439 | (unsigned long long)le64_to_cpu(u1->a), | 430 | (unsigned long long)le64_to_cpu(u1->a), |
440 | (unsigned long long)le64_to_cpu(u1->b), | 431 | (unsigned long long)le64_to_cpu(u1->b), |
441 | buffer_info->skb); | 432 | buffer_info->skb, next_desc); |
442 | } else { | 433 | } else { |
443 | printk(KERN_INFO "R [0x%03X] %016llX " | 434 | pr_info("%s[0x%03X] %016llX %016llX %016llX %p%s\n", |
444 | "%016llX %016llX %p", i, | 435 | "R ", i, |
445 | (unsigned long long)le64_to_cpu(u1->a), | 436 | (unsigned long long)le64_to_cpu(u1->a), |
446 | (unsigned long long)le64_to_cpu(u1->b), | 437 | (unsigned long long)le64_to_cpu(u1->b), |
447 | (unsigned long long)buffer_info->dma, | 438 | (unsigned long long)buffer_info->dma, |
448 | buffer_info->skb); | 439 | buffer_info->skb, next_desc); |
449 | 440 | ||
450 | if (netif_msg_pktdata(adapter)) | 441 | if (netif_msg_pktdata(adapter)) |
451 | print_hex_dump(KERN_INFO, "", | 442 | print_hex_dump(KERN_INFO, "", |
@@ -456,13 +447,6 @@ rx_ring_summary: | |||
456 | adapter->rx_buffer_len, | 447 | adapter->rx_buffer_len, |
457 | true); | 448 | true); |
458 | } | 449 | } |
459 | |||
460 | if (i == rx_ring->next_to_use) | ||
461 | printk(KERN_CONT " NTU\n"); | ||
462 | else if (i == rx_ring->next_to_clean) | ||
463 | printk(KERN_CONT " NTC\n"); | ||
464 | else | ||
465 | printk(KERN_CONT "\n"); | ||
466 | } | 450 | } |
467 | } | 451 | } |
468 | 452 | ||
@@ -1222,8 +1206,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
1222 | adapter->flags2 |= FLAG2_IS_DISCARDING; | 1206 | adapter->flags2 |= FLAG2_IS_DISCARDING; |
1223 | 1207 | ||
1224 | if (adapter->flags2 & FLAG2_IS_DISCARDING) { | 1208 | if (adapter->flags2 & FLAG2_IS_DISCARDING) { |
1225 | e_dbg("Packet Split buffers didn't pick up the full " | 1209 | e_dbg("Packet Split buffers didn't pick up the full packet\n"); |
1226 | "packet\n"); | ||
1227 | dev_kfree_skb_irq(skb); | 1210 | dev_kfree_skb_irq(skb); |
1228 | if (staterr & E1000_RXD_STAT_EOP) | 1211 | if (staterr & E1000_RXD_STAT_EOP) |
1229 | adapter->flags2 &= ~FLAG2_IS_DISCARDING; | 1212 | adapter->flags2 &= ~FLAG2_IS_DISCARDING; |
@@ -1238,8 +1221,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
1238 | length = le16_to_cpu(rx_desc->wb.middle.length0); | 1221 | length = le16_to_cpu(rx_desc->wb.middle.length0); |
1239 | 1222 | ||
1240 | if (!length) { | 1223 | if (!length) { |
1241 | e_dbg("Last part of the packet spanning multiple " | 1224 | e_dbg("Last part of the packet spanning multiple descriptors\n"); |
1242 | "descriptors\n"); | ||
1243 | dev_kfree_skb_irq(skb); | 1225 | dev_kfree_skb_irq(skb); |
1244 | goto next_desc; | 1226 | goto next_desc; |
1245 | } | 1227 | } |
@@ -1917,8 +1899,7 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter) | |||
1917 | return; | 1899 | return; |
1918 | } | 1900 | } |
1919 | /* MSI-X failed, so fall through and try MSI */ | 1901 | /* MSI-X failed, so fall through and try MSI */ |
1920 | e_err("Failed to initialize MSI-X interrupts. " | 1902 | e_err("Failed to initialize MSI-X interrupts. Falling back to MSI interrupts.\n"); |
1921 | "Falling back to MSI interrupts.\n"); | ||
1922 | e1000e_reset_interrupt_capability(adapter); | 1903 | e1000e_reset_interrupt_capability(adapter); |
1923 | } | 1904 | } |
1924 | adapter->int_mode = E1000E_INT_MODE_MSI; | 1905 | adapter->int_mode = E1000E_INT_MODE_MSI; |
@@ -1928,8 +1909,7 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter) | |||
1928 | adapter->flags |= FLAG_MSI_ENABLED; | 1909 | adapter->flags |= FLAG_MSI_ENABLED; |
1929 | } else { | 1910 | } else { |
1930 | adapter->int_mode = E1000E_INT_MODE_LEGACY; | 1911 | adapter->int_mode = E1000E_INT_MODE_LEGACY; |
1931 | e_err("Failed to initialize MSI interrupts. Falling " | 1912 | e_err("Failed to initialize MSI interrupts. Falling back to legacy interrupts.\n"); |
1932 | "back to legacy interrupts.\n"); | ||
1933 | } | 1913 | } |
1934 | /* Fall through */ | 1914 | /* Fall through */ |
1935 | case E1000E_INT_MODE_LEGACY: | 1915 | case E1000E_INT_MODE_LEGACY: |
@@ -3113,79 +3093,147 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) | |||
3113 | } | 3093 | } |
3114 | 3094 | ||
3115 | /** | 3095 | /** |
3116 | * e1000_update_mc_addr_list - Update Multicast addresses | 3096 | * e1000e_write_mc_addr_list - write multicast addresses to MTA |
3117 | * @hw: pointer to the HW structure | 3097 | * @netdev: network interface device structure |
3118 | * @mc_addr_list: array of multicast addresses to program | 3098 | * |
3119 | * @mc_addr_count: number of multicast addresses to program | 3099 | * Writes multicast address list to the MTA hash table. |
3100 | * Returns: -ENOMEM on failure | ||
3101 | * 0 on no addresses written | ||
3102 | * X on writing X addresses to MTA | ||
3103 | */ | ||
3104 | static int e1000e_write_mc_addr_list(struct net_device *netdev) | ||
3105 | { | ||
3106 | struct e1000_adapter *adapter = netdev_priv(netdev); | ||
3107 | struct e1000_hw *hw = &adapter->hw; | ||
3108 | struct netdev_hw_addr *ha; | ||
3109 | u8 *mta_list; | ||
3110 | int i; | ||
3111 | |||
3112 | if (netdev_mc_empty(netdev)) { | ||
3113 | /* nothing to program, so clear mc list */ | ||
3114 | hw->mac.ops.update_mc_addr_list(hw, NULL, 0); | ||
3115 | return 0; | ||
3116 | } | ||
3117 | |||
3118 | mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC); | ||
3119 | if (!mta_list) | ||
3120 | return -ENOMEM; | ||
3121 | |||
3122 | /* update_mc_addr_list expects a packed array of only addresses. */ | ||
3123 | i = 0; | ||
3124 | netdev_for_each_mc_addr(ha, netdev) | ||
3125 | memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); | ||
3126 | |||
3127 | hw->mac.ops.update_mc_addr_list(hw, mta_list, i); | ||
3128 | kfree(mta_list); | ||
3129 | |||
3130 | return netdev_mc_count(netdev); | ||
3131 | } | ||
3132 | |||
3133 | /** | ||
3134 | * e1000e_write_uc_addr_list - write unicast addresses to RAR table | ||
3135 | * @netdev: network interface device structure | ||
3120 | * | 3136 | * |
3121 | * Updates the Multicast Table Array. | 3137 | * Writes unicast address list to the RAR table. |
3122 | * The caller must have a packed mc_addr_list of multicast addresses. | 3138 | * Returns: -ENOMEM on failure/insufficient address space |
3139 | * 0 on no addresses written | ||
3140 | * X on writing X addresses to the RAR table | ||
3123 | **/ | 3141 | **/ |
3124 | static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list, | 3142 | static int e1000e_write_uc_addr_list(struct net_device *netdev) |
3125 | u32 mc_addr_count) | ||
3126 | { | 3143 | { |
3127 | hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count); | 3144 | struct e1000_adapter *adapter = netdev_priv(netdev); |
3145 | struct e1000_hw *hw = &adapter->hw; | ||
3146 | unsigned int rar_entries = hw->mac.rar_entry_count; | ||
3147 | int count = 0; | ||
3148 | |||
3149 | /* save a rar entry for our hardware address */ | ||
3150 | rar_entries--; | ||
3151 | |||
3152 | /* save a rar entry for the LAA workaround */ | ||
3153 | if (adapter->flags & FLAG_RESET_OVERWRITES_LAA) | ||
3154 | rar_entries--; | ||
3155 | |||
3156 | /* return ENOMEM indicating insufficient memory for addresses */ | ||
3157 | if (netdev_uc_count(netdev) > rar_entries) | ||
3158 | return -ENOMEM; | ||
3159 | |||
3160 | if (!netdev_uc_empty(netdev) && rar_entries) { | ||
3161 | struct netdev_hw_addr *ha; | ||
3162 | |||
3163 | /* | ||
3164 | * write the addresses in reverse order to avoid write | ||
3165 | * combining | ||
3166 | */ | ||
3167 | netdev_for_each_uc_addr(ha, netdev) { | ||
3168 | if (!rar_entries) | ||
3169 | break; | ||
3170 | e1000e_rar_set(hw, ha->addr, rar_entries--); | ||
3171 | count++; | ||
3172 | } | ||
3173 | } | ||
3174 | |||
3175 | /* zero out the remaining RAR entries not used above */ | ||
3176 | for (; rar_entries > 0; rar_entries--) { | ||
3177 | ew32(RAH(rar_entries), 0); | ||
3178 | ew32(RAL(rar_entries), 0); | ||
3179 | } | ||
3180 | e1e_flush(); | ||
3181 | |||
3182 | return count; | ||
3128 | } | 3183 | } |
3129 | 3184 | ||
3130 | /** | 3185 | /** |
3131 | * e1000_set_multi - Multicast and Promiscuous mode set | 3186 | * e1000e_set_rx_mode - secondary unicast, Multicast and Promiscuous mode set |
3132 | * @netdev: network interface device structure | 3187 | * @netdev: network interface device structure |
3133 | * | 3188 | * |
3134 | * The set_multi entry point is called whenever the multicast address | 3189 | * The ndo_set_rx_mode entry point is called whenever the unicast or multicast |
3135 | * list or the network interface flags are updated. This routine is | 3190 | * address list or the network interface flags are updated. This routine is |
3136 | * responsible for configuring the hardware for proper multicast, | 3191 | * responsible for configuring the hardware for proper unicast, multicast, |
3137 | * promiscuous mode, and all-multi behavior. | 3192 | * promiscuous mode, and all-multi behavior. |
3138 | **/ | 3193 | **/ |
3139 | static void e1000_set_multi(struct net_device *netdev) | 3194 | static void e1000e_set_rx_mode(struct net_device *netdev) |
3140 | { | 3195 | { |
3141 | struct e1000_adapter *adapter = netdev_priv(netdev); | 3196 | struct e1000_adapter *adapter = netdev_priv(netdev); |
3142 | struct e1000_hw *hw = &adapter->hw; | 3197 | struct e1000_hw *hw = &adapter->hw; |
3143 | struct netdev_hw_addr *ha; | ||
3144 | u8 *mta_list; | ||
3145 | u32 rctl; | 3198 | u32 rctl; |
3146 | 3199 | ||
3147 | /* Check for Promiscuous and All Multicast modes */ | 3200 | /* Check for Promiscuous and All Multicast modes */ |
3148 | |||
3149 | rctl = er32(RCTL); | 3201 | rctl = er32(RCTL); |
3150 | 3202 | ||
3203 | /* clear the affected bits */ | ||
3204 | rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE); | ||
3205 | |||
3151 | if (netdev->flags & IFF_PROMISC) { | 3206 | if (netdev->flags & IFF_PROMISC) { |
3152 | rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); | 3207 | rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); |
3153 | rctl &= ~E1000_RCTL_VFE; | ||
3154 | /* Do not hardware filter VLANs in promisc mode */ | 3208 | /* Do not hardware filter VLANs in promisc mode */ |
3155 | e1000e_vlan_filter_disable(adapter); | 3209 | e1000e_vlan_filter_disable(adapter); |
3156 | } else { | 3210 | } else { |
3211 | int count; | ||
3157 | if (netdev->flags & IFF_ALLMULTI) { | 3212 | if (netdev->flags & IFF_ALLMULTI) { |
3158 | rctl |= E1000_RCTL_MPE; | 3213 | rctl |= E1000_RCTL_MPE; |
3159 | rctl &= ~E1000_RCTL_UPE; | ||
3160 | } else { | 3214 | } else { |
3161 | rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE); | 3215 | /* |
3216 | * Write addresses to the MTA, if the attempt fails | ||
3217 | * then we should just turn on promiscuous mode so | ||
3218 | * that we can at least receive multicast traffic | ||
3219 | */ | ||
3220 | count = e1000e_write_mc_addr_list(netdev); | ||
3221 | if (count < 0) | ||
3222 | rctl |= E1000_RCTL_MPE; | ||
3162 | } | 3223 | } |
3163 | e1000e_vlan_filter_enable(adapter); | 3224 | e1000e_vlan_filter_enable(adapter); |
3164 | } | ||
3165 | |||
3166 | ew32(RCTL, rctl); | ||
3167 | |||
3168 | if (!netdev_mc_empty(netdev)) { | ||
3169 | int i = 0; | ||
3170 | |||
3171 | mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); | ||
3172 | if (!mta_list) | ||
3173 | return; | ||
3174 | |||
3175 | /* prepare a packed array of only addresses. */ | ||
3176 | netdev_for_each_mc_addr(ha, netdev) | ||
3177 | memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); | ||
3178 | |||
3179 | e1000_update_mc_addr_list(hw, mta_list, i); | ||
3180 | kfree(mta_list); | ||
3181 | } else { | ||
3182 | /* | 3225 | /* |
3183 | * if we're called from probe, we might not have | 3226 | * Write addresses to available RAR registers, if there is not |
3184 | * anything to do here, so clear out the list | 3227 | * sufficient space to store all the addresses then enable |
3228 | * unicast promiscuous mode | ||
3185 | */ | 3229 | */ |
3186 | e1000_update_mc_addr_list(hw, NULL, 0); | 3230 | count = e1000e_write_uc_addr_list(netdev); |
3231 | if (count < 0) | ||
3232 | rctl |= E1000_RCTL_UPE; | ||
3187 | } | 3233 | } |
3188 | 3234 | ||
3235 | ew32(RCTL, rctl); | ||
3236 | |||
3189 | if (netdev->features & NETIF_F_HW_VLAN_RX) | 3237 | if (netdev->features & NETIF_F_HW_VLAN_RX) |
3190 | e1000e_vlan_strip_enable(adapter); | 3238 | e1000e_vlan_strip_enable(adapter); |
3191 | else | 3239 | else |
@@ -3198,7 +3246,7 @@ static void e1000_set_multi(struct net_device *netdev) | |||
3198 | **/ | 3246 | **/ |
3199 | static void e1000_configure(struct e1000_adapter *adapter) | 3247 | static void e1000_configure(struct e1000_adapter *adapter) |
3200 | { | 3248 | { |
3201 | e1000_set_multi(adapter->netdev); | 3249 | e1000e_set_rx_mode(adapter->netdev); |
3202 | 3250 | ||
3203 | e1000_restore_vlan(adapter); | 3251 | e1000_restore_vlan(adapter); |
3204 | e1000_init_manageability_pt(adapter); | 3252 | e1000_init_manageability_pt(adapter); |
@@ -4168,16 +4216,13 @@ static void e1000_print_link_info(struct e1000_adapter *adapter) | |||
4168 | u32 ctrl = er32(CTRL); | 4216 | u32 ctrl = er32(CTRL); |
4169 | 4217 | ||
4170 | /* Link status message must follow this format for user tools */ | 4218 | /* Link status message must follow this format for user tools */ |
4171 | printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s, " | 4219 | printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n", |
4172 | "Flow Control: %s\n", | 4220 | adapter->netdev->name, |
4173 | adapter->netdev->name, | 4221 | adapter->link_speed, |
4174 | adapter->link_speed, | 4222 | adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half", |
4175 | (adapter->link_duplex == FULL_DUPLEX) ? | 4223 | (ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE) ? "Rx/Tx" : |
4176 | "Full Duplex" : "Half Duplex", | 4224 | (ctrl & E1000_CTRL_RFCE) ? "Rx" : |
4177 | ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ? | 4225 | (ctrl & E1000_CTRL_TFCE) ? "Tx" : "None"); |
4178 | "Rx/Tx" : | ||
4179 | ((ctrl & E1000_CTRL_RFCE) ? "Rx" : | ||
4180 | ((ctrl & E1000_CTRL_TFCE) ? "Tx" : "None"))); | ||
4181 | } | 4226 | } |
4182 | 4227 | ||
4183 | static bool e1000e_has_link(struct e1000_adapter *adapter) | 4228 | static bool e1000e_has_link(struct e1000_adapter *adapter) |
@@ -4323,10 +4368,7 @@ static void e1000_watchdog_task(struct work_struct *work) | |||
4323 | e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp); | 4368 | e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp); |
4324 | 4369 | ||
4325 | if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS)) | 4370 | if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS)) |
4326 | e_info("Autonegotiated half duplex but" | 4371 | e_info("Autonegotiated half duplex but link partner cannot autoneg. Try forcing full duplex if link gets many collisions.\n"); |
4327 | " link partner cannot autoneg. " | ||
4328 | " Try forcing full duplex if " | ||
4329 | "link gets many collisions.\n"); | ||
4330 | } | 4372 | } |
4331 | 4373 | ||
4332 | /* adjust timeout factor according to speed/duplex */ | 4374 | /* adjust timeout factor according to speed/duplex */ |
@@ -5110,8 +5152,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
5110 | if ((adapter->hw.mac.type == e1000_pch2lan) && | 5152 | if ((adapter->hw.mac.type == e1000_pch2lan) && |
5111 | !(adapter->flags2 & FLAG2_CRC_STRIPPING) && | 5153 | !(adapter->flags2 & FLAG2_CRC_STRIPPING) && |
5112 | (new_mtu > ETH_DATA_LEN)) { | 5154 | (new_mtu > ETH_DATA_LEN)) { |
5113 | e_err("Jumbo Frames not supported on 82579 when CRC " | 5155 | e_err("Jumbo Frames not supported on 82579 when CRC stripping is disabled.\n"); |
5114 | "stripping is disabled.\n"); | ||
5115 | return -EINVAL; | 5156 | return -EINVAL; |
5116 | } | 5157 | } |
5117 | 5158 | ||
@@ -5331,7 +5372,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake, | |||
5331 | 5372 | ||
5332 | if (wufc) { | 5373 | if (wufc) { |
5333 | e1000_setup_rctl(adapter); | 5374 | e1000_setup_rctl(adapter); |
5334 | e1000_set_multi(netdev); | 5375 | e1000e_set_rx_mode(netdev); |
5335 | 5376 | ||
5336 | /* turn on all-multi mode if wake on multicast is enabled */ | 5377 | /* turn on all-multi mode if wake on multicast is enabled */ |
5337 | if (wufc & E1000_WUFC_MC) { | 5378 | if (wufc & E1000_WUFC_MC) { |
@@ -5527,8 +5568,8 @@ static int __e1000_resume(struct pci_dev *pdev) | |||
5527 | phy_data & E1000_WUS_MC ? "Multicast Packet" : | 5568 | phy_data & E1000_WUS_MC ? "Multicast Packet" : |
5528 | phy_data & E1000_WUS_BC ? "Broadcast Packet" : | 5569 | phy_data & E1000_WUS_BC ? "Broadcast Packet" : |
5529 | phy_data & E1000_WUS_MAG ? "Magic Packet" : | 5570 | phy_data & E1000_WUS_MAG ? "Magic Packet" : |
5530 | phy_data & E1000_WUS_LNKC ? "Link Status " | 5571 | phy_data & E1000_WUS_LNKC ? |
5531 | " Change" : "other"); | 5572 | "Link Status Change" : "other"); |
5532 | } | 5573 | } |
5533 | e1e_wphy(&adapter->hw, BM_WUS, ~0); | 5574 | e1e_wphy(&adapter->hw, BM_WUS, ~0); |
5534 | } else { | 5575 | } else { |
@@ -5859,10 +5900,11 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter) | |||
5859 | } | 5900 | } |
5860 | } | 5901 | } |
5861 | 5902 | ||
5862 | static int e1000_set_features(struct net_device *netdev, u32 features) | 5903 | static int e1000_set_features(struct net_device *netdev, |
5904 | netdev_features_t features) | ||
5863 | { | 5905 | { |
5864 | struct e1000_adapter *adapter = netdev_priv(netdev); | 5906 | struct e1000_adapter *adapter = netdev_priv(netdev); |
5865 | u32 changed = features ^ netdev->features; | 5907 | netdev_features_t changed = features ^ netdev->features; |
5866 | 5908 | ||
5867 | if (changed & (NETIF_F_TSO | NETIF_F_TSO6)) | 5909 | if (changed & (NETIF_F_TSO | NETIF_F_TSO6)) |
5868 | adapter->flags |= FLAG_TSO_FORCE; | 5910 | adapter->flags |= FLAG_TSO_FORCE; |
@@ -5884,7 +5926,7 @@ static const struct net_device_ops e1000e_netdev_ops = { | |||
5884 | .ndo_stop = e1000_close, | 5926 | .ndo_stop = e1000_close, |
5885 | .ndo_start_xmit = e1000_xmit_frame, | 5927 | .ndo_start_xmit = e1000_xmit_frame, |
5886 | .ndo_get_stats64 = e1000e_get_stats64, | 5928 | .ndo_get_stats64 = e1000e_get_stats64, |
5887 | .ndo_set_rx_mode = e1000_set_multi, | 5929 | .ndo_set_rx_mode = e1000e_set_rx_mode, |
5888 | .ndo_set_mac_address = e1000_set_mac, | 5930 | .ndo_set_mac_address = e1000_set_mac, |
5889 | .ndo_change_mtu = e1000_change_mtu, | 5931 | .ndo_change_mtu = e1000_change_mtu, |
5890 | .ndo_do_ioctl = e1000_ioctl, | 5932 | .ndo_do_ioctl = e1000_ioctl, |
@@ -5949,8 +5991,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
5949 | err = dma_set_coherent_mask(&pdev->dev, | 5991 | err = dma_set_coherent_mask(&pdev->dev, |
5950 | DMA_BIT_MASK(32)); | 5992 | DMA_BIT_MASK(32)); |
5951 | if (err) { | 5993 | if (err) { |
5952 | dev_err(&pdev->dev, "No usable DMA " | 5994 | dev_err(&pdev->dev, "No usable DMA configuration, aborting\n"); |
5953 | "configuration, aborting\n"); | ||
5954 | goto err_dma; | 5995 | goto err_dma; |
5955 | } | 5996 | } |
5956 | } | 5997 | } |
@@ -6076,6 +6117,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
6076 | NETIF_F_TSO6 | | 6117 | NETIF_F_TSO6 | |
6077 | NETIF_F_HW_CSUM); | 6118 | NETIF_F_HW_CSUM); |
6078 | 6119 | ||
6120 | netdev->priv_flags |= IFF_UNICAST_FLT; | ||
6121 | |||
6079 | if (pci_using_dac) { | 6122 | if (pci_using_dac) { |
6080 | netdev->features |= NETIF_F_HIGHDMA; | 6123 | netdev->features |= NETIF_F_HIGHDMA; |
6081 | netdev->vlan_features |= NETIF_F_HIGHDMA; | 6124 | netdev->vlan_features |= NETIF_F_HIGHDMA; |
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c index 7881fb95a25b..b8e20f037d0a 100644 --- a/drivers/net/ethernet/intel/igb/e1000_82575.c +++ b/drivers/net/ethernet/intel/igb/e1000_82575.c | |||
@@ -29,6 +29,8 @@ | |||
29 | * e1000_82576 | 29 | * e1000_82576 |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
33 | |||
32 | #include <linux/types.h> | 34 | #include <linux/types.h> |
33 | #include <linux/if_ether.h> | 35 | #include <linux/if_ether.h> |
34 | 36 | ||
@@ -244,8 +246,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
244 | * Check for invalid size | 246 | * Check for invalid size |
245 | */ | 247 | */ |
246 | if ((hw->mac.type == e1000_82576) && (size > 15)) { | 248 | if ((hw->mac.type == e1000_82576) && (size > 15)) { |
247 | printk("igb: The NVM size is not valid, " | 249 | pr_notice("The NVM size is not valid, defaulting to 32K\n"); |
248 | "defaulting to 32K.\n"); | ||
249 | size = 15; | 250 | size = 15; |
250 | } | 251 | } |
251 | nvm->word_size = 1 << size; | 252 | nvm->word_size = 1 << size; |
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index 43873eba2f63..e9335efac386 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c | |||
@@ -673,25 +673,22 @@ static void igb_get_drvinfo(struct net_device *netdev, | |||
673 | struct ethtool_drvinfo *drvinfo) | 673 | struct ethtool_drvinfo *drvinfo) |
674 | { | 674 | { |
675 | struct igb_adapter *adapter = netdev_priv(netdev); | 675 | struct igb_adapter *adapter = netdev_priv(netdev); |
676 | char firmware_version[32]; | ||
677 | u16 eeprom_data; | 676 | u16 eeprom_data; |
678 | 677 | ||
679 | strncpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver) - 1); | 678 | strlcpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver)); |
680 | strncpy(drvinfo->version, igb_driver_version, | 679 | strlcpy(drvinfo->version, igb_driver_version, sizeof(drvinfo->version)); |
681 | sizeof(drvinfo->version) - 1); | ||
682 | 680 | ||
683 | /* EEPROM image version # is reported as firmware version # for | 681 | /* EEPROM image version # is reported as firmware version # for |
684 | * 82575 controllers */ | 682 | * 82575 controllers */ |
685 | adapter->hw.nvm.ops.read(&adapter->hw, 5, 1, &eeprom_data); | 683 | adapter->hw.nvm.ops.read(&adapter->hw, 5, 1, &eeprom_data); |
686 | sprintf(firmware_version, "%d.%d-%d", | 684 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), |
685 | "%d.%d-%d", | ||
687 | (eeprom_data & 0xF000) >> 12, | 686 | (eeprom_data & 0xF000) >> 12, |
688 | (eeprom_data & 0x0FF0) >> 4, | 687 | (eeprom_data & 0x0FF0) >> 4, |
689 | eeprom_data & 0x000F); | 688 | eeprom_data & 0x000F); |
690 | 689 | ||
691 | strncpy(drvinfo->fw_version, firmware_version, | 690 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
692 | sizeof(drvinfo->fw_version) - 1); | 691 | sizeof(drvinfo->bus_info)); |
693 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
694 | sizeof(drvinfo->bus_info) - 1); | ||
695 | drvinfo->n_stats = IGB_STATS_LEN; | 692 | drvinfo->n_stats = IGB_STATS_LEN; |
696 | drvinfo->testinfo_len = IGB_TEST_LEN; | 693 | drvinfo->testinfo_len = IGB_TEST_LEN; |
697 | drvinfo->regdump_len = igb_get_regs_len(netdev); | 694 | drvinfo->regdump_len = igb_get_regs_len(netdev); |
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index ced544499f1b..bd9b30e6ae9d 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
@@ -25,6 +25,8 @@ | |||
25 | 25 | ||
26 | *******************************************************************************/ | 26 | *******************************************************************************/ |
27 | 27 | ||
28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
29 | |||
28 | #include <linux/module.h> | 30 | #include <linux/module.h> |
29 | #include <linux/types.h> | 31 | #include <linux/types.h> |
30 | #include <linux/init.h> | 32 | #include <linux/init.h> |
@@ -145,7 +147,7 @@ static bool igb_clean_rx_irq(struct igb_q_vector *, int); | |||
145 | static int igb_ioctl(struct net_device *, struct ifreq *, int cmd); | 147 | static int igb_ioctl(struct net_device *, struct ifreq *, int cmd); |
146 | static void igb_tx_timeout(struct net_device *); | 148 | static void igb_tx_timeout(struct net_device *); |
147 | static void igb_reset_task(struct work_struct *); | 149 | static void igb_reset_task(struct work_struct *); |
148 | static void igb_vlan_mode(struct net_device *netdev, u32 features); | 150 | static void igb_vlan_mode(struct net_device *netdev, netdev_features_t features); |
149 | static void igb_vlan_rx_add_vid(struct net_device *, u16); | 151 | static void igb_vlan_rx_add_vid(struct net_device *, u16); |
150 | static void igb_vlan_rx_kill_vid(struct net_device *, u16); | 152 | static void igb_vlan_rx_kill_vid(struct net_device *, u16); |
151 | static void igb_restore_vlan(struct igb_adapter *); | 153 | static void igb_restore_vlan(struct igb_adapter *); |
@@ -325,16 +327,13 @@ static void igb_regdump(struct e1000_hw *hw, struct igb_reg_info *reginfo) | |||
325 | regs[n] = rd32(E1000_TXDCTL(n)); | 327 | regs[n] = rd32(E1000_TXDCTL(n)); |
326 | break; | 328 | break; |
327 | default: | 329 | default: |
328 | printk(KERN_INFO "%-15s %08x\n", | 330 | pr_info("%-15s %08x\n", reginfo->name, rd32(reginfo->ofs)); |
329 | reginfo->name, rd32(reginfo->ofs)); | ||
330 | return; | 331 | return; |
331 | } | 332 | } |
332 | 333 | ||
333 | snprintf(rname, 16, "%s%s", reginfo->name, "[0-3]"); | 334 | snprintf(rname, 16, "%s%s", reginfo->name, "[0-3]"); |
334 | printk(KERN_INFO "%-15s ", rname); | 335 | pr_info("%-15s %08x %08x %08x %08x\n", rname, regs[0], regs[1], |
335 | for (n = 0; n < 4; n++) | 336 | regs[2], regs[3]); |
336 | printk(KERN_CONT "%08x ", regs[n]); | ||
337 | printk(KERN_CONT "\n"); | ||
338 | } | 337 | } |
339 | 338 | ||
340 | /* | 339 | /* |
@@ -359,18 +358,15 @@ static void igb_dump(struct igb_adapter *adapter) | |||
359 | /* Print netdevice Info */ | 358 | /* Print netdevice Info */ |
360 | if (netdev) { | 359 | if (netdev) { |
361 | dev_info(&adapter->pdev->dev, "Net device Info\n"); | 360 | dev_info(&adapter->pdev->dev, "Net device Info\n"); |
362 | printk(KERN_INFO "Device Name state " | 361 | pr_info("Device Name state trans_start " |
363 | "trans_start last_rx\n"); | 362 | "last_rx\n"); |
364 | printk(KERN_INFO "%-15s %016lX %016lX %016lX\n", | 363 | pr_info("%-15s %016lX %016lX %016lX\n", netdev->name, |
365 | netdev->name, | 364 | netdev->state, netdev->trans_start, netdev->last_rx); |
366 | netdev->state, | ||
367 | netdev->trans_start, | ||
368 | netdev->last_rx); | ||
369 | } | 365 | } |
370 | 366 | ||
371 | /* Print Registers */ | 367 | /* Print Registers */ |
372 | dev_info(&adapter->pdev->dev, "Register Dump\n"); | 368 | dev_info(&adapter->pdev->dev, "Register Dump\n"); |
373 | printk(KERN_INFO " Register Name Value\n"); | 369 | pr_info(" Register Name Value\n"); |
374 | for (reginfo = (struct igb_reg_info *)igb_reg_info_tbl; | 370 | for (reginfo = (struct igb_reg_info *)igb_reg_info_tbl; |
375 | reginfo->name; reginfo++) { | 371 | reginfo->name; reginfo++) { |
376 | igb_regdump(hw, reginfo); | 372 | igb_regdump(hw, reginfo); |
@@ -381,18 +377,17 @@ static void igb_dump(struct igb_adapter *adapter) | |||
381 | goto exit; | 377 | goto exit; |
382 | 378 | ||
383 | dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); | 379 | dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); |
384 | printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma ]" | 380 | pr_info("Queue [NTU] [NTC] [bi(ntc)->dma ] leng ntw timestamp\n"); |
385 | " leng ntw timestamp\n"); | ||
386 | for (n = 0; n < adapter->num_tx_queues; n++) { | 381 | for (n = 0; n < adapter->num_tx_queues; n++) { |
387 | struct igb_tx_buffer *buffer_info; | 382 | struct igb_tx_buffer *buffer_info; |
388 | tx_ring = adapter->tx_ring[n]; | 383 | tx_ring = adapter->tx_ring[n]; |
389 | buffer_info = &tx_ring->tx_buffer_info[tx_ring->next_to_clean]; | 384 | buffer_info = &tx_ring->tx_buffer_info[tx_ring->next_to_clean]; |
390 | printk(KERN_INFO " %5d %5X %5X %016llX %04X %p %016llX\n", | 385 | pr_info(" %5d %5X %5X %016llX %04X %p %016llX\n", |
391 | n, tx_ring->next_to_use, tx_ring->next_to_clean, | 386 | n, tx_ring->next_to_use, tx_ring->next_to_clean, |
392 | (u64)buffer_info->dma, | 387 | (u64)buffer_info->dma, |
393 | buffer_info->length, | 388 | buffer_info->length, |
394 | buffer_info->next_to_watch, | 389 | buffer_info->next_to_watch, |
395 | (u64)buffer_info->time_stamp); | 390 | (u64)buffer_info->time_stamp); |
396 | } | 391 | } |
397 | 392 | ||
398 | /* Print TX Rings */ | 393 | /* Print TX Rings */ |
@@ -414,36 +409,38 @@ static void igb_dump(struct igb_adapter *adapter) | |||
414 | 409 | ||
415 | for (n = 0; n < adapter->num_tx_queues; n++) { | 410 | for (n = 0; n < adapter->num_tx_queues; n++) { |
416 | tx_ring = adapter->tx_ring[n]; | 411 | tx_ring = adapter->tx_ring[n]; |
417 | printk(KERN_INFO "------------------------------------\n"); | 412 | pr_info("------------------------------------\n"); |
418 | printk(KERN_INFO "TX QUEUE INDEX = %d\n", tx_ring->queue_index); | 413 | pr_info("TX QUEUE INDEX = %d\n", tx_ring->queue_index); |
419 | printk(KERN_INFO "------------------------------------\n"); | 414 | pr_info("------------------------------------\n"); |
420 | printk(KERN_INFO "T [desc] [address 63:0 ] " | 415 | pr_info("T [desc] [address 63:0 ] [PlPOCIStDDM Ln] " |
421 | "[PlPOCIStDDM Ln] [bi->dma ] " | 416 | "[bi->dma ] leng ntw timestamp " |
422 | "leng ntw timestamp bi->skb\n"); | 417 | "bi->skb\n"); |
423 | 418 | ||
424 | for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { | 419 | for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { |
420 | const char *next_desc; | ||
425 | struct igb_tx_buffer *buffer_info; | 421 | struct igb_tx_buffer *buffer_info; |
426 | tx_desc = IGB_TX_DESC(tx_ring, i); | 422 | tx_desc = IGB_TX_DESC(tx_ring, i); |
427 | buffer_info = &tx_ring->tx_buffer_info[i]; | 423 | buffer_info = &tx_ring->tx_buffer_info[i]; |
428 | u0 = (struct my_u0 *)tx_desc; | 424 | u0 = (struct my_u0 *)tx_desc; |
429 | printk(KERN_INFO "T [0x%03X] %016llX %016llX %016llX" | 425 | if (i == tx_ring->next_to_use && |
430 | " %04X %p %016llX %p", i, | 426 | i == tx_ring->next_to_clean) |
427 | next_desc = " NTC/U"; | ||
428 | else if (i == tx_ring->next_to_use) | ||
429 | next_desc = " NTU"; | ||
430 | else if (i == tx_ring->next_to_clean) | ||
431 | next_desc = " NTC"; | ||
432 | else | ||
433 | next_desc = ""; | ||
434 | |||
435 | pr_info("T [0x%03X] %016llX %016llX %016llX" | ||
436 | " %04X %p %016llX %p%s\n", i, | ||
431 | le64_to_cpu(u0->a), | 437 | le64_to_cpu(u0->a), |
432 | le64_to_cpu(u0->b), | 438 | le64_to_cpu(u0->b), |
433 | (u64)buffer_info->dma, | 439 | (u64)buffer_info->dma, |
434 | buffer_info->length, | 440 | buffer_info->length, |
435 | buffer_info->next_to_watch, | 441 | buffer_info->next_to_watch, |
436 | (u64)buffer_info->time_stamp, | 442 | (u64)buffer_info->time_stamp, |
437 | buffer_info->skb); | 443 | buffer_info->skb, next_desc); |
438 | if (i == tx_ring->next_to_use && | ||
439 | i == tx_ring->next_to_clean) | ||
440 | printk(KERN_CONT " NTC/U\n"); | ||
441 | else if (i == tx_ring->next_to_use) | ||
442 | printk(KERN_CONT " NTU\n"); | ||
443 | else if (i == tx_ring->next_to_clean) | ||
444 | printk(KERN_CONT " NTC\n"); | ||
445 | else | ||
446 | printk(KERN_CONT "\n"); | ||
447 | 444 | ||
448 | if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) | 445 | if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) |
449 | print_hex_dump(KERN_INFO, "", | 446 | print_hex_dump(KERN_INFO, "", |
@@ -456,11 +453,11 @@ static void igb_dump(struct igb_adapter *adapter) | |||
456 | /* Print RX Rings Summary */ | 453 | /* Print RX Rings Summary */ |
457 | rx_ring_summary: | 454 | rx_ring_summary: |
458 | dev_info(&adapter->pdev->dev, "RX Rings Summary\n"); | 455 | dev_info(&adapter->pdev->dev, "RX Rings Summary\n"); |
459 | printk(KERN_INFO "Queue [NTU] [NTC]\n"); | 456 | pr_info("Queue [NTU] [NTC]\n"); |
460 | for (n = 0; n < adapter->num_rx_queues; n++) { | 457 | for (n = 0; n < adapter->num_rx_queues; n++) { |
461 | rx_ring = adapter->rx_ring[n]; | 458 | rx_ring = adapter->rx_ring[n]; |
462 | printk(KERN_INFO " %5d %5X %5X\n", n, | 459 | pr_info(" %5d %5X %5X\n", |
463 | rx_ring->next_to_use, rx_ring->next_to_clean); | 460 | n, rx_ring->next_to_use, rx_ring->next_to_clean); |
464 | } | 461 | } |
465 | 462 | ||
466 | /* Print RX Rings */ | 463 | /* Print RX Rings */ |
@@ -492,36 +489,43 @@ rx_ring_summary: | |||
492 | 489 | ||
493 | for (n = 0; n < adapter->num_rx_queues; n++) { | 490 | for (n = 0; n < adapter->num_rx_queues; n++) { |
494 | rx_ring = adapter->rx_ring[n]; | 491 | rx_ring = adapter->rx_ring[n]; |
495 | printk(KERN_INFO "------------------------------------\n"); | 492 | pr_info("------------------------------------\n"); |
496 | printk(KERN_INFO "RX QUEUE INDEX = %d\n", rx_ring->queue_index); | 493 | pr_info("RX QUEUE INDEX = %d\n", rx_ring->queue_index); |
497 | printk(KERN_INFO "------------------------------------\n"); | 494 | pr_info("------------------------------------\n"); |
498 | printk(KERN_INFO "R [desc] [ PktBuf A0] " | 495 | pr_info("R [desc] [ PktBuf A0] [ HeadBuf DD] " |
499 | "[ HeadBuf DD] [bi->dma ] [bi->skb] " | 496 | "[bi->dma ] [bi->skb] <-- Adv Rx Read format\n"); |
500 | "<-- Adv Rx Read format\n"); | 497 | pr_info("RWB[desc] [PcsmIpSHl PtRs] [vl er S cks ln] -----" |
501 | printk(KERN_INFO "RWB[desc] [PcsmIpSHl PtRs] " | 498 | "----------- [bi->skb] <-- Adv Rx Write-Back format\n"); |
502 | "[vl er S cks ln] ---------------- [bi->skb] " | ||
503 | "<-- Adv Rx Write-Back format\n"); | ||
504 | 499 | ||
505 | for (i = 0; i < rx_ring->count; i++) { | 500 | for (i = 0; i < rx_ring->count; i++) { |
501 | const char *next_desc; | ||
506 | struct igb_rx_buffer *buffer_info; | 502 | struct igb_rx_buffer *buffer_info; |
507 | buffer_info = &rx_ring->rx_buffer_info[i]; | 503 | buffer_info = &rx_ring->rx_buffer_info[i]; |
508 | rx_desc = IGB_RX_DESC(rx_ring, i); | 504 | rx_desc = IGB_RX_DESC(rx_ring, i); |
509 | u0 = (struct my_u0 *)rx_desc; | 505 | u0 = (struct my_u0 *)rx_desc; |
510 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); | 506 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); |
507 | |||
508 | if (i == rx_ring->next_to_use) | ||
509 | next_desc = " NTU"; | ||
510 | else if (i == rx_ring->next_to_clean) | ||
511 | next_desc = " NTC"; | ||
512 | else | ||
513 | next_desc = ""; | ||
514 | |||
511 | if (staterr & E1000_RXD_STAT_DD) { | 515 | if (staterr & E1000_RXD_STAT_DD) { |
512 | /* Descriptor Done */ | 516 | /* Descriptor Done */ |
513 | printk(KERN_INFO "RWB[0x%03X] %016llX " | 517 | pr_info("%s[0x%03X] %016llX %016llX -------" |
514 | "%016llX ---------------- %p", i, | 518 | "--------- %p%s\n", "RWB", i, |
515 | le64_to_cpu(u0->a), | 519 | le64_to_cpu(u0->a), |
516 | le64_to_cpu(u0->b), | 520 | le64_to_cpu(u0->b), |
517 | buffer_info->skb); | 521 | buffer_info->skb, next_desc); |
518 | } else { | 522 | } else { |
519 | printk(KERN_INFO "R [0x%03X] %016llX " | 523 | pr_info("%s[0x%03X] %016llX %016llX %016llX" |
520 | "%016llX %016llX %p", i, | 524 | " %p%s\n", "R ", i, |
521 | le64_to_cpu(u0->a), | 525 | le64_to_cpu(u0->a), |
522 | le64_to_cpu(u0->b), | 526 | le64_to_cpu(u0->b), |
523 | (u64)buffer_info->dma, | 527 | (u64)buffer_info->dma, |
524 | buffer_info->skb); | 528 | buffer_info->skb, next_desc); |
525 | 529 | ||
526 | if (netif_msg_pktdata(adapter)) { | 530 | if (netif_msg_pktdata(adapter)) { |
527 | print_hex_dump(KERN_INFO, "", | 531 | print_hex_dump(KERN_INFO, "", |
@@ -538,14 +542,6 @@ rx_ring_summary: | |||
538 | PAGE_SIZE/2, true); | 542 | PAGE_SIZE/2, true); |
539 | } | 543 | } |
540 | } | 544 | } |
541 | |||
542 | if (i == rx_ring->next_to_use) | ||
543 | printk(KERN_CONT " NTU\n"); | ||
544 | else if (i == rx_ring->next_to_clean) | ||
545 | printk(KERN_CONT " NTC\n"); | ||
546 | else | ||
547 | printk(KERN_CONT "\n"); | ||
548 | |||
549 | } | 545 | } |
550 | } | 546 | } |
551 | 547 | ||
@@ -599,10 +595,10 @@ struct net_device *igb_get_hw_dev(struct e1000_hw *hw) | |||
599 | static int __init igb_init_module(void) | 595 | static int __init igb_init_module(void) |
600 | { | 596 | { |
601 | int ret; | 597 | int ret; |
602 | printk(KERN_INFO "%s - version %s\n", | 598 | pr_info("%s - version %s\n", |
603 | igb_driver_string, igb_driver_version); | 599 | igb_driver_string, igb_driver_version); |
604 | 600 | ||
605 | printk(KERN_INFO "%s\n", igb_copyright); | 601 | pr_info("%s\n", igb_copyright); |
606 | 602 | ||
607 | #ifdef CONFIG_IGB_DCA | 603 | #ifdef CONFIG_IGB_DCA |
608 | dca_register_notify(&dca_notifier); | 604 | dca_register_notify(&dca_notifier); |
@@ -1742,7 +1738,8 @@ void igb_reset(struct igb_adapter *adapter) | |||
1742 | igb_get_phy_info(hw); | 1738 | igb_get_phy_info(hw); |
1743 | } | 1739 | } |
1744 | 1740 | ||
1745 | static u32 igb_fix_features(struct net_device *netdev, u32 features) | 1741 | static netdev_features_t igb_fix_features(struct net_device *netdev, |
1742 | netdev_features_t features) | ||
1746 | { | 1743 | { |
1747 | /* | 1744 | /* |
1748 | * Since there is no support for separate rx/tx vlan accel | 1745 | * Since there is no support for separate rx/tx vlan accel |
@@ -1756,9 +1753,10 @@ static u32 igb_fix_features(struct net_device *netdev, u32 features) | |||
1756 | return features; | 1753 | return features; |
1757 | } | 1754 | } |
1758 | 1755 | ||
1759 | static int igb_set_features(struct net_device *netdev, u32 features) | 1756 | static int igb_set_features(struct net_device *netdev, |
1757 | netdev_features_t features) | ||
1760 | { | 1758 | { |
1761 | u32 changed = netdev->features ^ features; | 1759 | netdev_features_t changed = netdev->features ^ features; |
1762 | 1760 | ||
1763 | if (changed & NETIF_F_HW_VLAN_RX) | 1761 | if (changed & NETIF_F_HW_VLAN_RX) |
1764 | igb_vlan_mode(netdev, features); | 1762 | igb_vlan_mode(netdev, features); |
@@ -3640,23 +3638,23 @@ static void igb_watchdog_task(struct work_struct *work) | |||
3640 | 3638 | ||
3641 | ctrl = rd32(E1000_CTRL); | 3639 | ctrl = rd32(E1000_CTRL); |
3642 | /* Links status message must follow this format */ | 3640 | /* Links status message must follow this format */ |
3643 | printk(KERN_INFO "igb: %s NIC Link is Up %d Mbps %s, " | 3641 | printk(KERN_INFO "igb: %s NIC Link is Up %d Mbps %s " |
3644 | "Flow Control: %s\n", | 3642 | "Duplex, Flow Control: %s\n", |
3645 | netdev->name, | 3643 | netdev->name, |
3646 | adapter->link_speed, | 3644 | adapter->link_speed, |
3647 | adapter->link_duplex == FULL_DUPLEX ? | 3645 | adapter->link_duplex == FULL_DUPLEX ? |
3648 | "Full Duplex" : "Half Duplex", | 3646 | "Full" : "Half", |
3649 | ((ctrl & E1000_CTRL_TFCE) && | 3647 | (ctrl & E1000_CTRL_TFCE) && |
3650 | (ctrl & E1000_CTRL_RFCE)) ? "RX/TX" : | 3648 | (ctrl & E1000_CTRL_RFCE) ? "RX/TX" : |
3651 | ((ctrl & E1000_CTRL_RFCE) ? "RX" : | 3649 | (ctrl & E1000_CTRL_RFCE) ? "RX" : |
3652 | ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None"))); | 3650 | (ctrl & E1000_CTRL_TFCE) ? "TX" : "None"); |
3653 | 3651 | ||
3654 | /* check for thermal sensor event */ | 3652 | /* check for thermal sensor event */ |
3655 | if (igb_thermal_sensor_event(hw, E1000_THSTAT_LINK_THROTTLE)) { | 3653 | if (igb_thermal_sensor_event(hw, |
3656 | printk(KERN_INFO "igb: %s The network adapter " | 3654 | E1000_THSTAT_LINK_THROTTLE)) { |
3657 | "link speed was downshifted " | 3655 | netdev_info(netdev, "The network adapter link " |
3658 | "because it overheated.\n", | 3656 | "speed was downshifted because it " |
3659 | netdev->name); | 3657 | "overheated\n"); |
3660 | } | 3658 | } |
3661 | 3659 | ||
3662 | /* adjust timeout factor according to speed/duplex */ | 3660 | /* adjust timeout factor according to speed/duplex */ |
@@ -3686,11 +3684,10 @@ static void igb_watchdog_task(struct work_struct *work) | |||
3686 | adapter->link_duplex = 0; | 3684 | adapter->link_duplex = 0; |
3687 | 3685 | ||
3688 | /* check for thermal sensor event */ | 3686 | /* check for thermal sensor event */ |
3689 | if (igb_thermal_sensor_event(hw, E1000_THSTAT_PWR_DOWN)) { | 3687 | if (igb_thermal_sensor_event(hw, |
3690 | printk(KERN_ERR "igb: %s The network adapter " | 3688 | E1000_THSTAT_PWR_DOWN)) { |
3691 | "was stopped because it " | 3689 | netdev_err(netdev, "The network adapter was " |
3692 | "overheated.\n", | 3690 | "stopped because it overheated\n"); |
3693 | netdev->name); | ||
3694 | } | 3691 | } |
3695 | 3692 | ||
3696 | /* Links status message must follow this format */ | 3693 | /* Links status message must follow this format */ |
@@ -6467,7 +6464,7 @@ s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) | |||
6467 | return 0; | 6464 | return 0; |
6468 | } | 6465 | } |
6469 | 6466 | ||
6470 | static void igb_vlan_mode(struct net_device *netdev, u32 features) | 6467 | static void igb_vlan_mode(struct net_device *netdev, netdev_features_t features) |
6471 | { | 6468 | { |
6472 | struct igb_adapter *adapter = netdev_priv(netdev); | 6469 | struct igb_adapter *adapter = netdev_priv(netdev); |
6473 | struct e1000_hw *hw = &adapter->hw; | 6470 | struct e1000_hw *hw = &adapter->hw; |
diff --git a/drivers/net/ethernet/intel/igbvf/ethtool.c b/drivers/net/ethernet/intel/igbvf/ethtool.c index 2c25858cc0ff..e60f1c6957af 100644 --- a/drivers/net/ethernet/intel/igbvf/ethtool.c +++ b/drivers/net/ethernet/intel/igbvf/ethtool.c | |||
@@ -191,12 +191,14 @@ static void igbvf_get_drvinfo(struct net_device *netdev, | |||
191 | struct ethtool_drvinfo *drvinfo) | 191 | struct ethtool_drvinfo *drvinfo) |
192 | { | 192 | { |
193 | struct igbvf_adapter *adapter = netdev_priv(netdev); | 193 | struct igbvf_adapter *adapter = netdev_priv(netdev); |
194 | char firmware_version[32] = "N/A"; | ||
195 | 194 | ||
196 | strncpy(drvinfo->driver, igbvf_driver_name, 32); | 195 | strlcpy(drvinfo->driver, igbvf_driver_name, sizeof(drvinfo->driver)); |
197 | strncpy(drvinfo->version, igbvf_driver_version, 32); | 196 | strlcpy(drvinfo->version, igbvf_driver_version, |
198 | strncpy(drvinfo->fw_version, firmware_version, 32); | 197 | sizeof(drvinfo->version)); |
199 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | 198 | strlcpy(drvinfo->fw_version, "N/A", |
199 | sizeof(drvinfo->fw_version)); | ||
200 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
201 | sizeof(drvinfo->bus_info)); | ||
200 | drvinfo->regdump_len = igbvf_get_regs_len(netdev); | 202 | drvinfo->regdump_len = igbvf_get_regs_len(netdev); |
201 | drvinfo->eedump_len = igbvf_get_eeprom_len(netdev); | 203 | drvinfo->eedump_len = igbvf_get_eeprom_len(netdev); |
202 | } | 204 | } |
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index cca78124be31..c358973ce414 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c | |||
@@ -25,6 +25,8 @@ | |||
25 | 25 | ||
26 | *******************************************************************************/ | 26 | *******************************************************************************/ |
27 | 27 | ||
28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
29 | |||
28 | #include <linux/module.h> | 30 | #include <linux/module.h> |
29 | #include <linux/types.h> | 31 | #include <linux/types.h> |
30 | #include <linux/init.h> | 32 | #include <linux/init.h> |
@@ -1746,10 +1748,9 @@ void igbvf_update_stats(struct igbvf_adapter *adapter) | |||
1746 | 1748 | ||
1747 | static void igbvf_print_link_info(struct igbvf_adapter *adapter) | 1749 | static void igbvf_print_link_info(struct igbvf_adapter *adapter) |
1748 | { | 1750 | { |
1749 | dev_info(&adapter->pdev->dev, "Link is Up %d Mbps %s\n", | 1751 | dev_info(&adapter->pdev->dev, "Link is Up %d Mbps %s Duplex\n", |
1750 | adapter->link_speed, | 1752 | adapter->link_speed, |
1751 | ((adapter->link_duplex == FULL_DUPLEX) ? | 1753 | adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half"); |
1752 | "Full Duplex" : "Half Duplex")); | ||
1753 | } | 1754 | } |
1754 | 1755 | ||
1755 | static bool igbvf_has_link(struct igbvf_adapter *adapter) | 1756 | static bool igbvf_has_link(struct igbvf_adapter *adapter) |
@@ -2532,7 +2533,8 @@ static void igbvf_print_device_info(struct igbvf_adapter *adapter) | |||
2532 | dev_info(&pdev->dev, "Address: %pM\n", netdev->dev_addr); | 2533 | dev_info(&pdev->dev, "Address: %pM\n", netdev->dev_addr); |
2533 | } | 2534 | } |
2534 | 2535 | ||
2535 | static int igbvf_set_features(struct net_device *netdev, u32 features) | 2536 | static int igbvf_set_features(struct net_device *netdev, |
2537 | netdev_features_t features) | ||
2536 | { | 2538 | { |
2537 | struct igbvf_adapter *adapter = netdev_priv(netdev); | 2539 | struct igbvf_adapter *adapter = netdev_priv(netdev); |
2538 | 2540 | ||
@@ -2842,9 +2844,8 @@ static struct pci_driver igbvf_driver = { | |||
2842 | static int __init igbvf_init_module(void) | 2844 | static int __init igbvf_init_module(void) |
2843 | { | 2845 | { |
2844 | int ret; | 2846 | int ret; |
2845 | printk(KERN_INFO "%s - version %s\n", | 2847 | pr_info("%s - version %s\n", igbvf_driver_string, igbvf_driver_version); |
2846 | igbvf_driver_string, igbvf_driver_version); | 2848 | pr_info("%s\n", igbvf_copyright); |
2847 | printk(KERN_INFO "%s\n", igbvf_copyright); | ||
2848 | 2849 | ||
2849 | ret = pci_register_driver(&igbvf_driver); | 2850 | ret = pci_register_driver(&igbvf_driver); |
2850 | 2851 | ||
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c index 9dfce7dff79b..96fcb0e06450 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c | |||
@@ -473,10 +473,13 @@ ixgb_get_drvinfo(struct net_device *netdev, | |||
473 | { | 473 | { |
474 | struct ixgb_adapter *adapter = netdev_priv(netdev); | 474 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
475 | 475 | ||
476 | strncpy(drvinfo->driver, ixgb_driver_name, 32); | 476 | strlcpy(drvinfo->driver, ixgb_driver_name, |
477 | strncpy(drvinfo->version, ixgb_driver_version, 32); | 477 | sizeof(drvinfo->driver)); |
478 | strncpy(drvinfo->fw_version, "N/A", 32); | 478 | strlcpy(drvinfo->version, ixgb_driver_version, |
479 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | 479 | sizeof(drvinfo->version)); |
480 | strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); | ||
481 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
482 | sizeof(drvinfo->bus_info)); | ||
480 | drvinfo->n_stats = IXGB_STATS_LEN; | 483 | drvinfo->n_stats = IXGB_STATS_LEN; |
481 | drvinfo->regdump_len = ixgb_get_regs_len(netdev); | 484 | drvinfo->regdump_len = ixgb_get_regs_len(netdev); |
482 | drvinfo->eedump_len = ixgb_get_eeprom_len(netdev); | 485 | drvinfo->eedump_len = ixgb_get_eeprom_len(netdev); |
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index e21148f8b160..247cf9219e03 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c | |||
@@ -325,8 +325,8 @@ ixgb_reset(struct ixgb_adapter *adapter) | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | static u32 | 328 | static netdev_features_t |
329 | ixgb_fix_features(struct net_device *netdev, u32 features) | 329 | ixgb_fix_features(struct net_device *netdev, netdev_features_t features) |
330 | { | 330 | { |
331 | /* | 331 | /* |
332 | * Tx VLAN insertion does not work per HW design when Rx stripping is | 332 | * Tx VLAN insertion does not work per HW design when Rx stripping is |
@@ -339,10 +339,10 @@ ixgb_fix_features(struct net_device *netdev, u32 features) | |||
339 | } | 339 | } |
340 | 340 | ||
341 | static int | 341 | static int |
342 | ixgb_set_features(struct net_device *netdev, u32 features) | 342 | ixgb_set_features(struct net_device *netdev, netdev_features_t features) |
343 | { | 343 | { |
344 | struct ixgb_adapter *adapter = netdev_priv(netdev); | 344 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
345 | u32 changed = features ^ netdev->features; | 345 | netdev_features_t changed = features ^ netdev->features; |
346 | 346 | ||
347 | if (!(changed & (NETIF_F_RXCSUM|NETIF_F_HW_VLAN_RX))) | 347 | if (!(changed & (NETIF_F_RXCSUM|NETIF_F_HW_VLAN_RX))) |
348 | return 0; | 348 | return 0; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 70d58c3849b0..91f871b6b3ba 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | |||
@@ -888,23 +888,19 @@ static void ixgbe_get_drvinfo(struct net_device *netdev, | |||
888 | struct ethtool_drvinfo *drvinfo) | 888 | struct ethtool_drvinfo *drvinfo) |
889 | { | 889 | { |
890 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 890 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
891 | char firmware_version[32]; | ||
892 | u32 nvm_track_id; | 891 | u32 nvm_track_id; |
893 | 892 | ||
894 | strncpy(drvinfo->driver, ixgbe_driver_name, | 893 | strlcpy(drvinfo->driver, ixgbe_driver_name, sizeof(drvinfo->driver)); |
895 | sizeof(drvinfo->driver) - 1); | 894 | strlcpy(drvinfo->version, ixgbe_driver_version, |
896 | strncpy(drvinfo->version, ixgbe_driver_version, | 895 | sizeof(drvinfo->version)); |
897 | sizeof(drvinfo->version) - 1); | ||
898 | 896 | ||
899 | nvm_track_id = (adapter->eeprom_verh << 16) | | 897 | nvm_track_id = (adapter->eeprom_verh << 16) | |
900 | adapter->eeprom_verl; | 898 | adapter->eeprom_verl; |
901 | snprintf(firmware_version, sizeof(firmware_version), "0x%08x", | 899 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "0x%08x", |
902 | nvm_track_id); | 900 | nvm_track_id); |
903 | 901 | ||
904 | strncpy(drvinfo->fw_version, firmware_version, | 902 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
905 | sizeof(drvinfo->fw_version) - 1); | 903 | sizeof(drvinfo->bus_info)); |
906 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), | ||
907 | sizeof(drvinfo->bus_info) - 1); | ||
908 | drvinfo->n_stats = IXGBE_STATS_LEN; | 904 | drvinfo->n_stats = IXGBE_STATS_LEN; |
909 | drvinfo->testinfo_len = IXGBE_TEST_LEN; | 905 | drvinfo->testinfo_len = IXGBE_TEST_LEN; |
910 | drvinfo->regdump_len = ixgbe_get_regs_len(netdev); | 906 | drvinfo->regdump_len = ixgbe_get_regs_len(netdev); |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 8ef92d1a6aa1..820fc040c241 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
@@ -7174,7 +7174,8 @@ void ixgbe_do_reset(struct net_device *netdev) | |||
7174 | ixgbe_reset(adapter); | 7174 | ixgbe_reset(adapter); |
7175 | } | 7175 | } |
7176 | 7176 | ||
7177 | static u32 ixgbe_fix_features(struct net_device *netdev, u32 data) | 7177 | static netdev_features_t ixgbe_fix_features(struct net_device *netdev, |
7178 | netdev_features_t data) | ||
7178 | { | 7179 | { |
7179 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 7180 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
7180 | 7181 | ||
@@ -7204,7 +7205,8 @@ static u32 ixgbe_fix_features(struct net_device *netdev, u32 data) | |||
7204 | return data; | 7205 | return data; |
7205 | } | 7206 | } |
7206 | 7207 | ||
7207 | static int ixgbe_set_features(struct net_device *netdev, u32 data) | 7208 | static int ixgbe_set_features(struct net_device *netdev, |
7209 | netdev_features_t data) | ||
7208 | { | 7210 | { |
7209 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 7211 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
7210 | bool need_reset = false; | 7212 | bool need_reset = false; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c index 00fcd39ad666..cf6812dd1436 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | |||
@@ -572,7 +572,7 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf) | |||
572 | 572 | ||
573 | /* reply to reset with ack and vf mac address */ | 573 | /* reply to reset with ack and vf mac address */ |
574 | msgbuf[0] = IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK; | 574 | msgbuf[0] = IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK; |
575 | memcpy(new_mac, vf_mac, IXGBE_ETH_LENGTH_OF_ADDRESS); | 575 | memcpy(new_mac, vf_mac, ETH_ALEN); |
576 | /* | 576 | /* |
577 | * Piggyback the multicast filter type so VF can compute the | 577 | * Piggyback the multicast filter type so VF can compute the |
578 | * correct vectors | 578 | * correct vectors |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h index 6c5cca808bd7..242643a69b3f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | |||
@@ -1710,8 +1710,6 @@ enum { | |||
1710 | #define IXGBE_NVM_POLL_WRITE 1 /* Flag for polling for write complete */ | 1710 | #define IXGBE_NVM_POLL_WRITE 1 /* Flag for polling for write complete */ |
1711 | #define IXGBE_NVM_POLL_READ 0 /* Flag for polling for read complete */ | 1711 | #define IXGBE_NVM_POLL_READ 0 /* Flag for polling for read complete */ |
1712 | 1712 | ||
1713 | #define IXGBE_ETH_LENGTH_OF_ADDRESS 6 | ||
1714 | |||
1715 | #define IXGBE_EEPROM_PAGE_SIZE_MAX 128 | 1713 | #define IXGBE_EEPROM_PAGE_SIZE_MAX 128 |
1716 | #define IXGBE_EEPROM_RD_BUFFER_MAX_COUNT 512 /* EEPROM words # read in burst */ | 1714 | #define IXGBE_EEPROM_RD_BUFFER_MAX_COUNT 512 /* EEPROM words # read in burst */ |
1717 | #define IXGBE_EEPROM_WR_BUFFER_MAX_COUNT 256 /* EEPROM words # wr in burst */ | 1715 | #define IXGBE_EEPROM_WR_BUFFER_MAX_COUNT 256 /* EEPROM words # wr in burst */ |
@@ -2802,9 +2800,9 @@ struct ixgbe_eeprom_info { | |||
2802 | struct ixgbe_mac_info { | 2800 | struct ixgbe_mac_info { |
2803 | struct ixgbe_mac_operations ops; | 2801 | struct ixgbe_mac_operations ops; |
2804 | enum ixgbe_mac_type type; | 2802 | enum ixgbe_mac_type type; |
2805 | u8 addr[IXGBE_ETH_LENGTH_OF_ADDRESS]; | 2803 | u8 addr[ETH_ALEN]; |
2806 | u8 perm_addr[IXGBE_ETH_LENGTH_OF_ADDRESS]; | 2804 | u8 perm_addr[ETH_ALEN]; |
2807 | u8 san_addr[IXGBE_ETH_LENGTH_OF_ADDRESS]; | 2805 | u8 san_addr[ETH_ALEN]; |
2808 | /* prefix for World Wide Node Name (WWNN) */ | 2806 | /* prefix for World Wide Node Name (WWNN) */ |
2809 | u16 wwnn_prefix; | 2807 | u16 wwnn_prefix; |
2810 | /* prefix for World Wide Port Name (WWPN) */ | 2808 | /* prefix for World Wide Port Name (WWPN) */ |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c index e5101e91b6b5..8cc5eccfd651 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c | |||
@@ -751,16 +751,20 @@ static s32 ixgbe_blink_led_start_X540(struct ixgbe_hw *hw, u32 index) | |||
751 | { | 751 | { |
752 | u32 macc_reg; | 752 | u32 macc_reg; |
753 | u32 ledctl_reg; | 753 | u32 ledctl_reg; |
754 | ixgbe_link_speed speed; | ||
755 | bool link_up; | ||
754 | 756 | ||
755 | /* | 757 | /* |
756 | * In order for the blink bit in the LED control register | 758 | * Link should be up in order for the blink bit in the LED control |
757 | * to work, link and speed must be forced in the MAC. We | 759 | * register to work. Force link and speed in the MAC if link is down. |
758 | * will reverse this when we stop the blinking. | 760 | * This will be reversed when we stop the blinking. |
759 | */ | 761 | */ |
760 | macc_reg = IXGBE_READ_REG(hw, IXGBE_MACC); | 762 | hw->mac.ops.check_link(hw, &speed, &link_up, false); |
761 | macc_reg |= IXGBE_MACC_FLU | IXGBE_MACC_FSV_10G | IXGBE_MACC_FS; | 763 | if (link_up == false) { |
762 | IXGBE_WRITE_REG(hw, IXGBE_MACC, macc_reg); | 764 | macc_reg = IXGBE_READ_REG(hw, IXGBE_MACC); |
763 | 765 | macc_reg |= IXGBE_MACC_FLU | IXGBE_MACC_FSV_10G | IXGBE_MACC_FS; | |
766 | IXGBE_WRITE_REG(hw, IXGBE_MACC, macc_reg); | ||
767 | } | ||
764 | /* Set the LED to LINK_UP + BLINK. */ | 768 | /* Set the LED to LINK_UP + BLINK. */ |
765 | ledctl_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); | 769 | ledctl_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); |
766 | ledctl_reg &= ~IXGBE_LED_MODE_MASK(index); | 770 | ledctl_reg &= ~IXGBE_LED_MODE_MASK(index); |
diff --git a/drivers/net/ethernet/intel/ixgbevf/defines.h b/drivers/net/ethernet/intel/ixgbevf/defines.h index 78abb6f1a866..2eb89cb94a0d 100644 --- a/drivers/net/ethernet/intel/ixgbevf/defines.h +++ b/drivers/net/ethernet/intel/ixgbevf/defines.h | |||
@@ -35,7 +35,6 @@ | |||
35 | #define IXGBE_VF_IRQ_CLEAR_MASK 7 | 35 | #define IXGBE_VF_IRQ_CLEAR_MASK 7 |
36 | #define IXGBE_VF_MAX_TX_QUEUES 1 | 36 | #define IXGBE_VF_MAX_TX_QUEUES 1 |
37 | #define IXGBE_VF_MAX_RX_QUEUES 1 | 37 | #define IXGBE_VF_MAX_RX_QUEUES 1 |
38 | #define IXGBE_ETH_LENGTH_OF_ADDRESS 6 | ||
39 | 38 | ||
40 | /* Link speed */ | 39 | /* Link speed */ |
41 | typedef u32 ixgbe_link_speed; | 40 | typedef u32 ixgbe_link_speed; |
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c index e29ba4506b74..149fa520d7f2 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | /* ethtool support for ixgbevf */ | 28 | /* ethtool support for ixgbevf */ |
29 | 29 | ||
30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
31 | |||
30 | #include <linux/types.h> | 32 | #include <linux/types.h> |
31 | #include <linux/module.h> | 33 | #include <linux/module.h> |
32 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
@@ -549,8 +551,8 @@ static const u32 register_test_patterns[] = { | |||
549 | writel((W & M), (adapter->hw.hw_addr + R)); \ | 551 | writel((W & M), (adapter->hw.hw_addr + R)); \ |
550 | val = readl(adapter->hw.hw_addr + R); \ | 552 | val = readl(adapter->hw.hw_addr + R); \ |
551 | if ((W & M) != (val & M)) { \ | 553 | if ((W & M) != (val & M)) { \ |
552 | printk(KERN_ERR "set/check reg %04X test failed: got 0x%08X " \ | 554 | pr_err("set/check reg %04X test failed: got 0x%08X expected " \ |
553 | "expected 0x%08X\n", R, (val & M), (W & M)); \ | 555 | "0x%08X\n", R, (val & M), (W & M)); \ |
554 | *data = R; \ | 556 | *data = R; \ |
555 | writel(before, (adapter->hw.hw_addr + R)); \ | 557 | writel(before, (adapter->hw.hw_addr + R)); \ |
556 | return 1; \ | 558 | return 1; \ |
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index 4c8e19951d57..0c39bb1ac3bb 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | |||
@@ -29,6 +29,9 @@ | |||
29 | /****************************************************************************** | 29 | /****************************************************************************** |
30 | Copyright (c)2006 - 2007 Myricom, Inc. for some LRO specific code | 30 | Copyright (c)2006 - 2007 Myricom, Inc. for some LRO specific code |
31 | ******************************************************************************/ | 31 | ******************************************************************************/ |
32 | |||
33 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
34 | |||
32 | #include <linux/types.h> | 35 | #include <linux/types.h> |
33 | #include <linux/bitops.h> | 36 | #include <linux/bitops.h> |
34 | #include <linux/module.h> | 37 | #include <linux/module.h> |
@@ -1437,7 +1440,7 @@ static int ixgbevf_write_uc_addr_list(struct net_device *netdev) | |||
1437 | int count = 0; | 1440 | int count = 0; |
1438 | 1441 | ||
1439 | if ((netdev_uc_count(netdev)) > 10) { | 1442 | if ((netdev_uc_count(netdev)) > 10) { |
1440 | printk(KERN_ERR "Too many unicast filters - No Space\n"); | 1443 | pr_err("Too many unicast filters - No Space\n"); |
1441 | return -ENOSPC; | 1444 | return -ENOSPC; |
1442 | } | 1445 | } |
1443 | 1446 | ||
@@ -2135,7 +2138,7 @@ static int ixgbevf_init_interrupt_scheme(struct ixgbevf_adapter *adapter) | |||
2135 | 2138 | ||
2136 | err = ixgbevf_alloc_queues(adapter); | 2139 | err = ixgbevf_alloc_queues(adapter); |
2137 | if (err) { | 2140 | if (err) { |
2138 | printk(KERN_ERR "Unable to allocate memory for queues\n"); | 2141 | pr_err("Unable to allocate memory for queues\n"); |
2139 | goto err_alloc_queues; | 2142 | goto err_alloc_queues; |
2140 | } | 2143 | } |
2141 | 2144 | ||
@@ -2189,7 +2192,7 @@ static int __devinit ixgbevf_sw_init(struct ixgbevf_adapter *adapter) | |||
2189 | } else { | 2192 | } else { |
2190 | err = hw->mac.ops.init_hw(hw); | 2193 | err = hw->mac.ops.init_hw(hw); |
2191 | if (err) { | 2194 | if (err) { |
2192 | printk(KERN_ERR "init_shared_code failed: %d\n", err); | 2195 | pr_err("init_shared_code failed: %d\n", err); |
2193 | goto out; | 2196 | goto out; |
2194 | } | 2197 | } |
2195 | } | 2198 | } |
@@ -2630,8 +2633,8 @@ static int ixgbevf_open(struct net_device *netdev) | |||
2630 | * the vf can't start. */ | 2633 | * the vf can't start. */ |
2631 | if (hw->adapter_stopped) { | 2634 | if (hw->adapter_stopped) { |
2632 | err = IXGBE_ERR_MBX; | 2635 | err = IXGBE_ERR_MBX; |
2633 | printk(KERN_ERR "Unable to start - perhaps the PF" | 2636 | pr_err("Unable to start - perhaps the PF Driver isn't " |
2634 | " Driver isn't up yet\n"); | 2637 | "up yet\n"); |
2635 | goto err_setup_reset; | 2638 | goto err_setup_reset; |
2636 | } | 2639 | } |
2637 | } | 2640 | } |
@@ -2842,10 +2845,8 @@ static bool ixgbevf_tx_csum(struct ixgbevf_adapter *adapter, | |||
2842 | break; | 2845 | break; |
2843 | default: | 2846 | default: |
2844 | if (unlikely(net_ratelimit())) { | 2847 | if (unlikely(net_ratelimit())) { |
2845 | printk(KERN_WARNING | 2848 | pr_warn("partial checksum but " |
2846 | "partial checksum but " | 2849 | "proto=%x!\n", skb->protocol); |
2847 | "proto=%x!\n", | ||
2848 | skb->protocol); | ||
2849 | } | 2850 | } |
2850 | break; | 2851 | break; |
2851 | } | 2852 | } |
@@ -3249,7 +3250,8 @@ static struct rtnl_link_stats64 *ixgbevf_get_stats(struct net_device *netdev, | |||
3249 | return stats; | 3250 | return stats; |
3250 | } | 3251 | } |
3251 | 3252 | ||
3252 | static int ixgbevf_set_features(struct net_device *netdev, u32 features) | 3253 | static int ixgbevf_set_features(struct net_device *netdev, |
3254 | netdev_features_t features) | ||
3253 | { | 3255 | { |
3254 | struct ixgbevf_adapter *adapter = netdev_priv(netdev); | 3256 | struct ixgbevf_adapter *adapter = netdev_priv(netdev); |
3255 | 3257 | ||
@@ -3414,7 +3416,7 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev, | |||
3414 | memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); | 3416 | memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); |
3415 | 3417 | ||
3416 | if (!is_valid_ether_addr(netdev->dev_addr)) { | 3418 | if (!is_valid_ether_addr(netdev->dev_addr)) { |
3417 | printk(KERN_ERR "invalid MAC address\n"); | 3419 | pr_err("invalid MAC address\n"); |
3418 | err = -EIO; | 3420 | err = -EIO; |
3419 | goto err_sw_init; | 3421 | goto err_sw_init; |
3420 | } | 3422 | } |
@@ -3535,10 +3537,10 @@ static struct pci_driver ixgbevf_driver = { | |||
3535 | static int __init ixgbevf_init_module(void) | 3537 | static int __init ixgbevf_init_module(void) |
3536 | { | 3538 | { |
3537 | int ret; | 3539 | int ret; |
3538 | printk(KERN_INFO "ixgbevf: %s - version %s\n", ixgbevf_driver_string, | 3540 | pr_info("%s - version %s\n", ixgbevf_driver_string, |
3539 | ixgbevf_driver_version); | 3541 | ixgbevf_driver_version); |
3540 | 3542 | ||
3541 | printk(KERN_INFO "%s\n", ixgbevf_copyright); | 3543 | pr_info("%s\n", ixgbevf_copyright); |
3542 | 3544 | ||
3543 | ret = pci_register_driver(&ixgbevf_driver); | 3545 | ret = pci_register_driver(&ixgbevf_driver); |
3544 | return ret; | 3546 | return ret; |
diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.c b/drivers/net/ethernet/intel/ixgbevf/vf.c index aa3682e8c473..21533e300367 100644 --- a/drivers/net/ethernet/intel/ixgbevf/vf.c +++ b/drivers/net/ethernet/intel/ixgbevf/vf.c | |||
@@ -108,7 +108,7 @@ static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw) | |||
108 | if (msgbuf[0] != (IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK)) | 108 | if (msgbuf[0] != (IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK)) |
109 | return IXGBE_ERR_INVALID_MAC_ADDR; | 109 | return IXGBE_ERR_INVALID_MAC_ADDR; |
110 | 110 | ||
111 | memcpy(hw->mac.perm_addr, addr, IXGBE_ETH_LENGTH_OF_ADDRESS); | 111 | memcpy(hw->mac.perm_addr, addr, ETH_ALEN); |
112 | hw->mac.mc_filter_type = msgbuf[IXGBE_VF_MC_TYPE_WORD]; | 112 | hw->mac.mc_filter_type = msgbuf[IXGBE_VF_MC_TYPE_WORD]; |
113 | 113 | ||
114 | return 0; | 114 | return 0; |
@@ -211,7 +211,7 @@ static s32 ixgbevf_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr) | |||
211 | **/ | 211 | **/ |
212 | static s32 ixgbevf_get_mac_addr_vf(struct ixgbe_hw *hw, u8 *mac_addr) | 212 | static s32 ixgbevf_get_mac_addr_vf(struct ixgbe_hw *hw, u8 *mac_addr) |
213 | { | 213 | { |
214 | memcpy(mac_addr, hw->mac.perm_addr, IXGBE_ETH_LENGTH_OF_ADDRESS); | 214 | memcpy(mac_addr, hw->mac.perm_addr, ETH_ALEN); |
215 | 215 | ||
216 | return 0; | 216 | return 0; |
217 | } | 217 | } |
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 7becff1f387d..5c0b531949e2 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c | |||
@@ -1883,7 +1883,7 @@ jme_fill_tx_map(struct pci_dev *pdev, | |||
1883 | struct page *page, | 1883 | struct page *page, |
1884 | u32 page_offset, | 1884 | u32 page_offset, |
1885 | u32 len, | 1885 | u32 len, |
1886 | u8 hidma) | 1886 | bool hidma) |
1887 | { | 1887 | { |
1888 | dma_addr_t dmaaddr; | 1888 | dma_addr_t dmaaddr; |
1889 | 1889 | ||
@@ -1917,7 +1917,7 @@ jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx) | |||
1917 | struct jme_ring *txring = &(jme->txring[0]); | 1917 | struct jme_ring *txring = &(jme->txring[0]); |
1918 | struct txdesc *txdesc = txring->desc, *ctxdesc; | 1918 | struct txdesc *txdesc = txring->desc, *ctxdesc; |
1919 | struct jme_buffer_info *txbi = txring->bufinf, *ctxbi; | 1919 | struct jme_buffer_info *txbi = txring->bufinf, *ctxbi; |
1920 | u8 hidma = jme->dev->features & NETIF_F_HIGHDMA; | 1920 | bool hidma = jme->dev->features & NETIF_F_HIGHDMA; |
1921 | int i, nr_frags = skb_shinfo(skb)->nr_frags; | 1921 | int i, nr_frags = skb_shinfo(skb)->nr_frags; |
1922 | int mask = jme->tx_ring_mask; | 1922 | int mask = jme->tx_ring_mask; |
1923 | const struct skb_frag_struct *frag; | 1923 | const struct skb_frag_struct *frag; |
@@ -2292,9 +2292,9 @@ jme_get_drvinfo(struct net_device *netdev, | |||
2292 | { | 2292 | { |
2293 | struct jme_adapter *jme = netdev_priv(netdev); | 2293 | struct jme_adapter *jme = netdev_priv(netdev); |
2294 | 2294 | ||
2295 | strcpy(info->driver, DRV_NAME); | 2295 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
2296 | strcpy(info->version, DRV_VERSION); | 2296 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
2297 | strcpy(info->bus_info, pci_name(jme->pdev)); | 2297 | strlcpy(info->bus_info, pci_name(jme->pdev), sizeof(info->bus_info)); |
2298 | } | 2298 | } |
2299 | 2299 | ||
2300 | static int | 2300 | static int |
@@ -2620,8 +2620,8 @@ jme_set_msglevel(struct net_device *netdev, u32 value) | |||
2620 | jme->msg_enable = value; | 2620 | jme->msg_enable = value; |
2621 | } | 2621 | } |
2622 | 2622 | ||
2623 | static u32 | 2623 | static netdev_features_t |
2624 | jme_fix_features(struct net_device *netdev, u32 features) | 2624 | jme_fix_features(struct net_device *netdev, netdev_features_t features) |
2625 | { | 2625 | { |
2626 | if (netdev->mtu > 1900) | 2626 | if (netdev->mtu > 1900) |
2627 | features &= ~(NETIF_F_ALL_TSO | NETIF_F_ALL_CSUM); | 2627 | features &= ~(NETIF_F_ALL_TSO | NETIF_F_ALL_CSUM); |
@@ -2629,7 +2629,7 @@ jme_fix_features(struct net_device *netdev, u32 features) | |||
2629 | } | 2629 | } |
2630 | 2630 | ||
2631 | static int | 2631 | static int |
2632 | jme_set_features(struct net_device *netdev, u32 features) | 2632 | jme_set_features(struct net_device *netdev, netdev_features_t features) |
2633 | { | 2633 | { |
2634 | struct jme_adapter *jme = netdev_priv(netdev); | 2634 | struct jme_adapter *jme = netdev_priv(netdev); |
2635 | 2635 | ||
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 194a03113802..43e3e6102149 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c | |||
@@ -1502,10 +1502,11 @@ mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1502 | static void mv643xx_eth_get_drvinfo(struct net_device *dev, | 1502 | static void mv643xx_eth_get_drvinfo(struct net_device *dev, |
1503 | struct ethtool_drvinfo *drvinfo) | 1503 | struct ethtool_drvinfo *drvinfo) |
1504 | { | 1504 | { |
1505 | strncpy(drvinfo->driver, mv643xx_eth_driver_name, 32); | 1505 | strlcpy(drvinfo->driver, mv643xx_eth_driver_name, sizeof(info->driver)); |
1506 | strncpy(drvinfo->version, mv643xx_eth_driver_version, 32); | 1506 | strlcpy(drvinfo->version, mv643xx_eth_driver_version, |
1507 | strncpy(drvinfo->fw_version, "N/A", 32); | 1507 | sizeof(info->version)); |
1508 | strncpy(drvinfo->bus_info, "platform", 32); | 1508 | strlcpy(drvinfo->fw_version, "N/A", sizeof(info->fw_version)); |
1509 | strlcpy(drvinfo->bus_info, "platform", sizeof(info->bus_info)); | ||
1509 | drvinfo->n_stats = ARRAY_SIZE(mv643xx_eth_stats); | 1510 | drvinfo->n_stats = ARRAY_SIZE(mv643xx_eth_stats); |
1510 | } | 1511 | } |
1511 | 1512 | ||
@@ -1578,10 +1579,10 @@ mv643xx_eth_set_ringparam(struct net_device *dev, struct ethtool_ringparam *er) | |||
1578 | 1579 | ||
1579 | 1580 | ||
1580 | static int | 1581 | static int |
1581 | mv643xx_eth_set_features(struct net_device *dev, u32 features) | 1582 | mv643xx_eth_set_features(struct net_device *dev, netdev_features_t features) |
1582 | { | 1583 | { |
1583 | struct mv643xx_eth_private *mp = netdev_priv(dev); | 1584 | struct mv643xx_eth_private *mp = netdev_priv(dev); |
1584 | u32 rx_csum = features & NETIF_F_RXCSUM; | 1585 | bool rx_csum = features & NETIF_F_RXCSUM; |
1585 | 1586 | ||
1586 | wrlp(mp, PORT_CONFIG, rx_csum ? 0x02000000 : 0x00000000); | 1587 | wrlp(mp, PORT_CONFIG, rx_csum ? 0x02000000 : 0x00000000); |
1587 | 1588 | ||
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c index c7b60839ac99..3943f5f7bb4a 100644 --- a/drivers/net/ethernet/marvell/skge.c +++ b/drivers/net/ethernet/marvell/skge.c | |||
@@ -394,10 +394,11 @@ static void skge_get_drvinfo(struct net_device *dev, | |||
394 | { | 394 | { |
395 | struct skge_port *skge = netdev_priv(dev); | 395 | struct skge_port *skge = netdev_priv(dev); |
396 | 396 | ||
397 | strcpy(info->driver, DRV_NAME); | 397 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
398 | strcpy(info->version, DRV_VERSION); | 398 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
399 | strcpy(info->fw_version, "N/A"); | 399 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
400 | strcpy(info->bus_info, pci_name(skge->hw->pdev)); | 400 | strlcpy(info->bus_info, pci_name(skge->hw->pdev), |
401 | sizeof(info->bus_info)); | ||
401 | } | 402 | } |
402 | 403 | ||
403 | static const struct skge_stat { | 404 | static const struct skge_stat { |
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 7803efa46eb2..ca33908bc7f3 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c | |||
@@ -1284,7 +1284,7 @@ static const uint32_t rss_init_key[10] = { | |||
1284 | }; | 1284 | }; |
1285 | 1285 | ||
1286 | /* Enable/disable receive hash calculation (RSS) */ | 1286 | /* Enable/disable receive hash calculation (RSS) */ |
1287 | static void rx_set_rss(struct net_device *dev, u32 features) | 1287 | static void rx_set_rss(struct net_device *dev, netdev_features_t features) |
1288 | { | 1288 | { |
1289 | struct sky2_port *sky2 = netdev_priv(dev); | 1289 | struct sky2_port *sky2 = netdev_priv(dev); |
1290 | struct sky2_hw *hw = sky2->hw; | 1290 | struct sky2_hw *hw = sky2->hw; |
@@ -1402,7 +1402,7 @@ static int sky2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1402 | 1402 | ||
1403 | #define SKY2_VLAN_OFFLOADS (NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO) | 1403 | #define SKY2_VLAN_OFFLOADS (NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO) |
1404 | 1404 | ||
1405 | static void sky2_vlan_mode(struct net_device *dev, u32 features) | 1405 | static void sky2_vlan_mode(struct net_device *dev, netdev_features_t features) |
1406 | { | 1406 | { |
1407 | struct sky2_port *sky2 = netdev_priv(dev); | 1407 | struct sky2_port *sky2 = netdev_priv(dev); |
1408 | struct sky2_hw *hw = sky2->hw; | 1408 | struct sky2_hw *hw = sky2->hw; |
@@ -3643,10 +3643,11 @@ static void sky2_get_drvinfo(struct net_device *dev, | |||
3643 | { | 3643 | { |
3644 | struct sky2_port *sky2 = netdev_priv(dev); | 3644 | struct sky2_port *sky2 = netdev_priv(dev); |
3645 | 3645 | ||
3646 | strcpy(info->driver, DRV_NAME); | 3646 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
3647 | strcpy(info->version, DRV_VERSION); | 3647 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
3648 | strcpy(info->fw_version, "N/A"); | 3648 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
3649 | strcpy(info->bus_info, pci_name(sky2->hw->pdev)); | 3649 | strlcpy(info->bus_info, pci_name(sky2->hw->pdev), |
3650 | sizeof(info->bus_info)); | ||
3650 | } | 3651 | } |
3651 | 3652 | ||
3652 | static const struct sky2_stat { | 3653 | static const struct sky2_stat { |
@@ -4311,7 +4312,8 @@ static int sky2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom | |||
4311 | return sky2_vpd_write(sky2->hw, cap, data, eeprom->offset, eeprom->len); | 4312 | return sky2_vpd_write(sky2->hw, cap, data, eeprom->offset, eeprom->len); |
4312 | } | 4313 | } |
4313 | 4314 | ||
4314 | static u32 sky2_fix_features(struct net_device *dev, u32 features) | 4315 | static netdev_features_t sky2_fix_features(struct net_device *dev, |
4316 | netdev_features_t features) | ||
4315 | { | 4317 | { |
4316 | const struct sky2_port *sky2 = netdev_priv(dev); | 4318 | const struct sky2_port *sky2 = netdev_priv(dev); |
4317 | const struct sky2_hw *hw = sky2->hw; | 4319 | const struct sky2_hw *hw = sky2->hw; |
@@ -4335,13 +4337,13 @@ static u32 sky2_fix_features(struct net_device *dev, u32 features) | |||
4335 | return features; | 4337 | return features; |
4336 | } | 4338 | } |
4337 | 4339 | ||
4338 | static int sky2_set_features(struct net_device *dev, u32 features) | 4340 | static int sky2_set_features(struct net_device *dev, netdev_features_t features) |
4339 | { | 4341 | { |
4340 | struct sky2_port *sky2 = netdev_priv(dev); | 4342 | struct sky2_port *sky2 = netdev_priv(dev); |
4341 | u32 changed = dev->features ^ features; | 4343 | netdev_features_t changed = dev->features ^ features; |
4342 | 4344 | ||
4343 | if (changed & NETIF_F_RXCSUM) { | 4345 | if (changed & NETIF_F_RXCSUM) { |
4344 | u32 on = features & NETIF_F_RXCSUM; | 4346 | bool on = features & NETIF_F_RXCSUM; |
4345 | sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), | 4347 | sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), |
4346 | on ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); | 4348 | on ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); |
4347 | } | 4349 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 74e2a2a8a02b..ee637a200915 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | |||
@@ -45,13 +45,16 @@ mlx4_en_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
45 | struct mlx4_en_priv *priv = netdev_priv(dev); | 45 | struct mlx4_en_priv *priv = netdev_priv(dev); |
46 | struct mlx4_en_dev *mdev = priv->mdev; | 46 | struct mlx4_en_dev *mdev = priv->mdev; |
47 | 47 | ||
48 | strncpy(drvinfo->driver, DRV_NAME, 32); | 48 | strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); |
49 | strncpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", 32); | 49 | strlcpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", |
50 | sprintf(drvinfo->fw_version, "%d.%d.%d", | 50 | sizeof(drvinfo->version)); |
51 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), | ||
52 | "%d.%d.%d", | ||
51 | (u16) (mdev->dev->caps.fw_ver >> 32), | 53 | (u16) (mdev->dev->caps.fw_ver >> 32), |
52 | (u16) ((mdev->dev->caps.fw_ver >> 16) & 0xffff), | 54 | (u16) ((mdev->dev->caps.fw_ver >> 16) & 0xffff), |
53 | (u16) (mdev->dev->caps.fw_ver & 0xffff)); | 55 | (u16) (mdev->dev->caps.fw_ver & 0xffff)); |
54 | strncpy(drvinfo->bus_info, pci_name(mdev->dev->pdev), 32); | 56 | strlcpy(drvinfo->bus_info, pci_name(mdev->dev->pdev), |
57 | sizeof(drvinfo->bus_info)); | ||
55 | drvinfo->n_stats = 0; | 58 | drvinfo->n_stats = 0; |
56 | drvinfo->regdump_len = 0; | 59 | drvinfo->regdump_len = 0; |
57 | drvinfo->eedump_len = 0; | 60 | drvinfo->eedump_len = 0; |
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index 7ece990381c8..7abd510fe01f 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c | |||
@@ -743,8 +743,7 @@ | |||
743 | /* Change default LED mode. */ | 743 | /* Change default LED mode. */ |
744 | #define SET_DEFAULT_LED LED_SPEED_DUPLEX_ACT | 744 | #define SET_DEFAULT_LED LED_SPEED_DUPLEX_ACT |
745 | 745 | ||
746 | #define MAC_ADDR_LEN 6 | 746 | #define MAC_ADDR_ORDER(i) (ETH_ALEN - 1 - (i)) |
747 | #define MAC_ADDR_ORDER(i) (MAC_ADDR_LEN - 1 - (i)) | ||
748 | 747 | ||
749 | #define MAX_ETHERNET_BODY_SIZE 1500 | 748 | #define MAX_ETHERNET_BODY_SIZE 1500 |
750 | #define ETHERNET_HEADER_SIZE 14 | 749 | #define ETHERNET_HEADER_SIZE 14 |
@@ -1043,7 +1042,7 @@ enum { | |||
1043 | * @valid: Valid setting indicating the entry is being used. | 1042 | * @valid: Valid setting indicating the entry is being used. |
1044 | */ | 1043 | */ |
1045 | struct ksz_mac_table { | 1044 | struct ksz_mac_table { |
1046 | u8 mac_addr[MAC_ADDR_LEN]; | 1045 | u8 mac_addr[ETH_ALEN]; |
1047 | u16 vid; | 1046 | u16 vid; |
1048 | u8 fid; | 1047 | u8 fid; |
1049 | u8 ports; | 1048 | u8 ports; |
@@ -1187,8 +1186,8 @@ struct ksz_switch { | |||
1187 | u8 diffserv[DIFFSERV_ENTRIES]; | 1186 | u8 diffserv[DIFFSERV_ENTRIES]; |
1188 | u8 p_802_1p[PRIO_802_1P_ENTRIES]; | 1187 | u8 p_802_1p[PRIO_802_1P_ENTRIES]; |
1189 | 1188 | ||
1190 | u8 br_addr[MAC_ADDR_LEN]; | 1189 | u8 br_addr[ETH_ALEN]; |
1191 | u8 other_addr[MAC_ADDR_LEN]; | 1190 | u8 other_addr[ETH_ALEN]; |
1192 | 1191 | ||
1193 | u8 broad_per; | 1192 | u8 broad_per; |
1194 | u8 member; | 1193 | u8 member; |
@@ -1292,14 +1291,14 @@ struct ksz_hw { | |||
1292 | int tx_int_mask; | 1291 | int tx_int_mask; |
1293 | int tx_size; | 1292 | int tx_size; |
1294 | 1293 | ||
1295 | u8 perm_addr[MAC_ADDR_LEN]; | 1294 | u8 perm_addr[ETH_ALEN]; |
1296 | u8 override_addr[MAC_ADDR_LEN]; | 1295 | u8 override_addr[ETH_ALEN]; |
1297 | u8 address[ADDITIONAL_ENTRIES][MAC_ADDR_LEN]; | 1296 | u8 address[ADDITIONAL_ENTRIES][ETH_ALEN]; |
1298 | u8 addr_list_size; | 1297 | u8 addr_list_size; |
1299 | u8 mac_override; | 1298 | u8 mac_override; |
1300 | u8 promiscuous; | 1299 | u8 promiscuous; |
1301 | u8 all_multi; | 1300 | u8 all_multi; |
1302 | u8 multi_list[MAX_MULTICAST_LIST][MAC_ADDR_LEN]; | 1301 | u8 multi_list[MAX_MULTICAST_LIST][ETH_ALEN]; |
1303 | u8 multi_bits[HW_MULTICAST_SIZE]; | 1302 | u8 multi_bits[HW_MULTICAST_SIZE]; |
1304 | u8 multi_list_size; | 1303 | u8 multi_list_size; |
1305 | 1304 | ||
@@ -3654,7 +3653,7 @@ static void hw_add_wol_bcast(struct ksz_hw *hw) | |||
3654 | static const u8 mask[] = { 0x3F }; | 3653 | static const u8 mask[] = { 0x3F }; |
3655 | static const u8 pattern[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | 3654 | static const u8 pattern[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
3656 | 3655 | ||
3657 | hw_set_wol_frame(hw, 2, 1, mask, MAC_ADDR_LEN, pattern); | 3656 | hw_set_wol_frame(hw, 2, 1, mask, ETH_ALEN, pattern); |
3658 | } | 3657 | } |
3659 | 3658 | ||
3660 | /** | 3659 | /** |
@@ -3689,7 +3688,7 @@ static void hw_add_wol_ucast(struct ksz_hw *hw) | |||
3689 | { | 3688 | { |
3690 | static const u8 mask[] = { 0x3F }; | 3689 | static const u8 mask[] = { 0x3F }; |
3691 | 3690 | ||
3692 | hw_set_wol_frame(hw, 0, 1, mask, MAC_ADDR_LEN, hw->override_addr); | 3691 | hw_set_wol_frame(hw, 0, 1, mask, ETH_ALEN, hw->override_addr); |
3693 | } | 3692 | } |
3694 | 3693 | ||
3695 | /** | 3694 | /** |
@@ -4055,7 +4054,7 @@ static void hw_set_addr(struct ksz_hw *hw) | |||
4055 | { | 4054 | { |
4056 | int i; | 4055 | int i; |
4057 | 4056 | ||
4058 | for (i = 0; i < MAC_ADDR_LEN; i++) | 4057 | for (i = 0; i < ETH_ALEN; i++) |
4059 | writeb(hw->override_addr[MAC_ADDR_ORDER(i)], | 4058 | writeb(hw->override_addr[MAC_ADDR_ORDER(i)], |
4060 | hw->io + KS884X_ADDR_0_OFFSET + i); | 4059 | hw->io + KS884X_ADDR_0_OFFSET + i); |
4061 | 4060 | ||
@@ -4072,17 +4071,16 @@ static void hw_read_addr(struct ksz_hw *hw) | |||
4072 | { | 4071 | { |
4073 | int i; | 4072 | int i; |
4074 | 4073 | ||
4075 | for (i = 0; i < MAC_ADDR_LEN; i++) | 4074 | for (i = 0; i < ETH_ALEN; i++) |
4076 | hw->perm_addr[MAC_ADDR_ORDER(i)] = readb(hw->io + | 4075 | hw->perm_addr[MAC_ADDR_ORDER(i)] = readb(hw->io + |
4077 | KS884X_ADDR_0_OFFSET + i); | 4076 | KS884X_ADDR_0_OFFSET + i); |
4078 | 4077 | ||
4079 | if (!hw->mac_override) { | 4078 | if (!hw->mac_override) { |
4080 | memcpy(hw->override_addr, hw->perm_addr, MAC_ADDR_LEN); | 4079 | memcpy(hw->override_addr, hw->perm_addr, ETH_ALEN); |
4081 | if (empty_addr(hw->override_addr)) { | 4080 | if (empty_addr(hw->override_addr)) { |
4082 | memcpy(hw->perm_addr, DEFAULT_MAC_ADDRESS, | 4081 | memcpy(hw->perm_addr, DEFAULT_MAC_ADDRESS, ETH_ALEN); |
4083 | MAC_ADDR_LEN); | ||
4084 | memcpy(hw->override_addr, DEFAULT_MAC_ADDRESS, | 4082 | memcpy(hw->override_addr, DEFAULT_MAC_ADDRESS, |
4085 | MAC_ADDR_LEN); | 4083 | ETH_ALEN); |
4086 | hw->override_addr[5] += hw->id; | 4084 | hw->override_addr[5] += hw->id; |
4087 | hw_set_addr(hw); | 4085 | hw_set_addr(hw); |
4088 | } | 4086 | } |
@@ -4130,16 +4128,16 @@ static int hw_add_addr(struct ksz_hw *hw, u8 *mac_addr) | |||
4130 | int i; | 4128 | int i; |
4131 | int j = ADDITIONAL_ENTRIES; | 4129 | int j = ADDITIONAL_ENTRIES; |
4132 | 4130 | ||
4133 | if (!memcmp(hw->override_addr, mac_addr, MAC_ADDR_LEN)) | 4131 | if (!memcmp(hw->override_addr, mac_addr, ETH_ALEN)) |
4134 | return 0; | 4132 | return 0; |
4135 | for (i = 0; i < hw->addr_list_size; i++) { | 4133 | for (i = 0; i < hw->addr_list_size; i++) { |
4136 | if (!memcmp(hw->address[i], mac_addr, MAC_ADDR_LEN)) | 4134 | if (!memcmp(hw->address[i], mac_addr, ETH_ALEN)) |
4137 | return 0; | 4135 | return 0; |
4138 | if (ADDITIONAL_ENTRIES == j && empty_addr(hw->address[i])) | 4136 | if (ADDITIONAL_ENTRIES == j && empty_addr(hw->address[i])) |
4139 | j = i; | 4137 | j = i; |
4140 | } | 4138 | } |
4141 | if (j < ADDITIONAL_ENTRIES) { | 4139 | if (j < ADDITIONAL_ENTRIES) { |
4142 | memcpy(hw->address[j], mac_addr, MAC_ADDR_LEN); | 4140 | memcpy(hw->address[j], mac_addr, ETH_ALEN); |
4143 | hw_ena_add_addr(hw, j, hw->address[j]); | 4141 | hw_ena_add_addr(hw, j, hw->address[j]); |
4144 | return 0; | 4142 | return 0; |
4145 | } | 4143 | } |
@@ -4151,8 +4149,8 @@ static int hw_del_addr(struct ksz_hw *hw, u8 *mac_addr) | |||
4151 | int i; | 4149 | int i; |
4152 | 4150 | ||
4153 | for (i = 0; i < hw->addr_list_size; i++) { | 4151 | for (i = 0; i < hw->addr_list_size; i++) { |
4154 | if (!memcmp(hw->address[i], mac_addr, MAC_ADDR_LEN)) { | 4152 | if (!memcmp(hw->address[i], mac_addr, ETH_ALEN)) { |
4155 | memset(hw->address[i], 0, MAC_ADDR_LEN); | 4153 | memset(hw->address[i], 0, ETH_ALEN); |
4156 | writel(0, hw->io + ADD_ADDR_INCR * i + | 4154 | writel(0, hw->io + ADD_ADDR_INCR * i + |
4157 | KS_ADD_ADDR_0_HI); | 4155 | KS_ADD_ADDR_0_HI); |
4158 | return 0; | 4156 | return 0; |
@@ -5676,7 +5674,7 @@ static int netdev_set_mac_address(struct net_device *dev, void *addr) | |||
5676 | hw_del_addr(hw, dev->dev_addr); | 5674 | hw_del_addr(hw, dev->dev_addr); |
5677 | else { | 5675 | else { |
5678 | hw->mac_override = 1; | 5676 | hw->mac_override = 1; |
5679 | memcpy(hw->override_addr, mac->sa_data, MAC_ADDR_LEN); | 5677 | memcpy(hw->override_addr, mac->sa_data, ETH_ALEN); |
5680 | } | 5678 | } |
5681 | 5679 | ||
5682 | memcpy(dev->dev_addr, mac->sa_data, MAX_ADDR_LEN); | 5680 | memcpy(dev->dev_addr, mac->sa_data, MAX_ADDR_LEN); |
@@ -5786,7 +5784,7 @@ static void netdev_set_rx_mode(struct net_device *dev) | |||
5786 | netdev_for_each_mc_addr(ha, dev) { | 5784 | netdev_for_each_mc_addr(ha, dev) { |
5787 | if (i >= MAX_MULTICAST_LIST) | 5785 | if (i >= MAX_MULTICAST_LIST) |
5788 | break; | 5786 | break; |
5789 | memcpy(hw->multi_list[i++], ha->addr, MAC_ADDR_LEN); | 5787 | memcpy(hw->multi_list[i++], ha->addr, ETH_ALEN); |
5790 | } | 5788 | } |
5791 | hw->multi_list_size = (u8) i; | 5789 | hw->multi_list_size = (u8) i; |
5792 | hw_set_grp_addr(hw); | 5790 | hw_set_grp_addr(hw); |
@@ -6093,9 +6091,10 @@ static void netdev_get_drvinfo(struct net_device *dev, | |||
6093 | struct dev_priv *priv = netdev_priv(dev); | 6091 | struct dev_priv *priv = netdev_priv(dev); |
6094 | struct dev_info *hw_priv = priv->adapter; | 6092 | struct dev_info *hw_priv = priv->adapter; |
6095 | 6093 | ||
6096 | strcpy(info->driver, DRV_NAME); | 6094 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
6097 | strcpy(info->version, DRV_VERSION); | 6095 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
6098 | strcpy(info->bus_info, pci_name(hw_priv->pdev)); | 6096 | strlcpy(info->bus_info, pci_name(hw_priv->pdev), |
6097 | sizeof(info->bus_info)); | ||
6099 | } | 6098 | } |
6100 | 6099 | ||
6101 | /** | 6100 | /** |
@@ -6587,7 +6586,8 @@ static void netdev_get_ethtool_stats(struct net_device *dev, | |||
6587 | * | 6586 | * |
6588 | * Return 0 if successful; otherwise an error code. | 6587 | * Return 0 if successful; otherwise an error code. |
6589 | */ | 6588 | */ |
6590 | static int netdev_set_features(struct net_device *dev, u32 features) | 6589 | static int netdev_set_features(struct net_device *dev, |
6590 | netdev_features_t features) | ||
6591 | { | 6591 | { |
6592 | struct dev_priv *priv = netdev_priv(dev); | 6592 | struct dev_priv *priv = netdev_priv(dev); |
6593 | struct dev_info *hw_priv = priv->adapter; | 6593 | struct dev_info *hw_priv = priv->adapter; |
@@ -6860,7 +6860,7 @@ static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port) | |||
6860 | int num; | 6860 | int num; |
6861 | 6861 | ||
6862 | i = j = num = got_num = 0; | 6862 | i = j = num = got_num = 0; |
6863 | while (j < MAC_ADDR_LEN) { | 6863 | while (j < ETH_ALEN) { |
6864 | if (macaddr[i]) { | 6864 | if (macaddr[i]) { |
6865 | int digit; | 6865 | int digit; |
6866 | 6866 | ||
@@ -6891,7 +6891,7 @@ static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port) | |||
6891 | } | 6891 | } |
6892 | i++; | 6892 | i++; |
6893 | } | 6893 | } |
6894 | if (MAC_ADDR_LEN == j) { | 6894 | if (ETH_ALEN == j) { |
6895 | if (MAIN_PORT == port) | 6895 | if (MAIN_PORT == port) |
6896 | hw_priv->hw.mac_override = 1; | 6896 | hw_priv->hw.mac_override = 1; |
6897 | } | 6897 | } |
@@ -7058,7 +7058,7 @@ static int __devinit pcidev_init(struct pci_dev *pdev, | |||
7058 | 7058 | ||
7059 | /* Multiple device interfaces mode requires a second MAC address. */ | 7059 | /* Multiple device interfaces mode requires a second MAC address. */ |
7060 | if (hw->dev_count > 1) { | 7060 | if (hw->dev_count > 1) { |
7061 | memcpy(sw->other_addr, hw->override_addr, MAC_ADDR_LEN); | 7061 | memcpy(sw->other_addr, hw->override_addr, ETH_ALEN); |
7062 | read_other_addr(hw); | 7062 | read_other_addr(hw); |
7063 | if (mac1addr[0] != ':') | 7063 | if (mac1addr[0] != ':') |
7064 | get_mac_addr(hw_priv, mac1addr, OTHER_PORT); | 7064 | get_mac_addr(hw_priv, mac1addr, OTHER_PORT); |
@@ -7108,12 +7108,11 @@ static int __devinit pcidev_init(struct pci_dev *pdev, | |||
7108 | dev->irq = pdev->irq; | 7108 | dev->irq = pdev->irq; |
7109 | if (MAIN_PORT == i) | 7109 | if (MAIN_PORT == i) |
7110 | memcpy(dev->dev_addr, hw_priv->hw.override_addr, | 7110 | memcpy(dev->dev_addr, hw_priv->hw.override_addr, |
7111 | MAC_ADDR_LEN); | 7111 | ETH_ALEN); |
7112 | else { | 7112 | else { |
7113 | memcpy(dev->dev_addr, sw->other_addr, | 7113 | memcpy(dev->dev_addr, sw->other_addr, ETH_ALEN); |
7114 | MAC_ADDR_LEN); | ||
7115 | if (!memcmp(sw->other_addr, hw->override_addr, | 7114 | if (!memcmp(sw->other_addr, hw->override_addr, |
7116 | MAC_ADDR_LEN)) | 7115 | ETH_ALEN)) |
7117 | dev->dev_addr[5] += port->first_port; | 7116 | dev->dev_addr[5] += port->first_port; |
7118 | } | 7117 | } |
7119 | 7118 | ||
diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c index 0778edcf7b9a..20b72ecb020a 100644 --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c | |||
@@ -1491,7 +1491,7 @@ myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget) | |||
1491 | * access to avoid theoretical race condition with functions that | 1491 | * access to avoid theoretical race condition with functions that |
1492 | * change NETIF_F_LRO flag at runtime. | 1492 | * change NETIF_F_LRO flag at runtime. |
1493 | */ | 1493 | */ |
1494 | bool lro_enabled = ACCESS_ONCE(mgp->dev->features) & NETIF_F_LRO; | 1494 | bool lro_enabled = !!(ACCESS_ONCE(mgp->dev->features) & NETIF_F_LRO); |
1495 | 1495 | ||
1496 | while (rx_done->entry[idx].length != 0 && work_done < budget) { | 1496 | while (rx_done->entry[idx].length != 0 && work_done < budget) { |
1497 | length = ntohs(rx_done->entry[idx].length); | 1497 | length = ntohs(rx_done->entry[idx].length); |
@@ -3149,7 +3149,8 @@ static int myri10ge_set_mac_address(struct net_device *dev, void *addr) | |||
3149 | return 0; | 3149 | return 0; |
3150 | } | 3150 | } |
3151 | 3151 | ||
3152 | static u32 myri10ge_fix_features(struct net_device *dev, u32 features) | 3152 | static netdev_features_t myri10ge_fix_features(struct net_device *dev, |
3153 | netdev_features_t features) | ||
3153 | { | 3154 | { |
3154 | if (!(features & NETIF_F_RXCSUM)) | 3155 | if (!(features & NETIF_F_RXCSUM)) |
3155 | features &= ~NETIF_F_LRO; | 3156 | features &= ~NETIF_F_LRO; |
diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c index 6ca047aab793..ac7b16b6e7af 100644 --- a/drivers/net/ethernet/natsemi/natsemi.c +++ b/drivers/net/ethernet/natsemi/natsemi.c | |||
@@ -2555,9 +2555,9 @@ static void set_rx_mode(struct net_device *dev) | |||
2555 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 2555 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
2556 | { | 2556 | { |
2557 | struct netdev_private *np = netdev_priv(dev); | 2557 | struct netdev_private *np = netdev_priv(dev); |
2558 | strncpy(info->driver, DRV_NAME, ETHTOOL_BUSINFO_LEN); | 2558 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
2559 | strncpy(info->version, DRV_VERSION, ETHTOOL_BUSINFO_LEN); | 2559 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
2560 | strncpy(info->bus_info, pci_name(np->pci_dev), ETHTOOL_BUSINFO_LEN); | 2560 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
2561 | } | 2561 | } |
2562 | 2562 | ||
2563 | static int get_regs_len(struct net_device *dev) | 2563 | static int get_regs_len(struct net_device *dev) |
diff --git a/drivers/net/ethernet/natsemi/ns83820.c b/drivers/net/ethernet/natsemi/ns83820.c index 2b8f64ddfb55..c24b46cbfe27 100644 --- a/drivers/net/ethernet/natsemi/ns83820.c +++ b/drivers/net/ethernet/natsemi/ns83820.c | |||
@@ -1364,9 +1364,9 @@ static int ns83820_set_settings(struct net_device *ndev, | |||
1364 | static void ns83820_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) | 1364 | static void ns83820_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) |
1365 | { | 1365 | { |
1366 | struct ns83820 *dev = PRIV(ndev); | 1366 | struct ns83820 *dev = PRIV(ndev); |
1367 | strcpy(info->driver, "ns83820"); | 1367 | strlcpy(info->driver, "ns83820", sizeof(info->driver)); |
1368 | strcpy(info->version, VERSION); | 1368 | strlcpy(info->version, VERSION, sizeof(info->version)); |
1369 | strcpy(info->bus_info, pci_name(dev->pci_dev)); | 1369 | strlcpy(info->bus_info, pci_name(dev->pci_dev), sizeof(info->bus_info)); |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | static u32 ns83820_get_link(struct net_device *ndev) | 1372 | static u32 ns83820_get_link(struct net_device *ndev) |
diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c index c27fb3dda9f4..76ae47627200 100644 --- a/drivers/net/ethernet/neterion/s2io.c +++ b/drivers/net/ethernet/neterion/s2io.c | |||
@@ -5391,10 +5391,10 @@ static void s2io_ethtool_gdrvinfo(struct net_device *dev, | |||
5391 | { | 5391 | { |
5392 | struct s2io_nic *sp = netdev_priv(dev); | 5392 | struct s2io_nic *sp = netdev_priv(dev); |
5393 | 5393 | ||
5394 | strncpy(info->driver, s2io_driver_name, sizeof(info->driver)); | 5394 | strlcpy(info->driver, s2io_driver_name, sizeof(info->driver)); |
5395 | strncpy(info->version, s2io_driver_version, sizeof(info->version)); | 5395 | strlcpy(info->version, s2io_driver_version, sizeof(info->version)); |
5396 | strncpy(info->fw_version, "", sizeof(info->fw_version)); | 5396 | strlcpy(info->fw_version, "", sizeof(info->fw_version)); |
5397 | strncpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info)); | 5397 | strlcpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info)); |
5398 | info->regdump_len = XENA_REG_SPACE; | 5398 | info->regdump_len = XENA_REG_SPACE; |
5399 | info->eedump_len = XENA_EEPROM_SPACE; | 5399 | info->eedump_len = XENA_EEPROM_SPACE; |
5400 | } | 5400 | } |
@@ -6616,10 +6616,10 @@ static void s2io_ethtool_get_strings(struct net_device *dev, | |||
6616 | } | 6616 | } |
6617 | } | 6617 | } |
6618 | 6618 | ||
6619 | static int s2io_set_features(struct net_device *dev, u32 features) | 6619 | static int s2io_set_features(struct net_device *dev, netdev_features_t features) |
6620 | { | 6620 | { |
6621 | struct s2io_nic *sp = netdev_priv(dev); | 6621 | struct s2io_nic *sp = netdev_priv(dev); |
6622 | u32 changed = (features ^ dev->features) & NETIF_F_LRO; | 6622 | netdev_features_t changed = (features ^ dev->features) & NETIF_F_LRO; |
6623 | 6623 | ||
6624 | if (changed && netif_running(dev)) { | 6624 | if (changed && netif_running(dev)) { |
6625 | int rc; | 6625 | int rc; |
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c index a83197d757c1..16d4d8e913c3 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c | |||
@@ -2662,9 +2662,10 @@ static void vxge_poll_vp_lockup(unsigned long data) | |||
2662 | mod_timer(&vdev->vp_lockup_timer, jiffies + HZ / 1000); | 2662 | mod_timer(&vdev->vp_lockup_timer, jiffies + HZ / 1000); |
2663 | } | 2663 | } |
2664 | 2664 | ||
2665 | static u32 vxge_fix_features(struct net_device *dev, u32 features) | 2665 | static netdev_features_t vxge_fix_features(struct net_device *dev, |
2666 | netdev_features_t features) | ||
2666 | { | 2667 | { |
2667 | u32 changed = dev->features ^ features; | 2668 | netdev_features_t changed = dev->features ^ features; |
2668 | 2669 | ||
2669 | /* Enabling RTH requires some of the logic in vxge_device_register and a | 2670 | /* Enabling RTH requires some of the logic in vxge_device_register and a |
2670 | * vpath reset. Due to these restrictions, only allow modification | 2671 | * vpath reset. Due to these restrictions, only allow modification |
@@ -2676,10 +2677,10 @@ static u32 vxge_fix_features(struct net_device *dev, u32 features) | |||
2676 | return features; | 2677 | return features; |
2677 | } | 2678 | } |
2678 | 2679 | ||
2679 | static int vxge_set_features(struct net_device *dev, u32 features) | 2680 | static int vxge_set_features(struct net_device *dev, netdev_features_t features) |
2680 | { | 2681 | { |
2681 | struct vxgedev *vdev = netdev_priv(dev); | 2682 | struct vxgedev *vdev = netdev_priv(dev); |
2682 | u32 changed = dev->features ^ features; | 2683 | netdev_features_t changed = dev->features ^ features; |
2683 | 2684 | ||
2684 | if (!(changed & NETIF_F_RXHASH)) | 2685 | if (!(changed & NETIF_F_RXHASH)) |
2685 | return 0; | 2686 | return 0; |
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 1c61d36e6570..8db0b376d5b7 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c | |||
@@ -65,7 +65,8 @@ | |||
65 | #include <linux/slab.h> | 65 | #include <linux/slab.h> |
66 | #include <linux/uaccess.h> | 66 | #include <linux/uaccess.h> |
67 | #include <linux/prefetch.h> | 67 | #include <linux/prefetch.h> |
68 | #include <linux/io.h> | 68 | #include <linux/u64_stats_sync.h> |
69 | #include <linux/io.h> | ||
69 | 70 | ||
70 | #include <asm/irq.h> | 71 | #include <asm/irq.h> |
71 | #include <asm/system.h> | 72 | #include <asm/system.h> |
@@ -736,6 +737,16 @@ struct nv_skb_map { | |||
736 | * - tx setup is lockless: it relies on netif_tx_lock. Actual submission | 737 | * - tx setup is lockless: it relies on netif_tx_lock. Actual submission |
737 | * needs netdev_priv(dev)->lock :-( | 738 | * needs netdev_priv(dev)->lock :-( |
738 | * - set_multicast_list: preparation lockless, relies on netif_tx_lock. | 739 | * - set_multicast_list: preparation lockless, relies on netif_tx_lock. |
740 | * | ||
741 | * Hardware stats updates are protected by hwstats_lock: | ||
742 | * - updated by nv_do_stats_poll (timer). This is meant to avoid | ||
743 | * integer wraparound in the NIC stats registers, at low frequency | ||
744 | * (0.1 Hz) | ||
745 | * - updated by nv_get_ethtool_stats + nv_get_stats64 | ||
746 | * | ||
747 | * Software stats are accessed only through 64b synchronization points | ||
748 | * and are not subject to other synchronization techniques (single | ||
749 | * update thread on the TX or RX paths). | ||
739 | */ | 750 | */ |
740 | 751 | ||
741 | /* in dev: base, irq */ | 752 | /* in dev: base, irq */ |
@@ -745,9 +756,10 @@ struct fe_priv { | |||
745 | struct net_device *dev; | 756 | struct net_device *dev; |
746 | struct napi_struct napi; | 757 | struct napi_struct napi; |
747 | 758 | ||
748 | /* General data: | 759 | /* hardware stats are updated in syscall and timer */ |
749 | * Locking: spin_lock(&np->lock); */ | 760 | spinlock_t hwstats_lock; |
750 | struct nv_ethtool_stats estats; | 761 | struct nv_ethtool_stats estats; |
762 | |||
751 | int in_shutdown; | 763 | int in_shutdown; |
752 | u32 linkspeed; | 764 | u32 linkspeed; |
753 | int duplex; | 765 | int duplex; |
@@ -798,6 +810,13 @@ struct fe_priv { | |||
798 | u32 nic_poll_irq; | 810 | u32 nic_poll_irq; |
799 | int rx_ring_size; | 811 | int rx_ring_size; |
800 | 812 | ||
813 | /* RX software stats */ | ||
814 | struct u64_stats_sync swstats_rx_syncp; | ||
815 | u64 stat_rx_packets; | ||
816 | u64 stat_rx_bytes; /* not always available in HW */ | ||
817 | u64 stat_rx_missed_errors; | ||
818 | u64 stat_rx_dropped; | ||
819 | |||
801 | /* media detection workaround. | 820 | /* media detection workaround. |
802 | * Locking: Within irq hander or disable_irq+spin_lock(&np->lock); | 821 | * Locking: Within irq hander or disable_irq+spin_lock(&np->lock); |
803 | */ | 822 | */ |
@@ -820,6 +839,12 @@ struct fe_priv { | |||
820 | struct nv_skb_map *tx_end_flip; | 839 | struct nv_skb_map *tx_end_flip; |
821 | int tx_stop; | 840 | int tx_stop; |
822 | 841 | ||
842 | /* TX software stats */ | ||
843 | struct u64_stats_sync swstats_tx_syncp; | ||
844 | u64 stat_tx_packets; /* not always available in HW */ | ||
845 | u64 stat_tx_bytes; | ||
846 | u64 stat_tx_dropped; | ||
847 | |||
823 | /* msi/msi-x fields */ | 848 | /* msi/msi-x fields */ |
824 | u32 msi_flags; | 849 | u32 msi_flags; |
825 | struct msix_entry msi_x_entry[NV_MSI_X_MAX_VECTORS]; | 850 | struct msix_entry msi_x_entry[NV_MSI_X_MAX_VECTORS]; |
@@ -892,6 +917,11 @@ enum { | |||
892 | static int dma_64bit = NV_DMA_64BIT_ENABLED; | 917 | static int dma_64bit = NV_DMA_64BIT_ENABLED; |
893 | 918 | ||
894 | /* | 919 | /* |
920 | * Debug output control for tx_timeout | ||
921 | */ | ||
922 | static bool debug_tx_timeout = false; | ||
923 | |||
924 | /* | ||
895 | * Crossover Detection | 925 | * Crossover Detection |
896 | * Realtek 8201 phy + some OEM boards do not work properly. | 926 | * Realtek 8201 phy + some OEM boards do not work properly. |
897 | */ | 927 | */ |
@@ -1630,11 +1660,19 @@ static void nv_mac_reset(struct net_device *dev) | |||
1630 | pci_push(base); | 1660 | pci_push(base); |
1631 | } | 1661 | } |
1632 | 1662 | ||
1633 | static void nv_get_hw_stats(struct net_device *dev) | 1663 | /* Caller must appropriately lock netdev_priv(dev)->hwstats_lock */ |
1664 | static void nv_update_stats(struct net_device *dev) | ||
1634 | { | 1665 | { |
1635 | struct fe_priv *np = netdev_priv(dev); | 1666 | struct fe_priv *np = netdev_priv(dev); |
1636 | u8 __iomem *base = get_hwbase(dev); | 1667 | u8 __iomem *base = get_hwbase(dev); |
1637 | 1668 | ||
1669 | /* If it happens that this is run in top-half context, then | ||
1670 | * replace the spin_lock of hwstats_lock with | ||
1671 | * spin_lock_irqsave() in calling functions. */ | ||
1672 | WARN_ONCE(in_irq(), "forcedeth: estats spin_lock(_bh) from top-half"); | ||
1673 | assert_spin_locked(&np->hwstats_lock); | ||
1674 | |||
1675 | /* query hardware */ | ||
1638 | np->estats.tx_bytes += readl(base + NvRegTxCnt); | 1676 | np->estats.tx_bytes += readl(base + NvRegTxCnt); |
1639 | np->estats.tx_zero_rexmt += readl(base + NvRegTxZeroReXmt); | 1677 | np->estats.tx_zero_rexmt += readl(base + NvRegTxZeroReXmt); |
1640 | np->estats.tx_one_rexmt += readl(base + NvRegTxOneReXmt); | 1678 | np->estats.tx_one_rexmt += readl(base + NvRegTxOneReXmt); |
@@ -1693,40 +1731,73 @@ static void nv_get_hw_stats(struct net_device *dev) | |||
1693 | } | 1731 | } |
1694 | 1732 | ||
1695 | /* | 1733 | /* |
1696 | * nv_get_stats: dev->get_stats function | 1734 | * nv_get_stats64: dev->ndo_get_stats64 function |
1697 | * Get latest stats value from the nic. | 1735 | * Get latest stats value from the nic. |
1698 | * Called with read_lock(&dev_base_lock) held for read - | 1736 | * Called with read_lock(&dev_base_lock) held for read - |
1699 | * only synchronized against unregister_netdevice. | 1737 | * only synchronized against unregister_netdevice. |
1700 | */ | 1738 | */ |
1701 | static struct net_device_stats *nv_get_stats(struct net_device *dev) | 1739 | static struct rtnl_link_stats64* |
1740 | nv_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *storage) | ||
1741 | __acquires(&netdev_priv(dev)->hwstats_lock) | ||
1742 | __releases(&netdev_priv(dev)->hwstats_lock) | ||
1702 | { | 1743 | { |
1703 | struct fe_priv *np = netdev_priv(dev); | 1744 | struct fe_priv *np = netdev_priv(dev); |
1745 | unsigned int syncp_start; | ||
1746 | |||
1747 | /* | ||
1748 | * Note: because HW stats are not always available and for | ||
1749 | * consistency reasons, the following ifconfig stats are | ||
1750 | * managed by software: rx_bytes, tx_bytes, rx_packets and | ||
1751 | * tx_packets. The related hardware stats reported by ethtool | ||
1752 | * should be equivalent to these ifconfig stats, with 4 | ||
1753 | * additional bytes per packet (Ethernet FCS CRC), except for | ||
1754 | * tx_packets when TSO kicks in. | ||
1755 | */ | ||
1756 | |||
1757 | /* software stats */ | ||
1758 | do { | ||
1759 | syncp_start = u64_stats_fetch_begin_bh(&np->swstats_rx_syncp); | ||
1760 | storage->rx_packets = np->stat_rx_packets; | ||
1761 | storage->rx_bytes = np->stat_rx_bytes; | ||
1762 | storage->rx_dropped = np->stat_rx_dropped; | ||
1763 | storage->rx_missed_errors = np->stat_rx_missed_errors; | ||
1764 | } while (u64_stats_fetch_retry_bh(&np->swstats_rx_syncp, syncp_start)); | ||
1765 | |||
1766 | do { | ||
1767 | syncp_start = u64_stats_fetch_begin_bh(&np->swstats_tx_syncp); | ||
1768 | storage->tx_packets = np->stat_tx_packets; | ||
1769 | storage->tx_bytes = np->stat_tx_bytes; | ||
1770 | storage->tx_dropped = np->stat_tx_dropped; | ||
1771 | } while (u64_stats_fetch_retry_bh(&np->swstats_tx_syncp, syncp_start)); | ||
1704 | 1772 | ||
1705 | /* If the nic supports hw counters then retrieve latest values */ | 1773 | /* If the nic supports hw counters then retrieve latest values */ |
1706 | if (np->driver_data & (DEV_HAS_STATISTICS_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_STATISTICS_V3)) { | 1774 | if (np->driver_data & DEV_HAS_STATISTICS_V123) { |
1707 | nv_get_hw_stats(dev); | 1775 | spin_lock_bh(&np->hwstats_lock); |
1708 | 1776 | ||
1709 | /* | 1777 | nv_update_stats(dev); |
1710 | * Note: because HW stats are not always available and | ||
1711 | * for consistency reasons, the following ifconfig | ||
1712 | * stats are managed by software: rx_bytes, tx_bytes, | ||
1713 | * rx_packets and tx_packets. The related hardware | ||
1714 | * stats reported by ethtool should be equivalent to | ||
1715 | * these ifconfig stats, with 4 additional bytes per | ||
1716 | * packet (Ethernet FCS CRC). | ||
1717 | */ | ||
1718 | 1778 | ||
1719 | /* copy to net_device stats */ | 1779 | /* generic stats */ |
1720 | dev->stats.tx_fifo_errors = np->estats.tx_fifo_errors; | 1780 | storage->rx_errors = np->estats.rx_errors_total; |
1721 | dev->stats.tx_carrier_errors = np->estats.tx_carrier_errors; | 1781 | storage->tx_errors = np->estats.tx_errors_total; |
1722 | dev->stats.rx_crc_errors = np->estats.rx_crc_errors; | 1782 | |
1723 | dev->stats.rx_over_errors = np->estats.rx_over_errors; | 1783 | /* meaningful only when NIC supports stats v3 */ |
1724 | dev->stats.rx_fifo_errors = np->estats.rx_drop_frame; | 1784 | storage->multicast = np->estats.rx_multicast; |
1725 | dev->stats.rx_errors = np->estats.rx_errors_total; | 1785 | |
1726 | dev->stats.tx_errors = np->estats.tx_errors_total; | 1786 | /* detailed rx_errors */ |
1787 | storage->rx_length_errors = np->estats.rx_length_error; | ||
1788 | storage->rx_over_errors = np->estats.rx_over_errors; | ||
1789 | storage->rx_crc_errors = np->estats.rx_crc_errors; | ||
1790 | storage->rx_frame_errors = np->estats.rx_frame_align_error; | ||
1791 | storage->rx_fifo_errors = np->estats.rx_drop_frame; | ||
1792 | |||
1793 | /* detailed tx_errors */ | ||
1794 | storage->tx_carrier_errors = np->estats.tx_carrier_errors; | ||
1795 | storage->tx_fifo_errors = np->estats.tx_fifo_errors; | ||
1796 | |||
1797 | spin_unlock_bh(&np->hwstats_lock); | ||
1727 | } | 1798 | } |
1728 | 1799 | ||
1729 | return &dev->stats; | 1800 | return storage; |
1730 | } | 1801 | } |
1731 | 1802 | ||
1732 | /* | 1803 | /* |
@@ -1759,8 +1830,12 @@ static int nv_alloc_rx(struct net_device *dev) | |||
1759 | np->put_rx.orig = np->first_rx.orig; | 1830 | np->put_rx.orig = np->first_rx.orig; |
1760 | if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx)) | 1831 | if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx)) |
1761 | np->put_rx_ctx = np->first_rx_ctx; | 1832 | np->put_rx_ctx = np->first_rx_ctx; |
1762 | } else | 1833 | } else { |
1834 | u64_stats_update_begin(&np->swstats_rx_syncp); | ||
1835 | np->stat_rx_dropped++; | ||
1836 | u64_stats_update_end(&np->swstats_rx_syncp); | ||
1763 | return 1; | 1837 | return 1; |
1838 | } | ||
1764 | } | 1839 | } |
1765 | return 0; | 1840 | return 0; |
1766 | } | 1841 | } |
@@ -1791,8 +1866,12 @@ static int nv_alloc_rx_optimized(struct net_device *dev) | |||
1791 | np->put_rx.ex = np->first_rx.ex; | 1866 | np->put_rx.ex = np->first_rx.ex; |
1792 | if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx)) | 1867 | if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx)) |
1793 | np->put_rx_ctx = np->first_rx_ctx; | 1868 | np->put_rx_ctx = np->first_rx_ctx; |
1794 | } else | 1869 | } else { |
1870 | u64_stats_update_begin(&np->swstats_rx_syncp); | ||
1871 | np->stat_rx_dropped++; | ||
1872 | u64_stats_update_end(&np->swstats_rx_syncp); | ||
1795 | return 1; | 1873 | return 1; |
1874 | } | ||
1796 | } | 1875 | } |
1797 | return 0; | 1876 | return 0; |
1798 | } | 1877 | } |
@@ -1927,8 +2006,11 @@ static void nv_drain_tx(struct net_device *dev) | |||
1927 | np->tx_ring.ex[i].bufhigh = 0; | 2006 | np->tx_ring.ex[i].bufhigh = 0; |
1928 | np->tx_ring.ex[i].buflow = 0; | 2007 | np->tx_ring.ex[i].buflow = 0; |
1929 | } | 2008 | } |
1930 | if (nv_release_txskb(np, &np->tx_skb[i])) | 2009 | if (nv_release_txskb(np, &np->tx_skb[i])) { |
1931 | dev->stats.tx_dropped++; | 2010 | u64_stats_update_begin(&np->swstats_tx_syncp); |
2011 | np->stat_tx_dropped++; | ||
2012 | u64_stats_update_end(&np->swstats_tx_syncp); | ||
2013 | } | ||
1932 | np->tx_skb[i].dma = 0; | 2014 | np->tx_skb[i].dma = 0; |
1933 | np->tx_skb[i].dma_len = 0; | 2015 | np->tx_skb[i].dma_len = 0; |
1934 | np->tx_skb[i].dma_single = 0; | 2016 | np->tx_skb[i].dma_single = 0; |
@@ -2385,11 +2467,14 @@ static int nv_tx_done(struct net_device *dev, int limit) | |||
2385 | if (np->desc_ver == DESC_VER_1) { | 2467 | if (np->desc_ver == DESC_VER_1) { |
2386 | if (flags & NV_TX_LASTPACKET) { | 2468 | if (flags & NV_TX_LASTPACKET) { |
2387 | if (flags & NV_TX_ERROR) { | 2469 | if (flags & NV_TX_ERROR) { |
2388 | if ((flags & NV_TX_RETRYERROR) && !(flags & NV_TX_RETRYCOUNT_MASK)) | 2470 | if ((flags & NV_TX_RETRYERROR) |
2471 | && !(flags & NV_TX_RETRYCOUNT_MASK)) | ||
2389 | nv_legacybackoff_reseed(dev); | 2472 | nv_legacybackoff_reseed(dev); |
2390 | } else { | 2473 | } else { |
2391 | dev->stats.tx_packets++; | 2474 | u64_stats_update_begin(&np->swstats_tx_syncp); |
2392 | dev->stats.tx_bytes += np->get_tx_ctx->skb->len; | 2475 | np->stat_tx_packets++; |
2476 | np->stat_tx_bytes += np->get_tx_ctx->skb->len; | ||
2477 | u64_stats_update_end(&np->swstats_tx_syncp); | ||
2393 | } | 2478 | } |
2394 | dev_kfree_skb_any(np->get_tx_ctx->skb); | 2479 | dev_kfree_skb_any(np->get_tx_ctx->skb); |
2395 | np->get_tx_ctx->skb = NULL; | 2480 | np->get_tx_ctx->skb = NULL; |
@@ -2398,11 +2483,14 @@ static int nv_tx_done(struct net_device *dev, int limit) | |||
2398 | } else { | 2483 | } else { |
2399 | if (flags & NV_TX2_LASTPACKET) { | 2484 | if (flags & NV_TX2_LASTPACKET) { |
2400 | if (flags & NV_TX2_ERROR) { | 2485 | if (flags & NV_TX2_ERROR) { |
2401 | if ((flags & NV_TX2_RETRYERROR) && !(flags & NV_TX2_RETRYCOUNT_MASK)) | 2486 | if ((flags & NV_TX2_RETRYERROR) |
2487 | && !(flags & NV_TX2_RETRYCOUNT_MASK)) | ||
2402 | nv_legacybackoff_reseed(dev); | 2488 | nv_legacybackoff_reseed(dev); |
2403 | } else { | 2489 | } else { |
2404 | dev->stats.tx_packets++; | 2490 | u64_stats_update_begin(&np->swstats_tx_syncp); |
2405 | dev->stats.tx_bytes += np->get_tx_ctx->skb->len; | 2491 | np->stat_tx_packets++; |
2492 | np->stat_tx_bytes += np->get_tx_ctx->skb->len; | ||
2493 | u64_stats_update_end(&np->swstats_tx_syncp); | ||
2406 | } | 2494 | } |
2407 | dev_kfree_skb_any(np->get_tx_ctx->skb); | 2495 | dev_kfree_skb_any(np->get_tx_ctx->skb); |
2408 | np->get_tx_ctx->skb = NULL; | 2496 | np->get_tx_ctx->skb = NULL; |
@@ -2436,15 +2524,18 @@ static int nv_tx_done_optimized(struct net_device *dev, int limit) | |||
2436 | 2524 | ||
2437 | if (flags & NV_TX2_LASTPACKET) { | 2525 | if (flags & NV_TX2_LASTPACKET) { |
2438 | if (flags & NV_TX2_ERROR) { | 2526 | if (flags & NV_TX2_ERROR) { |
2439 | if ((flags & NV_TX2_RETRYERROR) && !(flags & NV_TX2_RETRYCOUNT_MASK)) { | 2527 | if ((flags & NV_TX2_RETRYERROR) |
2528 | && !(flags & NV_TX2_RETRYCOUNT_MASK)) { | ||
2440 | if (np->driver_data & DEV_HAS_GEAR_MODE) | 2529 | if (np->driver_data & DEV_HAS_GEAR_MODE) |
2441 | nv_gear_backoff_reseed(dev); | 2530 | nv_gear_backoff_reseed(dev); |
2442 | else | 2531 | else |
2443 | nv_legacybackoff_reseed(dev); | 2532 | nv_legacybackoff_reseed(dev); |
2444 | } | 2533 | } |
2445 | } else { | 2534 | } else { |
2446 | dev->stats.tx_packets++; | 2535 | u64_stats_update_begin(&np->swstats_tx_syncp); |
2447 | dev->stats.tx_bytes += np->get_tx_ctx->skb->len; | 2536 | np->stat_tx_packets++; |
2537 | np->stat_tx_bytes += np->get_tx_ctx->skb->len; | ||
2538 | u64_stats_update_end(&np->swstats_tx_syncp); | ||
2448 | } | 2539 | } |
2449 | 2540 | ||
2450 | dev_kfree_skb_any(np->get_tx_ctx->skb); | 2541 | dev_kfree_skb_any(np->get_tx_ctx->skb); |
@@ -2477,56 +2568,64 @@ static void nv_tx_timeout(struct net_device *dev) | |||
2477 | u32 status; | 2568 | u32 status; |
2478 | union ring_type put_tx; | 2569 | union ring_type put_tx; |
2479 | int saved_tx_limit; | 2570 | int saved_tx_limit; |
2480 | int i; | ||
2481 | 2571 | ||
2482 | if (np->msi_flags & NV_MSI_X_ENABLED) | 2572 | if (np->msi_flags & NV_MSI_X_ENABLED) |
2483 | status = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQSTAT_MASK; | 2573 | status = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQSTAT_MASK; |
2484 | else | 2574 | else |
2485 | status = readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK; | 2575 | status = readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK; |
2486 | 2576 | ||
2487 | netdev_info(dev, "Got tx_timeout. irq: %08x\n", status); | 2577 | netdev_warn(dev, "Got tx_timeout. irq status: %08x\n", status); |
2488 | 2578 | ||
2489 | netdev_info(dev, "Ring at %lx\n", (unsigned long)np->ring_addr); | 2579 | if (unlikely(debug_tx_timeout)) { |
2490 | netdev_info(dev, "Dumping tx registers\n"); | 2580 | int i; |
2491 | for (i = 0; i <= np->register_size; i += 32) { | 2581 | |
2492 | netdev_info(dev, | 2582 | netdev_info(dev, "Ring at %lx\n", (unsigned long)np->ring_addr); |
2493 | "%3x: %08x %08x %08x %08x %08x %08x %08x %08x\n", | 2583 | netdev_info(dev, "Dumping tx registers\n"); |
2494 | i, | 2584 | for (i = 0; i <= np->register_size; i += 32) { |
2495 | readl(base + i + 0), readl(base + i + 4), | ||
2496 | readl(base + i + 8), readl(base + i + 12), | ||
2497 | readl(base + i + 16), readl(base + i + 20), | ||
2498 | readl(base + i + 24), readl(base + i + 28)); | ||
2499 | } | ||
2500 | netdev_info(dev, "Dumping tx ring\n"); | ||
2501 | for (i = 0; i < np->tx_ring_size; i += 4) { | ||
2502 | if (!nv_optimized(np)) { | ||
2503 | netdev_info(dev, | ||
2504 | "%03x: %08x %08x // %08x %08x // %08x %08x // %08x %08x\n", | ||
2505 | i, | ||
2506 | le32_to_cpu(np->tx_ring.orig[i].buf), | ||
2507 | le32_to_cpu(np->tx_ring.orig[i].flaglen), | ||
2508 | le32_to_cpu(np->tx_ring.orig[i+1].buf), | ||
2509 | le32_to_cpu(np->tx_ring.orig[i+1].flaglen), | ||
2510 | le32_to_cpu(np->tx_ring.orig[i+2].buf), | ||
2511 | le32_to_cpu(np->tx_ring.orig[i+2].flaglen), | ||
2512 | le32_to_cpu(np->tx_ring.orig[i+3].buf), | ||
2513 | le32_to_cpu(np->tx_ring.orig[i+3].flaglen)); | ||
2514 | } else { | ||
2515 | netdev_info(dev, | 2585 | netdev_info(dev, |
2516 | "%03x: %08x %08x %08x // %08x %08x %08x // %08x %08x %08x // %08x %08x %08x\n", | 2586 | "%3x: %08x %08x %08x %08x " |
2587 | "%08x %08x %08x %08x\n", | ||
2517 | i, | 2588 | i, |
2518 | le32_to_cpu(np->tx_ring.ex[i].bufhigh), | 2589 | readl(base + i + 0), readl(base + i + 4), |
2519 | le32_to_cpu(np->tx_ring.ex[i].buflow), | 2590 | readl(base + i + 8), readl(base + i + 12), |
2520 | le32_to_cpu(np->tx_ring.ex[i].flaglen), | 2591 | readl(base + i + 16), readl(base + i + 20), |
2521 | le32_to_cpu(np->tx_ring.ex[i+1].bufhigh), | 2592 | readl(base + i + 24), readl(base + i + 28)); |
2522 | le32_to_cpu(np->tx_ring.ex[i+1].buflow), | 2593 | } |
2523 | le32_to_cpu(np->tx_ring.ex[i+1].flaglen), | 2594 | netdev_info(dev, "Dumping tx ring\n"); |
2524 | le32_to_cpu(np->tx_ring.ex[i+2].bufhigh), | 2595 | for (i = 0; i < np->tx_ring_size; i += 4) { |
2525 | le32_to_cpu(np->tx_ring.ex[i+2].buflow), | 2596 | if (!nv_optimized(np)) { |
2526 | le32_to_cpu(np->tx_ring.ex[i+2].flaglen), | 2597 | netdev_info(dev, |
2527 | le32_to_cpu(np->tx_ring.ex[i+3].bufhigh), | 2598 | "%03x: %08x %08x // %08x %08x " |
2528 | le32_to_cpu(np->tx_ring.ex[i+3].buflow), | 2599 | "// %08x %08x // %08x %08x\n", |
2529 | le32_to_cpu(np->tx_ring.ex[i+3].flaglen)); | 2600 | i, |
2601 | le32_to_cpu(np->tx_ring.orig[i].buf), | ||
2602 | le32_to_cpu(np->tx_ring.orig[i].flaglen), | ||
2603 | le32_to_cpu(np->tx_ring.orig[i+1].buf), | ||
2604 | le32_to_cpu(np->tx_ring.orig[i+1].flaglen), | ||
2605 | le32_to_cpu(np->tx_ring.orig[i+2].buf), | ||
2606 | le32_to_cpu(np->tx_ring.orig[i+2].flaglen), | ||
2607 | le32_to_cpu(np->tx_ring.orig[i+3].buf), | ||
2608 | le32_to_cpu(np->tx_ring.orig[i+3].flaglen)); | ||
2609 | } else { | ||
2610 | netdev_info(dev, | ||
2611 | "%03x: %08x %08x %08x " | ||
2612 | "// %08x %08x %08x " | ||
2613 | "// %08x %08x %08x " | ||
2614 | "// %08x %08x %08x\n", | ||
2615 | i, | ||
2616 | le32_to_cpu(np->tx_ring.ex[i].bufhigh), | ||
2617 | le32_to_cpu(np->tx_ring.ex[i].buflow), | ||
2618 | le32_to_cpu(np->tx_ring.ex[i].flaglen), | ||
2619 | le32_to_cpu(np->tx_ring.ex[i+1].bufhigh), | ||
2620 | le32_to_cpu(np->tx_ring.ex[i+1].buflow), | ||
2621 | le32_to_cpu(np->tx_ring.ex[i+1].flaglen), | ||
2622 | le32_to_cpu(np->tx_ring.ex[i+2].bufhigh), | ||
2623 | le32_to_cpu(np->tx_ring.ex[i+2].buflow), | ||
2624 | le32_to_cpu(np->tx_ring.ex[i+2].flaglen), | ||
2625 | le32_to_cpu(np->tx_ring.ex[i+3].bufhigh), | ||
2626 | le32_to_cpu(np->tx_ring.ex[i+3].buflow), | ||
2627 | le32_to_cpu(np->tx_ring.ex[i+3].flaglen)); | ||
2628 | } | ||
2530 | } | 2629 | } |
2531 | } | 2630 | } |
2532 | 2631 | ||
@@ -2649,8 +2748,11 @@ static int nv_rx_process(struct net_device *dev, int limit) | |||
2649 | } | 2748 | } |
2650 | /* the rest are hard errors */ | 2749 | /* the rest are hard errors */ |
2651 | else { | 2750 | else { |
2652 | if (flags & NV_RX_MISSEDFRAME) | 2751 | if (flags & NV_RX_MISSEDFRAME) { |
2653 | dev->stats.rx_missed_errors++; | 2752 | u64_stats_update_begin(&np->swstats_rx_syncp); |
2753 | np->stat_rx_missed_errors++; | ||
2754 | u64_stats_update_end(&np->swstats_rx_syncp); | ||
2755 | } | ||
2654 | dev_kfree_skb(skb); | 2756 | dev_kfree_skb(skb); |
2655 | goto next_pkt; | 2757 | goto next_pkt; |
2656 | } | 2758 | } |
@@ -2693,8 +2795,10 @@ static int nv_rx_process(struct net_device *dev, int limit) | |||
2693 | skb_put(skb, len); | 2795 | skb_put(skb, len); |
2694 | skb->protocol = eth_type_trans(skb, dev); | 2796 | skb->protocol = eth_type_trans(skb, dev); |
2695 | napi_gro_receive(&np->napi, skb); | 2797 | napi_gro_receive(&np->napi, skb); |
2696 | dev->stats.rx_packets++; | 2798 | u64_stats_update_begin(&np->swstats_rx_syncp); |
2697 | dev->stats.rx_bytes += len; | 2799 | np->stat_rx_packets++; |
2800 | np->stat_rx_bytes += len; | ||
2801 | u64_stats_update_end(&np->swstats_rx_syncp); | ||
2698 | next_pkt: | 2802 | next_pkt: |
2699 | if (unlikely(np->get_rx.orig++ == np->last_rx.orig)) | 2803 | if (unlikely(np->get_rx.orig++ == np->last_rx.orig)) |
2700 | np->get_rx.orig = np->first_rx.orig; | 2804 | np->get_rx.orig = np->first_rx.orig; |
@@ -2777,8 +2881,10 @@ static int nv_rx_process_optimized(struct net_device *dev, int limit) | |||
2777 | __vlan_hwaccel_put_tag(skb, vid); | 2881 | __vlan_hwaccel_put_tag(skb, vid); |
2778 | } | 2882 | } |
2779 | napi_gro_receive(&np->napi, skb); | 2883 | napi_gro_receive(&np->napi, skb); |
2780 | dev->stats.rx_packets++; | 2884 | u64_stats_update_begin(&np->swstats_rx_syncp); |
2781 | dev->stats.rx_bytes += len; | 2885 | np->stat_rx_packets++; |
2886 | np->stat_rx_bytes += len; | ||
2887 | u64_stats_update_end(&np->swstats_rx_syncp); | ||
2782 | } else { | 2888 | } else { |
2783 | dev_kfree_skb(skb); | 2889 | dev_kfree_skb(skb); |
2784 | } | 2890 | } |
@@ -3021,6 +3127,73 @@ static void nv_update_pause(struct net_device *dev, u32 pause_flags) | |||
3021 | } | 3127 | } |
3022 | } | 3128 | } |
3023 | 3129 | ||
3130 | static void nv_force_linkspeed(struct net_device *dev, int speed, int duplex) | ||
3131 | { | ||
3132 | struct fe_priv *np = netdev_priv(dev); | ||
3133 | u8 __iomem *base = get_hwbase(dev); | ||
3134 | u32 phyreg, txreg; | ||
3135 | int mii_status; | ||
3136 | |||
3137 | np->linkspeed = NVREG_LINKSPEED_FORCE|speed; | ||
3138 | np->duplex = duplex; | ||
3139 | |||
3140 | /* see if gigabit phy */ | ||
3141 | mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ); | ||
3142 | if (mii_status & PHY_GIGABIT) { | ||
3143 | np->gigabit = PHY_GIGABIT; | ||
3144 | phyreg = readl(base + NvRegSlotTime); | ||
3145 | phyreg &= ~(0x3FF00); | ||
3146 | if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_10) | ||
3147 | phyreg |= NVREG_SLOTTIME_10_100_FULL; | ||
3148 | else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_100) | ||
3149 | phyreg |= NVREG_SLOTTIME_10_100_FULL; | ||
3150 | else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_1000) | ||
3151 | phyreg |= NVREG_SLOTTIME_1000_FULL; | ||
3152 | writel(phyreg, base + NvRegSlotTime); | ||
3153 | } | ||
3154 | |||
3155 | phyreg = readl(base + NvRegPhyInterface); | ||
3156 | phyreg &= ~(PHY_HALF|PHY_100|PHY_1000); | ||
3157 | if (np->duplex == 0) | ||
3158 | phyreg |= PHY_HALF; | ||
3159 | if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_100) | ||
3160 | phyreg |= PHY_100; | ||
3161 | else if ((np->linkspeed & NVREG_LINKSPEED_MASK) == | ||
3162 | NVREG_LINKSPEED_1000) | ||
3163 | phyreg |= PHY_1000; | ||
3164 | writel(phyreg, base + NvRegPhyInterface); | ||
3165 | |||
3166 | if (phyreg & PHY_RGMII) { | ||
3167 | if ((np->linkspeed & NVREG_LINKSPEED_MASK) == | ||
3168 | NVREG_LINKSPEED_1000) | ||
3169 | txreg = NVREG_TX_DEFERRAL_RGMII_1000; | ||
3170 | else | ||
3171 | txreg = NVREG_TX_DEFERRAL_RGMII_10_100; | ||
3172 | } else { | ||
3173 | txreg = NVREG_TX_DEFERRAL_DEFAULT; | ||
3174 | } | ||
3175 | writel(txreg, base + NvRegTxDeferral); | ||
3176 | |||
3177 | if (np->desc_ver == DESC_VER_1) { | ||
3178 | txreg = NVREG_TX_WM_DESC1_DEFAULT; | ||
3179 | } else { | ||
3180 | if ((np->linkspeed & NVREG_LINKSPEED_MASK) == | ||
3181 | NVREG_LINKSPEED_1000) | ||
3182 | txreg = NVREG_TX_WM_DESC2_3_1000; | ||
3183 | else | ||
3184 | txreg = NVREG_TX_WM_DESC2_3_DEFAULT; | ||
3185 | } | ||
3186 | writel(txreg, base + NvRegTxWatermark); | ||
3187 | |||
3188 | writel(NVREG_MISC1_FORCE | (np->duplex ? 0 : NVREG_MISC1_HD), | ||
3189 | base + NvRegMisc1); | ||
3190 | pci_push(base); | ||
3191 | writel(np->linkspeed, base + NvRegLinkSpeed); | ||
3192 | pci_push(base); | ||
3193 | |||
3194 | return; | ||
3195 | } | ||
3196 | |||
3024 | /** | 3197 | /** |
3025 | * nv_update_linkspeed: Setup the MAC according to the link partner | 3198 | * nv_update_linkspeed: Setup the MAC according to the link partner |
3026 | * @dev: Network device to be configured | 3199 | * @dev: Network device to be configured |
@@ -3042,11 +3215,25 @@ static int nv_update_linkspeed(struct net_device *dev) | |||
3042 | int newls = np->linkspeed; | 3215 | int newls = np->linkspeed; |
3043 | int newdup = np->duplex; | 3216 | int newdup = np->duplex; |
3044 | int mii_status; | 3217 | int mii_status; |
3218 | u32 bmcr; | ||
3045 | int retval = 0; | 3219 | int retval = 0; |
3046 | u32 control_1000, status_1000, phyreg, pause_flags, txreg; | 3220 | u32 control_1000, status_1000, phyreg, pause_flags, txreg; |
3047 | u32 txrxFlags = 0; | 3221 | u32 txrxFlags = 0; |
3048 | u32 phy_exp; | 3222 | u32 phy_exp; |
3049 | 3223 | ||
3224 | /* If device loopback is enabled, set carrier on and enable max link | ||
3225 | * speed. | ||
3226 | */ | ||
3227 | bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); | ||
3228 | if (bmcr & BMCR_LOOPBACK) { | ||
3229 | if (netif_running(dev)) { | ||
3230 | nv_force_linkspeed(dev, NVREG_LINKSPEED_1000, 1); | ||
3231 | if (!netif_carrier_ok(dev)) | ||
3232 | netif_carrier_on(dev); | ||
3233 | } | ||
3234 | return 1; | ||
3235 | } | ||
3236 | |||
3050 | /* BMSR_LSTATUS is latched, read it twice: | 3237 | /* BMSR_LSTATUS is latched, read it twice: |
3051 | * we want the current value. | 3238 | * we want the current value. |
3052 | */ | 3239 | */ |
@@ -3729,6 +3916,7 @@ static int nv_request_irq(struct net_device *dev, int intr_test) | |||
3729 | writel(0, base + NvRegMSIXMap0); | 3916 | writel(0, base + NvRegMSIXMap0); |
3730 | writel(0, base + NvRegMSIXMap1); | 3917 | writel(0, base + NvRegMSIXMap1); |
3731 | } | 3918 | } |
3919 | netdev_info(dev, "MSI-X enabled\n"); | ||
3732 | } | 3920 | } |
3733 | } | 3921 | } |
3734 | if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) { | 3922 | if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) { |
@@ -3750,6 +3938,7 @@ static int nv_request_irq(struct net_device *dev, int intr_test) | |||
3750 | writel(0, base + NvRegMSIMap1); | 3938 | writel(0, base + NvRegMSIMap1); |
3751 | /* enable msi vector 0 */ | 3939 | /* enable msi vector 0 */ |
3752 | writel(NVREG_MSI_VECTOR_0_ENABLED, base + NvRegMSIIrqMask); | 3940 | writel(NVREG_MSI_VECTOR_0_ENABLED, base + NvRegMSIIrqMask); |
3941 | netdev_info(dev, "MSI enabled\n"); | ||
3753 | } | 3942 | } |
3754 | } | 3943 | } |
3755 | if (ret != 0) { | 3944 | if (ret != 0) { |
@@ -3904,11 +4093,18 @@ static void nv_poll_controller(struct net_device *dev) | |||
3904 | #endif | 4093 | #endif |
3905 | 4094 | ||
3906 | static void nv_do_stats_poll(unsigned long data) | 4095 | static void nv_do_stats_poll(unsigned long data) |
4096 | __acquires(&netdev_priv(dev)->hwstats_lock) | ||
4097 | __releases(&netdev_priv(dev)->hwstats_lock) | ||
3907 | { | 4098 | { |
3908 | struct net_device *dev = (struct net_device *) data; | 4099 | struct net_device *dev = (struct net_device *) data; |
3909 | struct fe_priv *np = netdev_priv(dev); | 4100 | struct fe_priv *np = netdev_priv(dev); |
3910 | 4101 | ||
3911 | nv_get_hw_stats(dev); | 4102 | /* If lock is currently taken, the stats are being refreshed |
4103 | * and hence fresh enough */ | ||
4104 | if (spin_trylock(&np->hwstats_lock)) { | ||
4105 | nv_update_stats(dev); | ||
4106 | spin_unlock(&np->hwstats_lock); | ||
4107 | } | ||
3912 | 4108 | ||
3913 | if (!np->in_shutdown) | 4109 | if (!np->in_shutdown) |
3914 | mod_timer(&np->stats_poll, | 4110 | mod_timer(&np->stats_poll, |
@@ -3918,9 +4114,9 @@ static void nv_do_stats_poll(unsigned long data) | |||
3918 | static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 4114 | static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
3919 | { | 4115 | { |
3920 | struct fe_priv *np = netdev_priv(dev); | 4116 | struct fe_priv *np = netdev_priv(dev); |
3921 | strcpy(info->driver, DRV_NAME); | 4117 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
3922 | strcpy(info->version, FORCEDETH_VERSION); | 4118 | strlcpy(info->version, FORCEDETH_VERSION, sizeof(info->version)); |
3923 | strcpy(info->bus_info, pci_name(np->pci_dev)); | 4119 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
3924 | } | 4120 | } |
3925 | 4121 | ||
3926 | static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) | 4122 | static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) |
@@ -4473,7 +4669,63 @@ static int nv_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam* | |||
4473 | return 0; | 4669 | return 0; |
4474 | } | 4670 | } |
4475 | 4671 | ||
4476 | static u32 nv_fix_features(struct net_device *dev, u32 features) | 4672 | static int nv_set_loopback(struct net_device *dev, netdev_features_t features) |
4673 | { | ||
4674 | struct fe_priv *np = netdev_priv(dev); | ||
4675 | unsigned long flags; | ||
4676 | u32 miicontrol; | ||
4677 | int err, retval = 0; | ||
4678 | |||
4679 | spin_lock_irqsave(&np->lock, flags); | ||
4680 | miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); | ||
4681 | if (features & NETIF_F_LOOPBACK) { | ||
4682 | if (miicontrol & BMCR_LOOPBACK) { | ||
4683 | spin_unlock_irqrestore(&np->lock, flags); | ||
4684 | netdev_info(dev, "Loopback already enabled\n"); | ||
4685 | return 0; | ||
4686 | } | ||
4687 | nv_disable_irq(dev); | ||
4688 | /* Turn on loopback mode */ | ||
4689 | miicontrol |= BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED1000; | ||
4690 | err = mii_rw(dev, np->phyaddr, MII_BMCR, miicontrol); | ||
4691 | if (err) { | ||
4692 | retval = PHY_ERROR; | ||
4693 | spin_unlock_irqrestore(&np->lock, flags); | ||
4694 | phy_init(dev); | ||
4695 | } else { | ||
4696 | if (netif_running(dev)) { | ||
4697 | /* Force 1000 Mbps full-duplex */ | ||
4698 | nv_force_linkspeed(dev, NVREG_LINKSPEED_1000, | ||
4699 | 1); | ||
4700 | /* Force link up */ | ||
4701 | netif_carrier_on(dev); | ||
4702 | } | ||
4703 | spin_unlock_irqrestore(&np->lock, flags); | ||
4704 | netdev_info(dev, | ||
4705 | "Internal PHY loopback mode enabled.\n"); | ||
4706 | } | ||
4707 | } else { | ||
4708 | if (!(miicontrol & BMCR_LOOPBACK)) { | ||
4709 | spin_unlock_irqrestore(&np->lock, flags); | ||
4710 | netdev_info(dev, "Loopback already disabled\n"); | ||
4711 | return 0; | ||
4712 | } | ||
4713 | nv_disable_irq(dev); | ||
4714 | /* Turn off loopback */ | ||
4715 | spin_unlock_irqrestore(&np->lock, flags); | ||
4716 | netdev_info(dev, "Internal PHY loopback mode disabled.\n"); | ||
4717 | phy_init(dev); | ||
4718 | } | ||
4719 | msleep(500); | ||
4720 | spin_lock_irqsave(&np->lock, flags); | ||
4721 | nv_enable_irq(dev); | ||
4722 | spin_unlock_irqrestore(&np->lock, flags); | ||
4723 | |||
4724 | return retval; | ||
4725 | } | ||
4726 | |||
4727 | static netdev_features_t nv_fix_features(struct net_device *dev, | ||
4728 | netdev_features_t features) | ||
4477 | { | 4729 | { |
4478 | /* vlan is dependent on rx checksum offload */ | 4730 | /* vlan is dependent on rx checksum offload */ |
4479 | if (features & (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX)) | 4731 | if (features & (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX)) |
@@ -4482,7 +4734,7 @@ static u32 nv_fix_features(struct net_device *dev, u32 features) | |||
4482 | return features; | 4734 | return features; |
4483 | } | 4735 | } |
4484 | 4736 | ||
4485 | static void nv_vlan_mode(struct net_device *dev, u32 features) | 4737 | static void nv_vlan_mode(struct net_device *dev, netdev_features_t features) |
4486 | { | 4738 | { |
4487 | struct fe_priv *np = get_nvpriv(dev); | 4739 | struct fe_priv *np = get_nvpriv(dev); |
4488 | 4740 | ||
@@ -4503,11 +4755,18 @@ static void nv_vlan_mode(struct net_device *dev, u32 features) | |||
4503 | spin_unlock_irq(&np->lock); | 4755 | spin_unlock_irq(&np->lock); |
4504 | } | 4756 | } |
4505 | 4757 | ||
4506 | static int nv_set_features(struct net_device *dev, u32 features) | 4758 | static int nv_set_features(struct net_device *dev, netdev_features_t features) |
4507 | { | 4759 | { |
4508 | struct fe_priv *np = netdev_priv(dev); | 4760 | struct fe_priv *np = netdev_priv(dev); |
4509 | u8 __iomem *base = get_hwbase(dev); | 4761 | u8 __iomem *base = get_hwbase(dev); |
4510 | u32 changed = dev->features ^ features; | 4762 | netdev_features_t changed = dev->features ^ features; |
4763 | int retval; | ||
4764 | |||
4765 | if ((changed & NETIF_F_LOOPBACK) && netif_running(dev)) { | ||
4766 | retval = nv_set_loopback(dev, features); | ||
4767 | if (retval != 0) | ||
4768 | return retval; | ||
4769 | } | ||
4511 | 4770 | ||
4512 | if (changed & NETIF_F_RXCSUM) { | 4771 | if (changed & NETIF_F_RXCSUM) { |
4513 | spin_lock_irq(&np->lock); | 4772 | spin_lock_irq(&np->lock); |
@@ -4553,14 +4812,18 @@ static int nv_get_sset_count(struct net_device *dev, int sset) | |||
4553 | } | 4812 | } |
4554 | } | 4813 | } |
4555 | 4814 | ||
4556 | static void nv_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *estats, u64 *buffer) | 4815 | static void nv_get_ethtool_stats(struct net_device *dev, |
4816 | struct ethtool_stats *estats, u64 *buffer) | ||
4817 | __acquires(&netdev_priv(dev)->hwstats_lock) | ||
4818 | __releases(&netdev_priv(dev)->hwstats_lock) | ||
4557 | { | 4819 | { |
4558 | struct fe_priv *np = netdev_priv(dev); | 4820 | struct fe_priv *np = netdev_priv(dev); |
4559 | 4821 | ||
4560 | /* update stats */ | 4822 | spin_lock_bh(&np->hwstats_lock); |
4561 | nv_get_hw_stats(dev); | 4823 | nv_update_stats(dev); |
4562 | 4824 | memcpy(buffer, &np->estats, | |
4563 | memcpy(buffer, &np->estats, nv_get_sset_count(dev, ETH_SS_STATS)*sizeof(u64)); | 4825 | nv_get_sset_count(dev, ETH_SS_STATS)*sizeof(u64)); |
4826 | spin_unlock_bh(&np->hwstats_lock); | ||
4564 | } | 4827 | } |
4565 | 4828 | ||
4566 | static int nv_link_test(struct net_device *dev) | 4829 | static int nv_link_test(struct net_device *dev) |
@@ -5142,6 +5405,12 @@ static int nv_open(struct net_device *dev) | |||
5142 | 5405 | ||
5143 | spin_unlock_irq(&np->lock); | 5406 | spin_unlock_irq(&np->lock); |
5144 | 5407 | ||
5408 | /* If the loopback feature was set while the device was down, make sure | ||
5409 | * that it's set correctly now. | ||
5410 | */ | ||
5411 | if (dev->features & NETIF_F_LOOPBACK) | ||
5412 | nv_set_loopback(dev, dev->features); | ||
5413 | |||
5145 | return 0; | 5414 | return 0; |
5146 | out_drain: | 5415 | out_drain: |
5147 | nv_drain_rxtx(dev); | 5416 | nv_drain_rxtx(dev); |
@@ -5198,7 +5467,7 @@ static int nv_close(struct net_device *dev) | |||
5198 | static const struct net_device_ops nv_netdev_ops = { | 5467 | static const struct net_device_ops nv_netdev_ops = { |
5199 | .ndo_open = nv_open, | 5468 | .ndo_open = nv_open, |
5200 | .ndo_stop = nv_close, | 5469 | .ndo_stop = nv_close, |
5201 | .ndo_get_stats = nv_get_stats, | 5470 | .ndo_get_stats64 = nv_get_stats64, |
5202 | .ndo_start_xmit = nv_start_xmit, | 5471 | .ndo_start_xmit = nv_start_xmit, |
5203 | .ndo_tx_timeout = nv_tx_timeout, | 5472 | .ndo_tx_timeout = nv_tx_timeout, |
5204 | .ndo_change_mtu = nv_change_mtu, | 5473 | .ndo_change_mtu = nv_change_mtu, |
@@ -5215,7 +5484,7 @@ static const struct net_device_ops nv_netdev_ops = { | |||
5215 | static const struct net_device_ops nv_netdev_ops_optimized = { | 5484 | static const struct net_device_ops nv_netdev_ops_optimized = { |
5216 | .ndo_open = nv_open, | 5485 | .ndo_open = nv_open, |
5217 | .ndo_stop = nv_close, | 5486 | .ndo_stop = nv_close, |
5218 | .ndo_get_stats = nv_get_stats, | 5487 | .ndo_get_stats64 = nv_get_stats64, |
5219 | .ndo_start_xmit = nv_start_xmit_optimized, | 5488 | .ndo_start_xmit = nv_start_xmit_optimized, |
5220 | .ndo_tx_timeout = nv_tx_timeout, | 5489 | .ndo_tx_timeout = nv_tx_timeout, |
5221 | .ndo_change_mtu = nv_change_mtu, | 5490 | .ndo_change_mtu = nv_change_mtu, |
@@ -5254,6 +5523,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
5254 | np->dev = dev; | 5523 | np->dev = dev; |
5255 | np->pci_dev = pci_dev; | 5524 | np->pci_dev = pci_dev; |
5256 | spin_lock_init(&np->lock); | 5525 | spin_lock_init(&np->lock); |
5526 | spin_lock_init(&np->hwstats_lock); | ||
5257 | SET_NETDEV_DEV(dev, &pci_dev->dev); | 5527 | SET_NETDEV_DEV(dev, &pci_dev->dev); |
5258 | 5528 | ||
5259 | init_timer(&np->oom_kick); | 5529 | init_timer(&np->oom_kick); |
@@ -5262,7 +5532,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
5262 | init_timer(&np->nic_poll); | 5532 | init_timer(&np->nic_poll); |
5263 | np->nic_poll.data = (unsigned long) dev; | 5533 | np->nic_poll.data = (unsigned long) dev; |
5264 | np->nic_poll.function = nv_do_nic_poll; /* timer handler */ | 5534 | np->nic_poll.function = nv_do_nic_poll; /* timer handler */ |
5265 | init_timer(&np->stats_poll); | 5535 | init_timer_deferrable(&np->stats_poll); |
5266 | np->stats_poll.data = (unsigned long) dev; | 5536 | np->stats_poll.data = (unsigned long) dev; |
5267 | np->stats_poll.function = nv_do_stats_poll; /* timer handler */ | 5537 | np->stats_poll.function = nv_do_stats_poll; /* timer handler */ |
5268 | 5538 | ||
@@ -5346,6 +5616,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
5346 | 5616 | ||
5347 | dev->features |= dev->hw_features; | 5617 | dev->features |= dev->hw_features; |
5348 | 5618 | ||
5619 | /* Add loopback capability to the device. */ | ||
5620 | dev->hw_features |= NETIF_F_LOOPBACK; | ||
5621 | |||
5349 | np->pause_flags = NV_PAUSEFRAME_RX_CAPABLE | NV_PAUSEFRAME_RX_REQ | NV_PAUSEFRAME_AUTONEG; | 5622 | np->pause_flags = NV_PAUSEFRAME_RX_CAPABLE | NV_PAUSEFRAME_RX_REQ | NV_PAUSEFRAME_AUTONEG; |
5350 | if ((id->driver_data & DEV_HAS_PAUSEFRAME_TX_V1) || | 5623 | if ((id->driver_data & DEV_HAS_PAUSEFRAME_TX_V1) || |
5351 | (id->driver_data & DEV_HAS_PAUSEFRAME_TX_V2) || | 5624 | (id->driver_data & DEV_HAS_PAUSEFRAME_TX_V2) || |
@@ -5621,12 +5894,14 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
5621 | dev_info(&pci_dev->dev, "ifname %s, PHY OUI 0x%x @ %d, addr %pM\n", | 5894 | dev_info(&pci_dev->dev, "ifname %s, PHY OUI 0x%x @ %d, addr %pM\n", |
5622 | dev->name, np->phy_oui, np->phyaddr, dev->dev_addr); | 5895 | dev->name, np->phy_oui, np->phyaddr, dev->dev_addr); |
5623 | 5896 | ||
5624 | dev_info(&pci_dev->dev, "%s%s%s%s%s%s%s%s%s%sdesc-v%u\n", | 5897 | dev_info(&pci_dev->dev, "%s%s%s%s%s%s%s%s%s%s%sdesc-v%u\n", |
5625 | dev->features & NETIF_F_HIGHDMA ? "highdma " : "", | 5898 | dev->features & NETIF_F_HIGHDMA ? "highdma " : "", |
5626 | dev->features & (NETIF_F_IP_CSUM | NETIF_F_SG) ? | 5899 | dev->features & (NETIF_F_IP_CSUM | NETIF_F_SG) ? |
5627 | "csum " : "", | 5900 | "csum " : "", |
5628 | dev->features & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX) ? | 5901 | dev->features & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX) ? |
5629 | "vlan " : "", | 5902 | "vlan " : "", |
5903 | dev->features & (NETIF_F_LOOPBACK) ? | ||
5904 | "loopback " : "", | ||
5630 | id->driver_data & DEV_HAS_POWER_CNTRL ? "pwrctl " : "", | 5905 | id->driver_data & DEV_HAS_POWER_CNTRL ? "pwrctl " : "", |
5631 | id->driver_data & DEV_HAS_MGMT_UNIT ? "mgmt " : "", | 5906 | id->driver_data & DEV_HAS_MGMT_UNIT ? "mgmt " : "", |
5632 | id->driver_data & DEV_NEED_TIMERIRQ ? "timirq " : "", | 5907 | id->driver_data & DEV_NEED_TIMERIRQ ? "timirq " : "", |
@@ -6000,6 +6275,9 @@ module_param(phy_cross, int, 0); | |||
6000 | MODULE_PARM_DESC(phy_cross, "Phy crossover detection for Realtek 8201 phy is enabled by setting to 1 and disabled by setting to 0."); | 6275 | MODULE_PARM_DESC(phy_cross, "Phy crossover detection for Realtek 8201 phy is enabled by setting to 1 and disabled by setting to 0."); |
6001 | module_param(phy_power_down, int, 0); | 6276 | module_param(phy_power_down, int, 0); |
6002 | MODULE_PARM_DESC(phy_power_down, "Power down phy and disable link when interface is down (1), or leave phy powered up (0)."); | 6277 | MODULE_PARM_DESC(phy_power_down, "Power down phy and disable link when interface is down (1), or leave phy powered up (0)."); |
6278 | module_param(debug_tx_timeout, bool, 0); | ||
6279 | MODULE_PARM_DESC(debug_tx_timeout, | ||
6280 | "Dump tx related registers and ring when tx_timeout happens"); | ||
6003 | 6281 | ||
6004 | MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>"); | 6282 | MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>"); |
6005 | MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver"); | 6283 | MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver"); |
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c index 8c8027176bef..0063194adb9e 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c | |||
@@ -161,10 +161,11 @@ static void pch_gbe_get_drvinfo(struct net_device *netdev, | |||
161 | { | 161 | { |
162 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); | 162 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); |
163 | 163 | ||
164 | strcpy(drvinfo->driver, KBUILD_MODNAME); | 164 | strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); |
165 | strcpy(drvinfo->version, pch_driver_version); | 165 | strlcpy(drvinfo->version, pch_driver_version, sizeof(drvinfo->version)); |
166 | strcpy(drvinfo->fw_version, "N/A"); | 166 | strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); |
167 | strcpy(drvinfo->bus_info, pci_name(adapter->pdev)); | 167 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
168 | sizeof(drvinfo->bus_info)); | ||
168 | drvinfo->regdump_len = pch_gbe_get_regs_len(netdev); | 169 | drvinfo->regdump_len = pch_gbe_get_regs_len(netdev); |
169 | } | 170 | } |
170 | 171 | ||
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index 48406ca382f1..964e9c0948bc 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | |||
@@ -2109,10 +2109,11 @@ static int pch_gbe_change_mtu(struct net_device *netdev, int new_mtu) | |||
2109 | * Returns | 2109 | * Returns |
2110 | * 0: HW state updated successfully | 2110 | * 0: HW state updated successfully |
2111 | */ | 2111 | */ |
2112 | static int pch_gbe_set_features(struct net_device *netdev, u32 features) | 2112 | static int pch_gbe_set_features(struct net_device *netdev, |
2113 | netdev_features_t features) | ||
2113 | { | 2114 | { |
2114 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); | 2115 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); |
2115 | u32 changed = features ^ netdev->features; | 2116 | netdev_features_t changed = features ^ netdev->features; |
2116 | 2117 | ||
2117 | if (!(changed & NETIF_F_RXCSUM)) | 2118 | if (!(changed & NETIF_F_RXCSUM)) |
2118 | return 0; | 2119 | return 0; |
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c index e09ea83b8c47..8a371985319f 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c | |||
@@ -83,14 +83,18 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
83 | u32 fw_minor = 0; | 83 | u32 fw_minor = 0; |
84 | u32 fw_build = 0; | 84 | u32 fw_build = 0; |
85 | 85 | ||
86 | strncpy(drvinfo->driver, netxen_nic_driver_name, 32); | 86 | strlcpy(drvinfo->driver, netxen_nic_driver_name, |
87 | strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); | 87 | sizeof(drvinfo->driver)); |
88 | strlcpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, | ||
89 | sizeof(drvinfo->version)); | ||
88 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); | 90 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); |
89 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); | 91 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); |
90 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); | 92 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); |
91 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); | 93 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), |
94 | "%d.%d.%d", fw_major, fw_minor, fw_build); | ||
92 | 95 | ||
93 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | 96 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
97 | sizeof(drvinfo->bus_info)); | ||
94 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; | 98 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; |
95 | drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev); | 99 | drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev); |
96 | } | 100 | } |
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 8cf3173ba488..7dd9a4b107e6 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | |||
@@ -544,7 +544,8 @@ static void netxen_set_multicast_list(struct net_device *dev) | |||
544 | adapter->set_multi(dev); | 544 | adapter->set_multi(dev); |
545 | } | 545 | } |
546 | 546 | ||
547 | static u32 netxen_fix_features(struct net_device *dev, u32 features) | 547 | static netdev_features_t netxen_fix_features(struct net_device *dev, |
548 | netdev_features_t features) | ||
548 | { | 549 | { |
549 | if (!(features & NETIF_F_RXCSUM)) { | 550 | if (!(features & NETIF_F_RXCSUM)) { |
550 | netdev_info(dev, "disabling LRO as RXCSUM is off\n"); | 551 | netdev_info(dev, "disabling LRO as RXCSUM is off\n"); |
@@ -555,7 +556,8 @@ static u32 netxen_fix_features(struct net_device *dev, u32 features) | |||
555 | return features; | 556 | return features; |
556 | } | 557 | } |
557 | 558 | ||
558 | static int netxen_set_features(struct net_device *dev, u32 features) | 559 | static int netxen_set_features(struct net_device *dev, |
560 | netdev_features_t features) | ||
559 | { | 561 | { |
560 | struct netxen_adapter *adapter = netdev_priv(dev); | 562 | struct netxen_adapter *adapter = netdev_priv(dev); |
561 | int hw_lro; | 563 | int hw_lro; |
diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c index a4bdff438a5e..9416f297100e 100644 --- a/drivers/net/ethernet/qlogic/qla3xxx.c +++ b/drivers/net/ethernet/qlogic/qla3xxx.c | |||
@@ -1735,10 +1735,12 @@ static void ql_get_drvinfo(struct net_device *ndev, | |||
1735 | struct ethtool_drvinfo *drvinfo) | 1735 | struct ethtool_drvinfo *drvinfo) |
1736 | { | 1736 | { |
1737 | struct ql3_adapter *qdev = netdev_priv(ndev); | 1737 | struct ql3_adapter *qdev = netdev_priv(ndev); |
1738 | strncpy(drvinfo->driver, ql3xxx_driver_name, 32); | 1738 | strlcpy(drvinfo->driver, ql3xxx_driver_name, sizeof(drvinfo->driver)); |
1739 | strncpy(drvinfo->version, ql3xxx_driver_version, 32); | 1739 | strlcpy(drvinfo->version, ql3xxx_driver_version, |
1740 | strncpy(drvinfo->fw_version, "N/A", 32); | 1740 | sizeof(drvinfo->version)); |
1741 | strncpy(drvinfo->bus_info, pci_name(qdev->pdev), 32); | 1741 | strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); |
1742 | strlcpy(drvinfo->bus_info, pci_name(qdev->pdev), | ||
1743 | sizeof(drvinfo->bus_info)); | ||
1742 | drvinfo->regdump_len = 0; | 1744 | drvinfo->regdump_len = 0; |
1743 | drvinfo->eedump_len = 0; | 1745 | drvinfo->eedump_len = 0; |
1744 | } | 1746 | } |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index 7ed53dbb8646..60976fc4ccc6 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | |||
@@ -1466,8 +1466,9 @@ void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup); | |||
1466 | 1466 | ||
1467 | int qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu); | 1467 | int qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu); |
1468 | int qlcnic_change_mtu(struct net_device *netdev, int new_mtu); | 1468 | int qlcnic_change_mtu(struct net_device *netdev, int new_mtu); |
1469 | u32 qlcnic_fix_features(struct net_device *netdev, u32 features); | 1469 | netdev_features_t qlcnic_fix_features(struct net_device *netdev, |
1470 | int qlcnic_set_features(struct net_device *netdev, u32 features); | 1470 | netdev_features_t features); |
1471 | int qlcnic_set_features(struct net_device *netdev, netdev_features_t features); | ||
1471 | int qlcnic_config_hw_lro(struct qlcnic_adapter *adapter, int enable); | 1472 | int qlcnic_config_hw_lro(struct qlcnic_adapter *adapter, int enable); |
1472 | int qlcnic_config_bridged_mode(struct qlcnic_adapter *adapter, u32 enable); | 1473 | int qlcnic_config_bridged_mode(struct qlcnic_adapter *adapter, u32 enable); |
1473 | int qlcnic_send_lro_cleanup(struct qlcnic_adapter *adapter); | 1474 | int qlcnic_send_lro_cleanup(struct qlcnic_adapter *adapter); |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 8aa1c6e8667b..cc228cf3d84b 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | |||
@@ -140,11 +140,14 @@ qlcnic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
140 | fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); | 140 | fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); |
141 | fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); | 141 | fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); |
142 | fw_build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB); | 142 | fw_build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB); |
143 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); | 143 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), |
144 | 144 | "%d.%d.%d", fw_major, fw_minor, fw_build); | |
145 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | 145 | |
146 | strlcpy(drvinfo->driver, qlcnic_driver_name, 32); | 146 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
147 | strlcpy(drvinfo->version, QLCNIC_LINUX_VERSIONID, 32); | 147 | sizeof(drvinfo->bus_info)); |
148 | strlcpy(drvinfo->driver, qlcnic_driver_name, sizeof(drvinfo->driver)); | ||
149 | strlcpy(drvinfo->version, QLCNIC_LINUX_VERSIONID, | ||
150 | sizeof(drvinfo->version)); | ||
148 | } | 151 | } |
149 | 152 | ||
150 | static int | 153 | static int |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c index bcb81e47543a..b528e52a8ee1 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c | |||
@@ -817,12 +817,13 @@ int qlcnic_change_mtu(struct net_device *netdev, int mtu) | |||
817 | } | 817 | } |
818 | 818 | ||
819 | 819 | ||
820 | u32 qlcnic_fix_features(struct net_device *netdev, u32 features) | 820 | netdev_features_t qlcnic_fix_features(struct net_device *netdev, |
821 | netdev_features_t features) | ||
821 | { | 822 | { |
822 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 823 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
823 | 824 | ||
824 | if ((adapter->flags & QLCNIC_ESWITCH_ENABLED)) { | 825 | if ((adapter->flags & QLCNIC_ESWITCH_ENABLED)) { |
825 | u32 changed = features ^ netdev->features; | 826 | netdev_features_t changed = features ^ netdev->features; |
826 | features ^= changed & (NETIF_F_ALL_CSUM | NETIF_F_RXCSUM); | 827 | features ^= changed & (NETIF_F_ALL_CSUM | NETIF_F_RXCSUM); |
827 | } | 828 | } |
828 | 829 | ||
@@ -833,10 +834,10 @@ u32 qlcnic_fix_features(struct net_device *netdev, u32 features) | |||
833 | } | 834 | } |
834 | 835 | ||
835 | 836 | ||
836 | int qlcnic_set_features(struct net_device *netdev, u32 features) | 837 | int qlcnic_set_features(struct net_device *netdev, netdev_features_t features) |
837 | { | 838 | { |
838 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 839 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
839 | u32 changed = netdev->features ^ features; | 840 | netdev_features_t changed = netdev->features ^ features; |
840 | int hw_lro = (features & NETIF_F_LRO) ? QLCNIC_LRO_ENABLED : 0; | 841 | int hw_lro = (features & NETIF_F_LRO) ? QLCNIC_LRO_ENABLED : 0; |
841 | 842 | ||
842 | if (!(changed & NETIF_F_LRO)) | 843 | if (!(changed & NETIF_F_LRO)) |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 0bd163828e33..823f845ddc04 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
@@ -792,7 +792,7 @@ qlcnic_set_netdev_features(struct qlcnic_adapter *adapter, | |||
792 | struct qlcnic_esw_func_cfg *esw_cfg) | 792 | struct qlcnic_esw_func_cfg *esw_cfg) |
793 | { | 793 | { |
794 | struct net_device *netdev = adapter->netdev; | 794 | struct net_device *netdev = adapter->netdev; |
795 | unsigned long features, vlan_features; | 795 | netdev_features_t features, vlan_features; |
796 | 796 | ||
797 | features = (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM | | 797 | features = (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM | |
798 | NETIF_F_IPV6_CSUM | NETIF_F_GRO); | 798 | NETIF_F_IPV6_CSUM | NETIF_F_GRO); |
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c b/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c index 9b67bfea035f..8e2c2a74f3a5 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c | |||
@@ -366,13 +366,16 @@ static void ql_get_drvinfo(struct net_device *ndev, | |||
366 | struct ethtool_drvinfo *drvinfo) | 366 | struct ethtool_drvinfo *drvinfo) |
367 | { | 367 | { |
368 | struct ql_adapter *qdev = netdev_priv(ndev); | 368 | struct ql_adapter *qdev = netdev_priv(ndev); |
369 | strncpy(drvinfo->driver, qlge_driver_name, 32); | 369 | strlcpy(drvinfo->driver, qlge_driver_name, sizeof(drvinfo->driver)); |
370 | strncpy(drvinfo->version, qlge_driver_version, 32); | 370 | strlcpy(drvinfo->version, qlge_driver_version, |
371 | snprintf(drvinfo->fw_version, 32, "v%d.%d.%d", | 371 | sizeof(drvinfo->version)); |
372 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), | ||
373 | "v%d.%d.%d", | ||
372 | (qdev->fw_rev_id & 0x00ff0000) >> 16, | 374 | (qdev->fw_rev_id & 0x00ff0000) >> 16, |
373 | (qdev->fw_rev_id & 0x0000ff00) >> 8, | 375 | (qdev->fw_rev_id & 0x0000ff00) >> 8, |
374 | (qdev->fw_rev_id & 0x000000ff)); | 376 | (qdev->fw_rev_id & 0x000000ff)); |
375 | strncpy(drvinfo->bus_info, pci_name(qdev->pdev), 32); | 377 | strlcpy(drvinfo->bus_info, pci_name(qdev->pdev), |
378 | sizeof(drvinfo->bus_info)); | ||
376 | drvinfo->n_stats = 0; | 379 | drvinfo->n_stats = 0; |
377 | drvinfo->testinfo_len = 0; | 380 | drvinfo->testinfo_len = 0; |
378 | if (!test_bit(QL_FRC_COREDUMP, &qdev->flags)) | 381 | if (!test_bit(QL_FRC_COREDUMP, &qdev->flags)) |
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c index c92afcd912e2..1ce4e08037b8 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c | |||
@@ -2307,7 +2307,7 @@ static int ql_napi_poll_msix(struct napi_struct *napi, int budget) | |||
2307 | return work_done; | 2307 | return work_done; |
2308 | } | 2308 | } |
2309 | 2309 | ||
2310 | static void qlge_vlan_mode(struct net_device *ndev, u32 features) | 2310 | static void qlge_vlan_mode(struct net_device *ndev, netdev_features_t features) |
2311 | { | 2311 | { |
2312 | struct ql_adapter *qdev = netdev_priv(ndev); | 2312 | struct ql_adapter *qdev = netdev_priv(ndev); |
2313 | 2313 | ||
@@ -2323,7 +2323,8 @@ static void qlge_vlan_mode(struct net_device *ndev, u32 features) | |||
2323 | } | 2323 | } |
2324 | } | 2324 | } |
2325 | 2325 | ||
2326 | static u32 qlge_fix_features(struct net_device *ndev, u32 features) | 2326 | static netdev_features_t qlge_fix_features(struct net_device *ndev, |
2327 | netdev_features_t features) | ||
2327 | { | 2328 | { |
2328 | /* | 2329 | /* |
2329 | * Since there is no support for separate rx/tx vlan accel | 2330 | * Since there is no support for separate rx/tx vlan accel |
@@ -2337,9 +2338,10 @@ static u32 qlge_fix_features(struct net_device *ndev, u32 features) | |||
2337 | return features; | 2338 | return features; |
2338 | } | 2339 | } |
2339 | 2340 | ||
2340 | static int qlge_set_features(struct net_device *ndev, u32 features) | 2341 | static int qlge_set_features(struct net_device *ndev, |
2342 | netdev_features_t features) | ||
2341 | { | 2343 | { |
2342 | u32 changed = ndev->features ^ features; | 2344 | netdev_features_t changed = ndev->features ^ features; |
2343 | 2345 | ||
2344 | if (changed & NETIF_F_HW_VLAN_RX) | 2346 | if (changed & NETIF_F_HW_VLAN_RX) |
2345 | qlge_vlan_mode(ndev, features); | 2347 | qlge_vlan_mode(ndev, features); |
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index ee5da9293ce0..87cff10f7be7 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c | |||
@@ -1319,9 +1319,9 @@ static void cp_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info | |||
1319 | { | 1319 | { |
1320 | struct cp_private *cp = netdev_priv(dev); | 1320 | struct cp_private *cp = netdev_priv(dev); |
1321 | 1321 | ||
1322 | strcpy (info->driver, DRV_NAME); | 1322 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1323 | strcpy (info->version, DRV_VERSION); | 1323 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1324 | strcpy (info->bus_info, pci_name(cp->pdev)); | 1324 | strlcpy(info->bus_info, pci_name(cp->pdev), sizeof(info->bus_info)); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | static void cp_get_ringparam(struct net_device *dev, | 1327 | static void cp_get_ringparam(struct net_device *dev, |
@@ -1392,7 +1392,7 @@ static void cp_set_msglevel(struct net_device *dev, u32 value) | |||
1392 | cp->msg_enable = value; | 1392 | cp->msg_enable = value; |
1393 | } | 1393 | } |
1394 | 1394 | ||
1395 | static int cp_set_features(struct net_device *dev, u32 features) | 1395 | static int cp_set_features(struct net_device *dev, netdev_features_t features) |
1396 | { | 1396 | { |
1397 | struct cp_private *cp = netdev_priv(dev); | 1397 | struct cp_private *cp = netdev_priv(dev); |
1398 | unsigned long flags; | 1398 | unsigned long flags; |
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index 4d6b254fc6c1..d9c72273e428 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c | |||
@@ -2330,9 +2330,9 @@ static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
2330 | static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 2330 | static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
2331 | { | 2331 | { |
2332 | struct rtl8139_private *tp = netdev_priv(dev); | 2332 | struct rtl8139_private *tp = netdev_priv(dev); |
2333 | strcpy(info->driver, DRV_NAME); | 2333 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
2334 | strcpy(info->version, DRV_VERSION); | 2334 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
2335 | strcpy(info->bus_info, pci_name(tp->pci_dev)); | 2335 | strlcpy(info->bus_info, pci_name(tp->pci_dev), sizeof(info->bus_info)); |
2336 | info->regdump_len = tp->regs_len; | 2336 | info->regdump_len = tp->regs_len; |
2337 | } | 2337 | } |
2338 | 2338 | ||
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 6f06aa10f0d7..f7bc310f5185 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
@@ -69,9 +69,6 @@ | |||
69 | The RTL chips use a 64 element hash table based on the Ethernet CRC. */ | 69 | The RTL chips use a 64 element hash table based on the Ethernet CRC. */ |
70 | static const int multicast_filter_limit = 32; | 70 | static const int multicast_filter_limit = 32; |
71 | 71 | ||
72 | /* MAC address length */ | ||
73 | #define MAC_ADDR_LEN 6 | ||
74 | |||
75 | #define MAX_READ_REQUEST_SHIFT 12 | 72 | #define MAX_READ_REQUEST_SHIFT 12 |
76 | #define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ | 73 | #define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ |
77 | #define SafeMtu 0x1c20 /* ... actually life sucks beyond ~7k */ | 74 | #define SafeMtu 0x1c20 /* ... actually life sucks beyond ~7k */ |
@@ -1404,12 +1401,12 @@ static void rtl8169_get_drvinfo(struct net_device *dev, | |||
1404 | struct rtl8169_private *tp = netdev_priv(dev); | 1401 | struct rtl8169_private *tp = netdev_priv(dev); |
1405 | struct rtl_fw *rtl_fw = tp->rtl_fw; | 1402 | struct rtl_fw *rtl_fw = tp->rtl_fw; |
1406 | 1403 | ||
1407 | strcpy(info->driver, MODULENAME); | 1404 | strlcpy(info->driver, MODULENAME, sizeof(info->driver)); |
1408 | strcpy(info->version, RTL8169_VERSION); | 1405 | strlcpy(info->version, RTL8169_VERSION, sizeof(info->version)); |
1409 | strcpy(info->bus_info, pci_name(tp->pci_dev)); | 1406 | strlcpy(info->bus_info, pci_name(tp->pci_dev), sizeof(info->bus_info)); |
1410 | BUILD_BUG_ON(sizeof(info->fw_version) < sizeof(rtl_fw->version)); | 1407 | BUILD_BUG_ON(sizeof(info->fw_version) < sizeof(rtl_fw->version)); |
1411 | strcpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" : | 1408 | strlcpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" : |
1412 | rtl_fw->version); | 1409 | rtl_fw->version, sizeof(info->fw_version)); |
1413 | } | 1410 | } |
1414 | 1411 | ||
1415 | static int rtl8169_get_regs_len(struct net_device *dev) | 1412 | static int rtl8169_get_regs_len(struct net_device *dev) |
@@ -1553,7 +1550,8 @@ static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1553 | return ret; | 1550 | return ret; |
1554 | } | 1551 | } |
1555 | 1552 | ||
1556 | static u32 rtl8169_fix_features(struct net_device *dev, u32 features) | 1553 | static netdev_features_t rtl8169_fix_features(struct net_device *dev, |
1554 | netdev_features_t features) | ||
1557 | { | 1555 | { |
1558 | struct rtl8169_private *tp = netdev_priv(dev); | 1556 | struct rtl8169_private *tp = netdev_priv(dev); |
1559 | 1557 | ||
@@ -1567,7 +1565,8 @@ static u32 rtl8169_fix_features(struct net_device *dev, u32 features) | |||
1567 | return features; | 1565 | return features; |
1568 | } | 1566 | } |
1569 | 1567 | ||
1570 | static int rtl8169_set_features(struct net_device *dev, u32 features) | 1568 | static int rtl8169_set_features(struct net_device *dev, |
1569 | netdev_features_t features) | ||
1571 | { | 1570 | { |
1572 | struct rtl8169_private *tp = netdev_priv(dev); | 1571 | struct rtl8169_private *tp = netdev_priv(dev); |
1573 | void __iomem *ioaddr = tp->mmio_addr; | 1572 | void __iomem *ioaddr = tp->mmio_addr; |
@@ -4099,7 +4098,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
4099 | spin_lock_init(&tp->lock); | 4098 | spin_lock_init(&tp->lock); |
4100 | 4099 | ||
4101 | /* Get MAC address */ | 4100 | /* Get MAC address */ |
4102 | for (i = 0; i < MAC_ADDR_LEN; i++) | 4101 | for (i = 0; i < ETH_ALEN; i++) |
4103 | dev->dev_addr[i] = RTL_R8(MAC0 + i); | 4102 | dev->dev_addr[i] = RTL_R8(MAC0 + i); |
4104 | memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); | 4103 | memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); |
4105 | 4104 | ||
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index d5731f1fe6d6..14e134d3b4d7 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c | |||
@@ -1900,7 +1900,7 @@ static void efx_set_multicast_list(struct net_device *net_dev) | |||
1900 | /* Otherwise efx_start_port() will do this */ | 1900 | /* Otherwise efx_start_port() will do this */ |
1901 | } | 1901 | } |
1902 | 1902 | ||
1903 | static int efx_set_features(struct net_device *net_dev, u32 data) | 1903 | static int efx_set_features(struct net_device *net_dev, netdev_features_t data) |
1904 | { | 1904 | { |
1905 | struct efx_nic *efx = netdev_priv(net_dev); | 1905 | struct efx_nic *efx = netdev_priv(net_dev); |
1906 | 1906 | ||
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index b8e251a1ee48..c49502bab6a3 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
@@ -908,7 +908,7 @@ struct efx_nic_type { | |||
908 | unsigned int phys_addr_channels; | 908 | unsigned int phys_addr_channels; |
909 | unsigned int tx_dc_base; | 909 | unsigned int tx_dc_base; |
910 | unsigned int rx_dc_base; | 910 | unsigned int rx_dc_base; |
911 | u32 offload_features; | 911 | netdev_features_t offload_features; |
912 | }; | 912 | }; |
913 | 913 | ||
914 | /************************************************************************** | 914 | /************************************************************************** |
diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c index 1b4658c99391..5b118cd5bf94 100644 --- a/drivers/net/ethernet/sis/sis190.c +++ b/drivers/net/ethernet/sis/sis190.c | |||
@@ -47,8 +47,6 @@ | |||
47 | #define sis190_rx_skb netif_rx | 47 | #define sis190_rx_skb netif_rx |
48 | #define sis190_rx_quota(count, quota) count | 48 | #define sis190_rx_quota(count, quota) count |
49 | 49 | ||
50 | #define MAC_ADDR_LEN 6 | ||
51 | |||
52 | #define NUM_TX_DESC 64 /* [8..1024] */ | 50 | #define NUM_TX_DESC 64 /* [8..1024] */ |
53 | #define NUM_RX_DESC 64 /* [8..8192] */ | 51 | #define NUM_RX_DESC 64 /* [8..8192] */ |
54 | #define TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc)) | 52 | #define TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc)) |
@@ -1601,7 +1599,7 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev, | |||
1601 | } | 1599 | } |
1602 | 1600 | ||
1603 | /* Get MAC address from EEPROM */ | 1601 | /* Get MAC address from EEPROM */ |
1604 | for (i = 0; i < MAC_ADDR_LEN / 2; i++) { | 1602 | for (i = 0; i < ETH_ALEN / 2; i++) { |
1605 | u16 w = sis190_read_eeprom(ioaddr, EEPROMMACAddr + i); | 1603 | u16 w = sis190_read_eeprom(ioaddr, EEPROMMACAddr + i); |
1606 | 1604 | ||
1607 | ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(w); | 1605 | ((__le16 *)dev->dev_addr)[i] = cpu_to_le16(w); |
@@ -1653,7 +1651,7 @@ static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev, | |||
1653 | udelay(50); | 1651 | udelay(50); |
1654 | pci_read_config_byte(isa_bridge, 0x48, ®); | 1652 | pci_read_config_byte(isa_bridge, 0x48, ®); |
1655 | 1653 | ||
1656 | for (i = 0; i < MAC_ADDR_LEN; i++) { | 1654 | for (i = 0; i < ETH_ALEN; i++) { |
1657 | outb(0x9 + i, 0x78); | 1655 | outb(0x9 + i, 0x78); |
1658 | dev->dev_addr[i] = inb(0x79); | 1656 | dev->dev_addr[i] = inb(0x79); |
1659 | } | 1657 | } |
@@ -1692,7 +1690,7 @@ static inline void sis190_init_rxfilter(struct net_device *dev) | |||
1692 | */ | 1690 | */ |
1693 | SIS_W16(RxMacControl, ctl & ~0x0f00); | 1691 | SIS_W16(RxMacControl, ctl & ~0x0f00); |
1694 | 1692 | ||
1695 | for (i = 0; i < MAC_ADDR_LEN; i++) | 1693 | for (i = 0; i < ETH_ALEN; i++) |
1696 | SIS_W8(RxMacAddr + i, dev->dev_addr[i]); | 1694 | SIS_W8(RxMacAddr + i, dev->dev_addr[i]); |
1697 | 1695 | ||
1698 | SIS_W16(RxMacControl, ctl); | 1696 | SIS_W16(RxMacControl, ctl); |
@@ -1760,9 +1758,10 @@ static void sis190_get_drvinfo(struct net_device *dev, | |||
1760 | { | 1758 | { |
1761 | struct sis190_private *tp = netdev_priv(dev); | 1759 | struct sis190_private *tp = netdev_priv(dev); |
1762 | 1760 | ||
1763 | strcpy(info->driver, DRV_NAME); | 1761 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1764 | strcpy(info->version, DRV_VERSION); | 1762 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1765 | strcpy(info->bus_info, pci_name(tp->pci_dev)); | 1763 | strlcpy(info->bus_info, pci_name(tp->pci_dev), |
1764 | sizeof(info->bus_info)); | ||
1766 | } | 1765 | } |
1767 | 1766 | ||
1768 | static int sis190_get_regs_len(struct net_device *dev) | 1767 | static int sis190_get_regs_len(struct net_device *dev) |
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index a184abc5ef11..c8efc708c792 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c | |||
@@ -1991,9 +1991,10 @@ static void sis900_get_drvinfo(struct net_device *net_dev, | |||
1991 | { | 1991 | { |
1992 | struct sis900_private *sis_priv = netdev_priv(net_dev); | 1992 | struct sis900_private *sis_priv = netdev_priv(net_dev); |
1993 | 1993 | ||
1994 | strcpy (info->driver, SIS900_MODULE_NAME); | 1994 | strlcpy(info->driver, SIS900_MODULE_NAME, sizeof(info->driver)); |
1995 | strcpy (info->version, SIS900_DRV_VERSION); | 1995 | strlcpy(info->version, SIS900_DRV_VERSION, sizeof(info->version)); |
1996 | strcpy (info->bus_info, pci_name(sis_priv->pci_dev)); | 1996 | strlcpy(info->bus_info, pci_name(sis_priv->pci_dev), |
1997 | sizeof(info->bus_info)); | ||
1997 | } | 1998 | } |
1998 | 1999 | ||
1999 | static u32 sis900_get_msglevel(struct net_device *net_dev) | 2000 | static u32 sis900_get_msglevel(struct net_device *net_dev) |
diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c index 0a5dfb814157..2c077ce0b6d6 100644 --- a/drivers/net/ethernet/smsc/epic100.c +++ b/drivers/net/ethernet/smsc/epic100.c | |||
@@ -1414,9 +1414,9 @@ static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo * | |||
1414 | { | 1414 | { |
1415 | struct epic_private *np = netdev_priv(dev); | 1415 | struct epic_private *np = netdev_priv(dev); |
1416 | 1416 | ||
1417 | strcpy (info->driver, DRV_NAME); | 1417 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1418 | strcpy (info->version, DRV_VERSION); | 1418 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1419 | strcpy (info->bus_info, pci_name(np->pci_dev)); | 1419 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
1420 | } | 1420 | } |
1421 | 1421 | ||
1422 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1422 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
diff --git a/drivers/net/ethernet/smsc/smc91c92_cs.c b/drivers/net/ethernet/smsc/smc91c92_cs.c index cbfa98187131..ada927aba7a5 100644 --- a/drivers/net/ethernet/smsc/smc91c92_cs.c +++ b/drivers/net/ethernet/smsc/smc91c92_cs.c | |||
@@ -1909,8 +1909,8 @@ static int check_if_running(struct net_device *dev) | |||
1909 | 1909 | ||
1910 | static void smc_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1910 | static void smc_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1911 | { | 1911 | { |
1912 | strcpy(info->driver, DRV_NAME); | 1912 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1913 | strcpy(info->version, DRV_VERSION); | 1913 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | static int smc_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 1916 | static int smc_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c index edb24b0e337b..a9efbdfe5302 100644 --- a/drivers/net/ethernet/smsc/smsc9420.c +++ b/drivers/net/ethernet/smsc/smsc9420.c | |||
@@ -279,9 +279,10 @@ static void smsc9420_ethtool_get_drvinfo(struct net_device *netdev, | |||
279 | { | 279 | { |
280 | struct smsc9420_pdata *pd = netdev_priv(netdev); | 280 | struct smsc9420_pdata *pd = netdev_priv(netdev); |
281 | 281 | ||
282 | strcpy(drvinfo->driver, DRV_NAME); | 282 | strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); |
283 | strcpy(drvinfo->bus_info, pci_name(pd->pdev)); | 283 | strlcpy(drvinfo->bus_info, pci_name(pd->pdev), |
284 | strcpy(drvinfo->version, DRV_VERSION); | 284 | sizeof(drvinfo->bus_info)); |
285 | strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); | ||
285 | } | 286 | } |
286 | 287 | ||
287 | static u32 smsc9420_ethtool_get_msglevel(struct net_device *netdev) | 288 | static u32 smsc9420_ethtool_get_msglevel(struct net_device *netdev) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 0395f9eba801..ed83c4c47b8a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | |||
@@ -185,9 +185,10 @@ static void stmmac_ethtool_getdrvinfo(struct net_device *dev, | |||
185 | struct stmmac_priv *priv = netdev_priv(dev); | 185 | struct stmmac_priv *priv = netdev_priv(dev); |
186 | 186 | ||
187 | if (priv->plat->has_gmac) | 187 | if (priv->plat->has_gmac) |
188 | strcpy(info->driver, GMAC_ETHTOOL_NAME); | 188 | strlcpy(info->driver, GMAC_ETHTOOL_NAME, sizeof(info->driver)); |
189 | else | 189 | else |
190 | strcpy(info->driver, MAC100_ETHTOOL_NAME); | 190 | strlcpy(info->driver, MAC100_ETHTOOL_NAME, |
191 | sizeof(info->driver)); | ||
191 | 192 | ||
192 | strcpy(info->version, DRV_MODULE_VERSION); | 193 | strcpy(info->version, DRV_MODULE_VERSION); |
193 | info->fw_version[0] = '\0'; | 194 | info->fw_version[0] = '\0'; |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 8ea770a89f25..de71859bb295 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
@@ -1466,7 +1466,8 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) | |||
1466 | return 0; | 1466 | return 0; |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | static u32 stmmac_fix_features(struct net_device *dev, u32 features) | 1469 | static netdev_features_t stmmac_fix_features(struct net_device *dev, |
1470 | netdev_features_t features) | ||
1470 | { | 1471 | { |
1471 | struct stmmac_priv *priv = netdev_priv(dev); | 1472 | struct stmmac_priv *priv = netdev_priv(dev); |
1472 | 1473 | ||
diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index fd40988c19a6..f10665f594c4 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c | |||
@@ -4532,10 +4532,9 @@ static void cas_set_multicast(struct net_device *dev) | |||
4532 | static void cas_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 4532 | static void cas_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
4533 | { | 4533 | { |
4534 | struct cas *cp = netdev_priv(dev); | 4534 | struct cas *cp = netdev_priv(dev); |
4535 | strncpy(info->driver, DRV_MODULE_NAME, ETHTOOL_BUSINFO_LEN); | 4535 | strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); |
4536 | strncpy(info->version, DRV_MODULE_VERSION, ETHTOOL_BUSINFO_LEN); | 4536 | strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); |
4537 | info->fw_version[0] = '\0'; | 4537 | strlcpy(info->bus_info, pci_name(cp->pdev), sizeof(info->bus_info)); |
4538 | strncpy(info->bus_info, pci_name(cp->pdev), ETHTOOL_BUSINFO_LEN); | ||
4539 | info->regdump_len = cp->casreg_len < CAS_MAX_REGS ? | 4538 | info->regdump_len = cp->casreg_len < CAS_MAX_REGS ? |
4540 | cp->casreg_len : CAS_MAX_REGS; | 4539 | cp->casreg_len : CAS_MAX_REGS; |
4541 | info->n_stats = CAS_NUM_STAT_KEYS; | 4540 | info->n_stats = CAS_NUM_STAT_KEYS; |
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index 73c708107a37..9997be525089 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c | |||
@@ -1151,19 +1151,8 @@ static int link_status_mii(struct niu *np, int *link_up_p) | |||
1151 | supported |= SUPPORTED_1000baseT_Full; | 1151 | supported |= SUPPORTED_1000baseT_Full; |
1152 | lp->supported = supported; | 1152 | lp->supported = supported; |
1153 | 1153 | ||
1154 | advertising = 0; | 1154 | advertising = mii_adv_to_ethtool_100bt(advert); |
1155 | if (advert & ADVERTISE_10HALF) | 1155 | advertising |= mii_adv_to_ethtool_1000T(ctrl1000); |
1156 | advertising |= ADVERTISED_10baseT_Half; | ||
1157 | if (advert & ADVERTISE_10FULL) | ||
1158 | advertising |= ADVERTISED_10baseT_Full; | ||
1159 | if (advert & ADVERTISE_100HALF) | ||
1160 | advertising |= ADVERTISED_100baseT_Half; | ||
1161 | if (advert & ADVERTISE_100FULL) | ||
1162 | advertising |= ADVERTISED_100baseT_Full; | ||
1163 | if (ctrl1000 & ADVERTISE_1000HALF) | ||
1164 | advertising |= ADVERTISED_1000baseT_Half; | ||
1165 | if (ctrl1000 & ADVERTISE_1000FULL) | ||
1166 | advertising |= ADVERTISED_1000baseT_Full; | ||
1167 | 1156 | ||
1168 | if (bmcr & BMCR_ANENABLE) { | 1157 | if (bmcr & BMCR_ANENABLE) { |
1169 | int neg, neg1000; | 1158 | int neg, neg1000; |
@@ -6823,12 +6812,13 @@ static void niu_get_drvinfo(struct net_device *dev, | |||
6823 | struct niu *np = netdev_priv(dev); | 6812 | struct niu *np = netdev_priv(dev); |
6824 | struct niu_vpd *vpd = &np->vpd; | 6813 | struct niu_vpd *vpd = &np->vpd; |
6825 | 6814 | ||
6826 | strcpy(info->driver, DRV_MODULE_NAME); | 6815 | strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); |
6827 | strcpy(info->version, DRV_MODULE_VERSION); | 6816 | strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); |
6828 | sprintf(info->fw_version, "%d.%d", | 6817 | snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d", |
6829 | vpd->fcode_major, vpd->fcode_minor); | 6818 | vpd->fcode_major, vpd->fcode_minor); |
6830 | if (np->parent->plat_type != PLAT_TYPE_NIU) | 6819 | if (np->parent->plat_type != PLAT_TYPE_NIU) |
6831 | strcpy(info->bus_info, pci_name(np->pdev)); | 6820 | strlcpy(info->bus_info, pci_name(np->pdev), |
6821 | sizeof(info->bus_info)); | ||
6832 | } | 6822 | } |
6833 | 6823 | ||
6834 | static int niu_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 6824 | static int niu_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c index ceab215bb4a3..31441a870b0b 100644 --- a/drivers/net/ethernet/sun/sungem.c +++ b/drivers/net/ethernet/sun/sungem.c | |||
@@ -2517,9 +2517,9 @@ static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
2517 | { | 2517 | { |
2518 | struct gem *gp = netdev_priv(dev); | 2518 | struct gem *gp = netdev_priv(dev); |
2519 | 2519 | ||
2520 | strcpy(info->driver, DRV_NAME); | 2520 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
2521 | strcpy(info->version, DRV_VERSION); | 2521 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
2522 | strcpy(info->bus_info, pci_name(gp->pdev)); | 2522 | strlcpy(info->bus_info, pci_name(gp->pdev), sizeof(info->bus_info)); |
2523 | } | 2523 | } |
2524 | 2524 | ||
2525 | static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 2525 | static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index cf14ab9db576..eebd52f10365 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c | |||
@@ -2457,11 +2457,11 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
2457 | { | 2457 | { |
2458 | struct happy_meal *hp = netdev_priv(dev); | 2458 | struct happy_meal *hp = netdev_priv(dev); |
2459 | 2459 | ||
2460 | strcpy(info->driver, "sunhme"); | 2460 | strlcpy(info->driver, "sunhme", sizeof(info->driver)); |
2461 | strcpy(info->version, "2.02"); | 2461 | strlcpy(info->version, "2.02", sizeof(info->version)); |
2462 | if (hp->happy_flags & HFLAG_PCI) { | 2462 | if (hp->happy_flags & HFLAG_PCI) { |
2463 | struct pci_dev *pdev = hp->happy_dev; | 2463 | struct pci_dev *pdev = hp->happy_dev; |
2464 | strcpy(info->bus_info, pci_name(pdev)); | 2464 | strlcpy(info->bus_info, pci_name(pdev), sizeof(info->bus_info)); |
2465 | } | 2465 | } |
2466 | #ifdef CONFIG_SBUS | 2466 | #ifdef CONFIG_SBUS |
2467 | else { | 2467 | else { |
@@ -2469,7 +2469,8 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
2469 | struct platform_device *op = hp->happy_dev; | 2469 | struct platform_device *op = hp->happy_dev; |
2470 | regs = of_get_property(op->dev.of_node, "regs", NULL); | 2470 | regs = of_get_property(op->dev.of_node, "regs", NULL); |
2471 | if (regs) | 2471 | if (regs) |
2472 | sprintf(info->bus_info, "SBUS:%d", | 2472 | snprintf(info->bus_info, sizeof(info->bus_info), |
2473 | "SBUS:%d", | ||
2473 | regs->which_io); | 2474 | regs->which_io); |
2474 | } | 2475 | } |
2475 | #endif | 2476 | #endif |
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index f34dd99fe579..5587ecdf32e3 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c | |||
@@ -2009,9 +2009,9 @@ static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i | |||
2009 | { | 2009 | { |
2010 | struct rhine_private *rp = netdev_priv(dev); | 2010 | struct rhine_private *rp = netdev_priv(dev); |
2011 | 2011 | ||
2012 | strcpy(info->driver, DRV_NAME); | 2012 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
2013 | strcpy(info->version, DRV_VERSION); | 2013 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
2014 | strcpy(info->bus_info, pci_name(rp->pdev)); | 2014 | strlcpy(info->bus_info, pci_name(rp->pdev), sizeof(info->bus_info)); |
2015 | } | 2015 | } |
2016 | 2016 | ||
2017 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 2017 | static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c index 4535d7cc848e..59bb5fd56afe 100644 --- a/drivers/net/ethernet/via/via-velocity.c +++ b/drivers/net/ethernet/via/via-velocity.c | |||
@@ -3270,9 +3270,9 @@ static int velocity_set_settings(struct net_device *dev, | |||
3270 | static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 3270 | static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
3271 | { | 3271 | { |
3272 | struct velocity_info *vptr = netdev_priv(dev); | 3272 | struct velocity_info *vptr = netdev_priv(dev); |
3273 | strcpy(info->driver, VELOCITY_NAME); | 3273 | strlcpy(info->driver, VELOCITY_NAME, sizeof(info->driver)); |
3274 | strcpy(info->version, VELOCITY_VERSION); | 3274 | strlcpy(info->version, VELOCITY_VERSION, sizeof(info->version)); |
3275 | strcpy(info->bus_info, pci_name(vptr->pdev)); | 3275 | strlcpy(info->bus_info, pci_name(vptr->pdev), sizeof(info->bus_info)); |
3276 | } | 3276 | } |
3277 | 3277 | ||
3278 | static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | 3278 | static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index 2681b53820ee..1ade9e18d299 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c | |||
@@ -920,12 +920,26 @@ temac_poll_controller(struct net_device *ndev) | |||
920 | } | 920 | } |
921 | #endif | 921 | #endif |
922 | 922 | ||
923 | static int temac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) | ||
924 | { | ||
925 | struct temac_local *lp = netdev_priv(ndev); | ||
926 | |||
927 | if (!netif_running(ndev)) | ||
928 | return -EINVAL; | ||
929 | |||
930 | if (!lp->phy_dev) | ||
931 | return -EINVAL; | ||
932 | |||
933 | return phy_mii_ioctl(lp->phy_dev, rq, cmd); | ||
934 | } | ||
935 | |||
923 | static const struct net_device_ops temac_netdev_ops = { | 936 | static const struct net_device_ops temac_netdev_ops = { |
924 | .ndo_open = temac_open, | 937 | .ndo_open = temac_open, |
925 | .ndo_stop = temac_stop, | 938 | .ndo_stop = temac_stop, |
926 | .ndo_start_xmit = temac_start_xmit, | 939 | .ndo_start_xmit = temac_start_xmit, |
927 | .ndo_set_mac_address = netdev_set_mac_address, | 940 | .ndo_set_mac_address = netdev_set_mac_address, |
928 | .ndo_validate_addr = eth_validate_addr, | 941 | .ndo_validate_addr = eth_validate_addr, |
942 | .ndo_do_ioctl = temac_ioctl, | ||
929 | #ifdef CONFIG_NET_POLL_CONTROLLER | 943 | #ifdef CONFIG_NET_POLL_CONTROLLER |
930 | .ndo_poll_controller = temac_poll_controller, | 944 | .ndo_poll_controller = temac_poll_controller, |
931 | #endif | 945 | #endif |
diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c index bbe8b7dbf3f3..33979c3ac943 100644 --- a/drivers/net/ethernet/xircom/xirc2ps_cs.c +++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c | |||
@@ -1411,7 +1411,7 @@ do_open(struct net_device *dev) | |||
1411 | static void netdev_get_drvinfo(struct net_device *dev, | 1411 | static void netdev_get_drvinfo(struct net_device *dev, |
1412 | struct ethtool_drvinfo *info) | 1412 | struct ethtool_drvinfo *info) |
1413 | { | 1413 | { |
1414 | strcpy(info->driver, "xirc2ps_cs"); | 1414 | strlcpy(info->driver, "xirc2ps_cs", sizeof(info->driver)); |
1415 | sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); | 1415 | sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); |
1416 | } | 1416 | } |
1417 | 1417 | ||
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index 46b5f5fd686b..e05b645bbc32 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c | |||
@@ -164,7 +164,7 @@ static const struct net_device_ops ifb_netdev_ops = { | |||
164 | .ndo_validate_addr = eth_validate_addr, | 164 | .ndo_validate_addr = eth_validate_addr, |
165 | }; | 165 | }; |
166 | 166 | ||
167 | #define IFB_FEATURES (NETIF_F_NO_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST | \ | 167 | #define IFB_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST | \ |
168 | NETIF_F_TSO_ECN | NETIF_F_TSO | NETIF_F_TSO6 | \ | 168 | NETIF_F_TSO_ECN | NETIF_F_TSO | NETIF_F_TSO6 | \ |
169 | NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_TX) | 169 | NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_TX) |
170 | 170 | ||
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 4ce9e5f2c069..b71998d0b5b4 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -169,7 +169,7 @@ static void loopback_setup(struct net_device *dev) | |||
169 | dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | 169 | dev->features = NETIF_F_SG | NETIF_F_FRAGLIST |
170 | | NETIF_F_ALL_TSO | 170 | | NETIF_F_ALL_TSO |
171 | | NETIF_F_UFO | 171 | | NETIF_F_UFO |
172 | | NETIF_F_NO_CSUM | 172 | | NETIF_F_HW_CSUM |
173 | | NETIF_F_RXCSUM | 173 | | NETIF_F_RXCSUM |
174 | | NETIF_F_HIGHDMA | 174 | | NETIF_F_HIGHDMA |
175 | | NETIF_F_LLTX | 175 | | NETIF_F_LLTX |
diff --git a/drivers/net/mii.c b/drivers/net/mii.c index c62e7816d548..d0a296272713 100644 --- a/drivers/net/mii.c +++ b/drivers/net/mii.c | |||
@@ -41,20 +41,8 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr) | |||
41 | advert = mii->mdio_read(mii->dev, mii->phy_id, addr); | 41 | advert = mii->mdio_read(mii->dev, mii->phy_id, addr); |
42 | if (advert & LPA_LPACK) | 42 | if (advert & LPA_LPACK) |
43 | result |= ADVERTISED_Autoneg; | 43 | result |= ADVERTISED_Autoneg; |
44 | if (advert & ADVERTISE_10HALF) | 44 | |
45 | result |= ADVERTISED_10baseT_Half; | 45 | return result | mii_adv_to_ethtool_100bt(advert); |
46 | if (advert & ADVERTISE_10FULL) | ||
47 | result |= ADVERTISED_10baseT_Full; | ||
48 | if (advert & ADVERTISE_100HALF) | ||
49 | result |= ADVERTISED_100baseT_Half; | ||
50 | if (advert & ADVERTISE_100FULL) | ||
51 | result |= ADVERTISED_100baseT_Full; | ||
52 | if (advert & ADVERTISE_PAUSE_CAP) | ||
53 | result |= ADVERTISED_Pause; | ||
54 | if (advert & ADVERTISE_PAUSE_ASYM) | ||
55 | result |= ADVERTISED_Asym_Pause; | ||
56 | |||
57 | return result; | ||
58 | } | 46 | } |
59 | 47 | ||
60 | /** | 48 | /** |
@@ -104,19 +92,13 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
104 | ecmd->autoneg = AUTONEG_ENABLE; | 92 | ecmd->autoneg = AUTONEG_ENABLE; |
105 | 93 | ||
106 | ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE); | 94 | ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE); |
107 | if (ctrl1000 & ADVERTISE_1000HALF) | 95 | if (mii->supports_gmii) |
108 | ecmd->advertising |= ADVERTISED_1000baseT_Half; | 96 | ecmd->advertising |= mii_adv_to_ethtool_1000T(ctrl1000); |
109 | if (ctrl1000 & ADVERTISE_1000FULL) | ||
110 | ecmd->advertising |= ADVERTISED_1000baseT_Full; | ||
111 | 97 | ||
112 | if (bmsr & BMSR_ANEGCOMPLETE) { | 98 | if (bmsr & BMSR_ANEGCOMPLETE) { |
113 | ecmd->lp_advertising = mii_get_an(mii, MII_LPA); | 99 | ecmd->lp_advertising = mii_get_an(mii, MII_LPA); |
114 | if (stat1000 & LPA_1000HALF) | 100 | ecmd->lp_advertising |= |
115 | ecmd->lp_advertising |= | 101 | mii_lpa_to_ethtool_1000T(stat1000); |
116 | ADVERTISED_1000baseT_Half; | ||
117 | if (stat1000 & LPA_1000FULL) | ||
118 | ecmd->lp_advertising |= | ||
119 | ADVERTISED_1000baseT_Full; | ||
120 | } else { | 102 | } else { |
121 | ecmd->lp_advertising = 0; | 103 | ecmd->lp_advertising = 0; |
122 | } | 104 | } |
@@ -204,20 +186,10 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
204 | advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000); | 186 | advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000); |
205 | tmp2 = advert2 & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL); | 187 | tmp2 = advert2 & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL); |
206 | } | 188 | } |
207 | if (ecmd->advertising & ADVERTISED_10baseT_Half) | 189 | tmp |= ethtool_adv_to_mii_100bt(ecmd->advertising); |
208 | tmp |= ADVERTISE_10HALF; | 190 | |
209 | if (ecmd->advertising & ADVERTISED_10baseT_Full) | 191 | if (mii->supports_gmii) |
210 | tmp |= ADVERTISE_10FULL; | 192 | tmp2 |= ethtool_adv_to_mii_1000T(ecmd->advertising); |
211 | if (ecmd->advertising & ADVERTISED_100baseT_Half) | ||
212 | tmp |= ADVERTISE_100HALF; | ||
213 | if (ecmd->advertising & ADVERTISED_100baseT_Full) | ||
214 | tmp |= ADVERTISE_100FULL; | ||
215 | if (mii->supports_gmii) { | ||
216 | if (ecmd->advertising & ADVERTISED_1000baseT_Half) | ||
217 | tmp2 |= ADVERTISE_1000HALF; | ||
218 | if (ecmd->advertising & ADVERTISED_1000baseT_Full) | ||
219 | tmp2 |= ADVERTISE_1000FULL; | ||
220 | } | ||
221 | if (advert != tmp) { | 193 | if (advert != tmp) { |
222 | mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp); | 194 | mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp); |
223 | mii->advertising = tmp; | 195 | mii->advertising = tmp; |
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c index 65391891d8c4..daec9b05d168 100644 --- a/drivers/net/phy/mdio-bitbang.c +++ b/drivers/net/phy/mdio-bitbang.c | |||
@@ -202,6 +202,14 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val) | |||
202 | return 0; | 202 | return 0; |
203 | } | 203 | } |
204 | 204 | ||
205 | static int mdiobb_reset(struct mii_bus *bus) | ||
206 | { | ||
207 | struct mdiobb_ctrl *ctrl = bus->priv; | ||
208 | if (ctrl->reset) | ||
209 | ctrl->reset(bus); | ||
210 | return 0; | ||
211 | } | ||
212 | |||
205 | struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl) | 213 | struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl) |
206 | { | 214 | { |
207 | struct mii_bus *bus; | 215 | struct mii_bus *bus; |
@@ -214,6 +222,7 @@ struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl) | |||
214 | 222 | ||
215 | bus->read = mdiobb_read; | 223 | bus->read = mdiobb_read; |
216 | bus->write = mdiobb_write; | 224 | bus->write = mdiobb_write; |
225 | bus->reset = mdiobb_reset; | ||
217 | bus->priv = ctrl; | 226 | bus->priv = ctrl; |
218 | 227 | ||
219 | return bus; | 228 | return bus; |
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 2843c90f712f..89c5a3eccc12 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c | |||
@@ -95,6 +95,7 @@ static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev, | |||
95 | goto out; | 95 | goto out; |
96 | 96 | ||
97 | bitbang->ctrl.ops = &mdio_gpio_ops; | 97 | bitbang->ctrl.ops = &mdio_gpio_ops; |
98 | bitbang->ctrl.reset = pdata->reset; | ||
98 | bitbang->mdc = pdata->mdc; | 99 | bitbang->mdc = pdata->mdc; |
99 | bitbang->mdio = pdata->mdio; | 100 | bitbang->mdio = pdata->mdio; |
100 | 101 | ||
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 83a5a5afec67..edb905f80115 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -563,20 +563,9 @@ static int genphy_config_advert(struct phy_device *phydev) | |||
563 | if (adv < 0) | 563 | if (adv < 0) |
564 | return adv; | 564 | return adv; |
565 | 565 | ||
566 | adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | | 566 | adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | |
567 | ADVERTISE_PAUSE_ASYM); | 567 | ADVERTISE_PAUSE_ASYM); |
568 | if (advertise & ADVERTISED_10baseT_Half) | 568 | adv |= ethtool_adv_to_mii_100bt(advertise); |
569 | adv |= ADVERTISE_10HALF; | ||
570 | if (advertise & ADVERTISED_10baseT_Full) | ||
571 | adv |= ADVERTISE_10FULL; | ||
572 | if (advertise & ADVERTISED_100baseT_Half) | ||
573 | adv |= ADVERTISE_100HALF; | ||
574 | if (advertise & ADVERTISED_100baseT_Full) | ||
575 | adv |= ADVERTISE_100FULL; | ||
576 | if (advertise & ADVERTISED_Pause) | ||
577 | adv |= ADVERTISE_PAUSE_CAP; | ||
578 | if (advertise & ADVERTISED_Asym_Pause) | ||
579 | adv |= ADVERTISE_PAUSE_ASYM; | ||
580 | 569 | ||
581 | if (adv != oldadv) { | 570 | if (adv != oldadv) { |
582 | err = phy_write(phydev, MII_ADVERTISE, adv); | 571 | err = phy_write(phydev, MII_ADVERTISE, adv); |
@@ -595,10 +584,7 @@ static int genphy_config_advert(struct phy_device *phydev) | |||
595 | return adv; | 584 | return adv; |
596 | 585 | ||
597 | adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); | 586 | adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); |
598 | if (advertise & SUPPORTED_1000baseT_Half) | 587 | adv |= ethtool_adv_to_mii_1000T(advertise); |
599 | adv |= ADVERTISE_1000HALF; | ||
600 | if (advertise & SUPPORTED_1000baseT_Full) | ||
601 | adv |= ADVERTISE_1000FULL; | ||
602 | 588 | ||
603 | if (adv != oldadv) { | 589 | if (adv != oldadv) { |
604 | err = phy_write(phydev, MII_CTRL1000, adv); | 590 | err = phy_write(phydev, MII_CTRL1000, adv); |
diff --git a/drivers/net/team/Kconfig b/drivers/net/team/Kconfig new file mode 100644 index 000000000000..248a144033ca --- /dev/null +++ b/drivers/net/team/Kconfig | |||
@@ -0,0 +1,43 @@ | |||
1 | menuconfig NET_TEAM | ||
2 | tristate "Ethernet team driver support (EXPERIMENTAL)" | ||
3 | depends on EXPERIMENTAL | ||
4 | ---help--- | ||
5 | This allows one to create virtual interfaces that teams together | ||
6 | multiple ethernet devices. | ||
7 | |||
8 | Team devices can be added using the "ip" command from the | ||
9 | iproute2 package: | ||
10 | |||
11 | "ip link add link [ address MAC ] [ NAME ] type team" | ||
12 | |||
13 | To compile this driver as a module, choose M here: the module | ||
14 | will be called team. | ||
15 | |||
16 | if NET_TEAM | ||
17 | |||
18 | config NET_TEAM_MODE_ROUNDROBIN | ||
19 | tristate "Round-robin mode support" | ||
20 | depends on NET_TEAM | ||
21 | ---help--- | ||
22 | Basic mode where port used for transmitting packets is selected in | ||
23 | round-robin fashion using packet counter. | ||
24 | |||
25 | All added ports are setup to have bond's mac address. | ||
26 | |||
27 | To compile this team mode as a module, choose M here: the module | ||
28 | will be called team_mode_roundrobin. | ||
29 | |||
30 | config NET_TEAM_MODE_ACTIVEBACKUP | ||
31 | tristate "Active-backup mode support" | ||
32 | depends on NET_TEAM | ||
33 | ---help--- | ||
34 | Only one port is active at a time and the rest of ports are used | ||
35 | for backup. | ||
36 | |||
37 | Mac addresses of ports are not modified. Userspace is responsible | ||
38 | to do so. | ||
39 | |||
40 | To compile this team mode as a module, choose M here: the module | ||
41 | will be called team_mode_activebackup. | ||
42 | |||
43 | endif # NET_TEAM | ||
diff --git a/drivers/net/team/Makefile b/drivers/net/team/Makefile new file mode 100644 index 000000000000..85f2028a87af --- /dev/null +++ b/drivers/net/team/Makefile | |||
@@ -0,0 +1,7 @@ | |||
1 | # | ||
2 | # Makefile for the network team driver | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_NET_TEAM) += team.o | ||
6 | obj-$(CONFIG_NET_TEAM_MODE_ROUNDROBIN) += team_mode_roundrobin.o | ||
7 | obj-$(CONFIG_NET_TEAM_MODE_ACTIVEBACKUP) += team_mode_activebackup.o | ||
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c new file mode 100644 index 000000000000..064155d56bce --- /dev/null +++ b/drivers/net/team/team.c | |||
@@ -0,0 +1,1661 @@ | |||
1 | /* | ||
2 | * net/drivers/team/team.c - Network team device driver | ||
3 | * Copyright (c) 2011 Jiri Pirko <jpirko@redhat.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/types.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/slab.h> | ||
16 | #include <linux/rcupdate.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/ctype.h> | ||
19 | #include <linux/notifier.h> | ||
20 | #include <linux/netdevice.h> | ||
21 | #include <linux/if_arp.h> | ||
22 | #include <linux/socket.h> | ||
23 | #include <linux/etherdevice.h> | ||
24 | #include <linux/rtnetlink.h> | ||
25 | #include <net/rtnetlink.h> | ||
26 | #include <net/genetlink.h> | ||
27 | #include <net/netlink.h> | ||
28 | #include <linux/if_team.h> | ||
29 | |||
30 | #define DRV_NAME "team" | ||
31 | |||
32 | |||
33 | /********** | ||
34 | * Helpers | ||
35 | **********/ | ||
36 | |||
37 | #define team_port_exists(dev) (dev->priv_flags & IFF_TEAM_PORT) | ||
38 | |||
39 | static struct team_port *team_port_get_rcu(const struct net_device *dev) | ||
40 | { | ||
41 | struct team_port *port = rcu_dereference(dev->rx_handler_data); | ||
42 | |||
43 | return team_port_exists(dev) ? port : NULL; | ||
44 | } | ||
45 | |||
46 | static struct team_port *team_port_get_rtnl(const struct net_device *dev) | ||
47 | { | ||
48 | struct team_port *port = rtnl_dereference(dev->rx_handler_data); | ||
49 | |||
50 | return team_port_exists(dev) ? port : NULL; | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * Since the ability to change mac address for open port device is tested in | ||
55 | * team_port_add, this function can be called without control of return value | ||
56 | */ | ||
57 | static int __set_port_mac(struct net_device *port_dev, | ||
58 | const unsigned char *dev_addr) | ||
59 | { | ||
60 | struct sockaddr addr; | ||
61 | |||
62 | memcpy(addr.sa_data, dev_addr, ETH_ALEN); | ||
63 | addr.sa_family = ARPHRD_ETHER; | ||
64 | return dev_set_mac_address(port_dev, &addr); | ||
65 | } | ||
66 | |||
67 | int team_port_set_orig_mac(struct team_port *port) | ||
68 | { | ||
69 | return __set_port_mac(port->dev, port->orig.dev_addr); | ||
70 | } | ||
71 | |||
72 | int team_port_set_team_mac(struct team_port *port) | ||
73 | { | ||
74 | return __set_port_mac(port->dev, port->team->dev->dev_addr); | ||
75 | } | ||
76 | EXPORT_SYMBOL(team_port_set_team_mac); | ||
77 | |||
78 | |||
79 | /******************* | ||
80 | * Options handling | ||
81 | *******************/ | ||
82 | |||
83 | struct team_option *__team_find_option(struct team *team, const char *opt_name) | ||
84 | { | ||
85 | struct team_option *option; | ||
86 | |||
87 | list_for_each_entry(option, &team->option_list, list) { | ||
88 | if (strcmp(option->name, opt_name) == 0) | ||
89 | return option; | ||
90 | } | ||
91 | return NULL; | ||
92 | } | ||
93 | |||
94 | int team_options_register(struct team *team, | ||
95 | const struct team_option *option, | ||
96 | size_t option_count) | ||
97 | { | ||
98 | int i; | ||
99 | struct team_option **dst_opts; | ||
100 | int err; | ||
101 | |||
102 | dst_opts = kzalloc(sizeof(struct team_option *) * option_count, | ||
103 | GFP_KERNEL); | ||
104 | if (!dst_opts) | ||
105 | return -ENOMEM; | ||
106 | for (i = 0; i < option_count; i++, option++) { | ||
107 | if (__team_find_option(team, option->name)) { | ||
108 | err = -EEXIST; | ||
109 | goto rollback; | ||
110 | } | ||
111 | dst_opts[i] = kmemdup(option, sizeof(*option), GFP_KERNEL); | ||
112 | if (!dst_opts[i]) { | ||
113 | err = -ENOMEM; | ||
114 | goto rollback; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | for (i = 0; i < option_count; i++) | ||
119 | list_add_tail(&dst_opts[i]->list, &team->option_list); | ||
120 | |||
121 | kfree(dst_opts); | ||
122 | return 0; | ||
123 | |||
124 | rollback: | ||
125 | for (i = 0; i < option_count; i++) | ||
126 | kfree(dst_opts[i]); | ||
127 | |||
128 | kfree(dst_opts); | ||
129 | return err; | ||
130 | } | ||
131 | |||
132 | EXPORT_SYMBOL(team_options_register); | ||
133 | |||
134 | static void __team_options_change_check(struct team *team, | ||
135 | struct team_option *changed_option); | ||
136 | |||
137 | static void __team_options_unregister(struct team *team, | ||
138 | const struct team_option *option, | ||
139 | size_t option_count) | ||
140 | { | ||
141 | int i; | ||
142 | |||
143 | for (i = 0; i < option_count; i++, option++) { | ||
144 | struct team_option *del_opt; | ||
145 | |||
146 | del_opt = __team_find_option(team, option->name); | ||
147 | if (del_opt) { | ||
148 | list_del(&del_opt->list); | ||
149 | kfree(del_opt); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | void team_options_unregister(struct team *team, | ||
155 | const struct team_option *option, | ||
156 | size_t option_count) | ||
157 | { | ||
158 | __team_options_unregister(team, option, option_count); | ||
159 | __team_options_change_check(team, NULL); | ||
160 | } | ||
161 | EXPORT_SYMBOL(team_options_unregister); | ||
162 | |||
163 | static int team_option_get(struct team *team, struct team_option *option, | ||
164 | void *arg) | ||
165 | { | ||
166 | return option->getter(team, arg); | ||
167 | } | ||
168 | |||
169 | static int team_option_set(struct team *team, struct team_option *option, | ||
170 | void *arg) | ||
171 | { | ||
172 | int err; | ||
173 | |||
174 | err = option->setter(team, arg); | ||
175 | if (err) | ||
176 | return err; | ||
177 | |||
178 | __team_options_change_check(team, option); | ||
179 | return err; | ||
180 | } | ||
181 | |||
182 | /**************** | ||
183 | * Mode handling | ||
184 | ****************/ | ||
185 | |||
186 | static LIST_HEAD(mode_list); | ||
187 | static DEFINE_SPINLOCK(mode_list_lock); | ||
188 | |||
189 | static struct team_mode *__find_mode(const char *kind) | ||
190 | { | ||
191 | struct team_mode *mode; | ||
192 | |||
193 | list_for_each_entry(mode, &mode_list, list) { | ||
194 | if (strcmp(mode->kind, kind) == 0) | ||
195 | return mode; | ||
196 | } | ||
197 | return NULL; | ||
198 | } | ||
199 | |||
200 | static bool is_good_mode_name(const char *name) | ||
201 | { | ||
202 | while (*name != '\0') { | ||
203 | if (!isalpha(*name) && !isdigit(*name) && *name != '_') | ||
204 | return false; | ||
205 | name++; | ||
206 | } | ||
207 | return true; | ||
208 | } | ||
209 | |||
210 | int team_mode_register(struct team_mode *mode) | ||
211 | { | ||
212 | int err = 0; | ||
213 | |||
214 | if (!is_good_mode_name(mode->kind) || | ||
215 | mode->priv_size > TEAM_MODE_PRIV_SIZE) | ||
216 | return -EINVAL; | ||
217 | spin_lock(&mode_list_lock); | ||
218 | if (__find_mode(mode->kind)) { | ||
219 | err = -EEXIST; | ||
220 | goto unlock; | ||
221 | } | ||
222 | list_add_tail(&mode->list, &mode_list); | ||
223 | unlock: | ||
224 | spin_unlock(&mode_list_lock); | ||
225 | return err; | ||
226 | } | ||
227 | EXPORT_SYMBOL(team_mode_register); | ||
228 | |||
229 | int team_mode_unregister(struct team_mode *mode) | ||
230 | { | ||
231 | spin_lock(&mode_list_lock); | ||
232 | list_del_init(&mode->list); | ||
233 | spin_unlock(&mode_list_lock); | ||
234 | return 0; | ||
235 | } | ||
236 | EXPORT_SYMBOL(team_mode_unregister); | ||
237 | |||
238 | static struct team_mode *team_mode_get(const char *kind) | ||
239 | { | ||
240 | struct team_mode *mode; | ||
241 | |||
242 | spin_lock(&mode_list_lock); | ||
243 | mode = __find_mode(kind); | ||
244 | if (!mode) { | ||
245 | spin_unlock(&mode_list_lock); | ||
246 | request_module("team-mode-%s", kind); | ||
247 | spin_lock(&mode_list_lock); | ||
248 | mode = __find_mode(kind); | ||
249 | } | ||
250 | if (mode) | ||
251 | if (!try_module_get(mode->owner)) | ||
252 | mode = NULL; | ||
253 | |||
254 | spin_unlock(&mode_list_lock); | ||
255 | return mode; | ||
256 | } | ||
257 | |||
258 | static void team_mode_put(const struct team_mode *mode) | ||
259 | { | ||
260 | module_put(mode->owner); | ||
261 | } | ||
262 | |||
263 | static bool team_dummy_transmit(struct team *team, struct sk_buff *skb) | ||
264 | { | ||
265 | dev_kfree_skb_any(skb); | ||
266 | return false; | ||
267 | } | ||
268 | |||
269 | rx_handler_result_t team_dummy_receive(struct team *team, | ||
270 | struct team_port *port, | ||
271 | struct sk_buff *skb) | ||
272 | { | ||
273 | return RX_HANDLER_ANOTHER; | ||
274 | } | ||
275 | |||
276 | static void team_adjust_ops(struct team *team) | ||
277 | { | ||
278 | /* | ||
279 | * To avoid checks in rx/tx skb paths, ensure here that non-null and | ||
280 | * correct ops are always set. | ||
281 | */ | ||
282 | |||
283 | if (list_empty(&team->port_list) || | ||
284 | !team->mode || !team->mode->ops->transmit) | ||
285 | team->ops.transmit = team_dummy_transmit; | ||
286 | else | ||
287 | team->ops.transmit = team->mode->ops->transmit; | ||
288 | |||
289 | if (list_empty(&team->port_list) || | ||
290 | !team->mode || !team->mode->ops->receive) | ||
291 | team->ops.receive = team_dummy_receive; | ||
292 | else | ||
293 | team->ops.receive = team->mode->ops->receive; | ||
294 | } | ||
295 | |||
296 | /* | ||
297 | * We can benefit from the fact that it's ensured no port is present | ||
298 | * at the time of mode change. Therefore no packets are in fly so there's no | ||
299 | * need to set mode operations in any special way. | ||
300 | */ | ||
301 | static int __team_change_mode(struct team *team, | ||
302 | const struct team_mode *new_mode) | ||
303 | { | ||
304 | /* Check if mode was previously set and do cleanup if so */ | ||
305 | if (team->mode) { | ||
306 | void (*exit_op)(struct team *team) = team->ops.exit; | ||
307 | |||
308 | /* Clear ops area so no callback is called any longer */ | ||
309 | memset(&team->ops, 0, sizeof(struct team_mode_ops)); | ||
310 | team_adjust_ops(team); | ||
311 | |||
312 | if (exit_op) | ||
313 | exit_op(team); | ||
314 | team_mode_put(team->mode); | ||
315 | team->mode = NULL; | ||
316 | /* zero private data area */ | ||
317 | memset(&team->mode_priv, 0, | ||
318 | sizeof(struct team) - offsetof(struct team, mode_priv)); | ||
319 | } | ||
320 | |||
321 | if (!new_mode) | ||
322 | return 0; | ||
323 | |||
324 | if (new_mode->ops->init) { | ||
325 | int err; | ||
326 | |||
327 | err = new_mode->ops->init(team); | ||
328 | if (err) | ||
329 | return err; | ||
330 | } | ||
331 | |||
332 | team->mode = new_mode; | ||
333 | memcpy(&team->ops, new_mode->ops, sizeof(struct team_mode_ops)); | ||
334 | team_adjust_ops(team); | ||
335 | |||
336 | return 0; | ||
337 | } | ||
338 | |||
339 | static int team_change_mode(struct team *team, const char *kind) | ||
340 | { | ||
341 | struct team_mode *new_mode; | ||
342 | struct net_device *dev = team->dev; | ||
343 | int err; | ||
344 | |||
345 | if (!list_empty(&team->port_list)) { | ||
346 | netdev_err(dev, "No ports can be present during mode change\n"); | ||
347 | return -EBUSY; | ||
348 | } | ||
349 | |||
350 | if (team->mode && strcmp(team->mode->kind, kind) == 0) { | ||
351 | netdev_err(dev, "Unable to change to the same mode the team is in\n"); | ||
352 | return -EINVAL; | ||
353 | } | ||
354 | |||
355 | new_mode = team_mode_get(kind); | ||
356 | if (!new_mode) { | ||
357 | netdev_err(dev, "Mode \"%s\" not found\n", kind); | ||
358 | return -EINVAL; | ||
359 | } | ||
360 | |||
361 | err = __team_change_mode(team, new_mode); | ||
362 | if (err) { | ||
363 | netdev_err(dev, "Failed to change to mode \"%s\"\n", kind); | ||
364 | team_mode_put(new_mode); | ||
365 | return err; | ||
366 | } | ||
367 | |||
368 | netdev_info(dev, "Mode changed to \"%s\"\n", kind); | ||
369 | return 0; | ||
370 | } | ||
371 | |||
372 | |||
373 | /************************ | ||
374 | * Rx path frame handler | ||
375 | ************************/ | ||
376 | |||
377 | /* note: already called with rcu_read_lock */ | ||
378 | static rx_handler_result_t team_handle_frame(struct sk_buff **pskb) | ||
379 | { | ||
380 | struct sk_buff *skb = *pskb; | ||
381 | struct team_port *port; | ||
382 | struct team *team; | ||
383 | rx_handler_result_t res; | ||
384 | |||
385 | skb = skb_share_check(skb, GFP_ATOMIC); | ||
386 | if (!skb) | ||
387 | return RX_HANDLER_CONSUMED; | ||
388 | |||
389 | *pskb = skb; | ||
390 | |||
391 | port = team_port_get_rcu(skb->dev); | ||
392 | team = port->team; | ||
393 | |||
394 | res = team->ops.receive(team, port, skb); | ||
395 | if (res == RX_HANDLER_ANOTHER) { | ||
396 | struct team_pcpu_stats *pcpu_stats; | ||
397 | |||
398 | pcpu_stats = this_cpu_ptr(team->pcpu_stats); | ||
399 | u64_stats_update_begin(&pcpu_stats->syncp); | ||
400 | pcpu_stats->rx_packets++; | ||
401 | pcpu_stats->rx_bytes += skb->len; | ||
402 | if (skb->pkt_type == PACKET_MULTICAST) | ||
403 | pcpu_stats->rx_multicast++; | ||
404 | u64_stats_update_end(&pcpu_stats->syncp); | ||
405 | |||
406 | skb->dev = team->dev; | ||
407 | } else { | ||
408 | this_cpu_inc(team->pcpu_stats->rx_dropped); | ||
409 | } | ||
410 | |||
411 | return res; | ||
412 | } | ||
413 | |||
414 | |||
415 | /**************** | ||
416 | * Port handling | ||
417 | ****************/ | ||
418 | |||
419 | static bool team_port_find(const struct team *team, | ||
420 | const struct team_port *port) | ||
421 | { | ||
422 | struct team_port *cur; | ||
423 | |||
424 | list_for_each_entry(cur, &team->port_list, list) | ||
425 | if (cur == port) | ||
426 | return true; | ||
427 | return false; | ||
428 | } | ||
429 | |||
430 | /* | ||
431 | * Add/delete port to the team port list. Write guarded by rtnl_lock. | ||
432 | * Takes care of correct port->index setup (might be racy). | ||
433 | */ | ||
434 | static void team_port_list_add_port(struct team *team, | ||
435 | struct team_port *port) | ||
436 | { | ||
437 | port->index = team->port_count++; | ||
438 | hlist_add_head_rcu(&port->hlist, | ||
439 | team_port_index_hash(team, port->index)); | ||
440 | list_add_tail_rcu(&port->list, &team->port_list); | ||
441 | } | ||
442 | |||
443 | static void __reconstruct_port_hlist(struct team *team, int rm_index) | ||
444 | { | ||
445 | int i; | ||
446 | struct team_port *port; | ||
447 | |||
448 | for (i = rm_index + 1; i < team->port_count; i++) { | ||
449 | port = team_get_port_by_index(team, i); | ||
450 | hlist_del_rcu(&port->hlist); | ||
451 | port->index--; | ||
452 | hlist_add_head_rcu(&port->hlist, | ||
453 | team_port_index_hash(team, port->index)); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | static void team_port_list_del_port(struct team *team, | ||
458 | struct team_port *port) | ||
459 | { | ||
460 | int rm_index = port->index; | ||
461 | |||
462 | hlist_del_rcu(&port->hlist); | ||
463 | list_del_rcu(&port->list); | ||
464 | __reconstruct_port_hlist(team, rm_index); | ||
465 | team->port_count--; | ||
466 | } | ||
467 | |||
468 | #define TEAM_VLAN_FEATURES (NETIF_F_ALL_CSUM | NETIF_F_SG | \ | ||
469 | NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \ | ||
470 | NETIF_F_HIGHDMA | NETIF_F_LRO) | ||
471 | |||
472 | static void __team_compute_features(struct team *team) | ||
473 | { | ||
474 | struct team_port *port; | ||
475 | u32 vlan_features = TEAM_VLAN_FEATURES; | ||
476 | unsigned short max_hard_header_len = ETH_HLEN; | ||
477 | |||
478 | list_for_each_entry(port, &team->port_list, list) { | ||
479 | vlan_features = netdev_increment_features(vlan_features, | ||
480 | port->dev->vlan_features, | ||
481 | TEAM_VLAN_FEATURES); | ||
482 | |||
483 | if (port->dev->hard_header_len > max_hard_header_len) | ||
484 | max_hard_header_len = port->dev->hard_header_len; | ||
485 | } | ||
486 | |||
487 | team->dev->vlan_features = vlan_features; | ||
488 | team->dev->hard_header_len = max_hard_header_len; | ||
489 | |||
490 | netdev_change_features(team->dev); | ||
491 | } | ||
492 | |||
493 | static void team_compute_features(struct team *team) | ||
494 | { | ||
495 | mutex_lock(&team->lock); | ||
496 | __team_compute_features(team); | ||
497 | mutex_unlock(&team->lock); | ||
498 | } | ||
499 | |||
500 | static int team_port_enter(struct team *team, struct team_port *port) | ||
501 | { | ||
502 | int err = 0; | ||
503 | |||
504 | dev_hold(team->dev); | ||
505 | port->dev->priv_flags |= IFF_TEAM_PORT; | ||
506 | if (team->ops.port_enter) { | ||
507 | err = team->ops.port_enter(team, port); | ||
508 | if (err) { | ||
509 | netdev_err(team->dev, "Device %s failed to enter team mode\n", | ||
510 | port->dev->name); | ||
511 | goto err_port_enter; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | return 0; | ||
516 | |||
517 | err_port_enter: | ||
518 | port->dev->priv_flags &= ~IFF_TEAM_PORT; | ||
519 | dev_put(team->dev); | ||
520 | |||
521 | return err; | ||
522 | } | ||
523 | |||
524 | static void team_port_leave(struct team *team, struct team_port *port) | ||
525 | { | ||
526 | if (team->ops.port_leave) | ||
527 | team->ops.port_leave(team, port); | ||
528 | port->dev->priv_flags &= ~IFF_TEAM_PORT; | ||
529 | dev_put(team->dev); | ||
530 | } | ||
531 | |||
532 | static void __team_port_change_check(struct team_port *port, bool linkup); | ||
533 | |||
534 | static int team_port_add(struct team *team, struct net_device *port_dev) | ||
535 | { | ||
536 | struct net_device *dev = team->dev; | ||
537 | struct team_port *port; | ||
538 | char *portname = port_dev->name; | ||
539 | int err; | ||
540 | |||
541 | if (port_dev->flags & IFF_LOOPBACK || | ||
542 | port_dev->type != ARPHRD_ETHER) { | ||
543 | netdev_err(dev, "Device %s is of an unsupported type\n", | ||
544 | portname); | ||
545 | return -EINVAL; | ||
546 | } | ||
547 | |||
548 | if (team_port_exists(port_dev)) { | ||
549 | netdev_err(dev, "Device %s is already a port " | ||
550 | "of a team device\n", portname); | ||
551 | return -EBUSY; | ||
552 | } | ||
553 | |||
554 | if (port_dev->flags & IFF_UP) { | ||
555 | netdev_err(dev, "Device %s is up. Set it down before adding it as a team port\n", | ||
556 | portname); | ||
557 | return -EBUSY; | ||
558 | } | ||
559 | |||
560 | port = kzalloc(sizeof(struct team_port), GFP_KERNEL); | ||
561 | if (!port) | ||
562 | return -ENOMEM; | ||
563 | |||
564 | port->dev = port_dev; | ||
565 | port->team = team; | ||
566 | |||
567 | port->orig.mtu = port_dev->mtu; | ||
568 | err = dev_set_mtu(port_dev, dev->mtu); | ||
569 | if (err) { | ||
570 | netdev_dbg(dev, "Error %d calling dev_set_mtu\n", err); | ||
571 | goto err_set_mtu; | ||
572 | } | ||
573 | |||
574 | memcpy(port->orig.dev_addr, port_dev->dev_addr, ETH_ALEN); | ||
575 | |||
576 | err = team_port_enter(team, port); | ||
577 | if (err) { | ||
578 | netdev_err(dev, "Device %s failed to enter team mode\n", | ||
579 | portname); | ||
580 | goto err_port_enter; | ||
581 | } | ||
582 | |||
583 | err = dev_open(port_dev); | ||
584 | if (err) { | ||
585 | netdev_dbg(dev, "Device %s opening failed\n", | ||
586 | portname); | ||
587 | goto err_dev_open; | ||
588 | } | ||
589 | |||
590 | err = netdev_set_master(port_dev, dev); | ||
591 | if (err) { | ||
592 | netdev_err(dev, "Device %s failed to set master\n", portname); | ||
593 | goto err_set_master; | ||
594 | } | ||
595 | |||
596 | err = netdev_rx_handler_register(port_dev, team_handle_frame, | ||
597 | port); | ||
598 | if (err) { | ||
599 | netdev_err(dev, "Device %s failed to register rx_handler\n", | ||
600 | portname); | ||
601 | goto err_handler_register; | ||
602 | } | ||
603 | |||
604 | team_port_list_add_port(team, port); | ||
605 | team_adjust_ops(team); | ||
606 | __team_compute_features(team); | ||
607 | __team_port_change_check(port, !!netif_carrier_ok(port_dev)); | ||
608 | |||
609 | netdev_info(dev, "Port device %s added\n", portname); | ||
610 | |||
611 | return 0; | ||
612 | |||
613 | err_handler_register: | ||
614 | netdev_set_master(port_dev, NULL); | ||
615 | |||
616 | err_set_master: | ||
617 | dev_close(port_dev); | ||
618 | |||
619 | err_dev_open: | ||
620 | team_port_leave(team, port); | ||
621 | team_port_set_orig_mac(port); | ||
622 | |||
623 | err_port_enter: | ||
624 | dev_set_mtu(port_dev, port->orig.mtu); | ||
625 | |||
626 | err_set_mtu: | ||
627 | kfree(port); | ||
628 | |||
629 | return err; | ||
630 | } | ||
631 | |||
632 | static int team_port_del(struct team *team, struct net_device *port_dev) | ||
633 | { | ||
634 | struct net_device *dev = team->dev; | ||
635 | struct team_port *port; | ||
636 | char *portname = port_dev->name; | ||
637 | |||
638 | port = team_port_get_rtnl(port_dev); | ||
639 | if (!port || !team_port_find(team, port)) { | ||
640 | netdev_err(dev, "Device %s does not act as a port of this team\n", | ||
641 | portname); | ||
642 | return -ENOENT; | ||
643 | } | ||
644 | |||
645 | __team_port_change_check(port, false); | ||
646 | team_port_list_del_port(team, port); | ||
647 | team_adjust_ops(team); | ||
648 | netdev_rx_handler_unregister(port_dev); | ||
649 | netdev_set_master(port_dev, NULL); | ||
650 | dev_close(port_dev); | ||
651 | team_port_leave(team, port); | ||
652 | team_port_set_orig_mac(port); | ||
653 | dev_set_mtu(port_dev, port->orig.mtu); | ||
654 | synchronize_rcu(); | ||
655 | kfree(port); | ||
656 | netdev_info(dev, "Port device %s removed\n", portname); | ||
657 | __team_compute_features(team); | ||
658 | |||
659 | return 0; | ||
660 | } | ||
661 | |||
662 | |||
663 | /***************** | ||
664 | * Net device ops | ||
665 | *****************/ | ||
666 | |||
667 | static const char team_no_mode_kind[] = "*NOMODE*"; | ||
668 | |||
669 | static int team_mode_option_get(struct team *team, void *arg) | ||
670 | { | ||
671 | const char **str = arg; | ||
672 | |||
673 | *str = team->mode ? team->mode->kind : team_no_mode_kind; | ||
674 | return 0; | ||
675 | } | ||
676 | |||
677 | static int team_mode_option_set(struct team *team, void *arg) | ||
678 | { | ||
679 | const char **str = arg; | ||
680 | |||
681 | return team_change_mode(team, *str); | ||
682 | } | ||
683 | |||
684 | static const struct team_option team_options[] = { | ||
685 | { | ||
686 | .name = "mode", | ||
687 | .type = TEAM_OPTION_TYPE_STRING, | ||
688 | .getter = team_mode_option_get, | ||
689 | .setter = team_mode_option_set, | ||
690 | }, | ||
691 | }; | ||
692 | |||
693 | static int team_init(struct net_device *dev) | ||
694 | { | ||
695 | struct team *team = netdev_priv(dev); | ||
696 | int i; | ||
697 | int err; | ||
698 | |||
699 | team->dev = dev; | ||
700 | mutex_init(&team->lock); | ||
701 | |||
702 | team->pcpu_stats = alloc_percpu(struct team_pcpu_stats); | ||
703 | if (!team->pcpu_stats) | ||
704 | return -ENOMEM; | ||
705 | |||
706 | for (i = 0; i < TEAM_PORT_HASHENTRIES; i++) | ||
707 | INIT_HLIST_HEAD(&team->port_hlist[i]); | ||
708 | INIT_LIST_HEAD(&team->port_list); | ||
709 | |||
710 | team_adjust_ops(team); | ||
711 | |||
712 | INIT_LIST_HEAD(&team->option_list); | ||
713 | err = team_options_register(team, team_options, ARRAY_SIZE(team_options)); | ||
714 | if (err) | ||
715 | goto err_options_register; | ||
716 | netif_carrier_off(dev); | ||
717 | |||
718 | return 0; | ||
719 | |||
720 | err_options_register: | ||
721 | free_percpu(team->pcpu_stats); | ||
722 | |||
723 | return err; | ||
724 | } | ||
725 | |||
726 | static void team_uninit(struct net_device *dev) | ||
727 | { | ||
728 | struct team *team = netdev_priv(dev); | ||
729 | struct team_port *port; | ||
730 | struct team_port *tmp; | ||
731 | |||
732 | mutex_lock(&team->lock); | ||
733 | list_for_each_entry_safe(port, tmp, &team->port_list, list) | ||
734 | team_port_del(team, port->dev); | ||
735 | |||
736 | __team_change_mode(team, NULL); /* cleanup */ | ||
737 | __team_options_unregister(team, team_options, ARRAY_SIZE(team_options)); | ||
738 | mutex_unlock(&team->lock); | ||
739 | } | ||
740 | |||
741 | static void team_destructor(struct net_device *dev) | ||
742 | { | ||
743 | struct team *team = netdev_priv(dev); | ||
744 | |||
745 | free_percpu(team->pcpu_stats); | ||
746 | free_netdev(dev); | ||
747 | } | ||
748 | |||
749 | static int team_open(struct net_device *dev) | ||
750 | { | ||
751 | netif_carrier_on(dev); | ||
752 | return 0; | ||
753 | } | ||
754 | |||
755 | static int team_close(struct net_device *dev) | ||
756 | { | ||
757 | netif_carrier_off(dev); | ||
758 | return 0; | ||
759 | } | ||
760 | |||
761 | /* | ||
762 | * note: already called with rcu_read_lock | ||
763 | */ | ||
764 | static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev) | ||
765 | { | ||
766 | struct team *team = netdev_priv(dev); | ||
767 | bool tx_success = false; | ||
768 | unsigned int len = skb->len; | ||
769 | |||
770 | tx_success = team->ops.transmit(team, skb); | ||
771 | if (tx_success) { | ||
772 | struct team_pcpu_stats *pcpu_stats; | ||
773 | |||
774 | pcpu_stats = this_cpu_ptr(team->pcpu_stats); | ||
775 | u64_stats_update_begin(&pcpu_stats->syncp); | ||
776 | pcpu_stats->tx_packets++; | ||
777 | pcpu_stats->tx_bytes += len; | ||
778 | u64_stats_update_end(&pcpu_stats->syncp); | ||
779 | } else { | ||
780 | this_cpu_inc(team->pcpu_stats->tx_dropped); | ||
781 | } | ||
782 | |||
783 | return NETDEV_TX_OK; | ||
784 | } | ||
785 | |||
786 | static void team_change_rx_flags(struct net_device *dev, int change) | ||
787 | { | ||
788 | struct team *team = netdev_priv(dev); | ||
789 | struct team_port *port; | ||
790 | int inc; | ||
791 | |||
792 | rcu_read_lock(); | ||
793 | list_for_each_entry_rcu(port, &team->port_list, list) { | ||
794 | if (change & IFF_PROMISC) { | ||
795 | inc = dev->flags & IFF_PROMISC ? 1 : -1; | ||
796 | dev_set_promiscuity(port->dev, inc); | ||
797 | } | ||
798 | if (change & IFF_ALLMULTI) { | ||
799 | inc = dev->flags & IFF_ALLMULTI ? 1 : -1; | ||
800 | dev_set_allmulti(port->dev, inc); | ||
801 | } | ||
802 | } | ||
803 | rcu_read_unlock(); | ||
804 | } | ||
805 | |||
806 | static void team_set_rx_mode(struct net_device *dev) | ||
807 | { | ||
808 | struct team *team = netdev_priv(dev); | ||
809 | struct team_port *port; | ||
810 | |||
811 | rcu_read_lock(); | ||
812 | list_for_each_entry_rcu(port, &team->port_list, list) { | ||
813 | dev_uc_sync(port->dev, dev); | ||
814 | dev_mc_sync(port->dev, dev); | ||
815 | } | ||
816 | rcu_read_unlock(); | ||
817 | } | ||
818 | |||
819 | static int team_set_mac_address(struct net_device *dev, void *p) | ||
820 | { | ||
821 | struct team *team = netdev_priv(dev); | ||
822 | struct team_port *port; | ||
823 | struct sockaddr *addr = p; | ||
824 | |||
825 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | ||
826 | rcu_read_lock(); | ||
827 | list_for_each_entry_rcu(port, &team->port_list, list) | ||
828 | if (team->ops.port_change_mac) | ||
829 | team->ops.port_change_mac(team, port); | ||
830 | rcu_read_unlock(); | ||
831 | return 0; | ||
832 | } | ||
833 | |||
834 | static int team_change_mtu(struct net_device *dev, int new_mtu) | ||
835 | { | ||
836 | struct team *team = netdev_priv(dev); | ||
837 | struct team_port *port; | ||
838 | int err; | ||
839 | |||
840 | /* | ||
841 | * Alhough this is reader, it's guarded by team lock. It's not possible | ||
842 | * to traverse list in reverse under rcu_read_lock | ||
843 | */ | ||
844 | mutex_lock(&team->lock); | ||
845 | list_for_each_entry(port, &team->port_list, list) { | ||
846 | err = dev_set_mtu(port->dev, new_mtu); | ||
847 | if (err) { | ||
848 | netdev_err(dev, "Device %s failed to change mtu", | ||
849 | port->dev->name); | ||
850 | goto unwind; | ||
851 | } | ||
852 | } | ||
853 | mutex_unlock(&team->lock); | ||
854 | |||
855 | dev->mtu = new_mtu; | ||
856 | |||
857 | return 0; | ||
858 | |||
859 | unwind: | ||
860 | list_for_each_entry_continue_reverse(port, &team->port_list, list) | ||
861 | dev_set_mtu(port->dev, dev->mtu); | ||
862 | mutex_unlock(&team->lock); | ||
863 | |||
864 | return err; | ||
865 | } | ||
866 | |||
867 | static struct rtnl_link_stats64 * | ||
868 | team_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) | ||
869 | { | ||
870 | struct team *team = netdev_priv(dev); | ||
871 | struct team_pcpu_stats *p; | ||
872 | u64 rx_packets, rx_bytes, rx_multicast, tx_packets, tx_bytes; | ||
873 | u32 rx_dropped = 0, tx_dropped = 0; | ||
874 | unsigned int start; | ||
875 | int i; | ||
876 | |||
877 | for_each_possible_cpu(i) { | ||
878 | p = per_cpu_ptr(team->pcpu_stats, i); | ||
879 | do { | ||
880 | start = u64_stats_fetch_begin_bh(&p->syncp); | ||
881 | rx_packets = p->rx_packets; | ||
882 | rx_bytes = p->rx_bytes; | ||
883 | rx_multicast = p->rx_multicast; | ||
884 | tx_packets = p->tx_packets; | ||
885 | tx_bytes = p->tx_bytes; | ||
886 | } while (u64_stats_fetch_retry_bh(&p->syncp, start)); | ||
887 | |||
888 | stats->rx_packets += rx_packets; | ||
889 | stats->rx_bytes += rx_bytes; | ||
890 | stats->multicast += rx_multicast; | ||
891 | stats->tx_packets += tx_packets; | ||
892 | stats->tx_bytes += tx_bytes; | ||
893 | /* | ||
894 | * rx_dropped & tx_dropped are u32, updated | ||
895 | * without syncp protection. | ||
896 | */ | ||
897 | rx_dropped += p->rx_dropped; | ||
898 | tx_dropped += p->tx_dropped; | ||
899 | } | ||
900 | stats->rx_dropped = rx_dropped; | ||
901 | stats->tx_dropped = tx_dropped; | ||
902 | return stats; | ||
903 | } | ||
904 | |||
905 | static void team_vlan_rx_add_vid(struct net_device *dev, uint16_t vid) | ||
906 | { | ||
907 | struct team *team = netdev_priv(dev); | ||
908 | struct team_port *port; | ||
909 | |||
910 | rcu_read_lock(); | ||
911 | list_for_each_entry_rcu(port, &team->port_list, list) { | ||
912 | const struct net_device_ops *ops = port->dev->netdev_ops; | ||
913 | |||
914 | if (ops->ndo_vlan_rx_add_vid) | ||
915 | ops->ndo_vlan_rx_add_vid(port->dev, vid); | ||
916 | } | ||
917 | rcu_read_unlock(); | ||
918 | } | ||
919 | |||
920 | static void team_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid) | ||
921 | { | ||
922 | struct team *team = netdev_priv(dev); | ||
923 | struct team_port *port; | ||
924 | |||
925 | rcu_read_lock(); | ||
926 | list_for_each_entry_rcu(port, &team->port_list, list) { | ||
927 | const struct net_device_ops *ops = port->dev->netdev_ops; | ||
928 | |||
929 | if (ops->ndo_vlan_rx_kill_vid) | ||
930 | ops->ndo_vlan_rx_kill_vid(port->dev, vid); | ||
931 | } | ||
932 | rcu_read_unlock(); | ||
933 | } | ||
934 | |||
935 | static int team_add_slave(struct net_device *dev, struct net_device *port_dev) | ||
936 | { | ||
937 | struct team *team = netdev_priv(dev); | ||
938 | int err; | ||
939 | |||
940 | mutex_lock(&team->lock); | ||
941 | err = team_port_add(team, port_dev); | ||
942 | mutex_unlock(&team->lock); | ||
943 | return err; | ||
944 | } | ||
945 | |||
946 | static int team_del_slave(struct net_device *dev, struct net_device *port_dev) | ||
947 | { | ||
948 | struct team *team = netdev_priv(dev); | ||
949 | int err; | ||
950 | |||
951 | mutex_lock(&team->lock); | ||
952 | err = team_port_del(team, port_dev); | ||
953 | mutex_unlock(&team->lock); | ||
954 | return err; | ||
955 | } | ||
956 | |||
957 | static netdev_features_t team_fix_features(struct net_device *dev, | ||
958 | netdev_features_t features) | ||
959 | { | ||
960 | struct team_port *port; | ||
961 | struct team *team = netdev_priv(dev); | ||
962 | netdev_features_t mask; | ||
963 | |||
964 | mask = features; | ||
965 | features &= ~NETIF_F_ONE_FOR_ALL; | ||
966 | features |= NETIF_F_ALL_FOR_ALL; | ||
967 | |||
968 | rcu_read_lock(); | ||
969 | list_for_each_entry_rcu(port, &team->port_list, list) { | ||
970 | features = netdev_increment_features(features, | ||
971 | port->dev->features, | ||
972 | mask); | ||
973 | } | ||
974 | rcu_read_unlock(); | ||
975 | return features; | ||
976 | } | ||
977 | |||
978 | static const struct net_device_ops team_netdev_ops = { | ||
979 | .ndo_init = team_init, | ||
980 | .ndo_uninit = team_uninit, | ||
981 | .ndo_open = team_open, | ||
982 | .ndo_stop = team_close, | ||
983 | .ndo_start_xmit = team_xmit, | ||
984 | .ndo_change_rx_flags = team_change_rx_flags, | ||
985 | .ndo_set_rx_mode = team_set_rx_mode, | ||
986 | .ndo_set_mac_address = team_set_mac_address, | ||
987 | .ndo_change_mtu = team_change_mtu, | ||
988 | .ndo_get_stats64 = team_get_stats64, | ||
989 | .ndo_vlan_rx_add_vid = team_vlan_rx_add_vid, | ||
990 | .ndo_vlan_rx_kill_vid = team_vlan_rx_kill_vid, | ||
991 | .ndo_add_slave = team_add_slave, | ||
992 | .ndo_del_slave = team_del_slave, | ||
993 | .ndo_fix_features = team_fix_features, | ||
994 | }; | ||
995 | |||
996 | |||
997 | /*********************** | ||
998 | * rt netlink interface | ||
999 | ***********************/ | ||
1000 | |||
1001 | static void team_setup(struct net_device *dev) | ||
1002 | { | ||
1003 | ether_setup(dev); | ||
1004 | |||
1005 | dev->netdev_ops = &team_netdev_ops; | ||
1006 | dev->destructor = team_destructor; | ||
1007 | dev->tx_queue_len = 0; | ||
1008 | dev->flags |= IFF_MULTICAST; | ||
1009 | dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); | ||
1010 | |||
1011 | /* | ||
1012 | * Indicate we support unicast address filtering. That way core won't | ||
1013 | * bring us to promisc mode in case a unicast addr is added. | ||
1014 | * Let this up to underlay drivers. | ||
1015 | */ | ||
1016 | dev->priv_flags |= IFF_UNICAST_FLT; | ||
1017 | |||
1018 | dev->features |= NETIF_F_LLTX; | ||
1019 | dev->features |= NETIF_F_GRO; | ||
1020 | dev->hw_features = NETIF_F_HW_VLAN_TX | | ||
1021 | NETIF_F_HW_VLAN_RX | | ||
1022 | NETIF_F_HW_VLAN_FILTER; | ||
1023 | |||
1024 | dev->features |= dev->hw_features; | ||
1025 | } | ||
1026 | |||
1027 | static int team_newlink(struct net *src_net, struct net_device *dev, | ||
1028 | struct nlattr *tb[], struct nlattr *data[]) | ||
1029 | { | ||
1030 | int err; | ||
1031 | |||
1032 | if (tb[IFLA_ADDRESS] == NULL) | ||
1033 | random_ether_addr(dev->dev_addr); | ||
1034 | |||
1035 | err = register_netdevice(dev); | ||
1036 | if (err) | ||
1037 | return err; | ||
1038 | |||
1039 | return 0; | ||
1040 | } | ||
1041 | |||
1042 | static int team_validate(struct nlattr *tb[], struct nlattr *data[]) | ||
1043 | { | ||
1044 | if (tb[IFLA_ADDRESS]) { | ||
1045 | if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) | ||
1046 | return -EINVAL; | ||
1047 | if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) | ||
1048 | return -EADDRNOTAVAIL; | ||
1049 | } | ||
1050 | return 0; | ||
1051 | } | ||
1052 | |||
1053 | static struct rtnl_link_ops team_link_ops __read_mostly = { | ||
1054 | .kind = DRV_NAME, | ||
1055 | .priv_size = sizeof(struct team), | ||
1056 | .setup = team_setup, | ||
1057 | .newlink = team_newlink, | ||
1058 | .validate = team_validate, | ||
1059 | }; | ||
1060 | |||
1061 | |||
1062 | /*********************************** | ||
1063 | * Generic netlink custom interface | ||
1064 | ***********************************/ | ||
1065 | |||
1066 | static struct genl_family team_nl_family = { | ||
1067 | .id = GENL_ID_GENERATE, | ||
1068 | .name = TEAM_GENL_NAME, | ||
1069 | .version = TEAM_GENL_VERSION, | ||
1070 | .maxattr = TEAM_ATTR_MAX, | ||
1071 | .netnsok = true, | ||
1072 | }; | ||
1073 | |||
1074 | static const struct nla_policy team_nl_policy[TEAM_ATTR_MAX + 1] = { | ||
1075 | [TEAM_ATTR_UNSPEC] = { .type = NLA_UNSPEC, }, | ||
1076 | [TEAM_ATTR_TEAM_IFINDEX] = { .type = NLA_U32 }, | ||
1077 | [TEAM_ATTR_LIST_OPTION] = { .type = NLA_NESTED }, | ||
1078 | [TEAM_ATTR_LIST_PORT] = { .type = NLA_NESTED }, | ||
1079 | }; | ||
1080 | |||
1081 | static const struct nla_policy | ||
1082 | team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = { | ||
1083 | [TEAM_ATTR_OPTION_UNSPEC] = { .type = NLA_UNSPEC, }, | ||
1084 | [TEAM_ATTR_OPTION_NAME] = { | ||
1085 | .type = NLA_STRING, | ||
1086 | .len = TEAM_STRING_MAX_LEN, | ||
1087 | }, | ||
1088 | [TEAM_ATTR_OPTION_CHANGED] = { .type = NLA_FLAG }, | ||
1089 | [TEAM_ATTR_OPTION_TYPE] = { .type = NLA_U8 }, | ||
1090 | [TEAM_ATTR_OPTION_DATA] = { | ||
1091 | .type = NLA_BINARY, | ||
1092 | .len = TEAM_STRING_MAX_LEN, | ||
1093 | }, | ||
1094 | }; | ||
1095 | |||
1096 | static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info) | ||
1097 | { | ||
1098 | struct sk_buff *msg; | ||
1099 | void *hdr; | ||
1100 | int err; | ||
1101 | |||
1102 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
1103 | if (!msg) | ||
1104 | return -ENOMEM; | ||
1105 | |||
1106 | hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, | ||
1107 | &team_nl_family, 0, TEAM_CMD_NOOP); | ||
1108 | if (IS_ERR(hdr)) { | ||
1109 | err = PTR_ERR(hdr); | ||
1110 | goto err_msg_put; | ||
1111 | } | ||
1112 | |||
1113 | genlmsg_end(msg, hdr); | ||
1114 | |||
1115 | return genlmsg_unicast(genl_info_net(info), msg, info->snd_pid); | ||
1116 | |||
1117 | err_msg_put: | ||
1118 | nlmsg_free(msg); | ||
1119 | |||
1120 | return err; | ||
1121 | } | ||
1122 | |||
1123 | /* | ||
1124 | * Netlink cmd functions should be locked by following two functions. | ||
1125 | * Since dev gets held here, that ensures dev won't disappear in between. | ||
1126 | */ | ||
1127 | static struct team *team_nl_team_get(struct genl_info *info) | ||
1128 | { | ||
1129 | struct net *net = genl_info_net(info); | ||
1130 | int ifindex; | ||
1131 | struct net_device *dev; | ||
1132 | struct team *team; | ||
1133 | |||
1134 | if (!info->attrs[TEAM_ATTR_TEAM_IFINDEX]) | ||
1135 | return NULL; | ||
1136 | |||
1137 | ifindex = nla_get_u32(info->attrs[TEAM_ATTR_TEAM_IFINDEX]); | ||
1138 | dev = dev_get_by_index(net, ifindex); | ||
1139 | if (!dev || dev->netdev_ops != &team_netdev_ops) { | ||
1140 | if (dev) | ||
1141 | dev_put(dev); | ||
1142 | return NULL; | ||
1143 | } | ||
1144 | |||
1145 | team = netdev_priv(dev); | ||
1146 | mutex_lock(&team->lock); | ||
1147 | return team; | ||
1148 | } | ||
1149 | |||
1150 | static void team_nl_team_put(struct team *team) | ||
1151 | { | ||
1152 | mutex_unlock(&team->lock); | ||
1153 | dev_put(team->dev); | ||
1154 | } | ||
1155 | |||
1156 | static int team_nl_send_generic(struct genl_info *info, struct team *team, | ||
1157 | int (*fill_func)(struct sk_buff *skb, | ||
1158 | struct genl_info *info, | ||
1159 | int flags, struct team *team)) | ||
1160 | { | ||
1161 | struct sk_buff *skb; | ||
1162 | int err; | ||
1163 | |||
1164 | skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
1165 | if (!skb) | ||
1166 | return -ENOMEM; | ||
1167 | |||
1168 | err = fill_func(skb, info, NLM_F_ACK, team); | ||
1169 | if (err < 0) | ||
1170 | goto err_fill; | ||
1171 | |||
1172 | err = genlmsg_unicast(genl_info_net(info), skb, info->snd_pid); | ||
1173 | return err; | ||
1174 | |||
1175 | err_fill: | ||
1176 | nlmsg_free(skb); | ||
1177 | return err; | ||
1178 | } | ||
1179 | |||
1180 | static int team_nl_fill_options_get_changed(struct sk_buff *skb, | ||
1181 | u32 pid, u32 seq, int flags, | ||
1182 | struct team *team, | ||
1183 | struct team_option *changed_option) | ||
1184 | { | ||
1185 | struct nlattr *option_list; | ||
1186 | void *hdr; | ||
1187 | struct team_option *option; | ||
1188 | |||
1189 | hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags, | ||
1190 | TEAM_CMD_OPTIONS_GET); | ||
1191 | if (IS_ERR(hdr)) | ||
1192 | return PTR_ERR(hdr); | ||
1193 | |||
1194 | NLA_PUT_U32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex); | ||
1195 | option_list = nla_nest_start(skb, TEAM_ATTR_LIST_OPTION); | ||
1196 | if (!option_list) | ||
1197 | return -EMSGSIZE; | ||
1198 | |||
1199 | list_for_each_entry(option, &team->option_list, list) { | ||
1200 | struct nlattr *option_item; | ||
1201 | long arg; | ||
1202 | |||
1203 | option_item = nla_nest_start(skb, TEAM_ATTR_ITEM_OPTION); | ||
1204 | if (!option_item) | ||
1205 | goto nla_put_failure; | ||
1206 | NLA_PUT_STRING(skb, TEAM_ATTR_OPTION_NAME, option->name); | ||
1207 | if (option == changed_option) | ||
1208 | NLA_PUT_FLAG(skb, TEAM_ATTR_OPTION_CHANGED); | ||
1209 | switch (option->type) { | ||
1210 | case TEAM_OPTION_TYPE_U32: | ||
1211 | NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_U32); | ||
1212 | team_option_get(team, option, &arg); | ||
1213 | NLA_PUT_U32(skb, TEAM_ATTR_OPTION_DATA, arg); | ||
1214 | break; | ||
1215 | case TEAM_OPTION_TYPE_STRING: | ||
1216 | NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_STRING); | ||
1217 | team_option_get(team, option, &arg); | ||
1218 | NLA_PUT_STRING(skb, TEAM_ATTR_OPTION_DATA, | ||
1219 | (char *) arg); | ||
1220 | break; | ||
1221 | default: | ||
1222 | BUG(); | ||
1223 | } | ||
1224 | nla_nest_end(skb, option_item); | ||
1225 | } | ||
1226 | |||
1227 | nla_nest_end(skb, option_list); | ||
1228 | return genlmsg_end(skb, hdr); | ||
1229 | |||
1230 | nla_put_failure: | ||
1231 | genlmsg_cancel(skb, hdr); | ||
1232 | return -EMSGSIZE; | ||
1233 | } | ||
1234 | |||
1235 | static int team_nl_fill_options_get(struct sk_buff *skb, | ||
1236 | struct genl_info *info, int flags, | ||
1237 | struct team *team) | ||
1238 | { | ||
1239 | return team_nl_fill_options_get_changed(skb, info->snd_pid, | ||
1240 | info->snd_seq, NLM_F_ACK, | ||
1241 | team, NULL); | ||
1242 | } | ||
1243 | |||
1244 | static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info) | ||
1245 | { | ||
1246 | struct team *team; | ||
1247 | int err; | ||
1248 | |||
1249 | team = team_nl_team_get(info); | ||
1250 | if (!team) | ||
1251 | return -EINVAL; | ||
1252 | |||
1253 | err = team_nl_send_generic(info, team, team_nl_fill_options_get); | ||
1254 | |||
1255 | team_nl_team_put(team); | ||
1256 | |||
1257 | return err; | ||
1258 | } | ||
1259 | |||
1260 | static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info) | ||
1261 | { | ||
1262 | struct team *team; | ||
1263 | int err = 0; | ||
1264 | int i; | ||
1265 | struct nlattr *nl_option; | ||
1266 | |||
1267 | team = team_nl_team_get(info); | ||
1268 | if (!team) | ||
1269 | return -EINVAL; | ||
1270 | |||
1271 | err = -EINVAL; | ||
1272 | if (!info->attrs[TEAM_ATTR_LIST_OPTION]) { | ||
1273 | err = -EINVAL; | ||
1274 | goto team_put; | ||
1275 | } | ||
1276 | |||
1277 | nla_for_each_nested(nl_option, info->attrs[TEAM_ATTR_LIST_OPTION], i) { | ||
1278 | struct nlattr *mode_attrs[TEAM_ATTR_OPTION_MAX + 1]; | ||
1279 | enum team_option_type opt_type; | ||
1280 | struct team_option *option; | ||
1281 | char *opt_name; | ||
1282 | bool opt_found = false; | ||
1283 | |||
1284 | if (nla_type(nl_option) != TEAM_ATTR_ITEM_OPTION) { | ||
1285 | err = -EINVAL; | ||
1286 | goto team_put; | ||
1287 | } | ||
1288 | err = nla_parse_nested(mode_attrs, TEAM_ATTR_OPTION_MAX, | ||
1289 | nl_option, team_nl_option_policy); | ||
1290 | if (err) | ||
1291 | goto team_put; | ||
1292 | if (!mode_attrs[TEAM_ATTR_OPTION_NAME] || | ||
1293 | !mode_attrs[TEAM_ATTR_OPTION_TYPE] || | ||
1294 | !mode_attrs[TEAM_ATTR_OPTION_DATA]) { | ||
1295 | err = -EINVAL; | ||
1296 | goto team_put; | ||
1297 | } | ||
1298 | switch (nla_get_u8(mode_attrs[TEAM_ATTR_OPTION_TYPE])) { | ||
1299 | case NLA_U32: | ||
1300 | opt_type = TEAM_OPTION_TYPE_U32; | ||
1301 | break; | ||
1302 | case NLA_STRING: | ||
1303 | opt_type = TEAM_OPTION_TYPE_STRING; | ||
1304 | break; | ||
1305 | default: | ||
1306 | goto team_put; | ||
1307 | } | ||
1308 | |||
1309 | opt_name = nla_data(mode_attrs[TEAM_ATTR_OPTION_NAME]); | ||
1310 | list_for_each_entry(option, &team->option_list, list) { | ||
1311 | long arg; | ||
1312 | struct nlattr *opt_data_attr; | ||
1313 | |||
1314 | if (option->type != opt_type || | ||
1315 | strcmp(option->name, opt_name)) | ||
1316 | continue; | ||
1317 | opt_found = true; | ||
1318 | opt_data_attr = mode_attrs[TEAM_ATTR_OPTION_DATA]; | ||
1319 | switch (opt_type) { | ||
1320 | case TEAM_OPTION_TYPE_U32: | ||
1321 | arg = nla_get_u32(opt_data_attr); | ||
1322 | break; | ||
1323 | case TEAM_OPTION_TYPE_STRING: | ||
1324 | arg = (long) nla_data(opt_data_attr); | ||
1325 | break; | ||
1326 | default: | ||
1327 | BUG(); | ||
1328 | } | ||
1329 | err = team_option_set(team, option, &arg); | ||
1330 | if (err) | ||
1331 | goto team_put; | ||
1332 | } | ||
1333 | if (!opt_found) { | ||
1334 | err = -ENOENT; | ||
1335 | goto team_put; | ||
1336 | } | ||
1337 | } | ||
1338 | |||
1339 | team_put: | ||
1340 | team_nl_team_put(team); | ||
1341 | |||
1342 | return err; | ||
1343 | } | ||
1344 | |||
1345 | static int team_nl_fill_port_list_get_changed(struct sk_buff *skb, | ||
1346 | u32 pid, u32 seq, int flags, | ||
1347 | struct team *team, | ||
1348 | struct team_port *changed_port) | ||
1349 | { | ||
1350 | struct nlattr *port_list; | ||
1351 | void *hdr; | ||
1352 | struct team_port *port; | ||
1353 | |||
1354 | hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags, | ||
1355 | TEAM_CMD_PORT_LIST_GET); | ||
1356 | if (IS_ERR(hdr)) | ||
1357 | return PTR_ERR(hdr); | ||
1358 | |||
1359 | NLA_PUT_U32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex); | ||
1360 | port_list = nla_nest_start(skb, TEAM_ATTR_LIST_PORT); | ||
1361 | if (!port_list) | ||
1362 | return -EMSGSIZE; | ||
1363 | |||
1364 | list_for_each_entry(port, &team->port_list, list) { | ||
1365 | struct nlattr *port_item; | ||
1366 | |||
1367 | port_item = nla_nest_start(skb, TEAM_ATTR_ITEM_PORT); | ||
1368 | if (!port_item) | ||
1369 | goto nla_put_failure; | ||
1370 | NLA_PUT_U32(skb, TEAM_ATTR_PORT_IFINDEX, port->dev->ifindex); | ||
1371 | if (port == changed_port) | ||
1372 | NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_CHANGED); | ||
1373 | if (port->linkup) | ||
1374 | NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_LINKUP); | ||
1375 | NLA_PUT_U32(skb, TEAM_ATTR_PORT_SPEED, port->speed); | ||
1376 | NLA_PUT_U8(skb, TEAM_ATTR_PORT_DUPLEX, port->duplex); | ||
1377 | nla_nest_end(skb, port_item); | ||
1378 | } | ||
1379 | |||
1380 | nla_nest_end(skb, port_list); | ||
1381 | return genlmsg_end(skb, hdr); | ||
1382 | |||
1383 | nla_put_failure: | ||
1384 | genlmsg_cancel(skb, hdr); | ||
1385 | return -EMSGSIZE; | ||
1386 | } | ||
1387 | |||
1388 | static int team_nl_fill_port_list_get(struct sk_buff *skb, | ||
1389 | struct genl_info *info, int flags, | ||
1390 | struct team *team) | ||
1391 | { | ||
1392 | return team_nl_fill_port_list_get_changed(skb, info->snd_pid, | ||
1393 | info->snd_seq, NLM_F_ACK, | ||
1394 | team, NULL); | ||
1395 | } | ||
1396 | |||
1397 | static int team_nl_cmd_port_list_get(struct sk_buff *skb, | ||
1398 | struct genl_info *info) | ||
1399 | { | ||
1400 | struct team *team; | ||
1401 | int err; | ||
1402 | |||
1403 | team = team_nl_team_get(info); | ||
1404 | if (!team) | ||
1405 | return -EINVAL; | ||
1406 | |||
1407 | err = team_nl_send_generic(info, team, team_nl_fill_port_list_get); | ||
1408 | |||
1409 | team_nl_team_put(team); | ||
1410 | |||
1411 | return err; | ||
1412 | } | ||
1413 | |||
1414 | static struct genl_ops team_nl_ops[] = { | ||
1415 | { | ||
1416 | .cmd = TEAM_CMD_NOOP, | ||
1417 | .doit = team_nl_cmd_noop, | ||
1418 | .policy = team_nl_policy, | ||
1419 | }, | ||
1420 | { | ||
1421 | .cmd = TEAM_CMD_OPTIONS_SET, | ||
1422 | .doit = team_nl_cmd_options_set, | ||
1423 | .policy = team_nl_policy, | ||
1424 | .flags = GENL_ADMIN_PERM, | ||
1425 | }, | ||
1426 | { | ||
1427 | .cmd = TEAM_CMD_OPTIONS_GET, | ||
1428 | .doit = team_nl_cmd_options_get, | ||
1429 | .policy = team_nl_policy, | ||
1430 | .flags = GENL_ADMIN_PERM, | ||
1431 | }, | ||
1432 | { | ||
1433 | .cmd = TEAM_CMD_PORT_LIST_GET, | ||
1434 | .doit = team_nl_cmd_port_list_get, | ||
1435 | .policy = team_nl_policy, | ||
1436 | .flags = GENL_ADMIN_PERM, | ||
1437 | }, | ||
1438 | }; | ||
1439 | |||
1440 | static struct genl_multicast_group team_change_event_mcgrp = { | ||
1441 | .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, | ||
1442 | }; | ||
1443 | |||
1444 | static int team_nl_send_event_options_get(struct team *team, | ||
1445 | struct team_option *changed_option) | ||
1446 | { | ||
1447 | struct sk_buff *skb; | ||
1448 | int err; | ||
1449 | struct net *net = dev_net(team->dev); | ||
1450 | |||
1451 | skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
1452 | if (!skb) | ||
1453 | return -ENOMEM; | ||
1454 | |||
1455 | err = team_nl_fill_options_get_changed(skb, 0, 0, 0, team, | ||
1456 | changed_option); | ||
1457 | if (err < 0) | ||
1458 | goto err_fill; | ||
1459 | |||
1460 | err = genlmsg_multicast_netns(net, skb, 0, team_change_event_mcgrp.id, | ||
1461 | GFP_KERNEL); | ||
1462 | return err; | ||
1463 | |||
1464 | err_fill: | ||
1465 | nlmsg_free(skb); | ||
1466 | return err; | ||
1467 | } | ||
1468 | |||
1469 | static int team_nl_send_event_port_list_get(struct team_port *port) | ||
1470 | { | ||
1471 | struct sk_buff *skb; | ||
1472 | int err; | ||
1473 | struct net *net = dev_net(port->team->dev); | ||
1474 | |||
1475 | skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
1476 | if (!skb) | ||
1477 | return -ENOMEM; | ||
1478 | |||
1479 | err = team_nl_fill_port_list_get_changed(skb, 0, 0, 0, | ||
1480 | port->team, port); | ||
1481 | if (err < 0) | ||
1482 | goto err_fill; | ||
1483 | |||
1484 | err = genlmsg_multicast_netns(net, skb, 0, team_change_event_mcgrp.id, | ||
1485 | GFP_KERNEL); | ||
1486 | return err; | ||
1487 | |||
1488 | err_fill: | ||
1489 | nlmsg_free(skb); | ||
1490 | return err; | ||
1491 | } | ||
1492 | |||
1493 | static int team_nl_init(void) | ||
1494 | { | ||
1495 | int err; | ||
1496 | |||
1497 | err = genl_register_family_with_ops(&team_nl_family, team_nl_ops, | ||
1498 | ARRAY_SIZE(team_nl_ops)); | ||
1499 | if (err) | ||
1500 | return err; | ||
1501 | |||
1502 | err = genl_register_mc_group(&team_nl_family, &team_change_event_mcgrp); | ||
1503 | if (err) | ||
1504 | goto err_change_event_grp_reg; | ||
1505 | |||
1506 | return 0; | ||
1507 | |||
1508 | err_change_event_grp_reg: | ||
1509 | genl_unregister_family(&team_nl_family); | ||
1510 | |||
1511 | return err; | ||
1512 | } | ||
1513 | |||
1514 | static void team_nl_fini(void) | ||
1515 | { | ||
1516 | genl_unregister_family(&team_nl_family); | ||
1517 | } | ||
1518 | |||
1519 | |||
1520 | /****************** | ||
1521 | * Change checkers | ||
1522 | ******************/ | ||
1523 | |||
1524 | static void __team_options_change_check(struct team *team, | ||
1525 | struct team_option *changed_option) | ||
1526 | { | ||
1527 | int err; | ||
1528 | |||
1529 | err = team_nl_send_event_options_get(team, changed_option); | ||
1530 | if (err) | ||
1531 | netdev_warn(team->dev, "Failed to send options change via netlink\n"); | ||
1532 | } | ||
1533 | |||
1534 | /* rtnl lock is held */ | ||
1535 | static void __team_port_change_check(struct team_port *port, bool linkup) | ||
1536 | { | ||
1537 | int err; | ||
1538 | |||
1539 | if (port->linkup == linkup) | ||
1540 | return; | ||
1541 | |||
1542 | port->linkup = linkup; | ||
1543 | if (linkup) { | ||
1544 | struct ethtool_cmd ecmd; | ||
1545 | |||
1546 | err = __ethtool_get_settings(port->dev, &ecmd); | ||
1547 | if (!err) { | ||
1548 | port->speed = ethtool_cmd_speed(&ecmd); | ||
1549 | port->duplex = ecmd.duplex; | ||
1550 | goto send_event; | ||
1551 | } | ||
1552 | } | ||
1553 | port->speed = 0; | ||
1554 | port->duplex = 0; | ||
1555 | |||
1556 | send_event: | ||
1557 | err = team_nl_send_event_port_list_get(port); | ||
1558 | if (err) | ||
1559 | netdev_warn(port->team->dev, "Failed to send port change of device %s via netlink\n", | ||
1560 | port->dev->name); | ||
1561 | |||
1562 | } | ||
1563 | |||
1564 | static void team_port_change_check(struct team_port *port, bool linkup) | ||
1565 | { | ||
1566 | struct team *team = port->team; | ||
1567 | |||
1568 | mutex_lock(&team->lock); | ||
1569 | __team_port_change_check(port, linkup); | ||
1570 | mutex_unlock(&team->lock); | ||
1571 | } | ||
1572 | |||
1573 | /************************************ | ||
1574 | * Net device notifier event handler | ||
1575 | ************************************/ | ||
1576 | |||
1577 | static int team_device_event(struct notifier_block *unused, | ||
1578 | unsigned long event, void *ptr) | ||
1579 | { | ||
1580 | struct net_device *dev = (struct net_device *) ptr; | ||
1581 | struct team_port *port; | ||
1582 | |||
1583 | port = team_port_get_rtnl(dev); | ||
1584 | if (!port) | ||
1585 | return NOTIFY_DONE; | ||
1586 | |||
1587 | switch (event) { | ||
1588 | case NETDEV_UP: | ||
1589 | if (netif_carrier_ok(dev)) | ||
1590 | team_port_change_check(port, true); | ||
1591 | case NETDEV_DOWN: | ||
1592 | team_port_change_check(port, false); | ||
1593 | case NETDEV_CHANGE: | ||
1594 | if (netif_running(port->dev)) | ||
1595 | team_port_change_check(port, | ||
1596 | !!netif_carrier_ok(port->dev)); | ||
1597 | break; | ||
1598 | case NETDEV_UNREGISTER: | ||
1599 | team_del_slave(port->team->dev, dev); | ||
1600 | break; | ||
1601 | case NETDEV_FEAT_CHANGE: | ||
1602 | team_compute_features(port->team); | ||
1603 | break; | ||
1604 | case NETDEV_CHANGEMTU: | ||
1605 | /* Forbid to change mtu of underlaying device */ | ||
1606 | return NOTIFY_BAD; | ||
1607 | case NETDEV_PRE_TYPE_CHANGE: | ||
1608 | /* Forbid to change type of underlaying device */ | ||
1609 | return NOTIFY_BAD; | ||
1610 | } | ||
1611 | return NOTIFY_DONE; | ||
1612 | } | ||
1613 | |||
1614 | static struct notifier_block team_notifier_block __read_mostly = { | ||
1615 | .notifier_call = team_device_event, | ||
1616 | }; | ||
1617 | |||
1618 | |||
1619 | /*********************** | ||
1620 | * Module init and exit | ||
1621 | ***********************/ | ||
1622 | |||
1623 | static int __init team_module_init(void) | ||
1624 | { | ||
1625 | int err; | ||
1626 | |||
1627 | register_netdevice_notifier(&team_notifier_block); | ||
1628 | |||
1629 | err = rtnl_link_register(&team_link_ops); | ||
1630 | if (err) | ||
1631 | goto err_rtnl_reg; | ||
1632 | |||
1633 | err = team_nl_init(); | ||
1634 | if (err) | ||
1635 | goto err_nl_init; | ||
1636 | |||
1637 | return 0; | ||
1638 | |||
1639 | err_nl_init: | ||
1640 | rtnl_link_unregister(&team_link_ops); | ||
1641 | |||
1642 | err_rtnl_reg: | ||
1643 | unregister_netdevice_notifier(&team_notifier_block); | ||
1644 | |||
1645 | return err; | ||
1646 | } | ||
1647 | |||
1648 | static void __exit team_module_exit(void) | ||
1649 | { | ||
1650 | team_nl_fini(); | ||
1651 | rtnl_link_unregister(&team_link_ops); | ||
1652 | unregister_netdevice_notifier(&team_notifier_block); | ||
1653 | } | ||
1654 | |||
1655 | module_init(team_module_init); | ||
1656 | module_exit(team_module_exit); | ||
1657 | |||
1658 | MODULE_LICENSE("GPL v2"); | ||
1659 | MODULE_AUTHOR("Jiri Pirko <jpirko@redhat.com>"); | ||
1660 | MODULE_DESCRIPTION("Ethernet team device driver"); | ||
1661 | MODULE_ALIAS_RTNL_LINK(DRV_NAME); | ||
diff --git a/drivers/net/team/team_mode_activebackup.c b/drivers/net/team/team_mode_activebackup.c new file mode 100644 index 000000000000..b34427502b54 --- /dev/null +++ b/drivers/net/team/team_mode_activebackup.c | |||
@@ -0,0 +1,136 @@ | |||
1 | /* | ||
2 | * net/drivers/team/team_mode_activebackup.c - Active-backup mode for team | ||
3 | * Copyright (c) 2011 Jiri Pirko <jpirko@redhat.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/types.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/errno.h> | ||
16 | #include <linux/netdevice.h> | ||
17 | #include <net/rtnetlink.h> | ||
18 | #include <linux/if_team.h> | ||
19 | |||
20 | struct ab_priv { | ||
21 | struct team_port __rcu *active_port; | ||
22 | }; | ||
23 | |||
24 | static struct ab_priv *ab_priv(struct team *team) | ||
25 | { | ||
26 | return (struct ab_priv *) &team->mode_priv; | ||
27 | } | ||
28 | |||
29 | static rx_handler_result_t ab_receive(struct team *team, struct team_port *port, | ||
30 | struct sk_buff *skb) { | ||
31 | struct team_port *active_port; | ||
32 | |||
33 | active_port = rcu_dereference(ab_priv(team)->active_port); | ||
34 | if (active_port != port) | ||
35 | return RX_HANDLER_EXACT; | ||
36 | return RX_HANDLER_ANOTHER; | ||
37 | } | ||
38 | |||
39 | static bool ab_transmit(struct team *team, struct sk_buff *skb) | ||
40 | { | ||
41 | struct team_port *active_port; | ||
42 | |||
43 | active_port = rcu_dereference(ab_priv(team)->active_port); | ||
44 | if (unlikely(!active_port)) | ||
45 | goto drop; | ||
46 | skb->dev = active_port->dev; | ||
47 | if (dev_queue_xmit(skb)) | ||
48 | return false; | ||
49 | return true; | ||
50 | |||
51 | drop: | ||
52 | dev_kfree_skb_any(skb); | ||
53 | return false; | ||
54 | } | ||
55 | |||
56 | static void ab_port_leave(struct team *team, struct team_port *port) | ||
57 | { | ||
58 | if (ab_priv(team)->active_port == port) | ||
59 | rcu_assign_pointer(ab_priv(team)->active_port, NULL); | ||
60 | } | ||
61 | |||
62 | static int ab_active_port_get(struct team *team, void *arg) | ||
63 | { | ||
64 | u32 *ifindex = arg; | ||
65 | |||
66 | *ifindex = 0; | ||
67 | if (ab_priv(team)->active_port) | ||
68 | *ifindex = ab_priv(team)->active_port->dev->ifindex; | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | static int ab_active_port_set(struct team *team, void *arg) | ||
73 | { | ||
74 | u32 *ifindex = arg; | ||
75 | struct team_port *port; | ||
76 | |||
77 | list_for_each_entry_rcu(port, &team->port_list, list) { | ||
78 | if (port->dev->ifindex == *ifindex) { | ||
79 | rcu_assign_pointer(ab_priv(team)->active_port, port); | ||
80 | return 0; | ||
81 | } | ||
82 | } | ||
83 | return -ENOENT; | ||
84 | } | ||
85 | |||
86 | static const struct team_option ab_options[] = { | ||
87 | { | ||
88 | .name = "activeport", | ||
89 | .type = TEAM_OPTION_TYPE_U32, | ||
90 | .getter = ab_active_port_get, | ||
91 | .setter = ab_active_port_set, | ||
92 | }, | ||
93 | }; | ||
94 | |||
95 | int ab_init(struct team *team) | ||
96 | { | ||
97 | return team_options_register(team, ab_options, ARRAY_SIZE(ab_options)); | ||
98 | } | ||
99 | |||
100 | void ab_exit(struct team *team) | ||
101 | { | ||
102 | team_options_unregister(team, ab_options, ARRAY_SIZE(ab_options)); | ||
103 | } | ||
104 | |||
105 | static const struct team_mode_ops ab_mode_ops = { | ||
106 | .init = ab_init, | ||
107 | .exit = ab_exit, | ||
108 | .receive = ab_receive, | ||
109 | .transmit = ab_transmit, | ||
110 | .port_leave = ab_port_leave, | ||
111 | }; | ||
112 | |||
113 | static struct team_mode ab_mode = { | ||
114 | .kind = "activebackup", | ||
115 | .owner = THIS_MODULE, | ||
116 | .priv_size = sizeof(struct ab_priv), | ||
117 | .ops = &ab_mode_ops, | ||
118 | }; | ||
119 | |||
120 | static int __init ab_init_module(void) | ||
121 | { | ||
122 | return team_mode_register(&ab_mode); | ||
123 | } | ||
124 | |||
125 | static void __exit ab_cleanup_module(void) | ||
126 | { | ||
127 | team_mode_unregister(&ab_mode); | ||
128 | } | ||
129 | |||
130 | module_init(ab_init_module); | ||
131 | module_exit(ab_cleanup_module); | ||
132 | |||
133 | MODULE_LICENSE("GPL v2"); | ||
134 | MODULE_AUTHOR("Jiri Pirko <jpirko@redhat.com>"); | ||
135 | MODULE_DESCRIPTION("Active-backup mode for team"); | ||
136 | MODULE_ALIAS("team-mode-activebackup"); | ||
diff --git a/drivers/net/team/team_mode_roundrobin.c b/drivers/net/team/team_mode_roundrobin.c new file mode 100644 index 000000000000..a0e8f806331a --- /dev/null +++ b/drivers/net/team/team_mode_roundrobin.c | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * net/drivers/team/team_mode_roundrobin.c - Round-robin mode for team | ||
3 | * Copyright (c) 2011 Jiri Pirko <jpirko@redhat.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/types.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/errno.h> | ||
16 | #include <linux/netdevice.h> | ||
17 | #include <linux/if_team.h> | ||
18 | |||
19 | struct rr_priv { | ||
20 | unsigned int sent_packets; | ||
21 | }; | ||
22 | |||
23 | static struct rr_priv *rr_priv(struct team *team) | ||
24 | { | ||
25 | return (struct rr_priv *) &team->mode_priv; | ||
26 | } | ||
27 | |||
28 | static struct team_port *__get_first_port_up(struct team *team, | ||
29 | struct team_port *port) | ||
30 | { | ||
31 | struct team_port *cur; | ||
32 | |||
33 | if (port->linkup) | ||
34 | return port; | ||
35 | cur = port; | ||
36 | list_for_each_entry_continue_rcu(cur, &team->port_list, list) | ||
37 | if (cur->linkup) | ||
38 | return cur; | ||
39 | list_for_each_entry_rcu(cur, &team->port_list, list) { | ||
40 | if (cur == port) | ||
41 | break; | ||
42 | if (cur->linkup) | ||
43 | return cur; | ||
44 | } | ||
45 | return NULL; | ||
46 | } | ||
47 | |||
48 | static bool rr_transmit(struct team *team, struct sk_buff *skb) | ||
49 | { | ||
50 | struct team_port *port; | ||
51 | int port_index; | ||
52 | |||
53 | port_index = rr_priv(team)->sent_packets++ % team->port_count; | ||
54 | port = team_get_port_by_index_rcu(team, port_index); | ||
55 | port = __get_first_port_up(team, port); | ||
56 | if (unlikely(!port)) | ||
57 | goto drop; | ||
58 | skb->dev = port->dev; | ||
59 | if (dev_queue_xmit(skb)) | ||
60 | return false; | ||
61 | return true; | ||
62 | |||
63 | drop: | ||
64 | dev_kfree_skb_any(skb); | ||
65 | return false; | ||
66 | } | ||
67 | |||
68 | static int rr_port_enter(struct team *team, struct team_port *port) | ||
69 | { | ||
70 | return team_port_set_team_mac(port); | ||
71 | } | ||
72 | |||
73 | static void rr_port_change_mac(struct team *team, struct team_port *port) | ||
74 | { | ||
75 | team_port_set_team_mac(port); | ||
76 | } | ||
77 | |||
78 | static const struct team_mode_ops rr_mode_ops = { | ||
79 | .transmit = rr_transmit, | ||
80 | .port_enter = rr_port_enter, | ||
81 | .port_change_mac = rr_port_change_mac, | ||
82 | }; | ||
83 | |||
84 | static struct team_mode rr_mode = { | ||
85 | .kind = "roundrobin", | ||
86 | .owner = THIS_MODULE, | ||
87 | .priv_size = sizeof(struct rr_priv), | ||
88 | .ops = &rr_mode_ops, | ||
89 | }; | ||
90 | |||
91 | static int __init rr_init_module(void) | ||
92 | { | ||
93 | return team_mode_register(&rr_mode); | ||
94 | } | ||
95 | |||
96 | static void __exit rr_cleanup_module(void) | ||
97 | { | ||
98 | team_mode_unregister(&rr_mode); | ||
99 | } | ||
100 | |||
101 | module_init(rr_init_module); | ||
102 | module_exit(rr_cleanup_module); | ||
103 | |||
104 | MODULE_LICENSE("GPL v2"); | ||
105 | MODULE_AUTHOR("Jiri Pirko <jpirko@redhat.com>"); | ||
106 | MODULE_DESCRIPTION("Round-robin mode for team"); | ||
107 | MODULE_ALIAS("team-mode-roundrobin"); | ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 7bea9c65119e..3dd13d606d00 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -123,7 +123,7 @@ struct tun_struct { | |||
123 | gid_t group; | 123 | gid_t group; |
124 | 124 | ||
125 | struct net_device *dev; | 125 | struct net_device *dev; |
126 | u32 set_features; | 126 | netdev_features_t set_features; |
127 | #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \ | 127 | #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \ |
128 | NETIF_F_TSO6|NETIF_F_UFO) | 128 | NETIF_F_TSO6|NETIF_F_UFO) |
129 | struct fasync_struct *fasync; | 129 | struct fasync_struct *fasync; |
@@ -454,7 +454,8 @@ tun_net_change_mtu(struct net_device *dev, int new_mtu) | |||
454 | return 0; | 454 | return 0; |
455 | } | 455 | } |
456 | 456 | ||
457 | static u32 tun_net_fix_features(struct net_device *dev, u32 features) | 457 | static netdev_features_t tun_net_fix_features(struct net_device *dev, |
458 | netdev_features_t features) | ||
458 | { | 459 | { |
459 | struct tun_struct *tun = netdev_priv(dev); | 460 | struct tun_struct *tun = netdev_priv(dev); |
460 | 461 | ||
@@ -1196,7 +1197,7 @@ static int tun_get_iff(struct net *net, struct tun_struct *tun, | |||
1196 | * privs required. */ | 1197 | * privs required. */ |
1197 | static int set_offload(struct tun_struct *tun, unsigned long arg) | 1198 | static int set_offload(struct tun_struct *tun, unsigned long arg) |
1198 | { | 1199 | { |
1199 | u32 features = 0; | 1200 | netdev_features_t features = 0; |
1200 | 1201 | ||
1201 | if (arg & TUN_F_CSUM) { | 1202 | if (arg & TUN_F_CSUM) { |
1202 | features |= NETIF_F_HW_CSUM; | 1203 | features |= NETIF_F_HW_CSUM; |
@@ -1589,16 +1590,16 @@ static void tun_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
1589 | { | 1590 | { |
1590 | struct tun_struct *tun = netdev_priv(dev); | 1591 | struct tun_struct *tun = netdev_priv(dev); |
1591 | 1592 | ||
1592 | strcpy(info->driver, DRV_NAME); | 1593 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
1593 | strcpy(info->version, DRV_VERSION); | 1594 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
1594 | strcpy(info->fw_version, "N/A"); | 1595 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
1595 | 1596 | ||
1596 | switch (tun->flags & TUN_TYPE_MASK) { | 1597 | switch (tun->flags & TUN_TYPE_MASK) { |
1597 | case TUN_TUN_DEV: | 1598 | case TUN_TUN_DEV: |
1598 | strcpy(info->bus_info, "tun"); | 1599 | strlcpy(info->bus_info, "tun", sizeof(info->bus_info)); |
1599 | break; | 1600 | break; |
1600 | case TUN_TAP_DEV: | 1601 | case TUN_TAP_DEV: |
1601 | strcpy(info->bus_info, "tap"); | 1602 | strlcpy(info->bus_info, "tap", sizeof(info->bus_info)); |
1602 | break; | 1603 | break; |
1603 | } | 1604 | } |
1604 | } | 1605 | } |
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index a5b9b12ef268..7d62c39f65cf 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c | |||
@@ -728,7 +728,8 @@ static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu) | |||
728 | } | 728 | } |
729 | 729 | ||
730 | /* Enable or disable Rx checksum offload engine */ | 730 | /* Enable or disable Rx checksum offload engine */ |
731 | static int smsc75xx_set_features(struct net_device *netdev, u32 features) | 731 | static int smsc75xx_set_features(struct net_device *netdev, |
732 | netdev_features_t features) | ||
732 | { | 733 | { |
733 | struct usbnet *dev = netdev_priv(netdev); | 734 | struct usbnet *dev = netdev_priv(netdev); |
734 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); | 735 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index eff67678c5a6..56f3894d701a 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
@@ -516,7 +516,8 @@ static void smsc95xx_status(struct usbnet *dev, struct urb *urb) | |||
516 | } | 516 | } |
517 | 517 | ||
518 | /* Enable or disable Tx & Rx checksum offload engines */ | 518 | /* Enable or disable Tx & Rx checksum offload engines */ |
519 | static int smsc95xx_set_features(struct net_device *netdev, u32 features) | 519 | static int smsc95xx_set_features(struct net_device *netdev, |
520 | netdev_features_t features) | ||
520 | { | 521 | { |
521 | struct usbnet *dev = netdev_priv(netdev); | 522 | struct usbnet *dev = netdev_priv(netdev); |
522 | u32 read_buf; | 523 | u32 read_buf; |
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index ef883e97cee0..b576812bdc59 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -27,8 +27,8 @@ | |||
27 | 27 | ||
28 | struct veth_net_stats { | 28 | struct veth_net_stats { |
29 | u64 rx_packets; | 29 | u64 rx_packets; |
30 | u64 tx_packets; | ||
31 | u64 rx_bytes; | 30 | u64 rx_bytes; |
31 | u64 tx_packets; | ||
32 | u64 tx_bytes; | 32 | u64 tx_bytes; |
33 | u64 rx_dropped; | 33 | u64 rx_dropped; |
34 | struct u64_stats_sync syncp; | 34 | struct u64_stats_sync syncp; |
@@ -66,9 +66,9 @@ static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
66 | 66 | ||
67 | static void veth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 67 | static void veth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
68 | { | 68 | { |
69 | strcpy(info->driver, DRV_NAME); | 69 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
70 | strcpy(info->version, DRV_VERSION); | 70 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
71 | strcpy(info->fw_version, "N/A"); | 71 | strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
72 | } | 72 | } |
73 | 73 | ||
74 | static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf) | 74 | static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf) |
@@ -271,7 +271,7 @@ static void veth_setup(struct net_device *dev) | |||
271 | dev->features |= NETIF_F_LLTX; | 271 | dev->features |= NETIF_F_LLTX; |
272 | dev->destructor = veth_dev_free; | 272 | dev->destructor = veth_dev_free; |
273 | 273 | ||
274 | dev->hw_features = NETIF_F_NO_CSUM | NETIF_F_SG | NETIF_F_RXCSUM; | 274 | dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_RXCSUM; |
275 | } | 275 | } |
276 | 276 | ||
277 | /* | 277 | /* |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 6ee8410443c4..4dc9d842a7a3 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -39,6 +39,7 @@ module_param(gso, bool, 0444); | |||
39 | #define GOOD_COPY_LEN 128 | 39 | #define GOOD_COPY_LEN 128 |
40 | 40 | ||
41 | #define VIRTNET_SEND_COMMAND_SG_MAX 2 | 41 | #define VIRTNET_SEND_COMMAND_SG_MAX 2 |
42 | #define VIRTNET_DRIVER_VERSION "1.0.0" | ||
42 | 43 | ||
43 | struct virtnet_stats { | 44 | struct virtnet_stats { |
44 | struct u64_stats_sync syncp; | 45 | struct u64_stats_sync syncp; |
@@ -889,7 +890,21 @@ static void virtnet_get_ringparam(struct net_device *dev, | |||
889 | 890 | ||
890 | } | 891 | } |
891 | 892 | ||
893 | |||
894 | static void virtnet_get_drvinfo(struct net_device *dev, | ||
895 | struct ethtool_drvinfo *info) | ||
896 | { | ||
897 | struct virtnet_info *vi = netdev_priv(dev); | ||
898 | struct virtio_device *vdev = vi->vdev; | ||
899 | |||
900 | strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); | ||
901 | strlcpy(info->version, VIRTNET_DRIVER_VERSION, sizeof(info->version)); | ||
902 | strlcpy(info->bus_info, virtio_bus_name(vdev), sizeof(info->bus_info)); | ||
903 | |||
904 | } | ||
905 | |||
892 | static const struct ethtool_ops virtnet_ethtool_ops = { | 906 | static const struct ethtool_ops virtnet_ethtool_ops = { |
907 | .get_drvinfo = virtnet_get_drvinfo, | ||
893 | .get_link = ethtool_op_get_link, | 908 | .get_link = ethtool_op_get_link, |
894 | .get_ringparam = virtnet_get_ringparam, | 909 | .get_ringparam = virtnet_get_ringparam, |
895 | }; | 910 | }; |
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index e662cbc8bfbd..77f723415c9c 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c | |||
@@ -262,11 +262,11 @@ vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) | |||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | int vmxnet3_set_features(struct net_device *netdev, u32 features) | 265 | int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features) |
266 | { | 266 | { |
267 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); | 267 | struct vmxnet3_adapter *adapter = netdev_priv(netdev); |
268 | unsigned long flags; | 268 | unsigned long flags; |
269 | u32 changed = features ^ netdev->features; | 269 | netdev_features_t changed = features ^ netdev->features; |
270 | 270 | ||
271 | if (changed & (NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_HW_VLAN_RX)) { | 271 | if (changed & (NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_HW_VLAN_RX)) { |
272 | if (features & NETIF_F_RXCSUM) | 272 | if (features & NETIF_F_RXCSUM) |
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index b18eac1dccaa..ed54797db191 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h | |||
@@ -401,7 +401,7 @@ void | |||
401 | vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter); | 401 | vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter); |
402 | 402 | ||
403 | int | 403 | int |
404 | vmxnet3_set_features(struct net_device *netdev, u32 features); | 404 | vmxnet3_set_features(struct net_device *netdev, netdev_features_t features); |
405 | 405 | ||
406 | int | 406 | int |
407 | vmxnet3_create_queues(struct vmxnet3_adapter *adapter, | 407 | vmxnet3_create_queues(struct vmxnet3_adapter *adapter, |
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile index 0a304b060b6c..c1c0678b1fb6 100644 --- a/drivers/net/wireless/Makefile +++ b/drivers/net/wireless/Makefile | |||
@@ -58,6 +58,6 @@ obj-$(CONFIG_WL12XX_PLATFORM_DATA) += wl12xx/ | |||
58 | obj-$(CONFIG_IWM) += iwmc3200wifi/ | 58 | obj-$(CONFIG_IWM) += iwmc3200wifi/ |
59 | 59 | ||
60 | obj-$(CONFIG_MWIFIEX) += mwifiex/ | 60 | obj-$(CONFIG_MWIFIEX) += mwifiex/ |
61 | obj-$(CONFIG_BRCMFMAC) += brcm80211/ | 61 | |
62 | obj-$(CONFIG_BRCMUMAC) += brcm80211/ | 62 | obj-$(CONFIG_BRCMFMAC) += brcm80211/ |
63 | obj-$(CONFIG_BRCMSMAC) += brcm80211/ | 63 | obj-$(CONFIG_BRCMSMAC) += brcm80211/ |
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 0f9ee46cfc97..4596c33a7a69 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h | |||
@@ -239,6 +239,7 @@ enum ATH_DEBUG { | |||
239 | ATH_DBG_BTCOEX = 0x00002000, | 239 | ATH_DBG_BTCOEX = 0x00002000, |
240 | ATH_DBG_WMI = 0x00004000, | 240 | ATH_DBG_WMI = 0x00004000, |
241 | ATH_DBG_BSTUCK = 0x00008000, | 241 | ATH_DBG_BSTUCK = 0x00008000, |
242 | ATH_DBG_MCI = 0x00010000, | ||
242 | ATH_DBG_ANY = 0xffffffff | 243 | ATH_DBG_ANY = 0xffffffff |
243 | }; | 244 | }; |
244 | 245 | ||
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index f517eb8f7b44..5ac2bc2ebee6 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c | |||
@@ -1734,7 +1734,8 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, | |||
1734 | struct ieee80211_channel *chan, bool offchan, | 1734 | struct ieee80211_channel *chan, bool offchan, |
1735 | enum nl80211_channel_type channel_type, | 1735 | enum nl80211_channel_type channel_type, |
1736 | bool channel_type_valid, unsigned int wait, | 1736 | bool channel_type_valid, unsigned int wait, |
1737 | const u8 *buf, size_t len, bool no_cck, u64 *cookie) | 1737 | const u8 *buf, size_t len, bool no_cck, |
1738 | bool dont_wait_for_ack, u64 *cookie) | ||
1738 | { | 1739 | { |
1739 | struct ath6kl *ar = ath6kl_priv(dev); | 1740 | struct ath6kl *ar = ath6kl_priv(dev); |
1740 | u32 id; | 1741 | u32 id; |
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index c1d2366704b5..81e0031012ca 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c | |||
@@ -1548,7 +1548,8 @@ static int ath6kl_init(struct net_device *dev) | |||
1548 | ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | | 1548 | ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | |
1549 | ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; | 1549 | ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; |
1550 | 1550 | ||
1551 | ar->wdev->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; | 1551 | ar->wdev->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | |
1552 | WIPHY_FLAG_HAVE_AP_SME; | ||
1552 | 1553 | ||
1553 | status = ath6kl_target_config_wlan_params(ar); | 1554 | status = ath6kl_target_config_wlan_params(ar); |
1554 | if (!status) | 1555 | if (!status) |
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig index d9c08c619a3a..7b4c074e12fa 100644 --- a/drivers/net/wireless/ath/ath9k/Kconfig +++ b/drivers/net/wireless/ath/ath9k/Kconfig | |||
@@ -25,6 +25,7 @@ config ATH9K | |||
25 | 25 | ||
26 | config ATH9K_PCI | 26 | config ATH9K_PCI |
27 | bool "Atheros ath9k PCI/PCIe bus support" | 27 | bool "Atheros ath9k PCI/PCIe bus support" |
28 | default y | ||
28 | depends on ATH9K && PCI | 29 | depends on ATH9K && PCI |
29 | ---help--- | 30 | ---help--- |
30 | This option enables the PCI bus support in ath9k. | 31 | This option enables the PCI bus support in ath9k. |
diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile index 36ed3c46fec6..49d3f25f509d 100644 --- a/drivers/net/wireless/ath/ath9k/Makefile +++ b/drivers/net/wireless/ath/ath9k/Makefile | |||
@@ -4,6 +4,7 @@ ath9k-y += beacon.o \ | |||
4 | main.o \ | 4 | main.o \ |
5 | recv.o \ | 5 | recv.o \ |
6 | xmit.o \ | 6 | xmit.o \ |
7 | mci.o \ | ||
7 | 8 | ||
8 | ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o | 9 | ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o |
9 | ath9k-$(CONFIG_ATH9K_PCI) += pci.o | 10 | ath9k-$(CONFIG_ATH9K_PCI) += pci.o |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index 3b262ba6b172..a93bd63ad23b 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | |||
@@ -121,10 +121,8 @@ static const struct ar9300_eeprom ar9300_default = { | |||
121 | * if the register is per chain | 121 | * if the register is per chain |
122 | */ | 122 | */ |
123 | .noiseFloorThreshCh = {-1, 0, 0}, | 123 | .noiseFloorThreshCh = {-1, 0, 0}, |
124 | .ob = {1, 1, 1},/* 3 chain */ | 124 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
125 | .db_stage2 = {1, 1, 1}, /* 3 chain */ | 125 | .quick_drop = 0, |
126 | .db_stage3 = {0, 0, 0}, | ||
127 | .db_stage4 = {0, 0, 0}, | ||
128 | .xpaBiasLvl = 0, | 126 | .xpaBiasLvl = 0, |
129 | .txFrameToDataStart = 0x0e, | 127 | .txFrameToDataStart = 0x0e, |
130 | .txFrameToPaOn = 0x0e, | 128 | .txFrameToPaOn = 0x0e, |
@@ -144,7 +142,7 @@ static const struct ar9300_eeprom ar9300_default = { | |||
144 | }, | 142 | }, |
145 | .base_ext1 = { | 143 | .base_ext1 = { |
146 | .ant_div_control = 0, | 144 | .ant_div_control = 0, |
147 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | 145 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
148 | }, | 146 | }, |
149 | .calFreqPier2G = { | 147 | .calFreqPier2G = { |
150 | FREQ2FBIN(2412, 1), | 148 | FREQ2FBIN(2412, 1), |
@@ -323,10 +321,8 @@ static const struct ar9300_eeprom ar9300_default = { | |||
323 | .spurChans = {0, 0, 0, 0, 0}, | 321 | .spurChans = {0, 0, 0, 0, 0}, |
324 | /* noiseFloorThreshCh Check if the register is per chain */ | 322 | /* noiseFloorThreshCh Check if the register is per chain */ |
325 | .noiseFloorThreshCh = {-1, 0, 0}, | 323 | .noiseFloorThreshCh = {-1, 0, 0}, |
326 | .ob = {3, 3, 3}, /* 3 chain */ | 324 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
327 | .db_stage2 = {3, 3, 3}, /* 3 chain */ | 325 | .quick_drop = 0, |
328 | .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ | ||
329 | .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ | ||
330 | .xpaBiasLvl = 0, | 326 | .xpaBiasLvl = 0, |
331 | .txFrameToDataStart = 0x0e, | 327 | .txFrameToDataStart = 0x0e, |
332 | .txFrameToPaOn = 0x0e, | 328 | .txFrameToPaOn = 0x0e, |
@@ -698,10 +694,8 @@ static const struct ar9300_eeprom ar9300_x113 = { | |||
698 | * if the register is per chain | 694 | * if the register is per chain |
699 | */ | 695 | */ |
700 | .noiseFloorThreshCh = {-1, 0, 0}, | 696 | .noiseFloorThreshCh = {-1, 0, 0}, |
701 | .ob = {1, 1, 1},/* 3 chain */ | 697 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
702 | .db_stage2 = {1, 1, 1}, /* 3 chain */ | 698 | .quick_drop = 0, |
703 | .db_stage3 = {0, 0, 0}, | ||
704 | .db_stage4 = {0, 0, 0}, | ||
705 | .xpaBiasLvl = 0, | 699 | .xpaBiasLvl = 0, |
706 | .txFrameToDataStart = 0x0e, | 700 | .txFrameToDataStart = 0x0e, |
707 | .txFrameToPaOn = 0x0e, | 701 | .txFrameToPaOn = 0x0e, |
@@ -721,7 +715,7 @@ static const struct ar9300_eeprom ar9300_x113 = { | |||
721 | }, | 715 | }, |
722 | .base_ext1 = { | 716 | .base_ext1 = { |
723 | .ant_div_control = 0, | 717 | .ant_div_control = 0, |
724 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | 718 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
725 | }, | 719 | }, |
726 | .calFreqPier2G = { | 720 | .calFreqPier2G = { |
727 | FREQ2FBIN(2412, 1), | 721 | FREQ2FBIN(2412, 1), |
@@ -900,10 +894,8 @@ static const struct ar9300_eeprom ar9300_x113 = { | |||
900 | .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0}, | 894 | .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0}, |
901 | /* noiseFloorThreshCh Check if the register is per chain */ | 895 | /* noiseFloorThreshCh Check if the register is per chain */ |
902 | .noiseFloorThreshCh = {-1, 0, 0}, | 896 | .noiseFloorThreshCh = {-1, 0, 0}, |
903 | .ob = {3, 3, 3}, /* 3 chain */ | 897 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
904 | .db_stage2 = {3, 3, 3}, /* 3 chain */ | 898 | .quick_drop = 0, |
905 | .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ | ||
906 | .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ | ||
907 | .xpaBiasLvl = 0xf, | 899 | .xpaBiasLvl = 0xf, |
908 | .txFrameToDataStart = 0x0e, | 900 | .txFrameToDataStart = 0x0e, |
909 | .txFrameToPaOn = 0x0e, | 901 | .txFrameToPaOn = 0x0e, |
@@ -1276,10 +1268,8 @@ static const struct ar9300_eeprom ar9300_h112 = { | |||
1276 | * if the register is per chain | 1268 | * if the register is per chain |
1277 | */ | 1269 | */ |
1278 | .noiseFloorThreshCh = {-1, 0, 0}, | 1270 | .noiseFloorThreshCh = {-1, 0, 0}, |
1279 | .ob = {1, 1, 1},/* 3 chain */ | 1271 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
1280 | .db_stage2 = {1, 1, 1}, /* 3 chain */ | 1272 | .quick_drop = 0, |
1281 | .db_stage3 = {0, 0, 0}, | ||
1282 | .db_stage4 = {0, 0, 0}, | ||
1283 | .xpaBiasLvl = 0, | 1273 | .xpaBiasLvl = 0, |
1284 | .txFrameToDataStart = 0x0e, | 1274 | .txFrameToDataStart = 0x0e, |
1285 | .txFrameToPaOn = 0x0e, | 1275 | .txFrameToPaOn = 0x0e, |
@@ -1291,20 +1281,20 @@ static const struct ar9300_eeprom ar9300_h112 = { | |||
1291 | .txEndToRxOn = 0x2, | 1281 | .txEndToRxOn = 0x2, |
1292 | .txFrameToXpaOn = 0xe, | 1282 | .txFrameToXpaOn = 0xe, |
1293 | .thresh62 = 28, | 1283 | .thresh62 = 28, |
1294 | .papdRateMaskHt20 = LE32(0x80c080), | 1284 | .papdRateMaskHt20 = LE32(0x0c80c080), |
1295 | .papdRateMaskHt40 = LE32(0x80c080), | 1285 | .papdRateMaskHt40 = LE32(0x0080c080), |
1296 | .futureModal = { | 1286 | .futureModal = { |
1297 | 0, 0, 0, 0, 0, 0, 0, 0, | 1287 | 0, 0, 0, 0, 0, 0, 0, 0, |
1298 | }, | 1288 | }, |
1299 | }, | 1289 | }, |
1300 | .base_ext1 = { | 1290 | .base_ext1 = { |
1301 | .ant_div_control = 0, | 1291 | .ant_div_control = 0, |
1302 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | 1292 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
1303 | }, | 1293 | }, |
1304 | .calFreqPier2G = { | 1294 | .calFreqPier2G = { |
1305 | FREQ2FBIN(2412, 1), | 1295 | FREQ2FBIN(2412, 1), |
1306 | FREQ2FBIN(2437, 1), | 1296 | FREQ2FBIN(2437, 1), |
1307 | FREQ2FBIN(2472, 1), | 1297 | FREQ2FBIN(2462, 1), |
1308 | }, | 1298 | }, |
1309 | /* ar9300_cal_data_per_freq_op_loop 2g */ | 1299 | /* ar9300_cal_data_per_freq_op_loop 2g */ |
1310 | .calPierData2G = { | 1300 | .calPierData2G = { |
@@ -1314,7 +1304,7 @@ static const struct ar9300_eeprom ar9300_h112 = { | |||
1314 | }, | 1304 | }, |
1315 | .calTarget_freqbin_Cck = { | 1305 | .calTarget_freqbin_Cck = { |
1316 | FREQ2FBIN(2412, 1), | 1306 | FREQ2FBIN(2412, 1), |
1317 | FREQ2FBIN(2484, 1), | 1307 | FREQ2FBIN(2472, 1), |
1318 | }, | 1308 | }, |
1319 | .calTarget_freqbin_2G = { | 1309 | .calTarget_freqbin_2G = { |
1320 | FREQ2FBIN(2412, 1), | 1310 | FREQ2FBIN(2412, 1), |
@@ -1478,10 +1468,8 @@ static const struct ar9300_eeprom ar9300_h112 = { | |||
1478 | .spurChans = {0, 0, 0, 0, 0}, | 1468 | .spurChans = {0, 0, 0, 0, 0}, |
1479 | /* noiseFloorThreshCh Check if the register is per chain */ | 1469 | /* noiseFloorThreshCh Check if the register is per chain */ |
1480 | .noiseFloorThreshCh = {-1, 0, 0}, | 1470 | .noiseFloorThreshCh = {-1, 0, 0}, |
1481 | .ob = {3, 3, 3}, /* 3 chain */ | 1471 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
1482 | .db_stage2 = {3, 3, 3}, /* 3 chain */ | 1472 | .quick_drop = 0, |
1483 | .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ | ||
1484 | .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ | ||
1485 | .xpaBiasLvl = 0, | 1473 | .xpaBiasLvl = 0, |
1486 | .txFrameToDataStart = 0x0e, | 1474 | .txFrameToDataStart = 0x0e, |
1487 | .txFrameToPaOn = 0x0e, | 1475 | .txFrameToPaOn = 0x0e, |
@@ -1515,7 +1503,7 @@ static const struct ar9300_eeprom ar9300_h112 = { | |||
1515 | FREQ2FBIN(5500, 0), | 1503 | FREQ2FBIN(5500, 0), |
1516 | FREQ2FBIN(5600, 0), | 1504 | FREQ2FBIN(5600, 0), |
1517 | FREQ2FBIN(5700, 0), | 1505 | FREQ2FBIN(5700, 0), |
1518 | FREQ2FBIN(5825, 0) | 1506 | FREQ2FBIN(5785, 0) |
1519 | }, | 1507 | }, |
1520 | .calPierData5G = { | 1508 | .calPierData5G = { |
1521 | { | 1509 | { |
@@ -1854,10 +1842,8 @@ static const struct ar9300_eeprom ar9300_x112 = { | |||
1854 | * if the register is per chain | 1842 | * if the register is per chain |
1855 | */ | 1843 | */ |
1856 | .noiseFloorThreshCh = {-1, 0, 0}, | 1844 | .noiseFloorThreshCh = {-1, 0, 0}, |
1857 | .ob = {1, 1, 1},/* 3 chain */ | 1845 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
1858 | .db_stage2 = {1, 1, 1}, /* 3 chain */ | 1846 | .quick_drop = 0, |
1859 | .db_stage3 = {0, 0, 0}, | ||
1860 | .db_stage4 = {0, 0, 0}, | ||
1861 | .xpaBiasLvl = 0, | 1847 | .xpaBiasLvl = 0, |
1862 | .txFrameToDataStart = 0x0e, | 1848 | .txFrameToDataStart = 0x0e, |
1863 | .txFrameToPaOn = 0x0e, | 1849 | .txFrameToPaOn = 0x0e, |
@@ -1877,7 +1863,7 @@ static const struct ar9300_eeprom ar9300_x112 = { | |||
1877 | }, | 1863 | }, |
1878 | .base_ext1 = { | 1864 | .base_ext1 = { |
1879 | .ant_div_control = 0, | 1865 | .ant_div_control = 0, |
1880 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | 1866 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
1881 | }, | 1867 | }, |
1882 | .calFreqPier2G = { | 1868 | .calFreqPier2G = { |
1883 | FREQ2FBIN(2412, 1), | 1869 | FREQ2FBIN(2412, 1), |
@@ -2056,10 +2042,8 @@ static const struct ar9300_eeprom ar9300_x112 = { | |||
2056 | .spurChans = {0, 0, 0, 0, 0}, | 2042 | .spurChans = {0, 0, 0, 0, 0}, |
2057 | /* noiseFloorThreshch check if the register is per chain */ | 2043 | /* noiseFloorThreshch check if the register is per chain */ |
2058 | .noiseFloorThreshCh = {-1, 0, 0}, | 2044 | .noiseFloorThreshCh = {-1, 0, 0}, |
2059 | .ob = {3, 3, 3}, /* 3 chain */ | 2045 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
2060 | .db_stage2 = {3, 3, 3}, /* 3 chain */ | 2046 | .quick_drop = 0, |
2061 | .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ | ||
2062 | .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ | ||
2063 | .xpaBiasLvl = 0, | 2047 | .xpaBiasLvl = 0, |
2064 | .txFrameToDataStart = 0x0e, | 2048 | .txFrameToDataStart = 0x0e, |
2065 | .txFrameToPaOn = 0x0e, | 2049 | .txFrameToPaOn = 0x0e, |
@@ -2431,10 +2415,8 @@ static const struct ar9300_eeprom ar9300_h116 = { | |||
2431 | * if the register is per chain | 2415 | * if the register is per chain |
2432 | */ | 2416 | */ |
2433 | .noiseFloorThreshCh = {-1, 0, 0}, | 2417 | .noiseFloorThreshCh = {-1, 0, 0}, |
2434 | .ob = {1, 1, 1},/* 3 chain */ | 2418 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
2435 | .db_stage2 = {1, 1, 1}, /* 3 chain */ | 2419 | .quick_drop = 0, |
2436 | .db_stage3 = {0, 0, 0}, | ||
2437 | .db_stage4 = {0, 0, 0}, | ||
2438 | .xpaBiasLvl = 0, | 2420 | .xpaBiasLvl = 0, |
2439 | .txFrameToDataStart = 0x0e, | 2421 | .txFrameToDataStart = 0x0e, |
2440 | .txFrameToPaOn = 0x0e, | 2422 | .txFrameToPaOn = 0x0e, |
@@ -2454,12 +2436,12 @@ static const struct ar9300_eeprom ar9300_h116 = { | |||
2454 | }, | 2436 | }, |
2455 | .base_ext1 = { | 2437 | .base_ext1 = { |
2456 | .ant_div_control = 0, | 2438 | .ant_div_control = 0, |
2457 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | 2439 | .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
2458 | }, | 2440 | }, |
2459 | .calFreqPier2G = { | 2441 | .calFreqPier2G = { |
2460 | FREQ2FBIN(2412, 1), | 2442 | FREQ2FBIN(2412, 1), |
2461 | FREQ2FBIN(2437, 1), | 2443 | FREQ2FBIN(2437, 1), |
2462 | FREQ2FBIN(2472, 1), | 2444 | FREQ2FBIN(2462, 1), |
2463 | }, | 2445 | }, |
2464 | /* ar9300_cal_data_per_freq_op_loop 2g */ | 2446 | /* ar9300_cal_data_per_freq_op_loop 2g */ |
2465 | .calPierData2G = { | 2447 | .calPierData2G = { |
@@ -2633,10 +2615,8 @@ static const struct ar9300_eeprom ar9300_h116 = { | |||
2633 | .spurChans = {0, 0, 0, 0, 0}, | 2615 | .spurChans = {0, 0, 0, 0, 0}, |
2634 | /* noiseFloorThreshCh Check if the register is per chain */ | 2616 | /* noiseFloorThreshCh Check if the register is per chain */ |
2635 | .noiseFloorThreshCh = {-1, 0, 0}, | 2617 | .noiseFloorThreshCh = {-1, 0, 0}, |
2636 | .ob = {3, 3, 3}, /* 3 chain */ | 2618 | .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
2637 | .db_stage2 = {3, 3, 3}, /* 3 chain */ | 2619 | .quick_drop = 0, |
2638 | .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ | ||
2639 | .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ | ||
2640 | .xpaBiasLvl = 0, | 2620 | .xpaBiasLvl = 0, |
2641 | .txFrameToDataStart = 0x0e, | 2621 | .txFrameToDataStart = 0x0e, |
2642 | .txFrameToPaOn = 0x0e, | 2622 | .txFrameToPaOn = 0x0e, |
@@ -2663,7 +2643,7 @@ static const struct ar9300_eeprom ar9300_h116 = { | |||
2663 | .xatten1MarginHigh = {0, 0, 0} | 2643 | .xatten1MarginHigh = {0, 0, 0} |
2664 | }, | 2644 | }, |
2665 | .calFreqPier5G = { | 2645 | .calFreqPier5G = { |
2666 | FREQ2FBIN(5180, 0), | 2646 | FREQ2FBIN(5160, 0), |
2667 | FREQ2FBIN(5220, 0), | 2647 | FREQ2FBIN(5220, 0), |
2668 | FREQ2FBIN(5320, 0), | 2648 | FREQ2FBIN(5320, 0), |
2669 | FREQ2FBIN(5400, 0), | 2649 | FREQ2FBIN(5400, 0), |
@@ -3023,6 +3003,8 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah, | |||
3023 | return eep->modalHeader5G.antennaGain; | 3003 | return eep->modalHeader5G.antennaGain; |
3024 | case EEP_ANTENNA_GAIN_2G: | 3004 | case EEP_ANTENNA_GAIN_2G: |
3025 | return eep->modalHeader2G.antennaGain; | 3005 | return eep->modalHeader2G.antennaGain; |
3006 | case EEP_QUICK_DROP: | ||
3007 | return pBase->miscConfiguration & BIT(1); | ||
3026 | default: | 3008 | default: |
3027 | return 0; | 3009 | return 0; |
3028 | } | 3010 | } |
@@ -3428,25 +3410,14 @@ static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size, | |||
3428 | PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]); | 3410 | PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]); |
3429 | PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]); | 3411 | PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]); |
3430 | PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]); | 3412 | PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]); |
3413 | PR_EEP("Quick Drop", modal_hdr->quick_drop); | ||
3414 | PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff); | ||
3431 | PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl); | 3415 | PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl); |
3432 | PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart); | 3416 | PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart); |
3433 | PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn); | 3417 | PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn); |
3434 | PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn); | 3418 | PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn); |
3435 | PR_EEP("txClip", modal_hdr->txClip); | 3419 | PR_EEP("txClip", modal_hdr->txClip); |
3436 | PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize); | 3420 | PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize); |
3437 | PR_EEP("Chain0 ob", modal_hdr->ob[0]); | ||
3438 | PR_EEP("Chain1 ob", modal_hdr->ob[1]); | ||
3439 | PR_EEP("Chain2 ob", modal_hdr->ob[2]); | ||
3440 | |||
3441 | PR_EEP("Chain0 db_stage2", modal_hdr->db_stage2[0]); | ||
3442 | PR_EEP("Chain1 db_stage2", modal_hdr->db_stage2[1]); | ||
3443 | PR_EEP("Chain2 db_stage2", modal_hdr->db_stage2[2]); | ||
3444 | PR_EEP("Chain0 db_stage3", modal_hdr->db_stage3[0]); | ||
3445 | PR_EEP("Chain1 db_stage3", modal_hdr->db_stage3[1]); | ||
3446 | PR_EEP("Chain2 db_stage3", modal_hdr->db_stage3[2]); | ||
3447 | PR_EEP("Chain0 db_stage4", modal_hdr->db_stage4[0]); | ||
3448 | PR_EEP("Chain1 db_stage4", modal_hdr->db_stage4[1]); | ||
3449 | PR_EEP("Chain2 db_stage4", modal_hdr->db_stage4[2]); | ||
3450 | 3421 | ||
3451 | return len; | 3422 | return len; |
3452 | } | 3423 | } |
@@ -3503,6 +3474,7 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr, | |||
3503 | PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4))); | 3474 | PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4))); |
3504 | PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5))); | 3475 | PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5))); |
3505 | PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0))); | 3476 | PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0))); |
3477 | PR_EEP("Quick Drop", !!(pBase->miscConfiguration & BIT(1))); | ||
3506 | PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1); | 3478 | PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1); |
3507 | PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio); | 3479 | PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio); |
3508 | PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio); | 3480 | PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio); |
@@ -3965,6 +3937,40 @@ static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah) | |||
3965 | } | 3937 | } |
3966 | } | 3938 | } |
3967 | 3939 | ||
3940 | static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq) | ||
3941 | { | ||
3942 | struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; | ||
3943 | int quick_drop = ath9k_hw_ar9300_get_eeprom(ah, EEP_QUICK_DROP); | ||
3944 | s32 t[3], f[3] = {5180, 5500, 5785}; | ||
3945 | |||
3946 | if (!quick_drop) | ||
3947 | return; | ||
3948 | |||
3949 | if (freq < 4000) | ||
3950 | quick_drop = eep->modalHeader2G.quick_drop; | ||
3951 | else { | ||
3952 | t[0] = eep->base_ext1.quick_drop_low; | ||
3953 | t[1] = eep->modalHeader5G.quick_drop; | ||
3954 | t[2] = eep->base_ext1.quick_drop_high; | ||
3955 | quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3); | ||
3956 | } | ||
3957 | REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop); | ||
3958 | } | ||
3959 | |||
3960 | static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, u16 freq) | ||
3961 | { | ||
3962 | struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; | ||
3963 | u32 value; | ||
3964 | |||
3965 | value = (freq < 4000) ? eep->modalHeader2G.txEndToXpaOff : | ||
3966 | eep->modalHeader5G.txEndToXpaOff; | ||
3967 | |||
3968 | REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, | ||
3969 | AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value); | ||
3970 | REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, | ||
3971 | AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value); | ||
3972 | } | ||
3973 | |||
3968 | static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, | 3974 | static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, |
3969 | struct ath9k_channel *chan) | 3975 | struct ath9k_channel *chan) |
3970 | { | 3976 | { |
@@ -3972,10 +3978,12 @@ static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, | |||
3972 | ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan)); | 3978 | ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan)); |
3973 | ar9003_hw_drive_strength_apply(ah); | 3979 | ar9003_hw_drive_strength_apply(ah); |
3974 | ar9003_hw_atten_apply(ah, chan); | 3980 | ar9003_hw_atten_apply(ah, chan); |
3981 | ar9003_hw_quick_drop_apply(ah, chan->channel); | ||
3975 | if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah)) | 3982 | if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah)) |
3976 | ar9003_hw_internal_regulator_apply(ah); | 3983 | ar9003_hw_internal_regulator_apply(ah); |
3977 | if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) | 3984 | if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) |
3978 | ar9003_hw_apply_tuning_caps(ah); | 3985 | ar9003_hw_apply_tuning_caps(ah); |
3986 | ar9003_hw_txend_to_xpa_off_apply(ah, chan->channel); | ||
3979 | } | 3987 | } |
3980 | 3988 | ||
3981 | static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah, | 3989 | static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah, |
@@ -5051,6 +5059,8 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, | |||
5051 | regulatory->max_power_level = targetPowerValT2[i]; | 5059 | regulatory->max_power_level = targetPowerValT2[i]; |
5052 | } | 5060 | } |
5053 | 5061 | ||
5062 | ath9k_hw_update_regulatory_maxpower(ah); | ||
5063 | |||
5054 | if (test) | 5064 | if (test) |
5055 | return; | 5065 | return; |
5056 | 5066 | ||
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h index 6335a867527e..bb223fe82816 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h | |||
@@ -216,10 +216,8 @@ struct ar9300_modal_eep_header { | |||
216 | u8 spurChans[AR_EEPROM_MODAL_SPURS]; | 216 | u8 spurChans[AR_EEPROM_MODAL_SPURS]; |
217 | /* 3 Check if the register is per chain */ | 217 | /* 3 Check if the register is per chain */ |
218 | int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS]; | 218 | int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS]; |
219 | u8 ob[AR9300_MAX_CHAINS]; | 219 | u8 reserved[11]; |
220 | u8 db_stage2[AR9300_MAX_CHAINS]; | 220 | int8_t quick_drop; |
221 | u8 db_stage3[AR9300_MAX_CHAINS]; | ||
222 | u8 db_stage4[AR9300_MAX_CHAINS]; | ||
223 | u8 xpaBiasLvl; | 221 | u8 xpaBiasLvl; |
224 | u8 txFrameToDataStart; | 222 | u8 txFrameToDataStart; |
225 | u8 txFrameToPaOn; | 223 | u8 txFrameToPaOn; |
@@ -269,7 +267,9 @@ struct cal_ctl_data_5g { | |||
269 | 267 | ||
270 | struct ar9300_BaseExtension_1 { | 268 | struct ar9300_BaseExtension_1 { |
271 | u8 ant_div_control; | 269 | u8 ant_div_control; |
272 | u8 future[13]; | 270 | u8 future[11]; |
271 | int8_t quick_drop_low; | ||
272 | int8_t quick_drop_high; | ||
273 | } __packed; | 273 | } __packed; |
274 | 274 | ||
275 | struct ar9300_BaseExtension_2 { | 275 | struct ar9300_BaseExtension_2 { |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c index 2330e7ede199..e41d26939ab8 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c | |||
@@ -199,12 +199,14 @@ static void ar9003_hw_spur_mitigate_mrc_cck(struct ath_hw *ah, | |||
199 | synth_freq = chan->channel; | 199 | synth_freq = chan->channel; |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | range = 10; | 202 | range = AR_SREV_9462(ah) ? 5 : 10; |
203 | max_spur_cnts = 4; | 203 | max_spur_cnts = 4; |
204 | synth_freq = chan->channel; | 204 | synth_freq = chan->channel; |
205 | } | 205 | } |
206 | 206 | ||
207 | for (i = 0; i < max_spur_cnts; i++) { | 207 | for (i = 0; i < max_spur_cnts; i++) { |
208 | if (AR_SREV_9462(ah) && (i == 0 || i == 3)) | ||
209 | continue; | ||
208 | negative = 0; | 210 | negative = 0; |
209 | if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah)) | 211 | if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah)) |
210 | cur_bb_spur = FBIN2FREQ(spur_fbin_ptr[i], | 212 | cur_bb_spur = FBIN2FREQ(spur_fbin_ptr[i], |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h index 4114fe752c6b..497d7461838a 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h | |||
@@ -389,6 +389,8 @@ | |||
389 | #define AR_PHY_DAG_CTRLCCK_RSSI_THR_S 10 | 389 | #define AR_PHY_DAG_CTRLCCK_RSSI_THR_S 10 |
390 | 390 | ||
391 | #define AR_PHY_RIFS_INIT_DELAY 0x3ff0000 | 391 | #define AR_PHY_RIFS_INIT_DELAY 0x3ff0000 |
392 | #define AR_PHY_AGC_QUICK_DROP 0x03c00000 | ||
393 | #define AR_PHY_AGC_QUICK_DROP_S 22 | ||
392 | #define AR_PHY_AGC_COARSE_LOW 0x00007F80 | 394 | #define AR_PHY_AGC_COARSE_LOW 0x00007F80 |
393 | #define AR_PHY_AGC_COARSE_LOW_S 7 | 395 | #define AR_PHY_AGC_COARSE_LOW_S 7 |
394 | #define AR_PHY_AGC_COARSE_HIGH 0x003F8000 | 396 | #define AR_PHY_AGC_COARSE_HIGH 0x003F8000 |
diff --git a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h index 9c51b395b4ff..259a6f312afb 100644 --- a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h | |||
@@ -43,16 +43,16 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = { | |||
43 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ | 43 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ |
44 | {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011}, | 44 | {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011}, |
45 | {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, | 45 | {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, |
46 | {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, | 46 | {0x00009824, 0x5ac640de, 0x5ac640d0, 0x5ac640d0, 0x5ac640de}, |
47 | {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, | 47 | {0x00009828, 0x0796be89, 0x0696b081, 0x0696b881, 0x0796be89}, |
48 | {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, | 48 | {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, |
49 | {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c}, | 49 | {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c}, |
50 | {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4}, | 50 | {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4}, |
51 | {0x00009e00, 0x0372111a, 0x0372111a, 0x037216a0, 0x037216a0}, | 51 | {0x00009e00, 0x0372111a, 0x0372111a, 0x037216a0, 0x037216a0}, |
52 | {0x00009e04, 0x001c2020, 0x001c2020, 0x001c2020, 0x001c2020}, | 52 | {0x00009e04, 0x001c2020, 0x001c2020, 0x001c2020, 0x001c2020}, |
53 | {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, | 53 | {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, |
54 | {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e}, | 54 | {0x00009e10, 0x92c88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x92c84d2e}, |
55 | {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3039605e, 0x33795d5e}, | 55 | {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e}, |
56 | {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | 56 | {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, |
57 | {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, | 57 | {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, |
58 | {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, | 58 | {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, |
@@ -688,8 +688,8 @@ static const u32 ar9462_2p0_mac_postamble_emulation[][5] = { | |||
688 | static const u32 ar9462_2p0_radio_postamble_sys3ant[][5] = { | 688 | static const u32 ar9462_2p0_radio_postamble_sys3ant[][5] = { |
689 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ | 689 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ |
690 | {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, | 690 | {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, |
691 | {0x00016140, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, | 691 | {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, |
692 | {0x00016540, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, | 692 | {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, |
693 | }; | 693 | }; |
694 | 694 | ||
695 | static const u32 ar9462_2p0_baseband_postamble_emulation[][5] = { | 695 | static const u32 ar9462_2p0_baseband_postamble_emulation[][5] = { |
@@ -717,8 +717,8 @@ static const u32 ar9462_2p0_baseband_postamble_emulation[][5] = { | |||
717 | static const u32 ar9462_2p0_radio_postamble_sys2ant[][5] = { | 717 | static const u32 ar9462_2p0_radio_postamble_sys2ant[][5] = { |
718 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ | 718 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ |
719 | {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, | 719 | {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, |
720 | {0x00016140, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, | 720 | {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, |
721 | {0x00016540, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, | 721 | {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, |
722 | }; | 722 | }; |
723 | 723 | ||
724 | static const u32 ar9462_common_wo_xlna_rx_gain_table_2p0[][2] = { | 724 | static const u32 ar9462_common_wo_xlna_rx_gain_table_2p0[][2] = { |
@@ -1059,7 +1059,7 @@ static const u32 ar9462_modes_low_ob_db_tx_gain_table_2p0[][5] = { | |||
1059 | 1059 | ||
1060 | static const u32 ar9462_2p0_soc_postamble[][5] = { | 1060 | static const u32 ar9462_2p0_soc_postamble[][5] = { |
1061 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ | 1061 | /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ |
1062 | {0x00007010, 0x00002233, 0x00002233, 0x00002233, 0x00002233}, | 1062 | {0x00007010, 0x00000033, 0x00000033, 0x00000033, 0x00000033}, |
1063 | }; | 1063 | }; |
1064 | 1064 | ||
1065 | static const u32 ar9462_2p0_baseband_core[][2] = { | 1065 | static const u32 ar9462_2p0_baseband_core[][2] = { |
@@ -1257,8 +1257,8 @@ static const u32 ar9462_modes_high_ob_db_tx_gain_table_2p0[][5] = { | |||
1257 | {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, | 1257 | {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, |
1258 | {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, | 1258 | {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, |
1259 | {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, | 1259 | {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, |
1260 | {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83}, | 1260 | {0x0000a54c, 0x59025eb6, 0x59025eb6, 0x42001a83, 0x42001a83}, |
1261 | {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84}, | 1261 | {0x0000a550, 0x5d025ef6, 0x5d025ef6, 0x44001c84, 0x44001c84}, |
1262 | {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, | 1262 | {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, |
1263 | {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, | 1263 | {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, |
1264 | {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, | 1264 | {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, |
@@ -1850,8 +1850,8 @@ static const u32 ar9462_modes_green_ob_db_tx_gain_table_2p0[][5] = { | |||
1850 | {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, | 1850 | {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, |
1851 | {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, | 1851 | {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, |
1852 | {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, | 1852 | {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, |
1853 | {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83}, | 1853 | {0x0000a54c, 0x59025eb6, 0x59025eb6, 0x42001a83, 0x42001a83}, |
1854 | {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84}, | 1854 | {0x0000a550, 0x5d025ef6, 0x5d025ef6, 0x44001c84, 0x44001c84}, |
1855 | {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, | 1855 | {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, |
1856 | {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, | 1856 | {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, |
1857 | {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, | 1857 | {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, |
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 1c269f50822b..93b45b4b3033 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include "debug.h" | 26 | #include "debug.h" |
27 | #include "common.h" | 27 | #include "common.h" |
28 | #include "mci.h" | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * Header for the ath9k.ko driver core *only* -- hw code nor any other driver | 31 | * Header for the ath9k.ko driver core *only* -- hw code nor any other driver |
@@ -252,6 +253,7 @@ struct ath_node { | |||
252 | #ifdef CONFIG_ATH9K_DEBUGFS | 253 | #ifdef CONFIG_ATH9K_DEBUGFS |
253 | struct list_head list; /* for sc->nodes */ | 254 | struct list_head list; /* for sc->nodes */ |
254 | struct ieee80211_sta *sta; /* station struct we're part of */ | 255 | struct ieee80211_sta *sta; /* station struct we're part of */ |
256 | struct ieee80211_vif *vif; /* interface with which we're associated */ | ||
255 | #endif | 257 | #endif |
256 | struct ath_atx_tid tid[WME_NUM_TID]; | 258 | struct ath_atx_tid tid[WME_NUM_TID]; |
257 | struct ath_atx_ac ac[WME_NUM_AC]; | 259 | struct ath_atx_ac ac[WME_NUM_AC]; |
@@ -443,7 +445,9 @@ struct ath_btcoex { | |||
443 | u32 btcoex_no_stomp; /* in usec */ | 445 | u32 btcoex_no_stomp; /* in usec */ |
444 | u32 btcoex_period; /* in usec */ | 446 | u32 btcoex_period; /* in usec */ |
445 | u32 btscan_no_stomp; /* in usec */ | 447 | u32 btscan_no_stomp; /* in usec */ |
448 | u32 duty_cycle; | ||
446 | struct ath_gen_timer *no_stomp_timer; /* Timer for no BT stomping */ | 449 | struct ath_gen_timer *no_stomp_timer; /* Timer for no BT stomping */ |
450 | struct ath_mci_profile mci; | ||
447 | }; | 451 | }; |
448 | 452 | ||
449 | int ath_init_btcoex_timer(struct ath_softc *sc); | 453 | int ath_init_btcoex_timer(struct ath_softc *sc); |
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 2741203e803f..6fb719d85b37 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -709,24 +709,29 @@ static ssize_t read_file_stations(struct file *file, char __user *user_buf, | |||
709 | 709 | ||
710 | len += snprintf(buf + len, size - len, | 710 | len += snprintf(buf + len, size - len, |
711 | "Stations:\n" | 711 | "Stations:\n" |
712 | " tid: addr sched paused buf_q-empty an ac\n" | 712 | " tid: addr sched paused buf_q-empty an ac baw\n" |
713 | " ac: addr sched tid_q-empty txq\n"); | 713 | " ac: addr sched tid_q-empty txq\n"); |
714 | 714 | ||
715 | spin_lock(&sc->nodes_lock); | 715 | spin_lock(&sc->nodes_lock); |
716 | list_for_each_entry(an, &sc->nodes, list) { | 716 | list_for_each_entry(an, &sc->nodes, list) { |
717 | unsigned short ma = an->maxampdu; | ||
718 | if (ma == 0) | ||
719 | ma = 65535; /* see ath_lookup_rate */ | ||
717 | len += snprintf(buf + len, size - len, | 720 | len += snprintf(buf + len, size - len, |
718 | "%pM\n", an->sta->addr); | 721 | "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n", |
722 | an->vif->addr, an->sta->addr, ma, | ||
723 | (unsigned int)(an->mpdudensity)); | ||
719 | if (len >= size) | 724 | if (len >= size) |
720 | goto done; | 725 | goto done; |
721 | 726 | ||
722 | for (q = 0; q < WME_NUM_TID; q++) { | 727 | for (q = 0; q < WME_NUM_TID; q++) { |
723 | struct ath_atx_tid *tid = &(an->tid[q]); | 728 | struct ath_atx_tid *tid = &(an->tid[q]); |
724 | len += snprintf(buf + len, size - len, | 729 | len += snprintf(buf + len, size - len, |
725 | " tid: %p %s %s %i %p %p\n", | 730 | " tid: %p %s %s %i %p %p %hu\n", |
726 | tid, tid->sched ? "sched" : "idle", | 731 | tid, tid->sched ? "sched" : "idle", |
727 | tid->paused ? "paused" : "running", | 732 | tid->paused ? "paused" : "running", |
728 | skb_queue_empty(&tid->buf_q), | 733 | skb_queue_empty(&tid->buf_q), |
729 | tid->an, tid->ac); | 734 | tid->an, tid->ac, tid->baw_size); |
730 | if (len >= size) | 735 | if (len >= size) |
731 | goto done; | 736 | goto done; |
732 | } | 737 | } |
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h index 49abd34be741..5ff7ab965120 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom.h +++ b/drivers/net/wireless/ath/ath9k/eeprom.h | |||
@@ -249,7 +249,8 @@ enum eeprom_param { | |||
249 | EEP_ANT_DIV_CTL1, | 249 | EEP_ANT_DIV_CTL1, |
250 | EEP_CHAIN_MASK_REDUCE, | 250 | EEP_CHAIN_MASK_REDUCE, |
251 | EEP_ANTENNA_GAIN_2G, | 251 | EEP_ANTENNA_GAIN_2G, |
252 | EEP_ANTENNA_GAIN_5G | 252 | EEP_ANTENNA_GAIN_5G, |
253 | EEP_QUICK_DROP | ||
253 | }; | 254 | }; |
254 | 255 | ||
255 | enum ar5416_rates { | 256 | enum ar5416_rates { |
diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 655576c8fdab..2c279dcaf4ba 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c | |||
@@ -189,8 +189,8 @@ static void ath_btcoex_period_timer(unsigned long data) | |||
189 | bool is_btscan; | 189 | bool is_btscan; |
190 | 190 | ||
191 | ath9k_ps_wakeup(sc); | 191 | ath9k_ps_wakeup(sc); |
192 | ath_detect_bt_priority(sc); | 192 | if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) |
193 | 193 | ath_detect_bt_priority(sc); | |
194 | is_btscan = sc->sc_flags & SC_OP_BT_SCAN; | 194 | is_btscan = sc->sc_flags & SC_OP_BT_SCAN; |
195 | 195 | ||
196 | spin_lock_bh(&btcoex->btcoex_lock); | 196 | spin_lock_bh(&btcoex->btcoex_lock); |
@@ -212,8 +212,9 @@ static void ath_btcoex_period_timer(unsigned long data) | |||
212 | } | 212 | } |
213 | 213 | ||
214 | ath9k_ps_restore(sc); | 214 | ath9k_ps_restore(sc); |
215 | timer_period = btcoex->btcoex_period / 1000; | ||
215 | mod_timer(&btcoex->period_timer, jiffies + | 216 | mod_timer(&btcoex->period_timer, jiffies + |
216 | msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD)); | 217 | msecs_to_jiffies(timer_period)); |
217 | } | 218 | } |
218 | 219 | ||
219 | /* | 220 | /* |
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 2f91acccb7db..662ab7e9a0f0 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -2335,7 +2335,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
2335 | ah->enabled_cals |= TX_IQ_ON_AGC_CAL; | 2335 | ah->enabled_cals |= TX_IQ_ON_AGC_CAL; |
2336 | } | 2336 | } |
2337 | if (AR_SREV_9462(ah)) | 2337 | if (AR_SREV_9462(ah)) |
2338 | pCap->hw_caps |= ATH9K_HW_CAP_RTT; | 2338 | pCap->hw_caps |= ATH9K_HW_CAP_RTT | ATH9K_HW_CAP_MCI; |
2339 | 2339 | ||
2340 | return 0; | 2340 | return 0; |
2341 | } | 2341 | } |
@@ -2583,7 +2583,7 @@ void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test) | |||
2583 | struct ath9k_channel *chan = ah->curchan; | 2583 | struct ath9k_channel *chan = ah->curchan; |
2584 | struct ieee80211_channel *channel = chan->chan; | 2584 | struct ieee80211_channel *channel = chan->chan; |
2585 | 2585 | ||
2586 | reg->power_limit = min_t(int, limit, MAX_RATE_POWER); | 2586 | reg->power_limit = min_t(u32, limit, MAX_RATE_POWER); |
2587 | if (test) | 2587 | if (test) |
2588 | channel->max_power = MAX_RATE_POWER / 2; | 2588 | channel->max_power = MAX_RATE_POWER / 2; |
2589 | 2589 | ||
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index f389b3c93cf3..33e8f2f9d425 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h | |||
@@ -203,6 +203,7 @@ enum ath9k_hw_caps { | |||
203 | ATH9K_HW_CAP_5GHZ = BIT(14), | 203 | ATH9K_HW_CAP_5GHZ = BIT(14), |
204 | ATH9K_HW_CAP_APM = BIT(15), | 204 | ATH9K_HW_CAP_APM = BIT(15), |
205 | ATH9K_HW_CAP_RTT = BIT(16), | 205 | ATH9K_HW_CAP_RTT = BIT(16), |
206 | ATH9K_HW_CAP_MCI = BIT(17), | ||
206 | }; | 207 | }; |
207 | 208 | ||
208 | struct ath9k_hw_capabilities { | 209 | struct ath9k_hw_capabilities { |
@@ -419,6 +420,16 @@ enum ath9k_rx_qtype { | |||
419 | ATH9K_RX_QUEUE_MAX, | 420 | ATH9K_RX_QUEUE_MAX, |
420 | }; | 421 | }; |
421 | 422 | ||
423 | enum ath_mci_gpm_coex_profile_type { | ||
424 | MCI_GPM_COEX_PROFILE_UNKNOWN, | ||
425 | MCI_GPM_COEX_PROFILE_RFCOMM, | ||
426 | MCI_GPM_COEX_PROFILE_A2DP, | ||
427 | MCI_GPM_COEX_PROFILE_HID, | ||
428 | MCI_GPM_COEX_PROFILE_BNEP, | ||
429 | MCI_GPM_COEX_PROFILE_VOICE, | ||
430 | MCI_GPM_COEX_PROFILE_MAX | ||
431 | }; | ||
432 | |||
422 | struct ath9k_beacon_state { | 433 | struct ath9k_beacon_state { |
423 | u32 bs_nexttbtt; | 434 | u32 bs_nexttbtt; |
424 | u32 bs_nextdtim; | 435 | u32 bs_nextdtim; |
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index d4c909f8e474..e046de94836a 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c | |||
@@ -424,6 +424,8 @@ static int ath9k_init_btcoex(struct ath_softc *sc) | |||
424 | txq = sc->tx.txq_map[WME_AC_BE]; | 424 | txq = sc->tx.txq_map[WME_AC_BE]; |
425 | ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum); | 425 | ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum); |
426 | sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; | 426 | sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; |
427 | sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; | ||
428 | INIT_LIST_HEAD(&sc->btcoex.mci.info); | ||
427 | break; | 429 | break; |
428 | default: | 430 | default: |
429 | WARN_ON(1); | 431 | WARN_ON(1); |
@@ -695,6 +697,7 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
695 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; | 697 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
696 | 698 | ||
697 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; | 699 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
700 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; | ||
698 | 701 | ||
699 | hw->queues = 4; | 702 | hw->queues = 4; |
700 | hw->max_rates = 4; | 703 | hw->max_rates = 4; |
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 93fbe6f40898..e43c41cff25b 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -630,7 +630,8 @@ set_timer: | |||
630 | } | 630 | } |
631 | } | 631 | } |
632 | 632 | ||
633 | static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta) | 633 | static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, |
634 | struct ieee80211_vif *vif) | ||
634 | { | 635 | { |
635 | struct ath_node *an; | 636 | struct ath_node *an; |
636 | an = (struct ath_node *)sta->drv_priv; | 637 | an = (struct ath_node *)sta->drv_priv; |
@@ -640,6 +641,7 @@ static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta) | |||
640 | list_add(&an->list, &sc->nodes); | 641 | list_add(&an->list, &sc->nodes); |
641 | spin_unlock(&sc->nodes_lock); | 642 | spin_unlock(&sc->nodes_lock); |
642 | an->sta = sta; | 643 | an->sta = sta; |
644 | an->vif = vif; | ||
643 | #endif | 645 | #endif |
644 | if (sc->sc_flags & SC_OP_TXAGGR) { | 646 | if (sc->sc_flags & SC_OP_TXAGGR) { |
645 | ath_tx_node_init(sc, an); | 647 | ath_tx_node_init(sc, an); |
@@ -1133,8 +1135,9 @@ static int ath9k_start(struct ieee80211_hw *hw) | |||
1133 | 1135 | ||
1134 | if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) && | 1136 | if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) && |
1135 | !ah->btcoex_hw.enabled) { | 1137 | !ah->btcoex_hw.enabled) { |
1136 | ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, | 1138 | if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) |
1137 | AR_STOMP_LOW_WLAN_WGHT); | 1139 | ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, |
1140 | AR_STOMP_LOW_WLAN_WGHT); | ||
1138 | ath9k_hw_btcoex_enable(ah); | 1141 | ath9k_hw_btcoex_enable(ah); |
1139 | 1142 | ||
1140 | if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) | 1143 | if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) |
@@ -1237,6 +1240,7 @@ static void ath9k_stop(struct ieee80211_hw *hw) | |||
1237 | ath9k_hw_btcoex_disable(ah); | 1240 | ath9k_hw_btcoex_disable(ah); |
1238 | if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) | 1241 | if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) |
1239 | ath9k_btcoex_timer_pause(sc); | 1242 | ath9k_btcoex_timer_pause(sc); |
1243 | ath_mci_flush_profile(&sc->btcoex.mci); | ||
1240 | } | 1244 | } |
1241 | 1245 | ||
1242 | spin_lock_bh(&sc->sc_pcu_lock); | 1246 | spin_lock_bh(&sc->sc_pcu_lock); |
@@ -1798,7 +1802,7 @@ static int ath9k_sta_add(struct ieee80211_hw *hw, | |||
1798 | struct ath_node *an = (struct ath_node *) sta->drv_priv; | 1802 | struct ath_node *an = (struct ath_node *) sta->drv_priv; |
1799 | struct ieee80211_key_conf ps_key = { }; | 1803 | struct ieee80211_key_conf ps_key = { }; |
1800 | 1804 | ||
1801 | ath_node_attach(sc, sta); | 1805 | ath_node_attach(sc, sta, vif); |
1802 | 1806 | ||
1803 | if (vif->type != NL80211_IFTYPE_AP && | 1807 | if (vif->type != NL80211_IFTYPE_AP && |
1804 | vif->type != NL80211_IFTYPE_AP_VLAN) | 1808 | vif->type != NL80211_IFTYPE_AP_VLAN) |
diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c new file mode 100644 index 000000000000..0fbb141bc302 --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/mci.c | |||
@@ -0,0 +1,254 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2010-2011 Atheros Communications Inc. | ||
3 | * | ||
4 | * Permission to use, copy, modify, and/or distribute this software for any | ||
5 | * purpose with or without fee is hereby granted, provided that the above | ||
6 | * copyright notice and this permission notice appear in all copies. | ||
7 | * | ||
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
15 | */ | ||
16 | |||
17 | #include "ath9k.h" | ||
18 | #include "mci.h" | ||
19 | |||
20 | u8 ath_mci_duty_cycle[] = { 0, 50, 60, 70, 80, 85, 90, 95, 98 }; | ||
21 | |||
22 | static struct ath_mci_profile_info* | ||
23 | ath_mci_find_profile(struct ath_mci_profile *mci, | ||
24 | struct ath_mci_profile_info *info) | ||
25 | { | ||
26 | struct ath_mci_profile_info *entry; | ||
27 | |||
28 | list_for_each_entry(entry, &mci->info, list) { | ||
29 | if (entry->conn_handle == info->conn_handle) | ||
30 | break; | ||
31 | } | ||
32 | return entry; | ||
33 | } | ||
34 | |||
35 | static bool ath_mci_add_profile(struct ath_common *common, | ||
36 | struct ath_mci_profile *mci, | ||
37 | struct ath_mci_profile_info *info) | ||
38 | { | ||
39 | struct ath_mci_profile_info *entry; | ||
40 | |||
41 | if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) && | ||
42 | (info->type == MCI_GPM_COEX_PROFILE_VOICE)) { | ||
43 | ath_dbg(common, ATH_DBG_MCI, | ||
44 | "Too many SCO profile, failed to add new profile\n"); | ||
45 | return false; | ||
46 | } | ||
47 | |||
48 | if (((NUM_PROF(mci) - mci->num_sco) == ATH_MCI_MAX_ACL_PROFILE) && | ||
49 | (info->type != MCI_GPM_COEX_PROFILE_VOICE)) { | ||
50 | ath_dbg(common, ATH_DBG_MCI, | ||
51 | "Too many ACL profile, failed to add new profile\n"); | ||
52 | return false; | ||
53 | } | ||
54 | |||
55 | entry = ath_mci_find_profile(mci, info); | ||
56 | |||
57 | if (entry) | ||
58 | memcpy(entry, info, 10); | ||
59 | else { | ||
60 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); | ||
61 | if (!entry) | ||
62 | return false; | ||
63 | |||
64 | memcpy(entry, info, 10); | ||
65 | INC_PROF(mci, info); | ||
66 | list_add_tail(&info->list, &mci->info); | ||
67 | } | ||
68 | return true; | ||
69 | } | ||
70 | |||
71 | static void ath_mci_del_profile(struct ath_common *common, | ||
72 | struct ath_mci_profile *mci, | ||
73 | struct ath_mci_profile_info *info) | ||
74 | { | ||
75 | struct ath_mci_profile_info *entry; | ||
76 | |||
77 | entry = ath_mci_find_profile(mci, info); | ||
78 | |||
79 | if (!entry) { | ||
80 | ath_dbg(common, ATH_DBG_MCI, | ||
81 | "Profile to be deleted not found\n"); | ||
82 | return; | ||
83 | } | ||
84 | DEC_PROF(mci, entry); | ||
85 | list_del(&entry->list); | ||
86 | kfree(entry); | ||
87 | } | ||
88 | |||
89 | void ath_mci_flush_profile(struct ath_mci_profile *mci) | ||
90 | { | ||
91 | struct ath_mci_profile_info *info, *tinfo; | ||
92 | |||
93 | list_for_each_entry_safe(info, tinfo, &mci->info, list) { | ||
94 | list_del(&info->list); | ||
95 | DEC_PROF(mci, info); | ||
96 | kfree(info); | ||
97 | } | ||
98 | mci->aggr_limit = 0; | ||
99 | } | ||
100 | |||
101 | static void ath_mci_adjust_aggr_limit(struct ath_btcoex *btcoex) | ||
102 | { | ||
103 | struct ath_mci_profile *mci = &btcoex->mci; | ||
104 | u32 wlan_airtime = btcoex->btcoex_period * | ||
105 | (100 - btcoex->duty_cycle) / 100; | ||
106 | |||
107 | /* | ||
108 | * Scale: wlan_airtime is in ms, aggr_limit is in 0.25 ms. | ||
109 | * When wlan_airtime is less than 4ms, aggregation limit has to be | ||
110 | * adjusted half of wlan_airtime to ensure that the aggregation can fit | ||
111 | * without collision with BT traffic. | ||
112 | */ | ||
113 | if ((wlan_airtime <= 4) && | ||
114 | (!mci->aggr_limit || (mci->aggr_limit > (2 * wlan_airtime)))) | ||
115 | mci->aggr_limit = 2 * wlan_airtime; | ||
116 | } | ||
117 | |||
118 | static void ath_mci_update_scheme(struct ath_softc *sc) | ||
119 | { | ||
120 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
121 | struct ath_btcoex *btcoex = &sc->btcoex; | ||
122 | struct ath_mci_profile *mci = &btcoex->mci; | ||
123 | struct ath_mci_profile_info *info; | ||
124 | u32 num_profile = NUM_PROF(mci); | ||
125 | |||
126 | if (num_profile == 1) { | ||
127 | info = list_first_entry(&mci->info, | ||
128 | struct ath_mci_profile_info, | ||
129 | list); | ||
130 | if (mci->num_sco && info->T == 12) { | ||
131 | mci->aggr_limit = 8; | ||
132 | ath_dbg(common, ATH_DBG_MCI, | ||
133 | "Single SCO, aggregation limit 2 ms\n"); | ||
134 | } else if ((info->type == MCI_GPM_COEX_PROFILE_BNEP) && | ||
135 | !info->master) { | ||
136 | btcoex->btcoex_period = 60; | ||
137 | ath_dbg(common, ATH_DBG_MCI, | ||
138 | "Single slave PAN/FTP, bt period 60 ms\n"); | ||
139 | } else if ((info->type == MCI_GPM_COEX_PROFILE_HID) && | ||
140 | (info->T > 0 && info->T < 50) && | ||
141 | (info->A > 1 || info->W > 1)) { | ||
142 | btcoex->duty_cycle = 30; | ||
143 | mci->aggr_limit = 8; | ||
144 | ath_dbg(common, ATH_DBG_MCI, | ||
145 | "Multiple attempt/timeout single HID " | ||
146 | "aggregation limit 2 ms dutycycle 30%%\n"); | ||
147 | } | ||
148 | } else if ((num_profile == 2) && (mci->num_hid == 2)) { | ||
149 | btcoex->duty_cycle = 30; | ||
150 | mci->aggr_limit = 8; | ||
151 | ath_dbg(common, ATH_DBG_MCI, | ||
152 | "Two HIDs aggregation limit 2 ms dutycycle 30%%\n"); | ||
153 | } else if (num_profile > 3) { | ||
154 | mci->aggr_limit = 6; | ||
155 | ath_dbg(common, ATH_DBG_MCI, | ||
156 | "Three or more profiles aggregation limit 1.5 ms\n"); | ||
157 | } | ||
158 | |||
159 | if (IS_CHAN_2GHZ(sc->sc_ah->curchan)) { | ||
160 | if (IS_CHAN_HT(sc->sc_ah->curchan)) | ||
161 | ath_mci_adjust_aggr_limit(btcoex); | ||
162 | else | ||
163 | btcoex->btcoex_period >>= 1; | ||
164 | } | ||
165 | |||
166 | ath9k_hw_btcoex_disable(sc->sc_ah); | ||
167 | ath9k_btcoex_timer_pause(sc); | ||
168 | |||
169 | if (IS_CHAN_5GHZ(sc->sc_ah->curchan)) | ||
170 | return; | ||
171 | |||
172 | btcoex->duty_cycle += (mci->num_bdr ? ATH_MCI_MAX_DUTY_CYCLE : 0); | ||
173 | if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE) | ||
174 | btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE; | ||
175 | |||
176 | btcoex->btcoex_period *= 1000; | ||
177 | btcoex->btcoex_no_stomp = btcoex->btcoex_period * | ||
178 | (100 - btcoex->duty_cycle) / 100; | ||
179 | |||
180 | ath9k_hw_btcoex_enable(sc->sc_ah); | ||
181 | ath9k_btcoex_timer_resume(sc); | ||
182 | } | ||
183 | |||
184 | void ath_mci_process_profile(struct ath_softc *sc, | ||
185 | struct ath_mci_profile_info *info) | ||
186 | { | ||
187 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
188 | struct ath_btcoex *btcoex = &sc->btcoex; | ||
189 | struct ath_mci_profile *mci = &btcoex->mci; | ||
190 | |||
191 | if (info->start) { | ||
192 | if (!ath_mci_add_profile(common, mci, info)) | ||
193 | return; | ||
194 | } else | ||
195 | ath_mci_del_profile(common, mci, info); | ||
196 | |||
197 | btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD; | ||
198 | mci->aggr_limit = mci->num_sco ? 6 : 0; | ||
199 | if (NUM_PROF(mci)) { | ||
200 | btcoex->bt_stomp_type = ATH_BTCOEX_STOMP_LOW; | ||
201 | btcoex->duty_cycle = ath_mci_duty_cycle[NUM_PROF(mci)]; | ||
202 | } else { | ||
203 | btcoex->bt_stomp_type = mci->num_mgmt ? ATH_BTCOEX_STOMP_ALL : | ||
204 | ATH_BTCOEX_STOMP_LOW; | ||
205 | btcoex->duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; | ||
206 | } | ||
207 | |||
208 | ath_mci_update_scheme(sc); | ||
209 | } | ||
210 | |||
211 | void ath_mci_process_status(struct ath_softc *sc, | ||
212 | struct ath_mci_profile_status *status) | ||
213 | { | ||
214 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
215 | struct ath_btcoex *btcoex = &sc->btcoex; | ||
216 | struct ath_mci_profile *mci = &btcoex->mci; | ||
217 | struct ath_mci_profile_info info; | ||
218 | int i = 0, old_num_mgmt = mci->num_mgmt; | ||
219 | |||
220 | /* Link status type are not handled */ | ||
221 | if (status->is_link) { | ||
222 | ath_dbg(common, ATH_DBG_MCI, | ||
223 | "Skip link type status update\n"); | ||
224 | return; | ||
225 | } | ||
226 | |||
227 | memset(&info, 0, sizeof(struct ath_mci_profile_info)); | ||
228 | |||
229 | info.conn_handle = status->conn_handle; | ||
230 | if (ath_mci_find_profile(mci, &info)) { | ||
231 | ath_dbg(common, ATH_DBG_MCI, | ||
232 | "Skip non link state update for existing profile %d\n", | ||
233 | status->conn_handle); | ||
234 | return; | ||
235 | } | ||
236 | if (status->conn_handle >= ATH_MCI_MAX_PROFILE) { | ||
237 | ath_dbg(common, ATH_DBG_MCI, | ||
238 | "Ignore too many non-link update\n"); | ||
239 | return; | ||
240 | } | ||
241 | if (status->is_critical) | ||
242 | __set_bit(status->conn_handle, mci->status); | ||
243 | else | ||
244 | __clear_bit(status->conn_handle, mci->status); | ||
245 | |||
246 | mci->num_mgmt = 0; | ||
247 | do { | ||
248 | if (test_bit(i, mci->status)) | ||
249 | mci->num_mgmt++; | ||
250 | } while (++i < ATH_MCI_MAX_PROFILE); | ||
251 | |||
252 | if (old_num_mgmt != mci->num_mgmt) | ||
253 | ath_mci_update_scheme(sc); | ||
254 | } | ||
diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h new file mode 100644 index 000000000000..9590c61822d1 --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/mci.h | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2010-2011 Atheros Communications Inc. | ||
3 | * | ||
4 | * Permission to use, copy, modify, and/or distribute this software for any | ||
5 | * purpose with or without fee is hereby granted, provided that the above | ||
6 | * copyright notice and this permission notice appear in all copies. | ||
7 | * | ||
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
15 | */ | ||
16 | |||
17 | #ifndef MCI_H | ||
18 | #define MCI_H | ||
19 | |||
20 | #define ATH_MCI_DEF_BT_PERIOD 40 | ||
21 | #define ATH_MCI_BDR_DUTY_CYCLE 20 | ||
22 | #define ATH_MCI_MAX_DUTY_CYCLE 90 | ||
23 | |||
24 | #define ATH_MCI_DEF_AGGR_LIMIT 6 /* in 0.24 ms */ | ||
25 | #define ATH_MCI_MAX_ACL_PROFILE 7 | ||
26 | #define ATH_MCI_MAX_SCO_PROFILE 1 | ||
27 | #define ATH_MCI_MAX_PROFILE (ATH_MCI_MAX_ACL_PROFILE +\ | ||
28 | ATH_MCI_MAX_SCO_PROFILE) | ||
29 | |||
30 | #define INC_PROF(_mci, _info) do { \ | ||
31 | switch (_info->type) { \ | ||
32 | case MCI_GPM_COEX_PROFILE_RFCOMM:\ | ||
33 | _mci->num_other_acl++; \ | ||
34 | break; \ | ||
35 | case MCI_GPM_COEX_PROFILE_A2DP: \ | ||
36 | _mci->num_a2dp++; \ | ||
37 | if (!_info->edr) \ | ||
38 | _mci->num_bdr++; \ | ||
39 | break; \ | ||
40 | case MCI_GPM_COEX_PROFILE_HID: \ | ||
41 | _mci->num_hid++; \ | ||
42 | break; \ | ||
43 | case MCI_GPM_COEX_PROFILE_BNEP: \ | ||
44 | _mci->num_pan++; \ | ||
45 | break; \ | ||
46 | case MCI_GPM_COEX_PROFILE_VOICE: \ | ||
47 | _mci->num_sco++; \ | ||
48 | break; \ | ||
49 | default: \ | ||
50 | break; \ | ||
51 | } \ | ||
52 | } while (0) | ||
53 | |||
54 | #define DEC_PROF(_mci, _info) do { \ | ||
55 | switch (_info->type) { \ | ||
56 | case MCI_GPM_COEX_PROFILE_RFCOMM:\ | ||
57 | _mci->num_other_acl--; \ | ||
58 | break; \ | ||
59 | case MCI_GPM_COEX_PROFILE_A2DP: \ | ||
60 | _mci->num_a2dp--; \ | ||
61 | if (!_info->edr) \ | ||
62 | _mci->num_bdr--; \ | ||
63 | break; \ | ||
64 | case MCI_GPM_COEX_PROFILE_HID: \ | ||
65 | _mci->num_hid--; \ | ||
66 | break; \ | ||
67 | case MCI_GPM_COEX_PROFILE_BNEP: \ | ||
68 | _mci->num_pan--; \ | ||
69 | break; \ | ||
70 | case MCI_GPM_COEX_PROFILE_VOICE: \ | ||
71 | _mci->num_sco--; \ | ||
72 | break; \ | ||
73 | default: \ | ||
74 | break; \ | ||
75 | } \ | ||
76 | } while (0) | ||
77 | |||
78 | #define NUM_PROF(_mci) (_mci->num_other_acl + _mci->num_a2dp + \ | ||
79 | _mci->num_hid + _mci->num_pan + _mci->num_sco) | ||
80 | |||
81 | struct ath_mci_profile_info { | ||
82 | u8 type; | ||
83 | u8 conn_handle; | ||
84 | bool start; | ||
85 | bool master; | ||
86 | bool edr; | ||
87 | u8 voice_type; | ||
88 | u16 T; /* Voice: Tvoice, HID: Tsniff, in slots */ | ||
89 | u8 W; /* Voice: Wvoice, HID: Sniff timeout, in slots */ | ||
90 | u8 A; /* HID: Sniff attempt, in slots */ | ||
91 | struct list_head list; | ||
92 | }; | ||
93 | |||
94 | struct ath_mci_profile_status { | ||
95 | bool is_critical; | ||
96 | bool is_link; | ||
97 | u8 conn_handle; | ||
98 | }; | ||
99 | |||
100 | struct ath_mci_profile { | ||
101 | struct list_head info; | ||
102 | DECLARE_BITMAP(status, ATH_MCI_MAX_PROFILE); | ||
103 | u16 aggr_limit; | ||
104 | u8 num_mgmt; | ||
105 | u8 num_sco; | ||
106 | u8 num_a2dp; | ||
107 | u8 num_hid; | ||
108 | u8 num_pan; | ||
109 | u8 num_other_acl; | ||
110 | u8 num_bdr; | ||
111 | }; | ||
112 | |||
113 | void ath_mci_flush_profile(struct ath_mci_profile *mci); | ||
114 | void ath_mci_process_profile(struct ath_softc *sc, | ||
115 | struct ath_mci_profile_info *info); | ||
116 | void ath_mci_process_status(struct ath_softc *sc, | ||
117 | struct ath_mci_profile_status *status); | ||
118 | #endif | ||
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 03b0a651a591..55d077e7135d 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c | |||
@@ -601,6 +601,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, | |||
601 | struct sk_buff *skb; | 601 | struct sk_buff *skb; |
602 | struct ieee80211_tx_info *tx_info; | 602 | struct ieee80211_tx_info *tx_info; |
603 | struct ieee80211_tx_rate *rates; | 603 | struct ieee80211_tx_rate *rates; |
604 | struct ath_mci_profile *mci = &sc->btcoex.mci; | ||
604 | u32 max_4ms_framelen, frmlen; | 605 | u32 max_4ms_framelen, frmlen; |
605 | u16 aggr_limit, legacy = 0; | 606 | u16 aggr_limit, legacy = 0; |
606 | int i; | 607 | int i; |
@@ -645,7 +646,9 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, | |||
645 | if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy) | 646 | if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy) |
646 | return 0; | 647 | return 0; |
647 | 648 | ||
648 | if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) | 649 | if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit) |
650 | aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4; | ||
651 | else if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) | ||
649 | aggr_limit = min((max_4ms_framelen * 3) / 8, | 652 | aggr_limit = min((max_4ms_framelen * 3) / 8, |
650 | (u32)ATH_AMPDU_LIMIT_MAX); | 653 | (u32)ATH_AMPDU_LIMIT_MAX); |
651 | else | 654 | else |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/Makefile b/drivers/net/wireless/brcm80211/brcmfmac/Makefile index b44e3094588a..d58aa1b0a932 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/Makefile +++ b/drivers/net/wireless/brcm80211/brcmfmac/Makefile | |||
@@ -26,7 +26,8 @@ DHDOFILES = \ | |||
26 | dhd_sdio.o \ | 26 | dhd_sdio.o \ |
27 | dhd_linux.o \ | 27 | dhd_linux.o \ |
28 | bcmsdh.o \ | 28 | bcmsdh.o \ |
29 | bcmsdh_sdmmc.o | 29 | bcmsdh_sdmmc.o \ |
30 | sdio_chip.o | ||
30 | 31 | ||
31 | obj-$(CONFIG_BRCMFMAC) += brcmfmac.o | 32 | obj-$(CONFIG_BRCMFMAC) += brcmfmac.o |
32 | brcmfmac-objs += $(DHDOFILES) | 33 | brcmfmac-objs += $(DHDOFILES) |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h b/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h index d7d3afd5a10f..cecb5e5f412b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h | |||
@@ -18,13 +18,6 @@ | |||
18 | #define _bcmchip_h_ | 18 | #define _bcmchip_h_ |
19 | 19 | ||
20 | /* bcm4329 */ | 20 | /* bcm4329 */ |
21 | /* SDIO device core, ID 0x829 */ | ||
22 | #define BCM4329_CORE_BUS_BASE 0x18011000 | ||
23 | /* internal memory core, ID 0x80e */ | ||
24 | #define BCM4329_CORE_SOCRAM_BASE 0x18003000 | ||
25 | /* ARM Cortex M3 core, ID 0x82a */ | ||
26 | #define BCM4329_CORE_ARM_BASE 0x18002000 | ||
27 | #define BCM4329_RAMSIZE 0x48000 | ||
28 | /* firmware name */ | 21 | /* firmware name */ |
29 | #define BCM4329_FW_NAME "brcm/bcm4329-fullmac-4.bin" | 22 | #define BCM4329_FW_NAME "brcm/bcm4329-fullmac-4.bin" |
30 | #define BCM4329_NV_NAME "brcm/bcm4329-fullmac-4.txt" | 23 | #define BCM4329_NV_NAME "brcm/bcm4329-fullmac-4.txt" |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 4645766b4070..6da519e7578f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h | |||
@@ -87,7 +87,7 @@ | |||
87 | #define TOE_TX_CSUM_OL 0x00000001 | 87 | #define TOE_TX_CSUM_OL 0x00000001 |
88 | #define TOE_RX_CSUM_OL 0x00000002 | 88 | #define TOE_RX_CSUM_OL 0x00000002 |
89 | 89 | ||
90 | #define BRCMF_BSS_INFO_VERSION 108 /* current ver of brcmf_bss_info struct */ | 90 | #define BRCMF_BSS_INFO_VERSION 108 /* curr ver of brcmf_bss_info_le struct */ |
91 | 91 | ||
92 | /* size of brcmf_scan_params not including variable length array */ | 92 | /* size of brcmf_scan_params not including variable length array */ |
93 | #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64 | 93 | #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64 |
@@ -122,8 +122,6 @@ | |||
122 | 122 | ||
123 | /* For supporting multiple interfaces */ | 123 | /* For supporting multiple interfaces */ |
124 | #define BRCMF_MAX_IFS 16 | 124 | #define BRCMF_MAX_IFS 16 |
125 | #define BRCMF_DEL_IF -0xe | ||
126 | #define BRCMF_BAD_IF -0xf | ||
127 | 125 | ||
128 | #define DOT11_BSSTYPE_ANY 2 | 126 | #define DOT11_BSSTYPE_ANY 2 |
129 | #define DOT11_MAX_DEFAULT_KEYS 4 | 127 | #define DOT11_MAX_DEFAULT_KEYS 4 |
@@ -365,7 +363,7 @@ struct brcmf_pkt_filter_enable_le { | |||
365 | * Applications MUST CHECK ie_offset field and length field to access IEs and | 363 | * Applications MUST CHECK ie_offset field and length field to access IEs and |
366 | * next bss_info structure in a vector (in struct brcmf_scan_results) | 364 | * next bss_info structure in a vector (in struct brcmf_scan_results) |
367 | */ | 365 | */ |
368 | struct brcmf_bss_info { | 366 | struct brcmf_bss_info_le { |
369 | __le32 version; /* version field */ | 367 | __le32 version; /* version field */ |
370 | __le32 length; /* byte length of data in this record, | 368 | __le32 length; /* byte length of data in this record, |
371 | * starting at version and including IEs | 369 | * starting at version and including IEs |
@@ -466,14 +464,13 @@ struct brcmf_scan_results { | |||
466 | u32 buflen; | 464 | u32 buflen; |
467 | u32 version; | 465 | u32 version; |
468 | u32 count; | 466 | u32 count; |
469 | struct brcmf_bss_info bss_info[1]; | 467 | struct brcmf_bss_info_le bss_info_le[]; |
470 | }; | 468 | }; |
471 | 469 | ||
472 | struct brcmf_scan_results_le { | 470 | struct brcmf_scan_results_le { |
473 | __le32 buflen; | 471 | __le32 buflen; |
474 | __le32 version; | 472 | __le32 version; |
475 | __le32 count; | 473 | __le32 count; |
476 | struct brcmf_bss_info bss_info[1]; | ||
477 | }; | 474 | }; |
478 | 475 | ||
479 | /* used for association with a specific BSSID and chanspec list */ | 476 | /* used for association with a specific BSSID and chanspec list */ |
@@ -493,10 +490,6 @@ struct brcmf_join_params { | |||
493 | struct brcmf_assoc_params_le params_le; | 490 | struct brcmf_assoc_params_le params_le; |
494 | }; | 491 | }; |
495 | 492 | ||
496 | /* size of brcmf_scan_results not including variable length array */ | ||
497 | #define BRCMF_SCAN_RESULTS_FIXED_SIZE \ | ||
498 | (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info)) | ||
499 | |||
500 | /* incremental scan results struct */ | 493 | /* incremental scan results struct */ |
501 | struct brcmf_iscan_results { | 494 | struct brcmf_iscan_results { |
502 | union { | 495 | union { |
@@ -511,7 +504,7 @@ struct brcmf_iscan_results { | |||
511 | 504 | ||
512 | /* size of brcmf_iscan_results not including variable length array */ | 505 | /* size of brcmf_iscan_results not including variable length array */ |
513 | #define BRCMF_ISCAN_RESULTS_FIXED_SIZE \ | 506 | #define BRCMF_ISCAN_RESULTS_FIXED_SIZE \ |
514 | (BRCMF_SCAN_RESULTS_FIXED_SIZE + \ | 507 | (sizeof(struct brcmf_scan_results) + \ |
515 | offsetof(struct brcmf_iscan_results, results)) | 508 | offsetof(struct brcmf_iscan_results, results)) |
516 | 509 | ||
517 | struct brcmf_wsec_key { | 510 | struct brcmf_wsec_key { |
@@ -734,8 +727,7 @@ extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, | |||
734 | extern void brcmf_c_init(void); | 727 | extern void brcmf_c_init(void); |
735 | 728 | ||
736 | extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, | 729 | extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, |
737 | struct net_device *ndev, char *name, u8 *mac_addr, | 730 | char *name, u8 *mac_addr); |
738 | u32 flags, u8 bssidx); | ||
739 | extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); | 731 | extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); |
740 | 732 | ||
741 | /* Send packet to dongle via data channel */ | 733 | /* Send packet to dongle via data channel */ |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c index 891826197f96..40928e58b6a6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c | |||
@@ -488,10 +488,9 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, | |||
488 | 488 | ||
489 | if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { | 489 | if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { |
490 | if (ifevent->action == BRCMF_E_IF_ADD) | 490 | if (ifevent->action == BRCMF_E_IF_ADD) |
491 | brcmf_add_if(drvr_priv, ifevent->ifidx, NULL, | 491 | brcmf_add_if(drvr_priv, ifevent->ifidx, |
492 | event->ifname, | 492 | event->ifname, |
493 | pvt_data->eth.h_dest, | 493 | pvt_data->eth.h_dest); |
494 | ifevent->flags, ifevent->bssidx); | ||
495 | else | 494 | else |
496 | brcmf_del_if(drvr_priv, ifevent->ifidx); | 495 | brcmf_del_if(drvr_priv, ifevent->ifidx); |
497 | } else { | 496 | } else { |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 4acbac5a74c6..719fd9397eb6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | |||
@@ -58,7 +58,6 @@ struct brcmf_if { | |||
58 | struct net_device *ndev; | 58 | struct net_device *ndev; |
59 | struct net_device_stats stats; | 59 | struct net_device_stats stats; |
60 | int idx; /* iface idx in dongle */ | 60 | int idx; /* iface idx in dongle */ |
61 | int state; /* interface state */ | ||
62 | u8 mac_addr[ETH_ALEN]; /* assigned MAC address */ | 61 | u8 mac_addr[ETH_ALEN]; /* assigned MAC address */ |
63 | }; | 62 | }; |
64 | 63 | ||
@@ -80,20 +79,6 @@ struct brcmf_info { | |||
80 | /* Error bits */ | 79 | /* Error bits */ |
81 | module_param(brcmf_msg_level, int, 0); | 80 | module_param(brcmf_msg_level, int, 0); |
82 | 81 | ||
83 | |||
84 | static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *ndev) | ||
85 | { | ||
86 | int i = 0; | ||
87 | |||
88 | while (i < BRCMF_MAX_IFS) { | ||
89 | if (drvr_priv->iflist[i] && drvr_priv->iflist[i]->ndev == ndev) | ||
90 | return i; | ||
91 | i++; | ||
92 | } | ||
93 | |||
94 | return BRCMF_BAD_IF; | ||
95 | } | ||
96 | |||
97 | int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) | 82 | int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) |
98 | { | 83 | { |
99 | int i = BRCMF_MAX_IFS; | 84 | int i = BRCMF_MAX_IFS; |
@@ -285,14 +270,9 @@ _brcmf_set_mac_address(struct work_struct *work) | |||
285 | 270 | ||
286 | static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) | 271 | static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) |
287 | { | 272 | { |
288 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 273 | struct brcmf_if *ifp = netdev_priv(ndev); |
289 | netdev_priv(ndev); | 274 | struct brcmf_info *drvr_priv = ifp->info; |
290 | struct sockaddr *sa = (struct sockaddr *)addr; | 275 | struct sockaddr *sa = (struct sockaddr *)addr; |
291 | int ifidx; | ||
292 | |||
293 | ifidx = brcmf_net2idx(drvr_priv, ndev); | ||
294 | if (ifidx == BRCMF_BAD_IF) | ||
295 | return -1; | ||
296 | 276 | ||
297 | memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); | 277 | memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); |
298 | schedule_work(&drvr_priv->setmacaddr_work); | 278 | schedule_work(&drvr_priv->setmacaddr_work); |
@@ -301,13 +281,8 @@ static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) | |||
301 | 281 | ||
302 | static void brcmf_netdev_set_multicast_list(struct net_device *ndev) | 282 | static void brcmf_netdev_set_multicast_list(struct net_device *ndev) |
303 | { | 283 | { |
304 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 284 | struct brcmf_if *ifp = netdev_priv(ndev); |
305 | netdev_priv(ndev); | 285 | struct brcmf_info *drvr_priv = ifp->info; |
306 | int ifidx; | ||
307 | |||
308 | ifidx = brcmf_net2idx(drvr_priv, ndev); | ||
309 | if (ifidx == BRCMF_BAD_IF) | ||
310 | return; | ||
311 | 286 | ||
312 | schedule_work(&drvr_priv->multicast_work); | 287 | schedule_work(&drvr_priv->multicast_work); |
313 | } | 288 | } |
@@ -341,9 +316,8 @@ int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) | |||
341 | static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) | 316 | static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) |
342 | { | 317 | { |
343 | int ret; | 318 | int ret; |
344 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 319 | struct brcmf_if *ifp = netdev_priv(ndev); |
345 | netdev_priv(ndev); | 320 | struct brcmf_info *drvr_priv = ifp->info; |
346 | int ifidx; | ||
347 | 321 | ||
348 | brcmf_dbg(TRACE, "Enter\n"); | 322 | brcmf_dbg(TRACE, "Enter\n"); |
349 | 323 | ||
@@ -355,9 +329,8 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
355 | return -ENODEV; | 329 | return -ENODEV; |
356 | } | 330 | } |
357 | 331 | ||
358 | ifidx = brcmf_net2idx(drvr_priv, ndev); | 332 | if (!drvr_priv->iflist[ifp->idx]) { |
359 | if (ifidx == BRCMF_BAD_IF) { | 333 | brcmf_dbg(ERROR, "bad ifidx %d\n", ifp->idx); |
360 | brcmf_dbg(ERROR, "bad ifidx %d\n", ifidx); | ||
361 | netif_stop_queue(ndev); | 334 | netif_stop_queue(ndev); |
362 | return -ENODEV; | 335 | return -ENODEV; |
363 | } | 336 | } |
@@ -367,20 +340,20 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
367 | struct sk_buff *skb2; | 340 | struct sk_buff *skb2; |
368 | 341 | ||
369 | brcmf_dbg(INFO, "%s: insufficient headroom\n", | 342 | brcmf_dbg(INFO, "%s: insufficient headroom\n", |
370 | brcmf_ifname(&drvr_priv->pub, ifidx)); | 343 | brcmf_ifname(&drvr_priv->pub, ifp->idx)); |
371 | drvr_priv->pub.tx_realloc++; | 344 | drvr_priv->pub.tx_realloc++; |
372 | skb2 = skb_realloc_headroom(skb, drvr_priv->pub.hdrlen); | 345 | skb2 = skb_realloc_headroom(skb, drvr_priv->pub.hdrlen); |
373 | dev_kfree_skb(skb); | 346 | dev_kfree_skb(skb); |
374 | skb = skb2; | 347 | skb = skb2; |
375 | if (skb == NULL) { | 348 | if (skb == NULL) { |
376 | brcmf_dbg(ERROR, "%s: skb_realloc_headroom failed\n", | 349 | brcmf_dbg(ERROR, "%s: skb_realloc_headroom failed\n", |
377 | brcmf_ifname(&drvr_priv->pub, ifidx)); | 350 | brcmf_ifname(&drvr_priv->pub, ifp->idx)); |
378 | ret = -ENOMEM; | 351 | ret = -ENOMEM; |
379 | goto done; | 352 | goto done; |
380 | } | 353 | } |
381 | } | 354 | } |
382 | 355 | ||
383 | ret = brcmf_sendpkt(&drvr_priv->pub, ifidx, skb); | 356 | ret = brcmf_sendpkt(&drvr_priv->pub, ifp->idx, skb); |
384 | 357 | ||
385 | done: | 358 | done: |
386 | if (ret) | 359 | if (ret) |
@@ -482,12 +455,10 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, | |||
482 | skb_mac_header(skb), | 455 | skb_mac_header(skb), |
483 | &event, &data); | 456 | &event, &data); |
484 | 457 | ||
485 | if (drvr_priv->iflist[ifidx] && | 458 | if (drvr_priv->iflist[ifidx]) { |
486 | !drvr_priv->iflist[ifidx]->state) | ||
487 | ifp = drvr_priv->iflist[ifidx]; | 459 | ifp = drvr_priv->iflist[ifidx]; |
488 | |||
489 | if (ifp->ndev) | ||
490 | ifp->ndev->last_rx = jiffies; | 460 | ifp->ndev->last_rx = jiffies; |
461 | } | ||
491 | 462 | ||
492 | drvr->dstats.rx_bytes += skb->len; | 463 | drvr->dstats.rx_bytes += skb->len; |
493 | drvr->rx_packets++; /* Local count */ | 464 | drvr->rx_packets++; /* Local count */ |
@@ -524,19 +495,11 @@ void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp, bool success) | |||
524 | 495 | ||
525 | static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev) | 496 | static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev) |
526 | { | 497 | { |
527 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 498 | struct brcmf_if *ifp = netdev_priv(ndev); |
528 | netdev_priv(ndev); | 499 | struct brcmf_info *drvr_priv = ifp->info; |
529 | struct brcmf_if *ifp; | ||
530 | int ifidx; | ||
531 | 500 | ||
532 | brcmf_dbg(TRACE, "Enter\n"); | 501 | brcmf_dbg(TRACE, "Enter\n"); |
533 | 502 | ||
534 | ifidx = brcmf_net2idx(drvr_priv, ndev); | ||
535 | if (ifidx == BRCMF_BAD_IF) | ||
536 | return NULL; | ||
537 | |||
538 | ifp = drvr_priv->iflist[ifidx]; | ||
539 | |||
540 | if (drvr_priv->pub.up) | 503 | if (drvr_priv->pub.up) |
541 | /* Use the protocol to get dongle stats */ | 504 | /* Use the protocol to get dongle stats */ |
542 | brcmf_proto_dstats(&drvr_priv->pub); | 505 | brcmf_proto_dstats(&drvr_priv->pub); |
@@ -637,8 +600,8 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) | |||
637 | static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, | 600 | static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, |
638 | struct ethtool_drvinfo *info) | 601 | struct ethtool_drvinfo *info) |
639 | { | 602 | { |
640 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 603 | struct brcmf_if *ifp = netdev_priv(ndev); |
641 | netdev_priv(ndev); | 604 | struct brcmf_info *drvr_priv = ifp->info; |
642 | 605 | ||
643 | sprintf(info->driver, KBUILD_MODNAME); | 606 | sprintf(info->driver, KBUILD_MODNAME); |
644 | sprintf(info->version, "%lu", drvr_priv->pub.drv_version); | 607 | sprintf(info->version, "%lu", drvr_priv->pub.drv_version); |
@@ -765,14 +728,12 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void __user *uaddr) | |||
765 | static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, | 728 | static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, |
766 | int cmd) | 729 | int cmd) |
767 | { | 730 | { |
768 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 731 | struct brcmf_if *ifp = netdev_priv(ndev); |
769 | netdev_priv(ndev); | 732 | struct brcmf_info *drvr_priv = ifp->info; |
770 | int ifidx; | ||
771 | 733 | ||
772 | ifidx = brcmf_net2idx(drvr_priv, ndev); | 734 | brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifp->idx, cmd); |
773 | brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifidx, cmd); | ||
774 | 735 | ||
775 | if (ifidx == BRCMF_BAD_IF) | 736 | if (!drvr_priv->iflist[ifp->idx]) |
776 | return -1; | 737 | return -1; |
777 | 738 | ||
778 | if (cmd == SIOCETHTOOL) | 739 | if (cmd == SIOCETHTOOL) |
@@ -788,17 +749,14 @@ s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len) | |||
788 | s32 err = 0; | 749 | s32 err = 0; |
789 | int buflen = 0; | 750 | int buflen = 0; |
790 | bool is_set_key_cmd; | 751 | bool is_set_key_cmd; |
791 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 752 | struct brcmf_if *ifp = netdev_priv(ndev); |
792 | netdev_priv(ndev); | 753 | struct brcmf_info *drvr_priv = ifp->info; |
793 | int ifidx; | ||
794 | 754 | ||
795 | memset(&dcmd, 0, sizeof(dcmd)); | 755 | memset(&dcmd, 0, sizeof(dcmd)); |
796 | dcmd.cmd = cmd; | 756 | dcmd.cmd = cmd; |
797 | dcmd.buf = arg; | 757 | dcmd.buf = arg; |
798 | dcmd.len = len; | 758 | dcmd.len = len; |
799 | 759 | ||
800 | ifidx = brcmf_net2idx(drvr_priv, ndev); | ||
801 | |||
802 | if (dcmd.buf != NULL) | 760 | if (dcmd.buf != NULL) |
803 | buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN); | 761 | buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN); |
804 | 762 | ||
@@ -826,7 +784,7 @@ s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len) | |||
826 | if (is_set_key_cmd) | 784 | if (is_set_key_cmd) |
827 | brcmf_netdev_wait_pend8021x(ndev); | 785 | brcmf_netdev_wait_pend8021x(ndev); |
828 | 786 | ||
829 | err = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, buflen); | 787 | err = brcmf_proto_dcmd(&drvr_priv->pub, ifp->idx, &dcmd, buflen); |
830 | 788 | ||
831 | done: | 789 | done: |
832 | if (err > 0) | 790 | if (err > 0) |
@@ -837,7 +795,8 @@ done: | |||
837 | 795 | ||
838 | static int brcmf_netdev_stop(struct net_device *ndev) | 796 | static int brcmf_netdev_stop(struct net_device *ndev) |
839 | { | 797 | { |
840 | struct brcmf_pub *drvr = *(struct brcmf_pub **) netdev_priv(ndev); | 798 | struct brcmf_if *ifp = netdev_priv(ndev); |
799 | struct brcmf_pub *drvr = &ifp->info->pub; | ||
841 | 800 | ||
842 | brcmf_dbg(TRACE, "Enter\n"); | 801 | brcmf_dbg(TRACE, "Enter\n"); |
843 | brcmf_cfg80211_down(drvr->config); | 802 | brcmf_cfg80211_down(drvr->config); |
@@ -853,16 +812,14 @@ static int brcmf_netdev_stop(struct net_device *ndev) | |||
853 | 812 | ||
854 | static int brcmf_netdev_open(struct net_device *ndev) | 813 | static int brcmf_netdev_open(struct net_device *ndev) |
855 | { | 814 | { |
856 | struct brcmf_info *drvr_priv = *(struct brcmf_info **) | 815 | struct brcmf_if *ifp = netdev_priv(ndev); |
857 | netdev_priv(ndev); | 816 | struct brcmf_info *drvr_priv = ifp->info; |
858 | u32 toe_ol; | 817 | u32 toe_ol; |
859 | int ifidx = brcmf_net2idx(drvr_priv, ndev); | ||
860 | s32 ret = 0; | 818 | s32 ret = 0; |
861 | 819 | ||
862 | brcmf_dbg(TRACE, "ifidx %d\n", ifidx); | 820 | brcmf_dbg(TRACE, "ifidx %d\n", ifp->idx); |
863 | |||
864 | if (ifidx == 0) { /* do it only for primary eth0 */ | ||
865 | 821 | ||
822 | if (ifp->idx == 0) { /* do it only for primary eth0 */ | ||
866 | /* try to bring up bus */ | 823 | /* try to bring up bus */ |
867 | ret = brcmf_bus_start(&drvr_priv->pub); | 824 | ret = brcmf_bus_start(&drvr_priv->pub); |
868 | if (ret != 0) { | 825 | if (ret != 0) { |
@@ -874,12 +831,12 @@ static int brcmf_netdev_open(struct net_device *ndev) | |||
874 | memcpy(ndev->dev_addr, drvr_priv->pub.mac, ETH_ALEN); | 831 | memcpy(ndev->dev_addr, drvr_priv->pub.mac, ETH_ALEN); |
875 | 832 | ||
876 | /* Get current TOE mode from dongle */ | 833 | /* Get current TOE mode from dongle */ |
877 | if (brcmf_toe_get(drvr_priv, ifidx, &toe_ol) >= 0 | 834 | if (brcmf_toe_get(drvr_priv, ifp->idx, &toe_ol) >= 0 |
878 | && (toe_ol & TOE_TX_CSUM_OL) != 0) | 835 | && (toe_ol & TOE_TX_CSUM_OL) != 0) |
879 | drvr_priv->iflist[ifidx]->ndev->features |= | 836 | drvr_priv->iflist[ifp->idx]->ndev->features |= |
880 | NETIF_F_IP_CSUM; | 837 | NETIF_F_IP_CSUM; |
881 | else | 838 | else |
882 | drvr_priv->iflist[ifidx]->ndev->features &= | 839 | drvr_priv->iflist[ifp->idx]->ndev->features &= |
883 | ~NETIF_F_IP_CSUM; | 840 | ~NETIF_F_IP_CSUM; |
884 | } | 841 | } |
885 | /* Allow transmit calls */ | 842 | /* Allow transmit calls */ |
@@ -893,75 +850,62 @@ static int brcmf_netdev_open(struct net_device *ndev) | |||
893 | return ret; | 850 | return ret; |
894 | } | 851 | } |
895 | 852 | ||
853 | static const struct net_device_ops brcmf_netdev_ops_pri = { | ||
854 | .ndo_open = brcmf_netdev_open, | ||
855 | .ndo_stop = brcmf_netdev_stop, | ||
856 | .ndo_get_stats = brcmf_netdev_get_stats, | ||
857 | .ndo_do_ioctl = brcmf_netdev_ioctl_entry, | ||
858 | .ndo_start_xmit = brcmf_netdev_start_xmit, | ||
859 | .ndo_set_mac_address = brcmf_netdev_set_mac_address, | ||
860 | .ndo_set_rx_mode = brcmf_netdev_set_multicast_list | ||
861 | }; | ||
862 | |||
896 | int | 863 | int |
897 | brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, | 864 | brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) |
898 | char *name, u8 *mac_addr, u32 flags, u8 bssidx) | ||
899 | { | 865 | { |
900 | struct brcmf_if *ifp; | 866 | struct brcmf_if *ifp; |
901 | int ret = 0, err = 0; | 867 | struct net_device *ndev; |
902 | 868 | ||
903 | brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, ndev); | 869 | brcmf_dbg(TRACE, "idx %d\n", ifidx); |
904 | 870 | ||
905 | ifp = drvr_priv->iflist[ifidx]; | 871 | ifp = drvr_priv->iflist[ifidx]; |
906 | if (!ifp) { | 872 | /* |
907 | ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); | 873 | * Delete the existing interface before overwriting it |
908 | if (!ifp) | 874 | * in case we missed the BRCMF_E_IF_DEL event. |
909 | return -ENOMEM; | 875 | */ |
876 | if (ifp) { | ||
877 | brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", | ||
878 | ifp->ndev->name); | ||
879 | netif_stop_queue(ifp->ndev); | ||
880 | unregister_netdev(ifp->ndev); | ||
881 | free_netdev(ifp->ndev); | ||
882 | drvr_priv->iflist[ifidx] = NULL; | ||
883 | } | ||
884 | |||
885 | /* Allocate netdev, including space for private structure */ | ||
886 | ndev = alloc_netdev(sizeof(struct brcmf_if), name, ether_setup); | ||
887 | if (!ndev) { | ||
888 | brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); | ||
889 | return -ENOMEM; | ||
910 | } | 890 | } |
911 | 891 | ||
912 | memset(ifp, 0, sizeof(struct brcmf_if)); | 892 | ifp = netdev_priv(ndev); |
893 | ifp->ndev = ndev; | ||
913 | ifp->info = drvr_priv; | 894 | ifp->info = drvr_priv; |
914 | drvr_priv->iflist[ifidx] = ifp; | 895 | drvr_priv->iflist[ifidx] = ifp; |
896 | ifp->idx = ifidx; | ||
915 | if (mac_addr != NULL) | 897 | if (mac_addr != NULL) |
916 | memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); | 898 | memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); |
917 | 899 | ||
918 | if (ndev == NULL) { | 900 | if (brcmf_net_attach(&drvr_priv->pub, ifp->idx)) { |
919 | ifp->state = BRCMF_E_IF_ADD; | 901 | brcmf_dbg(ERROR, "brcmf_net_attach failed"); |
920 | ifp->idx = ifidx; | 902 | free_netdev(ifp->ndev); |
921 | /* | 903 | drvr_priv->iflist[ifidx] = NULL; |
922 | * Delete the existing interface before overwriting it | 904 | return -EOPNOTSUPP; |
923 | * in case we missed the BRCMF_E_IF_DEL event. | 905 | } |
924 | */ | ||
925 | if (ifp->ndev != NULL) { | ||
926 | brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", | ||
927 | ifp->ndev->name); | ||
928 | netif_stop_queue(ifp->ndev); | ||
929 | unregister_netdev(ifp->ndev); | ||
930 | free_netdev(ifp->ndev); | ||
931 | } | ||
932 | |||
933 | /* Allocate netdev, including space for private structure */ | ||
934 | ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", | ||
935 | ether_setup); | ||
936 | if (!ifp->ndev) { | ||
937 | brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); | ||
938 | ret = -ENOMEM; | ||
939 | } | ||
940 | |||
941 | if (ret == 0) { | ||
942 | memcpy(netdev_priv(ifp->ndev), &drvr_priv, | ||
943 | sizeof(drvr_priv)); | ||
944 | err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); | ||
945 | if (err != 0) { | ||
946 | brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", | ||
947 | err); | ||
948 | ret = -EOPNOTSUPP; | ||
949 | } else { | ||
950 | brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", | ||
951 | current->pid, ifp->ndev->name); | ||
952 | ifp->state = 0; | ||
953 | } | ||
954 | } | ||
955 | |||
956 | if (ret < 0) { | ||
957 | if (ifp->ndev) | ||
958 | free_netdev(ifp->ndev); | ||
959 | 906 | ||
960 | drvr_priv->iflist[ifp->idx] = NULL; | 907 | brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", |
961 | kfree(ifp); | 908 | current->pid, ifp->ndev->name); |
962 | } | ||
963 | } else | ||
964 | ifp->ndev = ndev; | ||
965 | 909 | ||
966 | return 0; | 910 | return 0; |
967 | } | 911 | } |
@@ -977,47 +921,36 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) | |||
977 | brcmf_dbg(ERROR, "Null interface\n"); | 921 | brcmf_dbg(ERROR, "Null interface\n"); |
978 | return; | 922 | return; |
979 | } | 923 | } |
924 | if (ifp->ndev) { | ||
925 | if (ifidx == 0) { | ||
926 | if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { | ||
927 | rtnl_lock(); | ||
928 | brcmf_netdev_stop(ifp->ndev); | ||
929 | rtnl_unlock(); | ||
930 | } | ||
931 | } else { | ||
932 | netif_stop_queue(ifp->ndev); | ||
933 | } | ||
980 | 934 | ||
981 | ifp->state = BRCMF_E_IF_DEL; | ||
982 | ifp->idx = ifidx; | ||
983 | if (ifp->ndev != NULL) { | ||
984 | netif_stop_queue(ifp->ndev); | ||
985 | unregister_netdev(ifp->ndev); | 935 | unregister_netdev(ifp->ndev); |
986 | free_netdev(ifp->ndev); | ||
987 | drvr_priv->iflist[ifidx] = NULL; | 936 | drvr_priv->iflist[ifidx] = NULL; |
988 | kfree(ifp); | 937 | if (ifidx == 0) |
938 | brcmf_cfg80211_detach(drvr_priv->pub.config); | ||
939 | free_netdev(ifp->ndev); | ||
989 | } | 940 | } |
990 | } | 941 | } |
991 | 942 | ||
992 | struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) | 943 | struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) |
993 | { | 944 | { |
994 | struct brcmf_info *drvr_priv = NULL; | 945 | struct brcmf_info *drvr_priv = NULL; |
995 | struct net_device *ndev; | ||
996 | 946 | ||
997 | brcmf_dbg(TRACE, "Enter\n"); | 947 | brcmf_dbg(TRACE, "Enter\n"); |
998 | 948 | ||
999 | /* Allocate netdev, including space for private structure */ | ||
1000 | ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); | ||
1001 | if (!ndev) { | ||
1002 | brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); | ||
1003 | goto fail; | ||
1004 | } | ||
1005 | |||
1006 | /* Allocate primary brcmf_info */ | 949 | /* Allocate primary brcmf_info */ |
1007 | drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); | 950 | drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); |
1008 | if (!drvr_priv) | 951 | if (!drvr_priv) |
1009 | goto fail; | 952 | goto fail; |
1010 | 953 | ||
1011 | /* | ||
1012 | * Save the brcmf_info into the priv | ||
1013 | */ | ||
1014 | memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); | ||
1015 | |||
1016 | if (brcmf_add_if(drvr_priv, 0, ndev, ndev->name, NULL, 0, 0) == | ||
1017 | BRCMF_BAD_IF) | ||
1018 | goto fail; | ||
1019 | |||
1020 | ndev->netdev_ops = NULL; | ||
1021 | mutex_init(&drvr_priv->proto_block); | 954 | mutex_init(&drvr_priv->proto_block); |
1022 | 955 | ||
1023 | /* Link to info module */ | 956 | /* Link to info module */ |
@@ -1033,29 +966,12 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) | |||
1033 | goto fail; | 966 | goto fail; |
1034 | } | 967 | } |
1035 | 968 | ||
1036 | /* Attach and link in the cfg80211 */ | ||
1037 | drvr_priv->pub.config = | ||
1038 | brcmf_cfg80211_attach(ndev, | ||
1039 | brcmf_bus_get_device(bus), | ||
1040 | &drvr_priv->pub); | ||
1041 | if (drvr_priv->pub.config == NULL) { | ||
1042 | brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); | ||
1043 | goto fail; | ||
1044 | } | ||
1045 | |||
1046 | INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); | 969 | INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); |
1047 | INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); | 970 | INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); |
1048 | 971 | ||
1049 | /* | ||
1050 | * Save the brcmf_info into the priv | ||
1051 | */ | ||
1052 | memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); | ||
1053 | |||
1054 | return &drvr_priv->pub; | 972 | return &drvr_priv->pub; |
1055 | 973 | ||
1056 | fail: | 974 | fail: |
1057 | if (ndev) | ||
1058 | free_netdev(ndev); | ||
1059 | if (drvr_priv) | 975 | if (drvr_priv) |
1060 | brcmf_detach(&drvr_priv->pub); | 976 | brcmf_detach(&drvr_priv->pub); |
1061 | 977 | ||
@@ -1123,16 +1039,6 @@ int brcmf_bus_start(struct brcmf_pub *drvr) | |||
1123 | return 0; | 1039 | return 0; |
1124 | } | 1040 | } |
1125 | 1041 | ||
1126 | static struct net_device_ops brcmf_netdev_ops_pri = { | ||
1127 | .ndo_open = brcmf_netdev_open, | ||
1128 | .ndo_stop = brcmf_netdev_stop, | ||
1129 | .ndo_get_stats = brcmf_netdev_get_stats, | ||
1130 | .ndo_do_ioctl = brcmf_netdev_ioctl_entry, | ||
1131 | .ndo_start_xmit = brcmf_netdev_start_xmit, | ||
1132 | .ndo_set_mac_address = brcmf_netdev_set_mac_address, | ||
1133 | .ndo_set_rx_mode = brcmf_netdev_set_multicast_list | ||
1134 | }; | ||
1135 | |||
1136 | int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) | 1042 | int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) |
1137 | { | 1043 | { |
1138 | struct brcmf_info *drvr_priv = drvr->info; | 1044 | struct brcmf_info *drvr_priv = drvr->info; |
@@ -1169,6 +1075,18 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) | |||
1169 | 1075 | ||
1170 | memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); | 1076 | memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); |
1171 | 1077 | ||
1078 | /* attach to cfg80211 for primary interface */ | ||
1079 | if (!ifidx) { | ||
1080 | drvr->config = | ||
1081 | brcmf_cfg80211_attach(ndev, | ||
1082 | brcmf_bus_get_device(drvr->bus), | ||
1083 | drvr); | ||
1084 | if (drvr->config == NULL) { | ||
1085 | brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); | ||
1086 | goto fail; | ||
1087 | } | ||
1088 | } | ||
1089 | |||
1172 | if (register_netdev(ndev) != 0) { | 1090 | if (register_netdev(ndev) != 0) { |
1173 | brcmf_dbg(ERROR, "couldn't register the net device\n"); | 1091 | brcmf_dbg(ERROR, "couldn't register the net device\n"); |
1174 | goto fail; | 1092 | goto fail; |
@@ -1210,21 +1128,13 @@ void brcmf_detach(struct brcmf_pub *drvr) | |||
1210 | if (drvr) { | 1128 | if (drvr) { |
1211 | drvr_priv = drvr->info; | 1129 | drvr_priv = drvr->info; |
1212 | if (drvr_priv) { | 1130 | if (drvr_priv) { |
1213 | struct brcmf_if *ifp; | ||
1214 | int i; | 1131 | int i; |
1215 | 1132 | ||
1216 | for (i = 1; i < BRCMF_MAX_IFS; i++) | 1133 | /* make sure primary interface removed last */ |
1134 | for (i = BRCMF_MAX_IFS-1; i > -1; i--) | ||
1217 | if (drvr_priv->iflist[i]) | 1135 | if (drvr_priv->iflist[i]) |
1218 | brcmf_del_if(drvr_priv, i); | 1136 | brcmf_del_if(drvr_priv, i); |
1219 | 1137 | ||
1220 | ifp = drvr_priv->iflist[0]; | ||
1221 | if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { | ||
1222 | rtnl_lock(); | ||
1223 | brcmf_netdev_stop(ifp->ndev); | ||
1224 | rtnl_unlock(); | ||
1225 | unregister_netdev(ifp->ndev); | ||
1226 | } | ||
1227 | |||
1228 | cancel_work_sync(&drvr_priv->setmacaddr_work); | 1138 | cancel_work_sync(&drvr_priv->setmacaddr_work); |
1229 | cancel_work_sync(&drvr_priv->multicast_work); | 1139 | cancel_work_sync(&drvr_priv->multicast_work); |
1230 | 1140 | ||
@@ -1233,10 +1143,6 @@ void brcmf_detach(struct brcmf_pub *drvr) | |||
1233 | if (drvr->prot) | 1143 | if (drvr->prot) |
1234 | brcmf_proto_detach(drvr); | 1144 | brcmf_proto_detach(drvr); |
1235 | 1145 | ||
1236 | brcmf_cfg80211_detach(drvr->config); | ||
1237 | |||
1238 | free_netdev(ifp->ndev); | ||
1239 | kfree(ifp); | ||
1240 | kfree(drvr_priv); | 1146 | kfree(drvr_priv); |
1241 | } | 1147 | } |
1242 | } | 1148 | } |
@@ -1302,7 +1208,8 @@ static int brcmf_get_pend_8021x_cnt(struct brcmf_info *drvr_priv) | |||
1302 | 1208 | ||
1303 | int brcmf_netdev_wait_pend8021x(struct net_device *ndev) | 1209 | int brcmf_netdev_wait_pend8021x(struct net_device *ndev) |
1304 | { | 1210 | { |
1305 | struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(ndev); | 1211 | struct brcmf_if *ifp = netdev_priv(ndev); |
1212 | struct brcmf_info *drvr_priv = ifp->info; | ||
1306 | int timeout = 10 * HZ / 1000; | 1213 | int timeout = 10 * HZ / 1000; |
1307 | int ntimes = MAX_WAIT_FOR_8021X_TX; | 1214 | int ntimes = MAX_WAIT_FOR_8021X_TX; |
1308 | int pend = brcmf_get_pend_8021x_cnt(drvr_priv); | 1215 | int pend = brcmf_get_pend_8021x_cnt(drvr_priv); |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 313b8bf592d1..22913af26db8 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/semaphore.h> | 28 | #include <linux/semaphore.h> |
29 | #include <linux/firmware.h> | 29 | #include <linux/firmware.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/bcma/bcma.h> | ||
31 | #include <asm/unaligned.h> | 32 | #include <asm/unaligned.h> |
32 | #include <defs.h> | 33 | #include <defs.h> |
33 | #include <brcmu_wifi.h> | 34 | #include <brcmu_wifi.h> |
@@ -35,6 +36,7 @@ | |||
35 | #include <brcm_hw_ids.h> | 36 | #include <brcm_hw_ids.h> |
36 | #include <soc.h> | 37 | #include <soc.h> |
37 | #include "sdio_host.h" | 38 | #include "sdio_host.h" |
39 | #include "sdio_chip.h" | ||
38 | 40 | ||
39 | #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ | 41 | #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ |
40 | 42 | ||
@@ -134,33 +136,6 @@ struct rte_console { | |||
134 | /* Force no backplane reset */ | 136 | /* Force no backplane reset */ |
135 | #define SBSDIO_DEVCTL_RST_NOBPRESET 0x20 | 137 | #define SBSDIO_DEVCTL_RST_NOBPRESET 0x20 |
136 | 138 | ||
137 | /* SBSDIO_FUNC1_CHIPCLKCSR */ | ||
138 | |||
139 | /* Force ALP request to backplane */ | ||
140 | #define SBSDIO_FORCE_ALP 0x01 | ||
141 | /* Force HT request to backplane */ | ||
142 | #define SBSDIO_FORCE_HT 0x02 | ||
143 | /* Force ILP request to backplane */ | ||
144 | #define SBSDIO_FORCE_ILP 0x04 | ||
145 | /* Make ALP ready (power up xtal) */ | ||
146 | #define SBSDIO_ALP_AVAIL_REQ 0x08 | ||
147 | /* Make HT ready (power up PLL) */ | ||
148 | #define SBSDIO_HT_AVAIL_REQ 0x10 | ||
149 | /* Squelch clock requests from HW */ | ||
150 | #define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 | ||
151 | /* Status: ALP is ready */ | ||
152 | #define SBSDIO_ALP_AVAIL 0x40 | ||
153 | /* Status: HT is ready */ | ||
154 | #define SBSDIO_HT_AVAIL 0x80 | ||
155 | |||
156 | #define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) | ||
157 | #define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) | ||
158 | #define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) | ||
159 | #define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) | ||
160 | |||
161 | #define SBSDIO_CLKAV(regval, alponly) \ | ||
162 | (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) | ||
163 | |||
164 | /* direct(mapped) cis space */ | 139 | /* direct(mapped) cis space */ |
165 | 140 | ||
166 | /* MAPPED common CIS address */ | 141 | /* MAPPED common CIS address */ |
@@ -335,50 +310,6 @@ struct rte_console { | |||
335 | /* Flags for SDH calls */ | 310 | /* Flags for SDH calls */ |
336 | #define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED) | 311 | #define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED) |
337 | 312 | ||
338 | /* sbimstate */ | ||
339 | #define SBIM_IBE 0x20000 /* inbanderror */ | ||
340 | #define SBIM_TO 0x40000 /* timeout */ | ||
341 | #define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */ | ||
342 | #define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */ | ||
343 | |||
344 | /* sbtmstatelow */ | ||
345 | |||
346 | /* reset */ | ||
347 | #define SBTML_RESET 0x0001 | ||
348 | /* reject field */ | ||
349 | #define SBTML_REJ_MASK 0x0006 | ||
350 | /* reject */ | ||
351 | #define SBTML_REJ 0x0002 | ||
352 | /* temporary reject, for error recovery */ | ||
353 | #define SBTML_TMPREJ 0x0004 | ||
354 | |||
355 | /* Shift to locate the SI control flags in sbtml */ | ||
356 | #define SBTML_SICF_SHIFT 16 | ||
357 | |||
358 | /* sbtmstatehigh */ | ||
359 | #define SBTMH_SERR 0x0001 /* serror */ | ||
360 | #define SBTMH_INT 0x0002 /* interrupt */ | ||
361 | #define SBTMH_BUSY 0x0004 /* busy */ | ||
362 | #define SBTMH_TO 0x0020 /* timeout (sonics >= 2.3) */ | ||
363 | |||
364 | /* Shift to locate the SI status flags in sbtmh */ | ||
365 | #define SBTMH_SISF_SHIFT 16 | ||
366 | |||
367 | /* sbidlow */ | ||
368 | #define SBIDL_INIT 0x80 /* initiator */ | ||
369 | |||
370 | /* sbidhigh */ | ||
371 | #define SBIDH_RC_MASK 0x000f /* revision code */ | ||
372 | #define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ | ||
373 | #define SBIDH_RCE_SHIFT 8 | ||
374 | #define SBCOREREV(sbidh) \ | ||
375 | ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ | ||
376 | ((sbidh) & SBIDH_RC_MASK)) | ||
377 | #define SBIDH_CC_MASK 0x8ff0 /* core code */ | ||
378 | #define SBIDH_CC_SHIFT 4 | ||
379 | #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ | ||
380 | #define SBIDH_VC_SHIFT 16 | ||
381 | |||
382 | /* | 313 | /* |
383 | * Conversion of 802.1D priority to precedence level | 314 | * Conversion of 802.1D priority to precedence level |
384 | */ | 315 | */ |
@@ -388,17 +319,6 @@ static uint prio2prec(u32 prio) | |||
388 | (prio^2) : prio; | 319 | (prio^2) : prio; |
389 | } | 320 | } |
390 | 321 | ||
391 | /* | ||
392 | * Core reg address translation. | ||
393 | * Both macro's returns a 32 bits byte address on the backplane bus. | ||
394 | */ | ||
395 | #define CORE_CC_REG(base, field) \ | ||
396 | (base + offsetof(struct chipcregs, field)) | ||
397 | #define CORE_BUS_REG(base, field) \ | ||
398 | (base + offsetof(struct sdpcmd_regs, field)) | ||
399 | #define CORE_SB(base, field) \ | ||
400 | (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) | ||
401 | |||
402 | /* core registers */ | 322 | /* core registers */ |
403 | struct sdpcmd_regs { | 323 | struct sdpcmd_regs { |
404 | u32 corecontrol; /* 0x00, rev8 */ | 324 | u32 corecontrol; /* 0x00, rev8 */ |
@@ -524,21 +444,6 @@ struct sdpcm_shared_le { | |||
524 | 444 | ||
525 | 445 | ||
526 | /* misc chip info needed by some of the routines */ | 446 | /* misc chip info needed by some of the routines */ |
527 | struct chip_info { | ||
528 | u32 chip; | ||
529 | u32 chiprev; | ||
530 | u32 cccorebase; | ||
531 | u32 ccrev; | ||
532 | u32 cccaps; | ||
533 | u32 buscorebase; /* 32 bits backplane bus address */ | ||
534 | u32 buscorerev; | ||
535 | u32 buscoretype; | ||
536 | u32 ramcorebase; | ||
537 | u32 armcorebase; | ||
538 | u32 pmurev; | ||
539 | u32 ramsize; | ||
540 | }; | ||
541 | |||
542 | /* Private data for SDIO bus interaction */ | 447 | /* Private data for SDIO bus interaction */ |
543 | struct brcmf_bus { | 448 | struct brcmf_bus { |
544 | struct brcmf_pub *drvr; | 449 | struct brcmf_pub *drvr; |
@@ -574,7 +479,7 @@ struct brcmf_bus { | |||
574 | uint txminmax; | 479 | uint txminmax; |
575 | 480 | ||
576 | struct sk_buff *glomd; /* Packet containing glomming descriptor */ | 481 | struct sk_buff *glomd; /* Packet containing glomming descriptor */ |
577 | struct sk_buff *glom; /* Packet chain for glommed superframe */ | 482 | struct sk_buff_head glom; /* Packet list for glommed superframe */ |
578 | uint glomerr; /* Glom packet read errors */ | 483 | uint glomerr; /* Glom packet read errors */ |
579 | 484 | ||
580 | u8 *rxbuf; /* Buffer for receiving control packets */ | 485 | u8 *rxbuf; /* Buffer for receiving control packets */ |
@@ -663,46 +568,6 @@ struct brcmf_bus { | |||
663 | u32 fw_ptr; | 568 | u32 fw_ptr; |
664 | }; | 569 | }; |
665 | 570 | ||
666 | struct sbconfig { | ||
667 | u32 PAD[2]; | ||
668 | u32 sbipsflag; /* initiator port ocp slave flag */ | ||
669 | u32 PAD[3]; | ||
670 | u32 sbtpsflag; /* target port ocp slave flag */ | ||
671 | u32 PAD[11]; | ||
672 | u32 sbtmerrloga; /* (sonics >= 2.3) */ | ||
673 | u32 PAD; | ||
674 | u32 sbtmerrlog; /* (sonics >= 2.3) */ | ||
675 | u32 PAD[3]; | ||
676 | u32 sbadmatch3; /* address match3 */ | ||
677 | u32 PAD; | ||
678 | u32 sbadmatch2; /* address match2 */ | ||
679 | u32 PAD; | ||
680 | u32 sbadmatch1; /* address match1 */ | ||
681 | u32 PAD[7]; | ||
682 | u32 sbimstate; /* initiator agent state */ | ||
683 | u32 sbintvec; /* interrupt mask */ | ||
684 | u32 sbtmstatelow; /* target state */ | ||
685 | u32 sbtmstatehigh; /* target state */ | ||
686 | u32 sbbwa0; /* bandwidth allocation table0 */ | ||
687 | u32 PAD; | ||
688 | u32 sbimconfiglow; /* initiator configuration */ | ||
689 | u32 sbimconfighigh; /* initiator configuration */ | ||
690 | u32 sbadmatch0; /* address match0 */ | ||
691 | u32 PAD; | ||
692 | u32 sbtmconfiglow; /* target configuration */ | ||
693 | u32 sbtmconfighigh; /* target configuration */ | ||
694 | u32 sbbconfig; /* broadcast configuration */ | ||
695 | u32 PAD; | ||
696 | u32 sbbstate; /* broadcast state */ | ||
697 | u32 PAD[3]; | ||
698 | u32 sbactcnfg; /* activate configuration */ | ||
699 | u32 PAD[3]; | ||
700 | u32 sbflagst; /* current sbflags */ | ||
701 | u32 PAD[3]; | ||
702 | u32 sbidlow; /* identification */ | ||
703 | u32 sbidhigh; /* identification */ | ||
704 | }; | ||
705 | |||
706 | /* clkstate */ | 571 | /* clkstate */ |
707 | #define CLK_NONE 0 | 572 | #define CLK_NONE 0 |
708 | #define CLK_SDONLY 1 | 573 | #define CLK_SDONLY 1 |
@@ -750,10 +615,12 @@ static bool data_ok(struct brcmf_bus *bus) | |||
750 | static void | 615 | static void |
751 | r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) | 616 | r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) |
752 | { | 617 | { |
618 | u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); | ||
753 | *retryvar = 0; | 619 | *retryvar = 0; |
754 | do { | 620 | do { |
755 | *regvar = brcmf_sdcard_reg_read(bus->sdiodev, | 621 | *regvar = brcmf_sdcard_reg_read(bus->sdiodev, |
756 | bus->ci->buscorebase + reg_offset, sizeof(u32)); | 622 | bus->ci->c_inf[idx].base + reg_offset, |
623 | sizeof(u32)); | ||
757 | } while (brcmf_sdcard_regfail(bus->sdiodev) && | 624 | } while (brcmf_sdcard_regfail(bus->sdiodev) && |
758 | (++(*retryvar) <= retry_limit)); | 625 | (++(*retryvar) <= retry_limit)); |
759 | if (*retryvar) { | 626 | if (*retryvar) { |
@@ -768,10 +635,11 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) | |||
768 | static void | 635 | static void |
769 | w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) | 636 | w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) |
770 | { | 637 | { |
638 | u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); | ||
771 | *retryvar = 0; | 639 | *retryvar = 0; |
772 | do { | 640 | do { |
773 | brcmf_sdcard_reg_write(bus->sdiodev, | 641 | brcmf_sdcard_reg_write(bus->sdiodev, |
774 | bus->ci->buscorebase + reg_offset, | 642 | bus->ci->c_inf[idx].base + reg_offset, |
775 | sizeof(u32), regval); | 643 | sizeof(u32), regval); |
776 | } while (brcmf_sdcard_regfail(bus->sdiodev) && | 644 | } while (brcmf_sdcard_regfail(bus->sdiodev) && |
777 | (++(*retryvar) <= retry_limit)); | 645 | (++(*retryvar) <= retry_limit)); |
@@ -812,10 +680,6 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) | |||
812 | clkreq = | 680 | clkreq = |
813 | bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; | 681 | bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; |
814 | 682 | ||
815 | if ((bus->ci->chip == BCM4329_CHIP_ID) | ||
816 | && (bus->ci->chiprev == 0)) | ||
817 | clkreq |= SBSDIO_FORCE_ALP; | ||
818 | |||
819 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | 683 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, |
820 | SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); | 684 | SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); |
821 | if (err) { | 685 | if (err) { |
@@ -823,14 +687,6 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) | |||
823 | return -EBADE; | 687 | return -EBADE; |
824 | } | 688 | } |
825 | 689 | ||
826 | if (pendok && ((bus->ci->buscoretype == PCMCIA_CORE_ID) | ||
827 | && (bus->ci->buscorerev == 9))) { | ||
828 | u32 dummy, retries; | ||
829 | r_sdreg32(bus, &dummy, | ||
830 | offsetof(struct sdpcmd_regs, clockctlstatus), | ||
831 | &retries); | ||
832 | } | ||
833 | |||
834 | /* Check current status */ | 690 | /* Check current status */ |
835 | clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, | 691 | clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, |
836 | SBSDIO_FUNC1_CHIPCLKCSR, &err); | 692 | SBSDIO_FUNC1_CHIPCLKCSR, &err); |
@@ -1034,11 +890,9 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) | |||
1034 | SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); | 890 | SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); |
1035 | 891 | ||
1036 | /* Isolate the bus */ | 892 | /* Isolate the bus */ |
1037 | if (bus->ci->chip != BCM4329_CHIP_ID) { | 893 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, |
1038 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | 894 | SBSDIO_DEVICE_CTL, |
1039 | SBSDIO_DEVICE_CTL, | 895 | SBSDIO_DEVCTL_PADS_ISO, NULL); |
1040 | SBSDIO_DEVCTL_PADS_ISO, NULL); | ||
1041 | } | ||
1042 | 896 | ||
1043 | /* Change state */ | 897 | /* Change state */ |
1044 | bus->sleeping = true; | 898 | bus->sleeping = true; |
@@ -1049,13 +903,6 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) | |||
1049 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | 903 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, |
1050 | SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); | 904 | SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); |
1051 | 905 | ||
1052 | /* Force pad isolation off if possible | ||
1053 | (in case power never toggled) */ | ||
1054 | if ((bus->ci->buscoretype == PCMCIA_CORE_ID) | ||
1055 | && (bus->ci->buscorerev >= 10)) | ||
1056 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | ||
1057 | SBSDIO_DEVICE_CTL, 0, NULL); | ||
1058 | |||
1059 | /* Make sure the controller has the bus up */ | 906 | /* Make sure the controller has the bus up */ |
1060 | brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); | 907 | brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); |
1061 | 908 | ||
@@ -1222,6 +1069,51 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) | |||
1222 | bus->drvr->busstate = BRCMF_BUS_DOWN; | 1069 | bus->drvr->busstate = BRCMF_BUS_DOWN; |
1223 | } | 1070 | } |
1224 | 1071 | ||
1072 | /* copy a buffer into a pkt buffer chain */ | ||
1073 | static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_bus *bus, uint len) | ||
1074 | { | ||
1075 | uint n, ret = 0; | ||
1076 | struct sk_buff *p; | ||
1077 | u8 *buf; | ||
1078 | |||
1079 | buf = bus->dataptr; | ||
1080 | |||
1081 | /* copy the data */ | ||
1082 | skb_queue_walk(&bus->glom, p) { | ||
1083 | n = min_t(uint, p->len, len); | ||
1084 | memcpy(p->data, buf, n); | ||
1085 | buf += n; | ||
1086 | len -= n; | ||
1087 | ret += n; | ||
1088 | if (!len) | ||
1089 | break; | ||
1090 | } | ||
1091 | |||
1092 | return ret; | ||
1093 | } | ||
1094 | |||
1095 | /* return total length of buffer chain */ | ||
1096 | static uint brcmf_sdbrcm_glom_len(struct brcmf_bus *bus) | ||
1097 | { | ||
1098 | struct sk_buff *p; | ||
1099 | uint total; | ||
1100 | |||
1101 | total = 0; | ||
1102 | skb_queue_walk(&bus->glom, p) | ||
1103 | total += p->len; | ||
1104 | return total; | ||
1105 | } | ||
1106 | |||
1107 | static void brcmf_sdbrcm_free_glom(struct brcmf_bus *bus) | ||
1108 | { | ||
1109 | struct sk_buff *cur, *next; | ||
1110 | |||
1111 | skb_queue_walk_safe(&bus->glom, cur, next) { | ||
1112 | skb_unlink(cur, &bus->glom); | ||
1113 | brcmu_pkt_buf_free_skb(cur); | ||
1114 | } | ||
1115 | } | ||
1116 | |||
1225 | static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | 1117 | static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) |
1226 | { | 1118 | { |
1227 | u16 dlen, totlen; | 1119 | u16 dlen, totlen; |
@@ -1240,7 +1132,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1240 | /* If packets, issue read(s) and send up packet chain */ | 1132 | /* If packets, issue read(s) and send up packet chain */ |
1241 | /* Return sequence numbers consumed? */ | 1133 | /* Return sequence numbers consumed? */ |
1242 | 1134 | ||
1243 | brcmf_dbg(TRACE, "start: glomd %p glom %p\n", bus->glomd, bus->glom); | 1135 | brcmf_dbg(TRACE, "start: glomd %p glom %p\n", |
1136 | bus->glomd, skb_peek(&bus->glom)); | ||
1244 | 1137 | ||
1245 | /* If there's a descriptor, generate the packet chain */ | 1138 | /* If there's a descriptor, generate the packet chain */ |
1246 | if (bus->glomd) { | 1139 | if (bus->glomd) { |
@@ -1287,12 +1180,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1287 | num, sublen); | 1180 | num, sublen); |
1288 | break; | 1181 | break; |
1289 | } | 1182 | } |
1290 | if (!pfirst) { | 1183 | skb_queue_tail(&bus->glom, pnext); |
1291 | pfirst = plast = pnext; | ||
1292 | } else { | ||
1293 | plast->next = pnext; | ||
1294 | plast = pnext; | ||
1295 | } | ||
1296 | 1184 | ||
1297 | /* Adhere to start alignment requirements */ | 1185 | /* Adhere to start alignment requirements */ |
1298 | pkt_align(pnext, sublen, BRCMF_SDALIGN); | 1186 | pkt_align(pnext, sublen, BRCMF_SDALIGN); |
@@ -1308,12 +1196,9 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1308 | brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", | 1196 | brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", |
1309 | bus->nextlen, totlen, rxseq); | 1197 | bus->nextlen, totlen, rxseq); |
1310 | } | 1198 | } |
1311 | bus->glom = pfirst; | ||
1312 | pfirst = pnext = NULL; | 1199 | pfirst = pnext = NULL; |
1313 | } else { | 1200 | } else { |
1314 | if (pfirst) | 1201 | brcmf_sdbrcm_free_glom(bus); |
1315 | brcmu_pkt_buf_free_skb(pfirst); | ||
1316 | bus->glom = NULL; | ||
1317 | num = 0; | 1202 | num = 0; |
1318 | } | 1203 | } |
1319 | 1204 | ||
@@ -1325,18 +1210,18 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1325 | 1210 | ||
1326 | /* Ok -- either we just generated a packet chain, | 1211 | /* Ok -- either we just generated a packet chain, |
1327 | or had one from before */ | 1212 | or had one from before */ |
1328 | if (bus->glom) { | 1213 | if (!skb_queue_empty(&bus->glom)) { |
1329 | if (BRCMF_GLOM_ON()) { | 1214 | if (BRCMF_GLOM_ON()) { |
1330 | brcmf_dbg(GLOM, "try superframe read, packet chain:\n"); | 1215 | brcmf_dbg(GLOM, "try superframe read, packet chain:\n"); |
1331 | for (pnext = bus->glom; pnext; pnext = pnext->next) { | 1216 | skb_queue_walk(&bus->glom, pnext) { |
1332 | brcmf_dbg(GLOM, " %p: %p len 0x%04x (%d)\n", | 1217 | brcmf_dbg(GLOM, " %p: %p len 0x%04x (%d)\n", |
1333 | pnext, (u8 *) (pnext->data), | 1218 | pnext, (u8 *) (pnext->data), |
1334 | pnext->len, pnext->len); | 1219 | pnext->len, pnext->len); |
1335 | } | 1220 | } |
1336 | } | 1221 | } |
1337 | 1222 | ||
1338 | pfirst = bus->glom; | 1223 | pfirst = skb_peek(&bus->glom); |
1339 | dlen = (u16) brcmu_pkttotlen(pfirst); | 1224 | dlen = (u16) brcmf_sdbrcm_glom_len(bus); |
1340 | 1225 | ||
1341 | /* Do an SDIO read for the superframe. Configurable iovar to | 1226 | /* Do an SDIO read for the superframe. Configurable iovar to |
1342 | * read directly into the chained packet, or allocate a large | 1227 | * read directly into the chained packet, or allocate a large |
@@ -1354,8 +1239,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1354 | SDIO_FUNC_2, | 1239 | SDIO_FUNC_2, |
1355 | F2SYNC, bus->dataptr, dlen, | 1240 | F2SYNC, bus->dataptr, dlen, |
1356 | NULL); | 1241 | NULL); |
1357 | sublen = (u16) brcmu_pktfrombuf(pfirst, 0, dlen, | 1242 | sublen = (u16) brcmf_sdbrcm_glom_from_buf(bus, dlen); |
1358 | bus->dataptr); | ||
1359 | if (sublen != dlen) { | 1243 | if (sublen != dlen) { |
1360 | brcmf_dbg(ERROR, "FAILED TO COPY, dlen %d sublen %d\n", | 1244 | brcmf_dbg(ERROR, "FAILED TO COPY, dlen %d sublen %d\n", |
1361 | dlen, sublen); | 1245 | dlen, sublen); |
@@ -1380,9 +1264,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1380 | } else { | 1264 | } else { |
1381 | bus->glomerr = 0; | 1265 | bus->glomerr = 0; |
1382 | brcmf_sdbrcm_rxfail(bus, true, false); | 1266 | brcmf_sdbrcm_rxfail(bus, true, false); |
1383 | brcmu_pkt_buf_free_skb(bus->glom); | ||
1384 | bus->rxglomfail++; | 1267 | bus->rxglomfail++; |
1385 | bus->glom = NULL; | 1268 | brcmf_sdbrcm_free_glom(bus); |
1386 | } | 1269 | } |
1387 | return 0; | 1270 | return 0; |
1388 | } | 1271 | } |
@@ -1503,9 +1386,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1503 | } else { | 1386 | } else { |
1504 | bus->glomerr = 0; | 1387 | bus->glomerr = 0; |
1505 | brcmf_sdbrcm_rxfail(bus, true, false); | 1388 | brcmf_sdbrcm_rxfail(bus, true, false); |
1506 | brcmu_pkt_buf_free_skb(bus->glom); | ||
1507 | bus->rxglomfail++; | 1389 | bus->rxglomfail++; |
1508 | bus->glom = NULL; | 1390 | brcmf_sdbrcm_free_glom(bus); |
1509 | } | 1391 | } |
1510 | bus->nextlen = 0; | 1392 | bus->nextlen = 0; |
1511 | return 0; | 1393 | return 0; |
@@ -1513,7 +1395,6 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) | |||
1513 | 1395 | ||
1514 | /* Basic SD framing looks ok - process each packet (header) */ | 1396 | /* Basic SD framing looks ok - process each packet (header) */ |
1515 | save_pfirst = pfirst; | 1397 | save_pfirst = pfirst; |
1516 | bus->glom = NULL; | ||
1517 | plast = NULL; | 1398 | plast = NULL; |
1518 | 1399 | ||
1519 | for (num = 0; pfirst; rxseq++, pfirst = pnext) { | 1400 | for (num = 0; pfirst; rxseq++, pfirst = pnext) { |
@@ -1850,10 +1731,10 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) | |||
1850 | rxseq++, rxleft--) { | 1731 | rxseq++, rxleft--) { |
1851 | 1732 | ||
1852 | /* Handle glomming separately */ | 1733 | /* Handle glomming separately */ |
1853 | if (bus->glom || bus->glomd) { | 1734 | if (bus->glomd || !skb_queue_empty(&bus->glom)) { |
1854 | u8 cnt; | 1735 | u8 cnt; |
1855 | brcmf_dbg(GLOM, "calling rxglom: glomd %p, glom %p\n", | 1736 | brcmf_dbg(GLOM, "calling rxglom: glomd %p, glom %p\n", |
1856 | bus->glomd, bus->glom); | 1737 | bus->glomd, skb_peek(&bus->glom)); |
1857 | cnt = brcmf_sdbrcm_rxglom(bus, rxseq); | 1738 | cnt = brcmf_sdbrcm_rxglom(bus, rxseq); |
1858 | brcmf_dbg(GLOM, "rxglom returned %d\n", cnt); | 1739 | brcmf_dbg(GLOM, "rxglom returned %d\n", cnt); |
1859 | rxseq += cnt - 1; | 1740 | rxseq += cnt - 1; |
@@ -3210,135 +3091,11 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) | |||
3210 | return bcmerror; | 3091 | return bcmerror; |
3211 | } | 3092 | } |
3212 | 3093 | ||
3213 | static void | ||
3214 | brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) | ||
3215 | { | ||
3216 | u32 regdata; | ||
3217 | |||
3218 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3219 | CORE_SB(corebase, sbtmstatelow), 4); | ||
3220 | if (regdata & SBTML_RESET) | ||
3221 | return; | ||
3222 | |||
3223 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3224 | CORE_SB(corebase, sbtmstatelow), 4); | ||
3225 | if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { | ||
3226 | /* | ||
3227 | * set target reject and spin until busy is clear | ||
3228 | * (preserve core-specific bits) | ||
3229 | */ | ||
3230 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3231 | CORE_SB(corebase, sbtmstatelow), 4); | ||
3232 | brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), | ||
3233 | 4, regdata | SBTML_REJ); | ||
3234 | |||
3235 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3236 | CORE_SB(corebase, sbtmstatelow), 4); | ||
3237 | udelay(1); | ||
3238 | SPINWAIT((brcmf_sdcard_reg_read(sdiodev, | ||
3239 | CORE_SB(corebase, sbtmstatehigh), 4) & | ||
3240 | SBTMH_BUSY), 100000); | ||
3241 | |||
3242 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3243 | CORE_SB(corebase, sbtmstatehigh), 4); | ||
3244 | if (regdata & SBTMH_BUSY) | ||
3245 | brcmf_dbg(ERROR, "ARM core still busy\n"); | ||
3246 | |||
3247 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3248 | CORE_SB(corebase, sbidlow), 4); | ||
3249 | if (regdata & SBIDL_INIT) { | ||
3250 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3251 | CORE_SB(corebase, sbimstate), 4) | | ||
3252 | SBIM_RJ; | ||
3253 | brcmf_sdcard_reg_write(sdiodev, | ||
3254 | CORE_SB(corebase, sbimstate), 4, | ||
3255 | regdata); | ||
3256 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3257 | CORE_SB(corebase, sbimstate), 4); | ||
3258 | udelay(1); | ||
3259 | SPINWAIT((brcmf_sdcard_reg_read(sdiodev, | ||
3260 | CORE_SB(corebase, sbimstate), 4) & | ||
3261 | SBIM_BY), 100000); | ||
3262 | } | ||
3263 | |||
3264 | /* set reset and reject while enabling the clocks */ | ||
3265 | brcmf_sdcard_reg_write(sdiodev, | ||
3266 | CORE_SB(corebase, sbtmstatelow), 4, | ||
3267 | (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | | ||
3268 | SBTML_REJ | SBTML_RESET)); | ||
3269 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3270 | CORE_SB(corebase, sbtmstatelow), 4); | ||
3271 | udelay(10); | ||
3272 | |||
3273 | /* clear the initiator reject bit */ | ||
3274 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3275 | CORE_SB(corebase, sbidlow), 4); | ||
3276 | if (regdata & SBIDL_INIT) { | ||
3277 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3278 | CORE_SB(corebase, sbimstate), 4) & | ||
3279 | ~SBIM_RJ; | ||
3280 | brcmf_sdcard_reg_write(sdiodev, | ||
3281 | CORE_SB(corebase, sbimstate), 4, | ||
3282 | regdata); | ||
3283 | } | ||
3284 | } | ||
3285 | |||
3286 | /* leave reset and reject asserted */ | ||
3287 | brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, | ||
3288 | (SBTML_REJ | SBTML_RESET)); | ||
3289 | udelay(1); | ||
3290 | } | ||
3291 | |||
3292 | static void | ||
3293 | brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) | ||
3294 | { | ||
3295 | u32 regdata; | ||
3296 | |||
3297 | /* | ||
3298 | * Must do the disable sequence first to work for | ||
3299 | * arbitrary current core state. | ||
3300 | */ | ||
3301 | brcmf_sdbrcm_chip_disablecore(sdiodev, corebase); | ||
3302 | |||
3303 | /* | ||
3304 | * Now do the initialization sequence. | ||
3305 | * set reset while enabling the clock and | ||
3306 | * forcing them on throughout the core | ||
3307 | */ | ||
3308 | brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, | ||
3309 | ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | | ||
3310 | SBTML_RESET); | ||
3311 | udelay(1); | ||
3312 | |||
3313 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3314 | CORE_SB(corebase, sbtmstatehigh), 4); | ||
3315 | if (regdata & SBTMH_SERR) | ||
3316 | brcmf_sdcard_reg_write(sdiodev, | ||
3317 | CORE_SB(corebase, sbtmstatehigh), 4, 0); | ||
3318 | |||
3319 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
3320 | CORE_SB(corebase, sbimstate), 4); | ||
3321 | if (regdata & (SBIM_IBE | SBIM_TO)) | ||
3322 | brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, | ||
3323 | regdata & ~(SBIM_IBE | SBIM_TO)); | ||
3324 | |||
3325 | /* clear reset and allow it to propagate throughout the core */ | ||
3326 | brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, | ||
3327 | (SICF_FGC << SBTML_SICF_SHIFT) | | ||
3328 | (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); | ||
3329 | udelay(1); | ||
3330 | |||
3331 | /* leave clock enabled */ | ||
3332 | brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, | ||
3333 | (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); | ||
3334 | udelay(1); | ||
3335 | } | ||
3336 | |||
3337 | static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) | 3094 | static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) |
3338 | { | 3095 | { |
3339 | uint retries; | 3096 | uint retries; |
3340 | u32 regdata; | ||
3341 | int bcmerror = 0; | 3097 | int bcmerror = 0; |
3098 | struct chip_info *ci = bus->ci; | ||
3342 | 3099 | ||
3343 | /* To enter download state, disable ARM and reset SOCRAM. | 3100 | /* To enter download state, disable ARM and reset SOCRAM. |
3344 | * To exit download state, simply reset ARM (default is RAM boot). | 3101 | * To exit download state, simply reset ARM (default is RAM boot). |
@@ -3346,10 +3103,9 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) | |||
3346 | if (enter) { | 3103 | if (enter) { |
3347 | bus->alp_only = true; | 3104 | bus->alp_only = true; |
3348 | 3105 | ||
3349 | brcmf_sdbrcm_chip_disablecore(bus->sdiodev, | 3106 | ci->coredisable(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); |
3350 | bus->ci->armcorebase); | ||
3351 | 3107 | ||
3352 | brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); | 3108 | ci->resetcore(bus->sdiodev, ci, BCMA_CORE_INTERNAL_MEM); |
3353 | 3109 | ||
3354 | /* Clear the top bit of memory */ | 3110 | /* Clear the top bit of memory */ |
3355 | if (bus->ramsize) { | 3111 | if (bus->ramsize) { |
@@ -3358,11 +3114,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) | |||
3358 | (u8 *)&zeros, 4); | 3114 | (u8 *)&zeros, 4); |
3359 | } | 3115 | } |
3360 | } else { | 3116 | } else { |
3361 | regdata = brcmf_sdcard_reg_read(bus->sdiodev, | 3117 | if (!ci->iscoreup(bus->sdiodev, ci, BCMA_CORE_INTERNAL_MEM)) { |
3362 | CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); | ||
3363 | regdata &= (SBTML_RESET | SBTML_REJ_MASK | | ||
3364 | (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); | ||
3365 | if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) { | ||
3366 | brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); | 3118 | brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); |
3367 | bcmerror = -EBADE; | 3119 | bcmerror = -EBADE; |
3368 | goto fail; | 3120 | goto fail; |
@@ -3377,7 +3129,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) | |||
3377 | w_sdreg32(bus, 0xFFFFFFFF, | 3129 | w_sdreg32(bus, 0xFFFFFFFF, |
3378 | offsetof(struct sdpcmd_regs, intstatus), &retries); | 3130 | offsetof(struct sdpcmd_regs, intstatus), &retries); |
3379 | 3131 | ||
3380 | brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); | 3132 | ci->resetcore(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); |
3381 | 3133 | ||
3382 | /* Allow HT Clock now that the ARM is running. */ | 3134 | /* Allow HT Clock now that the ARM is running. */ |
3383 | bus->alp_only = false; | 3135 | bus->alp_only = false; |
@@ -3661,11 +3413,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) | |||
3661 | /* Clear any held glomming stuff */ | 3413 | /* Clear any held glomming stuff */ |
3662 | if (bus->glomd) | 3414 | if (bus->glomd) |
3663 | brcmu_pkt_buf_free_skb(bus->glomd); | 3415 | brcmu_pkt_buf_free_skb(bus->glomd); |
3664 | 3416 | brcmf_sdbrcm_free_glom(bus); | |
3665 | if (bus->glom) | ||
3666 | brcmu_pkt_buf_free_skb(bus->glom); | ||
3667 | |||
3668 | bus->glom = bus->glomd = NULL; | ||
3669 | 3417 | ||
3670 | /* Clear rx control and wake any waiters */ | 3418 | /* Clear rx control and wake any waiters */ |
3671 | bus->rxlen = 0; | 3419 | bus->rxlen = 0; |
@@ -3950,269 +3698,6 @@ fail: | |||
3950 | return false; | 3698 | return false; |
3951 | } | 3699 | } |
3952 | 3700 | ||
3953 | /* SDIO Pad drive strength to select value mappings */ | ||
3954 | struct sdiod_drive_str { | ||
3955 | u8 strength; /* Pad Drive Strength in mA */ | ||
3956 | u8 sel; /* Chip-specific select value */ | ||
3957 | }; | ||
3958 | |||
3959 | /* SDIO Drive Strength to sel value table for PMU Rev 1 */ | ||
3960 | static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { | ||
3961 | { | ||
3962 | 4, 0x2}, { | ||
3963 | 2, 0x3}, { | ||
3964 | 1, 0x0}, { | ||
3965 | 0, 0x0} | ||
3966 | }; | ||
3967 | |||
3968 | /* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ | ||
3969 | static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { | ||
3970 | { | ||
3971 | 12, 0x7}, { | ||
3972 | 10, 0x6}, { | ||
3973 | 8, 0x5}, { | ||
3974 | 6, 0x4}, { | ||
3975 | 4, 0x2}, { | ||
3976 | 2, 0x1}, { | ||
3977 | 0, 0x0} | ||
3978 | }; | ||
3979 | |||
3980 | /* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ | ||
3981 | static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { | ||
3982 | { | ||
3983 | 32, 0x7}, { | ||
3984 | 26, 0x6}, { | ||
3985 | 22, 0x5}, { | ||
3986 | 16, 0x4}, { | ||
3987 | 12, 0x3}, { | ||
3988 | 8, 0x2}, { | ||
3989 | 4, 0x1}, { | ||
3990 | 0, 0x0} | ||
3991 | }; | ||
3992 | |||
3993 | #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) | ||
3994 | |||
3995 | static char *brcmf_chipname(uint chipid, char *buf, uint len) | ||
3996 | { | ||
3997 | const char *fmt; | ||
3998 | |||
3999 | fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; | ||
4000 | snprintf(buf, len, fmt, chipid); | ||
4001 | return buf; | ||
4002 | } | ||
4003 | |||
4004 | static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, | ||
4005 | u32 drivestrength) { | ||
4006 | struct sdiod_drive_str *str_tab = NULL; | ||
4007 | u32 str_mask = 0; | ||
4008 | u32 str_shift = 0; | ||
4009 | char chn[8]; | ||
4010 | |||
4011 | if (!(bus->ci->cccaps & CC_CAP_PMU)) | ||
4012 | return; | ||
4013 | |||
4014 | switch (SDIOD_DRVSTR_KEY(bus->ci->chip, bus->ci->pmurev)) { | ||
4015 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): | ||
4016 | str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; | ||
4017 | str_mask = 0x30000000; | ||
4018 | str_shift = 28; | ||
4019 | break; | ||
4020 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): | ||
4021 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): | ||
4022 | str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; | ||
4023 | str_mask = 0x00003800; | ||
4024 | str_shift = 11; | ||
4025 | break; | ||
4026 | case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): | ||
4027 | str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; | ||
4028 | str_mask = 0x00003800; | ||
4029 | str_shift = 11; | ||
4030 | break; | ||
4031 | default: | ||
4032 | brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", | ||
4033 | brcmf_chipname(bus->ci->chip, chn, 8), | ||
4034 | bus->ci->chiprev, bus->ci->pmurev); | ||
4035 | break; | ||
4036 | } | ||
4037 | |||
4038 | if (str_tab != NULL) { | ||
4039 | u32 drivestrength_sel = 0; | ||
4040 | u32 cc_data_temp; | ||
4041 | int i; | ||
4042 | |||
4043 | for (i = 0; str_tab[i].strength != 0; i++) { | ||
4044 | if (drivestrength >= str_tab[i].strength) { | ||
4045 | drivestrength_sel = str_tab[i].sel; | ||
4046 | break; | ||
4047 | } | ||
4048 | } | ||
4049 | |||
4050 | brcmf_sdcard_reg_write(bus->sdiodev, | ||
4051 | CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), | ||
4052 | 4, 1); | ||
4053 | cc_data_temp = brcmf_sdcard_reg_read(bus->sdiodev, | ||
4054 | CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4); | ||
4055 | cc_data_temp &= ~str_mask; | ||
4056 | drivestrength_sel <<= str_shift; | ||
4057 | cc_data_temp |= drivestrength_sel; | ||
4058 | brcmf_sdcard_reg_write(bus->sdiodev, | ||
4059 | CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), | ||
4060 | 4, cc_data_temp); | ||
4061 | |||
4062 | brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", | ||
4063 | drivestrength, cc_data_temp); | ||
4064 | } | ||
4065 | } | ||
4066 | |||
4067 | static int | ||
4068 | brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, | ||
4069 | struct chip_info *ci, u32 regs) | ||
4070 | { | ||
4071 | u32 regdata; | ||
4072 | |||
4073 | /* | ||
4074 | * Get CC core rev | ||
4075 | * Chipid is assume to be at offset 0 from regs arg | ||
4076 | * For different chiptypes or old sdio hosts w/o chipcommon, | ||
4077 | * other ways of recognition should be added here. | ||
4078 | */ | ||
4079 | ci->cccorebase = regs; | ||
4080 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4081 | CORE_CC_REG(ci->cccorebase, chipid), 4); | ||
4082 | ci->chip = regdata & CID_ID_MASK; | ||
4083 | ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; | ||
4084 | |||
4085 | brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); | ||
4086 | |||
4087 | /* Address of cores for new chips should be added here */ | ||
4088 | switch (ci->chip) { | ||
4089 | case BCM4329_CHIP_ID: | ||
4090 | ci->buscorebase = BCM4329_CORE_BUS_BASE; | ||
4091 | ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; | ||
4092 | ci->armcorebase = BCM4329_CORE_ARM_BASE; | ||
4093 | ci->ramsize = BCM4329_RAMSIZE; | ||
4094 | break; | ||
4095 | default: | ||
4096 | brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); | ||
4097 | return -ENODEV; | ||
4098 | } | ||
4099 | |||
4100 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4101 | CORE_SB(ci->cccorebase, sbidhigh), 4); | ||
4102 | ci->ccrev = SBCOREREV(regdata); | ||
4103 | |||
4104 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4105 | CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); | ||
4106 | ci->pmurev = regdata & PCAP_REV_MASK; | ||
4107 | |||
4108 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4109 | CORE_SB(ci->buscorebase, sbidhigh), 4); | ||
4110 | ci->buscorerev = SBCOREREV(regdata); | ||
4111 | ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; | ||
4112 | |||
4113 | brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", | ||
4114 | ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); | ||
4115 | |||
4116 | /* get chipcommon capabilites */ | ||
4117 | ci->cccaps = brcmf_sdcard_reg_read(sdiodev, | ||
4118 | CORE_CC_REG(ci->cccorebase, capabilities), 4); | ||
4119 | |||
4120 | return 0; | ||
4121 | } | ||
4122 | |||
4123 | static int | ||
4124 | brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) | ||
4125 | { | ||
4126 | struct chip_info *ci; | ||
4127 | int err; | ||
4128 | u8 clkval, clkset; | ||
4129 | |||
4130 | brcmf_dbg(TRACE, "Enter\n"); | ||
4131 | |||
4132 | /* alloc chip_info_t */ | ||
4133 | ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); | ||
4134 | if (NULL == ci) | ||
4135 | return -ENOMEM; | ||
4136 | |||
4137 | /* bus/core/clk setup for register access */ | ||
4138 | /* Try forcing SDIO core to do ALPAvail request only */ | ||
4139 | clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; | ||
4140 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | ||
4141 | SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); | ||
4142 | if (err) { | ||
4143 | brcmf_dbg(ERROR, "error writing for HT off\n"); | ||
4144 | goto fail; | ||
4145 | } | ||
4146 | |||
4147 | /* If register supported, wait for ALPAvail and then force ALP */ | ||
4148 | /* This may take up to 15 milliseconds */ | ||
4149 | clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, | ||
4150 | SBSDIO_FUNC1_CHIPCLKCSR, NULL); | ||
4151 | if ((clkval & ~SBSDIO_AVBITS) == clkset) { | ||
4152 | SPINWAIT(((clkval = | ||
4153 | brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, | ||
4154 | SBSDIO_FUNC1_CHIPCLKCSR, | ||
4155 | NULL)), | ||
4156 | !SBSDIO_ALPAV(clkval)), | ||
4157 | PMU_MAX_TRANSITION_DLY); | ||
4158 | if (!SBSDIO_ALPAV(clkval)) { | ||
4159 | brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", | ||
4160 | clkval); | ||
4161 | err = -EBUSY; | ||
4162 | goto fail; | ||
4163 | } | ||
4164 | clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | | ||
4165 | SBSDIO_FORCE_ALP; | ||
4166 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | ||
4167 | SBSDIO_FUNC1_CHIPCLKCSR, | ||
4168 | clkset, &err); | ||
4169 | udelay(65); | ||
4170 | } else { | ||
4171 | brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", | ||
4172 | clkset, clkval); | ||
4173 | err = -EACCES; | ||
4174 | goto fail; | ||
4175 | } | ||
4176 | |||
4177 | /* Also, disable the extra SDIO pull-ups */ | ||
4178 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | ||
4179 | SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); | ||
4180 | |||
4181 | err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); | ||
4182 | if (err) | ||
4183 | goto fail; | ||
4184 | |||
4185 | /* | ||
4186 | * Make sure any on-chip ARM is off (in case strapping is wrong), | ||
4187 | * or downloaded code was already running. | ||
4188 | */ | ||
4189 | brcmf_sdbrcm_chip_disablecore(bus->sdiodev, ci->armcorebase); | ||
4190 | |||
4191 | brcmf_sdcard_reg_write(bus->sdiodev, | ||
4192 | CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); | ||
4193 | brcmf_sdcard_reg_write(bus->sdiodev, | ||
4194 | CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); | ||
4195 | |||
4196 | /* Disable F2 to clear any intermediate frame state on the dongle */ | ||
4197 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, | ||
4198 | SDIO_FUNC_ENABLE_1, NULL); | ||
4199 | |||
4200 | /* WAR: cmd52 backplane read so core HW will drop ALPReq */ | ||
4201 | clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, | ||
4202 | 0, NULL); | ||
4203 | |||
4204 | /* Done with backplane-dependent accesses, can drop clock... */ | ||
4205 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | ||
4206 | SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); | ||
4207 | |||
4208 | bus->ci = ci; | ||
4209 | return 0; | ||
4210 | fail: | ||
4211 | bus->ci = NULL; | ||
4212 | kfree(ci); | ||
4213 | return err; | ||
4214 | } | ||
4215 | |||
4216 | static bool | 3701 | static bool |
4217 | brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) | 3702 | brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) |
4218 | { | 3703 | { |
@@ -4220,6 +3705,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) | |||
4220 | int err = 0; | 3705 | int err = 0; |
4221 | int reg_addr; | 3706 | int reg_addr; |
4222 | u32 reg_val; | 3707 | u32 reg_val; |
3708 | u8 idx; | ||
4223 | 3709 | ||
4224 | bus->alp_only = true; | 3710 | bus->alp_only = true; |
4225 | 3711 | ||
@@ -4234,7 +3720,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) | |||
4234 | #endif /* BCMDBG */ | 3720 | #endif /* BCMDBG */ |
4235 | 3721 | ||
4236 | /* | 3722 | /* |
4237 | * Force PLL off until brcmf_sdbrcm_chip_attach() | 3723 | * Force PLL off until brcmf_sdio_chip_attach() |
4238 | * programs PLL control regs | 3724 | * programs PLL control regs |
4239 | */ | 3725 | */ |
4240 | 3726 | ||
@@ -4252,8 +3738,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) | |||
4252 | goto fail; | 3738 | goto fail; |
4253 | } | 3739 | } |
4254 | 3740 | ||
4255 | if (brcmf_sdbrcm_chip_attach(bus, regsva)) { | 3741 | if (brcmf_sdio_chip_attach(bus->sdiodev, &bus->ci, regsva)) { |
4256 | brcmf_dbg(ERROR, "brcmf_sdbrcm_chip_attach failed!\n"); | 3742 | brcmf_dbg(ERROR, "brcmf_sdio_chip_attach failed!\n"); |
4257 | goto fail; | 3743 | goto fail; |
4258 | } | 3744 | } |
4259 | 3745 | ||
@@ -4262,11 +3748,10 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) | |||
4262 | goto fail; | 3748 | goto fail; |
4263 | } | 3749 | } |
4264 | 3750 | ||
4265 | brcmf_sdbrcm_sdiod_drive_strength_init(bus, SDIO_DRIVE_STRENGTH); | 3751 | brcmf_sdio_chip_drivestrengthinit(bus->sdiodev, bus->ci, |
3752 | SDIO_DRIVE_STRENGTH); | ||
4266 | 3753 | ||
4267 | /* Get info on the ARM and SOCRAM cores... */ | 3754 | /* Get info on the SOCRAM cores... */ |
4268 | brcmf_sdcard_reg_read(bus->sdiodev, | ||
4269 | CORE_SB(bus->ci->armcorebase, sbidhigh), 4); | ||
4270 | bus->ramsize = bus->ci->ramsize; | 3755 | bus->ramsize = bus->ci->ramsize; |
4271 | if (!(bus->ramsize)) { | 3756 | if (!(bus->ramsize)) { |
4272 | brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); | 3757 | brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); |
@@ -4274,7 +3759,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) | |||
4274 | } | 3759 | } |
4275 | 3760 | ||
4276 | /* Set core control so an SDIO reset does a backplane reset */ | 3761 | /* Set core control so an SDIO reset does a backplane reset */ |
4277 | reg_addr = bus->ci->buscorebase + | 3762 | idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); |
3763 | reg_addr = bus->ci->c_inf[idx].base + | ||
4278 | offsetof(struct sdpcmd_regs, corecontrol); | 3764 | offsetof(struct sdpcmd_regs, corecontrol); |
4279 | reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); | 3765 | reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); |
4280 | brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), | 3766 | brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), |
@@ -4364,15 +3850,6 @@ brcmf_sdbrcm_watchdog(unsigned long data) | |||
4364 | } | 3850 | } |
4365 | } | 3851 | } |
4366 | 3852 | ||
4367 | static void | ||
4368 | brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus) | ||
4369 | { | ||
4370 | brcmf_dbg(TRACE, "Enter\n"); | ||
4371 | |||
4372 | kfree(bus->ci); | ||
4373 | bus->ci = NULL; | ||
4374 | } | ||
4375 | |||
4376 | static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) | 3853 | static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) |
4377 | { | 3854 | { |
4378 | brcmf_dbg(TRACE, "Enter\n"); | 3855 | brcmf_dbg(TRACE, "Enter\n"); |
@@ -4380,7 +3857,7 @@ static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) | |||
4380 | if (bus->ci) { | 3857 | if (bus->ci) { |
4381 | brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); | 3858 | brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); |
4382 | brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); | 3859 | brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); |
4383 | brcmf_sdbrcm_chip_detach(bus); | 3860 | brcmf_sdio_chip_detach(&bus->ci); |
4384 | if (bus->vars && bus->varsz) | 3861 | if (bus->vars && bus->varsz) |
4385 | kfree(bus->vars); | 3862 | kfree(bus->vars); |
4386 | bus->vars = NULL; | 3863 | bus->vars = NULL; |
@@ -4440,6 +3917,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, | |||
4440 | 3917 | ||
4441 | bus->sdiodev = sdiodev; | 3918 | bus->sdiodev = sdiodev; |
4442 | sdiodev->bus = bus; | 3919 | sdiodev->bus = bus; |
3920 | skb_queue_head_init(&bus->glom); | ||
4443 | bus->txbound = BRCMF_TXBOUND; | 3921 | bus->txbound = BRCMF_TXBOUND; |
4444 | bus->rxbound = BRCMF_RXBOUND; | 3922 | bus->rxbound = BRCMF_RXBOUND; |
4445 | bus->txminmax = BRCMF_TXMINMAX; | 3923 | bus->txminmax = BRCMF_TXMINMAX; |
@@ -4521,9 +3999,10 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, | |||
4521 | goto fail; | 3999 | goto fail; |
4522 | } | 4000 | } |
4523 | } | 4001 | } |
4524 | /* Ok, have the per-port tell the stack we're open for business */ | 4002 | |
4525 | if (brcmf_net_attach(bus->drvr, 0) != 0) { | 4003 | /* add interface and open for business */ |
4526 | brcmf_dbg(ERROR, "Net attach failed!!\n"); | 4004 | if (brcmf_add_if((struct brcmf_info *)bus->drvr, 0, "wlan%d", NULL)) { |
4005 | brcmf_dbg(ERROR, "Add primary net device interface failed!!\n"); | ||
4527 | goto fail; | 4006 | goto fail; |
4528 | } | 4007 | } |
4529 | 4008 | ||
@@ -4554,10 +4033,6 @@ struct device *brcmf_bus_get_device(struct brcmf_bus *bus) | |||
4554 | void | 4033 | void |
4555 | brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) | 4034 | brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) |
4556 | { | 4035 | { |
4557 | /* don't start the wd until fw is loaded */ | ||
4558 | if (bus->drvr->busstate == BRCMF_BUS_DOWN) | ||
4559 | return; | ||
4560 | |||
4561 | /* Totally stop the timer */ | 4036 | /* Totally stop the timer */ |
4562 | if (!wdtick && bus->wd_timer_valid == true) { | 4037 | if (!wdtick && bus->wd_timer_valid == true) { |
4563 | del_timer_sync(&bus->timer); | 4038 | del_timer_sync(&bus->timer); |
@@ -4566,6 +4041,10 @@ brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) | |||
4566 | return; | 4041 | return; |
4567 | } | 4042 | } |
4568 | 4043 | ||
4044 | /* don't start the wd until fw is loaded */ | ||
4045 | if (bus->drvr->busstate == BRCMF_BUS_DOWN) | ||
4046 | return; | ||
4047 | |||
4569 | if (wdtick) { | 4048 | if (wdtick) { |
4570 | if (bus->save_ms != BRCMF_WD_POLL_MS) { | 4049 | if (bus->save_ms != BRCMF_WD_POLL_MS) { |
4571 | if (bus->wd_timer_valid == true) | 4050 | if (bus->wd_timer_valid == true) |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c new file mode 100644 index 000000000000..f6b1822031fe --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c | |||
@@ -0,0 +1,622 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 Broadcom Corporation | ||
3 | * | ||
4 | * Permission to use, copy, modify, and/or distribute this software for any | ||
5 | * purpose with or without fee is hereby granted, provided that the above | ||
6 | * copyright notice and this permission notice appear in all copies. | ||
7 | * | ||
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
15 | */ | ||
16 | /* ***** SDIO interface chip backplane handle functions ***** */ | ||
17 | |||
18 | #include <linux/types.h> | ||
19 | #include <linux/netdevice.h> | ||
20 | #include <linux/mmc/card.h> | ||
21 | #include <linux/ssb/ssb_regs.h> | ||
22 | #include <linux/bcma/bcma.h> | ||
23 | |||
24 | #include <chipcommon.h> | ||
25 | #include <brcm_hw_ids.h> | ||
26 | #include <brcmu_wifi.h> | ||
27 | #include <brcmu_utils.h> | ||
28 | #include <soc.h> | ||
29 | #include "dhd.h" | ||
30 | #include "dhd_dbg.h" | ||
31 | #include "sdio_host.h" | ||
32 | #include "sdio_chip.h" | ||
33 | |||
34 | /* chip core base & ramsize */ | ||
35 | /* bcm4329 */ | ||
36 | /* SDIO device core, ID 0x829 */ | ||
37 | #define BCM4329_CORE_BUS_BASE 0x18011000 | ||
38 | /* internal memory core, ID 0x80e */ | ||
39 | #define BCM4329_CORE_SOCRAM_BASE 0x18003000 | ||
40 | /* ARM Cortex M3 core, ID 0x82a */ | ||
41 | #define BCM4329_CORE_ARM_BASE 0x18002000 | ||
42 | #define BCM4329_RAMSIZE 0x48000 | ||
43 | |||
44 | #define SBCOREREV(sbidh) \ | ||
45 | ((((sbidh) & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT) | \ | ||
46 | ((sbidh) & SSB_IDHIGH_RCLO)) | ||
47 | |||
48 | /* SOC Interconnect types (aka chip types) */ | ||
49 | #define SOCI_SB 0 | ||
50 | #define SOCI_AI 1 | ||
51 | |||
52 | /* EROM CompIdentB */ | ||
53 | #define CIB_REV_MASK 0xff000000 | ||
54 | #define CIB_REV_SHIFT 24 | ||
55 | |||
56 | #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) | ||
57 | /* SDIO Pad drive strength to select value mappings */ | ||
58 | struct sdiod_drive_str { | ||
59 | u8 strength; /* Pad Drive Strength in mA */ | ||
60 | u8 sel; /* Chip-specific select value */ | ||
61 | }; | ||
62 | /* SDIO Drive Strength to sel value table for PMU Rev 1 */ | ||
63 | static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { | ||
64 | { | ||
65 | 4, 0x2}, { | ||
66 | 2, 0x3}, { | ||
67 | 1, 0x0}, { | ||
68 | 0, 0x0} | ||
69 | }; | ||
70 | /* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ | ||
71 | static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { | ||
72 | { | ||
73 | 12, 0x7}, { | ||
74 | 10, 0x6}, { | ||
75 | 8, 0x5}, { | ||
76 | 6, 0x4}, { | ||
77 | 4, 0x2}, { | ||
78 | 2, 0x1}, { | ||
79 | 0, 0x0} | ||
80 | }; | ||
81 | /* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ | ||
82 | static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { | ||
83 | { | ||
84 | 32, 0x7}, { | ||
85 | 26, 0x6}, { | ||
86 | 22, 0x5}, { | ||
87 | 16, 0x4}, { | ||
88 | 12, 0x3}, { | ||
89 | 8, 0x2}, { | ||
90 | 4, 0x1}, { | ||
91 | 0, 0x0} | ||
92 | }; | ||
93 | |||
94 | u8 | ||
95 | brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid) | ||
96 | { | ||
97 | u8 idx; | ||
98 | |||
99 | for (idx = 0; idx < BRCMF_MAX_CORENUM; idx++) | ||
100 | if (coreid == ci->c_inf[idx].id) | ||
101 | return idx; | ||
102 | |||
103 | return BRCMF_MAX_CORENUM; | ||
104 | } | ||
105 | |||
106 | static u32 | ||
107 | brcmf_sdio_sb_corerev(struct brcmf_sdio_dev *sdiodev, | ||
108 | struct chip_info *ci, u16 coreid) | ||
109 | { | ||
110 | u32 regdata; | ||
111 | u8 idx; | ||
112 | |||
113 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
114 | |||
115 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
116 | CORE_SB(ci->c_inf[idx].base, sbidhigh), 4); | ||
117 | return SBCOREREV(regdata); | ||
118 | } | ||
119 | |||
120 | static u32 | ||
121 | brcmf_sdio_ai_corerev(struct brcmf_sdio_dev *sdiodev, | ||
122 | struct chip_info *ci, u16 coreid) | ||
123 | { | ||
124 | u8 idx; | ||
125 | |||
126 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
127 | |||
128 | return (ci->c_inf[idx].cib & CIB_REV_MASK) >> CIB_REV_SHIFT; | ||
129 | } | ||
130 | |||
131 | static bool | ||
132 | brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev, | ||
133 | struct chip_info *ci, u16 coreid) | ||
134 | { | ||
135 | u32 regdata; | ||
136 | u8 idx; | ||
137 | |||
138 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
139 | |||
140 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
141 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
142 | regdata &= (SSB_TMSLOW_RESET | SSB_TMSLOW_REJECT | | ||
143 | SSB_IMSTATE_REJECT | SSB_TMSLOW_CLOCK); | ||
144 | return (SSB_TMSLOW_CLOCK == regdata); | ||
145 | } | ||
146 | |||
147 | static bool | ||
148 | brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev, | ||
149 | struct chip_info *ci, u16 coreid) | ||
150 | { | ||
151 | u32 regdata; | ||
152 | u8 idx; | ||
153 | bool ret; | ||
154 | |||
155 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
156 | |||
157 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
158 | ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); | ||
159 | ret = (regdata & (BCMA_IOCTL_FGC | BCMA_IOCTL_CLK)) == BCMA_IOCTL_CLK; | ||
160 | |||
161 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
162 | ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, | ||
163 | 4); | ||
164 | ret = ret && ((regdata & BCMA_RESET_CTL_RESET) == 0); | ||
165 | |||
166 | return ret; | ||
167 | } | ||
168 | |||
169 | static void | ||
170 | brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev, | ||
171 | struct chip_info *ci, u16 coreid) | ||
172 | { | ||
173 | u32 regdata; | ||
174 | u8 idx; | ||
175 | |||
176 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
177 | |||
178 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
179 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
180 | if (regdata & SSB_TMSLOW_RESET) | ||
181 | return; | ||
182 | |||
183 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
184 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
185 | if ((regdata & SSB_TMSLOW_CLOCK) != 0) { | ||
186 | /* | ||
187 | * set target reject and spin until busy is clear | ||
188 | * (preserve core-specific bits) | ||
189 | */ | ||
190 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
191 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
192 | brcmf_sdcard_reg_write(sdiodev, | ||
193 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), | ||
194 | 4, regdata | SSB_TMSLOW_REJECT); | ||
195 | |||
196 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
197 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
198 | udelay(1); | ||
199 | SPINWAIT((brcmf_sdcard_reg_read(sdiodev, | ||
200 | CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4) & | ||
201 | SSB_TMSHIGH_BUSY), 100000); | ||
202 | |||
203 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
204 | CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4); | ||
205 | if (regdata & SSB_TMSHIGH_BUSY) | ||
206 | brcmf_dbg(ERROR, "core state still busy\n"); | ||
207 | |||
208 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
209 | CORE_SB(ci->c_inf[idx].base, sbidlow), 4); | ||
210 | if (regdata & SSB_IDLOW_INITIATOR) { | ||
211 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
212 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4) | | ||
213 | SSB_IMSTATE_REJECT; | ||
214 | brcmf_sdcard_reg_write(sdiodev, | ||
215 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4, | ||
216 | regdata); | ||
217 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
218 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4); | ||
219 | udelay(1); | ||
220 | SPINWAIT((brcmf_sdcard_reg_read(sdiodev, | ||
221 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4) & | ||
222 | SSB_IMSTATE_BUSY), 100000); | ||
223 | } | ||
224 | |||
225 | /* set reset and reject while enabling the clocks */ | ||
226 | brcmf_sdcard_reg_write(sdiodev, | ||
227 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, | ||
228 | (SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | | ||
229 | SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); | ||
230 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
231 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
232 | udelay(10); | ||
233 | |||
234 | /* clear the initiator reject bit */ | ||
235 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
236 | CORE_SB(ci->c_inf[idx].base, sbidlow), 4); | ||
237 | if (regdata & SSB_IDLOW_INITIATOR) { | ||
238 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
239 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4) & | ||
240 | ~SSB_IMSTATE_REJECT; | ||
241 | brcmf_sdcard_reg_write(sdiodev, | ||
242 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4, | ||
243 | regdata); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | /* leave reset and reject asserted */ | ||
248 | brcmf_sdcard_reg_write(sdiodev, | ||
249 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, | ||
250 | (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); | ||
251 | udelay(1); | ||
252 | } | ||
253 | |||
254 | static void | ||
255 | brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev, | ||
256 | struct chip_info *ci, u16 coreid) | ||
257 | { | ||
258 | u8 idx; | ||
259 | u32 regdata; | ||
260 | |||
261 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
262 | |||
263 | /* if core is already in reset, just return */ | ||
264 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
265 | ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, | ||
266 | 4); | ||
267 | if ((regdata & BCMA_RESET_CTL_RESET) != 0) | ||
268 | return; | ||
269 | |||
270 | brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, | ||
271 | 4, 0); | ||
272 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
273 | ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); | ||
274 | udelay(10); | ||
275 | |||
276 | brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, | ||
277 | 4, BCMA_RESET_CTL_RESET); | ||
278 | udelay(1); | ||
279 | } | ||
280 | |||
281 | static void | ||
282 | brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev, | ||
283 | struct chip_info *ci, u16 coreid) | ||
284 | { | ||
285 | u32 regdata; | ||
286 | u8 idx; | ||
287 | |||
288 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
289 | |||
290 | /* | ||
291 | * Must do the disable sequence first to work for | ||
292 | * arbitrary current core state. | ||
293 | */ | ||
294 | brcmf_sdio_sb_coredisable(sdiodev, ci, coreid); | ||
295 | |||
296 | /* | ||
297 | * Now do the initialization sequence. | ||
298 | * set reset while enabling the clock and | ||
299 | * forcing them on throughout the core | ||
300 | */ | ||
301 | brcmf_sdcard_reg_write(sdiodev, | ||
302 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, | ||
303 | SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET); | ||
304 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
305 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
306 | udelay(1); | ||
307 | |||
308 | /* clear any serror */ | ||
309 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
310 | CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4); | ||
311 | if (regdata & SSB_TMSHIGH_SERR) | ||
312 | brcmf_sdcard_reg_write(sdiodev, | ||
313 | CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4, 0); | ||
314 | |||
315 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
316 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4); | ||
317 | if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO)) | ||
318 | brcmf_sdcard_reg_write(sdiodev, | ||
319 | CORE_SB(ci->c_inf[idx].base, sbimstate), 4, | ||
320 | regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO)); | ||
321 | |||
322 | /* clear reset and allow it to propagate throughout the core */ | ||
323 | brcmf_sdcard_reg_write(sdiodev, | ||
324 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, | ||
325 | SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK); | ||
326 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
327 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
328 | udelay(1); | ||
329 | |||
330 | /* leave clock enabled */ | ||
331 | brcmf_sdcard_reg_write(sdiodev, | ||
332 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), | ||
333 | 4, SSB_TMSLOW_CLOCK); | ||
334 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
335 | CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); | ||
336 | udelay(1); | ||
337 | } | ||
338 | |||
339 | static void | ||
340 | brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev, | ||
341 | struct chip_info *ci, u16 coreid) | ||
342 | { | ||
343 | u8 idx; | ||
344 | u32 regdata; | ||
345 | |||
346 | idx = brcmf_sdio_chip_getinfidx(ci, coreid); | ||
347 | |||
348 | /* must disable first to work for arbitrary current core state */ | ||
349 | brcmf_sdio_ai_coredisable(sdiodev, ci, coreid); | ||
350 | |||
351 | /* now do initialization sequence */ | ||
352 | brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, | ||
353 | 4, BCMA_IOCTL_FGC | BCMA_IOCTL_CLK); | ||
354 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
355 | ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); | ||
356 | brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, | ||
357 | 4, 0); | ||
358 | udelay(1); | ||
359 | |||
360 | brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, | ||
361 | 4, BCMA_IOCTL_CLK); | ||
362 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
363 | ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); | ||
364 | udelay(1); | ||
365 | } | ||
366 | |||
367 | static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, | ||
368 | struct chip_info *ci, u32 regs) | ||
369 | { | ||
370 | u32 regdata; | ||
371 | |||
372 | /* | ||
373 | * Get CC core rev | ||
374 | * Chipid is assume to be at offset 0 from regs arg | ||
375 | * For different chiptypes or old sdio hosts w/o chipcommon, | ||
376 | * other ways of recognition should be added here. | ||
377 | */ | ||
378 | ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON; | ||
379 | ci->c_inf[0].base = regs; | ||
380 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
381 | CORE_CC_REG(ci->c_inf[0].base, chipid), 4); | ||
382 | ci->chip = regdata & CID_ID_MASK; | ||
383 | ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; | ||
384 | ci->socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT; | ||
385 | |||
386 | brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); | ||
387 | |||
388 | /* Address of cores for new chips should be added here */ | ||
389 | switch (ci->chip) { | ||
390 | case BCM4329_CHIP_ID: | ||
391 | ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; | ||
392 | ci->c_inf[1].base = BCM4329_CORE_BUS_BASE; | ||
393 | ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; | ||
394 | ci->c_inf[2].base = BCM4329_CORE_SOCRAM_BASE; | ||
395 | ci->c_inf[3].id = BCMA_CORE_ARM_CM3; | ||
396 | ci->c_inf[3].base = BCM4329_CORE_ARM_BASE; | ||
397 | ci->ramsize = BCM4329_RAMSIZE; | ||
398 | break; | ||
399 | default: | ||
400 | brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); | ||
401 | return -ENODEV; | ||
402 | } | ||
403 | |||
404 | switch (ci->socitype) { | ||
405 | case SOCI_SB: | ||
406 | ci->iscoreup = brcmf_sdio_sb_iscoreup; | ||
407 | ci->corerev = brcmf_sdio_sb_corerev; | ||
408 | ci->coredisable = brcmf_sdio_sb_coredisable; | ||
409 | ci->resetcore = brcmf_sdio_sb_resetcore; | ||
410 | break; | ||
411 | case SOCI_AI: | ||
412 | ci->iscoreup = brcmf_sdio_ai_iscoreup; | ||
413 | ci->corerev = brcmf_sdio_ai_corerev; | ||
414 | ci->coredisable = brcmf_sdio_ai_coredisable; | ||
415 | ci->resetcore = brcmf_sdio_ai_resetcore; | ||
416 | break; | ||
417 | default: | ||
418 | brcmf_dbg(ERROR, "socitype %u not supported\n", ci->socitype); | ||
419 | return -ENODEV; | ||
420 | } | ||
421 | |||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | static int | ||
426 | brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) | ||
427 | { | ||
428 | int err = 0; | ||
429 | u8 clkval, clkset; | ||
430 | |||
431 | /* Try forcing SDIO core to do ALPAvail request only */ | ||
432 | clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; | ||
433 | brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, | ||
434 | SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); | ||
435 | if (err) { | ||
436 | brcmf_dbg(ERROR, "error writing for HT off\n"); | ||
437 | return err; | ||
438 | } | ||
439 | |||
440 | /* If register supported, wait for ALPAvail and then force ALP */ | ||
441 | /* This may take up to 15 milliseconds */ | ||
442 | clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, | ||
443 | SBSDIO_FUNC1_CHIPCLKCSR, NULL); | ||
444 | |||
445 | if ((clkval & ~SBSDIO_AVBITS) != clkset) { | ||
446 | brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", | ||
447 | clkset, clkval); | ||
448 | return -EACCES; | ||
449 | } | ||
450 | |||
451 | SPINWAIT(((clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, | ||
452 | SBSDIO_FUNC1_CHIPCLKCSR, NULL)), | ||
453 | !SBSDIO_ALPAV(clkval)), | ||
454 | PMU_MAX_TRANSITION_DLY); | ||
455 | if (!SBSDIO_ALPAV(clkval)) { | ||
456 | brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", | ||
457 | clkval); | ||
458 | return -EBUSY; | ||
459 | } | ||
460 | |||
461 | clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_FORCE_ALP; | ||
462 | brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, | ||
463 | SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); | ||
464 | udelay(65); | ||
465 | |||
466 | /* Also, disable the extra SDIO pull-ups */ | ||
467 | brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, | ||
468 | SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); | ||
469 | |||
470 | return 0; | ||
471 | } | ||
472 | |||
473 | static void | ||
474 | brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, | ||
475 | struct chip_info *ci) | ||
476 | { | ||
477 | /* get chipcommon rev */ | ||
478 | ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id); | ||
479 | |||
480 | /* get chipcommon capabilites */ | ||
481 | ci->c_inf[0].caps = | ||
482 | brcmf_sdcard_reg_read(sdiodev, | ||
483 | CORE_CC_REG(ci->c_inf[0].base, capabilities), 4); | ||
484 | |||
485 | /* get pmu caps & rev */ | ||
486 | if (ci->c_inf[0].caps & CC_CAP_PMU) { | ||
487 | ci->pmucaps = brcmf_sdcard_reg_read(sdiodev, | ||
488 | CORE_CC_REG(ci->c_inf[0].base, pmucapabilities), 4); | ||
489 | ci->pmurev = ci->pmucaps & PCAP_REV_MASK; | ||
490 | } | ||
491 | |||
492 | ci->c_inf[1].rev = ci->corerev(sdiodev, ci, ci->c_inf[1].id); | ||
493 | |||
494 | brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", | ||
495 | ci->c_inf[0].rev, ci->pmurev, | ||
496 | ci->c_inf[1].rev, ci->c_inf[1].id); | ||
497 | |||
498 | /* | ||
499 | * Make sure any on-chip ARM is off (in case strapping is wrong), | ||
500 | * or downloaded code was already running. | ||
501 | */ | ||
502 | ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3); | ||
503 | } | ||
504 | |||
505 | int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, | ||
506 | struct chip_info **ci_ptr, u32 regs) | ||
507 | { | ||
508 | int ret; | ||
509 | struct chip_info *ci; | ||
510 | |||
511 | brcmf_dbg(TRACE, "Enter\n"); | ||
512 | |||
513 | /* alloc chip_info_t */ | ||
514 | ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); | ||
515 | if (!ci) | ||
516 | return -ENOMEM; | ||
517 | |||
518 | ret = brcmf_sdio_chip_buscoreprep(sdiodev); | ||
519 | if (ret != 0) | ||
520 | goto err; | ||
521 | |||
522 | ret = brcmf_sdio_chip_recognition(sdiodev, ci, regs); | ||
523 | if (ret != 0) | ||
524 | goto err; | ||
525 | |||
526 | brcmf_sdio_chip_buscoresetup(sdiodev, ci); | ||
527 | |||
528 | brcmf_sdcard_reg_write(sdiodev, | ||
529 | CORE_CC_REG(ci->c_inf[0].base, gpiopullup), 4, 0); | ||
530 | brcmf_sdcard_reg_write(sdiodev, | ||
531 | CORE_CC_REG(ci->c_inf[0].base, gpiopulldown), 4, 0); | ||
532 | |||
533 | *ci_ptr = ci; | ||
534 | return 0; | ||
535 | |||
536 | err: | ||
537 | kfree(ci); | ||
538 | return ret; | ||
539 | } | ||
540 | |||
541 | void | ||
542 | brcmf_sdio_chip_detach(struct chip_info **ci_ptr) | ||
543 | { | ||
544 | brcmf_dbg(TRACE, "Enter\n"); | ||
545 | |||
546 | kfree(*ci_ptr); | ||
547 | *ci_ptr = NULL; | ||
548 | } | ||
549 | |||
550 | static char *brcmf_sdio_chip_name(uint chipid, char *buf, uint len) | ||
551 | { | ||
552 | const char *fmt; | ||
553 | |||
554 | fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; | ||
555 | snprintf(buf, len, fmt, chipid); | ||
556 | return buf; | ||
557 | } | ||
558 | |||
559 | void | ||
560 | brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, | ||
561 | struct chip_info *ci, u32 drivestrength) | ||
562 | { | ||
563 | struct sdiod_drive_str *str_tab = NULL; | ||
564 | u32 str_mask = 0; | ||
565 | u32 str_shift = 0; | ||
566 | char chn[8]; | ||
567 | |||
568 | if (!(ci->c_inf[0].caps & CC_CAP_PMU)) | ||
569 | return; | ||
570 | |||
571 | switch (SDIOD_DRVSTR_KEY(ci->chip, ci->pmurev)) { | ||
572 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): | ||
573 | str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; | ||
574 | str_mask = 0x30000000; | ||
575 | str_shift = 28; | ||
576 | break; | ||
577 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): | ||
578 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): | ||
579 | str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; | ||
580 | str_mask = 0x00003800; | ||
581 | str_shift = 11; | ||
582 | break; | ||
583 | case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): | ||
584 | str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; | ||
585 | str_mask = 0x00003800; | ||
586 | str_shift = 11; | ||
587 | break; | ||
588 | default: | ||
589 | brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", | ||
590 | brcmf_sdio_chip_name(ci->chip, chn, 8), | ||
591 | ci->chiprev, ci->pmurev); | ||
592 | break; | ||
593 | } | ||
594 | |||
595 | if (str_tab != NULL) { | ||
596 | u32 drivestrength_sel = 0; | ||
597 | u32 cc_data_temp; | ||
598 | int i; | ||
599 | |||
600 | for (i = 0; str_tab[i].strength != 0; i++) { | ||
601 | if (drivestrength >= str_tab[i].strength) { | ||
602 | drivestrength_sel = str_tab[i].sel; | ||
603 | break; | ||
604 | } | ||
605 | } | ||
606 | |||
607 | brcmf_sdcard_reg_write(sdiodev, | ||
608 | CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), | ||
609 | 4, 1); | ||
610 | cc_data_temp = brcmf_sdcard_reg_read(sdiodev, | ||
611 | CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 4); | ||
612 | cc_data_temp &= ~str_mask; | ||
613 | drivestrength_sel <<= str_shift; | ||
614 | cc_data_temp |= drivestrength_sel; | ||
615 | brcmf_sdcard_reg_write(sdiodev, | ||
616 | CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), | ||
617 | 4, cc_data_temp); | ||
618 | |||
619 | brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", | ||
620 | drivestrength, cc_data_temp); | ||
621 | } | ||
622 | } | ||
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h new file mode 100644 index 000000000000..ce974d76bd92 --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h | |||
@@ -0,0 +1,136 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 Broadcom Corporation | ||
3 | * | ||
4 | * Permission to use, copy, modify, and/or distribute this software for any | ||
5 | * purpose with or without fee is hereby granted, provided that the above | ||
6 | * copyright notice and this permission notice appear in all copies. | ||
7 | * | ||
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
15 | */ | ||
16 | |||
17 | #ifndef _BRCMFMAC_SDIO_CHIP_H_ | ||
18 | #define _BRCMFMAC_SDIO_CHIP_H_ | ||
19 | |||
20 | /* | ||
21 | * Core reg address translation. | ||
22 | * Both macro's returns a 32 bits byte address on the backplane bus. | ||
23 | */ | ||
24 | #define CORE_CC_REG(base, field) \ | ||
25 | (base + offsetof(struct chipcregs, field)) | ||
26 | #define CORE_BUS_REG(base, field) \ | ||
27 | (base + offsetof(struct sdpcmd_regs, field)) | ||
28 | #define CORE_SB(base, field) \ | ||
29 | (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) | ||
30 | |||
31 | /* SDIO function 1 register CHIPCLKCSR */ | ||
32 | /* Force ALP request to backplane */ | ||
33 | #define SBSDIO_FORCE_ALP 0x01 | ||
34 | /* Force HT request to backplane */ | ||
35 | #define SBSDIO_FORCE_HT 0x02 | ||
36 | /* Force ILP request to backplane */ | ||
37 | #define SBSDIO_FORCE_ILP 0x04 | ||
38 | /* Make ALP ready (power up xtal) */ | ||
39 | #define SBSDIO_ALP_AVAIL_REQ 0x08 | ||
40 | /* Make HT ready (power up PLL) */ | ||
41 | #define SBSDIO_HT_AVAIL_REQ 0x10 | ||
42 | /* Squelch clock requests from HW */ | ||
43 | #define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 | ||
44 | /* Status: ALP is ready */ | ||
45 | #define SBSDIO_ALP_AVAIL 0x40 | ||
46 | /* Status: HT is ready */ | ||
47 | #define SBSDIO_HT_AVAIL 0x80 | ||
48 | #define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) | ||
49 | #define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) | ||
50 | #define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) | ||
51 | #define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) | ||
52 | #define SBSDIO_CLKAV(regval, alponly) \ | ||
53 | (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) | ||
54 | |||
55 | #define BRCMF_MAX_CORENUM 6 | ||
56 | |||
57 | struct chip_core_info { | ||
58 | u16 id; | ||
59 | u16 rev; | ||
60 | u32 base; | ||
61 | u32 wrapbase; | ||
62 | u32 caps; | ||
63 | u32 cib; | ||
64 | }; | ||
65 | |||
66 | struct chip_info { | ||
67 | u32 chip; | ||
68 | u32 chiprev; | ||
69 | u32 socitype; | ||
70 | /* core info */ | ||
71 | /* always put chipcommon core at 0, bus core at 1 */ | ||
72 | struct chip_core_info c_inf[BRCMF_MAX_CORENUM]; | ||
73 | u32 pmurev; | ||
74 | u32 pmucaps; | ||
75 | u32 ramsize; | ||
76 | |||
77 | bool (*iscoreup)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, | ||
78 | u16 coreid); | ||
79 | u32 (*corerev)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, | ||
80 | u16 coreid); | ||
81 | void (*coredisable)(struct brcmf_sdio_dev *sdiodev, | ||
82 | struct chip_info *ci, u16 coreid); | ||
83 | void (*resetcore)(struct brcmf_sdio_dev *sdiodev, | ||
84 | struct chip_info *ci, u16 coreid); | ||
85 | }; | ||
86 | |||
87 | struct sbconfig { | ||
88 | u32 PAD[2]; | ||
89 | u32 sbipsflag; /* initiator port ocp slave flag */ | ||
90 | u32 PAD[3]; | ||
91 | u32 sbtpsflag; /* target port ocp slave flag */ | ||
92 | u32 PAD[11]; | ||
93 | u32 sbtmerrloga; /* (sonics >= 2.3) */ | ||
94 | u32 PAD; | ||
95 | u32 sbtmerrlog; /* (sonics >= 2.3) */ | ||
96 | u32 PAD[3]; | ||
97 | u32 sbadmatch3; /* address match3 */ | ||
98 | u32 PAD; | ||
99 | u32 sbadmatch2; /* address match2 */ | ||
100 | u32 PAD; | ||
101 | u32 sbadmatch1; /* address match1 */ | ||
102 | u32 PAD[7]; | ||
103 | u32 sbimstate; /* initiator agent state */ | ||
104 | u32 sbintvec; /* interrupt mask */ | ||
105 | u32 sbtmstatelow; /* target state */ | ||
106 | u32 sbtmstatehigh; /* target state */ | ||
107 | u32 sbbwa0; /* bandwidth allocation table0 */ | ||
108 | u32 PAD; | ||
109 | u32 sbimconfiglow; /* initiator configuration */ | ||
110 | u32 sbimconfighigh; /* initiator configuration */ | ||
111 | u32 sbadmatch0; /* address match0 */ | ||
112 | u32 PAD; | ||
113 | u32 sbtmconfiglow; /* target configuration */ | ||
114 | u32 sbtmconfighigh; /* target configuration */ | ||
115 | u32 sbbconfig; /* broadcast configuration */ | ||
116 | u32 PAD; | ||
117 | u32 sbbstate; /* broadcast state */ | ||
118 | u32 PAD[3]; | ||
119 | u32 sbactcnfg; /* activate configuration */ | ||
120 | u32 PAD[3]; | ||
121 | u32 sbflagst; /* current sbflags */ | ||
122 | u32 PAD[3]; | ||
123 | u32 sbidlow; /* identification */ | ||
124 | u32 sbidhigh; /* identification */ | ||
125 | }; | ||
126 | |||
127 | extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, | ||
128 | struct chip_info **ci_ptr, u32 regs); | ||
129 | extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); | ||
130 | extern void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, | ||
131 | struct chip_info *ci, | ||
132 | u32 drivestrength); | ||
133 | extern u8 brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid); | ||
134 | |||
135 | |||
136 | #endif /* _BRCMFMAC_SDIO_CHIP_H_ */ | ||
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 5eddabe5228a..cc19a733ac65 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | |||
@@ -1997,7 +1997,7 @@ done: | |||
1997 | } | 1997 | } |
1998 | 1998 | ||
1999 | static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, | 1999 | static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, |
2000 | struct brcmf_bss_info *bi) | 2000 | struct brcmf_bss_info_le *bi) |
2001 | { | 2001 | { |
2002 | struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); | 2002 | struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); |
2003 | struct ieee80211_channel *notify_channel; | 2003 | struct ieee80211_channel *notify_channel; |
@@ -2049,18 +2049,27 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, | |||
2049 | notify_timestamp, notify_capability, notify_interval, notify_ie, | 2049 | notify_timestamp, notify_capability, notify_interval, notify_ie, |
2050 | notify_ielen, notify_signal, GFP_KERNEL); | 2050 | notify_ielen, notify_signal, GFP_KERNEL); |
2051 | 2051 | ||
2052 | if (!bss) { | 2052 | if (!bss) |
2053 | WL_ERR("cfg80211_inform_bss_frame error\n"); | 2053 | return -ENOMEM; |
2054 | return -EINVAL; | 2054 | |
2055 | } | 2055 | cfg80211_put_bss(bss); |
2056 | 2056 | ||
2057 | return err; | 2057 | return err; |
2058 | } | 2058 | } |
2059 | 2059 | ||
2060 | static struct brcmf_bss_info_le * | ||
2061 | next_bss_le(struct brcmf_scan_results *list, struct brcmf_bss_info_le *bss) | ||
2062 | { | ||
2063 | if (bss == NULL) | ||
2064 | return list->bss_info_le; | ||
2065 | return (struct brcmf_bss_info_le *)((unsigned long)bss + | ||
2066 | le32_to_cpu(bss->length)); | ||
2067 | } | ||
2068 | |||
2060 | static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) | 2069 | static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) |
2061 | { | 2070 | { |
2062 | struct brcmf_scan_results *bss_list; | 2071 | struct brcmf_scan_results *bss_list; |
2063 | struct brcmf_bss_info *bi = NULL; /* must be initialized */ | 2072 | struct brcmf_bss_info_le *bi = NULL; /* must be initialized */ |
2064 | s32 err = 0; | 2073 | s32 err = 0; |
2065 | int i; | 2074 | int i; |
2066 | 2075 | ||
@@ -2072,7 +2081,7 @@ static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) | |||
2072 | } | 2081 | } |
2073 | WL_SCAN("scanned AP count (%d)\n", bss_list->count); | 2082 | WL_SCAN("scanned AP count (%d)\n", bss_list->count); |
2074 | for (i = 0; i < bss_list->count && i < WL_AP_MAX; i++) { | 2083 | for (i = 0; i < bss_list->count && i < WL_AP_MAX; i++) { |
2075 | bi = next_bss(bss_list, bi); | 2084 | bi = next_bss_le(bss_list, bi); |
2076 | err = brcmf_inform_single_bss(cfg_priv, bi); | 2085 | err = brcmf_inform_single_bss(cfg_priv, bi); |
2077 | if (err) | 2086 | if (err) |
2078 | break; | 2087 | break; |
@@ -2085,8 +2094,9 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, | |||
2085 | { | 2094 | { |
2086 | struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); | 2095 | struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); |
2087 | struct ieee80211_channel *notify_channel; | 2096 | struct ieee80211_channel *notify_channel; |
2088 | struct brcmf_bss_info *bi = NULL; | 2097 | struct brcmf_bss_info_le *bi = NULL; |
2089 | struct ieee80211_supported_band *band; | 2098 | struct ieee80211_supported_band *band; |
2099 | struct cfg80211_bss *bss; | ||
2090 | u8 *buf = NULL; | 2100 | u8 *buf = NULL; |
2091 | s32 err = 0; | 2101 | s32 err = 0; |
2092 | u16 channel; | 2102 | u16 channel; |
@@ -2114,7 +2124,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, | |||
2114 | goto CleanUp; | 2124 | goto CleanUp; |
2115 | } | 2125 | } |
2116 | 2126 | ||
2117 | bi = (struct brcmf_bss_info *)(buf + 4); | 2127 | bi = (struct brcmf_bss_info_le *)(buf + 4); |
2118 | 2128 | ||
2119 | channel = bi->ctl_ch ? bi->ctl_ch : | 2129 | channel = bi->ctl_ch ? bi->ctl_ch : |
2120 | CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); | 2130 | CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); |
@@ -2140,10 +2150,17 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, | |||
2140 | WL_CONN("signal: %d\n", notify_signal); | 2150 | WL_CONN("signal: %d\n", notify_signal); |
2141 | WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); | 2151 | WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); |
2142 | 2152 | ||
2143 | cfg80211_inform_bss(wiphy, notify_channel, bssid, | 2153 | bss = cfg80211_inform_bss(wiphy, notify_channel, bssid, |
2144 | notify_timestamp, notify_capability, notify_interval, | 2154 | notify_timestamp, notify_capability, notify_interval, |
2145 | notify_ie, notify_ielen, notify_signal, GFP_KERNEL); | 2155 | notify_ie, notify_ielen, notify_signal, GFP_KERNEL); |
2146 | 2156 | ||
2157 | if (!bss) { | ||
2158 | err = -ENOMEM; | ||
2159 | goto CleanUp; | ||
2160 | } | ||
2161 | |||
2162 | cfg80211_put_bss(bss); | ||
2163 | |||
2147 | CleanUp: | 2164 | CleanUp: |
2148 | 2165 | ||
2149 | kfree(buf); | 2166 | kfree(buf); |
@@ -2188,7 +2205,7 @@ static struct brcmf_tlv *brcmf_parse_tlvs(void *buf, int buflen, uint key) | |||
2188 | 2205 | ||
2189 | static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) | 2206 | static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) |
2190 | { | 2207 | { |
2191 | struct brcmf_bss_info *bi; | 2208 | struct brcmf_bss_info_le *bi; |
2192 | struct brcmf_ssid *ssid; | 2209 | struct brcmf_ssid *ssid; |
2193 | struct brcmf_tlv *tim; | 2210 | struct brcmf_tlv *tim; |
2194 | u16 beacon_interval; | 2211 | u16 beacon_interval; |
@@ -2211,7 +2228,7 @@ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) | |||
2211 | goto update_bss_info_out; | 2228 | goto update_bss_info_out; |
2212 | } | 2229 | } |
2213 | 2230 | ||
2214 | bi = (struct brcmf_bss_info *)(cfg_priv->extra_buf + 4); | 2231 | bi = (struct brcmf_bss_info_le *)(cfg_priv->extra_buf + 4); |
2215 | err = brcmf_inform_single_bss(cfg_priv, bi); | 2232 | err = brcmf_inform_single_bss(cfg_priv, bi); |
2216 | if (err) | 2233 | if (err) |
2217 | goto update_bss_info_out; | 2234 | goto update_bss_info_out; |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h index 62dc46144ede..a613b49cb13f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h | |||
@@ -352,15 +352,6 @@ brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_priv *cfg) | |||
352 | return &cfg->conn_info; | 352 | return &cfg->conn_info; |
353 | } | 353 | } |
354 | 354 | ||
355 | static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, | ||
356 | struct brcmf_bss_info *bss) | ||
357 | { | ||
358 | return bss = bss ? | ||
359 | (struct brcmf_bss_info *)((unsigned long)bss + | ||
360 | le32_to_cpu(bss->length)) : | ||
361 | list->bss_info; | ||
362 | } | ||
363 | |||
364 | extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, | 355 | extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, |
365 | struct device *busdev, | 356 | struct device *busdev, |
366 | void *data); | 357 | void *data); |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 106a7424a7cd..b51d1e421e24 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | |||
@@ -38,88 +38,12 @@ | |||
38 | /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ | 38 | /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ |
39 | #define SI_PCIE_DMA_H32 0x80000000 | 39 | #define SI_PCIE_DMA_H32 0x80000000 |
40 | 40 | ||
41 | /* core codes */ | ||
42 | #define NODEV_CORE_ID 0x700 /* Invalid coreid */ | ||
43 | #define CC_CORE_ID 0x800 /* chipcommon core */ | ||
44 | #define ILINE20_CORE_ID 0x801 /* iline20 core */ | ||
45 | #define SRAM_CORE_ID 0x802 /* sram core */ | ||
46 | #define SDRAM_CORE_ID 0x803 /* sdram core */ | ||
47 | #define PCI_CORE_ID 0x804 /* pci core */ | ||
48 | #define MIPS_CORE_ID 0x805 /* mips core */ | ||
49 | #define ENET_CORE_ID 0x806 /* enet mac core */ | ||
50 | #define CODEC_CORE_ID 0x807 /* v90 codec core */ | ||
51 | #define USB_CORE_ID 0x808 /* usb 1.1 host/device core */ | ||
52 | #define ADSL_CORE_ID 0x809 /* ADSL core */ | ||
53 | #define ILINE100_CORE_ID 0x80a /* iline100 core */ | ||
54 | #define IPSEC_CORE_ID 0x80b /* ipsec core */ | ||
55 | #define UTOPIA_CORE_ID 0x80c /* utopia core */ | ||
56 | #define PCMCIA_CORE_ID 0x80d /* pcmcia core */ | ||
57 | #define SOCRAM_CORE_ID 0x80e /* internal memory core */ | ||
58 | #define MEMC_CORE_ID 0x80f /* memc sdram core */ | ||
59 | #define OFDM_CORE_ID 0x810 /* OFDM phy core */ | ||
60 | #define EXTIF_CORE_ID 0x811 /* external interface core */ | ||
61 | #define D11_CORE_ID 0x812 /* 802.11 MAC core */ | ||
62 | #define APHY_CORE_ID 0x813 /* 802.11a phy core */ | ||
63 | #define BPHY_CORE_ID 0x814 /* 802.11b phy core */ | ||
64 | #define GPHY_CORE_ID 0x815 /* 802.11g phy core */ | ||
65 | #define MIPS33_CORE_ID 0x816 /* mips3302 core */ | ||
66 | #define USB11H_CORE_ID 0x817 /* usb 1.1 host core */ | ||
67 | #define USB11D_CORE_ID 0x818 /* usb 1.1 device core */ | ||
68 | #define USB20H_CORE_ID 0x819 /* usb 2.0 host core */ | ||
69 | #define USB20D_CORE_ID 0x81a /* usb 2.0 device core */ | ||
70 | #define SDIOH_CORE_ID 0x81b /* sdio host core */ | ||
71 | #define ROBO_CORE_ID 0x81c /* roboswitch core */ | ||
72 | #define ATA100_CORE_ID 0x81d /* parallel ATA core */ | ||
73 | #define SATAXOR_CORE_ID 0x81e /* serial ATA & XOR DMA core */ | ||
74 | #define GIGETH_CORE_ID 0x81f /* gigabit ethernet core */ | ||
75 | #define PCIE_CORE_ID 0x820 /* pci express core */ | ||
76 | #define NPHY_CORE_ID 0x821 /* 802.11n 2x2 phy core */ | ||
77 | #define SRAMC_CORE_ID 0x822 /* SRAM controller core */ | ||
78 | #define MINIMAC_CORE_ID 0x823 /* MINI MAC/phy core */ | ||
79 | #define ARM11_CORE_ID 0x824 /* ARM 1176 core */ | ||
80 | #define ARM7S_CORE_ID 0x825 /* ARM7tdmi-s core */ | ||
81 | #define LPPHY_CORE_ID 0x826 /* 802.11a/b/g phy core */ | ||
82 | #define PMU_CORE_ID 0x827 /* PMU core */ | ||
83 | #define SSNPHY_CORE_ID 0x828 /* 802.11n single-stream phy core */ | ||
84 | #define SDIOD_CORE_ID 0x829 /* SDIO device core */ | ||
85 | #define ARMCM3_CORE_ID 0x82a /* ARM Cortex M3 core */ | ||
86 | #define HTPHY_CORE_ID 0x82b /* 802.11n 4x4 phy core */ | ||
87 | #define MIPS74K_CORE_ID 0x82c /* mips 74k core */ | ||
88 | #define GMAC_CORE_ID 0x82d /* Gigabit MAC core */ | ||
89 | #define DMEMC_CORE_ID 0x82e /* DDR1/2 memory controller core */ | ||
90 | #define PCIERC_CORE_ID 0x82f /* PCIE Root Complex core */ | ||
91 | #define OCP_CORE_ID 0x830 /* OCP2OCP bridge core */ | ||
92 | #define SC_CORE_ID 0x831 /* shared common core */ | ||
93 | #define AHB_CORE_ID 0x832 /* OCP2AHB bridge core */ | ||
94 | #define SPIH_CORE_ID 0x833 /* SPI host core */ | ||
95 | #define I2S_CORE_ID 0x834 /* I2S core */ | ||
96 | #define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ | ||
97 | #define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ | ||
98 | #define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ | ||
99 | #define DEF_AI_COMP 0xfff /* Default component, in ai chips it | ||
100 | * maps all unused address ranges | ||
101 | */ | ||
102 | |||
103 | /* chipcommon being the first core: */ | 41 | /* chipcommon being the first core: */ |
104 | #define SI_CC_IDX 0 | 42 | #define SI_CC_IDX 0 |
105 | 43 | ||
106 | /* SOC Interconnect types (aka chip types) */ | 44 | /* SOC Interconnect types (aka chip types) */ |
107 | #define SOCI_AI 1 | 45 | #define SOCI_AI 1 |
108 | 46 | ||
109 | /* Common core control flags */ | ||
110 | #define SICF_BIST_EN 0x8000 | ||
111 | #define SICF_PME_EN 0x4000 | ||
112 | #define SICF_CORE_BITS 0x3ffc | ||
113 | #define SICF_FGC 0x0002 | ||
114 | #define SICF_CLOCK_EN 0x0001 | ||
115 | |||
116 | /* Common core status flags */ | ||
117 | #define SISF_BIST_DONE 0x8000 | ||
118 | #define SISF_BIST_ERROR 0x4000 | ||
119 | #define SISF_GATED_CLK 0x2000 | ||
120 | #define SISF_DMA64 0x1000 | ||
121 | #define SISF_CORE_BITS 0x0fff | ||
122 | |||
123 | /* A register that is common to all cores to | 47 | /* A register that is common to all cores to |
124 | * communicate w/PMU regarding clock control. | 48 | * communicate w/PMU regarding clock control. |
125 | */ | 49 | */ |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c index 7f27dbdb6b60..43f7a724dda8 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c | |||
@@ -649,7 +649,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, | |||
649 | len = roundup(len, 4); | 649 | len = roundup(len, 4); |
650 | ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN); | 650 | ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN); |
651 | 651 | ||
652 | dma_len += (u16) brcmu_pkttotlen(p); | 652 | dma_len += (u16) p->len; |
653 | 653 | ||
654 | BCMMSG(wlc->wiphy, "wl%d: ampdu_len %d" | 654 | BCMMSG(wlc->wiphy, "wl%d: ampdu_len %d" |
655 | " seg_cnt %d null delim %d\n", | 655 | " seg_cnt %d null delim %d\n", |
@@ -741,9 +741,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, | |||
741 | if (p) { | 741 | if (p) { |
742 | if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && | 742 | if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && |
743 | ((u8) (p->priority) == tid)) { | 743 | ((u8) (p->priority) == tid)) { |
744 | 744 | plen = p->len + AMPDU_MAX_MPDU_OVERHEAD; | |
745 | plen = brcmu_pkttotlen(p) + | ||
746 | AMPDU_MAX_MPDU_OVERHEAD; | ||
747 | plen = max(scb_ampdu->min_len, plen); | 745 | plen = max(scb_ampdu->min_len, plen); |
748 | 746 | ||
749 | if ((plen + ampdu_len) > max_ampdu_bytes) { | 747 | if ((plen + ampdu_len) > max_ampdu_bytes) { |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c index 89ad1b7dab8f..55e9f45fce22 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c | |||
@@ -1153,121 +1153,6 @@ brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec, | |||
1153 | &txpwr); | 1153 | &txpwr); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | #ifdef POWER_DBG | ||
1157 | static void wlc_phy_txpower_limits_dump(struct txpwr_limits *txpwr) | ||
1158 | { | ||
1159 | int i; | ||
1160 | char buf[80]; | ||
1161 | char fraction[4][4] = { " ", ".25", ".5 ", ".75" }; | ||
1162 | |||
1163 | sprintf(buf, "CCK "); | ||
1164 | for (i = 0; i < BRCMS_NUM_RATES_CCK; i++) | ||
1165 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1166 | txpwr->cck[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1167 | fraction[txpwr->cck[i] % BRCMS_TXPWR_DB_FACTOR]); | ||
1168 | printk(KERN_DEBUG "%s\n", buf); | ||
1169 | |||
1170 | sprintf(buf, "20 MHz OFDM SISO "); | ||
1171 | for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) | ||
1172 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1173 | txpwr->ofdm[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1174 | fraction[txpwr->ofdm[i] % BRCMS_TXPWR_DB_FACTOR]); | ||
1175 | printk(KERN_DEBUG "%s\n", buf); | ||
1176 | |||
1177 | sprintf(buf, "20 MHz OFDM CDD "); | ||
1178 | for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) | ||
1179 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1180 | txpwr->ofdm_cdd[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1181 | fraction[txpwr->ofdm_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); | ||
1182 | printk(KERN_DEBUG "%s\n", buf); | ||
1183 | |||
1184 | sprintf(buf, "40 MHz OFDM SISO "); | ||
1185 | for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) | ||
1186 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1187 | txpwr->ofdm_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1188 | fraction[txpwr->ofdm_40_siso[i] % | ||
1189 | BRCMS_TXPWR_DB_FACTOR]); | ||
1190 | printk(KERN_DEBUG "%s\n", buf); | ||
1191 | |||
1192 | sprintf(buf, "40 MHz OFDM CDD "); | ||
1193 | for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) | ||
1194 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1195 | txpwr->ofdm_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1196 | fraction[txpwr->ofdm_40_cdd[i] % | ||
1197 | BRCMS_TXPWR_DB_FACTOR]); | ||
1198 | printk(KERN_DEBUG "%s\n", buf); | ||
1199 | |||
1200 | sprintf(buf, "20 MHz MCS0-7 SISO "); | ||
1201 | for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) | ||
1202 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1203 | txpwr->mcs_20_siso[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1204 | fraction[txpwr->mcs_20_siso[i] % | ||
1205 | BRCMS_TXPWR_DB_FACTOR]); | ||
1206 | printk(KERN_DEBUG "%s\n", buf); | ||
1207 | |||
1208 | sprintf(buf, "20 MHz MCS0-7 CDD "); | ||
1209 | for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) | ||
1210 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1211 | txpwr->mcs_20_cdd[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1212 | fraction[txpwr->mcs_20_cdd[i] % | ||
1213 | BRCMS_TXPWR_DB_FACTOR]); | ||
1214 | printk(KERN_DEBUG "%s\n", buf); | ||
1215 | |||
1216 | sprintf(buf, "20 MHz MCS0-7 STBC "); | ||
1217 | for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) | ||
1218 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1219 | txpwr->mcs_20_stbc[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1220 | fraction[txpwr->mcs_20_stbc[i] % | ||
1221 | BRCMS_TXPWR_DB_FACTOR]); | ||
1222 | printk(KERN_DEBUG "%s\n", buf); | ||
1223 | |||
1224 | sprintf(buf, "20 MHz MCS8-15 SDM "); | ||
1225 | for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) | ||
1226 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1227 | txpwr->mcs_20_mimo[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1228 | fraction[txpwr->mcs_20_mimo[i] % | ||
1229 | BRCMS_TXPWR_DB_FACTOR]); | ||
1230 | printk(KERN_DEBUG "%s\n", buf); | ||
1231 | |||
1232 | sprintf(buf, "40 MHz MCS0-7 SISO "); | ||
1233 | for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) | ||
1234 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1235 | txpwr->mcs_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1236 | fraction[txpwr->mcs_40_siso[i] % | ||
1237 | BRCMS_TXPWR_DB_FACTOR]); | ||
1238 | printk(KERN_DEBUG "%s\n", buf); | ||
1239 | |||
1240 | sprintf(buf, "40 MHz MCS0-7 CDD "); | ||
1241 | for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) | ||
1242 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1243 | txpwr->mcs_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1244 | fraction[txpwr->mcs_40_cdd[i] % | ||
1245 | BRCMS_TXPWR_DB_FACTOR]); | ||
1246 | printk(KERN_DEBUG "%s\n", buf); | ||
1247 | |||
1248 | sprintf(buf, "40 MHz MCS0-7 STBC "); | ||
1249 | for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) | ||
1250 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1251 | txpwr->mcs_40_stbc[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1252 | fraction[txpwr->mcs_40_stbc[i] % | ||
1253 | BRCMS_TXPWR_DB_FACTOR]); | ||
1254 | printk(KERN_DEBUG "%s\n", buf); | ||
1255 | |||
1256 | sprintf(buf, "40 MHz MCS8-15 SDM "); | ||
1257 | for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) | ||
1258 | sprintf(buf[strlen(buf)], " %2d%s", | ||
1259 | txpwr->mcs_40_mimo[i] / BRCMS_TXPWR_DB_FACTOR, | ||
1260 | fraction[txpwr->mcs_40_mimo[i] % | ||
1261 | BRCMS_TXPWR_DB_FACTOR]); | ||
1262 | } | ||
1263 | printk(KERN_DEBUG "%s\n", buf); | ||
1264 | |||
1265 | printk(KERN_DEBUG "MCS32 %2d%s\n", | ||
1266 | txpwr->mcs32 / BRCMS_TXPWR_DB_FACTOR, | ||
1267 | fraction[txpwr->mcs32 % BRCMS_TXPWR_DB_FACTOR]); | ||
1268 | } | ||
1269 | #endif /* POWER_DBG */ | ||
1270 | |||
1271 | void | 1156 | void |
1272 | brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, | 1157 | brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, |
1273 | struct txpwr_limits *txpwr) | 1158 | struct txpwr_limits *txpwr) |
@@ -1478,9 +1363,6 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, | |||
1478 | txpwr->mcs_40_stbc[i] = txpwr->mcs_40_cdd[i]; | 1363 | txpwr->mcs_40_stbc[i] = txpwr->mcs_40_cdd[i]; |
1479 | } | 1364 | } |
1480 | 1365 | ||
1481 | #ifdef POWER_DBG | ||
1482 | wlc_phy_txpower_limits_dump(txpwr); | ||
1483 | #endif | ||
1484 | return; | 1366 | return; |
1485 | } | 1367 | } |
1486 | 1368 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 6ebec8f42846..e286fb4d4813 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/skbuff.h> | ||
18 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
19 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
20 | 19 | ||
@@ -22,6 +21,7 @@ | |||
22 | #include <aiutils.h> | 21 | #include <aiutils.h> |
23 | #include "types.h" | 22 | #include "types.h" |
24 | #include "dma.h" | 23 | #include "dma.h" |
24 | #include "soc.h" | ||
25 | 25 | ||
26 | /* | 26 | /* |
27 | * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within | 27 | * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within |
@@ -901,7 +901,7 @@ static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) | |||
901 | 901 | ||
902 | /* | 902 | /* |
903 | * !! rx entry routine | 903 | * !! rx entry routine |
904 | * returns a pointer to the next frame received, or NULL if there are no more | 904 | * returns the number packages in the next frame, or 0 if there are no more |
905 | * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is | 905 | * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is |
906 | * supported with pkts chain | 906 | * supported with pkts chain |
907 | * otherwise, it's treated as giant pkt and will be tossed. | 907 | * otherwise, it's treated as giant pkt and will be tossed. |
@@ -909,38 +909,40 @@ static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) | |||
909 | * buffer data. After it reaches the max size of buffer, the data continues | 909 | * buffer data. After it reaches the max size of buffer, the data continues |
910 | * in next DMA descriptor buffer WITHOUT DMA header | 910 | * in next DMA descriptor buffer WITHOUT DMA header |
911 | */ | 911 | */ |
912 | struct sk_buff *dma_rx(struct dma_pub *pub) | 912 | int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list) |
913 | { | 913 | { |
914 | struct dma_info *di = (struct dma_info *)pub; | 914 | struct dma_info *di = (struct dma_info *)pub; |
915 | struct sk_buff *p, *head, *tail; | 915 | struct sk_buff_head dma_frames; |
916 | struct sk_buff *p, *next; | ||
916 | uint len; | 917 | uint len; |
917 | uint pkt_len; | 918 | uint pkt_len; |
918 | int resid = 0; | 919 | int resid = 0; |
920 | int pktcnt = 1; | ||
919 | 921 | ||
922 | skb_queue_head_init(&dma_frames); | ||
920 | next_frame: | 923 | next_frame: |
921 | head = _dma_getnextrxp(di, false); | 924 | p = _dma_getnextrxp(di, false); |
922 | if (head == NULL) | 925 | if (p == NULL) |
923 | return NULL; | 926 | return 0; |
924 | 927 | ||
925 | len = le16_to_cpu(*(__le16 *) (head->data)); | 928 | len = le16_to_cpu(*(__le16 *) (p->data)); |
926 | DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); | 929 | DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); |
927 | dma_spin_for_len(len, head); | 930 | dma_spin_for_len(len, p); |
928 | 931 | ||
929 | /* set actual length */ | 932 | /* set actual length */ |
930 | pkt_len = min((di->rxoffset + len), di->rxbufsize); | 933 | pkt_len = min((di->rxoffset + len), di->rxbufsize); |
931 | __skb_trim(head, pkt_len); | 934 | __skb_trim(p, pkt_len); |
935 | skb_queue_tail(&dma_frames, p); | ||
932 | resid = len - (di->rxbufsize - di->rxoffset); | 936 | resid = len - (di->rxbufsize - di->rxoffset); |
933 | 937 | ||
934 | /* check for single or multi-buffer rx */ | 938 | /* check for single or multi-buffer rx */ |
935 | if (resid > 0) { | 939 | if (resid > 0) { |
936 | tail = head; | ||
937 | while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { | 940 | while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { |
938 | tail->next = p; | ||
939 | pkt_len = min_t(uint, resid, di->rxbufsize); | 941 | pkt_len = min_t(uint, resid, di->rxbufsize); |
940 | __skb_trim(p, pkt_len); | 942 | __skb_trim(p, pkt_len); |
941 | 943 | skb_queue_tail(&dma_frames, p); | |
942 | tail = p; | ||
943 | resid -= di->rxbufsize; | 944 | resid -= di->rxbufsize; |
945 | pktcnt++; | ||
944 | } | 946 | } |
945 | 947 | ||
946 | #ifdef BCMDBG | 948 | #ifdef BCMDBG |
@@ -959,13 +961,18 @@ struct sk_buff *dma_rx(struct dma_pub *pub) | |||
959 | if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { | 961 | if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { |
960 | DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", | 962 | DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", |
961 | di->name, len)); | 963 | di->name, len)); |
962 | brcmu_pkt_buf_free_skb(head); | 964 | skb_queue_walk_safe(&dma_frames, p, next) { |
965 | skb_unlink(p, &dma_frames); | ||
966 | brcmu_pkt_buf_free_skb(p); | ||
967 | } | ||
963 | di->dma.rxgiants++; | 968 | di->dma.rxgiants++; |
969 | pktcnt = 1; | ||
964 | goto next_frame; | 970 | goto next_frame; |
965 | } | 971 | } |
966 | } | 972 | } |
967 | 973 | ||
968 | return head; | 974 | skb_queue_splice_tail(&dma_frames, skb_list); |
975 | return pktcnt; | ||
969 | } | 976 | } |
970 | 977 | ||
971 | static bool dma64_rxidle(struct dma_info *di) | 978 | static bool dma64_rxidle(struct dma_info *di) |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.h b/drivers/net/wireless/brcm80211/brcmsmac/dma.h index ebc5bc546f3b..d317c7c12f91 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.h | |||
@@ -18,6 +18,7 @@ | |||
18 | #define _BRCM_DMA_H_ | 18 | #define _BRCM_DMA_H_ |
19 | 19 | ||
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/skbuff.h> | ||
21 | #include "types.h" /* forward structure declarations */ | 22 | #include "types.h" /* forward structure declarations */ |
22 | 23 | ||
23 | /* map/unmap direction */ | 24 | /* map/unmap direction */ |
@@ -80,7 +81,7 @@ extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, | |||
80 | uint nrxpost, uint rxoffset, uint *msg_level); | 81 | uint nrxpost, uint rxoffset, uint *msg_level); |
81 | 82 | ||
82 | void dma_rxinit(struct dma_pub *pub); | 83 | void dma_rxinit(struct dma_pub *pub); |
83 | struct sk_buff *dma_rx(struct dma_pub *pub); | 84 | int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list); |
84 | bool dma_rxfill(struct dma_pub *pub); | 85 | bool dma_rxfill(struct dma_pub *pub); |
85 | bool dma_rxreset(struct dma_pub *pub); | 86 | bool dma_rxreset(struct dma_pub *pub); |
86 | bool dma_txreset(struct dma_pub *pub); | 87 | bool dma_txreset(struct dma_pub *pub); |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 0d8a9cdf897a..8457e969eb4f 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | |||
@@ -216,8 +216,7 @@ static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = { | |||
216 | .ht_cap = { | 216 | .ht_cap = { |
217 | /* from include/linux/ieee80211.h */ | 217 | /* from include/linux/ieee80211.h */ |
218 | .cap = IEEE80211_HT_CAP_GRN_FLD | | 218 | .cap = IEEE80211_HT_CAP_GRN_FLD | |
219 | IEEE80211_HT_CAP_SGI_20 | | 219 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40, |
220 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, | ||
221 | .ht_supported = true, | 220 | .ht_supported = true, |
222 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, | 221 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
223 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, | 222 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, |
@@ -238,8 +237,7 @@ static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = { | |||
238 | BRCMS_LEGACY_5G_RATE_OFFSET, | 237 | BRCMS_LEGACY_5G_RATE_OFFSET, |
239 | .ht_cap = { | 238 | .ht_cap = { |
240 | .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | | 239 | .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | |
241 | IEEE80211_HT_CAP_SGI_40 | | 240 | IEEE80211_HT_CAP_SGI_40, |
242 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ | ||
243 | .ht_supported = true, | 241 | .ht_supported = true, |
244 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, | 242 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
245 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, | 243 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, |
@@ -287,6 +285,7 @@ static int brcms_ops_start(struct ieee80211_hw *hw) | |||
287 | { | 285 | { |
288 | struct brcms_info *wl = hw->priv; | 286 | struct brcms_info *wl = hw->priv; |
289 | bool blocked; | 287 | bool blocked; |
288 | int err; | ||
290 | 289 | ||
291 | ieee80211_wake_queues(hw); | 290 | ieee80211_wake_queues(hw); |
292 | spin_lock_bh(&wl->lock); | 291 | spin_lock_bh(&wl->lock); |
@@ -295,57 +294,69 @@ static int brcms_ops_start(struct ieee80211_hw *hw) | |||
295 | if (!blocked) | 294 | if (!blocked) |
296 | wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); | 295 | wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); |
297 | 296 | ||
298 | return 0; | 297 | spin_lock_bh(&wl->lock); |
298 | /* avoid acknowledging frames before a non-monitor device is added */ | ||
299 | wl->mute_tx = true; | ||
300 | |||
301 | if (!wl->pub->up) | ||
302 | err = brcms_up(wl); | ||
303 | else | ||
304 | err = -ENODEV; | ||
305 | spin_unlock_bh(&wl->lock); | ||
306 | |||
307 | if (err != 0) | ||
308 | wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, | ||
309 | err); | ||
310 | return err; | ||
299 | } | 311 | } |
300 | 312 | ||
301 | static void brcms_ops_stop(struct ieee80211_hw *hw) | 313 | static void brcms_ops_stop(struct ieee80211_hw *hw) |
302 | { | 314 | { |
315 | struct brcms_info *wl = hw->priv; | ||
316 | int status; | ||
317 | |||
303 | ieee80211_stop_queues(hw); | 318 | ieee80211_stop_queues(hw); |
319 | |||
320 | if (wl->wlc == NULL) | ||
321 | return; | ||
322 | |||
323 | spin_lock_bh(&wl->lock); | ||
324 | status = brcms_c_chipmatch(wl->wlc->hw->vendorid, | ||
325 | wl->wlc->hw->deviceid); | ||
326 | spin_unlock_bh(&wl->lock); | ||
327 | if (!status) { | ||
328 | wiphy_err(wl->wiphy, | ||
329 | "wl: brcms_ops_stop: chipmatch failed\n"); | ||
330 | return; | ||
331 | } | ||
332 | |||
333 | /* put driver in down state */ | ||
334 | spin_lock_bh(&wl->lock); | ||
335 | brcms_down(wl); | ||
336 | spin_unlock_bh(&wl->lock); | ||
304 | } | 337 | } |
305 | 338 | ||
306 | static int | 339 | static int |
307 | brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | 340 | brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
308 | { | 341 | { |
309 | struct brcms_info *wl; | 342 | struct brcms_info *wl = hw->priv; |
310 | int err; | ||
311 | 343 | ||
312 | /* Just STA for now */ | 344 | /* Just STA for now */ |
313 | if (vif->type != NL80211_IFTYPE_AP && | 345 | if (vif->type != NL80211_IFTYPE_STATION) { |
314 | vif->type != NL80211_IFTYPE_MESH_POINT && | ||
315 | vif->type != NL80211_IFTYPE_STATION && | ||
316 | vif->type != NL80211_IFTYPE_WDS && | ||
317 | vif->type != NL80211_IFTYPE_ADHOC) { | ||
318 | wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only" | 346 | wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only" |
319 | " STA for now\n", __func__, vif->type); | 347 | " STA for now\n", __func__, vif->type); |
320 | return -EOPNOTSUPP; | 348 | return -EOPNOTSUPP; |
321 | } | 349 | } |
322 | 350 | ||
323 | wl = hw->priv; | 351 | wl->mute_tx = false; |
324 | spin_lock_bh(&wl->lock); | 352 | brcms_c_mute(wl->wlc, false); |
325 | if (!wl->pub->up) | ||
326 | err = brcms_up(wl); | ||
327 | else | ||
328 | err = -ENODEV; | ||
329 | spin_unlock_bh(&wl->lock); | ||
330 | |||
331 | if (err != 0) | ||
332 | wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, | ||
333 | err); | ||
334 | 353 | ||
335 | return err; | 354 | return 0; |
336 | } | 355 | } |
337 | 356 | ||
338 | static void | 357 | static void |
339 | brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | 358 | brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
340 | { | 359 | { |
341 | struct brcms_info *wl; | ||
342 | |||
343 | wl = hw->priv; | ||
344 | |||
345 | /* put driver in down state */ | ||
346 | spin_lock_bh(&wl->lock); | ||
347 | brcms_down(wl); | ||
348 | spin_unlock_bh(&wl->lock); | ||
349 | } | 360 | } |
350 | 361 | ||
351 | static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) | 362 | static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) |
@@ -609,13 +620,6 @@ brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
609 | wl->pub->global_ampdu->scb = scb; | 620 | wl->pub->global_ampdu->scb = scb; |
610 | wl->pub->global_ampdu->max_pdu = 16; | 621 | wl->pub->global_ampdu->max_pdu = 16; |
611 | 622 | ||
612 | sta->ht_cap.ht_supported = true; | ||
613 | sta->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; | ||
614 | sta->ht_cap.ampdu_density = AMPDU_DEF_MPDU_DENSITY; | ||
615 | sta->ht_cap.cap = IEEE80211_HT_CAP_GRN_FLD | | ||
616 | IEEE80211_HT_CAP_SGI_20 | | ||
617 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT; | ||
618 | |||
619 | /* | 623 | /* |
620 | * minstrel_ht initiates addBA on our behalf by calling | 624 | * minstrel_ht initiates addBA on our behalf by calling |
621 | * ieee80211_start_tx_ba_session() | 625 | * ieee80211_start_tx_ba_session() |
@@ -877,37 +881,18 @@ static void brcms_free(struct brcms_info *wl) | |||
877 | } | 881 | } |
878 | 882 | ||
879 | /* | 883 | /* |
880 | * called from both kernel as from this kernel module. | 884 | * called from both kernel as from this kernel module (error flow on attach) |
881 | * precondition: perimeter lock is not acquired. | 885 | * precondition: perimeter lock is not acquired. |
882 | */ | 886 | */ |
883 | static void brcms_remove(struct pci_dev *pdev) | 887 | static void brcms_remove(struct pci_dev *pdev) |
884 | { | 888 | { |
885 | struct brcms_info *wl; | 889 | struct ieee80211_hw *hw = pci_get_drvdata(pdev); |
886 | struct ieee80211_hw *hw; | 890 | struct brcms_info *wl = hw->priv; |
887 | int status; | ||
888 | |||
889 | hw = pci_get_drvdata(pdev); | ||
890 | wl = hw->priv; | ||
891 | if (!wl) { | ||
892 | pr_err("wl: brcms_remove: pci_get_drvdata failed\n"); | ||
893 | return; | ||
894 | } | ||
895 | 891 | ||
896 | spin_lock_bh(&wl->lock); | ||
897 | status = brcms_c_chipmatch(pdev->vendor, pdev->device); | ||
898 | spin_unlock_bh(&wl->lock); | ||
899 | if (!status) { | ||
900 | wiphy_err(wl->wiphy, "wl: brcms_remove: chipmatch " | ||
901 | "failed\n"); | ||
902 | return; | ||
903 | } | ||
904 | if (wl->wlc) { | 892 | if (wl->wlc) { |
905 | wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); | 893 | wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); |
906 | wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); | 894 | wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); |
907 | ieee80211_unregister_hw(hw); | 895 | ieee80211_unregister_hw(hw); |
908 | spin_lock_bh(&wl->lock); | ||
909 | brcms_down(wl); | ||
910 | spin_unlock_bh(&wl->lock); | ||
911 | } | 896 | } |
912 | pci_disable_device(pdev); | 897 | pci_disable_device(pdev); |
913 | 898 | ||
@@ -1081,9 +1066,6 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, | |||
1081 | 1066 | ||
1082 | wl->pub->ieee_hw = hw; | 1067 | wl->pub->ieee_hw = hw; |
1083 | 1068 | ||
1084 | /* disable mpc */ | ||
1085 | brcms_c_set_radio_mpc(wl->wlc, false); | ||
1086 | |||
1087 | /* register our interrupt handler */ | 1069 | /* register our interrupt handler */ |
1088 | if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { | 1070 | if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { |
1089 | wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit); | 1071 | wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit); |
@@ -1319,8 +1301,7 @@ void brcms_init(struct brcms_info *wl) | |||
1319 | { | 1301 | { |
1320 | BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); | 1302 | BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); |
1321 | brcms_reset(wl); | 1303 | brcms_reset(wl); |
1322 | 1304 | brcms_c_init(wl->wlc, wl->mute_tx); | |
1323 | brcms_c_init(wl->wlc); | ||
1324 | } | 1305 | } |
1325 | 1306 | ||
1326 | /* | 1307 | /* |
@@ -1337,6 +1318,14 @@ uint brcms_reset(struct brcms_info *wl) | |||
1337 | return 0; | 1318 | return 0; |
1338 | } | 1319 | } |
1339 | 1320 | ||
1321 | void brcms_fatal_error(struct brcms_info *wl) | ||
1322 | { | ||
1323 | wiphy_err(wl->wlc->wiphy, "wl%d: fatal error, reinitializing\n", | ||
1324 | wl->wlc->pub->unit); | ||
1325 | brcms_reset(wl); | ||
1326 | ieee80211_restart_hw(wl->pub->ieee_hw); | ||
1327 | } | ||
1328 | |||
1340 | /* | 1329 | /* |
1341 | * These are interrupt on/off entry points. Disable interrupts | 1330 | * These are interrupt on/off entry points. Disable interrupts |
1342 | * during interrupt state transition. | 1331 | * during interrupt state transition. |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h index 177f0e44e4b6..6242f188b717 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h | |||
@@ -80,6 +80,7 @@ struct brcms_info { | |||
80 | struct brcms_firmware fw; | 80 | struct brcms_firmware fw; |
81 | struct wiphy *wiphy; | 81 | struct wiphy *wiphy; |
82 | struct brcms_ucode ucode; | 82 | struct brcms_ucode ucode; |
83 | bool mute_tx; | ||
83 | }; | 84 | }; |
84 | 85 | ||
85 | /* misc callbacks */ | 86 | /* misc callbacks */ |
@@ -104,5 +105,6 @@ extern bool brcms_del_timer(struct brcms_timer *timer); | |||
104 | extern void brcms_msleep(struct brcms_info *wl, uint ms); | 105 | extern void brcms_msleep(struct brcms_info *wl, uint ms); |
105 | extern void brcms_dpc(unsigned long data); | 106 | extern void brcms_dpc(unsigned long data); |
106 | extern void brcms_timer(struct brcms_timer *t); | 107 | extern void brcms_timer(struct brcms_timer *t); |
108 | extern void brcms_fatal_error(struct brcms_info *wl); | ||
107 | 109 | ||
108 | #endif /* _BRCM_MAC80211_IF_H_ */ | 110 | #endif /* _BRCM_MAC80211_IF_H_ */ |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 510e9bb52287..36e3e0638300 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c | |||
@@ -30,44 +30,21 @@ | |||
30 | #include "mac80211_if.h" | 30 | #include "mac80211_if.h" |
31 | #include "ucode_loader.h" | 31 | #include "ucode_loader.h" |
32 | #include "main.h" | 32 | #include "main.h" |
33 | #include "soc.h" | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Indication for txflowcontrol that all priority bits in | 36 | * Indication for txflowcontrol that all priority bits in |
36 | * TXQ_STOP_FOR_PRIOFC_MASK are to be considered. | 37 | * TXQ_STOP_FOR_PRIOFC_MASK are to be considered. |
37 | */ | 38 | */ |
38 | #define ALLPRIO -1 | 39 | #define ALLPRIO -1 |
39 | |||
40 | /* | ||
41 | * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. | ||
42 | */ | ||
43 | #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) | ||
44 | 40 | ||
45 | /* watchdog timer, in unit of ms */ | 41 | /* watchdog timer, in unit of ms */ |
46 | #define TIMER_INTERVAL_WATCHDOG 1000 | 42 | #define TIMER_INTERVAL_WATCHDOG 1000 |
47 | /* radio monitor timer, in unit of ms */ | 43 | /* radio monitor timer, in unit of ms */ |
48 | #define TIMER_INTERVAL_RADIOCHK 800 | 44 | #define TIMER_INTERVAL_RADIOCHK 800 |
49 | |||
50 | /* Max MPC timeout, in unit of watchdog */ | ||
51 | #ifndef BRCMS_MPC_MAX_DELAYCNT | ||
52 | #define BRCMS_MPC_MAX_DELAYCNT 10 | ||
53 | #endif | ||
54 | |||
55 | /* Min MPC timeout, in unit of watchdog */ | ||
56 | #define BRCMS_MPC_MIN_DELAYCNT 1 | ||
57 | #define BRCMS_MPC_THRESHOLD 3 /* MPC count threshold level */ | ||
58 | 45 | ||
59 | /* beacon interval, in unit of 1024TU */ | 46 | /* beacon interval, in unit of 1024TU */ |
60 | #define BEACON_INTERVAL_DEFAULT 100 | 47 | #define BEACON_INTERVAL_DEFAULT 100 |
61 | /* DTIM interval, in unit of beacon interval */ | ||
62 | #define DTIM_INTERVAL_DEFAULT 3 | ||
63 | |||
64 | /* Scale down delays to accommodate QT slow speed */ | ||
65 | /* beacon interval, in unit of 1024TU */ | ||
66 | #define BEACON_INTERVAL_DEF_QT 20 | ||
67 | /* DTIM interval, in unit of beacon interval */ | ||
68 | #define DTIM_INTERVAL_DEF_QT 1 | ||
69 | |||
70 | #define TBTT_ALIGN_LEEWAY_US 100 /* min leeway before first TBTT in us */ | ||
71 | 48 | ||
72 | /* n-mode support capability */ | 49 | /* n-mode support capability */ |
73 | /* 2x2 includes both 1x1 & 2x2 devices | 50 | /* 2x2 includes both 1x1 & 2x2 devices |
@@ -78,113 +55,71 @@ | |||
78 | #define WL_11N_3x3 3 | 55 | #define WL_11N_3x3 3 |
79 | #define WL_11N_4x4 4 | 56 | #define WL_11N_4x4 4 |
80 | 57 | ||
81 | /* define 11n feature disable flags */ | 58 | #define EDCF_ACI_MASK 0x60 |
82 | #define WLFEATURE_DISABLE_11N 0x00000001 | 59 | #define EDCF_ACI_SHIFT 5 |
83 | #define WLFEATURE_DISABLE_11N_STBC_TX 0x00000002 | 60 | #define EDCF_ECWMIN_MASK 0x0f |
84 | #define WLFEATURE_DISABLE_11N_STBC_RX 0x00000004 | 61 | #define EDCF_ECWMAX_SHIFT 4 |
85 | #define WLFEATURE_DISABLE_11N_SGI_TX 0x00000008 | 62 | #define EDCF_AIFSN_MASK 0x0f |
86 | #define WLFEATURE_DISABLE_11N_SGI_RX 0x00000010 | 63 | #define EDCF_AIFSN_MAX 15 |
87 | #define WLFEATURE_DISABLE_11N_AMPDU_TX 0x00000020 | 64 | #define EDCF_ECWMAX_MASK 0xf0 |
88 | #define WLFEATURE_DISABLE_11N_AMPDU_RX 0x00000040 | 65 | |
89 | #define WLFEATURE_DISABLE_11N_GF 0x00000080 | 66 | #define EDCF_AC_BE_TXOP_STA 0x0000 |
90 | 67 | #define EDCF_AC_BK_TXOP_STA 0x0000 | |
91 | #define EDCF_ACI_MASK 0x60 | 68 | #define EDCF_AC_VO_ACI_STA 0x62 |
92 | #define EDCF_ACI_SHIFT 5 | 69 | #define EDCF_AC_VO_ECW_STA 0x32 |
93 | #define EDCF_ECWMIN_MASK 0x0f | 70 | #define EDCF_AC_VI_ACI_STA 0x42 |
94 | #define EDCF_ECWMAX_SHIFT 4 | 71 | #define EDCF_AC_VI_ECW_STA 0x43 |
95 | #define EDCF_AIFSN_MASK 0x0f | 72 | #define EDCF_AC_BK_ECW_STA 0xA4 |
96 | #define EDCF_AIFSN_MAX 15 | 73 | #define EDCF_AC_VI_TXOP_STA 0x005e |
97 | #define EDCF_ECWMAX_MASK 0xf0 | 74 | #define EDCF_AC_VO_TXOP_STA 0x002f |
98 | 75 | #define EDCF_AC_BE_ACI_STA 0x03 | |
99 | #define EDCF_AC_BE_TXOP_STA 0x0000 | 76 | #define EDCF_AC_BE_ECW_STA 0xA4 |
100 | #define EDCF_AC_BK_TXOP_STA 0x0000 | 77 | #define EDCF_AC_BK_ACI_STA 0x27 |
101 | #define EDCF_AC_VO_ACI_STA 0x62 | 78 | #define EDCF_AC_VO_TXOP_AP 0x002f |
102 | #define EDCF_AC_VO_ECW_STA 0x32 | 79 | |
103 | #define EDCF_AC_VI_ACI_STA 0x42 | 80 | #define EDCF_TXOP2USEC(txop) ((txop) << 5) |
104 | #define EDCF_AC_VI_ECW_STA 0x43 | 81 | #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) |
105 | #define EDCF_AC_BK_ECW_STA 0xA4 | 82 | |
106 | #define EDCF_AC_VI_TXOP_STA 0x005e | 83 | #define APHY_SYMBOL_TIME 4 |
107 | #define EDCF_AC_VO_TXOP_STA 0x002f | 84 | #define APHY_PREAMBLE_TIME 16 |
108 | #define EDCF_AC_BE_ACI_STA 0x03 | 85 | #define APHY_SIGNAL_TIME 4 |
109 | #define EDCF_AC_BE_ECW_STA 0xA4 | 86 | #define APHY_SIFS_TIME 16 |
110 | #define EDCF_AC_BK_ACI_STA 0x27 | 87 | #define APHY_SERVICE_NBITS 16 |
111 | #define EDCF_AC_VO_TXOP_AP 0x002f | 88 | #define APHY_TAIL_NBITS 6 |
112 | 89 | #define BPHY_SIFS_TIME 10 | |
113 | #define EDCF_TXOP2USEC(txop) ((txop) << 5) | 90 | #define BPHY_PLCP_SHORT_TIME 96 |
114 | #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) | 91 | |
115 | 92 | #define PREN_PREAMBLE 24 | |
116 | #define APHY_SYMBOL_TIME 4 | 93 | #define PREN_MM_EXT 12 |
117 | #define APHY_PREAMBLE_TIME 16 | 94 | #define PREN_PREAMBLE_EXT 4 |
118 | #define APHY_SIGNAL_TIME 4 | ||
119 | #define APHY_SIFS_TIME 16 | ||
120 | #define APHY_SERVICE_NBITS 16 | ||
121 | #define APHY_TAIL_NBITS 6 | ||
122 | #define BPHY_SIFS_TIME 10 | ||
123 | #define BPHY_PLCP_SHORT_TIME 96 | ||
124 | |||
125 | #define PREN_PREAMBLE 24 | ||
126 | #define PREN_MM_EXT 12 | ||
127 | #define PREN_PREAMBLE_EXT 4 | ||
128 | 95 | ||
129 | #define DOT11_MAC_HDR_LEN 24 | 96 | #define DOT11_MAC_HDR_LEN 24 |
130 | #define DOT11_ACK_LEN 10 | 97 | #define DOT11_ACK_LEN 10 |
131 | #define DOT11_BA_LEN 4 | 98 | #define DOT11_BA_LEN 4 |
132 | #define DOT11_OFDM_SIGNAL_EXTENSION 6 | 99 | #define DOT11_OFDM_SIGNAL_EXTENSION 6 |
133 | #define DOT11_MIN_FRAG_LEN 256 | 100 | #define DOT11_MIN_FRAG_LEN 256 |
134 | #define DOT11_RTS_LEN 16 | 101 | #define DOT11_RTS_LEN 16 |
135 | #define DOT11_CTS_LEN 10 | 102 | #define DOT11_CTS_LEN 10 |
136 | #define DOT11_BA_BITMAP_LEN 128 | 103 | #define DOT11_BA_BITMAP_LEN 128 |
137 | #define DOT11_MIN_BEACON_PERIOD 1 | 104 | #define DOT11_MIN_BEACON_PERIOD 1 |
138 | #define DOT11_MAX_BEACON_PERIOD 0xFFFF | 105 | #define DOT11_MAX_BEACON_PERIOD 0xFFFF |
139 | #define DOT11_MAXNUMFRAGS 16 | 106 | #define DOT11_MAXNUMFRAGS 16 |
140 | #define DOT11_MAX_FRAG_LEN 2346 | 107 | #define DOT11_MAX_FRAG_LEN 2346 |
141 | 108 | ||
142 | #define BPHY_PLCP_TIME 192 | 109 | #define BPHY_PLCP_TIME 192 |
143 | #define RIFS_11N_TIME 2 | 110 | #define RIFS_11N_TIME 2 |
144 | |||
145 | #define WME_VER 1 | ||
146 | #define WME_SUBTYPE_PARAM_IE 1 | ||
147 | #define WME_TYPE 2 | ||
148 | #define WME_OUI "\x00\x50\xf2" | ||
149 | |||
150 | #define AC_BE 0 | ||
151 | #define AC_BK 1 | ||
152 | #define AC_VI 2 | ||
153 | #define AC_VO 3 | ||
154 | 111 | ||
155 | #define BCN_TMPL_LEN 512 /* length of the BCN template area */ | 112 | /* length of the BCN template area */ |
113 | #define BCN_TMPL_LEN 512 | ||
156 | 114 | ||
157 | /* brcms_bss_info flag bit values */ | 115 | /* brcms_bss_info flag bit values */ |
158 | #define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ | 116 | #define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ |
159 | 117 | ||
160 | /* Flags used in brcms_c_txq_info.stopped */ | 118 | /* chip rx buffer offset */ |
161 | /* per prio flow control bits */ | 119 | #define BRCMS_HWRXOFF 38 |
162 | #define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF | ||
163 | /* stop txq enqueue for packet drain */ | ||
164 | #define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 | ||
165 | /* stop txq enqueue for ampdu flow control */ | ||
166 | #define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 | ||
167 | |||
168 | #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ | ||
169 | |||
170 | /* Find basic rate for a given rate */ | ||
171 | static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) | ||
172 | { | ||
173 | if (is_mcs_rate(rspec)) | ||
174 | return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] | ||
175 | .leg_ofdm]; | ||
176 | return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; | ||
177 | } | ||
178 | |||
179 | static u16 frametype(u32 rspec, u8 mimoframe) | ||
180 | { | ||
181 | if (is_mcs_rate(rspec)) | ||
182 | return mimoframe; | ||
183 | return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; | ||
184 | } | ||
185 | 120 | ||
186 | /* rfdisable delay timer 500 ms, runs of ALP clock */ | 121 | /* rfdisable delay timer 500 ms, runs of ALP clock */ |
187 | #define RFDISABLE_DEFAULT 10000000 | 122 | #define RFDISABLE_DEFAULT 10000000 |
188 | 123 | ||
189 | #define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ | 124 | #define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ |
190 | 125 | ||
@@ -194,87 +129,83 @@ static u16 frametype(u32 rspec, u8 mimoframe) | |||
194 | * These constants are used ONLY by wlc_prio2prec_map. Do not use them | 129 | * These constants are used ONLY by wlc_prio2prec_map. Do not use them |
195 | * elsewhere. | 130 | * elsewhere. |
196 | */ | 131 | */ |
197 | #define _BRCMS_PREC_NONE 0 /* None = - */ | 132 | #define _BRCMS_PREC_NONE 0 /* None = - */ |
198 | #define _BRCMS_PREC_BK 2 /* BK - Background */ | 133 | #define _BRCMS_PREC_BK 2 /* BK - Background */ |
199 | #define _BRCMS_PREC_BE 4 /* BE - Best-effort */ | 134 | #define _BRCMS_PREC_BE 4 /* BE - Best-effort */ |
200 | #define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */ | 135 | #define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */ |
201 | #define _BRCMS_PREC_CL 8 /* CL - Controlled Load */ | 136 | #define _BRCMS_PREC_CL 8 /* CL - Controlled Load */ |
202 | #define _BRCMS_PREC_VI 10 /* Vi - Video */ | 137 | #define _BRCMS_PREC_VI 10 /* Vi - Video */ |
203 | #define _BRCMS_PREC_VO 12 /* Vo - Voice */ | 138 | #define _BRCMS_PREC_VO 12 /* Vo - Voice */ |
204 | #define _BRCMS_PREC_NC 14 /* NC - Network Control */ | 139 | #define _BRCMS_PREC_NC 14 /* NC - Network Control */ |
205 | 140 | ||
206 | /* The BSS is generating beacons in HW */ | 141 | /* synthpu_dly times in us */ |
207 | #define BRCMS_BSSCFG_HW_BCN 0x20 | 142 | #define SYNTHPU_DLY_APHY_US 3700 |
208 | 143 | #define SYNTHPU_DLY_BPHY_US 1050 | |
209 | #define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ | 144 | #define SYNTHPU_DLY_NPHY_US 2048 |
210 | #define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us */ | 145 | #define SYNTHPU_DLY_LPPHY_US 300 |
211 | #define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us */ | 146 | |
212 | #define SYNTHPU_DLY_LPPHY_US 300 /* lpphy synthpu_dly time in us */ | 147 | #define ANTCNT 10 /* vanilla M_MAX_ANTCNT val */ |
213 | |||
214 | #define SYNTHPU_DLY_PHY_US_QT 100 /* QT synthpu_dly time in us */ | ||
215 | |||
216 | #define ANTCNT 10 /* vanilla M_MAX_ANTCNT value */ | ||
217 | 148 | ||
218 | /* Per-AC retry limit register definitions; uses defs.h bitfield macros */ | 149 | /* Per-AC retry limit register definitions; uses defs.h bitfield macros */ |
219 | #define EDCF_SHORT_S 0 | 150 | #define EDCF_SHORT_S 0 |
220 | #define EDCF_SFB_S 4 | 151 | #define EDCF_SFB_S 4 |
221 | #define EDCF_LONG_S 8 | 152 | #define EDCF_LONG_S 8 |
222 | #define EDCF_LFB_S 12 | 153 | #define EDCF_LFB_S 12 |
223 | #define EDCF_SHORT_M BITFIELD_MASK(4) | 154 | #define EDCF_SHORT_M BITFIELD_MASK(4) |
224 | #define EDCF_SFB_M BITFIELD_MASK(4) | 155 | #define EDCF_SFB_M BITFIELD_MASK(4) |
225 | #define EDCF_LONG_M BITFIELD_MASK(4) | 156 | #define EDCF_LONG_M BITFIELD_MASK(4) |
226 | #define EDCF_LFB_M BITFIELD_MASK(4) | 157 | #define EDCF_LFB_M BITFIELD_MASK(4) |
227 | 158 | ||
228 | #define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ | 159 | #define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ |
229 | #define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ | 160 | #define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ |
230 | #define RETRY_LONG_DEF 4 /* Default Long retry count */ | 161 | #define RETRY_LONG_DEF 4 /* Default Long retry count */ |
231 | #define RETRY_SHORT_FB 3 /* Short count for fallback rate */ | 162 | #define RETRY_SHORT_FB 3 /* Short count for fb rate */ |
232 | #define RETRY_LONG_FB 2 /* Long count for fallback rate */ | 163 | #define RETRY_LONG_FB 2 /* Long count for fb rate */ |
233 | 164 | ||
234 | #define APHY_CWMIN 15 | 165 | #define APHY_CWMIN 15 |
235 | #define PHY_CWMAX 1023 | 166 | #define PHY_CWMAX 1023 |
236 | 167 | ||
237 | #define EDCF_AIFSN_MIN 1 | 168 | #define EDCF_AIFSN_MIN 1 |
238 | 169 | ||
239 | #define FRAGNUM_MASK 0xF | 170 | #define FRAGNUM_MASK 0xF |
240 | 171 | ||
241 | #define APHY_SLOT_TIME 9 | 172 | #define APHY_SLOT_TIME 9 |
242 | #define BPHY_SLOT_TIME 20 | 173 | #define BPHY_SLOT_TIME 20 |
243 | 174 | ||
244 | #define WL_SPURAVOID_OFF 0 | 175 | #define WL_SPURAVOID_OFF 0 |
245 | #define WL_SPURAVOID_ON1 1 | 176 | #define WL_SPURAVOID_ON1 1 |
246 | #define WL_SPURAVOID_ON2 2 | 177 | #define WL_SPURAVOID_ON2 2 |
247 | 178 | ||
248 | /* invalid core flags, use the saved coreflags */ | 179 | /* invalid core flags, use the saved coreflags */ |
249 | #define BRCMS_USE_COREFLAGS 0xffffffff | 180 | #define BRCMS_USE_COREFLAGS 0xffffffff |
250 | 181 | ||
251 | /* values for PLCPHdr_override */ | 182 | /* values for PLCPHdr_override */ |
252 | #define BRCMS_PLCP_AUTO -1 | 183 | #define BRCMS_PLCP_AUTO -1 |
253 | #define BRCMS_PLCP_SHORT 0 | 184 | #define BRCMS_PLCP_SHORT 0 |
254 | #define BRCMS_PLCP_LONG 1 | 185 | #define BRCMS_PLCP_LONG 1 |
255 | 186 | ||
256 | /* values for g_protection_override and n_protection_override */ | 187 | /* values for g_protection_override and n_protection_override */ |
257 | #define BRCMS_PROTECTION_AUTO -1 | 188 | #define BRCMS_PROTECTION_AUTO -1 |
258 | #define BRCMS_PROTECTION_OFF 0 | 189 | #define BRCMS_PROTECTION_OFF 0 |
259 | #define BRCMS_PROTECTION_ON 1 | 190 | #define BRCMS_PROTECTION_ON 1 |
260 | #define BRCMS_PROTECTION_MMHDR_ONLY 2 | 191 | #define BRCMS_PROTECTION_MMHDR_ONLY 2 |
261 | #define BRCMS_PROTECTION_CTS_ONLY 3 | 192 | #define BRCMS_PROTECTION_CTS_ONLY 3 |
262 | 193 | ||
263 | /* values for g_protection_control and n_protection_control */ | 194 | /* values for g_protection_control and n_protection_control */ |
264 | #define BRCMS_PROTECTION_CTL_OFF 0 | 195 | #define BRCMS_PROTECTION_CTL_OFF 0 |
265 | #define BRCMS_PROTECTION_CTL_LOCAL 1 | 196 | #define BRCMS_PROTECTION_CTL_LOCAL 1 |
266 | #define BRCMS_PROTECTION_CTL_OVERLAP 2 | 197 | #define BRCMS_PROTECTION_CTL_OVERLAP 2 |
267 | 198 | ||
268 | /* values for n_protection */ | 199 | /* values for n_protection */ |
269 | #define BRCMS_N_PROTECTION_OFF 0 | 200 | #define BRCMS_N_PROTECTION_OFF 0 |
270 | #define BRCMS_N_PROTECTION_OPTIONAL 1 | 201 | #define BRCMS_N_PROTECTION_OPTIONAL 1 |
271 | #define BRCMS_N_PROTECTION_20IN40 2 | 202 | #define BRCMS_N_PROTECTION_20IN40 2 |
272 | #define BRCMS_N_PROTECTION_MIXEDMODE 3 | 203 | #define BRCMS_N_PROTECTION_MIXEDMODE 3 |
273 | 204 | ||
274 | /* values for band specific 40MHz capabilities */ | 205 | /* values for band specific 40MHz capabilities */ |
275 | #define BRCMS_N_BW_20ALL 0 | 206 | #define BRCMS_N_BW_20ALL 0 |
276 | #define BRCMS_N_BW_40ALL 1 | 207 | #define BRCMS_N_BW_40ALL 1 |
277 | #define BRCMS_N_BW_20IN2G_40IN5G 2 | 208 | #define BRCMS_N_BW_20IN2G_40IN5G 2 |
278 | 209 | ||
279 | /* bitflags for SGI support (sgi_rx iovar) */ | 210 | /* bitflags for SGI support (sgi_rx iovar) */ |
280 | #define BRCMS_N_SGI_20 0x01 | 211 | #define BRCMS_N_SGI_20 0x01 |
@@ -282,48 +213,42 @@ static u16 frametype(u32 rspec, u8 mimoframe) | |||
282 | 213 | ||
283 | /* defines used by the nrate iovar */ | 214 | /* defines used by the nrate iovar */ |
284 | /* MSC in use,indicates b0-6 holds an mcs */ | 215 | /* MSC in use,indicates b0-6 holds an mcs */ |
285 | #define NRATE_MCS_INUSE 0x00000080 | 216 | #define NRATE_MCS_INUSE 0x00000080 |
286 | /* rate/mcs value */ | 217 | /* rate/mcs value */ |
287 | #define NRATE_RATE_MASK 0x0000007f | 218 | #define NRATE_RATE_MASK 0x0000007f |
288 | /* stf mode mask: siso, cdd, stbc, sdm */ | 219 | /* stf mode mask: siso, cdd, stbc, sdm */ |
289 | #define NRATE_STF_MASK 0x0000ff00 | 220 | #define NRATE_STF_MASK 0x0000ff00 |
290 | /* stf mode shift */ | 221 | /* stf mode shift */ |
291 | #define NRATE_STF_SHIFT 8 | 222 | #define NRATE_STF_SHIFT 8 |
292 | /* bit indicates override both rate & mode */ | ||
293 | #define NRATE_OVERRIDE 0x80000000 | ||
294 | /* bit indicate to override mcs only */ | 223 | /* bit indicate to override mcs only */ |
295 | #define NRATE_OVERRIDE_MCS_ONLY 0x40000000 | 224 | #define NRATE_OVERRIDE_MCS_ONLY 0x40000000 |
296 | #define NRATE_SGI_MASK 0x00800000 /* sgi mode */ | 225 | #define NRATE_SGI_MASK 0x00800000 /* sgi mode */ |
297 | #define NRATE_SGI_SHIFT 23 /* sgi mode */ | 226 | #define NRATE_SGI_SHIFT 23 /* sgi mode */ |
298 | #define NRATE_LDPC_CODING 0x00400000 /* bit indicates adv coding in use */ | 227 | #define NRATE_LDPC_CODING 0x00400000 /* adv coding in use */ |
299 | #define NRATE_LDPC_SHIFT 22 /* ldpc shift */ | 228 | #define NRATE_LDPC_SHIFT 22 /* ldpc shift */ |
300 | 229 | ||
301 | #define NRATE_STF_SISO 0 /* stf mode SISO */ | 230 | #define NRATE_STF_SISO 0 /* stf mode SISO */ |
302 | #define NRATE_STF_CDD 1 /* stf mode CDD */ | 231 | #define NRATE_STF_CDD 1 /* stf mode CDD */ |
303 | #define NRATE_STF_STBC 2 /* stf mode STBC */ | 232 | #define NRATE_STF_STBC 2 /* stf mode STBC */ |
304 | #define NRATE_STF_SDM 3 /* stf mode SDM */ | 233 | #define NRATE_STF_SDM 3 /* stf mode SDM */ |
305 | 234 | ||
306 | #define MAX_DMA_SEGS 4 | 235 | #define MAX_DMA_SEGS 4 |
307 | 236 | ||
308 | /* Max # of entries in Tx FIFO based on 4kb page size */ | 237 | /* Max # of entries in Tx FIFO based on 4kb page size */ |
309 | #define NTXD 256 | 238 | #define NTXD 256 |
310 | /* Max # of entries in Rx FIFO based on 4kb page size */ | 239 | /* Max # of entries in Rx FIFO based on 4kb page size */ |
311 | #define NRXD 256 | 240 | #define NRXD 256 |
312 | 241 | ||
313 | /* try to keep this # rbufs posted to the chip */ | 242 | /* try to keep this # rbufs posted to the chip */ |
314 | #define NRXBUFPOST 32 | 243 | #define NRXBUFPOST 32 |
315 | 244 | ||
316 | /* data msg txq hiwat mark */ | 245 | /* data msg txq hiwat mark */ |
317 | #define BRCMS_DATAHIWAT 50 | 246 | #define BRCMS_DATAHIWAT 50 |
318 | 247 | ||
319 | /* bounded rx loops */ | 248 | /* max # frames to process in brcms_c_recv() */ |
320 | #define RXBND 8 /* max # frames to process in brcms_c_recv() */ | 249 | #define RXBND 8 |
321 | #define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ | 250 | /* max # tx status to process in wlc_txstatus() */ |
322 | 251 | #define TXSBND 8 | |
323 | /* | ||
324 | * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. | ||
325 | */ | ||
326 | #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) | ||
327 | 252 | ||
328 | /* brcmu_format_flags() bit description structure */ | 253 | /* brcmu_format_flags() bit description structure */ |
329 | struct brcms_c_bit_desc { | 254 | struct brcms_c_bit_desc { |
@@ -375,10 +300,22 @@ uint brcm_msg_level = | |||
375 | #endif /* BCMDBG */ | 300 | #endif /* BCMDBG */ |
376 | 301 | ||
377 | /* TX FIFO number to WME/802.1E Access Category */ | 302 | /* TX FIFO number to WME/802.1E Access Category */ |
378 | static const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; | 303 | static const u8 wme_fifo2ac[] = { |
304 | IEEE80211_AC_BK, | ||
305 | IEEE80211_AC_BE, | ||
306 | IEEE80211_AC_VI, | ||
307 | IEEE80211_AC_VO, | ||
308 | IEEE80211_AC_BE, | ||
309 | IEEE80211_AC_BE | ||
310 | }; | ||
379 | 311 | ||
380 | /* WME/802.1E Access Category to TX FIFO number */ | 312 | /* ieee80211 Access Category to TX FIFO number */ |
381 | static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; | 313 | static const u8 wme_ac2fifo[] = { |
314 | TX_AC_VO_FIFO, | ||
315 | TX_AC_VI_FIFO, | ||
316 | TX_AC_BE_FIFO, | ||
317 | TX_AC_BK_FIFO | ||
318 | }; | ||
382 | 319 | ||
383 | /* 802.1D Priority to precedence queue mapping */ | 320 | /* 802.1D Priority to precedence queue mapping */ |
384 | const u8 wlc_prio2prec_map[] = { | 321 | const u8 wlc_prio2prec_map[] = { |
@@ -405,13 +342,6 @@ static const u16 xmtfifo_sz[][NFIFO] = { | |||
405 | {9, 58, 22, 14, 14, 5}, | 342 | {9, 58, 22, 14, 14, 5}, |
406 | }; | 343 | }; |
407 | 344 | ||
408 | static const u8 acbitmap2maxprio[] = { | ||
409 | PRIO_8021D_BE, PRIO_8021D_BE, PRIO_8021D_BK, PRIO_8021D_BK, | ||
410 | PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, | ||
411 | PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, | ||
412 | PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO | ||
413 | }; | ||
414 | |||
415 | #ifdef BCMDBG | 345 | #ifdef BCMDBG |
416 | static const char * const fifo_names[] = { | 346 | static const char * const fifo_names[] = { |
417 | "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; | 347 | "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; |
@@ -424,6 +354,22 @@ static const char fifo_names[6][0]; | |||
424 | static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); | 354 | static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); |
425 | #endif | 355 | #endif |
426 | 356 | ||
357 | /* Find basic rate for a given rate */ | ||
358 | static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) | ||
359 | { | ||
360 | if (is_mcs_rate(rspec)) | ||
361 | return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] | ||
362 | .leg_ofdm]; | ||
363 | return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; | ||
364 | } | ||
365 | |||
366 | static u16 frametype(u32 rspec, u8 mimoframe) | ||
367 | { | ||
368 | if (is_mcs_rate(rspec)) | ||
369 | return mimoframe; | ||
370 | return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; | ||
371 | } | ||
372 | |||
427 | /* currently the best mechanism for determining SIFS is the band in use */ | 373 | /* currently the best mechanism for determining SIFS is the band in use */ |
428 | static u16 get_sifs(struct brcms_band *band) | 374 | static u16 get_sifs(struct brcms_band *band) |
429 | { | 375 | { |
@@ -470,20 +416,6 @@ static int brcms_chspec_bw(u16 chanspec) | |||
470 | return BRCMS_10_MHZ; | 416 | return BRCMS_10_MHZ; |
471 | } | 417 | } |
472 | 418 | ||
473 | /* | ||
474 | * return true if Minimum Power Consumption should | ||
475 | * be entered, false otherwise | ||
476 | */ | ||
477 | static bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc) | ||
478 | { | ||
479 | return false; | ||
480 | } | ||
481 | |||
482 | static bool brcms_c_ismpc(struct brcms_c_info *wlc) | ||
483 | { | ||
484 | return (wlc->mpc_delay_off == 0) && (brcms_c_is_non_delay_mpc(wlc)); | ||
485 | } | ||
486 | |||
487 | static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) | 419 | static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) |
488 | { | 420 | { |
489 | if (cfg == NULL) | 421 | if (cfg == NULL) |
@@ -669,9 +601,8 @@ static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, | |||
669 | * calculate frame duration of a given rate and length, return | 601 | * calculate frame duration of a given rate and length, return |
670 | * time in usec unit | 602 | * time in usec unit |
671 | */ | 603 | */ |
672 | uint | 604 | static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, |
673 | brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, | 605 | u8 preamble_type, uint mac_len) |
674 | u8 preamble_type, uint mac_len) | ||
675 | { | 606 | { |
676 | uint nsyms, dur = 0, Ndps, kNdps; | 607 | uint nsyms, dur = 0, Ndps, kNdps; |
677 | uint rate = rspec2rate(ratespec); | 608 | uint rate = rspec2rate(ratespec); |
@@ -969,7 +900,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) | |||
969 | lfbl, /* Long Frame Rate Fallback Limit */ | 900 | lfbl, /* Long Frame Rate Fallback Limit */ |
970 | fbl; | 901 | fbl; |
971 | 902 | ||
972 | if (queue < AC_COUNT) { | 903 | if (queue < IEEE80211_NUM_ACS) { |
973 | sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], | 904 | sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], |
974 | EDCF_SFB); | 905 | EDCF_SFB); |
975 | lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], | 906 | lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], |
@@ -1018,7 +949,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) | |||
1018 | tx_info->flags |= IEEE80211_TX_STAT_ACK; | 949 | tx_info->flags |= IEEE80211_TX_STAT_ACK; |
1019 | } | 950 | } |
1020 | 951 | ||
1021 | totlen = brcmu_pkttotlen(p); | 952 | totlen = p->len; |
1022 | free_pdu = true; | 953 | free_pdu = true; |
1023 | 954 | ||
1024 | brcms_c_txfifo_complete(wlc, queue, 1); | 955 | brcms_c_txfifo_complete(wlc, queue, 1); |
@@ -2352,13 +2283,6 @@ void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type) | |||
2352 | wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); | 2283 | wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); |
2353 | } | 2284 | } |
2354 | 2285 | ||
2355 | static void brcms_c_fatal_error(struct brcms_c_info *wlc) | ||
2356 | { | ||
2357 | wiphy_err(wlc->wiphy, "wl%d: fatal error, reinitializing\n", | ||
2358 | wlc->pub->unit); | ||
2359 | brcms_init(wlc->wl); | ||
2360 | } | ||
2361 | |||
2362 | static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) | 2286 | static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) |
2363 | { | 2287 | { |
2364 | bool fatal = false; | 2288 | bool fatal = false; |
@@ -2414,7 +2338,7 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) | |||
2414 | } | 2338 | } |
2415 | 2339 | ||
2416 | if (fatal) { | 2340 | if (fatal) { |
2417 | brcms_c_fatal_error(wlc_hw->wlc); /* big hammer */ | 2341 | brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ |
2418 | break; | 2342 | break; |
2419 | } else | 2343 | } else |
2420 | W_REG(®s->intctrlregs[idx].intstatus, | 2344 | W_REG(®s->intctrlregs[idx].intstatus, |
@@ -2479,6 +2403,7 @@ void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) | |||
2479 | W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); | 2403 | W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); |
2480 | } | 2404 | } |
2481 | 2405 | ||
2406 | /* assumes that the d11 MAC is enabled */ | ||
2482 | static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, | 2407 | static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, |
2483 | uint tx_fifo) | 2408 | uint tx_fifo) |
2484 | { | 2409 | { |
@@ -2535,11 +2460,12 @@ static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, | |||
2535 | } | 2460 | } |
2536 | } | 2461 | } |
2537 | 2462 | ||
2538 | static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) | 2463 | /* precondition: requires the mac core to be enabled */ |
2464 | static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool mute_tx) | ||
2539 | { | 2465 | { |
2540 | static const u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; | 2466 | static const u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; |
2541 | 2467 | ||
2542 | if (on) { | 2468 | if (mute_tx) { |
2543 | /* suspend tx fifos */ | 2469 | /* suspend tx fifos */ |
2544 | brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); | 2470 | brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); |
2545 | brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); | 2471 | brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); |
@@ -2561,14 +2487,20 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) | |||
2561 | wlc_hw->etheraddr); | 2487 | wlc_hw->etheraddr); |
2562 | } | 2488 | } |
2563 | 2489 | ||
2564 | wlc_phy_mute_upd(wlc_hw->band->pi, on, flags); | 2490 | wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); |
2565 | 2491 | ||
2566 | if (on) | 2492 | if (mute_tx) |
2567 | brcms_c_ucode_mute_override_set(wlc_hw); | 2493 | brcms_c_ucode_mute_override_set(wlc_hw); |
2568 | else | 2494 | else |
2569 | brcms_c_ucode_mute_override_clear(wlc_hw); | 2495 | brcms_c_ucode_mute_override_clear(wlc_hw); |
2570 | } | 2496 | } |
2571 | 2497 | ||
2498 | void | ||
2499 | brcms_c_mute(struct brcms_c_info *wlc, bool mute_tx) | ||
2500 | { | ||
2501 | brcms_b_mute(wlc->hw, mute_tx); | ||
2502 | } | ||
2503 | |||
2572 | /* | 2504 | /* |
2573 | * Read and clear macintmask and macintstatus and intstatus registers. | 2505 | * Read and clear macintmask and macintstatus and intstatus registers. |
2574 | * This routine should be called with interrupts off | 2506 | * This routine should be called with interrupts off |
@@ -3437,8 +3369,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) | |||
3437 | } | 3369 | } |
3438 | 3370 | ||
3439 | void | 3371 | void |
3440 | static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, | 3372 | static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec) { |
3441 | bool mute) { | ||
3442 | u32 macintmask; | 3373 | u32 macintmask; |
3443 | bool fastclk; | 3374 | bool fastclk; |
3444 | struct brcms_c_info *wlc = wlc_hw->wlc; | 3375 | struct brcms_c_info *wlc = wlc_hw->wlc; |
@@ -3463,10 +3394,6 @@ static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, | |||
3463 | /* core-specific initialization */ | 3394 | /* core-specific initialization */ |
3464 | brcms_b_coreinit(wlc); | 3395 | brcms_b_coreinit(wlc); |
3465 | 3396 | ||
3466 | /* suspend the tx fifos and mute the phy for preism cac time */ | ||
3467 | if (mute) | ||
3468 | brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); | ||
3469 | |||
3470 | /* band-specific inits */ | 3397 | /* band-specific inits */ |
3471 | brcms_b_bsinit(wlc, chanspec); | 3398 | brcms_b_bsinit(wlc, chanspec); |
3472 | 3399 | ||
@@ -3656,42 +3583,30 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, | |||
3656 | brcms_c_set_phy_chanspec(wlc, chanspec); | 3583 | brcms_c_set_phy_chanspec(wlc, chanspec); |
3657 | } | 3584 | } |
3658 | 3585 | ||
3659 | static void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc) | 3586 | /* |
3660 | { | 3587 | * Set or clear maccontrol bits MCTL_PROMISC, MCTL_BCNS_PROMISC and |
3661 | if (wlc->bcnmisc_monitor) | 3588 | * MCTL_KEEPCONTROL |
3662 | brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); | 3589 | */ |
3663 | else | ||
3664 | brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, 0); | ||
3665 | } | ||
3666 | |||
3667 | void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) | ||
3668 | { | ||
3669 | wlc->bcnmisc_monitor = promisc; | ||
3670 | brcms_c_mac_bcn_promisc(wlc); | ||
3671 | } | ||
3672 | |||
3673 | /* set or clear maccontrol bits MCTL_PROMISC and MCTL_KEEPCONTROL */ | ||
3674 | static void brcms_c_mac_promisc(struct brcms_c_info *wlc) | 3590 | static void brcms_c_mac_promisc(struct brcms_c_info *wlc) |
3675 | { | 3591 | { |
3676 | u32 promisc_bits = 0; | 3592 | u32 promisc_bits = 0; |
3677 | 3593 | ||
3678 | /* | 3594 | if (wlc->bcnmisc_monitor) |
3679 | * promiscuous mode just sets MCTL_PROMISC | 3595 | promisc_bits |= MCTL_BCNS_PROMISC; |
3680 | * Note: APs get all BSS traffic without the need to set | ||
3681 | * the MCTL_PROMISC bit since all BSS data traffic is | ||
3682 | * directed at the AP | ||
3683 | */ | ||
3684 | if (wlc->pub->promisc) | ||
3685 | promisc_bits |= MCTL_PROMISC; | ||
3686 | 3596 | ||
3687 | /* monitor mode needs both MCTL_PROMISC and MCTL_KEEPCONTROL | ||
3688 | * Note: monitor mode also needs MCTL_BCNS_PROMISC, but that is | ||
3689 | * handled in brcms_c_mac_bcn_promisc() | ||
3690 | */ | ||
3691 | if (wlc->monitor) | 3597 | if (wlc->monitor) |
3692 | promisc_bits |= MCTL_PROMISC | MCTL_KEEPCONTROL; | 3598 | promisc_bits |= |
3599 | MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL; | ||
3693 | 3600 | ||
3694 | brcms_b_mctrl(wlc->hw, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits); | 3601 | brcms_b_mctrl(wlc->hw, |
3602 | MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL, | ||
3603 | promisc_bits); | ||
3604 | } | ||
3605 | |||
3606 | void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) | ||
3607 | { | ||
3608 | wlc->bcnmisc_monitor = promisc; | ||
3609 | brcms_c_mac_promisc(wlc); | ||
3695 | } | 3610 | } |
3696 | 3611 | ||
3697 | /* | 3612 | /* |
@@ -3723,7 +3638,6 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) | |||
3723 | } | 3638 | } |
3724 | 3639 | ||
3725 | /* update the various promisc bits */ | 3640 | /* update the various promisc bits */ |
3726 | brcms_c_mac_bcn_promisc(wlc); | ||
3727 | brcms_c_mac_promisc(wlc); | 3641 | brcms_c_mac_promisc(wlc); |
3728 | } | 3642 | } |
3729 | 3643 | ||
@@ -3979,7 +3893,7 @@ static void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) | |||
3979 | 3893 | ||
3980 | void | 3894 | void |
3981 | brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, | 3895 | brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, |
3982 | bool mute, struct txpwr_limits *txpwr) | 3896 | bool mute_tx, struct txpwr_limits *txpwr) |
3983 | { | 3897 | { |
3984 | uint bandunit; | 3898 | uint bandunit; |
3985 | 3899 | ||
@@ -4005,7 +3919,7 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, | |||
4005 | } | 3919 | } |
4006 | } | 3920 | } |
4007 | 3921 | ||
4008 | wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); | 3922 | wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); |
4009 | 3923 | ||
4010 | if (!wlc_hw->up) { | 3924 | if (!wlc_hw->up) { |
4011 | if (wlc_hw->clk) | 3925 | if (wlc_hw->clk) |
@@ -4017,7 +3931,7 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, | |||
4017 | wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); | 3931 | wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); |
4018 | 3932 | ||
4019 | /* Update muting of the channel */ | 3933 | /* Update muting of the channel */ |
4020 | brcms_b_mute(wlc_hw, mute, 0); | 3934 | brcms_b_mute(wlc_hw, mute_tx); |
4021 | } | 3935 | } |
4022 | } | 3936 | } |
4023 | 3937 | ||
@@ -4205,7 +4119,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, | |||
4205 | EDCF_TXOP2USEC(acp_shm.txop); | 4119 | EDCF_TXOP2USEC(acp_shm.txop); |
4206 | acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); | 4120 | acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); |
4207 | 4121 | ||
4208 | if (aci == AC_VI && acp_shm.txop == 0 | 4122 | if (aci == IEEE80211_AC_VI && acp_shm.txop == 0 |
4209 | && acp_shm.aifs < EDCF_AIFSN_MAX) | 4123 | && acp_shm.aifs < EDCF_AIFSN_MAX) |
4210 | acp_shm.aifs++; | 4124 | acp_shm.aifs++; |
4211 | 4125 | ||
@@ -4242,7 +4156,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, | |||
4242 | } | 4156 | } |
4243 | } | 4157 | } |
4244 | 4158 | ||
4245 | void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) | 4159 | static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) |
4246 | { | 4160 | { |
4247 | u16 aci; | 4161 | u16 aci; |
4248 | int i_ac; | 4162 | int i_ac; |
@@ -4255,7 +4169,7 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) | |||
4255 | }; /* ucode needs these parameters during its initialization */ | 4169 | }; /* ucode needs these parameters during its initialization */ |
4256 | const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; | 4170 | const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; |
4257 | 4171 | ||
4258 | for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) { | 4172 | for (i_ac = 0; i_ac < IEEE80211_NUM_ACS; i_ac++, edcf_acp++) { |
4259 | /* find out which ac this set of params applies to */ | 4173 | /* find out which ac this set of params applies to */ |
4260 | aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; | 4174 | aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; |
4261 | 4175 | ||
@@ -4277,17 +4191,6 @@ void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) | |||
4277 | } | 4191 | } |
4278 | } | 4192 | } |
4279 | 4193 | ||
4280 | /* maintain LED behavior in down state */ | ||
4281 | static void brcms_c_down_led_upd(struct brcms_c_info *wlc) | ||
4282 | { | ||
4283 | /* | ||
4284 | * maintain LEDs while in down state, turn on sbclk if | ||
4285 | * not available yet. Turn on sbclk if necessary | ||
4286 | */ | ||
4287 | brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_FLIP); | ||
4288 | brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_FLIP); | ||
4289 | } | ||
4290 | |||
4291 | static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) | 4194 | static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) |
4292 | { | 4195 | { |
4293 | /* Don't start the timer if HWRADIO feature is disabled */ | 4196 | /* Don't start the timer if HWRADIO feature is disabled */ |
@@ -4299,28 +4202,6 @@ static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) | |||
4299 | brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); | 4202 | brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); |
4300 | } | 4203 | } |
4301 | 4204 | ||
4302 | static void brcms_c_radio_disable(struct brcms_c_info *wlc) | ||
4303 | { | ||
4304 | if (!wlc->pub->up) { | ||
4305 | brcms_c_down_led_upd(wlc); | ||
4306 | return; | ||
4307 | } | ||
4308 | |||
4309 | brcms_c_radio_monitor_start(wlc); | ||
4310 | brcms_down(wlc->wl); | ||
4311 | } | ||
4312 | |||
4313 | static void brcms_c_radio_enable(struct brcms_c_info *wlc) | ||
4314 | { | ||
4315 | if (wlc->pub->up) | ||
4316 | return; | ||
4317 | |||
4318 | if (brcms_deviceremoved(wlc)) | ||
4319 | return; | ||
4320 | |||
4321 | brcms_up(wlc->wl); | ||
4322 | } | ||
4323 | |||
4324 | static bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) | 4205 | static bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) |
4325 | { | 4206 | { |
4326 | if (!wlc->radio_monitor) | 4207 | if (!wlc->radio_monitor) |
@@ -4343,18 +4224,6 @@ static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) | |||
4343 | mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); | 4224 | mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); |
4344 | } | 4225 | } |
4345 | 4226 | ||
4346 | /* | ||
4347 | * centralized radio disable/enable function, | ||
4348 | * invoke radio enable/disable after updating hwradio status | ||
4349 | */ | ||
4350 | static void brcms_c_radio_upd(struct brcms_c_info *wlc) | ||
4351 | { | ||
4352 | if (wlc->pub->radio_disabled) | ||
4353 | brcms_c_radio_disable(wlc); | ||
4354 | else | ||
4355 | brcms_c_radio_enable(wlc); | ||
4356 | } | ||
4357 | |||
4358 | /* update hwradio status and return it */ | 4227 | /* update hwradio status and return it */ |
4359 | bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) | 4228 | bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) |
4360 | { | 4229 | { |
@@ -4376,12 +4245,7 @@ static void brcms_c_radio_timer(void *arg) | |||
4376 | return; | 4245 | return; |
4377 | } | 4246 | } |
4378 | 4247 | ||
4379 | /* cap mpc off count */ | ||
4380 | if (wlc->mpc_offcnt < BRCMS_MPC_MAX_DELAYCNT) | ||
4381 | wlc->mpc_offcnt++; | ||
4382 | |||
4383 | brcms_c_radio_hwdisable_upd(wlc); | 4248 | brcms_c_radio_hwdisable_upd(wlc); |
4384 | brcms_c_radio_upd(wlc); | ||
4385 | } | 4249 | } |
4386 | 4250 | ||
4387 | /* common low-level watchdog code */ | 4251 | /* common low-level watchdog code */ |
@@ -4407,60 +4271,6 @@ static void brcms_b_watchdog(void *arg) | |||
4407 | wlc_phy_watchdog(wlc_hw->band->pi); | 4271 | wlc_phy_watchdog(wlc_hw->band->pi); |
4408 | } | 4272 | } |
4409 | 4273 | ||
4410 | static void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) | ||
4411 | { | ||
4412 | bool mpc_radio, radio_state; | ||
4413 | |||
4414 | /* | ||
4415 | * Clear the WL_RADIO_MPC_DISABLE bit when mpc feature is disabled | ||
4416 | * in case the WL_RADIO_MPC_DISABLE bit was set. Stop the radio | ||
4417 | * monitor also when WL_RADIO_MPC_DISABLE is the only reason that | ||
4418 | * the radio is going down. | ||
4419 | */ | ||
4420 | if (!wlc->mpc) { | ||
4421 | if (!wlc->pub->radio_disabled) | ||
4422 | return; | ||
4423 | mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); | ||
4424 | brcms_c_radio_upd(wlc); | ||
4425 | if (!wlc->pub->radio_disabled) | ||
4426 | brcms_c_radio_monitor_stop(wlc); | ||
4427 | return; | ||
4428 | } | ||
4429 | |||
4430 | /* | ||
4431 | * sync ismpc logic with WL_RADIO_MPC_DISABLE bit in | ||
4432 | * wlc->pub->radio_disabled to go ON, always call radio_upd | ||
4433 | * synchronously to go OFF, postpone radio_upd to later when | ||
4434 | * context is safe(e.g. watchdog) | ||
4435 | */ | ||
4436 | radio_state = | ||
4437 | (mboolisset(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE) ? OFF : | ||
4438 | ON); | ||
4439 | mpc_radio = (brcms_c_ismpc(wlc) == true) ? OFF : ON; | ||
4440 | |||
4441 | if (radio_state == ON && mpc_radio == OFF) | ||
4442 | wlc->mpc_delay_off = wlc->mpc_dlycnt; | ||
4443 | else if (radio_state == OFF && mpc_radio == ON) { | ||
4444 | mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); | ||
4445 | brcms_c_radio_upd(wlc); | ||
4446 | if (wlc->mpc_offcnt < BRCMS_MPC_THRESHOLD) | ||
4447 | wlc->mpc_dlycnt = BRCMS_MPC_MAX_DELAYCNT; | ||
4448 | else | ||
4449 | wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; | ||
4450 | } | ||
4451 | /* | ||
4452 | * Below logic is meant to capture the transition from mpc off | ||
4453 | * to mpc on for reasons other than wlc->mpc_delay_off keeping | ||
4454 | * the mpc off. In that case reset wlc->mpc_delay_off to | ||
4455 | * wlc->mpc_dlycnt, so that we restart the countdown of mpc_delay_off | ||
4456 | */ | ||
4457 | if ((wlc->prev_non_delay_mpc == false) && | ||
4458 | (brcms_c_is_non_delay_mpc(wlc) == true) && wlc->mpc_delay_off) | ||
4459 | wlc->mpc_delay_off = wlc->mpc_dlycnt; | ||
4460 | |||
4461 | wlc->prev_non_delay_mpc = brcms_c_is_non_delay_mpc(wlc); | ||
4462 | } | ||
4463 | |||
4464 | /* common watchdog code */ | 4274 | /* common watchdog code */ |
4465 | static void brcms_c_watchdog(void *arg) | 4275 | static void brcms_c_watchdog(void *arg) |
4466 | { | 4276 | { |
@@ -4481,21 +4291,7 @@ static void brcms_c_watchdog(void *arg) | |||
4481 | /* increment second count */ | 4291 | /* increment second count */ |
4482 | wlc->pub->now++; | 4292 | wlc->pub->now++; |
4483 | 4293 | ||
4484 | /* delay radio disable */ | ||
4485 | if (wlc->mpc_delay_off) { | ||
4486 | if (--wlc->mpc_delay_off == 0) { | ||
4487 | mboolset(wlc->pub->radio_disabled, | ||
4488 | WL_RADIO_MPC_DISABLE); | ||
4489 | if (wlc->mpc && brcms_c_ismpc(wlc)) | ||
4490 | wlc->mpc_offcnt = 0; | ||
4491 | } | ||
4492 | } | ||
4493 | |||
4494 | /* mpc sync */ | ||
4495 | brcms_c_radio_mpc_upd(wlc); | ||
4496 | /* radio sync: sw/hw/mpc --> radio_disable/radio_enable */ | ||
4497 | brcms_c_radio_hwdisable_upd(wlc); | 4294 | brcms_c_radio_hwdisable_upd(wlc); |
4498 | brcms_c_radio_upd(wlc); | ||
4499 | /* if radio is disable, driver may be down, quit here */ | 4295 | /* if radio is disable, driver may be down, quit here */ |
4500 | if (wlc->pub->radio_disabled) | 4296 | if (wlc->pub->radio_disabled) |
4501 | return; | 4297 | return; |
@@ -4599,9 +4395,6 @@ static void brcms_c_info_init(struct brcms_c_info *wlc, int unit) | |||
4599 | /* WME QoS mode is Auto by default */ | 4395 | /* WME QoS mode is Auto by default */ |
4600 | wlc->pub->_ampdu = AMPDU_AGG_HOST; | 4396 | wlc->pub->_ampdu = AMPDU_AGG_HOST; |
4601 | wlc->pub->bcmerror = 0; | 4397 | wlc->pub->bcmerror = 0; |
4602 | |||
4603 | /* initialize mpc delay */ | ||
4604 | wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; | ||
4605 | } | 4398 | } |
4606 | 4399 | ||
4607 | static uint brcms_c_attach_module(struct brcms_c_info *wlc) | 4400 | static uint brcms_c_attach_module(struct brcms_c_info *wlc) |
@@ -5259,9 +5052,6 @@ static void brcms_c_ap_upd(struct brcms_c_info *wlc) | |||
5259 | { | 5052 | { |
5260 | /* STA-BSS; short capable */ | 5053 | /* STA-BSS; short capable */ |
5261 | wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; | 5054 | wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; |
5262 | |||
5263 | /* fixup mpc */ | ||
5264 | wlc->mpc = true; | ||
5265 | } | 5055 | } |
5266 | 5056 | ||
5267 | /* Initialize just the hardware when coming out of POR or S3/S5 system states */ | 5057 | /* Initialize just the hardware when coming out of POR or S3/S5 system states */ |
@@ -5376,7 +5166,7 @@ static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) | |||
5376 | if (!wlc->clk) | 5166 | if (!wlc->clk) |
5377 | return; | 5167 | return; |
5378 | 5168 | ||
5379 | for (ac = 0; ac < AC_COUNT; ac++) | 5169 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
5380 | brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), | 5170 | brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), |
5381 | wlc->wme_retries[ac]); | 5171 | wlc->wme_retries[ac]); |
5382 | } | 5172 | } |
@@ -5575,7 +5365,6 @@ uint brcms_c_down(struct brcms_c_info *wlc) | |||
5575 | if (!wlc->pub->up) | 5365 | if (!wlc->pub->up) |
5576 | return callbacks; | 5366 | return callbacks; |
5577 | 5367 | ||
5578 | /* in between, mpc could try to bring down again.. */ | ||
5579 | wlc->going_down = true; | 5368 | wlc->going_down = true; |
5580 | 5369 | ||
5581 | callbacks += brcms_b_bmac_down_prep(wlc->hw); | 5370 | callbacks += brcms_b_bmac_down_prep(wlc->hw); |
@@ -5852,7 +5641,7 @@ int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) | |||
5852 | 5641 | ||
5853 | brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); | 5642 | brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); |
5854 | 5643 | ||
5855 | for (ac = 0; ac < AC_COUNT; ac++) { | 5644 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
5856 | wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], | 5645 | wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], |
5857 | EDCF_SHORT, wlc->SRL); | 5646 | EDCF_SHORT, wlc->SRL); |
5858 | wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], | 5647 | wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], |
@@ -6103,7 +5892,6 @@ void brcms_c_print_txdesc(struct d11txh *txh) | |||
6103 | 5892 | ||
6104 | u8 *rtsph = txh->RTSPhyHeader; | 5893 | u8 *rtsph = txh->RTSPhyHeader; |
6105 | struct ieee80211_rts rts = txh->rts_frame; | 5894 | struct ieee80211_rts rts = txh->rts_frame; |
6106 | char hexbuf[256]; | ||
6107 | 5895 | ||
6108 | /* add plcp header along with txh descriptor */ | 5896 | /* add plcp header along with txh descriptor */ |
6109 | printk(KERN_DEBUG "Raw TxDesc + plcp header:\n"); | 5897 | printk(KERN_DEBUG "Raw TxDesc + plcp header:\n"); |
@@ -6124,17 +5912,16 @@ void brcms_c_print_txdesc(struct d11txh *txh) | |||
6124 | printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); | 5912 | printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); |
6125 | printk(KERN_DEBUG "\n"); | 5913 | printk(KERN_DEBUG "\n"); |
6126 | 5914 | ||
6127 | brcmu_format_hex(hexbuf, iv, sizeof(txh->IV)); | 5915 | print_hex_dump_bytes("SecIV:", DUMP_PREFIX_OFFSET, iv, sizeof(txh->IV)); |
6128 | printk(KERN_DEBUG "SecIV: %s\n", hexbuf); | 5916 | print_hex_dump_bytes("RA:", DUMP_PREFIX_OFFSET, |
6129 | brcmu_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA)); | 5917 | ra, sizeof(txh->TxFrameRA)); |
6130 | printk(KERN_DEBUG "RA: %s\n", hexbuf); | ||
6131 | 5918 | ||
6132 | printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); | 5919 | printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); |
6133 | brcmu_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback)); | 5920 | print_hex_dump_bytes("Fb RTS PLCP:", DUMP_PREFIX_OFFSET, |
6134 | printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); | 5921 | rtspfb, sizeof(txh->RTSPLCPFallback)); |
6135 | printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); | 5922 | printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); |
6136 | brcmu_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback)); | 5923 | print_hex_dump_bytes("PLCP:", DUMP_PREFIX_OFFSET, |
6137 | printk(KERN_DEBUG "PLCP: %s ", hexbuf); | 5924 | fragpfb, sizeof(txh->FragPLCPFallback)); |
6138 | printk(KERN_DEBUG "DUR: %04x", fragdfb); | 5925 | printk(KERN_DEBUG "DUR: %04x", fragdfb); |
6139 | printk(KERN_DEBUG "\n"); | 5926 | printk(KERN_DEBUG "\n"); |
6140 | 5927 | ||
@@ -6149,18 +5936,18 @@ void brcms_c_print_txdesc(struct d11txh *txh) | |||
6149 | printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); | 5936 | printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); |
6150 | printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); | 5937 | printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); |
6151 | 5938 | ||
6152 | brcmu_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader)); | 5939 | print_hex_dump_bytes("RTS PLCP:", DUMP_PREFIX_OFFSET, |
6153 | printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); | 5940 | rtsph, sizeof(txh->RTSPhyHeader)); |
6154 | brcmu_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame)); | 5941 | print_hex_dump_bytes("RTS Frame:", DUMP_PREFIX_OFFSET, |
6155 | printk(KERN_DEBUG "RTS Frame: %s", hexbuf); | 5942 | (u8 *)&rts, sizeof(txh->rts_frame)); |
6156 | printk(KERN_DEBUG "\n"); | 5943 | printk(KERN_DEBUG "\n"); |
6157 | } | 5944 | } |
6158 | #endif /* defined(BCMDBG) */ | 5945 | #endif /* defined(BCMDBG) */ |
6159 | 5946 | ||
6160 | #if defined(BCMDBG) | 5947 | #if defined(BCMDBG) |
6161 | int | 5948 | static int |
6162 | brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, | 5949 | brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, |
6163 | int len) | 5950 | int len) |
6164 | { | 5951 | { |
6165 | int i; | 5952 | int i; |
6166 | char *p = buf; | 5953 | char *p = buf; |
@@ -6916,7 +6703,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, | |||
6916 | qos = ieee80211_is_data_qos(h->frame_control); | 6703 | qos = ieee80211_is_data_qos(h->frame_control); |
6917 | 6704 | ||
6918 | /* compute length of frame in bytes for use in PLCP computations */ | 6705 | /* compute length of frame in bytes for use in PLCP computations */ |
6919 | len = brcmu_pkttotlen(p); | 6706 | len = p->len; |
6920 | phylen = len + FCS_LEN; | 6707 | phylen = len + FCS_LEN; |
6921 | 6708 | ||
6922 | /* Get tx_info */ | 6709 | /* Get tx_info */ |
@@ -8253,12 +8040,6 @@ int brcms_c_get_tx_power(struct brcms_c_info *wlc) | |||
8253 | return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); | 8040 | return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); |
8254 | } | 8041 | } |
8255 | 8042 | ||
8256 | void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc) | ||
8257 | { | ||
8258 | wlc->mpc = mpc; | ||
8259 | brcms_c_radio_mpc_upd(wlc); | ||
8260 | } | ||
8261 | |||
8262 | /* Process received frames */ | 8043 | /* Process received frames */ |
8263 | /* | 8044 | /* |
8264 | * Return true if more frames need to be processed. false otherwise. | 8045 | * Return true if more frames need to be processed. false otherwise. |
@@ -8328,21 +8109,17 @@ static bool | |||
8328 | brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) | 8109 | brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) |
8329 | { | 8110 | { |
8330 | struct sk_buff *p; | 8111 | struct sk_buff *p; |
8331 | struct sk_buff *head = NULL; | 8112 | struct sk_buff *next = NULL; |
8332 | struct sk_buff *tail = NULL; | 8113 | struct sk_buff_head recv_frames; |
8114 | |||
8333 | uint n = 0; | 8115 | uint n = 0; |
8334 | uint bound_limit = bound ? RXBND : -1; | 8116 | uint bound_limit = bound ? RXBND : -1; |
8335 | 8117 | ||
8336 | BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); | 8118 | BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); |
8337 | /* gather received frames */ | 8119 | skb_queue_head_init(&recv_frames); |
8338 | while ((p = dma_rx(wlc_hw->di[fifo]))) { | ||
8339 | 8120 | ||
8340 | if (!tail) | 8121 | /* gather received frames */ |
8341 | head = tail = p; | 8122 | while (dma_rx(wlc_hw->di[fifo], &recv_frames)) { |
8342 | else { | ||
8343 | tail->prev = p; | ||
8344 | tail = p; | ||
8345 | } | ||
8346 | 8123 | ||
8347 | /* !give others some time to run! */ | 8124 | /* !give others some time to run! */ |
8348 | if (++n >= bound_limit) | 8125 | if (++n >= bound_limit) |
@@ -8353,12 +8130,11 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) | |||
8353 | dma_rxfill(wlc_hw->di[fifo]); | 8130 | dma_rxfill(wlc_hw->di[fifo]); |
8354 | 8131 | ||
8355 | /* process each frame */ | 8132 | /* process each frame */ |
8356 | while ((p = head) != NULL) { | 8133 | skb_queue_walk_safe(&recv_frames, p, next) { |
8357 | struct d11rxhdr_le *rxh_le; | 8134 | struct d11rxhdr_le *rxh_le; |
8358 | struct d11rxhdr *rxh; | 8135 | struct d11rxhdr *rxh; |
8359 | head = head->prev; | ||
8360 | p->prev = NULL; | ||
8361 | 8136 | ||
8137 | skb_unlink(p, &recv_frames); | ||
8362 | rxh_le = (struct d11rxhdr_le *)p->data; | 8138 | rxh_le = (struct d11rxhdr_le *)p->data; |
8363 | rxh = (struct d11rxhdr *)p->data; | 8139 | rxh = (struct d11rxhdr *)p->data; |
8364 | 8140 | ||
@@ -8448,8 +8224,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) | |||
8448 | printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", | 8224 | printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", |
8449 | __func__, wlc_hw->sih->chip, | 8225 | __func__, wlc_hw->sih->chip, |
8450 | wlc_hw->sih->chiprev); | 8226 | wlc_hw->sih->chiprev); |
8451 | /* big hammer */ | 8227 | brcms_fatal_error(wlc_hw->wlc->wl); |
8452 | brcms_init(wlc->wl); | ||
8453 | } | 8228 | } |
8454 | 8229 | ||
8455 | /* gptimer timeout */ | 8230 | /* gptimer timeout */ |
@@ -8470,15 +8245,14 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) | |||
8470 | return wlc->macintstatus != 0; | 8245 | return wlc->macintstatus != 0; |
8471 | 8246 | ||
8472 | fatal: | 8247 | fatal: |
8473 | brcms_init(wlc->wl); | 8248 | brcms_fatal_error(wlc_hw->wlc->wl); |
8474 | return wlc->macintstatus != 0; | 8249 | return wlc->macintstatus != 0; |
8475 | } | 8250 | } |
8476 | 8251 | ||
8477 | void brcms_c_init(struct brcms_c_info *wlc) | 8252 | void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) |
8478 | { | 8253 | { |
8479 | struct d11regs __iomem *regs; | 8254 | struct d11regs __iomem *regs; |
8480 | u16 chanspec; | 8255 | u16 chanspec; |
8481 | bool mute = false; | ||
8482 | 8256 | ||
8483 | BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); | 8257 | BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); |
8484 | 8258 | ||
@@ -8494,7 +8268,7 @@ void brcms_c_init(struct brcms_c_info *wlc) | |||
8494 | else | 8268 | else |
8495 | chanspec = brcms_c_init_chanspec(wlc); | 8269 | chanspec = brcms_c_init_chanspec(wlc); |
8496 | 8270 | ||
8497 | brcms_b_init(wlc->hw, chanspec, mute); | 8271 | brcms_b_init(wlc->hw, chanspec); |
8498 | 8272 | ||
8499 | /* update beacon listen interval */ | 8273 | /* update beacon listen interval */ |
8500 | brcms_c_bcn_li_upd(wlc); | 8274 | brcms_c_bcn_li_upd(wlc); |
@@ -8560,15 +8334,16 @@ void brcms_c_init(struct brcms_c_info *wlc) | |||
8560 | /* ..now really unleash hell (allow the MAC out of suspend) */ | 8334 | /* ..now really unleash hell (allow the MAC out of suspend) */ |
8561 | brcms_c_enable_mac(wlc); | 8335 | brcms_c_enable_mac(wlc); |
8562 | 8336 | ||
8337 | /* suspend the tx fifos and mute the phy for preism cac time */ | ||
8338 | if (mute_tx) | ||
8339 | brcms_b_mute(wlc->hw, true); | ||
8340 | |||
8563 | /* clear tx flow control */ | 8341 | /* clear tx flow control */ |
8564 | brcms_c_txflowcontrol_reset(wlc); | 8342 | brcms_c_txflowcontrol_reset(wlc); |
8565 | 8343 | ||
8566 | /* enable the RF Disable Delay timer */ | 8344 | /* enable the RF Disable Delay timer */ |
8567 | W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); | 8345 | W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); |
8568 | 8346 | ||
8569 | /* initialize mpc delay */ | ||
8570 | wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; | ||
8571 | |||
8572 | /* | 8347 | /* |
8573 | * Initialize WME parameters; if they haven't been set by some other | 8348 | * Initialize WME parameters; if they haven't been set by some other |
8574 | * mechanism (IOVar, etc) then read them from the hardware. | 8349 | * mechanism (IOVar, etc) then read them from the hardware. |
@@ -8577,7 +8352,7 @@ void brcms_c_init(struct brcms_c_info *wlc) | |||
8577 | /* Uninitialized; read from HW */ | 8352 | /* Uninitialized; read from HW */ |
8578 | int ac; | 8353 | int ac; |
8579 | 8354 | ||
8580 | for (ac = 0; ac < AC_COUNT; ac++) | 8355 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
8581 | wlc->wme_retries[ac] = | 8356 | wlc->wme_retries[ac] = |
8582 | brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); | 8357 | brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); |
8583 | } | 8358 | } |
@@ -8754,8 +8529,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, | |||
8754 | brcms_c_ht_update_sgi_rx(wlc, 0); | 8529 | brcms_c_ht_update_sgi_rx(wlc, 0); |
8755 | } | 8530 | } |
8756 | 8531 | ||
8757 | /* initialize radio_mpc_disable according to wlc->mpc */ | ||
8758 | brcms_c_radio_mpc_upd(wlc); | ||
8759 | brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); | 8532 | brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); |
8760 | 8533 | ||
8761 | if (perr) | 8534 | if (perr) |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index c0e0fcfdfaf8..251c350b3164 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h | |||
@@ -44,8 +44,6 @@ | |||
44 | /* transmit buffer max headroom for protocol headers */ | 44 | /* transmit buffer max headroom for protocol headers */ |
45 | #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN) | 45 | #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN) |
46 | 46 | ||
47 | #define AC_COUNT 4 | ||
48 | |||
49 | /* Macros for doing definition and get/set of bitfields | 47 | /* Macros for doing definition and get/set of bitfields |
50 | * Usage example, e.g. a three-bit field (bits 4-6): | 48 | * Usage example, e.g. a three-bit field (bits 4-6): |
51 | * #define <NAME>_M BITFIELD_MASK(3) | 49 | * #define <NAME>_M BITFIELD_MASK(3) |
@@ -427,11 +425,6 @@ struct brcms_txq_info { | |||
427 | * bandinit_pending: track band init in auto band. | 425 | * bandinit_pending: track band init in auto band. |
428 | * radio_monitor: radio timer is running. | 426 | * radio_monitor: radio timer is running. |
429 | * going_down: down path intermediate variable. | 427 | * going_down: down path intermediate variable. |
430 | * mpc: enable minimum power consumption. | ||
431 | * mpc_dlycnt: # of watchdog cnt before turn disable radio. | ||
432 | * mpc_offcnt: # of watchdog cnt that radio is disabled. | ||
433 | * mpc_delay_off: delay radio disable by # of watchdog cnt. | ||
434 | * prev_non_delay_mpc: prev state brcms_c_is_non_delay_mpc. | ||
435 | * wdtimer: timer for watchdog routine. | 428 | * wdtimer: timer for watchdog routine. |
436 | * radio_timer: timer for hw radio button monitor routine. | 429 | * radio_timer: timer for hw radio button monitor routine. |
437 | * monitor: monitor (MPDU sniffing) mode. | 430 | * monitor: monitor (MPDU sniffing) mode. |
@@ -441,7 +434,7 @@ struct brcms_txq_info { | |||
441 | * bcn_li_dtim: beacon listen interval in # dtims. | 434 | * bcn_li_dtim: beacon listen interval in # dtims. |
442 | * WDarmed: watchdog timer is armed. | 435 | * WDarmed: watchdog timer is armed. |
443 | * WDlast: last time wlc_watchdog() was called. | 436 | * WDlast: last time wlc_watchdog() was called. |
444 | * edcf_txop[AC_COUNT]: current txop for each ac. | 437 | * edcf_txop[IEEE80211_NUM_ACS]: current txop for each ac. |
445 | * wme_retries: per-AC retry limits. | 438 | * wme_retries: per-AC retry limits. |
446 | * tx_prec_map: Precedence map based on HW FIFO space. | 439 | * tx_prec_map: Precedence map based on HW FIFO space. |
447 | * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME. | 440 | * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME. |
@@ -522,12 +515,6 @@ struct brcms_c_info { | |||
522 | bool radio_monitor; | 515 | bool radio_monitor; |
523 | bool going_down; | 516 | bool going_down; |
524 | 517 | ||
525 | bool mpc; | ||
526 | u8 mpc_dlycnt; | ||
527 | u8 mpc_offcnt; | ||
528 | u8 mpc_delay_off; | ||
529 | u8 prev_non_delay_mpc; | ||
530 | |||
531 | struct brcms_timer *wdtimer; | 518 | struct brcms_timer *wdtimer; |
532 | struct brcms_timer *radio_timer; | 519 | struct brcms_timer *radio_timer; |
533 | 520 | ||
@@ -546,9 +533,9 @@ struct brcms_c_info { | |||
546 | u32 WDlast; | 533 | u32 WDlast; |
547 | 534 | ||
548 | /* WME */ | 535 | /* WME */ |
549 | u16 edcf_txop[AC_COUNT]; | 536 | u16 edcf_txop[IEEE80211_NUM_ACS]; |
550 | 537 | ||
551 | u16 wme_retries[AC_COUNT]; | 538 | u16 wme_retries[IEEE80211_NUM_ACS]; |
552 | u16 tx_prec_map; | 539 | u16 tx_prec_map; |
553 | u16 fifo2prec_map[NFIFO]; | 540 | u16 fifo2prec_map[NFIFO]; |
554 | 541 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index a3149254cbcd..e17edf7e6833 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | |||
@@ -112,7 +112,7 @@ static const struct chan_info_basic chan_info_all[] = { | |||
112 | {216, 50800} | 112 | {216, 50800} |
113 | }; | 113 | }; |
114 | 114 | ||
115 | const u8 ofdm_rate_lookup[] = { | 115 | static const u8 ofdm_rate_lookup[] = { |
116 | 116 | ||
117 | BRCM_RATE_48M, | 117 | BRCM_RATE_48M, |
118 | BRCM_RATE_24M, | 118 | BRCM_RATE_24M, |
@@ -190,15 +190,7 @@ u16 read_radio_reg(struct brcms_phy *pi, u16 addr) | |||
190 | data = R_REG(&pi->regs->radioregdata); | 190 | data = R_REG(&pi->regs->radioregdata); |
191 | } else { | 191 | } else { |
192 | W_REG_FLUSH(&pi->regs->phy4waddr, addr); | 192 | W_REG_FLUSH(&pi->regs->phy4waddr, addr); |
193 | |||
194 | #ifdef __ARM_ARCH_4T__ | ||
195 | __asm__(" .align 4 "); | ||
196 | __asm__(" nop "); | ||
197 | data = R_REG(&pi->regs->phy4wdatalo); | ||
198 | #else | ||
199 | data = R_REG(&pi->regs->phy4wdatalo); | 193 | data = R_REG(&pi->regs->phy4wdatalo); |
200 | #endif | ||
201 | |||
202 | } | 194 | } |
203 | pi->phy_wreg = 0; | 195 | pi->phy_wreg = 0; |
204 | 196 | ||
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h index bea85241a244..5f9478b1c993 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h | |||
@@ -774,11 +774,6 @@ struct brcms_phy { | |||
774 | s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ]; | 774 | s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ]; |
775 | u8 nphy_noise_index; | 775 | u8 nphy_noise_index; |
776 | 776 | ||
777 | u8 nphy_txpid2g[PHY_CORE_NUM_2]; | ||
778 | u8 nphy_txpid5g[PHY_CORE_NUM_2]; | ||
779 | u8 nphy_txpid5gl[PHY_CORE_NUM_2]; | ||
780 | u8 nphy_txpid5gh[PHY_CORE_NUM_2]; | ||
781 | |||
782 | bool nphy_gain_boost; | 777 | bool nphy_gain_boost; |
783 | bool nphy_elna_gain_config; | 778 | bool nphy_elna_gain_config; |
784 | u16 old_bphy_test; | 779 | u16 old_bphy_test; |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index cd19c2f7a347..ec9b56639d54 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "phy_radio.h" | 29 | #include "phy_radio.h" |
30 | #include "phyreg_n.h" | 30 | #include "phyreg_n.h" |
31 | #include "phytbl_n.h" | 31 | #include "phytbl_n.h" |
32 | #include "soc.h" | ||
32 | 33 | ||
33 | #define READ_RADIO_REG2(pi, radio_type, jspace, core, reg_name) \ | 34 | #define READ_RADIO_REG2(pi, radio_type, jspace, core, reg_name) \ |
34 | read_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ | 35 | read_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ |
@@ -14417,12 +14418,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) | |||
14417 | switch (band_num) { | 14418 | switch (band_num) { |
14418 | case 0: | 14419 | case 0: |
14419 | 14420 | ||
14420 | pi->nphy_txpid2g[PHY_CORE_0] = | ||
14421 | (u8) wlapi_getintvar(shim, | ||
14422 | BRCMS_SROM_TXPID2GA0); | ||
14423 | pi->nphy_txpid2g[PHY_CORE_1] = | ||
14424 | (u8) wlapi_getintvar(shim, | ||
14425 | BRCMS_SROM_TXPID2GA1); | ||
14426 | pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = | 14421 | pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = |
14427 | (s8) wlapi_getintvar(shim, | 14422 | (s8) wlapi_getintvar(shim, |
14428 | BRCMS_SROM_MAXP2GA0); | 14423 | BRCMS_SROM_MAXP2GA0); |
@@ -14486,12 +14481,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) | |||
14486 | break; | 14481 | break; |
14487 | case 1: | 14482 | case 1: |
14488 | 14483 | ||
14489 | pi->nphy_txpid5g[PHY_CORE_0] = | ||
14490 | (u8) wlapi_getintvar(shim, | ||
14491 | BRCMS_SROM_TXPID5GA0); | ||
14492 | pi->nphy_txpid5g[PHY_CORE_1] = | ||
14493 | (u8) wlapi_getintvar(shim, | ||
14494 | BRCMS_SROM_TXPID5GA1); | ||
14495 | pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = | 14484 | pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = |
14496 | (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GA0); | 14485 | (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GA0); |
14497 | pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = | 14486 | pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = |
@@ -14551,12 +14540,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) | |||
14551 | break; | 14540 | break; |
14552 | case 2: | 14541 | case 2: |
14553 | 14542 | ||
14554 | pi->nphy_txpid5gl[0] = | ||
14555 | (u8) wlapi_getintvar(shim, | ||
14556 | BRCMS_SROM_TXPID5GLA0); | ||
14557 | pi->nphy_txpid5gl[1] = | ||
14558 | (u8) wlapi_getintvar(shim, | ||
14559 | BRCMS_SROM_TXPID5GLA1); | ||
14560 | pi->nphy_pwrctrl_info[0].max_pwr_5gl = | 14543 | pi->nphy_pwrctrl_info[0].max_pwr_5gl = |
14561 | (s8) wlapi_getintvar(shim, | 14544 | (s8) wlapi_getintvar(shim, |
14562 | BRCMS_SROM_MAXP5GLA0); | 14545 | BRCMS_SROM_MAXP5GLA0); |
@@ -14615,12 +14598,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) | |||
14615 | break; | 14598 | break; |
14616 | case 3: | 14599 | case 3: |
14617 | 14600 | ||
14618 | pi->nphy_txpid5gh[0] = | ||
14619 | (u8) wlapi_getintvar(shim, | ||
14620 | BRCMS_SROM_TXPID5GHA0); | ||
14621 | pi->nphy_txpid5gh[1] = | ||
14622 | (u8) wlapi_getintvar(shim, | ||
14623 | BRCMS_SROM_TXPID5GHA1); | ||
14624 | pi->nphy_pwrctrl_info[0].max_pwr_5gh = | 14601 | pi->nphy_pwrctrl_info[0].max_pwr_5gh = |
14625 | (s8) wlapi_getintvar(shim, | 14602 | (s8) wlapi_getintvar(shim, |
14626 | BRCMS_SROM_MAXP5GHA0); | 14603 | BRCMS_SROM_MAXP5GHA0); |
@@ -27994,20 +27971,11 @@ void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) | |||
27994 | chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); | 27971 | chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); |
27995 | switch (chan_freq_range) { | 27972 | switch (chan_freq_range) { |
27996 | case WL_CHAN_FREQ_RANGE_2G: | 27973 | case WL_CHAN_FREQ_RANGE_2G: |
27997 | txpi[0] = pi->nphy_txpid2g[0]; | ||
27998 | txpi[1] = pi->nphy_txpid2g[1]; | ||
27999 | break; | ||
28000 | case WL_CHAN_FREQ_RANGE_5GL: | 27974 | case WL_CHAN_FREQ_RANGE_5GL: |
28001 | txpi[0] = pi->nphy_txpid5gl[0]; | ||
28002 | txpi[1] = pi->nphy_txpid5gl[1]; | ||
28003 | break; | ||
28004 | case WL_CHAN_FREQ_RANGE_5GM: | 27975 | case WL_CHAN_FREQ_RANGE_5GM: |
28005 | txpi[0] = pi->nphy_txpid5g[0]; | ||
28006 | txpi[1] = pi->nphy_txpid5g[1]; | ||
28007 | break; | ||
28008 | case WL_CHAN_FREQ_RANGE_5GH: | 27976 | case WL_CHAN_FREQ_RANGE_5GH: |
28009 | txpi[0] = pi->nphy_txpid5gh[0]; | 27977 | txpi[0] = 0; |
28010 | txpi[1] = pi->nphy_txpid5gh[1]; | 27978 | txpi[1] = 0; |
28011 | break; | 27979 | break; |
28012 | default: | 27980 | default: |
28013 | txpi[0] = txpi[1] = 91; | 27981 | txpi[0] = txpi[1] = 91; |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c index 3b36e3acfd74..12ba575f5785 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "pub.h" | 23 | #include "pub.h" |
24 | #include "aiutils.h" | 24 | #include "aiutils.h" |
25 | #include "pmu.h" | 25 | #include "pmu.h" |
26 | #include "soc.h" | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * external LPO crystal frequency | 29 | * external LPO crystal frequency |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 37bb2dcc113f..21ccf3a03987 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h | |||
@@ -170,22 +170,6 @@ enum brcms_srom_id { | |||
170 | BRCMS_SROM_TSSIPOS2G, | 170 | BRCMS_SROM_TSSIPOS2G, |
171 | BRCMS_SROM_TSSIPOS5G, | 171 | BRCMS_SROM_TSSIPOS5G, |
172 | BRCMS_SROM_TXCHAIN, | 172 | BRCMS_SROM_TXCHAIN, |
173 | BRCMS_SROM_TXPID2GA0, | ||
174 | BRCMS_SROM_TXPID2GA1, | ||
175 | BRCMS_SROM_TXPID2GA2, | ||
176 | BRCMS_SROM_TXPID2GA3, | ||
177 | BRCMS_SROM_TXPID5GA0, | ||
178 | BRCMS_SROM_TXPID5GA1, | ||
179 | BRCMS_SROM_TXPID5GA2, | ||
180 | BRCMS_SROM_TXPID5GA3, | ||
181 | BRCMS_SROM_TXPID5GHA0, | ||
182 | BRCMS_SROM_TXPID5GHA1, | ||
183 | BRCMS_SROM_TXPID5GHA2, | ||
184 | BRCMS_SROM_TXPID5GHA3, | ||
185 | BRCMS_SROM_TXPID5GLA0, | ||
186 | BRCMS_SROM_TXPID5GLA1, | ||
187 | BRCMS_SROM_TXPID5GLA2, | ||
188 | BRCMS_SROM_TXPID5GLA3, | ||
189 | /* | 173 | /* |
190 | * per-path identifiers (see srom.c) | 174 | * per-path identifiers (see srom.c) |
191 | */ | 175 | */ |
@@ -225,10 +209,6 @@ enum brcms_srom_id { | |||
225 | BRCMS_SROM_PA2GW2A1, | 209 | BRCMS_SROM_PA2GW2A1, |
226 | BRCMS_SROM_PA2GW2A2, | 210 | BRCMS_SROM_PA2GW2A2, |
227 | BRCMS_SROM_PA2GW2A3, | 211 | BRCMS_SROM_PA2GW2A3, |
228 | BRCMS_SROM_PA2GW3A0, | ||
229 | BRCMS_SROM_PA2GW3A1, | ||
230 | BRCMS_SROM_PA2GW3A2, | ||
231 | BRCMS_SROM_PA2GW3A3, | ||
232 | BRCMS_SROM_PA5GHW0A0, | 212 | BRCMS_SROM_PA5GHW0A0, |
233 | BRCMS_SROM_PA5GHW0A1, | 213 | BRCMS_SROM_PA5GHW0A1, |
234 | BRCMS_SROM_PA5GHW0A2, | 214 | BRCMS_SROM_PA5GHW0A2, |
@@ -241,10 +221,6 @@ enum brcms_srom_id { | |||
241 | BRCMS_SROM_PA5GHW2A1, | 221 | BRCMS_SROM_PA5GHW2A1, |
242 | BRCMS_SROM_PA5GHW2A2, | 222 | BRCMS_SROM_PA5GHW2A2, |
243 | BRCMS_SROM_PA5GHW2A3, | 223 | BRCMS_SROM_PA5GHW2A3, |
244 | BRCMS_SROM_PA5GHW3A0, | ||
245 | BRCMS_SROM_PA5GHW3A1, | ||
246 | BRCMS_SROM_PA5GHW3A2, | ||
247 | BRCMS_SROM_PA5GHW3A3, | ||
248 | BRCMS_SROM_PA5GLW0A0, | 224 | BRCMS_SROM_PA5GLW0A0, |
249 | BRCMS_SROM_PA5GLW0A1, | 225 | BRCMS_SROM_PA5GLW0A1, |
250 | BRCMS_SROM_PA5GLW0A2, | 226 | BRCMS_SROM_PA5GLW0A2, |
@@ -257,10 +233,6 @@ enum brcms_srom_id { | |||
257 | BRCMS_SROM_PA5GLW2A1, | 233 | BRCMS_SROM_PA5GLW2A1, |
258 | BRCMS_SROM_PA5GLW2A2, | 234 | BRCMS_SROM_PA5GLW2A2, |
259 | BRCMS_SROM_PA5GLW2A3, | 235 | BRCMS_SROM_PA5GLW2A3, |
260 | BRCMS_SROM_PA5GLW3A0, | ||
261 | BRCMS_SROM_PA5GLW3A1, | ||
262 | BRCMS_SROM_PA5GLW3A2, | ||
263 | BRCMS_SROM_PA5GLW3A3, | ||
264 | BRCMS_SROM_PA5GW0A0, | 236 | BRCMS_SROM_PA5GW0A0, |
265 | BRCMS_SROM_PA5GW0A1, | 237 | BRCMS_SROM_PA5GW0A1, |
266 | BRCMS_SROM_PA5GW0A2, | 238 | BRCMS_SROM_PA5GW0A2, |
@@ -273,14 +245,9 @@ enum brcms_srom_id { | |||
273 | BRCMS_SROM_PA5GW2A1, | 245 | BRCMS_SROM_PA5GW2A1, |
274 | BRCMS_SROM_PA5GW2A2, | 246 | BRCMS_SROM_PA5GW2A2, |
275 | BRCMS_SROM_PA5GW2A3, | 247 | BRCMS_SROM_PA5GW2A3, |
276 | BRCMS_SROM_PA5GW3A0, | ||
277 | BRCMS_SROM_PA5GW3A1, | ||
278 | BRCMS_SROM_PA5GW3A2, | ||
279 | BRCMS_SROM_PA5GW3A3, | ||
280 | }; | 248 | }; |
281 | 249 | ||
282 | #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ | 250 | #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ |
283 | #define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ | ||
284 | 251 | ||
285 | /* phy types */ | 252 | /* phy types */ |
286 | #define PHY_TYPE_A 0 /* Phy type A */ | 253 | #define PHY_TYPE_A 0 /* Phy type A */ |
@@ -414,7 +381,6 @@ struct brcms_pub { | |||
414 | uint _nbands; /* # bands supported */ | 381 | uint _nbands; /* # bands supported */ |
415 | uint now; /* # elapsed seconds */ | 382 | uint now; /* # elapsed seconds */ |
416 | 383 | ||
417 | bool promisc; /* promiscuous destination address */ | ||
418 | bool delayed_down; /* down delayed */ | 384 | bool delayed_down; /* down delayed */ |
419 | bool associated; /* true:part of [I]BSS, false: not */ | 385 | bool associated; /* true:part of [I]BSS, false: not */ |
420 | /* (union of stas_associated, aps_associated) */ | 386 | /* (union of stas_associated, aps_associated) */ |
@@ -572,7 +538,7 @@ extern int brcms_c_up(struct brcms_c_info *wlc); | |||
572 | extern uint brcms_c_down(struct brcms_c_info *wlc); | 538 | extern uint brcms_c_down(struct brcms_c_info *wlc); |
573 | 539 | ||
574 | extern bool brcms_c_chipmatch(u16 vendor, u16 device); | 540 | extern bool brcms_c_chipmatch(u16 vendor, u16 device); |
575 | extern void brcms_c_init(struct brcms_c_info *wlc); | 541 | extern void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx); |
576 | extern void brcms_c_reset(struct brcms_c_info *wlc); | 542 | extern void brcms_c_reset(struct brcms_c_info *wlc); |
577 | 543 | ||
578 | extern void brcms_c_intrson(struct brcms_c_info *wlc); | 544 | extern void brcms_c_intrson(struct brcms_c_info *wlc); |
@@ -628,7 +594,7 @@ extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, | |||
628 | u8 interval); | 594 | u8 interval); |
629 | extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); | 595 | extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); |
630 | extern int brcms_c_get_tx_power(struct brcms_c_info *wlc); | 596 | extern int brcms_c_get_tx_power(struct brcms_c_info *wlc); |
631 | extern void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc); | ||
632 | extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); | 597 | extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); |
598 | extern void brcms_c_mute(struct brcms_c_info *wlc, bool on); | ||
633 | 599 | ||
634 | #endif /* _BRCM_PUB_H_ */ | 600 | #endif /* _BRCM_PUB_H_ */ |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/rate.h b/drivers/net/wireless/brcm80211/brcmsmac/rate.h index e7b9dc2f2731..980d578825cc 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/rate.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/rate.h | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | #include "types.h" | 20 | #include "types.h" |
21 | #include "d11.h" | 21 | #include "d11.h" |
22 | #include "phy_hal.h" | ||
22 | 23 | ||
23 | extern const u8 rate_info[]; | 24 | extern const u8 rate_info[]; |
24 | extern const struct brcms_c_rateset cck_ofdm_mimo_rates; | 25 | extern const struct brcms_c_rateset cck_ofdm_mimo_rates; |
@@ -198,11 +199,9 @@ static inline u8 cck_rspec(u8 cck) | |||
198 | 199 | ||
199 | /* Convert encoded rate value in plcp header to numerical rates in 500 KHz | 200 | /* Convert encoded rate value in plcp header to numerical rates in 500 KHz |
200 | * increments */ | 201 | * increments */ |
201 | extern const u8 ofdm_rate_lookup[]; | ||
202 | |||
203 | static inline u8 ofdm_phy2mac_rate(u8 rlpt) | 202 | static inline u8 ofdm_phy2mac_rate(u8 rlpt) |
204 | { | 203 | { |
205 | return ofdm_rate_lookup[rlpt & 0x7]; | 204 | return wlc_phy_get_ofdm_rate_lookup()[rlpt & 0x7]; |
206 | } | 205 | } |
207 | 206 | ||
208 | static inline u8 cck_phy2mac_rate(u8 signal) | 207 | static inline u8 cck_phy2mac_rate(u8 signal) |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 99f791048e84..b6987ea9fc68 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "aiutils.h" | 28 | #include "aiutils.h" |
29 | #include "otp.h" | 29 | #include "otp.h" |
30 | #include "srom.h" | 30 | #include "srom.h" |
31 | #include "soc.h" | ||
31 | 32 | ||
32 | /* | 33 | /* |
33 | * SROM CRC8 polynomial value: | 34 | * SROM CRC8 polynomial value: |
@@ -62,9 +63,6 @@ | |||
62 | #define SROM_MACHI_ET1 42 | 63 | #define SROM_MACHI_ET1 42 |
63 | #define SROM_MACMID_ET1 43 | 64 | #define SROM_MACMID_ET1 43 |
64 | #define SROM_MACLO_ET1 44 | 65 | #define SROM_MACLO_ET1 44 |
65 | #define SROM3_MACHI 37 | ||
66 | #define SROM3_MACMID 38 | ||
67 | #define SROM3_MACLO 39 | ||
68 | 66 | ||
69 | #define SROM_BXARSSI2G 40 | 67 | #define SROM_BXARSSI2G 40 |
70 | #define SROM_BXARSSI5G 41 | 68 | #define SROM_BXARSSI5G 41 |
@@ -101,7 +99,6 @@ | |||
101 | 99 | ||
102 | #define SROM_BFL 57 | 100 | #define SROM_BFL 57 |
103 | #define SROM_BFL2 28 | 101 | #define SROM_BFL2 28 |
104 | #define SROM3_BFL2 61 | ||
105 | 102 | ||
106 | #define SROM_AG10 58 | 103 | #define SROM_AG10 58 |
107 | 104 | ||
@@ -109,99 +106,16 @@ | |||
109 | 106 | ||
110 | #define SROM_OPO 60 | 107 | #define SROM_OPO 60 |
111 | 108 | ||
112 | #define SROM3_LEDDC 62 | ||
113 | |||
114 | #define SROM_CRCREV 63 | 109 | #define SROM_CRCREV 63 |
115 | 110 | ||
116 | /* SROM Rev 4: Reallocate the software part of the srom to accommodate | ||
117 | * MIMO features. It assumes up to two PCIE functions and 440 bytes | ||
118 | * of usable srom i.e. the usable storage in chips with OTP that | ||
119 | * implements hardware redundancy. | ||
120 | */ | ||
121 | |||
122 | #define SROM4_WORDS 220 | 111 | #define SROM4_WORDS 220 |
123 | 112 | ||
124 | #define SROM4_SIGN 32 | ||
125 | #define SROM4_SIGNATURE 0x5372 | ||
126 | |||
127 | #define SROM4_BREV 33 | ||
128 | |||
129 | #define SROM4_BFL0 34 | ||
130 | #define SROM4_BFL1 35 | ||
131 | #define SROM4_BFL2 36 | ||
132 | #define SROM4_BFL3 37 | ||
133 | #define SROM5_BFL0 37 | ||
134 | #define SROM5_BFL1 38 | ||
135 | #define SROM5_BFL2 39 | ||
136 | #define SROM5_BFL3 40 | ||
137 | |||
138 | #define SROM4_MACHI 38 | ||
139 | #define SROM4_MACMID 39 | ||
140 | #define SROM4_MACLO 40 | ||
141 | #define SROM5_MACHI 41 | ||
142 | #define SROM5_MACMID 42 | ||
143 | #define SROM5_MACLO 43 | ||
144 | |||
145 | #define SROM4_CCODE 41 | ||
146 | #define SROM4_REGREV 42 | ||
147 | #define SROM5_CCODE 34 | ||
148 | #define SROM5_REGREV 35 | ||
149 | |||
150 | #define SROM4_LEDBH10 43 | ||
151 | #define SROM4_LEDBH32 44 | ||
152 | #define SROM5_LEDBH10 59 | ||
153 | #define SROM5_LEDBH32 60 | ||
154 | |||
155 | #define SROM4_LEDDC 45 | ||
156 | #define SROM5_LEDDC 45 | ||
157 | |||
158 | #define SROM4_AA 46 | ||
159 | |||
160 | #define SROM4_AG10 47 | ||
161 | #define SROM4_AG32 48 | ||
162 | |||
163 | #define SROM4_TXPID2G 49 | ||
164 | #define SROM4_TXPID5G 51 | ||
165 | #define SROM4_TXPID5GL 53 | ||
166 | #define SROM4_TXPID5GH 55 | ||
167 | |||
168 | #define SROM4_TXRXC 61 | ||
169 | #define SROM4_TXCHAIN_MASK 0x000f | 113 | #define SROM4_TXCHAIN_MASK 0x000f |
170 | #define SROM4_TXCHAIN_SHIFT 0 | ||
171 | #define SROM4_RXCHAIN_MASK 0x00f0 | 114 | #define SROM4_RXCHAIN_MASK 0x00f0 |
172 | #define SROM4_RXCHAIN_SHIFT 4 | ||
173 | #define SROM4_SWITCH_MASK 0xff00 | 115 | #define SROM4_SWITCH_MASK 0xff00 |
174 | #define SROM4_SWITCH_SHIFT 8 | ||
175 | 116 | ||
176 | /* Per-path fields */ | 117 | /* Per-path fields */ |
177 | #define MAX_PATH_SROM 4 | 118 | #define MAX_PATH_SROM 4 |
178 | #define SROM4_PATH0 64 | ||
179 | #define SROM4_PATH1 87 | ||
180 | #define SROM4_PATH2 110 | ||
181 | #define SROM4_PATH3 133 | ||
182 | |||
183 | #define SROM4_2G_ITT_MAXP 0 | ||
184 | #define SROM4_2G_PA 1 | ||
185 | #define SROM4_5G_ITT_MAXP 5 | ||
186 | #define SROM4_5GLH_MAXP 6 | ||
187 | #define SROM4_5G_PA 7 | ||
188 | #define SROM4_5GL_PA 11 | ||
189 | #define SROM4_5GH_PA 15 | ||
190 | |||
191 | /* All the miriad power offsets */ | ||
192 | #define SROM4_2G_CCKPO 156 | ||
193 | #define SROM4_2G_OFDMPO 157 | ||
194 | #define SROM4_5G_OFDMPO 159 | ||
195 | #define SROM4_5GL_OFDMPO 161 | ||
196 | #define SROM4_5GH_OFDMPO 163 | ||
197 | #define SROM4_2G_MCSPO 165 | ||
198 | #define SROM4_5G_MCSPO 173 | ||
199 | #define SROM4_5GL_MCSPO 181 | ||
200 | #define SROM4_5GH_MCSPO 189 | ||
201 | #define SROM4_CDDPO 197 | ||
202 | #define SROM4_STBCPO 198 | ||
203 | #define SROM4_BW40PO 199 | ||
204 | #define SROM4_BWDUPPO 200 | ||
205 | 119 | ||
206 | #define SROM4_CRCREV 219 | 120 | #define SROM4_CRCREV 219 |
207 | 121 | ||
@@ -424,103 +338,32 @@ struct brcms_varbuf { | |||
424 | static const struct brcms_sromvar pci_sromvars[] = { | 338 | static const struct brcms_sromvar pci_sromvars[] = { |
425 | {BRCMS_SROM_DEVID, 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, | 339 | {BRCMS_SROM_DEVID, 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, |
426 | 0xffff}, | 340 | 0xffff}, |
427 | {BRCMS_SROM_BOARDREV, 0x0000000e, SRFL_PRHEX, SROM_AABREV, | ||
428 | SROM_BR_MASK}, | ||
429 | {BRCMS_SROM_BOARDREV, 0x000000f0, SRFL_PRHEX, SROM4_BREV, 0xffff}, | ||
430 | {BRCMS_SROM_BOARDREV, 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff}, | 341 | {BRCMS_SROM_BOARDREV, 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff}, |
431 | {BRCMS_SROM_BOARDFLAGS, 0x00000002, SRFL_PRHEX, SROM_BFL, 0xffff}, | ||
432 | {BRCMS_SROM_BOARDFLAGS, 0x00000004, SRFL_PRHEX | SRFL_MORE, SROM_BFL, | ||
433 | 0xffff}, | ||
434 | {BRCMS_SROM_CONT, 0, 0, SROM_BFL2, 0xffff}, | ||
435 | {BRCMS_SROM_BOARDFLAGS, 0x00000008, SRFL_PRHEX | SRFL_MORE, SROM_BFL, | ||
436 | 0xffff}, | ||
437 | {BRCMS_SROM_CONT, 0, 0, SROM3_BFL2, 0xffff}, | ||
438 | {BRCMS_SROM_BOARDFLAGS, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL0, | ||
439 | 0xffff}, | ||
440 | {BRCMS_SROM_CONT, 0, 0, SROM4_BFL1, 0xffff}, | ||
441 | {BRCMS_SROM_BOARDFLAGS, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL0, | ||
442 | 0xffff}, | ||
443 | {BRCMS_SROM_CONT, 0, 0, SROM5_BFL1, 0xffff}, | ||
444 | {BRCMS_SROM_BOARDFLAGS, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0, | 342 | {BRCMS_SROM_BOARDFLAGS, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0, |
445 | 0xffff}, | 343 | 0xffff}, |
446 | {BRCMS_SROM_CONT, 0, 0, SROM8_BFL1, 0xffff}, | 344 | {BRCMS_SROM_CONT, 0, 0, SROM8_BFL1, 0xffff}, |
447 | {BRCMS_SROM_BOARDFLAGS2, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL2, | ||
448 | 0xffff}, | ||
449 | {BRCMS_SROM_CONT, 0, 0, SROM4_BFL3, 0xffff}, | ||
450 | {BRCMS_SROM_BOARDFLAGS2, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL2, | ||
451 | 0xffff}, | ||
452 | {BRCMS_SROM_CONT, 0, 0, SROM5_BFL3, 0xffff}, | ||
453 | {BRCMS_SROM_BOARDFLAGS2, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2, | 345 | {BRCMS_SROM_BOARDFLAGS2, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2, |
454 | 0xffff}, | 346 | 0xffff}, |
455 | {BRCMS_SROM_CONT, 0, 0, SROM8_BFL3, 0xffff}, | 347 | {BRCMS_SROM_CONT, 0, 0, SROM8_BFL3, 0xffff}, |
456 | {BRCMS_SROM_BOARDTYPE, 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff}, | 348 | {BRCMS_SROM_BOARDTYPE, 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff}, |
457 | {BRCMS_SROM_BOARDNUM, 0x00000006, 0, SROM_MACLO_IL0, 0xffff}, | ||
458 | {BRCMS_SROM_BOARDNUM, 0x00000008, 0, SROM3_MACLO, 0xffff}, | ||
459 | {BRCMS_SROM_BOARDNUM, 0x00000010, 0, SROM4_MACLO, 0xffff}, | ||
460 | {BRCMS_SROM_BOARDNUM, 0x000000e0, 0, SROM5_MACLO, 0xffff}, | ||
461 | {BRCMS_SROM_BOARDNUM, 0xffffff00, 0, SROM8_MACLO, 0xffff}, | 349 | {BRCMS_SROM_BOARDNUM, 0xffffff00, 0, SROM8_MACLO, 0xffff}, |
462 | {BRCMS_SROM_CC, 0x00000002, 0, SROM_AABREV, SROM_CC_MASK}, | ||
463 | {BRCMS_SROM_REGREV, 0x00000008, 0, SROM_OPO, 0xff00}, | ||
464 | {BRCMS_SROM_REGREV, 0x00000010, 0, SROM4_REGREV, 0x00ff}, | ||
465 | {BRCMS_SROM_REGREV, 0x000000e0, 0, SROM5_REGREV, 0x00ff}, | ||
466 | {BRCMS_SROM_REGREV, 0xffffff00, 0, SROM8_REGREV, 0x00ff}, | 350 | {BRCMS_SROM_REGREV, 0xffffff00, 0, SROM8_REGREV, 0x00ff}, |
467 | {BRCMS_SROM_LEDBH0, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0x00ff}, | ||
468 | {BRCMS_SROM_LEDBH1, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0xff00}, | ||
469 | {BRCMS_SROM_LEDBH2, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0x00ff}, | ||
470 | {BRCMS_SROM_LEDBH3, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0xff00}, | ||
471 | {BRCMS_SROM_LEDBH0, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0x00ff}, | ||
472 | {BRCMS_SROM_LEDBH1, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0xff00}, | ||
473 | {BRCMS_SROM_LEDBH2, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0x00ff}, | ||
474 | {BRCMS_SROM_LEDBH3, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0xff00}, | ||
475 | {BRCMS_SROM_LEDBH0, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0x00ff}, | ||
476 | {BRCMS_SROM_LEDBH1, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0xff00}, | ||
477 | {BRCMS_SROM_LEDBH2, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0x00ff}, | ||
478 | {BRCMS_SROM_LEDBH3, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0xff00}, | ||
479 | {BRCMS_SROM_LEDBH0, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff}, | 351 | {BRCMS_SROM_LEDBH0, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff}, |
480 | {BRCMS_SROM_LEDBH1, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00}, | 352 | {BRCMS_SROM_LEDBH1, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00}, |
481 | {BRCMS_SROM_LEDBH2, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff}, | 353 | {BRCMS_SROM_LEDBH2, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff}, |
482 | {BRCMS_SROM_LEDBH3, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00}, | 354 | {BRCMS_SROM_LEDBH3, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00}, |
483 | {BRCMS_SROM_PA0B0, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB0, 0xffff}, | ||
484 | {BRCMS_SROM_PA0B1, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB1, 0xffff}, | ||
485 | {BRCMS_SROM_PA0B2, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB2, 0xffff}, | ||
486 | {BRCMS_SROM_PA0ITSSIT, 0x0000000e, 0, SROM_ITT, 0x00ff}, | ||
487 | {BRCMS_SROM_PA0MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0x00ff}, | ||
488 | {BRCMS_SROM_PA0B0, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff}, | 355 | {BRCMS_SROM_PA0B0, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff}, |
489 | {BRCMS_SROM_PA0B1, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff}, | 356 | {BRCMS_SROM_PA0B1, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff}, |
490 | {BRCMS_SROM_PA0B2, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff}, | 357 | {BRCMS_SROM_PA0B2, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff}, |
491 | {BRCMS_SROM_PA0ITSSIT, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00}, | 358 | {BRCMS_SROM_PA0ITSSIT, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00}, |
492 | {BRCMS_SROM_PA0MAXPWR, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff}, | 359 | {BRCMS_SROM_PA0MAXPWR, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff}, |
493 | {BRCMS_SROM_OPO, 0x0000000c, 0, SROM_OPO, 0x00ff}, | ||
494 | {BRCMS_SROM_OPO, 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff}, | 360 | {BRCMS_SROM_OPO, 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff}, |
495 | {BRCMS_SROM_AA2G, 0x0000000e, 0, SROM_AABREV, SROM_AA0_MASK}, | ||
496 | {BRCMS_SROM_AA2G, 0x000000f0, 0, SROM4_AA, 0x00ff}, | ||
497 | {BRCMS_SROM_AA2G, 0xffffff00, 0, SROM8_AA, 0x00ff}, | 361 | {BRCMS_SROM_AA2G, 0xffffff00, 0, SROM8_AA, 0x00ff}, |
498 | {BRCMS_SROM_AA5G, 0x0000000e, 0, SROM_AABREV, SROM_AA1_MASK}, | ||
499 | {BRCMS_SROM_AA5G, 0x000000f0, 0, SROM4_AA, 0xff00}, | ||
500 | {BRCMS_SROM_AA5G, 0xffffff00, 0, SROM8_AA, 0xff00}, | 362 | {BRCMS_SROM_AA5G, 0xffffff00, 0, SROM8_AA, 0xff00}, |
501 | {BRCMS_SROM_AG0, 0x0000000e, 0, SROM_AG10, 0x00ff}, | ||
502 | {BRCMS_SROM_AG1, 0x0000000e, 0, SROM_AG10, 0xff00}, | ||
503 | {BRCMS_SROM_AG0, 0x000000f0, 0, SROM4_AG10, 0x00ff}, | ||
504 | {BRCMS_SROM_AG1, 0x000000f0, 0, SROM4_AG10, 0xff00}, | ||
505 | {BRCMS_SROM_AG2, 0x000000f0, 0, SROM4_AG32, 0x00ff}, | ||
506 | {BRCMS_SROM_AG3, 0x000000f0, 0, SROM4_AG32, 0xff00}, | ||
507 | {BRCMS_SROM_AG0, 0xffffff00, 0, SROM8_AG10, 0x00ff}, | 363 | {BRCMS_SROM_AG0, 0xffffff00, 0, SROM8_AG10, 0x00ff}, |
508 | {BRCMS_SROM_AG1, 0xffffff00, 0, SROM8_AG10, 0xff00}, | 364 | {BRCMS_SROM_AG1, 0xffffff00, 0, SROM8_AG10, 0xff00}, |
509 | {BRCMS_SROM_AG2, 0xffffff00, 0, SROM8_AG32, 0x00ff}, | 365 | {BRCMS_SROM_AG2, 0xffffff00, 0, SROM8_AG32, 0x00ff}, |
510 | {BRCMS_SROM_AG3, 0xffffff00, 0, SROM8_AG32, 0xff00}, | 366 | {BRCMS_SROM_AG3, 0xffffff00, 0, SROM8_AG32, 0xff00}, |
511 | {BRCMS_SROM_PA1B0, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB0, 0xffff}, | ||
512 | {BRCMS_SROM_PA1B1, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB1, 0xffff}, | ||
513 | {BRCMS_SROM_PA1B2, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB2, 0xffff}, | ||
514 | {BRCMS_SROM_PA1LOB0, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB0, 0xffff}, | ||
515 | {BRCMS_SROM_PA1LOB1, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB1, 0xffff}, | ||
516 | {BRCMS_SROM_PA1LOB2, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB2, 0xffff}, | ||
517 | {BRCMS_SROM_PA1HIB0, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB0, 0xffff}, | ||
518 | {BRCMS_SROM_PA1HIB1, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB1, 0xffff}, | ||
519 | {BRCMS_SROM_PA1HIB2, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB2, 0xffff}, | ||
520 | {BRCMS_SROM_PA1ITSSIT, 0x0000000e, 0, SROM_ITT, 0xff00}, | ||
521 | {BRCMS_SROM_PA1MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0xff00}, | ||
522 | {BRCMS_SROM_PA1LOMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0xff00}, | ||
523 | {BRCMS_SROM_PA1HIMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0x00ff}, | ||
524 | {BRCMS_SROM_PA1B0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff}, | 367 | {BRCMS_SROM_PA1B0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff}, |
525 | {BRCMS_SROM_PA1B1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff}, | 368 | {BRCMS_SROM_PA1B1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff}, |
526 | {BRCMS_SROM_PA1B2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff}, | 369 | {BRCMS_SROM_PA1B2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff}, |
@@ -534,40 +377,20 @@ static const struct brcms_sromvar pci_sromvars[] = { | |||
534 | {BRCMS_SROM_PA1MAXPWR, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff}, | 377 | {BRCMS_SROM_PA1MAXPWR, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff}, |
535 | {BRCMS_SROM_PA1LOMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00}, | 378 | {BRCMS_SROM_PA1LOMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00}, |
536 | {BRCMS_SROM_PA1HIMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff}, | 379 | {BRCMS_SROM_PA1HIMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff}, |
537 | {BRCMS_SROM_BXA2G, 0x00000008, 0, SROM_BXARSSI2G, 0x1800}, | ||
538 | {BRCMS_SROM_RSSISAV2G, 0x00000008, 0, SROM_BXARSSI2G, 0x0700}, | ||
539 | {BRCMS_SROM_RSSISMC2G, 0x00000008, 0, SROM_BXARSSI2G, 0x00f0}, | ||
540 | {BRCMS_SROM_RSSISMF2G, 0x00000008, 0, SROM_BXARSSI2G, 0x000f}, | ||
541 | {BRCMS_SROM_BXA2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800}, | 380 | {BRCMS_SROM_BXA2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800}, |
542 | {BRCMS_SROM_RSSISAV2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700}, | 381 | {BRCMS_SROM_RSSISAV2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700}, |
543 | {BRCMS_SROM_RSSISMC2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0}, | 382 | {BRCMS_SROM_RSSISMC2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0}, |
544 | {BRCMS_SROM_RSSISMF2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f}, | 383 | {BRCMS_SROM_RSSISMF2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f}, |
545 | {BRCMS_SROM_BXA5G, 0x00000008, 0, SROM_BXARSSI5G, 0x1800}, | ||
546 | {BRCMS_SROM_RSSISAV5G, 0x00000008, 0, SROM_BXARSSI5G, 0x0700}, | ||
547 | {BRCMS_SROM_RSSISMC5G, 0x00000008, 0, SROM_BXARSSI5G, 0x00f0}, | ||
548 | {BRCMS_SROM_RSSISMF5G, 0x00000008, 0, SROM_BXARSSI5G, 0x000f}, | ||
549 | {BRCMS_SROM_BXA5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800}, | 384 | {BRCMS_SROM_BXA5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800}, |
550 | {BRCMS_SROM_RSSISAV5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700}, | 385 | {BRCMS_SROM_RSSISAV5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700}, |
551 | {BRCMS_SROM_RSSISMC5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0}, | 386 | {BRCMS_SROM_RSSISMC5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0}, |
552 | {BRCMS_SROM_RSSISMF5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f}, | 387 | {BRCMS_SROM_RSSISMF5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f}, |
553 | {BRCMS_SROM_TRI2G, 0x00000008, 0, SROM_TRI52G, 0x00ff}, | ||
554 | {BRCMS_SROM_TRI5G, 0x00000008, 0, SROM_TRI52G, 0xff00}, | ||
555 | {BRCMS_SROM_TRI5GL, 0x00000008, 0, SROM_TRI5GHL, 0x00ff}, | ||
556 | {BRCMS_SROM_TRI5GH, 0x00000008, 0, SROM_TRI5GHL, 0xff00}, | ||
557 | {BRCMS_SROM_TRI2G, 0xffffff00, 0, SROM8_TRI52G, 0x00ff}, | 388 | {BRCMS_SROM_TRI2G, 0xffffff00, 0, SROM8_TRI52G, 0x00ff}, |
558 | {BRCMS_SROM_TRI5G, 0xffffff00, 0, SROM8_TRI52G, 0xff00}, | 389 | {BRCMS_SROM_TRI5G, 0xffffff00, 0, SROM8_TRI52G, 0xff00}, |
559 | {BRCMS_SROM_TRI5GL, 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff}, | 390 | {BRCMS_SROM_TRI5GL, 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff}, |
560 | {BRCMS_SROM_TRI5GH, 0xffffff00, 0, SROM8_TRI5GHL, 0xff00}, | 391 | {BRCMS_SROM_TRI5GH, 0xffffff00, 0, SROM8_TRI5GHL, 0xff00}, |
561 | {BRCMS_SROM_RXPO2G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0x00ff}, | ||
562 | {BRCMS_SROM_RXPO5G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0xff00}, | ||
563 | {BRCMS_SROM_RXPO2G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff}, | 392 | {BRCMS_SROM_RXPO2G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff}, |
564 | {BRCMS_SROM_RXPO5G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00}, | 393 | {BRCMS_SROM_RXPO5G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00}, |
565 | {BRCMS_SROM_TXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, | ||
566 | SROM4_TXCHAIN_MASK}, | ||
567 | {BRCMS_SROM_RXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, | ||
568 | SROM4_RXCHAIN_MASK}, | ||
569 | {BRCMS_SROM_ANTSWITCH, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, | ||
570 | SROM4_SWITCH_MASK}, | ||
571 | {BRCMS_SROM_TXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, | 394 | {BRCMS_SROM_TXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, |
572 | SROM4_TXCHAIN_MASK}, | 395 | SROM4_TXCHAIN_MASK}, |
573 | {BRCMS_SROM_RXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, | 396 | {BRCMS_SROM_RXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, |
@@ -594,43 +417,11 @@ static const struct brcms_sromvar pci_sromvars[] = { | |||
594 | SROM8_FEM_ANTSWLUT_MASK}, | 417 | SROM8_FEM_ANTSWLUT_MASK}, |
595 | {BRCMS_SROM_TEMPTHRESH, 0xffffff00, 0, SROM8_THERMAL, 0xff00}, | 418 | {BRCMS_SROM_TEMPTHRESH, 0xffffff00, 0, SROM8_THERMAL, 0xff00}, |
596 | {BRCMS_SROM_TEMPOFFSET, 0xffffff00, 0, SROM8_THERMAL, 0x00ff}, | 419 | {BRCMS_SROM_TEMPOFFSET, 0xffffff00, 0, SROM8_THERMAL, 0x00ff}, |
597 | {BRCMS_SROM_TXPID2GA0, 0x000000f0, 0, SROM4_TXPID2G, 0x00ff}, | 420 | |
598 | {BRCMS_SROM_TXPID2GA1, 0x000000f0, 0, SROM4_TXPID2G, 0xff00}, | ||
599 | {BRCMS_SROM_TXPID2GA2, 0x000000f0, 0, SROM4_TXPID2G + 1, 0x00ff}, | ||
600 | {BRCMS_SROM_TXPID2GA3, 0x000000f0, 0, SROM4_TXPID2G + 1, 0xff00}, | ||
601 | {BRCMS_SROM_TXPID5GA0, 0x000000f0, 0, SROM4_TXPID5G, 0x00ff}, | ||
602 | {BRCMS_SROM_TXPID5GA1, 0x000000f0, 0, SROM4_TXPID5G, 0xff00}, | ||
603 | {BRCMS_SROM_TXPID5GA2, 0x000000f0, 0, SROM4_TXPID5G + 1, 0x00ff}, | ||
604 | {BRCMS_SROM_TXPID5GA3, 0x000000f0, 0, SROM4_TXPID5G + 1, 0xff00}, | ||
605 | {BRCMS_SROM_TXPID5GLA0, 0x000000f0, 0, SROM4_TXPID5GL, 0x00ff}, | ||
606 | {BRCMS_SROM_TXPID5GLA1, 0x000000f0, 0, SROM4_TXPID5GL, 0xff00}, | ||
607 | {BRCMS_SROM_TXPID5GLA2, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0x00ff}, | ||
608 | {BRCMS_SROM_TXPID5GLA3, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0xff00}, | ||
609 | {BRCMS_SROM_TXPID5GHA0, 0x000000f0, 0, SROM4_TXPID5GH, 0x00ff}, | ||
610 | {BRCMS_SROM_TXPID5GHA1, 0x000000f0, 0, SROM4_TXPID5GH, 0xff00}, | ||
611 | {BRCMS_SROM_TXPID5GHA2, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0x00ff}, | ||
612 | {BRCMS_SROM_TXPID5GHA3, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0xff00}, | ||
613 | |||
614 | {BRCMS_SROM_CCODE, 0x0000000f, SRFL_CCODE, SROM_CCODE, 0xffff}, | ||
615 | {BRCMS_SROM_CCODE, 0x00000010, SRFL_CCODE, SROM4_CCODE, 0xffff}, | ||
616 | {BRCMS_SROM_CCODE, 0x000000e0, SRFL_CCODE, SROM5_CCODE, 0xffff}, | ||
617 | {BRCMS_SROM_CCODE, 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff}, | 421 | {BRCMS_SROM_CCODE, 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff}, |
618 | {BRCMS_SROM_MACADDR, 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff}, | 422 | {BRCMS_SROM_MACADDR, 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff}, |
619 | {BRCMS_SROM_MACADDR, 0x000000e0, SRFL_ETHADDR, SROM5_MACHI, 0xffff}, | ||
620 | {BRCMS_SROM_MACADDR, 0x00000010, SRFL_ETHADDR, SROM4_MACHI, 0xffff}, | ||
621 | {BRCMS_SROM_MACADDR, 0x00000008, SRFL_ETHADDR, SROM3_MACHI, 0xffff}, | ||
622 | {BRCMS_SROM_IL0MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_IL0, | ||
623 | 0xffff}, | ||
624 | {BRCMS_SROM_ET1MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_ET1, | ||
625 | 0xffff}, | ||
626 | {BRCMS_SROM_LEDDC, 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC, | 423 | {BRCMS_SROM_LEDDC, 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC, |
627 | 0xffff}, | 424 | 0xffff}, |
628 | {BRCMS_SROM_LEDDC, 0x000000e0, SRFL_NOFFS | SRFL_LEDDC, SROM5_LEDDC, | ||
629 | 0xffff}, | ||
630 | {BRCMS_SROM_LEDDC, 0x00000010, SRFL_NOFFS | SRFL_LEDDC, SROM4_LEDDC, | ||
631 | 0xffff}, | ||
632 | {BRCMS_SROM_LEDDC, 0x00000008, SRFL_NOFFS | SRFL_LEDDC, SROM3_LEDDC, | ||
633 | 0xffff}, | ||
634 | {BRCMS_SROM_RAWTEMPSENSE, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, | 425 | {BRCMS_SROM_RAWTEMPSENSE, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, |
635 | 0x01ff}, | 426 | 0x01ff}, |
636 | {BRCMS_SROM_MEASPOWER, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, | 427 | {BRCMS_SROM_MEASPOWER, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, |
@@ -650,16 +441,7 @@ static const struct brcms_sromvar pci_sromvars[] = { | |||
650 | {BRCMS_SROM_PHYCAL_TEMPDELTA, 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA, | 441 | {BRCMS_SROM_PHYCAL_TEMPDELTA, 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA, |
651 | 0x00ff}, | 442 | 0x00ff}, |
652 | 443 | ||
653 | {BRCMS_SROM_CCK2GPO, 0x000000f0, 0, SROM4_2G_CCKPO, 0xffff}, | ||
654 | {BRCMS_SROM_CCK2GPO, 0x00000100, 0, SROM8_2G_CCKPO, 0xffff}, | 444 | {BRCMS_SROM_CCK2GPO, 0x00000100, 0, SROM8_2G_CCKPO, 0xffff}, |
655 | {BRCMS_SROM_OFDM2GPO, 0x000000f0, SRFL_MORE, SROM4_2G_OFDMPO, 0xffff}, | ||
656 | {BRCMS_SROM_CONT, 0, 0, SROM4_2G_OFDMPO + 1, 0xffff}, | ||
657 | {BRCMS_SROM_OFDM5GPO, 0x000000f0, SRFL_MORE, SROM4_5G_OFDMPO, 0xffff}, | ||
658 | {BRCMS_SROM_CONT, 0, 0, SROM4_5G_OFDMPO + 1, 0xffff}, | ||
659 | {BRCMS_SROM_OFDM5GLPO, 0x000000f0, SRFL_MORE, SROM4_5GL_OFDMPO, 0xffff}, | ||
660 | {BRCMS_SROM_CONT, 0, 0, SROM4_5GL_OFDMPO + 1, 0xffff}, | ||
661 | {BRCMS_SROM_OFDM5GHPO, 0x000000f0, SRFL_MORE, SROM4_5GH_OFDMPO, 0xffff}, | ||
662 | {BRCMS_SROM_CONT, 0, 0, SROM4_5GH_OFDMPO + 1, 0xffff}, | ||
663 | {BRCMS_SROM_OFDM2GPO, 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff}, | 445 | {BRCMS_SROM_OFDM2GPO, 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff}, |
664 | {BRCMS_SROM_CONT, 0, 0, SROM8_2G_OFDMPO + 1, 0xffff}, | 446 | {BRCMS_SROM_CONT, 0, 0, SROM8_2G_OFDMPO + 1, 0xffff}, |
665 | {BRCMS_SROM_OFDM5GPO, 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff}, | 447 | {BRCMS_SROM_OFDM5GPO, 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff}, |
@@ -668,38 +450,6 @@ static const struct brcms_sromvar pci_sromvars[] = { | |||
668 | {BRCMS_SROM_CONT, 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff}, | 450 | {BRCMS_SROM_CONT, 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff}, |
669 | {BRCMS_SROM_OFDM5GHPO, 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff}, | 451 | {BRCMS_SROM_OFDM5GHPO, 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff}, |
670 | {BRCMS_SROM_CONT, 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff}, | 452 | {BRCMS_SROM_CONT, 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff}, |
671 | {BRCMS_SROM_MCS2GPO0, 0x000000f0, 0, SROM4_2G_MCSPO, 0xffff}, | ||
672 | {BRCMS_SROM_MCS2GPO1, 0x000000f0, 0, SROM4_2G_MCSPO + 1, 0xffff}, | ||
673 | {BRCMS_SROM_MCS2GPO2, 0x000000f0, 0, SROM4_2G_MCSPO + 2, 0xffff}, | ||
674 | {BRCMS_SROM_MCS2GPO3, 0x000000f0, 0, SROM4_2G_MCSPO + 3, 0xffff}, | ||
675 | {BRCMS_SROM_MCS2GPO4, 0x000000f0, 0, SROM4_2G_MCSPO + 4, 0xffff}, | ||
676 | {BRCMS_SROM_MCS2GPO5, 0x000000f0, 0, SROM4_2G_MCSPO + 5, 0xffff}, | ||
677 | {BRCMS_SROM_MCS2GPO6, 0x000000f0, 0, SROM4_2G_MCSPO + 6, 0xffff}, | ||
678 | {BRCMS_SROM_MCS2GPO7, 0x000000f0, 0, SROM4_2G_MCSPO + 7, 0xffff}, | ||
679 | {BRCMS_SROM_MCS5GPO0, 0x000000f0, 0, SROM4_5G_MCSPO, 0xffff}, | ||
680 | {BRCMS_SROM_MCS5GPO1, 0x000000f0, 0, SROM4_5G_MCSPO + 1, 0xffff}, | ||
681 | {BRCMS_SROM_MCS5GPO2, 0x000000f0, 0, SROM4_5G_MCSPO + 2, 0xffff}, | ||
682 | {BRCMS_SROM_MCS5GPO3, 0x000000f0, 0, SROM4_5G_MCSPO + 3, 0xffff}, | ||
683 | {BRCMS_SROM_MCS5GPO4, 0x000000f0, 0, SROM4_5G_MCSPO + 4, 0xffff}, | ||
684 | {BRCMS_SROM_MCS5GPO5, 0x000000f0, 0, SROM4_5G_MCSPO + 5, 0xffff}, | ||
685 | {BRCMS_SROM_MCS5GPO6, 0x000000f0, 0, SROM4_5G_MCSPO + 6, 0xffff}, | ||
686 | {BRCMS_SROM_MCS5GPO7, 0x000000f0, 0, SROM4_5G_MCSPO + 7, 0xffff}, | ||
687 | {BRCMS_SROM_MCS5GLPO0, 0x000000f0, 0, SROM4_5GL_MCSPO, 0xffff}, | ||
688 | {BRCMS_SROM_MCS5GLPO1, 0x000000f0, 0, SROM4_5GL_MCSPO + 1, 0xffff}, | ||
689 | {BRCMS_SROM_MCS5GLPO2, 0x000000f0, 0, SROM4_5GL_MCSPO + 2, 0xffff}, | ||
690 | {BRCMS_SROM_MCS5GLPO3, 0x000000f0, 0, SROM4_5GL_MCSPO + 3, 0xffff}, | ||
691 | {BRCMS_SROM_MCS5GLPO4, 0x000000f0, 0, SROM4_5GL_MCSPO + 4, 0xffff}, | ||
692 | {BRCMS_SROM_MCS5GLPO5, 0x000000f0, 0, SROM4_5GL_MCSPO + 5, 0xffff}, | ||
693 | {BRCMS_SROM_MCS5GLPO6, 0x000000f0, 0, SROM4_5GL_MCSPO + 6, 0xffff}, | ||
694 | {BRCMS_SROM_MCS5GLPO7, 0x000000f0, 0, SROM4_5GL_MCSPO + 7, 0xffff}, | ||
695 | {BRCMS_SROM_MCS5GHPO0, 0x000000f0, 0, SROM4_5GH_MCSPO, 0xffff}, | ||
696 | {BRCMS_SROM_MCS5GHPO1, 0x000000f0, 0, SROM4_5GH_MCSPO + 1, 0xffff}, | ||
697 | {BRCMS_SROM_MCS5GHPO2, 0x000000f0, 0, SROM4_5GH_MCSPO + 2, 0xffff}, | ||
698 | {BRCMS_SROM_MCS5GHPO3, 0x000000f0, 0, SROM4_5GH_MCSPO + 3, 0xffff}, | ||
699 | {BRCMS_SROM_MCS5GHPO4, 0x000000f0, 0, SROM4_5GH_MCSPO + 4, 0xffff}, | ||
700 | {BRCMS_SROM_MCS5GHPO5, 0x000000f0, 0, SROM4_5GH_MCSPO + 5, 0xffff}, | ||
701 | {BRCMS_SROM_MCS5GHPO6, 0x000000f0, 0, SROM4_5GH_MCSPO + 6, 0xffff}, | ||
702 | {BRCMS_SROM_MCS5GHPO7, 0x000000f0, 0, SROM4_5GH_MCSPO + 7, 0xffff}, | ||
703 | {BRCMS_SROM_MCS2GPO0, 0x00000100, 0, SROM8_2G_MCSPO, 0xffff}, | 453 | {BRCMS_SROM_MCS2GPO0, 0x00000100, 0, SROM8_2G_MCSPO, 0xffff}, |
704 | {BRCMS_SROM_MCS2GPO1, 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff}, | 454 | {BRCMS_SROM_MCS2GPO1, 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff}, |
705 | {BRCMS_SROM_MCS2GPO2, 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff}, | 455 | {BRCMS_SROM_MCS2GPO2, 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff}, |
@@ -732,10 +482,6 @@ static const struct brcms_sromvar pci_sromvars[] = { | |||
732 | {BRCMS_SROM_MCS5GHPO5, 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff}, | 482 | {BRCMS_SROM_MCS5GHPO5, 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff}, |
733 | {BRCMS_SROM_MCS5GHPO6, 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff}, | 483 | {BRCMS_SROM_MCS5GHPO6, 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff}, |
734 | {BRCMS_SROM_MCS5GHPO7, 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff}, | 484 | {BRCMS_SROM_MCS5GHPO7, 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff}, |
735 | {BRCMS_SROM_CDDPO, 0x000000f0, 0, SROM4_CDDPO, 0xffff}, | ||
736 | {BRCMS_SROM_STBCPO, 0x000000f0, 0, SROM4_STBCPO, 0xffff}, | ||
737 | {BRCMS_SROM_BW40PO, 0x000000f0, 0, SROM4_BW40PO, 0xffff}, | ||
738 | {BRCMS_SROM_BWDUPPO, 0x000000f0, 0, SROM4_BWDUPPO, 0xffff}, | ||
739 | {BRCMS_SROM_CDDPO, 0x00000100, 0, SROM8_CDDPO, 0xffff}, | 485 | {BRCMS_SROM_CDDPO, 0x00000100, 0, SROM8_CDDPO, 0xffff}, |
740 | {BRCMS_SROM_STBCPO, 0x00000100, 0, SROM8_STBCPO, 0xffff}, | 486 | {BRCMS_SROM_STBCPO, 0x00000100, 0, SROM8_STBCPO, 0xffff}, |
741 | {BRCMS_SROM_BW40PO, 0x00000100, 0, SROM8_BW40PO, 0xffff}, | 487 | {BRCMS_SROM_BW40PO, 0x00000100, 0, SROM8_BW40PO, 0xffff}, |
@@ -811,34 +557,6 @@ static const struct brcms_sromvar pci_sromvars[] = { | |||
811 | }; | 557 | }; |
812 | 558 | ||
813 | static const struct brcms_sromvar perpath_pci_sromvars[] = { | 559 | static const struct brcms_sromvar perpath_pci_sromvars[] = { |
814 | {BRCMS_SROM_MAXP2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0x00ff}, | ||
815 | {BRCMS_SROM_ITT2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0xff00}, | ||
816 | {BRCMS_SROM_ITT5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0xff00}, | ||
817 | {BRCMS_SROM_PA2GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA, 0xffff}, | ||
818 | {BRCMS_SROM_PA2GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 1, 0xffff}, | ||
819 | {BRCMS_SROM_PA2GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 2, 0xffff}, | ||
820 | {BRCMS_SROM_PA2GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 3, 0xffff}, | ||
821 | {BRCMS_SROM_MAXP5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0x00ff}, | ||
822 | {BRCMS_SROM_MAXP5GHA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0x00ff}, | ||
823 | {BRCMS_SROM_MAXP5GLA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0xff00}, | ||
824 | {BRCMS_SROM_PA5GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA, 0xffff}, | ||
825 | {BRCMS_SROM_PA5GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 1, 0xffff}, | ||
826 | {BRCMS_SROM_PA5GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 2, 0xffff}, | ||
827 | {BRCMS_SROM_PA5GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 3, 0xffff}, | ||
828 | {BRCMS_SROM_PA5GLW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA, 0xffff}, | ||
829 | {BRCMS_SROM_PA5GLW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 1, | ||
830 | 0xffff}, | ||
831 | {BRCMS_SROM_PA5GLW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 2, | ||
832 | 0xffff}, | ||
833 | {BRCMS_SROM_PA5GLW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 3, | ||
834 | 0xffff}, | ||
835 | {BRCMS_SROM_PA5GHW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA, 0xffff}, | ||
836 | {BRCMS_SROM_PA5GHW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 1, | ||
837 | 0xffff}, | ||
838 | {BRCMS_SROM_PA5GHW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 2, | ||
839 | 0xffff}, | ||
840 | {BRCMS_SROM_PA5GHW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 3, | ||
841 | 0xffff}, | ||
842 | {BRCMS_SROM_MAXP2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff}, | 560 | {BRCMS_SROM_MAXP2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff}, |
843 | {BRCMS_SROM_ITT2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00}, | 561 | {BRCMS_SROM_ITT2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00}, |
844 | {BRCMS_SROM_ITT5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00}, | 562 | {BRCMS_SROM_ITT5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00}, |
@@ -868,24 +586,17 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { | |||
868 | * shared between devices. */ | 586 | * shared between devices. */ |
869 | static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; | 587 | static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; |
870 | 588 | ||
871 | static u16 __iomem * | 589 | static u8 __iomem * |
872 | srom_window_address(struct si_pub *sih, u8 __iomem *curmap) | 590 | srom_window_address(struct si_pub *sih, u8 __iomem *curmap) |
873 | { | 591 | { |
874 | if (sih->ccrev < 32) | 592 | if (sih->ccrev < 32) |
875 | return (u16 __iomem *)(curmap + PCI_BAR0_SPROM_OFFSET); | 593 | return curmap + PCI_BAR0_SPROM_OFFSET; |
876 | if (sih->cccaps & CC_CAP_SROM) | 594 | if (sih->cccaps & CC_CAP_SROM) |
877 | return (u16 __iomem *) | 595 | return curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP; |
878 | (curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); | ||
879 | 596 | ||
880 | return NULL; | 597 | return NULL; |
881 | } | 598 | } |
882 | 599 | ||
883 | /* Parse SROM and create name=value pairs. 'srom' points to | ||
884 | * the SROM word array. 'off' specifies the offset of the | ||
885 | * first word 'srom' points to, which should be either 0 or | ||
886 | * SROM3_SWRG_OFF (full SROM or software region). | ||
887 | */ | ||
888 | |||
889 | static uint mask_shift(u16 mask) | 600 | static uint mask_shift(u16 mask) |
890 | { | 601 | { |
891 | uint i; | 602 | uint i; |
@@ -906,18 +617,16 @@ static uint mask_width(u16 mask) | |||
906 | return 0; | 617 | return 0; |
907 | } | 618 | } |
908 | 619 | ||
909 | static inline void ltoh16_buf(u16 *buf, unsigned int size) | 620 | static inline void le16_to_cpu_buf(u16 *buf, uint nwords) |
910 | { | 621 | { |
911 | size /= 2; | 622 | while (nwords--) |
912 | while (size--) | 623 | *(buf + nwords) = le16_to_cpu(*(__le16 *)(buf + nwords)); |
913 | *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); | ||
914 | } | 624 | } |
915 | 625 | ||
916 | static inline void htol16_buf(u16 *buf, unsigned int size) | 626 | static inline void cpu_to_le16_buf(u16 *buf, uint nwords) |
917 | { | 627 | { |
918 | size /= 2; | 628 | while (nwords--) |
919 | while (size--) | 629 | *(__le16 *)(buf + nwords) = cpu_to_le16(*(buf + nwords)); |
920 | *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); | ||
921 | } | 630 | } |
922 | 631 | ||
923 | /* | 632 | /* |
@@ -929,11 +638,14 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) | |||
929 | struct brcms_srom_list_head *entry; | 638 | struct brcms_srom_list_head *entry; |
930 | enum brcms_srom_id id; | 639 | enum brcms_srom_id id; |
931 | u16 w; | 640 | u16 w; |
932 | u32 val; | 641 | u32 val = 0; |
933 | const struct brcms_sromvar *srv; | 642 | const struct brcms_sromvar *srv; |
934 | uint width; | 643 | uint width; |
935 | uint flags; | 644 | uint flags; |
936 | u32 sr = (1 << sromrev); | 645 | u32 sr = (1 << sromrev); |
646 | uint p; | ||
647 | uint pb = SROM8_PATH0; | ||
648 | const uint psz = SROM8_PATH1 - SROM8_PATH0; | ||
937 | 649 | ||
938 | /* first store the srom revision */ | 650 | /* first store the srom revision */ |
939 | entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); | 651 | entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); |
@@ -1031,47 +743,34 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) | |||
1031 | list_add(&entry->var_list, var_list); | 743 | list_add(&entry->var_list, var_list); |
1032 | } | 744 | } |
1033 | 745 | ||
1034 | if (sromrev >= 4) { | 746 | for (p = 0; p < MAX_PATH_SROM; p++) { |
1035 | /* Do per-path variables */ | 747 | for (srv = perpath_pci_sromvars; |
1036 | uint p, pb, psz; | 748 | srv->varid != BRCMS_SROM_NULL; srv++) { |
1037 | 749 | if ((srv->revmask & sr) == 0) | |
1038 | if (sromrev >= 8) { | 750 | continue; |
1039 | pb = SROM8_PATH0; | ||
1040 | psz = SROM8_PATH1 - SROM8_PATH0; | ||
1041 | } else { | ||
1042 | pb = SROM4_PATH0; | ||
1043 | psz = SROM4_PATH1 - SROM4_PATH0; | ||
1044 | } | ||
1045 | |||
1046 | for (p = 0; p < MAX_PATH_SROM; p++) { | ||
1047 | for (srv = perpath_pci_sromvars; | ||
1048 | srv->varid != BRCMS_SROM_NULL; srv++) { | ||
1049 | if ((srv->revmask & sr) == 0) | ||
1050 | continue; | ||
1051 | 751 | ||
1052 | if (srv->flags & SRFL_NOVAR) | 752 | if (srv->flags & SRFL_NOVAR) |
1053 | continue; | 753 | continue; |
1054 | 754 | ||
1055 | w = srom[pb + srv->off]; | 755 | w = srom[pb + srv->off]; |
1056 | val = (w & srv->mask) >> mask_shift(srv->mask); | 756 | val = (w & srv->mask) >> mask_shift(srv->mask); |
1057 | width = mask_width(srv->mask); | 757 | width = mask_width(srv->mask); |
1058 | 758 | ||
1059 | /* Cheating: no per-path var is more than | 759 | /* Cheating: no per-path var is more than |
1060 | * 1 word */ | 760 | * 1 word */ |
1061 | if ((srv->flags & SRFL_NOFFS) | 761 | if ((srv->flags & SRFL_NOFFS) |
1062 | && ((int)val == (1 << width) - 1)) | 762 | && ((int)val == (1 << width) - 1)) |
1063 | continue; | 763 | continue; |
1064 | 764 | ||
1065 | entry = | 765 | entry = |
1066 | kzalloc(sizeof(struct brcms_srom_list_head), | 766 | kzalloc(sizeof(struct brcms_srom_list_head), |
1067 | GFP_KERNEL); | 767 | GFP_KERNEL); |
1068 | entry->varid = srv->varid+p; | 768 | entry->varid = srv->varid+p; |
1069 | entry->var_type = BRCMS_SROM_UNUMBER; | 769 | entry->var_type = BRCMS_SROM_UNUMBER; |
1070 | entry->uval = val; | 770 | entry->uval = val; |
1071 | list_add(&entry->var_list, var_list); | 771 | list_add(&entry->var_list, var_list); |
1072 | } | ||
1073 | pb += psz; | ||
1074 | } | 772 | } |
773 | pb += psz; | ||
1075 | } | 774 | } |
1076 | } | 775 | } |
1077 | 776 | ||
@@ -1080,41 +779,38 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) | |||
1080 | * Return 0 on success, nonzero on error. | 779 | * Return 0 on success, nonzero on error. |
1081 | */ | 780 | */ |
1082 | static int | 781 | static int |
1083 | sprom_read_pci(struct si_pub *sih, u16 __iomem *sprom, uint wordoff, | 782 | sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, |
1084 | u16 *buf, uint nwords, bool check_crc) | 783 | u16 *buf, uint nwords, bool check_crc) |
1085 | { | 784 | { |
1086 | int err = 0; | 785 | int err = 0; |
1087 | uint i; | 786 | uint i; |
787 | u8 *bbuf = (u8 *)buf; /* byte buffer */ | ||
788 | uint nbytes = nwords << 1; | ||
1088 | 789 | ||
1089 | /* read the sprom */ | 790 | /* read the sprom in bytes */ |
1090 | for (i = 0; i < nwords; i++) | 791 | for (i = 0; i < nbytes; i++) |
1091 | buf[i] = R_REG(&sprom[wordoff + i]); | 792 | bbuf[i] = readb(sprom+i); |
1092 | |||
1093 | if (check_crc) { | ||
1094 | 793 | ||
1095 | if (buf[0] == 0xffff) | 794 | if (buf[0] == 0xffff) |
1096 | /* | 795 | /* |
1097 | * The hardware thinks that an srom that starts with | 796 | * The hardware thinks that an srom that starts with |
1098 | * 0xffff is blank, regardless of the rest of the | 797 | * 0xffff is blank, regardless of the rest of the |
1099 | * content, so declare it bad. | 798 | * content, so declare it bad. |
1100 | */ | 799 | */ |
1101 | return -ENODATA; | 800 | return -ENODATA; |
1102 | |||
1103 | /* fixup the endianness so crc8 will pass */ | ||
1104 | htol16_buf(buf, nwords * 2); | ||
1105 | if (crc8(brcms_srom_crc8_table, (u8 *) buf, nwords * 2, | ||
1106 | CRC8_INIT_VALUE) != | ||
1107 | CRC8_GOOD_VALUE(brcms_srom_crc8_table)) | ||
1108 | /* DBG only pci always read srom4 first, then srom8/9 */ | ||
1109 | err = -EIO; | ||
1110 | 801 | ||
802 | if (check_crc && | ||
803 | crc8(brcms_srom_crc8_table, bbuf, nbytes, CRC8_INIT_VALUE) != | ||
804 | CRC8_GOOD_VALUE(brcms_srom_crc8_table)) | ||
805 | err = -EIO; | ||
806 | else | ||
1111 | /* now correct the endianness of the byte array */ | 807 | /* now correct the endianness of the byte array */ |
1112 | ltoh16_buf(buf, nwords * 2); | 808 | le16_to_cpu_buf(buf, nwords); |
1113 | } | 809 | |
1114 | return err; | 810 | return err; |
1115 | } | 811 | } |
1116 | 812 | ||
1117 | static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) | 813 | static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords) |
1118 | { | 814 | { |
1119 | u8 *otp; | 815 | u8 *otp; |
1120 | uint sz = OTP_SZ_MAX / 2; /* size in words */ | 816 | uint sz = OTP_SZ_MAX / 2; /* size in words */ |
@@ -1126,7 +822,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) | |||
1126 | 822 | ||
1127 | err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); | 823 | err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); |
1128 | 824 | ||
1129 | memcpy(buf, otp, bufsz); | 825 | sz = min_t(uint, sz, nwords); |
826 | memcpy(buf, otp, sz * 2); | ||
1130 | 827 | ||
1131 | kfree(otp); | 828 | kfree(otp); |
1132 | 829 | ||
@@ -1139,13 +836,13 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) | |||
1139 | return -ENODATA; | 836 | return -ENODATA; |
1140 | 837 | ||
1141 | /* fixup the endianness so crc8 will pass */ | 838 | /* fixup the endianness so crc8 will pass */ |
1142 | htol16_buf(buf, bufsz); | 839 | cpu_to_le16_buf(buf, sz); |
1143 | if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, | 840 | if (crc8(brcms_srom_crc8_table, (u8 *) buf, sz * 2, |
1144 | CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) | 841 | CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) |
1145 | err = -EIO; | 842 | err = -EIO; |
1146 | 843 | else | |
1147 | /* now correct the endianness of the byte array */ | 844 | /* now correct the endianness of the byte array */ |
1148 | ltoh16_buf(buf, bufsz); | 845 | le16_to_cpu_buf(buf, sz); |
1149 | 846 | ||
1150 | return err; | 847 | return err; |
1151 | } | 848 | } |
@@ -1157,7 +854,7 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) | |||
1157 | static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) | 854 | static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) |
1158 | { | 855 | { |
1159 | u16 *srom; | 856 | u16 *srom; |
1160 | u16 __iomem *sromwindow; | 857 | u8 __iomem *sromwindow; |
1161 | u8 sromrev = 0; | 858 | u8 sromrev = 0; |
1162 | u32 sr; | 859 | u32 sr; |
1163 | int err = 0; | 860 | int err = 0; |
@@ -1173,29 +870,16 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) | |||
1173 | 870 | ||
1174 | crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); | 871 | crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); |
1175 | if (ai_is_sprom_available(sih)) { | 872 | if (ai_is_sprom_available(sih)) { |
1176 | err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, | 873 | err = sprom_read_pci(sih, sromwindow, 0, srom, |
1177 | true); | 874 | SROM4_WORDS, true); |
1178 | 875 | ||
1179 | if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || | 876 | if (err == 0) |
1180 | (((sih->buscoretype == PCIE_CORE_ID) | 877 | /* srom read and passed crc */ |
1181 | && (sih->buscorerev >= 6)) | ||
1182 | || ((sih->buscoretype == PCI_CORE_ID) | ||
1183 | && (sih->buscorerev >= 0xe)))) { | ||
1184 | /* sromrev >= 4, read more */ | ||
1185 | err = sprom_read_pci(sih, sromwindow, 0, srom, | ||
1186 | SROM4_WORDS, true); | ||
1187 | sromrev = srom[SROM4_CRCREV] & 0xff; | ||
1188 | } else if (err == 0) { | ||
1189 | /* srom is good and is rev < 4 */ | ||
1190 | /* top word of sprom contains version and crc8 */ | 878 | /* top word of sprom contains version and crc8 */ |
1191 | sromrev = srom[SROM_CRCREV] & 0xff; | 879 | sromrev = srom[SROM4_CRCREV] & 0xff; |
1192 | /* bcm4401 sroms misprogrammed */ | ||
1193 | if (sromrev == 0x10) | ||
1194 | sromrev = 1; | ||
1195 | } | ||
1196 | } else { | 880 | } else { |
1197 | /* Use OTP if SPROM not available */ | 881 | /* Use OTP if SPROM not available */ |
1198 | err = otp_read_pci(sih, srom, SROM_MAX); | 882 | err = otp_read_pci(sih, srom, SROM4_WORDS); |
1199 | if (err == 0) | 883 | if (err == 0) |
1200 | /* OTP only contain SROM rev8/rev9 for now */ | 884 | /* OTP only contain SROM rev8/rev9 for now */ |
1201 | sromrev = srom[SROM4_CRCREV] & 0xff; | 885 | sromrev = srom[SROM4_CRCREV] & 0xff; |
@@ -1208,10 +892,9 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) | |||
1208 | sr = 1 << sromrev; | 892 | sr = 1 << sromrev; |
1209 | 893 | ||
1210 | /* | 894 | /* |
1211 | * srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, | 895 | * srom version check: Current valid versions: 8, 9 |
1212 | * 9 | ||
1213 | */ | 896 | */ |
1214 | if ((sr & 0x33e) == 0) { | 897 | if ((sr & 0x300) == 0) { |
1215 | err = -EINVAL; | 898 | err = -EINVAL; |
1216 | goto errout; | 899 | goto errout; |
1217 | } | 900 | } |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.h b/drivers/net/wireless/brcm80211/brcmsmac/srom.h index 708c43ff51cc..c81df9798e50 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.h | |||
@@ -26,9 +26,4 @@ extern void srom_free_vars(struct si_pub *sih); | |||
26 | extern int srom_read(struct si_pub *sih, uint bus, void *curmap, | 26 | extern int srom_read(struct si_pub *sih, uint bus, void *curmap, |
27 | uint byteoff, uint nbytes, u16 *buf, bool check_crc); | 27 | uint byteoff, uint nbytes, u16 *buf, bool check_crc); |
28 | 28 | ||
29 | /* parse standard PCMCIA cis, normally used by SB/PCMCIA/SDIO/SPI/OTP | ||
30 | * and extract from it into name=value pairs | ||
31 | */ | ||
32 | extern int srom_parsecis(u8 **pcis, uint ciscnt, | ||
33 | char **vars, uint *count); | ||
34 | #endif /* _BRCM_SROM_H_ */ | 29 | #endif /* _BRCM_SROM_H_ */ |
diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index f27c48910827..b7537f70a795 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | |||
19 | #include <brcmu_utils.h> | 20 | #include <brcmu_utils.h> |
20 | 21 | ||
21 | MODULE_AUTHOR("Broadcom Corporation"); | 22 | MODULE_AUTHOR("Broadcom Corporation"); |
@@ -40,74 +41,20 @@ EXPORT_SYMBOL(brcmu_pkt_buf_get_skb); | |||
40 | /* Free the driver packet. Free the tag if present */ | 41 | /* Free the driver packet. Free the tag if present */ |
41 | void brcmu_pkt_buf_free_skb(struct sk_buff *skb) | 42 | void brcmu_pkt_buf_free_skb(struct sk_buff *skb) |
42 | { | 43 | { |
43 | struct sk_buff *nskb; | 44 | WARN_ON(skb->next); |
44 | int nest = 0; | 45 | if (skb->destructor) |
45 | 46 | /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if | |
46 | /* perversion: we use skb->next to chain multi-skb packets */ | 47 | * destructor exists |
47 | while (skb) { | 48 | */ |
48 | nskb = skb->next; | 49 | dev_kfree_skb_any(skb); |
49 | skb->next = NULL; | 50 | else |
50 | 51 | /* can free immediately (even in_irq()) if destructor | |
51 | if (skb->destructor) | 52 | * does not exist |
52 | /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if | 53 | */ |
53 | * destructor exists | 54 | dev_kfree_skb(skb); |
54 | */ | ||
55 | dev_kfree_skb_any(skb); | ||
56 | else | ||
57 | /* can free immediately (even in_irq()) if destructor | ||
58 | * does not exist | ||
59 | */ | ||
60 | dev_kfree_skb(skb); | ||
61 | |||
62 | nest++; | ||
63 | skb = nskb; | ||
64 | } | ||
65 | } | 55 | } |
66 | EXPORT_SYMBOL(brcmu_pkt_buf_free_skb); | 56 | EXPORT_SYMBOL(brcmu_pkt_buf_free_skb); |
67 | 57 | ||
68 | |||
69 | /* copy a buffer into a pkt buffer chain */ | ||
70 | uint brcmu_pktfrombuf(struct sk_buff *p, uint offset, int len, | ||
71 | unsigned char *buf) | ||
72 | { | ||
73 | uint n, ret = 0; | ||
74 | |||
75 | /* skip 'offset' bytes */ | ||
76 | for (; p && offset; p = p->next) { | ||
77 | if (offset < (uint) (p->len)) | ||
78 | break; | ||
79 | offset -= p->len; | ||
80 | } | ||
81 | |||
82 | if (!p) | ||
83 | return 0; | ||
84 | |||
85 | /* copy the data */ | ||
86 | for (; p && len; p = p->next) { | ||
87 | n = min((uint) (p->len) - offset, (uint) len); | ||
88 | memcpy(p->data + offset, buf, n); | ||
89 | buf += n; | ||
90 | len -= n; | ||
91 | ret += n; | ||
92 | offset = 0; | ||
93 | } | ||
94 | |||
95 | return ret; | ||
96 | } | ||
97 | EXPORT_SYMBOL(brcmu_pktfrombuf); | ||
98 | |||
99 | /* return total length of buffer chain */ | ||
100 | uint brcmu_pkttotlen(struct sk_buff *p) | ||
101 | { | ||
102 | uint total; | ||
103 | |||
104 | total = 0; | ||
105 | for (; p; p = p->next) | ||
106 | total += p->len; | ||
107 | return total; | ||
108 | } | ||
109 | EXPORT_SYMBOL(brcmu_pkttotlen); | ||
110 | |||
111 | /* | 58 | /* |
112 | * osl multiple-precedence packet queue | 59 | * osl multiple-precedence packet queue |
113 | * hi_prec is always >= the number of the highest non-empty precedence | 60 | * hi_prec is always >= the number of the highest non-empty precedence |
@@ -115,21 +62,13 @@ EXPORT_SYMBOL(brcmu_pkttotlen); | |||
115 | struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, | 62 | struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, |
116 | struct sk_buff *p) | 63 | struct sk_buff *p) |
117 | { | 64 | { |
118 | struct pktq_prec *q; | 65 | struct sk_buff_head *q; |
119 | 66 | ||
120 | if (pktq_full(pq) || pktq_pfull(pq, prec)) | 67 | if (pktq_full(pq) || pktq_pfull(pq, prec)) |
121 | return NULL; | 68 | return NULL; |
122 | 69 | ||
123 | q = &pq->q[prec]; | 70 | q = &pq->q[prec].skblist; |
124 | 71 | skb_queue_tail(q, p); | |
125 | if (q->head) | ||
126 | q->tail->prev = p; | ||
127 | else | ||
128 | q->head = p; | ||
129 | |||
130 | q->tail = p; | ||
131 | q->len++; | ||
132 | |||
133 | pq->len++; | 72 | pq->len++; |
134 | 73 | ||
135 | if (pq->hi_prec < prec) | 74 | if (pq->hi_prec < prec) |
@@ -142,20 +81,13 @@ EXPORT_SYMBOL(brcmu_pktq_penq); | |||
142 | struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec, | 81 | struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec, |
143 | struct sk_buff *p) | 82 | struct sk_buff *p) |
144 | { | 83 | { |
145 | struct pktq_prec *q; | 84 | struct sk_buff_head *q; |
146 | 85 | ||
147 | if (pktq_full(pq) || pktq_pfull(pq, prec)) | 86 | if (pktq_full(pq) || pktq_pfull(pq, prec)) |
148 | return NULL; | 87 | return NULL; |
149 | 88 | ||
150 | q = &pq->q[prec]; | 89 | q = &pq->q[prec].skblist; |
151 | 90 | skb_queue_head(q, p); | |
152 | if (q->head == NULL) | ||
153 | q->tail = p; | ||
154 | |||
155 | p->prev = q->head; | ||
156 | q->head = p; | ||
157 | q->len++; | ||
158 | |||
159 | pq->len++; | 91 | pq->len++; |
160 | 92 | ||
161 | if (pq->hi_prec < prec) | 93 | if (pq->hi_prec < prec) |
@@ -167,53 +99,30 @@ EXPORT_SYMBOL(brcmu_pktq_penq_head); | |||
167 | 99 | ||
168 | struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec) | 100 | struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec) |
169 | { | 101 | { |
170 | struct pktq_prec *q; | 102 | struct sk_buff_head *q; |
171 | struct sk_buff *p; | 103 | struct sk_buff *p; |
172 | 104 | ||
173 | q = &pq->q[prec]; | 105 | q = &pq->q[prec].skblist; |
174 | 106 | p = skb_dequeue(q); | |
175 | p = q->head; | ||
176 | if (p == NULL) | 107 | if (p == NULL) |
177 | return NULL; | 108 | return NULL; |
178 | 109 | ||
179 | q->head = p->prev; | ||
180 | if (q->head == NULL) | ||
181 | q->tail = NULL; | ||
182 | |||
183 | q->len--; | ||
184 | |||
185 | pq->len--; | 110 | pq->len--; |
186 | |||
187 | p->prev = NULL; | ||
188 | |||
189 | return p; | 111 | return p; |
190 | } | 112 | } |
191 | EXPORT_SYMBOL(brcmu_pktq_pdeq); | 113 | EXPORT_SYMBOL(brcmu_pktq_pdeq); |
192 | 114 | ||
193 | struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec) | 115 | struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec) |
194 | { | 116 | { |
195 | struct pktq_prec *q; | 117 | struct sk_buff_head *q; |
196 | struct sk_buff *p, *prev; | 118 | struct sk_buff *p; |
197 | |||
198 | q = &pq->q[prec]; | ||
199 | 119 | ||
200 | p = q->head; | 120 | q = &pq->q[prec].skblist; |
121 | p = skb_dequeue_tail(q); | ||
201 | if (p == NULL) | 122 | if (p == NULL) |
202 | return NULL; | 123 | return NULL; |
203 | 124 | ||
204 | for (prev = NULL; p != q->tail; p = p->prev) | ||
205 | prev = p; | ||
206 | |||
207 | if (prev) | ||
208 | prev->prev = NULL; | ||
209 | else | ||
210 | q->head = NULL; | ||
211 | |||
212 | q->tail = prev; | ||
213 | q->len--; | ||
214 | |||
215 | pq->len--; | 125 | pq->len--; |
216 | |||
217 | return p; | 126 | return p; |
218 | } | 127 | } |
219 | EXPORT_SYMBOL(brcmu_pktq_pdeq_tail); | 128 | EXPORT_SYMBOL(brcmu_pktq_pdeq_tail); |
@@ -222,31 +131,17 @@ void | |||
222 | brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, | 131 | brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, |
223 | bool (*fn)(struct sk_buff *, void *), void *arg) | 132 | bool (*fn)(struct sk_buff *, void *), void *arg) |
224 | { | 133 | { |
225 | struct pktq_prec *q; | 134 | struct sk_buff_head *q; |
226 | struct sk_buff *p, *prev = NULL; | 135 | struct sk_buff *p, *next; |
227 | 136 | ||
228 | q = &pq->q[prec]; | 137 | q = &pq->q[prec].skblist; |
229 | p = q->head; | 138 | skb_queue_walk_safe(q, p, next) { |
230 | while (p) { | ||
231 | if (fn == NULL || (*fn) (p, arg)) { | 139 | if (fn == NULL || (*fn) (p, arg)) { |
232 | bool head = (p == q->head); | 140 | skb_unlink(p, q); |
233 | if (head) | ||
234 | q->head = p->prev; | ||
235 | else | ||
236 | prev->prev = p->prev; | ||
237 | p->prev = NULL; | ||
238 | brcmu_pkt_buf_free_skb(p); | 141 | brcmu_pkt_buf_free_skb(p); |
239 | q->len--; | ||
240 | pq->len--; | 142 | pq->len--; |
241 | p = (head ? q->head : prev->prev); | ||
242 | } else { | ||
243 | prev = p; | ||
244 | p = p->prev; | ||
245 | } | 143 | } |
246 | } | 144 | } |
247 | |||
248 | if (q->head == NULL) | ||
249 | q->tail = NULL; | ||
250 | } | 145 | } |
251 | EXPORT_SYMBOL(brcmu_pktq_pflush); | 146 | EXPORT_SYMBOL(brcmu_pktq_pflush); |
252 | 147 | ||
@@ -271,8 +166,10 @@ void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len) | |||
271 | 166 | ||
272 | pq->max = (u16) max_len; | 167 | pq->max = (u16) max_len; |
273 | 168 | ||
274 | for (prec = 0; prec < num_prec; prec++) | 169 | for (prec = 0; prec < num_prec; prec++) { |
275 | pq->q[prec].max = pq->max; | 170 | pq->q[prec].max = pq->max; |
171 | skb_queue_head_init(&pq->q[prec].skblist); | ||
172 | } | ||
276 | } | 173 | } |
277 | EXPORT_SYMBOL(brcmu_pktq_init); | 174 | EXPORT_SYMBOL(brcmu_pktq_init); |
278 | 175 | ||
@@ -284,13 +181,13 @@ struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out) | |||
284 | return NULL; | 181 | return NULL; |
285 | 182 | ||
286 | for (prec = 0; prec < pq->hi_prec; prec++) | 183 | for (prec = 0; prec < pq->hi_prec; prec++) |
287 | if (pq->q[prec].head) | 184 | if (!skb_queue_empty(&pq->q[prec].skblist)) |
288 | break; | 185 | break; |
289 | 186 | ||
290 | if (prec_out) | 187 | if (prec_out) |
291 | *prec_out = prec; | 188 | *prec_out = prec; |
292 | 189 | ||
293 | return pq->q[prec].tail; | 190 | return skb_peek_tail(&pq->q[prec].skblist); |
294 | } | 191 | } |
295 | EXPORT_SYMBOL(brcmu_pktq_peek_tail); | 192 | EXPORT_SYMBOL(brcmu_pktq_peek_tail); |
296 | 193 | ||
@@ -303,7 +200,7 @@ int brcmu_pktq_mlen(struct pktq *pq, uint prec_bmp) | |||
303 | 200 | ||
304 | for (prec = 0; prec <= pq->hi_prec; prec++) | 201 | for (prec = 0; prec <= pq->hi_prec; prec++) |
305 | if (prec_bmp & (1 << prec)) | 202 | if (prec_bmp & (1 << prec)) |
306 | len += pq->q[prec].len; | 203 | len += pq->q[prec].skblist.qlen; |
307 | 204 | ||
308 | return len; | 205 | return len; |
309 | } | 206 | } |
@@ -313,39 +210,32 @@ EXPORT_SYMBOL(brcmu_pktq_mlen); | |||
313 | struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, | 210 | struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, |
314 | int *prec_out) | 211 | int *prec_out) |
315 | { | 212 | { |
316 | struct pktq_prec *q; | 213 | struct sk_buff_head *q; |
317 | struct sk_buff *p; | 214 | struct sk_buff *p; |
318 | int prec; | 215 | int prec; |
319 | 216 | ||
320 | if (pq->len == 0) | 217 | if (pq->len == 0) |
321 | return NULL; | 218 | return NULL; |
322 | 219 | ||
323 | while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL) | 220 | while ((prec = pq->hi_prec) > 0 && |
221 | skb_queue_empty(&pq->q[prec].skblist)) | ||
324 | pq->hi_prec--; | 222 | pq->hi_prec--; |
325 | 223 | ||
326 | while ((prec_bmp & (1 << prec)) == 0 || pq->q[prec].head == NULL) | 224 | while ((prec_bmp & (1 << prec)) == 0 || |
225 | skb_queue_empty(&pq->q[prec].skblist)) | ||
327 | if (prec-- == 0) | 226 | if (prec-- == 0) |
328 | return NULL; | 227 | return NULL; |
329 | 228 | ||
330 | q = &pq->q[prec]; | 229 | q = &pq->q[prec].skblist; |
331 | 230 | p = skb_dequeue(q); | |
332 | p = q->head; | ||
333 | if (p == NULL) | 231 | if (p == NULL) |
334 | return NULL; | 232 | return NULL; |
335 | 233 | ||
336 | q->head = p->prev; | 234 | pq->len--; |
337 | if (q->head == NULL) | ||
338 | q->tail = NULL; | ||
339 | |||
340 | q->len--; | ||
341 | 235 | ||
342 | if (prec_out) | 236 | if (prec_out) |
343 | *prec_out = prec; | 237 | *prec_out = prec; |
344 | 238 | ||
345 | pq->len--; | ||
346 | |||
347 | p->prev = NULL; | ||
348 | |||
349 | return p; | 239 | return p; |
350 | } | 240 | } |
351 | EXPORT_SYMBOL(brcmu_pktq_mdeq); | 241 | EXPORT_SYMBOL(brcmu_pktq_mdeq); |
@@ -364,23 +254,3 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0) | |||
364 | } | 254 | } |
365 | EXPORT_SYMBOL(brcmu_prpkt); | 255 | EXPORT_SYMBOL(brcmu_prpkt); |
366 | #endif /* defined(BCMDBG) */ | 256 | #endif /* defined(BCMDBG) */ |
367 | |||
368 | #if defined(BCMDBG) | ||
369 | /* | ||
370 | * print bytes formatted as hex to a string. return the resulting | ||
371 | * string length | ||
372 | */ | ||
373 | int brcmu_format_hex(char *str, const void *bytes, int len) | ||
374 | { | ||
375 | int i; | ||
376 | char *p = str; | ||
377 | const u8 *src = (const u8 *)bytes; | ||
378 | |||
379 | for (i = 0; i < len; i++) { | ||
380 | p += snprintf(p, 3, "%02X", *src); | ||
381 | src++; | ||
382 | } | ||
383 | return (int)(p - str); | ||
384 | } | ||
385 | EXPORT_SYMBOL(brcmu_format_hex); | ||
386 | #endif /* defined(BCMDBG) */ | ||
diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index 7d0f46e0eb95..ad249a0b4730 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h | |||
@@ -65,9 +65,7 @@ | |||
65 | #define ETHER_ADDR_STR_LEN 18 | 65 | #define ETHER_ADDR_STR_LEN 18 |
66 | 66 | ||
67 | struct pktq_prec { | 67 | struct pktq_prec { |
68 | struct sk_buff *head; /* first packet to dequeue */ | 68 | struct sk_buff_head skblist; |
69 | struct sk_buff *tail; /* last packet to dequeue */ | ||
70 | u16 len; /* number of queued packets */ | ||
71 | u16 max; /* maximum number of queued packets */ | 69 | u16 max; /* maximum number of queued packets */ |
72 | }; | 70 | }; |
73 | 71 | ||
@@ -88,32 +86,32 @@ struct pktq { | |||
88 | 86 | ||
89 | static inline int pktq_plen(struct pktq *pq, int prec) | 87 | static inline int pktq_plen(struct pktq *pq, int prec) |
90 | { | 88 | { |
91 | return pq->q[prec].len; | 89 | return pq->q[prec].skblist.qlen; |
92 | } | 90 | } |
93 | 91 | ||
94 | static inline int pktq_pavail(struct pktq *pq, int prec) | 92 | static inline int pktq_pavail(struct pktq *pq, int prec) |
95 | { | 93 | { |
96 | return pq->q[prec].max - pq->q[prec].len; | 94 | return pq->q[prec].max - pq->q[prec].skblist.qlen; |
97 | } | 95 | } |
98 | 96 | ||
99 | static inline bool pktq_pfull(struct pktq *pq, int prec) | 97 | static inline bool pktq_pfull(struct pktq *pq, int prec) |
100 | { | 98 | { |
101 | return pq->q[prec].len >= pq->q[prec].max; | 99 | return pq->q[prec].skblist.qlen >= pq->q[prec].max; |
102 | } | 100 | } |
103 | 101 | ||
104 | static inline bool pktq_pempty(struct pktq *pq, int prec) | 102 | static inline bool pktq_pempty(struct pktq *pq, int prec) |
105 | { | 103 | { |
106 | return pq->q[prec].len == 0; | 104 | return skb_queue_empty(&pq->q[prec].skblist); |
107 | } | 105 | } |
108 | 106 | ||
109 | static inline struct sk_buff *pktq_ppeek(struct pktq *pq, int prec) | 107 | static inline struct sk_buff *pktq_ppeek(struct pktq *pq, int prec) |
110 | { | 108 | { |
111 | return pq->q[prec].head; | 109 | return skb_peek(&pq->q[prec].skblist); |
112 | } | 110 | } |
113 | 111 | ||
114 | static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec) | 112 | static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec) |
115 | { | 113 | { |
116 | return pq->q[prec].tail; | 114 | return skb_peek_tail(&pq->q[prec].skblist); |
117 | } | 115 | } |
118 | 116 | ||
119 | extern struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, | 117 | extern struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, |
@@ -172,24 +170,16 @@ extern void brcmu_pktq_flush(struct pktq *pq, bool dir, | |||
172 | bool (*fn)(struct sk_buff *, void *), void *arg); | 170 | bool (*fn)(struct sk_buff *, void *), void *arg); |
173 | 171 | ||
174 | /* externs */ | 172 | /* externs */ |
175 | /* packet */ | ||
176 | extern uint brcmu_pktfrombuf(struct sk_buff *p, | ||
177 | uint offset, int len, unsigned char *buf); | ||
178 | extern uint brcmu_pkttotlen(struct sk_buff *p); | ||
179 | |||
180 | /* ip address */ | 173 | /* ip address */ |
181 | struct ipv4_addr; | 174 | struct ipv4_addr; |
182 | 175 | ||
176 | |||
177 | /* externs */ | ||
178 | /* format/print */ | ||
183 | #ifdef BCMDBG | 179 | #ifdef BCMDBG |
184 | extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); | 180 | extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); |
185 | #else | 181 | #else |
186 | #define brcmu_prpkt(a, b) | 182 | #define brcmu_prpkt(a, b) |
187 | #endif /* BCMDBG */ | 183 | #endif /* BCMDBG */ |
188 | 184 | ||
189 | /* externs */ | ||
190 | /* format/print */ | ||
191 | #if defined(BCMDBG) | ||
192 | extern int brcmu_format_hex(char *str, const void *bytes, int len); | ||
193 | #endif | ||
194 | |||
195 | #endif /* _BRCMU_UTILS_H_ */ | 185 | #endif /* _BRCMU_UTILS_H_ */ |
diff --git a/drivers/net/wireless/brcm80211/include/defs.h b/drivers/net/wireless/brcm80211/include/defs.h index 1e5f310af1e7..f0d8c04a9c8c 100644 --- a/drivers/net/wireless/brcm80211/include/defs.h +++ b/drivers/net/wireless/brcm80211/include/defs.h | |||
@@ -62,7 +62,6 @@ | |||
62 | 62 | ||
63 | #define WL_RADIO_SW_DISABLE (1<<0) | 63 | #define WL_RADIO_SW_DISABLE (1<<0) |
64 | #define WL_RADIO_HW_DISABLE (1<<1) | 64 | #define WL_RADIO_HW_DISABLE (1<<1) |
65 | #define WL_RADIO_MPC_DISABLE (1<<2) | ||
66 | /* some countries don't support any channel */ | 65 | /* some countries don't support any channel */ |
67 | #define WL_RADIO_COUNTRY_DISABLE (1<<3) | 66 | #define WL_RADIO_COUNTRY_DISABLE (1<<3) |
68 | 67 | ||
diff --git a/drivers/net/wireless/brcm80211/include/soc.h b/drivers/net/wireless/brcm80211/include/soc.h index 4fcb956ad9e0..4e9b7e4827ea 100644 --- a/drivers/net/wireless/brcm80211/include/soc.h +++ b/drivers/net/wireless/brcm80211/include/soc.h | |||
@@ -77,8 +77,9 @@ | |||
77 | #define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ | 77 | #define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ |
78 | #define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ | 78 | #define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ |
79 | #define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ | 79 | #define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ |
80 | /* Default component, in ai chips it maps all unused address ranges */ | 80 | #define DEF_AI_COMP 0xfff /* Default component, in ai chips it |
81 | #define DEF_AI_COMP 0xfff | 81 | * maps all unused address ranges |
82 | */ | ||
82 | 83 | ||
83 | /* Common core control flags */ | 84 | /* Common core control flags */ |
84 | #define SICF_BIST_EN 0x8000 | 85 | #define SICF_BIST_EN 0x8000 |
@@ -87,4 +88,11 @@ | |||
87 | #define SICF_FGC 0x0002 | 88 | #define SICF_FGC 0x0002 |
88 | #define SICF_CLOCK_EN 0x0001 | 89 | #define SICF_CLOCK_EN 0x0001 |
89 | 90 | ||
91 | /* Common core status flags */ | ||
92 | #define SISF_BIST_DONE 0x8000 | ||
93 | #define SISF_BIST_ERROR 0x4000 | ||
94 | #define SISF_GATED_CLK 0x2000 | ||
95 | #define SISF_DMA64 0x1000 | ||
96 | #define SISF_CORE_BITS 0x0fff | ||
97 | |||
90 | #endif /* _BRCM_SOC_H */ | 98 | #endif /* _BRCM_SOC_H */ |
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 99a710dfe771..99575884ff52 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c | |||
@@ -131,6 +131,14 @@ static struct ieee80211_rate ipw2200_rates[] = { | |||
131 | #define ipw2200_bg_rates (ipw2200_rates + 0) | 131 | #define ipw2200_bg_rates (ipw2200_rates + 0) |
132 | #define ipw2200_num_bg_rates 12 | 132 | #define ipw2200_num_bg_rates 12 |
133 | 133 | ||
134 | /* Ugly macro to convert literal channel numbers into their mhz equivalents | ||
135 | * There are certianly some conditions that will break this (like feeding it '30') | ||
136 | * but they shouldn't arise since nothing talks on channel 30. */ | ||
137 | #define ieee80211chan2mhz(x) \ | ||
138 | (((x) <= 14) ? \ | ||
139 | (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ | ||
140 | ((x) + 1000) * 5) | ||
141 | |||
134 | #ifdef CONFIG_IPW2200_QOS | 142 | #ifdef CONFIG_IPW2200_QOS |
135 | static int qos_enable = 0; | 143 | static int qos_enable = 0; |
136 | static int qos_burst_enable = 0; | 144 | static int qos_burst_enable = 0; |
diff --git a/drivers/net/wireless/ipw2x00/libipw.h b/drivers/net/wireless/ipw2x00/libipw.h index 70f5586d96bd..3d5821eeb054 100644 --- a/drivers/net/wireless/ipw2x00/libipw.h +++ b/drivers/net/wireless/ipw2x00/libipw.h | |||
@@ -66,16 +66,8 @@ extern u32 libipw_debug_level; | |||
66 | do { if (libipw_debug_level & (level)) \ | 66 | do { if (libipw_debug_level & (level)) \ |
67 | printk(KERN_DEBUG "libipw: %c %s " fmt, \ | 67 | printk(KERN_DEBUG "libipw: %c %s " fmt, \ |
68 | in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0) | 68 | in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0) |
69 | static inline bool libipw_ratelimit_debug(u32 level) | ||
70 | { | ||
71 | return (libipw_debug_level & level) && net_ratelimit(); | ||
72 | } | ||
73 | #else | 69 | #else |
74 | #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0) | 70 | #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0) |
75 | static inline bool libipw_ratelimit_debug(u32 level) | ||
76 | { | ||
77 | return false; | ||
78 | } | ||
79 | #endif /* CONFIG_LIBIPW_DEBUG */ | 71 | #endif /* CONFIG_LIBIPW_DEBUG */ |
80 | 72 | ||
81 | /* | 73 | /* |
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index c73e5ed8db5e..a7ab280994c8 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | # WIFI | 1 | # WIFI |
2 | obj-$(CONFIG_IWLWIFI) += iwlwifi.o | 2 | obj-$(CONFIG_IWLWIFI) += iwlwifi.o |
3 | iwlwifi-objs := iwl-agn.o iwl-agn-rs.o | 3 | iwlwifi-objs := iwl-agn.o iwl-agn-rs.o iwl-mac80211.o |
4 | iwlwifi-objs += iwl-agn-ucode.o iwl-agn-tx.o | 4 | iwlwifi-objs += iwl-agn-ucode.o iwl-agn-tx.o |
5 | iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o | 5 | iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o |
6 | iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o | 6 | iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o |
diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 79431977a968..b3193571ed07 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c | |||
@@ -270,11 +270,6 @@ struct iwl_cfg iwl2000_2bgn_cfg = { | |||
270 | .ht_params = &iwl2000_ht_params, | 270 | .ht_params = &iwl2000_ht_params, |
271 | }; | 271 | }; |
272 | 272 | ||
273 | struct iwl_cfg iwl2000_2bg_cfg = { | ||
274 | .name = "2000 Series 2x2 BG", | ||
275 | IWL_DEVICE_2000, | ||
276 | }; | ||
277 | |||
278 | struct iwl_cfg iwl2000_2bgn_d_cfg = { | 273 | struct iwl_cfg iwl2000_2bgn_d_cfg = { |
279 | .name = "2000D Series 2x2 BGN", | 274 | .name = "2000D Series 2x2 BGN", |
280 | IWL_DEVICE_2000, | 275 | IWL_DEVICE_2000, |
@@ -304,11 +299,6 @@ struct iwl_cfg iwl2030_2bgn_cfg = { | |||
304 | .ht_params = &iwl2000_ht_params, | 299 | .ht_params = &iwl2000_ht_params, |
305 | }; | 300 | }; |
306 | 301 | ||
307 | struct iwl_cfg iwl2030_2bg_cfg = { | ||
308 | .name = "2000 Series 2x2 BG/BT", | ||
309 | IWL_DEVICE_2030, | ||
310 | }; | ||
311 | |||
312 | #define IWL_DEVICE_105 \ | 302 | #define IWL_DEVICE_105 \ |
313 | .fw_name_pre = IWL105_FW_PRE, \ | 303 | .fw_name_pre = IWL105_FW_PRE, \ |
314 | .ucode_api_max = IWL105_UCODE_API_MAX, \ | 304 | .ucode_api_max = IWL105_UCODE_API_MAX, \ |
@@ -326,11 +316,6 @@ struct iwl_cfg iwl2030_2bg_cfg = { | |||
326 | .rx_with_siso_diversity = true, \ | 316 | .rx_with_siso_diversity = true, \ |
327 | .iq_invert = true \ | 317 | .iq_invert = true \ |
328 | 318 | ||
329 | struct iwl_cfg iwl105_bg_cfg = { | ||
330 | .name = "105 Series 1x1 BG", | ||
331 | IWL_DEVICE_105, | ||
332 | }; | ||
333 | |||
334 | struct iwl_cfg iwl105_bgn_cfg = { | 319 | struct iwl_cfg iwl105_bgn_cfg = { |
335 | .name = "105 Series 1x1 BGN", | 320 | .name = "105 Series 1x1 BGN", |
336 | IWL_DEVICE_105, | 321 | IWL_DEVICE_105, |
@@ -361,11 +346,6 @@ struct iwl_cfg iwl105_bgn_d_cfg = { | |||
361 | .rx_with_siso_diversity = true, \ | 346 | .rx_with_siso_diversity = true, \ |
362 | .iq_invert = true \ | 347 | .iq_invert = true \ |
363 | 348 | ||
364 | struct iwl_cfg iwl135_bg_cfg = { | ||
365 | .name = "135 Series 1x1 BG/BT", | ||
366 | IWL_DEVICE_135, | ||
367 | }; | ||
368 | |||
369 | struct iwl_cfg iwl135_bgn_cfg = { | 349 | struct iwl_cfg iwl135_bgn_cfg = { |
370 | .name = "135 Series 1x1 BGN/BT", | 350 | .name = "135 Series 1x1 BGN/BT", |
371 | IWL_DEVICE_135, | 351 | IWL_DEVICE_135, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index c840c78278db..ee3363fdf309 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c | |||
@@ -439,16 +439,6 @@ struct iwl_cfg iwl6035_2agn_cfg = { | |||
439 | .ht_params = &iwl6000_ht_params, | 439 | .ht_params = &iwl6000_ht_params, |
440 | }; | 440 | }; |
441 | 441 | ||
442 | struct iwl_cfg iwl6035_2abg_cfg = { | ||
443 | .name = "6035 Series 2x2 ABG/BT", | ||
444 | IWL_DEVICE_6030, | ||
445 | }; | ||
446 | |||
447 | struct iwl_cfg iwl6035_2bg_cfg = { | ||
448 | .name = "6035 Series 2x2 BG/BT", | ||
449 | IWL_DEVICE_6030, | ||
450 | }; | ||
451 | |||
452 | struct iwl_cfg iwl1030_bgn_cfg = { | 442 | struct iwl_cfg iwl1030_bgn_cfg = { |
453 | .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN", | 443 | .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN", |
454 | IWL_DEVICE_6030, | 444 | IWL_DEVICE_6030, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 1a52ed29f2d6..0bc962217351 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c | |||
@@ -827,6 +827,7 @@ static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) | |||
827 | case IEEE80211_SMPS_STATIC: | 827 | case IEEE80211_SMPS_STATIC: |
828 | case IEEE80211_SMPS_DYNAMIC: | 828 | case IEEE80211_SMPS_DYNAMIC: |
829 | return IWL_NUM_IDLE_CHAINS_SINGLE; | 829 | return IWL_NUM_IDLE_CHAINS_SINGLE; |
830 | case IEEE80211_SMPS_AUTOMATIC: | ||
830 | case IEEE80211_SMPS_OFF: | 831 | case IEEE80211_SMPS_OFF: |
831 | return active_cnt; | 832 | return active_cnt; |
832 | default: | 833 | default: |
@@ -983,3 +984,360 @@ void iwlagn_remove_notification(struct iwl_priv *priv, | |||
983 | list_del(&wait_entry->list); | 984 | list_del(&wait_entry->list); |
984 | spin_unlock_bh(&priv->notif_wait_lock); | 985 | spin_unlock_bh(&priv->notif_wait_lock); |
985 | } | 986 | } |
987 | |||
988 | #ifdef CONFIG_PM_SLEEP | ||
989 | static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) | ||
990 | { | ||
991 | int i; | ||
992 | |||
993 | for (i = 0; i < IWLAGN_P1K_SIZE; i++) | ||
994 | out[i] = cpu_to_le16(p1k[i]); | ||
995 | } | ||
996 | |||
997 | struct wowlan_key_data { | ||
998 | struct iwl_rxon_context *ctx; | ||
999 | struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; | ||
1000 | struct iwlagn_wowlan_tkip_params_cmd *tkip; | ||
1001 | const u8 *bssid; | ||
1002 | bool error, use_rsc_tsc, use_tkip; | ||
1003 | }; | ||
1004 | |||
1005 | |||
1006 | static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, | ||
1007 | struct ieee80211_vif *vif, | ||
1008 | struct ieee80211_sta *sta, | ||
1009 | struct ieee80211_key_conf *key, | ||
1010 | void *_data) | ||
1011 | { | ||
1012 | struct iwl_priv *priv = hw->priv; | ||
1013 | struct wowlan_key_data *data = _data; | ||
1014 | struct iwl_rxon_context *ctx = data->ctx; | ||
1015 | struct aes_sc *aes_sc, *aes_tx_sc = NULL; | ||
1016 | struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; | ||
1017 | struct iwlagn_p1k_cache *rx_p1ks; | ||
1018 | u8 *rx_mic_key; | ||
1019 | struct ieee80211_key_seq seq; | ||
1020 | u32 cur_rx_iv32 = 0; | ||
1021 | u16 p1k[IWLAGN_P1K_SIZE]; | ||
1022 | int ret, i; | ||
1023 | |||
1024 | mutex_lock(&priv->shrd->mutex); | ||
1025 | |||
1026 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
1027 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && | ||
1028 | !sta && !ctx->key_mapping_keys) | ||
1029 | ret = iwl_set_default_wep_key(priv, ctx, key); | ||
1030 | else | ||
1031 | ret = iwl_set_dynamic_key(priv, ctx, key, sta); | ||
1032 | |||
1033 | if (ret) { | ||
1034 | IWL_ERR(priv, "Error setting key during suspend!\n"); | ||
1035 | data->error = true; | ||
1036 | } | ||
1037 | |||
1038 | switch (key->cipher) { | ||
1039 | case WLAN_CIPHER_SUITE_TKIP: | ||
1040 | if (sta) { | ||
1041 | tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; | ||
1042 | tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; | ||
1043 | |||
1044 | rx_p1ks = data->tkip->rx_uni; | ||
1045 | |||
1046 | ieee80211_get_key_tx_seq(key, &seq); | ||
1047 | tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); | ||
1048 | tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); | ||
1049 | |||
1050 | ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); | ||
1051 | iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); | ||
1052 | |||
1053 | memcpy(data->tkip->mic_keys.tx, | ||
1054 | &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], | ||
1055 | IWLAGN_MIC_KEY_SIZE); | ||
1056 | |||
1057 | rx_mic_key = data->tkip->mic_keys.rx_unicast; | ||
1058 | } else { | ||
1059 | tkip_sc = | ||
1060 | data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; | ||
1061 | rx_p1ks = data->tkip->rx_multi; | ||
1062 | rx_mic_key = data->tkip->mic_keys.rx_mcast; | ||
1063 | } | ||
1064 | |||
1065 | /* | ||
1066 | * For non-QoS this relies on the fact that both the uCode and | ||
1067 | * mac80211 use TID 0 (as they need to to avoid replay attacks) | ||
1068 | * for checking the IV in the frames. | ||
1069 | */ | ||
1070 | for (i = 0; i < IWLAGN_NUM_RSC; i++) { | ||
1071 | ieee80211_get_key_rx_seq(key, i, &seq); | ||
1072 | tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); | ||
1073 | tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); | ||
1074 | /* wrapping isn't allowed, AP must rekey */ | ||
1075 | if (seq.tkip.iv32 > cur_rx_iv32) | ||
1076 | cur_rx_iv32 = seq.tkip.iv32; | ||
1077 | } | ||
1078 | |||
1079 | ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); | ||
1080 | iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); | ||
1081 | ieee80211_get_tkip_rx_p1k(key, data->bssid, | ||
1082 | cur_rx_iv32 + 1, p1k); | ||
1083 | iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); | ||
1084 | |||
1085 | memcpy(rx_mic_key, | ||
1086 | &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], | ||
1087 | IWLAGN_MIC_KEY_SIZE); | ||
1088 | |||
1089 | data->use_tkip = true; | ||
1090 | data->use_rsc_tsc = true; | ||
1091 | break; | ||
1092 | case WLAN_CIPHER_SUITE_CCMP: | ||
1093 | if (sta) { | ||
1094 | u8 *pn = seq.ccmp.pn; | ||
1095 | |||
1096 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; | ||
1097 | aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; | ||
1098 | |||
1099 | ieee80211_get_key_tx_seq(key, &seq); | ||
1100 | aes_tx_sc->pn = cpu_to_le64( | ||
1101 | (u64)pn[5] | | ||
1102 | ((u64)pn[4] << 8) | | ||
1103 | ((u64)pn[3] << 16) | | ||
1104 | ((u64)pn[2] << 24) | | ||
1105 | ((u64)pn[1] << 32) | | ||
1106 | ((u64)pn[0] << 40)); | ||
1107 | } else | ||
1108 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; | ||
1109 | |||
1110 | /* | ||
1111 | * For non-QoS this relies on the fact that both the uCode and | ||
1112 | * mac80211 use TID 0 for checking the IV in the frames. | ||
1113 | */ | ||
1114 | for (i = 0; i < IWLAGN_NUM_RSC; i++) { | ||
1115 | u8 *pn = seq.ccmp.pn; | ||
1116 | |||
1117 | ieee80211_get_key_rx_seq(key, i, &seq); | ||
1118 | aes_sc->pn = cpu_to_le64( | ||
1119 | (u64)pn[5] | | ||
1120 | ((u64)pn[4] << 8) | | ||
1121 | ((u64)pn[3] << 16) | | ||
1122 | ((u64)pn[2] << 24) | | ||
1123 | ((u64)pn[1] << 32) | | ||
1124 | ((u64)pn[0] << 40)); | ||
1125 | } | ||
1126 | data->use_rsc_tsc = true; | ||
1127 | break; | ||
1128 | } | ||
1129 | |||
1130 | mutex_unlock(&priv->shrd->mutex); | ||
1131 | } | ||
1132 | |||
1133 | int iwlagn_send_patterns(struct iwl_priv *priv, | ||
1134 | struct cfg80211_wowlan *wowlan) | ||
1135 | { | ||
1136 | struct iwlagn_wowlan_patterns_cmd *pattern_cmd; | ||
1137 | struct iwl_host_cmd cmd = { | ||
1138 | .id = REPLY_WOWLAN_PATTERNS, | ||
1139 | .dataflags[0] = IWL_HCMD_DFL_NOCOPY, | ||
1140 | .flags = CMD_SYNC, | ||
1141 | }; | ||
1142 | int i, err; | ||
1143 | |||
1144 | if (!wowlan->n_patterns) | ||
1145 | return 0; | ||
1146 | |||
1147 | cmd.len[0] = sizeof(*pattern_cmd) + | ||
1148 | wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); | ||
1149 | |||
1150 | pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); | ||
1151 | if (!pattern_cmd) | ||
1152 | return -ENOMEM; | ||
1153 | |||
1154 | pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); | ||
1155 | |||
1156 | for (i = 0; i < wowlan->n_patterns; i++) { | ||
1157 | int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); | ||
1158 | |||
1159 | memcpy(&pattern_cmd->patterns[i].mask, | ||
1160 | wowlan->patterns[i].mask, mask_len); | ||
1161 | memcpy(&pattern_cmd->patterns[i].pattern, | ||
1162 | wowlan->patterns[i].pattern, | ||
1163 | wowlan->patterns[i].pattern_len); | ||
1164 | pattern_cmd->patterns[i].mask_size = mask_len; | ||
1165 | pattern_cmd->patterns[i].pattern_size = | ||
1166 | wowlan->patterns[i].pattern_len; | ||
1167 | } | ||
1168 | |||
1169 | cmd.data[0] = pattern_cmd; | ||
1170 | err = iwl_trans_send_cmd(trans(priv), &cmd); | ||
1171 | kfree(pattern_cmd); | ||
1172 | return err; | ||
1173 | } | ||
1174 | |||
1175 | int iwlagn_suspend(struct iwl_priv *priv, | ||
1176 | struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) | ||
1177 | { | ||
1178 | struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; | ||
1179 | struct iwl_rxon_cmd rxon; | ||
1180 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
1181 | struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; | ||
1182 | struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; | ||
1183 | struct iwlagn_d3_config_cmd d3_cfg_cmd = {}; | ||
1184 | struct wowlan_key_data key_data = { | ||
1185 | .ctx = ctx, | ||
1186 | .bssid = ctx->active.bssid_addr, | ||
1187 | .use_rsc_tsc = false, | ||
1188 | .tkip = &tkip_cmd, | ||
1189 | .use_tkip = false, | ||
1190 | }; | ||
1191 | int ret, i; | ||
1192 | u16 seq; | ||
1193 | |||
1194 | key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); | ||
1195 | if (!key_data.rsc_tsc) | ||
1196 | return -ENOMEM; | ||
1197 | |||
1198 | memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); | ||
1199 | |||
1200 | /* | ||
1201 | * We know the last used seqno, and the uCode expects to know that | ||
1202 | * one, it will increment before TX. | ||
1203 | */ | ||
1204 | seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; | ||
1205 | wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); | ||
1206 | |||
1207 | /* | ||
1208 | * For QoS counters, we store the one to use next, so subtract 0x10 | ||
1209 | * since the uCode will add 0x10 before using the value. | ||
1210 | */ | ||
1211 | for (i = 0; i < 8; i++) { | ||
1212 | seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; | ||
1213 | seq -= 0x10; | ||
1214 | wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); | ||
1215 | } | ||
1216 | |||
1217 | if (wowlan->disconnect) | ||
1218 | wakeup_filter_cmd.enabled |= | ||
1219 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | | ||
1220 | IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); | ||
1221 | if (wowlan->magic_pkt) | ||
1222 | wakeup_filter_cmd.enabled |= | ||
1223 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); | ||
1224 | if (wowlan->gtk_rekey_failure) | ||
1225 | wakeup_filter_cmd.enabled |= | ||
1226 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); | ||
1227 | if (wowlan->eap_identity_req) | ||
1228 | wakeup_filter_cmd.enabled |= | ||
1229 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); | ||
1230 | if (wowlan->four_way_handshake) | ||
1231 | wakeup_filter_cmd.enabled |= | ||
1232 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); | ||
1233 | if (wowlan->n_patterns) | ||
1234 | wakeup_filter_cmd.enabled |= | ||
1235 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); | ||
1236 | |||
1237 | if (wowlan->rfkill_release) | ||
1238 | d3_cfg_cmd.wakeup_flags |= | ||
1239 | cpu_to_le32(IWLAGN_D3_WAKEUP_RFKILL); | ||
1240 | |||
1241 | iwl_scan_cancel_timeout(priv, 200); | ||
1242 | |||
1243 | memcpy(&rxon, &ctx->active, sizeof(rxon)); | ||
1244 | |||
1245 | iwl_trans_stop_device(trans(priv)); | ||
1246 | |||
1247 | priv->shrd->wowlan = true; | ||
1248 | |||
1249 | ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); | ||
1250 | if (ret) | ||
1251 | goto out; | ||
1252 | |||
1253 | /* now configure WoWLAN ucode */ | ||
1254 | ret = iwl_alive_start(priv); | ||
1255 | if (ret) | ||
1256 | goto out; | ||
1257 | |||
1258 | memcpy(&ctx->staging, &rxon, sizeof(rxon)); | ||
1259 | ret = iwlagn_commit_rxon(priv, ctx); | ||
1260 | if (ret) | ||
1261 | goto out; | ||
1262 | |||
1263 | ret = iwl_power_update_mode(priv, true); | ||
1264 | if (ret) | ||
1265 | goto out; | ||
1266 | |||
1267 | if (!iwlagn_mod_params.sw_crypto) { | ||
1268 | /* mark all keys clear */ | ||
1269 | priv->ucode_key_table = 0; | ||
1270 | ctx->key_mapping_keys = 0; | ||
1271 | |||
1272 | /* | ||
1273 | * This needs to be unlocked due to lock ordering | ||
1274 | * constraints. Since we're in the suspend path | ||
1275 | * that isn't really a problem though. | ||
1276 | */ | ||
1277 | mutex_unlock(&priv->shrd->mutex); | ||
1278 | ieee80211_iter_keys(priv->hw, ctx->vif, | ||
1279 | iwlagn_wowlan_program_keys, | ||
1280 | &key_data); | ||
1281 | mutex_lock(&priv->shrd->mutex); | ||
1282 | if (key_data.error) { | ||
1283 | ret = -EIO; | ||
1284 | goto out; | ||
1285 | } | ||
1286 | |||
1287 | if (key_data.use_rsc_tsc) { | ||
1288 | struct iwl_host_cmd rsc_tsc_cmd = { | ||
1289 | .id = REPLY_WOWLAN_TSC_RSC_PARAMS, | ||
1290 | .flags = CMD_SYNC, | ||
1291 | .data[0] = key_data.rsc_tsc, | ||
1292 | .dataflags[0] = IWL_HCMD_DFL_NOCOPY, | ||
1293 | .len[0] = sizeof(key_data.rsc_tsc), | ||
1294 | }; | ||
1295 | |||
1296 | ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); | ||
1297 | if (ret) | ||
1298 | goto out; | ||
1299 | } | ||
1300 | |||
1301 | if (key_data.use_tkip) { | ||
1302 | ret = iwl_trans_send_cmd_pdu(trans(priv), | ||
1303 | REPLY_WOWLAN_TKIP_PARAMS, | ||
1304 | CMD_SYNC, sizeof(tkip_cmd), | ||
1305 | &tkip_cmd); | ||
1306 | if (ret) | ||
1307 | goto out; | ||
1308 | } | ||
1309 | |||
1310 | if (priv->have_rekey_data) { | ||
1311 | memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); | ||
1312 | memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); | ||
1313 | kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); | ||
1314 | memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); | ||
1315 | kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); | ||
1316 | kek_kck_cmd.replay_ctr = priv->replay_ctr; | ||
1317 | |||
1318 | ret = iwl_trans_send_cmd_pdu(trans(priv), | ||
1319 | REPLY_WOWLAN_KEK_KCK_MATERIAL, | ||
1320 | CMD_SYNC, sizeof(kek_kck_cmd), | ||
1321 | &kek_kck_cmd); | ||
1322 | if (ret) | ||
1323 | goto out; | ||
1324 | } | ||
1325 | } | ||
1326 | |||
1327 | ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, | ||
1328 | sizeof(d3_cfg_cmd), &d3_cfg_cmd); | ||
1329 | if (ret) | ||
1330 | goto out; | ||
1331 | |||
1332 | ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, | ||
1333 | CMD_SYNC, sizeof(wakeup_filter_cmd), | ||
1334 | &wakeup_filter_cmd); | ||
1335 | if (ret) | ||
1336 | goto out; | ||
1337 | |||
1338 | ret = iwlagn_send_patterns(priv, wowlan); | ||
1339 | out: | ||
1340 | kfree(key_data.rsc_tsc); | ||
1341 | return ret; | ||
1342 | } | ||
1343 | #endif | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 66118cea2af3..359c47a4fcea 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c | |||
@@ -1458,10 +1458,8 @@ static int rs_move_legacy_other(struct iwl_priv *priv, | |||
1458 | break; | 1458 | break; |
1459 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: | 1459 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
1460 | /* avoid antenna B unless MIMO */ | 1460 | /* avoid antenna B unless MIMO */ |
1461 | valid_tx_ant = | ||
1462 | first_antenna(hw_params(priv).valid_tx_ant); | ||
1463 | if (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2) | 1461 | if (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2) |
1464 | tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; | 1462 | tbl->action = IWL_LEGACY_SWITCH_SISO; |
1465 | break; | 1463 | break; |
1466 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: | 1464 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: |
1467 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: | 1465 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: |
@@ -1636,10 +1634,8 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1636 | break; | 1634 | break; |
1637 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: | 1635 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
1638 | /* avoid antenna B unless MIMO */ | 1636 | /* avoid antenna B unless MIMO */ |
1639 | valid_tx_ant = | ||
1640 | first_antenna(hw_params(priv).valid_tx_ant); | ||
1641 | if (tbl->action == IWL_SISO_SWITCH_ANTENNA2) | 1637 | if (tbl->action == IWL_SISO_SWITCH_ANTENNA2) |
1642 | tbl->action = IWL_SISO_SWITCH_ANTENNA1; | 1638 | tbl->action = IWL_SISO_SWITCH_MIMO2_AB; |
1643 | break; | 1639 | break; |
1644 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: | 1640 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: |
1645 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: | 1641 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 5af9e6258a16..fdb4c3786114 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c | |||
@@ -800,7 +800,8 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv, | |||
800 | ctx->active.bssid_addr)) | 800 | ctx->active.bssid_addr)) |
801 | continue; | 801 | continue; |
802 | ctx->last_tx_rejected = false; | 802 | ctx->last_tx_rejected = false; |
803 | iwl_trans_wake_any_queue(trans(priv), ctx->ctxid); | 803 | iwl_trans_wake_any_queue(trans(priv), ctx->ctxid, |
804 | "channel got active"); | ||
804 | } | 805 | } |
805 | } | 806 | } |
806 | 807 | ||
@@ -1032,6 +1033,50 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv, | |||
1032 | return 0; | 1033 | return 0; |
1033 | } | 1034 | } |
1034 | 1035 | ||
1036 | static int iwlagn_rx_noa_notification(struct iwl_priv *priv, | ||
1037 | struct iwl_rx_mem_buffer *rxb, | ||
1038 | struct iwl_device_cmd *cmd) | ||
1039 | { | ||
1040 | struct iwl_wipan_noa_data *new_data, *old_data; | ||
1041 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | ||
1042 | struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->u.raw; | ||
1043 | |||
1044 | /* no condition -- we're in softirq */ | ||
1045 | old_data = rcu_dereference_protected(priv->noa_data, true); | ||
1046 | |||
1047 | if (noa_notif->noa_active) { | ||
1048 | u32 len = le16_to_cpu(noa_notif->noa_attribute.length); | ||
1049 | u32 copylen = len; | ||
1050 | |||
1051 | /* EID, len, OUI, subtype */ | ||
1052 | len += 1 + 1 + 3 + 1; | ||
1053 | /* P2P id, P2P length */ | ||
1054 | len += 1 + 2; | ||
1055 | copylen += 1 + 2; | ||
1056 | |||
1057 | new_data = kmalloc(sizeof(*new_data) + len, GFP_ATOMIC); | ||
1058 | if (new_data) { | ||
1059 | new_data->length = len; | ||
1060 | new_data->data[0] = WLAN_EID_VENDOR_SPECIFIC; | ||
1061 | new_data->data[1] = len - 2; /* not counting EID, len */ | ||
1062 | new_data->data[2] = (WLAN_OUI_WFA >> 16) & 0xff; | ||
1063 | new_data->data[3] = (WLAN_OUI_WFA >> 8) & 0xff; | ||
1064 | new_data->data[4] = (WLAN_OUI_WFA >> 0) & 0xff; | ||
1065 | new_data->data[5] = WLAN_OUI_TYPE_WFA_P2P; | ||
1066 | memcpy(&new_data->data[6], &noa_notif->noa_attribute, | ||
1067 | copylen); | ||
1068 | } | ||
1069 | } else | ||
1070 | new_data = NULL; | ||
1071 | |||
1072 | rcu_assign_pointer(priv->noa_data, new_data); | ||
1073 | |||
1074 | if (old_data) | ||
1075 | kfree_rcu(old_data, rcu_head); | ||
1076 | |||
1077 | return 0; | ||
1078 | } | ||
1079 | |||
1035 | /** | 1080 | /** |
1036 | * iwl_setup_rx_handlers - Initialize Rx handler callbacks | 1081 | * iwl_setup_rx_handlers - Initialize Rx handler callbacks |
1037 | * | 1082 | * |
@@ -1055,6 +1100,8 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv) | |||
1055 | handlers[BEACON_NOTIFICATION] = iwlagn_rx_beacon_notif; | 1100 | handlers[BEACON_NOTIFICATION] = iwlagn_rx_beacon_notif; |
1056 | handlers[REPLY_ADD_STA] = iwl_add_sta_callback; | 1101 | handlers[REPLY_ADD_STA] = iwl_add_sta_callback; |
1057 | 1102 | ||
1103 | handlers[REPLY_WIPAN_NOA_NOTIFICATION] = iwlagn_rx_noa_notification; | ||
1104 | |||
1058 | /* | 1105 | /* |
1059 | * The same handler is used for both the REPLY to a discrete | 1106 | * The same handler is used for both the REPLY to a discrete |
1060 | * statistics request from the host as well as for the periodic | 1107 | * statistics request from the host as well as for the periodic |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 58a381c01c89..8de97f5a1825 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | |||
@@ -45,7 +45,8 @@ static int iwlagn_disable_bss(struct iwl_priv *priv, | |||
45 | send->filter_flags = old_filter; | 45 | send->filter_flags = old_filter; |
46 | 46 | ||
47 | if (ret) | 47 | if (ret) |
48 | IWL_ERR(priv, "Error clearing ASSOC_MSK on BSS (%d)\n", ret); | 48 | IWL_DEBUG_QUIET_RFKILL(priv, |
49 | "Error clearing ASSOC_MSK on BSS (%d)\n", ret); | ||
49 | 50 | ||
50 | return ret; | 51 | return ret; |
51 | } | 52 | } |
@@ -116,7 +117,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv, | |||
116 | if (ctx->ht.enabled) | 117 | if (ctx->ht.enabled) |
117 | ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; | 118 | ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; |
118 | 119 | ||
119 | IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", | 120 | IWL_DEBUG_INFO(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", |
120 | ctx->qos_data.qos_active, | 121 | ctx->qos_data.qos_active, |
121 | ctx->qos_data.def_qos_parm.qos_flags); | 122 | ctx->qos_data.def_qos_parm.qos_flags); |
122 | 123 | ||
@@ -124,7 +125,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv, | |||
124 | sizeof(struct iwl_qosparam_cmd), | 125 | sizeof(struct iwl_qosparam_cmd), |
125 | &ctx->qos_data.def_qos_parm); | 126 | &ctx->qos_data.def_qos_parm); |
126 | if (ret) | 127 | if (ret) |
127 | IWL_ERR(priv, "Failed to update QoS\n"); | 128 | IWL_DEBUG_QUIET_RFKILL(priv, "Failed to update QoS\n"); |
128 | } | 129 | } |
129 | 130 | ||
130 | static int iwlagn_update_beacon(struct iwl_priv *priv, | 131 | static int iwlagn_update_beacon(struct iwl_priv *priv, |
@@ -541,6 +542,9 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
541 | 542 | ||
542 | mutex_lock(&priv->shrd->mutex); | 543 | mutex_lock(&priv->shrd->mutex); |
543 | 544 | ||
545 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) | ||
546 | goto out; | ||
547 | |||
544 | if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) { | 548 | if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) { |
545 | IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); | 549 | IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); |
546 | goto out; | 550 | goto out; |
@@ -840,7 +844,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, | |||
840 | if (ctx->last_tx_rejected) { | 844 | if (ctx->last_tx_rejected) { |
841 | ctx->last_tx_rejected = false; | 845 | ctx->last_tx_rejected = false; |
842 | iwl_trans_wake_any_queue(trans(priv), | 846 | iwl_trans_wake_any_queue(trans(priv), |
843 | ctx->ctxid); | 847 | ctx->ctxid, |
848 | "Disassoc: flush queue"); | ||
844 | } | 849 | } |
845 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 850 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
846 | 851 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index ed6283623932..901fd9485d75 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c | |||
@@ -647,7 +647,7 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | |||
647 | int ret; | 647 | int ret; |
648 | struct iwl_addsta_cmd sta_cmd; | 648 | struct iwl_addsta_cmd sta_cmd; |
649 | struct iwl_link_quality_cmd lq; | 649 | struct iwl_link_quality_cmd lq; |
650 | bool active; | 650 | bool active, have_lq = false; |
651 | 651 | ||
652 | spin_lock_irqsave(&priv->shrd->sta_lock, flags); | 652 | spin_lock_irqsave(&priv->shrd->sta_lock, flags); |
653 | if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { | 653 | if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { |
@@ -657,7 +657,10 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | |||
657 | 657 | ||
658 | memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd)); | 658 | memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd)); |
659 | sta_cmd.mode = 0; | 659 | sta_cmd.mode = 0; |
660 | memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq)); | 660 | if (priv->stations[sta_id].lq) { |
661 | memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq)); | ||
662 | have_lq = true; | ||
663 | } | ||
661 | 664 | ||
662 | active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE; | 665 | active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE; |
663 | priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; | 666 | priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; |
@@ -679,7 +682,8 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | |||
679 | if (ret) | 682 | if (ret) |
680 | IWL_ERR(priv, "failed to re-add STA %pM (%d)\n", | 683 | IWL_ERR(priv, "failed to re-add STA %pM (%d)\n", |
681 | priv->stations[sta_id].sta.sta.addr, ret); | 684 | priv->stations[sta_id].sta.sta.addr, ret); |
682 | iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); | 685 | if (have_lq) |
686 | iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); | ||
683 | } | 687 | } |
684 | 688 | ||
685 | int iwl_get_free_ucode_key_offset(struct iwl_priv *priv) | 689 | int iwl_get_free_ucode_key_offset(struct iwl_priv *priv) |
@@ -825,28 +829,6 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, | |||
825 | return ret; | 829 | return ret; |
826 | } | 830 | } |
827 | 831 | ||
828 | int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, | ||
829 | struct ieee80211_vif *vif, | ||
830 | struct ieee80211_sta *sta) | ||
831 | { | ||
832 | struct iwl_priv *priv = hw->priv; | ||
833 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | ||
834 | int ret; | ||
835 | |||
836 | IWL_DEBUG_MAC80211(priv, "enter: received request to remove " | ||
837 | "station %pM\n", sta->addr); | ||
838 | mutex_lock(&priv->shrd->mutex); | ||
839 | IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", | ||
840 | sta->addr); | ||
841 | ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); | ||
842 | if (ret) | ||
843 | IWL_ERR(priv, "Error removing station %pM\n", | ||
844 | sta->addr); | ||
845 | mutex_unlock(&priv->shrd->mutex); | ||
846 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
847 | |||
848 | return ret; | ||
849 | } | ||
850 | 832 | ||
851 | void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, | 833 | void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, |
852 | u8 sta_id, struct iwl_link_quality_cmd *link_cmd) | 834 | u8 sta_id, struct iwl_link_quality_cmd *link_cmd) |
@@ -1464,20 +1446,7 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, | |||
1464 | return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); | 1446 | return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); |
1465 | } | 1447 | } |
1466 | 1448 | ||
1467 | static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) | ||
1468 | { | ||
1469 | unsigned long flags; | ||
1470 | 1449 | ||
1471 | spin_lock_irqsave(&priv->shrd->sta_lock, flags); | ||
1472 | priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK; | ||
1473 | priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; | ||
1474 | priv->stations[sta_id].sta.sta.modify_mask = 0; | ||
1475 | priv->stations[sta_id].sta.sleep_tx_count = 0; | ||
1476 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; | ||
1477 | iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); | ||
1478 | spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); | ||
1479 | |||
1480 | } | ||
1481 | 1450 | ||
1482 | void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) | 1451 | void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) |
1483 | { | 1452 | { |
@@ -1494,36 +1463,3 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) | |||
1494 | spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); | 1463 | spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); |
1495 | 1464 | ||
1496 | } | 1465 | } |
1497 | |||
1498 | void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, | ||
1499 | struct ieee80211_vif *vif, | ||
1500 | enum sta_notify_cmd cmd, | ||
1501 | struct ieee80211_sta *sta) | ||
1502 | { | ||
1503 | struct iwl_priv *priv = hw->priv; | ||
1504 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | ||
1505 | int sta_id; | ||
1506 | |||
1507 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1508 | |||
1509 | switch (cmd) { | ||
1510 | case STA_NOTIFY_SLEEP: | ||
1511 | WARN_ON(!sta_priv->client); | ||
1512 | sta_priv->asleep = true; | ||
1513 | if (atomic_read(&sta_priv->pending_frames) > 0) | ||
1514 | ieee80211_sta_block_awake(hw, sta, true); | ||
1515 | break; | ||
1516 | case STA_NOTIFY_AWAKE: | ||
1517 | WARN_ON(!sta_priv->client); | ||
1518 | if (!sta_priv->asleep) | ||
1519 | break; | ||
1520 | sta_priv->asleep = false; | ||
1521 | sta_id = iwl_sta_id(sta); | ||
1522 | if (sta_id != IWL_INVALID_STATION) | ||
1523 | iwl_sta_modify_ps_wake(priv, sta_id); | ||
1524 | break; | ||
1525 | default: | ||
1526 | break; | ||
1527 | } | ||
1528 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1529 | } | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 35a6b71f358c..e6a02e09ee18 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c | |||
@@ -283,6 +283,19 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
283 | IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); | 283 | IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | if (unlikely(ieee80211_is_probe_resp(fc))) { | ||
287 | struct iwl_wipan_noa_data *noa_data = | ||
288 | rcu_dereference(priv->noa_data); | ||
289 | |||
290 | if (noa_data && | ||
291 | pskb_expand_head(skb, 0, noa_data->length, | ||
292 | GFP_ATOMIC) == 0) { | ||
293 | memcpy(skb_put(skb, noa_data->length), | ||
294 | noa_data->data, noa_data->length); | ||
295 | hdr = (struct ieee80211_hdr *)skb->data; | ||
296 | } | ||
297 | } | ||
298 | |||
286 | hdr_len = ieee80211_hdrlen(fc); | 299 | hdr_len = ieee80211_hdrlen(fc); |
287 | 300 | ||
288 | /* For management frames use broadcast id to do not break aggregation */ | 301 | /* For management frames use broadcast id to do not break aggregation */ |
@@ -800,7 +813,8 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, | |||
800 | iwl_is_associated_ctx(ctx) && ctx->vif && | 813 | iwl_is_associated_ctx(ctx) && ctx->vif && |
801 | ctx->vif->type == NL80211_IFTYPE_STATION) { | 814 | ctx->vif->type == NL80211_IFTYPE_STATION) { |
802 | ctx->last_tx_rejected = true; | 815 | ctx->last_tx_rejected = true; |
803 | iwl_trans_stop_queue(trans(priv), txq_id); | 816 | iwl_trans_stop_queue(trans(priv), txq_id, |
817 | "Tx on passive channel"); | ||
804 | 818 | ||
805 | IWL_DEBUG_TX_REPLY(priv, | 819 | IWL_DEBUG_TX_REPLY(priv, |
806 | "TXQ %d status %s (0x%08x) " | 820 | "TXQ %d status %s (0x%08x) " |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 8ba0dd54e37d..9ec315b31d45 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/dma-mapping.h> | ||
34 | 35 | ||
35 | #include "iwl-dev.h" | 36 | #include "iwl-dev.h" |
36 | #include "iwl-core.h" | 37 | #include "iwl-core.h" |
@@ -72,51 +73,98 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { | |||
72 | {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} | 73 | {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} |
73 | }; | 74 | }; |
74 | 75 | ||
76 | /****************************************************************************** | ||
77 | * | ||
78 | * uCode download functions | ||
79 | * | ||
80 | ******************************************************************************/ | ||
81 | |||
82 | static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) | ||
83 | { | ||
84 | if (desc->v_addr) | ||
85 | dma_free_coherent(bus->dev, desc->len, | ||
86 | desc->v_addr, desc->p_addr); | ||
87 | desc->v_addr = NULL; | ||
88 | desc->len = 0; | ||
89 | } | ||
90 | |||
91 | static void iwl_free_fw_img(struct iwl_bus *bus, struct fw_img *img) | ||
92 | { | ||
93 | iwl_free_fw_desc(bus, &img->code); | ||
94 | iwl_free_fw_desc(bus, &img->data); | ||
95 | } | ||
96 | |||
97 | void iwl_dealloc_ucode(struct iwl_trans *trans) | ||
98 | { | ||
99 | iwl_free_fw_img(bus(trans), &trans->ucode_rt); | ||
100 | iwl_free_fw_img(bus(trans), &trans->ucode_init); | ||
101 | iwl_free_fw_img(bus(trans), &trans->ucode_wowlan); | ||
102 | } | ||
103 | |||
104 | int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, | ||
105 | const void *data, size_t len) | ||
106 | { | ||
107 | if (!len) { | ||
108 | desc->v_addr = NULL; | ||
109 | return -EINVAL; | ||
110 | } | ||
111 | |||
112 | desc->v_addr = dma_alloc_coherent(bus->dev, len, | ||
113 | &desc->p_addr, GFP_KERNEL); | ||
114 | if (!desc->v_addr) | ||
115 | return -ENOMEM; | ||
116 | |||
117 | desc->len = len; | ||
118 | memcpy(desc->v_addr, data, len); | ||
119 | return 0; | ||
120 | } | ||
121 | |||
75 | /* | 122 | /* |
76 | * ucode | 123 | * ucode |
77 | */ | 124 | */ |
78 | static int iwlagn_load_section(struct iwl_priv *priv, const char *name, | 125 | static int iwlagn_load_section(struct iwl_trans *trans, const char *name, |
79 | struct fw_desc *image, u32 dst_addr) | 126 | struct fw_desc *image, u32 dst_addr) |
80 | { | 127 | { |
128 | struct iwl_bus *bus = bus(trans); | ||
81 | dma_addr_t phy_addr = image->p_addr; | 129 | dma_addr_t phy_addr = image->p_addr; |
82 | u32 byte_cnt = image->len; | 130 | u32 byte_cnt = image->len; |
83 | int ret; | 131 | int ret; |
84 | 132 | ||
85 | priv->ucode_write_complete = 0; | 133 | trans->ucode_write_complete = 0; |
86 | 134 | ||
87 | iwl_write_direct32(bus(priv), | 135 | iwl_write_direct32(bus, |
88 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), | 136 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), |
89 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); | 137 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); |
90 | 138 | ||
91 | iwl_write_direct32(bus(priv), | 139 | iwl_write_direct32(bus, |
92 | FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); | 140 | FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); |
93 | 141 | ||
94 | iwl_write_direct32(bus(priv), | 142 | iwl_write_direct32(bus, |
95 | FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), | 143 | FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), |
96 | phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); | 144 | phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); |
97 | 145 | ||
98 | iwl_write_direct32(bus(priv), | 146 | iwl_write_direct32(bus, |
99 | FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), | 147 | FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), |
100 | (iwl_get_dma_hi_addr(phy_addr) | 148 | (iwl_get_dma_hi_addr(phy_addr) |
101 | << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); | 149 | << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); |
102 | 150 | ||
103 | iwl_write_direct32(bus(priv), | 151 | iwl_write_direct32(bus, |
104 | FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), | 152 | FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), |
105 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | | 153 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | |
106 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | | 154 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | |
107 | FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); | 155 | FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); |
108 | 156 | ||
109 | iwl_write_direct32(bus(priv), | 157 | iwl_write_direct32(bus, |
110 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), | 158 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), |
111 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | | 159 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | |
112 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | | 160 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | |
113 | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); | 161 | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); |
114 | 162 | ||
115 | IWL_DEBUG_FW(priv, "%s uCode section being loaded...\n", name); | 163 | IWL_DEBUG_FW(bus, "%s uCode section being loaded...\n", name); |
116 | ret = wait_event_timeout(priv->shrd->wait_command_queue, | 164 | ret = wait_event_timeout(trans->shrd->wait_command_queue, |
117 | priv->ucode_write_complete, 5 * HZ); | 165 | trans->ucode_write_complete, 5 * HZ); |
118 | if (!ret) { | 166 | if (!ret) { |
119 | IWL_ERR(priv, "Could not load the %s uCode section\n", | 167 | IWL_ERR(trans, "Could not load the %s uCode section\n", |
120 | name); | 168 | name); |
121 | return -ETIMEDOUT; | 169 | return -ETIMEDOUT; |
122 | } | 170 | } |
@@ -124,17 +172,41 @@ static int iwlagn_load_section(struct iwl_priv *priv, const char *name, | |||
124 | return 0; | 172 | return 0; |
125 | } | 173 | } |
126 | 174 | ||
127 | static int iwlagn_load_given_ucode(struct iwl_priv *priv, | 175 | static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, |
128 | struct fw_img *image) | 176 | enum iwl_ucode_type ucode_type) |
177 | { | ||
178 | switch (ucode_type) { | ||
179 | case IWL_UCODE_INIT: | ||
180 | return &trans->ucode_init; | ||
181 | case IWL_UCODE_WOWLAN: | ||
182 | return &trans->ucode_wowlan; | ||
183 | case IWL_UCODE_REGULAR: | ||
184 | return &trans->ucode_rt; | ||
185 | case IWL_UCODE_NONE: | ||
186 | break; | ||
187 | } | ||
188 | return NULL; | ||
189 | } | ||
190 | |||
191 | static int iwlagn_load_given_ucode(struct iwl_trans *trans, | ||
192 | enum iwl_ucode_type ucode_type) | ||
129 | { | 193 | { |
130 | int ret = 0; | 194 | int ret = 0; |
195 | struct fw_img *image = iwl_get_ucode_image(trans, ucode_type); | ||
196 | |||
197 | |||
198 | if (!image) { | ||
199 | IWL_ERR(trans, "Invalid ucode requested (%d)\n", | ||
200 | ucode_type); | ||
201 | return -EINVAL; | ||
202 | } | ||
131 | 203 | ||
132 | ret = iwlagn_load_section(priv, "INST", &image->code, | 204 | ret = iwlagn_load_section(trans, "INST", &image->code, |
133 | IWLAGN_RTC_INST_LOWER_BOUND); | 205 | IWLAGN_RTC_INST_LOWER_BOUND); |
134 | if (ret) | 206 | if (ret) |
135 | return ret; | 207 | return ret; |
136 | 208 | ||
137 | return iwlagn_load_section(priv, "DATA", &image->data, | 209 | return iwlagn_load_section(trans, "DATA", &image->data, |
138 | IWLAGN_RTC_DATA_LOWER_BOUND); | 210 | IWLAGN_RTC_DATA_LOWER_BOUND); |
139 | } | 211 | } |
140 | 212 | ||
@@ -418,7 +490,7 @@ static int iwlagn_alive_notify(struct iwl_priv *priv) | |||
418 | * using sample data 100 bytes apart. If these sample points are good, | 490 | * using sample data 100 bytes apart. If these sample points are good, |
419 | * it's a pretty good bet that everything between them is good, too. | 491 | * it's a pretty good bet that everything between them is good, too. |
420 | */ | 492 | */ |
421 | static int iwl_verify_inst_sparse(struct iwl_priv *priv, | 493 | static int iwl_verify_inst_sparse(struct iwl_bus *bus, |
422 | struct fw_desc *fw_desc) | 494 | struct fw_desc *fw_desc) |
423 | { | 495 | { |
424 | __le32 *image = (__le32 *)fw_desc->v_addr; | 496 | __le32 *image = (__le32 *)fw_desc->v_addr; |
@@ -426,15 +498,15 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv, | |||
426 | u32 val; | 498 | u32 val; |
427 | u32 i; | 499 | u32 i; |
428 | 500 | ||
429 | IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); | 501 | IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); |
430 | 502 | ||
431 | for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { | 503 | for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { |
432 | /* read data comes through single port, auto-incr addr */ | 504 | /* read data comes through single port, auto-incr addr */ |
433 | /* NOTE: Use the debugless read so we don't flood kernel log | 505 | /* NOTE: Use the debugless read so we don't flood kernel log |
434 | * if IWL_DL_IO is set */ | 506 | * if IWL_DL_IO is set */ |
435 | iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, | 507 | iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, |
436 | i + IWLAGN_RTC_INST_LOWER_BOUND); | 508 | i + IWLAGN_RTC_INST_LOWER_BOUND); |
437 | val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); | 509 | val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); |
438 | if (val != le32_to_cpu(*image)) | 510 | if (val != le32_to_cpu(*image)) |
439 | return -EIO; | 511 | return -EIO; |
440 | } | 512 | } |
@@ -442,7 +514,7 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv, | |||
442 | return 0; | 514 | return 0; |
443 | } | 515 | } |
444 | 516 | ||
445 | static void iwl_print_mismatch_inst(struct iwl_priv *priv, | 517 | static void iwl_print_mismatch_inst(struct iwl_bus *bus, |
446 | struct fw_desc *fw_desc) | 518 | struct fw_desc *fw_desc) |
447 | { | 519 | { |
448 | __le32 *image = (__le32 *)fw_desc->v_addr; | 520 | __le32 *image = (__le32 *)fw_desc->v_addr; |
@@ -451,18 +523,18 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, | |||
451 | u32 offs; | 523 | u32 offs; |
452 | int errors = 0; | 524 | int errors = 0; |
453 | 525 | ||
454 | IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); | 526 | IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); |
455 | 527 | ||
456 | iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, | 528 | iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, |
457 | IWLAGN_RTC_INST_LOWER_BOUND); | 529 | IWLAGN_RTC_INST_LOWER_BOUND); |
458 | 530 | ||
459 | for (offs = 0; | 531 | for (offs = 0; |
460 | offs < len && errors < 20; | 532 | offs < len && errors < 20; |
461 | offs += sizeof(u32), image++) { | 533 | offs += sizeof(u32), image++) { |
462 | /* read data comes through single port, auto-incr addr */ | 534 | /* read data comes through single port, auto-incr addr */ |
463 | val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); | 535 | val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); |
464 | if (val != le32_to_cpu(*image)) { | 536 | if (val != le32_to_cpu(*image)) { |
465 | IWL_ERR(priv, "uCode INST section at " | 537 | IWL_ERR(bus, "uCode INST section at " |
466 | "offset 0x%x, is 0x%x, s/b 0x%x\n", | 538 | "offset 0x%x, is 0x%x, s/b 0x%x\n", |
467 | offs, val, le32_to_cpu(*image)); | 539 | offs, val, le32_to_cpu(*image)); |
468 | errors++; | 540 | errors++; |
@@ -474,16 +546,24 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, | |||
474 | * iwl_verify_ucode - determine which instruction image is in SRAM, | 546 | * iwl_verify_ucode - determine which instruction image is in SRAM, |
475 | * and verify its contents | 547 | * and verify its contents |
476 | */ | 548 | */ |
477 | static int iwl_verify_ucode(struct iwl_priv *priv, struct fw_img *img) | 549 | static int iwl_verify_ucode(struct iwl_trans *trans, |
550 | enum iwl_ucode_type ucode_type) | ||
478 | { | 551 | { |
479 | if (!iwl_verify_inst_sparse(priv, &img->code)) { | 552 | struct fw_img *img = iwl_get_ucode_image(trans, ucode_type); |
480 | IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); | 553 | |
554 | if (!img) { | ||
555 | IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); | ||
556 | return -EINVAL; | ||
557 | } | ||
558 | |||
559 | if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { | ||
560 | IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); | ||
481 | return 0; | 561 | return 0; |
482 | } | 562 | } |
483 | 563 | ||
484 | IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); | 564 | IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); |
485 | 565 | ||
486 | iwl_print_mismatch_inst(priv, &img->code); | 566 | iwl_print_mismatch_inst(bus(trans), &img->code); |
487 | return -EIO; | 567 | return -EIO; |
488 | } | 568 | } |
489 | 569 | ||
@@ -519,13 +599,12 @@ static void iwlagn_alive_fn(struct iwl_priv *priv, | |||
519 | #define UCODE_CALIB_TIMEOUT (2*HZ) | 599 | #define UCODE_CALIB_TIMEOUT (2*HZ) |
520 | 600 | ||
521 | int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, | 601 | int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, |
522 | struct fw_img *image, | 602 | enum iwl_ucode_type ucode_type) |
523 | enum iwlagn_ucode_type ucode_type) | ||
524 | { | 603 | { |
525 | struct iwl_notification_wait alive_wait; | 604 | struct iwl_notification_wait alive_wait; |
526 | struct iwlagn_alive_data alive_data; | 605 | struct iwlagn_alive_data alive_data; |
527 | int ret; | 606 | int ret; |
528 | enum iwlagn_ucode_type old_type; | 607 | enum iwl_ucode_type old_type; |
529 | 608 | ||
530 | ret = iwl_trans_start_device(trans(priv)); | 609 | ret = iwl_trans_start_device(trans(priv)); |
531 | if (ret) | 610 | if (ret) |
@@ -537,7 +616,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, | |||
537 | old_type = priv->ucode_type; | 616 | old_type = priv->ucode_type; |
538 | priv->ucode_type = ucode_type; | 617 | priv->ucode_type = ucode_type; |
539 | 618 | ||
540 | ret = iwlagn_load_given_ucode(priv, image); | 619 | ret = iwlagn_load_given_ucode(trans(priv), ucode_type); |
541 | if (ret) { | 620 | if (ret) { |
542 | priv->ucode_type = old_type; | 621 | priv->ucode_type = old_type; |
543 | iwlagn_remove_notification(priv, &alive_wait); | 622 | iwlagn_remove_notification(priv, &alive_wait); |
@@ -568,7 +647,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, | |||
568 | * skip it for WoWLAN. | 647 | * skip it for WoWLAN. |
569 | */ | 648 | */ |
570 | if (ucode_type != IWL_UCODE_WOWLAN) { | 649 | if (ucode_type != IWL_UCODE_WOWLAN) { |
571 | ret = iwl_verify_ucode(priv, image); | 650 | ret = iwl_verify_ucode(trans(priv), ucode_type); |
572 | if (ret) { | 651 | if (ret) { |
573 | priv->ucode_type = old_type; | 652 | priv->ucode_type = old_type; |
574 | return ret; | 653 | return ret; |
@@ -597,7 +676,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) | |||
597 | lockdep_assert_held(&priv->shrd->mutex); | 676 | lockdep_assert_held(&priv->shrd->mutex); |
598 | 677 | ||
599 | /* No init ucode required? Curious, but maybe ok */ | 678 | /* No init ucode required? Curious, but maybe ok */ |
600 | if (!priv->ucode_init.code.len) | 679 | if (!trans(priv)->ucode_init.code.len) |
601 | return 0; | 680 | return 0; |
602 | 681 | ||
603 | if (priv->ucode_type != IWL_UCODE_NONE) | 682 | if (priv->ucode_type != IWL_UCODE_NONE) |
@@ -608,8 +687,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) | |||
608 | NULL, NULL); | 687 | NULL, NULL); |
609 | 688 | ||
610 | /* Will also start the device */ | 689 | /* Will also start the device */ |
611 | ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, | 690 | ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); |
612 | IWL_UCODE_INIT); | ||
613 | if (ret) | 691 | if (ret) |
614 | goto error; | 692 | goto error; |
615 | 693 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ccba69b7f8a7..e235e84de8b4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/dma-mapping.h> | ||
34 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
35 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
36 | #include <linux/skbuff.h> | 35 | #include <linux/skbuff.h> |
@@ -452,52 +451,6 @@ static void iwl_bg_tx_flush(struct work_struct *work) | |||
452 | iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); | 451 | iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); |
453 | } | 452 | } |
454 | 453 | ||
455 | /****************************************************************************** | ||
456 | * | ||
457 | * uCode download functions | ||
458 | * | ||
459 | ******************************************************************************/ | ||
460 | |||
461 | static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc) | ||
462 | { | ||
463 | if (desc->v_addr) | ||
464 | dma_free_coherent(bus(priv)->dev, desc->len, | ||
465 | desc->v_addr, desc->p_addr); | ||
466 | desc->v_addr = NULL; | ||
467 | desc->len = 0; | ||
468 | } | ||
469 | |||
470 | static void iwl_free_fw_img(struct iwl_priv *priv, struct fw_img *img) | ||
471 | { | ||
472 | iwl_free_fw_desc(priv, &img->code); | ||
473 | iwl_free_fw_desc(priv, &img->data); | ||
474 | } | ||
475 | |||
476 | static void iwl_dealloc_ucode(struct iwl_priv *priv) | ||
477 | { | ||
478 | iwl_free_fw_img(priv, &priv->ucode_rt); | ||
479 | iwl_free_fw_img(priv, &priv->ucode_init); | ||
480 | iwl_free_fw_img(priv, &priv->ucode_wowlan); | ||
481 | } | ||
482 | |||
483 | static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc, | ||
484 | const void *data, size_t len) | ||
485 | { | ||
486 | if (!len) { | ||
487 | desc->v_addr = NULL; | ||
488 | return -EINVAL; | ||
489 | } | ||
490 | |||
491 | desc->v_addr = dma_alloc_coherent(bus(priv)->dev, len, | ||
492 | &desc->p_addr, GFP_KERNEL); | ||
493 | if (!desc->v_addr) | ||
494 | return -ENOMEM; | ||
495 | |||
496 | desc->len = len; | ||
497 | memcpy(desc->v_addr, data, len); | ||
498 | return 0; | ||
499 | } | ||
500 | |||
501 | static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) | 454 | static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) |
502 | { | 455 | { |
503 | int i; | 456 | int i; |
@@ -555,16 +508,7 @@ static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) | |||
555 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); | 508 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); |
556 | } | 509 | } |
557 | 510 | ||
558 | |||
559 | struct iwlagn_ucode_capabilities { | ||
560 | u32 max_probe_length; | ||
561 | u32 standard_phy_calibration_size; | ||
562 | u32 flags; | ||
563 | }; | ||
564 | |||
565 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); | 511 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); |
566 | static int iwlagn_mac_setup_register(struct iwl_priv *priv, | ||
567 | struct iwlagn_ucode_capabilities *capa); | ||
568 | 512 | ||
569 | #define UCODE_EXPERIMENTAL_INDEX 100 | 513 | #define UCODE_EXPERIMENTAL_INDEX 100 |
570 | #define UCODE_EXPERIMENTAL_TAG "exp" | 514 | #define UCODE_EXPERIMENTAL_TAG "exp" |
@@ -1040,30 +984,32 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1040 | /* Runtime instructions and 2 copies of data: | 984 | /* Runtime instructions and 2 copies of data: |
1041 | * 1) unmodified from disk | 985 | * 1) unmodified from disk |
1042 | * 2) backup cache for save/restore during power-downs */ | 986 | * 2) backup cache for save/restore during power-downs */ |
1043 | if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.code, | 987 | if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.code, |
1044 | pieces.inst, pieces.inst_size)) | 988 | pieces.inst, pieces.inst_size)) |
1045 | goto err_pci_alloc; | 989 | goto err_pci_alloc; |
1046 | if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.data, | 990 | if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.data, |
1047 | pieces.data, pieces.data_size)) | 991 | pieces.data, pieces.data_size)) |
1048 | goto err_pci_alloc; | 992 | goto err_pci_alloc; |
1049 | 993 | ||
1050 | /* Initialization instructions and data */ | 994 | /* Initialization instructions and data */ |
1051 | if (pieces.init_size && pieces.init_data_size) { | 995 | if (pieces.init_size && pieces.init_data_size) { |
1052 | if (iwl_alloc_fw_desc(priv, &priv->ucode_init.code, | 996 | if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.code, |
1053 | pieces.init, pieces.init_size)) | 997 | pieces.init, pieces.init_size)) |
1054 | goto err_pci_alloc; | 998 | goto err_pci_alloc; |
1055 | if (iwl_alloc_fw_desc(priv, &priv->ucode_init.data, | 999 | if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.data, |
1056 | pieces.init_data, pieces.init_data_size)) | 1000 | pieces.init_data, pieces.init_data_size)) |
1057 | goto err_pci_alloc; | 1001 | goto err_pci_alloc; |
1058 | } | 1002 | } |
1059 | 1003 | ||
1060 | /* WoWLAN instructions and data */ | 1004 | /* WoWLAN instructions and data */ |
1061 | if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { | 1005 | if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { |
1062 | if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.code, | 1006 | if (iwl_alloc_fw_desc(bus(priv), |
1007 | &trans(priv)->ucode_wowlan.code, | ||
1063 | pieces.wowlan_inst, | 1008 | pieces.wowlan_inst, |
1064 | pieces.wowlan_inst_size)) | 1009 | pieces.wowlan_inst_size)) |
1065 | goto err_pci_alloc; | 1010 | goto err_pci_alloc; |
1066 | if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.data, | 1011 | if (iwl_alloc_fw_desc(bus(priv), |
1012 | &trans(priv)->ucode_wowlan.data, | ||
1067 | pieces.wowlan_data, | 1013 | pieces.wowlan_data, |
1068 | pieces.wowlan_data_size)) | 1014 | pieces.wowlan_data_size)) |
1069 | goto err_pci_alloc; | 1015 | goto err_pci_alloc; |
@@ -1156,7 +1102,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1156 | 1102 | ||
1157 | err_pci_alloc: | 1103 | err_pci_alloc: |
1158 | IWL_ERR(priv, "failed to allocate pci memory\n"); | 1104 | IWL_ERR(priv, "failed to allocate pci memory\n"); |
1159 | iwl_dealloc_ucode(priv); | 1105 | iwl_dealloc_ucode(trans(priv)); |
1160 | out_unbind: | 1106 | out_unbind: |
1161 | complete(&priv->firmware_loading_complete); | 1107 | complete(&priv->firmware_loading_complete); |
1162 | device_release_driver(bus(priv)->dev); | 1108 | device_release_driver(bus(priv)->dev); |
@@ -1352,7 +1298,7 @@ int iwl_alive_start(struct iwl_priv *priv) | |||
1352 | 1298 | ||
1353 | static void iwl_cancel_deferred_work(struct iwl_priv *priv); | 1299 | static void iwl_cancel_deferred_work(struct iwl_priv *priv); |
1354 | 1300 | ||
1355 | static void __iwl_down(struct iwl_priv *priv) | 1301 | void __iwl_down(struct iwl_priv *priv) |
1356 | { | 1302 | { |
1357 | int exit_pending; | 1303 | int exit_pending; |
1358 | 1304 | ||
@@ -1415,7 +1361,7 @@ static void __iwl_down(struct iwl_priv *priv) | |||
1415 | priv->beacon_skb = NULL; | 1361 | priv->beacon_skb = NULL; |
1416 | } | 1362 | } |
1417 | 1363 | ||
1418 | static void iwl_down(struct iwl_priv *priv) | 1364 | void iwl_down(struct iwl_priv *priv) |
1419 | { | 1365 | { |
1420 | mutex_lock(&priv->shrd->mutex); | 1366 | mutex_lock(&priv->shrd->mutex); |
1421 | __iwl_down(priv); | 1367 | __iwl_down(priv); |
@@ -1424,57 +1370,6 @@ static void iwl_down(struct iwl_priv *priv) | |||
1424 | iwl_cancel_deferred_work(priv); | 1370 | iwl_cancel_deferred_work(priv); |
1425 | } | 1371 | } |
1426 | 1372 | ||
1427 | #define MAX_HW_RESTARTS 5 | ||
1428 | |||
1429 | static int __iwl_up(struct iwl_priv *priv) | ||
1430 | { | ||
1431 | struct iwl_rxon_context *ctx; | ||
1432 | int ret; | ||
1433 | |||
1434 | lockdep_assert_held(&priv->shrd->mutex); | ||
1435 | |||
1436 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { | ||
1437 | IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); | ||
1438 | return -EIO; | ||
1439 | } | ||
1440 | |||
1441 | for_each_context(priv, ctx) { | ||
1442 | ret = iwlagn_alloc_bcast_station(priv, ctx); | ||
1443 | if (ret) { | ||
1444 | iwl_dealloc_bcast_stations(priv); | ||
1445 | return ret; | ||
1446 | } | ||
1447 | } | ||
1448 | |||
1449 | ret = iwlagn_run_init_ucode(priv); | ||
1450 | if (ret) { | ||
1451 | IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); | ||
1452 | goto error; | ||
1453 | } | ||
1454 | |||
1455 | ret = iwlagn_load_ucode_wait_alive(priv, | ||
1456 | &priv->ucode_rt, | ||
1457 | IWL_UCODE_REGULAR); | ||
1458 | if (ret) { | ||
1459 | IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); | ||
1460 | goto error; | ||
1461 | } | ||
1462 | |||
1463 | ret = iwl_alive_start(priv); | ||
1464 | if (ret) | ||
1465 | goto error; | ||
1466 | return 0; | ||
1467 | |||
1468 | error: | ||
1469 | set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); | ||
1470 | __iwl_down(priv); | ||
1471 | clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); | ||
1472 | |||
1473 | IWL_ERR(priv, "Unable to initialize device.\n"); | ||
1474 | return ret; | ||
1475 | } | ||
1476 | |||
1477 | |||
1478 | /***************************************************************************** | 1373 | /***************************************************************************** |
1479 | * | 1374 | * |
1480 | * Workqueue callbacks | 1375 | * Workqueue callbacks |
@@ -1502,7 +1397,7 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work) | |||
1502 | mutex_unlock(&priv->shrd->mutex); | 1397 | mutex_unlock(&priv->shrd->mutex); |
1503 | } | 1398 | } |
1504 | 1399 | ||
1505 | static void iwlagn_prepare_restart(struct iwl_priv *priv) | 1400 | void iwlagn_prepare_restart(struct iwl_priv *priv) |
1506 | { | 1401 | { |
1507 | struct iwl_rxon_context *ctx; | 1402 | struct iwl_rxon_context *ctx; |
1508 | bool bt_full_concurrent; | 1403 | bool bt_full_concurrent; |
@@ -1559,1173 +1454,8 @@ static void iwl_bg_restart(struct work_struct *data) | |||
1559 | } | 1454 | } |
1560 | } | 1455 | } |
1561 | 1456 | ||
1562 | /***************************************************************************** | ||
1563 | * | ||
1564 | * mac80211 entry point functions | ||
1565 | * | ||
1566 | *****************************************************************************/ | ||
1567 | |||
1568 | static const struct ieee80211_iface_limit iwlagn_sta_ap_limits[] = { | ||
1569 | { | ||
1570 | .max = 1, | ||
1571 | .types = BIT(NL80211_IFTYPE_STATION), | ||
1572 | }, | ||
1573 | { | ||
1574 | .max = 1, | ||
1575 | .types = BIT(NL80211_IFTYPE_AP), | ||
1576 | }, | ||
1577 | }; | ||
1578 | |||
1579 | static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = { | ||
1580 | { | ||
1581 | .max = 2, | ||
1582 | .types = BIT(NL80211_IFTYPE_STATION), | ||
1583 | }, | ||
1584 | }; | ||
1585 | |||
1586 | static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = { | ||
1587 | { | ||
1588 | .max = 1, | ||
1589 | .types = BIT(NL80211_IFTYPE_STATION), | ||
1590 | }, | ||
1591 | { | ||
1592 | .max = 1, | ||
1593 | .types = BIT(NL80211_IFTYPE_P2P_GO) | | ||
1594 | BIT(NL80211_IFTYPE_AP), | ||
1595 | }, | ||
1596 | }; | ||
1597 | |||
1598 | static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = { | ||
1599 | { | ||
1600 | .max = 2, | ||
1601 | .types = BIT(NL80211_IFTYPE_STATION), | ||
1602 | }, | ||
1603 | { | ||
1604 | .max = 1, | ||
1605 | .types = BIT(NL80211_IFTYPE_P2P_CLIENT), | ||
1606 | }, | ||
1607 | }; | ||
1608 | |||
1609 | static const struct ieee80211_iface_combination | ||
1610 | iwlagn_iface_combinations_dualmode[] = { | ||
1611 | { .num_different_channels = 1, | ||
1612 | .max_interfaces = 2, | ||
1613 | .beacon_int_infra_match = true, | ||
1614 | .limits = iwlagn_sta_ap_limits, | ||
1615 | .n_limits = ARRAY_SIZE(iwlagn_sta_ap_limits), | ||
1616 | }, | ||
1617 | { .num_different_channels = 1, | ||
1618 | .max_interfaces = 2, | ||
1619 | .limits = iwlagn_2sta_limits, | ||
1620 | .n_limits = ARRAY_SIZE(iwlagn_2sta_limits), | ||
1621 | }, | ||
1622 | }; | ||
1623 | |||
1624 | static const struct ieee80211_iface_combination | ||
1625 | iwlagn_iface_combinations_p2p[] = { | ||
1626 | { .num_different_channels = 1, | ||
1627 | .max_interfaces = 2, | ||
1628 | .beacon_int_infra_match = true, | ||
1629 | .limits = iwlagn_p2p_sta_go_limits, | ||
1630 | .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits), | ||
1631 | }, | ||
1632 | { .num_different_channels = 1, | ||
1633 | .max_interfaces = 2, | ||
1634 | .limits = iwlagn_p2p_2sta_limits, | ||
1635 | .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits), | ||
1636 | }, | ||
1637 | }; | ||
1638 | |||
1639 | /* | ||
1640 | * Not a mac80211 entry point function, but it fits in with all the | ||
1641 | * other mac80211 functions grouped here. | ||
1642 | */ | ||
1643 | static int iwlagn_mac_setup_register(struct iwl_priv *priv, | ||
1644 | struct iwlagn_ucode_capabilities *capa) | ||
1645 | { | ||
1646 | int ret; | ||
1647 | struct ieee80211_hw *hw = priv->hw; | ||
1648 | struct iwl_rxon_context *ctx; | ||
1649 | |||
1650 | hw->rate_control_algorithm = "iwl-agn-rs"; | ||
1651 | |||
1652 | /* Tell mac80211 our characteristics */ | ||
1653 | hw->flags = IEEE80211_HW_SIGNAL_DBM | | ||
1654 | IEEE80211_HW_AMPDU_AGGREGATION | | ||
1655 | IEEE80211_HW_NEED_DTIM_PERIOD | | ||
1656 | IEEE80211_HW_SPECTRUM_MGMT | | ||
1657 | IEEE80211_HW_REPORTS_TX_ACK_STATUS; | ||
1658 | |||
1659 | /* | ||
1660 | * Including the following line will crash some AP's. This | ||
1661 | * workaround removes the stimulus which causes the crash until | ||
1662 | * the AP software can be fixed. | ||
1663 | hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; | ||
1664 | */ | ||
1665 | |||
1666 | hw->flags |= IEEE80211_HW_SUPPORTS_PS | | ||
1667 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS; | ||
1668 | |||
1669 | if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) | ||
1670 | hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | ||
1671 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; | ||
1672 | |||
1673 | if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) | ||
1674 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; | ||
1675 | |||
1676 | hw->sta_data_size = sizeof(struct iwl_station_priv); | ||
1677 | hw->vif_data_size = sizeof(struct iwl_vif_priv); | ||
1678 | |||
1679 | for_each_context(priv, ctx) { | ||
1680 | hw->wiphy->interface_modes |= ctx->interface_modes; | ||
1681 | hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; | ||
1682 | } | ||
1683 | |||
1684 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); | ||
1685 | |||
1686 | if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) { | ||
1687 | hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p; | ||
1688 | hw->wiphy->n_iface_combinations = | ||
1689 | ARRAY_SIZE(iwlagn_iface_combinations_p2p); | ||
1690 | } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { | ||
1691 | hw->wiphy->iface_combinations = iwlagn_iface_combinations_dualmode; | ||
1692 | hw->wiphy->n_iface_combinations = | ||
1693 | ARRAY_SIZE(iwlagn_iface_combinations_dualmode); | ||
1694 | } | ||
1695 | |||
1696 | hw->wiphy->max_remain_on_channel_duration = 1000; | ||
1697 | |||
1698 | hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | | ||
1699 | WIPHY_FLAG_DISABLE_BEACON_HINTS | | ||
1700 | WIPHY_FLAG_IBSS_RSN; | ||
1701 | |||
1702 | if (priv->ucode_wowlan.code.len && device_can_wakeup(bus(priv)->dev)) { | ||
1703 | hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | | ||
1704 | WIPHY_WOWLAN_DISCONNECT | | ||
1705 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | | ||
1706 | WIPHY_WOWLAN_RFKILL_RELEASE; | ||
1707 | if (!iwlagn_mod_params.sw_crypto) | ||
1708 | hw->wiphy->wowlan.flags |= | ||
1709 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | | ||
1710 | WIPHY_WOWLAN_GTK_REKEY_FAILURE; | ||
1711 | |||
1712 | hw->wiphy->wowlan.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS; | ||
1713 | hw->wiphy->wowlan.pattern_min_len = | ||
1714 | IWLAGN_WOWLAN_MIN_PATTERN_LEN; | ||
1715 | hw->wiphy->wowlan.pattern_max_len = | ||
1716 | IWLAGN_WOWLAN_MAX_PATTERN_LEN; | ||
1717 | } | ||
1718 | |||
1719 | if (iwlagn_mod_params.power_save) | ||
1720 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; | ||
1721 | else | ||
1722 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; | ||
1723 | |||
1724 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; | ||
1725 | /* we create the 802.11 header and a zero-length SSID element */ | ||
1726 | hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; | ||
1727 | |||
1728 | /* Default value; 4 EDCA QOS priorities */ | ||
1729 | hw->queues = 4; | ||
1730 | |||
1731 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; | ||
1732 | |||
1733 | if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) | ||
1734 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | ||
1735 | &priv->bands[IEEE80211_BAND_2GHZ]; | ||
1736 | if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) | ||
1737 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | ||
1738 | &priv->bands[IEEE80211_BAND_5GHZ]; | ||
1739 | |||
1740 | iwl_leds_init(priv); | ||
1741 | |||
1742 | ret = ieee80211_register_hw(priv->hw); | ||
1743 | if (ret) { | ||
1744 | IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); | ||
1745 | return ret; | ||
1746 | } | ||
1747 | priv->mac80211_registered = 1; | ||
1748 | |||
1749 | return 0; | ||
1750 | } | ||
1751 | |||
1752 | |||
1753 | static int iwlagn_mac_start(struct ieee80211_hw *hw) | ||
1754 | { | ||
1755 | struct iwl_priv *priv = hw->priv; | ||
1756 | int ret; | ||
1757 | |||
1758 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1759 | |||
1760 | /* we should be verifying the device is ready to be opened */ | ||
1761 | mutex_lock(&priv->shrd->mutex); | ||
1762 | ret = __iwl_up(priv); | ||
1763 | mutex_unlock(&priv->shrd->mutex); | ||
1764 | if (ret) | ||
1765 | return ret; | ||
1766 | |||
1767 | IWL_DEBUG_INFO(priv, "Start UP work done.\n"); | ||
1768 | |||
1769 | /* Now we should be done, and the READY bit should be set. */ | ||
1770 | if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status))) | ||
1771 | ret = -EIO; | ||
1772 | |||
1773 | iwlagn_led_enable(priv); | ||
1774 | |||
1775 | priv->is_open = 1; | ||
1776 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1777 | return 0; | ||
1778 | } | ||
1779 | |||
1780 | static void iwlagn_mac_stop(struct ieee80211_hw *hw) | ||
1781 | { | ||
1782 | struct iwl_priv *priv = hw->priv; | ||
1783 | |||
1784 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1785 | |||
1786 | if (!priv->is_open) | ||
1787 | return; | ||
1788 | |||
1789 | priv->is_open = 0; | ||
1790 | |||
1791 | iwl_down(priv); | ||
1792 | |||
1793 | flush_workqueue(priv->shrd->workqueue); | ||
1794 | |||
1795 | /* User space software may expect getting rfkill changes | ||
1796 | * even if interface is down */ | ||
1797 | iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF); | ||
1798 | iwl_enable_rfkill_int(priv); | ||
1799 | |||
1800 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1801 | } | ||
1802 | |||
1803 | #ifdef CONFIG_PM_SLEEP | ||
1804 | static int iwlagn_send_patterns(struct iwl_priv *priv, | ||
1805 | struct cfg80211_wowlan *wowlan) | ||
1806 | { | ||
1807 | struct iwlagn_wowlan_patterns_cmd *pattern_cmd; | ||
1808 | struct iwl_host_cmd cmd = { | ||
1809 | .id = REPLY_WOWLAN_PATTERNS, | ||
1810 | .dataflags[0] = IWL_HCMD_DFL_NOCOPY, | ||
1811 | .flags = CMD_SYNC, | ||
1812 | }; | ||
1813 | int i, err; | ||
1814 | |||
1815 | if (!wowlan->n_patterns) | ||
1816 | return 0; | ||
1817 | |||
1818 | cmd.len[0] = sizeof(*pattern_cmd) + | ||
1819 | wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); | ||
1820 | |||
1821 | pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); | ||
1822 | if (!pattern_cmd) | ||
1823 | return -ENOMEM; | ||
1824 | |||
1825 | pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); | ||
1826 | |||
1827 | for (i = 0; i < wowlan->n_patterns; i++) { | ||
1828 | int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); | ||
1829 | |||
1830 | memcpy(&pattern_cmd->patterns[i].mask, | ||
1831 | wowlan->patterns[i].mask, mask_len); | ||
1832 | memcpy(&pattern_cmd->patterns[i].pattern, | ||
1833 | wowlan->patterns[i].pattern, | ||
1834 | wowlan->patterns[i].pattern_len); | ||
1835 | pattern_cmd->patterns[i].mask_size = mask_len; | ||
1836 | pattern_cmd->patterns[i].pattern_size = | ||
1837 | wowlan->patterns[i].pattern_len; | ||
1838 | } | ||
1839 | |||
1840 | cmd.data[0] = pattern_cmd; | ||
1841 | err = iwl_trans_send_cmd(trans(priv), &cmd); | ||
1842 | kfree(pattern_cmd); | ||
1843 | return err; | ||
1844 | } | ||
1845 | #endif | ||
1846 | |||
1847 | static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, | ||
1848 | struct ieee80211_vif *vif, | ||
1849 | struct cfg80211_gtk_rekey_data *data) | ||
1850 | { | ||
1851 | struct iwl_priv *priv = hw->priv; | ||
1852 | |||
1853 | if (iwlagn_mod_params.sw_crypto) | ||
1854 | return; | ||
1855 | |||
1856 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1857 | mutex_lock(&priv->shrd->mutex); | ||
1858 | |||
1859 | if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif) | ||
1860 | goto out; | ||
1861 | |||
1862 | memcpy(priv->kek, data->kek, NL80211_KEK_LEN); | ||
1863 | memcpy(priv->kck, data->kck, NL80211_KCK_LEN); | ||
1864 | priv->replay_ctr = cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr)); | ||
1865 | priv->have_rekey_data = true; | ||
1866 | |||
1867 | out: | ||
1868 | mutex_unlock(&priv->shrd->mutex); | ||
1869 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1870 | } | ||
1871 | |||
1872 | struct wowlan_key_data { | ||
1873 | struct iwl_rxon_context *ctx; | ||
1874 | struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; | ||
1875 | struct iwlagn_wowlan_tkip_params_cmd *tkip; | ||
1876 | const u8 *bssid; | ||
1877 | bool error, use_rsc_tsc, use_tkip; | ||
1878 | }; | ||
1879 | |||
1880 | #ifdef CONFIG_PM_SLEEP | ||
1881 | static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) | ||
1882 | { | ||
1883 | int i; | ||
1884 | |||
1885 | for (i = 0; i < IWLAGN_P1K_SIZE; i++) | ||
1886 | out[i] = cpu_to_le16(p1k[i]); | ||
1887 | } | ||
1888 | |||
1889 | static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, | ||
1890 | struct ieee80211_vif *vif, | ||
1891 | struct ieee80211_sta *sta, | ||
1892 | struct ieee80211_key_conf *key, | ||
1893 | void *_data) | ||
1894 | { | ||
1895 | struct iwl_priv *priv = hw->priv; | ||
1896 | struct wowlan_key_data *data = _data; | ||
1897 | struct iwl_rxon_context *ctx = data->ctx; | ||
1898 | struct aes_sc *aes_sc, *aes_tx_sc = NULL; | ||
1899 | struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; | ||
1900 | struct iwlagn_p1k_cache *rx_p1ks; | ||
1901 | u8 *rx_mic_key; | ||
1902 | struct ieee80211_key_seq seq; | ||
1903 | u32 cur_rx_iv32 = 0; | ||
1904 | u16 p1k[IWLAGN_P1K_SIZE]; | ||
1905 | int ret, i; | ||
1906 | |||
1907 | mutex_lock(&priv->shrd->mutex); | ||
1908 | |||
1909 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
1910 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && | ||
1911 | !sta && !ctx->key_mapping_keys) | ||
1912 | ret = iwl_set_default_wep_key(priv, ctx, key); | ||
1913 | else | ||
1914 | ret = iwl_set_dynamic_key(priv, ctx, key, sta); | ||
1915 | |||
1916 | if (ret) { | ||
1917 | IWL_ERR(priv, "Error setting key during suspend!\n"); | ||
1918 | data->error = true; | ||
1919 | } | ||
1920 | |||
1921 | switch (key->cipher) { | ||
1922 | case WLAN_CIPHER_SUITE_TKIP: | ||
1923 | if (sta) { | ||
1924 | tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; | ||
1925 | tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; | ||
1926 | |||
1927 | rx_p1ks = data->tkip->rx_uni; | ||
1928 | |||
1929 | ieee80211_get_key_tx_seq(key, &seq); | ||
1930 | tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); | ||
1931 | tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); | ||
1932 | |||
1933 | ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); | ||
1934 | iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); | ||
1935 | |||
1936 | memcpy(data->tkip->mic_keys.tx, | ||
1937 | &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], | ||
1938 | IWLAGN_MIC_KEY_SIZE); | ||
1939 | |||
1940 | rx_mic_key = data->tkip->mic_keys.rx_unicast; | ||
1941 | } else { | ||
1942 | tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; | ||
1943 | rx_p1ks = data->tkip->rx_multi; | ||
1944 | rx_mic_key = data->tkip->mic_keys.rx_mcast; | ||
1945 | } | ||
1946 | |||
1947 | /* | ||
1948 | * For non-QoS this relies on the fact that both the uCode and | ||
1949 | * mac80211 use TID 0 (as they need to to avoid replay attacks) | ||
1950 | * for checking the IV in the frames. | ||
1951 | */ | ||
1952 | for (i = 0; i < IWLAGN_NUM_RSC; i++) { | ||
1953 | ieee80211_get_key_rx_seq(key, i, &seq); | ||
1954 | tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); | ||
1955 | tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); | ||
1956 | /* wrapping isn't allowed, AP must rekey */ | ||
1957 | if (seq.tkip.iv32 > cur_rx_iv32) | ||
1958 | cur_rx_iv32 = seq.tkip.iv32; | ||
1959 | } | ||
1960 | |||
1961 | ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); | ||
1962 | iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); | ||
1963 | ieee80211_get_tkip_rx_p1k(key, data->bssid, | ||
1964 | cur_rx_iv32 + 1, p1k); | ||
1965 | iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); | ||
1966 | |||
1967 | memcpy(rx_mic_key, | ||
1968 | &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], | ||
1969 | IWLAGN_MIC_KEY_SIZE); | ||
1970 | |||
1971 | data->use_tkip = true; | ||
1972 | data->use_rsc_tsc = true; | ||
1973 | break; | ||
1974 | case WLAN_CIPHER_SUITE_CCMP: | ||
1975 | if (sta) { | ||
1976 | u8 *pn = seq.ccmp.pn; | ||
1977 | |||
1978 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; | ||
1979 | aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; | ||
1980 | |||
1981 | ieee80211_get_key_tx_seq(key, &seq); | ||
1982 | aes_tx_sc->pn = cpu_to_le64( | ||
1983 | (u64)pn[5] | | ||
1984 | ((u64)pn[4] << 8) | | ||
1985 | ((u64)pn[3] << 16) | | ||
1986 | ((u64)pn[2] << 24) | | ||
1987 | ((u64)pn[1] << 32) | | ||
1988 | ((u64)pn[0] << 40)); | ||
1989 | } else | ||
1990 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; | ||
1991 | |||
1992 | /* | ||
1993 | * For non-QoS this relies on the fact that both the uCode and | ||
1994 | * mac80211 use TID 0 for checking the IV in the frames. | ||
1995 | */ | ||
1996 | for (i = 0; i < IWLAGN_NUM_RSC; i++) { | ||
1997 | u8 *pn = seq.ccmp.pn; | ||
1998 | |||
1999 | ieee80211_get_key_rx_seq(key, i, &seq); | ||
2000 | aes_sc->pn = cpu_to_le64( | ||
2001 | (u64)pn[5] | | ||
2002 | ((u64)pn[4] << 8) | | ||
2003 | ((u64)pn[3] << 16) | | ||
2004 | ((u64)pn[2] << 24) | | ||
2005 | ((u64)pn[1] << 32) | | ||
2006 | ((u64)pn[0] << 40)); | ||
2007 | } | ||
2008 | data->use_rsc_tsc = true; | ||
2009 | break; | ||
2010 | } | ||
2011 | |||
2012 | mutex_unlock(&priv->shrd->mutex); | ||
2013 | } | ||
2014 | |||
2015 | static int iwlagn_mac_suspend(struct ieee80211_hw *hw, | ||
2016 | struct cfg80211_wowlan *wowlan) | ||
2017 | { | ||
2018 | struct iwl_priv *priv = hw->priv; | ||
2019 | struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; | ||
2020 | struct iwl_rxon_cmd rxon; | ||
2021 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
2022 | struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; | ||
2023 | struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; | ||
2024 | struct wowlan_key_data key_data = { | ||
2025 | .ctx = ctx, | ||
2026 | .bssid = ctx->active.bssid_addr, | ||
2027 | .use_rsc_tsc = false, | ||
2028 | .tkip = &tkip_cmd, | ||
2029 | .use_tkip = false, | ||
2030 | }; | ||
2031 | int ret, i; | ||
2032 | u16 seq; | ||
2033 | |||
2034 | if (WARN_ON(!wowlan)) | ||
2035 | return -EINVAL; | ||
2036 | |||
2037 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2038 | mutex_lock(&priv->shrd->mutex); | ||
2039 | |||
2040 | /* Don't attempt WoWLAN when not associated, tear down instead. */ | ||
2041 | if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION || | ||
2042 | !iwl_is_associated_ctx(ctx)) { | ||
2043 | ret = 1; | ||
2044 | goto out; | ||
2045 | } | ||
2046 | |||
2047 | key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); | ||
2048 | if (!key_data.rsc_tsc) { | ||
2049 | ret = -ENOMEM; | ||
2050 | goto out; | ||
2051 | } | ||
2052 | |||
2053 | memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); | ||
2054 | |||
2055 | /* | ||
2056 | * We know the last used seqno, and the uCode expects to know that | ||
2057 | * one, it will increment before TX. | ||
2058 | */ | ||
2059 | seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; | ||
2060 | wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); | ||
2061 | |||
2062 | /* | ||
2063 | * For QoS counters, we store the one to use next, so subtract 0x10 | ||
2064 | * since the uCode will add 0x10 before using the value. | ||
2065 | */ | ||
2066 | for (i = 0; i < 8; i++) { | ||
2067 | seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; | ||
2068 | seq -= 0x10; | ||
2069 | wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); | ||
2070 | } | ||
2071 | |||
2072 | if (wowlan->disconnect) | ||
2073 | wakeup_filter_cmd.enabled |= | ||
2074 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | | ||
2075 | IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); | ||
2076 | if (wowlan->magic_pkt) | ||
2077 | wakeup_filter_cmd.enabled |= | ||
2078 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); | ||
2079 | if (wowlan->gtk_rekey_failure) | ||
2080 | wakeup_filter_cmd.enabled |= | ||
2081 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); | ||
2082 | if (wowlan->eap_identity_req) | ||
2083 | wakeup_filter_cmd.enabled |= | ||
2084 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); | ||
2085 | if (wowlan->four_way_handshake) | ||
2086 | wakeup_filter_cmd.enabled |= | ||
2087 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); | ||
2088 | if (wowlan->rfkill_release) | ||
2089 | wakeup_filter_cmd.enabled |= | ||
2090 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_RFKILL); | ||
2091 | if (wowlan->n_patterns) | ||
2092 | wakeup_filter_cmd.enabled |= | ||
2093 | cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); | ||
2094 | |||
2095 | iwl_scan_cancel_timeout(priv, 200); | ||
2096 | |||
2097 | memcpy(&rxon, &ctx->active, sizeof(rxon)); | ||
2098 | |||
2099 | iwl_trans_stop_device(trans(priv)); | ||
2100 | |||
2101 | priv->shrd->wowlan = true; | ||
2102 | |||
2103 | ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_wowlan, | ||
2104 | IWL_UCODE_WOWLAN); | ||
2105 | if (ret) | ||
2106 | goto error; | ||
2107 | |||
2108 | /* now configure WoWLAN ucode */ | ||
2109 | ret = iwl_alive_start(priv); | ||
2110 | if (ret) | ||
2111 | goto error; | ||
2112 | |||
2113 | memcpy(&ctx->staging, &rxon, sizeof(rxon)); | ||
2114 | ret = iwlagn_commit_rxon(priv, ctx); | ||
2115 | if (ret) | ||
2116 | goto error; | ||
2117 | |||
2118 | ret = iwl_power_update_mode(priv, true); | ||
2119 | if (ret) | ||
2120 | goto error; | ||
2121 | |||
2122 | if (!iwlagn_mod_params.sw_crypto) { | ||
2123 | /* mark all keys clear */ | ||
2124 | priv->ucode_key_table = 0; | ||
2125 | ctx->key_mapping_keys = 0; | ||
2126 | |||
2127 | /* | ||
2128 | * This needs to be unlocked due to lock ordering | ||
2129 | * constraints. Since we're in the suspend path | ||
2130 | * that isn't really a problem though. | ||
2131 | */ | ||
2132 | mutex_unlock(&priv->shrd->mutex); | ||
2133 | ieee80211_iter_keys(priv->hw, ctx->vif, | ||
2134 | iwlagn_wowlan_program_keys, | ||
2135 | &key_data); | ||
2136 | mutex_lock(&priv->shrd->mutex); | ||
2137 | if (key_data.error) { | ||
2138 | ret = -EIO; | ||
2139 | goto error; | ||
2140 | } | ||
2141 | |||
2142 | if (key_data.use_rsc_tsc) { | ||
2143 | struct iwl_host_cmd rsc_tsc_cmd = { | ||
2144 | .id = REPLY_WOWLAN_TSC_RSC_PARAMS, | ||
2145 | .flags = CMD_SYNC, | ||
2146 | .data[0] = key_data.rsc_tsc, | ||
2147 | .dataflags[0] = IWL_HCMD_DFL_NOCOPY, | ||
2148 | .len[0] = sizeof(*key_data.rsc_tsc), | ||
2149 | }; | ||
2150 | |||
2151 | ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); | ||
2152 | if (ret) | ||
2153 | goto error; | ||
2154 | } | ||
2155 | |||
2156 | if (key_data.use_tkip) { | ||
2157 | ret = iwl_trans_send_cmd_pdu(trans(priv), | ||
2158 | REPLY_WOWLAN_TKIP_PARAMS, | ||
2159 | CMD_SYNC, sizeof(tkip_cmd), | ||
2160 | &tkip_cmd); | ||
2161 | if (ret) | ||
2162 | goto error; | ||
2163 | } | ||
2164 | |||
2165 | if (priv->have_rekey_data) { | ||
2166 | memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); | ||
2167 | memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); | ||
2168 | kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); | ||
2169 | memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); | ||
2170 | kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); | ||
2171 | kek_kck_cmd.replay_ctr = priv->replay_ctr; | ||
2172 | |||
2173 | ret = iwl_trans_send_cmd_pdu(trans(priv), | ||
2174 | REPLY_WOWLAN_KEK_KCK_MATERIAL, | ||
2175 | CMD_SYNC, sizeof(kek_kck_cmd), | ||
2176 | &kek_kck_cmd); | ||
2177 | if (ret) | ||
2178 | goto error; | ||
2179 | } | ||
2180 | } | ||
2181 | |||
2182 | ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, | ||
2183 | CMD_SYNC, sizeof(wakeup_filter_cmd), | ||
2184 | &wakeup_filter_cmd); | ||
2185 | if (ret) | ||
2186 | goto error; | ||
2187 | |||
2188 | ret = iwlagn_send_patterns(priv, wowlan); | ||
2189 | if (ret) | ||
2190 | goto error; | ||
2191 | |||
2192 | device_set_wakeup_enable(bus(priv)->dev, true); | ||
2193 | |||
2194 | /* Now let the ucode operate on its own */ | ||
2195 | iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, | ||
2196 | CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); | ||
2197 | |||
2198 | goto out; | ||
2199 | |||
2200 | error: | ||
2201 | priv->shrd->wowlan = false; | ||
2202 | iwlagn_prepare_restart(priv); | ||
2203 | ieee80211_restart_hw(priv->hw); | ||
2204 | out: | ||
2205 | mutex_unlock(&priv->shrd->mutex); | ||
2206 | kfree(key_data.rsc_tsc); | ||
2207 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2208 | |||
2209 | return ret; | ||
2210 | } | ||
2211 | |||
2212 | static int iwlagn_mac_resume(struct ieee80211_hw *hw) | ||
2213 | { | ||
2214 | struct iwl_priv *priv = hw->priv; | ||
2215 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
2216 | struct ieee80211_vif *vif; | ||
2217 | unsigned long flags; | ||
2218 | u32 base, status = 0xffffffff; | ||
2219 | int ret = -EIO; | ||
2220 | |||
2221 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2222 | mutex_lock(&priv->shrd->mutex); | ||
2223 | |||
2224 | iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, | ||
2225 | CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); | ||
2226 | |||
2227 | base = priv->device_pointers.error_event_table; | ||
2228 | if (iwlagn_hw_valid_rtc_data_addr(base)) { | ||
2229 | spin_lock_irqsave(&bus(priv)->reg_lock, flags); | ||
2230 | ret = iwl_grab_nic_access_silent(bus(priv)); | ||
2231 | if (ret == 0) { | ||
2232 | iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base); | ||
2233 | status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); | ||
2234 | iwl_release_nic_access(bus(priv)); | ||
2235 | } | ||
2236 | spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); | ||
2237 | |||
2238 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
2239 | if (ret == 0) { | ||
2240 | if (!priv->wowlan_sram) | ||
2241 | priv->wowlan_sram = | ||
2242 | kzalloc(priv->ucode_wowlan.data.len, | ||
2243 | GFP_KERNEL); | ||
2244 | |||
2245 | if (priv->wowlan_sram) | ||
2246 | _iwl_read_targ_mem_words( | ||
2247 | bus(priv), 0x800000, priv->wowlan_sram, | ||
2248 | priv->ucode_wowlan.data.len / 4); | ||
2249 | } | ||
2250 | #endif | ||
2251 | } | ||
2252 | |||
2253 | /* we'll clear ctx->vif during iwlagn_prepare_restart() */ | ||
2254 | vif = ctx->vif; | ||
2255 | |||
2256 | priv->shrd->wowlan = false; | ||
2257 | |||
2258 | device_set_wakeup_enable(bus(priv)->dev, false); | ||
2259 | |||
2260 | iwlagn_prepare_restart(priv); | ||
2261 | |||
2262 | memset((void *)&ctx->active, 0, sizeof(ctx->active)); | ||
2263 | iwl_connection_init_rx_config(priv, ctx); | ||
2264 | iwlagn_set_rxon_chain(priv, ctx); | ||
2265 | |||
2266 | mutex_unlock(&priv->shrd->mutex); | ||
2267 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2268 | |||
2269 | ieee80211_resume_disconnect(vif); | ||
2270 | |||
2271 | return 1; | ||
2272 | } | ||
2273 | #endif | ||
2274 | |||
2275 | static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | ||
2276 | { | ||
2277 | struct iwl_priv *priv = hw->priv; | ||
2278 | |||
2279 | IWL_DEBUG_MACDUMP(priv, "enter\n"); | ||
2280 | |||
2281 | IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | ||
2282 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); | ||
2283 | |||
2284 | if (iwlagn_tx_skb(priv, skb)) | ||
2285 | dev_kfree_skb_any(skb); | ||
2286 | |||
2287 | IWL_DEBUG_MACDUMP(priv, "leave\n"); | ||
2288 | } | ||
2289 | |||
2290 | static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, | ||
2291 | struct ieee80211_vif *vif, | ||
2292 | struct ieee80211_key_conf *keyconf, | ||
2293 | struct ieee80211_sta *sta, | ||
2294 | u32 iv32, u16 *phase1key) | ||
2295 | { | ||
2296 | struct iwl_priv *priv = hw->priv; | ||
2297 | |||
2298 | iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key); | ||
2299 | } | ||
2300 | |||
2301 | static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | ||
2302 | struct ieee80211_vif *vif, | ||
2303 | struct ieee80211_sta *sta, | ||
2304 | struct ieee80211_key_conf *key) | ||
2305 | { | ||
2306 | struct iwl_priv *priv = hw->priv; | ||
2307 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
2308 | struct iwl_rxon_context *ctx = vif_priv->ctx; | ||
2309 | int ret; | ||
2310 | bool is_default_wep_key = false; | ||
2311 | |||
2312 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2313 | |||
2314 | if (iwlagn_mod_params.sw_crypto) { | ||
2315 | IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); | ||
2316 | return -EOPNOTSUPP; | ||
2317 | } | ||
2318 | |||
2319 | /* | ||
2320 | * We could program these keys into the hardware as well, but we | ||
2321 | * don't expect much multicast traffic in IBSS and having keys | ||
2322 | * for more stations is probably more useful. | ||
2323 | * | ||
2324 | * Mark key TX-only and return 0. | ||
2325 | */ | ||
2326 | if (vif->type == NL80211_IFTYPE_ADHOC && | ||
2327 | !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { | ||
2328 | key->hw_key_idx = WEP_INVALID_OFFSET; | ||
2329 | return 0; | ||
2330 | } | ||
2331 | |||
2332 | /* If they key was TX-only, accept deletion */ | ||
2333 | if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET) | ||
2334 | return 0; | ||
2335 | |||
2336 | mutex_lock(&priv->shrd->mutex); | ||
2337 | iwl_scan_cancel_timeout(priv, 100); | ||
2338 | |||
2339 | BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT); | ||
2340 | |||
2341 | /* | ||
2342 | * If we are getting WEP group key and we didn't receive any key mapping | ||
2343 | * so far, we are in legacy wep mode (group key only), otherwise we are | ||
2344 | * in 1X mode. | ||
2345 | * In legacy wep mode, we use another host command to the uCode. | ||
2346 | */ | ||
2347 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
2348 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { | ||
2349 | if (cmd == SET_KEY) | ||
2350 | is_default_wep_key = !ctx->key_mapping_keys; | ||
2351 | else | ||
2352 | is_default_wep_key = | ||
2353 | key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT; | ||
2354 | } | ||
2355 | |||
2356 | |||
2357 | switch (cmd) { | ||
2358 | case SET_KEY: | ||
2359 | if (is_default_wep_key) { | ||
2360 | ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); | ||
2361 | break; | ||
2362 | } | ||
2363 | ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta); | ||
2364 | if (ret) { | ||
2365 | /* | ||
2366 | * can't add key for RX, but we don't need it | ||
2367 | * in the device for TX so still return 0 | ||
2368 | */ | ||
2369 | ret = 0; | ||
2370 | key->hw_key_idx = WEP_INVALID_OFFSET; | ||
2371 | } | ||
2372 | |||
2373 | IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); | ||
2374 | break; | ||
2375 | case DISABLE_KEY: | ||
2376 | if (is_default_wep_key) | ||
2377 | ret = iwl_remove_default_wep_key(priv, ctx, key); | ||
2378 | else | ||
2379 | ret = iwl_remove_dynamic_key(priv, ctx, key, sta); | ||
2380 | |||
2381 | IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); | ||
2382 | break; | ||
2383 | default: | ||
2384 | ret = -EINVAL; | ||
2385 | } | ||
2386 | |||
2387 | mutex_unlock(&priv->shrd->mutex); | ||
2388 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2389 | |||
2390 | return ret; | ||
2391 | } | ||
2392 | |||
2393 | static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, | ||
2394 | struct ieee80211_vif *vif, | ||
2395 | enum ieee80211_ampdu_mlme_action action, | ||
2396 | struct ieee80211_sta *sta, u16 tid, u16 *ssn, | ||
2397 | u8 buf_size) | ||
2398 | { | ||
2399 | struct iwl_priv *priv = hw->priv; | ||
2400 | int ret = -EINVAL; | ||
2401 | struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; | ||
2402 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
2403 | |||
2404 | IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", | ||
2405 | sta->addr, tid); | ||
2406 | |||
2407 | if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)) | ||
2408 | return -EACCES; | ||
2409 | |||
2410 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2411 | mutex_lock(&priv->shrd->mutex); | ||
2412 | |||
2413 | switch (action) { | ||
2414 | case IEEE80211_AMPDU_RX_START: | ||
2415 | IWL_DEBUG_HT(priv, "start Rx\n"); | ||
2416 | ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); | ||
2417 | break; | ||
2418 | case IEEE80211_AMPDU_RX_STOP: | ||
2419 | IWL_DEBUG_HT(priv, "stop Rx\n"); | ||
2420 | ret = iwl_sta_rx_agg_stop(priv, sta, tid); | ||
2421 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) | ||
2422 | ret = 0; | ||
2423 | break; | ||
2424 | case IEEE80211_AMPDU_TX_START: | ||
2425 | IWL_DEBUG_HT(priv, "start Tx\n"); | ||
2426 | ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); | ||
2427 | break; | ||
2428 | case IEEE80211_AMPDU_TX_STOP: | ||
2429 | IWL_DEBUG_HT(priv, "stop Tx\n"); | ||
2430 | ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); | ||
2431 | if ((ret == 0) && (priv->agg_tids_count > 0)) { | ||
2432 | priv->agg_tids_count--; | ||
2433 | IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", | ||
2434 | priv->agg_tids_count); | ||
2435 | } | ||
2436 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) | ||
2437 | ret = 0; | ||
2438 | if (!priv->agg_tids_count && priv->cfg->ht_params && | ||
2439 | priv->cfg->ht_params->use_rts_for_aggregation) { | ||
2440 | /* | ||
2441 | * switch off RTS/CTS if it was previously enabled | ||
2442 | */ | ||
2443 | sta_priv->lq_sta.lq.general_params.flags &= | ||
2444 | ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; | ||
2445 | iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), | ||
2446 | &sta_priv->lq_sta.lq, CMD_ASYNC, false); | ||
2447 | } | ||
2448 | break; | ||
2449 | case IEEE80211_AMPDU_TX_OPERATIONAL: | ||
2450 | buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); | ||
2451 | |||
2452 | iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, iwl_sta_id(sta), | ||
2453 | tid, buf_size); | ||
2454 | |||
2455 | /* | ||
2456 | * If the limit is 0, then it wasn't initialised yet, | ||
2457 | * use the default. We can do that since we take the | ||
2458 | * minimum below, and we don't want to go above our | ||
2459 | * default due to hardware restrictions. | ||
2460 | */ | ||
2461 | if (sta_priv->max_agg_bufsize == 0) | ||
2462 | sta_priv->max_agg_bufsize = | ||
2463 | LINK_QUAL_AGG_FRAME_LIMIT_DEF; | ||
2464 | |||
2465 | /* | ||
2466 | * Even though in theory the peer could have different | ||
2467 | * aggregation reorder buffer sizes for different sessions, | ||
2468 | * our ucode doesn't allow for that and has a global limit | ||
2469 | * for each station. Therefore, use the minimum of all the | ||
2470 | * aggregation sessions and our default value. | ||
2471 | */ | ||
2472 | sta_priv->max_agg_bufsize = | ||
2473 | min(sta_priv->max_agg_bufsize, buf_size); | ||
2474 | |||
2475 | if (priv->cfg->ht_params && | ||
2476 | priv->cfg->ht_params->use_rts_for_aggregation) { | ||
2477 | /* | ||
2478 | * switch to RTS/CTS if it is the prefer protection | ||
2479 | * method for HT traffic | ||
2480 | */ | ||
2481 | |||
2482 | sta_priv->lq_sta.lq.general_params.flags |= | ||
2483 | LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; | ||
2484 | } | ||
2485 | priv->agg_tids_count++; | ||
2486 | IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", | ||
2487 | priv->agg_tids_count); | ||
2488 | |||
2489 | sta_priv->lq_sta.lq.agg_params.agg_frame_cnt_limit = | ||
2490 | sta_priv->max_agg_bufsize; | ||
2491 | |||
2492 | iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), | ||
2493 | &sta_priv->lq_sta.lq, CMD_ASYNC, false); | ||
2494 | |||
2495 | IWL_INFO(priv, "Tx aggregation enabled on ra = %pM tid = %d\n", | ||
2496 | sta->addr, tid); | ||
2497 | ret = 0; | ||
2498 | break; | ||
2499 | } | ||
2500 | mutex_unlock(&priv->shrd->mutex); | ||
2501 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2502 | return ret; | ||
2503 | } | ||
2504 | |||
2505 | static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, | ||
2506 | struct ieee80211_vif *vif, | ||
2507 | struct ieee80211_sta *sta) | ||
2508 | { | ||
2509 | struct iwl_priv *priv = hw->priv; | ||
2510 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | ||
2511 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
2512 | bool is_ap = vif->type == NL80211_IFTYPE_STATION; | ||
2513 | int ret = 0; | ||
2514 | u8 sta_id; | ||
2515 | |||
2516 | IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n", | ||
2517 | sta->addr); | ||
2518 | mutex_lock(&priv->shrd->mutex); | ||
2519 | IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", | ||
2520 | sta->addr); | ||
2521 | sta_priv->sta_id = IWL_INVALID_STATION; | ||
2522 | |||
2523 | atomic_set(&sta_priv->pending_frames, 0); | ||
2524 | if (vif->type == NL80211_IFTYPE_AP) | ||
2525 | sta_priv->client = true; | ||
2526 | |||
2527 | ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr, | ||
2528 | is_ap, sta, &sta_id); | ||
2529 | if (ret) { | ||
2530 | IWL_ERR(priv, "Unable to add station %pM (%d)\n", | ||
2531 | sta->addr, ret); | ||
2532 | /* Should we return success if return code is EEXIST ? */ | ||
2533 | goto out; | ||
2534 | } | ||
2535 | |||
2536 | sta_priv->sta_id = sta_id; | ||
2537 | |||
2538 | /* Initialize rate scaling */ | ||
2539 | IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", | ||
2540 | sta->addr); | ||
2541 | iwl_rs_rate_init(priv, sta, sta_id); | ||
2542 | out: | ||
2543 | mutex_unlock(&priv->shrd->mutex); | ||
2544 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2545 | |||
2546 | return ret; | ||
2547 | } | ||
2548 | |||
2549 | static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, | ||
2550 | struct ieee80211_channel_switch *ch_switch) | ||
2551 | { | ||
2552 | struct iwl_priv *priv = hw->priv; | ||
2553 | const struct iwl_channel_info *ch_info; | ||
2554 | struct ieee80211_conf *conf = &hw->conf; | ||
2555 | struct ieee80211_channel *channel = ch_switch->channel; | ||
2556 | struct iwl_ht_config *ht_conf = &priv->current_ht_config; | ||
2557 | /* | ||
2558 | * MULTI-FIXME | ||
2559 | * When we add support for multiple interfaces, we need to | ||
2560 | * revisit this. The channel switch command in the device | ||
2561 | * only affects the BSS context, but what does that really | ||
2562 | * mean? And what if we get a CSA on the second interface? | ||
2563 | * This needs a lot of work. | ||
2564 | */ | ||
2565 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
2566 | u16 ch; | ||
2567 | |||
2568 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2569 | |||
2570 | mutex_lock(&priv->shrd->mutex); | ||
2571 | |||
2572 | if (iwl_is_rfkill(priv->shrd)) | ||
2573 | goto out; | ||
2574 | |||
2575 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || | ||
2576 | test_bit(STATUS_SCANNING, &priv->shrd->status) || | ||
2577 | test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) | ||
2578 | goto out; | ||
2579 | |||
2580 | if (!iwl_is_associated_ctx(ctx)) | ||
2581 | goto out; | ||
2582 | |||
2583 | if (!priv->cfg->lib->set_channel_switch) | ||
2584 | goto out; | ||
2585 | |||
2586 | ch = channel->hw_value; | ||
2587 | if (le16_to_cpu(ctx->active.channel) == ch) | ||
2588 | goto out; | ||
2589 | |||
2590 | ch_info = iwl_get_channel_info(priv, channel->band, ch); | ||
2591 | if (!is_channel_valid(ch_info)) { | ||
2592 | IWL_DEBUG_MAC80211(priv, "invalid channel\n"); | ||
2593 | goto out; | ||
2594 | } | ||
2595 | |||
2596 | spin_lock_irq(&priv->shrd->lock); | ||
2597 | |||
2598 | priv->current_ht_config.smps = conf->smps_mode; | ||
2599 | |||
2600 | /* Configure HT40 channels */ | ||
2601 | ctx->ht.enabled = conf_is_ht(conf); | ||
2602 | if (ctx->ht.enabled) { | ||
2603 | if (conf_is_ht40_minus(conf)) { | ||
2604 | ctx->ht.extension_chan_offset = | ||
2605 | IEEE80211_HT_PARAM_CHA_SEC_BELOW; | ||
2606 | ctx->ht.is_40mhz = true; | ||
2607 | } else if (conf_is_ht40_plus(conf)) { | ||
2608 | ctx->ht.extension_chan_offset = | ||
2609 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE; | ||
2610 | ctx->ht.is_40mhz = true; | ||
2611 | } else { | ||
2612 | ctx->ht.extension_chan_offset = | ||
2613 | IEEE80211_HT_PARAM_CHA_SEC_NONE; | ||
2614 | ctx->ht.is_40mhz = false; | ||
2615 | } | ||
2616 | } else | ||
2617 | ctx->ht.is_40mhz = false; | ||
2618 | |||
2619 | if ((le16_to_cpu(ctx->staging.channel) != ch)) | ||
2620 | ctx->staging.flags = 0; | ||
2621 | |||
2622 | iwl_set_rxon_channel(priv, channel, ctx); | ||
2623 | iwl_set_rxon_ht(priv, ht_conf); | ||
2624 | iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); | ||
2625 | |||
2626 | spin_unlock_irq(&priv->shrd->lock); | ||
2627 | |||
2628 | iwl_set_rate(priv); | ||
2629 | /* | ||
2630 | * at this point, staging_rxon has the | ||
2631 | * configuration for channel switch | ||
2632 | */ | ||
2633 | set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); | ||
2634 | priv->switch_channel = cpu_to_le16(ch); | ||
2635 | if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) { | ||
2636 | clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); | ||
2637 | priv->switch_channel = 0; | ||
2638 | ieee80211_chswitch_done(ctx->vif, false); | ||
2639 | } | ||
2640 | |||
2641 | out: | ||
2642 | mutex_unlock(&priv->shrd->mutex); | ||
2643 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2644 | } | ||
2645 | |||
2646 | static void iwlagn_configure_filter(struct ieee80211_hw *hw, | ||
2647 | unsigned int changed_flags, | ||
2648 | unsigned int *total_flags, | ||
2649 | u64 multicast) | ||
2650 | { | ||
2651 | struct iwl_priv *priv = hw->priv; | ||
2652 | __le32 filter_or = 0, filter_nand = 0; | ||
2653 | struct iwl_rxon_context *ctx; | ||
2654 | |||
2655 | #define CHK(test, flag) do { \ | ||
2656 | if (*total_flags & (test)) \ | ||
2657 | filter_or |= (flag); \ | ||
2658 | else \ | ||
2659 | filter_nand |= (flag); \ | ||
2660 | } while (0) | ||
2661 | |||
2662 | IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", | ||
2663 | changed_flags, *total_flags); | ||
2664 | 1457 | ||
2665 | CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); | ||
2666 | /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ | ||
2667 | CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); | ||
2668 | CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); | ||
2669 | 1458 | ||
2670 | #undef CHK | ||
2671 | |||
2672 | mutex_lock(&priv->shrd->mutex); | ||
2673 | |||
2674 | for_each_context(priv, ctx) { | ||
2675 | ctx->staging.filter_flags &= ~filter_nand; | ||
2676 | ctx->staging.filter_flags |= filter_or; | ||
2677 | |||
2678 | /* | ||
2679 | * Not committing directly because hardware can perform a scan, | ||
2680 | * but we'll eventually commit the filter flags change anyway. | ||
2681 | */ | ||
2682 | } | ||
2683 | |||
2684 | mutex_unlock(&priv->shrd->mutex); | ||
2685 | |||
2686 | /* | ||
2687 | * Receiving all multicast frames is always enabled by the | ||
2688 | * default flags setup in iwl_connection_init_rx_config() | ||
2689 | * since we currently do not support programming multicast | ||
2690 | * filters into the device. | ||
2691 | */ | ||
2692 | *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | | ||
2693 | FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; | ||
2694 | } | ||
2695 | |||
2696 | static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) | ||
2697 | { | ||
2698 | struct iwl_priv *priv = hw->priv; | ||
2699 | |||
2700 | mutex_lock(&priv->shrd->mutex); | ||
2701 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2702 | |||
2703 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { | ||
2704 | IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); | ||
2705 | goto done; | ||
2706 | } | ||
2707 | if (iwl_is_rfkill(priv->shrd)) { | ||
2708 | IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); | ||
2709 | goto done; | ||
2710 | } | ||
2711 | |||
2712 | /* | ||
2713 | * mac80211 will not push any more frames for transmit | ||
2714 | * until the flush is completed | ||
2715 | */ | ||
2716 | if (drop) { | ||
2717 | IWL_DEBUG_MAC80211(priv, "send flush command\n"); | ||
2718 | if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { | ||
2719 | IWL_ERR(priv, "flush request fail\n"); | ||
2720 | goto done; | ||
2721 | } | ||
2722 | } | ||
2723 | IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); | ||
2724 | iwl_trans_wait_tx_queue_empty(trans(priv)); | ||
2725 | done: | ||
2726 | mutex_unlock(&priv->shrd->mutex); | ||
2727 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2728 | } | ||
2729 | 1459 | ||
2730 | void iwlagn_disable_roc(struct iwl_priv *priv) | 1460 | void iwlagn_disable_roc(struct iwl_priv *priv) |
2731 | { | 1461 | { |
@@ -2759,160 +1489,6 @@ static void iwlagn_disable_roc_work(struct work_struct *work) | |||
2759 | mutex_unlock(&priv->shrd->mutex); | 1489 | mutex_unlock(&priv->shrd->mutex); |
2760 | } | 1490 | } |
2761 | 1491 | ||
2762 | static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, | ||
2763 | struct ieee80211_channel *channel, | ||
2764 | enum nl80211_channel_type channel_type, | ||
2765 | int duration) | ||
2766 | { | ||
2767 | struct iwl_priv *priv = hw->priv; | ||
2768 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; | ||
2769 | int err = 0; | ||
2770 | |||
2771 | if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) | ||
2772 | return -EOPNOTSUPP; | ||
2773 | |||
2774 | if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT))) | ||
2775 | return -EOPNOTSUPP; | ||
2776 | |||
2777 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2778 | mutex_lock(&priv->shrd->mutex); | ||
2779 | |||
2780 | if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { | ||
2781 | err = -EBUSY; | ||
2782 | goto out; | ||
2783 | } | ||
2784 | |||
2785 | priv->hw_roc_channel = channel; | ||
2786 | priv->hw_roc_chantype = channel_type; | ||
2787 | priv->hw_roc_duration = duration; | ||
2788 | priv->hw_roc_start_notified = false; | ||
2789 | cancel_delayed_work(&priv->hw_roc_disable_work); | ||
2790 | |||
2791 | if (!ctx->is_active) { | ||
2792 | ctx->is_active = true; | ||
2793 | ctx->staging.dev_type = RXON_DEV_TYPE_P2P; | ||
2794 | memcpy(ctx->staging.node_addr, | ||
2795 | priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, | ||
2796 | ETH_ALEN); | ||
2797 | memcpy(ctx->staging.bssid_addr, | ||
2798 | priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, | ||
2799 | ETH_ALEN); | ||
2800 | err = iwlagn_commit_rxon(priv, ctx); | ||
2801 | if (err) | ||
2802 | goto out; | ||
2803 | ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK | | ||
2804 | RXON_FILTER_PROMISC_MSK | | ||
2805 | RXON_FILTER_CTL2HOST_MSK; | ||
2806 | |||
2807 | err = iwlagn_commit_rxon(priv, ctx); | ||
2808 | if (err) { | ||
2809 | iwlagn_disable_roc(priv); | ||
2810 | goto out; | ||
2811 | } | ||
2812 | priv->hw_roc_setup = true; | ||
2813 | } | ||
2814 | |||
2815 | err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band); | ||
2816 | if (err) | ||
2817 | iwlagn_disable_roc(priv); | ||
2818 | |||
2819 | out: | ||
2820 | mutex_unlock(&priv->shrd->mutex); | ||
2821 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2822 | |||
2823 | return err; | ||
2824 | } | ||
2825 | |||
2826 | static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) | ||
2827 | { | ||
2828 | struct iwl_priv *priv = hw->priv; | ||
2829 | |||
2830 | if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) | ||
2831 | return -EOPNOTSUPP; | ||
2832 | |||
2833 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2834 | mutex_lock(&priv->shrd->mutex); | ||
2835 | iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); | ||
2836 | iwlagn_disable_roc(priv); | ||
2837 | mutex_unlock(&priv->shrd->mutex); | ||
2838 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2839 | |||
2840 | return 0; | ||
2841 | } | ||
2842 | |||
2843 | static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, | ||
2844 | struct ieee80211_vif *vif, | ||
2845 | const u8 *bssid, | ||
2846 | enum ieee80211_tx_sync_type type) | ||
2847 | { | ||
2848 | struct iwl_priv *priv = hw->priv; | ||
2849 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
2850 | struct iwl_rxon_context *ctx = vif_priv->ctx; | ||
2851 | int ret; | ||
2852 | u8 sta_id; | ||
2853 | |||
2854 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2855 | mutex_lock(&priv->shrd->mutex); | ||
2856 | |||
2857 | if (iwl_is_associated_ctx(ctx)) { | ||
2858 | ret = 0; | ||
2859 | goto out; | ||
2860 | } | ||
2861 | |||
2862 | if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { | ||
2863 | ret = -EBUSY; | ||
2864 | goto out; | ||
2865 | } | ||
2866 | |||
2867 | ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id); | ||
2868 | if (ret) | ||
2869 | goto out; | ||
2870 | |||
2871 | if (WARN_ON(sta_id != ctx->ap_sta_id)) { | ||
2872 | ret = -EIO; | ||
2873 | goto out_remove_sta; | ||
2874 | } | ||
2875 | |||
2876 | memcpy(ctx->bssid, bssid, ETH_ALEN); | ||
2877 | ctx->preauth_bssid = true; | ||
2878 | |||
2879 | ret = iwlagn_commit_rxon(priv, ctx); | ||
2880 | |||
2881 | if (ret == 0) | ||
2882 | goto out; | ||
2883 | |||
2884 | out_remove_sta: | ||
2885 | iwl_remove_station(priv, sta_id, bssid); | ||
2886 | out: | ||
2887 | mutex_unlock(&priv->shrd->mutex); | ||
2888 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2889 | |||
2890 | return ret; | ||
2891 | } | ||
2892 | |||
2893 | static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, | ||
2894 | struct ieee80211_vif *vif, | ||
2895 | const u8 *bssid, | ||
2896 | enum ieee80211_tx_sync_type type) | ||
2897 | { | ||
2898 | struct iwl_priv *priv = hw->priv; | ||
2899 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
2900 | struct iwl_rxon_context *ctx = vif_priv->ctx; | ||
2901 | |||
2902 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
2903 | mutex_lock(&priv->shrd->mutex); | ||
2904 | |||
2905 | if (iwl_is_associated_ctx(ctx)) | ||
2906 | goto out; | ||
2907 | |||
2908 | iwl_remove_station(priv, ctx->ap_sta_id, bssid); | ||
2909 | ctx->preauth_bssid = false; | ||
2910 | /* no need to commit */ | ||
2911 | out: | ||
2912 | mutex_unlock(&priv->shrd->mutex); | ||
2913 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
2914 | } | ||
2915 | |||
2916 | /***************************************************************************** | 1492 | /***************************************************************************** |
2917 | * | 1493 | * |
2918 | * driver setup and teardown | 1494 | * driver setup and teardown |
@@ -3062,81 +1638,13 @@ static void iwl_uninit_drv(struct iwl_priv *priv) | |||
3062 | kmem_cache_destroy(priv->tx_cmd_pool); | 1638 | kmem_cache_destroy(priv->tx_cmd_pool); |
3063 | kfree(priv->scan_cmd); | 1639 | kfree(priv->scan_cmd); |
3064 | kfree(priv->beacon_cmd); | 1640 | kfree(priv->beacon_cmd); |
1641 | kfree(rcu_dereference_raw(priv->noa_data)); | ||
3065 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 1642 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
3066 | kfree(priv->wowlan_sram); | 1643 | kfree(priv->wowlan_sram); |
3067 | #endif | 1644 | #endif |
3068 | } | 1645 | } |
3069 | 1646 | ||
3070 | static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, | ||
3071 | enum ieee80211_rssi_event rssi_event) | ||
3072 | { | ||
3073 | struct iwl_priv *priv = hw->priv; | ||
3074 | |||
3075 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
3076 | mutex_lock(&priv->shrd->mutex); | ||
3077 | |||
3078 | if (priv->cfg->bt_params && | ||
3079 | priv->cfg->bt_params->advanced_bt_coexist) { | ||
3080 | if (rssi_event == RSSI_EVENT_LOW) | ||
3081 | priv->bt_enable_pspoll = true; | ||
3082 | else if (rssi_event == RSSI_EVENT_HIGH) | ||
3083 | priv->bt_enable_pspoll = false; | ||
3084 | |||
3085 | iwlagn_send_advance_bt_config(priv); | ||
3086 | } else { | ||
3087 | IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled," | ||
3088 | "ignoring RSSI callback\n"); | ||
3089 | } | ||
3090 | |||
3091 | mutex_unlock(&priv->shrd->mutex); | ||
3092 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
3093 | } | ||
3094 | |||
3095 | static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, | ||
3096 | struct ieee80211_sta *sta, bool set) | ||
3097 | { | ||
3098 | struct iwl_priv *priv = hw->priv; | ||
3099 | |||
3100 | queue_work(priv->shrd->workqueue, &priv->beacon_update); | ||
3101 | 1647 | ||
3102 | return 0; | ||
3103 | } | ||
3104 | |||
3105 | struct ieee80211_ops iwlagn_hw_ops = { | ||
3106 | .tx = iwlagn_mac_tx, | ||
3107 | .start = iwlagn_mac_start, | ||
3108 | .stop = iwlagn_mac_stop, | ||
3109 | #ifdef CONFIG_PM_SLEEP | ||
3110 | .suspend = iwlagn_mac_suspend, | ||
3111 | .resume = iwlagn_mac_resume, | ||
3112 | #endif | ||
3113 | .add_interface = iwlagn_mac_add_interface, | ||
3114 | .remove_interface = iwlagn_mac_remove_interface, | ||
3115 | .change_interface = iwlagn_mac_change_interface, | ||
3116 | .config = iwlagn_mac_config, | ||
3117 | .configure_filter = iwlagn_configure_filter, | ||
3118 | .set_key = iwlagn_mac_set_key, | ||
3119 | .update_tkip_key = iwlagn_mac_update_tkip_key, | ||
3120 | .set_rekey_data = iwlagn_mac_set_rekey_data, | ||
3121 | .conf_tx = iwlagn_mac_conf_tx, | ||
3122 | .bss_info_changed = iwlagn_bss_info_changed, | ||
3123 | .ampdu_action = iwlagn_mac_ampdu_action, | ||
3124 | .hw_scan = iwlagn_mac_hw_scan, | ||
3125 | .sta_notify = iwlagn_mac_sta_notify, | ||
3126 | .sta_add = iwlagn_mac_sta_add, | ||
3127 | .sta_remove = iwlagn_mac_sta_remove, | ||
3128 | .channel_switch = iwlagn_mac_channel_switch, | ||
3129 | .flush = iwlagn_mac_flush, | ||
3130 | .tx_last_beacon = iwlagn_mac_tx_last_beacon, | ||
3131 | .remain_on_channel = iwlagn_mac_remain_on_channel, | ||
3132 | .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, | ||
3133 | .rssi_callback = iwlagn_mac_rssi_callback, | ||
3134 | CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd) | ||
3135 | CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump) | ||
3136 | .tx_sync = iwlagn_mac_tx_sync, | ||
3137 | .finish_tx_sync = iwlagn_mac_finish_tx_sync, | ||
3138 | .set_tim = iwlagn_mac_set_tim, | ||
3139 | }; | ||
3140 | 1648 | ||
3141 | static u32 iwl_hw_detect(struct iwl_priv *priv) | 1649 | static u32 iwl_hw_detect(struct iwl_priv *priv) |
3142 | { | 1650 | { |
@@ -3170,27 +1678,7 @@ static int iwl_set_hw_params(struct iwl_priv *priv) | |||
3170 | return priv->cfg->lib->set_hw_params(priv); | 1678 | return priv->cfg->lib->set_hw_params(priv); |
3171 | } | 1679 | } |
3172 | 1680 | ||
3173 | /* This function both allocates and initializes hw and priv. */ | ||
3174 | static struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg) | ||
3175 | { | ||
3176 | struct iwl_priv *priv; | ||
3177 | /* mac80211 allocates memory for this device instance, including | ||
3178 | * space for this driver's private structure */ | ||
3179 | struct ieee80211_hw *hw; | ||
3180 | |||
3181 | hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); | ||
3182 | if (hw == NULL) { | ||
3183 | pr_err("%s: Can not allocate network device\n", | ||
3184 | cfg->name); | ||
3185 | goto out; | ||
3186 | } | ||
3187 | 1681 | ||
3188 | priv = hw->priv; | ||
3189 | priv->hw = hw; | ||
3190 | |||
3191 | out: | ||
3192 | return hw; | ||
3193 | } | ||
3194 | 1682 | ||
3195 | int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, | 1683 | int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, |
3196 | struct iwl_cfg *cfg) | 1684 | struct iwl_cfg *cfg) |
@@ -3204,8 +1692,9 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, | |||
3204 | /************************ | 1692 | /************************ |
3205 | * 1. Allocating HW data | 1693 | * 1. Allocating HW data |
3206 | ************************/ | 1694 | ************************/ |
3207 | hw = iwl_alloc_all(cfg); | 1695 | hw = iwl_alloc_all(); |
3208 | if (!hw) { | 1696 | if (!hw) { |
1697 | pr_err("%s: Cannot allocate network device\n", cfg->name); | ||
3209 | err = -ENOMEM; | 1698 | err = -ENOMEM; |
3210 | goto out; | 1699 | goto out; |
3211 | } | 1700 | } |
@@ -3397,7 +1886,7 @@ void __devexit iwl_remove(struct iwl_priv * priv) | |||
3397 | /*This will stop the queues, move the device to low power state */ | 1886 | /*This will stop the queues, move the device to low power state */ |
3398 | iwl_trans_stop_device(trans(priv)); | 1887 | iwl_trans_stop_device(trans(priv)); |
3399 | 1888 | ||
3400 | iwl_dealloc_ucode(priv); | 1889 | iwl_dealloc_ucode(trans(priv)); |
3401 | 1890 | ||
3402 | iwl_eeprom_free(priv); | 1891 | iwl_eeprom_free(priv); |
3403 | 1892 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 5b936ec1a541..5d8d2f445923 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h | |||
@@ -65,6 +65,12 @@ | |||
65 | 65 | ||
66 | #include "iwl-dev.h" | 66 | #include "iwl-dev.h" |
67 | 67 | ||
68 | struct iwlagn_ucode_capabilities { | ||
69 | u32 max_probe_length; | ||
70 | u32 standard_phy_calibration_size; | ||
71 | u32 flags; | ||
72 | }; | ||
73 | |||
68 | extern struct ieee80211_ops iwlagn_hw_ops; | 74 | extern struct ieee80211_ops iwlagn_hw_ops; |
69 | 75 | ||
70 | int iwl_reset_ict(struct iwl_trans *trans); | 76 | int iwl_reset_ict(struct iwl_trans *trans); |
@@ -77,6 +83,15 @@ static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) | |||
77 | hdr->data_valid = 1; | 83 | hdr->data_valid = 1; |
78 | } | 84 | } |
79 | 85 | ||
86 | void __iwl_down(struct iwl_priv *priv); | ||
87 | void iwl_down(struct iwl_priv *priv); | ||
88 | void iwlagn_prepare_restart(struct iwl_priv *priv); | ||
89 | |||
90 | /* MAC80211 */ | ||
91 | struct ieee80211_hw *iwl_alloc_all(void); | ||
92 | int iwlagn_mac_setup_register(struct iwl_priv *priv, | ||
93 | struct iwlagn_ucode_capabilities *capa); | ||
94 | |||
80 | /* RXON */ | 95 | /* RXON */ |
81 | int iwlagn_set_pan_params(struct iwl_priv *priv); | 96 | int iwlagn_set_pan_params(struct iwl_priv *priv); |
82 | int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx); | 97 | int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx); |
@@ -95,8 +110,7 @@ int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); | |||
95 | void iwlagn_send_prio_tbl(struct iwl_priv *priv); | 110 | void iwlagn_send_prio_tbl(struct iwl_priv *priv); |
96 | int iwlagn_run_init_ucode(struct iwl_priv *priv); | 111 | int iwlagn_run_init_ucode(struct iwl_priv *priv); |
97 | int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, | 112 | int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, |
98 | struct fw_img *image, | 113 | enum iwl_ucode_type ucode_type); |
99 | enum iwlagn_ucode_type ucode_type); | ||
100 | 114 | ||
101 | /* lib */ | 115 | /* lib */ |
102 | int iwlagn_send_tx_power(struct iwl_priv *priv); | 116 | int iwlagn_send_tx_power(struct iwl_priv *priv); |
@@ -105,6 +119,12 @@ u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); | |||
105 | int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); | 119 | int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); |
106 | void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); | 120 | void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); |
107 | int iwlagn_send_beacon_cmd(struct iwl_priv *priv); | 121 | int iwlagn_send_beacon_cmd(struct iwl_priv *priv); |
122 | #ifdef CONFIG_PM_SLEEP | ||
123 | int iwlagn_send_patterns(struct iwl_priv *priv, | ||
124 | struct cfg80211_wowlan *wowlan); | ||
125 | int iwlagn_suspend(struct iwl_priv *priv, | ||
126 | struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); | ||
127 | #endif | ||
108 | 128 | ||
109 | /* rx */ | 129 | /* rx */ |
110 | int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); | 130 | int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); |
@@ -196,9 +216,6 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, | |||
196 | struct ieee80211_sta *sta, u8 *sta_id_r); | 216 | struct ieee80211_sta *sta, u8 *sta_id_r); |
197 | int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, | 217 | int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, |
198 | const u8 *addr); | 218 | const u8 *addr); |
199 | int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | ||
200 | struct ieee80211_sta *sta); | ||
201 | |||
202 | u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, | 219 | u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, |
203 | const u8 *addr, bool is_ap, struct ieee80211_sta *sta); | 220 | const u8 *addr, bool is_ap, struct ieee80211_sta *sta); |
204 | 221 | ||
@@ -316,10 +333,6 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt); | |||
316 | int iwl_update_bcast_station(struct iwl_priv *priv, | 333 | int iwl_update_bcast_station(struct iwl_priv *priv, |
317 | struct iwl_rxon_context *ctx); | 334 | struct iwl_rxon_context *ctx); |
318 | int iwl_update_bcast_stations(struct iwl_priv *priv); | 335 | int iwl_update_bcast_stations(struct iwl_priv *priv); |
319 | void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, | ||
320 | struct ieee80211_vif *vif, | ||
321 | enum sta_notify_cmd cmd, | ||
322 | struct ieee80211_sta *sta); | ||
323 | 336 | ||
324 | /* rate */ | 337 | /* rate */ |
325 | static inline u32 iwl_ant_idx_to_flags(u8 ant_idx) | 338 | static inline u32 iwl_ant_idx_to_flags(u8 ant_idx) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-cfg.h b/drivers/net/wireless/iwlwifi/iwl-cfg.h index 2a2dc4597ba1..e1d78257e4a9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-cfg.h +++ b/drivers/net/wireless/iwlwifi/iwl-cfg.h | |||
@@ -101,17 +101,11 @@ extern struct iwl_cfg iwl100_bg_cfg; | |||
101 | extern struct iwl_cfg iwl130_bgn_cfg; | 101 | extern struct iwl_cfg iwl130_bgn_cfg; |
102 | extern struct iwl_cfg iwl130_bg_cfg; | 102 | extern struct iwl_cfg iwl130_bg_cfg; |
103 | extern struct iwl_cfg iwl2000_2bgn_cfg; | 103 | extern struct iwl_cfg iwl2000_2bgn_cfg; |
104 | extern struct iwl_cfg iwl2000_2bg_cfg; | ||
105 | extern struct iwl_cfg iwl2000_2bgn_d_cfg; | 104 | extern struct iwl_cfg iwl2000_2bgn_d_cfg; |
106 | extern struct iwl_cfg iwl2030_2bgn_cfg; | 105 | extern struct iwl_cfg iwl2030_2bgn_cfg; |
107 | extern struct iwl_cfg iwl2030_2bg_cfg; | ||
108 | extern struct iwl_cfg iwl6035_2agn_cfg; | 106 | extern struct iwl_cfg iwl6035_2agn_cfg; |
109 | extern struct iwl_cfg iwl6035_2abg_cfg; | ||
110 | extern struct iwl_cfg iwl6035_2bg_cfg; | ||
111 | extern struct iwl_cfg iwl105_bg_cfg; | ||
112 | extern struct iwl_cfg iwl105_bgn_cfg; | 107 | extern struct iwl_cfg iwl105_bgn_cfg; |
113 | extern struct iwl_cfg iwl105_bgn_d_cfg; | 108 | extern struct iwl_cfg iwl105_bgn_d_cfg; |
114 | extern struct iwl_cfg iwl135_bg_cfg; | ||
115 | extern struct iwl_cfg iwl135_bgn_cfg; | 109 | extern struct iwl_cfg iwl135_bgn_cfg; |
116 | 110 | ||
117 | #endif /* __iwl_pci_h__ */ | 111 | #endif /* __iwl_pci_h__ */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 69d5f85d11e2..f4eccf583775 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h | |||
@@ -198,6 +198,7 @@ enum { | |||
198 | REPLY_WOWLAN_TKIP_PARAMS = 0xe3, | 198 | REPLY_WOWLAN_TKIP_PARAMS = 0xe3, |
199 | REPLY_WOWLAN_KEK_KCK_MATERIAL = 0xe4, | 199 | REPLY_WOWLAN_KEK_KCK_MATERIAL = 0xe4, |
200 | REPLY_WOWLAN_GET_STATUS = 0xe5, | 200 | REPLY_WOWLAN_GET_STATUS = 0xe5, |
201 | REPLY_D3_CONFIG = 0xd3, | ||
201 | 202 | ||
202 | REPLY_MAX = 0xff | 203 | REPLY_MAX = 0xff |
203 | }; | 204 | }; |
@@ -3801,6 +3802,19 @@ struct iwl_bt_coex_prot_env_cmd { | |||
3801 | } __attribute__((packed)); | 3802 | } __attribute__((packed)); |
3802 | 3803 | ||
3803 | /* | 3804 | /* |
3805 | * REPLY_D3_CONFIG | ||
3806 | */ | ||
3807 | enum iwlagn_d3_wakeup_filters { | ||
3808 | IWLAGN_D3_WAKEUP_RFKILL = BIT(0), | ||
3809 | IWLAGN_D3_WAKEUP_SYSASSERT = BIT(1), | ||
3810 | }; | ||
3811 | |||
3812 | struct iwlagn_d3_config_cmd { | ||
3813 | __le32 min_sleep_time; | ||
3814 | __le32 wakeup_flags; | ||
3815 | } __packed; | ||
3816 | |||
3817 | /* | ||
3804 | * REPLY_WOWLAN_PATTERNS | 3818 | * REPLY_WOWLAN_PATTERNS |
3805 | */ | 3819 | */ |
3806 | #define IWLAGN_WOWLAN_MIN_PATTERN_LEN 16 | 3820 | #define IWLAGN_WOWLAN_MIN_PATTERN_LEN 16 |
@@ -3830,19 +3844,16 @@ enum iwlagn_wowlan_wakeup_filters { | |||
3830 | IWLAGN_WOWLAN_WAKEUP_BEACON_MISS = BIT(2), | 3844 | IWLAGN_WOWLAN_WAKEUP_BEACON_MISS = BIT(2), |
3831 | IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE = BIT(3), | 3845 | IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE = BIT(3), |
3832 | IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL = BIT(4), | 3846 | IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL = BIT(4), |
3833 | IWLAGN_WOWLAN_WAKEUP_RFKILL = BIT(5), | 3847 | IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(5), |
3834 | IWLAGN_WOWLAN_WAKEUP_UCODE_ERROR = BIT(6), | 3848 | IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(6), |
3835 | IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(7), | 3849 | IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(7), |
3836 | IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(8), | 3850 | IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(8), |
3837 | IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(9), | ||
3838 | IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(10), | ||
3839 | }; | 3851 | }; |
3840 | 3852 | ||
3841 | struct iwlagn_wowlan_wakeup_filter_cmd { | 3853 | struct iwlagn_wowlan_wakeup_filter_cmd { |
3842 | __le32 enabled; | 3854 | __le32 enabled; |
3843 | __le16 non_qos_seq; | 3855 | __le16 non_qos_seq; |
3844 | u8 min_sleep_seconds; | 3856 | __le16 reserved; |
3845 | u8 reserved; | ||
3846 | __le16 qos_seq[8]; | 3857 | __le16 qos_seq[8]; |
3847 | }; | 3858 | }; |
3848 | 3859 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 001fdf140abb..f9e9170e977a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -1120,229 +1120,8 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear) | |||
1120 | &statistics_cmd); | 1120 | &statistics_cmd); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, | ||
1124 | struct ieee80211_vif *vif, u16 queue, | ||
1125 | const struct ieee80211_tx_queue_params *params) | ||
1126 | { | ||
1127 | struct iwl_priv *priv = hw->priv; | ||
1128 | struct iwl_rxon_context *ctx; | ||
1129 | unsigned long flags; | ||
1130 | int q; | ||
1131 | |||
1132 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1133 | |||
1134 | if (!iwl_is_ready_rf(priv->shrd)) { | ||
1135 | IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); | ||
1136 | return -EIO; | ||
1137 | } | ||
1138 | |||
1139 | if (queue >= AC_NUM) { | ||
1140 | IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); | ||
1141 | return 0; | ||
1142 | } | ||
1143 | |||
1144 | q = AC_NUM - 1 - queue; | ||
1145 | |||
1146 | spin_lock_irqsave(&priv->shrd->lock, flags); | ||
1147 | |||
1148 | /* | ||
1149 | * MULTI-FIXME | ||
1150 | * This may need to be done per interface in nl80211/cfg80211/mac80211. | ||
1151 | */ | ||
1152 | for_each_context(priv, ctx) { | ||
1153 | ctx->qos_data.def_qos_parm.ac[q].cw_min = | ||
1154 | cpu_to_le16(params->cw_min); | ||
1155 | ctx->qos_data.def_qos_parm.ac[q].cw_max = | ||
1156 | cpu_to_le16(params->cw_max); | ||
1157 | ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; | ||
1158 | ctx->qos_data.def_qos_parm.ac[q].edca_txop = | ||
1159 | cpu_to_le16((params->txop * 32)); | ||
1160 | |||
1161 | ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; | ||
1162 | } | ||
1163 | |||
1164 | spin_unlock_irqrestore(&priv->shrd->lock, flags); | ||
1165 | |||
1166 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1167 | return 0; | ||
1168 | } | ||
1169 | |||
1170 | int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) | ||
1171 | { | ||
1172 | struct iwl_priv *priv = hw->priv; | ||
1173 | |||
1174 | return priv->ibss_manager == IWL_IBSS_MANAGER; | ||
1175 | } | ||
1176 | |||
1177 | static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | ||
1178 | { | ||
1179 | iwl_connection_init_rx_config(priv, ctx); | ||
1180 | |||
1181 | iwlagn_set_rxon_chain(priv, ctx); | ||
1182 | |||
1183 | return iwlagn_commit_rxon(priv, ctx); | ||
1184 | } | ||
1185 | |||
1186 | static int iwl_setup_interface(struct iwl_priv *priv, | ||
1187 | struct iwl_rxon_context *ctx) | ||
1188 | { | ||
1189 | struct ieee80211_vif *vif = ctx->vif; | ||
1190 | int err; | ||
1191 | |||
1192 | lockdep_assert_held(&priv->shrd->mutex); | ||
1193 | |||
1194 | /* | ||
1195 | * This variable will be correct only when there's just | ||
1196 | * a single context, but all code using it is for hardware | ||
1197 | * that supports only one context. | ||
1198 | */ | ||
1199 | priv->iw_mode = vif->type; | ||
1200 | |||
1201 | ctx->is_active = true; | ||
1202 | |||
1203 | err = iwl_set_mode(priv, ctx); | ||
1204 | if (err) { | ||
1205 | if (!ctx->always_active) | ||
1206 | ctx->is_active = false; | ||
1207 | return err; | ||
1208 | } | ||
1209 | |||
1210 | if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist && | ||
1211 | vif->type == NL80211_IFTYPE_ADHOC) { | ||
1212 | /* | ||
1213 | * pretend to have high BT traffic as long as we | ||
1214 | * are operating in IBSS mode, as this will cause | ||
1215 | * the rate scaling etc. to behave as intended. | ||
1216 | */ | ||
1217 | priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; | ||
1218 | } | ||
1219 | |||
1220 | return 0; | ||
1221 | } | ||
1222 | |||
1223 | int iwlagn_mac_add_interface(struct ieee80211_hw *hw, | ||
1224 | struct ieee80211_vif *vif) | ||
1225 | { | ||
1226 | struct iwl_priv *priv = hw->priv; | ||
1227 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
1228 | struct iwl_rxon_context *tmp, *ctx = NULL; | ||
1229 | int err; | ||
1230 | enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif); | ||
1231 | |||
1232 | IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", | ||
1233 | viftype, vif->addr); | ||
1234 | |||
1235 | cancel_delayed_work_sync(&priv->hw_roc_disable_work); | ||
1236 | |||
1237 | mutex_lock(&priv->shrd->mutex); | ||
1238 | |||
1239 | iwlagn_disable_roc(priv); | ||
1240 | |||
1241 | if (!iwl_is_ready_rf(priv->shrd)) { | ||
1242 | IWL_WARN(priv, "Try to add interface when device not ready\n"); | ||
1243 | err = -EINVAL; | ||
1244 | goto out; | ||
1245 | } | ||
1246 | |||
1247 | for_each_context(priv, tmp) { | ||
1248 | u32 possible_modes = | ||
1249 | tmp->interface_modes | tmp->exclusive_interface_modes; | ||
1250 | |||
1251 | if (tmp->vif) { | ||
1252 | /* check if this busy context is exclusive */ | ||
1253 | if (tmp->exclusive_interface_modes & | ||
1254 | BIT(tmp->vif->type)) { | ||
1255 | err = -EINVAL; | ||
1256 | goto out; | ||
1257 | } | ||
1258 | continue; | ||
1259 | } | ||
1260 | |||
1261 | if (!(possible_modes & BIT(viftype))) | ||
1262 | continue; | ||
1263 | 1123 | ||
1264 | /* have maybe usable context w/o interface */ | ||
1265 | ctx = tmp; | ||
1266 | break; | ||
1267 | } | ||
1268 | |||
1269 | if (!ctx) { | ||
1270 | err = -EOPNOTSUPP; | ||
1271 | goto out; | ||
1272 | } | ||
1273 | |||
1274 | vif_priv->ctx = ctx; | ||
1275 | ctx->vif = vif; | ||
1276 | |||
1277 | err = iwl_setup_interface(priv, ctx); | ||
1278 | if (!err) | ||
1279 | goto out; | ||
1280 | 1124 | ||
1281 | ctx->vif = NULL; | ||
1282 | priv->iw_mode = NL80211_IFTYPE_STATION; | ||
1283 | out: | ||
1284 | mutex_unlock(&priv->shrd->mutex); | ||
1285 | |||
1286 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1287 | return err; | ||
1288 | } | ||
1289 | |||
1290 | static void iwl_teardown_interface(struct iwl_priv *priv, | ||
1291 | struct ieee80211_vif *vif, | ||
1292 | bool mode_change) | ||
1293 | { | ||
1294 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
1295 | |||
1296 | lockdep_assert_held(&priv->shrd->mutex); | ||
1297 | |||
1298 | if (priv->scan_vif == vif) { | ||
1299 | iwl_scan_cancel_timeout(priv, 200); | ||
1300 | iwl_force_scan_end(priv); | ||
1301 | } | ||
1302 | |||
1303 | if (!mode_change) { | ||
1304 | iwl_set_mode(priv, ctx); | ||
1305 | if (!ctx->always_active) | ||
1306 | ctx->is_active = false; | ||
1307 | } | ||
1308 | |||
1309 | /* | ||
1310 | * When removing the IBSS interface, overwrite the | ||
1311 | * BT traffic load with the stored one from the last | ||
1312 | * notification, if any. If this is a device that | ||
1313 | * doesn't implement this, this has no effect since | ||
1314 | * both values are the same and zero. | ||
1315 | */ | ||
1316 | if (vif->type == NL80211_IFTYPE_ADHOC) | ||
1317 | priv->bt_traffic_load = priv->last_bt_traffic_load; | ||
1318 | } | ||
1319 | |||
1320 | void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, | ||
1321 | struct ieee80211_vif *vif) | ||
1322 | { | ||
1323 | struct iwl_priv *priv = hw->priv; | ||
1324 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
1325 | |||
1326 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1327 | |||
1328 | mutex_lock(&priv->shrd->mutex); | ||
1329 | |||
1330 | if (WARN_ON(ctx->vif != vif)) { | ||
1331 | struct iwl_rxon_context *tmp; | ||
1332 | IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif); | ||
1333 | for_each_context(priv, tmp) | ||
1334 | IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n", | ||
1335 | tmp->ctxid, tmp, tmp->vif); | ||
1336 | } | ||
1337 | ctx->vif = NULL; | ||
1338 | |||
1339 | iwl_teardown_interface(priv, vif, false); | ||
1340 | |||
1341 | mutex_unlock(&priv->shrd->mutex); | ||
1342 | |||
1343 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1344 | |||
1345 | } | ||
1346 | 1125 | ||
1347 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 1126 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
1348 | 1127 | ||
@@ -1649,97 +1428,13 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external) | |||
1649 | return 0; | 1428 | return 0; |
1650 | } | 1429 | } |
1651 | 1430 | ||
1652 | int iwlagn_mac_change_interface(struct ieee80211_hw *hw, | ||
1653 | struct ieee80211_vif *vif, | ||
1654 | enum nl80211_iftype newtype, bool newp2p) | ||
1655 | { | ||
1656 | struct iwl_priv *priv = hw->priv; | ||
1657 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
1658 | struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
1659 | struct iwl_rxon_context *tmp; | ||
1660 | enum nl80211_iftype newviftype = newtype; | ||
1661 | u32 interface_modes; | ||
1662 | int err; | ||
1663 | |||
1664 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1665 | |||
1666 | newtype = ieee80211_iftype_p2p(newtype, newp2p); | ||
1667 | |||
1668 | mutex_lock(&priv->shrd->mutex); | ||
1669 | |||
1670 | if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { | ||
1671 | /* | ||
1672 | * Huh? But wait ... this can maybe happen when | ||
1673 | * we're in the middle of a firmware restart! | ||
1674 | */ | ||
1675 | err = -EBUSY; | ||
1676 | goto out; | ||
1677 | } | ||
1678 | |||
1679 | interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; | ||
1680 | |||
1681 | if (!(interface_modes & BIT(newtype))) { | ||
1682 | err = -EBUSY; | ||
1683 | goto out; | ||
1684 | } | ||
1685 | |||
1686 | /* | ||
1687 | * Refuse a change that should be done by moving from the PAN | ||
1688 | * context to the BSS context instead, if the BSS context is | ||
1689 | * available and can support the new interface type. | ||
1690 | */ | ||
1691 | if (ctx->ctxid == IWL_RXON_CTX_PAN && !bss_ctx->vif && | ||
1692 | (bss_ctx->interface_modes & BIT(newtype) || | ||
1693 | bss_ctx->exclusive_interface_modes & BIT(newtype))) { | ||
1694 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); | ||
1695 | err = -EBUSY; | ||
1696 | goto out; | ||
1697 | } | ||
1698 | |||
1699 | if (ctx->exclusive_interface_modes & BIT(newtype)) { | ||
1700 | for_each_context(priv, tmp) { | ||
1701 | if (ctx == tmp) | ||
1702 | continue; | ||
1703 | |||
1704 | if (!tmp->vif) | ||
1705 | continue; | ||
1706 | |||
1707 | /* | ||
1708 | * The current mode switch would be exclusive, but | ||
1709 | * another context is active ... refuse the switch. | ||
1710 | */ | ||
1711 | err = -EBUSY; | ||
1712 | goto out; | ||
1713 | } | ||
1714 | } | ||
1715 | |||
1716 | /* success */ | ||
1717 | iwl_teardown_interface(priv, vif, true); | ||
1718 | vif->type = newviftype; | ||
1719 | vif->p2p = newp2p; | ||
1720 | err = iwl_setup_interface(priv, ctx); | ||
1721 | WARN_ON(err); | ||
1722 | /* | ||
1723 | * We've switched internally, but submitting to the | ||
1724 | * device may have failed for some reason. Mask this | ||
1725 | * error, because otherwise mac80211 will not switch | ||
1726 | * (and set the interface type back) and we'll be | ||
1727 | * out of sync with it. | ||
1728 | */ | ||
1729 | err = 0; | ||
1730 | |||
1731 | out: | ||
1732 | mutex_unlock(&priv->shrd->mutex); | ||
1733 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1734 | |||
1735 | return err; | ||
1736 | } | ||
1737 | 1431 | ||
1738 | int iwl_cmd_echo_test(struct iwl_priv *priv) | 1432 | int iwl_cmd_echo_test(struct iwl_priv *priv) |
1739 | { | 1433 | { |
1740 | int ret; | 1434 | int ret; |
1741 | struct iwl_host_cmd cmd = { | 1435 | struct iwl_host_cmd cmd = { |
1742 | .id = REPLY_ECHO, | 1436 | .id = REPLY_ECHO, |
1437 | .len = { 0 }, | ||
1743 | .flags = CMD_SYNC, | 1438 | .flags = CMD_SYNC, |
1744 | }; | 1439 | }; |
1745 | 1440 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 137da3380704..fa47f75185df 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -237,10 +237,6 @@ struct iwl_cfg { | |||
237 | * L i b * | 237 | * L i b * |
238 | ***************************/ | 238 | ***************************/ |
239 | 239 | ||
240 | int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, | ||
241 | struct ieee80211_vif *vif, u16 queue, | ||
242 | const struct ieee80211_tx_queue_params *params); | ||
243 | int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw); | ||
244 | void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx, | 240 | void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx, |
245 | int hw_decrypt); | 241 | int hw_decrypt); |
246 | int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx); | 242 | int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx); |
@@ -260,13 +256,6 @@ bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv, | |||
260 | void iwl_connection_init_rx_config(struct iwl_priv *priv, | 256 | void iwl_connection_init_rx_config(struct iwl_priv *priv, |
261 | struct iwl_rxon_context *ctx); | 257 | struct iwl_rxon_context *ctx); |
262 | void iwl_set_rate(struct iwl_priv *priv); | 258 | void iwl_set_rate(struct iwl_priv *priv); |
263 | int iwlagn_mac_add_interface(struct ieee80211_hw *hw, | ||
264 | struct ieee80211_vif *vif); | ||
265 | void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, | ||
266 | struct ieee80211_vif *vif); | ||
267 | int iwlagn_mac_change_interface(struct ieee80211_hw *hw, | ||
268 | struct ieee80211_vif *vif, | ||
269 | enum nl80211_iftype newtype, bool newp2p); | ||
270 | int iwl_cmd_echo_test(struct iwl_priv *priv); | 259 | int iwl_cmd_echo_test(struct iwl_priv *priv); |
271 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 260 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
272 | int iwl_alloc_traffic_mem(struct iwl_priv *priv); | 261 | int iwl_alloc_traffic_mem(struct iwl_priv *priv); |
@@ -323,9 +312,6 @@ void iwl_init_scan_params(struct iwl_priv *priv); | |||
323 | int iwl_scan_cancel(struct iwl_priv *priv); | 312 | int iwl_scan_cancel(struct iwl_priv *priv); |
324 | void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); | 313 | void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); |
325 | void iwl_force_scan_end(struct iwl_priv *priv); | 314 | void iwl_force_scan_end(struct iwl_priv *priv); |
326 | int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, | ||
327 | struct ieee80211_vif *vif, | ||
328 | struct cfg80211_scan_request *req); | ||
329 | void iwl_internal_short_hw_scan(struct iwl_priv *priv); | 315 | void iwl_internal_short_hw_scan(struct iwl_priv *priv); |
330 | int iwl_force_reset(struct iwl_priv *priv, int mode, bool external); | 316 | int iwl_force_reset(struct iwl_priv *priv, int mode, bool external); |
331 | u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, | 317 | u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h index b9f3267e720c..fbc3095c7b44 100644 --- a/drivers/net/wireless/iwlwifi/iwl-csr.h +++ b/drivers/net/wireless/iwlwifi/iwl-csr.h | |||
@@ -284,8 +284,8 @@ | |||
284 | #define CSR_HW_REV_TYPE_6x35 CSR_HW_REV_TYPE_6x05 | 284 | #define CSR_HW_REV_TYPE_6x35 CSR_HW_REV_TYPE_6x05 |
285 | #define CSR_HW_REV_TYPE_2x30 (0x00000C0) | 285 | #define CSR_HW_REV_TYPE_2x30 (0x00000C0) |
286 | #define CSR_HW_REV_TYPE_2x00 (0x0000100) | 286 | #define CSR_HW_REV_TYPE_2x00 (0x0000100) |
287 | #define CSR_HW_REV_TYPE_200 (0x0000110) | 287 | #define CSR_HW_REV_TYPE_105 (0x0000110) |
288 | #define CSR_HW_REV_TYPE_230 (0x0000120) | 288 | #define CSR_HW_REV_TYPE_135 (0x0000120) |
289 | #define CSR_HW_REV_TYPE_NONE (0x00001F0) | 289 | #define CSR_HW_REV_TYPE_NONE (0x00001F0) |
290 | 290 | ||
291 | /* EEPROM REG */ | 291 | /* EEPROM REG */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 69a77e24d229..40ef97bac1aa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h | |||
@@ -70,10 +70,25 @@ do { \ | |||
70 | DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ | 70 | DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ |
71 | } while (0) | 71 | } while (0) |
72 | 72 | ||
73 | #define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ | ||
74 | do { \ | ||
75 | if (!iwl_is_rfkill(p->shrd)) \ | ||
76 | dev_printk(KERN_ERR, bus(p)->dev, "%c %s " fmt, \ | ||
77 | (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ | ||
78 | else if (iwl_get_debug_level(p->shrd) & IWL_DL_RADIO) \ | ||
79 | dev_printk(KERN_ERR, bus(p)->dev, "(RFKILL) %c %s " fmt, \ | ||
80 | (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ | ||
81 | } while (0) | ||
82 | |||
73 | #else | 83 | #else |
74 | #define IWL_DEBUG(m, level, fmt, args...) | 84 | #define IWL_DEBUG(m, level, fmt, args...) |
75 | #define IWL_DEBUG_LIMIT(m, level, fmt, args...) | 85 | #define IWL_DEBUG_LIMIT(m, level, fmt, args...) |
76 | #define iwl_print_hex_dump(m, level, p, len) | 86 | #define iwl_print_hex_dump(m, level, p, len) |
87 | #define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ | ||
88 | do { \ | ||
89 | if (!iwl_is_rfkill(p->shrd)) \ | ||
90 | IWL_ERR(p, fmt, ##args); \ | ||
91 | } while (0) | ||
77 | #endif /* CONFIG_IWLWIFI_DEBUG */ | 92 | #endif /* CONFIG_IWLWIFI_DEBUG */ |
78 | 93 | ||
79 | #ifdef CONFIG_IWLWIFI_DEBUGFS | 94 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
@@ -151,7 +166,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) | |||
151 | #define IWL_DL_11H (1 << 28) | 166 | #define IWL_DL_11H (1 << 28) |
152 | #define IWL_DL_STATS (1 << 29) | 167 | #define IWL_DL_STATS (1 << 29) |
153 | #define IWL_DL_TX_REPLY (1 << 30) | 168 | #define IWL_DL_TX_REPLY (1 << 30) |
154 | #define IWL_DL_QOS (1 << 31) | 169 | #define IWL_DL_TX_QUEUES (1 << 31) |
155 | 170 | ||
156 | #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) | 171 | #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) |
157 | #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) | 172 | #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) |
@@ -188,7 +203,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) | |||
188 | #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) | 203 | #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) |
189 | #define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ | 204 | #define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ |
190 | IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) | 205 | IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) |
191 | #define IWL_DEBUG_QOS(p, f, a...) IWL_DEBUG(p, IWL_DL_QOS, f, ## a) | 206 | #define IWL_DEBUG_TX_QUEUES(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_QUEUES, f, ## a) |
192 | #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) | 207 | #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) |
193 | #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) | 208 | #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) |
194 | #define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a) | 209 | #define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index a1670e3f8bfa..68b04f5b10ce 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c | |||
@@ -236,9 +236,9 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, | |||
236 | if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { | 236 | if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { |
237 | priv->dbgfs_sram_offset = 0x800000; | 237 | priv->dbgfs_sram_offset = 0x800000; |
238 | if (priv->ucode_type == IWL_UCODE_INIT) | 238 | if (priv->ucode_type == IWL_UCODE_INIT) |
239 | priv->dbgfs_sram_len = priv->ucode_init.data.len; | 239 | priv->dbgfs_sram_len = trans(priv)->ucode_init.data.len; |
240 | else | 240 | else |
241 | priv->dbgfs_sram_len = priv->ucode_rt.data.len; | 241 | priv->dbgfs_sram_len = trans(priv)->ucode_rt.data.len; |
242 | } | 242 | } |
243 | len = priv->dbgfs_sram_len; | 243 | len = priv->dbgfs_sram_len; |
244 | 244 | ||
@@ -341,7 +341,7 @@ static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, | |||
341 | 341 | ||
342 | return simple_read_from_buffer(user_buf, count, ppos, | 342 | return simple_read_from_buffer(user_buf, count, ppos, |
343 | priv->wowlan_sram, | 343 | priv->wowlan_sram, |
344 | priv->ucode_wowlan.data.len); | 344 | trans(priv)->ucode_wowlan.data.len); |
345 | } | 345 | } |
346 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, | 346 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
347 | size_t count, loff_t *ppos) | 347 | size_t count, loff_t *ppos) |
@@ -430,7 +430,7 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file, | |||
430 | eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); | 430 | eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); |
431 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " | 431 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " |
432 | "version: 0x%x\n", | 432 | "version: 0x%x\n", |
433 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) | 433 | (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
434 | ? "OTP" : "EEPROM", eeprom_ver); | 434 | ? "OTP" : "EEPROM", eeprom_ver); |
435 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { | 435 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
436 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); | 436 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 6c00a447963d..556e4a2c19bc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -230,17 +230,6 @@ struct iwl_vif_priv { | |||
230 | u8 ibss_bssid_sta_id; | 230 | u8 ibss_bssid_sta_id; |
231 | }; | 231 | }; |
232 | 232 | ||
233 | /* one for each uCode image (inst/data, boot/init/runtime) */ | ||
234 | struct fw_desc { | ||
235 | void *v_addr; /* access by driver */ | ||
236 | dma_addr_t p_addr; /* access by card's busmaster DMA */ | ||
237 | u32 len; /* bytes */ | ||
238 | }; | ||
239 | |||
240 | struct fw_img { | ||
241 | struct fw_desc code, data; | ||
242 | }; | ||
243 | |||
244 | /* v1/v2 uCode file layout */ | 233 | /* v1/v2 uCode file layout */ |
245 | struct iwl_ucode_header { | 234 | struct iwl_ucode_header { |
246 | __le32 ver; /* major/minor/API/serial */ | 235 | __le32 ver; /* major/minor/API/serial */ |
@@ -805,13 +794,6 @@ enum iwl_scan_type { | |||
805 | IWL_SCAN_ROC, | 794 | IWL_SCAN_ROC, |
806 | }; | 795 | }; |
807 | 796 | ||
808 | enum iwlagn_ucode_type { | ||
809 | IWL_UCODE_NONE, | ||
810 | IWL_UCODE_REGULAR, | ||
811 | IWL_UCODE_INIT, | ||
812 | IWL_UCODE_WOWLAN, | ||
813 | }; | ||
814 | |||
815 | #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL | 797 | #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL |
816 | struct iwl_testmode_trace { | 798 | struct iwl_testmode_trace { |
817 | u32 buff_size; | 799 | u32 buff_size; |
@@ -824,6 +806,12 @@ struct iwl_testmode_trace { | |||
824 | }; | 806 | }; |
825 | #endif | 807 | #endif |
826 | 808 | ||
809 | struct iwl_wipan_noa_data { | ||
810 | struct rcu_head rcu_head; | ||
811 | u32 length; | ||
812 | u8 data[]; | ||
813 | }; | ||
814 | |||
827 | struct iwl_priv { | 815 | struct iwl_priv { |
828 | 816 | ||
829 | /*data shared among all the driver's layers */ | 817 | /*data shared among all the driver's layers */ |
@@ -883,6 +871,8 @@ struct iwl_priv { | |||
883 | /* init calibration results */ | 871 | /* init calibration results */ |
884 | struct iwl_calib_result calib_results[IWL_CALIB_MAX]; | 872 | struct iwl_calib_result calib_results[IWL_CALIB_MAX]; |
885 | 873 | ||
874 | struct iwl_wipan_noa_data __rcu *noa_data; | ||
875 | |||
886 | /* Scan related variables */ | 876 | /* Scan related variables */ |
887 | unsigned long scan_start; | 877 | unsigned long scan_start; |
888 | unsigned long scan_start_tsf; | 878 | unsigned long scan_start_tsf; |
@@ -907,12 +897,7 @@ struct iwl_priv { | |||
907 | u32 ucode_ver; /* version of ucode, copy of | 897 | u32 ucode_ver; /* version of ucode, copy of |
908 | iwl_ucode.ver */ | 898 | iwl_ucode.ver */ |
909 | 899 | ||
910 | struct fw_img ucode_rt; | 900 | enum iwl_ucode_type ucode_type; |
911 | struct fw_img ucode_init; | ||
912 | struct fw_img ucode_wowlan; | ||
913 | |||
914 | enum iwlagn_ucode_type ucode_type; | ||
915 | u8 ucode_write_complete; /* the image write is complete */ | ||
916 | char firmware_name[25]; | 901 | char firmware_name[25]; |
917 | 902 | ||
918 | struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; | 903 | struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; |
@@ -959,7 +944,6 @@ struct iwl_priv { | |||
959 | 944 | ||
960 | /* eeprom -- this is in the card's little endian byte order */ | 945 | /* eeprom -- this is in the card's little endian byte order */ |
961 | u8 *eeprom; | 946 | u8 *eeprom; |
962 | int nvm_device_type; | ||
963 | struct iwl_eeprom_calib_info *calib_info; | 947 | struct iwl_eeprom_calib_info *calib_info; |
964 | 948 | ||
965 | enum nl80211_iftype iw_mode; | 949 | enum nl80211_iftype iw_mode; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/iwlwifi/iwl-devtrace.c index a635a7e75447..2a2c8de64a04 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.c +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | /* sparse doesn't like tracepoint macros */ | 29 | /* sparse doesn't like tracepoint macros */ |
30 | #ifndef __CHECKER__ | 30 | #ifndef __CHECKER__ |
31 | #include "iwl-dev.h" | 31 | #include "iwl-trans.h" |
32 | 32 | ||
33 | #define CREATE_TRACE_POINTS | 33 | #define CREATE_TRACE_POINTS |
34 | #include "iwl-devtrace.h" | 34 | #include "iwl-devtrace.h" |
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h index 8a51c5ccda1e..f9d3319ecad5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include <linux/tracepoint.h> | 30 | #include <linux/tracepoint.h> |
31 | 31 | ||
32 | struct iwl_priv; | ||
33 | 32 | ||
34 | #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__) | 33 | #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__) |
35 | #undef TRACE_EVENT | 34 | #undef TRACE_EVENT |
@@ -37,14 +36,14 @@ struct iwl_priv; | |||
37 | static inline void trace_ ## name(proto) {} | 36 | static inline void trace_ ## name(proto) {} |
38 | #endif | 37 | #endif |
39 | 38 | ||
40 | #define PRIV_ENTRY __field(struct iwl_priv *, priv) | 39 | #define PRIV_ENTRY __field(void *, priv) |
41 | #define PRIV_ASSIGN __entry->priv = priv | 40 | #define PRIV_ASSIGN __entry->priv = priv |
42 | 41 | ||
43 | #undef TRACE_SYSTEM | 42 | #undef TRACE_SYSTEM |
44 | #define TRACE_SYSTEM iwlwifi_io | 43 | #define TRACE_SYSTEM iwlwifi_io |
45 | 44 | ||
46 | TRACE_EVENT(iwlwifi_dev_ioread32, | 45 | TRACE_EVENT(iwlwifi_dev_ioread32, |
47 | TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), | 46 | TP_PROTO(void *priv, u32 offs, u32 val), |
48 | TP_ARGS(priv, offs, val), | 47 | TP_ARGS(priv, offs, val), |
49 | TP_STRUCT__entry( | 48 | TP_STRUCT__entry( |
50 | PRIV_ENTRY | 49 | PRIV_ENTRY |
@@ -60,7 +59,7 @@ TRACE_EVENT(iwlwifi_dev_ioread32, | |||
60 | ); | 59 | ); |
61 | 60 | ||
62 | TRACE_EVENT(iwlwifi_dev_iowrite8, | 61 | TRACE_EVENT(iwlwifi_dev_iowrite8, |
63 | TP_PROTO(struct iwl_priv *priv, u32 offs, u8 val), | 62 | TP_PROTO(void *priv, u32 offs, u8 val), |
64 | TP_ARGS(priv, offs, val), | 63 | TP_ARGS(priv, offs, val), |
65 | TP_STRUCT__entry( | 64 | TP_STRUCT__entry( |
66 | PRIV_ENTRY | 65 | PRIV_ENTRY |
@@ -76,7 +75,7 @@ TRACE_EVENT(iwlwifi_dev_iowrite8, | |||
76 | ); | 75 | ); |
77 | 76 | ||
78 | TRACE_EVENT(iwlwifi_dev_iowrite32, | 77 | TRACE_EVENT(iwlwifi_dev_iowrite32, |
79 | TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), | 78 | TP_PROTO(void *priv, u32 offs, u32 val), |
80 | TP_ARGS(priv, offs, val), | 79 | TP_ARGS(priv, offs, val), |
81 | TP_STRUCT__entry( | 80 | TP_STRUCT__entry( |
82 | PRIV_ENTRY | 81 | PRIV_ENTRY |
@@ -95,7 +94,7 @@ TRACE_EVENT(iwlwifi_dev_iowrite32, | |||
95 | #define TRACE_SYSTEM iwlwifi_ucode | 94 | #define TRACE_SYSTEM iwlwifi_ucode |
96 | 95 | ||
97 | TRACE_EVENT(iwlwifi_dev_ucode_cont_event, | 96 | TRACE_EVENT(iwlwifi_dev_ucode_cont_event, |
98 | TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), | 97 | TP_PROTO(void *priv, u32 time, u32 data, u32 ev), |
99 | TP_ARGS(priv, time, data, ev), | 98 | TP_ARGS(priv, time, data, ev), |
100 | TP_STRUCT__entry( | 99 | TP_STRUCT__entry( |
101 | PRIV_ENTRY | 100 | PRIV_ENTRY |
@@ -115,7 +114,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_cont_event, | |||
115 | ); | 114 | ); |
116 | 115 | ||
117 | TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, | 116 | TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, |
118 | TP_PROTO(struct iwl_priv *priv, u32 wraps, u32 n_entry, u32 p_entry), | 117 | TP_PROTO(void *priv, u32 wraps, u32 n_entry, u32 p_entry), |
119 | TP_ARGS(priv, wraps, n_entry, p_entry), | 118 | TP_ARGS(priv, wraps, n_entry, p_entry), |
120 | TP_STRUCT__entry( | 119 | TP_STRUCT__entry( |
121 | PRIV_ENTRY | 120 | PRIV_ENTRY |
@@ -139,7 +138,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, | |||
139 | #define TRACE_SYSTEM iwlwifi | 138 | #define TRACE_SYSTEM iwlwifi |
140 | 139 | ||
141 | TRACE_EVENT(iwlwifi_dev_hcmd, | 140 | TRACE_EVENT(iwlwifi_dev_hcmd, |
142 | TP_PROTO(struct iwl_priv *priv, u32 flags, | 141 | TP_PROTO(void *priv, u32 flags, |
143 | const void *hcmd0, size_t len0, | 142 | const void *hcmd0, size_t len0, |
144 | const void *hcmd1, size_t len1, | 143 | const void *hcmd1, size_t len1, |
145 | const void *hcmd2, size_t len2), | 144 | const void *hcmd2, size_t len2), |
@@ -164,7 +163,7 @@ TRACE_EVENT(iwlwifi_dev_hcmd, | |||
164 | ); | 163 | ); |
165 | 164 | ||
166 | TRACE_EVENT(iwlwifi_dev_rx, | 165 | TRACE_EVENT(iwlwifi_dev_rx, |
167 | TP_PROTO(struct iwl_priv *priv, void *rxbuf, size_t len), | 166 | TP_PROTO(void *priv, void *rxbuf, size_t len), |
168 | TP_ARGS(priv, rxbuf, len), | 167 | TP_ARGS(priv, rxbuf, len), |
169 | TP_STRUCT__entry( | 168 | TP_STRUCT__entry( |
170 | PRIV_ENTRY | 169 | PRIV_ENTRY |
@@ -179,7 +178,7 @@ TRACE_EVENT(iwlwifi_dev_rx, | |||
179 | ); | 178 | ); |
180 | 179 | ||
181 | TRACE_EVENT(iwlwifi_dev_tx, | 180 | TRACE_EVENT(iwlwifi_dev_tx, |
182 | TP_PROTO(struct iwl_priv *priv, void *tfd, size_t tfdlen, | 181 | TP_PROTO(void *priv, void *tfd, size_t tfdlen, |
183 | void *buf0, size_t buf0_len, | 182 | void *buf0, size_t buf0_len, |
184 | void *buf1, size_t buf1_len), | 183 | void *buf1, size_t buf1_len), |
185 | TP_ARGS(priv, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len), | 184 | TP_ARGS(priv, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len), |
@@ -211,7 +210,7 @@ TRACE_EVENT(iwlwifi_dev_tx, | |||
211 | ); | 210 | ); |
212 | 211 | ||
213 | TRACE_EVENT(iwlwifi_dev_ucode_error, | 212 | TRACE_EVENT(iwlwifi_dev_ucode_error, |
214 | TP_PROTO(struct iwl_priv *priv, u32 desc, u32 tsf_low, | 213 | TP_PROTO(void *priv, u32 desc, u32 tsf_low, |
215 | u32 data1, u32 data2, u32 line, u32 blink1, | 214 | u32 data1, u32 data2, u32 line, u32 blink1, |
216 | u32 blink2, u32 ilink1, u32 ilink2, u32 bcon_time, | 215 | u32 blink2, u32 ilink1, u32 ilink2, u32 bcon_time, |
217 | u32 gp1, u32 gp2, u32 gp3, u32 ucode_ver, u32 hw_ver, | 216 | u32 gp1, u32 gp2, u32 gp3, u32 ucode_ver, u32 hw_ver, |
@@ -271,7 +270,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_error, | |||
271 | ); | 270 | ); |
272 | 271 | ||
273 | TRACE_EVENT(iwlwifi_dev_ucode_event, | 272 | TRACE_EVENT(iwlwifi_dev_ucode_event, |
274 | TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), | 273 | TP_PROTO(void *priv, u32 time, u32 data, u32 ev), |
275 | TP_ARGS(priv, time, data, ev), | 274 | TP_ARGS(priv, time, data, ev), |
276 | TP_STRUCT__entry( | 275 | TP_STRUCT__entry( |
277 | PRIV_ENTRY | 276 | PRIV_ENTRY |
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index a4e43bd4a547..dcada0827ea4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c | |||
@@ -149,23 +149,23 @@ static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */ | |||
149 | * EEPROM chip, not a single event, so even reads could conflict if they | 149 | * EEPROM chip, not a single event, so even reads could conflict if they |
150 | * weren't arbitrated by the semaphore. | 150 | * weren't arbitrated by the semaphore. |
151 | */ | 151 | */ |
152 | static int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv) | 152 | static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) |
153 | { | 153 | { |
154 | u16 count; | 154 | u16 count; |
155 | int ret; | 155 | int ret; |
156 | 156 | ||
157 | for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { | 157 | for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { |
158 | /* Request semaphore */ | 158 | /* Request semaphore */ |
159 | iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, | 159 | iwl_set_bit(bus, CSR_HW_IF_CONFIG_REG, |
160 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); | 160 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); |
161 | 161 | ||
162 | /* See if we got it */ | 162 | /* See if we got it */ |
163 | ret = iwl_poll_bit(bus(priv), CSR_HW_IF_CONFIG_REG, | 163 | ret = iwl_poll_bit(bus, CSR_HW_IF_CONFIG_REG, |
164 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, | 164 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, |
165 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, | 165 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, |
166 | EEPROM_SEM_TIMEOUT); | 166 | EEPROM_SEM_TIMEOUT); |
167 | if (ret >= 0) { | 167 | if (ret >= 0) { |
168 | IWL_DEBUG_EEPROM(priv, | 168 | IWL_DEBUG_EEPROM(bus, |
169 | "Acquired semaphore after %d tries.\n", | 169 | "Acquired semaphore after %d tries.\n", |
170 | count+1); | 170 | count+1); |
171 | return ret; | 171 | return ret; |
@@ -175,39 +175,39 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv) | |||
175 | return ret; | 175 | return ret; |
176 | } | 176 | } |
177 | 177 | ||
178 | static void iwl_eeprom_release_semaphore(struct iwl_priv *priv) | 178 | static void iwl_eeprom_release_semaphore(struct iwl_bus *bus) |
179 | { | 179 | { |
180 | iwl_clear_bit(bus(priv), CSR_HW_IF_CONFIG_REG, | 180 | iwl_clear_bit(bus, CSR_HW_IF_CONFIG_REG, |
181 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); | 181 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); |
182 | 182 | ||
183 | } | 183 | } |
184 | 184 | ||
185 | static int iwl_eeprom_verify_signature(struct iwl_priv *priv) | 185 | static int iwl_eeprom_verify_signature(struct iwl_trans *trans) |
186 | { | 186 | { |
187 | u32 gp = iwl_read32(bus(priv), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; | 187 | u32 gp = iwl_read32(bus(trans), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; |
188 | int ret = 0; | 188 | int ret = 0; |
189 | 189 | ||
190 | IWL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); | 190 | IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp); |
191 | switch (gp) { | 191 | switch (gp) { |
192 | case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP: | 192 | case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP: |
193 | if (priv->nvm_device_type != NVM_DEVICE_TYPE_OTP) { | 193 | if (trans->nvm_device_type != NVM_DEVICE_TYPE_OTP) { |
194 | IWL_ERR(priv, "EEPROM with bad signature: 0x%08x\n", | 194 | IWL_ERR(trans, "EEPROM with bad signature: 0x%08x\n", |
195 | gp); | 195 | gp); |
196 | ret = -ENOENT; | 196 | ret = -ENOENT; |
197 | } | 197 | } |
198 | break; | 198 | break; |
199 | case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: | 199 | case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: |
200 | case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: | 200 | case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: |
201 | if (priv->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) { | 201 | if (trans->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) { |
202 | IWL_ERR(priv, "OTP with bad signature: 0x%08x\n", gp); | 202 | IWL_ERR(trans, "OTP with bad signature: 0x%08x\n", gp); |
203 | ret = -ENOENT; | 203 | ret = -ENOENT; |
204 | } | 204 | } |
205 | break; | 205 | break; |
206 | case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP: | 206 | case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP: |
207 | default: | 207 | default: |
208 | IWL_ERR(priv, "bad EEPROM/OTP signature, type=%s, " | 208 | IWL_ERR(trans, "bad EEPROM/OTP signature, type=%s, " |
209 | "EEPROM_GP=0x%08x\n", | 209 | "EEPROM_GP=0x%08x\n", |
210 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) | 210 | (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
211 | ? "OTP" : "EEPROM", gp); | 211 | ? "OTP" : "EEPROM", gp); |
212 | ret = -ENOENT; | 212 | ret = -ENOENT; |
213 | break; | 213 | break; |
@@ -302,19 +302,19 @@ void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) | |||
302 | * | 302 | * |
303 | ******************************************************************************/ | 303 | ******************************************************************************/ |
304 | 304 | ||
305 | static void iwl_set_otp_access(struct iwl_priv *priv, enum iwl_access_mode mode) | 305 | static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode) |
306 | { | 306 | { |
307 | iwl_read32(bus(priv), CSR_OTP_GP_REG); | 307 | iwl_read32(bus, CSR_OTP_GP_REG); |
308 | 308 | ||
309 | if (mode == IWL_OTP_ACCESS_ABSOLUTE) | 309 | if (mode == IWL_OTP_ACCESS_ABSOLUTE) |
310 | iwl_clear_bit(bus(priv), CSR_OTP_GP_REG, | 310 | iwl_clear_bit(bus, CSR_OTP_GP_REG, |
311 | CSR_OTP_GP_REG_OTP_ACCESS_MODE); | 311 | CSR_OTP_GP_REG_OTP_ACCESS_MODE); |
312 | else | 312 | else |
313 | iwl_set_bit(bus(priv), CSR_OTP_GP_REG, | 313 | iwl_set_bit(bus, CSR_OTP_GP_REG, |
314 | CSR_OTP_GP_REG_OTP_ACCESS_MODE); | 314 | CSR_OTP_GP_REG_OTP_ACCESS_MODE); |
315 | } | 315 | } |
316 | 316 | ||
317 | static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) | 317 | static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) |
318 | { | 318 | { |
319 | u32 otpgp; | 319 | u32 otpgp; |
320 | int nvm_type; | 320 | int nvm_type; |
@@ -322,7 +322,7 @@ static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) | |||
322 | /* OTP only valid for CP/PP and after */ | 322 | /* OTP only valid for CP/PP and after */ |
323 | switch (hw_rev & CSR_HW_REV_TYPE_MSK) { | 323 | switch (hw_rev & CSR_HW_REV_TYPE_MSK) { |
324 | case CSR_HW_REV_TYPE_NONE: | 324 | case CSR_HW_REV_TYPE_NONE: |
325 | IWL_ERR(priv, "Unknown hardware type\n"); | 325 | IWL_ERR(bus, "Unknown hardware type\n"); |
326 | return -ENOENT; | 326 | return -ENOENT; |
327 | case CSR_HW_REV_TYPE_5300: | 327 | case CSR_HW_REV_TYPE_5300: |
328 | case CSR_HW_REV_TYPE_5350: | 328 | case CSR_HW_REV_TYPE_5350: |
@@ -331,7 +331,7 @@ static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) | |||
331 | nvm_type = NVM_DEVICE_TYPE_EEPROM; | 331 | nvm_type = NVM_DEVICE_TYPE_EEPROM; |
332 | break; | 332 | break; |
333 | default: | 333 | default: |
334 | otpgp = iwl_read32(bus(priv), CSR_OTP_GP_REG); | 334 | otpgp = iwl_read32(bus, CSR_OTP_GP_REG); |
335 | if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT) | 335 | if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT) |
336 | nvm_type = NVM_DEVICE_TYPE_OTP; | 336 | nvm_type = NVM_DEVICE_TYPE_OTP; |
337 | else | 337 | else |
@@ -341,73 +341,73 @@ static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) | |||
341 | return nvm_type; | 341 | return nvm_type; |
342 | } | 342 | } |
343 | 343 | ||
344 | static int iwl_init_otp_access(struct iwl_priv *priv) | 344 | static int iwl_init_otp_access(struct iwl_bus *bus) |
345 | { | 345 | { |
346 | int ret; | 346 | int ret; |
347 | 347 | ||
348 | /* Enable 40MHz radio clock */ | 348 | /* Enable 40MHz radio clock */ |
349 | iwl_write32(bus(priv), CSR_GP_CNTRL, | 349 | iwl_write32(bus, CSR_GP_CNTRL, |
350 | iwl_read32(bus(priv), CSR_GP_CNTRL) | | 350 | iwl_read32(bus, CSR_GP_CNTRL) | |
351 | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 351 | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
352 | 352 | ||
353 | /* wait for clock to be ready */ | 353 | /* wait for clock to be ready */ |
354 | ret = iwl_poll_bit(bus(priv), CSR_GP_CNTRL, | 354 | ret = iwl_poll_bit(bus, CSR_GP_CNTRL, |
355 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | 355 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, |
356 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | 356 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, |
357 | 25000); | 357 | 25000); |
358 | if (ret < 0) | 358 | if (ret < 0) |
359 | IWL_ERR(priv, "Time out access OTP\n"); | 359 | IWL_ERR(bus, "Time out access OTP\n"); |
360 | else { | 360 | else { |
361 | iwl_set_bits_prph(bus(priv), APMG_PS_CTRL_REG, | 361 | iwl_set_bits_prph(bus, APMG_PS_CTRL_REG, |
362 | APMG_PS_CTRL_VAL_RESET_REQ); | 362 | APMG_PS_CTRL_VAL_RESET_REQ); |
363 | udelay(5); | 363 | udelay(5); |
364 | iwl_clear_bits_prph(bus(priv), APMG_PS_CTRL_REG, | 364 | iwl_clear_bits_prph(bus, APMG_PS_CTRL_REG, |
365 | APMG_PS_CTRL_VAL_RESET_REQ); | 365 | APMG_PS_CTRL_VAL_RESET_REQ); |
366 | 366 | ||
367 | /* | 367 | /* |
368 | * CSR auto clock gate disable bit - | 368 | * CSR auto clock gate disable bit - |
369 | * this is only applicable for HW with OTP shadow RAM | 369 | * this is only applicable for HW with OTP shadow RAM |
370 | */ | 370 | */ |
371 | if (priv->cfg->base_params->shadow_ram_support) | 371 | if (priv(bus)->cfg->base_params->shadow_ram_support) |
372 | iwl_set_bit(bus(priv), CSR_DBG_LINK_PWR_MGMT_REG, | 372 | iwl_set_bit(bus, CSR_DBG_LINK_PWR_MGMT_REG, |
373 | CSR_RESET_LINK_PWR_MGMT_DISABLED); | 373 | CSR_RESET_LINK_PWR_MGMT_DISABLED); |
374 | } | 374 | } |
375 | return ret; | 375 | return ret; |
376 | } | 376 | } |
377 | 377 | ||
378 | static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, __le16 *eeprom_data) | 378 | static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) |
379 | { | 379 | { |
380 | int ret = 0; | 380 | int ret = 0; |
381 | u32 r; | 381 | u32 r; |
382 | u32 otpgp; | 382 | u32 otpgp; |
383 | 383 | ||
384 | iwl_write32(bus(priv), CSR_EEPROM_REG, | 384 | iwl_write32(bus, CSR_EEPROM_REG, |
385 | CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); | 385 | CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); |
386 | ret = iwl_poll_bit(bus(priv), CSR_EEPROM_REG, | 386 | ret = iwl_poll_bit(bus, CSR_EEPROM_REG, |
387 | CSR_EEPROM_REG_READ_VALID_MSK, | 387 | CSR_EEPROM_REG_READ_VALID_MSK, |
388 | CSR_EEPROM_REG_READ_VALID_MSK, | 388 | CSR_EEPROM_REG_READ_VALID_MSK, |
389 | IWL_EEPROM_ACCESS_TIMEOUT); | 389 | IWL_EEPROM_ACCESS_TIMEOUT); |
390 | if (ret < 0) { | 390 | if (ret < 0) { |
391 | IWL_ERR(priv, "Time out reading OTP[%d]\n", addr); | 391 | IWL_ERR(bus, "Time out reading OTP[%d]\n", addr); |
392 | return ret; | 392 | return ret; |
393 | } | 393 | } |
394 | r = iwl_read32(bus(priv), CSR_EEPROM_REG); | 394 | r = iwl_read32(bus, CSR_EEPROM_REG); |
395 | /* check for ECC errors: */ | 395 | /* check for ECC errors: */ |
396 | otpgp = iwl_read32(bus(priv), CSR_OTP_GP_REG); | 396 | otpgp = iwl_read32(bus, CSR_OTP_GP_REG); |
397 | if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { | 397 | if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { |
398 | /* stop in this case */ | 398 | /* stop in this case */ |
399 | /* set the uncorrectable OTP ECC bit for acknowledgement */ | 399 | /* set the uncorrectable OTP ECC bit for acknowledgement */ |
400 | iwl_set_bit(bus(priv), CSR_OTP_GP_REG, | 400 | iwl_set_bit(bus, CSR_OTP_GP_REG, |
401 | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); | 401 | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); |
402 | IWL_ERR(priv, "Uncorrectable OTP ECC error, abort OTP read\n"); | 402 | IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n"); |
403 | return -EINVAL; | 403 | return -EINVAL; |
404 | } | 404 | } |
405 | if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { | 405 | if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { |
406 | /* continue in this case */ | 406 | /* continue in this case */ |
407 | /* set the correctable OTP ECC bit for acknowledgement */ | 407 | /* set the correctable OTP ECC bit for acknowledgement */ |
408 | iwl_set_bit(bus(priv), CSR_OTP_GP_REG, | 408 | iwl_set_bit(bus, CSR_OTP_GP_REG, |
409 | CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); | 409 | CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); |
410 | IWL_ERR(priv, "Correctable OTP ECC error, continue read\n"); | 410 | IWL_ERR(bus, "Correctable OTP ECC error, continue read\n"); |
411 | } | 411 | } |
412 | *eeprom_data = cpu_to_le16(r >> 16); | 412 | *eeprom_data = cpu_to_le16(r >> 16); |
413 | return 0; | 413 | return 0; |
@@ -416,20 +416,20 @@ static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, __le16 *eeprom_dat | |||
416 | /* | 416 | /* |
417 | * iwl_is_otp_empty: check for empty OTP | 417 | * iwl_is_otp_empty: check for empty OTP |
418 | */ | 418 | */ |
419 | static bool iwl_is_otp_empty(struct iwl_priv *priv) | 419 | static bool iwl_is_otp_empty(struct iwl_bus *bus) |
420 | { | 420 | { |
421 | u16 next_link_addr = 0; | 421 | u16 next_link_addr = 0; |
422 | __le16 link_value; | 422 | __le16 link_value; |
423 | bool is_empty = false; | 423 | bool is_empty = false; |
424 | 424 | ||
425 | /* locate the beginning of OTP link list */ | 425 | /* locate the beginning of OTP link list */ |
426 | if (!iwl_read_otp_word(priv, next_link_addr, &link_value)) { | 426 | if (!iwl_read_otp_word(bus, next_link_addr, &link_value)) { |
427 | if (!link_value) { | 427 | if (!link_value) { |
428 | IWL_ERR(priv, "OTP is empty\n"); | 428 | IWL_ERR(bus, "OTP is empty\n"); |
429 | is_empty = true; | 429 | is_empty = true; |
430 | } | 430 | } |
431 | } else { | 431 | } else { |
432 | IWL_ERR(priv, "Unable to read first block of OTP list.\n"); | 432 | IWL_ERR(bus, "Unable to read first block of OTP list.\n"); |
433 | is_empty = true; | 433 | is_empty = true; |
434 | } | 434 | } |
435 | 435 | ||
@@ -446,7 +446,7 @@ static bool iwl_is_otp_empty(struct iwl_priv *priv) | |||
446 | * we should read and used to configure the device. | 446 | * we should read and used to configure the device. |
447 | * only perform this operation if shadow RAM is disabled | 447 | * only perform this operation if shadow RAM is disabled |
448 | */ | 448 | */ |
449 | static int iwl_find_otp_image(struct iwl_priv *priv, | 449 | static int iwl_find_otp_image(struct iwl_bus *bus, |
450 | u16 *validblockaddr) | 450 | u16 *validblockaddr) |
451 | { | 451 | { |
452 | u16 next_link_addr = 0, valid_addr; | 452 | u16 next_link_addr = 0, valid_addr; |
@@ -454,10 +454,10 @@ static int iwl_find_otp_image(struct iwl_priv *priv, | |||
454 | int usedblocks = 0; | 454 | int usedblocks = 0; |
455 | 455 | ||
456 | /* set addressing mode to absolute to traverse the link list */ | 456 | /* set addressing mode to absolute to traverse the link list */ |
457 | iwl_set_otp_access(priv, IWL_OTP_ACCESS_ABSOLUTE); | 457 | iwl_set_otp_access(bus, IWL_OTP_ACCESS_ABSOLUTE); |
458 | 458 | ||
459 | /* checking for empty OTP or error */ | 459 | /* checking for empty OTP or error */ |
460 | if (iwl_is_otp_empty(priv)) | 460 | if (iwl_is_otp_empty(bus)) |
461 | return -EINVAL; | 461 | return -EINVAL; |
462 | 462 | ||
463 | /* | 463 | /* |
@@ -471,9 +471,9 @@ static int iwl_find_otp_image(struct iwl_priv *priv, | |||
471 | */ | 471 | */ |
472 | valid_addr = next_link_addr; | 472 | valid_addr = next_link_addr; |
473 | next_link_addr = le16_to_cpu(link_value) * sizeof(u16); | 473 | next_link_addr = le16_to_cpu(link_value) * sizeof(u16); |
474 | IWL_DEBUG_EEPROM(priv, "OTP blocks %d addr 0x%x\n", | 474 | IWL_DEBUG_EEPROM(bus, "OTP blocks %d addr 0x%x\n", |
475 | usedblocks, next_link_addr); | 475 | usedblocks, next_link_addr); |
476 | if (iwl_read_otp_word(priv, next_link_addr, &link_value)) | 476 | if (iwl_read_otp_word(bus, next_link_addr, &link_value)) |
477 | return -EINVAL; | 477 | return -EINVAL; |
478 | if (!link_value) { | 478 | if (!link_value) { |
479 | /* | 479 | /* |
@@ -488,10 +488,10 @@ static int iwl_find_otp_image(struct iwl_priv *priv, | |||
488 | } | 488 | } |
489 | /* more in the link list, continue */ | 489 | /* more in the link list, continue */ |
490 | usedblocks++; | 490 | usedblocks++; |
491 | } while (usedblocks <= priv->cfg->base_params->max_ll_items); | 491 | } while (usedblocks <= priv(bus)->cfg->base_params->max_ll_items); |
492 | 492 | ||
493 | /* OTP has no valid blocks */ | 493 | /* OTP has no valid blocks */ |
494 | IWL_DEBUG_EEPROM(priv, "OTP has no valid blocks\n"); | 494 | IWL_DEBUG_EEPROM(bus, "OTP has no valid blocks\n"); |
495 | return -EINVAL; | 495 | return -EINVAL; |
496 | } | 496 | } |
497 | 497 | ||
@@ -504,28 +504,28 @@ static int iwl_find_otp_image(struct iwl_priv *priv, | |||
504 | * iwl_get_max_txpower_avg - get the highest tx power from all chains. | 504 | * iwl_get_max_txpower_avg - get the highest tx power from all chains. |
505 | * find the highest tx power from all chains for the channel | 505 | * find the highest tx power from all chains for the channel |
506 | */ | 506 | */ |
507 | static s8 iwl_get_max_txpower_avg(struct iwl_priv *priv, | 507 | static s8 iwl_get_max_txpower_avg(struct iwl_cfg *cfg, |
508 | struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, | 508 | struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, |
509 | int element, s8 *max_txpower_in_half_dbm) | 509 | int element, s8 *max_txpower_in_half_dbm) |
510 | { | 510 | { |
511 | s8 max_txpower_avg = 0; /* (dBm) */ | 511 | s8 max_txpower_avg = 0; /* (dBm) */ |
512 | 512 | ||
513 | /* Take the highest tx power from any valid chains */ | 513 | /* Take the highest tx power from any valid chains */ |
514 | if ((priv->cfg->valid_tx_ant & ANT_A) && | 514 | if ((cfg->valid_tx_ant & ANT_A) && |
515 | (enhanced_txpower[element].chain_a_max > max_txpower_avg)) | 515 | (enhanced_txpower[element].chain_a_max > max_txpower_avg)) |
516 | max_txpower_avg = enhanced_txpower[element].chain_a_max; | 516 | max_txpower_avg = enhanced_txpower[element].chain_a_max; |
517 | if ((priv->cfg->valid_tx_ant & ANT_B) && | 517 | if ((cfg->valid_tx_ant & ANT_B) && |
518 | (enhanced_txpower[element].chain_b_max > max_txpower_avg)) | 518 | (enhanced_txpower[element].chain_b_max > max_txpower_avg)) |
519 | max_txpower_avg = enhanced_txpower[element].chain_b_max; | 519 | max_txpower_avg = enhanced_txpower[element].chain_b_max; |
520 | if ((priv->cfg->valid_tx_ant & ANT_C) && | 520 | if ((cfg->valid_tx_ant & ANT_C) && |
521 | (enhanced_txpower[element].chain_c_max > max_txpower_avg)) | 521 | (enhanced_txpower[element].chain_c_max > max_txpower_avg)) |
522 | max_txpower_avg = enhanced_txpower[element].chain_c_max; | 522 | max_txpower_avg = enhanced_txpower[element].chain_c_max; |
523 | if (((priv->cfg->valid_tx_ant == ANT_AB) | | 523 | if (((cfg->valid_tx_ant == ANT_AB) | |
524 | (priv->cfg->valid_tx_ant == ANT_BC) | | 524 | (cfg->valid_tx_ant == ANT_BC) | |
525 | (priv->cfg->valid_tx_ant == ANT_AC)) && | 525 | (cfg->valid_tx_ant == ANT_AC)) && |
526 | (enhanced_txpower[element].mimo2_max > max_txpower_avg)) | 526 | (enhanced_txpower[element].mimo2_max > max_txpower_avg)) |
527 | max_txpower_avg = enhanced_txpower[element].mimo2_max; | 527 | max_txpower_avg = enhanced_txpower[element].mimo2_max; |
528 | if ((priv->cfg->valid_tx_ant == ANT_ABC) && | 528 | if ((cfg->valid_tx_ant == ANT_ABC) && |
529 | (enhanced_txpower[element].mimo3_max > max_txpower_avg)) | 529 | (enhanced_txpower[element].mimo3_max > max_txpower_avg)) |
530 | max_txpower_avg = enhanced_txpower[element].mimo3_max; | 530 | max_txpower_avg = enhanced_txpower[element].mimo3_max; |
531 | 531 | ||
@@ -627,7 +627,7 @@ void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) | |||
627 | ((txp->delta_20_in_40 & 0xf0) >> 4), | 627 | ((txp->delta_20_in_40 & 0xf0) >> 4), |
628 | (txp->delta_20_in_40 & 0x0f)); | 628 | (txp->delta_20_in_40 & 0x0f)); |
629 | 629 | ||
630 | max_txp_avg = iwl_get_max_txpower_avg(priv, txp_array, idx, | 630 | max_txp_avg = iwl_get_max_txpower_avg(priv->cfg, txp_array, idx, |
631 | &max_txp_avg_halfdbm); | 631 | &max_txp_avg_halfdbm); |
632 | 632 | ||
633 | /* | 633 | /* |
@@ -660,8 +660,8 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) | |||
660 | u16 validblockaddr = 0; | 660 | u16 validblockaddr = 0; |
661 | u16 cache_addr = 0; | 661 | u16 cache_addr = 0; |
662 | 662 | ||
663 | priv->nvm_device_type = iwl_get_nvm_type(priv, hw_rev); | 663 | trans(priv)->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev); |
664 | if (priv->nvm_device_type == -ENOENT) | 664 | if (trans(priv)->nvm_device_type == -ENOENT) |
665 | return -ENOENT; | 665 | return -ENOENT; |
666 | /* allocate eeprom */ | 666 | /* allocate eeprom */ |
667 | sz = priv->cfg->base_params->eeprom_size; | 667 | sz = priv->cfg->base_params->eeprom_size; |
@@ -675,7 +675,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) | |||
675 | 675 | ||
676 | iwl_apm_init(priv); | 676 | iwl_apm_init(priv); |
677 | 677 | ||
678 | ret = iwl_eeprom_verify_signature(priv); | 678 | ret = iwl_eeprom_verify_signature(trans(priv)); |
679 | if (ret < 0) { | 679 | if (ret < 0) { |
680 | IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); | 680 | IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); |
681 | ret = -ENOENT; | 681 | ret = -ENOENT; |
@@ -683,16 +683,16 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) | |||
683 | } | 683 | } |
684 | 684 | ||
685 | /* Make sure driver (instead of uCode) is allowed to read EEPROM */ | 685 | /* Make sure driver (instead of uCode) is allowed to read EEPROM */ |
686 | ret = iwl_eeprom_acquire_semaphore(priv); | 686 | ret = iwl_eeprom_acquire_semaphore(bus(priv)); |
687 | if (ret < 0) { | 687 | if (ret < 0) { |
688 | IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); | 688 | IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); |
689 | ret = -ENOENT; | 689 | ret = -ENOENT; |
690 | goto err; | 690 | goto err; |
691 | } | 691 | } |
692 | 692 | ||
693 | if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) { | 693 | if (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) { |
694 | 694 | ||
695 | ret = iwl_init_otp_access(priv); | 695 | ret = iwl_init_otp_access(bus(priv)); |
696 | if (ret) { | 696 | if (ret) { |
697 | IWL_ERR(priv, "Failed to initialize OTP access.\n"); | 697 | IWL_ERR(priv, "Failed to initialize OTP access.\n"); |
698 | ret = -ENOENT; | 698 | ret = -ENOENT; |
@@ -707,7 +707,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) | |||
707 | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); | 707 | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); |
708 | /* traversing the linked list if no shadow ram supported */ | 708 | /* traversing the linked list if no shadow ram supported */ |
709 | if (!priv->cfg->base_params->shadow_ram_support) { | 709 | if (!priv->cfg->base_params->shadow_ram_support) { |
710 | if (iwl_find_otp_image(priv, &validblockaddr)) { | 710 | if (iwl_find_otp_image(bus(priv), &validblockaddr)) { |
711 | ret = -ENOENT; | 711 | ret = -ENOENT; |
712 | goto done; | 712 | goto done; |
713 | } | 713 | } |
@@ -716,7 +716,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) | |||
716 | addr += sizeof(u16)) { | 716 | addr += sizeof(u16)) { |
717 | __le16 eeprom_data; | 717 | __le16 eeprom_data; |
718 | 718 | ||
719 | ret = iwl_read_otp_word(priv, addr, &eeprom_data); | 719 | ret = iwl_read_otp_word(bus(priv), addr, &eeprom_data); |
720 | if (ret) | 720 | if (ret) |
721 | goto done; | 721 | goto done; |
722 | e[cache_addr / 2] = eeprom_data; | 722 | e[cache_addr / 2] = eeprom_data; |
@@ -744,13 +744,13 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) | |||
744 | } | 744 | } |
745 | 745 | ||
746 | IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", | 746 | IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", |
747 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) | 747 | (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
748 | ? "OTP" : "EEPROM", | 748 | ? "OTP" : "EEPROM", |
749 | iwl_eeprom_query16(priv, EEPROM_VERSION)); | 749 | iwl_eeprom_query16(priv, EEPROM_VERSION)); |
750 | 750 | ||
751 | ret = 0; | 751 | ret = 0; |
752 | done: | 752 | done: |
753 | iwl_eeprom_release_semaphore(priv); | 753 | iwl_eeprom_release_semaphore(bus(priv)); |
754 | 754 | ||
755 | err: | 755 | err: |
756 | if (ret) | 756 | if (ret) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c new file mode 100644 index 000000000000..05b1f0d2f387 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c | |||
@@ -0,0 +1,1632 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. | ||
4 | * | ||
5 | * Portions of this file are derived from the ipw3945 project, as well | ||
6 | * as portions of the ieee80211 subsystem header files. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of version 2 of the GNU General Public License as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that 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 Street, Fifth Floor, Boston, MA 02110, USA | ||
20 | * | ||
21 | * The full GNU General Public License is included in this distribution in the | ||
22 | * file called LICENSE. | ||
23 | * | ||
24 | * Contact Information: | ||
25 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
27 | * | ||
28 | *****************************************************************************/ | ||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/module.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/slab.h> | ||
33 | #include <linux/dma-mapping.h> | ||
34 | #include <linux/delay.h> | ||
35 | #include <linux/sched.h> | ||
36 | #include <linux/skbuff.h> | ||
37 | #include <linux/netdevice.h> | ||
38 | #include <linux/firmware.h> | ||
39 | #include <linux/etherdevice.h> | ||
40 | #include <linux/if_arp.h> | ||
41 | |||
42 | #include <net/mac80211.h> | ||
43 | |||
44 | #include <asm/div64.h> | ||
45 | |||
46 | #include "iwl-eeprom.h" | ||
47 | #include "iwl-dev.h" | ||
48 | #include "iwl-core.h" | ||
49 | #include "iwl-io.h" | ||
50 | #include "iwl-agn-calib.h" | ||
51 | #include "iwl-agn.h" | ||
52 | #include "iwl-shared.h" | ||
53 | #include "iwl-bus.h" | ||
54 | #include "iwl-trans.h" | ||
55 | |||
56 | /***************************************************************************** | ||
57 | * | ||
58 | * mac80211 entry point functions | ||
59 | * | ||
60 | *****************************************************************************/ | ||
61 | |||
62 | static const struct ieee80211_iface_limit iwlagn_sta_ap_limits[] = { | ||
63 | { | ||
64 | .max = 1, | ||
65 | .types = BIT(NL80211_IFTYPE_STATION), | ||
66 | }, | ||
67 | { | ||
68 | .max = 1, | ||
69 | .types = BIT(NL80211_IFTYPE_AP), | ||
70 | }, | ||
71 | }; | ||
72 | |||
73 | static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = { | ||
74 | { | ||
75 | .max = 2, | ||
76 | .types = BIT(NL80211_IFTYPE_STATION), | ||
77 | }, | ||
78 | }; | ||
79 | |||
80 | static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = { | ||
81 | { | ||
82 | .max = 1, | ||
83 | .types = BIT(NL80211_IFTYPE_STATION), | ||
84 | }, | ||
85 | { | ||
86 | .max = 1, | ||
87 | .types = BIT(NL80211_IFTYPE_P2P_GO) | | ||
88 | BIT(NL80211_IFTYPE_AP), | ||
89 | }, | ||
90 | }; | ||
91 | |||
92 | static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = { | ||
93 | { | ||
94 | .max = 2, | ||
95 | .types = BIT(NL80211_IFTYPE_STATION), | ||
96 | }, | ||
97 | { | ||
98 | .max = 1, | ||
99 | .types = BIT(NL80211_IFTYPE_P2P_CLIENT), | ||
100 | }, | ||
101 | }; | ||
102 | |||
103 | static const struct ieee80211_iface_combination | ||
104 | iwlagn_iface_combinations_dualmode[] = { | ||
105 | { .num_different_channels = 1, | ||
106 | .max_interfaces = 2, | ||
107 | .beacon_int_infra_match = true, | ||
108 | .limits = iwlagn_sta_ap_limits, | ||
109 | .n_limits = ARRAY_SIZE(iwlagn_sta_ap_limits), | ||
110 | }, | ||
111 | { .num_different_channels = 1, | ||
112 | .max_interfaces = 2, | ||
113 | .limits = iwlagn_2sta_limits, | ||
114 | .n_limits = ARRAY_SIZE(iwlagn_2sta_limits), | ||
115 | }, | ||
116 | }; | ||
117 | |||
118 | static const struct ieee80211_iface_combination | ||
119 | iwlagn_iface_combinations_p2p[] = { | ||
120 | { .num_different_channels = 1, | ||
121 | .max_interfaces = 2, | ||
122 | .beacon_int_infra_match = true, | ||
123 | .limits = iwlagn_p2p_sta_go_limits, | ||
124 | .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits), | ||
125 | }, | ||
126 | { .num_different_channels = 1, | ||
127 | .max_interfaces = 2, | ||
128 | .limits = iwlagn_p2p_2sta_limits, | ||
129 | .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits), | ||
130 | }, | ||
131 | }; | ||
132 | |||
133 | /* | ||
134 | * Not a mac80211 entry point function, but it fits in with all the | ||
135 | * other mac80211 functions grouped here. | ||
136 | */ | ||
137 | int iwlagn_mac_setup_register(struct iwl_priv *priv, | ||
138 | struct iwlagn_ucode_capabilities *capa) | ||
139 | { | ||
140 | int ret; | ||
141 | struct ieee80211_hw *hw = priv->hw; | ||
142 | struct iwl_rxon_context *ctx; | ||
143 | |||
144 | hw->rate_control_algorithm = "iwl-agn-rs"; | ||
145 | |||
146 | /* Tell mac80211 our characteristics */ | ||
147 | hw->flags = IEEE80211_HW_SIGNAL_DBM | | ||
148 | IEEE80211_HW_AMPDU_AGGREGATION | | ||
149 | IEEE80211_HW_NEED_DTIM_PERIOD | | ||
150 | IEEE80211_HW_SPECTRUM_MGMT | | ||
151 | IEEE80211_HW_REPORTS_TX_ACK_STATUS; | ||
152 | |||
153 | /* | ||
154 | * Including the following line will crash some AP's. This | ||
155 | * workaround removes the stimulus which causes the crash until | ||
156 | * the AP software can be fixed. | ||
157 | hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; | ||
158 | */ | ||
159 | |||
160 | hw->flags |= IEEE80211_HW_SUPPORTS_PS | | ||
161 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS; | ||
162 | |||
163 | if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) | ||
164 | hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | ||
165 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; | ||
166 | |||
167 | if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) | ||
168 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; | ||
169 | |||
170 | hw->sta_data_size = sizeof(struct iwl_station_priv); | ||
171 | hw->vif_data_size = sizeof(struct iwl_vif_priv); | ||
172 | |||
173 | for_each_context(priv, ctx) { | ||
174 | hw->wiphy->interface_modes |= ctx->interface_modes; | ||
175 | hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; | ||
176 | } | ||
177 | |||
178 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); | ||
179 | |||
180 | if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) { | ||
181 | hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p; | ||
182 | hw->wiphy->n_iface_combinations = | ||
183 | ARRAY_SIZE(iwlagn_iface_combinations_p2p); | ||
184 | } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { | ||
185 | hw->wiphy->iface_combinations = | ||
186 | iwlagn_iface_combinations_dualmode; | ||
187 | hw->wiphy->n_iface_combinations = | ||
188 | ARRAY_SIZE(iwlagn_iface_combinations_dualmode); | ||
189 | } | ||
190 | |||
191 | hw->wiphy->max_remain_on_channel_duration = 1000; | ||
192 | |||
193 | hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | | ||
194 | WIPHY_FLAG_DISABLE_BEACON_HINTS | | ||
195 | WIPHY_FLAG_IBSS_RSN; | ||
196 | |||
197 | if (trans(priv)->ucode_wowlan.code.len && | ||
198 | device_can_wakeup(bus(priv)->dev)) { | ||
199 | hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | | ||
200 | WIPHY_WOWLAN_DISCONNECT | | ||
201 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | | ||
202 | WIPHY_WOWLAN_RFKILL_RELEASE; | ||
203 | if (!iwlagn_mod_params.sw_crypto) | ||
204 | hw->wiphy->wowlan.flags |= | ||
205 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | | ||
206 | WIPHY_WOWLAN_GTK_REKEY_FAILURE; | ||
207 | |||
208 | hw->wiphy->wowlan.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS; | ||
209 | hw->wiphy->wowlan.pattern_min_len = | ||
210 | IWLAGN_WOWLAN_MIN_PATTERN_LEN; | ||
211 | hw->wiphy->wowlan.pattern_max_len = | ||
212 | IWLAGN_WOWLAN_MAX_PATTERN_LEN; | ||
213 | } | ||
214 | |||
215 | if (iwlagn_mod_params.power_save) | ||
216 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; | ||
217 | else | ||
218 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; | ||
219 | |||
220 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; | ||
221 | /* we create the 802.11 header and a zero-length SSID element */ | ||
222 | hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; | ||
223 | |||
224 | /* Default value; 4 EDCA QOS priorities */ | ||
225 | hw->queues = 4; | ||
226 | |||
227 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; | ||
228 | |||
229 | if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) | ||
230 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | ||
231 | &priv->bands[IEEE80211_BAND_2GHZ]; | ||
232 | if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) | ||
233 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | ||
234 | &priv->bands[IEEE80211_BAND_5GHZ]; | ||
235 | |||
236 | iwl_leds_init(priv); | ||
237 | |||
238 | ret = ieee80211_register_hw(priv->hw); | ||
239 | if (ret) { | ||
240 | IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); | ||
241 | return ret; | ||
242 | } | ||
243 | priv->mac80211_registered = 1; | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static int __iwl_up(struct iwl_priv *priv) | ||
249 | { | ||
250 | struct iwl_rxon_context *ctx; | ||
251 | int ret; | ||
252 | |||
253 | lockdep_assert_held(&priv->shrd->mutex); | ||
254 | |||
255 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { | ||
256 | IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); | ||
257 | return -EIO; | ||
258 | } | ||
259 | |||
260 | for_each_context(priv, ctx) { | ||
261 | ret = iwlagn_alloc_bcast_station(priv, ctx); | ||
262 | if (ret) { | ||
263 | iwl_dealloc_bcast_stations(priv); | ||
264 | return ret; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | ret = iwlagn_run_init_ucode(priv); | ||
269 | if (ret) { | ||
270 | IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); | ||
271 | goto error; | ||
272 | } | ||
273 | |||
274 | ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); | ||
275 | if (ret) { | ||
276 | IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); | ||
277 | goto error; | ||
278 | } | ||
279 | |||
280 | ret = iwl_alive_start(priv); | ||
281 | if (ret) | ||
282 | goto error; | ||
283 | return 0; | ||
284 | |||
285 | error: | ||
286 | set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); | ||
287 | __iwl_down(priv); | ||
288 | clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); | ||
289 | |||
290 | IWL_ERR(priv, "Unable to initialize device.\n"); | ||
291 | return ret; | ||
292 | } | ||
293 | |||
294 | static int iwlagn_mac_start(struct ieee80211_hw *hw) | ||
295 | { | ||
296 | struct iwl_priv *priv = hw->priv; | ||
297 | int ret; | ||
298 | |||
299 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
300 | |||
301 | /* we should be verifying the device is ready to be opened */ | ||
302 | mutex_lock(&priv->shrd->mutex); | ||
303 | ret = __iwl_up(priv); | ||
304 | mutex_unlock(&priv->shrd->mutex); | ||
305 | if (ret) | ||
306 | return ret; | ||
307 | |||
308 | IWL_DEBUG_INFO(priv, "Start UP work done.\n"); | ||
309 | |||
310 | /* Now we should be done, and the READY bit should be set. */ | ||
311 | if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status))) | ||
312 | ret = -EIO; | ||
313 | |||
314 | iwlagn_led_enable(priv); | ||
315 | |||
316 | priv->is_open = 1; | ||
317 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | static void iwlagn_mac_stop(struct ieee80211_hw *hw) | ||
322 | { | ||
323 | struct iwl_priv *priv = hw->priv; | ||
324 | |||
325 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
326 | |||
327 | if (!priv->is_open) | ||
328 | return; | ||
329 | |||
330 | priv->is_open = 0; | ||
331 | |||
332 | iwl_down(priv); | ||
333 | |||
334 | flush_workqueue(priv->shrd->workqueue); | ||
335 | |||
336 | /* User space software may expect getting rfkill changes | ||
337 | * even if interface is down */ | ||
338 | iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF); | ||
339 | iwl_enable_rfkill_int(priv); | ||
340 | |||
341 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
342 | } | ||
343 | |||
344 | static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, | ||
345 | struct ieee80211_vif *vif, | ||
346 | struct cfg80211_gtk_rekey_data *data) | ||
347 | { | ||
348 | struct iwl_priv *priv = hw->priv; | ||
349 | |||
350 | if (iwlagn_mod_params.sw_crypto) | ||
351 | return; | ||
352 | |||
353 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
354 | mutex_lock(&priv->shrd->mutex); | ||
355 | |||
356 | if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif) | ||
357 | goto out; | ||
358 | |||
359 | memcpy(priv->kek, data->kek, NL80211_KEK_LEN); | ||
360 | memcpy(priv->kck, data->kck, NL80211_KCK_LEN); | ||
361 | priv->replay_ctr = | ||
362 | cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr)); | ||
363 | priv->have_rekey_data = true; | ||
364 | |||
365 | out: | ||
366 | mutex_unlock(&priv->shrd->mutex); | ||
367 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
368 | } | ||
369 | |||
370 | #ifdef CONFIG_PM_SLEEP | ||
371 | |||
372 | static int iwlagn_mac_suspend(struct ieee80211_hw *hw, | ||
373 | struct cfg80211_wowlan *wowlan) | ||
374 | { | ||
375 | struct iwl_priv *priv = hw->priv; | ||
376 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
377 | int ret; | ||
378 | |||
379 | if (WARN_ON(!wowlan)) | ||
380 | return -EINVAL; | ||
381 | |||
382 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
383 | mutex_lock(&priv->shrd->mutex); | ||
384 | |||
385 | /* Don't attempt WoWLAN when not associated, tear down instead. */ | ||
386 | if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION || | ||
387 | !iwl_is_associated_ctx(ctx)) { | ||
388 | ret = 1; | ||
389 | goto out; | ||
390 | } | ||
391 | |||
392 | ret = iwlagn_suspend(priv, hw, wowlan); | ||
393 | if (ret) | ||
394 | goto error; | ||
395 | |||
396 | device_set_wakeup_enable(bus(priv)->dev, true); | ||
397 | |||
398 | /* Now let the ucode operate on its own */ | ||
399 | iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, | ||
400 | CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); | ||
401 | |||
402 | goto out; | ||
403 | |||
404 | error: | ||
405 | priv->shrd->wowlan = false; | ||
406 | iwlagn_prepare_restart(priv); | ||
407 | ieee80211_restart_hw(priv->hw); | ||
408 | out: | ||
409 | mutex_unlock(&priv->shrd->mutex); | ||
410 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
411 | |||
412 | return ret; | ||
413 | } | ||
414 | |||
415 | static int iwlagn_mac_resume(struct ieee80211_hw *hw) | ||
416 | { | ||
417 | struct iwl_priv *priv = hw->priv; | ||
418 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
419 | struct ieee80211_vif *vif; | ||
420 | unsigned long flags; | ||
421 | u32 base, status = 0xffffffff; | ||
422 | int ret = -EIO; | ||
423 | |||
424 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
425 | mutex_lock(&priv->shrd->mutex); | ||
426 | |||
427 | iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, | ||
428 | CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); | ||
429 | |||
430 | base = priv->device_pointers.error_event_table; | ||
431 | if (iwlagn_hw_valid_rtc_data_addr(base)) { | ||
432 | spin_lock_irqsave(&bus(priv)->reg_lock, flags); | ||
433 | ret = iwl_grab_nic_access_silent(bus(priv)); | ||
434 | if (ret == 0) { | ||
435 | iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base); | ||
436 | status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); | ||
437 | iwl_release_nic_access(bus(priv)); | ||
438 | } | ||
439 | spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); | ||
440 | |||
441 | #ifdef CONFIG_IWLWIFI_DEBUGFS | ||
442 | if (ret == 0) { | ||
443 | struct iwl_trans *trans = trans(priv); | ||
444 | if (!priv->wowlan_sram) | ||
445 | priv->wowlan_sram = | ||
446 | kzalloc(trans->ucode_wowlan.data.len, | ||
447 | GFP_KERNEL); | ||
448 | |||
449 | if (priv->wowlan_sram) | ||
450 | _iwl_read_targ_mem_words( | ||
451 | bus(priv), 0x800000, priv->wowlan_sram, | ||
452 | trans->ucode_wowlan.data.len / 4); | ||
453 | } | ||
454 | #endif | ||
455 | } | ||
456 | |||
457 | /* we'll clear ctx->vif during iwlagn_prepare_restart() */ | ||
458 | vif = ctx->vif; | ||
459 | |||
460 | priv->shrd->wowlan = false; | ||
461 | |||
462 | device_set_wakeup_enable(bus(priv)->dev, false); | ||
463 | |||
464 | iwlagn_prepare_restart(priv); | ||
465 | |||
466 | memset((void *)&ctx->active, 0, sizeof(ctx->active)); | ||
467 | iwl_connection_init_rx_config(priv, ctx); | ||
468 | iwlagn_set_rxon_chain(priv, ctx); | ||
469 | |||
470 | mutex_unlock(&priv->shrd->mutex); | ||
471 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
472 | |||
473 | ieee80211_resume_disconnect(vif); | ||
474 | |||
475 | return 1; | ||
476 | } | ||
477 | |||
478 | #endif | ||
479 | |||
480 | static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | ||
481 | { | ||
482 | struct iwl_priv *priv = hw->priv; | ||
483 | |||
484 | IWL_DEBUG_MACDUMP(priv, "enter\n"); | ||
485 | |||
486 | IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | ||
487 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); | ||
488 | |||
489 | if (iwlagn_tx_skb(priv, skb)) | ||
490 | dev_kfree_skb_any(skb); | ||
491 | |||
492 | IWL_DEBUG_MACDUMP(priv, "leave\n"); | ||
493 | } | ||
494 | |||
495 | static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, | ||
496 | struct ieee80211_vif *vif, | ||
497 | struct ieee80211_key_conf *keyconf, | ||
498 | struct ieee80211_sta *sta, | ||
499 | u32 iv32, u16 *phase1key) | ||
500 | { | ||
501 | struct iwl_priv *priv = hw->priv; | ||
502 | |||
503 | iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key); | ||
504 | } | ||
505 | |||
506 | static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | ||
507 | struct ieee80211_vif *vif, | ||
508 | struct ieee80211_sta *sta, | ||
509 | struct ieee80211_key_conf *key) | ||
510 | { | ||
511 | struct iwl_priv *priv = hw->priv; | ||
512 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
513 | struct iwl_rxon_context *ctx = vif_priv->ctx; | ||
514 | int ret; | ||
515 | bool is_default_wep_key = false; | ||
516 | |||
517 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
518 | |||
519 | if (iwlagn_mod_params.sw_crypto) { | ||
520 | IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); | ||
521 | return -EOPNOTSUPP; | ||
522 | } | ||
523 | |||
524 | /* | ||
525 | * We could program these keys into the hardware as well, but we | ||
526 | * don't expect much multicast traffic in IBSS and having keys | ||
527 | * for more stations is probably more useful. | ||
528 | * | ||
529 | * Mark key TX-only and return 0. | ||
530 | */ | ||
531 | if (vif->type == NL80211_IFTYPE_ADHOC && | ||
532 | !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { | ||
533 | key->hw_key_idx = WEP_INVALID_OFFSET; | ||
534 | return 0; | ||
535 | } | ||
536 | |||
537 | /* If they key was TX-only, accept deletion */ | ||
538 | if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET) | ||
539 | return 0; | ||
540 | |||
541 | mutex_lock(&priv->shrd->mutex); | ||
542 | iwl_scan_cancel_timeout(priv, 100); | ||
543 | |||
544 | BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT); | ||
545 | |||
546 | /* | ||
547 | * If we are getting WEP group key and we didn't receive any key mapping | ||
548 | * so far, we are in legacy wep mode (group key only), otherwise we are | ||
549 | * in 1X mode. | ||
550 | * In legacy wep mode, we use another host command to the uCode. | ||
551 | */ | ||
552 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
553 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { | ||
554 | if (cmd == SET_KEY) | ||
555 | is_default_wep_key = !ctx->key_mapping_keys; | ||
556 | else | ||
557 | is_default_wep_key = | ||
558 | key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT; | ||
559 | } | ||
560 | |||
561 | |||
562 | switch (cmd) { | ||
563 | case SET_KEY: | ||
564 | if (is_default_wep_key) { | ||
565 | ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); | ||
566 | break; | ||
567 | } | ||
568 | ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta); | ||
569 | if (ret) { | ||
570 | /* | ||
571 | * can't add key for RX, but we don't need it | ||
572 | * in the device for TX so still return 0 | ||
573 | */ | ||
574 | ret = 0; | ||
575 | key->hw_key_idx = WEP_INVALID_OFFSET; | ||
576 | } | ||
577 | |||
578 | IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); | ||
579 | break; | ||
580 | case DISABLE_KEY: | ||
581 | if (is_default_wep_key) | ||
582 | ret = iwl_remove_default_wep_key(priv, ctx, key); | ||
583 | else | ||
584 | ret = iwl_remove_dynamic_key(priv, ctx, key, sta); | ||
585 | |||
586 | IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); | ||
587 | break; | ||
588 | default: | ||
589 | ret = -EINVAL; | ||
590 | } | ||
591 | |||
592 | mutex_unlock(&priv->shrd->mutex); | ||
593 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
594 | |||
595 | return ret; | ||
596 | } | ||
597 | |||
598 | static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, | ||
599 | struct ieee80211_vif *vif, | ||
600 | enum ieee80211_ampdu_mlme_action action, | ||
601 | struct ieee80211_sta *sta, u16 tid, u16 *ssn, | ||
602 | u8 buf_size) | ||
603 | { | ||
604 | struct iwl_priv *priv = hw->priv; | ||
605 | int ret = -EINVAL; | ||
606 | struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; | ||
607 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
608 | |||
609 | IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", | ||
610 | sta->addr, tid); | ||
611 | |||
612 | if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)) | ||
613 | return -EACCES; | ||
614 | |||
615 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
616 | mutex_lock(&priv->shrd->mutex); | ||
617 | |||
618 | switch (action) { | ||
619 | case IEEE80211_AMPDU_RX_START: | ||
620 | IWL_DEBUG_HT(priv, "start Rx\n"); | ||
621 | ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); | ||
622 | break; | ||
623 | case IEEE80211_AMPDU_RX_STOP: | ||
624 | IWL_DEBUG_HT(priv, "stop Rx\n"); | ||
625 | ret = iwl_sta_rx_agg_stop(priv, sta, tid); | ||
626 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) | ||
627 | ret = 0; | ||
628 | break; | ||
629 | case IEEE80211_AMPDU_TX_START: | ||
630 | IWL_DEBUG_HT(priv, "start Tx\n"); | ||
631 | ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); | ||
632 | break; | ||
633 | case IEEE80211_AMPDU_TX_STOP: | ||
634 | IWL_DEBUG_HT(priv, "stop Tx\n"); | ||
635 | ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); | ||
636 | if ((ret == 0) && (priv->agg_tids_count > 0)) { | ||
637 | priv->agg_tids_count--; | ||
638 | IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", | ||
639 | priv->agg_tids_count); | ||
640 | } | ||
641 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) | ||
642 | ret = 0; | ||
643 | if (!priv->agg_tids_count && priv->cfg->ht_params && | ||
644 | priv->cfg->ht_params->use_rts_for_aggregation) { | ||
645 | /* | ||
646 | * switch off RTS/CTS if it was previously enabled | ||
647 | */ | ||
648 | sta_priv->lq_sta.lq.general_params.flags &= | ||
649 | ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; | ||
650 | iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), | ||
651 | &sta_priv->lq_sta.lq, CMD_ASYNC, false); | ||
652 | } | ||
653 | break; | ||
654 | case IEEE80211_AMPDU_TX_OPERATIONAL: | ||
655 | buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); | ||
656 | |||
657 | iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, iwl_sta_id(sta), | ||
658 | tid, buf_size); | ||
659 | |||
660 | /* | ||
661 | * If the limit is 0, then it wasn't initialised yet, | ||
662 | * use the default. We can do that since we take the | ||
663 | * minimum below, and we don't want to go above our | ||
664 | * default due to hardware restrictions. | ||
665 | */ | ||
666 | if (sta_priv->max_agg_bufsize == 0) | ||
667 | sta_priv->max_agg_bufsize = | ||
668 | LINK_QUAL_AGG_FRAME_LIMIT_DEF; | ||
669 | |||
670 | /* | ||
671 | * Even though in theory the peer could have different | ||
672 | * aggregation reorder buffer sizes for different sessions, | ||
673 | * our ucode doesn't allow for that and has a global limit | ||
674 | * for each station. Therefore, use the minimum of all the | ||
675 | * aggregation sessions and our default value. | ||
676 | */ | ||
677 | sta_priv->max_agg_bufsize = | ||
678 | min(sta_priv->max_agg_bufsize, buf_size); | ||
679 | |||
680 | if (priv->cfg->ht_params && | ||
681 | priv->cfg->ht_params->use_rts_for_aggregation) { | ||
682 | /* | ||
683 | * switch to RTS/CTS if it is the prefer protection | ||
684 | * method for HT traffic | ||
685 | */ | ||
686 | |||
687 | sta_priv->lq_sta.lq.general_params.flags |= | ||
688 | LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; | ||
689 | } | ||
690 | priv->agg_tids_count++; | ||
691 | IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", | ||
692 | priv->agg_tids_count); | ||
693 | |||
694 | sta_priv->lq_sta.lq.agg_params.agg_frame_cnt_limit = | ||
695 | sta_priv->max_agg_bufsize; | ||
696 | |||
697 | iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), | ||
698 | &sta_priv->lq_sta.lq, CMD_ASYNC, false); | ||
699 | |||
700 | IWL_INFO(priv, "Tx aggregation enabled on ra = %pM tid = %d\n", | ||
701 | sta->addr, tid); | ||
702 | ret = 0; | ||
703 | break; | ||
704 | } | ||
705 | mutex_unlock(&priv->shrd->mutex); | ||
706 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
707 | return ret; | ||
708 | } | ||
709 | |||
710 | static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, | ||
711 | struct ieee80211_vif *vif, | ||
712 | struct ieee80211_sta *sta) | ||
713 | { | ||
714 | struct iwl_priv *priv = hw->priv; | ||
715 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | ||
716 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
717 | bool is_ap = vif->type == NL80211_IFTYPE_STATION; | ||
718 | int ret = 0; | ||
719 | u8 sta_id; | ||
720 | |||
721 | IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n", | ||
722 | sta->addr); | ||
723 | mutex_lock(&priv->shrd->mutex); | ||
724 | IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", | ||
725 | sta->addr); | ||
726 | sta_priv->sta_id = IWL_INVALID_STATION; | ||
727 | |||
728 | atomic_set(&sta_priv->pending_frames, 0); | ||
729 | if (vif->type == NL80211_IFTYPE_AP) | ||
730 | sta_priv->client = true; | ||
731 | |||
732 | ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr, | ||
733 | is_ap, sta, &sta_id); | ||
734 | if (ret) { | ||
735 | IWL_ERR(priv, "Unable to add station %pM (%d)\n", | ||
736 | sta->addr, ret); | ||
737 | /* Should we return success if return code is EEXIST ? */ | ||
738 | goto out; | ||
739 | } | ||
740 | |||
741 | sta_priv->sta_id = sta_id; | ||
742 | |||
743 | /* Initialize rate scaling */ | ||
744 | IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", | ||
745 | sta->addr); | ||
746 | iwl_rs_rate_init(priv, sta, sta_id); | ||
747 | out: | ||
748 | mutex_unlock(&priv->shrd->mutex); | ||
749 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
750 | |||
751 | return ret; | ||
752 | } | ||
753 | |||
754 | static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, | ||
755 | struct ieee80211_channel_switch *ch_switch) | ||
756 | { | ||
757 | struct iwl_priv *priv = hw->priv; | ||
758 | const struct iwl_channel_info *ch_info; | ||
759 | struct ieee80211_conf *conf = &hw->conf; | ||
760 | struct ieee80211_channel *channel = ch_switch->channel; | ||
761 | struct iwl_ht_config *ht_conf = &priv->current_ht_config; | ||
762 | /* | ||
763 | * MULTI-FIXME | ||
764 | * When we add support for multiple interfaces, we need to | ||
765 | * revisit this. The channel switch command in the device | ||
766 | * only affects the BSS context, but what does that really | ||
767 | * mean? And what if we get a CSA on the second interface? | ||
768 | * This needs a lot of work. | ||
769 | */ | ||
770 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
771 | u16 ch; | ||
772 | |||
773 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
774 | |||
775 | mutex_lock(&priv->shrd->mutex); | ||
776 | |||
777 | if (iwl_is_rfkill(priv->shrd)) | ||
778 | goto out; | ||
779 | |||
780 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || | ||
781 | test_bit(STATUS_SCANNING, &priv->shrd->status) || | ||
782 | test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) | ||
783 | goto out; | ||
784 | |||
785 | if (!iwl_is_associated_ctx(ctx)) | ||
786 | goto out; | ||
787 | |||
788 | if (!priv->cfg->lib->set_channel_switch) | ||
789 | goto out; | ||
790 | |||
791 | ch = channel->hw_value; | ||
792 | if (le16_to_cpu(ctx->active.channel) == ch) | ||
793 | goto out; | ||
794 | |||
795 | ch_info = iwl_get_channel_info(priv, channel->band, ch); | ||
796 | if (!is_channel_valid(ch_info)) { | ||
797 | IWL_DEBUG_MAC80211(priv, "invalid channel\n"); | ||
798 | goto out; | ||
799 | } | ||
800 | |||
801 | spin_lock_irq(&priv->shrd->lock); | ||
802 | |||
803 | priv->current_ht_config.smps = conf->smps_mode; | ||
804 | |||
805 | /* Configure HT40 channels */ | ||
806 | ctx->ht.enabled = conf_is_ht(conf); | ||
807 | if (ctx->ht.enabled) { | ||
808 | if (conf_is_ht40_minus(conf)) { | ||
809 | ctx->ht.extension_chan_offset = | ||
810 | IEEE80211_HT_PARAM_CHA_SEC_BELOW; | ||
811 | ctx->ht.is_40mhz = true; | ||
812 | } else if (conf_is_ht40_plus(conf)) { | ||
813 | ctx->ht.extension_chan_offset = | ||
814 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE; | ||
815 | ctx->ht.is_40mhz = true; | ||
816 | } else { | ||
817 | ctx->ht.extension_chan_offset = | ||
818 | IEEE80211_HT_PARAM_CHA_SEC_NONE; | ||
819 | ctx->ht.is_40mhz = false; | ||
820 | } | ||
821 | } else | ||
822 | ctx->ht.is_40mhz = false; | ||
823 | |||
824 | if ((le16_to_cpu(ctx->staging.channel) != ch)) | ||
825 | ctx->staging.flags = 0; | ||
826 | |||
827 | iwl_set_rxon_channel(priv, channel, ctx); | ||
828 | iwl_set_rxon_ht(priv, ht_conf); | ||
829 | iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); | ||
830 | |||
831 | spin_unlock_irq(&priv->shrd->lock); | ||
832 | |||
833 | iwl_set_rate(priv); | ||
834 | /* | ||
835 | * at this point, staging_rxon has the | ||
836 | * configuration for channel switch | ||
837 | */ | ||
838 | set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); | ||
839 | priv->switch_channel = cpu_to_le16(ch); | ||
840 | if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) { | ||
841 | clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); | ||
842 | priv->switch_channel = 0; | ||
843 | ieee80211_chswitch_done(ctx->vif, false); | ||
844 | } | ||
845 | |||
846 | out: | ||
847 | mutex_unlock(&priv->shrd->mutex); | ||
848 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
849 | } | ||
850 | |||
851 | static void iwlagn_configure_filter(struct ieee80211_hw *hw, | ||
852 | unsigned int changed_flags, | ||
853 | unsigned int *total_flags, | ||
854 | u64 multicast) | ||
855 | { | ||
856 | struct iwl_priv *priv = hw->priv; | ||
857 | __le32 filter_or = 0, filter_nand = 0; | ||
858 | struct iwl_rxon_context *ctx; | ||
859 | |||
860 | #define CHK(test, flag) do { \ | ||
861 | if (*total_flags & (test)) \ | ||
862 | filter_or |= (flag); \ | ||
863 | else \ | ||
864 | filter_nand |= (flag); \ | ||
865 | } while (0) | ||
866 | |||
867 | IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", | ||
868 | changed_flags, *total_flags); | ||
869 | |||
870 | CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); | ||
871 | /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ | ||
872 | CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); | ||
873 | CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); | ||
874 | |||
875 | #undef CHK | ||
876 | |||
877 | mutex_lock(&priv->shrd->mutex); | ||
878 | |||
879 | for_each_context(priv, ctx) { | ||
880 | ctx->staging.filter_flags &= ~filter_nand; | ||
881 | ctx->staging.filter_flags |= filter_or; | ||
882 | |||
883 | /* | ||
884 | * Not committing directly because hardware can perform a scan, | ||
885 | * but we'll eventually commit the filter flags change anyway. | ||
886 | */ | ||
887 | } | ||
888 | |||
889 | mutex_unlock(&priv->shrd->mutex); | ||
890 | |||
891 | /* | ||
892 | * Receiving all multicast frames is always enabled by the | ||
893 | * default flags setup in iwl_connection_init_rx_config() | ||
894 | * since we currently do not support programming multicast | ||
895 | * filters into the device. | ||
896 | */ | ||
897 | *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | | ||
898 | FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; | ||
899 | } | ||
900 | |||
901 | static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) | ||
902 | { | ||
903 | struct iwl_priv *priv = hw->priv; | ||
904 | |||
905 | mutex_lock(&priv->shrd->mutex); | ||
906 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
907 | |||
908 | if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { | ||
909 | IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); | ||
910 | goto done; | ||
911 | } | ||
912 | if (iwl_is_rfkill(priv->shrd)) { | ||
913 | IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); | ||
914 | goto done; | ||
915 | } | ||
916 | |||
917 | /* | ||
918 | * mac80211 will not push any more frames for transmit | ||
919 | * until the flush is completed | ||
920 | */ | ||
921 | if (drop) { | ||
922 | IWL_DEBUG_MAC80211(priv, "send flush command\n"); | ||
923 | if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { | ||
924 | IWL_ERR(priv, "flush request fail\n"); | ||
925 | goto done; | ||
926 | } | ||
927 | } | ||
928 | IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); | ||
929 | iwl_trans_wait_tx_queue_empty(trans(priv)); | ||
930 | done: | ||
931 | mutex_unlock(&priv->shrd->mutex); | ||
932 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
933 | } | ||
934 | |||
935 | static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, | ||
936 | struct ieee80211_channel *channel, | ||
937 | enum nl80211_channel_type channel_type, | ||
938 | int duration) | ||
939 | { | ||
940 | struct iwl_priv *priv = hw->priv; | ||
941 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; | ||
942 | int err = 0; | ||
943 | |||
944 | if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) | ||
945 | return -EOPNOTSUPP; | ||
946 | |||
947 | if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT))) | ||
948 | return -EOPNOTSUPP; | ||
949 | |||
950 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
951 | mutex_lock(&priv->shrd->mutex); | ||
952 | |||
953 | if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { | ||
954 | err = -EBUSY; | ||
955 | goto out; | ||
956 | } | ||
957 | |||
958 | priv->hw_roc_channel = channel; | ||
959 | priv->hw_roc_chantype = channel_type; | ||
960 | /* convert from ms to TU */ | ||
961 | priv->hw_roc_duration = DIV_ROUND_UP(1000 * duration, 1024); | ||
962 | priv->hw_roc_start_notified = false; | ||
963 | cancel_delayed_work(&priv->hw_roc_disable_work); | ||
964 | |||
965 | if (!ctx->is_active) { | ||
966 | static const struct iwl_qos_info default_qos_data = { | ||
967 | .def_qos_parm = { | ||
968 | .ac[0] = { | ||
969 | .cw_min = cpu_to_le16(3), | ||
970 | .cw_max = cpu_to_le16(7), | ||
971 | .aifsn = 2, | ||
972 | .edca_txop = cpu_to_le16(1504), | ||
973 | }, | ||
974 | .ac[1] = { | ||
975 | .cw_min = cpu_to_le16(7), | ||
976 | .cw_max = cpu_to_le16(15), | ||
977 | .aifsn = 2, | ||
978 | .edca_txop = cpu_to_le16(3008), | ||
979 | }, | ||
980 | .ac[2] = { | ||
981 | .cw_min = cpu_to_le16(15), | ||
982 | .cw_max = cpu_to_le16(1023), | ||
983 | .aifsn = 3, | ||
984 | }, | ||
985 | .ac[3] = { | ||
986 | .cw_min = cpu_to_le16(15), | ||
987 | .cw_max = cpu_to_le16(1023), | ||
988 | .aifsn = 7, | ||
989 | }, | ||
990 | }, | ||
991 | }; | ||
992 | |||
993 | ctx->is_active = true; | ||
994 | ctx->qos_data = default_qos_data; | ||
995 | ctx->staging.dev_type = RXON_DEV_TYPE_P2P; | ||
996 | memcpy(ctx->staging.node_addr, | ||
997 | priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, | ||
998 | ETH_ALEN); | ||
999 | memcpy(ctx->staging.bssid_addr, | ||
1000 | priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, | ||
1001 | ETH_ALEN); | ||
1002 | err = iwlagn_commit_rxon(priv, ctx); | ||
1003 | if (err) | ||
1004 | goto out; | ||
1005 | ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK | | ||
1006 | RXON_FILTER_PROMISC_MSK | | ||
1007 | RXON_FILTER_CTL2HOST_MSK; | ||
1008 | |||
1009 | err = iwlagn_commit_rxon(priv, ctx); | ||
1010 | if (err) { | ||
1011 | iwlagn_disable_roc(priv); | ||
1012 | goto out; | ||
1013 | } | ||
1014 | priv->hw_roc_setup = true; | ||
1015 | } | ||
1016 | |||
1017 | err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band); | ||
1018 | if (err) | ||
1019 | iwlagn_disable_roc(priv); | ||
1020 | |||
1021 | out: | ||
1022 | mutex_unlock(&priv->shrd->mutex); | ||
1023 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1024 | |||
1025 | return err; | ||
1026 | } | ||
1027 | |||
1028 | static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) | ||
1029 | { | ||
1030 | struct iwl_priv *priv = hw->priv; | ||
1031 | |||
1032 | if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) | ||
1033 | return -EOPNOTSUPP; | ||
1034 | |||
1035 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1036 | mutex_lock(&priv->shrd->mutex); | ||
1037 | iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); | ||
1038 | iwlagn_disable_roc(priv); | ||
1039 | mutex_unlock(&priv->shrd->mutex); | ||
1040 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1041 | |||
1042 | return 0; | ||
1043 | } | ||
1044 | |||
1045 | static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, | ||
1046 | struct ieee80211_vif *vif, | ||
1047 | const u8 *bssid, | ||
1048 | enum ieee80211_tx_sync_type type) | ||
1049 | { | ||
1050 | struct iwl_priv *priv = hw->priv; | ||
1051 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
1052 | struct iwl_rxon_context *ctx = vif_priv->ctx; | ||
1053 | int ret; | ||
1054 | u8 sta_id; | ||
1055 | |||
1056 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1057 | mutex_lock(&priv->shrd->mutex); | ||
1058 | |||
1059 | if (iwl_is_associated_ctx(ctx)) { | ||
1060 | ret = 0; | ||
1061 | goto out; | ||
1062 | } | ||
1063 | |||
1064 | if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, | ||
1065 | &priv->shrd->status)) { | ||
1066 | ret = -EBUSY; | ||
1067 | goto out; | ||
1068 | } | ||
1069 | |||
1070 | ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id); | ||
1071 | if (ret) | ||
1072 | goto out; | ||
1073 | |||
1074 | if (WARN_ON(sta_id != ctx->ap_sta_id)) { | ||
1075 | ret = -EIO; | ||
1076 | goto out_remove_sta; | ||
1077 | } | ||
1078 | |||
1079 | memcpy(ctx->bssid, bssid, ETH_ALEN); | ||
1080 | ctx->preauth_bssid = true; | ||
1081 | |||
1082 | ret = iwlagn_commit_rxon(priv, ctx); | ||
1083 | |||
1084 | if (ret == 0) | ||
1085 | goto out; | ||
1086 | |||
1087 | out_remove_sta: | ||
1088 | iwl_remove_station(priv, sta_id, bssid); | ||
1089 | out: | ||
1090 | mutex_unlock(&priv->shrd->mutex); | ||
1091 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1092 | |||
1093 | return ret; | ||
1094 | } | ||
1095 | |||
1096 | static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, | ||
1097 | struct ieee80211_vif *vif, | ||
1098 | const u8 *bssid, | ||
1099 | enum ieee80211_tx_sync_type type) | ||
1100 | { | ||
1101 | struct iwl_priv *priv = hw->priv; | ||
1102 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
1103 | struct iwl_rxon_context *ctx = vif_priv->ctx; | ||
1104 | |||
1105 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1106 | mutex_lock(&priv->shrd->mutex); | ||
1107 | |||
1108 | if (iwl_is_associated_ctx(ctx)) | ||
1109 | goto out; | ||
1110 | |||
1111 | iwl_remove_station(priv, ctx->ap_sta_id, bssid); | ||
1112 | ctx->preauth_bssid = false; | ||
1113 | /* no need to commit */ | ||
1114 | out: | ||
1115 | mutex_unlock(&priv->shrd->mutex); | ||
1116 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1117 | } | ||
1118 | |||
1119 | static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, | ||
1120 | enum ieee80211_rssi_event rssi_event) | ||
1121 | { | ||
1122 | struct iwl_priv *priv = hw->priv; | ||
1123 | |||
1124 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1125 | mutex_lock(&priv->shrd->mutex); | ||
1126 | |||
1127 | if (priv->cfg->bt_params && | ||
1128 | priv->cfg->bt_params->advanced_bt_coexist) { | ||
1129 | if (rssi_event == RSSI_EVENT_LOW) | ||
1130 | priv->bt_enable_pspoll = true; | ||
1131 | else if (rssi_event == RSSI_EVENT_HIGH) | ||
1132 | priv->bt_enable_pspoll = false; | ||
1133 | |||
1134 | iwlagn_send_advance_bt_config(priv); | ||
1135 | } else { | ||
1136 | IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled," | ||
1137 | "ignoring RSSI callback\n"); | ||
1138 | } | ||
1139 | |||
1140 | mutex_unlock(&priv->shrd->mutex); | ||
1141 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1142 | } | ||
1143 | |||
1144 | static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, | ||
1145 | struct ieee80211_sta *sta, bool set) | ||
1146 | { | ||
1147 | struct iwl_priv *priv = hw->priv; | ||
1148 | |||
1149 | queue_work(priv->shrd->workqueue, &priv->beacon_update); | ||
1150 | |||
1151 | return 0; | ||
1152 | } | ||
1153 | |||
1154 | static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, | ||
1155 | struct ieee80211_vif *vif, u16 queue, | ||
1156 | const struct ieee80211_tx_queue_params *params) | ||
1157 | { | ||
1158 | struct iwl_priv *priv = hw->priv; | ||
1159 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
1160 | struct iwl_rxon_context *ctx = vif_priv->ctx; | ||
1161 | unsigned long flags; | ||
1162 | int q; | ||
1163 | |||
1164 | if (WARN_ON(!ctx)) | ||
1165 | return -EINVAL; | ||
1166 | |||
1167 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1168 | |||
1169 | if (!iwl_is_ready_rf(priv->shrd)) { | ||
1170 | IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); | ||
1171 | return -EIO; | ||
1172 | } | ||
1173 | |||
1174 | if (queue >= AC_NUM) { | ||
1175 | IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); | ||
1176 | return 0; | ||
1177 | } | ||
1178 | |||
1179 | q = AC_NUM - 1 - queue; | ||
1180 | |||
1181 | spin_lock_irqsave(&priv->shrd->lock, flags); | ||
1182 | |||
1183 | ctx->qos_data.def_qos_parm.ac[q].cw_min = | ||
1184 | cpu_to_le16(params->cw_min); | ||
1185 | ctx->qos_data.def_qos_parm.ac[q].cw_max = | ||
1186 | cpu_to_le16(params->cw_max); | ||
1187 | ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; | ||
1188 | ctx->qos_data.def_qos_parm.ac[q].edca_txop = | ||
1189 | cpu_to_le16((params->txop * 32)); | ||
1190 | |||
1191 | ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; | ||
1192 | |||
1193 | spin_unlock_irqrestore(&priv->shrd->lock, flags); | ||
1194 | |||
1195 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1196 | return 0; | ||
1197 | } | ||
1198 | |||
1199 | static int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) | ||
1200 | { | ||
1201 | struct iwl_priv *priv = hw->priv; | ||
1202 | |||
1203 | return priv->ibss_manager == IWL_IBSS_MANAGER; | ||
1204 | } | ||
1205 | |||
1206 | static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | ||
1207 | { | ||
1208 | iwl_connection_init_rx_config(priv, ctx); | ||
1209 | |||
1210 | iwlagn_set_rxon_chain(priv, ctx); | ||
1211 | |||
1212 | return iwlagn_commit_rxon(priv, ctx); | ||
1213 | } | ||
1214 | |||
1215 | static int iwl_setup_interface(struct iwl_priv *priv, | ||
1216 | struct iwl_rxon_context *ctx) | ||
1217 | { | ||
1218 | struct ieee80211_vif *vif = ctx->vif; | ||
1219 | int err; | ||
1220 | |||
1221 | lockdep_assert_held(&priv->shrd->mutex); | ||
1222 | |||
1223 | /* | ||
1224 | * This variable will be correct only when there's just | ||
1225 | * a single context, but all code using it is for hardware | ||
1226 | * that supports only one context. | ||
1227 | */ | ||
1228 | priv->iw_mode = vif->type; | ||
1229 | |||
1230 | ctx->is_active = true; | ||
1231 | |||
1232 | err = iwl_set_mode(priv, ctx); | ||
1233 | if (err) { | ||
1234 | if (!ctx->always_active) | ||
1235 | ctx->is_active = false; | ||
1236 | return err; | ||
1237 | } | ||
1238 | |||
1239 | if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist && | ||
1240 | vif->type == NL80211_IFTYPE_ADHOC) { | ||
1241 | /* | ||
1242 | * pretend to have high BT traffic as long as we | ||
1243 | * are operating in IBSS mode, as this will cause | ||
1244 | * the rate scaling etc. to behave as intended. | ||
1245 | */ | ||
1246 | priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; | ||
1247 | } | ||
1248 | |||
1249 | return 0; | ||
1250 | } | ||
1251 | |||
1252 | static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, | ||
1253 | struct ieee80211_vif *vif) | ||
1254 | { | ||
1255 | struct iwl_priv *priv = hw->priv; | ||
1256 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; | ||
1257 | struct iwl_rxon_context *tmp, *ctx = NULL; | ||
1258 | int err; | ||
1259 | enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif); | ||
1260 | |||
1261 | IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", | ||
1262 | viftype, vif->addr); | ||
1263 | |||
1264 | cancel_delayed_work_sync(&priv->hw_roc_disable_work); | ||
1265 | |||
1266 | mutex_lock(&priv->shrd->mutex); | ||
1267 | |||
1268 | iwlagn_disable_roc(priv); | ||
1269 | |||
1270 | if (!iwl_is_ready_rf(priv->shrd)) { | ||
1271 | IWL_WARN(priv, "Try to add interface when device not ready\n"); | ||
1272 | err = -EINVAL; | ||
1273 | goto out; | ||
1274 | } | ||
1275 | |||
1276 | for_each_context(priv, tmp) { | ||
1277 | u32 possible_modes = | ||
1278 | tmp->interface_modes | tmp->exclusive_interface_modes; | ||
1279 | |||
1280 | if (tmp->vif) { | ||
1281 | /* check if this busy context is exclusive */ | ||
1282 | if (tmp->exclusive_interface_modes & | ||
1283 | BIT(tmp->vif->type)) { | ||
1284 | err = -EINVAL; | ||
1285 | goto out; | ||
1286 | } | ||
1287 | continue; | ||
1288 | } | ||
1289 | |||
1290 | if (!(possible_modes & BIT(viftype))) | ||
1291 | continue; | ||
1292 | |||
1293 | /* have maybe usable context w/o interface */ | ||
1294 | ctx = tmp; | ||
1295 | break; | ||
1296 | } | ||
1297 | |||
1298 | if (!ctx) { | ||
1299 | err = -EOPNOTSUPP; | ||
1300 | goto out; | ||
1301 | } | ||
1302 | |||
1303 | vif_priv->ctx = ctx; | ||
1304 | ctx->vif = vif; | ||
1305 | |||
1306 | err = iwl_setup_interface(priv, ctx); | ||
1307 | if (!err) | ||
1308 | goto out; | ||
1309 | |||
1310 | ctx->vif = NULL; | ||
1311 | priv->iw_mode = NL80211_IFTYPE_STATION; | ||
1312 | out: | ||
1313 | mutex_unlock(&priv->shrd->mutex); | ||
1314 | |||
1315 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1316 | return err; | ||
1317 | } | ||
1318 | |||
1319 | static void iwl_teardown_interface(struct iwl_priv *priv, | ||
1320 | struct ieee80211_vif *vif, | ||
1321 | bool mode_change) | ||
1322 | { | ||
1323 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
1324 | |||
1325 | lockdep_assert_held(&priv->shrd->mutex); | ||
1326 | |||
1327 | if (priv->scan_vif == vif) { | ||
1328 | iwl_scan_cancel_timeout(priv, 200); | ||
1329 | iwl_force_scan_end(priv); | ||
1330 | } | ||
1331 | |||
1332 | if (!mode_change) { | ||
1333 | iwl_set_mode(priv, ctx); | ||
1334 | if (!ctx->always_active) | ||
1335 | ctx->is_active = false; | ||
1336 | } | ||
1337 | |||
1338 | /* | ||
1339 | * When removing the IBSS interface, overwrite the | ||
1340 | * BT traffic load with the stored one from the last | ||
1341 | * notification, if any. If this is a device that | ||
1342 | * doesn't implement this, this has no effect since | ||
1343 | * both values are the same and zero. | ||
1344 | */ | ||
1345 | if (vif->type == NL80211_IFTYPE_ADHOC) | ||
1346 | priv->bt_traffic_load = priv->last_bt_traffic_load; | ||
1347 | } | ||
1348 | |||
1349 | static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, | ||
1350 | struct ieee80211_vif *vif) | ||
1351 | { | ||
1352 | struct iwl_priv *priv = hw->priv; | ||
1353 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
1354 | |||
1355 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1356 | |||
1357 | mutex_lock(&priv->shrd->mutex); | ||
1358 | |||
1359 | if (WARN_ON(ctx->vif != vif)) { | ||
1360 | struct iwl_rxon_context *tmp; | ||
1361 | IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif); | ||
1362 | for_each_context(priv, tmp) | ||
1363 | IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n", | ||
1364 | tmp->ctxid, tmp, tmp->vif); | ||
1365 | } | ||
1366 | ctx->vif = NULL; | ||
1367 | |||
1368 | iwl_teardown_interface(priv, vif, false); | ||
1369 | |||
1370 | mutex_unlock(&priv->shrd->mutex); | ||
1371 | |||
1372 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1373 | |||
1374 | } | ||
1375 | |||
1376 | static int iwlagn_mac_change_interface(struct ieee80211_hw *hw, | ||
1377 | struct ieee80211_vif *vif, | ||
1378 | enum nl80211_iftype newtype, bool newp2p) | ||
1379 | { | ||
1380 | struct iwl_priv *priv = hw->priv; | ||
1381 | struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); | ||
1382 | struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; | ||
1383 | struct iwl_rxon_context *tmp; | ||
1384 | enum nl80211_iftype newviftype = newtype; | ||
1385 | u32 interface_modes; | ||
1386 | int err; | ||
1387 | |||
1388 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1389 | |||
1390 | newtype = ieee80211_iftype_p2p(newtype, newp2p); | ||
1391 | |||
1392 | mutex_lock(&priv->shrd->mutex); | ||
1393 | |||
1394 | if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { | ||
1395 | /* | ||
1396 | * Huh? But wait ... this can maybe happen when | ||
1397 | * we're in the middle of a firmware restart! | ||
1398 | */ | ||
1399 | err = -EBUSY; | ||
1400 | goto out; | ||
1401 | } | ||
1402 | |||
1403 | interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; | ||
1404 | |||
1405 | if (!(interface_modes & BIT(newtype))) { | ||
1406 | err = -EBUSY; | ||
1407 | goto out; | ||
1408 | } | ||
1409 | |||
1410 | /* | ||
1411 | * Refuse a change that should be done by moving from the PAN | ||
1412 | * context to the BSS context instead, if the BSS context is | ||
1413 | * available and can support the new interface type. | ||
1414 | */ | ||
1415 | if (ctx->ctxid == IWL_RXON_CTX_PAN && !bss_ctx->vif && | ||
1416 | (bss_ctx->interface_modes & BIT(newtype) || | ||
1417 | bss_ctx->exclusive_interface_modes & BIT(newtype))) { | ||
1418 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); | ||
1419 | err = -EBUSY; | ||
1420 | goto out; | ||
1421 | } | ||
1422 | |||
1423 | if (ctx->exclusive_interface_modes & BIT(newtype)) { | ||
1424 | for_each_context(priv, tmp) { | ||
1425 | if (ctx == tmp) | ||
1426 | continue; | ||
1427 | |||
1428 | if (!tmp->vif) | ||
1429 | continue; | ||
1430 | |||
1431 | /* | ||
1432 | * The current mode switch would be exclusive, but | ||
1433 | * another context is active ... refuse the switch. | ||
1434 | */ | ||
1435 | err = -EBUSY; | ||
1436 | goto out; | ||
1437 | } | ||
1438 | } | ||
1439 | |||
1440 | /* success */ | ||
1441 | iwl_teardown_interface(priv, vif, true); | ||
1442 | vif->type = newviftype; | ||
1443 | vif->p2p = newp2p; | ||
1444 | err = iwl_setup_interface(priv, ctx); | ||
1445 | WARN_ON(err); | ||
1446 | /* | ||
1447 | * We've switched internally, but submitting to the | ||
1448 | * device may have failed for some reason. Mask this | ||
1449 | * error, because otherwise mac80211 will not switch | ||
1450 | * (and set the interface type back) and we'll be | ||
1451 | * out of sync with it. | ||
1452 | */ | ||
1453 | err = 0; | ||
1454 | |||
1455 | out: | ||
1456 | mutex_unlock(&priv->shrd->mutex); | ||
1457 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1458 | |||
1459 | return err; | ||
1460 | } | ||
1461 | |||
1462 | static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, | ||
1463 | struct ieee80211_vif *vif, | ||
1464 | struct cfg80211_scan_request *req) | ||
1465 | { | ||
1466 | struct iwl_priv *priv = hw->priv; | ||
1467 | int ret; | ||
1468 | |||
1469 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1470 | |||
1471 | if (req->n_channels == 0) | ||
1472 | return -EINVAL; | ||
1473 | |||
1474 | mutex_lock(&priv->shrd->mutex); | ||
1475 | |||
1476 | /* | ||
1477 | * If an internal scan is in progress, just set | ||
1478 | * up the scan_request as per above. | ||
1479 | */ | ||
1480 | if (priv->scan_type != IWL_SCAN_NORMAL) { | ||
1481 | IWL_DEBUG_SCAN(priv, | ||
1482 | "SCAN request during internal scan - defer\n"); | ||
1483 | priv->scan_request = req; | ||
1484 | priv->scan_vif = vif; | ||
1485 | ret = 0; | ||
1486 | } else { | ||
1487 | priv->scan_request = req; | ||
1488 | priv->scan_vif = vif; | ||
1489 | /* | ||
1490 | * mac80211 will only ask for one band at a time | ||
1491 | * so using channels[0] here is ok | ||
1492 | */ | ||
1493 | ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL, | ||
1494 | req->channels[0]->band); | ||
1495 | if (ret) { | ||
1496 | priv->scan_request = NULL; | ||
1497 | priv->scan_vif = NULL; | ||
1498 | } | ||
1499 | } | ||
1500 | |||
1501 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1502 | |||
1503 | mutex_unlock(&priv->shrd->mutex); | ||
1504 | |||
1505 | return ret; | ||
1506 | } | ||
1507 | |||
1508 | static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, | ||
1509 | struct ieee80211_vif *vif, | ||
1510 | struct ieee80211_sta *sta) | ||
1511 | { | ||
1512 | struct iwl_priv *priv = hw->priv; | ||
1513 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | ||
1514 | int ret; | ||
1515 | |||
1516 | IWL_DEBUG_MAC80211(priv, "enter: received request to remove " | ||
1517 | "station %pM\n", sta->addr); | ||
1518 | mutex_lock(&priv->shrd->mutex); | ||
1519 | IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", | ||
1520 | sta->addr); | ||
1521 | ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); | ||
1522 | if (ret) | ||
1523 | IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", | ||
1524 | sta->addr); | ||
1525 | mutex_unlock(&priv->shrd->mutex); | ||
1526 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1527 | |||
1528 | return ret; | ||
1529 | } | ||
1530 | |||
1531 | static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) | ||
1532 | { | ||
1533 | unsigned long flags; | ||
1534 | |||
1535 | spin_lock_irqsave(&priv->shrd->sta_lock, flags); | ||
1536 | priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK; | ||
1537 | priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; | ||
1538 | priv->stations[sta_id].sta.sta.modify_mask = 0; | ||
1539 | priv->stations[sta_id].sta.sleep_tx_count = 0; | ||
1540 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; | ||
1541 | iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); | ||
1542 | spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); | ||
1543 | |||
1544 | } | ||
1545 | |||
1546 | static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, | ||
1547 | struct ieee80211_vif *vif, | ||
1548 | enum sta_notify_cmd cmd, | ||
1549 | struct ieee80211_sta *sta) | ||
1550 | { | ||
1551 | struct iwl_priv *priv = hw->priv; | ||
1552 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | ||
1553 | int sta_id; | ||
1554 | |||
1555 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
1556 | |||
1557 | switch (cmd) { | ||
1558 | case STA_NOTIFY_SLEEP: | ||
1559 | WARN_ON(!sta_priv->client); | ||
1560 | sta_priv->asleep = true; | ||
1561 | if (atomic_read(&sta_priv->pending_frames) > 0) | ||
1562 | ieee80211_sta_block_awake(hw, sta, true); | ||
1563 | break; | ||
1564 | case STA_NOTIFY_AWAKE: | ||
1565 | WARN_ON(!sta_priv->client); | ||
1566 | if (!sta_priv->asleep) | ||
1567 | break; | ||
1568 | sta_priv->asleep = false; | ||
1569 | sta_id = iwl_sta_id(sta); | ||
1570 | if (sta_id != IWL_INVALID_STATION) | ||
1571 | iwl_sta_modify_ps_wake(priv, sta_id); | ||
1572 | break; | ||
1573 | default: | ||
1574 | break; | ||
1575 | } | ||
1576 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
1577 | } | ||
1578 | |||
1579 | struct ieee80211_ops iwlagn_hw_ops = { | ||
1580 | .tx = iwlagn_mac_tx, | ||
1581 | .start = iwlagn_mac_start, | ||
1582 | .stop = iwlagn_mac_stop, | ||
1583 | #ifdef CONFIG_PM_SLEEP | ||
1584 | .suspend = iwlagn_mac_suspend, | ||
1585 | .resume = iwlagn_mac_resume, | ||
1586 | #endif | ||
1587 | .add_interface = iwlagn_mac_add_interface, | ||
1588 | .remove_interface = iwlagn_mac_remove_interface, | ||
1589 | .change_interface = iwlagn_mac_change_interface, | ||
1590 | .config = iwlagn_mac_config, | ||
1591 | .configure_filter = iwlagn_configure_filter, | ||
1592 | .set_key = iwlagn_mac_set_key, | ||
1593 | .update_tkip_key = iwlagn_mac_update_tkip_key, | ||
1594 | .set_rekey_data = iwlagn_mac_set_rekey_data, | ||
1595 | .conf_tx = iwlagn_mac_conf_tx, | ||
1596 | .bss_info_changed = iwlagn_bss_info_changed, | ||
1597 | .ampdu_action = iwlagn_mac_ampdu_action, | ||
1598 | .hw_scan = iwlagn_mac_hw_scan, | ||
1599 | .sta_notify = iwlagn_mac_sta_notify, | ||
1600 | .sta_add = iwlagn_mac_sta_add, | ||
1601 | .sta_remove = iwlagn_mac_sta_remove, | ||
1602 | .channel_switch = iwlagn_mac_channel_switch, | ||
1603 | .flush = iwlagn_mac_flush, | ||
1604 | .tx_last_beacon = iwlagn_mac_tx_last_beacon, | ||
1605 | .remain_on_channel = iwlagn_mac_remain_on_channel, | ||
1606 | .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, | ||
1607 | .rssi_callback = iwlagn_mac_rssi_callback, | ||
1608 | CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd) | ||
1609 | CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump) | ||
1610 | .tx_sync = iwlagn_mac_tx_sync, | ||
1611 | .finish_tx_sync = iwlagn_mac_finish_tx_sync, | ||
1612 | .set_tim = iwlagn_mac_set_tim, | ||
1613 | }; | ||
1614 | |||
1615 | /* This function both allocates and initializes hw and priv. */ | ||
1616 | struct ieee80211_hw *iwl_alloc_all(void) | ||
1617 | { | ||
1618 | struct iwl_priv *priv; | ||
1619 | /* mac80211 allocates memory for this device instance, including | ||
1620 | * space for this driver's private structure */ | ||
1621 | struct ieee80211_hw *hw; | ||
1622 | |||
1623 | hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); | ||
1624 | if (!hw) | ||
1625 | goto out; | ||
1626 | |||
1627 | priv = hw->priv; | ||
1628 | priv->hw = hw; | ||
1629 | |||
1630 | out: | ||
1631 | return hw; | ||
1632 | } | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 1800029911ad..850ec8e51b17 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c | |||
@@ -256,6 +256,8 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { | |||
256 | {IWL_PCI_DEVICE(0x0082, 0xC020, iwl6005_2agn_sff_cfg)}, | 256 | {IWL_PCI_DEVICE(0x0082, 0xC020, iwl6005_2agn_sff_cfg)}, |
257 | {IWL_PCI_DEVICE(0x0085, 0xC220, iwl6005_2agn_sff_cfg)}, | 257 | {IWL_PCI_DEVICE(0x0085, 0xC220, iwl6005_2agn_sff_cfg)}, |
258 | {IWL_PCI_DEVICE(0x0082, 0x1341, iwl6005_2agn_d_cfg)}, | 258 | {IWL_PCI_DEVICE(0x0082, 0x1341, iwl6005_2agn_d_cfg)}, |
259 | {IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_cfg)},/* low 5GHz active */ | ||
260 | {IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_cfg)},/* high 5GHz active */ | ||
259 | 261 | ||
260 | /* 6x30 Series */ | 262 | /* 6x30 Series */ |
261 | {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, | 263 | {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, |
@@ -325,46 +327,28 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { | |||
325 | {IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)}, | 327 | {IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)}, |
326 | {IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)}, | 328 | {IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)}, |
327 | {IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)}, | 329 | {IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)}, |
328 | {IWL_PCI_DEVICE(0x0890, 0x4026, iwl2000_2bg_cfg)}, | ||
329 | {IWL_PCI_DEVICE(0x0891, 0x4226, iwl2000_2bg_cfg)}, | ||
330 | {IWL_PCI_DEVICE(0x0890, 0x4426, iwl2000_2bg_cfg)}, | ||
331 | {IWL_PCI_DEVICE(0x0890, 0x4822, iwl2000_2bgn_d_cfg)}, | 330 | {IWL_PCI_DEVICE(0x0890, 0x4822, iwl2000_2bgn_d_cfg)}, |
332 | 331 | ||
333 | /* 2x30 Series */ | 332 | /* 2x30 Series */ |
334 | {IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)}, | 333 | {IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)}, |
335 | {IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)}, | 334 | {IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)}, |
336 | {IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)}, | 335 | {IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)}, |
337 | {IWL_PCI_DEVICE(0x0887, 0x4066, iwl2030_2bg_cfg)}, | ||
338 | {IWL_PCI_DEVICE(0x0888, 0x4266, iwl2030_2bg_cfg)}, | ||
339 | {IWL_PCI_DEVICE(0x0887, 0x4466, iwl2030_2bg_cfg)}, | ||
340 | 336 | ||
341 | /* 6x35 Series */ | 337 | /* 6x35 Series */ |
342 | {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, | 338 | {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, |
343 | {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, | 339 | {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, |
344 | {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, | 340 | {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, |
345 | {IWL_PCI_DEVICE(0x088E, 0x4064, iwl6035_2abg_cfg)}, | ||
346 | {IWL_PCI_DEVICE(0x088F, 0x4264, iwl6035_2abg_cfg)}, | ||
347 | {IWL_PCI_DEVICE(0x088E, 0x4464, iwl6035_2abg_cfg)}, | ||
348 | {IWL_PCI_DEVICE(0x088E, 0x4066, iwl6035_2bg_cfg)}, | ||
349 | {IWL_PCI_DEVICE(0x088F, 0x4266, iwl6035_2bg_cfg)}, | ||
350 | {IWL_PCI_DEVICE(0x088E, 0x4466, iwl6035_2bg_cfg)}, | ||
351 | 341 | ||
352 | /* 105 Series */ | 342 | /* 105 Series */ |
353 | {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, | 343 | {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, |
354 | {IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)}, | 344 | {IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)}, |
355 | {IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)}, | 345 | {IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)}, |
356 | {IWL_PCI_DEVICE(0x0894, 0x0026, iwl105_bg_cfg)}, | ||
357 | {IWL_PCI_DEVICE(0x0895, 0x0226, iwl105_bg_cfg)}, | ||
358 | {IWL_PCI_DEVICE(0x0894, 0x0426, iwl105_bg_cfg)}, | ||
359 | {IWL_PCI_DEVICE(0x0894, 0x0822, iwl105_bgn_d_cfg)}, | 346 | {IWL_PCI_DEVICE(0x0894, 0x0822, iwl105_bgn_d_cfg)}, |
360 | 347 | ||
361 | /* 135 Series */ | 348 | /* 135 Series */ |
362 | {IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)}, | 349 | {IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)}, |
363 | {IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)}, | 350 | {IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)}, |
364 | {IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)}, | 351 | {IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)}, |
365 | {IWL_PCI_DEVICE(0x0892, 0x0066, iwl135_bg_cfg)}, | ||
366 | {IWL_PCI_DEVICE(0x0893, 0x0266, iwl135_bg_cfg)}, | ||
367 | {IWL_PCI_DEVICE(0x0892, 0x0466, iwl135_bg_cfg)}, | ||
368 | 352 | ||
369 | {0} | 353 | {0} |
370 | }; | 354 | }; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index e5d727f537d0..359d2182757b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c | |||
@@ -416,6 +416,8 @@ static u16 iwl_limit_dwell(struct iwl_priv *priv, u16 dwell_time) | |||
416 | 416 | ||
417 | if (!iwl_is_associated_ctx(ctx)) | 417 | if (!iwl_is_associated_ctx(ctx)) |
418 | continue; | 418 | continue; |
419 | if (ctx->staging.dev_type == RXON_DEV_TYPE_P2P) | ||
420 | continue; | ||
419 | value = ctx->beacon_int; | 421 | value = ctx->beacon_int; |
420 | if (!value) | 422 | if (!value) |
421 | value = IWL_PASSIVE_DWELL_BASE; | 423 | value = IWL_PASSIVE_DWELL_BASE; |
@@ -678,7 +680,8 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) | |||
678 | priv->contexts[IWL_RXON_CTX_BSS].active.flags & | 680 | priv->contexts[IWL_RXON_CTX_BSS].active.flags & |
679 | RXON_FLG_CHANNEL_MODE_MSK) | 681 | RXON_FLG_CHANNEL_MODE_MSK) |
680 | >> RXON_FLG_CHANNEL_MODE_POS; | 682 | >> RXON_FLG_CHANNEL_MODE_POS; |
681 | if (chan_mod == CHANNEL_MODE_PURE_40) { | 683 | if ((priv->scan_request && priv->scan_request->no_cck) || |
684 | chan_mod == CHANNEL_MODE_PURE_40) { | ||
682 | rate = IWL_RATE_6M_PLCP; | 685 | rate = IWL_RATE_6M_PLCP; |
683 | } else { | 686 | } else { |
684 | rate = IWL_RATE_1M_PLCP; | 687 | rate = IWL_RATE_1M_PLCP; |
@@ -938,51 +941,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, | |||
938 | return 0; | 941 | return 0; |
939 | } | 942 | } |
940 | 943 | ||
941 | int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, | ||
942 | struct ieee80211_vif *vif, | ||
943 | struct cfg80211_scan_request *req) | ||
944 | { | ||
945 | struct iwl_priv *priv = hw->priv; | ||
946 | int ret; | ||
947 | |||
948 | IWL_DEBUG_MAC80211(priv, "enter\n"); | ||
949 | |||
950 | if (req->n_channels == 0) | ||
951 | return -EINVAL; | ||
952 | |||
953 | mutex_lock(&priv->shrd->mutex); | ||
954 | |||
955 | /* | ||
956 | * If an internal scan is in progress, just set | ||
957 | * up the scan_request as per above. | ||
958 | */ | ||
959 | if (priv->scan_type != IWL_SCAN_NORMAL) { | ||
960 | IWL_DEBUG_SCAN(priv, | ||
961 | "SCAN request during internal scan - defer\n"); | ||
962 | priv->scan_request = req; | ||
963 | priv->scan_vif = vif; | ||
964 | ret = 0; | ||
965 | } else { | ||
966 | priv->scan_request = req; | ||
967 | priv->scan_vif = vif; | ||
968 | /* | ||
969 | * mac80211 will only ask for one band at a time | ||
970 | * so using channels[0] here is ok | ||
971 | */ | ||
972 | ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL, | ||
973 | req->channels[0]->band); | ||
974 | if (ret) { | ||
975 | priv->scan_request = NULL; | ||
976 | priv->scan_vif = NULL; | ||
977 | } | ||
978 | } | ||
979 | |||
980 | IWL_DEBUG_MAC80211(priv, "leave\n"); | ||
981 | |||
982 | mutex_unlock(&priv->shrd->mutex); | ||
983 | |||
984 | return ret; | ||
985 | } | ||
986 | 944 | ||
987 | /* | 945 | /* |
988 | * internal short scan, this function should only been called while associated. | 946 | * internal short scan, this function should only been called while associated. |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 5e50d88f302b..e3882d0cfc85 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c | |||
@@ -396,8 +396,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) | |||
396 | break; | 396 | break; |
397 | 397 | ||
398 | case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: | 398 | case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: |
399 | status = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, | 399 | status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); |
400 | IWL_UCODE_INIT); | ||
401 | if (status) | 400 | if (status) |
402 | IWL_DEBUG_INFO(priv, | 401 | IWL_DEBUG_INFO(priv, |
403 | "Error loading init ucode: %d\n", status); | 402 | "Error loading init ucode: %d\n", status); |
@@ -409,9 +408,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) | |||
409 | break; | 408 | break; |
410 | 409 | ||
411 | case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: | 410 | case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: |
412 | status = iwlagn_load_ucode_wait_alive(priv, | 411 | status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); |
413 | &priv->ucode_rt, | ||
414 | IWL_UCODE_REGULAR); | ||
415 | if (status) { | 412 | if (status) { |
416 | IWL_DEBUG_INFO(priv, | 413 | IWL_DEBUG_INFO(priv, |
417 | "Error loading runtime ucode: %d\n", status); | 414 | "Error loading runtime ucode: %d\n", status); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 2b6756e8b8f9..afaaa2a51b96 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | |||
@@ -355,7 +355,7 @@ static inline void iwl_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) | |||
355 | } | 355 | } |
356 | 356 | ||
357 | static inline void iwl_wake_queue(struct iwl_trans *trans, | 357 | static inline void iwl_wake_queue(struct iwl_trans *trans, |
358 | struct iwl_tx_queue *txq) | 358 | struct iwl_tx_queue *txq, const char *msg) |
359 | { | 359 | { |
360 | u8 queue = txq->swq_id; | 360 | u8 queue = txq->swq_id; |
361 | u8 ac = queue & 3; | 361 | u8 ac = queue & 3; |
@@ -363,13 +363,22 @@ static inline void iwl_wake_queue(struct iwl_trans *trans, | |||
363 | struct iwl_trans_pcie *trans_pcie = | 363 | struct iwl_trans_pcie *trans_pcie = |
364 | IWL_TRANS_GET_PCIE_TRANS(trans); | 364 | IWL_TRANS_GET_PCIE_TRANS(trans); |
365 | 365 | ||
366 | if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) | 366 | if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) { |
367 | if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) | 367 | if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) { |
368 | iwl_wake_sw_queue(priv(trans), ac); | 368 | iwl_wake_sw_queue(priv(trans), ac); |
369 | IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d ac %d. %s", | ||
370 | hwq, ac, msg); | ||
371 | } else { | ||
372 | IWL_DEBUG_TX_QUEUES(trans, "Don't wake hwq %d ac %d" | ||
373 | " stop count %d. %s", | ||
374 | hwq, ac, atomic_read(&trans_pcie-> | ||
375 | queue_stop_count[ac]), msg); | ||
376 | } | ||
377 | } | ||
369 | } | 378 | } |
370 | 379 | ||
371 | static inline void iwl_stop_queue(struct iwl_trans *trans, | 380 | static inline void iwl_stop_queue(struct iwl_trans *trans, |
372 | struct iwl_tx_queue *txq) | 381 | struct iwl_tx_queue *txq, const char *msg) |
373 | { | 382 | { |
374 | u8 queue = txq->swq_id; | 383 | u8 queue = txq->swq_id; |
375 | u8 ac = queue & 3; | 384 | u8 ac = queue & 3; |
@@ -377,9 +386,23 @@ static inline void iwl_stop_queue(struct iwl_trans *trans, | |||
377 | struct iwl_trans_pcie *trans_pcie = | 386 | struct iwl_trans_pcie *trans_pcie = |
378 | IWL_TRANS_GET_PCIE_TRANS(trans); | 387 | IWL_TRANS_GET_PCIE_TRANS(trans); |
379 | 388 | ||
380 | if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) | 389 | if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) { |
381 | if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) | 390 | if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) { |
382 | iwl_stop_sw_queue(priv(trans), ac); | 391 | iwl_stop_sw_queue(priv(trans), ac); |
392 | IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d ac %d" | ||
393 | " stop count %d. %s", | ||
394 | hwq, ac, atomic_read(&trans_pcie-> | ||
395 | queue_stop_count[ac]), msg); | ||
396 | } else { | ||
397 | IWL_DEBUG_TX_QUEUES(trans, "Don't stop hwq %d ac %d" | ||
398 | " stop count %d. %s", | ||
399 | hwq, ac, atomic_read(&trans_pcie-> | ||
400 | queue_stop_count[ac]), msg); | ||
401 | } | ||
402 | } else { | ||
403 | IWL_DEBUG_TX_QUEUES(trans, "stop hwq %d, but it is stopped/ %s", | ||
404 | hwq, msg); | ||
405 | } | ||
383 | } | 406 | } |
384 | 407 | ||
385 | #ifdef ieee80211_stop_queue | 408 | #ifdef ieee80211_stop_queue |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 374c68cc1d70..ee126f844a5c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | |||
@@ -1108,7 +1108,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) | |||
1108 | isr_stats->tx++; | 1108 | isr_stats->tx++; |
1109 | handled |= CSR_INT_BIT_FH_TX; | 1109 | handled |= CSR_INT_BIT_FH_TX; |
1110 | /* Wake up uCode load routine, now that load is complete */ | 1110 | /* Wake up uCode load routine, now that load is complete */ |
1111 | priv(trans)->ucode_write_complete = 1; | 1111 | trans->ucode_write_complete = 1; |
1112 | wake_up(&trans->shrd->wait_command_queue); | 1112 | wake_up(&trans->shrd->wait_command_queue); |
1113 | } | 1113 | } |
1114 | 1114 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 4a0c95302a7e..6dba1515023c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | |||
@@ -430,7 +430,7 @@ void iwl_trans_tx_queue_set_status(struct iwl_trans *trans, | |||
430 | 430 | ||
431 | txq->sched_retry = scd_retry; | 431 | txq->sched_retry = scd_retry; |
432 | 432 | ||
433 | IWL_DEBUG_INFO(trans, "%s %s Queue %d on FIFO %d\n", | 433 | IWL_DEBUG_TX_QUEUES(trans, "%s %s Queue %d on FIFO %d\n", |
434 | active ? "Activate" : "Deactivate", | 434 | active ? "Activate" : "Deactivate", |
435 | scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id); | 435 | scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id); |
436 | } | 436 | } |
@@ -561,12 +561,13 @@ int iwl_trans_pcie_tx_agg_alloc(struct iwl_trans *trans, | |||
561 | 561 | ||
562 | tid_data = &trans->shrd->tid_data[sta_id][tid]; | 562 | tid_data = &trans->shrd->tid_data[sta_id][tid]; |
563 | if (tid_data->tfds_in_queue == 0) { | 563 | if (tid_data->tfds_in_queue == 0) { |
564 | IWL_DEBUG_HT(trans, "HW queue is empty\n"); | 564 | IWL_DEBUG_TX_QUEUES(trans, "HW queue is empty\n"); |
565 | tid_data->agg.state = IWL_AGG_ON; | 565 | tid_data->agg.state = IWL_AGG_ON; |
566 | iwl_start_tx_ba_trans_ready(priv(trans), ctx, sta_id, tid); | 566 | iwl_start_tx_ba_trans_ready(priv(trans), ctx, sta_id, tid); |
567 | } else { | 567 | } else { |
568 | IWL_DEBUG_HT(trans, "HW queue is NOT empty: %d packets in HW" | 568 | IWL_DEBUG_TX_QUEUES(trans, |
569 | "queue\n", tid_data->tfds_in_queue); | 569 | "HW queue is NOT empty: %d packets in HW" |
570 | " queue\n", tid_data->tfds_in_queue); | ||
570 | tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; | 571 | tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; |
571 | } | 572 | } |
572 | spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); | 573 | spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); |
@@ -643,14 +644,15 @@ int iwl_trans_pcie_tx_agg_disable(struct iwl_trans *trans, | |||
643 | 644 | ||
644 | /* The queue is not empty */ | 645 | /* The queue is not empty */ |
645 | if (write_ptr != read_ptr) { | 646 | if (write_ptr != read_ptr) { |
646 | IWL_DEBUG_HT(trans, "Stopping a non empty AGG HW QUEUE\n"); | 647 | IWL_DEBUG_TX_QUEUES(trans, |
648 | "Stopping a non empty AGG HW QUEUE\n"); | ||
647 | trans->shrd->tid_data[sta_id][tid].agg.state = | 649 | trans->shrd->tid_data[sta_id][tid].agg.state = |
648 | IWL_EMPTYING_HW_QUEUE_DELBA; | 650 | IWL_EMPTYING_HW_QUEUE_DELBA; |
649 | spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); | 651 | spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); |
650 | return 0; | 652 | return 0; |
651 | } | 653 | } |
652 | 654 | ||
653 | IWL_DEBUG_HT(trans, "HW queue is empty\n"); | 655 | IWL_DEBUG_TX_QUEUES(trans, "HW queue is empty\n"); |
654 | turn_off: | 656 | turn_off: |
655 | trans->shrd->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF; | 657 | trans->shrd->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF; |
656 | 658 | ||
@@ -982,7 +984,8 @@ static int iwl_send_cmd_async(struct iwl_trans *trans, struct iwl_host_cmd *cmd) | |||
982 | 984 | ||
983 | ret = iwl_enqueue_hcmd(trans, cmd); | 985 | ret = iwl_enqueue_hcmd(trans, cmd); |
984 | if (ret < 0) { | 986 | if (ret < 0) { |
985 | IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", | 987 | IWL_DEBUG_QUIET_RFKILL(trans, |
988 | "Error sending %s: enqueue_hcmd failed: %d\n", | ||
986 | get_cmd_string(cmd->id), ret); | 989 | get_cmd_string(cmd->id), ret); |
987 | return ret; | 990 | return ret; |
988 | } | 991 | } |
@@ -1000,6 +1003,20 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) | |||
1000 | IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", | 1003 | IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", |
1001 | get_cmd_string(cmd->id)); | 1004 | get_cmd_string(cmd->id)); |
1002 | 1005 | ||
1006 | if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status)) | ||
1007 | return -EBUSY; | ||
1008 | |||
1009 | |||
1010 | if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { | ||
1011 | IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", | ||
1012 | get_cmd_string(cmd->id)); | ||
1013 | return -ECANCELED; | ||
1014 | } | ||
1015 | if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) { | ||
1016 | IWL_ERR(trans, "Command %s failed: FW Error\n", | ||
1017 | get_cmd_string(cmd->id)); | ||
1018 | return -EIO; | ||
1019 | } | ||
1003 | set_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); | 1020 | set_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); |
1004 | IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", | 1021 | IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", |
1005 | get_cmd_string(cmd->id)); | 1022 | get_cmd_string(cmd->id)); |
@@ -1008,7 +1025,8 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) | |||
1008 | if (cmd_idx < 0) { | 1025 | if (cmd_idx < 0) { |
1009 | ret = cmd_idx; | 1026 | ret = cmd_idx; |
1010 | clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); | 1027 | clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); |
1011 | IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", | 1028 | IWL_DEBUG_QUIET_RFKILL(trans, |
1029 | "Error sending %s: enqueue_hcmd failed: %d\n", | ||
1012 | get_cmd_string(cmd->id), ret); | 1030 | get_cmd_string(cmd->id), ret); |
1013 | return ret; | 1031 | return ret; |
1014 | } | 1032 | } |
@@ -1022,12 +1040,12 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) | |||
1022 | &trans_pcie->txq[trans->shrd->cmd_queue]; | 1040 | &trans_pcie->txq[trans->shrd->cmd_queue]; |
1023 | struct iwl_queue *q = &txq->q; | 1041 | struct iwl_queue *q = &txq->q; |
1024 | 1042 | ||
1025 | IWL_ERR(trans, | 1043 | IWL_DEBUG_QUIET_RFKILL(trans, |
1026 | "Error sending %s: time out after %dms.\n", | 1044 | "Error sending %s: time out after %dms.\n", |
1027 | get_cmd_string(cmd->id), | 1045 | get_cmd_string(cmd->id), |
1028 | jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); | 1046 | jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); |
1029 | 1047 | ||
1030 | IWL_ERR(trans, | 1048 | IWL_DEBUG_QUIET_RFKILL(trans, |
1031 | "Current CMD queue read_ptr %d write_ptr %d\n", | 1049 | "Current CMD queue read_ptr %d write_ptr %d\n", |
1032 | q->read_ptr, q->write_ptr); | 1050 | q->read_ptr, q->write_ptr); |
1033 | 1051 | ||
@@ -1039,18 +1057,6 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) | |||
1039 | } | 1057 | } |
1040 | } | 1058 | } |
1041 | 1059 | ||
1042 | if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { | ||
1043 | IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", | ||
1044 | get_cmd_string(cmd->id)); | ||
1045 | ret = -ECANCELED; | ||
1046 | goto fail; | ||
1047 | } | ||
1048 | if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) { | ||
1049 | IWL_ERR(trans, "Command %s failed: FW Error\n", | ||
1050 | get_cmd_string(cmd->id)); | ||
1051 | ret = -EIO; | ||
1052 | goto fail; | ||
1053 | } | ||
1054 | if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { | 1060 | if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { |
1055 | IWL_ERR(trans, "Error: Response NULL in '%s'\n", | 1061 | IWL_ERR(trans, "Error: Response NULL in '%s'\n", |
1056 | get_cmd_string(cmd->id)); | 1062 | get_cmd_string(cmd->id)); |
@@ -1071,7 +1077,7 @@ cancel: | |||
1071 | trans_pcie->txq[trans->shrd->cmd_queue].meta[cmd_idx].flags &= | 1077 | trans_pcie->txq[trans->shrd->cmd_queue].meta[cmd_idx].flags &= |
1072 | ~CMD_WANT_SKB; | 1078 | ~CMD_WANT_SKB; |
1073 | } | 1079 | } |
1074 | fail: | 1080 | |
1075 | if (cmd->reply_page) { | 1081 | if (cmd->reply_page) { |
1076 | iwl_free_pages(trans->shrd, cmd->reply_page); | 1082 | iwl_free_pages(trans->shrd, cmd->reply_page); |
1077 | cmd->reply_page = 0; | 1083 | cmd->reply_page = 0; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ce918980e977..93c4f56ac408 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | |||
@@ -1232,7 +1232,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, | |||
1232 | txq->need_update = 1; | 1232 | txq->need_update = 1; |
1233 | iwl_txq_update_write_ptr(trans, txq); | 1233 | iwl_txq_update_write_ptr(trans, txq); |
1234 | } else { | 1234 | } else { |
1235 | iwl_stop_queue(trans, txq); | 1235 | iwl_stop_queue(trans, txq, "Queue is full"); |
1236 | } | 1236 | } |
1237 | } | 1237 | } |
1238 | return 0; | 1238 | return 0; |
@@ -1284,20 +1284,21 @@ static int iwlagn_txq_check_empty(struct iwl_trans *trans, | |||
1284 | /* aggregated HW queue */ | 1284 | /* aggregated HW queue */ |
1285 | if ((txq_id == tid_data->agg.txq_id) && | 1285 | if ((txq_id == tid_data->agg.txq_id) && |
1286 | (q->read_ptr == q->write_ptr)) { | 1286 | (q->read_ptr == q->write_ptr)) { |
1287 | IWL_DEBUG_HT(trans, | 1287 | IWL_DEBUG_TX_QUEUES(trans, |
1288 | "HW queue empty: continue DELBA flow\n"); | 1288 | "HW queue empty: continue DELBA flow\n"); |
1289 | iwl_trans_pcie_txq_agg_disable(trans, txq_id); | 1289 | iwl_trans_pcie_txq_agg_disable(trans, txq_id); |
1290 | tid_data->agg.state = IWL_AGG_OFF; | 1290 | tid_data->agg.state = IWL_AGG_OFF; |
1291 | iwl_stop_tx_ba_trans_ready(priv(trans), | 1291 | iwl_stop_tx_ba_trans_ready(priv(trans), |
1292 | NUM_IWL_RXON_CTX, | 1292 | NUM_IWL_RXON_CTX, |
1293 | sta_id, tid); | 1293 | sta_id, tid); |
1294 | iwl_wake_queue(trans, &trans_pcie->txq[txq_id]); | 1294 | iwl_wake_queue(trans, &trans_pcie->txq[txq_id], |
1295 | "DELBA flow complete"); | ||
1295 | } | 1296 | } |
1296 | break; | 1297 | break; |
1297 | case IWL_EMPTYING_HW_QUEUE_ADDBA: | 1298 | case IWL_EMPTYING_HW_QUEUE_ADDBA: |
1298 | /* We are reclaiming the last packet of the queue */ | 1299 | /* We are reclaiming the last packet of the queue */ |
1299 | if (tid_data->tfds_in_queue == 0) { | 1300 | if (tid_data->tfds_in_queue == 0) { |
1300 | IWL_DEBUG_HT(trans, | 1301 | IWL_DEBUG_TX_QUEUES(trans, |
1301 | "HW queue empty: continue ADDBA flow\n"); | 1302 | "HW queue empty: continue ADDBA flow\n"); |
1302 | tid_data->agg.state = IWL_AGG_ON; | 1303 | tid_data->agg.state = IWL_AGG_ON; |
1303 | iwl_start_tx_ba_trans_ready(priv(trans), | 1304 | iwl_start_tx_ba_trans_ready(priv(trans), |
@@ -1355,7 +1356,7 @@ static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, | |||
1355 | ssn , tfd_num, txq_id, txq->swq_id); | 1356 | ssn , tfd_num, txq_id, txq->swq_id); |
1356 | freed = iwl_tx_queue_reclaim(trans, txq_id, tfd_num, skbs); | 1357 | freed = iwl_tx_queue_reclaim(trans, txq_id, tfd_num, skbs); |
1357 | if (iwl_queue_space(&txq->q) > txq->q.low_mark && cond) | 1358 | if (iwl_queue_space(&txq->q) > txq->q.low_mark && cond) |
1358 | iwl_wake_queue(trans, txq); | 1359 | iwl_wake_queue(trans, txq, "Packets reclaimed"); |
1359 | } | 1360 | } |
1360 | 1361 | ||
1361 | iwl_free_tfds_in_queue(trans, sta_id, tid, freed); | 1362 | iwl_free_tfds_in_queue(trans, sta_id, tid, freed); |
@@ -1419,7 +1420,8 @@ static int iwl_trans_pcie_resume(struct iwl_trans *trans) | |||
1419 | #endif /* CONFIG_PM_SLEEP */ | 1420 | #endif /* CONFIG_PM_SLEEP */ |
1420 | 1421 | ||
1421 | static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, | 1422 | static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, |
1422 | enum iwl_rxon_context_id ctx) | 1423 | enum iwl_rxon_context_id ctx, |
1424 | const char *msg) | ||
1423 | { | 1425 | { |
1424 | u8 ac, txq_id; | 1426 | u8 ac, txq_id; |
1425 | struct iwl_trans_pcie *trans_pcie = | 1427 | struct iwl_trans_pcie *trans_pcie = |
@@ -1427,11 +1429,11 @@ static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, | |||
1427 | 1429 | ||
1428 | for (ac = 0; ac < AC_NUM; ac++) { | 1430 | for (ac = 0; ac < AC_NUM; ac++) { |
1429 | txq_id = trans_pcie->ac_to_queue[ctx][ac]; | 1431 | txq_id = trans_pcie->ac_to_queue[ctx][ac]; |
1430 | IWL_DEBUG_INFO(trans, "Queue Status: Q[%d] %s\n", | 1432 | IWL_DEBUG_TX_QUEUES(trans, "Queue Status: Q[%d] %s\n", |
1431 | ac, | 1433 | ac, |
1432 | (atomic_read(&trans_pcie->queue_stop_count[ac]) > 0) | 1434 | (atomic_read(&trans_pcie->queue_stop_count[ac]) > 0) |
1433 | ? "stopped" : "awake"); | 1435 | ? "stopped" : "awake"); |
1434 | iwl_wake_queue(trans, &trans_pcie->txq[txq_id]); | 1436 | iwl_wake_queue(trans, &trans_pcie->txq[txq_id], msg); |
1435 | } | 1437 | } |
1436 | } | 1438 | } |
1437 | 1439 | ||
@@ -1454,11 +1456,12 @@ static struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd) | |||
1454 | return iwl_trans; | 1456 | return iwl_trans; |
1455 | } | 1457 | } |
1456 | 1458 | ||
1457 | static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id) | 1459 | static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id, |
1460 | const char *msg) | ||
1458 | { | 1461 | { |
1459 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 1462 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
1460 | 1463 | ||
1461 | iwl_stop_queue(trans, &trans_pcie->txq[txq_id]); | 1464 | iwl_stop_queue(trans, &trans_pcie->txq[txq_id], msg); |
1462 | } | 1465 | } |
1463 | 1466 | ||
1464 | #define IWL_FLUSH_WAIT_MS 2000 | 1467 | #define IWL_FLUSH_WAIT_MS 2000 |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index c5923125c3f9..50227ebc0ee2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h | |||
@@ -171,7 +171,8 @@ struct iwl_trans_ops { | |||
171 | void (*tx_start)(struct iwl_trans *trans); | 171 | void (*tx_start)(struct iwl_trans *trans); |
172 | 172 | ||
173 | void (*wake_any_queue)(struct iwl_trans *trans, | 173 | void (*wake_any_queue)(struct iwl_trans *trans, |
174 | enum iwl_rxon_context_id ctx); | 174 | enum iwl_rxon_context_id ctx, |
175 | const char *msg); | ||
175 | 176 | ||
176 | int (*send_cmd)(struct iwl_trans *trans, struct iwl_host_cmd *cmd); | 177 | int (*send_cmd)(struct iwl_trans *trans, struct iwl_host_cmd *cmd); |
177 | 178 | ||
@@ -196,7 +197,7 @@ struct iwl_trans_ops { | |||
196 | 197 | ||
197 | void (*free)(struct iwl_trans *trans); | 198 | void (*free)(struct iwl_trans *trans); |
198 | 199 | ||
199 | void (*stop_queue)(struct iwl_trans *trans, int q); | 200 | void (*stop_queue)(struct iwl_trans *trans, int q, const char *msg); |
200 | 201 | ||
201 | int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); | 202 | int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); |
202 | int (*check_stuck_queue)(struct iwl_trans *trans, int q); | 203 | int (*check_stuck_queue)(struct iwl_trans *trans, int q); |
@@ -207,17 +208,48 @@ struct iwl_trans_ops { | |||
207 | #endif | 208 | #endif |
208 | }; | 209 | }; |
209 | 210 | ||
211 | /* one for each uCode image (inst/data, boot/init/runtime) */ | ||
212 | struct fw_desc { | ||
213 | dma_addr_t p_addr; /* hardware address */ | ||
214 | void *v_addr; /* software address */ | ||
215 | u32 len; /* size in bytes */ | ||
216 | }; | ||
217 | |||
218 | struct fw_img { | ||
219 | struct fw_desc code; /* firmware code image */ | ||
220 | struct fw_desc data; /* firmware data image */ | ||
221 | }; | ||
222 | |||
223 | enum iwl_ucode_type { | ||
224 | IWL_UCODE_NONE, | ||
225 | IWL_UCODE_REGULAR, | ||
226 | IWL_UCODE_INIT, | ||
227 | IWL_UCODE_WOWLAN, | ||
228 | }; | ||
229 | |||
210 | /** | 230 | /** |
211 | * struct iwl_trans - transport common data | 231 | * struct iwl_trans - transport common data |
212 | * @ops - pointer to iwl_trans_ops | 232 | * @ops - pointer to iwl_trans_ops |
213 | * @shrd - pointer to iwl_shared which holds shared data from the upper layer | 233 | * @shrd - pointer to iwl_shared which holds shared data from the upper layer |
214 | * @hcmd_lock: protects HCMD | 234 | * @hcmd_lock: protects HCMD |
235 | * @ucode_write_complete: indicates that the ucode has been copied. | ||
236 | * @ucode_rt: run time ucode image | ||
237 | * @ucode_init: init ucode image | ||
238 | * @ucode_wowlan: wake on wireless ucode image (optional) | ||
215 | */ | 239 | */ |
216 | struct iwl_trans { | 240 | struct iwl_trans { |
217 | const struct iwl_trans_ops *ops; | 241 | const struct iwl_trans_ops *ops; |
218 | struct iwl_shared *shrd; | 242 | struct iwl_shared *shrd; |
219 | spinlock_t hcmd_lock; | 243 | spinlock_t hcmd_lock; |
220 | 244 | ||
245 | u8 ucode_write_complete; /* the image write is complete */ | ||
246 | struct fw_img ucode_rt; | ||
247 | struct fw_img ucode_init; | ||
248 | struct fw_img ucode_wowlan; | ||
249 | |||
250 | /* eeprom related variables */ | ||
251 | int nvm_device_type; | ||
252 | |||
221 | /* pointer to trans specific struct */ | 253 | /* pointer to trans specific struct */ |
222 | /*Ensure that this pointer will always be aligned to sizeof pointer */ | 254 | /*Ensure that this pointer will always be aligned to sizeof pointer */ |
223 | char trans_specific[0] __attribute__((__aligned__(sizeof(void *)))); | 255 | char trans_specific[0] __attribute__((__aligned__(sizeof(void *)))); |
@@ -249,9 +281,10 @@ static inline void iwl_trans_tx_start(struct iwl_trans *trans) | |||
249 | } | 281 | } |
250 | 282 | ||
251 | static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, | 283 | static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, |
252 | enum iwl_rxon_context_id ctx) | 284 | enum iwl_rxon_context_id ctx, |
285 | const char *msg) | ||
253 | { | 286 | { |
254 | trans->ops->wake_any_queue(trans, ctx); | 287 | trans->ops->wake_any_queue(trans, ctx, msg); |
255 | } | 288 | } |
256 | 289 | ||
257 | 290 | ||
@@ -311,9 +344,10 @@ static inline void iwl_trans_free(struct iwl_trans *trans) | |||
311 | trans->ops->free(trans); | 344 | trans->ops->free(trans); |
312 | } | 345 | } |
313 | 346 | ||
314 | static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q) | 347 | static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q, |
348 | const char *msg) | ||
315 | { | 349 | { |
316 | trans->ops->stop_queue(trans, q); | 350 | trans->ops->stop_queue(trans, q, msg); |
317 | } | 351 | } |
318 | 352 | ||
319 | static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) | 353 | static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) |
@@ -348,4 +382,8 @@ static inline int iwl_trans_resume(struct iwl_trans *trans) | |||
348 | ******************************************************/ | 382 | ******************************************************/ |
349 | extern const struct iwl_trans_ops trans_ops_pcie; | 383 | extern const struct iwl_trans_ops trans_ops_pcie; |
350 | 384 | ||
385 | int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, | ||
386 | const void *data, size_t len); | ||
387 | void iwl_dealloc_ucode(struct iwl_trans *trans); | ||
388 | |||
351 | #endif /* __iwl_trans_h__ */ | 389 | #endif /* __iwl_trans_h__ */ |
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c index c42be81e979e..48e8218fd23b 100644 --- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c +++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c | |||
@@ -165,11 +165,15 @@ static int iwm_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, | |||
165 | struct key_params *params) | 165 | struct key_params *params) |
166 | { | 166 | { |
167 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | 167 | struct iwm_priv *iwm = ndev_to_iwm(ndev); |
168 | struct iwm_key *key = &iwm->keys[key_index]; | 168 | struct iwm_key *key; |
169 | int ret; | 169 | int ret; |
170 | 170 | ||
171 | IWM_DBG_WEXT(iwm, DBG, "Adding key for %pM\n", mac_addr); | 171 | IWM_DBG_WEXT(iwm, DBG, "Adding key for %pM\n", mac_addr); |
172 | 172 | ||
173 | if (key_index >= IWM_NUM_KEYS) | ||
174 | return -ENOENT; | ||
175 | |||
176 | key = &iwm->keys[key_index]; | ||
173 | memset(key, 0, sizeof(struct iwm_key)); | 177 | memset(key, 0, sizeof(struct iwm_key)); |
174 | ret = iwm_key_init(key, key_index, mac_addr, params); | 178 | ret = iwm_key_init(key, key_index, mac_addr, params); |
175 | if (ret < 0) { | 179 | if (ret < 0) { |
@@ -214,8 +218,12 @@ static int iwm_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, | |||
214 | u8 key_index, bool pairwise, const u8 *mac_addr) | 218 | u8 key_index, bool pairwise, const u8 *mac_addr) |
215 | { | 219 | { |
216 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | 220 | struct iwm_priv *iwm = ndev_to_iwm(ndev); |
217 | struct iwm_key *key = &iwm->keys[key_index]; | 221 | struct iwm_key *key; |
218 | 222 | ||
223 | if (key_index >= IWM_NUM_KEYS) | ||
224 | return -ENOENT; | ||
225 | |||
226 | key = &iwm->keys[key_index]; | ||
219 | if (!iwm->keys[key_index].key_len) { | 227 | if (!iwm->keys[key_index].key_len) { |
220 | IWM_DBG_WEXT(iwm, DBG, "Key %d not used\n", key_index); | 228 | IWM_DBG_WEXT(iwm, DBG, "Key %d not used\n", key_index); |
221 | return 0; | 229 | return 0; |
@@ -236,6 +244,9 @@ static int iwm_cfg80211_set_default_key(struct wiphy *wiphy, | |||
236 | 244 | ||
237 | IWM_DBG_WEXT(iwm, DBG, "Default key index is: %d\n", key_index); | 245 | IWM_DBG_WEXT(iwm, DBG, "Default key index is: %d\n", key_index); |
238 | 246 | ||
247 | if (key_index >= IWM_NUM_KEYS) | ||
248 | return -ENOENT; | ||
249 | |||
239 | if (!iwm->keys[key_index].key_len) { | 250 | if (!iwm->keys[key_index].key_len) { |
240 | IWM_ERR(iwm, "Key %d not used\n", key_index); | 251 | IWM_ERR(iwm, "Key %d not used\n", key_index); |
241 | return -EINVAL; | 252 | return -EINVAL; |
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index a7f1ab28940d..d1d84e0e30fc 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c | |||
@@ -485,6 +485,7 @@ static int lbs_cfg_set_channel(struct wiphy *wiphy, | |||
485 | static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, | 485 | static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, |
486 | struct cmd_header *resp) | 486 | struct cmd_header *resp) |
487 | { | 487 | { |
488 | struct cfg80211_bss *bss; | ||
488 | struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; | 489 | struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; |
489 | int bsssize; | 490 | int bsssize; |
490 | const u8 *pos; | 491 | const u8 *pos; |
@@ -632,12 +633,14 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, | |||
632 | LBS_SCAN_RSSI_TO_MBM(rssi)/100); | 633 | LBS_SCAN_RSSI_TO_MBM(rssi)/100); |
633 | 634 | ||
634 | if (channel && | 635 | if (channel && |
635 | !(channel->flags & IEEE80211_CHAN_DISABLED)) | 636 | !(channel->flags & IEEE80211_CHAN_DISABLED)) { |
636 | cfg80211_inform_bss(wiphy, channel, | 637 | bss = cfg80211_inform_bss(wiphy, channel, |
637 | bssid, get_unaligned_le64(tsfdesc), | 638 | bssid, get_unaligned_le64(tsfdesc), |
638 | capa, intvl, ie, ielen, | 639 | capa, intvl, ie, ielen, |
639 | LBS_SCAN_RSSI_TO_MBM(rssi), | 640 | LBS_SCAN_RSSI_TO_MBM(rssi), |
640 | GFP_KERNEL); | 641 | GFP_KERNEL); |
642 | cfg80211_put_bss(bss); | ||
643 | } | ||
641 | } else | 644 | } else |
642 | lbs_deb_scan("scan response: missing BSS channel IE\n"); | 645 | lbs_deb_scan("scan response: missing BSS channel IE\n"); |
643 | 646 | ||
@@ -1720,6 +1723,7 @@ static void lbs_join_post(struct lbs_private *priv, | |||
1720 | 2 + 2 + /* atim */ | 1723 | 2 + 2 + /* atim */ |
1721 | 2 + 8]; /* extended rates */ | 1724 | 2 + 8]; /* extended rates */ |
1722 | u8 *fake = fake_ie; | 1725 | u8 *fake = fake_ie; |
1726 | struct cfg80211_bss *bss; | ||
1723 | 1727 | ||
1724 | lbs_deb_enter(LBS_DEB_CFG80211); | 1728 | lbs_deb_enter(LBS_DEB_CFG80211); |
1725 | 1729 | ||
@@ -1763,14 +1767,15 @@ static void lbs_join_post(struct lbs_private *priv, | |||
1763 | *fake++ = 0x6c; | 1767 | *fake++ = 0x6c; |
1764 | lbs_deb_hex(LBS_DEB_CFG80211, "IE", fake_ie, fake - fake_ie); | 1768 | lbs_deb_hex(LBS_DEB_CFG80211, "IE", fake_ie, fake - fake_ie); |
1765 | 1769 | ||
1766 | cfg80211_inform_bss(priv->wdev->wiphy, | 1770 | bss = cfg80211_inform_bss(priv->wdev->wiphy, |
1767 | params->channel, | 1771 | params->channel, |
1768 | bssid, | 1772 | bssid, |
1769 | 0, | 1773 | 0, |
1770 | capability, | 1774 | capability, |
1771 | params->beacon_interval, | 1775 | params->beacon_interval, |
1772 | fake_ie, fake - fake_ie, | 1776 | fake_ie, fake - fake_ie, |
1773 | 0, GFP_KERNEL); | 1777 | 0, GFP_KERNEL); |
1778 | cfg80211_put_bss(bss); | ||
1774 | 1779 | ||
1775 | memcpy(priv->wdev->ssid, params->ssid, params->ssid_len); | 1780 | memcpy(priv->wdev->ssid, params->ssid, params->ssid_len); |
1776 | priv->wdev->ssid_len = params->ssid_len; | 1781 | priv->wdev->ssid_len = params->ssid_len; |
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 523ad55a2885..6cf6d6d25e21 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -1748,6 +1748,8 @@ static int __init init_mac80211_hwsim(void) | |||
1748 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | 1748 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | |
1749 | IEEE80211_HW_AMPDU_AGGREGATION; | 1749 | IEEE80211_HW_AMPDU_AGGREGATION; |
1750 | 1750 | ||
1751 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; | ||
1752 | |||
1751 | /* ask mac80211 to reserve space for magic */ | 1753 | /* ask mac80211 to reserve space for magic */ |
1752 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); | 1754 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); |
1753 | hw->sta_data_size = sizeof(struct hwsim_sta_priv); | 1755 | hw->sta_data_size = sizeof(struct hwsim_sta_priv); |
diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c index 7aa9aa0ac958..681d3f2a4c28 100644 --- a/drivers/net/wireless/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c | |||
@@ -33,7 +33,7 @@ | |||
33 | * Since the buffer is linear, the function uses rotation to simulate | 33 | * Since the buffer is linear, the function uses rotation to simulate |
34 | * circular buffer. | 34 | * circular buffer. |
35 | */ | 35 | */ |
36 | static int | 36 | static void |
37 | mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, | 37 | mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, |
38 | struct mwifiex_rx_reorder_tbl | 38 | struct mwifiex_rx_reorder_tbl |
39 | *rx_reor_tbl_ptr, int start_win) | 39 | *rx_reor_tbl_ptr, int start_win) |
@@ -71,8 +71,6 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, | |||
71 | 71 | ||
72 | rx_reor_tbl_ptr->start_win = start_win; | 72 | rx_reor_tbl_ptr->start_win = start_win; |
73 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); | 73 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
74 | |||
75 | return 0; | ||
76 | } | 74 | } |
77 | 75 | ||
78 | /* | 76 | /* |
@@ -83,7 +81,7 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, | |||
83 | * Since the buffer is linear, the function uses rotation to simulate | 81 | * Since the buffer is linear, the function uses rotation to simulate |
84 | * circular buffer. | 82 | * circular buffer. |
85 | */ | 83 | */ |
86 | static int | 84 | static void |
87 | mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, | 85 | mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, |
88 | struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr) | 86 | struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr) |
89 | { | 87 | { |
@@ -119,7 +117,6 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, | |||
119 | rx_reor_tbl_ptr->start_win = (rx_reor_tbl_ptr->start_win + i) | 117 | rx_reor_tbl_ptr->start_win = (rx_reor_tbl_ptr->start_win + i) |
120 | &(MAX_TID_VALUE - 1); | 118 | &(MAX_TID_VALUE - 1); |
121 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); | 119 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
122 | return 0; | ||
123 | } | 120 | } |
124 | 121 | ||
125 | /* | 122 | /* |
@@ -405,7 +402,7 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, | |||
405 | u8 *ta, u8 pkt_type, void *payload) | 402 | u8 *ta, u8 pkt_type, void *payload) |
406 | { | 403 | { |
407 | struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; | 404 | struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; |
408 | int start_win, end_win, win_size, ret; | 405 | int start_win, end_win, win_size; |
409 | u16 pkt_index; | 406 | u16 pkt_index; |
410 | 407 | ||
411 | rx_reor_tbl_ptr = | 408 | rx_reor_tbl_ptr = |
@@ -452,11 +449,8 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, | |||
452 | start_win = (end_win - win_size) + 1; | 449 | start_win = (end_win - win_size) + 1; |
453 | else | 450 | else |
454 | start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1; | 451 | start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1; |
455 | ret = mwifiex_11n_dispatch_pkt_until_start_win(priv, | 452 | mwifiex_11n_dispatch_pkt_until_start_win(priv, |
456 | rx_reor_tbl_ptr, start_win); | 453 | rx_reor_tbl_ptr, start_win); |
457 | |||
458 | if (ret) | ||
459 | return ret; | ||
460 | } | 454 | } |
461 | 455 | ||
462 | if (pkt_type != PKT_TYPE_BAR) { | 456 | if (pkt_type != PKT_TYPE_BAR) { |
@@ -475,9 +469,9 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, | |||
475 | * Dispatch all packets sequentially from start_win until a | 469 | * Dispatch all packets sequentially from start_win until a |
476 | * hole is found and adjust the start_win appropriately | 470 | * hole is found and adjust the start_win appropriately |
477 | */ | 471 | */ |
478 | ret = mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr); | 472 | mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr); |
479 | 473 | ||
480 | return ret; | 474 | return 0; |
481 | } | 475 | } |
482 | 476 | ||
483 | /* | 477 | /* |
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 462c71067bfb..e9ab9a3fbe9c 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c | |||
@@ -780,6 +780,7 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv) | |||
780 | { | 780 | { |
781 | struct ieee80211_channel *chan; | 781 | struct ieee80211_channel *chan; |
782 | struct mwifiex_bss_info bss_info; | 782 | struct mwifiex_bss_info bss_info; |
783 | struct cfg80211_bss *bss; | ||
783 | int ie_len; | 784 | int ie_len; |
784 | u8 ie_buf[IEEE80211_MAX_SSID_LEN + sizeof(struct ieee_types_header)]; | 785 | u8 ie_buf[IEEE80211_MAX_SSID_LEN + sizeof(struct ieee_types_header)]; |
785 | enum ieee80211_band band; | 786 | enum ieee80211_band band; |
@@ -800,9 +801,10 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv) | |||
800 | ieee80211_channel_to_frequency(bss_info.bss_chan, | 801 | ieee80211_channel_to_frequency(bss_info.bss_chan, |
801 | band)); | 802 | band)); |
802 | 803 | ||
803 | cfg80211_inform_bss(priv->wdev->wiphy, chan, | 804 | bss = cfg80211_inform_bss(priv->wdev->wiphy, chan, |
804 | bss_info.bssid, 0, WLAN_CAPABILITY_IBSS, | 805 | bss_info.bssid, 0, WLAN_CAPABILITY_IBSS, |
805 | 0, ie_buf, ie_len, 0, GFP_KERNEL); | 806 | 0, ie_buf, ie_len, 0, GFP_KERNEL); |
807 | cfg80211_put_bss(bss); | ||
806 | memcpy(priv->cfg_bssid, bss_info.bssid, ETH_ALEN); | 808 | memcpy(priv->cfg_bssid, bss_info.bssid, ETH_ALEN); |
807 | 809 | ||
808 | return 0; | 810 | return 0; |
diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h index 0cc5d73cb0c1..35cb29cbd96e 100644 --- a/drivers/net/wireless/mwifiex/fw.h +++ b/drivers/net/wireless/mwifiex/fw.h | |||
@@ -673,7 +673,7 @@ struct host_cmd_ds_802_11_ad_hoc_start { | |||
673 | union ieee_types_phy_param_set phy_param_set; | 673 | union ieee_types_phy_param_set phy_param_set; |
674 | u16 reserved1; | 674 | u16 reserved1; |
675 | __le16 cap_info_bitmap; | 675 | __le16 cap_info_bitmap; |
676 | u8 DataRate[HOSTCMD_SUPPORTED_RATES]; | 676 | u8 data_rate[HOSTCMD_SUPPORTED_RATES]; |
677 | } __packed; | 677 | } __packed; |
678 | 678 | ||
679 | struct host_cmd_ds_802_11_ad_hoc_result { | 679 | struct host_cmd_ds_802_11_ad_hoc_result { |
diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index d792b3fb7c16..26940455255b 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c | |||
@@ -187,8 +187,6 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) | |||
187 | struct mwifiex_opt_sleep_confirm *sleep_cfm_buf = NULL; | 187 | struct mwifiex_opt_sleep_confirm *sleep_cfm_buf = NULL; |
188 | 188 | ||
189 | skb_put(adapter->sleep_cfm, sizeof(struct mwifiex_opt_sleep_confirm)); | 189 | skb_put(adapter->sleep_cfm, sizeof(struct mwifiex_opt_sleep_confirm)); |
190 | sleep_cfm_buf = (struct mwifiex_opt_sleep_confirm *) | ||
191 | (adapter->sleep_cfm->data); | ||
192 | 190 | ||
193 | adapter->cmd_sent = false; | 191 | adapter->cmd_sent = false; |
194 | 192 | ||
@@ -254,6 +252,8 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) | |||
254 | mwifiex_wmm_init(adapter); | 252 | mwifiex_wmm_init(adapter); |
255 | 253 | ||
256 | if (adapter->sleep_cfm) { | 254 | if (adapter->sleep_cfm) { |
255 | sleep_cfm_buf = (struct mwifiex_opt_sleep_confirm *) | ||
256 | adapter->sleep_cfm->data; | ||
257 | memset(sleep_cfm_buf, 0, adapter->sleep_cfm->len); | 257 | memset(sleep_cfm_buf, 0, adapter->sleep_cfm->len); |
258 | sleep_cfm_buf->command = | 258 | sleep_cfm_buf->command = |
259 | cpu_to_le16(HostCmd_CMD_802_11_PS_MODE_ENH); | 259 | cpu_to_le16(HostCmd_CMD_802_11_PS_MODE_ENH); |
diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index 62b4c2938608..1c4981367e50 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c | |||
@@ -724,8 +724,8 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, | |||
724 | u32 cmd_append_size = 0; | 724 | u32 cmd_append_size = 0; |
725 | u32 i; | 725 | u32 i; |
726 | u16 tmp_cap; | 726 | u16 tmp_cap; |
727 | uint16_t ht_cap_info; | ||
728 | struct mwifiex_ie_types_chan_list_param_set *chan_tlv; | 727 | struct mwifiex_ie_types_chan_list_param_set *chan_tlv; |
728 | u8 radio_type; | ||
729 | 729 | ||
730 | struct mwifiex_ie_types_htcap *ht_cap; | 730 | struct mwifiex_ie_types_htcap *ht_cap; |
731 | struct mwifiex_ie_types_htinfo *ht_info; | 731 | struct mwifiex_ie_types_htinfo *ht_info; |
@@ -837,8 +837,8 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, | |||
837 | bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL; | 837 | bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL; |
838 | } | 838 | } |
839 | 839 | ||
840 | memset(adhoc_start->DataRate, 0, sizeof(adhoc_start->DataRate)); | 840 | memset(adhoc_start->data_rate, 0, sizeof(adhoc_start->data_rate)); |
841 | mwifiex_get_active_data_rates(priv, adhoc_start->DataRate); | 841 | mwifiex_get_active_data_rates(priv, adhoc_start->data_rate); |
842 | if ((adapter->adhoc_start_band & BAND_G) && | 842 | if ((adapter->adhoc_start_band & BAND_G) && |
843 | (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) { | 843 | (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) { |
844 | if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, | 844 | if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, |
@@ -850,20 +850,19 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, | |||
850 | } | 850 | } |
851 | } | 851 | } |
852 | /* Find the last non zero */ | 852 | /* Find the last non zero */ |
853 | for (i = 0; i < sizeof(adhoc_start->DataRate) && | 853 | for (i = 0; i < sizeof(adhoc_start->data_rate); i++) |
854 | adhoc_start->DataRate[i]; | 854 | if (!adhoc_start->data_rate[i]) |
855 | i++) | 855 | break; |
856 | ; | ||
857 | 856 | ||
858 | priv->curr_bss_params.num_of_rates = i; | 857 | priv->curr_bss_params.num_of_rates = i; |
859 | 858 | ||
860 | /* Copy the ad-hoc creating rates into Current BSS rate structure */ | 859 | /* Copy the ad-hoc creating rates into Current BSS rate structure */ |
861 | memcpy(&priv->curr_bss_params.data_rates, | 860 | memcpy(&priv->curr_bss_params.data_rates, |
862 | &adhoc_start->DataRate, priv->curr_bss_params.num_of_rates); | 861 | &adhoc_start->data_rate, priv->curr_bss_params.num_of_rates); |
863 | 862 | ||
864 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: rates=%02x %02x %02x %02x\n", | 863 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: rates=%02x %02x %02x %02x\n", |
865 | adhoc_start->DataRate[0], adhoc_start->DataRate[1], | 864 | adhoc_start->data_rate[0], adhoc_start->data_rate[1], |
866 | adhoc_start->DataRate[2], adhoc_start->DataRate[3]); | 865 | adhoc_start->data_rate[2], adhoc_start->data_rate[3]); |
867 | 866 | ||
868 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n"); | 867 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n"); |
869 | 868 | ||
@@ -914,55 +913,40 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, | |||
914 | } | 913 | } |
915 | 914 | ||
916 | if (adapter->adhoc_11n_enabled) { | 915 | if (adapter->adhoc_11n_enabled) { |
917 | { | 916 | /* Fill HT CAPABILITY */ |
918 | ht_cap = (struct mwifiex_ie_types_htcap *) pos; | 917 | ht_cap = (struct mwifiex_ie_types_htcap *) pos; |
919 | memset(ht_cap, 0, | 918 | memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap)); |
920 | sizeof(struct mwifiex_ie_types_htcap)); | 919 | ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); |
921 | ht_cap->header.type = | 920 | ht_cap->header.len = |
922 | cpu_to_le16(WLAN_EID_HT_CAPABILITY); | 921 | cpu_to_le16(sizeof(struct ieee80211_ht_cap)); |
923 | ht_cap->header.len = | 922 | radio_type = mwifiex_band_to_radio_type( |
924 | cpu_to_le16(sizeof(struct ieee80211_ht_cap)); | 923 | priv->adapter->config_bands); |
925 | ht_cap_info = le16_to_cpu(ht_cap->ht_cap.cap_info); | 924 | mwifiex_fill_cap_info(priv, radio_type, ht_cap); |
926 | 925 | ||
927 | ht_cap_info |= IEEE80211_HT_CAP_SGI_20; | 926 | pos += sizeof(struct mwifiex_ie_types_htcap); |
928 | if (adapter->chan_offset) { | 927 | cmd_append_size += |
929 | ht_cap_info |= IEEE80211_HT_CAP_SGI_40; | 928 | sizeof(struct mwifiex_ie_types_htcap); |
930 | ht_cap_info |= IEEE80211_HT_CAP_DSSSCCK40; | ||
931 | ht_cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||
932 | SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask); | ||
933 | } | ||
934 | 929 | ||
935 | ht_cap->ht_cap.ampdu_params_info | 930 | /* Fill HT INFORMATION */ |
936 | = IEEE80211_HT_MAX_AMPDU_64K; | 931 | ht_info = (struct mwifiex_ie_types_htinfo *) pos; |
937 | ht_cap->ht_cap.mcs.rx_mask[0] = 0xff; | 932 | memset(ht_info, 0, sizeof(struct mwifiex_ie_types_htinfo)); |
938 | pos += sizeof(struct mwifiex_ie_types_htcap); | 933 | ht_info->header.type = cpu_to_le16(WLAN_EID_HT_INFORMATION); |
939 | cmd_append_size += | 934 | ht_info->header.len = |
940 | sizeof(struct mwifiex_ie_types_htcap); | 935 | cpu_to_le16(sizeof(struct ieee80211_ht_info)); |
941 | } | 936 | |
942 | { | 937 | ht_info->ht_info.control_chan = |
943 | ht_info = (struct mwifiex_ie_types_htinfo *) pos; | 938 | (u8) priv->curr_bss_params.bss_descriptor.channel; |
944 | memset(ht_info, 0, | 939 | if (adapter->chan_offset) { |
945 | sizeof(struct mwifiex_ie_types_htinfo)); | 940 | ht_info->ht_info.ht_param = adapter->chan_offset; |
946 | ht_info->header.type = | 941 | ht_info->ht_info.ht_param |= |
947 | cpu_to_le16(WLAN_EID_HT_INFORMATION); | ||
948 | ht_info->header.len = | ||
949 | cpu_to_le16(sizeof(struct ieee80211_ht_info)); | ||
950 | ht_info->ht_info.control_chan = | ||
951 | (u8) priv->curr_bss_params.bss_descriptor. | ||
952 | channel; | ||
953 | if (adapter->chan_offset) { | ||
954 | ht_info->ht_info.ht_param = | ||
955 | adapter->chan_offset; | ||
956 | ht_info->ht_info.ht_param |= | ||
957 | IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; | 942 | IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; |
958 | } | ||
959 | ht_info->ht_info.operation_mode = | ||
960 | cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); | ||
961 | ht_info->ht_info.basic_set[0] = 0xff; | ||
962 | pos += sizeof(struct mwifiex_ie_types_htinfo); | ||
963 | cmd_append_size += | ||
964 | sizeof(struct mwifiex_ie_types_htinfo); | ||
965 | } | 943 | } |
944 | ht_info->ht_info.operation_mode = | ||
945 | cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); | ||
946 | ht_info->ht_info.basic_set[0] = 0xff; | ||
947 | pos += sizeof(struct mwifiex_ie_types_htinfo); | ||
948 | cmd_append_size += | ||
949 | sizeof(struct mwifiex_ie_types_htinfo); | ||
966 | } | 950 | } |
967 | 951 | ||
968 | cmd->size = cpu_to_le16((u16) | 952 | cmd->size = cpu_to_le16((u16) |
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index d34acf082d3a..a2f32008f9a8 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c | |||
@@ -386,7 +386,6 @@ static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) | |||
386 | card->txbd_ring_vbase = kzalloc(card->txbd_ring_size, GFP_KERNEL); | 386 | card->txbd_ring_vbase = kzalloc(card->txbd_ring_size, GFP_KERNEL); |
387 | if (!card->txbd_ring_vbase) { | 387 | if (!card->txbd_ring_vbase) { |
388 | dev_err(adapter->dev, "Unable to allocate buffer for txbd ring.\n"); | 388 | dev_err(adapter->dev, "Unable to allocate buffer for txbd ring.\n"); |
389 | kfree(card->txbd_ring_vbase); | ||
390 | return -1; | 389 | return -1; |
391 | } | 390 | } |
392 | card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase); | 391 | card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase); |
@@ -1229,9 +1228,12 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, | |||
1229 | if (!skb) | 1228 | if (!skb) |
1230 | return 0; | 1229 | return 0; |
1231 | 1230 | ||
1232 | if (rdptr >= MWIFIEX_MAX_EVT_BD) | 1231 | if (rdptr >= MWIFIEX_MAX_EVT_BD) { |
1233 | dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n", | 1232 | dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n", |
1234 | rdptr); | 1233 | rdptr); |
1234 | ret = -EINVAL; | ||
1235 | goto done; | ||
1236 | } | ||
1235 | 1237 | ||
1236 | /* Read the event ring write pointer set by firmware */ | 1238 | /* Read the event ring write pointer set by firmware */ |
1237 | if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) { | 1239 | if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) { |
@@ -1672,9 +1674,8 @@ static int mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type, | |||
1672 | struct sk_buff *skb, | 1674 | struct sk_buff *skb, |
1673 | struct mwifiex_tx_param *tx_param) | 1675 | struct mwifiex_tx_param *tx_param) |
1674 | { | 1676 | { |
1675 | if (!adapter || !skb) { | 1677 | if (!skb) { |
1676 | dev_err(adapter->dev, "Invalid parameter in %s <%p, %p>\n", | 1678 | dev_err(adapter->dev, "Passed NULL skb to %s\n", __func__); |
1677 | __func__, adapter, skb); | ||
1678 | return -1; | 1679 | return -1; |
1679 | } | 1680 | } |
1680 | 1681 | ||
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 8d3ab378662b..b8b9d37b01a9 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c | |||
@@ -1537,11 +1537,6 @@ done: | |||
1537 | return 0; | 1537 | return 0; |
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | static void mwifiex_free_bss_priv(struct cfg80211_bss *bss) | ||
1541 | { | ||
1542 | kfree(bss->priv); | ||
1543 | } | ||
1544 | |||
1545 | /* | 1540 | /* |
1546 | * This function handles the command response of scan. | 1541 | * This function handles the command response of scan. |
1547 | * | 1542 | * |
@@ -1767,7 +1762,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, | |||
1767 | cap_info_bitmap, beacon_period, | 1762 | cap_info_bitmap, beacon_period, |
1768 | ie_buf, ie_len, rssi, GFP_KERNEL); | 1763 | ie_buf, ie_len, rssi, GFP_KERNEL); |
1769 | *(u8 *)bss->priv = band; | 1764 | *(u8 *)bss->priv = band; |
1770 | bss->free_priv = mwifiex_free_bss_priv; | 1765 | cfg80211_put_bss(bss); |
1771 | 1766 | ||
1772 | if (priv->media_connected && !memcmp(bssid, | 1767 | if (priv->media_connected && !memcmp(bssid, |
1773 | priv->curr_bss_params.bss_descriptor | 1768 | priv->curr_bss_params.bss_descriptor |
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 283171bbcedf..ffaf3f3a57df 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c | |||
@@ -1630,14 +1630,14 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) | |||
1630 | card->mpa_tx.pkt_cnt = 0; | 1630 | card->mpa_tx.pkt_cnt = 0; |
1631 | card->mpa_tx.start_port = 0; | 1631 | card->mpa_tx.start_port = 0; |
1632 | 1632 | ||
1633 | card->mpa_tx.enabled = 0; | 1633 | card->mpa_tx.enabled = 1; |
1634 | card->mpa_tx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; | 1634 | card->mpa_tx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; |
1635 | 1635 | ||
1636 | card->mpa_rx.buf_len = 0; | 1636 | card->mpa_rx.buf_len = 0; |
1637 | card->mpa_rx.pkt_cnt = 0; | 1637 | card->mpa_rx.pkt_cnt = 0; |
1638 | card->mpa_rx.start_port = 0; | 1638 | card->mpa_rx.start_port = 0; |
1639 | 1639 | ||
1640 | card->mpa_rx.enabled = 0; | 1640 | card->mpa_rx.enabled = 1; |
1641 | card->mpa_rx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; | 1641 | card->mpa_rx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; |
1642 | 1642 | ||
1643 | /* Allocate buffers for SDIO MP-A */ | 1643 | /* Allocate buffers for SDIO MP-A */ |
diff --git a/drivers/net/wireless/mwifiex/sta_rx.c b/drivers/net/wireless/mwifiex/sta_rx.c index 27430512f7cd..5e1ef7e5da4f 100644 --- a/drivers/net/wireless/mwifiex/sta_rx.c +++ b/drivers/net/wireless/mwifiex/sta_rx.c | |||
@@ -126,6 +126,9 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, | |||
126 | u16 rx_pkt_type; | 126 | u16 rx_pkt_type; |
127 | struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; | 127 | struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; |
128 | 128 | ||
129 | if (!priv) | ||
130 | return -1; | ||
131 | |||
129 | local_rx_pd = (struct rxpd *) (skb->data); | 132 | local_rx_pd = (struct rxpd *) (skb->data); |
130 | rx_pkt_type = local_rx_pd->rx_pkt_type; | 133 | rx_pkt_type = local_rx_pd->rx_pkt_type; |
131 | 134 | ||
@@ -189,12 +192,11 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, | |||
189 | (u8) local_rx_pd->rx_pkt_type, | 192 | (u8) local_rx_pd->rx_pkt_type, |
190 | skb); | 193 | skb); |
191 | 194 | ||
192 | if (ret || (rx_pkt_type == PKT_TYPE_BAR)) { | 195 | if (ret || (rx_pkt_type == PKT_TYPE_BAR)) |
193 | if (priv && (ret == -1)) | ||
194 | priv->stats.rx_dropped++; | ||
195 | |||
196 | dev_kfree_skb_any(skb); | 196 | dev_kfree_skb_any(skb); |
197 | } | 197 | |
198 | if (ret) | ||
199 | priv->stats.rx_dropped++; | ||
198 | 200 | ||
199 | return ret; | 201 | return ret; |
200 | } | 202 | } |
diff --git a/drivers/net/wireless/orinoco/scan.c b/drivers/net/wireless/orinoco/scan.c index e99ca1c1e0d8..96e39edfec77 100644 --- a/drivers/net/wireless/orinoco/scan.c +++ b/drivers/net/wireless/orinoco/scan.c | |||
@@ -76,6 +76,7 @@ static void orinoco_add_hostscan_result(struct orinoco_private *priv, | |||
76 | { | 76 | { |
77 | struct wiphy *wiphy = priv_to_wiphy(priv); | 77 | struct wiphy *wiphy = priv_to_wiphy(priv); |
78 | struct ieee80211_channel *channel; | 78 | struct ieee80211_channel *channel; |
79 | struct cfg80211_bss *cbss; | ||
79 | u8 *ie; | 80 | u8 *ie; |
80 | u8 ie_buf[46]; | 81 | u8 ie_buf[46]; |
81 | u64 timestamp; | 82 | u64 timestamp; |
@@ -121,9 +122,10 @@ static void orinoco_add_hostscan_result(struct orinoco_private *priv, | |||
121 | beacon_interval = le16_to_cpu(bss->a.beacon_interv); | 122 | beacon_interval = le16_to_cpu(bss->a.beacon_interv); |
122 | signal = SIGNAL_TO_MBM(le16_to_cpu(bss->a.level)); | 123 | signal = SIGNAL_TO_MBM(le16_to_cpu(bss->a.level)); |
123 | 124 | ||
124 | cfg80211_inform_bss(wiphy, channel, bss->a.bssid, timestamp, | 125 | cbss = cfg80211_inform_bss(wiphy, channel, bss->a.bssid, timestamp, |
125 | capability, beacon_interval, ie_buf, ie_len, | 126 | capability, beacon_interval, ie_buf, ie_len, |
126 | signal, GFP_KERNEL); | 127 | signal, GFP_KERNEL); |
128 | cfg80211_put_bss(cbss); | ||
127 | } | 129 | } |
128 | 130 | ||
129 | void orinoco_add_extscan_result(struct orinoco_private *priv, | 131 | void orinoco_add_extscan_result(struct orinoco_private *priv, |
@@ -132,6 +134,7 @@ void orinoco_add_extscan_result(struct orinoco_private *priv, | |||
132 | { | 134 | { |
133 | struct wiphy *wiphy = priv_to_wiphy(priv); | 135 | struct wiphy *wiphy = priv_to_wiphy(priv); |
134 | struct ieee80211_channel *channel; | 136 | struct ieee80211_channel *channel; |
137 | struct cfg80211_bss *cbss; | ||
135 | const u8 *ie; | 138 | const u8 *ie; |
136 | u64 timestamp; | 139 | u64 timestamp; |
137 | s32 signal; | 140 | s32 signal; |
@@ -152,9 +155,10 @@ void orinoco_add_extscan_result(struct orinoco_private *priv, | |||
152 | ie = bss->data; | 155 | ie = bss->data; |
153 | signal = SIGNAL_TO_MBM(bss->level); | 156 | signal = SIGNAL_TO_MBM(bss->level); |
154 | 157 | ||
155 | cfg80211_inform_bss(wiphy, channel, bss->bssid, timestamp, | 158 | cbss = cfg80211_inform_bss(wiphy, channel, bss->bssid, timestamp, |
156 | capability, beacon_interval, ie, ie_len, | 159 | capability, beacon_interval, ie, ie_len, |
157 | signal, GFP_KERNEL); | 160 | signal, GFP_KERNEL); |
161 | cfg80211_put_bss(cbss); | ||
158 | } | 162 | } |
159 | 163 | ||
160 | void orinoco_add_hostscan_results(struct orinoco_private *priv, | 164 | void orinoco_add_hostscan_results(struct orinoco_private *priv, |
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 0c13840a7de5..620e3c0e88e0 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c | |||
@@ -414,6 +414,7 @@ struct ndis_80211_pmkid { | |||
414 | #define RNDIS_WLAN_ALG_TKIP (1<<1) | 414 | #define RNDIS_WLAN_ALG_TKIP (1<<1) |
415 | #define RNDIS_WLAN_ALG_CCMP (1<<2) | 415 | #define RNDIS_WLAN_ALG_CCMP (1<<2) |
416 | 416 | ||
417 | #define RNDIS_WLAN_NUM_KEYS 4 | ||
417 | #define RNDIS_WLAN_KEY_MGMT_NONE 0 | 418 | #define RNDIS_WLAN_KEY_MGMT_NONE 0 |
418 | #define RNDIS_WLAN_KEY_MGMT_802_1X (1<<0) | 419 | #define RNDIS_WLAN_KEY_MGMT_802_1X (1<<0) |
419 | #define RNDIS_WLAN_KEY_MGMT_PSK (1<<1) | 420 | #define RNDIS_WLAN_KEY_MGMT_PSK (1<<1) |
@@ -516,7 +517,7 @@ struct rndis_wlan_private { | |||
516 | 517 | ||
517 | /* encryption stuff */ | 518 | /* encryption stuff */ |
518 | int encr_tx_key_index; | 519 | int encr_tx_key_index; |
519 | struct rndis_wlan_encr_key encr_keys[4]; | 520 | struct rndis_wlan_encr_key encr_keys[RNDIS_WLAN_NUM_KEYS]; |
520 | int wpa_version; | 521 | int wpa_version; |
521 | 522 | ||
522 | u8 command_buffer[COMMAND_BUFFER_SIZE]; | 523 | u8 command_buffer[COMMAND_BUFFER_SIZE]; |
@@ -1535,6 +1536,9 @@ static int remove_key(struct usbnet *usbdev, int index, const u8 *bssid) | |||
1535 | bool is_wpa; | 1536 | bool is_wpa; |
1536 | int ret; | 1537 | int ret; |
1537 | 1538 | ||
1539 | if (index >= RNDIS_WLAN_NUM_KEYS) | ||
1540 | return -ENOENT; | ||
1541 | |||
1538 | if (priv->encr_keys[index].len == 0) | 1542 | if (priv->encr_keys[index].len == 0) |
1539 | return 0; | 1543 | return 0; |
1540 | 1544 | ||
@@ -1972,11 +1976,12 @@ static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, | |||
1972 | return ret; | 1976 | return ret; |
1973 | } | 1977 | } |
1974 | 1978 | ||
1975 | static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev, | 1979 | static bool rndis_bss_info_update(struct usbnet *usbdev, |
1976 | struct ndis_80211_bssid_ex *bssid) | 1980 | struct ndis_80211_bssid_ex *bssid) |
1977 | { | 1981 | { |
1978 | struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); | 1982 | struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); |
1979 | struct ieee80211_channel *channel; | 1983 | struct ieee80211_channel *channel; |
1984 | struct cfg80211_bss *bss; | ||
1980 | s32 signal; | 1985 | s32 signal; |
1981 | u64 timestamp; | 1986 | u64 timestamp; |
1982 | u16 capability; | 1987 | u16 capability; |
@@ -2015,9 +2020,12 @@ static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev, | |||
2015 | capability = le16_to_cpu(fixed->capabilities); | 2020 | capability = le16_to_cpu(fixed->capabilities); |
2016 | beacon_interval = le16_to_cpu(fixed->beacon_interval); | 2021 | beacon_interval = le16_to_cpu(fixed->beacon_interval); |
2017 | 2022 | ||
2018 | return cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid->mac, | 2023 | bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid->mac, |
2019 | timestamp, capability, beacon_interval, ie, ie_len, signal, | 2024 | timestamp, capability, beacon_interval, ie, ie_len, signal, |
2020 | GFP_KERNEL); | 2025 | GFP_KERNEL); |
2026 | cfg80211_put_bss(bss); | ||
2027 | |||
2028 | return (bss != NULL); | ||
2021 | } | 2029 | } |
2022 | 2030 | ||
2023 | static struct ndis_80211_bssid_ex *next_bssid_list_item( | 2031 | static struct ndis_80211_bssid_ex *next_bssid_list_item( |
@@ -2451,6 +2459,9 @@ static int rndis_set_default_key(struct wiphy *wiphy, struct net_device *netdev, | |||
2451 | 2459 | ||
2452 | netdev_dbg(usbdev->net, "%s(%i)\n", __func__, key_index); | 2460 | netdev_dbg(usbdev->net, "%s(%i)\n", __func__, key_index); |
2453 | 2461 | ||
2462 | if (key_index >= RNDIS_WLAN_NUM_KEYS) | ||
2463 | return -ENOENT; | ||
2464 | |||
2454 | priv->encr_tx_key_index = key_index; | 2465 | priv->encr_tx_key_index = key_index; |
2455 | 2466 | ||
2456 | if (is_wpa_key(priv, key_index)) | 2467 | if (is_wpa_key(priv, key_index)) |
@@ -2641,6 +2652,7 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, | |||
2641 | struct ieee80211_channel *channel; | 2652 | struct ieee80211_channel *channel; |
2642 | struct ndis_80211_conf config; | 2653 | struct ndis_80211_conf config; |
2643 | struct ndis_80211_ssid ssid; | 2654 | struct ndis_80211_ssid ssid; |
2655 | struct cfg80211_bss *bss; | ||
2644 | s32 signal; | 2656 | s32 signal; |
2645 | u64 timestamp; | 2657 | u64 timestamp; |
2646 | u16 capability; | 2658 | u16 capability; |
@@ -2714,9 +2726,10 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, | |||
2714 | bssid, (u32)timestamp, capability, beacon_interval, ie_len, | 2726 | bssid, (u32)timestamp, capability, beacon_interval, ie_len, |
2715 | ssid.essid, signal); | 2727 | ssid.essid, signal); |
2716 | 2728 | ||
2717 | cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid, | 2729 | bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid, |
2718 | timestamp, capability, beacon_interval, ie_buf, ie_len, | 2730 | timestamp, capability, beacon_interval, ie_buf, ie_len, |
2719 | signal, GFP_KERNEL); | 2731 | signal, GFP_KERNEL); |
2732 | cfg80211_put_bss(bss); | ||
2720 | } | 2733 | } |
2721 | 2734 | ||
2722 | /* | 2735 | /* |
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index c244f2f1b83f..94a3e1706158 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | |||
@@ -275,6 +275,8 @@ static struct usb_device_id rtl8192c_usb_ids[] = { | |||
275 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8191, rtl92cu_hal_cfg)}, | 275 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8191, rtl92cu_hal_cfg)}, |
276 | 276 | ||
277 | /****** 8188CU ********/ | 277 | /****** 8188CU ********/ |
278 | /* RTL8188CTV */ | ||
279 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x018a, rtl92cu_hal_cfg)}, | ||
278 | /* 8188CE-VAU USB minCard */ | 280 | /* 8188CE-VAU USB minCard */ |
279 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8170, rtl92cu_hal_cfg)}, | 281 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8170, rtl92cu_hal_cfg)}, |
280 | /* 8188cu 1*1 dongle */ | 282 | /* 8188cu 1*1 dongle */ |
@@ -291,14 +293,14 @@ static struct usb_device_id rtl8192c_usb_ids[] = { | |||
291 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817e, rtl92cu_hal_cfg)}, | 293 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817e, rtl92cu_hal_cfg)}, |
292 | /* 8188RU in Alfa AWUS036NHR */ | 294 | /* 8188RU in Alfa AWUS036NHR */ |
293 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817f, rtl92cu_hal_cfg)}, | 295 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817f, rtl92cu_hal_cfg)}, |
296 | /* RTL8188CUS-VL */ | ||
297 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x818a, rtl92cu_hal_cfg)}, | ||
294 | /* 8188 Combo for BC4 */ | 298 | /* 8188 Combo for BC4 */ |
295 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8754, rtl92cu_hal_cfg)}, | 299 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8754, rtl92cu_hal_cfg)}, |
296 | 300 | ||
297 | /****** 8192CU ********/ | 301 | /****** 8192CU ********/ |
298 | /* 8191cu 1*2 */ | ||
299 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8177, rtl92cu_hal_cfg)}, | ||
300 | /* 8192cu 2*2 */ | 302 | /* 8192cu 2*2 */ |
301 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817b, rtl92cu_hal_cfg)}, | 303 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8178, rtl92cu_hal_cfg)}, |
302 | /* 8192CE-VAU USB minCard */ | 304 | /* 8192CE-VAU USB minCard */ |
303 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817c, rtl92cu_hal_cfg)}, | 305 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817c, rtl92cu_hal_cfg)}, |
304 | 306 | ||
@@ -309,13 +311,17 @@ static struct usb_device_id rtl8192c_usb_ids[] = { | |||
309 | {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ | 311 | {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ |
310 | {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ | 312 | {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ |
311 | {RTL_USB_DEVICE(0x0846, 0x9041, rtl92cu_hal_cfg)}, /*NetGear WNA1000M*/ | 313 | {RTL_USB_DEVICE(0x0846, 0x9041, rtl92cu_hal_cfg)}, /*NetGear WNA1000M*/ |
312 | {RTL_USB_DEVICE(0x0Df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ | 314 | {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ |
315 | {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ | ||
313 | {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/ | 316 | {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/ |
314 | /* HP - Lite-On ,8188CUS Slim Combo */ | 317 | /* HP - Lite-On ,8188CUS Slim Combo */ |
315 | {RTL_USB_DEVICE(0x103c, 0x1629, rtl92cu_hal_cfg)}, | 318 | {RTL_USB_DEVICE(0x103c, 0x1629, rtl92cu_hal_cfg)}, |
316 | {RTL_USB_DEVICE(0x13d3, 0x3357, rtl92cu_hal_cfg)}, /* AzureWave */ | 319 | {RTL_USB_DEVICE(0x13d3, 0x3357, rtl92cu_hal_cfg)}, /* AzureWave */ |
317 | {RTL_USB_DEVICE(0x2001, 0x3308, rtl92cu_hal_cfg)}, /*D-Link - Alpha*/ | 320 | {RTL_USB_DEVICE(0x2001, 0x3308, rtl92cu_hal_cfg)}, /*D-Link - Alpha*/ |
321 | {RTL_USB_DEVICE(0x2019, 0x4902, rtl92cu_hal_cfg)}, /*Planex - Etop*/ | ||
318 | {RTL_USB_DEVICE(0x2019, 0xab2a, rtl92cu_hal_cfg)}, /*Planex - Abocom*/ | 322 | {RTL_USB_DEVICE(0x2019, 0xab2a, rtl92cu_hal_cfg)}, /*Planex - Abocom*/ |
323 | /*SW-WF02-AD15 -Abocom*/ | ||
324 | {RTL_USB_DEVICE(0x2019, 0xab2e, rtl92cu_hal_cfg)}, | ||
319 | {RTL_USB_DEVICE(0x2019, 0xed17, rtl92cu_hal_cfg)}, /*PCI - Edimax*/ | 325 | {RTL_USB_DEVICE(0x2019, 0xed17, rtl92cu_hal_cfg)}, /*PCI - Edimax*/ |
320 | {RTL_USB_DEVICE(0x20f4, 0x648b, rtl92cu_hal_cfg)}, /*TRENDnet - Cameo*/ | 326 | {RTL_USB_DEVICE(0x20f4, 0x648b, rtl92cu_hal_cfg)}, /*TRENDnet - Cameo*/ |
321 | {RTL_USB_DEVICE(0x7392, 0x7811, rtl92cu_hal_cfg)}, /*Edimax - Edimax*/ | 327 | {RTL_USB_DEVICE(0x7392, 0x7811, rtl92cu_hal_cfg)}, /*Edimax - Edimax*/ |
@@ -326,14 +332,36 @@ static struct usb_device_id rtl8192c_usb_ids[] = { | |||
326 | {RTL_USB_DEVICE(0x4855, 0x0091, rtl92cu_hal_cfg)}, /* NetweeN-Feixun */ | 332 | {RTL_USB_DEVICE(0x4855, 0x0091, rtl92cu_hal_cfg)}, /* NetweeN-Feixun */ |
327 | {RTL_USB_DEVICE(0x9846, 0x9041, rtl92cu_hal_cfg)}, /* Netgear Cameo */ | 333 | {RTL_USB_DEVICE(0x9846, 0x9041, rtl92cu_hal_cfg)}, /* Netgear Cameo */ |
328 | 334 | ||
335 | /****** 8188 RU ********/ | ||
336 | /* Netcore */ | ||
337 | {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x317f, rtl92cu_hal_cfg)}, | ||
338 | |||
339 | /****** 8188CUS Slim Solo********/ | ||
340 | {RTL_USB_DEVICE(0x04f2, 0xaff7, rtl92cu_hal_cfg)}, /*Xavi*/ | ||
341 | {RTL_USB_DEVICE(0x04f2, 0xaff9, rtl92cu_hal_cfg)}, /*Xavi*/ | ||
342 | {RTL_USB_DEVICE(0x04f2, 0xaffa, rtl92cu_hal_cfg)}, /*Xavi*/ | ||
343 | |||
344 | /****** 8188CUS Slim Combo ********/ | ||
345 | {RTL_USB_DEVICE(0x04f2, 0xaff8, rtl92cu_hal_cfg)}, /*Xavi*/ | ||
346 | {RTL_USB_DEVICE(0x04f2, 0xaffb, rtl92cu_hal_cfg)}, /*Xavi*/ | ||
347 | {RTL_USB_DEVICE(0x04f2, 0xaffc, rtl92cu_hal_cfg)}, /*Xavi*/ | ||
348 | {RTL_USB_DEVICE(0x2019, 0x1201, rtl92cu_hal_cfg)}, /*Planex-Vencer*/ | ||
349 | |||
329 | /****** 8192CU ********/ | 350 | /****** 8192CU ********/ |
351 | {RTL_USB_DEVICE(0x050d, 0x2102, rtl92cu_hal_cfg)}, /*Belcom-Sercomm*/ | ||
352 | {RTL_USB_DEVICE(0x050d, 0x2103, rtl92cu_hal_cfg)}, /*Belcom-Edimax*/ | ||
330 | {RTL_USB_DEVICE(0x0586, 0x341f, rtl92cu_hal_cfg)}, /*Zyxel -Abocom*/ | 353 | {RTL_USB_DEVICE(0x0586, 0x341f, rtl92cu_hal_cfg)}, /*Zyxel -Abocom*/ |
331 | {RTL_USB_DEVICE(0x07aa, 0x0056, rtl92cu_hal_cfg)}, /*ATKK-Gemtek*/ | 354 | {RTL_USB_DEVICE(0x07aa, 0x0056, rtl92cu_hal_cfg)}, /*ATKK-Gemtek*/ |
332 | {RTL_USB_DEVICE(0x07b8, 0x8178, rtl92cu_hal_cfg)}, /*Funai -Abocom*/ | 355 | {RTL_USB_DEVICE(0x07b8, 0x8178, rtl92cu_hal_cfg)}, /*Funai -Abocom*/ |
356 | {RTL_USB_DEVICE(0x0846, 0x9021, rtl92cu_hal_cfg)}, /*Netgear-Sercomm*/ | ||
357 | {RTL_USB_DEVICE(0x0b05, 0x17ab, rtl92cu_hal_cfg)}, /*ASUS-Edimax*/ | ||
358 | {RTL_USB_DEVICE(0x0df6, 0x0061, rtl92cu_hal_cfg)}, /*Sitecom-Edimax*/ | ||
359 | {RTL_USB_DEVICE(0x0e66, 0x0019, rtl92cu_hal_cfg)}, /*Hawking-Edimax*/ | ||
333 | {RTL_USB_DEVICE(0x2001, 0x3307, rtl92cu_hal_cfg)}, /*D-Link-Cameo*/ | 360 | {RTL_USB_DEVICE(0x2001, 0x3307, rtl92cu_hal_cfg)}, /*D-Link-Cameo*/ |
334 | {RTL_USB_DEVICE(0x2001, 0x3309, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ | 361 | {RTL_USB_DEVICE(0x2001, 0x3309, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ |
335 | {RTL_USB_DEVICE(0x2001, 0x330a, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ | 362 | {RTL_USB_DEVICE(0x2001, 0x330a, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ |
336 | {RTL_USB_DEVICE(0x2019, 0xab2b, rtl92cu_hal_cfg)}, /*Planex -Abocom*/ | 363 | {RTL_USB_DEVICE(0x2019, 0xab2b, rtl92cu_hal_cfg)}, /*Planex -Abocom*/ |
364 | {RTL_USB_DEVICE(0x20f4, 0x624d, rtl92cu_hal_cfg)}, /*TRENDNet*/ | ||
337 | {RTL_USB_DEVICE(0x7392, 0x7822, rtl92cu_hal_cfg)}, /*Edimax -Edimax*/ | 365 | {RTL_USB_DEVICE(0x7392, 0x7822, rtl92cu_hal_cfg)}, /*Edimax -Edimax*/ |
338 | {} | 366 | {} |
339 | }; | 367 | }; |
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index 182562952c79..0b5c18feb303 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c | |||
@@ -165,7 +165,8 @@ static int xenvif_change_mtu(struct net_device *dev, int mtu) | |||
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
167 | 167 | ||
168 | static u32 xenvif_fix_features(struct net_device *dev, u32 features) | 168 | static netdev_features_t xenvif_fix_features(struct net_device *dev, |
169 | netdev_features_t features) | ||
169 | { | 170 | { |
170 | struct xenvif *vif = netdev_priv(dev); | 171 | struct xenvif *vif = netdev_priv(dev); |
171 | 172 | ||
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 226faab23603..4312db8cdeab 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
@@ -201,7 +201,7 @@ static void xennet_sysfs_delif(struct net_device *netdev); | |||
201 | #define xennet_sysfs_delif(dev) do { } while (0) | 201 | #define xennet_sysfs_delif(dev) do { } while (0) |
202 | #endif | 202 | #endif |
203 | 203 | ||
204 | static int xennet_can_sg(struct net_device *dev) | 204 | static bool xennet_can_sg(struct net_device *dev) |
205 | { | 205 | { |
206 | return dev->features & NETIF_F_SG; | 206 | return dev->features & NETIF_F_SG; |
207 | } | 207 | } |
@@ -1190,7 +1190,8 @@ static void xennet_uninit(struct net_device *dev) | |||
1190 | gnttab_free_grant_references(np->gref_rx_head); | 1190 | gnttab_free_grant_references(np->gref_rx_head); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | static u32 xennet_fix_features(struct net_device *dev, u32 features) | 1193 | static netdev_features_t xennet_fix_features(struct net_device *dev, |
1194 | netdev_features_t features) | ||
1194 | { | 1195 | { |
1195 | struct netfront_info *np = netdev_priv(dev); | 1196 | struct netfront_info *np = netdev_priv(dev); |
1196 | int val; | 1197 | int val; |
@@ -1216,7 +1217,8 @@ static u32 xennet_fix_features(struct net_device *dev, u32 features) | |||
1216 | return features; | 1217 | return features; |
1217 | } | 1218 | } |
1218 | 1219 | ||
1219 | static int xennet_set_features(struct net_device *dev, u32 features) | 1220 | static int xennet_set_features(struct net_device *dev, |
1221 | netdev_features_t features) | ||
1220 | { | 1222 | { |
1221 | if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) { | 1223 | if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) { |
1222 | netdev_info(dev, "Reducing MTU because no SG offload"); | 1224 | netdev_info(dev, "Reducing MTU because no SG offload"); |
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index 94f49ffa70ba..8af868bab20b 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c | |||
@@ -263,6 +263,11 @@ error: | |||
263 | return PTR_ERR(vqs[i]); | 263 | return PTR_ERR(vqs[i]); |
264 | } | 264 | } |
265 | 265 | ||
266 | static const char *kvm_bus_name(struct virtio_device *vdev) | ||
267 | { | ||
268 | return ""; | ||
269 | } | ||
270 | |||
266 | /* | 271 | /* |
267 | * The config ops structure as defined by virtio config | 272 | * The config ops structure as defined by virtio config |
268 | */ | 273 | */ |
@@ -276,6 +281,7 @@ static struct virtio_config_ops kvm_vq_configspace_ops = { | |||
276 | .reset = kvm_reset, | 281 | .reset = kvm_reset, |
277 | .find_vqs = kvm_find_vqs, | 282 | .find_vqs = kvm_find_vqs, |
278 | .del_vqs = kvm_del_vqs, | 283 | .del_vqs = kvm_del_vqs, |
284 | .bus_name = kvm_bus_name, | ||
279 | }; | 285 | }; |
280 | 286 | ||
281 | /* | 287 | /* |
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 4d5307ddbe55..63578925bc59 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c | |||
@@ -3209,7 +3209,8 @@ static int qeth_l3_stop(struct net_device *dev) | |||
3209 | return 0; | 3209 | return 0; |
3210 | } | 3210 | } |
3211 | 3211 | ||
3212 | static u32 qeth_l3_fix_features(struct net_device *dev, u32 features) | 3212 | static netdev_features_t qeth_l3_fix_features(struct net_device *dev, |
3213 | netdev_features_t features) | ||
3213 | { | 3214 | { |
3214 | struct qeth_card *card = dev->ml_priv; | 3215 | struct qeth_card *card = dev->ml_priv; |
3215 | 3216 | ||
@@ -3223,7 +3224,8 @@ static u32 qeth_l3_fix_features(struct net_device *dev, u32 features) | |||
3223 | return features; | 3224 | return features; |
3224 | } | 3225 | } |
3225 | 3226 | ||
3226 | static int qeth_l3_set_features(struct net_device *dev, u32 features) | 3227 | static int qeth_l3_set_features(struct net_device *dev, |
3228 | netdev_features_t features) | ||
3227 | { | 3229 | { |
3228 | struct qeth_card *card = dev->ml_priv; | 3230 | struct qeth_card *card = dev->ml_priv; |
3229 | u32 changed = dev->features ^ features; | 3231 | u32 changed = dev->features ^ features; |
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index acc5e43c373e..2f57380d7ed4 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c | |||
@@ -361,7 +361,12 @@ static int vm_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
361 | return 0; | 361 | return 0; |
362 | } | 362 | } |
363 | 363 | ||
364 | static const char *vm_bus_name(struct virtio_device *vdev) | ||
365 | { | ||
366 | struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); | ||
364 | 367 | ||
368 | return vm_dev->pdev->name; | ||
369 | } | ||
365 | 370 | ||
366 | static struct virtio_config_ops virtio_mmio_config_ops = { | 371 | static struct virtio_config_ops virtio_mmio_config_ops = { |
367 | .get = vm_get, | 372 | .get = vm_get, |
@@ -373,6 +378,7 @@ static struct virtio_config_ops virtio_mmio_config_ops = { | |||
373 | .del_vqs = vm_del_vqs, | 378 | .del_vqs = vm_del_vqs, |
374 | .get_features = vm_get_features, | 379 | .get_features = vm_get_features, |
375 | .finalize_features = vm_finalize_features, | 380 | .finalize_features = vm_finalize_features, |
381 | .bus_name = vm_bus_name, | ||
376 | }; | 382 | }; |
377 | 383 | ||
378 | 384 | ||
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index 3d1bf41e8892..91683e6e7af5 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -580,6 +580,13 @@ static int vp_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
580 | false, false); | 580 | false, false); |
581 | } | 581 | } |
582 | 582 | ||
583 | static const char *vp_bus_name(struct virtio_device *vdev) | ||
584 | { | ||
585 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | ||
586 | |||
587 | return pci_name(vp_dev->pci_dev); | ||
588 | } | ||
589 | |||
583 | static struct virtio_config_ops virtio_pci_config_ops = { | 590 | static struct virtio_config_ops virtio_pci_config_ops = { |
584 | .get = vp_get, | 591 | .get = vp_get, |
585 | .set = vp_set, | 592 | .set = vp_set, |
@@ -590,6 +597,7 @@ static struct virtio_config_ops virtio_pci_config_ops = { | |||
590 | .del_vqs = vp_del_vqs, | 597 | .del_vqs = vp_del_vqs, |
591 | .get_features = vp_get_features, | 598 | .get_features = vp_get_features, |
592 | .finalize_features = vp_finalize_features, | 599 | .finalize_features = vp_finalize_features, |
600 | .bus_name = vp_bus_name, | ||
593 | }; | 601 | }; |
594 | 602 | ||
595 | static void virtio_pci_release_dev(struct device *_d) | 603 | static void virtio_pci_release_dev(struct device *_d) |