Skip to content

Commit c863e20

Browse files
dhalperilinvjw
authored andcommitted
iwlwifi: implement iwl_debug_report_frame for iwlagn
The old version of this code was copied from 3945 and never updated. This patch cleans up structs that do not apply and accounts for other changes from 3945->iwlagn (e.g., PHY info can come in a separate cmd response from the ucode.) Signed-off-by: Daniel Halperin <[email protected]> Signed-off-by: Reinette Chatre <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent 0894e49 commit c863e20

File tree

3 files changed

+31
-105
lines changed

3 files changed

+31
-105
lines changed

drivers/net/wireless/iwlwifi/iwl-commands.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,25 +1023,6 @@ struct iwl_wep_cmd {
10231023
*
10241024
*****************************************************************************/
10251025

1026-
struct iwl4965_rx_frame_stats {
1027-
u8 phy_count;
1028-
u8 id;
1029-
u8 rssi;
1030-
u8 agc;
1031-
__le16 sig_avg;
1032-
__le16 noise_diff;
1033-
u8 payload[0];
1034-
} __attribute__ ((packed));
1035-
1036-
struct iwl4965_rx_frame_hdr {
1037-
__le16 channel;
1038-
__le16 phy_flags;
1039-
u8 reserved1;
1040-
u8 rate;
1041-
__le16 len;
1042-
u8 payload[0];
1043-
} __attribute__ ((packed));
1044-
10451026
#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
10461027
#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
10471028

@@ -1072,26 +1053,6 @@ struct iwl4965_rx_frame_hdr {
10721053
#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
10731054
#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
10741055

1075-
struct iwl4965_rx_frame_end {
1076-
__le32 status;
1077-
__le64 timestamp;
1078-
__le32 beacon_timestamp;
1079-
} __attribute__ ((packed));
1080-
1081-
/*
1082-
* REPLY_3945_RX = 0x1b (response only, not a command)
1083-
*
1084-
* NOTE: DO NOT dereference from casts to this structure
1085-
* It is provided only for calculating minimum data set size.
1086-
* The actual offsets of the hdr and end are dynamic based on
1087-
* stats.phy_count
1088-
*/
1089-
struct iwl4965_rx_frame {
1090-
struct iwl4965_rx_frame_stats stats;
1091-
struct iwl4965_rx_frame_hdr hdr;
1092-
struct iwl4965_rx_frame_end end;
1093-
} __attribute__ ((packed));
1094-
10951056
/* Fixed (non-configurable) rx data from phy */
10961057

10971058
#define IWL49_RX_RES_PHY_CNT 14
@@ -3049,7 +3010,6 @@ struct iwl_rx_packet {
30493010
struct iwl_cmd_header hdr;
30503011
union {
30513012
struct iwl_alive_resp alive_frame;
3052-
struct iwl4965_rx_frame rx_frame;
30533013
struct iwl4965_tx_resp tx_resp;
30543014
struct iwl4965_spectrum_notification spectrum_notif;
30553015
struct iwl4965_csa_notification csa_notif;
@@ -3068,8 +3028,6 @@ struct iwl_rx_packet {
30683028
} u;
30693029
} __attribute__ ((packed));
30703030

3071-
#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame))
3072-
30733031
int iwl_agn_check_rxon_cmd(struct iwl_rxon_cmd *rxon);
30743032

30753033
#endif /* __iwl_commands_h__ */

drivers/net/wireless/iwlwifi/iwl-dev.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,6 @@ struct iwl_hw_params {
553553
#define HT_SHORT_GI_40MHZ (1 << 1)
554554

555555

556-
#define IWL_RX_HDR(x) ((struct iwl4965_rx_frame_hdr *)(\
557-
x->u.rx_frame.stats.payload + \
558-
x->u.rx_frame.stats.phy_count))
559-
#define IWL_RX_END(x) ((struct iwl4965_rx_frame_end *)(\
560-
IWL_RX_HDR(x)->payload + \
561-
le16_to_cpu(IWL_RX_HDR(x)->len)))
562-
#define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
563-
#define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
564-
565556
/******************************************************************************
566557
*
567558
* Functions implemented in core module which are forward declared here

drivers/net/wireless/iwlwifi/iwl-rx.c

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -622,20 +622,24 @@ static int iwl_calc_sig_qual(int rssi_dbm, int noise_dbm)
622622
return sig_qual;
623623
}
624624

625-
#ifdef CONFIG_IWLWIFI_DEBUG
625+
/* Calc max signal level (dBm) among 3 possible receivers */
626+
static inline int iwl_calc_rssi(struct iwl_priv *priv,
627+
struct iwl_rx_phy_res *rx_resp)
628+
{
629+
return priv->cfg->ops->utils->calc_rssi(priv, rx_resp);
630+
}
626631

632+
#ifdef CONFIG_IWLWIFI_DEBUG
627633
/**
628634
* iwl_dbg_report_frame - dump frame to syslog during debug sessions
629635
*
630636
* You may hack this function to show different aspects of received frames,
631637
* including selective frame dumps.
632-
* group100 parameter selects whether to show 1 out of 100 good frames.
633-
*
634-
* TODO: This was originally written for 3945, need to audit for
635-
* proper operation with 4965.
638+
* group100 parameter selects whether to show 1 out of 100 good data frames.
639+
* All beacon and probe response frames are printed.
636640
*/
637641
static void iwl_dbg_report_frame(struct iwl_priv *priv,
638-
struct iwl_rx_packet *pkt,
642+
struct iwl_rx_phy_res *phy_res, u16 length,
639643
struct ieee80211_hdr *header, int group100)
640644
{
641645
u32 to_us;
@@ -647,20 +651,9 @@ static void iwl_dbg_report_frame(struct iwl_priv *priv,
647651
u16 seq_ctl;
648652
u16 channel;
649653
u16 phy_flags;
650-
int rate_sym;
651-
u16 length;
652-
u16 status;
653-
u16 bcn_tmr;
654+
u32 rate_n_flags;
654655
u32 tsf_low;
655-
u64 tsf;
656-
u8 rssi;
657-
u8 agc;
658-
u16 sig_avg;
659-
u16 noise_diff;
660-
struct iwl4965_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt);
661-
struct iwl4965_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
662-
struct iwl4965_rx_frame_end *rx_end = IWL_RX_END(pkt);
663-
u8 *data = IWL_RX_DATA(pkt);
656+
int rssi;
664657

665658
if (likely(!(priv->debug_level & IWL_DL_RX)))
666659
return;
@@ -670,22 +663,13 @@ static void iwl_dbg_report_frame(struct iwl_priv *priv,
670663
seq_ctl = le16_to_cpu(header->seq_ctrl);
671664

672665
/* metadata */
673-
channel = le16_to_cpu(rx_hdr->channel);
674-
phy_flags = le16_to_cpu(rx_hdr->phy_flags);
675-
rate_sym = rx_hdr->rate;
676-
length = le16_to_cpu(rx_hdr->len);
677-
678-
/* end-of-frame status and timestamp */
679-
status = le32_to_cpu(rx_end->status);
680-
bcn_tmr = le32_to_cpu(rx_end->beacon_timestamp);
681-
tsf_low = le64_to_cpu(rx_end->timestamp) & 0x0ffffffff;
682-
tsf = le64_to_cpu(rx_end->timestamp);
666+
channel = le16_to_cpu(phy_res->channel);
667+
phy_flags = le16_to_cpu(phy_res->phy_flags);
668+
rate_n_flags = le32_to_cpu(phy_res->rate_n_flags);
683669

684670
/* signal statistics */
685-
rssi = rx_stats->rssi;
686-
agc = rx_stats->agc;
687-
sig_avg = le16_to_cpu(rx_stats->sig_avg);
688-
noise_diff = le16_to_cpu(rx_stats->noise_diff);
671+
rssi = iwl_calc_rssi(priv, phy_res);
672+
tsf_low = le64_to_cpu(phy_res->timestamp) & 0x0ffffffff;
689673

690674
to_us = !compare_ether_addr(header->addr1, priv->mac_addr);
691675

@@ -739,11 +723,13 @@ static void iwl_dbg_report_frame(struct iwl_priv *priv,
739723
else
740724
title = "Frame";
741725

742-
rate_idx = iwl_hwrate_to_plcp_idx(rate_sym);
743-
if (unlikely(rate_idx == -1))
726+
rate_idx = iwl_hwrate_to_plcp_idx(rate_n_flags);
727+
if (unlikely((rate_idx < 0) || (rate_idx >= IWL_RATE_COUNT))) {
744728
bitrate = 0;
745-
else
729+
WARN_ON_ONCE(1);
730+
} else {
746731
bitrate = iwl_rates[rate_idx].ieee / 2;
732+
}
747733

748734
/* print frame summary.
749735
* MAC addresses show just the last byte (for brevity),
@@ -755,23 +741,22 @@ static void iwl_dbg_report_frame(struct iwl_priv *priv,
755741
length, rssi, channel, bitrate);
756742
else {
757743
/* src/dst addresses assume managed mode */
758-
IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, "
759-
"src=0x%02x, rssi=%u, tim=%lu usec, "
744+
IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, src=0x%02x, "
745+
"len=%u, rssi=%d, tim=%lu usec, "
760746
"phy=0x%02x, chnl=%d\n",
761747
title, le16_to_cpu(fc), header->addr1[5],
762-
header->addr3[5], rssi,
748+
header->addr3[5], length, rssi,
763749
tsf_low - priv->scan_start_tsf,
764750
phy_flags, channel);
765751
}
766752
}
767753
if (print_dump)
768-
iwl_print_hex_dump(priv, IWL_DL_RX, data, length);
754+
iwl_print_hex_dump(priv, IWL_DL_RX, header, length);
769755
}
770756
#else
771-
static inline void iwl_dbg_report_frame(struct iwl_priv *priv,
772-
struct iwl_rx_packet *pkt,
773-
struct ieee80211_hdr *header,
774-
int group100)
757+
static void iwl_dbg_report_frame(struct iwl_priv *priv,
758+
struct iwl_rx_phy_res *phy_res, u16 length,
759+
struct ieee80211_hdr *header, int group100)
775760
{
776761
}
777762
#endif
@@ -966,14 +951,6 @@ static void iwl_pass_packet_to_mac80211(struct iwl_priv *priv,
966951
rxb->skb = NULL;
967952
}
968953

969-
/* Calc max signal level (dBm) among 3 possible receivers */
970-
static inline int iwl_calc_rssi(struct iwl_priv *priv,
971-
struct iwl_rx_phy_res *rx_resp)
972-
{
973-
return priv->cfg->ops->utils->calc_rssi(priv, rx_resp);
974-
}
975-
976-
977954
/* This is necessary only for a number of statistics, see the caller. */
978955
static int iwl_is_network_packet(struct iwl_priv *priv,
979956
struct ieee80211_hdr *header)
@@ -1096,8 +1073,8 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
10961073
priv->last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
10971074

10981075
/* Set "1" to report good data frames in groups of 100 */
1099-
/* FIXME: need to optimize the call: */
1100-
iwl_dbg_report_frame(priv, pkt, header, 1);
1076+
if (unlikely(priv->debug_level & IWL_DL_RX))
1077+
iwl_dbg_report_frame(priv, rx_start, len, header, 1);
11011078

11021079
IWL_DEBUG_STATS_LIMIT("Rssi %d, noise %d, qual %d, TSF %llu\n",
11031080
rx_status.signal, rx_status.noise, rx_status.signal,

0 commit comments

Comments
 (0)