Message ID | 20140211163738.GA32043@gmail.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
On 11/02/14 17:37, Calvin Owens wrote: > Create a function to return a descriptive string for each reason code, > and print that in addition to the numeric value in the kernel log. These > codes are easily found on popular search engines, but one is generally > not able to access the internet when dealing with wireless connectivity > issues. > > Changes in v2: Refactored array of strings into switch statement. > Changes in v3: Fix style problem, use simplifying macro for switch > statement, eliminate temporary enum variable. > > Signed-off-by: Calvin Owens <jcalvinowens@gmail.com> > --- > include/net/mac80211.h | 10 +++++++++ > net/mac80211/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ > net/mac80211/mlme.c | 12 +++++------ > 3 files changed, 73 insertions(+), 6 deletions(-) > > diff --git a/include/net/mac80211.h b/include/net/mac80211.h > index f4ab2fb..d18acfe 100644 > --- a/include/net/mac80211.h > +++ b/include/net/mac80211.h > @@ -2971,6 +2971,16 @@ struct ieee80211_ops { > */ > struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, > const struct ieee80211_ops *ops); > +/** > + * ieee80211_get_reason_code_string - Get human readable reason code > + * > + * This function returns a string describing the @reason_code. > + * > + * @reason_code: Reason code Kerneldoc is not properly formatted here. The "@argument:" clause should be on the line right after the function name (as explained in Documentation/kernel-doc-nano-HOWTO.txt), e.g.: /** * function_name - blabla * @arg: I am a good arg description * Cheers,
On Tue, 2014-02-11 at 10:37 -0600, Calvin Owens wrote: > Create a function to return a descriptive string for each reason code, > and print that in addition to the numeric value in the kernel log. These > codes are easily found on popular search engines, but one is generally > not able to access the internet when dealing with wireless connectivity > issues. [] > include/net/mac80211.h | 10 +++++++++ > net/mac80211/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ > net/mac80211/mlme.c | 12 +++++------ > 3 files changed, 73 insertions(+), 6 deletions(-) Is there a reason why all of this this shouldn't be a static function local to mlme.c? Is this ever going to be used somewhere else? -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tuesday 02/11 at 09:13 -0800, Joe Perches wrote: > On Tue, 2014-02-11 at 10:37 -0600, Calvin Owens wrote: > > Create a function to return a descriptive string for each reason code, > > and print that in addition to the numeric value in the kernel log. These > > codes are easily found on popular search engines, but one is generally > > not able to access the internet when dealing with wireless connectivity > > issues. > [] > > include/net/mac80211.h | 10 +++++++++ > > net/mac80211/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > net/mac80211/mlme.c | 12 +++++------ > > 3 files changed, 73 insertions(+), 6 deletions(-) > > Is there a reason why all of this this shouldn't > be a static function local to mlme.c? > > Is this ever going to be used somewhere else? The enum for the reason code is defined in "include/linux/ieee80211.h", which is #include'd in 61 different files, so I thought it was conceivable that it might. I also thought the compiler wasn't likely to inline it even if it were static, since it wasn't tiny and had several callers. The switch statement approach produces nice, smaller code though: (as opposed to the original with the array of strings) ffffffff81728ac0 <ieee80211_get_reason_code_string>: ffffffff81728ac0: 83 ef 01 sub $0x1,%edi ffffffff81728ac3: 55 push %rbp ffffffff81728ac4: 48 c7 c0 f5 a7 a6 81 mov $0xffffffff81a6a7f5,%rax ffffffff81728acb: 66 83 ff 41 cmp $0x41,%di ffffffff81728acf: 48 89 e5 mov %rsp,%rbp ffffffff81728ad2: 77 0b ja ffffffff81728adf <ieee80211_get_reason_code_string+0x1f> ffffffff81728ad4: 0f b7 ff movzwl %di,%edi ffffffff81728ad7: 48 8b 04 fd 40 98 8e mov -0x7e7167c0(,%rdi,8),%rax ffffffff81728ade: 81 ffffffff81728adf: 5d pop %rbp ffffffff81728ae0: c3 retq ffffffff81728ae1: 66 66 66 66 66 66 2e data32 data32 data32 data32 data32 nopw %cs:0x0(%rax,%rax,1) ffffffff81728ae8: 0f 1f 84 00 00 00 00 ffffffff81728aef: 00 ... so it probably would get inlined. I'll make it static and resend. Thanks, Calvin -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tuesday 02/11 at 17:48 +0100, Antonio Quartulli wrote: > On 11/02/14 17:37, Calvin Owens wrote: > > Create a function to return a descriptive string for each reason code, > > and print that in addition to the numeric value in the kernel log. These > > codes are easily found on popular search engines, but one is generally > > not able to access the internet when dealing with wireless connectivity > > issues. > > > > Changes in v2: Refactored array of strings into switch statement. > > Changes in v3: Fix style problem, use simplifying macro for switch > > statement, eliminate temporary enum variable. > > > > Signed-off-by: Calvin Owens <jcalvinowens@gmail.com> > > --- > > include/net/mac80211.h | 10 +++++++++ > > net/mac80211/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > net/mac80211/mlme.c | 12 +++++------ > > 3 files changed, 73 insertions(+), 6 deletions(-) > > > > diff --git a/include/net/mac80211.h b/include/net/mac80211.h > > index f4ab2fb..d18acfe 100644 > > --- a/include/net/mac80211.h > > +++ b/include/net/mac80211.h > > @@ -2971,6 +2971,16 @@ struct ieee80211_ops { > > */ > > struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, > > const struct ieee80211_ops *ops); > > +/** > > + * ieee80211_get_reason_code_string - Get human readable reason code > > + * > > + * This function returns a string describing the @reason_code. > > + * > > + * @reason_code: Reason code > > Kerneldoc is not properly formatted here. > The "@argument:" clause should be on the line right after the function > name (as explained in Documentation/kernel-doc-nano-HOWTO.txt), e.g.: > > /** > * function_name - blabla > * @arg: I am a good arg description > * I actually just copied the comment format above the functions surrounding the one I added, several of which also appear to be incorrectly formatted. I can submit a patch to fix those as well if you like: is it worth the trouble? Thanks, Calvin > Cheers, > > -- > Antonio Quartulli > -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, 2014-02-11 at 17:48 +0100, Antonio Quartulli wrote: > On 11/02/14 17:37, Calvin Owens wrote: > > Create a function to return a descriptive string for each reason code, > > and print that in addition to the numeric value in the kernel log. These > > codes are easily found on popular search engines, but one is generally > > not able to access the internet when dealing with wireless connectivity > > issues. > > > > Changes in v2: Refactored array of strings into switch statement. > > Changes in v3: Fix style problem, use simplifying macro for switch > > statement, eliminate temporary enum variable. > > > > Signed-off-by: Calvin Owens <jcalvinowens@gmail.com> > > --- > > include/net/mac80211.h | 10 +++++++++ > > net/mac80211/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > net/mac80211/mlme.c | 12 +++++------ > > 3 files changed, 73 insertions(+), 6 deletions(-) > > > > diff --git a/include/net/mac80211.h b/include/net/mac80211.h > > index f4ab2fb..d18acfe 100644 > > --- a/include/net/mac80211.h > > +++ b/include/net/mac80211.h > > @@ -2971,6 +2971,16 @@ struct ieee80211_ops { > > */ > > struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, > > const struct ieee80211_ops *ops); > > +/** > > + * ieee80211_get_reason_code_string - Get human readable reason code > > + * > > + * This function returns a string describing the @reason_code. > > + * > > + * @reason_code: Reason code > > Kerneldoc is not properly formatted here. > The "@argument:" clause should be on the line right after the function > name (as explained in Documentation/kernel-doc-nano-HOWTO.txt), e.g.: I'm pretty sure it gets parsed correctly anyway, see e.g. https://www.kernel.org/doc/htmldocs/80211/API-ieee80211-alloc-hw.html (which is the function right above with the same style) johannes -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index f4ab2fb..d18acfe 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -2971,6 +2971,16 @@ struct ieee80211_ops { */ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, const struct ieee80211_ops *ops); +/** + * ieee80211_get_reason_code_string - Get human readable reason code + * + * This function returns a string describing the @reason_code. + * + * @reason_code: Reason code + * + * Return: Human readable reason string, or "<INVALID>" + */ +const char *ieee80211_get_reason_code_string(u16 reason_code); /** * ieee80211_register_hw - Register hardware device diff --git a/net/mac80211/main.c b/net/mac80211/main.c index d767cfb..307b444 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -743,6 +743,63 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local) return 0; } +#define case_WLAN(type) \ + case WLAN_REASON_##type: return #type + +const char *ieee80211_get_reason_code_string(u16 reason_code) +{ + switch (reason_code) { + case_WLAN(UNSPECIFIED); + case_WLAN(PREV_AUTH_NOT_VALID); + case_WLAN(DEAUTH_LEAVING); + case_WLAN(DISASSOC_DUE_TO_INACTIVITY); + case_WLAN(DISASSOC_AP_BUSY); + case_WLAN(CLASS2_FRAME_FROM_NONAUTH_STA); + case_WLAN(CLASS3_FRAME_FROM_NONASSOC_STA); + case_WLAN(DISASSOC_STA_HAS_LEFT); + case_WLAN(STA_REQ_ASSOC_WITHOUT_AUTH); + case_WLAN(DISASSOC_BAD_POWER); + case_WLAN(DISASSOC_BAD_SUPP_CHAN); + case_WLAN(INVALID_IE); + case_WLAN(MIC_FAILURE); + case_WLAN(4WAY_HANDSHAKE_TIMEOUT); + case_WLAN(GROUP_KEY_HANDSHAKE_TIMEOUT); + case_WLAN(IE_DIFFERENT); + case_WLAN(INVALID_GROUP_CIPHER); + case_WLAN(INVALID_PAIRWISE_CIPHER); + case_WLAN(INVALID_AKMP); + case_WLAN(UNSUPP_RSN_VERSION); + case_WLAN(INVALID_RSN_IE_CAP); + case_WLAN(IEEE8021X_FAILED); + case_WLAN(CIPHER_SUITE_REJECTED); + case_WLAN(DISASSOC_UNSPECIFIED_QOS); + case_WLAN(DISASSOC_QAP_NO_BANDWIDTH); + case_WLAN(DISASSOC_LOW_ACK); + case_WLAN(DISASSOC_QAP_EXCEED_TXOP); + case_WLAN(QSTA_LEAVE_QBSS); + case_WLAN(QSTA_NOT_USE); + case_WLAN(QSTA_REQUIRE_SETUP); + case_WLAN(QSTA_TIMEOUT); + case_WLAN(QSTA_CIPHER_NOT_SUPP); + case_WLAN(MESH_PEER_CANCELED); + case_WLAN(MESH_MAX_PEERS); + case_WLAN(MESH_CONFIG); + case_WLAN(MESH_CLOSE); + case_WLAN(MESH_MAX_RETRIES); + case_WLAN(MESH_CONFIRM_TIMEOUT); + case_WLAN(MESH_INVALID_GTK); + case_WLAN(MESH_INCONSISTENT_PARAM); + case_WLAN(MESH_INVALID_SECURITY); + case_WLAN(MESH_PATH_ERROR); + case_WLAN(MESH_PATH_NOFORWARD); + case_WLAN(MESH_PATH_DEST_UNREACHABLE); + case_WLAN(MAC_EXISTS_IN_MBSS); + case_WLAN(MESH_CHAN_REGULATORY); + case_WLAN(MESH_CHAN); + default: return "<INVALID>"; + } +} + int ieee80211_register_hw(struct ieee80211_hw *hw) { struct ieee80211_local *local = hw_to_local(hw); diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index fc1d824..5dec202 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -2231,8 +2231,8 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); - sdata_info(sdata, "deauthenticated from %pM (Reason: %u)\n", - bssid, reason_code); + sdata_info(sdata, "deauthenticated from %pM (Reason: %u=%s)\n", + bssid, reason_code, ieee80211_get_reason_code_string(reason_code)); ieee80211_set_disassoc(sdata, 0, 0, false, NULL); @@ -4301,8 +4301,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, bool report_frame = false; sdata_info(sdata, - "deauthenticating from %pM by local choice (reason=%d)\n", - req->bssid, req->reason_code); + "deauthenticating from %pM by local choice (Reason: %u=%s)\n", + req->bssid, req->reason_code, ieee80211_get_reason_code_string(req->reason_code)); if (ifmgd->auth_data) { drv_mgd_prepare_tx(sdata->local, sdata); @@ -4348,8 +4348,8 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, return -ENOLINK; sdata_info(sdata, - "disassociating from %pM by local choice (reason=%d)\n", - req->bss->bssid, req->reason_code); + "disassociating from %pM by local choice (Reason: %u=%s)\n", + req->bss->bssid, req->reason_code, ieee80211_get_reason_code_string(req->reason_code)); memcpy(bssid, req->bss->bssid, ETH_ALEN); ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DISASSOC,
Create a function to return a descriptive string for each reason code, and print that in addition to the numeric value in the kernel log. These codes are easily found on popular search engines, but one is generally not able to access the internet when dealing with wireless connectivity issues. Changes in v2: Refactored array of strings into switch statement. Changes in v3: Fix style problem, use simplifying macro for switch statement, eliminate temporary enum variable. Signed-off-by: Calvin Owens <jcalvinowens@gmail.com> --- include/net/mac80211.h | 10 +++++++++ net/mac80211/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/mlme.c | 12 +++++------ 3 files changed, 73 insertions(+), 6 deletions(-)