diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-06-11 17:21:56 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-14 12:18:12 -0400 |
commit | fd7c8a40b2a63863f749e4d17f0d94d2e5ab1331 (patch) | |
tree | 098e07d68b4d1e7a6c02750db480204c0dd469d5 /drivers/net/wireless/iwlwifi/iwl3945-base.c | |
parent | e36cfdc9b17fa64245ee6206287e5120e59bbfca (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/iwl3945-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index d0084bcb1eca..0a5bbe9ee938 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -2431,15 +2431,15 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv, | |||
2431 | struct ieee80211_hdr *hdr, | 2431 | struct ieee80211_hdr *hdr, |
2432 | int is_unicast, u8 std_id) | 2432 | int is_unicast, u8 std_id) |
2433 | { | 2433 | { |
2434 | u16 fc = le16_to_cpu(hdr->frame_control); | 2434 | __le16 fc = hdr->frame_control; |
2435 | __le32 tx_flags = cmd->cmd.tx.tx_flags; | 2435 | __le32 tx_flags = cmd->cmd.tx.tx_flags; |
2436 | 2436 | ||
2437 | cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | 2437 | cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; |
2438 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { | 2438 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { |
2439 | tx_flags |= TX_CMD_FLG_ACK_MSK; | 2439 | tx_flags |= TX_CMD_FLG_ACK_MSK; |
2440 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) | 2440 | if (ieee80211_is_mgmt(fc)) |
2441 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | 2441 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; |
2442 | if (ieee80211_is_probe_response(fc) && | 2442 | if (ieee80211_is_probe_resp(fc) && |
2443 | !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) | 2443 | !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) |
2444 | tx_flags |= TX_CMD_FLG_TSF_MSK; | 2444 | tx_flags |= TX_CMD_FLG_TSF_MSK; |
2445 | } else { | 2445 | } else { |
@@ -2451,8 +2451,8 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv, | |||
2451 | if (ieee80211_get_morefrag(hdr)) | 2451 | if (ieee80211_get_morefrag(hdr)) |
2452 | tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; | 2452 | tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; |
2453 | 2453 | ||
2454 | if (ieee80211_is_qos_data(fc)) { | 2454 | if (ieee80211_is_data_qos(fc)) { |
2455 | u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); | 2455 | u8 *qc = ieee80211_get_qos_ctl(hdr); |
2456 | cmd->cmd.tx.tid_tspec = qc[0] & 0xf; | 2456 | cmd->cmd.tx.tid_tspec = qc[0] & 0xf; |
2457 | tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; | 2457 | tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; |
2458 | } else { | 2458 | } else { |
@@ -2471,9 +2471,8 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv, | |||
2471 | tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; | 2471 | tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; |
2472 | 2472 | ||
2473 | tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); | 2473 | tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); |
2474 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { | 2474 | if (ieee80211_is_mgmt(fc)) { |
2475 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ || | 2475 | if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) |
2476 | (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ) | ||
2477 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3); | 2476 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3); |
2478 | else | 2477 | else |
2479 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2); | 2478 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2); |
@@ -2564,7 +2563,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb) | |||
2564 | u8 sta_id; | 2563 | u8 sta_id; |
2565 | u8 tid = 0; | 2564 | u8 tid = 0; |
2566 | u16 seq_number = 0; | 2565 | u16 seq_number = 0; |
2567 | u16 fc; | 2566 | __le16 fc; |
2568 | u8 wait_write_ptr = 0; | 2567 | u8 wait_write_ptr = 0; |
2569 | u8 *qc = NULL; | 2568 | u8 *qc = NULL; |
2570 | unsigned long flags; | 2569 | unsigned long flags; |
@@ -2589,28 +2588,28 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb) | |||
2589 | unicast = !is_multicast_ether_addr(hdr->addr1); | 2588 | unicast = !is_multicast_ether_addr(hdr->addr1); |
2590 | id = 0; | 2589 | id = 0; |
2591 | 2590 | ||
2592 | fc = le16_to_cpu(hdr->frame_control); | 2591 | fc = hdr->frame_control; |
2593 | 2592 | ||
2594 | #ifdef CONFIG_IWL3945_DEBUG | 2593 | #ifdef CONFIG_IWL3945_DEBUG |
2595 | if (ieee80211_is_auth(fc)) | 2594 | if (ieee80211_is_auth(fc)) |
2596 | IWL_DEBUG_TX("Sending AUTH frame\n"); | 2595 | IWL_DEBUG_TX("Sending AUTH frame\n"); |
2597 | else if (ieee80211_is_assoc_request(fc)) | 2596 | else if (ieee80211_is_assoc_req(fc)) |
2598 | IWL_DEBUG_TX("Sending ASSOC frame\n"); | 2597 | IWL_DEBUG_TX("Sending ASSOC frame\n"); |
2599 | else if (ieee80211_is_reassoc_request(fc)) | 2598 | else if (ieee80211_is_reassoc_req(fc)) |
2600 | IWL_DEBUG_TX("Sending REASSOC frame\n"); | 2599 | IWL_DEBUG_TX("Sending REASSOC frame\n"); |
2601 | #endif | 2600 | #endif |
2602 | 2601 | ||
2603 | /* drop all data frame if we are not associated */ | 2602 | /* drop all data frame if we are not associated */ |
2604 | if ((!iwl3945_is_associated(priv) || | 2603 | if ((!iwl3945_is_associated(priv) || |
2605 | ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id)) && | 2604 | ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id)) && |
2606 | ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)) { | 2605 | ieee80211_is_data(fc)) { |
2607 | IWL_DEBUG_DROP("Dropping - !iwl3945_is_associated\n"); | 2606 | IWL_DEBUG_DROP("Dropping - !iwl3945_is_associated\n"); |
2608 | goto drop_unlock; | 2607 | goto drop_unlock; |
2609 | } | 2608 | } |
2610 | 2609 | ||
2611 | spin_unlock_irqrestore(&priv->lock, flags); | 2610 | spin_unlock_irqrestore(&priv->lock, flags); |
2612 | 2611 | ||
2613 | hdr_len = ieee80211_get_hdrlen(fc); | 2612 | hdr_len = ieee80211_get_hdrlen(le16_to_cpu(fc)); |
2614 | 2613 | ||
2615 | /* Find (or create) index into station table for destination station */ | 2614 | /* Find (or create) index into station table for destination station */ |
2616 | sta_id = iwl3945_get_sta_id(priv, hdr); | 2615 | sta_id = iwl3945_get_sta_id(priv, hdr); |
@@ -2624,8 +2623,8 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb) | |||
2624 | 2623 | ||
2625 | IWL_DEBUG_RATE("station Id %d\n", sta_id); | 2624 | IWL_DEBUG_RATE("station Id %d\n", sta_id); |
2626 | 2625 | ||
2627 | if (ieee80211_is_qos_data(fc)) { | 2626 | if (ieee80211_is_data_qos(fc)) { |
2628 | qc = ieee80211_get_qos_ctrl(hdr, hdr_len); | 2627 | qc = ieee80211_get_qos_ctl(hdr); |
2629 | tid = qc[0] & 0xf; | 2628 | tid = qc[0] & 0xf; |
2630 | seq_number = priv->stations[sta_id].tid[tid].seq_number & | 2629 | seq_number = priv->stations[sta_id].tid[tid].seq_number & |
2631 | IEEE80211_SCTL_SEQ; | 2630 | IEEE80211_SCTL_SEQ; |
@@ -2746,7 +2745,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb) | |||
2746 | sizeof(out_cmd->cmd.tx)); | 2745 | sizeof(out_cmd->cmd.tx)); |
2747 | 2746 | ||
2748 | iwl3945_print_hex_dump(IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, | 2747 | iwl3945_print_hex_dump(IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, |
2749 | ieee80211_get_hdrlen(fc)); | 2748 | ieee80211_get_hdrlen(le16_to_cpu(fc))); |
2750 | 2749 | ||
2751 | /* Tell device the write index *just past* this latest filled TFD */ | 2750 | /* Tell device the write index *just past* this latest filled TFD */ |
2752 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); | 2751 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); |