632 lines
23 KiB
C
632 lines
23 KiB
C
|
/****************************************************************************
|
||
|
|
||
|
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_NWM_CCO_COMMON_H
|
||
|
#define CVG_NWM_CCO_COMMON_H
|
||
|
|
||
|
/* os shim includes */
|
||
|
#include "os_types.h"
|
||
|
#include "os_mem.h"
|
||
|
#include "os_utils.h"
|
||
|
|
||
|
/* common includes */
|
||
|
#include "iot_module.h"
|
||
|
#include "iot_pkt_api.h"
|
||
|
#include "iot_dbglog_parser.h"
|
||
|
#include "iot_dbglog_api.h"
|
||
|
#include "iot_io.h"
|
||
|
|
||
|
/* public api includes */
|
||
|
#include "cvg_api.h"
|
||
|
#include "plc_protocol.h"
|
||
|
#include "mac_bcm_api.h"
|
||
|
#include "mac_data_api.h"
|
||
|
#include "mac_vdev_api.h"
|
||
|
#include "mac_zc_api.h"
|
||
|
#include "plc_fr.h"
|
||
|
#include "plc_protocol.h"
|
||
|
#include "plc_mac_header.h"
|
||
|
#include "plc_const.h"
|
||
|
#include "plc_mme_assoc.h"
|
||
|
#include "plc_mme_leave_ind.h"
|
||
|
#include "plc_mme_discover_list.h"
|
||
|
#include "plc_mme_tf_sr.h"
|
||
|
#include "plc_mme_proxy_change.h"
|
||
|
#include "plc_mme_nw_conflict.h"
|
||
|
#include "plc_cert_test.h"
|
||
|
#include "plc_mme_heart_beat.h"
|
||
|
|
||
|
/* cvg module internal includes */
|
||
|
#include "cvg.h"
|
||
|
#include "cvg_app.h"
|
||
|
#include "cvg_nwm.h"
|
||
|
#include "cvg_nwm_internal.h"
|
||
|
#include "cvg_msg.h"
|
||
|
#include "cvg_prm.h"
|
||
|
#include "cvg_rt.h"
|
||
|
#include "cvg_bwm.h"
|
||
|
#include "cvg_security.h"
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
#if (PLC_SUPPORT_CCO_ROLE)
|
||
|
|
||
|
/* heart beat offline check count.
|
||
|
* according to smart grid spec, heart beat period is 2 * route period.
|
||
|
* if sta is inactive for 1 heart beart period, cco should treat sta
|
||
|
* as offline.
|
||
|
*/
|
||
|
#define CVG_NWM_HB_OFFLINE_CNT (2 * (CVG_RT_PARTIAL_RP_NUM + 1))
|
||
|
|
||
|
/* heart beat kickout check count.
|
||
|
* according to smart grid spec, heart beat period is 2 * route period.
|
||
|
* if sta is inactive for consecutive 4 heart beart period, cco should
|
||
|
* broadcast mme leave ind mme to kickout the sta.
|
||
|
*/
|
||
|
#define CVG_NWM_HB_KICKOUT_CNT (8 * (CVG_RT_PARTIAL_RP_NUM + 1))
|
||
|
|
||
|
/* pco out of sync check count.
|
||
|
* for every traffic success ratio report period, pco shall report tf_sr with
|
||
|
* its direct sub sta. if one pco report tf_sr with a sta that has a different
|
||
|
* pco in the tree maintained by cco. it means pco of the sta is out of sync.
|
||
|
* this may happen due to proxy change conf mme lost. this value define after
|
||
|
* how many consecutive tf_sr report period that cco see this issue, cco will
|
||
|
* confirm the issue really exist and shall start to fix it.
|
||
|
* the unit is 1 tf_sr report period.
|
||
|
*/
|
||
|
#define CVG_NWM_PCO_OUT_OF_SYNC_CNT (6)
|
||
|
|
||
|
/* CCO device start listen duration, unit is 1ms */
|
||
|
#define CVG_CCO_SL_DUR (10 * 1000)
|
||
|
|
||
|
/* CCO device NID conflict monitor duration for sta report case. according
|
||
|
* to spec, the value should be 30 minutes. if CCO keep receiving conflict
|
||
|
* report from sta during this time, CCO should restart the network.
|
||
|
* unit is 1ms.
|
||
|
*/
|
||
|
#define CVG_CCO_NID_CONFLICT_DUR (30 * 60 * 1000)
|
||
|
|
||
|
/* CCO device RF conflict monitor duration for sta report case. according
|
||
|
* to spec, the value should be 30 minutes. if CCO keep receiving conflict
|
||
|
* report from sta during this time, CCO should restart the network.
|
||
|
* unit is 1ms.
|
||
|
*/
|
||
|
#define CVG_CCO_RF_CONFLICT_DUR (30 * 60 * 1000)
|
||
|
|
||
|
/* define the NID conflict monitor counter N for sta report case.
|
||
|
* if no NID conflict from sta for N time long, stop NID conflict
|
||
|
* monitor timer. the unit is 1s.
|
||
|
*/
|
||
|
#define CVG_CCO_NID_CONFLICT_CD_DUR (400)
|
||
|
|
||
|
/* define the RF conflict monitor counter N for sta report case.
|
||
|
* if no RF conflict from sta for N time long, stop RF conflict
|
||
|
* monitor timer. the unit is 1s.
|
||
|
*/
|
||
|
#define CVG_CCO_RF_CONFLICT_CD_DUR (400)
|
||
|
|
||
|
/* CCO device gather assoc request duration.
|
||
|
* the unit is 1ms.
|
||
|
*/
|
||
|
#define CVG_CCO_ASSOC_REQ_GATHER_DUR (200)
|
||
|
|
||
|
/* if no assoc ongoing for N concesutive beacon periods, CCO should set
|
||
|
* assoc done flag in beacon to 1. This macro defined the N. According to
|
||
|
* cert test requirement, this value should be 3.
|
||
|
*/
|
||
|
#define CVG_CCO_ASSOC_DONE_DUR (10)
|
||
|
|
||
|
/* define the delay value of leave indication mme for each kick out.
|
||
|
* the unit is 1 beacon.
|
||
|
*/
|
||
|
#define CVG_CCO_LEAVE_IND_DELAY_DUR (2)
|
||
|
|
||
|
/* define maximum number of peers cco can kick out in one leave ind mme */
|
||
|
#define CVG_NWM_KICKOUT_MAX_CNT 64
|
||
|
|
||
|
/* if still received heart beat info of a peer which has been kicked out
|
||
|
* from the network for more than XXX time, CCO will broadcast kick out info
|
||
|
* to the whole network again. this macro defined the XXX value. unit is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_KICKOUT_INTERVAL (10 * 60)
|
||
|
|
||
|
/* uplink traffic successful ratio kickout check count.
|
||
|
* according to smart grid spec, tf_sr_report period is 4 * route period.
|
||
|
* if sta is inactive for consecutive (3 * 4) route period, cco should
|
||
|
* broadcast mme leave ind mme to kickout the sta. it is used to fix the problem
|
||
|
* that traffic successful ratio of ZhongChen sta is 0, but not leave the
|
||
|
* network and not roaming.
|
||
|
*/
|
||
|
#define CVG_NWM_UPLINK_INACTIVE_KICKOUT_CNT (3 * 4)
|
||
|
|
||
|
/* if number of PCO in the network is larger than this value, CCO use
|
||
|
* PCO hint inactively.
|
||
|
*/
|
||
|
#define CVG_NWM_PCO_HINT_ACTIVE_CNT_TH (CVG_PCO_MAX_CNT / 6)
|
||
|
|
||
|
/* if rx snr from the peer is less than this value, CCO will try to appoint
|
||
|
* other device as PCO to the peer. unit is 1 db.
|
||
|
*/
|
||
|
#define CVG_NWM_USE_CCO_AS_PCO_SNR_TH (0)
|
||
|
|
||
|
/* define the cco received minimum snr to ensure successful association */
|
||
|
#define CVG_NWM_CCO_ASSOC_SUCCESS_SNR_TH (15)
|
||
|
|
||
|
/* after CCO started, it only allows STA with to CCO traffic success ratio
|
||
|
* equal or larger than nwm->desc.cco.allowed_cco_tf_sr to join the network.
|
||
|
* After some time, CCO should lower the criteria to allow more STA with worse
|
||
|
* to CCO traffic success ratio to join the network. This macro defined the
|
||
|
* duration after which if no more device join the network, CCO should lower the
|
||
|
* allowed to CCO traffic success ratio criteria. the larger the value, the
|
||
|
* lower the speed to finish the whole network formation in worse network. In
|
||
|
* the opposite, the smaller the value, the smaller the chance to create a
|
||
|
* better network with good route.
|
||
|
* the unit is route period.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_LOWER_CRITERIA_TH 5
|
||
|
|
||
|
/* define the pace to lower the allowed to cco traffic success ratio */
|
||
|
#define CVG_NWM_LOWER_ALLOWED_CCO_TF_SR_PACE 15
|
||
|
|
||
|
/* define neighbor network info life time for cco role device. if local cco
|
||
|
* role device hasn't seen this network till life time expired, the network
|
||
|
* info will be deleted. the unit is 1 ms.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_NN_INFO_EXPIRED_DUR (10 * 60 * 1000)
|
||
|
|
||
|
/* define neighbor network rf info life time for cco role device. if local cco
|
||
|
* role device hasn't seen this rf network till life time expired, the rf
|
||
|
* info will be deleted. the unit is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_RF_INFO_EXPIRED_DUR (10 * 60)
|
||
|
|
||
|
/* if a peer try to assoc to us multiple times in a short duration, use
|
||
|
* assoc conf mme for assoc response instead of assoc gathered indication.
|
||
|
* this macro defined the duration. unit is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_FORCE_ASSOC_RSP_DUR 10
|
||
|
|
||
|
/* if a peer try to assoc to us multiple times with same p2p number in a while,
|
||
|
* we will ignore this request, otherwise accept the requset. unit is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_IGNORE_DUP_ASSOC_RSP_DUR 20
|
||
|
|
||
|
/* if a peer try to change proxy multiple times with same p2p number in a while,
|
||
|
* we will ignore this request, otherwise accept the requset. unit is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_IGNORE_DUP_PROXY_CH_RSP_DUR 20
|
||
|
|
||
|
/* define if cco support association request packet carry zc ntb for
|
||
|
* physical phase ident.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_PHY_PHASE_IDENT_ASSOC_EN 1
|
||
|
|
||
|
/* define if network formation done check threshold. if no STA join the network
|
||
|
* for more than this duration, CCO will set network formation done flag. unit
|
||
|
* is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_NW_FMT_DONE_DUR (5 * 60)
|
||
|
|
||
|
/* define if whole network route learning done check threshold. after network
|
||
|
* formation done, CCO will set route learning done flag after this duration.
|
||
|
* unit is 1 route period.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_NW_ROUTE_LEARN_DONE_DUR (5)
|
||
|
|
||
|
/* define allowed minimum duration for two periodically roaming request from
|
||
|
* same STA. if a STA request periodical roaming frequently, CCO will ignore
|
||
|
* the request. unit is 1s.
|
||
|
*/
|
||
|
#define CVG_CCO_ALLOWED_ROAM_DUR_MIN (60 * 15)
|
||
|
|
||
|
/* if CCO device detect NID conflict X times in one route period,
|
||
|
* restart the whole network with new NID. This macro defined the X.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_NID_CONFLICT_TH (3)
|
||
|
|
||
|
/* if CCO device detect RF conflict X times in one route period,
|
||
|
* reselect free rf channel as own channel. This macro defined the X.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_RF_CONFLICT_TH (10)
|
||
|
|
||
|
/* if CCO runs longer than this time threshold, auto high power is allowed
|
||
|
* if detected connected hotline. uint is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_HOT_HIGH_POWER_TIME_TH (600)
|
||
|
|
||
|
/* if CCO runs longer than this time threshold, auto high power is allowed
|
||
|
* if detected connected hotline. uint is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_HOT_HIGH_POWER_LONG_TIME_TH (30 * 60)
|
||
|
|
||
|
/* define the freq band detection send duration, unit is 1s. */
|
||
|
#define CVG_NWM_CCO_FB_DETECT_TX_DUR (3 * 60)
|
||
|
/* define the freq band detection stop sending duration, unit is 1s. */
|
||
|
#define CVG_NWM_CCO_FB_DETECT_NO_TX_DUR (3 * 60)
|
||
|
/* define the duration of application layer load stability, unit is 1s. */
|
||
|
#define CVG_NWM_CCO_APP_LOAD_STABLE_DUR (5 * 60)
|
||
|
/* define the freq band detection maximum delay enabled duration, unit is 1s */
|
||
|
#define CVG_NWM_CCO_FB_DETECT_DELAY_MAX (30 * 60)
|
||
|
/* define the freq band detection delay enabled threshold. network scale level
|
||
|
* is calculated by this value. The higher the level, the longer the delay time.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_FB_DETECT_DELAY_THRESHOLD 4
|
||
|
/* define the freq band detection delay pace according to the network scale,
|
||
|
* unit is 1s.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_FB_DETECT_DELAY_PACE (5 * 60)
|
||
|
|
||
|
/* define the boardcast packets tx link type, broadcast packets can sent only
|
||
|
* on hplc, rf or dual link.
|
||
|
*/
|
||
|
#define CVG_NWM_CCO_BCAST_LINK_HPLC (0)
|
||
|
#define CVG_NWM_CCO_BCAST_LINK_RF (1)
|
||
|
#define CVG_NWM_CCO_BCAST_LINK_DUAL (2)
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_cl_check_msdu_rec() - check if this is a duplicate
|
||
|
* connectionless sof frame.
|
||
|
* @param nwm: pointer to nwm vdev
|
||
|
* @param addr: original mac address
|
||
|
* @param msdu_sn: MSDU sequence number
|
||
|
* @param reboot_cnt: reboot count
|
||
|
* @retval: return non-zero if check failed
|
||
|
*/
|
||
|
uint8_t cvg_nwm_cco_cl_check_msdu_rec(cvg_nwm_vdev_t *nwm,
|
||
|
uint8_t *addr, uint16_t msdu_sn, uint8_t reboot_cnt);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_check_msdu_rec() - check if this is a duplicate sof frame.
|
||
|
* @param nwm: pointer to nwm vdev
|
||
|
* @param org_src_tei: TEI of original source STA
|
||
|
* @param reboot_cnt: reboot count
|
||
|
* @param msdu_sn: MSDU sequence number
|
||
|
*
|
||
|
* @retval: return non-zero if check failed
|
||
|
*/
|
||
|
uint32_t cvg_nwm_cco_check_msdu_rec(cvg_nwm_vdev_t *nwm, tei_t org_src_tei,
|
||
|
uint8_t reboot_cnt, uint16_t msdu_sn);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_stop_sl_timer() - stop conflict network listen timer
|
||
|
* @param nwm: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_stop_sl_timer(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_stop_rf_sl_timer() - stop conflict rf listen timer
|
||
|
* @param nwm: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_stop_rf_sl_timer(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_stop_gather_timer() - stop assoc gather timer
|
||
|
* @param nwm: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_stop_gather_timer(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_stop_rf_gather_timer() - stop rf assoc gather timer
|
||
|
* @param nwm: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_stop_rf_gather_timer(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_sl_func() - conflict network listen timeout function
|
||
|
* @param timer_id: id of conflict network listen timer
|
||
|
* @param arg: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_sl_func(timer_id_t timer_id, void *arg);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_rf_sl_func() - conflict rf listen timeout function
|
||
|
* @param timer_id: id of conflict rf listen timer
|
||
|
* @param arg: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_rf_sl_func(timer_id_t timer_id, void *arg);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_assoc_gather_func() - assoc request gather timeout
|
||
|
* function
|
||
|
* @param timer_id: id of assoc gather timer
|
||
|
* @param arg: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_assoc_gather_func(timer_id_t timer_id, void *arg);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_rf_assoc_gather_func() - rf assoc request gather timeout
|
||
|
* function
|
||
|
* @param timer_id: id of assoc gather timer
|
||
|
* @param arg: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_rf_assoc_gather_func(timer_id_t timer_id, void *arg);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_zc_notify_func() - cco zero-cross NTB area notification
|
||
|
* timeout function.
|
||
|
* @param timer_id: id of ntb area notification timer
|
||
|
* @param arg: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_zc_notify_func(timer_id_t timer_id, void *arg);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_gather_assoc() - gather information of 1 level station
|
||
|
* (non pco)that accepted.
|
||
|
* @param nwm: - pointer of nwm
|
||
|
* @param peer: - pointer of peer
|
||
|
* @param mac: - station mac.
|
||
|
* @param random: - assoc random.
|
||
|
* @param phase_1: - first possible phase
|
||
|
* @link_type: - link type between station and proxy
|
||
|
*/
|
||
|
void cvg_nwm_cco_gather_assoc(cvg_nwm_vdev_t *nwm, cvg_peer_info_t *peer,
|
||
|
uint8_t *mac, uint32_t random, uint8_t phase_1, uint8_t link_type);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_get_new_path_sn() - acquire one new path serial number
|
||
|
* @param nwm: pointer of nwm
|
||
|
*
|
||
|
* @retval new path serial number
|
||
|
*/
|
||
|
uint32_t cvg_nwm_cco_get_new_path_sn(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_p2p_sn_check() - check if p2p sn is acceptable. return 1
|
||
|
* if the new sn is acceptable
|
||
|
* @param curr_sn: current sn
|
||
|
* @param new_sn: new sn
|
||
|
*
|
||
|
* @retval 0 -- new sn is unacceptable
|
||
|
* @retval 1 -- new sn is acceptable
|
||
|
*/
|
||
|
uint8_t cvg_nwm_cco_p2p_sn_check(uint32_t curr_sn,
|
||
|
uint32_t new_sn);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_gen_sub_sta_info() - generate sub sta info for
|
||
|
* a peer. the bm will carry the tei info of the sub sta for return case.
|
||
|
* @param nwm: pointer of nwm
|
||
|
* @param peer: pointer of peer
|
||
|
* @param bm: bitmap of sub sta tei info for return
|
||
|
*
|
||
|
* @retval actual buffer used.
|
||
|
*/
|
||
|
uint32_t cvg_nwm_cco_gen_sub_sta_info(cvg_nwm_vdev_t *nwm,
|
||
|
cvg_peer_info_t *peer, cvg_tei_map_t *bm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_add_nid() - add a neighbor network info except
|
||
|
* rf info into nid list
|
||
|
* @param nwm: pointer of nwm
|
||
|
* @param nid: network id
|
||
|
* @param sp_flag_valid: flag to mark if sp_flag is valid
|
||
|
* @param sp_flag: set to 1 if remote device can't see local device
|
||
|
* @param bandwidth_valid: flag to mark if bandwidth is valid
|
||
|
* @param bandwidth: bandwidth taken by neighbour network in millisecond
|
||
|
* @param addr: address of the network
|
||
|
*/
|
||
|
void cvg_nwm_cco_add_nid(cvg_nwm_vdev_t *nwm, uint32_t nid,
|
||
|
uint8_t sp_flag_valid, uint8_t sp_flag, uint8_t bandwidth_valid,
|
||
|
uint32_t bandwidth, uint8_t *addr);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_get_nn_info_by_nid() - get a neighbor network info by nid
|
||
|
* @param nwm: pointer of nwm
|
||
|
* @param nid: network id
|
||
|
* @retval: NULL - no corresponding neighbor network,
|
||
|
* othersie - cvg_nwm_nn_cco_info_t structure pointer
|
||
|
*/
|
||
|
cvg_nwm_nn_cco_info_t *cvg_nwm_cco_get_nn_info_by_nid(cvg_nwm_vdev_t *nwm,
|
||
|
uint32_t nid);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_add_nid_ext() - add a neighbor network info include
|
||
|
* rf info into nid list
|
||
|
* @param nwm: pointer of nwm
|
||
|
* @param nid: network id
|
||
|
* @param rf_channel: rf channel
|
||
|
* @param sp_flag_valid: flag to mark if sp_flag is valid
|
||
|
* @param sp_flag: set to 1 if remote device can't see local device
|
||
|
* @param bandwidth: bandwidth taken by neighbour network in millisecond
|
||
|
* @param addr: address of the network
|
||
|
* @param rf_option: rf option
|
||
|
*/
|
||
|
void cvg_nwm_cco_add_nid_ext(cvg_nwm_vdev_t *nwm, uint32_t nid,
|
||
|
uint8_t rf_channel, uint8_t sp_flag_valid, uint8_t sp_flag,
|
||
|
uint32_t bandwidth, uint8_t *addr, uint8_t rf_option);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_restart() - move cco role device back to init
|
||
|
* status
|
||
|
* @param nwm: pointer of nwm
|
||
|
* @param reason: restart reason. see CVG_VDEV_START_XXX
|
||
|
*/
|
||
|
void cvg_nwm_cco_restart(cvg_nwm_vdev_t *nwm, uint8_t reason);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_nn_check() - check if any neighbor network info
|
||
|
* expired
|
||
|
* @param nwm: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_nn_check(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief check nid list report from mac layer against local nid.
|
||
|
* @param nwm: pointer of nwm
|
||
|
* @param rpt: nid list report from mac layer
|
||
|
* @retval: 1 - if nid conflict detected with local device
|
||
|
* @retval: 0 - if no nid conflict detected
|
||
|
*/
|
||
|
uint8_t cvg_nwm_cco_nid_rpt_check(cvg_nwm_vdev_t *nwm,
|
||
|
mac_nid_list_rpt_t *rpt);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_kickout_peer() - kick out peer.
|
||
|
* @param nwm: pointer to nwm
|
||
|
* @param cnt count of kickout peer list
|
||
|
* @param peer kickout peer list
|
||
|
* @param reason kickout reason
|
||
|
*/
|
||
|
void cvg_nwm_cco_kickout_peer(cvg_nwm_vdev_t *nwm, uint16_t cnt,
|
||
|
cvg_peer_info_t *peer[], uint16_t reason);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_kickout_unknown_peer() - kick out unknown peer.
|
||
|
* @param nwm: pointer to nwm
|
||
|
* @param addr kickout peer addr list
|
||
|
* @param reason kickout reason
|
||
|
*/
|
||
|
void cvg_nwm_cco_kickout_unknown_peer(cvg_nwm_vdev_t *nwm, uint16_t cnt,
|
||
|
uint8_t addr[][IOT_MAC_ADDR_LEN], uint16_t reason);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_hb_check() - heart beat check.
|
||
|
* @param nwm: pointer to nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_hb_check(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_freq_band_detect_check() - freq band detect check.
|
||
|
* @param nwm: pointer to nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_freq_band_detect_check(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_compare_proxy_hplc() - compare which hplc proxy is better,
|
||
|
* both proxys should be hplc link
|
||
|
* @param nwm: pointer to nwm
|
||
|
* @param pco1: pointer of pco 1, whose link type is hplc link
|
||
|
* @param pco2: pointer of pco 2, whose link type is hplc link
|
||
|
* @param prefer_l_phase: preferred logical phase
|
||
|
* @param prefer_p_phase: preferred physical phase
|
||
|
*
|
||
|
* @retval better pco
|
||
|
*/
|
||
|
pco_link_info_t *cvg_nwm_cco_compare_proxy_hplc(cvg_nwm_vdev_t *nwm,
|
||
|
pco_link_info_t *pco1, pco_link_info_t *pco2,
|
||
|
uint8_t prefer_l_phase, uint8_t prefer_p_phase);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_select_proxy() - select main proxy for sta from
|
||
|
* the cand_proxy list. the cand_proxy array must be not smaller than
|
||
|
* CANDIDATE_PROXY_COUNT.
|
||
|
* @param nwm: pointer of nwm
|
||
|
* @param peer: pointer of peer
|
||
|
* @param cand_proxy: cand_proxy list
|
||
|
* @param proxy: the proxy selected
|
||
|
* @param link_type: link type between station and selected proxy
|
||
|
* @param next_hop: next hop hint for proxy selection
|
||
|
* @param cco_rx_snr: cco rx snr from the peer
|
||
|
* @param hw_reset: flag to mark if hw reset happened since last proxy
|
||
|
* selection.
|
||
|
*
|
||
|
* @retval 0 -- for success case
|
||
|
* @retval othersie -- error code
|
||
|
*/
|
||
|
uint8_t cvg_nwm_cco_select_proxy(cvg_nwm_vdev_t *nwm, cvg_peer_info_t *peer,
|
||
|
pco_link_info_t cand_proxy[], cvg_peer_info_t **proxy, uint8_t *link_type,
|
||
|
tei_t next_hop, int8_t cco_rx_snr, uint8_t hw_reset);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_topo_check() - check whole network topologic to
|
||
|
* see if any network association related parameters need to be changed.
|
||
|
* @param nwm: pointer of nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_topo_check(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_update_bc() - update beacon template to mac
|
||
|
* @param nwm: pointer to nwm
|
||
|
* @param new_bp_req: if a new beacon period needed
|
||
|
*
|
||
|
* @retval 0 -- for success case
|
||
|
* @retval othersie -- error code
|
||
|
*/
|
||
|
uint32_t cvg_nwm_cco_update_bc(cvg_nwm_vdev_t *nwm, uint8_t new_bp_req);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_bp_end_alert() - beacon period alert,
|
||
|
* clean up leaving peers
|
||
|
* @param nwm: pointer to nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_bp_end_alert(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cco role init state handler
|
||
|
* @param nwm: pointer to nwm
|
||
|
* @param event: event to be handled
|
||
|
* @param data: pointer to event data
|
||
|
*
|
||
|
* @retval:
|
||
|
* next state of the state machine
|
||
|
*/
|
||
|
cvg_nwm_vdev_cco_state_t cvg_nwm_vdev_sm_cco_init(cvg_nwm_vdev_t *nwm,
|
||
|
cvg_vdev_event_t event, void *data);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_conn_less_handle() - handling connectionless data.
|
||
|
* @param nwm: - pointer to nwm vdev
|
||
|
* @param buf: - buffer containing connectionless data
|
||
|
* @param data: - pointer to connectionless data
|
||
|
* @param len: - data len.
|
||
|
* @param app_id: - application id of this msdu containing connectionless
|
||
|
* data.
|
||
|
* @retval: next state of the state machine.
|
||
|
*/
|
||
|
cvg_nwm_vdev_cco_state_t cvg_nwm_cco_conn_less_handle(
|
||
|
cvg_nwm_vdev_t *nwm, iot_pkt_t *buf, uint8_t *data, uint32_t len,
|
||
|
uint8_t app_id);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_cl_cache_clear() - clearing up msdu cache
|
||
|
* in conn less mode
|
||
|
* @param nwm: pointer to nwm
|
||
|
*/
|
||
|
void cvg_nwm_cco_cl_cache_clear(cvg_nwm_vdev_t *nwm);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_get_peer_bcast_link() - get peer tx link type of bcast
|
||
|
* packets
|
||
|
* @param peer: pointer to peer
|
||
|
* @retal: see CVG_NWM_CCO_BCAST_LINK_XXX
|
||
|
*/
|
||
|
uint8_t cvg_nwm_cco_get_peer_bcast_link(cvg_peer_info_t *peer);
|
||
|
|
||
|
/*
|
||
|
* @brief cvg_nwm_cco_is_pco_changed() - check if pco tei and link type of peer
|
||
|
* have changed.
|
||
|
* @param peer: pointer to peer
|
||
|
* @param new_pco: new pco tei of peer
|
||
|
* @param new_pco_link: new pco link type of peer
|
||
|
* @retval 0 -- is not changed
|
||
|
* othersie -- is changed
|
||
|
*/
|
||
|
static inline uint8_t cvg_nwm_cco_is_pco_changed(cvg_peer_info_t *peer,
|
||
|
tei_t new_pco, uint8_t new_pco_link)
|
||
|
{
|
||
|
return (peer->proxy != new_pco) || (peer->pco_link_type != new_pco_link);
|
||
|
}
|
||
|
|
||
|
#endif /* PLC_SUPPORT_CCO_ROLE */
|
||
|
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif /* CVG_NWM_CCO_COMMON_H */
|