old mode 100644new mode 100755.. | .. |
---|
469 | 469 | iter_cnt_to_send -= cnt; |
---|
470 | 470 | cache->tot_consumed += cnt; |
---|
471 | 471 | /* Push the data to the skb */ |
---|
472 | | -#ifdef ANDROID13_KERNEL515_BKPORT |
---|
473 | | - nla_put_nohdr(skb, cnt * sizeof(wifi_gscan_result_t), ptr); |
---|
474 | | -#else |
---|
475 | 472 | nla_append(skb, cnt * sizeof(wifi_gscan_result_t), ptr); |
---|
476 | | -#endif |
---|
477 | 473 | if (cache->tot_consumed == cache->tot_count) { |
---|
478 | 474 | cache = cache->next; |
---|
479 | 475 | } |
---|
.. | .. |
---|
1214 | 1210 | { |
---|
1215 | 1211 | int err = 0, type, band; |
---|
1216 | 1212 | struct bcm_cfg80211 *cfg = wiphy_priv(wiphy); |
---|
1217 | | - uint32 *reply = NULL; |
---|
| 1213 | + uint16 *reply = NULL; |
---|
1218 | 1214 | uint32 reply_len = 0, num_channels, mem_needed; |
---|
1219 | 1215 | struct sk_buff *skb; |
---|
1220 | 1216 | dhd_pub_t *dhdp; |
---|
.. | .. |
---|
2812 | 2808 | |
---|
2813 | 2809 | ret = dhd_cfgvendor_priv_string_handler(cfg, wdev, nlioc, buf); |
---|
2814 | 2810 | if (ret) { |
---|
2815 | | - WL_ERR(("dhd_cfgvendor returned error %d\n", ret)); |
---|
| 2811 | + WL_ERR(("dhd_cfgvendor returned error %d", ret)); |
---|
2816 | 2812 | vfree(buf); |
---|
2817 | 2813 | return ret; |
---|
2818 | 2814 | } |
---|
.. | .. |
---|
6860 | 6856 | cca_congest_ext_channel_req_v2_t *per_chspec_stats = NULL; |
---|
6861 | 6857 | uint per_chspec_stats_size = 0; |
---|
6862 | 6858 | cca_congest_ext_channel_req_v3_t *all_chan_results; |
---|
6863 | | - cca_congest_ext_channel_req_v3_t *all_chan_req = NULL; |
---|
6864 | | - uint all_chan_req_size = sizeof(cca_congest_ext_channel_req_v3_t); |
---|
| 6859 | + cca_congest_ext_channel_req_v3_t all_chan_req; |
---|
6865 | 6860 | #else |
---|
6866 | 6861 | /* cca_get_stats_ext iovar for Wifi channel statics */ |
---|
6867 | 6862 | struct cca_congest_ext_channel_req_v2 *cca_v2_results; |
---|
6868 | | - struct cca_congest_ext_channel_req_v2 *cca_v2_req = NULL; |
---|
6869 | | - uint cca_v2_req_size = sizeof(cca_congest_ext_channel_req_v2_t); |
---|
| 6863 | + struct cca_congest_ext_channel_req_v2 cca_v2_req; |
---|
6870 | 6864 | #endif /* CHAN_STATS_SUPPORT */ |
---|
6871 | 6865 | const wl_cnt_wlc_t *wlc_cnt; |
---|
6872 | 6866 | scb_val_t scbval; |
---|
.. | .. |
---|
7027 | 7021 | |
---|
7028 | 7022 | #ifdef CHAN_STATS_SUPPORT |
---|
7029 | 7023 | /* Option to get all channel statistics */ |
---|
7030 | | - all_chan_req = (void *)MALLOCZ(cfg->osh, all_chan_req_size); |
---|
7031 | | - if (all_chan_req == NULL) { |
---|
7032 | | - err = BCME_NOMEM; |
---|
7033 | | - WL_ERR(("all_chan_req alloc failed\n")); |
---|
7034 | | - goto exit; |
---|
7035 | | - } |
---|
7036 | | - all_chan_req->num_of_entries = 0; |
---|
7037 | | - all_chan_req->ver = WL_CCA_EXT_REQ_VER_V3; |
---|
| 7024 | + all_chan_req.num_of_entries = 0; |
---|
| 7025 | + all_chan_req.ver = WL_CCA_EXT_REQ_VER_V3; |
---|
7038 | 7026 | err = wldev_iovar_getbuf(bcmcfg_to_prmry_ndev(cfg), "cca_get_stats_ext", |
---|
7039 | | - all_chan_req, all_chan_req_size, iovar_buf, WLC_IOCTL_MAXLEN, NULL); |
---|
| 7027 | + &all_chan_req, sizeof(all_chan_req), iovar_buf, WLC_IOCTL_MAXLEN, NULL); |
---|
7040 | 7028 | |
---|
7041 | 7029 | if (err != BCME_OK && err != BCME_UNSUPPORTED) { |
---|
7042 | 7030 | WL_ERR(("cca_get_stats_ext iovar err = %d\n", err)); |
---|
.. | .. |
---|
7097 | 7085 | } |
---|
7098 | 7086 | } |
---|
7099 | 7087 | #else |
---|
7100 | | - cca_v2_req = (void *)MALLOCZ(cfg->osh, cca_v2_req_size); |
---|
7101 | | - if (cca_v2_req == NULL) { |
---|
7102 | | - err = BCME_NOMEM; |
---|
7103 | | - WL_ERR(("cca_v2_req alloc failed\n")); |
---|
7104 | | - goto exit; |
---|
7105 | | - } |
---|
7106 | | - cca_v2_req->ver = WL_CCA_EXT_REQ_VER_V2; |
---|
7107 | | - cca_v2_req->chanspec = |
---|
| 7088 | + cca_v2_req.ver = WL_CCA_EXT_REQ_VER_V2; |
---|
| 7089 | + cca_v2_req.chanspec = |
---|
7108 | 7090 | wl_chspec_host_to_driver(wf_chspec_primary20_chspec(cur_chanspec)); |
---|
7109 | 7091 | |
---|
7110 | | - err = wldev_iovar_getbuf(bcmcfg_to_prmry_ndev(cfg), "cca_get_stats_ext", cca_v2_req, |
---|
7111 | | - cca_v2_req_size, iovar_buf, WLC_IOCTL_MAXLEN, NULL); |
---|
| 7092 | + err = wldev_iovar_getbuf(bcmcfg_to_prmry_ndev(cfg), "cca_get_stats_ext", &cca_v2_req, |
---|
| 7093 | + sizeof(cca_v2_req), iovar_buf, WLC_IOCTL_MAXLEN, NULL); |
---|
7112 | 7094 | |
---|
7113 | 7095 | if (err != BCME_OK && err != BCME_UNSUPPORTED) { |
---|
7114 | 7096 | WL_ERR(("cca_get_stats_ext iovar err = %d\n", err)); |
---|
.. | .. |
---|
7163 | 7145 | dtoh32(cca_result->secs[0].congest_obss), |
---|
7164 | 7146 | dtoh32(cca_result->secs[0].interference))); |
---|
7165 | 7147 | } else { |
---|
7166 | | - WL_INFORM(("cca_get_stats is unsupported \n")); |
---|
| 7148 | + WL_ERR(("cca_get_stats is unsupported \n")); |
---|
7167 | 7149 | } |
---|
7168 | 7150 | |
---|
7169 | 7151 | /* If cca_get_stats is unsupported, cca_busy_time has zero value as initial value */ |
---|
.. | .. |
---|
7314 | 7296 | WL_ERR(("Vendor Command reply failed ret:%d \n", err)); |
---|
7315 | 7297 | |
---|
7316 | 7298 | exit: |
---|
7317 | | -#ifdef CHAN_STATS_SUPPORT |
---|
7318 | | - if (all_chan_req) { |
---|
7319 | | - MFREE(cfg->osh, all_chan_req, all_chan_req_size); |
---|
7320 | | - } |
---|
7321 | | -#else |
---|
7322 | | - if (cca_v2_req) { |
---|
7323 | | - MFREE(cfg->osh, cca_v2_req, cca_v2_req_size); |
---|
7324 | | - } |
---|
7325 | | -#endif /* CHAN_STATS_SUPPORT */ |
---|
7326 | 7299 | if (outdata) { |
---|
7327 | 7300 | MFREE(cfg->osh, outdata, WLC_IOCTL_MAXLEN); |
---|
7328 | 7301 | } |
---|
.. | .. |
---|
9069 | 9042 | } |
---|
9070 | 9043 | #endif /* WL_SAR_TX_POWER */ |
---|
9071 | 9044 | |
---|
9072 | | -#if !defined(WL_TWT) && defined(WL_TWT_HAL_IF) |
---|
9073 | | -static int |
---|
9074 | | -wl_cfgvendor_twt_setup(struct wiphy *wiphy, |
---|
9075 | | - struct wireless_dev *wdev, const void *data, int len) |
---|
9076 | | -{ |
---|
9077 | | - wl_twt_config_t val; |
---|
9078 | | - s32 bw; |
---|
9079 | | - s32 type, rem_attr; |
---|
9080 | | - u8 mybuf[WLC_IOCTL_SMLEN] = {0}; |
---|
9081 | | - u8 resp_buf[WLC_IOCTL_SMLEN] = {0}; |
---|
9082 | | - const struct nlattr *iter; |
---|
9083 | | - uint8 *rem = mybuf; |
---|
9084 | | - uint16 rem_len = sizeof(mybuf); |
---|
9085 | | - |
---|
9086 | | - bzero(&val, sizeof(val)); |
---|
9087 | | - val.version = WL_TWT_SETUP_VER; |
---|
9088 | | - val.length = sizeof(val.version) + sizeof(val.length); |
---|
9089 | | - |
---|
9090 | | - /* Default values, Override Below */ |
---|
9091 | | - val.desc.flow_flags = 0; |
---|
9092 | | - val.desc.wake_time_h = 0xFFFFFFFF; |
---|
9093 | | - val.desc.wake_time_l = 0xFFFFFFFF; |
---|
9094 | | - val.desc.wake_int_min = 0xFFFFFFFF; |
---|
9095 | | - val.desc.wake_int_max = 0xFFFFFFFF; |
---|
9096 | | - val.desc.wake_dur_min = 0xFFFFFFFF; |
---|
9097 | | - val.desc.wake_dur_max = 0xFFFFFFFF; |
---|
9098 | | - val.desc.avg_pkt_num = 0xFFFFFFFF; |
---|
9099 | | - val.desc.avg_pkt_size = 0xFFFFFFFF; |
---|
9100 | | - |
---|
9101 | | - nla_for_each_attr(iter, data, len, rem_attr) { |
---|
9102 | | - type = nla_type(iter); |
---|
9103 | | - switch (type) { |
---|
9104 | | - case ANDR_TWT_ATTR_CONFIG_ID: |
---|
9105 | | - /* Config ID */ |
---|
9106 | | - val.desc.configID = nla_get_u8(iter); |
---|
9107 | | - break; |
---|
9108 | | - case ANDR_TWT_ATTR_NEGOTIATION_TYPE: |
---|
9109 | | - /* negotiation_type */ |
---|
9110 | | - val.desc.negotiation_type = nla_get_u8(iter); |
---|
9111 | | - break; |
---|
9112 | | - case ANDR_TWT_ATTR_TRIGGER_TYPE: |
---|
9113 | | - /* Trigger Type */ |
---|
9114 | | - if (nla_get_u8(iter) == 1) { |
---|
9115 | | - val.desc.flow_flags |= WL_TWT_FLOW_FLAG_TRIGGER; |
---|
9116 | | - } |
---|
9117 | | - break; |
---|
9118 | | - case ANDR_TWT_ATTR_WAKE_DURATION: |
---|
9119 | | - /* Wake Duration */ |
---|
9120 | | - val.desc.wake_dur = nla_get_u32(iter); |
---|
9121 | | - break; |
---|
9122 | | - case ANDR_TWT_ATTR_WAKE_INTERVAL: |
---|
9123 | | - /* Wake interval */ |
---|
9124 | | - val.desc.wake_int = nla_get_u32(iter); |
---|
9125 | | - break; |
---|
9126 | | - case ANDR_TWT_ATTR_WAKETIME_OFFSET: |
---|
9127 | | - /* Wake Time parameter */ |
---|
9128 | | - val.desc.wake_time_h = 0; |
---|
9129 | | - val.desc.wake_time_l = nla_get_u32(iter); |
---|
9130 | | - break; |
---|
9131 | | - case ANDR_TWT_ATTR_WAKE_INTERVAL_MIN: |
---|
9132 | | - /* Minimum allowed Wake interval */ |
---|
9133 | | - val.desc.wake_int_min = nla_get_u32(iter); |
---|
9134 | | - break; |
---|
9135 | | - case ANDR_TWT_ATTR_WAKE_INTERVAL_MAX: |
---|
9136 | | - /* Max Allowed Wake interval */ |
---|
9137 | | - val.desc.wake_int_max = nla_get_u32(iter); |
---|
9138 | | - break; |
---|
9139 | | - case ANDR_TWT_ATTR_WAKE_DURATION_MIN: |
---|
9140 | | - /* Minimum allowed Wake duration */ |
---|
9141 | | - val.desc.wake_dur_min = nla_get_u32(iter); |
---|
9142 | | - break; |
---|
9143 | | - case ANDR_TWT_ATTR_WAKE_DURATION_MAX: |
---|
9144 | | - /* Maximum allowed Wake duration */ |
---|
9145 | | - val.desc.wake_dur_max = nla_get_u32(iter); |
---|
9146 | | - break; |
---|
9147 | | - case ANDR_TWT_ATTR_AVG_PKT_NUM: |
---|
9148 | | - /* Average number of packets */ |
---|
9149 | | - val.desc.avg_pkt_num = nla_get_u32(iter); |
---|
9150 | | - break; |
---|
9151 | | - case ANDR_TWT_ATTR_AVG_PKT_SIZE: |
---|
9152 | | - /* Average packets size */ |
---|
9153 | | - val.desc.avg_pkt_size = nla_get_u32(iter); |
---|
9154 | | - break; |
---|
9155 | | - default: |
---|
9156 | | - WL_ERR(("Invalid setup attribute type %d\n", type)); |
---|
9157 | | - break; |
---|
9158 | | - } |
---|
9159 | | - } |
---|
9160 | | - |
---|
9161 | | - bw = bcm_pack_xtlv_entry(&rem, &rem_len, WL_TWT_CMD_CONFIG, |
---|
9162 | | - sizeof(val), (uint8 *)&val, BCM_XTLV_OPTION_ALIGN32); |
---|
9163 | | - if (bw != BCME_OK) { |
---|
9164 | | - goto exit; |
---|
9165 | | - } |
---|
9166 | | - |
---|
9167 | | - bw = wldev_iovar_setbuf(wdev_to_ndev(wdev), "twt", |
---|
9168 | | - mybuf, sizeof(mybuf) - rem_len, resp_buf, WLC_IOCTL_SMLEN, NULL); |
---|
9169 | | - if (bw < 0) { |
---|
9170 | | - WL_ERR(("twt config set failed. ret:%d\n", bw)); |
---|
9171 | | - } else { |
---|
9172 | | - WL_INFORM(("twt config setup succeeded, config ID %d " |
---|
9173 | | - "Negotiation type %d flow flags %d\n", val.desc.configID, |
---|
9174 | | - val.desc.negotiation_type, val.desc.flow_flags)); |
---|
9175 | | - } |
---|
9176 | | - |
---|
9177 | | -exit: |
---|
9178 | | - return bw; |
---|
9179 | | -} |
---|
9180 | | - |
---|
9181 | | -static int |
---|
9182 | | -wl_cfgvendor_twt_teardown(struct wiphy *wiphy, |
---|
9183 | | - struct wireless_dev *wdev, const void *data, int len) |
---|
9184 | | -{ |
---|
9185 | | - wl_twt_teardown_t val; |
---|
9186 | | - s32 bw; |
---|
9187 | | - s32 type, rem_attr; |
---|
9188 | | - u8 mybuf[WLC_IOCTL_SMLEN] = {0}; |
---|
9189 | | - u8 res_buf[WLC_IOCTL_SMLEN] = {0}; |
---|
9190 | | - const struct nlattr *iter; |
---|
9191 | | - uint8 *rem = mybuf; |
---|
9192 | | - uint16 rem_len = sizeof(mybuf); |
---|
9193 | | - |
---|
9194 | | - bzero(&val, sizeof(val)); |
---|
9195 | | - val.version = WL_TWT_TEARDOWN_VER; |
---|
9196 | | - val.length = sizeof(val.version) + sizeof(val.length); |
---|
9197 | | - |
---|
9198 | | - /* Default values, Override Below */ |
---|
9199 | | - val.teardesc.flow_id = 0xFF; |
---|
9200 | | - val.teardesc.bid = 0xFF; |
---|
9201 | | - |
---|
9202 | | - nla_for_each_attr(iter, data, len, rem_attr) { |
---|
9203 | | - type = nla_type(iter); |
---|
9204 | | - switch (type) { |
---|
9205 | | - case ANDR_TWT_ATTR_CONFIG_ID: |
---|
9206 | | - /* Config ID */ |
---|
9207 | | - val.configID = nla_get_u8(iter); |
---|
9208 | | - break; |
---|
9209 | | - case ANDR_TWT_ATTR_NEGOTIATION_TYPE: |
---|
9210 | | - /* negotiation_type */ |
---|
9211 | | - val.teardesc.negotiation_type = nla_get_u8(iter); |
---|
9212 | | - break; |
---|
9213 | | - case ANDR_TWT_ATTR_ALL_TWT: |
---|
9214 | | - /* all twt */ |
---|
9215 | | - val.teardesc.alltwt = nla_get_u8(iter); |
---|
9216 | | - break; |
---|
9217 | | - default: |
---|
9218 | | - WL_ERR(("Invalid teardown attribute type %d\n", type)); |
---|
9219 | | - break; |
---|
9220 | | - } |
---|
9221 | | - } |
---|
9222 | | - |
---|
9223 | | - bw = bcm_pack_xtlv_entry(&rem, &rem_len, WL_TWT_CMD_TEARDOWN, |
---|
9224 | | - sizeof(val), (uint8 *)&val, BCM_XTLV_OPTION_ALIGN32); |
---|
9225 | | - if (bw != BCME_OK) { |
---|
9226 | | - goto exit; |
---|
9227 | | - } |
---|
9228 | | - |
---|
9229 | | - bw = wldev_iovar_setbuf(wdev_to_ndev(wdev), "twt", |
---|
9230 | | - mybuf, sizeof(mybuf) - rem_len, res_buf, WLC_IOCTL_SMLEN, NULL); |
---|
9231 | | - if (bw < 0) { |
---|
9232 | | - WL_ERR(("twt teardown failed. ret:%d\n", bw)); |
---|
9233 | | - } else { |
---|
9234 | | - WL_INFORM(("twt teardown succeeded, config ID %d " |
---|
9235 | | - "Negotiation type %d alltwt %d\n", val.configID, |
---|
9236 | | - val.teardesc.negotiation_type, val.teardesc.alltwt)); |
---|
9237 | | - } |
---|
9238 | | - |
---|
9239 | | -exit: |
---|
9240 | | - return bw; |
---|
9241 | | -} |
---|
9242 | | - |
---|
9243 | | -static int |
---|
9244 | | -wl_cfgvendor_twt_info_frame(struct wiphy *wiphy, |
---|
9245 | | - struct wireless_dev *wdev, const void *data, int len) |
---|
9246 | | -{ |
---|
9247 | | - wl_twt_info_t val; |
---|
9248 | | - int bw; |
---|
9249 | | - s32 type, rem_attr; |
---|
9250 | | - const struct nlattr *iter; |
---|
9251 | | - u8 mybuf[WLC_IOCTL_SMLEN] = {0}; |
---|
9252 | | - u8 res_buf[WLC_IOCTL_SMLEN] = {0}; |
---|
9253 | | - uint8 *rem = mybuf; |
---|
9254 | | - uint16 rem_len = sizeof(mybuf); |
---|
9255 | | - uint32 val32 = 0; |
---|
9256 | | - |
---|
9257 | | - bzero(&val, sizeof(val)); |
---|
9258 | | - val.version = WL_TWT_INFO_VER; |
---|
9259 | | - val.length = sizeof(val.version) + sizeof(val.length); |
---|
9260 | | - |
---|
9261 | | - /* Default values, Override Below */ |
---|
9262 | | - val.infodesc.flow_id = 0xFF; |
---|
9263 | | - val.desc.next_twt_h = 0xFFFFFFFF; |
---|
9264 | | - val.desc.next_twt_l = 0xFFFFFFFF; |
---|
9265 | | - |
---|
9266 | | - nla_for_each_attr(iter, data, len, rem_attr) { |
---|
9267 | | - type = nla_type(iter); |
---|
9268 | | - if (type == ANDR_TWT_ATTR_CONFIG_ID) { |
---|
9269 | | - /* Config ID */ |
---|
9270 | | - val.configID = nla_get_u8(iter); |
---|
9271 | | - } else if (type == ANDR_TWT_ATTR_RESUME_TIME) { |
---|
9272 | | - /* Resume offset */ |
---|
9273 | | - val32 = nla_get_u32(iter); |
---|
9274 | | - if (!((val32 == 0) || (val32 == -1))) { |
---|
9275 | | - val.infodesc.next_twt_h = 0; |
---|
9276 | | - val.infodesc.next_twt_l = val32; |
---|
9277 | | - val.infodesc.flow_flags |= WL_TWT_INFO_FLAG_RESUME; |
---|
9278 | | - } |
---|
9279 | | - } else if (type == ANDR_TWT_ATTR_ALL_TWT) { |
---|
9280 | | - /* all twt */ |
---|
9281 | | - val32 = (uint32)nla_get_u8(iter); |
---|
9282 | | - if (val32) { |
---|
9283 | | - val.infodesc.flow_flags |= WL_TWT_INFO_FLAG_ALL_TWT; |
---|
9284 | | - } |
---|
9285 | | - } else { |
---|
9286 | | - WL_ERR(("Invalid info frame attribute type %d\n", type)); |
---|
9287 | | - } |
---|
9288 | | - } |
---|
9289 | | - |
---|
9290 | | - bw = bcm_pack_xtlv_entry(&rem, &rem_len, WL_TWT_CMD_INFO, |
---|
9291 | | - sizeof(val), (uint8 *)&val, BCM_XTLV_OPTION_ALIGN32); |
---|
9292 | | - if (bw != BCME_OK) { |
---|
9293 | | - goto exit; |
---|
9294 | | - } |
---|
9295 | | - |
---|
9296 | | - bw = wldev_iovar_setbuf(wdev_to_ndev(wdev), "twt", |
---|
9297 | | - mybuf, sizeof(mybuf) - rem_len, res_buf, WLC_IOCTL_SMLEN, NULL); |
---|
9298 | | - if (bw < 0) { |
---|
9299 | | - WL_ERR(("twt info frame failed. ret:%d\n", bw)); |
---|
9300 | | - } else { |
---|
9301 | | - WL_INFORM(("twt info frame succeeded, config ID %d\n", val.configID)); |
---|
9302 | | - } |
---|
9303 | | - |
---|
9304 | | -exit: |
---|
9305 | | - return bw; |
---|
9306 | | -} |
---|
9307 | | - |
---|
9308 | | -static int |
---|
9309 | | -wl_cfgvendor_twt_stats_update_v2(struct wiphy *wiphy, wl_twt_stats_v2_t *stats) |
---|
9310 | | -{ |
---|
9311 | | - u32 i; |
---|
9312 | | - wl_twt_peer_stats_v2_t *peer_stats; |
---|
9313 | | - struct sk_buff *skb; |
---|
9314 | | - int32 mem_needed; |
---|
9315 | | - int ret = BCME_OK; |
---|
9316 | | - |
---|
9317 | | - mem_needed = BRCM_TWT_HAL_VENDOR_EVENT_BUF_LEN; |
---|
9318 | | - |
---|
9319 | | - skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, mem_needed); |
---|
9320 | | - if (unlikely(!skb)) { |
---|
9321 | | - WL_ERR(("%s: can't allocate %d bytes\n", __FUNCTION__, mem_needed)); |
---|
9322 | | - ret = -ENOMEM; |
---|
9323 | | - goto fail; |
---|
9324 | | - } |
---|
9325 | | - |
---|
9326 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_NUM_PEER_STATS, stats->num_stats); |
---|
9327 | | - if (ret < 0) { |
---|
9328 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_NUM_PEER_STATS, ret:%d\n", ret)); |
---|
9329 | | - goto fail; |
---|
9330 | | - } |
---|
9331 | | - |
---|
9332 | | - for (i = 0; i < stats->num_stats; i++) { |
---|
9333 | | - peer_stats = &stats->peer_stats_list[i]; |
---|
9334 | | - |
---|
9335 | | - WL_INFORM_MEM(("%u %u %u %u %u", |
---|
9336 | | - peer_stats->eosp_dur_avg, peer_stats->tx_pkts_avg, peer_stats->rx_pkts_avg, |
---|
9337 | | - peer_stats->tx_pkt_sz_avg, peer_stats->rx_pkt_sz_avg)); |
---|
9338 | | - ret = nla_put_u8(skb, ANDR_TWT_ATTR_CONFIG_ID, peer_stats->configID); |
---|
9339 | | - if (ret < 0) { |
---|
9340 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_CONFIG_ID, ret:%d\n", ret)); |
---|
9341 | | - goto fail; |
---|
9342 | | - } |
---|
9343 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_AVG_PKT_NUM_TX, peer_stats->tx_pkts_avg); |
---|
9344 | | - if (ret < 0) { |
---|
9345 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_AVG_PKT_NUM_TX, ret:%d\n", ret)); |
---|
9346 | | - goto fail; |
---|
9347 | | - } |
---|
9348 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_AVG_PKT_SIZE_TX, peer_stats->tx_pkt_sz_avg); |
---|
9349 | | - if (ret < 0) { |
---|
9350 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_AVG_PKT_SIZE_TX, ret:%d\n", ret)); |
---|
9351 | | - goto fail; |
---|
9352 | | - } |
---|
9353 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_AVG_PKT_NUM_RX, peer_stats->rx_pkts_avg); |
---|
9354 | | - if (ret < 0) { |
---|
9355 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_AVG_PKT_NUM_RX, ret:%d\n", ret)); |
---|
9356 | | - goto fail; |
---|
9357 | | - } |
---|
9358 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_AVG_PKT_SIZE_RX, peer_stats->rx_pkt_sz_avg); |
---|
9359 | | - if (ret < 0) { |
---|
9360 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_AVG_PKT_SIZE_RX, ret:%d\n", ret)); |
---|
9361 | | - goto fail; |
---|
9362 | | - } |
---|
9363 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_AVG_EOSP_DUR, peer_stats->eosp_dur_avg); |
---|
9364 | | - if (ret < 0) { |
---|
9365 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_AVG_EOSP_DUR, ret:%d\n", ret)); |
---|
9366 | | - goto fail; |
---|
9367 | | - } |
---|
9368 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_EOSP_CNT, peer_stats->eosp_count); |
---|
9369 | | - if (ret < 0) { |
---|
9370 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_EOSP_CNT, ret:%d\n", ret)); |
---|
9371 | | - goto fail; |
---|
9372 | | - } |
---|
9373 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_NUM_SP, peer_stats->sp_seq); |
---|
9374 | | - if (ret < 0) { |
---|
9375 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_NUM_SP, ret:%d\n", ret)); |
---|
9376 | | - goto fail; |
---|
9377 | | - } |
---|
9378 | | - } |
---|
9379 | | - |
---|
9380 | | - ret = cfg80211_vendor_cmd_reply(skb); |
---|
9381 | | - if (unlikely(ret)) { |
---|
9382 | | - WL_ERR(("vendor command reply failed, ret=%d\n", ret)); |
---|
9383 | | - } |
---|
9384 | | - return ret; |
---|
9385 | | - |
---|
9386 | | -fail: |
---|
9387 | | - /* Free skb for failure cases */ |
---|
9388 | | - if (skb) { |
---|
9389 | | - kfree_skb(skb); |
---|
9390 | | - } |
---|
9391 | | - return ret; |
---|
9392 | | -} |
---|
9393 | | - |
---|
9394 | | -static int |
---|
9395 | | -wl_cfgvendor_twt_stats(struct wiphy *wiphy, |
---|
9396 | | - struct wireless_dev *wdev, const void *data, int len, bool clear_stats) |
---|
9397 | | -{ |
---|
9398 | | - wl_twt_stats_cmd_v1_t query; |
---|
9399 | | - wl_twt_stats_v2_t stats_v2; |
---|
9400 | | - s32 type, rem_attr; |
---|
9401 | | - const struct nlattr *iter; |
---|
9402 | | - int ret = BCME_OK; |
---|
9403 | | - char iovbuf[WLC_IOCTL_SMLEN] = {0, }; |
---|
9404 | | - uint8 *pxtlv = NULL; |
---|
9405 | | - uint8 *iovresp = NULL; |
---|
9406 | | - uint16 buflen = 0, bufstart = 0; |
---|
9407 | | - struct bcm_cfg80211 *cfg = wl_get_cfg(wdev_to_ndev(wdev)); |
---|
9408 | | - |
---|
9409 | | - bzero(&query, sizeof(query)); |
---|
9410 | | - query.version = WL_TWT_STATS_CMD_VERSION_1; |
---|
9411 | | - query.length = sizeof(query) - OFFSETOF(wl_twt_stats_cmd_v1_t, peer); |
---|
9412 | | - |
---|
9413 | | - /* Default values, Override Below */ |
---|
9414 | | - query.num_bid = 0xFF; |
---|
9415 | | - query.num_fid = 0xFF; |
---|
9416 | | - |
---|
9417 | | - if (clear_stats) { |
---|
9418 | | - query.flags |= WL_TWT_STATS_CMD_FLAGS_RESET; |
---|
9419 | | - } |
---|
9420 | | - nla_for_each_attr(iter, data, len, rem_attr) { |
---|
9421 | | - type = nla_type(iter); |
---|
9422 | | - if (type == ANDR_TWT_ATTR_CONFIG_ID) { |
---|
9423 | | - /* Config ID */ |
---|
9424 | | - query.configID = nla_get_u8(iter); |
---|
9425 | | - } else { |
---|
9426 | | - WL_ERR(("Invalid TWT stats attribute type %d\n", type)); |
---|
9427 | | - } |
---|
9428 | | - } |
---|
9429 | | - |
---|
9430 | | - iovresp = (uint8 *)MALLOCZ(cfg->osh, WLC_IOCTL_MEDLEN); |
---|
9431 | | - if (iovresp == NULL) { |
---|
9432 | | - WL_ERR(("%s: iov resp memory alloc exited\n", __FUNCTION__)); |
---|
9433 | | - goto exit; |
---|
9434 | | - } |
---|
9435 | | - |
---|
9436 | | - buflen = bufstart = WLC_IOCTL_SMLEN; |
---|
9437 | | - pxtlv = (uint8 *)iovbuf; |
---|
9438 | | - ret = bcm_pack_xtlv_entry(&pxtlv, &buflen, WL_TWT_CMD_STATS, |
---|
9439 | | - sizeof(query), (uint8 *)&query, BCM_XTLV_OPTION_ALIGN32); |
---|
9440 | | - if (ret != BCME_OK) { |
---|
9441 | | - WL_ERR(("%s : Error return during pack xtlv :%d\n", __FUNCTION__, ret)); |
---|
9442 | | - goto exit; |
---|
9443 | | - } |
---|
9444 | | - |
---|
9445 | | - if ((ret = wldev_iovar_getbuf(wdev_to_ndev(wdev), "twt", iovbuf, bufstart-buflen, |
---|
9446 | | - iovresp, WLC_IOCTL_MEDLEN, NULL))) { |
---|
9447 | | - WL_ERR(("twt status failed with err=%d \n", ret)); |
---|
9448 | | - goto exit; |
---|
9449 | | - } |
---|
9450 | | - |
---|
9451 | | - (void)memcpy_s(&stats_v2, sizeof(stats_v2), iovresp, sizeof(stats_v2)); |
---|
9452 | | - |
---|
9453 | | - if (dtoh16(stats_v2.version) == WL_TWT_STATS_VERSION_2) { |
---|
9454 | | - if (!clear_stats) { |
---|
9455 | | - WL_ERR(("stats query ver %d, \n", dtoh16(stats_v2.version))); |
---|
9456 | | - ret = wl_cfgvendor_twt_stats_update_v2(wiphy, (wl_twt_stats_v2_t*)iovresp); |
---|
9457 | | - } |
---|
9458 | | - } else { |
---|
9459 | | - ret = BCME_UNSUPPORTED; |
---|
9460 | | - WL_ERR(("Version 1 unsupported. ver %d, \n", dtoh16(stats_v2.version))); |
---|
9461 | | - goto exit; |
---|
9462 | | - } |
---|
9463 | | - |
---|
9464 | | -exit: |
---|
9465 | | - if (iovresp) { |
---|
9466 | | - MFREE(cfg->osh, iovresp, WLC_IOCTL_MEDLEN); |
---|
9467 | | - } |
---|
9468 | | - |
---|
9469 | | - return ret; |
---|
9470 | | -} |
---|
9471 | | - |
---|
9472 | | -static int |
---|
9473 | | -wl_cfgvendor_twt_get_stats(struct wiphy *wiphy, |
---|
9474 | | - struct wireless_dev *wdev, const void *data, int len) |
---|
9475 | | -{ |
---|
9476 | | - return wl_cfgvendor_twt_stats(wiphy, wdev, data, len, false); |
---|
9477 | | -} |
---|
9478 | | - |
---|
9479 | | -static int |
---|
9480 | | -wl_cfgvendor_twt_clear_stats(struct wiphy *wiphy, |
---|
9481 | | - struct wireless_dev *wdev, const void *data, int len) |
---|
9482 | | -{ |
---|
9483 | | - return wl_cfgvendor_twt_stats(wiphy, wdev, data, len, true); |
---|
9484 | | -} |
---|
9485 | | - |
---|
9486 | | -static int |
---|
9487 | | -wl_cfgvendor_twt_update_cap(struct wiphy *wiphy, wl_twt_cap_t *result) |
---|
9488 | | -{ |
---|
9489 | | - struct sk_buff *skb; |
---|
9490 | | - int32 mem_needed; |
---|
9491 | | - int ret = BCME_OK; |
---|
9492 | | - |
---|
9493 | | - WL_INFORM_MEM(("TWT Capabilites Device,Peer 0x%04x 0x%04x\n", |
---|
9494 | | - result->device_cap, result->peer_cap)); |
---|
9495 | | - |
---|
9496 | | - mem_needed = VENDOR_REPLY_OVERHEAD + (ATTRIBUTE_U32_LEN * 2); |
---|
9497 | | - |
---|
9498 | | - skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, mem_needed); |
---|
9499 | | - if (unlikely(!skb)) { |
---|
9500 | | - WL_ERR(("%s: can't allocate %d bytes\n", __FUNCTION__, mem_needed)); |
---|
9501 | | - ret = -ENOMEM; |
---|
9502 | | - goto fail; |
---|
9503 | | - } |
---|
9504 | | - |
---|
9505 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_DEVICE_CAP, result->device_cap); |
---|
9506 | | - if (ret < 0) { |
---|
9507 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_DEVICE_CAP, ret:%d\n", ret)); |
---|
9508 | | - goto fail; |
---|
9509 | | - } |
---|
9510 | | - ret = nla_put_u32(skb, ANDR_TWT_ATTR_PEER_CAP, result->peer_cap); |
---|
9511 | | - if (ret < 0) { |
---|
9512 | | - WL_ERR(("Failed to put ANDR_TWT_ATTR_PEER_CAP, ret:%d\n", ret)); |
---|
9513 | | - goto fail; |
---|
9514 | | - } |
---|
9515 | | - |
---|
9516 | | - ret = cfg80211_vendor_cmd_reply(skb); |
---|
9517 | | - if (unlikely(ret)) { |
---|
9518 | | - WL_ERR(("vendor command reply failed, ret=%d\n", ret)); |
---|
9519 | | - } |
---|
9520 | | - return ret; |
---|
9521 | | - |
---|
9522 | | -fail: |
---|
9523 | | - /* Free skb for failure cases */ |
---|
9524 | | - if (skb) { |
---|
9525 | | - kfree_skb(skb); |
---|
9526 | | - } |
---|
9527 | | - return ret; |
---|
9528 | | -} |
---|
9529 | | - |
---|
9530 | | -static int |
---|
9531 | | -wl_cfgvendor_twt_cap(struct wiphy *wiphy, |
---|
9532 | | - struct wireless_dev *wdev, const void *data, int len) |
---|
9533 | | -{ |
---|
9534 | | - int ret = BCME_OK; |
---|
9535 | | - char iovbuf[WLC_IOCTL_SMLEN] = {0, }; |
---|
9536 | | - uint8 *pxtlv = NULL; |
---|
9537 | | - uint8 *iovresp = NULL; |
---|
9538 | | - wl_twt_cap_cmd_t cmd_cap; |
---|
9539 | | - wl_twt_cap_t result; |
---|
9540 | | - |
---|
9541 | | - uint16 buflen = 0, bufstart = 0; |
---|
9542 | | - struct bcm_cfg80211 *cfg = wl_get_cfg(wdev_to_ndev(wdev)); |
---|
9543 | | - |
---|
9544 | | - bzero(&cmd_cap, sizeof(cmd_cap)); |
---|
9545 | | - |
---|
9546 | | - cmd_cap.version = WL_TWT_CAP_CMD_VERSION_1; |
---|
9547 | | - cmd_cap.length = sizeof(cmd_cap) - OFFSETOF(wl_twt_cap_cmd_t, peer); |
---|
9548 | | - |
---|
9549 | | - iovresp = (uint8 *)MALLOCZ(cfg->osh, WLC_IOCTL_MEDLEN); |
---|
9550 | | - if (iovresp == NULL) { |
---|
9551 | | - WL_ERR(("%s: iov resp memory alloc exited\n", __FUNCTION__)); |
---|
9552 | | - goto exit; |
---|
9553 | | - } |
---|
9554 | | - |
---|
9555 | | - buflen = bufstart = WLC_IOCTL_SMLEN; |
---|
9556 | | - pxtlv = (uint8 *)iovbuf; |
---|
9557 | | - |
---|
9558 | | - ret = bcm_pack_xtlv_entry(&pxtlv, &buflen, WL_TWT_CMD_CAP, |
---|
9559 | | - sizeof(cmd_cap), (uint8 *)&cmd_cap, BCM_XTLV_OPTION_ALIGN32); |
---|
9560 | | - if (ret != BCME_OK) { |
---|
9561 | | - WL_ERR(("%s : Error return during pack xtlv :%d\n", __FUNCTION__, ret)); |
---|
9562 | | - goto exit; |
---|
9563 | | - } |
---|
9564 | | - |
---|
9565 | | - if ((ret = wldev_iovar_getbuf(wdev_to_ndev(wdev), "twt", iovbuf, bufstart-buflen, |
---|
9566 | | - iovresp, WLC_IOCTL_MEDLEN, NULL))) { |
---|
9567 | | - WL_ERR(("Getting twt status failed with err=%d \n", ret)); |
---|
9568 | | - goto exit; |
---|
9569 | | - } |
---|
9570 | | - |
---|
9571 | | - (void)memcpy_s(&result, sizeof(result), iovresp, sizeof(result)); |
---|
9572 | | - |
---|
9573 | | - if (dtoh16(result.version) == WL_TWT_CAP_CMD_VERSION_1) { |
---|
9574 | | - WL_ERR(("capability ver %d, \n", dtoh16(result.version))); |
---|
9575 | | - ret = wl_cfgvendor_twt_update_cap(wiphy, &result); |
---|
9576 | | - return ret; |
---|
9577 | | - } else { |
---|
9578 | | - ret = BCME_UNSUPPORTED; |
---|
9579 | | - WL_ERR(("Version 1 unsupported. ver %d, \n", dtoh16(result.version))); |
---|
9580 | | - goto exit; |
---|
9581 | | - } |
---|
9582 | | - |
---|
9583 | | -exit: |
---|
9584 | | - if (iovresp) { |
---|
9585 | | - MFREE(cfg->osh, iovresp, WLC_IOCTL_MEDLEN); |
---|
9586 | | - } |
---|
9587 | | - |
---|
9588 | | - return ret; |
---|
9589 | | -} |
---|
9590 | | - |
---|
9591 | | -static int |
---|
9592 | | -wl_cfgvendor_twt_update_setup_response(struct sk_buff *skb, void *event_data) |
---|
9593 | | -{ |
---|
9594 | | - s32 err = BCME_OK; |
---|
9595 | | - const wl_twt_setup_cplt_t *setup_cplt = (wl_twt_setup_cplt_t *)event_data; |
---|
9596 | | - const wl_twt_sdesc_t *sdesc = (const wl_twt_sdesc_t *)&setup_cplt[1]; |
---|
9597 | | - |
---|
9598 | | - WL_DBG(("TWT_SETUP: status %d, reason %d, configID %d, setup_cmd %d, flow_flags 0x%x," |
---|
9599 | | - " flow_id %d, channel %d, negotiation_type %d, wake_time_h %u, wake_time_l %u," |
---|
9600 | | - " wake_dur %u, wake_int %u\n", |
---|
9601 | | - (int)setup_cplt->status, (int)setup_cplt->reason_code, (int)setup_cplt->configID, |
---|
9602 | | - (int)sdesc->setup_cmd, sdesc->flow_flags, (int)sdesc->flow_id, (int)sdesc->channel, |
---|
9603 | | - (int)sdesc->negotiation_type, sdesc->wake_time_h, sdesc->wake_time_l, |
---|
9604 | | - sdesc->wake_dur, sdesc->wake_int)); |
---|
9605 | | - |
---|
9606 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_SUB_EVENT, ANDR_TWT_EVENT_SETUP); |
---|
9607 | | - if (unlikely(err)) { |
---|
9608 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_SUB_EVENT failed\n")); |
---|
9609 | | - goto fail; |
---|
9610 | | - } |
---|
9611 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_CONFIG_ID, setup_cplt->configID); |
---|
9612 | | - if (unlikely(err)) { |
---|
9613 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_CONFIG_ID failed\n")); |
---|
9614 | | - goto fail; |
---|
9615 | | - } |
---|
9616 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_REASON_CODE, setup_cplt->reason_code); |
---|
9617 | | - if (unlikely(err)) { |
---|
9618 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_REASON_CODE failed\n")); |
---|
9619 | | - goto fail; |
---|
9620 | | - } |
---|
9621 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_STATUS, !!(setup_cplt->status)); |
---|
9622 | | - if (unlikely(err)) { |
---|
9623 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_STATUS failed\n")); |
---|
9624 | | - goto fail; |
---|
9625 | | - } |
---|
9626 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_NEGOTIATION_TYPE, sdesc->negotiation_type); |
---|
9627 | | - if (unlikely(err)) { |
---|
9628 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_NEGOTIATION_TYPE failed\n")); |
---|
9629 | | - goto fail; |
---|
9630 | | - } |
---|
9631 | | - err = nla_put_u32(skb, ANDR_TWT_ATTR_WAKE_DURATION, sdesc->wake_dur); |
---|
9632 | | - if (unlikely(err)) { |
---|
9633 | | - WL_ERR(("nla_put_u32 WIFI_TWT_ATTR_WAKE_DURATION failed\n")); |
---|
9634 | | - goto fail; |
---|
9635 | | - } |
---|
9636 | | - err = nla_put_u32(skb, ANDR_TWT_ATTR_WAKE_INTERVAL, sdesc->wake_int); |
---|
9637 | | - if (unlikely(err)) { |
---|
9638 | | - WL_ERR(("nla_put_u32 WIFI_TWT_ATTR_WAKE_INTERVAL failed\n")); |
---|
9639 | | - goto fail; |
---|
9640 | | - } |
---|
9641 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_TRIGGER_TYPE, |
---|
9642 | | - !!(sdesc->flow_flags & WL_TWT_FLOW_FLAG_TRIGGER)); |
---|
9643 | | - if (unlikely(err)) { |
---|
9644 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_TRIGGER_TYPE failed\n")); |
---|
9645 | | - goto fail; |
---|
9646 | | - } |
---|
9647 | | - |
---|
9648 | | -fail: |
---|
9649 | | - return err; |
---|
9650 | | -} |
---|
9651 | | - |
---|
9652 | | -static int |
---|
9653 | | -wl_cfgvendor_twt_update_teardown_response(struct sk_buff *skb, void *event_data) |
---|
9654 | | -{ |
---|
9655 | | - s32 err = BCME_OK; |
---|
9656 | | - const wl_twt_teardown_cplt_t *td_cplt = (wl_twt_teardown_cplt_t *)event_data; |
---|
9657 | | - const wl_twt_teardesc_t *teardesc = (const wl_twt_teardesc_t *)&td_cplt[1]; |
---|
9658 | | - |
---|
9659 | | - WL_DBG(("TWT_TEARDOWN: status %d, reason %d, configID %d, flow_id %d, negotiation_type %d," |
---|
9660 | | - " bid %d, alltwt %d\n", (int)td_cplt->status, (int)td_cplt->reason_code, |
---|
9661 | | - (int)td_cplt->configID, (int)teardesc->flow_id, (int)teardesc->negotiation_type, |
---|
9662 | | - (int)teardesc->bid, (int)teardesc->alltwt)); |
---|
9663 | | - |
---|
9664 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_SUB_EVENT, ANDR_TWT_EVENT_TEARDOWN); |
---|
9665 | | - if (unlikely(err)) { |
---|
9666 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_SUB_EVENT failed\n")); |
---|
9667 | | - goto fail; |
---|
9668 | | - } |
---|
9669 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_REASON_CODE, td_cplt->reason_code); |
---|
9670 | | - if (unlikely(err)) { |
---|
9671 | | - WL_ERR(("nla_put_u8 ANDR_TWT_ATTR_REASON_CODE failed\n")); |
---|
9672 | | - goto fail; |
---|
9673 | | - } |
---|
9674 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_STATUS, !!(td_cplt->status)); |
---|
9675 | | - if (unlikely(err)) { |
---|
9676 | | - WL_ERR(("nla_put_u8 ANDR_TWT_ATTR_STATUS failed\n")); |
---|
9677 | | - goto fail; |
---|
9678 | | - } |
---|
9679 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_CONFIG_ID, td_cplt->configID); |
---|
9680 | | - if (unlikely(err)) { |
---|
9681 | | - WL_ERR(("nla_put_u8 ANDR_TWT_ATTR_CONFIG_ID failed\n")); |
---|
9682 | | - goto fail; |
---|
9683 | | - } |
---|
9684 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_ALL_TWT, teardesc->alltwt); |
---|
9685 | | - if (unlikely(err)) { |
---|
9686 | | - WL_ERR(("nla_put_u8 ANDR_TWT_ATTR_ALL_TWT failed\n")); |
---|
9687 | | - goto fail; |
---|
9688 | | - } |
---|
9689 | | - |
---|
9690 | | -fail: |
---|
9691 | | - return err; |
---|
9692 | | -} |
---|
9693 | | - |
---|
9694 | | -static int |
---|
9695 | | -wl_cfgvendor_twt_update_infoframe_response(struct sk_buff *skb, void *event_data) |
---|
9696 | | -{ |
---|
9697 | | - s32 err = BCME_OK; |
---|
9698 | | - const wl_twt_info_cplt_t *info_cplt = (wl_twt_info_cplt_t *)event_data; |
---|
9699 | | - const wl_twt_infodesc_t *infodesc = (const wl_twt_infodesc_t *)&info_cplt[1]; |
---|
9700 | | - |
---|
9701 | | - WL_DBG(("TWT_INFOFRM: status %d, reason %d, configID %d, flow_flags 0x%x, flow_id %d," |
---|
9702 | | - " next_twt_h %u, next_twt_l %u\n", (int)info_cplt->status, |
---|
9703 | | - (int)info_cplt->reason_code, (int)info_cplt->configID, infodesc->flow_flags, |
---|
9704 | | - (int)infodesc->flow_id, infodesc->next_twt_h, infodesc->next_twt_l)); |
---|
9705 | | - |
---|
9706 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_SUB_EVENT, ANDR_TWT_EVENT_INFO_FRM); |
---|
9707 | | - if (unlikely(err)) { |
---|
9708 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_SUB_EVENT failed\n")); |
---|
9709 | | - goto fail; |
---|
9710 | | - } |
---|
9711 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_REASON_CODE, info_cplt->reason_code); |
---|
9712 | | - if (unlikely(err)) { |
---|
9713 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_REASON_CODE failed\n")); |
---|
9714 | | - goto fail; |
---|
9715 | | - } |
---|
9716 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_STATUS, !!(info_cplt->status)); |
---|
9717 | | - if (unlikely(err)) { |
---|
9718 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_STATUS failed\n")); |
---|
9719 | | - goto fail; |
---|
9720 | | - } |
---|
9721 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_CONFIG_ID, info_cplt->configID); |
---|
9722 | | - if (unlikely(err)) { |
---|
9723 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_CONFIG_ID failed\n")); |
---|
9724 | | - goto fail; |
---|
9725 | | - } |
---|
9726 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_ALL_TWT, |
---|
9727 | | - !!(infodesc->flow_flags & WL_TWT_INFO_FLAG_ALL_TWT)); |
---|
9728 | | - if (unlikely(err)) { |
---|
9729 | | - WL_ERR(("nla_put_u8 ANDR_TWT_ATTR_TWT_RESUMED failed\n")); |
---|
9730 | | - goto fail; |
---|
9731 | | - } |
---|
9732 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_TWT_RESUMED, |
---|
9733 | | - !!(infodesc->flow_flags & WL_TWT_INFO_FLAG_RESUME)); |
---|
9734 | | - if (unlikely(err)) { |
---|
9735 | | - WL_ERR(("nla_put_u8 ANDR_TWT_ATTR_TWT_RESUMED failed\n")); |
---|
9736 | | - goto fail; |
---|
9737 | | - } |
---|
9738 | | - |
---|
9739 | | -fail: |
---|
9740 | | - return err; |
---|
9741 | | -} |
---|
9742 | | - |
---|
9743 | | -static int |
---|
9744 | | -wl_cfgvendor_twt_update_notify_response(struct sk_buff *skb, void *event_data) |
---|
9745 | | -{ |
---|
9746 | | - s32 err = BCME_OK; |
---|
9747 | | - const wl_twt_notify_t *notif_cplt = (wl_twt_notify_t *)event_data; |
---|
9748 | | - |
---|
9749 | | - WL_DBG(("TWT_NOTIFY: notification %d\n", (int)notif_cplt->notification)); |
---|
9750 | | - |
---|
9751 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_SUB_EVENT, ANDR_TWT_EVENT_NOTIFY); |
---|
9752 | | - if (unlikely(err)) { |
---|
9753 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_SUB_EVENT failed\n")); |
---|
9754 | | - goto fail; |
---|
9755 | | - } |
---|
9756 | | - |
---|
9757 | | - err = nla_put_u8(skb, ANDR_TWT_ATTR_TWT_NOTIFICATION, notif_cplt->notification); |
---|
9758 | | - if (unlikely(err)) { |
---|
9759 | | - WL_ERR(("nla_put_u8 WIFI_TWT_ATTR_NOTIFICATION failed\n")); |
---|
9760 | | - goto fail; |
---|
9761 | | - } |
---|
9762 | | - |
---|
9763 | | -fail: |
---|
9764 | | - return err; |
---|
9765 | | -} |
---|
9766 | | - |
---|
9767 | | -s32 |
---|
9768 | | -wl_cfgvendor_notify_twt_event(struct bcm_cfg80211 *cfg, |
---|
9769 | | - bcm_struct_cfgdev *cfgdev, const wl_event_msg_t *e, void *data) |
---|
9770 | | -{ |
---|
9771 | | - struct sk_buff *skb = NULL; |
---|
9772 | | - gfp_t kflags; |
---|
9773 | | - struct wiphy *wiphy = bcmcfg_to_wiphy(cfg); |
---|
9774 | | - int err = BCME_OK; |
---|
9775 | | - struct net_device *ndev = bcmcfg_to_prmry_ndev(cfg); |
---|
9776 | | - const wl_twt_event_t *twt_event = (wl_twt_event_t *)data; |
---|
9777 | | - |
---|
9778 | | - kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL; |
---|
9779 | | - skb = CFG80211_VENDOR_EVENT_ALLOC(wiphy, ndev_to_wdev(ndev), |
---|
9780 | | - BRCM_TWT_HAL_VENDOR_EVENT_BUF_LEN, BRCM_VENDOR_EVENT_TWT, kflags); |
---|
9781 | | - if (!skb) { |
---|
9782 | | - WL_ERR(("skb alloc failed")); |
---|
9783 | | - err = BCME_NOMEM; |
---|
9784 | | - goto fail; |
---|
9785 | | - } |
---|
9786 | | - |
---|
9787 | | - switch (twt_event->event_type) { |
---|
9788 | | - case WL_TWT_EVENT_SETUP: |
---|
9789 | | - err = wl_cfgvendor_twt_update_setup_response(skb, |
---|
9790 | | - (void*)twt_event->event_info); |
---|
9791 | | - break; |
---|
9792 | | - case WL_TWT_EVENT_TEARDOWN: |
---|
9793 | | - err = wl_cfgvendor_twt_update_teardown_response(skb, |
---|
9794 | | - (void*)twt_event->event_info); |
---|
9795 | | - break; |
---|
9796 | | - case WL_TWT_EVENT_INFOFRM: |
---|
9797 | | - err = wl_cfgvendor_twt_update_infoframe_response(skb, |
---|
9798 | | - (void*)twt_event->event_info); |
---|
9799 | | - break; |
---|
9800 | | - case WL_TWT_EVENT_NOTIFY: |
---|
9801 | | - err = wl_cfgvendor_twt_update_notify_response(skb, |
---|
9802 | | - (void*)twt_event->event_info); |
---|
9803 | | - break; |
---|
9804 | | - default: |
---|
9805 | | - WL_ERR(("Invalid TWT sub event type %d", twt_event->event_type)); |
---|
9806 | | - err = BCME_UNSUPPORTED; |
---|
9807 | | - break; |
---|
9808 | | - } |
---|
9809 | | - |
---|
9810 | | - if (err) { |
---|
9811 | | - goto fail; |
---|
9812 | | - } |
---|
9813 | | - |
---|
9814 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
---|
9815 | | - cfg80211_vendor_event(skb, kflags); |
---|
9816 | | -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) */ |
---|
9817 | | - WL_ERR(("Successfully sent TWT vendor event type %d\n", twt_event->event_type)); |
---|
9818 | | - return BCME_OK; |
---|
9819 | | - |
---|
9820 | | -fail: |
---|
9821 | | - /* Free skb for failure cases */ |
---|
9822 | | - if (skb) { |
---|
9823 | | - kfree_skb(skb); |
---|
9824 | | - } |
---|
9825 | | - |
---|
9826 | | - return err; |
---|
9827 | | -} |
---|
9828 | | -#endif /* !WL_TWT && WL_TWT_HAL_IF */ |
---|
9829 | | - |
---|
9830 | 9045 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|
9831 | 9046 | const struct nla_policy andr_wifi_attr_policy[ANDR_WIFI_ATTRIBUTE_MAX] = { |
---|
9832 | 9047 | [ANDR_WIFI_ATTRIBUTE_NUM_FEATURE_SET] = { .type = NLA_U32 }, |
---|
.. | .. |
---|
10125 | 9340 | [DEBUG_ATTRIBUTE_PKT_FATE_DATA] = { .type = NLA_U64 }, |
---|
10126 | 9341 | [DEBUG_ATTRIBUTE_HANG_REASON] = { .type = NLA_BINARY }, |
---|
10127 | 9342 | }; |
---|
10128 | | - |
---|
10129 | | -#if !defined(WL_TWT) && defined(WL_TWT_HAL_IF) |
---|
10130 | | -const struct nla_policy andr_twt_attr_policy[ANDR_TWT_ATTR_MAX] = { |
---|
10131 | | - [ANDR_TWT_ATTR_NONE] = { .strict_start_type = 0 }, |
---|
10132 | | - [ANDR_TWT_ATTR_CONFIG_ID] = { .type = NLA_U8 }, |
---|
10133 | | - [ANDR_TWT_ATTR_NEGOTIATION_TYPE] = { .type = NLA_U8 }, |
---|
10134 | | - [ANDR_TWT_ATTR_TRIGGER_TYPE] = { .type = NLA_U8 }, |
---|
10135 | | - [ANDR_TWT_ATTR_WAKE_DURATION] = { .type = NLA_U32 }, |
---|
10136 | | - [ANDR_TWT_ATTR_WAKE_INTERVAL] = { .type = NLA_U32 }, |
---|
10137 | | - [ANDR_TWT_ATTR_WAKE_INTERVAL_MIN] = { .type = NLA_U32 }, |
---|
10138 | | - [ANDR_TWT_ATTR_WAKE_INTERVAL_MAX] = { .type = NLA_U32 }, |
---|
10139 | | - [ANDR_TWT_ATTR_WAKE_DURATION_MIN] = { .type = NLA_U32 }, |
---|
10140 | | - [ANDR_TWT_ATTR_WAKE_DURATION_MAX] = { .type = NLA_U32 }, |
---|
10141 | | - [ANDR_TWT_ATTR_AVG_PKT_SIZE] = { .type = NLA_U32 }, |
---|
10142 | | - [ANDR_TWT_ATTR_AVG_PKT_NUM] = { .type = NLA_U32 }, |
---|
10143 | | - [ANDR_TWT_ATTR_WAKETIME_OFFSET] = { .type = NLA_U32 }, |
---|
10144 | | - [ANDR_TWT_ATTR_ALL_TWT] = { .type = NLA_U8 }, |
---|
10145 | | - [ANDR_TWT_ATTR_RESUME_TIME] = { .type = NLA_U32 }, |
---|
10146 | | - [ANDR_TWT_ATTR_AVG_EOSP_DUR] = { .type = NLA_U32 }, |
---|
10147 | | - [ANDR_TWT_ATTR_EOSP_CNT] = { .type = NLA_U32 }, |
---|
10148 | | - [ANDR_TWT_ATTR_NUM_SP] = { .type = NLA_U32 }, |
---|
10149 | | - [ANDR_TWT_ATTR_DEVICE_CAP] = { .type = NLA_U32 }, |
---|
10150 | | - [ANDR_TWT_ATTR_PEER_CAP] = { .type = NLA_U32 }, |
---|
10151 | | - [ANDR_TWT_ATTR_STATUS] = { .type = NLA_U8 }, |
---|
10152 | | - [ANDR_TWT_ATTR_REASON_CODE] = { .type = NLA_U8 }, |
---|
10153 | | - [ANDR_TWT_ATTR_TWT_RESUMED] = { .type = NLA_U8 }, |
---|
10154 | | - [ANDR_TWT_ATTR_TWT_NOTIFICATION] = { .type = NLA_U8 }, |
---|
10155 | | - [ANDR_TWT_ATTR_SUB_EVENT] = { .type = NLA_U8 }, |
---|
10156 | | - [ANDR_TWT_ATTR_NUM_PEER_STATS] = { .type = NLA_U8 }, |
---|
10157 | | - [ANDR_TWT_ATTR_AVG_PKT_NUM_TX] = { .type = NLA_U32 }, |
---|
10158 | | - [ANDR_TWT_ATTR_AVG_PKT_SIZE_TX] = { .type = NLA_U32 }, |
---|
10159 | | - [ANDR_TWT_ATTR_AVG_PKT_NUM_RX] = { .type = NLA_U32 }, |
---|
10160 | | - [ANDR_TWT_ATTR_AVG_PKT_SIZE_RX] = { .type = NLA_U32 }, |
---|
10161 | | -}; |
---|
10162 | | -#endif /* !WL_TWT && WL_TWT_HAL_IF */ |
---|
10163 | | - |
---|
10164 | 9343 | #endif /* LINUX_VERSION >= 5.3 */ |
---|
10165 | 9344 | |
---|
10166 | 9345 | static struct wiphy_vendor_command wl_vendor_cmds [] = { |
---|
.. | .. |
---|
11087 | 10266 | #endif /* LINUX_VERSION >= 5.3 */ |
---|
11088 | 10267 | } |
---|
11089 | 10268 | #endif /* WL_SAR_TX_POWER */ |
---|
11090 | | -#if !defined(WL_TWT) && defined(WL_TWT_HAL_IF) |
---|
11091 | | - { |
---|
11092 | | - { |
---|
11093 | | - .vendor_id = OUI_GOOGLE, |
---|
11094 | | - .subcmd = ANDR_TWT_SUBCMD_SETUP |
---|
11095 | | - }, |
---|
11096 | | - .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
---|
11097 | | - .doit = wl_cfgvendor_twt_setup, |
---|
11098 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|
11099 | | - .policy = andr_twt_attr_policy, |
---|
11100 | | - .maxattr = ANDR_TWT_ATTR_MAX |
---|
11101 | | -#endif /* LINUX_VERSION >= 5.3 */ |
---|
11102 | | - }, |
---|
11103 | | - { |
---|
11104 | | - { |
---|
11105 | | - .vendor_id = OUI_GOOGLE, |
---|
11106 | | - .subcmd = ANDR_TWT_SUBCMD_TEARDOWN |
---|
11107 | | - }, |
---|
11108 | | - .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
---|
11109 | | - .doit = wl_cfgvendor_twt_teardown, |
---|
11110 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|
11111 | | - .policy = andr_twt_attr_policy, |
---|
11112 | | - .maxattr = ANDR_TWT_ATTR_MAX |
---|
11113 | | -#endif /* LINUX_VERSION >= 5.3 */ |
---|
11114 | | - }, |
---|
11115 | | - { |
---|
11116 | | - { |
---|
11117 | | - .vendor_id = OUI_GOOGLE, |
---|
11118 | | - .subcmd = ANDR_TWT_SUBCMD_INFO_FRAME |
---|
11119 | | - }, |
---|
11120 | | - .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
---|
11121 | | - .doit = wl_cfgvendor_twt_info_frame, |
---|
11122 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|
11123 | | - .policy = andr_twt_attr_policy, |
---|
11124 | | - .maxattr = ANDR_TWT_ATTR_MAX |
---|
11125 | | -#endif /* LINUX_VERSION >= 5.3 */ |
---|
11126 | | - }, |
---|
11127 | | - { |
---|
11128 | | - { |
---|
11129 | | - .vendor_id = OUI_GOOGLE, |
---|
11130 | | - .subcmd = ANDR_TWT_SUBCMD_GET_CAP |
---|
11131 | | - }, |
---|
11132 | | - .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
---|
11133 | | - .doit = wl_cfgvendor_twt_cap, |
---|
11134 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|
11135 | | - .policy = andr_twt_attr_policy, |
---|
11136 | | - .maxattr = ANDR_TWT_ATTR_MAX |
---|
11137 | | -#endif /* LINUX_VERSION >= 5.3 */ |
---|
11138 | | - }, |
---|
11139 | | - { |
---|
11140 | | - { |
---|
11141 | | - .vendor_id = OUI_GOOGLE, |
---|
11142 | | - .subcmd = ANDR_TWT_SUBCMD_GET_STATS |
---|
11143 | | - }, |
---|
11144 | | - .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
---|
11145 | | - .doit = wl_cfgvendor_twt_get_stats, |
---|
11146 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|
11147 | | - .policy = andr_twt_attr_policy, |
---|
11148 | | - .maxattr = ANDR_TWT_ATTR_MAX |
---|
11149 | | -#endif /* LINUX_VERSION >= 5.3 */ |
---|
11150 | | - }, |
---|
11151 | | - { |
---|
11152 | | - { |
---|
11153 | | - .vendor_id = OUI_GOOGLE, |
---|
11154 | | - .subcmd = ANDR_TWT_SUBCMD_CLR_STATS |
---|
11155 | | - }, |
---|
11156 | | - .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, |
---|
11157 | | - .doit = wl_cfgvendor_twt_clear_stats, |
---|
11158 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|
11159 | | - .policy = andr_twt_attr_policy, |
---|
11160 | | - .maxattr = ANDR_TWT_ATTR_MAX |
---|
11161 | | -#endif /* LINUX_VERSION >= 5.3 */ |
---|
11162 | | - }, |
---|
11163 | | -#endif /* !WL_TWT && WL_TWT_HAL_IF */ |
---|
11164 | 10269 | |
---|
11165 | 10270 | }; |
---|
11166 | 10271 | |
---|
.. | .. |
---|
11206 | 10311 | { OUI_BRCM, BRCM_VENDOR_EVENT_CU}, |
---|
11207 | 10312 | { OUI_BRCM, BRCM_VENDOR_EVENT_WIPS}, |
---|
11208 | 10313 | { OUI_GOOGLE, NAN_ASYNC_RESPONSE_DISABLED}, |
---|
11209 | | - { OUI_BRCM, BRCM_VENDOR_EVENT_RCC_INFO}, |
---|
11210 | | - {OUI_BRCM, BRCM_VENDOR_EVENT_TWT} |
---|
| 10314 | + { OUI_BRCM, BRCM_VENDOR_EVENT_RCC_INFO} |
---|
11211 | 10315 | }; |
---|
11212 | 10316 | |
---|
11213 | 10317 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) |
---|