Re: [PATCH 02/27] qtnfmac: make "Channel change" event report full channel info
From: Sergey Matyukevich <hidden>
Date: 2017-08-29 14:32:00
quoted hunk ↗ jump to hunk
static int qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif,@@ -358,41 +359,36 @@ qtnf_event_handle_freq_change(struct qtnf_wmac *mac, u16 len) { struct wiphy *wiphy = priv_to_wiphy(mac); - struct cfg80211_chan_def chandef; - struct ieee80211_channel *chan; + struct cfg80211_chan_def chdef; struct qtnf_vif *vif; - int freq; int i;
Original variable name 'chandef' was easier to spell on the phone :) ...
+ qlink_chandef_q2cfg(wiphy, &data->chan, &chdef);
+
+ if (!cfg80211_chandef_valid(&chdef)) {
+ pr_err("MAC%u: bad channel freq1=%u bw=%u\n", mac->macid,
+ chdef.center_freq1, chdef.width);
return -EINVAL;
}Lets keep both freq1 and freq2 in error message. ...
+void qlink_chandef_q2cfg(struct wiphy *wiphy,
+ const struct qlink_chandef *qch,
+ struct cfg80211_chan_def *chdef)
+{
+ chdef->center_freq1 = le16_to_cpu(qch->center_freq1);
+ chdef->center_freq2 = le16_to_cpu(qch->center_freq2);
+ chdef->width = qlink_chanwidth_to_nl(qch->width);
+
+ switch (chdef->width) {
+ case NL80211_CHAN_WIDTH_20_NOHT:
+ case NL80211_CHAN_WIDTH_20:
+ case NL80211_CHAN_WIDTH_5:
+ case NL80211_CHAN_WIDTH_10:
+ chdef->chan = ieee80211_get_channel(wiphy, chdef->center_freq1);
+ break;
+ case NL80211_CHAN_WIDTH_40:
+ case NL80211_CHAN_WIDTH_80:
+ case NL80211_CHAN_WIDTH_80P80:
+ case NL80211_CHAN_WIDTH_160:
+ chdef->chan = ieee80211_get_channel(wiphy,
+ chdef->center_freq1 - 10);Do we have the same formula for 40MHz and 80MHz center frequency ? I thought we should be using the channel number for the left-most 20MHz band.
+ break; + default: + chdef->chan = NULL; + break; + } +}
Regards, Sergey