On Fri, Nov 17, 2017 at 12:28:35AM +0100, Stefan Sperling wrote:
> This diff switches athn(4) USB devices to open source firmware.
> 
> I only have an AR9271 device which I can test with:
> athn0 at uhub1 port 2 configuration 1 interface 0 "ATHEROS USB2.0 WLAN" rev 
> 2.00/1.08 addr 3
> athn0: AR9271 rev 1 (1T1R), ROM rev 13, address xx:xx:xx:xx:xx:xx
> 
> The diff switches AR7010 devices over as well because this new code
> will *not* support the old binary-only firmware anyway.
> But it is possible that AR7010 devices don't work yet with this diff.
> Can anybody help and test such a device? And if anyone would like to
> donate an AR7010 device for me to develop with, that would be appreciated.

I have received an AR7010 device from Stuart Henderson and now have
this device working as well. It actually didn't work properly even
with the old firmware due to existing bugs in the driver.

This new diff also makes use of the open firmware's Tx rate reports.
Tx rate scaling is always done in firmware on these devices and there
seems to be no way around that. What the driver can do is show which
Tx rate the firmware has most recently chosen in 'ifconfig athn0' output.
We could tweak the Tx rate scaling algo in firmware code of course :-)

I have also briefly tested hostap with both AR9271 and AR7010 and it
now seems to work well enough to justify removing the BUGS section from
the athn(4) page. I still wouldn't recommend using such a device as
primary AP because it can only support up to 8 clients, and association
to AR9271 was a bit flaky in my testing.

> The new firmware package 'athn-firmware-1.1p3', which contains the open
> firmware files, is required. Specifically, the diff needs these files
> from the new firmware package:
> 
>   /etc/firmware/athn-open-ar7010
>   /etc/firmware/athn-open-ar9271

This new firmware has been in fw_update for some time now so we can
commit this change without disrupting users tracking -current.

We should keep the old firmware file around for a while, just in case
this change needs to be reverted for some reason.

ok?

Index: if_athn_usb.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_athn_usb.c,v
retrieving revision 1.48
diff -u -p -r1.48 if_athn_usb.c
--- if_athn_usb.c       26 Oct 2017 15:00:28 -0000      1.48
+++ if_athn_usb.c       3 Feb 2018 22:08:54 -0000
@@ -159,6 +159,7 @@ void                athn_usb_delete_key_cb(struct athn
 void           athn_usb_bcneof(struct usbd_xfer *, void *,
                    usbd_status);
 void           athn_usb_swba(struct athn_usb_softc *);
+void           athn_usb_tx_status(void *, struct ieee80211_node *);
 void           athn_usb_rx_wmi_ctrl(struct athn_usb_softc *, uint8_t *, int);
 void           athn_usb_intr(struct usbd_xfer *, void *,
                    usbd_status);
@@ -629,12 +630,9 @@ athn_usb_load_firmware(struct athn_usb_s
        /* Determine which firmware image to load. */
        if (usc->flags & ATHN_USB_FLAG_AR7010) {
                dd = usbd_get_device_descriptor(usc->sc_udev);
-               if (UGETW(dd->bcdDevice) == 0x0202)
-                       name = "athn-ar7010-11";
-               else
-                       name = "athn-ar7010";
+               name = "athn-open-ar7010";
        } else
-               name = "athn-ar9271";
+               name = "athn-open-ar9271";
        /* Read firmware image from the filesystem. */
        if ((error = loadfirmware(name, &fw, &fwsize)) != 0) {
                printf("%s: failed loadfirmware of file %s (error %d)\n",
@@ -1033,7 +1031,6 @@ athn_usb_newstate_cb(struct athn_usb_sof
 
        s = splnet();
        ostate = ic->ic_state;
-       DPRINTF(("newstate %d -> %d\n", ostate, cmd->state));
 
        if (ostate == IEEE80211_S_RUN) {
                sta_index = ((struct athn_node *)ic->ic_bss)->sta_index;
@@ -1053,13 +1050,21 @@ athn_usb_newstate_cb(struct athn_usb_sof
        case IEEE80211_S_SCAN:
                /* Make the LED blink while scanning. */
                athn_set_led(sc, !sc->led_state);
-               (void)athn_usb_switch_chan(sc, ic->ic_bss->ni_chan, NULL);
+               error = athn_usb_switch_chan(sc, ic->ic_bss->ni_chan, NULL);
+               if (error)
+                       printf("%s: could not switch to channel %d\n",
+                           usc->usb_dev.dv_xname,
+                           ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan));
                if (!usbd_is_dying(usc->sc_udev))
                        timeout_add_msec(&sc->scan_to, 200);
                break;
        case IEEE80211_S_AUTH:
                athn_set_led(sc, 0);
                error = athn_usb_switch_chan(sc, ic->ic_bss->ni_chan, NULL);
+               if (error)
+                       printf("%s: could not switch to channel %d\n",
+                           usc->usb_dev.dv_xname,
+                           ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan));
                break;
        case IEEE80211_S_ASSOC:
                break;
@@ -1071,6 +1076,9 @@ athn_usb_newstate_cb(struct athn_usb_sof
 
                /* Create node entry for our BSS */
                error = athn_usb_create_node(usc, ic->ic_bss);
+               if (error)
+                       printf("%s: could not update firmware node table\n",
+                           usc->usb_dev.dv_xname);
 
                athn_set_bss(sc, ic->ic_bss);
                athn_usb_wmi_cmd(usc, AR_WMI_CMD_DISABLE_INTR);
@@ -1222,14 +1230,12 @@ athn_usb_create_node(struct athn_usb_sof
        if (usc->nnodes > AR_USB_MAX_STA)
                return ENOBUFS;
 
-       an->sta_index = IEEE80211_AID(ni->ni_associd);
+       an->sta_index = usc->nnodes;
 
        /* Create node entry on target. */
        memset(&sta, 0, sizeof(sta));
        IEEE80211_ADDR_COPY(sta.macaddr, ni->ni_macaddr);
        IEEE80211_ADDR_COPY(sta.bssid, ni->ni_bssid);
-       sta.associd = htobe16(ni->ni_associd);
-       sta.valid = 1;
        sta.sta_index = an->sta_index;
        sta.maxampdu = 0xffff;
        if (ni->ni_flags & IEEE80211_NODE_HT)
@@ -1319,8 +1325,16 @@ athn_usb_switch_chan(struct athn_softc *
                error = athn_hw_reset(sc, c, extc, 0);
                if (error != 0) /* Hopeless case. */
                        return (error);
+
+               error = athn_set_chan(sc, c, extc);
+               if (AR_SREV_9271(sc) && error == 0)
+                       ar9271_load_ani(sc);
+               if (error != 0)
+                       return (error);
        }
 
+       sc->ops.set_txpower(sc, c, extc);
+
        error = athn_usb_wmi_cmd(usc, AR_WMI_CMD_START_RECV);
        if (error != 0)
                return (error);
@@ -1518,11 +1532,44 @@ athn_usb_swba(struct athn_usb_softc *usc
 }
 #endif
 
+
+struct athn_usb_tx_status_arg {
+       struct athn_usb_softc *usc;
+       uint8_t ts_sta_index;
+       uint8_t ts_flags;
+       uint8_t ts_rate;
+};
+
+/* Update current transmit rate for a node based on firmware Tx status. */
+void
+athn_usb_tx_status(void *arg, struct ieee80211_node *ni)
+{
+       struct athn_usb_tx_status_arg *a = arg;
+       struct athn_usb_softc *usc = a->usc;
+       uint8_t ts_sta_index = a->ts_sta_index;
+       uint8_t ts_flags = a->ts_flags;
+       uint8_t ts_rate = a->ts_rate;
+       struct athn_node *an = (struct athn_node *)ni;
+       int i;
+
+       for (i = 0; i < usc->nnodes; i++) {
+               if (an->sta_index == ts_sta_index)
+                       break;
+       }
+       if (i == usc->nnodes) /* Tx report for unknown node */
+               return;
+
+       if (ts_flags & AR_HTC_TXSTAT_MCS) {
+               if (isset(ni->ni_rxmcs, ts_rate))
+                       ni->ni_txmcs = ts_rate;
+       } else if (ts_rate < ni->ni_rates.rs_nrates)
+               ni->ni_txrate = ts_rate;
+}
+
 void
 athn_usb_rx_wmi_ctrl(struct athn_usb_softc *usc, uint8_t *buf, int len)
 {
        struct ar_wmi_cmd_hdr *wmi;
-       struct ar_wmi_evt_txrate *txrate;
        uint16_t cmd_id;
 
        if (__predict_false(len < sizeof(*wmi)))
@@ -1547,10 +1594,42 @@ athn_usb_rx_wmi_ctrl(struct athn_usb_sof
                athn_usb_swba(usc);
                break;
 #endif
-       case AR_WMI_EVT_TXRATE:
-               txrate = (struct ar_wmi_evt_txrate *)&wmi[1];
-               DPRINTF(("txrate=%d\n", betoh32(txrate->txrate)));
+       case AR_WMI_EVT_TXSTATUS: {
+               struct ar_wmi_evt_txstatus *ts;
+               struct athn_usb_tx_status_arg arg;
+               int i;
+
+               ts = (struct ar_wmi_evt_txstatus *)&wmi[1];
+               for (i = 0; i < ts->count && i < AR_HTC_MAX_TX_STATUS; i++) {
+                       struct ieee80211com *ic = &usc->sc_sc.sc_ic;
+                       struct athn_node *an = (struct athn_node *)ic->ic_bss;
+                       uint8_t qid;
+
+                       /* Skip the node we use to send management frames. */
+                       if (ts->ts[i].cookie == 0)
+                               continue;
+
+                       /* Skip Tx reports for non-data frame endpoints. */
+                       qid = (ts->ts[i].rate & AR_HTC_TXSTAT_EPID) >>
+                               AR_HTC_TXSTAT_EPID_SHIFT;
+                       if (qid != usc->ep_data[EDCA_AC_BE] &&
+                           qid != usc->ep_data[EDCA_AC_BK] &&
+                           qid != usc->ep_data[EDCA_AC_VI] &&
+                           qid != usc->ep_data[EDCA_AC_VO])
+                               continue;
+
+                       arg.usc = usc;
+                       arg.ts_sta_index = ts->ts[i].cookie;
+                       arg.ts_flags = ts->ts[i].flags;
+                       arg.ts_rate = (ts->ts[i].rate & AR_HTC_TXSTAT_RATE);
+                       if (arg.ts_sta_index == an->sta_index)
+                               athn_usb_tx_status(&arg, ic->ic_bss);
+                       else
+                               ieee80211_iterate_nodes(ic,
+                                   athn_usb_tx_status, &arg);
+               }
                break;
+       }
        case AR_WMI_EVT_FATAL:
                printf("%s: fatal firmware error\n", usc->usb_dev.dv_xname);
                break;
@@ -2010,6 +2089,7 @@ athn_usb_tx(struct athn_softc *sc, struc
                                txf->flags |= htobe32(AR_HTC_TX_RTSCTS);
                }
                txf->key_idx = 0xff;
+               txf->cookie = sta_index;
                frm = (uint8_t *)&txf[1];
        } else {
                htc->endpoint_id = usc->ep_mgmt;
@@ -2019,6 +2099,7 @@ athn_usb_tx(struct athn_softc *sc, struc
                txm->node_idx = sta_index;
                txm->vif_idx = 0;
                txm->key_idx = 0xff;
+               txm->cookie = sta_index;
                frm = (uint8_t *)&txm[1];
        }
        /* Copy payload. */
@@ -2286,13 +2367,9 @@ athn_usb_init(struct ifnet *ifp)
 
        /* Update target capabilities. */
        memset(&hic, 0, sizeof(hic));
-       hic.flags = htobe32(0x400c2400);
-       hic.flags_ext = htobe32(0x00106080);
        hic.ampdu_limit = htobe32(0x0000ffff);
        hic.ampdu_subframes = 20;
-       hic.protmode = 1;       /* XXX */
-       hic.lg_txchainmask = sc->txchainmask;
-       hic.ht_txchainmask = sc->txchainmask;
+       hic.txchainmask = sc->txchainmask;
        DPRINTF(("updating target configuration\n"));
        error = athn_usb_wmi_xcmd(usc, AR_WMI_CMD_TARGET_IC_UPDATE,
            &hic, sizeof(hic), NULL);
@@ -2362,11 +2439,14 @@ athn_usb_stop(struct ifnet *ifp)
        IEEE80211_ADDR_COPY(hvif.myaddr, ic->ic_myaddr);
        (void)athn_usb_wmi_xcmd(usc, AR_WMI_CMD_VAP_REMOVE,
            &hvif, sizeof(hvif), NULL);
-       /* Remove default node. */
-       sta_index = 0;
-       (void)athn_usb_wmi_xcmd(usc, AR_WMI_CMD_NODE_REMOVE,
-           &sta_index, sizeof(sta_index), NULL);
-       usc->nnodes--;
+
+       /* Remove nodes. */
+       while (usc->nnodes > 0) {
+               sta_index = usc->nnodes - 1;
+               (void)athn_usb_wmi_xcmd(usc, AR_WMI_CMD_NODE_REMOVE,
+                   &sta_index, sizeof(sta_index), NULL);
+               usc->nnodes--;
+       }
 
        (void)athn_usb_wmi_cmd(usc, AR_WMI_CMD_DISABLE_INTR);
        (void)athn_usb_wmi_cmd(usc, AR_WMI_CMD_DRAIN_TXQ_ALL);
Index: if_athn_usb.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_athn_usb.h,v
retrieving revision 1.8
diff -u -p -r1.8 if_athn_usb.h
--- if_athn_usb.h       8 Apr 2017 02:57:25 -0000       1.8
+++ if_athn_usb.h       3 Feb 2018 21:51:10 -0000
@@ -34,47 +34,45 @@
 /* Wireless module interface commands. */
 #define AR_WMI_CMD_ECHO                        0x001
 #define AR_WMI_CMD_ACCESS_MEMORY       0x002
-#define AR_WMI_CMD_DISABLE_INTR                0x003
-#define AR_WMI_CMD_ENABLE_INTR         0x004
-#define AR_WMI_CMD_RX_LINK             0x005
+#define AR_WMI_GET_FW_VERSION          0x003
+#define AR_WMI_CMD_DISABLE_INTR                0x004
+#define AR_WMI_CMD_ENABLE_INTR         0x005
 #define AR_WMI_CMD_ATH_INIT            0x006
 #define AR_WMI_CMD_ABORT_TXQ           0x007
 #define AR_WMI_CMD_STOP_TX_DMA         0x008
-#define AR_WMI_CMD_STOP_DMA_RECV       0x009
-#define AR_WMI_CMD_ABORT_TX_DMA                0x00a
-#define AR_WMI_CMD_DRAIN_TXQ           0x00b
-#define AR_WMI_CMD_DRAIN_TXQ_ALL       0x00c
-#define AR_WMI_CMD_START_RECV          0x00d
-#define AR_WMI_CMD_STOP_RECV           0x00e
-#define AR_WMI_CMD_FLUSH_RECV          0x00f
-#define AR_WMI_CMD_SET_MODE            0x010
-#define AR_WMI_CMD_RESET               0x011
-#define AR_WMI_CMD_NODE_CREATE         0x012
-#define AR_WMI_CMD_NODE_REMOVE         0x013
-#define AR_WMI_CMD_VAP_REMOVE          0x014
-#define AR_WMI_CMD_VAP_CREATE          0x015
-#define AR_WMI_CMD_BEACON_UPDATE       0x016
-#define AR_WMI_CMD_REG_READ            0x017
-#define AR_WMI_CMD_REG_WRITE           0x018
-#define AR_WMI_CMD_RC_STATE_CHANGE     0x019
-#define AR_WMI_CMD_RC_RATE_UPDATE      0x01a
-#define AR_WMI_CMD_DEBUG_INFO          0x01b
-#define AR_WMI_CMD_HOST_ATTACH         0x01c
-#define AR_WMI_CMD_TARGET_IC_UPDATE    0x01d
-#define AR_WMI_CMD_TGT_STATS           0x01e
-#define AR_WMI_CMD_TX_AGGR_ENABLE      0x01f
+#define AR_WMI_CMD_ABORT_TX_DMA                0x009
+#define AR_WMI_CMD_DRAIN_TXQ           0x00a
+#define AR_WMI_CMD_DRAIN_TXQ_ALL       0x00b
+#define AR_WMI_CMD_START_RECV          0x00c
+#define AR_WMI_CMD_STOP_RECV           0x00d
+#define AR_WMI_CMD_FLUSH_RECV          0x00e
+#define AR_WMI_CMD_SET_MODE            0x00f
+#define AR_WMI_CMD_NODE_CREATE         0x010
+#define AR_WMI_CMD_NODE_REMOVE         0x011
+#define AR_WMI_CMD_VAP_REMOVE          0x012
+#define AR_WMI_CMD_VAP_CREATE          0x013
+#define AR_WMI_CMD_REG_READ            0x014
+#define AR_WMI_CMD_REG_WRITE           0x015
+#define AR_WMI_CMD_RC_STATE_CHANGE     0x016
+#define AR_WMI_CMD_RC_RATE_UPDATE      0x017
+#define AR_WMI_CMD_TARGET_IC_UPDATE    0x018
+#define AR_WMI_CMD_TX_AGGR_ENABLE      0x019
 #define AR_WMI_CMD_TGT_DETACH          0x020
-#define AR_WMI_CMD_TGT_TXQ_ENABLE      0x021
-#define AR_WMI_CMD_AGGR_LIMIT          0x026
+#define AR_WMI_CMD_NODE_UPDATE         0x021
+#define AR_WMI_CMD_INT_STATS           0x022
+#define AR_WMI_CMD_TX_STATS            0x023
+#define AR_WMI_CMD_RX_STATS            0x024
+#define AR_WMI_CMD_BITRATE_MASK                0x025
+#define AR_WMI_CMD_REG_RMW             0x026
+
 /* Wireless module interface events. */
 #define AR_WMI_EVT_TGT_RDY             0x001
 #define AR_WMI_EVT_SWBA                        0x002
 #define AR_WMI_EVT_FATAL               0x003
 #define AR_WMI_EVT_TXTO                        0x004
 #define AR_WMI_EVT_BMISS               0x005
-#define AR_WMI_EVT_WLAN_TXCOMP         0x006
-#define AR_WMI_EVT_DELBA               0x007
-#define AR_WMI_EVT_TXRATE              0x008
+#define AR_WMI_EVT_DELBA               0x006
+#define AR_WMI_EVT_TXSTATUS            0x007
 
 /* Structure for service AR_SVC_WMI_CONTROL. */
 struct ar_wmi_cmd_hdr {
@@ -85,15 +83,8 @@ struct ar_wmi_cmd_hdr {
 } __packed;
 
 /* Values for AR_WMI_CMD_SET_MODE. */
-#define AR_HTC_MODE_AUTO       0
-#define AR_HTC_MODE_11A                1
-#define AR_HTC_MODE_11B                2
-#define AR_HTC_MODE_11G                3
-#define AR_HTC_MODE_FH         4
-#define AR_HTC_MODE_TURBO_A    5
-#define AR_HTC_MODE_TURBO_G    6
-#define AR_HTC_MODE_11NA       7
-#define AR_HTC_MODE_11NG       8
+#define AR_HTC_MODE_11NA       0
+#define AR_HTC_MODE_11NG       1
 
 #define AR_MAX_WRITE_COUNT     32
 /* Structure for command AR_WMI_CMD_REG_WRITE. */
@@ -104,14 +95,11 @@ struct ar_wmi_cmd_reg_write {
 
 /* Structure for command AR_WMI_CMD_NODE_{CREATE,REMOVE}. */
 struct ar_htc_target_sta {
-       uint16_t        associd;
-       uint16_t        txpower;
-       uint32_t        pariwisekey;
        uint8_t         macaddr[IEEE80211_ADDR_LEN];
        uint8_t         bssid[IEEE80211_ADDR_LEN];
        uint8_t         sta_index;
        uint8_t         vif_index;
-       uint8_t         vif_sta;
+       uint8_t         is_vif_sta;
        uint16_t        flags;
 #define AR_HTC_STA_AUTH        0x0001
 #define AR_HTC_STA_QOS 0x0002
@@ -119,14 +107,14 @@ struct ar_htc_target_sta {
 #define AR_HTC_STA_HT  0x0008
 
        uint16_t        htcap;
-       uint8_t         valid;
-       uint16_t        capinfo;
-       uint32_t        reserved[2];
-       uint16_t        txseqmgmt;
-       uint8_t         is_vif_sta;
        uint16_t        maxampdu;
+       uint8_t         pad;
+
+       /* Internal state. */
+       uint16_t        txseqmgmt;
        uint16_t        iv16;
        uint32_t        iv32;
+       void            *ni_vap;
 } __packed;
 
 /* Structures for command AR_WMI_CMD_RC_RATE_UPDATE. */
@@ -139,12 +127,14 @@ struct ar_htc_rateset {
 struct ar_htc_target_rate {
        uint8_t                 sta_index;
        uint8_t                 isnew;
+       uint8_t                 pad[2];
        uint32_t                capflags;
-#define AR_RC_DS_FLAG  0x00000001
-#define AR_RC_40_FLAG  0x00000002
-#define AR_RC_SGI_FLAG 0x00000004
-#define AR_RC_HT_FLAG  0x00000008
-#define AR_RC_STBC_FLAG        0x00000020
+#define AR_RC_DS_FLAG          0x00000001
+#define AR_RC_40_FLAG          0x00000002
+#define AR_RC_SGI_FLAG         0x00000004
+#define AR_RC_HT_FLAG          0x00000008
+#define AR_RC_STBC_FLAG                0x00000030 /* 2 bits */
+#define AR_RC_WEP_TKIP_FLAG    0x00000100 
 
        struct ar_htc_rateset   lg_rates;
        struct ar_htc_rateset   ht_rates;
@@ -161,7 +151,6 @@ struct ar_htc_target_aggr {
 /* Structure for command AR_WMI_CMD_VAP_CREATE. */
 struct ar_htc_target_vif {
        uint8_t         index;
-       uint8_t         des_bssid[IEEE80211_ADDR_LEN];
        uint32_t        opmode;
 #define AR_HTC_M_IBSS          0
 #define AR_HTC_M_STA           1
@@ -169,41 +158,59 @@ struct ar_htc_target_vif {
 #define AR_HTC_M_AHDEMO                3
 #define AR_HTC_M_HOSTAP                6
 #define AR_HTC_M_MONITOR       8
-
        uint8_t         myaddr[IEEE80211_ADDR_LEN];
-       uint8_t         bssid[IEEE80211_ADDR_LEN];
-       uint32_t        flags;
-       uint32_t        flags_ext;
-       uint16_t        ps_sta;
-       uint16_t        rtsthreshold;
        uint8_t         ath_cap;
-       int8_t          mcast_rate;
+       uint16_t        rtsthreshold;
+       uint8_t         pad;
+
+       /* Internal state. */
+       int8_t          nodeindex;
+       void            *iv_bss;
 } __packed;
 
 /* Structure for command AM_WMI_CMD_TARGET_IC_UPDATE. */
 struct ar_htc_cap_target {
-       uint32_t        flags;
-       uint32_t        flags_ext;
        uint32_t        ampdu_limit;
        uint8_t         ampdu_subframes;
-       uint8_t         ht_txchainmask;
-       uint8_t         lg_txchainmask;
-       uint8_t         rtscts_ratecode;
-       uint8_t         protmode;
-} __packed;
-
-/* Structure for event AR_WMI_EVT_TXRATE. */
-struct ar_wmi_evt_txrate {
-       uint32_t        txrate;
-       uint8_t         rssi_thresh;
-       uint8_t         per;
+       uint8_t         enable_coex;
+       uint8_t         txchainmask;
+       uint8_t         pad;
+} __packed;
+
+#define AR_HTC_MAX_TX_STATUS 12
+
+/* Structure for event AR_WMI_EVT_TXSTATUS. */
+struct ar_wmi_evt_txstatus {
+       uint8_t                 count;
+       struct {
+               uint8_t         cookie;
+
+               /* 
+                * Legacy rates are indicated as rate array indices.
+                * HT rates are indicated as MSC indices.
+                */
+               uint8_t         rate;
+#define AR_HTC_TXSTAT_RATE             0x0f
+#define AR_HTC_TXSTAT_EPID             0xf0
+#define AR_HTC_TXSTAT_EPID_SHIFT       4
+
+               uint8_t         flags;
+#define AR_HTC_TXSTAT_ACK      0x01
+#define AR_HTC_TXSTAT_FILT     0x02
+#define AR_HTC_TXSTAT_RTC_CTS  0x04
+#define AR_HTC_TXSTAT_MCS      0x08
+#define AR_HTC_TXSTAT_CW40     0x10
+#define AR_HTC_TXSTAT_SGI      0x20
+       } ts[AR_HTC_MAX_TX_STATUS];
 } __packed;
 
 /* HTC header. */
 struct ar_htc_frame_hdr {
        uint8_t         endpoint_id;
        uint8_t         flags;
-#define AR_HTC_FLAG_TRAILER    0x02
+#define AR_HTC_FLAG_NEED_CREDIT_UPDATE         0x01
+#define AR_HTC_FLAG_TRAILER                    0x02
+#define AR_HTC_FLAG_CREDIT_REDISTRIBUTION      0x03
 
        uint16_t        payload_len;
        uint8_t         control[4];
@@ -236,7 +243,8 @@ struct ar_tx_frame {
 
        uint8_t         key_type;
        uint8_t         key_idx;
-       uint8_t         reserved[26];
+       uint8_t         cookie;
+       uint8_t         pad;
 } __packed;
 
 /* Structure for service AR_SVC_WMI_MGMT. */
@@ -247,7 +255,8 @@ struct ar_tx_mgmt {
        uint8_t         flags;
        uint8_t         key_type;
        uint8_t         key_idx;
-       uint16_t        reserved;
+       uint8_t         cookie;
+       uint8_t         pad;
 } __packed;
 
 /* Structure for service AR_SVC_WMI_BEACON. */

Reply via email to