Lines Matching full:p2p
18 #include "p2p.h"
22 /* parameters used for p2p escan */
47 #define P2P_VER 9 /* P2P version: 9=WiFi P2P v1.0 */
51 #define P2P_OUI "\x50\x6F\x9A" /* P2P OUI */
52 #define P2P_OUI_LEN 3 /* P2P OUI length */
71 /* WiFi P2P Public Action Frame OUI Subtypes */
75 #define P2P_PAF_INVITE_REQ 3 /* P2P Invitation Request */
76 #define P2P_PAF_INVITE_RSP 4 /* P2P Invitation Response */
83 /* WiFi P2P Action Frame OUI Subtypes */
85 #define P2P_AF_PRESENCE_REQ 1 /* P2P Presence Request */
86 #define P2P_AF_PRESENCE_RSP 2 /* P2P Presence Response */
89 /* P2P Service Discovery related */
114 * enum brcmf_p2p_disc_state - P2P discovery state values
116 * @WL_P2P_DISC_ST_SCAN: P2P discovery with wildcard SSID and P2P IE.
117 * @WL_P2P_DISC_ST_LISTEN: P2P discovery off-channel for specified time.
118 * @WL_P2P_DISC_ST_SEARCH: P2P discovery with P2P wildcard SSID and P2P IE.
127 * struct brcmf_p2p_scan_le - P2P specific scan request.
144 * struct brcmf_p2p_pub_act_frame - WiFi P2P Public Action Frame
165 * struct brcmf_p2p_action_frame - WiFi P2P Action Frame
213 * brcmf_p2p_is_pub_action() - true if p2p public type frame.
218 * Determine if action frame is p2p public action type
241 * brcmf_p2p_is_p2p_action() - true if p2p action type frame.
246 * Determine if action frame is p2p action type
268 * brcmf_p2p_is_gas_action() - true if p2p gas action type frame.
273 * Determine if action frame is p2p gas action type
305 * Print information about the p2p action frame
323 brcmf_dbg(TRACE, "%s P2P Group Owner Negotiation Req Frame\n", in brcmf_p2p_print_actframe()
327 brcmf_dbg(TRACE, "%s P2P Group Owner Negotiation Rsp Frame\n", in brcmf_p2p_print_actframe()
331 brcmf_dbg(TRACE, "%s P2P Group Owner Negotiation Confirm Frame\n", in brcmf_p2p_print_actframe()
335 brcmf_dbg(TRACE, "%s P2P Invitation Request Frame\n", in brcmf_p2p_print_actframe()
339 brcmf_dbg(TRACE, "%s P2P Invitation Response Frame\n", in brcmf_p2p_print_actframe()
343 brcmf_dbg(TRACE, "%s P2P Device Discoverability Request Frame\n", in brcmf_p2p_print_actframe()
347 brcmf_dbg(TRACE, "%s P2P Device Discoverability Response Frame\n", in brcmf_p2p_print_actframe()
351 brcmf_dbg(TRACE, "%s P2P Provision Discovery Request Frame\n", in brcmf_p2p_print_actframe()
355 brcmf_dbg(TRACE, "%s P2P Provision Discovery Response Frame\n", in brcmf_p2p_print_actframe()
359 brcmf_dbg(TRACE, "%s Unknown P2P Public Action Frame\n", in brcmf_p2p_print_actframe()
367 brcmf_dbg(TRACE, "%s P2P Notice of Absence Frame\n", in brcmf_p2p_print_actframe()
371 brcmf_dbg(TRACE, "%s P2P Presence Request Frame\n", in brcmf_p2p_print_actframe()
375 brcmf_dbg(TRACE, "%s P2P Presence Response Frame\n", in brcmf_p2p_print_actframe()
379 brcmf_dbg(TRACE, "%s P2P Discoverability Request Frame\n", in brcmf_p2p_print_actframe()
383 brcmf_dbg(TRACE, "%s Unknown P2P Action Frame\n", in brcmf_p2p_print_actframe()
391 brcmf_dbg(TRACE, "%s P2P GAS Initial Request\n", in brcmf_p2p_print_actframe()
395 brcmf_dbg(TRACE, "%s P2P GAS Initial Response\n", in brcmf_p2p_print_actframe()
399 brcmf_dbg(TRACE, "%s P2P GAS Comeback Request\n", in brcmf_p2p_print_actframe()
403 brcmf_dbg(TRACE, "%s P2P GAS Comeback Response\n", in brcmf_p2p_print_actframe()
407 brcmf_dbg(TRACE, "%s Unknown P2P GAS Frame\n", in brcmf_p2p_print_actframe()
440 * firmware for P2P device address. This must be done with discovery in brcmf_p2p_set_firmware()
454 * brcmf_p2p_generate_bss_mac() - derive mac addresses for P2P.
456 * @p2p: P2P specific data.
459 * P2P needs mac addresses for P2P device and interface. If no device
463 static void brcmf_p2p_generate_bss_mac(struct brcmf_p2p_info *p2p, u8 *dev_addr) in brcmf_p2p_generate_bss_mac() argument
465 struct brcmf_if *pri_ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; in brcmf_p2p_generate_bss_mac()
481 /* Generate the P2P Device Address obtaining a random ethernet in brcmf_p2p_generate_bss_mac()
485 eth_random_addr(p2p->dev_addr); in brcmf_p2p_generate_bss_mac()
487 memcpy(p2p->dev_addr, dev_addr, ETH_ALEN); in brcmf_p2p_generate_bss_mac()
490 p2p->dev_addr[0] |= 0x02; in brcmf_p2p_generate_bss_mac()
492 /* Generate the P2P Interface Address. If the discovery and connection in brcmf_p2p_generate_bss_mac()
494 * different from the P2P Device Address, but also locally administered. in brcmf_p2p_generate_bss_mac()
496 memcpy(p2p->conn_int_addr, p2p->dev_addr, ETH_ALEN); in brcmf_p2p_generate_bss_mac()
497 p2p->conn_int_addr[0] |= 0x02; in brcmf_p2p_generate_bss_mac()
498 p2p->conn_int_addr[4] ^= 0x80; in brcmf_p2p_generate_bss_mac()
500 memcpy(p2p->conn2_int_addr, p2p->dev_addr, ETH_ALEN); in brcmf_p2p_generate_bss_mac()
501 p2p->conn2_int_addr[0] |= 0x02; in brcmf_p2p_generate_bss_mac()
502 p2p->conn2_int_addr[4] ^= 0x90; in brcmf_p2p_generate_bss_mac()
506 * brcmf_p2p_scan_is_p2p_request() - is cfg80211 scan request a P2P scan.
511 * P2P wildcard ssid; otherwise returns false.
554 * brcmf_p2p_deinit_discovery() - disable P2P device discovery.
556 * @p2p: P2P specific data.
560 static s32 brcmf_p2p_deinit_discovery(struct brcmf_p2p_info *p2p) in brcmf_p2p_deinit_discovery() argument
567 vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif; in brcmf_p2p_deinit_discovery()
570 /* Disable P2P discovery in the firmware */ in brcmf_p2p_deinit_discovery()
571 vif = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif; in brcmf_p2p_deinit_discovery()
580 * @p2p: P2P specific data.
584 static int brcmf_p2p_enable_discovery(struct brcmf_p2p_info *p2p) in brcmf_p2p_enable_discovery() argument
586 struct brcmf_pub *drvr = p2p->cfg->pub; in brcmf_p2p_enable_discovery()
591 vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif; in brcmf_p2p_enable_discovery()
593 bphy_err(drvr, "P2P config device not available\n"); in brcmf_p2p_enable_discovery()
598 if (test_bit(BRCMF_P2P_STATUS_ENABLED, &p2p->status)) { in brcmf_p2p_enable_discovery()
599 brcmf_dbg(INFO, "P2P config device already configured\n"); in brcmf_p2p_enable_discovery()
603 /* Re-initialize P2P Discovery in the firmware */ in brcmf_p2p_enable_discovery()
604 vif = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif; in brcmf_p2p_enable_discovery()
610 vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif; in brcmf_p2p_enable_discovery()
619 * to ensure our P2P probe responses have the privacy bit in brcmf_p2p_enable_discovery()
629 set_bit(BRCMF_P2P_STATUS_ENABLED, &p2p->status); in brcmf_p2p_enable_discovery()
635 * brcmf_p2p_escan() - initiate a P2P scan.
637 * @p2p: P2P specific data.
640 * @search_state: P2P discover state to use.
641 * @bss_type: type of P2P bss.
643 static s32 brcmf_p2p_escan(struct brcmf_p2p_info *p2p, u32 num_chans, in brcmf_p2p_escan() argument
647 struct brcmf_pub *drvr = p2p->cfg->pub; in brcmf_p2p_escan()
664 vif = p2p->bss_idx[bss_type].vif; in brcmf_p2p_escan()
677 * because dongle use P2P WILDCARD internally by default, use in brcmf_p2p_escan()
685 * P2P WILDCARD because we just do broadcast scan unless in brcmf_p2p_escan()
702 * set p2p scan parameters. in brcmf_p2p_escan()
721 else if (brcmf_get_vif_state_any(p2p->cfg, BRCMF_VIF_STATUS_CONNECTED)) in brcmf_p2p_escan()
753 /* perform p2p scan on primary device */ in brcmf_p2p_escan()
756 set_bit(BRCMF_SCAN_STATUS_BUSY, &p2p->cfg->scan_status); in brcmf_p2p_escan()
769 * Determines the P2P discovery state based to scan request parameters and
776 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_run_escan() local
799 vif = p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif; in brcmf_p2p_run_escan()
808 brcmf_dbg(INFO, "P2P SEARCH PHASE START\n"); in brcmf_p2p_run_escan()
815 brcmf_dbg(INFO, "P2P SCAN STATE START\n"); in brcmf_p2p_run_escan()
819 * no P2P scanning on passive or DFS channels. in brcmf_p2p_run_escan()
828 chanspecs[i] = channel_to_chanspec(&p2p->cfg->d11inf, in brcmf_p2p_run_escan()
834 err = brcmf_p2p_escan(p2p, num_nodfs, chanspecs, search_state, in brcmf_p2p_run_escan()
851 * Scan ie for p2p ie and look for attribute 6 channel. If available determine
896 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_scan_prep() local
906 p2p->afx_hdl.my_listen_chan = err; in brcmf_p2p_scan_prep()
908 clear_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status); in brcmf_p2p_scan_prep()
909 brcmf_dbg(INFO, "P2P: GO_NEG_PHASE status cleared\n"); in brcmf_p2p_scan_prep()
911 err = brcmf_p2p_enable_discovery(p2p); in brcmf_p2p_scan_prep()
925 * @p2p: p2p device.
931 brcmf_p2p_discover_listen(struct brcmf_p2p_info *p2p, u16 channel, u32 duration) in brcmf_p2p_discover_listen() argument
933 struct brcmf_pub *drvr = p2p->cfg->pub; in brcmf_p2p_discover_listen()
938 vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif; in brcmf_p2p_discover_listen()
945 if (test_bit(BRCMF_P2P_STATUS_DISCOVER_LISTEN, &p2p->status)) { in brcmf_p2p_discover_listen()
953 p2p->cfg->d11inf.encchspec(&ch); in brcmf_p2p_discover_listen()
957 set_bit(BRCMF_P2P_STATUS_DISCOVER_LISTEN, &p2p->status); in brcmf_p2p_discover_listen()
958 p2p->remain_on_channel_cookie++; in brcmf_p2p_discover_listen()
979 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_remain_on_channel() local
987 err = brcmf_p2p_enable_discovery(p2p); in brcmf_p2p_remain_on_channel()
990 err = brcmf_p2p_discover_listen(p2p, channel_nr, duration); in brcmf_p2p_remain_on_channel()
994 memcpy(&p2p->remain_on_channel, channel, sizeof(*channel)); in brcmf_p2p_remain_on_channel()
995 *cookie = p2p->remain_on_channel_cookie; in brcmf_p2p_remain_on_channel()
1004 * brcmf_p2p_notify_listen_complete() - p2p listen has completed.
1016 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_notify_listen_complete() local
1020 &p2p->status)) { in brcmf_p2p_notify_listen_complete()
1022 &p2p->status)) { in brcmf_p2p_notify_listen_complete()
1024 &p2p->status); in brcmf_p2p_notify_listen_complete()
1026 complete(&p2p->wait_next_af); in brcmf_p2p_notify_listen_complete()
1030 p2p->remain_on_channel_cookie, in brcmf_p2p_notify_listen_complete()
1031 &p2p->remain_on_channel, in brcmf_p2p_notify_listen_complete()
1039 * brcmf_p2p_cancel_remain_on_channel() - cancel p2p listen state.
1056 * @p2p: p2p device.
1062 static s32 brcmf_p2p_act_frm_search(struct brcmf_p2p_info *p2p, u16 channel) in brcmf_p2p_act_frm_search() argument
1064 struct brcmf_pub *drvr = p2p->cfg->pub; in brcmf_p2p_act_frm_search()
1087 p2p->cfg->d11inf.encchspec(&ch); in brcmf_p2p_act_frm_search()
1093 p2p->cfg->d11inf.encchspec(&ch); in brcmf_p2p_act_frm_search()
1096 p2p->cfg->d11inf.encchspec(&ch); in brcmf_p2p_act_frm_search()
1099 p2p->cfg->d11inf.encchspec(&ch); in brcmf_p2p_act_frm_search()
1102 err = brcmf_p2p_escan(p2p, channel_cnt, default_chan_list, in brcmf_p2p_act_frm_search()
1119 struct brcmf_p2p_info *p2p = container_of(afx_hdl, in brcmf_p2p_afx_handler() local
1122 struct brcmf_pub *drvr = p2p->cfg->pub; in brcmf_p2p_afx_handler()
1130 err = brcmf_p2p_discover_listen(p2p, afx_hdl->my_listen_chan, in brcmf_p2p_afx_handler()
1133 err = brcmf_p2p_act_frm_search(p2p, afx_hdl->peer_listen_chan); in brcmf_p2p_afx_handler()
1138 &p2p->status)) in brcmf_p2p_afx_handler()
1147 * @p2p: p2p device info struct.
1150 static s32 brcmf_p2p_af_searching_channel(struct brcmf_p2p_info *p2p) in brcmf_p2p_af_searching_channel() argument
1152 struct afx_hdl *afx_hdl = &p2p->afx_hdl; in brcmf_p2p_af_searching_channel()
1158 pri_vif = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif; in brcmf_p2p_af_searching_channel()
1161 set_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status); in brcmf_p2p_af_searching_channel()
1180 &p2p->status))) in brcmf_p2p_af_searching_channel()
1194 &p2p->status))) in brcmf_p2p_af_searching_channel()
1210 clear_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status); in brcmf_p2p_af_searching_channel()
1227 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_scan_finding_common_channel() local
1228 struct afx_hdl *afx_hdl = &p2p->afx_hdl; in brcmf_p2p_scan_finding_common_channel()
1234 if (!test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status)) in brcmf_p2p_scan_finding_common_channel()
1276 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_abort_action_frame() local
1283 vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif; in brcmf_p2p_abort_action_frame()
1301 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_stop_wait_next_action_frame() local
1302 struct brcmf_if *ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; in brcmf_p2p_stop_wait_next_action_frame()
1305 if (test_bit(BRCMF_P2P_STATUS_SENDING_ACT_FRAME, &p2p->status) && in brcmf_p2p_stop_wait_next_action_frame()
1306 (test_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status) || in brcmf_p2p_stop_wait_next_action_frame()
1307 test_bit(BRCMF_P2P_STATUS_ACTION_TX_NOACK, &p2p->status))) { in brcmf_p2p_stop_wait_next_action_frame()
1312 if (p2p->af_sent_channel) { in brcmf_p2p_stop_wait_next_action_frame()
1320 &p2p->status)) { in brcmf_p2p_stop_wait_next_action_frame()
1331 * @p2p: p2p device info struct.
1337 brcmf_p2p_gon_req_collision(struct brcmf_p2p_info *p2p, u8 *mac) in brcmf_p2p_gon_req_collision() argument
1339 struct brcmf_cfg80211_info *cfg = p2p->cfg; in brcmf_p2p_gon_req_collision()
1344 if (!test_bit(BRCMF_P2P_STATUS_WAITING_NEXT_ACT_FRAME, &p2p->status) || in brcmf_p2p_gon_req_collision()
1345 !p2p->gon_req_action) in brcmf_p2p_gon_req_collision()
1354 ifp = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif->ifp; in brcmf_p2p_gon_req_collision()
1357 p2p->block_gon_req_tx = true; in brcmf_p2p_gon_req_collision()
1362 &p2p->status)) in brcmf_p2p_gon_req_collision()
1363 complete(&p2p->afx_hdl.act_frm_scan); in brcmf_p2p_gon_req_collision()
1365 &p2p->status)) in brcmf_p2p_gon_req_collision()
1391 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_notify_action_frame_rx() local
1392 struct afx_hdl *afx_hdl = &p2p->afx_hdl; in brcmf_p2p_notify_action_frame_rx()
1425 (brcmf_p2p_gon_req_collision(p2p, (u8 *)e->addr))) { in brcmf_p2p_notify_action_frame_rx()
1427 &p2p->status) && in brcmf_p2p_notify_action_frame_rx()
1441 brcmf_dbg(TRACE, "P2P: GO_NEG_PHASE status cleared\n"); in brcmf_p2p_notify_action_frame_rx()
1442 clear_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status); in brcmf_p2p_notify_action_frame_rx()
1449 if (test_bit(BRCMF_P2P_STATUS_WAITING_NEXT_ACT_FRAME, &p2p->status) && in brcmf_p2p_notify_action_frame_rx()
1450 (p2p->next_af_subtype == action)) { in brcmf_p2p_notify_action_frame_rx()
1453 &p2p->status); in brcmf_p2p_notify_action_frame_rx()
1498 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_notify_action_tx_complete() local
1505 if (!test_bit(BRCMF_P2P_STATUS_SENDING_ACT_FRAME, &p2p->status)) in brcmf_p2p_notify_action_tx_complete()
1511 &p2p->status); in brcmf_p2p_notify_action_tx_complete()
1512 if (!p2p->wait_for_offchan_complete) in brcmf_p2p_notify_action_tx_complete()
1513 complete(&p2p->send_af_done); in brcmf_p2p_notify_action_tx_complete()
1515 set_bit(BRCMF_P2P_STATUS_ACTION_TX_NOACK, &p2p->status); in brcmf_p2p_notify_action_tx_complete()
1523 complete(&p2p->send_af_done); in brcmf_p2p_notify_action_tx_complete()
1532 * @p2p: p2p info struct for vif.
1541 static s32 brcmf_p2p_tx_action_frame(struct brcmf_p2p_info *p2p, in brcmf_p2p_tx_action_frame() argument
1544 struct brcmf_pub *drvr = p2p->cfg->pub; in brcmf_p2p_tx_action_frame()
1551 reinit_completion(&p2p->send_af_done); in brcmf_p2p_tx_action_frame()
1552 clear_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status); in brcmf_p2p_tx_action_frame()
1553 clear_bit(BRCMF_P2P_STATUS_ACTION_TX_NOACK, &p2p->status); in brcmf_p2p_tx_action_frame()
1558 vif = p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif; in brcmf_p2p_tx_action_frame()
1560 vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif; in brcmf_p2p_tx_action_frame()
1569 p2p->af_sent_channel = le32_to_cpu(af_params->channel); in brcmf_p2p_tx_action_frame()
1570 p2p->af_tx_sent_jiffies = jiffies; in brcmf_p2p_tx_action_frame()
1572 if (test_bit(BRCMF_P2P_STATUS_DISCOVER_LISTEN, &p2p->status) && in brcmf_p2p_tx_action_frame()
1573 p2p->af_sent_channel == in brcmf_p2p_tx_action_frame()
1574 ieee80211_frequency_to_channel(p2p->remain_on_channel.center_freq)) in brcmf_p2p_tx_action_frame()
1575 p2p->wait_for_offchan_complete = false; in brcmf_p2p_tx_action_frame()
1577 p2p->wait_for_offchan_complete = true; in brcmf_p2p_tx_action_frame()
1580 (p2p->wait_for_offchan_complete) ? in brcmf_p2p_tx_action_frame()
1583 wait_for_completion_timeout(&p2p->send_af_done, P2P_AF_MAX_WAIT_TIME); in brcmf_p2p_tx_action_frame()
1585 if (test_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status)) { in brcmf_p2p_tx_action_frame()
1592 clear_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status); in brcmf_p2p_tx_action_frame()
1593 clear_bit(BRCMF_P2P_STATUS_ACTION_TX_NOACK, &p2p->status); in brcmf_p2p_tx_action_frame()
1613 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_pub_af_tx() local
1627 brcmf_dbg(TRACE, "P2P: GO_NEG_PHASE status set\n"); in brcmf_p2p_pub_af_tx()
1628 set_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status); in brcmf_p2p_pub_af_tx()
1631 p2p->next_af_subtype = act_frm->subtype + 1; in brcmf_p2p_pub_af_tx()
1632 p2p->gon_req_action = true; in brcmf_p2p_pub_af_tx()
1637 p2p->next_af_subtype = act_frm->subtype + 1; in brcmf_p2p_pub_af_tx()
1643 brcmf_dbg(TRACE, "P2P: GO_NEG_PHASE status cleared\n"); in brcmf_p2p_pub_af_tx()
1644 clear_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status); in brcmf_p2p_pub_af_tx()
1653 p2p->next_af_subtype = act_frm->subtype + 1; in brcmf_p2p_pub_af_tx()
1664 p2p->next_af_subtype = act_frm->subtype + 1; in brcmf_p2p_pub_af_tx()
1681 p2p->next_af_subtype = act_frm->subtype + 1; in brcmf_p2p_pub_af_tx()
1687 p2p->next_af_subtype = P2P_PAF_GON_REQ; in brcmf_p2p_pub_af_tx()
1693 bphy_err(drvr, "Unknown p2p pub act frame subtype: %d\n", in brcmf_p2p_pub_af_tx()
1722 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_send_action_frame() local
1726 struct afx_hdl *afx_hdl = &p2p->afx_hdl; in brcmf_p2p_send_action_frame()
1753 p2p->next_af_subtype = P2P_PAF_SUBTYPE_INVALID; in brcmf_p2p_send_action_frame()
1754 p2p->gon_req_action = false; in brcmf_p2p_send_action_frame()
1762 /* p2p public action frame process */ in brcmf_p2p_send_action_frame()
1766 bphy_err(drvr, "P2P Public action frame, unknown subtype.\n"); in brcmf_p2p_send_action_frame()
1778 p2p->next_af_subtype = action + 1; in brcmf_p2p_send_action_frame()
1805 &p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->sme_state)) in brcmf_p2p_send_action_frame()
1819 if (p2p->next_af_subtype != P2P_PAF_SUBTYPE_INVALID) { in brcmf_p2p_send_action_frame()
1821 set_bit(BRCMF_P2P_STATUS_WAITING_NEXT_ACT_FRAME, &p2p->status); in brcmf_p2p_send_action_frame()
1824 p2p->af_sent_channel = 0; in brcmf_p2p_send_action_frame()
1825 set_bit(BRCMF_P2P_STATUS_SENDING_ACT_FRAME, &p2p->status); in brcmf_p2p_send_action_frame()
1826 /* validate channel and p2p ies */ in brcmf_p2p_send_action_frame()
1829 p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif->saved_ie.probe_req_ie_len) { in brcmf_p2p_send_action_frame()
1830 afx_hdl = &p2p->afx_hdl; in brcmf_p2p_send_action_frame()
1833 if (brcmf_p2p_af_searching_channel(p2p) == in brcmf_p2p_send_action_frame()
1854 while (!p2p->block_gon_req_tx && in brcmf_p2p_send_action_frame()
1860 ack = !brcmf_p2p_tx_action_frame(p2p, af_params); in brcmf_p2p_send_action_frame()
1868 clear_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status); in brcmf_p2p_send_action_frame()
1872 clear_bit(BRCMF_P2P_STATUS_SENDING_ACT_FRAME, &p2p->status); in brcmf_p2p_send_action_frame()
1879 if (ack && config_af_params.extra_listen && !p2p->block_gon_req_tx && in brcmf_p2p_send_action_frame()
1880 test_bit(BRCMF_P2P_STATUS_WAITING_NEXT_ACT_FRAME, &p2p->status) && in brcmf_p2p_send_action_frame()
1881 p2p->af_sent_channel == afx_hdl->my_listen_chan) { in brcmf_p2p_send_action_frame()
1882 delta_ms = jiffies_to_msecs(jiffies - p2p->af_tx_sent_jiffies); in brcmf_p2p_send_action_frame()
1890 &p2p->status); in brcmf_p2p_send_action_frame()
1895 if (!brcmf_p2p_discover_listen(p2p, in brcmf_p2p_send_action_frame()
1896 p2p->af_sent_channel, in brcmf_p2p_send_action_frame()
1902 wait_for_completion_timeout(&p2p->wait_next_af, in brcmf_p2p_send_action_frame()
1906 &p2p->status); in brcmf_p2p_send_action_frame()
1910 if (p2p->block_gon_req_tx) { in brcmf_p2p_send_action_frame()
1914 p2p->block_gon_req_tx = false; in brcmf_p2p_send_action_frame()
1918 clear_bit(BRCMF_P2P_STATUS_WAITING_NEXT_ACT_FRAME, &p2p->status); in brcmf_p2p_send_action_frame()
1927 * brcmf_p2p_notify_rx_mgmt_p2p_probereq() - Event handler for p2p probe req.
1938 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_notify_rx_mgmt_p2p_probereq() local
1939 struct afx_hdl *afx_hdl = &p2p->afx_hdl; in brcmf_p2p_notify_rx_mgmt_p2p_probereq()
1959 if (test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status) && in brcmf_p2p_notify_rx_mgmt_p2p_probereq()
1972 /* Filter any P2P probe reqs arriving during the GO-NEG Phase */ in brcmf_p2p_notify_rx_mgmt_p2p_probereq()
1973 if (test_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status)) { in brcmf_p2p_notify_rx_mgmt_p2p_probereq()
1974 brcmf_dbg(INFO, "Filtering P2P probe_req in GO-NEG phase\n"); in brcmf_p2p_notify_rx_mgmt_p2p_probereq()
2003 * @p2p: P2P specific data.
2006 static void brcmf_p2p_get_current_chanspec(struct brcmf_p2p_info *p2p, in brcmf_p2p_get_current_chanspec() argument
2015 ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; in brcmf_p2p_get_current_chanspec()
2032 /* Use default channel for P2P */ in brcmf_p2p_get_current_chanspec()
2035 p2p->cfg->d11inf.encchspec(&ch); in brcmf_p2p_get_current_chanspec()
2040 * brcmf_p2p_ifchange - Change a P2P Role.
2048 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_ifchange() local
2057 vif = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif; in brcmf_p2p_ifchange()
2063 vif = p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif; in brcmf_p2p_ifchange()
2073 brcmf_p2p_get_current_chanspec(p2p, &chanspec); in brcmf_p2p_ifchange()
2077 memcpy(if_request.addr, p2p->conn_int_addr, sizeof(if_request.addr)); in brcmf_p2p_ifchange()
2101 static int brcmf_p2p_request_p2p_if(struct brcmf_p2p_info *p2p, in brcmf_p2p_request_p2p_if() argument
2110 brcmf_p2p_get_current_chanspec(p2p, &chanspec); in brcmf_p2p_request_p2p_if()
2146 * @p2p: P2P specific data.
2150 static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p, in brcmf_p2p_create_p2pdev() argument
2154 struct brcmf_pub *drvr = p2p->cfg->pub; in brcmf_p2p_create_p2pdev()
2161 if (p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif) in brcmf_p2p_create_p2pdev()
2164 p2p_vif = brcmf_alloc_vif(p2p->cfg, NL80211_IFTYPE_P2P_DEVICE); in brcmf_p2p_create_p2pdev()
2170 pri_ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; in brcmf_p2p_create_p2pdev()
2179 brcmf_p2p_generate_bss_mac(p2p, addr); in brcmf_p2p_create_p2pdev()
2180 brcmf_p2p_set_firmware(pri_ifp, p2p->dev_addr); in brcmf_p2p_create_p2pdev()
2182 brcmf_cfg80211_arm_vif_event(p2p->cfg, p2p_vif); in brcmf_p2p_create_p2pdev()
2185 /* Initialize P2P Discovery in the firmware */ in brcmf_p2p_create_p2pdev()
2190 brcmf_cfg80211_arm_vif_event(p2p->cfg, NULL); in brcmf_p2p_create_p2pdev()
2195 err = brcmf_cfg80211_wait_vif_event(p2p->cfg, BRCMF_E_IF_ADD, in brcmf_p2p_create_p2pdev()
2197 brcmf_cfg80211_arm_vif_event(p2p->cfg, NULL); in brcmf_p2p_create_p2pdev()
2207 p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = p2p_vif; in brcmf_p2p_create_p2pdev()
2208 memcpy(p2p_ifp->mac_addr, p2p->dev_addr, ETH_ALEN); in brcmf_p2p_create_p2pdev()
2209 memcpy(&p2p_vif->wdev.address, p2p->dev_addr, sizeof(p2p->dev_addr)); in brcmf_p2p_create_p2pdev()
2211 /* verify bsscfg index for P2P discovery */ in brcmf_p2p_create_p2pdev()
2220 init_completion(&p2p->send_af_done); in brcmf_p2p_create_p2pdev()
2221 INIT_WORK(&p2p->afx_hdl.afx_work, brcmf_p2p_afx_handler); in brcmf_p2p_create_p2pdev()
2222 init_completion(&p2p->afx_hdl.act_frm_scan); in brcmf_p2p_create_p2pdev()
2223 init_completion(&p2p->wait_next_af); in brcmf_p2p_create_p2pdev()
2241 if (!cfg->p2p.bss_idx[i].vif) { in brcmf_p2p_get_conn_idx()
2244 brcmf_err("Multi p2p not supported"); in brcmf_p2p_get_conn_idx()
2254 * brcmf_p2p_add_vif() - create a new P2P virtual interface.
2260 * @params: contains mac address for P2P device.
2289 return brcmf_p2p_create_p2pdev(&cfg->p2p, wiphy, in brcmf_p2p_add_vif()
2303 p2p_intf_addr = cfg->p2p.conn_int_addr; in brcmf_p2p_add_vif()
2305 p2p_intf_addr = cfg->p2p.conn2_int_addr; in brcmf_p2p_add_vif()
2310 err = brcmf_p2p_request_p2p_if(&cfg->p2p, ifp, in brcmf_p2p_add_vif()
2314 brcmf_err("request p2p interface failed\n"); in brcmf_p2p_add_vif()
2346 cfg->p2p.bss_idx[connidx].vif = vif; in brcmf_p2p_add_vif()
2347 /* Disable firmware roaming for P2P interface */ in brcmf_p2p_add_vif()
2350 /* set station timeout for p2p */ in brcmf_p2p_add_vif()
2362 * brcmf_p2p_del_vif() - delete a P2P virtual interface.
2370 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_del_vif() local
2376 brcmf_dbg(TRACE, "delete P2P vif\n"); in brcmf_p2p_del_vif()
2393 if (!p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif) in brcmf_p2p_del_vif()
2396 brcmf_p2p_deinit_discovery(p2p); in brcmf_p2p_del_vif()
2403 clear_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status); in brcmf_p2p_del_vif()
2404 brcmf_dbg(INFO, "P2P: GO_NEG_PHASE status cleared\n"); in brcmf_p2p_del_vif()
2428 if (vif == p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif) in brcmf_p2p_del_vif()
2429 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL; in brcmf_p2p_del_vif()
2430 if (vif == p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION2].vif) in brcmf_p2p_del_vif()
2431 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION2].vif = NULL; in brcmf_p2p_del_vif()
2442 brcmf_dbg(INFO, "P2P: device interface removed\n"); in brcmf_p2p_ifp_removed()
2445 cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL; in brcmf_p2p_ifp_removed()
2461 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_start_device() local
2467 err = brcmf_p2p_enable_discovery(p2p); in brcmf_p2p_start_device()
2477 struct brcmf_p2p_info *p2p = &cfg->p2p; in brcmf_p2p_stop_device() local
2485 if (p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif == vif) { in brcmf_p2p_stop_device()
2497 * brcmf_p2p_attach() - attach for P2P.
2500 * @p2pdev_forced: create p2p device interface at attach.
2505 struct brcmf_p2p_info *p2p; in brcmf_p2p_attach() local
2510 p2p = &cfg->p2p; in brcmf_p2p_attach()
2511 p2p->cfg = cfg; in brcmf_p2p_attach()
2514 p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif = pri_ifp->vif; in brcmf_p2p_attach()
2517 err_ptr = brcmf_p2p_create_p2pdev(p2p, NULL, NULL); in brcmf_p2p_attach()
2519 bphy_err(drvr, "P2P device creation failed.\n"); in brcmf_p2p_attach()
2523 p2p->p2pdev_dynamically = true; in brcmf_p2p_attach()
2529 * brcmf_p2p_detach() - detach P2P.
2531 * @p2p: P2P specific data.
2533 void brcmf_p2p_detach(struct brcmf_p2p_info *p2p) in brcmf_p2p_detach() argument
2537 vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif; in brcmf_p2p_detach()
2540 brcmf_p2p_deinit_discovery(p2p); in brcmf_p2p_detach()
2544 memset(p2p, 0, sizeof(*p2p)); in brcmf_p2p_detach()