# /space/home/slher/rel/Beken/v6_4_5/macsw/ip/lmac/src/chan/chan.c File Reference

MAC Management channel management implementation. More...

`#include "chan.h"`
`#include "mac_frame.h"`
`#include "mm.h"`
`#include "mm_timer.h"`
`#include "mm_bcn.h"`
`#include "co_endian.h"`
`#include "sta_mgmt.h"`
`#include "vif_mgmt.h"`
`#include "phy.h"`
`#include "dbg.h"`
`#include "rd.h"`
`#include "ps.h"`
`#include "txl_cntrl.h"`
`#include "txl_frame.h"`
`#include "rxl_hwdesc.h"`
`#include "hal_machw.h"`
`#include "td.h"`
`#include "scan.h"`
`#include "tpc.h"`
`#include "me.h"`
`#include "tdls.h"`
`#include "p2p.h"`

Go to the source code of this file.

## Data Structures
struct | chan_window
| Internal structure to represent window. More...
## Defines
#define | CHAN_SWITCH_CNT 4
| Maximum number of scheduled switch.
#define | CHAN_MIN_PRES_DUR_US (5000)
| Minimal presence duration on a channel (in us).
#define | CHAN_CONN_LESS_DELAY (30000)
| Delay before switching on a Scan or a ROC channel, indicate minimal duration between two successive scan/roc operations.
#define | CHAN_ROC_SCAN_PENDING_MASK (CO_BIT(CHAN_ENV_ROC_BIT) | CO_BIT(CHAN_ENV_SCAN_BIT))
| Flags indicating that a scan ROC is pending.
#define | CHAN_P2P_NOA_RESCHEDULE_THRESHOLD 2000
| Drift threshold of STA/P2P-CLI TBTT to re-schedule NOA, in us.
#define | CHAN_P2P_NOA_RESYNC_THRESHOLD 200
| Drift threshold of STA/P2P-CLI TBTT to re-sync P2P GO TBTT with NOA, in us.
## Functions
static void | chan_switch_start (struct chan_ctxt_tag *ctxt)
| Initiate channel switch procedure in order to jump to indicated channel.
static void | chan_switch_channel (void)
| Switch from chan_env.current_ctxt to chan_env.switch_ctxt.
__INLINE void | chan_switch_set_timer (struct chan_switch_tag *ch_switch)
| Configure timer for next channel switch.
__INLINE void | chan_switch_reset_timer (void)
| Cancel timer for channel switch.
__INLINE struct chan_switch_tag * | chan_switch_pop (void)
| Extract first element of scheduled channel switch list.
__INLINE struct chan_switch_tag * | chan_switch_pick (void)
| Get first element of scheduled channel switch list.
__INLINE struct chan_switch_tag * | chan_switch_last (void)
| Get last element of scheduled channel switch list.
__INLINE void | chan_switch_push_back (struct chan_switch_tag *ch_switch)
| Insert on element at the end of the scheduled channel switch list.
__INLINE bool | chan_switch_no_schedule (void)
| Check is scheduled channel switch list is empty.
__INLINE struct chan_switch_tag * | chan_switch_alloc (void)
| Allocate a channel switch information element.
__INLINE void | chan_switch_free (struct chan_switch_tag *ch_switch)
| Free a channel switch information element.
__INLINE struct chan_tbtt_tag * | chan_tbtt_pick (void)
| Get first element of tbtt list.
__INLINE struct chan_tbtt_tag * | chan_tbtt_next (struct chan_tbtt_tag *tbtt)
| Get next element of tbtt list.
__INLINE void | chan_tbtt_remove (struct chan_tbtt_tag *tbtt)
| Remove TBTT form the list.
__INLINE void | chan_tbtt_insert_before (struct chan_tbtt_tag *tbtt, struct chan_tbtt_tag *tbtt_next)
| Insert TBTT before another TBTT.
static uint32_t | chan_vif_tbtt_intv (struct vif_info_tag *vif)
| Get TBTT interval for a vif.
static uint32_t | chan_vif_tbtt_dur (struct vif_info_tag *vif)
| Get TBTT duration for a vif.
static void | chan_upd_ctxt_status (struct chan_ctxt_tag *ctxt, uint8_t status)
| Update the status of a provided channel context.
static struct chan_ctxt_tag * | chan_get_first_traf_ctxt (void)
| Get pointer to first active traffic channel context.
static struct chan_ctxt_tag * | chan_get_next_traf_ctxt (struct chan_ctxt_tag *ctxt)
| Get pointer to another traffic channel context.
static void | chan_send_pre_switch_ind (struct chan_ctxt_tag *old_ctxt)
| Send CHANNEL_PRE_SWITCH_IND message to the upper layers.
static void | chan_send_switch_ind (struct chan_ctxt_tag *new_ctxt)
| Send CHANNEL_SWITCH_IND message to the upper layers.
static void | chan_send_survey_ind (void)
| Send a channel survey to the host by using the MM_CHANNEL_SURVEY_IND message.
static void | chan_send_roc_exp_ind (struct chan_ctxt_tag *ctxt)
| Send MM_REMAIN_ON_CHANNEL_EXP_IND message to the upper layers.
__INLINE bool | chan_is_p2p_go (struct vif_info_tag *vif)
| Test if a vif is a P2P GO.
static uint32_t | chan_window_merge_duration (struct chan_window *w1, struct chan_window *w2, struct chan_window *w_res, uint32_t interval)
| Return the minimal window that contains both window.
static void | chan_stop_p2pgo_noa (struct vif_info_tag *p2pgo_vif)
| Stop concurrent NOA for a P2P GO interface.
static void | chan_start_p2pgo_noa (struct vif_info_tag *p2pgo_vif)
| Start concurrent NOA for a P2P GO interface.
__INLINE bool | chan_get_p2pgo (struct vif_info_tag **p2pgo_vif)
| Return P2P GO interface.
static bool | chan_start_p2pgo_single_noa (struct vif_info_tag *vif, uint32_t start, struct chan_tbtt_tag *tbtt)
| Start a non-periodic NOA on a P2P GO interface.
static bool | chan_tbtt_overlap (struct chan_tbtt_tag *tbtt1, struct chan_tbtt_tag *tbtt2)
| Check if TBTT constraint for two vifs overlap.
__INLINE bool | chan_tbtt_skip_fix_ctxt (uint32_t tbtt_time, struct chan_ctxt_tag *ctxt)
| Check if TBTT must be skipped because of scheduled switch or fix channel.
static void | chan_add_next_tbtt (struct vif_info_tag *vif, uint32_t tbtt_time, uint32_t skip_cnt)
| Add next TBTT for a vif.
static uint32_t | chan_share_medium (int32_t dur_to_split, uint32_t dur_spent, uint32_t now)
| Share time between two channel context.
static void | chan_schedule_one_switch (uint32_t date, struct chan_ctxt_tag *ctxt, struct chan_tbtt_tag *tbtt)
| Schedule a channel switch.
static bool | chan_schedule_extra_switch_from_p2pgo_ctxt (int p2p_vif_index, uint32_t now, uint32_t *switch_date, uint32_t *return_date)
| Schedule a switch (and return) to other context when TBTT ends on a channel with a P2P GO interface.
static bool | chan_schedule_extra_switch_to_p2pgo_ctxt (int p2p_vif_index, uint32_t *switch_date, uint32_t *return_date)
| Schedule a switch (and return) to a context with P2P GO interface when TBTT ends on a channel without a P2P GO interface.
static void | chan_schedule_switch_from_p2pgo_ctxt (int p2p_vif_index, struct chan_ctxt_tag *next_ctxt, uint32_t now, uint32_t *switch_date)
| Schedule a switch when TBTT window ends, from a context with a P2P GO interface to another context.
static void | chan_schedule_switch_to_p2pgo_ctxt (int p2p_vif_index, struct chan_ctxt_tag *ctxt, uint32_t now, uint32_t *switch_date)
| Schedule a switch from a context without P2P GO interface when TBTT ends to a context with P2P GO interface .
static void | chan_schedule_next_switch (struct vif_info_tag *vif, uint32_t now, uint32_t tbtt_dur)
| Schedule all channel switches from end of current TBTT until next TBTT.
static void | chan_cancel_all_switch (void)
| Cancel all scheduled channel switches.
static void | chan_fix_ctxt_until (struct chan_ctxt_tag *ctxt)
| Fix a channel context for a specified period.
static void | chan_conn_less_delay_evt (void *env)
| Callback called upon Connection Less Delay timer expiration.
static void | chan_conn_less_delay_prog (void)
| Program the timer used for delaying Scan/RoC operations.
static void | chan_conn_less_ctxt_end (struct chan_ctxt_tag *ctxt)
| Handle ends of connection-less channel context.
static struct chan_ctxt_tag * | chan_fix_ctxt_end (void)
| Return the new channel context to switch to after a fixed channel context.
static void | chan_tmr_switch_cb (void *env)
| Timer callback for channel switch.
static void | chan_pre_switch_channel (void)
| Function called once SW and HW are ready for a channel switch.
static void | chan_tx_cfm (void *dummy, uint32_t status)
| Function called during the Channel Switch procedure each time a NULL packet used for Absence indication is confirmed.
static void | chan_notify_presence (void)
| For each VIF linked with the channel context we are switching on, we send a NULL frame with the PM bit set to 0 in order to indicate our presence.
static int | chan_notify_absence (void)
| For each VIF linked with the channel context we are leaving, we send a NULL frame with the PM bit set to 1 in order to indicate our absence.
static void | chan_goto_idle_cb (void)
| This callback is called once HW has gone to the IDLE state during a channel switch procedure.
static void | chan_send_force_idle (void)
| Send a MM_FORCE_IDLE_REQ message to TASK_MM in order to require the HW to enter in IDLE mode.
static bool | chan_check_chan (struct mac_chan_op const *chan_req, uint8_t *idx)
| Go through the list of channel contexts in order to check if a channel context, using compatible parameters than those provided by the host, is currently used.
static void | chan_p2p_noa_resync (struct vif_info_tag *vif)
| Move P2P GO TBTT and NOA to resyncrhonize with other AP's TBTT.
static void | chan_p2p_noa_tsf_updated (struct vif_info_tag *vif)
| Post process after a TBTT move on a P2P GO interface.
static void | chan_p2p_noa_resync_check (struct vif_info_tag *vif, uint32_t tbtt_time)
| Check if drift in TBTT implies a resync (or restart) of NOA.
static void | chan_reset_tbtt_list (void)
| Reset TBTT list in channel module.
static void | chan_ctxt_init (struct chan_ctxt_tag *ctxt)
| Initialize all parameters stored in a channel context entry.
void | chan_init (void)
| MM Channel Module initialization function.
void | chan_scan_req (uint8_t band, uint16_t freq, int8_t pwr, uint32_t duration_us, uint8_t flags, uint8_t vif_index)
| Request to go to a specific channel for scanning.
uint8_t | chan_roc_req (struct mm_remain_on_channel_req const *req, ke_task_id_t taskid)
| Request to go to a specific channel for a given duration.
uint8_t | chan_ctxt_add (struct mac_chan_op const *chan_req, uint8_t *idx)
| Request to allocate a new channel context.
void | chan_ctxt_del (uint8_t idx)
| Free a previously allocated channel context.
void | chan_ctxt_link (uint8_t vif_idx, uint8_t chan_idx)
| Link a channel context to a VIF.
void | chan_ctxt_unlink (uint8_t vif_idx)
| Unlink the channel context from a VIF.
void | chan_ctxt_update (struct mm_chan_ctxt_update_req const *update)
| Request to update the parameters of a channel context.
void | chan_ctxt_link_monitor (uint8_t chan_idx)
| Link a channel context to the monitor interface.
int | chan_tbtt_start (struct vif_info_tag *vif, uint32_t tbtt_time, uint32_t next_tbtt_time)
| Indicates that TBTT starts and provides date of the next TBTT.
void | chan_tbtt_updated (struct vif_info_tag *vif)
| Called when TBTT timer has been updated after beacon reception.
void | chan_bcn_to_evt (struct vif_info_tag *vif)
| Indicates end of the TBTT window.
void | chan_bcn_detect_start (struct vif_info_tag *vif)
| Start a Remain on Channel procedure (duration is the beacon interval) in order to catch the beacon sent by a peer AP device.
void | chan_p2p_absence_update (struct chan_ctxt_tag *ctxt, bool absence)
| Function used by the P2P module to notify the chan module about an update of presence status of a GO device.
bool | chan_is_on_channel (struct vif_info_tag *vif)
| Check if the VIF passed as parameter has currently access to the channel.
bool | chan_is_tx_allowed (struct vif_info_tag *vif)
| Check if transmission is allowed on a vif's channel.
bool | chan_is_on_operational_channel (struct vif_info_tag *vif)
| Check if the VIF passed as parameter is currently on its operational channel.
void | chan_update_tx_power (struct chan_ctxt_tag *ctxt)
| Update TX power for a channel context.
## Variables
struct chan_env_tag | chan_env
| MM Channel module context variable.
struct chan_ctxt_tag | chan_ctxt_pool [CHAN_CHAN_CTXT_CNT]
| Pool of channel contexts.
struct chan_switch_tag | chan_switch_pool [CHAN_SWITCH_CNT]
| Pool of channel switch descriptor.

## Detailed Description

MAC Management channel management implementation.

Copyright (C) RivieraWaves 2011-2019

Definition in file chan.c.