Files
kunlun/plc/cvg/bwm/inc/cvg_bwm.h
2024-09-28 14:24:04 +08:00

337 lines
10 KiB
C
Executable File

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef CVG_BWM_H
#define CVG_BWM_H
/* os shim includes */
#include "os_types.h"
/* public api includes */
#include "cvg_api.h"
#include "plc_fr.h"
#include "mac_bcm_api.h"
/* cvg module internal includes */
#include "cvg.h"
#ifdef __cplusplus
extern "C" {
#endif
/* define minimum band switch delay. unit is 1 ms */
#define CVG_BWM_BAND_SWITCH_DELAY_MIN (2 * 60 * 1000)
/* define fast band switch delay. unit is 1ms */
#define CVG_BWM_BAND_SWITCH_DELAY_FAST (15 * 1000)
/* define minimum rf channel switch delay. unit is 1s */
#define CVG_BWM_RF_CHANNEL_SWITCH_DELAY_MIN (2 * 60)
/* define fast rf channel switch delay. unit is 1s */
#define CVG_BWM_RF_CHANNEL_SWITCH_DELAY_FAST (15)
/* define rf channel switch delay for cert test. unit is 1s */
#define CVG_BWM_RF_CHANNEL_SWITCH_DELAY_CERT_TEST (25)
/* define joined sta count of enabling plc band or rf channel fast switching */
#define CVG_BWM_FB_SWITCH_FAST_STA_CNT (10)
/*
* cvg_bwm_init() - global init of bandwdith management module
* @glb: pointer of cvg global data
* @cfg: pointer of cvg configuration
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t cvg_bwm_init(cvg_global_t *glb, cvg_cfg_t *cfg);
/*
* cvg_bwm_init_vdev() - vdev init of bandwdith management module
* @vdev: pointer of vdev to be init
* @cfg: pointer of vdev configuration
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t cvg_bwm_init_vdev(cvg_vdev_t *vdev, cvg_vdev_cfg_t *cfg);
/*
* cvg_bwm_deinit_vdev() - vdev deinit of bandwidth management module
* @vdev: pointer of vdev to be deinit
*/
void cvg_bwm_deinit_vdev(cvg_vdev_t *vdev);
/*
* cvg_bwm_reset_vdev() - vdev reset of bandwdith management module
* @vdev: pointer of vdev to be reset
* @cfg: pointer of vdev configuration
*/
void cvg_bwm_reset_vdev(cvg_vdev_t *vdev, cvg_vdev_cfg_t *cfg);
/*
* cvg_bwm_update_bc() - trigger bandwidth management module to update
* beacon template
* @vdev: pointer to vdev
* @ent: pointer to beacon update descriptor
* @rf_chg: pointer to beacon rf channel change entry to be forwarded,
* it is only valid for single mode sta device
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t cvg_bwm_update_bc(cvg_vdev_t *vdev, mac_bc_update_t *ent,
mac_bc_rf_channel_chg_t *rf_chg);
/*
* cvg_bwm_update_ts() - update time slot assignment info
* @vdev: pointer to vdev
* @ts: pointer to new time slot assignment info to be updated
*/
void cvg_bwm_update_ts(cvg_vdev_t *vdev, mac_bc_time_slot_t *ts);
/*
* cvg_bwm_fwd_lid_check() - check which lid should be chose
* @vdev: pointer to vdev
* @lid: lid in frame control field
* @retval: the appropriate tx info lid
*/
uint8_t cvg_bwm_fwd_lid_check(cvg_vdev_t *vdev, uint8_t lid);
/**
* @brief cvg_bwm_update_fb_chg() - update frequency band change entry
* assignment info
* @param vdev: pointer to vdev
* @param fb_chg: pointer to frequency band change entry assignment info
* to be updated. if fb_chg == NULL, indicates that no
* freq band change entries in the beacon frame.
* @param bc_band_id: freq band ID of the current received beacon.
*/
void cvg_bwm_update_fb_chg(cvg_vdev_t *vdev, mac_bc_freq_chg_t *fb_chg,
uint8_t bc_band_id);
/*
* cvg_bwm_get_bc_period() - get current beacon period
* @vdev: pointer to vdev
*
* return:
* beacon period. unit is 1ms.
*/
uint32_t cvg_bwm_get_bc_period(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_set_fb() - set frequency band
* @param vdev: pointer to vdev
* @param freq_band_id: new frequency band ID to be set.
* @retval: 0 -- success
* @retval: otherwise -- error code
*/
uint32_t cvg_bwm_set_fb(cvg_vdev_t *vdev, uint8_t freq_band_id);
/**
* @brief cvg_bwm_get_fb() - gets the currently used frequency band information.
* @param vdev: pointer to vdev
* @retval: currently used frequency band id.
*/
uint8_t cvg_bwm_get_fb(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_init_fb() - initialize freq band ID.
* @param vdev: pointer to vdev
*/
void cvg_bwm_init_fb(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_config_self_fb() - set frequency band to MAC layer
* @param vdev: pointer to vdev
* @param freq_band_id: new frequency band ID to be set.
* @param lock: if set, band will be locked.
* @return:
* ERR_OK - success
* otherwise - see ERR_XXX
*/
uint32_t cvg_bwm_config_self_fb(cvg_vdev_t *vdev, uint8_t freq_band_id,
uint8_t lock);
/**
* @brief cvg_bwm_fg_chg_timeout_handle() - frequency band change timeout
* fuction.
* @param vdev: pointer to vdev
* @return:
* ERR_OK - success
* otherwise - see ERR_XXX
*/
uint32_t cvg_bwm_fb_chg_timeout_handle(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_set_ts_reuse() - set reuse time solt flag. the flag allow to
* reuse the time slot if we miss beacons for
* following beacon periods to improve channel
* utilization.
* @param vdev: pointer to vdev
* @param enable: non-zero to enable reuse time solt. 0 to disable
* reuse time solt.
*/
void cvg_bwm_set_ts_reuse(cvg_vdev_t *vdev, uint8_t enable);
/**
* @brief cvg_bwm_is_ts_reuse() - check if reuse time solt flag is enabled.
* @param vdev: pointer to vdev
* @retval: 0 -- reuse time solt is disable
* @retval: otherwise -- reuse time solt is enable
*/
uint8_t cvg_bwm_is_ts_reuse(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_is_rf_update() - check if rf channel change info changed
* @param vdev: pointer to vdev
* @retval: 1 -- changed
* @retval: 0 -- not changed
*/
uint8_t cvg_bwm_is_rf_update(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_is_fb_update() - check if frequency band change info changed.
* @param vdev: pointer to vdev
* @retval: 1 -- changed
* @retval: 0 -- not changed
*/
uint8_t cvg_bwm_is_fb_update(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_check_alloc_lid() - check if beacon time slot lid is updated
* @param vdev: pointer to vdev
*/
void cvg_bwm_check_alloc_lid(cvg_vdev_t *vdev);
#if (PLC_SUPPORT_CCO_ROLE)
/*
* cvg_bwm_cco_request_lid() - request bandwidth for specified lid
* @vdev: pointer of vdev
* @lid: specified lid
*
* return:
* 0 - success
* otherwise - error code
*/
uint32_t cvg_bwm_cco_request_lid(cvg_vdev_t *vdev, uint8_t lid);
/*
* cvg_bwm_cco_release_lid() - release bandwidth for specified lid
* @vdev: pointer of vdev
* @lid: specified lid
*/
void cvg_bwm_cco_release_lid(cvg_vdev_t *vdev, uint8_t lid);
/*
* cvg_bwm_cco_bp_check() - check if beacon period parameters need to be updated
* @vdev: pointer to vdev
*/
void cvg_bwm_cco_bp_check(cvg_vdev_t *vdev);
/*
* cvg_bwm_cco_bp_end_alert() - beacon period end alert notification callback
* of bwm module
* @vdev: pointer of vdev
*/
void cvg_bwm_cco_bp_end_alert(cvg_vdev_t *vdev);
/*
* cvg_bwm_get_next_bc_period() - get duration of next beacon period
* @vdev: pointer of vdev
*
* return:
* beacon period. unit is 1ms.
*/
uint32_t cvg_bwm_get_next_bc_period(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_cco_set_csma_slot_average() - set csma slot average
* distribution of each phase.
* @param vdev: pointer to vdev
* @param enable: non-zero to enable csma slot average. 0 to disable
* csma solt average.
*/
void cvg_bwm_cco_set_csma_slot_average(cvg_vdev_t *vdev, uint8_t enable);
/**
* @brief cvg_bwm_cco_get_rf_slot_ratio() - get rf slot ratio,
* the ratio of rf beacon slot duration to hplc beacon slot duration
* @param vdev: pointer to vdev
*
* return: rf slot ratio
*/
uint8_t cvg_bwm_cco_get_rf_slot_ratio(cvg_vdev_t *vdev);
/*
* cvg_bwm_cco_check_cand_proxy_assign_ts() - check if candidate proxy can be
* assigned time slots when node selects the cand proxy to join network
* or roam.
* @vdev: pointer to vdev
* @nw_stat: pco type statistics of whole network
* @sub_stat: sub-pco type statistics of peer
* @peer: pointer to peer
* @cand_proxy: pointer to candidate proxy
* @cand_link: link type of candidate proxy, see PLC_DEV_COMM_TYPE_XXX
*
* return:
* 0 - can't assign ts
* 1 - can assign ts
*/
uint32_t cvg_bwm_cco_check_cand_proxy_assign_ts(cvg_vdev_t *vdev,
uint16_t nw_stat[][CVG_PRM_LINK_BM_P_CNT],
uint16_t sub_stat[][CVG_PRM_LINK_BM_P_CNT], cvg_peer_info_t *peer,
cvg_peer_info_t *cand_proxy, uint8_t cand_link);
/**
* @brief cvg_bwm_cco_get_bcsma_valid() - get if current bcsma is valid
* @param vdev: pointer to vdev
*
* return:
* 0 - bcsma is not valid
* 1 - bcsma is valid
*/
uint8_t cvg_bwm_cco_get_bcsma_valid(cvg_vdev_t *vdev);
/**
* @brief cvg_bwm_cco_is_rf_chging() - check if the rf channel is changing
* @param vdev: pointer to vdev
*
* return:
* 0 - no change
* 1 - rf is changing
*/
uint8_t cvg_bwm_cco_is_rf_chging(cvg_vdev_t *vdev);
#else /* PLC_SUPPORT_CCO_ROLE */
#define cvg_bwm_get_next_bc_period(vdev) (0)
#define cvg_bwm_cco_bp_check(vdev)
#endif /* PLC_SUPPORT_CCO_ROLE */
#ifdef __cplusplus
}
#endif
#endif /* CVG_BWM_H */