Advertisement
Guest User

ralpatch.diff

a guest
Jul 6th, 2011
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 394.66 KB | None | 0 0
  1. diff -aruN /usr/src/sys/dev/ral/if_ral_pci.c src/sys/dev/ral/if_ral_pci.c
  2. --- /usr/src/sys/dev/ral/if_ral_pci.c   2009-03-09 06:23:54.000000000 -0700
  3. +++ src/sys/dev/ral/if_ral_pci.c    2011-07-05 21:51:10.000000000 -0700
  4. @@ -1,8 +1,9 @@
  5.  /* $FreeBSD: src/sys/dev/ral/if_ral_pci.c,v 1.9 2009/03/09 13:23:54 imp Exp $  */
  6.  
  7.  /*-
  8. - * Copyright (c) 2005, 2006
  9. + * Copyright (c) 2005, 2006, 2011
  10.   * Damien Bergamini <damien.bergamini@free.fr>
  11. + * Matto <matto@63bit.net>
  12.   *
  13.   * Permission to use, copy, modify, and distribute this software for any
  14.   * purpose with or without fee is hereby granted, provided that the above
  15. @@ -58,6 +59,8 @@
  16.  #include <dev/ral/rt2560var.h>
  17.  #include <dev/ral/rt2661var.h>
  18.  
  19. +/* RT2860 includes */
  20. #include <dev/ral/rt2860_softc.h>
  21. #include <dev/ral/rt2860_reg.h>
  22. #include <dev/ral/rt2860_eeprom.h>
  23. #include <dev/ral/rt2860_ucode.h>
  24. #include <dev/ral/rt2860_txwi.h>
  25. #include <dev/ral/rt2860_rxwi.h>
  26. #include <dev/ral/rt2860_io.h>
  27. #include <dev/ral/rt2860_read_eeprom.h>
  28. #include <dev/ral/rt2860_led.h>
  29. #include <dev/ral/rt2860_rf.h>
  30. #include <dev/ral/rt2860_debug.h>
  31. +
  32.  MODULE_DEPEND(ral, pci, 1, 1, 1);
  33.  MODULE_DEPEND(ral, firmware, 1, 1, 1);
  34.  MODULE_DEPEND(ral, wlan, 1, 1, 1);
  35. @@ -68,14 +71,18 @@
  36.     uint16_t    device;
  37.     const char  *name;
  38.  };
  39. -
  40. +#define PCI_VENDOR_RALINK                      0x1814
  41. #define PCI_PRODUCT_RALINK_RT2860_PCI           0x0601
  42. #define PCI_PRODUCT_RALINK_RT2860_PCIe          0x0681
  43. #define PCI_PRODUCT_RALINK_RT2760_PCI           0x0701
  44. #define PCI_PRODUCT_RALINK_RT2790_PCIe          0x0781
  45. #define PCI_PRODUCT_RALINK_RT3090_PCIe          0x3090
  46.  static const struct ral_pci_ident ral_pci_ids[] = {
  47. -   { 0x1814, 0x0201, "Ralink Technology RT2560" },
  48. -   { 0x1814, 0x0301, "Ralink Technology RT2561S" },
  49. -   { 0x1814, 0x0302, "Ralink Technology RT2561" },
  50. -   { 0x1814, 0x0401, "Ralink Technology RT2661" },
  51. -
  52. -   { 0, 0, NULL }
  53. +   { 0x1814, 0x0201, "Ralink Technology RT2560" },
  54. +   { 0x1814, 0x0301, "Ralink Technology RT2561S" },
  55. +   { 0x1814, 0x0302, "Ralink Technology RT2561" },
  56. +   { 0x1814, 0x0401, "Ralink Technology RT2661" },
  57. +   { 0x1814, 0x0601, "Ralink Technology RT2860" },
  58. +   { 0x1814, 0x0681, "Ralink Technology RT2860" },
  59. +   { 0x1814, 0x0701, "Ralink Technology RT2760" },
  60. +   { 0x1814, 0x0781, "Ralink Technology RT2790" },
  61. +   { 0x1814, 0x3090, "Ralink Technology RT3090" },
  62. +   { 0, 0, NULL }
  63.  };
  64.  
  65.  static struct ral_opns {
  66. @@ -100,13 +107,14 @@
  67.     rt2661_shutdown,
  68.     rt2661_suspend,
  69.     rt2661_resume,
  70. -   rt2661_intr
  71. +   rt2661_intr
  72. }, ral_rt2860_opns = {
  73.     rt2860_attach,
  74.     rt2860_detach,
  75.     rt2860_shutdown,
  76.     rt2860_suspend,
  77.     rt2860_resume,
  78.     rt2860_intr
  79.  };
  80.  
  81.  struct ral_pci_softc {
  82.     union {
  83.         struct rt2560_softc sc_rt2560;
  84.         struct rt2661_softc sc_rt2661;
  85. +       struct rt2860_softc sc_rt2860;
  86.     } u;
  87.  
  88.     struct ral_opns     *sc_opns;
  89. @@ -179,9 +187,11 @@
  90.  
  91.     /* enable bus-mastering */
  92.     pci_enable_busmaster(dev);
  93. -
  94. +/* We are a little more complex than this now
  95.     psc->sc_opns = (pci_get_device(dev) == 0x0201) ? &ral_rt2560_opns :
  96.         &ral_rt2661_opns;
  97. +*/
  98. +   if (pci_get_vendor(dev) == PCI_VENDOR_RALINK) {
  99.         switch (pci_get_device(dev)) {
  100.         case 0x2560:
  101.             psc->sc_opns = &ral_rt2560_opns;
  102.             break;
  103.         case 0x2561:
  104.         case 0x2562: /*rt2561s these are all invalid codes to avoid -Werror crap from clang */
  105.         case 0x2661:
  106.             psc->sc_opns = &ral_rt2661_opns;
  107.             break;
  108.         default:
  109.             psc->sc_opns = &ral_rt2860_opns;
  110.             break;
  111.         }
  112.     } else {
  113.         /* all other vendors are RT2860 only */
  114.        
  115.         psc->sc_opns = &ral_rt2860_opns;
  116.     }
  117.  
  118.     psc->mem_rid = RAL_PCI_BAR0;
  119.     psc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &psc->mem_rid,
  120. diff -aruN /usr/src/sys/dev/ral/if_ral_pci.c.rej src/sys/dev/ral/if_ral_pci.c.rej
  121. --- /usr/src/sys/dev/ral/if_ral_pci.c.rej   1969-12-31 16:00:00.000000000 -0800
  122. +++ src/sys/dev/ral/if_ral_pci.c.rej    2011-07-05 21:51:10.000000000 -0700
  123. @@ -0,0 +1,265 @@
  124. +***************
  125. +*** 1,10 ****
  126. +  /*   $FreeBSD: src/sys/dev/ral/if_ral_pci.c,v 1.9 2009/03/09 13:23:54 imp Exp $  */
  127.  
  128. +  
  129.  
  130. +  /*-
  131.  
  132. +   * Copyright (c) 2005, 2006
  133.  
  134. +   *   Damien Bergamini <damien.bergamini@free.fr>
  135.  
  136. +   *
  137.  
  138. +   * Permission to use, copy, modify, and distribute this software for any
  139.  
  140. +   * purpose with or without fee is hereby granted, provided that the above
  141.  
  142. +   * copyright notice and this permission notice appear in all copies.
  143.  
  144. +   *
  145.  
  146. +--- 1,11 ----
  147. +  /*   $FreeBSD: src/sys/dev/ral/if_ral_pci.c,v 1.9 2009/03/09 13:23:54 imp Exp $  */
  148.  
  149. +  
  150.  
  151. +  /*-
  152.  
  153. +   * Copyright (c) 2005, 2006
  154.  
  155. +   *   Damien Bergamini <damien.bergamini@free.fr>
  156.  
  157. ++  *      Minor changes for rt2860 and bugs added by Matt (sendtomatt@gmail.com)
  158.  
  159. +   *
  160.  
  161. +   * Permission to use, copy, modify, and distribute this software for any
  162.  
  163. +   * purpose with or without fee is hereby granted, provided that the above
  164.  
  165. +   * copyright notice and this permission notice appear in all copies.
  166.  
  167. +   *
  168.  
  169. +***************
  170. +*** 19,29 ****
  171. +  
  172.  
  173. +  #include <sys/cdefs.h>
  174.  
  175. +  __FBSDID("$FreeBSD: src/sys/dev/ral/if_ral_pci.c,v 1.9 2009/03/09 13:23:54 imp Exp $");
  176.  
  177. +  
  178.  
  179. +  /*
  180.  
  181. +!  * PCI/Cardbus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
  182.  
  183. +   */
  184.  
  185. +  
  186.  
  187. +  #include <sys/param.h>
  188.  
  189. +  #include <sys/sysctl.h>
  190.  
  191. +  #include <sys/sockio.h>
  192.  
  193. +--- 20,30 ----
  194. +  
  195.  
  196. +  #include <sys/cdefs.h>
  197.  
  198. +  __FBSDID("$FreeBSD: src/sys/dev/ral/if_ral_pci.c,v 1.9 2009/03/09 13:23:54 imp Exp $");
  199.  
  200. +  
  201.  
  202. +  /*
  203.  
  204. +!  * PCI/Cardbus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661/RT2860/RT3090 driver.
  205.  
  206. +   */
  207.  
  208. +  
  209.  
  210. +  #include <sys/param.h>
  211.  
  212. +  #include <sys/sysctl.h>
  213.  
  214. +  #include <sys/sockio.h>
  215.  
  216. +***************
  217. +*** 56,65 ****
  218. +  #include <dev/pci/pcivar.h>
  219.  
  220. +  
  221.  
  222. +  #include <dev/ral/rt2560var.h>
  223.  
  224. +  #include <dev/ral/rt2661var.h>
  225.  
  226. +  
  227.  
  228. +  MODULE_DEPEND(ral, pci, 1, 1, 1);
  229.  
  230. +  MODULE_DEPEND(ral, firmware, 1, 1, 1);
  231.  
  232. +  MODULE_DEPEND(ral, wlan, 1, 1, 1);
  233.  
  234. +  MODULE_DEPEND(ral, wlan_amrr, 1, 1, 1);
  235.  
  236. +  
  237.  
  238. +--- 57,80 ----
  239. +  #include <dev/pci/pcivar.h>
  240.  
  241. +  
  242.  
  243. +  #include <dev/ral/rt2560var.h>
  244.  
  245. +  #include <dev/ral/rt2661var.h>
  246.  
  247. +  
  248.  
  249. ++ /* RT2860 includes */
  250.  
  251. ++ #include <dev/ral/rt2860_softc.h>
  252.  
  253. ++ #include <dev/ral/rt2860_reg.h>
  254.  
  255. ++ #include <dev/ral/rt2860_eeprom.h>
  256.  
  257. ++ #include <dev/ral/rt2860_ucode.h>
  258.  
  259. ++ #include <dev/ral/rt2860_txwi.h>
  260.  
  261. ++ #include <dev/ral/rt2860_rxwi.h>
  262.  
  263. ++ #include <dev/ral/rt2860_io.h>
  264.  
  265. ++ #include <dev/ral/rt2860_read_eeprom.h>
  266.  
  267. ++ #include <dev/ral/rt2860_led.h>
  268.  
  269. ++ #include <dev/ral/rt2860_rf.h>
  270.  
  271. ++ #include <dev/ral/rt2860_debug.h>
  272.  
  273. ++
  274.  
  275. ++
  276.  
  277. +  MODULE_DEPEND(ral, pci, 1, 1, 1);
  278.  
  279. +  MODULE_DEPEND(ral, firmware, 1, 1, 1);
  280.  
  281. +  MODULE_DEPEND(ral, wlan, 1, 1, 1);
  282.  
  283. +  MODULE_DEPEND(ral, wlan_amrr, 1, 1, 1);
  284.  
  285. +  
  286.  
  287. +***************
  288. +*** 67,82 ****
  289. +   uint16_t    vendor;
  290.  
  291. +   uint16_t    device;
  292.  
  293. +   const char  *name;
  294.  
  295. +  };
  296.  
  297. +  
  298.  
  299. +  static const struct ral_pci_ident ral_pci_ids[] = {
  300.  
  301. +   { 0x1814, 0x0201, "Ralink Technology RT2560" },
  302.  
  303. +   { 0x1814, 0x0301, "Ralink Technology RT2561S" },
  304.  
  305. +   { 0x1814, 0x0302, "Ralink Technology RT2561" },
  306.  
  307. +   { 0x1814, 0x0401, "Ralink Technology RT2661" },
  308.  
  309. +!
  310.  
  311. +   { 0, 0, NULL }
  312.  
  313. +  };
  314.  
  315. +  
  316.  
  317. +  static struct ral_opns {
  318.  
  319. +   int (*attach)(device_t, int);
  320.  
  321. +--- 82,108 ----
  322. +   uint16_t    vendor;
  323.  
  324. +   uint16_t    device;
  325.  
  326. +   const char  *name;
  327.  
  328. +  };
  329.  
  330. +  
  331.  
  332. ++ #define PCI_VENDOR_RALINK                        0x1814
  333.  
  334. ++ #define PCI_PRODUCT_RALINK_RT2860_PCI            0x0601
  335.  
  336. ++ #define PCI_PRODUCT_RALINK_RT2860_PCIe           0x0681
  337.  
  338. ++ #define PCI_PRODUCT_RALINK_RT2760_PCI            0x0701
  339.  
  340. ++ #define PCI_PRODUCT_RALINK_RT2790_PCIe           0x0781
  341.  
  342. ++ #define PCI_PRODUCT_RALINK_RT3090_PCIe           0x3090
  343.  
  344. ++
  345.  
  346. +  static const struct ral_pci_ident ral_pci_ids[] = {
  347.  
  348. +   { 0x1814, 0x0201, "Ralink Technology RT2560" },
  349.  
  350. +   { 0x1814, 0x0301, "Ralink Technology RT2561S" },
  351.  
  352. +   { 0x1814, 0x0302, "Ralink Technology RT2561" },
  353.  
  354. +   { 0x1814, 0x0401, "Ralink Technology RT2661" },
  355.  
  356. +!  { 0x1814, 0x0601, "Ralink Technology RT2860" },
  357.  
  358. +!  { 0x1814, 0x0681, "Ralink Technology RT2860" },
  359.  
  360. +!  { 0x1814, 0x0701, "Ralink Technology RT2760" },
  361.  
  362. +!  { 0x1814, 0x0781, "Ralink Technology RT2790" },
  363.  
  364. +!  { 0x1814, 0x3090, "Ralink Technology RT3090" },
  365.  
  366. +   { 0, 0, NULL }
  367.  
  368. +  };
  369.  
  370. +  
  371.  
  372. +  static struct ral_opns {
  373.  
  374. +   int (*attach)(device_t, int);
  375.  
  376. +***************
  377. +*** 99,114 ****
  378. +   rt2661_detach,
  379.  
  380. +   rt2661_shutdown,
  381.  
  382. +   rt2661_suspend,
  383.  
  384. +   rt2661_resume,
  385.  
  386. +   rt2661_intr
  387.  
  388. +  };
  389.  
  390. +  
  391.  
  392. +  struct ral_pci_softc {
  393.  
  394. +   union {
  395.  
  396. +       struct rt2560_softc sc_rt2560;
  397.  
  398. +       struct rt2661_softc sc_rt2661;
  399.  
  400. +   } u;
  401.  
  402. +  
  403.  
  404. +   struct ral_opns     *sc_opns;
  405.  
  406. +   int         irq_rid;
  407.  
  408. +   int         mem_rid;
  409.  
  410. +--- 125,150 ----
  411. +   rt2661_detach,
  412.  
  413. +   rt2661_shutdown,
  414.  
  415. +   rt2661_suspend,
  416.  
  417. +   rt2661_resume,
  418.  
  419. +   rt2661_intr
  420.  
  421. ++
  422.  
  423. ++ }, ral_rt2860_opns = {
  424.  
  425. ++  rt2860_attach,
  426.  
  427. ++  rt2860_detach,
  428.  
  429. ++  rt2860_shutdown,
  430.  
  431. ++  rt2860_suspend,
  432.  
  433. ++  rt2860_resume,
  434.  
  435. ++  rt2860_intr
  436.  
  437. ++
  438.  
  439. +  };
  440.  
  441. +  
  442.  
  443. +  struct ral_pci_softc {
  444.  
  445. +   union {
  446.  
  447. +       struct rt2560_softc sc_rt2560;
  448.  
  449. +       struct rt2661_softc sc_rt2661;
  450.  
  451. ++      struct rt2860_softc sc_rt2860;
  452.  
  453. +   } u;
  454.  
  455. +  
  456.  
  457. +   struct ral_opns     *sc_opns;
  458.  
  459. +   int         irq_rid;
  460.  
  461. +   int         mem_rid;
  462.  
  463. +***************
  464. +*** 178,190 ****
  465. +   }
  466.  
  467. +  
  468.  
  469. +   /* enable bus-mastering */
  470.  
  471. +   pci_enable_busmaster(dev);
  472.  
  473. +  
  474.  
  475. +   psc->sc_opns = (pci_get_device(dev) == 0x0201) ? &ral_rt2560_opns :
  476.  
  477. +       &ral_rt2661_opns;
  478.  
  479. +  
  480.  
  481. +   psc->mem_rid = RAL_PCI_BAR0;
  482.  
  483. +   psc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &psc->mem_rid,
  484.  
  485. +       RF_ACTIVE);
  486.  
  487. +   if (psc->mem == NULL) {
  488.  
  489. +       device_printf(dev, "could not allocate memory resource\n");
  490.  
  491. +--- 214,247 ----
  492. +   }
  493.  
  494. +  
  495.  
  496. +   /* enable bus-mastering */
  497.  
  498. +   pci_enable_busmaster(dev);
  499.  
  500. +  
  501.  
  502. ++ /*
  503.  
  504. +   psc->sc_opns = (pci_get_device(dev) == 0x0201) ? &ral_rt2560_opns :
  505.  
  506. +       &ral_rt2661_opns;
  507.  
  508. ++ */
  509.  
  510. +  
  511.  
  512. ++  if (pci_get_vendor(dev) == PCI_VENDOR_RALINK) {
  513.  
  514. ++      switch (pci_get_device(dev)) {
  515.  
  516. ++      case 0x2560:
  517.  
  518. ++          psc->sc_opns = &ral_rt2560_opns;
  519.  
  520. ++          break;
  521.  
  522. ++      case 0x2561:
  523.  
  524. ++      case 0x2562: /*rt2561s these are all invalid codes to avoid -Werror crap from clang */
  525.  
  526. ++      case 0x2661:
  527.  
  528. ++          psc->sc_opns = &ral_rt2661_opns;
  529.  
  530. ++          break;
  531.  
  532. ++      default:
  533.  
  534. ++          psc->sc_opns = &ral_rt2860_opns;
  535.  
  536. ++          break;
  537.  
  538. ++      }
  539.  
  540. ++  } else {
  541.  
  542. ++      /* all other vendors are RT2860 only */
  543.  
  544. ++     
  545.  
  546. ++      psc->sc_opns = &ral_rt2860_opns;
  547.  
  548. ++  }
  549.  
  550. +   psc->mem_rid = RAL_PCI_BAR0;
  551.  
  552. +   psc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &psc->mem_rid,
  553.  
  554. +       RF_ACTIVE);
  555.  
  556. +   if (psc->mem == NULL) {
  557.  
  558. +       device_printf(dev, "could not allocate memory resource\n");
  559.  
  560. +***************
  561. +*** 205,219 ****
  562. +  
  563.  
  564. +   error = (*psc->sc_opns->attach)(dev, pci_get_device(dev));
  565.  
  566. +   if (error != 0)
  567.  
  568. +       return error;
  569.  
  570. +  
  571.  
  572. +   /*
  573.  
  574. +    * Hook our interrupt after all initialization is complete.
  575.  
  576. +    */
  577.  
  578. +   error = bus_setup_intr(dev, psc->irq, INTR_TYPE_NET | INTR_MPSAFE,
  579.  
  580. +       NULL, psc->sc_opns->intr, psc, &psc->sc_ih);
  581.  
  582. +   if (error != 0) {
  583.  
  584. +       device_printf(dev, "could not set up interrupt\n");
  585.  
  586. +       return error;
  587.  
  588. +   }
  589.  
  590. +   sc->sc_invalid = 0;
  591.  
  592. +--- 262,281 ----
  593. +  
  594.  
  595. +   error = (*psc->sc_opns->attach)(dev, pci_get_device(dev));
  596.  
  597. +   if (error != 0)
  598.  
  599. +       return error;
  600.  
  601. +  
  602.  
  603. ++
  604.  
  605. ++
  606.  
  607. +   /*
  608.  
  609. +    * Hook our interrupt after all initialization is complete.
  610.  
  611. +    */
  612.  
  613. ++
  614.  
  615. +   error = bus_setup_intr(dev, psc->irq, INTR_TYPE_NET | INTR_MPSAFE,
  616.  
  617. +       NULL, psc->sc_opns->intr, psc, &psc->sc_ih);
  618.  
  619. ++  
  620.  
  621. ++  
  622.  
  623. +   if (error != 0) {
  624.  
  625. +       device_printf(dev, "could not set up interrupt\n");
  626.  
  627. +       return error;
  628.  
  629. +   }
  630.  
  631. +   sc->sc_invalid = 0;
  632.  
  633. diff -aruN /usr/src/sys/dev/ral/rt2860.c src/sys/dev/ral/rt2860.c
  634. --- /usr/src/sys/dev/ral/rt2860.c   1969-12-31 16:00:00.000000000 -0800
  635. +++ src/sys/dev/ral/rt2860.c    2011-07-05 21:51:10.000000000 -0700
  636. @@ -0,0 +1,9874 @@
  637. +
  638. +/*-
  639. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  640. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  641. + * Copyright (c) 2011 Matto <matto@63bit.net>
  642. + * Permission to use, copy, modify, and distribute this software for any
  643. + * purpose with or without fee is hereby granted, provided that the above
  644. + * copyright notice and this permission notice appear in all copies.
  645. + *
  646. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  647. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  648. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  649. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  650. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  651. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  652. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  653. + */
  654. +
  655. +#include <sys/param.h>
  656. +#include <sys/kernel.h>
  657. +#include <sys/module.h>
  658. +#include <sys/socket.h>
  659. +#include <sys/sysctl.h>
  660. +#include <net/if.h>
  661. +#include <net/if_media.h>
  662. +#include <dev/pci/pcireg.h>
  663. +#include <dev/pci/pcivar.h>
  664. +#include <net80211/ieee80211_var.h>
  665. +#include <dev/ral/rt2860_softc.h>
  666. +#include <dev/ral/rt2860_reg.h>
  667. +#include <dev/ral/rt2860_eeprom.h>
  668. +#include <dev/ral/rt2860_ucode.h>
  669. +#include <dev/ral/rt2860_txwi.h>
  670. +#include <dev/ral/rt2860_rxwi.h>
  671. +#include <dev/ral/rt2860_io.h>
  672. +#include <dev/ral/rt2860_read_eeprom.h>
  673. +#include <dev/ral/rt2860_led.h>
  674. +#include <dev/ral/rt2860_rf.h>
  675. +#include <dev/ral/rt2860_debug.h>
  676. +#include <dev/ral/rt2860_amrr.h>
  677. +
  678. +/*
  679. + * Defines and macros (General)
  680. + */
  681. +
  682. +#define RT2860_MAX_AGG_SIZE                        3840
  683. +
  684. +#define RT2860_TX_DATA_SEG0_SIZE               \
  685. +   (sizeof(struct rt2860_txwi) + sizeof(struct ieee80211_qosframe_addr4))
  686. +
  687. +#define RT2860_NOISE_FLOOR                     -95
  688. +
  689. +#define IEEE80211_HAS_ADDR4(wh)                    \
  690. +   (((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS)
  691. +
  692. +#define    RT2860_MS(_v, _f)                       (((_v) & _f) >> _f##_S)
  693. +#define    RT2860_SM(_v, _f)                       (((_v) << _f##_S) & _f)
  694. +
  695. +#define RT2860_TX_WATCHDOG_TIMEOUT             5
  696. +
  697. +#define RT2860_WCID_RESERVED                   0xff
  698. +#define RT2860_WCID_MCAST                      0xf7
  699. +
  700. +#define RT2860_IO_EEPROM_RAISE_CLK(sc, val)                            \
  701. +do                                                                 \
  702. +{                                                                  \
  703. +   (val) |= RT2860_REG_EESK;                                       \
  704. +                                                                   \
  705. +   rt2860_io_mac_write((sc), RT2860_REG_EEPROM_CSR, (val));        \
  706. +                                                                   \
  707. +   DELAY(1);                                                       \
  708. +} while (0)
  709. +
  710. +/*
  711. + * RT2860_IO_EEPROM_LOWER_CLK
  712. + */
  713. +#define RT2860_IO_EEPROM_LOWER_CLK(sc, val)                            \
  714. +do                                                                 \
  715. +{                                                                  \
  716. +   (val) &= ~RT2860_REG_EESK;                                      \
  717. +                                                                   \
  718. +   rt2860_io_mac_write((sc), RT2860_REG_EEPROM_CSR, (val));        \
  719. +                                                                   \
  720. +   DELAY(1);                                                       \
  721. +} while (0)
  722. +
  723. +#define RT2860_IO_BYTE_CRC16(byte, crc)                                \
  724. +   ((uint16_t) (((crc) << 8) ^ rt2860_io_ccitt16[(((crc) >> 8) ^ (byte)) & 255]))
  725. +
  726. +/*
  727. + *    Vendor IDs for various cards/chipsets
  728. + */
  729. +#define PCI_VENDOR_RALINK                      0x1814
  730. +#define PCI_PRODUCT_RALINK_RT2860_PCI          0x0601
  731. +#define PCI_PRODUCT_RALINK_RT2860_PCIe         0x0681
  732. +#define PCI_PRODUCT_RALINK_RT2760_PCI          0x0701
  733. +#define PCI_PRODUCT_RALINK_RT2790_PCIe         0x0781
  734. +#define PCI_PRODUCT_RALINK_RT3090_PCIe         0x3090
  735. +
  736. +/*
  737. + *   AMRR Defines
  738. + */
  739. +
  740. +#define RT2860_AMRR_IS_SUCCESS(amrr_node)              ((amrr_node)->retrycnt < (amrr_node)->txcnt / 10)
  741. +
  742. +#define RT2860_AMRR_IS_FAILURE(amrr_node)              ((amrr_node)->retrycnt > (amrr_node)->txcnt / 3)
  743. +
  744. +#define RT2860_AMRR_IS_ENOUGH(amrr_node)               ((amrr_node)->txcnt > 10)
  745. +
  746. +
  747. +/*
  748. + * Global function prototypes, used in bus depended interfaces
  749. +
  750. +int rt2860_attach(device_t dev);
  751. +
  752. +int rt2860_detach(device_t dev);
  753. +
  754. +int rt2860_shutdown(device_t dev);
  755. +
  756. +int rt2860_suspend(device_t dev);
  757. +
  758. +int rt2860_resume(device_t dev);
  759. + */
  760. +
  761. +/*
  762. + * Static function prototypes
  763. + */
  764. +
  765. +static void rt2860_init_channels(struct rt2860_softc *sc);
  766. +
  767. +static void rt2860_init_channels_ht40(struct rt2860_softc *sc);
  768. +
  769. +static void rt2860_init_locked(void *priv);
  770. +
  771. +static void rt2860_init(void *priv);
  772. +
  773. +static int rt2860_init_bbp(struct rt2860_softc *sc);
  774. +
  775. +static void rt2860_stop_locked(void *priv);
  776. +
  777. +static void rt2860_stop(void *priv);
  778. +
  779. +static void rt2860_start(struct ifnet *ifp);
  780. +
  781. +static int rt2860_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
  782. +
  783. +static struct ieee80211vap *rt2860_vap_create(struct ieee80211com *ic,
  784. +   const char name[IFNAMSIZ], int unit, int opmode, int flags,
  785. +   const uint8_t bssid[IEEE80211_ADDR_LEN],
  786. +   const uint8_t mac[IEEE80211_ADDR_LEN]);
  787. +
  788. +static void rt2860_vap_delete(struct ieee80211vap *vap);
  789. +
  790. +static int rt2860_vap_reset(struct ieee80211vap *vap, u_long cmd);
  791. +
  792. +static int rt2860_vap_newstate(struct ieee80211vap *vap,
  793. +   enum ieee80211_state nstate, int arg);
  794. +
  795. +static void rt2860_vap_key_update_begin(struct ieee80211vap *vap);
  796. +
  797. +static void rt2860_vap_key_update_end(struct ieee80211vap *vap);
  798. +
  799. +static int rt2860_vap_key_set(struct ieee80211vap *vap,
  800. +   const struct ieee80211_key *k, const uint8_t mac[IEEE80211_ADDR_LEN]);
  801. +
  802. +static int rt2860_vap_key_delete(struct ieee80211vap *vap,
  803. +   const struct ieee80211_key *k);
  804. +
  805. +static void rt2860_vap_update_beacon(struct ieee80211vap *vap, int what);
  806. +
  807. +static int rt2860_media_change(struct ifnet *ifp);
  808. +
  809. +static struct ieee80211_node *rt2860_node_alloc(struct ieee80211vap *vap,
  810. +   const uint8_t mac[IEEE80211_ADDR_LEN]);
  811. +
  812. +static void rt2860_node_cleanup(struct ieee80211_node *ni);
  813. +
  814. +static void rt2860_node_getmimoinfo(const struct ieee80211_node *ni,
  815. +   struct ieee80211_mimo_info *mi);
  816. +
  817. +static int rt2860_setregdomain(struct ieee80211com *ic,
  818. +   struct ieee80211_regdomain *reg,
  819. +   int nchans, struct ieee80211_channel chans[]);
  820. +
  821. +static void rt2860_getradiocaps(struct ieee80211com *ic,
  822. +   int maxchans, int *nchans, struct ieee80211_channel chans[]);
  823. +
  824. +static void rt2860_scan_start(struct ieee80211com *ic);
  825. +
  826. +static void rt2860_scan_end(struct ieee80211com *ic);
  827. +
  828. +static void rt2860_set_channel(struct ieee80211com *ic);
  829. +
  830. +static void rt2860_newassoc(struct ieee80211_node *ni, int isnew);
  831. +
  832. +static void rt2860_updateslot(struct ifnet *ifp);
  833. +
  834. +static void rt2860_update_promisc(struct ifnet *ifp);
  835. +
  836. +static void rt2860_update_mcast(struct ifnet *ifp);
  837. +
  838. +static int rt2860_wme_update(struct ieee80211com *ic);
  839. +
  840. +static int rt2860_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
  841. +   const struct ieee80211_bpf_params *params);
  842. +
  843. +static int rt2860_recv_action(struct ieee80211_node *ni,
  844. +   const struct ieee80211_frame *wh,
  845. +   const uint8_t *frm, const uint8_t *efrm);
  846. +
  847. +static int rt2860_send_action(struct ieee80211_node *ni,
  848. +   int cat, int act, void *sa);
  849. +
  850. +static int rt2860_addba_response(struct ieee80211_node *ni,
  851. +   struct ieee80211_tx_ampdu *tap,
  852. +   int status, int baparamset, int batimeout);
  853. +
  854. +static void rt2860_addba_stop(struct ieee80211_node *ni,
  855. +   struct ieee80211_tx_ampdu *tap);
  856. +
  857. +static int rt2860_ampdu_rx_start(struct ieee80211_node *ni,
  858. +   struct ieee80211_rx_ampdu *rap,
  859. +   int baparamset, int batimeout, int baseqctl);
  860. +
  861. +static void rt2860_ampdu_rx_stop(struct ieee80211_node *ni,
  862. +   struct ieee80211_rx_ampdu *rap);
  863. +
  864. +static int rt2860_send_bar(struct ieee80211_node *ni,
  865. +   struct ieee80211_tx_ampdu *tap, ieee80211_seq seqno);
  866. +
  867. +static void rt2860_amrr_update_iter_func(void *arg, struct ieee80211_node *ni);
  868. +
  869. +static void rt2860_periodic(void *arg);
  870. +
  871. +static void rt2860_tx_watchdog(void *arg);
  872. +
  873. +static int rt2860_staid_alloc(struct rt2860_softc *sc, int aid);
  874. +
  875. +static void rt2860_staid_delete(struct rt2860_softc *sc, int staid);
  876. +
  877. +static void rt2860_asic_set_bssid(struct rt2860_softc *sc,
  878. +   const uint8_t *bssid);
  879. +
  880. +static void rt2860_asic_set_macaddr(struct rt2860_softc *sc,
  881. +   const uint8_t *addr);
  882. +
  883. +static void rt2860_asic_enable_tsf_sync(struct rt2860_softc *sc);
  884. +
  885. +static void rt2860_asic_disable_tsf_sync(struct rt2860_softc *sc);
  886. +
  887. +static void rt2860_asic_enable_mrr(struct rt2860_softc *sc);
  888. +
  889. +static void rt2860_asic_set_txpreamble(struct rt2860_softc *sc);
  890. +
  891. +static void rt2860_asic_set_basicrates(struct rt2860_softc *sc);
  892. +
  893. +static void rt2860_asic_update_rtsthreshold(struct rt2860_softc *sc);
  894. +
  895. +static void rt2860_asic_update_txpower(struct rt2860_softc *sc);
  896. +
  897. +static void rt2860_asic_update_promisc(struct rt2860_softc *sc);
  898. +
  899. +static void rt2860_asic_updateprot(struct rt2860_softc *sc);
  900. +
  901. +static void rt2860_asic_updateslot(struct rt2860_softc *sc);
  902. +
  903. +static void rt2860_asic_wme_update(struct rt2860_softc *sc);
  904. +
  905. +static void rt2860_asic_update_beacon(struct rt2860_softc *sc,
  906. +   struct ieee80211vap *vap);
  907. +
  908. +static void rt2860_asic_clear_keytables(struct rt2860_softc *sc);
  909. +
  910. +static void rt2860_asic_add_ba_session(struct rt2860_softc *sc,
  911. +   uint8_t wcid, int tid);
  912. +
  913. +static void rt2860_asic_del_ba_session(struct rt2860_softc *sc,
  914. +   uint8_t wcid, int tid);
  915. +
  916. +static int rt2860_beacon_alloc(struct rt2860_softc *sc,
  917. +   struct ieee80211vap *vap);
  918. +
  919. +static uint8_t rt2860_rxrate(struct rt2860_rxwi *rxwi);
  920. +
  921. +static uint8_t rt2860_maxrssi_rxpath(struct rt2860_softc *sc,
  922. +   const struct rt2860_rxwi *rxwi);
  923. +
  924. +static int8_t rt2860_rssi2dbm(struct rt2860_softc *sc,
  925. +   uint8_t rssi, uint8_t rxpath);
  926. +
  927. +static uint8_t rt2860_rate2mcs(uint8_t rate);
  928. +
  929. +static int rt2860_tx_mgmt(struct rt2860_softc *sc,
  930. +   struct mbuf *m, struct ieee80211_node *ni, int qid);
  931. +
  932. +static int rt2860_tx_data(struct rt2860_softc *sc,
  933. +   struct mbuf *m, struct ieee80211_node *ni, int qid);
  934. +
  935. +/*
  936. +static int rt2860_tx_raw(struct rt2860_softc *sc,
  937. +   struct mbuf *m, struct ieee80211_node *ni,
  938. +   const struct ieee80211_bpf_params *params);
  939. +*/
  940. +
  941. +static int rt2860_amrr_update(struct rt2860_amrr *amrr,
  942. +   struct rt2860_amrr_node *amrr_node, struct ieee80211_node *ni);
  943. +
  944. +/* Declared elsewheres rt2860_softc.h */
  945. +/* static void rt2860_intr(void *arg); */
  946. +
  947. +static void rt2860_tx_coherent_intr(struct rt2860_softc *sc);
  948. +
  949. +static void rt2860_rx_coherent_intr(struct rt2860_softc *sc);
  950. +
  951. +static void rt2860_txrx_coherent_intr(struct rt2860_softc *sc);
  952. +
  953. +static void rt2860_fifo_sta_full_intr(struct rt2860_softc *sc);
  954. +
  955. +static void rt2860_rx_intr(struct rt2860_softc *sc);
  956. +
  957. +static void rt2860_rx_delay_intr(struct rt2860_softc *sc);
  958. +
  959. +static void rt2860_tx_intr(struct rt2860_softc *sc, int qid);
  960. +
  961. +static void rt2860_tx_delay_intr(struct rt2860_softc *sc);
  962. +
  963. +static void rt2860_pre_tbtt_intr(struct rt2860_softc *sc);
  964. +
  965. +static void rt2860_tbtt_intr(struct rt2860_softc *sc);
  966. +
  967. +static void rt2860_mcu_cmd_intr(struct rt2860_softc *sc);
  968. +
  969. +static void rt2860_auto_wakeup_intr(struct rt2860_softc *sc);
  970. +
  971. +static void rt2860_gp_timer_intr(struct rt2860_softc *sc);
  972. +
  973. +static void rt2860_rx_done_task(void *context, int pending);
  974. +
  975. +static void rt2860_tx_done_task(void *context, int pending);
  976. +
  977. +static void rt2860_fifo_sta_full_task(void *context, int pending);
  978. +
  979. +static void rt2860_periodic_task(void *context, int pending);
  980. +
  981. +static int rt2860_rx_eof(struct rt2860_softc *sc, int limit);
  982. +
  983. +static void rt2860_tx_eof(struct rt2860_softc *sc,
  984. +   struct rt2860_softc_tx_ring *ring);
  985. +
  986. +static void rt2860_update_stats(struct rt2860_softc *sc);
  987. +
  988. +static void rt2860_bbp_tuning(struct rt2860_softc *sc);
  989. +
  990. +static void rt2860_watchdog(struct rt2860_softc *sc);
  991. +
  992. +static void rt2860_drain_fifo_stats(struct rt2860_softc *sc);
  993. +
  994. +static void rt2860_update_raw_counters(struct rt2860_softc *sc);
  995. +
  996. +static void rt2860_intr_enable(struct rt2860_softc *sc, uint32_t intr_mask);
  997. +
  998. +static void rt2860_intr_disable(struct rt2860_softc *sc, uint32_t intr_mask);
  999. +
  1000. +static int rt2860_txrx_enable(struct rt2860_softc *sc);
  1001. +
  1002. +static int rt2860_alloc_rx_ring(struct rt2860_softc *sc,
  1003. +   struct rt2860_softc_rx_ring *ring);
  1004. +
  1005. +static void rt2860_reset_rx_ring(struct rt2860_softc *sc,
  1006. +   struct rt2860_softc_rx_ring *ring);
  1007. +
  1008. +static void rt2860_free_rx_ring(struct rt2860_softc *sc,
  1009. +   struct rt2860_softc_rx_ring *ring);
  1010. +
  1011. +static int rt2860_alloc_tx_ring(struct rt2860_softc *sc,
  1012. +   struct rt2860_softc_tx_ring *ring, int qid);
  1013. +
  1014. +static void rt2860_reset_tx_ring(struct rt2860_softc *sc,
  1015. +   struct rt2860_softc_tx_ring *ring);
  1016. +
  1017. +static void rt2860_free_tx_ring(struct rt2860_softc *sc,
  1018. +   struct rt2860_softc_tx_ring *ring);
  1019. +
  1020. +static void rt2860_dma_map_addr(void *arg, bus_dma_segment_t *segs,
  1021. +   int nseg, int error);
  1022. +
  1023. +static void rt2860_sysctl_attach(struct rt2860_softc *sc);
  1024. +
  1025. +static void rt2860_io_eeprom_shiftout_bits(struct rt2860_softc *sc,
  1026. +   uint16_t val, uint16_t count);
  1027. +
  1028. +static uint16_t rt2860_io_eeprom_shiftin_bits(struct rt2860_softc *sc);
  1029. +
  1030. +static uint8_t rt2860_io_byte_rev(uint8_t byte);
  1031. +
  1032. +static void rt2872_rf_set_chan(struct rt2860_softc *sc,    struct ieee80211_channel *c);
  1033. +
  1034. +/*
  1035. + * Static variables
  1036. + */
  1037. +
  1038. +extern uint8_t rt3052_rf_default[];
  1039. +
  1040. +static const struct rt2860_rf_prog
  1041. +{
  1042. +   uint8_t chan;
  1043. +   uint32_t r1, r2, r3, r4;
  1044. +} rt2860_rf_2850[] =
  1045. +{
  1046. +   {   1, 0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b },
  1047. +   {   2, 0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f },
  1048. +   {   3, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b },
  1049. +   {   4, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f },
  1050. +   {   5, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b },
  1051. +   {   6, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f },
  1052. +   {   7, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b },
  1053. +   {   8, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f },
  1054. +   {   9, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b },
  1055. +   {  10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f },
  1056. +   {  11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b },
  1057. +   {  12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f },
  1058. +   {  13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b },
  1059. +   {  14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193 },
  1060. +   {  36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3 },
  1061. +   {  38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193 },
  1062. +   {  40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183 },
  1063. +   {  44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3 },
  1064. +   {  46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b },
  1065. +   {  48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b },
  1066. +   {  52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193 },
  1067. +   {  54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3 },
  1068. +   {  56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b },
  1069. +   {  60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183 },
  1070. +   {  62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193 },
  1071. +   {  64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3 },
  1072. +   { 100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783 },
  1073. +   { 102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793 },
  1074. +   { 104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3 },
  1075. +   { 108, 0x98402ecc, 0x985c0a32, 0x98578a55, 0x980ed193 },
  1076. +   { 110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183 },
  1077. +   { 112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b },
  1078. +   { 116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3 },
  1079. +   { 118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193 },
  1080. +   { 120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183 },
  1081. +   { 124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193 },
  1082. +   { 126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed15b },
  1083. +   { 128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3 },
  1084. +   { 132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b },
  1085. +   { 134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193 },
  1086. +   { 136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b },
  1087. +   { 140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183 },
  1088. +   { 149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7 },
  1089. +   { 151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187 },
  1090. +   { 153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f },
  1091. +   { 157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f },
  1092. +   { 159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7 },
  1093. +   { 161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187 },
  1094. +   { 165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197 },
  1095. +   { 184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b },
  1096. +   { 188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13 },
  1097. +   { 192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b },
  1098. +   { 196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23 },
  1099. +   { 208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13 },
  1100. +   { 212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b },
  1101. +   { 216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23 },
  1102. +};
  1103. +
  1104. +static const struct rfprog {
  1105. +   uint8_t     chan;
  1106. +   uint32_t    r1, r2, r3, r4;
  1107. +} rt2860_rf2850[] = {
  1108. +   {   1, 0x100bb3, 0x1301e1, 0x05a014, 0x001402 },
  1109. +   {   2, 0x100bb3, 0x1301e1, 0x05a014, 0x001407 },
  1110. +   {   3, 0x100bb3, 0x1301e2, 0x05a014, 0x001402 },
  1111. +   {   4, 0x100bb3, 0x1301e2, 0x05a014, 0x001407 },
  1112. +   {   5, 0x100bb3, 0x1301e3, 0x05a014, 0x001402 },
  1113. +   {   6, 0x100bb3, 0x1301e3, 0x05a014, 0x001407 },
  1114. +   {   7, 0x100bb3, 0x1301e4, 0x05a014, 0x001402 },
  1115. +   {   8, 0x100bb3, 0x1301e4, 0x05a014, 0x001407 },
  1116. +   {   9, 0x100bb3, 0x1301e5, 0x05a014, 0x001402 },
  1117. +   {  10, 0x100bb3, 0x1301e5, 0x05a014, 0x001407 },
  1118. +   {  11, 0x100bb3, 0x1301e6, 0x05a014, 0x001402 },
  1119. +   {  12, 0x100bb3, 0x1301e6, 0x05a014, 0x001407 },
  1120. +   {  13, 0x100bb3, 0x1301e7, 0x05a014, 0x001402 },
  1121. +   {  14, 0x100bb3, 0x1301e8, 0x05a014, 0x001404 },
  1122. +   {  36, 0x100bb3, 0x130266, 0x056014, 0x001408 },
  1123. +   {  38, 0x100bb3, 0x130267, 0x056014, 0x001404 },
  1124. +   {  40, 0x100bb2, 0x1301a0, 0x056014, 0x001400 },
  1125. +   {  44, 0x100bb2, 0x1301a0, 0x056014, 0x001408 },
  1126. +   {  46, 0x100bb2, 0x1301a1, 0x056014, 0x001402 },
  1127. +   {  48, 0x100bb2, 0x1301a1, 0x056014, 0x001406 },
  1128. +   {  52, 0x100bb2, 0x1301a2, 0x056014, 0x001404 },
  1129. +   {  54, 0x100bb2, 0x1301a2, 0x056014, 0x001408 },
  1130. +   {  56, 0x100bb2, 0x1301a3, 0x056014, 0x001402 },
  1131. +   {  60, 0x100bb2, 0x1301a4, 0x056014, 0x001400 },
  1132. +   {  62, 0x100bb2, 0x1301a4, 0x056014, 0x001404 },
  1133. +   {  64, 0x100bb2, 0x1301a4, 0x056014, 0x001408 },
  1134. +   { 100, 0x100bb2, 0x1301ac, 0x05e014, 0x001400 },
  1135. +   { 102, 0x100bb2, 0x1701ac, 0x15e014, 0x001404 },
  1136. +   { 104, 0x100bb2, 0x1701ac, 0x15e014, 0x001408 },
  1137. +   { 108, 0x100bb3, 0x17028c, 0x15e014, 0x001404 },
  1138. +   { 110, 0x100bb3, 0x13028d, 0x05e014, 0x001400 },
  1139. +   { 112, 0x100bb3, 0x13028d, 0x05e014, 0x001406 },
  1140. +   { 116, 0x100bb3, 0x13028e, 0x05e014, 0x001408 },
  1141. +   { 118, 0x100bb3, 0x13028f, 0x05e014, 0x001404 },
  1142. +   { 120, 0x100bb1, 0x1300e0, 0x05e014, 0x001400 },
  1143. +   { 124, 0x100bb1, 0x1300e0, 0x05e014, 0x001404 },
  1144. +   { 126, 0x100bb1, 0x1300e0, 0x05e014, 0x001406 },
  1145. +   { 128, 0x100bb1, 0x1300e0, 0x05e014, 0x001408 },
  1146. +   { 132, 0x100bb1, 0x1300e1, 0x05e014, 0x001402 },
  1147. +   { 134, 0x100bb1, 0x1300e1, 0x05e014, 0x001404 },
  1148. +   { 136, 0x100bb1, 0x1300e1, 0x05e014, 0x001406 },
  1149. +   { 140, 0x100bb1, 0x1300e2, 0x05e014, 0x001400 },
  1150. +   { 149, 0x100bb1, 0x1300e2, 0x05e014, 0x001409 },
  1151. +   { 151, 0x100bb1, 0x1300e3, 0x05e014, 0x001401 },
  1152. +   { 153, 0x100bb1, 0x1300e3, 0x05e014, 0x001403 },
  1153. +   { 157, 0x100bb1, 0x1300e3, 0x05e014, 0x001407 },
  1154. +   { 159, 0x100bb1, 0x1300e3, 0x05e014, 0x001409 },
  1155. +   { 161, 0x100bb1, 0x1300e4, 0x05e014, 0x001401 },
  1156. +   { 165, 0x100bb1, 0x1300e4, 0x05e014, 0x001405 },
  1157. +   { 167, 0x100bb1, 0x1300f4, 0x05e014, 0x001407 },
  1158. +   { 169, 0x100bb1, 0x1300f4, 0x05e014, 0x001409 },
  1159. +   { 171, 0x100bb1, 0x1300f5, 0x05e014, 0x001401 },
  1160. +   { 173, 0x100bb1, 0x1300f5, 0x05e014, 0x001403 }
  1161. +};
  1162. +
  1163. +static const struct rt2860_rf_fi3020
  1164. +{
  1165. +   uint8_t channel, n, r, k;
  1166. +} rt2860_rf_fi3020[] =
  1167. +{
  1168. +   /* 802.11g  */
  1169. +   {1, 241,    2,  2},
  1170. +   {2, 241,    2,  7},
  1171. +   {3, 242,    2,  2},
  1172. +   {4, 242,    2,  7},
  1173. +   {5, 243,    2,  2},
  1174. +   {6, 243,    2,  7},
  1175. +   {7, 244,    2,  2},
  1176. +   {8, 244,    2,  7},
  1177. +   {9, 245,    2,  2},
  1178. +   {10,    245,    2,  7},
  1179. +   {11,    246,    2,  2},
  1180. +   {12,    246,    2,  7},
  1181. +   {13,    247,    2,  2},
  1182. +   {14,    248,    2,  4},
  1183. +
  1184. +   /* 802.11 UNI / HyperLan 2 */
  1185. +   {36,    0x56,   0,  4},
  1186. +   {38,    0x56,   0,  6},
  1187. +   {40,    0x56,   0,  8},
  1188. +   {44,    0x57,   0,  0},
  1189. +   {46,    0x57,   0,  2},
  1190. +   {48,    0x57,   0,  4},
  1191. +   {52,    0x57,   0,  8},
  1192. +   {54,    0x57,   0,  10},
  1193. +   {56,    0x58,   0,  0},
  1194. +   {60,    0x58,   0,  4},
  1195. +   {62,    0x58,   0,  6},
  1196. +   {64,    0x58,   0,  8},
  1197. +
  1198. +   /* 802.11 HyperLan 2 */
  1199. +   {100,   0x5b,   0,  8},
  1200. +   {102,   0x5b,   0,  10},
  1201. +   {104,   0x5c,   0,  0},
  1202. +   {108,   0x5c,   0,  4},
  1203. +   {110,   0x5c,   0,  6},
  1204. +   {112,   0x5c,   0,  8},
  1205. +   {116,   0x5d,   0,  0},
  1206. +   {118,   0x5d,   0,  2},
  1207. +   {120,   0x5d,   0,  4},
  1208. +   {124,   0x5d,   0,  8},
  1209. +   {126,   0x5d,   0,  10},
  1210. +   {128,   0x5e,   0,  0},
  1211. +   {132,   0x5e,   0,  4},
  1212. +   {134,   0x5e,   0,  6},
  1213. +   {136,   0x5e,   0,  8},
  1214. +   {140,   0x5f,   0,  0},
  1215. +
  1216. +   /* 802.11 UNII */
  1217. +   {149,   0x5f,   0,  9},
  1218. +   {151,   0x5f,   0,  11},
  1219. +   {153,   0x60,   0,  1},
  1220. +   {157,   0x60,   0,  5},
  1221. +   {159,   0x60,   0,  7},
  1222. +   {161,   0x60,   0,  9},
  1223. +   {165,   0x61,   0,  1},
  1224. +   {167,   0x61,   0,  3},
  1225. +   {169,   0x61,   0,  5},
  1226. +   {171,   0x61,   0,  7},
  1227. +   {173,   0x61,   0,  9},
  1228. +};
  1229. +
  1230. +static const struct {
  1231. +   uint8_t reg;
  1232. +   uint8_t val;
  1233. +}  rt3090_def_rf[] = {
  1234. +   {  4, 0x40 },
  1235. +   {  5, 0x03 },
  1236. +   {  6, 0x02 },
  1237. +   {  7, 0x70 },
  1238. +   {  9, 0x0f },
  1239. +   { 10, 0x41 },
  1240. +   { 11, 0x21 },
  1241. +   { 12, 0x7b },
  1242. +   { 14, 0x90 },
  1243. +   { 15, 0x58 },
  1244. +   { 16, 0xb3 },
  1245. +   { 17, 0x92 },
  1246. +   { 18, 0x2c },
  1247. +   { 19, 0x02 },
  1248. +   { 20, 0xba },
  1249. +   { 21, 0xdb },
  1250. +   { 24, 0x16 },
  1251. +   { 25, 0x01 },
  1252. +   { 29, 0x1f }
  1253. +};
  1254. +
  1255. +struct {
  1256. +   uint8_t n, r, k;
  1257. +} rt3090_freqs[] = {
  1258. +   { 0xf1, 2,  2 },
  1259. +   { 0xf1, 2,  7 },
  1260. +   { 0xf2, 2,  2 },
  1261. +   { 0xf2, 2,  7 },
  1262. +   { 0xf3, 2,  2 },
  1263. +   { 0xf3, 2,  7 },
  1264. +   { 0xf4, 2,  2 },
  1265. +   { 0xf4, 2,  7 },
  1266. +   { 0xf5, 2,  2 },
  1267. +   { 0xf5, 2,  7 },
  1268. +   { 0xf6, 2,  2 },
  1269. +   { 0xf6, 2,  7 },
  1270. +   { 0xf7, 2,  2 },
  1271. +   { 0xf8, 2,  4 },
  1272. +   { 0x56, 0,  4 },
  1273. +   { 0x56, 0,  6 },
  1274. +   { 0x56, 0,  8 },
  1275. +   { 0x57, 0,  0 },
  1276. +   { 0x57, 0,  2 },
  1277. +   { 0x57, 0,  4 },
  1278. +   { 0x57, 0,  8 },
  1279. +   { 0x57, 0, 10 },
  1280. +   { 0x58, 0,  0 },
  1281. +   { 0x58, 0,  4 },
  1282. +   { 0x58, 0,  6 },
  1283. +   { 0x58, 0,  8 },
  1284. +   { 0x5b, 0,  8 },
  1285. +   { 0x5b, 0, 10 },
  1286. +   { 0x5c, 0,  0 },
  1287. +   { 0x5c, 0,  4 },
  1288. +   { 0x5c, 0,  6 },
  1289. +   { 0x5c, 0,  8 },
  1290. +   { 0x5d, 0,  0 },
  1291. +   { 0x5d, 0,  2 },
  1292. +   { 0x5d, 0,  4 },
  1293. +   { 0x5d, 0,  8 },
  1294. +   { 0x5d, 0, 10 },
  1295. +   { 0x5e, 0,  0 },
  1296. +   { 0x5e, 0,  4 },
  1297. +   { 0x5e, 0,  6 },
  1298. +   { 0x5e, 0,  8 },
  1299. +   { 0x5f, 0,  0 },
  1300. +   { 0x5f, 0,  9 },
  1301. +   { 0x5f, 0, 11 },
  1302. +   { 0x60, 0,  1 },
  1303. +   { 0x60, 0,  5 },
  1304. +   { 0x60, 0,  7 },
  1305. +   { 0x60, 0,  9 },
  1306. +   { 0x61, 0,  1 },
  1307. +   { 0x61, 0,  3 },
  1308. +   { 0x61, 0,  5 },
  1309. +   { 0x61, 0,  7 },
  1310. +   { 0x61, 0,  9 }
  1311. +};
  1312. +
  1313. +/* #ifdef RT305X_SOC */
  1314. +static const uint16_t rt3052_eeprom[] =
  1315. +{
  1316. +   0x3052, 0x0101, 0x0c00, 0x3043, 0x8852, 0xffff, 0xffff, 0xffff,
  1317. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1318. +   0xffff, 0xffff, 0xffff, 0xffff, 0x0c00, 0x3043, 0x7752, 0x0c00,
  1319. +   0x3043, 0x6652, 0x0822, 0x0024, 0xffff, 0x012f, 0x7755, 0xaaa8,
  1320. +   0x888c, 0xffff, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff,
  1321. +   0xffff, 0x0d0d, 0x0d0d, 0x0c0c, 0x0c0c, 0x0c0c, 0x0c0c, 0x0c0c,
  1322. +   0x1010, 0x1111, 0x1211, 0x1212, 0x1313, 0x1413, 0x1414, 0xffff,
  1323. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1324. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1325. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1326. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1327. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1328. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1329. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x6666,
  1330. +   0xaacc, 0x6688, 0xaacc, 0x6688, 0xaacc, 0x6688, 0xaacc, 0x6688,
  1331. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1332. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1333. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1334. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1335. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1336. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1337. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1338. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1339. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1340. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1341. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1342. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1343. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1344. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1345. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1346. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1347. +   0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  1348. +};
  1349. +
  1350. +uint8_t rt3052_rf_default[] = {
  1351. +   0x50,
  1352. +   0x01,
  1353. +   0xF7,
  1354. +   0x75,
  1355. +   0x40,
  1356. +   0x03,
  1357. +   0x42,
  1358. +   0x50,
  1359. +   0x39,
  1360. +   0x0F,
  1361. +   0x60,
  1362. +   0x21,
  1363. +   0x75,
  1364. +   0x75,
  1365. +   0x90,
  1366. +   0x58,
  1367. +   0xB3,
  1368. +   0x92,
  1369. +   0x2C,
  1370. +   0x02,
  1371. +   0xBA,
  1372. +   0xDB,
  1373. +   0x00,
  1374. +   0x31,
  1375. +   0x08,
  1376. +   0x01,
  1377. +   0x25, /* Core Power: 0x25=1.25V */
  1378. +   0x23, /* RF: 1.35V */
  1379. +       0x13, /* ADC: must consist with R27 */
  1380. +   0x83,
  1381. +   0x00,
  1382. +   0x00,
  1383. +};
  1384. +/* #endif */
  1385. +
  1386. +static const uint16_t rt2860_io_ccitt16[] =
  1387. +{
  1388. +   0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
  1389. +   0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
  1390. +   0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
  1391. +   0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
  1392. +   0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
  1393. +   0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
  1394. +   0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
  1395. +   0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
  1396. +   0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
  1397. +   0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
  1398. +   0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
  1399. +   0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
  1400. +   0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
  1401. +   0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
  1402. +   0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
  1403. +   0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
  1404. +   0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
  1405. +   0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
  1406. +   0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
  1407. +   0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
  1408. +   0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
  1409. +   0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
  1410. +   0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
  1411. +   0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
  1412. +   0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
  1413. +   0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
  1414. +   0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
  1415. +   0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
  1416. +   0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
  1417. +   0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
  1418. +   0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
  1419. +   0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
  1420. +};
  1421. +
  1422. +static const struct
  1423. +{
  1424. +   uint32_t reg;
  1425. +   uint32_t val;
  1426. +} rt2860_def_mac[] =
  1427. +{
  1428. +   { RT2860_REG_PBF_BCN_OFFSET0,           0xf8f0e8e0 },
  1429. +   { RT2860_REG_PBF_BCN_OFFSET1,           0x6f77d0c8 },
  1430. +   { RT2860_REG_LEGACY_BASIC_RATE,         0x0000013f },
  1431. +   { RT2860_REG_HT_BASIC_RATE,             0x00008003 },
  1432. +   { RT2860_REG_SYS_CTRL,                  0x00000000 },
  1433. +   { RT2860_REG_RX_FILTER_CFG,             0x00017f97 },
  1434. +   { RT2860_REG_BKOFF_SLOT_CFG,            0x00000209 },
  1435. +   { RT2860_REG_TX_SW_CFG0,                0x00000000 },
  1436. +   { RT2860_REG_TX_SW_CFG1,                0x00080606 },
  1437. +   { RT2860_REG_TX_LINK_CFG,               0x00001020 },
  1438. +   { RT2860_REG_TX_TIMEOUT_CFG,            0x000a2090 },
  1439. +   { RT2860_REG_MAX_LEN_CFG,               (1 << 12) | RT2860_MAX_AGG_SIZE },
  1440. +   { RT2860_REG_LED_CFG,                   0x7f031e46 },
  1441. +   { RT2860_REG_PBF_MAX_PCNT,              0x1f3fbf9f },
  1442. +   { RT2860_REG_TX_RTY_CFG,                0x47d01f0f },
  1443. +   { RT2860_REG_AUTO_RSP_CFG,              0x00000013 },
  1444. +   { RT2860_REG_TX_CCK_PROT_CFG,           0x05740003 },
  1445. +   { RT2860_REG_TX_OFDM_PROT_CFG,          0x05740003 },
  1446. +   { RT2860_REG_TX_GF20_PROT_CFG,          0x01744004 },
  1447. +   { RT2860_REG_TX_GF40_PROT_CFG,          0x03f44084 },
  1448. +   { RT2860_REG_TX_MM20_PROT_CFG,          0x01744004 },
  1449. +   { RT2860_REG_TX_MM40_PROT_CFG,          0x03f54084 },
  1450. +   { RT2860_REG_TX_TXOP_CTRL_CFG,          0x0000583f },
  1451. +   { RT2860_REG_TX_RTS_CFG,                0x00092b20 },
  1452. +   { RT2860_REG_TX_EXP_ACK_TIME,           0x002400ca },
  1453. +   { RT2860_REG_HCCAPSMP_TXOP_HLDR_ET,     0x00000002 },
  1454. +   { RT2860_REG_XIFS_TIME_CFG,             0x33a41010 },
  1455. +   { RT2860_REG_PWR_PIN_CFG,               0x00000003 },
  1456. +   { RT2860_REG_SCHDMA_WMM_AIFSN_CFG,      0x00002273 },
  1457. +   { RT2860_REG_SCHDMA_WMM_CWMIN_CFG,      0x00002344 },
  1458. +   { RT2860_REG_SCHDMA_WMM_CWMAX_CFG,      0x000034aa },
  1459. +};
  1460. +
  1461. +#define RT2860_DEF_MAC_SIZE        (sizeof(rt2860_def_mac) / sizeof(rt2860_def_mac[0]))
  1462. +
  1463. +static const struct
  1464. +{
  1465. +   uint8_t reg;
  1466. +   uint8_t val;
  1467. +} rt2860_def_bbp[] =
  1468. +{
  1469. +   { 65,   0x2c },
  1470. +   { 66,   0x38 },
  1471. +   { 69,   0x12 },
  1472. +   { 70,   0x0a },
  1473. +   { 73,   0x10 },
  1474. +   { 81,   0x37 },
  1475. +   { 82,   0x62 },
  1476. +   { 83,   0x6a },
  1477. +   { 84,   0x99 },
  1478. +   { 86,   0x00 },
  1479. +   { 91,   0x04 },
  1480. +   { 92,   0x00 },
  1481. +   { 103,  0x00 },
  1482. +   { 105,  0x05 },
  1483. +   { 106,  0x35 },
  1484. +};
  1485. +
  1486. +#define RT2860_DEF_BBP_SIZE        (sizeof(rt2860_def_bbp) / sizeof(rt2860_def_bbp[0]))
  1487. +
  1488. +SYSCTL_NODE(_hw, OID_AUTO, rt2860, CTLFLAG_RD, 0, "RT2860 driver parameters");
  1489. +
  1490. +static int rt2860_tx_stbc = 1;
  1491. +SYSCTL_INT(_hw_rt2860, OID_AUTO, tx_stbc, CTLFLAG_RW, &rt2860_tx_stbc, 0, "RT2860 Tx STBC");
  1492. +TUNABLE_INT("hw.ral.2860_stbc", &rt2860_tx_stbc);
  1493. +
  1494. +#ifdef RT2860_DEBUG
  1495. +static int rt2860_debug = 0;
  1496. +SYSCTL_INT(_hw_rt2860, OID_AUTO, debug, CTLFLAG_RW, &rt2860_debug, 0, "RT2860 debug level");
  1497. +TUNABLE_INT("hw.ral.2860_debug", &rt2860_debug);
  1498. +#endif
  1499. +
  1500. +/*
  1501. + *  Core Functions
  1502. + */
  1503. +
  1504. +/*
  1505. + * rt2860_attach
  1506. + */
  1507. +int rt2860_attach(device_t dev, int id)
  1508. +{
  1509. +   struct rt2860_softc *sc;
  1510. +   struct ifnet *ifp;
  1511. +   struct ieee80211com *ic;
  1512. +   int error, ntries, i;
  1513. +
  1514. +   sc = device_get_softc(dev);
  1515. +   sc->sc_id = id;
  1516. +   sc->sc_dev = dev;
  1517. +
  1518. +   mtx_init(&sc->sc_mtx, device_get_nameunit(dev),
  1519. +       MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE);
  1520. +
  1521. +
  1522. +   /* done already, I believe */
  1523. +/*
  1524. +   sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
  1525. +       &sc->mem_rid, RF_ACTIVE);
  1526. +
  1527. +   if (sc->mem == NULL)
  1528. +   {
  1529. +       printf("%s: invalid memory resource\n",
  1530. +           device_get_nameunit(dev));
  1531. +       error = ENXIO;
  1532. +       goto fail;
  1533. +   }
  1534. +
  1535. +   sc->sc_st = rman_get_bustag(sc->mem);
  1536. +   sc->sc_sh = rman_get_bushandle(sc->mem);
  1537. +
  1538. +   sc->irq_rid = 0;
  1539. +   sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
  1540. +       &sc->irq_rid, RF_ACTIVE | RF_SHAREABLE);
  1541. +*/
  1542. +
  1543. +/*
  1544. +   if (sc->irq == NULL)
  1545. +
  1546. +   {
  1547. +
  1548. +       printf("%s: invalid IRQ resource\n",
  1549. +
  1550. +           device_get_nameunit(dev));
  1551. +       error = ENXIO;
  1552. +       goto fail;
  1553. +   }
  1554. +*/
  1555. +   sc->tx_stbc = rt2860_tx_stbc;
  1556. +
  1557. +#ifdef RT2860_DEBUG
  1558. +   sc->debug = rt2860_debug;
  1559. +
  1560. +   SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
  1561. +       SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
  1562. +       "debug", CTLFLAG_RW, &sc->debug, 0, "rt2860 debug level");
  1563. +#endif
  1564. +
  1565. +   RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  1566. +       "%s: attaching\n",
  1567. +       device_get_nameunit(sc->sc_dev));
  1568. +
  1569. +   /* wait for NIC to initialize */
  1570. +
  1571. +   for (ntries = 0; ntries < 1000; ntries++)
  1572. +   {
  1573. +       sc->mac_rev = rt2860_io_mac_read(sc, RT2860_REG_MAC_CSR0);
  1574. +       if (sc->mac_rev != 0x00000000 && sc->mac_rev != 0xffffffff)
  1575. +           break;
  1576. +
  1577. +       DELAY(10);
  1578. +   }
  1579. +
  1580. +   if (ntries == 1000)
  1581. +   {
  1582. +       printf("%s: timeout waiting for NIC to initialize\n",
  1583. +           device_get_nameunit(dev));
  1584. +       error = EIO;
  1585. +       goto fail;
  1586. +   }
  1587. +
  1588. +   rt2860_read_eeprom(sc);
  1589. +
  1590. +   printf("%s: MAC/BBP RT2860 (rev 0x%08x), RF %s\n",
  1591. +       device_get_nameunit(sc->sc_dev), sc->mac_rev,
  1592. +       rt2860_rf_name(sc->rf_rev));
  1593. +
  1594. +   /* clear key tables */
  1595. +
  1596. +   rt2860_asic_clear_keytables(sc);
  1597. +
  1598. +   /* allocate Tx and Rx rings */
  1599. +
  1600. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  1601. +   {
  1602. +       error = rt2860_alloc_tx_ring(sc, &sc->tx_ring[i], i);
  1603. +       if (error != 0)
  1604. +       {
  1605. +           printf("%s: could not allocate Tx ring #%d\n",
  1606. +               device_get_nameunit(sc->sc_dev), i);
  1607. +           goto fail;
  1608. +       }
  1609. +   }
  1610. +
  1611. +   sc->tx_ring_mgtqid = 5;
  1612. +
  1613. +   error = rt2860_alloc_rx_ring(sc, &sc->rx_ring);
  1614. +   if (error != 0)
  1615. +   {
  1616. +       printf("%s: could not allocate Rx ring\n",
  1617. +           device_get_nameunit(sc->sc_dev));
  1618. +       goto fail;
  1619. +   }
  1620. +
  1621. +   callout_init(&sc->periodic_ch, 0);
  1622. +   callout_init_mtx(&sc->tx_watchdog_ch, &sc->sc_mtx, 0);
  1623. +
  1624. +   ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
  1625. +   if (ifp == NULL)
  1626. +   {
  1627. +       printf("%s: could not if_alloc()\n",
  1628. +           device_get_nameunit(sc->sc_dev));
  1629. +       error = ENOMEM;
  1630. +       goto fail;
  1631. +   }
  1632. +
  1633. +   ifp->if_softc = sc;
  1634. +
  1635. +   if_initname(ifp, device_get_name(dev), device_get_unit(sc->sc_dev));
  1636. +
  1637. +   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
  1638. +
  1639. +   ifp->if_init = rt2860_init;
  1640. +   ifp->if_ioctl = rt2860_ioctl;
  1641. +   ifp->if_start = rt2860_start;
  1642. +
  1643. +   IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
  1644. +   ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
  1645. +   IFQ_SET_READY(&ifp->if_snd);
  1646. +
  1647. +   ic = ifp->if_l2com;
  1648. +
  1649. +   ic->ic_ifp = ifp;
  1650. +
  1651. +   ic->ic_phytype = IEEE80211_T_HT;
  1652. +   ic->ic_opmode = IEEE80211_M_STA;
  1653. +
  1654. +   ic->ic_caps = IEEE80211_C_MONITOR |
  1655. +       IEEE80211_C_IBSS |
  1656. +       IEEE80211_C_STA |
  1657. +       IEEE80211_C_AHDEMO |
  1658. +       IEEE80211_C_HOSTAP |
  1659. +       IEEE80211_C_WDS |
  1660. +       IEEE80211_C_MBSS |
  1661. +       IEEE80211_C_BGSCAN |
  1662. +       IEEE80211_C_TXPMGT |
  1663. +       IEEE80211_C_SHPREAMBLE |
  1664. +       IEEE80211_C_SHSLOT |
  1665. +       IEEE80211_C_TXFRAG |
  1666. +       IEEE80211_C_BURST |
  1667. +       IEEE80211_C_WME |
  1668. +       IEEE80211_C_WPA;
  1669. +
  1670. +   ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP |
  1671. +       IEEE80211_CRYPTO_TKIP |
  1672. +       IEEE80211_CRYPTO_TKIPMIC |
  1673. +       IEEE80211_CRYPTO_AES_CCM;
  1674. +
  1675. +   ic->ic_htcaps = IEEE80211_HTC_HT |
  1676. +       IEEE80211_HTC_AMSDU |                   /* A-MSDU Tx */
  1677. +       IEEE80211_HTC_AMPDU |                   /* A-MPDU Tx */
  1678. +       IEEE80211_HTC_SMPS |                    /* MIMO power save */
  1679. +       IEEE80211_HTCAP_MAXAMSDU_3839 |         /* max. A-MSDU Rx length */
  1680. +       IEEE80211_HTCAP_CHWIDTH40 |             /* HT 40MHz channel width */
  1681. +       IEEE80211_HTCAP_GREENFIELD |            /* HT greenfield */
  1682. +       IEEE80211_HTCAP_SHORTGI20 |             /* HT 20MHz short GI */
  1683. +       IEEE80211_HTCAP_SHORTGI40 |             /* HT 40MHz short GI */
  1684. +       IEEE80211_HTCAP_SMPS_OFF;               /* MIMO power save disabled */
  1685. +
  1686. +   /* spatial streams */
  1687. +
  1688. +   if (sc->nrxpath == 2)
  1689. +       ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_2STREAM;
  1690. +   else if (sc->nrxpath == 3)
  1691. +       ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_3STREAM;
  1692. +   else
  1693. +       ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_1STREAM;
  1694. +
  1695. +   if (sc->ntxpath > 1)
  1696. +       ic->ic_htcaps |= IEEE80211_HTCAP_TXSTBC;
  1697. +
  1698. +   /* delayed BA */
  1699. +
  1700. +   if (sc->mac_rev != 0x28600100)
  1701. +       ic->ic_htcaps |= IEEE80211_HTCAP_DELBA;
  1702. +
  1703. +   /* init channels */
  1704. +
  1705. +   ic->ic_nchans = 0;
  1706. +
  1707. +   rt2860_init_channels(sc);
  1708. +
  1709. +   rt2860_init_channels_ht40(sc);
  1710. +
  1711. +   ieee80211_ifattach(ic, sc->mac_addr);
  1712. +
  1713. +   ic->ic_vap_create = rt2860_vap_create;
  1714. +   ic->ic_vap_delete = rt2860_vap_delete;
  1715. +
  1716. +   ic->ic_node_alloc = rt2860_node_alloc;
  1717. +
  1718. +   sc->node_cleanup = ic->ic_node_cleanup;
  1719. +   ic->ic_node_cleanup = rt2860_node_cleanup;
  1720. +
  1721. +   ic->ic_node_getmimoinfo = rt2860_node_getmimoinfo;
  1722. +   ic->ic_setregdomain = rt2860_setregdomain;
  1723. +   ic->ic_getradiocaps = rt2860_getradiocaps;
  1724. +   ic->ic_scan_start = rt2860_scan_start;
  1725. +   ic->ic_scan_end = rt2860_scan_end;
  1726. +   ic->ic_set_channel = rt2860_set_channel;
  1727. +   ic->ic_newassoc = rt2860_newassoc;
  1728. +   ic->ic_updateslot = rt2860_updateslot;
  1729. +   ic->ic_update_promisc = rt2860_update_promisc;
  1730. +   ic->ic_update_mcast = rt2860_update_mcast;
  1731. +   ic->ic_wme.wme_update = rt2860_wme_update;
  1732. +   ic->ic_raw_xmit = rt2860_raw_xmit;
  1733. +
  1734. +   sc->recv_action = ic->ic_recv_action;
  1735. +   ic->ic_recv_action = rt2860_recv_action;
  1736. +
  1737. +   sc->send_action = ic->ic_send_action;
  1738. +   ic->ic_send_action = rt2860_send_action;
  1739. +
  1740. +   sc->addba_response = ic->ic_addba_response;
  1741. +   ic->ic_addba_response = rt2860_addba_response;
  1742. +
  1743. +   sc->addba_stop = ic->ic_addba_stop;
  1744. +   ic->ic_addba_stop = rt2860_addba_stop;
  1745. +
  1746. +   sc->ampdu_rx_start = ic->ic_ampdu_rx_start;
  1747. +   ic->ic_ampdu_rx_start = rt2860_ampdu_rx_start;
  1748. +
  1749. +   sc->ampdu_rx_stop = ic->ic_ampdu_rx_stop;
  1750. +   ic->ic_ampdu_rx_stop = rt2860_ampdu_rx_stop;
  1751. +
  1752. +   /* hardware requires padding between 802.11 frame header and body */
  1753. +
  1754. +   ic->ic_flags |= IEEE80211_F_DATAPAD | IEEE80211_F_DOTH;
  1755. +
  1756. +
  1757. +   ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS;
  1758. +
  1759. +   ieee80211_radiotap_attach(ic,
  1760. +       &sc->txtap.ihdr, sizeof(sc->txtap),
  1761. +       RT2860_SOFTC_TX_RADIOTAP_PRESENT,
  1762. +       &sc->rxtap.ihdr, sizeof(sc->rxtap),
  1763. +       RT2860_SOFTC_RX_RADIOTAP_PRESENT);
  1764. +
  1765. +   /* init task queue */
  1766. +
  1767. +   TASK_INIT(&sc->rx_done_task, 0, rt2860_rx_done_task, sc);
  1768. +   TASK_INIT(&sc->tx_done_task, 0, rt2860_tx_done_task, sc);
  1769. +   TASK_INIT(&sc->fifo_sta_full_task, 0, rt2860_fifo_sta_full_task, sc);
  1770. +   TASK_INIT(&sc->periodic_task, 0, rt2860_periodic_task, sc);
  1771. +
  1772. +   sc->rx_process_limit = 100;
  1773. +
  1774. +   sc->taskqueue = taskqueue_create("rt2860_taskq", M_NOWAIT,
  1775. +       taskqueue_thread_enqueue, &sc->taskqueue);
  1776. +
  1777. +   taskqueue_start_threads(&sc->taskqueue, 1, PI_NET, "%s taskq",
  1778. +       device_get_nameunit(sc->sc_dev));
  1779. +
  1780. +   rt2860_sysctl_attach(sc);
  1781. +
  1782. +   if (bootverbose)
  1783. +       ieee80211_announce(ic);
  1784. +
  1785. +   /* set up interrupt */
  1786. +   /* AGain, already handled
  1787. +   error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
  1788. +       NULL, rt2860_intr, sc, &sc->irqh);
  1789. +   if (error != 0)
  1790. +
  1791. +   {
  1792. +       printf("%s: could not set up interrupt\n",
  1793. +           device_get_nameunit(dev));
  1794. +       goto fail;
  1795. +   }
  1796. +
  1797. +   */
  1798. +   return 0;
  1799. +
  1800. +fail:
  1801. +
  1802. +   /* free Tx and Rx rings */
  1803. +
  1804. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  1805. +       rt2860_free_tx_ring(sc, &sc->tx_ring[i]);
  1806. +
  1807. +   rt2860_free_rx_ring(sc, &sc->rx_ring);
  1808. +
  1809. +   mtx_destroy(&sc->sc_mtx);
  1810. +/*
  1811. +
  1812. +   if (sc->mem != NULL)
  1813. +       bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem);
  1814. +
  1815. +   if (sc->irq != NULL)
  1816. +       bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
  1817. +
  1818. +*/
  1819. +   return error;
  1820. +}
  1821. +
  1822. +
  1823. +/*
  1824. +
  1825. + * rt2860_detach
  1826. + */
  1827. +int rt2860_detach(void *xsc)
  1828. +{
  1829. +   struct rt2860_softc *sc = xsc;
  1830. +   struct ifnet *ifp;
  1831. +   struct ieee80211com *ic;
  1832. +   int i;
  1833. +
  1834. +   ifp = sc->sc_ifp;
  1835. +   ic = ifp->if_l2com;
  1836. +
  1837. +   RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  1838. +       "ral2860 detach");
  1839. +
  1840. +   RT2860_SOFTC_LOCK(sc);
  1841. +
  1842. +   ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
  1843. +
  1844. +   callout_stop(&sc->periodic_ch);
  1845. +   callout_stop(&sc->tx_watchdog_ch);
  1846. +
  1847. +   taskqueue_drain(sc->taskqueue, &sc->rx_done_task);
  1848. +   taskqueue_drain(sc->taskqueue, &sc->tx_done_task);
  1849. +   taskqueue_drain(sc->taskqueue, &sc->fifo_sta_full_task);
  1850. +   taskqueue_drain(sc->taskqueue, &sc->periodic_task);
  1851. +
  1852. +   /* free Tx and Rx rings */
  1853. +
  1854. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  1855. +       rt2860_free_tx_ring(sc, &sc->tx_ring[i]);
  1856. +
  1857. +   rt2860_free_rx_ring(sc, &sc->rx_ring);
  1858. +
  1859. +   RT2860_SOFTC_UNLOCK(sc);
  1860. +
  1861. +   ieee80211_ifdetach(ic);
  1862. +
  1863. +   if_free(ifp);
  1864. +
  1865. +   taskqueue_free(sc->taskqueue);
  1866. +
  1867. +   mtx_destroy(&sc->sc_mtx);
  1868. +/*
  1869. + * Handled by RAL overlords
  1870. + */
  1871. +/*
  1872. +
  1873. +   bus_generic_detach(sc->sc_dev);
  1874. +
  1875. +   bus_teardown_intr(sc->sc_dev, sc->irq, sc->irqh);
  1876. +
  1877. +   bus_release_resource(sc->sc_dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
  1878. +
  1879. +
  1880. +   bus_release_resource(sc->sc_dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem);
  1881. +*/
  1882. +   return 0;
  1883. +}
  1884. +
  1885. +/*
  1886. + * rt2860_shutdown
  1887. + */
  1888. +void rt2860_shutdown(void *xsc)
  1889. +{
  1890. +   struct rt2860_softc *sc = xsc;
  1891. +
  1892. +   RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  1893. +       "%s: shutting down\n",
  1894. +       device_get_nameunit(sc->sc_dev));
  1895. +
  1896. +   rt2860_stop(sc);
  1897. +
  1898. +   sc->flags &= ~RT2860_SOFTC_FLAGS_UCODE_LOADED;
  1899. +}
  1900. +
  1901. +/*
  1902. + * rt2860_suspend
  1903. +
  1904. + */
  1905. +void rt2860_suspend(void *xsc)
  1906. +{
  1907. +   struct rt2860_softc *sc = xsc;
  1908. +
  1909. +
  1910. +   RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  1911. +       "%s: suspending\n",
  1912. +       device_get_nameunit(sc->sc_dev));
  1913. +
  1914. +
  1915. +   rt2860_stop(sc);
  1916. +
  1917. +   sc->flags &= ~RT2860_SOFTC_FLAGS_UCODE_LOADED;
  1918. +}
  1919. +
  1920. +/*
  1921. + * rt2860_resume
  1922. + */
  1923. +void rt2860_resume(void *xsc)
  1924. +{
  1925. +   struct rt2860_softc *sc = xsc;
  1926. +   struct ifnet *ifp;
  1927. +
  1928. +   ifp = sc->sc_ifp;
  1929. +
  1930. +   RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  1931. +       "%s: resuming\n",
  1932. +       device_get_nameunit(sc->sc_dev));
  1933. +
  1934. +   if (ifp->if_flags & IFF_UP)
  1935. +       rt2860_init(sc);
  1936. +
  1937. +}
  1938. +
  1939. +
  1940. +/*
  1941. + * rt2860_init_channels
  1942. + */
  1943. +static void rt2860_init_channels(struct rt2860_softc *sc)
  1944. +{
  1945. +   struct ifnet *ifp;
  1946. +   struct ieee80211com *ic;
  1947. +   struct ieee80211_channel *c;
  1948. +   int i, flags;
  1949. +
  1950. +   ifp = sc->sc_ifp;
  1951. +   ic = ifp->if_l2com;
  1952. +
  1953. +   /* set supported channels for 2GHz band */
  1954. +
  1955. +   for (i = 1; i <= 14; i++)
  1956. +   {
  1957. +       c = &ic->ic_channels[ic->ic_nchans++];
  1958. +       flags = IEEE80211_CHAN_B;
  1959. +
  1960. +       c->ic_freq = ieee80211_ieee2mhz(i, flags);
  1961. +       c->ic_ieee = i;
  1962. +       c->ic_flags = flags;
  1963. +
  1964. +       c = &ic->ic_channels[ic->ic_nchans++];
  1965. +       flags = IEEE80211_CHAN_B | IEEE80211_CHAN_HT20;
  1966. +
  1967. +       c->ic_freq = ieee80211_ieee2mhz(i, flags);
  1968. +       c->ic_ieee = i;
  1969. +       c->ic_flags = flags;
  1970. +
  1971. +       c = &ic->ic_channels[ic->ic_nchans++];
  1972. +       flags = IEEE80211_CHAN_G;
  1973. +
  1974. +       c->ic_freq = ieee80211_ieee2mhz(i, flags);
  1975. +       c->ic_ieee = i;
  1976. +       c->ic_flags = flags;
  1977. +
  1978. +       c = &ic->ic_channels[ic->ic_nchans++];
  1979. +       flags = IEEE80211_CHAN_G | IEEE80211_CHAN_HT20;
  1980. +
  1981. +       c->ic_freq = ieee80211_ieee2mhz(i, flags);
  1982. +       c->ic_ieee = i;
  1983. +       c->ic_flags = flags;
  1984. +   }
  1985. +
  1986. +   /* set supported channels for 5GHz band */
  1987. +
  1988. +   if (sc->rf_rev == RT2860_EEPROM_RF_2850 ||
  1989. +       sc->rf_rev == RT2860_EEPROM_RF_2750 ||
  1990. +       sc->rf_rev == RT2860_EEPROM_RF_3052)
  1991. +   {
  1992. +       for (i = 36; i <= 64; i += 4)
  1993. +       {
  1994. +           c = &ic->ic_channels[ic->ic_nchans++];
  1995. +           flags = IEEE80211_CHAN_A;
  1996. +
  1997. +           c->ic_freq = ieee80211_ieee2mhz(i, flags);
  1998. +           c->ic_ieee = i;
  1999. +           c->ic_flags = flags;
  2000. +
  2001. +           c = &ic->ic_channels[ic->ic_nchans++];
  2002. +           flags = IEEE80211_CHAN_A | IEEE80211_CHAN_HT20;
  2003. +
  2004. +           c->ic_freq = ieee80211_ieee2mhz(i, flags);
  2005. +           c->ic_ieee = i;
  2006. +           c->ic_flags = flags;
  2007. +       }
  2008. +
  2009. +       for (i = 100; i <= 140; i += 4)
  2010. +       {
  2011. +           c = &ic->ic_channels[ic->ic_nchans++];
  2012. +           flags = IEEE80211_CHAN_A;
  2013. +
  2014. +           c->ic_freq = ieee80211_ieee2mhz(i, flags);
  2015. +           c->ic_ieee = i;
  2016. +           c->ic_flags = flags;
  2017. +
  2018. +           c = &ic->ic_channels[ic->ic_nchans++];
  2019. +           flags = IEEE80211_CHAN_A | IEEE80211_CHAN_HT20;
  2020. +
  2021. +           c->ic_freq = ieee80211_ieee2mhz(i, flags);
  2022. +
  2023. +           c->ic_ieee = i;
  2024. +           c->ic_flags = flags;
  2025. +       }
  2026. +
  2027. +       for (i = 149; i <= 165; i += 4)
  2028. +       {
  2029. +           c = &ic->ic_channels[ic->ic_nchans++];
  2030. +           flags = IEEE80211_CHAN_A;
  2031. +
  2032. +           c->ic_freq = ieee80211_ieee2mhz(i, flags);
  2033. +           c->ic_ieee = i;
  2034. +           c->ic_flags = flags;
  2035. +
  2036. +           c = &ic->ic_channels[ic->ic_nchans++];
  2037. +           flags = IEEE80211_CHAN_A | IEEE80211_CHAN_HT20;
  2038. +
  2039. +           c->ic_freq = ieee80211_ieee2mhz(i, flags);
  2040. +           c->ic_ieee = i;
  2041. +           c->ic_flags = flags;
  2042. +       }
  2043. +   }
  2044. +}
  2045. +
  2046. +/*
  2047. + * rt2860_init_channels_ht40
  2048. + */
  2049. +static void rt2860_init_channels_ht40(struct rt2860_softc *sc)
  2050. +{
  2051. +   struct ifnet *ifp;
  2052. +   struct ieee80211com *ic;
  2053. +   struct ieee80211_channel *c, *cent, *ext;
  2054. +   int i, flags;
  2055. +
  2056. +   ifp = sc->sc_ifp;
  2057. +   ic = ifp->if_l2com;
  2058. +
  2059. +   /* set supported channels for 2GHz band */
  2060. +
  2061. +   for (i = 1; i <= 14; i++)
  2062. +   {
  2063. +       flags = IEEE80211_CHAN_G | IEEE80211_CHAN_HT40;
  2064. +
  2065. +       /* find the center channel */
  2066. +
  2067. +       cent = ieee80211_find_channel_byieee(ic, i,
  2068. +           flags & ~IEEE80211_CHAN_HT);
  2069. +       if (cent == NULL)
  2070. +       {
  2071. +           printf("%s: skip channel %d, could not find center channel\n",
  2072. +               device_get_nameunit(sc->sc_dev), i);
  2073. +           continue;
  2074. +       }
  2075. +
  2076. +       /* find the extension channel */
  2077. +
  2078. +       ext = ieee80211_find_channel(ic, cent->ic_freq + 20,
  2079. +           flags & ~IEEE80211_CHAN_HT);
  2080. +       if (ext == NULL)
  2081. +       {
  2082. +           printf("%s: skip channel %d, could not find extension channel\n",
  2083. +               device_get_nameunit(sc->sc_dev), i);
  2084. +           continue;
  2085. +       }
  2086. +
  2087. +       c = &ic->ic_channels[ic->ic_nchans++];
  2088. +
  2089. +       *c = *cent;
  2090. +       c->ic_extieee = ext->ic_ieee;
  2091. +       c->ic_flags &= ~IEEE80211_CHAN_HT;
  2092. +       c->ic_flags |= IEEE80211_CHAN_HT40U;
  2093. +
  2094. +       c = &ic->ic_channels[ic->ic_nchans++];
  2095. +
  2096. +       *c = *ext;
  2097. +       c->ic_extieee = cent->ic_ieee;
  2098. +       c->ic_flags &= ~IEEE80211_CHAN_HT;
  2099. +       c->ic_flags |= IEEE80211_CHAN_HT40D;
  2100. +   }
  2101. +
  2102. +   /* set supported channels for 5GHz band */
  2103. +
  2104. +   if (sc->rf_rev == RT2860_EEPROM_RF_2850 ||
  2105. +       sc->rf_rev == RT2860_EEPROM_RF_2750 ||
  2106. +       sc->rf_rev == RT2860_EEPROM_RF_3052)
  2107. +   {
  2108. +       for (i = 36; i <= 64; i += 4)
  2109. +       {
  2110. +           flags = IEEE80211_CHAN_A | IEEE80211_CHAN_HT40;
  2111. +
  2112. +           /* find the center channel */
  2113. +
  2114. +           cent = ieee80211_find_channel_byieee(ic, i,
  2115. +               flags & ~IEEE80211_CHAN_HT);
  2116. +           if (cent == NULL)
  2117. +           {
  2118. +               printf("%s: skip channel %d, could not find center channel\n",
  2119. +                   device_get_nameunit(sc->sc_dev), i);
  2120. +               continue;
  2121. +           }
  2122. +
  2123. +           /* find the extension channel */
  2124. +
  2125. +           ext = ieee80211_find_channel(ic, cent->ic_freq + 20,
  2126. +               flags & ~IEEE80211_CHAN_HT);
  2127. +           if (ext == NULL)
  2128. +           {
  2129. +               printf("%s: skip channel %d, could not find extension channel\n",
  2130. +                   device_get_nameunit(sc->sc_dev), i);
  2131. +               continue;
  2132. +           }
  2133. +
  2134. +           c = &ic->ic_channels[ic->ic_nchans++];
  2135. +
  2136. +           *c = *cent;
  2137. +           c->ic_extieee = ext->ic_ieee;
  2138. +           c->ic_flags &= ~IEEE80211_CHAN_HT;
  2139. +           c->ic_flags |= IEEE80211_CHAN_HT40U;
  2140. +
  2141. +           c = &ic->ic_channels[ic->ic_nchans++];
  2142. +
  2143. +           *c = *ext;
  2144. +           c->ic_extieee = cent->ic_ieee;
  2145. +           c->ic_flags &= ~IEEE80211_CHAN_HT;
  2146. +           c->ic_flags |= IEEE80211_CHAN_HT40D;
  2147. +       }
  2148. +
  2149. +       for (i = 100; i <= 140; i += 4)
  2150. +       {
  2151. +           flags = IEEE80211_CHAN_A | IEEE80211_CHAN_HT40;
  2152. +
  2153. +           /* find the center channel */
  2154. +
  2155. +           cent = ieee80211_find_channel_byieee(ic, i,
  2156. +               flags & ~IEEE80211_CHAN_HT);
  2157. +           if (cent == NULL)
  2158. +           {
  2159. +               printf("%s: skip channel %d, could not find center channel\n",
  2160. +                   device_get_nameunit(sc->sc_dev), i);
  2161. +               continue;
  2162. +           }
  2163. +
  2164. +           /* find the extension channel */
  2165. +
  2166. +           ext = ieee80211_find_channel(ic, cent->ic_freq + 20,
  2167. +               flags & ~IEEE80211_CHAN_HT);
  2168. +           if (ext == NULL)
  2169. +           {
  2170. +               printf("%s: skip channel %d, could not find extension channel\n",
  2171. +                   device_get_nameunit(sc->sc_dev), i);
  2172. +               continue;
  2173. +           }
  2174. +
  2175. +           c = &ic->ic_channels[ic->ic_nchans++];
  2176. +
  2177. +           *c = *cent;
  2178. +           c->ic_extieee = ext->ic_ieee;
  2179. +           c->ic_flags &= ~IEEE80211_CHAN_HT;
  2180. +           c->ic_flags |= IEEE80211_CHAN_HT40U;
  2181. +
  2182. +           c = &ic->ic_channels[ic->ic_nchans++];
  2183. +
  2184. +           *c = *ext;
  2185. +           c->ic_extieee = cent->ic_ieee;
  2186. +           c->ic_flags &= ~IEEE80211_CHAN_HT;
  2187. +           c->ic_flags |= IEEE80211_CHAN_HT40D;
  2188. +       }
  2189. +
  2190. +       for (i = 149; i <= 165; i += 4)
  2191. +       {
  2192. +           flags = IEEE80211_CHAN_A | IEEE80211_CHAN_HT40;
  2193. +
  2194. +           /* find the center channel */
  2195. +
  2196. +           cent = ieee80211_find_channel_byieee(ic, i,
  2197. +               flags & ~IEEE80211_CHAN_HT);
  2198. +           if (cent == NULL)
  2199. +           {
  2200. +               printf("%s: skip channel %d, could not find center channel\n",
  2201. +                   device_get_nameunit(sc->sc_dev), i);
  2202. +               continue;
  2203. +           }
  2204. +
  2205. +           /* find the extension channel */
  2206. +
  2207. +           ext = ieee80211_find_channel(ic, cent->ic_freq + 20,
  2208. +               flags & ~IEEE80211_CHAN_HT);
  2209. +           if (ext == NULL)
  2210. +           {
  2211. +               printf("%s: skip channel %d, could not find extension channel\n",
  2212. +                   device_get_nameunit(sc->sc_dev), i);
  2213. +               continue;
  2214. +           }
  2215. +
  2216. +           c = &ic->ic_channels[ic->ic_nchans++];
  2217. +
  2218. +           *c = *cent;
  2219. +           c->ic_extieee = ext->ic_ieee;
  2220. +           c->ic_flags &= ~IEEE80211_CHAN_HT;
  2221. +           c->ic_flags |= IEEE80211_CHAN_HT40U;
  2222. +
  2223. +           c = &ic->ic_channels[ic->ic_nchans++];
  2224. +
  2225. +           *c = *ext;
  2226. +           c->ic_extieee = cent->ic_ieee;
  2227. +           c->ic_flags &= ~IEEE80211_CHAN_HT;
  2228. +           c->ic_flags |= IEEE80211_CHAN_HT40D;
  2229. +       }
  2230. +   }
  2231. +}
  2232. +
  2233. +/*
  2234. + * rt2860_init_locked
  2235. + */
  2236. +static void rt2860_init_locked(void *priv)
  2237. +{
  2238. +   struct rt2860_softc *sc;
  2239. +   struct ifnet *ifp;
  2240. +   struct ieee80211com *ic;
  2241. +   int error, i, ntries;
  2242. +   uint32_t tmp, stacnt[6];
  2243. +
  2244. +   sc = priv;
  2245. +   ifp = sc->sc_ifp;
  2246. +   ic = ifp->if_l2com;
  2247. +
  2248. +   RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  2249. +       "%s: initializing\n",
  2250. +       device_get_nameunit(sc->sc_dev));
  2251. +
  2252. +   RT2860_SOFTC_ASSERT_LOCKED(sc);
  2253. +
  2254. +   if (sc->mac_rev != 0x28720200)
  2255. +   {
  2256. +       if (!(sc->flags & RT2860_SOFTC_FLAGS_UCODE_LOADED))
  2257. +
  2258. +       {
  2259. +       RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  2260. +           "%s: loading 8051 microcode\n",
  2261. +           device_get_nameunit(sc->sc_dev));
  2262. +
  2263. +       error = rt2860_io_mcu_load_ucode(sc, rt2860_ucode, sizeof(rt2860_ucode));
  2264. +       if (error != 0)
  2265. +       {
  2266. +           printf("%s: could not load 8051 microcode\n",
  2267. +               device_get_nameunit(sc->sc_dev));
  2268. +           goto fail;
  2269. +       }
  2270. +
  2271. +       RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  2272. +           "%s: 8051 microcode was successfully loaded\n",
  2273. +           device_get_nameunit(sc->sc_dev));
  2274. +
  2275. +       sc->flags |= RT2860_SOFTC_FLAGS_UCODE_LOADED;
  2276. +       }
  2277. +   }
  2278. +   else
  2279. +   {
  2280. +       sc->flags |= RT2860_SOFTC_FLAGS_UCODE_LOADED;
  2281. +
  2282. +       /* Blink every TX */
  2283. +#define LED_CFG_LED_POLARITY   (1<<30)
  2284. +#define LED_CFG_Y_LED_MODE_ONTX    (1<<28)
  2285. +#define LED_CFG_G_LED_MODE_ONTX    (1<<26)
  2286. +#define LED_CFG_R_LED_MODE_ONTX    (1<<24)
  2287. +#define LED_CFG_SLOW_BLK_TIME  (0x03<<16) /* sec */
  2288. +#define LED_CFG_LED_OFF_TIME   (0x1e<<8) /* msec */
  2289. +#define LED_CFG_LED_ON_TIME    (0x46) /* msec */
  2290. +       rt2860_io_mac_write(sc, RT2860_REG_LED_CFG,
  2291. +           LED_CFG_LED_POLARITY |
  2292. +           LED_CFG_Y_LED_MODE_ONTX |
  2293. +           LED_CFG_G_LED_MODE_ONTX |
  2294. +           LED_CFG_R_LED_MODE_ONTX |
  2295. +           LED_CFG_SLOW_BLK_TIME |
  2296. +           LED_CFG_LED_OFF_TIME |
  2297. +           LED_CFG_LED_ON_TIME);
  2298. +   }
  2299. +
  2300. +   rt2860_io_mac_write(sc, RT2860_REG_PWR_PIN_CFG, 0x2);
  2301. +
  2302. +   /* disable DMA engine */
  2303. +
  2304. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG);
  2305. +
  2306. +   tmp &= 0xff0;
  2307. +   tmp |= RT2860_REG_TX_WB_DDONE;
  2308. +
  2309. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG, tmp);
  2310. +
  2311. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_RST_IDX, 0xffffffff);
  2312. +
  2313. +   /* PBF hardware reset */
  2314. +
  2315. +   rt2860_io_mac_write(sc, RT2860_REG_PBF_SYS_CTRL, 0xe1f);
  2316. +   rt2860_io_mac_write(sc, RT2860_REG_PBF_SYS_CTRL, 0xe00);
  2317. +
  2318. +   /* wait while DMA engine is busy */
  2319. +
  2320. +   for (ntries = 0; ntries < 100; ntries++)
  2321. +   {
  2322. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG);
  2323. +       if (!(tmp & (RT2860_REG_TX_DMA_BUSY | RT2860_REG_RX_DMA_BUSY)))
  2324. +           break;
  2325. +
  2326. +       DELAY(1000);
  2327. +   }
  2328. +
  2329. +   if (ntries == 100)
  2330. +   {
  2331. +       printf("%s: timeout waiting for DMA engine\n",
  2332. +           device_get_nameunit(sc->sc_dev));
  2333. +       goto fail;
  2334. +   }
  2335. +
  2336. +   tmp &= 0xff0;
  2337. +   tmp |= RT2860_REG_TX_WB_DDONE;
  2338. +
  2339. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG, tmp);
  2340. +
  2341. +   /* reset Rx and Tx rings */
  2342. +
  2343. +   tmp = RT2860_REG_RST_IDX_RX |
  2344. +       RT2860_REG_RST_IDX_TX_MGMT |
  2345. +       RT2860_REG_RST_IDX_TX_HCCA |
  2346. +       RT2860_REG_RST_IDX_TX_AC3 |
  2347. +       RT2860_REG_RST_IDX_TX_AC2 |
  2348. +       RT2860_REG_RST_IDX_TX_AC1 |
  2349. +       RT2860_REG_RST_IDX_TX_AC0;
  2350. +
  2351. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_RST_IDX, tmp);
  2352. +
  2353. +   /* PBF hardware reset */
  2354. +
  2355. +   rt2860_io_mac_write(sc, RT2860_REG_PBF_SYS_CTRL, 0xe1f);
  2356. +   rt2860_io_mac_write(sc, RT2860_REG_PBF_SYS_CTRL, 0xe00);
  2357. +
  2358. +   rt2860_io_mac_write(sc, RT2860_REG_PWR_PIN_CFG, 0x3);
  2359. +
  2360. +   rt2860_io_mac_write(sc, RT2860_REG_SYS_CTRL,
  2361. +       RT2860_REG_MAC_SRST | RT2860_REG_BBP_HRST);
  2362. +   rt2860_io_mac_write(sc, RT2860_REG_SYS_CTRL, 0);
  2363. +
  2364. +   /* init Tx power per rate */
  2365. +
  2366. +   for (i = 0; i < RT2860_SOFTC_TXPOW_RATE_COUNT; i++)
  2367. +   {
  2368. +       if (sc->txpow_rate_20mhz[i] == 0xffffffff)
  2369. +           continue;
  2370. +
  2371. +       rt2860_io_mac_write(sc, RT2860_REG_TX_PWR_CFG(i),
  2372. +           sc->txpow_rate_20mhz[i]);
  2373. +   }
  2374. +
  2375. +   for (i = 0; i < RT2860_DEF_MAC_SIZE; i++)
  2376. +       rt2860_io_mac_write(sc, rt2860_def_mac[i].reg,
  2377. +           rt2860_def_mac[i].val);
  2378. +
  2379. +   /* wait while MAC is busy */
  2380. +
  2381. +   for (ntries = 0; ntries < 100; ntries++)
  2382. +   {
  2383. +       if (!(rt2860_io_mac_read(sc, RT2860_REG_STATUS_CFG) &
  2384. +           (RT2860_REG_STATUS_TX_BUSY | RT2860_REG_STATUS_RX_BUSY)))
  2385. +           break;
  2386. +
  2387. +       DELAY(1000);
  2388. +   }
  2389. +
  2390. +   if (ntries == 100)
  2391. +   {
  2392. +       printf("%s: timeout waiting for MAC\n",
  2393. +           device_get_nameunit(sc->sc_dev));
  2394. +       goto fail;
  2395. +   }
  2396. +  
  2397. +   /* clear Host to MCU mailbox */
  2398. +
  2399. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX_BBP_AGENT, 0);
  2400. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX, 0);
  2401. +
  2402. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_BOOT,
  2403. +       RT2860_REG_H2M_TOKEN_NO_INTR, 0);
  2404. +
  2405. +   DELAY(1000);
  2406. +
  2407. +   error = rt2860_init_bbp(sc);
  2408. +   if (error != 0)
  2409. +       goto fail;
  2410. +
  2411. +   /* set up maximum buffer sizes */
  2412. +
  2413. +   tmp = (1 << 12) | RT2860_MAX_AGG_SIZE;
  2414. +
  2415. +   rt2860_io_mac_write(sc, RT2860_REG_MAX_LEN_CFG, tmp);
  2416. +
  2417. +   if (sc->mac_rev == 0x28720200)
  2418. +   {
  2419. +       /* set max. PSDU length from 16K to 32K bytes */
  2420. +
  2421. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_MAX_LEN_CFG);
  2422. +
  2423. +       tmp &= ~(3 << 12);
  2424. +       tmp |= (2 << 12);
  2425. +
  2426. +       rt2860_io_mac_write(sc, RT2860_REG_MAX_LEN_CFG, tmp);
  2427. +   }
  2428. +
  2429. +   if (sc->mac_rev >= 0x28720200 && sc->mac_rev < 0x30700200)
  2430. +   {
  2431. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_MAX_LEN_CFG);
  2432. +
  2433. +       tmp &= 0xfff;
  2434. +       tmp |= 0x2000;
  2435. +
  2436. +       rt2860_io_mac_write(sc, RT2860_REG_MAX_LEN_CFG, tmp);
  2437. +   }
  2438. +
  2439. +   /* set mac address */
  2440. +
  2441. +   rt2860_asic_set_macaddr(sc, IF_LLADDR(ifp));
  2442. +
  2443. +   /* clear statistic registers */
  2444. +
  2445. +   rt2860_io_mac_read_multi(sc, RT2860_REG_RX_STA_CNT0,
  2446. +       stacnt, sizeof(stacnt));
  2447. +
  2448. +   /* set RTS threshold */
  2449. +
  2450. +   rt2860_asic_update_rtsthreshold(sc);
  2451. +
  2452. +   /* set Tx power */
  2453. +
  2454. +   rt2860_asic_update_txpower(sc);
  2455. +
  2456. +   /* set up protection mode */
  2457. +
  2458. +   sc->tx_ampdu_sessions = 0;
  2459. +
  2460. +   rt2860_asic_updateprot(sc);
  2461. +
  2462. +   /* clear beacon frame space (entries = 8, entry size = 512) */
  2463. +
  2464. +   rt2860_io_mac_set_region_4(sc, RT2860_REG_BEACON_BASE(0), 0, 1024);
  2465. +
  2466. +   taskqueue_unblock(sc->taskqueue);
  2467. +
  2468. +   /* init Tx rings (4 EDCAs + HCCA + MGMT) */
  2469. +
  2470. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  2471. +       rt2860_reset_tx_ring(sc, &sc->tx_ring[i]);
  2472. +
  2473. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  2474. +   {
  2475. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_BASE_PTR(i),
  2476. +           sc->tx_ring[i].desc_phys_addr);
  2477. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_MAX_CNT(i),
  2478. +           RT2860_SOFTC_TX_RING_DESC_COUNT);
  2479. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_CTX_IDX(i), 0);
  2480. +   }
  2481. +
  2482. +   /* init Rx ring */
  2483. +
  2484. +   rt2860_reset_rx_ring(sc, &sc->rx_ring);
  2485. +
  2486. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_BASE_PTR,
  2487. +       sc->rx_ring.desc_phys_addr);
  2488. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_MAX_CNT,
  2489. +       RT2860_SOFTC_RX_RING_DATA_COUNT);
  2490. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_CALC_IDX,
  2491. +       RT2860_SOFTC_RX_RING_DATA_COUNT - 1);
  2492. +
  2493. +
  2494. +   /* wait while DMA engine is busy */
  2495. +
  2496. +   for (ntries = 0; ntries < 100; ntries++)
  2497. +   {
  2498. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG);
  2499. +       if (!(tmp & (RT2860_REG_TX_DMA_BUSY | RT2860_REG_RX_DMA_BUSY)))
  2500. +           break;
  2501. +
  2502. +       DELAY(1000);
  2503. +   }
  2504. +
  2505. +   if (ntries == 100)
  2506. +   {
  2507. +       printf("%s: timeout waiting for DMA engine\n",
  2508. +           device_get_nameunit(sc->sc_dev));
  2509. +       goto fail;
  2510. +   }
  2511. +
  2512. +   tmp &= 0xff0;
  2513. +   tmp |= RT2860_REG_TX_WB_DDONE;
  2514. +
  2515. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG, tmp);
  2516. +
  2517. +   /* disable interrupts mitigation */
  2518. +
  2519. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_DELAY_INT_CFG, 0);
  2520. +
  2521. +   /* select Main antenna for 1T1R devices */
  2522. +   if (sc->rf_rev == RT2860_EEPROM_RF_2020 ||
  2523. +       sc->rf_rev == RT2860_EEPROM_RF_3020 ||
  2524. +       sc->rf_rev == RT2860_EEPROM_RF_3320)
  2525. +       rt3090_set_rx_antenna(sc, 0);
  2526. +
  2527. +   /* send LEDs operating mode to microcontroller */
  2528. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_LED1,
  2529. +       RT2860_REG_H2M_TOKEN_NO_INTR, sc->led_off[0]);
  2530. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_LED2,
  2531. +       RT2860_REG_H2M_TOKEN_NO_INTR, sc->led_off[1]);
  2532. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_LED3,
  2533. +       RT2860_REG_H2M_TOKEN_NO_INTR, sc->led_off[2]);
  2534. +
  2535. +   /* turn radio LED on */
  2536. +
  2537. +   rt2860_led_cmd(sc, RT2860_LED_CMD_RADIO_ON);
  2538. +
  2539. +   /* write vendor-specific BBP values (from EEPROM) */
  2540. +
  2541. +   for (i = 0; i < RT2860_SOFTC_BBP_EEPROM_COUNT; i++)
  2542. +   {
  2543. +       if (sc->bbp_eeprom[i].reg == 0x00 ||
  2544. +           sc->bbp_eeprom[i].reg == 0xff)
  2545. +           continue;
  2546. +
  2547. +       rt2860_io_bbp_write(sc, sc->bbp_eeprom[i].reg,
  2548. +           sc->bbp_eeprom[i].val);
  2549. +   }
  2550. +
  2551. +   if ((sc->mac_rev & 0xffff0000) >= 0x30710000)
  2552. +       rt3090_rf_init(sc);
  2553. +
  2554. +   if (sc->mac_rev != 0x28720200) {
  2555. +       /* 0x28720200 don`t have RT2860_REG_SCHDMA_GPIO_CTRL_CFG */
  2556. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_GPIO_CTRL_CFG);
  2557. +           if (tmp & (1 << 2)) {
  2558. +           rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_SLEEP,
  2559. +               RT2860_REG_H2M_TOKEN_RADIOOFF, 0x02ff);
  2560. +           rt2860_io_mcu_cmd_check(sc, RT2860_REG_H2M_TOKEN_RADIOOFF);
  2561. +
  2562. +           rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_WAKEUP,
  2563. +               RT2860_REG_H2M_TOKEN_WAKEUP, 0);
  2564. +           rt2860_io_mcu_cmd_check(sc, RT2860_REG_H2M_TOKEN_WAKEUP);
  2565. +       }
  2566. +   }
  2567. +
  2568. +   if ((sc->mac_rev & 0xffff0000) >= 0x30710000)
  2569. +       rt3090_rf_wakeup(sc);
  2570. +
  2571. +   /* disable non-existing Rx chains */
  2572. +
  2573. +   tmp = rt2860_io_bbp_read(sc, 3);
  2574. +
  2575. +   tmp &= ~((1 << 4) | (1 << 3));
  2576. +
  2577. +   if (sc->nrxpath == 3)
  2578. +       tmp |= (1 << 4);
  2579. +   else if (sc->nrxpath == 2)
  2580. +       tmp |= (1 << 3);
  2581. +
  2582. +   rt2860_io_bbp_write(sc, 3, tmp);
  2583. +
  2584. +   /* disable non-existing Tx chains */
  2585. +
  2586. +   tmp = rt2860_io_bbp_read(sc, 1);
  2587. +
  2588. +   tmp &= ~((1 << 4) | (1 << 3));
  2589. +
  2590. +   if (sc->ntxpath == 2)
  2591. +       tmp |= (1 << 4);
  2592. +
  2593. +   rt2860_io_bbp_write(sc, 1, tmp);
  2594. +
  2595. +   if ((sc->mac_rev & 0xffff0000) >= 0x30710000)
  2596. +       rt3090_rf_setup(sc);
  2597. +
  2598. +   if (sc->rf_rev == RT2860_EEPROM_RF_3022)
  2599. +   {
  2600. +       /* calibrate RF */
  2601. +                tmp = rt2860_io_rf_read(sc, 30);
  2602. +                tmp |= 0x80;
  2603. +                rt2860_io_rf_write(sc, 30, tmp);
  2604. +                DELAY(1000);
  2605. +                tmp &= 0x7F;
  2606. +                rt2860_io_rf_write(sc, 30, tmp);
  2607. +
  2608. +                /* Initialize RF register to default value */
  2609. +       rt2860_io_rf_load_defaults(sc);
  2610. +   }
  2611. +
  2612. +   /* set current channel */
  2613. +   rt2860_rf_set_chan(sc, ic->ic_curchan);
  2614. +
  2615. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WMM_TXOP0_CFG, 0);
  2616. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WMM_TXOP1_CFG,
  2617. +       (48 << 16) | 96);
  2618. +
  2619. +   if ((sc->mac_rev & 0xffff) != 0x0101)
  2620. +       rt2860_io_mac_write(sc, RT2860_REG_TX_TXOP_CTRL_CFG, 0x583f);
  2621. +
  2622. +   /* clear pending interrupts */
  2623. +
  2624. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_STATUS, 0xffffffff);
  2625. +
  2626. +   /* enable interrupts */
  2627. +
  2628. +   tmp = RT2860_REG_INT_TX_COHERENT |
  2629. +       RT2860_REG_INT_RX_COHERENT |
  2630. +       RT2860_REG_INT_GP_TIMER |
  2631. +       RT2860_REG_INT_AUTO_WAKEUP |
  2632. +       RT2860_REG_INT_FIFO_STA_FULL |
  2633. +       RT2860_REG_INT_PRE_TBTT |
  2634. +       RT2860_REG_INT_TBTT |
  2635. +       RT2860_REG_INT_TXRX_COHERENT |
  2636. +       RT2860_REG_INT_MCU_CMD |
  2637. +       RT2860_REG_INT_TX_MGMT_DONE |
  2638. +       RT2860_REG_INT_TX_HCCA_DONE |
  2639. +       RT2860_REG_INT_TX_AC3_DONE |
  2640. +       RT2860_REG_INT_TX_AC2_DONE |
  2641. +       RT2860_REG_INT_TX_AC1_DONE |
  2642. +       RT2860_REG_INT_TX_AC0_DONE |
  2643. +       RT2860_REG_INT_RX_DONE;
  2644. +
  2645. +   sc->intr_enable_mask = tmp;
  2646. +
  2647. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_MASK, tmp);
  2648. +
  2649. +   if (rt2860_txrx_enable(sc) != 0)
  2650. +       goto fail;
  2651. +
  2652. +   /* clear garbage interrupts */
  2653. +
  2654. +   tmp = rt2860_io_mac_read(sc, 0x1300);
  2655. +
  2656. +   ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  2657. +   ifp->if_drv_flags |= IFF_DRV_RUNNING;
  2658. +
  2659. +   sc->periodic_round = 0;
  2660. +
  2661. +   callout_reset(&sc->periodic_ch, hz / 10, rt2860_periodic, sc);
  2662. +
  2663. +   return;
  2664. +
  2665. +fail:
  2666. +
  2667. +   rt2860_stop_locked(sc);
  2668. +}
  2669. +
  2670. +/*
  2671. + * rt2860_init
  2672. +
  2673. + */
  2674. +static void rt2860_init(void *priv)
  2675. +{
  2676. +   struct rt2860_softc *sc;
  2677. +
  2678. +   sc = priv;
  2679. +
  2680. +   RT2860_SOFTC_LOCK(sc);
  2681. +
  2682. +   rt2860_init_locked(sc);
  2683. +
  2684. +   RT2860_SOFTC_UNLOCK(sc);
  2685. +}
  2686. +
  2687. +/*
  2688. +
  2689. + * rt2860_init_bbp
  2690. + */
  2691. +static int rt2860_init_bbp(struct rt2860_softc *sc)
  2692. +{
  2693. +   int ntries, i;
  2694. +   uint8_t tmp;
  2695. +
  2696. +   for (ntries = 0; ntries < 20; ntries++)
  2697. +   {
  2698. +       tmp = rt2860_io_bbp_read(sc, 0);
  2699. +       if (tmp != 0x00 && tmp != 0xff)
  2700. +           break;
  2701. +   }
  2702. +
  2703. +   if (tmp == 0x00 || tmp == 0xff)
  2704. +   {
  2705. +       printf("%s: timeout waiting for BBP to wakeup\n",
  2706. +           device_get_nameunit(sc->sc_dev));
  2707. +       return ETIMEDOUT;
  2708. +
  2709. +   }
  2710. +
  2711. +   for (i = 0; i < RT2860_DEF_BBP_SIZE; i++)
  2712. +       rt2860_io_bbp_write(sc, rt2860_def_bbp[i].reg,
  2713. +           rt2860_def_bbp[i].val);
  2714. +
  2715. +   if ((sc->mac_rev & 0xffff) != 0x0101)
  2716. +       rt2860_io_bbp_write(sc, 84, 0x19);
  2717. +
  2718. +   if (sc->mac_rev == 0x28600100)
  2719. +   {
  2720. +       rt2860_io_bbp_write(sc, 69, 0x16);
  2721. +       rt2860_io_bbp_write(sc, 73, 0x12);
  2722. +   }
  2723. +
  2724. +   return 0;
  2725. +}
  2726. +
  2727. +/*
  2728. +
  2729. + * rt2860_stop_locked
  2730. + */
  2731. +static void rt2860_stop_locked(void *priv)
  2732. +{
  2733. +   struct rt2860_softc *sc;
  2734. +   struct ifnet *ifp;
  2735. +   struct ieee80211com *ic;
  2736. +   uint32_t tmp;
  2737. +
  2738. +   sc = priv;
  2739. +   ifp = sc->sc_ifp;
  2740. +   ic = ifp->if_l2com;
  2741. +
  2742. +   RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
  2743. +       "%s: stopping\n",
  2744. +       device_get_nameunit(sc->sc_dev));
  2745. +
  2746. +   RT2860_SOFTC_ASSERT_LOCKED(sc);
  2747. +
  2748. +   sc->sc_tx_timer = 0;
  2749. +
  2750. +   if (ifp->if_drv_flags & IFF_DRV_RUNNING)
  2751. +       rt2860_led_cmd(sc, RT2860_LED_CMD_RADIO_OFF);
  2752. +
  2753. +   ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
  2754. +
  2755. +   callout_stop(&sc->periodic_ch);
  2756. +   callout_stop(&sc->tx_watchdog_ch);
  2757. +
  2758. +   RT2860_SOFTC_UNLOCK(sc);
  2759. +
  2760. +   taskqueue_block(sc->taskqueue);
  2761. +
  2762. +   taskqueue_drain(sc->taskqueue, &sc->rx_done_task);
  2763. +   taskqueue_drain(sc->taskqueue, &sc->tx_done_task);
  2764. +   taskqueue_drain(sc->taskqueue, &sc->fifo_sta_full_task);
  2765. +   taskqueue_drain(sc->taskqueue, &sc->periodic_task);
  2766. +
  2767. +   RT2860_SOFTC_LOCK(sc);
  2768. +
  2769. +   /* clear key tables */
  2770. +
  2771. +   rt2860_asic_clear_keytables(sc);
  2772. +
  2773. +   /* disable interrupts */
  2774. +
  2775. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_MASK, 0);
  2776. +
  2777. +   /* disable Tx/Rx */
  2778. +
  2779. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_SYS_CTRL);
  2780. +
  2781. +   tmp &= ~(RT2860_REG_RX_ENABLE | RT2860_REG_TX_ENABLE);
  2782. +
  2783. +   rt2860_io_mac_write(sc, RT2860_REG_SYS_CTRL, tmp);
  2784. +
  2785. +   /* reset adapter */
  2786. +
  2787. +   rt2860_io_mac_write(sc, RT2860_REG_SYS_CTRL,
  2788. +       RT2860_REG_MAC_SRST | RT2860_REG_BBP_HRST);
  2789. +   rt2860_io_mac_write(sc, RT2860_REG_SYS_CTRL, 0);
  2790. +}
  2791. +
  2792. +/*
  2793. + * rt2860_stop
  2794. + */
  2795. +static void rt2860_stop(void *priv)
  2796. +{
  2797. +   struct rt2860_softc *sc;
  2798. +
  2799. +   sc = priv;
  2800. +
  2801. +   RT2860_SOFTC_LOCK(sc);
  2802. +
  2803. +   rt2860_stop_locked(sc);
  2804. +
  2805. +   RT2860_SOFTC_UNLOCK(sc);
  2806. +}
  2807. +
  2808. +/*
  2809. + * rt2860_start
  2810. +
  2811. + */
  2812. +static void rt2860_start(struct ifnet *ifp)
  2813. +{
  2814. +   struct rt2860_softc *sc;
  2815. +   struct ieee80211_node *ni;
  2816. +   struct mbuf *m;
  2817. +   int qid;
  2818. +
  2819. +   sc = ifp->if_softc;
  2820. +
  2821. +   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
  2822. +       return;
  2823. +
  2824. +   for (;;)
  2825. +   {
  2826. +       IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
  2827. +       if (m == NULL)
  2828. +           break;
  2829. +
  2830. +       ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
  2831. +
  2832. +       m->m_pkthdr.rcvif = NULL;
  2833. +
  2834. +       qid = M_WME_GETAC(m);
  2835. +
  2836. +       RT2860_SOFTC_TX_RING_LOCK(&sc->tx_ring[qid]);
  2837. +
  2838. +       if (sc->tx_ring[qid].data_queued >= RT2860_SOFTC_TX_RING_DATA_COUNT)
  2839. +       {
  2840. +           RT2860_SOFTC_TX_RING_UNLOCK(&sc->tx_ring[qid]);
  2841. +
  2842. +           RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  2843. +               "%s: if_start: Tx ring with qid=%d is full\n",
  2844. +               device_get_nameunit(sc->sc_dev), qid);
  2845. +
  2846. +           m_freem(m);
  2847. +           ieee80211_free_node(ni);
  2848. +
  2849. +           ifp->if_drv_flags |= IFF_DRV_OACTIVE;
  2850. +           ifp->if_oerrors++;
  2851. +
  2852. +           sc->tx_data_queue_full[qid]++;
  2853. +
  2854. +           break;
  2855. +       }
  2856. +
  2857. +       if (rt2860_tx_data(sc, m, ni, qid) != 0)
  2858. +       {
  2859. +           RT2860_SOFTC_TX_RING_UNLOCK(&sc->tx_ring[qid]);
  2860. +
  2861. +           ieee80211_free_node(ni);
  2862. +
  2863. +           ifp->if_oerrors++;
  2864. +
  2865. +           break;
  2866. +       }
  2867. +
  2868. +       RT2860_SOFTC_TX_RING_UNLOCK(&sc->tx_ring[qid]);
  2869. +
  2870. +       rt2860_drain_fifo_stats(sc);
  2871. +
  2872. +       sc->sc_tx_timer = RT2860_TX_WATCHDOG_TIMEOUT;
  2873. +
  2874. +       callout_reset(&sc->tx_watchdog_ch, hz, rt2860_tx_watchdog, sc);
  2875. +   }
  2876. +}
  2877. +
  2878. +/*
  2879. + * rt2860_ioctl
  2880. + */
  2881. +static int rt2860_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
  2882. +{
  2883. +   struct rt2860_softc *sc;
  2884. +   struct ieee80211com *ic;
  2885. +   struct ifreq *ifr;
  2886. +   int error, startall;
  2887. +
  2888. +   sc = ifp->if_softc;
  2889. +   ic = ifp->if_l2com;
  2890. +   ifr = (struct ifreq *) data;
  2891. +
  2892. +   error = 0;
  2893. +
  2894. +   switch (cmd)
  2895. +   {
  2896. +       case SIOCSIFFLAGS:
  2897. +           startall = 0;
  2898. +
  2899. +           RT2860_SOFTC_LOCK(sc);
  2900. +
  2901. +           if (ifp->if_flags & IFF_UP)
  2902. +           {
  2903. +               if (ifp->if_drv_flags & IFF_DRV_RUNNING)
  2904. +               {
  2905. +                   if ((ifp->if_flags ^ sc->if_flags) & IFF_PROMISC)
  2906. +                       rt2860_asic_update_promisc(sc);
  2907. +               }
  2908. +               else
  2909. +               {
  2910. +                   rt2860_init_locked(sc);
  2911. +                   startall = 1;
  2912. +               }
  2913. +           }
  2914. +           else
  2915. +           {
  2916. +               if (ifp->if_drv_flags & IFF_DRV_RUNNING)
  2917. +                   rt2860_stop_locked(sc);
  2918. +           }
  2919. +
  2920. +           sc->if_flags = ifp->if_flags;
  2921. +
  2922. +           RT2860_SOFTC_UNLOCK(sc);
  2923. +
  2924. +           if (startall)
  2925. +               ieee80211_start_all(ic);
  2926. +       break;
  2927. +
  2928. +       case SIOCGIFMEDIA:
  2929. +       case SIOCSIFMEDIA:
  2930. +           error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
  2931. +       break;
  2932. +
  2933. +       case SIOCGIFADDR:
  2934. +           error = ether_ioctl(ifp, cmd, data);
  2935. +       break;
  2936. +
  2937. +       default:
  2938. +           error = EINVAL;
  2939. +       break;
  2940. +   }
  2941. +
  2942. +   return error;
  2943. +}
  2944. +
  2945. +/*
  2946. + * rt2860_vap_create
  2947. + */
  2948. +static struct ieee80211vap *rt2860_vap_create(struct ieee80211com *ic,
  2949. +   const char name[IFNAMSIZ], int unit, int opmode, int flags,
  2950. +   const uint8_t bssid[IEEE80211_ADDR_LEN],
  2951. +   const uint8_t mac[IEEE80211_ADDR_LEN])
  2952. +{
  2953. +   struct rt2860_softc *sc;
  2954. +   struct ifnet *ifp;
  2955. +   struct rt2860_softc_vap *rvap;
  2956. +   struct ieee80211vap *vap;
  2957. +
  2958. +   ifp = ic->ic_ifp;
  2959. +   sc = ifp->if_softc;
  2960. +
  2961. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  2962. +       "%s: VAP create: opmode=%s\n",
  2963. +       device_get_nameunit(sc->sc_dev),
  2964. +       ieee80211_opmode_name[opmode]);
  2965. +
  2966. +   switch (opmode)
  2967. +   {
  2968. +       case IEEE80211_M_IBSS:
  2969. +
  2970. +       case IEEE80211_M_STA:
  2971. +       case IEEE80211_M_AHDEMO:
  2972. +       case IEEE80211_M_HOSTAP:
  2973. +       case IEEE80211_M_MBSS:
  2974. +           if ((sc->napvaps + sc->nadhocvaps + sc->nstavaps) != 0)
  2975. +           {
  2976. +               if_printf(ifp, "only 1 VAP supported\n");
  2977. +               return NULL;
  2978. +           }
  2979. +      
  2980. +           if (opmode == IEEE80211_M_STA)
  2981. +               flags |= IEEE80211_CLONE_NOBEACONS;
  2982. +       break;
  2983. +
  2984. +       case IEEE80211_M_WDS:
  2985. +           if (sc->napvaps == 0)
  2986. +           {
  2987. +               if_printf(ifp, "WDS only supported in AP mode\n");
  2988. +               return NULL;
  2989. +           }
  2990. +       break;
  2991. +
  2992. +       case IEEE80211_M_MONITOR:
  2993. +       break;
  2994. +
  2995. +       default:
  2996. +           if_printf(ifp, "unknown opmode %d\n", opmode);
  2997. +           return NULL;
  2998. +   }
  2999. +
  3000. +   rvap = (struct rt2860_softc_vap *) malloc(sizeof(struct rt2860_softc_vap),
  3001. +       M_80211_VAP, M_NOWAIT | M_ZERO);
  3002. +   if (rvap == NULL)
  3003. +       return NULL;
  3004. +
  3005. +   vap = &rvap->vap;
  3006. +
  3007. +   ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac);
  3008. +
  3009. +   rvap->newstate = vap->iv_newstate;
  3010. +   vap->iv_newstate = rt2860_vap_newstate;
  3011. +
  3012. +   vap->iv_reset = rt2860_vap_reset;
  3013. +   vap->iv_key_update_begin = rt2860_vap_key_update_begin;
  3014. +   vap->iv_key_update_end = rt2860_vap_key_update_end;
  3015. +   vap->iv_key_set = rt2860_vap_key_set;
  3016. +   vap->iv_key_delete = rt2860_vap_key_delete;
  3017. +   vap->iv_update_beacon = rt2860_vap_update_beacon;
  3018. +
  3019. +   rt2860_amrr_init(&rvap->amrr, vap,
  3020. +       sc->ntxpath,
  3021. +       RT2860_AMRR_MIN_SUCCESS_THRESHOLD,
  3022. +       RT2860_AMRR_MAX_SUCCESS_THRESHOLD,
  3023. +       500);
  3024. +
  3025. +   vap->iv_max_aid = RT2860_SOFTC_STAID_COUNT;
  3026. +
  3027. +   /* overwrite default Rx A-MPDU factor */
  3028. +
  3029. +   vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_32K;
  3030. +   vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_NA;
  3031. +   vap->iv_ampdu_limit = vap->iv_ampdu_rxmax;
  3032. +
  3033. +   ieee80211_vap_attach(vap, rt2860_media_change, ieee80211_media_status);
  3034. +
  3035. +   switch (vap->iv_opmode)
  3036. +   {
  3037. +       case IEEE80211_M_HOSTAP:
  3038. +       case IEEE80211_M_MBSS:
  3039. +       case IEEE80211_M_AHDEMO:
  3040. +           sc->napvaps++;
  3041. +       break;
  3042. +
  3043. +       case IEEE80211_M_IBSS:
  3044. +           sc->nadhocvaps++;
  3045. +       break;
  3046. +
  3047. +       case IEEE80211_M_STA:
  3048. +           sc->nstavaps++;
  3049. +       break;
  3050. +
  3051. +       case IEEE80211_M_WDS:
  3052. +           sc->nwdsvaps++;
  3053. +       break;
  3054. +
  3055. +       default:
  3056. +       break;
  3057. +   }
  3058. +
  3059. +   sc->nvaps++;
  3060. +
  3061. +   if (sc->napvaps > 0)
  3062. +       ic->ic_opmode = IEEE80211_M_HOSTAP;
  3063. +   else if (sc->nadhocvaps > 0)
  3064. +       ic->ic_opmode = IEEE80211_M_IBSS;
  3065. +   else if (sc->nstavaps > 0)
  3066. +       ic->ic_opmode = IEEE80211_M_STA;
  3067. +   else
  3068. +       ic->ic_opmode = opmode;
  3069. +
  3070. +   return vap;
  3071. +}
  3072. +
  3073. +/*
  3074. + * rt2860_vap_delete
  3075. +
  3076. + */
  3077. +static void rt2860_vap_delete(struct ieee80211vap *vap)
  3078. +{
  3079. +   struct rt2860_softc *sc;
  3080. +   struct ieee80211com *ic;
  3081. +   struct ifnet *ifp;
  3082. +   struct rt2860_softc_vap *rvap;
  3083. +   enum ieee80211_opmode opmode;
  3084. +
  3085. +   ic = vap->iv_ic;
  3086. +   ifp = ic->ic_ifp;
  3087. +   sc = ifp->if_softc;
  3088. +   rvap = (struct rt2860_softc_vap *) vap;
  3089. +   opmode = vap->iv_opmode;
  3090. +
  3091. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  3092. +       "%s: VAP delete: opmode=%s\n",
  3093. +       device_get_nameunit(sc->sc_dev), ieee80211_opmode_name[opmode]);
  3094. +
  3095. +   rt2860_amrr_cleanup(&rvap->amrr);
  3096. +
  3097. +   ieee80211_vap_detach(vap);
  3098. +
  3099. +   if (rvap->beacon_mbuf != NULL)
  3100. +   {
  3101. +       m_free(rvap->beacon_mbuf);
  3102. +       rvap->beacon_mbuf = NULL;
  3103. +   }
  3104. +
  3105. +   switch (opmode)
  3106. +   {
  3107. +       case IEEE80211_M_HOSTAP:
  3108. +       case IEEE80211_M_MBSS:
  3109. +       case IEEE80211_M_AHDEMO:
  3110. +           sc->napvaps--;
  3111. +       break;
  3112. +
  3113. +       case IEEE80211_M_IBSS:
  3114. +           sc->nadhocvaps--;
  3115. +       break;
  3116. +
  3117. +       case IEEE80211_M_STA:
  3118. +           sc->nstavaps--;
  3119. +       break;
  3120. +
  3121. +       case IEEE80211_M_WDS:
  3122. +           sc->nwdsvaps--;
  3123. +       break;
  3124. +
  3125. +       default:
  3126. +       break;
  3127. +   }
  3128. +
  3129. +   sc->nvaps--;
  3130. +
  3131. +   if (sc->napvaps > 0)
  3132. +       ic->ic_opmode = IEEE80211_M_HOSTAP;
  3133. +   else if (sc->nadhocvaps > 0)
  3134. +       ic->ic_opmode = IEEE80211_M_IBSS;
  3135. +   else if (sc->nstavaps > 0)
  3136. +       ic->ic_opmode = IEEE80211_M_STA;
  3137. +
  3138. +   free(rvap, M_80211_VAP);
  3139. +}
  3140. +
  3141. +/*
  3142. + * rt2860_reset_vap
  3143. +
  3144. + */
  3145. +static int rt2860_vap_reset(struct ieee80211vap *vap, u_long cmd)
  3146. +{
  3147. +   struct rt2860_softc *sc;
  3148. +   struct ieee80211com *ic;
  3149. +   struct ifnet *ifp;
  3150. +   struct rt2860_softc_vap *rvap;
  3151. +   int error;
  3152. +
  3153. +   ic = vap->iv_ic;
  3154. +   ifp = ic->ic_ifp;
  3155. +   sc = ifp->if_softc;
  3156. +   rvap = (struct rt2860_softc_vap *) vap;
  3157. +
  3158. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  3159. +       "%s: VAP reset: cmd=%lu\n",
  3160. +       device_get_nameunit(sc->sc_dev), cmd);
  3161. +
  3162. +   error = 0;
  3163. +
  3164. +   switch (cmd)
  3165. +   {
  3166. +       case IEEE80211_IOC_RTSTHRESHOLD:
  3167. +       case IEEE80211_IOC_AMSDU:
  3168. +           rt2860_asic_update_rtsthreshold(sc);
  3169. +       break;
  3170. +
  3171. +       case IEEE80211_IOC_PROTMODE:
  3172. +       case IEEE80211_IOC_HTPROTMODE:
  3173. +           rt2860_asic_updateprot(sc);
  3174. +       break;
  3175. +
  3176. +       case IEEE80211_IOC_TXPOWER:
  3177. +           rt2860_asic_update_txpower(sc);
  3178. +       break;
  3179. +
  3180. +       case IEEE80211_IOC_BURST:
  3181. +           rt2860_asic_updateslot(sc);
  3182. +       break;
  3183. +
  3184. +       case IEEE80211_IOC_SHORTGI:
  3185. +       case IEEE80211_IOC_AMPDU_DENSITY:
  3186. +       case IEEE80211_IOC_SMPS:
  3187. +       break;
  3188. +
  3189. +       default:
  3190. +           error = ENETRESET;
  3191. +       break;
  3192. +   }
  3193. +
  3194. +   return error;
  3195. +}
  3196. +
  3197. +/*
  3198. + * rt2860_vap_newstate
  3199. + */
  3200. +static int rt2860_vap_newstate(struct ieee80211vap *vap,
  3201. +   enum ieee80211_state nstate, int arg)
  3202. +{
  3203. +   struct rt2860_softc *sc;
  3204. +   struct ieee80211com *ic;
  3205. +   struct ifnet *ifp;
  3206. +   struct rt2860_softc_vap *rvap;
  3207. +   struct ieee80211_node *ni;
  3208. +
  3209. +   enum ieee80211_state ostate;
  3210. +   int error;
  3211. +
  3212. +   ic = vap->iv_ic;
  3213. +   ifp = ic->ic_ifp;
  3214. +   sc = ifp->if_softc;
  3215. +   rvap = (struct rt2860_softc_vap *) vap;
  3216. +
  3217. +   ostate = vap->iv_state;
  3218. +
  3219. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  3220. +       "%s: VAP newstate: %s -> %s\n",
  3221. +       device_get_nameunit(sc->sc_dev),
  3222. +       ieee80211_state_name[ostate], ieee80211_state_name[nstate]);
  3223. +
  3224. +   error = rvap->newstate(vap, nstate, arg);
  3225. +   if (error != 0)
  3226. +       return error;
  3227. +
  3228. +   IEEE80211_UNLOCK(ic);
  3229. +
  3230. +   RT2860_SOFTC_LOCK(sc);
  3231. +
  3232. +   /* turn link LED off */
  3233. +
  3234. +   if (nstate != IEEE80211_S_RUN)
  3235. +       rt2860_led_cmd(sc, RT2860_LED_CMD_RADIO_OFF);
  3236. +
  3237. +   switch (nstate)
  3238. +   {
  3239. +       case IEEE80211_S_INIT:
  3240. +           rt2860_asic_disable_tsf_sync(sc);
  3241. +       break;
  3242. +
  3243. +       case IEEE80211_S_RUN:
  3244. +           ni = vap->iv_bss;
  3245. +
  3246. +           rt2860_rf_set_chan(sc, ni->ni_chan);
  3247. +
  3248. +           if (vap->iv_opmode != IEEE80211_M_MONITOR)
  3249. +           {
  3250. +               rt2860_asic_enable_mrr(sc);
  3251. +               rt2860_asic_set_txpreamble(sc);
  3252. +               rt2860_asic_set_basicrates(sc);
  3253. +               rt2860_asic_update_txpower(sc);
  3254. +               rt2860_asic_set_bssid(sc, ni->ni_bssid);
  3255. +           }
  3256. +
  3257. +           if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
  3258. +               vap->iv_opmode == IEEE80211_M_IBSS ||
  3259. +               vap->iv_opmode == IEEE80211_M_MBSS)
  3260. +           {
  3261. +               error = rt2860_beacon_alloc(sc, vap);
  3262. +               if (error != 0)
  3263. +                   break;
  3264. +
  3265. +               rt2860_asic_update_beacon(sc, vap);
  3266. +           }
  3267. +
  3268. +           if (vap->iv_opmode != IEEE80211_M_MONITOR)
  3269. +               rt2860_asic_enable_tsf_sync(sc);
  3270. +
  3271. +           /* turn link LED on */
  3272. +
  3273. +           if (vap->iv_opmode != IEEE80211_M_MONITOR)
  3274. +           {
  3275. +               rt2860_led_cmd(sc, RT2860_LED_CMD_RADIO_ON |
  3276. +                   (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan) ?
  3277. +                       RT2860_LED_CMD_LINK_2GHZ : RT2860_LED_CMD_LINK_5GHZ));
  3278. +           }
  3279. +       break;
  3280. +
  3281. +       case IEEE80211_S_SLEEP:
  3282. +       break;
  3283. +
  3284. +       default:
  3285. +       break;
  3286. +   }
  3287. +
  3288. +   RT2860_SOFTC_UNLOCK(sc);
  3289. +
  3290. +   IEEE80211_LOCK(ic);
  3291. +
  3292. +   return error;
  3293. +}
  3294. +
  3295. +/*
  3296. + * rt2860_vap_key_update_begin
  3297. + */
  3298. +static void rt2860_vap_key_update_begin(struct ieee80211vap *vap)
  3299. +{
  3300. +   struct rt2860_softc *sc;
  3301. +   struct ieee80211com *ic;
  3302. +   struct ifnet *ifp;
  3303. +
  3304. +   ic = vap->iv_ic;
  3305. +   ifp = ic->ic_ifp;
  3306. +   sc = ifp->if_softc;
  3307. +
  3308. +   RT2860_DPRINTF(sc, RT2860_DEBUG_KEY,
  3309. +       "%s: VAP key update begin\n",
  3310. +       device_get_nameunit(sc->sc_dev));
  3311. +
  3312. +   taskqueue_block(sc->taskqueue);
  3313. +
  3314. +   IF_LOCK(&ifp->if_snd);
  3315. +}
  3316. +
  3317. +/*
  3318. + * rt2860_vap_key_update_end
  3319. + */
  3320. +static void rt2860_vap_key_update_end(struct ieee80211vap *vap)
  3321. +{
  3322. +   struct rt2860_softc *sc;
  3323. +   struct ieee80211com *ic;
  3324. +   struct ifnet *ifp;
  3325. +
  3326. +   ic = vap->iv_ic;
  3327. +   ifp = ic->ic_ifp;
  3328. +   sc = ifp->if_softc;
  3329. +
  3330. +   RT2860_DPRINTF(sc, RT2860_DEBUG_KEY,
  3331. +       "%s: VAP key update end\n",
  3332. +       device_get_nameunit(sc->sc_dev));
  3333. +
  3334. +   IF_UNLOCK(&ifp->if_snd);
  3335. +
  3336. +   taskqueue_unblock(sc->taskqueue);
  3337. +}
  3338. +
  3339. +/*
  3340. + * rt2860_vap_key_set
  3341. +
  3342. + */
  3343. +static int rt2860_vap_key_set(struct ieee80211vap *vap,
  3344. +   const struct ieee80211_key *k, const uint8_t mac[IEEE80211_ADDR_LEN])
  3345. +{
  3346. +   struct rt2860_softc *sc;
  3347. +   struct ieee80211com *ic;
  3348. +   struct ifnet *ifp;
  3349. +   struct ieee80211_node *ni;
  3350. +   struct rt2860_softc_node *rni;
  3351. +   uint16_t key_base, keymode_base;
  3352. +   uint8_t mode, vapid, wcid, iv[8];
  3353. +   uint32_t tmp;
  3354. +
  3355. +   if (k->wk_cipher->ic_cipher != IEEE80211_CIPHER_WEP &&
  3356. +       k->wk_cipher->ic_cipher != IEEE80211_CIPHER_TKIP &&
  3357. +       k->wk_cipher->ic_cipher != IEEE80211_CIPHER_AES_CCM)
  3358. +       return 0;
  3359. +
  3360. +   ic = vap->iv_ic;
  3361. +   ifp = ic->ic_ifp;
  3362. +   sc = ifp->if_softc;
  3363. +
  3364. +   switch (k->wk_cipher->ic_cipher)
  3365. +   {
  3366. +       case IEEE80211_CIPHER_WEP:
  3367. +           if(k->wk_keylen < 8)
  3368. +               mode = RT2860_REG_CIPHER_MODE_WEP40;
  3369. +           else
  3370. +               mode = RT2860_REG_CIPHER_MODE_WEP104;
  3371. +       break;
  3372. +
  3373. +       case IEEE80211_CIPHER_TKIP:
  3374. +           mode = RT2860_REG_CIPHER_MODE_TKIP;
  3375. +       break;
  3376. +
  3377. +       case IEEE80211_CIPHER_AES_CCM:
  3378. +           mode = RT2860_REG_CIPHER_MODE_AES_CCMP;
  3379. +       break;
  3380. +
  3381. +       default:
  3382. +           return 0;
  3383. +   }
  3384. +
  3385. +   RT2860_DPRINTF(sc, RT2860_DEBUG_KEY,
  3386. +       "%s: VAP key set: keyix=%d, keylen=%d, macaddr=%s, mode=%d, group=%d\n",
  3387. +       device_get_nameunit(sc->sc_dev), k->wk_keyix, k->wk_keylen, ether_sprintf(k->wk_macaddr),
  3388. +       mode, (k->wk_flags & IEEE80211_KEY_GROUP) ? 1 : 0);
  3389. +
  3390. +   if (!(k->wk_flags & IEEE80211_KEY_GROUP))
  3391. +   {
  3392. +       /* install pairwise key */
  3393. +
  3394. +       ni = ieee80211_find_vap_node(&ic->ic_sta, vap, mac);
  3395. +       if (!ni) {
  3396. +           printf("ieee80211_find_vap_node return 0\n");
  3397. +           return 0;
  3398. +       }
  3399. +       rni = (struct rt2860_softc_node *) ni;
  3400. +
  3401. +       vapid = 0;
  3402. +       wcid = rni->staid;
  3403. +       key_base = RT2860_REG_PKEY(wcid);
  3404. +
  3405. +       ieee80211_free_node(ni);
  3406. +
  3407. +       if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_WEP)
  3408. +       {
  3409. +           memset(iv, 0, 8);
  3410. +
  3411. +           iv[3] = (k->wk_keyix << 6);
  3412. +       }
  3413. +       else
  3414. +       {
  3415. +           if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP)
  3416. +           {
  3417. +               iv[0] = (k->wk_keytsc >> 8);
  3418. +               iv[1] = ((iv[0] | 0x20) & 0x7f);
  3419. +               iv[2] = k->wk_keytsc;
  3420. +           }
  3421. +           else
  3422. +           {
  3423. +               /* AES CCMP */
  3424. +
  3425. +               iv[0] = k->wk_keytsc;
  3426. +               iv[1] = k->wk_keytsc >> 8;
  3427. +               iv[2] = 0;
  3428. +           }
  3429. +
  3430. +           iv[3] = ((k->wk_keyix << 6) | IEEE80211_WEP_EXTIV);
  3431. +           iv[4] = (k->wk_keytsc >> 16);
  3432. +           iv[5] = (k->wk_keytsc >> 24);
  3433. +           iv[6] = (k->wk_keytsc >> 32);
  3434. +           iv[7] = (k->wk_keytsc >> 40);
  3435. +
  3436. +           RT2860_DPRINTF(sc, RT2860_DEBUG_KEY,
  3437. +               "%s: VAP key set: iv=%02x %02x %02x %02x %02x %02x %02x %02x\n",
  3438. +               device_get_nameunit(sc->sc_dev),
  3439. +               iv[0], iv[1], iv[2], iv[3], iv[4], iv[5], iv[6], iv[7]);
  3440. +
  3441. +       }
  3442. +
  3443. +       rt2860_io_mac_write_multi(sc, RT2860_REG_IVEIV(wcid), iv, 8);
  3444. +
  3445. +       if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP)
  3446. +       {
  3447. +           rt2860_io_mac_write_multi(sc, key_base, k->wk_key, 16);
  3448. +
  3449. +           if (vap->iv_opmode != IEEE80211_M_HOSTAP)
  3450. +           {
  3451. +               rt2860_io_mac_write_multi(sc, key_base + 16, &k->wk_key[16], 8);
  3452. +               rt2860_io_mac_write_multi(sc, key_base + 24, &k->wk_key[24], 8);
  3453. +           }
  3454. +           else
  3455. +           {
  3456. +               rt2860_io_mac_write_multi(sc, key_base + 16, &k->wk_key[24], 8);
  3457. +               rt2860_io_mac_write_multi(sc, key_base + 24, &k->wk_key[16], 8);
  3458. +           }
  3459. +       }
  3460. +       else
  3461. +       {
  3462. +           rt2860_io_mac_write_multi(sc, key_base, k->wk_key, k->wk_keylen);
  3463. +       }
  3464. +
  3465. +       tmp = ((vapid & RT2860_REG_VAP_MASK) << RT2860_REG_VAP_SHIFT) |
  3466. +           (mode << RT2860_REG_CIPHER_MODE_SHIFT) | RT2860_REG_PKEY_ENABLE;
  3467. +
  3468. +       rt2860_io_mac_write(sc, RT2860_REG_WCID_ATTR(wcid), tmp);
  3469. +   }
  3470. +
  3471. +   if ((k->wk_flags & IEEE80211_KEY_GROUP) ||
  3472. +       (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_WEP))
  3473. +   {
  3474. +       /* install group key */
  3475. +
  3476. +       vapid = 0;
  3477. +       wcid = RT2860_WCID_MCAST;
  3478. +       key_base = RT2860_REG_SKEY(vapid, k->wk_keyix);
  3479. +       keymode_base = RT2860_REG_SKEY_MODE(vapid);
  3480. +
  3481. +       if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP)
  3482. +       {
  3483. +           rt2860_io_mac_write_multi(sc, key_base, k->wk_key, 16);
  3484. +
  3485. +           if (vap->iv_opmode != IEEE80211_M_HOSTAP)
  3486. +           {
  3487. +               rt2860_io_mac_write_multi(sc, key_base + 16, &k->wk_key[16], 8);
  3488. +               rt2860_io_mac_write_multi(sc, key_base + 24, &k->wk_key[24], 8);
  3489. +           }
  3490. +           else
  3491. +           {
  3492. +               rt2860_io_mac_write_multi(sc, key_base + 16, &k->wk_key[24], 8);
  3493. +               rt2860_io_mac_write_multi(sc, key_base + 24, &k->wk_key[16], 8);
  3494. +           }
  3495. +       }
  3496. +       else
  3497. +       {
  3498. +           rt2860_io_mac_write_multi(sc, key_base, k->wk_key, k->wk_keylen);
  3499. +       }
  3500. +
  3501. +       tmp = rt2860_io_mac_read(sc, keymode_base);
  3502. +
  3503. +       tmp &= ~(0xf << (k->wk_keyix * 4 + 16 * (vapid % 2)));
  3504. +       tmp |= (mode << (k->wk_keyix * 4 + 16 * (vapid % 2)));
  3505. +
  3506. +       rt2860_io_mac_write(sc, keymode_base, tmp);
  3507. +
  3508. +       if (vap->iv_opmode == IEEE80211_M_HOSTAP)
  3509. +       {
  3510. +           if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_WEP)
  3511. +           {
  3512. +               memset(iv, 0, 8);
  3513. +
  3514. +               iv[3] = (k->wk_keyix << 6);
  3515. +           }
  3516. +           else
  3517. +           {
  3518. +               if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP)
  3519. +               {
  3520. +                   iv[0] = (k->wk_keytsc >> 8);
  3521. +                   iv[1] = ((iv[0] | 0x20) & 0x7f);
  3522. +                   iv[2] = k->wk_keytsc;
  3523. +               }
  3524. +               else
  3525. +               {
  3526. +                   /* AES CCMP */
  3527. +
  3528. +                   iv[0] = k->wk_keytsc;
  3529. +                   iv[1] = k->wk_keytsc >> 8;
  3530. +                   iv[2] = 0;
  3531. +               }
  3532. +
  3533. +               iv[3] = ((k->wk_keyix << 6) | IEEE80211_WEP_EXTIV);
  3534. +               iv[4] = (k->wk_keytsc >> 16);
  3535. +               iv[5] = (k->wk_keytsc >> 24);
  3536. +               iv[6] = (k->wk_keytsc >> 32);
  3537. +               iv[7] = (k->wk_keytsc >> 40);
  3538. +
  3539. +               RT2860_DPRINTF(sc, RT2860_DEBUG_KEY,
  3540. +                   "%s: VAP key set: iv=%02x %02x %02x %02x %02x %02x %02x %02x\n",
  3541. +                   device_get_nameunit(sc->sc_dev),
  3542. +                   iv[0], iv[1], iv[2], iv[3], iv[4], iv[5], iv[6], iv[7]);
  3543. +           }
  3544. +
  3545. +           rt2860_io_mac_write_multi(sc, RT2860_REG_IVEIV(wcid), iv, 8);
  3546. +
  3547. +           tmp = ((vapid & RT2860_REG_VAP_MASK) << RT2860_REG_VAP_SHIFT) |
  3548. +               (mode << RT2860_REG_CIPHER_MODE_SHIFT);
  3549. +
  3550. +           rt2860_io_mac_write(sc, RT2860_REG_WCID_ATTR(wcid), tmp);
  3551. +       }
  3552. +   }
  3553. +
  3554. +   return 1;
  3555. +}
  3556. +
  3557. +/*
  3558. +
  3559. + * rt2860_vap_key_delete
  3560. + */
  3561. +static int rt2860_vap_key_delete(struct ieee80211vap *vap,
  3562. +   const struct ieee80211_key *k)
  3563. +{
  3564. +   struct rt2860_softc *sc;
  3565. +   struct ieee80211com *ic;
  3566. +   struct ifnet *ifp;
  3567. +   uint8_t vapid, wcid;
  3568. +   uint32_t tmp;
  3569. +
  3570. +   ic = vap->iv_ic;
  3571. +   ifp = ic->ic_ifp;
  3572. +   sc = ifp->if_softc;
  3573. +
  3574. +   RT2860_DPRINTF(sc, RT2860_DEBUG_KEY,
  3575. +       "%s: VAP key delete: keyix=%d, keylen=%d, macaddr=%s, group=%d\n",
  3576. +       device_get_nameunit(sc->sc_dev), k->wk_keyix, k->wk_keylen, ether_sprintf(k->wk_macaddr),
  3577. +       (k->wk_flags & IEEE80211_KEY_GROUP) ? 1 : 0);
  3578. +
  3579. +   if (k->wk_flags & IEEE80211_KEY_GROUP)
  3580. +   {
  3581. +       /* remove group key */
  3582. +
  3583. +       vapid = 0;
  3584. +       wcid = RT2860_WCID_MCAST;
  3585. +
  3586. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_SKEY_MODE(vapid));
  3587. +
  3588. +       tmp &= ~(0xf << (k->wk_keyix * 4 + 16 * (vapid % 2)));
  3589. +       tmp |= (RT2860_REG_CIPHER_MODE_NONE << (k->wk_keyix * 4 + 16 * (vapid % 2)));
  3590. +
  3591. +       rt2860_io_mac_write(sc, RT2860_REG_SKEY_MODE(vapid), tmp);
  3592. +
  3593. +       if (vap->iv_opmode == IEEE80211_M_HOSTAP)
  3594. +       {
  3595. +           tmp = ((vapid & RT2860_REG_VAP_MASK) << RT2860_REG_VAP_SHIFT) |
  3596. +               (RT2860_REG_CIPHER_MODE_NONE << RT2860_REG_CIPHER_MODE_SHIFT) | RT2860_REG_PKEY_ENABLE;
  3597. +
  3598. +           rt2860_io_mac_write(sc, RT2860_REG_WCID_ATTR(wcid), tmp);
  3599. +       }
  3600. +   }
  3601. +
  3602. +   return 1;
  3603. +}
  3604. +
  3605. +/*
  3606. + * rt2860_vap_update_beacon
  3607. +
  3608. + */
  3609. +static void rt2860_vap_update_beacon(struct ieee80211vap *vap, int what)
  3610. +{
  3611. +   struct rt2860_softc *sc;
  3612. +   struct ieee80211com *ic;
  3613. +   struct ifnet *ifp;
  3614. +   struct rt2860_softc_vap *rvap;
  3615. +   struct mbuf *m;
  3616. +   struct ieee80211_beacon_offsets *bo;
  3617. +   int error;
  3618. +
  3619. +   ic = vap->iv_ic;
  3620. +   ifp = ic->ic_ifp;
  3621. +   sc = ifp->if_softc;
  3622. +   rvap = (struct rt2860_softc_vap *) vap;
  3623. +   m = rvap->beacon_mbuf;
  3624. +   bo = &rvap->beacon_offsets;
  3625. +
  3626. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BEACON,
  3627. +       "%s: VAP update beacon: what=%d\n",
  3628. +       device_get_nameunit(sc->sc_dev), what);
  3629. +
  3630. +   setbit(bo->bo_flags, what);
  3631. +
  3632. +   if (m == NULL)
  3633. +   {
  3634. +       error = rt2860_beacon_alloc(sc, vap);
  3635. +       if (error != 0)
  3636. +           return;
  3637. +
  3638. +       m = rvap->beacon_mbuf;
  3639. +   }
  3640. +
  3641. +
  3642. +   ieee80211_beacon_update(vap->iv_bss, bo, m, 0);
  3643. +
  3644. +   rt2860_asic_update_beacon(sc, vap);
  3645. +}
  3646. +
  3647. +/*
  3648. + * rt2860_media_change
  3649. + */
  3650. +static int rt2860_media_change(struct ifnet *ifp)
  3651. +{
  3652. +   int error;
  3653. +
  3654. +   error = ieee80211_media_change(ifp);
  3655. +
  3656. +   return (error == ENETRESET ? 0 : error);
  3657. +}
  3658. +
  3659. +
  3660. +/*
  3661. + *  Chip/Board IO functions
  3662. + */
  3663. +
  3664. +
  3665. +/*
  3666. + * rt2860_io_mac_read
  3667. + */
  3668. +uint32_t rt2860_io_mac_read(struct rt2860_softc *sc, uint16_t reg)
  3669. +{
  3670. +   bus_space_read_4(sc->sc_st, sc->sc_sh, RT2860_REG_MAC_CSR0);
  3671. +   return bus_space_read_4(sc->sc_st, sc->sc_sh, reg);
  3672. +}
  3673. +
  3674. +/*
  3675. + * rt2860_io_mac_read_multi
  3676. + */
  3677. +void rt2860_io_mac_read_multi(struct rt2860_softc *sc,
  3678. +   uint16_t reg, void *buf, size_t len)
  3679. +{
  3680. +   bus_space_read_4(sc->sc_st, sc->sc_sh, RT2860_REG_MAC_CSR0);
  3681. +   bus_space_read_region_1(sc->sc_st, sc->sc_sh, reg, buf, len);
  3682. +}
  3683. +
  3684. +/*
  3685. + * rt2860_io_mac_write
  3686. + */
  3687. +void rt2860_io_mac_write(struct rt2860_softc *sc,
  3688. +   uint16_t reg, uint32_t val)
  3689. +{
  3690. +   bus_space_read_4(sc->sc_st, sc->sc_sh, RT2860_REG_MAC_CSR0);
  3691. +   bus_space_write_4(sc->sc_st, sc->sc_sh, reg, val);
  3692. +}
  3693. +
  3694. +/*
  3695. + * rt2860_io_mac_write_multi
  3696. + */
  3697. +void rt2860_io_mac_write_multi(struct rt2860_softc *sc,
  3698. +   uint16_t reg, const void *buf, size_t len)
  3699. +{
  3700. +   int i;
  3701. +   const uint8_t *p;
  3702. +
  3703. +   bus_space_read_4(sc->sc_st, sc->sc_sh, RT2860_REG_MAC_CSR0);
  3704. +
  3705. +   p = buf;
  3706. +   for (i = 0; i < len; i ++)
  3707. +       bus_space_write_1(sc->sc_st, sc->sc_sh, reg + i, *(p+i));
  3708. +#ifdef notyet
  3709. +   bus_space_write_region_1(sc->sc_st, sc->sc_sh, reg, buf, len);
  3710. +#endif
  3711. +}
  3712. +
  3713. +/*
  3714. + * rt2860_io_mac_set_region_4
  3715. + */
  3716. +void rt2860_io_mac_set_region_4(struct rt2860_softc *sc,
  3717. +   uint16_t reg, uint32_t val, size_t len)
  3718. +{
  3719. +   int i;
  3720. +
  3721. +   for (i = 0; i < len; i += sizeof(uint32_t))
  3722. +       rt2860_io_mac_write(sc, reg + i, val);
  3723. +}
  3724. +
  3725. +/* Read 16-bit from eFUSE ROM (>=RT3071 only.) */
  3726. +static uint16_t
  3727. +rt3090_efuse_read_2(struct rt2860_softc *sc, uint16_t addr)
  3728. +{
  3729. +   uint32_t tmp;
  3730. +   uint16_t reg;
  3731. +   int ntries;
  3732. +
  3733. +   addr *= 2;
  3734. +   /*-
  3735. +    * Read one 16-byte block into registers EFUSE_DATA[0-3]:
  3736. +    * DATA0: F E D C
  3737. +    * DATA1: B A 9 8
  3738. +    * DATA2: 7 6 5 4
  3739. +    * DATA3: 3 2 1 0
  3740. +    */
  3741. +   tmp = rt2860_io_mac_read(sc, RT3070_EFUSE_CTRL);
  3742. +   tmp &= ~(RT3070_EFSROM_MODE_MASK | RT3070_EFSROM_AIN_MASK);
  3743. +   tmp |= (addr & ~0xf) << RT3070_EFSROM_AIN_SHIFT | RT3070_EFSROM_KICK;
  3744. +   rt2860_io_mac_write(sc, RT3070_EFUSE_CTRL, tmp);
  3745. +   for (ntries = 0; ntries < 500; ntries++) {
  3746. +       tmp = rt2860_io_mac_read(sc, RT3070_EFUSE_CTRL);
  3747. +       if (!(tmp & RT3070_EFSROM_KICK))
  3748. +           break;
  3749. +       DELAY(2);
  3750. +   }
  3751. +   if (ntries == 500)
  3752. +       return 0xffff;
  3753. +
  3754. +   if ((tmp & RT3070_EFUSE_AOUT_MASK) == RT3070_EFUSE_AOUT_MASK)
  3755. +       return 0xffff;  /* address not found */
  3756. +
  3757. +   /* determine to which 32-bit register our 16-bit word belongs */
  3758. +   reg = RT3070_EFUSE_DATA3 - (addr & 0xc);
  3759. +   tmp = rt2860_io_mac_read(sc, reg);
  3760. +
  3761. +   return (addr & 2) ? tmp >> 16 : tmp & 0xffff;
  3762. +}
  3763. +
  3764. +
  3765. +/*
  3766. + * rt2860_io_eeprom_read
  3767. + */
  3768. +uint16_t rt2860_io_eeprom_read(struct rt2860_softc *sc, uint16_t addr)
  3769. +{
  3770. +   uint32_t tmp;
  3771. +   uint16_t val;
  3772. +
  3773. +   addr = (addr >> 1);
  3774. +
  3775. +   if (sc->mac_rev == 0x28720200) {
  3776. +       return (rt3052_eeprom[addr]);
  3777. +   } else if ((sc->mac_rev & 0xffff0000) >= 0x30710000) {
  3778. +       tmp = rt2860_io_mac_read(sc, RT3070_EFUSE_CTRL);
  3779. +       if (tmp & RT3070_SEL_EFUSE)
  3780. +           return (rt3090_efuse_read_2(sc, addr));
  3781. +   }
  3782. +
  3783. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  3784. +
  3785. +   tmp &= ~(RT2860_REG_EEDI | RT2860_REG_EEDO | RT2860_REG_EESK);
  3786. +   tmp |= RT2860_REG_EECS;
  3787. +
  3788. +   rt2860_io_mac_write(sc, RT2860_REG_EEPROM_CSR, tmp);
  3789. +
  3790. +   if (((sc->mac_rev & 0xffff0000) != 0x30710000) &&
  3791. +       ((sc->mac_rev & 0xffff0000) != 0x30900000) &&
  3792. +       ((sc->mac_rev & 0xffff0000) != 0x35720000) &&
  3793. +       ((sc->mac_rev & 0xffff0000) != 0x33900000))
  3794. +   {
  3795. +       RT2860_IO_EEPROM_RAISE_CLK(sc, tmp);
  3796. +       RT2860_IO_EEPROM_LOWER_CLK(sc, tmp);
  3797. +   }
  3798. +
  3799. +   rt2860_io_eeprom_shiftout_bits(sc, RT2860_REG_EEOP_READ, 3);
  3800. +   rt2860_io_eeprom_shiftout_bits(sc, addr, sc->eeprom_addr_num);
  3801. +
  3802. +   val = rt2860_io_eeprom_shiftin_bits(sc);
  3803. +
  3804. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  3805. +
  3806. +   tmp &= ~(RT2860_REG_EECS | RT2860_REG_EEDI);
  3807. +
  3808. +   rt2860_io_mac_write(sc, RT2860_REG_EEPROM_CSR, tmp);
  3809. +
  3810. +   RT2860_IO_EEPROM_RAISE_CLK(sc, tmp);
  3811. +   RT2860_IO_EEPROM_LOWER_CLK(sc, tmp);
  3812. +
  3813. +   return val;
  3814. +}
  3815. +
  3816. +/*
  3817. + * rt2860_io_eeprom_read_multi
  3818. + */
  3819. +void rt2860_io_eeprom_read_multi(struct rt2860_softc *sc,
  3820. +   uint16_t addr, void *buf, size_t len)
  3821. +{
  3822. +   uint16_t *ptr;
  3823. +   int i;
  3824. +
  3825. +   len += len % sizeof(uint16_t);
  3826. +   ptr = buf;
  3827. +
  3828. +   i = 0;
  3829. +
  3830. +   do
  3831. +   {
  3832. +       *ptr++ = rt2860_io_eeprom_read(sc, addr + i);
  3833. +
  3834. +       i += sizeof(uint16_t);
  3835. +       len -= sizeof(uint16_t);
  3836. +   } while (len > 0);
  3837. +}
  3838. +
  3839. +/*
  3840. + * rt2860_io_bbp_read
  3841. + */
  3842. +uint8_t rt2860_io_bbp_read(struct rt2860_softc *sc, uint8_t reg)
  3843. +{
  3844. +   int ntries;
  3845. +   uint32_t tmp;
  3846. +
  3847. +   if (sc->mac_rev == 0x28720200)
  3848. +   {
  3849. +       for (ntries = 0; ntries < 100; ntries ++) {
  3850. +           if ( !(rt2860_io_mac_read(sc, RT2860_REG_BBP_CSR_CFG) &
  3851. +               RT2860_REG_BBP_CSR_BUSY) )
  3852. +               break;
  3853. +           DELAY(1);
  3854. +       }
  3855. +       if (ntries == 100) {
  3856. +           printf("%s:%s: BBP busy after 100 probes\n",
  3857. +               device_get_nameunit(sc->sc_dev), __func__);
  3858. +           return (0);
  3859. +       }
  3860. +       rt2860_io_mac_write(sc, RT2860_REG_BBP_CSR_CFG,
  3861. +           RT2860_REG_BBP_CSR_READ |
  3862. +           RT2860_REG_BBP_CSR_KICK | RT2860_REG_BBP_RW_MODE_PARALLEL |
  3863. +           (reg & RT2860_REG_BBP_REG_MASK) << RT2860_REG_BBP_REG_SHIFT);
  3864. +       for (ntries = 0; ntries < 100; ntries ++) {
  3865. +           if ( !(rt2860_io_mac_read(sc, RT2860_REG_BBP_CSR_CFG) &
  3866. +               RT2860_REG_BBP_CSR_BUSY) )
  3867. +               break;
  3868. +           DELAY(1);
  3869. +       }
  3870. +       if (ntries == 100) {
  3871. +           printf("%s:%s: BBP busy after 100 probes\n",
  3872. +               device_get_nameunit(sc->sc_dev), __func__);
  3873. +           return (0);
  3874. +       }
  3875. +       else {
  3876. +           return
  3877. +               ((rt2860_io_mac_read(sc, RT2860_REG_BBP_CSR_CFG) >>
  3878. +               RT2860_REG_BBP_VAL_SHIFT) &
  3879. +               RT2860_REG_BBP_VAL_MASK);
  3880. +       }
  3881. +       return (0);
  3882. +   }
  3883. +
  3884. +   for (ntries = 0; ntries < 100; ntries++)
  3885. +   {
  3886. +       if (!(rt2860_io_mac_read(sc, RT2860_REG_H2M_MAILBOX_BBP_AGENT) &
  3887. +           RT2860_REG_BBP_CSR_BUSY))
  3888. +           break;
  3889. +
  3890. +       DELAY(1);
  3891. +   }
  3892. +
  3893. +   if (ntries == 100)
  3894. +   {
  3895. +       printf("%s: could not read from BBP through MCU: reg=0x%02x\n",
  3896. +           device_get_nameunit(sc->sc_dev), reg);
  3897. +       return 0;
  3898. +   }
  3899. +
  3900. +   tmp = RT2860_REG_BBP_RW_MODE_PARALLEL |
  3901. +       RT2860_REG_BBP_CSR_BUSY |
  3902. +       RT2860_REG_BBP_CSR_READ |
  3903. +       ((reg & RT2860_REG_BBP_REG_MASK) << RT2860_REG_BBP_REG_SHIFT);
  3904. +
  3905. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX_BBP_AGENT, tmp);
  3906. +
  3907. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_BBP,
  3908. +       RT2860_REG_H2M_TOKEN_NO_INTR, 0);
  3909. +
  3910. +   DELAY(1000);
  3911. +
  3912. +   for (ntries = 0; ntries < 100; ntries++)
  3913. +   {
  3914. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_H2M_MAILBOX_BBP_AGENT);
  3915. +       if (!(tmp & RT2860_REG_BBP_CSR_BUSY))
  3916. +           return ((tmp >> RT2860_REG_BBP_VAL_SHIFT) &
  3917. +               RT2860_REG_BBP_VAL_MASK);
  3918. +
  3919. +       DELAY(1);
  3920. +   }
  3921. +
  3922. +   printf("%s: could not read from BBP through MCU: reg=0x%02x\n",
  3923. +       device_get_nameunit(sc->sc_dev), reg);
  3924. +
  3925. +   return 0;
  3926. +}
  3927. +
  3928. +/*
  3929. + * rt2860_io_bbp_write
  3930. + */
  3931. +void rt2860_io_bbp_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val)
  3932. +{
  3933. +   int ntries;
  3934. +   uint32_t tmp;
  3935. +
  3936. +   if (sc->mac_rev == 0x28720200)
  3937. +   {
  3938. +       for (ntries = 0; ntries < 100; ntries ++) {
  3939. +           if ( !(rt2860_io_mac_read(sc, RT2860_REG_BBP_CSR_CFG) &
  3940. +               RT2860_REG_BBP_CSR_BUSY) )
  3941. +               break;
  3942. +           DELAY(1);
  3943. +       }
  3944. +       if (ntries == 100) {
  3945. +           printf("%s:%s: BBP busy after 100 probes\n",
  3946. +               device_get_nameunit(sc->sc_dev), __func__);
  3947. +           return;
  3948. +       }
  3949. +       rt2860_io_mac_write(sc, RT2860_REG_BBP_CSR_CFG,
  3950. +           RT2860_REG_BBP_CSR_KICK | RT2860_REG_BBP_RW_MODE_PARALLEL |
  3951. +           (reg & RT2860_REG_BBP_REG_MASK) << RT2860_REG_BBP_REG_SHIFT |
  3952. +           (val & RT2860_REG_BBP_VAL_MASK) << RT2860_REG_BBP_VAL_SHIFT );
  3953. +       rt2860_io_bbp_read(sc, reg);
  3954. +       return;
  3955. +   }
  3956. +
  3957. +   for (ntries = 0; ntries < 100; ntries++)
  3958. +   {
  3959. +       if (!(rt2860_io_mac_read(sc, RT2860_REG_H2M_MAILBOX_BBP_AGENT) &
  3960. +           RT2860_REG_BBP_CSR_BUSY))
  3961. +           break;
  3962. +
  3963. +       DELAY(1);
  3964. +   }
  3965. +
  3966. +   if (ntries == 100)
  3967. +   {
  3968. +       printf("%s: could not write to BBP through MCU: reg=0x%02x\n",
  3969. +           device_get_nameunit(sc->sc_dev), reg);
  3970. +       return;
  3971. +   }
  3972. +
  3973. +   tmp = RT2860_REG_BBP_RW_MODE_PARALLEL |
  3974. +       RT2860_REG_BBP_CSR_BUSY |
  3975. +       ((reg & RT2860_REG_BBP_REG_MASK) << RT2860_REG_BBP_REG_SHIFT) |
  3976. +       ((val & RT2860_REG_BBP_VAL_MASK) << RT2860_REG_BBP_VAL_SHIFT);
  3977. +
  3978. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX_BBP_AGENT, tmp);
  3979. +
  3980. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_BBP,
  3981. +       RT2860_REG_H2M_TOKEN_NO_INTR, 0);
  3982. +
  3983. +   DELAY(1000);
  3984. +}
  3985. +
  3986. +/*
  3987. + * rt2860_io_rf_write
  3988. + */
  3989. +void rt2860_io_rf_write(struct rt2860_softc *sc, uint8_t reg, uint32_t val)
  3990. +{
  3991. +   int ntries;
  3992. +   if (sc->mac_rev == 0x28720200)
  3993. +   {
  3994. +       for (ntries = 0; ntries < 100; ntries ++) {
  3995. +           if ( !(rt2860_io_mac_read(sc, RT2872_REG_RF_CSR_CFG) &
  3996. +               RT2872_REG_RF_CSR_BUSY) )
  3997. +               break;
  3998. +           DELAY(1);
  3999. +       }
  4000. +       if (ntries == 100) {
  4001. +           printf("%s:%s: RF busy after 100 probes\n",
  4002. +               device_get_nameunit(sc->sc_dev), __func__);
  4003. +           return;
  4004. +       }
  4005. +       rt2860_io_mac_write(sc, RT2872_REG_RF_CSR_CFG,
  4006. +           RT2872_REG_RF_CSR_KICK | RT2872_REG_RF_CSR_WRITE |
  4007. +           (reg & RT2872_REG_RF_ID_MASK) << RT2872_REG_RF_ID_SHIFT |
  4008. +           (val & RT2872_REG_RF_VAL_MASK) << RT2872_REG_RF_VAL_SHIFT );
  4009. +       rt2860_io_rf_read(sc, reg);
  4010. +       return;
  4011. +   }
  4012. +
  4013. +
  4014. +   for (ntries = 0; ntries < 100; ntries++)
  4015. +       if (!(rt2860_io_mac_read(sc, RT2860_REG_RF_CSR_CFG0) &
  4016. +           RT2860_REG_RF_BUSY))
  4017. +           break;
  4018. +
  4019. +   if (ntries == 100)
  4020. +   {
  4021. +       printf("%s: could not write to RF: reg=0x%02x\n",
  4022. +           device_get_nameunit(sc->sc_dev), reg);
  4023. +       return;
  4024. +   }
  4025. +
  4026. +   rt2860_io_mac_write(sc, RT2860_REG_RF_CSR_CFG0, val);
  4027. +}
  4028. +
  4029. +/*
  4030. + * rt2860_io_rf_read
  4031. + */
  4032. +int32_t rt2860_io_rf_read(struct rt2860_softc *sc, uint8_t reg)
  4033. +{
  4034. +   int ntries;
  4035. +   if (sc->mac_rev == 0x28720200)
  4036. +   {
  4037. +       for (ntries = 0; ntries < 100; ntries ++) {
  4038. +           if ( !(rt2860_io_mac_read(sc, RT2872_REG_RF_CSR_CFG) &
  4039. +               RT2872_REG_RF_CSR_BUSY) )
  4040. +               break;
  4041. +           DELAY(1);
  4042. +       }
  4043. +       if (ntries == 100) {
  4044. +           printf("%s:%s: RF busy after 100 probes\n",
  4045. +               device_get_nameunit(sc->sc_dev), __func__);
  4046. +           return (-1);
  4047. +       }
  4048. +       rt2860_io_mac_write(sc, RT2872_REG_RF_CSR_CFG,
  4049. +           RT2872_REG_RF_CSR_KICK |
  4050. +           (reg & RT2872_REG_RF_ID_MASK) << RT2872_REG_RF_ID_SHIFT );
  4051. +
  4052. +       for (ntries = 0; ntries < 100; ntries ++) {
  4053. +           if ( !(rt2860_io_mac_read(sc, RT2872_REG_RF_CSR_CFG) &
  4054. +               RT2872_REG_RF_CSR_BUSY) )
  4055. +               break;
  4056. +           DELAY(1);
  4057. +       }
  4058. +       if (ntries == 100) {
  4059. +           printf("%s:%s: RF busy after 100 probes\n",
  4060. +               device_get_nameunit(sc->sc_dev), __func__);
  4061. +       }
  4062. +
  4063. +       return (rt2860_io_mac_read(sc, RT2872_REG_RF_CSR_CFG) & RT2872_REG_RF_VAL_MASK);
  4064. +   }
  4065. +   return (-1);
  4066. +}
  4067. +
  4068. +/*
  4069. + * rt2860_io_rf_load_defaults
  4070. + */
  4071. +void rt2860_io_rf_load_defaults(struct rt2860_softc *sc)
  4072. +{
  4073. +   int i;
  4074. +
  4075. +   if (sc->mac_rev == 0x28720200) {
  4076. +       for (i = 0; i < 32; i ++)
  4077. +           rt2860_io_rf_write(sc, i, rt3052_rf_default[i]);
  4078. +   }
  4079. +}
  4080. +
  4081. +/*
  4082. + * rt2860_io_mcu_cmd
  4083. + */
  4084. +void rt2860_io_mcu_cmd(struct rt2860_softc *sc, uint8_t cmd,
  4085. +   uint8_t token, uint16_t arg)
  4086. +{
  4087. +   uint32_t tmp;
  4088. +   int ntries;
  4089. +
  4090. +   if (sc->mac_rev == 0x28720200)
  4091. +       return;
  4092. +
  4093. +   for (ntries = 0; ntries < 100; ntries++)
  4094. +   {
  4095. +       if (!(rt2860_io_mac_read(sc, RT2860_REG_H2M_MAILBOX) &
  4096. +           RT2860_REG_H2M_BUSY))
  4097. +           break;
  4098. +
  4099. +       DELAY(2);
  4100. +   }
  4101. +
  4102. +   if (ntries == 100)
  4103. +   {
  4104. +       printf("%s: could not read H2M: cmd=0x%02x\n",
  4105. +           device_get_nameunit(sc->sc_dev), cmd);
  4106. +       return;
  4107. +   }
  4108. +
  4109. +   tmp = RT2860_REG_H2M_BUSY | (token << 16) | arg;
  4110. +
  4111. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX, tmp);
  4112. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_HOST_CMD, cmd);
  4113. +}
  4114. +
  4115. +/*
  4116. + * rt2860_io_mcu_cmd_check
  4117. + */
  4118. +int rt2860_io_mcu_cmd_check(struct rt2860_softc *sc, uint8_t cid)
  4119. +{
  4120. +   uint32_t tmp, mask, status;
  4121. +   int result, ntries;
  4122. +
  4123. +   result = -1;
  4124. +
  4125. +   for (ntries = 0; ntries < 200; ntries++)
  4126. +   {
  4127. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_H2M_MAILBOX_CID);
  4128. +
  4129. +       if (((cid >> RT2860_REG_H2M_CID0_SHIFT) & RT2860_REG_H2M_CID_MASK) == cid)
  4130. +       {
  4131. +           mask = (RT2860_REG_H2M_CID_MASK << RT2860_REG_H2M_CID0_SHIFT);
  4132. +           break;
  4133. +       }
  4134. +       else if (((tmp >> RT2860_REG_H2M_CID1_SHIFT) & RT2860_REG_H2M_CID_MASK) == cid)
  4135. +       {
  4136. +           mask = (RT2860_REG_H2M_CID_MASK << RT2860_REG_H2M_CID1_SHIFT);
  4137. +           break;
  4138. +       }
  4139. +       else if (((tmp >> RT2860_REG_H2M_CID2_SHIFT) & RT2860_REG_H2M_CID_MASK) == cid)
  4140. +       {
  4141. +           mask = (RT2860_REG_H2M_CID_MASK << RT2860_REG_H2M_CID2_SHIFT);
  4142. +           break;
  4143. +       }
  4144. +       else if (((tmp >> RT2860_REG_H2M_CID3_SHIFT) & RT2860_REG_H2M_CID_MASK) == cid)
  4145. +       {
  4146. +           mask = (RT2860_REG_H2M_CID_MASK << RT2860_REG_H2M_CID3_SHIFT);
  4147. +           break;
  4148. +       }
  4149. +
  4150. +       DELAY(100);
  4151. +   }
  4152. +
  4153. +   status = rt2860_io_mac_read(sc, RT2860_REG_H2M_MAILBOX_STATUS);
  4154. +
  4155. +   if (ntries < 200)
  4156. +   {
  4157. +       status &= mask;
  4158. +
  4159. +       if ((status == 0x1) ||
  4160. +           (status == 0x100) ||
  4161. +           (status == 0x10000) ||
  4162. +           (status == 0x1000000))
  4163. +           result = 0;
  4164. +   }
  4165. +
  4166. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX_STATUS, 0xffffffff);
  4167. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX_CID, 0xffffffff);
  4168. +
  4169. +   return result;
  4170. +}
  4171. +
  4172. +/*
  4173. + * rt2860_io_mcu_load_ucode
  4174. + */
  4175. +int rt2860_io_mcu_load_ucode(struct rt2860_softc *sc,
  4176. +   const uint8_t *ucode, size_t len)
  4177. +{
  4178. +   int i, ntries;
  4179. +   uint16_t crc;
  4180. +
  4181. +   for (i = 0, crc = 0xffff; i < len - 2; i++)
  4182. +       crc = RT2860_IO_BYTE_CRC16(rt2860_io_byte_rev(ucode[i]), crc);
  4183. +
  4184. +   if (ucode[len - 2] != rt2860_io_byte_rev(crc >> 8) ||
  4185. +       ucode[len - 1] != rt2860_io_byte_rev(crc))
  4186. +   {
  4187. +       printf("%s: wrong microcode crc\n",
  4188. +           device_get_nameunit(sc->sc_dev));
  4189. +       return EINVAL;
  4190. +   }
  4191. +
  4192. +   rt2860_io_mac_write(sc, RT2860_REG_PBF_SYS_CTRL, RT2860_REG_HST_PM_SEL);
  4193. +
  4194. +   for(i = 0; i < len; i += 4)
  4195. +   {
  4196. +       rt2860_io_mac_write(sc, RT2860_REG_MCU_UCODE_BASE + i,
  4197. +           (ucode[i+3] << 24) | (ucode[i+2] << 16) |
  4198. +           (ucode[i+1] << 8) | ucode[i]);
  4199. +   }
  4200. +
  4201. +   if (sc->mac_rev != 0x28720200)
  4202. +       rt2860_io_mac_write_multi(sc, RT2860_REG_MCU_UCODE_BASE,
  4203. +           ucode, len);
  4204. +
  4205. +   rt2860_io_mac_write(sc, RT2860_REG_PBF_SYS_CTRL, 0);
  4206. +
  4207. +   if (sc->mac_rev != 0x28720200)
  4208. +       rt2860_io_mac_write(sc, RT2860_REG_PBF_SYS_CTRL,
  4209. +           RT2860_REG_MCU_RESET);
  4210. +
  4211. +   DELAY(10000);
  4212. +
  4213. +   /* initialize BBP R/W access agent */
  4214. +
  4215. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX_BBP_AGENT, 0);
  4216. +   rt2860_io_mac_write(sc, RT2860_REG_H2M_MAILBOX, 0);
  4217. +
  4218. +   if (sc->mac_rev != 0x28720200) {
  4219. +
  4220. +       for (ntries = 0; ntries < 1000; ntries++)
  4221. +       {
  4222. +           if (rt2860_io_mac_read(sc, RT2860_REG_PBF_SYS_CTRL) &
  4223. +               RT2860_REG_MCU_READY)
  4224. +               break;
  4225. +
  4226. +           DELAY(1000);
  4227. +       }
  4228. +
  4229. +       if (ntries == 1000)
  4230. +       {
  4231. +           printf("%s: timeout waiting for MCU to initialize\n",
  4232. +               device_get_nameunit(sc->sc_dev));
  4233. +           return ETIMEDOUT;
  4234. +       }
  4235. +   }
  4236. +
  4237. +   return 0;
  4238. +}
  4239. +
  4240. +/*
  4241. + * rt2860_io_eeprom_shiftout_bits
  4242. + */
  4243. +static void rt2860_io_eeprom_shiftout_bits(struct rt2860_softc *sc,
  4244. +   uint16_t val, uint16_t count)
  4245. +{
  4246. +   uint32_t mask, tmp;
  4247. +
  4248. +   mask = (1 << (count - 1));
  4249. +
  4250. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  4251. +
  4252. +   tmp &= ~(RT2860_REG_EEDO | RT2860_REG_EEDI);
  4253. +
  4254. +   do
  4255. +   {
  4256. +       tmp &= ~RT2860_REG_EEDI;
  4257. +
  4258. +       if(val & mask)
  4259. +           tmp |= RT2860_REG_EEDI;
  4260. +
  4261. +       rt2860_io_mac_write(sc, RT2860_REG_EEPROM_CSR, tmp);
  4262. +
  4263. +       RT2860_IO_EEPROM_RAISE_CLK(sc, tmp);
  4264. +       RT2860_IO_EEPROM_LOWER_CLK(sc, tmp);
  4265. +
  4266. +       mask = (mask >> 1);
  4267. +   } while (mask);
  4268. +
  4269. +   tmp &= ~RT2860_REG_EEDI;
  4270. +
  4271. +   rt2860_io_mac_write(sc, RT2860_REG_EEPROM_CSR, tmp);
  4272. +}
  4273. +
  4274. +/*
  4275. + * rt2860_io_eeprom_shiftin_bits
  4276. + */
  4277. +static uint16_t rt2860_io_eeprom_shiftin_bits(struct rt2860_softc *sc)
  4278. +{
  4279. +   uint32_t tmp;
  4280. +   uint16_t val;
  4281. +   int i;
  4282. +
  4283. +   val = 0;
  4284. +
  4285. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  4286. +
  4287. +   tmp &= ~(RT2860_REG_EEDO | RT2860_REG_EEDI);
  4288. +
  4289. +   for(i = 0; i < 16; i++)
  4290. +   {
  4291. +       val = (val << 1);
  4292. +
  4293. +       RT2860_IO_EEPROM_RAISE_CLK(sc, tmp);
  4294. +
  4295. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  4296. +
  4297. +       RT2860_IO_EEPROM_LOWER_CLK(sc, tmp);
  4298. +      
  4299. +       tmp &= ~RT2860_REG_EEDI;
  4300. +       if(tmp & RT2860_REG_EEDO)
  4301. +           val |= 1;
  4302. +   }
  4303. +
  4304. +   return val;
  4305. +}
  4306. +
  4307. +/*
  4308. + * rt2860_io_byte_rev
  4309. + */
  4310. +static uint8_t rt2860_io_byte_rev(uint8_t byte)
  4311. +{
  4312. +   int i;
  4313. +   uint8_t tmp;
  4314. +
  4315. +   for(i = 0, tmp = 0; ; i++)
  4316. +   {
  4317. +       if(byte & 0x80)
  4318. +           tmp |= 0x80;
  4319. +
  4320. +       if(i == 7)
  4321. +           break;
  4322. +
  4323. +       byte <<= 1;
  4324. +       tmp >>= 1;
  4325. +   }
  4326. +
  4327. +   return tmp;
  4328. +}
  4329. +
  4330. +/*
  4331. + * rt2860_read_eeprom
  4332. + */
  4333. +void rt2860_read_eeprom(struct rt2860_softc *sc)
  4334. +{
  4335. +   uint32_t tmp;
  4336. +   uint16_t val;
  4337. +   int i;
  4338. +
  4339. +   /* read EEPROM address number */
  4340. +
  4341. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  4342. +
  4343. +   if((tmp & 0x30) == 0)
  4344. +       sc->eeprom_addr_num = 6;
  4345. +   else if((tmp & 0x30) == 0x10)
  4346. +       sc->eeprom_addr_num = 8;
  4347. +   else
  4348. +       sc->eeprom_addr_num = 8;
  4349. +
  4350. +   /* read EEPROM version */
  4351. +
  4352. +   sc->eeprom_rev = rt2860_io_eeprom_read(sc, RT2860_EEPROM_VERSION);
  4353. +
  4354. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4355. +       "%s: EEPROM rev=0x%04x\n",
  4356. +       device_get_nameunit(sc->sc_dev), sc->eeprom_rev);
  4357. +
  4358. +   /* read MAC address */
  4359. +
  4360. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_ADDRESS01);
  4361. +
  4362. +   sc->mac_addr[0] = (val & 0xff);
  4363. +   sc->mac_addr[1] = (val >> 8);
  4364. +
  4365. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_ADDRESS23);
  4366. +
  4367. +   sc->mac_addr[2] = (val & 0xff);
  4368. +   sc->mac_addr[3] = (val >> 8);
  4369. +
  4370. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_ADDRESS45);
  4371. +
  4372. +   sc->mac_addr[4] = (val & 0xff);
  4373. +   sc->mac_addr[5] = (val >> 8);
  4374. +
  4375. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4376. +       "%s: EEPROM mac address=%s\n",
  4377. +       device_get_nameunit(sc->sc_dev), ether_sprintf(sc->mac_addr));
  4378. +
  4379. +   /* read RF information */
  4380. +
  4381. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_ANTENNA);
  4382. +   if (val == 0xffff)
  4383. +   {
  4384. +       printf("%s: invalid EEPROM antenna info\n",
  4385. +           device_get_nameunit(sc->sc_dev));
  4386. +
  4387. +       sc->rf_rev = RT2860_EEPROM_RF_2820;
  4388. +       sc->ntxpath = 1;
  4389. +       sc->nrxpath = 2;
  4390. +   }
  4391. +   else
  4392. +   {
  4393. +       sc->rf_rev = (val >> 8) & 0xf;
  4394. +       sc->ntxpath = (val >> 4) & 0xf;
  4395. +       sc->nrxpath = (val & 0xf);
  4396. +   }
  4397. +
  4398. +   if ((sc->mac_rev != 0x28830300) && (sc->nrxpath > 2))
  4399. +   {
  4400. +       /* only 2 Rx streams for RT2860 series */
  4401. +
  4402. +       sc->nrxpath = 2;
  4403. +   }
  4404. +
  4405. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4406. +       "%s: EEPROM RF rev=0x%04x, paths=%dT%dR\n",
  4407. +       device_get_nameunit(sc->sc_dev), sc->rf_rev, sc->ntxpath, sc->nrxpath);
  4408. +
  4409. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_NIC_CONFIG);
  4410. +   if ((val & 0xff00) != 0xff00)
  4411. +       sc->patch_dac = (val >> 15) & 1;
  4412. +
  4413. +   sc->hw_radio_cntl = ((val & RT2860_EEPROM_HW_RADIO_CNTL) ? 1 : 0);
  4414. +   sc->tx_agc_cntl = ((val & RT2860_EEPROM_TX_AGC_CNTL) ? 1 : 0);
  4415. +   sc->ext_lna_2ghz = ((val & RT2860_EEPROM_EXT_LNA_2GHZ) ? 1 : 0);
  4416. +   sc->ext_lna_5ghz = ((val & RT2860_EEPROM_EXT_LNA_5GHZ) ? 1 : 0);
  4417. +
  4418. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4419. +       "%s: EEPROM NIC config: HW radio cntl=%d, Tx AGC cntl=%d, ext LNA gains=%d/%d\n",
  4420. +       device_get_nameunit(sc->sc_dev),
  4421. +       sc->hw_radio_cntl, sc->tx_agc_cntl, sc->ext_lna_2ghz, sc->ext_lna_5ghz);
  4422. +
  4423. +   /* read country code */
  4424. +
  4425. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_COUNTRY);
  4426. +
  4427. +   sc->country_2ghz = (val >> 8) & 0xff;
  4428. +   sc->country_5ghz = (val & 0xff);
  4429. +
  4430. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4431. +       "%s: EEPROM country code=%d/%d\n",
  4432. +       device_get_nameunit(sc->sc_dev), sc->country_2ghz, sc->country_5ghz);
  4433. +
  4434. +   /* read RF frequency offset */
  4435. +
  4436. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_RF_FREQ_OFF);
  4437. +
  4438. +   if ((val & 0xff) != 0xff)
  4439. +   {
  4440. +       sc->rf_freq_off = (val & 0xff);
  4441. +   }
  4442. +   else
  4443. +   {
  4444. +       printf("%s: invalid EEPROM RF freq offset\n",
  4445. +           device_get_nameunit(sc->sc_dev));
  4446. +
  4447. +       sc->rf_freq_off = 0;
  4448. +   }
  4449. +
  4450. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4451. +       "%s: EEPROM freq offset=0x%02x\n",
  4452. +       device_get_nameunit(sc->sc_dev), sc->rf_freq_off);
  4453. +
  4454. +   /* read LEDs operating mode */
  4455. +
  4456. +   if (((val >> 8) & 0xff) != 0xff)
  4457. +   {
  4458. +       sc->led_cntl = ((val >> 8) & 0xff);
  4459. +       sc->led_off[0] = rt2860_io_eeprom_read(sc, RT2860_EEPROM_LED1_OFF);
  4460. +       sc->led_off[1] = rt2860_io_eeprom_read(sc, RT2860_EEPROM_LED2_OFF);
  4461. +       sc->led_off[2] = rt2860_io_eeprom_read(sc, RT2860_EEPROM_LED3_OFF);
  4462. +   }
  4463. +   else
  4464. +   {
  4465. +       printf("%s: invalid EEPROM LED settings\n",
  4466. +           device_get_nameunit(sc->sc_dev));
  4467. +
  4468. +       sc->led_cntl = RT2860_EEPROM_LED_CNTL_DEFAULT;
  4469. +       sc->led_off[0] = RT2860_EEPROM_LED1_OFF_DEFAULT;
  4470. +       sc->led_off[1] = RT2860_EEPROM_LED2_OFF_DEFAULT;
  4471. +       sc->led_off[2] = RT2860_EEPROM_LED3_OFF_DEFAULT;
  4472. +   }
  4473. +
  4474. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4475. +       "%s: EEPROM LED cntl=0x%02x, LEDs=0x%04x/0x%04x/0x%04x\n",
  4476. +       device_get_nameunit(sc->sc_dev), sc->led_cntl,
  4477. +       sc->led_off[0], sc->led_off[1], sc->led_off[2]);
  4478. +
  4479. +   /* read RSSI offsets and LNA gains */
  4480. +
  4481. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_LNA_GAIN);
  4482. +   if ((sc->mac_rev & 0xffff0000) >= 0x30710000)
  4483. +       sc->lna_gain[0] = RT3090_DEF_LNA;
  4484. +   else                /* channel group 0 */
  4485. +       sc->lna_gain[0] = val & 0xff;
  4486. +
  4487. +   sc->lna_gain[1] = (val >> 8) & 0xff;
  4488. +
  4489. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_RSSI_OFF_2GHZ_BASE);
  4490. +
  4491. +   sc->rssi_off_2ghz[0] = (val & 0xff);
  4492. +   sc->rssi_off_2ghz[1] = (val >> 8) & 0xff;
  4493. +
  4494. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_RSSI_OFF_2GHZ_BASE + 2);
  4495. +
  4496. +   if ((sc->mac_rev & 0xffff0000) >= 0x30710000) {
  4497. +       /*
  4498. +        * On RT3090 chips (limited to 2 Rx chains), this ROM
  4499. +        * field contains the Tx mixer gain for the 2GHz band.
  4500. +        */
  4501. +       if ((val & 0xff) != 0xff)
  4502. +           sc->txmixgain_2ghz = val & 0x7;
  4503. +   } else
  4504. +       sc->rssi_off_2ghz[2] = val & 0xff;  /* Ant C */
  4505. +   sc->lna_gain[2] = (val >> 8) & 0xff;
  4506. +
  4507. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_RSSI_OFF_5GHZ_BASE);
  4508. +
  4509. +   sc->rssi_off_5ghz[0] = (val & 0xff);
  4510. +   sc->rssi_off_5ghz[1] = (val >> 8) & 0xff;
  4511. +
  4512. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_RSSI_OFF_5GHZ_BASE + 2);
  4513. +
  4514. +   sc->rssi_off_5ghz[2] = (val & 0xff);
  4515. +   sc->lna_gain[3] = (val >> 8) & 0xff;
  4516. +
  4517. +   for (i = 2; i < RT2860_SOFTC_LNA_GAIN_COUNT; i++)
  4518. +   {
  4519. +       if (sc->lna_gain[i] == 0x00 || sc->lna_gain[i] == (int8_t) 0xff)
  4520. +       {
  4521. +           printf("%s: invalid EEPROM LNA gain #%d: 0x%02x\n",
  4522. +               device_get_nameunit(sc->sc_dev), i, sc->lna_gain[i]);
  4523. +
  4524. +           sc->lna_gain[i] = sc->lna_gain[1];
  4525. +       }
  4526. +   }
  4527. +
  4528. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4529. +       "%s: EEPROM LNA gains=0x%02x/0x%02x/0x%02x/0x%02x\n",
  4530. +       device_get_nameunit(sc->sc_dev),
  4531. +       sc->lna_gain[0], sc->lna_gain[1], sc->lna_gain[2], sc->lna_gain[3]);
  4532. +
  4533. +   for (i = 0; i < RT2860_SOFTC_RSSI_OFF_COUNT; i++)
  4534. +   {
  4535. +       if (sc->rssi_off_2ghz[i] < RT2860_EEPROM_RSSI_OFF_MIN ||
  4536. +           sc->rssi_off_2ghz[i] > RT2860_EEPROM_RSSI_OFF_MAX)
  4537. +       {
  4538. +           printf("%s: invalid EEPROM RSSI offset #%d (2GHz): 0x%02x\n",
  4539. +               device_get_nameunit(sc->sc_dev), i, sc->rssi_off_2ghz[i]);
  4540. +
  4541. +           sc->rssi_off_2ghz[i] = 0;
  4542. +       }
  4543. +
  4544. +       if (sc->rssi_off_5ghz[i] < RT2860_EEPROM_RSSI_OFF_MIN ||
  4545. +           sc->rssi_off_5ghz[i] > RT2860_EEPROM_RSSI_OFF_MAX)
  4546. +       {
  4547. +           printf("%s: invalid EEPROM RSSI offset #%d (5GHz): 0x%02x\n",
  4548. +               device_get_nameunit(sc->sc_dev), i, sc->rssi_off_5ghz[i]);
  4549. +
  4550. +           sc->rssi_off_5ghz[i] = 0;
  4551. +       }
  4552. +   }
  4553. +
  4554. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4555. +       "%s: EEPROM RSSI offsets 2GHz=%d/%d/%d\n",
  4556. +       device_get_nameunit(sc->sc_dev),
  4557. +       sc->rssi_off_2ghz[0], sc->rssi_off_2ghz[1], sc->rssi_off_2ghz[2]);
  4558. +
  4559. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4560. +       "%s: EEPROM RSSI offsets 5GHz=%d/%d/%d\n",
  4561. +       device_get_nameunit(sc->sc_dev),
  4562. +       sc->rssi_off_5ghz[0], sc->rssi_off_5ghz[1], sc->rssi_off_5ghz[2]);
  4563. +
  4564. +   /* read Tx power settings for 2GHz channels */
  4565. +
  4566. +   for (i = 0; i < 14; i += 2)
  4567. +   {
  4568. +       val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TXPOW1_2GHZ_BASE + i / 2);
  4569. +
  4570. +       sc->txpow1[i + 0] = (int8_t) (val & 0xff);
  4571. +       sc->txpow1[i + 1] = (int8_t) (val >> 8);
  4572. +
  4573. +       val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TXPOW2_2GHZ_BASE + i / 2);
  4574. +
  4575. +       sc->txpow2[i + 0] = (int8_t) (val & 0xff);
  4576. +       sc->txpow2[i + 1] = (int8_t) (val >> 8);
  4577. +   }
  4578. +
  4579. +   /* read Tx power settings for 5GHz channels */
  4580. +
  4581. +   for (; i < RT2860_SOFTC_TXPOW_COUNT; i += 2)
  4582. +   {
  4583. +       val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TXPOW1_5GHZ_BASE + i / 2);
  4584. +
  4585. +       sc->txpow1[i + 0] = (int8_t) (val & 0xff);
  4586. +       sc->txpow1[i + 1] = (int8_t) (val >> 8);
  4587. +
  4588. +       val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TXPOW2_5GHZ_BASE + i / 2);
  4589. +
  4590. +       sc->txpow2[i + 0] = (int8_t) (val & 0xff);
  4591. +       sc->txpow2[i + 1] = (int8_t) (val >> 8);
  4592. +   }
  4593. +
  4594. +   /* fix broken Tx power settings */
  4595. +
  4596. +    for (i = 0; i < 14; i++)
  4597. +   {
  4598. +       if (sc->txpow1[i] < RT2860_EEPROM_TXPOW_2GHZ_MIN ||
  4599. +           sc->txpow1[i] > RT2860_EEPROM_TXPOW_2GHZ_MAX)
  4600. +       {
  4601. +           printf("%s: invalid EEPROM Tx power1 #%d (2GHz): 0x%02x\n",
  4602. +               device_get_nameunit(sc->sc_dev), i, sc->txpow1[i]);
  4603. +
  4604. +           sc->txpow1[i] = RT2860_EEPROM_TXPOW_2GHZ_DEFAULT;
  4605. +       }
  4606. +
  4607. +       if (sc->txpow2[i] < RT2860_EEPROM_TXPOW_2GHZ_MIN ||
  4608. +           sc->txpow2[i] > RT2860_EEPROM_TXPOW_2GHZ_MAX)
  4609. +       {
  4610. +           printf("%s: invalid EEPROM Tx power2 #%d (2GHz): 0x%02x\n",
  4611. +               device_get_nameunit(sc->sc_dev), i, sc->txpow2[i]);
  4612. +
  4613. +           sc->txpow2[i] = RT2860_EEPROM_TXPOW_2GHZ_DEFAULT;
  4614. +       }
  4615. +   }
  4616. +
  4617. +   for (; i < RT2860_SOFTC_TXPOW_COUNT; i++)
  4618. +   {
  4619. +       if (sc->txpow1[i] < RT2860_EEPROM_TXPOW_5GHZ_MIN ||
  4620. +           sc->txpow1[i] > RT2860_EEPROM_TXPOW_5GHZ_MAX)
  4621. +       {
  4622. +           printf("%s: invalid EEPROM Tx power1 #%d (5GHz): 0x%02x\n",
  4623. +               device_get_nameunit(sc->sc_dev), i, sc->txpow1[i]);
  4624. +
  4625. +           sc->txpow1[i] = RT2860_EEPROM_TXPOW_5GHZ_DEFAULT;
  4626. +       }
  4627. +
  4628. +       if (sc->txpow2[i] < RT2860_EEPROM_TXPOW_5GHZ_MIN ||
  4629. +           sc->txpow2[i] > RT2860_EEPROM_TXPOW_5GHZ_MAX)
  4630. +       {
  4631. +           printf("%s: invalid EEPROM Tx power2 #%d (5GHz): 0x%02x\n",
  4632. +               device_get_nameunit(sc->sc_dev), i, sc->txpow2[i]);
  4633. +
  4634. +           sc->txpow2[i] = RT2860_EEPROM_TXPOW_5GHZ_DEFAULT;
  4635. +       }
  4636. +   }
  4637. +
  4638. +   /* read Tx power per rate deltas */
  4639. +
  4640. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TXPOW_RATE_DELTA);
  4641. +
  4642. +   sc->txpow_rate_delta_2ghz = 0;
  4643. +   sc->txpow_rate_delta_5ghz = 0;
  4644. +
  4645. +   if ((val & 0xff) != 0xff)
  4646. +   {
  4647. +       if (val & 0x80)
  4648. +           sc->txpow_rate_delta_2ghz = (val & 0xf);
  4649. +
  4650. +       if (!(val & 0x40))
  4651. +           sc->txpow_rate_delta_2ghz = -sc->txpow_rate_delta_2ghz;
  4652. +   }
  4653. +
  4654. +   val >>= 8;
  4655. +
  4656. +   if ((val & 0xff) != 0xff)
  4657. +   {
  4658. +       if (val & 0x80)
  4659. +           sc->txpow_rate_delta_5ghz = (val & 0xf);
  4660. +
  4661. +       if (!(val & 0x40))
  4662. +           sc->txpow_rate_delta_5ghz = -sc->txpow_rate_delta_5ghz;
  4663. +   }
  4664. +
  4665. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4666. +       "%s: EEPROM Tx power per rate deltas=%d(2MHz), %d(5MHz)\n",
  4667. +       device_get_nameunit(sc->sc_dev),
  4668. +       sc->txpow_rate_delta_2ghz, sc->txpow_rate_delta_5ghz);
  4669. +
  4670. +   /* read Tx power per rate */
  4671. +
  4672. +   for (i = 0; i < RT2860_SOFTC_TXPOW_RATE_COUNT; i++)
  4673. +   {
  4674. +       rt2860_io_eeprom_read_multi(sc, RT2860_EEPROM_TXPOW_RATE_BASE + i * sizeof(uint32_t),
  4675. +           &tmp, sizeof(uint32_t));
  4676. +
  4677. +       sc->txpow_rate_20mhz[i] = tmp;
  4678. +       sc->txpow_rate_40mhz_2ghz[i] =
  4679. +           rt2860_read_eeprom_txpow_rate_add_delta(tmp, sc->txpow_rate_delta_2ghz);
  4680. +       sc->txpow_rate_40mhz_5ghz[i] =
  4681. +           rt2860_read_eeprom_txpow_rate_add_delta(tmp, sc->txpow_rate_delta_5ghz);
  4682. +
  4683. +       RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4684. +           "%s: EEPROM Tx power per rate #%d=0x%08x(20MHz), 0x%08x(40MHz/2GHz), 0x%08x(40MHz/5GHz)\n",
  4685. +           device_get_nameunit(sc->sc_dev), i,
  4686. +           sc->txpow_rate_20mhz[i], sc->txpow_rate_40mhz_2ghz[i], sc->txpow_rate_40mhz_5ghz[i]);
  4687. +   }
  4688. +
  4689. +   if (sc->tx_agc_cntl)
  4690. +       sc->tx_agc_cntl_2ghz = sc->tx_agc_cntl_5ghz = 1;
  4691. +
  4692. +   /* read factory-calibrated samples for temperature compensation */
  4693. +
  4694. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_2GHZ_BASE);
  4695. +
  4696. +   sc->tssi_2ghz[0] = (val & 0xff);    /* [-4] */
  4697. +   sc->tssi_2ghz[1] = (val >> 8);      /* [-3] */
  4698. +
  4699. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_2GHZ_BASE + 2);
  4700. +
  4701. +   sc->tssi_2ghz[2] = (val & 0xff);    /* [-2] */
  4702. +   sc->tssi_2ghz[3] = (val >> 8);      /* [-1] */
  4703. +
  4704. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_2GHZ_BASE + 2 * 2);
  4705. +
  4706. +   sc->tssi_2ghz[4] = (val & 0xff);    /* [0] */
  4707. +   sc->tssi_2ghz[5] = (val >> 8);      /* [+1] */
  4708. +
  4709. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_2GHZ_BASE + 3 * 2);
  4710. +
  4711. +   sc->tssi_2ghz[6] = (val & 0xff);    /* [+2] */
  4712. +   sc->tssi_2ghz[7] = (val >> 8);      /* [+3] */
  4713. +
  4714. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_2GHZ_BASE + 4 * 2);
  4715. +
  4716. +   sc->tssi_2ghz[8] = (val & 0xff);    /* [+4] */
  4717. +   sc->tssi_step_2ghz = (val >> 8);
  4718. +
  4719. +   if (sc->tssi_2ghz[4] == 0xff)
  4720. +       sc->tx_agc_cntl_2ghz = 0;
  4721. +
  4722. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4723. +       "%s: EEPROM TSSI 2GHz: 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, "
  4724. +       "0x%02x, 0x%02x, step=%d\n",
  4725. +       device_get_nameunit(sc->sc_dev),
  4726. +       sc->tssi_2ghz[0], sc->tssi_2ghz[1], sc->tssi_2ghz[2],
  4727. +       sc->tssi_2ghz[3], sc->tssi_2ghz[4], sc->tssi_2ghz[5],
  4728. +       sc->tssi_2ghz[6], sc->tssi_2ghz[7], sc->tssi_2ghz[8],
  4729. +       sc->tssi_step_2ghz);
  4730. +
  4731. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_5GHZ_BASE);
  4732. +
  4733. +   sc->tssi_5ghz[0] = (val & 0xff);    /* [-4] */
  4734. +   sc->tssi_5ghz[1] = (val >> 8);      /* [-3] */
  4735. +
  4736. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_5GHZ_BASE + 2);
  4737. +
  4738. +   sc->tssi_5ghz[2] = (val & 0xff);    /* [-2] */
  4739. +   sc->tssi_5ghz[3] = (val >> 8);      /* [-1] */
  4740. +
  4741. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_5GHZ_BASE + 2 * 2);
  4742. +
  4743. +   sc->tssi_5ghz[4] = (val & 0xff);    /* [0] */
  4744. +   sc->tssi_5ghz[5] = (val >> 8);      /* [+1] */
  4745. +
  4746. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_5GHZ_BASE + 3 * 2);
  4747. +
  4748. +   sc->tssi_5ghz[6] = (val & 0xff);    /* [+2] */
  4749. +   sc->tssi_5ghz[7] = (val >> 8);      /* [+3] */
  4750. +
  4751. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_TSSI_5GHZ_BASE + 4 * 2);
  4752. +
  4753. +   sc->tssi_5ghz[8] = (val & 0xff);    /* [+4] */
  4754. +   sc->tssi_step_5ghz = (val >> 8);
  4755. +
  4756. +   if (sc->tssi_5ghz[4] == 0xff)
  4757. +       sc->tx_agc_cntl_5ghz = 0;
  4758. +
  4759. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4760. +       "%s: EEPROM TSSI 5GHz: 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, "
  4761. +       "0x%02x, 0x%02x, step=%d\n",
  4762. +       device_get_nameunit(sc->sc_dev),
  4763. +       sc->tssi_5ghz[0], sc->tssi_5ghz[1], sc->tssi_5ghz[2],
  4764. +       sc->tssi_5ghz[3], sc->tssi_5ghz[4], sc->tssi_5ghz[5],
  4765. +       sc->tssi_5ghz[6], sc->tssi_5ghz[7], sc->tssi_5ghz[8],
  4766. +       sc->tssi_step_5ghz);
  4767. +
  4768. +   /* read default BBP settings */
  4769. +
  4770. +   rt2860_io_eeprom_read_multi(sc, RT2860_EEPROM_BBP_BASE,
  4771. +       sc->bbp_eeprom, RT2860_SOFTC_BBP_EEPROM_COUNT * 2);
  4772. +
  4773. +   if ((sc->mac_rev & 0xffff0000) >= 0x30710000) {
  4774. +       /* read vendor RF settings */
  4775. +       rt2860_io_eeprom_read_multi(sc, RT3071_EEPROM_RF_BASE, sc->rf, 10 * 2);
  4776. +   }
  4777. +
  4778. +   /* read powersave level */
  4779. +   val = rt2860_io_eeprom_read(sc, RT2860_EEPROM_POWERSAVE_LEVEL);
  4780. +
  4781. +   sc->powersave_level = val & 0xff;
  4782. +
  4783. +   if ((sc->powersave_level & 0xff) == 0xff)
  4784. +       printf("%s: invalid EEPROM powersave level\n",
  4785. +           device_get_nameunit(sc->sc_dev));
  4786. +
  4787. +   RT2860_DPRINTF(sc, RT2860_DEBUG_EEPROM,
  4788. +       "%s: EEPROM powersave level=0x%02x\n",
  4789. +       device_get_nameunit(sc->sc_dev), sc->powersave_level);
  4790. +}
  4791. +
  4792. +/*
  4793. + * rt2860_read_eeprom_txpow_rate_add_delta
  4794. + */
  4795. +uint32_t rt2860_read_eeprom_txpow_rate_add_delta(uint32_t txpow_rate,
  4796. +   int8_t delta)
  4797. +{
  4798. +   int8_t b4;
  4799. +   int i;
  4800. +
  4801. +   for (i = 0; i < 8; i++)
  4802. +   {
  4803. +       b4 = txpow_rate & 0xf;
  4804. +       b4 += delta;
  4805. +
  4806. +       if (b4 < 0)
  4807. +           b4 = 0;
  4808. +       else if (b4 > 0xf)
  4809. +           b4 = 0xf;
  4810. +
  4811. +       txpow_rate = (txpow_rate >> 4) | (b4 << 28);
  4812. +   }
  4813. +
  4814. +   return txpow_rate;
  4815. +}
  4816. +
  4817. +/*
  4818. + *  LED functions NOTE/FIXME: Untested by me
  4819. + */
  4820. +
  4821. +/*
  4822. + * rt2860_led_brightness
  4823. + */
  4824. +void rt2860_led_brightness(struct rt2860_softc *sc, uint8_t brightness)
  4825. +{
  4826. +   uint8_t polarity;
  4827. +   uint16_t tmp;
  4828. +
  4829. +   polarity = (sc->led_cntl & RT2860_EEPROM_LED_POLARITY) ? 1 : 0;
  4830. +
  4831. +   tmp = (polarity << 8) | brightness;
  4832. +
  4833. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_LED_BRIGHTNESS,
  4834. +       RT2860_REG_H2M_TOKEN_NO_INTR, tmp);
  4835. +}
  4836. +
  4837. +/*
  4838. + * rt2860_led_cmd
  4839. + */
  4840. +void rt2860_led_cmd(struct rt2860_softc *sc, uint8_t cmd)
  4841. +{
  4842. +   uint16_t tmp;
  4843. +
  4844. +   tmp = (cmd << 8) | (sc->led_cntl & RT2860_EEPROM_LED_MODE_MASK);
  4845. +
  4846. +   rt2860_io_mcu_cmd(sc, RT2860_IO_MCU_CMD_LEDS,
  4847. +       RT2860_REG_H2M_TOKEN_NO_INTR, tmp);
  4848. +}
  4849. +
  4850. +/*
  4851. + *  RF MAC functions
  4852. + */
  4853. +
  4854. +
  4855. +uint8_t
  4856. +rt3090_rf_read(struct rt2860_softc *sc, uint8_t reg)
  4857. +{
  4858. +   uint32_t tmp;
  4859. +   int ntries;
  4860. +
  4861. +   for (ntries = 0; ntries < 100; ntries++) {
  4862. +       if (!(rt2860_io_mac_read(sc, RT3070_RF_CSR_CFG) & RT3070_RF_KICK))
  4863. +           break;
  4864. +       DELAY(1);
  4865. +   }
  4866. +   if (ntries == 100) {
  4867. +       device_printf(sc->sc_dev, "could not read RF register\n");
  4868. +       return 0xff;
  4869. +   }
  4870. +   tmp = RT3070_RF_KICK | reg << 8;
  4871. +   rt2860_io_mac_write(sc, RT3070_RF_CSR_CFG, tmp);
  4872. +
  4873. +   for (ntries = 0; ntries < 100; ntries++) {
  4874. +       tmp = rt2860_io_mac_read(sc, RT3070_RF_CSR_CFG);
  4875. +       if (!(tmp & RT3070_RF_KICK))
  4876. +           break;
  4877. +       DELAY(1);
  4878. +   }
  4879. +   if (ntries == 100) {
  4880. +       device_printf(sc->sc_dev, "could not read RF register\n");
  4881. +       return 0xff;
  4882. +   }
  4883. +   return tmp & 0xff;
  4884. +}
  4885. +
  4886. +void
  4887. +rt3090_rf_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val)
  4888. +{
  4889. +   uint32_t tmp;
  4890. +   int ntries;
  4891. +
  4892. +   for (ntries = 0; ntries < 10; ntries++) {
  4893. +       if (!(rt2860_io_mac_read(sc, RT3070_RF_CSR_CFG) & RT3070_RF_KICK))
  4894. +           break;
  4895. +       DELAY(10);
  4896. +   }
  4897. +   if (ntries == 10) {
  4898. +       device_printf(sc->sc_dev, "could not write to RF\n");
  4899. +       return;
  4900. +   }
  4901. +
  4902. +   tmp = RT3070_RF_WRITE | RT3070_RF_KICK | reg << 8 | val;
  4903. +   rt2860_io_mac_write(sc, RT3070_RF_CSR_CFG, tmp);
  4904. +}
  4905. +
  4906. +/*
  4907. + * rt2860_rf_name
  4908. + */
  4909. +const char *rt2860_rf_name(int rf_rev)
  4910. +{
  4911. +   switch (rf_rev)
  4912. +   {
  4913. +       case RT2860_EEPROM_RF_2820:
  4914. +           return "RT2820 2.4G 2T3R";
  4915. +
  4916. +       case RT2860_EEPROM_RF_2850:
  4917. +           return "RT2850 2.4G/5G 2T3R";
  4918. +
  4919. +       case RT2860_EEPROM_RF_2720:
  4920. +           return "RT2720 2.4G 1T2R";
  4921. +
  4922. +       case RT2860_EEPROM_RF_2750:
  4923. +           return "RT2750 2.4G/5G 1T2R";
  4924. +
  4925. +       case RT2860_EEPROM_RF_3020:
  4926. +           return "RT3020 2.4G 1T1R";
  4927. +
  4928. +       case RT2860_EEPROM_RF_2020:
  4929. +           return "RT2020 2.4G B/G";
  4930. +
  4931. +       case RT2860_EEPROM_RF_3021:
  4932. +           return "RT3021 2.4G 1T2R";
  4933. +
  4934. +       case RT2860_EEPROM_RF_3022:
  4935. +           return "RT3022 2.4G 2T2R";
  4936. +
  4937. +       case RT2860_EEPROM_RF_3052:
  4938. +           return "RT3052 2.4G/5G 2T2R";
  4939. +
  4940. +       case RT2860_EEPROM_RF_2853:
  4941. +           return "RT2853 2.4G.5G 3T3R";
  4942. +
  4943. +       case RT2860_EEPROM_RF_3320:
  4944. +           return "RT3320 2.4G 1T1R with PA";
  4945. +
  4946. +       case RT2860_EEPROM_RF_3322:
  4947. +           return "RT3322 2.4G 2T2R with PA";
  4948. +
  4949. +       case RT2860_EEPROM_RF_3053:
  4950. +           return "RT3053 2.4G/5G 3T3R";
  4951. +
  4952. +       default:
  4953. +           return "unknown";
  4954. +   }
  4955. +}
  4956. +
  4957. +/*
  4958. + * rt2860_rf_select_chan_group
  4959. + */
  4960. +void rt2860_rf_select_chan_group(struct rt2860_softc *sc,
  4961. +   struct ieee80211_channel *c)
  4962. +{
  4963. +   struct ifnet *ifp;
  4964. +   struct ieee80211com *ic;
  4965. +   int chan, group;
  4966. +   uint32_t tmp;
  4967. +
  4968. +   ifp = sc->sc_ifp;
  4969. +   ic = ifp->if_l2com;
  4970. +
  4971. +   chan = ieee80211_chan2ieee(ic, c);
  4972. +   if (chan == 0 || chan == IEEE80211_CHAN_ANY)
  4973. +       return;
  4974. +
  4975. +   if (chan <= 14)
  4976. +       group = 0;
  4977. +   else if (chan <= 64)
  4978. +       group = 1;
  4979. +   else if (chan <= 128)
  4980. +       group = 2;
  4981. +   else
  4982. +       group = 3;
  4983. +
  4984. +   rt2860_io_bbp_write(sc, 62, 0x37 - sc->lna_gain[group]);
  4985. +   rt2860_io_bbp_write(sc, 63, 0x37 - sc->lna_gain[group]);
  4986. +   rt2860_io_bbp_write(sc, 64, 0x37 - sc->lna_gain[group]);
  4987. +   rt2860_io_bbp_write(sc, 86, 0x00);
  4988. +
  4989. +   if (group == 0)
  4990. +   {
  4991. +       if (sc->ext_lna_2ghz)
  4992. +       {
  4993. +           rt2860_io_bbp_write(sc, 82, 0x62);
  4994. +           rt2860_io_bbp_write(sc, 75, 0x46);
  4995. +       }
  4996. +       else
  4997. +       {
  4998. +           rt2860_io_bbp_write(sc, 82, 0x84);
  4999. +           rt2860_io_bbp_write(sc, 75, 0x50);
  5000. +       }
  5001. +   }
  5002. +   else
  5003. +   {
  5004. +       rt2860_io_bbp_write(sc, 82, 0xf2);
  5005. +
  5006. +       if (sc->ext_lna_5ghz)
  5007. +           rt2860_io_bbp_write(sc, 75, 0x46);
  5008. +       else
  5009. +           rt2860_io_bbp_write(sc, 75, 0x50);
  5010. +   }
  5011. +
  5012. +   if (group == 0)
  5013. +   {
  5014. +       tmp = 0x2e + sc->lna_gain[group];
  5015. +   }
  5016. +   else
  5017. +   {
  5018. +       if ((ic->ic_flags & IEEE80211_F_SCAN) || !IEEE80211_IS_CHAN_HT40(c))
  5019. +           tmp = 0x32 + sc->lna_gain[group] * 5 / 3;
  5020. +       else
  5021. +           tmp = 0x3a + sc->lna_gain[group] * 5 / 3;
  5022. +   }
  5023. +
  5024. +   rt2860_io_bbp_write(sc, 66, tmp);
  5025. +
  5026. +   tmp = RT2860_REG_RFTR_ENABLE |
  5027. +       RT2860_REG_TRSW_ENABLE |
  5028. +       RT2860_REG_LNA_PE_G1_ENABLE |
  5029. +       RT2860_REG_LNA_PE_A1_ENABLE |
  5030. +       RT2860_REG_LNA_PE_G0_ENABLE |
  5031. +       RT2860_REG_LNA_PE_A0_ENABLE;
  5032. +
  5033. +   if (group == 0)
  5034. +       tmp |= RT2860_REG_PA_PE_G1_ENABLE |
  5035. +           RT2860_REG_PA_PE_G0_ENABLE;
  5036. +   else
  5037. +       tmp |= RT2860_REG_PA_PE_A1_ENABLE |
  5038. +           RT2860_REG_PA_PE_A0_ENABLE;
  5039. +
  5040. +   if (sc->ntxpath == 1)
  5041. +       tmp &= ~(RT2860_REG_PA_PE_G1_ENABLE | RT2860_REG_PA_PE_A1_ENABLE);
  5042. +
  5043. +   if (sc->nrxpath == 1)
  5044. +       tmp &= ~(RT2860_REG_LNA_PE_G1_ENABLE | RT2860_REG_LNA_PE_A1_ENABLE);
  5045. +
  5046. +   rt2860_io_mac_write(sc, RT2860_REG_TX_PIN_CFG, tmp);
  5047. +
  5048. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_BAND_CFG);
  5049. +
  5050. +   tmp &= ~(RT2860_REG_TX_BAND_BG | RT2860_REG_TX_BAND_A | RT2860_REG_TX_BAND_HT40_ABOVE);
  5051. +
  5052. +   if (group == 0)
  5053. +       tmp |= RT2860_REG_TX_BAND_BG;
  5054. +   else
  5055. +       tmp |= RT2860_REG_TX_BAND_A;
  5056. +
  5057. +   /* set central channel position */
  5058. +
  5059. +   if (IEEE80211_IS_CHAN_HT40U(c))
  5060. +       tmp |= RT2860_REG_TX_BAND_HT40_BELOW;
  5061. +   else if (IEEE80211_IS_CHAN_HT40D(c))
  5062. +       tmp |= RT2860_REG_TX_BAND_HT40_ABOVE;
  5063. +   else
  5064. +       tmp |= RT2860_REG_TX_BAND_HT40_BELOW;
  5065. +
  5066. +   rt2860_io_mac_write(sc, RT2860_REG_TX_BAND_CFG, tmp);
  5067. +
  5068. +   /* set bandwidth (20MHz or 40MHz) */
  5069. +
  5070. +   tmp = rt2860_io_bbp_read(sc, 4);
  5071. +
  5072. +   tmp &= ~0x18;
  5073. +
  5074. +   if (IEEE80211_IS_CHAN_HT40(c))
  5075. +       tmp |= 0x10;
  5076. +
  5077. +   rt2860_io_bbp_write(sc, 4, tmp);
  5078. +
  5079. +   /* set central channel position */
  5080. +
  5081. +   tmp = rt2860_io_bbp_read(sc, 3);
  5082. +
  5083. +   tmp &= ~0x20;
  5084. +
  5085. +   if (IEEE80211_IS_CHAN_HT40D(c))
  5086. +       tmp |= 0x20;
  5087. +
  5088. +   rt2860_io_bbp_write(sc, 3, tmp);
  5089. +
  5090. +   if (sc->mac_rev == 0x28600100)
  5091. +   {
  5092. +       if (!IEEE80211_IS_CHAN_HT40(c))
  5093. +       {
  5094. +           rt2860_io_bbp_write(sc, 69, 0x16);
  5095. +           rt2860_io_bbp_write(sc, 70, 0x08);
  5096. +           rt2860_io_bbp_write(sc, 73, 0x12);
  5097. +       }
  5098. +       else
  5099. +       {
  5100. +           rt2860_io_bbp_write(sc, 69, 0x1a);
  5101. +           rt2860_io_bbp_write(sc, 70, 0x0a);
  5102. +           rt2860_io_bbp_write(sc, 73, 0x16);
  5103. +       }
  5104. +   }
  5105. +
  5106. +}
  5107. +
  5108. +void
  5109. +rt3090_set_chan(struct rt2860_softc *sc, u_int chan)
  5110. +{
  5111. +   int8_t txpow1, txpow2;
  5112. +   uint8_t rf;
  5113. +   int i;
  5114. +
  5115. +   KASSERT((chan >= 1 && chan <= 14), "RT3090 is 2GHz only");  /* RT3090 is 2GHz only */
  5116. +
  5117. +   /* find the settings for this channel (we know it exists) */
  5118. +   for (i = 0; rt2860_rf2850[i].chan != chan; i++);
  5119. +
  5120. +   /* use Tx power values from EEPROM */
  5121. +   txpow1 = sc->txpow1[i];
  5122. +   txpow2 = sc->txpow2[i];
  5123. +
  5124. +   rt3090_rf_write(sc, 2, rt3090_freqs[i].n);
  5125. +   rf = rt3090_rf_read(sc, 3);
  5126. +   rf = (rf & ~0x0f) | rt3090_freqs[i].k;
  5127. +   rt3090_rf_write(sc, 3, rf);
  5128. +   rf = rt3090_rf_read(sc, 6);
  5129. +   rf = (rf & ~0x03) | rt3090_freqs[i].r;
  5130. +   rt3090_rf_write(sc, 6, rf);
  5131. +
  5132. +   /* set Tx0 power */
  5133. +   rf = rt3090_rf_read(sc, 12);
  5134. +   rf = (rf & ~0x1f) | txpow1;
  5135. +   rt3090_rf_write(sc, 12, rf);
  5136. +
  5137. +   /* set Tx1 power */
  5138. +   rf = rt3090_rf_read(sc, 13);
  5139. +   rf = (rf & ~0x1f) | txpow2;
  5140. +   rt3090_rf_write(sc, 13, rf);
  5141. +
  5142. +   rf = rt3090_rf_read(sc, 1);
  5143. +   rf &= ~0xfc;
  5144. +   if (sc->ntxpath == 1)
  5145. +       rf |= RT3070_TX1_PD | RT3070_TX2_PD;
  5146. +   else if (sc->ntxpath == 2)
  5147. +       rf |= RT3070_TX2_PD;
  5148. +   if (sc->nrxpath == 1)
  5149. +       rf |= RT3070_RX1_PD | RT3070_RX2_PD;
  5150. +   else if (sc->nrxpath == 2)
  5151. +       rf |= RT3070_RX2_PD;
  5152. +   rt3090_rf_write(sc, 1, rf);
  5153. +
  5154. +   /* set RF offset */
  5155. +   rf = rt3090_rf_read(sc, 23);
  5156. +   rf = (rf & ~0x7f) | sc->rf_freq_off;
  5157. +   rt3090_rf_write(sc, 23, rf);
  5158. +
  5159. +   /* program RF filter */
  5160. +   rf = rt3090_rf_read(sc, 24);    /* Tx */
  5161. +   rf = (rf & ~0x3f) | sc->rf24_20mhz;
  5162. +   rt3090_rf_write(sc, 24, rf);
  5163. +   rf = rt3090_rf_read(sc, 31);    /* Rx */
  5164. +   rf = (rf & ~0x3f) | sc->rf24_20mhz;
  5165. +   rt3090_rf_write(sc, 31, rf);
  5166. +
  5167. +   /* enable RF tuning */
  5168. +   rf = rt3090_rf_read(sc, 7);
  5169. +   rt3090_rf_write(sc, 7, rf | RT3070_TUNE);
  5170. +}
  5171. +
  5172. +int
  5173. +rt3090_rf_init(struct rt2860_softc *sc)
  5174. +{
  5175. +   uint32_t tmp;
  5176. +   uint8_t rf, bbp;
  5177. +   int i;
  5178. +
  5179. +   rf = rt3090_rf_read(sc, 30);
  5180. +   /* toggle RF R30 bit 7 */
  5181. +   rt3090_rf_write(sc, 30, rf | 0x80);
  5182. +   DELAY(1000);
  5183. +   rt3090_rf_write(sc, 30, rf & ~0x80);
  5184. +
  5185. +   tmp = rt2860_io_mac_read(sc, RT3070_LDO_CFG0);
  5186. +   tmp &= ~0x1f000000;
  5187. +   if (sc->patch_dac && (sc->mac_rev & 0x0000ffff) < 0x0211)
  5188. +       tmp |= 0x0d000000;  /* 1.35V */
  5189. +   else
  5190. +       tmp |= 0x01000000;  /* 1.2V */
  5191. +   rt2860_io_mac_write(sc, RT3070_LDO_CFG0, tmp);
  5192. +
  5193. +   /* patch LNA_PE_G1 */
  5194. +   tmp = rt2860_io_mac_read(sc, RT3070_GPIO_SWITCH);
  5195. +   rt2860_io_mac_write(sc, RT3070_GPIO_SWITCH, tmp & ~0x20);
  5196. +
  5197. +   /* initialize RF registers to default value */
  5198. +   for (i = 0; i < (sizeof(rt3090_def_rf)/2); i++) {
  5199. +       rt3090_rf_write(sc, rt3090_def_rf[i].reg,
  5200. +           rt3090_def_rf[i].val);
  5201. +   }
  5202. +
  5203. +   /* select 20MHz bandwidth */
  5204. +   rt3090_rf_write(sc, 31, 0x14);
  5205. +
  5206. +   rf = rt3090_rf_read(sc, 6);
  5207. +   rt3090_rf_write(sc, 6, rf | 0x40);
  5208. +
  5209. +   if ((sc->mac_rev & 0xffff0000) != 0x35930000) {
  5210. +       /* calibrate filter for 20MHz bandwidth */
  5211. +       sc->rf24_20mhz = 0x1f;  /* default value */
  5212. +       rt3090_filter_calib(sc, 0x07, 0x16, &sc->rf24_20mhz);
  5213. +
  5214. +       /* select 40MHz bandwidth */
  5215. +       bbp = rt2860_io_bbp_read(sc, 4);
  5216. +       rt2860_io_bbp_write(sc, 4, (bbp & ~0x08) | 0x10);
  5217. +       rf = rt3090_rf_read(sc, 31);
  5218. +       rt3090_rf_write(sc, 31, rf | 0x20);
  5219. +
  5220. +       /* calibrate filter for 40MHz bandwidth */
  5221. +       sc->rf24_40mhz = 0x2f;  /* default value */
  5222. +       rt3090_filter_calib(sc, 0x27, 0x19, &sc->rf24_40mhz);
  5223. +
  5224. +       /* go back to 20MHz bandwidth */
  5225. +       bbp = rt2860_io_bbp_read(sc, 4);
  5226. +       rt2860_io_bbp_write(sc, 4, bbp & ~0x18);
  5227. +   }
  5228. +   if ((sc->mac_rev & 0x0000ffff) < 0x0211)
  5229. +       rt3090_rf_write(sc, 27, 0x03);
  5230. +
  5231. +   tmp = rt2860_io_mac_read(sc, RT3070_OPT_14);
  5232. +   rt2860_io_mac_write(sc, RT3070_OPT_14, tmp | 1);
  5233. +
  5234. +   if (sc->rf_rev == RT2860_EEPROM_RF_3020)
  5235. +       rt3090_set_rx_antenna(sc, 0);
  5236. +
  5237. +   bbp = rt2860_io_bbp_read(sc, 138);
  5238. +   if ((sc->mac_rev & 0xffff0000) == 0x35930000) {
  5239. +       if (sc->ntxpath == 1)
  5240. +           bbp |= 0x60;    /* turn off DAC1 and DAC2 */
  5241. +       else if (sc->ntxpath == 2)
  5242. +           bbp |= 0x40;    /* turn off DAC2 */
  5243. +       if (sc->nrxpath == 1)
  5244. +           bbp &= ~0x06;   /* turn off ADC1 and ADC2 */
  5245. +       else if (sc->nrxpath == 2)
  5246. +           bbp &= ~0x04;   /* turn off ADC2 */
  5247. +   } else {
  5248. +       if (sc->ntxpath == 1)
  5249. +           bbp |= 0x20;    /* turn off DAC1 */
  5250. +       if (sc->nrxpath == 1)
  5251. +           bbp &= ~0x02;   /* turn off ADC1 */
  5252. +   }
  5253. +   rt2860_io_bbp_write(sc, 138, bbp);
  5254. +
  5255. +   rf = rt3090_rf_read(sc, 1);
  5256. +   rf &= ~(RT3070_RX0_PD | RT3070_TX0_PD);
  5257. +   rf |= RT3070_RF_BLOCK | RT3070_RX1_PD | RT3070_TX1_PD;
  5258. +   rt3090_rf_write(sc, 1, rf);
  5259. +
  5260. +   rf = rt3090_rf_read(sc, 15);
  5261. +   rt3090_rf_write(sc, 15, rf & ~RT3070_TX_LO2);
  5262. +
  5263. +   rf = rt3090_rf_read(sc, 17);
  5264. +   rf &= ~RT3070_TX_LO1;
  5265. +   if ((sc->mac_rev & 0x0000ffff) >= 0x0211 && !sc->ext_lna_2ghz)
  5266. +       rf |= 0x20; /* fix for long range Rx issue */
  5267. +   if (sc->txmixgain_2ghz >= 2)
  5268. +       rf = (rf & ~0x7) | sc->txmixgain_2ghz;
  5269. +   rt3090_rf_write(sc, 17, rf);
  5270. +
  5271. +   rf = rt3090_rf_read(sc, 20);
  5272. +   rt3090_rf_write(sc, 20, rf & ~RT3070_RX_LO1);
  5273. +
  5274. +   rf = rt3090_rf_read(sc, 21);
  5275. +   rt3090_rf_write(sc, 21, rf & ~RT3070_RX_LO2);
  5276. +
  5277. +   return 0;
  5278. +}
  5279. +
  5280. +void
  5281. +rt3090_set_rx_antenna(struct rt2860_softc *sc, int aux)
  5282. +{
  5283. +   uint32_t tmp;
  5284. +
  5285. +   if (aux) {
  5286. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  5287. +       rt2860_io_mac_write(sc, RT2860_REG_EEPROM_CSR, tmp & ~RT2860_REG_EESK);
  5288. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_GPIO_CTRL_CFG);
  5289. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_GPIO_CTRL_CFG, (tmp & ~0x0808) | 0x08);
  5290. +   } else {
  5291. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_EEPROM_CSR);
  5292. +       rt2860_io_mac_write(sc, RT2860_REG_EEPROM_CSR, tmp | RT2860_REG_EESK);
  5293. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_GPIO_CTRL_CFG);
  5294. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_GPIO_CTRL_CFG, tmp & ~0x0808);
  5295. +   }
  5296. +}
  5297. +
  5298. +void
  5299. +rt3090_rf_wakeup(struct rt2860_softc *sc)
  5300. +{
  5301. +   uint32_t tmp;
  5302. +   uint8_t rf;
  5303. +
  5304. +   if ((sc->mac_rev & 0xffff0000) == 0x35930000) {
  5305. +       /* enable VCO */
  5306. +       rf = rt3090_rf_read(sc, 1);
  5307. +       rt3090_rf_write(sc, 1, rf | RT3593_VCO);
  5308. +
  5309. +       /* initiate VCO calibration */
  5310. +       rf = rt3090_rf_read(sc, 3);
  5311. +       rt3090_rf_write(sc, 3, rf | RT3593_VCOCAL);
  5312. +
  5313. +       /* enable VCO bias current control */
  5314. +       rf = rt3090_rf_read(sc, 6);
  5315. +       rt3090_rf_write(sc, 6, rf | RT3593_VCO_IC);
  5316. +
  5317. +       /* initiate res calibration */
  5318. +       rf = rt3090_rf_read(sc, 2);
  5319. +       rt3090_rf_write(sc, 2, rf | RT3593_RESCAL);
  5320. +
  5321. +       /* set reference current control to 0.33 mA */
  5322. +       rf = rt3090_rf_read(sc, 22);
  5323. +       rf &= ~RT3593_CP_IC_MASK;
  5324. +       rf |= 1 << RT3593_CP_IC_SHIFT;
  5325. +       rt3090_rf_write(sc, 22, rf);
  5326. +
  5327. +       /* enable RX CTB */
  5328. +       rf = rt3090_rf_read(sc, 46);
  5329. +       rt3090_rf_write(sc, 46, rf | RT3593_RX_CTB);
  5330. +
  5331. +       rf = rt3090_rf_read(sc, 20);
  5332. +       rf &= ~(RT3593_LDO_RF_VC_MASK | RT3593_LDO_PLL_VC_MASK);
  5333. +       rt3090_rf_write(sc, 20, rf);
  5334. +   } else {
  5335. +       /* enable RF block */
  5336. +       rf = rt3090_rf_read(sc, 1);
  5337. +       rt3090_rf_write(sc, 1, rf | RT3070_RF_BLOCK);
  5338. +
  5339. +       /* enable VCO bias current control */
  5340. +       rf = rt3090_rf_read(sc, 7);
  5341. +       rt3090_rf_write(sc, 7, rf | 0x30);
  5342. +
  5343. +       rf = rt3090_rf_read(sc, 9);
  5344. +       rt3090_rf_write(sc, 9, rf | 0x0e);
  5345. +
  5346. +       /* enable RX CTB */
  5347. +       rf = rt3090_rf_read(sc, 21);
  5348. +       rt3090_rf_write(sc, 21, rf | RT3070_RX_CTB);
  5349. +
  5350. +       /* fix Tx to Rx IQ glitch by raising RF voltage */
  5351. +       rf = rt3090_rf_read(sc, 27);
  5352. +       rf &= ~0x77;
  5353. +       if ((sc->mac_rev & 0x0000ffff) < 0x0211)
  5354. +           rf |= 0x03;
  5355. +       rt3090_rf_write(sc, 27, rf);
  5356. +   }
  5357. +   if (sc->patch_dac && (sc->mac_rev & 0x0000ffff) < 0x0211) {
  5358. +       tmp = rt2860_io_mac_read(sc, RT3070_LDO_CFG0);
  5359. +       tmp = (tmp & ~0x1f000000) | 0x0d000000;
  5360. +       rt2860_io_mac_write(sc, RT3070_LDO_CFG0, tmp);
  5361. +   }
  5362. +}
  5363. +
  5364. +int
  5365. +rt3090_filter_calib(struct rt2860_softc *sc, uint8_t init, uint8_t target,
  5366. +    uint8_t *val)
  5367. +{
  5368. +   uint8_t rf22, rf24;
  5369. +   uint8_t bbp55_pb, bbp55_sb, delta;
  5370. +   int ntries;
  5371. +
  5372. +   /* program filter */
  5373. +   rf24 = rt3090_rf_read(sc, 24);
  5374. +   rf24 = (rf24 & 0xc0) | init;    /* initial filter value */
  5375. +   rt3090_rf_write(sc, 24, rf24);
  5376. +
  5377. +   /* enable baseband loopback mode */
  5378. +   rf22 = rt3090_rf_read(sc, 22);
  5379. +   rt3090_rf_write(sc, 22, rf22 | RT3070_BB_LOOPBACK);
  5380. +
  5381. +   /* set power and frequency of passband test tone */
  5382. +   rt2860_io_bbp_write(sc, 24, 0x00);
  5383. +   for (ntries = 0; ntries < 100; ntries++) {
  5384. +       /* transmit test tone */
  5385. +       rt2860_io_bbp_write(sc, 25, 0x90);
  5386. +       DELAY(1000);
  5387. +       /* read received power */
  5388. +       bbp55_pb = rt2860_io_bbp_read(sc, 55);
  5389. +       if (bbp55_pb != 0)
  5390. +           break;
  5391. +   }
  5392. +   if (ntries == 100)
  5393. +       return ETIMEDOUT;
  5394. +
  5395. +   /* set power and frequency of stopband test tone */
  5396. +   rt2860_io_bbp_write(sc, 24, 0x06);
  5397. +   for (ntries = 0; ntries < 100; ntries++) {
  5398. +       /* transmit test tone */
  5399. +       rt2860_io_bbp_write(sc, 25, 0x90);
  5400. +       DELAY(1000);
  5401. +       /* read received power */
  5402. +       bbp55_sb = rt2860_io_bbp_read(sc, 55);
  5403. +
  5404. +       delta = bbp55_pb - bbp55_sb;
  5405. +       if (delta > target)
  5406. +           break;
  5407. +
  5408. +       /* reprogram filter */
  5409. +       rf24++;
  5410. +       rt3090_rf_write(sc, 24, rf24);
  5411. +   }
  5412. +   if (ntries < 100) {
  5413. +       if (rf24 != init)
  5414. +           rf24--; /* backtrack */
  5415. +       *val = rf24;
  5416. +       rt3090_rf_write(sc, 24, rf24);
  5417. +   }
  5418. +
  5419. +   /* restore initial state */
  5420. +   rt2860_io_bbp_write(sc, 24, 0x00);
  5421. +
  5422. +   /* disable baseband loopback mode */
  5423. +   rf22 = rt3090_rf_read(sc, 22);
  5424. +   rt3090_rf_write(sc, 22, rf22 & ~RT3070_BB_LOOPBACK);
  5425. +
  5426. +   return 0;
  5427. +}
  5428. +
  5429. +void
  5430. +rt3090_rf_setup(struct rt2860_softc *sc)
  5431. +{
  5432. +   uint8_t bbp;
  5433. +   int i;
  5434. +
  5435. +   if ((sc->mac_rev & 0x0000ffff) >= 0x0211) {
  5436. +       /* enable DC filter */
  5437. +       rt2860_io_bbp_write(sc, 103, 0xc0);
  5438. +
  5439. +       /* improve power consumption */
  5440. +       bbp = rt2860_io_bbp_read(sc, 31);
  5441. +       rt2860_io_bbp_write(sc, 31, bbp & ~0x03);
  5442. +   }
  5443. +
  5444. +   rt2860_io_mac_write(sc, RT2860_REG_TX_SW_CFG1, 0);
  5445. +   if ((sc->mac_rev & 0x0000ffff) < 0x0211) {
  5446. +       rt2860_io_mac_write(sc, RT2860_REG_TX_SW_CFG2,
  5447. +           sc->patch_dac ? 0x2c : 0x0f);
  5448. +   } else
  5449. +       rt2860_io_mac_write(sc, RT2860_REG_TX_SW_CFG2, 0);
  5450. +
  5451. +   /* initialize RF registers from ROM */
  5452. +   for (i = 0; i < 10; i++) {
  5453. +       if (sc->rf[i].reg == 0 || sc->rf[i].reg == 0xff)
  5454. +           continue;
  5455. +       rt3090_rf_write(sc, sc->rf[i].reg, sc->rf[i].val);
  5456. +   }
  5457. +}
  5458. +
  5459. +
  5460. +/*
  5461. + * rt2860_rf_set_chan
  5462. + */
  5463. +void rt2860_rf_set_chan(struct rt2860_softc *sc,
  5464. +   struct ieee80211_channel *c)
  5465. +{
  5466. +   struct ifnet *ifp;
  5467. +   struct ieee80211com *ic;
  5468. +   const struct rt2860_rf_prog *prog;
  5469. +   uint32_t r1, r2, r3, r4;
  5470. +   int8_t txpow1, txpow2;
  5471. +   int i, chan;
  5472. +
  5473. +   if (sc->mac_rev == 0x28720200) {
  5474. +       rt2872_rf_set_chan(sc, c);
  5475. +       return;
  5476. +   }
  5477. +
  5478. +   ifp = sc->sc_ifp;
  5479. +   ic = ifp->if_l2com;
  5480. +   prog = rt2860_rf_2850;
  5481. +
  5482. +   /* get central channel position */
  5483. +
  5484. +   chan = ieee80211_chan2ieee(ic, c);
  5485. +
  5486. +   if ((sc->mac_rev & 0xffff0000) >= 0x30710000) {
  5487. +       rt3090_set_chan(sc, chan);
  5488. +       return;
  5489. +   }
  5490. +
  5491. +   if (IEEE80211_IS_CHAN_HT40U(c))
  5492. +       chan += 2;
  5493. +   else if (IEEE80211_IS_CHAN_HT40D(c))
  5494. +       chan -= 2;
  5495. +
  5496. +   RT2860_DPRINTF(sc, RT2860_DEBUG_CHAN,
  5497. +       "%s: RF set channel: channel=%u, HT%s%s\n",
  5498. +       device_get_nameunit(sc->sc_dev),
  5499. +       ieee80211_chan2ieee(ic, c),
  5500. +       !IEEE80211_IS_CHAN_HT(c) ? " disabled" :
  5501. +           IEEE80211_IS_CHAN_HT20(c) ? "20":
  5502. +               IEEE80211_IS_CHAN_HT40U(c) ? "40U" : "40D",
  5503. +       (ic->ic_flags & IEEE80211_F_SCAN) ? ", scanning" : "");
  5504. +
  5505. +   if (chan == 0 || chan == IEEE80211_CHAN_ANY)
  5506. +       return;
  5507. +
  5508. +   for (i = 0; prog[i].chan != chan; i++);
  5509. +
  5510. +   r1 = prog[i].r1;
  5511. +   r2 = prog[i].r2;
  5512. +   r3 = prog[i].r3;
  5513. +   r4 = prog[i].r4;
  5514. +
  5515. +   txpow1 = sc->txpow1[i];
  5516. +   txpow2 = sc->txpow2[i];
  5517. +
  5518. +   if (sc->ntxpath == 1)
  5519. +       r2 |= (1 << 14);
  5520. +
  5521. +   if (sc->nrxpath == 2)
  5522. +       r2 |= (1 << 6);
  5523. +   else if (sc->nrxpath == 1)
  5524. +       r2 |= (1 << 17) | (1 << 6);
  5525. +
  5526. +   if (IEEE80211_IS_CHAN_2GHZ(c))
  5527. +   {
  5528. +       r3 = (r3 & 0xffffc1ff) | (txpow1 << 9);
  5529. +       r4 = (r4 & ~0x001f87c0) | (sc->rf_freq_off << 15) |
  5530. +           (txpow2 << 6);
  5531. +   }
  5532. +   else
  5533. +   {
  5534. +       r3 = r3 & 0xffffc1ff;
  5535. +       r4 = (r4 & ~0x001f87c0) | (sc->rf_freq_off << 15);
  5536. +
  5537. +       if (txpow1 >= RT2860_EEPROM_TXPOW_5GHZ_MIN && txpow1 < 0)
  5538. +       {
  5539. +           txpow1 = (-RT2860_EEPROM_TXPOW_5GHZ_MIN + txpow1);
  5540. +           if (txpow1 > RT2860_EEPROM_TXPOW_5GHZ_MAX)
  5541. +               txpow1 = RT2860_EEPROM_TXPOW_5GHZ_MAX;
  5542. +
  5543. +           r3 |= (txpow1 << 10);
  5544. +       }
  5545. +       else
  5546. +       {
  5547. +           if (txpow1 > RT2860_EEPROM_TXPOW_5GHZ_MAX)
  5548. +               txpow1 = RT2860_EEPROM_TXPOW_5GHZ_MAX;
  5549. +
  5550. +           r3 |= (txpow1 << 10) | (1 << 9);
  5551. +       }
  5552. +
  5553. +       if (txpow2 >= RT2860_EEPROM_TXPOW_5GHZ_MIN && txpow2 < 0)
  5554. +       {
  5555. +           txpow2 = (-RT2860_EEPROM_TXPOW_5GHZ_MIN + txpow2);
  5556. +           if (txpow2 > RT2860_EEPROM_TXPOW_5GHZ_MAX)
  5557. +               txpow2 = RT2860_EEPROM_TXPOW_5GHZ_MAX;
  5558. +
  5559. +           r4 |= (txpow2 << 7);
  5560. +       }
  5561. +       else
  5562. +       {
  5563. +           if (txpow2 > RT2860_EEPROM_TXPOW_5GHZ_MAX)
  5564. +               txpow2 = RT2860_EEPROM_TXPOW_5GHZ_MAX;
  5565. +
  5566. +           r4 |= (txpow2 << 7) | (1 << 6);
  5567. +       }
  5568. +   }
  5569. +
  5570. +   if (!(ic->ic_flags & IEEE80211_F_SCAN) && IEEE80211_IS_CHAN_HT40(c))
  5571. +       r4 |= (1 << 21);
  5572. +
  5573. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R1, r1);
  5574. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R2, r2);
  5575. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R3, r3 & ~(1 << 2));
  5576. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R4, r4);
  5577. +
  5578. +   DELAY(200);
  5579. +
  5580. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R1, r1);
  5581. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R2, r2);
  5582. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R3, r3 | (1 << 2));
  5583. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R4, r4);
  5584. +
  5585. +   DELAY(200);
  5586. +
  5587. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R1, r1);
  5588. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R2, r2);
  5589. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R3, r3 & ~(1 << 2));
  5590. +   rt2860_io_rf_write(sc, RT2860_REG_RF_R4, r4);
  5591. +
  5592. +   rt2860_rf_select_chan_group(sc, c);
  5593. +
  5594. +   DELAY(1000);
  5595. +}
  5596. +
  5597. +/*
  5598. + * rt2872_rf_set_chan
  5599. + */
  5600. +static void
  5601. +rt2872_rf_set_chan(struct rt2860_softc *sc,
  5602. +   struct ieee80211_channel *c)
  5603. +{
  5604. +   struct ifnet *ifp;
  5605. +   struct ieee80211com *ic;
  5606. +   const struct rt2860_rf_prog *prog;
  5607. +   uint32_t r1, r2, r3, r4;
  5608. +   uint32_t r6, r7, r12, r13, r23, r24;
  5609. +   int8_t txpow1, txpow2;
  5610. +   int i, chan;
  5611. +
  5612. +   ifp = sc->sc_ifp;
  5613. +   ic = ifp->if_l2com;
  5614. +   prog = rt2860_rf_2850;
  5615. +
  5616. +   /* get central channel position */
  5617. +
  5618. +   chan = ieee80211_chan2ieee(ic, c);
  5619. +
  5620. +   if (IEEE80211_IS_CHAN_HT40U(c))
  5621. +       chan += 2;
  5622. +   else if (IEEE80211_IS_CHAN_HT40D(c))
  5623. +       chan -= 2;
  5624. +
  5625. +   RT2860_DPRINTF(sc, RT2860_DEBUG_CHAN,
  5626. +       "%s: RF set channel: channel=%u, HT%s%s\n",
  5627. +       device_get_nameunit(sc->sc_dev),
  5628. +       ieee80211_chan2ieee(ic, c),
  5629. +       !IEEE80211_IS_CHAN_HT(c) ? " disabled" :
  5630. +           IEEE80211_IS_CHAN_HT20(c) ? "20":
  5631. +               IEEE80211_IS_CHAN_HT40U(c) ? "40U" : "40D",
  5632. +       (ic->ic_flags & IEEE80211_F_SCAN) ? ", scanning" : "");
  5633. +
  5634. +   if (chan == 0 || chan == IEEE80211_CHAN_ANY)
  5635. +       return;
  5636. +
  5637. +   for (i = 0; prog[i].chan != chan; i++);
  5638. +
  5639. +   r1 = prog[i].r1;
  5640. +   r2 = prog[i].r2;
  5641. +   r3 = prog[i].r3;
  5642. +   r4 = prog[i].r4;
  5643. +
  5644. +   txpow1 = sc->txpow1[i];
  5645. +   txpow2 = sc->txpow2[i];
  5646. +
  5647. +   for (i = 0; rt2860_rf_fi3020[i].channel != chan; i++);
  5648. +
  5649. +   /* Programm channel parameters */
  5650. +   r2 = rt2860_rf_fi3020[i].n;
  5651. +   rt2860_io_rf_write(sc, 2 , r2 );
  5652. +   r3 = rt2860_rf_fi3020[i].k;
  5653. +   rt2860_io_rf_write(sc, 3 , r3 );
  5654. +
  5655. +   r6 = (rt3052_rf_default[6] & 0xFC) | (rt2860_rf_fi3020[i].r & 0x03);
  5656. +   rt2860_io_rf_write(sc, 6 , r6 );
  5657. +
  5658. +   /* Set Tx Power */
  5659. +   r12 = (rt3052_rf_default[12] & 0xE0) | (txpow1 & 0x1f);
  5660. +   rt2860_io_rf_write(sc, 12, r12);
  5661. +
  5662. +   /* Set Tx1 Power */
  5663. +   r13 = (rt3052_rf_default[13] & 0xE0) | (txpow2 & 0x1f);
  5664. +   rt2860_io_rf_write(sc, 13, r13);
  5665. +
  5666. +   /* Set RF offset */
  5667. +   r23 = (rt3052_rf_default[23] & 0x80) | (sc->rf_freq_off);
  5668. +   rt2860_io_rf_write(sc, 23, r23);
  5669. +
  5670. +   /* Set BW */
  5671. +   r24 = (rt3052_rf_default[24] & 0xDF);
  5672. +   if (!(ic->ic_flags & IEEE80211_F_SCAN) && IEEE80211_IS_CHAN_HT40(c))
  5673. +       r24 |= 0x20;
  5674. +   rt2860_io_rf_write(sc, 24, r24);
  5675. +
  5676. +   /* Enable RF tuning */
  5677. +   r7 = (rt3052_rf_default[7]) | 1;
  5678. +   rt2860_io_rf_write(sc, 7 , r7 );
  5679. +
  5680. +   /* Antenna */
  5681. +   r1 = (rt3052_rf_default[1] & 0xab) | ((sc->nrxpath == 1)?0x10:0) |
  5682. +       ((sc->ntxpath == 1)?0x20:0);
  5683. +   rt2860_io_rf_write(sc, 1 , r1 );
  5684. +
  5685. +   DELAY(200);
  5686. +
  5687. +   rt2860_rf_select_chan_group(sc, c);
  5688. +
  5689. +   DELAY(1000);
  5690. +}
  5691. +/*
  5692. + *   AMRR functions
  5693. + */
  5694. +
  5695. +/*
  5696. + * rt2860_amrr_init
  5697. + */
  5698. +void rt2860_amrr_init(struct rt2860_amrr *amrr, struct ieee80211vap *vap,
  5699. +   int ntxpath, int min_success_threshold, int max_success_threshold, int msecs)
  5700. +{
  5701. +   int t;
  5702. +
  5703. +   amrr->ntxpath = ntxpath;
  5704. +
  5705. +   amrr->min_success_threshold = min_success_threshold;
  5706. +   amrr->max_success_threshold = max_success_threshold;
  5707. +
  5708. +   if (msecs < 100)
  5709. +       msecs = 100;
  5710. +
  5711. +   t = msecs_to_ticks(msecs);
  5712. +
  5713. +   amrr->interval = (t < 1) ? 1 : t;
  5714. +}
  5715. +
  5716. +/*
  5717. + * rt2860_amrr_cleanup
  5718. + */
  5719. +void rt2860_amrr_cleanup(struct rt2860_amrr *amrr)
  5720. +{
  5721. +}
  5722. +
  5723. +/*
  5724. + * rt2860_amrr_node_init
  5725. + */
  5726. +void rt2860_amrr_node_init(struct rt2860_amrr *amrr,
  5727. +    struct rt2860_amrr_node *amrr_node, struct ieee80211_node *ni)
  5728. +{
  5729. +   const struct ieee80211_rateset *rs;
  5730. +
  5731. +   amrr_node->amrr = amrr;
  5732. +   amrr_node->success = 0;
  5733. +   amrr_node->recovery = 0;
  5734. +   amrr_node->txcnt = 0;
  5735. +   amrr_node->retrycnt = 0;
  5736. +   amrr_node->success_threshold = amrr->min_success_threshold;
  5737. +
  5738. +   if (ni->ni_flags & IEEE80211_NODE_HT)
  5739. +   {
  5740. +       rs = (const struct ieee80211_rateset *) &ni->ni_htrates;
  5741. +
  5742. +       for (amrr_node->rate_index = rs->rs_nrates - 1;
  5743. +           amrr_node->rate_index > 0 && (rs->rs_rates[amrr_node->rate_index] & IEEE80211_RATE_VAL) > 4;
  5744. +           amrr_node->rate_index--) ;
  5745. +
  5746. +       ni->ni_txrate = rs->rs_rates[amrr_node->rate_index] | IEEE80211_RATE_MCS;
  5747. +   }
  5748. +   else
  5749. +   {
  5750. +       rs = &ni->ni_rates;
  5751. +
  5752. +       for (amrr_node->rate_index = rs->rs_nrates - 1;
  5753. +           amrr_node->rate_index > 0 && (rs->rs_rates[amrr_node->rate_index] & IEEE80211_RATE_VAL) > 72;
  5754. +           amrr_node->rate_index--) ;
  5755. +
  5756. +       ni->ni_txrate = rs->rs_rates[amrr_node->rate_index] & IEEE80211_RATE_VAL;
  5757. +   }
  5758. +
  5759. +   amrr_node->ticks = ticks;
  5760. +}
  5761. +
  5762. +/*
  5763. + * rt2860_amrr_choose
  5764. + */
  5765. +int rt2860_amrr_choose(struct ieee80211_node *ni,
  5766. +   struct rt2860_amrr_node *amrr_node)
  5767. +{
  5768. +   struct rt2860_amrr *amrr;
  5769. +   int rate_index;
  5770. +
  5771. +   amrr = amrr_node->amrr;
  5772. +
  5773. +   if (RT2860_AMRR_IS_ENOUGH(amrr_node) &&
  5774. +       (ticks - amrr_node->ticks) > amrr->interval)
  5775. +   {
  5776. +       rate_index = rt2860_amrr_update(amrr, amrr_node, ni);
  5777. +       if (rate_index != amrr_node->rate_index)
  5778. +       {
  5779. +           if (ni->ni_flags & IEEE80211_NODE_HT)
  5780. +               ni->ni_txrate = ni->ni_htrates.rs_rates[rate_index] | IEEE80211_RATE_MCS;
  5781. +           else
  5782. +               ni->ni_txrate = ni->ni_rates.rs_rates[rate_index] & IEEE80211_RATE_VAL;
  5783. +
  5784. +           amrr_node->rate_index = rate_index;
  5785. +       }
  5786. +
  5787. +       amrr_node->ticks = ticks;
  5788. +   }
  5789. +   else
  5790. +   {
  5791. +       rate_index = amrr_node->rate_index;
  5792. +   }
  5793. +
  5794. +   return rate_index;
  5795. +}
  5796. +
  5797. +/*
  5798. + * rt2860_amrr_update
  5799. + */
  5800. +
  5801. +static int rt2860_amrr_update(struct rt2860_amrr *amrr,
  5802. +   struct rt2860_amrr_node *amrr_node, struct ieee80211_node *ni)
  5803. +{
  5804. +   const struct ieee80211_rateset *rs;
  5805. +   int rate_index;
  5806. +
  5807. +   KASSERT(RT2860_AMRR_IS_ENOUGH(amrr_node),
  5808. +       ("not enough Tx count: txcnt=%d",
  5809. +        amrr_node->txcnt));
  5810. +
  5811. +   if (ni->ni_flags & IEEE80211_NODE_HT)
  5812. +       rs = (const struct ieee80211_rateset *) &ni->ni_htrates;
  5813. +   else
  5814. +       rs = &ni->ni_rates;
  5815. +
  5816. +   rate_index = amrr_node->rate_index;
  5817. +
  5818. +   if (RT2860_AMRR_IS_SUCCESS(amrr_node))
  5819. +   {
  5820. +       amrr_node->success++;
  5821. +       if ((amrr_node->success >= amrr_node->success_threshold) &&
  5822. +           (rate_index + 1 < rs->rs_nrates) &&
  5823. +           (!(ni->ni_flags & IEEE80211_NODE_HT) || (rs->rs_rates[rate_index + 1] & IEEE80211_RATE_VAL) < (amrr->ntxpath * 8)))
  5824. +       {
  5825. +           amrr_node->recovery = 1;
  5826. +           amrr_node->success = 0;
  5827. +
  5828. +           rate_index++;
  5829. +       }
  5830. +       else
  5831. +       {
  5832. +           amrr_node->recovery = 0;
  5833. +       }
  5834. +   }
  5835. +   else if (RT2860_AMRR_IS_FAILURE(amrr_node))
  5836. +   {
  5837. +       amrr_node->success = 0;
  5838. +
  5839. +       if (rate_index > 0)
  5840. +       {
  5841. +           if (amrr_node->recovery)
  5842. +           {
  5843. +               amrr_node->success_threshold *= 2;
  5844. +               if (amrr_node->success_threshold > amrr->max_success_threshold)
  5845. +                   amrr_node->success_threshold = amrr->max_success_threshold;
  5846. +           }
  5847. +           else
  5848. +           {
  5849. +               amrr_node->success_threshold = amrr->min_success_threshold;
  5850. +           }
  5851. +
  5852. +           rate_index--;
  5853. +       }
  5854. +
  5855. +       amrr_node->recovery = 0;
  5856. +   }
  5857. +
  5858. +   amrr_node->txcnt = 0;
  5859. +   amrr_node->retrycnt = 0;
  5860. +
  5861. +   return rate_index;
  5862. +}
  5863. +
  5864. +/*
  5865. + *  RF & Asic level functions (incl. net80211 callbacks etc.)
  5866. + */
  5867. +
  5868. + /*
  5869. +  * rt2860_node_alloc
  5870. +  */
  5871. +static struct ieee80211_node *rt2860_node_alloc(struct ieee80211vap *vap,
  5872. +   const uint8_t mac[IEEE80211_ADDR_LEN])
  5873. +{
  5874. +   return malloc(sizeof(struct rt2860_softc_node),
  5875. +       M_80211_NODE, M_NOWAIT | M_ZERO);
  5876. +}
  5877. +
  5878. +/*
  5879. + * rt2860_node_cleanup
  5880. + */
  5881. +static void rt2860_node_cleanup(struct ieee80211_node *ni)
  5882. +{
  5883. +   struct rt2860_softc *sc;
  5884. +   struct ieee80211com *ic;
  5885. +   struct ifnet *ifp;
  5886. +   struct rt2860_softc_node *rni;
  5887. +   uint8_t vapid, wcid;
  5888. +   uint32_t tmp;
  5889. +
  5890. +   ic = ni->ni_ic;
  5891. +   ifp = ic->ic_ifp;
  5892. +   sc = ifp->if_softc;
  5893. +   rni = (struct rt2860_softc_node *) ni;
  5894. +
  5895. +   RT2860_DPRINTF(sc, RT2860_DEBUG_NODE,
  5896. +       "%s: node cleanup: macaddr=%s, associd=0x%04x, staid=0x%02x\n",
  5897. +       device_get_nameunit(sc->sc_dev), ether_sprintf(ni->ni_macaddr),
  5898. +       ni->ni_associd, rni->staid);
  5899. +
  5900. +   if (rni->staid != 0)
  5901. +   {
  5902. +       vapid = 0;
  5903. +       wcid = rni->staid;
  5904. +
  5905. +       tmp = ((vapid & RT2860_REG_VAP_MASK) << RT2860_REG_VAP_SHIFT) |
  5906. +           (RT2860_REG_CIPHER_MODE_NONE << RT2860_REG_CIPHER_MODE_SHIFT) | RT2860_REG_PKEY_ENABLE;
  5907. +
  5908. +       rt2860_io_mac_write(sc, RT2860_REG_WCID_ATTR(wcid), tmp);
  5909. +
  5910. +       rt2860_io_mac_write(sc, RT2860_REG_WCID(wcid), 0x00000000);
  5911. +       rt2860_io_mac_write(sc, RT2860_REG_WCID(wcid) + 4, 0x00000000);
  5912. +
  5913. +       rt2860_staid_delete(sc, rni->staid);
  5914. +
  5915. +       rni->staid = 0;
  5916. +   }
  5917. +
  5918. +   sc->node_cleanup(ni);
  5919. + }
  5920. +
  5921. +/*
  5922. + * rt2860_node_getmimoinfo
  5923. + */
  5924. +static void rt2860_node_getmimoinfo(const struct ieee80211_node *ni,
  5925. +   struct ieee80211_mimo_info *mi)
  5926. +{
  5927. +   const struct rt2860_softc_node *rni;
  5928. +   int i;
  5929. +
  5930. +   rni = (const struct rt2860_softc_node *) ni;
  5931. +
  5932. +   for (i = 0; i < RT2860_SOFTC_RSSI_COUNT; i++)
  5933. +   {
  5934. +       mi->rssi[i] = rni->last_rssi_dbm[i];
  5935. +       mi->noise[i] = RT2860_NOISE_FLOOR;
  5936. +   }
  5937. +}
  5938. +
  5939. +
  5940. +
  5941. +
  5942. +/*
  5943. + * rt2860_setregdomain
  5944. + */
  5945. +static int rt2860_setregdomain(struct ieee80211com *ic,
  5946. +   struct ieee80211_regdomain *reg,
  5947. +   int nchans, struct ieee80211_channel chans[])
  5948. +{
  5949. +   struct rt2860_softc *sc;
  5950. +   struct ifnet *ifp;
  5951. +
  5952. +   ifp = ic->ic_ifp;
  5953. +   sc = ifp->if_softc;
  5954. +
  5955. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  5956. +       "%s: set regulatory domain: country=%d, country code string=%c%c, location=%c\n",
  5957. +       device_get_nameunit(sc->sc_dev),
  5958. +       reg->country, reg->isocc[0], reg->isocc[1], reg->location);
  5959. +
  5960. +   return 0;
  5961. +}
  5962. +
  5963. +/*
  5964. + * rt2860_getradiocaps
  5965. + */
  5966. +static void rt2860_getradiocaps(struct ieee80211com *ic,
  5967. +   int maxchans, int *nchans, struct ieee80211_channel chans[])
  5968. +{
  5969. +   *nchans = (ic->ic_nchans >= maxchans) ? maxchans : ic->ic_nchans;
  5970. +
  5971. +   memcpy(chans, ic->ic_channels, (*nchans) * sizeof(struct ieee80211_channel));
  5972. +}
  5973. +
  5974. +/*
  5975. + * rt2860_scan_start
  5976. + */
  5977. +static void rt2860_scan_start(struct ieee80211com *ic)
  5978. +{
  5979. +   struct rt2860_softc *sc;
  5980. +   struct ifnet *ifp;
  5981. +
  5982. +   ifp = ic->ic_ifp;
  5983. +   sc = ifp->if_softc;
  5984. +
  5985. +   rt2860_asic_disable_tsf_sync(sc);
  5986. +}
  5987. +
  5988. +/*
  5989. + * rt2860_scan_end
  5990. + */
  5991. +static void rt2860_scan_end(struct ieee80211com *ic)
  5992. +{
  5993. +   struct rt2860_softc *sc;
  5994. +   struct ifnet *ifp;
  5995. +
  5996. +   ifp = ic->ic_ifp;
  5997. +   sc = ifp->if_softc;
  5998. +
  5999. +   rt2860_asic_enable_tsf_sync(sc);
  6000. +}
  6001. +
  6002. +/*
  6003. + * rt2860_set_channel
  6004. + */
  6005. +static void rt2860_set_channel(struct ieee80211com *ic)
  6006. +{
  6007. +   struct rt2860_softc *sc;
  6008. +   struct ifnet *ifp;
  6009. +
  6010. +   ifp = ic->ic_ifp;
  6011. +   sc = ifp->if_softc;
  6012. +
  6013. +   RT2860_DPRINTF(sc, RT2860_DEBUG_CHAN,
  6014. +       "%s: set channel: channel=%u, HT%s%s\n",
  6015. +       device_get_nameunit(sc->sc_dev),
  6016. +       ieee80211_chan2ieee(ic, ic->ic_curchan),
  6017. +       !IEEE80211_IS_CHAN_HT(ic->ic_curchan) ? " disabled" :
  6018. +           IEEE80211_IS_CHAN_HT20(ic->ic_curchan) ? "20":
  6019. +               IEEE80211_IS_CHAN_HT40U(ic->ic_curchan) ? "40U" : "40D",
  6020. +       (ic->ic_flags & IEEE80211_F_SCAN) ? ", scanning" : "");
  6021. +
  6022. +   RT2860_SOFTC_LOCK(sc);
  6023. +
  6024. +   rt2860_rf_set_chan(sc, ic->ic_curchan);
  6025. +
  6026. +   RT2860_SOFTC_UNLOCK(sc);
  6027. +}
  6028. +
  6029. +/*
  6030. + * rt2860_newassoc
  6031. + */
  6032. +static void rt2860_newassoc(struct ieee80211_node *ni, int isnew)
  6033. +{
  6034. +   struct rt2860_softc *sc;
  6035. +   struct ieee80211com *ic;
  6036. +   struct ifnet *ifp;
  6037. +   struct ieee80211vap *vap;
  6038. +   struct rt2860_softc_vap *rvap;
  6039. +   struct rt2860_softc_node *rni;
  6040. +   uint16_t aid;
  6041. +   uint8_t wcid;
  6042. +   uint32_t tmp;
  6043. +
  6044. +   vap = ni->ni_vap;
  6045. +   ic = vap->iv_ic;
  6046. +   ifp = ic->ic_ifp;
  6047. +   sc = ifp->if_softc;
  6048. +   rvap = (struct rt2860_softc_vap *) vap;
  6049. +   rni = (struct rt2860_softc_node *) ni;
  6050. +
  6051. +   if (isnew)
  6052. +   {
  6053. +       aid = IEEE80211_AID(ni->ni_associd);
  6054. +       rni->staid = rt2860_staid_alloc(sc, aid);
  6055. +       wcid = rni->staid;
  6056. +
  6057. +       tmp = (ni->ni_macaddr[3] << 24) |
  6058. +           (ni->ni_macaddr[2] << 16) |
  6059. +           (ni->ni_macaddr[1] << 8) |
  6060. +           ni->ni_macaddr[0];
  6061. +
  6062. +       rt2860_io_mac_write(sc, RT2860_REG_WCID(wcid), tmp);
  6063. +
  6064. +       tmp = (ni->ni_macaddr[5] << 8) |
  6065. +           ni->ni_macaddr[4];
  6066. +
  6067. +       rt2860_io_mac_write(sc, RT2860_REG_WCID(wcid) + 4, tmp);
  6068. +
  6069. +       rt2860_amrr_node_init(&rvap->amrr, &sc->amrr_node[wcid], ni);
  6070. +
  6071. +       RT2860_DPRINTF(sc, RT2860_DEBUG_RATE,
  6072. +           "%s: initial%s node Tx rate: associd=0x%04x, rate=0x%02x, max rate=0x%02x\n",
  6073. +           device_get_nameunit(sc->sc_dev),
  6074. +           (ni->ni_flags & IEEE80211_NODE_HT) ? " HT" : "",
  6075. +           ni->ni_associd, ni->ni_txrate,
  6076. +           (ni->ni_flags & IEEE80211_NODE_HT) ?
  6077. +               (ni->ni_htrates.rs_rates[ni->ni_htrates.rs_nrates - 1] | IEEE80211_RATE_MCS) :
  6078. +               (ni->ni_rates.rs_rates[ni->ni_rates.rs_nrates - 1] & IEEE80211_RATE_VAL));
  6079. +
  6080. +       rt2860_asic_updateprot(sc);
  6081. +       rt2860_asic_updateslot(sc);
  6082. +       rt2860_asic_set_txpreamble(sc);
  6083. +   }
  6084. +
  6085. +   RT2860_DPRINTF(sc, RT2860_DEBUG_NODE,
  6086. +       "%s: new association: isnew=%d, macaddr=%s, associd=0x%04x, staid=0x%02x, QoS %s, ERP %s, HT %s\n",
  6087. +       device_get_nameunit(sc->sc_dev), isnew, ether_sprintf(ni->ni_macaddr),
  6088. +       ni->ni_associd, rni->staid,
  6089. +       (ni->ni_flags & IEEE80211_NODE_QOS) ? "enabled" : "disabled",
  6090. +       (ni->ni_flags & IEEE80211_NODE_ERP) ? "enabled" : "disabled",
  6091. +       (ni->ni_flags & IEEE80211_NODE_HT) ? "enabled" : "disabled");
  6092. +}
  6093. +
  6094. +/*
  6095. + * rt2860_updateslot
  6096. + */
  6097. +static void rt2860_updateslot(struct ifnet *ifp)
  6098. +{
  6099. +   struct rt2860_softc *sc;
  6100. +
  6101. +   sc = ifp->if_softc;
  6102. +
  6103. +   rt2860_asic_updateslot(sc);
  6104. +}
  6105. +
  6106. +/*
  6107. + * rt2860_update_promisc
  6108. + */
  6109. +static void rt2860_update_promisc(struct ifnet *ifp)
  6110. +{
  6111. +   struct rt2860_softc *sc;
  6112. +
  6113. +   sc = ifp->if_softc;
  6114. +
  6115. +   rt2860_asic_update_promisc(sc);
  6116. +}
  6117. +
  6118. +/*
  6119. + * rt2860_update_mcast
  6120. + */
  6121. +static void rt2860_update_mcast(struct ifnet *ifp)
  6122. +{
  6123. +   struct rt2860_softc *sc;
  6124. +
  6125. +   sc = ifp->if_softc;
  6126. +}
  6127. +
  6128. +/*
  6129. + * rt2860_wme_update
  6130. + */
  6131. +static int rt2860_wme_update(struct ieee80211com *ic)
  6132. +{
  6133. +   struct rt2860_softc *sc;
  6134. +   struct ifnet *ifp;
  6135. +
  6136. +   ifp = ic->ic_ifp;
  6137. +   sc = ifp->if_softc;
  6138. +
  6139. +   rt2860_asic_wme_update(sc);
  6140. +
  6141. +   return 0;
  6142. +}
  6143. +
  6144. +/*
  6145. + * rt2860_raw_xmit
  6146. + */
  6147. +static int rt2860_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
  6148. +   const struct ieee80211_bpf_params *params)
  6149. +{
  6150. +   struct rt2860_softc *sc;
  6151. +   struct ieee80211com *ic;
  6152. +   struct ifnet *ifp;
  6153. +
  6154. +   ic = ni->ni_ic;
  6155. +   ifp = ic->ic_ifp;
  6156. +   sc = ifp->if_softc;
  6157. +
  6158. +   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
  6159. +   {
  6160. +       m_freem(m);
  6161. +       ieee80211_free_node(ni);
  6162. +
  6163. +       return ENETDOWN;
  6164. +   }
  6165. +
  6166. +   RT2860_SOFTC_TX_RING_LOCK(&sc->tx_ring[sc->tx_ring_mgtqid]);
  6167. +
  6168. +   if (sc->tx_ring[sc->tx_ring_mgtqid].data_queued >= RT2860_SOFTC_TX_RING_DATA_COUNT)
  6169. +   {
  6170. +       RT2860_SOFTC_TX_RING_UNLOCK(&sc->tx_ring[sc->tx_ring_mgtqid]);
  6171. +
  6172. +       RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  6173. +           "%s: raw xmit: Tx ring with qid=%d is full\n",
  6174. +           device_get_nameunit(sc->sc_dev), sc->tx_ring_mgtqid);
  6175. +
  6176. +       ifp->if_drv_flags |= IFF_DRV_OACTIVE;
  6177. +
  6178. +       m_freem(m);
  6179. +       ieee80211_free_node(ni);
  6180. +
  6181. +       sc->tx_data_queue_full[sc->tx_ring_mgtqid]++;
  6182. +
  6183. +       return ENOBUFS;
  6184. +   }
  6185. +
  6186. +   if (rt2860_tx_mgmt(sc, m, ni, sc->tx_ring_mgtqid) != 0)
  6187. +   {
  6188. +       RT2860_SOFTC_TX_RING_UNLOCK(&sc->tx_ring[sc->tx_ring_mgtqid]);
  6189. +
  6190. +       ifp->if_oerrors++;
  6191. +
  6192. +       ieee80211_free_node(ni);
  6193. +
  6194. +       return EIO;
  6195. +   }
  6196. +
  6197. +   RT2860_SOFTC_TX_RING_UNLOCK(&sc->tx_ring[sc->tx_ring_mgtqid]);
  6198. +
  6199. +   sc->sc_tx_timer = RT2860_TX_WATCHDOG_TIMEOUT;
  6200. +
  6201. +   return 0;
  6202. +}
  6203. +
  6204. +/*
  6205. + * rt2860_recv_action
  6206. + */
  6207. +static int rt2860_recv_action(struct ieee80211_node *ni,
  6208. +   const struct ieee80211_frame *wh,
  6209. +   const uint8_t *frm, const uint8_t *efrm)
  6210. +{
  6211. +   struct rt2860_softc *sc;
  6212. +   struct ieee80211com *ic;
  6213. +   struct ifnet *ifp;
  6214. +   struct rt2860_softc_node *rni;
  6215. +   const struct ieee80211_action *ia;
  6216. +   uint16_t baparamset;
  6217. +   uint8_t wcid;
  6218. +   int tid;
  6219. +
  6220. +   ic = ni->ni_ic;
  6221. +   ifp = ic->ic_ifp;
  6222. +   sc = ifp->if_softc;
  6223. +   rni = (struct rt2860_softc_node *) ni;
  6224. +
  6225. +   ia = (const struct ieee80211_action *) frm;
  6226. +
  6227. +   if (ia->ia_category == IEEE80211_ACTION_CAT_BA)
  6228. +   {
  6229. +       switch (ia->ia_action)
  6230. +       {
  6231. +           /* IEEE80211_ACTION_BA_DELBA */
  6232. +           case IEEE80211_ACTION_BA_DELBA:
  6233. +               baparamset = LE_READ_2(frm + 2);
  6234. +               tid = RT2860_MS(baparamset, IEEE80211_BAPS_TID);
  6235. +               wcid = rni->staid;
  6236. +
  6237. +               RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6238. +                   "%s: received DELBA request: associd=0x%04x, staid=0x%02x, tid=%d\n",
  6239. +                   device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid, tid);
  6240. +
  6241. +               if (rni->staid != 0)
  6242. +                   rt2860_asic_del_ba_session(sc, wcid, tid);
  6243. +           break;
  6244. +       }
  6245. +   }
  6246. +
  6247. +   return sc->recv_action(ni, wh, frm, efrm);
  6248. +}
  6249. +
  6250. +/*
  6251. + * rt2860_send_action
  6252. + */
  6253. +static int rt2860_send_action(struct ieee80211_node *ni,
  6254. +   int cat, int act, void *sa)
  6255. +{
  6256. +   struct rt2860_softc *sc;
  6257. +   struct ieee80211com *ic;
  6258. +   struct ifnet *ifp;
  6259. +   struct rt2860_softc_node *rni;
  6260. +   uint16_t *args, status, baparamset;
  6261. +   uint8_t wcid;
  6262. +   int tid, bufsize;
  6263. +
  6264. +   ic = ni->ni_ic;
  6265. +   ifp = ic->ic_ifp;
  6266. +   sc = ifp->if_softc;
  6267. +   rni = (struct rt2860_softc_node *) ni;
  6268. +
  6269. +   wcid = rni->staid;
  6270. +   args = sa;
  6271. +
  6272. +   if (cat == IEEE80211_ACTION_CAT_BA)
  6273. +   {
  6274. +       switch (act)
  6275. +       {
  6276. +           /* IEEE80211_ACTION_BA_ADDBA_RESPONSE */
  6277. +           case IEEE80211_ACTION_BA_ADDBA_RESPONSE:
  6278. +               status = args[1];
  6279. +               baparamset = args[2];
  6280. +               tid = RT2860_MS(baparamset, IEEE80211_BAPS_TID);
  6281. +               bufsize = RT2860_MS(baparamset, IEEE80211_BAPS_BUFSIZ);
  6282. +
  6283. +               RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6284. +                   "%s: sending ADDBA response: associd=0x%04x, staid=0x%02x, status=%d, tid=%d, bufsize=%d\n",
  6285. +                   device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid, status, tid, bufsize);
  6286. +
  6287. +               if (status == IEEE80211_STATUS_SUCCESS)
  6288. +                   rt2860_asic_add_ba_session(sc, wcid, tid);
  6289. +           break;
  6290. +
  6291. +           /* IEEE80211_ACTION_BA_DELBA */
  6292. +           case IEEE80211_ACTION_BA_DELBA:
  6293. +               baparamset = RT2860_SM(args[0], IEEE80211_DELBAPS_TID) | args[1];
  6294. +               tid = RT2860_MS(baparamset, IEEE80211_DELBAPS_TID);
  6295. +
  6296. +               RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6297. +                   "%s: sending DELBA request: associd=0x%04x, staid=0x%02x, tid=%d\n",
  6298. +                   device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid, tid);
  6299. +
  6300. +               if (RT2860_MS(baparamset, IEEE80211_DELBAPS_INIT) != IEEE80211_DELBAPS_INIT)
  6301. +                   rt2860_asic_del_ba_session(sc, wcid, tid);
  6302. +           break;
  6303. +       }
  6304. +   }
  6305. +
  6306. +   return sc->send_action(ni, cat, act, sa);
  6307. +}
  6308. +
  6309. +/*
  6310. + * rt2860_addba_response
  6311. + */
  6312. +static int rt2860_addba_response(struct ieee80211_node *ni,
  6313. +   struct ieee80211_tx_ampdu *tap,
  6314. +   int status, int baparamset, int batimeout)
  6315. +{
  6316. +   struct rt2860_softc *sc;
  6317. +   struct ieee80211com *ic;
  6318. +   struct ifnet *ifp;
  6319. +   struct rt2860_softc_node *rni;
  6320. +   ieee80211_seq seqno;
  6321. +   int ret, tid, old_bufsize, new_bufsize;
  6322. +
  6323. +   ic = ni->ni_ic;
  6324. +   ifp = ic->ic_ifp;
  6325. +   sc = ifp->if_softc;
  6326. +   rni = (struct rt2860_softc_node *) ni;
  6327. +
  6328. +   tid = RT2860_MS(baparamset, IEEE80211_BAPS_TID);
  6329. +   old_bufsize = RT2860_MS(baparamset, IEEE80211_BAPS_BUFSIZ);
  6330. +   new_bufsize = old_bufsize;
  6331. +
  6332. +   if (status == IEEE80211_STATUS_SUCCESS)
  6333. +   {
  6334. +       if (sc->mac_rev >= 0x28830300)
  6335. +       {
  6336. +           if (sc->mac_rev >= 0x30700200)
  6337. +               new_bufsize = 13;
  6338. +           else
  6339. +               new_bufsize = 31;
  6340. +       }
  6341. +       else if (sc->mac_rev >= 0x28720200)
  6342. +       {
  6343. +           new_bufsize = 13;
  6344. +       }
  6345. +       else
  6346. +       {
  6347. +           new_bufsize = 7;
  6348. +       }
  6349. +
  6350. +       if (old_bufsize > new_bufsize)
  6351. +       {
  6352. +           baparamset &= ~IEEE80211_BAPS_BUFSIZ;
  6353. +           baparamset = RT2860_SM(new_bufsize, IEEE80211_BAPS_BUFSIZ);
  6354. +       }
  6355. +
  6356. +       if (!(tap->txa_flags & IEEE80211_AGGR_RUNNING))
  6357. +       {
  6358. +           sc->tx_ampdu_sessions++;
  6359. +
  6360. +           if (sc->tx_ampdu_sessions == 1)
  6361. +               rt2860_asic_updateprot(sc);
  6362. +       }
  6363. +   }
  6364. +
  6365. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6366. +       "%s: received ADDBA response: associd=0x%04x, staid=0x%02x, status=%d, tid=%d, "
  6367. +       "old bufsize=%d, new bufsize=%d\n",
  6368. +       device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid, status, tid,
  6369. +       old_bufsize, new_bufsize);
  6370. +
  6371. +   ret = sc->addba_response(ni, tap, status, baparamset, batimeout);
  6372. +
  6373. +   if (status == IEEE80211_STATUS_SUCCESS)
  6374. +   {
  6375. +       seqno = ni->ni_txseqs[tid];
  6376. +
  6377. +       rt2860_send_bar(ni, tap, seqno);
  6378. +   }
  6379. +
  6380. +   return ret;
  6381. +}
  6382. +
  6383. +/*
  6384. + * rt2860_addba_stop
  6385. + */
  6386. +static void rt2860_addba_stop(struct ieee80211_node *ni,
  6387. +   struct ieee80211_tx_ampdu *tap)
  6388. +{
  6389. +   struct rt2860_softc *sc;
  6390. +   struct ieee80211com *ic;
  6391. +   struct ifnet *ifp;
  6392. +   struct rt2860_softc_node *rni;
  6393. +   int tid;
  6394. +
  6395. +   ic = ni->ni_ic;
  6396. +   ifp = ic->ic_ifp;
  6397. +   sc = ifp->if_softc;
  6398. +   rni = (struct rt2860_softc_node *) ni;
  6399. +
  6400. +   tid = WME_AC_TO_TID(tap->txa_ac);
  6401. +
  6402. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6403. +       "%s: stopping A-MPDU Tx: associd=0x%04x, staid=0x%02x, tid=%d\n",
  6404. +       device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid, tid);
  6405. +
  6406. +   if (tap->txa_flags & IEEE80211_AGGR_RUNNING)
  6407. +   {
  6408. +       if (sc->tx_ampdu_sessions > 0)
  6409. +       {
  6410. +           sc->tx_ampdu_sessions--;
  6411. +
  6412. +           if (sc->tx_ampdu_sessions == 0)
  6413. +               rt2860_asic_updateprot(sc);
  6414. +       }
  6415. +       else
  6416. +       {
  6417. +           printf("%s: number of A-MPDU Tx sessions cannot be negative\n",
  6418. +               device_get_nameunit(sc->sc_dev));
  6419. +       }
  6420. +   }
  6421. +
  6422. +   sc->addba_stop(ni, tap);
  6423. +}
  6424. +
  6425. +/*
  6426. + * rt2860_ampdu_rx_start
  6427. + */
  6428. +static int rt2860_ampdu_rx_start(struct ieee80211_node *ni,
  6429. +   struct ieee80211_rx_ampdu *rap,
  6430. +   int baparamset, int batimeout, int baseqctl)
  6431. +{
  6432. +   struct rt2860_softc *sc;
  6433. +   struct ieee80211com *ic;
  6434. +   struct ifnet *ifp;
  6435. +   struct rt2860_softc_node *rni;
  6436. +   int tid;
  6437. +
  6438. +   ic = ni->ni_ic;
  6439. +   ifp = ic->ic_ifp;
  6440. +   sc = ifp->if_softc;
  6441. +   rni = (struct rt2860_softc_node *) ni;
  6442. +
  6443. +   tid = RT2860_MS(baparamset, IEEE80211_BAPS_TID);
  6444. +
  6445. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6446. +       "%s: starting A-MPDU Rx: associd=0x%04x, staid=0x%02x, tid=%d\n",
  6447. +       device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid, tid);
  6448. +
  6449. +   if (!(rap->rxa_flags & IEEE80211_AGGR_RUNNING))
  6450. +       sc->rx_ampdu_sessions++;
  6451. +
  6452. +   return sc->ampdu_rx_start(ni, rap, baparamset, batimeout, baseqctl);
  6453. +}
  6454. +
  6455. +/*
  6456. + * rt2860_ampdu_rx_stop
  6457. + */
  6458. +static void rt2860_ampdu_rx_stop(struct ieee80211_node *ni,
  6459. +   struct ieee80211_rx_ampdu *rap)
  6460. +{
  6461. +   struct rt2860_softc *sc;
  6462. +   struct ieee80211com *ic;
  6463. +   struct ifnet *ifp;
  6464. +   struct rt2860_softc_node *rni;
  6465. +
  6466. +   ic = ni->ni_ic;
  6467. +   ifp = ic->ic_ifp;
  6468. +   sc = ifp->if_softc;
  6469. +   rni = (struct rt2860_softc_node *) ni;
  6470. +
  6471. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6472. +       "%s: stopping A-MPDU Rx: associd=0x%04x, staid=0x%02x\n",
  6473. +       device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid);
  6474. +
  6475. +   if (rap->rxa_flags & IEEE80211_AGGR_RUNNING)
  6476. +   {
  6477. +       if (sc->rx_ampdu_sessions > 0)
  6478. +           sc->rx_ampdu_sessions--;
  6479. +       else
  6480. +           printf("%s: number of A-MPDU Rx sessions cannot be negative\n",
  6481. +               device_get_nameunit(sc->sc_dev));
  6482. +   }
  6483. +
  6484. +   sc->ampdu_rx_stop(ni, rap);
  6485. +}
  6486. +
  6487. +/*
  6488. + * rt2860_send_bar
  6489. + */
  6490. +static int rt2860_send_bar(struct ieee80211_node *ni,
  6491. +   struct ieee80211_tx_ampdu *tap, ieee80211_seq seqno)
  6492. +{
  6493. +   struct rt2860_softc *sc;
  6494. +   struct ieee80211com *ic;
  6495. +   struct ifnet *ifp;
  6496. +   struct ieee80211vap *vap;
  6497. +   struct ieee80211_frame_bar *bar;
  6498. +   struct rt2860_softc_node *rni;
  6499. +   struct mbuf *m;
  6500. +   uint16_t barctl, barseqctl;
  6501. +   uint8_t *frm;
  6502. +   int ret, tid;
  6503. +
  6504. +   ic = ni->ni_ic;
  6505. +   ifp = ic->ic_ifp;
  6506. +   sc = ifp->if_softc;
  6507. +   vap = ni->ni_vap;
  6508. +   rni = (struct rt2860_softc_node *) ni;
  6509. +
  6510. +   if (!(tap->txa_flags & IEEE80211_AGGR_RUNNING))
  6511. +       return EINVAL;
  6512. +
  6513. +   m = ieee80211_getmgtframe(&frm, ic->ic_headroom, sizeof(struct ieee80211_frame_bar));
  6514. +   if (m == NULL)
  6515. +       return ENOMEM;
  6516. +
  6517. +   bar = mtod(m, struct ieee80211_frame_bar *);
  6518. +
  6519. +   bar->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_BAR;
  6520. +   bar->i_fc[1] = 0;
  6521. +
  6522. +   IEEE80211_ADDR_COPY(bar->i_ra, ni->ni_macaddr);
  6523. +   IEEE80211_ADDR_COPY(bar->i_ta, vap->iv_myaddr);
  6524. +
  6525. +   tid = WME_AC_TO_TID(tap->txa_ac);
  6526. +
  6527. +   barctl = (tap->txa_flags & IEEE80211_AGGR_IMMEDIATE ?  0 : IEEE80211_BAR_NOACK) |
  6528. +       IEEE80211_BAR_COMP |
  6529. +       RT2860_SM(tid, IEEE80211_BAR_TID);
  6530. +   barseqctl = RT2860_SM(seqno, IEEE80211_BAR_SEQ_START);
  6531. +
  6532. +   bar->i_ctl = htole16(barctl);
  6533. +   bar->i_seq = htole16(barseqctl);
  6534. +
  6535. +   m->m_pkthdr.len = m->m_len = sizeof(struct ieee80211_frame_bar);
  6536. +
  6537. +   tap->txa_start = seqno;
  6538. +
  6539. +   ieee80211_ref_node(ni);
  6540. +
  6541. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  6542. +       "%s: sending BAR: associd=0x%04x, staid=0x%02x, tid=%d, seqno=%d\n",
  6543. +       device_get_nameunit(sc->sc_dev), ni->ni_associd, rni->staid, tid, seqno);
  6544. +
  6545. +   ret = ic->ic_raw_xmit(ni, m, NULL);
  6546. +   if (ret != 0)
  6547. +       ieee80211_free_node(ni);
  6548. +
  6549. +   return ret;
  6550. +}
  6551. +
  6552. +/*
  6553. + * rt2860_amrr_update_iter_func
  6554. + */
  6555. +static void rt2860_amrr_update_iter_func(void *arg, struct ieee80211_node *ni)
  6556. +{
  6557. +   struct rt2860_softc *sc;
  6558. +   struct ieee80211com *ic;
  6559. +   struct ifnet *ifp;
  6560. +   struct ieee80211vap *vap;
  6561. +   struct rt2860_softc_vap *rvap;
  6562. +   struct rt2860_softc_node *rni;
  6563. +   uint8_t wcid;
  6564. +
  6565. +   vap = arg;
  6566. +   ic = vap->iv_ic;
  6567. +   ifp = ic->ic_ifp;
  6568. +   sc = ifp->if_softc;
  6569. +   rvap = (struct rt2860_softc_vap *) vap;
  6570. +   rni = (struct rt2860_softc_node *) ni;
  6571. +
  6572. +   /* only associated stations */
  6573. +
  6574. +   if ((ni->ni_vap == vap) && (rni->staid != 0))
  6575. +   {
  6576. +       wcid = rni->staid;
  6577. +
  6578. +       RT2860_DPRINTF(sc, RT2860_DEBUG_RATE,
  6579. +           "%s: AMRR node: staid=0x%02x, txcnt=%d, success=%d, retrycnt=%d\n",
  6580. +           device_get_nameunit(sc->sc_dev),
  6581. +           rni->staid, sc->amrr_node[wcid].txcnt, sc->amrr_node[wcid].success, sc->amrr_node[wcid].retrycnt);
  6582. +
  6583. +       rt2860_amrr_choose(ni, &sc->amrr_node[wcid]);
  6584. +
  6585. +       RT2860_DPRINTF(sc, RT2860_DEBUG_RATE,
  6586. +           "%s:%s node Tx rate: associd=0x%04x, staid=0x%02x, rate=0x%02x, max rate=0x%02x\n",
  6587. +           device_get_nameunit(sc->sc_dev),
  6588. +           (ni->ni_flags & IEEE80211_NODE_HT) ? " HT" : "",
  6589. +           ni->ni_associd, rni->staid, ni->ni_txrate,
  6590. +           (ni->ni_flags & IEEE80211_NODE_HT) ?
  6591. +               (ni->ni_htrates.rs_rates[ni->ni_htrates.rs_nrates - 1] | IEEE80211_RATE_MCS) :
  6592. +               (ni->ni_rates.rs_rates[ni->ni_rates.rs_nrates - 1] & IEEE80211_RATE_VAL));
  6593. +   }
  6594. +}
  6595. +
  6596. +/*
  6597. + * rt2860_periodic
  6598. + */
  6599. +static void rt2860_periodic(void *arg)
  6600. +{
  6601. +   struct rt2860_softc *sc;
  6602. +
  6603. +   sc = arg;
  6604. +
  6605. +   RT2860_DPRINTF(sc, RT2860_DEBUG_PERIODIC,
  6606. +       "%s: periodic\n",
  6607. +       device_get_nameunit(sc->sc_dev));
  6608. +
  6609. +   taskqueue_enqueue(sc->taskqueue, &sc->periodic_task);
  6610. +}
  6611. +
  6612. +/*
  6613. + * rt2860_tx_watchdog
  6614. + */
  6615. +static void rt2860_tx_watchdog(void *arg)
  6616. +{
  6617. +   struct rt2860_softc *sc;
  6618. +   struct ifnet *ifp;
  6619. +
  6620. +   sc = arg;
  6621. +   ifp = sc->sc_ifp;
  6622. +
  6623. +   if (sc->sc_tx_timer == 0)
  6624. +       return;
  6625. +
  6626. +   if (--sc->sc_tx_timer == 0)
  6627. +   {
  6628. +       printf("%s: Tx watchdog timeout: resetting\n",
  6629. +           device_get_nameunit(sc->sc_dev));
  6630. +
  6631. +       rt2860_stop_locked(sc);
  6632. +       rt2860_init_locked(sc);
  6633. +
  6634. +       ifp->if_oerrors++;
  6635. +
  6636. +       sc->tx_watchdog_timeouts++;
  6637. +   }
  6638. +
  6639. +   callout_reset(&sc->tx_watchdog_ch, hz, rt2860_tx_watchdog, sc);
  6640. +}
  6641. +
  6642. +/*
  6643. + * rt2860_staid_alloc
  6644. + */
  6645. +static int rt2860_staid_alloc(struct rt2860_softc *sc, int aid)
  6646. +{
  6647. +   int staid;
  6648. +
  6649. +   if ((aid > 0 && aid < RT2860_SOFTC_STAID_COUNT) && isclr(sc->staid_mask, aid))
  6650. +   {
  6651. +       staid = aid;
  6652. +   }
  6653. +   else
  6654. +   {
  6655. +       for (staid = 1; staid < RT2860_SOFTC_STAID_COUNT; staid++)
  6656. +       {
  6657. +           if (isclr(sc->staid_mask, staid))
  6658. +               break;
  6659. +       }
  6660. +   }
  6661. +
  6662. +   setbit(sc->staid_mask, staid);
  6663. +
  6664. +   return staid;
  6665. +}
  6666. +
  6667. +/*
  6668. + * rt2860_staid_delete
  6669. + */
  6670. +static void rt2860_staid_delete(struct rt2860_softc *sc, int staid)
  6671. +{
  6672. +   clrbit(sc->staid_mask, staid);
  6673. +}
  6674. +
  6675. +/*
  6676. + * rt2860_asic_set_bssid
  6677. + */
  6678. +static void rt2860_asic_set_bssid(struct rt2860_softc *sc,
  6679. +   const uint8_t *bssid)
  6680. +{
  6681. +   uint32_t tmp;
  6682. +
  6683. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  6684. +       "%s: set bssid: bssid=%s\n",
  6685. +       device_get_nameunit(sc->sc_dev),
  6686. +       ether_sprintf(bssid));
  6687. +
  6688. +   tmp = bssid[0] | (bssid[1]) << 8 | (bssid[2] << 16) | (bssid[3] << 24);
  6689. +
  6690. +   rt2860_io_mac_write(sc, RT2860_REG_BSSID_DW0, tmp);
  6691. +
  6692. +   tmp = bssid[4] | (bssid[5] << 8);
  6693. +
  6694. +   rt2860_io_mac_write(sc, RT2860_REG_BSSID_DW1, tmp);
  6695. +}
  6696. +
  6697. +/*
  6698. + * rt2860_asic_set_macaddr
  6699. + */
  6700. +static void rt2860_asic_set_macaddr(struct rt2860_softc *sc,
  6701. +   const uint8_t *addr)
  6702. +{
  6703. +   uint32_t tmp;
  6704. +
  6705. +   tmp = addr[0] | (addr[1] << 8) | (addr[2] << 16) | (addr[3] << 24);
  6706. +
  6707. +   rt2860_io_mac_write(sc, RT2860_REG_ADDR_DW0, tmp);
  6708. +
  6709. +   tmp = addr[4] | (addr[5] << 8) | (0xff << 16);
  6710. +
  6711. +   rt2860_io_mac_write(sc, RT2860_REG_ADDR_DW1, tmp);
  6712. +}
  6713. +
  6714. +/*
  6715. + * rt2860_asic_enable_tsf_sync
  6716. + */
  6717. +static void rt2860_asic_enable_tsf_sync(struct rt2860_softc *sc)
  6718. +{
  6719. +   struct ifnet *ifp;
  6720. +   struct ieee80211com *ic;
  6721. +   struct ieee80211vap *vap;
  6722. +   uint32_t tmp;
  6723. +
  6724. +   ifp = sc->sc_ifp;
  6725. +   ic = ifp->if_l2com;
  6726. +   vap = TAILQ_FIRST(&ic->ic_vaps);
  6727. +
  6728. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BEACON,
  6729. +       "%s: enabling TSF\n",
  6730. +       device_get_nameunit(sc->sc_dev));
  6731. +
  6732. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_BCN_TIME_CFG);
  6733. +
  6734. +   tmp &= ~0x1fffff;
  6735. +   tmp |= vap->iv_bss->ni_intval * 16;
  6736. +   tmp |= (RT2860_REG_TSF_TIMER_ENABLE | RT2860_REG_TBTT_TIMER_ENABLE);
  6737. +
  6738. +   if (vap->iv_opmode == IEEE80211_M_STA)
  6739. +   {
  6740. +       tmp |= (RT2860_REG_TSF_SYNC_MODE_STA << RT2860_REG_TSF_SYNC_MODE_SHIFT);
  6741. +   }
  6742. +   else if (vap->iv_opmode == IEEE80211_M_IBSS)
  6743. +   {
  6744. +       tmp |= RT2860_REG_BCN_TX_ENABLE;
  6745. +       tmp |= (RT2860_REG_TSF_SYNC_MODE_IBSS << RT2860_REG_TSF_SYNC_MODE_SHIFT);
  6746. +   }
  6747. +   else if (vap->iv_opmode == IEEE80211_M_HOSTAP)
  6748. +   {
  6749. +       tmp |= RT2860_REG_BCN_TX_ENABLE;
  6750. +       tmp |= (RT2860_REG_TSF_SYNC_MODE_HOSTAP << RT2860_REG_TSF_SYNC_MODE_SHIFT);
  6751. +   }
  6752. +
  6753. +   rt2860_io_mac_write(sc, RT2860_REG_BCN_TIME_CFG, tmp);
  6754. +}
  6755. +
  6756. +/*
  6757. + * rt2860_asic_disable_tsf_sync
  6758. + */
  6759. +static void rt2860_asic_disable_tsf_sync(struct rt2860_softc *sc)
  6760. +{
  6761. +   uint32_t tmp;
  6762. +
  6763. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BEACON,
  6764. +       "%s: disabling TSF\n",
  6765. +       device_get_nameunit(sc->sc_dev));
  6766. +
  6767. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_BCN_TIME_CFG);
  6768. +
  6769. +   tmp &= ~(RT2860_REG_BCN_TX_ENABLE |
  6770. +       RT2860_REG_TSF_TIMER_ENABLE |
  6771. +       RT2860_REG_TBTT_TIMER_ENABLE);
  6772. +
  6773. +   tmp &= ~(RT2860_REG_TSF_SYNC_MODE_MASK << RT2860_REG_TSF_SYNC_MODE_SHIFT);
  6774. +   tmp |= (RT2860_REG_TSF_SYNC_MODE_DISABLE << RT2860_REG_TSF_SYNC_MODE_SHIFT);
  6775. +
  6776. +   rt2860_io_mac_write(sc, RT2860_REG_BCN_TIME_CFG, tmp);
  6777. +}
  6778. +
  6779. +/*
  6780. + * rt2860_asic_enable_mrr
  6781. + */
  6782. +static void rt2860_asic_enable_mrr(struct rt2860_softc *sc)
  6783. +{
  6784. +#define CCK(mcs)   (mcs)
  6785. +#define OFDM(mcs)  ((1 << 3) | (mcs))
  6786. +#define HT(mcs)        (mcs)
  6787. +
  6788. +   rt2860_io_mac_write(sc, RT2860_REG_TX_LG_FBK_CFG0,
  6789. +       (OFDM(6) << 28) |   /* 54 -> 48 */
  6790. +       (OFDM(5) << 24) |   /* 48 -> 36 */
  6791. +       (OFDM(4) << 20) |   /* 36 -> 24 */
  6792. +       (OFDM(3) << 16) |   /* 24 -> 18 */
  6793. +       (OFDM(2) << 12) |   /* 18 -> 12 */
  6794. +       (OFDM(1) << 8)  |   /* 12 -> 9 */
  6795. +       (OFDM(0) << 4)  |   /*  9 -> 6 */
  6796. +       OFDM(0));           /*  6 -> 6 */
  6797. +
  6798. +   rt2860_io_mac_write(sc, RT2860_REG_TX_LG_FBK_CFG1,
  6799. +       (CCK(2) << 12) |    /* 11  -> 5.5 */
  6800. +       (CCK(1) << 8)  |    /* 5.5 -> 2 */
  6801. +       (CCK(0) << 4)  |    /*   2 -> 1 */
  6802. +       CCK(0));            /*   1 -> 1 */
  6803. +
  6804. +   rt2860_io_mac_write(sc, RT2860_REG_TX_HT_FBK_CFG0,
  6805. +       (HT(6) << 28) |
  6806. +       (HT(5) << 24) |
  6807. +       (HT(4) << 20) |
  6808. +       (HT(3) << 16) |
  6809. +       (HT(2) << 12) |
  6810. +       (HT(1) << 8)  |
  6811. +       (HT(0) << 4)  |
  6812. +       HT(0));
  6813. +
  6814. +   rt2860_io_mac_write(sc, RT2860_REG_TX_HT_FBK_CFG1,
  6815. +       (HT(14) << 28) |
  6816. +       (HT(13) << 24) |
  6817. +       (HT(12) << 20) |
  6818. +       (HT(11) << 16) |
  6819. +       (HT(10) << 12) |
  6820. +       (HT(9) << 8)   |
  6821. +       (HT(8) << 4)   |
  6822. +       HT(7));
  6823. +
  6824. +#undef HT
  6825. +#undef OFDM
  6826. +#undef CCK
  6827. +}
  6828. +
  6829. +/*
  6830. + * rt2860_asic_set_txpreamble
  6831. + */
  6832. +static void rt2860_asic_set_txpreamble(struct rt2860_softc *sc)
  6833. +{
  6834. +   struct ifnet *ifp;
  6835. +   struct ieee80211com *ic;
  6836. +   uint32_t tmp;
  6837. +
  6838. +   ifp = sc->sc_ifp;
  6839. +   ic = ifp->if_l2com;
  6840. +
  6841. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  6842. +       "%s: %s short Tx preamble\n",
  6843. +       device_get_nameunit(sc->sc_dev),
  6844. +       (ic->ic_flags & IEEE80211_F_SHPREAMBLE) ? "enabling" : "disabling");
  6845. +
  6846. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_AUTO_RSP_CFG);
  6847. +
  6848. +   tmp &= ~RT2860_REG_CCK_SHORT_ENABLE;
  6849. +
  6850. +   if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
  6851. +       tmp |= RT2860_REG_CCK_SHORT_ENABLE;
  6852. +
  6853. +   rt2860_io_mac_write(sc, RT2860_REG_AUTO_RSP_CFG, tmp);
  6854. +}
  6855. +
  6856. +/*
  6857. + * rt2860_asic_set_basicrates
  6858. + */
  6859. +static void rt2860_asic_set_basicrates(struct rt2860_softc *sc)
  6860. +{
  6861. +   struct ifnet *ifp;
  6862. +   struct ieee80211com *ic;
  6863. +
  6864. +   ifp = sc->sc_ifp;
  6865. +   ic = ifp->if_l2com;
  6866. +
  6867. +   if (ic->ic_curmode == IEEE80211_MODE_11B)
  6868. +       rt2860_io_mac_write(sc, RT2860_REG_LEGACY_BASIC_RATE, 0xf);
  6869. +   else if (ic->ic_curmode == IEEE80211_MODE_11A)
  6870. +       rt2860_io_mac_write(sc, RT2860_REG_LEGACY_BASIC_RATE, 0x150);
  6871. +   else
  6872. +       rt2860_io_mac_write(sc, RT2860_REG_LEGACY_BASIC_RATE, 0x15f);
  6873. +}
  6874. +
  6875. +/*
  6876. + * rt2860_asic_update_rtsthreshold
  6877. + */
  6878. +static void rt2860_asic_update_rtsthreshold(struct rt2860_softc *sc)
  6879. +{
  6880. +   struct ifnet *ifp;
  6881. +   struct ieee80211com *ic;
  6882. +   struct ieee80211vap *vap;
  6883. +   uint32_t tmp;
  6884. +   uint16_t threshold;
  6885. +
  6886. +   ifp = sc->sc_ifp;
  6887. +   ic = ifp->if_l2com;
  6888. +   vap = TAILQ_FIRST(&ic->ic_vaps);
  6889. +
  6890. +   if (vap == NULL)
  6891. +       threshold = IEEE80211_RTS_MAX;
  6892. +   else if (vap->iv_flags_ht & IEEE80211_FHT_AMSDU_TX)
  6893. +       threshold = 0x1000;
  6894. +   else
  6895. +       threshold = vap->iv_rtsthreshold;
  6896. +
  6897. +   RT2860_DPRINTF(sc, RT2860_DEBUG_PROT,
  6898. +       "%s: updating RTS threshold: %d\n",
  6899. +       device_get_nameunit(sc->sc_dev), threshold);
  6900. +
  6901. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_RTS_CFG);
  6902. +
  6903. +   tmp &= ~(RT2860_REG_TX_RTS_THRESHOLD_MASK << RT2860_REG_TX_RTS_THRESHOLD_SHIFT);
  6904. +
  6905. +   tmp |= ((threshold & RT2860_REG_TX_RTS_THRESHOLD_MASK) <<
  6906. +       RT2860_REG_TX_RTS_THRESHOLD_SHIFT);
  6907. +
  6908. +   rt2860_io_mac_write(sc, RT2860_REG_TX_RTS_CFG, tmp);
  6909. +}
  6910. +
  6911. +/*
  6912. + * rt2860_asic_update_txpower
  6913. + */
  6914. +static void rt2860_asic_update_txpower(struct rt2860_softc *sc)
  6915. +{
  6916. +   struct ifnet *ifp;
  6917. +   struct ieee80211com *ic;
  6918. +   uint32_t *txpow_rate;
  6919. +   int8_t delta;
  6920. +   uint8_t val;
  6921. +   uint32_t tmp;
  6922. +   int i;
  6923. +
  6924. +   ifp = sc->sc_ifp;
  6925. +   ic = ifp->if_l2com;
  6926. +
  6927. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  6928. +       "%s: updating Tx power: %d\n",
  6929. +       device_get_nameunit(sc->sc_dev), ic->ic_txpowlimit);
  6930. +
  6931. +   if (!IEEE80211_IS_CHAN_HT40(ic->ic_curchan))
  6932. +   {
  6933. +       txpow_rate = sc->txpow_rate_20mhz;
  6934. +   }
  6935. +   else
  6936. +   {
  6937. +       if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan))
  6938. +           txpow_rate = sc->txpow_rate_40mhz_2ghz;
  6939. +       else
  6940. +           txpow_rate = sc->txpow_rate_40mhz_5ghz;
  6941. +   }
  6942. +
  6943. +   delta = 0;
  6944. +
  6945. +   val = rt2860_io_bbp_read(sc, 1);
  6946. +   val &= 0xfc;
  6947. +
  6948. +   if (ic->ic_txpowlimit > 90)
  6949. +   {
  6950. +       /* do nothing */
  6951. +   }
  6952. +   else if (ic->ic_txpowlimit > 60)
  6953. +   {
  6954. +       delta -= 1;
  6955. +   }
  6956. +   else if (ic->ic_txpowlimit > 30)
  6957. +   {
  6958. +       delta -= 3;
  6959. +   }
  6960. +   else if (ic->ic_txpowlimit > 15)
  6961. +   {
  6962. +       val |= 0x1;
  6963. +   }
  6964. +   else if (ic->ic_txpowlimit > 9)
  6965. +   {
  6966. +       val |= 0x1;
  6967. +       delta -= 3;
  6968. +   }
  6969. +   else
  6970. +   {
  6971. +       val |= 0x2;
  6972. +   }
  6973. +
  6974. +   rt2860_io_bbp_write(sc, 1, val);
  6975. +
  6976. +   for (i = 0; i < RT2860_SOFTC_TXPOW_RATE_COUNT; i++)
  6977. +   {
  6978. +       if (txpow_rate[i] == 0xffffffff)
  6979. +           continue;
  6980. +
  6981. +       tmp = rt2860_read_eeprom_txpow_rate_add_delta(txpow_rate[i], delta);
  6982. +
  6983. +       rt2860_io_mac_write(sc, RT2860_REG_TX_PWR_CFG(i), tmp);
  6984. +   }
  6985. +}
  6986. +
  6987. +/*
  6988. + * rt2860_asic_update_promisc
  6989. + */
  6990. +static void rt2860_asic_update_promisc(struct rt2860_softc *sc)
  6991. +{
  6992. +   struct ifnet *ifp;
  6993. +   uint32_t tmp;
  6994. +
  6995. +   ifp = sc->sc_ifp;
  6996. +
  6997. +   printf("%s: %s promiscuous mode\n",
  6998. +       device_get_nameunit(sc->sc_dev),
  6999. +       (ifp->if_flags & IFF_PROMISC) ? "entering" : "leaving");
  7000. +
  7001. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_RX_FILTER_CFG);
  7002. +
  7003. +   tmp &= ~RT2860_REG_RX_FILTER_DROP_UC_NOME;
  7004. +
  7005. +   if (!(ifp->if_flags & IFF_PROMISC))
  7006. +       tmp |= RT2860_REG_RX_FILTER_DROP_UC_NOME;
  7007. +
  7008. +   rt2860_io_mac_write(sc, RT2860_REG_RX_FILTER_CFG, tmp);
  7009. +}
  7010. +
  7011. +/*
  7012. + * rt2860_asic_updateprot
  7013. + */
  7014. +static void rt2860_asic_updateprot(struct rt2860_softc *sc)
  7015. +{
  7016. +   struct ifnet *ifp;
  7017. +   struct ieee80211com *ic;
  7018. +   struct ieee80211vap *vap;
  7019. +   uint32_t cck_prot, ofdm_prot, mm20_prot, mm40_prot, gf20_prot, gf40_prot;
  7020. +   uint8_t htopmode;
  7021. +   enum ieee80211_protmode htprotmode;
  7022. +
  7023. +   ifp = sc->sc_ifp;
  7024. +   ic = ifp->if_l2com;
  7025. +   vap = TAILQ_FIRST(&ic->ic_vaps);
  7026. +
  7027. +   /* CCK frame protection */
  7028. +
  7029. +   cck_prot = RT2860_REG_RTSTH_ENABLE | RT2860_REG_PROT_NAV_SHORT |
  7030. +       RT2860_REG_TXOP_ALLOW_ALL | RT2860_REG_PROT_CTRL_NONE;
  7031. +
  7032. +   /* set up protection frame phy mode and rate (MCS code) */
  7033. +
  7034. +   if (ic->ic_curmode == IEEE80211_MODE_11A)
  7035. +       cck_prot |= (RT2860_REG_PROT_PHYMODE_OFDM << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7036. +           (0 << RT2860_REG_PROT_MCS_SHIFT);
  7037. +   else
  7038. +       cck_prot |= ((RT2860_REG_PROT_PHYMODE_CCK << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7039. +           (3 << RT2860_REG_PROT_MCS_SHIFT));
  7040. +
  7041. +   rt2860_io_mac_write(sc, RT2860_REG_TX_CCK_PROT_CFG, cck_prot);
  7042. +
  7043. +   /* OFDM frame protection */
  7044. +
  7045. +   ofdm_prot = RT2860_REG_RTSTH_ENABLE | RT2860_REG_PROT_NAV_SHORT |
  7046. +       RT2860_REG_TXOP_ALLOW_ALL;
  7047. +
  7048. +   if (ic->ic_flags & IEEE80211_F_USEPROT)
  7049. +   {
  7050. +       RT2860_DPRINTF(sc, RT2860_DEBUG_PROT,
  7051. +           "%s: updating protection mode: b/g protection mode=%s\n",
  7052. +           device_get_nameunit(sc->sc_dev),
  7053. +           (ic->ic_protmode == IEEE80211_PROT_RTSCTS) ? "RTS/CTS" :
  7054. +               ((ic->ic_protmode == IEEE80211_PROT_CTSONLY) ? "CTS-to-self" : "none"));
  7055. +
  7056. +       if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
  7057. +           ofdm_prot |= RT2860_REG_PROT_CTRL_RTS_CTS;
  7058. +       else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
  7059. +           ofdm_prot |= RT2860_REG_PROT_CTRL_CTS;
  7060. +       else
  7061. +           ofdm_prot |= RT2860_REG_PROT_CTRL_NONE;
  7062. +   }
  7063. +   else
  7064. +   {
  7065. +       RT2860_DPRINTF(sc, RT2860_DEBUG_PROT,
  7066. +           "%s: updating protection mode: b/g protection mode=%s\n",
  7067. +           device_get_nameunit(sc->sc_dev), "none");
  7068. +
  7069. +       ofdm_prot |= RT2860_REG_PROT_CTRL_NONE;
  7070. +   }
  7071. +
  7072. +   rt2860_io_mac_write(sc, RT2860_REG_TX_OFDM_PROT_CFG, ofdm_prot);
  7073. +
  7074. +   /* HT frame protection */
  7075. +
  7076. +   if ((vap != NULL) && (vap->iv_opmode == IEEE80211_M_STA) && (vap->iv_state == IEEE80211_S_RUN))
  7077. +       htopmode = vap->iv_bss->ni_htopmode;
  7078. +   else
  7079. +       htopmode = ic->ic_curhtprotmode;
  7080. +
  7081. +   htprotmode = ic->ic_htprotmode;
  7082. +
  7083. +   /* force HT mixed mode and RTS/CTS protection if A-MPDU Tx aggregation is enabled */
  7084. +
  7085. +   if (sc->tx_ampdu_sessions > 0)
  7086. +   {
  7087. +       RT2860_DPRINTF(sc, RT2860_DEBUG_PROT,
  7088. +           "%s: updating protection mode: forcing HT mixed mode and RTS/CTS protection\n",
  7089. +           device_get_nameunit(sc->sc_dev));
  7090. +
  7091. +       htopmode = IEEE80211_HTINFO_OPMODE_MIXED;
  7092. +       htprotmode = IEEE80211_PROT_RTSCTS;
  7093. +   }
  7094. +
  7095. +   RT2860_DPRINTF(sc, RT2860_DEBUG_PROT,
  7096. +       "%s: updating protection mode: HT operation mode=0x%02x, protection mode=%s\n",
  7097. +       device_get_nameunit(sc->sc_dev),
  7098. +       htopmode & IEEE80211_HTINFO_OPMODE,
  7099. +       (htprotmode == IEEE80211_PROT_RTSCTS) ? "RTS/CTS" :
  7100. +           ((htprotmode == IEEE80211_PROT_CTSONLY) ? "CTS-to-self" : "none"));
  7101. +
  7102. +   switch (htopmode & IEEE80211_HTINFO_OPMODE)
  7103. +   {
  7104. +       /* IEEE80211_HTINFO_OPMODE_HT20PR */
  7105. +       case IEEE80211_HTINFO_OPMODE_HT20PR:
  7106. +           mm20_prot = RT2860_REG_PROT_NAV_SHORT | RT2860_REG_PROT_CTRL_NONE |
  7107. +               RT2860_REG_TXOP_ALLOW_CCK | RT2860_REG_TXOP_ALLOW_OFDM |
  7108. +               RT2860_REG_TXOP_ALLOW_MM20 | RT2860_REG_TXOP_ALLOW_GF20 |
  7109. +               (RT2860_REG_PROT_PHYMODE_OFDM << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7110. +               (4 << RT2860_REG_PROT_MCS_SHIFT);
  7111. +
  7112. +           gf20_prot = mm20_prot;
  7113. +
  7114. +           mm40_prot = RT2860_REG_PROT_NAV_SHORT | RT2860_REG_TXOP_ALLOW_ALL |
  7115. +               (RT2860_REG_PROT_PHYMODE_OFDM << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7116. +               (0x84 << RT2860_REG_PROT_MCS_SHIFT);
  7117. +
  7118. +           if (htprotmode == IEEE80211_PROT_RTSCTS)
  7119. +               mm40_prot |= RT2860_REG_PROT_CTRL_RTS_CTS;
  7120. +           else if (htprotmode == IEEE80211_PROT_CTSONLY)
  7121. +               mm40_prot |= RT2860_REG_PROT_CTRL_CTS;
  7122. +           else
  7123. +               mm40_prot |= RT2860_REG_PROT_CTRL_NONE;
  7124. +
  7125. +           gf40_prot = mm40_prot;
  7126. +       break;
  7127. +
  7128. +       /* IEEE80211_HTINFO_OPMODE_MIXED */
  7129. +       case IEEE80211_HTINFO_OPMODE_MIXED:
  7130. +           mm20_prot = RT2860_REG_PROT_NAV_SHORT |
  7131. +               RT2860_REG_TXOP_ALLOW_CCK | RT2860_REG_TXOP_ALLOW_OFDM |
  7132. +               RT2860_REG_TXOP_ALLOW_MM20 | RT2860_REG_TXOP_ALLOW_GF20;
  7133. +
  7134. +           if (ic->ic_flags & IEEE80211_F_USEPROT)
  7135. +               mm20_prot |= (RT2860_REG_PROT_PHYMODE_CCK << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7136. +                   (3 << RT2860_REG_PROT_MCS_SHIFT);
  7137. +           else
  7138. +               mm20_prot |= (RT2860_REG_PROT_PHYMODE_OFDM << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7139. +                   (4 << RT2860_REG_PROT_MCS_SHIFT);
  7140. +
  7141. +           if (htprotmode == IEEE80211_PROT_RTSCTS)
  7142. +               mm20_prot |= RT2860_REG_PROT_CTRL_RTS_CTS;
  7143. +           else if (htprotmode == IEEE80211_PROT_CTSONLY)
  7144. +               mm20_prot |= RT2860_REG_PROT_CTRL_CTS;
  7145. +           else
  7146. +               mm20_prot |= RT2860_REG_PROT_CTRL_NONE;
  7147. +
  7148. +           gf20_prot = mm20_prot;
  7149. +
  7150. +           mm40_prot = RT2860_REG_PROT_NAV_SHORT | RT2860_REG_TXOP_ALLOW_ALL;
  7151. +
  7152. +           if (ic->ic_flags & IEEE80211_F_USEPROT)
  7153. +               mm40_prot |= (RT2860_REG_PROT_PHYMODE_CCK << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7154. +                   (3 << RT2860_REG_PROT_MCS_SHIFT);
  7155. +           else
  7156. +               mm40_prot |= (RT2860_REG_PROT_PHYMODE_OFDM << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7157. +                   (0x84 << RT2860_REG_PROT_MCS_SHIFT);
  7158. +
  7159. +           if (htprotmode == IEEE80211_PROT_RTSCTS)
  7160. +               mm40_prot |= RT2860_REG_PROT_CTRL_RTS_CTS;
  7161. +           else if (htprotmode == IEEE80211_PROT_CTSONLY)
  7162. +               mm40_prot |= RT2860_REG_PROT_CTRL_CTS;
  7163. +           else
  7164. +               mm40_prot |= RT2860_REG_PROT_CTRL_NONE;
  7165. +
  7166. +           gf40_prot = mm40_prot;
  7167. +       break;
  7168. +
  7169. +       /*
  7170. +        * IEEE80211_HTINFO_OPMODE_PURE
  7171. +        * IEEE80211_HTINFO_OPMODE_PROTOPT
  7172. +        */
  7173. +       case IEEE80211_HTINFO_OPMODE_PURE:
  7174. +       case IEEE80211_HTINFO_OPMODE_PROTOPT:
  7175. +       default:
  7176. +           mm20_prot = RT2860_REG_PROT_NAV_SHORT | RT2860_REG_PROT_CTRL_NONE |
  7177. +               RT2860_REG_TXOP_ALLOW_CCK | RT2860_REG_TXOP_ALLOW_OFDM |
  7178. +               RT2860_REG_TXOP_ALLOW_MM20 | RT2860_REG_TXOP_ALLOW_GF20 |
  7179. +               (RT2860_REG_PROT_PHYMODE_OFDM << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7180. +               (4 << RT2860_REG_PROT_MCS_SHIFT);
  7181. +
  7182. +           gf20_prot = mm20_prot;
  7183. +
  7184. +           mm40_prot = RT2860_REG_PROT_NAV_SHORT | RT2860_REG_PROT_CTRL_NONE |
  7185. +               RT2860_REG_TXOP_ALLOW_ALL |
  7186. +               (RT2860_REG_PROT_PHYMODE_OFDM << RT2860_REG_PROT_PHYMODE_SHIFT) |
  7187. +               (0x84 << RT2860_REG_PROT_MCS_SHIFT);
  7188. +
  7189. +           gf40_prot = mm40_prot;
  7190. +       break;
  7191. +   }
  7192. +
  7193. +   rt2860_io_mac_write(sc, RT2860_REG_TX_MM20_PROT_CFG, mm20_prot);
  7194. +   rt2860_io_mac_write(sc, RT2860_REG_TX_MM40_PROT_CFG, mm40_prot);
  7195. +   rt2860_io_mac_write(sc, RT2860_REG_TX_GF20_PROT_CFG, gf20_prot);
  7196. +   rt2860_io_mac_write(sc, RT2860_REG_TX_GF40_PROT_CFG, gf40_prot);
  7197. +}
  7198. +
  7199. +/*
  7200. + * rt2860_asic_updateslot
  7201. + */
  7202. +static void rt2860_asic_updateslot(struct rt2860_softc *sc)
  7203. +{
  7204. +   struct ifnet *ifp;
  7205. +   struct ieee80211com *ic;
  7206. +   struct ieee80211vap *vap;
  7207. +   uint32_t tmp;
  7208. +
  7209. +   ifp = sc->sc_ifp;
  7210. +   ic = ifp->if_l2com;
  7211. +   vap = TAILQ_FIRST(&ic->ic_vaps);
  7212. +
  7213. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATE,
  7214. +       "%s: %s short slot time\n",
  7215. +       device_get_nameunit(sc->sc_dev),
  7216. +       ((ic->ic_flags & IEEE80211_F_SHSLOT) ||
  7217. +        ((vap != NULL) && (vap->iv_flags & IEEE80211_F_BURST))) ? "enabling" : "disabling");
  7218. +
  7219. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_BKOFF_SLOT_CFG);
  7220. +
  7221. +   tmp &= ~0xff;
  7222. +
  7223. +   if ((ic->ic_flags & IEEE80211_F_SHSLOT) ||
  7224. +       ((vap != NULL) && (vap->iv_flags & IEEE80211_F_BURST)))
  7225. +       tmp |= IEEE80211_DUR_SHSLOT;
  7226. +   else
  7227. +       tmp |= IEEE80211_DUR_SLOT;
  7228. +
  7229. +   rt2860_io_mac_write(sc, RT2860_REG_BKOFF_SLOT_CFG, tmp);
  7230. +}
  7231. +
  7232. +/*
  7233. + * rt2860_asic_wme_update
  7234. + */
  7235. +static void rt2860_asic_wme_update(struct rt2860_softc *sc)
  7236. +{
  7237. +   struct ifnet *ifp;
  7238. +   struct ieee80211com *ic;
  7239. +   struct ieee80211_wme_state *wme;
  7240. +   const struct wmeParams *wmep;
  7241. +   int i;
  7242. +
  7243. +   ifp = sc->sc_ifp;
  7244. +   ic = ifp->if_l2com;
  7245. +   wme = &ic->ic_wme;
  7246. +   wmep = wme->wme_chanParams.cap_wmeParams;
  7247. +
  7248. +   RT2860_DPRINTF(sc, RT2860_DEBUG_WME,
  7249. +       "%s: wme update: WME_AC_VO=%d/%d/%d/%d, WME_AC_VI=%d/%d/%d/%d, "
  7250. +       "WME_AC_BK=%d/%d/%d/%d, WME_AC_BE=%d/%d/%d/%d\n",
  7251. +       device_get_nameunit(sc->sc_dev),
  7252. +       wmep[WME_AC_VO].wmep_aifsn,
  7253. +       wmep[WME_AC_VO].wmep_logcwmin, wmep[WME_AC_VO].wmep_logcwmax,
  7254. +       wmep[WME_AC_VO].wmep_txopLimit,
  7255. +       wmep[WME_AC_VI].wmep_aifsn,
  7256. +       wmep[WME_AC_VI].wmep_logcwmin, wmep[WME_AC_VI].wmep_logcwmax,
  7257. +       wmep[WME_AC_VI].wmep_txopLimit,
  7258. +       wmep[WME_AC_BK].wmep_aifsn,
  7259. +       wmep[WME_AC_BK].wmep_logcwmin, wmep[WME_AC_BK].wmep_logcwmax,
  7260. +       wmep[WME_AC_BK].wmep_txopLimit,
  7261. +       wmep[WME_AC_BE].wmep_aifsn,
  7262. +       wmep[WME_AC_BE].wmep_logcwmin, wmep[WME_AC_BE].wmep_logcwmax,
  7263. +       wmep[WME_AC_BE].wmep_txopLimit);
  7264. +
  7265. +   for (i = 0; i < WME_NUM_AC; i++)
  7266. +       rt2860_io_mac_write(sc, RT2860_REG_TX_EDCA_AC_CFG(i),
  7267. +           (wmep[i].wmep_logcwmax << 16) | (wmep[i].wmep_logcwmin << 12) |
  7268. +           (wmep[i].wmep_aifsn << 8) | wmep[i].wmep_txopLimit);
  7269. +
  7270. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WMM_AIFSN_CFG,
  7271. +       (wmep[WME_AC_VO].wmep_aifsn << 12) | (wmep[WME_AC_VI].wmep_aifsn << 8) |
  7272. +       (wmep[WME_AC_BK].wmep_aifsn << 4) | wmep[WME_AC_BE].wmep_aifsn);
  7273. +
  7274. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WMM_CWMIN_CFG,
  7275. +       (wmep[WME_AC_VO].wmep_logcwmin << 12) | (wmep[WME_AC_VI].wmep_logcwmin << 8) |
  7276. +       (wmep[WME_AC_BK].wmep_logcwmin << 4) | wmep[WME_AC_BE].wmep_logcwmin);
  7277. +
  7278. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WMM_CWMAX_CFG,
  7279. +       (wmep[WME_AC_VO].wmep_logcwmax << 12) | (wmep[WME_AC_VI].wmep_logcwmax << 8) |
  7280. +       (wmep[WME_AC_BK].wmep_logcwmax << 4) | wmep[WME_AC_BE].wmep_logcwmax);
  7281. +
  7282. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WMM_TXOP0_CFG,
  7283. +       (wmep[WME_AC_BK].wmep_txopLimit << 16) | wmep[WME_AC_BE].wmep_txopLimit);
  7284. +
  7285. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WMM_TXOP1_CFG,
  7286. +       (wmep[WME_AC_VO].wmep_txopLimit << 16) | wmep[WME_AC_VI].wmep_txopLimit);
  7287. +}
  7288. +
  7289. +/*
  7290. + * rt2860_asic_update_beacon
  7291. + */
  7292. +static void rt2860_asic_update_beacon(struct rt2860_softc *sc,
  7293. +   struct ieee80211vap *vap)
  7294. +{
  7295. +   struct rt2860_softc_vap *rvap;
  7296. +   struct mbuf *m;
  7297. +   struct rt2860_txwi *txwi;
  7298. +   uint32_t tmp;
  7299. +
  7300. +   rvap = (struct rt2860_softc_vap *) vap;
  7301. +
  7302. +   m = rvap->beacon_mbuf;
  7303. +   txwi = &rvap->beacon_txwi;
  7304. +
  7305. +   /* disable temporarily TSF sync */
  7306. +
  7307. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_BCN_TIME_CFG);
  7308. +
  7309. +   tmp &= ~(RT2860_REG_BCN_TX_ENABLE |
  7310. +       RT2860_REG_TSF_TIMER_ENABLE |
  7311. +       RT2860_REG_TBTT_TIMER_ENABLE);
  7312. +
  7313. +   rt2860_io_mac_write(sc, RT2860_REG_BCN_TIME_CFG, tmp);
  7314. +
  7315. +   /* write Tx wireless info and beacon frame to on-chip memory */
  7316. +
  7317. +   rt2860_io_mac_write_multi(sc, RT2860_REG_BEACON_BASE(0),
  7318. +       txwi, sizeof(struct rt2860_txwi));
  7319. +
  7320. +   rt2860_io_mac_write_multi(sc, RT2860_REG_BEACON_BASE(0) + sizeof(struct rt2860_txwi),
  7321. +       mtod(m, uint8_t *), m->m_pkthdr.len);
  7322. +
  7323. +   /* enable again TSF sync */
  7324. +
  7325. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_BCN_TIME_CFG);
  7326. +
  7327. +   tmp |= (RT2860_REG_BCN_TX_ENABLE |
  7328. +       RT2860_REG_TSF_TIMER_ENABLE |
  7329. +       RT2860_REG_TBTT_TIMER_ENABLE);
  7330. +
  7331. +   rt2860_io_mac_write(sc, RT2860_REG_BCN_TIME_CFG, tmp);
  7332. +}
  7333. +
  7334. +/*
  7335. + * rt2860_asic_clear_keytables
  7336. + */
  7337. +static void rt2860_asic_clear_keytables(struct rt2860_softc *sc)
  7338. +{
  7339. +   int i;
  7340. +
  7341. +   /* clear Rx WCID search table (entries = 256, entry size = 8) */
  7342. +
  7343. +   for (i = 0; i < 256; i++)
  7344. +   {
  7345. +       rt2860_io_mac_write(sc, RT2860_REG_WCID(i), 0xffffffff);
  7346. +       rt2860_io_mac_write(sc, RT2860_REG_WCID(i) + 4, 0x0000ffff);
  7347. +   }
  7348. +
  7349. +   /* clear WCID attribute table (entries = 256, entry size = 4) */
  7350. +
  7351. +   rt2860_io_mac_set_region_4(sc, RT2860_REG_WCID_ATTR(0), 0, 256);
  7352. +
  7353. +   /* clear IV/EIV table (entries = 256, entry size = 8) */
  7354. +
  7355. +   rt2860_io_mac_set_region_4(sc, RT2860_REG_IVEIV(0), 0, 2 * 256);
  7356. +
  7357. +   /* clear pairwise key table (entries = 64, entry size = 32) */
  7358. +
  7359. +   rt2860_io_mac_set_region_4(sc, RT2860_REG_PKEY(0), 0, 8 * 64);
  7360. +
  7361. +   /* clear shared key table (entries = 32, entry size = 32) */
  7362. +
  7363. +   rt2860_io_mac_set_region_4(sc, RT2860_REG_SKEY(0, 0), 0, 8 * 32);
  7364. +
  7365. +   /* clear shared key mode (entries = 32, entry size = 2) */
  7366. +
  7367. +   rt2860_io_mac_set_region_4(sc, RT2860_REG_SKEY_MODE(0), 0, 16);
  7368. +}
  7369. +
  7370. +/*
  7371. + * rt2860_asic_add_ba_session
  7372. + */
  7373. +static void rt2860_asic_add_ba_session(struct rt2860_softc *sc,
  7374. +   uint8_t wcid, int tid)
  7375. +{
  7376. +   uint32_t tmp;
  7377. +
  7378. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  7379. +       "%s: adding BA session: wcid=0x%02x, tid=%d\n",
  7380. +       device_get_nameunit(sc->sc_dev), wcid, tid);
  7381. +
  7382. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_WCID(wcid) + 4);
  7383. +
  7384. +   tmp |= (0x10000 << tid);
  7385. +
  7386. +   rt2860_io_mac_write(sc, RT2860_REG_WCID(wcid) + 4, tmp);
  7387. +}
  7388. +
  7389. +/*
  7390. + * rt2860_asic_del_ba_session
  7391. + */
  7392. +static void rt2860_asic_del_ba_session(struct rt2860_softc *sc,
  7393. +   uint8_t wcid, int tid)
  7394. +{
  7395. +   uint32_t tmp;
  7396. +
  7397. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BA,
  7398. +       "%s: deleting BA session: wcid=0x%02x, tid=%d\n",
  7399. +       device_get_nameunit(sc->sc_dev), wcid, tid);
  7400. +
  7401. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_WCID(wcid) + 4);
  7402. +
  7403. +   tmp &= ~(0x10000 << tid);
  7404. +
  7405. +   rt2860_io_mac_write(sc, RT2860_REG_WCID(wcid) + 4, tmp);
  7406. +}
  7407. +
  7408. +/*
  7409. + * rt2860_beacon_alloc
  7410. + */
  7411. +static int rt2860_beacon_alloc(struct rt2860_softc *sc,
  7412. +   struct ieee80211vap *vap)
  7413. +{
  7414. +   struct ieee80211com *ic;
  7415. +   struct rt2860_softc_vap *rvap;
  7416. +   struct mbuf *m;
  7417. +   struct rt2860_txwi txwi;
  7418. +   uint8_t rate, mcs;
  7419. +
  7420. +   ic = vap->iv_ic;
  7421. +   rvap = (struct rt2860_softc_vap *) vap;
  7422. +
  7423. +   m = ieee80211_beacon_alloc(vap->iv_bss, &rvap->beacon_offsets);
  7424. +   if (m == NULL)
  7425. +       return ENOMEM;
  7426. +
  7427. +   rate = IEEE80211_IS_CHAN_5GHZ(vap->iv_bss->ni_chan) ? 12 : 2;
  7428. +   mcs = rt2860_rate2mcs(rate);
  7429. +
  7430. +   RT2860_DPRINTF(sc, RT2860_DEBUG_BEACON,
  7431. +       "%s: beacon allocate: mcs=0x%02x\n",
  7432. +       device_get_nameunit(sc->sc_dev), mcs);
  7433. +
  7434. +   memset(&txwi, 0, sizeof(struct rt2860_txwi));
  7435. +
  7436. +   txwi.wcid = RT2860_WCID_RESERVED;
  7437. +   txwi.pid_mpdu_len = ((htole16(m->m_pkthdr.len) & RT2860_TXWI_MPDU_LEN_MASK) <<
  7438. +        RT2860_TXWI_MPDU_LEN_SHIFT);
  7439. +   txwi.txop = (RT2860_TXWI_TXOP_HT << RT2860_TXWI_TXOP_SHIFT);
  7440. +   txwi.mpdu_density_flags |=
  7441. +       (RT2860_TXWI_FLAGS_TS << RT2860_TXWI_FLAGS_SHIFT);
  7442. +   txwi.bawin_size_xflags |=
  7443. +       (RT2860_TXWI_XFLAGS_NSEQ << RT2860_TXWI_XFLAGS_SHIFT);
  7444. +
  7445. +   if (rate == 2)
  7446. +   {
  7447. +       txwi.phymode_ifs_stbc_shortgi =
  7448. +           (RT2860_TXWI_PHYMODE_CCK << RT2860_TXWI_PHYMODE_SHIFT);
  7449. +
  7450. +       if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
  7451. +           mcs |= RT2860_TXWI_MCS_SHOTPRE;
  7452. +   }
  7453. +   else
  7454. +   {
  7455. +       txwi.phymode_ifs_stbc_shortgi =
  7456. +           (RT2860_TXWI_PHYMODE_OFDM << RT2860_TXWI_PHYMODE_SHIFT);
  7457. +   }
  7458. +
  7459. +   txwi.bw_mcs = (RT2860_TXWI_BW_20 << RT2860_TXWI_BW_SHIFT) |
  7460. +       ((mcs & RT2860_TXWI_MCS_MASK) << RT2860_TXWI_MCS_SHIFT);
  7461. +
  7462. +   if (rvap->beacon_mbuf != NULL)
  7463. +   {
  7464. +       m_free(rvap->beacon_mbuf);
  7465. +       rvap->beacon_mbuf = NULL;
  7466. +   }
  7467. +
  7468. +   rvap->beacon_mbuf = m;
  7469. +   rvap->beacon_txwi = txwi;
  7470. +
  7471. +   return 0;
  7472. +}
  7473. +
  7474. +/*
  7475. + * rt2860_rxrate
  7476. + */
  7477. +static uint8_t rt2860_rxrate(struct rt2860_rxwi *rxwi)
  7478. +{
  7479. +   uint8_t mcs, phymode;
  7480. +   uint8_t rate;
  7481. +
  7482. +   mcs = (rxwi->bw_mcs >> RT2860_RXWI_MCS_SHIFT) & RT2860_RXWI_MCS_MASK;
  7483. +   phymode = (rxwi->phymode_stbc_shortgi >> RT2860_RXWI_PHYMODE_SHIFT) &
  7484. +       RT2860_RXWI_PHYMODE_MASK;
  7485. +
  7486. +   rate = 2;
  7487. +
  7488. +   switch (phymode)
  7489. +   {
  7490. +       case RT2860_RXWI_PHYMODE_CCK:
  7491. +           switch (mcs & ~RT2860_RXWI_MCS_SHOTPRE)
  7492. +           {
  7493. +               case 0: rate = 2; break;    /* 1 Mbps */
  7494. +               case 1: rate = 4; break;    /* 2 MBps */
  7495. +               case 2: rate = 11; break;   /* 5.5 Mbps */
  7496. +               case 3: rate = 22; break;   /* 11 Mbps */
  7497. +           }
  7498. +       break;
  7499. +
  7500. +       case RT2860_RXWI_PHYMODE_OFDM:
  7501. +           switch (mcs)
  7502. +           {
  7503. +               case 0: rate = 12; break;   /* 6 Mbps */
  7504. +               case 1: rate = 18; break;   /* 9 Mbps */
  7505. +               case 2: rate = 24; break;   /* 12 Mbps */
  7506. +               case 3: rate = 36; break;   /* 18 Mbps */
  7507. +               case 4: rate = 48; break;   /* 24 Mbps */
  7508. +               case 5: rate = 72; break;   /* 36 Mbps */
  7509. +               case 6: rate = 96; break;   /* 48 Mbps */
  7510. +               case 7: rate = 108; break;  /* 54 Mbps */
  7511. +           }
  7512. +       break;
  7513. +
  7514. +       case RT2860_RXWI_PHYMODE_HT_MIXED:
  7515. +       case RT2860_RXWI_PHYMODE_HT_GF:
  7516. +       break;
  7517. +   }
  7518. +
  7519. +   return rate;
  7520. +}
  7521. +
  7522. +/*
  7523. + * rt2860_maxrssi_rxpath
  7524. + */
  7525. +static uint8_t rt2860_maxrssi_rxpath(struct rt2860_softc *sc,
  7526. +   const struct rt2860_rxwi *rxwi)
  7527. +{
  7528. +   uint8_t rxpath;
  7529. +
  7530. +   rxpath = 0;
  7531. +
  7532. +   if (sc->nrxpath > 1)
  7533. +       if (rxwi->rssi[1] > rxwi->rssi[rxpath])
  7534. +           rxpath = 1;
  7535. +
  7536. +   if (sc->nrxpath > 2)
  7537. +       if (rxwi->rssi[2] > rxwi->rssi[rxpath])
  7538. +           rxpath = 2;
  7539. +
  7540. +   return rxpath;
  7541. +}
  7542. +
  7543. +/*
  7544. + * rt2860_rssi2dbm
  7545. + */
  7546. +static int8_t rt2860_rssi2dbm(struct rt2860_softc *sc,
  7547. +   uint8_t rssi, uint8_t rxpath)
  7548. +{
  7549. +   struct ifnet *ifp;
  7550. +   struct ieee80211com *ic;
  7551. +   struct ieee80211_channel *c;
  7552. +   int chan;
  7553. +   int8_t rssi_off, lna_gain;
  7554. +
  7555. +   if (rssi == 0)
  7556. +       return -99;
  7557. +
  7558. +   ifp = sc->sc_ifp;
  7559. +   ic = ifp->if_l2com;
  7560. +   c = ic->ic_curchan;
  7561. +   chan = ieee80211_chan2ieee(ic, c);
  7562. +
  7563. +   if (IEEE80211_IS_CHAN_5GHZ(c))
  7564. +   {
  7565. +       rssi_off = sc->rssi_off_5ghz[rxpath];
  7566. +
  7567. +       if (chan <= 64)
  7568. +           lna_gain = sc->lna_gain[1];
  7569. +       else if (chan <= 128)
  7570. +           lna_gain = sc->lna_gain[2];
  7571. +       else
  7572. +           lna_gain = sc->lna_gain[3];
  7573. +   }
  7574. +   else
  7575. +   {
  7576. +       rssi_off = sc->rssi_off_2ghz[rxpath] - sc->lna_gain[0];
  7577. +       lna_gain = sc->lna_gain[0];
  7578. +   }
  7579. +
  7580. +   return (-12 - rssi_off - lna_gain - rssi);
  7581. +}
  7582. +
  7583. +/*
  7584. + * rt2860_rate2mcs
  7585. + */
  7586. +static uint8_t rt2860_rate2mcs(uint8_t rate)
  7587. +{
  7588. +   switch (rate)
  7589. +   {
  7590. +       /* CCK rates */
  7591. +       case 2: return 0;
  7592. +       case 4: return 1;
  7593. +       case 11: return 2;
  7594. +       case 22: return 3;
  7595. +
  7596. +       /* OFDM rates */
  7597. +       case 12: return 0;
  7598. +       case 18: return 1;
  7599. +       case 24: return 2;
  7600. +       case 36: return 3;
  7601. +       case 48: return 4;
  7602. +       case 72: return 5;
  7603. +       case 96: return 6;
  7604. +       case 108: return 7;
  7605. +   }
  7606. +
  7607. +   return 0;
  7608. +}
  7609. +
  7610. +/*
  7611. + * rt2860_tx_mgmt
  7612. + */
  7613. +static int rt2860_tx_mgmt(struct rt2860_softc *sc,
  7614. +   struct mbuf *m, struct ieee80211_node *ni, int qid)
  7615. +{
  7616. +   struct ifnet *ifp;
  7617. +   struct ieee80211com *ic;
  7618. +   struct ieee80211vap *vap;
  7619. +   const struct ieee80211_txparam *tp;
  7620. +   struct rt2860_softc_node *rni;
  7621. +   struct rt2860_softc_tx_ring *ring;
  7622. +   struct rt2860_softc_tx_data *data;
  7623. +   struct rt2860_txdesc *desc;
  7624. +   struct rt2860_txwi *txwi;
  7625. +   struct ieee80211_frame *wh;
  7626. +   struct rt2860_softc_tx_radiotap_header *tap;
  7627. +   bus_dma_segment_t dma_seg[RT2860_SOFTC_MAX_SCATTER];
  7628. +   u_int hdrsize, hdrspace;
  7629. +   uint8_t rate, mcs, pid, qsel;
  7630. +   uint16_t len, dmalen, mpdu_len, dur;
  7631. +   int error, mimops, ndmasegs, ndescs, i, j;
  7632. +
  7633. +   KASSERT(qid >= 0 && qid < RT2860_SOFTC_TX_RING_COUNT,
  7634. +       ("%s: Tx MGMT: invalid qid=%d\n",
  7635. +        device_get_nameunit(sc->sc_dev), qid));
  7636. +
  7637. +   RT2860_SOFTC_TX_RING_ASSERT_LOCKED(&sc->tx_ring[qid]);
  7638. +
  7639. +   ifp = sc->sc_ifp;
  7640. +   ic = ifp->if_l2com;
  7641. +   vap = ni->ni_vap;
  7642. +   rni = (struct rt2860_softc_node *) ni;
  7643. +   tp = ni->ni_txparms;
  7644. +
  7645. +   ring = &sc->tx_ring[qid];
  7646. +   desc = &ring->desc[ring->desc_cur];
  7647. +   data = &ring->data[ring->data_cur];
  7648. +   txwi = (struct rt2860_txwi *) (ring->seg0 + ring->data_cur * RT2860_TX_DATA_SEG0_SIZE);
  7649. +
  7650. +   wh = mtod(m, struct ieee80211_frame *);
  7651. +
  7652. +   rate = tp->mgmtrate & IEEE80211_RATE_VAL;
  7653. +/* XXX */
  7654. +   if (!rate)
  7655. +       return EFBIG;
  7656. +
  7657. +   /* fill Tx wireless info */
  7658. +
  7659. +   if (ni->ni_flags & IEEE80211_NODE_HT)
  7660. +       mcs = rate;
  7661. +   else
  7662. +       mcs = rt2860_rate2mcs(rate);
  7663. +
  7664. +   /* calculate MPDU length without padding */
  7665. +
  7666. +   hdrsize = ieee80211_anyhdrsize(wh);
  7667. +   hdrspace = ieee80211_anyhdrspace(ic, wh);
  7668. +   mpdu_len = m->m_pkthdr.len - hdrspace + hdrsize;
  7669. +
  7670. +   memset(txwi, 0, sizeof(struct rt2860_txwi));
  7671. +
  7672. +   /* management frames do not need encryption */
  7673. +
  7674. +   txwi->wcid = RT2860_WCID_RESERVED;
  7675. +
  7676. +   /* MIMO power save */
  7677. +
  7678. +   if ((ni->ni_flags & IEEE80211_NODE_HT) && (ni->ni_flags & IEEE80211_NODE_MIMO_PS))
  7679. +   {
  7680. +       if (mcs > 7)
  7681. +       {
  7682. +           if (ni->ni_flags & IEEE80211_NODE_MIMO_RTS)
  7683. +           {
  7684. +               /* dynamic MIMO power save */
  7685. +
  7686. +               txwi->mpdu_density_flags |=
  7687. +                   (RT2860_TXWI_FLAGS_MIMOPS << RT2860_TXWI_FLAGS_SHIFT);
  7688. +           }
  7689. +           else
  7690. +           {
  7691. +               /* static MIMO power save */
  7692. +
  7693. +               mcs = 7;
  7694. +           }
  7695. +       }
  7696. +
  7697. +       mimops = 1;
  7698. +   }
  7699. +   else
  7700. +   {
  7701. +       mimops = 0;
  7702. +   }
  7703. +
  7704. +   pid = (mcs < 0xf) ? (mcs + 1) : mcs;
  7705. +
  7706. +   txwi->pid_mpdu_len = ((htole16(pid) & RT2860_TXWI_PID_MASK) <<
  7707. +       RT2860_TXWI_PID_SHIFT) | ((htole16(mpdu_len) & RT2860_TXWI_MPDU_LEN_MASK) <<
  7708. +           RT2860_TXWI_MPDU_LEN_SHIFT);
  7709. +
  7710. +   if (ni->ni_flags & IEEE80211_NODE_HT)
  7711. +   {
  7712. +       txwi->phymode_ifs_stbc_shortgi |=
  7713. +           (RT2860_TXWI_PHYMODE_HT_MIXED << RT2860_TXWI_PHYMODE_SHIFT);
  7714. +   }
  7715. +   else
  7716. +   {
  7717. +       if (ieee80211_rate2phytype(ic->ic_rt, rate) != IEEE80211_T_OFDM)
  7718. +       {
  7719. +           txwi->phymode_ifs_stbc_shortgi |=
  7720. +               (RT2860_TXWI_PHYMODE_CCK << RT2860_TXWI_PHYMODE_SHIFT);
  7721. +
  7722. +           if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
  7723. +               mcs |= RT2860_TXWI_MCS_SHOTPRE;
  7724. +       }
  7725. +       else
  7726. +       {
  7727. +           txwi->phymode_ifs_stbc_shortgi |=
  7728. +               (RT2860_TXWI_PHYMODE_OFDM << RT2860_TXWI_PHYMODE_SHIFT);
  7729. +       }
  7730. +   }
  7731. +
  7732. +   txwi->bw_mcs = (RT2860_TXWI_BW_20 << RT2860_TXWI_BW_SHIFT) |
  7733. +       ((mcs & RT2860_TXWI_MCS_MASK) << RT2860_TXWI_MCS_SHIFT);
  7734. +
  7735. +   txwi->txop = (RT2860_TXWI_TXOP_BACKOFF << RT2860_TXWI_TXOP_SHIFT);
  7736. +
  7737. +   /* skip ACKs for multicast frames */
  7738. +
  7739. +   if (!IEEE80211_IS_MULTICAST(wh->i_addr1))
  7740. +   {
  7741. +       txwi->bawin_size_xflags |=
  7742. +           (RT2860_TXWI_XFLAGS_ACK << RT2860_TXWI_XFLAGS_SHIFT);
  7743. +
  7744. +       if (ni->ni_flags & IEEE80211_NODE_HT)
  7745. +       {
  7746. +           /* preamble + plcp + signal extension + SIFS */
  7747. +
  7748. +           dur = 16 + 4 + 6 + 10;
  7749. +       }
  7750. +       else
  7751. +       {
  7752. +           dur = ieee80211_ack_duration(ic->ic_rt, rate,
  7753. +               ic->ic_flags & IEEE80211_F_SHPREAMBLE);
  7754. +       }
  7755. +
  7756. +       *(uint16_t *) wh->i_dur = htole16(dur);
  7757. +   }
  7758. +
  7759. +   /* ask MAC to insert timestamp into probe responses */
  7760. +
  7761. +   if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) ==
  7762. +       (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP))
  7763. +       txwi->mpdu_density_flags |=
  7764. +           (RT2860_TXWI_FLAGS_TS << RT2860_TXWI_FLAGS_SHIFT);
  7765. +
  7766. +   if (ieee80211_radiotap_active_vap(vap))
  7767. +   {
  7768. +       tap = &sc->txtap;
  7769. +
  7770. +       tap->flags = IEEE80211_RADIOTAP_F_DATAPAD;
  7771. +       tap->chan_flags = htole32(ic->ic_curchan->ic_flags);
  7772. +       tap->chan_freq = htole16(ic->ic_curchan->ic_freq);
  7773. +       tap->chan_ieee = ic->ic_curchan->ic_ieee;
  7774. +       tap->chan_maxpow = 0;
  7775. +
  7776. +       if (ni->ni_flags & IEEE80211_NODE_HT)
  7777. +           tap->rate = mcs | IEEE80211_RATE_MCS;
  7778. +       else
  7779. +           tap->rate = rate;
  7780. +
  7781. +       if (mcs & RT2860_TXWI_MCS_SHOTPRE)
  7782. +           tap->flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
  7783. +
  7784. +       if (wh->i_fc[1] & IEEE80211_FC1_WEP)
  7785. +           tap->flags |= IEEE80211_RADIOTAP_F_WEP;
  7786. +
  7787. +       if (wh->i_fc[1] & IEEE80211_FC1_WEP)
  7788. +       {
  7789. +           wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
  7790. +
  7791. +           ieee80211_radiotap_tx(vap, m);
  7792. +
  7793. +           wh->i_fc[1] |= IEEE80211_FC1_WEP;
  7794. +       }
  7795. +       else
  7796. +       {
  7797. +           ieee80211_radiotap_tx(vap, m);
  7798. +       }
  7799. +   }
  7800. +
  7801. +   /* copy and trim 802.11 header */
  7802. +
  7803. +   m_copydata(m, 0, hdrsize, (caddr_t) (txwi + 1));
  7804. +   m_adj(m, hdrspace);
  7805. +
  7806. +   error = bus_dmamap_load_mbuf_sg(ring->data_dma_tag, data->dma_map, m,
  7807. +       dma_seg, &ndmasegs, BUS_DMA_NOWAIT);
  7808. +   if (error != 0)
  7809. +   {
  7810. +       /* too many fragments, linearize */
  7811. +
  7812. +       RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  7813. +           "%s: could not load mbuf DMA map, trying to linearize mbuf: ndmasegs=%d, len=%d, error=%d\n",
  7814. +           device_get_nameunit(sc->sc_dev), ndmasegs, m->m_pkthdr.len, error);
  7815. +
  7816. +       m = m_defrag(m, M_DONTWAIT);
  7817. +       if (m == NULL)
  7818. +           return ENOMEM;
  7819. +
  7820. +       sc->tx_defrag_packets++;
  7821. +
  7822. +       error = bus_dmamap_load_mbuf_sg(ring->data_dma_tag, data->dma_map, m,
  7823. +           dma_seg, &ndmasegs, BUS_DMA_NOWAIT);
  7824. +       if (error != 0)
  7825. +       {
  7826. +           printf("%s: could not load mbuf DMA map: ndmasegs=%d, len=%d, error=%d\n",
  7827. +               device_get_nameunit(sc->sc_dev), ndmasegs, m->m_pkthdr.len, error);
  7828. +           m_freem(m);
  7829. +           return error;
  7830. +       }
  7831. +   }
  7832. +
  7833. +   if (m->m_pkthdr.len == 0)
  7834. +       ndmasegs = 0;
  7835. +
  7836. +   /* determine how many Tx descs are required */
  7837. +
  7838. +   ndescs = 1 + ndmasegs / 2;
  7839. +   if ((ring->desc_queued + ndescs) > (RT2860_SOFTC_TX_RING_DESC_COUNT - 2))
  7840. +   {
  7841. +       RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  7842. +           "%s: there are not enough Tx descs\n",
  7843. +           device_get_nameunit(sc->sc_dev));
  7844. +
  7845. +       sc->no_tx_desc_avail++;
  7846. +
  7847. +       bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
  7848. +       m_freem(m);
  7849. +       return EFBIG;
  7850. +   }
  7851. +
  7852. +   data->m = m;
  7853. +   data->ni = ni;
  7854. +
  7855. +   /* set up Tx descs */
  7856. +
  7857. +   /* first segment is Tx wireless info and 802.11 header */
  7858. +
  7859. +   len = sizeof(struct rt2860_txwi) + hdrsize;
  7860. +
  7861. +   /* align end on a 4-bytes boundary */
  7862. +
  7863. +   dmalen = (len + 3) & ~ 3;
  7864. +
  7865. +   memset((caddr_t) txwi + len, 0, dmalen - len);
  7866. +
  7867. +   qsel = RT2860_TXDESC_QSEL_EDCA;
  7868. +
  7869. +   desc->sdp0 = htole32(ring->seg0_phys_addr + ring->data_cur * RT2860_TX_DATA_SEG0_SIZE);
  7870. +   desc->sdl0 = htole16(dmalen);
  7871. +   desc->qsel_flags = (qsel << RT2860_TXDESC_QSEL_SHIFT);
  7872. +
  7873. +   /* set up payload segments */
  7874. +
  7875. +   for (i = ndmasegs, j = 0; i >= 2; i -= 2)
  7876. +   {
  7877. +       desc->sdp1 = htole32(dma_seg[j].ds_addr);
  7878. +       desc->sdl1 = htole16(dma_seg[j].ds_len);
  7879. +
  7880. +       ring->desc_queued++;
  7881. +       ring->desc_cur = (ring->desc_cur + 1) % RT2860_SOFTC_TX_RING_DESC_COUNT;
  7882. +
  7883. +       j++;
  7884. +
  7885. +       desc = &ring->desc[ring->desc_cur];
  7886. +
  7887. +       desc->sdp0 = htole32(dma_seg[j].ds_addr);
  7888. +       desc->sdl0 = htole16(dma_seg[j].ds_len);
  7889. +       desc->qsel_flags = (qsel << RT2860_TXDESC_QSEL_SHIFT);
  7890. +
  7891. +       j++;
  7892. +   }
  7893. +
  7894. +   /* finalize last payload segment */
  7895. +
  7896. +   if (i > 0)
  7897. +   {
  7898. +       desc->sdp1 = htole32(dma_seg[j].ds_addr);
  7899. +       desc->sdl1 = htole16(dma_seg[j].ds_len | RT2860_TXDESC_SDL1_LASTSEG);
  7900. +   }
  7901. +   else
  7902. +   {
  7903. +       desc->sdl0 |= htole16(RT2860_TXDESC_SDL0_LASTSEG);
  7904. +       desc->sdl1 = 0;
  7905. +   }
  7906. +
  7907. +   RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  7908. +       "%s: sending MGMT frame: qid=%d, hdrsize=%d, hdrspace=%d, len=%d, "
  7909. +       "mcs=%d, mimops=%d, DMA len=%d, ndmasegs=%d, DMA ds_len=%d/%d/%d/%d/%d\n",
  7910. +       device_get_nameunit(sc->sc_dev),
  7911. +       qid, hdrsize, hdrspace, m->m_pkthdr.len + hdrsize,
  7912. +       mcs, mimops, dmalen, ndmasegs,
  7913. +       (int) dma_seg[0].ds_len, (int) dma_seg[1].ds_len, (int) dma_seg[2].ds_len, (int) dma_seg[3].ds_len, (int) dma_seg[4].ds_len);
  7914. +
  7915. +   bus_dmamap_sync(ring->seg0_dma_tag, ring->seg0_dma_map,
  7916. +       BUS_DMASYNC_PREWRITE);
  7917. +   bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  7918. +       BUS_DMASYNC_PREWRITE);
  7919. +   bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  7920. +       BUS_DMASYNC_PREWRITE);
  7921. +
  7922. +   ring->desc_queued++;
  7923. +   ring->desc_cur = (ring->desc_cur + 1) % RT2860_SOFTC_TX_RING_DESC_COUNT;
  7924. +
  7925. +   ring->data_queued++;
  7926. +   ring->data_cur = (ring->data_cur + 1) % RT2860_SOFTC_TX_RING_DATA_COUNT;
  7927. +
  7928. +   /* kick Tx */
  7929. +
  7930. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_CTX_IDX(qid), ring->desc_cur);
  7931. +
  7932. +   return 0;
  7933. +}
  7934. +
  7935. +/*
  7936. + * rt2860_tx_data
  7937. + */
  7938. +static int rt2860_tx_data(struct rt2860_softc *sc,
  7939. +   struct mbuf *m, struct ieee80211_node *ni, int qid)
  7940. +{
  7941. +   struct ifnet *ifp;
  7942. +   struct ieee80211com *ic;
  7943. +   struct ieee80211vap *vap;
  7944. +   const struct ieee80211_txparam *tp;
  7945. +   struct rt2860_softc_node *rni;
  7946. +   struct rt2860_softc_tx_ring *ring;
  7947. +   struct rt2860_softc_tx_data *data;
  7948. +   struct rt2860_txdesc *desc;
  7949. +   struct rt2860_txwi *txwi;
  7950. +   struct ieee80211_frame *wh;
  7951. +   struct ieee80211_tx_ampdu *tx_ampdu;
  7952. +   ieee80211_seq seqno;
  7953. +   struct rt2860_softc_tx_radiotap_header *tap;
  7954. +   bus_dma_segment_t dma_seg[RT2860_SOFTC_MAX_SCATTER];
  7955. +   u_int hdrsize, hdrspace;
  7956. +   uint8_t type, rate, bw, stbc, shortgi, mcs, pid, wcid, mpdu_density, bawin_size, qsel;
  7957. +   uint16_t qos, len, dmalen, mpdu_len, dur;
  7958. +   int error, hasqos, ac, tid, ampdu, mimops, ndmasegs, ndescs, i, j;
  7959. +
  7960. +   KASSERT(qid >= 0 && qid < RT2860_SOFTC_TX_RING_COUNT,
  7961. +       ("%s: Tx data: invalid qid=%d\n",
  7962. +        device_get_nameunit(sc->sc_dev), qid));
  7963. +
  7964. +   RT2860_SOFTC_TX_RING_ASSERT_LOCKED(&sc->tx_ring[qid]);
  7965. +
  7966. +   ifp = sc->sc_ifp;
  7967. +   ic = ifp->if_l2com;
  7968. +   vap = ni->ni_vap;
  7969. +   rni = (struct rt2860_softc_node *) ni;
  7970. +   tp = ni->ni_txparms;
  7971. +
  7972. +   ring = &sc->tx_ring[qid];
  7973. +   desc = &ring->desc[ring->desc_cur];
  7974. +   data = &ring->data[ring->data_cur];
  7975. +   txwi = (struct rt2860_txwi *) (ring->seg0 + ring->data_cur * RT2860_TX_DATA_SEG0_SIZE);
  7976. +
  7977. +   wh = mtod(m, struct ieee80211_frame *);
  7978. +
  7979. +   type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
  7980. +
  7981. +   hasqos = IEEE80211_QOS_HAS_SEQ(wh);
  7982. +   if (hasqos)
  7983. +   {
  7984. +       if (IEEE80211_HAS_ADDR4(wh))
  7985. +           qos = le16toh(*(const uint16_t *)
  7986. +               (((struct ieee80211_qosframe_addr4 *) wh)->i_qos));
  7987. +       else
  7988. +           qos = le16toh(*(const uint16_t *)
  7989. +               (((struct ieee80211_qosframe *) wh)->i_qos));
  7990. +   }
  7991. +   else
  7992. +   {
  7993. +       qos = 0;
  7994. +   }
  7995. +
  7996. +   if (IEEE80211_IS_MULTICAST(wh->i_addr1))
  7997. +       rate = tp->mcastrate;
  7998. +   else if (m->m_flags & M_EAPOL)
  7999. +       rate = tp->mgmtrate;
  8000. +   else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
  8001. +       rate = tp->ucastrate;
  8002. +   else
  8003. +       rate = ni->ni_txrate;
  8004. +
  8005. +   rate &= IEEE80211_RATE_VAL;
  8006. +/* XXX */
  8007. +   if (!rate)
  8008. +       return EFBIG;
  8009. +
  8010. +   /* fill Tx wireless info */
  8011. +
  8012. +   if (ni->ni_flags & IEEE80211_NODE_HT)
  8013. +       mcs = rate;
  8014. +   else
  8015. +       mcs = rt2860_rate2mcs(rate);
  8016. +
  8017. +   if (type == IEEE80211_FC0_TYPE_DATA)
  8018. +       wcid = !IEEE80211_IS_MULTICAST(wh->i_addr1) ? rni->staid : RT2860_WCID_MCAST;
  8019. +   else
  8020. +       wcid = RT2860_WCID_RESERVED;
  8021. +
  8022. +   /* calculate MPDU length without padding */
  8023. +
  8024. +   hdrsize = ieee80211_anyhdrsize(wh);
  8025. +   hdrspace = ieee80211_anyhdrspace(ic, wh);
  8026. +   mpdu_len = m->m_pkthdr.len - hdrspace + hdrsize;
  8027. +
  8028. +   memset(txwi, 0, sizeof(struct rt2860_txwi));
  8029. +
  8030. +   txwi->wcid = wcid;
  8031. +
  8032. +   /* MIMO power save */
  8033. +
  8034. +   if ((ni->ni_flags & IEEE80211_NODE_HT) && (ni->ni_flags & IEEE80211_NODE_MIMO_PS))
  8035. +   {
  8036. +       if (mcs > 7)
  8037. +       {
  8038. +           if (ni->ni_flags & IEEE80211_NODE_MIMO_RTS)
  8039. +           {
  8040. +               /* dynamic MIMO power save */
  8041. +
  8042. +               txwi->mpdu_density_flags |=
  8043. +                   (RT2860_TXWI_FLAGS_MIMOPS << RT2860_TXWI_FLAGS_SHIFT);
  8044. +           }
  8045. +           else
  8046. +           {
  8047. +               /* static MIMO power save */
  8048. +
  8049. +               mcs = 7;
  8050. +           }
  8051. +       }
  8052. +
  8053. +       mimops = 1;
  8054. +   }
  8055. +   else
  8056. +   {
  8057. +       mimops = 0;
  8058. +   }
  8059. +
  8060. +   pid = (mcs < 0xf) ? (mcs + 1) : mcs;
  8061. +
  8062. +   txwi->pid_mpdu_len = ((htole16(pid) & RT2860_TXWI_PID_MASK) <<
  8063. +       RT2860_TXWI_PID_SHIFT) | ((htole16(mpdu_len) & RT2860_TXWI_MPDU_LEN_MASK) <<
  8064. +           RT2860_TXWI_MPDU_LEN_SHIFT);
  8065. +
  8066. +   stbc = sc->tx_stbc && (mcs <= 7) && (vap->iv_htcaps & IEEE80211_HTCAP_TXSTBC) &&
  8067. +       (ni->ni_flags & IEEE80211_NODE_HT) && (ni->ni_htcap & IEEE80211_HTCAP_RXSTBC);
  8068. +
  8069. +   shortgi = ((vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20) && (ni->ni_flags & IEEE80211_NODE_SGI20) && (ni->ni_chw == 20)) ||
  8070. +       ((vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40) && (ni->ni_flags & IEEE80211_NODE_SGI40) && (ni->ni_chw == 40));
  8071. +
  8072. +   txwi->phymode_ifs_stbc_shortgi |=
  8073. +       ((stbc & RT2860_TXWI_STBC_MASK) << RT2860_TXWI_STBC_SHIFT) |
  8074. +       ((shortgi & RT2860_TXWI_SHORTGI_MASK) << RT2860_TXWI_SHORTGI_SHIFT);
  8075. +
  8076. +   if (ni->ni_flags & IEEE80211_NODE_HT)
  8077. +   {
  8078. +       txwi->phymode_ifs_stbc_shortgi |=
  8079. +           (RT2860_TXWI_PHYMODE_HT_MIXED << RT2860_TXWI_PHYMODE_SHIFT);
  8080. +   }
  8081. +   else
  8082. +   {
  8083. +       if (ieee80211_rate2phytype(ic->ic_rt, rate) != IEEE80211_T_OFDM)
  8084. +       {
  8085. +           txwi->phymode_ifs_stbc_shortgi |=
  8086. +               (RT2860_TXWI_PHYMODE_CCK << RT2860_TXWI_PHYMODE_SHIFT);
  8087. +
  8088. +           if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
  8089. +               mcs |= RT2860_TXWI_MCS_SHOTPRE;
  8090. +       }
  8091. +       else
  8092. +       {
  8093. +           txwi->phymode_ifs_stbc_shortgi |=
  8094. +               (RT2860_TXWI_PHYMODE_OFDM << RT2860_TXWI_PHYMODE_SHIFT);
  8095. +       }
  8096. +   }
  8097. +
  8098. +   if ((ni->ni_flags & IEEE80211_NODE_HT) && (ni->ni_chw == 40))
  8099. +       bw = RT2860_TXWI_BW_40;
  8100. +   else
  8101. +       bw = RT2860_TXWI_BW_20;
  8102. +
  8103. +   txwi->bw_mcs = ((bw & RT2860_TXWI_BW_MASK) << RT2860_TXWI_BW_SHIFT) |
  8104. +       ((mcs & RT2860_TXWI_MCS_MASK) << RT2860_TXWI_MCS_SHIFT);
  8105. +
  8106. +   txwi->txop = (RT2860_TXWI_TXOP_HT << RT2860_TXWI_TXOP_SHIFT);
  8107. +
  8108. +   if (!IEEE80211_IS_MULTICAST(wh->i_addr1) &&
  8109. +       (!hasqos || (qos & IEEE80211_QOS_ACKPOLICY) != IEEE80211_QOS_ACKPOLICY_NOACK))
  8110. +   {
  8111. +       txwi->bawin_size_xflags |=
  8112. +           (RT2860_TXWI_XFLAGS_ACK << RT2860_TXWI_XFLAGS_SHIFT);
  8113. +
  8114. +       if (ni->ni_flags & IEEE80211_NODE_HT)
  8115. +       {
  8116. +           /* preamble + plcp + signal extension + SIFS */
  8117. +
  8118. +           dur = 16 + 4 + 6 + 10;
  8119. +       }
  8120. +       else
  8121. +       {
  8122. +           dur = ieee80211_ack_duration(ic->ic_rt, rate,
  8123. +               ic->ic_flags & IEEE80211_F_SHPREAMBLE);
  8124. +       }
  8125. +
  8126. +       *(uint16_t *) wh->i_dur = htole16(dur);
  8127. +   }
  8128. +
  8129. +   /* check for A-MPDU */
  8130. +
  8131. +   if (m->m_flags & M_AMPDU_MPDU)
  8132. +   {
  8133. +       ac = M_WME_GETAC(m);
  8134. +       tid = WME_AC_TO_TID(ac);
  8135. +       tx_ampdu = &ni->ni_tx_ampdu[ac];
  8136. +
  8137. +       mpdu_density = RT2860_MS(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY);
  8138. +       bawin_size = tx_ampdu->txa_wnd;
  8139. +
  8140. +       txwi->mpdu_density_flags |=
  8141. +           ((mpdu_density & RT2860_TXWI_MPDU_DENSITY_MASK) << RT2860_TXWI_MPDU_DENSITY_SHIFT) |
  8142. +           (RT2860_TXWI_FLAGS_AMPDU << RT2860_TXWI_FLAGS_SHIFT);
  8143. +
  8144. +       txwi->bawin_size_xflags |=
  8145. +           ((bawin_size & RT2860_TXWI_BAWIN_SIZE_MASK) << RT2860_TXWI_BAWIN_SIZE_SHIFT);
  8146. +
  8147. +       seqno = ni->ni_txseqs[tid]++;
  8148. +
  8149. +       *(uint16_t *) &wh->i_seq[0] = htole16(seqno << IEEE80211_SEQ_SEQ_SHIFT);
  8150. +
  8151. +       ampdu = 1;
  8152. +   }
  8153. +   else
  8154. +   {
  8155. +       mpdu_density = 0;
  8156. +       bawin_size = 0;
  8157. +       ampdu = 0;
  8158. +   }
  8159. +
  8160. +   /* ask MAC to insert timestamp into probe responses */
  8161. +
  8162. +   if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) ==
  8163. +       (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP))
  8164. +       txwi->mpdu_density_flags |=
  8165. +           (RT2860_TXWI_FLAGS_TS << RT2860_TXWI_FLAGS_SHIFT);
  8166. +
  8167. +   if (ieee80211_radiotap_active_vap(vap))
  8168. +   {
  8169. +       tap = &sc->txtap;
  8170. +
  8171. +       tap->flags = IEEE80211_RADIOTAP_F_DATAPAD;
  8172. +       tap->chan_flags = htole32(ic->ic_curchan->ic_flags);
  8173. +       tap->chan_freq = htole16(ic->ic_curchan->ic_freq);
  8174. +       tap->chan_ieee = ic->ic_curchan->ic_ieee;
  8175. +       tap->chan_maxpow = 0;
  8176. +
  8177. +       if (ni->ni_flags & IEEE80211_NODE_HT)
  8178. +           tap->rate = mcs | IEEE80211_RATE_MCS;
  8179. +       else
  8180. +           tap->rate = rate;
  8181. +
  8182. +       if (mcs & RT2860_TXWI_MCS_SHOTPRE)
  8183. +           tap->flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
  8184. +
  8185. +       if (shortgi)
  8186. +           tap->flags |= IEEE80211_RADIOTAP_F_SHORTGI;
  8187. +
  8188. +       if (wh->i_fc[1] & IEEE80211_FC1_WEP)
  8189. +           tap->flags |= IEEE80211_RADIOTAP_F_WEP;
  8190. +
  8191. +       /* XXX use temporarily radiotap CFP flag as A-MPDU flag */
  8192. +
  8193. +       if (ampdu)
  8194. +           tap->flags |= IEEE80211_RADIOTAP_F_CFP;
  8195. +
  8196. +       if (wh->i_fc[1] & IEEE80211_FC1_WEP)
  8197. +       {
  8198. +           wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
  8199. +
  8200. +           ieee80211_radiotap_tx(vap, m);
  8201. +
  8202. +           wh->i_fc[1] |= IEEE80211_FC1_WEP;
  8203. +       }
  8204. +       else
  8205. +       {
  8206. +           ieee80211_radiotap_tx(vap, m);
  8207. +       }
  8208. +   }
  8209. +
  8210. +   /* copy and trim 802.11 header */
  8211. +
  8212. +   m_copydata(m, 0, hdrsize, (caddr_t) (txwi + 1));
  8213. +   m_adj(m, hdrspace);
  8214. +
  8215. +   error = bus_dmamap_load_mbuf_sg(ring->data_dma_tag, data->dma_map, m,
  8216. +       dma_seg, &ndmasegs, BUS_DMA_NOWAIT);
  8217. +   if (error != 0)
  8218. +   {
  8219. +       /* too many fragments, linearize */
  8220. +
  8221. +       RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  8222. +           "%s: could not load mbuf DMA map, trying to linearize mbuf: ndmasegs=%d, len=%d, error=%d\n",
  8223. +           device_get_nameunit(sc->sc_dev), ndmasegs, m->m_pkthdr.len, error);
  8224. +
  8225. +       m = m_defrag(m, M_DONTWAIT);
  8226. +       if (m == NULL)
  8227. +           return ENOMEM;
  8228. +
  8229. +       sc->tx_defrag_packets++;
  8230. +
  8231. +       error = bus_dmamap_load_mbuf_sg(ring->data_dma_tag, data->dma_map, m,
  8232. +           dma_seg, &ndmasegs, BUS_DMA_NOWAIT);
  8233. +       if (error != 0)
  8234. +       {
  8235. +           printf("%s: could not load mbuf DMA map: ndmasegs=%d, len=%d, error=%d\n",
  8236. +               device_get_nameunit(sc->sc_dev), ndmasegs, m->m_pkthdr.len, error);
  8237. +           m_freem(m);
  8238. +           return error;
  8239. +       }
  8240. +   }
  8241. +
  8242. +   if (m->m_pkthdr.len == 0)
  8243. +       ndmasegs = 0;
  8244. +
  8245. +   /* determine how many Tx descs are required */
  8246. +
  8247. +   ndescs = 1 + ndmasegs / 2;
  8248. +   if ((ring->desc_queued + ndescs) > (RT2860_SOFTC_TX_RING_DESC_COUNT - 2))
  8249. +   {
  8250. +       RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  8251. +           "%s: there are not enough Tx descs\n",
  8252. +           device_get_nameunit(sc->sc_dev));
  8253. +
  8254. +       sc->no_tx_desc_avail++;
  8255. +
  8256. +       bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
  8257. +       m_freem(m);
  8258. +       return EFBIG;
  8259. +   }
  8260. +
  8261. +   data->m = m;
  8262. +   data->ni = ni;
  8263. +
  8264. +   /* set up Tx descs */
  8265. +
  8266. +   /* first segment is Tx wireless info and 802.11 header */
  8267. +
  8268. +   len = sizeof(struct rt2860_txwi) + hdrsize;
  8269. +
  8270. +   /* align end on a 4-bytes boundary */
  8271. +
  8272. +   dmalen = (len + 3) & ~ 3;
  8273. +
  8274. +   memset((caddr_t) txwi + len, 0, dmalen - len);
  8275. +
  8276. +   qsel = RT2860_TXDESC_QSEL_EDCA;
  8277. +
  8278. +   desc->sdp0 = htole32(ring->seg0_phys_addr + ring->data_cur * RT2860_TX_DATA_SEG0_SIZE);
  8279. +   desc->sdl0 = htole16(dmalen);
  8280. +   desc->qsel_flags = (qsel << RT2860_TXDESC_QSEL_SHIFT);
  8281. +
  8282. +   /* set up payload segments */
  8283. +
  8284. +   for (i = ndmasegs, j = 0; i >= 2; i -= 2)
  8285. +   {
  8286. +       desc->sdp1 = htole32(dma_seg[j].ds_addr);
  8287. +       desc->sdl1 = htole16(dma_seg[j].ds_len);
  8288. +
  8289. +       ring->desc_queued++;
  8290. +       ring->desc_cur = (ring->desc_cur + 1) % RT2860_SOFTC_TX_RING_DESC_COUNT;
  8291. +
  8292. +       j++;
  8293. +
  8294. +       desc = &ring->desc[ring->desc_cur];
  8295. +
  8296. +       desc->sdp0 = htole32(dma_seg[j].ds_addr);
  8297. +       desc->sdl0 = htole16(dma_seg[j].ds_len);
  8298. +       desc->qsel_flags = (qsel << RT2860_TXDESC_QSEL_SHIFT);
  8299. +
  8300. +       j++;
  8301. +   }
  8302. +
  8303. +   /* finalize last payload segment */
  8304. +
  8305. +   if (i > 0)
  8306. +   {
  8307. +       desc->sdp1 = htole32(dma_seg[j].ds_addr);
  8308. +       desc->sdl1 = htole16(dma_seg[j].ds_len | RT2860_TXDESC_SDL1_LASTSEG);
  8309. +   }
  8310. +   else
  8311. +   {
  8312. +       desc->sdl0 |= htole16(RT2860_TXDESC_SDL0_LASTSEG);
  8313. +       desc->sdl1 = 0;
  8314. +   }
  8315. +
  8316. +   RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  8317. +       "%s: sending data: qid=%d, hdrsize=%d, hdrspace=%d, len=%d, "
  8318. +       "bw=%d, stbc=%d, shortgi=%d, mcs=%d, wcid=0x%02x, "
  8319. +       "ampdu=%d (density=%d, winsize=%d), mimops=%d, DMA len=%d, ndmasegs=%d, DMA ds_len=%d/%d/%d/%d/%d\n",
  8320. +       device_get_nameunit(sc->sc_dev),
  8321. +       qid, hdrsize, hdrspace, m->m_pkthdr.len + hdrsize,
  8322. +       bw, stbc, shortgi, mcs, wcid, ampdu, mpdu_density, bawin_size, mimops, dmalen, ndmasegs,
  8323. +       (int) dma_seg[0].ds_len, (int) dma_seg[1].ds_len, (int) dma_seg[2].ds_len, (int) dma_seg[3].ds_len, (int) dma_seg[4].ds_len);
  8324. +
  8325. +   bus_dmamap_sync(ring->seg0_dma_tag, ring->seg0_dma_map,
  8326. +       BUS_DMASYNC_PREWRITE);
  8327. +   bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  8328. +       BUS_DMASYNC_PREWRITE);
  8329. +   bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  8330. +       BUS_DMASYNC_PREWRITE);
  8331. +
  8332. +   ring->desc_queued++;
  8333. +   ring->desc_cur = (ring->desc_cur + 1) % RT2860_SOFTC_TX_RING_DESC_COUNT;
  8334. +
  8335. +   ring->data_queued++;
  8336. +   ring->data_cur = (ring->data_cur + 1) % RT2860_SOFTC_TX_RING_DATA_COUNT;
  8337. +
  8338. +   /* kick Tx */
  8339. +
  8340. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_CTX_IDX(qid), ring->desc_cur);
  8341. +
  8342. +   return 0;
  8343. +}
  8344. +
  8345. +/*
  8346. + * rt2860_tx_raw
  8347. +static int rt2860_tx_raw(struct rt2860_softc *sc,
  8348. +   struct mbuf *m, struct ieee80211_node *ni,
  8349. +   const struct ieee80211_bpf_params *params)
  8350. +{
  8351. +   RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  8352. +       "%s: Tx raw\n",
  8353. +       device_get_nameunit(sc->sc_dev));
  8354. +
  8355. +   return 0;
  8356. +}
  8357. + */
  8358. +
  8359. +/*
  8360. + * rt2860_intr
  8361. + */
  8362. +void rt2860_intr(void *arg)
  8363. +{
  8364. +   struct rt2860_softc *sc;
  8365. +   struct ifnet *ifp;
  8366. +   uint32_t status;
  8367. +
  8368. +   sc = arg;
  8369. +   ifp = sc->sc_ifp;
  8370. +
  8371. +   /* acknowledge interrupts */
  8372. +
  8373. +   status = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_INT_STATUS);
  8374. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_STATUS, status);
  8375. +
  8376. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8377. +       "%s: interrupt: status = 0x%08x\n",
  8378. +       device_get_nameunit(sc->sc_dev), status);
  8379. +
  8380. +   if (status == 0xffffffff ||     /* device likely went away */
  8381. +       status == 0)                /* not for us */
  8382. +       return;
  8383. +
  8384. +   sc->interrupts++;
  8385. +
  8386. +   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
  8387. +       return;
  8388. +
  8389. +   if (status & RT2860_REG_INT_TX_COHERENT)
  8390. +       rt2860_tx_coherent_intr(sc);
  8391. +
  8392. +   if (status & RT2860_REG_INT_RX_COHERENT)
  8393. +       rt2860_rx_coherent_intr(sc);
  8394. +
  8395. +   if (status & RT2860_REG_INT_TXRX_COHERENT)
  8396. +       rt2860_txrx_coherent_intr(sc);
  8397. +
  8398. +   if (status & RT2860_REG_INT_FIFO_STA_FULL)
  8399. +       rt2860_fifo_sta_full_intr(sc);
  8400. +
  8401. +   if (status & RT2860_REG_INT_TX_MGMT_DONE)
  8402. +       rt2860_tx_intr(sc, 5);
  8403. +
  8404. +   if (status & RT2860_REG_INT_RX_DONE)
  8405. +       rt2860_rx_intr(sc);
  8406. +
  8407. +   if (status & RT2860_REG_INT_RX_DELAY_DONE)
  8408. +       rt2860_rx_delay_intr(sc);
  8409. +
  8410. +   if (status & RT2860_REG_INT_TX_HCCA_DONE)
  8411. +       rt2860_tx_intr(sc, 4);
  8412. +
  8413. +   if (status & RT2860_REG_INT_TX_AC3_DONE)
  8414. +       rt2860_tx_intr(sc, 3);
  8415. +
  8416. +   if (status & RT2860_REG_INT_TX_AC2_DONE)
  8417. +       rt2860_tx_intr(sc, 2);
  8418. +
  8419. +   if (status & RT2860_REG_INT_TX_AC1_DONE)
  8420. +       rt2860_tx_intr(sc, 1);
  8421. +
  8422. +   if (status & RT2860_REG_INT_TX_AC0_DONE)
  8423. +       rt2860_tx_intr(sc, 0);
  8424. +
  8425. +   if (status & RT2860_REG_INT_TX_DELAY_DONE)
  8426. +       rt2860_tx_delay_intr(sc);
  8427. +
  8428. +   if (status & RT2860_REG_INT_PRE_TBTT)
  8429. +       rt2860_pre_tbtt_intr(sc);
  8430. +
  8431. +   if (status & RT2860_REG_INT_TBTT)
  8432. +       rt2860_tbtt_intr(sc);
  8433. +
  8434. +   if (status & RT2860_REG_INT_MCU_CMD)
  8435. +       rt2860_mcu_cmd_intr(sc);
  8436. +
  8437. +   if (status & RT2860_REG_INT_AUTO_WAKEUP)
  8438. +       rt2860_auto_wakeup_intr(sc);
  8439. +
  8440. +   if (status & RT2860_REG_INT_GP_TIMER)
  8441. +       rt2860_gp_timer_intr(sc);
  8442. +}
  8443. +
  8444. +/*
  8445. + * rt2860_tx_coherent_intr
  8446. + */
  8447. +static void rt2860_tx_coherent_intr(struct rt2860_softc *sc)
  8448. +{
  8449. +   uint32_t tmp;
  8450. +   int i;
  8451. +
  8452. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8453. +       "%s: Tx coherent interrupt\n",
  8454. +       device_get_nameunit(sc->sc_dev));
  8455. +
  8456. +   sc->tx_coherent_interrupts++;
  8457. +
  8458. +   /* restart DMA engine */
  8459. +
  8460. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG);
  8461. +
  8462. +   tmp &= ~(RT2860_REG_TX_WB_DDONE |
  8463. +       RT2860_REG_RX_DMA_ENABLE |
  8464. +       RT2860_REG_TX_DMA_ENABLE);
  8465. +
  8466. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG, tmp);
  8467. +
  8468. +   /* init Tx rings (4 EDCAs + HCCA + MGMT) */
  8469. +
  8470. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  8471. +       rt2860_reset_tx_ring(sc, &sc->tx_ring[i]);
  8472. +
  8473. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  8474. +   {
  8475. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_BASE_PTR(i),
  8476. +           sc->tx_ring[i].desc_phys_addr);
  8477. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_MAX_CNT(i),
  8478. +           RT2860_SOFTC_TX_RING_DESC_COUNT);
  8479. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_CTX_IDX(i), 0);
  8480. +   }
  8481. +
  8482. +   /* init Rx ring */
  8483. +
  8484. +   rt2860_reset_rx_ring(sc, &sc->rx_ring);
  8485. +
  8486. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_BASE_PTR,
  8487. +       sc->rx_ring.desc_phys_addr);
  8488. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_MAX_CNT,
  8489. +       RT2860_SOFTC_RX_RING_DATA_COUNT);
  8490. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_CALC_IDX,
  8491. +       RT2860_SOFTC_RX_RING_DATA_COUNT - 1);
  8492. +
  8493. +   rt2860_txrx_enable(sc);
  8494. +}
  8495. +
  8496. +/*
  8497. + * rt2860_rx_coherent_intr
  8498. + */
  8499. +static void rt2860_rx_coherent_intr(struct rt2860_softc *sc)
  8500. +{
  8501. +   uint32_t tmp;
  8502. +   int i;
  8503. +
  8504. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8505. +       "%s: Rx coherent interrupt\n",
  8506. +       device_get_nameunit(sc->sc_dev));
  8507. +
  8508. +   sc->rx_coherent_interrupts++;
  8509. +
  8510. +   /* restart DMA engine */
  8511. +
  8512. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG);
  8513. +
  8514. +   tmp &= ~(RT2860_REG_TX_WB_DDONE |
  8515. +       RT2860_REG_RX_DMA_ENABLE |
  8516. +       RT2860_REG_TX_DMA_ENABLE);
  8517. +
  8518. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG, tmp);
  8519. +
  8520. +   /* init Tx rings (4 EDCAs + HCCA + MGMT) */
  8521. +
  8522. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  8523. +       rt2860_reset_tx_ring(sc, &sc->tx_ring[i]);
  8524. +
  8525. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  8526. +   {
  8527. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_BASE_PTR(i),
  8528. +           sc->tx_ring[i].desc_phys_addr);
  8529. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_MAX_CNT(i),
  8530. +           RT2860_SOFTC_TX_RING_DESC_COUNT);
  8531. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_CTX_IDX(i), 0);
  8532. +   }
  8533. +
  8534. +   /* init Rx ring */
  8535. +
  8536. +   rt2860_reset_rx_ring(sc, &sc->rx_ring);
  8537. +
  8538. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_BASE_PTR,
  8539. +       sc->rx_ring.desc_phys_addr);
  8540. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_MAX_CNT,
  8541. +       RT2860_SOFTC_RX_RING_DATA_COUNT);
  8542. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_CALC_IDX,
  8543. +       RT2860_SOFTC_RX_RING_DATA_COUNT - 1);
  8544. +
  8545. +   rt2860_txrx_enable(sc);
  8546. +}
  8547. +
  8548. +/*
  8549. + * rt2860_txrx_coherent_intr
  8550. + */
  8551. +static void rt2860_txrx_coherent_intr(struct rt2860_softc *sc)
  8552. +{
  8553. +   uint32_t tmp;
  8554. +   int i;
  8555. +
  8556. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8557. +       "%s: Tx/Rx coherent interrupt\n",
  8558. +       device_get_nameunit(sc->sc_dev));
  8559. +
  8560. +   sc->txrx_coherent_interrupts++;
  8561. +
  8562. +   /* restart DMA engine */
  8563. +
  8564. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG);
  8565. +
  8566. +   tmp &= ~(RT2860_REG_TX_WB_DDONE |
  8567. +       RT2860_REG_RX_DMA_ENABLE |
  8568. +       RT2860_REG_TX_DMA_ENABLE);
  8569. +
  8570. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG, tmp);
  8571. +
  8572. +   /* init Tx rings (4 EDCAs + HCCA + MGMT) */
  8573. +
  8574. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  8575. +       rt2860_reset_tx_ring(sc, &sc->tx_ring[i]);
  8576. +
  8577. +   for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
  8578. +   {
  8579. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_BASE_PTR(i),
  8580. +           sc->tx_ring[i].desc_phys_addr);
  8581. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_MAX_CNT(i),
  8582. +           RT2860_SOFTC_TX_RING_DESC_COUNT);
  8583. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_TX_CTX_IDX(i), 0);
  8584. +   }
  8585. +
  8586. +   /* init Rx ring */
  8587. +
  8588. +   rt2860_reset_rx_ring(sc, &sc->rx_ring);
  8589. +
  8590. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_BASE_PTR,
  8591. +       sc->rx_ring.desc_phys_addr);
  8592. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_MAX_CNT,
  8593. +       RT2860_SOFTC_RX_RING_DATA_COUNT);
  8594. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_CALC_IDX,
  8595. +       RT2860_SOFTC_RX_RING_DATA_COUNT - 1);
  8596. +
  8597. +   rt2860_txrx_enable(sc);
  8598. +}
  8599. +
  8600. +/*
  8601. + * rt2860_fifo_sta_full_intr
  8602. + */
  8603. +static void rt2860_fifo_sta_full_intr(struct rt2860_softc *sc)
  8604. +{
  8605. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8606. +       "%s: FIFO statistic full interrupt\n",
  8607. +       device_get_nameunit(sc->sc_dev));
  8608. +
  8609. +   sc->fifo_sta_full_interrupts++;
  8610. +
  8611. +   RT2860_SOFTC_LOCK(sc);
  8612. +
  8613. +   if (!(sc->intr_disable_mask & RT2860_REG_INT_FIFO_STA_FULL))
  8614. +   {
  8615. +       rt2860_intr_disable(sc, RT2860_REG_INT_FIFO_STA_FULL);
  8616. +
  8617. +       taskqueue_enqueue(sc->taskqueue, &sc->fifo_sta_full_task);
  8618. +   }
  8619. +
  8620. +   sc->intr_pending_mask |= RT2860_REG_INT_FIFO_STA_FULL;
  8621. +
  8622. +   RT2860_SOFTC_UNLOCK(sc);
  8623. +}
  8624. +
  8625. +/*
  8626. + * rt2860_rx_intr
  8627. + */
  8628. +static void rt2860_rx_intr(struct rt2860_softc *sc)
  8629. +{
  8630. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8631. +       "%s: Rx interrupt\n",
  8632. +       device_get_nameunit(sc->sc_dev));
  8633. +
  8634. +   sc->rx_interrupts++;
  8635. +
  8636. +   RT2860_SOFTC_LOCK(sc);
  8637. +
  8638. +   if (!(sc->intr_disable_mask & RT2860_REG_INT_RX_DONE))
  8639. +   {
  8640. +       rt2860_intr_disable(sc, RT2860_REG_INT_RX_DONE);
  8641. +
  8642. +       taskqueue_enqueue(sc->taskqueue, &sc->rx_done_task);
  8643. +   }
  8644. +
  8645. +   sc->intr_pending_mask |= RT2860_REG_INT_RX_DONE;
  8646. +
  8647. +   RT2860_SOFTC_UNLOCK(sc);
  8648. +}
  8649. +
  8650. +/*
  8651. + * rt2860_rx_delay_intr
  8652. + */
  8653. +static void rt2860_rx_delay_intr(struct rt2860_softc *sc)
  8654. +{
  8655. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8656. +       "%s: Rx delay interrupt\n",
  8657. +       device_get_nameunit(sc->sc_dev));
  8658. +
  8659. +   sc->rx_delay_interrupts++;
  8660. +}
  8661. +
  8662. +/*
  8663. + * rt2860_tx_intr
  8664. + */
  8665. +static void rt2860_tx_intr(struct rt2860_softc *sc, int qid)
  8666. +{
  8667. +   KASSERT(qid >= 0 && qid < RT2860_SOFTC_TX_RING_COUNT,
  8668. +       ("%s: Tx interrupt: invalid qid=%d\n",
  8669. +        device_get_nameunit(sc->sc_dev), qid));
  8670. +
  8671. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8672. +       "%s: Tx interrupt: qid=%d\n",
  8673. +       device_get_nameunit(sc->sc_dev), qid);
  8674. +
  8675. +   sc->tx_interrupts[qid]++;
  8676. +
  8677. +   RT2860_SOFTC_LOCK(sc);
  8678. +
  8679. +   if (!(sc->intr_disable_mask & (RT2860_REG_INT_TX_AC0_DONE << qid)))
  8680. +   {
  8681. +       rt2860_intr_disable(sc, (RT2860_REG_INT_TX_AC0_DONE << qid));
  8682. +
  8683. +       taskqueue_enqueue(sc->taskqueue, &sc->tx_done_task);
  8684. +   }
  8685. +
  8686. +   sc->intr_pending_mask |= (RT2860_REG_INT_TX_AC0_DONE << qid);
  8687. +
  8688. +   RT2860_SOFTC_UNLOCK(sc);
  8689. +}
  8690. +
  8691. +/*
  8692. + * rt2860_tx_delay_intr
  8693. + */
  8694. +static void rt2860_tx_delay_intr(struct rt2860_softc *sc)
  8695. +{
  8696. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8697. +       "%s: Tx delay interrupt\n",
  8698. +       device_get_nameunit(sc->sc_dev));
  8699. +
  8700. +   sc->tx_delay_interrupts++;
  8701. +}
  8702. +
  8703. +/*
  8704. + * rt2860_pre_tbtt_intr
  8705. + */
  8706. +static void rt2860_pre_tbtt_intr(struct rt2860_softc *sc)
  8707. +{
  8708. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8709. +       "%s: Pre-TBTT interrupt\n",
  8710. +       device_get_nameunit(sc->sc_dev));
  8711. +
  8712. +   sc->pre_tbtt_interrupts++;
  8713. +}
  8714. +
  8715. +/*
  8716. + * rt2860_tbtt_intr
  8717. + */
  8718. +static void rt2860_tbtt_intr(struct rt2860_softc *sc)
  8719. +{
  8720. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8721. +       "%s: TBTT interrupt\n",
  8722. +       device_get_nameunit(sc->sc_dev));
  8723. +
  8724. +   sc->tbtt_interrupts++;
  8725. +}
  8726. +
  8727. +/*
  8728. + * rt2860_mcu_cmd_intr
  8729. + */
  8730. +static void rt2860_mcu_cmd_intr(struct rt2860_softc *sc)
  8731. +{
  8732. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8733. +       "%s: MCU command interrupt\n",
  8734. +       device_get_nameunit(sc->sc_dev));
  8735. +
  8736. +   sc->mcu_cmd_interrupts++;
  8737. +}
  8738. +
  8739. +/*
  8740. + * rt2860_auto_wakeup_intr
  8741. + */
  8742. +static void rt2860_auto_wakeup_intr(struct rt2860_softc *sc)
  8743. +{
  8744. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8745. +       "%s: auto wakeup interrupt\n",
  8746. +       device_get_nameunit(sc->sc_dev));
  8747. +
  8748. +   sc->auto_wakeup_interrupts++;
  8749. +}
  8750. +
  8751. +/*
  8752. + * rt2860_gp_timer_intr
  8753. + */
  8754. +static void rt2860_gp_timer_intr(struct rt2860_softc *sc)
  8755. +{
  8756. +   RT2860_DPRINTF(sc, RT2860_DEBUG_INTR,
  8757. +       "%s: GP timer interrupt\n",
  8758. +       device_get_nameunit(sc->sc_dev));
  8759. +
  8760. +   sc->gp_timer_interrupts++;
  8761. +}
  8762. +
  8763. +/*
  8764. + * rt2860_rx_done_task
  8765. + */
  8766. +static void rt2860_rx_done_task(void *context, int pending)
  8767. +{
  8768. +   struct rt2860_softc *sc;
  8769. +   struct ifnet *ifp;
  8770. +   int again;
  8771. +
  8772. +   sc = context;
  8773. +   ifp = sc->sc_ifp;
  8774. +
  8775. +   RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  8776. +       "%s: Rx done task\n",
  8777. +       device_get_nameunit(sc->sc_dev));
  8778. +
  8779. +   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
  8780. +       return;
  8781. +
  8782. +   sc->intr_pending_mask &= ~RT2860_REG_INT_RX_DONE;
  8783. +
  8784. +   again = rt2860_rx_eof(sc, sc->rx_process_limit);
  8785. +
  8786. +   RT2860_SOFTC_LOCK(sc);
  8787. +
  8788. +   if ((sc->intr_pending_mask & RT2860_REG_INT_RX_DONE) || again)
  8789. +   {
  8790. +       RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  8791. +           "%s: Rx done task: scheduling again\n",
  8792. +           device_get_nameunit(sc->sc_dev));
  8793. +
  8794. +       taskqueue_enqueue(sc->taskqueue, &sc->rx_done_task);
  8795. +   }
  8796. +   else
  8797. +   {
  8798. +       rt2860_intr_enable(sc, RT2860_REG_INT_RX_DONE);
  8799. +   }
  8800. +
  8801. +   RT2860_SOFTC_UNLOCK(sc);
  8802. +}
  8803. +
  8804. +/*
  8805. + * rt2860_tx_done_task
  8806. + */
  8807. +static void rt2860_tx_done_task(void *context, int pending)
  8808. +{
  8809. +   struct rt2860_softc *sc;
  8810. +   struct ifnet *ifp;
  8811. +   uint32_t intr_mask;
  8812. +   int i;
  8813. +
  8814. +   sc = context;
  8815. +   ifp = sc->sc_ifp;
  8816. +
  8817. +   RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  8818. +       "%s: Tx done task\n",
  8819. +       device_get_nameunit(sc->sc_dev));
  8820. +
  8821. +   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
  8822. +       return;
  8823. +
  8824. +   for (i = RT2860_SOFTC_TX_RING_COUNT - 1; i >= 0; i--)
  8825. +   {
  8826. +       if (sc->intr_pending_mask & (RT2860_REG_INT_TX_AC0_DONE << i))
  8827. +       {
  8828. +           sc->intr_pending_mask &= ~(RT2860_REG_INT_TX_AC0_DONE << i);
  8829. +
  8830. +           rt2860_tx_eof(sc, &sc->tx_ring[i]);
  8831. +       }
  8832. +   }
  8833. +
  8834. +   sc->sc_tx_timer = 0;
  8835. +
  8836. +   ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  8837. +
  8838. +   intr_mask = (RT2860_REG_INT_TX_MGMT_DONE |
  8839. +       RT2860_REG_INT_TX_HCCA_DONE |
  8840. +       RT2860_REG_INT_TX_AC3_DONE |
  8841. +       RT2860_REG_INT_TX_AC2_DONE |
  8842. +       RT2860_REG_INT_TX_AC1_DONE |
  8843. +       RT2860_REG_INT_TX_AC0_DONE);
  8844. +
  8845. +   RT2860_SOFTC_LOCK(sc);
  8846. +
  8847. +   rt2860_intr_enable(sc, ~sc->intr_pending_mask &
  8848. +       (sc->intr_disable_mask & intr_mask));
  8849. +
  8850. +   if (sc->intr_pending_mask & intr_mask)
  8851. +   {
  8852. +       RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  8853. +           "%s: Tx done task: scheduling again\n",
  8854. +           device_get_nameunit(sc->sc_dev));
  8855. +
  8856. +       taskqueue_enqueue(sc->taskqueue, &sc->tx_done_task);
  8857. +   }
  8858. +
  8859. +   RT2860_SOFTC_UNLOCK(sc);
  8860. +
  8861. +   if (!IFQ_IS_EMPTY(&ifp->if_snd))
  8862. +       rt2860_start(ifp);
  8863. +}
  8864. +
  8865. +/*
  8866. + * rt2860_fifo_sta_full_task
  8867. + */
  8868. +static void rt2860_fifo_sta_full_task(void *context, int pending)
  8869. +{
  8870. +   struct rt2860_softc *sc;
  8871. +   struct ifnet *ifp;
  8872. +
  8873. +   sc = context;
  8874. +   ifp = sc->sc_ifp;
  8875. +
  8876. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATS,
  8877. +       "%s: FIFO statistic full task\n",
  8878. +       device_get_nameunit(sc->sc_dev));
  8879. +
  8880. +   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
  8881. +       return;
  8882. +
  8883. +   sc->intr_pending_mask &= ~RT2860_REG_INT_FIFO_STA_FULL;
  8884. +
  8885. +   rt2860_drain_fifo_stats(sc);
  8886. +
  8887. +   RT2860_SOFTC_LOCK(sc);
  8888. +
  8889. +   if (sc->intr_pending_mask & RT2860_REG_INT_FIFO_STA_FULL)
  8890. +   {
  8891. +       RT2860_DPRINTF(sc, RT2860_DEBUG_STATS,
  8892. +           "%s: FIFO statistic full task: scheduling again\n",
  8893. +           device_get_nameunit(sc->sc_dev));
  8894. +
  8895. +       taskqueue_enqueue(sc->taskqueue, &sc->fifo_sta_full_task);
  8896. +   }
  8897. +   else
  8898. +   {
  8899. +       rt2860_intr_enable(sc, RT2860_REG_INT_FIFO_STA_FULL);
  8900. +   }
  8901. +
  8902. +   RT2860_SOFTC_UNLOCK(sc);
  8903. +
  8904. +   if (!IFQ_IS_EMPTY(&ifp->if_snd))
  8905. +       rt2860_start(ifp);
  8906. +}
  8907. +
  8908. +/*
  8909. + * rt2860_periodic_task
  8910. + */
  8911. +static void rt2860_periodic_task(void *context, int pending)
  8912. +{
  8913. +   struct rt2860_softc *sc;
  8914. +   struct ifnet *ifp;
  8915. +   struct ieee80211com *ic;
  8916. +   struct ieee80211vap *vap;
  8917. +
  8918. +   sc = context;
  8919. +   ifp = sc->sc_ifp;
  8920. +   ic = ifp->if_l2com;
  8921. +   vap = TAILQ_FIRST(&ic->ic_vaps);
  8922. +
  8923. +   RT2860_DPRINTF(sc, RT2860_DEBUG_PERIODIC,
  8924. +       "%s: periodic task: round=%lu\n",
  8925. +       device_get_nameunit(sc->sc_dev), sc->periodic_round);
  8926. +
  8927. +   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
  8928. +       return;
  8929. +
  8930. +   RT2860_SOFTC_LOCK(sc);
  8931. +
  8932. +   sc->periodic_round++;
  8933. +
  8934. +   rt2860_update_stats(sc);
  8935. +
  8936. +   if ((sc->periodic_round % 10) == 0)
  8937. +   {
  8938. +       rt2860_bbp_tuning(sc);
  8939. +
  8940. +       rt2860_update_raw_counters(sc);
  8941. +
  8942. +       rt2860_watchdog(sc);
  8943. +
  8944. +       if (vap != NULL && vap->iv_opmode != IEEE80211_M_MONITOR && vap->iv_state == IEEE80211_S_RUN)
  8945. +       {
  8946. +           if (vap->iv_opmode == IEEE80211_M_STA)
  8947. +               rt2860_amrr_update_iter_func(vap, vap->iv_bss);
  8948. +           else
  8949. +               ieee80211_iterate_nodes(&ic->ic_sta, rt2860_amrr_update_iter_func, vap);
  8950. +       }
  8951. +   }
  8952. +
  8953. +   RT2860_SOFTC_UNLOCK(sc);
  8954. +
  8955. +   callout_reset(&sc->periodic_ch, hz / 10, rt2860_periodic, sc);
  8956. +}
  8957. +
  8958. +/*
  8959. + * rt2860_rx_eof
  8960. + */
  8961. +static int rt2860_rx_eof(struct rt2860_softc *sc, int limit)
  8962. +{
  8963. +   struct ifnet *ifp;
  8964. +   struct ieee80211com *ic;
  8965. +   struct ieee80211_frame *wh;
  8966. +   struct ieee80211_node *ni;
  8967. +   struct rt2860_softc_node *rni;
  8968. +   struct rt2860_softc_rx_radiotap_header *tap;
  8969. +   struct rt2860_softc_rx_ring *ring;
  8970. +   struct rt2860_rxdesc *desc;
  8971. +   struct rt2860_softc_rx_data *data;
  8972. +   struct rt2860_rxwi *rxwi;
  8973. +   struct mbuf *m, *mnew;
  8974. +   bus_dma_segment_t segs[1];
  8975. +   bus_dmamap_t dma_map;
  8976. +   uint32_t index, desc_flags;
  8977. +   uint8_t cipher_err, rssi, ant, phymode, bw, shortgi, stbc, mcs, keyidx, tid, frag;
  8978. +   uint16_t seq;
  8979. +   int8_t rssi_dbm;
  8980. +   int error, nsegs, len, ampdu, amsdu, rssi_dbm_rel, nframes, i;
  8981. +  
  8982. +   ifp = sc->sc_ifp;
  8983. +   ic = ifp->if_l2com;
  8984. +   ring = &sc->rx_ring;
  8985. +
  8986. +   nframes = 0;
  8987. +
  8988. +   while (limit != 0)
  8989. +   {
  8990. +       index = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_RX_DRX_IDX);
  8991. +       if (ring->cur == index)
  8992. +           break;
  8993. +
  8994. +       desc = &ring->desc[ring->cur];
  8995. +       data = &ring->data[ring->cur];
  8996. +
  8997. +       bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  8998. +           BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
  8999. +#ifdef XXX_TESTED_AND_WORKED
  9000. +       if (!(desc->sdl0 & htole16(RT2860_RXDESC_SDL0_DDONE)))
  9001. +           break;
  9002. +#endif
  9003. +
  9004. +       nframes++;
  9005. +
  9006. +       mnew = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
  9007. +       if (mnew == NULL)
  9008. +       {
  9009. +           sc->rx_mbuf_alloc_errors++;
  9010. +           ifp->if_ierrors++;
  9011. +           goto skip;
  9012. +       }
  9013. +
  9014. +       mnew->m_len = mnew->m_pkthdr.len = MJUMPAGESIZE;
  9015. +
  9016. +       error = bus_dmamap_load_mbuf_sg(ring->data_dma_tag, ring->spare_dma_map,
  9017. +           mnew, segs, &nsegs, BUS_DMA_NOWAIT);
  9018. +       if (error != 0)
  9019. +       {
  9020. +           RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9021. +               "%s: could not load Rx mbuf DMA map: error=%d, nsegs=%d\n",
  9022. +               device_get_nameunit(sc->sc_dev), error, nsegs);
  9023. +
  9024. +           m_freem(mnew);
  9025. +
  9026. +           sc->rx_mbuf_dmamap_errors++;
  9027. +           ifp->if_ierrors++;
  9028. +
  9029. +           goto skip;
  9030. +       }
  9031. +
  9032. +       KASSERT(nsegs == 1, ("%s: too many DMA segments",
  9033. +           device_get_nameunit(sc->sc_dev)));
  9034. +
  9035. +       bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  9036. +           BUS_DMASYNC_POSTREAD);
  9037. +       bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
  9038. +
  9039. +       dma_map = data->dma_map;
  9040. +       data->dma_map = ring->spare_dma_map;
  9041. +       ring->spare_dma_map = dma_map;
  9042. +
  9043. +       bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  9044. +           BUS_DMASYNC_PREREAD);
  9045. +
  9046. +       m = data->m;
  9047. +
  9048. +       data->m = mnew;
  9049. +       desc->sdp0 = htole32(segs[0].ds_addr);
  9050. +
  9051. +       desc_flags = le32toh(desc->flags);
  9052. +
  9053. +       RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9054. +           "%s: Rx frame: rxdesc flags=0x%08x\n",
  9055. +           device_get_nameunit(sc->sc_dev), desc_flags);
  9056. +
  9057. +       /* get Rx wireless info */
  9058. +
  9059. +       rxwi = mtod(m, struct rt2860_rxwi *);
  9060. +       len = (le16toh(rxwi->tid_size) >> RT2860_RXWI_SIZE_SHIFT) &
  9061. +           RT2860_RXWI_SIZE_MASK;
  9062. +
  9063. +       /* check for L2 padding between IEEE 802.11 frame header and body */
  9064. +
  9065. +       if (desc_flags & RT2860_RXDESC_FLAGS_L2PAD)
  9066. +       {
  9067. +           RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9068. +               "%s: L2 padding: len=%d\n",
  9069. +               device_get_nameunit(sc->sc_dev), len);
  9070. +
  9071. +           len += 2;
  9072. +       }
  9073. +
  9074. +       m->m_pkthdr.rcvif = ifp;
  9075. +       m->m_data = (caddr_t) (rxwi + 1);
  9076. +       m->m_pkthdr.len = m->m_len = len;
  9077. +
  9078. +       /* check for crc errors */
  9079. +
  9080. +       if (desc_flags & RT2860_RXDESC_FLAGS_CRC_ERR)
  9081. +       {
  9082. +           RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9083. +               "%s: rxdesc: crc error\n",
  9084. +               device_get_nameunit(sc->sc_dev));
  9085. +
  9086. +           ifp->if_ierrors++;
  9087. +
  9088. +           if (!(ifp->if_flags & IFF_PROMISC))
  9089. +           {
  9090. +               m_freem(m);
  9091. +               goto skip;
  9092. +           }
  9093. +       }
  9094. +
  9095. +       wh = (struct ieee80211_frame *) (rxwi + 1);
  9096. +
  9097. +       /* check for cipher errors */
  9098. +
  9099. +       if (desc_flags & RT2860_RXDESC_FLAGS_DECRYPTED)
  9100. +       {
  9101. +           cipher_err = ((desc_flags >> RT2860_RXDESC_FLAGS_CIPHER_ERR_SHIFT) &
  9102. +               RT2860_RXDESC_FLAGS_CIPHER_ERR_MASK);
  9103. +           if (cipher_err == RT2860_RXDESC_FLAGS_CIPHER_ERR_NONE)
  9104. +           {
  9105. +               if (wh->i_fc[1] & IEEE80211_FC1_WEP)
  9106. +                   wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
  9107. +
  9108. +               m->m_flags |= M_WEP;
  9109. +
  9110. +               sc->rx_cipher_no_errors++;
  9111. +           }
  9112. +           else
  9113. +           {
  9114. +               RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9115. +                   "%s: rxdesc: cipher error=0x%02x\n",
  9116. +                   device_get_nameunit(sc->sc_dev), cipher_err);
  9117. +
  9118. +               if (cipher_err == RT2860_RXDESC_FLAGS_CIPHER_ERR_ICV)
  9119. +                   sc->rx_cipher_icv_errors++;
  9120. +               else if (cipher_err == RT2860_RXDESC_FLAGS_CIPHER_ERR_MIC)
  9121. +                   sc->rx_cipher_mic_errors++;
  9122. +               else if (cipher_err == RT2860_RXDESC_FLAGS_CIPHER_ERR_INVALID_KEY)
  9123. +                   sc->rx_cipher_invalid_key_errors++;
  9124. +
  9125. +               if ((cipher_err == RT2860_RXDESC_FLAGS_CIPHER_ERR_MIC) &&
  9126. +                   (desc_flags & RT2860_RXDESC_FLAGS_MYBSS))
  9127. +               {
  9128. +                   ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) wh);
  9129. +                   if (ni != NULL)
  9130. +                   {
  9131. +                       keyidx = (rxwi->udf_bssidx_keyidx >> RT2860_RXWI_KEYIDX_SHIFT) &
  9132. +                           RT2860_RXWI_KEYIDX_MASK;
  9133. +
  9134. +                       ieee80211_notify_michael_failure(ni->ni_vap, wh, keyidx);
  9135. +
  9136. +                       ieee80211_free_node(ni);
  9137. +                   }
  9138. +               }
  9139. +
  9140. +               ifp->if_ierrors++;
  9141. +
  9142. +               if (!(ifp->if_flags & IFF_PROMISC))
  9143. +               {
  9144. +                   m_free(m);
  9145. +                   goto skip;
  9146. +               }
  9147. +           }
  9148. +       }
  9149. +       else
  9150. +       {
  9151. +           if (wh->i_fc[1] & IEEE80211_FC1_WEP)
  9152. +           {
  9153. +               RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9154. +                   "%s: rxdesc: not decrypted but protected flag set\n",
  9155. +                   device_get_nameunit(sc->sc_dev));
  9156. +
  9157. +               ifp->if_ierrors++;
  9158. +
  9159. +               if (!(ifp->if_flags & IFF_PROMISC))
  9160. +               {
  9161. +                   m_free(m);
  9162. +                   goto skip;
  9163. +               }
  9164. +           }
  9165. +       }
  9166. +
  9167. +       /* check for A-MPDU */
  9168. +
  9169. +       if (desc_flags & RT2860_RXDESC_FLAGS_BA)
  9170. +       {
  9171. +           m->m_flags |= M_AMPDU;
  9172. +
  9173. +           sc->rx_ampdu++;
  9174. +
  9175. +           if (wh->i_fc[1] & IEEE80211_FC1_RETRY)
  9176. +               sc->rx_ampdu_retries++;
  9177. +
  9178. +           ampdu = 1;
  9179. +       }
  9180. +       else
  9181. +       {
  9182. +           ampdu = 0;
  9183. +       }
  9184. +
  9185. +       /* check for A-MSDU */
  9186. +
  9187. +       if (desc_flags & RT2860_RXDESC_FLAGS_AMSDU)
  9188. +       {
  9189. +           sc->rx_amsdu++;
  9190. +
  9191. +           amsdu = 1;
  9192. +       }
  9193. +       else
  9194. +       {
  9195. +           amsdu = 0;
  9196. +       }
  9197. +
  9198. +       ant = rt2860_maxrssi_rxpath(sc, rxwi);
  9199. +       rssi = rxwi->rssi[ant];
  9200. +       rssi_dbm = rt2860_rssi2dbm(sc, rssi, ant);
  9201. +       phymode = ((rxwi->phymode_stbc_shortgi >> RT2860_RXWI_PHYMODE_SHIFT) &
  9202. +           RT2860_RXWI_PHYMODE_MASK);
  9203. +       bw = ((rxwi->bw_mcs >> RT2860_RXWI_BW_SHIFT) & RT2860_RXWI_BW_MASK);
  9204. +       shortgi = ((rxwi->phymode_stbc_shortgi >> RT2860_RXWI_SHORTGI_SHIFT) &
  9205. +           RT2860_RXWI_SHORTGI_MASK);
  9206. +       stbc = ((rxwi->phymode_stbc_shortgi >> RT2860_RXWI_STBC_SHIFT) &
  9207. +           RT2860_RXWI_STBC_MASK);
  9208. +       mcs = ((rxwi->bw_mcs >> RT2860_RXWI_MCS_SHIFT) & RT2860_RXWI_MCS_MASK);
  9209. +       tid = ((rxwi->tid_size >> RT2860_RXWI_TID_SHIFT) & RT2860_RXWI_TID_MASK);
  9210. +       seq = ((rxwi->seq_frag >> RT2860_RXWI_SEQ_SHIFT) & RT2860_RXWI_SEQ_MASK);
  9211. +       frag = ((rxwi->seq_frag >> RT2860_RXWI_FRAG_SHIFT) & RT2860_RXWI_FRAG_MASK);
  9212. +
  9213. +       if (ieee80211_radiotap_active(ic))
  9214. +       {
  9215. +           tap = &sc->rxtap;
  9216. +
  9217. +           tap->flags = (desc_flags & RT2860_RXDESC_FLAGS_L2PAD) ? IEEE80211_RADIOTAP_F_DATAPAD : 0;
  9218. +           tap->dbm_antsignal = rssi_dbm;
  9219. +           tap->dbm_antnoise = RT2860_NOISE_FLOOR;
  9220. +           tap->antenna = ant;
  9221. +           tap->antsignal = rssi;
  9222. +           tap->chan_flags = htole32(ic->ic_curchan->ic_flags);
  9223. +           tap->chan_freq = htole16(ic->ic_curchan->ic_freq);
  9224. +           tap->chan_ieee = ic->ic_curchan->ic_ieee;
  9225. +           tap->chan_maxpow = 0;
  9226. +
  9227. +           if (phymode == RT2860_TXWI_PHYMODE_HT_MIXED || phymode == RT2860_TXWI_PHYMODE_HT_GF)
  9228. +               tap->rate = mcs | IEEE80211_RATE_MCS;
  9229. +           else
  9230. +               tap->rate = rt2860_rxrate(rxwi);
  9231. +
  9232. +           if (desc_flags & RT2860_RXDESC_FLAGS_CRC_ERR)
  9233. +               tap->flags |= IEEE80211_RADIOTAP_F_BADFCS;
  9234. +
  9235. +           if (desc_flags & RT2860_RXDESC_FLAGS_FRAG)
  9236. +               tap->flags |= IEEE80211_RADIOTAP_F_FRAG;
  9237. +
  9238. +           if (rxwi->bw_mcs & RT2860_RXWI_MCS_SHOTPRE)
  9239. +               tap->flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
  9240. +
  9241. +           if ((desc_flags & RT2860_RXDESC_FLAGS_DECRYPTED) ||
  9242. +               (wh->i_fc[1] & IEEE80211_FC1_WEP))
  9243. +               tap->flags |= IEEE80211_RADIOTAP_F_WEP;
  9244. +
  9245. +           if (shortgi)
  9246. +               tap->flags |= IEEE80211_RADIOTAP_F_SHORTGI;
  9247. +
  9248. +           /* XXX use temporarily radiotap CFP flag as A-MPDU flag */
  9249. +
  9250. +           if (ampdu)
  9251. +               tap->flags |= IEEE80211_RADIOTAP_F_CFP;
  9252. +       }
  9253. +
  9254. +       /*
  9255. +        * net80211 assumes that RSSI data are in the range [-127..127] and
  9256. +        * in .5 dBm units relative to the current noise floor
  9257. +        */
  9258. +
  9259. +       rssi_dbm_rel = (rssi_dbm - RT2860_NOISE_FLOOR) * 2;
  9260. +       if (rssi_dbm_rel > 127)
  9261. +           rssi_dbm_rel = 127;
  9262. +
  9263. +       RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9264. +           "%s: received frame: len=%d, phymode=%d, bw=%d, shortgi=%d, stbc=0x%02x, mcs=%d, "
  9265. +           "ant=%d, rssi=%d/%d/%d, snr=%d/%d, wcid=0x%02x, ampdu=%d, amsdu=%d, tid=%d, seq=%d, frag=%d, "
  9266. +           "retry=%d, rssi_dbm=%d, rssi_dbm_rel=%d\n",
  9267. +           device_get_nameunit(sc->sc_dev),
  9268. +           len, phymode, bw, shortgi, stbc, mcs,
  9269. +           ant, rxwi->rssi[0], rxwi->rssi[1], rxwi->rssi[2],
  9270. +           rxwi->snr[0], rxwi->snr[1],
  9271. +           rxwi->wcid, ampdu, amsdu, tid, seq, frag, (wh->i_fc[1] & IEEE80211_FC1_RETRY) ? 1 : 0,
  9272. +           rssi_dbm, rssi_dbm_rel);
  9273. +
  9274. +       ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *) wh);
  9275. +       if (ni != NULL)
  9276. +       {
  9277. +           rni = (struct rt2860_softc_node *) ni;
  9278. +
  9279. +           for (i = 0; i < RT2860_SOFTC_RSSI_COUNT; i++)
  9280. +           {
  9281. +               rni->last_rssi[i] = rxwi->rssi[i];
  9282. +               rni->last_rssi_dbm[i] = rt2860_rssi2dbm(sc, rxwi->rssi[i], i);
  9283. +           }
  9284. +
  9285. +           ieee80211_input(ni, m, rssi_dbm_rel, RT2860_NOISE_FLOOR);
  9286. +           ieee80211_free_node(ni);
  9287. +       }
  9288. +       else
  9289. +       {
  9290. +           ieee80211_input_all(ic, m, rssi_dbm_rel, RT2860_NOISE_FLOOR);
  9291. +       }
  9292. +
  9293. +skip:
  9294. +
  9295. +       desc->sdl0 &= ~htole16(RT2860_RXDESC_SDL0_DDONE);
  9296. +
  9297. +       bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  9298. +           BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  9299. +
  9300. +       ring->cur = (ring->cur + 1) % RT2860_SOFTC_RX_RING_DATA_COUNT;
  9301. +
  9302. +       limit--;
  9303. +   }
  9304. +
  9305. +   if (ring->cur == 0)
  9306. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_CALC_IDX,
  9307. +           RT2860_SOFTC_RX_RING_DATA_COUNT - 1);
  9308. +   else
  9309. +       rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_RX_CALC_IDX,
  9310. +           ring->cur - 1);
  9311. +
  9312. +   RT2860_DPRINTF(sc, RT2860_DEBUG_RX,
  9313. +       "%s: Rx eof: nframes=%d\n",
  9314. +       device_get_nameunit(sc->sc_dev), nframes);
  9315. +
  9316. +   sc->rx_packets += nframes;
  9317. +
  9318. +   return (limit == 0);
  9319. +}
  9320. +
  9321. +/*
  9322. + * rt2860_tx_eof
  9323. + */
  9324. +static void rt2860_tx_eof(struct rt2860_softc *sc,
  9325. +   struct rt2860_softc_tx_ring *ring)
  9326. +{
  9327. +   struct ifnet *ifp;
  9328. +   struct rt2860_txdesc *desc;
  9329. +   struct rt2860_softc_tx_data *data;
  9330. +   uint32_t index;
  9331. +   int ndescs, nframes;
  9332. +
  9333. +   ifp = sc->sc_ifp;
  9334. +
  9335. +   ndescs = 0;
  9336. +   nframes = 0;
  9337. +
  9338. +   for (;;)
  9339. +   {
  9340. +       index = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_TX_DTX_IDX(ring->qid));
  9341. +       if (ring->desc_next == index)
  9342. +           break;
  9343. +
  9344. +       ndescs++;
  9345. +
  9346. +       rt2860_drain_fifo_stats(sc);
  9347. +
  9348. +       desc = &ring->desc[ring->desc_next];
  9349. +
  9350. +       bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  9351. +           BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
  9352. +
  9353. +       if (desc->sdl0 & htole16(RT2860_TXDESC_SDL0_LASTSEG) ||
  9354. +           desc->sdl1 & htole16(RT2860_TXDESC_SDL1_LASTSEG))
  9355. +       {
  9356. +           nframes++;
  9357. +
  9358. +           data = &ring->data[ring->data_next];
  9359. +
  9360. +           if (data->m->m_flags & M_TXCB)
  9361. +               ieee80211_process_callback(data->ni, data->m, 0);
  9362. +
  9363. +           bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  9364. +               BUS_DMASYNC_POSTWRITE);
  9365. +           bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
  9366. +
  9367. +           m_freem(data->m);
  9368. +
  9369. +           ieee80211_free_node(data->ni);
  9370. +
  9371. +           data->m = NULL;
  9372. +           data->ni = NULL;
  9373. +
  9374. +           ifp->if_opackets++;
  9375. +
  9376. +           RT2860_SOFTC_TX_RING_LOCK(ring);
  9377. +
  9378. +           ring->data_queued--;
  9379. +           ring->data_next = (ring->data_next + 1) % RT2860_SOFTC_TX_RING_DATA_COUNT;
  9380. +
  9381. +           RT2860_SOFTC_TX_RING_UNLOCK(ring);
  9382. +       }
  9383. +
  9384. +       desc->sdl0 &= ~htole16(RT2860_TXDESC_SDL0_DDONE);
  9385. +
  9386. +       bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  9387. +           BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  9388. +
  9389. +       RT2860_SOFTC_TX_RING_LOCK(ring);
  9390. +
  9391. +       ring->desc_queued--;
  9392. +       ring->desc_next = (ring->desc_next + 1) % RT2860_SOFTC_TX_RING_DESC_COUNT;
  9393. +
  9394. +       RT2860_SOFTC_TX_RING_UNLOCK(ring);
  9395. +   }
  9396. +
  9397. +   RT2860_DPRINTF(sc, RT2860_DEBUG_TX,
  9398. +       "%s: Tx eof: qid=%d, ndescs=%d, nframes=%d\n",
  9399. +       device_get_nameunit(sc->sc_dev), ring->qid, ndescs, nframes);
  9400. +}
  9401. +
  9402. +/*
  9403. + * rt2860_update_stats
  9404. + */
  9405. +static void rt2860_update_stats(struct rt2860_softc *sc)
  9406. +{
  9407. +   struct ifnet *ifp;
  9408. +   struct ieee80211com *ic;
  9409. +   uint32_t stacnt[3];
  9410. +   int beacons, noretryok, retryok, failed, underflows, zerolen;
  9411. +
  9412. +   ifp = sc->sc_ifp;
  9413. +   ic = ifp->if_l2com;
  9414. +
  9415. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATS,
  9416. +       "%s: update statistic\n",
  9417. +       device_get_nameunit(sc->sc_dev));
  9418. +
  9419. +   rt2860_drain_fifo_stats(sc);
  9420. +
  9421. +   /* read and clear Tx statistic registers */
  9422. +
  9423. +   rt2860_io_mac_read_multi(sc, RT2860_REG_TX_STA_CNT0,
  9424. +       stacnt, sizeof(stacnt));
  9425. +
  9426. +   stacnt[0] = le32toh(stacnt[0]);
  9427. +   stacnt[1] = le32toh(stacnt[1]);
  9428. +   stacnt[2] = le32toh(stacnt[2]);
  9429. +
  9430. +   beacons = stacnt[0] >> 16;
  9431. +   noretryok = stacnt[1] & 0xffff;
  9432. +   retryok = stacnt[1] >> 16;
  9433. +   failed = stacnt[0] & 0xffff;
  9434. +   underflows = stacnt[2] >> 16;
  9435. +   zerolen = stacnt[2] & 0xffff;
  9436. +
  9437. +   RT2860_DPRINTF(sc, RT2860_DEBUG_STATS,
  9438. +       "%s: update statistic: beacons=%d, noretryok=%d, retryok=%d, failed=%d, underflows=%d, zerolen=%d\n",
  9439. +       device_get_nameunit(sc->sc_dev),
  9440. +       beacons, noretryok, retryok, failed, underflows, zerolen);
  9441. +
  9442. +   ifp->if_oerrors += failed;
  9443. +
  9444. +   sc->tx_beacons += beacons;
  9445. +   sc->tx_noretryok += noretryok;
  9446. +   sc->tx_retryok += retryok;
  9447. +   sc->tx_failed += failed;
  9448. +   sc->tx_underflows += underflows;
  9449. +   sc->tx_zerolen += zerolen;
  9450. +}
  9451. +
  9452. +/*
  9453. + * rt2860_bbp_tuning
  9454. + */
  9455. +static void rt2860_bbp_tuning(struct rt2860_softc *sc)
  9456. +{
  9457. +   struct ifnet *ifp;
  9458. +   struct ieee80211com *ic;
  9459. +   struct ieee80211vap *vap;
  9460. +   struct ieee80211_node *ni;
  9461. +   int chan, group;
  9462. +   int8_t rssi, old, new;
  9463. +
  9464. +   /* RT2860C does not support BBP tuning */
  9465. +
  9466. +   if (sc->mac_rev == 0x28600100)
  9467. +       return;
  9468. +
  9469. +   ifp = sc->sc_ifp;
  9470. +   ic = ifp->if_l2com;
  9471. +   vap = TAILQ_FIRST(&ic->ic_vaps);
  9472. +
  9473. +   if ((ic->ic_flags & IEEE80211_F_SCAN) || vap == NULL ||
  9474. +       vap->iv_opmode != IEEE80211_M_STA || vap->iv_state != IEEE80211_S_RUN)
  9475. +       return;
  9476. +
  9477. +   ni = vap->iv_bss;
  9478. +
  9479. +   chan = ieee80211_chan2ieee(ic, ni->ni_chan);
  9480. +
  9481. +   if (chan <= 14)
  9482. +       group = 0;
  9483. +   else if (chan <= 64)
  9484. +       group = 1;
  9485. +   else if (chan <= 128)
  9486. +       group = 2;
  9487. +   else
  9488. +       group = 3;
  9489. +
  9490. +   rssi = ieee80211_getrssi(vap);
  9491. +
  9492. +   if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
  9493. +   {
  9494. +       new = 0x2e + sc->lna_gain[group];
  9495. +   }
  9496. +   else
  9497. +   {
  9498. +       if (!IEEE80211_IS_CHAN_HT40(ni->ni_chan))
  9499. +           new = 0x32 + sc->lna_gain[group] * 5 / 3;
  9500. +       else
  9501. +           new = 0x3a + sc->lna_gain[group] * 5 / 3;
  9502. +   }
  9503. +
  9504. +   /* Tune if absolute average RSSI is greater than -80 */
  9505. +
  9506. +   if (rssi > 30)
  9507. +       new += 0x10;
  9508. +
  9509. +   old = rt2860_io_bbp_read(sc, 66);
  9510. +
  9511. +   if (old != new)
  9512. +       rt2860_io_bbp_write(sc, 66, new);
  9513. +}
  9514. +
  9515. +/*
  9516. + * rt2860_watchdog
  9517. + */
  9518. +static void rt2860_watchdog(struct rt2860_softc *sc)
  9519. +{
  9520. +   uint32_t tmp;
  9521. +   int ntries;
  9522. +
  9523. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_PBF_TXRXQ_PCNT);
  9524. +
  9525. +   RT2860_DPRINTF(sc, RT2860_DEBUG_WATCHDOG,
  9526. +       "%s: watchdog: TXRXQ_PCNT=0x%08x\n",
  9527. +       device_get_nameunit(sc->sc_dev), tmp);
  9528. +
  9529. +   if (((tmp >> RT2860_REG_TX0Q_PCNT_SHIFT) & RT2860_REG_TX0Q_PCNT_MASK) != 0)
  9530. +   {
  9531. +       sc->tx_queue_not_empty[0]++;
  9532. +
  9533. +       rt2860_io_mac_write(sc, RT2860_REG_PBF_CFG, 0xf40012);
  9534. +
  9535. +       for (ntries = 0; ntries < 10; ntries++)
  9536. +       {
  9537. +           tmp = rt2860_io_mac_read(sc, RT2860_REG_PBF_TXRXQ_PCNT);
  9538. +           if (((tmp >> RT2860_REG_TX0Q_PCNT_SHIFT) & RT2860_REG_TX0Q_PCNT_MASK) == 0)
  9539. +               break;
  9540. +
  9541. +           DELAY(1);
  9542. +       }
  9543. +
  9544. +       rt2860_io_mac_write(sc, RT2860_REG_PBF_CFG, 0xf40006);
  9545. +   }
  9546. +
  9547. +   if (((tmp >> RT2860_REG_TX1Q_PCNT_SHIFT) & RT2860_REG_TX1Q_PCNT_MASK) != 0)
  9548. +   {
  9549. +       sc->tx_queue_not_empty[1]++;
  9550. +
  9551. +       rt2860_io_mac_write(sc, RT2860_REG_PBF_CFG, 0xf4000a);
  9552. +
  9553. +       for (ntries = 0; ntries < 10; ntries++)
  9554. +       {
  9555. +           tmp = rt2860_io_mac_read(sc, RT2860_REG_PBF_TXRXQ_PCNT);
  9556. +           if (((tmp >> RT2860_REG_TX1Q_PCNT_SHIFT) & RT2860_REG_TX1Q_PCNT_MASK) == 0)
  9557. +               break;
  9558. +
  9559. +           DELAY(1);
  9560. +       }
  9561. +
  9562. +       rt2860_io_mac_write(sc, RT2860_REG_PBF_CFG, 0xf40006);
  9563. +   }
  9564. +}
  9565. +
  9566. +/*
  9567. + * rt2860_drain_fifo_stats
  9568. + */
  9569. +static void rt2860_drain_fifo_stats(struct rt2860_softc *sc)
  9570. +{
  9571. +   struct ifnet *ifp;
  9572. +   uint32_t stats;
  9573. +   uint8_t wcid, mcs, pid;
  9574. +   int ok, agg, retrycnt;
  9575. +
  9576. +   ifp = sc->sc_ifp;
  9577. +
  9578. +   /* drain Tx status FIFO (maxsize = 16) */
  9579. +
  9580. +   while ((stats = rt2860_io_mac_read(sc, RT2860_REG_TX_STA_FIFO)) &
  9581. +       RT2860_REG_TX_STA_FIFO_VALID)
  9582. +   {
  9583. +       wcid = (stats >> RT2860_REG_TX_STA_FIFO_WCID_SHIFT) &
  9584. +           RT2860_REG_TX_STA_FIFO_WCID_MASK;
  9585. +
  9586. +       /* if no ACK was requested, no feedback is available */
  9587. +
  9588. +       if (!(stats & RT2860_REG_TX_STA_FIFO_ACK_REQ) || wcid == RT2860_WCID_RESERVED)
  9589. +           continue;
  9590. +
  9591. +       /* update AMRR statistic */
  9592. +
  9593. +       ok = (stats & RT2860_REG_TX_STA_FIFO_TX_OK) ? 1 : 0;
  9594. +       agg = (stats & RT2860_REG_TX_STA_FIFO_AGG) ? 1 : 0;
  9595. +       mcs = (stats >> RT2860_REG_TX_STA_FIFO_MCS_SHIFT) &
  9596. +           RT2860_REG_TX_STA_FIFO_MCS_MASK;
  9597. +       pid = (stats >> RT2860_REG_TX_STA_FIFO_PID_SHIFT) &
  9598. +           RT2860_REG_TX_STA_FIFO_PID_MASK;
  9599. +       retrycnt = (mcs < 0xf) ? (pid - mcs - 1) : 0;
  9600. +
  9601. +       RT2860_DPRINTF(sc, RT2860_DEBUG_STATS,
  9602. +           "%s: FIFO statistic: wcid=0x%02x, ok=%d, agg=%d, mcs=0x%02x, pid=0x%02x, retrycnt=%d\n",
  9603. +           device_get_nameunit(sc->sc_dev),
  9604. +           wcid, ok, agg, mcs, pid, retrycnt);
  9605. +
  9606. +       rt2860_amrr_tx_complete(&sc->amrr_node[wcid], ok, retrycnt);
  9607. +
  9608. +       if (!ok)
  9609. +           ifp->if_oerrors++;
  9610. +   }
  9611. +}
  9612. +
  9613. +/*
  9614. + * rt2860_update_raw_counters
  9615. + */
  9616. +static void rt2860_update_raw_counters(struct rt2860_softc *sc)
  9617. +{
  9618. +   uint32_t tmp;
  9619. +
  9620. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT);
  9621. +
  9622. +   sc->tx_nonagg += tmp & 0xffff;
  9623. +   sc->tx_agg += tmp >> 16;
  9624. +
  9625. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT0);
  9626. +
  9627. +   sc->tx_ampdu += (tmp & 0xffff) / 1 + (tmp >> 16) / 2;
  9628. +
  9629. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT1);
  9630. +
  9631. +   sc->tx_ampdu += (tmp & 0xffff) / 3 + (tmp >> 16) / 4;
  9632. +
  9633. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT2);
  9634. +
  9635. +   sc->tx_ampdu += (tmp & 0xffff) / 5 + (tmp >> 16) / 6;
  9636. +
  9637. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT3);
  9638. +
  9639. +   sc->tx_ampdu += (tmp & 0xffff) / 7 + (tmp >> 16) / 8;
  9640. +
  9641. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT4);
  9642. +
  9643. +   sc->tx_ampdu += (tmp & 0xffff) / 9 + (tmp >> 16) / 10;
  9644. +
  9645. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT5);
  9646. +
  9647. +   sc->tx_ampdu += (tmp & 0xffff) / 11 + (tmp >> 16) / 12;
  9648. +
  9649. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT6);
  9650. +
  9651. +   sc->tx_ampdu += (tmp & 0xffff) / 13 + (tmp >> 16) / 14;
  9652. +
  9653. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TX_AGG_CNT7);
  9654. +
  9655. +   sc->tx_ampdu += (tmp & 0xffff) / 15 + (tmp >> 16) / 16;
  9656. +
  9657. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_RX_STA_CNT0);
  9658. +
  9659. +   sc->rx_crc_errors += tmp & 0xffff;
  9660. +   sc->rx_phy_errors += tmp >> 16;
  9661. +
  9662. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_RX_STA_CNT1);
  9663. +
  9664. +   sc->rx_false_ccas += tmp & 0xffff;
  9665. +   sc->rx_plcp_errors += tmp >> 16;
  9666. +
  9667. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_RX_STA_CNT2);
  9668. +
  9669. +   sc->rx_dup_packets += tmp & 0xffff;
  9670. +   sc->rx_fifo_overflows += tmp >> 16;
  9671. +
  9672. +   tmp = rt2860_io_mac_read(sc, RT2860_REG_TXRX_MPDU_DEN_CNT);
  9673. +
  9674. +   sc->tx_mpdu_zero_density += tmp & 0xffff;
  9675. +   sc->rx_mpdu_zero_density += tmp >> 16;
  9676. +}
  9677. +
  9678. +/*
  9679. + * rt2860_intr_enable
  9680. + */
  9681. +static void rt2860_intr_enable(struct rt2860_softc *sc, uint32_t intr_mask)
  9682. +{
  9683. +   uint32_t tmp;
  9684. +
  9685. +   sc->intr_disable_mask &= ~intr_mask;
  9686. +
  9687. +   tmp = sc->intr_enable_mask & ~sc->intr_disable_mask;
  9688. +
  9689. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_MASK, tmp);
  9690. +}
  9691. +
  9692. +/*
  9693. + * rt2860_intr_disable
  9694. + */
  9695. +static void rt2860_intr_disable(struct rt2860_softc *sc, uint32_t intr_mask)
  9696. +{
  9697. +   uint32_t tmp;
  9698. +
  9699. +   sc->intr_disable_mask |= intr_mask;
  9700. +
  9701. +   tmp = sc->intr_enable_mask & ~sc->intr_disable_mask;
  9702. +
  9703. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_INT_MASK, tmp);
  9704. +}
  9705. +
  9706. +/*
  9707. + * rt2860_txrx_enable
  9708. + */
  9709. +static int rt2860_txrx_enable(struct rt2860_softc *sc)
  9710. +{
  9711. +   struct ieee80211com *ic;
  9712. +   struct ifnet *ifp;
  9713. +   uint32_t tmp;
  9714. +   int ntries;
  9715. +
  9716. +   ifp = sc->sc_ifp;
  9717. +   ic = ifp->if_l2com;
  9718. +
  9719. +   /* enable Tx/Rx DMA engine */
  9720. +
  9721. +   rt2860_io_mac_write(sc, RT2860_REG_SYS_CTRL, RT2860_REG_TX_ENABLE);
  9722. +
  9723. +   for (ntries = 0; ntries < 200; ntries++)
  9724. +   {
  9725. +       tmp = rt2860_io_mac_read(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG);
  9726. +       if (!(tmp & (RT2860_REG_TX_DMA_BUSY | RT2860_REG_RX_DMA_BUSY)))
  9727. +           break;
  9728. +
  9729. +       DELAY(1000);
  9730. +   }
  9731. +
  9732. +   if (ntries == 200)
  9733. +   {
  9734. +       printf("%s: timeout waiting for DMA engine\n",
  9735. +           device_get_nameunit(sc->sc_dev));
  9736. +       return -1;
  9737. +   }
  9738. +
  9739. +   DELAY(50);
  9740. +
  9741. +   tmp |= RT2860_REG_TX_WB_DDONE |
  9742. +       RT2860_REG_RX_DMA_ENABLE |
  9743. +       RT2860_REG_TX_DMA_ENABLE |
  9744. +       (RT2860_REG_WPDMA_BT_SIZE64 << RT2860_REG_WPDMA_BT_SIZE_SHIFT);
  9745. +
  9746. +   rt2860_io_mac_write(sc, RT2860_REG_SCHDMA_WPDMA_GLO_CFG, tmp);
  9747. +
  9748. +   /* set Rx filter */
  9749. +
  9750. +   tmp = RT2860_REG_RX_FILTER_DROP_CRC_ERR |
  9751. +       RT2860_REG_RX_FILTER_DROP_PHY_ERR;
  9752. +
  9753. +   if (ic->ic_opmode != IEEE80211_M_MONITOR)
  9754. +   {
  9755. +       tmp |= RT2860_REG_RX_FILTER_DROP_DUPL |
  9756. +           RT2860_REG_RX_FILTER_DROP_CTS |
  9757. +           RT2860_REG_RX_FILTER_DROP_BA |
  9758. +           RT2860_REG_RX_FILTER_DROP_ACK |
  9759. +           RT2860_REG_RX_FILTER_DROP_VER_ERR |
  9760. +           RT2860_REG_RX_FILTER_DROP_CTRL_RSV |
  9761. +           RT2860_REG_RX_FILTER_DROP_CFACK |
  9762. +           RT2860_REG_RX_FILTER_DROP_CFEND;
  9763. +
  9764. +       if (ic->ic_opmode == IEEE80211_M_STA)
  9765. +           tmp |= RT2860_REG_RX_FILTER_DROP_RTS |
  9766. +               RT2860_REG_RX_FILTER_DROP_PSPOLL;
  9767. +
  9768. +       if (!(ifp->if_flags & IFF_PROMISC))
  9769. +           tmp |= RT2860_REG_RX_FILTER_DROP_UC_NOME;
  9770. +   }
  9771. +
  9772. +   rt2860_io_mac_write(sc, RT2860_REG_RX_FILTER_CFG, tmp);
  9773. +
  9774. +   rt2860_io_mac_write(sc, RT2860_REG_SYS_CTRL,
  9775. +       RT2860_REG_RX_ENABLE | RT2860_REG_TX_ENABLE);
  9776. +
  9777. +   return 0;
  9778. +}
  9779. +
  9780. +/*
  9781. + * rt2860_alloc_rx_ring
  9782. + */
  9783. +static int rt2860_alloc_rx_ring(struct rt2860_softc *sc,
  9784. +   struct rt2860_softc_rx_ring *ring)
  9785. +{
  9786. +   struct rt2860_rxdesc *desc;
  9787. +   struct rt2860_softc_rx_data *data;
  9788. +   bus_dma_segment_t segs[1];
  9789. +   int i, nsegs, error;
  9790. +
  9791. +   error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), PAGE_SIZE, 0,
  9792. +       BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
  9793. +       RT2860_SOFTC_RX_RING_DATA_COUNT * sizeof(struct rt2860_rxdesc), 1,
  9794. +       RT2860_SOFTC_RX_RING_DATA_COUNT * sizeof(struct rt2860_rxdesc),
  9795. +       0, NULL, NULL, &ring->desc_dma_tag);
  9796. +   if (error != 0)
  9797. +   {
  9798. +       printf("%s: could not create Rx desc DMA tag\n",
  9799. +           device_get_nameunit(sc->sc_dev));
  9800. +       goto fail;
  9801. +   }
  9802. +
  9803. +   error = bus_dmamem_alloc(ring->desc_dma_tag, (void **) &ring->desc,
  9804. +       BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_dma_map);
  9805. +   if (error != 0)
  9806. +   {
  9807. +       printf("%s: could not allocate Rx desc DMA memory\n",
  9808. +           device_get_nameunit(sc->sc_dev));
  9809. +       goto fail;
  9810. +   }
  9811. +
  9812. +   error = bus_dmamap_load(ring->desc_dma_tag, ring->desc_dma_map,
  9813. +       ring->desc,
  9814. +       RT2860_SOFTC_RX_RING_DATA_COUNT * sizeof(struct rt2860_rxdesc),
  9815. +       rt2860_dma_map_addr, &ring->desc_phys_addr, 0);
  9816. +   if (error != 0)
  9817. +   {
  9818. +       printf("%s: could not load Rx desc DMA map\n",
  9819. +           device_get_nameunit(sc->sc_dev));
  9820. +       goto fail;
  9821. +   }
  9822. +
  9823. +   error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), PAGE_SIZE, 0,
  9824. +       BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
  9825. +       MJUMPAGESIZE, 1, MJUMPAGESIZE, 0, NULL, NULL,
  9826. +       &ring->data_dma_tag);
  9827. +   if (error != 0)
  9828. +   {
  9829. +       printf("%s: could not create Rx data DMA tag\n",
  9830. +           device_get_nameunit(sc->sc_dev));
  9831. +       goto fail;
  9832. +   }
  9833. +
  9834. +   for (i = 0; i < RT2860_SOFTC_RX_RING_DATA_COUNT; i++)
  9835. +   {
  9836. +       desc = &ring->desc[i];
  9837. +       data = &ring->data[i];
  9838. +
  9839. +       error = bus_dmamap_create(ring->data_dma_tag, 0, &data->dma_map);
  9840. +       if (error != 0)
  9841. +       {
  9842. +           printf("%s: could not create Rx data DMA map\n",
  9843. +               device_get_nameunit(sc->sc_dev));
  9844. +           goto fail;
  9845. +       }
  9846. +
  9847. +       data->m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
  9848. +       if (data->m == NULL)
  9849. +       {
  9850. +           printf("%s: could not allocate Rx mbuf\n",
  9851. +               device_get_nameunit(sc->sc_dev));
  9852. +           error = ENOMEM;
  9853. +           goto fail;
  9854. +       }
  9855. +
  9856. +       data->m->m_len = data->m->m_pkthdr.len = MJUMPAGESIZE;
  9857. +
  9858. +       error = bus_dmamap_load_mbuf_sg(ring->data_dma_tag, data->dma_map,
  9859. +           data->m, segs, &nsegs, BUS_DMA_NOWAIT);
  9860. +       if (error != 0)
  9861. +       {
  9862. +           printf("%s: could not load Rx mbuf DMA map\n",
  9863. +               device_get_nameunit(sc->sc_dev));
  9864. +           goto fail;
  9865. +       }
  9866. +
  9867. +       KASSERT(nsegs == 1, ("%s: too many DMA segments",
  9868. +           device_get_nameunit(sc->sc_dev)));
  9869. +
  9870. +       desc->sdp0 = htole32(segs[0].ds_addr);
  9871. +       desc->sdl0 = htole16(MJUMPAGESIZE);
  9872. +   }
  9873. +
  9874. +   error = bus_dmamap_create(ring->data_dma_tag, 0, &ring->spare_dma_map);
  9875. +   if (error != 0)
  9876. +   {
  9877. +       printf("%s: could not create Rx spare DMA map\n",
  9878. +           device_get_nameunit(sc->sc_dev));
  9879. +       goto fail;
  9880. +   }
  9881. +
  9882. +   bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  9883. +       BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  9884. +
  9885. +   return 0;
  9886. +
  9887. +fail:
  9888. +  
  9889. +   rt2860_free_rx_ring(sc, ring);
  9890. +
  9891. +   return error;
  9892. +}
  9893. +
  9894. +/*
  9895. + * rt2860_reset_rx_ring
  9896. + */
  9897. +static void rt2860_reset_rx_ring(struct rt2860_softc *sc,
  9898. +   struct rt2860_softc_rx_ring *ring)
  9899. +{
  9900. +   struct rt2860_rxdesc *desc;
  9901. +   int i;
  9902. +
  9903. +   for (i = 0; i < RT2860_SOFTC_RX_RING_DATA_COUNT; i++)
  9904. +   {
  9905. +       desc = &ring->desc[i];
  9906. +
  9907. +       desc->sdl0 &= ~htole16(RT2860_RXDESC_SDL0_DDONE);
  9908. +   }
  9909. +
  9910. +   bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  9911. +       BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  9912. +
  9913. +   ring->cur = 0;
  9914. +}
  9915. +
  9916. +/*
  9917. + * rt2860_free_rx_ring
  9918. + */
  9919. +static void rt2860_free_rx_ring(struct rt2860_softc *sc,
  9920. +   struct rt2860_softc_rx_ring *ring)
  9921. +{
  9922. +   struct rt2860_softc_rx_data *data;
  9923. +   int i;
  9924. +
  9925. +   if (ring->desc != NULL)
  9926. +   {
  9927. +       bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  9928. +           BUS_DMASYNC_POSTWRITE);
  9929. +       bus_dmamap_unload(ring->desc_dma_tag, ring->desc_dma_map);
  9930. +       bus_dmamem_free(ring->desc_dma_tag, ring->desc,
  9931. +           ring->desc_dma_map);
  9932. +   }
  9933. +
  9934. +   if (ring->desc_dma_tag != NULL)
  9935. +       bus_dma_tag_destroy(ring->desc_dma_tag);
  9936. +
  9937. +   for (i = 0; i < RT2860_SOFTC_RX_RING_DATA_COUNT; i++)
  9938. +   {
  9939. +       data = &ring->data[i];
  9940. +
  9941. +       if (data->m != NULL)
  9942. +       {
  9943. +           bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  9944. +               BUS_DMASYNC_POSTREAD);
  9945. +           bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
  9946. +           m_freem(data->m);
  9947. +       }
  9948. +
  9949. +       if (data->dma_map != NULL)
  9950. +           bus_dmamap_destroy(ring->data_dma_tag, data->dma_map);
  9951. +   }
  9952. +
  9953. +   if (ring->spare_dma_map != NULL)
  9954. +       bus_dmamap_destroy(ring->data_dma_tag, ring->spare_dma_map);
  9955. +
  9956. +   if (ring->data_dma_tag != NULL)
  9957. +       bus_dma_tag_destroy(ring->data_dma_tag);
  9958. +}
  9959. +
  9960. +/*
  9961. + * rt2860_alloc_tx_ring
  9962. + */
  9963. +static int rt2860_alloc_tx_ring(struct rt2860_softc *sc,
  9964. +   struct rt2860_softc_tx_ring *ring, int qid)
  9965. +{
  9966. +   struct rt2860_softc_tx_data *data;
  9967. +   int error, i;
  9968. +
  9969. +   mtx_init(&ring->lock, device_get_nameunit(sc->sc_dev), NULL, MTX_DEF);
  9970. +
  9971. +   error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), PAGE_SIZE, 0,
  9972. +       BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
  9973. +       RT2860_SOFTC_TX_RING_DESC_COUNT * sizeof(struct rt2860_txdesc), 1,
  9974. +       RT2860_SOFTC_TX_RING_DESC_COUNT * sizeof(struct rt2860_txdesc),
  9975. +       0, NULL, NULL, &ring->desc_dma_tag);
  9976. +   if (error != 0)
  9977. +   {
  9978. +       printf("%s: could not create Tx desc DMA tag\n",
  9979. +           device_get_nameunit(sc->sc_dev));
  9980. +       goto fail;
  9981. +   }
  9982. +
  9983. +   error = bus_dmamem_alloc(ring->desc_dma_tag, (void **) &ring->desc,
  9984. +       BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_dma_map);
  9985. +   if (error != 0)
  9986. +   {
  9987. +       printf("%s: could not allocate Tx desc DMA memory\n",
  9988. +           device_get_nameunit(sc->sc_dev));
  9989. +       goto fail;
  9990. +   }
  9991. +
  9992. +   error = bus_dmamap_load(ring->desc_dma_tag, ring->desc_dma_map,
  9993. +       ring->desc,
  9994. +       RT2860_SOFTC_TX_RING_DESC_COUNT * sizeof(struct rt2860_txdesc),
  9995. +       rt2860_dma_map_addr, &ring->desc_phys_addr, 0);
  9996. +   if (error != 0)
  9997. +   {
  9998. +       printf("%s: could not load Tx desc DMA map\n",
  9999. +           device_get_nameunit(sc->sc_dev));
  10000. +       goto fail;
  10001. +   }
  10002. +
  10003. +   ring->desc_queued = 0;
  10004. +   ring->desc_cur = 0;
  10005. +   ring->desc_next = 0;
  10006. +
  10007. +   error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), PAGE_SIZE, 0,
  10008. +       BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
  10009. +       RT2860_SOFTC_TX_RING_DATA_COUNT * RT2860_TX_DATA_SEG0_SIZE, 1,
  10010. +       RT2860_SOFTC_TX_RING_DATA_COUNT * RT2860_TX_DATA_SEG0_SIZE,
  10011. +       0, NULL, NULL, &ring->seg0_dma_tag);
  10012. +   if (error != 0)
  10013. +   {
  10014. +       printf("%s: could not create Tx seg0 DMA tag\n",
  10015. +           device_get_nameunit(sc->sc_dev));
  10016. +       goto fail;
  10017. +   }
  10018. +
  10019. +   error = bus_dmamem_alloc(ring->seg0_dma_tag, (void **) &ring->seg0,
  10020. +       BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->seg0_dma_map);
  10021. +   if (error != 0)
  10022. +   {
  10023. +       printf("%s: could not allocate Tx seg0 DMA memory\n",
  10024. +           device_get_nameunit(sc->sc_dev));
  10025. +       goto fail;
  10026. +   }
  10027. +
  10028. +   error = bus_dmamap_load(ring->seg0_dma_tag, ring->seg0_dma_map,
  10029. +       ring->seg0,
  10030. +       RT2860_SOFTC_TX_RING_DATA_COUNT * RT2860_TX_DATA_SEG0_SIZE,
  10031. +       rt2860_dma_map_addr, &ring->seg0_phys_addr, 0);
  10032. +   if (error != 0)
  10033. +   {
  10034. +       printf("%s: could not load Tx seg0 DMA map\n",
  10035. +           device_get_nameunit(sc->sc_dev));
  10036. +       goto fail;
  10037. +   }
  10038. +
  10039. +   error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), PAGE_SIZE, 0,
  10040. +       BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
  10041. +       MJUMPAGESIZE, RT2860_SOFTC_MAX_SCATTER, MJUMPAGESIZE, 0, NULL, NULL,
  10042. +       &ring->data_dma_tag);
  10043. +   if (error != 0)
  10044. +   {
  10045. +       printf("%s: could not create Tx data DMA tag\n",
  10046. +           device_get_nameunit(sc->sc_dev));
  10047. +       goto fail;
  10048. +   }
  10049. +
  10050. +   for (i = 0; i < RT2860_SOFTC_TX_RING_DATA_COUNT; i++)
  10051. +   {
  10052. +       data = &ring->data[i];
  10053. +
  10054. +       error = bus_dmamap_create(ring->data_dma_tag, 0, &data->dma_map);
  10055. +       if (error != 0)
  10056. +       {
  10057. +           printf("%s: could not create Tx data DMA map\n",
  10058. +               device_get_nameunit(sc->sc_dev));
  10059. +           goto fail;
  10060. +       }
  10061. +   }
  10062. +
  10063. +   ring->data_queued = 0;
  10064. +   ring->data_cur = 0;
  10065. +   ring->data_next = 0;
  10066. +
  10067. +   ring->qid = qid;
  10068. +
  10069. +   return 0;
  10070. +
  10071. +fail:
  10072. +  
  10073. +   rt2860_free_tx_ring(sc, ring);
  10074. +
  10075. +   return error;
  10076. +}
  10077. +
  10078. +/*
  10079. + * rt2860_reset_tx_ring
  10080. + */
  10081. +static void rt2860_reset_tx_ring(struct rt2860_softc *sc,
  10082. +   struct rt2860_softc_tx_ring *ring)
  10083. +{
  10084. +   struct rt2860_softc_tx_data *data;
  10085. +   struct rt2860_txdesc *desc;
  10086. +   int i;
  10087. +
  10088. +   for (i = 0; i < RT2860_SOFTC_TX_RING_DESC_COUNT; i++)
  10089. +   {
  10090. +       desc = &ring->desc[i];
  10091. +
  10092. +       desc->sdl0 = 0;
  10093. +       desc->sdl1 = 0;
  10094. +   }
  10095. +
  10096. +   ring->desc_queued = 0;
  10097. +   ring->desc_cur = 0;
  10098. +   ring->desc_next = 0;
  10099. +
  10100. +   bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  10101. +       BUS_DMASYNC_PREWRITE);
  10102. +
  10103. +   bus_dmamap_sync(ring->seg0_dma_tag, ring->seg0_dma_map,
  10104. +       BUS_DMASYNC_PREWRITE);
  10105. +
  10106. +   for (i = 0; i < RT2860_SOFTC_TX_RING_DATA_COUNT; i++)
  10107. +   {
  10108. +       data = &ring->data[i];
  10109. +
  10110. +       if (data->m != NULL)
  10111. +       {
  10112. +           bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  10113. +               BUS_DMASYNC_POSTWRITE);
  10114. +           bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
  10115. +           m_freem(data->m);
  10116. +           data->m = NULL;
  10117. +       }
  10118. +
  10119. +       if (data->ni != NULL)
  10120. +       {
  10121. +           ieee80211_free_node(data->ni);
  10122. +           data->ni = NULL;
  10123. +       }
  10124. +   }
  10125. +
  10126. +   ring->data_queued = 0;
  10127. +   ring->data_cur = 0;
  10128. +   ring->data_next = 0;
  10129. +}
  10130. +
  10131. +/*
  10132. + * rt2860_free_tx_ring
  10133. + */
  10134. +static void rt2860_free_tx_ring(struct rt2860_softc *sc,
  10135. +   struct rt2860_softc_tx_ring *ring)
  10136. +{
  10137. +   struct rt2860_softc_tx_data *data;
  10138. +   int i;
  10139. +
  10140. +   if (ring->desc != NULL)
  10141. +   {
  10142. +       bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
  10143. +           BUS_DMASYNC_POSTWRITE);
  10144. +       bus_dmamap_unload(ring->desc_dma_tag, ring->desc_dma_map);
  10145. +       bus_dmamem_free(ring->desc_dma_tag, ring->desc,
  10146. +           ring->desc_dma_map);
  10147. +   }
  10148. +
  10149. +   if (ring->desc_dma_tag != NULL)
  10150. +       bus_dma_tag_destroy(ring->desc_dma_tag);
  10151. +
  10152. +   if (ring->seg0 != NULL)
  10153. +   {
  10154. +       bus_dmamap_sync(ring->seg0_dma_tag, ring->seg0_dma_map,
  10155. +           BUS_DMASYNC_POSTWRITE);
  10156. +       bus_dmamap_unload(ring->seg0_dma_tag, ring->seg0_dma_map);
  10157. +       bus_dmamem_free(ring->seg0_dma_tag, ring->seg0,
  10158. +           ring->seg0_dma_map);
  10159. +   }
  10160. +
  10161. +   if (ring->seg0_dma_tag != NULL)
  10162. +       bus_dma_tag_destroy(ring->seg0_dma_tag);
  10163. +
  10164. +   for (i = 0; i < RT2860_SOFTC_TX_RING_DATA_COUNT; i++)
  10165. +   {
  10166. +       data = &ring->data[i];
  10167. +
  10168. +       if (data->m != NULL)
  10169. +       {
  10170. +           bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
  10171. +               BUS_DMASYNC_POSTWRITE);
  10172. +           bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
  10173. +           m_freem(data->m);
  10174. +       }
  10175. +
  10176. +       if (data->ni != NULL)
  10177. +           ieee80211_free_node(data->ni);
  10178. +
  10179. +       if (data->dma_map != NULL)
  10180. +           bus_dmamap_destroy(ring->data_dma_tag, data->dma_map);
  10181. +   }
  10182. +
  10183. +   if (ring->data_dma_tag != NULL)
  10184. +       bus_dma_tag_destroy(ring->data_dma_tag);
  10185. +
  10186. +   mtx_destroy(&ring->lock);
  10187. +}
  10188. +
  10189. +
  10190. +/*
  10191. + * rt2860_dma_map_addr
  10192. + */
  10193. +static void rt2860_dma_map_addr(void *arg, bus_dma_segment_t *segs,
  10194. +   int nseg, int error)
  10195. +{
  10196. +   if (error != 0)
  10197. +       return;
  10198. +
  10199. +   KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
  10200. +
  10201. +   *(bus_addr_t *) arg = segs[0].ds_addr;
  10202. +}
  10203. +
  10204. +/*
  10205. + * rt2860_sysctl_attach
  10206. + */
  10207. +static void rt2860_sysctl_attach(struct rt2860_softc *sc)
  10208. +{
  10209. +   struct sysctl_ctx_list *ctx;
  10210. +   struct sysctl_oid *tree;
  10211. +   struct sysctl_oid *stats;
  10212. +
  10213. +   ctx = device_get_sysctl_ctx(sc->sc_dev);
  10214. +   tree = device_get_sysctl_tree(sc->sc_dev);
  10215. +
  10216. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
  10217. +       "tx_stbc", CTLFLAG_RW, &sc->tx_stbc, 0,
  10218. +       "Tx STBC");
  10219. +
  10220. +   /* statistic counters */
  10221. +
  10222. +   stats = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
  10223. +       "stats", CTLFLAG_RD, 0, "statistic");
  10224. +
  10225. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10226. +       "interrupts", CTLFLAG_RD, &sc->interrupts, 0,
  10227. +       "all interrupts");
  10228. +
  10229. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10230. +       "tx_coherent_interrupts", CTLFLAG_RD, &sc->tx_coherent_interrupts, 0,
  10231. +       "Tx coherent interrupts");
  10232. +
  10233. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10234. +       "rx_coherent_interrupts", CTLFLAG_RD, &sc->rx_coherent_interrupts, 0,
  10235. +       "Rx coherent interrupts");
  10236. +
  10237. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10238. +       "txrx_coherent_interrupts", CTLFLAG_RD, &sc->txrx_coherent_interrupts, 0,
  10239. +       "Tx/Rx coherent interrupts");
  10240. +
  10241. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10242. +       "fifo_sta_full_interrupts", CTLFLAG_RD, &sc->fifo_sta_full_interrupts, 0,
  10243. +       "FIFO statistic full interrupts");
  10244. +
  10245. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10246. +       "rx_interrupts", CTLFLAG_RD, &sc->rx_interrupts, 0,
  10247. +       "Rx interrupts");
  10248. +
  10249. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10250. +       "rx_delay_interrupts", CTLFLAG_RD, &sc->rx_delay_interrupts, 0,
  10251. +       "Rx delay interrupts");
  10252. +
  10253. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10254. +       "tx_mgmt_interrupts", CTLFLAG_RD, &sc->tx_interrupts[5], 0,
  10255. +       "Tx MGMT interrupts");
  10256. +
  10257. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10258. +       "tx_hcca_interrupts", CTLFLAG_RD, &sc->tx_interrupts[4], 0,
  10259. +       "Tx HCCA interrupts");
  10260. +
  10261. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10262. +       "tx_ac3_interrupts", CTLFLAG_RD, &sc->tx_interrupts[3], 0,
  10263. +       "Tx AC3 interrupts");
  10264. +
  10265. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10266. +       "tx_ac2_interrupts", CTLFLAG_RD, &sc->tx_interrupts[2], 0,
  10267. +       "Tx AC2 interrupts");
  10268. +
  10269. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10270. +       "tx_ac1_interrupts", CTLFLAG_RD, &sc->tx_interrupts[1], 0,
  10271. +       "Tx AC1 interrupts");
  10272. +
  10273. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10274. +       "tx_ac0_interrupts", CTLFLAG_RD, &sc->tx_interrupts[0], 0,
  10275. +       "Tx AC0 interrupts");
  10276. +
  10277. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10278. +       "tx_delay_interrupts", CTLFLAG_RD, &sc->tx_delay_interrupts, 0,
  10279. +       "Tx delay interrupts");
  10280. +
  10281. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10282. +       "pre_tbtt_interrupts", CTLFLAG_RD, &sc->pre_tbtt_interrupts, 0,
  10283. +       "Pre-TBTT interrupts");
  10284. +
  10285. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10286. +       "tbtt_interrupts", CTLFLAG_RD, &sc->tbtt_interrupts, 0,
  10287. +       "TBTT interrupts");
  10288. +
  10289. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10290. +       "mcu_cmd_interrupts", CTLFLAG_RD, &sc->mcu_cmd_interrupts, 0,
  10291. +       "MCU command interrupts");
  10292. +
  10293. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10294. +       "auto_wakeup_interrupts", CTLFLAG_RD, &sc->auto_wakeup_interrupts, 0,
  10295. +       "auto wakeup interrupts");
  10296. +
  10297. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10298. +       "gp_timer_interrupts", CTLFLAG_RD, &sc->gp_timer_interrupts, 0,
  10299. +       "GP timer interrupts");
  10300. +
  10301. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10302. +       "tx_mgmt_desc_queued", CTLFLAG_RD, &sc->tx_ring[5].desc_queued, 0,
  10303. +       "Tx MGMT descriptors queued");
  10304. +
  10305. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10306. +       "tx_mgmt_data_queued", CTLFLAG_RD, &sc->tx_ring[5].data_queued, 0,
  10307. +       "Tx MGMT data queued");
  10308. +
  10309. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10310. +       "tx_hcca_desc_queued", CTLFLAG_RD, &sc->tx_ring[4].desc_queued, 0,
  10311. +       "Tx HCCA descriptors queued");
  10312. +
  10313. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10314. +       "tx_hcca_data_queued", CTLFLAG_RD, &sc->tx_ring[4].data_queued, 0,
  10315. +       "Tx HCCA data queued");
  10316. +
  10317. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10318. +       "tx_ac3_desc_queued", CTLFLAG_RD, &sc->tx_ring[3].desc_queued, 0,
  10319. +       "Tx AC3 descriptors queued");
  10320. +
  10321. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10322. +       "tx_ac3_data_queued", CTLFLAG_RD, &sc->tx_ring[3].data_queued, 0,
  10323. +       "Tx AC3 data queued");
  10324. +
  10325. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10326. +       "tx_ac2_desc_queued", CTLFLAG_RD, &sc->tx_ring[2].desc_queued, 0,
  10327. +       "Tx AC2 descriptors queued");
  10328. +
  10329. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10330. +       "tx_ac2_data_queued", CTLFLAG_RD, &sc->tx_ring[2].data_queued, 0,
  10331. +       "Tx AC2 data queued");
  10332. +
  10333. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10334. +       "tx_ac1_desc_queued", CTLFLAG_RD, &sc->tx_ring[1].desc_queued, 0,
  10335. +       "Tx AC1 descriptors queued");
  10336. +
  10337. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10338. +       "tx_ac1_data_queued", CTLFLAG_RD, &sc->tx_ring[1].data_queued, 0,
  10339. +       "Tx AC1 data queued");
  10340. +
  10341. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10342. +       "tx_ac0_desc_queued", CTLFLAG_RD, &sc->tx_ring[0].desc_queued, 0,
  10343. +       "Tx AC0 descriptors queued");
  10344. +
  10345. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10346. +       "tx_ac0_data_queued", CTLFLAG_RD, &sc->tx_ring[0].data_queued, 0,
  10347. +       "Tx AC0 data queued");
  10348. +
  10349. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10350. +       "tx_mgmt_data_queue_full", CTLFLAG_RD, &sc->tx_data_queue_full[5], 0,
  10351. +       "Tx MGMT data queue full");
  10352. +
  10353. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10354. +       "tx_hcca_data_queue_full", CTLFLAG_RD, &sc->tx_data_queue_full[4], 0,
  10355. +       "Tx HCCA data queue full");
  10356. +
  10357. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10358. +       "tx_ac3_data_queue_full", CTLFLAG_RD, &sc->tx_data_queue_full[3], 0,
  10359. +       "Tx AC3 data queue full");
  10360. +
  10361. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10362. +       "tx_ac2_data_queue_full", CTLFLAG_RD, &sc->tx_data_queue_full[2], 0,
  10363. +       "Tx AC2 data queue full");
  10364. +
  10365. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10366. +       "tx_ac1_data_queue_full", CTLFLAG_RD, &sc->tx_data_queue_full[1], 0,
  10367. +       "Tx AC1 data queue full");
  10368. +
  10369. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10370. +       "tx_ac0_data_queue_full", CTLFLAG_RD, &sc->tx_data_queue_full[0], 0,
  10371. +       "Tx AC0 data queue full");
  10372. +
  10373. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10374. +       "tx_watchdog_timeouts", CTLFLAG_RD, &sc->tx_watchdog_timeouts, 0,
  10375. +       "Tx watchdog timeouts");
  10376. +
  10377. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10378. +       "tx_defrag_packets", CTLFLAG_RD, &sc->tx_defrag_packets, 0,
  10379. +       "Tx defragmented packets");
  10380. +
  10381. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10382. +       "no_tx_desc_avail", CTLFLAG_RD, &sc->no_tx_desc_avail, 0,
  10383. +       "no Tx descriptors available");
  10384. +
  10385. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10386. +       "rx_mbuf_alloc_errors", CTLFLAG_RD, &sc->rx_mbuf_alloc_errors, 0,
  10387. +       "Rx mbuf allocation errors");
  10388. +
  10389. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10390. +       "rx_mbuf_dmamap_errors", CTLFLAG_RD, &sc->rx_mbuf_dmamap_errors, 0,
  10391. +       "Rx mbuf DMA mapping errors");
  10392. +
  10393. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10394. +       "tx_queue_0_not_empty", CTLFLAG_RD, &sc->tx_queue_not_empty[0], 0,
  10395. +       "Tx queue 0 not empty");
  10396. +
  10397. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10398. +       "tx_queue_1_not_empty", CTLFLAG_RD, &sc->tx_queue_not_empty[1], 0,
  10399. +       "Tx queue 1 not empty");
  10400. +
  10401. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10402. +       "tx_beacons", CTLFLAG_RD, &sc->tx_beacons, 0,
  10403. +       "Tx beacons");
  10404. +
  10405. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10406. +       "tx_noretryok", CTLFLAG_RD, &sc->tx_noretryok, 0,
  10407. +       "Tx successfull without retries");
  10408. +
  10409. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10410. +       "tx_retryok", CTLFLAG_RD, &sc->tx_retryok, 0,
  10411. +       "Tx successfull with retries");
  10412. +
  10413. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10414. +       "tx_failed", CTLFLAG_RD, &sc->tx_failed, 0,
  10415. +       "Tx failed");
  10416. +
  10417. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10418. +       "tx_underflows", CTLFLAG_RD, &sc->tx_underflows, 0,
  10419. +       "Tx underflows");
  10420. +
  10421. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10422. +       "tx_zerolen", CTLFLAG_RD, &sc->tx_zerolen, 0,
  10423. +       "Tx zero length");
  10424. +
  10425. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10426. +       "tx_nonagg", CTLFLAG_RD, &sc->tx_nonagg, 0,
  10427. +       "Tx non-aggregated");
  10428. +
  10429. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10430. +       "tx_agg", CTLFLAG_RD, &sc->tx_agg, 0,
  10431. +       "Tx aggregated");
  10432. +
  10433. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10434. +       "tx_ampdu", CTLFLAG_RD, &sc->tx_ampdu, 0,
  10435. +       "Tx A-MPDU");
  10436. +
  10437. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10438. +       "tx_mpdu_zero_density", CTLFLAG_RD, &sc->tx_mpdu_zero_density, 0,
  10439. +       "Tx MPDU with zero density");
  10440. +
  10441. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10442. +       "tx_ampdu_sessions", CTLFLAG_RD, &sc->tx_ampdu_sessions, 0,
  10443. +       "Tx A-MPDU sessions");
  10444. +
  10445. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10446. +       "rx_packets", CTLFLAG_RD, &sc->rx_packets, 0,
  10447. +       "Rx packets");
  10448. +
  10449. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10450. +       "rx_ampdu", CTLFLAG_RD, &sc->rx_ampdu, 0,
  10451. +       "Rx A-MPDU");
  10452. +
  10453. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10454. +       "rx_ampdu_retries", CTLFLAG_RD, &sc->rx_ampdu_retries, 0,
  10455. +       "Rx A-MPDU retries");
  10456. +
  10457. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10458. +       "rx_mpdu_zero_density", CTLFLAG_RD, &sc->rx_mpdu_zero_density, 0,
  10459. +       "Rx MPDU with zero density");
  10460. +
  10461. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10462. +       "rx_ampdu_sessions", CTLFLAG_RD, &sc->rx_ampdu_sessions, 0,
  10463. +       "Rx A-MPDU sessions");
  10464. +
  10465. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10466. +       "rx_amsdu", CTLFLAG_RD, &sc->rx_amsdu, 0,
  10467. +       "Rx A-MSDU");
  10468. +
  10469. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10470. +       "rx_crc_errors", CTLFLAG_RD, &sc->rx_crc_errors, 0,
  10471. +       "Rx CRC errors");
  10472. +
  10473. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10474. +       "rx_phy_errors", CTLFLAG_RD, &sc->rx_phy_errors, 0,
  10475. +       "Rx PHY errors");
  10476. +
  10477. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10478. +       "rx_false_ccas", CTLFLAG_RD, &sc->rx_false_ccas, 0,
  10479. +       "Rx false CCAs");
  10480. +
  10481. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10482. +       "rx_plcp_errors", CTLFLAG_RD, &sc->rx_plcp_errors, 0,
  10483. +       "Rx PLCP errors");
  10484. +
  10485. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10486. +       "rx_dup_packets", CTLFLAG_RD, &sc->rx_dup_packets, 0,
  10487. +       "Rx duplicate packets");
  10488. +
  10489. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10490. +       "rx_fifo_overflows", CTLFLAG_RD, &sc->rx_fifo_overflows, 0,
  10491. +       "Rx FIFO overflows");
  10492. +
  10493. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10494. +       "rx_cipher_no_errors", CTLFLAG_RD, &sc->rx_cipher_no_errors, 0,
  10495. +       "Rx cipher no errors");
  10496. +
  10497. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10498. +       "rx_cipher_icv_errors", CTLFLAG_RD, &sc->rx_cipher_icv_errors, 0,
  10499. +       "Rx cipher ICV errors");
  10500. +
  10501. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10502. +       "rx_cipher_mic_errors", CTLFLAG_RD, &sc->rx_cipher_mic_errors, 0,
  10503. +       "Rx cipher MIC errors");
  10504. +
  10505. +   SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(stats), OID_AUTO,
  10506. +       "rx_cipher_invalid_key_errors", CTLFLAG_RD, &sc->rx_cipher_invalid_key_errors, 0,
  10507. +       "Rx cipher invalid key errors");
  10508. +}
  10509. +
  10510. +
  10511. diff -aruN /usr/src/sys/dev/ral/rt2860_amrr.h src/sys/dev/ral/rt2860_amrr.h
  10512. --- /usr/src/sys/dev/ral/rt2860_amrr.h  1969-12-31 16:00:00.000000000 -0800
  10513. +++ src/sys/dev/ral/rt2860_amrr.h   2011-07-05 21:51:10.000000000 -0700
  10514. @@ -0,0 +1,80 @@
  10515. +
  10516.  
  10517. +/*-
  10518.  
  10519. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  10520.  
  10521. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  10522.  
  10523. + *
  10524.  
  10525. + * Permission to use, copy, modify, and distribute this software for any
  10526.  
  10527. + * purpose with or without fee is hereby granted, provided that the above
  10528.  
  10529. + * copyright notice and this permission notice appear in all copies.
  10530.  
  10531. + *
  10532.  
  10533. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10534.  
  10535. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10536.  
  10537. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10538.  
  10539. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10540.  
  10541. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  10542.  
  10543. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  10544.  
  10545. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  10546.  
  10547. + */
  10548.  
  10549. +
  10550.  
  10551. +#ifndef _RT2860_AMRR_H_
  10552.  
  10553. +#define _RT2860_AMRR_H_
  10554.  
  10555. +
  10556.  
  10557. +#define RT2860_AMRR_MIN_SUCCESS_THRESHOLD                  1
  10558.  
  10559. +#define RT2860_AMRR_MAX_SUCCESS_THRESHOLD                  15
  10560.  
  10561. +
  10562.  
  10563. +struct rt2860_amrr
  10564.  
  10565. +{
  10566.  
  10567. +   int ntxpath;
  10568.  
  10569. +
  10570.  
  10571. +   unsigned int min_success_threshold;
  10572.  
  10573. +   unsigned int max_success_threshold;
  10574.  
  10575. +
  10576.  
  10577. +   int interval;
  10578.  
  10579. +};
  10580.  
  10581. +
  10582.  
  10583. +struct rt2860_amrr_node
  10584.  
  10585. +{
  10586.  
  10587. +   struct rt2860_amrr *amrr;
  10588.  
  10589. +
  10590.  
  10591. +   int rate_index;
  10592.  
  10593. +
  10594.  
  10595. +   int ticks;
  10596.  
  10597. +
  10598.  
  10599. +   unsigned int txcnt;
  10600.  
  10601. +   unsigned int success;
  10602.  
  10603. +   unsigned int success_threshold;
  10604.  
  10605. +   unsigned int recovery;
  10606.  
  10607. +   unsigned int retrycnt;
  10608.  
  10609. +};
  10610.  
  10611. +
  10612.  
  10613. +void rt2860_amrr_init(struct rt2860_amrr *amrr, struct ieee80211vap *vap,
  10614.  
  10615. +   int ntxpath, int min_success_threshold, int max_success_threshold, int msecs);
  10616.  
  10617. +
  10618.  
  10619. +void rt2860_amrr_cleanup(struct rt2860_amrr *amrr);
  10620.  
  10621. +
  10622.  
  10623. +void rt2860_amrr_node_init(struct rt2860_amrr *amrr,
  10624.  
  10625. +    struct rt2860_amrr_node *amrr_node, struct ieee80211_node *ni);
  10626.  
  10627. +
  10628.  
  10629. +int rt2860_amrr_choose(struct ieee80211_node *ni,
  10630.  
  10631. +   struct rt2860_amrr_node *amrr_node);
  10632.  
  10633. +
  10634.  
  10635. +static __inline void rt2860_amrr_tx_complete(struct rt2860_amrr_node *amrr_node,
  10636.  
  10637. +   int ok, int retries)
  10638.  
  10639. +{
  10640.  
  10641. +   amrr_node->txcnt++;
  10642.  
  10643. +
  10644.  
  10645. +   if (ok)
  10646.  
  10647. +       amrr_node->success++;
  10648.  
  10649. +
  10650.  
  10651. +   amrr_node->retrycnt += retries;
  10652.  
  10653. +}
  10654.  
  10655. +
  10656.  
  10657. +static __inline void rt2860_amrr_tx_update(struct rt2860_amrr_node *amrr_node,
  10658.  
  10659. +   int txcnt, int success, int retrycnt)
  10660.  
  10661. +{
  10662.  
  10663. +   amrr_node->txcnt = txcnt;
  10664.  
  10665. +   amrr_node->success = success;
  10666.  
  10667. +   amrr_node->retrycnt = retrycnt;
  10668.  
  10669. +}
  10670.  
  10671. +
  10672.  
  10673. +#endif /* #ifndef _RT2860_AMRR_H_ */
  10674.  
  10675. diff -aruN /usr/src/sys/dev/ral/rt2860_debug.h src/sys/dev/ral/rt2860_debug.h
  10676. --- /usr/src/sys/dev/ral/rt2860_debug.h 1969-12-31 16:00:00.000000000 -0800
  10677. +++ src/sys/dev/ral/rt2860_debug.h  2011-07-05 21:51:10.000000000 -0700
  10678. @@ -0,0 +1,53 @@
  10679. +
  10680.  
  10681. +/*-
  10682.  
  10683. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  10684.  
  10685. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  10686.  
  10687. + *
  10688.  
  10689. + * Permission to use, copy, modify, and distribute this software for any
  10690.  
  10691. + * purpose with or without fee is hereby granted, provided that the above
  10692.  
  10693. + * copyright notice and this permission notice appear in all copies.
  10694.  
  10695. + *
  10696.  
  10697. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10698.  
  10699. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10700.  
  10701. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10702.  
  10703. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10704.  
  10705. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  10706.  
  10707. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  10708.  
  10709. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  10710.  
  10711. + */
  10712.  
  10713. +
  10714.  
  10715. +#ifndef _RT2860_DEBUG_H_
  10716.  
  10717. +#define _RT2860_DEBUG_H_
  10718.  
  10719. +
  10720.  
  10721. +#ifdef RT2860_DEBUG
  10722.  
  10723. +
  10724.  
  10725. +enum
  10726.  
  10727. +{
  10728.  
  10729. +   RT2860_DEBUG_EEPROM = 0x00000001,
  10730.  
  10731. +   RT2860_DEBUG_RX = 0x00000002,
  10732.  
  10733. +   RT2860_DEBUG_TX = 0x00000004,
  10734.  
  10735. +   RT2860_DEBUG_INTR = 0x00000008,
  10736.  
  10737. +   RT2860_DEBUG_STATE = 0x00000010,
  10738.  
  10739. +   RT2860_DEBUG_CHAN = 0x00000020,
  10740.  
  10741. +   RT2860_DEBUG_NODE = 0x00000040,
  10742.  
  10743. +   RT2860_DEBUG_KEY = 0x00000080,
  10744.  
  10745. +   RT2860_DEBUG_PROT = 0x00000100,
  10746.  
  10747. +   RT2860_DEBUG_WME = 0x00000200,
  10748.  
  10749. +   RT2860_DEBUG_BEACON = 0x00000400,
  10750.  
  10751. +   RT2860_DEBUG_BA = 0x00000800,
  10752.  
  10753. +   RT2860_DEBUG_STATS = 0x00001000,
  10754.  
  10755. +   RT2860_DEBUG_RATE = 0x00002000,
  10756.  
  10757. +   RT2860_DEBUG_PERIODIC = 0x00004000,
  10758.  
  10759. +   RT2860_DEBUG_WATCHDOG = 0x00008000,
  10760.  
  10761. +   RT2860_DEBUG_ANY = 0xffffffff
  10762.  
  10763. +};
  10764.  
  10765. +
  10766.  
  10767. +#define RT2860_DPRINTF(sc, m, fmt, ...)        do { if ((sc)->debug & (m)) printf(fmt, __VA_ARGS__); } while (0)
  10768.  
  10769. +
  10770.  
  10771. +#else
  10772.  
  10773. +
  10774.  
  10775. +#define RT2860_DPRINTF(sc, m, fmt, ...)
  10776.  
  10777. +
  10778.  
  10779. +#endif /* #ifdef RT2860_DEBUG */
  10780.  
  10781. +
  10782.  
  10783. +#endif /* #ifndef _RT2860_DEBUG_H_ */
  10784.  
  10785. diff -aruN /usr/src/sys/dev/ral/rt2860_eeprom.h src/sys/dev/ral/rt2860_eeprom.h
  10786. --- /usr/src/sys/dev/ral/rt2860_eeprom.h    1969-12-31 16:00:00.000000000 -0800
  10787. +++ src/sys/dev/ral/rt2860_eeprom.h 2011-07-05 21:51:10.000000000 -0700
  10788. @@ -0,0 +1,91 @@
  10789. +
  10790.  
  10791. +/*-
  10792.  
  10793. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  10794.  
  10795. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  10796.  
  10797. + *
  10798.  
  10799. + * Permission to use, copy, modify, and distribute this software for any
  10800.  
  10801. + * purpose with or without fee is hereby granted, provided that the above
  10802.  
  10803. + * copyright notice and this permission notice appear in all copies.
  10804.  
  10805. + *
  10806.  
  10807. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10808.  
  10809. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10810.  
  10811. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10812.  
  10813. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10814.  
  10815. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  10816.  
  10817. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  10818.  
  10819. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  10820.  
  10821. + */
  10822.  
  10823. +
  10824.  
  10825. +#ifndef _RT2860_EEPROM_H_
  10826.  
  10827. +#define _RT2860_EEPROM_H_
  10828.  
  10829. +
  10830.  
  10831. +#define RT2860_EEPROM_VERSION                  0x0002
  10832.  
  10833. +#define RT2860_EEPROM_ADDRESS01                    0x0004
  10834.  
  10835. +#define RT2860_EEPROM_ADDRESS23                    0x0006
  10836.  
  10837. +#define RT2860_EEPROM_ADDRESS45                    0x0008
  10838.  
  10839. +#define RT2860_EEPROM_POWERSAVE_LEVEL          0x0022
  10840.  
  10841. +#define RT2860_EEPROM_ANTENNA                  0x0034
  10842.  
  10843. +#define RT2860_EEPROM_NIC_CONFIG               0x0036
  10844.  
  10845. +#define RT2860_EEPROM_COUNTRY                  0x0038
  10846.  
  10847. +#define RT2860_EEPROM_RF_FREQ_OFF              0x003a
  10848.  
  10849. +#define RT2860_EEPROM_LED1_OFF                 0x003c
  10850.  
  10851. +#define RT2860_EEPROM_LED2_OFF                 0x003e
  10852.  
  10853. +#define RT2860_EEPROM_LED3_OFF                 0x0040
  10854.  
  10855. +#define RT2860_EEPROM_LNA_GAIN                 0x0044
  10856.  
  10857. +#define RT2860_EEPROM_RSSI_OFF_2GHZ_BASE       0x0046
  10858.  
  10859. +#define RT2860_EEPROM_RSSI2_OFF_2GHZ_BASE      0x0048
  10860.  
  10861. +#define RT2860_EEPROM_RSSI_OFF_5GHZ_BASE       0x004a
  10862.  
  10863. +#define RT2860_EEPROM_RSSI2_OFF_5GHZ_BASE      0x004c
  10864.  
  10865. +#define RT2860_EEPROM_TXPOW_RATE_DELTA         0x0050
  10866.  
  10867. +#define RT2860_EEPROM_TXPOW1_2GHZ_BASE         0x0052
  10868.  
  10869. +#define RT2860_EEPROM_TXPOW2_2GHZ_BASE         0x0060
  10870.  
  10871. +#define RT2860_EEPROM_TSSI_2GHZ_BASE           0x006e
  10872.  
  10873. +#define RT2860_EEPROM_TXPOW1_5GHZ_BASE         0x0078
  10874.  
  10875. +#define RT2860_EEPROM_TXPOW2_5GHZ_BASE         0x00a6
  10876.  
  10877. +#define RT2860_EEPROM_TSSI_5GHZ_BASE           0x00d4
  10878.  
  10879. +#define RT2860_EEPROM_TXPOW_RATE_BASE          0x00de
  10880.  
  10881. +#define RT2860_EEPROM_BBP_BASE             0x00f0
  10882.  
  10883. +#define RT3071_EEPROM_RF_BASE              0x0082
  10884.  
  10885. +
  10886.  
  10887. +#define RT2860_EEPROM_RF_2820                  1 /* 2.4GHz 2T3R */
  10888.  
  10889. +#define RT2860_EEPROM_RF_2850                  2 /* 2.4/5GHz 2T3R */
  10890.  
  10891. +#define RT2860_EEPROM_RF_2720                  3 /* 2.4GHz 1T2R */
  10892.  
  10893. +#define RT2860_EEPROM_RF_2750                  4 /* 2.4G/5GHz 1T2R */
  10894.  
  10895. +#define RT2860_EEPROM_RF_3020                  5 /* 2.4G 1T1R */
  10896.  
  10897. +#define RT2860_EEPROM_RF_2020                  6 /* 2.4G B/G */
  10898.  
  10899. +#define RT2860_EEPROM_RF_3021                  7 /* 2.4G 1T2R */
  10900.  
  10901. +#define RT2860_EEPROM_RF_3022                  8 /* 2.4G 2T2R */
  10902.  
  10903. +#define RT2860_EEPROM_RF_3052                  9 /* 2.4G/5G 2T2R */
  10904.  
  10905. +#define RT2860_EEPROM_RF_2853                  10 /* 2.4G.5G 3T3R */
  10906.  
  10907. +#define RT2860_EEPROM_RF_3320                  11 /* 2.4G 1T1R with PA (RT3350/RT3370/RT3390) */
  10908.  
  10909. +#define RT2860_EEPROM_RF_3322                  12 /* 2.4G 2T2R with PA (RT3352/RT3371/RT3372/RT3391/RT3392) */
  10910.  
  10911. +#define RT2860_EEPROM_RF_3053                  13 /* 2.4G/5G 3T3R (RT3883/RT3563/RT3573/RT3593/RT3662) */
  10912.  
  10913. +#define RT2860_EEPROM_RF_3853                  13 /* 2.4G/5G 3T3R (RT3883/RT3563/RT3573/RT3593/RT3662) */
  10914.  
  10915. +
  10916.  
  10917. +/*
  10918.  
  10919. + * RT2860_EEPROM_NIC_CONFIG flags
  10920.  
  10921. + */
  10922.  
  10923. +#define RT2860_EEPROM_EXT_LNA_5GHZ             (1 << 3)
  10924.  
  10925. +#define RT2860_EEPROM_EXT_LNA_2GHZ             (1 << 2)
  10926.  
  10927. +#define RT2860_EEPROM_TX_AGC_CNTL              (1 << 1)
  10928.  
  10929. +#define RT2860_EEPROM_HW_RADIO_CNTL                (1 << 0)
  10930.  
  10931. +
  10932.  
  10933. +#define RT2860_EEPROM_LED_POLARITY             (1 << 7)
  10934.  
  10935. +#define RT2860_EEPROM_LED_MODE_MASK                0x7f
  10936.  
  10937. +
  10938.  
  10939. +#define RT2860_EEPROM_LED_CNTL_DEFAULT         0x01
  10940.  
  10941. +#define RT2860_EEPROM_LED1_OFF_DEFAULT         0x5555
  10942.  
  10943. +#define RT2860_EEPROM_LED2_OFF_DEFAULT         0x2221
  10944.  
  10945. +#define RT2860_EEPROM_LED3_OFF_DEFAULT         0xa9f8
  10946.  
  10947. +
  10948.  
  10949. +#define RT2860_EEPROM_RSSI_OFF_MIN             -10
  10950.  
  10951. +#define RT2860_EEPROM_RSSI_OFF_MAX             10
  10952.  
  10953. +
  10954.  
  10955. +#define RT2860_EEPROM_TXPOW_2GHZ_MIN           0
  10956.  
  10957. +#define RT2860_EEPROM_TXPOW_2GHZ_MAX           31
  10958.  
  10959. +#define RT2860_EEPROM_TXPOW_2GHZ_DEFAULT       5
  10960.  
  10961. +#define RT2860_EEPROM_TXPOW_5GHZ_MIN           -7
  10962.  
  10963. +#define RT2860_EEPROM_TXPOW_5GHZ_MAX           15
  10964.  
  10965. +#define RT2860_EEPROM_TXPOW_5GHZ_DEFAULT       5
  10966.  
  10967. +
  10968.  
  10969. +#endif /* #ifndef _RT2860_EEPROM_H_ */
  10970.  
  10971. diff -aruN /usr/src/sys/dev/ral/rt2860_io.h src/sys/dev/ral/rt2860_io.h
  10972. --- /usr/src/sys/dev/ral/rt2860_io.h    1969-12-31 16:00:00.000000000 -0800
  10973. +++ src/sys/dev/ral/rt2860_io.h 2011-07-05 21:51:10.000000000 -0700
  10974. @@ -0,0 +1,73 @@
  10975. +
  10976.  
  10977. +/*-
  10978.  
  10979. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  10980.  
  10981. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  10982.  
  10983. + *
  10984.  
  10985. + * Permission to use, copy, modify, and distribute this software for any
  10986.  
  10987. + * purpose with or without fee is hereby granted, provided that the above
  10988.  
  10989. + * copyright notice and this permission notice appear in all copies.
  10990.  
  10991. + *
  10992.  
  10993. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10994.  
  10995. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10996.  
  10997. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10998.  
  10999. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11000.  
  11001. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11002.  
  11003. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  11004.  
  11005. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  11006.  
  11007. + */
  11008.  
  11009. +
  11010.  
  11011. +#ifndef _RT2860_IO_H_
  11012.  
  11013. +#define _RT2860_IO_H_
  11014.  
  11015. +
  11016.  
  11017. +#include <dev/ral/rt2860_softc.h>
  11018.  
  11019. +
  11020.  
  11021. +#define RT2860_IO_MCU_CMD_SLEEP                0x30
  11022.  
  11023. +#define RT2860_IO_MCU_CMD_WAKEUP           0x31
  11024.  
  11025. +#define RT2860_IO_MCU_CMD_RADIOOFF         0x35
  11026.  
  11027. +#define RT2860_IO_MCU_CMD_LEDS             0x50
  11028.  
  11029. +#define RT2860_IO_MCU_CMD_LED_BRIGHTNESS       0x51
  11030.  
  11031. +#define RT2860_IO_MCU_CMD_LED1             0x52
  11032.  
  11033. +#define RT2860_IO_MCU_CMD_LED2             0x53
  11034.  
  11035. +#define RT2860_IO_MCU_CMD_LED3             0x54
  11036.  
  11037. +#define RT2860_IO_MCU_CMD_BOOT             0x72
  11038.  
  11039. +#define RT2860_IO_MCU_CMD_BBP              0x80
  11040.  
  11041. +#define RT2860_IO_MCU_CMD_POWERSAVE_LEVEL      0x83
  11042.  
  11043. +
  11044.  
  11045. +void rt2860_io_rf_load_defaults(struct rt2860_softc *sc);
  11046.  
  11047. +uint32_t rt2860_io_mac_read(struct rt2860_softc *sc, uint16_t reg);
  11048.  
  11049. +
  11050.  
  11051. +void rt2860_io_mac_read_multi(struct rt2860_softc *sc,
  11052.  
  11053. +   uint16_t reg, void *buf, size_t len);
  11054.  
  11055. +
  11056.  
  11057. +void rt2860_io_mac_write(struct rt2860_softc *sc,
  11058.  
  11059. +   uint16_t reg, uint32_t val);
  11060.  
  11061. +
  11062.  
  11063. +void rt2860_io_mac_write_multi(struct rt2860_softc *sc,
  11064.  
  11065. +   uint16_t reg, const void *buf, size_t len);
  11066.  
  11067. +
  11068.  
  11069. +void rt2860_io_mac_set_region_4(struct rt2860_softc *sc,
  11070.  
  11071. +   uint16_t reg, uint32_t val, size_t len);
  11072.  
  11073. +
  11074.  
  11075. +uint16_t rt2860_io_eeprom_read(struct rt2860_softc *sc, uint16_t addr);
  11076.  
  11077. +
  11078.  
  11079. +void rt2860_io_eeprom_read_multi(struct rt2860_softc *sc,
  11080.  
  11081. +   uint16_t addr, void *buf, size_t len);
  11082.  
  11083. +
  11084.  
  11085. +uint8_t rt2860_io_bbp_read(struct rt2860_softc *sc, uint8_t reg);
  11086.  
  11087. +
  11088.  
  11089. +void rt2860_io_bbp_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val);
  11090.  
  11091. +
  11092.  
  11093. +void rt2860_io_rf_write(struct rt2860_softc *sc, uint8_t reg, uint32_t val);
  11094.  
  11095. +
  11096.  
  11097. +int32_t rt2860_io_rf_read(struct rt2860_softc *sc, uint8_t reg);
  11098.  
  11099. +
  11100.  
  11101. +void rt2860_io_mcu_cmd(struct rt2860_softc *sc, uint8_t cmd,
  11102.  
  11103. +   uint8_t token, uint16_t arg);
  11104.  
  11105. +
  11106.  
  11107. +int rt2860_io_mcu_cmd_check(struct rt2860_softc *sc, uint8_t cid);
  11108.  
  11109. +
  11110.  
  11111. +int rt2860_io_mcu_load_ucode(struct rt2860_softc *sc,
  11112.  
  11113. +   const uint8_t *ucode, size_t len);
  11114.  
  11115. +
  11116.  
  11117. +
  11118.  
  11119. +#endif /* #ifndef _RT2860_IO_H_ */
  11120.  
  11121. diff -aruN /usr/src/sys/dev/ral/rt2860_led.h src/sys/dev/ral/rt2860_led.h
  11122. --- /usr/src/sys/dev/ral/rt2860_led.h   1969-12-31 16:00:00.000000000 -0800
  11123. +++ src/sys/dev/ral/rt2860_led.h    2011-07-05 21:51:10.000000000 -0700
  11124. @@ -0,0 +1,33 @@
  11125. +
  11126.  
  11127. +/*-
  11128.  
  11129. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  11130.  
  11131. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  11132.  
  11133. + *
  11134.  
  11135. + * Permission to use, copy, modify, and distribute this software for any
  11136.  
  11137. + * purpose with or without fee is hereby granted, provided that the above
  11138.  
  11139. + * copyright notice and this permission notice appear in all copies.
  11140.  
  11141. + *
  11142.  
  11143. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11144.  
  11145. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11146.  
  11147. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11148.  
  11149. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11150.  
  11151. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11152.  
  11153. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  11154.  
  11155. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  11156.  
  11157. + */
  11158.  
  11159. +
  11160.  
  11161. +#ifndef _RT2860_LED_H_
  11162.  
  11163. +#define _RT2860_LED_H_
  11164.  
  11165. +
  11166.  
  11167. +#include <dev/ral/rt2860_softc.h>
  11168.  
  11169. +
  11170.  
  11171. +#define RT2860_LED_CMD_RADIO_OFF               0
  11172.  
  11173. +#define RT2860_LED_CMD_RADIO_ON                    (1 << 5)
  11174.  
  11175. +#define RT2860_LED_CMD_LINK_2GHZ               (1 << 6)
  11176.  
  11177. +#define RT2860_LED_CMD_LINK_5GHZ               (1 << 7)
  11178.  
  11179. +
  11180.  
  11181. +void rt2860_led_brightness(struct rt2860_softc *sc, uint8_t brightness);
  11182.  
  11183. +
  11184.  
  11185. +void rt2860_led_cmd(struct rt2860_softc *sc, uint8_t cmd);
  11186.  
  11187. +
  11188.  
  11189. +#endif /* #ifndef _RT2860_LED_H_ */
  11190.  
  11191. diff -aruN /usr/src/sys/dev/ral/rt2860_read_eeprom.h src/sys/dev/ral/rt2860_read_eeprom.h
  11192. --- /usr/src/sys/dev/ral/rt2860_read_eeprom.h   1969-12-31 16:00:00.000000000 -0800
  11193. +++ src/sys/dev/ral/rt2860_read_eeprom.h    2011-07-05 21:51:10.000000000 -0700
  11194. @@ -0,0 +1,29 @@
  11195. +
  11196.  
  11197. +/*-
  11198.  
  11199. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  11200.  
  11201. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  11202.  
  11203. + *
  11204.  
  11205. + * Permission to use, copy, modify, and distribute this software for any
  11206.  
  11207. + * purpose with or without fee is hereby granted, provided that the above
  11208.  
  11209. + * copyright notice and this permission notice appear in all copies.
  11210.  
  11211. + *
  11212.  
  11213. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11214.  
  11215. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11216.  
  11217. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11218.  
  11219. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11220.  
  11221. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11222.  
  11223. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  11224.  
  11225. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  11226.  
  11227. + */
  11228.  
  11229. +
  11230.  
  11231. +#ifndef _RT2860_READ_EEPROM_H_
  11232.  
  11233. +#define _RT2860_READ_EEPROM_H_
  11234.  
  11235. +
  11236.  
  11237. +#include <dev/ral/rt2860_softc.h>
  11238.  
  11239. +
  11240.  
  11241. +void rt2860_read_eeprom(struct rt2860_softc *sc);
  11242.  
  11243. +
  11244.  
  11245. +uint32_t rt2860_read_eeprom_txpow_rate_add_delta(uint32_t txpow_rate,
  11246.  
  11247. +   int8_t delta);
  11248.  
  11249. +
  11250.  
  11251. +#endif /* #ifndef _RT2860_READ_EEPROM_H_ */
  11252.  
  11253. diff -aruN /usr/src/sys/dev/ral/rt2860_reg.h src/sys/dev/ral/rt2860_reg.h
  11254. --- /usr/src/sys/dev/ral/rt2860_reg.h   1969-12-31 16:00:00.000000000 -0800
  11255. +++ src/sys/dev/ral/rt2860_reg.h    2011-07-05 21:51:10.000000000 -0700
  11256. @@ -0,0 +1,559 @@
  11257. +
  11258.  
  11259. +/*-
  11260.  
  11261. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  11262.  
  11263. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  11264.  
  11265. + *
  11266.  
  11267. + * Permission to use, copy, modify, and distribute this software for any
  11268.  
  11269. + * purpose with or without fee is hereby granted, provided that the above
  11270.  
  11271. + * copyright notice and this permission notice appear in all copies.
  11272.  
  11273. + *
  11274.  
  11275. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11276.  
  11277. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11278.  
  11279. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11280.  
  11281. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11282.  
  11283. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11284.  
  11285. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  11286.  
  11287. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  11288.  
  11289. + */
  11290.  
  11291. +
  11292.  
  11293. +#ifndef _RT2860_REG_H_
  11294.  
  11295. +#define _RT2860_REG_H_
  11296.  
  11297. +
  11298.  
  11299. +#define RT2860_REG_PCI_CFG                 0x0000
  11300.  
  11301. +#define RT2860_REG_EEPROM_CSR                  0x0004
  11302.  
  11303. +#define RT2860_REG_PCI_MCU_CSR                 0x0008
  11304.  
  11305. +#define RT2860_REG_PCI_SYS_CSR                 0x000c
  11306.  
  11307. +#define RT2860_REG_PCIE_JTAG                   0x0010
  11308.  
  11309. +
  11310.  
  11311. +#define RT2860_REG_SCHDMA_INT_STATUS               0x0200
  11312.  
  11313. +#define RT2860_REG_SCHDMA_INT_MASK                 0x0204
  11314.  
  11315. +#define RT2860_REG_SCHDMA_WPDMA_GLO_CFG                0x0208
  11316.  
  11317. +#define RT2860_REG_SCHDMA_WPDMA_RST_IDX                0x020c
  11318.  
  11319. +#define RT2860_REG_SCHDMA_DELAY_INT_CFG                0x0210
  11320.  
  11321. +#define RT2860_REG_SCHDMA_WMM_AIFSN_CFG                0x0214
  11322.  
  11323. +#define RT2860_REG_SCHDMA_WMM_CWMIN_CFG                0x0218
  11324.  
  11325. +#define RT2860_REG_SCHDMA_WMM_CWMAX_CFG                0x021c
  11326.  
  11327. +#define RT2860_REG_SCHDMA_WMM_TXOP0_CFG                0x0220
  11328.  
  11329. +#define RT2860_REG_SCHDMA_WMM_TXOP1_CFG                0x0224
  11330.  
  11331. +#define RT2860_REG_SCHDMA_GPIO_CTRL_CFG                0x0228
  11332.  
  11333. +#define RT2860_REG_SCHDMA_RX_BASE_PTR              0x0290
  11334.  
  11335. +#define RT2860_REG_SCHDMA_RX_MAX_CNT               0x0294
  11336.  
  11337. +#define RT2860_REG_SCHDMA_RX_CALC_IDX              0x0298
  11338.  
  11339. +#define RT2860_REG_SCHDMA_RX_DRX_IDX               0x029c
  11340.  
  11341. +#define RT2860_REG_SCHDMA_TX_BASE_PTR(qid)         (0x0230 + (qid) * 16)
  11342.  
  11343. +#define RT2860_REG_SCHDMA_TX_MAX_CNT(qid)          (0x0234 + (qid) * 16)
  11344.  
  11345. +#define RT2860_REG_SCHDMA_TX_CTX_IDX(qid)          (0x0238 + (qid) * 16)
  11346.  
  11347. +#define RT2860_REG_SCHDMA_TX_DTX_IDX(qid)          (0x023c + (qid) * 16)
  11348.  
  11349. +#define RT2860_REG_SCHDMA_US_CYC_CNT               0x02a4
  11350.  
  11351. +
  11352.  
  11353. +#define RT2860_REG_PBF_SYS_CTRL                        0x0400
  11354.  
  11355. +#define RT2860_REG_PBF_HOST_CMD                        0x0404
  11356.  
  11357. +#define RT2860_REG_PBF_CFG                     0x0408
  11358.  
  11359. +#define RT2860_REG_PBF_MAX_PCNT                        0x040c
  11360.  
  11361. +#define RT2860_REG_PBF_BUF_CTRL                        0x0410
  11362.  
  11363. +#define RT2860_REG_PBF_MCU_INT_STA                 0x0414
  11364.  
  11365. +#define RT2860_REG_PBF_MCU_INT_ENA                 0x0418
  11366.  
  11367. +#define RT2860_REG_PBF_TX0Q_IO                     0x041c
  11368.  
  11369. +#define RT2860_REG_PBF_TX1Q_IO                     0x0420
  11370.  
  11371. +#define RT2860_REG_PBF_TX2Q_IO                     0x0424
  11372.  
  11373. +#define RT2860_REG_PBF_RX0Q_IO                     0x0428
  11374.  
  11375. +#define RT2860_REG_PBF_BCN_OFFSET0                 0x042c
  11376.  
  11377. +#define RT2860_REG_PBF_BCN_OFFSET1                 0x0430
  11378.  
  11379. +#define RT2860_REG_PBF_TXRXQ_STA                   0x0434
  11380.  
  11381. +#define RT2860_REG_PBF_TXRXQ_PCNT                  0x0438
  11382.  
  11383. +#define RT2860_REG_PBF_DBG                     0x043c
  11384.  
  11385. +#define RT2860_REG_PBF_CAP_CTRL                        0x0440
  11386.  
  11387. +
  11388.  
  11389. +#define RT2872_REG_RF_CSR_CFG                      0x500
  11390.  
  11391. +#define RT2872_REG_RF_SETTING                      0x504
  11392.  
  11393. +#define RT2872_REG_RF_TEST_CONTROL                 0x508
  11394.  
  11395. +
  11396.  
  11397. +#define RT2860_REG_MAC_CSR0                        0x1000
  11398.  
  11399. +#define RT2860_REG_SYS_CTRL                        0x1004
  11400.  
  11401. +#define RT2860_REG_ADDR_DW0                        0x1008
  11402.  
  11403. +#define RT2860_REG_ADDR_DW1                        0x100c
  11404.  
  11405. +#define RT2860_REG_BSSID_DW0                       0x1010
  11406.  
  11407. +#define RT2860_REG_BSSID_DW1                       0x1014
  11408.  
  11409. +#define RT2860_REG_MAX_LEN_CFG                     0x1018
  11410.  
  11411. +#define RT2860_REG_BBP_CSR_CFG                     0x101c
  11412.  
  11413. +#define RT2860_REG_RF_CSR_CFG0                     0x1020
  11414.  
  11415. +#define RT2860_REG_LED_CFG                     0x102c
  11416.  
  11417. +#define RT2860_REG_AMPDU_MAX_LEN_20M1S                 0x1030
  11418.  
  11419. +#define RT2860_REG_AMPDU_MAX_LEN_20M2S                 0x1034
  11420.  
  11421. +#define RT2860_REG_AMPDU_MAX_LEN_40M1S                 0x1038
  11422.  
  11423. +#define RT2860_REG_AMPDU_MAX_LEN_40M2S                 0x103c
  11424.  
  11425. +#define RT2860_REG_AMPDU_BA_WINSIZE                    0x1040
  11426.  
  11427. +
  11428.  
  11429. +#define RT2860_REG_XIFS_TIME_CFG                           0x1100
  11430.  
  11431. +#define RT2860_REG_BKOFF_SLOT_CFG                  0x1104
  11432.  
  11433. +#define RT2860_REG_NAV_TIME_CFG                        0x1108
  11434.  
  11435. +#define RT2860_REG_CH_TIME_CFG                     0x110c
  11436.  
  11437. +#define RT2860_REG_PBF_LIFE_TIMER                  0x1110
  11438.  
  11439. +#define RT2860_REG_BCN_TIME_CFG                        0x1114
  11440.  
  11441. +#define RT2860_REG_TBTT_SYNC_CFG                   0x1118
  11442.  
  11443. +#define RT2860_REG_TSF_TIMER_DW0                   0x111c
  11444.  
  11445. +#define RT2860_REG_TSF_TIMER_DW1                   0x1120
  11446.  
  11447. +#define RT2860_REG_TBTT_TIMER                      0x1124
  11448.  
  11449. +#define RT2860_REG_INT_TIMER                       0x1128
  11450.  
  11451. +#define RT2860_REG_INT_TIMER_EN                        0x112c
  11452.  
  11453. +#define RT2860_REG_CH_IDLE_STA                     0x1130
  11454.  
  11455. +
  11456.  
  11457. +#define RT2860_REG_STATUS_CFG                      0x1200
  11458.  
  11459. +#define RT2860_REG_PWR_PIN_CFG                     0x1204
  11460.  
  11461. +#define RT2860_REG_AUTO_WAKEUP_CFG                 0x1208
  11462.  
  11463. +
  11464.  
  11465. +#define RT2860_REG_TX_EDCA_AC_CFG(aci)                 (0x1300 + (aci) * 4)
  11466.  
  11467. +#define RT2860_REG_TX_EDCA_TID_AC_MAP                  0x1310
  11468.  
  11469. +#define RT2860_REG_TX_PWR_CFG(ridx)                    (0x1314 + (ridx) * 4)
  11470.  
  11471. +#define RT2860_REG_TX_PIN_CFG                      0x1328
  11472.  
  11473. +#define RT2860_REG_TX_BAND_CFG                     0x132c
  11474.  
  11475. +#define RT2860_REG_TX_SW_CFG0                      0x1330
  11476.  
  11477. +#define RT2860_REG_TX_SW_CFG1                      0x1334
  11478.  
  11479. +#define RT2860_REG_TX_SW_CFG2                      0x1338
  11480.  
  11481. +#define RT2860_REG_TX_TXOP_THRES_CFG                   0x133c
  11482.  
  11483. +#define RT2860_REG_TX_TXOP_CTRL_CFG                    0x1340
  11484.  
  11485. +#define RT2860_REG_TX_RTS_CFG                      0x1344
  11486.  
  11487. +#define RT2860_REG_TX_TIMEOUT_CFG                  0x1348
  11488.  
  11489. +#define RT2860_REG_TX_RTY_CFG                      0x134c
  11490.  
  11491. +#define RT2860_REG_TX_LINK_CFG                     0x1350
  11492.  
  11493. +#define RT2860_REG_TX_HT_FBK_CFG0                  0x1354
  11494.  
  11495. +#define RT2860_REG_TX_HT_FBK_CFG1                  0x1358
  11496.  
  11497. +#define RT2860_REG_TX_LG_FBK_CFG0                  0x135c
  11498.  
  11499. +#define RT2860_REG_TX_LG_FBK_CFG1                  0x1360
  11500.  
  11501. +#define RT2860_REG_TX_CCK_PROT_CFG                 0x1364
  11502.  
  11503. +#define RT2860_REG_TX_OFDM_PROT_CFG                    0x1368
  11504.  
  11505. +#define RT2860_REG_TX_MM20_PROT_CFG                    0x136c
  11506.  
  11507. +#define RT2860_REG_TX_MM40_PROT_CFG                    0x1370
  11508.  
  11509. +#define RT2860_REG_TX_GF20_PROT_CFG                    0x1374
  11510.  
  11511. +#define RT2860_REG_TX_GF40_PROT_CFG                    0x1378
  11512.  
  11513. +#define RT2860_REG_TX_EXP_CTS_TIME                 0x137c
  11514.  
  11515. +#define RT2860_REG_TX_EXP_ACK_TIME                 0x1380
  11516.  
  11517. +
  11518.  
  11519. +#define RT2860_REG_RX_FILTER_CFG                   0x1400
  11520.  
  11521. +#define RT2860_REG_AUTO_RSP_CFG                        0x1404
  11522.  
  11523. +#define RT2860_REG_LEGACY_BASIC_RATE                   0x1408
  11524.  
  11525. +#define RT2860_REG_HT_BASIC_RATE                   0x140c
  11526.  
  11527. +#define RT2860_REG_HT_CTRL_CFG                     0x1410
  11528.  
  11529. +#define RT2860_REG_SIFS_COST_CFG                   0x1414
  11530.  
  11531. +#define RT2860_REG_RX_PARSER_CFG                   0x1418
  11532.  
  11533. +
  11534.  
  11535. +#define RT2860_REG_TX_SEC_CNT0                     0x1500
  11536.  
  11537. +#define RT2860_REG_RX_SEC_CNT0                     0x1504
  11538.  
  11539. +#define RT2860_REG_CCMP_FC_MUTE                        0x1508
  11540.  
  11541. +
  11542.  
  11543. +#define RT2860_REG_HCCAPSMP_TXOP_HLDR_ADDR0                0x1600
  11544.  
  11545. +#define RT2860_REG_HCCAPSMP_TXOP_HLDR_ADDR1                0x1604
  11546.  
  11547. +#define RT2860_REG_HCCAPSMP_TXOP_HLDR_ET               0x1608
  11548.  
  11549. +#define RT2860_REG_HCCAPSMP_QOS_CFPOLL_RA_DW0              0x160c
  11550.  
  11551. +#define RT2860_REG_HCCAPSMP_QOS_CFPOLL_A1_DW1              0x1610
  11552.  
  11553. +#define RT2860_REG_HCCAPSMP_QOS_CFPOLL_QC              0x1614
  11554.  
  11555. +
  11556.  
  11557. +#define RT2860_REG_RX_STA_CNT0                     0x1700
  11558.  
  11559. +#define RT2860_REG_RX_STA_CNT1                     0x1704
  11560.  
  11561. +#define RT2860_REG_RX_STA_CNT2                     0x1708
  11562.  
  11563. +#define RT2860_REG_TX_STA_CNT0                     0x170c
  11564.  
  11565. +#define RT2860_REG_TX_STA_CNT1                     0x1710
  11566.  
  11567. +#define RT2860_REG_TX_STA_CNT2                     0x1714
  11568.  
  11569. +#define RT2860_REG_TX_STA_FIFO                     0x1718
  11570.  
  11571. +#define RT2860_REG_TX_AGG_CNT                      0x171c
  11572.  
  11573. +#define RT2860_REG_TX_AGG_CNT0                     0x1720
  11574.  
  11575. +#define RT2860_REG_TX_AGG_CNT1                     0x1724
  11576.  
  11577. +#define RT2860_REG_TX_AGG_CNT2                     0x1728
  11578.  
  11579. +#define RT2860_REG_TX_AGG_CNT3                     0x172c
  11580.  
  11581. +#define RT2860_REG_TX_AGG_CNT4                     0x1730
  11582.  
  11583. +#define RT2860_REG_TX_AGG_CNT5                     0x1734
  11584.  
  11585. +#define RT2860_REG_TX_AGG_CNT6                     0x1738
  11586.  
  11587. +#define RT2860_REG_TX_AGG_CNT7                     0x173c
  11588.  
  11589. +#define RT2860_REG_TXRX_MPDU_DEN_CNT                   0x1740
  11590.  
  11591. +
  11592.  
  11593. +#define RT2860_REG_WCID(wcid)                      (0x1800 + (wcid) * 8)
  11594.  
  11595. +#define RT2860_REG_PKEY(wcid)                      (0x4000 + (wcid) * 32)
  11596.  
  11597. +#define RT2860_REG_IVEIV(wcid)                     (0x6000 + (wcid) * 8)
  11598.  
  11599. +#define RT2860_REG_WCID_ATTR(wcid)                 (0x6800 + (wcid) * 4)
  11600.  
  11601. +#define RT2860_REG_SKEY(vap, kidx)                 (0x6c00 + ((vap) * 4 + (kidx)) * 32)
  11602.  
  11603. +#define RT2860_REG_SKEY_MODE(vap)                  (0x7000 + ((vap) / 2) * 4)
  11604.  
  11605. +
  11606.  
  11607. +#define RT2860_REG_MCU_UCODE_BASE                  0x2000
  11608.  
  11609. +
  11610.  
  11611. +#define RT2860_REG_H2M_HOST_CMD                        0x0404
  11612.  
  11613. +#define RT2860_REG_H2M_MAILBOX                     0x7010
  11614.  
  11615. +#define RT2860_REG_H2M_MAILBOX_CID                 0x7014
  11616.  
  11617. +#define RT2860_REG_H2M_MAILBOX_STATUS              0x701c
  11618.  
  11619. +#define RT2860_REG_H2M_MAILBOX_BBP_AGENT           0x7028
  11620.  
  11621. +
  11622.  
  11623. +#define RT2860_REG_BEACON_BASE(vap)                    (0x7800 + (vap) * 512)
  11624.  
  11625. +
  11626.  
  11627. +/* RT3070 registers */
  11628.  
  11629. +#define RT3070_RF_CSR_CFG      0x0500
  11630.  
  11631. +#define RT3070_EFUSE_CTRL      0x0580
  11632.  
  11633. +#define RT3070_EFUSE_DATA0     0x0590
  11634.  
  11635. +#define RT3070_EFUSE_DATA1     0x0594
  11636.  
  11637. +#define RT3070_EFUSE_DATA2     0x0598
  11638.  
  11639. +#define RT3070_EFUSE_DATA3     0x059c
  11640.  
  11641. +#define RT3090_OSC_CTRL            0x05a4
  11642.  
  11643. +#define RT3070_LDO_CFG0            0x05d4
  11644.  
  11645. +#define RT3070_GPIO_SWITCH     0x05dc
  11646.  
  11647. +
  11648.  
  11649. +#define RT3090_AUX_CTRL            0x010c
  11650.  
  11651. +#define RT3070_OPT_14          0x0114
  11652.  
  11653. +
  11654.  
  11655. +/* possible flags for register RF_CSR_CFG */
  11656.  
  11657. +#define RT3070_RF_KICK     (1 << 17)
  11658.  
  11659. +#define RT3070_RF_WRITE        (1 << 16)
  11660.  
  11661. +
  11662.  
  11663. +/* possible flags for register EFUSE_CTRL */
  11664.  
  11665. +#define RT3070_SEL_EFUSE   (1 << 31)
  11666.  
  11667. +#define RT3070_EFSROM_KICK (1 << 30)
  11668.  
  11669. +#define RT3070_EFSROM_AIN_MASK 0x03ff0000
  11670.  
  11671. +#define RT3070_EFSROM_AIN_SHIFT    16
  11672.  
  11673. +#define RT3070_EFSROM_MODE_MASK    0x000000c0
  11674.  
  11675. +#define RT3070_EFUSE_AOUT_MASK 0x0000003f
  11676.  
  11677. +
  11678.  
  11679. +/* possible flags for RT3020 RF register 1 */
  11680.  
  11681. +#define RT3070_RF_BLOCK    (1 << 0)
  11682.  
  11683. +#define RT3070_RX0_PD  (1 << 2)
  11684.  
  11685. +#define RT3070_TX0_PD  (1 << 3)
  11686.  
  11687. +#define RT3070_RX1_PD  (1 << 4)
  11688.  
  11689. +#define RT3070_TX1_PD  (1 << 5)
  11690.  
  11691. +#define RT3070_RX2_PD  (1 << 6)
  11692.  
  11693. +#define RT3070_TX2_PD  (1 << 7)
  11694.  
  11695. +
  11696.  
  11697. +/* possible flags for RT3020 RF register 1 */
  11698.  
  11699. +#define RT3070_RF_BLOCK    (1 << 0)
  11700.  
  11701. +#define RT3070_RX0_PD  (1 << 2)
  11702.  
  11703. +#define RT3070_TX0_PD  (1 << 3)
  11704.  
  11705. +#define RT3070_RX1_PD  (1 << 4)
  11706.  
  11707. +#define RT3070_TX1_PD  (1 << 5)
  11708.  
  11709. +#define RT3070_RX2_PD  (1 << 6)
  11710.  
  11711. +#define RT3070_TX2_PD  (1 << 7)
  11712.  
  11713. +
  11714.  
  11715. +/* possible flags for RT3020 RF register 7 */
  11716.  
  11717. +#define RT3070_TUNE    (1 << 0)
  11718.  
  11719. +
  11720.  
  11721. +/* possible flags for RT3020 RF register 15 */
  11722.  
  11723. +#define RT3070_TX_LO2  (1 << 3)
  11724.  
  11725. +
  11726.  
  11727. +/* possible flags for RT3020 RF register 17 */
  11728.  
  11729. +#define RT3070_TX_LO1  (1 << 3)
  11730.  
  11731. +
  11732.  
  11733. +/* possible flags for RT3020 RF register 20 */
  11734.  
  11735. +#define RT3070_RX_LO1  (1 << 3)
  11736.  
  11737. +
  11738.  
  11739. +/* possible flags for RT3020 RF register 21 */
  11740.  
  11741. +#define RT3070_RX_LO2  (1 << 3)
  11742.  
  11743. +#define RT3070_RX_CTB  (1 << 7)
  11744.  
  11745. +
  11746.  
  11747. +/* possible flags for RT3020 RF register 22 */
  11748.  
  11749. +#define RT3070_BB_LOOPBACK (1 << 0)
  11750.  
  11751. +
  11752.  
  11753. +/* possible flags for RT3053 RF register 1 */
  11754.  
  11755. +#define RT3593_VCO (1 << 0)
  11756.  
  11757. +
  11758.  
  11759. +/* possible flags for RT3053 RF register 2 */
  11760.  
  11761. +#define RT3593_RESCAL  (1 << 7)
  11762.  
  11763. +
  11764.  
  11765. +/* possible flags for RT3053 RF register 3 */
  11766.  
  11767. +#define RT3593_VCOCAL  (1 << 7)
  11768.  
  11769. +
  11770.  
  11771. +/* possible flags for RT3053 RF register 6 */
  11772.  
  11773. +#define RT3593_VCO_IC  (1 << 6)
  11774.  
  11775. +
  11776.  
  11777. +/* possible flags for RT3053 RF register 20 */
  11778.  
  11779. +#define RT3593_LDO_PLL_VC_MASK 0x0e
  11780.  
  11781. +#define RT3593_LDO_RF_VC_MASK  0xe0
  11782.  
  11783. +
  11784.  
  11785. +/* possible flags for RT3053 RF register 22 */
  11786.  
  11787. +#define RT3593_CP_IC_MASK  0xe0
  11788.  
  11789. +#define RT3593_CP_IC_SHIFT 5
  11790.  
  11791. +
  11792.  
  11793. +/* possible flags for RT3053 RF register 46 */
  11794.  
  11795. +#define RT3593_RX_CTB  (1 << 5)
  11796.  
  11797. +
  11798.  
  11799. +#define RT3090_DEF_LNA 10
  11800.  
  11801. +
  11802.  
  11803. +
  11804.  
  11805. +#define RT2860_REG_RF_R1                           0
  11806.  
  11807. +#define RT2860_REG_RF_R2                           1
  11808.  
  11809. +#define RT2860_REG_RF_R3                           2
  11810.  
  11811. +#define RT2860_REG_RF_R4                           3
  11812.  
  11813. +
  11814.  
  11815. +/*
  11816.  
  11817. + * RT2860_REG_EEPROM_CSR flags
  11818.  
  11819. + */
  11820.  
  11821. +#define RT2860_REG_EERL                                (1 << 7)
  11822.  
  11823. +#define RT2860_REG_EEDO                                (1 << 3)
  11824.  
  11825. +#define RT2860_REG_EEDI                                (1 << 2)
  11826.  
  11827. +#define RT2860_REG_EECS                                (1 << 1)
  11828.  
  11829. +#define RT2860_REG_EESK                                (1 << 0)
  11830.  
  11831. +#define RT2860_REG_EEOP_READ                       0x6
  11832.  
  11833. +
  11834.  
  11835. +/*
  11836.  
  11837. + * RT2860_REG_SCHDMA_INT_STATUS
  11838.  
  11839. + * RT2860_REG_SCHDMA_INT_MASK flags
  11840.  
  11841. + */
  11842.  
  11843. +#define RT2860_REG_INT_TX_COHERENT                 (1 << 17)
  11844.  
  11845. +#define RT2860_REG_INT_RX_COHERENT                 (1 << 16)
  11846.  
  11847. +#define RT2860_REG_INT_GP_TIMER                        (1 << 15)
  11848.  
  11849. +#define RT2860_REG_INT_AUTO_WAKEUP                 (1 << 14)
  11850.  
  11851. +#define RT2860_REG_INT_FIFO_STA_FULL               (1 << 13)
  11852.  
  11853. +#define RT2860_REG_INT_PRE_TBTT                        (1 << 12)
  11854.  
  11855. +#define RT2860_REG_INT_TBTT                            (1 << 11)
  11856.  
  11857. +#define RT2860_REG_INT_TXRX_COHERENT               (1 << 10)
  11858.  
  11859. +#define RT2860_REG_INT_MCU_CMD                     (1 << 9)
  11860.  
  11861. +#define RT2860_REG_INT_TX_MGMT_DONE                    (1 << 8)
  11862.  
  11863. +#define RT2860_REG_INT_TX_HCCA_DONE                    (1 << 7)
  11864.  
  11865. +#define RT2860_REG_INT_TX_AC3_DONE                 (1 << 6)
  11866.  
  11867. +#define RT2860_REG_INT_TX_AC2_DONE                 (1 << 5)
  11868.  
  11869. +#define RT2860_REG_INT_TX_AC1_DONE                 (1 << 4)
  11870.  
  11871. +#define RT2860_REG_INT_TX_AC0_DONE                 (1 << 3)
  11872.  
  11873. +#define RT2860_REG_INT_RX_DONE                     (1 << 2)
  11874.  
  11875. +#define RT2860_REG_INT_TX_DELAY_DONE               (1 << 1)
  11876.  
  11877. +#define RT2860_REG_INT_RX_DELAY_DONE               (1 << 0)
  11878.  
  11879. +
  11880.  
  11881. +/*
  11882.  
  11883. + * RT2860_REG_SCHDMA_WPDMA_GLO_CFG flags
  11884.  
  11885. + */
  11886.  
  11887. +#define RT2860_REG_TX_WB_DDONE                     (1 << 6)
  11888.  
  11889. +#define RT2860_REG_RX_DMA_BUSY                     (1 << 3)
  11890.  
  11891. +#define RT2860_REG_RX_DMA_ENABLE                   (1 << 2)
  11892.  
  11893. +#define RT2860_REG_TX_DMA_BUSY                     (1 << 1)
  11894.  
  11895. +#define RT2860_REG_TX_DMA_ENABLE                   (1 << 0)
  11896.  
  11897. +#define RT2860_REG_WPDMA_BT_SIZE_SHIFT             4
  11898.  
  11899. +#define RT2860_REG_WPDMA_BT_SIZE16                 0
  11900.  
  11901. +#define RT2860_REG_WPDMA_BT_SIZE32                 1
  11902.  
  11903. +#define RT2860_REG_WPDMA_BT_SIZE64                 2
  11904.  
  11905. +#define RT2860_REG_WPDMA_BT_SIZE128                    3
  11906.  
  11907. +
  11908.  
  11909. +/*
  11910.  
  11911. + * RT2860_REG_SCHDMA_WPDMA_RST_IDX flags
  11912.  
  11913. + */
  11914.  
  11915. +#define RT2860_REG_RST_IDX_RX                      (1 << 16)
  11916.  
  11917. +#define RT2860_REG_RST_IDX_TX_MGMT                 (1 << 5)
  11918.  
  11919. +#define RT2860_REG_RST_IDX_TX_HCCA                 (1 << 4)
  11920.  
  11921. +#define RT2860_REG_RST_IDX_TX_AC3                  (1 << 3)
  11922.  
  11923. +#define RT2860_REG_RST_IDX_TX_AC2                  (1 << 2)
  11924.  
  11925. +#define RT2860_REG_RST_IDX_TX_AC1                  (1 << 1)
  11926.  
  11927. +#define RT2860_REG_RST_IDX_TX_AC0                  (1 << 0)
  11928.  
  11929. +
  11930.  
  11931. +/*
  11932.  
  11933. + * RT2860_REG_SCHDMA_DELAY_INT_CFG flags
  11934.  
  11935. + */
  11936.  
  11937. +#define RT2860_REG_INT_TX_DELAY_ENABLE             (1 << 31)
  11938.  
  11939. +#define RT2860_REG_INT_TX_MAX_PINT_SHIFT           24
  11940.  
  11941. +#define RT2860_REG_INT_TX_MAX_PINT_MASK                0x7
  11942.  
  11943. +#define RT2860_REG_INT_TX_MAX_PTIME_SHIFT          16
  11944.  
  11945. +#define RT2860_REG_INT_TX_MAX_PTIME_MASK           0x8
  11946.  
  11947. +#define RT2860_REG_INT_RX_DELAY_ENABLE             (1 << 15)
  11948.  
  11949. +#define RT2860_REG_INT_RX_MAX_PINT_SHIFT           8
  11950.  
  11951. +#define RT2860_REG_INT_RX_MAX_PINT_MASK                0x7
  11952.  
  11953. +#define RT2860_REG_INT_RX_MAX_PTIME_SHIFT          0
  11954.  
  11955. +#define RT2860_REG_INT_RX_MAX_PTIME_MASK           0x8
  11956.  
  11957. +
  11958.  
  11959. +/*
  11960.  
  11961. + * RT2860_REG_PBF_SYS_CTRL flags
  11962.  
  11963. + */
  11964.  
  11965. +#define RT2860_REG_HST_PM_SEL                      (1 << 16)
  11966.  
  11967. +#define RT2860_REG_MCU_READY                       (1 << 7)
  11968.  
  11969. +#define RT2860_REG_MCU_RESET                       (1 << 0)
  11970.  
  11971. +
  11972.  
  11973. +/*
  11974.  
  11975. + * RT2860_REG_PBF_TXRXQ_PCNT flags
  11976.  
  11977. + */
  11978.  
  11979. +#define RT2860_REG_RXQ_PCNT_SHIFT                  24
  11980.  
  11981. +#define RT2860_REG_RXQ_PCNT_MASK                   0xff
  11982.  
  11983. +#define RT2860_REG_TX2Q_PCNT_SHIFT                 16
  11984.  
  11985. +#define RT2860_REG_TX2Q_PCNT_MASK                  0xff
  11986.  
  11987. +#define RT2860_REG_TX1Q_PCNT_SHIFT                 8
  11988.  
  11989. +#define RT2860_REG_TX1Q_PCNT_MASK                  0xff
  11990.  
  11991. +#define RT2860_REG_TX0Q_PCNT_SHIFT                 0
  11992.  
  11993. +#define RT2860_REG_TX0Q_PCNT_MASK                  0xff
  11994.  
  11995. +
  11996.  
  11997. +/*
  11998.  
  11999. + * RT2860_REG_SYS_CTRL flags
  12000.  
  12001. + */
  12002.  
  12003. +#define RT2860_REG_RX_ENABLE                       (1 << 3)
  12004.  
  12005. +#define RT2860_REG_TX_ENABLE                       (1 << 2)
  12006.  
  12007. +#define RT2860_REG_BBP_HRST                            (1 << 1)
  12008.  
  12009. +#define RT2860_REG_MAC_SRST                            (1 << 0)
  12010.  
  12011. +
  12012.  
  12013. +/*
  12014.  
  12015. + * RT2872_REG_RF_CSR_CFG flags
  12016.  
  12017. + */
  12018.  
  12019. +#define RT2872_REG_RF_CSR_BUSY                     (1 << 17)
  12020.  
  12021. +#define RT2872_REG_RF_CSR_KICK                     (1 << 17)
  12022.  
  12023. +#define RT2872_REG_RF_CSR_WRITE                        (1 << 16)
  12024.  
  12025. +#define RT2872_REG_RF_ID_SHIFT                     8
  12026.  
  12027. +#define RT2872_REG_RF_ID_MASK                      0x1f
  12028.  
  12029. +#define RT2872_REG_RF_VAL_SHIFT                        0
  12030.  
  12031. +#define RT2872_REG_RF_VAL_MASK                     0xff
  12032.  
  12033. +
  12034.  
  12035. +/*
  12036.  
  12037. + * RT2860_REG_BBP_CSR_CFG flags
  12038.  
  12039. + */
  12040.  
  12041. +#define RT2860_REG_BBP_RW_MODE_PARALLEL                    (1 << 19)
  12042.  
  12043. +#define RT2860_REG_BBP_PAR_DUR                     (1 << 19)
  12044.  
  12045. +#define RT2860_REG_BBP_CSR_BUSY                        (1 << 17)
  12046.  
  12047. +#define RT2860_REG_BBP_CSR_KICK                        (1 << 17)
  12048.  
  12049. +#define RT2860_REG_BBP_CSR_READ                        (1 << 16)
  12050.  
  12051. +#define RT2860_REG_BBP_REG_SHIFT                   8
  12052.  
  12053. +#define RT2860_REG_BBP_REG_MASK                        0xff
  12054.  
  12055. +#define RT2860_REG_BBP_VAL_SHIFT                   0
  12056.  
  12057. +#define RT2860_REG_BBP_VAL_MASK                        0xff
  12058.  
  12059. +
  12060.  
  12061. +/*
  12062.  
  12063. + * RT2860_REG_RF_CSR_CFG0 flags
  12064.  
  12065. + */
  12066.  
  12067. +#define RT2860_REG_RF_BUSY                         (1 << 31)
  12068.  
  12069. +
  12070.  
  12071. +/*
  12072.  
  12073. + * RT2860_REG_BCN_TIME_CFG flags
  12074.  
  12075. + */
  12076.  
  12077. +#define RT2860_REG_BCN_TX_ENABLE                   (1 << 20)
  12078.  
  12079. +#define RT2860_REG_TBTT_TIMER_ENABLE               (1 << 19)
  12080.  
  12081. +#define RT2860_REG_TSF_TIMER_ENABLE                    (1 << 16)
  12082.  
  12083. +#define RT2860_REG_TSF_SYNC_MODE_SHIFT             17
  12084.  
  12085. +#define RT2860_REG_TSF_SYNC_MODE_MASK              0x3
  12086.  
  12087. +#define RT2860_REG_TSF_SYNC_MODE_DISABLE           0
  12088.  
  12089. +#define RT2860_REG_TSF_SYNC_MODE_STA               1
  12090.  
  12091. +#define RT2860_REG_TSF_SYNC_MODE_IBSS              2
  12092.  
  12093. +#define RT2860_REG_TSF_SYNC_MODE_HOSTAP                3
  12094.  
  12095. +
  12096.  
  12097. +/*
  12098.  
  12099. + * RT2860_REG_STATUS_CFG flags
  12100.  
  12101. + */
  12102.  
  12103. +#define RT2860_REG_STATUS_RX_BUSY                  (1 << 1)
  12104.  
  12105. +#define RT2860_REG_STATUS_TX_BUSY                  (1 << 0)
  12106.  
  12107. +
  12108.  
  12109. +/*
  12110.  
  12111. + * RT2860_REG_TX_PIN_CFG flags
  12112.  
  12113. + */
  12114.  
  12115. +#define RT2860_REG_TRSW_ENABLE                     (1 << 18)
  12116.  
  12117. +#define RT2860_REG_RFTR_ENABLE                     (1 << 16)
  12118.  
  12119. +#define RT2860_REG_LNA_PE_G1_ENABLE                    (1 << 11)
  12120.  
  12121. +#define RT2860_REG_LNA_PE_A1_ENABLE                    (1 << 10)
  12122.  
  12123. +#define RT2860_REG_LNA_PE_G0_ENABLE                    (1 << 9)
  12124.  
  12125. +#define RT2860_REG_LNA_PE_A0_ENABLE                    (1 << 8)
  12126.  
  12127. +#define RT2860_REG_PA_PE_G1_ENABLE                 (1 << 3)
  12128.  
  12129. +#define RT2860_REG_PA_PE_A1_ENABLE                 (1 << 2)
  12130.  
  12131. +#define RT2860_REG_PA_PE_G0_ENABLE                 (1 << 1)
  12132.  
  12133. +#define RT2860_REG_PA_PE_A0_ENABLE                 (1 << 0)
  12134.  
  12135. +
  12136.  
  12137. +/*
  12138.  
  12139. + * RT2860_REG_TX_BAND_CFG flags
  12140.  
  12141. + */
  12142.  
  12143. +#define RT2860_REG_TX_BAND_BG                      (1 << 2)
  12144.  
  12145. +#define RT2860_REG_TX_BAND_A                       (1 << 1)
  12146.  
  12147. +#define RT2860_REG_TX_BAND_HT40_ABOVE              (1 << 0)
  12148.  
  12149. +#define RT2860_REG_TX_BAND_HT40_BELOW              (0 << 0)
  12150.  
  12151. +
  12152.  
  12153. +/*
  12154.  
  12155. + * RT2860_REG_TX_RTS_CFG flags
  12156.  
  12157. + */
  12158.  
  12159. +#define RT2860_REG_TX_RTS_THRESHOLD_SHIFT          8
  12160.  
  12161. +#define RT2860_REG_TX_RTS_THRESHOLD_MASK           0xffff
  12162.  
  12163. +
  12164.  
  12165. +/*
  12166.  
  12167. + * RT2860_REG_TX_CCK_PROT_CFG
  12168.  
  12169. + * RT2860_REG_TX_OFDM_PROT_CFG
  12170.  
  12171. + * RT2860_REG_TX_MM20_PROT_CFG
  12172.  
  12173. + * RT2860_REG_TX_MM40_PROT_CFG
  12174.  
  12175. + * RT2860_REG_TX_GF20_PROT_CFG
  12176.  
  12177. + * RT2860_REG_TX_GF40_PROT_CFG flags
  12178.  
  12179. + */
  12180.  
  12181. +#define RT2860_REG_RTSTH_ENABLE                        (1 << 26)
  12182.  
  12183. +#define RT2860_REG_TXOP_ALLOW_GF40                 (1 << 25)
  12184.  
  12185. +#define RT2860_REG_TXOP_ALLOW_GF20                 (1 << 24)
  12186.  
  12187. +#define RT2860_REG_TXOP_ALLOW_MM40                 (1 << 23)
  12188.  
  12189. +#define RT2860_REG_TXOP_ALLOW_MM20                 (1 << 22)
  12190.  
  12191. +#define RT2860_REG_TXOP_ALLOW_OFDM                 (1 << 21)
  12192.  
  12193. +#define RT2860_REG_TXOP_ALLOW_CCK                  (1 << 20)
  12194.  
  12195. +#define RT2860_REG_TXOP_ALLOW_ALL                  (0x3f << 20)
  12196.  
  12197. +#define RT2860_REG_PROT_NAV_NONE                   (0 << 18)
  12198.  
  12199. +#define RT2860_REG_PROT_NAV_SHORT                  (1 << 18)
  12200.  
  12201. +#define RT2860_REG_PROT_NAV_LONG                   (2 << 18)
  12202.  
  12203. +#define RT2860_REG_PROT_CTRL_NONE                  (0 << 16)
  12204.  
  12205. +#define RT2860_REG_PROT_CTRL_RTS_CTS               (1 << 16)
  12206.  
  12207. +#define RT2860_REG_PROT_CTRL_CTS                   (2 << 16)
  12208.  
  12209. +#define RT2860_REG_PROT_PHYMODE_SHIFT              14
  12210.  
  12211. +#define RT2860_REG_PROT_PHYMODE_MASK               0x3
  12212.  
  12213. +#define RT2860_REG_PROT_PHYMODE_CCK                    0
  12214.  
  12215. +#define RT2860_REG_PROT_PHYMODE_OFDM               1
  12216.  
  12217. +#define RT2860_REG_PROT_MCS_SHIFT                  0
  12218.  
  12219. +#define RT2860_REG_PROT_MCS_MASK                   0x7f
  12220.  
  12221. +
  12222.  
  12223. +/*
  12224.  
  12225. + * RT2860_REG_RX_FILTER_CFG flags
  12226.  
  12227. + */
  12228.  
  12229. +#define RT2860_REG_RX_FILTER_DROP_CTRL_RSV         (1 << 16)
  12230.  
  12231. +#define RT2860_REG_RX_FILTER_DROP_BAR              (1 << 15)
  12232.  
  12233. +#define RT2860_REG_RX_FILTER_DROP_BA               (1 << 14)
  12234.  
  12235. +#define RT2860_REG_RX_FILTER_DROP_PSPOLL           (1 << 13)
  12236.  
  12237. +#define RT2860_REG_RX_FILTER_DROP_RTS              (1 << 12)
  12238.  
  12239. +#define RT2860_REG_RX_FILTER_DROP_CTS              (1 << 11)
  12240.  
  12241. +#define RT2860_REG_RX_FILTER_DROP_ACK              (1 << 10)
  12242.  
  12243. +#define RT2860_REG_RX_FILTER_DROP_CFEND                (1 << 9)
  12244.  
  12245. +#define RT2860_REG_RX_FILTER_DROP_CFACK                (1 << 8)
  12246.  
  12247. +#define RT2860_REG_RX_FILTER_DROP_DUPL             (1 << 7)
  12248.  
  12249. +#define RT2860_REG_RX_FILTER_DROP_BCAST                (1 << 6)
  12250.  
  12251. +#define RT2860_REG_RX_FILTER_DROP_MCAST                (1 << 5)
  12252.  
  12253. +#define RT2860_REG_RX_FILTER_DROP_VER_ERR          (1 << 4)
  12254.  
  12255. +#define RT2860_REG_RX_FILTER_DROP_NOT_MYBSS            (1 << 3)
  12256.  
  12257. +#define RT2860_REG_RX_FILTER_DROP_UC_NOME          (1 << 2)
  12258.  
  12259. +#define RT2860_REG_RX_FILTER_DROP_PHY_ERR          (1 << 1)
  12260.  
  12261. +#define RT2860_REG_RX_FILTER_DROP_CRC_ERR          (1 << 0)
  12262.  
  12263. +
  12264.  
  12265. +/*
  12266.  
  12267. + * RT2860_REG_AUTO_RSP_CFG flags
  12268.  
  12269. + */
  12270.  
  12271. +#define RT2860_REG_CCK_SHORT_ENABLE                    (1 << 4)
  12272.  
  12273. +
  12274.  
  12275. +/*
  12276.  
  12277. + * RT2860_REG_TX_STA_FIFO flags
  12278.  
  12279. + */
  12280.  
  12281. +#define RT2860_REG_TX_STA_FIFO_MCS_SHIFT           16
  12282.  
  12283. +#define RT2860_REG_TX_STA_FIFO_MCS_MASK                0x7f
  12284.  
  12285. +#define RT2860_REG_TX_STA_FIFO_WCID_SHIFT          8
  12286.  
  12287. +#define RT2860_REG_TX_STA_FIFO_WCID_MASK           0xff
  12288.  
  12289. +#define RT2860_REG_TX_STA_FIFO_PID_SHIFT           1
  12290.  
  12291. +#define RT2860_REG_TX_STA_FIFO_PID_MASK                0xf
  12292.  
  12293. +#define RT2860_REG_TX_STA_FIFO_ACK_REQ             (1 << 7)
  12294.  
  12295. +#define RT2860_REG_TX_STA_FIFO_AGG                 (1 << 6)
  12296.  
  12297. +#define RT2860_REG_TX_STA_FIFO_TX_OK               (1 << 5)
  12298.  
  12299. +#define RT2860_REG_TX_STA_FIFO_VALID               (1 << 0)
  12300.  
  12301. +
  12302.  
  12303. +/*
  12304.  
  12305. + * RT2860_REG_WCID_ATTR flags
  12306.  
  12307. + */
  12308.  
  12309. +#define RT2860_REG_VAP_SHIFT                       4
  12310.  
  12311. +#define RT2860_REG_VAP_MASK                            0x7
  12312.  
  12313. +#define RT2860_REG_CIPHER_MODE_SHIFT               1
  12314.  
  12315. +#define RT2860_REG_CIPHER_MODE_MASK                    0x7
  12316.  
  12317. +#define RT2860_REG_CIPHER_MODE_NONE                    0
  12318.  
  12319. +#define RT2860_REG_CIPHER_MODE_WEP40               1
  12320.  
  12321. +#define RT2860_REG_CIPHER_MODE_WEP104              2
  12322.  
  12323. +#define RT2860_REG_CIPHER_MODE_TKIP                    3
  12324.  
  12325. +#define RT2860_REG_CIPHER_MODE_AES_CCMP                4
  12326.  
  12327. +#define RT2860_REG_CIPHER_MODE_CKIP40              5
  12328.  
  12329. +#define RT2860_REG_CIPHER_MODE_CKIP104             6
  12330.  
  12331. +#define RT2860_REG_CIPHER_MODE_CKIP128             7
  12332.  
  12333. +#define RT2860_REG_PKEY_ENABLE                     (1 << 0)
  12334.  
  12335. +
  12336.  
  12337. +/*
  12338.  
  12339. + * RT2860_REG_H2M_MAILBOX flags
  12340.  
  12341. + */
  12342.  
  12343. +#define RT2860_REG_H2M_BUSY                            (1 << 24)
  12344.  
  12345. +#define RT2860_REG_H2M_TOKEN_POWERSAVE             1
  12346.  
  12347. +#define RT2860_REG_H2M_TOKEN_RADIOOFF              2
  12348.  
  12349. +#define RT2860_REG_H2M_TOKEN_WAKEUP                    3
  12350.  
  12351. +#define RT2860_REG_H2M_TOKEN_NO_INTR               0xff
  12352.  
  12353. +
  12354.  
  12355. +/*
  12356.  
  12357. + * RT2860_REG_H2M_MAILBOX_CID flags
  12358.  
  12359. + */
  12360.  
  12361. +#define RT2860_REG_H2M_CID0_SHIFT                  0
  12362.  
  12363. +#define RT2860_REG_H2M_CID1_SHIFT                  8
  12364.  
  12365. +#define RT2860_REG_H2M_CID2_SHIFT                  16
  12366.  
  12367. +#define RT2860_REG_H2M_CID3_SHIFT                  24
  12368.  
  12369. +#define RT2860_REG_H2M_CID_MASK                        0xff
  12370.  
  12371. +
  12372.  
  12373. +#endif /* #ifndef _RT2860_REG_H_ */
  12374.  
  12375. diff -aruN /usr/src/sys/dev/ral/rt2860_rf.h src/sys/dev/ral/rt2860_rf.h
  12376. --- /usr/src/sys/dev/ral/rt2860_rf.h    1969-12-31 16:00:00.000000000 -0800
  12377. +++ src/sys/dev/ral/rt2860_rf.h 2011-07-05 21:51:10.000000000 -0700
  12378. @@ -0,0 +1,49 @@
  12379. +
  12380.  
  12381. +/*-
  12382.  
  12383. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  12384.  
  12385. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  12386.  
  12387. + *
  12388.  
  12389. + * Permission to use, copy, modify, and distribute this software for any
  12390.  
  12391. + * purpose with or without fee is hereby granted, provided that the above
  12392.  
  12393. + * copyright notice and this permission notice appear in all copies.
  12394.  
  12395. + *
  12396.  
  12397. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12398.  
  12399. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12400.  
  12401. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12402.  
  12403. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12404.  
  12405. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12406.  
  12407. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12408.  
  12409. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  12410.  
  12411. + */
  12412.  
  12413. +
  12414.  
  12415. +#ifndef _RT2860_RF_H_
  12416.  
  12417. +#define _RT2860_RF_H_
  12418.  
  12419. +
  12420.  
  12421. +#include <dev/ral/rt2860_softc.h>
  12422.  
  12423. +
  12424.  
  12425. +const char *rt2860_rf_name(int rf_rev);
  12426.  
  12427. +
  12428.  
  12429. +void rt2860_rf_select_chan_group(struct rt2860_softc *sc,
  12430.  
  12431. +   struct ieee80211_channel *c);
  12432.  
  12433. +
  12434.  
  12435. +void rt2860_rf_set_chan(struct rt2860_softc *sc,
  12436.  
  12437. +   struct ieee80211_channel *c);
  12438.  
  12439. +
  12440.  
  12441. +uint8_t rt3090_rf_read(struct rt2860_softc *sc, uint8_t reg);
  12442.  
  12443. +
  12444.  
  12445. +void rt3090_rf_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val);
  12446.  
  12447. +
  12448.  
  12449. +void rt3090_set_chan(struct rt2860_softc *sc, u_int chan);
  12450.  
  12451. +
  12452.  
  12453. +int rt3090_rf_init(struct rt2860_softc *sc);
  12454.  
  12455. +
  12456.  
  12457. +void rt3090_set_rx_antenna(struct rt2860_softc *, int);
  12458.  
  12459. +
  12460.  
  12461. +void rt3090_rf_wakeup(struct rt2860_softc *sc);
  12462.  
  12463. +
  12464.  
  12465. +int rt3090_filter_calib(struct rt2860_softc *sc, uint8_t init, uint8_t target,
  12466.  
  12467. +    uint8_t *val);
  12468.  
  12469. +
  12470.  
  12471. +void rt3090_rf_setup(struct rt2860_softc *sc);
  12472.  
  12473. +
  12474.  
  12475. +#endif /* #ifndef _RT2860_RF_H_ */
  12476.  
  12477. diff -aruN /usr/src/sys/dev/ral/rt2860_rxdesc.h src/sys/dev/ral/rt2860_rxdesc.h
  12478. --- /usr/src/sys/dev/ral/rt2860_rxdesc.h    1969-12-31 16:00:00.000000000 -0800
  12479. +++ src/sys/dev/ral/rt2860_rxdesc.h 2011-07-05 21:51:10.000000000 -0700
  12480. @@ -0,0 +1,62 @@
  12481. +
  12482.  
  12483. +/*-
  12484.  
  12485. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  12486.  
  12487. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  12488.  
  12489. + *
  12490.  
  12491. + * Permission to use, copy, modify, and distribute this software for any
  12492.  
  12493. + * purpose with or without fee is hereby granted, provided that the above
  12494.  
  12495. + * copyright notice and this permission notice appear in all copies.
  12496.  
  12497. + *
  12498.  
  12499. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12500.  
  12501. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12502.  
  12503. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12504.  
  12505. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12506.  
  12507. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12508.  
  12509. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12510.  
  12511. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  12512.  
  12513. + */
  12514.  
  12515. +
  12516.  
  12517. +#ifndef _RT2860_RXDESC_H_
  12518.  
  12519. +#define _RT2860_RXDESC_H_
  12520.  
  12521. +
  12522.  
  12523. +#define RT2860_RXDESC_SDL0_DDONE                       (1 << 15)
  12524.  
  12525. +
  12526.  
  12527. +#define RT2860_RXDESC_FLAGS_LAST_AMSDU                 (1 << 19)
  12528.  
  12529. +#define RT2860_RXDESC_FLAGS_CIPHER_ALG                 (1 << 18)
  12530.  
  12531. +#define RT2860_RXDESC_FLAGS_PLCP_RSSIL                 (1 << 17)
  12532.  
  12533. +#define RT2860_RXDESC_FLAGS_DECRYPTED                  (1 << 16)
  12534.  
  12535. +#define RT2860_RXDESC_FLAGS_AMPDU                      (1 << 15)
  12536.  
  12537. +#define RT2860_RXDESC_FLAGS_L2PAD                      (1 << 14)
  12538.  
  12539. +#define RT2860_RXDESC_FLAGS_RSSI                       (1 << 13)
  12540.  
  12541. +#define RT2860_RXDESC_FLAGS_HTC                            (1 << 12)
  12542.  
  12543. +#define RT2860_RXDESC_FLAGS_AMSDU                      (1 << 11)
  12544.  
  12545. +#define RT2860_RXDESC_FLAGS_CRC_ERR                        (1 << 8)
  12546.  
  12547. +#define RT2860_RXDESC_FLAGS_MYBSS                      (1 << 7)
  12548.  
  12549. +#define RT2860_RXDESC_FLAGS_BCAST                      (1 << 6)
  12550.  
  12551. +#define RT2860_RXDESC_FLAGS_MCAST                      (1 << 5)
  12552.  
  12553. +#define RT2860_RXDESC_FLAGS_U2M                            (1 << 4)
  12554.  
  12555. +#define RT2860_RXDESC_FLAGS_FRAG                       (1 << 3)
  12556.  
  12557. +#define RT2860_RXDESC_FLAGS_NULL_DATA                  (1 << 2)
  12558.  
  12559. +#define RT2860_RXDESC_FLAGS_DATA                       (1 << 1)
  12560.  
  12561. +#define RT2860_RXDESC_FLAGS_BA                         (1 << 0)
  12562.  
  12563. +
  12564.  
  12565. +#define RT2860_RXDESC_FLAGS_CIPHER_ERR_SHIFT           9
  12566.  
  12567. +#define RT2860_RXDESC_FLAGS_CIPHER_ERR_MASK                0x3
  12568.  
  12569. +#define RT2860_RXDESC_FLAGS_CIPHER_ERR_NONE                0
  12570.  
  12571. +#define RT2860_RXDESC_FLAGS_CIPHER_ERR_ICV             1
  12572.  
  12573. +#define RT2860_RXDESC_FLAGS_CIPHER_ERR_MIC             2
  12574.  
  12575. +#define RT2860_RXDESC_FLAGS_CIPHER_ERR_INVALID_KEY     3
  12576.  
  12577. +
  12578.  
  12579. +#define RT2860_RXDESC_FLAGS_PLCP_SIGNAL_SHIFT          20
  12580.  
  12581. +#define RT2860_RXDESC_FLAGS_PLCP_SIGNAL_MASK           0xfff
  12582.  
  12583. +
  12584.  
  12585. +struct rt2860_rxdesc
  12586.  
  12587. +{
  12588.  
  12589. +   uint32_t sdp0;
  12590.  
  12591. +   uint16_t sdl1;
  12592.  
  12593. +   uint16_t sdl0;
  12594.  
  12595. +   uint32_t sdp1;
  12596.  
  12597. +   uint32_t flags;
  12598.  
  12599. +} __packed;
  12600.  
  12601. +
  12602.  
  12603. +#endif /* #ifndef _RT2860_RXDESC_H_ */
  12604.  
  12605. diff -aruN /usr/src/sys/dev/ral/rt2860_rxwi.h src/sys/dev/ral/rt2860_rxwi.h
  12606. --- /usr/src/sys/dev/ral/rt2860_rxwi.h  1969-12-31 16:00:00.000000000 -0800
  12607. +++ src/sys/dev/ral/rt2860_rxwi.h   2011-07-05 21:51:10.000000000 -0700
  12608. @@ -0,0 +1,79 @@
  12609. +
  12610.  
  12611. +/*-
  12612.  
  12613. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  12614.  
  12615. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  12616.  
  12617. + *
  12618.  
  12619. + * Permission to use, copy, modify, and distribute this software for any
  12620.  
  12621. + * purpose with or without fee is hereby granted, provided that the above
  12622.  
  12623. + * copyright notice and this permission notice appear in all copies.
  12624.  
  12625. + *
  12626.  
  12627. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12628.  
  12629. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12630.  
  12631. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12632.  
  12633. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12634.  
  12635. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12636.  
  12637. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12638.  
  12639. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  12640.  
  12641. + */
  12642.  
  12643. +
  12644.  
  12645. +#ifndef _RT2860_RXWI_H_
  12646.  
  12647. +#define _RT2860_RXWI_H_
  12648.  
  12649. +
  12650.  
  12651. +#define RT2860_RXWI_KEYIDX_SHIFT           0
  12652.  
  12653. +#define RT2860_RXWI_KEYIDX_MASK                0x3
  12654.  
  12655. +
  12656.  
  12657. +#define RT2860_RXWI_BSSIDX_SHIFT           2
  12658.  
  12659. +#define RT2860_RXWI_BSSIDX_MASK                0x7
  12660.  
  12661. +
  12662.  
  12663. +#define RT2860_RXWI_UDF_SHIFT              5
  12664.  
  12665. +#define RT2860_RXWI_UDF_MASK               0x7
  12666.  
  12667. +
  12668.  
  12669. +#define RT2860_RXWI_SIZE_SHIFT             0
  12670.  
  12671. +#define RT2860_RXWI_SIZE_MASK              0xfff
  12672.  
  12673. +
  12674.  
  12675. +#define RT2860_RXWI_TID_SHIFT              12
  12676.  
  12677. +#define RT2860_RXWI_TID_MASK               0xf
  12678.  
  12679. +
  12680.  
  12681. +#define RT2860_RXWI_FRAG_SHIFT             0
  12682.  
  12683. +#define RT2860_RXWI_FRAG_MASK              0xf
  12684.  
  12685. +
  12686.  
  12687. +#define RT2860_RXWI_SEQ_SHIFT              4
  12688.  
  12689. +#define RT2860_RXWI_SEQ_MASK               0xfff
  12690.  
  12691. +
  12692.  
  12693. +#define RT2860_RXWI_MCS_SHIFT              0
  12694.  
  12695. +#define RT2860_RXWI_MCS_MASK               0x7f
  12696.  
  12697. +#define RT2860_RXWI_MCS_SHOTPRE                (1 << 3)
  12698.  
  12699. +
  12700.  
  12701. +#define RT2860_RXWI_BW_SHIFT               7
  12702.  
  12703. +#define RT2860_RXWI_BW_MASK                    0x1
  12704.  
  12705. +#define RT2860_RXWI_BW_20                  0
  12706.  
  12707. +#define RT2860_RXWI_BW_40                  1
  12708.  
  12709. +
  12710.  
  12711. +#define RT2860_RXWI_SHORTGI_SHIFT          0
  12712.  
  12713. +#define RT2860_RXWI_SHORTGI_MASK           0x1
  12714.  
  12715. +
  12716.  
  12717. +#define RT2860_RXWI_STBC_SHIFT             1
  12718.  
  12719. +#define RT2860_RXWI_STBC_MASK              0x3
  12720.  
  12721. +
  12722.  
  12723. +#define RT2860_RXWI_PHYMODE_SHIFT          6
  12724.  
  12725. +#define RT2860_RXWI_PHYMODE_MASK           0x3
  12726.  
  12727. +#define RT2860_RXWI_PHYMODE_CCK                0
  12728.  
  12729. +#define RT2860_RXWI_PHYMODE_OFDM           1
  12730.  
  12731. +#define RT2860_RXWI_PHYMODE_HT_MIXED       2
  12732.  
  12733. +#define RT2860_RXWI_PHYMODE_HT_GF          3
  12734.  
  12735. +
  12736.  
  12737. +struct rt2860_rxwi
  12738.  
  12739. +{
  12740.  
  12741. +   uint8_t wcid;
  12742.  
  12743. +   uint8_t udf_bssidx_keyidx;
  12744.  
  12745. +   uint16_t tid_size;
  12746.  
  12747. +   uint16_t seq_frag;
  12748.  
  12749. +   uint8_t bw_mcs;
  12750.  
  12751. +   uint8_t phymode_stbc_shortgi;
  12752.  
  12753. +   uint8_t rssi[3];
  12754.  
  12755. +   uint8_t reserved1;
  12756.  
  12757. +   uint8_t snr[2];
  12758.  
  12759. +   uint16_t reserved2;
  12760.  
  12761. +} __packed;
  12762.  
  12763. +
  12764.  
  12765. +#endif /* #ifndef _RT2860_RXWI_H_ */
  12766.  
  12767. diff -aruN /usr/src/sys/dev/ral/rt2860_softc.h src/sys/dev/ral/rt2860_softc.h
  12768. --- /usr/src/sys/dev/ral/rt2860_softc.h 1969-12-31 16:00:00.000000000 -0800
  12769. +++ src/sys/dev/ral/rt2860_softc.h  2011-07-05 21:51:10.000000000 -0700
  12770. @@ -0,0 +1,442 @@
  12771. +
  12772.  
  12773. +/*-
  12774.  
  12775. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  12776.  
  12777. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  12778.  
  12779. + * Copyright (c) 2011 Matto <matto@63bit.net>
  12780.  
  12781. + * Permission to use, copy, modify, and distribute this software for any
  12782.  
  12783. + * purpose with or without fee is hereby granted, provided that the above
  12784.  
  12785. + * copyright notice and this permission notice appear in all copies.
  12786.  
  12787. + *
  12788.  
  12789. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12790.  
  12791. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12792.  
  12793. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12794.  
  12795. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12796.  
  12797. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12798.  
  12799. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12800.  
  12801. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  12802.  
  12803. + */
  12804.  
  12805. +
  12806.  
  12807. +#ifndef _RT2860_SOFTC_H_
  12808.  
  12809. +#define _RT2860_SOFTC_H_
  12810.  
  12811. +
  12812.  
  12813. +#include <sys/param.h>
  12814.  
  12815. +#include <sys/sysctl.h>
  12816.  
  12817. +#include <sys/sockio.h>
  12818.  
  12819. +#include <sys/mbuf.h>
  12820.  
  12821. +#include <sys/kernel.h>
  12822.  
  12823. +#include <sys/socket.h>
  12824.  
  12825. +#include <sys/systm.h>
  12826.  
  12827. +#include <sys/malloc.h>
  12828.  
  12829. +#include <sys/taskqueue.h>
  12830.  
  12831. +#include <sys/module.h>
  12832.  
  12833. +#include <sys/bus.h>
  12834.  
  12835. +#include <sys/endian.h>
  12836.  
  12837. +
  12838.  
  12839. +#include <machine/bus.h>
  12840.  
  12841. +#include <machine/resource.h>
  12842.  
  12843. +#include <sys/rman.h>
  12844.  
  12845. +
  12846.  
  12847. +#include <net/bpf.h>
  12848.  
  12849. +#include <net/if.h>
  12850.  
  12851. +#include <net/if_arp.h>
  12852.  
  12853. +#include <net/ethernet.h>
  12854.  
  12855. +#include <net/if_dl.h>
  12856.  
  12857. +#include <net/if_media.h>
  12858.  
  12859. +#include <net/if_types.h>
  12860.  
  12861. +
  12862.  
  12863. +#include <net80211/ieee80211_var.h>
  12864.  
  12865. +#include <net80211/ieee80211_input.h>
  12866.  
  12867. +#include <net80211/ieee80211_radiotap.h>
  12868.  
  12869. +#include <net80211/ieee80211_regdomain.h>
  12870.  
  12871. +
  12872.  
  12873. +#include <dev/ral/rt2860_rxdesc.h>
  12874.  
  12875. +#include <dev/ral/rt2860_txdesc.h>
  12876.  
  12877. +#include <dev/ral/rt2860_txwi.h>
  12878.  
  12879. +#include <dev/ral/rt2860_amrr.h>
  12880.  
  12881. +
  12882.  
  12883. +#define RT2860_SOFTC_LOCK(sc)              mtx_lock(&(sc)->sc_mtx)
  12884.  
  12885. +#define RT2860_SOFTC_UNLOCK(sc)                \
  12886.  
  12887. +       mtx_unlock(&(sc)->sc_mtx)
  12888.  
  12889. +#define    RT2860_SOFTC_ASSERT_LOCKED(sc)          \
  12890.  
  12891. +       mtx_assert(&(sc)->sc_mtx, MA_OWNED)
  12892.  
  12893. +
  12894.  
  12895. +#define RT2860_SOFTC_TX_RING_LOCK(ring)            mtx_lock(&(ring)->lock)
  12896.  
  12897. +#define RT2860_SOFTC_TX_RING_UNLOCK(ring)      \
  12898.  
  12899. +       mtx_unlock(&(ring)->lock)
  12900.  
  12901. +#define    RT2860_SOFTC_TX_RING_ASSERT_LOCKED(ring)    \
  12902.  
  12903. +       mtx_assert(&(ring)->lock, MA_OWNED)
  12904.  
  12905. +
  12906.  
  12907. +#define RT2860_SOFTC_FLAGS_UCODE_LOADED            (1 << 0)
  12908.  
  12909. +
  12910.  
  12911. +#define RT2860_SOFTC_LED_OFF_COUNT         3
  12912.  
  12913. +
  12914.  
  12915. +#define RT2860_SOFTC_RSSI_OFF_COUNT            3
  12916.  
  12917. +
  12918.  
  12919. +#define RT2860_SOFTC_LNA_GAIN_COUNT            4
  12920.  
  12921. +
  12922.  
  12923. +#define RT2860_SOFTC_TXPOW_COUNT           50
  12924.  
  12925. +
  12926.  
  12927. +#define RT2860_SOFTC_TXPOW_RATE_COUNT          5
  12928.  
  12929. +
  12930.  
  12931. +#define RT2860_SOFTC_TSSI_COUNT                9
  12932.  
  12933. +
  12934.  
  12935. +#define RT2860_SOFTC_BBP_EEPROM_COUNT          8
  12936.  
  12937. +
  12938.  
  12939. +#define RT2860_SOFTC_RSSI_COUNT                3
  12940.  
  12941. +
  12942.  
  12943. +#define RT2860_SOFTC_STAID_COUNT           64
  12944.  
  12945. +
  12946.  
  12947. +#define RT2860_SOFTC_TX_RING_COUNT         6
  12948.  
  12949. +
  12950.  
  12951. +#define RT2860_SOFTC_RX_RING_DATA_COUNT            128
  12952.  
  12953. +
  12954.  
  12955. +#define RT2860_SOFTC_MAX_SCATTER           10
  12956.  
  12957. +
  12958.  
  12959. +#define RT2860_SOFTC_TX_RING_DATA_COUNT            256
  12960.  
  12961. +#define RT2860_SOFTC_TX_RING_DESC_COUNT                    \
  12962.  
  12963. +   (RT2860_SOFTC_TX_RING_DATA_COUNT * RT2860_SOFTC_MAX_SCATTER)
  12964.  
  12965. +
  12966.  
  12967. +#define RT2860_SOFTC_RX_RADIOTAP_PRESENT               \
  12968.  
  12969. +   ((1 << IEEE80211_RADIOTAP_FLAGS) |              \
  12970.  
  12971. +    (1 << IEEE80211_RADIOTAP_RATE) |               \
  12972.  
  12973. +    (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |          \
  12974.  
  12975. +    (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |           \
  12976.  
  12977. +    (1 << IEEE80211_RADIOTAP_ANTENNA) |                \
  12978.  
  12979. +    (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |           \
  12980.  
  12981. +    (1 << IEEE80211_RADIOTAP_XCHANNEL))
  12982.  
  12983. +
  12984.  
  12985. +#define RT2860_SOFTC_TX_RADIOTAP_PRESENT               \
  12986.  
  12987. +   ((1 << IEEE80211_RADIOTAP_FLAGS) |              \
  12988.  
  12989. +    (1 << IEEE80211_RADIOTAP_RATE) |               \
  12990.  
  12991. +    (1 << IEEE80211_RADIOTAP_XCHANNEL))
  12992.  
  12993. +
  12994.  
  12995. +struct rt2860_softc_rx_data
  12996.  
  12997. +{
  12998.  
  12999. +   bus_dmamap_t dma_map;
  13000.  
  13001. +   struct mbuf *m;
  13002.  
  13003. +};
  13004.  
  13005. +
  13006.  
  13007. +struct rt2860_softc_rx_ring
  13008.  
  13009. +{
  13010.  
  13011. +   bus_dma_tag_t desc_dma_tag;
  13012.  
  13013. +   bus_dmamap_t desc_dma_map;
  13014.  
  13015. +   bus_addr_t desc_phys_addr;
  13016.  
  13017. +   struct rt2860_rxdesc *desc;
  13018.  
  13019. +   bus_dma_tag_t data_dma_tag;
  13020.  
  13021. +   bus_dmamap_t spare_dma_map;
  13022.  
  13023. +   struct rt2860_softc_rx_data data[RT2860_SOFTC_RX_RING_DATA_COUNT];
  13024.  
  13025. +   int cur;
  13026.  
  13027. +};
  13028.  
  13029. +
  13030.  
  13031. +struct rt2860_softc_tx_data
  13032.  
  13033. +{
  13034.  
  13035. +   bus_dmamap_t dma_map;
  13036.  
  13037. +   struct ieee80211_node *ni;
  13038.  
  13039. +   struct mbuf *m;
  13040.  
  13041. +};
  13042.  
  13043. +
  13044.  
  13045. +struct rt2860_softc_tx_ring
  13046.  
  13047. +{
  13048.  
  13049. +   struct mtx lock;
  13050.  
  13051. +   bus_dma_tag_t desc_dma_tag;
  13052.  
  13053. +   bus_dmamap_t desc_dma_map;
  13054.  
  13055. +   bus_addr_t desc_phys_addr;
  13056.  
  13057. +   struct rt2860_txdesc *desc;
  13058.  
  13059. +   int desc_queued;
  13060.  
  13061. +   int desc_cur;
  13062.  
  13063. +   int desc_next;
  13064.  
  13065. +   bus_dma_tag_t seg0_dma_tag;
  13066.  
  13067. +   bus_dmamap_t seg0_dma_map;
  13068.  
  13069. +   bus_addr_t seg0_phys_addr;
  13070.  
  13071. +   uint8_t *seg0;
  13072.  
  13073. +   bus_dma_tag_t data_dma_tag;
  13074.  
  13075. +   struct rt2860_softc_tx_data data[RT2860_SOFTC_TX_RING_DATA_COUNT];
  13076.  
  13077. +   int data_queued;
  13078.  
  13079. +   int data_cur;
  13080.  
  13081. +   int data_next;
  13082.  
  13083. +   int qid;
  13084.  
  13085. +};
  13086.  
  13087. +
  13088.  
  13089. +struct rt2860_softc_node
  13090.  
  13091. +{
  13092.  
  13093. +   struct ieee80211_node ni;
  13094.  
  13095. +
  13096.  
  13097. +   uint8_t staid;
  13098.  
  13099. +
  13100.  
  13101. +   uint8_t last_rssi[RT2860_SOFTC_RSSI_COUNT];
  13102.  
  13103. +   int8_t last_rssi_dbm[RT2860_SOFTC_RSSI_COUNT];
  13104.  
  13105. +};
  13106.  
  13107. +
  13108.  
  13109. +struct rt2860_softc_vap
  13110.  
  13111. +{
  13112.  
  13113. +   struct ieee80211vap vap;
  13114.  
  13115. +
  13116.  
  13117. +   struct ieee80211_beacon_offsets beacon_offsets;
  13118.  
  13119. +   struct mbuf *beacon_mbuf;
  13120.  
  13121. +   struct rt2860_txwi beacon_txwi;
  13122.  
  13123. +
  13124.  
  13125. +   struct rt2860_amrr amrr;
  13126.  
  13127. +
  13128.  
  13129. +   int (*newstate)(struct ieee80211vap *vap,
  13130.  
  13131. +       enum ieee80211_state nstate, int arg);
  13132.  
  13133. +};
  13134.  
  13135. +
  13136.  
  13137. +struct rt2860_softc_rx_radiotap_header
  13138.  
  13139. +{
  13140.  
  13141. +   struct ieee80211_radiotap_header ihdr;
  13142.  
  13143. +   uint8_t flags;
  13144.  
  13145. +   uint8_t rate;
  13146.  
  13147. +   int8_t dbm_antsignal;
  13148.  
  13149. +   int8_t dbm_antnoise;
  13150.  
  13151. +   uint8_t antenna;
  13152.  
  13153. +   uint8_t antsignal;
  13154.  
  13155. +   uint8_t pad[2];
  13156.  
  13157. +   uint32_t chan_flags;
  13158.  
  13159. +   uint16_t chan_freq;
  13160.  
  13161. +   uint8_t chan_ieee;
  13162.  
  13163. +   int8_t chan_maxpow;
  13164.  
  13165. +} __packed;
  13166.  
  13167. +
  13168.  
  13169. +struct rt2860_softc_tx_radiotap_header
  13170.  
  13171. +{
  13172.  
  13173. +   struct ieee80211_radiotap_header ihdr;
  13174.  
  13175. +   uint8_t flags;
  13176.  
  13177. +   uint8_t rate;
  13178.  
  13179. +   uint8_t pad[2];
  13180.  
  13181. +   uint32_t chan_flags;
  13182.  
  13183. +   uint16_t chan_freq;
  13184.  
  13185. +   uint8_t chan_ieee;
  13186.  
  13187. +   int8_t chan_maxpow;
  13188.  
  13189. +} __packed;
  13190.  
  13191. +
  13192.  
  13193. +struct rt2860_softc
  13194.  
  13195. +{
  13196.  
  13197. +
  13198.  
  13199. +        struct ifnet       *sc_ifp;
  13200.  
  13201. +   device_t        sc_dev;
  13202.  
  13203. +   bus_space_tag_t     sc_st;
  13204.  
  13205. +   bus_space_handle_t  sc_sh;
  13206.  
  13207. +
  13208.  
  13209. +   struct mtx      sc_mtx;
  13210.  
  13211. +
  13212.  
  13213. +   struct callout      watchdog_ch;
  13214.  
  13215. +   int         sc_id;
  13216.  
  13217. +   int         sc_tx_timer;
  13218.  
  13219. +   int                     sc_invalid;
  13220.  
  13221. +   int         sc_debug;
  13222.  
  13223. +
  13224.  
  13225. +
  13226.  
  13227. +   uint32_t flags;
  13228.  
  13229. +/*
  13230.  
  13231. +   int mem_rid;
  13232.  
  13233. +   struct resource *mem;
  13234.  
  13235. +
  13236.  
  13237. +   int irq_rid;
  13238.  
  13239. +   struct resource *irq;
  13240.  
  13241. +*/
  13242.  
  13243. +   void *irqh;
  13244.  
  13245. +
  13246.  
  13247. +   int if_flags;
  13248.  
  13249. +
  13250.  
  13251. +   int nvaps;
  13252.  
  13253. +   int napvaps;
  13254.  
  13255. +   int nadhocvaps;
  13256.  
  13257. +   int nstavaps;
  13258.  
  13259. +   int nwdsvaps;
  13260.  
  13261. +
  13262.  
  13263. +   void (*node_cleanup)(struct ieee80211_node *ni);
  13264.  
  13265. +
  13266.  
  13267. +   int (*recv_action)(struct ieee80211_node *ni,
  13268.  
  13269. +       const struct ieee80211_frame *wh,
  13270.  
  13271. +       const uint8_t *frm, const uint8_t *efrm);
  13272.  
  13273. +
  13274.  
  13275. +   int (*send_action)(struct ieee80211_node *ni,
  13276.  
  13277. +       int cat, int act, void *sa);
  13278.  
  13279. +
  13280.  
  13281. +   int (*addba_response)(struct ieee80211_node *ni,
  13282.  
  13283. +       struct ieee80211_tx_ampdu *tap,
  13284.  
  13285. +       int status, int baparamset, int batimeout);
  13286.  
  13287. +
  13288.  
  13289. +   void (*addba_stop)(struct ieee80211_node *ni,
  13290.  
  13291. +       struct ieee80211_tx_ampdu *tap);
  13292.  
  13293. +
  13294.  
  13295. +   int (*ampdu_rx_start)(struct ieee80211_node *ni,
  13296.  
  13297. +       struct ieee80211_rx_ampdu *rap,
  13298.  
  13299. +       int baparamset, int batimeout, int baseqctl);
  13300.  
  13301. +
  13302.  
  13303. +   void (*ampdu_rx_stop)(struct ieee80211_node *ni,
  13304.  
  13305. +       struct ieee80211_rx_ampdu *rap);
  13306.  
  13307. +
  13308.  
  13309. +   struct rt2860_amrr_node amrr_node[RT2860_SOFTC_STAID_COUNT];
  13310.  
  13311. +
  13312.  
  13313. +   uint32_t mac_rev;
  13314.  
  13315. +   uint8_t eeprom_addr_num;
  13316.  
  13317. +   uint16_t eeprom_rev;
  13318.  
  13319. +   uint8_t rf_rev;
  13320.  
  13321. +
  13322.  
  13323. +   uint8_t mac_addr[IEEE80211_ADDR_LEN];
  13324.  
  13325. +
  13326.  
  13327. +   uint8_t ntxpath;
  13328.  
  13329. +   uint8_t nrxpath;
  13330.  
  13331. +
  13332.  
  13333. +   int hw_radio_cntl;
  13334.  
  13335. +   int tx_agc_cntl;
  13336.  
  13337. +   int ext_lna_2ghz;
  13338.  
  13339. +   int ext_lna_5ghz;
  13340.  
  13341. +
  13342.  
  13343. +   uint8_t country_2ghz;
  13344.  
  13345. +   uint8_t country_5ghz;
  13346.  
  13347. +
  13348.  
  13349. +   uint8_t rf_freq_off;
  13350.  
  13351. +
  13352.  
  13353. +   uint8_t led_cntl;
  13354.  
  13355. +   uint16_t led_off[RT2860_SOFTC_LED_OFF_COUNT];
  13356.  
  13357. +
  13358.  
  13359. +   int8_t rssi_off_2ghz[RT2860_SOFTC_RSSI_OFF_COUNT];
  13360.  
  13361. +   int8_t rssi_off_5ghz[RT2860_SOFTC_RSSI_OFF_COUNT];
  13362.  
  13363. +
  13364.  
  13365. +   int8_t lna_gain[RT2860_SOFTC_LNA_GAIN_COUNT];
  13366.  
  13367. +
  13368.  
  13369. +   int8_t txpow1[RT2860_SOFTC_TXPOW_COUNT];
  13370.  
  13371. +   int8_t txpow2[RT2860_SOFTC_TXPOW_COUNT];
  13372.  
  13373. +
  13374.  
  13375. +   int8_t txpow_rate_delta_2ghz;
  13376.  
  13377. +   int8_t txpow_rate_delta_5ghz;
  13378.  
  13379. +   uint32_t txpow_rate_20mhz[RT2860_SOFTC_TXPOW_RATE_COUNT];
  13380.  
  13381. +   uint32_t txpow_rate_40mhz_2ghz[RT2860_SOFTC_TXPOW_RATE_COUNT];
  13382.  
  13383. +   uint32_t txpow_rate_40mhz_5ghz[RT2860_SOFTC_TXPOW_RATE_COUNT];
  13384.  
  13385. +
  13386.  
  13387. +   int tx_agc_cntl_2ghz;
  13388.  
  13389. +   int tx_agc_cntl_5ghz;
  13390.  
  13391. +
  13392.  
  13393. +   uint8_t tssi_2ghz[RT2860_SOFTC_TSSI_COUNT];
  13394.  
  13395. +   uint8_t tssi_step_2ghz;
  13396.  
  13397. +   uint8_t tssi_5ghz[RT2860_SOFTC_TSSI_COUNT];
  13398.  
  13399. +   uint8_t tssi_step_5ghz;
  13400.  
  13401. +
  13402.  
  13403. +   struct
  13404.  
  13405. +   {
  13406.  
  13407. +       uint8_t val;
  13408.  
  13409. +       uint8_t reg;
  13410.  
  13411. +   } __packed bbp_eeprom[RT2860_SOFTC_BBP_EEPROM_COUNT], rf[10];
  13412.  
  13413. +
  13414.  
  13415. +   uint16_t powersave_level;
  13416.  
  13417. +
  13418.  
  13419. +   uint8_t staid_mask[RT2860_SOFTC_STAID_COUNT / NBBY];
  13420.  
  13421. +
  13422.  
  13423. +   uint32_t intr_enable_mask;
  13424.  
  13425. +   uint32_t intr_disable_mask;
  13426.  
  13427. +   uint32_t intr_pending_mask;
  13428.  
  13429. +
  13430.  
  13431. +   struct task rx_done_task;
  13432.  
  13433. +   int rx_process_limit;
  13434.  
  13435. +
  13436.  
  13437. +   struct task tx_done_task;
  13438.  
  13439. +
  13440.  
  13441. +   struct task fifo_sta_full_task;
  13442.  
  13443. +
  13444.  
  13445. +   struct task periodic_task;
  13446.  
  13447. +   struct callout periodic_ch;
  13448.  
  13449. +   unsigned long periodic_round;
  13450.  
  13451. +
  13452.  
  13453. +   struct taskqueue *taskqueue;
  13454.  
  13455. +
  13456.  
  13457. +   struct rt2860_softc_rx_ring rx_ring;
  13458.  
  13459. +
  13460.  
  13461. +   struct rt2860_softc_tx_ring tx_ring[RT2860_SOFTC_TX_RING_COUNT];
  13462.  
  13463. +   int tx_ring_mgtqid;
  13464.  
  13465. +
  13466.  
  13467. +   struct callout tx_watchdog_ch;
  13468.  
  13469. +   int tx_timer;
  13470.  
  13471. +
  13472.  
  13473. +   struct rt2860_softc_rx_radiotap_header rxtap;
  13474.  
  13475. +   struct rt2860_softc_tx_radiotap_header txtap;
  13476.  
  13477. +
  13478.  
  13479. +   /* statistic counters */
  13480.  
  13481. +
  13482.  
  13483. +   unsigned long interrupts;
  13484.  
  13485. +   unsigned long tx_coherent_interrupts;
  13486.  
  13487. +   unsigned long rx_coherent_interrupts;
  13488.  
  13489. +   unsigned long txrx_coherent_interrupts;
  13490.  
  13491. +   unsigned long fifo_sta_full_interrupts;
  13492.  
  13493. +   unsigned long rx_interrupts;
  13494.  
  13495. +   unsigned long rx_delay_interrupts;
  13496.  
  13497. +   unsigned long tx_interrupts[RT2860_SOFTC_TX_RING_COUNT];
  13498.  
  13499. +   unsigned long tx_delay_interrupts;
  13500.  
  13501. +   unsigned long pre_tbtt_interrupts;
  13502.  
  13503. +   unsigned long tbtt_interrupts;
  13504.  
  13505. +   unsigned long mcu_cmd_interrupts;
  13506.  
  13507. +   unsigned long auto_wakeup_interrupts;
  13508.  
  13509. +   unsigned long gp_timer_interrupts;
  13510.  
  13511. +
  13512.  
  13513. +   unsigned long tx_data_queue_full[RT2860_SOFTC_TX_RING_COUNT];
  13514.  
  13515. +
  13516.  
  13517. +   unsigned long tx_watchdog_timeouts;
  13518.  
  13519. +
  13520.  
  13521. +   unsigned long tx_defrag_packets;
  13522.  
  13523. +
  13524.  
  13525. +   unsigned long no_tx_desc_avail;
  13526.  
  13527. +
  13528.  
  13529. +   unsigned long rx_mbuf_alloc_errors;
  13530.  
  13531. +   unsigned long rx_mbuf_dmamap_errors;
  13532.  
  13533. +
  13534.  
  13535. +   unsigned long tx_queue_not_empty[2];
  13536.  
  13537. +
  13538.  
  13539. +   unsigned long tx_beacons;
  13540.  
  13541. +   unsigned long tx_noretryok;
  13542.  
  13543. +   unsigned long tx_retryok;
  13544.  
  13545. +   unsigned long tx_failed;
  13546.  
  13547. +   unsigned long tx_underflows;
  13548.  
  13549. +   unsigned long tx_zerolen;
  13550.  
  13551. +   unsigned long tx_nonagg;
  13552.  
  13553. +   unsigned long tx_agg;
  13554.  
  13555. +   unsigned long tx_ampdu;
  13556.  
  13557. +   unsigned long tx_mpdu_zero_density;
  13558.  
  13559. +   unsigned long tx_ampdu_sessions;
  13560.  
  13561. +
  13562.  
  13563. +   unsigned long rx_packets;
  13564.  
  13565. +   unsigned long rx_ampdu;
  13566.  
  13567. +   unsigned long rx_ampdu_retries;
  13568.  
  13569. +   unsigned long rx_mpdu_zero_density;
  13570.  
  13571. +   unsigned long rx_ampdu_sessions;
  13572.  
  13573. +   unsigned long rx_amsdu;
  13574.  
  13575. +   unsigned long rx_crc_errors;
  13576.  
  13577. +   unsigned long rx_phy_errors;
  13578.  
  13579. +   unsigned long rx_false_ccas;
  13580.  
  13581. +   unsigned long rx_plcp_errors;
  13582.  
  13583. +   unsigned long rx_dup_packets;
  13584.  
  13585. +   unsigned long rx_fifo_overflows;
  13586.  
  13587. +   unsigned long rx_cipher_no_errors;
  13588.  
  13589. +   unsigned long rx_cipher_icv_errors;
  13590.  
  13591. +   unsigned long rx_cipher_mic_errors;
  13592.  
  13593. +   unsigned long rx_cipher_invalid_key_errors;
  13594.  
  13595. +
  13596.  
  13597. +   int tx_stbc;
  13598.  
  13599. +
  13600.  
  13601. +   uint8_t rf24_20mhz;
  13602.  
  13603. +   uint8_t rf24_40mhz;
  13604.  
  13605. +   uint8_t patch_dac;
  13606.  
  13607. +   uint8_t txmixgain_2ghz;
  13608.  
  13609. +   uint8_t txmixgain_5ghz;
  13610.  
  13611. +
  13612.  
  13613. +#ifdef RT2860_DEBUG
  13614.  
  13615. +   int debug;
  13616.  
  13617. +#endif
  13618.  
  13619. +};
  13620.  
  13621. +
  13622.  
  13623. +
  13624.  
  13625. +int rt2860_attach(device_t dev,int ignore);
  13626.  
  13627. +
  13628.  
  13629. +int rt2860_detach(void *xsc);
  13630.  
  13631. +
  13632.  
  13633. +void rt2860_shutdown(void *xsc);
  13634.  
  13635. +
  13636.  
  13637. +void rt2860_suspend(void *xsc);
  13638.  
  13639. +
  13640.  
  13641. +void rt2860_resume(void *xsc);
  13642.  
  13643. +
  13644.  
  13645. +void rt2860_intr(void *arg);
  13646.  
  13647. +
  13648.  
  13649. +
  13650.  
  13651. +#endif /* #ifndef _RT2860_SOFTC_H_ */
  13652.  
  13653. +
  13654.  
  13655. diff -aruN /usr/src/sys/dev/ral/rt2860_txdesc.h src/sys/dev/ral/rt2860_txdesc.h
  13656. --- /usr/src/sys/dev/ral/rt2860_txdesc.h    1969-12-31 16:00:00.000000000 -0800
  13657. +++ src/sys/dev/ral/rt2860_txdesc.h 2011-07-05 21:51:10.000000000 -0700
  13658. @@ -0,0 +1,48 @@
  13659. +
  13660.  
  13661. +/*-
  13662.  
  13663. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  13664.  
  13665. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  13666.  
  13667. + *
  13668.  
  13669. + * Permission to use, copy, modify, and distribute this software for any
  13670.  
  13671. + * purpose with or without fee is hereby granted, provided that the above
  13672.  
  13673. + * copyright notice and this permission notice appear in all copies.
  13674.  
  13675. + *
  13676.  
  13677. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13678.  
  13679. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13680.  
  13681. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13682.  
  13683. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13684.  
  13685. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13686.  
  13687. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13688.  
  13689. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13690.  
  13691. + */
  13692.  
  13693. +
  13694.  
  13695. +#ifndef _RT2860_TXDESC_H_
  13696.  
  13697. +#define _RT2860_TXDESC_H_
  13698.  
  13699. +
  13700.  
  13701. +#define RT2860_TXDESC_SDL1_BURST                       (1 << 15)
  13702.  
  13703. +#define RT2860_TXDESC_SDL1_LASTSEG                     (1 << 14)
  13704.  
  13705. +
  13706.  
  13707. +#define RT2860_TXDESC_SDL0_DDONE                       (1 << 15)
  13708.  
  13709. +#define RT2860_TXDESC_SDL0_LASTSEG                     (1 << 14)
  13710.  
  13711. +
  13712.  
  13713. +#define RT2860_TXDESC_FLAGS_SHIFT                      0
  13714.  
  13715. +#define RT2860_TXDESC_FLAGS_MASK                       0xf9
  13716.  
  13717. +#define RT2860_TXDESC_FLAGS_WI_VALID                   (1 << 0)
  13718.  
  13719. +
  13720.  
  13721. +#define RT2860_TXDESC_QSEL_SHIFT                       1
  13722.  
  13723. +#define RT2860_TXDESC_QSEL_MASK                            0x3
  13724.  
  13725. +#define RT2860_TXDESC_QSEL_MGMT                            0
  13726.  
  13727. +#define RT2860_TXDESC_QSEL_HCCA                            1
  13728.  
  13729. +#define RT2860_TXDESC_QSEL_EDCA                            2
  13730.  
  13731. +
  13732.  
  13733. +struct rt2860_txdesc
  13734.  
  13735. +{
  13736.  
  13737. +   uint32_t sdp0;
  13738.  
  13739. +   uint16_t sdl1;
  13740.  
  13741. +   uint16_t sdl0;
  13742.  
  13743. +   uint32_t sdp1;
  13744.  
  13745. +   uint8_t reserved[3];
  13746.  
  13747. +   uint8_t qsel_flags;
  13748.  
  13749. +} __packed;
  13750.  
  13751. +
  13752.  
  13753. +#endif /* #ifndef _RT2860_TXDESC_H_ */
  13754.  
  13755. diff -aruN /usr/src/sys/dev/ral/rt2860_txwi.h src/sys/dev/ral/rt2860_txwi.h
  13756. --- /usr/src/sys/dev/ral/rt2860_txwi.h  1969-12-31 16:00:00.000000000 -0800
  13757. +++ src/sys/dev/ral/rt2860_txwi.h   2011-07-05 21:51:10.000000000 -0700
  13758. @@ -0,0 +1,92 @@
  13759. +
  13760.  
  13761. +/*-
  13762.  
  13763. + * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com>
  13764.  
  13765. + * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
  13766.  
  13767. + *
  13768.  
  13769. + * Permission to use, copy, modify, and distribute this software for any
  13770.  
  13771. + * purpose with or without fee is hereby granted, provided that the above
  13772.  
  13773. + * copyright notice and this permission notice appear in all copies.
  13774.  
  13775. + *
  13776.  
  13777. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13778.  
  13779. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13780.  
  13781. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13782.  
  13783. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13784.  
  13785. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13786.  
  13787. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13788.  
  13789. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13790.  
  13791. + */
  13792.  
  13793. +
  13794.  
  13795. +#ifndef _RT2860_TXWI_H_
  13796.  
  13797. +#define _RT2860_TXWI_H_
  13798.  
  13799. +
  13800.  
  13801. +#define RT2860_TXWI_FLAGS_SHIFT                    0
  13802.  
  13803. +#define RT2860_TXWI_FLAGS_MASK                 0x1f
  13804.  
  13805. +#define RT2860_TXWI_FLAGS_AMPDU                    (1 << 4)
  13806.  
  13807. +#define RT2860_TXWI_FLAGS_TS                   (1 << 3)
  13808.  
  13809. +#define RT2860_TXWI_FLAGS_CFACK                    (1 << 2)
  13810.  
  13811. +#define RT2860_TXWI_FLAGS_MIMOPS               (1 << 1)
  13812.  
  13813. +#define RT2860_TXWI_FLAGS_FRAG                 (1 << 0)
  13814.  
  13815. +
  13816.  
  13817. +#define RT2860_TXWI_MPDU_DENSITY_SHIFT         5
  13818.  
  13819. +#define RT2860_TXWI_MPDU_DENSITY_MASK          0x7
  13820.  
  13821. +
  13822.  
  13823. +#define RT2860_TXWI_TXOP_SHIFT                 0
  13824.  
  13825. +#define RT2860_TXWI_TXOP_MASK                  0x3
  13826.  
  13827. +#define RT2860_TXWI_TXOP_HT                        0
  13828.  
  13829. +#define RT2860_TXWI_TXOP_PIFS                  1
  13830.  
  13831. +#define RT2860_TXWI_TXOP_SIFS                  2
  13832.  
  13833. +#define RT2860_TXWI_TXOP_BACKOFF               3
  13834.  
  13835. +
  13836.  
  13837. +#define RT2860_TXWI_MCS_SHIFT                  0
  13838.  
  13839. +#define RT2860_TXWI_MCS_MASK                   0x7f
  13840.  
  13841. +#define RT2860_TXWI_MCS_SHOTPRE                    (1 << 3)
  13842.  
  13843. +
  13844.  
  13845. +#define RT2860_TXWI_BW_SHIFT                   7
  13846.  
  13847. +#define RT2860_TXWI_BW_MASK                        0x1
  13848.  
  13849. +#define RT2860_TXWI_BW_20                      0
  13850.  
  13851. +#define RT2860_TXWI_BW_40                      1
  13852.  
  13853. +
  13854.  
  13855. +#define RT2860_TXWI_SHORTGI_SHIFT              0
  13856.  
  13857. +#define RT2860_TXWI_SHORTGI_MASK               0x1
  13858.  
  13859. +
  13860.  
  13861. +#define RT2860_TXWI_STBC_SHIFT                 1
  13862.  
  13863. +#define RT2860_TXWI_STBC_MASK                  0x3
  13864.  
  13865. +
  13866.  
  13867. +#define RT2860_TXWI_IFS_SHIFT                  3
  13868.  
  13869. +#define RT2860_TXWI_IFS_MASK                   0x1
  13870.  
  13871. +
  13872.  
  13873. +#define RT2860_TXWI_PHYMODE_SHIFT              6
  13874.  
  13875. +#define RT2860_TXWI_PHYMODE_MASK               0x3
  13876.  
  13877. +#define RT2860_TXWI_PHYMODE_CCK                    0
  13878.  
  13879. +#define RT2860_TXWI_PHYMODE_OFDM               1
  13880.  
  13881. +#define RT2860_TXWI_PHYMODE_HT_MIXED           2
  13882.  
  13883. +#define RT2860_TXWI_PHYMODE_HT_GF              3
  13884.  
  13885. +
  13886.  
  13887. +#define RT2860_TXWI_XFLAGS_SHIFT               0
  13888.  
  13889. +#define RT2860_TXWI_XFLAGS_MASK                    0x3
  13890.  
  13891. +#define RT2860_TXWI_XFLAGS_NSEQ                    (1 << 1)
  13892.  
  13893. +#define RT2860_TXWI_XFLAGS_ACK                 (1 << 0)
  13894.  
  13895. +
  13896.  
  13897. +#define RT2860_TXWI_BAWIN_SIZE_SHIFT           2
  13898.  
  13899. +#define RT2860_TXWI_BAWIN_SIZE_MASK                0x3f
  13900.  
  13901. +
  13902.  
  13903. +#define RT2860_TXWI_MPDU_LEN_SHIFT             0
  13904.  
  13905. +#define RT2860_TXWI_MPDU_LEN_MASK              0xfff
  13906.  
  13907. +
  13908.  
  13909. +#define RT2860_TXWI_PID_SHIFT                  12
  13910.  
  13911. +#define RT2860_TXWI_PID_MASK                   0xf
  13912.  
  13913. +
  13914.  
  13915. +struct rt2860_txwi
  13916.  
  13917. +{
  13918.  
  13919. +   uint8_t mpdu_density_flags;
  13920.  
  13921. +   uint8_t txop;
  13922.  
  13923. +   uint8_t bw_mcs;
  13924.  
  13925. +   uint8_t phymode_ifs_stbc_shortgi;
  13926.  
  13927. +   uint8_t bawin_size_xflags;
  13928.  
  13929. +   uint8_t wcid;
  13930.  
  13931. +   uint16_t pid_mpdu_len;
  13932.  
  13933. +   uint32_t iv;
  13934.  
  13935. +   uint32_t eiv;
  13936.  
  13937. +} __packed;
  13938.  
  13939. +
  13940.  
  13941. +#endif /* #ifndef _RT2860_TXWI_H_ */
  13942.  
  13943. diff -aruN /usr/src/sys/dev/ral/rt2860_ucode.h src/sys/dev/ral/rt2860_ucode.h
  13944. --- /usr/src/sys/dev/ral/rt2860_ucode.h 1969-12-31 16:00:00.000000000 -0800
  13945. +++ src/sys/dev/ral/rt2860_ucode.h  2011-07-05 21:51:10.000000000 -0700
  13946. @@ -0,0 +1,2104 @@
  13947. +
  13948.  
  13949. +/*
  13950.  
  13951. + Copyright (c) 2007, Ralink Technology Corporation
  13952.  
  13953. + All rights reserved.
  13954.  
  13955. +
  13956.  
  13957. + Redistribution.  Redistribution and use in binary form, without
  13958.  
  13959. + modification, are permitted provided that the following conditions are
  13960.  
  13961. + met:
  13962.  
  13963. +
  13964.  
  13965. +   * Redistributions must reproduce the above copyright notice and the
  13966.  
  13967. +   following disclaimer in the documentation and/or other materials
  13968.  
  13969. +   provided with the distribution.
  13970.  
  13971. +   * Neither the name of Ralink Technology Corporation nor the names of its
  13972.  
  13973. +   suppliers may be used to endorse or promote products derived from this
  13974.  
  13975. +   software without specific prior written permission.
  13976.  
  13977. +   * No reverse engineering, decompilation, or disassembly of this software
  13978.  
  13979. +   is permitted.
  13980.  
  13981. +
  13982.  
  13983. + Limited patent license. Ralink Technology Corporation grants a world-wide,
  13984.  
  13985. + royalty-free, non-exclusive license under patents it now or hereafter
  13986.  
  13987. + owns or controls to make, have made, use, import, offer to sell and
  13988.  
  13989. + sell ("Utilize") this software, but solely to the extent that any
  13990.  
  13991. + such patent is necessary to Utilize the software alone, or in
  13992.  
  13993. + combination with an operating system licensed under an approved Open
  13994.  
  13995. + Source license as listed by the Open Source Initiative at
  13996.  
  13997. + http://opensource.org/licenses.  The patent license shall not apply to
  13998.  
  13999. + any other combinations which include this software.  No hardware per
  14000.  
  14001. + se is licensed hereunder.
  14002.  
  14003. +
  14004.  
  14005. + DISCLAIMER.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  14006.  
  14007. + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  14008.  
  14009. + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  14010.  
  14011. + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  14012.  
  14013. + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14014.  
  14015. + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  14016.  
  14017. + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  14018.  
  14019. + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14020.  
  14021. + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14022.  
  14023. + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  14024.  
  14025. + USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  14026.  
  14027. + DAMAGE.
  14028.  
  14029. +*/
  14030.  
  14031. +
  14032.  
  14033. +#ifndef _RT2860_UCODE_H_
  14034.  
  14035. +#define _RT2860_UCODE_H_
  14036.  
  14037. +
  14038.  
  14039. +/*
  14040.  
  14041. + * RT2860 microcode v26
  14042.  
  14043. + */
  14044.  
  14045. +static const uint8_t rt2860_ucode[] =
  14046.  
  14047. +{
  14048.  
  14049. +   0x02, 0x03, 0x5E, 0x02,
  14050.  
  14051. +   0x02, 0xB1, 0x22, 0x22,
  14052.  
  14053. +   0xFF, 0xFF, 0xFF, 0x02,
  14054.  
  14055. +   0x01, 0x82, 0xFF, 0xFF,
  14056.  
  14057. +   0xFF, 0xFF, 0xFF, 0x02,
  14058.  
  14059. +   0x00, 0x1E, 0xFF, 0xFF,
  14060.  
  14061. +   0xFF, 0xFF, 0xFF, 0x02,
  14062.  
  14063. +   0x01, 0x33, 0xC0, 0xE0,
  14064.  
  14065. +   0xC0, 0xF0, 0xC0, 0x83,
  14066.  
  14067. +   0xC0, 0x82, 0xC0, 0xD0,
  14068.  
  14069. +   0x75, 0xD0, 0x18, 0xC2,
  14070.  
  14071. +   0xAF, 0x30, 0x45, 0x03,
  14072.  
  14073. +   0x12, 0x10, 0x09, 0x90,
  14074.  
  14075. +   0x04, 0x16, 0xE0, 0x30,
  14076.  
  14077. +   0xE3, 0x03, 0x74, 0x08,
  14078.  
  14079. +   0xF0, 0x90, 0x04, 0x14,
  14080.  
  14081. +   0xE0, 0x20, 0xE7, 0x03,
  14082.  
  14083. +   0x02, 0x00, 0xCB, 0x74,
  14084.  
  14085. +   0x80, 0xF0, 0x90, 0x70,
  14086.  
  14087. +   0x12, 0xE0, 0xF5, 0x2F,
  14088.  
  14089. +   0x90, 0x04, 0x04, 0xE0,
  14090.  
  14091. +   0x24, 0xCF, 0x60, 0x30,
  14092.  
  14093. +   0x14, 0x60, 0x42, 0x24,
  14094.  
  14095. +   0xE2, 0x60, 0x47, 0x14,
  14096.  
  14097. +   0x60, 0x55, 0x24, 0x21,
  14098.  
  14099. +   0x70, 0x60, 0xE5, 0x55,
  14100.  
  14101. +   0x24, 0xFE, 0x60, 0x07,
  14102.  
  14103. +   0x14, 0x60, 0x08, 0x24,
  14104.  
  14105. +   0x02, 0x70, 0x08, 0x7D,
  14106.  
  14107. +   0x01, 0x80, 0x28, 0x7D,
  14108.  
  14109. +   0x02, 0x80, 0x24, 0x90,
  14110.  
  14111. +   0x70, 0x10, 0xE0, 0xF5,
  14112.  
  14113. +   0x50, 0x85, 0x2F, 0x40,
  14114.  
  14115. +   0xD2, 0x01, 0x80, 0x3E,
  14116.  
  14117. +   0xE5, 0x55, 0x64, 0x03,
  14118.  
  14119. +   0x60, 0x04, 0xE5, 0x55,
  14120.  
  14121. +   0x70, 0x04, 0x7D, 0x02,
  14122.  
  14123. +   0x80, 0x09, 0x85, 0x2F,
  14124.  
  14125. +   0x41, 0xD2, 0x02, 0x80,
  14126.  
  14127. +   0x29, 0xAD, 0x55, 0xAF,
  14128.  
  14129. +   0x2F, 0x12, 0x02, 0x8D,
  14130.  
  14131. +   0x80, 0x20, 0x90, 0x70,
  14132.  
  14133. +   0x10, 0xE0, 0xF5, 0x47,
  14134.  
  14135. +   0x90, 0x70, 0x11, 0xE0,
  14136.  
  14137. +   0xF5, 0x44, 0x12, 0x10,
  14138.  
  14139. +   0x25, 0x80, 0x06, 0x90,
  14140.  
  14141. +   0x70, 0x10, 0xE0, 0xF5,
  14142.  
  14143. +   0x45, 0xE4, 0xFD, 0xAF,
  14144.  
  14145. +   0x2F, 0x12, 0x02, 0x8D,
  14146.  
  14147. +   0xD2, 0x04, 0x90, 0x70,
  14148.  
  14149. +   0x13, 0xE4, 0xF0, 0xD2,
  14150.  
  14151. +   0xAF, 0xD0, 0xD0, 0xD0,
  14152.  
  14153. +   0x82, 0xD0, 0x83, 0xD0,
  14154.  
  14155. +   0xF0, 0xD0, 0xE0, 0x32,
  14156.  
  14157. +   0x90, 0x70, 0x2A, 0xE0,
  14158.  
  14159. +   0x30, 0xE1, 0x53, 0xC2,
  14160.  
  14161. +   0xAF, 0x90, 0x70, 0x28,
  14162.  
  14163. +   0xE0, 0x90, 0x10, 0x1C,
  14164.  
  14165. +   0xF0, 0x90, 0x70, 0x29,
  14166.  
  14167. +   0xE0, 0x90, 0x10, 0x1D,
  14168.  
  14169. +   0xF0, 0x90, 0x70, 0x2A,
  14170.  
  14171. +   0xE0, 0x90, 0x10, 0x1E,
  14172.  
  14173. +   0xF0, 0x90, 0x10, 0x1C,
  14174.  
  14175. +   0xE0, 0xF5, 0x30, 0x90,
  14176.  
  14177. +   0x10, 0x1E, 0xE0, 0x20,
  14178.  
  14179. +   0xE1, 0xF3, 0x90, 0x10,
  14180.  
  14181. +   0x1C, 0xE0, 0x90, 0x70,
  14182.  
  14183. +   0x28, 0xF0, 0x90, 0x10,
  14184.  
  14185. +   0x1D, 0xE0, 0x90, 0x70,
  14186.  
  14187. +   0x29, 0xF0, 0x90, 0x10,
  14188.  
  14189. +   0x1E, 0xE0, 0x90, 0x70,
  14190.  
  14191. +   0x2A, 0xF0, 0x30, 0x4A,
  14192.  
  14193. +   0x0D, 0x90, 0x70, 0x24,
  14194.  
  14195. +   0xE0, 0x44, 0x01, 0xF0,
  14196.  
  14197. +   0x90, 0x02, 0x2C, 0x74,
  14198.  
  14199. +   0xFF, 0xF0, 0xC2, 0x05,
  14200.  
  14201. +   0xD2, 0xAF, 0x22, 0xC0,
  14202.  
  14203. +   0xE0, 0xC0, 0xF0, 0xC0,
  14204.  
  14205. +   0x83, 0xC0, 0x82, 0xC0,
  14206.  
  14207. +   0xD0, 0xE8, 0xC0, 0xE0,
  14208.  
  14209. +   0xE9, 0xC0, 0xE0, 0xEA,
  14210.  
  14211. +   0xC0, 0xE0, 0xEB, 0xC0,
  14212.  
  14213. +   0xE0, 0xEC, 0xC0, 0xE0,
  14214.  
  14215. +   0xED, 0xC0, 0xE0, 0xEE,
  14216.  
  14217. +   0xC0, 0xE0, 0xEF, 0xC0,
  14218.  
  14219. +   0xE0, 0xC2, 0xAF, 0x30,
  14220.  
  14221. +   0x45, 0x03, 0x12, 0x10,
  14222.  
  14223. +   0x12, 0xD2, 0xAF, 0xD0,
  14224.  
  14225. +   0xE0, 0xFF, 0xD0, 0xE0,
  14226.  
  14227. +   0xFE, 0xD0, 0xE0, 0xFD,
  14228.  
  14229. +   0xD0, 0xE0, 0xFC, 0xD0,
  14230.  
  14231. +   0xE0, 0xFB, 0xD0, 0xE0,
  14232.  
  14233. +   0xFA, 0xD0, 0xE0, 0xF9,
  14234.  
  14235. +   0xD0, 0xE0, 0xF8, 0xD0,
  14236.  
  14237. +   0xD0, 0xD0, 0x82, 0xD0,
  14238.  
  14239. +   0x83, 0xD0, 0xF0, 0xD0,
  14240.  
  14241. +   0xE0, 0x32, 0xC0, 0xE0,
  14242.  
  14243. +   0xC0, 0xF0, 0xC0, 0x83,
  14244.  
  14245. +   0xC0, 0x82, 0xC0, 0xD0,
  14246.  
  14247. +   0x75, 0xD0, 0x10, 0xC2,
  14248.  
  14249. +   0xAF, 0x30, 0x45, 0x03,
  14250.  
  14251. +   0x12, 0x10, 0x0C, 0x30,
  14252.  
  14253. +   0x58, 0x0A, 0xE5, 0x54,
  14254.  
  14255. +   0x60, 0x04, 0x15, 0x54,
  14256.  
  14257. +   0x80, 0x02, 0xC2, 0x58,
  14258.  
  14259. +   0x30, 0x59, 0x0A, 0xE5,
  14260.  
  14261. +   0x50, 0x60, 0x04, 0x15,
  14262.  
  14263. +   0x50, 0x80, 0x02, 0xC2,
  14264.  
  14265. +   0x59, 0xD5, 0x53, 0x07,
  14266.  
  14267. +   0x30, 0x60, 0x04, 0x15,
  14268.  
  14269. +   0x46, 0xD2, 0x04, 0x30,
  14270.  
  14271. +   0x45, 0x03, 0x12, 0x10,
  14272.  
  14273. +   0x0F, 0xC2, 0x8D, 0xD2,
  14274.  
  14275. +   0xAF, 0xD0, 0xD0, 0xD0,
  14276.  
  14277. +   0x82, 0xD0, 0x83, 0xD0,
  14278.  
  14279. +   0xF0, 0xD0, 0xE0, 0x32,
  14280.  
  14281. +   0x12, 0x02, 0xD3, 0x30,
  14282.  
  14283. +   0x45, 0x03, 0x12, 0x10,
  14284.  
  14285. +   0x03, 0x30, 0x01, 0x06,
  14286.  
  14287. +   0x20, 0x09, 0x03, 0x12,
  14288.  
  14289. +   0x10, 0x1C, 0x30, 0x02,
  14290.  
  14291. +   0x06, 0x20, 0x0A, 0x03,
  14292.  
  14293. +   0x12, 0x10, 0x1F, 0x30,
  14294.  
  14295. +   0x03, 0x06, 0x20, 0x0B,
  14296.  
  14297. +   0x03, 0x12, 0x10, 0x1F,
  14298.  
  14299. +   0x30, 0x04, 0x06, 0x20,
  14300.  
  14301. +   0x0C, 0x03, 0x12, 0x10,
  14302.  
  14303. +   0x22, 0x20, 0x13, 0x09,
  14304.  
  14305. +   0x20, 0x11, 0x06, 0xE5,
  14306.  
  14307. +   0x2B, 0x45, 0x2C, 0x60,
  14308.  
  14309. +   0x03, 0xD3, 0x80, 0x01,
  14310.  
  14311. +   0xC3, 0x92, 0xA9, 0x12,
  14312.  
  14313. +   0x02, 0xEC, 0x80, 0xBF,
  14314.  
  14315. +   0xC2, 0x43, 0xD2, 0x45,
  14316.  
  14317. +   0xE4, 0xF5, 0x20, 0xF5,
  14318.  
  14319. +   0x21, 0xF5, 0x53, 0xF5,
  14320.  
  14321. +   0x46, 0xF5, 0x2B, 0xF5,
  14322.  
  14323. +   0x2C, 0xC2, 0x42, 0xF5,
  14324.  
  14325. +   0x51, 0xF5, 0x52, 0xF5,
  14326.  
  14327. +   0x55, 0x90, 0x04, 0x18,
  14328.  
  14329. +   0x74, 0x80, 0xF0, 0x90,
  14330.  
  14331. +   0x04, 0x1A, 0x74, 0x08,
  14332.  
  14333. +   0xF0, 0xC2, 0x19, 0xC2,
  14334.  
  14335. +   0x18, 0xC2, 0x1A, 0x22,
  14336.  
  14337. +   0xC8, 0xEF, 0xC8, 0xE6,
  14338.  
  14339. +   0xFA, 0x08, 0xE6, 0x4A,
  14340.  
  14341. +   0x60, 0x0C, 0xC8, 0xEF,
  14342.  
  14343. +   0xC8, 0x08, 0xE6, 0x16,
  14344.  
  14345. +   0x18, 0x70, 0x01, 0x16,
  14346.  
  14347. +   0xC3, 0x22, 0xED, 0x24,
  14348.  
  14349. +   0xFF, 0xFD, 0xEC, 0x34,
  14350.  
  14351. +   0xFF, 0xC8, 0xEF, 0xC8,
  14352.  
  14353. +   0xF6, 0x08, 0xC6, 0xED,
  14354.  
  14355. +   0xC6, 0xD3, 0x22, 0xD0,
  14356.  
  14357. +   0x83, 0xD0, 0x82, 0xF8,
  14358.  
  14359. +   0xE4, 0x93, 0x70, 0x12,
  14360.  
  14361. +   0x74, 0x01, 0x93, 0x70,
  14362.  
  14363. +   0x0D, 0xA3, 0xA3, 0x93,
  14364.  
  14365. +   0xF8, 0x74, 0x01, 0x93,
  14366.  
  14367. +   0xF5, 0x82, 0x88, 0x83,
  14368.  
  14369. +   0xE4, 0x73, 0x74, 0x02,
  14370.  
  14371. +   0x93, 0x68, 0x60, 0xEF,
  14372.  
  14373. +   0xA3, 0xA3, 0xA3, 0x80,
  14374.  
  14375. +   0xDF, 0xEF, 0xF4, 0x60,
  14376.  
  14377. +   0x1F, 0xE4, 0xFE, 0x12,
  14378.  
  14379. +   0x03, 0x6A, 0xE0, 0xB4,
  14380.  
  14381. +   0xFF, 0x12, 0x12, 0x03,
  14382.  
  14383. +   0x6A, 0xEF, 0xF0, 0x74,
  14384.  
  14385. +   0x1C, 0x2E, 0xF5, 0x82,
  14386.  
  14387. +   0xE4, 0x34, 0x70, 0xF5,
  14388.  
  14389. +   0x83, 0xED, 0xF0, 0x22,
  14390.  
  14391. +   0x0E, 0xBE, 0x04, 0xE3,
  14392.  
  14393. +   0x22, 0xC0, 0xE0, 0xC0,
  14394.  
  14395. +   0xF0, 0xC0, 0x83, 0xC0,
  14396.  
  14397. +   0x82, 0xC0, 0xD0, 0x75,
  14398.  
  14399. +   0xD0, 0x08, 0xC2, 0xAF,
  14400.  
  14401. +   0x30, 0x45, 0x03, 0x12,
  14402.  
  14403. +   0x10, 0x06, 0xD2, 0xAF,
  14404.  
  14405. +   0xD0, 0xD0, 0xD0, 0x82,
  14406.  
  14407. +   0xD0, 0x83, 0xD0, 0xF0,
  14408.  
  14409. +   0xD0, 0xE0, 0x32, 0xC2,
  14410.  
  14411. +   0xAF, 0x12, 0x00, 0x06,
  14412.  
  14413. +   0x12, 0x02, 0x14, 0x12,
  14414.  
  14415. +   0x03, 0x1C, 0xE4, 0xF5,
  14416.  
  14417. +   0x22, 0xF5, 0x47, 0x90,
  14418.  
  14419. +   0x04, 0x00, 0x74, 0x80,
  14420.  
  14421. +   0xF0, 0xD2, 0xAF, 0x22,
  14422.  
  14423. +   0x30, 0x45, 0x03, 0x12,
  14424.  
  14425. +   0x10, 0x15, 0xE5, 0x20,
  14426.  
  14427. +   0x70, 0x03, 0x20, 0x10,
  14428.  
  14429. +   0x03, 0x30, 0x11, 0x03,
  14430.  
  14431. +   0x43, 0x87, 0x01, 0x22,
  14432.  
  14433. +   0xC0, 0x2A, 0x74, 0x03,
  14434.  
  14435. +   0xC0, 0xE0, 0xC0, 0x82,
  14436.  
  14437. +   0xC0, 0x83, 0x75, 0x2A,
  14438.  
  14439. +   0x0A, 0x22, 0xC0, 0x2A,
  14440.  
  14441. +   0x74, 0x03, 0xC0, 0xE0,
  14442.  
  14443. +   0xC0, 0x82, 0xC0, 0x83,
  14444.  
  14445. +   0x75, 0x2A, 0x18, 0x22,
  14446.  
  14447. +   0x75, 0x89, 0x02, 0xE4,
  14448.  
  14449. +   0xF5, 0x8C, 0xF5, 0x8A,
  14450.  
  14451. +   0xF5, 0x88, 0xF5, 0xB8,
  14452.  
  14453. +   0xF5, 0xE8, 0x75, 0x90,
  14454.  
  14455. +   0x18, 0xD2, 0x8C, 0x75,
  14456.  
  14457. +   0xA8, 0x05, 0x22, 0xCE,
  14458.  
  14459. +   0xEF, 0xCE, 0xEE, 0x60,
  14460.  
  14461. +   0x08, 0x7F, 0xFF, 0x12,
  14462.  
  14463. +   0x03, 0x80, 0x1E, 0x80,
  14464.  
  14465. +   0xF5, 0x22, 0xC8, 0xEF,
  14466.  
  14467. +   0xC8, 0xE6, 0x60, 0x03,
  14468.  
  14469. +   0x16, 0xC3, 0x22, 0xED,
  14470.  
  14471. +   0x14, 0xF6, 0xD3, 0x22,
  14472.  
  14473. +   0xC8, 0xEF, 0xC8, 0xE6,
  14474.  
  14475. +   0x60, 0x06, 0x16, 0xE6,
  14476.  
  14477. +   0x24, 0xFF, 0xB3, 0x22,
  14478.  
  14479. +   0xC3, 0x22, 0x78, 0x7F,
  14480.  
  14481. +   0xE4, 0xF6, 0xD8, 0xFD,
  14482.  
  14483. +   0x75, 0x81, 0x5F, 0x02,
  14484.  
  14485. +   0x01, 0xD0, 0x74, 0x14,
  14486.  
  14487. +   0x2E, 0xF5, 0x82, 0xE4,
  14488.  
  14489. +   0x34, 0x70, 0xF5, 0x83,
  14490.  
  14491. +   0x22, 0xEF, 0x90, 0x03,
  14492.  
  14493. +   0x7E, 0x93, 0x90, 0x03,
  14494.  
  14495. +   0x00, 0x73, 0x0A, 0x18,
  14496.  
  14497. +   0xEF, 0x60, 0x03, 0x1F,
  14498.  
  14499. +   0x80, 0xFA, 0x22, 0xFF,
  14500.  
  14501. +   0xFF, 0xFF, 0xFF, 0xFF,
  14502.  
  14503. +   0xFF, 0xFF, 0xFF, 0xFF,
  14504.  
  14505. +   0xFF, 0xFF, 0xFF, 0xFF,
  14506.  
  14507. +   0xFF, 0xFF, 0xFF, 0xFF,
  14508.  
  14509. +   0xFF, 0xFF, 0xFF, 0xFF,
  14510.  
  14511. +   0xFF, 0xFF, 0xFF, 0xFF,
  14512.  
  14513. +   0xFF, 0xFF, 0xFF, 0xFF,
  14514.  
  14515. +   0xFF, 0xFF, 0xFF, 0xFF,
  14516.  
  14517. +   0xFF, 0xFF, 0xFF, 0xFF,
  14518.  
  14519. +   0xFF, 0xFF, 0xFF, 0xFF,
  14520.  
  14521. +   0xFF, 0xFF, 0xFF, 0xFF,
  14522.  
  14523. +   0xFF, 0xFF, 0xFF, 0xFF,
  14524.  
  14525. +   0xFF, 0xFF, 0xFF, 0xFF,
  14526.  
  14527. +   0xFF, 0xFF, 0xFF, 0xFF,
  14528.  
  14529. +   0xFF, 0xFF, 0xFF, 0xFF,
  14530.  
  14531. +   0xFF, 0xFF, 0xFF, 0xFF,
  14532.  
  14533. +   0xFF, 0xFF, 0xFF, 0xFF,
  14534.  
  14535. +   0xFF, 0xFF, 0xFF, 0xFF,
  14536.  
  14537. +   0xFF, 0xFF, 0xFF, 0xFF,
  14538.  
  14539. +   0xFF, 0xFF, 0xFF, 0xFF,
  14540.  
  14541. +   0xFF, 0xFF, 0xFF, 0xFF,
  14542.  
  14543. +   0xFF, 0xFF, 0xFF, 0xFF,
  14544.  
  14545. +   0xFF, 0xFF, 0xFF, 0xFF,
  14546.  
  14547. +   0xFF, 0xFF, 0xFF, 0xFF,
  14548.  
  14549. +   0xFF, 0xFF, 0xFF, 0xFF,
  14550.  
  14551. +   0xFF, 0xFF, 0xFF, 0xFF,
  14552.  
  14553. +   0xFF, 0xFF, 0xFF, 0xFF,
  14554.  
  14555. +   0xFF, 0xFF, 0xFF, 0xFF,
  14556.  
  14557. +   0xFF, 0xFF, 0xFF, 0xFF,
  14558.  
  14559. +   0xFF, 0xFF, 0xFF, 0xFF,
  14560.  
  14561. +   0xFF, 0xFF, 0xFF, 0xFF,
  14562.  
  14563. +   0xFF, 0xFF, 0xFF, 0xFF,
  14564.  
  14565. +   0xFF, 0xFF, 0xFF, 0xFF,
  14566.  
  14567. +   0xFF, 0xFF, 0xFF, 0xFF,
  14568.  
  14569. +   0xFF, 0xFF, 0xFF, 0xFF,
  14570.  
  14571. +   0xFF, 0xFF, 0xFF, 0xFF,
  14572.  
  14573. +   0xFF, 0xFF, 0xFF, 0xFF,
  14574.  
  14575. +   0xFF, 0xFF, 0xFF, 0xFF,
  14576.  
  14577. +   0xFF, 0xFF, 0xFF, 0xFF,
  14578.  
  14579. +   0xFF, 0xFF, 0xFF, 0xFF,
  14580.  
  14581. +   0xFF, 0xFF, 0xFF, 0xFF,
  14582.  
  14583. +   0xFF, 0xFF, 0xFF, 0xFF,
  14584.  
  14585. +   0xFF, 0xFF, 0xFF, 0xFF,
  14586.  
  14587. +   0xFF, 0xFF, 0xFF, 0xFF,
  14588.  
  14589. +   0xFF, 0xFF, 0xFF, 0xFF,
  14590.  
  14591. +   0xFF, 0xFF, 0xFF, 0xFF,
  14592.  
  14593. +   0xFF, 0xFF, 0xFF, 0xFF,
  14594.  
  14595. +   0xFF, 0xFF, 0xFF, 0xFF,
  14596.  
  14597. +   0xFF, 0xFF, 0xFF, 0xFF,
  14598.  
  14599. +   0xFF, 0xFF, 0xFF, 0xFF,
  14600.  
  14601. +   0xFF, 0xFF, 0xFF, 0xFF,
  14602.  
  14603. +   0xFF, 0xFF, 0xFF, 0xFF,
  14604.  
  14605. +   0xFF, 0xFF, 0xFF, 0xFF,
  14606.  
  14607. +   0xFF, 0xFF, 0xFF, 0xFF,
  14608.  
  14609. +   0xFF, 0xFF, 0xFF, 0xFF,
  14610.  
  14611. +   0xFF, 0xFF, 0xFF, 0xFF,
  14612.  
  14613. +   0xFF, 0xFF, 0xFF, 0xFF,
  14614.  
  14615. +   0xFF, 0xFF, 0xFF, 0xFF,
  14616.  
  14617. +   0xFF, 0xFF, 0xFF, 0xFF,
  14618.  
  14619. +   0xFF, 0xFF, 0xFF, 0xFF,
  14620.  
  14621. +   0xFF, 0xFF, 0xFF, 0xFF,
  14622.  
  14623. +   0xFF, 0xFF, 0xFF, 0xFF,
  14624.  
  14625. +   0xFF, 0xFF, 0xFF, 0xFF,
  14626.  
  14627. +   0xFF, 0xFF, 0xFF, 0xFF,
  14628.  
  14629. +   0xFF, 0xFF, 0xFF, 0xFF,
  14630.  
  14631. +   0xFF, 0xFF, 0xFF, 0xFF,
  14632.  
  14633. +   0xFF, 0xFF, 0xFF, 0xFF,
  14634.  
  14635. +   0xFF, 0xFF, 0xFF, 0xFF,
  14636.  
  14637. +   0xFF, 0xFF, 0xFF, 0xFF,
  14638.  
  14639. +   0xFF, 0xFF, 0xFF, 0xFF,
  14640.  
  14641. +   0xFF, 0xFF, 0xFF, 0xFF,
  14642.  
  14643. +   0xFF, 0xFF, 0xFF, 0xFF,
  14644.  
  14645. +   0xFF, 0xFF, 0xFF, 0xFF,
  14646.  
  14647. +   0xFF, 0xFF, 0xFF, 0xFF,
  14648.  
  14649. +   0xFF, 0xFF, 0xFF, 0xFF,
  14650.  
  14651. +   0xFF, 0xFF, 0xFF, 0xFF,
  14652.  
  14653. +   0xFF, 0xFF, 0xFF, 0xFF,
  14654.  
  14655. +   0xFF, 0xFF, 0xFF, 0xFF,
  14656.  
  14657. +   0xFF, 0xFF, 0xFF, 0xFF,
  14658.  
  14659. +   0xFF, 0xFF, 0xFF, 0xFF,
  14660.  
  14661. +   0xFF, 0xFF, 0xFF, 0xFF,
  14662.  
  14663. +   0xFF, 0xFF, 0xFF, 0xFF,
  14664.  
  14665. +   0xFF, 0xFF, 0xFF, 0xFF,
  14666.  
  14667. +   0xFF, 0xFF, 0xFF, 0xFF,
  14668.  
  14669. +   0xFF, 0xFF, 0xFF, 0xFF,
  14670.  
  14671. +   0xFF, 0xFF, 0xFF, 0xFF,
  14672.  
  14673. +   0xFF, 0xFF, 0xFF, 0xFF,
  14674.  
  14675. +   0xFF, 0xFF, 0xFF, 0xFF,
  14676.  
  14677. +   0xFF, 0xFF, 0xFF, 0xFF,
  14678.  
  14679. +   0xFF, 0xFF, 0xFF, 0xFF,
  14680.  
  14681. +   0xFF, 0xFF, 0xFF, 0xFF,
  14682.  
  14683. +   0xFF, 0xFF, 0xFF, 0xFF,
  14684.  
  14685. +   0xFF, 0xFF, 0xFF, 0xFF,
  14686.  
  14687. +   0xFF, 0xFF, 0xFF, 0xFF,
  14688.  
  14689. +   0xFF, 0xFF, 0xFF, 0xFF,
  14690.  
  14691. +   0xFF, 0xFF, 0xFF, 0xFF,
  14692.  
  14693. +   0xFF, 0xFF, 0xFF, 0xFF,
  14694.  
  14695. +   0xFF, 0xFF, 0xFF, 0xFF,
  14696.  
  14697. +   0xFF, 0xFF, 0xFF, 0xFF,
  14698.  
  14699. +   0xFF, 0xFF, 0xFF, 0xFF,
  14700.  
  14701. +   0xFF, 0xFF, 0xFF, 0xFF,
  14702.  
  14703. +   0xFF, 0xFF, 0xFF, 0xFF,
  14704.  
  14705. +   0xFF, 0xFF, 0xFF, 0xFF,
  14706.  
  14707. +   0xFF, 0xFF, 0xFF, 0xFF,
  14708.  
  14709. +   0xFF, 0xFF, 0xFF, 0xFF,
  14710.  
  14711. +   0xFF, 0xFF, 0xFF, 0xFF,
  14712.  
  14713. +   0xFF, 0xFF, 0xFF, 0xFF,
  14714.  
  14715. +   0xFF, 0xFF, 0xFF, 0xFF,
  14716.  
  14717. +   0xFF, 0xFF, 0xFF, 0xFF,
  14718.  
  14719. +   0xFF, 0xFF, 0xFF, 0xFF,
  14720.  
  14721. +   0xFF, 0xFF, 0xFF, 0xFF,
  14722.  
  14723. +   0xFF, 0xFF, 0xFF, 0xFF,
  14724.  
  14725. +   0xFF, 0xFF, 0xFF, 0xFF,
  14726.  
  14727. +   0xFF, 0xFF, 0xFF, 0xFF,
  14728.  
  14729. +   0xFF, 0xFF, 0xFF, 0xFF,
  14730.  
  14731. +   0xFF, 0xFF, 0xFF, 0xFF,
  14732.  
  14733. +   0xFF, 0xFF, 0xFF, 0xFF,
  14734.  
  14735. +   0xFF, 0xFF, 0xFF, 0xFF,
  14736.  
  14737. +   0xFF, 0xFF, 0xFF, 0xFF,
  14738.  
  14739. +   0xFF, 0xFF, 0xFF, 0xFF,
  14740.  
  14741. +   0xFF, 0xFF, 0xFF, 0xFF,
  14742.  
  14743. +   0xFF, 0xFF, 0xFF, 0xFF,
  14744.  
  14745. +   0xFF, 0xFF, 0xFF, 0xFF,
  14746.  
  14747. +   0xFF, 0xFF, 0xFF, 0xFF,
  14748.  
  14749. +   0xFF, 0xFF, 0xFF, 0xFF,
  14750.  
  14751. +   0xFF, 0xFF, 0xFF, 0xFF,
  14752.  
  14753. +   0xFF, 0xFF, 0xFF, 0xFF,
  14754.  
  14755. +   0xFF, 0xFF, 0xFF, 0xFF,
  14756.  
  14757. +   0xFF, 0xFF, 0xFF, 0xFF,
  14758.  
  14759. +   0xFF, 0xFF, 0xFF, 0xFF,
  14760.  
  14761. +   0xFF, 0xFF, 0xFF, 0xFF,
  14762.  
  14763. +   0xFF, 0xFF, 0xFF, 0xFF,
  14764.  
  14765. +   0xFF, 0xFF, 0xFF, 0xFF,
  14766.  
  14767. +   0xFF, 0xFF, 0xFF, 0xFF,
  14768.  
  14769. +   0xFF, 0xFF, 0xFF, 0xFF,
  14770.  
  14771. +   0xFF, 0xFF, 0xFF, 0xFF,
  14772.  
  14773. +   0xFF, 0xFF, 0xFF, 0xFF,
  14774.  
  14775. +   0xFF, 0xFF, 0xFF, 0xFF,
  14776.  
  14777. +   0xFF, 0xFF, 0xFF, 0xFF,
  14778.  
  14779. +   0xFF, 0xFF, 0xFF, 0xFF,
  14780.  
  14781. +   0xFF, 0xFF, 0xFF, 0xFF,
  14782.  
  14783. +   0xFF, 0xFF, 0xFF, 0xFF,
  14784.  
  14785. +   0xFF, 0xFF, 0xFF, 0xFF,
  14786.  
  14787. +   0xFF, 0xFF, 0xFF, 0xFF,
  14788.  
  14789. +   0xFF, 0xFF, 0xFF, 0xFF,
  14790.  
  14791. +   0xFF, 0xFF, 0xFF, 0xFF,
  14792.  
  14793. +   0xFF, 0xFF, 0xFF, 0xFF,
  14794.  
  14795. +   0xFF, 0xFF, 0xFF, 0xFF,
  14796.  
  14797. +   0xFF, 0xFF, 0xFF, 0xFF,
  14798.  
  14799. +   0xFF, 0xFF, 0xFF, 0xFF,
  14800.  
  14801. +   0xFF, 0xFF, 0xFF, 0xFF,
  14802.  
  14803. +   0xFF, 0xFF, 0xFF, 0xFF,
  14804.  
  14805. +   0xFF, 0xFF, 0xFF, 0xFF,
  14806.  
  14807. +   0xFF, 0xFF, 0xFF, 0xFF,
  14808.  
  14809. +   0xFF, 0xFF, 0xFF, 0xFF,
  14810.  
  14811. +   0xFF, 0xFF, 0xFF, 0xFF,
  14812.  
  14813. +   0xFF, 0xFF, 0xFF, 0xFF,
  14814.  
  14815. +   0xFF, 0xFF, 0xFF, 0xFF,
  14816.  
  14817. +   0xFF, 0xFF, 0xFF, 0xFF,
  14818.  
  14819. +   0xFF, 0xFF, 0xFF, 0xFF,
  14820.  
  14821. +   0xFF, 0xFF, 0xFF, 0xFF,
  14822.  
  14823. +   0xFF, 0xFF, 0xFF, 0xFF,
  14824.  
  14825. +   0xFF, 0xFF, 0xFF, 0xFF,
  14826.  
  14827. +   0xFF, 0xFF, 0xFF, 0xFF,
  14828.  
  14829. +   0xFF, 0xFF, 0xFF, 0xFF,
  14830.  
  14831. +   0xFF, 0xFF, 0xFF, 0xFF,
  14832.  
  14833. +   0xFF, 0xFF, 0xFF, 0xFF,
  14834.  
  14835. +   0xFF, 0xFF, 0xFF, 0xFF,
  14836.  
  14837. +   0xFF, 0xFF, 0xFF, 0xFF,
  14838.  
  14839. +   0xFF, 0xFF, 0xFF, 0xFF,
  14840.  
  14841. +   0xFF, 0xFF, 0xFF, 0xFF,
  14842.  
  14843. +   0xFF, 0xFF, 0xFF, 0xFF,
  14844.  
  14845. +   0xFF, 0xFF, 0xFF, 0xFF,
  14846.  
  14847. +   0xFF, 0xFF, 0xFF, 0xFF,
  14848.  
  14849. +   0xFF, 0xFF, 0xFF, 0xFF,
  14850.  
  14851. +   0xFF, 0xFF, 0xFF, 0xFF,
  14852.  
  14853. +   0xFF, 0xFF, 0xFF, 0xFF,
  14854.  
  14855. +   0xFF, 0xFF, 0xFF, 0xFF,
  14856.  
  14857. +   0xFF, 0xFF, 0xFF, 0xFF,
  14858.  
  14859. +   0xFF, 0xFF, 0xFF, 0xFF,
  14860.  
  14861. +   0xFF, 0xFF, 0xFF, 0xFF,
  14862.  
  14863. +   0xFF, 0xFF, 0xFF, 0xFF,
  14864.  
  14865. +   0xFF, 0xFF, 0xFF, 0xFF,
  14866.  
  14867. +   0xFF, 0xFF, 0xFF, 0xFF,
  14868.  
  14869. +   0xFF, 0xFF, 0xFF, 0xFF,
  14870.  
  14871. +   0xFF, 0xFF, 0xFF, 0xFF,
  14872.  
  14873. +   0xFF, 0xFF, 0xFF, 0xFF,
  14874.  
  14875. +   0xFF, 0xFF, 0xFF, 0xFF,
  14876.  
  14877. +   0xFF, 0xFF, 0xFF, 0xFF,
  14878.  
  14879. +   0xFF, 0xFF, 0xFF, 0xFF,
  14880.  
  14881. +   0xFF, 0xFF, 0xFF, 0xFF,
  14882.  
  14883. +   0xFF, 0xFF, 0xFF, 0xFF,
  14884.  
  14885. +   0xFF, 0xFF, 0xFF, 0xFF,
  14886.  
  14887. +   0xFF, 0xFF, 0xFF, 0xFF,
  14888.  
  14889. +   0xFF, 0xFF, 0xFF, 0xFF,
  14890.  
  14891. +   0xFF, 0xFF, 0xFF, 0xFF,
  14892.  
  14893. +   0xFF, 0xFF, 0xFF, 0xFF,
  14894.  
  14895. +   0xFF, 0xFF, 0xFF, 0xFF,
  14896.  
  14897. +   0xFF, 0xFF, 0xFF, 0xFF,
  14898.  
  14899. +   0xFF, 0xFF, 0xFF, 0xFF,
  14900.  
  14901. +   0xFF, 0xFF, 0xFF, 0xFF,
  14902.  
  14903. +   0xFF, 0xFF, 0xFF, 0xFF,
  14904.  
  14905. +   0xFF, 0xFF, 0xFF, 0xFF,
  14906.  
  14907. +   0xFF, 0xFF, 0xFF, 0xFF,
  14908.  
  14909. +   0xFF, 0xFF, 0xFF, 0xFF,
  14910.  
  14911. +   0xFF, 0xFF, 0xFF, 0xFF,
  14912.  
  14913. +   0xFF, 0xFF, 0xFF, 0xFF,
  14914.  
  14915. +   0xFF, 0xFF, 0xFF, 0xFF,
  14916.  
  14917. +   0xFF, 0xFF, 0xFF, 0xFF,
  14918.  
  14919. +   0xFF, 0xFF, 0xFF, 0xFF,
  14920.  
  14921. +   0xFF, 0xFF, 0xFF, 0xFF,
  14922.  
  14923. +   0xFF, 0xFF, 0xFF, 0xFF,
  14924.  
  14925. +   0xFF, 0xFF, 0xFF, 0xFF,
  14926.  
  14927. +   0xFF, 0xFF, 0xFF, 0xFF,
  14928.  
  14929. +   0xFF, 0xFF, 0xFF, 0xFF,
  14930.  
  14931. +   0xFF, 0xFF, 0xFF, 0xFF,
  14932.  
  14933. +   0xFF, 0xFF, 0xFF, 0xFF,
  14934.  
  14935. +   0xFF, 0xFF, 0xFF, 0xFF,
  14936.  
  14937. +   0xFF, 0xFF, 0xFF, 0xFF,
  14938.  
  14939. +   0xFF, 0xFF, 0xFF, 0xFF,
  14940.  
  14941. +   0xFF, 0xFF, 0xFF, 0xFF,
  14942.  
  14943. +   0xFF, 0xFF, 0xFF, 0xFF,
  14944.  
  14945. +   0xFF, 0xFF, 0xFF, 0xFF,
  14946.  
  14947. +   0xFF, 0xFF, 0xFF, 0xFF,
  14948.  
  14949. +   0xFF, 0xFF, 0xFF, 0xFF,
  14950.  
  14951. +   0xFF, 0xFF, 0xFF, 0xFF,
  14952.  
  14953. +   0xFF, 0xFF, 0xFF, 0xFF,
  14954.  
  14955. +   0xFF, 0xFF, 0xFF, 0xFF,
  14956.  
  14957. +   0xFF, 0xFF, 0xFF, 0xFF,
  14958.  
  14959. +   0xFF, 0xFF, 0xFF, 0xFF,
  14960.  
  14961. +   0xFF, 0xFF, 0xFF, 0xFF,
  14962.  
  14963. +   0xFF, 0xFF, 0xFF, 0xFF,
  14964.  
  14965. +   0xFF, 0xFF, 0xFF, 0xFF,
  14966.  
  14967. +   0xFF, 0xFF, 0xFF, 0xFF,
  14968.  
  14969. +   0xFF, 0xFF, 0xFF, 0xFF,
  14970.  
  14971. +   0xFF, 0xFF, 0xFF, 0xFF,
  14972.  
  14973. +   0xFF, 0xFF, 0xFF, 0xFF,
  14974.  
  14975. +   0xFF, 0xFF, 0xFF, 0xFF,
  14976.  
  14977. +   0xFF, 0xFF, 0xFF, 0xFF,
  14978.  
  14979. +   0xFF, 0xFF, 0xFF, 0xFF,
  14980.  
  14981. +   0xFF, 0xFF, 0xFF, 0xFF,
  14982.  
  14983. +   0xFF, 0xFF, 0xFF, 0xFF,
  14984.  
  14985. +   0xFF, 0xFF, 0xFF, 0xFF,
  14986.  
  14987. +   0xFF, 0xFF, 0xFF, 0xFF,
  14988.  
  14989. +   0xFF, 0xFF, 0xFF, 0xFF,
  14990.  
  14991. +   0xFF, 0xFF, 0xFF, 0xFF,
  14992.  
  14993. +   0xFF, 0xFF, 0xFF, 0xFF,
  14994.  
  14995. +   0xFF, 0xFF, 0xFF, 0xFF,
  14996.  
  14997. +   0xFF, 0xFF, 0xFF, 0xFF,
  14998.  
  14999. +   0xFF, 0xFF, 0xFF, 0xFF,
  15000.  
  15001. +   0xFF, 0xFF, 0xFF, 0xFF,
  15002.  
  15003. +   0xFF, 0xFF, 0xFF, 0xFF,
  15004.  
  15005. +   0xFF, 0xFF, 0xFF, 0xFF,
  15006.  
  15007. +   0xFF, 0xFF, 0xFF, 0xFF,
  15008.  
  15009. +   0xFF, 0xFF, 0xFF, 0xFF,
  15010.  
  15011. +   0xFF, 0xFF, 0xFF, 0xFF,
  15012.  
  15013. +   0xFF, 0xFF, 0xFF, 0xFF,
  15014.  
  15015. +   0xFF, 0xFF, 0xFF, 0xFF,
  15016.  
  15017. +   0xFF, 0xFF, 0xFF, 0xFF,
  15018.  
  15019. +   0xFF, 0xFF, 0xFF, 0xFF,
  15020.  
  15021. +   0xFF, 0xFF, 0xFF, 0xFF,
  15022.  
  15023. +   0xFF, 0xFF, 0xFF, 0xFF,
  15024.  
  15025. +   0xFF, 0xFF, 0xFF, 0xFF,
  15026.  
  15027. +   0xFF, 0xFF, 0xFF, 0xFF,
  15028.  
  15029. +   0xFF, 0xFF, 0xFF, 0xFF,
  15030.  
  15031. +   0xFF, 0xFF, 0xFF, 0xFF,
  15032.  
  15033. +   0xFF, 0xFF, 0xFF, 0xFF,
  15034.  
  15035. +   0xFF, 0xFF, 0xFF, 0xFF,
  15036.  
  15037. +   0xFF, 0xFF, 0xFF, 0xFF,
  15038.  
  15039. +   0xFF, 0xFF, 0xFF, 0xFF,
  15040.  
  15041. +   0xFF, 0xFF, 0xFF, 0xFF,
  15042.  
  15043. +   0xFF, 0xFF, 0xFF, 0xFF,
  15044.  
  15045. +   0xFF, 0xFF, 0xFF, 0xFF,
  15046.  
  15047. +   0xFF, 0xFF, 0xFF, 0xFF,
  15048.  
  15049. +   0xFF, 0xFF, 0xFF, 0xFF,
  15050.  
  15051. +   0xFF, 0xFF, 0xFF, 0xFF,
  15052.  
  15053. +   0xFF, 0xFF, 0xFF, 0xFF,
  15054.  
  15055. +   0xFF, 0xFF, 0xFF, 0xFF,
  15056.  
  15057. +   0xFF, 0xFF, 0xFF, 0xFF,
  15058.  
  15059. +   0xFF, 0xFF, 0xFF, 0xFF,
  15060.  
  15061. +   0xFF, 0xFF, 0xFF, 0xFF,
  15062.  
  15063. +   0xFF, 0xFF, 0xFF, 0xFF,
  15064.  
  15065. +   0xFF, 0xFF, 0xFF, 0xFF,
  15066.  
  15067. +   0xFF, 0xFF, 0xFF, 0xFF,
  15068.  
  15069. +   0xFF, 0xFF, 0xFF, 0xFF,
  15070.  
  15071. +   0xFF, 0xFF, 0xFF, 0xFF,
  15072.  
  15073. +   0xFF, 0xFF, 0xFF, 0xFF,
  15074.  
  15075. +   0xFF, 0xFF, 0xFF, 0xFF,
  15076.  
  15077. +   0xFF, 0xFF, 0xFF, 0xFF,
  15078.  
  15079. +   0xFF, 0xFF, 0xFF, 0xFF,
  15080.  
  15081. +   0xFF, 0xFF, 0xFF, 0xFF,
  15082.  
  15083. +   0xFF, 0xFF, 0xFF, 0xFF,
  15084.  
  15085. +   0xFF, 0xFF, 0xFF, 0xFF,
  15086.  
  15087. +   0xFF, 0xFF, 0xFF, 0xFF,
  15088.  
  15089. +   0xFF, 0xFF, 0xFF, 0xFF,
  15090.  
  15091. +   0xFF, 0xFF, 0xFF, 0xFF,
  15092.  
  15093. +   0xFF, 0xFF, 0xFF, 0xFF,
  15094.  
  15095. +   0xFF, 0xFF, 0xFF, 0xFF,
  15096.  
  15097. +   0xFF, 0xFF, 0xFF, 0xFF,
  15098.  
  15099. +   0xFF, 0xFF, 0xFF, 0xFF,
  15100.  
  15101. +   0xFF, 0xFF, 0xFF, 0xFF,
  15102.  
  15103. +   0xFF, 0xFF, 0xFF, 0xFF,
  15104.  
  15105. +   0xFF, 0xFF, 0xFF, 0xFF,
  15106.  
  15107. +   0xFF, 0xFF, 0xFF, 0xFF,
  15108.  
  15109. +   0xFF, 0xFF, 0xFF, 0xFF,
  15110.  
  15111. +   0xFF, 0xFF, 0xFF, 0xFF,
  15112.  
  15113. +   0xFF, 0xFF, 0xFF, 0xFF,
  15114.  
  15115. +   0xFF, 0xFF, 0xFF, 0xFF,
  15116.  
  15117. +   0xFF, 0xFF, 0xFF, 0xFF,
  15118.  
  15119. +   0xFF, 0xFF, 0xFF, 0xFF,
  15120.  
  15121. +   0xFF, 0xFF, 0xFF, 0xFF,
  15122.  
  15123. +   0xFF, 0xFF, 0xFF, 0xFF,
  15124.  
  15125. +   0xFF, 0xFF, 0xFF, 0xFF,
  15126.  
  15127. +   0xFF, 0xFF, 0xFF, 0xFF,
  15128.  
  15129. +   0xFF, 0xFF, 0xFF, 0xFF,
  15130.  
  15131. +   0xFF, 0xFF, 0xFF, 0xFF,
  15132.  
  15133. +   0xFF, 0xFF, 0xFF, 0xFF,
  15134.  
  15135. +   0xFF, 0xFF, 0xFF, 0xFF,
  15136.  
  15137. +   0xFF, 0xFF, 0xFF, 0xFF,
  15138.  
  15139. +   0xFF, 0xFF, 0xFF, 0xFF,
  15140.  
  15141. +   0xFF, 0xFF, 0xFF, 0xFF,
  15142.  
  15143. +   0xFF, 0xFF, 0xFF, 0xFF,
  15144.  
  15145. +   0xFF, 0xFF, 0xFF, 0xFF,
  15146.  
  15147. +   0xFF, 0xFF, 0xFF, 0xFF,
  15148.  
  15149. +   0xFF, 0xFF, 0xFF, 0xFF,
  15150.  
  15151. +   0xFF, 0xFF, 0xFF, 0xFF,
  15152.  
  15153. +   0xFF, 0xFF, 0xFF, 0xFF,
  15154.  
  15155. +   0xFF, 0xFF, 0xFF, 0xFF,
  15156.  
  15157. +   0xFF, 0xFF, 0xFF, 0xFF,
  15158.  
  15159. +   0xFF, 0xFF, 0xFF, 0xFF,
  15160.  
  15161. +   0xFF, 0xFF, 0xFF, 0xFF,
  15162.  
  15163. +   0xFF, 0xFF, 0xFF, 0xFF,
  15164.  
  15165. +   0xFF, 0xFF, 0xFF, 0xFF,
  15166.  
  15167. +   0xFF, 0xFF, 0xFF, 0xFF,
  15168.  
  15169. +   0xFF, 0xFF, 0xFF, 0xFF,
  15170.  
  15171. +   0xFF, 0xFF, 0xFF, 0xFF,
  15172.  
  15173. +   0xFF, 0xFF, 0xFF, 0xFF,
  15174.  
  15175. +   0xFF, 0xFF, 0xFF, 0xFF,
  15176.  
  15177. +   0xFF, 0xFF, 0xFF, 0xFF,
  15178.  
  15179. +   0xFF, 0xFF, 0xFF, 0xFF,
  15180.  
  15181. +   0xFF, 0xFF, 0xFF, 0xFF,
  15182.  
  15183. +   0xFF, 0xFF, 0xFF, 0xFF,
  15184.  
  15185. +   0xFF, 0xFF, 0xFF, 0xFF,
  15186.  
  15187. +   0xFF, 0xFF, 0xFF, 0xFF,
  15188.  
  15189. +   0xFF, 0xFF, 0xFF, 0xFF,
  15190.  
  15191. +   0xFF, 0xFF, 0xFF, 0xFF,
  15192.  
  15193. +   0xFF, 0xFF, 0xFF, 0xFF,
  15194.  
  15195. +   0xFF, 0xFF, 0xFF, 0xFF,
  15196.  
  15197. +   0xFF, 0xFF, 0xFF, 0xFF,
  15198.  
  15199. +   0xFF, 0xFF, 0xFF, 0xFF,
  15200.  
  15201. +   0xFF, 0xFF, 0xFF, 0xFF,
  15202.  
  15203. +   0xFF, 0xFF, 0xFF, 0xFF,
  15204.  
  15205. +   0xFF, 0xFF, 0xFF, 0xFF,
  15206.  
  15207. +   0xFF, 0xFF, 0xFF, 0xFF,
  15208.  
  15209. +   0xFF, 0xFF, 0xFF, 0xFF,
  15210.  
  15211. +   0xFF, 0xFF, 0xFF, 0xFF,
  15212.  
  15213. +   0xFF, 0xFF, 0xFF, 0xFF,
  15214.  
  15215. +   0xFF, 0xFF, 0xFF, 0xFF,
  15216.  
  15217. +   0xFF, 0xFF, 0xFF, 0xFF,
  15218.  
  15219. +   0xFF, 0xFF, 0xFF, 0xFF,
  15220.  
  15221. +   0xFF, 0xFF, 0xFF, 0xFF,
  15222.  
  15223. +   0xFF, 0xFF, 0xFF, 0xFF,
  15224.  
  15225. +   0xFF, 0xFF, 0xFF, 0xFF,
  15226.  
  15227. +   0xFF, 0xFF, 0xFF, 0xFF,
  15228.  
  15229. +   0xFF, 0xFF, 0xFF, 0xFF,
  15230.  
  15231. +   0xFF, 0xFF, 0xFF, 0xFF,
  15232.  
  15233. +   0xFF, 0xFF, 0xFF, 0xFF,
  15234.  
  15235. +   0xFF, 0xFF, 0xFF, 0xFF,
  15236.  
  15237. +   0xFF, 0xFF, 0xFF, 0xFF,
  15238.  
  15239. +   0xFF, 0xFF, 0xFF, 0xFF,
  15240.  
  15241. +   0xFF, 0xFF, 0xFF, 0xFF,
  15242.  
  15243. +   0xFF, 0xFF, 0xFF, 0xFF,
  15244.  
  15245. +   0xFF, 0xFF, 0xFF, 0xFF,
  15246.  
  15247. +   0xFF, 0xFF, 0xFF, 0xFF,
  15248.  
  15249. +   0xFF, 0xFF, 0xFF, 0xFF,
  15250.  
  15251. +   0xFF, 0xFF, 0xFF, 0xFF,
  15252.  
  15253. +   0xFF, 0xFF, 0xFF, 0xFF,
  15254.  
  15255. +   0xFF, 0xFF, 0xFF, 0xFF,
  15256.  
  15257. +   0xFF, 0xFF, 0xFF, 0xFF,
  15258.  
  15259. +   0xFF, 0xFF, 0xFF, 0xFF,
  15260.  
  15261. +   0xFF, 0xFF, 0xFF, 0xFF,
  15262.  
  15263. +   0xFF, 0xFF, 0xFF, 0xFF,
  15264.  
  15265. +   0xFF, 0xFF, 0xFF, 0xFF,
  15266.  
  15267. +   0xFF, 0xFF, 0xFF, 0xFF,
  15268.  
  15269. +   0xFF, 0xFF, 0xFF, 0xFF,
  15270.  
  15271. +   0xFF, 0xFF, 0xFF, 0xFF,
  15272.  
  15273. +   0xFF, 0xFF, 0xFF, 0xFF,
  15274.  
  15275. +   0xFF, 0xFF, 0xFF, 0xFF,
  15276.  
  15277. +   0xFF, 0xFF, 0xFF, 0xFF,
  15278.  
  15279. +   0xFF, 0xFF, 0xFF, 0xFF,
  15280.  
  15281. +   0xFF, 0xFF, 0xFF, 0xFF,
  15282.  
  15283. +   0xFF, 0xFF, 0xFF, 0xFF,
  15284.  
  15285. +   0xFF, 0xFF, 0xFF, 0xFF,
  15286.  
  15287. +   0xFF, 0xFF, 0xFF, 0xFF,
  15288.  
  15289. +   0xFF, 0xFF, 0xFF, 0xFF,
  15290.  
  15291. +   0xFF, 0xFF, 0xFF, 0xFF,
  15292.  
  15293. +   0xFF, 0xFF, 0xFF, 0xFF,
  15294.  
  15295. +   0xFF, 0xFF, 0xFF, 0xFF,
  15296.  
  15297. +   0xFF, 0xFF, 0xFF, 0xFF,
  15298.  
  15299. +   0xFF, 0xFF, 0xFF, 0xFF,
  15300.  
  15301. +   0xFF, 0xFF, 0xFF, 0xFF,
  15302.  
  15303. +   0xFF, 0xFF, 0xFF, 0xFF,
  15304.  
  15305. +   0xFF, 0xFF, 0xFF, 0xFF,
  15306.  
  15307. +   0xFF, 0xFF, 0xFF, 0xFF,
  15308.  
  15309. +   0xFF, 0xFF, 0xFF, 0xFF,
  15310.  
  15311. +   0xFF, 0xFF, 0xFF, 0xFF,
  15312.  
  15313. +   0xFF, 0xFF, 0xFF, 0xFF,
  15314.  
  15315. +   0xFF, 0xFF, 0xFF, 0xFF,
  15316.  
  15317. +   0xFF, 0xFF, 0xFF, 0xFF,
  15318.  
  15319. +   0xFF, 0xFF, 0xFF, 0xFF,
  15320.  
  15321. +   0xFF, 0xFF, 0xFF, 0xFF,
  15322.  
  15323. +   0xFF, 0xFF, 0xFF, 0xFF,
  15324.  
  15325. +   0xFF, 0xFF, 0xFF, 0xFF,
  15326.  
  15327. +   0xFF, 0xFF, 0xFF, 0xFF,
  15328.  
  15329. +   0xFF, 0xFF, 0xFF, 0xFF,
  15330.  
  15331. +   0xFF, 0xFF, 0xFF, 0xFF,
  15332.  
  15333. +   0xFF, 0xFF, 0xFF, 0xFF,
  15334.  
  15335. +   0xFF, 0xFF, 0xFF, 0xFF,
  15336.  
  15337. +   0xFF, 0xFF, 0xFF, 0xFF,
  15338.  
  15339. +   0xFF, 0xFF, 0xFF, 0xFF,
  15340.  
  15341. +   0xFF, 0xFF, 0xFF, 0xFF,
  15342.  
  15343. +   0xFF, 0xFF, 0xFF, 0xFF,
  15344.  
  15345. +   0xFF, 0xFF, 0xFF, 0xFF,
  15346.  
  15347. +   0xFF, 0xFF, 0xFF, 0xFF,
  15348.  
  15349. +   0xFF, 0xFF, 0xFF, 0xFF,
  15350.  
  15351. +   0xFF, 0xFF, 0xFF, 0xFF,
  15352.  
  15353. +   0xFF, 0xFF, 0xFF, 0xFF,
  15354.  
  15355. +   0xFF, 0xFF, 0xFF, 0xFF,
  15356.  
  15357. +   0xFF, 0xFF, 0xFF, 0xFF,
  15358.  
  15359. +   0xFF, 0xFF, 0xFF, 0xFF,
  15360.  
  15361. +   0xFF, 0xFF, 0xFF, 0xFF,
  15362.  
  15363. +   0xFF, 0xFF, 0xFF, 0xFF,
  15364.  
  15365. +   0xFF, 0xFF, 0xFF, 0xFF,
  15366.  
  15367. +   0xFF, 0xFF, 0xFF, 0xFF,
  15368.  
  15369. +   0xFF, 0xFF, 0xFF, 0xFF,
  15370.  
  15371. +   0xFF, 0xFF, 0xFF, 0xFF,
  15372.  
  15373. +   0xFF, 0xFF, 0xFF, 0xFF,
  15374.  
  15375. +   0xFF, 0xFF, 0xFF, 0xFF,
  15376.  
  15377. +   0xFF, 0xFF, 0xFF, 0xFF,
  15378.  
  15379. +   0xFF, 0xFF, 0xFF, 0xFF,
  15380.  
  15381. +   0xFF, 0xFF, 0xFF, 0xFF,
  15382.  
  15383. +   0xFF, 0xFF, 0xFF, 0xFF,
  15384.  
  15385. +   0xFF, 0xFF, 0xFF, 0xFF,
  15386.  
  15387. +   0xFF, 0xFF, 0xFF, 0xFF,
  15388.  
  15389. +   0xFF, 0xFF, 0xFF, 0xFF,
  15390.  
  15391. +   0xFF, 0xFF, 0xFF, 0xFF,
  15392.  
  15393. +   0xFF, 0xFF, 0xFF, 0xFF,
  15394.  
  15395. +   0xFF, 0xFF, 0xFF, 0xFF,
  15396.  
  15397. +   0xFF, 0xFF, 0xFF, 0xFF,
  15398.  
  15399. +   0xFF, 0xFF, 0xFF, 0xFF,
  15400.  
  15401. +   0xFF, 0xFF, 0xFF, 0xFF,
  15402.  
  15403. +   0xFF, 0xFF, 0xFF, 0xFF,
  15404.  
  15405. +   0xFF, 0xFF, 0xFF, 0xFF,
  15406.  
  15407. +   0xFF, 0xFF, 0xFF, 0xFF,
  15408.  
  15409. +   0xFF, 0xFF, 0xFF, 0xFF,
  15410.  
  15411. +   0xFF, 0xFF, 0xFF, 0xFF,
  15412.  
  15413. +   0xFF, 0xFF, 0xFF, 0xFF,
  15414.  
  15415. +   0xFF, 0xFF, 0xFF, 0xFF,
  15416.  
  15417. +   0xFF, 0xFF, 0xFF, 0xFF,
  15418.  
  15419. +   0xFF, 0xFF, 0xFF, 0xFF,
  15420.  
  15421. +   0xFF, 0xFF, 0xFF, 0xFF,
  15422.  
  15423. +   0xFF, 0xFF, 0xFF, 0xFF,
  15424.  
  15425. +   0xFF, 0xFF, 0xFF, 0xFF,
  15426.  
  15427. +   0xFF, 0xFF, 0xFF, 0xFF,
  15428.  
  15429. +   0xFF, 0xFF, 0xFF, 0xFF,
  15430.  
  15431. +   0xFF, 0xFF, 0xFF, 0xFF,
  15432.  
  15433. +   0xFF, 0xFF, 0xFF, 0xFF,
  15434.  
  15435. +   0xFF, 0xFF, 0xFF, 0xFF,
  15436.  
  15437. +   0xFF, 0xFF, 0xFF, 0xFF,
  15438.  
  15439. +   0xFF, 0xFF, 0xFF, 0xFF,
  15440.  
  15441. +   0xFF, 0xFF, 0xFF, 0xFF,
  15442.  
  15443. +   0xFF, 0xFF, 0xFF, 0xFF,
  15444.  
  15445. +   0xFF, 0xFF, 0xFF, 0xFF,
  15446.  
  15447. +   0xFF, 0xFF, 0xFF, 0xFF,
  15448.  
  15449. +   0xFF, 0xFF, 0xFF, 0xFF,
  15450.  
  15451. +   0xFF, 0xFF, 0xFF, 0xFF,
  15452.  
  15453. +   0xFF, 0xFF, 0xFF, 0xFF,
  15454.  
  15455. +   0xFF, 0xFF, 0xFF, 0xFF,
  15456.  
  15457. +   0xFF, 0xFF, 0xFF, 0xFF,
  15458.  
  15459. +   0xFF, 0xFF, 0xFF, 0xFF,
  15460.  
  15461. +   0xFF, 0xFF, 0xFF, 0xFF,
  15462.  
  15463. +   0xFF, 0xFF, 0xFF, 0xFF,
  15464.  
  15465. +   0xFF, 0xFF, 0xFF, 0xFF,
  15466.  
  15467. +   0xFF, 0xFF, 0xFF, 0xFF,
  15468.  
  15469. +   0xFF, 0xFF, 0xFF, 0xFF,
  15470.  
  15471. +   0xFF, 0xFF, 0xFF, 0xFF,
  15472.  
  15473. +   0xFF, 0xFF, 0xFF, 0xFF,
  15474.  
  15475. +   0xFF, 0xFF, 0xFF, 0xFF,
  15476.  
  15477. +   0xFF, 0xFF, 0xFF, 0xFF,
  15478.  
  15479. +   0xFF, 0xFF, 0xFF, 0xFF,
  15480.  
  15481. +   0xFF, 0xFF, 0xFF, 0xFF,
  15482.  
  15483. +   0xFF, 0xFF, 0xFF, 0xFF,
  15484.  
  15485. +   0xFF, 0xFF, 0xFF, 0xFF,
  15486.  
  15487. +   0xFF, 0xFF, 0xFF, 0xFF,
  15488.  
  15489. +   0xFF, 0xFF, 0xFF, 0xFF,
  15490.  
  15491. +   0xFF, 0xFF, 0xFF, 0xFF,
  15492.  
  15493. +   0xFF, 0xFF, 0xFF, 0xFF,
  15494.  
  15495. +   0xFF, 0xFF, 0xFF, 0xFF,
  15496.  
  15497. +   0xFF, 0xFF, 0xFF, 0xFF,
  15498.  
  15499. +   0xFF, 0xFF, 0xFF, 0xFF,
  15500.  
  15501. +   0xFF, 0xFF, 0xFF, 0xFF,
  15502.  
  15503. +   0xFF, 0xFF, 0xFF, 0xFF,
  15504.  
  15505. +   0xFF, 0xFF, 0xFF, 0xFF,
  15506.  
  15507. +   0xFF, 0xFF, 0xFF, 0xFF,
  15508.  
  15509. +   0xFF, 0xFF, 0xFF, 0xFF,
  15510.  
  15511. +   0xFF, 0xFF, 0xFF, 0xFF,
  15512.  
  15513. +   0xFF, 0xFF, 0xFF, 0xFF,
  15514.  
  15515. +   0xFF, 0xFF, 0xFF, 0xFF,
  15516.  
  15517. +   0xFF, 0xFF, 0xFF, 0xFF,
  15518.  
  15519. +   0xFF, 0xFF, 0xFF, 0xFF,
  15520.  
  15521. +   0xFF, 0xFF, 0xFF, 0xFF,
  15522.  
  15523. +   0xFF, 0xFF, 0xFF, 0xFF,
  15524.  
  15525. +   0xFF, 0xFF, 0xFF, 0xFF,
  15526.  
  15527. +   0xFF, 0xFF, 0xFF, 0xFF,
  15528.  
  15529. +   0xFF, 0xFF, 0xFF, 0xFF,
  15530.  
  15531. +   0xFF, 0xFF, 0xFF, 0xFF,
  15532.  
  15533. +   0xFF, 0xFF, 0xFF, 0xFF,
  15534.  
  15535. +   0xFF, 0xFF, 0xFF, 0xFF,
  15536.  
  15537. +   0xFF, 0xFF, 0xFF, 0xFF,
  15538.  
  15539. +   0xFF, 0xFF, 0xFF, 0xFF,
  15540.  
  15541. +   0xFF, 0xFF, 0xFF, 0xFF,
  15542.  
  15543. +   0xFF, 0xFF, 0xFF, 0xFF,
  15544.  
  15545. +   0xFF, 0xFF, 0xFF, 0xFF,
  15546.  
  15547. +   0xFF, 0xFF, 0xFF, 0xFF,
  15548.  
  15549. +   0xFF, 0xFF, 0xFF, 0xFF,
  15550.  
  15551. +   0xFF, 0xFF, 0xFF, 0xFF,
  15552.  
  15553. +   0xFF, 0xFF, 0xFF, 0xFF,
  15554.  
  15555. +   0xFF, 0xFF, 0xFF, 0xFF,
  15556.  
  15557. +   0xFF, 0xFF, 0xFF, 0xFF,
  15558.  
  15559. +   0xFF, 0xFF, 0xFF, 0xFF,
  15560.  
  15561. +   0xFF, 0xFF, 0xFF, 0xFF,
  15562.  
  15563. +   0xFF, 0xFF, 0xFF, 0xFF,
  15564.  
  15565. +   0xFF, 0xFF, 0xFF, 0xFF,
  15566.  
  15567. +   0xFF, 0xFF, 0xFF, 0xFF,
  15568.  
  15569. +   0xFF, 0xFF, 0xFF, 0xFF,
  15570.  
  15571. +   0xFF, 0xFF, 0xFF, 0xFF,
  15572.  
  15573. +   0xFF, 0xFF, 0xFF, 0xFF,
  15574.  
  15575. +   0xFF, 0xFF, 0xFF, 0xFF,
  15576.  
  15577. +   0xFF, 0xFF, 0xFF, 0xFF,
  15578.  
  15579. +   0xFF, 0xFF, 0xFF, 0xFF,
  15580.  
  15581. +   0xFF, 0xFF, 0xFF, 0xFF,
  15582.  
  15583. +   0xFF, 0xFF, 0xFF, 0xFF,
  15584.  
  15585. +   0xFF, 0xFF, 0xFF, 0xFF,
  15586.  
  15587. +   0xFF, 0xFF, 0xFF, 0xFF,
  15588.  
  15589. +   0xFF, 0xFF, 0xFF, 0xFF,
  15590.  
  15591. +   0xFF, 0xFF, 0xFF, 0xFF,
  15592.  
  15593. +   0xFF, 0xFF, 0xFF, 0xFF,
  15594.  
  15595. +   0xFF, 0xFF, 0xFF, 0xFF,
  15596.  
  15597. +   0xFF, 0xFF, 0xFF, 0xFF,
  15598.  
  15599. +   0xFF, 0xFF, 0xFF, 0xFF,
  15600.  
  15601. +   0xFF, 0xFF, 0xFF, 0xFF,
  15602.  
  15603. +   0xFF, 0xFF, 0xFF, 0xFF,
  15604.  
  15605. +   0xFF, 0xFF, 0xFF, 0xFF,
  15606.  
  15607. +   0xFF, 0xFF, 0xFF, 0xFF,
  15608.  
  15609. +   0xFF, 0xFF, 0xFF, 0xFF,
  15610.  
  15611. +   0xFF, 0xFF, 0xFF, 0xFF,
  15612.  
  15613. +   0xFF, 0xFF, 0xFF, 0xFF,
  15614.  
  15615. +   0xFF, 0xFF, 0xFF, 0xFF,
  15616.  
  15617. +   0xFF, 0xFF, 0xFF, 0xFF,
  15618.  
  15619. +   0xFF, 0xFF, 0xFF, 0xFF,
  15620.  
  15621. +   0xFF, 0xFF, 0xFF, 0xFF,
  15622.  
  15623. +   0xFF, 0xFF, 0xFF, 0xFF,
  15624.  
  15625. +   0xFF, 0xFF, 0xFF, 0xFF,
  15626.  
  15627. +   0xFF, 0xFF, 0xFF, 0xFF,
  15628.  
  15629. +   0xFF, 0xFF, 0xFF, 0xFF,
  15630.  
  15631. +   0xFF, 0xFF, 0xFF, 0xFF,
  15632.  
  15633. +   0xFF, 0xFF, 0xFF, 0xFF,
  15634.  
  15635. +   0xFF, 0xFF, 0xFF, 0xFF,
  15636.  
  15637. +   0xFF, 0xFF, 0xFF, 0xFF,
  15638.  
  15639. +   0xFF, 0xFF, 0xFF, 0xFF,
  15640.  
  15641. +   0xFF, 0xFF, 0xFF, 0xFF,
  15642.  
  15643. +   0xFF, 0xFF, 0xFF, 0xFF,
  15644.  
  15645. +   0xFF, 0xFF, 0xFF, 0xFF,
  15646.  
  15647. +   0xFF, 0xFF, 0xFF, 0xFF,
  15648.  
  15649. +   0xFF, 0xFF, 0xFF, 0xFF,
  15650.  
  15651. +   0xFF, 0xFF, 0xFF, 0xFF,
  15652.  
  15653. +   0xFF, 0xFF, 0xFF, 0xFF,
  15654.  
  15655. +   0xFF, 0xFF, 0xFF, 0xFF,
  15656.  
  15657. +   0xFF, 0xFF, 0xFF, 0xFF,
  15658.  
  15659. +   0xFF, 0xFF, 0xFF, 0xFF,
  15660.  
  15661. +   0xFF, 0xFF, 0xFF, 0xFF,
  15662.  
  15663. +   0xFF, 0xFF, 0xFF, 0xFF,
  15664.  
  15665. +   0xFF, 0xFF, 0xFF, 0xFF,
  15666.  
  15667. +   0xFF, 0xFF, 0xFF, 0xFF,
  15668.  
  15669. +   0xFF, 0xFF, 0xFF, 0xFF,
  15670.  
  15671. +   0xFF, 0xFF, 0xFF, 0xFF,
  15672.  
  15673. +   0xFF, 0xFF, 0xFF, 0xFF,
  15674.  
  15675. +   0xFF, 0xFF, 0xFF, 0xFF,
  15676.  
  15677. +   0xFF, 0xFF, 0xFF, 0xFF,
  15678.  
  15679. +   0xFF, 0xFF, 0xFF, 0xFF,
  15680.  
  15681. +   0xFF, 0xFF, 0xFF, 0xFF,
  15682.  
  15683. +   0xFF, 0xFF, 0xFF, 0xFF,
  15684.  
  15685. +   0xFF, 0xFF, 0xFF, 0xFF,
  15686.  
  15687. +   0xFF, 0xFF, 0xFF, 0xFF,
  15688.  
  15689. +   0xFF, 0xFF, 0xFF, 0xFF,
  15690.  
  15691. +   0xFF, 0xFF, 0xFF, 0xFF,
  15692.  
  15693. +   0xFF, 0xFF, 0xFF, 0xFF,
  15694.  
  15695. +   0xFF, 0xFF, 0xFF, 0xFF,
  15696.  
  15697. +   0xFF, 0xFF, 0xFF, 0xFF,
  15698.  
  15699. +   0xFF, 0xFF, 0xFF, 0xFF,
  15700.  
  15701. +   0xFF, 0xFF, 0xFF, 0xFF,
  15702.  
  15703. +   0xFF, 0xFF, 0xFF, 0xFF,
  15704.  
  15705. +   0xFF, 0xFF, 0xFF, 0xFF,
  15706.  
  15707. +   0xFF, 0xFF, 0xFF, 0xFF,
  15708.  
  15709. +   0xFF, 0xFF, 0xFF, 0xFF,
  15710.  
  15711. +   0xFF, 0xFF, 0xFF, 0xFF,
  15712.  
  15713. +   0xFF, 0xFF, 0xFF, 0xFF,
  15714.  
  15715. +   0xFF, 0xFF, 0xFF, 0xFF,
  15716.  
  15717. +   0xFF, 0xFF, 0xFF, 0xFF,
  15718.  
  15719. +   0xFF, 0xFF, 0xFF, 0xFF,
  15720.  
  15721. +   0xFF, 0xFF, 0xFF, 0xFF,
  15722.  
  15723. +   0xFF, 0xFF, 0xFF, 0xFF,
  15724.  
  15725. +   0xFF, 0xFF, 0xFF, 0xFF,
  15726.  
  15727. +   0xFF, 0xFF, 0xFF, 0xFF,
  15728.  
  15729. +   0xFF, 0xFF, 0xFF, 0xFF,
  15730.  
  15731. +   0xFF, 0xFF, 0xFF, 0xFF,
  15732.  
  15733. +   0xFF, 0xFF, 0xFF, 0xFF,
  15734.  
  15735. +   0xFF, 0xFF, 0xFF, 0xFF,
  15736.  
  15737. +   0xFF, 0xFF, 0xFF, 0xFF,
  15738.  
  15739. +   0xFF, 0xFF, 0xFF, 0xFF,
  15740.  
  15741. +   0xFF, 0xFF, 0xFF, 0xFF,
  15742.  
  15743. +   0xFF, 0xFF, 0xFF, 0xFF,
  15744.  
  15745. +   0xFF, 0xFF, 0xFF, 0xFF,
  15746.  
  15747. +   0xFF, 0xFF, 0xFF, 0xFF,
  15748.  
  15749. +   0xFF, 0xFF, 0xFF, 0xFF,
  15750.  
  15751. +   0xFF, 0xFF, 0xFF, 0xFF,
  15752.  
  15753. +   0xFF, 0xFF, 0xFF, 0xFF,
  15754.  
  15755. +   0xFF, 0xFF, 0xFF, 0xFF,
  15756.  
  15757. +   0xFF, 0xFF, 0xFF, 0xFF,
  15758.  
  15759. +   0xFF, 0xFF, 0xFF, 0xFF,
  15760.  
  15761. +   0xFF, 0xFF, 0xFF, 0xFF,
  15762.  
  15763. +   0xFF, 0xFF, 0xFF, 0xFF,
  15764.  
  15765. +   0xFF, 0xFF, 0xFF, 0xFF,
  15766.  
  15767. +   0xFF, 0xFF, 0xFF, 0xFF,
  15768.  
  15769. +   0xFF, 0xFF, 0xFF, 0xFF,
  15770.  
  15771. +   0xFF, 0xFF, 0xFF, 0xFF,
  15772.  
  15773. +   0xFF, 0xFF, 0xFF, 0xFF,
  15774.  
  15775. +   0xFF, 0xFF, 0xFF, 0xFF,
  15776.  
  15777. +   0xFF, 0xFF, 0xFF, 0xFF,
  15778.  
  15779. +   0xFF, 0xFF, 0xFF, 0xFF,
  15780.  
  15781. +   0xFF, 0xFF, 0xFF, 0xFF,
  15782.  
  15783. +   0xFF, 0xFF, 0xFF, 0xFF,
  15784.  
  15785. +   0xFF, 0xFF, 0xFF, 0xFF,
  15786.  
  15787. +   0xFF, 0xFF, 0xFF, 0xFF,
  15788.  
  15789. +   0xFF, 0xFF, 0xFF, 0xFF,
  15790.  
  15791. +   0xFF, 0xFF, 0xFF, 0xFF,
  15792.  
  15793. +   0xFF, 0xFF, 0xFF, 0xFF,
  15794.  
  15795. +   0xFF, 0xFF, 0xFF, 0xFF,
  15796.  
  15797. +   0xFF, 0xFF, 0xFF, 0xFF,
  15798.  
  15799. +   0xFF, 0xFF, 0xFF, 0xFF,
  15800.  
  15801. +   0xFF, 0xFF, 0xFF, 0xFF,
  15802.  
  15803. +   0xFF, 0xFF, 0xFF, 0xFF,
  15804.  
  15805. +   0xFF, 0xFF, 0xFF, 0xFF,
  15806.  
  15807. +   0xFF, 0xFF, 0xFF, 0xFF,
  15808.  
  15809. +   0xFF, 0xFF, 0xFF, 0xFF,
  15810.  
  15811. +   0xFF, 0xFF, 0xFF, 0xFF,
  15812.  
  15813. +   0xFF, 0xFF, 0xFF, 0xFF,
  15814.  
  15815. +   0xFF, 0xFF, 0xFF, 0xFF,
  15816.  
  15817. +   0xFF, 0xFF, 0xFF, 0xFF,
  15818.  
  15819. +   0xFF, 0xFF, 0xFF, 0xFF,
  15820.  
  15821. +   0xFF, 0xFF, 0xFF, 0xFF,
  15822.  
  15823. +   0xFF, 0xFF, 0xFF, 0xFF,
  15824.  
  15825. +   0xFF, 0xFF, 0xFF, 0xFF,
  15826.  
  15827. +   0xFF, 0xFF, 0xFF, 0xFF,
  15828.  
  15829. +   0xFF, 0xFF, 0xFF, 0xFF,
  15830.  
  15831. +   0xFF, 0xFF, 0xFF, 0xFF,
  15832.  
  15833. +   0xFF, 0xFF, 0xFF, 0xFF,
  15834.  
  15835. +   0xFF, 0xFF, 0xFF, 0xFF,
  15836.  
  15837. +   0xFF, 0xFF, 0xFF, 0xFF,
  15838.  
  15839. +   0xFF, 0xFF, 0xFF, 0xFF,
  15840.  
  15841. +   0xFF, 0xFF, 0xFF, 0xFF,
  15842.  
  15843. +   0xFF, 0xFF, 0xFF, 0xFF,
  15844.  
  15845. +   0xFF, 0xFF, 0xFF, 0xFF,
  15846.  
  15847. +   0xFF, 0xFF, 0xFF, 0xFF,
  15848.  
  15849. +   0xFF, 0xFF, 0xFF, 0xFF,
  15850.  
  15851. +   0xFF, 0xFF, 0xFF, 0xFF,
  15852.  
  15853. +   0xFF, 0xFF, 0xFF, 0xFF,
  15854.  
  15855. +   0xFF, 0xFF, 0xFF, 0xFF,
  15856.  
  15857. +   0xFF, 0xFF, 0xFF, 0xFF,
  15858.  
  15859. +   0xFF, 0xFF, 0xFF, 0xFF,
  15860.  
  15861. +   0xFF, 0xFF, 0xFF, 0xFF,
  15862.  
  15863. +   0xFF, 0xFF, 0xFF, 0xFF,
  15864.  
  15865. +   0xFF, 0xFF, 0xFF, 0xFF,
  15866.  
  15867. +   0xFF, 0xFF, 0xFF, 0xFF,
  15868.  
  15869. +   0xFF, 0xFF, 0xFF, 0xFF,
  15870.  
  15871. +   0xFF, 0xFF, 0xFF, 0xFF,
  15872.  
  15873. +   0xFF, 0xFF, 0xFF, 0xFF,
  15874.  
  15875. +   0xFF, 0xFF, 0xFF, 0xFF,
  15876.  
  15877. +   0xFF, 0xFF, 0xFF, 0xFF,
  15878.  
  15879. +   0xFF, 0xFF, 0xFF, 0xFF,
  15880.  
  15881. +   0xFF, 0xFF, 0xFF, 0xFF,
  15882.  
  15883. +   0xFF, 0xFF, 0xFF, 0xFF,
  15884.  
  15885. +   0xFF, 0xFF, 0xFF, 0xFF,
  15886.  
  15887. +   0xFF, 0xFF, 0xFF, 0xFF,
  15888.  
  15889. +   0xFF, 0xFF, 0xFF, 0xFF,
  15890.  
  15891. +   0xFF, 0xFF, 0xFF, 0xFF,
  15892.  
  15893. +   0xFF, 0xFF, 0xFF, 0xFF,
  15894.  
  15895. +   0xFF, 0xFF, 0xFF, 0xFF,
  15896.  
  15897. +   0xFF, 0xFF, 0xFF, 0xFF,
  15898.  
  15899. +   0xFF, 0xFF, 0xFF, 0xFF,
  15900.  
  15901. +   0xFF, 0xFF, 0xFF, 0xFF,
  15902.  
  15903. +   0xFF, 0xFF, 0xFF, 0xFF,
  15904.  
  15905. +   0xFF, 0xFF, 0xFF, 0xFF,
  15906.  
  15907. +   0xFF, 0xFF, 0xFF, 0xFF,
  15908.  
  15909. +   0xFF, 0xFF, 0xFF, 0xFF,
  15910.  
  15911. +   0xFF, 0xFF, 0xFF, 0xFF,
  15912.  
  15913. +   0xFF, 0xFF, 0xFF, 0xFF,
  15914.  
  15915. +   0xFF, 0xFF, 0xFF, 0xFF,
  15916.  
  15917. +   0xFF, 0xFF, 0xFF, 0xFF,
  15918.  
  15919. +   0xFF, 0xFF, 0xFF, 0xFF,
  15920.  
  15921. +   0xFF, 0xFF, 0xFF, 0xFF,
  15922.  
  15923. +   0xFF, 0xFF, 0xFF, 0xFF,
  15924.  
  15925. +   0xFF, 0xFF, 0xFF, 0xFF,
  15926.  
  15927. +   0xFF, 0xFF, 0xFF, 0xFF,
  15928.  
  15929. +   0xFF, 0xFF, 0xFF, 0xFF,
  15930.  
  15931. +   0xFF, 0xFF, 0xFF, 0xFF,
  15932.  
  15933. +   0xFF, 0xFF, 0xFF, 0xFF,
  15934.  
  15935. +   0xFF, 0xFF, 0xFF, 0xFF,
  15936.  
  15937. +   0xFF, 0xFF, 0xFF, 0xFF,
  15938.  
  15939. +   0xFF, 0xFF, 0xFF, 0xFF,
  15940.  
  15941. +   0xFF, 0xFF, 0xFF, 0xFF,
  15942.  
  15943. +   0xFF, 0xFF, 0xFF, 0xFF,
  15944.  
  15945. +   0xFF, 0xFF, 0xFF, 0xFF,
  15946.  
  15947. +   0xFF, 0xFF, 0xFF, 0xFF,
  15948.  
  15949. +   0xFF, 0xFF, 0xFF, 0xFF,
  15950.  
  15951. +   0xFF, 0xFF, 0xFF, 0xFF,
  15952.  
  15953. +   0xFF, 0xFF, 0xFF, 0xFF,
  15954.  
  15955. +   0xFF, 0xFF, 0xFF, 0xFF,
  15956.  
  15957. +   0xFF, 0xFF, 0xFF, 0xFF,
  15958.  
  15959. +   0xFF, 0xFF, 0xFF, 0xFF,
  15960.  
  15961. +   0xFF, 0xFF, 0xFF, 0xFF,
  15962.  
  15963. +   0xFF, 0xFF, 0xFF, 0xFF,
  15964.  
  15965. +   0xFF, 0xFF, 0xFF, 0xFF,
  15966.  
  15967. +   0xFF, 0xFF, 0xFF, 0xFF,
  15968.  
  15969. +   0xFF, 0xFF, 0xFF, 0xFF,
  15970.  
  15971. +   0xFF, 0xFF, 0xFF, 0xFF,
  15972.  
  15973. +   0xFF, 0xFF, 0xFF, 0xFF,
  15974.  
  15975. +   0xFF, 0xFF, 0xFF, 0xFF,
  15976.  
  15977. +   0xFF, 0xFF, 0xFF, 0xFF,
  15978.  
  15979. +   0xFF, 0xFF, 0xFF, 0xFF,
  15980.  
  15981. +   0xFF, 0xFF, 0xFF, 0xFF,
  15982.  
  15983. +   0xFF, 0xFF, 0xFF, 0xFF,
  15984.  
  15985. +   0xFF, 0xFF, 0xFF, 0xFF,
  15986.  
  15987. +   0xFF, 0xFF, 0xFF, 0xFF,
  15988.  
  15989. +   0xFF, 0xFF, 0xFF, 0xFF,
  15990.  
  15991. +   0xFF, 0xFF, 0xFF, 0xFF,
  15992.  
  15993. +   0xFF, 0xFF, 0xFF, 0xFF,
  15994.  
  15995. +   0xFF, 0xFF, 0xFF, 0xFF,
  15996.  
  15997. +   0xFF, 0xFF, 0xFF, 0xFF,
  15998.  
  15999. +   0xFF, 0xFF, 0xFF, 0xFF,
  16000.  
  16001. +   0xFF, 0xFF, 0xFF, 0xFF,
  16002.  
  16003. +   0xFF, 0xFF, 0xFF, 0xFF,
  16004.  
  16005. +   0xFF, 0xFF, 0xFF, 0xFF,
  16006.  
  16007. +   0xFF, 0xFF, 0xFF, 0xFF,
  16008.  
  16009. +   0xFF, 0xFF, 0xFF, 0xFF,
  16010.  
  16011. +   0xFF, 0xFF, 0xFF, 0xFF,
  16012.  
  16013. +   0xFF, 0xFF, 0xFF, 0xFF,
  16014.  
  16015. +   0xFF, 0xFF, 0xFF, 0xFF,
  16016.  
  16017. +   0xFF, 0xFF, 0xFF, 0xFF,
  16018.  
  16019. +   0xFF, 0xFF, 0xFF, 0xFF,
  16020.  
  16021. +   0xFF, 0xFF, 0xFF, 0xFF,
  16022.  
  16023. +   0xFF, 0xFF, 0xFF, 0xFF,
  16024.  
  16025. +   0xFF, 0xFF, 0xFF, 0xFF,
  16026.  
  16027. +   0xFF, 0xFF, 0xFF, 0xFF,
  16028.  
  16029. +   0xFF, 0xFF, 0xFF, 0xFF,
  16030.  
  16031. +   0xFF, 0xFF, 0xFF, 0xFF,
  16032.  
  16033. +   0xFF, 0xFF, 0xFF, 0xFF,
  16034.  
  16035. +   0xFF, 0xFF, 0xFF, 0xFF,
  16036.  
  16037. +   0xFF, 0xFF, 0xFF, 0xFF,
  16038.  
  16039. +   0xFF, 0xFF, 0xFF, 0xFF,
  16040.  
  16041. +   0xFF, 0xFF, 0xFF, 0xFF,
  16042.  
  16043. +   0xFF, 0xFF, 0xFF, 0xFF,
  16044.  
  16045. +   0xFF, 0xFF, 0xFF, 0xFF,
  16046.  
  16047. +   0xFF, 0xFF, 0xFF, 0xFF,
  16048.  
  16049. +   0xFF, 0xFF, 0xFF, 0xFF,
  16050.  
  16051. +   0xFF, 0xFF, 0xFF, 0xFF,
  16052.  
  16053. +   0xFF, 0xFF, 0xFF, 0xFF,
  16054.  
  16055. +   0xFF, 0xFF, 0xFF, 0xFF,
  16056.  
  16057. +   0xFF, 0xFF, 0xFF, 0xFF,
  16058.  
  16059. +   0xFF, 0xFF, 0xFF, 0xFF,
  16060.  
  16061. +   0xFF, 0xFF, 0xFF, 0xFF,
  16062.  
  16063. +   0xFF, 0xFF, 0xFF, 0xFF,
  16064.  
  16065. +   0xFF, 0xFF, 0xFF, 0xFF,
  16066.  
  16067. +   0xFF, 0xFF, 0xFF, 0xFF,
  16068.  
  16069. +   0xFF, 0xFF, 0xFF, 0xFF,
  16070.  
  16071. +   0xFF, 0xFF, 0xFF, 0xFF,
  16072.  
  16073. +   0xFF, 0xFF, 0xFF, 0xFF,
  16074.  
  16075. +   0xFF, 0xFF, 0xFF, 0xFF,
  16076.  
  16077. +   0xFF, 0xFF, 0xFF, 0xFF,
  16078.  
  16079. +   0xFF, 0xFF, 0xFF, 0xFF,
  16080.  
  16081. +   0xFF, 0xFF, 0xFF, 0xFF,
  16082.  
  16083. +   0xFF, 0xFF, 0xFF, 0xFF,
  16084.  
  16085. +   0xFF, 0xFF, 0xFF, 0xFF,
  16086.  
  16087. +   0xFF, 0xFF, 0xFF, 0xFF,
  16088.  
  16089. +   0xFF, 0xFF, 0xFF, 0xFF,
  16090.  
  16091. +   0xFF, 0xFF, 0xFF, 0xFF,
  16092.  
  16093. +   0xFF, 0xFF, 0xFF, 0xFF,
  16094.  
  16095. +   0xFF, 0xFF, 0xFF, 0xFF,
  16096.  
  16097. +   0xFF, 0xFF, 0xFF, 0x02,
  16098.  
  16099. +   0x10, 0x28, 0x02, 0x10,
  16100.  
  16101. +   0x3B, 0x02, 0x10, 0x3C,
  16102.  
  16103. +   0x02, 0x12, 0xB8, 0x02,
  16104.  
  16105. +   0x12, 0xB9, 0x02, 0x13,
  16106.  
  16107. +   0x3E, 0x02, 0x13, 0x3F,
  16108.  
  16109. +   0xC3, 0x22, 0xFF, 0xFF,
  16110.  
  16111. +   0x02, 0x16, 0x56, 0x02,
  16112.  
  16113. +   0x17, 0x6B, 0x02, 0x14,
  16114.  
  16115. +   0x2A, 0x02, 0x13, 0x40,
  16116.  
  16117. +   0x30, 0x05, 0x06, 0x20,
  16118.  
  16119. +   0x0D, 0x03, 0x12, 0x00,
  16120.  
  16121. +   0xD8, 0x30, 0x06, 0x06,
  16122.  
  16123. +   0x20, 0x0E, 0x03, 0x12,
  16124.  
  16125. +   0x18, 0x5E, 0x22, 0x22,
  16126.  
  16127. +   0x90, 0x04, 0x14, 0xE0,
  16128.  
  16129. +   0x20, 0xE7, 0x03, 0x02,
  16130.  
  16131. +   0x12, 0xB7, 0x90, 0x70,
  16132.  
  16133. +   0x12, 0xE0, 0xF5, 0x56,
  16134.  
  16135. +   0x90, 0x04, 0x04, 0xE0,
  16136.  
  16137. +   0x12, 0x02, 0x67, 0x11,
  16138.  
  16139. +   0x4E, 0x30, 0x11, 0x25,
  16140.  
  16141. +   0x31, 0x10, 0x87, 0x33,
  16142.  
  16143. +   0x10, 0xAA, 0x34, 0x10,
  16144.  
  16145. +   0xC3, 0x35, 0x11, 0x57,
  16146.  
  16147. +   0x50, 0x11, 0x7B, 0x51,
  16148.  
  16149. +   0x11, 0x84, 0x52, 0x11,
  16150.  
  16151. +   0x84, 0x53, 0x11, 0x84,
  16152.  
  16153. +   0x54, 0x11, 0xC5, 0x55,
  16154.  
  16155. +   0x11, 0xDC, 0x70, 0x12,
  16156.  
  16157. +   0x07, 0x71, 0x12, 0x34,
  16158.  
  16159. +   0x72, 0x12, 0x5E, 0x80,
  16160.  
  16161. +   0x12, 0x81, 0x83, 0x00,
  16162.  
  16163. +   0x00, 0x12, 0xB7, 0x75,
  16164.  
  16165. +   0x24, 0x05, 0x75, 0x25,
  16166.  
  16167. +   0xDC, 0x90, 0x70, 0x9F,
  16168.  
  16169. +   0x74, 0x12, 0xF0, 0xD2,
  16170.  
  16171. +   0x18, 0xD2, 0x61, 0x75,
  16172.  
  16173. +   0x35, 0x0D, 0xE4, 0x90,
  16174.  
  16175. +   0x70, 0x13, 0xF0, 0xE5,
  16176.  
  16177. +   0x56, 0xF4, 0x70, 0x03,
  16178.  
  16179. +   0x02, 0x12, 0xB7, 0x02,
  16180.  
  16181. +   0x12, 0xAA, 0xC2, 0x18,
  16182.  
  16183. +   0x90, 0x01, 0x14, 0xE0,
  16184.  
  16185. +   0x54, 0xFD, 0xF0, 0xE4,
  16186.  
  16187. +   0x90, 0x70, 0x13, 0xF0,
  16188.  
  16189. +   0xE5, 0x56, 0xF4, 0x70,
  16190.  
  16191. +   0x03, 0x02, 0x12, 0xB7,
  16192.  
  16193. +   0x02, 0x12, 0xAA, 0xE5,
  16194.  
  16195. +   0x55, 0x64, 0x02, 0x70,
  16196.  
  16197. +   0x37, 0x90, 0x70, 0x10,
  16198.  
  16199. +   0xE0, 0x60, 0x08, 0x90,
  16200.  
  16201. +   0x01, 0x0D, 0x74, 0x09,
  16202.  
  16203. +   0xF0, 0x80, 0x25, 0xE5,
  16204.  
  16205. +   0x34, 0x14, 0x60, 0x0A,
  16206.  
  16207. +   0x14, 0x60, 0x0F, 0x14,
  16208.  
  16209. +   0x60, 0x14, 0x24, 0x03,
  16210.  
  16211. +   0x70, 0x16, 0x90, 0x01,
  16212.  
  16213. +   0x0D, 0x74, 0x08, 0xF0,
  16214.  
  16215. +   0x80, 0x0E, 0x90, 0x01,
  16216.  
  16217. +   0x0D, 0x74, 0x0B, 0xF0,
  16218.  
  16219. +   0x80, 0x06, 0x90, 0x01,
  16220.  
  16221. +   0x0D, 0x74, 0x1B, 0xF0,
  16222.  
  16223. +   0x7D, 0x01, 0x80, 0x02,
  16224.  
  16225. +   0x7D, 0x02, 0xAF, 0x56,
  16226.  
  16227. +   0x12, 0x02, 0x8D, 0x90,
  16228.  
  16229. +   0x70, 0x11, 0xE0, 0x24,
  16230.  
  16231. +   0xFF, 0x92, 0x1B, 0x90,
  16232.  
  16233. +   0x04, 0x14, 0x74, 0x80,
  16234.  
  16235. +   0xF0, 0xE4, 0x90, 0x70,
  16236.  
  16237. +   0x13, 0xF0, 0xE5, 0x56,
  16238.  
  16239. +   0xF4, 0x70, 0x03, 0x02,
  16240.  
  16241. +   0x12, 0xB7, 0x02, 0x12,
  16242.  
  16243. +   0xAA, 0x20, 0x02, 0x03,
  16244.  
  16245. +   0x30, 0x03, 0x1D, 0x7D,
  16246.  
  16247. +   0x02, 0xAF, 0x56, 0x12,
  16248.  
  16249. +   0x02, 0x8D, 0x90, 0x04,
  16250.  
  16251. +   0x14, 0x74, 0x80, 0xF0,
  16252.  
  16253. +   0xE4, 0x90, 0x70, 0x13,
  16254.  
  16255. +   0xF0, 0xE5, 0x56, 0xF4,
  16256.  
  16257. +   0x70, 0x03, 0x02, 0x12,
  16258.  
  16259. +   0xB7, 0x02, 0x12, 0xAA,
  16260.  
  16261. +   0x85, 0x56, 0x41, 0xD2,
  16262.  
  16263. +   0x02, 0x22, 0x90, 0x70,
  16264.  
  16265. +   0x11, 0xE0, 0x24, 0xFF,
  16266.  
  16267. +   0x92, 0x1B, 0x22, 0x90,
  16268.  
  16269. +   0x70, 0x10, 0xE0, 0x54,
  16270.  
  16271. +   0x7F, 0x64, 0x02, 0x60,
  16272.  
  16273. +   0x03, 0x02, 0x12, 0xB7,
  16274.  
  16275. +   0x90, 0x70, 0x11, 0xE0,
  16276.  
  16277. +   0x64, 0x08, 0x60, 0x08,
  16278.  
  16279. +   0xE0, 0x64, 0x20, 0x60,
  16280.  
  16281. +   0x03, 0x02, 0x12, 0xB7,
  16282.  
  16283. +   0x75, 0x4E, 0x03, 0x75,
  16284.  
  16285. +   0x4F, 0x20, 0x22, 0x90,
  16286.  
  16287. +   0x70, 0x11, 0xE0, 0x24,
  16288.  
  16289. +   0xFF, 0x92, 0x47, 0x22,
  16290.  
  16291. +   0x90, 0x04, 0x04, 0xE0,
  16292.  
  16293. +   0x25, 0xE0, 0x24, 0x5D,
  16294.  
  16295. +   0xF5, 0x57, 0x90, 0x70,
  16296.  
  16297. +   0x10, 0xE0, 0xFF, 0x74,
  16298.  
  16299. +   0x47, 0x25, 0x57, 0xF8,
  16300.  
  16301. +   0xC6, 0xEF, 0xC6, 0x90,
  16302.  
  16303. +   0x70, 0x11, 0xE0, 0xFF,
  16304.  
  16305. +   0x74, 0x48, 0x25, 0x57,
  16306.  
  16307. +   0xF8, 0xC6, 0xEF, 0xC6,
  16308.  
  16309. +   0xE4, 0xFD, 0xAF, 0x56,
  16310.  
  16311. +   0x12, 0x02, 0x8D, 0x90,
  16312.  
  16313. +   0x04, 0x14, 0x74, 0x80,
  16314.  
  16315. +   0xF0, 0xE4, 0x90, 0x70,
  16316.  
  16317. +   0x13, 0xF0, 0xE5, 0x56,
  16318.  
  16319. +   0xF4, 0x70, 0x03, 0x02,
  16320.  
  16321. +   0x12, 0xB7, 0x02, 0x12,
  16322.  
  16323. +   0xAA, 0xE5, 0x47, 0xB4,
  16324.  
  16325. +   0x07, 0x08, 0x90, 0x70,
  16326.  
  16327. +   0x11, 0xE0, 0x54, 0x07,
  16328.  
  16329. +   0xF5, 0x26, 0xE4, 0xFD,
  16330.  
  16331. +   0xAF, 0x56, 0x12, 0x02,
  16332.  
  16333. +   0x8D, 0xD2, 0x04, 0x22,
  16334.  
  16335. +   0x90, 0x70, 0x10, 0xE0,
  16336.  
  16337. +   0xFE, 0x90, 0x70, 0x11,
  16338.  
  16339. +   0xE0, 0xFD, 0xED, 0xF8,
  16340.  
  16341. +   0xE6, 0xF5, 0x57, 0xFD,
  16342.  
  16343. +   0xAF, 0x56, 0x12, 0x02,
  16344.  
  16345. +   0x8D, 0x90, 0x04, 0x14,
  16346.  
  16347. +   0x74, 0x80, 0xF0, 0xE4,
  16348.  
  16349. +   0x90, 0x70, 0x13, 0xF0,
  16350.  
  16351. +   0xE5, 0x56, 0xF4, 0x70,
  16352.  
  16353. +   0x03, 0x02, 0x12, 0xB7,
  16354.  
  16355. +   0x02, 0x12, 0xAA, 0x90,
  16356.  
  16357. +   0x70, 0x10, 0xE0, 0xFE,
  16358.  
  16359. +   0x90, 0x70, 0x11, 0xE0,
  16360.  
  16361. +   0xFD, 0xED, 0xF5, 0x82,
  16362.  
  16363. +   0x8E, 0x83, 0xE0, 0xF5,
  16364.  
  16365. +   0x57, 0xFD, 0xAF, 0x56,
  16366.  
  16367. +   0x12, 0x02, 0x8D, 0x90,
  16368.  
  16369. +   0x04, 0x14, 0x74, 0x80,
  16370.  
  16371. +   0xF0, 0xE4, 0x90, 0x70,
  16372.  
  16373. +   0x13, 0xF0, 0xE5, 0x56,
  16374.  
  16375. +   0xF4, 0x70, 0x03, 0x02,
  16376.  
  16377. +   0x12, 0xB7, 0x80, 0x76,
  16378.  
  16379. +   0xE4, 0xF5, 0x4E, 0xF5,
  16380.  
  16381. +   0x4F, 0x75, 0x26, 0xFF,
  16382.  
  16383. +   0xC2, 0x19, 0xC2, 0x18,
  16384.  
  16385. +   0xC2, 0x1A, 0x75, 0x34,
  16386.  
  16387. +   0xFF, 0xAD, 0x57, 0xAF,
  16388.  
  16389. +   0x56, 0x12, 0x02, 0x8D,
  16390.  
  16391. +   0x90, 0x04, 0x14, 0x74,
  16392.  
  16393. +   0x80, 0xF0, 0xE4, 0x90,
  16394.  
  16395. +   0x70, 0x13, 0xF0, 0xE5,
  16396.  
  16397. +   0x56, 0xF4, 0x60, 0x5B,
  16398.  
  16399. +   0x80, 0x4C, 0x90, 0x70,
  16400.  
  16401. +   0x10, 0xE0, 0x24, 0xFF,
  16402.  
  16403. +   0x92, 0x4A, 0xD2, 0x05,
  16404.  
  16405. +   0xAD, 0x57, 0xAF, 0x56,
  16406.  
  16407. +   0x12, 0x02, 0x8D, 0x90,
  16408.  
  16409. +   0x04, 0x14, 0x74, 0x80,
  16410.  
  16411. +   0xF0, 0xE4, 0x90, 0x70,
  16412.  
  16413. +   0x13, 0xF0, 0xE5, 0x56,
  16414.  
  16415. +   0xF4, 0x60, 0x38, 0x80,
  16416.  
  16417. +   0x29, 0x90, 0x70, 0x10,
  16418.  
  16419. +   0xE0, 0xF5, 0x34, 0xD3,
  16420.  
  16421. +   0x94, 0x00, 0x40, 0x07,
  16422.  
  16423. +   0x90, 0x01, 0x0D, 0xE0,
  16424.  
  16425. +   0x54, 0xFB, 0xF0, 0xAD,
  16426.  
  16427. +   0x57, 0xAF, 0x56, 0x12,
  16428.  
  16429. +   0x02, 0x8D, 0x90, 0x04,
  16430.  
  16431. +   0x14, 0x74, 0x80, 0xF0,
  16432.  
  16433. +   0xE4, 0x90, 0x70, 0x13,
  16434.  
  16435. +   0xF0, 0xE5, 0x56, 0xF4,
  16436.  
  16437. +   0x60, 0x0D, 0x90, 0x70,
  16438.  
  16439. +   0x25, 0xE0, 0x44, 0x01,
  16440.  
  16441. +   0xF0, 0x90, 0x02, 0x2C,
  16442.  
  16443. +   0x74, 0xFF, 0xF0, 0x22,
  16444.  
  16445. +   0x22, 0xE5, 0x53, 0x60,
  16446.  
  16447. +   0x03, 0x02, 0x13, 0x3D,
  16448.  
  16449. +   0xE5, 0x4F, 0x45, 0x4E,
  16450.  
  16451. +   0x60, 0x08, 0xE5, 0x4F,
  16452.  
  16453. +   0x15, 0x4F, 0x70, 0x02,
  16454.  
  16455. +   0x15, 0x4E, 0xA2, 0x19,
  16456.  
  16457. +   0xE4, 0x33, 0x90, 0x70,
  16458.  
  16459. +   0x90, 0xF0, 0xA2, 0x18,
  16460.  
  16461. +   0xE4, 0x33, 0xA3, 0xF0,
  16462.  
  16463. +   0x30, 0x19, 0x4D, 0x90,
  16464.  
  16465. +   0x70, 0x98, 0x74, 0x23,
  16466.  
  16467. +   0xF0, 0xA3, 0xE5, 0x25,
  16468.  
  16469. +   0xF0, 0xE5, 0x24, 0xA3,
  16470.  
  16471. +   0xF0, 0x7F, 0x35, 0x7D,
  16472.  
  16473. +   0x32, 0x12, 0x03, 0x42,
  16474.  
  16475. +   0x50, 0x09, 0x90, 0x10,
  16476.  
  16477. +   0x04, 0xE0, 0x54, 0xF7,
  16478.  
  16479. +   0xF0, 0xD2, 0x06, 0xE5,
  16480.  
  16481. +   0x35, 0xD3, 0x94, 0x10,
  16482.  
  16483. +   0x40, 0x1E, 0x30, 0x1A,
  16484.  
  16485. +   0x1B, 0xC2, 0x1A, 0xA2,
  16486.  
  16487. +   0x18, 0x92, 0x19, 0x20,
  16488.  
  16489. +   0x19, 0x12, 0x90, 0x04,
  16490.  
  16491. +   0x09, 0xE0, 0x54, 0xDD,
  16492.  
  16493. +   0xF0, 0x90, 0x10, 0x04,
  16494.  
  16495. +   0xE0, 0x44, 0x08, 0xF0,
  16496.  
  16497. +   0xC2, 0x61, 0xD2, 0x03,
  16498.  
  16499. +   0xE5, 0x35, 0xB4, 0x0B,
  16500.  
  16501. +   0x14, 0xD2, 0x03, 0x22,
  16502.  
  16503. +   0xE4, 0xF5, 0x35, 0xA2,
  16504.  
  16505. +   0x18, 0x92, 0x19, 0x30,
  16506.  
  16507. +   0x19, 0x07, 0x90, 0x04,
  16508.  
  16509. +   0x09, 0xE0, 0x44, 0x22,
  16510.  
  16511. +   0xF0, 0x22, 0x22, 0x22,
  16512.  
  16513. +   0xC2, 0x4B, 0xC2, 0x4C,
  16514.  
  16515. +   0xE5, 0x44, 0x12, 0x02,
  16516.  
  16517. +   0x67, 0x13, 0x62, 0x00,
  16518.  
  16519. +   0x13, 0xF5, 0x04, 0x13,
  16520.  
  16521. +   0xF1, 0x08, 0x13, 0xCC,
  16522.  
  16523. +   0x10, 0x13, 0x76, 0x20,
  16524.  
  16525. +   0x13, 0x96, 0x60, 0x13,
  16526.  
  16527. +   0xA7, 0xA0, 0x00, 0x00,
  16528.  
  16529. +   0x13, 0xF7, 0x85, 0x48,
  16530.  
  16531. +   0x43, 0x85, 0x4A, 0x42,
  16532.  
  16533. +   0x85, 0x4C, 0x5E, 0xE5,
  16534.  
  16535. +   0x47, 0x64, 0x06, 0x60,
  16536.  
  16537. +   0x03, 0x02, 0x13, 0xF7,
  16538.  
  16539. +   0x80, 0x1B, 0xE5, 0x48,
  16540.  
  16541. +   0xC4, 0x54, 0x0F, 0xF5,
  16542.  
  16543. +   0x43, 0xE5, 0x4A, 0xC4,
  16544.  
  16545. +   0x54, 0x0F, 0xF5, 0x42,
  16546.  
  16547. +   0xE5, 0x4C, 0xC4, 0x54,
  16548.  
  16549. +   0x0F, 0xF5, 0x5E, 0xE5,
  16550.  
  16551. +   0x47, 0x64, 0x06, 0x70,
  16552.  
  16553. +   0x66, 0x53, 0x43, 0x0F,
  16554.  
  16555. +   0x80, 0x61, 0x85, 0x49,
  16556.  
  16557. +   0x43, 0x85, 0x4B, 0x42,
  16558.  
  16559. +   0x85, 0x4D, 0x5E, 0xE5,
  16560.  
  16561. +   0x47, 0x64, 0x06, 0x70,
  16562.  
  16563. +   0x52, 0x80, 0x1B, 0xE5,
  16564.  
  16565. +   0x49, 0xC4, 0x54, 0x0F,
  16566.  
  16567. +   0xF5, 0x43, 0xE5, 0x4B,
  16568.  
  16569. +   0xC4, 0x54, 0x0F, 0xF5,
  16570.  
  16571. +   0x42, 0xE5, 0x4D, 0xC4,
  16572.  
  16573. +   0x54, 0x0F, 0xF5, 0x5E,
  16574.  
  16575. +   0xE5, 0x47, 0x64, 0x06,
  16576.  
  16577. +   0x70, 0x35, 0xE5, 0x43,
  16578.  
  16579. +   0x54, 0x0F, 0x44, 0x10,
  16580.  
  16581. +   0xF5, 0x43, 0x80, 0x2B,
  16582.  
  16583. +   0xE5, 0x47, 0xB4, 0x04,
  16584.  
  16585. +   0x06, 0x53, 0x5E, 0xFB,
  16586.  
  16587. +   0x75, 0x42, 0x09, 0xE5,
  16588.  
  16589. +   0x47, 0xB4, 0x05, 0x06,
  16590.  
  16591. +   0x43, 0x5E, 0x04, 0x75,
  16592.  
  16593. +   0x42, 0x09, 0xE5, 0x47,
  16594.  
  16595. +   0xB4, 0x06, 0x10, 0xE5,
  16596.  
  16597. +   0x43, 0x54, 0x0F, 0x44,
  16598.  
  16599. +   0x30, 0xF5, 0x43, 0x80,
  16600.  
  16601. +   0x06, 0xD2, 0x4B, 0x80,
  16602.  
  16603. +   0x02, 0xD2, 0x4C, 0xE4,
  16604.  
  16605. +   0xF5, 0x38, 0xE5, 0x42,
  16606.  
  16607. +   0xC4, 0x54, 0xF0, 0xFF,
  16608.  
  16609. +   0xE5, 0x43, 0x54, 0x0F,
  16610.  
  16611. +   0x4F, 0xF5, 0x5F, 0x90,
  16612.  
  16613. +   0x70, 0x44, 0xF0, 0xA3,
  16614.  
  16615. +   0xE5, 0x5E, 0xF0, 0xA3,
  16616.  
  16617. +   0xE5, 0x4A, 0xF0, 0xA3,
  16618.  
  16619. +   0xE5, 0x48, 0xF0, 0xA3,
  16620.  
  16621. +   0xE5, 0x4C, 0xF0, 0xA3,
  16622.  
  16623. +   0xE5, 0x44, 0xF0, 0xA3,
  16624.  
  16625. +   0xE5, 0x42, 0xF0, 0xA3,
  16626.  
  16627. +   0xE5, 0x43, 0xF0, 0xD2,
  16628.  
  16629. +   0x60, 0x22, 0xE5, 0x47,
  16630.  
  16631. +   0x60, 0x10, 0x24, 0xC0,
  16632.  
  16633. +   0x70, 0x03, 0x12, 0x16,
  16634.  
  16635. +   0x36, 0x12, 0x14, 0x3F,
  16636.  
  16637. +   0xC2, 0xAF, 0xC2, 0x04,
  16638.  
  16639. +   0xD2, 0xAF, 0x22, 0xC2,
  16640.  
  16641. +   0xAF, 0x90, 0x04, 0x14,
  16642.  
  16643. +   0xE0, 0x54, 0x0E, 0x60,
  16644.  
  16645. +   0x04, 0xD2, 0x1C, 0x80,
  16646.  
  16647. +   0x08, 0xE5, 0x4E, 0x45,
  16648.  
  16649. +   0x4F, 0x24, 0xFF, 0x92,
  16650.  
  16651. +   0x1C, 0xD2, 0xAF, 0x90,
  16652.  
  16653. +   0x04, 0x14, 0xE0, 0xA2,
  16654.  
  16655. +   0xE4, 0x92, 0x1D, 0x74,
  16656.  
  16657. +   0x1E, 0xF0, 0xE5, 0x5F,
  16658.  
  16659. +   0x54, 0x0F, 0xF5, 0x2D,
  16660.  
  16661. +   0xE5, 0x38, 0x70, 0x13,
  16662.  
  16663. +   0x30, 0x1C, 0x05, 0xE5,
  16664.  
  16665. +   0x5F, 0x20, 0xE5, 0x0B,
  16666.  
  16667. +   0x30, 0x1D, 0x19, 0xE5,
  16668.  
  16669. +   0x5F, 0x54, 0x30, 0xFF,
  16670.  
  16671. +   0xBF, 0x30, 0x11, 0xE5,
  16672.  
  16673. +   0x38, 0x70, 0x05, 0x75,
  16674.  
  16675. +   0x38, 0x0C, 0x80, 0x02,
  16676.  
  16677. +   0x15, 0x38, 0xD2, 0x6C,
  16678.  
  16679. +   0xD2, 0x6D, 0x80, 0x0F,
  16680.  
  16681. +   0xE5, 0x5F, 0x30, 0xE6,
  16682.  
  16683. +   0x06, 0xC2, 0x6C, 0xD2,
  16684.  
  16685. +   0x6D, 0x80, 0x04, 0xD2,
  16686.  
  16687. +   0x6C, 0xC2, 0x6D, 0xE5,
  16688.  
  16689. +   0x47, 0x64, 0x03, 0x70,
  16690.  
  16691. +   0x21, 0x30, 0x4B, 0x06,
  16692.  
  16693. +   0xC2, 0x6C, 0xD2, 0x6D,
  16694.  
  16695. +   0x80, 0x18, 0xE5, 0x38,
  16696.  
  16697. +   0x70, 0x03, 0x30, 0x4C,
  16698.  
  16699. +   0x11, 0xC2, 0x4C, 0xE5,
  16700.  
  16701. +   0x38, 0x70, 0x05, 0x75,
  16702.  
  16703. +   0x38, 0x07, 0x80, 0x02,
  16704.  
  16705. +   0x15, 0x38, 0xD2, 0x6C,
  16706.  
  16707. +   0xD2, 0x6D, 0x90, 0x70,
  16708.  
  16709. +   0x46, 0xE5, 0x2D, 0xF0,
  16710.  
  16711. +   0x20, 0x69, 0x07, 0xE5,
  16712.  
  16713. +   0x5E, 0x20, 0xE0, 0x02,
  16714.  
  16715. +   0xB2, 0x68, 0x20, 0x6B,
  16716.  
  16717. +   0x07, 0xE5, 0x5E, 0x20,
  16718.  
  16719. +   0xE1, 0x02, 0xB2, 0x6A,
  16720.  
  16721. +   0x20, 0x6D, 0x07, 0xE5,
  16722.  
  16723. +   0x5E, 0x20, 0xE2, 0x02,
  16724.  
  16725. +   0xB2, 0x6C, 0x90, 0x70,
  16726.  
  16727. +   0x47, 0xE5, 0x2D, 0xF0,
  16728.  
  16729. +   0x75, 0x2E, 0x40, 0x20,
  16730.  
  16731. +   0x69, 0x04, 0xA2, 0x68,
  16732.  
  16733. +   0x80, 0x15, 0x30, 0x68,
  16734.  
  16735. +   0x06, 0xE5, 0x46, 0xA2,
  16736.  
  16737. +   0xE3, 0x80, 0x0C, 0xE5,
  16738.  
  16739. +   0x46, 0x54, 0xF0, 0xFF,
  16740.  
  16741. +   0xBF, 0xF0, 0x03, 0xD3,
  16742.  
  16743. +   0x80, 0x01, 0xC3, 0x92,
  16744.  
  16745. +   0x73, 0x92, 0x72, 0x20,
  16746.  
  16747. +   0x6B, 0x04, 0xA2, 0x6A,
  16748.  
  16749. +   0x80, 0x15, 0x30, 0x6A,
  16750.  
  16751. +   0x06, 0xE5, 0x46, 0xA2,
  16752.  
  16753. +   0xE3, 0x80, 0x0C, 0xE5,
  16754.  
  16755. +   0x46, 0x54, 0xF0, 0xFF,
  16756.  
  16757. +   0xBF, 0xF0, 0x03, 0xD3,
  16758.  
  16759. +   0x80, 0x01, 0xC3, 0x92,
  16760.  
  16761. +   0x75, 0x92, 0x74, 0x20,
  16762.  
  16763. +   0x6D, 0x04, 0xA2, 0x6C,
  16764.  
  16765. +   0x80, 0x15, 0x30, 0x6C,
  16766.  
  16767. +   0x06, 0xE5, 0x46, 0xA2,
  16768.  
  16769. +   0xE3, 0x80, 0x0C, 0xE5,
  16770.  
  16771. +   0x46, 0x54, 0xF0, 0xFF,
  16772.  
  16773. +   0xBF, 0xF0, 0x03, 0xD3,
  16774.  
  16775. +   0x80, 0x01, 0xC3, 0x92,
  16776.  
  16777. +   0x71, 0x92, 0x70, 0x90,
  16778.  
  16779. +   0x10, 0x2F, 0xE5, 0x2E,
  16780.  
  16781. +   0xF0, 0xE5, 0x47, 0x64,
  16782.  
  16783. +   0x06, 0x70, 0x46, 0x90,
  16784.  
  16785. +   0x02, 0x29, 0xE0, 0x54,
  16786.  
  16787. +   0xFE, 0xF0, 0xE5, 0x43,
  16788.  
  16789. +   0xC4, 0x54, 0x0F, 0x14,
  16790.  
  16791. +   0x60, 0x14, 0x24, 0xFE,
  16792.  
  16793. +   0x60, 0x1F, 0x24, 0x03,
  16794.  
  16795. +   0x60, 0x03, 0x02, 0x16,
  16796.  
  16797. +   0x35, 0x90, 0x02, 0x28,
  16798.  
  16799. +   0xE0, 0x30, 0x47, 0x0D,
  16800.  
  16801. +   0x80, 0x07, 0x90, 0x02,
  16802.  
  16803. +   0x28, 0xE0, 0x20, 0x47,
  16804.  
  16805. +   0x04, 0x54, 0xFE, 0xF0,
  16806.  
  16807. +   0x22, 0x44, 0x01, 0xF0,
  16808.  
  16809. +   0x22, 0xE5, 0x46, 0x30,
  16810.  
  16811. +   0xE3, 0x04, 0x7F, 0x01,
  16812.  
  16813. +   0x80, 0x02, 0x7F, 0x00,
  16814.  
  16815. +   0x90, 0x02, 0x28, 0xE0,
  16816.  
  16817. +   0x54, 0xFE, 0x4F, 0xF0,
  16818.  
  16819. +   0x22, 0xE5, 0x47, 0x64,
  16820.  
  16821. +   0x07, 0x60, 0x03, 0x02,
  16822.  
  16823. +   0x16, 0x35, 0xF5, 0x27,
  16824.  
  16825. +   0x90, 0x02, 0x29, 0xE0,
  16826.  
  16827. +   0x54, 0xFC, 0xF0, 0xE5,
  16828.  
  16829. +   0x26, 0x14, 0x60, 0x26,
  16830.  
  16831. +   0x14, 0x60, 0x2E, 0x14,
  16832.  
  16833. +   0x60, 0x36, 0x24, 0x03,
  16834.  
  16835. +   0x70, 0x5F, 0xE5, 0x46,
  16836.  
  16837. +   0x13, 0x13, 0x13, 0x54,
  16838.  
  16839. +   0x1F, 0x75, 0xF0, 0x03,
  16840.  
  16841. +   0x84, 0xAF, 0xF0, 0x20,
  16842.  
  16843. +   0x47, 0x04, 0x7E, 0x01,
  16844.  
  16845. +   0x80, 0x02, 0x7E, 0x00,
  16846.  
  16847. +   0xEF, 0x6E, 0x24, 0xFF,
  16848.  
  16849. +   0x80, 0x02, 0xA2, 0x47,
  16850.  
  16851. +   0x92, 0x39, 0xA2, 0x47,
  16852.  
  16853. +   0xB3, 0x92, 0x38, 0x80,
  16854.  
  16855. +   0x3F, 0xE5, 0x46, 0x30,
  16856.  
  16857. +   0xE3, 0x03, 0xD3, 0x80,
  16858.  
  16859. +   0x27, 0xC3, 0x80, 0x24,
  16860.  
  16861. +   0xE5, 0x46, 0x30, 0xE3,
  16862.  
  16863. +   0x0D, 0x54, 0x70, 0xC3,
  16864.  
  16865. +   0x94, 0x60, 0x50, 0x06,
  16866.  
  16867. +   0x7E, 0x00, 0x7F, 0x01,
  16868.  
  16869. +   0x80, 0x04, 0x7E, 0x00,
  16870.  
  16871. +   0x7F, 0x00, 0x20, 0x47,
  16872.  
  16873. +   0x04, 0x7D, 0x01, 0x80,
  16874.  
  16875. +   0x02, 0x7D, 0x00, 0xEF,
  16876.  
  16877. +   0x6D, 0x4E, 0x24, 0xFF,
  16878.  
  16879. +   0x92, 0x38, 0xA2, 0x47,
  16880.  
  16881. +   0xB3, 0x92, 0x39, 0x80,
  16882.  
  16883. +   0x07, 0xA2, 0x47, 0xB3,
  16884.  
  16885. +   0x92, 0x38, 0x92, 0x39,
  16886.  
  16887. +   0x90, 0x02, 0x28, 0xE0,
  16888.  
  16889. +   0x54, 0xFC, 0x45, 0x27,
  16890.  
  16891. +   0xF0, 0x22, 0xE4, 0x90,
  16892.  
  16893. +   0x02, 0x29, 0xF0, 0x30,
  16894.  
  16895. +   0x47, 0x04, 0xAF, 0x45,
  16896.  
  16897. +   0x80, 0x04, 0xE5, 0x45,
  16898.  
  16899. +   0xF4, 0xFF, 0x90, 0x02,
  16900.  
  16901. +   0x28, 0xEF, 0xF0, 0x22,
  16902.  
  16903. +   0x8F, 0x50, 0xD2, 0x59,
  16904.  
  16905. +   0x22, 0x8F, 0x54, 0xD2,
  16906.  
  16907. +   0x58, 0x22, 0xE4, 0xF5,
  16908.  
  16909. +   0x30, 0xC2, 0xAF, 0xE5,
  16910.  
  16911. +   0x51, 0x14, 0x60, 0x4A,
  16912.  
  16913. +   0x14, 0x60, 0x6A, 0x24,
  16914.  
  16915. +   0x02, 0x60, 0x03, 0x02,
  16916.  
  16917. +   0x17, 0x4C, 0xD2, 0x59,
  16918.  
  16919. +   0x75, 0x55, 0x01, 0x20,
  16920.  
  16921. +   0x19, 0x1C, 0x90, 0x02,
  16922.  
  16923. +   0x08, 0xE0, 0x54, 0xFE,
  16924.  
  16925. +   0xF0, 0xE0, 0x20, 0xE1,
  16926.  
  16927. +   0x23, 0x90, 0x04, 0x34,
  16928.  
  16929. +   0xE0, 0xB4, 0x02, 0x1C,
  16930.  
  16931. +   0xA3, 0xE0, 0xB4, 0x02,
  16932.  
  16933. +   0x17, 0xA3, 0xE0, 0xB4,
  16934.  
  16935. +   0x02, 0x12, 0x7F, 0x20,
  16936.  
  16937. +   0x12, 0x16, 0x4C, 0x90,
  16938.  
  16939. +   0x10, 0x04, 0xE0, 0x54,
  16940.  
  16941. +   0xF3, 0xF0, 0x75, 0x51,
  16942.  
  16943. +   0x01, 0x02, 0x17, 0x4C,
  16944.  
  16945. +   0xE5, 0x50, 0x70, 0x06,
  16946.  
  16947. +   0x75, 0x30, 0x03, 0x02,
  16948.  
  16949. +   0x17, 0x4C, 0x90, 0x12,
  16950.  
  16951. +   0x00, 0xE0, 0x54, 0x03,
  16952.  
  16953. +   0x70, 0x15, 0x7F, 0x20,
  16954.  
  16955. +   0x12, 0x16, 0x4C, 0x20,
  16956.  
  16957. +   0x19, 0x07, 0x90, 0x02,
  16958.  
  16959. +   0x08, 0xE0, 0x54, 0xFB,
  16960.  
  16961. +   0xF0, 0x75, 0x51, 0x02,
  16962.  
  16963. +   0x02, 0x17, 0x4C, 0xE5,
  16964.  
  16965. +   0x50, 0x70, 0x02, 0x80,
  16966.  
  16967. +   0x7A, 0x20, 0x19, 0x0F,
  16968.  
  16969. +   0x90, 0x02, 0x08, 0xE0,
  16970.  
  16971. +   0x20, 0xE3, 0x6C, 0x90,
  16972.  
  16973. +   0x04, 0x37, 0xE0, 0x64,
  16974.  
  16975. +   0x22, 0x70, 0x64, 0x90,
  16976.  
  16977. +   0x12, 0x04, 0x74, 0x0A,
  16978.  
  16979. +   0xF0, 0x30, 0x1B, 0x11,
  16980.  
  16981. +   0x90, 0x13, 0x28, 0xE0,
  16982.  
  16983. +   0x54, 0xF0, 0xF0, 0xA3,
  16984.  
  16985. +   0xE0, 0x54, 0xF0, 0xF0,
  16986.  
  16987. +   0xA3, 0xE0, 0x54, 0xFA,
  16988.  
  16989. +   0xF0, 0x20, 0x19, 0x07,
  16990.  
  16991. +   0x90, 0x04, 0x01, 0xE0,
  16992.  
  16993. +   0x44, 0x10, 0xF0, 0xE5,
  16994.  
  16995. +   0x34, 0xF4, 0x90, 0x04,
  16996.  
  16997. +   0x01, 0x60, 0x06, 0xE0,
  16998.  
  16999. +   0x54, 0xFB, 0xF0, 0x80,
  17000.  
  17001. +   0x04, 0xE0, 0x54, 0xF9,
  17002.  
  17003. +   0xF0, 0x20, 0x19, 0x07,
  17004.  
  17005. +   0x90, 0x12, 0x04, 0xE0,
  17006.  
  17007. +   0x44, 0x04, 0xF0, 0xE5,
  17008.  
  17009. +   0x34, 0xF4, 0x60, 0x14,
  17010.  
  17011. +   0x90, 0x01, 0x0D, 0xE0,
  17012.  
  17013. +   0xF5, 0x33, 0xE5, 0x34,
  17014.  
  17015. +   0xD3, 0x94, 0x02, 0x40,
  17016.  
  17017. +   0x07, 0x90, 0x12, 0x04,
  17018.  
  17019. +   0xE0, 0x54, 0xFD, 0xF0,
  17020.  
  17021. +   0x75, 0x30, 0x01, 0x75,
  17022.  
  17023. +   0x55, 0x02, 0xE4, 0xF5,
  17024.  
  17025. +   0x51, 0x80, 0x09, 0xE5,
  17026.  
  17027. +   0x50, 0x70, 0x05, 0x75,
  17028.  
  17029. +   0x30, 0x03, 0xF5, 0x51,
  17030.  
  17031. +   0xE5, 0x30, 0x60, 0x18,
  17032.  
  17033. +   0xC2, 0x01, 0xE4, 0xF5,
  17034.  
  17035. +   0x51, 0xC2, 0x59, 0x20,
  17036.  
  17037. +   0x19, 0x0E, 0xAD, 0x30,
  17038.  
  17039. +   0xAF, 0x40, 0x12, 0x18,
  17040.  
  17041. +   0x2A, 0xE5, 0x30, 0xB4,
  17042.  
  17043. +   0x03, 0x02, 0xD2, 0x03,
  17044.  
  17045. +   0xD2, 0xAF, 0x22, 0xC2,
  17046.  
  17047. +   0xAF, 0x30, 0x01, 0x0E,
  17048.  
  17049. +   0xE4, 0xF5, 0x51, 0xC2,
  17050.  
  17051. +   0x59, 0xC2, 0x01, 0x7D,
  17052.  
  17053. +   0x02, 0xAF, 0x40, 0x12,
  17054.  
  17055. +   0x18, 0x2A, 0xE5, 0x52,
  17056.  
  17057. +   0x14, 0x60, 0x55, 0x14,
  17058.  
  17059. +   0x60, 0x2F, 0x24, 0x02,
  17060.  
  17061. +   0x60, 0x03, 0x02, 0x18,
  17062.  
  17063. +   0x27, 0xE5, 0x34, 0xF4,
  17064.  
  17065. +   0x60, 0x23, 0xE5, 0x34,
  17066.  
  17067. +   0xD3, 0x94, 0x02, 0x40,
  17068.  
  17069. +   0x16, 0x90, 0x12, 0x04,
  17070.  
  17071. +   0xE0, 0x44, 0x02, 0xF0,
  17072.  
  17073. +   0x90, 0x01, 0x0D, 0xE0,
  17074.  
  17075. +   0x20, 0xE3, 0x03, 0x02,
  17076.  
  17077. +   0x18, 0x27, 0x7F, 0x50,
  17078.  
  17079. +   0x12, 0x16, 0x51, 0x75,
  17080.  
  17081. +   0x52, 0x02, 0x75, 0x55,
  17082.  
  17083. +   0x03, 0xE5, 0x34, 0xF4,
  17084.  
  17085. +   0x60, 0x0A, 0xE5, 0x54,
  17086.  
  17087. +   0x70, 0x69, 0x90, 0x01,
  17088.  
  17089. +   0x0D, 0xE5, 0x33, 0xF0,
  17090.  
  17091. +   0x90, 0x12, 0x04, 0xE0,
  17092.  
  17093. +   0x54, 0xFB, 0xF0, 0x7F,
  17094.  
  17095. +   0x20, 0x12, 0x16, 0x51,
  17096.  
  17097. +   0x75, 0x52, 0x01, 0x75,
  17098.  
  17099. +   0x55, 0x03, 0x80, 0x4F,
  17100.  
  17101. +   0xE5, 0x54, 0x70, 0x4B,
  17102.  
  17103. +   0x90, 0x04, 0x01, 0xE0,
  17104.  
  17105. +   0x44, 0x0E, 0xF0, 0x20,
  17106.  
  17107. +   0x19, 0x04, 0xE0, 0x54,
  17108.  
  17109. +   0xEF, 0xF0, 0x90, 0x13,
  17110.  
  17111. +   0x28, 0xE0, 0x44, 0x0F,
  17112.  
  17113. +   0xF0, 0xA3, 0xE0, 0x44,
  17114.  
  17115. +   0x0F, 0xF0, 0xA3, 0xE0,
  17116.  
  17117. +   0x44, 0x05, 0xF0, 0x90,
  17118.  
  17119. +   0x12, 0x04, 0x74, 0x03,
  17120.  
  17121. +   0xF0, 0x20, 0x19, 0x07,
  17122.  
  17123. +   0x90, 0x02, 0x08, 0xE0,
  17124.  
  17125. +   0x44, 0x05, 0xF0, 0x90,
  17126.  
  17127. +   0x10, 0x04, 0xE0, 0x44,
  17128.  
  17129. +   0x0C, 0xF0, 0xE4, 0xF5,
  17130.  
  17131. +   0x52, 0xF5, 0x55, 0x30,
  17132.  
  17133. +   0x02, 0x0B, 0xC2, 0x02,
  17134.  
  17135. +   0x7D, 0x01, 0xAF, 0x41,
  17136.  
  17137. +   0x12, 0x18, 0x2A, 0x80,
  17138.  
  17139. +   0x02, 0xC2, 0x03, 0xD2,
  17140.  
  17141. +   0xAF, 0x22, 0xEF, 0xF4,
  17142.  
  17143. +   0x60, 0x2D, 0xE4, 0xFE,
  17144.  
  17145. +   0x74, 0x14, 0x2E, 0xF5,
  17146.  
  17147. +   0x82, 0xE4, 0x34, 0x70,
  17148.  
  17149. +   0xF5, 0x83, 0xE0, 0xB4,
  17150.  
  17151. +   0xFF, 0x19, 0x74, 0x14,
  17152.  
  17153. +   0x2E, 0xF5, 0x82, 0xE4,
  17154.  
  17155. +   0x34, 0x70, 0xF5, 0x83,
  17156.  
  17157. +   0xEF, 0xF0, 0x74, 0x1C,
  17158.  
  17159. +   0x2E, 0xF5, 0x82, 0xE4,
  17160.  
  17161. +   0x34, 0x70, 0xF5, 0x83,
  17162.  
  17163. +   0xED, 0xF0, 0x22, 0x0E,
  17164.  
  17165. +   0xBE, 0x04, 0xD5, 0x22,
  17166.  
  17167. +   0x22, 0x22, 0x20, 0x19,
  17168.  
  17169. +   0x03, 0x02, 0x19, 0x0F,
  17170.  
  17171. +   0x90, 0x70, 0x80, 0xE0,
  17172.  
  17173. +   0x04, 0xF0, 0x90, 0x04,
  17174.  
  17175. +   0x37, 0xE0, 0x30, 0xE5,
  17176.  
  17177. +   0x03, 0x02, 0x19, 0x0B,
  17178.  
  17179. +   0x90, 0x04, 0x28, 0xE0,
  17180.  
  17181. +   0xF5, 0x31, 0xA3, 0xE0,
  17182.  
  17183. +   0xF5, 0x30, 0xF5, 0x32,
  17184.  
  17185. +   0xE4, 0xF5, 0x37, 0x90,
  17186.  
  17187. +   0x70, 0x81, 0xE0, 0x04,
  17188.  
  17189. +   0xF0, 0x90, 0x70, 0x82,
  17190.  
  17191. +   0xE0, 0x04, 0xF0, 0xE5,
  17192.  
  17193. +   0x32, 0x75, 0xF0, 0x80,
  17194.  
  17195. +   0xA4, 0x24, 0x00, 0xFF,
  17196.  
  17197. +   0xE5, 0xF0, 0x34, 0x80,
  17198.  
  17199. +   0xFE, 0xE5, 0x30, 0x65,
  17200.  
  17201. +   0x32, 0x70, 0x05, 0xFC,
  17202.  
  17203. +   0x7D, 0x18, 0x80, 0x04,
  17204.  
  17205. +   0x7C, 0x00, 0x7D, 0x00,
  17206.  
  17207. +   0xEF, 0x2D, 0xFF, 0xEE,
  17208.  
  17209. +   0x3C, 0xFE, 0x12, 0x19,
  17210.  
  17211. +   0x10, 0x50, 0x25, 0x90,
  17212.  
  17213. +   0x70, 0x83, 0xE0, 0x04,
  17214.  
  17215. +   0xF0, 0x90, 0x01, 0x14,
  17216.  
  17217. +   0xE0, 0x44, 0x02, 0xF0,
  17218.  
  17219. +   0xE0, 0x30, 0xE1, 0x06,
  17220.  
  17221. +   0x90, 0x70, 0x92, 0x74,
  17222.  
  17223. +   0x45, 0xF0, 0x90, 0x70,
  17224.  
  17225. +   0x93, 0xE0, 0x04, 0xF0,
  17226.  
  17227. +   0x90, 0x04, 0x01, 0xE0,
  17228.  
  17229. +   0x90, 0x70, 0x94, 0xF0,
  17230.  
  17231. +   0xE5, 0x32, 0x65, 0x31,
  17232.  
  17233. +   0x60, 0x10, 0xE4, 0x25,
  17234.  
  17235. +   0x32, 0xFF, 0xE4, 0x34,
  17236.  
  17237. +   0x80, 0x8F, 0x82, 0xF5,
  17238.  
  17239. +   0x83, 0xE0, 0xF5, 0x32,
  17240.  
  17241. +   0x80, 0x97, 0x90, 0x04,
  17242.  
  17243. +   0x10, 0x74, 0x01, 0xF0,
  17244.  
  17245. +   0x90, 0x04, 0x28, 0xE5,
  17246.  
  17247. +   0x31, 0xF0, 0xA3, 0xE5,
  17248.  
  17249. +   0x30, 0xF0, 0x90, 0x04,
  17250.  
  17251. +   0x11, 0x74, 0x01, 0xF0,
  17252.  
  17253. +   0x02, 0x18, 0x6A, 0xC2,
  17254.  
  17255. +   0x06, 0xD2, 0x1A, 0x22,
  17256.  
  17257. +   0x90, 0x70, 0x84, 0xE5,
  17258.  
  17259. +   0x37, 0xF0, 0xC3, 0x94,
  17260.  
  17261. +   0x06, 0x50, 0x19, 0x8F,
  17262.  
  17263. +   0x82, 0x8E, 0x83, 0xE0,
  17264.  
  17265. +   0xB4, 0xFF, 0x07, 0x05,
  17266.  
  17267. +   0x37, 0xE4, 0xF5, 0x36,
  17268.  
  17269. +   0x80, 0x59, 0xE4, 0xF5,
  17270.  
  17271. +   0x37, 0x8F, 0x82, 0x8E,
  17272.  
  17273. +   0x83, 0xF0, 0x80, 0x4F,
  17274.  
  17275. +   0xE5, 0x36, 0x75, 0xF0,
  17276.  
  17277. +   0x06, 0x84, 0x74, 0x08,
  17278.  
  17279. +   0x25, 0xF0, 0xF5, 0x82,
  17280.  
  17281. +   0xE4, 0x34, 0x10, 0xF5,
  17282.  
  17283. +   0x83, 0xE0, 0xFD, 0x8F,
  17284.  
  17285. +   0x82, 0x8E, 0x83, 0xE0,
  17286.  
  17287. +   0xFC, 0x6D, 0x70, 0x30,
  17288.  
  17289. +   0x90, 0x70, 0x88, 0xE0,
  17290.  
  17291. +   0x04, 0xF0, 0xA3, 0xE0,
  17292.  
  17293. +   0xFD, 0xD3, 0x95, 0x37,
  17294.  
  17295. +   0x40, 0x02, 0x80, 0x02,
  17296.  
  17297. +   0xAD, 0x37, 0x90, 0x70,
  17298.  
  17299. +   0x89, 0xED, 0xF0, 0x05,
  17300.  
  17301. +   0x37, 0x05, 0x36, 0xE5,
  17302.  
  17303. +   0x36, 0x75, 0xF0, 0x06,
  17304.  
  17305. +   0x84, 0x74, 0x8A, 0x25,
  17306.  
  17307. +   0xF0, 0xF5, 0x82, 0xE4,
  17308.  
  17309. +   0x34, 0x70, 0xF5, 0x83,
  17310.  
  17311. +   0xEC, 0xF0, 0x80, 0x03,
  17312.  
  17313. +   0xE4, 0xF5, 0x37, 0x0F,
  17314.  
  17315. +   0xBF, 0x00, 0x01, 0x0E,
  17316.  
  17317. +   0xEF, 0x54, 0x7F, 0x60,
  17318.  
  17319. +   0x0A, 0xE5, 0x37, 0xC3,
  17320.  
  17321. +   0x94, 0x4E, 0x50, 0x03,
  17322.  
  17323. +   0x02, 0x19, 0x10, 0xE5,
  17324.  
  17325. +   0x37, 0xB4, 0x4E, 0x03,
  17326.  
  17327. +   0xD3, 0x80, 0x01, 0xC3,
  17328.  
  17329. +   0x22, 0x00, 0x00, 0x00,
  17330.  
  17331. +   0x00, 0x00, 0x00, 0x00,
  17332.  
  17333. +   0x00, 0x00, 0x00, 0x00,
  17334.  
  17335. +   0x00, 0x00, 0x00, 0x00,
  17336.  
  17337. +   0x00, 0x00, 0x00, 0x00,
  17338.  
  17339. +   0x00, 0x00, 0x00, 0x00,
  17340.  
  17341. +   0x00, 0x00, 0x00, 0x00,
  17342.  
  17343. +   0x00, 0x00, 0x00, 0x00,
  17344.  
  17345. +   0x00, 0x00, 0x00, 0x00,
  17346.  
  17347. +   0x00, 0x00, 0x00, 0x00,
  17348.  
  17349. +   0x00, 0x00, 0x00, 0x00,
  17350.  
  17351. +   0x00, 0x00, 0x00, 0x00,
  17352.  
  17353. +   0x00, 0x00, 0x00, 0x00,
  17354.  
  17355. +   0x00, 0x00, 0x00, 0x00,
  17356.  
  17357. +   0x00, 0x00, 0x00, 0x00,
  17358.  
  17359. +   0x00, 0x00, 0x00, 0x00,
  17360.  
  17361. +   0x00, 0x00, 0x00, 0x00,
  17362.  
  17363. +   0x00, 0x00, 0x00, 0x00,
  17364.  
  17365. +   0x00, 0x00, 0x00, 0x00,
  17366.  
  17367. +   0x00, 0x00, 0x00, 0x00,
  17368.  
  17369. +   0x00, 0x00, 0x00, 0x00,
  17370.  
  17371. +   0x00, 0x00, 0x00, 0x00,
  17372.  
  17373. +   0x00, 0x00, 0x00, 0x00,
  17374.  
  17375. +   0x00, 0x00, 0x00, 0x00,
  17376.  
  17377. +   0x00, 0x00, 0x00, 0x00,
  17378.  
  17379. +   0x00, 0x00, 0x00, 0x00,
  17380.  
  17381. +   0x00, 0x00, 0x00, 0x00,
  17382.  
  17383. +   0x00, 0x00, 0x00, 0x00,
  17384.  
  17385. +   0x00, 0x00, 0x00, 0x00,
  17386.  
  17387. +   0x00, 0x00, 0x00, 0x00,
  17388.  
  17389. +   0x00, 0x00, 0x00, 0x00,
  17390.  
  17391. +   0x00, 0x00, 0x00, 0x00,
  17392.  
  17393. +   0x00, 0x00, 0x00, 0x00,
  17394.  
  17395. +   0x00, 0x00, 0x00, 0x00,
  17396.  
  17397. +   0x00, 0x00, 0x00, 0x00,
  17398.  
  17399. +   0x00, 0x00, 0x00, 0x00,
  17400.  
  17401. +   0x00, 0x00, 0x00, 0x00,
  17402.  
  17403. +   0x00, 0x00, 0x00, 0x00,
  17404.  
  17405. +   0x00, 0x00, 0x00, 0x00,
  17406.  
  17407. +   0x00, 0x00, 0x00, 0x00,
  17408.  
  17409. +   0x00, 0x00, 0x00, 0x00,
  17410.  
  17411. +   0x00, 0x00, 0x00, 0x00,
  17412.  
  17413. +   0x00, 0x00, 0x00, 0x00,
  17414.  
  17415. +   0x00, 0x00, 0x00, 0x00,
  17416.  
  17417. +   0x00, 0x00, 0x00, 0x00,
  17418.  
  17419. +   0x00, 0x00, 0x00, 0x00,
  17420.  
  17421. +   0x00, 0x00, 0x00, 0x00,
  17422.  
  17423. +   0x00, 0x00, 0x00, 0x00,
  17424.  
  17425. +   0x00, 0x00, 0x00, 0x00,
  17426.  
  17427. +   0x00, 0x00, 0x00, 0x00,
  17428.  
  17429. +   0x00, 0x00, 0x00, 0x00,
  17430.  
  17431. +   0x00, 0x00, 0x00, 0x00,
  17432.  
  17433. +   0x00, 0x00, 0x00, 0x00,
  17434.  
  17435. +   0x00, 0x00, 0x00, 0x00,
  17436.  
  17437. +   0x00, 0x00, 0x00, 0x00,
  17438.  
  17439. +   0x00, 0x00, 0x00, 0x00,
  17440.  
  17441. +   0x00, 0x00, 0x00, 0x00,
  17442.  
  17443. +   0x00, 0x00, 0x00, 0x00,
  17444.  
  17445. +   0x00, 0x00, 0x00, 0x00,
  17446.  
  17447. +   0x00, 0x00, 0x00, 0x00,
  17448.  
  17449. +   0x00, 0x00, 0x00, 0x00,
  17450.  
  17451. +   0x00, 0x00, 0x00, 0x00,
  17452.  
  17453. +   0x00, 0x00, 0x00, 0x00,
  17454.  
  17455. +   0x00, 0x00, 0x00, 0x00,
  17456.  
  17457. +   0x00, 0x00, 0x00, 0x00,
  17458.  
  17459. +   0x00, 0x00, 0x00, 0x00,
  17460.  
  17461. +   0x00, 0x00, 0x00, 0x00,
  17462.  
  17463. +   0x00, 0x00, 0x00, 0x00,
  17464.  
  17465. +   0x00, 0x00, 0x00, 0x00,
  17466.  
  17467. +   0x00, 0x00, 0x00, 0x00,
  17468.  
  17469. +   0x00, 0x00, 0x00, 0x00,
  17470.  
  17471. +   0x00, 0x00, 0x00, 0x00,
  17472.  
  17473. +   0x00, 0x00, 0x00, 0x00,
  17474.  
  17475. +   0x00, 0x00, 0x00, 0x00,
  17476.  
  17477. +   0x00, 0x00, 0x00, 0x00,
  17478.  
  17479. +   0x00, 0x00, 0x00, 0x00,
  17480.  
  17481. +   0x00, 0x00, 0x00, 0x00,
  17482.  
  17483. +   0x00, 0x00, 0x00, 0x00,
  17484.  
  17485. +   0x00, 0x00, 0x00, 0x00,
  17486.  
  17487. +   0x00, 0x00, 0x00, 0x00,
  17488.  
  17489. +   0x00, 0x00, 0x00, 0x00,
  17490.  
  17491. +   0x00, 0x00, 0x00, 0x00,
  17492.  
  17493. +   0x00, 0x00, 0x00, 0x00,
  17494.  
  17495. +   0x00, 0x00, 0x00, 0x00,
  17496.  
  17497. +   0x00, 0x00, 0x00, 0x00,
  17498.  
  17499. +   0x00, 0x00, 0x00, 0x00,
  17500.  
  17501. +   0x00, 0x00, 0x00, 0x00,
  17502.  
  17503. +   0x00, 0x00, 0x00, 0x00,
  17504.  
  17505. +   0x00, 0x00, 0x00, 0x00,
  17506.  
  17507. +   0x00, 0x00, 0x00, 0x00,
  17508.  
  17509. +   0x00, 0x00, 0x00, 0x00,
  17510.  
  17511. +   0x00, 0x00, 0x00, 0x00,
  17512.  
  17513. +   0x00, 0x00, 0x00, 0x00,
  17514.  
  17515. +   0x00, 0x00, 0x00, 0x00,
  17516.  
  17517. +   0x00, 0x00, 0x00, 0x00,
  17518.  
  17519. +   0x00, 0x00, 0x00, 0x00,
  17520.  
  17521. +   0x00, 0x00, 0x00, 0x00,
  17522.  
  17523. +   0x00, 0x00, 0x00, 0x00,
  17524.  
  17525. +   0x00, 0x00, 0x00, 0x00,
  17526.  
  17527. +   0x00, 0x00, 0x00, 0x00,
  17528.  
  17529. +   0x00, 0x00, 0x00, 0x00,
  17530.  
  17531. +   0x00, 0x00, 0x00, 0x00,
  17532.  
  17533. +   0x00, 0x00, 0x00, 0x00,
  17534.  
  17535. +   0x00, 0x00, 0x00, 0x00,
  17536.  
  17537. +   0x00, 0x00, 0x00, 0x00,
  17538.  
  17539. +   0x00, 0x00, 0x00, 0x00,
  17540.  
  17541. +   0x00, 0x00, 0x00, 0x00,
  17542.  
  17543. +   0x00, 0x00, 0x00, 0x00,
  17544.  
  17545. +   0x00, 0x00, 0x00, 0x00,
  17546.  
  17547. +   0x00, 0x00, 0x00, 0x00,
  17548.  
  17549. +   0x00, 0x00, 0x00, 0x00,
  17550.  
  17551. +   0x00, 0x00, 0x00, 0x00,
  17552.  
  17553. +   0x00, 0x00, 0x00, 0x00,
  17554.  
  17555. +   0x00, 0x00, 0x00, 0x00,
  17556.  
  17557. +   0x00, 0x00, 0x00, 0x00,
  17558.  
  17559. +   0x00, 0x00, 0x00, 0x00,
  17560.  
  17561. +   0x00, 0x00, 0x00, 0x00,
  17562.  
  17563. +   0x00, 0x00, 0x00, 0x00,
  17564.  
  17565. +   0x00, 0x00, 0x00, 0x00,
  17566.  
  17567. +   0x00, 0x00, 0x00, 0x00,
  17568.  
  17569. +   0x00, 0x00, 0x00, 0x00,
  17570.  
  17571. +   0x00, 0x00, 0x00, 0x00,
  17572.  
  17573. +   0x00, 0x00, 0x00, 0x00,
  17574.  
  17575. +   0x00, 0x00, 0x00, 0x00,
  17576.  
  17577. +   0x00, 0x00, 0x00, 0x00,
  17578.  
  17579. +   0x00, 0x00, 0x00, 0x00,
  17580.  
  17581. +   0x00, 0x00, 0x00, 0x00,
  17582.  
  17583. +   0x00, 0x00, 0x00, 0x00,
  17584.  
  17585. +   0x00, 0x00, 0x00, 0x00,
  17586.  
  17587. +   0x00, 0x00, 0x00, 0x00,
  17588.  
  17589. +   0x00, 0x00, 0x00, 0x00,
  17590.  
  17591. +   0x00, 0x00, 0x00, 0x00,
  17592.  
  17593. +   0x00, 0x00, 0x00, 0x00,
  17594.  
  17595. +   0x00, 0x00, 0x00, 0x00,
  17596.  
  17597. +   0x00, 0x00, 0x00, 0x00,
  17598.  
  17599. +   0x00, 0x00, 0x00, 0x00,
  17600.  
  17601. +   0x00, 0x00, 0x00, 0x00,
  17602.  
  17603. +   0x00, 0x00, 0x00, 0x00,
  17604.  
  17605. +   0x00, 0x00, 0x00, 0x00,
  17606.  
  17607. +   0x00, 0x00, 0x00, 0x00,
  17608.  
  17609. +   0x00, 0x00, 0x00, 0x00,
  17610.  
  17611. +   0x00, 0x00, 0x00, 0x00,
  17612.  
  17613. +   0x00, 0x00, 0x00, 0x00,
  17614.  
  17615. +   0x00, 0x00, 0x00, 0x00,
  17616.  
  17617. +   0x00, 0x00, 0x00, 0x00,
  17618.  
  17619. +   0x00, 0x00, 0x00, 0x00,
  17620.  
  17621. +   0x00, 0x00, 0x00, 0x00,
  17622.  
  17623. +   0x00, 0x00, 0x00, 0x00,
  17624.  
  17625. +   0x00, 0x00, 0x00, 0x00,
  17626.  
  17627. +   0x00, 0x00, 0x00, 0x00,
  17628.  
  17629. +   0x00, 0x00, 0x00, 0x00,
  17630.  
  17631. +   0x00, 0x00, 0x00, 0x00,
  17632.  
  17633. +   0x00, 0x00, 0x00, 0x00,
  17634.  
  17635. +   0x00, 0x00, 0x00, 0x00,
  17636.  
  17637. +   0x00, 0x00, 0x00, 0x00,
  17638.  
  17639. +   0x00, 0x00, 0x00, 0x00,
  17640.  
  17641. +   0x00, 0x00, 0x00, 0x00,
  17642.  
  17643. +   0x00, 0x00, 0x00, 0x00,
  17644.  
  17645. +   0x00, 0x00, 0x00, 0x00,
  17646.  
  17647. +   0x00, 0x00, 0x00, 0x00,
  17648.  
  17649. +   0x00, 0x00, 0x00, 0x00,
  17650.  
  17651. +   0x00, 0x00, 0x00, 0x00,
  17652.  
  17653. +   0x00, 0x00, 0x00, 0x00,
  17654.  
  17655. +   0x00, 0x00, 0x00, 0x00,
  17656.  
  17657. +   0x00, 0x00, 0x00, 0x00,
  17658.  
  17659. +   0x00, 0x00, 0x00, 0x00,
  17660.  
  17661. +   0x00, 0x00, 0x00, 0x00,
  17662.  
  17663. +   0x00, 0x00, 0x00, 0x00,
  17664.  
  17665. +   0x00, 0x00, 0x00, 0x00,
  17666.  
  17667. +   0x00, 0x00, 0x00, 0x00,
  17668.  
  17669. +   0x00, 0x00, 0x00, 0x00,
  17670.  
  17671. +   0x00, 0x00, 0x00, 0x00,
  17672.  
  17673. +   0x00, 0x00, 0x00, 0x00,
  17674.  
  17675. +   0x00, 0x00, 0x00, 0x00,
  17676.  
  17677. +   0x00, 0x00, 0x00, 0x00,
  17678.  
  17679. +   0x00, 0x00, 0x00, 0x00,
  17680.  
  17681. +   0x00, 0x00, 0x00, 0x00,
  17682.  
  17683. +   0x00, 0x00, 0x00, 0x00,
  17684.  
  17685. +   0x00, 0x00, 0x00, 0x00,
  17686.  
  17687. +   0x00, 0x00, 0x00, 0x00,
  17688.  
  17689. +   0x00, 0x00, 0x00, 0x00,
  17690.  
  17691. +   0x00, 0x00, 0x00, 0x00,
  17692.  
  17693. +   0x00, 0x00, 0x00, 0x00,
  17694.  
  17695. +   0x00, 0x00, 0x00, 0x00,
  17696.  
  17697. +   0x00, 0x00, 0x00, 0x00,
  17698.  
  17699. +   0x00, 0x00, 0x00, 0x00,
  17700.  
  17701. +   0x00, 0x00, 0x00, 0x00,
  17702.  
  17703. +   0x00, 0x00, 0x00, 0x00,
  17704.  
  17705. +   0x00, 0x00, 0x00, 0x00,
  17706.  
  17707. +   0x00, 0x00, 0x00, 0x00,
  17708.  
  17709. +   0x00, 0x00, 0x00, 0x00,
  17710.  
  17711. +   0x00, 0x00, 0x00, 0x00,
  17712.  
  17713. +   0x00, 0x00, 0x00, 0x00,
  17714.  
  17715. +   0x00, 0x00, 0x00, 0x00,
  17716.  
  17717. +   0x00, 0x00, 0x00, 0x00,
  17718.  
  17719. +   0x00, 0x00, 0x00, 0x00,
  17720.  
  17721. +   0x00, 0x00, 0x00, 0x00,
  17722.  
  17723. +   0x00, 0x00, 0x00, 0x00,
  17724.  
  17725. +   0x00, 0x00, 0x00, 0x00,
  17726.  
  17727. +   0x00, 0x00, 0x00, 0x00,
  17728.  
  17729. +   0x00, 0x00, 0x00, 0x00,
  17730.  
  17731. +   0x00, 0x00, 0x00, 0x00,
  17732.  
  17733. +   0x00, 0x00, 0x00, 0x00,
  17734.  
  17735. +   0x00, 0x00, 0x00, 0x00,
  17736.  
  17737. +   0x00, 0x00, 0x00, 0x00,
  17738.  
  17739. +   0x00, 0x00, 0x00, 0x00,
  17740.  
  17741. +   0x00, 0x00, 0x00, 0x00,
  17742.  
  17743. +   0x00, 0x00, 0x00, 0x00,
  17744.  
  17745. +   0x00, 0x00, 0x00, 0x00,
  17746.  
  17747. +   0x00, 0x00, 0x00, 0x00,
  17748.  
  17749. +   0x00, 0x00, 0x00, 0x00,
  17750.  
  17751. +   0x00, 0x00, 0x00, 0x00,
  17752.  
  17753. +   0x00, 0x00, 0x00, 0x00,
  17754.  
  17755. +   0x00, 0x00, 0x00, 0x00,
  17756.  
  17757. +   0x00, 0x00, 0x00, 0x00,
  17758.  
  17759. +   0x00, 0x00, 0x00, 0x00,
  17760.  
  17761. +   0x00, 0x00, 0x00, 0x00,
  17762.  
  17763. +   0x00, 0x00, 0x00, 0x00,
  17764.  
  17765. +   0x00, 0x00, 0x00, 0x00,
  17766.  
  17767. +   0x00, 0x00, 0x00, 0x00,
  17768.  
  17769. +   0x00, 0x00, 0x00, 0x00,
  17770.  
  17771. +   0x00, 0x00, 0x00, 0x00,
  17772.  
  17773. +   0x00, 0x00, 0x00, 0x00,
  17774.  
  17775. +   0x00, 0x00, 0x00, 0x00,
  17776.  
  17777. +   0x00, 0x00, 0x00, 0x00,
  17778.  
  17779. +   0x00, 0x00, 0x00, 0x00,
  17780.  
  17781. +   0x00, 0x00, 0x00, 0x00,
  17782.  
  17783. +   0x00, 0x00, 0x00, 0x00,
  17784.  
  17785. +   0x00, 0x00, 0x00, 0x00,
  17786.  
  17787. +   0x00, 0x00, 0x00, 0x00,
  17788.  
  17789. +   0x00, 0x00, 0x00, 0x00,
  17790.  
  17791. +   0x00, 0x00, 0x00, 0x00,
  17792.  
  17793. +   0x00, 0x00, 0x00, 0x00,
  17794.  
  17795. +   0x00, 0x00, 0x00, 0x00,
  17796.  
  17797. +   0x00, 0x00, 0x00, 0x00,
  17798.  
  17799. +   0x00, 0x00, 0x00, 0x00,
  17800.  
  17801. +   0x00, 0x00, 0x00, 0x00,
  17802.  
  17803. +   0x00, 0x00, 0x00, 0x00,
  17804.  
  17805. +   0x00, 0x00, 0x00, 0x00,
  17806.  
  17807. +   0x00, 0x00, 0x00, 0x00,
  17808.  
  17809. +   0x00, 0x00, 0x00, 0x00,
  17810.  
  17811. +   0x00, 0x00, 0x00, 0x00,
  17812.  
  17813. +   0x00, 0x00, 0x00, 0x00,
  17814.  
  17815. +   0x00, 0x00, 0x00, 0x00,
  17816.  
  17817. +   0x00, 0x00, 0x00, 0x00,
  17818.  
  17819. +   0x00, 0x00, 0x00, 0x00,
  17820.  
  17821. +   0x00, 0x00, 0x00, 0x00,
  17822.  
  17823. +   0x00, 0x00, 0x00, 0x00,
  17824.  
  17825. +   0x00, 0x00, 0x00, 0x00,
  17826.  
  17827. +   0x00, 0x00, 0x00, 0x00,
  17828.  
  17829. +   0x00, 0x00, 0x00, 0x00,
  17830.  
  17831. +   0x00, 0x00, 0x00, 0x00,
  17832.  
  17833. +   0x00, 0x00, 0x00, 0x00,
  17834.  
  17835. +   0x00, 0x00, 0x00, 0x00,
  17836.  
  17837. +   0x00, 0x00, 0x00, 0x00,
  17838.  
  17839. +   0x00, 0x00, 0x00, 0x00,
  17840.  
  17841. +   0x00, 0x00, 0x00, 0x00,
  17842.  
  17843. +   0x00, 0x00, 0x00, 0x00,
  17844.  
  17845. +   0x00, 0x00, 0x00, 0x00,
  17846.  
  17847. +   0x00, 0x00, 0x00, 0x00,
  17848.  
  17849. +   0x00, 0x00, 0x00, 0x00,
  17850.  
  17851. +   0x00, 0x00, 0x00, 0x00,
  17852.  
  17853. +   0x00, 0x00, 0x00, 0x00,
  17854.  
  17855. +   0x00, 0x00, 0x00, 0x00,
  17856.  
  17857. +   0x00, 0x00, 0x00, 0x00,
  17858.  
  17859. +   0x00, 0x00, 0x00, 0x00,
  17860.  
  17861. +   0x00, 0x00, 0x00, 0x00,
  17862.  
  17863. +   0x00, 0x00, 0x00, 0x00,
  17864.  
  17865. +   0x00, 0x00, 0x00, 0x00,
  17866.  
  17867. +   0x00, 0x00, 0x00, 0x00,
  17868.  
  17869. +   0x00, 0x00, 0x00, 0x00,
  17870.  
  17871. +   0x00, 0x00, 0x00, 0x00,
  17872.  
  17873. +   0x00, 0x00, 0x00, 0x00,
  17874.  
  17875. +   0x00, 0x00, 0x00, 0x00,
  17876.  
  17877. +   0x00, 0x00, 0x00, 0x00,
  17878.  
  17879. +   0x00, 0x00, 0x00, 0x00,
  17880.  
  17881. +   0x00, 0x00, 0x00, 0x00,
  17882.  
  17883. +   0x00, 0x00, 0x00, 0x00,
  17884.  
  17885. +   0x00, 0x00, 0x00, 0x00,
  17886.  
  17887. +   0x00, 0x00, 0x00, 0x00,
  17888.  
  17889. +   0x00, 0x00, 0x00, 0x00,
  17890.  
  17891. +   0x00, 0x00, 0x00, 0x00,
  17892.  
  17893. +   0x00, 0x00, 0x00, 0x00,
  17894.  
  17895. +   0x00, 0x00, 0x00, 0x00,
  17896.  
  17897. +   0x00, 0x00, 0x00, 0x00,
  17898.  
  17899. +   0x00, 0x00, 0x00, 0x00,
  17900.  
  17901. +   0x00, 0x00, 0x00, 0x00,
  17902.  
  17903. +   0x00, 0x00, 0x00, 0x00,
  17904.  
  17905. +   0x00, 0x00, 0x00, 0x00,
  17906.  
  17907. +   0x00, 0x00, 0x00, 0x00,
  17908.  
  17909. +   0x00, 0x00, 0x00, 0x00,
  17910.  
  17911. +   0x00, 0x00, 0x00, 0x00,
  17912.  
  17913. +   0x00, 0x00, 0x00, 0x00,
  17914.  
  17915. +   0x00, 0x00, 0x00, 0x00,
  17916.  
  17917. +   0x00, 0x00, 0x00, 0x00,
  17918.  
  17919. +   0x00, 0x00, 0x00, 0x00,
  17920.  
  17921. +   0x00, 0x00, 0x00, 0x00,
  17922.  
  17923. +   0x00, 0x00, 0x00, 0x00,
  17924.  
  17925. +   0x00, 0x00, 0x00, 0x00,
  17926.  
  17927. +   0x00, 0x00, 0x00, 0x00,
  17928.  
  17929. +   0x00, 0x00, 0x00, 0x00,
  17930.  
  17931. +   0x00, 0x00, 0x00, 0x00,
  17932.  
  17933. +   0x00, 0x00, 0x00, 0x00,
  17934.  
  17935. +   0x00, 0x00, 0x00, 0x00,
  17936.  
  17937. +   0x00, 0x00, 0x00, 0x00,
  17938.  
  17939. +   0x00, 0x00, 0x00, 0x00,
  17940.  
  17941. +   0x00, 0x00, 0x00, 0x00,
  17942.  
  17943. +   0x00, 0x00, 0x00, 0x00,
  17944.  
  17945. +   0x00, 0x00, 0x00, 0x00,
  17946.  
  17947. +   0x00, 0x00, 0x00, 0x00,
  17948.  
  17949. +   0x00, 0x00, 0x00, 0x00,
  17950.  
  17951. +   0x00, 0x00, 0x00, 0x00,
  17952.  
  17953. +   0x00, 0x00, 0x00, 0x00,
  17954.  
  17955. +   0x00, 0x00, 0x00, 0x00,
  17956.  
  17957. +   0x00, 0x00, 0x00, 0x00,
  17958.  
  17959. +   0x00, 0x00, 0x00, 0x00,
  17960.  
  17961. +   0x00, 0x00, 0x00, 0x00,
  17962.  
  17963. +   0x00, 0x00, 0x00, 0x00,
  17964.  
  17965. +   0x00, 0x00, 0x00, 0x00,
  17966.  
  17967. +   0x00, 0x00, 0x00, 0x00,
  17968.  
  17969. +   0x00, 0x00, 0x00, 0x00,
  17970.  
  17971. +   0x00, 0x00, 0x00, 0x00,
  17972.  
  17973. +   0x00, 0x00, 0x00, 0x00,
  17974.  
  17975. +   0x00, 0x00, 0x00, 0x00,
  17976.  
  17977. +   0x00, 0x00, 0x00, 0x00,
  17978.  
  17979. +   0x00, 0x00, 0x00, 0x00,
  17980.  
  17981. +   0x00, 0x00, 0x00, 0x00,
  17982.  
  17983. +   0x00, 0x00, 0x00, 0x00,
  17984.  
  17985. +   0x00, 0x00, 0x00, 0x00,
  17986.  
  17987. +   0x00, 0x00, 0x00, 0x00,
  17988.  
  17989. +   0x00, 0x00, 0x00, 0x00,
  17990.  
  17991. +   0x00, 0x00, 0x00, 0x00,
  17992.  
  17993. +   0x00, 0x00, 0x00, 0x00,
  17994.  
  17995. +   0x00, 0x00, 0x00, 0x00,
  17996.  
  17997. +   0x00, 0x00, 0x00, 0x00,
  17998.  
  17999. +   0x00, 0x00, 0x00, 0x00,
  18000.  
  18001. +   0x00, 0x00, 0x00, 0x00,
  18002.  
  18003. +   0x00, 0x00, 0x00, 0x00,
  18004.  
  18005. +   0x00, 0x00, 0x00, 0x00,
  18006.  
  18007. +   0x00, 0x00, 0x00, 0x00,
  18008.  
  18009. +   0x00, 0x00, 0x00, 0x00,
  18010.  
  18011. +   0x00, 0x00, 0x00, 0x00,
  18012.  
  18013. +   0x00, 0x00, 0x00, 0x00,
  18014.  
  18015. +   0x00, 0x00, 0x00, 0x00,
  18016.  
  18017. +   0x00, 0x00, 0x00, 0x00,
  18018.  
  18019. +   0x00, 0x00, 0x00, 0x00,
  18020.  
  18021. +   0x00, 0x00, 0x00, 0x00,
  18022.  
  18023. +   0x00, 0x00, 0x00, 0x00,
  18024.  
  18025. +   0x00, 0x00, 0x00, 0x00,
  18026.  
  18027. +   0x00, 0x00, 0x00, 0x00,
  18028.  
  18029. +   0x00, 0x00, 0x00, 0x00,
  18030.  
  18031. +   0x00, 0x00, 0x00, 0x00,
  18032.  
  18033. +   0x00, 0x00, 0x00, 0x00,
  18034.  
  18035. +   0x00, 0x00, 0x00, 0x00,
  18036.  
  18037. +   0x00, 0x00, 0x00, 0x00,
  18038.  
  18039. +   0x00, 0x00, 0x00, 0x00,
  18040.  
  18041. +   0x00, 0x00, 0x00, 0x00,
  18042.  
  18043. +   0x00, 0x00, 0x00, 0x00,
  18044.  
  18045. +   0x00, 0x00, 0x00, 0x00,
  18046.  
  18047. +   0x00, 0x00, 0x00, 0x00,
  18048.  
  18049. +   0x00, 0x00, 0x00, 0x00,
  18050.  
  18051. +   0x00, 0x00, 0x00, 0x00,
  18052.  
  18053. +   0x00, 0x00, 0x00, 0x00,
  18054.  
  18055. +   0x00, 0x00, 0x00, 0x00,
  18056.  
  18057. +   0x00, 0x00, 0x00, 0x00,
  18058.  
  18059. +   0x00, 0x00, 0x00, 0x00,
  18060.  
  18061. +   0x00, 0x00, 0x00, 0x00,
  18062.  
  18063. +   0x00, 0x00, 0x00, 0x00,
  18064.  
  18065. +   0x00, 0x00, 0x00, 0x00,
  18066.  
  18067. +   0x00, 0x00, 0x00, 0x00,
  18068.  
  18069. +   0x00, 0x00, 0x00, 0x00,
  18070.  
  18071. +   0x00, 0x00, 0x00, 0x00,
  18072.  
  18073. +   0x00, 0x00, 0x00, 0x00,
  18074.  
  18075. +   0x00, 0x00, 0x00, 0x00,
  18076.  
  18077. +   0x00, 0x00, 0x00, 0x00,
  18078.  
  18079. +   0x00, 0x00, 0x00, 0x00,
  18080.  
  18081. +   0x00, 0x00, 0x00, 0x00,
  18082.  
  18083. +   0x00, 0x00, 0x00, 0x00,
  18084.  
  18085. +   0x00, 0x00, 0x00, 0x00,
  18086.  
  18087. +   0x00, 0x00, 0x00, 0x00,
  18088.  
  18089. +   0x00, 0x00, 0x00, 0x00,
  18090.  
  18091. +   0x00, 0x00, 0x00, 0x00,
  18092.  
  18093. +   0x00, 0x00, 0x00, 0x00,
  18094.  
  18095. +   0x00, 0x00, 0x00, 0x00,
  18096.  
  18097. +   0x00, 0x00, 0x00, 0x00,
  18098.  
  18099. +   0x00, 0x00, 0x00, 0x00,
  18100.  
  18101. +   0x00, 0x00, 0x00, 0x00,
  18102.  
  18103. +   0x00, 0x00, 0x00, 0x00,
  18104.  
  18105. +   0x00, 0x00, 0x00, 0x00,
  18106.  
  18107. +   0x00, 0x00, 0x00, 0x00,
  18108.  
  18109. +   0x00, 0x00, 0x00, 0x00,
  18110.  
  18111. +   0x00, 0x00, 0x00, 0x00,
  18112.  
  18113. +   0x00, 0x00, 0x00, 0x00,
  18114.  
  18115. +   0x00, 0x00, 0x00, 0x00,
  18116.  
  18117. +   0x00, 0x00, 0x00, 0x00,
  18118.  
  18119. +   0x00, 0x00, 0x00, 0x00,
  18120.  
  18121. +   0x00, 0x00, 0x00, 0x00,
  18122.  
  18123. +   0x00, 0x00, 0x00, 0x00,
  18124.  
  18125. +   0x00, 0x00, 0x00, 0x00,
  18126.  
  18127. +   0x00, 0x00, 0x00, 0x00,
  18128.  
  18129. +   0x00, 0x00, 0x00, 0x00,
  18130.  
  18131. +   0x00, 0x00, 0x00, 0x00,
  18132.  
  18133. +   0x00, 0x00, 0x00, 0x00,
  18134.  
  18135. +   0x00, 0x00, 0x00, 0x00,
  18136.  
  18137. +   0x00, 0x00, 0x00, 0x00,
  18138.  
  18139. +   0x00, 0x00, 0x00, 0x00,
  18140.  
  18141. +   0x00, 0x00, 0x00, 0x00,
  18142.  
  18143. +   0x00, 0x0B, 0x94, 0xEB,
  18144.  
  18145. +};
  18146.  
  18147. +
  18148.  
  18149. +#endif /* _RT2860_UCODE_H_ */
  18150.  
  18151. +
  18152.  
  18153. +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement