# VIF_MGMT
[LMAC]

Virtual interfaces Management. More...

Collaboration diagram for VIF_MGMT:

## Data Structures
struct | vif_info_tag
| VIF Info Table. More...
struct | vif_mgmt_env_tag
| VIF management module environment. More...
## Defines
#define | VIF_MGMT_BCN_TO_DUR (10000)
| Duration before a Timeout is raised when waiting for a beacon.
#define | INVALID_VIF_IDX 0xFF
| Macro defining an invalid VIF index.
#define | VIF_UNDEF_POWER 0x7F
| Macro defining an unknown tx power.
## Enumerations
enum | VIF_AP_BCMC_STATUS { VIF_AP_BCMC_BUFFERED = CO_BIT(0), VIF_AP_BCMC_MOREDATA = CO_BIT(1) }
| Bitfield for Broadcast/Multicast traffic status. More...
## Functions
static void | vif_mgmt_bcn_to_evt (void *env)
| Handles the action to be performed just before beacon reception.
static void | vif_mgmt_entry_init (struct vif_info_tag *vif)
| Initializes (resets) the content of a VIF entry.
void | vif_mgmt_init (void)
| Initialize all the entries of the station table.
void | vif_mgmt_reset (void)
| Tries to send all the internal frames postponed during a reset procedure once the TX path has been fully reset.
uint8_t | vif_mgmt_register (struct mac_addr const *mac_addr, uint8_t vif_type, bool p2p, uint8_t *vif_idx)
| Allocates new VIF entry, initializes it and fills it with information passed as parameters.
void | vif_mgmt_unregister (uint8_t vif_idx)
| Deletes the VIF entry.
void | vif_mgmt_add_key (struct mm_key_add_req const *param, uint8_t hw_key_idx)
| Add a key for a VIF.
void | vif_mgmt_del_key (struct vif_info_tag *vif, uint8_t keyid)
| delete a key for a VIF
uint8_t | vif_mgmt_get_staid (const struct vif_info_tag *vif, const struct mac_addr *sta_addr)
| Return IDX of a STA linked to the vif.
void | vif_mgmt_send_postponed_frame (struct vif_info_tag *vif)
| Try to send TX frame whose transmission had been postponed due to bad current channel and peer absence.
void | vif_mgmt_bcn_to_prog (struct vif_info_tag *vif)
| Program TimeOut for beacon reception.
void | vif_mgmt_bcn_recv (struct vif_info_tag *vif)
| Update Channel status after reception of BEACON.
void | vif_mgmt_set_ap_bcn_int (struct vif_info_tag *vif, uint16_t bcn_int)
| Set the Beacon Interval value for an AP or a Mesh Point VIF (should have been verified before any call to this function).
void | vif_mgmt_switch_channel (struct vif_info_tag *vif)
| Execute Channel switch at the end of a CSA.
struct vif_info_tag * | vif_mgmt_get_single_sta_vif (void)
| Check if only one VIF is registered, and is of STA type.
void | vif_mgmt_set_bssid_mask (void)
| Set BSSID mask according to BSSID index and Maximum BSSID indicator.
__INLINE int | vif_mgmt_used_cnt (void)
| Get the current number of used VIFs.
__INLINE struct vif_info_tag * | vif_mgmt_first_used (void)
| Get the pointer to the first VIF in the used list.
__INLINE struct vif_info_tag * | vif_mgmt_next (struct vif_info_tag *vif)
| Get the pointer to the next VIF following the one passed as parameter.
__INLINE uint8_t | vif_mgmt_get_type (uint8_t vif_idx)
| Return the type of the VIF the index of which is passed as parameter.
__INLINE uint8_t | vif_mgmt_get_band (struct vif_info_tag *vif)
| Return band of the channel used by a vif.
__INLINE int | vif_mgmt_get_txtype (struct vif_info_tag *vif)
| Return TX type to used to send frame on this vif.
__INLINE struct mac_addr * | vif_mgmt_get_addr (uint8_t vif_idx)
| Get VIF MAC address.
## Variables
struct vif_mgmt_env_tag | vif_mgmt_env
| VIF management environment variable.
struct vif_info_tag | vif_info_tab [NX_VIRT_DEV_MAX]
| VIF information table.
struct vif_mgmt_env_tag | vif_mgmt_env
| VIF management environment variable.
struct vif_info_tag | vif_info_tab [NX_VIRT_DEV_MAX]
| VIF information table.

## Detailed Description

Virtual interfaces Management.

## Enumeration Type Documentation

enum VIF_AP_BCMC_STATUS

Bitfield for Broadcast/Multicast traffic status.

Enumerator:

  VIF_AP_BCMC_BUFFERED | BCMC traffic buffered.
  VIF_AP_BCMC_MOREDATA | Last BCMC traffic has been sent with more_data flag set.

Definition at line 69 of file vif_mgmt.h.

## Function Documentation

void vif_mgmt_add_key | ( | struct mm_key_add_req const * | param,
|  | uint8_t | hw_key_idx |
| ) |  |  |

Add a key for a VIF.

Parameters:

  `[in]` | param | Pointer to the key parameters.
  `[in]` | hw_key_idx | Index of the key in the HW key RAM

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

Update Channel status after reception of BEACON.

This function is called after reception of BEACON by a STA interface. If will clear the timer started by vif_mgmt_bcn_to_prog and called the corresponding callback vif_mgmt_bcn_to_evt. If Power Save is enabled but the VIF is not currently in power save mode, this function will do nothing and callback will only be called when timer expires.

Parameters:

  `[in]` | vif | Pointer to the VIF structure

Referenced by rxl_frame_handle().

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

Handles the action to be performed just before beacon reception.

Parameters:

  `[in]` | env | Pointer to the VIF environment variables

Definition at line 78 of file vif_mgmt.c.

References chan_bcn_to_evt(), vif_info_tag::chan_ctxt, vif_info_tag::p2p, and p2p_bcn_evt_handle().

Referenced by vif_mgmt_entry_init().

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

Program TimeOut for beacon reception.

This function programs a timer that will expire if a beacon is not received by the VIF after VIF_MGMT_BCN_TO_DUR. Only used for STA VIF.

Parameters:

  `[in]` | vif | Pointer to the VIF structure

Referenced by mm_ap_tbtt().

void vif_mgmt_del_key | ( | struct vif_info_tag * | vif,
|  | uint8_t | keyid |
| ) |  |  |

delete a key for a VIF

Parameters:

  `[in]` | vif | Pointer to the VIF structure
  `[in]` | keyid | Key index

static void vif_mgmt_entry_init | ( | struct vif_info_tag * | vif | ) | `[static]`

Initializes (resets) the content of a VIF entry.

Parameters:

  `[in]` | vif | A pointer to the VIF entry to reset

Definition at line 105 of file vif_mgmt.c.

References mm_timer_tag::cb, mm_timer_tag::env, vif_info_tag::tmr_bcn_to, vif_info_tag::tx_power, vif_info_tag::type, vif_info_tag::user_tx_power, vif_mgmt_bcn_to_evt(), VIF_UNDEF_POWER, and VIF_UNKNOWN.

__INLINE struct vif_info_tag* vif_mgmt_first_used | ( | void |  | ) | `[read]`

Get the pointer to the first VIF in the used list.

Returns:
  A pointer to the VIF instance

Definition at line 374 of file vif_mgmt.h.

References co_list_pick(), vif_mgmt_env_tag::used_list, and vif_mgmt_env.

Referenced by chan_notify_absence(), chan_notify_presence(), chan_p2p_noa_resync_check(), chan_start_p2pgo_noa(), chan_stop_p2pgo_noa(), chan_switch_channel(), and rxu_mgt_search_rx_vif().

__INLINE struct mac_addr* vif_mgmt_get_addr | ( | uint8_t | vif_idx | ) | `[read]`

Get VIF MAC address.

Parameters:

  `[in]` | vif_idx | VIF index

Returns:
  MAC address of the VIF

Definition at line 560 of file vif_mgmt.h.

References vif_info_tab.

Referenced by bfr_prep_bfr_poll(), and bfr_prep_ndpa().

__INLINE uint8_t vif_mgmt_get_band | ( | struct vif_info_tag * | vif | ) |

Return band of the channel used by a vif.

If channel contexts are not used, return band of the current channel.

Parameters:

  `[in]` | vif | Pointer to the vif structure

Returns:
  The band index, and PHY_BAND_MAX if no channel is associated to the vif

Definition at line 508 of file vif_mgmt.h.

References mac_chan_op::band, vif_info_tag::chan_ctxt, chan_ctxt_tag::channel, PHY_BAND_MAX, phy_get_channel(), PHY_INFO_BAND, and PHY_PRIM.

Referenced by mm_bcn_desc_prep(), and vif_mgmt_get_txtype().

struct vif_info_tag * vif_mgmt_get_single_sta_vif | ( | void |  | ) | `[read]`

Check if only one VIF is registered, and is of STA type.

Returns:
  A pointer to the VIF structure if available, NULL otherwise

uint8_t vif_mgmt_get_staid | ( | const struct vif_info_tag * | vif,
|  | const struct mac_addr * | sta_addr |
| ) |  |  |

Return IDX of a STA linked to the vif.

Parameters:

  `[in]` | vif | Pointer to the VIF structure
  `[in]` | sta_addr | MAC address of the STA

Returns:
  Index of the STA, and INVALID_STA_IDX if there no such STA linked to this VIF.

__INLINE int vif_mgmt_get_txtype | ( | struct vif_info_tag * | vif | ) |

Return TX type to used to send frame on this vif.

Select tx type based on the band used by the channel associated to the vif. If channel contexts are not used, select type based on band of current channel.

Parameters:

  `[in]` | vif | Pointer to the vif structure

Returns:
  TX_DEFAULT_24G or TX_DEFAULT_5G

Definition at line 533 of file vif_mgmt.h.

References ASSERT_ERR, vif_info_tag::p2p, PHY_BAND_2G4, PHY_BAND_MAX, TX_DEFAULT_24G, TX_DEFAULT_5G, and vif_mgmt_get_band().

Referenced by ps_send_pspoll(), txl_frame_send_null_frame(), txl_frame_send_qosnull_frame(), txl_frame_send_tdls_channel_switch_req_frame(), txl_frame_send_tdls_channel_switch_rsp_frame(), and txl_frame_send_tdls_peer_traffic_ind_frame().

__INLINE uint8_t vif_mgmt_get_type | ( | uint8_t | vif_idx | ) |

Return the type of the VIF the index of which is passed as parameter.

Parameters:

  `[in]` | vif_idx | Index of the VIF

Returns:
  The VIF type

Definition at line 478 of file vif_mgmt.h.

References vif_info_tag::type, and vif_info_tab.

__INLINE struct vif_info_tag* vif_mgmt_next | ( | struct vif_info_tag * | vif | ) | `[read]`

Get the pointer to the next VIF following the one passed as parameter.

Parameters:

  `[in]` | vif | Pointer to the current VIF instance

Returns:
  A pointer to the next VIF instance

Definition at line 389 of file vif_mgmt.h.

References co_list_next(), and vif_info_tag::list_hdr.

Referenced by chan_notify_absence(), chan_notify_presence(), chan_p2p_noa_resync_check(), chan_start_p2pgo_noa(), chan_stop_p2pgo_noa(), and mm_ap_tbtt().

uint8_t vif_mgmt_register | ( | struct mac_addr const * | mac_addr,
|  | uint8_t | vif_type,
|  | bool | p2p,
|  | uint8_t * | vif_idx |
| ) |  |  |

Allocates new VIF entry, initializes it and fills it with information passed as parameters.

Parameters:

  `[in]` | mac_addr | MAC address of the VIF
  `[in]` | vif_type | VIF type
  `[in]` | p2p | P2P Interface
  `[out]` | vif_idx | Pointer to the allocated VIF index

Returns:
  CO_OK if allocation was successful, CO_FAIL otherwise.

Referenced by mm_add_if_req_handler().

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

Try to send TX frame whose transmission had been postponed due to bad current channel and peer absence.

Parameters:

  `[in]` | vif | Pointer to the VIF environment structure

Referenced by chan_switch_channel(), and p2p_update_go_ps_state().

void vif_mgmt_set_ap_bcn_int | ( | struct vif_info_tag * | vif,
|  | uint16_t | bcn_int |
| ) |  |  |

Set the Beacon Interval value for an AP or a Mesh Point VIF (should have been verified before any call to this function).

It is also considered that the driver provides only beacon intervals whose value is a multiple of a previously provided beacon interval.

Parameters:

  `[in]` | vif | VIF Entry for which the Beacon Interval must be set
  `[in]` | bcn_int | Beacon Interval

Referenced by mm_set_beacon_int_req_handler().

void vif_mgmt_set_bssid_mask | ( | void |  | ) |

Set BSSID mask according to BSSID index and Maximum BSSID indicator.

The function checks if only one VIF is registered, of STA type and connected to a nonTransmitted BSSID.

Referenced by mm_set_vif_state_req_handler().

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

Execute Channel switch at the end of a CSA.

This function will take care of changing the channel for a specific vif (that is already active with a context channel). It will first unlink the current channel ctx, create a new channel ctxt (channel configuration is read from vif_info_tag.csa_channel) and link this new context. Once done: For STA: restart timer/counter for beacon For AP: stop beacon transmission until driver send the updated beacon

Parameters:

  `[in]` | vif | Pointer to the VIF structure

Referenced by mm_bcn_transmitted().

void vif_mgmt_unregister | ( | uint8_t | vif_idx | ) |

Deletes the VIF entry.

Parameters:

  `[in]` | vif_idx | Index of the VIF to be deleted.

Referenced by mm_remove_if_req_handler().

__INLINE int vif_mgmt_used_cnt | ( | void |  | ) |

Get the current number of used VIFs.

Returns:
  The number of used VIFs

Definition at line 360 of file vif_mgmt.h.

References vif_mgmt_env_tag::vif_ap_cnt, vif_mgmt_env, and vif_mgmt_env_tag::vif_sta_cnt.

Referenced by mm_set_bssid_req_handler().