Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes and more updates from David Miller:

1) Tunneling fixes from Tom Herbert and Alexander Duyck.

2) AF_UNIX updates some struct sock bit fields with the socket lock,
whereas setsockopt() sets overlapping ones with locking. Seperate
out the synchronized vs. the AF_UNIX unsynchronized ones to avoid
corruption. From Andrey Ryabinin.

3) Mount BPF filesystem with mount_nodev rather than mount_ns, from
Eric Biederman.

4) A couple kmemdup conversions, from Muhammad Falak R Wani.

5) BPF verifier fixes from Alexei Starovoitov.

6) Don't let tunneled UDP packets get stuck in socket queues, if
something goes wrong during the encapsulation just drop the packet
rather than signalling an error up the call stack. From Hannes
Frederic Sowa.

7) SKB ref after free in batman-adv, from Florian Westphal.

8) TCP iSCSI, ocfs2, rds, and tipc have to disable BH in it's TCP
callbacks since the TCP stack runs pre-emptibly now. From Eric
Dumazet.

9) Fix crash in fixed_phy_add, from Rabin Vincent.

10) Fix length checks in xen-netback, from Paul Durrant.

11) Fix mixup in KEY vs KEYID macsec attributes, from Sabrina Dubroca.

12) RDS connection spamming bug fixes from Sowmini Varadhan

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (152 commits)
net: suppress warnings on dev_alloc_skb
uapi glibc compat: fix compilation when !__USE_MISC in glibc
udp: prevent skbs lingering in tunnel socket queues
bpf: teach verifier to recognize imm += ptr pattern
bpf: support decreasing order in direct packet access
net: usb: ch9200: use kmemdup
ps3_gelic: use kmemdup
net:liquidio: use kmemdup
bpf: Use mount_nodev not mount_ns to mount the bpf filesystem
net: cdc_ncm: update datagram size after changing mtu
tuntap: correctly wake up process during uninit
intel: Add support for IPv6 IP-in-IP offload
ip6_gre: Do not allow segmentation offloads GRE_CSUM is enabled with FOU/GUE
RDS: TCP: Avoid rds connection churn from rogue SYNs
RDS: TCP: rds_tcp_accept_worker() must exit gracefully when terminating rds-tcp
net: sock: move ->sk_shutdown out of bitfields.
ipv6: Don't reset inner headers in ip6_tnl_xmit
ip4ip6: Support for GSO/GRO
ip6ip6: Support for GSO/GRO
ipv6: Set features for IPv6 tunnels
...

+7723 -5220
-3
Documentation/devicetree/bindings/net/phy.txt
··· 35 35 - broken-turn-around: If set, indicates the PHY device does not correctly 36 36 release the turn around line low at the end of a MDIO transaction. 37 37 38 - - reset-gpios: Reference to a GPIO used to reset the phy. 39 - 40 38 Example: 41 39 42 40 ethernet-phy@0 { ··· 42 44 interrupt-parent = <40000>; 43 45 interrupts = <35 1>; 44 46 reg = <0>; 45 - reset-gpios = <&gpio1 17 GPIO_ACTIVE_LOW>; 46 47 };
+1
MAINTAINERS
··· 5902 5902 INTEL WIRELESS WIFI LINK (iwlwifi) 5903 5903 M: Johannes Berg <johannes.berg@intel.com> 5904 5904 M: Emmanuel Grumbach <emmanuel.grumbach@intel.com> 5905 + M: Luca Coelho <luciano.coelho@intel.com> 5905 5906 M: Intel Linux Wireless <linuxwifi@intel.com> 5906 5907 L: linux-wireless@vger.kernel.org 5907 5908 W: http://intellinuxwireless.org
+10 -11
drivers/net/Space.c
··· 35 35 #include <net/Space.h> 36 36 37 37 /* A unified ethernet device probe. This is the easiest way to have every 38 - ethernet adaptor have the name "eth[0123...]". 39 - */ 38 + * ethernet adaptor have the name "eth[0123...]". 39 + */ 40 40 41 41 struct devprobe2 { 42 42 struct net_device *(*probe)(int unit); ··· 46 46 static int __init probe_list2(int unit, struct devprobe2 *p, int autoprobe) 47 47 { 48 48 struct net_device *dev; 49 + 49 50 for (; p->probe; p++) { 50 51 if (autoprobe && p->status) 51 52 continue; ··· 59 58 return -ENODEV; 60 59 } 61 60 62 - /* 63 - * ISA probes that touch addresses < 0x400 (including those that also 61 + /* ISA probes that touch addresses < 0x400 (including those that also 64 62 * look for EISA/PCI cards in addition to ISA cards). 65 63 */ 66 64 static struct devprobe2 isa_probes[] __initdata = { ··· 86 86 #endif 87 87 #ifdef CONFIG_CS89x0 88 88 #ifndef CONFIG_CS89x0_PLATFORM 89 - {cs89x0_probe, 0}, 89 + {cs89x0_probe, 0}, 90 90 #endif 91 91 #endif 92 - #if defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET) /* Intel I82596 */ 93 - {i82596_probe, 0}, 92 + #if defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET) /* Intel */ 93 + {i82596_probe, 0}, /* I82596 */ 94 94 #endif 95 95 #ifdef CONFIG_NI65 96 96 {ni65_probe, 0}, ··· 118 118 {mac8390_probe, 0}, 119 119 #endif 120 120 #ifdef CONFIG_MAC89x0 121 - {mac89x0_probe, 0}, 121 + {mac89x0_probe, 0}, 122 122 #endif 123 123 {NULL, 0}, 124 124 }; 125 125 126 - /* 127 - * Unified ethernet device probe, segmented per architecture and 126 + /* Unified ethernet device probe, segmented per architecture and 128 127 * per bus interface. This drives the legacy devices only for now. 129 128 */ 130 129 ··· 134 135 if (base_addr == 1) 135 136 return; 136 137 137 - (void)( probe_list2(unit, m68k_probes, base_addr == 0) && 138 + (void)(probe_list2(unit, m68k_probes, base_addr == 0) && 138 139 probe_list2(unit, isa_probes, base_addr == 0)); 139 140 } 140 141
+1 -1
drivers/net/ethernet/amd/au1000_eth.c
··· 1269 1269 aup->phy_irq = pd->phy_irq; 1270 1270 } 1271 1271 1272 - if (aup->phy_busid && aup->phy_busid > 0) { 1272 + if (aup->phy_busid > 0) { 1273 1273 dev_err(&pdev->dev, "MAC0-associated PHY attached 2nd MACs MII bus not supported yet\n"); 1274 1274 err = -ENODEV; 1275 1275 goto err_mdiobus_alloc;
+2 -3
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 13259 13259 NETIF_F_RXHASH | NETIF_F_HW_VLAN_CTAG_TX; 13260 13260 if (!chip_is_e1x) { 13261 13261 dev->hw_features |= NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL | 13262 - NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT; 13262 + NETIF_F_GSO_IPXIP4; 13263 13263 dev->hw_enc_features = 13264 13264 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | 13265 13265 NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | 13266 - NETIF_F_GSO_IPIP | 13267 - NETIF_F_GSO_SIT | 13266 + NETIF_F_GSO_IPXIP4 | 13268 13267 NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL; 13269 13268 } 13270 13269
+2 -3
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 6311 6311 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | 6312 6312 NETIF_F_TSO | NETIF_F_TSO6 | 6313 6313 NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE | 6314 - NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT | 6314 + NETIF_F_GSO_IPXIP4 | 6315 6315 NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM | 6316 6316 NETIF_F_GSO_PARTIAL | NETIF_F_RXHASH | 6317 6317 NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_GRO; ··· 6321 6321 NETIF_F_TSO | NETIF_F_TSO6 | 6322 6322 NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE | 6323 6323 NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM | 6324 - NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT | 6325 - NETIF_F_GSO_PARTIAL; 6324 + NETIF_F_GSO_IPXIP4 | NETIF_F_GSO_PARTIAL; 6326 6325 dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM | 6327 6326 NETIF_F_GSO_GRE_CSUM; 6328 6327 dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA;
+1 -3
drivers/net/ethernet/cavium/liquidio/octeon_device.c
··· 602 602 snprintf(oct->fw_info.liquidio_firmware_version, 32, "LIQUIDIO: %s", 603 603 h->version); 604 604 605 - buffer = kmalloc(size, GFP_KERNEL); 605 + buffer = kmemdup(data, size, GFP_KERNEL); 606 606 if (!buffer) 607 607 return -ENOMEM; 608 - 609 - memcpy(buffer, data, size); 610 608 611 609 p = buffer + sizeof(struct octeon_firmware_file_header); 612 610
+3 -1
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
··· 274 274 static void bgx_lmac_handler(struct net_device *netdev) 275 275 { 276 276 struct lmac *lmac = container_of(netdev, struct lmac, netdev); 277 - struct phy_device *phydev = lmac->phydev; 277 + struct phy_device *phydev; 278 278 int link_changed = 0; 279 279 280 280 if (!lmac) 281 281 return; 282 + 283 + phydev = lmac->phydev; 282 284 283 285 if (!phydev->link && lmac->last_link) 284 286 link_changed = -1;
+4 -5
drivers/net/ethernet/ibm/ehea/ehea_main.c
··· 1169 1169 ec = EHEA_BMASK_GET(NEQE_EVENT_CODE, eqe); 1170 1170 portnum = EHEA_BMASK_GET(NEQE_PORTNUM, eqe); 1171 1171 port = ehea_get_port(adapter, portnum); 1172 + if (!port) { 1173 + netdev_err(NULL, "unknown portnum %x\n", portnum); 1174 + return; 1175 + } 1172 1176 dev = port->netdev; 1173 1177 1174 1178 switch (ec) { 1175 1179 case EHEA_EC_PORTSTATE_CHG: /* port state change */ 1176 - 1177 - if (!port) { 1178 - netdev_err(dev, "unknown portnum %x\n", portnum); 1179 - break; 1180 - } 1181 1180 1182 1181 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) { 1183 1182 if (!netif_carrier_ok(dev)) {
+2 -2
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 9083 9083 NETIF_F_TSO6 | 9084 9084 NETIF_F_GSO_GRE | 9085 9085 NETIF_F_GSO_GRE_CSUM | 9086 - NETIF_F_GSO_IPIP | 9087 - NETIF_F_GSO_SIT | 9086 + NETIF_F_GSO_IPXIP4 | 9087 + NETIF_F_GSO_IPXIP6 | 9088 9088 NETIF_F_GSO_UDP_TUNNEL | 9089 9089 NETIF_F_GSO_UDP_TUNNEL_CSUM | 9090 9090 NETIF_F_GSO_PARTIAL |
+2 -2
drivers/net/ethernet/intel/i40e/i40e_txrx.c
··· 2284 2284 2285 2285 if (skb_shinfo(skb)->gso_type & (SKB_GSO_GRE | 2286 2286 SKB_GSO_GRE_CSUM | 2287 - SKB_GSO_IPIP | 2288 - SKB_GSO_SIT | 2287 + SKB_GSO_IPXIP4 | 2288 + SKB_GSO_IPXIP6 | 2289 2289 SKB_GSO_UDP_TUNNEL | 2290 2290 SKB_GSO_UDP_TUNNEL_CSUM)) { 2291 2291 if (!(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) &&
+2 -2
drivers/net/ethernet/intel/i40evf/i40e_txrx.c
··· 1559 1559 1560 1560 if (skb_shinfo(skb)->gso_type & (SKB_GSO_GRE | 1561 1561 SKB_GSO_GRE_CSUM | 1562 - SKB_GSO_IPIP | 1563 - SKB_GSO_SIT | 1562 + SKB_GSO_IPXIP4 | 1563 + SKB_GSO_IPXIP6 | 1564 1564 SKB_GSO_UDP_TUNNEL | 1565 1565 SKB_GSO_UDP_TUNNEL_CSUM)) { 1566 1566 if (!(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) &&
+2 -2
drivers/net/ethernet/intel/i40evf/i40evf_main.c
··· 2230 2230 NETIF_F_TSO6 | 2231 2231 NETIF_F_GSO_GRE | 2232 2232 NETIF_F_GSO_GRE_CSUM | 2233 - NETIF_F_GSO_IPIP | 2234 - NETIF_F_GSO_SIT | 2233 + NETIF_F_GSO_IPXIP4 | 2234 + NETIF_F_GSO_IPXIP6 | 2235 2235 NETIF_F_GSO_UDP_TUNNEL | 2236 2236 NETIF_F_GSO_UDP_TUNNEL_CSUM | 2237 2237 NETIF_F_GSO_PARTIAL |
+2 -2
drivers/net/ethernet/intel/igb/igb_main.c
··· 2418 2418 2419 2419 #define IGB_GSO_PARTIAL_FEATURES (NETIF_F_GSO_GRE | \ 2420 2420 NETIF_F_GSO_GRE_CSUM | \ 2421 - NETIF_F_GSO_IPIP | \ 2422 - NETIF_F_GSO_SIT | \ 2421 + NETIF_F_GSO_IPXIP4 | \ 2422 + NETIF_F_GSO_IPXIP6 | \ 2423 2423 NETIF_F_GSO_UDP_TUNNEL | \ 2424 2424 NETIF_F_GSO_UDP_TUNNEL_CSUM) 2425 2425
+2 -2
drivers/net/ethernet/intel/igbvf/netdev.c
··· 2763 2763 2764 2764 #define IGBVF_GSO_PARTIAL_FEATURES (NETIF_F_GSO_GRE | \ 2765 2765 NETIF_F_GSO_GRE_CSUM | \ 2766 - NETIF_F_GSO_IPIP | \ 2767 - NETIF_F_GSO_SIT | \ 2766 + NETIF_F_GSO_IPXIP4 | \ 2767 + NETIF_F_GSO_IPXIP6 | \ 2768 2768 NETIF_F_GSO_UDP_TUNNEL | \ 2769 2769 NETIF_F_GSO_UDP_TUNNEL_CSUM) 2770 2770
+2 -2
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 9482 9482 9483 9483 #define IXGBE_GSO_PARTIAL_FEATURES (NETIF_F_GSO_GRE | \ 9484 9484 NETIF_F_GSO_GRE_CSUM | \ 9485 - NETIF_F_GSO_IPIP | \ 9486 - NETIF_F_GSO_SIT | \ 9485 + NETIF_F_GSO_IPXIP4 | \ 9486 + NETIF_F_GSO_IPXIP6 | \ 9487 9487 NETIF_F_GSO_UDP_TUNNEL | \ 9488 9488 NETIF_F_GSO_UDP_TUNNEL_CSUM) 9489 9489
+2 -2
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
··· 4062 4062 4063 4063 #define IXGBEVF_GSO_PARTIAL_FEATURES (NETIF_F_GSO_GRE | \ 4064 4064 NETIF_F_GSO_GRE_CSUM | \ 4065 - NETIF_F_GSO_IPIP | \ 4066 - NETIF_F_GSO_SIT | \ 4065 + NETIF_F_GSO_IPXIP4 | \ 4066 + NETIF_F_GSO_IPXIP6 | \ 4067 4067 NETIF_F_GSO_UDP_TUNNEL | \ 4068 4068 NETIF_F_GSO_UDP_TUNNEL_CSUM) 4069 4069
+3 -4
drivers/net/ethernet/qlogic/qede/qede_main.c
··· 1076 1076 * start until its over and we don't want to risk allocation failing 1077 1077 * here, so re-allocate when aggregation will be over. 1078 1078 */ 1079 - dma_unmap_addr_set(sw_rx_data_prod, mapping, 1080 - dma_unmap_addr(replace_buf, mapping)); 1079 + sw_rx_data_prod->mapping = replace_buf->mapping; 1081 1080 1082 1081 sw_rx_data_prod->data = replace_buf->data; 1083 1082 rx_bd_prod->addr.hi = cpu_to_le32(upper_32_bits(mapping)); ··· 2654 2655 2655 2656 if (replace_buf->data) { 2656 2657 dma_unmap_page(&edev->pdev->dev, 2657 - dma_unmap_addr(replace_buf, mapping), 2658 + replace_buf->mapping, 2658 2659 PAGE_SIZE, DMA_FROM_DEVICE); 2659 2660 __free_page(replace_buf->data); 2660 2661 } ··· 2754 2755 goto err; 2755 2756 } 2756 2757 2757 - dma_unmap_addr_set(replace_buf, mapping, mapping); 2758 + replace_buf->mapping = mapping; 2758 2759 tpa_info->replace_buf.page_offset = 0; 2759 2760 2760 2761 tpa_info->replace_buf_mapping = mapping;
+2 -2
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
··· 1616 1616 target->valid = 1; 1617 1617 target->eurus_index = i; 1618 1618 kfree(target->hwinfo); 1619 - target->hwinfo = kzalloc(be16_to_cpu(scan_info->size), 1619 + target->hwinfo = kmemdup(scan_info, 1620 + be16_to_cpu(scan_info->size), 1620 1621 GFP_KERNEL); 1621 1622 if (!target->hwinfo) 1622 1623 continue; 1623 1624 1624 1625 /* copy hw scan info */ 1625 - memcpy(target->hwinfo, scan_info, be16_to_cpu(scan_info->size)); 1626 1626 target->essid_len = strnlen(scan_info->essid, 1627 1627 sizeof(scan_info->essid)); 1628 1628 target->rate_len = 0;
+3 -7
drivers/net/geneve.c
··· 335 335 336 336 /* Need Geneve and inner Ethernet header to be present */ 337 337 if (unlikely(!pskb_may_pull(skb, GENEVE_BASE_HLEN))) 338 - goto error; 338 + goto drop; 339 339 340 340 /* Return packets with reserved bits set */ 341 341 geneveh = geneve_hdr(skb); 342 342 if (unlikely(geneveh->ver != GENEVE_VER)) 343 - goto error; 343 + goto drop; 344 344 345 345 if (unlikely(geneveh->proto_type != htons(ETH_P_TEB))) 346 - goto error; 346 + goto drop; 347 347 348 348 gs = rcu_dereference_sk_user_data(sk); 349 349 if (!gs) ··· 366 366 /* Consume bad packet */ 367 367 kfree_skb(skb); 368 368 return 0; 369 - 370 - error: 371 - /* Let the UDP layer deal with the skb */ 372 - return 1; 373 369 } 374 370 375 371 static struct socket *geneve_create_sock(struct net *net, bool ipv6,
-1
drivers/net/ieee802154/adf7242.c
··· 915 915 (stat & 0xf) == RC_STATUS_PHY_RDY ? "RC_STATUS_PHY_RDY" : "", 916 916 (stat & 0xf) == RC_STATUS_RX ? "RC_STATUS_RX" : "", 917 917 (stat & 0xf) == RC_STATUS_TX ? "RC_STATUS_TX" : ""); 918 - } 919 918 #endif 920 919 } 921 920
+2 -1
drivers/net/irda/nsc-ircc.c
··· 1253 1253 */ 1254 1254 static __u8 nsc_ircc_change_speed(struct nsc_ircc_cb *self, __u32 speed) 1255 1255 { 1256 - struct net_device *dev = self->netdev; 1256 + struct net_device *dev; 1257 1257 __u8 mcr = MCR_SIR; 1258 1258 int iobase; 1259 1259 __u8 bank; ··· 1263 1263 1264 1264 IRDA_ASSERT(self != NULL, return 0;); 1265 1265 1266 + dev = self->netdev; 1266 1267 iobase = self->io.fir_base; 1267 1268 1268 1269 /* Update accounting for new speed */
+2 -2
drivers/net/macsec.c
··· 1646 1646 if (tb_sa[MACSEC_SA_ATTR_ACTIVE]) 1647 1647 rx_sa->active = !!nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]); 1648 1648 1649 - nla_memcpy(rx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEY], MACSEC_KEYID_LEN); 1649 + nla_memcpy(rx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); 1650 1650 rx_sa->sc = rx_sc; 1651 1651 rcu_assign_pointer(rx_sc->sa[assoc_num], rx_sa); 1652 1652 ··· 1785 1785 return -ENOMEM; 1786 1786 } 1787 1787 1788 - nla_memcpy(tx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEY], MACSEC_KEYID_LEN); 1788 + nla_memcpy(tx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); 1789 1789 1790 1790 spin_lock_bh(&tx_sa->lock); 1791 1791 tx_sa->next_pn = nla_get_u32(tb_sa[MACSEC_SA_ATTR_PN]);
+5 -1
drivers/net/phy/fixed_phy.c
··· 255 255 256 256 memset(fp->regs, 0xFF, sizeof(fp->regs[0]) * MII_REGS_NUM); 257 257 258 - fmb->mii_bus->irq[phy_addr] = irq; 258 + if (irq != PHY_POLL) 259 + fmb->mii_bus->irq[phy_addr] = irq; 259 260 260 261 fp->addr = phy_addr; 261 262 fp->status = *status; ··· 314 313 struct phy_device *phy; 315 314 int phy_addr; 316 315 int ret; 316 + 317 + if (!fmb->mii_bus || fmb->mii_bus->state != MDIOBUS_REGISTERED) 318 + return ERR_PTR(-EPROBE_DEFER); 317 319 318 320 /* Get the next available PHY address, up to PHY_MAX_ADDR */ 319 321 spin_lock(&phy_fixed_addr_lock);
-8
drivers/net/phy/phy_device.c
··· 34 34 #include <linux/io.h> 35 35 #include <linux/uaccess.h> 36 36 #include <linux/of.h> 37 - #include <linux/gpio/consumer.h> 38 37 39 38 #include <asm/irq.h> 40 39 ··· 1570 1571 struct device_driver *drv = phydev->mdio.dev.driver; 1571 1572 struct phy_driver *phydrv = to_phy_driver(drv); 1572 1573 int err = 0; 1573 - struct gpio_descs *reset_gpios; 1574 1574 1575 1575 phydev->drv = phydrv; 1576 - 1577 - /* take phy out of reset */ 1578 - reset_gpios = devm_gpiod_get_array_optional(dev, "reset", 1579 - GPIOD_OUT_LOW); 1580 - if (IS_ERR(reset_gpios)) 1581 - return PTR_ERR(reset_gpios); 1582 1576 1583 1577 /* Disable the interrupt if the PHY doesn't support it 1584 1578 * but the interrupt is still a valid one
+3 -3
drivers/net/tun.c
··· 580 580 for (i = 0; i < n; i++) { 581 581 tfile = rtnl_dereference(tun->tfiles[i]); 582 582 BUG_ON(!tfile); 583 + tfile->socket.sk->sk_shutdown = RCV_SHUTDOWN; 583 584 tfile->socket.sk->sk_data_ready(tfile->socket.sk); 584 585 RCU_INIT_POINTER(tfile->tun, NULL); 585 586 --tun->numqueues; 586 587 } 587 588 list_for_each_entry(tfile, &tun->disabled, next) { 589 + tfile->socket.sk->sk_shutdown = RCV_SHUTDOWN; 588 590 tfile->socket.sk->sk_data_ready(tfile->socket.sk); 589 591 RCU_INIT_POINTER(tfile->tun, NULL); 590 592 } ··· 643 641 goto out; 644 642 } 645 643 tfile->queue_index = tun->numqueues; 644 + tfile->socket.sk->sk_shutdown &= ~RCV_SHUTDOWN; 646 645 rcu_assign_pointer(tfile->tun, tun); 647 646 rcu_assign_pointer(tun->tfiles[tun->numqueues], tfile); 648 647 tun->numqueues++; ··· 1493 1490 1494 1491 if (!iov_iter_count(to)) 1495 1492 return 0; 1496 - 1497 - if (tun->dev->reg_state != NETREG_REGISTERED) 1498 - return -EIO; 1499 1493 1500 1494 /* Read frames from queue */ 1501 1495 skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0,
+4 -2
drivers/net/usb/cdc_ncm.c
··· 740 740 int cdc_ncm_change_mtu(struct net_device *net, int new_mtu) 741 741 { 742 742 struct usbnet *dev = netdev_priv(net); 743 - struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; 744 - int maxmtu = ctx->max_datagram_size - cdc_ncm_eth_hlen(dev); 743 + int maxmtu = cdc_ncm_max_dgram_size(dev) - cdc_ncm_eth_hlen(dev); 745 744 746 745 if (new_mtu <= 0 || new_mtu > maxmtu) 747 746 return -EINVAL; 747 + 748 748 net->mtu = new_mtu; 749 + cdc_ncm_set_dgram_size(dev, new_mtu + cdc_ncm_eth_hlen(dev)); 750 + 749 751 return 0; 750 752 } 751 753 EXPORT_SYMBOL_GPL(cdc_ncm_change_mtu);
+1 -2
drivers/net/usb/ch9200.c
··· 155 155 index, size); 156 156 157 157 if (data) { 158 - buf = kmalloc(size, GFP_KERNEL); 158 + buf = kmemdup(data, size, GFP_KERNEL); 159 159 if (!buf) { 160 160 err = -ENOMEM; 161 161 goto err_out; 162 162 } 163 - memcpy(buf, data, size); 164 163 } 165 164 166 165 err = usb_control_msg(dev->udev,
+2 -2
drivers/net/vxlan.c
··· 1304 1304 1305 1305 /* Need UDP and VXLAN header to be present */ 1306 1306 if (!pskb_may_pull(skb, VXLAN_HLEN)) 1307 - return 1; 1307 + goto drop; 1308 1308 1309 1309 unparsed = *vxlan_hdr(skb); 1310 1310 /* VNI flag always required to be set */ ··· 1313 1313 ntohl(vxlan_hdr(skb)->vx_flags), 1314 1314 ntohl(vxlan_hdr(skb)->vx_vni)); 1315 1315 /* Return non vxlan pkt */ 1316 - return 1; 1316 + goto drop; 1317 1317 } 1318 1318 unparsed.vx_flags &= ~VXLAN_HF_VNI; 1319 1319 unparsed.vx_vni &= ~VXLAN_VNI_MASK;
+14 -4
drivers/net/wireless/ath/ath10k/core.c
··· 202 202 .name = "qca4019 hw1.0", 203 203 .patch_load_addr = QCA4019_HW_1_0_PATCH_LOAD_ADDR, 204 204 .uart_pin = 7, 205 + .has_shifted_cc_wraparound = true, 205 206 .otp_exe_param = 0x0010000, 206 207 .continuous_frag_desc = true, 207 208 .channel_counters_freq_hz = 125000, ··· 687 686 if (!IS_ERR(ar->cal_file)) 688 687 release_firmware(ar->cal_file); 689 688 689 + if (!IS_ERR(ar->pre_cal_file)) 690 + release_firmware(ar->pre_cal_file); 691 + 690 692 ath10k_swap_code_seg_release(ar); 691 693 692 694 ar->normal_mode_fw.fw_file.otp_data = NULL; ··· 700 696 ar->normal_mode_fw.fw_file.firmware_len = 0; 701 697 702 698 ar->cal_file = NULL; 699 + ar->pre_cal_file = NULL; 703 700 } 704 701 705 702 static int ath10k_fetch_cal_file(struct ath10k *ar) ··· 1397 1392 complete_all(&ar->install_key_done); 1398 1393 complete_all(&ar->vdev_setup_done); 1399 1394 complete_all(&ar->thermal.wmi_sync); 1395 + complete_all(&ar->bss_survey_done); 1400 1396 wake_up(&ar->htt.empty_tx_wq); 1401 1397 wake_up(&ar->wmi.tx_credits_wq); 1402 1398 wake_up(&ar->peer_mapping_wq); ··· 1730 1724 if (ath10k_peer_stats_enabled(ar)) 1731 1725 val = WMI_10_4_PEER_STATS; 1732 1726 1727 + if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64, ar->wmi.svc_map)) 1728 + val |= WMI_10_4_BSS_CHANNEL_INFO_64; 1729 + 1733 1730 status = ath10k_mac_ext_resource_config(ar, val); 1734 1731 if (status) { 1735 1732 ath10k_err(ar, ··· 1767 1758 goto err_hif_stop; 1768 1759 } 1769 1760 1761 + ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1; 1762 + 1763 + INIT_LIST_HEAD(&ar->arvifs); 1764 + 1770 1765 /* we don't care about HTT in UTF mode */ 1771 1766 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) { 1772 1767 status = ath10k_htt_setup(&ar->htt); ··· 1783 1770 status = ath10k_debug_start(ar); 1784 1771 if (status) 1785 1772 goto err_hif_stop; 1786 - 1787 - ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1; 1788 - 1789 - INIT_LIST_HEAD(&ar->arvifs); 1790 1773 1791 1774 return 0; 1792 1775 ··· 2094 2085 init_completion(&ar->install_key_done); 2095 2086 init_completion(&ar->vdev_setup_done); 2096 2087 init_completion(&ar->thermal.wmi_sync); 2088 + init_completion(&ar->bss_survey_done); 2097 2089 2098 2090 INIT_DELAYED_WORK(&ar->scan.timeout, ath10k_scan_timeout_work); 2099 2091
+2 -2
drivers/net/wireless/ath/ath10k/core.h
··· 876 876 * avoid reporting garbage data. 877 877 */ 878 878 bool ch_info_can_report_survey; 879 + struct completion bss_survey_done; 879 880 880 881 struct dfs_pattern_detector *dfs_detector; 881 882 ··· 884 883 885 884 #ifdef CONFIG_ATH10K_DEBUGFS 886 885 struct ath10k_debug debug; 887 - #endif 888 - 889 886 struct { 890 887 /* relay(fs) channel for spectral scan */ 891 888 struct rchan *rfs_chan_spec_scan; ··· 892 893 enum ath10k_spectral_mode mode; 893 894 struct ath10k_spec_scan config; 894 895 } spectral; 896 + #endif 895 897 896 898 struct { 897 899 /* protected by conf_mutex */
+36 -4
drivers/net/wireless/ath/ath10k/mac.c
··· 4278 4278 if (ar->phy_capability & WHAL_WLAN_11G_CAPABILITY) { 4279 4279 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; 4280 4280 band->ht_cap = ht_cap; 4281 - 4282 - /* Enable the VHT support at 2.4 GHz */ 4283 - band->vht_cap = vht_cap; 4284 4281 } 4285 4282 if (ar->phy_capability & WHAL_WLAN_11A_CAPABILITY) { 4286 4283 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; ··· 4343 4346 4344 4347 /* 4345 4348 * This makes sense only when restarting hw. It is harmless to call 4346 - * uncoditionally. This is necessary to make sure no HTT/WMI tx 4349 + * unconditionally. This is necessary to make sure no HTT/WMI tx 4347 4350 * commands will be submitted while restarting. 4348 4351 */ 4349 4352 ath10k_drain_tx(ar); ··· 6404 6407 mutex_unlock(&ar->conf_mutex); 6405 6408 } 6406 6409 6410 + static void 6411 + ath10k_mac_update_bss_chan_survey(struct ath10k *ar, 6412 + struct ieee80211_channel *channel) 6413 + { 6414 + int ret; 6415 + enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR; 6416 + 6417 + lockdep_assert_held(&ar->conf_mutex); 6418 + 6419 + if (!test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64, ar->wmi.svc_map) || 6420 + (ar->rx_channel != channel)) 6421 + return; 6422 + 6423 + if (ar->scan.state != ATH10K_SCAN_IDLE) { 6424 + ath10k_dbg(ar, ATH10K_DBG_MAC, "ignoring bss chan info request while scanning..\n"); 6425 + return; 6426 + } 6427 + 6428 + reinit_completion(&ar->bss_survey_done); 6429 + 6430 + ret = ath10k_wmi_pdev_bss_chan_info_request(ar, type); 6431 + if (ret) { 6432 + ath10k_warn(ar, "failed to send pdev bss chan info request\n"); 6433 + return; 6434 + } 6435 + 6436 + ret = wait_for_completion_timeout(&ar->bss_survey_done, 3 * HZ); 6437 + if (!ret) { 6438 + ath10k_warn(ar, "bss channel survey timed out\n"); 6439 + return; 6440 + } 6441 + } 6442 + 6407 6443 static int ath10k_get_survey(struct ieee80211_hw *hw, int idx, 6408 6444 struct survey_info *survey) 6409 6445 { ··· 6460 6430 ret = -ENOENT; 6461 6431 goto exit; 6462 6432 } 6433 + 6434 + ath10k_mac_update_bss_chan_survey(ar, survey->channel); 6463 6435 6464 6436 spin_lock_bh(&ar->data_lock); 6465 6437 memcpy(survey, ar_survey, sizeof(*survey));
+21
drivers/net/wireless/ath/ath10k/wmi-ops.h
··· 191 191 u32 fw_feature_bitmap); 192 192 int (*get_vdev_subtype)(struct ath10k *ar, 193 193 enum wmi_vdev_subtype subtype); 194 + struct sk_buff *(*gen_pdev_bss_chan_info_req) 195 + (struct ath10k *ar, 196 + enum wmi_bss_survey_req_type type); 194 197 }; 195 198 196 199 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id); ··· 1362 1359 return -EOPNOTSUPP; 1363 1360 1364 1361 return ar->wmi.ops->get_vdev_subtype(ar, subtype); 1362 + } 1363 + 1364 + static inline int 1365 + ath10k_wmi_pdev_bss_chan_info_request(struct ath10k *ar, 1366 + enum wmi_bss_survey_req_type type) 1367 + { 1368 + struct ath10k_wmi *wmi = &ar->wmi; 1369 + struct sk_buff *skb; 1370 + 1371 + if (!wmi->ops->gen_pdev_bss_chan_info_req) 1372 + return -EOPNOTSUPP; 1373 + 1374 + skb = wmi->ops->gen_pdev_bss_chan_info_req(ar, type); 1375 + if (IS_ERR(skb)) 1376 + return PTR_ERR(skb); 1377 + 1378 + return ath10k_wmi_cmd_send(ar, skb, 1379 + wmi->cmd->pdev_bss_chan_info_request_cmdid); 1365 1380 } 1366 1381 1367 1382 #endif
+87 -1
drivers/net/wireless/ath/ath10k/wmi.c
··· 521 521 .vdev_filter_neighbor_rx_packets_cmdid = WMI_CMD_UNSUPPORTED, 522 522 .mu_cal_start_cmdid = WMI_CMD_UNSUPPORTED, 523 523 .set_cca_params_cmdid = WMI_CMD_UNSUPPORTED, 524 - .pdev_bss_chan_info_request_cmdid = WMI_CMD_UNSUPPORTED, 524 + .pdev_bss_chan_info_request_cmdid = 525 + WMI_10_2_PDEV_BSS_CHAN_INFO_REQUEST_CMDID, 525 526 }; 526 527 527 528 /* 10.4 WMI cmd track */ ··· 1634 1633 ch->max_power = arg->max_power; 1635 1634 ch->reg_power = arg->max_reg_power; 1636 1635 ch->antenna_max = arg->max_antenna_gain; 1636 + ch->max_tx_power = arg->max_power; 1637 1637 1638 1638 /* mode & flags share storage */ 1639 1639 ch->mode = arg->mode; ··· 4794 4792 return 0; 4795 4793 } 4796 4794 4795 + static int ath10k_wmi_event_pdev_bss_chan_info(struct ath10k *ar, 4796 + struct sk_buff *skb) 4797 + { 4798 + struct wmi_pdev_bss_chan_info_event *ev; 4799 + struct survey_info *survey; 4800 + u64 busy, total, tx, rx, rx_bss; 4801 + u32 freq, noise_floor; 4802 + u32 cc_freq_hz = ar->hw_params.channel_counters_freq_hz; 4803 + int idx; 4804 + 4805 + ev = (struct wmi_pdev_bss_chan_info_event *)skb->data; 4806 + if (WARN_ON(skb->len < sizeof(*ev))) 4807 + return -EPROTO; 4808 + 4809 + freq = __le32_to_cpu(ev->freq); 4810 + noise_floor = __le32_to_cpu(ev->noise_floor); 4811 + busy = __le64_to_cpu(ev->cycle_busy); 4812 + total = __le64_to_cpu(ev->cycle_total); 4813 + tx = __le64_to_cpu(ev->cycle_tx); 4814 + rx = __le64_to_cpu(ev->cycle_rx); 4815 + rx_bss = __le64_to_cpu(ev->cycle_rx_bss); 4816 + 4817 + ath10k_dbg(ar, ATH10K_DBG_WMI, 4818 + "wmi event pdev bss chan info:\n freq: %d noise: %d cycle: busy %llu total %llu tx %llu rx %llu rx_bss %llu\n", 4819 + freq, noise_floor, busy, total, tx, rx, rx_bss); 4820 + 4821 + spin_lock_bh(&ar->data_lock); 4822 + idx = freq_to_idx(ar, freq); 4823 + if (idx >= ARRAY_SIZE(ar->survey)) { 4824 + ath10k_warn(ar, "bss chan info: invalid frequency %d (idx %d out of bounds)\n", 4825 + freq, idx); 4826 + goto exit; 4827 + } 4828 + 4829 + survey = &ar->survey[idx]; 4830 + 4831 + survey->noise = noise_floor; 4832 + survey->time = div_u64(total, cc_freq_hz); 4833 + survey->time_busy = div_u64(busy, cc_freq_hz); 4834 + survey->time_rx = div_u64(rx_bss, cc_freq_hz); 4835 + survey->time_tx = div_u64(tx, cc_freq_hz); 4836 + survey->filled |= (SURVEY_INFO_NOISE_DBM | 4837 + SURVEY_INFO_TIME | 4838 + SURVEY_INFO_TIME_BUSY | 4839 + SURVEY_INFO_TIME_RX | 4840 + SURVEY_INFO_TIME_TX); 4841 + exit: 4842 + spin_unlock_bh(&ar->data_lock); 4843 + complete(&ar->bss_survey_done); 4844 + return 0; 4845 + } 4846 + 4797 4847 static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb) 4798 4848 { 4799 4849 struct wmi_cmd_hdr *cmd_hdr; ··· 5189 5135 case WMI_10_2_PDEV_TEMPERATURE_EVENTID: 5190 5136 ath10k_wmi_event_temperature(ar, skb); 5191 5137 break; 5138 + case WMI_10_2_PDEV_BSS_CHAN_INFO_EVENTID: 5139 + ath10k_wmi_event_pdev_bss_chan_info(ar, skb); 5140 + break; 5192 5141 case WMI_10_2_RTT_KEEPALIVE_EVENTID: 5193 5142 case WMI_10_2_GPIO_INPUT_EVENTID: 5194 5143 case WMI_10_2_PEER_RATECODE_LIST_EVENTID: ··· 5269 5212 ath10k_wmi_event_vdev_stopped(ar, skb); 5270 5213 break; 5271 5214 case WMI_10_4_WOW_WAKEUP_HOST_EVENTID: 5215 + case WMI_10_4_PEER_RATECODE_LIST_EVENTID: 5272 5216 ath10k_dbg(ar, ATH10K_DBG_WMI, 5273 5217 "received event id %d not implemented\n", id); 5274 5218 break; ··· 5278 5220 break; 5279 5221 case WMI_10_4_PDEV_TEMPERATURE_EVENTID: 5280 5222 ath10k_wmi_event_temperature(ar, skb); 5223 + break; 5224 + case WMI_10_4_PDEV_BSS_CHAN_INFO_EVENTID: 5225 + ath10k_wmi_event_pdev_bss_chan_info(ar, skb); 5281 5226 break; 5282 5227 default: 5283 5228 ath10k_warn(ar, "Unknown eventid: %d\n", id); ··· 5666 5605 5667 5606 if (ath10k_peer_stats_enabled(ar)) 5668 5607 features |= WMI_10_2_PEER_STATS; 5608 + 5609 + if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64, ar->wmi.svc_map)) 5610 + features |= WMI_10_2_BSS_CHAN_INFO; 5669 5611 5670 5612 cmd->resource_config.feature_mask = __cpu_to_le32(features); 5671 5613 ··· 6697 6633 return ERR_PTR(-ENOMEM); 6698 6634 6699 6635 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature\n"); 6636 + return skb; 6637 + } 6638 + 6639 + static struct sk_buff * 6640 + ath10k_wmi_10_2_op_gen_pdev_bss_chan_info(struct ath10k *ar, 6641 + enum wmi_bss_survey_req_type type) 6642 + { 6643 + struct wmi_pdev_chan_info_req_cmd *cmd; 6644 + struct sk_buff *skb; 6645 + 6646 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); 6647 + if (!skb) 6648 + return ERR_PTR(-ENOMEM); 6649 + 6650 + cmd = (struct wmi_pdev_chan_info_req_cmd *)skb->data; 6651 + cmd->type = __cpu_to_le32(type); 6652 + 6653 + ath10k_dbg(ar, ATH10K_DBG_WMI, 6654 + "wmi pdev bss info request type %d\n", type); 6655 + 6700 6656 return skb; 6701 6657 } 6702 6658 ··· 7819 7735 .gen_init = ath10k_wmi_10_2_op_gen_init, 7820 7736 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc, 7821 7737 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature, 7738 + .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info, 7822 7739 7823 7740 /* shared with 10.1 */ 7824 7741 .map_svc = wmi_10x_svc_map, ··· 7946 7861 .gen_request_stats = ath10k_wmi_op_gen_request_stats, 7947 7862 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature, 7948 7863 .get_vdev_subtype = ath10k_wmi_10_4_op_get_vdev_subtype, 7864 + .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info, 7949 7865 }; 7950 7866 7951 7867 int ath10k_wmi_attach(struct ath10k *ar)
+26
drivers/net/wireless/ath/ath10k/wmi.h
··· 1444 1444 WMI_10_2_MU_CAL_START_CMDID, 1445 1445 WMI_10_2_SET_LTEU_CONFIG_CMDID, 1446 1446 WMI_10_2_SET_CCA_PARAMS, 1447 + WMI_10_2_PDEV_BSS_CHAN_INFO_REQUEST_CMDID, 1447 1448 WMI_10_2_PDEV_UTF_CMDID = WMI_10_2_END_CMDID - 1, 1448 1449 }; 1449 1450 ··· 1488 1487 WMI_10_2_WDS_PEER_EVENTID, 1489 1488 WMI_10_2_PEER_STA_PS_STATECHG_EVENTID, 1490 1489 WMI_10_2_PDEV_TEMPERATURE_EVENTID, 1490 + WMI_10_2_MU_REPORT_EVENTID, 1491 + WMI_10_2_PDEV_BSS_CHAN_INFO_EVENTID, 1491 1492 WMI_10_2_PDEV_UTF_EVENTID = WMI_10_2_END_EVENTID - 1, 1492 1493 }; 1493 1494 ··· 1798 1795 __le32 reginfo1; 1799 1796 struct { 1800 1797 u8 antenna_max; 1798 + u8 max_tx_power; 1801 1799 } __packed; 1802 1800 } __packed; 1803 1801 } __packed; ··· 2454 2450 WMI_10_2_RX_BATCH_MODE = BIT(0), 2455 2451 WMI_10_2_ATF_CONFIG = BIT(1), 2456 2452 WMI_10_2_COEX_GPIO = BIT(3), 2453 + WMI_10_2_BSS_CHAN_INFO = BIT(6), 2457 2454 WMI_10_2_PEER_STATS = BIT(7), 2458 2455 }; 2459 2456 ··· 6285 6280 __le32 temperature; 6286 6281 } __packed; 6287 6282 6283 + struct wmi_pdev_bss_chan_info_event { 6284 + __le32 freq; 6285 + __le32 noise_floor; 6286 + __le64 cycle_busy; 6287 + __le64 cycle_total; 6288 + __le64 cycle_tx; 6289 + __le64 cycle_rx; 6290 + __le64 cycle_rx_bss; 6291 + __le32 reserved; 6292 + } __packed; 6293 + 6288 6294 /* WOW structures */ 6289 6295 enum wmi_wow_wakeup_event { 6290 6296 WOW_BMISS_EVENT = 0, ··· 6498 6482 WMI_HOST_PLATFORM_HIGH_PERF, 6499 6483 WMI_HOST_PLATFORM_LOW_PERF, 6500 6484 }; 6485 + 6486 + enum wmi_bss_survey_req_type { 6487 + WMI_BSS_SURVEY_REQ_TYPE_READ = 1, 6488 + WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR, 6489 + }; 6490 + 6491 + struct wmi_pdev_chan_info_req_cmd { 6492 + __le32 type; 6493 + __le32 reserved; 6494 + } __packed; 6501 6495 6502 6496 struct ath10k; 6503 6497 struct ath10k_vif;
+3
drivers/net/wireless/ath/ath6kl/core.c
··· 31 31 static unsigned int suspend_mode; 32 32 static unsigned int wow_mode; 33 33 static unsigned int uart_debug; 34 + static unsigned int uart_rate = 115200; 34 35 static unsigned int ath6kl_p2p; 35 36 static unsigned int testmode; 36 37 static unsigned int recovery_enable; ··· 41 40 module_param(suspend_mode, uint, 0644); 42 41 module_param(wow_mode, uint, 0644); 43 42 module_param(uart_debug, uint, 0644); 43 + module_param(uart_rate, uint, 0644); 44 44 module_param(ath6kl_p2p, uint, 0644); 45 45 module_param(testmode, uint, 0644); 46 46 module_param(recovery_enable, uint, 0644); ··· 182 180 183 181 if (uart_debug) 184 182 ar->conf_flags |= ATH6KL_CONF_UART_DEBUG; 183 + ar->hw.uarttx_rate = uart_rate; 185 184 186 185 set_bit(FIRST_BOOT, &ar->flag); 187 186
+1
drivers/net/wireless/ath/ath6kl/core.h
··· 781 781 u32 board_addr; 782 782 u32 refclk_hz; 783 783 u32 uarttx_pin; 784 + u32 uarttx_rate; 784 785 u32 testscript_addr; 785 786 u8 tx_ant; 786 787 u8 rx_ant;
+9
drivers/net/wireless/ath/ath6kl/init.c
··· 173 173 .reserved_ram_size = 7168, 174 174 .board_addr = 0x436400, 175 175 .testscript_addr = 0, 176 + .uarttx_pin = 11, 176 177 .flags = 0, 177 178 178 179 .fw = { ··· 650 649 ar->hw.uarttx_pin); 651 650 if (status) 652 651 return status; 652 + 653 + /* Only set the baud rate if we're actually doing debug */ 654 + if (ar->conf_flags & ATH6KL_CONF_UART_DEBUG) { 655 + status = ath6kl_bmi_write_hi32(ar, hi_desired_baud_rate, 656 + ar->hw.uarttx_rate); 657 + if (status) 658 + return status; 659 + } 653 660 654 661 /* Configure target refclk_hz */ 655 662 if (ar->hw.refclk_hz != 0) {
+20 -20
drivers/net/wireless/ath/ath9k/Kconfig
··· 75 75 ---help--- 76 76 This option enables detailed statistics for association stations. 77 77 78 + config ATH9K_TX99 79 + bool "Atheros ath9k TX99 testing support" 80 + depends on ATH9K_DEBUGFS && CFG80211_CERTIFICATION_ONUS 81 + default n 82 + ---help--- 83 + Say N. This should only be enabled on systems undergoing 84 + certification testing and evaluation in a controlled environment. 85 + Enabling this will only enable TX99 support, all other modes of 86 + operation will be disabled. 87 + 88 + TX99 support enables Specific Absorption Rate (SAR) testing. 89 + SAR is the unit of measurement for the amount of radio frequency(RF) 90 + absorbed by the body when using a wireless device. The RF exposure 91 + limits used are expressed in the terms of SAR, which is a measure 92 + of the electric and magnetic field strength and power density for 93 + transmitters operating at frequencies from 300 kHz to 100 GHz. 94 + Regulatory bodies around the world require that wireless device 95 + be evaluated to meet the RF exposure limits set forth in the 96 + governmental SAR regulations. 97 + 78 98 config ATH9K_DFS_CERTIFIED 79 99 bool "Atheros DFS support for certified platforms" 80 100 depends on ATH9K && CFG80211_CERTIFICATION_ONUS ··· 122 102 This option enables ath9k dynamic ACK timeout estimation algorithm 123 103 based on ACK frame RX timestamp, TX frame timestamp and frame 124 104 duration 125 - 126 - config ATH9K_TX99 127 - bool "Atheros ath9k TX99 testing support" 128 - depends on ATH9K_DEBUGFS && CFG80211_CERTIFICATION_ONUS 129 - default n 130 - ---help--- 131 - Say N. This should only be enabled on systems undergoing 132 - certification testing and evaluation in a controlled environment. 133 - Enabling this will only enable TX99 support, all other modes of 134 - operation will be disabled. 135 - 136 - TX99 support enables Specific Absorption Rate (SAR) testing. 137 - SAR is the unit of measurement for the amount of radio frequency(RF) 138 - absorbed by the body when using a wireless device. The RF exposure 139 - limits used are expressed in the terms of SAR, which is a measure 140 - of the electric and magnetic field strength and power density for 141 - transmitters operating at frequencies from 300 kHz to 100 GHz. 142 - Regulatory bodies around the world require that wireless device 143 - be evaluated to meet the RF exposure limits set forth in the 144 - governmental SAR regulations. 145 105 146 106 config ATH9K_WOW 147 107 bool "Wake on Wireless LAN support (EXPERIMENTAL)"
+1 -1
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
··· 4402 4402 } 4403 4403 4404 4404 /* Set tx power registers to array of values passed in */ 4405 - static int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray) 4405 + int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray) 4406 4406 { 4407 4407 #define POW_SM(_r, _s) (((_r) & 0x3f) << (_s)) 4408 4408 /* make sure forced gain is not set */
+1
drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
··· 355 355 struct ath9k_channel *chan); 356 356 357 357 void ar9003_hw_internal_regulator_apply(struct ath_hw *ah); 358 + int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray); 358 359 359 360 #endif
+7 -65
drivers/net/wireless/ath/ath9k/ar9003_phy.c
··· 17 17 #include <linux/export.h> 18 18 #include "hw.h" 19 19 #include "ar9003_phy.h" 20 + #include "ar9003_eeprom.h" 20 21 21 22 #define AR9300_OFDM_RATES 8 22 23 #define AR9300_HT_SS_RATES 8 ··· 1010 1009 if (IS_CHAN_A_FAST_CLOCK(ah, chan)) 1011 1010 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE); 1012 1011 1013 - if (rfMode & (AR_PHY_MODE_QUARTER | AR_PHY_MODE_HALF)) 1012 + if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan)) 1014 1013 REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL, 1015 1014 AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW, 3); 1016 1015 ··· 1841 1840 1842 1841 static void ar9003_hw_tx99_set_txpower(struct ath_hw *ah, u8 txpower) 1843 1842 { 1844 - static s16 p_pwr_array[ar9300RateSize] = { 0 }; 1843 + static u8 p_pwr_array[ar9300RateSize] = { 0 }; 1845 1844 unsigned int i; 1846 1845 1847 - if (txpower <= MAX_RATE_POWER) { 1848 - for (i = 0; i < ar9300RateSize; i++) 1849 - p_pwr_array[i] = txpower; 1850 - } else { 1851 - for (i = 0; i < ar9300RateSize; i++) 1852 - p_pwr_array[i] = MAX_RATE_POWER; 1853 - } 1846 + txpower = txpower <= MAX_RATE_POWER ? txpower : MAX_RATE_POWER; 1847 + for (i = 0; i < ar9300RateSize; i++) 1848 + p_pwr_array[i] = txpower; 1854 1849 1855 - REG_WRITE(ah, 0xa458, 0); 1856 - 1857 - REG_WRITE(ah, 0xa3c0, 1858 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_6_24], 24) | 1859 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_6_24], 16) | 1860 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_6_24], 8) | 1861 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_6_24], 0)); 1862 - REG_WRITE(ah, 0xa3c4, 1863 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_54], 24) | 1864 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_48], 16) | 1865 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_36], 8) | 1866 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_6_24], 0)); 1867 - REG_WRITE(ah, 0xa3c8, 1868 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_1L_5L], 24) | 1869 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_1L_5L], 16) | 1870 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_1L_5L], 0)); 1871 - REG_WRITE(ah, 0xa3cc, 1872 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_11S], 24) | 1873 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_11L], 16) | 1874 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_5S], 8) | 1875 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_LEGACY_1L_5L], 0)); 1876 - REG_WRITE(ah, 0xa3d0, 1877 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_5], 24) | 1878 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_4], 16) | 1879 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_1_3_9_11_17_19], 8)| 1880 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_0_8_16], 0)); 1881 - REG_WRITE(ah, 0xa3d4, 1882 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_13], 24) | 1883 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_12], 16) | 1884 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_7], 8) | 1885 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_6], 0)); 1886 - REG_WRITE(ah, 0xa3e4, 1887 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_21], 24) | 1888 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_20], 16) | 1889 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_15], 8) | 1890 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_14], 0)); 1891 - REG_WRITE(ah, 0xa3e8, 1892 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_23], 24) | 1893 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_22], 16) | 1894 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_23], 8) | 1895 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT20_22], 0)); 1896 - REG_WRITE(ah, 0xa3d8, 1897 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_5], 24) | 1898 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_4], 16) | 1899 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_1_3_9_11_17_19], 8) | 1900 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_0_8_16], 0)); 1901 - REG_WRITE(ah, 0xa3dc, 1902 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_13], 24) | 1903 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_12], 16) | 1904 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_7], 8) | 1905 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_6], 0)); 1906 - REG_WRITE(ah, 0xa3ec, 1907 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_21], 24) | 1908 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_20], 16) | 1909 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_15], 8) | 1910 - ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_14], 0)); 1850 + ar9003_hw_tx_power_regwrite(ah, p_pwr_array); 1911 1851 } 1912 1852 1913 1853 static void ar9003_hw_init_txpower_cck(struct ath_hw *ah, u8 *rate_array)
+1 -1
drivers/net/wireless/ath/wcn36xx/smd.h
··· 24 24 25 25 #define WCN36XX_HAL_BUF_SIZE 4096 26 26 27 - #define HAL_MSG_TIMEOUT 500 27 + #define HAL_MSG_TIMEOUT 10000 28 28 #define WCN36XX_SMSM_WLAN_TX_ENABLE 0x00000400 29 29 #define WCN36XX_SMSM_WLAN_TX_RINGS_EMPTY 0x00000200 30 30 /* The PNO version info be contained in the rsp msg */
+3 -2
drivers/net/wireless/ath/wil6210/cfg80211.c
··· 375 375 return -EBUSY; 376 376 } 377 377 378 - /* scan on P2P_DEVICE is handled as p2p search */ 379 - if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) { 378 + /* social scan on P2P_DEVICE is handled as p2p search */ 379 + if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE && 380 + wil_p2p_is_social_scan(request)) { 380 381 wil->scan_request = request; 381 382 wil->radio_wdev = wdev; 382 383 rc = wil_p2p_search(wil, request);
+19 -3
drivers/net/wireless/ath/wil6210/debug.c
··· 17 17 #include "wil6210.h" 18 18 #include "trace.h" 19 19 20 - void wil_err(struct wil6210_priv *wil, const char *fmt, ...) 20 + void __wil_err(struct wil6210_priv *wil, const char *fmt, ...) 21 21 { 22 22 struct net_device *ndev = wil_to_ndev(wil); 23 23 struct va_format vaf = { ··· 32 32 va_end(args); 33 33 } 34 34 35 - void wil_err_ratelimited(struct wil6210_priv *wil, const char *fmt, ...) 35 + void __wil_err_ratelimited(struct wil6210_priv *wil, const char *fmt, ...) 36 36 { 37 37 if (net_ratelimit()) { 38 38 struct net_device *ndev = wil_to_ndev(wil); ··· 49 49 } 50 50 } 51 51 52 - void wil_info(struct wil6210_priv *wil, const char *fmt, ...) 52 + void wil_dbg_ratelimited(const struct wil6210_priv *wil, const char *fmt, ...) 53 + { 54 + struct va_format vaf; 55 + va_list args; 56 + 57 + if (!net_ratelimit()) 58 + return; 59 + 60 + va_start(args, fmt); 61 + vaf.fmt = fmt; 62 + vaf.va = &args; 63 + netdev_dbg(wil_to_ndev(wil), "%pV", &vaf); 64 + trace_wil6210_log_dbg(&vaf); 65 + va_end(args); 66 + } 67 + 68 + void __wil_info(struct wil6210_priv *wil, const char *fmt, ...) 53 69 { 54 70 struct net_device *ndev = wil_to_ndev(wil); 55 71 struct va_format vaf = {
+129 -8
drivers/net/wireless/ath/wil6210/debugfs.c
··· 171 171 int rsize; 172 172 uint i; 173 173 174 + wil_halp_vote(wil); 175 + 174 176 wil_memcpy_fromio_32(&r, off, sizeof(r)); 175 177 wil_mbox_ring_le2cpus(&r); 176 178 /* ··· 238 236 } 239 237 out: 240 238 seq_puts(s, "}\n"); 239 + wil_halp_unvote(wil); 241 240 } 242 241 243 242 static int wil_mbox_debugfs_show(struct seq_file *s, void *data) ··· 503 500 size_t count, loff_t *ppos) 504 501 { 505 502 enum { max_count = 4096 }; 506 - struct debugfs_blob_wrapper *blob = file->private_data; 503 + struct wil_blob_wrapper *wil_blob = file->private_data; 507 504 loff_t pos = *ppos; 508 - size_t available = blob->size; 505 + size_t available = wil_blob->blob.size; 509 506 void *buf; 510 507 size_t ret; 511 508 ··· 524 521 if (!buf) 525 522 return -ENOMEM; 526 523 527 - wil_memcpy_fromio_32(buf, (const volatile void __iomem *)blob->data + 528 - pos, count); 524 + wil_memcpy_fromio_halp_vote(wil_blob->wil, buf, 525 + (const volatile void __iomem *) 526 + wil_blob->blob.data + pos, count); 529 527 530 528 ret = copy_to_user(user_buf, buf, count); 531 529 kfree(buf); ··· 549 545 struct dentry *wil_debugfs_create_ioblob(const char *name, 550 546 umode_t mode, 551 547 struct dentry *parent, 552 - struct debugfs_blob_wrapper *blob) 548 + struct wil_blob_wrapper *wil_blob) 553 549 { 554 - return debugfs_create_file(name, mode, parent, blob, &fops_ioblob); 550 + return debugfs_create_file(name, mode, parent, wil_blob, &fops_ioblob); 555 551 } 556 552 557 553 /*---reset---*/ ··· 1441 1437 .llseek = seq_lseek, 1442 1438 }; 1443 1439 1440 + static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf, 1441 + size_t count, loff_t *ppos) 1442 + { 1443 + char buf[80]; 1444 + int n; 1445 + 1446 + n = snprintf(buf, sizeof(buf), 1447 + "led_id is set to %d, echo 1 to enable, 0 to disable\n", 1448 + led_id); 1449 + 1450 + n = min_t(int, n, sizeof(buf)); 1451 + 1452 + return simple_read_from_buffer(user_buf, count, ppos, 1453 + buf, n); 1454 + } 1455 + 1456 + static ssize_t wil_write_file_led_cfg(struct file *file, 1457 + const char __user *buf_, 1458 + size_t count, loff_t *ppos) 1459 + { 1460 + struct wil6210_priv *wil = file->private_data; 1461 + int val; 1462 + int rc; 1463 + 1464 + rc = kstrtoint_from_user(buf_, count, 0, &val); 1465 + if (rc) { 1466 + wil_err(wil, "Invalid argument\n"); 1467 + return rc; 1468 + } 1469 + 1470 + wil_info(wil, "%s led %d\n", val ? "Enabling" : "Disabling", led_id); 1471 + rc = wmi_led_cfg(wil, val); 1472 + if (rc) { 1473 + wil_info(wil, "%s led %d failed\n", 1474 + val ? "Enabling" : "Disabling", led_id); 1475 + return rc; 1476 + } 1477 + 1478 + return count; 1479 + } 1480 + 1481 + static const struct file_operations fops_led_cfg = { 1482 + .read = wil_read_file_led_cfg, 1483 + .write = wil_write_file_led_cfg, 1484 + .open = simple_open, 1485 + }; 1486 + 1487 + /* led_blink_time, write: 1488 + * "<blink_on_slow> <blink_off_slow> <blink_on_med> <blink_off_med> <blink_on_fast> <blink_off_fast> 1489 + */ 1490 + static ssize_t wil_write_led_blink_time(struct file *file, 1491 + const char __user *buf, 1492 + size_t len, loff_t *ppos) 1493 + { 1494 + int rc; 1495 + char *kbuf = kmalloc(len + 1, GFP_KERNEL); 1496 + 1497 + if (!kbuf) 1498 + return -ENOMEM; 1499 + 1500 + rc = simple_write_to_buffer(kbuf, len, ppos, buf, len); 1501 + if (rc != len) { 1502 + kfree(kbuf); 1503 + return rc >= 0 ? -EIO : rc; 1504 + } 1505 + 1506 + kbuf[len] = '\0'; 1507 + rc = sscanf(kbuf, "%d %d %d %d %d %d", 1508 + &led_blink_time[WIL_LED_TIME_SLOW].on_ms, 1509 + &led_blink_time[WIL_LED_TIME_SLOW].off_ms, 1510 + &led_blink_time[WIL_LED_TIME_MED].on_ms, 1511 + &led_blink_time[WIL_LED_TIME_MED].off_ms, 1512 + &led_blink_time[WIL_LED_TIME_FAST].on_ms, 1513 + &led_blink_time[WIL_LED_TIME_FAST].off_ms); 1514 + kfree(kbuf); 1515 + 1516 + if (rc < 0) 1517 + return rc; 1518 + if (rc < 6) 1519 + return -EINVAL; 1520 + 1521 + return len; 1522 + } 1523 + 1524 + static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf, 1525 + size_t count, loff_t *ppos) 1526 + { 1527 + static char text[400]; 1528 + 1529 + snprintf(text, sizeof(text), 1530 + "To set led blink on/off time variables write:\n" 1531 + "<blink_on_slow> <blink_off_slow> <blink_on_med> " 1532 + "<blink_off_med> <blink_on_fast> <blink_off_fast>\n" 1533 + "The current values are:\n" 1534 + "%d %d %d %d %d %d\n", 1535 + led_blink_time[WIL_LED_TIME_SLOW].on_ms, 1536 + led_blink_time[WIL_LED_TIME_SLOW].off_ms, 1537 + led_blink_time[WIL_LED_TIME_MED].on_ms, 1538 + led_blink_time[WIL_LED_TIME_MED].off_ms, 1539 + led_blink_time[WIL_LED_TIME_FAST].on_ms, 1540 + led_blink_time[WIL_LED_TIME_FAST].off_ms); 1541 + 1542 + return simple_read_from_buffer(user_buf, count, ppos, text, 1543 + sizeof(text)); 1544 + } 1545 + 1546 + static const struct file_operations fops_led_blink_time = { 1547 + .read = wil_read_led_blink_time, 1548 + .write = wil_write_led_blink_time, 1549 + .open = simple_open, 1550 + }; 1551 + 1444 1552 /*----------------*/ 1445 1553 static void wil6210_debugfs_init_blobs(struct wil6210_priv *wil, 1446 1554 struct dentry *dbg) ··· 1561 1445 char name[32]; 1562 1446 1563 1447 for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) { 1564 - struct debugfs_blob_wrapper *blob = &wil->blobs[i]; 1448 + struct wil_blob_wrapper *wil_blob = &wil->blobs[i]; 1449 + struct debugfs_blob_wrapper *blob = &wil_blob->blob; 1565 1450 const struct fw_map *map = &fw_mapping[i]; 1566 1451 1567 1452 if (!map->name) 1568 1453 continue; 1569 1454 1455 + wil_blob->wil = wil; 1570 1456 blob->data = (void * __force)wil->csr + HOSTADDR(map->host); 1571 1457 blob->size = map->to - map->from; 1572 1458 snprintf(name, sizeof(name), "blob_%s", map->name); 1573 - wil_debugfs_create_ioblob(name, S_IRUGO, dbg, blob); 1459 + wil_debugfs_create_ioblob(name, S_IRUGO, dbg, wil_blob); 1574 1460 } 1575 1461 } 1576 1462 ··· 1601 1483 {"link", S_IRUGO, &fops_link}, 1602 1484 {"info", S_IRUGO, &fops_info}, 1603 1485 {"recovery", S_IRUGO | S_IWUSR, &fops_recovery}, 1486 + {"led_cfg", S_IRUGO | S_IWUSR, &fops_led_cfg}, 1487 + {"led_blink_time", S_IRUGO | S_IWUSR, &fops_led_blink_time}, 1604 1488 }; 1605 1489 1606 1490 static void wil6210_debugfs_init_files(struct wil6210_priv *wil, ··· 1665 1545 {"mem_addr", S_IRUGO | S_IWUSR, (ulong)&mem_addr, doff_u32}, 1666 1546 {"vring_idle_trsh", S_IRUGO | S_IWUSR, (ulong)&vring_idle_trsh, 1667 1547 doff_u32}, 1548 + {"led_polarity", S_IRUGO | S_IWUSR, (ulong)&led_polarity, doff_u8}, 1668 1549 {}, 1669 1550 }; 1670 1551
+72 -21
drivers/net/wireless/ath/wil6210/interrupt.c
··· 35 35 * 36 36 */ 37 37 38 - #define WIL6210_IRQ_DISABLE (0xFFFFFFFFUL) 38 + #define WIL6210_IRQ_DISABLE (0xFFFFFFFFUL) 39 + #define WIL6210_IRQ_DISABLE_NO_HALP (0xF7FFFFFFUL) 39 40 #define WIL6210_IMC_RX (BIT_DMA_EP_RX_ICR_RX_DONE | \ 40 41 BIT_DMA_EP_RX_ICR_RX_HTRSH) 42 + #define WIL6210_IMC_RX_NO_RX_HTRSH (WIL6210_IMC_RX & \ 43 + (~(BIT_DMA_EP_RX_ICR_RX_HTRSH))) 41 44 #define WIL6210_IMC_TX (BIT_DMA_EP_TX_ICR_TX_DONE | \ 42 45 BIT_DMA_EP_TX_ICR_TX_DONE_N(0)) 43 - #define WIL6210_IMC_MISC (ISR_MISC_FW_READY | \ 44 - ISR_MISC_MBOX_EVT | \ 45 - ISR_MISC_FW_ERROR) 46 - 46 + #define WIL6210_IMC_MISC_NO_HALP (ISR_MISC_FW_READY | \ 47 + ISR_MISC_MBOX_EVT | \ 48 + ISR_MISC_FW_ERROR) 49 + #define WIL6210_IMC_MISC (WIL6210_IMC_MISC_NO_HALP | \ 50 + BIT_DMA_EP_MISC_ICR_HALP) 47 51 #define WIL6210_IRQ_PSEUDO_MASK (u32)(~(BIT_DMA_PSEUDO_CAUSE_RX | \ 48 52 BIT_DMA_PSEUDO_CAUSE_TX | \ 49 53 BIT_DMA_PSEUDO_CAUSE_MISC)) ··· 55 51 #if defined(CONFIG_WIL6210_ISR_COR) 56 52 /* configure to Clear-On-Read mode */ 57 53 #define WIL_ICR_ICC_VALUE (0xFFFFFFFFUL) 54 + #define WIL_ICR_ICC_MISC_VALUE (0xF7FFFFFFUL) 58 55 59 56 static inline void wil_icr_clear(u32 x, void __iomem *addr) 60 57 { ··· 63 58 #else /* defined(CONFIG_WIL6210_ISR_COR) */ 64 59 /* configure to Write-1-to-Clear mode */ 65 60 #define WIL_ICR_ICC_VALUE (0UL) 61 + #define WIL_ICR_ICC_MISC_VALUE (0UL) 66 62 67 63 static inline void wil_icr_clear(u32 x, void __iomem *addr) 68 64 { ··· 92 86 WIL6210_IRQ_DISABLE); 93 87 } 94 88 95 - static void wil6210_mask_irq_misc(struct wil6210_priv *wil) 89 + static void wil6210_mask_irq_misc(struct wil6210_priv *wil, bool mask_halp) 96 90 { 91 + wil_dbg_irq(wil, "%s: mask_halp(%s)\n", __func__, 92 + mask_halp ? "true" : "false"); 93 + 97 94 wil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, IMS), 98 - WIL6210_IRQ_DISABLE); 95 + mask_halp ? WIL6210_IRQ_DISABLE : WIL6210_IRQ_DISABLE_NO_HALP); 96 + } 97 + 98 + static void wil6210_mask_halp(struct wil6210_priv *wil) 99 + { 100 + wil_dbg_irq(wil, "%s()\n", __func__); 101 + 102 + wil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, IMS), 103 + BIT_DMA_EP_MISC_ICR_HALP); 99 104 } 100 105 101 106 static void wil6210_mask_irq_pseudo(struct wil6210_priv *wil) ··· 126 109 127 110 void wil6210_unmask_irq_rx(struct wil6210_priv *wil) 128 111 { 112 + bool unmask_rx_htrsh = test_bit(wil_status_fwconnected, wil->status); 113 + 129 114 wil_w(wil, RGF_DMA_EP_RX_ICR + offsetof(struct RGF_ICR, IMC), 130 - WIL6210_IMC_RX); 115 + unmask_rx_htrsh ? WIL6210_IMC_RX : WIL6210_IMC_RX_NO_RX_HTRSH); 131 116 } 132 117 133 - static void wil6210_unmask_irq_misc(struct wil6210_priv *wil) 118 + static void wil6210_unmask_irq_misc(struct wil6210_priv *wil, bool unmask_halp) 134 119 { 120 + wil_dbg_irq(wil, "%s: unmask_halp(%s)\n", __func__, 121 + unmask_halp ? "true" : "false"); 122 + 135 123 wil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, IMC), 136 - WIL6210_IMC_MISC); 124 + unmask_halp ? WIL6210_IMC_MISC : WIL6210_IMC_MISC_NO_HALP); 125 + } 126 + 127 + static void wil6210_unmask_halp(struct wil6210_priv *wil) 128 + { 129 + wil_dbg_irq(wil, "%s()\n", __func__); 130 + 131 + wil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, IMC), 132 + BIT_DMA_EP_MISC_ICR_HALP); 137 133 } 138 134 139 135 static void wil6210_unmask_irq_pseudo(struct wil6210_priv *wil) ··· 164 134 165 135 wil6210_mask_irq_tx(wil); 166 136 wil6210_mask_irq_rx(wil); 167 - wil6210_mask_irq_misc(wil); 137 + wil6210_mask_irq_misc(wil, true); 168 138 wil6210_mask_irq_pseudo(wil); 169 139 } 170 140 ··· 177 147 wil_w(wil, RGF_DMA_EP_TX_ICR + offsetof(struct RGF_ICR, ICC), 178 148 WIL_ICR_ICC_VALUE); 179 149 wil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, ICC), 180 - WIL_ICR_ICC_VALUE); 150 + WIL_ICR_ICC_MISC_VALUE); 181 151 182 152 wil6210_unmask_irq_pseudo(wil); 183 153 wil6210_unmask_irq_tx(wil); 184 154 wil6210_unmask_irq_rx(wil); 185 - wil6210_unmask_irq_misc(wil); 155 + wil6210_unmask_irq_misc(wil, true); 186 156 } 187 157 188 158 void wil_configure_interrupt_moderation(struct wil6210_priv *wil) ··· 258 228 */ 259 229 if (likely(isr & (BIT_DMA_EP_RX_ICR_RX_DONE | 260 230 BIT_DMA_EP_RX_ICR_RX_HTRSH))) { 261 - wil_dbg_irq(wil, "RX done\n"); 262 - 263 - if (unlikely(isr & BIT_DMA_EP_RX_ICR_RX_HTRSH)) 264 - wil_err_ratelimited(wil, 265 - "Received \"Rx buffer is in risk of overflow\" interrupt\n"); 231 + wil_dbg_irq(wil, "RX done / RX_HTRSH received, ISR (0x%x)\n", 232 + isr); 266 233 267 234 isr &= ~(BIT_DMA_EP_RX_ICR_RX_DONE | 268 235 BIT_DMA_EP_RX_ICR_RX_HTRSH); ··· 371 344 return IRQ_NONE; 372 345 } 373 346 374 - wil6210_mask_irq_misc(wil); 347 + wil6210_mask_irq_misc(wil, false); 375 348 376 349 if (isr & ISR_MISC_FW_ERROR) { 377 350 u32 fw_assert_code = wil_r(wil, RGF_FW_ASSERT_CODE); ··· 399 372 isr &= ~ISR_MISC_FW_READY; 400 373 } 401 374 375 + if (isr & BIT_DMA_EP_MISC_ICR_HALP) { 376 + wil_dbg_irq(wil, "%s: HALP IRQ invoked\n", __func__); 377 + wil6210_mask_halp(wil); 378 + isr &= ~BIT_DMA_EP_MISC_ICR_HALP; 379 + complete(&wil->halp.comp); 380 + } 381 + 402 382 wil->isr_misc = isr; 403 383 404 384 if (isr) { 405 385 return IRQ_WAKE_THREAD; 406 386 } else { 407 - wil6210_unmask_irq_misc(wil); 387 + wil6210_unmask_irq_misc(wil, false); 408 388 return IRQ_HANDLED; 409 389 } 410 390 } ··· 448 414 449 415 wil->isr_misc = 0; 450 416 451 - wil6210_unmask_irq_misc(wil); 417 + wil6210_unmask_irq_misc(wil, false); 452 418 453 419 return IRQ_HANDLED; 454 420 } ··· 588 554 wil_clear32(wil->csr + HOSTADDR(RGF_DMA_EP_MISC_ICR) + 589 555 offsetof(struct RGF_ICR, ICR)); 590 556 wmb(); /* make sure write completed */ 557 + } 558 + 559 + void wil6210_set_halp(struct wil6210_priv *wil) 560 + { 561 + wil_dbg_misc(wil, "%s()\n", __func__); 562 + 563 + wil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, ICS), 564 + BIT_DMA_EP_MISC_ICR_HALP); 565 + } 566 + 567 + void wil6210_clear_halp(struct wil6210_priv *wil) 568 + { 569 + wil_dbg_misc(wil, "%s()\n", __func__); 570 + 571 + wil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, ICR), 572 + BIT_DMA_EP_MISC_ICR_HALP); 573 + wil6210_unmask_halp(wil); 591 574 } 592 575 593 576 int wil6210_init_irq(struct wil6210_priv *wil, int irq, bool use_msi)
+92 -3
drivers/net/wireless/ath/wil6210/main.c
··· 23 23 #include "wmi.h" 24 24 #include "boot_loader.h" 25 25 26 + #define WAIT_FOR_HALP_VOTE_MS 100 27 + 26 28 bool debug_fw; /* = false; */ 27 29 module_param(debug_fw, bool, S_IRUGO); 28 30 MODULE_PARM_DESC(debug_fw, " do not perform card reset. For FW debug"); ··· 134 132 *d++ = __raw_readl(s++); 135 133 } 136 134 135 + void wil_memcpy_fromio_halp_vote(struct wil6210_priv *wil, void *dst, 136 + const volatile void __iomem *src, size_t count) 137 + { 138 + wil_halp_vote(wil); 139 + wil_memcpy_fromio_32(dst, src, count); 140 + wil_halp_unvote(wil); 141 + } 142 + 137 143 void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src, 138 144 size_t count) 139 145 { ··· 150 140 151 141 for (count += 4; count > 4; count -= 4) 152 142 __raw_writel(*s++, d++); 143 + } 144 + 145 + void wil_memcpy_toio_halp_vote(struct wil6210_priv *wil, 146 + volatile void __iomem *dst, 147 + const void *src, size_t count) 148 + { 149 + wil_halp_vote(wil); 150 + wil_memcpy_toio_32(dst, src, count); 151 + wil_halp_unvote(wil); 153 152 } 154 153 155 154 static void wil_disconnect_cid(struct wil6210_priv *wil, int cid, ··· 213 194 memset(&sta->stats, 0, sizeof(sta->stats)); 214 195 } 215 196 197 + static bool wil_ap_is_connected(struct wil6210_priv *wil) 198 + { 199 + int i; 200 + 201 + for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { 202 + if (wil->sta[i].status == wil_sta_connected) 203 + return true; 204 + } 205 + 206 + return false; 207 + } 208 + 216 209 static void _wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid, 217 210 u16 reason_code, bool from_event) 218 211 { ··· 277 246 GFP_KERNEL); 278 247 } 279 248 clear_bit(wil_status_fwconnecting, wil->status); 249 + break; 250 + case NL80211_IFTYPE_AP: 251 + case NL80211_IFTYPE_P2P_GO: 252 + if (!wil_ap_is_connected(wil)) 253 + clear_bit(wil_status_fwconnected, wil->status); 280 254 break; 281 255 default: 282 256 break; ··· 493 457 mutex_init(&wil->wmi_mutex); 494 458 mutex_init(&wil->probe_client_mutex); 495 459 mutex_init(&wil->p2p_wdev_mutex); 460 + mutex_init(&wil->halp.lock); 496 461 497 462 init_completion(&wil->wmi_ready); 498 463 init_completion(&wil->wmi_call); 464 + init_completion(&wil->halp.comp); 499 465 500 466 wil->bcast_vring = -1; 501 467 setup_timer(&wil->connect_timer, wil_connect_timer_fn, (ulong)wil); ··· 593 555 static void wil_set_oob_mode(struct wil6210_priv *wil, bool enable) 594 556 { 595 557 wil_info(wil, "%s: enable=%d\n", __func__, enable); 596 - if (enable) { 558 + if (enable) 597 559 wil_s(wil, RGF_USER_USAGE_6, BIT_USER_OOB_MODE); 598 - } else { 560 + else 599 561 wil_c(wil, RGF_USER_USAGE_6, BIT_USER_OOB_MODE); 600 - } 601 562 } 602 563 603 564 static int wil_target_reset(struct wil6210_priv *wil) ··· 841 804 wil6210_disconnect(wil, NULL, WLAN_REASON_DEAUTH_LEAVING, false); 842 805 wil_bcast_fini(wil); 843 806 807 + /* Disable device led before reset*/ 808 + wmi_led_cfg(wil, false); 809 + 844 810 /* prevent NAPI from being scheduled and prevent wmi commands */ 845 811 mutex_lock(&wil->wmi_mutex); 846 812 bitmap_zero(wil->status, wil_status_last); ··· 911 871 wil->ap_isolate = 0; 912 872 reinit_completion(&wil->wmi_ready); 913 873 reinit_completion(&wil->wmi_call); 874 + reinit_completion(&wil->halp.comp); 914 875 915 876 if (load_fw) { 916 877 wil_configure_interrupt_moderation(wil); ··· 1101 1060 } 1102 1061 1103 1062 return rc; 1063 + } 1064 + 1065 + void wil_halp_vote(struct wil6210_priv *wil) 1066 + { 1067 + unsigned long rc; 1068 + unsigned long to_jiffies = msecs_to_jiffies(WAIT_FOR_HALP_VOTE_MS); 1069 + 1070 + mutex_lock(&wil->halp.lock); 1071 + 1072 + wil_dbg_misc(wil, "%s: start, HALP ref_cnt (%d)\n", __func__, 1073 + wil->halp.ref_cnt); 1074 + 1075 + if (++wil->halp.ref_cnt == 1) { 1076 + wil6210_set_halp(wil); 1077 + rc = wait_for_completion_timeout(&wil->halp.comp, to_jiffies); 1078 + if (!rc) 1079 + wil_err(wil, "%s: HALP vote timed out\n", __func__); 1080 + else 1081 + wil_dbg_misc(wil, 1082 + "%s: HALP vote completed after %d ms\n", 1083 + __func__, 1084 + jiffies_to_msecs(to_jiffies - rc)); 1085 + } 1086 + 1087 + wil_dbg_misc(wil, "%s: end, HALP ref_cnt (%d)\n", __func__, 1088 + wil->halp.ref_cnt); 1089 + 1090 + mutex_unlock(&wil->halp.lock); 1091 + } 1092 + 1093 + void wil_halp_unvote(struct wil6210_priv *wil) 1094 + { 1095 + WARN_ON(wil->halp.ref_cnt == 0); 1096 + 1097 + mutex_lock(&wil->halp.lock); 1098 + 1099 + wil_dbg_misc(wil, "%s: start, HALP ref_cnt (%d)\n", __func__, 1100 + wil->halp.ref_cnt); 1101 + 1102 + if (--wil->halp.ref_cnt == 0) { 1103 + wil6210_clear_halp(wil); 1104 + wil_dbg_misc(wil, "%s: HALP unvote\n", __func__); 1105 + } 1106 + 1107 + wil_dbg_misc(wil, "%s: end, HALP ref_cnt (%d)\n", __func__, 1108 + wil->halp.ref_cnt); 1109 + 1110 + mutex_unlock(&wil->halp.lock); 1104 1111 }
+6
drivers/net/wireless/ath/wil6210/p2p.c
··· 22 22 #define P2P_SEARCH_DURATION_MS 500 23 23 #define P2P_DEFAULT_BI 100 24 24 25 + bool wil_p2p_is_social_scan(struct cfg80211_scan_request *request) 26 + { 27 + return (request->n_channels == 1) && 28 + (request->channels[0]->hw_value == P2P_DMG_SOCIAL_CHANNEL); 29 + } 30 + 25 31 void wil_p2p_discovery_timer_fn(ulong x) 26 32 { 27 33 struct wil6210_priv *wil = (void *)x;
+1 -1
drivers/net/wireless/ath/wil6210/txrx.c
··· 1759 1759 goto drop; 1760 1760 } 1761 1761 if (unlikely(!test_bit(wil_status_fwconnected, wil->status))) { 1762 - wil_err_ratelimited(wil, "FW not connected\n"); 1762 + wil_dbg_ratelimited(wil, "FW not connected, packet dropped\n"); 1763 1763 goto drop; 1764 1764 } 1765 1765 if (unlikely(wil->wdev->iftype == NL80211_IFTYPE_MONITOR)) {
+63 -4
drivers/net/wireless/ath/wil6210/wil6210.h
··· 168 168 #define RGF_DMA_EP_MISC_ICR (0x881bec) /* struct RGF_ICR */ 169 169 #define BIT_DMA_EP_MISC_ICR_RX_HTRSH BIT(0) 170 170 #define BIT_DMA_EP_MISC_ICR_TX_NO_ACT BIT(1) 171 + #define BIT_DMA_EP_MISC_ICR_HALP BIT(27) 171 172 #define BIT_DMA_EP_MISC_ICR_FW_INT(n) BIT(28+n) /* n = [0..3] */ 172 173 173 174 /* Legacy interrupt moderation control (before Sparrow v2)*/ ··· 535 534 int descriptor_size; 536 535 }; 537 536 537 + struct wil_halp { 538 + struct mutex lock; /* protect halp ref_cnt */ 539 + unsigned int ref_cnt; 540 + struct completion comp; 541 + }; 542 + 543 + struct wil_blob_wrapper { 544 + struct wil6210_priv *wil; 545 + struct debugfs_blob_wrapper blob; 546 + }; 547 + 548 + #define WIL_LED_MAX_ID (2) 549 + #define WIL_LED_INVALID_ID (0xF) 550 + #define WIL_LED_BLINK_ON_SLOW_MS (300) 551 + #define WIL_LED_BLINK_OFF_SLOW_MS (300) 552 + #define WIL_LED_BLINK_ON_MED_MS (200) 553 + #define WIL_LED_BLINK_OFF_MED_MS (200) 554 + #define WIL_LED_BLINK_ON_FAST_MS (100) 555 + #define WIL_LED_BLINK_OFF_FAST_MS (100) 556 + enum { 557 + WIL_LED_TIME_SLOW = 0, 558 + WIL_LED_TIME_MED, 559 + WIL_LED_TIME_FAST, 560 + WIL_LED_TIME_LAST, 561 + }; 562 + 563 + struct blink_on_off_time { 564 + u32 on_ms; 565 + u32 off_ms; 566 + }; 567 + 568 + extern struct blink_on_off_time led_blink_time[WIL_LED_TIME_LAST]; 569 + extern u8 led_id; 570 + extern u8 led_polarity; 571 + 538 572 struct wil6210_priv { 539 573 struct pci_dev *pdev; 540 574 struct wireless_dev *wdev; ··· 642 606 atomic_t isr_count_rx, isr_count_tx; 643 607 /* debugfs */ 644 608 struct dentry *debug; 645 - struct debugfs_blob_wrapper blobs[ARRAY_SIZE(fw_mapping)]; 609 + struct wil_blob_wrapper blobs[ARRAY_SIZE(fw_mapping)]; 646 610 u8 discovery_mode; 647 611 648 612 void *platform_handle; ··· 658 622 struct wireless_dev *p2p_wdev; 659 623 struct mutex p2p_wdev_mutex; /* protect @p2p_wdev */ 660 624 struct wireless_dev *radio_wdev; 625 + 626 + /* High Access Latency Policy voting */ 627 + struct wil_halp halp; 628 + 661 629 }; 662 630 663 631 #define wil_to_wiphy(i) (i->wdev->wiphy) ··· 675 635 __printf(2, 3) 676 636 void wil_dbg_trace(struct wil6210_priv *wil, const char *fmt, ...); 677 637 __printf(2, 3) 678 - void wil_err(struct wil6210_priv *wil, const char *fmt, ...); 638 + void __wil_err(struct wil6210_priv *wil, const char *fmt, ...); 679 639 __printf(2, 3) 680 - void wil_err_ratelimited(struct wil6210_priv *wil, const char *fmt, ...); 640 + void __wil_err_ratelimited(struct wil6210_priv *wil, const char *fmt, ...); 681 641 __printf(2, 3) 682 - void wil_info(struct wil6210_priv *wil, const char *fmt, ...); 642 + void __wil_info(struct wil6210_priv *wil, const char *fmt, ...); 643 + __printf(2, 3) 644 + void wil_dbg_ratelimited(const struct wil6210_priv *wil, const char *fmt, ...); 683 645 #define wil_dbg(wil, fmt, arg...) do { \ 684 646 netdev_dbg(wil_to_ndev(wil), fmt, ##arg); \ 685 647 wil_dbg_trace(wil, fmt, ##arg); \ ··· 692 650 #define wil_dbg_wmi(wil, fmt, arg...) wil_dbg(wil, "DBG[ WMI]" fmt, ##arg) 693 651 #define wil_dbg_misc(wil, fmt, arg...) wil_dbg(wil, "DBG[MISC]" fmt, ##arg) 694 652 #define wil_dbg_pm(wil, fmt, arg...) wil_dbg(wil, "DBG[ PM ]" fmt, ##arg) 653 + #define wil_err(wil, fmt, arg...) __wil_err(wil, "%s: " fmt, __func__, ##arg) 654 + #define wil_info(wil, fmt, arg...) __wil_info(wil, "%s: " fmt, __func__, ##arg) 655 + #define wil_err_ratelimited(wil, fmt, arg...) \ 656 + __wil_err_ratelimited(wil, "%s: " fmt, __func__, ##arg) 695 657 696 658 /* target operations */ 697 659 /* register read */ ··· 753 707 size_t count); 754 708 void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src, 755 709 size_t count); 710 + void wil_memcpy_fromio_halp_vote(struct wil6210_priv *wil, void *dst, 711 + const volatile void __iomem *src, 712 + size_t count); 713 + void wil_memcpy_toio_halp_vote(struct wil6210_priv *wil, 714 + volatile void __iomem *dst, 715 + const void *src, size_t count); 756 716 757 717 void *wil_if_alloc(struct device *dev); 758 718 void wil_if_free(struct wil6210_priv *wil); ··· 824 772 void wil_enable_irq(struct wil6210_priv *wil); 825 773 826 774 /* P2P */ 775 + bool wil_p2p_is_social_scan(struct cfg80211_scan_request *request); 827 776 void wil_p2p_discovery_timer_fn(ulong x); 828 777 int wil_p2p_search(struct wil6210_priv *wil, 829 778 struct cfg80211_scan_request *request); ··· 858 805 int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 wmi_nettype, 859 806 u8 chan, u8 hidden_ssid, u8 is_go); 860 807 int wmi_pcp_stop(struct wil6210_priv *wil); 808 + int wmi_led_cfg(struct wil6210_priv *wil, bool enable); 861 809 void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid, 862 810 u16 reason_code, bool from_event); 863 811 void wil_probe_client_flush(struct wil6210_priv *wil); ··· 895 841 896 842 int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size); 897 843 void wil_fw_core_dump(struct wil6210_priv *wil); 844 + 845 + void wil_halp_vote(struct wil6210_priv *wil); 846 + void wil_halp_unvote(struct wil6210_priv *wil); 847 + void wil6210_set_halp(struct wil6210_priv *wil); 848 + void wil6210_clear_halp(struct wil6210_priv *wil); 898 849 899 850 #endif /* __WIL6210_H__ */
+92 -5
drivers/net/wireless/ath/wil6210/wmi.c
··· 32 32 MODULE_PARM_DESC(agg_wsize, " Window size for Tx Block Ack after connect;" 33 33 " 0 - use default; < 0 - don't auto-establish"); 34 34 35 + u8 led_id = WIL_LED_INVALID_ID; 36 + module_param(led_id, byte, S_IRUGO); 37 + MODULE_PARM_DESC(led_id, 38 + " 60G device led enablement. Set the led ID (0-2) to enable"); 39 + 35 40 /** 36 41 * WMI event receiving - theory of operations 37 42 * ··· 98 93 * 932000..949000 back-door debug data 99 94 */ 100 95 }; 96 + 97 + struct blink_on_off_time led_blink_time[] = { 98 + {WIL_LED_BLINK_ON_SLOW_MS, WIL_LED_BLINK_OFF_SLOW_MS}, 99 + {WIL_LED_BLINK_ON_MED_MS, WIL_LED_BLINK_OFF_MED_MS}, 100 + {WIL_LED_BLINK_ON_FAST_MS, WIL_LED_BLINK_OFF_FAST_MS}, 101 + }; 102 + 103 + u8 led_polarity = LED_POLARITY_LOW_ACTIVE; 101 104 102 105 /** 103 106 * return AHB address for given firmware/ucode internal (linker) address ··· 207 194 void __iomem *dst; 208 195 void __iomem *head = wmi_addr(wil, r->head); 209 196 uint retry; 197 + int rc = 0; 210 198 211 199 if (sizeof(cmd) + len > r->entry_size) { 212 200 wil_err(wil, "WMI size too large: %d bytes, max is %d\n", ··· 226 212 wil_err(wil, "WMI head is garbage: 0x%08x\n", r->head); 227 213 return -EINVAL; 228 214 } 215 + 216 + wil_halp_vote(wil); 217 + 229 218 /* read Tx head till it is not busy */ 230 219 for (retry = 5; retry > 0; retry--) { 231 220 wil_memcpy_fromio_32(&d_head, head, sizeof(d_head)); ··· 238 221 } 239 222 if (d_head.sync != 0) { 240 223 wil_err(wil, "WMI head busy\n"); 241 - return -EBUSY; 224 + rc = -EBUSY; 225 + goto out; 242 226 } 243 227 /* next head */ 244 228 next_head = r->base + ((r->head - r->base + sizeof(d_head)) % r->size); ··· 248 230 for (retry = 5; retry > 0; retry--) { 249 231 if (!test_bit(wil_status_fwready, wil->status)) { 250 232 wil_err(wil, "WMI: cannot send command while FW not ready\n"); 251 - return -EAGAIN; 233 + rc = -EAGAIN; 234 + goto out; 252 235 } 253 236 r->tail = wil_r(wil, RGF_MBOX + 254 237 offsetof(struct wil6210_mbox_ctl, tx.tail)); ··· 259 240 } 260 241 if (next_head == r->tail) { 261 242 wil_err(wil, "WMI ring full\n"); 262 - return -EBUSY; 243 + rc = -EBUSY; 244 + goto out; 263 245 } 264 246 dst = wmi_buffer(wil, d_head.addr); 265 247 if (!dst) { 266 248 wil_err(wil, "invalid WMI buffer: 0x%08x\n", 267 249 le32_to_cpu(d_head.addr)); 268 - return -EINVAL; 250 + rc = -EAGAIN; 251 + goto out; 269 252 } 270 253 cmd.hdr.seq = cpu_to_le16(++wil->wmi_seq); 271 254 /* set command */ ··· 290 269 wil_w(wil, RGF_USER_USER_ICR + offsetof(struct RGF_ICR, ICS), 291 270 SW_INT_MBOX); 292 271 293 - return 0; 272 + out: 273 + wil_halp_unvote(wil); 274 + return rc; 294 275 } 295 276 296 277 int wmi_send(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len) ··· 984 961 return wmi_send(wil, WMI_SET_MAC_ADDRESS_CMDID, &cmd, sizeof(cmd)); 985 962 } 986 963 964 + int wmi_led_cfg(struct wil6210_priv *wil, bool enable) 965 + { 966 + int rc = 0; 967 + struct wmi_led_cfg_cmd cmd = { 968 + .led_mode = enable, 969 + .id = led_id, 970 + .slow_blink_cfg.blink_on = 971 + cpu_to_le32(led_blink_time[WIL_LED_TIME_SLOW].on_ms), 972 + .slow_blink_cfg.blink_off = 973 + cpu_to_le32(led_blink_time[WIL_LED_TIME_SLOW].off_ms), 974 + .medium_blink_cfg.blink_on = 975 + cpu_to_le32(led_blink_time[WIL_LED_TIME_MED].on_ms), 976 + .medium_blink_cfg.blink_off = 977 + cpu_to_le32(led_blink_time[WIL_LED_TIME_MED].off_ms), 978 + .fast_blink_cfg.blink_on = 979 + cpu_to_le32(led_blink_time[WIL_LED_TIME_FAST].on_ms), 980 + .fast_blink_cfg.blink_off = 981 + cpu_to_le32(led_blink_time[WIL_LED_TIME_FAST].off_ms), 982 + .led_polarity = led_polarity, 983 + }; 984 + struct { 985 + struct wmi_cmd_hdr wmi; 986 + struct wmi_led_cfg_done_event evt; 987 + } __packed reply; 988 + 989 + if (led_id == WIL_LED_INVALID_ID) 990 + goto out; 991 + 992 + if (led_id > WIL_LED_MAX_ID) { 993 + wil_err(wil, "Invalid led id %d\n", led_id); 994 + rc = -EINVAL; 995 + goto out; 996 + } 997 + 998 + wil_dbg_wmi(wil, 999 + "%s led %d\n", 1000 + enable ? "enabling" : "disabling", led_id); 1001 + 1002 + rc = wmi_call(wil, WMI_LED_CFG_CMDID, &cmd, sizeof(cmd), 1003 + WMI_LED_CFG_DONE_EVENTID, &reply, sizeof(reply), 1004 + 100); 1005 + if (rc) 1006 + goto out; 1007 + 1008 + if (reply.evt.status) { 1009 + wil_err(wil, "led %d cfg failed with status %d\n", 1010 + led_id, le32_to_cpu(reply.evt.status)); 1011 + rc = -EINVAL; 1012 + } 1013 + 1014 + out: 1015 + return rc; 1016 + } 1017 + 987 1018 int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 wmi_nettype, 988 1019 u8 chan, u8 hidden_ssid, u8 is_go) 989 1020 { ··· 1080 1003 if (reply.evt.status != WMI_FW_STATUS_SUCCESS) 1081 1004 rc = -EINVAL; 1082 1005 1006 + if (wmi_nettype != WMI_NETTYPE_P2P) 1007 + /* Don't fail due to error in the led configuration */ 1008 + wmi_led_cfg(wil, true); 1009 + 1083 1010 return rc; 1084 1011 } 1085 1012 1086 1013 int wmi_pcp_stop(struct wil6210_priv *wil) 1087 1014 { 1015 + int rc; 1016 + 1017 + rc = wmi_led_cfg(wil, false); 1018 + if (rc) 1019 + return rc; 1020 + 1088 1021 return wmi_call(wil, WMI_PCP_STOP_CMDID, NULL, 0, 1089 1022 WMI_PCP_STOPPED_EVENTID, NULL, 0, 20); 1090 1023 }
+61
drivers/net/wireless/ath/wil6210/wmi.h
··· 129 129 WMI_THERMAL_THROTTLING_GET_STATUS_CMDID = 0x855, 130 130 WMI_OTP_READ_CMDID = 0x856, 131 131 WMI_OTP_WRITE_CMDID = 0x857, 132 + WMI_LED_CFG_CMDID = 0x858, 132 133 /* Performance monitoring commands */ 133 134 WMI_BF_CTRL_CMDID = 0x862, 134 135 WMI_NOTIFY_REQ_CMDID = 0x863, ··· 869 868 WMI_RX_MGMT_PACKET_EVENTID = 0x1840, 870 869 WMI_TX_MGMT_PACKET_EVENTID = 0x1841, 871 870 WMI_OTP_READ_RESULT_EVENTID = 0x1856, 871 + WMI_LED_CFG_DONE_EVENTID = 0x1858, 872 872 /* Performance monitoring events */ 873 873 WMI_DATA_PORT_OPEN_EVENTID = 0x1860, 874 874 WMI_WBE_LINK_DOWN_EVENTID = 0x1861, ··· 1350 1348 WMI_HIDDEN_SSID_SEND_EMPTY = 0x10, 1351 1349 WMI_HIDDEN_SSID_CLEAR = 0xFE, 1352 1350 }; 1351 + 1352 + /* WMI_LED_CFG_CMDID 1353 + * 1354 + * Configure LED On\Off\Blinking operation 1355 + * 1356 + * Returned events: 1357 + * - WMI_LED_CFG_DONE_EVENTID 1358 + */ 1359 + enum led_mode { 1360 + LED_DISABLE = 0x00, 1361 + LED_ENABLE = 0x01, 1362 + }; 1363 + 1364 + /* The names of the led as 1365 + * described on HW schemes. 1366 + */ 1367 + enum wmi_led_id { 1368 + WMI_LED_WLAN = 0x00, 1369 + WMI_LED_WPAN = 0x01, 1370 + WMI_LED_WWAN = 0x02, 1371 + }; 1372 + 1373 + /* Led polarity mode. */ 1374 + enum wmi_led_polarity { 1375 + LED_POLARITY_HIGH_ACTIVE = 0x00, 1376 + LED_POLARITY_LOW_ACTIVE = 0x01, 1377 + }; 1378 + 1379 + /* Combination of on and off 1380 + * creates the blinking period 1381 + */ 1382 + struct wmi_led_blink_mode { 1383 + __le32 blink_on; 1384 + __le32 blink_off; 1385 + } __packed; 1386 + 1387 + /* WMI_LED_CFG_CMDID */ 1388 + struct wmi_led_cfg_cmd { 1389 + /* enum led_mode_e */ 1390 + u8 led_mode; 1391 + /* enum wmi_led_id_e */ 1392 + u8 id; 1393 + /* slow speed blinking combination */ 1394 + struct wmi_led_blink_mode slow_blink_cfg; 1395 + /* medium speed blinking combination */ 1396 + struct wmi_led_blink_mode medium_blink_cfg; 1397 + /* high speed blinking combination */ 1398 + struct wmi_led_blink_mode fast_blink_cfg; 1399 + /* polarity of the led */ 1400 + u8 led_polarity; 1401 + /* reserved */ 1402 + u8 reserved; 1403 + } __packed; 1404 + 1405 + /* WMI_LED_CFG_DONE_EVENTID */ 1406 + struct wmi_led_cfg_done_event { 1407 + /* led config status */ 1408 + __le32 status; 1409 + } __packed; 1353 1410 1354 1411 #endif /* __WILOCITY_WMI_H__ */
+1 -1
drivers/net/wireless/atmel/atmel.c
··· 2275 2275 fwrq->m = ieee80211_frequency_to_channel(f); 2276 2276 } 2277 2277 /* Setting by channel number */ 2278 - if ((fwrq->m > 1000) || (fwrq->e > 0)) 2278 + if (fwrq->m < 0 || fwrq->m > 1000 || fwrq->e > 0) 2279 2279 rc = -EOPNOTSUPP; 2280 2280 else { 2281 2281 int channel = fwrq->m;
+1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
··· 1098 1098 BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43430), 1099 1099 BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4345), 1100 1100 BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4354), 1101 + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4356), 1101 1102 { /* end: all zeroes */ } 1102 1103 }; 1103 1104 MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
+1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
··· 1333 1333 1334 1334 switch (pub->chip) { 1335 1335 case BRCM_CC_4354_CHIP_ID: 1336 + case BRCM_CC_4356_CHIP_ID: 1336 1337 /* explicitly check SR engine enable bit */ 1337 1338 pmu_cc3_mask = BIT(2); 1338 1339 /* fall-through */
+3 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
··· 609 609 BRCMF_FW_NVRAM_DEF(43430, "brcmfmac43430-sdio.bin", "brcmfmac43430-sdio.txt"); 610 610 BRCMF_FW_NVRAM_DEF(43455, "brcmfmac43455-sdio.bin", "brcmfmac43455-sdio.txt"); 611 611 BRCMF_FW_NVRAM_DEF(4354, "brcmfmac4354-sdio.bin", "brcmfmac4354-sdio.txt"); 612 + BRCMF_FW_NVRAM_DEF(4356, "brcmfmac4356-sdio.bin", "brcmfmac4356-sdio.txt"); 612 613 613 614 static struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = { 614 615 BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43143_CHIP_ID, 0xFFFFFFFF, 43143), ··· 625 624 BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4339_CHIP_ID, 0xFFFFFFFF, 4339), 626 625 BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43430_CHIP_ID, 0xFFFFFFFF, 43430), 627 626 BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4345_CHIP_ID, 0xFFFFFFC0, 43455), 628 - BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, 4354) 627 + BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, 4354), 628 + BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356) 629 629 }; 630 630 631 631 static void pkt_align(struct sk_buff *p, int len, int align)
+1 -1
drivers/net/wireless/cisco/airo.c
··· 5794 5794 fwrq->m = ieee80211_frequency_to_channel(f); 5795 5795 } 5796 5796 /* Setting by channel number */ 5797 - if((fwrq->m > 1000) || (fwrq->e > 0)) 5797 + if (fwrq->m < 0 || fwrq->m > 1000 || fwrq->e > 0) 5798 5798 rc = -EOPNOTSUPP; 5799 5799 else { 5800 5800 int channel = fwrq->m;
-6
drivers/net/wireless/intel/iwlwifi/Kconfig
··· 134 134 is a low-impact option that allows getting insight into the 135 135 driver's state at runtime. 136 136 137 - config IWLWIFI_DEBUG_EXPERIMENTAL_UCODE 138 - bool "Experimental uCode support" 139 - depends on IWLWIFI_DEBUG 140 - ---help--- 141 - Enable use of experimental ucode for testing and debugging. 142 - 143 137 config IWLWIFI_DEVICE_TRACING 144 138 bool "iwlwifi device access tracing" 145 139 depends on EVENT_TRACING
+1 -1
drivers/net/wireless/intel/iwlwifi/iwl-1000.c
··· 52 52 static const struct iwl_base_params iwl1000_base_params = { 53 53 .num_of_queues = IWLAGN_NUM_QUEUES, 54 54 .eeprom_size = OTP_LOW_IMAGE_SIZE, 55 - .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL, 55 + .pll_cfg = true, 56 56 .max_ll_items = OTP_MAX_LL_ITEMS_1000, 57 57 .shadow_ram_support = false, 58 58 .led_compensation = 51,
-2
drivers/net/wireless/intel/iwlwifi/iwl-2000.c
··· 62 62 static const struct iwl_base_params iwl2000_base_params = { 63 63 .eeprom_size = OTP_LOW_IMAGE_SIZE, 64 64 .num_of_queues = IWLAGN_NUM_QUEUES, 65 - .pll_cfg_val = 0, 66 65 .max_ll_items = OTP_MAX_LL_ITEMS_2x00, 67 66 .shadow_ram_support = true, 68 67 .led_compensation = 51, ··· 75 76 static const struct iwl_base_params iwl2030_base_params = { 76 77 .eeprom_size = OTP_LOW_IMAGE_SIZE, 77 78 .num_of_queues = IWLAGN_NUM_QUEUES, 78 - .pll_cfg_val = 0, 79 79 .max_ll_items = OTP_MAX_LL_ITEMS_2x00, 80 80 .shadow_ram_support = true, 81 81 .led_compensation = 57,
+1 -1
drivers/net/wireless/intel/iwlwifi/iwl-5000.c
··· 53 53 static const struct iwl_base_params iwl5000_base_params = { 54 54 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE, 55 55 .num_of_queues = IWLAGN_NUM_QUEUES, 56 - .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL, 56 + .pll_cfg = true, 57 57 .led_compensation = 51, 58 58 .wd_timeout = IWL_WATCHDOG_DISABLED, 59 59 .max_event_log_size = 512,
-3
drivers/net/wireless/intel/iwlwifi/iwl-6000.c
··· 71 71 static const struct iwl_base_params iwl6000_base_params = { 72 72 .eeprom_size = OTP_LOW_IMAGE_SIZE, 73 73 .num_of_queues = IWLAGN_NUM_QUEUES, 74 - .pll_cfg_val = 0, 75 74 .max_ll_items = OTP_MAX_LL_ITEMS_6x00, 76 75 .shadow_ram_support = true, 77 76 .led_compensation = 51, ··· 83 84 static const struct iwl_base_params iwl6050_base_params = { 84 85 .eeprom_size = OTP_LOW_IMAGE_SIZE, 85 86 .num_of_queues = IWLAGN_NUM_QUEUES, 86 - .pll_cfg_val = 0, 87 87 .max_ll_items = OTP_MAX_LL_ITEMS_6x50, 88 88 .shadow_ram_support = true, 89 89 .led_compensation = 51, ··· 95 97 static const struct iwl_base_params iwl6000_g2_base_params = { 96 98 .eeprom_size = OTP_LOW_IMAGE_SIZE, 97 99 .num_of_queues = IWLAGN_NUM_QUEUES, 98 - .pll_cfg_val = 0, 99 100 .max_ll_items = OTP_MAX_LL_ITEMS_6x00, 100 101 .shadow_ram_support = true, 101 102 .led_compensation = 57,
-1
drivers/net/wireless/intel/iwlwifi/iwl-7000.c
··· 122 122 static const struct iwl_base_params iwl7000_base_params = { 123 123 .eeprom_size = OTP_LOW_IMAGE_SIZE_FAMILY_7000, 124 124 .num_of_queues = 31, 125 - .pll_cfg_val = 0, 126 125 .shadow_ram_support = true, 127 126 .led_compensation = 57, 128 127 .wd_timeout = IWL_LONG_WD_TIMEOUT,
+14 -1
drivers/net/wireless/intel/iwlwifi/iwl-8000.c
··· 112 112 static const struct iwl_base_params iwl8000_base_params = { 113 113 .eeprom_size = OTP_LOW_IMAGE_SIZE_FAMILY_8000, 114 114 .num_of_queues = 31, 115 - .pll_cfg_val = 0, 116 115 .shadow_ram_support = true, 117 116 .led_compensation = 57, 118 117 .wd_timeout = IWL_LONG_WD_TIMEOUT, ··· 226 227 .name = "Intel(R) Dual Band Wireless-AC 8260", 227 228 .fw_name_pre = IWL8000_FW_PRE, 228 229 IWL_DEVICE_8260, 230 + .ht_params = &iwl8000_ht_params, 231 + .nvm_ver = IWL8000_NVM_VERSION, 232 + .nvm_calib_ver = IWL8000_TX_POWER_VERSION, 233 + .max_rx_agg_size = MAX_RX_AGG_SIZE_8260_SDIO, 234 + .max_tx_agg_size = MAX_TX_AGG_SIZE_8260_SDIO, 235 + .disable_dummy_notification = true, 236 + .max_ht_ampdu_exponent = MAX_HT_AMPDU_EXPONENT_8260_SDIO, 237 + .max_vht_ampdu_exponent = MAX_VHT_AMPDU_EXPONENT_8260_SDIO, 238 + }; 239 + 240 + const struct iwl_cfg iwl8265_2ac_sdio_cfg = { 241 + .name = "Intel(R) Dual Band Wireless-AC 8265", 242 + .fw_name_pre = IWL8265_FW_PRE, 243 + IWL_DEVICE_8265, 229 244 .ht_params = &iwl8000_ht_params, 230 245 .nvm_ver = IWL8000_NVM_VERSION, 231 246 .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
+28 -6
drivers/net/wireless/intel/iwlwifi/iwl-9000.c
··· 72 72 #define IWL9000_SMEM_OFFSET 0x400000 73 73 #define IWL9000_SMEM_LEN 0x68000 74 74 75 - #define IWL9000_FW_PRE "iwlwifi-9000-" 75 + #define IWL9000_FW_PRE "iwlwifi-9000-pu-a0-lc-a0-" 76 + #define IWL9260_FW_PRE "iwlwifi-9260-th-a0-jf-a0-" 77 + #define IWL9260LC_FW_PRE "iwlwifi-9260-th-a0-lc-a0-" 76 78 #define IWL9000_MODULE_FIRMWARE(api) \ 77 79 IWL9000_FW_PRE "-" __stringify(api) ".ucode" 80 + #define IWL9260_MODULE_FIRMWARE(api) \ 81 + IWL9260_FW_PRE "-" __stringify(api) ".ucode" 82 + #define IWL9260LC_MODULE_FIRMWARE(api) \ 83 + IWL9260LC_FW_PRE "-" __stringify(api) ".ucode" 78 84 79 85 #define NVM_HW_SECTION_NUM_FAMILY_9000 10 80 86 81 87 static const struct iwl_base_params iwl9000_base_params = { 82 88 .eeprom_size = OTP_LOW_IMAGE_SIZE_FAMILY_9000, 83 89 .num_of_queues = 31, 84 - .pll_cfg_val = 0, 85 90 .shadow_ram_support = true, 86 91 .led_compensation = 57, 87 92 .wd_timeout = IWL_LONG_WD_TIMEOUT, ··· 143 138 .apmg_not_supported = true, \ 144 139 .mq_rx_supported = true, \ 145 140 .vht_mu_mimo_supported = true, \ 146 - .mac_addr_from_csr = true 141 + .mac_addr_from_csr = true, \ 142 + .rf_id = true 147 143 148 - const struct iwl_cfg iwl9560_2ac_cfg = { 149 - .name = "Intel(R) Dual Band Wireless AC 9560", 150 - .fw_name_pre = IWL9000_FW_PRE, 144 + const struct iwl_cfg iwl9260_2ac_cfg = { 145 + .name = "Intel(R) Dual Band Wireless AC 9260", 146 + .fw_name_pre = IWL9260_FW_PRE, 147 + IWL_DEVICE_9000, 148 + .ht_params = &iwl9000_ht_params, 149 + .nvm_ver = IWL9000_NVM_VERSION, 150 + .nvm_calib_ver = IWL9000_TX_POWER_VERSION, 151 + .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K, 152 + }; 153 + 154 + /* 155 + * TODO the struct below is for internal testing only this should be 156 + * removed by EO 2016~ 157 + */ 158 + const struct iwl_cfg iwl9260lc_2ac_cfg = { 159 + .name = "Intel(R) Dual Band Wireless AC 9260", 160 + .fw_name_pre = IWL9260LC_FW_PRE, 151 161 IWL_DEVICE_9000, 152 162 .ht_params = &iwl9000_ht_params, 153 163 .nvm_ver = IWL9000_NVM_VERSION, ··· 181 161 }; 182 162 183 163 MODULE_FIRMWARE(IWL9000_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX)); 164 + MODULE_FIRMWARE(IWL9260_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX)); 165 + MODULE_FIRMWARE(IWL9260LC_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
+65 -57
drivers/net/wireless/intel/iwlwifi/iwl-config.h
··· 6 6 * GPL LICENSE SUMMARY 7 7 * 8 8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. 9 + * Copyright (C) 2016 Intel Deutschland GmbH 9 10 * 10 11 * This program is free software; you can redistribute it and/or modify 11 12 * it under the terms of version 2 of the GNU General Public License as ··· 32 31 * BSD LICENSE 33 32 * 34 33 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. 34 + * Copyright (C) 2016 Intel Deutschland GmbH 35 35 * All rights reserved. 36 36 * 37 37 * Redistribution and use in source and binary forms, with or without ··· 167 165 * @scd_chain_ext_wa: should the chain extension feature in SCD be disabled. 168 166 */ 169 167 struct iwl_base_params { 170 - int eeprom_size; 171 - int num_of_queues; /* def: HW dependent */ 172 - /* for iwl_pcie_apm_init() */ 173 - u32 pll_cfg_val; 174 - 175 - const u16 max_ll_items; 176 - const bool shadow_ram_support; 177 - u16 led_compensation; 178 168 unsigned int wd_timeout; 179 - u32 max_event_log_size; 180 - const bool shadow_reg_enable; 181 - const bool pcie_l1_allowed; 182 - const bool apmg_wake_up_wa; 183 - const bool scd_chain_ext_wa; 169 + 170 + u16 eeprom_size; 171 + u16 max_event_log_size; 172 + 173 + u8 pll_cfg:1, /* for iwl_pcie_apm_init() */ 174 + shadow_ram_support:1, 175 + shadow_reg_enable:1, 176 + pcie_l1_allowed:1, 177 + apmg_wake_up_wa:1, 178 + scd_chain_ext_wa:1; 179 + 180 + u8 num_of_queues; /* def: HW dependent */ 181 + 182 + u8 max_ll_items; 183 + u8 led_compensation; 184 184 }; 185 185 186 186 /* ··· 193 189 */ 194 190 struct iwl_ht_params { 195 191 enum ieee80211_smps_mode smps_mode; 196 - const bool ht_greenfield_support; /* if used set to true */ 197 - const bool stbc; 198 - const bool ldpc; 199 - bool use_rts_for_aggregation; 192 + u8 ht_greenfield_support:1, 193 + stbc:1, 194 + ldpc:1, 195 + use_rts_for_aggregation:1; 200 196 u8 ht40_bands; 201 197 }; 202 198 ··· 237 233 u32 tx_protection_entry; 238 234 u32 tx_protection_exit; 239 235 struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE]; 240 - bool support_ct_kill; 241 - bool support_dynamic_smps; 242 - bool support_tx_protection; 243 - bool support_tx_backoff; 236 + u8 support_ct_kill:1, 237 + support_dynamic_smps:1, 238 + support_tx_protection:1, 239 + support_tx_backoff:1; 244 240 }; 245 241 246 242 /* ··· 318 314 * @smem_len: the length of SMEM 319 315 * @mq_rx_supported: multi-queue rx support 320 316 * @vht_mu_mimo_supported: VHT MU-MIMO support 317 + * @rf_id: need to read rf_id to determine the firmware image 321 318 * 322 319 * We enable the driver to be backward compatible wrt. hardware features. 323 320 * API differences in uCode shouldn't be handled here but through TLVs ··· 328 323 /* params specific to an individual device within a device family */ 329 324 const char *name; 330 325 const char *fw_name_pre; 331 - const unsigned int ucode_api_max; 332 - const unsigned int ucode_api_min; 333 - const enum iwl_device_family device_family; 334 - const u32 max_data_size; 335 - const u32 max_inst_size; 336 - u8 valid_tx_ant; 337 - u8 valid_rx_ant; 338 - u8 non_shared_ant; 339 - bool bt_shared_single_ant; 340 - u16 nvm_ver; 341 - u16 nvm_calib_ver; 342 326 /* params not likely to change within a device family */ 343 327 const struct iwl_base_params *base_params; 344 328 /* params likely to change within a device family */ 345 329 const struct iwl_ht_params *ht_params; 346 330 const struct iwl_eeprom_params *eeprom_params; 347 - enum iwl_led_mode led_mode; 348 - const bool rx_with_siso_diversity; 349 - const bool internal_wimax_coex; 350 - const bool host_interrupt_operation_mode; 351 - bool high_temp; 352 - u8 nvm_hw_section_num; 353 - bool mac_addr_from_csr; 354 - bool lp_xtal_workaround; 355 331 const struct iwl_pwr_tx_backoff *pwr_tx_backoffs; 356 - bool no_power_up_nic_in_init; 357 332 const char *default_nvm_file_B_step; 358 333 const char *default_nvm_file_C_step; 359 - netdev_features_t features; 360 - unsigned int max_rx_agg_size; 361 - bool disable_dummy_notification; 362 - unsigned int max_tx_agg_size; 363 - unsigned int max_ht_ampdu_exponent; 364 - unsigned int max_vht_ampdu_exponent; 365 - const u32 dccm_offset; 366 - const u32 dccm_len; 367 - const u32 dccm2_offset; 368 - const u32 dccm2_len; 369 - const u32 smem_offset; 370 - const u32 smem_len; 371 334 const struct iwl_tt_params *thermal_params; 372 - bool apmg_not_supported; 373 - bool mq_rx_supported; 374 - bool vht_mu_mimo_supported; 335 + enum iwl_device_family device_family; 336 + enum iwl_led_mode led_mode; 337 + u32 max_data_size; 338 + u32 max_inst_size; 339 + netdev_features_t features; 340 + u32 dccm_offset; 341 + u32 dccm_len; 342 + u32 dccm2_offset; 343 + u32 dccm2_len; 344 + u32 smem_offset; 345 + u32 smem_len; 346 + u16 nvm_ver; 347 + u16 nvm_calib_ver; 348 + u16 rx_with_siso_diversity:1, 349 + bt_shared_single_ant:1, 350 + internal_wimax_coex:1, 351 + host_interrupt_operation_mode:1, 352 + high_temp:1, 353 + mac_addr_from_csr:1, 354 + lp_xtal_workaround:1, 355 + no_power_up_nic_in_init:1, 356 + disable_dummy_notification:1, 357 + apmg_not_supported:1, 358 + mq_rx_supported:1, 359 + vht_mu_mimo_supported:1, 360 + rf_id:1; 361 + u8 valid_tx_ant; 362 + u8 valid_rx_ant; 363 + u8 non_shared_ant; 364 + u8 nvm_hw_section_num; 365 + u8 max_rx_agg_size; 366 + u8 max_tx_agg_size; 367 + u8 max_ht_ampdu_exponent; 368 + u8 max_vht_ampdu_exponent; 369 + u8 ucode_api_max; 370 + u8 ucode_api_min; 375 371 }; 376 372 377 373 /* ··· 443 437 extern const struct iwl_cfg iwl8265_2ac_cfg; 444 438 extern const struct iwl_cfg iwl4165_2ac_cfg; 445 439 extern const struct iwl_cfg iwl8260_2ac_sdio_cfg; 440 + extern const struct iwl_cfg iwl8265_2ac_sdio_cfg; 446 441 extern const struct iwl_cfg iwl4165_2ac_sdio_cfg; 447 - extern const struct iwl_cfg iwl9560_2ac_cfg; 442 + extern const struct iwl_cfg iwl9260_2ac_cfg; 443 + extern const struct iwl_cfg iwl9260lc_2ac_cfg; 448 444 extern const struct iwl_cfg iwl5165_2ac_cfg; 449 445 #endif /* CONFIG_IWLMVM */ 450 446
+15
drivers/net/wireless/intel/iwlwifi/iwl-csr.h
··· 108 108 #define CSR_HW_REV (CSR_BASE+0x028) 109 109 110 110 /* 111 + * RF ID revision info 112 + * Bit fields: 113 + * 31:24: Reserved (set to 0x0) 114 + * 23:12: Type 115 + * 11:8: Step (A - 0x0, B - 0x1, etc) 116 + * 7:4: Dash 117 + * 3:0: Flavor 118 + */ 119 + #define CSR_HW_RF_ID (CSR_BASE+0x09c) 120 + 121 + /* 111 122 * EEPROM and OTP (one-time-programmable) memory reads 112 123 * 113 124 * NOTE: Device must be awake, initialized via apm_ops.init(), ··· 343 332 #define CSR_HW_REV_TYPE_135 (0x0000120) 344 333 #define CSR_HW_REV_TYPE_7265D (0x0000210) 345 334 #define CSR_HW_REV_TYPE_NONE (0x00001F0) 335 + 336 + /* RF_ID value */ 337 + #define CSR_HW_RF_ID_TYPE_JF (0x00105000) 338 + #define CSR_HW_RF_ID_TYPE_LC (0x00101000) 346 339 347 340 /* EEPROM REG */ 348 341 #define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
+11 -28
drivers/net/wireless/intel/iwlwifi/iwl-drv.c
··· 117 117 const struct iwl_cfg *cfg; 118 118 119 119 int fw_index; /* firmware we're trying to load */ 120 - char firmware_name[32]; /* name of firmware file to load */ 120 + char firmware_name[64]; /* name of firmware file to load */ 121 121 122 122 struct completion request_firmware_complete; 123 123 ··· 211 211 static void iwl_req_fw_callback(const struct firmware *ucode_raw, 212 212 void *context); 213 213 214 - #define UCODE_EXPERIMENTAL_INDEX 100 215 - #define UCODE_EXPERIMENTAL_TAG "exp" 216 - 217 214 static int iwl_request_firmware(struct iwl_drv *drv, bool first) 218 215 { 219 216 const char *name_pre = drv->cfg->fw_name_pre; 220 217 char tag[8]; 221 218 222 219 if (first) { 223 - #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE 224 - drv->fw_index = UCODE_EXPERIMENTAL_INDEX; 225 - strcpy(tag, UCODE_EXPERIMENTAL_TAG); 226 - } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) { 227 - #endif 228 220 drv->fw_index = drv->cfg->ucode_api_max; 229 221 sprintf(tag, "%d", drv->fw_index); 230 222 } else { ··· 232 240 snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%s.ucode", 233 241 name_pre, tag); 234 242 235 - IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n", 236 - (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) 237 - ? "EXPERIMENTAL " : "", 243 + IWL_DEBUG_INFO(drv, "attempting to load firmware '%s'\n", 238 244 drv->firmware_name); 239 245 240 246 return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name, ··· 531 541 } 532 542 533 543 if (build) 534 - sprintf(buildstr, " build %u%s", build, 535 - (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) 536 - ? " (EXP)" : ""); 544 + sprintf(buildstr, " build %u", build); 537 545 else 538 546 buildstr[0] = '\0'; 539 547 ··· 615 627 build = le32_to_cpu(ucode->build); 616 628 617 629 if (build) 618 - sprintf(buildstr, " build %u%s", build, 619 - (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) 620 - ? " (EXP)" : ""); 630 + sprintf(buildstr, " build %u", build); 621 631 else 622 632 buildstr[0] = '\0'; 623 633 ··· 1263 1277 * firmware filename ... but we don't check for that and only rely 1264 1278 * on the API version read from firmware header from here on forward 1265 1279 */ 1266 - /* no api version check required for experimental uCode */ 1267 - if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) { 1268 - if (api_ver < api_min || api_ver > api_max) { 1269 - IWL_ERR(drv, 1270 - "Driver unable to support your firmware API. " 1271 - "Driver supports v%u, firmware is v%u.\n", 1272 - api_max, api_ver); 1273 - goto try_again; 1274 - } 1280 + if (api_ver < api_min || api_ver > api_max) { 1281 + IWL_ERR(drv, 1282 + "Driver unable to support your firmware API. " 1283 + "Driver supports v%u, firmware is v%u.\n", 1284 + api_max, api_ver); 1285 + goto try_again; 1275 1286 } 1276 1287 1277 1288 /* ··· 1727 1744 1728 1745 module_param_named(disable_11ac, iwlwifi_mod_params.disable_11ac, bool, 1729 1746 S_IRUGO); 1730 - MODULE_PARM_DESC(disable_11ac, "Disable VHT capabilities"); 1747 + MODULE_PARM_DESC(disable_11ac, "Disable VHT capabilities (default: false)");
+1
drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h
··· 98 98 s8 max_tx_pwr_half_dbm; 99 99 100 100 bool lar_enabled; 101 + bool vht160_supported; 101 102 struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; 102 103 struct ieee80211_channel channels[]; 103 104 };
+3
drivers/net/wireless/intel/iwlwifi/iwl-fh.h
··· 321 321 /* Write index table */ 322 322 #define RFH_Q0_FRBDCB_WIDX 0xA08080 323 323 #define RFH_Q_FRBDCB_WIDX(q) (RFH_Q0_FRBDCB_WIDX + (q) * 4) 324 + /* Write index table - shadow registers */ 325 + #define RFH_Q0_FRBDCB_WIDX_TRG 0x1C80 326 + #define RFH_Q_FRBDCB_WIDX_TRG(q) (RFH_Q0_FRBDCB_WIDX_TRG + (q) * 4) 324 327 /* Read index table */ 325 328 #define RFH_Q0_FRBDCB_RIDX 0xA080C0 326 329 #define RFH_Q_FRBDCB_RIDX(q) (RFH_Q0_FRBDCB_RIDX + (q) * 4)
+13 -3
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
··· 288 288 !data->sku_cap_band_52GHz_enable) 289 289 continue; 290 290 291 + if (ch_flags & NVM_CHANNEL_160MHZ) 292 + data->vht160_supported = true; 293 + 291 294 if (!lar_supported && !(ch_flags & NVM_CHANNEL_VALID)) { 292 295 /* 293 296 * Channels might become valid later if lar is ··· 334 331 channel->flags = 0; 335 332 336 333 IWL_DEBUG_EEPROM(dev, 337 - "Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n", 334 + "Ch. %d [%sGHz] flags 0x%x %s%s%s%s%s%s%s%s%s%s(%ddBm): Ad-Hoc %ssupported\n", 338 335 channel->hw_value, 339 336 is_5ghz ? "5.2" : "2.4", 337 + ch_flags, 340 338 CHECK_AND_PRINT_I(VALID), 341 339 CHECK_AND_PRINT_I(IBSS), 342 340 CHECK_AND_PRINT_I(ACTIVE), 343 341 CHECK_AND_PRINT_I(RADAR), 344 - CHECK_AND_PRINT_I(WIDE), 345 342 CHECK_AND_PRINT_I(INDOOR_ONLY), 346 343 CHECK_AND_PRINT_I(GO_CONCURRENT), 347 - ch_flags, 344 + CHECK_AND_PRINT_I(WIDE), 345 + CHECK_AND_PRINT_I(40MHZ), 346 + CHECK_AND_PRINT_I(80MHZ), 347 + CHECK_AND_PRINT_I(160MHZ), 348 348 channel->max_power, 349 349 ((ch_flags & NVM_CHANNEL_IBSS) && 350 350 !(ch_flags & NVM_CHANNEL_RADAR)) ··· 375 369 3 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT | 376 370 max_ampdu_exponent << 377 371 IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; 372 + 373 + if (data->vht160_supported) 374 + vht_cap->cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ | 375 + IEEE80211_VHT_CAP_SHORT_GI_160; 378 376 379 377 if (cfg->vht_mu_mimo_supported) 380 378 vht_cap->cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
+52 -16
drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
··· 6 6 * GPL LICENSE SUMMARY 7 7 * 8 8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. 9 + * Copyright(c) 2016 Intel Deutschland GmbH 9 10 * 10 11 * This program is free software; you can redistribute it and/or modify 11 12 * it under the terms of version 2 of the GNU General Public License as ··· 73 72 #include "iwl-trans.h" 74 73 75 74 #define CHANNEL_NUM_SIZE 4 /* num of channels in calib_ch size */ 76 - #define IWL_NUM_PAPD_CH_GROUPS 9 77 - #define IWL_NUM_TXP_CH_GROUPS 9 78 75 79 76 struct iwl_phy_db_entry { 80 77 u16 size; ··· 85 86 * @cfg: phy configuration. 86 87 * @calib_nch: non channel specific calibration data. 87 88 * @calib_ch: channel specific calibration data. 89 + * @n_group_papd: number of entries in papd channel group. 88 90 * @calib_ch_group_papd: calibration data related to papd channel group. 91 + * @n_group_txp: number of entries in tx power channel group. 89 92 * @calib_ch_group_txp: calibration data related to tx power chanel group. 90 93 */ 91 94 struct iwl_phy_db { 92 95 struct iwl_phy_db_entry cfg; 93 96 struct iwl_phy_db_entry calib_nch; 94 - struct iwl_phy_db_entry calib_ch_group_papd[IWL_NUM_PAPD_CH_GROUPS]; 95 - struct iwl_phy_db_entry calib_ch_group_txp[IWL_NUM_TXP_CH_GROUPS]; 97 + int n_group_papd; 98 + struct iwl_phy_db_entry *calib_ch_group_papd; 99 + int n_group_txp; 100 + struct iwl_phy_db_entry *calib_ch_group_txp; 96 101 97 102 struct iwl_trans *trans; 98 103 }; ··· 146 143 147 144 phy_db->trans = trans; 148 145 146 + phy_db->n_group_txp = -1; 147 + phy_db->n_group_papd = -1; 148 + 149 149 /* TODO: add default values of the phy db. */ 150 150 return phy_db; 151 151 } ··· 172 166 case IWL_PHY_DB_CALIB_NCH: 173 167 return &phy_db->calib_nch; 174 168 case IWL_PHY_DB_CALIB_CHG_PAPD: 175 - if (chg_id >= IWL_NUM_PAPD_CH_GROUPS) 169 + if (chg_id >= phy_db->n_group_papd) 176 170 return NULL; 177 171 return &phy_db->calib_ch_group_papd[chg_id]; 178 172 case IWL_PHY_DB_CALIB_CHG_TXP: 179 - if (chg_id >= IWL_NUM_TXP_CH_GROUPS) 173 + if (chg_id >= phy_db->n_group_txp) 180 174 return NULL; 181 175 return &phy_db->calib_ch_group_txp[chg_id]; 182 176 default: ··· 208 202 209 203 iwl_phy_db_free_section(phy_db, IWL_PHY_DB_CFG, 0); 210 204 iwl_phy_db_free_section(phy_db, IWL_PHY_DB_CALIB_NCH, 0); 211 - for (i = 0; i < IWL_NUM_PAPD_CH_GROUPS; i++) 205 + 206 + for (i = 0; i < phy_db->n_group_papd; i++) 212 207 iwl_phy_db_free_section(phy_db, IWL_PHY_DB_CALIB_CHG_PAPD, i); 213 - for (i = 0; i < IWL_NUM_TXP_CH_GROUPS; i++) 208 + kfree(phy_db->calib_ch_group_papd); 209 + 210 + for (i = 0; i < phy_db->n_group_txp; i++) 214 211 iwl_phy_db_free_section(phy_db, IWL_PHY_DB_CALIB_CHG_TXP, i); 212 + kfree(phy_db->calib_ch_group_txp); 215 213 216 214 kfree(phy_db); 217 215 } 218 216 IWL_EXPORT_SYMBOL(iwl_phy_db_free); 219 217 220 - int iwl_phy_db_set_section(struct iwl_phy_db *phy_db, struct iwl_rx_packet *pkt, 221 - gfp_t alloc_ctx) 218 + int iwl_phy_db_set_section(struct iwl_phy_db *phy_db, 219 + struct iwl_rx_packet *pkt) 222 220 { 223 221 struct iwl_calib_res_notif_phy_db *phy_db_notif = 224 222 (struct iwl_calib_res_notif_phy_db *)pkt->data; ··· 234 224 if (!phy_db) 235 225 return -EINVAL; 236 226 237 - if (type == IWL_PHY_DB_CALIB_CHG_PAPD || 238 - type == IWL_PHY_DB_CALIB_CHG_TXP) 227 + if (type == IWL_PHY_DB_CALIB_CHG_PAPD) { 239 228 chg_id = le16_to_cpup((__le16 *)phy_db_notif->data); 229 + if (phy_db && !phy_db->calib_ch_group_papd) { 230 + /* 231 + * Firmware sends the largest index first, so we can use 232 + * it to know how much we should allocate. 233 + */ 234 + phy_db->calib_ch_group_papd = kcalloc(chg_id + 1, 235 + sizeof(struct iwl_phy_db_entry), 236 + GFP_ATOMIC); 237 + if (!phy_db->calib_ch_group_papd) 238 + return -ENOMEM; 239 + phy_db->n_group_papd = chg_id + 1; 240 + } 241 + } else if (type == IWL_PHY_DB_CALIB_CHG_TXP) { 242 + chg_id = le16_to_cpup((__le16 *)phy_db_notif->data); 243 + if (phy_db && !phy_db->calib_ch_group_txp) { 244 + /* 245 + * Firmware sends the largest index first, so we can use 246 + * it to know how much we should allocate. 247 + */ 248 + phy_db->calib_ch_group_txp = kcalloc(chg_id + 1, 249 + sizeof(struct iwl_phy_db_entry), 250 + GFP_ATOMIC); 251 + if (!phy_db->calib_ch_group_txp) 252 + return -ENOMEM; 253 + phy_db->n_group_txp = chg_id + 1; 254 + } 255 + } 240 256 241 257 entry = iwl_phy_db_get_section(phy_db, type, chg_id); 242 258 if (!entry) 243 259 return -EINVAL; 244 260 245 261 kfree(entry->data); 246 - entry->data = kmemdup(phy_db_notif->data, size, alloc_ctx); 262 + entry->data = kmemdup(phy_db_notif->data, size, GFP_ATOMIC); 247 263 if (!entry->data) { 248 264 entry->size = 0; 249 265 return -ENOMEM; ··· 332 296 if (ch_index == 0xff) 333 297 return 0xff; 334 298 335 - for (i = 0; i < IWL_NUM_TXP_CH_GROUPS; i++) { 299 + for (i = 0; i < phy_db->n_group_txp; i++) { 336 300 txp_chg = (void *)phy_db->calib_ch_group_txp[i].data; 337 301 if (!txp_chg) 338 302 return 0xff; ··· 483 447 /* Send all the TXP channel specific data */ 484 448 err = iwl_phy_db_send_all_channel_groups(phy_db, 485 449 IWL_PHY_DB_CALIB_CHG_PAPD, 486 - IWL_NUM_PAPD_CH_GROUPS); 450 + phy_db->n_group_papd); 487 451 if (err) { 488 452 IWL_ERR(phy_db->trans, 489 453 "Cannot send channel specific PAPD groups\n"); ··· 493 457 /* Send all the TXP channel specific data */ 494 458 err = iwl_phy_db_send_all_channel_groups(phy_db, 495 459 IWL_PHY_DB_CALIB_CHG_TXP, 496 - IWL_NUM_TXP_CH_GROUPS); 460 + phy_db->n_group_txp); 497 461 if (err) { 498 462 IWL_ERR(phy_db->trans, 499 463 "Cannot send channel specific TX power groups\n");
+2 -2
drivers/net/wireless/intel/iwlwifi/iwl-phy-db.h
··· 73 73 74 74 void iwl_phy_db_free(struct iwl_phy_db *phy_db); 75 75 76 - int iwl_phy_db_set_section(struct iwl_phy_db *phy_db, struct iwl_rx_packet *pkt, 77 - gfp_t alloc_ctx); 76 + int iwl_phy_db_set_section(struct iwl_phy_db *phy_db, 77 + struct iwl_rx_packet *pkt); 78 78 79 79 80 80 int iwl_send_phy_db_data(struct iwl_phy_db *phy_db);
+2
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
··· 753 753 * @dev - pointer to struct device * that represents the device 754 754 * @max_skb_frags: maximum number of fragments an SKB can have when transmitted. 755 755 * 0 indicates that frag SKBs (NETIF_F_SG) aren't supported. 756 + * @hw_rf_id a u32 with the device RF ID 756 757 * @hw_id: a u32 with the ID of the device / sub-device. 757 758 * Set during transport allocation. 758 759 * @hw_id_str: a string with info about HW ID. Set during transport allocation. ··· 798 797 struct device *dev; 799 798 u32 max_skb_frags; 800 799 u32 hw_rev; 800 + u32 hw_rf_id; 801 801 u32 hw_id; 802 802 char hw_id_str[52]; 803 803
+1
drivers/net/wireless/intel/iwlwifi/mvm/constants.h
··· 109 109 #define IWL_MVM_RS_80_20_FAR_RANGE_TWEAK 1 110 110 #define IWL_MVM_TOF_IS_RESPONDER 0 111 111 #define IWL_MVM_SW_TX_CSUM_OFFLOAD 0 112 + #define IWL_MVM_HW_CSUM_DISABLE 0 112 113 #define IWL_MVM_COLLECT_FW_ERR_DUMP 1 113 114 #define IWL_MVM_RS_NUM_TRY_BEFORE_ANT_TOGGLE 1 114 115 #define IWL_MVM_RS_HT_VHT_RETRIES_PER_RATE 2
+2 -6
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
··· 1804 1804 struct iwl_wowlan_status *fw_status; 1805 1805 int i; 1806 1806 bool keep; 1807 - struct ieee80211_sta *ap_sta; 1808 1807 struct iwl_mvm_sta *mvm_ap_sta; 1809 1808 1810 1809 fw_status = iwl_mvm_get_wakeup_status(mvm, vif); ··· 1822 1823 status.wake_packet = fw_status->wake_packet; 1823 1824 1824 1825 /* still at hard-coded place 0 for D3 image */ 1825 - ap_sta = rcu_dereference_protected( 1826 - mvm->fw_id_to_mac_id[0], 1827 - lockdep_is_held(&mvm->mutex)); 1828 - if (IS_ERR_OR_NULL(ap_sta)) 1826 + mvm_ap_sta = iwl_mvm_sta_from_staid_protected(mvm, 0); 1827 + if (!mvm_ap_sta) 1829 1828 goto out_free; 1830 1829 1831 - mvm_ap_sta = iwl_mvm_sta_from_mac80211(ap_sta); 1832 1830 for (i = 0; i < IWL_MAX_TID_COUNT; i++) { 1833 1831 u16 seq = status.qos_seq_ctr[i]; 1834 1832 /* firmware stores last-used value, we store next value */
+3 -6
drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
··· 281 281 282 282 if (vif->type == NL80211_IFTYPE_STATION && 283 283 ap_sta_id != IWL_MVM_STATION_COUNT) { 284 - struct ieee80211_sta *sta; 284 + struct iwl_mvm_sta *mvm_sta; 285 285 286 - sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[ap_sta_id], 287 - lockdep_is_held(&mvm->mutex)); 288 - if (!IS_ERR_OR_NULL(sta)) { 289 - struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); 290 - 286 + mvm_sta = iwl_mvm_sta_from_staid_protected(mvm, ap_sta_id); 287 + if (mvm_sta) { 291 288 pos += scnprintf(buf+pos, bufsz-pos, 292 289 "ap_sta_id %d - reduced Tx power %d\n", 293 290 ap_sta_id,
+2
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
··· 1309 1309 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_CSA); 1310 1310 PRINT_MVM_REF(IWL_MVM_REF_FW_DBG_COLLECT); 1311 1311 PRINT_MVM_REF(IWL_MVM_REF_INIT_UCODE); 1312 + PRINT_MVM_REF(IWL_MVM_REF_SENDING_CMD); 1313 + PRINT_MVM_REF(IWL_MVM_REF_RX); 1312 1314 1313 1315 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1314 1316 }
+1 -1
drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h
··· 368 368 u8 decrypt_key[16]; 369 369 u8 tkip_mic_key[8]; 370 370 struct iwl_wowlan_rsc_tsc_params_cmd rsc; 371 - } __packed; 371 + } __packed; /* WOWLAN_GTK_MATERIAL_VER_1 */ 372 372 373 373 struct iwl_wowlan_status { 374 374 struct iwl_wowlan_gtk_status gtk;
+8 -1
drivers/net/wireless/intel/iwlwifi/mvm/fw-api-rx.h
··· 437 437 /** 438 438 * Internal message identifier 439 439 * 440 + * @IWL_MVM_RXQ_EMPTY: empty sync notification 440 441 * @IWL_MVM_RXQ_NOTIF_DEL_BA: notify RSS queues of delBA 441 442 */ 442 443 enum iwl_mvm_rxq_notif_type { 444 + IWL_MVM_RXQ_EMPTY, 443 445 IWL_MVM_RXQ_NOTIF_DEL_BA, 444 446 }; 445 447 446 448 /** 447 449 * struct iwl_mvm_internal_rxq_notif - Internal representation of the data sent 448 450 * in &iwl_rxq_sync_cmd. Should be DWORD aligned. 451 + * FW is agnostic to the payload, so there are no endianity requirements. 449 452 * 450 453 * @type: value from &iwl_mvm_rxq_notif_type 454 + * @sync: ctrl path is waiting for all notifications to be received 455 + * @cookie: internal cookie to identify old notifications 451 456 * @data: payload 452 457 */ 453 458 struct iwl_mvm_internal_rxq_notif { 454 - u32 type; 459 + u16 type; 460 + u16 sync; 461 + u32 cookie; 455 462 u8 data[]; 456 463 } __packed; 457 464
+6 -4
drivers/net/wireless/intel/iwlwifi/mvm/fw-api-sta.h
··· 173 173 174 174 /** 175 175 * enum iwl_sta_modify_flag - indicate to the fw what flag are being changed 176 - * @STA_MODIFY_KEY: this command modifies %key 176 + * @STA_MODIFY_QUEUE_REMOVAL: this command removes a queue 177 177 * @STA_MODIFY_TID_DISABLE_TX: this command modifies %tid_disable_tx 178 178 * @STA_MODIFY_TX_RATE: unused 179 179 * @STA_MODIFY_ADD_BA_TID: this command modifies %add_immediate_ba_tid ··· 183 183 * @STA_MODIFY_QUEUES: modify the queues used by this station 184 184 */ 185 185 enum iwl_sta_modify_flag { 186 - STA_MODIFY_KEY = BIT(0), 186 + STA_MODIFY_QUEUE_REMOVAL = BIT(0), 187 187 STA_MODIFY_TID_DISABLE_TX = BIT(1), 188 188 STA_MODIFY_TX_RATE = BIT(2), 189 189 STA_MODIFY_ADD_BA_TID = BIT(3), ··· 255 255 __le64 hw_tkip_mic_tx_key; 256 256 } __packed; 257 257 258 - #define IWL_ADD_STA_STATUS_MASK 0xFF 259 - #define IWL_ADD_STA_BAID_MASK 0xFF00 258 + #define IWL_ADD_STA_STATUS_MASK 0xFF 259 + #define IWL_ADD_STA_BAID_VALID_MASK 0x8000 260 + #define IWL_ADD_STA_BAID_MASK 0x7F00 261 + #define IWL_ADD_STA_BAID_SHIFT 8 260 262 261 263 /** 262 264 * struct iwl_mvm_add_sta_cmd_v7 - Add/modify a station in the fw's sta table.
+5
drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h
··· 90 90 * DQA queue numbers 91 91 * 92 92 * @IWL_MVM_DQA_CMD_QUEUE: a queue reserved for sending HCMDs to the FW 93 + * @IWL_MVM_DQA_P2P_DEVICE_QUEUE: a queue reserved for P2P device frames 93 94 * @IWL_MVM_DQA_GCAST_QUEUE: a queue reserved for P2P GO/SoftAP GCAST frames 94 95 * @IWL_MVM_DQA_BSS_CLIENT_QUEUE: a queue reserved for BSS activity, to ensure 95 96 * that we are never left without the possibility to connect to an AP. ··· 98 97 * Each MGMT queue is mapped to a single STA 99 98 * MGMT frames are frames that return true on ieee80211_is_mgmt() 100 99 * @IWL_MVM_DQA_MAX_MGMT_QUEUE: last TXQ in pool for MGMT frames 100 + * @IWL_MVM_DQA_AP_PROBE_RESP_QUEUE: a queue reserved for P2P GO/SoftAP probe 101 + * responses 101 102 * @IWL_MVM_DQA_MIN_DATA_QUEUE: first TXQ in pool for DATA frames. 102 103 * DATA frames are intended for !ieee80211_is_mgmt() frames, but if 103 104 * the MGMT TXQ pool is exhausted, mgmt frames can be sent on DATA queues ··· 108 105 */ 109 106 enum iwl_mvm_dqa_txq { 110 107 IWL_MVM_DQA_CMD_QUEUE = 0, 108 + IWL_MVM_DQA_P2P_DEVICE_QUEUE = 2, 111 109 IWL_MVM_DQA_GCAST_QUEUE = 3, 112 110 IWL_MVM_DQA_BSS_CLIENT_QUEUE = 4, 113 111 IWL_MVM_DQA_MIN_MGMT_QUEUE = 5, 114 112 IWL_MVM_DQA_MAX_MGMT_QUEUE = 8, 113 + IWL_MVM_DQA_AP_PROBE_RESP_QUEUE = 9, 115 114 IWL_MVM_DQA_MIN_DATA_QUEUE = 10, 116 115 IWL_MVM_DQA_MAX_DATA_QUEUE = 31, 117 116 };
+48 -12
drivers/net/wireless/intel/iwlwifi/mvm/fw-dbg.c
··· 271 271 for (i = 0; 272 272 i < ARRAY_SIZE(mvm->shared_mem_cfg.internal_txfifo_size); 273 273 i++) { 274 - /* Mark the number of TXF we're pulling now */ 275 - iwl_trans_write_prph(mvm->trans, TXF_CPU2_NUM, i); 276 - 277 274 fifo_hdr = (void *)(*dump_data)->data; 278 275 fifo_data = (void *)fifo_hdr->data; 279 276 fifo_len = mvm->shared_mem_cfg.internal_txfifo_size[i]; ··· 286 289 cpu_to_le32(fifo_len + sizeof(*fifo_hdr)); 287 290 288 291 fifo_hdr->fifo_num = cpu_to_le32(i); 292 + 293 + /* Mark the number of TXF we're pulling now */ 294 + iwl_trans_write_prph(mvm->trans, TXF_CPU2_NUM, i); 295 + 289 296 fifo_hdr->available_bytes = 290 297 cpu_to_le32(iwl_trans_read_prph(mvm->trans, 291 298 TXF_CPU2_FIFO_ITEM_CNT)); ··· 340 339 #define IWL8260_ICCM_OFFSET 0x44000 /* Only for B-step */ 341 340 #define IWL8260_ICCM_LEN 0xC000 /* Only for B-step */ 342 341 343 - static const struct { 342 + struct iwl_prph_range { 344 343 u32 start, end; 345 - } iwl_prph_dump_addr[] = { 344 + }; 345 + 346 + static const struct iwl_prph_range iwl_prph_dump_addr_comm[] = { 346 347 { .start = 0x00a00000, .end = 0x00a00000 }, 347 348 { .start = 0x00a0000c, .end = 0x00a00024 }, 348 349 { .start = 0x00a0002c, .end = 0x00a0003c }, ··· 442 439 { .start = 0x00a44000, .end = 0x00a7bf80 }, 443 440 }; 444 441 442 + static const struct iwl_prph_range iwl_prph_dump_addr_9000[] = { 443 + { .start = 0x00a05c00, .end = 0x00a05c18 }, 444 + { .start = 0x00a05400, .end = 0x00a056e8 }, 445 + { .start = 0x00a08000, .end = 0x00a098bc }, 446 + { .start = 0x00adfc00, .end = 0x00adfd1c }, 447 + { .start = 0x00a02400, .end = 0x00a02758 }, 448 + }; 449 + 445 450 static u32 iwl_dump_prph(struct iwl_trans *trans, 446 - struct iwl_fw_error_dump_data **data) 451 + struct iwl_fw_error_dump_data **data, 452 + const struct iwl_prph_range *iwl_prph_dump_addr, 453 + u32 range_len) 447 454 { 448 455 struct iwl_fw_error_dump_prph *prph; 449 456 unsigned long flags; ··· 462 449 if (!iwl_trans_grab_nic_access(trans, &flags)) 463 450 return 0; 464 451 465 - for (i = 0; i < ARRAY_SIZE(iwl_prph_dump_addr); i++) { 452 + for (i = 0; i < range_len; i++) { 466 453 /* The range includes both boundaries */ 467 454 int num_bytes_in_chunk = iwl_prph_dump_addr[i].end - 468 455 iwl_prph_dump_addr[i].start + 4; ··· 585 572 } 586 573 587 574 /* Make room for PRPH registers */ 588 - for (i = 0; i < ARRAY_SIZE(iwl_prph_dump_addr); i++) { 575 + for (i = 0; i < ARRAY_SIZE(iwl_prph_dump_addr_comm); i++) { 589 576 /* The range includes both boundaries */ 590 - int num_bytes_in_chunk = iwl_prph_dump_addr[i].end - 591 - iwl_prph_dump_addr[i].start + 4; 577 + int num_bytes_in_chunk = 578 + iwl_prph_dump_addr_comm[i].end - 579 + iwl_prph_dump_addr_comm[i].start + 4; 592 580 593 581 prph_len += sizeof(*dump_data) + 594 582 sizeof(struct iwl_fw_error_dump_prph) + 595 583 num_bytes_in_chunk; 584 + } 585 + 586 + if (mvm->cfg->mq_rx_supported) { 587 + for (i = 0; i < 588 + ARRAY_SIZE(iwl_prph_dump_addr_9000); i++) { 589 + /* The range includes both boundaries */ 590 + int num_bytes_in_chunk = 591 + iwl_prph_dump_addr_9000[i].end - 592 + iwl_prph_dump_addr_9000[i].start + 4; 593 + 594 + prph_len += sizeof(*dump_data) + 595 + sizeof(struct iwl_fw_error_dump_prph) + 596 + num_bytes_in_chunk; 597 + } 596 598 } 597 599 598 600 if (mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000) ··· 797 769 } 798 770 } 799 771 800 - if (prph_len) 801 - iwl_dump_prph(mvm->trans, &dump_data); 772 + if (prph_len) { 773 + iwl_dump_prph(mvm->trans, &dump_data, 774 + iwl_prph_dump_addr_comm, 775 + ARRAY_SIZE(iwl_prph_dump_addr_comm)); 776 + 777 + if (mvm->cfg->mq_rx_supported) 778 + iwl_dump_prph(mvm->trans, &dump_data, 779 + iwl_prph_dump_addr_9000, 780 + ARRAY_SIZE(iwl_prph_dump_addr_9000)); 781 + } 802 782 803 783 dump_trans_data: 804 784 fw_error_dump->trans_ptr = iwl_trans_dump_data(mvm->trans,
+1 -1
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
··· 535 535 return true; 536 536 } 537 537 538 - WARN_ON(iwl_phy_db_set_section(phy_db, pkt, GFP_ATOMIC)); 538 + WARN_ON(iwl_phy_db_set_section(phy_db, pkt)); 539 539 540 540 return false; 541 541 }
+16 -6
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
··· 501 501 502 502 switch (vif->type) { 503 503 case NL80211_IFTYPE_P2P_DEVICE: 504 - iwl_mvm_enable_ac_txq(mvm, IWL_MVM_OFFCHANNEL_QUEUE, 505 - IWL_MVM_OFFCHANNEL_QUEUE, 506 - IWL_MVM_TX_FIFO_VO, 0, wdg_timeout); 504 + if (!iwl_mvm_is_dqa_supported(mvm)) 505 + iwl_mvm_enable_ac_txq(mvm, IWL_MVM_OFFCHANNEL_QUEUE, 506 + IWL_MVM_OFFCHANNEL_QUEUE, 507 + IWL_MVM_TX_FIFO_VO, 0, 508 + wdg_timeout); 507 509 break; 508 510 case NL80211_IFTYPE_AP: 509 511 iwl_mvm_enable_ac_txq(mvm, vif->cab_queue, vif->cab_queue, ··· 535 533 536 534 switch (vif->type) { 537 535 case NL80211_IFTYPE_P2P_DEVICE: 538 - iwl_mvm_disable_txq(mvm, IWL_MVM_OFFCHANNEL_QUEUE, 539 - IWL_MVM_OFFCHANNEL_QUEUE, IWL_MAX_TID_COUNT, 540 - 0); 536 + if (!iwl_mvm_is_dqa_supported(mvm)) 537 + iwl_mvm_disable_txq(mvm, IWL_MVM_OFFCHANNEL_QUEUE, 538 + IWL_MVM_OFFCHANNEL_QUEUE, 539 + IWL_MAX_TID_COUNT, 0); 540 + 541 541 break; 542 542 case NL80211_IFTYPE_AP: 543 543 iwl_mvm_disable_txq(mvm, vif->cab_queue, vif->cab_queue, 544 544 IWL_MAX_TID_COUNT, 0); 545 + 546 + if (iwl_mvm_is_dqa_supported(mvm)) 547 + iwl_mvm_disable_txq(mvm, 548 + IWL_MVM_DQA_AP_PROBE_RESP_QUEUE, 549 + vif->hw_queue[0], IWL_MAX_TID_COUNT, 550 + 0); 545 551 /* fall through */ 546 552 default: 547 553 /*
+70 -4
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
··· 229 229 230 230 IWL_DEBUG_RPM(mvm, "Leave mvm reference - type %d\n", ref_type); 231 231 spin_lock_bh(&mvm->refs_lock); 232 - WARN_ON(!mvm->refs[ref_type]--); 232 + if (WARN_ON(!mvm->refs[ref_type])) { 233 + spin_unlock_bh(&mvm->refs_lock); 234 + return; 235 + } 236 + mvm->refs[ref_type]--; 233 237 spin_unlock_bh(&mvm->refs_lock); 234 238 iwl_trans_unref(mvm->trans); 235 239 } ··· 443 439 ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS); 444 440 ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU); 445 441 ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR); 442 + if (iwl_mvm_has_new_rx_api(mvm)) 443 + ieee80211_hw_set(hw, SUPPORTS_REORDERING_BUFFER); 444 + 445 + if (mvm->trans->num_rx_queues > 1) 446 + ieee80211_hw_set(hw, USES_RSS); 446 447 447 448 if (mvm->trans->max_skb_frags) 448 449 hw->netdev_features = NETIF_F_HIGHDMA | NETIF_F_SG; 449 450 450 - hw->queues = mvm->first_agg_queue; 451 + if (!iwl_mvm_is_dqa_supported(mvm)) 452 + hw->queues = mvm->first_agg_queue; 453 + else 454 + hw->queues = IEEE80211_MAX_QUEUES; 451 455 hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; 452 456 hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC | 453 457 IEEE80211_RADIOTAP_MCS_HAVE_STBC; ··· 860 848 u16 *ssn = &params->ssn; 861 849 u8 buf_size = params->buf_size; 862 850 bool amsdu = params->amsdu; 851 + u16 timeout = params->timeout; 863 852 864 853 IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", 865 854 sta->addr, tid, action); ··· 901 888 ret = -EINVAL; 902 889 break; 903 890 } 904 - ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true, buf_size); 891 + ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true, buf_size, 892 + timeout); 905 893 break; 906 894 case IEEE80211_AMPDU_RX_STOP: 907 - ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false, buf_size); 895 + ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false, buf_size, 896 + timeout); 908 897 break; 909 898 case IEEE80211_AMPDU_TX_START: 910 899 if (!iwl_enable_tx_ampdu(mvm->cfg)) { ··· 4052 4037 } 4053 4038 } 4054 4039 4040 + void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, 4041 + struct iwl_mvm_internal_rxq_notif *notif, 4042 + u32 size) 4043 + { 4044 + DECLARE_WAIT_QUEUE_HEAD_ONSTACK(notif_waitq); 4045 + u32 qmask = BIT(mvm->trans->num_rx_queues) - 1; 4046 + int ret; 4047 + 4048 + lockdep_assert_held(&mvm->mutex); 4049 + 4050 + if (!iwl_mvm_has_new_rx_api(mvm)) 4051 + return; 4052 + 4053 + notif->cookie = mvm->queue_sync_cookie; 4054 + 4055 + if (notif->sync) 4056 + atomic_set(&mvm->queue_sync_counter, 4057 + mvm->trans->num_rx_queues); 4058 + 4059 + ret = iwl_mvm_notify_rx_queue(mvm, qmask, (u8 *)notif, size); 4060 + if (ret) { 4061 + IWL_ERR(mvm, "Failed to trigger RX queues sync (%d)\n", ret); 4062 + goto out; 4063 + } 4064 + 4065 + if (notif->sync) 4066 + ret = wait_event_timeout(notif_waitq, 4067 + atomic_read(&mvm->queue_sync_counter) == 0, 4068 + HZ); 4069 + WARN_ON_ONCE(!ret); 4070 + 4071 + out: 4072 + atomic_set(&mvm->queue_sync_counter, 0); 4073 + mvm->queue_sync_cookie++; 4074 + } 4075 + 4076 + static void iwl_mvm_sync_rx_queues(struct ieee80211_hw *hw) 4077 + { 4078 + struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 4079 + struct iwl_mvm_internal_rxq_notif data = { 4080 + .type = IWL_MVM_RXQ_EMPTY, 4081 + .sync = 1, 4082 + }; 4083 + 4084 + mutex_lock(&mvm->mutex); 4085 + iwl_mvm_sync_rx_queues_internal(mvm, &data, sizeof(data)); 4086 + mutex_unlock(&mvm->mutex); 4087 + } 4088 + 4055 4089 const struct ieee80211_ops iwl_mvm_hw_ops = { 4056 4090 .tx = iwl_mvm_mac_tx, 4057 4091 .ampdu_action = iwl_mvm_mac_ampdu_action, ··· 4156 4092 .tdls_recv_channel_switch = iwl_mvm_tdls_recv_channel_switch, 4157 4093 4158 4094 .event_callback = iwl_mvm_mac_event_callback, 4095 + 4096 + .sync_rx_queues = iwl_mvm_sync_rx_queues, 4159 4097 4160 4098 CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) 4161 4099
+98 -8
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
··· 301 301 IWL_MVM_REF_PROTECT_CSA, 302 302 IWL_MVM_REF_FW_DBG_COLLECT, 303 303 IWL_MVM_REF_INIT_UCODE, 304 + IWL_MVM_REF_SENDING_CMD, 305 + IWL_MVM_REF_RX, 304 306 305 307 /* update debugfs.c when changing this */ 306 308 ··· 615 613 u32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM]; 616 614 }; 617 615 616 + /** 617 + * struct iwl_mvm_reorder_buffer - per ra/tid/queue reorder buffer 618 + * @head_sn: reorder window head sn 619 + * @num_stored: number of mpdus stored in the buffer 620 + * @buf_size: the reorder buffer size as set by the last addba request 621 + * @sta_id: sta id of this reorder buffer 622 + * @queue: queue of this reorder buffer 623 + * @last_amsdu: track last ASMDU SN for duplication detection 624 + * @last_sub_index: track ASMDU sub frame index for duplication detection 625 + * @entries: list of skbs stored 626 + * @reorder_time: time the packet was stored in the reorder buffer 627 + * @reorder_timer: timer for frames are in the reorder buffer. For AMSDU 628 + * it is the time of last received sub-frame 629 + * @removed: prevent timer re-arming 630 + * @lock: protect reorder buffer internal state 631 + * @mvm: mvm pointer, needed for frame timer context 632 + */ 633 + struct iwl_mvm_reorder_buffer { 634 + u16 head_sn; 635 + u16 num_stored; 636 + u8 buf_size; 637 + u8 sta_id; 638 + int queue; 639 + u16 last_amsdu; 640 + u8 last_sub_index; 641 + struct sk_buff_head entries[IEEE80211_MAX_AMPDU_BUF]; 642 + unsigned long reorder_time[IEEE80211_MAX_AMPDU_BUF]; 643 + struct timer_list reorder_timer; 644 + bool removed; 645 + spinlock_t lock; 646 + struct iwl_mvm *mvm; 647 + } ____cacheline_aligned_in_smp; 648 + 649 + /** 650 + * struct iwl_mvm_baid_data - BA session data 651 + * @sta_id: station id 652 + * @tid: tid of the session 653 + * @baid baid of the session 654 + * @timeout: the timeout set in the addba request 655 + * @last_rx: last rx jiffies, updated only if timeout passed from last update 656 + * @session_timer: timer to check if BA session expired, runs at 2 * timeout 657 + * @mvm: mvm pointer, needed for timer context 658 + * @reorder_buf: reorder buffer, allocated per queue 659 + */ 660 + struct iwl_mvm_baid_data { 661 + struct rcu_head rcu_head; 662 + u8 sta_id; 663 + u8 tid; 664 + u8 baid; 665 + u16 timeout; 666 + unsigned long last_rx; 667 + struct timer_list session_timer; 668 + struct iwl_mvm *mvm; 669 + struct iwl_mvm_reorder_buffer reorder_buf[]; 670 + }; 671 + 672 + /* 673 + * enum iwl_mvm_queue_status - queue status 674 + * @IWL_MVM_QUEUE_FREE: the queue is not allocated nor reserved 675 + * Basically, this means that this queue can be used for any purpose 676 + * @IWL_MVM_QUEUE_RESERVED: queue is reserved but not yet in use 677 + * This is the state of a queue that has been dedicated for some RATID 678 + * (agg'd or not), but that hasn't yet gone through the actual enablement 679 + * of iwl_mvm_enable_txq(), and therefore no traffic can go through it yet. 680 + * Note that in this state there is no requirement to already know what TID 681 + * should be used with this queue, it is just marked as a queue that will 682 + * be used, and shouldn't be allocated to anyone else. 683 + * @IWL_MVM_QUEUE_READY: queue is ready to be used 684 + * This is the state of a queue that has been fully configured (including 685 + * SCD pointers, etc), has a specific RA/TID assigned to it, and can be 686 + * used to send traffic. 687 + */ 688 + enum iwl_mvm_queue_status { 689 + IWL_MVM_QUEUE_FREE, 690 + IWL_MVM_QUEUE_RESERVED, 691 + IWL_MVM_QUEUE_READY, 692 + }; 693 + 618 694 struct iwl_mvm { 619 695 /* for logger access */ 620 696 struct device *dev; ··· 713 633 714 634 unsigned long status; 715 635 636 + u32 queue_sync_cookie; 637 + atomic_t queue_sync_counter; 716 638 /* 717 639 * for beacon filtering - 718 640 * currently only one interface can be supported ··· 748 666 u32 hw_queue_to_mac80211; 749 667 u8 hw_queue_refcount; 750 668 u8 ra_sta_id; /* The RA this queue is mapped to, if exists */ 751 - /* 752 - * This is to mark that queue is reserved for a STA but not yet 753 - * allocated. This is needed to make sure we have at least one 754 - * available queue to use when adding a new STA 755 - */ 756 - bool setup_reserved; 757 669 u16 tid_bitmap; /* Bitmap of the TIDs mapped to this queue */ 670 + enum iwl_mvm_queue_status status; 758 671 } queue_info[IWL_MAX_HW_QUEUES]; 759 672 spinlock_t queue_info_lock; /* For syncing queue mgmt operations */ 760 673 struct work_struct add_stream_wk; /* To add streams to queues */ ··· 997 920 u32 ciphers[6]; 998 921 struct iwl_mvm_tof_data tof_data; 999 922 923 + struct ieee80211_vif *nan_vif; 924 + #define IWL_MAX_BAID 32 925 + struct iwl_mvm_baid_data __rcu *baid_map[IWL_MAX_BAID]; 926 + 1000 927 /* 1001 928 * Drop beacons from other APs in AP mode when there are no connected 1002 929 * clients. ··· 1146 1065 static inline bool iwl_mvm_is_csum_supported(struct iwl_mvm *mvm) 1147 1066 { 1148 1067 return fw_has_capa(&mvm->fw->ucode_capa, 1149 - IWL_UCODE_TLV_CAPA_CSUM_SUPPORT); 1068 + IWL_UCODE_TLV_CAPA_CSUM_SUPPORT) && 1069 + !IWL_MVM_HW_CSUM_DISABLE; 1150 1070 } 1151 1071 1152 1072 static inline bool iwl_mvm_is_mplut_supported(struct iwl_mvm *mvm) ··· 1324 1242 void iwl_mvm_rx_phy_cmd_mq(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1325 1243 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi, 1326 1244 struct iwl_rx_cmd_buffer *rxb, int queue); 1327 - void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, 1245 + void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, 1328 1246 struct iwl_rx_cmd_buffer *rxb, int queue); 1329 1247 int iwl_mvm_notify_rx_queue(struct iwl_mvm *mvm, u32 rxq_mask, 1330 1248 const u8 *data, u32 count); ··· 1648 1566 void iwl_mvm_start_mac_queues(struct iwl_mvm *mvm, unsigned long mq); 1649 1567 void iwl_mvm_stop_mac_queues(struct iwl_mvm *mvm, unsigned long mq); 1650 1568 1569 + /* Re-configure the SCD for a queue that has already been configured */ 1570 + int iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo, int sta_id, 1571 + int tid, int frame_limit, u16 ssn); 1572 + 1651 1573 /* Thermal management and CT-kill */ 1652 1574 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff); 1653 1575 void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp); ··· 1714 1628 void iwl_mvm_rx_tdls_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1715 1629 void iwl_mvm_tdls_ch_switch_work(struct work_struct *work); 1716 1630 1631 + void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, 1632 + struct iwl_mvm_internal_rxq_notif *notif, 1633 + u32 size); 1634 + void iwl_mvm_reorder_timer_expired(unsigned long data); 1717 1635 struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm); 1718 1636 1719 1637 void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
+13 -8
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
··· 554 554 mvm->restart_fw = iwlwifi_mod_params.restart_fw ? -1 : 0; 555 555 556 556 mvm->aux_queue = 15; 557 - mvm->first_agg_queue = 16; 558 - mvm->last_agg_queue = mvm->cfg->base_params->num_of_queues - 1; 557 + if (!iwl_mvm_is_dqa_supported(mvm)) { 558 + mvm->first_agg_queue = 16; 559 + mvm->last_agg_queue = mvm->cfg->base_params->num_of_queues - 1; 560 + } else { 561 + mvm->first_agg_queue = IWL_MVM_DQA_MIN_DATA_QUEUE; 562 + mvm->last_agg_queue = IWL_MVM_DQA_MAX_DATA_QUEUE; 563 + } 559 564 if (mvm->cfg->base_params->num_of_queues == 16) { 560 565 mvm->aux_queue = 11; 561 566 mvm->first_agg_queue = 12; ··· 590 585 spin_lock_init(&mvm->refs_lock); 591 586 skb_queue_head_init(&mvm->d0i3_tx); 592 587 init_waitqueue_head(&mvm->d0i3_exit_waitq); 588 + 589 + atomic_set(&mvm->queue_sync_counter, 0); 593 590 594 591 SET_IEEE80211_DEV(mvm->hw, mvm->trans->dev); 595 592 ··· 937 930 if (likely(pkt->hdr.cmd == REPLY_RX_MPDU_CMD)) 938 931 iwl_mvm_rx_rx_mpdu(mvm, napi, rxb); 939 932 else if (pkt->hdr.cmd == FRAME_RELEASE) 940 - iwl_mvm_rx_frame_release(mvm, rxb, 0); 933 + iwl_mvm_rx_frame_release(mvm, napi, rxb, 0); 941 934 else if (pkt->hdr.cmd == REPLY_RX_PHY_CMD) 942 935 iwl_mvm_rx_rx_phy_cmd(mvm, rxb); 943 936 else ··· 1215 1208 struct iwl_d0i3_iter_data *iter_data) 1216 1209 { 1217 1210 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1218 - struct ieee80211_sta *ap_sta; 1219 1211 struct iwl_mvm_sta *mvmsta; 1220 1212 u32 available_tids = 0; 1221 1213 u8 tid; ··· 1223 1217 mvmvif->ap_sta_id == IWL_MVM_STATION_COUNT)) 1224 1218 return false; 1225 1219 1226 - ap_sta = rcu_dereference(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id]); 1227 - if (IS_ERR_OR_NULL(ap_sta)) 1220 + mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, mvmvif->ap_sta_id); 1221 + if (!mvmsta) 1228 1222 return false; 1229 1223 1230 - mvmsta = iwl_mvm_sta_from_mac80211(ap_sta); 1231 1224 spin_lock_bh(&mvmsta->lock); 1232 1225 for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { 1233 1226 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; ··· 1637 1632 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1638 1633 1639 1634 if (unlikely(pkt->hdr.cmd == FRAME_RELEASE)) 1640 - iwl_mvm_rx_frame_release(mvm, rxb, queue); 1635 + iwl_mvm_rx_frame_release(mvm, napi, rxb, queue); 1641 1636 else if (unlikely(pkt->hdr.cmd == RX_QUEUES_NOTIFICATION && 1642 1637 pkt->hdr.group_id == DATA_PATH_GROUP)) 1643 1638 iwl_mvm_rx_queue_notif(mvm, rxb, queue);
+23 -3
drivers/net/wireless/intel/iwlwifi/mvm/rx.c
··· 97 97 * Adds the rxb to a new skb and give it to mac80211 98 98 */ 99 99 static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm, 100 + struct ieee80211_sta *sta, 100 101 struct napi_struct *napi, 101 102 struct sk_buff *skb, 102 103 struct ieee80211_hdr *hdr, u16 len, ··· 132 131 fraglen, rxb->truesize); 133 132 } 134 133 135 - ieee80211_rx_napi(mvm->hw, NULL, skb, napi); 134 + ieee80211_rx_napi(mvm->hw, sta, skb, napi); 136 135 } 137 136 138 137 /* ··· 272 271 u32 rate_n_flags; 273 272 u32 rx_pkt_status; 274 273 u8 crypt_len = 0; 274 + bool take_ref; 275 275 276 276 phy_info = &mvm->last_phy_info; 277 277 rx_res = (struct iwl_rx_mpdu_res_start *)pkt->data; ··· 455 453 mvm->sched_scan_pass_all == SCHED_SCAN_PASS_ALL_ENABLED)) 456 454 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_FOUND; 457 455 458 - iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, hdr, len, ampdu_status, 459 - crypt_len, rxb); 456 + if (unlikely(ieee80211_is_beacon(hdr->frame_control) || 457 + ieee80211_is_probe_resp(hdr->frame_control))) 458 + rx_status->boottime_ns = ktime_get_boot_ns(); 459 + 460 + /* Take a reference briefly to kick off a d0i3 entry delay so 461 + * we can handle bursts of RX packets without toggling the 462 + * state too often. But don't do this for beacons if we are 463 + * going to idle because the beacon filtering changes we make 464 + * cause the firmware to send us collateral beacons. */ 465 + take_ref = !(test_bit(STATUS_TRANS_GOING_IDLE, &mvm->trans->status) && 466 + ieee80211_is_beacon(hdr->frame_control)); 467 + 468 + if (take_ref) 469 + iwl_mvm_ref(mvm, IWL_MVM_REF_RX); 470 + 471 + iwl_mvm_pass_packet_to_mac80211(mvm, sta, napi, skb, hdr, len, 472 + ampdu_status, crypt_len, rxb); 473 + 474 + if (take_ref) 475 + iwl_mvm_unref(mvm, IWL_MVM_REF_RX); 460 476 } 461 477 462 478 static void iwl_mvm_update_rx_statistics(struct iwl_mvm *mvm,
+351 -5
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
··· 210 210 if (iwl_mvm_check_pn(mvm, skb, queue, sta)) 211 211 kfree_skb(skb); 212 212 else 213 - ieee80211_rx_napi(mvm->hw, NULL, skb, napi); 213 + ieee80211_rx_napi(mvm->hw, sta, skb, napi); 214 214 } 215 215 216 216 static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm, ··· 395 395 return ret; 396 396 } 397 397 398 + /* 399 + * Returns true if sn2 - buffer_size < sn1 < sn2. 400 + * To be used only in order to compare reorder buffer head with NSSN. 401 + * We fully trust NSSN unless it is behind us due to reorder timeout. 402 + * Reorder timeout can only bring us up to buffer_size SNs ahead of NSSN. 403 + */ 404 + static bool iwl_mvm_is_sn_less(u16 sn1, u16 sn2, u16 buffer_size) 405 + { 406 + return ieee80211_sn_less(sn1, sn2) && 407 + !ieee80211_sn_less(sn1, sn2 - buffer_size); 408 + } 409 + 410 + #define RX_REORDER_BUF_TIMEOUT_MQ (HZ / 10) 411 + 412 + static void iwl_mvm_release_frames(struct iwl_mvm *mvm, 413 + struct ieee80211_sta *sta, 414 + struct napi_struct *napi, 415 + struct iwl_mvm_reorder_buffer *reorder_buf, 416 + u16 nssn) 417 + { 418 + u16 ssn = reorder_buf->head_sn; 419 + 420 + lockdep_assert_held(&reorder_buf->lock); 421 + 422 + /* ignore nssn smaller than head sn - this can happen due to timeout */ 423 + if (iwl_mvm_is_sn_less(nssn, ssn, reorder_buf->buf_size)) 424 + return; 425 + 426 + while (iwl_mvm_is_sn_less(ssn, nssn, reorder_buf->buf_size)) { 427 + int index = ssn % reorder_buf->buf_size; 428 + struct sk_buff_head *skb_list = &reorder_buf->entries[index]; 429 + struct sk_buff *skb; 430 + 431 + ssn = ieee80211_sn_inc(ssn); 432 + 433 + /* holes are valid since nssn indicates frames were received. */ 434 + if (skb_queue_empty(skb_list) || !skb_peek_tail(skb_list)) 435 + continue; 436 + /* Empty the list. Will have more than one frame for A-MSDU */ 437 + while ((skb = __skb_dequeue(skb_list))) { 438 + iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, 439 + reorder_buf->queue, 440 + sta); 441 + reorder_buf->num_stored--; 442 + } 443 + } 444 + reorder_buf->head_sn = nssn; 445 + 446 + if (reorder_buf->num_stored && !reorder_buf->removed) { 447 + u16 index = reorder_buf->head_sn % reorder_buf->buf_size; 448 + 449 + while (!skb_peek_tail(&reorder_buf->entries[index])) 450 + index = (index + 1) % reorder_buf->buf_size; 451 + /* modify timer to match next frame's expiration time */ 452 + mod_timer(&reorder_buf->reorder_timer, 453 + reorder_buf->reorder_time[index] + 1 + 454 + RX_REORDER_BUF_TIMEOUT_MQ); 455 + } else { 456 + del_timer(&reorder_buf->reorder_timer); 457 + } 458 + } 459 + 460 + void iwl_mvm_reorder_timer_expired(unsigned long data) 461 + { 462 + struct iwl_mvm_reorder_buffer *buf = (void *)data; 463 + int i; 464 + u16 sn = 0, index = 0; 465 + bool expired = false; 466 + 467 + spin_lock_bh(&buf->lock); 468 + 469 + if (!buf->num_stored || buf->removed) { 470 + spin_unlock_bh(&buf->lock); 471 + return; 472 + } 473 + 474 + for (i = 0; i < buf->buf_size ; i++) { 475 + index = (buf->head_sn + i) % buf->buf_size; 476 + 477 + if (!skb_peek_tail(&buf->entries[index])) 478 + continue; 479 + if (!time_after(jiffies, buf->reorder_time[index] + 480 + RX_REORDER_BUF_TIMEOUT_MQ)) 481 + break; 482 + expired = true; 483 + sn = ieee80211_sn_add(buf->head_sn, i + 1); 484 + } 485 + 486 + if (expired) { 487 + struct ieee80211_sta *sta; 488 + 489 + rcu_read_lock(); 490 + sta = rcu_dereference(buf->mvm->fw_id_to_mac_id[buf->sta_id]); 491 + /* SN is set to the last expired frame + 1 */ 492 + iwl_mvm_release_frames(buf->mvm, sta, NULL, buf, sn); 493 + rcu_read_unlock(); 494 + } else if (buf->num_stored) { 495 + /* 496 + * If no frame expired and there are stored frames, index is now 497 + * pointing to the first unexpired frame - modify timer 498 + * accordingly to this frame. 499 + */ 500 + mod_timer(&buf->reorder_timer, 501 + buf->reorder_time[index] + 502 + 1 + RX_REORDER_BUF_TIMEOUT_MQ); 503 + } 504 + spin_unlock_bh(&buf->lock); 505 + } 506 + 507 + static void iwl_mvm_del_ba(struct iwl_mvm *mvm, int queue, 508 + struct iwl_mvm_delba_data *data) 509 + { 510 + struct iwl_mvm_baid_data *ba_data; 511 + struct ieee80211_sta *sta; 512 + struct iwl_mvm_reorder_buffer *reorder_buf; 513 + u8 baid = data->baid; 514 + 515 + if (WARN_ON_ONCE(baid >= IWL_RX_REORDER_DATA_INVALID_BAID)) 516 + return; 517 + 518 + rcu_read_lock(); 519 + 520 + ba_data = rcu_dereference(mvm->baid_map[baid]); 521 + if (WARN_ON_ONCE(!ba_data)) 522 + goto out; 523 + 524 + sta = rcu_dereference(mvm->fw_id_to_mac_id[ba_data->sta_id]); 525 + if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) 526 + goto out; 527 + 528 + reorder_buf = &ba_data->reorder_buf[queue]; 529 + 530 + /* release all frames that are in the reorder buffer to the stack */ 531 + spin_lock_bh(&reorder_buf->lock); 532 + iwl_mvm_release_frames(mvm, sta, NULL, reorder_buf, 533 + ieee80211_sn_add(reorder_buf->head_sn, 534 + reorder_buf->buf_size)); 535 + spin_unlock_bh(&reorder_buf->lock); 536 + del_timer_sync(&reorder_buf->reorder_timer); 537 + 538 + out: 539 + rcu_read_unlock(); 540 + } 541 + 398 542 void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, 399 543 int queue) 400 544 { ··· 549 405 notif = (void *)pkt->data; 550 406 internal_notif = (void *)notif->payload; 551 407 408 + if (internal_notif->sync) { 409 + if (mvm->queue_sync_cookie != internal_notif->cookie) { 410 + WARN_ONCE(1, 411 + "Received expired RX queue sync message\n"); 412 + return; 413 + } 414 + atomic_dec(&mvm->queue_sync_counter); 415 + } 416 + 552 417 switch (internal_notif->type) { 418 + case IWL_MVM_RXQ_EMPTY: 419 + break; 553 420 case IWL_MVM_RXQ_NOTIF_DEL_BA: 554 - /* TODO */ 421 + iwl_mvm_del_ba(mvm, queue, (void *)internal_notif->data); 555 422 break; 556 423 default: 557 424 WARN_ONCE(1, "Invalid identifier %d", internal_notif->type); 558 425 } 426 + } 427 + 428 + /* 429 + * Returns true if the MPDU was buffered\dropped, false if it should be passed 430 + * to upper layer. 431 + */ 432 + static bool iwl_mvm_reorder(struct iwl_mvm *mvm, 433 + struct napi_struct *napi, 434 + int queue, 435 + struct ieee80211_sta *sta, 436 + struct sk_buff *skb, 437 + struct iwl_rx_mpdu_desc *desc) 438 + { 439 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 440 + struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); 441 + struct iwl_mvm_baid_data *baid_data; 442 + struct iwl_mvm_reorder_buffer *buffer; 443 + struct sk_buff *tail; 444 + u32 reorder = le32_to_cpu(desc->reorder_data); 445 + bool amsdu = desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU; 446 + u8 tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; 447 + u8 sub_frame_idx = desc->amsdu_info & 448 + IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK; 449 + int index; 450 + u16 nssn, sn; 451 + u8 baid; 452 + 453 + baid = (reorder & IWL_RX_MPDU_REORDER_BAID_MASK) >> 454 + IWL_RX_MPDU_REORDER_BAID_SHIFT; 455 + 456 + if (baid == IWL_RX_REORDER_DATA_INVALID_BAID) 457 + return false; 458 + 459 + /* no sta yet */ 460 + if (WARN_ON(IS_ERR_OR_NULL(sta))) 461 + return false; 462 + 463 + /* not a data packet */ 464 + if (!ieee80211_is_data_qos(hdr->frame_control) || 465 + is_multicast_ether_addr(hdr->addr1)) 466 + return false; 467 + 468 + if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) 469 + return false; 470 + 471 + baid_data = rcu_dereference(mvm->baid_map[baid]); 472 + if (WARN(!baid_data, 473 + "Received baid %d, but no data exists for this BAID\n", baid)) 474 + return false; 475 + if (WARN(tid != baid_data->tid || mvm_sta->sta_id != baid_data->sta_id, 476 + "baid 0x%x is mapped to sta:%d tid:%d, but was received for sta:%d tid:%d\n", 477 + baid, baid_data->sta_id, baid_data->tid, mvm_sta->sta_id, 478 + tid)) 479 + return false; 480 + 481 + nssn = reorder & IWL_RX_MPDU_REORDER_NSSN_MASK; 482 + sn = (reorder & IWL_RX_MPDU_REORDER_SN_MASK) >> 483 + IWL_RX_MPDU_REORDER_SN_SHIFT; 484 + 485 + buffer = &baid_data->reorder_buf[queue]; 486 + 487 + spin_lock_bh(&buffer->lock); 488 + 489 + /* 490 + * If there was a significant jump in the nssn - adjust. 491 + * If the SN is smaller than the NSSN it might need to first go into 492 + * the reorder buffer, in which case we just release up to it and the 493 + * rest of the function will take of storing it and releasing up to the 494 + * nssn 495 + */ 496 + if (!iwl_mvm_is_sn_less(nssn, buffer->head_sn + buffer->buf_size, 497 + buffer->buf_size)) { 498 + u16 min_sn = ieee80211_sn_less(sn, nssn) ? sn : nssn; 499 + 500 + iwl_mvm_release_frames(mvm, sta, napi, buffer, min_sn); 501 + } 502 + 503 + /* drop any oudated packets */ 504 + if (ieee80211_sn_less(sn, buffer->head_sn)) 505 + goto drop; 506 + 507 + /* release immediately if allowed by nssn and no stored frames */ 508 + if (!buffer->num_stored && ieee80211_sn_less(sn, nssn)) { 509 + if (iwl_mvm_is_sn_less(buffer->head_sn, nssn, 510 + buffer->buf_size)) 511 + buffer->head_sn = nssn; 512 + /* No need to update AMSDU last SN - we are moving the head */ 513 + spin_unlock_bh(&buffer->lock); 514 + return false; 515 + } 516 + 517 + index = sn % buffer->buf_size; 518 + 519 + /* 520 + * Check if we already stored this frame 521 + * As AMSDU is either received or not as whole, logic is simple: 522 + * If we have frames in that position in the buffer and the last frame 523 + * originated from AMSDU had a different SN then it is a retransmission. 524 + * If it is the same SN then if the subframe index is incrementing it 525 + * is the same AMSDU - otherwise it is a retransmission. 526 + */ 527 + tail = skb_peek_tail(&buffer->entries[index]); 528 + if (tail && !amsdu) 529 + goto drop; 530 + else if (tail && (sn != buffer->last_amsdu || 531 + buffer->last_sub_index >= sub_frame_idx)) 532 + goto drop; 533 + 534 + /* put in reorder buffer */ 535 + __skb_queue_tail(&buffer->entries[index], skb); 536 + buffer->num_stored++; 537 + buffer->reorder_time[index] = jiffies; 538 + 539 + if (amsdu) { 540 + buffer->last_amsdu = sn; 541 + buffer->last_sub_index = sub_frame_idx; 542 + } 543 + 544 + iwl_mvm_release_frames(mvm, sta, napi, buffer, nssn); 545 + spin_unlock_bh(&buffer->lock); 546 + return true; 547 + 548 + drop: 549 + kfree_skb(skb); 550 + spin_unlock_bh(&buffer->lock); 551 + return true; 552 + } 553 + 554 + static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm, u8 baid) 555 + { 556 + unsigned long now = jiffies; 557 + unsigned long timeout; 558 + struct iwl_mvm_baid_data *data; 559 + 560 + rcu_read_lock(); 561 + 562 + data = rcu_dereference(mvm->baid_map[baid]); 563 + if (WARN_ON(!data)) 564 + goto out; 565 + 566 + if (!data->timeout) 567 + goto out; 568 + 569 + timeout = data->timeout; 570 + /* 571 + * Do not update last rx all the time to avoid cache bouncing 572 + * between the rx queues. 573 + * Update it every timeout. Worst case is the session will 574 + * expire after ~ 2 * timeout, which doesn't matter that much. 575 + */ 576 + if (time_before(data->last_rx + TU_TO_JIFFIES(timeout), now)) 577 + /* Update is atomic */ 578 + data->last_rx = now; 579 + 580 + out: 581 + rcu_read_unlock(); 559 582 } 560 583 561 584 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi, ··· 795 484 796 485 if (sta) { 797 486 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 487 + u8 baid = (u8)((le32_to_cpu(desc->reorder_data) & 488 + IWL_RX_MPDU_REORDER_BAID_MASK) >> 489 + IWL_RX_MPDU_REORDER_BAID_SHIFT); 798 490 799 491 /* 800 492 * We have tx blocked stations (with CS bit). If we heard ··· 850 536 851 537 *qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT; 852 538 } 539 + if (baid != IWL_RX_REORDER_DATA_INVALID_BAID) 540 + iwl_mvm_agg_rx_received(mvm, baid); 853 541 } 854 542 855 543 /* ··· 909 593 /* TODO: PHY info - gscan */ 910 594 911 595 iwl_mvm_create_skb(skb, hdr, len, crypt_len, rxb); 912 - iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta); 596 + if (!iwl_mvm_reorder(mvm, napi, queue, sta, skb, desc)) 597 + iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta); 913 598 rcu_read_unlock(); 914 599 } 915 600 916 - void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, 601 + void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, 917 602 struct iwl_rx_cmd_buffer *rxb, int queue) 918 603 { 919 - /* TODO */ 604 + struct iwl_rx_packet *pkt = rxb_addr(rxb); 605 + struct iwl_frame_release *release = (void *)pkt->data; 606 + struct ieee80211_sta *sta; 607 + struct iwl_mvm_reorder_buffer *reorder_buf; 608 + struct iwl_mvm_baid_data *ba_data; 609 + 610 + int baid = release->baid; 611 + 612 + if (WARN_ON_ONCE(baid == IWL_RX_REORDER_DATA_INVALID_BAID)) 613 + return; 614 + 615 + rcu_read_lock(); 616 + 617 + ba_data = rcu_dereference(mvm->baid_map[baid]); 618 + if (WARN_ON_ONCE(!ba_data)) 619 + goto out; 620 + 621 + sta = rcu_dereference(mvm->fw_id_to_mac_id[ba_data->sta_id]); 622 + if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) 623 + goto out; 624 + 625 + reorder_buf = &ba_data->reorder_buf[queue]; 626 + 627 + spin_lock_bh(&reorder_buf->lock); 628 + iwl_mvm_release_frames(mvm, sta, napi, reorder_buf, 629 + le16_to_cpu(release->nssn)); 630 + spin_unlock_bh(&reorder_buf->lock); 631 + 632 + out: 633 + rcu_read_unlock(); 920 634 }
+363 -49
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
··· 223 223 return ret; 224 224 } 225 225 226 + static void iwl_mvm_rx_agg_session_expired(unsigned long data) 227 + { 228 + struct iwl_mvm_baid_data __rcu **rcu_ptr = (void *)data; 229 + struct iwl_mvm_baid_data *ba_data; 230 + struct ieee80211_sta *sta; 231 + struct iwl_mvm_sta *mvm_sta; 232 + unsigned long timeout; 233 + 234 + rcu_read_lock(); 235 + 236 + ba_data = rcu_dereference(*rcu_ptr); 237 + 238 + if (WARN_ON(!ba_data)) 239 + goto unlock; 240 + 241 + if (!ba_data->timeout) 242 + goto unlock; 243 + 244 + timeout = ba_data->last_rx + TU_TO_JIFFIES(ba_data->timeout * 2); 245 + if (time_is_after_jiffies(timeout)) { 246 + mod_timer(&ba_data->session_timer, timeout); 247 + goto unlock; 248 + } 249 + 250 + /* Timer expired */ 251 + sta = rcu_dereference(ba_data->mvm->fw_id_to_mac_id[ba_data->sta_id]); 252 + mvm_sta = iwl_mvm_sta_from_mac80211(sta); 253 + ieee80211_stop_rx_ba_session_offl(mvm_sta->vif, 254 + sta->addr, ba_data->tid); 255 + unlock: 256 + rcu_read_unlock(); 257 + } 258 + 226 259 static int iwl_mvm_tdls_sta_init(struct iwl_mvm *mvm, 227 260 struct ieee80211_sta *sta) 228 261 { ··· 326 293 u8 mac_queue = mvmsta->vif->hw_queue[ac]; 327 294 int queue = -1; 328 295 int ssn; 296 + int ret; 329 297 330 298 lockdep_assert_held(&mvm->mutex); 331 299 ··· 355 321 if (queue < 0) 356 322 queue = iwl_mvm_find_free_queue(mvm, IWL_MVM_DQA_MIN_DATA_QUEUE, 357 323 IWL_MVM_DQA_MAX_DATA_QUEUE); 324 + 325 + /* 326 + * Mark TXQ as ready, even though it hasn't been fully configured yet, 327 + * to make sure no one else takes it. 328 + * This will allow avoiding re-acquiring the lock at the end of the 329 + * configuration. On error we'll mark it back as free. 330 + */ 358 331 if (queue >= 0) 359 - mvm->queue_info[queue].setup_reserved = false; 332 + mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY; 360 333 361 334 spin_unlock_bh(&mvm->queue_info_lock); 362 335 ··· 395 354 mvmsta->reserved_queue = IEEE80211_INVAL_HW_QUEUE; 396 355 spin_unlock_bh(&mvmsta->lock); 397 356 398 - return iwl_mvm_sta_send_to_fw(mvm, sta, true, STA_MODIFY_QUEUES); 357 + ret = iwl_mvm_sta_send_to_fw(mvm, sta, true, STA_MODIFY_QUEUES); 358 + if (ret) 359 + goto out_err; 360 + 361 + return 0; 362 + 363 + out_err: 364 + iwl_mvm_disable_txq(mvm, queue, mac_queue, tid, 0); 365 + 366 + return ret; 399 367 } 400 368 401 369 static inline u8 iwl_mvm_tid_to_ac_queue(int tid) ··· 510 460 /* Make sure we have free resources for this STA */ 511 461 if (vif_type == NL80211_IFTYPE_STATION && !sta->tdls && 512 462 !mvm->queue_info[IWL_MVM_DQA_BSS_CLIENT_QUEUE].hw_queue_refcount && 513 - !mvm->queue_info[IWL_MVM_DQA_BSS_CLIENT_QUEUE].setup_reserved) 463 + (mvm->queue_info[IWL_MVM_DQA_BSS_CLIENT_QUEUE].status == 464 + IWL_MVM_QUEUE_FREE)) 514 465 queue = IWL_MVM_DQA_BSS_CLIENT_QUEUE; 515 466 else 516 467 queue = iwl_mvm_find_free_queue(mvm, IWL_MVM_DQA_MIN_DATA_QUEUE, ··· 521 470 IWL_ERR(mvm, "No available queues for new station\n"); 522 471 return -ENOSPC; 523 472 } 524 - mvm->queue_info[queue].setup_reserved = true; 473 + mvm->queue_info[queue].status = IWL_MVM_QUEUE_RESERVED; 525 474 526 475 spin_unlock_bh(&mvm->queue_info_lock); 527 476 ··· 1051 1000 1052 1001 lockdep_assert_held(&mvm->mutex); 1053 1002 1003 + if (iwl_mvm_is_dqa_supported(mvm)) { 1004 + struct iwl_trans_txq_scd_cfg cfg = { 1005 + .fifo = IWL_MVM_TX_FIFO_VO, 1006 + .sta_id = mvmvif->bcast_sta.sta_id, 1007 + .tid = IWL_MAX_TID_COUNT, 1008 + .aggregate = false, 1009 + .frame_limit = IWL_FRAME_LIMIT, 1010 + }; 1011 + unsigned int wdg_timeout = 1012 + iwl_mvm_get_wd_timeout(mvm, vif, false, false); 1013 + int queue; 1014 + 1015 + if ((vif->type == NL80211_IFTYPE_AP) && 1016 + (mvmvif->bcast_sta.tfd_queue_msk & 1017 + BIT(IWL_MVM_DQA_AP_PROBE_RESP_QUEUE))) 1018 + queue = IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; 1019 + else if ((vif->type == NL80211_IFTYPE_P2P_DEVICE) && 1020 + (mvmvif->bcast_sta.tfd_queue_msk & 1021 + BIT(IWL_MVM_DQA_P2P_DEVICE_QUEUE))) 1022 + queue = IWL_MVM_DQA_P2P_DEVICE_QUEUE; 1023 + else if (WARN(1, "Missed required TXQ for adding bcast STA\n")) 1024 + return -EINVAL; 1025 + 1026 + iwl_mvm_enable_txq(mvm, queue, vif->hw_queue[0], 0, &cfg, 1027 + wdg_timeout); 1028 + } 1029 + 1054 1030 if (vif->type == NL80211_IFTYPE_ADHOC) 1055 1031 baddr = vif->bss_conf.bssid; 1056 1032 ··· 1106 1028 int iwl_mvm_alloc_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 1107 1029 { 1108 1030 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1109 - u32 qmask; 1031 + u32 qmask = 0; 1110 1032 1111 1033 lockdep_assert_held(&mvm->mutex); 1112 1034 1113 - qmask = iwl_mvm_mac_get_queues_mask(vif); 1035 + if (!iwl_mvm_is_dqa_supported(mvm)) 1036 + qmask = iwl_mvm_mac_get_queues_mask(vif); 1114 1037 1115 - /* 1116 - * The firmware defines the TFD queue mask to only be relevant 1117 - * for *unicast* queues, so the multicast (CAB) queue shouldn't 1118 - * be included. 1119 - */ 1120 - if (vif->type == NL80211_IFTYPE_AP) 1038 + if (vif->type == NL80211_IFTYPE_AP) { 1039 + /* 1040 + * The firmware defines the TFD queue mask to only be relevant 1041 + * for *unicast* queues, so the multicast (CAB) queue shouldn't 1042 + * be included. 1043 + */ 1121 1044 qmask &= ~BIT(vif->cab_queue); 1045 + 1046 + if (iwl_mvm_is_dqa_supported(mvm)) 1047 + qmask |= BIT(IWL_MVM_DQA_AP_PROBE_RESP_QUEUE); 1048 + } else if (iwl_mvm_is_dqa_supported(mvm) && 1049 + vif->type == NL80211_IFTYPE_P2P_DEVICE) { 1050 + qmask |= BIT(IWL_MVM_DQA_P2P_DEVICE_QUEUE); 1051 + } 1122 1052 1123 1053 return iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta, qmask, 1124 1054 ieee80211_vif_type_p2p(vif)); ··· 1185 1099 1186 1100 #define IWL_MAX_RX_BA_SESSIONS 16 1187 1101 1102 + static void iwl_mvm_sync_rxq_del_ba(struct iwl_mvm *mvm, u8 baid) 1103 + { 1104 + struct iwl_mvm_delba_notif notif = { 1105 + .metadata.type = IWL_MVM_RXQ_NOTIF_DEL_BA, 1106 + .metadata.sync = 1, 1107 + .delba.baid = baid, 1108 + }; 1109 + iwl_mvm_sync_rx_queues_internal(mvm, (void *)&notif, sizeof(notif)); 1110 + }; 1111 + 1112 + static void iwl_mvm_free_reorder(struct iwl_mvm *mvm, 1113 + struct iwl_mvm_baid_data *data) 1114 + { 1115 + int i; 1116 + 1117 + iwl_mvm_sync_rxq_del_ba(mvm, data->baid); 1118 + 1119 + for (i = 0; i < mvm->trans->num_rx_queues; i++) { 1120 + int j; 1121 + struct iwl_mvm_reorder_buffer *reorder_buf = 1122 + &data->reorder_buf[i]; 1123 + 1124 + spin_lock_bh(&reorder_buf->lock); 1125 + if (likely(!reorder_buf->num_stored)) { 1126 + spin_unlock_bh(&reorder_buf->lock); 1127 + continue; 1128 + } 1129 + 1130 + /* 1131 + * This shouldn't happen in regular DELBA since the internal 1132 + * delBA notification should trigger a release of all frames in 1133 + * the reorder buffer. 1134 + */ 1135 + WARN_ON(1); 1136 + 1137 + for (j = 0; j < reorder_buf->buf_size; j++) 1138 + __skb_queue_purge(&reorder_buf->entries[j]); 1139 + /* 1140 + * Prevent timer re-arm. This prevents a very far fetched case 1141 + * where we timed out on the notification. There may be prior 1142 + * RX frames pending in the RX queue before the notification 1143 + * that might get processed between now and the actual deletion 1144 + * and we would re-arm the timer although we are deleting the 1145 + * reorder buffer. 1146 + */ 1147 + reorder_buf->removed = true; 1148 + spin_unlock_bh(&reorder_buf->lock); 1149 + del_timer_sync(&reorder_buf->reorder_timer); 1150 + } 1151 + } 1152 + 1153 + static void iwl_mvm_init_reorder_buffer(struct iwl_mvm *mvm, 1154 + u32 sta_id, 1155 + struct iwl_mvm_baid_data *data, 1156 + u16 ssn, u8 buf_size) 1157 + { 1158 + int i; 1159 + 1160 + for (i = 0; i < mvm->trans->num_rx_queues; i++) { 1161 + struct iwl_mvm_reorder_buffer *reorder_buf = 1162 + &data->reorder_buf[i]; 1163 + int j; 1164 + 1165 + reorder_buf->num_stored = 0; 1166 + reorder_buf->head_sn = ssn; 1167 + reorder_buf->buf_size = buf_size; 1168 + /* rx reorder timer */ 1169 + reorder_buf->reorder_timer.function = 1170 + iwl_mvm_reorder_timer_expired; 1171 + reorder_buf->reorder_timer.data = (unsigned long)reorder_buf; 1172 + init_timer(&reorder_buf->reorder_timer); 1173 + spin_lock_init(&reorder_buf->lock); 1174 + reorder_buf->mvm = mvm; 1175 + reorder_buf->queue = i; 1176 + reorder_buf->sta_id = sta_id; 1177 + for (j = 0; j < reorder_buf->buf_size; j++) 1178 + __skb_queue_head_init(&reorder_buf->entries[j]); 1179 + } 1180 + } 1181 + 1188 1182 int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta, 1189 - int tid, u16 ssn, bool start, u8 buf_size) 1183 + int tid, u16 ssn, bool start, u8 buf_size, u16 timeout) 1190 1184 { 1191 1185 struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); 1192 1186 struct iwl_mvm_add_sta_cmd cmd = {}; 1187 + struct iwl_mvm_baid_data *baid_data = NULL; 1193 1188 int ret; 1194 1189 u32 status; 1195 1190 ··· 1279 1112 if (start && mvm->rx_ba_sessions >= IWL_MAX_RX_BA_SESSIONS) { 1280 1113 IWL_WARN(mvm, "Not enough RX BA SESSIONS\n"); 1281 1114 return -ENOSPC; 1115 + } 1116 + 1117 + if (iwl_mvm_has_new_rx_api(mvm) && start) { 1118 + /* 1119 + * Allocate here so if allocation fails we can bail out early 1120 + * before starting the BA session in the firmware 1121 + */ 1122 + baid_data = kzalloc(sizeof(*baid_data) + 1123 + mvm->trans->num_rx_queues * 1124 + sizeof(baid_data->reorder_buf[0]), 1125 + GFP_KERNEL); 1126 + if (!baid_data) 1127 + return -ENOMEM; 1282 1128 } 1283 1129 1284 1130 cmd.mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color); ··· 1312 1132 iwl_mvm_add_sta_cmd_size(mvm), 1313 1133 &cmd, &status); 1314 1134 if (ret) 1315 - return ret; 1135 + goto out_free; 1316 1136 1317 1137 switch (status & IWL_ADD_STA_STATUS_MASK) { 1318 1138 case ADD_STA_SUCCESS: ··· 1330 1150 break; 1331 1151 } 1332 1152 1333 - if (!ret) { 1334 - if (start) 1335 - mvm->rx_ba_sessions++; 1336 - else if (mvm->rx_ba_sessions > 0) 1337 - /* check that restart flow didn't zero the counter */ 1338 - mvm->rx_ba_sessions--; 1339 - } 1153 + if (ret) 1154 + goto out_free; 1340 1155 1156 + if (start) { 1157 + u8 baid; 1158 + 1159 + mvm->rx_ba_sessions++; 1160 + 1161 + if (!iwl_mvm_has_new_rx_api(mvm)) 1162 + return 0; 1163 + 1164 + if (WARN_ON(!(status & IWL_ADD_STA_BAID_VALID_MASK))) { 1165 + ret = -EINVAL; 1166 + goto out_free; 1167 + } 1168 + baid = (u8)((status & IWL_ADD_STA_BAID_MASK) >> 1169 + IWL_ADD_STA_BAID_SHIFT); 1170 + baid_data->baid = baid; 1171 + baid_data->timeout = timeout; 1172 + baid_data->last_rx = jiffies; 1173 + init_timer(&baid_data->session_timer); 1174 + baid_data->session_timer.function = 1175 + iwl_mvm_rx_agg_session_expired; 1176 + baid_data->session_timer.data = 1177 + (unsigned long)&mvm->baid_map[baid]; 1178 + baid_data->mvm = mvm; 1179 + baid_data->tid = tid; 1180 + baid_data->sta_id = mvm_sta->sta_id; 1181 + 1182 + mvm_sta->tid_to_baid[tid] = baid; 1183 + if (timeout) 1184 + mod_timer(&baid_data->session_timer, 1185 + TU_TO_EXP_TIME(timeout * 2)); 1186 + 1187 + iwl_mvm_init_reorder_buffer(mvm, mvm_sta->sta_id, 1188 + baid_data, ssn, buf_size); 1189 + /* 1190 + * protect the BA data with RCU to cover a case where our 1191 + * internal RX sync mechanism will timeout (not that it's 1192 + * supposed to happen) and we will free the session data while 1193 + * RX is being processed in parallel 1194 + */ 1195 + WARN_ON(rcu_access_pointer(mvm->baid_map[baid])); 1196 + rcu_assign_pointer(mvm->baid_map[baid], baid_data); 1197 + } else if (mvm->rx_ba_sessions > 0) { 1198 + u8 baid = mvm_sta->tid_to_baid[tid]; 1199 + 1200 + /* check that restart flow didn't zero the counter */ 1201 + mvm->rx_ba_sessions--; 1202 + if (!iwl_mvm_has_new_rx_api(mvm)) 1203 + return 0; 1204 + 1205 + if (WARN_ON(baid == IWL_RX_REORDER_DATA_INVALID_BAID)) 1206 + return -EINVAL; 1207 + 1208 + baid_data = rcu_access_pointer(mvm->baid_map[baid]); 1209 + if (WARN_ON(!baid_data)) 1210 + return -EINVAL; 1211 + 1212 + /* synchronize all rx queues so we can safely delete */ 1213 + iwl_mvm_free_reorder(mvm, baid_data); 1214 + del_timer_sync(&baid_data->session_timer); 1215 + RCU_INIT_POINTER(mvm->baid_map[baid], NULL); 1216 + kfree_rcu(baid_data, rcu_head); 1217 + } 1218 + return 0; 1219 + 1220 + out_free: 1221 + kfree(baid_data); 1341 1222 return ret; 1342 1223 } 1343 1224 ··· 1416 1175 mvm_sta->tfd_queue_msk |= BIT(queue); 1417 1176 mvm_sta->tid_disable_agg &= ~BIT(tid); 1418 1177 } else { 1419 - mvm_sta->tfd_queue_msk &= ~BIT(queue); 1178 + /* In DQA-mode the queue isn't removed on agg termination */ 1179 + if (!iwl_mvm_is_dqa_supported(mvm)) 1180 + mvm_sta->tfd_queue_msk &= ~BIT(queue); 1420 1181 mvm_sta->tid_disable_agg |= BIT(tid); 1421 1182 } 1422 1183 ··· 1501 1258 1502 1259 spin_lock_bh(&mvm->queue_info_lock); 1503 1260 1504 - txq_id = iwl_mvm_find_free_queue(mvm, mvm->first_agg_queue, 1505 - mvm->last_agg_queue); 1506 - if (txq_id < 0) { 1507 - ret = txq_id; 1508 - spin_unlock_bh(&mvm->queue_info_lock); 1509 - IWL_ERR(mvm, "Failed to allocate agg queue\n"); 1510 - goto release_locks; 1261 + /* 1262 + * Note the possible cases: 1263 + * 1. In DQA mode with an enabled TXQ - TXQ needs to become agg'ed 1264 + * 2. Non-DQA mode: the TXQ hasn't yet been enabled, so find a free 1265 + * one and mark it as reserved 1266 + * 3. In DQA mode, but no traffic yet on this TID: same treatment as in 1267 + * non-DQA mode, since the TXQ hasn't yet been allocated 1268 + */ 1269 + txq_id = mvmsta->tid_data[tid].txq_id; 1270 + if (!iwl_mvm_is_dqa_supported(mvm) || 1271 + mvm->queue_info[txq_id].status != IWL_MVM_QUEUE_READY) { 1272 + txq_id = iwl_mvm_find_free_queue(mvm, mvm->first_agg_queue, 1273 + mvm->last_agg_queue); 1274 + if (txq_id < 0) { 1275 + ret = txq_id; 1276 + spin_unlock_bh(&mvm->queue_info_lock); 1277 + IWL_ERR(mvm, "Failed to allocate agg queue\n"); 1278 + goto release_locks; 1279 + } 1280 + 1281 + /* TXQ hasn't yet been enabled, so mark it only as reserved */ 1282 + mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_RESERVED; 1511 1283 } 1512 - mvm->queue_info[txq_id].setup_reserved = true; 1513 1284 spin_unlock_bh(&mvm->queue_info_lock); 1285 + 1286 + IWL_DEBUG_TX_QUEUES(mvm, 1287 + "AGG for tid %d will be on queue #%d\n", 1288 + tid, txq_id); 1514 1289 1515 1290 tid_data = &mvmsta->tid_data[tid]; 1516 1291 tid_data->ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); ··· 1564 1303 unsigned int wdg_timeout = 1565 1304 iwl_mvm_get_wd_timeout(mvm, vif, sta->tdls, false); 1566 1305 int queue, ret; 1306 + bool alloc_queue = true; 1567 1307 u16 ssn; 1568 1308 1569 1309 struct iwl_trans_txq_scd_cfg cfg = { ··· 1590 1328 1591 1329 cfg.fifo = iwl_mvm_ac_to_tx_fifo[tid_to_mac80211_ac[tid]]; 1592 1330 1593 - iwl_mvm_enable_txq(mvm, queue, vif->hw_queue[tid_to_mac80211_ac[tid]], 1594 - ssn, &cfg, wdg_timeout); 1331 + /* In DQA mode, the existing queue might need to be reconfigured */ 1332 + if (iwl_mvm_is_dqa_supported(mvm)) { 1333 + spin_lock_bh(&mvm->queue_info_lock); 1334 + /* Maybe there is no need to even alloc a queue... */ 1335 + if (mvm->queue_info[queue].status == IWL_MVM_QUEUE_READY) 1336 + alloc_queue = false; 1337 + spin_unlock_bh(&mvm->queue_info_lock); 1338 + 1339 + /* 1340 + * Only reconfig the SCD for the queue if the window size has 1341 + * changed from current (become smaller) 1342 + */ 1343 + if (!alloc_queue && buf_size < mvmsta->max_agg_bufsize) { 1344 + /* 1345 + * If reconfiguring an existing queue, it first must be 1346 + * drained 1347 + */ 1348 + ret = iwl_trans_wait_tx_queue_empty(mvm->trans, 1349 + BIT(queue)); 1350 + if (ret) { 1351 + IWL_ERR(mvm, 1352 + "Error draining queue before reconfig\n"); 1353 + return ret; 1354 + } 1355 + 1356 + ret = iwl_mvm_reconfig_scd(mvm, queue, cfg.fifo, 1357 + mvmsta->sta_id, tid, 1358 + buf_size, ssn); 1359 + if (ret) { 1360 + IWL_ERR(mvm, 1361 + "Error reconfiguring TXQ #%d\n", queue); 1362 + return ret; 1363 + } 1364 + } 1365 + } 1366 + 1367 + if (alloc_queue) 1368 + iwl_mvm_enable_txq(mvm, queue, 1369 + vif->hw_queue[tid_to_mac80211_ac[tid]], ssn, 1370 + &cfg, wdg_timeout); 1595 1371 1596 1372 ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true); 1597 1373 if (ret) ··· 1637 1337 1638 1338 /* No need to mark as reserved */ 1639 1339 spin_lock_bh(&mvm->queue_info_lock); 1640 - mvm->queue_info[queue].setup_reserved = false; 1340 + mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY; 1641 1341 spin_unlock_bh(&mvm->queue_info_lock); 1642 1342 1643 1343 /* ··· 1684 1384 1685 1385 mvmsta->agg_tids &= ~BIT(tid); 1686 1386 1687 - /* No need to mark as reserved anymore */ 1688 1387 spin_lock_bh(&mvm->queue_info_lock); 1689 - mvm->queue_info[txq_id].setup_reserved = false; 1388 + /* 1389 + * The TXQ is marked as reserved only if no traffic came through yet 1390 + * This means no traffic has been sent on this TID (agg'd or not), so 1391 + * we no longer have use for the queue. Since it hasn't even been 1392 + * allocated through iwl_mvm_enable_txq, so we can just mark it back as 1393 + * free. 1394 + */ 1395 + if (mvm->queue_info[txq_id].status == IWL_MVM_QUEUE_RESERVED) 1396 + mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_FREE; 1690 1397 spin_unlock_bh(&mvm->queue_info_lock); 1691 1398 1692 1399 switch (tid_data->state) { ··· 1719 1412 1720 1413 iwl_mvm_sta_tx_agg(mvm, sta, tid, txq_id, false); 1721 1414 1722 - iwl_mvm_disable_txq(mvm, txq_id, 1723 - vif->hw_queue[tid_to_mac80211_ac[tid]], tid, 1724 - 0); 1415 + if (!iwl_mvm_is_dqa_supported(mvm)) { 1416 + int mac_queue = vif->hw_queue[tid_to_mac80211_ac[tid]]; 1417 + 1418 + iwl_mvm_disable_txq(mvm, txq_id, mac_queue, tid, 0); 1419 + } 1725 1420 return 0; 1726 1421 case IWL_AGG_STARTING: 1727 1422 case IWL_EMPTYING_HW_QUEUE_ADDBA: ··· 1774 1465 mvmsta->agg_tids &= ~BIT(tid); 1775 1466 spin_unlock_bh(&mvmsta->lock); 1776 1467 1777 - /* No need to mark as reserved */ 1778 1468 spin_lock_bh(&mvm->queue_info_lock); 1779 - mvm->queue_info[txq_id].setup_reserved = false; 1469 + /* 1470 + * The TXQ is marked as reserved only if no traffic came through yet 1471 + * This means no traffic has been sent on this TID (agg'd or not), so 1472 + * we no longer have use for the queue. Since it hasn't even been 1473 + * allocated through iwl_mvm_enable_txq, so we can just mark it back as 1474 + * free. 1475 + */ 1476 + if (mvm->queue_info[txq_id].status == IWL_MVM_QUEUE_RESERVED) 1477 + mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_FREE; 1780 1478 spin_unlock_bh(&mvm->queue_info_lock); 1781 1479 1782 1480 if (old_state >= IWL_AGG_ON) { ··· 1796 1480 1797 1481 iwl_mvm_sta_tx_agg(mvm, sta, tid, txq_id, false); 1798 1482 1799 - iwl_mvm_disable_txq(mvm, tid_data->txq_id, 1800 - vif->hw_queue[tid_to_mac80211_ac[tid]], tid, 1801 - 0); 1483 + if (!iwl_mvm_is_dqa_supported(mvm)) { 1484 + int mac_queue = vif->hw_queue[tid_to_mac80211_ac[tid]]; 1485 + 1486 + iwl_mvm_disable_txq(mvm, tid_data->txq_id, mac_queue, 1487 + tid, 0); 1488 + } 1802 1489 } 1803 1490 1804 1491 return 0; ··· 1852 1533 mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { 1853 1534 u8 sta_id = mvmvif->ap_sta_id; 1854 1535 1855 - sta = rcu_dereference_check(mvm->fw_id_to_mac_id[sta_id], 1856 - lockdep_is_held(&mvm->mutex)); 1857 1536 /* 1858 1537 * It is possible that the 'sta' parameter is NULL, 1859 1538 * for example when a GTK is removed - the sta_id will then 1860 1539 * be the AP ID, and no station was passed by mac80211. 1861 1540 */ 1862 - if (IS_ERR_OR_NULL(sta)) 1863 - return NULL; 1864 - 1865 - return iwl_mvm_sta_from_mac80211(sta); 1541 + return iwl_mvm_sta_from_staid_protected(mvm, sta_id); 1866 1542 } 1867 1543 1868 1544 return NULL;
+12 -1
drivers/net/wireless/intel/iwlwifi/mvm/sta.h
··· 348 348 } ____cacheline_aligned_in_smp q[]; 349 349 }; 350 350 351 + struct iwl_mvm_delba_data { 352 + u32 baid; 353 + } __packed; 354 + 355 + struct iwl_mvm_delba_notif { 356 + struct iwl_mvm_internal_rxq_notif metadata; 357 + struct iwl_mvm_delba_data delba; 358 + } __packed; 359 + 351 360 /** 352 361 * struct iwl_mvm_rxq_dup_data - per station per rx queue data 353 362 * @last_seq: last sequence per tid for duplicate packet detection ··· 382 373 * @lock: lock to protect the whole struct. Since %tid_data is access from Tx 383 374 * and from Tx response flow, it needs a spinlock. 384 375 * @tid_data: per tid data + mgmt. Look at %iwl_mvm_tid_data. 376 + * @tid_to_baid: a simple map of TID to baid 385 377 * @reserved_queue: the queue reserved for this STA for DQA purposes 386 378 * Every STA has is given one reserved queue to allow it to operate. If no 387 379 * such queue can be guaranteed, the STA addition will fail. ··· 416 406 bool next_status_eosp; 417 407 spinlock_t lock; 418 408 struct iwl_mvm_tid_data tid_data[IWL_MAX_TID_COUNT + 1]; 409 + u8 tid_to_baid[IWL_MAX_TID_COUNT]; 419 410 struct iwl_lq_sta lq_sta; 420 411 struct ieee80211_vif *vif; 421 412 struct iwl_mvm_key_pn __rcu *ptk_pn[4]; ··· 498 487 499 488 /* AMPDU */ 500 489 int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta, 501 - int tid, u16 ssn, bool start, u8 buf_size); 490 + int tid, u16 ssn, bool start, u8 buf_size, u16 timeout); 502 491 int iwl_mvm_sta_tx_agg_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 503 492 struct ieee80211_sta *sta, u16 tid, u16 *ssn); 504 493 int iwl_mvm_sta_tx_agg_oper(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+3 -5
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
··· 359 359 360 360 static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable) 361 361 { 362 - struct ieee80211_sta *sta; 363 362 struct iwl_mvm_sta *mvmsta; 364 363 int i, err; 365 364 366 365 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) { 367 - sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], 368 - lockdep_is_held(&mvm->mutex)); 369 - if (IS_ERR_OR_NULL(sta)) 366 + mvmsta = iwl_mvm_sta_from_staid_protected(mvm, i); 367 + if (!mvmsta) 370 368 continue; 371 - mvmsta = iwl_mvm_sta_from_mac80211(sta); 369 + 372 370 if (enable == mvmsta->tt_tx_protection) 373 371 continue; 374 372 err = iwl_mvm_tx_protection(mvm, mvmsta, enable);
+43 -16
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
··· 475 475 return dev_cmd; 476 476 } 477 477 478 + static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm, 479 + struct ieee80211_tx_info *info, __le16 fc) 480 + { 481 + if (iwl_mvm_is_dqa_supported(mvm)) { 482 + if (info->control.vif->type == NL80211_IFTYPE_AP && 483 + ieee80211_is_probe_resp(fc)) 484 + return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; 485 + else if (ieee80211_is_mgmt(fc) && 486 + info->control.vif->type == NL80211_IFTYPE_P2P_DEVICE) 487 + return IWL_MVM_DQA_P2P_DEVICE_QUEUE; 488 + } 489 + 490 + return info->hw_queue; 491 + } 492 + 478 493 int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb) 479 494 { 480 495 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; ··· 499 484 struct iwl_tx_cmd *tx_cmd; 500 485 u8 sta_id; 501 486 int hdrlen = ieee80211_hdrlen(hdr->frame_control); 487 + int queue; 502 488 503 489 memcpy(&info, skb->cb, sizeof(info)); 504 490 ··· 524 508 info.control.vif->type == NL80211_IFTYPE_STATION) 525 509 IEEE80211_SKB_CB(skb)->hw_queue = mvm->aux_queue; 526 510 511 + queue = info.hw_queue; 512 + 527 513 /* 528 514 * If the interface on which the frame is sent is the P2P_DEVICE 529 515 * or an AP/GO interface use the broadcast station associated ··· 541 523 iwl_mvm_vif_from_mac80211(info.control.vif); 542 524 543 525 if (info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE || 544 - info.control.vif->type == NL80211_IFTYPE_AP) 526 + info.control.vif->type == NL80211_IFTYPE_AP) { 545 527 sta_id = mvmvif->bcast_sta.sta_id; 546 - else if (info.control.vif->type == NL80211_IFTYPE_STATION && 547 - is_multicast_ether_addr(hdr->addr1)) { 528 + queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info, 529 + hdr->frame_control); 530 + } else if (info.control.vif->type == NL80211_IFTYPE_STATION && 531 + is_multicast_ether_addr(hdr->addr1)) { 548 532 u8 ap_sta_id = ACCESS_ONCE(mvmvif->ap_sta_id); 549 533 550 534 if (ap_sta_id != IWL_MVM_STATION_COUNT) ··· 554 534 } 555 535 } 556 536 557 - IWL_DEBUG_TX(mvm, "station Id %d, queue=%d\n", sta_id, info.hw_queue); 537 + IWL_DEBUG_TX(mvm, "station Id %d, queue=%d\n", sta_id, queue); 558 538 559 539 dev_cmd = iwl_mvm_set_tx_params(mvm, skb, &info, hdrlen, NULL, sta_id); 560 540 if (!dev_cmd) ··· 565 545 /* Copy MAC header from skb into command buffer */ 566 546 memcpy(tx_cmd->hdr, hdr, hdrlen); 567 547 568 - if (iwl_trans_tx(mvm->trans, skb, dev_cmd, info.hw_queue)) { 548 + if (iwl_trans_tx(mvm->trans, skb, dev_cmd, queue)) { 569 549 iwl_trans_free_tx_cmd(mvm->trans, dev_cmd); 570 550 return -1; 571 551 } ··· 609 589 if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT)) 610 590 return -EINVAL; 611 591 592 + dbg_max_amsdu_len = ACCESS_ONCE(mvm->max_amsdu_len); 593 + 612 594 if (!sta->max_amsdu_len || 613 595 !ieee80211_is_data_qos(hdr->frame_control) || 614 - !mvmsta->tlc_amsdu) { 596 + (!mvmsta->tlc_amsdu && !dbg_max_amsdu_len)) { 615 597 num_subframes = 1; 616 598 pad = 0; 617 599 goto segment; ··· 644 622 } 645 623 646 624 max_amsdu_len = sta->max_amsdu_len; 647 - dbg_max_amsdu_len = ACCESS_ONCE(mvm->max_amsdu_len); 648 625 649 626 /* the Tx FIFO to which this A-MSDU will be routed */ 650 627 txf = iwl_mvm_ac_to_tx_fifo[tid_to_mac80211_ac[tid]]; ··· 657 636 max_amsdu_len = min_t(unsigned int, max_amsdu_len, 658 637 mvm->shared_mem_cfg.txfifo_size[txf] - 256); 659 638 660 - if (dbg_max_amsdu_len) 639 + if (unlikely(dbg_max_amsdu_len)) 661 640 max_amsdu_len = min_t(unsigned int, max_amsdu_len, 662 641 dbg_max_amsdu_len); 663 642 ··· 933 912 934 913 spin_unlock(&mvmsta->lock); 935 914 936 - if (txq_id < mvm->first_agg_queue) 915 + /* Increase pending frames count if this isn't AMPDU */ 916 + if (!is_ampdu) 937 917 atomic_inc(&mvm->pending_frames[mvmsta->sta_id]); 938 918 939 919 return 0; ··· 1182 1160 u8 skb_freed = 0; 1183 1161 u16 next_reclaimed, seq_ctl; 1184 1162 bool is_ndp = false; 1163 + bool txq_agg = false; /* Is this TXQ aggregated */ 1185 1164 1186 1165 __skb_queue_head_init(&skbs); 1187 1166 ··· 1313 1290 bool send_eosp_ndp = false; 1314 1291 1315 1292 spin_lock_bh(&mvmsta->lock); 1293 + txq_agg = (mvmsta->tid_data[tid].state == IWL_AGG_ON); 1294 + 1316 1295 if (!is_ndp) { 1317 1296 tid_data->next_reclaimed = next_reclaimed; 1318 1297 IWL_DEBUG_TX_REPLY(mvm, ··· 1370 1345 * If the txq is not an AMPDU queue, there is no chance we freed 1371 1346 * several skbs. Check that out... 1372 1347 */ 1373 - if (txq_id >= mvm->first_agg_queue) 1348 + if (txq_agg) 1374 1349 goto out; 1375 1350 1376 1351 /* We can't free more than one frame at once on a shared queue */ 1377 - WARN_ON(skb_freed > 1); 1352 + WARN_ON(!iwl_mvm_is_dqa_supported(mvm) && (skb_freed > 1)); 1378 1353 1379 1354 /* If we have still frames for this STA nothing to do here */ 1380 1355 if (!atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id])) ··· 1468 1443 int sta_id = IWL_MVM_TX_RES_GET_RA(tx_resp->ra_tid); 1469 1444 int tid = IWL_MVM_TX_RES_GET_TID(tx_resp->ra_tid); 1470 1445 u16 sequence = le16_to_cpu(pkt->hdr.sequence); 1471 - struct ieee80211_sta *sta; 1446 + struct iwl_mvm_sta *mvmsta; 1447 + int queue = SEQ_TO_QUEUE(sequence); 1472 1448 1473 - if (WARN_ON_ONCE(SEQ_TO_QUEUE(sequence) < mvm->first_agg_queue)) 1449 + if (WARN_ON_ONCE(queue < mvm->first_agg_queue && 1450 + (!iwl_mvm_is_dqa_supported(mvm) || 1451 + (queue != IWL_MVM_DQA_BSS_CLIENT_QUEUE)))) 1474 1452 return; 1475 1453 1476 1454 if (WARN_ON_ONCE(tid == IWL_TID_NON_QOS)) ··· 1483 1455 1484 1456 rcu_read_lock(); 1485 1457 1486 - sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); 1458 + mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, sta_id); 1487 1459 1488 - if (!WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) { 1489 - struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 1460 + if (!WARN_ON_ONCE(!mvmsta)) { 1490 1461 mvmsta->tid_data[tid].rate_n_flags = 1491 1462 le32_to_cpu(tx_resp->initial_rate); 1492 1463 mvmsta->tid_data[tid].tx_time =
+43 -2
drivers/net/wireless/intel/iwlwifi/mvm/utils.c
··· 90 90 * the mutex, this ensures we don't try to send two 91 91 * (or more) synchronous commands at a time. 92 92 */ 93 - if (!(cmd->flags & CMD_ASYNC)) 93 + if (!(cmd->flags & CMD_ASYNC)) { 94 94 lockdep_assert_held(&mvm->mutex); 95 + if (!(cmd->flags & CMD_SEND_IN_IDLE)) 96 + iwl_mvm_ref(mvm, IWL_MVM_REF_SENDING_CMD); 97 + } 95 98 96 99 ret = iwl_trans_send_cmd(mvm->trans, cmd); 100 + 101 + if (!(cmd->flags & (CMD_ASYNC | CMD_SEND_IN_IDLE))) 102 + iwl_mvm_unref(mvm, IWL_MVM_REF_SENDING_CMD); 97 103 98 104 /* 99 105 * If the caller wants the SKB, then don't hide any problems, the ··· 587 581 588 582 for (i = minq; i <= maxq; i++) 589 583 if (mvm->queue_info[i].hw_queue_refcount == 0 && 590 - !mvm->queue_info[i].setup_reserved) 584 + mvm->queue_info[i].status == IWL_MVM_QUEUE_FREE) 591 585 return i; 592 586 593 587 return -ENOSPC; 588 + } 589 + 590 + int iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo, int sta_id, 591 + int tid, int frame_limit, u16 ssn) 592 + { 593 + struct iwl_scd_txq_cfg_cmd cmd = { 594 + .scd_queue = queue, 595 + .enable = 1, 596 + .window = frame_limit, 597 + .sta_id = sta_id, 598 + .ssn = cpu_to_le16(ssn), 599 + .tx_fifo = fifo, 600 + .aggregate = (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE || 601 + queue == IWL_MVM_DQA_BSS_CLIENT_QUEUE), 602 + .tid = tid, 603 + }; 604 + int ret; 605 + 606 + spin_lock_bh(&mvm->queue_info_lock); 607 + if (WARN(mvm->queue_info[queue].hw_queue_refcount == 0, 608 + "Trying to reconfig unallocated queue %d\n", queue)) { 609 + spin_unlock_bh(&mvm->queue_info_lock); 610 + return -ENXIO; 611 + } 612 + spin_unlock_bh(&mvm->queue_info_lock); 613 + 614 + IWL_DEBUG_TX_QUEUES(mvm, "Reconfig SCD for TXQ #%d\n", queue); 615 + 616 + ret = iwl_mvm_send_cmd_pdu(mvm, SCD_QUEUE_CFG, 0, sizeof(cmd), &cmd); 617 + WARN_ONCE(ret, "Failed to re-configure queue %d on FIFO %d, ret=%d\n", 618 + queue, fifo, ret); 619 + 620 + return ret; 594 621 } 595 622 596 623 void iwl_mvm_enable_txq(struct iwl_mvm *mvm, int queue, int mac80211_queue, ··· 721 682 mvm->queue_info[queue].hw_queue_refcount--; 722 683 723 684 cmd.enable = mvm->queue_info[queue].hw_queue_refcount ? 1 : 0; 685 + if (!cmd.enable) 686 + mvm->queue_info[queue].status = IWL_MVM_QUEUE_FREE; 724 687 725 688 IWL_DEBUG_TX_QUEUES(mvm, 726 689 "Disabling TXQ #%d refcount=%d (mac80211 map:0x%x)\n",
+21 -10
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
··· 493 493 {IWL_PCI_DEVICE(0x24FD, 0x8130, iwl8265_2ac_cfg)}, 494 494 495 495 /* 9000 Series */ 496 - {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9560_2ac_cfg)}, 497 - {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9560_2ac_cfg)}, 498 - {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl5165_2ac_cfg)}, 496 + {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)}, 497 + {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)}, 498 + {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9260_2ac_cfg)}, 499 + {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9260_2ac_cfg)}, 500 + {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9260_2ac_cfg)}, 501 + {IWL_PCI_DEVICE(0x9DF0, 0x0410, iwl9260_2ac_cfg)}, 502 + {IWL_PCI_DEVICE(0x9DF0, 0x0610, iwl9260_2ac_cfg)}, 503 + {IWL_PCI_DEVICE(0x9DF0, 0x0310, iwl5165_2ac_cfg)}, 504 + {IWL_PCI_DEVICE(0x9DF0, 0x0000, iwl5165_2ac_cfg)}, 505 + {IWL_PCI_DEVICE(0x9DF0, 0x0510, iwl5165_2ac_cfg)}, 499 506 {IWL_PCI_DEVICE(0x9DF0, 0x2010, iwl5165_2ac_cfg)}, 500 507 {IWL_PCI_DEVICE(0x2526, 0x1420, iwl5165_2ac_cfg)}, 501 - {IWL_PCI_DEVICE(0x2526, 0x0010, iwl5165_2ac_cfg)}, 502 - {IWL_PCI_DEVICE(0x9DF0, 0x0000, iwl5165_2ac_cfg)}, 503 - {IWL_PCI_DEVICE(0x9DF0, 0x0310, iwl5165_2ac_cfg)}, 504 - {IWL_PCI_DEVICE(0x9DF0, 0x0510, iwl5165_2ac_cfg)}, 505 508 {IWL_PCI_DEVICE(0x9DF0, 0x0710, iwl5165_2ac_cfg)}, 506 - {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9560_2ac_cfg)}, 507 - {IWL_PCI_DEVICE(0x9DF0, 0x0410, iwl9560_2ac_cfg)}, 508 - {IWL_PCI_DEVICE(0x9DF0, 0x0610, iwl9560_2ac_cfg)}, 509 + {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl5165_2ac_cfg)}, 509 510 #endif /* CONFIG_IWLMVM */ 510 511 511 512 {0} ··· 596 595 { 597 596 const struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 598 597 const struct iwl_cfg *cfg_7265d __maybe_unused = NULL; 598 + const struct iwl_cfg *cfg_9260lc __maybe_unused = NULL; 599 599 struct iwl_trans *iwl_trans; 600 600 struct iwl_trans_pcie *trans_pcie; 601 601 int ret; ··· 623 621 (iwl_trans->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_7265D) { 624 622 cfg = cfg_7265d; 625 623 iwl_trans->cfg = cfg_7265d; 624 + } 625 + 626 + if (iwl_trans->cfg->rf_id) { 627 + if (cfg == &iwl9260_2ac_cfg) 628 + cfg_9260lc = &iwl9260lc_2ac_cfg; 629 + if (cfg_9260lc && iwl_trans->hw_rf_id == CSR_HW_RF_ID_TYPE_LC) { 630 + cfg = cfg_9260lc; 631 + iwl_trans->cfg = cfg_9260lc; 632 + } 626 633 } 627 634 #endif 628 635
-3
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
··· 481 481 struct sk_buff_head *skbs); 482 482 void iwl_trans_pcie_tx_reset(struct iwl_trans *trans); 483 483 484 - void iwl_trans_pcie_ref(struct iwl_trans *trans); 485 - void iwl_trans_pcie_unref(struct iwl_trans *trans); 486 - 487 484 static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx) 488 485 { 489 486 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
+64 -47
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
··· 161 161 return cpu_to_le32((u32)(dma_addr >> 8)); 162 162 } 163 163 164 - static void iwl_pcie_write_prph_64(struct iwl_trans *trans, u64 ofs, u64 val) 164 + static void iwl_pcie_write_prph_64_no_grab(struct iwl_trans *trans, u64 ofs, 165 + u64 val) 165 166 { 166 - iwl_write_prph(trans, ofs, val & 0xffffffff); 167 - iwl_write_prph(trans, ofs + 4, val >> 32); 167 + iwl_write_prph_no_grab(trans, ofs, val & 0xffffffff); 168 + iwl_write_prph_no_grab(trans, ofs + 4, val >> 32); 168 169 } 169 170 170 171 /* ··· 209 208 210 209 rxq->write_actual = round_down(rxq->write, 8); 211 210 if (trans->cfg->mq_rx_supported) 212 - iwl_write_prph(trans, RFH_Q_FRBDCB_WIDX(rxq->id), 213 - rxq->write_actual); 211 + iwl_write32(trans, RFH_Q_FRBDCB_WIDX_TRG(rxq->id), 212 + rxq->write_actual); 214 213 /* 215 214 * write to FH_RSCSR_CHNL0_WPTR register even in MQ as a W/A to 216 215 * hardware shadow registers bug - writing to RFH_Q_FRBDCB_WIDX will ··· 699 698 { 700 699 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 701 700 u32 rb_size; 701 + unsigned long flags; 702 702 const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ 703 703 704 704 switch (trans_pcie->rx_buf_size) { ··· 717 715 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; 718 716 } 719 717 718 + if (!iwl_trans_grab_nic_access(trans, &flags)) 719 + return; 720 + 720 721 /* Stop Rx DMA */ 721 - iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); 722 + iwl_write32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); 722 723 /* reset and flush pointers */ 723 - iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_RBDCB_WPTR, 0); 724 - iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_FLUSH_RB_REQ, 0); 725 - iwl_write_direct32(trans, FH_RSCSR_CHNL0_RDPTR, 0); 724 + iwl_write32(trans, FH_MEM_RCSR_CHNL0_RBDCB_WPTR, 0); 725 + iwl_write32(trans, FH_MEM_RCSR_CHNL0_FLUSH_RB_REQ, 0); 726 + iwl_write32(trans, FH_RSCSR_CHNL0_RDPTR, 0); 726 727 727 728 /* Reset driver's Rx queue write index */ 728 - iwl_write_direct32(trans, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); 729 + iwl_write32(trans, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); 729 730 730 731 /* Tell device where to find RBD circular buffer in DRAM */ 731 - iwl_write_direct32(trans, FH_RSCSR_CHNL0_RBDCB_BASE_REG, 732 - (u32)(rxq->bd_dma >> 8)); 732 + iwl_write32(trans, FH_RSCSR_CHNL0_RBDCB_BASE_REG, 733 + (u32)(rxq->bd_dma >> 8)); 733 734 734 735 /* Tell device where in DRAM to update its Rx status */ 735 - iwl_write_direct32(trans, FH_RSCSR_CHNL0_STTS_WPTR_REG, 736 - rxq->rb_stts_dma >> 4); 736 + iwl_write32(trans, FH_RSCSR_CHNL0_STTS_WPTR_REG, 737 + rxq->rb_stts_dma >> 4); 737 738 738 739 /* Enable Rx DMA 739 740 * FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY is set because of HW bug in ··· 746 741 * RB timeout 0x10 747 742 * 256 RBDs 748 743 */ 749 - iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 750 - FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | 751 - FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY | 752 - FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | 753 - rb_size| 754 - (RX_RB_TIMEOUT << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| 755 - (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); 744 + iwl_write32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 745 + FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | 746 + FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY | 747 + FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | 748 + rb_size | 749 + (RX_RB_TIMEOUT << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) | 750 + (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); 751 + 752 + iwl_trans_release_nic_access(trans, &flags); 756 753 757 754 /* Set interrupt coalescing timer to default (2048 usecs) */ 758 755 iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); ··· 768 761 { 769 762 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 770 763 u32 rb_size, enabled = 0; 764 + unsigned long flags; 771 765 int i; 772 766 773 767 switch (trans_pcie->rx_buf_size) { ··· 786 778 rb_size = RFH_RXF_DMA_RB_SIZE_4K; 787 779 } 788 780 781 + if (!iwl_trans_grab_nic_access(trans, &flags)) 782 + return; 783 + 789 784 /* Stop Rx DMA */ 790 - iwl_write_prph(trans, RFH_RXF_DMA_CFG, 0); 785 + iwl_write_prph_no_grab(trans, RFH_RXF_DMA_CFG, 0); 791 786 /* disable free amd used rx queue operation */ 792 - iwl_write_prph(trans, RFH_RXF_RXQ_ACTIVE, 0); 787 + iwl_write_prph_no_grab(trans, RFH_RXF_RXQ_ACTIVE, 0); 793 788 794 789 for (i = 0; i < trans->num_rx_queues; i++) { 795 790 /* Tell device where to find RBD free table in DRAM */ 796 - iwl_pcie_write_prph_64(trans, RFH_Q_FRBDCB_BA_LSB(i), 797 - (u64)(trans_pcie->rxq[i].bd_dma)); 791 + iwl_pcie_write_prph_64_no_grab(trans, 792 + RFH_Q_FRBDCB_BA_LSB(i), 793 + trans_pcie->rxq[i].bd_dma); 798 794 /* Tell device where to find RBD used table in DRAM */ 799 - iwl_pcie_write_prph_64(trans, RFH_Q_URBDCB_BA_LSB(i), 800 - (u64)(trans_pcie->rxq[i].used_bd_dma)); 795 + iwl_pcie_write_prph_64_no_grab(trans, 796 + RFH_Q_URBDCB_BA_LSB(i), 797 + trans_pcie->rxq[i].used_bd_dma); 801 798 /* Tell device where in DRAM to update its Rx status */ 802 - iwl_pcie_write_prph_64(trans, RFH_Q_URBD_STTS_WPTR_LSB(i), 803 - trans_pcie->rxq[i].rb_stts_dma); 799 + iwl_pcie_write_prph_64_no_grab(trans, 800 + RFH_Q_URBD_STTS_WPTR_LSB(i), 801 + trans_pcie->rxq[i].rb_stts_dma); 804 802 /* Reset device indice tables */ 805 - iwl_write_prph(trans, RFH_Q_FRBDCB_WIDX(i), 0); 806 - iwl_write_prph(trans, RFH_Q_FRBDCB_RIDX(i), 0); 807 - iwl_write_prph(trans, RFH_Q_URBDCB_WIDX(i), 0); 803 + iwl_write_prph_no_grab(trans, RFH_Q_FRBDCB_WIDX(i), 0); 804 + iwl_write_prph_no_grab(trans, RFH_Q_FRBDCB_RIDX(i), 0); 805 + iwl_write_prph_no_grab(trans, RFH_Q_URBDCB_WIDX(i), 0); 808 806 809 807 enabled |= BIT(i) | BIT(i + 16); 810 808 } ··· 826 812 * Drop frames that exceed RB size 827 813 * 512 RBDs 828 814 */ 829 - iwl_write_prph(trans, RFH_RXF_DMA_CFG, 830 - RFH_DMA_EN_ENABLE_VAL | 831 - rb_size | RFH_RXF_DMA_SINGLE_FRAME_MASK | 832 - RFH_RXF_DMA_MIN_RB_4_8 | 833 - RFH_RXF_DMA_DROP_TOO_LARGE_MASK | 834 - RFH_RXF_DMA_RBDCB_SIZE_512); 815 + iwl_write_prph_no_grab(trans, RFH_RXF_DMA_CFG, 816 + RFH_DMA_EN_ENABLE_VAL | 817 + rb_size | RFH_RXF_DMA_SINGLE_FRAME_MASK | 818 + RFH_RXF_DMA_MIN_RB_4_8 | 819 + RFH_RXF_DMA_DROP_TOO_LARGE_MASK | 820 + RFH_RXF_DMA_RBDCB_SIZE_512); 835 821 836 822 /* 837 823 * Activate DMA snooping. 838 824 * Set RX DMA chunk size to 64B 839 825 * Default queue is 0 840 826 */ 841 - iwl_write_prph(trans, RFH_GEN_CFG, RFH_GEN_CFG_RFH_DMA_SNOOP | 842 - (DEFAULT_RXQ_NUM << RFH_GEN_CFG_DEFAULT_RXQ_NUM_POS) | 843 - RFH_GEN_CFG_SERVICE_DMA_SNOOP); 827 + iwl_write_prph_no_grab(trans, RFH_GEN_CFG, RFH_GEN_CFG_RFH_DMA_SNOOP | 828 + (DEFAULT_RXQ_NUM << 829 + RFH_GEN_CFG_DEFAULT_RXQ_NUM_POS) | 830 + RFH_GEN_CFG_SERVICE_DMA_SNOOP); 844 831 /* Enable the relevant rx queues */ 845 - iwl_write_prph(trans, RFH_RXF_RXQ_ACTIVE, enabled); 832 + iwl_write_prph_no_grab(trans, RFH_RXF_RXQ_ACTIVE, enabled); 833 + 834 + iwl_trans_release_nic_access(trans, &flags); 846 835 847 836 /* Set interrupt coalescing timer to default (2048 usecs) */ 848 837 iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); ··· 1315 1298 * write 1 clear (W1C) register, meaning that it's being clear 1316 1299 * by writing 1 to the bit. 1317 1300 */ 1318 - iwl_write_direct32(trans, CSR_MSIX_AUTOMASK_ST_AD, BIT(entry->entry)); 1301 + iwl_write32(trans, CSR_MSIX_AUTOMASK_ST_AD, BIT(entry->entry)); 1319 1302 } 1320 1303 1321 1304 /* ··· 1834 1817 lock_map_acquire(&trans->sync_cmd_lockdep_map); 1835 1818 1836 1819 spin_lock(&trans_pcie->irq_lock); 1837 - inta_fh = iwl_read_direct32(trans, CSR_MSIX_FH_INT_CAUSES_AD); 1838 - inta_hw = iwl_read_direct32(trans, CSR_MSIX_HW_INT_CAUSES_AD); 1820 + inta_fh = iwl_read32(trans, CSR_MSIX_FH_INT_CAUSES_AD); 1821 + inta_hw = iwl_read32(trans, CSR_MSIX_HW_INT_CAUSES_AD); 1839 1822 /* 1840 1823 * Clear causes registers to avoid being handling the same cause. 1841 1824 */ 1842 - iwl_write_direct32(trans, CSR_MSIX_FH_INT_CAUSES_AD, inta_fh); 1843 - iwl_write_direct32(trans, CSR_MSIX_HW_INT_CAUSES_AD, inta_hw); 1825 + iwl_write32(trans, CSR_MSIX_FH_INT_CAUSES_AD, inta_fh); 1826 + iwl_write32(trans, CSR_MSIX_HW_INT_CAUSES_AD, inta_hw); 1844 1827 spin_unlock(&trans_pcie->irq_lock); 1845 1828 1846 1829 if (unlikely(!(inta_fh | inta_hw))) {
+13 -16
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
··· 269 269 iwl_pcie_apm_config(trans); 270 270 271 271 /* Configure analog phase-lock-loop before activating to D0A */ 272 - if (trans->cfg->base_params->pll_cfg_val) 273 - iwl_set_bit(trans, CSR_ANA_PLL_CFG, 274 - trans->cfg->base_params->pll_cfg_val); 272 + if (trans->cfg->base_params->pll_cfg) 273 + iwl_set_bit(trans, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL); 275 274 276 275 /* 277 276 * Set "initialization complete" bit to move adapter from ··· 360 361 361 362 /* Reset entire device - do controller reset (results in SHRD_HW_RST) */ 362 363 iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 363 - 364 - udelay(10); 364 + usleep_range(1000, 2000); 365 365 366 366 /* 367 367 * Set "initialization complete" bit to move adapter from ··· 406 408 * SHRD_HW_RST). Turn MAC off before proceeding. 407 409 */ 408 410 iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 409 - 410 - udelay(10); 411 + usleep_range(1000, 2000); 411 412 412 413 /* Enable LP XTAL by indirect access through CSR */ 413 414 apmg_gp1_reg = iwl_trans_pcie_read_shr(trans, SHR_APMG_GP1_REG); ··· 503 506 504 507 /* Reset the entire device */ 505 508 iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 506 - 507 - udelay(10); 509 + usleep_range(1000, 2000); 508 510 509 511 /* 510 512 * Clear "initialization complete" bit to move adapter from ··· 582 586 583 587 iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, 584 588 CSR_RESET_LINK_PWR_MGMT_DISABLED); 585 - msleep(1); 589 + usleep_range(1000, 2000); 586 590 587 591 for (iter = 0; iter < 10; iter++) { 588 592 /* If HW is not ready, prepare the conditions to check again */ ··· 1070 1074 1071 1075 /* stop and reset the on-board processor */ 1072 1076 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 1073 - udelay(20); 1077 + usleep_range(1000, 2000); 1074 1078 1075 1079 /* 1076 1080 * Upon stop, the APM issues an interrupt if HW RF kill is set. ··· 1522 1526 1523 1527 /* Reset the entire device */ 1524 1528 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 1525 - 1526 - usleep_range(10, 15); 1529 + usleep_range(1000, 2000); 1527 1530 1528 1531 iwl_pcie_apm_init(trans); 1529 1532 ··· 1945 1950 "WR pointer moved while flushing %d -> %d\n", 1946 1951 wr_ptr, write_ptr)) 1947 1952 return -ETIMEDOUT; 1948 - msleep(1); 1953 + usleep_range(1000, 2000); 1949 1954 } 1950 1955 1951 1956 if (q->read_ptr != q->write_ptr) { ··· 2008 2013 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags); 2009 2014 } 2010 2015 2011 - void iwl_trans_pcie_ref(struct iwl_trans *trans) 2016 + static void iwl_trans_pcie_ref(struct iwl_trans *trans) 2012 2017 { 2013 2018 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2014 2019 ··· 2023 2028 #endif /* CONFIG_PM */ 2024 2029 } 2025 2030 2026 - void iwl_trans_pcie_unref(struct iwl_trans *trans) 2031 + static void iwl_trans_pcie_unref(struct iwl_trans *trans) 2027 2032 { 2028 2033 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2029 2034 ··· 2901 2906 iwl_trans_release_nic_access(trans, &flags); 2902 2907 } 2903 2908 } 2909 + 2910 + trans->hw_rf_id = iwl_read32(trans, CSR_HW_RF_ID); 2904 2911 2905 2912 iwl_pcie_set_interrupt_capa(pdev, trans); 2906 2913 trans->hw_id = (pdev->device << 16) + pdev->subsystem_device;
+16 -5
drivers/net/wireless/intel/iwlwifi/pcie/tx.c
··· 32 32 #include <linux/ieee80211.h> 33 33 #include <linux/slab.h> 34 34 #include <linux/sched.h> 35 + #include <linux/pm_runtime.h> 35 36 #include <net/ip6_checksum.h> 36 37 #include <net/tso.h> 37 38 ··· 606 605 if (trans_pcie->ref_cmd_in_flight) { 607 606 trans_pcie->ref_cmd_in_flight = false; 608 607 IWL_DEBUG_RPM(trans, "clear ref_cmd_in_flight - unref\n"); 609 - iwl_trans_pcie_unref(trans); 608 + iwl_trans_unref(trans); 610 609 } 611 610 612 611 if (!trans->cfg->base_params->apmg_wake_up_wa) ··· 651 650 if (txq_id != trans_pcie->cmd_queue) { 652 651 IWL_DEBUG_RPM(trans, "Q %d - last tx freed\n", 653 652 q->id); 654 - iwl_trans_pcie_unref(trans); 653 + iwl_trans_unref(trans); 655 654 } else { 656 655 iwl_pcie_clear_cmd_in_flight(trans); 657 656 } ··· 1135 1134 1136 1135 if (q->read_ptr == q->write_ptr) { 1137 1136 IWL_DEBUG_RPM(trans, "Q %d - last tx reclaimed\n", q->id); 1138 - iwl_trans_pcie_unref(trans); 1137 + iwl_trans_unref(trans); 1139 1138 } 1140 1139 1141 1140 out: ··· 1154 1153 !trans_pcie->ref_cmd_in_flight) { 1155 1154 trans_pcie->ref_cmd_in_flight = true; 1156 1155 IWL_DEBUG_RPM(trans, "set ref_cmd_in_flight - ref\n"); 1157 - iwl_trans_pcie_ref(trans); 1156 + iwl_trans_ref(trans); 1158 1157 } 1159 1158 1160 1159 /* ··· 1800 1799 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", 1801 1800 iwl_get_cmd_string(trans, cmd->id)); 1802 1801 1802 + if (pm_runtime_suspended(&trans_pcie->pci_dev->dev)) { 1803 + ret = wait_event_timeout(trans_pcie->d0i3_waitq, 1804 + pm_runtime_active(&trans_pcie->pci_dev->dev), 1805 + msecs_to_jiffies(IWL_TRANS_IDLE_TIMEOUT)); 1806 + if (!ret) { 1807 + IWL_ERR(trans, "Timeout exiting D0i3 before hcmd\n"); 1808 + return -ETIMEDOUT; 1809 + } 1810 + } 1811 + 1803 1812 cmd_idx = iwl_pcie_enqueue_hcmd(trans, cmd); 1804 1813 if (cmd_idx < 0) { 1805 1814 ret = cmd_idx; ··· 2373 2362 txq->frozen_expiry_remainder = txq->wd_timeout; 2374 2363 } 2375 2364 IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", q->id); 2376 - iwl_trans_pcie_ref(trans); 2365 + iwl_trans_ref(trans); 2377 2366 } 2378 2367 2379 2368 /* Tell device the write index *just past* this latest filled TFD */
+1 -2
drivers/net/wireless/marvell/mwifiex/pcie.h
··· 23 23 #define _MWIFIEX_PCIE_H 24 24 25 25 #include <linux/pci.h> 26 - #include <linux/pcieport_if.h> 27 26 #include <linux/interrupt.h> 28 27 29 28 #include "decl.h" ··· 116 117 /* FW awake cookie after FW ready */ 117 118 #define FW_AWAKE_COOKIE (0xAA55AA55) 118 119 #define MWIFIEX_DEF_SLEEP_COOKIE 0xBEEFBEEF 119 - #define MWIFIEX_MAX_DELAY_COUNT 5 120 + #define MWIFIEX_MAX_DELAY_COUNT 100 120 121 121 122 struct mwifiex_pcie_card_reg { 122 123 u16 cmd_addr_lo;
+3 -2
drivers/net/wireless/marvell/mwifiex/sdio.c
··· 104 104 105 105 if (!dev->of_node || 106 106 !of_match_node(mwifiex_sdio_of_match_table, dev->of_node)) { 107 - pr_err("sdio platform data not available"); 107 + dev_err(dev, "sdio platform data not available\n"); 108 108 return -1; 109 109 } 110 110 ··· 115 115 if (cfg && card->plt_of_node) { 116 116 cfg->irq_wifi = irq_of_parse_and_map(card->plt_of_node, 0); 117 117 if (!cfg->irq_wifi) { 118 - dev_err(dev, "fail to parse irq_wifi from device tree"); 118 + dev_err(dev, 119 + "fail to parse irq_wifi from device tree\n"); 119 120 } else { 120 121 ret = devm_request_irq(dev, cfg->irq_wifi, 121 122 mwifiex_wake_irq_wifi,
+12 -87
drivers/net/wireless/realtek/rtl818x/rtl8187/rtl8187.h
··· 160 160 161 161 void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data); 162 162 163 - static inline u8 rtl818x_ioread8_idx(struct rtl8187_priv *priv, 164 - u8 *addr, u8 idx) 165 - { 166 - u8 val; 167 - 168 - mutex_lock(&priv->io_mutex); 169 - usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 170 - RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 171 - (unsigned long)addr, idx & 0x03, 172 - &priv->io_dmabuf->bits8, sizeof(val), HZ / 2); 173 - 174 - val = priv->io_dmabuf->bits8; 175 - mutex_unlock(&priv->io_mutex); 176 - 177 - return val; 178 - } 163 + u8 rtl818x_ioread8_idx(struct rtl8187_priv *priv, 164 + u8 *addr, u8 idx); 179 165 180 166 static inline u8 rtl818x_ioread8(struct rtl8187_priv *priv, u8 *addr) 181 167 { 182 168 return rtl818x_ioread8_idx(priv, addr, 0); 183 169 } 184 170 185 - static inline u16 rtl818x_ioread16_idx(struct rtl8187_priv *priv, 186 - __le16 *addr, u8 idx) 187 - { 188 - __le16 val; 189 - 190 - mutex_lock(&priv->io_mutex); 191 - usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 192 - RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 193 - (unsigned long)addr, idx & 0x03, 194 - &priv->io_dmabuf->bits16, sizeof(val), HZ / 2); 195 - 196 - val = priv->io_dmabuf->bits16; 197 - mutex_unlock(&priv->io_mutex); 198 - 199 - return le16_to_cpu(val); 200 - } 171 + u16 rtl818x_ioread16_idx(struct rtl8187_priv *priv, 172 + __le16 *addr, u8 idx); 201 173 202 174 static inline u16 rtl818x_ioread16(struct rtl8187_priv *priv, __le16 *addr) 203 175 { 204 176 return rtl818x_ioread16_idx(priv, addr, 0); 205 177 } 206 178 207 - static inline u32 rtl818x_ioread32_idx(struct rtl8187_priv *priv, 208 - __le32 *addr, u8 idx) 209 - { 210 - __le32 val; 211 - 212 - mutex_lock(&priv->io_mutex); 213 - usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 214 - RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 215 - (unsigned long)addr, idx & 0x03, 216 - &priv->io_dmabuf->bits32, sizeof(val), HZ / 2); 217 - 218 - val = priv->io_dmabuf->bits32; 219 - mutex_unlock(&priv->io_mutex); 220 - 221 - return le32_to_cpu(val); 222 - } 179 + u32 rtl818x_ioread32_idx(struct rtl8187_priv *priv, 180 + __le32 *addr, u8 idx); 223 181 224 182 static inline u32 rtl818x_ioread32(struct rtl8187_priv *priv, __le32 *addr) 225 183 { 226 184 return rtl818x_ioread32_idx(priv, addr, 0); 227 185 } 228 186 229 - static inline void rtl818x_iowrite8_idx(struct rtl8187_priv *priv, 230 - u8 *addr, u8 val, u8 idx) 231 - { 232 - mutex_lock(&priv->io_mutex); 233 - 234 - priv->io_dmabuf->bits8 = val; 235 - usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 236 - RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 237 - (unsigned long)addr, idx & 0x03, 238 - &priv->io_dmabuf->bits8, sizeof(val), HZ / 2); 239 - 240 - mutex_unlock(&priv->io_mutex); 241 - } 187 + void rtl818x_iowrite8_idx(struct rtl8187_priv *priv, 188 + u8 *addr, u8 val, u8 idx); 242 189 243 190 static inline void rtl818x_iowrite8(struct rtl8187_priv *priv, u8 *addr, u8 val) 244 191 { 245 192 rtl818x_iowrite8_idx(priv, addr, val, 0); 246 193 } 247 194 248 - static inline void rtl818x_iowrite16_idx(struct rtl8187_priv *priv, 249 - __le16 *addr, u16 val, u8 idx) 250 - { 251 - mutex_lock(&priv->io_mutex); 252 - 253 - priv->io_dmabuf->bits16 = cpu_to_le16(val); 254 - usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 255 - RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 256 - (unsigned long)addr, idx & 0x03, 257 - &priv->io_dmabuf->bits16, sizeof(val), HZ / 2); 258 - 259 - mutex_unlock(&priv->io_mutex); 260 - } 195 + void rtl818x_iowrite16_idx(struct rtl8187_priv *priv, 196 + __le16 *addr, u16 val, u8 idx); 261 197 262 198 static inline void rtl818x_iowrite16(struct rtl8187_priv *priv, __le16 *addr, 263 199 u16 val) ··· 201 265 rtl818x_iowrite16_idx(priv, addr, val, 0); 202 266 } 203 267 204 - static inline void rtl818x_iowrite32_idx(struct rtl8187_priv *priv, 205 - __le32 *addr, u32 val, u8 idx) 206 - { 207 - mutex_lock(&priv->io_mutex); 208 - 209 - priv->io_dmabuf->bits32 = cpu_to_le32(val); 210 - usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 211 - RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 212 - (unsigned long)addr, idx & 0x03, 213 - &priv->io_dmabuf->bits32, sizeof(val), HZ / 2); 214 - 215 - mutex_unlock(&priv->io_mutex); 216 - } 268 + void rtl818x_iowrite32_idx(struct rtl8187_priv *priv, 269 + __le32 *addr, u32 val, u8 idx); 217 270 218 271 static inline void rtl818x_iowrite32(struct rtl8187_priv *priv, __le32 *addr, 219 272 u32 val)
+93
drivers/net/wireless/realtek/rtl818x/rtl8187/rtl8225.c
··· 22 22 #include "rtl8187.h" 23 23 #include "rtl8225.h" 24 24 25 + u8 rtl818x_ioread8_idx(struct rtl8187_priv *priv, 26 + u8 *addr, u8 idx) 27 + { 28 + u8 val; 29 + 30 + mutex_lock(&priv->io_mutex); 31 + usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 32 + RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 33 + (unsigned long)addr, idx & 0x03, 34 + &priv->io_dmabuf->bits8, sizeof(val), HZ / 2); 35 + 36 + val = priv->io_dmabuf->bits8; 37 + mutex_unlock(&priv->io_mutex); 38 + 39 + return val; 40 + } 41 + 42 + u16 rtl818x_ioread16_idx(struct rtl8187_priv *priv, 43 + __le16 *addr, u8 idx) 44 + { 45 + __le16 val; 46 + 47 + mutex_lock(&priv->io_mutex); 48 + usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 49 + RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 50 + (unsigned long)addr, idx & 0x03, 51 + &priv->io_dmabuf->bits16, sizeof(val), HZ / 2); 52 + 53 + val = priv->io_dmabuf->bits16; 54 + mutex_unlock(&priv->io_mutex); 55 + 56 + return le16_to_cpu(val); 57 + } 58 + 59 + u32 rtl818x_ioread32_idx(struct rtl8187_priv *priv, 60 + __le32 *addr, u8 idx) 61 + { 62 + __le32 val; 63 + 64 + mutex_lock(&priv->io_mutex); 65 + usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 66 + RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 67 + (unsigned long)addr, idx & 0x03, 68 + &priv->io_dmabuf->bits32, sizeof(val), HZ / 2); 69 + 70 + val = priv->io_dmabuf->bits32; 71 + mutex_unlock(&priv->io_mutex); 72 + 73 + return le32_to_cpu(val); 74 + } 75 + 76 + void rtl818x_iowrite8_idx(struct rtl8187_priv *priv, 77 + u8 *addr, u8 val, u8 idx) 78 + { 79 + mutex_lock(&priv->io_mutex); 80 + 81 + priv->io_dmabuf->bits8 = val; 82 + usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 83 + RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 84 + (unsigned long)addr, idx & 0x03, 85 + &priv->io_dmabuf->bits8, sizeof(val), HZ / 2); 86 + 87 + mutex_unlock(&priv->io_mutex); 88 + } 89 + 90 + void rtl818x_iowrite16_idx(struct rtl8187_priv *priv, 91 + __le16 *addr, u16 val, u8 idx) 92 + { 93 + mutex_lock(&priv->io_mutex); 94 + 95 + priv->io_dmabuf->bits16 = cpu_to_le16(val); 96 + usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 97 + RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 98 + (unsigned long)addr, idx & 0x03, 99 + &priv->io_dmabuf->bits16, sizeof(val), HZ / 2); 100 + 101 + mutex_unlock(&priv->io_mutex); 102 + } 103 + 104 + void rtl818x_iowrite32_idx(struct rtl8187_priv *priv, 105 + __le32 *addr, u32 val, u8 idx) 106 + { 107 + mutex_lock(&priv->io_mutex); 108 + 109 + priv->io_dmabuf->bits32 = cpu_to_le32(val); 110 + usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 111 + RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 112 + (unsigned long)addr, idx & 0x03, 113 + &priv->io_dmabuf->bits32, sizeof(val), HZ / 2); 114 + 115 + mutex_unlock(&priv->io_mutex); 116 + } 117 + 25 118 static void rtl8225_write_bitbang(struct ieee80211_hw *dev, u8 addr, u16 data) 26 119 { 27 120 struct rtl8187_priv *priv = dev->priv;
+3
drivers/net/wireless/realtek/rtl8xxxu/Makefile
··· 1 1 obj-$(CONFIG_RTL8XXXU) += rtl8xxxu.o 2 + 3 + rtl8xxxu-y := rtl8xxxu_core.o rtl8xxxu_8192e.o rtl8xxxu_8723b.o \ 4 + rtl8xxxu_8723a.o rtl8xxxu_8192c.o
+131 -4157
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
··· 42 42 43 43 #define DRIVER_NAME "rtl8xxxu" 44 44 45 - static int rtl8xxxu_debug = RTL8XXXU_DEBUG_EFUSE; 45 + int rtl8xxxu_debug = RTL8XXXU_DEBUG_EFUSE; 46 46 static bool rtl8xxxu_ht40_2g; 47 47 48 48 MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@redhat.com>"); ··· 128 128 .n_bitrates = ARRAY_SIZE(rtl8xxxu_rates), 129 129 }; 130 130 131 - static struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table[] = { 131 + struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table[] = { 132 132 {0x420, 0x80}, {0x423, 0x00}, {0x430, 0x00}, {0x431, 0x00}, 133 133 {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 134 134 {0x436, 0x06}, {0x437, 0x07}, {0x438, 0x00}, {0x439, 0x00}, ··· 151 151 {0x63f, 0x0e}, {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, 152 152 {0x702, 0x65}, {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, 153 153 {0x70a, 0x65}, {0x70b, 0x87}, {0xffff, 0xff}, 154 - }; 155 - 156 - static struct rtl8xxxu_reg8val rtl8723b_mac_init_table[] = { 157 - {0x02f, 0x30}, {0x035, 0x00}, {0x039, 0x08}, {0x04e, 0xe0}, 158 - {0x064, 0x00}, {0x067, 0x20}, {0x428, 0x0a}, {0x429, 0x10}, 159 - {0x430, 0x00}, {0x431, 0x00}, 160 - {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 161 - {0x436, 0x07}, {0x437, 0x08}, {0x43c, 0x04}, {0x43d, 0x05}, 162 - {0x43e, 0x07}, {0x43f, 0x08}, {0x440, 0x5d}, {0x441, 0x01}, 163 - {0x442, 0x00}, {0x444, 0x10}, {0x445, 0x00}, {0x446, 0x00}, 164 - {0x447, 0x00}, {0x448, 0x00}, {0x449, 0xf0}, {0x44a, 0x0f}, 165 - {0x44b, 0x3e}, {0x44c, 0x10}, {0x44d, 0x00}, {0x44e, 0x00}, 166 - {0x44f, 0x00}, {0x450, 0x00}, {0x451, 0xf0}, {0x452, 0x0f}, 167 - {0x453, 0x00}, {0x456, 0x5e}, {0x460, 0x66}, {0x461, 0x66}, 168 - {0x4c8, 0xff}, {0x4c9, 0x08}, {0x4cc, 0xff}, 169 - {0x4cd, 0xff}, {0x4ce, 0x01}, {0x500, 0x26}, {0x501, 0xa2}, 170 - {0x502, 0x2f}, {0x503, 0x00}, {0x504, 0x28}, {0x505, 0xa3}, 171 - {0x506, 0x5e}, {0x507, 0x00}, {0x508, 0x2b}, {0x509, 0xa4}, 172 - {0x50a, 0x5e}, {0x50b, 0x00}, {0x50c, 0x4f}, {0x50d, 0xa4}, 173 - {0x50e, 0x00}, {0x50f, 0x00}, {0x512, 0x1c}, {0x514, 0x0a}, 174 - {0x516, 0x0a}, {0x525, 0x4f}, 175 - {0x550, 0x10}, {0x551, 0x10}, {0x559, 0x02}, {0x55c, 0x50}, 176 - {0x55d, 0xff}, {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, 177 - {0x620, 0xff}, {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, 178 - {0x624, 0xff}, {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, 179 - {0x638, 0x50}, {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, 180 - {0x63f, 0x0e}, {0x640, 0x40}, {0x642, 0x40}, {0x643, 0x00}, 181 - {0x652, 0xc8}, {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, 182 - {0x702, 0x65}, {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, 183 - {0x70a, 0x65}, {0x70b, 0x87}, {0x765, 0x18}, {0x76e, 0x04}, 184 - {0xffff, 0xff}, 185 - }; 186 - 187 - static struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = { 188 - {0x011, 0xeb}, {0x012, 0x07}, {0x014, 0x75}, {0x303, 0xa7}, 189 - {0x428, 0x0a}, {0x429, 0x10}, {0x430, 0x00}, {0x431, 0x00}, 190 - {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 191 - {0x436, 0x07}, {0x437, 0x08}, {0x43c, 0x04}, {0x43d, 0x05}, 192 - {0x43e, 0x07}, {0x43f, 0x08}, {0x440, 0x5d}, {0x441, 0x01}, 193 - {0x442, 0x00}, {0x444, 0x10}, {0x445, 0x00}, {0x446, 0x00}, 194 - {0x447, 0x00}, {0x448, 0x00}, {0x449, 0xf0}, {0x44a, 0x0f}, 195 - {0x44b, 0x3e}, {0x44c, 0x10}, {0x44d, 0x00}, {0x44e, 0x00}, 196 - {0x44f, 0x00}, {0x450, 0x00}, {0x451, 0xf0}, {0x452, 0x0f}, 197 - {0x453, 0x00}, {0x456, 0x5e}, {0x460, 0x66}, {0x461, 0x66}, 198 - {0x4c8, 0xff}, {0x4c9, 0x08}, {0x4cc, 0xff}, {0x4cd, 0xff}, 199 - {0x4ce, 0x01}, {0x500, 0x26}, {0x501, 0xa2}, {0x502, 0x2f}, 200 - {0x503, 0x00}, {0x504, 0x28}, {0x505, 0xa3}, {0x506, 0x5e}, 201 - {0x507, 0x00}, {0x508, 0x2b}, {0x509, 0xa4}, {0x50a, 0x5e}, 202 - {0x50b, 0x00}, {0x50c, 0x4f}, {0x50d, 0xa4}, {0x50e, 0x00}, 203 - {0x50f, 0x00}, {0x512, 0x1c}, {0x514, 0x0a}, {0x516, 0x0a}, 204 - {0x525, 0x4f}, {0x540, 0x12}, {0x541, 0x64}, {0x550, 0x10}, 205 - {0x551, 0x10}, {0x559, 0x02}, {0x55c, 0x50}, {0x55d, 0xff}, 206 - {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, {0x620, 0xff}, 207 - {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, {0x624, 0xff}, 208 - {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, {0x638, 0x50}, 209 - {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, {0x63f, 0x0e}, 210 - {0x640, 0x40}, {0x642, 0x40}, {0x643, 0x00}, {0x652, 0xc8}, 211 - {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, {0x702, 0x65}, 212 - {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, {0x70a, 0x65}, 213 - {0x70b, 0x87}, 214 - {0xffff, 0xff}, 215 - }; 216 - 217 - #ifdef CONFIG_RTL8XXXU_UNTESTED 218 - static struct rtl8xxxu_power_base rtl8188r_power_base = { 219 - .reg_0e00 = 0x06080808, 220 - .reg_0e04 = 0x00040406, 221 - .reg_0e08 = 0x00000000, 222 - .reg_086c = 0x00000000, 223 - 224 - .reg_0e10 = 0x04060608, 225 - .reg_0e14 = 0x00020204, 226 - .reg_0e18 = 0x04060608, 227 - .reg_0e1c = 0x00020204, 228 - 229 - .reg_0830 = 0x06080808, 230 - .reg_0834 = 0x00040406, 231 - .reg_0838 = 0x00000000, 232 - .reg_086c_2 = 0x00000000, 233 - 234 - .reg_083c = 0x04060608, 235 - .reg_0848 = 0x00020204, 236 - .reg_084c = 0x04060608, 237 - .reg_0868 = 0x00020204, 238 - }; 239 - 240 - static struct rtl8xxxu_power_base rtl8192c_power_base = { 241 - .reg_0e00 = 0x07090c0c, 242 - .reg_0e04 = 0x01020405, 243 - .reg_0e08 = 0x00000000, 244 - .reg_086c = 0x00000000, 245 - 246 - .reg_0e10 = 0x0b0c0c0e, 247 - .reg_0e14 = 0x01030506, 248 - .reg_0e18 = 0x0b0c0d0e, 249 - .reg_0e1c = 0x01030509, 250 - 251 - .reg_0830 = 0x07090c0c, 252 - .reg_0834 = 0x01020405, 253 - .reg_0838 = 0x00000000, 254 - .reg_086c_2 = 0x00000000, 255 - 256 - .reg_083c = 0x0b0c0d0e, 257 - .reg_0848 = 0x01030509, 258 - .reg_084c = 0x0b0c0d0e, 259 - .reg_0868 = 0x01030509, 260 - }; 261 - #endif 262 - 263 - static struct rtl8xxxu_power_base rtl8723a_power_base = { 264 - .reg_0e00 = 0x0a0c0c0c, 265 - .reg_0e04 = 0x02040608, 266 - .reg_0e08 = 0x00000000, 267 - .reg_086c = 0x00000000, 268 - 269 - .reg_0e10 = 0x0a0c0d0e, 270 - .reg_0e14 = 0x02040608, 271 - .reg_0e18 = 0x0a0c0d0e, 272 - .reg_0e1c = 0x02040608, 273 - 274 - .reg_0830 = 0x0a0c0c0c, 275 - .reg_0834 = 0x02040608, 276 - .reg_0838 = 0x00000000, 277 - .reg_086c_2 = 0x00000000, 278 - 279 - .reg_083c = 0x0a0c0d0e, 280 - .reg_0848 = 0x02040608, 281 - .reg_084c = 0x0a0c0d0e, 282 - .reg_0868 = 0x02040608, 283 154 }; 284 155 285 156 static struct rtl8xxxu_reg32val rtl8723a_phy_1t_init_table[] = { ··· 248 377 {0xee0, 0x001b25a0}, {0xeec, 0x6b1b25a0}, 249 378 {0xf14, 0x00000003}, {0xf4c, 0x00000000}, 250 379 {0xf00, 0x00000300}, 251 - {0xffff, 0xffffffff}, 252 - }; 253 - 254 - static struct rtl8xxxu_reg32val rtl8723b_phy_1t_init_table[] = { 255 - {0x800, 0x80040000}, {0x804, 0x00000003}, 256 - {0x808, 0x0000fc00}, {0x80c, 0x0000000a}, 257 - {0x810, 0x10001331}, {0x814, 0x020c3d10}, 258 - {0x818, 0x02200385}, {0x81c, 0x00000000}, 259 - {0x820, 0x01000100}, {0x824, 0x00190204}, 260 - {0x828, 0x00000000}, {0x82c, 0x00000000}, 261 - {0x830, 0x00000000}, {0x834, 0x00000000}, 262 - {0x838, 0x00000000}, {0x83c, 0x00000000}, 263 - {0x840, 0x00010000}, {0x844, 0x00000000}, 264 - {0x848, 0x00000000}, {0x84c, 0x00000000}, 265 - {0x850, 0x00000000}, {0x854, 0x00000000}, 266 - {0x858, 0x569a11a9}, {0x85c, 0x01000014}, 267 - {0x860, 0x66f60110}, {0x864, 0x061f0649}, 268 - {0x868, 0x00000000}, {0x86c, 0x27272700}, 269 - {0x870, 0x07000760}, {0x874, 0x25004000}, 270 - {0x878, 0x00000808}, {0x87c, 0x00000000}, 271 - {0x880, 0xb0000c1c}, {0x884, 0x00000001}, 272 - {0x888, 0x00000000}, {0x88c, 0xccc000c0}, 273 - {0x890, 0x00000800}, {0x894, 0xfffffffe}, 274 - {0x898, 0x40302010}, {0x89c, 0x00706050}, 275 - {0x900, 0x00000000}, {0x904, 0x00000023}, 276 - {0x908, 0x00000000}, {0x90c, 0x81121111}, 277 - {0x910, 0x00000002}, {0x914, 0x00000201}, 278 - {0xa00, 0x00d047c8}, {0xa04, 0x80ff800c}, 279 - {0xa08, 0x8c838300}, {0xa0c, 0x2e7f120f}, 280 - {0xa10, 0x9500bb78}, {0xa14, 0x1114d028}, 281 - {0xa18, 0x00881117}, {0xa1c, 0x89140f00}, 282 - {0xa20, 0x1a1b0000}, {0xa24, 0x090e1317}, 283 - {0xa28, 0x00000204}, {0xa2c, 0x00d30000}, 284 - {0xa70, 0x101fbf00}, {0xa74, 0x00000007}, 285 - {0xa78, 0x00000900}, {0xa7c, 0x225b0606}, 286 - {0xa80, 0x21806490}, {0xb2c, 0x00000000}, 287 - {0xc00, 0x48071d40}, {0xc04, 0x03a05611}, 288 - {0xc08, 0x000000e4}, {0xc0c, 0x6c6c6c6c}, 289 - {0xc10, 0x08800000}, {0xc14, 0x40000100}, 290 - {0xc18, 0x08800000}, {0xc1c, 0x40000100}, 291 - {0xc20, 0x00000000}, {0xc24, 0x00000000}, 292 - {0xc28, 0x00000000}, {0xc2c, 0x00000000}, 293 - {0xc30, 0x69e9ac44}, {0xc34, 0x469652af}, 294 - {0xc38, 0x49795994}, {0xc3c, 0x0a97971c}, 295 - {0xc40, 0x1f7c403f}, {0xc44, 0x000100b7}, 296 - {0xc48, 0xec020107}, {0xc4c, 0x007f037f}, 297 - {0xc50, 0x69553420}, {0xc54, 0x43bc0094}, 298 - {0xc58, 0x00013149}, {0xc5c, 0x00250492}, 299 - {0xc60, 0x00000000}, {0xc64, 0x7112848b}, 300 - {0xc68, 0x47c00bff}, {0xc6c, 0x00000036}, 301 - {0xc70, 0x2c7f000d}, {0xc74, 0x020610db}, 302 - {0xc78, 0x0000001f}, {0xc7c, 0x00b91612}, 303 - {0xc80, 0x390000e4}, {0xc84, 0x20f60000}, 304 - {0xc88, 0x40000100}, {0xc8c, 0x20200000}, 305 - {0xc90, 0x00020e1a}, {0xc94, 0x00000000}, 306 - {0xc98, 0x00020e1a}, {0xc9c, 0x00007f7f}, 307 - {0xca0, 0x00000000}, {0xca4, 0x000300a0}, 308 - {0xca8, 0x00000000}, {0xcac, 0x00000000}, 309 - {0xcb0, 0x00000000}, {0xcb4, 0x00000000}, 310 - {0xcb8, 0x00000000}, {0xcbc, 0x28000000}, 311 - {0xcc0, 0x00000000}, {0xcc4, 0x00000000}, 312 - {0xcc8, 0x00000000}, {0xccc, 0x00000000}, 313 - {0xcd0, 0x00000000}, {0xcd4, 0x00000000}, 314 - {0xcd8, 0x64b22427}, {0xcdc, 0x00766932}, 315 - {0xce0, 0x00222222}, {0xce4, 0x00000000}, 316 - {0xce8, 0x37644302}, {0xcec, 0x2f97d40c}, 317 - {0xd00, 0x00000740}, {0xd04, 0x40020401}, 318 - {0xd08, 0x0000907f}, {0xd0c, 0x20010201}, 319 - {0xd10, 0xa0633333}, {0xd14, 0x3333bc53}, 320 - {0xd18, 0x7a8f5b6f}, {0xd2c, 0xcc979975}, 321 - {0xd30, 0x00000000}, {0xd34, 0x80608000}, 322 - {0xd38, 0x00000000}, {0xd3c, 0x00127353}, 323 - {0xd40, 0x00000000}, {0xd44, 0x00000000}, 324 - {0xd48, 0x00000000}, {0xd4c, 0x00000000}, 325 - {0xd50, 0x6437140a}, {0xd54, 0x00000000}, 326 - {0xd58, 0x00000282}, {0xd5c, 0x30032064}, 327 - {0xd60, 0x4653de68}, {0xd64, 0x04518a3c}, 328 - {0xd68, 0x00002101}, {0xd6c, 0x2a201c16}, 329 - {0xd70, 0x1812362e}, {0xd74, 0x322c2220}, 330 - {0xd78, 0x000e3c24}, {0xe00, 0x2d2d2d2d}, 331 - {0xe04, 0x2d2d2d2d}, {0xe08, 0x0390272d}, 332 - {0xe10, 0x2d2d2d2d}, {0xe14, 0x2d2d2d2d}, 333 - {0xe18, 0x2d2d2d2d}, {0xe1c, 0x2d2d2d2d}, 334 - {0xe28, 0x00000000}, {0xe30, 0x1000dc1f}, 335 - {0xe34, 0x10008c1f}, {0xe38, 0x02140102}, 336 - {0xe3c, 0x681604c2}, {0xe40, 0x01007c00}, 337 - {0xe44, 0x01004800}, {0xe48, 0xfb000000}, 338 - {0xe4c, 0x000028d1}, {0xe50, 0x1000dc1f}, 339 - {0xe54, 0x10008c1f}, {0xe58, 0x02140102}, 340 - {0xe5c, 0x28160d05}, {0xe60, 0x00000008}, 341 - {0xe68, 0x001b2556}, {0xe6c, 0x00c00096}, 342 - {0xe70, 0x00c00096}, {0xe74, 0x01000056}, 343 - {0xe78, 0x01000014}, {0xe7c, 0x01000056}, 344 - {0xe80, 0x01000014}, {0xe84, 0x00c00096}, 345 - {0xe88, 0x01000056}, {0xe8c, 0x00c00096}, 346 - {0xed0, 0x00c00096}, {0xed4, 0x00c00096}, 347 - {0xed8, 0x00c00096}, {0xedc, 0x000000d6}, 348 - {0xee0, 0x000000d6}, {0xeec, 0x01c00016}, 349 - {0xf14, 0x00000003}, {0xf4c, 0x00000000}, 350 - {0xf00, 0x00000300}, 351 - {0x820, 0x01000100}, {0x800, 0x83040000}, 352 380 {0xffff, 0xffffffff}, 353 381 }; 354 382 ··· 448 678 {0xffff, 0xffffffff}, 449 679 }; 450 680 451 - static struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] = { 452 - {0x800, 0x80040000}, {0x804, 0x00000003}, 453 - {0x808, 0x0000fc00}, {0x80c, 0x0000000a}, 454 - {0x810, 0x10001331}, {0x814, 0x020c3d10}, 455 - {0x818, 0x02220385}, {0x81c, 0x00000000}, 456 - {0x820, 0x01000100}, {0x824, 0x00390204}, 457 - {0x828, 0x01000100}, {0x82c, 0x00390204}, 458 - {0x830, 0x32323232}, {0x834, 0x30303030}, 459 - {0x838, 0x30303030}, {0x83c, 0x30303030}, 460 - {0x840, 0x00010000}, {0x844, 0x00010000}, 461 - {0x848, 0x28282828}, {0x84c, 0x28282828}, 462 - {0x850, 0x00000000}, {0x854, 0x00000000}, 463 - {0x858, 0x009a009a}, {0x85c, 0x01000014}, 464 - {0x860, 0x66f60000}, {0x864, 0x061f0000}, 465 - {0x868, 0x30303030}, {0x86c, 0x30303030}, 466 - {0x870, 0x00000000}, {0x874, 0x55004200}, 467 - {0x878, 0x08080808}, {0x87c, 0x00000000}, 468 - {0x880, 0xb0000c1c}, {0x884, 0x00000001}, 469 - {0x888, 0x00000000}, {0x88c, 0xcc0000c0}, 470 - {0x890, 0x00000800}, {0x894, 0xfffffffe}, 471 - {0x898, 0x40302010}, {0x900, 0x00000000}, 472 - {0x904, 0x00000023}, {0x908, 0x00000000}, 473 - {0x90c, 0x81121313}, {0x910, 0x806c0001}, 474 - {0x914, 0x00000001}, {0x918, 0x00000000}, 475 - {0x91c, 0x00010000}, {0x924, 0x00000001}, 476 - {0x928, 0x00000000}, {0x92c, 0x00000000}, 477 - {0x930, 0x00000000}, {0x934, 0x00000000}, 478 - {0x938, 0x00000000}, {0x93c, 0x00000000}, 479 - {0x940, 0x00000000}, {0x944, 0x00000000}, 480 - {0x94c, 0x00000008}, {0xa00, 0x00d0c7c8}, 481 - {0xa04, 0x81ff000c}, {0xa08, 0x8c838300}, 482 - {0xa0c, 0x2e68120f}, {0xa10, 0x95009b78}, 483 - {0xa14, 0x1114d028}, {0xa18, 0x00881117}, 484 - {0xa1c, 0x89140f00}, {0xa20, 0x1a1b0000}, 485 - {0xa24, 0x090e1317}, {0xa28, 0x00000204}, 486 - {0xa2c, 0x00d30000}, {0xa70, 0x101fff00}, 487 - {0xa74, 0x00000007}, {0xa78, 0x00000900}, 488 - {0xa7c, 0x225b0606}, {0xa80, 0x218075b1}, 489 - {0xb38, 0x00000000}, {0xc00, 0x48071d40}, 490 - {0xc04, 0x03a05633}, {0xc08, 0x000000e4}, 491 - {0xc0c, 0x6c6c6c6c}, {0xc10, 0x08800000}, 492 - {0xc14, 0x40000100}, {0xc18, 0x08800000}, 493 - {0xc1c, 0x40000100}, {0xc20, 0x00000000}, 494 - {0xc24, 0x00000000}, {0xc28, 0x00000000}, 495 - {0xc2c, 0x00000000}, {0xc30, 0x69e9ac47}, 496 - {0xc34, 0x469652af}, {0xc38, 0x49795994}, 497 - {0xc3c, 0x0a97971c}, {0xc40, 0x1f7c403f}, 498 - {0xc44, 0x000100b7}, {0xc48, 0xec020107}, 499 - {0xc4c, 0x007f037f}, 500 - #ifdef EXT_PA_8192EU 501 - /* External PA or external LNA */ 502 - {0xc50, 0x00340220}, 503 - #else 504 - {0xc50, 0x00340020}, 505 - #endif 506 - {0xc54, 0x0080801f}, 507 - #ifdef EXT_PA_8192EU 508 - /* External PA or external LNA */ 509 - {0xc58, 0x00000220}, 510 - #else 511 - {0xc58, 0x00000020}, 512 - #endif 513 - {0xc5c, 0x00248492}, {0xc60, 0x00000000}, 514 - {0xc64, 0x7112848b}, {0xc68, 0x47c00bff}, 515 - {0xc6c, 0x00000036}, {0xc70, 0x00000600}, 516 - {0xc74, 0x02013169}, {0xc78, 0x0000001f}, 517 - {0xc7c, 0x00b91612}, 518 - #ifdef EXT_PA_8192EU 519 - /* External PA or external LNA */ 520 - {0xc80, 0x2d4000b5}, 521 - #else 522 - {0xc80, 0x40000100}, 523 - #endif 524 - {0xc84, 0x21f60000}, 525 - #ifdef EXT_PA_8192EU 526 - /* External PA or external LNA */ 527 - {0xc88, 0x2d4000b5}, 528 - #else 529 - {0xc88, 0x40000100}, 530 - #endif 531 - {0xc8c, 0xa0e40000}, {0xc90, 0x00121820}, 532 - {0xc94, 0x00000000}, {0xc98, 0x00121820}, 533 - {0xc9c, 0x00007f7f}, {0xca0, 0x00000000}, 534 - {0xca4, 0x000300a0}, {0xca8, 0x00000000}, 535 - {0xcac, 0x00000000}, {0xcb0, 0x00000000}, 536 - {0xcb4, 0x00000000}, {0xcb8, 0x00000000}, 537 - {0xcbc, 0x28000000}, {0xcc0, 0x00000000}, 538 - {0xcc4, 0x00000000}, {0xcc8, 0x00000000}, 539 - {0xccc, 0x00000000}, {0xcd0, 0x00000000}, 540 - {0xcd4, 0x00000000}, {0xcd8, 0x64b22427}, 541 - {0xcdc, 0x00766932}, {0xce0, 0x00222222}, 542 - {0xce4, 0x00040000}, {0xce8, 0x77644302}, 543 - {0xcec, 0x2f97d40c}, {0xd00, 0x00080740}, 544 - {0xd04, 0x00020403}, {0xd08, 0x0000907f}, 545 - {0xd0c, 0x20010201}, {0xd10, 0xa0633333}, 546 - {0xd14, 0x3333bc43}, {0xd18, 0x7a8f5b6b}, 547 - {0xd1c, 0x0000007f}, {0xd2c, 0xcc979975}, 548 - {0xd30, 0x00000000}, {0xd34, 0x80608000}, 549 - {0xd38, 0x00000000}, {0xd3c, 0x00127353}, 550 - {0xd40, 0x00000000}, {0xd44, 0x00000000}, 551 - {0xd48, 0x00000000}, {0xd4c, 0x00000000}, 552 - {0xd50, 0x6437140a}, {0xd54, 0x00000000}, 553 - {0xd58, 0x00000282}, {0xd5c, 0x30032064}, 554 - {0xd60, 0x4653de68}, {0xd64, 0x04518a3c}, 555 - {0xd68, 0x00002101}, {0xd6c, 0x2a201c16}, 556 - {0xd70, 0x1812362e}, {0xd74, 0x322c2220}, 557 - {0xd78, 0x000e3c24}, {0xd80, 0x01081008}, 558 - {0xd84, 0x00000800}, {0xd88, 0xf0b50000}, 559 - {0xe00, 0x30303030}, {0xe04, 0x30303030}, 560 - {0xe08, 0x03903030}, {0xe10, 0x30303030}, 561 - {0xe14, 0x30303030}, {0xe18, 0x30303030}, 562 - {0xe1c, 0x30303030}, {0xe28, 0x00000000}, 563 - {0xe30, 0x1000dc1f}, {0xe34, 0x10008c1f}, 564 - {0xe38, 0x02140102}, {0xe3c, 0x681604c2}, 565 - {0xe40, 0x01007c00}, {0xe44, 0x01004800}, 566 - {0xe48, 0xfb000000}, {0xe4c, 0x000028d1}, 567 - {0xe50, 0x1000dc1f}, {0xe54, 0x10008c1f}, 568 - {0xe58, 0x02140102}, {0xe5c, 0x28160d05}, 569 - {0xe60, 0x00000008}, {0xe68, 0x0fc05656}, 570 - {0xe6c, 0x03c09696}, {0xe70, 0x03c09696}, 571 - {0xe74, 0x0c005656}, {0xe78, 0x0c005656}, 572 - {0xe7c, 0x0c005656}, {0xe80, 0x0c005656}, 573 - {0xe84, 0x03c09696}, {0xe88, 0x0c005656}, 574 - {0xe8c, 0x03c09696}, {0xed0, 0x03c09696}, 575 - {0xed4, 0x03c09696}, {0xed8, 0x03c09696}, 576 - {0xedc, 0x0000d6d6}, {0xee0, 0x0000d6d6}, 577 - {0xeec, 0x0fc01616}, {0xee4, 0xb0000c1c}, 578 - {0xee8, 0x00000001}, {0xf14, 0x00000003}, 579 - {0xf4c, 0x00000000}, {0xf00, 0x00000300}, 580 - {0xffff, 0xffffffff}, 581 - }; 582 - 583 681 static struct rtl8xxxu_reg32val rtl8xxx_agc_standard_table[] = { 584 682 {0xc78, 0x7b000001}, {0xc78, 0x7b010001}, 585 683 {0xc78, 0x7b020001}, {0xc78, 0x7b030001}, ··· 616 978 {0xffff, 0xffffffff} 617 979 }; 618 980 619 - static struct rtl8xxxu_reg32val rtl8xxx_agc_8723bu_table[] = { 620 - {0xc78, 0xfd000001}, {0xc78, 0xfc010001}, 621 - {0xc78, 0xfb020001}, {0xc78, 0xfa030001}, 622 - {0xc78, 0xf9040001}, {0xc78, 0xf8050001}, 623 - {0xc78, 0xf7060001}, {0xc78, 0xf6070001}, 624 - {0xc78, 0xf5080001}, {0xc78, 0xf4090001}, 625 - {0xc78, 0xf30a0001}, {0xc78, 0xf20b0001}, 626 - {0xc78, 0xf10c0001}, {0xc78, 0xf00d0001}, 627 - {0xc78, 0xef0e0001}, {0xc78, 0xee0f0001}, 628 - {0xc78, 0xed100001}, {0xc78, 0xec110001}, 629 - {0xc78, 0xeb120001}, {0xc78, 0xea130001}, 630 - {0xc78, 0xe9140001}, {0xc78, 0xe8150001}, 631 - {0xc78, 0xe7160001}, {0xc78, 0xe6170001}, 632 - {0xc78, 0xe5180001}, {0xc78, 0xe4190001}, 633 - {0xc78, 0xe31a0001}, {0xc78, 0xa51b0001}, 634 - {0xc78, 0xa41c0001}, {0xc78, 0xa31d0001}, 635 - {0xc78, 0x671e0001}, {0xc78, 0x661f0001}, 636 - {0xc78, 0x65200001}, {0xc78, 0x64210001}, 637 - {0xc78, 0x63220001}, {0xc78, 0x4a230001}, 638 - {0xc78, 0x49240001}, {0xc78, 0x48250001}, 639 - {0xc78, 0x47260001}, {0xc78, 0x46270001}, 640 - {0xc78, 0x45280001}, {0xc78, 0x44290001}, 641 - {0xc78, 0x432a0001}, {0xc78, 0x422b0001}, 642 - {0xc78, 0x292c0001}, {0xc78, 0x282d0001}, 643 - {0xc78, 0x272e0001}, {0xc78, 0x262f0001}, 644 - {0xc78, 0x0a300001}, {0xc78, 0x09310001}, 645 - {0xc78, 0x08320001}, {0xc78, 0x07330001}, 646 - {0xc78, 0x06340001}, {0xc78, 0x05350001}, 647 - {0xc78, 0x04360001}, {0xc78, 0x03370001}, 648 - {0xc78, 0x02380001}, {0xc78, 0x01390001}, 649 - {0xc78, 0x013a0001}, {0xc78, 0x013b0001}, 650 - {0xc78, 0x013c0001}, {0xc78, 0x013d0001}, 651 - {0xc78, 0x013e0001}, {0xc78, 0x013f0001}, 652 - {0xc78, 0xfc400001}, {0xc78, 0xfb410001}, 653 - {0xc78, 0xfa420001}, {0xc78, 0xf9430001}, 654 - {0xc78, 0xf8440001}, {0xc78, 0xf7450001}, 655 - {0xc78, 0xf6460001}, {0xc78, 0xf5470001}, 656 - {0xc78, 0xf4480001}, {0xc78, 0xf3490001}, 657 - {0xc78, 0xf24a0001}, {0xc78, 0xf14b0001}, 658 - {0xc78, 0xf04c0001}, {0xc78, 0xef4d0001}, 659 - {0xc78, 0xee4e0001}, {0xc78, 0xed4f0001}, 660 - {0xc78, 0xec500001}, {0xc78, 0xeb510001}, 661 - {0xc78, 0xea520001}, {0xc78, 0xe9530001}, 662 - {0xc78, 0xe8540001}, {0xc78, 0xe7550001}, 663 - {0xc78, 0xe6560001}, {0xc78, 0xe5570001}, 664 - {0xc78, 0xe4580001}, {0xc78, 0xe3590001}, 665 - {0xc78, 0xa65a0001}, {0xc78, 0xa55b0001}, 666 - {0xc78, 0xa45c0001}, {0xc78, 0xa35d0001}, 667 - {0xc78, 0x675e0001}, {0xc78, 0x665f0001}, 668 - {0xc78, 0x65600001}, {0xc78, 0x64610001}, 669 - {0xc78, 0x63620001}, {0xc78, 0x62630001}, 670 - {0xc78, 0x61640001}, {0xc78, 0x48650001}, 671 - {0xc78, 0x47660001}, {0xc78, 0x46670001}, 672 - {0xc78, 0x45680001}, {0xc78, 0x44690001}, 673 - {0xc78, 0x436a0001}, {0xc78, 0x426b0001}, 674 - {0xc78, 0x286c0001}, {0xc78, 0x276d0001}, 675 - {0xc78, 0x266e0001}, {0xc78, 0x256f0001}, 676 - {0xc78, 0x24700001}, {0xc78, 0x09710001}, 677 - {0xc78, 0x08720001}, {0xc78, 0x07730001}, 678 - {0xc78, 0x06740001}, {0xc78, 0x05750001}, 679 - {0xc78, 0x04760001}, {0xc78, 0x03770001}, 680 - {0xc78, 0x02780001}, {0xc78, 0x01790001}, 681 - {0xc78, 0x017a0001}, {0xc78, 0x017b0001}, 682 - {0xc78, 0x017c0001}, {0xc78, 0x017d0001}, 683 - {0xc78, 0x017e0001}, {0xc78, 0x017f0001}, 684 - {0xc50, 0x69553422}, 685 - {0xc50, 0x69553420}, 686 - {0x824, 0x00390204}, 687 - {0xffff, 0xffffffff} 688 - }; 689 - 690 - static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_std_table[] = { 691 - {0xc78, 0xfb000001}, {0xc78, 0xfb010001}, 692 - {0xc78, 0xfb020001}, {0xc78, 0xfb030001}, 693 - {0xc78, 0xfb040001}, {0xc78, 0xfb050001}, 694 - {0xc78, 0xfa060001}, {0xc78, 0xf9070001}, 695 - {0xc78, 0xf8080001}, {0xc78, 0xf7090001}, 696 - {0xc78, 0xf60a0001}, {0xc78, 0xf50b0001}, 697 - {0xc78, 0xf40c0001}, {0xc78, 0xf30d0001}, 698 - {0xc78, 0xf20e0001}, {0xc78, 0xf10f0001}, 699 - {0xc78, 0xf0100001}, {0xc78, 0xef110001}, 700 - {0xc78, 0xee120001}, {0xc78, 0xed130001}, 701 - {0xc78, 0xec140001}, {0xc78, 0xeb150001}, 702 - {0xc78, 0xea160001}, {0xc78, 0xe9170001}, 703 - {0xc78, 0xe8180001}, {0xc78, 0xe7190001}, 704 - {0xc78, 0xc81a0001}, {0xc78, 0xc71b0001}, 705 - {0xc78, 0xc61c0001}, {0xc78, 0x071d0001}, 706 - {0xc78, 0x061e0001}, {0xc78, 0x051f0001}, 707 - {0xc78, 0x04200001}, {0xc78, 0x03210001}, 708 - {0xc78, 0xaa220001}, {0xc78, 0xa9230001}, 709 - {0xc78, 0xa8240001}, {0xc78, 0xa7250001}, 710 - {0xc78, 0xa6260001}, {0xc78, 0x85270001}, 711 - {0xc78, 0x84280001}, {0xc78, 0x83290001}, 712 - {0xc78, 0x252a0001}, {0xc78, 0x242b0001}, 713 - {0xc78, 0x232c0001}, {0xc78, 0x222d0001}, 714 - {0xc78, 0x672e0001}, {0xc78, 0x662f0001}, 715 - {0xc78, 0x65300001}, {0xc78, 0x64310001}, 716 - {0xc78, 0x63320001}, {0xc78, 0x62330001}, 717 - {0xc78, 0x61340001}, {0xc78, 0x45350001}, 718 - {0xc78, 0x44360001}, {0xc78, 0x43370001}, 719 - {0xc78, 0x42380001}, {0xc78, 0x41390001}, 720 - {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 721 - {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 722 - {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 723 - {0xc78, 0xfb400001}, {0xc78, 0xfb410001}, 724 - {0xc78, 0xfb420001}, {0xc78, 0xfb430001}, 725 - {0xc78, 0xfb440001}, {0xc78, 0xfb450001}, 726 - {0xc78, 0xfa460001}, {0xc78, 0xf9470001}, 727 - {0xc78, 0xf8480001}, {0xc78, 0xf7490001}, 728 - {0xc78, 0xf64a0001}, {0xc78, 0xf54b0001}, 729 - {0xc78, 0xf44c0001}, {0xc78, 0xf34d0001}, 730 - {0xc78, 0xf24e0001}, {0xc78, 0xf14f0001}, 731 - {0xc78, 0xf0500001}, {0xc78, 0xef510001}, 732 - {0xc78, 0xee520001}, {0xc78, 0xed530001}, 733 - {0xc78, 0xec540001}, {0xc78, 0xeb550001}, 734 - {0xc78, 0xea560001}, {0xc78, 0xe9570001}, 735 - {0xc78, 0xe8580001}, {0xc78, 0xe7590001}, 736 - {0xc78, 0xe65a0001}, {0xc78, 0xe55b0001}, 737 - {0xc78, 0xe45c0001}, {0xc78, 0xe35d0001}, 738 - {0xc78, 0xe25e0001}, {0xc78, 0xe15f0001}, 739 - {0xc78, 0x8a600001}, {0xc78, 0x89610001}, 740 - {0xc78, 0x88620001}, {0xc78, 0x87630001}, 741 - {0xc78, 0x86640001}, {0xc78, 0x85650001}, 742 - {0xc78, 0x84660001}, {0xc78, 0x83670001}, 743 - {0xc78, 0x82680001}, {0xc78, 0x6b690001}, 744 - {0xc78, 0x6a6a0001}, {0xc78, 0x696b0001}, 745 - {0xc78, 0x686c0001}, {0xc78, 0x676d0001}, 746 - {0xc78, 0x666e0001}, {0xc78, 0x656f0001}, 747 - {0xc78, 0x64700001}, {0xc78, 0x63710001}, 748 - {0xc78, 0x62720001}, {0xc78, 0x61730001}, 749 - {0xc78, 0x49740001}, {0xc78, 0x48750001}, 750 - {0xc78, 0x47760001}, {0xc78, 0x46770001}, 751 - {0xc78, 0x45780001}, {0xc78, 0x44790001}, 752 - {0xc78, 0x437a0001}, {0xc78, 0x427b0001}, 753 - {0xc78, 0x417c0001}, {0xc78, 0x407d0001}, 754 - {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 755 - {0xc50, 0x00040022}, {0xc50, 0x00040020}, 756 - {0xffff, 0xffffffff} 757 - }; 758 - 759 - static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_highpa_table[] = { 760 - {0xc78, 0xfa000001}, {0xc78, 0xf9010001}, 761 - {0xc78, 0xf8020001}, {0xc78, 0xf7030001}, 762 - {0xc78, 0xf6040001}, {0xc78, 0xf5050001}, 763 - {0xc78, 0xf4060001}, {0xc78, 0xf3070001}, 764 - {0xc78, 0xf2080001}, {0xc78, 0xf1090001}, 765 - {0xc78, 0xf00a0001}, {0xc78, 0xef0b0001}, 766 - {0xc78, 0xee0c0001}, {0xc78, 0xed0d0001}, 767 - {0xc78, 0xec0e0001}, {0xc78, 0xeb0f0001}, 768 - {0xc78, 0xea100001}, {0xc78, 0xe9110001}, 769 - {0xc78, 0xe8120001}, {0xc78, 0xe7130001}, 770 - {0xc78, 0xe6140001}, {0xc78, 0xe5150001}, 771 - {0xc78, 0xe4160001}, {0xc78, 0xe3170001}, 772 - {0xc78, 0xe2180001}, {0xc78, 0xe1190001}, 773 - {0xc78, 0x8a1a0001}, {0xc78, 0x891b0001}, 774 - {0xc78, 0x881c0001}, {0xc78, 0x871d0001}, 775 - {0xc78, 0x861e0001}, {0xc78, 0x851f0001}, 776 - {0xc78, 0x84200001}, {0xc78, 0x83210001}, 777 - {0xc78, 0x82220001}, {0xc78, 0x6a230001}, 778 - {0xc78, 0x69240001}, {0xc78, 0x68250001}, 779 - {0xc78, 0x67260001}, {0xc78, 0x66270001}, 780 - {0xc78, 0x65280001}, {0xc78, 0x64290001}, 781 - {0xc78, 0x632a0001}, {0xc78, 0x622b0001}, 782 - {0xc78, 0x612c0001}, {0xc78, 0x602d0001}, 783 - {0xc78, 0x472e0001}, {0xc78, 0x462f0001}, 784 - {0xc78, 0x45300001}, {0xc78, 0x44310001}, 785 - {0xc78, 0x43320001}, {0xc78, 0x42330001}, 786 - {0xc78, 0x41340001}, {0xc78, 0x40350001}, 787 - {0xc78, 0x40360001}, {0xc78, 0x40370001}, 788 - {0xc78, 0x40380001}, {0xc78, 0x40390001}, 789 - {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 790 - {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 791 - {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 792 - {0xc78, 0xfa400001}, {0xc78, 0xf9410001}, 793 - {0xc78, 0xf8420001}, {0xc78, 0xf7430001}, 794 - {0xc78, 0xf6440001}, {0xc78, 0xf5450001}, 795 - {0xc78, 0xf4460001}, {0xc78, 0xf3470001}, 796 - {0xc78, 0xf2480001}, {0xc78, 0xf1490001}, 797 - {0xc78, 0xf04a0001}, {0xc78, 0xef4b0001}, 798 - {0xc78, 0xee4c0001}, {0xc78, 0xed4d0001}, 799 - {0xc78, 0xec4e0001}, {0xc78, 0xeb4f0001}, 800 - {0xc78, 0xea500001}, {0xc78, 0xe9510001}, 801 - {0xc78, 0xe8520001}, {0xc78, 0xe7530001}, 802 - {0xc78, 0xe6540001}, {0xc78, 0xe5550001}, 803 - {0xc78, 0xe4560001}, {0xc78, 0xe3570001}, 804 - {0xc78, 0xe2580001}, {0xc78, 0xe1590001}, 805 - {0xc78, 0x8a5a0001}, {0xc78, 0x895b0001}, 806 - {0xc78, 0x885c0001}, {0xc78, 0x875d0001}, 807 - {0xc78, 0x865e0001}, {0xc78, 0x855f0001}, 808 - {0xc78, 0x84600001}, {0xc78, 0x83610001}, 809 - {0xc78, 0x82620001}, {0xc78, 0x6a630001}, 810 - {0xc78, 0x69640001}, {0xc78, 0x68650001}, 811 - {0xc78, 0x67660001}, {0xc78, 0x66670001}, 812 - {0xc78, 0x65680001}, {0xc78, 0x64690001}, 813 - {0xc78, 0x636a0001}, {0xc78, 0x626b0001}, 814 - {0xc78, 0x616c0001}, {0xc78, 0x606d0001}, 815 - {0xc78, 0x476e0001}, {0xc78, 0x466f0001}, 816 - {0xc78, 0x45700001}, {0xc78, 0x44710001}, 817 - {0xc78, 0x43720001}, {0xc78, 0x42730001}, 818 - {0xc78, 0x41740001}, {0xc78, 0x40750001}, 819 - {0xc78, 0x40760001}, {0xc78, 0x40770001}, 820 - {0xc78, 0x40780001}, {0xc78, 0x40790001}, 821 - {0xc78, 0x407a0001}, {0xc78, 0x407b0001}, 822 - {0xc78, 0x407c0001}, {0xc78, 0x407d0001}, 823 - {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 824 - {0xc50, 0x00040222}, {0xc50, 0x00040220}, 825 - {0xffff, 0xffffffff} 826 - }; 827 - 828 - static struct rtl8xxxu_rfregval rtl8723au_radioa_1t_init_table[] = { 829 - {0x00, 0x00030159}, {0x01, 0x00031284}, 830 - {0x02, 0x00098000}, {0x03, 0x00039c63}, 831 - {0x04, 0x000210e7}, {0x09, 0x0002044f}, 832 - {0x0a, 0x0001a3f1}, {0x0b, 0x00014787}, 833 - {0x0c, 0x000896fe}, {0x0d, 0x0000e02c}, 834 - {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 835 - {0x19, 0x00000000}, {0x1a, 0x00030355}, 836 - {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 837 - {0x1d, 0x000a1250}, {0x1e, 0x0000024f}, 838 - {0x1f, 0x00000000}, {0x20, 0x0000b614}, 839 - {0x21, 0x0006c000}, {0x22, 0x00000000}, 840 - {0x23, 0x00001558}, {0x24, 0x00000060}, 841 - {0x25, 0x00000483}, {0x26, 0x0004f000}, 842 - {0x27, 0x000ec7d9}, {0x28, 0x00057730}, 843 - {0x29, 0x00004783}, {0x2a, 0x00000001}, 844 - {0x2b, 0x00021334}, {0x2a, 0x00000000}, 845 - {0x2b, 0x00000054}, {0x2a, 0x00000001}, 846 - {0x2b, 0x00000808}, {0x2b, 0x00053333}, 847 - {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 848 - {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 849 - {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 850 - {0x2b, 0x00000808}, {0x2b, 0x00063333}, 851 - {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 852 - {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 853 - {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 854 - {0x2b, 0x00000808}, {0x2b, 0x00073333}, 855 - {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 856 - {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 857 - {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 858 - {0x2b, 0x00000709}, {0x2b, 0x00063333}, 859 - {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 860 - {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 861 - {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 862 - {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 863 - {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 864 - {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 865 - {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 866 - {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 867 - {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 868 - {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 869 - {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 870 - {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 871 - {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 872 - {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 873 - {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 874 - {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 875 - {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 876 - {0x10, 0x0002000f}, {0x11, 0x000203f9}, 877 - {0x10, 0x0003000f}, {0x11, 0x000ff500}, 878 - {0x10, 0x00000000}, {0x11, 0x00000000}, 879 - {0x10, 0x0008000f}, {0x11, 0x0003f100}, 880 - {0x10, 0x0009000f}, {0x11, 0x00023100}, 881 - {0x12, 0x00032000}, {0x12, 0x00071000}, 882 - {0x12, 0x000b0000}, {0x12, 0x000fc000}, 883 - {0x13, 0x000287b3}, {0x13, 0x000244b7}, 884 - {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 885 - {0x13, 0x00018493}, {0x13, 0x0001429b}, 886 - {0x13, 0x00010299}, {0x13, 0x0000c29c}, 887 - {0x13, 0x000081a0}, {0x13, 0x000040ac}, 888 - {0x13, 0x00000020}, {0x14, 0x0001944c}, 889 - {0x14, 0x00059444}, {0x14, 0x0009944c}, 890 - {0x14, 0x000d9444}, {0x15, 0x0000f474}, 891 - {0x15, 0x0004f477}, {0x15, 0x0008f455}, 892 - {0x15, 0x000cf455}, {0x16, 0x00000339}, 893 - {0x16, 0x00040339}, {0x16, 0x00080339}, 894 - {0x16, 0x000c0366}, {0x00, 0x00010159}, 895 - {0x18, 0x0000f401}, {0xfe, 0x00000000}, 896 - {0xfe, 0x00000000}, {0x1f, 0x00000003}, 897 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 898 - {0x1e, 0x00000247}, {0x1f, 0x00000000}, 899 - {0x00, 0x00030159}, 900 - {0xff, 0xffffffff} 901 - }; 902 - 903 - static struct rtl8xxxu_rfregval rtl8723bu_radioa_1t_init_table[] = { 904 - {0x00, 0x00010000}, {0xb0, 0x000dffe0}, 905 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 906 - {0xfe, 0x00000000}, {0xb1, 0x00000018}, 907 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 908 - {0xfe, 0x00000000}, {0xb2, 0x00084c00}, 909 - {0xb5, 0x0000d2cc}, {0xb6, 0x000925aa}, 910 - {0xb7, 0x00000010}, {0xb8, 0x0000907f}, 911 - {0x5c, 0x00000002}, {0x7c, 0x00000002}, 912 - {0x7e, 0x00000005}, {0x8b, 0x0006fc00}, 913 - {0xb0, 0x000ff9f0}, {0x1c, 0x000739d2}, 914 - {0x1e, 0x00000000}, {0xdf, 0x00000780}, 915 - {0x50, 0x00067435}, 916 - /* 917 - * The 8723bu vendor driver indicates that bit 8 should be set in 918 - * 0x51 for package types TFBGA90, TFBGA80, and TFBGA79. However 919 - * they never actually check the package type - and just default 920 - * to not setting it. 921 - */ 922 - {0x51, 0x0006b04e}, 923 - {0x52, 0x000007d2}, {0x53, 0x00000000}, 924 - {0x54, 0x00050400}, {0x55, 0x0004026e}, 925 - {0xdd, 0x0000004c}, {0x70, 0x00067435}, 926 - /* 927 - * 0x71 has same package type condition as for register 0x51 928 - */ 929 - {0x71, 0x0006b04e}, 930 - {0x72, 0x000007d2}, {0x73, 0x00000000}, 931 - {0x74, 0x00050400}, {0x75, 0x0004026e}, 932 - {0xef, 0x00000100}, {0x34, 0x0000add7}, 933 - {0x35, 0x00005c00}, {0x34, 0x00009dd4}, 934 - {0x35, 0x00005000}, {0x34, 0x00008dd1}, 935 - {0x35, 0x00004400}, {0x34, 0x00007dce}, 936 - {0x35, 0x00003800}, {0x34, 0x00006cd1}, 937 - {0x35, 0x00004400}, {0x34, 0x00005cce}, 938 - {0x35, 0x00003800}, {0x34, 0x000048ce}, 939 - {0x35, 0x00004400}, {0x34, 0x000034ce}, 940 - {0x35, 0x00003800}, {0x34, 0x00002451}, 941 - {0x35, 0x00004400}, {0x34, 0x0000144e}, 942 - {0x35, 0x00003800}, {0x34, 0x00000051}, 943 - {0x35, 0x00004400}, {0xef, 0x00000000}, 944 - {0xef, 0x00000100}, {0xed, 0x00000010}, 945 - {0x44, 0x0000add7}, {0x44, 0x00009dd4}, 946 - {0x44, 0x00008dd1}, {0x44, 0x00007dce}, 947 - {0x44, 0x00006cc1}, {0x44, 0x00005cce}, 948 - {0x44, 0x000044d1}, {0x44, 0x000034ce}, 949 - {0x44, 0x00002451}, {0x44, 0x0000144e}, 950 - {0x44, 0x00000051}, {0xef, 0x00000000}, 951 - {0xed, 0x00000000}, {0x7f, 0x00020080}, 952 - {0xef, 0x00002000}, {0x3b, 0x000380ef}, 953 - {0x3b, 0x000302fe}, {0x3b, 0x00028ce6}, 954 - {0x3b, 0x000200bc}, {0x3b, 0x000188a5}, 955 - {0x3b, 0x00010fbc}, {0x3b, 0x00008f71}, 956 - {0x3b, 0x00000900}, {0xef, 0x00000000}, 957 - {0xed, 0x00000001}, {0x40, 0x000380ef}, 958 - {0x40, 0x000302fe}, {0x40, 0x00028ce6}, 959 - {0x40, 0x000200bc}, {0x40, 0x000188a5}, 960 - {0x40, 0x00010fbc}, {0x40, 0x00008f71}, 961 - {0x40, 0x00000900}, {0xed, 0x00000000}, 962 - {0x82, 0x00080000}, {0x83, 0x00008000}, 963 - {0x84, 0x00048d80}, {0x85, 0x00068000}, 964 - {0xa2, 0x00080000}, {0xa3, 0x00008000}, 965 - {0xa4, 0x00048d80}, {0xa5, 0x00068000}, 966 - {0xed, 0x00000002}, {0xef, 0x00000002}, 967 - {0x56, 0x00000032}, {0x76, 0x00000032}, 968 - {0x01, 0x00000780}, 969 - {0xff, 0xffffffff} 970 - }; 971 - 972 - #ifdef CONFIG_RTL8XXXU_UNTESTED 973 - static struct rtl8xxxu_rfregval rtl8192cu_radioa_2t_init_table[] = { 974 - {0x00, 0x00030159}, {0x01, 0x00031284}, 975 - {0x02, 0x00098000}, {0x03, 0x00018c63}, 976 - {0x04, 0x000210e7}, {0x09, 0x0002044f}, 977 - {0x0a, 0x0001adb1}, {0x0b, 0x00054867}, 978 - {0x0c, 0x0008992e}, {0x0d, 0x0000e52c}, 979 - {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 980 - {0x19, 0x00000000}, {0x1a, 0x00010255}, 981 - {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 982 - {0x1d, 0x000a1250}, {0x1e, 0x0004445f}, 983 - {0x1f, 0x00080001}, {0x20, 0x0000b614}, 984 - {0x21, 0x0006c000}, {0x22, 0x00000000}, 985 - {0x23, 0x00001558}, {0x24, 0x00000060}, 986 - {0x25, 0x00000483}, {0x26, 0x0004f000}, 987 - {0x27, 0x000ec7d9}, {0x28, 0x000577c0}, 988 - {0x29, 0x00004783}, {0x2a, 0x00000001}, 989 - {0x2b, 0x00021334}, {0x2a, 0x00000000}, 990 - {0x2b, 0x00000054}, {0x2a, 0x00000001}, 991 - {0x2b, 0x00000808}, {0x2b, 0x00053333}, 992 - {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 993 - {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 994 - {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 995 - {0x2b, 0x00000808}, {0x2b, 0x00063333}, 996 - {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 997 - {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 998 - {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 999 - {0x2b, 0x00000808}, {0x2b, 0x00073333}, 1000 - {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 1001 - {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 1002 - {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 1003 - {0x2b, 0x00000709}, {0x2b, 0x00063333}, 1004 - {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 1005 - {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 1006 - {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 1007 - {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 1008 - {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 1009 - {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 1010 - {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 1011 - {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 1012 - {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 1013 - {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 1014 - {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 1015 - {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 1016 - {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 1017 - {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 1018 - {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 1019 - {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 1020 - {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 1021 - {0x10, 0x0002000f}, {0x11, 0x000203f9}, 1022 - {0x10, 0x0003000f}, {0x11, 0x000ff500}, 1023 - {0x10, 0x00000000}, {0x11, 0x00000000}, 1024 - {0x10, 0x0008000f}, {0x11, 0x0003f100}, 1025 - {0x10, 0x0009000f}, {0x11, 0x00023100}, 1026 - {0x12, 0x00032000}, {0x12, 0x00071000}, 1027 - {0x12, 0x000b0000}, {0x12, 0x000fc000}, 1028 - {0x13, 0x000287b3}, {0x13, 0x000244b7}, 1029 - {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 1030 - {0x13, 0x00018493}, {0x13, 0x0001429b}, 1031 - {0x13, 0x00010299}, {0x13, 0x0000c29c}, 1032 - {0x13, 0x000081a0}, {0x13, 0x000040ac}, 1033 - {0x13, 0x00000020}, {0x14, 0x0001944c}, 1034 - {0x14, 0x00059444}, {0x14, 0x0009944c}, 1035 - {0x14, 0x000d9444}, {0x15, 0x0000f424}, 1036 - {0x15, 0x0004f424}, {0x15, 0x0008f424}, 1037 - {0x15, 0x000cf424}, {0x16, 0x000e0330}, 1038 - {0x16, 0x000a0330}, {0x16, 0x00060330}, 1039 - {0x16, 0x00020330}, {0x00, 0x00010159}, 1040 - {0x18, 0x0000f401}, {0xfe, 0x00000000}, 1041 - {0xfe, 0x00000000}, {0x1f, 0x00080003}, 1042 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1043 - {0x1e, 0x00044457}, {0x1f, 0x00080000}, 1044 - {0x00, 0x00030159}, 1045 - {0xff, 0xffffffff} 1046 - }; 1047 - 1048 - static struct rtl8xxxu_rfregval rtl8192cu_radiob_2t_init_table[] = { 1049 - {0x00, 0x00030159}, {0x01, 0x00031284}, 1050 - {0x02, 0x00098000}, {0x03, 0x00018c63}, 1051 - {0x04, 0x000210e7}, {0x09, 0x0002044f}, 1052 - {0x0a, 0x0001adb1}, {0x0b, 0x00054867}, 1053 - {0x0c, 0x0008992e}, {0x0d, 0x0000e52c}, 1054 - {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 1055 - {0x12, 0x00032000}, {0x12, 0x00071000}, 1056 - {0x12, 0x000b0000}, {0x12, 0x000fc000}, 1057 - {0x13, 0x000287af}, {0x13, 0x000244b7}, 1058 - {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 1059 - {0x13, 0x00018493}, {0x13, 0x00014297}, 1060 - {0x13, 0x00010295}, {0x13, 0x0000c298}, 1061 - {0x13, 0x0000819c}, {0x13, 0x000040a8}, 1062 - {0x13, 0x0000001c}, {0x14, 0x0001944c}, 1063 - {0x14, 0x00059444}, {0x14, 0x0009944c}, 1064 - {0x14, 0x000d9444}, {0x15, 0x0000f424}, 1065 - {0x15, 0x0004f424}, {0x15, 0x0008f424}, 1066 - {0x15, 0x000cf424}, {0x16, 0x000e0330}, 1067 - {0x16, 0x000a0330}, {0x16, 0x00060330}, 1068 - {0x16, 0x00020330}, 1069 - {0xff, 0xffffffff} 1070 - }; 1071 - 1072 - static struct rtl8xxxu_rfregval rtl8192cu_radioa_1t_init_table[] = { 1073 - {0x00, 0x00030159}, {0x01, 0x00031284}, 1074 - {0x02, 0x00098000}, {0x03, 0x00018c63}, 1075 - {0x04, 0x000210e7}, {0x09, 0x0002044f}, 1076 - {0x0a, 0x0001adb1}, {0x0b, 0x00054867}, 1077 - {0x0c, 0x0008992e}, {0x0d, 0x0000e52c}, 1078 - {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 1079 - {0x19, 0x00000000}, {0x1a, 0x00010255}, 1080 - {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 1081 - {0x1d, 0x000a1250}, {0x1e, 0x0004445f}, 1082 - {0x1f, 0x00080001}, {0x20, 0x0000b614}, 1083 - {0x21, 0x0006c000}, {0x22, 0x00000000}, 1084 - {0x23, 0x00001558}, {0x24, 0x00000060}, 1085 - {0x25, 0x00000483}, {0x26, 0x0004f000}, 1086 - {0x27, 0x000ec7d9}, {0x28, 0x000577c0}, 1087 - {0x29, 0x00004783}, {0x2a, 0x00000001}, 1088 - {0x2b, 0x00021334}, {0x2a, 0x00000000}, 1089 - {0x2b, 0x00000054}, {0x2a, 0x00000001}, 1090 - {0x2b, 0x00000808}, {0x2b, 0x00053333}, 1091 - {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 1092 - {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 1093 - {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 1094 - {0x2b, 0x00000808}, {0x2b, 0x00063333}, 1095 - {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 1096 - {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 1097 - {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 1098 - {0x2b, 0x00000808}, {0x2b, 0x00073333}, 1099 - {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 1100 - {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 1101 - {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 1102 - {0x2b, 0x00000709}, {0x2b, 0x00063333}, 1103 - {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 1104 - {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 1105 - {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 1106 - {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 1107 - {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 1108 - {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 1109 - {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 1110 - {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 1111 - {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 1112 - {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 1113 - {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 1114 - {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 1115 - {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 1116 - {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 1117 - {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 1118 - {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 1119 - {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 1120 - {0x10, 0x0002000f}, {0x11, 0x000203f9}, 1121 - {0x10, 0x0003000f}, {0x11, 0x000ff500}, 1122 - {0x10, 0x00000000}, {0x11, 0x00000000}, 1123 - {0x10, 0x0008000f}, {0x11, 0x0003f100}, 1124 - {0x10, 0x0009000f}, {0x11, 0x00023100}, 1125 - {0x12, 0x00032000}, {0x12, 0x00071000}, 1126 - {0x12, 0x000b0000}, {0x12, 0x000fc000}, 1127 - {0x13, 0x000287b3}, {0x13, 0x000244b7}, 1128 - {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 1129 - {0x13, 0x00018493}, {0x13, 0x0001429b}, 1130 - {0x13, 0x00010299}, {0x13, 0x0000c29c}, 1131 - {0x13, 0x000081a0}, {0x13, 0x000040ac}, 1132 - {0x13, 0x00000020}, {0x14, 0x0001944c}, 1133 - {0x14, 0x00059444}, {0x14, 0x0009944c}, 1134 - {0x14, 0x000d9444}, {0x15, 0x0000f405}, 1135 - {0x15, 0x0004f405}, {0x15, 0x0008f405}, 1136 - {0x15, 0x000cf405}, {0x16, 0x000e0330}, 1137 - {0x16, 0x000a0330}, {0x16, 0x00060330}, 1138 - {0x16, 0x00020330}, {0x00, 0x00010159}, 1139 - {0x18, 0x0000f401}, {0xfe, 0x00000000}, 1140 - {0xfe, 0x00000000}, {0x1f, 0x00080003}, 1141 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1142 - {0x1e, 0x00044457}, {0x1f, 0x00080000}, 1143 - {0x00, 0x00030159}, 1144 - {0xff, 0xffffffff} 1145 - }; 1146 - 1147 - static struct rtl8xxxu_rfregval rtl8188ru_radioa_1t_highpa_table[] = { 1148 - {0x00, 0x00030159}, {0x01, 0x00031284}, 1149 - {0x02, 0x00098000}, {0x03, 0x00018c63}, 1150 - {0x04, 0x000210e7}, {0x09, 0x0002044f}, 1151 - {0x0a, 0x0001adb0}, {0x0b, 0x00054867}, 1152 - {0x0c, 0x0008992e}, {0x0d, 0x0000e529}, 1153 - {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 1154 - {0x19, 0x00000000}, {0x1a, 0x00000255}, 1155 - {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 1156 - {0x1d, 0x000a1250}, {0x1e, 0x0004445f}, 1157 - {0x1f, 0x00080001}, {0x20, 0x0000b614}, 1158 - {0x21, 0x0006c000}, {0x22, 0x0000083c}, 1159 - {0x23, 0x00001558}, {0x24, 0x00000060}, 1160 - {0x25, 0x00000483}, {0x26, 0x0004f000}, 1161 - {0x27, 0x000ec7d9}, {0x28, 0x000977c0}, 1162 - {0x29, 0x00004783}, {0x2a, 0x00000001}, 1163 - {0x2b, 0x00021334}, {0x2a, 0x00000000}, 1164 - {0x2b, 0x00000054}, {0x2a, 0x00000001}, 1165 - {0x2b, 0x00000808}, {0x2b, 0x00053333}, 1166 - {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 1167 - {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 1168 - {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 1169 - {0x2b, 0x00000808}, {0x2b, 0x00063333}, 1170 - {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 1171 - {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 1172 - {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 1173 - {0x2b, 0x00000808}, {0x2b, 0x00073333}, 1174 - {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 1175 - {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 1176 - {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 1177 - {0x2b, 0x00000709}, {0x2b, 0x00063333}, 1178 - {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 1179 - {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 1180 - {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 1181 - {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 1182 - {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 1183 - {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 1184 - {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 1185 - {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 1186 - {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 1187 - {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 1188 - {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 1189 - {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 1190 - {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 1191 - {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 1192 - {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 1193 - {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 1194 - {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 1195 - {0x10, 0x0002000f}, {0x11, 0x000203f9}, 1196 - {0x10, 0x0003000f}, {0x11, 0x000ff500}, 1197 - {0x10, 0x00000000}, {0x11, 0x00000000}, 1198 - {0x10, 0x0008000f}, {0x11, 0x0003f100}, 1199 - {0x10, 0x0009000f}, {0x11, 0x00023100}, 1200 - {0x12, 0x000d8000}, {0x12, 0x00090000}, 1201 - {0x12, 0x00051000}, {0x12, 0x00012000}, 1202 - {0x13, 0x00028fb4}, {0x13, 0x00024fa8}, 1203 - {0x13, 0x000207a4}, {0x13, 0x0001c3b0}, 1204 - {0x13, 0x000183a4}, {0x13, 0x00014398}, 1205 - {0x13, 0x000101a4}, {0x13, 0x0000c198}, 1206 - {0x13, 0x000080a4}, {0x13, 0x00004098}, 1207 - {0x13, 0x00000000}, {0x14, 0x0001944c}, 1208 - {0x14, 0x00059444}, {0x14, 0x0009944c}, 1209 - {0x14, 0x000d9444}, {0x15, 0x0000f405}, 1210 - {0x15, 0x0004f405}, {0x15, 0x0008f405}, 1211 - {0x15, 0x000cf405}, {0x16, 0x000e0330}, 1212 - {0x16, 0x000a0330}, {0x16, 0x00060330}, 1213 - {0x16, 0x00020330}, {0x00, 0x00010159}, 1214 - {0x18, 0x0000f401}, {0xfe, 0x00000000}, 1215 - {0xfe, 0x00000000}, {0x1f, 0x00080003}, 1216 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1217 - {0x1e, 0x00044457}, {0x1f, 0x00080000}, 1218 - {0x00, 0x00030159}, 1219 - {0xff, 0xffffffff} 1220 - }; 1221 - #endif 1222 - 1223 - static struct rtl8xxxu_rfregval rtl8192eu_radioa_init_table[] = { 1224 - {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 1225 - {0x00, 0x00030000}, {0x08, 0x00008400}, 1226 - {0x18, 0x00000407}, {0x19, 0x00000012}, 1227 - {0x1b, 0x00000064}, {0x1e, 0x00080009}, 1228 - {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 1229 - {0x3f, 0x00000000}, {0x42, 0x000060c0}, 1230 - {0x57, 0x000d0000}, {0x58, 0x000be180}, 1231 - {0x67, 0x00001552}, {0x83, 0x00000000}, 1232 - {0xb0, 0x000ff9f1}, {0xb1, 0x00055418}, 1233 - {0xb2, 0x0008cc00}, {0xb4, 0x00043083}, 1234 - {0xb5, 0x00008166}, {0xb6, 0x0000803e}, 1235 - {0xb7, 0x0001c69f}, {0xb8, 0x0000407f}, 1236 - {0xb9, 0x00080001}, {0xba, 0x00040001}, 1237 - {0xbb, 0x00000400}, {0xbf, 0x000c0000}, 1238 - {0xc2, 0x00002400}, {0xc3, 0x00000009}, 1239 - {0xc4, 0x00040c91}, {0xc5, 0x00099999}, 1240 - {0xc6, 0x000000a3}, {0xc7, 0x00088820}, 1241 - {0xc8, 0x00076c06}, {0xc9, 0x00000000}, 1242 - {0xca, 0x00080000}, {0xdf, 0x00000180}, 1243 - {0xef, 0x000001a0}, {0x51, 0x00069545}, 1244 - {0x52, 0x0007e45e}, {0x53, 0x00000071}, 1245 - {0x56, 0x00051ff3}, {0x35, 0x000000a8}, 1246 - {0x35, 0x000001e2}, {0x35, 0x000002a8}, 1247 - {0x36, 0x00001c24}, {0x36, 0x00009c24}, 1248 - {0x36, 0x00011c24}, {0x36, 0x00019c24}, 1249 - {0x18, 0x00000c07}, {0x5a, 0x00048000}, 1250 - {0x19, 0x000739d0}, 1251 - #ifdef EXT_PA_8192EU 1252 - /* External PA or external LNA */ 1253 - {0x34, 0x0000a093}, {0x34, 0x0000908f}, 1254 - {0x34, 0x0000808c}, {0x34, 0x0000704d}, 1255 - {0x34, 0x0000604a}, {0x34, 0x00005047}, 1256 - {0x34, 0x0000400a}, {0x34, 0x00003007}, 1257 - {0x34, 0x00002004}, {0x34, 0x00001001}, 1258 - {0x34, 0x00000000}, 1259 - #else 1260 - /* Regular */ 1261 - {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 1262 - {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 1263 - {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 1264 - {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 1265 - {0x34, 0x0000244f}, {0x34, 0x0000144c}, 1266 - {0x34, 0x00000014}, 1267 - #endif 1268 - {0x00, 0x00030159}, 1269 - {0x84, 0x00068180}, 1270 - {0x86, 0x0000014e}, 1271 - {0x87, 0x00048e00}, 1272 - {0x8e, 0x00065540}, 1273 - {0x8f, 0x00088000}, 1274 - {0xef, 0x000020a0}, 1275 - #ifdef EXT_PA_8192EU 1276 - /* External PA or external LNA */ 1277 - {0x3b, 0x000f07b0}, 1278 - #else 1279 - {0x3b, 0x000f02b0}, 1280 - #endif 1281 - {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 1282 - {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 1283 - {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 1284 - {0x3b, 0x0008f780}, 1285 - #ifdef EXT_PA_8192EU 1286 - /* External PA or external LNA */ 1287 - {0x3b, 0x000787b0}, 1288 - #else 1289 - {0x3b, 0x00078730}, 1290 - #endif 1291 - {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 1292 - {0x3b, 0x00040620}, {0x3b, 0x00037090}, 1293 - {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 1294 - {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 1295 - {0xfe, 0x00000000}, {0x18, 0x0000fc07}, 1296 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1297 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1298 - {0x1e, 0x00000001}, {0x1f, 0x00080000}, 1299 - {0x00, 0x00033e70}, 1300 - {0xff, 0xffffffff} 1301 - }; 1302 - 1303 - static struct rtl8xxxu_rfregval rtl8192eu_radiob_init_table[] = { 1304 - {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 1305 - {0x00, 0x00030000}, {0x08, 0x00008400}, 1306 - {0x18, 0x00000407}, {0x19, 0x00000012}, 1307 - {0x1b, 0x00000064}, {0x1e, 0x00080009}, 1308 - {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 1309 - {0x3f, 0x00000000}, {0x42, 0x000060c0}, 1310 - {0x57, 0x000d0000}, {0x58, 0x000be180}, 1311 - {0x67, 0x00001552}, {0x7f, 0x00000082}, 1312 - {0x81, 0x0003f000}, {0x83, 0x00000000}, 1313 - {0xdf, 0x00000180}, {0xef, 0x000001a0}, 1314 - {0x51, 0x00069545}, {0x52, 0x0007e42e}, 1315 - {0x53, 0x00000071}, {0x56, 0x00051ff3}, 1316 - {0x35, 0x000000a8}, {0x35, 0x000001e0}, 1317 - {0x35, 0x000002a8}, {0x36, 0x00001ca8}, 1318 - {0x36, 0x00009c24}, {0x36, 0x00011c24}, 1319 - {0x36, 0x00019c24}, {0x18, 0x00000c07}, 1320 - {0x5a, 0x00048000}, {0x19, 0x000739d0}, 1321 - #ifdef EXT_PA_8192EU 1322 - /* External PA or external LNA */ 1323 - {0x34, 0x0000a093}, {0x34, 0x0000908f}, 1324 - {0x34, 0x0000808c}, {0x34, 0x0000704d}, 1325 - {0x34, 0x0000604a}, {0x34, 0x00005047}, 1326 - {0x34, 0x0000400a}, {0x34, 0x00003007}, 1327 - {0x34, 0x00002004}, {0x34, 0x00001001}, 1328 - {0x34, 0x00000000}, 1329 - #else 1330 - {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 1331 - {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 1332 - {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 1333 - {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 1334 - {0x34, 0x0000244f}, {0x34, 0x0000144c}, 1335 - {0x34, 0x00000014}, 1336 - #endif 1337 - {0x00, 0x00030159}, {0x84, 0x00068180}, 1338 - {0x86, 0x000000ce}, {0x87, 0x00048a00}, 1339 - {0x8e, 0x00065540}, {0x8f, 0x00088000}, 1340 - {0xef, 0x000020a0}, 1341 - #ifdef EXT_PA_8192EU 1342 - /* External PA or external LNA */ 1343 - {0x3b, 0x000f07b0}, 1344 - #else 1345 - {0x3b, 0x000f02b0}, 1346 - #endif 1347 - 1348 - {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 1349 - {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 1350 - {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 1351 - {0x3b, 0x0008f780}, 1352 - #ifdef EXT_PA_8192EU 1353 - /* External PA or external LNA */ 1354 - {0x3b, 0x000787b0}, 1355 - #else 1356 - {0x3b, 0x00078730}, 1357 - #endif 1358 - {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 1359 - {0x3b, 0x00040620}, {0x3b, 0x00037090}, 1360 - {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 1361 - {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 1362 - {0x00, 0x00010159}, {0xfe, 0x00000000}, 1363 - {0xfe, 0x00000000}, {0xfe, 0x00000000}, 1364 - {0xfe, 0x00000000}, {0x1e, 0x00000001}, 1365 - {0x1f, 0x00080000}, {0x00, 0x00033e70}, 1366 - {0xff, 0xffffffff} 1367 - }; 1368 - 1369 981 static struct rtl8xxxu_rfregs rtl8xxxu_rfregs[] = { 1370 982 { /* RF_A */ 1371 983 .hssiparm1 = REG_FPGA0_XA_HSSI_PARM1, ··· 635 1747 }, 636 1748 }; 637 1749 638 - static const u32 rtl8xxxu_iqk_phy_iq_bb_reg[RTL8XXXU_BB_REGS] = { 1750 + const u32 rtl8xxxu_iqk_phy_iq_bb_reg[RTL8XXXU_BB_REGS] = { 639 1751 REG_OFDM0_XA_RX_IQ_IMBALANCE, 640 1752 REG_OFDM0_XB_RX_IQ_IMBALANCE, 641 1753 REG_OFDM0_ENERGY_CCA_THRES, ··· 647 1759 REG_OFDM0_RX_IQ_EXT_ANTA 648 1760 }; 649 1761 650 - static u8 rtl8xxxu_read8(struct rtl8xxxu_priv *priv, u16 addr) 1762 + u8 rtl8xxxu_read8(struct rtl8xxxu_priv *priv, u16 addr) 651 1763 { 652 1764 struct usb_device *udev = priv->udev; 653 1765 int len; ··· 667 1779 return data; 668 1780 } 669 1781 670 - static u16 rtl8xxxu_read16(struct rtl8xxxu_priv *priv, u16 addr) 1782 + u16 rtl8xxxu_read16(struct rtl8xxxu_priv *priv, u16 addr) 671 1783 { 672 1784 struct usb_device *udev = priv->udev; 673 1785 int len; ··· 687 1799 return data; 688 1800 } 689 1801 690 - static u32 rtl8xxxu_read32(struct rtl8xxxu_priv *priv, u16 addr) 1802 + u32 rtl8xxxu_read32(struct rtl8xxxu_priv *priv, u16 addr) 691 1803 { 692 1804 struct usb_device *udev = priv->udev; 693 1805 int len; ··· 707 1819 return data; 708 1820 } 709 1821 710 - static int rtl8xxxu_write8(struct rtl8xxxu_priv *priv, u16 addr, u8 val) 1822 + int rtl8xxxu_write8(struct rtl8xxxu_priv *priv, u16 addr, u8 val) 711 1823 { 712 1824 struct usb_device *udev = priv->udev; 713 1825 int ret; ··· 727 1839 return ret; 728 1840 } 729 1841 730 - static int rtl8xxxu_write16(struct rtl8xxxu_priv *priv, u16 addr, u16 val) 1842 + int rtl8xxxu_write16(struct rtl8xxxu_priv *priv, u16 addr, u16 val) 731 1843 { 732 1844 struct usb_device *udev = priv->udev; 733 1845 int ret; ··· 746 1858 return ret; 747 1859 } 748 1860 749 - static int rtl8xxxu_write32(struct rtl8xxxu_priv *priv, u16 addr, u32 val) 1861 + int rtl8xxxu_write32(struct rtl8xxxu_priv *priv, u16 addr, u32 val) 750 1862 { 751 1863 struct usb_device *udev = priv->udev; 752 1864 int ret; ··· 805 1917 return -EAGAIN; 806 1918 } 807 1919 808 - static u32 rtl8xxxu_read_rfreg(struct rtl8xxxu_priv *priv, 809 - enum rtl8xxxu_rfpath path, u8 reg) 1920 + u32 rtl8xxxu_read_rfreg(struct rtl8xxxu_priv *priv, 1921 + enum rtl8xxxu_rfpath path, u8 reg) 810 1922 { 811 1923 u32 hssia, val32, retval; 812 1924 ··· 850 1962 * have write issues in high temperature conditions. We may have to 851 1963 * retry writing them. 852 1964 */ 853 - static int rtl8xxxu_write_rfreg(struct rtl8xxxu_priv *priv, 854 - enum rtl8xxxu_rfpath path, u8 reg, u32 data) 1965 + int rtl8xxxu_write_rfreg(struct rtl8xxxu_priv *priv, 1966 + enum rtl8xxxu_rfpath path, u8 reg, u32 data) 855 1967 { 856 1968 int ret, retval; 857 1969 u32 dataaddr, val32; ··· 887 1999 return retval; 888 2000 } 889 2001 890 - static int rtl8723a_h2c_cmd(struct rtl8xxxu_priv *priv, 891 - struct h2c_cmd *h2c, int len) 2002 + int 2003 + rtl8xxxu_gen1_h2c_cmd(struct rtl8xxxu_priv *priv, struct h2c_cmd *h2c, int len) 892 2004 { 893 2005 struct device *dev = &priv->udev->dev; 894 2006 int mbox_nr, retry, retval = 0; ··· 899 2011 900 2012 mbox_nr = priv->next_mbox; 901 2013 mbox_reg = REG_HMBOX_0 + (mbox_nr * 4); 902 - mbox_ext_reg = priv->fops->mbox_ext_reg + 903 - (mbox_nr * priv->fops->mbox_ext_width); 2014 + mbox_ext_reg = REG_HMBOX_EXT_0 + (mbox_nr * 2); 904 2015 905 2016 /* 906 2017 * MBOX ready? ··· 921 2034 * Need to swap as it's being swapped again by rtl8xxxu_write16/32() 922 2035 */ 923 2036 if (len > sizeof(u32)) { 924 - if (priv->fops->mbox_ext_width == 4) { 925 - rtl8xxxu_write32(priv, mbox_ext_reg, 926 - le32_to_cpu(h2c->raw_wide.ext)); 927 - if (rtl8xxxu_debug & RTL8XXXU_DEBUG_H2C) 928 - dev_info(dev, "H2C_EXT %08x\n", 929 - le32_to_cpu(h2c->raw_wide.ext)); 930 - } else { 931 - rtl8xxxu_write16(priv, mbox_ext_reg, 932 - le16_to_cpu(h2c->raw.ext)); 933 - if (rtl8xxxu_debug & RTL8XXXU_DEBUG_H2C) 934 - dev_info(dev, "H2C_EXT %04x\n", 935 - le16_to_cpu(h2c->raw.ext)); 936 - } 2037 + rtl8xxxu_write16(priv, mbox_ext_reg, le16_to_cpu(h2c->raw.ext)); 2038 + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_H2C) 2039 + dev_info(dev, "H2C_EXT %04x\n", 2040 + le16_to_cpu(h2c->raw.ext)); 937 2041 } 938 2042 rtl8xxxu_write32(priv, mbox_reg, le32_to_cpu(h2c->raw.data)); 939 2043 if (rtl8xxxu_debug & RTL8XXXU_DEBUG_H2C) ··· 937 2059 return retval; 938 2060 } 939 2061 940 - static void rtl8723bu_write_btreg(struct rtl8xxxu_priv *priv, u8 reg, u8 data) 2062 + int 2063 + rtl8xxxu_gen2_h2c_cmd(struct rtl8xxxu_priv *priv, struct h2c_cmd *h2c, int len) 941 2064 { 942 - struct h2c_cmd h2c; 943 - int reqnum = 0; 2065 + struct device *dev = &priv->udev->dev; 2066 + int mbox_nr, retry, retval = 0; 2067 + int mbox_reg, mbox_ext_reg; 2068 + u8 val8; 944 2069 945 - memset(&h2c, 0, sizeof(struct h2c_cmd)); 946 - h2c.bt_mp_oper.cmd = H2C_8723B_BT_MP_OPER; 947 - h2c.bt_mp_oper.operreq = 0 | (reqnum << 4); 948 - h2c.bt_mp_oper.opcode = BT_MP_OP_WRITE_REG_VALUE; 949 - h2c.bt_mp_oper.data = data; 950 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.bt_mp_oper)); 2070 + mutex_lock(&priv->h2c_mutex); 951 2071 952 - reqnum++; 953 - memset(&h2c, 0, sizeof(struct h2c_cmd)); 954 - h2c.bt_mp_oper.cmd = H2C_8723B_BT_MP_OPER; 955 - h2c.bt_mp_oper.operreq = 0 | (reqnum << 4); 956 - h2c.bt_mp_oper.opcode = BT_MP_OP_WRITE_REG_VALUE; 957 - h2c.bt_mp_oper.addr = reg; 958 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.bt_mp_oper)); 2072 + mbox_nr = priv->next_mbox; 2073 + mbox_reg = REG_HMBOX_0 + (mbox_nr * 4); 2074 + mbox_ext_reg = REG_HMBOX_EXT0_8723B + (mbox_nr * 4); 2075 + 2076 + /* 2077 + * MBOX ready? 2078 + */ 2079 + retry = 100; 2080 + do { 2081 + val8 = rtl8xxxu_read8(priv, REG_HMTFR); 2082 + if (!(val8 & BIT(mbox_nr))) 2083 + break; 2084 + } while (retry--); 2085 + 2086 + if (!retry) { 2087 + dev_info(dev, "%s: Mailbox busy\n", __func__); 2088 + retval = -EBUSY; 2089 + goto error; 2090 + } 2091 + 2092 + /* 2093 + * Need to swap as it's being swapped again by rtl8xxxu_write16/32() 2094 + */ 2095 + if (len > sizeof(u32)) { 2096 + rtl8xxxu_write32(priv, mbox_ext_reg, 2097 + le32_to_cpu(h2c->raw_wide.ext)); 2098 + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_H2C) 2099 + dev_info(dev, "H2C_EXT %08x\n", 2100 + le32_to_cpu(h2c->raw_wide.ext)); 2101 + } 2102 + rtl8xxxu_write32(priv, mbox_reg, le32_to_cpu(h2c->raw.data)); 2103 + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_H2C) 2104 + dev_info(dev, "H2C %08x\n", le32_to_cpu(h2c->raw.data)); 2105 + 2106 + priv->next_mbox = (mbox_nr + 1) % H2C_MAX_MBOX; 2107 + 2108 + error: 2109 + mutex_unlock(&priv->h2c_mutex); 2110 + return retval; 959 2111 } 960 2112 961 - static void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv) 2113 + void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv) 962 2114 { 963 2115 u8 val8; 964 2116 u32 val32; ··· 1032 2124 rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00); 1033 2125 } 1034 2126 1035 - static void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv) 2127 + void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv) 1036 2128 { 1037 2129 u8 sps0; 1038 2130 u32 val32; ··· 1071 2163 rtl8xxxu_write8(priv, REG_SPS0_CTRL, sps0); 1072 2164 } 1073 2165 1074 - 1075 - static void rtl8723a_stop_tx_beacon(struct rtl8xxxu_priv *priv) 2166 + static void rtl8xxxu_stop_tx_beacon(struct rtl8xxxu_priv *priv) 1076 2167 { 1077 2168 u8 val8; 1078 2169 ··· 1095 2188 * 1096 2189 * Note: We index from 0 in the code 1097 2190 */ 1098 - static int rtl8723a_channel_to_group(int channel) 2191 + static int rtl8xxxu_gen1_channel_to_group(int channel) 1099 2192 { 1100 2193 int group; 1101 2194 ··· 1112 2205 /* 1113 2206 * Valid for rtl8723bu and rtl8192eu 1114 2207 */ 1115 - static int rtl8xxxu_gen2_channel_to_group(int channel) 2208 + int rtl8xxxu_gen2_channel_to_group(int channel) 1116 2209 { 1117 2210 int group; 1118 2211 ··· 1130 2223 return group; 1131 2224 } 1132 2225 1133 - static void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw) 2226 + void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw) 1134 2227 { 1135 2228 struct rtl8xxxu_priv *priv = hw->priv; 1136 2229 u32 val32, rsr; ··· 1252 2345 } 1253 2346 } 1254 2347 1255 - static void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw) 2348 + void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw) 1256 2349 { 1257 2350 struct rtl8xxxu_priv *priv = hw->priv; 1258 2351 u32 val32, rsr; ··· 1382 2475 } 1383 2476 } 1384 2477 1385 - static void 2478 + void 1386 2479 rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 1387 2480 { 1388 2481 struct rtl8xxxu_power_base *power_base = priv->power_base; ··· 1392 2485 u8 val8; 1393 2486 int group, i; 1394 2487 1395 - group = rtl8723a_channel_to_group(channel); 2488 + group = rtl8xxxu_gen1_channel_to_group(channel); 1396 2489 1397 2490 cck[0] = priv->cck_tx_power_index_A[group] - 1; 1398 2491 cck[1] = priv->cck_tx_power_index_B[group] - 1; ··· 1513 2606 else 1514 2607 val8 = (mcsbase[1] > 6) ? (mcsbase[1] - 6) : 0; 1515 2608 rtl8xxxu_write8(priv, REG_OFDM0_XD_TX_IQ_IMBALANCE + i, val8); 1516 - } 1517 - } 1518 - 1519 - static void 1520 - rtl8723b_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 1521 - { 1522 - u32 val32, ofdm, mcs; 1523 - u8 cck, ofdmbase, mcsbase; 1524 - int group, tx_idx; 1525 - 1526 - tx_idx = 0; 1527 - group = rtl8xxxu_gen2_channel_to_group(channel); 1528 - 1529 - cck = priv->cck_tx_power_index_B[group]; 1530 - val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); 1531 - val32 &= 0xffff00ff; 1532 - val32 |= (cck << 8); 1533 - rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32); 1534 - 1535 - val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 1536 - val32 &= 0xff; 1537 - val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 1538 - rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 1539 - 1540 - ofdmbase = priv->ht40_1s_tx_power_index_B[group]; 1541 - ofdmbase += priv->ofdm_tx_power_diff[tx_idx].b; 1542 - ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24; 1543 - 1544 - rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm); 1545 - rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm); 1546 - 1547 - mcsbase = priv->ht40_1s_tx_power_index_B[group]; 1548 - if (ht40) 1549 - mcsbase += priv->ht40_tx_power_diff[tx_idx++].b; 1550 - else 1551 - mcsbase += priv->ht20_tx_power_diff[tx_idx++].b; 1552 - mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 1553 - 1554 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); 1555 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); 1556 - } 1557 - 1558 - static void 1559 - rtl8192e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 1560 - { 1561 - u32 val32, ofdm, mcs; 1562 - u8 cck, ofdmbase, mcsbase; 1563 - int group, tx_idx; 1564 - 1565 - tx_idx = 0; 1566 - group = rtl8xxxu_gen2_channel_to_group(channel); 1567 - 1568 - cck = priv->cck_tx_power_index_A[group]; 1569 - 1570 - val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); 1571 - val32 &= 0xffff00ff; 1572 - val32 |= (cck << 8); 1573 - rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32); 1574 - 1575 - val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 1576 - val32 &= 0xff; 1577 - val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 1578 - rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 1579 - 1580 - ofdmbase = priv->ht40_1s_tx_power_index_A[group]; 1581 - ofdmbase += priv->ofdm_tx_power_diff[tx_idx].a; 1582 - ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24; 1583 - 1584 - rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm); 1585 - rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm); 1586 - 1587 - mcsbase = priv->ht40_1s_tx_power_index_A[group]; 1588 - if (ht40) 1589 - mcsbase += priv->ht40_tx_power_diff[tx_idx++].a; 1590 - else 1591 - mcsbase += priv->ht20_tx_power_diff[tx_idx++].a; 1592 - mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 1593 - 1594 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); 1595 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); 1596 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, mcs); 1597 - rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs); 1598 - 1599 - if (priv->tx_paths > 1) { 1600 - cck = priv->cck_tx_power_index_B[group]; 1601 - 1602 - val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK1_55_MCS32); 1603 - val32 &= 0xff; 1604 - val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 1605 - rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK1_55_MCS32, val32); 1606 - 1607 - val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 1608 - val32 &= 0xffffff00; 1609 - val32 |= cck; 1610 - rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 1611 - 1612 - ofdmbase = priv->ht40_1s_tx_power_index_B[group]; 1613 - ofdmbase += priv->ofdm_tx_power_diff[tx_idx].b; 1614 - ofdm = ofdmbase | ofdmbase << 8 | 1615 - ofdmbase << 16 | ofdmbase << 24; 1616 - 1617 - rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE18_06, ofdm); 1618 - rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE54_24, ofdm); 1619 - 1620 - mcsbase = priv->ht40_1s_tx_power_index_B[group]; 1621 - if (ht40) 1622 - mcsbase += priv->ht40_tx_power_diff[tx_idx++].b; 1623 - else 1624 - mcsbase += priv->ht20_tx_power_diff[tx_idx++].b; 1625 - mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 1626 - 1627 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS03_MCS00, mcs); 1628 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS07_MCS04, mcs); 1629 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS11_MCS08, mcs); 1630 - rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS15_MCS12, mcs); 1631 2609 } 1632 2610 } 1633 2611 ··· 1757 2965 return 0; 1758 2966 } 1759 2967 1760 - static int rtl8723au_parse_efuse(struct rtl8xxxu_priv *priv) 1761 - { 1762 - struct rtl8723au_efuse *efuse = &priv->efuse_wifi.efuse8723; 1763 - 1764 - if (efuse->rtl_id != cpu_to_le16(0x8129)) 1765 - return -EINVAL; 1766 - 1767 - ether_addr_copy(priv->mac_addr, efuse->mac_addr); 1768 - 1769 - memcpy(priv->cck_tx_power_index_A, 1770 - efuse->cck_tx_power_index_A, 1771 - sizeof(efuse->cck_tx_power_index_A)); 1772 - memcpy(priv->cck_tx_power_index_B, 1773 - efuse->cck_tx_power_index_B, 1774 - sizeof(efuse->cck_tx_power_index_B)); 1775 - 1776 - memcpy(priv->ht40_1s_tx_power_index_A, 1777 - efuse->ht40_1s_tx_power_index_A, 1778 - sizeof(efuse->ht40_1s_tx_power_index_A)); 1779 - memcpy(priv->ht40_1s_tx_power_index_B, 1780 - efuse->ht40_1s_tx_power_index_B, 1781 - sizeof(efuse->ht40_1s_tx_power_index_B)); 1782 - 1783 - memcpy(priv->ht20_tx_power_index_diff, 1784 - efuse->ht20_tx_power_index_diff, 1785 - sizeof(efuse->ht20_tx_power_index_diff)); 1786 - memcpy(priv->ofdm_tx_power_index_diff, 1787 - efuse->ofdm_tx_power_index_diff, 1788 - sizeof(efuse->ofdm_tx_power_index_diff)); 1789 - 1790 - memcpy(priv->ht40_max_power_offset, 1791 - efuse->ht40_max_power_offset, 1792 - sizeof(efuse->ht40_max_power_offset)); 1793 - memcpy(priv->ht20_max_power_offset, 1794 - efuse->ht20_max_power_offset, 1795 - sizeof(efuse->ht20_max_power_offset)); 1796 - 1797 - if (priv->efuse_wifi.efuse8723.version >= 0x01) { 1798 - priv->has_xtalk = 1; 1799 - priv->xtalk = priv->efuse_wifi.efuse8723.xtal_k & 0x3f; 1800 - } 1801 - 1802 - priv->power_base = &rtl8723a_power_base; 1803 - 1804 - dev_info(&priv->udev->dev, "Vendor: %.7s\n", 1805 - efuse->vendor_name); 1806 - dev_info(&priv->udev->dev, "Product: %.41s\n", 1807 - efuse->device_name); 1808 - return 0; 1809 - } 1810 - 1811 - static int rtl8723bu_parse_efuse(struct rtl8xxxu_priv *priv) 1812 - { 1813 - struct rtl8723bu_efuse *efuse = &priv->efuse_wifi.efuse8723bu; 1814 - int i; 1815 - 1816 - if (efuse->rtl_id != cpu_to_le16(0x8129)) 1817 - return -EINVAL; 1818 - 1819 - ether_addr_copy(priv->mac_addr, efuse->mac_addr); 1820 - 1821 - memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base, 1822 - sizeof(efuse->tx_power_index_A.cck_base)); 1823 - memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_B.cck_base, 1824 - sizeof(efuse->tx_power_index_B.cck_base)); 1825 - 1826 - memcpy(priv->ht40_1s_tx_power_index_A, 1827 - efuse->tx_power_index_A.ht40_base, 1828 - sizeof(efuse->tx_power_index_A.ht40_base)); 1829 - memcpy(priv->ht40_1s_tx_power_index_B, 1830 - efuse->tx_power_index_B.ht40_base, 1831 - sizeof(efuse->tx_power_index_B.ht40_base)); 1832 - 1833 - priv->ofdm_tx_power_diff[0].a = 1834 - efuse->tx_power_index_A.ht20_ofdm_1s_diff.a; 1835 - priv->ofdm_tx_power_diff[0].b = 1836 - efuse->tx_power_index_B.ht20_ofdm_1s_diff.a; 1837 - 1838 - priv->ht20_tx_power_diff[0].a = 1839 - efuse->tx_power_index_A.ht20_ofdm_1s_diff.b; 1840 - priv->ht20_tx_power_diff[0].b = 1841 - efuse->tx_power_index_B.ht20_ofdm_1s_diff.b; 1842 - 1843 - priv->ht40_tx_power_diff[0].a = 0; 1844 - priv->ht40_tx_power_diff[0].b = 0; 1845 - 1846 - for (i = 1; i < RTL8723B_TX_COUNT; i++) { 1847 - priv->ofdm_tx_power_diff[i].a = 1848 - efuse->tx_power_index_A.pwr_diff[i - 1].ofdm; 1849 - priv->ofdm_tx_power_diff[i].b = 1850 - efuse->tx_power_index_B.pwr_diff[i - 1].ofdm; 1851 - 1852 - priv->ht20_tx_power_diff[i].a = 1853 - efuse->tx_power_index_A.pwr_diff[i - 1].ht20; 1854 - priv->ht20_tx_power_diff[i].b = 1855 - efuse->tx_power_index_B.pwr_diff[i - 1].ht20; 1856 - 1857 - priv->ht40_tx_power_diff[i].a = 1858 - efuse->tx_power_index_A.pwr_diff[i - 1].ht40; 1859 - priv->ht40_tx_power_diff[i].b = 1860 - efuse->tx_power_index_B.pwr_diff[i - 1].ht40; 1861 - } 1862 - 1863 - priv->has_xtalk = 1; 1864 - priv->xtalk = priv->efuse_wifi.efuse8723bu.xtal_k & 0x3f; 1865 - 1866 - dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); 1867 - dev_info(&priv->udev->dev, "Product: %.41s\n", efuse->device_name); 1868 - 1869 - if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { 1870 - int i; 1871 - unsigned char *raw = priv->efuse_wifi.raw; 1872 - 1873 - dev_info(&priv->udev->dev, 1874 - "%s: dumping efuse (0x%02zx bytes):\n", 1875 - __func__, sizeof(struct rtl8723bu_efuse)); 1876 - for (i = 0; i < sizeof(struct rtl8723bu_efuse); i += 8) { 1877 - dev_info(&priv->udev->dev, "%02x: " 1878 - "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, 1879 - raw[i], raw[i + 1], raw[i + 2], 1880 - raw[i + 3], raw[i + 4], raw[i + 5], 1881 - raw[i + 6], raw[i + 7]); 1882 - } 1883 - } 1884 - 1885 - return 0; 1886 - } 1887 - 1888 - #ifdef CONFIG_RTL8XXXU_UNTESTED 1889 - 1890 - static int rtl8192cu_parse_efuse(struct rtl8xxxu_priv *priv) 1891 - { 1892 - struct rtl8192cu_efuse *efuse = &priv->efuse_wifi.efuse8192; 1893 - int i; 1894 - 1895 - if (efuse->rtl_id != cpu_to_le16(0x8129)) 1896 - return -EINVAL; 1897 - 1898 - ether_addr_copy(priv->mac_addr, efuse->mac_addr); 1899 - 1900 - memcpy(priv->cck_tx_power_index_A, 1901 - efuse->cck_tx_power_index_A, 1902 - sizeof(efuse->cck_tx_power_index_A)); 1903 - memcpy(priv->cck_tx_power_index_B, 1904 - efuse->cck_tx_power_index_B, 1905 - sizeof(efuse->cck_tx_power_index_B)); 1906 - 1907 - memcpy(priv->ht40_1s_tx_power_index_A, 1908 - efuse->ht40_1s_tx_power_index_A, 1909 - sizeof(efuse->ht40_1s_tx_power_index_A)); 1910 - memcpy(priv->ht40_1s_tx_power_index_B, 1911 - efuse->ht40_1s_tx_power_index_B, 1912 - sizeof(efuse->ht40_1s_tx_power_index_B)); 1913 - memcpy(priv->ht40_2s_tx_power_index_diff, 1914 - efuse->ht40_2s_tx_power_index_diff, 1915 - sizeof(efuse->ht40_2s_tx_power_index_diff)); 1916 - 1917 - memcpy(priv->ht20_tx_power_index_diff, 1918 - efuse->ht20_tx_power_index_diff, 1919 - sizeof(efuse->ht20_tx_power_index_diff)); 1920 - memcpy(priv->ofdm_tx_power_index_diff, 1921 - efuse->ofdm_tx_power_index_diff, 1922 - sizeof(efuse->ofdm_tx_power_index_diff)); 1923 - 1924 - memcpy(priv->ht40_max_power_offset, 1925 - efuse->ht40_max_power_offset, 1926 - sizeof(efuse->ht40_max_power_offset)); 1927 - memcpy(priv->ht20_max_power_offset, 1928 - efuse->ht20_max_power_offset, 1929 - sizeof(efuse->ht20_max_power_offset)); 1930 - 1931 - dev_info(&priv->udev->dev, "Vendor: %.7s\n", 1932 - efuse->vendor_name); 1933 - dev_info(&priv->udev->dev, "Product: %.20s\n", 1934 - efuse->device_name); 1935 - 1936 - priv->power_base = &rtl8192c_power_base; 1937 - 1938 - if (efuse->rf_regulatory & 0x20) { 1939 - sprintf(priv->chip_name, "8188RU"); 1940 - priv->rtl_chip = RTL8188R; 1941 - priv->hi_pa = 1; 1942 - priv->no_pape = 1; 1943 - priv->power_base = &rtl8188r_power_base; 1944 - } 1945 - 1946 - if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { 1947 - unsigned char *raw = priv->efuse_wifi.raw; 1948 - 1949 - dev_info(&priv->udev->dev, 1950 - "%s: dumping efuse (0x%02zx bytes):\n", 1951 - __func__, sizeof(struct rtl8192cu_efuse)); 1952 - for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8) { 1953 - dev_info(&priv->udev->dev, "%02x: " 1954 - "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, 1955 - raw[i], raw[i + 1], raw[i + 2], 1956 - raw[i + 3], raw[i + 4], raw[i + 5], 1957 - raw[i + 6], raw[i + 7]); 1958 - } 1959 - } 1960 - return 0; 1961 - } 1962 - 1963 - #endif 1964 - 1965 - static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv) 1966 - { 1967 - struct rtl8192eu_efuse *efuse = &priv->efuse_wifi.efuse8192eu; 1968 - int i; 1969 - 1970 - if (efuse->rtl_id != cpu_to_le16(0x8129)) 1971 - return -EINVAL; 1972 - 1973 - ether_addr_copy(priv->mac_addr, efuse->mac_addr); 1974 - 1975 - memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base, 1976 - sizeof(efuse->tx_power_index_A.cck_base)); 1977 - memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_B.cck_base, 1978 - sizeof(efuse->tx_power_index_B.cck_base)); 1979 - 1980 - memcpy(priv->ht40_1s_tx_power_index_A, 1981 - efuse->tx_power_index_A.ht40_base, 1982 - sizeof(efuse->tx_power_index_A.ht40_base)); 1983 - memcpy(priv->ht40_1s_tx_power_index_B, 1984 - efuse->tx_power_index_B.ht40_base, 1985 - sizeof(efuse->tx_power_index_B.ht40_base)); 1986 - 1987 - priv->ht20_tx_power_diff[0].a = 1988 - efuse->tx_power_index_A.ht20_ofdm_1s_diff.b; 1989 - priv->ht20_tx_power_diff[0].b = 1990 - efuse->tx_power_index_B.ht20_ofdm_1s_diff.b; 1991 - 1992 - priv->ht40_tx_power_diff[0].a = 0; 1993 - priv->ht40_tx_power_diff[0].b = 0; 1994 - 1995 - for (i = 1; i < RTL8723B_TX_COUNT; i++) { 1996 - priv->ofdm_tx_power_diff[i].a = 1997 - efuse->tx_power_index_A.pwr_diff[i - 1].ofdm; 1998 - priv->ofdm_tx_power_diff[i].b = 1999 - efuse->tx_power_index_B.pwr_diff[i - 1].ofdm; 2000 - 2001 - priv->ht20_tx_power_diff[i].a = 2002 - efuse->tx_power_index_A.pwr_diff[i - 1].ht20; 2003 - priv->ht20_tx_power_diff[i].b = 2004 - efuse->tx_power_index_B.pwr_diff[i - 1].ht20; 2005 - 2006 - priv->ht40_tx_power_diff[i].a = 2007 - efuse->tx_power_index_A.pwr_diff[i - 1].ht40; 2008 - priv->ht40_tx_power_diff[i].b = 2009 - efuse->tx_power_index_B.pwr_diff[i - 1].ht40; 2010 - } 2011 - 2012 - priv->has_xtalk = 1; 2013 - priv->xtalk = priv->efuse_wifi.efuse8192eu.xtal_k & 0x3f; 2014 - 2015 - dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); 2016 - dev_info(&priv->udev->dev, "Product: %.11s\n", efuse->device_name); 2017 - dev_info(&priv->udev->dev, "Serial: %.11s\n", efuse->serial); 2018 - 2019 - if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { 2020 - unsigned char *raw = priv->efuse_wifi.raw; 2021 - 2022 - dev_info(&priv->udev->dev, 2023 - "%s: dumping efuse (0x%02zx bytes):\n", 2024 - __func__, sizeof(struct rtl8192eu_efuse)); 2025 - for (i = 0; i < sizeof(struct rtl8192eu_efuse); i += 8) { 2026 - dev_info(&priv->udev->dev, "%02x: " 2027 - "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, 2028 - raw[i], raw[i + 1], raw[i + 2], 2029 - raw[i + 3], raw[i + 4], raw[i + 5], 2030 - raw[i + 6], raw[i + 7]); 2031 - } 2032 - } 2033 - return 0; 2034 - } 2035 - 2036 2968 static int 2037 2969 rtl8xxxu_read_efuse8(struct rtl8xxxu_priv *priv, u16 offset, u8 *data) 2038 2970 { ··· 1904 3388 return ret; 1905 3389 } 1906 3390 1907 - static void rtl8xxxu_reset_8051(struct rtl8xxxu_priv *priv) 3391 + void rtl8xxxu_reset_8051(struct rtl8xxxu_priv *priv) 1908 3392 { 1909 3393 u8 val8; 1910 3394 u16 sys_func; ··· 1916 3400 sys_func = rtl8xxxu_read16(priv, REG_SYS_FUNC); 1917 3401 sys_func &= ~SYS_FUNC_CPU_ENABLE; 1918 3402 rtl8xxxu_write16(priv, REG_SYS_FUNC, sys_func); 1919 - 1920 - val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL + 1); 1921 - val8 |= BIT(0); 1922 - rtl8xxxu_write8(priv, REG_RSV_CTRL + 1, val8); 1923 - 1924 - sys_func |= SYS_FUNC_CPU_ENABLE; 1925 - rtl8xxxu_write16(priv, REG_SYS_FUNC, sys_func); 1926 - } 1927 - 1928 - static void rtl8723bu_reset_8051(struct rtl8xxxu_priv *priv) 1929 - { 1930 - u8 val8; 1931 - u16 sys_func; 1932 - 1933 - val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL); 1934 - val8 &= ~BIT(1); 1935 - rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); 1936 - 1937 - val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL + 1); 1938 - val8 &= ~BIT(0); 1939 - rtl8xxxu_write8(priv, REG_RSV_CTRL + 1, val8); 1940 - 1941 - sys_func = rtl8xxxu_read16(priv, REG_SYS_FUNC); 1942 - sys_func &= ~SYS_FUNC_CPU_ENABLE; 1943 - rtl8xxxu_write16(priv, REG_SYS_FUNC, sys_func); 1944 - 1945 - val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL); 1946 - val8 &= ~BIT(1); 1947 - rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); 1948 3403 1949 3404 val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL + 1); 1950 3405 val8 |= BIT(0); ··· 2060 3573 return ret; 2061 3574 } 2062 3575 2063 - static int rtl8xxxu_load_firmware(struct rtl8xxxu_priv *priv, char *fw_name) 3576 + int rtl8xxxu_load_firmware(struct rtl8xxxu_priv *priv, char *fw_name) 2064 3577 { 2065 3578 struct device *dev = &priv->udev->dev; 2066 3579 const struct firmware *fw; ··· 2109 3622 return ret; 2110 3623 } 2111 3624 2112 - static int rtl8723au_load_firmware(struct rtl8xxxu_priv *priv) 2113 - { 2114 - char *fw_name; 2115 - int ret; 2116 - 2117 - switch (priv->chip_cut) { 2118 - case 0: 2119 - fw_name = "rtlwifi/rtl8723aufw_A.bin"; 2120 - break; 2121 - case 1: 2122 - if (priv->enable_bluetooth) 2123 - fw_name = "rtlwifi/rtl8723aufw_B.bin"; 2124 - else 2125 - fw_name = "rtlwifi/rtl8723aufw_B_NoBT.bin"; 2126 - 2127 - break; 2128 - default: 2129 - return -EINVAL; 2130 - } 2131 - 2132 - ret = rtl8xxxu_load_firmware(priv, fw_name); 2133 - return ret; 2134 - } 2135 - 2136 - static int rtl8723bu_load_firmware(struct rtl8xxxu_priv *priv) 2137 - { 2138 - char *fw_name; 2139 - int ret; 2140 - 2141 - if (priv->enable_bluetooth) 2142 - fw_name = "rtlwifi/rtl8723bu_bt.bin"; 2143 - else 2144 - fw_name = "rtlwifi/rtl8723bu_nic.bin"; 2145 - 2146 - ret = rtl8xxxu_load_firmware(priv, fw_name); 2147 - return ret; 2148 - } 2149 - 2150 - #ifdef CONFIG_RTL8XXXU_UNTESTED 2151 - 2152 - static int rtl8192cu_load_firmware(struct rtl8xxxu_priv *priv) 2153 - { 2154 - char *fw_name; 2155 - int ret; 2156 - 2157 - if (!priv->vendor_umc) 2158 - fw_name = "rtlwifi/rtl8192cufw_TMSC.bin"; 2159 - else if (priv->chip_cut || priv->rtl_chip == RTL8192C) 2160 - fw_name = "rtlwifi/rtl8192cufw_B.bin"; 2161 - else 2162 - fw_name = "rtlwifi/rtl8192cufw_A.bin"; 2163 - 2164 - ret = rtl8xxxu_load_firmware(priv, fw_name); 2165 - 2166 - return ret; 2167 - } 2168 - 2169 - #endif 2170 - 2171 - static int rtl8192eu_load_firmware(struct rtl8xxxu_priv *priv) 2172 - { 2173 - char *fw_name; 2174 - int ret; 2175 - 2176 - fw_name = "rtlwifi/rtl8192eu_nic.bin"; 2177 - 2178 - ret = rtl8xxxu_load_firmware(priv, fw_name); 2179 - 2180 - return ret; 2181 - } 2182 - 2183 - static void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv) 3625 + void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv) 2184 3626 { 2185 3627 u16 val16; 2186 3628 int i = 100; ··· 2134 3718 val16 &= ~SYS_FUNC_CPU_ENABLE; 2135 3719 rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 2136 3720 } 2137 - } 2138 - 2139 - static void rtl8723bu_phy_init_antenna_selection(struct rtl8xxxu_priv *priv) 2140 - { 2141 - u32 val32; 2142 - 2143 - val32 = rtl8xxxu_read32(priv, REG_PAD_CTRL1); 2144 - val32 &= ~(BIT(20) | BIT(24)); 2145 - rtl8xxxu_write32(priv, REG_PAD_CTRL1, val32); 2146 - 2147 - val32 = rtl8xxxu_read32(priv, REG_GPIO_MUXCFG); 2148 - val32 &= ~BIT(4); 2149 - rtl8xxxu_write32(priv, REG_GPIO_MUXCFG, val32); 2150 - 2151 - val32 = rtl8xxxu_read32(priv, REG_GPIO_MUXCFG); 2152 - val32 |= BIT(3); 2153 - rtl8xxxu_write32(priv, REG_GPIO_MUXCFG, val32); 2154 - 2155 - val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 2156 - val32 |= BIT(24); 2157 - rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 2158 - 2159 - val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 2160 - val32 &= ~BIT(23); 2161 - rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 2162 - 2163 - val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 2164 - val32 |= (BIT(0) | BIT(1)); 2165 - rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 2166 - 2167 - val32 = rtl8xxxu_read32(priv, REG_RFE_CTRL_ANTA_SRC); 2168 - val32 &= 0xffffff00; 2169 - val32 |= 0x77; 2170 - rtl8xxxu_write32(priv, REG_RFE_CTRL_ANTA_SRC, val32); 2171 - 2172 - val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 2173 - val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 2174 - rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 2175 3721 } 2176 3722 2177 3723 static int ··· 2166 3788 return 0; 2167 3789 } 2168 3790 2169 - static int rtl8xxxu_init_phy_regs(struct rtl8xxxu_priv *priv, 2170 - struct rtl8xxxu_reg32val *array) 3791 + int rtl8xxxu_init_phy_regs(struct rtl8xxxu_priv *priv, 3792 + struct rtl8xxxu_reg32val *array) 2171 3793 { 2172 3794 int i, ret; 2173 3795 u16 reg; ··· 2192 3814 return 0; 2193 3815 } 2194 3816 2195 - static void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv) 3817 + void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv) 2196 3818 { 2197 3819 u8 val8, ldoa15, ldov12d, lpldo, ldohci12; 2198 3820 u16 val16; ··· 2243 3865 lpldo = 1; 2244 3866 val32 = (lpldo << 24) | (ldohci12 << 16) | (ldov12d << 8) | ldoa15; 2245 3867 rtl8xxxu_write32(priv, REG_LDOA15_CTRL, val32); 2246 - } 2247 - 2248 - static void rtl8723bu_init_phy_bb(struct rtl8xxxu_priv *priv) 2249 - { 2250 - u8 val8; 2251 - u16 val16; 2252 - 2253 - val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 2254 - val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; 2255 - rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 2256 - 2257 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 2258 - 2259 - /* 6. 0x1f[7:0] = 0x07 */ 2260 - val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 2261 - rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 2262 - 2263 - /* Why? */ 2264 - rtl8xxxu_write8(priv, REG_SYS_FUNC, 0xe3); 2265 - rtl8xxxu_write8(priv, REG_AFE_XTAL_CTRL + 1, 0x80); 2266 - rtl8xxxu_init_phy_regs(priv, rtl8723b_phy_1t_init_table); 2267 - 2268 - rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8723bu_table); 2269 - } 2270 - 2271 - static void rtl8192eu_init_phy_bb(struct rtl8xxxu_priv *priv) 2272 - { 2273 - u8 val8; 2274 - u16 val16; 2275 - 2276 - val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 2277 - val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; 2278 - rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 2279 - 2280 - /* 6. 0x1f[7:0] = 0x07 */ 2281 - val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 2282 - rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 2283 - 2284 - val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 2285 - val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD | SYS_FUNC_DIO_RF | 2286 - SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB); 2287 - rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 2288 - val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 2289 - rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 2290 - rtl8xxxu_init_phy_regs(priv, rtl8192eu_phy_init_table); 2291 - 2292 - if (priv->hi_pa) 2293 - rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_highpa_table); 2294 - else 2295 - rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_std_table); 2296 3868 } 2297 3869 2298 3870 /* ··· 2379 4051 return 0; 2380 4052 } 2381 4053 2382 - static int rtl8xxxu_init_phy_rf(struct rtl8xxxu_priv *priv, 2383 - struct rtl8xxxu_rfregval *table, 2384 - enum rtl8xxxu_rfpath path) 4054 + int rtl8xxxu_init_phy_rf(struct rtl8xxxu_priv *priv, 4055 + struct rtl8xxxu_rfregval *table, 4056 + enum rtl8xxxu_rfpath path) 2385 4057 { 2386 4058 u32 val32; 2387 4059 u16 val16, rfsi_rfenv; ··· 2444 4116 return 0; 2445 4117 } 2446 4118 2447 - static int rtl8723au_init_phy_rf(struct rtl8xxxu_priv *priv) 2448 - { 2449 - int ret; 2450 - 2451 - ret = rtl8xxxu_init_phy_rf(priv, rtl8723au_radioa_1t_init_table, RF_A); 2452 - 2453 - /* Reduce 80M spur */ 2454 - rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, 0x0381808d); 2455 - rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 2456 - rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff82); 2457 - rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 2458 - 2459 - return ret; 2460 - } 2461 - 2462 - static int rtl8723bu_init_phy_rf(struct rtl8xxxu_priv *priv) 2463 - { 2464 - int ret; 2465 - 2466 - ret = rtl8xxxu_init_phy_rf(priv, rtl8723bu_radioa_1t_init_table, RF_A); 2467 - /* 2468 - * PHY LCK 2469 - */ 2470 - rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdfbe0); 2471 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_MODE_AG, 0x8c01); 2472 - msleep(200); 2473 - rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdffe0); 2474 - 2475 - return ret; 2476 - } 2477 - 2478 - #ifdef CONFIG_RTL8XXXU_UNTESTED 2479 - static int rtl8192cu_init_phy_rf(struct rtl8xxxu_priv *priv) 2480 - { 2481 - struct rtl8xxxu_rfregval *rftable; 2482 - int ret; 2483 - 2484 - if (priv->rtl_chip == RTL8188R) { 2485 - rftable = rtl8188ru_radioa_1t_highpa_table; 2486 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 2487 - } else if (priv->rf_paths == 1) { 2488 - rftable = rtl8192cu_radioa_1t_init_table; 2489 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 2490 - } else { 2491 - rftable = rtl8192cu_radioa_2t_init_table; 2492 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 2493 - if (ret) 2494 - goto exit; 2495 - rftable = rtl8192cu_radiob_2t_init_table; 2496 - ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_B); 2497 - } 2498 - 2499 - exit: 2500 - return ret; 2501 - } 2502 - #endif 2503 - 2504 - static int rtl8192eu_init_phy_rf(struct rtl8xxxu_priv *priv) 2505 - { 2506 - int ret; 2507 - 2508 - ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radioa_init_table, RF_A); 2509 - if (ret) 2510 - goto exit; 2511 - 2512 - ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radiob_init_table, RF_B); 2513 - 2514 - exit: 2515 - return ret; 2516 - } 2517 - 2518 4119 static int rtl8xxxu_llt_write(struct rtl8xxxu_priv *priv, u8 address, u8 data) 2519 4120 { 2520 4121 int ret = -EBUSY; ··· 2465 4208 return ret; 2466 4209 } 2467 4210 2468 - static int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) 4211 + int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) 2469 4212 { 2470 4213 int ret; 2471 4214 int i; ··· 2496 4239 return ret; 2497 4240 } 2498 4241 2499 - static int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) 4242 + int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) 2500 4243 { 2501 4244 u32 val32; 2502 4245 int ret = 0; ··· 2640 4383 return ret; 2641 4384 } 2642 4385 2643 - static void rtl8xxxu_fill_iqk_matrix_a(struct rtl8xxxu_priv *priv, 2644 - bool iqk_ok, int result[][8], 2645 - int candidate, bool tx_only) 4386 + void rtl8xxxu_fill_iqk_matrix_a(struct rtl8xxxu_priv *priv, bool iqk_ok, 4387 + int result[][8], int candidate, bool tx_only) 2646 4388 { 2647 4389 u32 oldval, x, tx0_a, reg; 2648 4390 int y, tx0_c; ··· 2717 4461 rtl8xxxu_write32(priv, REG_OFDM0_RX_IQ_EXT_ANTA, val32); 2718 4462 } 2719 4463 2720 - static void rtl8xxxu_fill_iqk_matrix_b(struct rtl8xxxu_priv *priv, 2721 - bool iqk_ok, int result[][8], 2722 - int candidate, bool tx_only) 4464 + void rtl8xxxu_fill_iqk_matrix_b(struct rtl8xxxu_priv *priv, bool iqk_ok, 4465 + int result[][8], int candidate, bool tx_only) 2723 4466 { 2724 4467 u32 oldval, x, tx1_a, reg; 2725 4468 int y, tx1_c; ··· 2850 4595 return false; 2851 4596 } 2852 4597 2853 - static bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv, 2854 - int result[][8], int c1, int c2) 4598 + bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv, 4599 + int result[][8], int c1, int c2) 2855 4600 { 2856 4601 u32 i, j, diff, simubitmap, bound = 0; 2857 4602 int candidate[2] = {-1, -1}; /* for path A and path B */ ··· 2935 4680 return false; 2936 4681 } 2937 4682 2938 - static void 4683 + void 2939 4684 rtl8xxxu_save_mac_regs(struct rtl8xxxu_priv *priv, const u32 *reg, u32 *backup) 2940 4685 { 2941 4686 int i; ··· 2946 4691 backup[i] = rtl8xxxu_read32(priv, reg[i]); 2947 4692 } 2948 4693 2949 - static void rtl8xxxu_restore_mac_regs(struct rtl8xxxu_priv *priv, 2950 - const u32 *reg, u32 *backup) 4694 + void rtl8xxxu_restore_mac_regs(struct rtl8xxxu_priv *priv, 4695 + const u32 *reg, u32 *backup) 2951 4696 { 2952 4697 int i; 2953 4698 ··· 2957 4702 rtl8xxxu_write32(priv, reg[i], backup[i]); 2958 4703 } 2959 4704 2960 - static void rtl8xxxu_save_regs(struct rtl8xxxu_priv *priv, const u32 *regs, 2961 - u32 *backup, int count) 4705 + void rtl8xxxu_save_regs(struct rtl8xxxu_priv *priv, const u32 *regs, 4706 + u32 *backup, int count) 2962 4707 { 2963 4708 int i; 2964 4709 ··· 2966 4711 backup[i] = rtl8xxxu_read32(priv, regs[i]); 2967 4712 } 2968 4713 2969 - static void rtl8xxxu_restore_regs(struct rtl8xxxu_priv *priv, const u32 *regs, 2970 - u32 *backup, int count) 4714 + void rtl8xxxu_restore_regs(struct rtl8xxxu_priv *priv, const u32 *regs, 4715 + u32 *backup, int count) 2971 4716 { 2972 4717 int i; 2973 4718 ··· 2976 4721 } 2977 4722 2978 4723 2979 - static void rtl8xxxu_path_adda_on(struct rtl8xxxu_priv *priv, const u32 *regs, 2980 - bool path_a_on) 4724 + void rtl8xxxu_path_adda_on(struct rtl8xxxu_priv *priv, const u32 *regs, 4725 + bool path_a_on) 2981 4726 { 2982 4727 u32 path_on; 2983 4728 int i; ··· 2996 4741 rtl8xxxu_write32(priv, regs[i], path_on); 2997 4742 } 2998 4743 2999 - static void rtl8xxxu_mac_calibration(struct rtl8xxxu_priv *priv, 3000 - const u32 *regs, u32 *backup) 4744 + void rtl8xxxu_mac_calibration(struct rtl8xxxu_priv *priv, 4745 + const u32 *regs, u32 *backup) 3001 4746 { 3002 4747 int i = 0; 3003 4748 ··· 3098 4843 else 3099 4844 dev_warn(&priv->udev->dev, "%s: Path B RX IQK failed!\n", 3100 4845 __func__); 3101 - out: 3102 - return result; 3103 - } 3104 - 3105 - static int rtl8723bu_iqk_path_a(struct rtl8xxxu_priv *priv) 3106 - { 3107 - u32 reg_eac, reg_e94, reg_e9c, path_sel, val32; 3108 - int result = 0; 3109 - 3110 - path_sel = rtl8xxxu_read32(priv, REG_S0S1_PATH_SWITCH); 3111 - 3112 - /* 3113 - * Leave IQK mode 3114 - */ 3115 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3116 - val32 &= 0x000000ff; 3117 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3118 - 3119 - /* 3120 - * Enable path A PA in TX IQK mode 3121 - */ 3122 - val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 3123 - val32 |= 0x80000; 3124 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 3125 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x20000); 3126 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0003f); 3127 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xc7f87); 3128 - 3129 - /* 3130 - * Tx IQK setting 3131 - */ 3132 - rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 3133 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3134 - 3135 - /* path-A IQK setting */ 3136 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 3137 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 3138 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 3139 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3140 - 3141 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x821403ea); 3142 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28110000); 3143 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82110000); 3144 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x28110000); 3145 - 3146 - /* LO calibration setting */ 3147 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00462911); 3148 - 3149 - /* 3150 - * Enter IQK mode 3151 - */ 3152 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3153 - val32 &= 0x000000ff; 3154 - val32 |= 0x80800000; 3155 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3156 - 3157 - /* 3158 - * The vendor driver indicates the USB module is always using 3159 - * S0S1 path 1 for the 8723bu. This may be different for 8192eu 3160 - */ 3161 - if (priv->rf_paths > 1) 3162 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000000); 3163 - else 3164 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000280); 3165 - 3166 - /* 3167 - * Bit 12 seems to be BT_GRANT, and is only found in the 8723bu. 3168 - * No trace of this in the 8192eu or 8188eu vendor drivers. 3169 - */ 3170 - rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00000800); 3171 - 3172 - /* One shot, path A LOK & IQK */ 3173 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 3174 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3175 - 3176 - mdelay(1); 3177 - 3178 - /* Restore Ant Path */ 3179 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, path_sel); 3180 - #ifdef RTL8723BU_BT 3181 - /* GNT_BT = 1 */ 3182 - rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00001800); 3183 - #endif 3184 - 3185 - /* 3186 - * Leave IQK mode 3187 - */ 3188 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3189 - val32 &= 0x000000ff; 3190 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3191 - 3192 - /* Check failed */ 3193 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3194 - reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 3195 - reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 3196 - 3197 - val32 = (reg_e9c >> 16) & 0x3ff; 3198 - if (val32 & 0x200) 3199 - val32 = 0x400 - val32; 3200 - 3201 - if (!(reg_eac & BIT(28)) && 3202 - ((reg_e94 & 0x03ff0000) != 0x01420000) && 3203 - ((reg_e9c & 0x03ff0000) != 0x00420000) && 3204 - ((reg_e94 & 0x03ff0000) < 0x01100000) && 3205 - ((reg_e94 & 0x03ff0000) > 0x00f00000) && 3206 - val32 < 0xf) 3207 - result |= 0x01; 3208 - else /* If TX not OK, ignore RX */ 3209 - goto out; 3210 - 3211 - out: 3212 - return result; 3213 - } 3214 - 3215 - static int rtl8723bu_rx_iqk_path_a(struct rtl8xxxu_priv *priv) 3216 - { 3217 - u32 reg_ea4, reg_eac, reg_e94, reg_e9c, path_sel, val32; 3218 - int result = 0; 3219 - 3220 - path_sel = rtl8xxxu_read32(priv, REG_S0S1_PATH_SWITCH); 3221 - 3222 - /* 3223 - * Leave IQK mode 3224 - */ 3225 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3226 - val32 &= 0x000000ff; 3227 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3228 - 3229 - /* 3230 - * Enable path A PA in TX IQK mode 3231 - */ 3232 - val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 3233 - val32 |= 0x80000; 3234 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 3235 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 3236 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 3237 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7fb7); 3238 - 3239 - /* 3240 - * Tx IQK setting 3241 - */ 3242 - rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 3243 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3244 - 3245 - /* path-A IQK setting */ 3246 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 3247 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 3248 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 3249 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3250 - 3251 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160ff0); 3252 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28110000); 3253 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82110000); 3254 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x28110000); 3255 - 3256 - /* LO calibration setting */ 3257 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 3258 - 3259 - /* 3260 - * Enter IQK mode 3261 - */ 3262 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3263 - val32 &= 0x000000ff; 3264 - val32 |= 0x80800000; 3265 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3266 - 3267 - /* 3268 - * The vendor driver indicates the USB module is always using 3269 - * S0S1 path 1 for the 8723bu. This may be different for 8192eu 3270 - */ 3271 - if (priv->rf_paths > 1) 3272 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000000); 3273 - else 3274 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000280); 3275 - 3276 - /* 3277 - * Bit 12 seems to be BT_GRANT, and is only found in the 8723bu. 3278 - * No trace of this in the 8192eu or 8188eu vendor drivers. 3279 - */ 3280 - rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00000800); 3281 - 3282 - /* One shot, path A LOK & IQK */ 3283 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 3284 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3285 - 3286 - mdelay(1); 3287 - 3288 - /* Restore Ant Path */ 3289 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, path_sel); 3290 - #ifdef RTL8723BU_BT 3291 - /* GNT_BT = 1 */ 3292 - rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00001800); 3293 - #endif 3294 - 3295 - /* 3296 - * Leave IQK mode 3297 - */ 3298 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3299 - val32 &= 0x000000ff; 3300 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3301 - 3302 - /* Check failed */ 3303 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3304 - reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 3305 - reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 3306 - 3307 - val32 = (reg_e9c >> 16) & 0x3ff; 3308 - if (val32 & 0x200) 3309 - val32 = 0x400 - val32; 3310 - 3311 - if (!(reg_eac & BIT(28)) && 3312 - ((reg_e94 & 0x03ff0000) != 0x01420000) && 3313 - ((reg_e9c & 0x03ff0000) != 0x00420000) && 3314 - ((reg_e94 & 0x03ff0000) < 0x01100000) && 3315 - ((reg_e94 & 0x03ff0000) > 0x00f00000) && 3316 - val32 < 0xf) 3317 - result |= 0x01; 3318 - else /* If TX not OK, ignore RX */ 3319 - goto out; 3320 - 3321 - val32 = 0x80007c00 | (reg_e94 &0x3ff0000) | 3322 - ((reg_e9c & 0x3ff0000) >> 16); 3323 - rtl8xxxu_write32(priv, REG_TX_IQK, val32); 3324 - 3325 - /* 3326 - * Modify RX IQK mode 3327 - */ 3328 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3329 - val32 &= 0x000000ff; 3330 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3331 - val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 3332 - val32 |= 0x80000; 3333 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 3334 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 3335 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 3336 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7d77); 3337 - 3338 - /* 3339 - * PA, PAD setting 3340 - */ 3341 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0xf80); 3342 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_55, 0x4021f); 3343 - 3344 - /* 3345 - * RX IQK setting 3346 - */ 3347 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3348 - 3349 - /* path-A IQK setting */ 3350 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 3351 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x18008c1c); 3352 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 3353 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3354 - 3355 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82110000); 3356 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x2816001f); 3357 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82110000); 3358 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x28110000); 3359 - 3360 - /* LO calibration setting */ 3361 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a8d1); 3362 - 3363 - /* 3364 - * Enter IQK mode 3365 - */ 3366 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3367 - val32 &= 0x000000ff; 3368 - val32 |= 0x80800000; 3369 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3370 - 3371 - if (priv->rf_paths > 1) 3372 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000000); 3373 - else 3374 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000280); 3375 - 3376 - /* 3377 - * Disable BT 3378 - */ 3379 - rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00000800); 3380 - 3381 - /* One shot, path A LOK & IQK */ 3382 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 3383 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3384 - 3385 - mdelay(1); 3386 - 3387 - /* Restore Ant Path */ 3388 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, path_sel); 3389 - #ifdef RTL8723BU_BT 3390 - /* GNT_BT = 1 */ 3391 - rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00001800); 3392 - #endif 3393 - 3394 - /* 3395 - * Leave IQK mode 3396 - */ 3397 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3398 - val32 &= 0x000000ff; 3399 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3400 - 3401 - /* Check failed */ 3402 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3403 - reg_ea4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_A_2); 3404 - 3405 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x780); 3406 - 3407 - val32 = (reg_eac >> 16) & 0x3ff; 3408 - if (val32 & 0x200) 3409 - val32 = 0x400 - val32; 3410 - 3411 - if (!(reg_eac & BIT(27)) && 3412 - ((reg_ea4 & 0x03ff0000) != 0x01320000) && 3413 - ((reg_eac & 0x03ff0000) != 0x00360000) && 3414 - ((reg_ea4 & 0x03ff0000) < 0x01100000) && 3415 - ((reg_ea4 & 0x03ff0000) > 0x00f00000) && 3416 - val32 < 0xf) 3417 - result |= 0x02; 3418 - else /* If TX not OK, ignore RX */ 3419 - goto out; 3420 - out: 3421 - return result; 3422 - } 3423 - 3424 - static int rtl8192eu_iqk_path_a(struct rtl8xxxu_priv *priv) 3425 - { 3426 - u32 reg_eac, reg_e94, reg_e9c; 3427 - int result = 0; 3428 - 3429 - /* 3430 - * TX IQK 3431 - * PA/PAD controlled by 0x0 3432 - */ 3433 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3434 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00180); 3435 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3436 - 3437 - /* Path A IQK setting */ 3438 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 3439 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 3440 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 3441 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3442 - 3443 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82140303); 3444 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160000); 3445 - 3446 - /* LO calibration setting */ 3447 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00462911); 3448 - 3449 - /* One shot, path A LOK & IQK */ 3450 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 3451 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3452 - 3453 - mdelay(10); 3454 - 3455 - /* Check failed */ 3456 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3457 - reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 3458 - reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 3459 - 3460 - if (!(reg_eac & BIT(28)) && 3461 - ((reg_e94 & 0x03ff0000) != 0x01420000) && 3462 - ((reg_e9c & 0x03ff0000) != 0x00420000)) 3463 - result |= 0x01; 3464 - 3465 - return result; 3466 - } 3467 - 3468 - static int rtl8192eu_rx_iqk_path_a(struct rtl8xxxu_priv *priv) 3469 - { 3470 - u32 reg_ea4, reg_eac, reg_e94, reg_e9c, val32; 3471 - int result = 0; 3472 - 3473 - /* Leave IQK mode */ 3474 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00); 3475 - 3476 - /* Enable path A PA in TX IQK mode */ 3477 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 3478 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 3479 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 3480 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf117b); 3481 - 3482 - /* PA/PAD control by 0x56, and set = 0x0 */ 3483 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 3484 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 3485 - 3486 - /* Enter IQK mode */ 3487 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3488 - 3489 - /* TX IQK setting */ 3490 - rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 3491 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3492 - 3493 - /* path-A IQK setting */ 3494 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 3495 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 3496 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 3497 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3498 - 3499 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 3500 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160c1f); 3501 - 3502 - /* LO calibration setting */ 3503 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 3504 - 3505 - /* One shot, path A LOK & IQK */ 3506 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 3507 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3508 - 3509 - mdelay(10); 3510 - 3511 - /* Check failed */ 3512 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3513 - reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 3514 - reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 3515 - 3516 - if (!(reg_eac & BIT(28)) && 3517 - ((reg_e94 & 0x03ff0000) != 0x01420000) && 3518 - ((reg_e9c & 0x03ff0000) != 0x00420000)) { 3519 - result |= 0x01; 3520 - } else { 3521 - /* PA/PAD controlled by 0x0 */ 3522 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3523 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 3524 - goto out; 3525 - } 3526 - 3527 - val32 = 0x80007c00 | 3528 - (reg_e94 & 0x03ff0000) | ((reg_e9c >> 16) & 0x03ff); 3529 - rtl8xxxu_write32(priv, REG_TX_IQK, val32); 3530 - 3531 - /* Modify RX IQK mode table */ 3532 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3533 - 3534 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 3535 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 3536 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 3537 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7ffa); 3538 - 3539 - /* PA/PAD control by 0x56, and set = 0x0 */ 3540 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 3541 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 3542 - 3543 - /* Enter IQK mode */ 3544 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3545 - 3546 - /* IQK setting */ 3547 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3548 - 3549 - /* Path A IQK setting */ 3550 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 3551 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x18008c1c); 3552 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 3553 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3554 - 3555 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 3556 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 3557 - 3558 - /* LO calibration setting */ 3559 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 3560 - 3561 - /* One shot, path A LOK & IQK */ 3562 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 3563 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3564 - 3565 - mdelay(10); 3566 - 3567 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3568 - reg_ea4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_A_2); 3569 - 3570 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3571 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 3572 - 3573 - if (!(reg_eac & BIT(27)) && 3574 - ((reg_ea4 & 0x03ff0000) != 0x01320000) && 3575 - ((reg_eac & 0x03ff0000) != 0x00360000)) 3576 - result |= 0x02; 3577 - else 3578 - dev_warn(&priv->udev->dev, "%s: Path A RX IQK failed!\n", 3579 - __func__); 3580 - 3581 - out: 3582 - return result; 3583 - } 3584 - 3585 - static int rtl8192eu_iqk_path_b(struct rtl8xxxu_priv *priv) 3586 - { 3587 - u32 reg_eac, reg_eb4, reg_ebc; 3588 - int result = 0; 3589 - 3590 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3591 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00180); 3592 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3593 - 3594 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3595 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3596 - 3597 - /* Path B IQK setting */ 3598 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 3599 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 3600 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 3601 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3602 - 3603 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x821403e2); 3604 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160000); 3605 - 3606 - /* LO calibration setting */ 3607 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00492911); 3608 - 3609 - /* One shot, path A LOK & IQK */ 3610 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 3611 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3612 - 3613 - mdelay(1); 3614 - 3615 - /* Check failed */ 3616 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3617 - reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 3618 - reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 3619 - 3620 - if (!(reg_eac & BIT(31)) && 3621 - ((reg_eb4 & 0x03ff0000) != 0x01420000) && 3622 - ((reg_ebc & 0x03ff0000) != 0x00420000)) 3623 - result |= 0x01; 3624 - else 3625 - dev_warn(&priv->udev->dev, "%s: Path B IQK failed!\n", 3626 - __func__); 3627 - 3628 - return result; 3629 - } 3630 - 3631 - static int rtl8192eu_rx_iqk_path_b(struct rtl8xxxu_priv *priv) 3632 - { 3633 - u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc, val32; 3634 - int result = 0; 3635 - 3636 - /* Leave IQK mode */ 3637 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3638 - 3639 - /* Enable path A PA in TX IQK mode */ 3640 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 3641 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 3642 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 3643 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf117b); 3644 - 3645 - /* PA/PAD control by 0x56, and set = 0x0 */ 3646 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 3647 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 3648 - 3649 - /* Enter IQK mode */ 3650 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3651 - 3652 - /* TX IQK setting */ 3653 - rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 3654 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3655 - 3656 - /* path-A IQK setting */ 3657 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 3658 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 3659 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 3660 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 3661 - 3662 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82160c1f); 3663 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160c1f); 3664 - 3665 - /* LO calibration setting */ 3666 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 3667 - 3668 - /* One shot, path A LOK & IQK */ 3669 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 3670 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3671 - 3672 - mdelay(10); 3673 - 3674 - /* Check failed */ 3675 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3676 - reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 3677 - reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 3678 - 3679 - if (!(reg_eac & BIT(31)) && 3680 - ((reg_eb4 & 0x03ff0000) != 0x01420000) && 3681 - ((reg_ebc & 0x03ff0000) != 0x00420000)) { 3682 - result |= 0x01; 3683 - } else { 3684 - /* 3685 - * PA/PAD controlled by 0x0 3686 - * Vendor driver restores RF_A here which I believe is a bug 3687 - */ 3688 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3689 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 3690 - goto out; 3691 - } 3692 - 3693 - val32 = 0x80007c00 | 3694 - (reg_eb4 & 0x03ff0000) | ((reg_ebc >> 16) & 0x03ff); 3695 - rtl8xxxu_write32(priv, REG_TX_IQK, val32); 3696 - 3697 - /* Modify RX IQK mode table */ 3698 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3699 - 3700 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 3701 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 3702 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 3703 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf7ffa); 3704 - 3705 - /* PA/PAD control by 0x56, and set = 0x0 */ 3706 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 3707 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 3708 - 3709 - /* Enter IQK mode */ 3710 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3711 - 3712 - /* IQK setting */ 3713 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3714 - 3715 - /* Path A IQK setting */ 3716 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 3717 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 3718 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 3719 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x18008c1c); 3720 - 3721 - rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 3722 - rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 3723 - 3724 - /* LO calibration setting */ 3725 - rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 3726 - 3727 - /* One shot, path A LOK & IQK */ 3728 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 3729 - rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 3730 - 3731 - mdelay(10); 3732 - 3733 - reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 3734 - reg_ec4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_B_2); 3735 - reg_ecc = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_B_2); 3736 - 3737 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3738 - rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 3739 - 3740 - if (!(reg_eac & BIT(30)) && 3741 - ((reg_ec4 & 0x03ff0000) != 0x01320000) && 3742 - ((reg_ecc & 0x03ff0000) != 0x00360000)) 3743 - result |= 0x02; 3744 - else 3745 - dev_warn(&priv->udev->dev, "%s: Path B RX IQK failed!\n", 3746 - __func__); 3747 - 3748 4846 out: 3749 4847 return result; 3750 4848 } ··· 3307 5699 } 3308 5700 } 3309 5701 3310 - static void rtl8723bu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, 3311 - int result[][8], int t) 3312 - { 3313 - struct device *dev = &priv->udev->dev; 3314 - u32 i, val32; 3315 - int path_a_ok /*, path_b_ok */; 3316 - int retry = 2; 3317 - const u32 adda_regs[RTL8XXXU_ADDA_REGS] = { 3318 - REG_FPGA0_XCD_SWITCH_CTRL, REG_BLUETOOTH, 3319 - REG_RX_WAIT_CCA, REG_TX_CCK_RFON, 3320 - REG_TX_CCK_BBON, REG_TX_OFDM_RFON, 3321 - REG_TX_OFDM_BBON, REG_TX_TO_RX, 3322 - REG_TX_TO_TX, REG_RX_CCK, 3323 - REG_RX_OFDM, REG_RX_WAIT_RIFS, 3324 - REG_RX_TO_RX, REG_STANDBY, 3325 - REG_SLEEP, REG_PMPD_ANAEN 3326 - }; 3327 - const u32 iqk_mac_regs[RTL8XXXU_MAC_REGS] = { 3328 - REG_TXPAUSE, REG_BEACON_CTRL, 3329 - REG_BEACON_CTRL_1, REG_GPIO_MUXCFG 3330 - }; 3331 - const u32 iqk_bb_regs[RTL8XXXU_BB_REGS] = { 3332 - REG_OFDM0_TRX_PATH_ENABLE, REG_OFDM0_TR_MUX_PAR, 3333 - REG_FPGA0_XCD_RF_SW_CTRL, REG_CONFIG_ANT_A, REG_CONFIG_ANT_B, 3334 - REG_FPGA0_XAB_RF_SW_CTRL, REG_FPGA0_XA_RF_INT_OE, 3335 - REG_FPGA0_XB_RF_INT_OE, REG_FPGA0_RF_MODE 3336 - }; 3337 - u8 xa_agc = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1) & 0xff; 3338 - u8 xb_agc = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1) & 0xff; 3339 - 3340 - /* 3341 - * Note: IQ calibration must be performed after loading 3342 - * PHY_REG.txt , and radio_a, radio_b.txt 3343 - */ 3344 - 3345 - if (t == 0) { 3346 - /* Save ADDA parameters, turn Path A ADDA on */ 3347 - rtl8xxxu_save_regs(priv, adda_regs, priv->adda_backup, 3348 - RTL8XXXU_ADDA_REGS); 3349 - rtl8xxxu_save_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 3350 - rtl8xxxu_save_regs(priv, iqk_bb_regs, 3351 - priv->bb_backup, RTL8XXXU_BB_REGS); 3352 - } 3353 - 3354 - rtl8xxxu_path_adda_on(priv, adda_regs, true); 3355 - 3356 - /* MAC settings */ 3357 - rtl8xxxu_mac_calibration(priv, iqk_mac_regs, priv->mac_backup); 3358 - 3359 - val32 = rtl8xxxu_read32(priv, REG_CCK0_AFE_SETTING); 3360 - val32 |= 0x0f000000; 3361 - rtl8xxxu_write32(priv, REG_CCK0_AFE_SETTING, val32); 3362 - 3363 - rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, 0x03a05600); 3364 - rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 3365 - rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22204000); 3366 - 3367 - /* 3368 - * RX IQ calibration setting for 8723B D cut large current issue 3369 - * when leaving IPS 3370 - */ 3371 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3372 - val32 &= 0x000000ff; 3373 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3374 - 3375 - val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 3376 - val32 |= 0x80000; 3377 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 3378 - 3379 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 3380 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 3381 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7fb7); 3382 - 3383 - val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED); 3384 - val32 |= 0x20; 3385 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED, val32); 3386 - 3387 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_43, 0x60fbd); 3388 - 3389 - for (i = 0; i < retry; i++) { 3390 - path_a_ok = rtl8723bu_iqk_path_a(priv); 3391 - if (path_a_ok == 0x01) { 3392 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3393 - val32 &= 0x000000ff; 3394 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3395 - 3396 - val32 = rtl8xxxu_read32(priv, 3397 - REG_TX_POWER_BEFORE_IQK_A); 3398 - result[t][0] = (val32 >> 16) & 0x3ff; 3399 - val32 = rtl8xxxu_read32(priv, 3400 - REG_TX_POWER_AFTER_IQK_A); 3401 - result[t][1] = (val32 >> 16) & 0x3ff; 3402 - 3403 - break; 3404 - } 3405 - } 3406 - 3407 - if (!path_a_ok) 3408 - dev_dbg(dev, "%s: Path A TX IQK failed!\n", __func__); 3409 - 3410 - for (i = 0; i < retry; i++) { 3411 - path_a_ok = rtl8723bu_rx_iqk_path_a(priv); 3412 - if (path_a_ok == 0x03) { 3413 - val32 = rtl8xxxu_read32(priv, 3414 - REG_RX_POWER_BEFORE_IQK_A_2); 3415 - result[t][2] = (val32 >> 16) & 0x3ff; 3416 - val32 = rtl8xxxu_read32(priv, 3417 - REG_RX_POWER_AFTER_IQK_A_2); 3418 - result[t][3] = (val32 >> 16) & 0x3ff; 3419 - 3420 - break; 3421 - } 3422 - } 3423 - 3424 - if (!path_a_ok) 3425 - dev_dbg(dev, "%s: Path A RX IQK failed!\n", __func__); 3426 - 3427 - if (priv->tx_paths > 1) { 3428 - #if 1 3429 - dev_warn(dev, "%s: Path B not supported\n", __func__); 3430 - #else 3431 - 3432 - /* 3433 - * Path A into standby 3434 - */ 3435 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3436 - val32 &= 0x000000ff; 3437 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3438 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0x10000); 3439 - 3440 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3441 - val32 &= 0x000000ff; 3442 - val32 |= 0x80800000; 3443 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3444 - 3445 - /* Turn Path B ADDA on */ 3446 - rtl8xxxu_path_adda_on(priv, adda_regs, false); 3447 - 3448 - for (i = 0; i < retry; i++) { 3449 - path_b_ok = rtl8xxxu_iqk_path_b(priv); 3450 - if (path_b_ok == 0x03) { 3451 - val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 3452 - result[t][4] = (val32 >> 16) & 0x3ff; 3453 - val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 3454 - result[t][5] = (val32 >> 16) & 0x3ff; 3455 - break; 3456 - } 3457 - } 3458 - 3459 - if (!path_b_ok) 3460 - dev_dbg(dev, "%s: Path B IQK failed!\n", __func__); 3461 - 3462 - for (i = 0; i < retry; i++) { 3463 - path_b_ok = rtl8723bu_rx_iqk_path_b(priv); 3464 - if (path_a_ok == 0x03) { 3465 - val32 = rtl8xxxu_read32(priv, 3466 - REG_RX_POWER_BEFORE_IQK_B_2); 3467 - result[t][6] = (val32 >> 16) & 0x3ff; 3468 - val32 = rtl8xxxu_read32(priv, 3469 - REG_RX_POWER_AFTER_IQK_B_2); 3470 - result[t][7] = (val32 >> 16) & 0x3ff; 3471 - break; 3472 - } 3473 - } 3474 - 3475 - if (!path_b_ok) 3476 - dev_dbg(dev, "%s: Path B RX IQK failed!\n", __func__); 3477 - #endif 3478 - } 3479 - 3480 - /* Back to BB mode, load original value */ 3481 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 3482 - val32 &= 0x000000ff; 3483 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 3484 - 3485 - if (t) { 3486 - /* Reload ADDA power saving parameters */ 3487 - rtl8xxxu_restore_regs(priv, adda_regs, priv->adda_backup, 3488 - RTL8XXXU_ADDA_REGS); 3489 - 3490 - /* Reload MAC parameters */ 3491 - rtl8xxxu_restore_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 3492 - 3493 - /* Reload BB parameters */ 3494 - rtl8xxxu_restore_regs(priv, iqk_bb_regs, 3495 - priv->bb_backup, RTL8XXXU_BB_REGS); 3496 - 3497 - /* Restore RX initial gain */ 3498 - val32 = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1); 3499 - val32 &= 0xffffff00; 3500 - rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | 0x50); 3501 - rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | xa_agc); 3502 - 3503 - if (priv->tx_paths > 1) { 3504 - val32 = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1); 3505 - val32 &= 0xffffff00; 3506 - rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 3507 - val32 | 0x50); 3508 - rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 3509 - val32 | xb_agc); 3510 - } 3511 - 3512 - /* Load 0xe30 IQC default value */ 3513 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x01008c00); 3514 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x01008c00); 3515 - } 3516 - } 3517 - 3518 - static void rtl8192eu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, 3519 - int result[][8], int t) 3520 - { 3521 - struct device *dev = &priv->udev->dev; 3522 - u32 i, val32; 3523 - int path_a_ok, path_b_ok; 3524 - int retry = 2; 3525 - const u32 adda_regs[RTL8XXXU_ADDA_REGS] = { 3526 - REG_FPGA0_XCD_SWITCH_CTRL, REG_BLUETOOTH, 3527 - REG_RX_WAIT_CCA, REG_TX_CCK_RFON, 3528 - REG_TX_CCK_BBON, REG_TX_OFDM_RFON, 3529 - REG_TX_OFDM_BBON, REG_TX_TO_RX, 3530 - REG_TX_TO_TX, REG_RX_CCK, 3531 - REG_RX_OFDM, REG_RX_WAIT_RIFS, 3532 - REG_RX_TO_RX, REG_STANDBY, 3533 - REG_SLEEP, REG_PMPD_ANAEN 3534 - }; 3535 - const u32 iqk_mac_regs[RTL8XXXU_MAC_REGS] = { 3536 - REG_TXPAUSE, REG_BEACON_CTRL, 3537 - REG_BEACON_CTRL_1, REG_GPIO_MUXCFG 3538 - }; 3539 - const u32 iqk_bb_regs[RTL8XXXU_BB_REGS] = { 3540 - REG_OFDM0_TRX_PATH_ENABLE, REG_OFDM0_TR_MUX_PAR, 3541 - REG_FPGA0_XCD_RF_SW_CTRL, REG_CONFIG_ANT_A, REG_CONFIG_ANT_B, 3542 - REG_FPGA0_XAB_RF_SW_CTRL, REG_FPGA0_XA_RF_INT_OE, 3543 - REG_FPGA0_XB_RF_INT_OE, REG_CCK0_AFE_SETTING 3544 - }; 3545 - u8 xa_agc = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1) & 0xff; 3546 - u8 xb_agc = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1) & 0xff; 3547 - 3548 - /* 3549 - * Note: IQ calibration must be performed after loading 3550 - * PHY_REG.txt , and radio_a, radio_b.txt 3551 - */ 3552 - 3553 - if (t == 0) { 3554 - /* Save ADDA parameters, turn Path A ADDA on */ 3555 - rtl8xxxu_save_regs(priv, adda_regs, priv->adda_backup, 3556 - RTL8XXXU_ADDA_REGS); 3557 - rtl8xxxu_save_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 3558 - rtl8xxxu_save_regs(priv, iqk_bb_regs, 3559 - priv->bb_backup, RTL8XXXU_BB_REGS); 3560 - } 3561 - 3562 - rtl8xxxu_path_adda_on(priv, adda_regs, true); 3563 - 3564 - /* MAC settings */ 3565 - rtl8xxxu_mac_calibration(priv, iqk_mac_regs, priv->mac_backup); 3566 - 3567 - val32 = rtl8xxxu_read32(priv, REG_CCK0_AFE_SETTING); 3568 - val32 |= 0x0f000000; 3569 - rtl8xxxu_write32(priv, REG_CCK0_AFE_SETTING, val32); 3570 - 3571 - rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, 0x03a05600); 3572 - rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 3573 - rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22208200); 3574 - 3575 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_XAB_RF_SW_CTRL); 3576 - val32 |= (FPGA0_RF_PAPE | (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); 3577 - rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 3578 - 3579 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_RF_INT_OE); 3580 - val32 |= BIT(10); 3581 - rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, val32); 3582 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_XB_RF_INT_OE); 3583 - val32 |= BIT(10); 3584 - rtl8xxxu_write32(priv, REG_FPGA0_XB_RF_INT_OE, val32); 3585 - 3586 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3587 - rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 3588 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3589 - 3590 - for (i = 0; i < retry; i++) { 3591 - path_a_ok = rtl8192eu_iqk_path_a(priv); 3592 - if (path_a_ok == 0x01) { 3593 - val32 = rtl8xxxu_read32(priv, 3594 - REG_TX_POWER_BEFORE_IQK_A); 3595 - result[t][0] = (val32 >> 16) & 0x3ff; 3596 - val32 = rtl8xxxu_read32(priv, 3597 - REG_TX_POWER_AFTER_IQK_A); 3598 - result[t][1] = (val32 >> 16) & 0x3ff; 3599 - 3600 - break; 3601 - } 3602 - } 3603 - 3604 - if (!path_a_ok) 3605 - dev_dbg(dev, "%s: Path A TX IQK failed!\n", __func__); 3606 - 3607 - for (i = 0; i < retry; i++) { 3608 - path_a_ok = rtl8192eu_rx_iqk_path_a(priv); 3609 - if (path_a_ok == 0x03) { 3610 - val32 = rtl8xxxu_read32(priv, 3611 - REG_RX_POWER_BEFORE_IQK_A_2); 3612 - result[t][2] = (val32 >> 16) & 0x3ff; 3613 - val32 = rtl8xxxu_read32(priv, 3614 - REG_RX_POWER_AFTER_IQK_A_2); 3615 - result[t][3] = (val32 >> 16) & 0x3ff; 3616 - 3617 - break; 3618 - } 3619 - } 3620 - 3621 - if (!path_a_ok) 3622 - dev_dbg(dev, "%s: Path A RX IQK failed!\n", __func__); 3623 - 3624 - if (priv->rf_paths > 1) { 3625 - /* Path A into standby */ 3626 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3627 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0x10000); 3628 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3629 - 3630 - /* Turn Path B ADDA on */ 3631 - rtl8xxxu_path_adda_on(priv, adda_regs, false); 3632 - 3633 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 3634 - rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 3635 - rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 3636 - 3637 - for (i = 0; i < retry; i++) { 3638 - path_b_ok = rtl8192eu_iqk_path_b(priv); 3639 - if (path_b_ok == 0x01) { 3640 - val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 3641 - result[t][4] = (val32 >> 16) & 0x3ff; 3642 - val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 3643 - result[t][5] = (val32 >> 16) & 0x3ff; 3644 - break; 3645 - } 3646 - } 3647 - 3648 - if (!path_b_ok) 3649 - dev_dbg(dev, "%s: Path B IQK failed!\n", __func__); 3650 - 3651 - for (i = 0; i < retry; i++) { 3652 - path_b_ok = rtl8192eu_rx_iqk_path_b(priv); 3653 - if (path_a_ok == 0x03) { 3654 - val32 = rtl8xxxu_read32(priv, 3655 - REG_RX_POWER_BEFORE_IQK_B_2); 3656 - result[t][6] = (val32 >> 16) & 0x3ff; 3657 - val32 = rtl8xxxu_read32(priv, 3658 - REG_RX_POWER_AFTER_IQK_B_2); 3659 - result[t][7] = (val32 >> 16) & 0x3ff; 3660 - break; 3661 - } 3662 - } 3663 - 3664 - if (!path_b_ok) 3665 - dev_dbg(dev, "%s: Path B RX IQK failed!\n", __func__); 3666 - } 3667 - 3668 - /* Back to BB mode, load original value */ 3669 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 3670 - 3671 - if (t) { 3672 - /* Reload ADDA power saving parameters */ 3673 - rtl8xxxu_restore_regs(priv, adda_regs, priv->adda_backup, 3674 - RTL8XXXU_ADDA_REGS); 3675 - 3676 - /* Reload MAC parameters */ 3677 - rtl8xxxu_restore_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 3678 - 3679 - /* Reload BB parameters */ 3680 - rtl8xxxu_restore_regs(priv, iqk_bb_regs, 3681 - priv->bb_backup, RTL8XXXU_BB_REGS); 3682 - 3683 - /* Restore RX initial gain */ 3684 - val32 = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1); 3685 - val32 &= 0xffffff00; 3686 - rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | 0x50); 3687 - rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | xa_agc); 3688 - 3689 - if (priv->rf_paths > 1) { 3690 - val32 = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1); 3691 - val32 &= 0xffffff00; 3692 - rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 3693 - val32 | 0x50); 3694 - rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 3695 - val32 | xb_agc); 3696 - } 3697 - 3698 - /* Load 0xe30 IQC default value */ 3699 - rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x01008c00); 3700 - rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x01008c00); 3701 - } 3702 - } 3703 - 3704 - static void rtl8xxxu_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start) 5702 + void rtl8xxxu_gen2_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start) 3705 5703 { 3706 5704 struct h2c_cmd h2c; 3707 - 3708 - if (priv->fops->mbox_ext_width < 4) 3709 - return; 3710 5705 3711 5706 memset(&h2c, 0, sizeof(struct h2c_cmd)); 3712 5707 h2c.bt_wlan_calibration.cmd = H2C_8723B_BT_WLAN_CALIBRATION; 3713 5708 h2c.bt_wlan_calibration.data = start; 3714 5709 3715 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.bt_wlan_calibration)); 5710 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.bt_wlan_calibration)); 3716 5711 } 3717 5712 3718 - static void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 5713 + void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 3719 5714 { 3720 5715 struct device *dev = &priv->udev->dev; 3721 5716 int result[4][8]; /* last is final result */ ··· 3328 6117 u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; 3329 6118 s32 reg_tmp = 0; 3330 6119 bool simu; 3331 - 3332 - rtl8xxxu_prepare_calibrate(priv, 1); 3333 6120 3334 6121 memset(result, 0, sizeof(result)); 3335 6122 candidate = -1; ··· 3411 6202 candidate, (reg_ea4 == 0)); 3412 6203 3413 6204 if (priv->tx_paths > 1 && reg_eb4) 3414 - rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 3415 - candidate, (reg_ec4 == 0)); 3416 - 3417 - rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 3418 - priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 3419 - 3420 - rtl8xxxu_prepare_calibrate(priv, 0); 3421 - } 3422 - 3423 - static void rtl8723bu_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 3424 - { 3425 - struct device *dev = &priv->udev->dev; 3426 - int result[4][8]; /* last is final result */ 3427 - int i, candidate; 3428 - bool path_a_ok, path_b_ok; 3429 - u32 reg_e94, reg_e9c, reg_ea4, reg_eac; 3430 - u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; 3431 - u32 val32, bt_control; 3432 - s32 reg_tmp = 0; 3433 - bool simu; 3434 - 3435 - rtl8xxxu_prepare_calibrate(priv, 1); 3436 - 3437 - memset(result, 0, sizeof(result)); 3438 - candidate = -1; 3439 - 3440 - path_a_ok = false; 3441 - path_b_ok = false; 3442 - 3443 - bt_control = rtl8xxxu_read32(priv, REG_BT_CONTROL_8723BU); 3444 - 3445 - for (i = 0; i < 3; i++) { 3446 - rtl8723bu_phy_iqcalibrate(priv, result, i); 3447 - 3448 - if (i == 1) { 3449 - simu = rtl8xxxu_gen2_simularity_compare(priv, 3450 - result, 0, 1); 3451 - if (simu) { 3452 - candidate = 0; 3453 - break; 3454 - } 3455 - } 3456 - 3457 - if (i == 2) { 3458 - simu = rtl8xxxu_gen2_simularity_compare(priv, 3459 - result, 0, 2); 3460 - if (simu) { 3461 - candidate = 0; 3462 - break; 3463 - } 3464 - 3465 - simu = rtl8xxxu_gen2_simularity_compare(priv, 3466 - result, 1, 2); 3467 - if (simu) { 3468 - candidate = 1; 3469 - } else { 3470 - for (i = 0; i < 8; i++) 3471 - reg_tmp += result[3][i]; 3472 - 3473 - if (reg_tmp) 3474 - candidate = 3; 3475 - else 3476 - candidate = -1; 3477 - } 3478 - } 3479 - } 3480 - 3481 - for (i = 0; i < 4; i++) { 3482 - reg_e94 = result[i][0]; 3483 - reg_e9c = result[i][1]; 3484 - reg_ea4 = result[i][2]; 3485 - reg_eac = result[i][3]; 3486 - reg_eb4 = result[i][4]; 3487 - reg_ebc = result[i][5]; 3488 - reg_ec4 = result[i][6]; 3489 - reg_ecc = result[i][7]; 3490 - } 3491 - 3492 - if (candidate >= 0) { 3493 - reg_e94 = result[candidate][0]; 3494 - priv->rege94 = reg_e94; 3495 - reg_e9c = result[candidate][1]; 3496 - priv->rege9c = reg_e9c; 3497 - reg_ea4 = result[candidate][2]; 3498 - reg_eac = result[candidate][3]; 3499 - reg_eb4 = result[candidate][4]; 3500 - priv->regeb4 = reg_eb4; 3501 - reg_ebc = result[candidate][5]; 3502 - priv->regebc = reg_ebc; 3503 - reg_ec4 = result[candidate][6]; 3504 - reg_ecc = result[candidate][7]; 3505 - dev_dbg(dev, "%s: candidate is %x\n", __func__, candidate); 3506 - dev_dbg(dev, 3507 - "%s: e94 =%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x " 3508 - "ecc=%x\n ", __func__, reg_e94, reg_e9c, 3509 - reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc); 3510 - path_a_ok = true; 3511 - path_b_ok = true; 3512 - } else { 3513 - reg_e94 = reg_eb4 = priv->rege94 = priv->regeb4 = 0x100; 3514 - reg_e9c = reg_ebc = priv->rege9c = priv->regebc = 0x0; 3515 - } 3516 - 3517 - if (reg_e94 && candidate >= 0) 3518 - rtl8xxxu_fill_iqk_matrix_a(priv, path_a_ok, result, 3519 - candidate, (reg_ea4 == 0)); 3520 - 3521 - if (priv->tx_paths > 1 && reg_eb4) 3522 - rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 3523 - candidate, (reg_ec4 == 0)); 3524 - 3525 - rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 3526 - priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 3527 - 3528 - rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, bt_control); 3529 - 3530 - val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 3531 - val32 |= 0x80000; 3532 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 3533 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x18000); 3534 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 3535 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xe6177); 3536 - val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED); 3537 - val32 |= 0x20; 3538 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED, val32); 3539 - rtl8xxxu_write_rfreg(priv, RF_A, 0x43, 0x300bd); 3540 - 3541 - if (priv->rf_paths > 1) 3542 - dev_dbg(dev, "%s: 8723BU 2T not supported\n", __func__); 3543 - 3544 - rtl8xxxu_prepare_calibrate(priv, 0); 3545 - } 3546 - 3547 - static void rtl8192eu_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 3548 - { 3549 - struct device *dev = &priv->udev->dev; 3550 - int result[4][8]; /* last is final result */ 3551 - int i, candidate; 3552 - bool path_a_ok, path_b_ok; 3553 - u32 reg_e94, reg_e9c, reg_ea4, reg_eac; 3554 - u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; 3555 - bool simu; 3556 - 3557 - memset(result, 0, sizeof(result)); 3558 - candidate = -1; 3559 - 3560 - path_a_ok = false; 3561 - path_b_ok = false; 3562 - 3563 - for (i = 0; i < 3; i++) { 3564 - rtl8192eu_phy_iqcalibrate(priv, result, i); 3565 - 3566 - if (i == 1) { 3567 - simu = rtl8xxxu_gen2_simularity_compare(priv, 3568 - result, 0, 1); 3569 - if (simu) { 3570 - candidate = 0; 3571 - break; 3572 - } 3573 - } 3574 - 3575 - if (i == 2) { 3576 - simu = rtl8xxxu_gen2_simularity_compare(priv, 3577 - result, 0, 2); 3578 - if (simu) { 3579 - candidate = 0; 3580 - break; 3581 - } 3582 - 3583 - simu = rtl8xxxu_gen2_simularity_compare(priv, 3584 - result, 1, 2); 3585 - if (simu) 3586 - candidate = 1; 3587 - else 3588 - candidate = 3; 3589 - } 3590 - } 3591 - 3592 - for (i = 0; i < 4; i++) { 3593 - reg_e94 = result[i][0]; 3594 - reg_e9c = result[i][1]; 3595 - reg_ea4 = result[i][2]; 3596 - reg_eac = result[i][3]; 3597 - reg_eb4 = result[i][4]; 3598 - reg_ebc = result[i][5]; 3599 - reg_ec4 = result[i][6]; 3600 - reg_ecc = result[i][7]; 3601 - } 3602 - 3603 - if (candidate >= 0) { 3604 - reg_e94 = result[candidate][0]; 3605 - priv->rege94 = reg_e94; 3606 - reg_e9c = result[candidate][1]; 3607 - priv->rege9c = reg_e9c; 3608 - reg_ea4 = result[candidate][2]; 3609 - reg_eac = result[candidate][3]; 3610 - reg_eb4 = result[candidate][4]; 3611 - priv->regeb4 = reg_eb4; 3612 - reg_ebc = result[candidate][5]; 3613 - priv->regebc = reg_ebc; 3614 - reg_ec4 = result[candidate][6]; 3615 - reg_ecc = result[candidate][7]; 3616 - dev_dbg(dev, "%s: candidate is %x\n", __func__, candidate); 3617 - dev_dbg(dev, 3618 - "%s: e94 =%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x " 3619 - "ecc=%x\n ", __func__, reg_e94, reg_e9c, 3620 - reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc); 3621 - path_a_ok = true; 3622 - path_b_ok = true; 3623 - } else { 3624 - reg_e94 = reg_eb4 = priv->rege94 = priv->regeb4 = 0x100; 3625 - reg_e9c = reg_ebc = priv->rege9c = priv->regebc = 0x0; 3626 - } 3627 - 3628 - if (reg_e94 && candidate >= 0) 3629 - rtl8xxxu_fill_iqk_matrix_a(priv, path_a_ok, result, 3630 - candidate, (reg_ea4 == 0)); 3631 - 3632 - if (priv->rf_paths > 1) 3633 6205 rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 3634 6206 candidate, (reg_ec4 == 0)); 3635 6207 ··· 3586 6596 return ret; 3587 6597 } 3588 6598 3589 - static int rtl8723bu_active_to_emu(struct rtl8xxxu_priv *priv) 3590 - { 3591 - u8 val8; 3592 - u16 val16; 3593 - u32 val32; 3594 - int count, ret = 0; 3595 - 3596 - /* Turn off RF */ 3597 - rtl8xxxu_write8(priv, REG_RF_CTRL, 0); 3598 - 3599 - /* Enable rising edge triggering interrupt */ 3600 - val16 = rtl8xxxu_read16(priv, REG_GPIO_INTM); 3601 - val16 &= ~GPIO_INTM_EDGE_TRIG_IRQ; 3602 - rtl8xxxu_write16(priv, REG_GPIO_INTM, val16); 3603 - 3604 - /* Release WLON reset 0x04[16]= 1*/ 3605 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3606 - val32 |= APS_FSMCO_WLON_RESET; 3607 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3608 - 3609 - /* 0x0005[1] = 1 turn off MAC by HW state machine*/ 3610 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3611 - val8 |= BIT(1); 3612 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3613 - 3614 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 3615 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3616 - if ((val8 & BIT(1)) == 0) 3617 - break; 3618 - udelay(10); 3619 - } 3620 - 3621 - if (!count) { 3622 - dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n", 3623 - __func__); 3624 - ret = -EBUSY; 3625 - goto exit; 3626 - } 3627 - 3628 - /* Enable BT control XTAL setting */ 3629 - val8 = rtl8xxxu_read8(priv, REG_AFE_MISC); 3630 - val8 &= ~AFE_MISC_WL_XTAL_CTRL; 3631 - rtl8xxxu_write8(priv, REG_AFE_MISC, val8); 3632 - 3633 - /* 0x0000[5] = 1 analog Ips to digital, 1:isolation */ 3634 - val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 3635 - val8 |= SYS_ISO_ANALOG_IPS; 3636 - rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 3637 - 3638 - /* 0x0020[0] = 0 disable LDOA12 MACRO block*/ 3639 - val8 = rtl8xxxu_read8(priv, REG_LDOA15_CTRL); 3640 - val8 &= ~LDOA15_ENABLE; 3641 - rtl8xxxu_write8(priv, REG_LDOA15_CTRL, val8); 3642 - 3643 - exit: 3644 - return ret; 3645 - } 3646 - 3647 - static int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv *priv) 6599 + int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv *priv) 3648 6600 { 3649 6601 u8 val8; 3650 6602 u8 val32; ··· 3642 6710 return ret; 3643 6711 } 3644 6712 3645 - static void rtl8723a_disabled_to_emu(struct rtl8xxxu_priv *priv) 6713 + void rtl8xxxu_disabled_to_emu(struct rtl8xxxu_priv *priv) 3646 6714 { 3647 6715 u8 val8; 3648 6716 ··· 3660 6728 val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3661 6729 val8 &= ~(BIT(3) | BIT(4)); 3662 6730 rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3663 - } 3664 - 3665 - static void rtl8192e_disabled_to_emu(struct rtl8xxxu_priv *priv) 3666 - { 3667 - u8 val8; 3668 - 3669 - /* Clear suspend enable and power down enable*/ 3670 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3671 - val8 &= ~(BIT(3) | BIT(4)); 3672 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3673 - } 3674 - 3675 - static int rtl8192e_emu_to_active(struct rtl8xxxu_priv *priv) 3676 - { 3677 - u8 val8; 3678 - u32 val32; 3679 - int count, ret = 0; 3680 - 3681 - /* disable HWPDN 0x04[15]=0*/ 3682 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3683 - val8 &= ~BIT(7); 3684 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3685 - 3686 - /* disable SW LPS 0x04[10]= 0 */ 3687 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3688 - val8 &= ~BIT(2); 3689 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3690 - 3691 - /* disable WL suspend*/ 3692 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3693 - val8 &= ~(BIT(3) | BIT(4)); 3694 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3695 - 3696 - /* wait till 0x04[17] = 1 power ready*/ 3697 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 3698 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3699 - if (val32 & BIT(17)) 3700 - break; 3701 - 3702 - udelay(10); 3703 - } 3704 - 3705 - if (!count) { 3706 - ret = -EBUSY; 3707 - goto exit; 3708 - } 3709 - 3710 - /* We should be able to optimize the following three entries into one */ 3711 - 3712 - /* release WLON reset 0x04[16]= 1*/ 3713 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); 3714 - val8 |= BIT(0); 3715 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); 3716 - 3717 - /* set, then poll until 0 */ 3718 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3719 - val32 |= APS_FSMCO_MAC_ENABLE; 3720 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3721 - 3722 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 3723 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3724 - if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { 3725 - ret = 0; 3726 - break; 3727 - } 3728 - udelay(10); 3729 - } 3730 - 3731 - if (!count) { 3732 - ret = -EBUSY; 3733 - goto exit; 3734 - } 3735 - 3736 - exit: 3737 - return ret; 3738 - } 3739 - 3740 - static int rtl8723a_emu_to_active(struct rtl8xxxu_priv *priv) 3741 - { 3742 - u8 val8; 3743 - u32 val32; 3744 - int count, ret = 0; 3745 - 3746 - /* 0x20[0] = 1 enable LDOA12 MACRO block for all interface*/ 3747 - val8 = rtl8xxxu_read8(priv, REG_LDOA15_CTRL); 3748 - val8 |= LDOA15_ENABLE; 3749 - rtl8xxxu_write8(priv, REG_LDOA15_CTRL, val8); 3750 - 3751 - /* 0x67[0] = 0 to disable BT_GPS_SEL pins*/ 3752 - val8 = rtl8xxxu_read8(priv, 0x0067); 3753 - val8 &= ~BIT(4); 3754 - rtl8xxxu_write8(priv, 0x0067, val8); 3755 - 3756 - mdelay(1); 3757 - 3758 - /* 0x00[5] = 0 release analog Ips to digital, 1:isolation */ 3759 - val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 3760 - val8 &= ~SYS_ISO_ANALOG_IPS; 3761 - rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 3762 - 3763 - /* disable SW LPS 0x04[10]= 0 */ 3764 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3765 - val8 &= ~BIT(2); 3766 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3767 - 3768 - /* wait till 0x04[17] = 1 power ready*/ 3769 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 3770 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3771 - if (val32 & BIT(17)) 3772 - break; 3773 - 3774 - udelay(10); 3775 - } 3776 - 3777 - if (!count) { 3778 - ret = -EBUSY; 3779 - goto exit; 3780 - } 3781 - 3782 - /* We should be able to optimize the following three entries into one */ 3783 - 3784 - /* release WLON reset 0x04[16]= 1*/ 3785 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); 3786 - val8 |= BIT(0); 3787 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); 3788 - 3789 - /* disable HWPDN 0x04[15]= 0*/ 3790 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3791 - val8 &= ~BIT(7); 3792 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3793 - 3794 - /* disable WL suspend*/ 3795 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3796 - val8 &= ~(BIT(3) | BIT(4)); 3797 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3798 - 3799 - /* set, then poll until 0 */ 3800 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3801 - val32 |= APS_FSMCO_MAC_ENABLE; 3802 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3803 - 3804 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 3805 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3806 - if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { 3807 - ret = 0; 3808 - break; 3809 - } 3810 - udelay(10); 3811 - } 3812 - 3813 - if (!count) { 3814 - ret = -EBUSY; 3815 - goto exit; 3816 - } 3817 - 3818 - /* 0x4C[23] = 0x4E[7] = 1, switch DPDT_SEL_P output from WL BB */ 3819 - /* 3820 - * Note: Vendor driver actually clears this bit, despite the 3821 - * documentation claims it's being set! 3822 - */ 3823 - val8 = rtl8xxxu_read8(priv, REG_LEDCFG2); 3824 - val8 |= LEDCFG2_DPDT_SELECT; 3825 - val8 &= ~LEDCFG2_DPDT_SELECT; 3826 - rtl8xxxu_write8(priv, REG_LEDCFG2, val8); 3827 - 3828 - exit: 3829 - return ret; 3830 - } 3831 - 3832 - static int rtl8723b_emu_to_active(struct rtl8xxxu_priv *priv) 3833 - { 3834 - u8 val8; 3835 - u32 val32; 3836 - int count, ret = 0; 3837 - 3838 - /* 0x20[0] = 1 enable LDOA12 MACRO block for all interface */ 3839 - val8 = rtl8xxxu_read8(priv, REG_LDOA15_CTRL); 3840 - val8 |= LDOA15_ENABLE; 3841 - rtl8xxxu_write8(priv, REG_LDOA15_CTRL, val8); 3842 - 3843 - /* 0x67[0] = 0 to disable BT_GPS_SEL pins*/ 3844 - val8 = rtl8xxxu_read8(priv, 0x0067); 3845 - val8 &= ~BIT(4); 3846 - rtl8xxxu_write8(priv, 0x0067, val8); 3847 - 3848 - mdelay(1); 3849 - 3850 - /* 0x00[5] = 0 release analog Ips to digital, 1:isolation */ 3851 - val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 3852 - val8 &= ~SYS_ISO_ANALOG_IPS; 3853 - rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 3854 - 3855 - /* Disable SW LPS 0x04[10]= 0 */ 3856 - val32 = rtl8xxxu_read8(priv, REG_APS_FSMCO); 3857 - val32 &= ~APS_FSMCO_SW_LPS; 3858 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3859 - 3860 - /* Wait until 0x04[17] = 1 power ready */ 3861 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 3862 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3863 - if (val32 & BIT(17)) 3864 - break; 3865 - 3866 - udelay(10); 3867 - } 3868 - 3869 - if (!count) { 3870 - ret = -EBUSY; 3871 - goto exit; 3872 - } 3873 - 3874 - /* We should be able to optimize the following three entries into one */ 3875 - 3876 - /* Release WLON reset 0x04[16]= 1*/ 3877 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3878 - val32 |= APS_FSMCO_WLON_RESET; 3879 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3880 - 3881 - /* Disable HWPDN 0x04[15]= 0*/ 3882 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3883 - val32 &= ~APS_FSMCO_HW_POWERDOWN; 3884 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3885 - 3886 - /* Disable WL suspend*/ 3887 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3888 - val32 &= ~(APS_FSMCO_HW_SUSPEND | APS_FSMCO_PCIE); 3889 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3890 - 3891 - /* Set, then poll until 0 */ 3892 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3893 - val32 |= APS_FSMCO_MAC_ENABLE; 3894 - rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 3895 - 3896 - for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 3897 - val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 3898 - if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { 3899 - ret = 0; 3900 - break; 3901 - } 3902 - udelay(10); 3903 - } 3904 - 3905 - if (!count) { 3906 - ret = -EBUSY; 3907 - goto exit; 3908 - } 3909 - 3910 - /* Enable WL control XTAL setting */ 3911 - val8 = rtl8xxxu_read8(priv, REG_AFE_MISC); 3912 - val8 |= AFE_MISC_WL_XTAL_CTRL; 3913 - rtl8xxxu_write8(priv, REG_AFE_MISC, val8); 3914 - 3915 - /* Enable falling edge triggering interrupt */ 3916 - val8 = rtl8xxxu_read8(priv, REG_GPIO_INTM + 1); 3917 - val8 |= BIT(1); 3918 - rtl8xxxu_write8(priv, REG_GPIO_INTM + 1, val8); 3919 - 3920 - /* Enable GPIO9 interrupt mode */ 3921 - val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL_2 + 1); 3922 - val8 |= BIT(1); 3923 - rtl8xxxu_write8(priv, REG_GPIO_IO_SEL_2 + 1, val8); 3924 - 3925 - /* Enable GPIO9 input mode */ 3926 - val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL_2); 3927 - val8 &= ~BIT(1); 3928 - rtl8xxxu_write8(priv, REG_GPIO_IO_SEL_2, val8); 3929 - 3930 - /* Enable HSISR GPIO[C:0] interrupt */ 3931 - val8 = rtl8xxxu_read8(priv, REG_HSIMR); 3932 - val8 |= BIT(0); 3933 - rtl8xxxu_write8(priv, REG_HSIMR, val8); 3934 - 3935 - /* Enable HSISR GPIO9 interrupt */ 3936 - val8 = rtl8xxxu_read8(priv, REG_HSIMR + 2); 3937 - val8 |= BIT(1); 3938 - rtl8xxxu_write8(priv, REG_HSIMR + 2, val8); 3939 - 3940 - val8 = rtl8xxxu_read8(priv, REG_MULTI_FUNC_CTRL); 3941 - val8 |= MULTI_WIFI_HW_ROF_EN; 3942 - rtl8xxxu_write8(priv, REG_MULTI_FUNC_CTRL, val8); 3943 - 3944 - /* For GPIO9 internal pull high setting BIT(14) */ 3945 - val8 = rtl8xxxu_read8(priv, REG_MULTI_FUNC_CTRL + 1); 3946 - val8 |= BIT(6); 3947 - rtl8xxxu_write8(priv, REG_MULTI_FUNC_CTRL + 1, val8); 3948 - 3949 - exit: 3950 - return ret; 3951 6731 } 3952 6732 3953 6733 static int rtl8xxxu_emu_to_disabled(struct rtl8xxxu_priv *priv) ··· 3687 7043 return 0; 3688 7044 } 3689 7045 3690 - static int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv *priv) 7046 + int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv *priv) 3691 7047 { 3692 7048 struct device *dev = &priv->udev->dev; 3693 7049 u32 val32; ··· 3720 7076 return retval; 3721 7077 } 3722 7078 3723 - static void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv) 7079 + void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv) 3724 7080 { 3725 7081 /* Fix USB interface interference issue */ 3726 7082 rtl8xxxu_write8(priv, 0xfe40, 0xe0); ··· 3755 7111 } 3756 7112 } 3757 7113 3758 - static void rtl8xxxu_gen2_usb_quirks(struct rtl8xxxu_priv *priv) 7114 + void rtl8xxxu_gen2_usb_quirks(struct rtl8xxxu_priv *priv) 3759 7115 { 3760 7116 u32 val32; 3761 7117 ··· 3764 7120 rtl8xxxu_write32(priv, REG_TXDMA_OFFSET_CHK, val32); 3765 7121 } 3766 7122 3767 - static int rtl8723au_power_on(struct rtl8xxxu_priv *priv) 3768 - { 3769 - u8 val8; 3770 - u16 val16; 3771 - u32 val32; 3772 - int ret; 3773 - 3774 - /* 3775 - * RSV_CTRL 0x001C[7:0] = 0x00, unlock ISO/CLK/Power control register 3776 - */ 3777 - rtl8xxxu_write8(priv, REG_RSV_CTRL, 0x0); 3778 - 3779 - rtl8723a_disabled_to_emu(priv); 3780 - 3781 - ret = rtl8723a_emu_to_active(priv); 3782 - if (ret) 3783 - goto exit; 3784 - 3785 - /* 3786 - * 0x0004[19] = 1, reset 8051 3787 - */ 3788 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); 3789 - val8 |= BIT(3); 3790 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); 3791 - 3792 - /* 3793 - * Enable MAC DMA/WMAC/SCHEDULE/SEC block 3794 - * Set CR bit10 to enable 32k calibration. 3795 - */ 3796 - val16 = rtl8xxxu_read16(priv, REG_CR); 3797 - val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 3798 - CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | 3799 - CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | 3800 - CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | 3801 - CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); 3802 - rtl8xxxu_write16(priv, REG_CR, val16); 3803 - 3804 - /* For EFuse PG */ 3805 - val32 = rtl8xxxu_read32(priv, REG_EFUSE_CTRL); 3806 - val32 &= ~(BIT(28) | BIT(29) | BIT(30)); 3807 - val32 |= (0x06 << 28); 3808 - rtl8xxxu_write32(priv, REG_EFUSE_CTRL, val32); 3809 - exit: 3810 - return ret; 3811 - } 3812 - 3813 - static int rtl8723bu_power_on(struct rtl8xxxu_priv *priv) 3814 - { 3815 - u8 val8; 3816 - u16 val16; 3817 - u32 val32; 3818 - int ret; 3819 - 3820 - rtl8723a_disabled_to_emu(priv); 3821 - 3822 - ret = rtl8723b_emu_to_active(priv); 3823 - if (ret) 3824 - goto exit; 3825 - 3826 - /* 3827 - * Enable MAC DMA/WMAC/SCHEDULE/SEC block 3828 - * Set CR bit10 to enable 32k calibration. 3829 - */ 3830 - val16 = rtl8xxxu_read16(priv, REG_CR); 3831 - val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 3832 - CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | 3833 - CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | 3834 - CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | 3835 - CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); 3836 - rtl8xxxu_write16(priv, REG_CR, val16); 3837 - 3838 - /* 3839 - * BT coexist power on settings. This is identical for 1 and 2 3840 - * antenna parts. 3841 - */ 3842 - rtl8xxxu_write8(priv, REG_PAD_CTRL1 + 3, 0x20); 3843 - 3844 - val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3845 - val16 |= SYS_FUNC_BBRSTB | SYS_FUNC_BB_GLB_RSTN; 3846 - rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3847 - 3848 - rtl8xxxu_write8(priv, REG_BT_CONTROL_8723BU + 1, 0x18); 3849 - rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 3850 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 3851 - /* Antenna inverse */ 3852 - rtl8xxxu_write8(priv, 0xfe08, 0x01); 3853 - 3854 - val16 = rtl8xxxu_read16(priv, REG_PWR_DATA); 3855 - val16 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 3856 - rtl8xxxu_write16(priv, REG_PWR_DATA, val16); 3857 - 3858 - val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 3859 - val32 |= LEDCFG0_DPDT_SELECT; 3860 - rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 3861 - 3862 - val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 3863 - val8 &= ~PAD_CTRL1_SW_DPDT_SEL_DATA; 3864 - rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 3865 - exit: 3866 - return ret; 3867 - } 3868 - 3869 - #ifdef CONFIG_RTL8XXXU_UNTESTED 3870 - 3871 - static int rtl8192cu_power_on(struct rtl8xxxu_priv *priv) 3872 - { 3873 - u8 val8; 3874 - u16 val16; 3875 - u32 val32; 3876 - int i; 3877 - 3878 - for (i = 100; i; i--) { 3879 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO); 3880 - if (val8 & APS_FSMCO_PFM_ALDN) 3881 - break; 3882 - } 3883 - 3884 - if (!i) { 3885 - pr_info("%s: Poll failed\n", __func__); 3886 - return -ENODEV; 3887 - } 3888 - 3889 - /* 3890 - * RSV_CTRL 0x001C[7:0] = 0x00, unlock ISO/CLK/Power control register 3891 - */ 3892 - rtl8xxxu_write8(priv, REG_RSV_CTRL, 0x0); 3893 - rtl8xxxu_write8(priv, REG_SPS0_CTRL, 0x2b); 3894 - udelay(100); 3895 - 3896 - val8 = rtl8xxxu_read8(priv, REG_LDOV12D_CTRL); 3897 - if (!(val8 & LDOV12D_ENABLE)) { 3898 - pr_info("%s: Enabling LDOV12D (%02x)\n", __func__, val8); 3899 - val8 |= LDOV12D_ENABLE; 3900 - rtl8xxxu_write8(priv, REG_LDOV12D_CTRL, val8); 3901 - 3902 - udelay(100); 3903 - 3904 - val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 3905 - val8 &= ~SYS_ISO_MD2PP; 3906 - rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 3907 - } 3908 - 3909 - /* 3910 - * Auto enable WLAN 3911 - */ 3912 - val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); 3913 - val16 |= APS_FSMCO_MAC_ENABLE; 3914 - rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); 3915 - 3916 - for (i = 1000; i; i--) { 3917 - val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); 3918 - if (!(val16 & APS_FSMCO_MAC_ENABLE)) 3919 - break; 3920 - } 3921 - if (!i) { 3922 - pr_info("%s: FSMCO_MAC_ENABLE poll failed\n", __func__); 3923 - return -EBUSY; 3924 - } 3925 - 3926 - /* 3927 - * Enable radio, GPIO, LED 3928 - */ 3929 - val16 = APS_FSMCO_HW_SUSPEND | APS_FSMCO_ENABLE_POWERDOWN | 3930 - APS_FSMCO_PFM_ALDN; 3931 - rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); 3932 - 3933 - /* 3934 - * Release RF digital isolation 3935 - */ 3936 - val16 = rtl8xxxu_read16(priv, REG_SYS_ISO_CTRL); 3937 - val16 &= ~SYS_ISO_DIOR; 3938 - rtl8xxxu_write16(priv, REG_SYS_ISO_CTRL, val16); 3939 - 3940 - val8 = rtl8xxxu_read8(priv, REG_APSD_CTRL); 3941 - val8 &= ~APSD_CTRL_OFF; 3942 - rtl8xxxu_write8(priv, REG_APSD_CTRL, val8); 3943 - for (i = 200; i; i--) { 3944 - val8 = rtl8xxxu_read8(priv, REG_APSD_CTRL); 3945 - if (!(val8 & APSD_CTRL_OFF_STATUS)) 3946 - break; 3947 - } 3948 - 3949 - if (!i) { 3950 - pr_info("%s: APSD_CTRL poll failed\n", __func__); 3951 - return -EBUSY; 3952 - } 3953 - 3954 - /* 3955 - * Enable MAC DMA/WMAC/SCHEDULE/SEC block 3956 - */ 3957 - val16 = rtl8xxxu_read16(priv, REG_CR); 3958 - val16 |= CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 3959 - CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | CR_PROTOCOL_ENABLE | 3960 - CR_SCHEDULE_ENABLE | CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE; 3961 - rtl8xxxu_write16(priv, REG_CR, val16); 3962 - 3963 - rtl8xxxu_write8(priv, 0xfe10, 0x19); 3964 - 3965 - /* 3966 - * Workaround for 8188RU LNA power leakage problem. 3967 - */ 3968 - if (priv->rtl_chip == RTL8188R) { 3969 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_XCD_RF_PARM); 3970 - val32 &= ~BIT(1); 3971 - rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_PARM, val32); 3972 - } 3973 - return 0; 3974 - } 3975 - 3976 - #endif 3977 - 3978 - /* 3979 - * This is needed for 8723bu as well, presumable 3980 - */ 3981 - static void rtl8192e_crystal_afe_adjust(struct rtl8xxxu_priv *priv) 3982 - { 3983 - u8 val8; 3984 - u32 val32; 3985 - 3986 - /* 3987 - * 40Mhz crystal source, MAC 0x28[2]=0 3988 - */ 3989 - val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 3990 - val8 &= 0xfb; 3991 - rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 3992 - 3993 - val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 3994 - val32 &= 0xfffffc7f; 3995 - rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 3996 - 3997 - /* 3998 - * 92e AFE parameter 3999 - * AFE PLL KVCO selection, MAC 0x28[6]=1 4000 - */ 4001 - val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 4002 - val8 &= 0xbf; 4003 - rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 4004 - 4005 - /* 4006 - * AFE PLL KVCO selection, MAC 0x78[21]=0 4007 - */ 4008 - val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 4009 - val32 &= 0xffdfffff; 4010 - rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 4011 - } 4012 - 4013 - static int rtl8192eu_power_on(struct rtl8xxxu_priv *priv) 4014 - { 4015 - u16 val16; 4016 - u32 val32; 4017 - int ret; 4018 - 4019 - ret = 0; 4020 - 4021 - val32 = rtl8xxxu_read32(priv, REG_SYS_CFG); 4022 - if (val32 & SYS_CFG_SPS_LDO_SEL) { 4023 - rtl8xxxu_write8(priv, REG_LDO_SW_CTRL, 0xc3); 4024 - } else { 4025 - /* 4026 - * Raise 1.2V voltage 4027 - */ 4028 - val32 = rtl8xxxu_read32(priv, REG_8192E_LDOV12_CTRL); 4029 - val32 &= 0xff0fffff; 4030 - val32 |= 0x00500000; 4031 - rtl8xxxu_write32(priv, REG_8192E_LDOV12_CTRL, val32); 4032 - rtl8xxxu_write8(priv, REG_LDO_SW_CTRL, 0x83); 4033 - } 4034 - 4035 - /* 4036 - * Adjust AFE before enabling PLL 4037 - */ 4038 - rtl8192e_crystal_afe_adjust(priv); 4039 - rtl8192e_disabled_to_emu(priv); 4040 - 4041 - ret = rtl8192e_emu_to_active(priv); 4042 - if (ret) 4043 - goto exit; 4044 - 4045 - rtl8xxxu_write16(priv, REG_CR, 0x0000); 4046 - 4047 - /* 4048 - * Enable MAC DMA/WMAC/SCHEDULE/SEC block 4049 - * Set CR bit10 to enable 32k calibration. 4050 - */ 4051 - val16 = rtl8xxxu_read16(priv, REG_CR); 4052 - val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 4053 - CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | 4054 - CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | 4055 - CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | 4056 - CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); 4057 - rtl8xxxu_write16(priv, REG_CR, val16); 4058 - 4059 - exit: 4060 - return ret; 4061 - } 4062 - 4063 - static void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv) 7123 + void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv) 4064 7124 { 4065 7125 u8 val8; 4066 7126 u16 val16; ··· 3814 7466 rtl8xxxu_write8(priv, REG_RSV_CTRL, 0x0e); 3815 7467 } 3816 7468 3817 - static void rtl8723bu_power_off(struct rtl8xxxu_priv *priv) 3818 - { 3819 - u8 val8; 3820 - u16 val16; 3821 - 3822 - rtl8xxxu_flush_fifo(priv); 3823 - 3824 - /* 3825 - * Disable TX report timer 3826 - */ 3827 - val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); 3828 - val8 &= ~TX_REPORT_CTRL_TIMER_ENABLE; 3829 - rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); 3830 - 3831 - rtl8xxxu_write8(priv, REG_CR, 0x0000); 3832 - 3833 - rtl8xxxu_active_to_lps(priv); 3834 - 3835 - /* Reset Firmware if running in RAM */ 3836 - if (rtl8xxxu_read8(priv, REG_MCU_FW_DL) & MCU_FW_RAM_SEL) 3837 - rtl8xxxu_firmware_self_reset(priv); 3838 - 3839 - /* Reset MCU */ 3840 - val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 3841 - val16 &= ~SYS_FUNC_CPU_ENABLE; 3842 - rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 3843 - 3844 - /* Reset MCU ready status */ 3845 - rtl8xxxu_write8(priv, REG_MCU_FW_DL, 0x00); 3846 - 3847 - rtl8723bu_active_to_emu(priv); 3848 - 3849 - val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 3850 - val8 |= BIT(3); /* APS_FSMCO_HW_SUSPEND */ 3851 - rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 3852 - 3853 - /* 0x48[16] = 1 to enable GPIO9 as EXT wakeup */ 3854 - val8 = rtl8xxxu_read8(priv, REG_GPIO_INTM + 2); 3855 - val8 |= BIT(0); 3856 - rtl8xxxu_write8(priv, REG_GPIO_INTM + 2, val8); 3857 - } 3858 - 3859 7469 #ifdef NEED_PS_TDMA 3860 7470 static void rtl8723bu_set_ps_tdma(struct rtl8xxxu_priv *priv, 3861 7471 u8 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) ··· 3827 7521 h2c.b_type_dma.data3 = arg3; 3828 7522 h2c.b_type_dma.data4 = arg4; 3829 7523 h2c.b_type_dma.data5 = arg5; 3830 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.b_type_dma)); 7524 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.b_type_dma)); 3831 7525 } 3832 7526 #endif 3833 7527 3834 - static void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv) 3835 - { 3836 - u32 val32; 3837 - u8 val8; 3838 - 3839 - val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); 3840 - val8 |= BIT(5); 3841 - rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); 3842 - 3843 - /* 3844 - * WLAN action by PTA 3845 - */ 3846 - rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 3847 - 3848 - val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 3849 - val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 3850 - rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 3851 - 3852 - val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 3853 - val32 |= (BIT(0) | BIT(1)); 3854 - rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 3855 - 3856 - rtl8xxxu_write8(priv, REG_RFE_CTRL_ANTA_SRC, 0x77); 3857 - 3858 - val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 3859 - val32 &= ~BIT(24); 3860 - val32 |= BIT(23); 3861 - rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 3862 - 3863 - /* 3864 - * Fix external switch Main->S1, Aux->S0 3865 - */ 3866 - val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 3867 - val8 &= ~BIT(0); 3868 - rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 3869 - } 3870 - 3871 - static void rtl8723b_enable_rf(struct rtl8xxxu_priv *priv) 3872 - { 3873 - struct h2c_cmd h2c; 3874 - u32 val32; 3875 - u8 val8; 3876 - 3877 - /* 3878 - * No indication anywhere as to what 0x0790 does. The 2 antenna 3879 - * vendor code preserves bits 6-7 here. 3880 - */ 3881 - rtl8xxxu_write8(priv, 0x0790, 0x05); 3882 - /* 3883 - * 0x0778 seems to be related to enabling the number of antennas 3884 - * In the vendor driver halbtc8723b2ant_InitHwConfig() sets it 3885 - * to 0x03, while halbtc8723b1ant_InitHwConfig() sets it to 0x01 3886 - */ 3887 - rtl8xxxu_write8(priv, 0x0778, 0x01); 3888 - 3889 - val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); 3890 - val8 |= BIT(5); 3891 - rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); 3892 - 3893 - rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_IQADJ_G1, 0x780); 3894 - 3895 - rtl8723bu_write_btreg(priv, 0x3c, 0x15); /* BT TRx Mask on */ 3896 - 3897 - /* 3898 - * Set BT grant to low 3899 - */ 3900 - memset(&h2c, 0, sizeof(struct h2c_cmd)); 3901 - h2c.bt_grant.cmd = H2C_8723B_BT_GRANT; 3902 - h2c.bt_grant.data = 0; 3903 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.bt_grant)); 3904 - 3905 - /* 3906 - * WLAN action by PTA 3907 - */ 3908 - rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 3909 - 3910 - /* 3911 - * BT select S0/S1 controlled by WiFi 3912 - */ 3913 - val8 = rtl8xxxu_read8(priv, 0x0067); 3914 - val8 |= BIT(5); 3915 - rtl8xxxu_write8(priv, 0x0067, val8); 3916 - 3917 - val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 3918 - val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 3919 - rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 3920 - 3921 - /* 3922 - * Bits 6/7 are marked in/out ... but for what? 3923 - */ 3924 - rtl8xxxu_write8(priv, 0x0974, 0xff); 3925 - 3926 - val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 3927 - val32 |= (BIT(0) | BIT(1)); 3928 - rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 3929 - 3930 - rtl8xxxu_write8(priv, REG_RFE_CTRL_ANTA_SRC, 0x77); 3931 - 3932 - val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 3933 - val32 &= ~BIT(24); 3934 - val32 |= BIT(23); 3935 - rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 3936 - 3937 - /* 3938 - * Fix external switch Main->S1, Aux->S0 3939 - */ 3940 - val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 3941 - val8 &= ~BIT(0); 3942 - rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 3943 - 3944 - memset(&h2c, 0, sizeof(struct h2c_cmd)); 3945 - h2c.ant_sel_rsv.cmd = H2C_8723B_ANT_SEL_RSV; 3946 - h2c.ant_sel_rsv.ant_inverse = 1; 3947 - h2c.ant_sel_rsv.int_switch_type = 0; 3948 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.ant_sel_rsv)); 3949 - 3950 - /* 3951 - * 0x280, 0x00, 0x200, 0x80 - not clear 3952 - */ 3953 - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 3954 - 3955 - /* 3956 - * Software control, antenna at WiFi side 3957 - */ 3958 - #ifdef NEED_PS_TDMA 3959 - rtl8723bu_set_ps_tdma(priv, 0x08, 0x00, 0x00, 0x00, 0x00); 3960 - #endif 3961 - 3962 - rtl8xxxu_write32(priv, REG_BT_COEX_TABLE1, 0x55555555); 3963 - rtl8xxxu_write32(priv, REG_BT_COEX_TABLE2, 0x55555555); 3964 - rtl8xxxu_write32(priv, REG_BT_COEX_TABLE3, 0x00ffffff); 3965 - rtl8xxxu_write8(priv, REG_BT_COEX_TABLE4, 0x03); 3966 - 3967 - memset(&h2c, 0, sizeof(struct h2c_cmd)); 3968 - h2c.bt_info.cmd = H2C_8723B_BT_INFO; 3969 - h2c.bt_info.data = BIT(0); 3970 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.bt_info)); 3971 - 3972 - memset(&h2c, 0, sizeof(struct h2c_cmd)); 3973 - h2c.ignore_wlan.cmd = H2C_8723B_BT_IGNORE_WLANACT; 3974 - h2c.ignore_wlan.data = 0; 3975 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.ignore_wlan)); 3976 - } 3977 - 3978 - static void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv) 7528 + void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv) 3979 7529 { 3980 7530 u32 val32; 3981 7531 3982 7532 val32 = rtl8xxxu_read32(priv, REG_RX_WAIT_CCA); 3983 7533 val32 &= ~(BIT(22) | BIT(23)); 3984 7534 rtl8xxxu_write32(priv, REG_RX_WAIT_CCA, val32); 3985 - } 3986 - 3987 - static void rtl8723bu_init_aggregation(struct rtl8xxxu_priv *priv) 3988 - { 3989 - u32 agg_rx; 3990 - u8 agg_ctrl; 3991 - 3992 - /* 3993 - * For now simply disable RX aggregation 3994 - */ 3995 - agg_ctrl = rtl8xxxu_read8(priv, REG_TRXDMA_CTRL); 3996 - agg_ctrl &= ~TRXDMA_CTRL_RXDMA_AGG_EN; 3997 - 3998 - agg_rx = rtl8xxxu_read32(priv, REG_RXDMA_AGG_PG_TH); 3999 - agg_rx &= ~RXDMA_USB_AGG_ENABLE; 4000 - agg_rx &= ~0xff0f; 4001 - 4002 - rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl); 4003 - rtl8xxxu_write32(priv, REG_RXDMA_AGG_PG_TH, agg_rx); 4004 - } 4005 - 4006 - static void rtl8723bu_init_statistics(struct rtl8xxxu_priv *priv) 4007 - { 4008 - u32 val32; 4009 - 4010 - /* Time duration for NHM unit: 4us, 0x2710=40ms */ 4011 - rtl8xxxu_write16(priv, REG_NHM_TIMER_8723B + 2, 0x2710); 4012 - rtl8xxxu_write16(priv, REG_NHM_TH9_TH10_8723B + 2, 0xffff); 4013 - rtl8xxxu_write32(priv, REG_NHM_TH3_TO_TH0_8723B, 0xffffff52); 4014 - rtl8xxxu_write32(priv, REG_NHM_TH7_TO_TH4_8723B, 0xffffffff); 4015 - /* TH8 */ 4016 - val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 4017 - val32 |= 0xff; 4018 - rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 4019 - /* Enable CCK */ 4020 - val32 = rtl8xxxu_read32(priv, REG_NHM_TH9_TH10_8723B); 4021 - val32 |= BIT(8) | BIT(9) | BIT(10); 4022 - rtl8xxxu_write32(priv, REG_NHM_TH9_TH10_8723B, val32); 4023 - /* Max power amongst all RX antennas */ 4024 - val32 = rtl8xxxu_read32(priv, REG_OFDM0_FA_RSTC); 4025 - val32 |= BIT(7); 4026 - rtl8xxxu_write32(priv, REG_OFDM0_FA_RSTC, val32); 4027 7535 } 4028 7536 4029 7537 static void rtl8xxxu_old_init_queue_reserved_page(struct rtl8xxxu_priv *priv) ··· 4329 8209 rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8); 4330 8210 } 4331 8211 4332 - static void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv, 4333 - u32 ramask, int sgi) 8212 + void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv, u32 ramask, int sgi) 4334 8213 { 4335 8214 struct h2c_cmd h2c; 4336 8215 ··· 4345 8226 4346 8227 dev_dbg(&priv->udev->dev, "%s: rate mask %08x, arg %02x, size %zi\n", 4347 8228 __func__, ramask, h2c.ramask.arg, sizeof(h2c.ramask)); 4348 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.ramask)); 8229 + rtl8xxxu_gen1_h2c_cmd(priv, &h2c, sizeof(h2c.ramask)); 4349 8230 } 4350 8231 4351 - static void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, 4352 - u32 ramask, int sgi) 8232 + void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, 8233 + u32 ramask, int sgi) 4353 8234 { 4354 8235 struct h2c_cmd h2c; 4355 8236 u8 bw = 0; ··· 4371 8252 4372 8253 dev_dbg(&priv->udev->dev, "%s: rate mask %08x, arg %02x, size %zi\n", 4373 8254 __func__, ramask, h2c.ramask.arg, sizeof(h2c.b_macid_cfg)); 4374 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.b_macid_cfg)); 8255 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.b_macid_cfg)); 4375 8256 } 4376 8257 4377 - static void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, 4378 - u8 macid, bool connect) 8258 + void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, 8259 + u8 macid, bool connect) 4379 8260 { 4380 8261 struct h2c_cmd h2c; 4381 8262 ··· 4388 8269 else 4389 8270 h2c.joinbss.data = H2C_JOIN_BSS_DISCONNECT; 4390 8271 4391 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.joinbss)); 8272 + rtl8xxxu_gen1_h2c_cmd(priv, &h2c, sizeof(h2c.joinbss)); 4392 8273 } 4393 8274 4394 - static void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, 4395 - u8 macid, bool connect) 8275 + void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, 8276 + u8 macid, bool connect) 4396 8277 { 4397 8278 struct h2c_cmd h2c; 4398 8279 ··· 4404 8285 else 4405 8286 h2c.media_status_rpt.parm &= ~BIT(0); 4406 8287 4407 - rtl8723a_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt)); 8288 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt)); 4408 8289 } 4409 8290 4410 8291 static void rtl8xxxu_set_basic_rates(struct rtl8xxxu_priv *priv, u32 rate_cfg) ··· 4474 8355 4475 8356 rtl8xxxu_write8(priv, REG_BCN_MAX_ERR, 0xff); 4476 8357 4477 - rtl8723a_stop_tx_beacon(priv); 8358 + rtl8xxxu_stop_tx_beacon(priv); 4478 8359 4479 8360 /* joinbss sequence */ 4480 8361 rtl8xxxu_write16(priv, REG_BCN_PSR_RPT, ··· 5045 8926 } 5046 8927 } 5047 8928 5048 - static int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, 5049 - struct sk_buff *skb, 5050 - struct ieee80211_rx_status *rx_status) 8929 + int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb, 8930 + struct ieee80211_rx_status *rx_status) 5051 8931 { 5052 8932 struct rtl8xxxu_rxdesc16 *rx_desc = 5053 8933 (struct rtl8xxxu_rxdesc16 *)skb->data; ··· 5091 8973 return RX_TYPE_DATA_PKT; 5092 8974 } 5093 8975 5094 - static int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, 5095 - struct sk_buff *skb, 5096 - struct ieee80211_rx_status *rx_status) 8976 + int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb, 8977 + struct ieee80211_rx_status *rx_status) 5097 8978 { 5098 8979 struct rtl8xxxu_rxdesc24 *rx_desc = 5099 8980 (struct rtl8xxxu_rxdesc24 *)skb->data; ··· 5310 9193 5311 9194 switch (vif->type) { 5312 9195 case NL80211_IFTYPE_STATION: 5313 - rtl8723a_stop_tx_beacon(priv); 9196 + rtl8xxxu_stop_tx_beacon(priv); 5314 9197 5315 9198 val8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL); 5316 9199 val8 |= BEACON_ATIM | BEACON_FUNCTION_ENABLE | ··· 5995 9878 usb_put_dev(priv->udev); 5996 9879 ieee80211_free_hw(hw); 5997 9880 } 5998 - 5999 - static struct rtl8xxxu_fileops rtl8723au_fops = { 6000 - .parse_efuse = rtl8723au_parse_efuse, 6001 - .load_firmware = rtl8723au_load_firmware, 6002 - .power_on = rtl8723au_power_on, 6003 - .power_off = rtl8xxxu_power_off, 6004 - .reset_8051 = rtl8xxxu_reset_8051, 6005 - .llt_init = rtl8xxxu_init_llt_table, 6006 - .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, 6007 - .init_phy_rf = rtl8723au_init_phy_rf, 6008 - .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, 6009 - .config_channel = rtl8xxxu_gen1_config_channel, 6010 - .parse_rx_desc = rtl8xxxu_parse_rxdesc16, 6011 - .enable_rf = rtl8xxxu_gen1_enable_rf, 6012 - .disable_rf = rtl8xxxu_gen1_disable_rf, 6013 - .usb_quirks = rtl8xxxu_gen1_usb_quirks, 6014 - .set_tx_power = rtl8xxxu_gen1_set_tx_power, 6015 - .update_rate_mask = rtl8xxxu_update_rate_mask, 6016 - .report_connect = rtl8xxxu_gen1_report_connect, 6017 - .writeN_block_size = 1024, 6018 - .mbox_ext_reg = REG_HMBOX_EXT_0, 6019 - .mbox_ext_width = 2, 6020 - .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), 6021 - .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), 6022 - .adda_1t_init = 0x0b1b25a0, 6023 - .adda_1t_path_on = 0x0bdb25a0, 6024 - .adda_2t_path_on_a = 0x04db25a4, 6025 - .adda_2t_path_on_b = 0x0b1b25a4, 6026 - .trxff_boundary = 0x27ff, 6027 - .pbp_rx = PBP_PAGE_SIZE_128, 6028 - .pbp_tx = PBP_PAGE_SIZE_128, 6029 - .mactable = rtl8xxxu_gen1_mac_init_table, 6030 - }; 6031 - 6032 - static struct rtl8xxxu_fileops rtl8723bu_fops = { 6033 - .parse_efuse = rtl8723bu_parse_efuse, 6034 - .load_firmware = rtl8723bu_load_firmware, 6035 - .power_on = rtl8723bu_power_on, 6036 - .power_off = rtl8723bu_power_off, 6037 - .reset_8051 = rtl8723bu_reset_8051, 6038 - .llt_init = rtl8xxxu_auto_llt_table, 6039 - .init_phy_bb = rtl8723bu_init_phy_bb, 6040 - .init_phy_rf = rtl8723bu_init_phy_rf, 6041 - .phy_init_antenna_selection = rtl8723bu_phy_init_antenna_selection, 6042 - .phy_iq_calibrate = rtl8723bu_phy_iq_calibrate, 6043 - .config_channel = rtl8xxxu_gen2_config_channel, 6044 - .parse_rx_desc = rtl8xxxu_parse_rxdesc24, 6045 - .init_aggregation = rtl8723bu_init_aggregation, 6046 - .init_statistics = rtl8723bu_init_statistics, 6047 - .enable_rf = rtl8723b_enable_rf, 6048 - .disable_rf = rtl8xxxu_gen2_disable_rf, 6049 - .usb_quirks = rtl8xxxu_gen2_usb_quirks, 6050 - .set_tx_power = rtl8723b_set_tx_power, 6051 - .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, 6052 - .report_connect = rtl8xxxu_gen2_report_connect, 6053 - .writeN_block_size = 1024, 6054 - .mbox_ext_reg = REG_HMBOX_EXT0_8723B, 6055 - .mbox_ext_width = 4, 6056 - .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), 6057 - .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), 6058 - .has_s0s1 = 1, 6059 - .adda_1t_init = 0x01c00014, 6060 - .adda_1t_path_on = 0x01c00014, 6061 - .adda_2t_path_on_a = 0x01c00014, 6062 - .adda_2t_path_on_b = 0x01c00014, 6063 - .trxff_boundary = 0x3f7f, 6064 - .pbp_rx = PBP_PAGE_SIZE_256, 6065 - .pbp_tx = PBP_PAGE_SIZE_256, 6066 - .mactable = rtl8723b_mac_init_table, 6067 - }; 6068 - 6069 - #ifdef CONFIG_RTL8XXXU_UNTESTED 6070 - 6071 - static struct rtl8xxxu_fileops rtl8192cu_fops = { 6072 - .parse_efuse = rtl8192cu_parse_efuse, 6073 - .load_firmware = rtl8192cu_load_firmware, 6074 - .power_on = rtl8192cu_power_on, 6075 - .power_off = rtl8xxxu_power_off, 6076 - .reset_8051 = rtl8xxxu_reset_8051, 6077 - .llt_init = rtl8xxxu_init_llt_table, 6078 - .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, 6079 - .init_phy_rf = rtl8192cu_init_phy_rf, 6080 - .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, 6081 - .config_channel = rtl8xxxu_gen1_config_channel, 6082 - .parse_rx_desc = rtl8xxxu_parse_rxdesc16, 6083 - .enable_rf = rtl8xxxu_gen1_enable_rf, 6084 - .disable_rf = rtl8xxxu_gen1_disable_rf, 6085 - .usb_quirks = rtl8xxxu_gen1_usb_quirks, 6086 - .set_tx_power = rtl8xxxu_gen1_set_tx_power, 6087 - .update_rate_mask = rtl8xxxu_update_rate_mask, 6088 - .report_connect = rtl8xxxu_gen1_report_connect, 6089 - .writeN_block_size = 128, 6090 - .mbox_ext_reg = REG_HMBOX_EXT_0, 6091 - .mbox_ext_width = 2, 6092 - .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), 6093 - .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), 6094 - .adda_1t_init = 0x0b1b25a0, 6095 - .adda_1t_path_on = 0x0bdb25a0, 6096 - .adda_2t_path_on_a = 0x04db25a4, 6097 - .adda_2t_path_on_b = 0x0b1b25a4, 6098 - .trxff_boundary = 0x27ff, 6099 - .pbp_rx = PBP_PAGE_SIZE_128, 6100 - .pbp_tx = PBP_PAGE_SIZE_128, 6101 - .mactable = rtl8xxxu_gen1_mac_init_table, 6102 - }; 6103 - 6104 - #endif 6105 - 6106 - static struct rtl8xxxu_fileops rtl8192eu_fops = { 6107 - .parse_efuse = rtl8192eu_parse_efuse, 6108 - .load_firmware = rtl8192eu_load_firmware, 6109 - .power_on = rtl8192eu_power_on, 6110 - .power_off = rtl8xxxu_power_off, 6111 - .reset_8051 = rtl8xxxu_reset_8051, 6112 - .llt_init = rtl8xxxu_auto_llt_table, 6113 - .init_phy_bb = rtl8192eu_init_phy_bb, 6114 - .init_phy_rf = rtl8192eu_init_phy_rf, 6115 - .phy_iq_calibrate = rtl8192eu_phy_iq_calibrate, 6116 - .config_channel = rtl8xxxu_gen2_config_channel, 6117 - .parse_rx_desc = rtl8xxxu_parse_rxdesc24, 6118 - .enable_rf = rtl8192e_enable_rf, 6119 - .disable_rf = rtl8xxxu_gen2_disable_rf, 6120 - .usb_quirks = rtl8xxxu_gen2_usb_quirks, 6121 - .set_tx_power = rtl8192e_set_tx_power, 6122 - .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, 6123 - .report_connect = rtl8xxxu_gen2_report_connect, 6124 - .writeN_block_size = 128, 6125 - .mbox_ext_reg = REG_HMBOX_EXT0_8723B, 6126 - .mbox_ext_width = 4, 6127 - .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), 6128 - .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), 6129 - .has_s0s1 = 0, 6130 - .adda_1t_init = 0x0fc01616, 6131 - .adda_1t_path_on = 0x0fc01616, 6132 - .adda_2t_path_on_a = 0x0fc01616, 6133 - .adda_2t_path_on_b = 0x0fc01616, 6134 - .trxff_boundary = 0x3cff, 6135 - .mactable = rtl8192e_mac_init_table, 6136 - .total_page_num = TX_TOTAL_PAGE_NUM_8192E, 6137 - .page_num_hi = TX_PAGE_NUM_HI_PQ_8192E, 6138 - .page_num_lo = TX_PAGE_NUM_LO_PQ_8192E, 6139 - .page_num_norm = TX_PAGE_NUM_NORM_PQ_8192E, 6140 - }; 6141 9881 6142 9882 static struct usb_device_id dev_table[] = { 6143 9883 {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8724, 0xff, 0xff, 0xff),
+79 -2
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
··· 1329 1329 void (*report_connect) (struct rtl8xxxu_priv *priv, 1330 1330 u8 macid, bool connect); 1331 1331 int writeN_block_size; 1332 - u16 mbox_ext_reg; 1333 - char mbox_ext_width; 1334 1332 char tx_desc_size; 1335 1333 char rx_desc_size; 1336 1334 char has_s0s1; ··· 1345 1347 u8 page_num_lo; 1346 1348 u8 page_num_norm; 1347 1349 }; 1350 + 1351 + extern int rtl8xxxu_debug; 1352 + 1353 + extern struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table[]; 1354 + extern const u32 rtl8xxxu_iqk_phy_iq_bb_reg[]; 1355 + u8 rtl8xxxu_read8(struct rtl8xxxu_priv *priv, u16 addr); 1356 + u16 rtl8xxxu_read16(struct rtl8xxxu_priv *priv, u16 addr); 1357 + u32 rtl8xxxu_read32(struct rtl8xxxu_priv *priv, u16 addr); 1358 + int rtl8xxxu_write8(struct rtl8xxxu_priv *priv, u16 addr, u8 val); 1359 + int rtl8xxxu_write16(struct rtl8xxxu_priv *priv, u16 addr, u16 val); 1360 + int rtl8xxxu_write32(struct rtl8xxxu_priv *priv, u16 addr, u32 val); 1361 + u32 rtl8xxxu_read_rfreg(struct rtl8xxxu_priv *priv, 1362 + enum rtl8xxxu_rfpath path, u8 reg); 1363 + int rtl8xxxu_write_rfreg(struct rtl8xxxu_priv *priv, 1364 + enum rtl8xxxu_rfpath path, u8 reg, u32 data); 1365 + void rtl8xxxu_save_regs(struct rtl8xxxu_priv *priv, const u32 *regs, 1366 + u32 *backup, int count); 1367 + void rtl8xxxu_restore_regs(struct rtl8xxxu_priv *priv, const u32 *regs, 1368 + u32 *backup, int count); 1369 + void rtl8xxxu_save_mac_regs(struct rtl8xxxu_priv *priv, 1370 + const u32 *reg, u32 *backup); 1371 + void rtl8xxxu_restore_mac_regs(struct rtl8xxxu_priv *priv, 1372 + const u32 *reg, u32 *backup); 1373 + void rtl8xxxu_path_adda_on(struct rtl8xxxu_priv *priv, const u32 *regs, 1374 + bool path_a_on); 1375 + void rtl8xxxu_mac_calibration(struct rtl8xxxu_priv *priv, 1376 + const u32 *regs, u32 *backup); 1377 + void rtl8xxxu_fill_iqk_matrix_a(struct rtl8xxxu_priv *priv, bool iqk_ok, 1378 + int result[][8], int candidate, bool tx_only); 1379 + void rtl8xxxu_fill_iqk_matrix_b(struct rtl8xxxu_priv *priv, bool iqk_ok, 1380 + int result[][8], int candidate, bool tx_only); 1381 + int rtl8xxxu_init_phy_rf(struct rtl8xxxu_priv *priv, 1382 + struct rtl8xxxu_rfregval *table, 1383 + enum rtl8xxxu_rfpath path); 1384 + int rtl8xxxu_init_phy_regs(struct rtl8xxxu_priv *priv, 1385 + struct rtl8xxxu_reg32val *array); 1386 + int rtl8xxxu_load_firmware(struct rtl8xxxu_priv *priv, char *fw_name); 1387 + void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv); 1388 + void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv); 1389 + void rtl8xxxu_reset_8051(struct rtl8xxxu_priv *priv); 1390 + int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page); 1391 + void rtl8xxxu_gen2_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start); 1392 + int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv *priv); 1393 + int rtl8xxxu_gen2_h2c_cmd(struct rtl8xxxu_priv *priv, 1394 + struct h2c_cmd *h2c, int len); 1395 + int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv *priv); 1396 + void rtl8xxxu_disabled_to_emu(struct rtl8xxxu_priv *priv); 1397 + int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page); 1398 + void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv); 1399 + void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv); 1400 + void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, 1401 + int channel, bool ht40); 1402 + void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw); 1403 + void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw); 1404 + void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv); 1405 + void rtl8xxxu_gen2_usb_quirks(struct rtl8xxxu_priv *priv); 1406 + void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv, 1407 + u32 ramask, int sgi); 1408 + void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv, 1409 + u32 ramask, int sgi); 1410 + void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv, 1411 + u8 macid, bool connect); 1412 + void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, 1413 + u8 macid, bool connect); 1414 + void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv); 1415 + void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv); 1416 + void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv); 1417 + int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb, 1418 + struct ieee80211_rx_status *rx_status); 1419 + int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb, 1420 + struct ieee80211_rx_status *rx_status); 1421 + int rtl8xxxu_gen2_channel_to_group(int channel); 1422 + bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv, 1423 + int result[][8], int c1, int c2); 1424 + 1425 + extern struct rtl8xxxu_fileops rtl8192cu_fops; 1426 + extern struct rtl8xxxu_fileops rtl8192eu_fops; 1427 + extern struct rtl8xxxu_fileops rtl8723au_fops; 1428 + extern struct rtl8xxxu_fileops rtl8723bu_fops;
+586
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
··· 1 + /* 2 + * RTL8XXXU mac80211 USB driver - 8188c/8188r/8192c specific subdriver 3 + * 4 + * Copyright (c) 2014 - 2016 Jes Sorensen <Jes.Sorensen@redhat.com> 5 + * 6 + * Portions, notably calibration code: 7 + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 8 + * 9 + * This driver was written as a replacement for the vendor provided 10 + * rtl8723au driver. As the Realtek 8xxx chips are very similar in 11 + * their programming interface, I have started adding support for 12 + * additional 8xxx chips like the 8192cu, 8188cus, etc. 13 + * 14 + * This program is free software; you can redistribute it and/or modify it 15 + * under the terms of version 2 of the GNU General Public License as 16 + * published by the Free Software Foundation. 17 + * 18 + * This program is distributed in the hope that it will be useful, but WITHOUT 19 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 + * more details. 22 + */ 23 + 24 + #include <linux/init.h> 25 + #include <linux/kernel.h> 26 + #include <linux/sched.h> 27 + #include <linux/errno.h> 28 + #include <linux/slab.h> 29 + #include <linux/module.h> 30 + #include <linux/spinlock.h> 31 + #include <linux/list.h> 32 + #include <linux/usb.h> 33 + #include <linux/netdevice.h> 34 + #include <linux/etherdevice.h> 35 + #include <linux/ethtool.h> 36 + #include <linux/wireless.h> 37 + #include <linux/firmware.h> 38 + #include <linux/moduleparam.h> 39 + #include <net/mac80211.h> 40 + #include "rtl8xxxu.h" 41 + #include "rtl8xxxu_regs.h" 42 + 43 + #ifdef CONFIG_RTL8XXXU_UNTESTED 44 + static struct rtl8xxxu_power_base rtl8192c_power_base = { 45 + .reg_0e00 = 0x07090c0c, 46 + .reg_0e04 = 0x01020405, 47 + .reg_0e08 = 0x00000000, 48 + .reg_086c = 0x00000000, 49 + 50 + .reg_0e10 = 0x0b0c0c0e, 51 + .reg_0e14 = 0x01030506, 52 + .reg_0e18 = 0x0b0c0d0e, 53 + .reg_0e1c = 0x01030509, 54 + 55 + .reg_0830 = 0x07090c0c, 56 + .reg_0834 = 0x01020405, 57 + .reg_0838 = 0x00000000, 58 + .reg_086c_2 = 0x00000000, 59 + 60 + .reg_083c = 0x0b0c0d0e, 61 + .reg_0848 = 0x01030509, 62 + .reg_084c = 0x0b0c0d0e, 63 + .reg_0868 = 0x01030509, 64 + }; 65 + 66 + static struct rtl8xxxu_power_base rtl8188r_power_base = { 67 + .reg_0e00 = 0x06080808, 68 + .reg_0e04 = 0x00040406, 69 + .reg_0e08 = 0x00000000, 70 + .reg_086c = 0x00000000, 71 + 72 + .reg_0e10 = 0x04060608, 73 + .reg_0e14 = 0x00020204, 74 + .reg_0e18 = 0x04060608, 75 + .reg_0e1c = 0x00020204, 76 + 77 + .reg_0830 = 0x06080808, 78 + .reg_0834 = 0x00040406, 79 + .reg_0838 = 0x00000000, 80 + .reg_086c_2 = 0x00000000, 81 + 82 + .reg_083c = 0x04060608, 83 + .reg_0848 = 0x00020204, 84 + .reg_084c = 0x04060608, 85 + .reg_0868 = 0x00020204, 86 + }; 87 + 88 + static struct rtl8xxxu_rfregval rtl8192cu_radioa_2t_init_table[] = { 89 + {0x00, 0x00030159}, {0x01, 0x00031284}, 90 + {0x02, 0x00098000}, {0x03, 0x00018c63}, 91 + {0x04, 0x000210e7}, {0x09, 0x0002044f}, 92 + {0x0a, 0x0001adb1}, {0x0b, 0x00054867}, 93 + {0x0c, 0x0008992e}, {0x0d, 0x0000e52c}, 94 + {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 95 + {0x19, 0x00000000}, {0x1a, 0x00010255}, 96 + {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 97 + {0x1d, 0x000a1250}, {0x1e, 0x0004445f}, 98 + {0x1f, 0x00080001}, {0x20, 0x0000b614}, 99 + {0x21, 0x0006c000}, {0x22, 0x00000000}, 100 + {0x23, 0x00001558}, {0x24, 0x00000060}, 101 + {0x25, 0x00000483}, {0x26, 0x0004f000}, 102 + {0x27, 0x000ec7d9}, {0x28, 0x000577c0}, 103 + {0x29, 0x00004783}, {0x2a, 0x00000001}, 104 + {0x2b, 0x00021334}, {0x2a, 0x00000000}, 105 + {0x2b, 0x00000054}, {0x2a, 0x00000001}, 106 + {0x2b, 0x00000808}, {0x2b, 0x00053333}, 107 + {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 108 + {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 109 + {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 110 + {0x2b, 0x00000808}, {0x2b, 0x00063333}, 111 + {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 112 + {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 113 + {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 114 + {0x2b, 0x00000808}, {0x2b, 0x00073333}, 115 + {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 116 + {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 117 + {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 118 + {0x2b, 0x00000709}, {0x2b, 0x00063333}, 119 + {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 120 + {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 121 + {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 122 + {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 123 + {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 124 + {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 125 + {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 126 + {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 127 + {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 128 + {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 129 + {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 130 + {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 131 + {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 132 + {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 133 + {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 134 + {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 135 + {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 136 + {0x10, 0x0002000f}, {0x11, 0x000203f9}, 137 + {0x10, 0x0003000f}, {0x11, 0x000ff500}, 138 + {0x10, 0x00000000}, {0x11, 0x00000000}, 139 + {0x10, 0x0008000f}, {0x11, 0x0003f100}, 140 + {0x10, 0x0009000f}, {0x11, 0x00023100}, 141 + {0x12, 0x00032000}, {0x12, 0x00071000}, 142 + {0x12, 0x000b0000}, {0x12, 0x000fc000}, 143 + {0x13, 0x000287b3}, {0x13, 0x000244b7}, 144 + {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 145 + {0x13, 0x00018493}, {0x13, 0x0001429b}, 146 + {0x13, 0x00010299}, {0x13, 0x0000c29c}, 147 + {0x13, 0x000081a0}, {0x13, 0x000040ac}, 148 + {0x13, 0x00000020}, {0x14, 0x0001944c}, 149 + {0x14, 0x00059444}, {0x14, 0x0009944c}, 150 + {0x14, 0x000d9444}, {0x15, 0x0000f424}, 151 + {0x15, 0x0004f424}, {0x15, 0x0008f424}, 152 + {0x15, 0x000cf424}, {0x16, 0x000e0330}, 153 + {0x16, 0x000a0330}, {0x16, 0x00060330}, 154 + {0x16, 0x00020330}, {0x00, 0x00010159}, 155 + {0x18, 0x0000f401}, {0xfe, 0x00000000}, 156 + {0xfe, 0x00000000}, {0x1f, 0x00080003}, 157 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 158 + {0x1e, 0x00044457}, {0x1f, 0x00080000}, 159 + {0x00, 0x00030159}, 160 + {0xff, 0xffffffff} 161 + }; 162 + 163 + static struct rtl8xxxu_rfregval rtl8192cu_radiob_2t_init_table[] = { 164 + {0x00, 0x00030159}, {0x01, 0x00031284}, 165 + {0x02, 0x00098000}, {0x03, 0x00018c63}, 166 + {0x04, 0x000210e7}, {0x09, 0x0002044f}, 167 + {0x0a, 0x0001adb1}, {0x0b, 0x00054867}, 168 + {0x0c, 0x0008992e}, {0x0d, 0x0000e52c}, 169 + {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 170 + {0x12, 0x00032000}, {0x12, 0x00071000}, 171 + {0x12, 0x000b0000}, {0x12, 0x000fc000}, 172 + {0x13, 0x000287af}, {0x13, 0x000244b7}, 173 + {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 174 + {0x13, 0x00018493}, {0x13, 0x00014297}, 175 + {0x13, 0x00010295}, {0x13, 0x0000c298}, 176 + {0x13, 0x0000819c}, {0x13, 0x000040a8}, 177 + {0x13, 0x0000001c}, {0x14, 0x0001944c}, 178 + {0x14, 0x00059444}, {0x14, 0x0009944c}, 179 + {0x14, 0x000d9444}, {0x15, 0x0000f424}, 180 + {0x15, 0x0004f424}, {0x15, 0x0008f424}, 181 + {0x15, 0x000cf424}, {0x16, 0x000e0330}, 182 + {0x16, 0x000a0330}, {0x16, 0x00060330}, 183 + {0x16, 0x00020330}, 184 + {0xff, 0xffffffff} 185 + }; 186 + 187 + static struct rtl8xxxu_rfregval rtl8192cu_radioa_1t_init_table[] = { 188 + {0x00, 0x00030159}, {0x01, 0x00031284}, 189 + {0x02, 0x00098000}, {0x03, 0x00018c63}, 190 + {0x04, 0x000210e7}, {0x09, 0x0002044f}, 191 + {0x0a, 0x0001adb1}, {0x0b, 0x00054867}, 192 + {0x0c, 0x0008992e}, {0x0d, 0x0000e52c}, 193 + {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 194 + {0x19, 0x00000000}, {0x1a, 0x00010255}, 195 + {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 196 + {0x1d, 0x000a1250}, {0x1e, 0x0004445f}, 197 + {0x1f, 0x00080001}, {0x20, 0x0000b614}, 198 + {0x21, 0x0006c000}, {0x22, 0x00000000}, 199 + {0x23, 0x00001558}, {0x24, 0x00000060}, 200 + {0x25, 0x00000483}, {0x26, 0x0004f000}, 201 + {0x27, 0x000ec7d9}, {0x28, 0x000577c0}, 202 + {0x29, 0x00004783}, {0x2a, 0x00000001}, 203 + {0x2b, 0x00021334}, {0x2a, 0x00000000}, 204 + {0x2b, 0x00000054}, {0x2a, 0x00000001}, 205 + {0x2b, 0x00000808}, {0x2b, 0x00053333}, 206 + {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 207 + {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 208 + {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 209 + {0x2b, 0x00000808}, {0x2b, 0x00063333}, 210 + {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 211 + {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 212 + {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 213 + {0x2b, 0x00000808}, {0x2b, 0x00073333}, 214 + {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 215 + {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 216 + {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 217 + {0x2b, 0x00000709}, {0x2b, 0x00063333}, 218 + {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 219 + {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 220 + {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 221 + {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 222 + {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 223 + {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 224 + {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 225 + {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 226 + {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 227 + {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 228 + {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 229 + {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 230 + {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 231 + {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 232 + {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 233 + {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 234 + {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 235 + {0x10, 0x0002000f}, {0x11, 0x000203f9}, 236 + {0x10, 0x0003000f}, {0x11, 0x000ff500}, 237 + {0x10, 0x00000000}, {0x11, 0x00000000}, 238 + {0x10, 0x0008000f}, {0x11, 0x0003f100}, 239 + {0x10, 0x0009000f}, {0x11, 0x00023100}, 240 + {0x12, 0x00032000}, {0x12, 0x00071000}, 241 + {0x12, 0x000b0000}, {0x12, 0x000fc000}, 242 + {0x13, 0x000287b3}, {0x13, 0x000244b7}, 243 + {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 244 + {0x13, 0x00018493}, {0x13, 0x0001429b}, 245 + {0x13, 0x00010299}, {0x13, 0x0000c29c}, 246 + {0x13, 0x000081a0}, {0x13, 0x000040ac}, 247 + {0x13, 0x00000020}, {0x14, 0x0001944c}, 248 + {0x14, 0x00059444}, {0x14, 0x0009944c}, 249 + {0x14, 0x000d9444}, {0x15, 0x0000f405}, 250 + {0x15, 0x0004f405}, {0x15, 0x0008f405}, 251 + {0x15, 0x000cf405}, {0x16, 0x000e0330}, 252 + {0x16, 0x000a0330}, {0x16, 0x00060330}, 253 + {0x16, 0x00020330}, {0x00, 0x00010159}, 254 + {0x18, 0x0000f401}, {0xfe, 0x00000000}, 255 + {0xfe, 0x00000000}, {0x1f, 0x00080003}, 256 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 257 + {0x1e, 0x00044457}, {0x1f, 0x00080000}, 258 + {0x00, 0x00030159}, 259 + {0xff, 0xffffffff} 260 + }; 261 + 262 + static struct rtl8xxxu_rfregval rtl8188ru_radioa_1t_highpa_table[] = { 263 + {0x00, 0x00030159}, {0x01, 0x00031284}, 264 + {0x02, 0x00098000}, {0x03, 0x00018c63}, 265 + {0x04, 0x000210e7}, {0x09, 0x0002044f}, 266 + {0x0a, 0x0001adb0}, {0x0b, 0x00054867}, 267 + {0x0c, 0x0008992e}, {0x0d, 0x0000e529}, 268 + {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 269 + {0x19, 0x00000000}, {0x1a, 0x00000255}, 270 + {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 271 + {0x1d, 0x000a1250}, {0x1e, 0x0004445f}, 272 + {0x1f, 0x00080001}, {0x20, 0x0000b614}, 273 + {0x21, 0x0006c000}, {0x22, 0x0000083c}, 274 + {0x23, 0x00001558}, {0x24, 0x00000060}, 275 + {0x25, 0x00000483}, {0x26, 0x0004f000}, 276 + {0x27, 0x000ec7d9}, {0x28, 0x000977c0}, 277 + {0x29, 0x00004783}, {0x2a, 0x00000001}, 278 + {0x2b, 0x00021334}, {0x2a, 0x00000000}, 279 + {0x2b, 0x00000054}, {0x2a, 0x00000001}, 280 + {0x2b, 0x00000808}, {0x2b, 0x00053333}, 281 + {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 282 + {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 283 + {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 284 + {0x2b, 0x00000808}, {0x2b, 0x00063333}, 285 + {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 286 + {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 287 + {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 288 + {0x2b, 0x00000808}, {0x2b, 0x00073333}, 289 + {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 290 + {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 291 + {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 292 + {0x2b, 0x00000709}, {0x2b, 0x00063333}, 293 + {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 294 + {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 295 + {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 296 + {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 297 + {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 298 + {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 299 + {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 300 + {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 301 + {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 302 + {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 303 + {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 304 + {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 305 + {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 306 + {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 307 + {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 308 + {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 309 + {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 310 + {0x10, 0x0002000f}, {0x11, 0x000203f9}, 311 + {0x10, 0x0003000f}, {0x11, 0x000ff500}, 312 + {0x10, 0x00000000}, {0x11, 0x00000000}, 313 + {0x10, 0x0008000f}, {0x11, 0x0003f100}, 314 + {0x10, 0x0009000f}, {0x11, 0x00023100}, 315 + {0x12, 0x000d8000}, {0x12, 0x00090000}, 316 + {0x12, 0x00051000}, {0x12, 0x00012000}, 317 + {0x13, 0x00028fb4}, {0x13, 0x00024fa8}, 318 + {0x13, 0x000207a4}, {0x13, 0x0001c3b0}, 319 + {0x13, 0x000183a4}, {0x13, 0x00014398}, 320 + {0x13, 0x000101a4}, {0x13, 0x0000c198}, 321 + {0x13, 0x000080a4}, {0x13, 0x00004098}, 322 + {0x13, 0x00000000}, {0x14, 0x0001944c}, 323 + {0x14, 0x00059444}, {0x14, 0x0009944c}, 324 + {0x14, 0x000d9444}, {0x15, 0x0000f405}, 325 + {0x15, 0x0004f405}, {0x15, 0x0008f405}, 326 + {0x15, 0x000cf405}, {0x16, 0x000e0330}, 327 + {0x16, 0x000a0330}, {0x16, 0x00060330}, 328 + {0x16, 0x00020330}, {0x00, 0x00010159}, 329 + {0x18, 0x0000f401}, {0xfe, 0x00000000}, 330 + {0xfe, 0x00000000}, {0x1f, 0x00080003}, 331 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 332 + {0x1e, 0x00044457}, {0x1f, 0x00080000}, 333 + {0x00, 0x00030159}, 334 + {0xff, 0xffffffff} 335 + }; 336 + 337 + static int rtl8192cu_load_firmware(struct rtl8xxxu_priv *priv) 338 + { 339 + char *fw_name; 340 + int ret; 341 + 342 + if (!priv->vendor_umc) 343 + fw_name = "rtlwifi/rtl8192cufw_TMSC.bin"; 344 + else if (priv->chip_cut || priv->rtl_chip == RTL8192C) 345 + fw_name = "rtlwifi/rtl8192cufw_B.bin"; 346 + else 347 + fw_name = "rtlwifi/rtl8192cufw_A.bin"; 348 + 349 + ret = rtl8xxxu_load_firmware(priv, fw_name); 350 + 351 + return ret; 352 + } 353 + 354 + static int rtl8192cu_parse_efuse(struct rtl8xxxu_priv *priv) 355 + { 356 + struct rtl8192cu_efuse *efuse = &priv->efuse_wifi.efuse8192; 357 + int i; 358 + 359 + if (efuse->rtl_id != cpu_to_le16(0x8129)) 360 + return -EINVAL; 361 + 362 + ether_addr_copy(priv->mac_addr, efuse->mac_addr); 363 + 364 + memcpy(priv->cck_tx_power_index_A, 365 + efuse->cck_tx_power_index_A, 366 + sizeof(efuse->cck_tx_power_index_A)); 367 + memcpy(priv->cck_tx_power_index_B, 368 + efuse->cck_tx_power_index_B, 369 + sizeof(efuse->cck_tx_power_index_B)); 370 + 371 + memcpy(priv->ht40_1s_tx_power_index_A, 372 + efuse->ht40_1s_tx_power_index_A, 373 + sizeof(efuse->ht40_1s_tx_power_index_A)); 374 + memcpy(priv->ht40_1s_tx_power_index_B, 375 + efuse->ht40_1s_tx_power_index_B, 376 + sizeof(efuse->ht40_1s_tx_power_index_B)); 377 + memcpy(priv->ht40_2s_tx_power_index_diff, 378 + efuse->ht40_2s_tx_power_index_diff, 379 + sizeof(efuse->ht40_2s_tx_power_index_diff)); 380 + 381 + memcpy(priv->ht20_tx_power_index_diff, 382 + efuse->ht20_tx_power_index_diff, 383 + sizeof(efuse->ht20_tx_power_index_diff)); 384 + memcpy(priv->ofdm_tx_power_index_diff, 385 + efuse->ofdm_tx_power_index_diff, 386 + sizeof(efuse->ofdm_tx_power_index_diff)); 387 + 388 + memcpy(priv->ht40_max_power_offset, 389 + efuse->ht40_max_power_offset, 390 + sizeof(efuse->ht40_max_power_offset)); 391 + memcpy(priv->ht20_max_power_offset, 392 + efuse->ht20_max_power_offset, 393 + sizeof(efuse->ht20_max_power_offset)); 394 + 395 + dev_info(&priv->udev->dev, "Vendor: %.7s\n", 396 + efuse->vendor_name); 397 + dev_info(&priv->udev->dev, "Product: %.20s\n", 398 + efuse->device_name); 399 + 400 + priv->power_base = &rtl8192c_power_base; 401 + 402 + if (efuse->rf_regulatory & 0x20) { 403 + sprintf(priv->chip_name, "8188RU"); 404 + priv->rtl_chip = RTL8188R; 405 + priv->hi_pa = 1; 406 + priv->no_pape = 1; 407 + priv->power_base = &rtl8188r_power_base; 408 + } 409 + 410 + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { 411 + unsigned char *raw = priv->efuse_wifi.raw; 412 + 413 + dev_info(&priv->udev->dev, 414 + "%s: dumping efuse (0x%02zx bytes):\n", 415 + __func__, sizeof(struct rtl8192cu_efuse)); 416 + for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8) { 417 + dev_info(&priv->udev->dev, "%02x: " 418 + "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, 419 + raw[i], raw[i + 1], raw[i + 2], 420 + raw[i + 3], raw[i + 4], raw[i + 5], 421 + raw[i + 6], raw[i + 7]); 422 + } 423 + } 424 + return 0; 425 + } 426 + 427 + static int rtl8192cu_init_phy_rf(struct rtl8xxxu_priv *priv) 428 + { 429 + struct rtl8xxxu_rfregval *rftable; 430 + int ret; 431 + 432 + if (priv->rtl_chip == RTL8188R) { 433 + rftable = rtl8188ru_radioa_1t_highpa_table; 434 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 435 + } else if (priv->rf_paths == 1) { 436 + rftable = rtl8192cu_radioa_1t_init_table; 437 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 438 + } else { 439 + rftable = rtl8192cu_radioa_2t_init_table; 440 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_A); 441 + if (ret) 442 + goto exit; 443 + rftable = rtl8192cu_radiob_2t_init_table; 444 + ret = rtl8xxxu_init_phy_rf(priv, rftable, RF_B); 445 + } 446 + 447 + exit: 448 + return ret; 449 + } 450 + 451 + static int rtl8192cu_power_on(struct rtl8xxxu_priv *priv) 452 + { 453 + u8 val8; 454 + u16 val16; 455 + u32 val32; 456 + int i; 457 + 458 + for (i = 100; i; i--) { 459 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO); 460 + if (val8 & APS_FSMCO_PFM_ALDN) 461 + break; 462 + } 463 + 464 + if (!i) { 465 + pr_info("%s: Poll failed\n", __func__); 466 + return -ENODEV; 467 + } 468 + 469 + /* 470 + * RSV_CTRL 0x001C[7:0] = 0x00, unlock ISO/CLK/Power control register 471 + */ 472 + rtl8xxxu_write8(priv, REG_RSV_CTRL, 0x0); 473 + rtl8xxxu_write8(priv, REG_SPS0_CTRL, 0x2b); 474 + udelay(100); 475 + 476 + val8 = rtl8xxxu_read8(priv, REG_LDOV12D_CTRL); 477 + if (!(val8 & LDOV12D_ENABLE)) { 478 + pr_info("%s: Enabling LDOV12D (%02x)\n", __func__, val8); 479 + val8 |= LDOV12D_ENABLE; 480 + rtl8xxxu_write8(priv, REG_LDOV12D_CTRL, val8); 481 + 482 + udelay(100); 483 + 484 + val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 485 + val8 &= ~SYS_ISO_MD2PP; 486 + rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 487 + } 488 + 489 + /* 490 + * Auto enable WLAN 491 + */ 492 + val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); 493 + val16 |= APS_FSMCO_MAC_ENABLE; 494 + rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); 495 + 496 + for (i = 1000; i; i--) { 497 + val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); 498 + if (!(val16 & APS_FSMCO_MAC_ENABLE)) 499 + break; 500 + } 501 + if (!i) { 502 + pr_info("%s: FSMCO_MAC_ENABLE poll failed\n", __func__); 503 + return -EBUSY; 504 + } 505 + 506 + /* 507 + * Enable radio, GPIO, LED 508 + */ 509 + val16 = APS_FSMCO_HW_SUSPEND | APS_FSMCO_ENABLE_POWERDOWN | 510 + APS_FSMCO_PFM_ALDN; 511 + rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); 512 + 513 + /* 514 + * Release RF digital isolation 515 + */ 516 + val16 = rtl8xxxu_read16(priv, REG_SYS_ISO_CTRL); 517 + val16 &= ~SYS_ISO_DIOR; 518 + rtl8xxxu_write16(priv, REG_SYS_ISO_CTRL, val16); 519 + 520 + val8 = rtl8xxxu_read8(priv, REG_APSD_CTRL); 521 + val8 &= ~APSD_CTRL_OFF; 522 + rtl8xxxu_write8(priv, REG_APSD_CTRL, val8); 523 + for (i = 200; i; i--) { 524 + val8 = rtl8xxxu_read8(priv, REG_APSD_CTRL); 525 + if (!(val8 & APSD_CTRL_OFF_STATUS)) 526 + break; 527 + } 528 + 529 + if (!i) { 530 + pr_info("%s: APSD_CTRL poll failed\n", __func__); 531 + return -EBUSY; 532 + } 533 + 534 + /* 535 + * Enable MAC DMA/WMAC/SCHEDULE/SEC block 536 + */ 537 + val16 = rtl8xxxu_read16(priv, REG_CR); 538 + val16 |= CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 539 + CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | CR_PROTOCOL_ENABLE | 540 + CR_SCHEDULE_ENABLE | CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE; 541 + rtl8xxxu_write16(priv, REG_CR, val16); 542 + 543 + rtl8xxxu_write8(priv, 0xfe10, 0x19); 544 + 545 + /* 546 + * Workaround for 8188RU LNA power leakage problem. 547 + */ 548 + if (priv->rtl_chip == RTL8188R) { 549 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XCD_RF_PARM); 550 + val32 &= ~BIT(1); 551 + rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_PARM, val32); 552 + } 553 + return 0; 554 + } 555 + 556 + struct rtl8xxxu_fileops rtl8192cu_fops = { 557 + .parse_efuse = rtl8192cu_parse_efuse, 558 + .load_firmware = rtl8192cu_load_firmware, 559 + .power_on = rtl8192cu_power_on, 560 + .power_off = rtl8xxxu_power_off, 561 + .reset_8051 = rtl8xxxu_reset_8051, 562 + .llt_init = rtl8xxxu_init_llt_table, 563 + .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, 564 + .init_phy_rf = rtl8192cu_init_phy_rf, 565 + .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, 566 + .config_channel = rtl8xxxu_gen1_config_channel, 567 + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, 568 + .enable_rf = rtl8xxxu_gen1_enable_rf, 569 + .disable_rf = rtl8xxxu_gen1_disable_rf, 570 + .usb_quirks = rtl8xxxu_gen1_usb_quirks, 571 + .set_tx_power = rtl8xxxu_gen1_set_tx_power, 572 + .update_rate_mask = rtl8xxxu_update_rate_mask, 573 + .report_connect = rtl8xxxu_gen1_report_connect, 574 + .writeN_block_size = 128, 575 + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), 576 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), 577 + .adda_1t_init = 0x0b1b25a0, 578 + .adda_1t_path_on = 0x0bdb25a0, 579 + .adda_2t_path_on_a = 0x04db25a4, 580 + .adda_2t_path_on_b = 0x0b1b25a4, 581 + .trxff_boundary = 0x27ff, 582 + .pbp_rx = PBP_PAGE_SIZE_128, 583 + .pbp_tx = PBP_PAGE_SIZE_128, 584 + .mactable = rtl8xxxu_gen1_mac_init_table, 585 + }; 586 + #endif
+1525
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
··· 1 + /* 2 + * RTL8XXXU mac80211 USB driver - 8192e specific subdriver 3 + * 4 + * Copyright (c) 2014 - 2016 Jes Sorensen <Jes.Sorensen@redhat.com> 5 + * 6 + * Portions, notably calibration code: 7 + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 8 + * 9 + * This driver was written as a replacement for the vendor provided 10 + * rtl8723au driver. As the Realtek 8xxx chips are very similar in 11 + * their programming interface, I have started adding support for 12 + * additional 8xxx chips like the 8192cu, 8188cus, etc. 13 + * 14 + * This program is free software; you can redistribute it and/or modify it 15 + * under the terms of version 2 of the GNU General Public License as 16 + * published by the Free Software Foundation. 17 + * 18 + * This program is distributed in the hope that it will be useful, but WITHOUT 19 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 + * more details. 22 + */ 23 + 24 + #include <linux/init.h> 25 + #include <linux/kernel.h> 26 + #include <linux/sched.h> 27 + #include <linux/errno.h> 28 + #include <linux/slab.h> 29 + #include <linux/module.h> 30 + #include <linux/spinlock.h> 31 + #include <linux/list.h> 32 + #include <linux/usb.h> 33 + #include <linux/netdevice.h> 34 + #include <linux/etherdevice.h> 35 + #include <linux/ethtool.h> 36 + #include <linux/wireless.h> 37 + #include <linux/firmware.h> 38 + #include <linux/moduleparam.h> 39 + #include <net/mac80211.h> 40 + #include "rtl8xxxu.h" 41 + #include "rtl8xxxu_regs.h" 42 + 43 + static struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = { 44 + {0x011, 0xeb}, {0x012, 0x07}, {0x014, 0x75}, {0x303, 0xa7}, 45 + {0x428, 0x0a}, {0x429, 0x10}, {0x430, 0x00}, {0x431, 0x00}, 46 + {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 47 + {0x436, 0x07}, {0x437, 0x08}, {0x43c, 0x04}, {0x43d, 0x05}, 48 + {0x43e, 0x07}, {0x43f, 0x08}, {0x440, 0x5d}, {0x441, 0x01}, 49 + {0x442, 0x00}, {0x444, 0x10}, {0x445, 0x00}, {0x446, 0x00}, 50 + {0x447, 0x00}, {0x448, 0x00}, {0x449, 0xf0}, {0x44a, 0x0f}, 51 + {0x44b, 0x3e}, {0x44c, 0x10}, {0x44d, 0x00}, {0x44e, 0x00}, 52 + {0x44f, 0x00}, {0x450, 0x00}, {0x451, 0xf0}, {0x452, 0x0f}, 53 + {0x453, 0x00}, {0x456, 0x5e}, {0x460, 0x66}, {0x461, 0x66}, 54 + {0x4c8, 0xff}, {0x4c9, 0x08}, {0x4cc, 0xff}, {0x4cd, 0xff}, 55 + {0x4ce, 0x01}, {0x500, 0x26}, {0x501, 0xa2}, {0x502, 0x2f}, 56 + {0x503, 0x00}, {0x504, 0x28}, {0x505, 0xa3}, {0x506, 0x5e}, 57 + {0x507, 0x00}, {0x508, 0x2b}, {0x509, 0xa4}, {0x50a, 0x5e}, 58 + {0x50b, 0x00}, {0x50c, 0x4f}, {0x50d, 0xa4}, {0x50e, 0x00}, 59 + {0x50f, 0x00}, {0x512, 0x1c}, {0x514, 0x0a}, {0x516, 0x0a}, 60 + {0x525, 0x4f}, {0x540, 0x12}, {0x541, 0x64}, {0x550, 0x10}, 61 + {0x551, 0x10}, {0x559, 0x02}, {0x55c, 0x50}, {0x55d, 0xff}, 62 + {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, {0x620, 0xff}, 63 + {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, {0x624, 0xff}, 64 + {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, {0x638, 0x50}, 65 + {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, {0x63f, 0x0e}, 66 + {0x640, 0x40}, {0x642, 0x40}, {0x643, 0x00}, {0x652, 0xc8}, 67 + {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, {0x702, 0x65}, 68 + {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, {0x70a, 0x65}, 69 + {0x70b, 0x87}, 70 + {0xffff, 0xff}, 71 + }; 72 + 73 + static struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] = { 74 + {0x800, 0x80040000}, {0x804, 0x00000003}, 75 + {0x808, 0x0000fc00}, {0x80c, 0x0000000a}, 76 + {0x810, 0x10001331}, {0x814, 0x020c3d10}, 77 + {0x818, 0x02220385}, {0x81c, 0x00000000}, 78 + {0x820, 0x01000100}, {0x824, 0x00390204}, 79 + {0x828, 0x01000100}, {0x82c, 0x00390204}, 80 + {0x830, 0x32323232}, {0x834, 0x30303030}, 81 + {0x838, 0x30303030}, {0x83c, 0x30303030}, 82 + {0x840, 0x00010000}, {0x844, 0x00010000}, 83 + {0x848, 0x28282828}, {0x84c, 0x28282828}, 84 + {0x850, 0x00000000}, {0x854, 0x00000000}, 85 + {0x858, 0x009a009a}, {0x85c, 0x01000014}, 86 + {0x860, 0x66f60000}, {0x864, 0x061f0000}, 87 + {0x868, 0x30303030}, {0x86c, 0x30303030}, 88 + {0x870, 0x00000000}, {0x874, 0x55004200}, 89 + {0x878, 0x08080808}, {0x87c, 0x00000000}, 90 + {0x880, 0xb0000c1c}, {0x884, 0x00000001}, 91 + {0x888, 0x00000000}, {0x88c, 0xcc0000c0}, 92 + {0x890, 0x00000800}, {0x894, 0xfffffffe}, 93 + {0x898, 0x40302010}, {0x900, 0x00000000}, 94 + {0x904, 0x00000023}, {0x908, 0x00000000}, 95 + {0x90c, 0x81121313}, {0x910, 0x806c0001}, 96 + {0x914, 0x00000001}, {0x918, 0x00000000}, 97 + {0x91c, 0x00010000}, {0x924, 0x00000001}, 98 + {0x928, 0x00000000}, {0x92c, 0x00000000}, 99 + {0x930, 0x00000000}, {0x934, 0x00000000}, 100 + {0x938, 0x00000000}, {0x93c, 0x00000000}, 101 + {0x940, 0x00000000}, {0x944, 0x00000000}, 102 + {0x94c, 0x00000008}, {0xa00, 0x00d0c7c8}, 103 + {0xa04, 0x81ff000c}, {0xa08, 0x8c838300}, 104 + {0xa0c, 0x2e68120f}, {0xa10, 0x95009b78}, 105 + {0xa14, 0x1114d028}, {0xa18, 0x00881117}, 106 + {0xa1c, 0x89140f00}, {0xa20, 0x1a1b0000}, 107 + {0xa24, 0x090e1317}, {0xa28, 0x00000204}, 108 + {0xa2c, 0x00d30000}, {0xa70, 0x101fff00}, 109 + {0xa74, 0x00000007}, {0xa78, 0x00000900}, 110 + {0xa7c, 0x225b0606}, {0xa80, 0x218075b1}, 111 + {0xb38, 0x00000000}, {0xc00, 0x48071d40}, 112 + {0xc04, 0x03a05633}, {0xc08, 0x000000e4}, 113 + {0xc0c, 0x6c6c6c6c}, {0xc10, 0x08800000}, 114 + {0xc14, 0x40000100}, {0xc18, 0x08800000}, 115 + {0xc1c, 0x40000100}, {0xc20, 0x00000000}, 116 + {0xc24, 0x00000000}, {0xc28, 0x00000000}, 117 + {0xc2c, 0x00000000}, {0xc30, 0x69e9ac47}, 118 + {0xc34, 0x469652af}, {0xc38, 0x49795994}, 119 + {0xc3c, 0x0a97971c}, {0xc40, 0x1f7c403f}, 120 + {0xc44, 0x000100b7}, {0xc48, 0xec020107}, 121 + {0xc4c, 0x007f037f}, 122 + #ifdef EXT_PA_8192EU 123 + /* External PA or external LNA */ 124 + {0xc50, 0x00340220}, 125 + #else 126 + {0xc50, 0x00340020}, 127 + #endif 128 + {0xc54, 0x0080801f}, 129 + #ifdef EXT_PA_8192EU 130 + /* External PA or external LNA */ 131 + {0xc58, 0x00000220}, 132 + #else 133 + {0xc58, 0x00000020}, 134 + #endif 135 + {0xc5c, 0x00248492}, {0xc60, 0x00000000}, 136 + {0xc64, 0x7112848b}, {0xc68, 0x47c00bff}, 137 + {0xc6c, 0x00000036}, {0xc70, 0x00000600}, 138 + {0xc74, 0x02013169}, {0xc78, 0x0000001f}, 139 + {0xc7c, 0x00b91612}, 140 + #ifdef EXT_PA_8192EU 141 + /* External PA or external LNA */ 142 + {0xc80, 0x2d4000b5}, 143 + #else 144 + {0xc80, 0x40000100}, 145 + #endif 146 + {0xc84, 0x21f60000}, 147 + #ifdef EXT_PA_8192EU 148 + /* External PA or external LNA */ 149 + {0xc88, 0x2d4000b5}, 150 + #else 151 + {0xc88, 0x40000100}, 152 + #endif 153 + {0xc8c, 0xa0e40000}, {0xc90, 0x00121820}, 154 + {0xc94, 0x00000000}, {0xc98, 0x00121820}, 155 + {0xc9c, 0x00007f7f}, {0xca0, 0x00000000}, 156 + {0xca4, 0x000300a0}, {0xca8, 0x00000000}, 157 + {0xcac, 0x00000000}, {0xcb0, 0x00000000}, 158 + {0xcb4, 0x00000000}, {0xcb8, 0x00000000}, 159 + {0xcbc, 0x28000000}, {0xcc0, 0x00000000}, 160 + {0xcc4, 0x00000000}, {0xcc8, 0x00000000}, 161 + {0xccc, 0x00000000}, {0xcd0, 0x00000000}, 162 + {0xcd4, 0x00000000}, {0xcd8, 0x64b22427}, 163 + {0xcdc, 0x00766932}, {0xce0, 0x00222222}, 164 + {0xce4, 0x00040000}, {0xce8, 0x77644302}, 165 + {0xcec, 0x2f97d40c}, {0xd00, 0x00080740}, 166 + {0xd04, 0x00020403}, {0xd08, 0x0000907f}, 167 + {0xd0c, 0x20010201}, {0xd10, 0xa0633333}, 168 + {0xd14, 0x3333bc43}, {0xd18, 0x7a8f5b6b}, 169 + {0xd1c, 0x0000007f}, {0xd2c, 0xcc979975}, 170 + {0xd30, 0x00000000}, {0xd34, 0x80608000}, 171 + {0xd38, 0x00000000}, {0xd3c, 0x00127353}, 172 + {0xd40, 0x00000000}, {0xd44, 0x00000000}, 173 + {0xd48, 0x00000000}, {0xd4c, 0x00000000}, 174 + {0xd50, 0x6437140a}, {0xd54, 0x00000000}, 175 + {0xd58, 0x00000282}, {0xd5c, 0x30032064}, 176 + {0xd60, 0x4653de68}, {0xd64, 0x04518a3c}, 177 + {0xd68, 0x00002101}, {0xd6c, 0x2a201c16}, 178 + {0xd70, 0x1812362e}, {0xd74, 0x322c2220}, 179 + {0xd78, 0x000e3c24}, {0xd80, 0x01081008}, 180 + {0xd84, 0x00000800}, {0xd88, 0xf0b50000}, 181 + {0xe00, 0x30303030}, {0xe04, 0x30303030}, 182 + {0xe08, 0x03903030}, {0xe10, 0x30303030}, 183 + {0xe14, 0x30303030}, {0xe18, 0x30303030}, 184 + {0xe1c, 0x30303030}, {0xe28, 0x00000000}, 185 + {0xe30, 0x1000dc1f}, {0xe34, 0x10008c1f}, 186 + {0xe38, 0x02140102}, {0xe3c, 0x681604c2}, 187 + {0xe40, 0x01007c00}, {0xe44, 0x01004800}, 188 + {0xe48, 0xfb000000}, {0xe4c, 0x000028d1}, 189 + {0xe50, 0x1000dc1f}, {0xe54, 0x10008c1f}, 190 + {0xe58, 0x02140102}, {0xe5c, 0x28160d05}, 191 + {0xe60, 0x00000008}, {0xe68, 0x0fc05656}, 192 + {0xe6c, 0x03c09696}, {0xe70, 0x03c09696}, 193 + {0xe74, 0x0c005656}, {0xe78, 0x0c005656}, 194 + {0xe7c, 0x0c005656}, {0xe80, 0x0c005656}, 195 + {0xe84, 0x03c09696}, {0xe88, 0x0c005656}, 196 + {0xe8c, 0x03c09696}, {0xed0, 0x03c09696}, 197 + {0xed4, 0x03c09696}, {0xed8, 0x03c09696}, 198 + {0xedc, 0x0000d6d6}, {0xee0, 0x0000d6d6}, 199 + {0xeec, 0x0fc01616}, {0xee4, 0xb0000c1c}, 200 + {0xee8, 0x00000001}, {0xf14, 0x00000003}, 201 + {0xf4c, 0x00000000}, {0xf00, 0x00000300}, 202 + {0xffff, 0xffffffff}, 203 + }; 204 + 205 + static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_std_table[] = { 206 + {0xc78, 0xfb000001}, {0xc78, 0xfb010001}, 207 + {0xc78, 0xfb020001}, {0xc78, 0xfb030001}, 208 + {0xc78, 0xfb040001}, {0xc78, 0xfb050001}, 209 + {0xc78, 0xfa060001}, {0xc78, 0xf9070001}, 210 + {0xc78, 0xf8080001}, {0xc78, 0xf7090001}, 211 + {0xc78, 0xf60a0001}, {0xc78, 0xf50b0001}, 212 + {0xc78, 0xf40c0001}, {0xc78, 0xf30d0001}, 213 + {0xc78, 0xf20e0001}, {0xc78, 0xf10f0001}, 214 + {0xc78, 0xf0100001}, {0xc78, 0xef110001}, 215 + {0xc78, 0xee120001}, {0xc78, 0xed130001}, 216 + {0xc78, 0xec140001}, {0xc78, 0xeb150001}, 217 + {0xc78, 0xea160001}, {0xc78, 0xe9170001}, 218 + {0xc78, 0xe8180001}, {0xc78, 0xe7190001}, 219 + {0xc78, 0xc81a0001}, {0xc78, 0xc71b0001}, 220 + {0xc78, 0xc61c0001}, {0xc78, 0x071d0001}, 221 + {0xc78, 0x061e0001}, {0xc78, 0x051f0001}, 222 + {0xc78, 0x04200001}, {0xc78, 0x03210001}, 223 + {0xc78, 0xaa220001}, {0xc78, 0xa9230001}, 224 + {0xc78, 0xa8240001}, {0xc78, 0xa7250001}, 225 + {0xc78, 0xa6260001}, {0xc78, 0x85270001}, 226 + {0xc78, 0x84280001}, {0xc78, 0x83290001}, 227 + {0xc78, 0x252a0001}, {0xc78, 0x242b0001}, 228 + {0xc78, 0x232c0001}, {0xc78, 0x222d0001}, 229 + {0xc78, 0x672e0001}, {0xc78, 0x662f0001}, 230 + {0xc78, 0x65300001}, {0xc78, 0x64310001}, 231 + {0xc78, 0x63320001}, {0xc78, 0x62330001}, 232 + {0xc78, 0x61340001}, {0xc78, 0x45350001}, 233 + {0xc78, 0x44360001}, {0xc78, 0x43370001}, 234 + {0xc78, 0x42380001}, {0xc78, 0x41390001}, 235 + {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 236 + {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 237 + {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 238 + {0xc78, 0xfb400001}, {0xc78, 0xfb410001}, 239 + {0xc78, 0xfb420001}, {0xc78, 0xfb430001}, 240 + {0xc78, 0xfb440001}, {0xc78, 0xfb450001}, 241 + {0xc78, 0xfa460001}, {0xc78, 0xf9470001}, 242 + {0xc78, 0xf8480001}, {0xc78, 0xf7490001}, 243 + {0xc78, 0xf64a0001}, {0xc78, 0xf54b0001}, 244 + {0xc78, 0xf44c0001}, {0xc78, 0xf34d0001}, 245 + {0xc78, 0xf24e0001}, {0xc78, 0xf14f0001}, 246 + {0xc78, 0xf0500001}, {0xc78, 0xef510001}, 247 + {0xc78, 0xee520001}, {0xc78, 0xed530001}, 248 + {0xc78, 0xec540001}, {0xc78, 0xeb550001}, 249 + {0xc78, 0xea560001}, {0xc78, 0xe9570001}, 250 + {0xc78, 0xe8580001}, {0xc78, 0xe7590001}, 251 + {0xc78, 0xe65a0001}, {0xc78, 0xe55b0001}, 252 + {0xc78, 0xe45c0001}, {0xc78, 0xe35d0001}, 253 + {0xc78, 0xe25e0001}, {0xc78, 0xe15f0001}, 254 + {0xc78, 0x8a600001}, {0xc78, 0x89610001}, 255 + {0xc78, 0x88620001}, {0xc78, 0x87630001}, 256 + {0xc78, 0x86640001}, {0xc78, 0x85650001}, 257 + {0xc78, 0x84660001}, {0xc78, 0x83670001}, 258 + {0xc78, 0x82680001}, {0xc78, 0x6b690001}, 259 + {0xc78, 0x6a6a0001}, {0xc78, 0x696b0001}, 260 + {0xc78, 0x686c0001}, {0xc78, 0x676d0001}, 261 + {0xc78, 0x666e0001}, {0xc78, 0x656f0001}, 262 + {0xc78, 0x64700001}, {0xc78, 0x63710001}, 263 + {0xc78, 0x62720001}, {0xc78, 0x61730001}, 264 + {0xc78, 0x49740001}, {0xc78, 0x48750001}, 265 + {0xc78, 0x47760001}, {0xc78, 0x46770001}, 266 + {0xc78, 0x45780001}, {0xc78, 0x44790001}, 267 + {0xc78, 0x437a0001}, {0xc78, 0x427b0001}, 268 + {0xc78, 0x417c0001}, {0xc78, 0x407d0001}, 269 + {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 270 + {0xc50, 0x00040022}, {0xc50, 0x00040020}, 271 + {0xffff, 0xffffffff} 272 + }; 273 + 274 + static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_highpa_table[] = { 275 + {0xc78, 0xfa000001}, {0xc78, 0xf9010001}, 276 + {0xc78, 0xf8020001}, {0xc78, 0xf7030001}, 277 + {0xc78, 0xf6040001}, {0xc78, 0xf5050001}, 278 + {0xc78, 0xf4060001}, {0xc78, 0xf3070001}, 279 + {0xc78, 0xf2080001}, {0xc78, 0xf1090001}, 280 + {0xc78, 0xf00a0001}, {0xc78, 0xef0b0001}, 281 + {0xc78, 0xee0c0001}, {0xc78, 0xed0d0001}, 282 + {0xc78, 0xec0e0001}, {0xc78, 0xeb0f0001}, 283 + {0xc78, 0xea100001}, {0xc78, 0xe9110001}, 284 + {0xc78, 0xe8120001}, {0xc78, 0xe7130001}, 285 + {0xc78, 0xe6140001}, {0xc78, 0xe5150001}, 286 + {0xc78, 0xe4160001}, {0xc78, 0xe3170001}, 287 + {0xc78, 0xe2180001}, {0xc78, 0xe1190001}, 288 + {0xc78, 0x8a1a0001}, {0xc78, 0x891b0001}, 289 + {0xc78, 0x881c0001}, {0xc78, 0x871d0001}, 290 + {0xc78, 0x861e0001}, {0xc78, 0x851f0001}, 291 + {0xc78, 0x84200001}, {0xc78, 0x83210001}, 292 + {0xc78, 0x82220001}, {0xc78, 0x6a230001}, 293 + {0xc78, 0x69240001}, {0xc78, 0x68250001}, 294 + {0xc78, 0x67260001}, {0xc78, 0x66270001}, 295 + {0xc78, 0x65280001}, {0xc78, 0x64290001}, 296 + {0xc78, 0x632a0001}, {0xc78, 0x622b0001}, 297 + {0xc78, 0x612c0001}, {0xc78, 0x602d0001}, 298 + {0xc78, 0x472e0001}, {0xc78, 0x462f0001}, 299 + {0xc78, 0x45300001}, {0xc78, 0x44310001}, 300 + {0xc78, 0x43320001}, {0xc78, 0x42330001}, 301 + {0xc78, 0x41340001}, {0xc78, 0x40350001}, 302 + {0xc78, 0x40360001}, {0xc78, 0x40370001}, 303 + {0xc78, 0x40380001}, {0xc78, 0x40390001}, 304 + {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, 305 + {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, 306 + {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, 307 + {0xc78, 0xfa400001}, {0xc78, 0xf9410001}, 308 + {0xc78, 0xf8420001}, {0xc78, 0xf7430001}, 309 + {0xc78, 0xf6440001}, {0xc78, 0xf5450001}, 310 + {0xc78, 0xf4460001}, {0xc78, 0xf3470001}, 311 + {0xc78, 0xf2480001}, {0xc78, 0xf1490001}, 312 + {0xc78, 0xf04a0001}, {0xc78, 0xef4b0001}, 313 + {0xc78, 0xee4c0001}, {0xc78, 0xed4d0001}, 314 + {0xc78, 0xec4e0001}, {0xc78, 0xeb4f0001}, 315 + {0xc78, 0xea500001}, {0xc78, 0xe9510001}, 316 + {0xc78, 0xe8520001}, {0xc78, 0xe7530001}, 317 + {0xc78, 0xe6540001}, {0xc78, 0xe5550001}, 318 + {0xc78, 0xe4560001}, {0xc78, 0xe3570001}, 319 + {0xc78, 0xe2580001}, {0xc78, 0xe1590001}, 320 + {0xc78, 0x8a5a0001}, {0xc78, 0x895b0001}, 321 + {0xc78, 0x885c0001}, {0xc78, 0x875d0001}, 322 + {0xc78, 0x865e0001}, {0xc78, 0x855f0001}, 323 + {0xc78, 0x84600001}, {0xc78, 0x83610001}, 324 + {0xc78, 0x82620001}, {0xc78, 0x6a630001}, 325 + {0xc78, 0x69640001}, {0xc78, 0x68650001}, 326 + {0xc78, 0x67660001}, {0xc78, 0x66670001}, 327 + {0xc78, 0x65680001}, {0xc78, 0x64690001}, 328 + {0xc78, 0x636a0001}, {0xc78, 0x626b0001}, 329 + {0xc78, 0x616c0001}, {0xc78, 0x606d0001}, 330 + {0xc78, 0x476e0001}, {0xc78, 0x466f0001}, 331 + {0xc78, 0x45700001}, {0xc78, 0x44710001}, 332 + {0xc78, 0x43720001}, {0xc78, 0x42730001}, 333 + {0xc78, 0x41740001}, {0xc78, 0x40750001}, 334 + {0xc78, 0x40760001}, {0xc78, 0x40770001}, 335 + {0xc78, 0x40780001}, {0xc78, 0x40790001}, 336 + {0xc78, 0x407a0001}, {0xc78, 0x407b0001}, 337 + {0xc78, 0x407c0001}, {0xc78, 0x407d0001}, 338 + {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, 339 + {0xc50, 0x00040222}, {0xc50, 0x00040220}, 340 + {0xffff, 0xffffffff} 341 + }; 342 + 343 + static struct rtl8xxxu_rfregval rtl8192eu_radioa_init_table[] = { 344 + {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 345 + {0x00, 0x00030000}, {0x08, 0x00008400}, 346 + {0x18, 0x00000407}, {0x19, 0x00000012}, 347 + {0x1b, 0x00000064}, {0x1e, 0x00080009}, 348 + {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 349 + {0x3f, 0x00000000}, {0x42, 0x000060c0}, 350 + {0x57, 0x000d0000}, {0x58, 0x000be180}, 351 + {0x67, 0x00001552}, {0x83, 0x00000000}, 352 + {0xb0, 0x000ff9f1}, {0xb1, 0x00055418}, 353 + {0xb2, 0x0008cc00}, {0xb4, 0x00043083}, 354 + {0xb5, 0x00008166}, {0xb6, 0x0000803e}, 355 + {0xb7, 0x0001c69f}, {0xb8, 0x0000407f}, 356 + {0xb9, 0x00080001}, {0xba, 0x00040001}, 357 + {0xbb, 0x00000400}, {0xbf, 0x000c0000}, 358 + {0xc2, 0x00002400}, {0xc3, 0x00000009}, 359 + {0xc4, 0x00040c91}, {0xc5, 0x00099999}, 360 + {0xc6, 0x000000a3}, {0xc7, 0x00088820}, 361 + {0xc8, 0x00076c06}, {0xc9, 0x00000000}, 362 + {0xca, 0x00080000}, {0xdf, 0x00000180}, 363 + {0xef, 0x000001a0}, {0x51, 0x00069545}, 364 + {0x52, 0x0007e45e}, {0x53, 0x00000071}, 365 + {0x56, 0x00051ff3}, {0x35, 0x000000a8}, 366 + {0x35, 0x000001e2}, {0x35, 0x000002a8}, 367 + {0x36, 0x00001c24}, {0x36, 0x00009c24}, 368 + {0x36, 0x00011c24}, {0x36, 0x00019c24}, 369 + {0x18, 0x00000c07}, {0x5a, 0x00048000}, 370 + {0x19, 0x000739d0}, 371 + #ifdef EXT_PA_8192EU 372 + /* External PA or external LNA */ 373 + {0x34, 0x0000a093}, {0x34, 0x0000908f}, 374 + {0x34, 0x0000808c}, {0x34, 0x0000704d}, 375 + {0x34, 0x0000604a}, {0x34, 0x00005047}, 376 + {0x34, 0x0000400a}, {0x34, 0x00003007}, 377 + {0x34, 0x00002004}, {0x34, 0x00001001}, 378 + {0x34, 0x00000000}, 379 + #else 380 + /* Regular */ 381 + {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 382 + {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 383 + {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 384 + {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 385 + {0x34, 0x0000244f}, {0x34, 0x0000144c}, 386 + {0x34, 0x00000014}, 387 + #endif 388 + {0x00, 0x00030159}, 389 + {0x84, 0x00068180}, 390 + {0x86, 0x0000014e}, 391 + {0x87, 0x00048e00}, 392 + {0x8e, 0x00065540}, 393 + {0x8f, 0x00088000}, 394 + {0xef, 0x000020a0}, 395 + #ifdef EXT_PA_8192EU 396 + /* External PA or external LNA */ 397 + {0x3b, 0x000f07b0}, 398 + #else 399 + {0x3b, 0x000f02b0}, 400 + #endif 401 + {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 402 + {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 403 + {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 404 + {0x3b, 0x0008f780}, 405 + #ifdef EXT_PA_8192EU 406 + /* External PA or external LNA */ 407 + {0x3b, 0x000787b0}, 408 + #else 409 + {0x3b, 0x00078730}, 410 + #endif 411 + {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 412 + {0x3b, 0x00040620}, {0x3b, 0x00037090}, 413 + {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 414 + {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 415 + {0xfe, 0x00000000}, {0x18, 0x0000fc07}, 416 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 417 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 418 + {0x1e, 0x00000001}, {0x1f, 0x00080000}, 419 + {0x00, 0x00033e70}, 420 + {0xff, 0xffffffff} 421 + }; 422 + 423 + static struct rtl8xxxu_rfregval rtl8192eu_radiob_init_table[] = { 424 + {0x7f, 0x00000082}, {0x81, 0x0003fc00}, 425 + {0x00, 0x00030000}, {0x08, 0x00008400}, 426 + {0x18, 0x00000407}, {0x19, 0x00000012}, 427 + {0x1b, 0x00000064}, {0x1e, 0x00080009}, 428 + {0x1f, 0x00000880}, {0x2f, 0x0001a060}, 429 + {0x3f, 0x00000000}, {0x42, 0x000060c0}, 430 + {0x57, 0x000d0000}, {0x58, 0x000be180}, 431 + {0x67, 0x00001552}, {0x7f, 0x00000082}, 432 + {0x81, 0x0003f000}, {0x83, 0x00000000}, 433 + {0xdf, 0x00000180}, {0xef, 0x000001a0}, 434 + {0x51, 0x00069545}, {0x52, 0x0007e42e}, 435 + {0x53, 0x00000071}, {0x56, 0x00051ff3}, 436 + {0x35, 0x000000a8}, {0x35, 0x000001e0}, 437 + {0x35, 0x000002a8}, {0x36, 0x00001ca8}, 438 + {0x36, 0x00009c24}, {0x36, 0x00011c24}, 439 + {0x36, 0x00019c24}, {0x18, 0x00000c07}, 440 + {0x5a, 0x00048000}, {0x19, 0x000739d0}, 441 + #ifdef EXT_PA_8192EU 442 + /* External PA or external LNA */ 443 + {0x34, 0x0000a093}, {0x34, 0x0000908f}, 444 + {0x34, 0x0000808c}, {0x34, 0x0000704d}, 445 + {0x34, 0x0000604a}, {0x34, 0x00005047}, 446 + {0x34, 0x0000400a}, {0x34, 0x00003007}, 447 + {0x34, 0x00002004}, {0x34, 0x00001001}, 448 + {0x34, 0x00000000}, 449 + #else 450 + {0x34, 0x0000add7}, {0x34, 0x00009dd4}, 451 + {0x34, 0x00008dd1}, {0x34, 0x00007dce}, 452 + {0x34, 0x00006dcb}, {0x34, 0x00005dc8}, 453 + {0x34, 0x00004dc5}, {0x34, 0x000034cc}, 454 + {0x34, 0x0000244f}, {0x34, 0x0000144c}, 455 + {0x34, 0x00000014}, 456 + #endif 457 + {0x00, 0x00030159}, {0x84, 0x00068180}, 458 + {0x86, 0x000000ce}, {0x87, 0x00048a00}, 459 + {0x8e, 0x00065540}, {0x8f, 0x00088000}, 460 + {0xef, 0x000020a0}, 461 + #ifdef EXT_PA_8192EU 462 + /* External PA or external LNA */ 463 + {0x3b, 0x000f07b0}, 464 + #else 465 + {0x3b, 0x000f02b0}, 466 + #endif 467 + 468 + {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, 469 + {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, 470 + {0x3b, 0x000a0080}, {0x3b, 0x00090080}, 471 + {0x3b, 0x0008f780}, 472 + #ifdef EXT_PA_8192EU 473 + /* External PA or external LNA */ 474 + {0x3b, 0x000787b0}, 475 + #else 476 + {0x3b, 0x00078730}, 477 + #endif 478 + {0x3b, 0x00060fb0}, {0x3b, 0x0005ffa0}, 479 + {0x3b, 0x00040620}, {0x3b, 0x00037090}, 480 + {0x3b, 0x00020080}, {0x3b, 0x0001f060}, 481 + {0x3b, 0x0000ffb0}, {0xef, 0x000000a0}, 482 + {0x00, 0x00010159}, {0xfe, 0x00000000}, 483 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 484 + {0xfe, 0x00000000}, {0x1e, 0x00000001}, 485 + {0x1f, 0x00080000}, {0x00, 0x00033e70}, 486 + {0xff, 0xffffffff} 487 + }; 488 + 489 + static void 490 + rtl8192e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 491 + { 492 + u32 val32, ofdm, mcs; 493 + u8 cck, ofdmbase, mcsbase; 494 + int group, tx_idx; 495 + 496 + tx_idx = 0; 497 + group = rtl8xxxu_gen2_channel_to_group(channel); 498 + 499 + cck = priv->cck_tx_power_index_A[group]; 500 + 501 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); 502 + val32 &= 0xffff00ff; 503 + val32 |= (cck << 8); 504 + rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32); 505 + 506 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 507 + val32 &= 0xff; 508 + val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 509 + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 510 + 511 + ofdmbase = priv->ht40_1s_tx_power_index_A[group]; 512 + ofdmbase += priv->ofdm_tx_power_diff[tx_idx].a; 513 + ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24; 514 + 515 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm); 516 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm); 517 + 518 + mcsbase = priv->ht40_1s_tx_power_index_A[group]; 519 + if (ht40) 520 + mcsbase += priv->ht40_tx_power_diff[tx_idx++].a; 521 + else 522 + mcsbase += priv->ht20_tx_power_diff[tx_idx++].a; 523 + mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 524 + 525 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); 526 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); 527 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, mcs); 528 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs); 529 + 530 + if (priv->tx_paths > 1) { 531 + cck = priv->cck_tx_power_index_B[group]; 532 + 533 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK1_55_MCS32); 534 + val32 &= 0xff; 535 + val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 536 + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK1_55_MCS32, val32); 537 + 538 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 539 + val32 &= 0xffffff00; 540 + val32 |= cck; 541 + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 542 + 543 + ofdmbase = priv->ht40_1s_tx_power_index_B[group]; 544 + ofdmbase += priv->ofdm_tx_power_diff[tx_idx].b; 545 + ofdm = ofdmbase | ofdmbase << 8 | 546 + ofdmbase << 16 | ofdmbase << 24; 547 + 548 + rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE18_06, ofdm); 549 + rtl8xxxu_write32(priv, REG_TX_AGC_B_RATE54_24, ofdm); 550 + 551 + mcsbase = priv->ht40_1s_tx_power_index_B[group]; 552 + if (ht40) 553 + mcsbase += priv->ht40_tx_power_diff[tx_idx++].b; 554 + else 555 + mcsbase += priv->ht20_tx_power_diff[tx_idx++].b; 556 + mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 557 + 558 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS03_MCS00, mcs); 559 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS07_MCS04, mcs); 560 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS11_MCS08, mcs); 561 + rtl8xxxu_write32(priv, REG_TX_AGC_B_MCS15_MCS12, mcs); 562 + } 563 + } 564 + 565 + static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv) 566 + { 567 + struct rtl8192eu_efuse *efuse = &priv->efuse_wifi.efuse8192eu; 568 + int i; 569 + 570 + if (efuse->rtl_id != cpu_to_le16(0x8129)) 571 + return -EINVAL; 572 + 573 + ether_addr_copy(priv->mac_addr, efuse->mac_addr); 574 + 575 + memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base, 576 + sizeof(efuse->tx_power_index_A.cck_base)); 577 + memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_B.cck_base, 578 + sizeof(efuse->tx_power_index_B.cck_base)); 579 + 580 + memcpy(priv->ht40_1s_tx_power_index_A, 581 + efuse->tx_power_index_A.ht40_base, 582 + sizeof(efuse->tx_power_index_A.ht40_base)); 583 + memcpy(priv->ht40_1s_tx_power_index_B, 584 + efuse->tx_power_index_B.ht40_base, 585 + sizeof(efuse->tx_power_index_B.ht40_base)); 586 + 587 + priv->ht20_tx_power_diff[0].a = 588 + efuse->tx_power_index_A.ht20_ofdm_1s_diff.b; 589 + priv->ht20_tx_power_diff[0].b = 590 + efuse->tx_power_index_B.ht20_ofdm_1s_diff.b; 591 + 592 + priv->ht40_tx_power_diff[0].a = 0; 593 + priv->ht40_tx_power_diff[0].b = 0; 594 + 595 + for (i = 1; i < RTL8723B_TX_COUNT; i++) { 596 + priv->ofdm_tx_power_diff[i].a = 597 + efuse->tx_power_index_A.pwr_diff[i - 1].ofdm; 598 + priv->ofdm_tx_power_diff[i].b = 599 + efuse->tx_power_index_B.pwr_diff[i - 1].ofdm; 600 + 601 + priv->ht20_tx_power_diff[i].a = 602 + efuse->tx_power_index_A.pwr_diff[i - 1].ht20; 603 + priv->ht20_tx_power_diff[i].b = 604 + efuse->tx_power_index_B.pwr_diff[i - 1].ht20; 605 + 606 + priv->ht40_tx_power_diff[i].a = 607 + efuse->tx_power_index_A.pwr_diff[i - 1].ht40; 608 + priv->ht40_tx_power_diff[i].b = 609 + efuse->tx_power_index_B.pwr_diff[i - 1].ht40; 610 + } 611 + 612 + priv->has_xtalk = 1; 613 + priv->xtalk = priv->efuse_wifi.efuse8192eu.xtal_k & 0x3f; 614 + 615 + dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); 616 + dev_info(&priv->udev->dev, "Product: %.11s\n", efuse->device_name); 617 + dev_info(&priv->udev->dev, "Serial: %.11s\n", efuse->serial); 618 + 619 + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { 620 + unsigned char *raw = priv->efuse_wifi.raw; 621 + 622 + dev_info(&priv->udev->dev, 623 + "%s: dumping efuse (0x%02zx bytes):\n", 624 + __func__, sizeof(struct rtl8192eu_efuse)); 625 + for (i = 0; i < sizeof(struct rtl8192eu_efuse); i += 8) { 626 + dev_info(&priv->udev->dev, "%02x: " 627 + "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, 628 + raw[i], raw[i + 1], raw[i + 2], 629 + raw[i + 3], raw[i + 4], raw[i + 5], 630 + raw[i + 6], raw[i + 7]); 631 + } 632 + } 633 + return 0; 634 + } 635 + 636 + static int rtl8192eu_load_firmware(struct rtl8xxxu_priv *priv) 637 + { 638 + char *fw_name; 639 + int ret; 640 + 641 + fw_name = "rtlwifi/rtl8192eu_nic.bin"; 642 + 643 + ret = rtl8xxxu_load_firmware(priv, fw_name); 644 + 645 + return ret; 646 + } 647 + 648 + static void rtl8192eu_init_phy_bb(struct rtl8xxxu_priv *priv) 649 + { 650 + u8 val8; 651 + u16 val16; 652 + 653 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 654 + val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; 655 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 656 + 657 + /* 6. 0x1f[7:0] = 0x07 */ 658 + val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 659 + rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 660 + 661 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 662 + val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD | SYS_FUNC_DIO_RF | 663 + SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB); 664 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 665 + val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 666 + rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 667 + rtl8xxxu_init_phy_regs(priv, rtl8192eu_phy_init_table); 668 + 669 + if (priv->hi_pa) 670 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_highpa_table); 671 + else 672 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8192eu_std_table); 673 + } 674 + 675 + static int rtl8192eu_init_phy_rf(struct rtl8xxxu_priv *priv) 676 + { 677 + int ret; 678 + 679 + ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radioa_init_table, RF_A); 680 + if (ret) 681 + goto exit; 682 + 683 + ret = rtl8xxxu_init_phy_rf(priv, rtl8192eu_radiob_init_table, RF_B); 684 + 685 + exit: 686 + return ret; 687 + } 688 + 689 + static int rtl8192eu_iqk_path_a(struct rtl8xxxu_priv *priv) 690 + { 691 + u32 reg_eac, reg_e94, reg_e9c; 692 + int result = 0; 693 + 694 + /* 695 + * TX IQK 696 + * PA/PAD controlled by 0x0 697 + */ 698 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 699 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00180); 700 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 701 + 702 + /* Path A IQK setting */ 703 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 704 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 705 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 706 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 707 + 708 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82140303); 709 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160000); 710 + 711 + /* LO calibration setting */ 712 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00462911); 713 + 714 + /* One shot, path A LOK & IQK */ 715 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 716 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 717 + 718 + mdelay(10); 719 + 720 + /* Check failed */ 721 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 722 + reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 723 + reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 724 + 725 + if (!(reg_eac & BIT(28)) && 726 + ((reg_e94 & 0x03ff0000) != 0x01420000) && 727 + ((reg_e9c & 0x03ff0000) != 0x00420000)) 728 + result |= 0x01; 729 + 730 + return result; 731 + } 732 + 733 + static int rtl8192eu_rx_iqk_path_a(struct rtl8xxxu_priv *priv) 734 + { 735 + u32 reg_ea4, reg_eac, reg_e94, reg_e9c, val32; 736 + int result = 0; 737 + 738 + /* Leave IQK mode */ 739 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00); 740 + 741 + /* Enable path A PA in TX IQK mode */ 742 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 743 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 744 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 745 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf117b); 746 + 747 + /* PA/PAD control by 0x56, and set = 0x0 */ 748 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 749 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 750 + 751 + /* Enter IQK mode */ 752 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 753 + 754 + /* TX IQK setting */ 755 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 756 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 757 + 758 + /* path-A IQK setting */ 759 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 760 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 761 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 762 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 763 + 764 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 765 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x68160c1f); 766 + 767 + /* LO calibration setting */ 768 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 769 + 770 + /* One shot, path A LOK & IQK */ 771 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 772 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 773 + 774 + mdelay(10); 775 + 776 + /* Check failed */ 777 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 778 + reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 779 + reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 780 + 781 + if (!(reg_eac & BIT(28)) && 782 + ((reg_e94 & 0x03ff0000) != 0x01420000) && 783 + ((reg_e9c & 0x03ff0000) != 0x00420000)) { 784 + result |= 0x01; 785 + } else { 786 + /* PA/PAD controlled by 0x0 */ 787 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 788 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 789 + goto out; 790 + } 791 + 792 + val32 = 0x80007c00 | 793 + (reg_e94 & 0x03ff0000) | ((reg_e9c >> 16) & 0x03ff); 794 + rtl8xxxu_write32(priv, REG_TX_IQK, val32); 795 + 796 + /* Modify RX IQK mode table */ 797 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 798 + 799 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); 800 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 801 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); 802 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7ffa); 803 + 804 + /* PA/PAD control by 0x56, and set = 0x0 */ 805 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); 806 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); 807 + 808 + /* Enter IQK mode */ 809 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 810 + 811 + /* IQK setting */ 812 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 813 + 814 + /* Path A IQK setting */ 815 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 816 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x18008c1c); 817 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 818 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 819 + 820 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 821 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 822 + 823 + /* LO calibration setting */ 824 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 825 + 826 + /* One shot, path A LOK & IQK */ 827 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 828 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 829 + 830 + mdelay(10); 831 + 832 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 833 + reg_ea4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_A_2); 834 + 835 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 836 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); 837 + 838 + if (!(reg_eac & BIT(27)) && 839 + ((reg_ea4 & 0x03ff0000) != 0x01320000) && 840 + ((reg_eac & 0x03ff0000) != 0x00360000)) 841 + result |= 0x02; 842 + else 843 + dev_warn(&priv->udev->dev, "%s: Path A RX IQK failed!\n", 844 + __func__); 845 + 846 + out: 847 + return result; 848 + } 849 + 850 + static int rtl8192eu_iqk_path_b(struct rtl8xxxu_priv *priv) 851 + { 852 + u32 reg_eac, reg_eb4, reg_ebc; 853 + int result = 0; 854 + 855 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 856 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00180); 857 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 858 + 859 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 860 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 861 + 862 + /* Path B IQK setting */ 863 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 864 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 865 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 866 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 867 + 868 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x821403e2); 869 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160000); 870 + 871 + /* LO calibration setting */ 872 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00492911); 873 + 874 + /* One shot, path A LOK & IQK */ 875 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 876 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 877 + 878 + mdelay(1); 879 + 880 + /* Check failed */ 881 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 882 + reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 883 + reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 884 + 885 + if (!(reg_eac & BIT(31)) && 886 + ((reg_eb4 & 0x03ff0000) != 0x01420000) && 887 + ((reg_ebc & 0x03ff0000) != 0x00420000)) 888 + result |= 0x01; 889 + else 890 + dev_warn(&priv->udev->dev, "%s: Path B IQK failed!\n", 891 + __func__); 892 + 893 + return result; 894 + } 895 + 896 + static int rtl8192eu_rx_iqk_path_b(struct rtl8xxxu_priv *priv) 897 + { 898 + u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc, val32; 899 + int result = 0; 900 + 901 + /* Leave IQK mode */ 902 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 903 + 904 + /* Enable path A PA in TX IQK mode */ 905 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 906 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 907 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 908 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf117b); 909 + 910 + /* PA/PAD control by 0x56, and set = 0x0 */ 911 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 912 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 913 + 914 + /* Enter IQK mode */ 915 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 916 + 917 + /* TX IQK setting */ 918 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 919 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 920 + 921 + /* path-A IQK setting */ 922 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 923 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 924 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x18008c1c); 925 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 926 + 927 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82160c1f); 928 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x68160c1f); 929 + 930 + /* LO calibration setting */ 931 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 932 + 933 + /* One shot, path A LOK & IQK */ 934 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 935 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 936 + 937 + mdelay(10); 938 + 939 + /* Check failed */ 940 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 941 + reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 942 + reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 943 + 944 + if (!(reg_eac & BIT(31)) && 945 + ((reg_eb4 & 0x03ff0000) != 0x01420000) && 946 + ((reg_ebc & 0x03ff0000) != 0x00420000)) { 947 + result |= 0x01; 948 + } else { 949 + /* 950 + * PA/PAD controlled by 0x0 951 + * Vendor driver restores RF_A here which I believe is a bug 952 + */ 953 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 954 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 955 + goto out; 956 + } 957 + 958 + val32 = 0x80007c00 | 959 + (reg_eb4 & 0x03ff0000) | ((reg_ebc >> 16) & 0x03ff); 960 + rtl8xxxu_write32(priv, REG_TX_IQK, val32); 961 + 962 + /* Modify RX IQK mode table */ 963 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 964 + 965 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_WE_LUT, 0x800a0); 966 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_RCK_OS, 0x30000); 967 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G1, 0x0000f); 968 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_TXPA_G2, 0xf7ffa); 969 + 970 + /* PA/PAD control by 0x56, and set = 0x0 */ 971 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x00980); 972 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_56, 0x51000); 973 + 974 + /* Enter IQK mode */ 975 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 976 + 977 + /* IQK setting */ 978 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 979 + 980 + /* Path A IQK setting */ 981 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 982 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 983 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 984 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x18008c1c); 985 + 986 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); 987 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); 988 + 989 + /* LO calibration setting */ 990 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a891); 991 + 992 + /* One shot, path A LOK & IQK */ 993 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xfa000000); 994 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 995 + 996 + mdelay(10); 997 + 998 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 999 + reg_ec4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_B_2); 1000 + reg_ecc = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_B_2); 1001 + 1002 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 1003 + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_UNKNOWN_DF, 0x180); 1004 + 1005 + if (!(reg_eac & BIT(30)) && 1006 + ((reg_ec4 & 0x03ff0000) != 0x01320000) && 1007 + ((reg_ecc & 0x03ff0000) != 0x00360000)) 1008 + result |= 0x02; 1009 + else 1010 + dev_warn(&priv->udev->dev, "%s: Path B RX IQK failed!\n", 1011 + __func__); 1012 + 1013 + out: 1014 + return result; 1015 + } 1016 + 1017 + static void rtl8192eu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, 1018 + int result[][8], int t) 1019 + { 1020 + struct device *dev = &priv->udev->dev; 1021 + u32 i, val32; 1022 + int path_a_ok, path_b_ok; 1023 + int retry = 2; 1024 + const u32 adda_regs[RTL8XXXU_ADDA_REGS] = { 1025 + REG_FPGA0_XCD_SWITCH_CTRL, REG_BLUETOOTH, 1026 + REG_RX_WAIT_CCA, REG_TX_CCK_RFON, 1027 + REG_TX_CCK_BBON, REG_TX_OFDM_RFON, 1028 + REG_TX_OFDM_BBON, REG_TX_TO_RX, 1029 + REG_TX_TO_TX, REG_RX_CCK, 1030 + REG_RX_OFDM, REG_RX_WAIT_RIFS, 1031 + REG_RX_TO_RX, REG_STANDBY, 1032 + REG_SLEEP, REG_PMPD_ANAEN 1033 + }; 1034 + const u32 iqk_mac_regs[RTL8XXXU_MAC_REGS] = { 1035 + REG_TXPAUSE, REG_BEACON_CTRL, 1036 + REG_BEACON_CTRL_1, REG_GPIO_MUXCFG 1037 + }; 1038 + const u32 iqk_bb_regs[RTL8XXXU_BB_REGS] = { 1039 + REG_OFDM0_TRX_PATH_ENABLE, REG_OFDM0_TR_MUX_PAR, 1040 + REG_FPGA0_XCD_RF_SW_CTRL, REG_CONFIG_ANT_A, REG_CONFIG_ANT_B, 1041 + REG_FPGA0_XAB_RF_SW_CTRL, REG_FPGA0_XA_RF_INT_OE, 1042 + REG_FPGA0_XB_RF_INT_OE, REG_CCK0_AFE_SETTING 1043 + }; 1044 + u8 xa_agc = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1) & 0xff; 1045 + u8 xb_agc = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1) & 0xff; 1046 + 1047 + /* 1048 + * Note: IQ calibration must be performed after loading 1049 + * PHY_REG.txt , and radio_a, radio_b.txt 1050 + */ 1051 + 1052 + if (t == 0) { 1053 + /* Save ADDA parameters, turn Path A ADDA on */ 1054 + rtl8xxxu_save_regs(priv, adda_regs, priv->adda_backup, 1055 + RTL8XXXU_ADDA_REGS); 1056 + rtl8xxxu_save_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 1057 + rtl8xxxu_save_regs(priv, iqk_bb_regs, 1058 + priv->bb_backup, RTL8XXXU_BB_REGS); 1059 + } 1060 + 1061 + rtl8xxxu_path_adda_on(priv, adda_regs, true); 1062 + 1063 + /* MAC settings */ 1064 + rtl8xxxu_mac_calibration(priv, iqk_mac_regs, priv->mac_backup); 1065 + 1066 + val32 = rtl8xxxu_read32(priv, REG_CCK0_AFE_SETTING); 1067 + val32 |= 0x0f000000; 1068 + rtl8xxxu_write32(priv, REG_CCK0_AFE_SETTING, val32); 1069 + 1070 + rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, 0x03a05600); 1071 + rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 1072 + rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22208200); 1073 + 1074 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XAB_RF_SW_CTRL); 1075 + val32 |= (FPGA0_RF_PAPE | (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); 1076 + rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); 1077 + 1078 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_RF_INT_OE); 1079 + val32 |= BIT(10); 1080 + rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, val32); 1081 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_XB_RF_INT_OE); 1082 + val32 |= BIT(10); 1083 + rtl8xxxu_write32(priv, REG_FPGA0_XB_RF_INT_OE, val32); 1084 + 1085 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 1086 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 1087 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 1088 + 1089 + for (i = 0; i < retry; i++) { 1090 + path_a_ok = rtl8192eu_iqk_path_a(priv); 1091 + if (path_a_ok == 0x01) { 1092 + val32 = rtl8xxxu_read32(priv, 1093 + REG_TX_POWER_BEFORE_IQK_A); 1094 + result[t][0] = (val32 >> 16) & 0x3ff; 1095 + val32 = rtl8xxxu_read32(priv, 1096 + REG_TX_POWER_AFTER_IQK_A); 1097 + result[t][1] = (val32 >> 16) & 0x3ff; 1098 + 1099 + break; 1100 + } 1101 + } 1102 + 1103 + if (!path_a_ok) 1104 + dev_dbg(dev, "%s: Path A TX IQK failed!\n", __func__); 1105 + 1106 + for (i = 0; i < retry; i++) { 1107 + path_a_ok = rtl8192eu_rx_iqk_path_a(priv); 1108 + if (path_a_ok == 0x03) { 1109 + val32 = rtl8xxxu_read32(priv, 1110 + REG_RX_POWER_BEFORE_IQK_A_2); 1111 + result[t][2] = (val32 >> 16) & 0x3ff; 1112 + val32 = rtl8xxxu_read32(priv, 1113 + REG_RX_POWER_AFTER_IQK_A_2); 1114 + result[t][3] = (val32 >> 16) & 0x3ff; 1115 + 1116 + break; 1117 + } 1118 + } 1119 + 1120 + if (!path_a_ok) 1121 + dev_dbg(dev, "%s: Path A RX IQK failed!\n", __func__); 1122 + 1123 + if (priv->rf_paths > 1) { 1124 + /* Path A into standby */ 1125 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 1126 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0x10000); 1127 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 1128 + 1129 + /* Turn Path B ADDA on */ 1130 + rtl8xxxu_path_adda_on(priv, adda_regs, false); 1131 + 1132 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); 1133 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 1134 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 1135 + 1136 + for (i = 0; i < retry; i++) { 1137 + path_b_ok = rtl8192eu_iqk_path_b(priv); 1138 + if (path_b_ok == 0x01) { 1139 + val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 1140 + result[t][4] = (val32 >> 16) & 0x3ff; 1141 + val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 1142 + result[t][5] = (val32 >> 16) & 0x3ff; 1143 + break; 1144 + } 1145 + } 1146 + 1147 + if (!path_b_ok) 1148 + dev_dbg(dev, "%s: Path B IQK failed!\n", __func__); 1149 + 1150 + for (i = 0; i < retry; i++) { 1151 + path_b_ok = rtl8192eu_rx_iqk_path_b(priv); 1152 + if (path_a_ok == 0x03) { 1153 + val32 = rtl8xxxu_read32(priv, 1154 + REG_RX_POWER_BEFORE_IQK_B_2); 1155 + result[t][6] = (val32 >> 16) & 0x3ff; 1156 + val32 = rtl8xxxu_read32(priv, 1157 + REG_RX_POWER_AFTER_IQK_B_2); 1158 + result[t][7] = (val32 >> 16) & 0x3ff; 1159 + break; 1160 + } 1161 + } 1162 + 1163 + if (!path_b_ok) 1164 + dev_dbg(dev, "%s: Path B RX IQK failed!\n", __func__); 1165 + } 1166 + 1167 + /* Back to BB mode, load original value */ 1168 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); 1169 + 1170 + if (t) { 1171 + /* Reload ADDA power saving parameters */ 1172 + rtl8xxxu_restore_regs(priv, adda_regs, priv->adda_backup, 1173 + RTL8XXXU_ADDA_REGS); 1174 + 1175 + /* Reload MAC parameters */ 1176 + rtl8xxxu_restore_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 1177 + 1178 + /* Reload BB parameters */ 1179 + rtl8xxxu_restore_regs(priv, iqk_bb_regs, 1180 + priv->bb_backup, RTL8XXXU_BB_REGS); 1181 + 1182 + /* Restore RX initial gain */ 1183 + val32 = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1); 1184 + val32 &= 0xffffff00; 1185 + rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | 0x50); 1186 + rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | xa_agc); 1187 + 1188 + if (priv->rf_paths > 1) { 1189 + val32 = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1); 1190 + val32 &= 0xffffff00; 1191 + rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 1192 + val32 | 0x50); 1193 + rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 1194 + val32 | xb_agc); 1195 + } 1196 + 1197 + /* Load 0xe30 IQC default value */ 1198 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x01008c00); 1199 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x01008c00); 1200 + } 1201 + } 1202 + 1203 + static void rtl8192eu_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 1204 + { 1205 + struct device *dev = &priv->udev->dev; 1206 + int result[4][8]; /* last is final result */ 1207 + int i, candidate; 1208 + bool path_a_ok, path_b_ok; 1209 + u32 reg_e94, reg_e9c, reg_ea4, reg_eac; 1210 + u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; 1211 + bool simu; 1212 + 1213 + memset(result, 0, sizeof(result)); 1214 + candidate = -1; 1215 + 1216 + path_a_ok = false; 1217 + path_b_ok = false; 1218 + 1219 + for (i = 0; i < 3; i++) { 1220 + rtl8192eu_phy_iqcalibrate(priv, result, i); 1221 + 1222 + if (i == 1) { 1223 + simu = rtl8xxxu_gen2_simularity_compare(priv, 1224 + result, 0, 1); 1225 + if (simu) { 1226 + candidate = 0; 1227 + break; 1228 + } 1229 + } 1230 + 1231 + if (i == 2) { 1232 + simu = rtl8xxxu_gen2_simularity_compare(priv, 1233 + result, 0, 2); 1234 + if (simu) { 1235 + candidate = 0; 1236 + break; 1237 + } 1238 + 1239 + simu = rtl8xxxu_gen2_simularity_compare(priv, 1240 + result, 1, 2); 1241 + if (simu) 1242 + candidate = 1; 1243 + else 1244 + candidate = 3; 1245 + } 1246 + } 1247 + 1248 + for (i = 0; i < 4; i++) { 1249 + reg_e94 = result[i][0]; 1250 + reg_e9c = result[i][1]; 1251 + reg_ea4 = result[i][2]; 1252 + reg_eac = result[i][3]; 1253 + reg_eb4 = result[i][4]; 1254 + reg_ebc = result[i][5]; 1255 + reg_ec4 = result[i][6]; 1256 + reg_ecc = result[i][7]; 1257 + } 1258 + 1259 + if (candidate >= 0) { 1260 + reg_e94 = result[candidate][0]; 1261 + priv->rege94 = reg_e94; 1262 + reg_e9c = result[candidate][1]; 1263 + priv->rege9c = reg_e9c; 1264 + reg_ea4 = result[candidate][2]; 1265 + reg_eac = result[candidate][3]; 1266 + reg_eb4 = result[candidate][4]; 1267 + priv->regeb4 = reg_eb4; 1268 + reg_ebc = result[candidate][5]; 1269 + priv->regebc = reg_ebc; 1270 + reg_ec4 = result[candidate][6]; 1271 + reg_ecc = result[candidate][7]; 1272 + dev_dbg(dev, "%s: candidate is %x\n", __func__, candidate); 1273 + dev_dbg(dev, 1274 + "%s: e94 =%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x " 1275 + "ecc=%x\n ", __func__, reg_e94, reg_e9c, 1276 + reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc); 1277 + path_a_ok = true; 1278 + path_b_ok = true; 1279 + } else { 1280 + reg_e94 = reg_eb4 = priv->rege94 = priv->regeb4 = 0x100; 1281 + reg_e9c = reg_ebc = priv->rege9c = priv->regebc = 0x0; 1282 + } 1283 + 1284 + if (reg_e94 && candidate >= 0) 1285 + rtl8xxxu_fill_iqk_matrix_a(priv, path_a_ok, result, 1286 + candidate, (reg_ea4 == 0)); 1287 + 1288 + if (priv->rf_paths > 1) 1289 + rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 1290 + candidate, (reg_ec4 == 0)); 1291 + 1292 + rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 1293 + priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 1294 + } 1295 + 1296 + /* 1297 + * This is needed for 8723bu as well, presumable 1298 + */ 1299 + static void rtl8192e_crystal_afe_adjust(struct rtl8xxxu_priv *priv) 1300 + { 1301 + u8 val8; 1302 + u32 val32; 1303 + 1304 + /* 1305 + * 40Mhz crystal source, MAC 0x28[2]=0 1306 + */ 1307 + val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 1308 + val8 &= 0xfb; 1309 + rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 1310 + 1311 + val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 1312 + val32 &= 0xfffffc7f; 1313 + rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 1314 + 1315 + /* 1316 + * 92e AFE parameter 1317 + * AFE PLL KVCO selection, MAC 0x28[6]=1 1318 + */ 1319 + val8 = rtl8xxxu_read8(priv, REG_AFE_PLL_CTRL); 1320 + val8 &= 0xbf; 1321 + rtl8xxxu_write8(priv, REG_AFE_PLL_CTRL, val8); 1322 + 1323 + /* 1324 + * AFE PLL KVCO selection, MAC 0x78[21]=0 1325 + */ 1326 + val32 = rtl8xxxu_read32(priv, REG_AFE_CTRL4); 1327 + val32 &= 0xffdfffff; 1328 + rtl8xxxu_write32(priv, REG_AFE_CTRL4, val32); 1329 + } 1330 + 1331 + static void rtl8192e_disabled_to_emu(struct rtl8xxxu_priv *priv) 1332 + { 1333 + u8 val8; 1334 + 1335 + /* Clear suspend enable and power down enable*/ 1336 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 1337 + val8 &= ~(BIT(3) | BIT(4)); 1338 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 1339 + } 1340 + 1341 + static int rtl8192e_emu_to_active(struct rtl8xxxu_priv *priv) 1342 + { 1343 + u8 val8; 1344 + u32 val32; 1345 + int count, ret = 0; 1346 + 1347 + /* disable HWPDN 0x04[15]=0*/ 1348 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 1349 + val8 &= ~BIT(7); 1350 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 1351 + 1352 + /* disable SW LPS 0x04[10]= 0 */ 1353 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 1354 + val8 &= ~BIT(2); 1355 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 1356 + 1357 + /* disable WL suspend*/ 1358 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 1359 + val8 &= ~(BIT(3) | BIT(4)); 1360 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 1361 + 1362 + /* wait till 0x04[17] = 1 power ready*/ 1363 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 1364 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1365 + if (val32 & BIT(17)) 1366 + break; 1367 + 1368 + udelay(10); 1369 + } 1370 + 1371 + if (!count) { 1372 + ret = -EBUSY; 1373 + goto exit; 1374 + } 1375 + 1376 + /* We should be able to optimize the following three entries into one */ 1377 + 1378 + /* release WLON reset 0x04[16]= 1*/ 1379 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); 1380 + val8 |= BIT(0); 1381 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); 1382 + 1383 + /* set, then poll until 0 */ 1384 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1385 + val32 |= APS_FSMCO_MAC_ENABLE; 1386 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 1387 + 1388 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 1389 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1390 + if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { 1391 + ret = 0; 1392 + break; 1393 + } 1394 + udelay(10); 1395 + } 1396 + 1397 + if (!count) { 1398 + ret = -EBUSY; 1399 + goto exit; 1400 + } 1401 + 1402 + exit: 1403 + return ret; 1404 + } 1405 + 1406 + static int rtl8192eu_power_on(struct rtl8xxxu_priv *priv) 1407 + { 1408 + u16 val16; 1409 + u32 val32; 1410 + int ret; 1411 + 1412 + ret = 0; 1413 + 1414 + val32 = rtl8xxxu_read32(priv, REG_SYS_CFG); 1415 + if (val32 & SYS_CFG_SPS_LDO_SEL) { 1416 + rtl8xxxu_write8(priv, REG_LDO_SW_CTRL, 0xc3); 1417 + } else { 1418 + /* 1419 + * Raise 1.2V voltage 1420 + */ 1421 + val32 = rtl8xxxu_read32(priv, REG_8192E_LDOV12_CTRL); 1422 + val32 &= 0xff0fffff; 1423 + val32 |= 0x00500000; 1424 + rtl8xxxu_write32(priv, REG_8192E_LDOV12_CTRL, val32); 1425 + rtl8xxxu_write8(priv, REG_LDO_SW_CTRL, 0x83); 1426 + } 1427 + 1428 + /* 1429 + * Adjust AFE before enabling PLL 1430 + */ 1431 + rtl8192e_crystal_afe_adjust(priv); 1432 + rtl8192e_disabled_to_emu(priv); 1433 + 1434 + ret = rtl8192e_emu_to_active(priv); 1435 + if (ret) 1436 + goto exit; 1437 + 1438 + rtl8xxxu_write16(priv, REG_CR, 0x0000); 1439 + 1440 + /* 1441 + * Enable MAC DMA/WMAC/SCHEDULE/SEC block 1442 + * Set CR bit10 to enable 32k calibration. 1443 + */ 1444 + val16 = rtl8xxxu_read16(priv, REG_CR); 1445 + val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 1446 + CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | 1447 + CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | 1448 + CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | 1449 + CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); 1450 + rtl8xxxu_write16(priv, REG_CR, val16); 1451 + 1452 + exit: 1453 + return ret; 1454 + } 1455 + 1456 + static void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv) 1457 + { 1458 + u32 val32; 1459 + u8 val8; 1460 + 1461 + val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); 1462 + val8 |= BIT(5); 1463 + rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); 1464 + 1465 + /* 1466 + * WLAN action by PTA 1467 + */ 1468 + rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 1469 + 1470 + val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 1471 + val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 1472 + rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 1473 + 1474 + val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 1475 + val32 |= (BIT(0) | BIT(1)); 1476 + rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 1477 + 1478 + rtl8xxxu_write8(priv, REG_RFE_CTRL_ANTA_SRC, 0x77); 1479 + 1480 + val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 1481 + val32 &= ~BIT(24); 1482 + val32 |= BIT(23); 1483 + rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 1484 + 1485 + /* 1486 + * Fix external switch Main->S1, Aux->S0 1487 + */ 1488 + val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 1489 + val8 &= ~BIT(0); 1490 + rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 1491 + } 1492 + 1493 + struct rtl8xxxu_fileops rtl8192eu_fops = { 1494 + .parse_efuse = rtl8192eu_parse_efuse, 1495 + .load_firmware = rtl8192eu_load_firmware, 1496 + .power_on = rtl8192eu_power_on, 1497 + .power_off = rtl8xxxu_power_off, 1498 + .reset_8051 = rtl8xxxu_reset_8051, 1499 + .llt_init = rtl8xxxu_auto_llt_table, 1500 + .init_phy_bb = rtl8192eu_init_phy_bb, 1501 + .init_phy_rf = rtl8192eu_init_phy_rf, 1502 + .phy_iq_calibrate = rtl8192eu_phy_iq_calibrate, 1503 + .config_channel = rtl8xxxu_gen2_config_channel, 1504 + .parse_rx_desc = rtl8xxxu_parse_rxdesc24, 1505 + .enable_rf = rtl8192e_enable_rf, 1506 + .disable_rf = rtl8xxxu_gen2_disable_rf, 1507 + .usb_quirks = rtl8xxxu_gen2_usb_quirks, 1508 + .set_tx_power = rtl8192e_set_tx_power, 1509 + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, 1510 + .report_connect = rtl8xxxu_gen2_report_connect, 1511 + .writeN_block_size = 128, 1512 + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), 1513 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), 1514 + .has_s0s1 = 0, 1515 + .adda_1t_init = 0x0fc01616, 1516 + .adda_1t_path_on = 0x0fc01616, 1517 + .adda_2t_path_on_a = 0x0fc01616, 1518 + .adda_2t_path_on_b = 0x0fc01616, 1519 + .trxff_boundary = 0x3cff, 1520 + .mactable = rtl8192e_mac_init_table, 1521 + .total_page_num = TX_TOTAL_PAGE_NUM_8192E, 1522 + .page_num_hi = TX_PAGE_NUM_HI_PQ_8192E, 1523 + .page_num_lo = TX_PAGE_NUM_LO_PQ_8192E, 1524 + .page_num_norm = TX_PAGE_NUM_NORM_PQ_8192E, 1525 + };
+397
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
··· 1 + /* 2 + * RTL8XXXU mac80211 USB driver - 8723a specific subdriver 3 + * 4 + * Copyright (c) 2014 - 2016 Jes Sorensen <Jes.Sorensen@redhat.com> 5 + * 6 + * Portions, notably calibration code: 7 + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 8 + * 9 + * This driver was written as a replacement for the vendor provided 10 + * rtl8723au driver. As the Realtek 8xxx chips are very similar in 11 + * their programming interface, I have started adding support for 12 + * additional 8xxx chips like the 8192cu, 8188cus, etc. 13 + * 14 + * This program is free software; you can redistribute it and/or modify it 15 + * under the terms of version 2 of the GNU General Public License as 16 + * published by the Free Software Foundation. 17 + * 18 + * This program is distributed in the hope that it will be useful, but WITHOUT 19 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 + * more details. 22 + */ 23 + 24 + #include <linux/init.h> 25 + #include <linux/kernel.h> 26 + #include <linux/sched.h> 27 + #include <linux/errno.h> 28 + #include <linux/slab.h> 29 + #include <linux/module.h> 30 + #include <linux/spinlock.h> 31 + #include <linux/list.h> 32 + #include <linux/usb.h> 33 + #include <linux/netdevice.h> 34 + #include <linux/etherdevice.h> 35 + #include <linux/ethtool.h> 36 + #include <linux/wireless.h> 37 + #include <linux/firmware.h> 38 + #include <linux/moduleparam.h> 39 + #include <net/mac80211.h> 40 + #include "rtl8xxxu.h" 41 + #include "rtl8xxxu_regs.h" 42 + 43 + static struct rtl8xxxu_power_base rtl8723a_power_base = { 44 + .reg_0e00 = 0x0a0c0c0c, 45 + .reg_0e04 = 0x02040608, 46 + .reg_0e08 = 0x00000000, 47 + .reg_086c = 0x00000000, 48 + 49 + .reg_0e10 = 0x0a0c0d0e, 50 + .reg_0e14 = 0x02040608, 51 + .reg_0e18 = 0x0a0c0d0e, 52 + .reg_0e1c = 0x02040608, 53 + 54 + .reg_0830 = 0x0a0c0c0c, 55 + .reg_0834 = 0x02040608, 56 + .reg_0838 = 0x00000000, 57 + .reg_086c_2 = 0x00000000, 58 + 59 + .reg_083c = 0x0a0c0d0e, 60 + .reg_0848 = 0x02040608, 61 + .reg_084c = 0x0a0c0d0e, 62 + .reg_0868 = 0x02040608, 63 + }; 64 + 65 + static struct rtl8xxxu_rfregval rtl8723au_radioa_1t_init_table[] = { 66 + {0x00, 0x00030159}, {0x01, 0x00031284}, 67 + {0x02, 0x00098000}, {0x03, 0x00039c63}, 68 + {0x04, 0x000210e7}, {0x09, 0x0002044f}, 69 + {0x0a, 0x0001a3f1}, {0x0b, 0x00014787}, 70 + {0x0c, 0x000896fe}, {0x0d, 0x0000e02c}, 71 + {0x0e, 0x00039ce7}, {0x0f, 0x00000451}, 72 + {0x19, 0x00000000}, {0x1a, 0x00030355}, 73 + {0x1b, 0x00060a00}, {0x1c, 0x000fc378}, 74 + {0x1d, 0x000a1250}, {0x1e, 0x0000024f}, 75 + {0x1f, 0x00000000}, {0x20, 0x0000b614}, 76 + {0x21, 0x0006c000}, {0x22, 0x00000000}, 77 + {0x23, 0x00001558}, {0x24, 0x00000060}, 78 + {0x25, 0x00000483}, {0x26, 0x0004f000}, 79 + {0x27, 0x000ec7d9}, {0x28, 0x00057730}, 80 + {0x29, 0x00004783}, {0x2a, 0x00000001}, 81 + {0x2b, 0x00021334}, {0x2a, 0x00000000}, 82 + {0x2b, 0x00000054}, {0x2a, 0x00000001}, 83 + {0x2b, 0x00000808}, {0x2b, 0x00053333}, 84 + {0x2c, 0x0000000c}, {0x2a, 0x00000002}, 85 + {0x2b, 0x00000808}, {0x2b, 0x0005b333}, 86 + {0x2c, 0x0000000d}, {0x2a, 0x00000003}, 87 + {0x2b, 0x00000808}, {0x2b, 0x00063333}, 88 + {0x2c, 0x0000000d}, {0x2a, 0x00000004}, 89 + {0x2b, 0x00000808}, {0x2b, 0x0006b333}, 90 + {0x2c, 0x0000000d}, {0x2a, 0x00000005}, 91 + {0x2b, 0x00000808}, {0x2b, 0x00073333}, 92 + {0x2c, 0x0000000d}, {0x2a, 0x00000006}, 93 + {0x2b, 0x00000709}, {0x2b, 0x0005b333}, 94 + {0x2c, 0x0000000d}, {0x2a, 0x00000007}, 95 + {0x2b, 0x00000709}, {0x2b, 0x00063333}, 96 + {0x2c, 0x0000000d}, {0x2a, 0x00000008}, 97 + {0x2b, 0x0000060a}, {0x2b, 0x0004b333}, 98 + {0x2c, 0x0000000d}, {0x2a, 0x00000009}, 99 + {0x2b, 0x0000060a}, {0x2b, 0x00053333}, 100 + {0x2c, 0x0000000d}, {0x2a, 0x0000000a}, 101 + {0x2b, 0x0000060a}, {0x2b, 0x0005b333}, 102 + {0x2c, 0x0000000d}, {0x2a, 0x0000000b}, 103 + {0x2b, 0x0000060a}, {0x2b, 0x00063333}, 104 + {0x2c, 0x0000000d}, {0x2a, 0x0000000c}, 105 + {0x2b, 0x0000060a}, {0x2b, 0x0006b333}, 106 + {0x2c, 0x0000000d}, {0x2a, 0x0000000d}, 107 + {0x2b, 0x0000060a}, {0x2b, 0x00073333}, 108 + {0x2c, 0x0000000d}, {0x2a, 0x0000000e}, 109 + {0x2b, 0x0000050b}, {0x2b, 0x00066666}, 110 + {0x2c, 0x0000001a}, {0x2a, 0x000e0000}, 111 + {0x10, 0x0004000f}, {0x11, 0x000e31fc}, 112 + {0x10, 0x0006000f}, {0x11, 0x000ff9f8}, 113 + {0x10, 0x0002000f}, {0x11, 0x000203f9}, 114 + {0x10, 0x0003000f}, {0x11, 0x000ff500}, 115 + {0x10, 0x00000000}, {0x11, 0x00000000}, 116 + {0x10, 0x0008000f}, {0x11, 0x0003f100}, 117 + {0x10, 0x0009000f}, {0x11, 0x00023100}, 118 + {0x12, 0x00032000}, {0x12, 0x00071000}, 119 + {0x12, 0x000b0000}, {0x12, 0x000fc000}, 120 + {0x13, 0x000287b3}, {0x13, 0x000244b7}, 121 + {0x13, 0x000204ab}, {0x13, 0x0001c49f}, 122 + {0x13, 0x00018493}, {0x13, 0x0001429b}, 123 + {0x13, 0x00010299}, {0x13, 0x0000c29c}, 124 + {0x13, 0x000081a0}, {0x13, 0x000040ac}, 125 + {0x13, 0x00000020}, {0x14, 0x0001944c}, 126 + {0x14, 0x00059444}, {0x14, 0x0009944c}, 127 + {0x14, 0x000d9444}, {0x15, 0x0000f474}, 128 + {0x15, 0x0004f477}, {0x15, 0x0008f455}, 129 + {0x15, 0x000cf455}, {0x16, 0x00000339}, 130 + {0x16, 0x00040339}, {0x16, 0x00080339}, 131 + {0x16, 0x000c0366}, {0x00, 0x00010159}, 132 + {0x18, 0x0000f401}, {0xfe, 0x00000000}, 133 + {0xfe, 0x00000000}, {0x1f, 0x00000003}, 134 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 135 + {0x1e, 0x00000247}, {0x1f, 0x00000000}, 136 + {0x00, 0x00030159}, 137 + {0xff, 0xffffffff} 138 + }; 139 + 140 + static int rtl8723au_parse_efuse(struct rtl8xxxu_priv *priv) 141 + { 142 + struct rtl8723au_efuse *efuse = &priv->efuse_wifi.efuse8723; 143 + 144 + if (efuse->rtl_id != cpu_to_le16(0x8129)) 145 + return -EINVAL; 146 + 147 + ether_addr_copy(priv->mac_addr, efuse->mac_addr); 148 + 149 + memcpy(priv->cck_tx_power_index_A, 150 + efuse->cck_tx_power_index_A, 151 + sizeof(efuse->cck_tx_power_index_A)); 152 + memcpy(priv->cck_tx_power_index_B, 153 + efuse->cck_tx_power_index_B, 154 + sizeof(efuse->cck_tx_power_index_B)); 155 + 156 + memcpy(priv->ht40_1s_tx_power_index_A, 157 + efuse->ht40_1s_tx_power_index_A, 158 + sizeof(efuse->ht40_1s_tx_power_index_A)); 159 + memcpy(priv->ht40_1s_tx_power_index_B, 160 + efuse->ht40_1s_tx_power_index_B, 161 + sizeof(efuse->ht40_1s_tx_power_index_B)); 162 + 163 + memcpy(priv->ht20_tx_power_index_diff, 164 + efuse->ht20_tx_power_index_diff, 165 + sizeof(efuse->ht20_tx_power_index_diff)); 166 + memcpy(priv->ofdm_tx_power_index_diff, 167 + efuse->ofdm_tx_power_index_diff, 168 + sizeof(efuse->ofdm_tx_power_index_diff)); 169 + 170 + memcpy(priv->ht40_max_power_offset, 171 + efuse->ht40_max_power_offset, 172 + sizeof(efuse->ht40_max_power_offset)); 173 + memcpy(priv->ht20_max_power_offset, 174 + efuse->ht20_max_power_offset, 175 + sizeof(efuse->ht20_max_power_offset)); 176 + 177 + if (priv->efuse_wifi.efuse8723.version >= 0x01) { 178 + priv->has_xtalk = 1; 179 + priv->xtalk = priv->efuse_wifi.efuse8723.xtal_k & 0x3f; 180 + } 181 + 182 + priv->power_base = &rtl8723a_power_base; 183 + 184 + dev_info(&priv->udev->dev, "Vendor: %.7s\n", 185 + efuse->vendor_name); 186 + dev_info(&priv->udev->dev, "Product: %.41s\n", 187 + efuse->device_name); 188 + return 0; 189 + } 190 + 191 + static int rtl8723au_load_firmware(struct rtl8xxxu_priv *priv) 192 + { 193 + char *fw_name; 194 + int ret; 195 + 196 + switch (priv->chip_cut) { 197 + case 0: 198 + fw_name = "rtlwifi/rtl8723aufw_A.bin"; 199 + break; 200 + case 1: 201 + if (priv->enable_bluetooth) 202 + fw_name = "rtlwifi/rtl8723aufw_B.bin"; 203 + else 204 + fw_name = "rtlwifi/rtl8723aufw_B_NoBT.bin"; 205 + 206 + break; 207 + default: 208 + return -EINVAL; 209 + } 210 + 211 + ret = rtl8xxxu_load_firmware(priv, fw_name); 212 + return ret; 213 + } 214 + 215 + static int rtl8723au_init_phy_rf(struct rtl8xxxu_priv *priv) 216 + { 217 + int ret; 218 + 219 + ret = rtl8xxxu_init_phy_rf(priv, rtl8723au_radioa_1t_init_table, RF_A); 220 + 221 + /* Reduce 80M spur */ 222 + rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, 0x0381808d); 223 + rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 224 + rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff82); 225 + rtl8xxxu_write32(priv, REG_AFE_PLL_CTRL, 0xf0ffff83); 226 + 227 + return ret; 228 + } 229 + 230 + static int rtl8723a_emu_to_active(struct rtl8xxxu_priv *priv) 231 + { 232 + u8 val8; 233 + u32 val32; 234 + int count, ret = 0; 235 + 236 + /* 0x20[0] = 1 enable LDOA12 MACRO block for all interface*/ 237 + val8 = rtl8xxxu_read8(priv, REG_LDOA15_CTRL); 238 + val8 |= LDOA15_ENABLE; 239 + rtl8xxxu_write8(priv, REG_LDOA15_CTRL, val8); 240 + 241 + /* 0x67[0] = 0 to disable BT_GPS_SEL pins*/ 242 + val8 = rtl8xxxu_read8(priv, 0x0067); 243 + val8 &= ~BIT(4); 244 + rtl8xxxu_write8(priv, 0x0067, val8); 245 + 246 + mdelay(1); 247 + 248 + /* 0x00[5] = 0 release analog Ips to digital, 1:isolation */ 249 + val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 250 + val8 &= ~SYS_ISO_ANALOG_IPS; 251 + rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 252 + 253 + /* disable SW LPS 0x04[10]= 0 */ 254 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 255 + val8 &= ~BIT(2); 256 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 257 + 258 + /* wait till 0x04[17] = 1 power ready*/ 259 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 260 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 261 + if (val32 & BIT(17)) 262 + break; 263 + 264 + udelay(10); 265 + } 266 + 267 + if (!count) { 268 + ret = -EBUSY; 269 + goto exit; 270 + } 271 + 272 + /* We should be able to optimize the following three entries into one */ 273 + 274 + /* release WLON reset 0x04[16]= 1*/ 275 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); 276 + val8 |= BIT(0); 277 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); 278 + 279 + /* disable HWPDN 0x04[15]= 0*/ 280 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 281 + val8 &= ~BIT(7); 282 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 283 + 284 + /* disable WL suspend*/ 285 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 286 + val8 &= ~(BIT(3) | BIT(4)); 287 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 288 + 289 + /* set, then poll until 0 */ 290 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 291 + val32 |= APS_FSMCO_MAC_ENABLE; 292 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 293 + 294 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 295 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 296 + if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { 297 + ret = 0; 298 + break; 299 + } 300 + udelay(10); 301 + } 302 + 303 + if (!count) { 304 + ret = -EBUSY; 305 + goto exit; 306 + } 307 + 308 + /* 0x4C[23] = 0x4E[7] = 1, switch DPDT_SEL_P output from WL BB */ 309 + /* 310 + * Note: Vendor driver actually clears this bit, despite the 311 + * documentation claims it's being set! 312 + */ 313 + val8 = rtl8xxxu_read8(priv, REG_LEDCFG2); 314 + val8 |= LEDCFG2_DPDT_SELECT; 315 + val8 &= ~LEDCFG2_DPDT_SELECT; 316 + rtl8xxxu_write8(priv, REG_LEDCFG2, val8); 317 + 318 + exit: 319 + return ret; 320 + } 321 + 322 + static int rtl8723au_power_on(struct rtl8xxxu_priv *priv) 323 + { 324 + u8 val8; 325 + u16 val16; 326 + u32 val32; 327 + int ret; 328 + 329 + /* 330 + * RSV_CTRL 0x001C[7:0] = 0x00, unlock ISO/CLK/Power control register 331 + */ 332 + rtl8xxxu_write8(priv, REG_RSV_CTRL, 0x0); 333 + 334 + rtl8xxxu_disabled_to_emu(priv); 335 + 336 + ret = rtl8723a_emu_to_active(priv); 337 + if (ret) 338 + goto exit; 339 + 340 + /* 341 + * 0x0004[19] = 1, reset 8051 342 + */ 343 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); 344 + val8 |= BIT(3); 345 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); 346 + 347 + /* 348 + * Enable MAC DMA/WMAC/SCHEDULE/SEC block 349 + * Set CR bit10 to enable 32k calibration. 350 + */ 351 + val16 = rtl8xxxu_read16(priv, REG_CR); 352 + val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 353 + CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | 354 + CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | 355 + CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | 356 + CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); 357 + rtl8xxxu_write16(priv, REG_CR, val16); 358 + 359 + /* For EFuse PG */ 360 + val32 = rtl8xxxu_read32(priv, REG_EFUSE_CTRL); 361 + val32 &= ~(BIT(28) | BIT(29) | BIT(30)); 362 + val32 |= (0x06 << 28); 363 + rtl8xxxu_write32(priv, REG_EFUSE_CTRL, val32); 364 + exit: 365 + return ret; 366 + } 367 + 368 + struct rtl8xxxu_fileops rtl8723au_fops = { 369 + .parse_efuse = rtl8723au_parse_efuse, 370 + .load_firmware = rtl8723au_load_firmware, 371 + .power_on = rtl8723au_power_on, 372 + .power_off = rtl8xxxu_power_off, 373 + .reset_8051 = rtl8xxxu_reset_8051, 374 + .llt_init = rtl8xxxu_init_llt_table, 375 + .init_phy_bb = rtl8xxxu_gen1_init_phy_bb, 376 + .init_phy_rf = rtl8723au_init_phy_rf, 377 + .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, 378 + .config_channel = rtl8xxxu_gen1_config_channel, 379 + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, 380 + .enable_rf = rtl8xxxu_gen1_enable_rf, 381 + .disable_rf = rtl8xxxu_gen1_disable_rf, 382 + .usb_quirks = rtl8xxxu_gen1_usb_quirks, 383 + .set_tx_power = rtl8xxxu_gen1_set_tx_power, 384 + .update_rate_mask = rtl8xxxu_update_rate_mask, 385 + .report_connect = rtl8xxxu_gen1_report_connect, 386 + .writeN_block_size = 1024, 387 + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), 388 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), 389 + .adda_1t_init = 0x0b1b25a0, 390 + .adda_1t_path_on = 0x0bdb25a0, 391 + .adda_2t_path_on_a = 0x04db25a4, 392 + .adda_2t_path_on_b = 0x0b1b25a4, 393 + .trxff_boundary = 0x27ff, 394 + .pbp_rx = PBP_PAGE_SIZE_128, 395 + .pbp_tx = PBP_PAGE_SIZE_128, 396 + .mactable = rtl8xxxu_gen1_mac_init_table, 397 + };
+1682
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
··· 1 + /* 2 + * RTL8XXXU mac80211 USB driver - 8723b specific subdriver 3 + * 4 + * Copyright (c) 2014 - 2016 Jes Sorensen <Jes.Sorensen@redhat.com> 5 + * 6 + * Portions, notably calibration code: 7 + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 8 + * 9 + * This driver was written as a replacement for the vendor provided 10 + * rtl8723au driver. As the Realtek 8xxx chips are very similar in 11 + * their programming interface, I have started adding support for 12 + * additional 8xxx chips like the 8192cu, 8188cus, etc. 13 + * 14 + * This program is free software; you can redistribute it and/or modify it 15 + * under the terms of version 2 of the GNU General Public License as 16 + * published by the Free Software Foundation. 17 + * 18 + * This program is distributed in the hope that it will be useful, but WITHOUT 19 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 + * more details. 22 + */ 23 + 24 + #include <linux/init.h> 25 + #include <linux/kernel.h> 26 + #include <linux/sched.h> 27 + #include <linux/errno.h> 28 + #include <linux/slab.h> 29 + #include <linux/module.h> 30 + #include <linux/spinlock.h> 31 + #include <linux/list.h> 32 + #include <linux/usb.h> 33 + #include <linux/netdevice.h> 34 + #include <linux/etherdevice.h> 35 + #include <linux/ethtool.h> 36 + #include <linux/wireless.h> 37 + #include <linux/firmware.h> 38 + #include <linux/moduleparam.h> 39 + #include <net/mac80211.h> 40 + #include "rtl8xxxu.h" 41 + #include "rtl8xxxu_regs.h" 42 + 43 + static struct rtl8xxxu_reg8val rtl8723b_mac_init_table[] = { 44 + {0x02f, 0x30}, {0x035, 0x00}, {0x039, 0x08}, {0x04e, 0xe0}, 45 + {0x064, 0x00}, {0x067, 0x20}, {0x428, 0x0a}, {0x429, 0x10}, 46 + {0x430, 0x00}, {0x431, 0x00}, 47 + {0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05}, 48 + {0x436, 0x07}, {0x437, 0x08}, {0x43c, 0x04}, {0x43d, 0x05}, 49 + {0x43e, 0x07}, {0x43f, 0x08}, {0x440, 0x5d}, {0x441, 0x01}, 50 + {0x442, 0x00}, {0x444, 0x10}, {0x445, 0x00}, {0x446, 0x00}, 51 + {0x447, 0x00}, {0x448, 0x00}, {0x449, 0xf0}, {0x44a, 0x0f}, 52 + {0x44b, 0x3e}, {0x44c, 0x10}, {0x44d, 0x00}, {0x44e, 0x00}, 53 + {0x44f, 0x00}, {0x450, 0x00}, {0x451, 0xf0}, {0x452, 0x0f}, 54 + {0x453, 0x00}, {0x456, 0x5e}, {0x460, 0x66}, {0x461, 0x66}, 55 + {0x4c8, 0xff}, {0x4c9, 0x08}, {0x4cc, 0xff}, 56 + {0x4cd, 0xff}, {0x4ce, 0x01}, {0x500, 0x26}, {0x501, 0xa2}, 57 + {0x502, 0x2f}, {0x503, 0x00}, {0x504, 0x28}, {0x505, 0xa3}, 58 + {0x506, 0x5e}, {0x507, 0x00}, {0x508, 0x2b}, {0x509, 0xa4}, 59 + {0x50a, 0x5e}, {0x50b, 0x00}, {0x50c, 0x4f}, {0x50d, 0xa4}, 60 + {0x50e, 0x00}, {0x50f, 0x00}, {0x512, 0x1c}, {0x514, 0x0a}, 61 + {0x516, 0x0a}, {0x525, 0x4f}, 62 + {0x550, 0x10}, {0x551, 0x10}, {0x559, 0x02}, {0x55c, 0x50}, 63 + {0x55d, 0xff}, {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, 64 + {0x620, 0xff}, {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, 65 + {0x624, 0xff}, {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, 66 + {0x638, 0x50}, {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, 67 + {0x63f, 0x0e}, {0x640, 0x40}, {0x642, 0x40}, {0x643, 0x00}, 68 + {0x652, 0xc8}, {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, 69 + {0x702, 0x65}, {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, 70 + {0x70a, 0x65}, {0x70b, 0x87}, {0x765, 0x18}, {0x76e, 0x04}, 71 + {0xffff, 0xff}, 72 + }; 73 + 74 + static struct rtl8xxxu_reg32val rtl8723b_phy_1t_init_table[] = { 75 + {0x800, 0x80040000}, {0x804, 0x00000003}, 76 + {0x808, 0x0000fc00}, {0x80c, 0x0000000a}, 77 + {0x810, 0x10001331}, {0x814, 0x020c3d10}, 78 + {0x818, 0x02200385}, {0x81c, 0x00000000}, 79 + {0x820, 0x01000100}, {0x824, 0x00190204}, 80 + {0x828, 0x00000000}, {0x82c, 0x00000000}, 81 + {0x830, 0x00000000}, {0x834, 0x00000000}, 82 + {0x838, 0x00000000}, {0x83c, 0x00000000}, 83 + {0x840, 0x00010000}, {0x844, 0x00000000}, 84 + {0x848, 0x00000000}, {0x84c, 0x00000000}, 85 + {0x850, 0x00000000}, {0x854, 0x00000000}, 86 + {0x858, 0x569a11a9}, {0x85c, 0x01000014}, 87 + {0x860, 0x66f60110}, {0x864, 0x061f0649}, 88 + {0x868, 0x00000000}, {0x86c, 0x27272700}, 89 + {0x870, 0x07000760}, {0x874, 0x25004000}, 90 + {0x878, 0x00000808}, {0x87c, 0x00000000}, 91 + {0x880, 0xb0000c1c}, {0x884, 0x00000001}, 92 + {0x888, 0x00000000}, {0x88c, 0xccc000c0}, 93 + {0x890, 0x00000800}, {0x894, 0xfffffffe}, 94 + {0x898, 0x40302010}, {0x89c, 0x00706050}, 95 + {0x900, 0x00000000}, {0x904, 0x00000023}, 96 + {0x908, 0x00000000}, {0x90c, 0x81121111}, 97 + {0x910, 0x00000002}, {0x914, 0x00000201}, 98 + {0xa00, 0x00d047c8}, {0xa04, 0x80ff800c}, 99 + {0xa08, 0x8c838300}, {0xa0c, 0x2e7f120f}, 100 + {0xa10, 0x9500bb78}, {0xa14, 0x1114d028}, 101 + {0xa18, 0x00881117}, {0xa1c, 0x89140f00}, 102 + {0xa20, 0x1a1b0000}, {0xa24, 0x090e1317}, 103 + {0xa28, 0x00000204}, {0xa2c, 0x00d30000}, 104 + {0xa70, 0x101fbf00}, {0xa74, 0x00000007}, 105 + {0xa78, 0x00000900}, {0xa7c, 0x225b0606}, 106 + {0xa80, 0x21806490}, {0xb2c, 0x00000000}, 107 + {0xc00, 0x48071d40}, {0xc04, 0x03a05611}, 108 + {0xc08, 0x000000e4}, {0xc0c, 0x6c6c6c6c}, 109 + {0xc10, 0x08800000}, {0xc14, 0x40000100}, 110 + {0xc18, 0x08800000}, {0xc1c, 0x40000100}, 111 + {0xc20, 0x00000000}, {0xc24, 0x00000000}, 112 + {0xc28, 0x00000000}, {0xc2c, 0x00000000}, 113 + {0xc30, 0x69e9ac44}, {0xc34, 0x469652af}, 114 + {0xc38, 0x49795994}, {0xc3c, 0x0a97971c}, 115 + {0xc40, 0x1f7c403f}, {0xc44, 0x000100b7}, 116 + {0xc48, 0xec020107}, {0xc4c, 0x007f037f}, 117 + {0xc50, 0x69553420}, {0xc54, 0x43bc0094}, 118 + {0xc58, 0x00013149}, {0xc5c, 0x00250492}, 119 + {0xc60, 0x00000000}, {0xc64, 0x7112848b}, 120 + {0xc68, 0x47c00bff}, {0xc6c, 0x00000036}, 121 + {0xc70, 0x2c7f000d}, {0xc74, 0x020610db}, 122 + {0xc78, 0x0000001f}, {0xc7c, 0x00b91612}, 123 + {0xc80, 0x390000e4}, {0xc84, 0x20f60000}, 124 + {0xc88, 0x40000100}, {0xc8c, 0x20200000}, 125 + {0xc90, 0x00020e1a}, {0xc94, 0x00000000}, 126 + {0xc98, 0x00020e1a}, {0xc9c, 0x00007f7f}, 127 + {0xca0, 0x00000000}, {0xca4, 0x000300a0}, 128 + {0xca8, 0x00000000}, {0xcac, 0x00000000}, 129 + {0xcb0, 0x00000000}, {0xcb4, 0x00000000}, 130 + {0xcb8, 0x00000000}, {0xcbc, 0x28000000}, 131 + {0xcc0, 0x00000000}, {0xcc4, 0x00000000}, 132 + {0xcc8, 0x00000000}, {0xccc, 0x00000000}, 133 + {0xcd0, 0x00000000}, {0xcd4, 0x00000000}, 134 + {0xcd8, 0x64b22427}, {0xcdc, 0x00766932}, 135 + {0xce0, 0x00222222}, {0xce4, 0x00000000}, 136 + {0xce8, 0x37644302}, {0xcec, 0x2f97d40c}, 137 + {0xd00, 0x00000740}, {0xd04, 0x40020401}, 138 + {0xd08, 0x0000907f}, {0xd0c, 0x20010201}, 139 + {0xd10, 0xa0633333}, {0xd14, 0x3333bc53}, 140 + {0xd18, 0x7a8f5b6f}, {0xd2c, 0xcc979975}, 141 + {0xd30, 0x00000000}, {0xd34, 0x80608000}, 142 + {0xd38, 0x00000000}, {0xd3c, 0x00127353}, 143 + {0xd40, 0x00000000}, {0xd44, 0x00000000}, 144 + {0xd48, 0x00000000}, {0xd4c, 0x00000000}, 145 + {0xd50, 0x6437140a}, {0xd54, 0x00000000}, 146 + {0xd58, 0x00000282}, {0xd5c, 0x30032064}, 147 + {0xd60, 0x4653de68}, {0xd64, 0x04518a3c}, 148 + {0xd68, 0x00002101}, {0xd6c, 0x2a201c16}, 149 + {0xd70, 0x1812362e}, {0xd74, 0x322c2220}, 150 + {0xd78, 0x000e3c24}, {0xe00, 0x2d2d2d2d}, 151 + {0xe04, 0x2d2d2d2d}, {0xe08, 0x0390272d}, 152 + {0xe10, 0x2d2d2d2d}, {0xe14, 0x2d2d2d2d}, 153 + {0xe18, 0x2d2d2d2d}, {0xe1c, 0x2d2d2d2d}, 154 + {0xe28, 0x00000000}, {0xe30, 0x1000dc1f}, 155 + {0xe34, 0x10008c1f}, {0xe38, 0x02140102}, 156 + {0xe3c, 0x681604c2}, {0xe40, 0x01007c00}, 157 + {0xe44, 0x01004800}, {0xe48, 0xfb000000}, 158 + {0xe4c, 0x000028d1}, {0xe50, 0x1000dc1f}, 159 + {0xe54, 0x10008c1f}, {0xe58, 0x02140102}, 160 + {0xe5c, 0x28160d05}, {0xe60, 0x00000008}, 161 + {0xe68, 0x001b2556}, {0xe6c, 0x00c00096}, 162 + {0xe70, 0x00c00096}, {0xe74, 0x01000056}, 163 + {0xe78, 0x01000014}, {0xe7c, 0x01000056}, 164 + {0xe80, 0x01000014}, {0xe84, 0x00c00096}, 165 + {0xe88, 0x01000056}, {0xe8c, 0x00c00096}, 166 + {0xed0, 0x00c00096}, {0xed4, 0x00c00096}, 167 + {0xed8, 0x00c00096}, {0xedc, 0x000000d6}, 168 + {0xee0, 0x000000d6}, {0xeec, 0x01c00016}, 169 + {0xf14, 0x00000003}, {0xf4c, 0x00000000}, 170 + {0xf00, 0x00000300}, 171 + {0x820, 0x01000100}, {0x800, 0x83040000}, 172 + {0xffff, 0xffffffff}, 173 + }; 174 + 175 + static struct rtl8xxxu_reg32val rtl8xxx_agc_8723bu_table[] = { 176 + {0xc78, 0xfd000001}, {0xc78, 0xfc010001}, 177 + {0xc78, 0xfb020001}, {0xc78, 0xfa030001}, 178 + {0xc78, 0xf9040001}, {0xc78, 0xf8050001}, 179 + {0xc78, 0xf7060001}, {0xc78, 0xf6070001}, 180 + {0xc78, 0xf5080001}, {0xc78, 0xf4090001}, 181 + {0xc78, 0xf30a0001}, {0xc78, 0xf20b0001}, 182 + {0xc78, 0xf10c0001}, {0xc78, 0xf00d0001}, 183 + {0xc78, 0xef0e0001}, {0xc78, 0xee0f0001}, 184 + {0xc78, 0xed100001}, {0xc78, 0xec110001}, 185 + {0xc78, 0xeb120001}, {0xc78, 0xea130001}, 186 + {0xc78, 0xe9140001}, {0xc78, 0xe8150001}, 187 + {0xc78, 0xe7160001}, {0xc78, 0xe6170001}, 188 + {0xc78, 0xe5180001}, {0xc78, 0xe4190001}, 189 + {0xc78, 0xe31a0001}, {0xc78, 0xa51b0001}, 190 + {0xc78, 0xa41c0001}, {0xc78, 0xa31d0001}, 191 + {0xc78, 0x671e0001}, {0xc78, 0x661f0001}, 192 + {0xc78, 0x65200001}, {0xc78, 0x64210001}, 193 + {0xc78, 0x63220001}, {0xc78, 0x4a230001}, 194 + {0xc78, 0x49240001}, {0xc78, 0x48250001}, 195 + {0xc78, 0x47260001}, {0xc78, 0x46270001}, 196 + {0xc78, 0x45280001}, {0xc78, 0x44290001}, 197 + {0xc78, 0x432a0001}, {0xc78, 0x422b0001}, 198 + {0xc78, 0x292c0001}, {0xc78, 0x282d0001}, 199 + {0xc78, 0x272e0001}, {0xc78, 0x262f0001}, 200 + {0xc78, 0x0a300001}, {0xc78, 0x09310001}, 201 + {0xc78, 0x08320001}, {0xc78, 0x07330001}, 202 + {0xc78, 0x06340001}, {0xc78, 0x05350001}, 203 + {0xc78, 0x04360001}, {0xc78, 0x03370001}, 204 + {0xc78, 0x02380001}, {0xc78, 0x01390001}, 205 + {0xc78, 0x013a0001}, {0xc78, 0x013b0001}, 206 + {0xc78, 0x013c0001}, {0xc78, 0x013d0001}, 207 + {0xc78, 0x013e0001}, {0xc78, 0x013f0001}, 208 + {0xc78, 0xfc400001}, {0xc78, 0xfb410001}, 209 + {0xc78, 0xfa420001}, {0xc78, 0xf9430001}, 210 + {0xc78, 0xf8440001}, {0xc78, 0xf7450001}, 211 + {0xc78, 0xf6460001}, {0xc78, 0xf5470001}, 212 + {0xc78, 0xf4480001}, {0xc78, 0xf3490001}, 213 + {0xc78, 0xf24a0001}, {0xc78, 0xf14b0001}, 214 + {0xc78, 0xf04c0001}, {0xc78, 0xef4d0001}, 215 + {0xc78, 0xee4e0001}, {0xc78, 0xed4f0001}, 216 + {0xc78, 0xec500001}, {0xc78, 0xeb510001}, 217 + {0xc78, 0xea520001}, {0xc78, 0xe9530001}, 218 + {0xc78, 0xe8540001}, {0xc78, 0xe7550001}, 219 + {0xc78, 0xe6560001}, {0xc78, 0xe5570001}, 220 + {0xc78, 0xe4580001}, {0xc78, 0xe3590001}, 221 + {0xc78, 0xa65a0001}, {0xc78, 0xa55b0001}, 222 + {0xc78, 0xa45c0001}, {0xc78, 0xa35d0001}, 223 + {0xc78, 0x675e0001}, {0xc78, 0x665f0001}, 224 + {0xc78, 0x65600001}, {0xc78, 0x64610001}, 225 + {0xc78, 0x63620001}, {0xc78, 0x62630001}, 226 + {0xc78, 0x61640001}, {0xc78, 0x48650001}, 227 + {0xc78, 0x47660001}, {0xc78, 0x46670001}, 228 + {0xc78, 0x45680001}, {0xc78, 0x44690001}, 229 + {0xc78, 0x436a0001}, {0xc78, 0x426b0001}, 230 + {0xc78, 0x286c0001}, {0xc78, 0x276d0001}, 231 + {0xc78, 0x266e0001}, {0xc78, 0x256f0001}, 232 + {0xc78, 0x24700001}, {0xc78, 0x09710001}, 233 + {0xc78, 0x08720001}, {0xc78, 0x07730001}, 234 + {0xc78, 0x06740001}, {0xc78, 0x05750001}, 235 + {0xc78, 0x04760001}, {0xc78, 0x03770001}, 236 + {0xc78, 0x02780001}, {0xc78, 0x01790001}, 237 + {0xc78, 0x017a0001}, {0xc78, 0x017b0001}, 238 + {0xc78, 0x017c0001}, {0xc78, 0x017d0001}, 239 + {0xc78, 0x017e0001}, {0xc78, 0x017f0001}, 240 + {0xc50, 0x69553422}, 241 + {0xc50, 0x69553420}, 242 + {0x824, 0x00390204}, 243 + {0xffff, 0xffffffff} 244 + }; 245 + 246 + static struct rtl8xxxu_rfregval rtl8723bu_radioa_1t_init_table[] = { 247 + {0x00, 0x00010000}, {0xb0, 0x000dffe0}, 248 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 249 + {0xfe, 0x00000000}, {0xb1, 0x00000018}, 250 + {0xfe, 0x00000000}, {0xfe, 0x00000000}, 251 + {0xfe, 0x00000000}, {0xb2, 0x00084c00}, 252 + {0xb5, 0x0000d2cc}, {0xb6, 0x000925aa}, 253 + {0xb7, 0x00000010}, {0xb8, 0x0000907f}, 254 + {0x5c, 0x00000002}, {0x7c, 0x00000002}, 255 + {0x7e, 0x00000005}, {0x8b, 0x0006fc00}, 256 + {0xb0, 0x000ff9f0}, {0x1c, 0x000739d2}, 257 + {0x1e, 0x00000000}, {0xdf, 0x00000780}, 258 + {0x50, 0x00067435}, 259 + /* 260 + * The 8723bu vendor driver indicates that bit 8 should be set in 261 + * 0x51 for package types TFBGA90, TFBGA80, and TFBGA79. However 262 + * they never actually check the package type - and just default 263 + * to not setting it. 264 + */ 265 + {0x51, 0x0006b04e}, 266 + {0x52, 0x000007d2}, {0x53, 0x00000000}, 267 + {0x54, 0x00050400}, {0x55, 0x0004026e}, 268 + {0xdd, 0x0000004c}, {0x70, 0x00067435}, 269 + /* 270 + * 0x71 has same package type condition as for register 0x51 271 + */ 272 + {0x71, 0x0006b04e}, 273 + {0x72, 0x000007d2}, {0x73, 0x00000000}, 274 + {0x74, 0x00050400}, {0x75, 0x0004026e}, 275 + {0xef, 0x00000100}, {0x34, 0x0000add7}, 276 + {0x35, 0x00005c00}, {0x34, 0x00009dd4}, 277 + {0x35, 0x00005000}, {0x34, 0x00008dd1}, 278 + {0x35, 0x00004400}, {0x34, 0x00007dce}, 279 + {0x35, 0x00003800}, {0x34, 0x00006cd1}, 280 + {0x35, 0x00004400}, {0x34, 0x00005cce}, 281 + {0x35, 0x00003800}, {0x34, 0x000048ce}, 282 + {0x35, 0x00004400}, {0x34, 0x000034ce}, 283 + {0x35, 0x00003800}, {0x34, 0x00002451}, 284 + {0x35, 0x00004400}, {0x34, 0x0000144e}, 285 + {0x35, 0x00003800}, {0x34, 0x00000051}, 286 + {0x35, 0x00004400}, {0xef, 0x00000000}, 287 + {0xef, 0x00000100}, {0xed, 0x00000010}, 288 + {0x44, 0x0000add7}, {0x44, 0x00009dd4}, 289 + {0x44, 0x00008dd1}, {0x44, 0x00007dce}, 290 + {0x44, 0x00006cc1}, {0x44, 0x00005cce}, 291 + {0x44, 0x000044d1}, {0x44, 0x000034ce}, 292 + {0x44, 0x00002451}, {0x44, 0x0000144e}, 293 + {0x44, 0x00000051}, {0xef, 0x00000000}, 294 + {0xed, 0x00000000}, {0x7f, 0x00020080}, 295 + {0xef, 0x00002000}, {0x3b, 0x000380ef}, 296 + {0x3b, 0x000302fe}, {0x3b, 0x00028ce6}, 297 + {0x3b, 0x000200bc}, {0x3b, 0x000188a5}, 298 + {0x3b, 0x00010fbc}, {0x3b, 0x00008f71}, 299 + {0x3b, 0x00000900}, {0xef, 0x00000000}, 300 + {0xed, 0x00000001}, {0x40, 0x000380ef}, 301 + {0x40, 0x000302fe}, {0x40, 0x00028ce6}, 302 + {0x40, 0x000200bc}, {0x40, 0x000188a5}, 303 + {0x40, 0x00010fbc}, {0x40, 0x00008f71}, 304 + {0x40, 0x00000900}, {0xed, 0x00000000}, 305 + {0x82, 0x00080000}, {0x83, 0x00008000}, 306 + {0x84, 0x00048d80}, {0x85, 0x00068000}, 307 + {0xa2, 0x00080000}, {0xa3, 0x00008000}, 308 + {0xa4, 0x00048d80}, {0xa5, 0x00068000}, 309 + {0xed, 0x00000002}, {0xef, 0x00000002}, 310 + {0x56, 0x00000032}, {0x76, 0x00000032}, 311 + {0x01, 0x00000780}, 312 + {0xff, 0xffffffff} 313 + }; 314 + 315 + static void rtl8723bu_write_btreg(struct rtl8xxxu_priv *priv, u8 reg, u8 data) 316 + { 317 + struct h2c_cmd h2c; 318 + int reqnum = 0; 319 + 320 + memset(&h2c, 0, sizeof(struct h2c_cmd)); 321 + h2c.bt_mp_oper.cmd = H2C_8723B_BT_MP_OPER; 322 + h2c.bt_mp_oper.operreq = 0 | (reqnum << 4); 323 + h2c.bt_mp_oper.opcode = BT_MP_OP_WRITE_REG_VALUE; 324 + h2c.bt_mp_oper.data = data; 325 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.bt_mp_oper)); 326 + 327 + reqnum++; 328 + memset(&h2c, 0, sizeof(struct h2c_cmd)); 329 + h2c.bt_mp_oper.cmd = H2C_8723B_BT_MP_OPER; 330 + h2c.bt_mp_oper.operreq = 0 | (reqnum << 4); 331 + h2c.bt_mp_oper.opcode = BT_MP_OP_WRITE_REG_VALUE; 332 + h2c.bt_mp_oper.addr = reg; 333 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.bt_mp_oper)); 334 + } 335 + 336 + static void rtl8723bu_reset_8051(struct rtl8xxxu_priv *priv) 337 + { 338 + u8 val8; 339 + u16 sys_func; 340 + 341 + val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL); 342 + val8 &= ~BIT(1); 343 + rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); 344 + 345 + val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL + 1); 346 + val8 &= ~BIT(0); 347 + rtl8xxxu_write8(priv, REG_RSV_CTRL + 1, val8); 348 + 349 + sys_func = rtl8xxxu_read16(priv, REG_SYS_FUNC); 350 + sys_func &= ~SYS_FUNC_CPU_ENABLE; 351 + rtl8xxxu_write16(priv, REG_SYS_FUNC, sys_func); 352 + 353 + val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL); 354 + val8 &= ~BIT(1); 355 + rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); 356 + 357 + val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL + 1); 358 + val8 |= BIT(0); 359 + rtl8xxxu_write8(priv, REG_RSV_CTRL + 1, val8); 360 + 361 + sys_func |= SYS_FUNC_CPU_ENABLE; 362 + rtl8xxxu_write16(priv, REG_SYS_FUNC, sys_func); 363 + } 364 + 365 + static void 366 + rtl8723b_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) 367 + { 368 + u32 val32, ofdm, mcs; 369 + u8 cck, ofdmbase, mcsbase; 370 + int group, tx_idx; 371 + 372 + tx_idx = 0; 373 + group = rtl8xxxu_gen2_channel_to_group(channel); 374 + 375 + cck = priv->cck_tx_power_index_B[group]; 376 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); 377 + val32 &= 0xffff00ff; 378 + val32 |= (cck << 8); 379 + rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32); 380 + 381 + val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); 382 + val32 &= 0xff; 383 + val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); 384 + rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); 385 + 386 + ofdmbase = priv->ht40_1s_tx_power_index_B[group]; 387 + ofdmbase += priv->ofdm_tx_power_diff[tx_idx].b; 388 + ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24; 389 + 390 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm); 391 + rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm); 392 + 393 + mcsbase = priv->ht40_1s_tx_power_index_B[group]; 394 + if (ht40) 395 + mcsbase += priv->ht40_tx_power_diff[tx_idx++].b; 396 + else 397 + mcsbase += priv->ht20_tx_power_diff[tx_idx++].b; 398 + mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; 399 + 400 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); 401 + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); 402 + } 403 + 404 + static int rtl8723bu_parse_efuse(struct rtl8xxxu_priv *priv) 405 + { 406 + struct rtl8723bu_efuse *efuse = &priv->efuse_wifi.efuse8723bu; 407 + int i; 408 + 409 + if (efuse->rtl_id != cpu_to_le16(0x8129)) 410 + return -EINVAL; 411 + 412 + ether_addr_copy(priv->mac_addr, efuse->mac_addr); 413 + 414 + memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base, 415 + sizeof(efuse->tx_power_index_A.cck_base)); 416 + memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_B.cck_base, 417 + sizeof(efuse->tx_power_index_B.cck_base)); 418 + 419 + memcpy(priv->ht40_1s_tx_power_index_A, 420 + efuse->tx_power_index_A.ht40_base, 421 + sizeof(efuse->tx_power_index_A.ht40_base)); 422 + memcpy(priv->ht40_1s_tx_power_index_B, 423 + efuse->tx_power_index_B.ht40_base, 424 + sizeof(efuse->tx_power_index_B.ht40_base)); 425 + 426 + priv->ofdm_tx_power_diff[0].a = 427 + efuse->tx_power_index_A.ht20_ofdm_1s_diff.a; 428 + priv->ofdm_tx_power_diff[0].b = 429 + efuse->tx_power_index_B.ht20_ofdm_1s_diff.a; 430 + 431 + priv->ht20_tx_power_diff[0].a = 432 + efuse->tx_power_index_A.ht20_ofdm_1s_diff.b; 433 + priv->ht20_tx_power_diff[0].b = 434 + efuse->tx_power_index_B.ht20_ofdm_1s_diff.b; 435 + 436 + priv->ht40_tx_power_diff[0].a = 0; 437 + priv->ht40_tx_power_diff[0].b = 0; 438 + 439 + for (i = 1; i < RTL8723B_TX_COUNT; i++) { 440 + priv->ofdm_tx_power_diff[i].a = 441 + efuse->tx_power_index_A.pwr_diff[i - 1].ofdm; 442 + priv->ofdm_tx_power_diff[i].b = 443 + efuse->tx_power_index_B.pwr_diff[i - 1].ofdm; 444 + 445 + priv->ht20_tx_power_diff[i].a = 446 + efuse->tx_power_index_A.pwr_diff[i - 1].ht20; 447 + priv->ht20_tx_power_diff[i].b = 448 + efuse->tx_power_index_B.pwr_diff[i - 1].ht20; 449 + 450 + priv->ht40_tx_power_diff[i].a = 451 + efuse->tx_power_index_A.pwr_diff[i - 1].ht40; 452 + priv->ht40_tx_power_diff[i].b = 453 + efuse->tx_power_index_B.pwr_diff[i - 1].ht40; 454 + } 455 + 456 + priv->has_xtalk = 1; 457 + priv->xtalk = priv->efuse_wifi.efuse8723bu.xtal_k & 0x3f; 458 + 459 + dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); 460 + dev_info(&priv->udev->dev, "Product: %.41s\n", efuse->device_name); 461 + 462 + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { 463 + int i; 464 + unsigned char *raw = priv->efuse_wifi.raw; 465 + 466 + dev_info(&priv->udev->dev, 467 + "%s: dumping efuse (0x%02zx bytes):\n", 468 + __func__, sizeof(struct rtl8723bu_efuse)); 469 + for (i = 0; i < sizeof(struct rtl8723bu_efuse); i += 8) { 470 + dev_info(&priv->udev->dev, "%02x: " 471 + "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, 472 + raw[i], raw[i + 1], raw[i + 2], 473 + raw[i + 3], raw[i + 4], raw[i + 5], 474 + raw[i + 6], raw[i + 7]); 475 + } 476 + } 477 + 478 + return 0; 479 + } 480 + 481 + static int rtl8723bu_load_firmware(struct rtl8xxxu_priv *priv) 482 + { 483 + char *fw_name; 484 + int ret; 485 + 486 + if (priv->enable_bluetooth) 487 + fw_name = "rtlwifi/rtl8723bu_bt.bin"; 488 + else 489 + fw_name = "rtlwifi/rtl8723bu_nic.bin"; 490 + 491 + ret = rtl8xxxu_load_firmware(priv, fw_name); 492 + return ret; 493 + } 494 + 495 + static void rtl8723bu_init_phy_bb(struct rtl8xxxu_priv *priv) 496 + { 497 + u8 val8; 498 + u16 val16; 499 + 500 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 501 + val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; 502 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 503 + 504 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 505 + 506 + /* 6. 0x1f[7:0] = 0x07 */ 507 + val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; 508 + rtl8xxxu_write8(priv, REG_RF_CTRL, val8); 509 + 510 + /* Why? */ 511 + rtl8xxxu_write8(priv, REG_SYS_FUNC, 0xe3); 512 + rtl8xxxu_write8(priv, REG_AFE_XTAL_CTRL + 1, 0x80); 513 + rtl8xxxu_init_phy_regs(priv, rtl8723b_phy_1t_init_table); 514 + 515 + rtl8xxxu_init_phy_regs(priv, rtl8xxx_agc_8723bu_table); 516 + } 517 + 518 + static int rtl8723bu_init_phy_rf(struct rtl8xxxu_priv *priv) 519 + { 520 + int ret; 521 + 522 + ret = rtl8xxxu_init_phy_rf(priv, rtl8723bu_radioa_1t_init_table, RF_A); 523 + /* 524 + * PHY LCK 525 + */ 526 + rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdfbe0); 527 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_MODE_AG, 0x8c01); 528 + msleep(200); 529 + rtl8xxxu_write_rfreg(priv, RF_A, 0xb0, 0xdffe0); 530 + 531 + return ret; 532 + } 533 + 534 + static void rtl8723bu_phy_init_antenna_selection(struct rtl8xxxu_priv *priv) 535 + { 536 + u32 val32; 537 + 538 + val32 = rtl8xxxu_read32(priv, REG_PAD_CTRL1); 539 + val32 &= ~(BIT(20) | BIT(24)); 540 + rtl8xxxu_write32(priv, REG_PAD_CTRL1, val32); 541 + 542 + val32 = rtl8xxxu_read32(priv, REG_GPIO_MUXCFG); 543 + val32 &= ~BIT(4); 544 + rtl8xxxu_write32(priv, REG_GPIO_MUXCFG, val32); 545 + 546 + val32 = rtl8xxxu_read32(priv, REG_GPIO_MUXCFG); 547 + val32 |= BIT(3); 548 + rtl8xxxu_write32(priv, REG_GPIO_MUXCFG, val32); 549 + 550 + val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 551 + val32 |= BIT(24); 552 + rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 553 + 554 + val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 555 + val32 &= ~BIT(23); 556 + rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 557 + 558 + val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 559 + val32 |= (BIT(0) | BIT(1)); 560 + rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 561 + 562 + val32 = rtl8xxxu_read32(priv, REG_RFE_CTRL_ANTA_SRC); 563 + val32 &= 0xffffff00; 564 + val32 |= 0x77; 565 + rtl8xxxu_write32(priv, REG_RFE_CTRL_ANTA_SRC, val32); 566 + 567 + val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 568 + val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 569 + rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 570 + } 571 + 572 + static int rtl8723bu_iqk_path_a(struct rtl8xxxu_priv *priv) 573 + { 574 + u32 reg_eac, reg_e94, reg_e9c, path_sel, val32; 575 + int result = 0; 576 + 577 + path_sel = rtl8xxxu_read32(priv, REG_S0S1_PATH_SWITCH); 578 + 579 + /* 580 + * Leave IQK mode 581 + */ 582 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 583 + val32 &= 0x000000ff; 584 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 585 + 586 + /* 587 + * Enable path A PA in TX IQK mode 588 + */ 589 + val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 590 + val32 |= 0x80000; 591 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 592 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x20000); 593 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0003f); 594 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xc7f87); 595 + 596 + /* 597 + * Tx IQK setting 598 + */ 599 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 600 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 601 + 602 + /* path-A IQK setting */ 603 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 604 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 605 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 606 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 607 + 608 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x821403ea); 609 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28110000); 610 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82110000); 611 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x28110000); 612 + 613 + /* LO calibration setting */ 614 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00462911); 615 + 616 + /* 617 + * Enter IQK mode 618 + */ 619 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 620 + val32 &= 0x000000ff; 621 + val32 |= 0x80800000; 622 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 623 + 624 + /* 625 + * The vendor driver indicates the USB module is always using 626 + * S0S1 path 1 for the 8723bu. This may be different for 8192eu 627 + */ 628 + if (priv->rf_paths > 1) 629 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000000); 630 + else 631 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000280); 632 + 633 + /* 634 + * Bit 12 seems to be BT_GRANT, and is only found in the 8723bu. 635 + * No trace of this in the 8192eu or 8188eu vendor drivers. 636 + */ 637 + rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00000800); 638 + 639 + /* One shot, path A LOK & IQK */ 640 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 641 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 642 + 643 + mdelay(1); 644 + 645 + /* Restore Ant Path */ 646 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, path_sel); 647 + #ifdef RTL8723BU_BT 648 + /* GNT_BT = 1 */ 649 + rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00001800); 650 + #endif 651 + 652 + /* 653 + * Leave IQK mode 654 + */ 655 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 656 + val32 &= 0x000000ff; 657 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 658 + 659 + /* Check failed */ 660 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 661 + reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 662 + reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 663 + 664 + val32 = (reg_e9c >> 16) & 0x3ff; 665 + if (val32 & 0x200) 666 + val32 = 0x400 - val32; 667 + 668 + if (!(reg_eac & BIT(28)) && 669 + ((reg_e94 & 0x03ff0000) != 0x01420000) && 670 + ((reg_e9c & 0x03ff0000) != 0x00420000) && 671 + ((reg_e94 & 0x03ff0000) < 0x01100000) && 672 + ((reg_e94 & 0x03ff0000) > 0x00f00000) && 673 + val32 < 0xf) 674 + result |= 0x01; 675 + else /* If TX not OK, ignore RX */ 676 + goto out; 677 + 678 + out: 679 + return result; 680 + } 681 + 682 + static int rtl8723bu_rx_iqk_path_a(struct rtl8xxxu_priv *priv) 683 + { 684 + u32 reg_ea4, reg_eac, reg_e94, reg_e9c, path_sel, val32; 685 + int result = 0; 686 + 687 + path_sel = rtl8xxxu_read32(priv, REG_S0S1_PATH_SWITCH); 688 + 689 + /* 690 + * Leave IQK mode 691 + */ 692 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 693 + val32 &= 0x000000ff; 694 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 695 + 696 + /* 697 + * Enable path A PA in TX IQK mode 698 + */ 699 + val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 700 + val32 |= 0x80000; 701 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 702 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 703 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 704 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7fb7); 705 + 706 + /* 707 + * Tx IQK setting 708 + */ 709 + rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); 710 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 711 + 712 + /* path-A IQK setting */ 713 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x18008c1c); 714 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x38008c1c); 715 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 716 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 717 + 718 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160ff0); 719 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28110000); 720 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82110000); 721 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x28110000); 722 + 723 + /* LO calibration setting */ 724 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); 725 + 726 + /* 727 + * Enter IQK mode 728 + */ 729 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 730 + val32 &= 0x000000ff; 731 + val32 |= 0x80800000; 732 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 733 + 734 + /* 735 + * The vendor driver indicates the USB module is always using 736 + * S0S1 path 1 for the 8723bu. This may be different for 8192eu 737 + */ 738 + if (priv->rf_paths > 1) 739 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000000); 740 + else 741 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000280); 742 + 743 + /* 744 + * Bit 12 seems to be BT_GRANT, and is only found in the 8723bu. 745 + * No trace of this in the 8192eu or 8188eu vendor drivers. 746 + */ 747 + rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00000800); 748 + 749 + /* One shot, path A LOK & IQK */ 750 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 751 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 752 + 753 + mdelay(1); 754 + 755 + /* Restore Ant Path */ 756 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, path_sel); 757 + #ifdef RTL8723BU_BT 758 + /* GNT_BT = 1 */ 759 + rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00001800); 760 + #endif 761 + 762 + /* 763 + * Leave IQK mode 764 + */ 765 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 766 + val32 &= 0x000000ff; 767 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 768 + 769 + /* Check failed */ 770 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 771 + reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); 772 + reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); 773 + 774 + val32 = (reg_e9c >> 16) & 0x3ff; 775 + if (val32 & 0x200) 776 + val32 = 0x400 - val32; 777 + 778 + if (!(reg_eac & BIT(28)) && 779 + ((reg_e94 & 0x03ff0000) != 0x01420000) && 780 + ((reg_e9c & 0x03ff0000) != 0x00420000) && 781 + ((reg_e94 & 0x03ff0000) < 0x01100000) && 782 + ((reg_e94 & 0x03ff0000) > 0x00f00000) && 783 + val32 < 0xf) 784 + result |= 0x01; 785 + else /* If TX not OK, ignore RX */ 786 + goto out; 787 + 788 + val32 = 0x80007c00 | (reg_e94 &0x3ff0000) | 789 + ((reg_e9c & 0x3ff0000) >> 16); 790 + rtl8xxxu_write32(priv, REG_TX_IQK, val32); 791 + 792 + /* 793 + * Modify RX IQK mode 794 + */ 795 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 796 + val32 &= 0x000000ff; 797 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 798 + val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 799 + val32 |= 0x80000; 800 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 801 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 802 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 803 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7d77); 804 + 805 + /* 806 + * PA, PAD setting 807 + */ 808 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0xf80); 809 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_55, 0x4021f); 810 + 811 + /* 812 + * RX IQK setting 813 + */ 814 + rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); 815 + 816 + /* path-A IQK setting */ 817 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); 818 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x18008c1c); 819 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_B, 0x38008c1c); 820 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_B, 0x38008c1c); 821 + 822 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82110000); 823 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x2816001f); 824 + rtl8xxxu_write32(priv, REG_TX_IQK_PI_B, 0x82110000); 825 + rtl8xxxu_write32(priv, REG_RX_IQK_PI_B, 0x28110000); 826 + 827 + /* LO calibration setting */ 828 + rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a8d1); 829 + 830 + /* 831 + * Enter IQK mode 832 + */ 833 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 834 + val32 &= 0x000000ff; 835 + val32 |= 0x80800000; 836 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 837 + 838 + if (priv->rf_paths > 1) 839 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000000); 840 + else 841 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00000280); 842 + 843 + /* 844 + * Disable BT 845 + */ 846 + rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00000800); 847 + 848 + /* One shot, path A LOK & IQK */ 849 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); 850 + rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); 851 + 852 + mdelay(1); 853 + 854 + /* Restore Ant Path */ 855 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, path_sel); 856 + #ifdef RTL8723BU_BT 857 + /* GNT_BT = 1 */ 858 + rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, 0x00001800); 859 + #endif 860 + 861 + /* 862 + * Leave IQK mode 863 + */ 864 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 865 + val32 &= 0x000000ff; 866 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 867 + 868 + /* Check failed */ 869 + reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); 870 + reg_ea4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_A_2); 871 + 872 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x780); 873 + 874 + val32 = (reg_eac >> 16) & 0x3ff; 875 + if (val32 & 0x200) 876 + val32 = 0x400 - val32; 877 + 878 + if (!(reg_eac & BIT(27)) && 879 + ((reg_ea4 & 0x03ff0000) != 0x01320000) && 880 + ((reg_eac & 0x03ff0000) != 0x00360000) && 881 + ((reg_ea4 & 0x03ff0000) < 0x01100000) && 882 + ((reg_ea4 & 0x03ff0000) > 0x00f00000) && 883 + val32 < 0xf) 884 + result |= 0x02; 885 + else /* If TX not OK, ignore RX */ 886 + goto out; 887 + out: 888 + return result; 889 + } 890 + 891 + static void rtl8723bu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, 892 + int result[][8], int t) 893 + { 894 + struct device *dev = &priv->udev->dev; 895 + u32 i, val32; 896 + int path_a_ok /*, path_b_ok */; 897 + int retry = 2; 898 + const u32 adda_regs[RTL8XXXU_ADDA_REGS] = { 899 + REG_FPGA0_XCD_SWITCH_CTRL, REG_BLUETOOTH, 900 + REG_RX_WAIT_CCA, REG_TX_CCK_RFON, 901 + REG_TX_CCK_BBON, REG_TX_OFDM_RFON, 902 + REG_TX_OFDM_BBON, REG_TX_TO_RX, 903 + REG_TX_TO_TX, REG_RX_CCK, 904 + REG_RX_OFDM, REG_RX_WAIT_RIFS, 905 + REG_RX_TO_RX, REG_STANDBY, 906 + REG_SLEEP, REG_PMPD_ANAEN 907 + }; 908 + const u32 iqk_mac_regs[RTL8XXXU_MAC_REGS] = { 909 + REG_TXPAUSE, REG_BEACON_CTRL, 910 + REG_BEACON_CTRL_1, REG_GPIO_MUXCFG 911 + }; 912 + const u32 iqk_bb_regs[RTL8XXXU_BB_REGS] = { 913 + REG_OFDM0_TRX_PATH_ENABLE, REG_OFDM0_TR_MUX_PAR, 914 + REG_FPGA0_XCD_RF_SW_CTRL, REG_CONFIG_ANT_A, REG_CONFIG_ANT_B, 915 + REG_FPGA0_XAB_RF_SW_CTRL, REG_FPGA0_XA_RF_INT_OE, 916 + REG_FPGA0_XB_RF_INT_OE, REG_FPGA0_RF_MODE 917 + }; 918 + u8 xa_agc = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1) & 0xff; 919 + u8 xb_agc = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1) & 0xff; 920 + 921 + /* 922 + * Note: IQ calibration must be performed after loading 923 + * PHY_REG.txt , and radio_a, radio_b.txt 924 + */ 925 + 926 + if (t == 0) { 927 + /* Save ADDA parameters, turn Path A ADDA on */ 928 + rtl8xxxu_save_regs(priv, adda_regs, priv->adda_backup, 929 + RTL8XXXU_ADDA_REGS); 930 + rtl8xxxu_save_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 931 + rtl8xxxu_save_regs(priv, iqk_bb_regs, 932 + priv->bb_backup, RTL8XXXU_BB_REGS); 933 + } 934 + 935 + rtl8xxxu_path_adda_on(priv, adda_regs, true); 936 + 937 + /* MAC settings */ 938 + rtl8xxxu_mac_calibration(priv, iqk_mac_regs, priv->mac_backup); 939 + 940 + val32 = rtl8xxxu_read32(priv, REG_CCK0_AFE_SETTING); 941 + val32 |= 0x0f000000; 942 + rtl8xxxu_write32(priv, REG_CCK0_AFE_SETTING, val32); 943 + 944 + rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, 0x03a05600); 945 + rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); 946 + rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22204000); 947 + 948 + /* 949 + * RX IQ calibration setting for 8723B D cut large current issue 950 + * when leaving IPS 951 + */ 952 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 953 + val32 &= 0x000000ff; 954 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 955 + 956 + val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 957 + val32 |= 0x80000; 958 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 959 + 960 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); 961 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 962 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7fb7); 963 + 964 + val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED); 965 + val32 |= 0x20; 966 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED, val32); 967 + 968 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_43, 0x60fbd); 969 + 970 + for (i = 0; i < retry; i++) { 971 + path_a_ok = rtl8723bu_iqk_path_a(priv); 972 + if (path_a_ok == 0x01) { 973 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 974 + val32 &= 0x000000ff; 975 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 976 + 977 + val32 = rtl8xxxu_read32(priv, 978 + REG_TX_POWER_BEFORE_IQK_A); 979 + result[t][0] = (val32 >> 16) & 0x3ff; 980 + val32 = rtl8xxxu_read32(priv, 981 + REG_TX_POWER_AFTER_IQK_A); 982 + result[t][1] = (val32 >> 16) & 0x3ff; 983 + 984 + break; 985 + } 986 + } 987 + 988 + if (!path_a_ok) 989 + dev_dbg(dev, "%s: Path A TX IQK failed!\n", __func__); 990 + 991 + for (i = 0; i < retry; i++) { 992 + path_a_ok = rtl8723bu_rx_iqk_path_a(priv); 993 + if (path_a_ok == 0x03) { 994 + val32 = rtl8xxxu_read32(priv, 995 + REG_RX_POWER_BEFORE_IQK_A_2); 996 + result[t][2] = (val32 >> 16) & 0x3ff; 997 + val32 = rtl8xxxu_read32(priv, 998 + REG_RX_POWER_AFTER_IQK_A_2); 999 + result[t][3] = (val32 >> 16) & 0x3ff; 1000 + 1001 + break; 1002 + } 1003 + } 1004 + 1005 + if (!path_a_ok) 1006 + dev_dbg(dev, "%s: Path A RX IQK failed!\n", __func__); 1007 + 1008 + if (priv->tx_paths > 1) { 1009 + #if 1 1010 + dev_warn(dev, "%s: Path B not supported\n", __func__); 1011 + #else 1012 + 1013 + /* 1014 + * Path A into standby 1015 + */ 1016 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 1017 + val32 &= 0x000000ff; 1018 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 1019 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0x10000); 1020 + 1021 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 1022 + val32 &= 0x000000ff; 1023 + val32 |= 0x80800000; 1024 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 1025 + 1026 + /* Turn Path B ADDA on */ 1027 + rtl8xxxu_path_adda_on(priv, adda_regs, false); 1028 + 1029 + for (i = 0; i < retry; i++) { 1030 + path_b_ok = rtl8xxxu_iqk_path_b(priv); 1031 + if (path_b_ok == 0x03) { 1032 + val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); 1033 + result[t][4] = (val32 >> 16) & 0x3ff; 1034 + val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); 1035 + result[t][5] = (val32 >> 16) & 0x3ff; 1036 + break; 1037 + } 1038 + } 1039 + 1040 + if (!path_b_ok) 1041 + dev_dbg(dev, "%s: Path B IQK failed!\n", __func__); 1042 + 1043 + for (i = 0; i < retry; i++) { 1044 + path_b_ok = rtl8723bu_rx_iqk_path_b(priv); 1045 + if (path_a_ok == 0x03) { 1046 + val32 = rtl8xxxu_read32(priv, 1047 + REG_RX_POWER_BEFORE_IQK_B_2); 1048 + result[t][6] = (val32 >> 16) & 0x3ff; 1049 + val32 = rtl8xxxu_read32(priv, 1050 + REG_RX_POWER_AFTER_IQK_B_2); 1051 + result[t][7] = (val32 >> 16) & 0x3ff; 1052 + break; 1053 + } 1054 + } 1055 + 1056 + if (!path_b_ok) 1057 + dev_dbg(dev, "%s: Path B RX IQK failed!\n", __func__); 1058 + #endif 1059 + } 1060 + 1061 + /* Back to BB mode, load original value */ 1062 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 1063 + val32 &= 0x000000ff; 1064 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 1065 + 1066 + if (t) { 1067 + /* Reload ADDA power saving parameters */ 1068 + rtl8xxxu_restore_regs(priv, adda_regs, priv->adda_backup, 1069 + RTL8XXXU_ADDA_REGS); 1070 + 1071 + /* Reload MAC parameters */ 1072 + rtl8xxxu_restore_mac_regs(priv, iqk_mac_regs, priv->mac_backup); 1073 + 1074 + /* Reload BB parameters */ 1075 + rtl8xxxu_restore_regs(priv, iqk_bb_regs, 1076 + priv->bb_backup, RTL8XXXU_BB_REGS); 1077 + 1078 + /* Restore RX initial gain */ 1079 + val32 = rtl8xxxu_read32(priv, REG_OFDM0_XA_AGC_CORE1); 1080 + val32 &= 0xffffff00; 1081 + rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | 0x50); 1082 + rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, val32 | xa_agc); 1083 + 1084 + if (priv->tx_paths > 1) { 1085 + val32 = rtl8xxxu_read32(priv, REG_OFDM0_XB_AGC_CORE1); 1086 + val32 &= 0xffffff00; 1087 + rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 1088 + val32 | 0x50); 1089 + rtl8xxxu_write32(priv, REG_OFDM0_XB_AGC_CORE1, 1090 + val32 | xb_agc); 1091 + } 1092 + 1093 + /* Load 0xe30 IQC default value */ 1094 + rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x01008c00); 1095 + rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x01008c00); 1096 + } 1097 + } 1098 + 1099 + static void rtl8723bu_phy_iq_calibrate(struct rtl8xxxu_priv *priv) 1100 + { 1101 + struct device *dev = &priv->udev->dev; 1102 + int result[4][8]; /* last is final result */ 1103 + int i, candidate; 1104 + bool path_a_ok, path_b_ok; 1105 + u32 reg_e94, reg_e9c, reg_ea4, reg_eac; 1106 + u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; 1107 + u32 val32, bt_control; 1108 + s32 reg_tmp = 0; 1109 + bool simu; 1110 + 1111 + rtl8xxxu_gen2_prepare_calibrate(priv, 1); 1112 + 1113 + memset(result, 0, sizeof(result)); 1114 + candidate = -1; 1115 + 1116 + path_a_ok = false; 1117 + path_b_ok = false; 1118 + 1119 + bt_control = rtl8xxxu_read32(priv, REG_BT_CONTROL_8723BU); 1120 + 1121 + for (i = 0; i < 3; i++) { 1122 + rtl8723bu_phy_iqcalibrate(priv, result, i); 1123 + 1124 + if (i == 1) { 1125 + simu = rtl8xxxu_gen2_simularity_compare(priv, 1126 + result, 0, 1); 1127 + if (simu) { 1128 + candidate = 0; 1129 + break; 1130 + } 1131 + } 1132 + 1133 + if (i == 2) { 1134 + simu = rtl8xxxu_gen2_simularity_compare(priv, 1135 + result, 0, 2); 1136 + if (simu) { 1137 + candidate = 0; 1138 + break; 1139 + } 1140 + 1141 + simu = rtl8xxxu_gen2_simularity_compare(priv, 1142 + result, 1, 2); 1143 + if (simu) { 1144 + candidate = 1; 1145 + } else { 1146 + for (i = 0; i < 8; i++) 1147 + reg_tmp += result[3][i]; 1148 + 1149 + if (reg_tmp) 1150 + candidate = 3; 1151 + else 1152 + candidate = -1; 1153 + } 1154 + } 1155 + } 1156 + 1157 + for (i = 0; i < 4; i++) { 1158 + reg_e94 = result[i][0]; 1159 + reg_e9c = result[i][1]; 1160 + reg_ea4 = result[i][2]; 1161 + reg_eac = result[i][3]; 1162 + reg_eb4 = result[i][4]; 1163 + reg_ebc = result[i][5]; 1164 + reg_ec4 = result[i][6]; 1165 + reg_ecc = result[i][7]; 1166 + } 1167 + 1168 + if (candidate >= 0) { 1169 + reg_e94 = result[candidate][0]; 1170 + priv->rege94 = reg_e94; 1171 + reg_e9c = result[candidate][1]; 1172 + priv->rege9c = reg_e9c; 1173 + reg_ea4 = result[candidate][2]; 1174 + reg_eac = result[candidate][3]; 1175 + reg_eb4 = result[candidate][4]; 1176 + priv->regeb4 = reg_eb4; 1177 + reg_ebc = result[candidate][5]; 1178 + priv->regebc = reg_ebc; 1179 + reg_ec4 = result[candidate][6]; 1180 + reg_ecc = result[candidate][7]; 1181 + dev_dbg(dev, "%s: candidate is %x\n", __func__, candidate); 1182 + dev_dbg(dev, 1183 + "%s: e94 =%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x " 1184 + "ecc=%x\n ", __func__, reg_e94, reg_e9c, 1185 + reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc); 1186 + path_a_ok = true; 1187 + path_b_ok = true; 1188 + } else { 1189 + reg_e94 = reg_eb4 = priv->rege94 = priv->regeb4 = 0x100; 1190 + reg_e9c = reg_ebc = priv->rege9c = priv->regebc = 0x0; 1191 + } 1192 + 1193 + if (reg_e94 && candidate >= 0) 1194 + rtl8xxxu_fill_iqk_matrix_a(priv, path_a_ok, result, 1195 + candidate, (reg_ea4 == 0)); 1196 + 1197 + if (priv->tx_paths > 1 && reg_eb4) 1198 + rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, 1199 + candidate, (reg_ec4 == 0)); 1200 + 1201 + rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, 1202 + priv->bb_recovery_backup, RTL8XXXU_BB_REGS); 1203 + 1204 + rtl8xxxu_write32(priv, REG_BT_CONTROL_8723BU, bt_control); 1205 + 1206 + val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_WE_LUT); 1207 + val32 |= 0x80000; 1208 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, val32); 1209 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x18000); 1210 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0001f); 1211 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xe6177); 1212 + val32 = rtl8xxxu_read_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED); 1213 + val32 |= 0x20; 1214 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_ED, val32); 1215 + rtl8xxxu_write_rfreg(priv, RF_A, 0x43, 0x300bd); 1216 + 1217 + if (priv->rf_paths > 1) 1218 + dev_dbg(dev, "%s: 8723BU 2T not supported\n", __func__); 1219 + 1220 + rtl8xxxu_gen2_prepare_calibrate(priv, 0); 1221 + } 1222 + 1223 + static int rtl8723bu_active_to_emu(struct rtl8xxxu_priv *priv) 1224 + { 1225 + u8 val8; 1226 + u16 val16; 1227 + u32 val32; 1228 + int count, ret = 0; 1229 + 1230 + /* Turn off RF */ 1231 + rtl8xxxu_write8(priv, REG_RF_CTRL, 0); 1232 + 1233 + /* Enable rising edge triggering interrupt */ 1234 + val16 = rtl8xxxu_read16(priv, REG_GPIO_INTM); 1235 + val16 &= ~GPIO_INTM_EDGE_TRIG_IRQ; 1236 + rtl8xxxu_write16(priv, REG_GPIO_INTM, val16); 1237 + 1238 + /* Release WLON reset 0x04[16]= 1*/ 1239 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1240 + val32 |= APS_FSMCO_WLON_RESET; 1241 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 1242 + 1243 + /* 0x0005[1] = 1 turn off MAC by HW state machine*/ 1244 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 1245 + val8 |= BIT(1); 1246 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 1247 + 1248 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 1249 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 1250 + if ((val8 & BIT(1)) == 0) 1251 + break; 1252 + udelay(10); 1253 + } 1254 + 1255 + if (!count) { 1256 + dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n", 1257 + __func__); 1258 + ret = -EBUSY; 1259 + goto exit; 1260 + } 1261 + 1262 + /* Enable BT control XTAL setting */ 1263 + val8 = rtl8xxxu_read8(priv, REG_AFE_MISC); 1264 + val8 &= ~AFE_MISC_WL_XTAL_CTRL; 1265 + rtl8xxxu_write8(priv, REG_AFE_MISC, val8); 1266 + 1267 + /* 0x0000[5] = 1 analog Ips to digital, 1:isolation */ 1268 + val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 1269 + val8 |= SYS_ISO_ANALOG_IPS; 1270 + rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 1271 + 1272 + /* 0x0020[0] = 0 disable LDOA12 MACRO block*/ 1273 + val8 = rtl8xxxu_read8(priv, REG_LDOA15_CTRL); 1274 + val8 &= ~LDOA15_ENABLE; 1275 + rtl8xxxu_write8(priv, REG_LDOA15_CTRL, val8); 1276 + 1277 + exit: 1278 + return ret; 1279 + } 1280 + 1281 + static int rtl8723b_emu_to_active(struct rtl8xxxu_priv *priv) 1282 + { 1283 + u8 val8; 1284 + u32 val32; 1285 + int count, ret = 0; 1286 + 1287 + /* 0x20[0] = 1 enable LDOA12 MACRO block for all interface */ 1288 + val8 = rtl8xxxu_read8(priv, REG_LDOA15_CTRL); 1289 + val8 |= LDOA15_ENABLE; 1290 + rtl8xxxu_write8(priv, REG_LDOA15_CTRL, val8); 1291 + 1292 + /* 0x67[0] = 0 to disable BT_GPS_SEL pins*/ 1293 + val8 = rtl8xxxu_read8(priv, 0x0067); 1294 + val8 &= ~BIT(4); 1295 + rtl8xxxu_write8(priv, 0x0067, val8); 1296 + 1297 + mdelay(1); 1298 + 1299 + /* 0x00[5] = 0 release analog Ips to digital, 1:isolation */ 1300 + val8 = rtl8xxxu_read8(priv, REG_SYS_ISO_CTRL); 1301 + val8 &= ~SYS_ISO_ANALOG_IPS; 1302 + rtl8xxxu_write8(priv, REG_SYS_ISO_CTRL, val8); 1303 + 1304 + /* Disable SW LPS 0x04[10]= 0 */ 1305 + val32 = rtl8xxxu_read8(priv, REG_APS_FSMCO); 1306 + val32 &= ~APS_FSMCO_SW_LPS; 1307 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 1308 + 1309 + /* Wait until 0x04[17] = 1 power ready */ 1310 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 1311 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1312 + if (val32 & BIT(17)) 1313 + break; 1314 + 1315 + udelay(10); 1316 + } 1317 + 1318 + if (!count) { 1319 + ret = -EBUSY; 1320 + goto exit; 1321 + } 1322 + 1323 + /* We should be able to optimize the following three entries into one */ 1324 + 1325 + /* Release WLON reset 0x04[16]= 1*/ 1326 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1327 + val32 |= APS_FSMCO_WLON_RESET; 1328 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 1329 + 1330 + /* Disable HWPDN 0x04[15]= 0*/ 1331 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1332 + val32 &= ~APS_FSMCO_HW_POWERDOWN; 1333 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 1334 + 1335 + /* Disable WL suspend*/ 1336 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1337 + val32 &= ~(APS_FSMCO_HW_SUSPEND | APS_FSMCO_PCIE); 1338 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 1339 + 1340 + /* Set, then poll until 0 */ 1341 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1342 + val32 |= APS_FSMCO_MAC_ENABLE; 1343 + rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); 1344 + 1345 + for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { 1346 + val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); 1347 + if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { 1348 + ret = 0; 1349 + break; 1350 + } 1351 + udelay(10); 1352 + } 1353 + 1354 + if (!count) { 1355 + ret = -EBUSY; 1356 + goto exit; 1357 + } 1358 + 1359 + /* Enable WL control XTAL setting */ 1360 + val8 = rtl8xxxu_read8(priv, REG_AFE_MISC); 1361 + val8 |= AFE_MISC_WL_XTAL_CTRL; 1362 + rtl8xxxu_write8(priv, REG_AFE_MISC, val8); 1363 + 1364 + /* Enable falling edge triggering interrupt */ 1365 + val8 = rtl8xxxu_read8(priv, REG_GPIO_INTM + 1); 1366 + val8 |= BIT(1); 1367 + rtl8xxxu_write8(priv, REG_GPIO_INTM + 1, val8); 1368 + 1369 + /* Enable GPIO9 interrupt mode */ 1370 + val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL_2 + 1); 1371 + val8 |= BIT(1); 1372 + rtl8xxxu_write8(priv, REG_GPIO_IO_SEL_2 + 1, val8); 1373 + 1374 + /* Enable GPIO9 input mode */ 1375 + val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL_2); 1376 + val8 &= ~BIT(1); 1377 + rtl8xxxu_write8(priv, REG_GPIO_IO_SEL_2, val8); 1378 + 1379 + /* Enable HSISR GPIO[C:0] interrupt */ 1380 + val8 = rtl8xxxu_read8(priv, REG_HSIMR); 1381 + val8 |= BIT(0); 1382 + rtl8xxxu_write8(priv, REG_HSIMR, val8); 1383 + 1384 + /* Enable HSISR GPIO9 interrupt */ 1385 + val8 = rtl8xxxu_read8(priv, REG_HSIMR + 2); 1386 + val8 |= BIT(1); 1387 + rtl8xxxu_write8(priv, REG_HSIMR + 2, val8); 1388 + 1389 + val8 = rtl8xxxu_read8(priv, REG_MULTI_FUNC_CTRL); 1390 + val8 |= MULTI_WIFI_HW_ROF_EN; 1391 + rtl8xxxu_write8(priv, REG_MULTI_FUNC_CTRL, val8); 1392 + 1393 + /* For GPIO9 internal pull high setting BIT(14) */ 1394 + val8 = rtl8xxxu_read8(priv, REG_MULTI_FUNC_CTRL + 1); 1395 + val8 |= BIT(6); 1396 + rtl8xxxu_write8(priv, REG_MULTI_FUNC_CTRL + 1, val8); 1397 + 1398 + exit: 1399 + return ret; 1400 + } 1401 + 1402 + static int rtl8723bu_power_on(struct rtl8xxxu_priv *priv) 1403 + { 1404 + u8 val8; 1405 + u16 val16; 1406 + u32 val32; 1407 + int ret; 1408 + 1409 + rtl8xxxu_disabled_to_emu(priv); 1410 + 1411 + ret = rtl8723b_emu_to_active(priv); 1412 + if (ret) 1413 + goto exit; 1414 + 1415 + /* 1416 + * Enable MAC DMA/WMAC/SCHEDULE/SEC block 1417 + * Set CR bit10 to enable 32k calibration. 1418 + */ 1419 + val16 = rtl8xxxu_read16(priv, REG_CR); 1420 + val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | 1421 + CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | 1422 + CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | 1423 + CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | 1424 + CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); 1425 + rtl8xxxu_write16(priv, REG_CR, val16); 1426 + 1427 + /* 1428 + * BT coexist power on settings. This is identical for 1 and 2 1429 + * antenna parts. 1430 + */ 1431 + rtl8xxxu_write8(priv, REG_PAD_CTRL1 + 3, 0x20); 1432 + 1433 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 1434 + val16 |= SYS_FUNC_BBRSTB | SYS_FUNC_BB_GLB_RSTN; 1435 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 1436 + 1437 + rtl8xxxu_write8(priv, REG_BT_CONTROL_8723BU + 1, 0x18); 1438 + rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 1439 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 1440 + /* Antenna inverse */ 1441 + rtl8xxxu_write8(priv, 0xfe08, 0x01); 1442 + 1443 + val16 = rtl8xxxu_read16(priv, REG_PWR_DATA); 1444 + val16 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 1445 + rtl8xxxu_write16(priv, REG_PWR_DATA, val16); 1446 + 1447 + val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 1448 + val32 |= LEDCFG0_DPDT_SELECT; 1449 + rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 1450 + 1451 + val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 1452 + val8 &= ~PAD_CTRL1_SW_DPDT_SEL_DATA; 1453 + rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 1454 + exit: 1455 + return ret; 1456 + } 1457 + 1458 + static void rtl8723bu_power_off(struct rtl8xxxu_priv *priv) 1459 + { 1460 + u8 val8; 1461 + u16 val16; 1462 + 1463 + rtl8xxxu_flush_fifo(priv); 1464 + 1465 + /* 1466 + * Disable TX report timer 1467 + */ 1468 + val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); 1469 + val8 &= ~TX_REPORT_CTRL_TIMER_ENABLE; 1470 + rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); 1471 + 1472 + rtl8xxxu_write8(priv, REG_CR, 0x0000); 1473 + 1474 + rtl8xxxu_active_to_lps(priv); 1475 + 1476 + /* Reset Firmware if running in RAM */ 1477 + if (rtl8xxxu_read8(priv, REG_MCU_FW_DL) & MCU_FW_RAM_SEL) 1478 + rtl8xxxu_firmware_self_reset(priv); 1479 + 1480 + /* Reset MCU */ 1481 + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); 1482 + val16 &= ~SYS_FUNC_CPU_ENABLE; 1483 + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); 1484 + 1485 + /* Reset MCU ready status */ 1486 + rtl8xxxu_write8(priv, REG_MCU_FW_DL, 0x00); 1487 + 1488 + rtl8723bu_active_to_emu(priv); 1489 + 1490 + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); 1491 + val8 |= BIT(3); /* APS_FSMCO_HW_SUSPEND */ 1492 + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); 1493 + 1494 + /* 0x48[16] = 1 to enable GPIO9 as EXT wakeup */ 1495 + val8 = rtl8xxxu_read8(priv, REG_GPIO_INTM + 2); 1496 + val8 |= BIT(0); 1497 + rtl8xxxu_write8(priv, REG_GPIO_INTM + 2, val8); 1498 + } 1499 + 1500 + static void rtl8723b_enable_rf(struct rtl8xxxu_priv *priv) 1501 + { 1502 + struct h2c_cmd h2c; 1503 + u32 val32; 1504 + u8 val8; 1505 + 1506 + /* 1507 + * No indication anywhere as to what 0x0790 does. The 2 antenna 1508 + * vendor code preserves bits 6-7 here. 1509 + */ 1510 + rtl8xxxu_write8(priv, 0x0790, 0x05); 1511 + /* 1512 + * 0x0778 seems to be related to enabling the number of antennas 1513 + * In the vendor driver halbtc8723b2ant_InitHwConfig() sets it 1514 + * to 0x03, while halbtc8723b1ant_InitHwConfig() sets it to 0x01 1515 + */ 1516 + rtl8xxxu_write8(priv, 0x0778, 0x01); 1517 + 1518 + val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); 1519 + val8 |= BIT(5); 1520 + rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); 1521 + 1522 + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_IQADJ_G1, 0x780); 1523 + 1524 + rtl8723bu_write_btreg(priv, 0x3c, 0x15); /* BT TRx Mask on */ 1525 + 1526 + /* 1527 + * Set BT grant to low 1528 + */ 1529 + memset(&h2c, 0, sizeof(struct h2c_cmd)); 1530 + h2c.bt_grant.cmd = H2C_8723B_BT_GRANT; 1531 + h2c.bt_grant.data = 0; 1532 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.bt_grant)); 1533 + 1534 + /* 1535 + * WLAN action by PTA 1536 + */ 1537 + rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); 1538 + 1539 + /* 1540 + * BT select S0/S1 controlled by WiFi 1541 + */ 1542 + val8 = rtl8xxxu_read8(priv, 0x0067); 1543 + val8 |= BIT(5); 1544 + rtl8xxxu_write8(priv, 0x0067, val8); 1545 + 1546 + val32 = rtl8xxxu_read32(priv, REG_PWR_DATA); 1547 + val32 |= PWR_DATA_EEPRPAD_RFE_CTRL_EN; 1548 + rtl8xxxu_write32(priv, REG_PWR_DATA, val32); 1549 + 1550 + /* 1551 + * Bits 6/7 are marked in/out ... but for what? 1552 + */ 1553 + rtl8xxxu_write8(priv, 0x0974, 0xff); 1554 + 1555 + val32 = rtl8xxxu_read32(priv, REG_RFE_BUFFER); 1556 + val32 |= (BIT(0) | BIT(1)); 1557 + rtl8xxxu_write32(priv, REG_RFE_BUFFER, val32); 1558 + 1559 + rtl8xxxu_write8(priv, REG_RFE_CTRL_ANTA_SRC, 0x77); 1560 + 1561 + val32 = rtl8xxxu_read32(priv, REG_LEDCFG0); 1562 + val32 &= ~BIT(24); 1563 + val32 |= BIT(23); 1564 + rtl8xxxu_write32(priv, REG_LEDCFG0, val32); 1565 + 1566 + /* 1567 + * Fix external switch Main->S1, Aux->S0 1568 + */ 1569 + val8 = rtl8xxxu_read8(priv, REG_PAD_CTRL1); 1570 + val8 &= ~BIT(0); 1571 + rtl8xxxu_write8(priv, REG_PAD_CTRL1, val8); 1572 + 1573 + memset(&h2c, 0, sizeof(struct h2c_cmd)); 1574 + h2c.ant_sel_rsv.cmd = H2C_8723B_ANT_SEL_RSV; 1575 + h2c.ant_sel_rsv.ant_inverse = 1; 1576 + h2c.ant_sel_rsv.int_switch_type = 0; 1577 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.ant_sel_rsv)); 1578 + 1579 + /* 1580 + * 0x280, 0x00, 0x200, 0x80 - not clear 1581 + */ 1582 + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); 1583 + 1584 + /* 1585 + * Software control, antenna at WiFi side 1586 + */ 1587 + #ifdef NEED_PS_TDMA 1588 + rtl8723bu_set_ps_tdma(priv, 0x08, 0x00, 0x00, 0x00, 0x00); 1589 + #endif 1590 + 1591 + rtl8xxxu_write32(priv, REG_BT_COEX_TABLE1, 0x55555555); 1592 + rtl8xxxu_write32(priv, REG_BT_COEX_TABLE2, 0x55555555); 1593 + rtl8xxxu_write32(priv, REG_BT_COEX_TABLE3, 0x00ffffff); 1594 + rtl8xxxu_write8(priv, REG_BT_COEX_TABLE4, 0x03); 1595 + 1596 + memset(&h2c, 0, sizeof(struct h2c_cmd)); 1597 + h2c.bt_info.cmd = H2C_8723B_BT_INFO; 1598 + h2c.bt_info.data = BIT(0); 1599 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.bt_info)); 1600 + 1601 + memset(&h2c, 0, sizeof(struct h2c_cmd)); 1602 + h2c.ignore_wlan.cmd = H2C_8723B_BT_IGNORE_WLANACT; 1603 + h2c.ignore_wlan.data = 0; 1604 + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.ignore_wlan)); 1605 + } 1606 + 1607 + static void rtl8723bu_init_aggregation(struct rtl8xxxu_priv *priv) 1608 + { 1609 + u32 agg_rx; 1610 + u8 agg_ctrl; 1611 + 1612 + /* 1613 + * For now simply disable RX aggregation 1614 + */ 1615 + agg_ctrl = rtl8xxxu_read8(priv, REG_TRXDMA_CTRL); 1616 + agg_ctrl &= ~TRXDMA_CTRL_RXDMA_AGG_EN; 1617 + 1618 + agg_rx = rtl8xxxu_read32(priv, REG_RXDMA_AGG_PG_TH); 1619 + agg_rx &= ~RXDMA_USB_AGG_ENABLE; 1620 + agg_rx &= ~0xff0f; 1621 + 1622 + rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl); 1623 + rtl8xxxu_write32(priv, REG_RXDMA_AGG_PG_TH, agg_rx); 1624 + } 1625 + 1626 + static void rtl8723bu_init_statistics(struct rtl8xxxu_priv *priv) 1627 + { 1628 + u32 val32; 1629 + 1630 + /* Time duration for NHM unit: 4us, 0x2710=40ms */ 1631 + rtl8xxxu_write16(priv, REG_NHM_TIMER_8723B + 2, 0x2710); 1632 + rtl8xxxu_write16(priv, REG_NHM_TH9_TH10_8723B + 2, 0xffff); 1633 + rtl8xxxu_write32(priv, REG_NHM_TH3_TO_TH0_8723B, 0xffffff52); 1634 + rtl8xxxu_write32(priv, REG_NHM_TH7_TO_TH4_8723B, 0xffffffff); 1635 + /* TH8 */ 1636 + val32 = rtl8xxxu_read32(priv, REG_FPGA0_IQK); 1637 + val32 |= 0xff; 1638 + rtl8xxxu_write32(priv, REG_FPGA0_IQK, val32); 1639 + /* Enable CCK */ 1640 + val32 = rtl8xxxu_read32(priv, REG_NHM_TH9_TH10_8723B); 1641 + val32 |= BIT(8) | BIT(9) | BIT(10); 1642 + rtl8xxxu_write32(priv, REG_NHM_TH9_TH10_8723B, val32); 1643 + /* Max power amongst all RX antennas */ 1644 + val32 = rtl8xxxu_read32(priv, REG_OFDM0_FA_RSTC); 1645 + val32 |= BIT(7); 1646 + rtl8xxxu_write32(priv, REG_OFDM0_FA_RSTC, val32); 1647 + } 1648 + 1649 + struct rtl8xxxu_fileops rtl8723bu_fops = { 1650 + .parse_efuse = rtl8723bu_parse_efuse, 1651 + .load_firmware = rtl8723bu_load_firmware, 1652 + .power_on = rtl8723bu_power_on, 1653 + .power_off = rtl8723bu_power_off, 1654 + .reset_8051 = rtl8723bu_reset_8051, 1655 + .llt_init = rtl8xxxu_auto_llt_table, 1656 + .init_phy_bb = rtl8723bu_init_phy_bb, 1657 + .init_phy_rf = rtl8723bu_init_phy_rf, 1658 + .phy_init_antenna_selection = rtl8723bu_phy_init_antenna_selection, 1659 + .phy_iq_calibrate = rtl8723bu_phy_iq_calibrate, 1660 + .config_channel = rtl8xxxu_gen2_config_channel, 1661 + .parse_rx_desc = rtl8xxxu_parse_rxdesc24, 1662 + .init_aggregation = rtl8723bu_init_aggregation, 1663 + .init_statistics = rtl8723bu_init_statistics, 1664 + .enable_rf = rtl8723b_enable_rf, 1665 + .disable_rf = rtl8xxxu_gen2_disable_rf, 1666 + .usb_quirks = rtl8xxxu_gen2_usb_quirks, 1667 + .set_tx_power = rtl8723b_set_tx_power, 1668 + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, 1669 + .report_connect = rtl8xxxu_gen2_report_connect, 1670 + .writeN_block_size = 1024, 1671 + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), 1672 + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), 1673 + .has_s0s1 = 1, 1674 + .adda_1t_init = 0x01c00014, 1675 + .adda_1t_path_on = 0x01c00014, 1676 + .adda_2t_path_on_a = 0x01c00014, 1677 + .adda_2t_path_on_b = 0x01c00014, 1678 + .trxff_boundary = 0x3f7f, 1679 + .pbp_rx = PBP_PAGE_SIZE_256, 1680 + .pbp_tx = PBP_PAGE_SIZE_256, 1681 + .mactable = rtl8723b_mac_init_table, 1682 + };
+2 -2
drivers/net/wireless/realtek/rtlwifi/base.c
··· 1660 1660 if (((rtlpriv->link_info.num_rx_inperiod + 1661 1661 rtlpriv->link_info.num_tx_inperiod) > 8) || 1662 1662 (rtlpriv->link_info.num_rx_inperiod > 2)) 1663 - rtl_lps_enter(hw); 1664 - else 1665 1663 rtl_lps_leave(hw); 1664 + else 1665 + rtl_lps_enter(hw); 1666 1666 } 1667 1667 1668 1668 rtlpriv->link_info.num_rx_inperiod = 0;
+2 -2
drivers/net/wireless/realtek/rtlwifi/pci.c
··· 1572 1572 true, 1573 1573 HW_DESC_TXBUFF_ADDR), 1574 1574 skb->len, PCI_DMA_TODEVICE); 1575 - kfree_skb(skb); 1575 + dev_kfree_skb_irq(skb); 1576 1576 ring->idx = (ring->idx + 1) % ring->entries; 1577 1577 } 1578 1578 ring->idx = 0; ··· 2456 2456 EXPORT_SYMBOL(rtl_pci_resume); 2457 2457 #endif /* CONFIG_PM_SLEEP */ 2458 2458 2459 - struct rtl_intf_ops rtl_pci_ops = { 2459 + const struct rtl_intf_ops rtl_pci_ops = { 2460 2460 .read_efuse_byte = read_efuse_byte, 2461 2461 .adapter_start = rtl_pci_start, 2462 2462 .adapter_stop = rtl_pci_stop,
+1 -1
drivers/net/wireless/realtek/rtlwifi/pci.h
··· 286 286 287 287 int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw); 288 288 289 - extern struct rtl_intf_ops rtl_pci_ops; 289 + extern const struct rtl_intf_ops rtl_pci_ops; 290 290 291 291 int rtl_pci_probe(struct pci_dev *pdev, 292 292 const struct pci_device_id *id);
+4 -8
drivers/net/wireless/realtek/rtlwifi/ps.c
··· 443 443 444 444 spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); 445 445 446 - /* Idle for a while if we connect to AP a while ago. */ 447 - if (mac->cnt_after_linked >= 2) { 448 - if (ppsc->dot11_psmode == EACTIVE) { 449 - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 450 - "Enter 802.11 power save mode...\n"); 451 - 452 - rtl_lps_set_psmode(hw, EAUTOPS); 453 - } 446 + if (ppsc->dot11_psmode == EACTIVE) { 447 + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 448 + "Enter 802.11 power save mode...\n"); 449 + rtl_lps_set_psmode(hw, EAUTOPS); 454 450 } 455 451 456 452 spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag);
+1 -2
drivers/net/wireless/realtek/rtlwifi/rtl8192se/rf.c
··· 208 208 "Realtek regulatory, 40MHz, writeval = 0x%x\n", 209 209 writeval); 210 210 } else { 211 - if (rtlphy->pwrgroup_cnt == 1) 212 - chnlgroup = 0; 211 + chnlgroup = 0; 213 212 214 213 if (rtlphy->pwrgroup_cnt >= 3) { 215 214 if (chnl <= 3)
+1 -1
drivers/net/wireless/realtek/rtlwifi/usb.c
··· 1049 1049 rtlpriv->cfg->ops->fill_h2c_cmd(hw, H2C_RA_MASK, 5, rtlpriv->rate_mask); 1050 1050 } 1051 1051 1052 - static struct rtl_intf_ops rtl_usb_ops = { 1052 + static const struct rtl_intf_ops rtl_usb_ops = { 1053 1053 .adapter_start = rtl_usb_start, 1054 1054 .adapter_stop = rtl_usb_stop, 1055 1055 .adapter_tx = rtl_usb_tx,
+1 -1
drivers/net/wireless/realtek/rtlwifi/wifi.h
··· 2593 2593 *intf_ops : for diff interrface usb/pcie 2594 2594 */ 2595 2595 struct rtl_hal_cfg *cfg; 2596 - struct rtl_intf_ops *intf_ops; 2596 + const struct rtl_intf_ops *intf_ops; 2597 2597 2598 2598 /*this var will be set by set_bit, 2599 2599 and was used to indicate status of
+2 -2
drivers/net/wireless/ti/wl12xx/main.c
··· 553 553 .size = 0x00000004 554 554 }, 555 555 .mem3 = { 556 - .start = 0x00040404, 557 - .size = 0x00000000 556 + .start = 0x00000000, 557 + .size = 0x00040404 558 558 }, 559 559 }, 560 560
+14 -3
drivers/net/wireless/ti/wlcore/io.c
··· 175 175 if (ret < 0) 176 176 goto out; 177 177 178 - /* We don't need the size of the last partition, as it is 179 - * automatically calculated based on the total memory size and 180 - * the sizes of the previous partitions. 178 + /* wl12xx only: We don't need the size of the last partition, 179 + * as it is automatically calculated based on the total memory 180 + * size and the sizes of the previous partitions. 181 + * 182 + * wl18xx re-defines the HW_PART3 addresses for logger over 183 + * SDIO support. wl12xx is expecting the write to 184 + * HW_PART3_START_ADDR at offset 24. This creates conflict 185 + * between the addresses. 186 + * In order to fix this the expected value is written to 187 + * HW_PART3_SIZE_ADDR instead which is at offset 24 after changes. 181 188 */ 182 189 ret = wlcore_raw_write32(wl, HW_PART3_START_ADDR, p->mem3.start); 190 + if (ret < 0) 191 + goto out; 192 + 193 + ret = wlcore_raw_write32(wl, HW_PART3_SIZE_ADDR, p->mem3.size); 183 194 if (ret < 0) 184 195 goto out; 185 196
+2 -1
drivers/net/wireless/ti/wlcore/io.h
··· 36 36 #define HW_PART1_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 12) 37 37 #define HW_PART2_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 16) 38 38 #define HW_PART2_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 20) 39 - #define HW_PART3_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 24) 39 + #define HW_PART3_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 24) 40 + #define HW_PART3_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 28) 40 41 41 42 #define HW_ACCESS_REGISTER_SIZE 4 42 43
+2 -2
drivers/net/xen-netback/hash.c
··· 311 311 if (len > XEN_NETBK_MAX_HASH_KEY_SIZE) 312 312 return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; 313 313 314 - if (len != 0) { 314 + if (copy_op.len != 0) { 315 315 gnttab_batch_copy(&copy_op, 1); 316 316 317 317 if (copy_op.status != GNTST_okay) ··· 359 359 if (mapping[off++] >= vif->num_queues) 360 360 return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; 361 361 362 - if (len != 0) { 362 + if (copy_op.len != 0) { 363 363 gnttab_batch_copy(&copy_op, 1); 364 364 365 365 if (copy_op.status != GNTST_okay)
+1 -2
drivers/net/xen-netback/interface.c
··· 780 780 vif->ctrl_task = NULL; 781 781 } 782 782 783 - xenvif_deinit_hash(vif); 784 - 785 783 if (vif->ctrl_irq) { 784 + xenvif_deinit_hash(vif); 786 785 unbind_from_irqhandler(vif->ctrl_irq, vif); 787 786 vif->ctrl_irq = 0; 788 787 }
+6 -6
drivers/scsi/iscsi_tcp.c
··· 131 131 struct iscsi_tcp_conn *tcp_conn; 132 132 read_descriptor_t rd_desc; 133 133 134 - read_lock(&sk->sk_callback_lock); 134 + read_lock_bh(&sk->sk_callback_lock); 135 135 conn = sk->sk_user_data; 136 136 if (!conn) { 137 - read_unlock(&sk->sk_callback_lock); 137 + read_unlock_bh(&sk->sk_callback_lock); 138 138 return; 139 139 } 140 140 tcp_conn = conn->dd_data; ··· 154 154 /* If we had to (atomically) map a highmem page, 155 155 * unmap it now. */ 156 156 iscsi_tcp_segment_unmap(&tcp_conn->in.segment); 157 - read_unlock(&sk->sk_callback_lock); 157 + read_unlock_bh(&sk->sk_callback_lock); 158 158 } 159 159 160 160 static void iscsi_sw_tcp_state_change(struct sock *sk) ··· 165 165 struct iscsi_session *session; 166 166 void (*old_state_change)(struct sock *); 167 167 168 - read_lock(&sk->sk_callback_lock); 168 + read_lock_bh(&sk->sk_callback_lock); 169 169 conn = sk->sk_user_data; 170 170 if (!conn) { 171 - read_unlock(&sk->sk_callback_lock); 171 + read_unlock_bh(&sk->sk_callback_lock); 172 172 return; 173 173 } 174 174 session = conn->session; ··· 179 179 tcp_sw_conn = tcp_conn->dd_data; 180 180 old_state_change = tcp_sw_conn->old_state_change; 181 181 182 - read_unlock(&sk->sk_callback_lock); 182 + read_unlock_bh(&sk->sk_callback_lock); 183 183 184 184 old_state_change(sk); 185 185 }
+9 -8
fs/ocfs2/cluster/tcp.c
··· 600 600 static void o2net_data_ready(struct sock *sk) 601 601 { 602 602 void (*ready)(struct sock *sk); 603 + struct o2net_sock_container *sc; 603 604 604 - read_lock(&sk->sk_callback_lock); 605 - if (sk->sk_user_data) { 606 - struct o2net_sock_container *sc = sk->sk_user_data; 605 + read_lock_bh(&sk->sk_callback_lock); 606 + sc = sk->sk_user_data; 607 + if (sc) { 607 608 sclog(sc, "data_ready hit\n"); 608 609 o2net_set_data_ready_time(sc); 609 610 o2net_sc_queue_work(sc, &sc->sc_rx_work); ··· 612 611 } else { 613 612 ready = sk->sk_data_ready; 614 613 } 615 - read_unlock(&sk->sk_callback_lock); 614 + read_unlock_bh(&sk->sk_callback_lock); 616 615 617 616 ready(sk); 618 617 } ··· 623 622 void (*state_change)(struct sock *sk); 624 623 struct o2net_sock_container *sc; 625 624 626 - read_lock(&sk->sk_callback_lock); 625 + read_lock_bh(&sk->sk_callback_lock); 627 626 sc = sk->sk_user_data; 628 627 if (sc == NULL) { 629 628 state_change = sk->sk_state_change; ··· 650 649 break; 651 650 } 652 651 out: 653 - read_unlock(&sk->sk_callback_lock); 652 + read_unlock_bh(&sk->sk_callback_lock); 654 653 state_change(sk); 655 654 } 656 655 ··· 2013 2012 { 2014 2013 void (*ready)(struct sock *sk); 2015 2014 2016 - read_lock(&sk->sk_callback_lock); 2015 + read_lock_bh(&sk->sk_callback_lock); 2017 2016 ready = sk->sk_user_data; 2018 2017 if (ready == NULL) { /* check for teardown race */ 2019 2018 ready = sk->sk_data_ready; ··· 2040 2039 } 2041 2040 2042 2041 out: 2043 - read_unlock(&sk->sk_callback_lock); 2042 + read_unlock_bh(&sk->sk_callback_lock); 2044 2043 if (ready != NULL) 2045 2044 ready(sk); 2046 2045 }
+1
include/linux/mmc/sdio_ids.h
··· 36 36 #define SDIO_DEVICE_ID_BROADCOM_43430 0xa9a6 37 37 #define SDIO_DEVICE_ID_BROADCOM_4345 0x4345 38 38 #define SDIO_DEVICE_ID_BROADCOM_4354 0x4354 39 + #define SDIO_DEVICE_ID_BROADCOM_4356 0x4356 39 40 40 41 #define SDIO_VENDOR_ID_INTEL 0x0089 41 42 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402
+6 -6
include/linux/netdev_features.h
··· 44 44 NETIF_F_FSO_BIT, /* ... FCoE segmentation */ 45 45 NETIF_F_GSO_GRE_BIT, /* ... GRE with TSO */ 46 46 NETIF_F_GSO_GRE_CSUM_BIT, /* ... GRE with csum with TSO */ 47 - NETIF_F_GSO_IPIP_BIT, /* ... IPIP tunnel with TSO */ 48 - NETIF_F_GSO_SIT_BIT, /* ... SIT tunnel with TSO */ 47 + NETIF_F_GSO_IPXIP4_BIT, /* ... IP4 or IP6 over IP4 with TSO */ 48 + NETIF_F_GSO_IPXIP6_BIT, /* ... IP4 or IP6 over IP6 with TSO */ 49 49 NETIF_F_GSO_UDP_TUNNEL_BIT, /* ... UDP TUNNEL with TSO */ 50 50 NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */ 51 51 NETIF_F_GSO_PARTIAL_BIT, /* ... Only segment inner-most L4 ··· 121 121 #define NETIF_F_RXALL __NETIF_F(RXALL) 122 122 #define NETIF_F_GSO_GRE __NETIF_F(GSO_GRE) 123 123 #define NETIF_F_GSO_GRE_CSUM __NETIF_F(GSO_GRE_CSUM) 124 - #define NETIF_F_GSO_IPIP __NETIF_F(GSO_IPIP) 125 - #define NETIF_F_GSO_SIT __NETIF_F(GSO_SIT) 124 + #define NETIF_F_GSO_IPXIP4 __NETIF_F(GSO_IPXIP4) 125 + #define NETIF_F_GSO_IPXIP6 __NETIF_F(GSO_IPXIP6) 126 126 #define NETIF_F_GSO_UDP_TUNNEL __NETIF_F(GSO_UDP_TUNNEL) 127 127 #define NETIF_F_GSO_UDP_TUNNEL_CSUM __NETIF_F(GSO_UDP_TUNNEL_CSUM) 128 128 #define NETIF_F_TSO_MANGLEID __NETIF_F(TSO_MANGLEID) ··· 200 200 201 201 #define NETIF_F_GSO_ENCAP_ALL (NETIF_F_GSO_GRE | \ 202 202 NETIF_F_GSO_GRE_CSUM | \ 203 - NETIF_F_GSO_IPIP | \ 204 - NETIF_F_GSO_SIT | \ 203 + NETIF_F_GSO_IPXIP4 | \ 204 + NETIF_F_GSO_IPXIP6 | \ 205 205 NETIF_F_GSO_UDP_TUNNEL | \ 206 206 NETIF_F_GSO_UDP_TUNNEL_CSUM) 207 207
+2 -2
include/linux/netdevice.h
··· 4006 4006 BUILD_BUG_ON(SKB_GSO_FCOE != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT)); 4007 4007 BUILD_BUG_ON(SKB_GSO_GRE != (NETIF_F_GSO_GRE >> NETIF_F_GSO_SHIFT)); 4008 4008 BUILD_BUG_ON(SKB_GSO_GRE_CSUM != (NETIF_F_GSO_GRE_CSUM >> NETIF_F_GSO_SHIFT)); 4009 - BUILD_BUG_ON(SKB_GSO_IPIP != (NETIF_F_GSO_IPIP >> NETIF_F_GSO_SHIFT)); 4010 - BUILD_BUG_ON(SKB_GSO_SIT != (NETIF_F_GSO_SIT >> NETIF_F_GSO_SHIFT)); 4009 + BUILD_BUG_ON(SKB_GSO_IPXIP4 != (NETIF_F_GSO_IPXIP4 >> NETIF_F_GSO_SHIFT)); 4010 + BUILD_BUG_ON(SKB_GSO_IPXIP6 != (NETIF_F_GSO_IPXIP6 >> NETIF_F_GSO_SHIFT)); 4011 4011 BUILD_BUG_ON(SKB_GSO_UDP_TUNNEL != (NETIF_F_GSO_UDP_TUNNEL >> NETIF_F_GSO_SHIFT)); 4012 4012 BUILD_BUG_ON(SKB_GSO_UDP_TUNNEL_CSUM != (NETIF_F_GSO_UDP_TUNNEL_CSUM >> NETIF_F_GSO_SHIFT)); 4013 4013 BUILD_BUG_ON(SKB_GSO_PARTIAL != (NETIF_F_GSO_PARTIAL >> NETIF_F_GSO_SHIFT));
+4 -4
include/linux/skbuff.h
··· 471 471 472 472 SKB_GSO_GRE_CSUM = 1 << 8, 473 473 474 - SKB_GSO_IPIP = 1 << 9, 474 + SKB_GSO_IPXIP4 = 1 << 9, 475 475 476 - SKB_GSO_SIT = 1 << 10, 476 + SKB_GSO_IPXIP6 = 1 << 10, 477 477 478 478 SKB_GSO_UDP_TUNNEL = 1 << 11, 479 479 ··· 2467 2467 2468 2468 static inline struct page *dev_alloc_pages(unsigned int order) 2469 2469 { 2470 - return __dev_alloc_pages(GFP_ATOMIC, order); 2470 + return __dev_alloc_pages(GFP_ATOMIC | __GFP_NOWARN, order); 2471 2471 } 2472 2472 2473 2473 /** ··· 2485 2485 2486 2486 static inline struct page *dev_alloc_page(void) 2487 2487 { 2488 - return __dev_alloc_page(GFP_ATOMIC); 2488 + return dev_alloc_pages(0); 2489 2489 } 2490 2490 2491 2491 /**
+1 -1
include/net/act_api.h
··· 192 192 #else /* CONFIG_NET_CLS_ACT */ 193 193 194 194 #define tc_no_actions(_exts) true 195 - #define tc_for_each_action(_a, _exts) while (0) 195 + #define tc_for_each_action(_a, _exts) while ((void)(_a), 0) 196 196 #define tcf_action_stats_update(a, bytes, packets, lastuse) 197 197 198 198 #endif /* CONFIG_NET_CLS_ACT */
+5 -5
include/net/fou.h
··· 9 9 #include <net/udp.h> 10 10 11 11 size_t fou_encap_hlen(struct ip_tunnel_encap *e); 12 - static size_t gue_encap_hlen(struct ip_tunnel_encap *e); 12 + size_t gue_encap_hlen(struct ip_tunnel_encap *e); 13 13 14 - int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 15 - u8 *protocol, struct flowi4 *fl4); 16 - int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 17 - u8 *protocol, struct flowi4 *fl4); 14 + int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 15 + u8 *protocol, __be16 *sport, int type); 16 + int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 17 + u8 *protocol, __be16 *sport, int type); 18 18 19 19 #endif
+5
include/net/inet_common.h
··· 39 39 int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, 40 40 int *addr_len); 41 41 42 + struct sk_buff **inet_gro_receive(struct sk_buff **head, struct sk_buff *skb); 43 + int inet_gro_complete(struct sk_buff *skb, int nhoff); 44 + struct sk_buff *inet_gso_segment(struct sk_buff *skb, 45 + netdev_features_t features); 46 + 42 47 static inline void inet_ctl_sock_destroy(struct sock *sk) 43 48 { 44 49 if (sk)
+59 -1
include/net/ip6_tunnel.h
··· 52 52 __u32 o_seqno; /* The last output seqno */ 53 53 int hlen; /* tun_hlen + encap_hlen */ 54 54 int tun_hlen; /* Precalculated header length */ 55 + int encap_hlen; /* Encap header length (FOU,GUE) */ 56 + struct ip_tunnel_encap encap; 55 57 int mlink; 56 - 57 58 }; 59 + 60 + struct ip6_tnl_encap_ops { 61 + size_t (*encap_hlen)(struct ip_tunnel_encap *e); 62 + int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e, 63 + u8 *protocol, struct flowi6 *fl6); 64 + }; 65 + 66 + extern const struct ip6_tnl_encap_ops __rcu * 67 + ip6tun_encaps[MAX_IPTUN_ENCAP_OPS]; 68 + 69 + int ip6_tnl_encap_add_ops(const struct ip6_tnl_encap_ops *ops, 70 + unsigned int num); 71 + int ip6_tnl_encap_del_ops(const struct ip6_tnl_encap_ops *ops, 72 + unsigned int num); 73 + int ip6_tnl_encap_setup(struct ip6_tnl *t, 74 + struct ip_tunnel_encap *ipencap); 75 + 76 + static inline int ip6_encap_hlen(struct ip_tunnel_encap *e) 77 + { 78 + const struct ip6_tnl_encap_ops *ops; 79 + int hlen = -EINVAL; 80 + 81 + if (e->type == TUNNEL_ENCAP_NONE) 82 + return 0; 83 + 84 + if (e->type >= MAX_IPTUN_ENCAP_OPS) 85 + return -EINVAL; 86 + 87 + rcu_read_lock(); 88 + ops = rcu_dereference(ip6tun_encaps[e->type]); 89 + if (likely(ops && ops->encap_hlen)) 90 + hlen = ops->encap_hlen(e); 91 + rcu_read_unlock(); 92 + 93 + return hlen; 94 + } 95 + 96 + static inline int ip6_tnl_encap(struct sk_buff *skb, struct ip6_tnl *t, 97 + u8 *protocol, struct flowi6 *fl6) 98 + { 99 + const struct ip6_tnl_encap_ops *ops; 100 + int ret = -EINVAL; 101 + 102 + if (t->encap.type == TUNNEL_ENCAP_NONE) 103 + return 0; 104 + 105 + if (t->encap.type >= MAX_IPTUN_ENCAP_OPS) 106 + return -EINVAL; 107 + 108 + rcu_read_lock(); 109 + ops = rcu_dereference(ip6tun_encaps[t->encap.type]); 110 + if (likely(ops && ops->build_header)) 111 + ret = ops->build_header(skb, &t->encap, protocol, fl6); 112 + rcu_read_unlock(); 113 + 114 + return ret; 115 + } 58 116 59 117 /* Tunnel encapsulation limit destination sub-option */ 60 118
+58 -18
include/net/ip_tunnels.h
··· 171 171 struct ip_tunnel __rcu *collect_md_tun; 172 172 }; 173 173 174 - struct ip_tunnel_encap_ops { 175 - size_t (*encap_hlen)(struct ip_tunnel_encap *e); 176 - int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e, 177 - u8 *protocol, struct flowi4 *fl4); 178 - }; 179 - 180 - #define MAX_IPTUN_ENCAP_OPS 8 181 - 182 - extern const struct ip_tunnel_encap_ops __rcu * 183 - iptun_encaps[MAX_IPTUN_ENCAP_OPS]; 184 - 185 - int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op, 186 - unsigned int num); 187 - int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op, 188 - unsigned int num); 189 - 190 174 static inline void ip_tunnel_key_init(struct ip_tunnel_key *key, 191 175 __be32 saddr, __be32 daddr, 192 176 u8 tos, u8 ttl, __be32 label, ··· 235 251 void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, 236 252 const struct iphdr *tnl_params, const u8 protocol); 237 253 int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd); 238 - int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, 239 - u8 *protocol, struct flowi4 *fl4); 240 254 int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict); 241 255 int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu); 242 256 ··· 253 271 int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[], 254 272 struct ip_tunnel_parm *p); 255 273 void ip_tunnel_setup(struct net_device *dev, int net_id); 274 + 275 + struct ip_tunnel_encap_ops { 276 + size_t (*encap_hlen)(struct ip_tunnel_encap *e); 277 + int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e, 278 + u8 *protocol, struct flowi4 *fl4); 279 + }; 280 + 281 + #define MAX_IPTUN_ENCAP_OPS 8 282 + 283 + extern const struct ip_tunnel_encap_ops __rcu * 284 + iptun_encaps[MAX_IPTUN_ENCAP_OPS]; 285 + 286 + int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op, 287 + unsigned int num); 288 + int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op, 289 + unsigned int num); 290 + 256 291 int ip_tunnel_encap_setup(struct ip_tunnel *t, 257 292 struct ip_tunnel_encap *ipencap); 293 + 294 + static inline int ip_encap_hlen(struct ip_tunnel_encap *e) 295 + { 296 + const struct ip_tunnel_encap_ops *ops; 297 + int hlen = -EINVAL; 298 + 299 + if (e->type == TUNNEL_ENCAP_NONE) 300 + return 0; 301 + 302 + if (e->type >= MAX_IPTUN_ENCAP_OPS) 303 + return -EINVAL; 304 + 305 + rcu_read_lock(); 306 + ops = rcu_dereference(iptun_encaps[e->type]); 307 + if (likely(ops && ops->encap_hlen)) 308 + hlen = ops->encap_hlen(e); 309 + rcu_read_unlock(); 310 + 311 + return hlen; 312 + } 313 + 314 + static inline int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, 315 + u8 *protocol, struct flowi4 *fl4) 316 + { 317 + const struct ip_tunnel_encap_ops *ops; 318 + int ret = -EINVAL; 319 + 320 + if (t->encap.type == TUNNEL_ENCAP_NONE) 321 + return 0; 322 + 323 + if (t->encap.type >= MAX_IPTUN_ENCAP_OPS) 324 + return -EINVAL; 325 + 326 + rcu_read_lock(); 327 + ops = rcu_dereference(iptun_encaps[t->encap.type]); 328 + if (likely(ops && ops->build_header)) 329 + ret = ops->build_header(skb, &t->encap, protocol, fl4); 330 + rcu_read_unlock(); 331 + 332 + return ret; 333 + } 258 334 259 335 /* Extract dsfield from inner protocol */ 260 336 static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph,
+8 -1
include/net/sock.h
··· 382 382 atomic_t sk_omem_alloc; 383 383 int sk_sndbuf; 384 384 struct sk_buff_head sk_write_queue; 385 + 386 + /* 387 + * Because of non atomicity rules, all 388 + * changes are protected by socket lock. 389 + */ 385 390 kmemcheck_bitfield_begin(flags); 386 - unsigned int sk_shutdown : 2, 391 + unsigned int sk_padding : 2, 387 392 sk_no_check_tx : 1, 388 393 sk_no_check_rx : 1, 389 394 sk_userlocks : 4, ··· 396 391 sk_type : 16; 397 392 #define SK_PROTOCOL_MAX U8_MAX 398 393 kmemcheck_bitfield_end(flags); 394 + 399 395 int sk_wmem_queued; 400 396 gfp_t sk_allocation; 401 397 u32 sk_pacing_rate; /* bytes per second */ ··· 424 418 struct timer_list sk_timer; 425 419 ktime_t sk_stamp; 426 420 u16 sk_tsflags; 421 + u8 sk_shutdown; 427 422 u32 sk_tskey; 428 423 struct socket *sk_socket; 429 424 void *sk_user_data;
+1 -1
include/uapi/linux/libc-compat.h
··· 52 52 #if defined(__GLIBC__) 53 53 54 54 /* Coordinate with glibc net/if.h header. */ 55 - #if defined(_NET_IF_H) 55 + #if defined(_NET_IF_H) && defined(__USE_MISC) 56 56 57 57 /* GLIBC headers included first so don't define anything 58 58 * that would already be defined. */
+2 -2
kernel/bpf/core.c
··· 231 231 hdr->pages = size / PAGE_SIZE; 232 232 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)), 233 233 PAGE_SIZE - sizeof(*hdr)); 234 - start = (prandom_u32() % hole) & ~(alignment - 1); 234 + start = (get_random_int() % hole) & ~(alignment - 1); 235 235 236 236 /* Leave a random number of instructions before BPF code. */ 237 237 *image_ptr = &hdr->image[start]; ··· 251 251 struct bpf_insn *to_buff) 252 252 { 253 253 struct bpf_insn *to = to_buff; 254 - u32 imm_rnd = prandom_u32(); 254 + u32 imm_rnd = get_random_int(); 255 255 s16 off; 256 256 257 257 BUILD_BUG_ON(BPF_REG_AX + 1 != MAX_BPF_JIT_REG);
+1 -1
kernel/bpf/inode.c
··· 357 357 static struct dentry *bpf_mount(struct file_system_type *type, int flags, 358 358 const char *dev_name, void *data) 359 359 { 360 - return mount_ns(type, flags, current->nsproxy->mnt_ns, bpf_fill_super); 360 + return mount_nodev(type, flags, data, bpf_fill_super); 361 361 } 362 362 363 363 static struct file_system_type bpf_fs_type = {
+21 -9
kernel/bpf/verifier.c
··· 683 683 { 684 684 struct reg_state *regs = env->cur_state.regs; 685 685 struct reg_state *reg = &regs[regno]; 686 - int linear_size = (int) reg->range - (int) reg->off; 687 686 688 - if (linear_size < 0 || linear_size >= MAX_PACKET_OFF) { 689 - verbose("verifier bug\n"); 690 - return -EFAULT; 691 - } 692 - if (off < 0 || off + size > linear_size) { 693 - verbose("invalid access to packet, off=%d size=%d, allowed=%d\n", 694 - off, size, linear_size); 687 + off += reg->off; 688 + if (off < 0 || off + size > reg->range) { 689 + verbose("invalid access to packet, off=%d size=%d, R%d(id=%d,off=%d,r=%d)\n", 690 + off, size, regno, reg->id, reg->off, reg->range); 695 691 return -EACCES; 696 692 } 697 693 return 0; ··· 1245 1249 struct reg_state *regs = env->cur_state.regs; 1246 1250 struct reg_state *dst_reg = &regs[insn->dst_reg]; 1247 1251 struct reg_state *src_reg = &regs[insn->src_reg]; 1252 + struct reg_state tmp_reg; 1248 1253 s32 imm; 1249 1254 1250 1255 if (BPF_SRC(insn->code) == BPF_K) { ··· 1268 1271 */ 1269 1272 dst_reg->off += imm; 1270 1273 } else { 1274 + if (src_reg->type == PTR_TO_PACKET) { 1275 + /* R6=pkt(id=0,off=0,r=62) R7=imm22; r7 += r6 */ 1276 + tmp_reg = *dst_reg; /* save r7 state */ 1277 + *dst_reg = *src_reg; /* copy pkt_ptr state r6 into r7 */ 1278 + src_reg = &tmp_reg; /* pretend it's src_reg state */ 1279 + /* if the checks below reject it, the copy won't matter, 1280 + * since we're rejecting the whole program. If all ok, 1281 + * then imm22 state will be added to r7 1282 + * and r7 will be pkt(id=0,off=22,r=62) while 1283 + * r6 will stay as pkt(id=0,off=0,r=62) 1284 + */ 1285 + } 1286 + 1271 1287 if (src_reg->type == CONST_IMM) { 1272 1288 /* pkt_ptr += reg where reg is known constant */ 1273 1289 imm = src_reg->imm; ··· 1579 1569 return 0; 1580 1570 } else if (opcode == BPF_ADD && 1581 1571 BPF_CLASS(insn->code) == BPF_ALU64 && 1582 - dst_reg->type == PTR_TO_PACKET) { 1572 + (dst_reg->type == PTR_TO_PACKET || 1573 + (BPF_SRC(insn->code) == BPF_X && 1574 + regs[insn->src_reg].type == PTR_TO_PACKET))) { 1583 1575 /* ptr_to_packet += K|X */ 1584 1576 return check_packet_ptr_add(env, insn); 1585 1577 } else if (BPF_CLASS(insn->code) == BPF_ALU64 &&
+4 -5
net/batman-adv/bat_iv_ogm.c
··· 157 157 orig_node->bat_iv.bcast_own = data_ptr; 158 158 159 159 data_ptr = kmalloc_array(max_if_num, sizeof(u8), GFP_ATOMIC); 160 - if (!data_ptr) { 161 - kfree(orig_node->bat_iv.bcast_own); 160 + if (!data_ptr) 162 161 goto unlock; 163 - } 164 162 165 163 memcpy(data_ptr, orig_node->bat_iv.bcast_own_sum, 166 164 (max_if_num - 1) * sizeof(u8)); ··· 1180 1182 u8 total_count; 1181 1183 u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own; 1182 1184 unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; 1183 - int tq_asym_penalty, inv_asym_penalty, if_num; 1185 + int if_num; 1186 + unsigned int tq_asym_penalty, inv_asym_penalty; 1184 1187 unsigned int combined_tq; 1185 - int tq_iface_penalty; 1188 + unsigned int tq_iface_penalty; 1186 1189 bool ret = false; 1187 1190 1188 1191 /* find corresponding one hop neighbor */
+58 -8
net/batman-adv/bat_v.c
··· 27 27 #include <linux/rculist.h> 28 28 #include <linux/rcupdate.h> 29 29 #include <linux/seq_file.h> 30 + #include <linux/stddef.h> 30 31 #include <linux/types.h> 31 32 #include <linux/workqueue.h> 32 33 ··· 40 39 41 40 static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface) 42 41 { 42 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 43 + struct batadv_hard_iface *primary_if; 44 + 45 + primary_if = batadv_primary_if_get_selected(bat_priv); 46 + 47 + if (primary_if) { 48 + batadv_v_elp_iface_activate(primary_if, hard_iface); 49 + batadv_hardif_put(primary_if); 50 + } 51 + 43 52 /* B.A.T.M.A.N. V does not use any queuing mechanism, therefore it can 44 53 * set the interface as ACTIVE right away, without any risk of race 45 54 * condition ··· 83 72 batadv_v_elp_iface_disable(hard_iface); 84 73 } 85 74 86 - static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface) 87 - { 88 - } 89 - 90 75 static void batadv_v_primary_iface_set(struct batadv_hard_iface *hard_iface) 91 76 { 92 77 batadv_v_elp_primary_iface_set(hard_iface); 93 78 batadv_v_ogm_primary_iface_set(hard_iface); 79 + } 80 + 81 + /** 82 + * batadv_v_iface_update_mac - react to hard-interface MAC address change 83 + * @hard_iface: the modified interface 84 + * 85 + * If the modified interface is the primary one, update the originator 86 + * address in the ELP and OGM messages to reflect the new MAC address. 87 + */ 88 + static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface) 89 + { 90 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 91 + struct batadv_hard_iface *primary_if; 92 + 93 + primary_if = batadv_primary_if_get_selected(bat_priv); 94 + if (primary_if != hard_iface) 95 + goto out; 96 + 97 + batadv_v_primary_iface_set(hard_iface); 98 + out: 99 + if (primary_if) 100 + batadv_hardif_put(primary_if); 94 101 } 95 102 96 103 static void ··· 284 255 struct batadv_hard_iface *if_outgoing2) 285 256 { 286 257 struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2; 258 + int ret = 0; 287 259 288 260 ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1); 261 + if (WARN_ON(!ifinfo1)) 262 + goto err_ifinfo1; 263 + 289 264 ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2); 265 + if (WARN_ON(!ifinfo2)) 266 + goto err_ifinfo2; 290 267 291 - if (WARN_ON(!ifinfo1 || !ifinfo2)) 292 - return 0; 268 + ret = ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput; 293 269 294 - return ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput; 270 + batadv_neigh_ifinfo_put(ifinfo2); 271 + err_ifinfo2: 272 + batadv_neigh_ifinfo_put(ifinfo1); 273 + err_ifinfo1: 274 + return ret; 295 275 } 296 276 297 277 static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1, ··· 310 272 { 311 273 struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2; 312 274 u32 threshold; 275 + bool ret = false; 313 276 314 277 ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1); 278 + if (WARN_ON(!ifinfo1)) 279 + goto err_ifinfo1; 280 + 315 281 ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2); 282 + if (WARN_ON(!ifinfo2)) 283 + goto err_ifinfo2; 316 284 317 285 threshold = ifinfo1->bat_v.throughput / 4; 318 286 threshold = ifinfo1->bat_v.throughput - threshold; 319 287 320 - return ifinfo2->bat_v.throughput > threshold; 288 + ret = ifinfo2->bat_v.throughput > threshold; 289 + 290 + batadv_neigh_ifinfo_put(ifinfo2); 291 + err_ifinfo2: 292 + batadv_neigh_ifinfo_put(ifinfo1); 293 + err_ifinfo1: 294 + return ret; 321 295 } 322 296 323 297 static struct batadv_algo_ops batadv_batman_v __read_mostly = {
+22 -9
net/batman-adv/bat_v_elp.c
··· 377 377 } 378 378 379 379 /** 380 + * batadv_v_elp_iface_activate - update the ELP buffer belonging to the given 381 + * hard-interface 382 + * @primary_iface: the new primary interface 383 + * @hard_iface: interface holding the to-be-updated buffer 384 + */ 385 + void batadv_v_elp_iface_activate(struct batadv_hard_iface *primary_iface, 386 + struct batadv_hard_iface *hard_iface) 387 + { 388 + struct batadv_elp_packet *elp_packet; 389 + struct sk_buff *skb; 390 + 391 + if (!hard_iface->bat_v.elp_skb) 392 + return; 393 + 394 + skb = hard_iface->bat_v.elp_skb; 395 + elp_packet = (struct batadv_elp_packet *)skb->data; 396 + ether_addr_copy(elp_packet->orig, 397 + primary_iface->net_dev->dev_addr); 398 + } 399 + 400 + /** 380 401 * batadv_v_elp_primary_iface_set - change internal data to reflect the new 381 402 * primary interface 382 403 * @primary_iface: the new primary interface ··· 405 384 void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *primary_iface) 406 385 { 407 386 struct batadv_hard_iface *hard_iface; 408 - struct batadv_elp_packet *elp_packet; 409 - struct sk_buff *skb; 410 387 411 388 /* update orig field of every elp iface belonging to this mesh */ 412 389 rcu_read_lock(); ··· 412 393 if (primary_iface->soft_iface != hard_iface->soft_iface) 413 394 continue; 414 395 415 - if (!hard_iface->bat_v.elp_skb) 416 - continue; 417 - 418 - skb = hard_iface->bat_v.elp_skb; 419 - elp_packet = (struct batadv_elp_packet *)skb->data; 420 - ether_addr_copy(elp_packet->orig, 421 - primary_iface->net_dev->dev_addr); 396 + batadv_v_elp_iface_activate(primary_iface, hard_iface); 422 397 } 423 398 rcu_read_unlock(); 424 399 }
+2
net/batman-adv/bat_v_elp.h
··· 25 25 26 26 int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface); 27 27 void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface); 28 + void batadv_v_elp_iface_activate(struct batadv_hard_iface *primary_iface, 29 + struct batadv_hard_iface *hard_iface); 28 30 void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *primary_iface); 29 31 int batadv_v_elp_packet_recv(struct sk_buff *skb, 30 32 struct batadv_hard_iface *if_incoming);
+4 -2
net/batman-adv/originator.c
··· 619 619 struct batadv_neigh_node *neigh_node; 620 620 struct batadv_hardif_neigh_node *hardif_neigh = NULL; 621 621 622 + spin_lock_bh(&orig_node->neigh_list_lock); 623 + 622 624 neigh_node = batadv_neigh_node_get(orig_node, hard_iface, neigh_addr); 623 625 if (neigh_node) 624 626 goto out; ··· 652 650 kref_init(&neigh_node->refcount); 653 651 kref_get(&neigh_node->refcount); 654 652 655 - spin_lock_bh(&orig_node->neigh_list_lock); 656 653 hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); 657 - spin_unlock_bh(&orig_node->neigh_list_lock); 658 654 659 655 batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, 660 656 "Creating new neighbor %pM for orig_node %pM on interface %s\n", 661 657 neigh_addr, orig_node->orig, hard_iface->net_dev->name); 662 658 663 659 out: 660 + spin_unlock_bh(&orig_node->neigh_list_lock); 661 + 664 662 if (hardif_neigh) 665 663 batadv_hardif_neigh_put(hardif_neigh); 666 664 return neigh_node;
+3 -1
net/batman-adv/routing.c
··· 601 601 struct batadv_unicast_packet *unicast_packet; 602 602 struct ethhdr *ethhdr = eth_hdr(skb); 603 603 int res, hdr_len, ret = NET_RX_DROP; 604 + unsigned int len; 604 605 605 606 unicast_packet = (struct batadv_unicast_packet *)skb->data; 606 607 ··· 642 641 if (hdr_len > 0) 643 642 batadv_skb_set_priority(skb, hdr_len); 644 643 644 + len = skb->len; 645 645 res = batadv_send_skb_to_orig(skb, orig_node, recv_if); 646 646 647 647 /* translate transmit result into receive result */ ··· 650 648 /* skb was transmitted and consumed */ 651 649 batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); 652 650 batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, 653 - skb->len + ETH_HLEN); 651 + len + ETH_HLEN); 654 652 655 653 ret = NET_RX_SUCCESS; 656 654 } else if (res == NET_XMIT_POLICED) {
+2 -2
net/core/ethtool.c
··· 84 84 [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation", 85 85 [NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation", 86 86 [NETIF_F_GSO_GRE_CSUM_BIT] = "tx-gre-csum-segmentation", 87 - [NETIF_F_GSO_IPIP_BIT] = "tx-ipip-segmentation", 88 - [NETIF_F_GSO_SIT_BIT] = "tx-sit-segmentation", 87 + [NETIF_F_GSO_IPXIP4_BIT] = "tx-ipxip4-segmentation", 88 + [NETIF_F_GSO_IPXIP6_BIT] = "tx-ipxip6-segmentation", 89 89 [NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation", 90 90 [NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT] = "tx-udp_tnl-csum-segmentation", 91 91 [NETIF_F_GSO_PARTIAL_BIT] = "tx-gso-partial",
+8 -24
net/ipv4/af_inet.c
··· 1192 1192 } 1193 1193 EXPORT_SYMBOL(inet_sk_rebuild_header); 1194 1194 1195 - static struct sk_buff *inet_gso_segment(struct sk_buff *skb, 1196 - netdev_features_t features) 1195 + struct sk_buff *inet_gso_segment(struct sk_buff *skb, 1196 + netdev_features_t features) 1197 1197 { 1198 1198 bool udpfrag = false, fixedid = false, encap; 1199 1199 struct sk_buff *segs = ERR_PTR(-EINVAL); ··· 1204 1204 int nhoff; 1205 1205 int ihl; 1206 1206 int id; 1207 - 1208 - if (unlikely(skb_shinfo(skb)->gso_type & 1209 - ~(SKB_GSO_TCPV4 | 1210 - SKB_GSO_UDP | 1211 - SKB_GSO_DODGY | 1212 - SKB_GSO_TCP_ECN | 1213 - SKB_GSO_GRE | 1214 - SKB_GSO_GRE_CSUM | 1215 - SKB_GSO_IPIP | 1216 - SKB_GSO_SIT | 1217 - SKB_GSO_TCPV6 | 1218 - SKB_GSO_UDP_TUNNEL | 1219 - SKB_GSO_UDP_TUNNEL_CSUM | 1220 - SKB_GSO_TCP_FIXEDID | 1221 - SKB_GSO_TUNNEL_REMCSUM | 1222 - SKB_GSO_PARTIAL | 1223 - 0))) 1224 - goto out; 1225 1207 1226 1208 skb_reset_network_header(skb); 1227 1209 nhoff = skb_network_header(skb) - skb_mac_header(skb); ··· 1280 1298 out: 1281 1299 return segs; 1282 1300 } 1301 + EXPORT_SYMBOL(inet_gso_segment); 1283 1302 1284 - static struct sk_buff **inet_gro_receive(struct sk_buff **head, 1285 - struct sk_buff *skb) 1303 + struct sk_buff **inet_gro_receive(struct sk_buff **head, struct sk_buff *skb) 1286 1304 { 1287 1305 const struct net_offload *ops; 1288 1306 struct sk_buff **pp = NULL; ··· 1398 1416 1399 1417 return pp; 1400 1418 } 1419 + EXPORT_SYMBOL(inet_gro_receive); 1401 1420 1402 1421 static struct sk_buff **ipip_gro_receive(struct sk_buff **head, 1403 1422 struct sk_buff *skb) ··· 1450 1467 return -EINVAL; 1451 1468 } 1452 1469 1453 - static int inet_gro_complete(struct sk_buff *skb, int nhoff) 1470 + int inet_gro_complete(struct sk_buff *skb, int nhoff) 1454 1471 { 1455 1472 __be16 newlen = htons(skb->len - nhoff); 1456 1473 struct iphdr *iph = (struct iphdr *)(skb->data + nhoff); ··· 1480 1497 1481 1498 return err; 1482 1499 } 1500 + EXPORT_SYMBOL(inet_gro_complete); 1483 1501 1484 1502 static int ipip_gro_complete(struct sk_buff *skb, int nhoff) 1485 1503 { 1486 1504 skb->encapsulation = 1; 1487 - skb_shinfo(skb)->gso_type |= SKB_GSO_IPIP; 1505 + skb_shinfo(skb)->gso_type |= SKB_GSO_IPXIP4; 1488 1506 return inet_gro_complete(skb, nhoff); 1489 1507 } 1490 1508
+88 -56
net/ipv4/fou.c
··· 21 21 u8 protocol; 22 22 u8 flags; 23 23 __be16 port; 24 + u8 family; 24 25 u16 type; 25 26 struct list_head list; 26 27 struct rcu_head rcu; ··· 48 47 return sk->sk_user_data; 49 48 } 50 49 51 - static int fou_recv_pull(struct sk_buff *skb, size_t len) 50 + static int fou_recv_pull(struct sk_buff *skb, struct fou *fou, size_t len) 52 51 { 53 - struct iphdr *iph = ip_hdr(skb); 54 - 55 52 /* Remove 'len' bytes from the packet (UDP header and 56 53 * FOU header if present). 57 54 */ 58 - iph->tot_len = htons(ntohs(iph->tot_len) - len); 55 + if (fou->family == AF_INET) 56 + ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(skb)->tot_len) - len); 57 + else 58 + ipv6_hdr(skb)->payload_len = 59 + htons(ntohs(ipv6_hdr(skb)->payload_len) - len); 60 + 59 61 __skb_pull(skb, len); 60 62 skb_postpull_rcsum(skb, udp_hdr(skb), len); 61 63 skb_reset_transport_header(skb); ··· 72 68 if (!fou) 73 69 return 1; 74 70 75 - if (fou_recv_pull(skb, sizeof(struct udphdr))) 71 + if (fou_recv_pull(skb, fou, sizeof(struct udphdr))) 76 72 goto drop; 77 73 78 74 return -fou->protocol; ··· 145 141 146 142 hdrlen = sizeof(struct guehdr) + optlen; 147 143 148 - ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(skb)->tot_len) - len); 144 + if (fou->family == AF_INET) 145 + ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(skb)->tot_len) - len); 146 + else 147 + ipv6_hdr(skb)->payload_len = 148 + htons(ntohs(ipv6_hdr(skb)->payload_len) - len); 149 149 150 150 /* Pull csum through the guehdr now . This can be used if 151 151 * there is a remote checksum offload. ··· 434 426 435 427 mutex_lock(&fn->fou_lock); 436 428 list_for_each_entry(fout, &fn->fou_list, list) { 437 - if (fou->port == fout->port) { 429 + if (fou->port == fout->port && 430 + fou->family == fout->family) { 438 431 mutex_unlock(&fn->fou_lock); 439 432 return -EALREADY; 440 433 } ··· 457 448 kfree_rcu(fou, rcu); 458 449 } 459 450 460 - static int fou_encap_init(struct sock *sk, struct fou *fou, struct fou_cfg *cfg) 461 - { 462 - udp_sk(sk)->encap_rcv = fou_udp_recv; 463 - udp_sk(sk)->gro_receive = fou_gro_receive; 464 - udp_sk(sk)->gro_complete = fou_gro_complete; 465 - fou_from_sock(sk)->protocol = cfg->protocol; 466 - 467 - return 0; 468 - } 469 - 470 - static int gue_encap_init(struct sock *sk, struct fou *fou, struct fou_cfg *cfg) 471 - { 472 - udp_sk(sk)->encap_rcv = gue_udp_recv; 473 - udp_sk(sk)->gro_receive = gue_gro_receive; 474 - udp_sk(sk)->gro_complete = gue_gro_complete; 475 - 476 - return 0; 477 - } 478 - 479 451 static int fou_create(struct net *net, struct fou_cfg *cfg, 480 452 struct socket **sockp) 481 453 { 482 454 struct socket *sock = NULL; 483 455 struct fou *fou = NULL; 484 456 struct sock *sk; 457 + struct udp_tunnel_sock_cfg tunnel_cfg; 485 458 int err; 486 459 487 460 /* Open UDP socket */ ··· 480 489 481 490 sk = sock->sk; 482 491 483 - fou->flags = cfg->flags; 484 492 fou->port = cfg->udp_config.local_udp_port; 493 + fou->family = cfg->udp_config.family; 494 + fou->flags = cfg->flags; 495 + fou->type = cfg->type; 496 + fou->sock = sock; 497 + 498 + memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); 499 + tunnel_cfg.encap_type = 1; 500 + tunnel_cfg.sk_user_data = fou; 501 + tunnel_cfg.encap_destroy = NULL; 485 502 486 503 /* Initial for fou type */ 487 504 switch (cfg->type) { 488 505 case FOU_ENCAP_DIRECT: 489 - err = fou_encap_init(sk, fou, cfg); 490 - if (err) 491 - goto error; 506 + tunnel_cfg.encap_rcv = fou_udp_recv; 507 + tunnel_cfg.gro_receive = fou_gro_receive; 508 + tunnel_cfg.gro_complete = fou_gro_complete; 509 + fou->protocol = cfg->protocol; 492 510 break; 493 511 case FOU_ENCAP_GUE: 494 - err = gue_encap_init(sk, fou, cfg); 495 - if (err) 496 - goto error; 512 + tunnel_cfg.encap_rcv = gue_udp_recv; 513 + tunnel_cfg.gro_receive = gue_gro_receive; 514 + tunnel_cfg.gro_complete = gue_gro_complete; 497 515 break; 498 516 default: 499 517 err = -EINVAL; 500 518 goto error; 501 519 } 502 520 503 - fou->type = cfg->type; 504 - 505 - udp_sk(sk)->encap_type = 1; 506 - udp_encap_enable(); 507 - 508 - sk->sk_user_data = fou; 509 - fou->sock = sock; 510 - 511 - inet_inc_convert_csum(sk); 521 + setup_udp_tunnel_sock(net, sock, &tunnel_cfg); 512 522 513 523 sk->sk_allocation = GFP_ATOMIC; 514 524 ··· 534 542 { 535 543 struct fou_net *fn = net_generic(net, fou_net_id); 536 544 __be16 port = cfg->udp_config.local_udp_port; 545 + u8 family = cfg->udp_config.family; 537 546 int err = -EINVAL; 538 547 struct fou *fou; 539 548 540 549 mutex_lock(&fn->fou_lock); 541 550 list_for_each_entry(fou, &fn->fou_list, list) { 542 - if (fou->port == port) { 551 + if (fou->port == port && fou->family == family) { 543 552 fou_release(fou); 544 553 err = 0; 545 554 break; ··· 578 585 if (info->attrs[FOU_ATTR_AF]) { 579 586 u8 family = nla_get_u8(info->attrs[FOU_ATTR_AF]); 580 587 581 - if (family != AF_INET) 582 - return -EINVAL; 588 + switch (family) { 589 + case AF_INET: 590 + break; 591 + case AF_INET6: 592 + cfg->udp_config.ipv6_v6only = 1; 593 + break; 594 + default: 595 + return -EAFNOSUPPORT; 596 + } 583 597 584 598 cfg->udp_config.family = family; 585 599 } ··· 677 677 struct fou_cfg cfg; 678 678 struct fou *fout; 679 679 __be16 port; 680 + u8 family; 680 681 int ret; 681 682 682 683 ret = parse_nl_config(info, &cfg); ··· 687 686 if (port == 0) 688 687 return -EINVAL; 689 688 689 + family = cfg.udp_config.family; 690 + if (family != AF_INET && family != AF_INET6) 691 + return -EINVAL; 692 + 690 693 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 691 694 if (!msg) 692 695 return -ENOMEM; ··· 698 693 ret = -ESRCH; 699 694 mutex_lock(&fn->fou_lock); 700 695 list_for_each_entry(fout, &fn->fou_list, list) { 701 - if (port == fout->port) { 696 + if (port == fout->port && family == fout->family) { 702 697 ret = fou_dump_info(fout, info->snd_portid, 703 698 info->snd_seq, 0, msg, 704 699 info->genlhdr->cmd); ··· 803 798 *protocol = IPPROTO_UDP; 804 799 } 805 800 801 + int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 802 + u8 *protocol, __be16 *sport, int type) 803 + { 804 + int err; 805 + 806 + err = iptunnel_handle_offloads(skb, type); 807 + if (err) 808 + return err; 809 + 810 + *sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), 811 + skb, 0, 0, false); 812 + 813 + return 0; 814 + } 815 + EXPORT_SYMBOL(__fou_build_header); 816 + 806 817 int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 807 818 u8 *protocol, struct flowi4 *fl4) 808 819 { ··· 827 806 __be16 sport; 828 807 int err; 829 808 830 - err = iptunnel_handle_offloads(skb, type); 809 + err = __fou_build_header(skb, e, protocol, &sport, type); 831 810 if (err) 832 811 return err; 833 812 834 - sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), 835 - skb, 0, 0, false); 836 813 fou_build_udp(skb, e, fl4, protocol, sport); 837 814 838 815 return 0; 839 816 } 840 817 EXPORT_SYMBOL(fou_build_header); 841 818 842 - int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 843 - u8 *protocol, struct flowi4 *fl4) 819 + int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 820 + u8 *protocol, __be16 *sport, int type) 844 821 { 845 - int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM : 846 - SKB_GSO_UDP_TUNNEL; 847 822 struct guehdr *guehdr; 848 823 size_t hdrlen, optlen = 0; 849 - __be16 sport; 850 824 void *data; 851 825 bool need_priv = false; 852 826 int err; ··· 860 844 return err; 861 845 862 846 /* Get source port (based on flow hash) before skb_push */ 863 - sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), 864 - skb, 0, 0, false); 847 + *sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), 848 + skb, 0, 0, false); 865 849 866 850 hdrlen = sizeof(struct guehdr) + optlen; 867 851 ··· 905 889 } 906 890 907 891 } 892 + 893 + return 0; 894 + } 895 + EXPORT_SYMBOL(__gue_build_header); 896 + 897 + int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 898 + u8 *protocol, struct flowi4 *fl4) 899 + { 900 + int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM : 901 + SKB_GSO_UDP_TUNNEL; 902 + __be16 sport; 903 + int err; 904 + 905 + err = __gue_build_header(skb, e, protocol, &sport, type); 906 + if (err) 907 + return err; 908 908 909 909 fou_build_udp(skb, e, fl4, protocol, sport); 910 910
-14
net/ipv4/gre_offload.c
··· 26 26 int gre_offset, outer_hlen; 27 27 bool need_csum, ufo; 28 28 29 - if (unlikely(skb_shinfo(skb)->gso_type & 30 - ~(SKB_GSO_TCPV4 | 31 - SKB_GSO_TCPV6 | 32 - SKB_GSO_UDP | 33 - SKB_GSO_DODGY | 34 - SKB_GSO_TCP_ECN | 35 - SKB_GSO_TCP_FIXEDID | 36 - SKB_GSO_GRE | 37 - SKB_GSO_GRE_CSUM | 38 - SKB_GSO_IPIP | 39 - SKB_GSO_SIT | 40 - SKB_GSO_PARTIAL))) 41 - goto out; 42 - 43 29 if (!skb->encapsulation) 44 30 goto out; 45 31
-45
net/ipv4/ip_tunnel.c
··· 443 443 } 444 444 EXPORT_SYMBOL_GPL(ip_tunnel_rcv); 445 445 446 - static int ip_encap_hlen(struct ip_tunnel_encap *e) 447 - { 448 - const struct ip_tunnel_encap_ops *ops; 449 - int hlen = -EINVAL; 450 - 451 - if (e->type == TUNNEL_ENCAP_NONE) 452 - return 0; 453 - 454 - if (e->type >= MAX_IPTUN_ENCAP_OPS) 455 - return -EINVAL; 456 - 457 - rcu_read_lock(); 458 - ops = rcu_dereference(iptun_encaps[e->type]); 459 - if (likely(ops && ops->encap_hlen)) 460 - hlen = ops->encap_hlen(e); 461 - rcu_read_unlock(); 462 - 463 - return hlen; 464 - } 465 - 466 - const struct ip_tunnel_encap_ops __rcu * 467 - iptun_encaps[MAX_IPTUN_ENCAP_OPS] __read_mostly; 468 - 469 446 int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *ops, 470 447 unsigned int num) 471 448 { ··· 495 518 return 0; 496 519 } 497 520 EXPORT_SYMBOL_GPL(ip_tunnel_encap_setup); 498 - 499 - int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, 500 - u8 *protocol, struct flowi4 *fl4) 501 - { 502 - const struct ip_tunnel_encap_ops *ops; 503 - int ret = -EINVAL; 504 - 505 - if (t->encap.type == TUNNEL_ENCAP_NONE) 506 - return 0; 507 - 508 - if (t->encap.type >= MAX_IPTUN_ENCAP_OPS) 509 - return -EINVAL; 510 - 511 - rcu_read_lock(); 512 - ops = rcu_dereference(iptun_encaps[t->encap.type]); 513 - if (likely(ops && ops->build_header)) 514 - ret = ops->build_header(skb, &t->encap, protocol, fl4); 515 - rcu_read_unlock(); 516 - 517 - return ret; 518 - } 519 - EXPORT_SYMBOL(ip_tunnel_encap); 520 521 521 522 static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb, 522 523 struct rtable *rt, __be16 df,
+9
net/ipv4/ip_tunnel_core.c
··· 37 37 #include <net/icmp.h> 38 38 #include <net/protocol.h> 39 39 #include <net/ip_tunnels.h> 40 + #include <net/ip6_tunnel.h> 40 41 #include <net/arp.h> 41 42 #include <net/checksum.h> 42 43 #include <net/dsfield.h> ··· 47 46 #include <net/netns/generic.h> 48 47 #include <net/rtnetlink.h> 49 48 #include <net/dst_metadata.h> 49 + 50 + const struct ip_tunnel_encap_ops __rcu * 51 + iptun_encaps[MAX_IPTUN_ENCAP_OPS] __read_mostly; 52 + EXPORT_SYMBOL(iptun_encaps); 53 + 54 + const struct ip6_tnl_encap_ops __rcu * 55 + ip6tun_encaps[MAX_IPTUN_ENCAP_OPS] __read_mostly; 56 + EXPORT_SYMBOL(ip6tun_encaps); 50 57 51 58 void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, 52 59 __be32 src, __be32 dst, __u8 proto,
+1 -1
net/ipv4/ipip.c
··· 219 219 if (unlikely(skb->protocol != htons(ETH_P_IP))) 220 220 goto tx_error; 221 221 222 - if (iptunnel_handle_offloads(skb, SKB_GSO_IPIP)) 222 + if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4)) 223 223 goto tx_error; 224 224 225 225 skb_set_inner_ipproto(skb, IPPROTO_IPIP);
-19
net/ipv4/tcp_offload.c
··· 83 83 84 84 if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) { 85 85 /* Packet is from an untrusted source, reset gso_segs. */ 86 - int type = skb_shinfo(skb)->gso_type; 87 - 88 - if (unlikely(type & 89 - ~(SKB_GSO_TCPV4 | 90 - SKB_GSO_DODGY | 91 - SKB_GSO_TCP_ECN | 92 - SKB_GSO_TCP_FIXEDID | 93 - SKB_GSO_TCPV6 | 94 - SKB_GSO_GRE | 95 - SKB_GSO_GRE_CSUM | 96 - SKB_GSO_IPIP | 97 - SKB_GSO_SIT | 98 - SKB_GSO_UDP_TUNNEL | 99 - SKB_GSO_UDP_TUNNEL_CSUM | 100 - SKB_GSO_TUNNEL_REMCSUM | 101 - 0) || 102 - !(type & (SKB_GSO_TCPV4 | 103 - SKB_GSO_TCPV6)))) 104 - goto out; 105 86 106 87 skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss); 107 88
+1 -1
net/ipv4/udp.c
··· 1565 1565 1566 1566 /* if we're overly short, let UDP handle it */ 1567 1567 encap_rcv = ACCESS_ONCE(up->encap_rcv); 1568 - if (skb->len > sizeof(struct udphdr) && encap_rcv) { 1568 + if (encap_rcv) { 1569 1569 int ret; 1570 1570 1571 1571 /* Verify checksum before giving to encap */
-10
net/ipv4/udp_offload.c
··· 209 209 210 210 if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) { 211 211 /* Packet is from an untrusted source, reset gso_segs. */ 212 - int type = skb_shinfo(skb)->gso_type; 213 - 214 - if (unlikely(type & ~(SKB_GSO_UDP | SKB_GSO_DODGY | 215 - SKB_GSO_UDP_TUNNEL | 216 - SKB_GSO_UDP_TUNNEL_CSUM | 217 - SKB_GSO_TUNNEL_REMCSUM | 218 - SKB_GSO_IPIP | 219 - SKB_GSO_GRE | SKB_GSO_GRE_CSUM) || 220 - !(type & (SKB_GSO_UDP)))) 221 - goto out; 222 212 223 213 skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss); 224 214
+1
net/ipv6/Makefile
··· 42 42 obj-$(CONFIG_IPV6_SIT) += sit.o 43 43 obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o 44 44 obj-$(CONFIG_IPV6_GRE) += ip6_gre.o 45 + obj-$(CONFIG_NET_FOU) += fou6.o 45 46 46 47 obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o 47 48 obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
+140
net/ipv6/fou6.c
··· 1 + #include <linux/module.h> 2 + #include <linux/errno.h> 3 + #include <linux/socket.h> 4 + #include <linux/skbuff.h> 5 + #include <linux/ip.h> 6 + #include <linux/udp.h> 7 + #include <linux/types.h> 8 + #include <linux/kernel.h> 9 + #include <net/fou.h> 10 + #include <net/ip.h> 11 + #include <net/ip6_tunnel.h> 12 + #include <net/ip6_checksum.h> 13 + #include <net/protocol.h> 14 + #include <net/udp.h> 15 + #include <net/udp_tunnel.h> 16 + 17 + static void fou6_build_udp(struct sk_buff *skb, struct ip_tunnel_encap *e, 18 + struct flowi6 *fl6, u8 *protocol, __be16 sport) 19 + { 20 + struct udphdr *uh; 21 + 22 + skb_push(skb, sizeof(struct udphdr)); 23 + skb_reset_transport_header(skb); 24 + 25 + uh = udp_hdr(skb); 26 + 27 + uh->dest = e->dport; 28 + uh->source = sport; 29 + uh->len = htons(skb->len); 30 + udp6_set_csum(!(e->flags & TUNNEL_ENCAP_FLAG_CSUM6), skb, 31 + &fl6->saddr, &fl6->daddr, skb->len); 32 + 33 + *protocol = IPPROTO_UDP; 34 + } 35 + 36 + int fou6_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 37 + u8 *protocol, struct flowi6 *fl6) 38 + { 39 + __be16 sport; 40 + int err; 41 + int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM6 ? 42 + SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL; 43 + 44 + err = __fou_build_header(skb, e, protocol, &sport, type); 45 + if (err) 46 + return err; 47 + 48 + fou6_build_udp(skb, e, fl6, protocol, sport); 49 + 50 + return 0; 51 + } 52 + EXPORT_SYMBOL(fou6_build_header); 53 + 54 + int gue6_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, 55 + u8 *protocol, struct flowi6 *fl6) 56 + { 57 + __be16 sport; 58 + int err; 59 + int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM6 ? 60 + SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL; 61 + 62 + err = __gue_build_header(skb, e, protocol, &sport, type); 63 + if (err) 64 + return err; 65 + 66 + fou6_build_udp(skb, e, fl6, protocol, sport); 67 + 68 + return 0; 69 + } 70 + EXPORT_SYMBOL(gue6_build_header); 71 + 72 + #ifdef CONFIG_NET_FOU_IP_TUNNELS 73 + 74 + static const struct ip6_tnl_encap_ops fou_ip6tun_ops = { 75 + .encap_hlen = fou_encap_hlen, 76 + .build_header = fou6_build_header, 77 + }; 78 + 79 + static const struct ip6_tnl_encap_ops gue_ip6tun_ops = { 80 + .encap_hlen = gue_encap_hlen, 81 + .build_header = gue6_build_header, 82 + }; 83 + 84 + static int ip6_tnl_encap_add_fou_ops(void) 85 + { 86 + int ret; 87 + 88 + ret = ip6_tnl_encap_add_ops(&fou_ip6tun_ops, TUNNEL_ENCAP_FOU); 89 + if (ret < 0) { 90 + pr_err("can't add fou6 ops\n"); 91 + return ret; 92 + } 93 + 94 + ret = ip6_tnl_encap_add_ops(&gue_ip6tun_ops, TUNNEL_ENCAP_GUE); 95 + if (ret < 0) { 96 + pr_err("can't add gue6 ops\n"); 97 + ip6_tnl_encap_del_ops(&fou_ip6tun_ops, TUNNEL_ENCAP_FOU); 98 + return ret; 99 + } 100 + 101 + return 0; 102 + } 103 + 104 + static void ip6_tnl_encap_del_fou_ops(void) 105 + { 106 + ip6_tnl_encap_del_ops(&fou_ip6tun_ops, TUNNEL_ENCAP_FOU); 107 + ip6_tnl_encap_del_ops(&gue_ip6tun_ops, TUNNEL_ENCAP_GUE); 108 + } 109 + 110 + #else 111 + 112 + static int ip6_tnl_encap_add_fou_ops(void) 113 + { 114 + return 0; 115 + } 116 + 117 + static void ip6_tnl_encap_del_fou_ops(void) 118 + { 119 + } 120 + 121 + #endif 122 + 123 + static int __init fou6_init(void) 124 + { 125 + int ret; 126 + 127 + ret = ip6_tnl_encap_add_fou_ops(); 128 + 129 + return ret; 130 + } 131 + 132 + static void __exit fou6_fini(void) 133 + { 134 + ip6_tnl_encap_del_fou_ops(); 135 + } 136 + 137 + module_init(fou6_init); 138 + module_exit(fou6_fini); 139 + MODULE_AUTHOR("Tom Herbert <therbert@google.com>"); 140 + MODULE_LICENSE("GPL");
+83 -8
net/ipv6/ip6_gre.c
··· 729 729 730 730 t->tun_hlen = gre_calc_hlen(t->parms.o_flags); 731 731 732 - t->hlen = t->tun_hlen; 732 + t->hlen = t->encap_hlen + t->tun_hlen; 733 733 734 734 t_hlen = t->hlen + sizeof(struct ipv6hdr); 735 735 ··· 1022 1022 } 1023 1023 1024 1024 tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags); 1025 - 1026 - tunnel->hlen = tunnel->tun_hlen; 1027 - 1025 + tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen; 1028 1026 t_hlen = tunnel->hlen + sizeof(struct ipv6hdr); 1029 1027 1030 1028 dev->hard_header_len = LL_MAX_HEADER + t_hlen; ··· 1288 1290 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 1289 1291 } 1290 1292 1293 + static bool ip6gre_netlink_encap_parms(struct nlattr *data[], 1294 + struct ip_tunnel_encap *ipencap) 1295 + { 1296 + bool ret = false; 1297 + 1298 + memset(ipencap, 0, sizeof(*ipencap)); 1299 + 1300 + if (!data) 1301 + return ret; 1302 + 1303 + if (data[IFLA_GRE_ENCAP_TYPE]) { 1304 + ret = true; 1305 + ipencap->type = nla_get_u16(data[IFLA_GRE_ENCAP_TYPE]); 1306 + } 1307 + 1308 + if (data[IFLA_GRE_ENCAP_FLAGS]) { 1309 + ret = true; 1310 + ipencap->flags = nla_get_u16(data[IFLA_GRE_ENCAP_FLAGS]); 1311 + } 1312 + 1313 + if (data[IFLA_GRE_ENCAP_SPORT]) { 1314 + ret = true; 1315 + ipencap->sport = nla_get_be16(data[IFLA_GRE_ENCAP_SPORT]); 1316 + } 1317 + 1318 + if (data[IFLA_GRE_ENCAP_DPORT]) { 1319 + ret = true; 1320 + ipencap->dport = nla_get_be16(data[IFLA_GRE_ENCAP_DPORT]); 1321 + } 1322 + 1323 + return ret; 1324 + } 1325 + 1291 1326 static int ip6gre_newlink(struct net *src_net, struct net_device *dev, 1292 1327 struct nlattr *tb[], struct nlattr *data[]) 1293 1328 { 1294 1329 struct ip6_tnl *nt; 1295 1330 struct net *net = dev_net(dev); 1296 1331 struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); 1332 + struct ip_tunnel_encap ipencap; 1297 1333 int err; 1298 1334 1299 1335 nt = netdev_priv(dev); 1336 + 1337 + if (ip6gre_netlink_encap_parms(data, &ipencap)) { 1338 + int err = ip6_tnl_encap_setup(nt, &ipencap); 1339 + 1340 + if (err < 0) 1341 + return err; 1342 + } 1343 + 1300 1344 ip6gre_netlink_parms(data, &nt->parms); 1301 1345 1302 1346 if (ip6gre_tunnel_find(net, &nt->parms, dev->type)) ··· 1355 1315 dev->hw_features |= GRE6_FEATURES; 1356 1316 1357 1317 if (!(nt->parms.o_flags & TUNNEL_SEQ)) { 1358 - /* TCP segmentation offload is not supported when we 1359 - * generate output sequences. 1318 + /* TCP offload with GRE SEQ is not supported, nor 1319 + * can we support 2 levels of outer headers requiring 1320 + * an update. 1360 1321 */ 1361 - dev->features |= NETIF_F_GSO_SOFTWARE; 1362 - dev->hw_features |= NETIF_F_GSO_SOFTWARE; 1322 + if (!(nt->parms.o_flags & TUNNEL_CSUM) || 1323 + (nt->encap.type == TUNNEL_ENCAP_NONE)) { 1324 + dev->features |= NETIF_F_GSO_SOFTWARE; 1325 + dev->hw_features |= NETIF_F_GSO_SOFTWARE; 1326 + } 1363 1327 1364 1328 /* Can use a lockless transmit, unless we generate 1365 1329 * output sequences ··· 1389 1345 struct net *net = nt->net; 1390 1346 struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); 1391 1347 struct __ip6_tnl_parm p; 1348 + struct ip_tunnel_encap ipencap; 1392 1349 1393 1350 if (dev == ign->fb_tunnel_dev) 1394 1351 return -EINVAL; 1352 + 1353 + if (ip6gre_netlink_encap_parms(data, &ipencap)) { 1354 + int err = ip6_tnl_encap_setup(nt, &ipencap); 1355 + 1356 + if (err < 0) 1357 + return err; 1358 + } 1395 1359 1396 1360 ip6gre_netlink_parms(data, &p); 1397 1361 ··· 1452 1400 nla_total_size(4) + 1453 1401 /* IFLA_GRE_FLAGS */ 1454 1402 nla_total_size(4) + 1403 + /* IFLA_GRE_ENCAP_TYPE */ 1404 + nla_total_size(2) + 1405 + /* IFLA_GRE_ENCAP_FLAGS */ 1406 + nla_total_size(2) + 1407 + /* IFLA_GRE_ENCAP_SPORT */ 1408 + nla_total_size(2) + 1409 + /* IFLA_GRE_ENCAP_DPORT */ 1410 + nla_total_size(2) + 1455 1411 0; 1456 1412 } 1457 1413 ··· 1482 1422 nla_put_be32(skb, IFLA_GRE_FLOWINFO, p->flowinfo) || 1483 1423 nla_put_u32(skb, IFLA_GRE_FLAGS, p->flags)) 1484 1424 goto nla_put_failure; 1425 + 1426 + if (nla_put_u16(skb, IFLA_GRE_ENCAP_TYPE, 1427 + t->encap.type) || 1428 + nla_put_be16(skb, IFLA_GRE_ENCAP_SPORT, 1429 + t->encap.sport) || 1430 + nla_put_be16(skb, IFLA_GRE_ENCAP_DPORT, 1431 + t->encap.dport) || 1432 + nla_put_u16(skb, IFLA_GRE_ENCAP_FLAGS, 1433 + t->encap.flags)) 1434 + goto nla_put_failure; 1435 + 1485 1436 return 0; 1486 1437 1487 1438 nla_put_failure: ··· 1511 1440 [IFLA_GRE_ENCAP_LIMIT] = { .type = NLA_U8 }, 1512 1441 [IFLA_GRE_FLOWINFO] = { .type = NLA_U32 }, 1513 1442 [IFLA_GRE_FLAGS] = { .type = NLA_U32 }, 1443 + [IFLA_GRE_ENCAP_TYPE] = { .type = NLA_U16 }, 1444 + [IFLA_GRE_ENCAP_FLAGS] = { .type = NLA_U16 }, 1445 + [IFLA_GRE_ENCAP_SPORT] = { .type = NLA_U16 }, 1446 + [IFLA_GRE_ENCAP_DPORT] = { .type = NLA_U16 }, 1514 1447 }; 1515 1448 1516 1449 static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
+29 -4
net/ipv6/ip6_input.c
··· 223 223 unsigned int nhoff; 224 224 int nexthdr; 225 225 bool raw; 226 + bool have_final = false; 226 227 227 228 /* 228 229 * Parse extension headers ··· 237 236 nhoff = IP6CB(skb)->nhoff; 238 237 nexthdr = skb_network_header(skb)[nhoff]; 239 238 239 + resubmit_final: 240 240 raw = raw6_local_deliver(skb, nexthdr); 241 241 ipprot = rcu_dereference(inet6_protos[nexthdr]); 242 242 if (ipprot) { 243 243 int ret; 244 244 245 - if (ipprot->flags & INET6_PROTO_FINAL) { 245 + if (have_final) { 246 + if (!(ipprot->flags & INET6_PROTO_FINAL)) { 247 + /* Once we've seen a final protocol don't 248 + * allow encapsulation on any non-final 249 + * ones. This allows foo in UDP encapsulation 250 + * to work. 251 + */ 252 + goto discard; 253 + } 254 + } else if (ipprot->flags & INET6_PROTO_FINAL) { 246 255 const struct ipv6hdr *hdr; 256 + 257 + /* Only do this once for first final protocol */ 258 + have_final = true; 247 259 248 260 /* Free reference early: we don't need it any more, 249 261 and it may hold ip_conntrack module loaded ··· 277 263 goto discard; 278 264 279 265 ret = ipprot->handler(skb); 280 - if (ret > 0) 281 - goto resubmit; 282 - else if (ret == 0) 266 + if (ret > 0) { 267 + if (ipprot->flags & INET6_PROTO_FINAL) { 268 + /* Not an extension header, most likely UDP 269 + * encapsulation. Use return value as nexthdr 270 + * protocol not nhoff (which presumably is 271 + * not set by handler). 272 + */ 273 + nexthdr = ret; 274 + goto resubmit_final; 275 + } else { 276 + goto resubmit; 277 + } 278 + } else if (ret == 0) { 283 279 __IP6_INC_STATS(net, idev, IPSTATS_MIB_INDELIVERS); 280 + } 284 281 } else { 285 282 if (!raw) { 286 283 if (xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+54 -23
net/ipv6/ip6_offload.c
··· 16 16 17 17 #include <net/protocol.h> 18 18 #include <net/ipv6.h> 19 + #include <net/inet_common.h> 19 20 20 21 #include "ip6_offload.h" 21 22 ··· 70 69 bool encap, udpfrag; 71 70 int nhoff; 72 71 73 - if (unlikely(skb_shinfo(skb)->gso_type & 74 - ~(SKB_GSO_TCPV4 | 75 - SKB_GSO_UDP | 76 - SKB_GSO_DODGY | 77 - SKB_GSO_TCP_ECN | 78 - SKB_GSO_TCP_FIXEDID | 79 - SKB_GSO_TCPV6 | 80 - SKB_GSO_GRE | 81 - SKB_GSO_GRE_CSUM | 82 - SKB_GSO_IPIP | 83 - SKB_GSO_SIT | 84 - SKB_GSO_UDP_TUNNEL | 85 - SKB_GSO_UDP_TUNNEL_CSUM | 86 - SKB_GSO_TUNNEL_REMCSUM | 87 - SKB_GSO_PARTIAL | 88 - 0))) 89 - goto out; 90 - 91 72 skb_reset_network_header(skb); 92 73 nhoff = skb_network_header(skb) - skb_mac_header(skb); 93 74 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) ··· 87 104 proto = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr); 88 105 89 106 if (skb->encapsulation && 90 - skb_shinfo(skb)->gso_type & (SKB_GSO_SIT|SKB_GSO_IPIP)) 107 + skb_shinfo(skb)->gso_type & (SKB_GSO_IPXIP4 | SKB_GSO_IPXIP6)) 91 108 udpfrag = proto == IPPROTO_UDP && encap; 92 109 else 93 110 udpfrag = proto == IPPROTO_UDP && !skb->encapsulation; ··· 254 271 return pp; 255 272 } 256 273 257 - static struct sk_buff **sit_gro_receive(struct sk_buff **head, 258 - struct sk_buff *skb) 274 + static struct sk_buff **sit_ip6ip6_gro_receive(struct sk_buff **head, 275 + struct sk_buff *skb) 259 276 { 277 + /* Common GRO receive for SIT and IP6IP6 */ 278 + 260 279 if (NAPI_GRO_CB(skb)->encap_mark) { 261 280 NAPI_GRO_CB(skb)->flush = 1; 262 281 return NULL; ··· 267 282 NAPI_GRO_CB(skb)->encap_mark = 1; 268 283 269 284 return ipv6_gro_receive(head, skb); 285 + } 286 + 287 + static struct sk_buff **ip4ip6_gro_receive(struct sk_buff **head, 288 + struct sk_buff *skb) 289 + { 290 + /* Common GRO receive for SIT and IP6IP6 */ 291 + 292 + if (NAPI_GRO_CB(skb)->encap_mark) { 293 + NAPI_GRO_CB(skb)->flush = 1; 294 + return NULL; 295 + } 296 + 297 + NAPI_GRO_CB(skb)->encap_mark = 1; 298 + 299 + return inet_gro_receive(head, skb); 270 300 } 271 301 272 302 static int ipv6_gro_complete(struct sk_buff *skb, int nhoff) ··· 312 312 static int sit_gro_complete(struct sk_buff *skb, int nhoff) 313 313 { 314 314 skb->encapsulation = 1; 315 - skb_shinfo(skb)->gso_type |= SKB_GSO_SIT; 315 + skb_shinfo(skb)->gso_type |= SKB_GSO_IPXIP4; 316 316 return ipv6_gro_complete(skb, nhoff); 317 + } 318 + 319 + static int ip6ip6_gro_complete(struct sk_buff *skb, int nhoff) 320 + { 321 + skb->encapsulation = 1; 322 + skb_shinfo(skb)->gso_type |= SKB_GSO_IPXIP6; 323 + return ipv6_gro_complete(skb, nhoff); 324 + } 325 + 326 + static int ip4ip6_gro_complete(struct sk_buff *skb, int nhoff) 327 + { 328 + skb->encapsulation = 1; 329 + skb_shinfo(skb)->gso_type |= SKB_GSO_IPXIP6; 330 + return inet_gro_complete(skb, nhoff); 317 331 } 318 332 319 333 static struct packet_offload ipv6_packet_offload __read_mostly = { ··· 342 328 static const struct net_offload sit_offload = { 343 329 .callbacks = { 344 330 .gso_segment = ipv6_gso_segment, 345 - .gro_receive = sit_gro_receive, 331 + .gro_receive = sit_ip6ip6_gro_receive, 346 332 .gro_complete = sit_gro_complete, 347 333 }, 348 334 }; 349 335 336 + static const struct net_offload ip4ip6_offload = { 337 + .callbacks = { 338 + .gso_segment = inet_gso_segment, 339 + .gro_receive = ip4ip6_gro_receive, 340 + .gro_complete = ip4ip6_gro_complete, 341 + }, 342 + }; 343 + 344 + static const struct net_offload ip6ip6_offload = { 345 + .callbacks = { 346 + .gso_segment = ipv6_gso_segment, 347 + .gro_receive = sit_ip6ip6_gro_receive, 348 + .gro_complete = ip6ip6_gro_complete, 349 + }, 350 + }; 350 351 static int __init ipv6_offload_init(void) 351 352 { 352 353 ··· 373 344 dev_add_offload(&ipv6_packet_offload); 374 345 375 346 inet_add_offload(&sit_offload, IPPROTO_IPV6); 347 + inet6_add_offload(&ip6ip6_offload, IPPROTO_IPV6); 348 + inet6_add_offload(&ip4ip6_offload, IPPROTO_IPIP); 376 349 377 350 return 0; 378 351 }
+172 -18
net/ipv6/ip6_tunnel.c
··· 1010 1010 struct dst_entry *dst = NULL, *ndst = NULL; 1011 1011 struct net_device *tdev; 1012 1012 int mtu; 1013 - unsigned int max_headroom = sizeof(struct ipv6hdr); 1013 + unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen; 1014 + unsigned int max_headroom = psh_hlen; 1014 1015 int err = -1; 1015 1016 1016 1017 /* NBMA tunnel */ ··· 1064 1063 t->parms.name); 1065 1064 goto tx_err_dst_release; 1066 1065 } 1067 - mtu = dst_mtu(dst) - sizeof(*ipv6h); 1066 + mtu = dst_mtu(dst) - psh_hlen; 1068 1067 if (encap_limit >= 0) { 1069 1068 max_headroom += 8; 1070 1069 mtu -= 8; ··· 1120 1119 ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL); 1121 1120 } 1122 1121 1123 - if (likely(!skb->encapsulation)) { 1124 - skb_reset_inner_headers(skb); 1125 - skb->encapsulation = 1; 1126 - } 1127 - 1122 + /* Calculate max headroom for all the headers and adjust 1123 + * needed_headroom if necessary. 1124 + */ 1128 1125 max_headroom = LL_RESERVED_SPACE(dst->dev) + sizeof(struct ipv6hdr) 1129 - + dst->header_len; 1126 + + dst->header_len + t->hlen; 1130 1127 if (max_headroom > dev->needed_headroom) 1131 1128 dev->needed_headroom = max_headroom; 1129 + 1130 + err = ip6_tnl_encap(skb, t, &proto, fl6); 1131 + if (err) 1132 + return err; 1132 1133 1133 1134 skb_push(skb, sizeof(struct ipv6hdr)); 1134 1135 skb_reset_network_header(skb); ··· 1182 1179 & IPV6_TCLASS_MASK; 1183 1180 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK) 1184 1181 fl6.flowi6_mark = skb->mark; 1182 + 1183 + if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6)) 1184 + return -1; 1185 + 1186 + skb_set_inner_ipproto(skb, IPPROTO_IPIP); 1185 1187 1186 1188 err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, 1187 1189 IPPROTO_IPIP); ··· 1242 1234 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK) 1243 1235 fl6.flowi6_mark = skb->mark; 1244 1236 1237 + if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6)) 1238 + return -1; 1239 + 1240 + skb_set_inner_ipproto(skb, IPPROTO_IPV6); 1241 + 1245 1242 err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, 1246 1243 IPPROTO_IPV6); 1247 1244 if (err != 0) { ··· 1293 1280 struct net_device *dev = t->dev; 1294 1281 struct __ip6_tnl_parm *p = &t->parms; 1295 1282 struct flowi6 *fl6 = &t->fl.u.ip6; 1283 + int t_hlen; 1296 1284 1297 1285 memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); 1298 1286 memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr)); ··· 1317 1303 else 1318 1304 dev->flags &= ~IFF_POINTOPOINT; 1319 1305 1306 + t->tun_hlen = 0; 1307 + t->hlen = t->encap_hlen + t->tun_hlen; 1308 + t_hlen = t->hlen + sizeof(struct ipv6hdr); 1309 + 1320 1310 if (p->flags & IP6_TNL_F_CAP_XMIT) { 1321 1311 int strict = (ipv6_addr_type(&p->raddr) & 1322 1312 (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL)); ··· 1334 1316 1335 1317 if (rt->dst.dev) { 1336 1318 dev->hard_header_len = rt->dst.dev->hard_header_len + 1337 - sizeof(struct ipv6hdr); 1319 + t_hlen; 1338 1320 1339 - dev->mtu = rt->dst.dev->mtu - sizeof(struct ipv6hdr); 1321 + dev->mtu = rt->dst.dev->mtu - t_hlen; 1340 1322 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) 1341 1323 dev->mtu -= 8; 1342 1324 ··· 1582 1564 } 1583 1565 EXPORT_SYMBOL(ip6_tnl_get_iflink); 1584 1566 1567 + int ip6_tnl_encap_add_ops(const struct ip6_tnl_encap_ops *ops, 1568 + unsigned int num) 1569 + { 1570 + if (num >= MAX_IPTUN_ENCAP_OPS) 1571 + return -ERANGE; 1572 + 1573 + return !cmpxchg((const struct ip6_tnl_encap_ops **) 1574 + &ip6tun_encaps[num], 1575 + NULL, ops) ? 0 : -1; 1576 + } 1577 + EXPORT_SYMBOL(ip6_tnl_encap_add_ops); 1578 + 1579 + int ip6_tnl_encap_del_ops(const struct ip6_tnl_encap_ops *ops, 1580 + unsigned int num) 1581 + { 1582 + int ret; 1583 + 1584 + if (num >= MAX_IPTUN_ENCAP_OPS) 1585 + return -ERANGE; 1586 + 1587 + ret = (cmpxchg((const struct ip6_tnl_encap_ops **) 1588 + &ip6tun_encaps[num], 1589 + ops, NULL) == ops) ? 0 : -1; 1590 + 1591 + synchronize_net(); 1592 + 1593 + return ret; 1594 + } 1595 + EXPORT_SYMBOL(ip6_tnl_encap_del_ops); 1596 + 1597 + int ip6_tnl_encap_setup(struct ip6_tnl *t, 1598 + struct ip_tunnel_encap *ipencap) 1599 + { 1600 + int hlen; 1601 + 1602 + memset(&t->encap, 0, sizeof(t->encap)); 1603 + 1604 + hlen = ip6_encap_hlen(ipencap); 1605 + if (hlen < 0) 1606 + return hlen; 1607 + 1608 + t->encap.type = ipencap->type; 1609 + t->encap.sport = ipencap->sport; 1610 + t->encap.dport = ipencap->dport; 1611 + t->encap.flags = ipencap->flags; 1612 + 1613 + t->encap_hlen = hlen; 1614 + t->hlen = t->encap_hlen + t->tun_hlen; 1615 + 1616 + return 0; 1617 + } 1618 + EXPORT_SYMBOL_GPL(ip6_tnl_encap_setup); 1619 + 1585 1620 static const struct net_device_ops ip6_tnl_netdev_ops = { 1586 1621 .ndo_init = ip6_tnl_dev_init, 1587 1622 .ndo_uninit = ip6_tnl_dev_uninit, ··· 1645 1574 .ndo_get_iflink = ip6_tnl_get_iflink, 1646 1575 }; 1647 1576 1577 + #define IPXIPX_FEATURES (NETIF_F_SG | \ 1578 + NETIF_F_FRAGLIST | \ 1579 + NETIF_F_HIGHDMA | \ 1580 + NETIF_F_GSO_SOFTWARE | \ 1581 + NETIF_F_HW_CSUM) 1648 1582 1649 1583 /** 1650 1584 * ip6_tnl_dev_setup - setup virtual tunnel device ··· 1661 1585 1662 1586 static void ip6_tnl_dev_setup(struct net_device *dev) 1663 1587 { 1664 - struct ip6_tnl *t; 1665 - 1666 1588 dev->netdev_ops = &ip6_tnl_netdev_ops; 1667 1589 dev->destructor = ip6_dev_free; 1668 1590 1669 1591 dev->type = ARPHRD_TUNNEL6; 1670 - dev->hard_header_len = LL_MAX_HEADER + sizeof(struct ipv6hdr); 1671 - dev->mtu = ETH_DATA_LEN - sizeof(struct ipv6hdr); 1672 - t = netdev_priv(dev); 1673 - if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) 1674 - dev->mtu -= 8; 1675 1592 dev->flags |= IFF_NOARP; 1676 1593 dev->addr_len = sizeof(struct in6_addr); 1594 + dev->features |= NETIF_F_LLTX; 1677 1595 netif_keep_dst(dev); 1596 + 1597 + dev->features |= IPXIPX_FEATURES; 1598 + dev->hw_features |= IPXIPX_FEATURES; 1599 + 1678 1600 /* This perm addr will be used as interface identifier by IPv6 */ 1679 1601 dev->addr_assign_type = NET_ADDR_RANDOM; 1680 1602 eth_random_addr(dev->perm_addr); ··· 1689 1615 { 1690 1616 struct ip6_tnl *t = netdev_priv(dev); 1691 1617 int ret; 1618 + int t_hlen; 1692 1619 1693 1620 t->dev = dev; 1694 1621 t->net = dev_net(dev); ··· 1705 1630 if (ret) 1706 1631 goto destroy_dst; 1707 1632 1708 - t->hlen = 0; 1709 1633 t->tun_hlen = 0; 1634 + t->hlen = t->encap_hlen + t->tun_hlen; 1635 + t_hlen = t->hlen + sizeof(struct ipv6hdr); 1636 + 1637 + dev->type = ARPHRD_TUNNEL6; 1638 + dev->hard_header_len = LL_MAX_HEADER + t_hlen; 1639 + dev->mtu = ETH_DATA_LEN - t_hlen; 1640 + if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) 1641 + dev->mtu -= 8; 1710 1642 1711 1643 return 0; 1712 1644 ··· 1811 1729 parms->proto = nla_get_u8(data[IFLA_IPTUN_PROTO]); 1812 1730 } 1813 1731 1732 + static bool ip6_tnl_netlink_encap_parms(struct nlattr *data[], 1733 + struct ip_tunnel_encap *ipencap) 1734 + { 1735 + bool ret = false; 1736 + 1737 + memset(ipencap, 0, sizeof(*ipencap)); 1738 + 1739 + if (!data) 1740 + return ret; 1741 + 1742 + if (data[IFLA_IPTUN_ENCAP_TYPE]) { 1743 + ret = true; 1744 + ipencap->type = nla_get_u16(data[IFLA_IPTUN_ENCAP_TYPE]); 1745 + } 1746 + 1747 + if (data[IFLA_IPTUN_ENCAP_FLAGS]) { 1748 + ret = true; 1749 + ipencap->flags = nla_get_u16(data[IFLA_IPTUN_ENCAP_FLAGS]); 1750 + } 1751 + 1752 + if (data[IFLA_IPTUN_ENCAP_SPORT]) { 1753 + ret = true; 1754 + ipencap->sport = nla_get_be16(data[IFLA_IPTUN_ENCAP_SPORT]); 1755 + } 1756 + 1757 + if (data[IFLA_IPTUN_ENCAP_DPORT]) { 1758 + ret = true; 1759 + ipencap->dport = nla_get_be16(data[IFLA_IPTUN_ENCAP_DPORT]); 1760 + } 1761 + 1762 + return ret; 1763 + } 1764 + 1814 1765 static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev, 1815 1766 struct nlattr *tb[], struct nlattr *data[]) 1816 1767 { 1817 1768 struct net *net = dev_net(dev); 1818 1769 struct ip6_tnl *nt, *t; 1770 + struct ip_tunnel_encap ipencap; 1819 1771 1820 1772 nt = netdev_priv(dev); 1773 + 1774 + if (ip6_tnl_netlink_encap_parms(data, &ipencap)) { 1775 + int err = ip6_tnl_encap_setup(nt, &ipencap); 1776 + 1777 + if (err < 0) 1778 + return err; 1779 + } 1780 + 1821 1781 ip6_tnl_netlink_parms(data, &nt->parms); 1822 1782 1823 1783 t = ip6_tnl_locate(net, &nt->parms, 0); ··· 1876 1752 struct __ip6_tnl_parm p; 1877 1753 struct net *net = t->net; 1878 1754 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); 1755 + struct ip_tunnel_encap ipencap; 1879 1756 1880 1757 if (dev == ip6n->fb_tnl_dev) 1881 1758 return -EINVAL; 1882 1759 1760 + if (ip6_tnl_netlink_encap_parms(data, &ipencap)) { 1761 + int err = ip6_tnl_encap_setup(t, &ipencap); 1762 + 1763 + if (err < 0) 1764 + return err; 1765 + } 1883 1766 ip6_tnl_netlink_parms(data, &p); 1884 1767 1885 1768 t = ip6_tnl_locate(net, &p, 0); ··· 1927 1796 nla_total_size(4) + 1928 1797 /* IFLA_IPTUN_PROTO */ 1929 1798 nla_total_size(1) + 1799 + /* IFLA_IPTUN_ENCAP_TYPE */ 1800 + nla_total_size(2) + 1801 + /* IFLA_IPTUN_ENCAP_FLAGS */ 1802 + nla_total_size(2) + 1803 + /* IFLA_IPTUN_ENCAP_SPORT */ 1804 + nla_total_size(2) + 1805 + /* IFLA_IPTUN_ENCAP_DPORT */ 1806 + nla_total_size(2) + 1930 1807 0; 1931 1808 } 1932 1809 ··· 1952 1813 nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) || 1953 1814 nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto)) 1954 1815 goto nla_put_failure; 1816 + 1817 + if (nla_put_u16(skb, IFLA_IPTUN_ENCAP_TYPE, 1818 + tunnel->encap.type) || 1819 + nla_put_be16(skb, IFLA_IPTUN_ENCAP_SPORT, 1820 + tunnel->encap.sport) || 1821 + nla_put_be16(skb, IFLA_IPTUN_ENCAP_DPORT, 1822 + tunnel->encap.dport) || 1823 + nla_put_u16(skb, IFLA_IPTUN_ENCAP_FLAGS, 1824 + tunnel->encap.flags)) 1825 + goto nla_put_failure; 1826 + 1955 1827 return 0; 1956 1828 1957 1829 nla_put_failure: ··· 1986 1836 [IFLA_IPTUN_FLOWINFO] = { .type = NLA_U32 }, 1987 1837 [IFLA_IPTUN_FLAGS] = { .type = NLA_U32 }, 1988 1838 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 }, 1839 + [IFLA_IPTUN_ENCAP_TYPE] = { .type = NLA_U16 }, 1840 + [IFLA_IPTUN_ENCAP_FLAGS] = { .type = NLA_U16 }, 1841 + [IFLA_IPTUN_ENCAP_SPORT] = { .type = NLA_U16 }, 1842 + [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 }, 1989 1843 }; 1990 1844 1991 1845 static struct rtnl_link_ops ip6_link_ops __read_mostly = {
+2 -2
net/ipv6/sit.c
··· 913 913 goto tx_error; 914 914 } 915 915 916 - if (iptunnel_handle_offloads(skb, SKB_GSO_SIT)) { 916 + if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4)) { 917 917 ip_rt_put(rt); 918 918 goto tx_error; 919 919 } ··· 1000 1000 struct ip_tunnel *tunnel = netdev_priv(dev); 1001 1001 const struct iphdr *tiph = &tunnel->parms.iph; 1002 1002 1003 - if (iptunnel_handle_offloads(skb, SKB_GSO_IPIP)) 1003 + if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4)) 1004 1004 goto tx_error; 1005 1005 1006 1006 skb_set_inner_ipproto(skb, IPPROTO_IPIP);
+1 -1
net/ipv6/udp.c
··· 617 617 618 618 /* if we're overly short, let UDP handle it */ 619 619 encap_rcv = ACCESS_ONCE(up->encap_rcv); 620 - if (skb->len > sizeof(struct udphdr) && encap_rcv) { 620 + if (encap_rcv) { 621 621 int ret; 622 622 623 623 /* Verify checksum before giving to encap */
-13
net/ipv6/udp_offload.c
··· 36 36 37 37 if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) { 38 38 /* Packet is from an untrusted source, reset gso_segs. */ 39 - int type = skb_shinfo(skb)->gso_type; 40 - 41 - if (unlikely(type & ~(SKB_GSO_UDP | 42 - SKB_GSO_DODGY | 43 - SKB_GSO_UDP_TUNNEL | 44 - SKB_GSO_UDP_TUNNEL_CSUM | 45 - SKB_GSO_TUNNEL_REMCSUM | 46 - SKB_GSO_GRE | 47 - SKB_GSO_GRE_CSUM | 48 - SKB_GSO_IPIP | 49 - SKB_GSO_SIT) || 50 - !(type & (SKB_GSO_UDP)))) 51 - goto out; 52 39 53 40 skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss); 54 41
+1 -1
net/kcm/kcmsock.c
··· 1483 1483 long timeo; 1484 1484 struct kcm_rx_msg *rxm; 1485 1485 int err = 0; 1486 - size_t copied; 1486 + ssize_t copied; 1487 1487 struct sk_buff *skb; 1488 1488 1489 1489 /* Only support splice for SOCKSEQPACKET */
+1 -10
net/mpls/mpls_gso.c
··· 26 26 netdev_features_t mpls_features; 27 27 __be16 mpls_protocol; 28 28 29 - if (unlikely(skb_shinfo(skb)->gso_type & 30 - ~(SKB_GSO_TCPV4 | 31 - SKB_GSO_TCPV6 | 32 - SKB_GSO_UDP | 33 - SKB_GSO_DODGY | 34 - SKB_GSO_TCP_FIXEDID | 35 - SKB_GSO_TCP_ECN))) 36 - goto out; 37 - 38 29 /* Setup inner SKB. */ 39 30 mpls_protocol = skb->protocol; 40 31 skb->protocol = skb->inner_protocol; ··· 48 57 * skb_mac_gso_segment(), an indirect caller of this function. 49 58 */ 50 59 __skb_pull(skb, skb->data - skb_mac_header(skb)); 51 - out: 60 + 52 61 return segs; 53 62 } 54 63
+7 -10
net/netfilter/ipvs/ip_vs_xmit.c
··· 932 932 933 933 static inline int __tun_gso_type_mask(int encaps_af, int orig_af) 934 934 { 935 - if (encaps_af == AF_INET) { 936 - if (orig_af == AF_INET) 937 - return SKB_GSO_IPIP; 938 - 939 - return SKB_GSO_SIT; 935 + switch (encaps_af) { 936 + case AF_INET: 937 + return SKB_GSO_IPXIP4; 938 + case AF_INET6: 939 + return SKB_GSO_IPXIP6; 940 + default: 941 + return 0; 940 942 } 941 - 942 - /* GSO: we need to provide proper SKB_GSO_ value for IPv6: 943 - * SKB_GSO_SIT/IPV6 944 - */ 945 - return 0; 946 943 } 947 944 948 945 /*
+2 -2
net/rds/tcp_connect.c
··· 43 43 struct rds_connection *conn; 44 44 struct rds_tcp_connection *tc; 45 45 46 - read_lock(&sk->sk_callback_lock); 46 + read_lock_bh(&sk->sk_callback_lock); 47 47 conn = sk->sk_user_data; 48 48 if (!conn) { 49 49 state_change = sk->sk_state_change; ··· 69 69 break; 70 70 } 71 71 out: 72 - read_unlock(&sk->sk_callback_lock); 72 + read_unlock_bh(&sk->sk_callback_lock); 73 73 state_change(sk); 74 74 } 75 75
+11 -6
net/rds/tcp_listen.c
··· 80 80 int conn_state; 81 81 struct sock *nsk; 82 82 83 + if (!sock) /* module unload or netns delete in progress */ 84 + return -ENETUNREACH; 85 + 83 86 ret = sock_create_kern(sock_net(sock->sk), sock->sk->sk_family, 84 87 sock->sk->sk_type, sock->sk->sk_protocol, 85 88 &new_sock); ··· 132 129 * so we must quiesce any send threads before resetting 133 130 * c_transport_data. 134 131 */ 135 - wait_event(conn->c_waitq, 136 - !test_bit(RDS_IN_XMIT, &conn->c_flags)); 137 - if (ntohl(inet->inet_saddr) < ntohl(inet->inet_daddr)) { 132 + if (ntohl(inet->inet_saddr) < ntohl(inet->inet_daddr) || 133 + !conn->c_outgoing) { 138 134 goto rst_nsk; 139 - } else if (rs_tcp->t_sock) { 135 + } else { 136 + atomic_set(&conn->c_state, RDS_CONN_CONNECTING); 137 + wait_event(conn->c_waitq, 138 + !test_bit(RDS_IN_XMIT, &conn->c_flags)); 140 139 rds_tcp_restore_callbacks(rs_tcp->t_sock, rs_tcp); 141 140 conn->c_outgoing = 0; 142 141 } ··· 171 166 172 167 rdsdebug("listen data ready sk %p\n", sk); 173 168 174 - read_lock(&sk->sk_callback_lock); 169 + read_lock_bh(&sk->sk_callback_lock); 175 170 ready = sk->sk_user_data; 176 171 if (!ready) { /* check for teardown race */ 177 172 ready = sk->sk_data_ready; ··· 188 183 rds_tcp_accept_work(sk); 189 184 190 185 out: 191 - read_unlock(&sk->sk_callback_lock); 186 + read_unlock_bh(&sk->sk_callback_lock); 192 187 ready(sk); 193 188 } 194 189
+2 -2
net/rds/tcp_recv.c
··· 301 301 302 302 rdsdebug("data ready sk %p\n", sk); 303 303 304 - read_lock(&sk->sk_callback_lock); 304 + read_lock_bh(&sk->sk_callback_lock); 305 305 conn = sk->sk_user_data; 306 306 if (!conn) { /* check for teardown race */ 307 307 ready = sk->sk_data_ready; ··· 315 315 if (rds_tcp_read_sock(conn, GFP_ATOMIC) == -ENOMEM) 316 316 queue_delayed_work(rds_wq, &conn->c_recv_w, 0); 317 317 out: 318 - read_unlock(&sk->sk_callback_lock); 318 + read_unlock_bh(&sk->sk_callback_lock); 319 319 ready(sk); 320 320 } 321 321
+2 -2
net/rds/tcp_send.c
··· 180 180 struct rds_connection *conn; 181 181 struct rds_tcp_connection *tc; 182 182 183 - read_lock(&sk->sk_callback_lock); 183 + read_lock_bh(&sk->sk_callback_lock); 184 184 conn = sk->sk_user_data; 185 185 if (!conn) { 186 186 write_space = sk->sk_write_space; ··· 200 200 queue_delayed_work(rds_wq, &conn->c_send_w, 0); 201 201 202 202 out: 203 - read_unlock(&sk->sk_callback_lock); 203 + read_unlock_bh(&sk->sk_callback_lock); 204 204 205 205 /* 206 206 * write_space is only called when data leaves tcp's send queue if
+4 -4
net/tipc/server.c
··· 138 138 { 139 139 struct tipc_conn *con; 140 140 141 - read_lock(&sk->sk_callback_lock); 141 + read_lock_bh(&sk->sk_callback_lock); 142 142 con = sock2con(sk); 143 143 if (con && test_bit(CF_CONNECTED, &con->flags)) { 144 144 conn_get(con); 145 145 if (!queue_work(con->server->rcv_wq, &con->rwork)) 146 146 conn_put(con); 147 147 } 148 - read_unlock(&sk->sk_callback_lock); 148 + read_unlock_bh(&sk->sk_callback_lock); 149 149 } 150 150 151 151 static void sock_write_space(struct sock *sk) 152 152 { 153 153 struct tipc_conn *con; 154 154 155 - read_lock(&sk->sk_callback_lock); 155 + read_lock_bh(&sk->sk_callback_lock); 156 156 con = sock2con(sk); 157 157 if (con && test_bit(CF_CONNECTED, &con->flags)) { 158 158 conn_get(con); 159 159 if (!queue_work(con->server->send_wq, &con->swork)) 160 160 conn_put(con); 161 161 } 162 - read_unlock(&sk->sk_callback_lock); 162 + read_unlock_bh(&sk->sk_callback_lock); 163 163 } 164 164 165 165 static void tipc_register_callbacks(struct socket *sock, struct tipc_conn *con)