aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-tx.c
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-06-11 17:21:56 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-14 12:18:12 -0400
commitfd7c8a40b2a63863f749e4d17f0d94d2e5ab1331 (patch)
tree098e07d68b4d1e7a6c02750db480204c0dd469d5 /drivers/net/wireless/iwlwifi/iwl-tx.c
parente36cfdc9b17fa64245ee6206287e5120e59bbfca (diff)
mac80211: add helpers for frame control testing
A few general categories: 1) ieee80211_has_* tests if particular fctl bits are set, the helpers are de in the same order as the fctl defines: A combined _has_a4 was also added to test when both FROMDS and TODS are set. 2) ieee80211_is_* is meant to test whether the frame control is of a certain ftype - data, mgmt, ctl, and two special helpers _is_data_qos, _is_data_pres which also test a subset of the stype space. When testing for a particular stype applicable only to one ftype, functions like ieee80211_is_ack have been added. Note that the ftype is also being checked in these helpers. They have been added for all mgmt and ctl stypes in the same order as the STYPE defines. 3) ieee80211_get_* is meant to take a struct ieee80211_hdr * and returns a pointer to somewhere in the struct, see get_SA, get_DA, get_qos_ctl. The intel wireless drivers had helpers that used this namespace, convert the all to use the new helpers and remove the byteshifting as they were defined in cpu-order rather than little-endian. Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-tx.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index e804bf8aea80..98c434c52a64 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -569,15 +569,15 @@ static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
569 struct ieee80211_hdr *hdr, 569 struct ieee80211_hdr *hdr,
570 int is_unicast, u8 std_id) 570 int is_unicast, u8 std_id)
571{ 571{
572 u16 fc = le16_to_cpu(hdr->frame_control); 572 __le16 fc = hdr->frame_control;
573 __le32 tx_flags = tx_cmd->tx_flags; 573 __le32 tx_flags = tx_cmd->tx_flags;
574 574
575 tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 575 tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
576 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { 576 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
577 tx_flags |= TX_CMD_FLG_ACK_MSK; 577 tx_flags |= TX_CMD_FLG_ACK_MSK;
578 if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) 578 if (ieee80211_is_mgmt(fc))
579 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 579 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
580 if (ieee80211_is_probe_response(fc) && 580 if (ieee80211_is_probe_resp(fc) &&
581 !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) 581 !(le16_to_cpu(hdr->seq_ctrl) & 0xf))
582 tx_flags |= TX_CMD_FLG_TSF_MSK; 582 tx_flags |= TX_CMD_FLG_TSF_MSK;
583 } else { 583 } else {
@@ -585,7 +585,7 @@ static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
585 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 585 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
586 } 586 }
587 587
588 if (ieee80211_is_back_request(fc)) 588 if (ieee80211_is_back_req(fc))
589 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; 589 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK;
590 590
591 591
@@ -593,8 +593,8 @@ static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
593 if (ieee80211_get_morefrag(hdr)) 593 if (ieee80211_get_morefrag(hdr))
594 tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; 594 tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK;
595 595
596 if (ieee80211_is_qos_data(fc)) { 596 if (ieee80211_is_data_qos(fc)) {
597 u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); 597 u8 *qc = ieee80211_get_qos_ctl(hdr);
598 tx_cmd->tid_tspec = qc[0] & 0xf; 598 tx_cmd->tid_tspec = qc[0] & 0xf;
599 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; 599 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK;
600 } else { 600 } else {
@@ -613,9 +613,8 @@ static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
613 tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; 613 tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK;
614 614
615 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); 615 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK);
616 if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { 616 if (ieee80211_is_mgmt(fc)) {
617 if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ || 617 if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc))
618 (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ)
619 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); 618 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3);
620 else 619 else
621 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); 620 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2);
@@ -634,7 +633,7 @@ static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
634static void iwl_tx_cmd_build_rate(struct iwl_priv *priv, 633static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
635 struct iwl_tx_cmd *tx_cmd, 634 struct iwl_tx_cmd *tx_cmd,
636 struct ieee80211_tx_info *info, 635 struct ieee80211_tx_info *info,
637 u16 fc, int sta_id, 636 __le16 fc, int sta_id,
638 int is_hcca) 637 int is_hcca)
639{ 638{
640 u8 rts_retry_limit = 0; 639 u8 rts_retry_limit = 0;
@@ -655,7 +654,7 @@ static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
655 rate_flags |= RATE_MCS_CCK_MSK; 654 rate_flags |= RATE_MCS_CCK_MSK;
656 655
657 656
658 if (ieee80211_is_probe_response(fc)) { 657 if (ieee80211_is_probe_resp(fc)) {
659 data_retry_limit = 3; 658 data_retry_limit = 3;
660 if (data_retry_limit < rts_retry_limit) 659 if (data_retry_limit < rts_retry_limit)
661 rts_retry_limit = data_retry_limit; 660 rts_retry_limit = data_retry_limit;
@@ -670,11 +669,11 @@ static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
670 tx_cmd->initial_rate_index = 0; 669 tx_cmd->initial_rate_index = 0;
671 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; 670 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK;
672 } else { 671 } else {
673 switch (fc & IEEE80211_FCTL_STYPE) { 672 switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
674 case IEEE80211_STYPE_AUTH: 673 case cpu_to_le16(IEEE80211_STYPE_AUTH):
675 case IEEE80211_STYPE_DEAUTH: 674 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
676 case IEEE80211_STYPE_ASSOC_REQ: 675 case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ):
677 case IEEE80211_STYPE_REASSOC_REQ: 676 case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ):
678 if (tx_cmd->tx_flags & TX_CMD_FLG_RTS_MSK) { 677 if (tx_cmd->tx_flags & TX_CMD_FLG_RTS_MSK) {
679 tx_cmd->tx_flags &= ~TX_CMD_FLG_RTS_MSK; 678 tx_cmd->tx_flags &= ~TX_CMD_FLG_RTS_MSK;
680 tx_cmd->tx_flags |= TX_CMD_FLG_CTS_MSK; 679 tx_cmd->tx_flags |= TX_CMD_FLG_CTS_MSK;
@@ -771,7 +770,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
771 u16 seq_number = 0; 770 u16 seq_number = 0;
772 u8 id, hdr_len, unicast; 771 u8 id, hdr_len, unicast;
773 u8 sta_id; 772 u8 sta_id;
774 u16 fc; 773 __le16 fc;
775 u8 wait_write_ptr = 0; 774 u8 wait_write_ptr = 0;
776 u8 tid = 0; 775 u8 tid = 0;
777 u8 *qc = NULL; 776 u8 *qc = NULL;
@@ -798,19 +797,19 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
798 unicast = !is_multicast_ether_addr(hdr->addr1); 797 unicast = !is_multicast_ether_addr(hdr->addr1);
799 id = 0; 798 id = 0;
800 799
801 fc = le16_to_cpu(hdr->frame_control); 800 fc = hdr->frame_control;
802 801
803#ifdef CONFIG_IWLWIFI_DEBUG 802#ifdef CONFIG_IWLWIFI_DEBUG
804 if (ieee80211_is_auth(fc)) 803 if (ieee80211_is_auth(fc))
805 IWL_DEBUG_TX("Sending AUTH frame\n"); 804 IWL_DEBUG_TX("Sending AUTH frame\n");
806 else if (ieee80211_is_assoc_request(fc)) 805 else if (ieee80211_is_assoc_req(fc))
807 IWL_DEBUG_TX("Sending ASSOC frame\n"); 806 IWL_DEBUG_TX("Sending ASSOC frame\n");
808 else if (ieee80211_is_reassoc_request(fc)) 807 else if (ieee80211_is_reassoc_req(fc))
809 IWL_DEBUG_TX("Sending REASSOC frame\n"); 808 IWL_DEBUG_TX("Sending REASSOC frame\n");
810#endif 809#endif
811 810
812 /* drop all data frame if we are not associated */ 811 /* drop all data frame if we are not associated */
813 if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && 812 if (ieee80211_is_data(fc) &&
814 (!iwl_is_associated(priv) || 813 (!iwl_is_associated(priv) ||
815 ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id) || 814 ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id) ||
816 !priv->assoc_station_added)) { 815 !priv->assoc_station_added)) {
@@ -820,7 +819,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
820 819
821 spin_unlock_irqrestore(&priv->lock, flags); 820 spin_unlock_irqrestore(&priv->lock, flags);
822 821
823 hdr_len = ieee80211_get_hdrlen(fc); 822 hdr_len = ieee80211_get_hdrlen(le16_to_cpu(fc));
824 823
825 /* Find (or create) index into station table for destination station */ 824 /* Find (or create) index into station table for destination station */
826 sta_id = iwl_get_sta_id(priv, hdr); 825 sta_id = iwl_get_sta_id(priv, hdr);
@@ -834,8 +833,8 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
834 833
835 IWL_DEBUG_TX("station Id %d\n", sta_id); 834 IWL_DEBUG_TX("station Id %d\n", sta_id);
836 835
837 if (ieee80211_is_qos_data(fc)) { 836 if (ieee80211_is_data_qos(fc)) {
838 qc = ieee80211_get_qos_ctrl(hdr, hdr_len); 837 qc = ieee80211_get_qos_ctl(hdr);
839 tid = qc[0] & 0xf; 838 tid = qc[0] & 0xf;
840 seq_number = priv->stations[sta_id].tid[tid].seq_number & 839 seq_number = priv->stations[sta_id].tid[tid].seq_number &
841 IEEE80211_SCTL_SEQ; 840 IEEE80211_SCTL_SEQ;
@@ -938,7 +937,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
938 /* set is_hcca to 0; it probably will never be implemented */ 937 /* set is_hcca to 0; it probably will never be implemented */
939 iwl_tx_cmd_build_rate(priv, tx_cmd, info, fc, sta_id, 0); 938 iwl_tx_cmd_build_rate(priv, tx_cmd, info, fc, sta_id, 0);
940 939
941 iwl_update_tx_stats(priv, fc, len); 940 iwl_update_tx_stats(priv, le16_to_cpu(fc), len);
942 941
943 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + 942 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
944 offsetof(struct iwl_tx_cmd, scratch); 943 offsetof(struct iwl_tx_cmd, scratch);