@@ -1755,6 +1755,7 @@ static void mwifiex_complete_scan(struct mwifiex_private *priv)
17551755{
17561756 struct mwifiex_adapter * adapter = priv -> adapter ;
17571757
1758+ adapter -> survey_idx = 0 ;
17581759 if (adapter -> curr_cmd -> wait_q_enabled ) {
17591760 adapter -> cmd_wait_q .status = 0 ;
17601761 if (!priv -> scan_request ) {
@@ -1976,17 +1977,90 @@ int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
19761977 return 0 ;
19771978}
19781979
1980+ static void
1981+ mwifiex_update_chan_statistics (struct mwifiex_private * priv ,
1982+ struct mwifiex_ietypes_chanstats * tlv_stat )
1983+ {
1984+ struct mwifiex_adapter * adapter = priv -> adapter ;
1985+ u8 i , num_chan ;
1986+ struct mwifiex_fw_chan_stats * fw_chan_stats ;
1987+ struct mwifiex_chan_stats chan_stats ;
1988+
1989+ fw_chan_stats = (void * )((u8 * )tlv_stat +
1990+ sizeof (struct mwifiex_ie_types_header ));
1991+ num_chan = le16_to_cpu (tlv_stat -> header .len ) /
1992+ sizeof (struct mwifiex_chan_stats );
1993+
1994+ for (i = 0 ; i < num_chan ; i ++ ) {
1995+ chan_stats .chan_num = fw_chan_stats -> chan_num ;
1996+ chan_stats .bandcfg = fw_chan_stats -> bandcfg ;
1997+ chan_stats .flags = fw_chan_stats -> flags ;
1998+ chan_stats .noise = fw_chan_stats -> noise ;
1999+ chan_stats .total_bss = le16_to_cpu (fw_chan_stats -> total_bss );
2000+ chan_stats .cca_scan_dur =
2001+ le16_to_cpu (fw_chan_stats -> cca_scan_dur );
2002+ chan_stats .cca_busy_dur =
2003+ le16_to_cpu (fw_chan_stats -> cca_busy_dur );
2004+ dev_dbg (adapter -> dev ,
2005+ "chan=%d, noise=%d, total_network=%d scan_duration=%d, busy_duration=%d\n" ,
2006+ chan_stats .chan_num ,
2007+ chan_stats .noise ,
2008+ chan_stats .total_bss ,
2009+ chan_stats .cca_scan_dur ,
2010+ chan_stats .cca_busy_dur );
2011+ memcpy (& adapter -> chan_stats [adapter -> survey_idx ++ ], & chan_stats ,
2012+ sizeof (struct mwifiex_chan_stats ));
2013+ fw_chan_stats ++ ;
2014+ }
2015+ }
2016+
19792017/* This function handles the command response of extended scan */
1980- int mwifiex_ret_802_11_scan_ext (struct mwifiex_private * priv )
2018+ int mwifiex_ret_802_11_scan_ext (struct mwifiex_private * priv ,
2019+ struct host_cmd_ds_command * resp )
19812020{
19822021 struct mwifiex_adapter * adapter = priv -> adapter ;
2022+ struct host_cmd_ds_802_11_scan_ext * ext_scan_resp ;
2023+ struct mwifiex_ie_types_header * tlv ;
2024+ struct mwifiex_ietypes_chanstats * tlv_stat ;
2025+ u16 buf_left , type , len ;
2026+
19832027 struct host_cmd_ds_command * cmd_ptr ;
19842028 struct cmd_ctrl_node * cmd_node ;
19852029 unsigned long cmd_flags , scan_flags ;
19862030 bool complete_scan = false;
19872031
19882032 dev_dbg (priv -> adapter -> dev , "info: EXT scan returns successfully\n" );
19892033
2034+ ext_scan_resp = & resp -> params .ext_scan ;
2035+
2036+ tlv = (void * )ext_scan_resp -> tlv_buffer ;
2037+ buf_left = le16_to_cpu (resp -> size ) - (sizeof (* ext_scan_resp ) + S_DS_GEN
2038+ - 1 );
2039+
2040+ while (buf_left >= sizeof (struct mwifiex_ie_types_header )) {
2041+ type = le16_to_cpu (tlv -> type );
2042+ len = le16_to_cpu (tlv -> len );
2043+
2044+ if (buf_left < (sizeof (struct mwifiex_ie_types_header ) + len )) {
2045+ dev_err (adapter -> dev ,
2046+ "error processing scan response TLVs" );
2047+ break ;
2048+ }
2049+
2050+ switch (type ) {
2051+ case TLV_TYPE_CHANNEL_STATS :
2052+ tlv_stat = (void * )tlv ;
2053+ mwifiex_update_chan_statistics (priv , tlv_stat );
2054+ break ;
2055+ default :
2056+ break ;
2057+ }
2058+
2059+ buf_left -= len + sizeof (struct mwifiex_ie_types_header );
2060+ tlv = (void * )((u8 * )tlv + len +
2061+ sizeof (struct mwifiex_ie_types_header ));
2062+ }
2063+
19902064 spin_lock_irqsave (& adapter -> cmd_pending_q_lock , cmd_flags );
19912065 spin_lock_irqsave (& adapter -> scan_pending_q_lock , scan_flags );
19922066 if (list_empty (& adapter -> scan_pending_q )) {
0 commit comments