[RAMEN9610-10619][Common][9610] wlbt: [ACS] Rssi factor calculation issue.
authorHimani Gupta <himani.g2@samsung.com>
Fri, 4 Jan 2019 06:32:22 +0000 (12:02 +0530)
committerhskang <hs1218.kang@samsung.com>
Fri, 11 Jan 2019 12:40:37 +0000 (21:40 +0900)
Driver changes to calculate rssi factor for 2.4GHZ.

Change-Id: I865c211f2a4cae268fc6dc19a9dff16960b5a50d
SCSC-Bug-Id: SSB-47988
Signed-off-by: Himani Gupta <himani.g2@samsung.com>
drivers/net/wireless/scsc/nl80211_vendor.c
drivers/net/wireless/scsc/nl80211_vendor.h
drivers/net/wireless/scsc/rx.c

index d011b1db74ff82ce672f7f9b678eab8ddbf7a685..c475041fa73e04d7ade6d50987a82e8781958dfa 100755 (executable)
@@ -6232,11 +6232,13 @@ static int slsi_acs_init(struct wiphy *wiphy,
                                return -ENOMEM;
                        }
                        memcpy(freq_list, nla_data(attr), nla_len(attr));
-                       freq_list_len = nla_len(attr);
+                       freq_list_len = nla_len(attr) / sizeof(u32);
+                       SLSI_INFO(sdev, "ACS freq_list_len: %d\n", freq_list_len);
                        break;
                }
                default:
-                       SLSI_ERR(sdev, "Invalid type : %d\n", type);
+                       if (type > SLSI_ACS_ATTR_MAX)
+                               SLSI_ERR(sdev, "Invalid type : %d\n", type);
                        break;
                }
        }
index 1d75011004db8f3dce60b2dbda1e9688a1323b82..2d456372e790a1dbfcca7cc6964625ad527d4cc9 100755 (executable)
@@ -1649,8 +1649,8 @@ struct slsi_acs_chan_info {
        u8 num_bss_load_ap;
        u8 total_chan_utilization;
        u8 avg_chan_utilization;
-       u8 rssi_factor;
-       u8 adj_rssi_factor;
+       int rssi_factor;
+       int adj_rssi_factor;
 };
 
 struct slsi_acs_selected_channels {
index 9d1fb2f887699da194b38876e93300808613bef3..693f6e9ad026e9dedbca27ffd94d1edee8d53816 100755 (executable)
@@ -575,7 +575,7 @@ int slsi_set_2g_auto_channel(struct slsi_dev *sdev, struct netdev_vif  *ndev_vif
                             struct slsi_acs_selected_channels *acs_selected_channels,
                             struct slsi_acs_chan_info *ch_info)
 {
-       int i = 0, j = 0, adjacent_rssi, avg_load, total_num_ap, total_rssi;
+       int i = 0, j = 0, avg_load, total_num_ap, total_rssi, adjacent_rssi;
        bool all_bss_load = true, none_bss_load = true;
        int  min_avg_chan_utilization = INT_MAX, min_adjacent_rssi = INT_MAX;
        int ch_idx_min_load = 0, ch_idx_min_rssi = 0;
@@ -814,6 +814,24 @@ int slsi_set_5g_auto_channel(struct slsi_dev *sdev, struct netdev_vif  *ndev_vif
        return ret;
 }
 
+int slsi_acs_get_rssi_factor(struct slsi_dev *sdev, int rssi, int ch_util)
+{
+       int frac_pow_val[10] = {10, 12, 15, 19, 25, 31, 39, 50, 63, 79};
+       int res = 1;
+       int i;
+
+       if (rssi < 0)
+               rssi = 0 - rssi;
+       else
+               return INT_MAX;
+       for (i = 0; i < rssi / 10; i++)
+               res *= 10;
+       res = (10000000 * ch_util / res)  / frac_pow_val[rssi % 10];
+
+       SLSI_DBG3(sdev, SLSI_MLME, "ch_util:%d\n", ch_util);
+       return res;
+}
+
 struct slsi_acs_chan_info *slsi_acs_scan_results(struct slsi_dev *sdev, struct netdev_vif  *ndev_vif, u16 scan_id)
 {
        struct sk_buff *scan_res;
@@ -869,9 +887,14 @@ struct slsi_acs_chan_info *slsi_acs_scan_results(struct slsi_dev *sdev, struct n
                                        ch_info[idx].total_chan_utilization += ch_util;
                                }
                        }
-                       if (idx == scan_channel->hw_value - 1)   /*if 2.4GHZ channel */
-                               ch_info[idx].rssi_factor += 10 ^ (fapi_get_s16(scan_res,
-                                                                 u.mlme_scan_ind.rssi) / 10) * ch_util;
+                       if (idx == scan_channel->hw_value - 1)  {    /*if 2.4GHZ channel */
+                               int res = 0;
+
+                               res = slsi_acs_get_rssi_factor(sdev, fapi_get_s16(scan_res, u.mlme_scan_ind.rssi),
+                                                              ch_util);
+                               ch_info[idx].rssi_factor += res;
+                               SLSI_DBG3(sdev, SLSI_MLME, "ch_info[idx].rssi_factor:%d\n", ch_info[idx].rssi_factor);
+                       }
                } else {
                        goto next_scan;
                }