# P2P
[LMAC]

P2P module. More...

Collaboration diagram for P2P:

## Data Structures
struct | p2p_noa_info_tag
| Structure containing all information linked with NoA. More...
struct | p2p_info_tag
| Information structure containing all information about a P2P link. More...
struct | p2p_env_tag
| P2P Global Environment. More...
## Defines
#define | P2P_NOA_CONTINUOUS_COUNTER (255)
| If the counter field of NOA attribute is equal to 255, the absence cycles shall repeat until cancel.
#define | P2P_INVALID_IDX (0xFF)
| Invalid P2P Information Structure Index.
#define | P2P_NOA_NB_MAX (2)
| Maximal number of concurrent NoA.
#define | P2P_NOA_TIMER_MARGIN (5000)
| Margin used to avoid to program NOA timer in the past (in us).
#define | P2P_ABSENCE_DUR_MIN (5000)
| Minimal absence duration we can consider (in us).
#define | P2P_BCN_RX_TO_DUR (5000)
| Beacon RX Timeout Duration (in us).
#define | P2P_OPPPS_MASK (0x80)
| Flag allowing to read OppPS subfield of CTWindow + OppPS field.
#define | P2P_CTWINDOW_MASK (0x7F)
| Flag allowing to read CTWindow subfield of CTWindow + OppPS field.
#define | P2P_SSID_WILDCARD ("DIRECT-")
| SSID Wildcard for a P2P Device.
#define | P2P_SSID_WILDCARD_LEN (7)
| Length of P2P SSID Wildcard.
## Enumerations
enum | p2p_noa_timer_status { P2P_NOA_TIMER_NOT_STARTED = 0, P2P_NOA_TIMER_WAIT_NEXT_ABS, P2P_NOA_TIMER_WAIT_END_ABS }
| NOA Timer (see struct p2p_info_tag) status. More...
enum | p2p_oppps_timer_status { P2P_OPPPS_TIMER_NOT_STARTED = 0, P2P_OPPPS_TIMER_WAIT_END_CTW, P2P_OPPPS_TIMER_WAIT_START_CTW }
| OppPS Timer (see struct p2p_info_tag) status. More...
enum | p2p_attribute_id { P2P_ATT_ID_STATUS = 0, P2P_ATT_ID_MINOR_REASON_CODE, P2P_ATT_ID_P2P_CAPABILITY, P2P_ATT_ID_P2P_DEVICE_ID, P2P_ATT_ID_GROUP_OWNER_INTENT, P2P_ATT_ID_CONFIG_TIMEOUT, P2P_ATT_ID_LISTEN_CHANNEL, P2P_ATT_ID_P2P_GROUP_BSSID, P2P_ATT_ID_EXT_LISTEN_TIMING, P2P_ATT_ID_INTENDED_P2P_IF_ADDR, P2P_ATT_ID_P2P_MANAGEABILITY, P2P_ATT_ID_CHANNEL_LIST, P2P_ATT_ID_NOTICE_OF_ABSENCE, P2P_ATT_ID_P2P_DEVICE_INFO, P2P_ATT_ID_P2P_GROUP_INFO, P2P_ATT_ID_P2P_GROUP_ID, P2P_ATT_ID_P2P_INTERFACE, P2P_ATT_ID_OPERATING_CHANNEL, P2P_ATT_ID_INVITATION_FLAGS, P2P_ATT_ID_VENDOR_SPEC = 221, P2P_ATT_ID_MAX = 255 }
| P2P Attribute ID definitions See wifi_p2p_technical_specification_v1.1.pdf 4.1.1 - P2P IE Format Table 6. More...
enum | p2p_role { P2P_ROLE_CLIENT = 0, P2P_ROLE_GO }
| P2P Role. More...
enum | p2p_bcn_upd_op { P2P_BCN_UPD_OP_NONE = 0, P2P_BCN_UPD_OP_NOA_ADD, P2P_BCN_UPD_OP_NOA_RMV, P2P_BCN_UPD_OP_NOA_UPD }
| Operation codes to be used in p2p_bcn_update_req structure. More...
enum | p2p_noa_type { P2P_NOA_TYPE_CONCURRENT, P2P_NOA_TYPE_NORMAL }
| Type of NoA. More...
## Functions
__INLINE void | p2p_go_noa_get_intv_cnt (struct p2p_noa_info_tag *noa)
| Compute the number of NOA absence periods before updating Start Time field in NOA attribute.
static void | p2p_cli_noa_cancel (struct p2p_noa_info_tag *noa)
| Cancel NOA procedure on P2P client side.
static uint32_t | p2p_local_2_peer_time (struct vif_info_tag *vif, uint32_t local_time)
| Convert local (P2P CLI) time to peer (P2P GO) time.
static uint32_t | p2p_peer_2_local_time (struct vif_info_tag *vif, uint32_t peer_time)
| Convert peer (P2P GO) time to local (P2P CLI) time.
static uint32_t | p2p_att_find (uint32_t ie_addr, uint16_t ie_total_len, uint8_t att_id)
| Look for specific attribute inside a provided information element (IE).
static void | p2p_goto_idle_cb (void)
| Callback called once system entered in IDLE state before peer device absence.
static bool | p2p_noa_wait_end_abs (struct p2p_info_tag *p2p, uint8_t *low_noa_count)
| Check if at least one NOA absence is currently in progress.
static void | p2p_update_noa_presence_date (struct p2p_info_tag *p2p)
| Update P2P GO next absence and presence date.
static void | p2p_update_go_ps_state (struct p2p_info_tag *p2p)
| Update Power Save status of the GO.
static void | p2p_noa_timer_prog (struct p2p_noa_info_tag *noa, uint32_t time)
| Program the NOA Timer for a given P2P entry.
static void | p2p_noa_timer_end (void *env)
| Function called upon NOA timer expiration.
static void | p2p_oppps_timer_end (void *env)
| Callback for Opportunistic Power Save timer.
static void | p2p_go_send_noa_upd_ind (struct p2p_info_tag *p2p, uint8_t noa_instance)
| Send a MM_P2P_NOA_UPD_IND to the host so that it can maintain a status about the NoA scheme currently applied locally.
static uint8_t | p2p_go_get_noa_inst (struct p2p_info_tag *p2p)
| Get the number of NOA timer currently configured.
static uint32_t | p2p_cli_noa_get_abs_time (struct p2p_noa_info_tag *noa, uint8_t vif_index, uint32_t start_time, uint32_t tsf_peer)
| A frame containing a Notice of Absence attribute can be received after the indicated start time.
static bool | p2p_cli_noa_start (struct p2p_noa_info_tag *noa, uint8_t vif_index, uint32_t start_time, uint32_t tsf_peer)
| Start NOA procedure on P2P client side.
static void | p2p_cli_noa_handle_att (uint8_t p2p_index, uint32_t a_noa_att, uint32_t tsf_peer)
| Handle the received NOA attribute.
void | p2p_init (void)
| Initialize the p2p module.
uint8_t | p2p_create (uint8_t vif_index, uint8_t role)
| Link a VIF entry with a P2P entry.
void | p2p_cancel (uint8_t p2p_index, bool vif_del)
| Release a P2P structure.
void | p2p_set_vif_state (struct vif_info_tag *vif, bool active)
| Update the P2P entry parameters when VIF state is updated.
bool | p2p_is_present (uint8_t p2p_index)
| Check GO device presence.
bool | p2p_go_get_next_NOA_date (struct vif_info_tag *vif, uint32_t *next_p2p_present, uint32_t *next_p2p_absent)
| Get next presence/absence date for a p2p GO interface.
uint32_t | p2p_go_get_next_noa_end_date (struct vif_info_tag *vif, uint8_t noa_inst)
| Get end of the next NOA iteration.
void | p2p_tbtt_handle (struct vif_info_tag *vif, uint32_t tbtt_time)
| Handle P2P operation to be performed on STA_TBBT or AP_TBBT event.
void | p2p_bcn_evt_handle (struct vif_info_tag *vif)
| Handle P2P operation to be performed on Beacon reception.
uint32_t | p2p_cli_bcn_check_noa (struct vif_info_tag *vif, struct rx_pbd *pyld_desc, struct rx_dmadesc *dma_hdrdesc)
| Look for P2P NOA Attribute inside a received beacon.
void | p2p_cli_handle_action (struct vif_info_tag *vif, uint32_t a_frame, uint16_t length, uint32_t rx_tsf)
| Look for P2P NOA Attribute inside a received action frame.
bool | p2p_go_check_ps_mode (void)
| Check P2P PS mode.
void | p2p_go_td_evt (uint8_t vif_index, uint8_t new_status)
| Handle update of Traffic status generated by the Traffic Detection module.
void | p2p_go_oppps_start (struct vif_info_tag *vif, uint8_t ctw)
| Start Opportunistic Power Save mode on P2P GO side.
void | p2p_go_oppps_stop (struct vif_info_tag *vif)
| Stop Opportunistic Power Save mode on P2P GO side.
void | p2p_go_ps_state_update (struct vif_info_tag *vif)
| Check if GO PS state has to be updated once it is known that a peer CLI device is entered in Doze mode (used if OppPS has been enabled).
uint8_t | p2p_go_noa_start (struct vif_info_tag *vif, bool concurrent, bool dyn_noa, uint8_t counter, uint32_t intv_us, uint32_t dur_us, uint32_t start_time)
| Start NOA procedure on P2P GO side.
uint8_t | p2p_go_noa_stop (struct vif_info_tag *vif, uint8_t noa_inst, bool host_req)
| Stop NOA procedure on P2P GO side.
void | p2p_go_noa_concurrent_move (struct vif_info_tag *vif, int32_t offset)
| Shift concurrent NOA with a given offset.
uint8_t | p2p_go_bcn_get_noa_len (uint8_t p2p_index)
| Return the additional length to consider in the beacon for the NOA attribute.
void | p2p_go_bcn_init_noa_pyld (uint32_t a_noa_ie_elt)
| Initialize an NOA attribute payload buffer (attribute ID, attribute length, .
void | p2p_go_bcn_upd_noa_pyld (uint8_t p2p_index, uint32_t a_noa_ie_elt)
| Trigger an update of the provided NOA attribute payload buffer.
void | p2p_go_bcn_op_done (uint8_t p2p_index, uint8_t operation)
| Callback to be used by mm_bcn module once operation required by p2p module has been done (ADD, REMOVE, UPDATE).
void | p2p_go_pre_tbtt (struct vif_info_tag *vif)
| When HW is in doze mode, it does not trigger the TBTT interrupt anymore.
## Variables
struct p2p_env_tag | p2p_env
| Global p2p status.
struct p2p_info_tag | p2p_info_tab [NX_P2P_VIF_MAX]
| Global table with all P2P entries.
struct p2p_env_tag | p2p_env
| Global p2p status.
struct p2p_info_tag | p2p_info_tab [NX_P2P_VIF_MAX]
| Global table with all P2P entries.
## P2P IE format
See wifi_p2p_technical_specification_v1.1.pdf: 4.1.1 - P2P IE Format Table 4
#define | P2P_IE_ID_OFT (0)
| P2P Element ID (Vendor Specific).
#define | P2P_IE_LEN_OFT (1)
| P2P Element ID (Vendor Specific).
#define | P2P_IE_OUI_OFT (2)
| P2P Element ID (Vendor Specific).
#define | P2P_IE_OUI_TYPE_OFT (5)
| P2P Element ID (Vendor Specific).
#define | P2P_IE_ATT_OFT (6)
| P2P Element ID (Vendor Specific).
#define | P2P_ELMT_ID (MAC_ELTID_OUI)
| P2P Element ID (Vendor Specific).
#define | P2P_OUI_WIFI_ALL_BYTE0 (0x50)
| OUI Value - Wi-FiAll.
#define | P2P_OUI_WIFI_ALL_BYTE1 (0x6F)
| P2P Element ID (Vendor Specific).
#define | P2P_OUI_WIFI_ALL_BYTE2 (0x9A)
| P2P Element ID (Vendor Specific).
#define | P2P_OUI_TYPE_P2P (9)
| Vendor Specific OUI Type for P2P.
## P2P Attribute format
See wifi_p2p_technical_specification_v1.1.pdf. 4.1.1 - General format of P2P attribute Table 5
#define | P2P_ATT_ID_OFT (0)
#define | P2P_ATT_LEN_OFT (1)
#define | P2P_ATT_BODY_OFT (3)
## Notice of Absence attribute format
See wifi_p2p_technical_specification_v1.1.pdf. 4.1.14 - Notice of Absence attribute Tables 26-27
#define | P2P_NOA_ATT_INDEX_OFT P2P_ATT_BODY_OFT
#define | P2P_NOA_ATT_CTW_OPPPS_OFT (4)
#define | P2P_NOA_ATT_NOA_DESC_OFT (5)
## Notice of Absence descriptor format
See wifi_p2p_technical_specification_v1.1.pdf. 4.1.14 - Notice of Absence attribute Tables 28
#define | P2P_NOA_DESC_COUNT_OFT (0)
#define | P2P_NOA_DESC_DUR_OFT (1)
#define | P2P_NOA_DESC_INTV_OFT (5)
#define | P2P_NOA_DESC_START_OFT (9)
#define | P2P_NOA_DESC_LENGTH (13)
#define | P2P_IE_NOA_NO_NOA_DESC_LENGTH (P2P_IE_ATT_OFT + P2P_NOA_ATT_NOA_DESC_OFT)
#define | P2P_NOA_IE_BUFFER_LEN ((P2P_IE_NOA_NO_NOA_DESC_LENGTH + (P2P_NOA_NB_MAX * P2P_NOA_DESC_LENGTH) + 1) / 2)

## Detailed Description

P2P module.

## Enumeration Type Documentation

enum p2p_attribute_id

P2P Attribute ID definitions See wifi_p2p_technical_specification_v1.1.pdf 4.1.1 - P2P IE Format Table 6.

Enumerator:

  P2P_ATT_ID_VENDOR_SPEC | 19 - 220 -> Reserved
  P2P_ATT_ID_MAX | 222 - 255 -> Reserved

Definition at line 156 of file p2p.h.

enum p2p_bcn_upd_op

Operation codes to be used in p2p_bcn_update_req structure.

Enumerator:

  P2P_BCN_UPD_OP_NONE | No Operation.
  P2P_BCN_UPD_OP_NOA_ADD | Add P2P NOA IE.
  P2P_BCN_UPD_OP_NOA_RMV | Remove P2P NOA IE.
  P2P_BCN_UPD_OP_NOA_UPD | Update P2P NOA IE.

Definition at line 193 of file p2p.h.

enum p2p_noa_timer_status

NOA Timer (see struct p2p_info_tag) status.

Enumerator:

  P2P_NOA_TIMER_NOT_STARTED | Timer not started.
  P2P_NOA_TIMER_WAIT_NEXT_ABS | Wait for next absence.
  P2P_NOA_TIMER_WAIT_END_ABS | Wait for end of absence.

Definition at line 130 of file p2p.h.

enum p2p_noa_type

Type of NoA.

Enumerator:

  P2P_NOA_TYPE_CONCURRENT | Concurrent NoA - Triggered by connection as STA on a different channel.
  P2P_NOA_TYPE_NORMAL | Normal NoA.

Definition at line 208 of file p2p.h.

enum p2p_oppps_timer_status

OppPS Timer (see struct p2p_info_tag) status.

Enumerator:

  P2P_OPPPS_TIMER_NOT_STARTED | Timer not started.
  P2P_OPPPS_TIMER_WAIT_END_CTW | Wait for end of CTWindow.
  P2P_OPPPS_TIMER_WAIT_START_CTW | Wait start of CTWindow.

Definition at line 141 of file p2p.h.

enum p2p_role

P2P Role.

Enumerator:

  P2P_ROLE_CLIENT | Client.
  P2P_ROLE_GO | GO.

Definition at line 184 of file p2p.h.

## Function Documentation

static uint32_t p2p_att_find | ( | uint32_t | ie_addr,
|  | uint16_t | ie_total_len,
|  | uint8_t | att_id |
| ) |  |  | `[static]`

Look for specific attribute inside a provided information element (IE).

For example, can be used to find Notice of Absence attribute inside P2P IE.

Parameters:

  `[in]` | ie_addr | IE Start Address
  `[in]` | ie_total_len | IE Total Length
  `[in]` | att_id | Attribute ID to look for

Returns:
  Start address of the attribute if found, else 0.

Definition at line 104 of file p2p.c.

References co_read16p(), and co_read8p().

void p2p_bcn_evt_handle | ( | struct vif_info_tag * | vif | ) |

Handle P2P operation to be performed on Beacon reception.

Parameters:

  `[in]` | vif | VIF Entry

Referenced by vif_mgmt_bcn_to_evt().

void p2p_cancel | ( | uint8_t | p2p_index,
|  | bool | vif_del |
| ) |  |  |

Release a P2P structure.

Parameters:

  `[in]` | p2p_index | P2P entry index
  `[in]` | vif_del | Indicate if the VIF will be unregistered.

uint32_t p2p_cli_bcn_check_noa | ( | struct vif_info_tag * | vif,
|  | struct rx_pbd * | pyld_desc,
|  | struct rx_dmadesc * | dma_hdrdesc |
| ) |  |  |

Look for P2P NOA Attribute inside a received beacon.

Start/Update/Stop the NOA procedure accordingly with received information.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | pyld_desc | Beacon Payload Descriptor
  `[in]` | dma_hdrdesc | Beacon Header Descriptor

Returns:
  address on the NOA Attribute IE. (0 if not present)

Referenced by rxl_frame_handle().

void p2p_cli_handle_action | ( | struct vif_info_tag * | vif,
|  | uint32_t | a_frame,
|  | uint16_t | length,
|  | uint32_t | rx_tsf |
| ) |  |  |

Look for P2P NOA Attribute inside a received action frame.

Start/Update/Stop the NOA procedure accordingly with received information.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | a_frame | Address of the frame (HW address)
  `[in]` | length | Length of the frame (bytes)
  `[in]` | rx_tsf | TSF when frame was received

Referenced by rxl_frame_handle().

static void p2p_cli_noa_cancel | ( | struct p2p_noa_info_tag * | noa | ) | `[static]`

Cancel NOA procedure on P2P client side.

Parameters:

  `[in]` | noa | NOA Entry

Definition at line 931 of file p2p.c.

References mm_timer_clear(), p2p_noa_info_tag::noa_inst, p2p_noa_info_tag::noa_status, p2p_noa_info_tag::noa_timer, p2p_noa_info_tag::p2p_index, p2p_info_tab, P2P_NOA_TIMER_NOT_STARTED, PROF_P2P_NOA_ABS_CLR, TRACE_P2P, and p2p_info_tag::vif_index.

Referenced by p2p_cli_noa_handle_att(), and p2p_noa_timer_end().

static uint32_t p2p_cli_noa_get_abs_time | ( | struct p2p_noa_info_tag * | noa,
|  | uint8_t | vif_index,
|  | uint32_t | start_time,
|  | uint32_t | tsf_peer |
| ) |  |  | `[static]`

A frame containing a Notice of Absence attribute can be received after the indicated start time.

Hence we have to compute how many absences have been missed since start time in order to properly program the next absence time.

Parameters:

  `[in]` | noa | NOA Entry
  `[in]` | vif_index | Vif index
  `[in]` | start_time | Start Time value read in the NOA attribute (4 lower bytes of TSF)
  `[in]` | tsf_peer | TSF value provided by the peer device

Returns:
  Peer device next absence time

Definition at line 833 of file p2p.c.

References co_min(), hal_machw_time_past(), vif_info_tag::index, p2p_noa_info_tag::noa_counter, p2p_noa_info_tag::noa_intv_us, P2P_NOA_CONTINUOUS_COUNTER, p2p_peer_2_local_time(), p2p_noa_info_tag::peer_next_noa_time, vif_info_tag::sta, TR_32, TRACE_P2P, vif_info_tag::u, and vif_info_tab.

Referenced by p2p_cli_noa_start().

static void p2p_cli_noa_handle_att | ( | uint8_t | p2p_index,
|  | uint32_t | a_noa_att,
|  | uint32_t | tsf_peer |
| ) |  |  | `[static]`

Handle the received NOA attribute.

Parameters:

  `[in]` | p2p_index | Index of the P2P entry for which NOA attribute has been found
  `[in]` | a_noa_att | Address of received NOA attribute
  `[in]` | tsf_peer | Peer TSF at Beacon Transmission

Definition at line 957 of file p2p.c.

References co_read16p(), co_read32p(), co_read8p(), p2p_info_tag::is_noa_bcn, p2p_info_tag::noa, p2p_noa_info_tag::noa_counter, p2p_noa_info_tag::noa_dur_us, p2p_info_tag::noa_index, p2p_noa_info_tag::noa_init_counter, p2p_noa_info_tag::noa_intv_us, p2p_info_tag::noa_nb, p2p_info_tag::oppps_ctw, p2p_cli_noa_cancel(), p2p_cli_noa_start(), P2P_CTWINDOW_MASK, p2p_info_tab, P2P_NOA_NB_MAX, P2P_OPPPS_MASK, p2p_update_go_ps_state(), TRACE_P2P, and p2p_info_tag::vif_index.

static bool p2p_cli_noa_start | ( | struct p2p_noa_info_tag * | noa,
|  | uint8_t | vif_index,
|  | uint32_t | start_time,
|  | uint32_t | tsf_peer |
| ) |  |  | `[static]`

Start NOA procedure on P2P client side.

Parameters:

  `[in]` | noa | NOA Entry
  `[in]` | vif_index | VIF index
  `[in]` | start_time | NOA Start Time value read in the received Beacon
  `[in]` | tsf_peer | Peer TSF at Beacon Transmission

Returns:
  True if NOA has been started, false otherwise.

Definition at line 904 of file p2p.c.

References p2p_noa_info_tag::noa_counter, p2p_noa_info_tag::noa_dur_us, p2p_noa_info_tag::noa_inst, p2p_noa_info_tag::noa_intv_us, p2p_noa_info_tag::noa_status, p2p_cli_noa_get_abs_time(), p2p_noa_timer_prog(), P2P_NOA_TIMER_WAIT_NEXT_ABS, TR_32, and TRACE_P2P.

Referenced by p2p_cli_noa_handle_att().

uint8_t p2p_create | ( | uint8_t | vif_index,
|  | uint8_t | role |
| ) |  |  |

Link a VIF entry with a P2P entry.

Parameters:

  `[in]` | vif_index | Index of the P2P VIF
  `[in]` | role | P2P Interface Role

Returns:
  P2P entry index if a P2P structure was available, else P2P_INVALID_IDX.

uint8_t p2p_go_bcn_get_noa_len | ( | uint8_t | p2p_index | ) |

Return the additional length to consider in the beacon for the NOA attribute.

If the NOA is not part of the sent beacon, the function return 0.

Parameters:

  `[in]` | p2p_index | P2P entry index

Returns:
  size, in bytes, for the NAO attribute

Referenced by mm_bcn_build().

void p2p_go_bcn_init_noa_pyld | ( | uint32_t | a_noa_ie_elt | ) |

Initialize an NOA attribute payload buffer (attribute ID, attribute length, .

..)

Parameters:

  `[in]` | a_noa_ie_elt | Address of a NOA attribute payload buffer

void p2p_go_bcn_op_done | ( | uint8_t | p2p_index,
|  | uint8_t | operation |
| ) |  |  |

Callback to be used by mm_bcn module once operation required by p2p module has been done (ADD, REMOVE, UPDATE).

Parameters:

  `[in]` | p2p_index | P2P entry index
  `[in]` | operation | Required operation

void p2p_go_bcn_upd_noa_pyld | ( | uint8_t | p2p_index,
|  | uint32_t | a_noa_ie_elt |
| ) |  |  |

Trigger an update of the provided NOA attribute payload buffer.

This function is called by the mm_bcn module once it is possible to update the data contained in the beacon after mm_bcn_update_p2p_noa is called.

Parameters:

  `[in]` | p2p_index | P2P entry index
  `[in]` | a_noa_ie_elt | Address of a NOA attribute payload buffer

bool p2p_go_check_ps_mode | ( | void |  | ) |

Check P2P PS mode.

Returns:
  True if only one VIF is active and this VIF is a P2P GO VIF with PS enabled and currently in a absence period.

Referenced by ps_sleep_check().

bool p2p_go_get_next_NOA_date | ( | struct vif_info_tag * | vif,
|  | uint32_t * | next_p2p_present,
|  | uint32_t * | next_p2p_absent |
| ) |  |  |

Get next presence/absence date for a p2p GO interface.

This function returns next absence/presence date for a GO interface based on its scheduled NOA. The date returned takes into account potential overlapping NOA, and they are always in the future (meaning that if this is currently an absence period then next_presence date will happen before next_absence date).

Note:
  The return value indicates if this is currently a presence or absence period from NOA point of view. It is not always the same status as returned by p2p_is_present (e.g. if TBTT happens during an absence period of a periodic NOA, then p2p_is_present will return true, but this function will return false).

Parameters:

  `[in]` | vif | Vif entry for the P2P GO interface.
  `[out]` | next_p2p_present | Date at witch next NOA ends
  `[out]` | next_p2p_absent | Date at witch next NOA starts

Returns:
  true if this is currently a presence period and false otherwise.

Referenced by chan_schedule_extra_switch_from_p2pgo_ctxt(), chan_schedule_extra_switch_to_p2pgo_ctxt(), chan_schedule_switch_from_p2pgo_ctxt(), and chan_schedule_switch_to_p2pgo_ctxt().

uint32_t p2p_go_get_next_noa_end_date | ( | struct vif_info_tag * | vif,
|  | uint8_t | noa_inst |
| ) |  |  |

Get end of the next NOA iteration.

Parameters:

  `[in]` | vif | Vif entry for the P2P interface
  `[in]` | noa_inst | Index of the NOA

Returns:
  timestamp, in us, of the end of the next absence period of the required NOA.

Referenced by chan_p2p_noa_resync_check(), and chan_start_p2pgo_single_noa().

static uint8_t p2p_go_get_noa_inst | ( | struct p2p_info_tag * | p2p | ) | `[static]`

Get the number of NOA timer currently configured.

Parameters:

  `[in]` | p2p | P2P Entry (necessarily a GO).

Returns:
  The number of NOA configured for the P2P entry

Definition at line 778 of file p2p.c.

References p2p_info_tag::noa, p2p_noa_info_tag::noa_status, P2P_NOA_NB_MAX, and P2P_NOA_TIMER_NOT_STARTED.

void p2p_go_noa_concurrent_move | ( | struct vif_info_tag * | vif,
|  | int32_t | offset |
| ) |  |  |

Shift concurrent NOA with a given offset.

It will shift the next iteration of all concurrent NOA with a given offset.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | offset | Offset to apply, in us.

Referenced by chan_p2p_noa_resync().

__INLINE void p2p_go_noa_get_intv_cnt | ( | struct p2p_noa_info_tag * | noa | ) |

Compute the number of NOA absence periods before updating Start Time field in NOA attribute.

Do nothing for non-recursive NOA

Parameters:

  `[in,out]` | noa | P2P NOA Entry, update the value of noa_time_upd_cnt

Definition at line 806 of file p2p.c.

References p2p_noa_info_tag::noa_intv_us, and p2p_noa_info_tag::noa_time_upd_cnt.

Referenced by p2p_noa_timer_end().

uint8_t p2p_go_noa_start | ( | struct vif_info_tag * | vif,
|  | bool | concurrent,
|  | bool | dyn_noa,
|  | uint8_t | counter,
|  | uint32_t | intv_us,
|  | uint32_t | dur_us,
|  | uint32_t | start_time |
| ) |  |  |

Start NOA procedure on P2P GO side.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | concurrent | Whether it is a concurent (P2P_NOA_TYPE_CONCURRENT) NOA or not (P2P_NOA_TYPE_NORMAL)
  `[in]` | dyn_noa | Indicate if NoA can be paused for traffic reason
  `[in]` | counter | Number of absense intervals
  `[in]` | intv_us | Length of the Notice of Absence interval (in us)
  `[in]` | dur_us | Duration of the absence (in us)
  `[in]` | start_time | Start time (TSF timer) of the NOA

Returns:
  Index of the NOA and P2P_INVALID_IDX if no NOA has been created.

Referenced by chan_start_p2pgo_noa(), chan_start_p2pgo_single_noa(), and mm_set_p2p_noa_req_handler().

uint8_t p2p_go_noa_stop | ( | struct vif_info_tag * | vif,
|  | uint8_t | noa_inst,
|  | bool | host_req |
| ) |  |  |

Stop NOA procedure on P2P GO side.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | noa_inst | NOA instance to be stopped
  `[in]` | host_req | Indicate if stop is request by host or not. Host is not allowed to stop a NoA started for concurrent mode reasons.

Returns:
  CO_OK if NAO has been stopped, CO_FAIL otherwise

Referenced by chan_stop_p2pgo_noa(), mm_set_p2p_noa_req_handler(), and p2p_noa_timer_end().

void p2p_go_oppps_start | ( | struct vif_info_tag * | vif,
|  | uint8_t | ctw |
| ) |  |  |

Start Opportunistic Power Save mode on P2P GO side.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | ctw | CTWindow

Referenced by mm_set_p2p_oppps_req_handler().

void p2p_go_oppps_stop | ( | struct vif_info_tag * | vif | ) |

Stop Opportunistic Power Save mode on P2P GO side.

Parameters:

  `[in]` | vif | VIF Entry

Referenced by mm_set_p2p_oppps_req_handler().

void p2p_go_pre_tbtt | ( | struct vif_info_tag * | vif | ) |

When HW is in doze mode, it does not trigger the TBTT interrupt anymore.

Hence we use a timer in order to wake up slightly before AP_TBTT occurs. This function is used as a callback for the TBTT timer

Parameters:

  `[in]` | vif | VIF Entry

void p2p_go_ps_state_update | ( | struct vif_info_tag * | vif | ) |

Check if GO PS state has to be updated once it is known that a peer CLI device is entered in Doze mode (used if OppPS has been enabled).

Parameters:

  `[in]` | vif | VIF Entry

Referenced by me_sta_add_req_handler(), and rxl_pm_check().

static void p2p_go_send_noa_upd_ind | ( | struct p2p_info_tag * | p2p,
|  | uint8_t | noa_instance |
| ) |  |  | `[static]`

Send a MM_P2P_NOA_UPD_IND to the host so that it can maintain a status about the NoA scheme currently applied locally.

Parameters:

  `[in]` | p2p | P2P Entry
  `[in]` | noa_instance | NoA Instance Updated

Definition at line 747 of file p2p.c.

References mm_p2p_noa_upd_ind::count, mm_p2p_noa_upd_ind::duration_us, mm_p2p_noa_upd_ind::interval_us, KE_MSG_ALLOC, ke_msg_send(), MM_P2P_NOA_UPD_IND, p2p_info_tag::noa, p2p_noa_info_tag::noa_dur_us, p2p_noa_info_tag::noa_init_counter, mm_p2p_noa_upd_ind::noa_inst_nb, p2p_noa_info_tag::noa_intv_us, p2p_noa_info_tag::noa_start_time, p2p_noa_info_tag::noa_status, p2p_noa_info_tag::noa_type, mm_p2p_noa_upd_ind::noa_type, P2P_NOA_TIMER_NOT_STARTED, mm_p2p_noa_upd_ind::start_time, TASK_MM, p2p_info_tag::vif_index, and mm_p2p_noa_upd_ind::vif_index.

void p2p_go_td_evt | ( | uint8_t | vif_index,
|  | uint8_t | new_status |
| ) |  |  |

Handle update of Traffic status generated by the Traffic Detection module.

When VIF is used for a P2P GO, it is used to stop/start NOA in order to increase the throughput if needed.

Parameters:

  `[in]` | vif_index | Index of the VIF entry for which the status has been updated
  `[in]` | new_status | New traffic status for the vif (td_status_bit)

void p2p_init | ( | void |  | ) |

Initialize the p2p module.

Set the vif_index value of each p2p structures to INVALID_VIF_IDX in order to inform that the structure is available.

bool p2p_is_present | ( | uint8_t | p2p_index | ) |

Check GO device presence.

Parameters:

  `[in]` | p2p_index | Index of the P2P entry

Returns:
  true if the GO device is present, false otherwise

Referenced by ps_uapsd_timer_handle().

static uint32_t p2p_local_2_peer_time | ( | struct vif_info_tag * | vif,
|  | uint32_t | local_time |
| ) |  |  | `[inline, static]`

Convert local (P2P CLI) time to peer (P2P GO) time.

Parameters:

  `[in]` | vif | Vif pointer for the P2P CLI interface
  `[in]` | local_time | Local time to convert

Returns:
  Local time converted in Peer time

Definition at line 71 of file p2p.c.

References ASSERT_ERR, vif_info_tag::sta, vif_info_tag::type, vif_info_tag::u, and VIF_STA.

Referenced by p2p_noa_timer_end().

static void p2p_noa_timer_end | ( | void * | env | ) | `[static]`

Function called upon NOA timer expiration.

Handle the timer state machine update and computation of next timer expiration time.

Parameters:

  `[in]` | env | P2P Entry for which timer was programmed.

Definition at line 565 of file p2p.c.

References ASSERT_ERR, hal_machw_time_cmp(), vif_info_tag::index, p2p_info_tag::is_noa_bcn, ke_time(), mm_bcn_update_p2p_noa(), p2p_noa_info_tag::noa_counter, p2p_noa_info_tag::noa_dur_us, p2p_noa_info_tag::noa_init_counter, p2p_noa_info_tag::noa_inst, p2p_noa_info_tag::noa_intv_us, p2p_noa_info_tag::noa_start_time, p2p_noa_info_tag::noa_status, p2p_noa_info_tag::noa_time_upd_cnt, p2p_noa_info_tag::noa_timer, P2P_BCN_UPD_OP_NOA_UPD, p2p_cli_noa_cancel(), p2p_go_noa_get_intv_cnt(), p2p_go_noa_stop(), p2p_noa_info_tag::p2p_index, p2p_info_tab, p2p_local_2_peer_time(), P2P_NOA_CONTINUOUS_COUNTER, P2P_NOA_TIMER_MARGIN, P2P_NOA_TIMER_NOT_STARTED, p2p_noa_timer_prog(), P2P_NOA_TIMER_WAIT_END_ABS, P2P_NOA_TIMER_WAIT_NEXT_ABS, p2p_peer_2_local_time(), P2P_ROLE_CLIENT, P2P_ROLE_GO, p2p_update_go_ps_state(), p2p_update_noa_presence_date(), p2p_noa_info_tag::peer_next_noa_time, vif_info_tag::prevent_sleep, PROF_P2P_NOA_ABS_CLR, PROF_P2P_NOA_ABS_SET, PS_VIF_P2P_GO_PRESENT, p2p_info_tag::role, mm_timer_tag::time, TRACE_P2P, vif_info_tag::type, VIF_AP, p2p_info_tag::vif_index, and vif_info_tab.

static void p2p_noa_timer_prog | ( | struct p2p_noa_info_tag * | noa,
|  | uint32_t | time |
| ) |  |  | `[static]`

Program the NOA Timer for a given P2P entry.

Call p2p_noa_timer_end function once timer expires.

Parameters:

  `[in]` | noa | P2P NOA Entry for which the timer is programmed
  `[in]` | time | NOA Timer Expiration Time

Definition at line 549 of file p2p.c.

References mm_timer_set(), p2p_noa_info_tag::noa_inst, p2p_noa_info_tag::noa_timer, p2p_noa_info_tag::p2p_index, p2p_info_tab, TR_32, TRACE_P2P, and p2p_info_tag::vif_index.

Referenced by p2p_cli_noa_start(), and p2p_noa_timer_end().

static bool p2p_noa_wait_end_abs | ( | struct p2p_info_tag * | p2p,
|  | uint8_t * | low_noa_count |
| ) |  |  | `[static]`

Check if at least one NOA absence is currently in progress.

Also return the lowest NOA count.

Parameters:

  `[in]` | p2p | P2P Entry
  `[out]` | low_noa_count | Lower found NOA count value

Returns:
  true if at least NOA currently in its absence period is found, and false otherwise.

Definition at line 153 of file p2p.c.

References p2p_noa_info_tag::dyn_noa, p2p_info_tag::noa, p2p_noa_info_tag::noa_init_counter, p2p_info_tag::noa_paused, p2p_noa_info_tag::noa_status, p2p_noa_info_tag::noa_type, NX_P2P_GO, P2P_NOA_NB_MAX, P2P_NOA_TIMER_WAIT_END_ABS, and P2P_NOA_TYPE_NORMAL.

Referenced by p2p_update_go_ps_state().

static void p2p_oppps_timer_end | ( | void * | env | ) | `[static]`

Callback for Opportunistic Power Save timer.

Called when oppPS timer expire, for for P2P client interface. The timer is started after reception of the beacon, if the GO is advertising oppPS. The duration of the timer, aka the CTWindow, is given by the GO. At the end on the CTWindow the GO may enter power save mode, so it is necessary to update it status.

Parameters:

  `[in]` | env | P2P Entry for which timer was programmed.

Definition at line 716 of file p2p.c.

References mm_timer_set(), p2p_info_tag::oppps_ctw_end, p2p_info_tag::oppps_status, p2p_info_tag::oppps_timer, P2P_OPPPS_TIMER_NOT_STARTED, P2P_OPPPS_TIMER_WAIT_END_CTW, P2P_OPPPS_TIMER_WAIT_START_CTW, p2p_update_go_ps_state(), PROF_P2P_CTW_CLR, PROF_P2P_CTW_SET, TRACE_P2P, and p2p_info_tag::vif_index.

static uint32_t p2p_peer_2_local_time | ( | struct vif_info_tag * | vif,
|  | uint32_t | peer_time |
| ) |  |  | `[inline, static]`

Convert peer (P2P GO) time to local (P2P CLI) time.

Parameters:

  `[in]` | vif | Vif pointer for the P2P CLI interface
  `[in]` | peer_time | Peer time to convert

Returns:
  Peer time converted in Local time

Definition at line 86 of file p2p.c.

References ASSERT_ERR, vif_info_tag::sta, vif_info_tag::type, vif_info_tag::u, and VIF_STA.

Referenced by p2p_cli_noa_get_abs_time(), and p2p_noa_timer_end().

void p2p_set_vif_state | ( | struct vif_info_tag * | vif,
|  | bool | active |
| ) |  |  |

Update the P2P entry parameters when VIF state is updated.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | active | Boolean value indicating if VIF is active or not

Referenced by mm_set_vif_state_req_handler().

void p2p_tbtt_handle | ( | struct vif_info_tag * | vif,
|  | uint32_t | tbtt_time |
| ) |  |  |

Handle P2P operation to be performed on STA_TBBT or AP_TBBT event.

Parameters:

  `[in]` | vif | VIF Entry
  `[in]` | tbtt_time | Timestamp of TBTT. It doesn't include any margin.

Referenced by mm_ap_tbtt().

static void p2p_update_go_ps_state | ( | struct p2p_info_tag * | p2p | ) | `[static]`

Update Power Save status of the GO.

Update the Power Save status of the GO in the P2P connection. This function can be called on the client or the GO interface.

Parameters:

  `[in]` | p2p | P2P Entry for which power state must be updated.

Definition at line 379 of file p2p.c.

References AC_BCN, vif_info_tag::ap, mm_force_idle_req::cb, vif_info_tag::chan_ctxt, chan_p2p_absence_update(), DESC_DONE_SW_TX_BIT, GLOBAL_INT_DISABLE, GLOBAL_INT_RESTORE, p2p_info_tag::is_go_present, p2p_info_tag::is_waiting_bcn, KE_MSG_ALLOC, ke_msg_send(), mm_bcn_transmitting(), MM_FORCE_IDLE_REQ, MM_P2P_VIF_PS_CHANGE_IND, p2p_info_tag::oppps_ctw, p2p_info_tag::oppps_status, p2p_goto_idle_cb(), vif_info_tag::p2p_link_nb, p2p_noa_wait_end_abs(), P2P_OPPPS_TIMER_WAIT_END_CTW, P2P_ROLE_CLIENT, P2P_ROLE_GO, vif_info_tag::prevent_sleep, ps_env_tag::prevent_sleep, PROF_P2P_ABSENCE_CLR, PROF_P2P_ABSENCE_SET, ps_env, PS_MODE_OFF, PS_MODE_ON, ps_env_tag::ps_on, ps_p2p_absence_update(), PS_PSM_PAUSED, mm_p2p_vif_ps_change_ind::ps_state, PS_VIF_P2P_GO_PRESENT, p2p_info_tag::role, TASK_MM, TRACE_P2P, txl_cntrl_flush_ac(), txl_cntrl_halt_ac(), vif_info_tag::type, vif_info_tag::u, VIF_AP, mm_p2p_vif_ps_change_ind::vif_index, p2p_info_tag::vif_index, vif_info_tab, and vif_mgmt_send_postponed_frame().

Referenced by p2p_cli_noa_handle_att(), p2p_noa_timer_end(), and p2p_oppps_timer_end().

static void p2p_update_noa_presence_date | ( | struct p2p_info_tag * | p2p | ) | `[static]`

Update P2P GO next absence and presence date.

Using NOA configured, this function updates the date of the next absence and presence of the p2p GO interface. This function is called when NOA is started/stopped or when NOA status is updated.

Parameters:

  `[in]` | p2p | P2P Entry

Definition at line 190 of file p2p.c.

References ASSERT_WARN, p2p_noa_info_tag::dyn_noa, hal_machw_time_cmp(), p2p_info_tag::next_absent, p2p_info_tag::next_present, p2p_info_tag::noa, p2p_noa_info_tag::noa_counter, p2p_noa_info_tag::noa_dur_us, p2p_noa_info_tag::noa_intv_us, p2p_info_tag::noa_paused, p2p_noa_info_tag::noa_status, p2p_noa_info_tag::noa_timer, p2p_noa_info_tag::noa_type, NX_P2P_GO, P2P_NOA_NB_MAX, P2P_NOA_TIMER_WAIT_END_ABS, P2P_NOA_TIMER_WAIT_NEXT_ABS, P2P_NOA_TYPE_NORMAL, and mm_timer_tag::time.

Referenced by p2p_noa_timer_end().