# MM
[LMAC]

LMAC MAC Management module. More...

Collaboration diagram for MM:

## Data Structures
struct | antenna_diversity
| Antenna Diversity structure. More...
struct | mm_env_tag
| LMAC MAC Management Context. More...
## Modules
| MM_BCN

| LMAC Beacon Management module.
| MM_TASK

| LMAC Management module task.
| MM_TIMER

| LMAC MAC Management timer module.
## Defines
#define | MM_TBTT_EVT_MASK (KE_EVT_PRIMARY_TBTT_BIT | KE_EVT_SECONDARY_TBTT_BIT)
| Event mask of the TBTT kernel events.
#define | MM_BEACON_LOSS_THD 10
| Beacon loss threshold above which we consider the connection as lost.
#define | MM_KEEP_ALIVE_PERIOD (30 * 1000000)
| Periodicity of keep-alive NULL frame transmission.
#define | MM_TBTT_IRQ_MASK (NXMAC_IMP_PRI_DTIM_BIT | NXMAC_IMP_PRI_TBTT_BIT)
| Mask of the TBTT interrupts.
#define | MM_MAC_ADDR_MSK ((NX_VIRT_DEV_MAX - 1) << 8)
| Mask used for the MAC address compatibility checking.
#define | TXOP(limit)
| Macro returning the maximum duration of A-MPDUs according to the TXOP limit.
#define | TBTT_DELAY 400
| Wake up delay before TBTT is occurring.
#define | KEY_RAM_WR(key_idx, ctype, vif_idx, spp, usedefkey, clen)
| Write parameters to the key RAM.
#define | MM_TBTT_COMPUTE_MARGIN (CHAN_SWITCH_DELAY + 300)
| Margin taken when checking if the computed TBTT is not in the past.
#define | TASK_IND TASK_SM
| Task identifier used for transmission of indication from MM to UMAC.
#define | MM_DEFAULT_TX_POWER 15
| Default TX power to apply when no regulatory info is available.
#define | MM_DEFAULT_MAX_AMPDU_DURATION 150
| Maximum duration of an A-MPDU (in 32us units).
#define | MM_AP_CLK_ACCURACY 20
| Default peer device accuracy (in ppm).
#define | MM_RX_FILTER_MONITOR
| RX filter for monitoring mode (all packets allowed).
#define | MM_RX_FILTER_ACTIVE
| RX filter for active mode (i.e. not monitoring).
#define | MM_SEC_MAX_KEY_NBR 64
| Number of supported Default+Pairwise keys.
#define | MM_SEC_VLAN_COUNT 6
| Number of VLAN Id.
#define | MM_SEC_DEFAULT_KEY_COUNT (MAC_DEFAULT_KEY_COUNT * MM_SEC_VLAN_COUNT)
| Number of default keys.
#define | MM_SEC_DEFAULT_VIF_KEY_COUNT (MAC_DEFAULT_KEY_COUNT * NX_VIRT_DEV_MAX)
| Number of default keys for number of supported VIFs.
#define | MM_SEC_CTYPE_NULL 0
| NULL cipher.
#define | MM_SEC_CTYPE_WEP 1
| WEP (RC4) cipher.
#define | MM_SEC_CTYPE_TKIP 2
| TKIP cipher.
#define | MM_SEC_CTYPE_CCMP 3
| CCMP cipher.
#define | MM_SEC_CTYPE_WPI_SMS4 4
| WAPI (SMS4) cipher.
#define | MM_VIF_TO_KEY(key_idx, vif_idx) ((key_idx) + ((vif_idx) * MAC_DEFAULT_KEY_COUNT))
| Macro converting a default key index to its HW index in key memory.
#define | MM_STA_TO_KEY(sta_idx) ((sta_idx) + MM_SEC_DEFAULT_KEY_COUNT)
| Macro converting a STA index to the its HW pairwise key index in key memory.
#define | MM_MLINK_TO_KEY(key_idx, mlink_idx) (((NX_VIRT_DEV_MAX + mlink_idx) * MAC_DEFAULT_KEY_COUNT) + key_idx)
| Macro converting a Mesh Link Index and a key index to its HW index in key memory.
#define | MM_KEY_TO_STA(hw_key_idx) ((hw_key_idx) - MM_SEC_DEFAULT_KEY_COUNT)
| Macro converting HW pairwise key index (>= MAC_DEFAULT_KEY_COUNT) to a STA index.
#define | MM_KEY_TO_VIF(hw_key_idx) (((hw_key_idx) & ~(MAC_DEFAULT_KEY_COUNT - 1)) / MAC_DEFAULT_KEY_COUNT)
| Macro converting a hw_key_idx (< MAC_DEFAULT_KEY_COUNT) to the VIF index it corresponds.
#define | MM_KEY_TO_KEYID(hw_key_idx) ((hw_key_idx) & (MAC_DEFAULT_KEY_COUNT - 1))
| Macro converting a hw_key_idx (< MAC_DEFAULT_KEY_COUNT) to the default key id it corresponds.
#define | MM_KEY_TO_MLINK(hw_key_idx) (((hw_key_idx & ~(MAC_DEFAULT_KEY_COUNT - 1)) / MAC_DEFAULT_KEY_COUNT) - NX_VIRT_DEV_MAX)
| Macro converting a hw_key_idx (< MAC_DEFAULT_KEY_COUNT) to the Mesh Link index it corresponds.
#define | MM_SEC_MFP_KEY_COUNT (MAC_DEFAULT_MFP_KEY_COUNT - MAC_DEFAULT_KEY_COUNT)
| Number of MFP keys per VIF.
#define | MM_SEC_MAX_MFP_KEY_NBR MM_SEC_MAX_KEY_NBR + (MM_SEC_MFP_KEY_COUNT * MM_SEC_VLAN_COUNT)
| Maximum number of hardware key that can be defined when MFP is enabled.
#define | MM_VIF_TO_MFP_KEY(key_idx, vif_idx) ((((key_idx) - MAC_DEFAULT_KEY_COUNT) + ((vif_idx) * MM_SEC_MFP_KEY_COUNT)) + MM_SEC_MAX_KEY_NBR)
| Macro converting mfp key (0/1) and vif index to HW key index.
#define | MM_MFP_KEY_TO_VIF(hw_key_idx) (((hw_key_idx) - MM_SEC_MAX_KEY_NBR) / MM_SEC_MFP_KEY_COUNT)
| Macro converting a hw_key_idx, in range [MM_SEC_MAX_KEY_NBR MM_SEC_MAX_MFP_KEY_NBR], to the Vif Index it corresponds.
#define | MM_MFP_KEY_TO_KEYID(hw_key_idx) ((((hw_key_idx) - MM_SEC_MAX_KEY_NBR) & (MM_SEC_MFP_KEY_COUNT - 1)) + MAC_DEFAULT_KEY_COUNT)
| Macro converting a hw_key_idx, in range [MM_SEC_MAX_KEY_NBR MM_SEC_MAX_MFP_KEY_NBR], to the MFP key id it corresponds.
#define | MM_SEC_MAX_MESH_MFP_KEY_NBR (MM_SEC_MAX_MFP_KEY_NBR + (MM_SEC_MFP_KEY_COUNT * NX_REMOTE_STA_MAX))
| Maximum number of hardware key that can be defined when MESH and MFP are enabled.
#define | MM_STA_TO_MESH_MFP_KEY(key_idx, sta_idx) (MM_SEC_MAX_MFP_KEY_NBR + (MM_SEC_MFP_KEY_COUNT * sta_idx) + key_idx)
| Macro converting mfp key index (0/1) and sta index to HW key index.
#define | MM_MESH_MFP_KEY_TO_KEYID(hw_key_idx) ((hw_key_idx - MM_SEC_MAX_MFP_KEY_NBR) & (MM_SEC_MFP_KEY_COUNT - 1))
| Macro converting a hw_key_idx, in range [MM_SEC_MAX_MFP_KEY_NBR MM_SEC_MAX_MESH_MFP_KEY_NBR], to the MFP key id it corresponds.
#define | MM_PRE_AP_TBTT_DELAY_US (1000)
| Delay between call to tbtt_timer callback for AP VIFs and AP_TBTT.
#define | ANT_DIV_RSSI_THD (20)
| Antenna Diversity RSSI threshold.
#define | ANT_DIV_RSSI_GOLDEN_MIN (-55)
| Antenna Diversity RSSI golden range min.
#define | ANT_DIV_RSSI_GOLDEN_MAX (-20)
| Antenna Diversity RSSI golden range max.
#define | ANT_DIV_RSSI_STEP_CHANGE (5)
| Antenna Diversity RSSI step change.
#define | ANT_DIV_BEACON_LOSS_THD (3)
| Antenna Diversity beacon loss threshold.
#define | ANT_DIV_RSSI_RESET (-128)
| Antenna Diversity RSSI reset value.
#define | ANT_DIV_UPDATE_CNT_THD (100)
| Antenna Diversity update counter threshold.
## Enumerations
enum | { BA_AGMT_TX, BA_AGMT_RX }
| BA agreement types. More...
enum | { BA_AGMT_ESTABLISHED, BA_AGMT_ALREADY_EXISTS, BA_AGMT_DELETED, BA_AGMT_DOESNT_EXIST, BA_AGMT_NO_MORE_BA_AGMT, BA_AGMT_NOT_SUPPORTED }
| BA agreement related status. More...
enum | mm_features { MM_FEAT_BCN_BIT = 0, MM_FEAT_AUTOBCN_BIT, MM_FEAT_HWSCAN_BIT, MM_FEAT_CMON_BIT, MM_FEAT_MROLE_BIT, MM_FEAT_RADAR_BIT, MM_FEAT_PS_BIT, MM_FEAT_UAPSD_BIT, MM_FEAT_DPSM_BIT, MM_FEAT_AMPDU_BIT, MM_FEAT_AMSDU_BIT, MM_FEAT_CHNL_CTXT_BIT, MM_FEAT_REORD_BIT, MM_FEAT_P2P_BIT, MM_FEAT_P2P_GO_BIT, MM_FEAT_UMAC_BIT, MM_FEAT_VHT_BIT, MM_FEAT_BFMEE_BIT, MM_FEAT_BFMER_BIT, MM_FEAT_WAPI_BIT, MM_FEAT_MFP_BIT, MM_FEAT_MU_MIMO_RX_BIT, MM_FEAT_MU_MIMO_TX_BIT, MM_FEAT_MESH_BIT, MM_FEAT_TDLS_BIT, MM_FEAT_ANT_DIV_BIT, MM_FEAT_UF_BIT, MM_AMSDU_MAX_SIZE_BIT0, MM_AMSDU_MAX_SIZE_BIT1, MM_FEAT_MON_DATA_BIT, MM_FEAT_HE_BIT }
| Features supported by LMAC - Positions. More...
## Functions
static void | mm_key_ram_param_get (uint8_t cipher_suite, struct mac_sec_key const *key, uint8_t *ctype, uint8_t *clen)
| Compute the cType and cLen to be set to the key RAM depending on the Cipher and the key length.
static void | mm_ap_tbtt_move_cb (void *offset)
| Callback function called when the TBTT move can be performed.
void | mm_env_max_ampdu_duration_set (void)
| Set the maximum A-MPDU duration based on TXOP registers.
void | mm_env_init (void)
| MM Module mm_env_init routine.
void | mm_init (void)
| Initialize all MM related context and data etc.
void | mm_tbtt_compute (struct bcn_frame *bcn, uint16_t len, struct rx_hd *rhd, struct vif_info_tag *vif, struct sta_info_tag *sta, uint32_t tim)
| Configure tbtt_timer for next beacon.
static void | mm_ap_probe_cfm (void *env, uint32_t status)
| Callback function indicating the completion of the NULL frame transmission used to probe the AP in case we don't receive any more beacons.
static uint32_t | mm_compute_beacon_crc (struct bcn_frame *bcn, uint16_t len, uint32_t *tim)
| Function computing the CRC of the received beacon The function skips the information elements handled in the LMAC (such as the TIM).
bool | mm_check_beacon (struct rx_hd *rhd, struct vif_info_tag *vif, struct sta_info_tag *sta, uint32_t *tim)
| Function responsible for all the connection monitoring stuff.
void | mm_reset (void)
| MM Module reset function.
void | mm_active (void)
| Put the HW state to active.
void | mm_sta_tbtt (void *env)
| MM timer callback for the station TBTT handling.
static void | mm_ap_tbtt (uint32_t evt)
| Handler for KE_EVT_PRIMARY_TBTT and KE_EVT_SECONDARY_TBTT events for beaconning interfaces.
void | mm_ap_pre_tbtt (void *env)
| MM timer callback for the AP pre-TBTT handling.
void | mm_tbtt_evt (int dummy)
| Kernel event handler for the TBTT event.
uint8_t | mm_sec_machwaddr_wr (uint8_t sta_idx, uint8_t inst_nbr)
| Function to add a MAC address in the MAC HW key storage.
uint8_t | mm_sec_machwkey_wr (struct mm_key_add_req const *param)
| Function to write key in MAC HW.
void | mm_sec_machwkey_del (uint8_t hw_key_idx)
| Function to delete a key from the MAC HW.
void | mm_sec_machwaddr_del (uint8_t sta_idx)
| Function to delete a MAC address from the MAC HW key storage.
void | mm_hw_idle_evt (int dummy)
| Kernel event handler for the HW IDLE event.
void | mm_hw_info_set (struct mac_addr const *mac_addr)
| Setting of general HW info upon the first interface creation.
void | mm_hw_ap_info_set (void)
| Set the correct HW information for an AP.
void | mm_hw_ap_info_reset (void)
| Reset the HW information for an AP.
bool | mm_ba_agmt_tx_exists (uint8_t sta_idx, uint8_t tid)
| Simple check for existence of a BA agreement for a certain (STA, TID) pair (TX).
bool | mm_ba_agmt_rx_exists (uint8_t sta_idx, uint8_t tid)
| Simple check for existence of a BA agreement for a certain (STA, TID) pair (RX).
int32_t | mm_ap_tbtt_move (int32_t offset)
| Request to apply an offset (positive or negative) to the next TBTT.
void | mm_back_to_host_idle (void)
| Ask MM to switch back to IDLE state requested by the host (quit BYPASSED mode).
void | mm_force_idle_req (void)
| Force the HW to go to IDLE immediately.
void | mm_no_idle_start (void)
| Ask MM to disallow the switch to IDLE state.
void | mm_no_idle_stop (void)
| Ask MM to allow again the switch to IDLE state.
uint8_t | mm_sta_add (struct mm_sta_add_req const *param, uint8_t *sta_idx, uint8_t *hw_sta_idx)
| Add a station to the list of known stations.
void | mm_sta_del (uint8_t sta_idx)
| Delete a station from the list of known stations.
void | mm_send_connection_loss_ind (struct vif_info_tag *vif)
| Inform the host that connection has been lost with an AP.
void | mm_check_rssi (struct vif_info_tag *vif, int8_t rssi)
| Check RSSI level and inform the host if RSSI is decreased below the threshold or if it is increased above the threshold.
void | mm_send_pktloss_ind (struct vif_info_tag *vif, uint8_t sta_idx, uint32_t num_pkts)
| Send the MM_PKTLOSS_IND message to the host.
void | mm_send_csa_traffic_ind (uint8_t vif_index, bool enable)
| Send host message to stop (resp restarted) tx traffic because CSA is in progress (resp.
void | mm_ant_div_init (bool enable)
| Initialize the antenna diversity parameters.
void | mm_ant_div_switch_and_stop (void)
| Switch antenna, if no other active connections are set up and if the algorithm is enabled.
void | mm_ant_div_update (void)
| Update the status of the antenna switch flag.
void | mm_ant_div_restore (bool active)
| Update the number of active VIF and update accordingly the status of the antenna switch flag.
void | mm_ant_div_switch_antenna (void)
| Change the antenna connected to path_0, reset the update counter and request an update of the initial RSSI (case 1x1 station).
void | mm_ant_div_reset_rssi (uint8_t ant)
| Reset the current and the initial RSSI values in the antenna diversity structure for the requested antenna.
void | mm_ant_div_update_rssi (int8_t *rssi)
| Update the RSSI values for both antennas.
void | mm_ant_div_check (uint8_t beacon_loss_cnt)
| This function is called at each tbtt, it updates the counter of beacon periods without any antenna switch (2x2 station only) and it checks if the antenna connected to path_0 should be switched.
__INLINE void | mm_rx_filter_set (void)
| This function applies the RX filter requested by the UMAC and LMAC.
__INLINE void | mm_rx_filter_umac_set (uint32_t filter)
| This function sets the RX filter for the UMAC.
__INLINE void | mm_rx_filter_lmac_enable_set (uint32_t filter)
| This function enables some RX filter bits on the LMAC filter.
__INLINE void | mm_rx_filter_lmac_enable_clear (uint32_t filter)
| This function disables some RX filter bits on the LMAC filter.
__INLINE void | mm_ps_change_ind (uint8_t sta_idx, uint8_t ps_state)
| This function indicates a PS state change of a peer device to the upper layers.
__INLINE void | mm_traffic_req_ind (uint8_t sta_idx, uint8_t pkt_cnt, bool uapsd)
| This function requests some buffered packets to be transmitted.
__INLINE uint8_t | mm_get_golden_range_distance (int8_t rssi)
| This function calculates the distance of the RSSI from the golden range.
## Variables
struct mm_env_tag | mm_env
| Global data for maintaining BSS and STA information.
struct mm_env_tag | mm_env
| Global data for maintaining BSS and STA information.

## Detailed Description

LMAC MAC Management module.

## Define Documentation

#define KEY_RAM_WR | ( | key_idx,
|  | ctype,
|  | vif_idx,
|  | spp,
|  | usedefkey,
|  | clen |  | ) |

Value:

    {                                                                                        \
        nxmac_encr_cntrl_pack(0, 1, 0, 0, key_idx, ctype, vif_idx, spp, usedefkey, clen);    \
        while(nxmac_new_write_getf());                                                       \
    }

Write parameters to the key RAM.

Parameters:

  `[in]` | key_idx | Index of the key RAM entry to be written
  `[in]` | ctype | Encryption type
  `[in]` | vif_idx | Index of the VIF the key is belonging to
  `[in]` | spp | SPP parameter
  `[in]` | usedefkey | Flag indicating whether the default key shall be used for this entry
  `[in]` | clen | Flag indicating the key length

Definition at line 108 of file mm.c.

#define MM_KEEP_ALIVE_PERIOD (30 * 1000000)

Periodicity of keep-alive NULL frame transmission.

30s

Definition at line 77 of file mm.c.

#define MM_RX_FILTER_ACTIVE

Value:

    (NXMAC_ACCEPT_MULTICAST_BIT | NXMAC_ACCEPT_BROADCAST_BIT | \
                                 NXMAC_ACCEPT_MY_UNICAST_BIT | NXMAC_ACCEPT_PROBE_REQ_BIT | \
                                 NXMAC_ACCEPT_BEACON_BIT | NXMAC_ACCEPT_OTHER_MGMT_FRAMES_BIT | \
                                 NXMAC_ACCEPT_BAR_BIT | NXMAC_ACCEPT_BA_BIT |                \
                                 NXMAC_ACCEPT_DATA_BIT | NXMAC_ACCEPT_Q_DATA_BIT |           \
                                 NXMAC_ACCEPT_QO_S_NULL_BIT | NXMAC_ACCEPT_OTHER_DATA_FRAMES_BIT)

RX filter for active mode (i.e. not monitoring).

Definition at line 68 of file mm.h.

#define MM_RX_FILTER_MONITOR

Value:

    (0xFFFFFFFF & ~(NXMAC_ACCEPT_ERROR_FRAMES_BIT | NXMAC_EXC_UNENCRYPTED_BIT |                      \
                                                  NXMAC_EN_DUPLICATE_DETECTION_BIT))

RX filter for monitoring mode (all packets allowed).

Definition at line 63 of file mm.h.

#define TBTT_DELAY 400

Wake up delay before TBTT is occurring.

400us

Definition at line 91 of file mm.c.

#define TXOP | ( | limit |  | ) |

Value:

    (((limit)==0) || ((limit) > MM_DEFAULT_MAX_AMPDU_DURATION))?       \
                                      MM_DEFAULT_MAX_AMPDU_DURATION:(limit);

Macro returning the maximum duration of A-MPDUs according to the TXOP limit.

Definition at line 86 of file mm.c.

## Enumeration Type Documentation

anonymous enum

BA agreement types.

Enumerator:

  BA_AGMT_TX | BlockAck agreement for TX.
  BA_AGMT_RX | BlockAck agreement for RX.

Definition at line 191 of file mm.h.

anonymous enum

BA agreement related status.

Enumerator:

  BA_AGMT_ESTABLISHED | Correct BA agreement establishment.
  BA_AGMT_ALREADY_EXISTS | BA agreement already exists for STA+TID requested, cannot override it (should have been deleted first).
  BA_AGMT_DELETED | Correct BA agreement deletion.
  BA_AGMT_DOESNT_EXIST | BA agreement for the (STA, TID) doesn't exist so nothing to delete.
  BA_AGMT_NO_MORE_BA_AGMT | No more BA agreement can be added for the specified type.
  BA_AGMT_NOT_SUPPORTED | BA agreement type not supported.

Definition at line 201 of file mm.h.

enum mm_features

Features supported by LMAC - Positions.

Enumerator:

  MM_FEAT_BCN_BIT | Beaconing.
  MM_FEAT_AUTOBCN_BIT | Autonomous Beacon Transmission.
  MM_FEAT_HWSCAN_BIT | Scan in LMAC.
  MM_FEAT_CMON_BIT | Connection Monitoring.
  MM_FEAT_MROLE_BIT | Multi Role.
  MM_FEAT_RADAR_BIT | Radar Detection.
  MM_FEAT_PS_BIT | Power Save.
  MM_FEAT_UAPSD_BIT | UAPSD.
  MM_FEAT_DPSM_BIT | DPSM.
  MM_FEAT_AMPDU_BIT | A-MPDU.
  MM_FEAT_AMSDU_BIT | A-MSDU.
  MM_FEAT_CHNL_CTXT_BIT | Channel Context.
  MM_FEAT_REORD_BIT | Packet reordering.
  MM_FEAT_P2P_BIT | P2P.
  MM_FEAT_P2P_GO_BIT | P2P Go.
  MM_FEAT_UMAC_BIT | UMAC Present.
  MM_FEAT_VHT_BIT | VHT support.
  MM_FEAT_BFMEE_BIT | Beamformee.
  MM_FEAT_BFMER_BIT | Beamformer.
  MM_FEAT_WAPI_BIT | WAPI.
  MM_FEAT_MFP_BIT | MFP.
  MM_FEAT_MU_MIMO_RX_BIT | Mu-MIMO RX support.
  MM_FEAT_MU_MIMO_TX_BIT | Mu-MIMO TX support.
  MM_FEAT_MESH_BIT | Wireless Mesh Networking.
  MM_FEAT_TDLS_BIT | TDLS support.
  MM_FEAT_ANT_DIV_BIT | Antenna Diversity support.
  MM_FEAT_UF_BIT | UF support.
  MM_AMSDU_MAX_SIZE_BIT0 | A-MSDU maximum size (bit0).
  MM_AMSDU_MAX_SIZE_BIT1 | A-MSDU maximum size (bit1).
  MM_FEAT_MON_DATA_BIT | MON_DATA support.
  MM_FEAT_HE_BIT | HE (802.11ax) support.

Definition at line 218 of file mm.h.

## Function Documentation

void mm_ant_div_check | ( | uint8_t | beacon_loss_cnt | ) |

This function is called at each tbtt, it updates the counter of beacon periods without any antenna switch (2x2 station only) and it checks if the antenna connected to path_0 should be switched.

In case of 1x1 station, an antenna switch is requested if:

- more than ANT_DIV_BEACON_LOSS_THD consecutive beacons are lost
- the RSSI of the current antenna is outside of the golden range and:
  - the distance of the other antenna RSSI from the golden range is less than the distance of the current antenna RSSI from the golden range
  - or the current antenna RSSI is changed of more than ANT_DIV_RSSI_STEP_CHANGE compared to its initial RSSI
  - or it has not been updated for at least ANT_DIV_UPDATE_CNT_THD beacon periods In case of 2x2 station, an antenna switch is requested if the RSSI of the antenna connected to path_1 is greater of at least ANT_DIV_RSSI_THD than the RSSI of the antenna connected to path_0. If the switch is requested, the MM_SWITCH_ANTENNA_REQ message is sent.

Parameters:

  `[in]` | beacon_loss_cnt | Number of consecutive beacons lost

void mm_ant_div_init | ( | bool | enable | ) |

Initialize the antenna diversity parameters.

Parameters:

  `[in]` | enable | Whether the algorithm is enabled or not

Referenced by mm_ant_div_init_req_handler().

void mm_ant_div_reset_rssi | ( | uint8_t | ant | ) |

Reset the current and the initial RSSI values in the antenna diversity structure for the requested antenna.

Parameters:

  `[in]` | ant | Antenna for which the RSSI reset is requested

void mm_ant_div_restore | ( | bool | active | ) |

Update the number of active VIF and update accordingly the status of the antenna switch flag.

Parameters:

  `[in]` | active | VIF status

Referenced by mm_set_vif_state_req_handler().

void mm_ant_div_switch_and_stop | ( | void |  | ) |

Switch antenna, if no other active connections are set up and if the algorithm is enabled.

Then disable the antenna switch.

Referenced by mm_ant_div_stop_req_handler().

void mm_ant_div_switch_antenna | ( | void |  | ) |

Change the antenna connected to path_0, reset the update counter and request an update of the initial RSSI (case 1x1 station).

Referenced by mm_switch_antenna_req_handler().

void mm_ant_div_update_rssi | ( | int8_t * | rssi | ) |

Update the RSSI values for both antennas.

Parameters:

  `[in]` | rssi | Pointer to the RSSI values for both antennas.

void mm_ap_pre_tbtt | ( | void * | env | ) |

MM timer callback for the AP pre-TBTT handling.

Parameters:

  `[in]` | env | Pointer to the environment to be passed to the callback upon timer expiry

static void mm_ap_probe_cfm | ( | void * | env,
|  | uint32_t | status |
| ) |  |  | `[static]`

Callback function indicating the completion of the NULL frame transmission used to probe the AP in case we don't receive any more beacons.

Parameters:

  `[in]` | env | Pointer to the VIF entry
  `[in]` | status | Status of the transmission

Definition at line 441 of file mm.c.

References FRAME_SUCCESSFUL_TX_BIT, mm_send_connection_loss_ind(), vif_info_tag::sta, and vif_info_tag::u.

static void mm_ap_tbtt | ( | uint32_t | evt | ) | `[static]`

Handler for KE_EVT_PRIMARY_TBTT and KE_EVT_SECONDARY_TBTT events for beaconning interfaces.

It prepares beacon transmission for all beaconning interfaces.

Parameters:

  `[in]` | evt | Event being processed

Definition at line 712 of file mm.c.

References AC_BCN, vif_info_tag::ap, vif_info_tag::chan_ctxt, chan_tbtt_start(), co_list_pick(), DESC_DONE_SW_TX_BIT, GLOBAL_INT_DISABLE, GLOBAL_INT_RESTORE, HAL_MACHW_BCN_TX_DELAY_US, ke_time(), mm_bcn_transmit(), MM_PRE_AP_TBTT_DELAY_US, mm_timer_set(), vif_info_tag::p2p, p2p_tbtt_handle(), PROF_AP_TBTT_CLR, PROF_AP_TBTT_SET, vif_info_tag::tbtt_timer, mm_timer_tag::time, txl_cntrl_flush_ac(), txl_cntrl_halt_ac(), vif_info_tag::type, vif_info_tag::u, vif_mgmt_env_tag::used_list, VIF_AP, VIF_MESH_POINT, vif_mgmt_bcn_to_prog(), vif_mgmt_env, and vif_mgmt_next().

int32_t mm_ap_tbtt_move | ( | int32_t | offset | ) |

Request to apply an offset (positive or negative) to the next TBTT.

Depending on the current position within the beacon period the function will chose to apply immediately the offset or program a timer to apply later.

Parameters:

  `[in]` | offset | Offset to apply to the TBTT (can be positive to delay the TBTT or negative to advance it)

Returns:
  The offset that will be applied (0 if no offset applied).

Referenced by chan_p2p_noa_resync(), chan_start_p2pgo_noa(), and mm_tbtt_move_req_handler().

static void mm_ap_tbtt_move_cb | ( | void * | offset | ) | `[static]`

Callback function called when the TBTT move can be performed.

The function will send an internal message to the MM in order to handle the TBTT move in IDLE state.

Parameters:

  `[in]` | offset | Offset to be applied to the TBTT

Definition at line 215 of file mm.c.

References KE_MSG_ALLOC, ke_msg_send(), MM_TBTT_MOVE_REQ, mm_tbtt_move_req::offset, and TASK_MM.

bool mm_ba_agmt_rx_exists | ( | uint8_t | sta_idx,
|  | uint8_t | tid |
| ) |  |  |

Simple check for existence of a BA agreement for a certain (STA, TID) pair (RX).

Parameters:

  `[in]` | sta_idx | STA index in STA info table for which BA agreement existence must be checked
  `[in]` | tid | TID corresponding to STA index in STA info table for which BA agreement existence must be checked

Returns:
  1 if existent, 0 if not.

Referenced by mm_ba_del_req_handler(), and rxu_mgt_ind_handler().

bool mm_ba_agmt_tx_exists | ( | uint8_t | sta_idx,
|  | uint8_t | tid |
| ) |  |  |

Simple check for existence of a BA agreement for a certain (STA, TID) pair (TX).

Parameters:

  `[in]` | sta_idx | STA index in STA info table for which BA agreement existence must be checked
  `[in]` | tid | TID corresponding to STA index in STA info table for which BA agreement existence must be checked

Returns:
  1 if existent, 0 if not.

Referenced by mm_ba_add_req_handler(), and mm_ba_del_req_handler().

void mm_back_to_host_idle | ( | void |  | ) |

Ask MM to switch back to IDLE state requested by the host (quit BYPASSED mode).

Referenced by chan_conn_less_ctxt_end().

bool mm_check_beacon | ( | struct rx_hd * | rhd,
|  | struct vif_info_tag * | vif,
|  | struct sta_info_tag * | sta,
|  | uint32_t * | tim |
| ) |  |  |

Function responsible for all the connection monitoring stuff.

It resets the beacon loss counter, checks if the beacon has changed compared to the previous one (in order to know if it has to be forwarded to the upper layers or not), and sends the keep-alive NULL frame if it is time to do so.

Parameters:

  `[in]` | rhd | Pointer to the beacon RX descriptor
  `[in]` | vif | Pointer to the VIF entry
  `[in]` | sta | Pointer to the STA entry that sent the beacon
  `[out]` | tim | Pointer to the TIM IE found in the beacon

Returns:
  true if the beacon has to be uploaded (i.e because it changed since the last one), false otherwise.

Referenced by rxl_frame_handle().

void mm_check_rssi | ( | struct vif_info_tag * | vif,
|  | int8_t | rssi |
| ) |  |  |

Check RSSI level and inform the host if RSSI is decreased below the threshold or if it is increased above the threshold.

Parameters:

  `[in]` | vif | Pointer to the VIF entry
  `[in]` | rssi | RSSI received

static uint32_t mm_compute_beacon_crc | ( | struct bcn_frame * | bcn,
|  | uint16_t | len,
|  | uint32_t * | tim |
| ) |  |  | `[static]`

Function computing the CRC of the received beacon The function skips the information elements handled in the LMAC (such as the TIM).

It also returns the address of the TIM in the beacon buffer.

Parameters:

  `[in]` | bcn | Pointer to the BCN frame
  `[in]` | len | Length of the BCN frame
  `[out]` | tim | Variable to which the TIM address will be written

Returns:
  The computed CRC

Definition at line 471 of file mm.c.

References co_crc32(), co_read8p(), CPU2HW, MAC_BEACON_INTERVAL_OFT, MAC_BEACON_VARIABLE_PART_OFT, MAC_ELTID_TIM, and MAC_INFOELT_INFO_OFT.

void mm_force_idle_req | ( | void |  | ) |

Force the HW to go to IDLE immediately.

Referenced by chan_conn_less_ctxt_end(), chan_goto_idle_cb(), chan_tx_cfm(), and p2p_goto_idle_cb().

__INLINE uint8_t mm_get_golden_range_distance | ( | int8_t | rssi | ) |

This function calculates the distance of the RSSI from the golden range.

Parameters:

  `[in]` | rssi | RSSI value

Returns:
  Distance of RSSI from the golden range

Definition at line 489 of file mm.h.

References ANT_DIV_RSSI_GOLDEN_MAX, and ANT_DIV_RSSI_GOLDEN_MIN.

void mm_hw_ap_info_reset | ( | void |  | ) |

Reset the HW information for an AP.

void mm_hw_ap_info_set | ( | void |  | ) |

Set the correct HW information for an AP.

void mm_hw_idle_evt | ( | int | dummy | ) |

Kernel event handler for the HW IDLE event.

This function puts the MM task in IDLE state.

Parameters:

  `[in]` | dummy | Parameter not used but required to follow the kernel event callback format

void mm_hw_info_set | ( | struct mac_addr const * | mac_addr | ) |

Setting of general HW info upon the first interface creation.

Parameters:

  `[in]` | mac_addr | Primary MAC address of the interface

void mm_init | ( | void |  | ) |

Initialize all MM related context and data etc.

MM Module main initialization function.

...

This function is called after reset and initializes all MM related env and data.

Referenced by mm_reset_req_handler().

static void mm_key_ram_param_get | ( | uint8_t | cipher_suite,
|  | struct mac_sec_key const * | key,
|  | uint8_t * | ctype,
|  | uint8_t * | clen |
| ) |  |  | `[static]`

Compute the cType and cLen to be set to the key RAM depending on the Cipher and the key length.

Parameters:

  `[in]` | cipher_suite | Cipher suite to be used (mac_cipher_suite)
  `[in]` | key | Pointer to the key structure
  `[out]` | ctype | cType parameter to be set to the key RAM
  `[out]` | clen | cLen parameter to be set to the key RAM

Definition at line 159 of file mm.c.

References ASSERT_ERR, mac_sec_key::length, MAC_CIPHER_CCMP, MAC_CIPHER_TKIP, MAC_CIPHER_WEP104, MAC_CIPHER_WEP40, MAC_CIPHER_WPI_SMS4, MM_SEC_CTYPE_CCMP, MM_SEC_CTYPE_NULL, MM_SEC_CTYPE_TKIP, MM_SEC_CTYPE_WEP, and MM_SEC_CTYPE_WPI_SMS4.

void mm_no_idle_start | ( | void |  | ) |

Ask MM to disallow the switch to IDLE state.

This function is called upon beacon programming to ensure that the MAC HW proceeds to the packet transmission.

void mm_no_idle_stop | ( | void |  | ) |

Ask MM to allow again the switch to IDLE state.

This function is called upon beacon transmission confirmation from the MAC HW.

Referenced by mm_bcn_transmitted().

__INLINE void mm_ps_change_ind | ( | uint8_t | sta_idx,
|  | uint8_t | ps_state |
| ) |  |  |

This function indicates a PS state change of a peer device to the upper layers.

Parameters:

  `[in]` | sta_idx | Index of the peer device in the station table
  `[in]` | ps_state | New PS state of the peer device

Definition at line 429 of file mm.h.

References KE_MSG_ALLOC, ke_msg_send(), MM_PS_CHANGE_IND, mm_ps_change_ind::ps_state, sta_info_tag::ps_state, mm_ps_change_ind::sta_idx, sta_info_tab, and TASK_MM.

Referenced by me_sta_add_req_handler(), and rxl_pm_check().

void mm_reset | ( | void |  | ) |

MM Module reset function.

This function is part of the recovery mechanism invoked upon an error detection in the LMAC. It resets the MM state machine.

__INLINE void mm_rx_filter_lmac_enable_clear | ( | uint32_t | filter | ) |

This function disables some RX filter bits on the LMAC filter.

Parameters:

  `[in]` | filter | Bits to be cleared

Definition at line 413 of file mm.h.

References mm_env, mm_rx_filter_set(), and mm_env_tag::rx_filter_lmac_enable.

Referenced by mm_scan_channel_end_ind_handler().

__INLINE void mm_rx_filter_lmac_enable_set | ( | uint32_t | filter | ) |

This function enables some RX filter bits on the LMAC filter.

Parameters:

  `[in]` | filter | Bits to be set

Definition at line 398 of file mm.h.

References mm_env, mm_rx_filter_set(), and mm_env_tag::rx_filter_lmac_enable.

Referenced by mm_scan_channel_start_ind_handler().

__INLINE void mm_rx_filter_umac_set | ( | uint32_t | filter | ) |

This function sets the RX filter for the UMAC.

Parameters:

  `[in]` | filter | Filter bitfield requested by the UMAC

Definition at line 383 of file mm.h.

References mm_env, mm_rx_filter_set(), and mm_env_tag::rx_filter_umac.

Referenced by mm_set_filter_req_handler().

void mm_sec_machwaddr_del | ( | uint8_t | sta_idx | ) |

Function to delete a MAC address from the MAC HW key storage.

This function is called from MM_STA_DEL_REQ handler.

Parameters:

  `[in]` | sta_idx | Index of the station

uint8_t mm_sec_machwaddr_wr | ( | uint8_t | sta_idx,
|  | uint8_t | inst_nbr |
| ) |  |  |

Function to add a MAC address in the MAC HW key storage.

This function is called from MM_STA_ADD_REQ handler.

Parameters:

  `[in]` | sta_idx | Index of the station
  `[in]` | inst_nbr | Index of the VIF

Returns:
  The HW STA index for the new STA

void mm_sec_machwkey_del | ( | uint8_t | hw_key_idx | ) |

Function to delete a key from the MAC HW.

This function is called from MM_KEY_DEL_REQ handler to remove a key from the KeyStoragRAM of the MAC HW.

Parameters:

  `[in]` | hw_key_idx | Index of the key to be removed

Referenced by mm_key_del_req_handler().

uint8_t mm_sec_machwkey_wr | ( | struct mm_key_add_req const * | param | ) |

Function to write key in MAC HW.

This function is called from MM_KEY_ADD_REQ handler to store a key into the KeyStoragRAM of the MAC HW.

Parameters:

  `[in]` | param | Pointer to the parameters of the message.

Returns:
  The HW key index for the new key

Referenced by mm_key_add_req_handler().

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

Inform the host that connection has been lost with an AP.

Parameters:

  `[in]` | vif | VIF Entry used for the connection.

Referenced by mm_ap_probe_cfm(), and ps_check_tx_status().

void mm_send_csa_traffic_ind | ( | uint8_t | vif_index,
|  | bool | enable |
| ) |  |  |

Send host message to stop (resp restarted) tx traffic because CSA is in progress (resp.

finished)

Parameters:

  `[in]` | vif_index | Vif index
  `[in]` | enable | Traffic status

Referenced by me_beacon_check().

void mm_send_pktloss_ind | ( | struct vif_info_tag * | vif,
|  | uint8_t | sta_idx,
|  | uint32_t | num_pkts |
| ) |  |  |

Send the MM_PKTLOSS_IND message to the host.

Parameters:

  `[in]` | vif | VIF Entry used for the connection.
  `[in]` | sta_idx | STA index in STA info table for which the packet loss msg is sent.
  `[in]` | num_pkts | Number of packets lost.

Referenced by tdls_keep_alive_frame_tx_cfm(), and tdls_pti_timeout_evt().

uint8_t mm_sta_add | ( | struct mm_sta_add_req const * | param,
|  | uint8_t * | sta_idx,
|  | uint8_t * | hw_sta_idx |
| ) |  |  |

Add a station to the list of known stations.

Parameters:

  `[in]` | param | MM_STA_ADD_REQ message parameters
  `[out]` | sta_idx | Pointer to which the allocated STA index should be written
  `[out]` | hw_sta_idx | Pointer to which the allocated STA HW index should be written

Returns:
  The status of the allocation (CO_OK if successful)

Referenced by me_sta_add_req_handler(), and mm_sta_add_req_handler().

void mm_sta_del | ( | uint8_t | sta_idx | ) |

Delete a station from the list of known stations.

Parameters:

  `[in]` | sta_idx | Index of the station to delete

Referenced by mm_sta_del_req_handler().

void mm_sta_tbtt | ( | void * | env | ) |

MM timer callback for the station TBTT handling.

Parameters:

  `[in]` | env | Pointer to the environment to be passed to the callback upon timer expiry

void mm_tbtt_compute | ( | struct bcn_frame * | bcn,
|  | uint16_t | len,
|  | struct rx_hd * | rhd,
|  | struct vif_info_tag * | vif,
|  | struct sta_info_tag * | sta,
|  | uint32_t | tim |
| ) |  |  |

Configure tbtt_timer for next beacon.

Configure tbtt_timer of the vif to be triggered before the next expected beacon

Parameters:

  `[in]` | bcn | Pointer to the beacon
  `[in]` | len | Length of the beacon
  `[in]` | rhd | Pointer to the beacon RX descriptor
  `[in]` | vif | Pointer to the VIF entry
  `[in]` | sta | Pointer to the STA entry that send the beacon
  `[in]` | tim | Pointer to the TIM IE found in the beacon

Referenced by rxl_frame_handle().

void mm_tbtt_evt | ( | int | dummy | ) |

Kernel event handler for the TBTT event.

This function flushes the beacon queue and signals the event to the upper MAC.

Parameters:

  `[in]` | dummy | Parameter not used but required to follow the kernel event callback format

__INLINE void mm_traffic_req_ind | ( | uint8_t | sta_idx,
|  | uint8_t | pkt_cnt,
|  | bool | uapsd |
| ) |  |  |

This function requests some buffered packets to be transmitted.

Parameters:

  `[in]` | sta_idx | Index of the peer device we have to transmit to
  `[in]` | pkt_cnt | Number of packets that need to be transmitted
  `[in]` | uapsd | Flag indicating if the request is for U-APSD queues or not

Definition at line 461 of file mm.h.

References KE_MSG_ALLOC, ke_msg_send(), MM_TRAFFIC_REQ_IND, mm_traffic_req_ind::pkt_cnt, PROF_PS_TRAFFIC_REQ_CLR, PROF_PS_TRAFFIC_REQ_SET, mm_traffic_req_ind::sta_idx, TASK_MM, and mm_traffic_req_ind::uapsd.

Referenced by rxl_pm_check().

## Variable Documentation

struct mm_env_tag mm_env`[read]`

Global data for maintaining BSS and STA information.

LMAC MM Context variable, used to store MM Context data

Definition at line 734 of file mm.h.

Referenced by chan_switch_channel(), mm_hw_config_handler(), mm_rx_filter_lmac_enable_clear(), mm_rx_filter_lmac_enable_set(), mm_rx_filter_set(), mm_rx_filter_umac_set(), mm_set_basic_rates_req_handler(), mm_set_idle_req_handler(), mm_set_vif_state_req_handler(), mm_tbtt_move_req_handler(), and txl_ampdu_constraints_get().

struct mm_env_tag mm_env`[read]`

Global data for maintaining BSS and STA information.

LMAC MM Context variable, used to store MM Context data

Definition at line 145 of file mm.c.

Referenced by chan_switch_channel(), mm_hw_config_handler(), mm_rx_filter_lmac_enable_clear(), mm_rx_filter_lmac_enable_set(), mm_rx_filter_set(), mm_rx_filter_umac_set(), mm_set_basic_rates_req_handler(), mm_set_idle_req_handler(), mm_set_vif_state_req_handler(), mm_tbtt_move_req_handler(), and txl_ampdu_constraints_get().