2379 lines
		
	
	
		
			73 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			2379 lines
		
	
	
		
			73 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_PRM_H
 | |
| #define CVG_PRM_H
 | |
| 
 | |
| /* os shim includes */
 | |
| #include "os_types.h"
 | |
| #include "os_utils.h"
 | |
| 
 | |
| /* common includes */
 | |
| #include "iot_config.h"
 | |
| 
 | |
| /* public api includes */
 | |
| #include "cvg_api.h"
 | |
| #include "plc_fr.h"
 | |
| #include "plc_protocol.h"
 | |
| #include "plc_mme_assoc.h"
 | |
| #include "plc_const.h"
 | |
| 
 | |
| /* cvg module internal includes */
 | |
| #include "cvg.h"
 | |
| #include "cvg_bitmap.h"
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| 
 | |
| /* peer state definition */
 | |
| #define CVG_PEER_S_INVAL        0  /* invalid state */
 | |
| #define CVG_PEER_S_ASSOCING     1  /* peer is associating with the network */
 | |
| #define CVG_PEER_S_ASSOCED      2  /* peer associated with the network */
 | |
| #define CVG_PEER_S_OFFLINE      3  /* peer is in offline status */
 | |
| #define CVG_PEER_S_LEAVING      4  /* peer is in leaving status */
 | |
| #define CVG_PEER_S_DISASSOCED   5  /* peer is dis-associated with the network */
 | |
| 
 | |
| #if RUN_IN_PSRAM
 | |
| 
 | |
| /* define the per peer msdu record array size */
 | |
| #define CVG_PEER_MSDU_REC_CNT   16
 | |
| 
 | |
| #else /* RUN_IN_PSRAM */
 | |
| 
 | |
| /* define the per peer msdu record array size */
 | |
| #define CVG_PEER_MSDU_REC_CNT   8
 | |
| 
 | |
| #endif /* RUN_IN_PSRAM */
 | |
| 
 | |
| #if (PLC_SUPPORT_PCO_HIS)
 | |
| 
 | |
| #if (HPLC_RF_DEV_SUPPORT)
 | |
| 
 | |
| /* define the pco history record array size */
 | |
| #define CVG_PEER_PCO_HIS_DEPTH          12
 | |
| 
 | |
| #else /* HPLC_RF_DEV_SUPPORT */
 | |
| 
 | |
| #define CVG_PEER_PCO_HIS_DEPTH          6
 | |
| 
 | |
| #endif /* HPLC_RF_DEV_SUPPORT */
 | |
| 
 | |
| #else /* PLC_SUPPORT_PCO_HIS */
 | |
| 
 | |
| #define CVG_PEER_PCO_HIS_DEPTH          0
 | |
| 
 | |
| #endif /* PLC_SUPPORT_PCO_HIS */
 | |
| 
 | |
| /* define the traffic success ratio record array size */
 | |
| #define CVG_PEER_TF_SR_HIS_DEPTH        8
 | |
| 
 | |
| /* define pco history count threshold for hint link evaluation */
 | |
| #define CVG_PEER_HINT_LINK_HIS_CNT_TH   3
 | |
| 
 | |
| /* define HPLC traffic success ratio bad threshold */
 | |
| #define CVG_PEER_HPLC_TF_SR_BAD_TH      25
 | |
| 
 | |
| /* define RF traffic success ratio bad threshold */
 | |
| #define CVG_PEER_RF_TF_SR_BAD_TH        10
 | |
| 
 | |
| /* define the peer direct sub node link type */
 | |
| /* link type of direct sub node is invalid */
 | |
| #define CVG_PEER_SUB_LINK_INVALID       0
 | |
| /* link type of direct sub node is hplc */
 | |
| #define CVG_PEER_SUB_LINK_HPLC          1
 | |
| /* link type of direct sub node is rf */
 | |
| #define CVG_PEER_SUB_LINK_RF            2
 | |
| /* link type of direct sub node is hplc and rf */
 | |
| #define CVG_PEER_SUB_LINK_DUAL          3
 | |
| 
 | |
| /* define the bitmap of proxy node link type */
 | |
| /* device type: hplc, direct sub node link type: hplc  */
 | |
| #define CVG_PRM_LINK_BM_P_HPLC          0
 | |
| /* device type: rf, direct sub node link type: rf  */
 | |
| #define CVG_PRM_LINK_BM_P_RF            1
 | |
| /* device type: dual mode, direct sub node link type: hplc  */
 | |
| #define CVG_PRM_LINK_BM_P_DUAL_HPLC     2
 | |
| /* device type: dual mode, direct sub node link type: rf  */
 | |
| #define CVG_PRM_LINK_BM_P_DUAL_RF       3
 | |
| /* device type: dual mode, direct sub node link type: hplc and rf  */
 | |
| #define CVG_PRM_LINK_BM_P_DUAL_DUAL     4
 | |
| /* bitmap count */
 | |
| #define CVG_PRM_LINK_BM_P_CNT           5
 | |
| 
 | |
| /* define the bitmap of discover node link type */
 | |
| /* device type: hplc */
 | |
| #define CVG_PRM_LINK_BM_S_HPLC          0
 | |
| /* device type: rf */
 | |
| #define CVG_PRM_LINK_BM_S_RF            1
 | |
| /* device type: dual mode */
 | |
| #define CVG_PRM_LINK_BM_S_DUAL          2
 | |
| /* bitmap count */
 | |
| #define CVG_PRM_LINK_BM_S_CNT           3
 | |
| 
 | |
| /* define receive bitmap bit count, the count should be a multiple of 8 */
 | |
| #define CVG_PRM_RF_RCV_BM_BIT_CNT       32
 | |
| 
 | |
| /* peer authorized state definition */
 | |
| #define CVG_PEER_AUTH_INVAL           0
 | |
| #define CVG_PEER_AUTH_DAK_PENDING     1
 | |
| #define CVG_PEER_AUTH_DAK_SUCCESS     2
 | |
| #define CVG_PEER_AUTH_NEK_SUCCESS     3
 | |
| 
 | |
| /* cvg layer peer descriptor */
 | |
| #if PLC_SUPPORT_CCO_ROLE == 0
 | |
| #pragma pack(push)
 | |
| #pragma pack(1)
 | |
| #endif
 | |
| 
 | |
| /* peer zero-cross ntb info */
 | |
| typedef struct _cvg_peer_zc_info {
 | |
|     /* the farthest ntb difference between cco and sta in historical statistics
 | |
|      */
 | |
|     uint32_t his_farthest_diff;
 | |
|     /* the closest ntb difference between cco and sta in historical statistics
 | |
|      */
 | |
|     uint32_t his_closest_diff;
 | |
|     /* the max ntb difference between max ntb and min ntb in a statistic */
 | |
|     uint32_t his_diff_max_min;
 | |
|     /* the max ntb difference between cco and sta in a statistic */
 | |
|     int32_t diff_max;
 | |
|     /* the min ntb difference between cco and sta in a statistic */
 | |
|     int32_t diff_min;
 | |
|     /* the average ntb difference between cco and sta in a statistic */
 | |
|     int32_t diff_avg;
 | |
| } cvg_peer_zc_info_t;
 | |
| 
 | |
| /* pco history info */
 | |
| typedef struct _cvg_peer_pco_his {
 | |
|     /* next index to write the new tf_sr */
 | |
|     uint8_t     tf_sr_idx       :4,
 | |
|     /* number of valid tf_sr in the array */
 | |
|                 tf_sr_cnt       :4;
 | |
|     /* number of associations through this pco */
 | |
|     uint8_t     assoc_cnt       :7,
 | |
|     /* flag to mark if the pco link is rf link */
 | |
|                 is_rf           :1;
 | |
|     /* traffic success ratio history with the pco */
 | |
|     uint8_t     tf_sr[CVG_PEER_TF_SR_HIS_DEPTH];
 | |
|     /* mac adress of the pco */
 | |
|     uint8_t     addr[IOT_MAC_ADDR_LEN];
 | |
| } cvg_peer_pco_his_t;
 | |
| 
 | |
| /* peer vendor info comes from assoc request or config */
 | |
| typedef struct _cvg_peer_vendor_info {
 | |
|     /* build version info */
 | |
|     uint32_t    build_ver;
 | |
|     union {
 | |
|         /* vendor info param, the same as the following field */
 | |
|         uint32_t    info_param;
 | |
|         struct {
 | |
|             /* flag to mark if tsfm info is valid */
 | |
|             uint32_t    tsfm_valid           :1,
 | |
|             /* last network selection start reason */
 | |
|                         start_reason         :6,
 | |
|             /* firmware version type, 0 - release, 1 - debug */
 | |
|                         ver_type             :1,
 | |
|             /* layout definition */
 | |
|                         mtd_type             :4,
 | |
|             /* flag to mark if psram enabled */
 | |
|                         psram_enable         :1,
 | |
|             /* flag to mark if zc edge is falling */
 | |
|                         zc_edge_is_falling   :1,
 | |
|             /* flag to mark if support large number of directly
 | |
|              * connected sub-sta
 | |
|              */
 | |
|                         sub_sta_large        :1,
 | |
|             /* reserved for future */
 | |
|                         rsvd                 :1,
 | |
|             /* mark to make sure CCO and STA are belong to same vendor */
 | |
|                         vendor_mark          :16;
 | |
|         };
 | |
|     };
 | |
| #if PLC_SUPPORT_HW_TSFM_DETECT_CACHE
 | |
|     /* tsfm address info */
 | |
|     uint8_t     tsfm_addr[IOT_MAC_ADDR_LEN];
 | |
| #endif
 | |
| } cvg_peer_vendor_info_t;
 | |
| 
 | |
| /* peer version info comes from assoc request or config */
 | |
| typedef struct _cvg_peer_ver_info {
 | |
|     /* software version */
 | |
|     uint16_t    sw_ver;
 | |
|     /* software build time */
 | |
|     uint16_t    build_time_y    :7,
 | |
|                 build_time_m    :4,
 | |
|                 build_time_d    :5;
 | |
|     /* module vendor ID */
 | |
|     uint16_t    vendor_id;
 | |
| #if PLC_SUPPORT_VER_INFO_COMP
 | |
|     /* see SYSTEM_BOOT_REASON_XXX */
 | |
|     uint8_t     boot_reason;
 | |
|     /* boot version */
 | |
|     uint8_t     boot_ver;
 | |
|     /* chip ID */
 | |
|     uint16_t    chip_id;
 | |
| #endif
 | |
| } cvg_peer_ver_info_t;
 | |
| 
 | |
| /* peer authorized state info */
 | |
| typedef struct _cvg_peer_auth_info {
 | |
|     /* authorized mac adress */
 | |
|     uint8_t     auth_mac[IOT_MAC_ADDR_LEN];
 | |
|     /* authorized state info, see CVG_PEER_AUTH_XXX */
 | |
|     uint8_t     state;
 | |
|     /* indicate authorized interaction process inactive count */
 | |
|     uint8_t     inactive_cnt;
 | |
|     /* protocol message number */
 | |
|     uint8_t     proto_msg_sn;
 | |
|     /* protocol run number */
 | |
|     uint16_t    proto_run_sn;
 | |
|     /* auth sta nonce */
 | |
|     uint32_t    sta_nonce;
 | |
|     /* auth cco nonce */
 | |
|     uint32_t    cco_nonce;
 | |
| } cvg_peer_auth_info_t;
 | |
| 
 | |
| typedef struct _cvg_peer_info {
 | |
|     /* role of the peer */
 | |
|     uint8_t         role            :3,
 | |
|     /* flag to mark if the peer is a direct sub sta of local device, this flag
 | |
|      * is not used if local device is cco role as all level 1 peers are direct
 | |
|      * sub sta of cco.
 | |
|      */
 | |
|                     d_sub_sta       :1,
 | |
|     /* level of the peer */
 | |
|                     level           :4;
 | |
|     /* possible power line phase estimated */
 | |
|     uint8_t         phase_1         :2,
 | |
|                     phase_2         :2,
 | |
|                     phase_3         :2,
 | |
|     /* flag to indicate if tx_sr calculation required */
 | |
|                     need_cal_tx     :1,
 | |
|     /* flag to indicate if rx_sr calculation required */
 | |
|                     need_cal_rx     :1;
 | |
|     /* rx snr from peer. snr is claculate from discover node list mme and
 | |
|      * beacon. if remote peer is cco and it don't have send phase
 | |
|      * info in the discovery node list mme, we won't calculate snr from
 | |
|      * discovery node list mme. currently, only our device has send phase info
 | |
|      * in the discovery node list mme.
 | |
|      * If local device is CCO, this means the uplink snr of the peer with its
 | |
|      * PCO. The PCO maybe report rx_snr list with own child nodes to CCO
 | |
|      * depending on different link type, while it's all stored here.
 | |
|      */
 | |
|     int8_t          rx_snr;
 | |
|     /* indicate the peer is inactive in hplc link and in how many consecutive
 | |
|      * partial route period till last partial period.
 | |
|      */
 | |
|     uint8_t         hplc_inactive_cnt :7,
 | |
|     /* flag to mark if the peer is from the same vendor as us */
 | |
|                     same_vendor     :1;
 | |
|     /* min traffic succes ratio from peer to cco. There may be multiple
 | |
|      * hops from local device to cco. this value is the lowest
 | |
|      * traffic success ratio between two hops in the full path from local
 | |
|      * device to cco.
 | |
|      */
 | |
|     uint32_t        cco_tf_sr       :7,
 | |
|     /* flag to mark if beacon ever received */
 | |
|                     bc_rx           :1,
 | |
|     /* flag to mark if beacon ever received in previous route period */
 | |
|                     prev_bc_rx      :1,
 | |
|     /* tx successful ratio, calculated from discover mme.
 | |
|      * tx means from local device to remote peer.
 | |
|      * If local device is CCO, this means the downlink traffic success ratio
 | |
|      * of the peer with its PCO. The PCO reports tx_sr list with own child
 | |
|      * nodes to CCO periodically depending on different link type, while it's
 | |
|      * all stored here.
 | |
|      */
 | |
|                     tx_sr           :7,
 | |
|     /* flag to mark if direct sub sta delay deletion */
 | |
|                     d_sub_delay_del :1,
 | |
|     /* rx successful ratio, calculated from discover mme.
 | |
|      * rx means from remote peer to local device.
 | |
|      * If local device is CCO, this means the uplink traffic success ratio of
 | |
|      * the peer with its PCO. The PCO reports rx_sr list with own child nodes
 | |
|      * to CCO periodically depending on different link type, while it's all
 | |
|      * stored here.
 | |
|      */
 | |
|                     rx_sr           :7,
 | |
|     /* flag to mark if tf_sr is available */
 | |
|                     tf_sr_valid     :1,
 | |
|     /* traffic successful ratio, calculated from tx_sr, rx_sr and history
 | |
|      * tf_sr in previous route period. see cvg_rt_calc_peer_tf_sr.
 | |
|      * tf_sr stands for the traffic successful ratio between peer and own proxy
 | |
|      * for CCO, or stands for the actual traffic successful ratio between local
 | |
|      * device and peer for STA, and tx_sr and rx_sr have the similar definition.
 | |
|      */
 | |
|                     tf_sr           :7;
 | |
|     /* number of discover mme and beacon local device received from remote
 | |
|      * peer in current route peroid. if remote peer is cco and it don't have
 | |
|      * send phase info in the discovery node list mme, we calculate discovery
 | |
|      * node list mme received from all phases together.
 | |
|      * currently, only our device has send phase info in the discovery node
 | |
|      * list mme.
 | |
|      */
 | |
|     uint8_t         dis_rx;
 | |
|     /* number of discover mme and beacon local device received from remote
 | |
|      * peer in previous route peroid.
 | |
|      */
 | |
|     uint8_t         prev_dis_rx;
 | |
|     /* flag to mark if discovery node list mme ever received */
 | |
|     uint8_t         dis_mme_rx      :1,
 | |
|     /* flag to mark if discovery node list mme ever received in previous
 | |
|      * route period.
 | |
|      */
 | |
|                     prev_dis_mme_rx :1,
 | |
|     /* number of discover mme local device received from remote peer in
 | |
|      * current route peroid.
 | |
|      */
 | |
|                     dis_only_rx     :6;
 | |
| #if HPLC_RF_SUPPORT
 | |
|     /* rf hop to cco */
 | |
|     uint8_t         rf_hop          :4,
 | |
| #if HPLC_RF_DEV_SUPPORT
 | |
|     /* flag to mark if rf beacon and rf discover mme ever received in previous
 | |
|      * statistic period. see CVG_RT_RF_BC_DIS_RX_STAT_DUR
 | |
|      */
 | |
|                     rf_prev_bc_dis_rx :4;
 | |
|     /* rf rx successful ratio, calculated from rf discover mme.
 | |
|      * rx means from remote peer to local device.
 | |
|      */
 | |
|     uint32_t        rf_rx_sr        :7,
 | |
|     /* flag to mark if rf beacon and rf discovery list mme ever received in
 | |
|      * current statistic period. see CVG_RT_RF_BC_DIS_RX_STAT_DUR
 | |
|      */
 | |
|                     rf_bc_dis_rx    :1,
 | |
|     /* rf weight rx successful ratio, it is more accurate than rf_rx_sr.
 | |
|      * the rf_wi_rx_sr applies to calculate tf_sr, while rf_rx_sr
 | |
|      * applies to fill the rf discovery list
 | |
|      */
 | |
|                     rf_wi_rx_sr     :7,
 | |
|     /* rf tx successful ratio, calculated from rf discover mme.
 | |
|      * tx means from local device to remote peer.
 | |
|      */
 | |
|                     rf_tx_sr        :7,
 | |
|     /* rf traffic successful ratio */
 | |
|                     rf_tf_sr        :7,
 | |
|     /* reserved for future */
 | |
|                     rsvd3           :3;
 | |
|     /* rf rx snr from peer */
 | |
|     int8_t          rf_rx_snr;
 | |
|     /* rf tx snr to the peer */
 | |
|     int8_t          rf_tx_snr;
 | |
|     /* rf rx rssi from peer */
 | |
|     int8_t          rf_rx_rssi;
 | |
|     /* flag to mark if rf tf_sr is available */
 | |
|     uint8_t         rf_tf_sr_valid   :1,
 | |
|     /* indicate the peer is inactive in rf link and in how many consecutive
 | |
|      * rf discovery node list period.
 | |
|      */
 | |
|                     rf_inactive_cnt  :7;
 | |
|     /* rf discovery list start sequence */
 | |
|     uint8_t         rf_start_seq;
 | |
|     /* local rf discovery period count */
 | |
|     uint8_t         rf_dp_cnt;
 | |
|     /* count of the rf discovery list was not received */
 | |
|     uint8_t         rf_dis_inactive_cnt :7,
 | |
|     /* flag to mark if rf start seq is valid */
 | |
|                     rf_seq_valid    :1;
 | |
|     /* rf discovery list receive bitmap */
 | |
|     uint32_t        rf_rcv_bm;
 | |
| #else /* HPLC_RF_DEV_SUPPORT */
 | |
|     /* reserved for future */
 | |
|                     rsvd3           :4;
 | |
| #endif /* HPLC_RF_DEV_SUPPORT */
 | |
| #endif /* HPLC_RF_SUPPORT */
 | |
| #if PLC_SUPPORT_PROXY_LEARNING
 | |
|     /* sta learnt proxy from beacon or discover mme,
 | |
|      * cco is aware of all sta proxy, and stores in proxy fields
 | |
|      */
 | |
|     uint16_t        learnt_proxy    :12,
 | |
| #else /* PLC_SUPPORT_PROXY_LEARNING */
 | |
|     uint8_t         rsvd2           :4,
 | |
| #endif /* PLC_SUPPORT_PROXY_LEARNING */
 | |
|     /* indicate the peer is detected to be switched to proxy rather than local
 | |
|      * device in how many consecutive partial route period till the last
 | |
|      * partial route period.
 | |
|      * this count is being used only when d_sub_sta is true.
 | |
|      */
 | |
|                     proxy_chg_cnt   :4;
 | |
| #if (PLC_SUPPORT_CCO_ROLE)
 | |
|     /* peer state info, see CVG_PEER_S_XXX */
 | |
|     uint8_t         state           :3,
 | |
|     /* zero-crossing collection edge types, see CVG_ZC_CT_EDGE_XXX */
 | |
|                     edge_type       :2,
 | |
|     /* flag to mark if the bonding relationship between the node and TEI already
 | |
|      * exists before the node joined the network.
 | |
|      * this value is used for app node join info report.
 | |
|      */
 | |
|                     bonding_flag    :1,
 | |
|     /* link type of direct sub node, see CVG_PEER_SUB_LINK_TYPE_XXX */
 | |
|                     sub_link_type   :2;
 | |
|     /* device type. See  PLC_DEV_TYPE_XXX */
 | |
|     uint8_t         dev_type;
 | |
|     /* tx snr to the peer. snr is claculate from discover node list mme and
 | |
|      * beacon. if remote peer is cco and it don't have send phase
 | |
|      * info in the discovery node list mme, we won't calculate snr from
 | |
|      * discovery node list mme. currently, only our device has send phase info
 | |
|      * in the discovery node list mme.
 | |
|      * If local device is CCO, this means the downlink snr of the peer with its
 | |
|      * PCO. The PCO maybe report tx_snr list with own child nodes to CCO
 | |
|      * depending on different link type, while it's all stored here.
 | |
|      */
 | |
|     int8_t          tx_snr;
 | |
|     /* possible physical power line phase estimated */
 | |
|     uint8_t         phy_phase_1         :2,
 | |
|                     phy_phase_2         :2,
 | |
|                     phy_phase_3         :2,
 | |
|     /* reserved for future */
 | |
|                     rsvd                :1,
 | |
|     /* flag to mark if zero-cross info is valid */
 | |
|                     zc_info_valid       :1;
 | |
|     /* zc collect query retry count */
 | |
|     uint8_t         zc_query_cnt;
 | |
|     /* zc collect query retry count for no phase info peer */
 | |
|     uint8_t         zc_no_phase_query_cnt;
 | |
|     /* latest in use msdu record index */
 | |
|     uint8_t         msdu_rec_idx;
 | |
|     /* number of consecutive traffic success ratio report period that
 | |
|      * CCO detected pco of the peer is not the same as the the info saved in
 | |
|      * CCO side.
 | |
|      */
 | |
|     uint8_t         pco_out_of_sync :4,
 | |
|     /* mac address type. see PLC_MAC_ADDR_TYPE_XXX */
 | |
|                     mac_addr_type   :2,
 | |
|     /* flag to mark if delete the corresponding tei lock while the peer leave
 | |
|      * the network.
 | |
|      */
 | |
|                     leave_unlock    :1,
 | |
|     /* flag to mark if L/N reversed in Single-phase power meter or phase
 | |
|      * sequence reversed in Three-phase power meter.
 | |
|      */
 | |
|                     opposite_phase  :1;
 | |
|     /* flag to mark if L/N reversed in Three-phase power meter */
 | |
|     uint8_t         opposite_3p     :1,
 | |
|     /* connection position of N-wire if L/N of three-phase meter is reversed.
 | |
|      * see IOT_PLC_PHASE_XXX.
 | |
|      * Note: the position refers to the physical phase terminal.
 | |
|      */
 | |
|                     opposite_3p_pos :2,
 | |
|     /* flag to mark 3phase sta zc ntb report odd numbers */
 | |
|                     zc_3p_rpt_odd_flag :1,
 | |
|     /* zc collect phase error count */
 | |
|                     zc_phase_err_cnt   :4;
 | |
|     /* 1 - hw_reset_cnt changed relative to the last time join net */
 | |
|     uint8_t         hw_reset_flag      :1,
 | |
|     /* 1 - sw_reset_cnt changed relative to the last time join net */
 | |
|                     sw_reset_flag      :1,
 | |
|     /* count of 3phase sta zc ntb report odd numbers */
 | |
|                     zc_3p_rpt_odd_cnt  :3,
 | |
|     /* link type between station and proxy, see PLC_LINK_TYPE_XXX */
 | |
|                     pco_link_type      :1,
 | |
|     /* device communication type, see PLC_DEV_COMM_TYPE_XXX */
 | |
|                     comm_type          :2;
 | |
|     /* indicate the peer uplink is inactive in how many consecutive route
 | |
|      * period till last partial period.
 | |
|      */
 | |
|     uint8_t         uplink_inactive_cnt;
 | |
|     /* indicate the peer send mme traffic successful ratio report is inactive
 | |
|      * in how many consecutive route period till last partial period, when
 | |
|      * device role is pco.
 | |
|      */
 | |
|     uint8_t         tf_sr_send_inactive_cnt;
 | |
|     /* previous proxy tei */
 | |
|     uint32_t        prev_proxy         :12,
 | |
|     /* proxy tei */
 | |
|                     proxy              :12,
 | |
|     /* indicate the peer is inactive in how many consecutive partial route
 | |
|      * period till last partial period. it doesn't care which link type is
 | |
|      * acitve for cco.
 | |
|      */
 | |
|                     inactive_cnt       :7,
 | |
|     /* reserved for future */
 | |
|                     rsvd4              :1;
 | |
|     /* peer to peer serial number */
 | |
|     uint32_t        p2p_sn;
 | |
|     /* association random number */
 | |
|     uint32_t        assoc_rnd;
 | |
|     /* time stamp of last assoc, unit is 1s */
 | |
|     uint32_t        last_assoc_ts;
 | |
|     /* time stamp of last proxy change request, unit is 1s */
 | |
|     uint32_t        last_proxy_chg_ts;
 | |
|     /* time stamp of last detection, unit is 1s */
 | |
|     uint32_t        last_seen_ts;
 | |
|     /* time stamp of last deletion, unit is 1s */
 | |
|     uint32_t        last_delete_ts;
 | |
|     /* time stamp of last leaving the network, unit is 1s */
 | |
|     uint32_t        last_leave_ts;
 | |
|     /* how many times sta leaving network */
 | |
|     uint16_t        leave_cnt;
 | |
|     /* total valid assoc request received from the peer counter */
 | |
|     uint16_t        assoc_rx_cnt;
 | |
|     /* total proxy change request accepted counter */
 | |
|     uint16_t        proxy_chg_accept_cnt;
 | |
|     /* hardware reset count */
 | |
|     uint16_t        hw_reset_cnt;
 | |
|     /* software reset count */
 | |
|     uint16_t        sw_reset_cnt;
 | |
|     /* total directly connected sub-sta count, it contain hplc and rf devices */
 | |
|     uint16_t        d_sub_sta_cnt;
 | |
|     /* pointer to directly connected sub-sta info, if hplc+rf dual mode device
 | |
|      * is supported, bitmap will contain both hplc and rf devices.
 | |
|      */
 | |
|     cvg_tei_map_t   *direct_sub_sta;
 | |
|     /* msdu record of the peer */
 | |
|     uint32_t        msdu_rec[CVG_PEER_MSDU_REC_CNT];
 | |
|     /* the version of station */
 | |
|     cvg_peer_ver_info_t    ver_info;
 | |
|     /* the version of station */
 | |
|     cvg_peer_vendor_info_t vendor_info;
 | |
| #if HPLC_RF_SUPPORT
 | |
|     /* pointer to rf link directly connected sub-sta info */
 | |
|     cvg_tei_map_t   *rf_d_sub_sta;
 | |
|     /* rf link directly connected sub-sta count */
 | |
|     uint16_t        rf_d_sub_sta_cnt;
 | |
| #endif
 | |
| #if PLC_SUPPORT_PEER_STAT
 | |
|     /* time stamp of first assoc, unit is 1s */
 | |
|     uint32_t        first_assoc_ts;
 | |
|     /* total valid proxy change request received from the peer counter */
 | |
|     uint32_t        proxy_chg_rx_cnt;
 | |
|     /* time span from the last time sta changes state from CVG_PEER_S_OFFLINE
 | |
|        to CVG_PEER_S_ASSOCED, unit is 1s */
 | |
|     uint32_t        last_leave_dur;
 | |
|     /* max time span from state CVG_PEER_S_OFFLINE to CVG_PEER_S_ASSOCED,
 | |
|        unit is 1s */
 | |
|     uint32_t        max_leave_dur;
 | |
| #endif
 | |
| #if PLC_SUPPORT_CHIP_ID
 | |
|     /* chip management id */
 | |
|     mme_chip_id_t     chip_mm_id;
 | |
| #endif
 | |
| #if CVG_NETWORK_NTB_DEBUG
 | |
|     /* peer zero-cross ntb info */
 | |
|     cvg_peer_zc_info_t zc_info;
 | |
| #endif
 | |
|     /* pco history info */
 | |
|     cvg_peer_pco_his_t pco_his[CVG_PEER_PCO_HIS_DEPTH];
 | |
| #if (PLC_SUPPORT_AUTH_DAK)
 | |
|     /* peer authorized state info */
 | |
|     cvg_peer_auth_info_t auth_info;
 | |
| #endif
 | |
| #endif /* PLC_SUPPORT_CCO_ROLE */
 | |
| } cvg_peer_info_t;
 | |
| 
 | |
| #if PLC_SUPPORT_CCO_ROLE == 0
 | |
| #pragma pack(pop)
 | |
| #endif
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_init() - global init of peer management module
 | |
|  * @glb:    pointer of cvg global data
 | |
|  * @cfg:    pointer of cvg configuration
 | |
|  *
 | |
|  * return:
 | |
|  *      0         -- for success case
 | |
|  *      othersie  -- error code
 | |
|  */
 | |
| uint32_t cvg_prm_init(cvg_global_t *glb, cvg_cfg_t *cfg);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_init_vdev() - vdev init of peer 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_prm_init_vdev(cvg_vdev_t *vdev, cvg_vdev_cfg_t *cfg);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_deinit_vdev() - vdev deinit of peer management module
 | |
|  * @vdev:   pointer of vdev to be deinit
 | |
|  */
 | |
| void cvg_prm_deinit_vdev(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_reset_vdev() - vdev reset of peer management module
 | |
|  * @vdev:   pointer of vdev to be reset
 | |
|  * @cfg:    pointer of vdev configuration
 | |
|  */
 | |
| void cvg_prm_reset_vdev(cvg_vdev_t *vdev, cvg_vdev_cfg_t *cfg);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_reset_peer() - peer reset of peer management module
 | |
|  * @vdev:   pointer of vdev of the peer to be reset
 | |
|  * @peer:   pointer of peer to be reset
 | |
|  */
 | |
| void cvg_prm_reset_peer(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_create_peer() -  create peer with specific tei
 | |
|  * @vdev:   pointer to vdev
 | |
|  * #tei:    specified tei
 | |
|  *
 | |
|  * return:
 | |
|  *  NULL        --  for failure case
 | |
|  *  otherwise   --  pointer to newly created peer
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_create_peer_by_tei(cvg_vdev_t *vdev, tei_t tei);
 | |
| 
 | |
| /*
 | |
| * cvg_prm_delete_peer() - delete peer
 | |
| * @vdev:   pointer to vdev
 | |
| * @peer:   pointer to peer
 | |
| */
 | |
| void cvg_prm_delete_peer(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_delete_peer() - delete peer
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @tei:    tei of the peer to be deleted
 | |
|  */
 | |
| void cvg_prm_delete_peer_by_tei(cvg_vdev_t *vdev, tei_t tei);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_by_tei() -  get remote peer by tei
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @tei:    tei to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  NULL        --  peer not exist
 | |
|  *  otherwise   --  pointer to the peer
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_get_peer_by_tei(cvg_vdev_t *vdev, tei_t tei);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_tei() - get tei of the remote peer
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * return:  tei of the peer
 | |
|  */
 | |
| tei_t cvg_prm_get_peer_tei(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_all_dis_node_info() - get tei bitmap of remote peers and
 | |
|  *                 the number of received discover node list mme from each
 | |
|  *                 peer in last route period. if no mme received, the peer
 | |
|  *                 will be excluded.
 | |
|  * @param vdev:    pointer to vdev
 | |
|  * @param data:    pointer to buffer to receive the result
 | |
|  * @param len:     pointer to length of the buffer. In return, this value is set
 | |
|  *                 the actually buffer length usage.
 | |
|  * @param max_len: limit of bitmap and the number of received discover node list
 | |
|  *                 mme buffer length. This value is only valid in none CCO role
 | |
|  *                 case.
 | |
|  * @param fix_bm_size: bitmap fixed length, 0 means variable length.
 | |
|  * @return:            number of sta in the sta list
 | |
|  */
 | |
| uint16_t cvg_prm_get_dis_node_info(cvg_vdev_t *vdev, uint8_t *data,
 | |
|     uint32_t *len, uint32_t max_len, uint8_t fix_bm_size);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_direct_peer_bm() - get tei bitmap of peer in the network
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @bm:     tei bitmap to store peers' tei info
 | |
|  */
 | |
| void cvg_prm_get_peer_bm(cvg_vdev_t *vdev, cvg_tei_map_t *bm);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_direct_peer_bm() - get tei bitmap of directly connected peer
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @bm:     tei bitmap to store peers' tei info
 | |
|  */
 | |
| void cvg_prm_get_direct_peer_bm(cvg_vdev_t *vdev, cvg_tei_map_t *bm);
 | |
| 
 | |
| /*
 | |
|  * @brief   cvg_prm_get_peer_to_cco_min_tf_sr() - get min traffic success ratio
 | |
|  *          from local device to cco through the appointed peer.
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval  0 - 100 traffic success ratio. unit is 1%.
 | |
|  */
 | |
| uint8_t cvg_prm_get_peer_to_cco_min_tf_sr(cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_role() - set peer role
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  * @role:   role to be set
 | |
|  */
 | |
| void cvg_prm_set_peer_role(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t role);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_role() - get peer role
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * return:
 | |
|  *  PLC_DEV_ROLE_XXX
 | |
|  */
 | |
| #define cvg_prm_get_peer_role(peer) ((uint8_t)((peer)->role))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_role() - set peer level
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  * @level:  level to be set
 | |
|  */
 | |
| void cvg_prm_set_peer_level(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t level);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_level() - get peer level
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * return:
 | |
|  *  from 0 to PLC_MAX_RT_LEVEL
 | |
|  */
 | |
| #define cvg_prm_get_peer_level(peer) ((uint8_t)((peer)->level))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_phase() - set peer phase
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  * @phase1: first possible phase. the highest possibility.
 | |
|  * @phase2: second possible phase.
 | |
|  * @phase3: third possible phase. the lowest possibility.
 | |
|  */
 | |
| void cvg_prm_set_peer_phase(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t phase1, uint8_t phase2, uint8_t phase3);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_phase1() - get peer the highest possibile phase
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * return:
 | |
|  *  PLC_PHASE_XXX
 | |
|  */
 | |
| #define cvg_prm_get_peer_phase1(peer) ((uint8_t)((peer)->phase_1))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_phase2() - get peer the second possibile phase
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * return:
 | |
|  *  PLC_PHASE_XXX
 | |
|  */
 | |
| #define cvg_prm_get_peer_phase2(peer) ((uint8_t)((peer)->phase_2))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_phase3() - get peer the third possibile phase
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * return:
 | |
|  *  PLC_PHASE_XXX
 | |
|  */
 | |
| #define cvg_prm_get_peer_phase3(peer) ((uint8_t)((peer)->phase_3))
 | |
| 
 | |
| /*
 | |
|  * @brief   cvg_prm_is_peer_d_sub() - check if peer if direct sub sta of local
 | |
|  *                                    device.
 | |
|  * @param   peer:   pointer to the peer
 | |
|  * @retval  true:   if peer is direct sub sta of local device
 | |
|  * @retval  false:  if peer is not direct sub sta of local device
 | |
|  */
 | |
| #define cvg_prm_is_peer_d_sub(peer) (!!((peer)->d_sub_sta))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_d_sub() - set peer as direct sub sta of local device
 | |
|  * @param vdev: pointer to vdev
 | |
|  * @param peer: pointer to the peer
 | |
|  */
 | |
| void cvg_prm_set_peer_d_sub(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_clear_peer_d_sub() - clear peer direct sub sta flag
 | |
|  * @param vdev: pointer to vdev
 | |
|  * @param peer: pointer to the peer
 | |
|  */
 | |
| void cvg_prm_clear_peer_d_sub(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_cco_tf_sr() - set peer to cco traffic success ratio
 | |
|  * @vdev:       pointer to vdev
 | |
|  * @peer:       pointer to the peer
 | |
|  * @cco_tf_sr:  traffic success ratio to be set
 | |
|  */
 | |
| void cvg_prm_set_peer_cco_tf_sr(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t cco_tf_sr);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_cco_peer() - get cco peer info of the specified phase
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @phase:  phase to be tracked
 | |
|  *
 | |
|  * return:
 | |
|  *  NULL        -   if cco peer don't support the specified phase
 | |
|  *  otherwise   -   pointer to the peer info
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_get_cco_peer(cvg_vdev_t *vdev, uint8_t phase);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_cco_peer_new_bp() - get cco peer new bp info of the phase
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param phase:    phase to be tracked
 | |
|  *
 | |
|  * @return:
 | |
|  *  1   -   if local device have not received beacon from cco's specific phase
 | |
|  *          for the new beacon period.
 | |
|  *  0   -   if local device have received beacon from cco's specific phase
 | |
|  *          for the new beacon period.
 | |
|  */
 | |
| uint8_t cvg_prm_get_cco_peer_new_bp(cvg_vdev_t *vdev, uint8_t phase);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_cco_peer_new_bp() - set cco peer new bp info of the phase
 | |
|  * @param vdev:   pointer to vdev
 | |
|  * @param phase:  phase to be set
 | |
|  */
 | |
| void cvg_prm_set_cco_peer_new_bp(cvg_vdev_t *vdev, uint8_t phase);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_clear_cco_peer_new_bp() - clear cco peer new bp info of the
 | |
|  *                                          phase
 | |
|  * @param vdev:   pointer to vdev
 | |
|  * @param phase:  phase to be cleared
 | |
|  */
 | |
| void cvg_prm_clear_cco_peer_new_bp(cvg_vdev_t *vdev, uint8_t phase);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_copy_peer() - copy peer data from one to another one,
 | |
|  *                  NOTE: rf info copying is not support, rf snr/rssi/tf_sr will
 | |
|  *                  not be copied.
 | |
|  * @dst:            pointer to the destination peer
 | |
|  * @src:            pointer to the source peer
 | |
|  * @copy_tf_sr:     flag to mark if traffic success ratio related info should be
 | |
|  *                  copied
 | |
|  */
 | |
| void cvg_prm_copy_peer(cvg_peer_info_t *dst, cvg_peer_info_t *src,
 | |
|     uint8_t copy_tf_sr);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_cnt() - get number of peers found in the network
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of peers found in the network include the self peer.
 | |
|  */
 | |
| uint32_t cvg_prm_get_peer_cnt(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * @brief   get number of direct sub peers of local device
 | |
|  * @param vdev: pointer to vdev to be checked
 | |
|  *
 | |
|  * @return:
 | |
|  *  the number of peers direct sub peers of local device
 | |
|  */
 | |
| uint16_t cvg_prm_get_d_sub_sta_cnt(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_dump_peer() - dump peer info
 | |
|  * @vdev:   pointer to vdev to be dumped
 | |
|  * @peer:   pointer to peer to be dumped
 | |
|  */
 | |
| void cvg_prm_dump_peer(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief   dump prm statistics. note that this function is invoked outside CVG
 | |
|  *          context, suppose this function should only read some statistics
 | |
|  *          variables from CVG layer.
 | |
|  * @param vdev: pointer to vdev
 | |
|  */
 | |
| void cvg_prm_status_dump(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_learnt_proxy() - set peer learnt proxy
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  * @ptei:   learnt proxy tei
 | |
|  */
 | |
| void cvg_prm_set_learnt_proxy(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     tei_t ptei);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_learnt_proxy() - get peer learnt proxy
 | |
|  * @param vdev: pointer to vdev
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @return:     the tei of peer learnt proxy
 | |
|  */
 | |
| tei_t cvg_prm_get_learnt_proxy(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_hplc_inactive_cnt() - get peer hplc link inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  the number of peer hplc inactive count
 | |
|  */
 | |
| #define cvg_prm_get_peer_hplc_inactive_cnt(peer) ((peer)->hplc_inactive_cnt)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_hplc_inactive_cnt() - set peer hplc link inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  * @cnt:    count
 | |
|  */
 | |
| #define cvg_prm_set_peer_hplc_inactive_cnt(peer, cnt) \
 | |
|     (((peer)->hplc_inactive_cnt) = (cnt))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_hplc_inactive_inc() - set peer hplc link inactive count
 | |
|  *          increment
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| #define cvg_prm_set_peer_hplc_inactive_inc(peer) \
 | |
|     iot_counter_inc((peer)->hplc_inactive_cnt)
 | |
| 
 | |
| #if (PLC_SUPPORT_CCO_ROLE)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_create_peer() -  create peer and assign a freed tei to the new peer
 | |
|  * @vdev:          pointer to vdev
 | |
|  * @vendor_info:   vendor info comes from assoc requst
 | |
|  *
 | |
|  * return:
 | |
|  *  NULL        --  for failure case
 | |
|  *  otherwise   --  pointer to newly created peer
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_create_peer(cvg_vdev_t *vdev,
 | |
|     mme_vendor_info_t *vendor_info);
 | |
| 
 | |
| /*
 | |
|  * @brief   get remote peer by mac address not matter the peer is in network
 | |
|  *          or corresponding tei being locked. tei for a remote peer could be
 | |
|  *          locked even the peer has left the network for a while if the peer
 | |
|  *          is using meter type mac address.
 | |
|  *
 | |
|  * @param vdev: pointer to vdev to be checked
 | |
|  * @param addr: mac address to be checked
 | |
|  *
 | |
|  * @return:
 | |
|  *  NULL        --  peer not exist
 | |
|  *  otherwise   --  pointer to the peer
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_get_peer_by_addr_locked(cvg_vdev_t *vdev,
 | |
|     uint8_t *addr);
 | |
| 
 | |
| /*
 | |
|  * @brief   get remote peer by corresponding tei being locked. tei for a
 | |
|  *          remote peer could be locked even the peer has left the network
 | |
|  *          for a while if the peer is using meter type mac address.
 | |
|  *
 | |
|  * @param vdev: pointer to vdev to be checked
 | |
|  * @param tei: tei to be checked
 | |
|  *
 | |
|  * @return:
 | |
|  *  NULL        --  peer not exist
 | |
|  *  otherwise   --  pointer to the peer
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_get_peer_by_tei_locked(cvg_vdev_t *vdev, tei_t tei);
 | |
| 
 | |
| /*
 | |
|  * @brief   get locked peer that can be recycled. locked peer can be recycled
 | |
|  *          when tei is not enough for new associated sta.
 | |
|  *
 | |
|  * @param vdev: pointer to vdev to be checked
 | |
|  *
 | |
|  * @return:
 | |
|  *  NULL        --  peer not exist
 | |
|  *  otherwise   --  pointer to the peer
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_get_recycle_peer_locked(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * @brief   get directly connected sub sta of the peer
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @peer:   pointer to peer
 | |
|  *
 | |
|  * return:  number of directly connected sub sta
 | |
|  */
 | |
| static inline uint32_t cvg_prm_get_peer_d_sub_sta_cnt(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     if (cvg_prm_get_peer_role(peer) == PLC_DEV_ROLE_STA)
 | |
|         return 0;
 | |
|     return peer->d_sub_sta_cnt;
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_sub_sta() -  get bitmap of all sub sta of the peer
 | |
|  * @vdev:       pointer to vdev to be checked
 | |
|  * @proxy:      pointer to peer to be checked
 | |
|  * @bm:         bitmap of sub sta tei info for return.
 | |
|  */
 | |
| void cvg_prm_get_sub_sta_bm(cvg_vdev_t *vdev, cvg_peer_info_t *proxy,
 | |
|     cvg_tei_map_t *bm);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_sub_sta() -  get bitmap and tei list of sub sta of the peer.
 | |
|  *                          the format of the tei list is same as the route info
 | |
|  *                          field of the assoc conf mme defined in smart grid
 | |
|  *                          spec.
 | |
|  * @vdev:       pointer to vdev to be checked
 | |
|  * @peer:       pointer to peer to be checked
 | |
|  * @sub_bm:     bitmap of sub sta tei info for return.
 | |
|  * @data:       buffer to save the tei list info for return.
 | |
|  * @len:        length of the buffer.
 | |
|  *
 | |
|  * return:      actual buffer used.
 | |
|  */
 | |
| uint32_t cvg_prm_get_sub_sta(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     cvg_tei_map_t *sub_bm, uint8_t *data, uint32_t len);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_proxy() - set proxy info of the peer
 | |
|  * @vdev:       pointer to vdev
 | |
|  * @s_tei:      tei of the peer
 | |
|  * @p_tei:      tei of the proxy
 | |
|  * @link_type:  link type between station and proxy
 | |
|  * @from_assoc: flag to mark if this proxy set is for assoc request
 | |
|  */
 | |
| void cvg_prm_set_peer_proxy(cvg_vdev_t *vdev, tei_t s_tei, tei_t p_tei,
 | |
|     uint8_t link_type, uint8_t from_assoc);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_update_peer_rf_hop_for_sub_sta() - update rf_hop of sub sta of the
 | |
|  *          peer
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| void cvg_prm_update_peer_rf_hop_for_sub_sta(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_update_peer_level_for_sub_sta() - update level of sub sta of the peer
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| void cvg_prm_update_peer_level_for_sub_sta(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_update_peer_phase_for_sub_sta() - update phase of sub sta of the peer
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| void cvg_prm_update_peer_phase_for_sub_sta(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_sub_sta_max_level() - get max level of the existing sub sta of
 | |
|  *                                   the peer
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * return:
 | |
|  *  max level of the sub sta. if no sub sta exist, the peer level will be
 | |
|  *  returned.
 | |
|  */
 | |
| uint8_t cvg_prm_get_sub_sta_max_level(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief   check if peer is a sub sta of the proxy
 | |
|  * @param   vdev:   pointer to vdev to be checked
 | |
|  * @param   proxy:  the proxy to be checked
 | |
|  * @param   peer:   the peer to be checked
 | |
|  *
 | |
|  * @return:
 | |
|  *  2   --  proxy chain to the proxy is invalid
 | |
|  *  1   --  peer is a sub sta of the proxy
 | |
|  *  0   --  peer is not a sub sta of the proxy
 | |
|  */
 | |
| uint8_t cvg_prm_is_sub_sta(cvg_vdev_t *vdev, cvg_peer_info_t *proxy,
 | |
|     cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_active() - set peer to active status
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| void cvg_prm_set_peer_active(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_id() - set peer chip id
 | |
|  * @peer:   pointer to the peer
 | |
|  * @p_id:   pointer to the chip id to be set
 | |
|  */
 | |
| void cvg_prm_set_peer_id(cvg_peer_info_t *peer, mme_chip_id_t *p_id);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_id() - get peer chip id
 | |
|  * @peer:   pointer to the peer
 | |
|  * @p_id:   store chip id, as return value
 | |
|  */
 | |
| void cvg_prm_get_peer_id(cvg_peer_info_t *peer, mme_chip_id_t *p_id);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_hw_tsfm_addr() - get peer hardware tsfm addr
 | |
|  * @peer:          pointer to the peer
 | |
|  * @vendor_info:   vendor info comes from assoc requst or config
 | |
|  */
 | |
| void cvg_prm_get_hw_tsfm_addr(cvg_peer_info_t *peer, uint8_t *addr);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_clear_peer_hw_tsfm() - clear peer hardware tsfm info
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| void cvg_prm_clear_peer_hw_tsfm(cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_vendor_info() - set peer vendor info
 | |
|  * @peer:          pointer to the peer
 | |
|  * @vendor_info:   vendor info comes from assoc requst or config
 | |
|  */
 | |
| void cvg_prm_set_vendor_info(cvg_peer_info_t *peer,
 | |
|     mme_vendor_info_t *vendor_info);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_ver_info() - set peer version info
 | |
|  * @peer:          pointer to the peer
 | |
|  * @verson_info:   version info comes from assoc requst or config
 | |
|  */
 | |
| void cvg_prm_set_ver_info(cvg_peer_info_t *peer, mme_ver_info_t *ver_info);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_pco_cnt() - get number of pco role devices in the network
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of pco role devices in the network.
 | |
|  */
 | |
| uint32_t cvg_prm_get_pco_cnt(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_pco_cnt() - get number of sta role devices in the network
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of sta role devices in the network.
 | |
|  */
 | |
| uint32_t cvg_prm_get_sta_cnt(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_pco_bm() - get pointer to pco bitmap of a specific level
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @level:  level to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the pointer to the pco bitmap of a specific level. note that the returned
 | |
|  *  bimap is read only and can only be used inside CVG thread context.
 | |
|  */
 | |
| cvg_tei_map_t *cvg_prm_get_pco_bm(cvg_vdev_t *vdev, uint8_t level);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_sta_bm() - get pointer to sta bitmap of a specific level
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @level:  level to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the pointer to the sta bitmap of a specific level. note that the returned
 | |
|  *  bimap is read only and can only be used inside CVG thread context.
 | |
|  */
 | |
| cvg_tei_map_t *cvg_prm_get_sta_bm(cvg_vdev_t *vdev, uint8_t level);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_phase1_cnt() - get first possible phase count of the specified
 | |
|  *                            phase in the whole network.
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @phase:  phase to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of devices that the first possible phase is the specified phase.
 | |
|  */
 | |
| uint32_t cvg_prm_get_phase1_cnt(cvg_vdev_t *vdev, uint8_t phase);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_phase2_cnt() - get second possible phase count of the specified
 | |
|  *                            phase in the whole network.
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @phase:  phase to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of devices that the second possible phase is the specified phase.
 | |
|  */
 | |
| uint32_t cvg_prm_get_phase2_cnt(cvg_vdev_t *vdev, uint8_t phase);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_phase1_cnt() - get third possible phase count of the specified
 | |
|  *                            phase in the whole network.
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @phase:  phase to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of devices that the third possible phase is the specified phase.
 | |
|  */
 | |
| uint32_t cvg_prm_get_phase3_cnt(cvg_vdev_t *vdev, uint8_t phase);
 | |
| 
 | |
| /*
 | |
|  * @brief   get the logical phase phase which has the most devices on it.
 | |
|  * @param   vdev: pointer to vdev
 | |
|  * @reval:  see PLC_PHASE_XXX
 | |
|  */
 | |
| uint8_t cvg_prm_get_most_dev_phase(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * @brief   get the max level of the whole topo tree
 | |
|  * @param   vdev: pointer to vdev
 | |
|  * @reval:  0 ~ (PLC_MAX_RT_LEVEL - 1), max level of the topo tree.
 | |
|  */
 | |
| uint8_t cvg_prm_get_topo_depth(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_peer_assoc_notify() - peer associated notification
 | |
|  * @param vdev: pointer to vdev
 | |
|  * @param peer: peer associated
 | |
|  */
 | |
| void cvg_prm_peer_assoc_notify(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_peer_proxy_chg_rx_notify() - peer proxy change reuqest rx
 | |
|  *        notification
 | |
|  * @param vdev: pointer to vdev
 | |
|  * @param peer: peer from which the request received
 | |
|  */
 | |
| void cvg_prm_peer_proxy_chg_rx_notify(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_peer_phase_chg_notify() - level 1 peer phase change
 | |
|  *        notification
 | |
|  * @param vdev: pointer to vdev
 | |
|  * @param peer: peer from which the request received
 | |
|  */
 | |
| void cvg_prm_peer_phase_chg_notify(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief delete tei lock
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param sta_tei:  tei lock to be deleted
 | |
|  */
 | |
| void cvg_prm_delete_locked_tei(cvg_vdev_t *vdev, tei_t sta_tei);
 | |
| 
 | |
| /*
 | |
|  * @brief check and clean up obsolete tei lock
 | |
|  * @param vdev: pointer to vdev
 | |
|  */
 | |
| void cvg_prm_clean_up_locked_tei_bm(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * @brief add pco into history
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  * @param proxy:    pointer to the proxy of the peer
 | |
|  * @param link_type: link type between peer and proxy, see PLC_LINK_TYPE_XXX
 | |
|  */
 | |
| void cvg_prm_add_pco_his(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     cvg_peer_info_t *proxy, uint8_t link_type);
 | |
| 
 | |
| /*
 | |
|  * @brief update pco history data
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  * @param proxy:    pointer to the proxy of the peer
 | |
|  * @param link_type:  link type between peer and proxy, see PLC_LINK_TYPE_XXX
 | |
|  * @param from_assoc: flag to mark if this proxy set is for assoc request
 | |
|  * @param force_bad:  flag to mark if force set proxy is bad
 | |
|  */
 | |
| void cvg_prm_update_pco_his(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     cvg_peer_info_t *proxy, uint8_t link_type, uint8_t from_assoc,
 | |
|     uint8_t force_bad);
 | |
| 
 | |
| /*
 | |
|  * @brief check if the proxy is good pco according pco history of the peer
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  * @param proxy:    pointer to the proxy
 | |
|  * @param link_type: link type between peer and proxy, see PLC_LINK_TYPE_XXX
 | |
|  */
 | |
| uint8_t cvg_prm_is_pco_his_bad(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     cvg_peer_info_t *proxy, uint8_t link_type);
 | |
| 
 | |
| /*
 | |
|  * @brief dump pco history info of the peer
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  */
 | |
| void cvg_prm_dump_pco_his(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_is_sig_phase() - check if the peer is single-phase
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  * @retval: 1 - single-phase, 0 - not single-phase or unknown.
 | |
|  */
 | |
| uint8_t cvg_prm_is_single_phase(cvg_vdev_t *vdev, cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_tx_snr() - get peer tx snr
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: tx snr, unit is 1db
 | |
|  */
 | |
| #define cvg_prm_get_peer_tx_snr(peer) ((peer)->tx_snr)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_tx_snr() - set peer tx snr
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _snr_:    snr to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_tx_snr(peer, _snr_) ((peer)->tx_snr = (_snr_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_proxy_tei() - get peer proxy tei
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: tei
 | |
|  */
 | |
| #define cvg_prm_get_peer_proxy_tei(peer) ((tei_t)((peer)->proxy))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_clear_peer_phy_phase_info() - clear peer phy phase info
 | |
|  * @param peer:      pointer to the peer
 | |
|  */
 | |
| #define cvg_prm_clear_peer_phy_phase_info(peer) \
 | |
|     do {                                      \
 | |
|         peer->phy_phase_1 = PLC_PHASE_ALL;    \
 | |
|         peer->phy_phase_2 = PLC_PHASE_ALL;    \
 | |
|         peer->phy_phase_3 = PLC_PHASE_ALL;    \
 | |
|         peer->opposite_phase = 0;             \
 | |
|         peer->opposite_3p = 0;                \
 | |
|         peer->opposite_3p_pos = 0;            \
 | |
|         peer->zc_no_phase_query_cnt = 0;      \
 | |
|         peer->zc_query_cnt = 0;               \
 | |
|         peer->zc_phase_err_cnt = 0;           \
 | |
|         peer->zc_3p_rpt_odd_flag = 0;         \
 | |
|         peer->zc_3p_rpt_odd_cnt = 0;          \
 | |
|     } while(0)
 | |
| 
 | |
| #if PLC_SUPPORT_PEER_STAT
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_last_leave_dur() - get peer last leave duration
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: last leave duration, unit is 1s
 | |
|  */
 | |
| #define cvg_prm_get_peer_last_leave_dur(peer) ((peer)->last_leave_dur)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_last_leave_dur() - set peer last leave duration
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _last_leave_dur_: last leave duration to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_last_leave_dur(peer, _last_leave_dur_) \
 | |
|     ((peer)->last_leave_dur = (_last_leave_dur_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_max_leave_dur() - get peer max leave duration
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: max leave duration, unit is 1s
 | |
|  */
 | |
| #define cvg_prm_get_peer_max_leave_dur(peer) ((peer)->max_leave_dur)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_max_leave_dur() - set peer max leave duration
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _max_leave_dur_: max leave duration to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_max_leave_dur(peer, _max_leave_dur_) \
 | |
|     ((peer)->max_leave_dur = (_max_leave_dur_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_pco_chg_rx_cnt() - get peer proxy change rx cnt
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: proxy change rx cnt
 | |
|  */
 | |
| #define cvg_prm_get_peer_pco_chg_rx_cnt(peer) ((peer)->proxy_chg_rx_cnt)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_first_assoc_ts() - get peer first assoc timestamp
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: first assoc ts
 | |
|  */
 | |
| #define cvg_prm_get_peer_first_assoc_ts(peer) ((peer)->first_assoc_ts)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_first_assoc_ts() - set peer first assoc ts
 | |
|  * @param peer: pointer to the peer
 | |
|  * @param ts:   first assoc timestamp
 | |
|  */
 | |
| #define cvg_prm_set_peer_first_assoc_ts(peer, ts) \
 | |
|     ((peer)->first_assoc_ts = (ts))
 | |
| 
 | |
| #else /* PLC_SUPPORT_PEER_STAT */
 | |
| 
 | |
| #define cvg_prm_get_peer_max_leave_dur(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_max_leave_dur(peer, _max_leave_dur_)
 | |
| 
 | |
| #define cvg_prm_get_peer_last_leave_dur(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_last_leave_dur(peer, _last_leave_dur_)
 | |
| 
 | |
| #define cvg_prm_get_peer_pco_chg_rx_cnt(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_first_assoc_ts(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_first_assoc_ts(peer, first_assoc_ts)
 | |
| 
 | |
| #endif /* PLC_SUPPORT_PEER_STAT */
 | |
| 
 | |
| #if PLC_SUPPORT_VER_INFO_COMP
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_boot_reason() - get peer boot reason
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: boot reason
 | |
|  */
 | |
| #define cvg_prm_get_peer_boot_reason(peer) ((peer)->ver_info.boot_reason)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_boot_ver() - get peer boot version
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: boot version
 | |
|  */
 | |
| #define cvg_prm_get_peer_boot_ver(peer) ((peer)->ver_info.boot_ver)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_chip_id() - get peer chip id
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: chip id
 | |
|  */
 | |
| #define cvg_prm_get_peer_chip_id(peer) ((peer)->ver_info.chip_id)
 | |
| 
 | |
| #else /* PLC_SUPPORT_VER_INFO_COMP */
 | |
| 
 | |
| #define cvg_prm_get_peer_boot_reason(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_boot_ver(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_chip_id(peer) (0)
 | |
| 
 | |
| #endif /* PLC_SUPPORT_VER_INFO_COMP */
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_uplink_inactive() - set peer uplink inactive status
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  */
 | |
| static inline void cvg_prm_set_peer_uplink_inactive(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     iot_counter_inc(peer->uplink_inactive_cnt);
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_uplink_active() - set peer uplink active status
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  */
 | |
| static inline void cvg_prm_set_peer_uplink_active(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     peer->uplink_inactive_cnt = 0;
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_uplink_active_by_tei() - set peer uplink active status
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  */
 | |
| static inline void cvg_prm_set_peer_uplink_active_by_tei(cvg_vdev_t *vdev,
 | |
|     tei_t tei)
 | |
| {
 | |
|     cvg_peer_info_t *peer;
 | |
| 
 | |
|     peer = cvg_prm_get_peer_by_tei(vdev, tei);
 | |
|     if (peer) {
 | |
|         peer->uplink_inactive_cnt = 0;
 | |
|     }
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_pco_tf_sr_send_inactive() - set peer send tf_sr report
 | |
|  *                  inactive status
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  */
 | |
| static inline void cvg_prm_set_pco_tf_sr_send_inactive(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     if (peer->role == PLC_DEV_ROLE_PCO) {
 | |
|         iot_counter_inc(peer->tf_sr_send_inactive_cnt);
 | |
|     } else {
 | |
|         peer->tf_sr_send_inactive_cnt = 0;
 | |
|     }
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_pco_tf_sr_send_active() - set peer send tf_sr report
 | |
|  *                  active status
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  */
 | |
| static inline void cvg_prm_set_pco_tf_sr_send_active(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     peer->tf_sr_send_inactive_cnt = 0;
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_inactive_cnt() - get peer inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  the number of peer inactive count
 | |
|  */
 | |
| #define cvg_prm_get_peer_inactive_cnt(peer) ((peer)->inactive_cnt)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_inactive_cnt() - set peer inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  * @cnt:    count
 | |
|  */
 | |
| #define cvg_prm_set_peer_inactive_cnt(peer, cnt) ((peer)->inactive_cnt = (cnt))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_inactive_cnt_inc() - set peer inactive count increment
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| #define cvg_prm_set_peer_inactive_cnt_inc(peer)     \
 | |
|     iot_counter_inc((peer)->inactive_cnt)
 | |
| 
 | |
| #if HPLC_RF_SUPPORT
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_pco_link_type() - set peer pco link type
 | |
|  * @param peer:      pointer to the peer
 | |
|  * @param _link_type_:link type to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_pco_link_type(peer, _link_type_) \
 | |
|     ((peer)->pco_link_type = (_link_type_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_pco_link_type() - get peer pco link type
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: pco link type
 | |
|  */
 | |
| #define cvg_prm_get_peer_pco_link_type(peer) ((peer)->pco_link_type)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_sub_link_type() - set peer sub_link_type
 | |
|  * @param peer:      pointer to the peer
 | |
|  * @param _link_type_:link type to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_sub_link_type(peer, _link_type_) \
 | |
|     ((peer)->sub_link_type = (_link_type_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_sub_link_type() - get peer sub link type
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: sub link type
 | |
|  */
 | |
| #define cvg_prm_get_peer_sub_link_type(peer) ((peer)->sub_link_type)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_comm_type() - set peer dev communication type
 | |
|  * @param peer:      pointer to the peer
 | |
|  * @param _comm_type_:comm type to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_comm_type(peer, _comm_type_) \
 | |
|     ((peer)->comm_type = (_comm_type_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_comm_type() - get peer dev communication type
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: dev communication type
 | |
|  */
 | |
| #define cvg_prm_get_peer_comm_type(peer) ((peer)->comm_type)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_pco_link_bm() - get pointer to pco bitmap of a specific
 | |
|  *                             level and link type
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @level:  level to be checked
 | |
|  * @link:   link type to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the pointer to the pco bitmap of a specific level and link type.
 | |
|  */
 | |
| cvg_tei_map_t *cvg_prm_get_pco_link_bm(cvg_vdev_t *vdev, uint8_t level,
 | |
|     uint8_t link);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_sta_link_bm() - get pointer to sta bitmap of a specific
 | |
|  *                             level and link type
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @level:  level to be checked
 | |
|  * @link:   link type to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the pointer to the sta bitmap of a specific level and link type.
 | |
|  */
 | |
| cvg_tei_map_t *cvg_prm_get_sta_link_bm(cvg_vdev_t *vdev, uint8_t level,
 | |
|     uint8_t link);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_pco_link_cnt() - get pco number of a specific link type
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @level:  level to be checked
 | |
|  * @link:   link type to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the pco number of a specific link type
 | |
|  */
 | |
| uint32_t cvg_prm_get_pco_link_cnt(cvg_vdev_t *vdev, uint8_t level, uint8_t link);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_sta_link_cnt() - get sta number of a specific link type
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @link:   link type to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the sta number of a specific link type
 | |
|  */
 | |
| uint32_t cvg_prm_get_sta_link_cnt(cvg_vdev_t *vdev, uint8_t link);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_cnt() - get number of rf dual mode device peers found
 | |
|  *                             in the network
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of rf dual mode device peers found in the network include the
 | |
|  *  self peer.
 | |
|  */
 | |
| uint16_t cvg_prm_get_peer_rf_cnt(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_cnt() - get number of hplc single mode device peers found
 | |
|  *                             in the network
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  the number of hplc single device peers found in the network include the
 | |
|  *  self peer.
 | |
|  */
 | |
| uint16_t cvg_prm_get_peer_hplc_cnt(cvg_vdev_t *vdev);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_d_sub_sta() - get pointer to peer rf direct sub
 | |
|  *              sta
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: pointer to peer rf direct sub
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_d_sub_sta(peer) ((peer)->rf_d_sub_sta)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_cco_get_nw_pco_type_stat() - get pco type statistics of whole network
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @stat:   pco type statistics of whole network
 | |
|  */
 | |
| void cvg_prm_cco_get_nw_pco_type_stat(cvg_vdev_t *vdev,
 | |
|     uint16_t stat[][CVG_PRM_LINK_BM_P_CNT]);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_cco_get_sub_pco_type_stat() - get sub-pco type statistics of peer if
 | |
|  * the peer role is pco.
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @peer:   pointer to peer
 | |
|  * @stat:   sub-pco type statistics of peer
 | |
|  */
 | |
| void cvg_prm_cco_get_sub_pco_type_stat(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer, uint16_t stat[][CVG_PRM_LINK_BM_P_CNT]);
 | |
| 
 | |
| /*
 | |
|  * @brief get hint link according to pco history statistics
 | |
|  * @param vdev:     pointer to vdev
 | |
|  * @param peer:     pointer to the peer
 | |
|  * @param link:     pointer to hint link, as return value
 | |
|  * @retval: ERR_OK - get success, ERR_FAIL - get failure
 | |
|  */
 | |
| uint8_t cvg_prm_pco_his_get_hint_link(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t *link);
 | |
| 
 | |
| #else /* HPLC_RF_SUPPORT */
 | |
| 
 | |
| #define cvg_prm_set_peer_pco_link_type(peer, link_type)
 | |
| 
 | |
| #define cvg_prm_get_peer_pco_link_type(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_sub_link_type(peer, link_type)
 | |
| 
 | |
| #define cvg_prm_get_peer_sub_link_type(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_comm_type(peer, comm_type)
 | |
| 
 | |
| #define cvg_prm_get_peer_comm_type(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_pco_link_bm(vdev, level, link) (NULL)
 | |
| 
 | |
| #define cvg_prm_get_sta_link_bm(vdev, level, link) (NULL)
 | |
| 
 | |
| #define cvg_prm_get_pco_link_cnt(vdev, level, link) (0)
 | |
| 
 | |
| #define cvg_prm_get_sta_link_cnt(vdev, link) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_cnt(vdev, link) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_hplc_cnt(vdev, link) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_d_sub_sta(peer) (NULL)
 | |
| 
 | |
| #define cvg_prm_cco_get_nw_pco_type_stat(vdev, stat)
 | |
| 
 | |
| #define cvg_prm_cco_get_sub_pco_type_stat(vdev, peer, stat)
 | |
| 
 | |
| #define cvg_prm_pco_his_get_hint_link(vdev, peer, link) (ERR_FAIL)
 | |
| 
 | |
| #endif /* HPLC_RF_SUPPORT */
 | |
| 
 | |
| #else /* PLC_SUPPORT_CCO_ROLE */
 | |
| 
 | |
| static inline void cvg_prm_set_peer_uplink_inactive(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)peer;
 | |
| }
 | |
| 
 | |
| static inline void cvg_prm_set_peer_uplink_active(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)peer;
 | |
| }
 | |
| 
 | |
| static inline void cvg_prm_set_peer_uplink_active_by_tei(cvg_vdev_t *vdev,
 | |
|     tei_t tei)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)tei;
 | |
| }
 | |
| 
 | |
| static inline void cvg_prm_set_pco_tf_sr_send_inactive(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)peer;
 | |
| }
 | |
| 
 | |
| static inline void cvg_prm_set_pco_tf_sr_send_active(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)peer;
 | |
| }
 | |
| 
 | |
| #define cvg_prm_get_most_dev_phase(vdev) (PLC_PHASE_A)
 | |
| 
 | |
| #define cvg_prm_update_pco_his(vdev, peer, proxy, link_type, from_assoc, \
 | |
|     force_bad)
 | |
| 
 | |
| #define cvg_prm_get_pco_cnt(vdev) (0)
 | |
| 
 | |
| #define cvg_prm_get_sta_cnt(vdev) (0)
 | |
| 
 | |
| static inline int8_t cvg_prm_get_peer_tx_snr(cvg_peer_info_t *peer)
 | |
| {
 | |
|     (void)peer;
 | |
|     return INVALID_SNR;
 | |
| }
 | |
| 
 | |
| static inline void cvg_prm_set_peer_tx_snr(cvg_peer_info_t *peer, int8_t snr)
 | |
| {
 | |
|     (void)peer;
 | |
|     (void)snr;
 | |
| }
 | |
| 
 | |
| #endif /* PLC_SUPPORT_CCO_ROLE */
 | |
| 
 | |
| #if (PLC_SUPPORT_ADDR_TO_TEI_MAP)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_addr() - set peer address info
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to peer
 | |
|  * @addr:   mac address info
 | |
|  */
 | |
| void cvg_prm_set_peer_addr(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t *addr);
 | |
| 
 | |
| /*
 | |
|  * @brief   cvg_prm_get_peer_addr() - get peer address info
 | |
|  * @param vdev:   pointer to vdev
 | |
|  * @param peer:   pointer to peer
 | |
|  * @param addr:   buffer to receive mac address info
 | |
|  *
 | |
|  * @retval  ERR_OK - for success case
 | |
|  * @retval  otherwise - for failure case
 | |
|  */
 | |
| uint32_t cvg_prm_get_peer_addr(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t *addr);
 | |
| 
 | |
| /**
 | |
|  * @brief cvg_prm_get_addr_by_tei() - get node address by tei
 | |
|  * @param vdev:   pointer to vdev
 | |
|  * @param tei:    query node tei
 | |
|  * @param addr:   buffer to receive mac address info
 | |
|  *
 | |
|  * @retval  ERR_OK - for success case
 | |
|  * @retval  otherwise - for failure case
 | |
|  */
 | |
| uint32_t cvg_prm_get_addr_by_tei(cvg_vdev_t *vdev, tei_t tei, uint8_t *addr);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_by_addr() -  get remote peer by mac address
 | |
|  * @vdev:   pointer to vdev to be checked
 | |
|  * @addr:   mac address to be checked
 | |
|  *
 | |
|  * return:
 | |
|  *  NULL        --  peer not exist
 | |
|  *  otherwise   --  pointer to the peer
 | |
|  */
 | |
| cvg_peer_info_t *cvg_prm_get_peer_by_addr(cvg_vdev_t *vdev, uint8_t *addr);
 | |
| 
 | |
| #else /* PLC_SUPPORT_ADDR_TO_TEI_MAP */
 | |
| 
 | |
| #define cvg_prm_get_peer_by_addr(vdev, addr) (NULL)
 | |
| 
 | |
| #define cvg_prm_set_peer_addr(vdev, peer, addr)
 | |
| 
 | |
| static inline uint32_t cvg_prm_get_peer_addr(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer, uint8_t *addr)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)peer;
 | |
| 
 | |
|     os_mem_set(addr, 0, IOT_MAC_ADDR_LEN);
 | |
|     return ERR_NOT_EXIST;
 | |
| }
 | |
| 
 | |
| static inline uint32_t cvg_prm_get_addr_by_tei(cvg_vdev_t *vdev, tei_t tei,
 | |
|     uint8_t *addr)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)tei;
 | |
| 
 | |
|     os_mem_set(addr, 0, IOT_MAC_ADDR_LEN);
 | |
|     return ERR_NOT_EXIST;
 | |
| }
 | |
| 
 | |
| #endif /* PLC_SUPPORT_ADDR_TO_TEI_MAP */
 | |
| 
 | |
| #if HPLC_RF_SUPPORT
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_hop() - set peer rf hop
 | |
|  * @vdev:   pointer to vdev
 | |
|  * @peer:   pointer to the peer
 | |
|  * @level:  rf hop to be set
 | |
|  */
 | |
| void cvg_prm_set_peer_rf_hop(cvg_vdev_t *vdev, cvg_peer_info_t *peer,
 | |
|     uint8_t rf_hop);
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_hop() - get peer rf hop
 | |
|  * @peer:   pointer to the peer
 | |
|  * return:  rf hop, range from 0 to PLC_MAX_RT_LEVEL
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_hop(peer) ((peer)->rf_hop)
 | |
| 
 | |
| #if HPLC_RF_DEV_SUPPORT
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_dp_inc() - set peer rf discovery period count increment
 | |
|  * @peer:   pointer of the peer
 | |
|  */
 | |
| void cvg_prm_set_peer_rf_dp_inc(cvg_peer_info_t *peer);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_dp_cnt() - set peer rf discovery period count
 | |
|  * @peer:   pointer of the peer
 | |
|  * @cnt:    count
 | |
|  */
 | |
| void cvg_prm_set_peer_rf_dp_cnt(cvg_peer_info_t *peer, uint8_t cnt);
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_dp_cnt() - get peer rf discovery period count
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  the number of peer rf discovery period count
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_dp_cnt(peer) ((peer)->rf_dp_cnt)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_tx_snr() - get peer rf tx snr
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: tx snr, unit is 1db
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_tx_snr(peer) ((peer)->rf_tx_snr)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_tx_snr() - set peer rf tx snr
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _snr_:    snr to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_tx_snr(peer, _snr_) ((peer)->rf_tx_snr = (_snr_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_rx_snr() - get peer rf rx snr
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: rx snr, unit is 1db
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_rx_snr(peer) ((peer)->rf_rx_snr)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_rx_snr() - set peer rf rx snr
 | |
|  * @param peer:     pointer to the peer
 | |
|  * @param _snr_:    snr to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_rx_snr(peer, _snr_) ((peer)->rf_rx_snr = (_snr_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_tx_sr() - get peer rf tx successful ratio
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: tx sr
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_tx_sr(peer) ((uint8_t)(peer)->rf_tx_sr)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_tx_sr() - set peer rf tx successful ratio
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _sr_:     tx sr
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_tx_sr(peer, _sr_) ((peer)->rf_tx_sr = (_sr_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_rx_sr() - get peer rf rx successful ratio
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: rx sr
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_rx_sr(peer) ((uint8_t)(peer)->rf_rx_sr)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_rx_sr() - set peer rf rx successful ratio
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _sr_:     successful ratio to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_rx_sr(peer, _sr_) ((peer)->rf_rx_sr = (_sr_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_wi_rx_sr() - get peer rf weight rx successful
 | |
|  *                                         ratio
 | |
|  * @param peer: pointer to the peer
 | |
|  * @retval: rf weight rx successful ratio
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_wi_rx_sr(peer) ((uint8_t)(peer)->rf_wi_rx_sr)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_wi_rx_sr() - set peer rf weight rx successful
 | |
|  *                                         ratio
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _sr_:     successful ratio to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_wi_rx_sr(peer, _sr_) ((peer)->rf_wi_rx_sr = (_sr_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_rx_rssi() - get peer rf rx rssi
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: rx rssi
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_rx_rssi(peer) ((peer)->rf_rx_rssi)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_rx_rssi() - set peer rf rx rssi
 | |
|  * @param peer:     pointer to the peer
 | |
|  * @param rssi:     rssi to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_rx_rssi(peer, rssi) ((peer)->rf_rx_rssi = (rssi))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_tf_sr() - get peer rf successful ratio
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: traffic success ratio. unit is 1%.
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_tf_sr(peer) ((uint8_t)(peer)->rf_tf_sr)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_tf_sr() - set peer rf successful ratio
 | |
|  * @parampeer:      pointer to the peer
 | |
|  * @param _sr_:     successful ratio to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_tf_sr(peer, _sr_) ((peer)->rf_tf_sr = (_sr_))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_rf_tf_sr_valid() - get peer rf successful ratio valid
 | |
|  *        flag
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval: 1 - valid, 0 - invalid
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_tf_sr_valid(peer) ((peer)->rf_tf_sr_valid)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_tf_sr_valid() - set peer rf successful ratio valid
 | |
|  *        flag
 | |
|  * @param peer:      pointer to the peer
 | |
|  * @param valid:    valid flag
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_tf_sr_valid(peer, valid) \
 | |
|     ((peer)->rf_tf_sr_valid = (valid))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_bc_dis_rx() - set peer rf beacon and rf discovery
 | |
|  *                   list rx flag
 | |
|  * @param peer:      pointer to the peer
 | |
|  * @param rx_flag:   receive flag
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_bc_dis_rx(peer, rx_flag) \
 | |
|     ((peer)->rf_bc_dis_rx = (rx_flag))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_bc_dis_rx() - get peer rf beacon and rf discovery list
 | |
|  *          rx flag
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  flag to mark if rf beacon and rf bediscovery list mme ever received
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_bc_dis_rx(peer) ((peer)->rf_bc_dis_rx)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_prev_bc_dis_rx() - set peer rf beacon and rf
 | |
|  *                   discovery list rx flag in previous rf calculation period
 | |
|  * @param peer:      pointer to the peer
 | |
|  * @param rx_flag:   receive flag
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_prev_bc_dis_rx(peer, rx_flag) \
 | |
|     ((peer)->rf_prev_bc_dis_rx = (rx_flag))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_prev_bc_dis_rx() - get peer rf beacon and rf discovery
 | |
|  *          list rx flag in previous rf calculation period
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  flag to mark if rf beacon and rf bediscovery list mme ever received
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_prev_bc_dis_rx(peer) ((peer)->rf_prev_bc_dis_rx)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_seq_valid() - get peer rf start seq valid flag
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  flag to mark if rf_seq_valid is valid
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_seq_valid(peer) ((peer)->rf_seq_valid)
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_set_peer_rf_seq_valid() - set peer rf start seq valid flag
 | |
|  * @param peer:      pointer to the peer
 | |
|  * @param flag:      flag to mark if rf_seq_valid is valid
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_seq_valid(peer, flag) \
 | |
|     ((peer)->rf_seq_valid = (flag))
 | |
| 
 | |
| /*
 | |
|  * @brief cvg_prm_get_peer_to_cco_rf_min_tf_sr() - get min rf traffic success
 | |
|  *        ratio from local device to cco through the appointed peer.
 | |
|  * @param peer: pointer to the peer
 | |
|  *
 | |
|  * @retval  0 - 100 traffic success ratio. unit is 1%.
 | |
|  */
 | |
| static inline uint8_t cvg_prm_get_peer_to_cco_rf_min_tf_sr(cvg_peer_info_t *peer)
 | |
| {
 | |
|     if ((uint8_t)peer->cco_tf_sr < peer->rf_tf_sr)
 | |
|         return (uint8_t)peer->cco_tf_sr;
 | |
|     else
 | |
|         return (uint8_t)peer->rf_tf_sr;
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_inactive_cnt() - get peer rf link inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  the number of peer rf inactive count
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_inactive_cnt(peer) ((peer)->rf_inactive_cnt)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_inactive_cnt() - set peer rf link inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  * @cnt:    count
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_inactive_cnt(peer, cnt) \
 | |
|     (((peer)->rf_inactive_cnt) = (cnt))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_inactive_inc() - set peer rf link inactive count increment
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_inactive_inc(peer) \
 | |
|     iot_counter_inc((peer)->rf_inactive_cnt)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_dis_inactive_cnt() - get peer rf discovery list
 | |
|  *                                          inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  the number of peer rf discovery list inactive count
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_dis_inactive_cnt(peer) ((peer)->rf_dis_inactive_cnt)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_dis_inactive_cnt() - set peer rf discovery list
 | |
|  *                                          inactive count
 | |
|  * @peer:   pointer to the peer
 | |
|  * @cnt:    count
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_dis_inactive_cnt(peer, cnt) \
 | |
|     (((peer)->rf_dis_inactive_cnt) = (cnt))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_dis_inactive_inc() - set peer rf discovery list
 | |
|  *                                          inactive count increment
 | |
|  * @peer:   pointer to the peer
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_dis_inactive_inc(peer) \
 | |
|     iot_counter_inc((peer)->rf_dis_inactive_cnt)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_start_seq() - get peer rf discovery list start seq
 | |
|  * @peer:   pointer to the peer
 | |
|  *
 | |
|  * @return:
 | |
|  *  the value of peer rf discovery list start seq
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_start_seq(peer) ((peer)->rf_start_seq)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_start_seq() - set peer rf discovery list start seq
 | |
|  * @peer:       pointer to the peer
 | |
|  * @start_seq:  rf discovery list start seq
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_start_seq(peer, seq) \
 | |
|     (((peer)->rf_start_seq) = (seq))
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_get_peer_rf_rcv_bm() - get peer rf receive bitmap
 | |
|  * @peer:       pointer to the peer
 | |
|  * @return:     peer rf receive bitmap
 | |
|  */
 | |
| #define cvg_prm_get_peer_rf_rcv_bm(peer) ((peer)->rf_rcv_bm)
 | |
| 
 | |
| /*
 | |
|  * cvg_prm_set_peer_rf_rcv_bm() - set peer rf receive bitmap
 | |
|  * @peer:       pointer to the peer
 | |
|  * @rcv_bm:     rf receive bitmap to be set
 | |
|  */
 | |
| #define cvg_prm_set_peer_rf_rcv_bm(peer, rcv_bm) \
 | |
|     (((peer)->rf_rcv_bm) = (rcv_bm))
 | |
| 
 | |
| #else /* HPLC_RF_DEV_SUPPORT */
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tx_snr(peer, snr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tx_snr(peer) (INVALID_SNR)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rx_snr(peer, snr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rx_snr(peer) (INVALID_SNR)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rx_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rx_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_wi_rx_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_wi_rx_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tx_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tx_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rx_rssi(peer, rssi)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rx_rssi(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tf_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tf_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tf_sr_valid(peer, valid)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_bc_dis_rx(peer, rx_flag)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_bc_dis_rx(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_prev_bc_dis_rx(peer, rx_flag)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_prev_bc_dis_rx(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_seq_valid(peer, flag)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_seq_valid(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tf_sr_valid(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_to_cco_rf_min_tf_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_inactive_cnt(peer) (0xff)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_inactive_cnt(peer, cnt)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_inactive_inc(peer)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_dis_inactive_cnt(peer) (0xff)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dis_inactive_cnt(peer, cnt)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dis_inactive_inc(peer)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_dp_cnt(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dp_cnt(peer, cnt)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dp_inc(peer)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_start_seq(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_start_seq(peer, seq)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rcv_bm(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rcv_bm(peer, rcv_bm)
 | |
| 
 | |
| #endif /* HPLC_RF_DEV_SUPPORT */
 | |
| 
 | |
| #else /* HPLC_RF_SUPPORT */
 | |
| 
 | |
| static inline void cvg_prm_set_peer_rf_hop(cvg_vdev_t *vdev,
 | |
|     cvg_peer_info_t *peer, uint8_t rf_hop)
 | |
| {
 | |
|     (void)vdev;
 | |
|     (void)peer;
 | |
|     (void)rf_hop;
 | |
| }
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_hop(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tx_snr(peer, snr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tx_snr(peer) (INVALID_SNR)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rx_snr(peer, snr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rx_snr(peer) (INVALID_SNR)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rx_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rx_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_wi_rx_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_wi_rx_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tx_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tx_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rx_rssi(peer, rssi)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rx_rssi(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tf_sr(peer, sr)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tf_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_tf_sr_valid(peer, valid)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_bc_dis_rx(peer, rx_flag)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_bc_dis_rx(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_prev_bc_dis_rx(peer, rx_flag)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_prev_bc_dis_rx(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_seq_valid(peer, flag)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_seq_valid(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_tf_sr_valid(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_to_cco_rf_min_tf_sr(peer) (0)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_inactive_cnt(peer) (0xff)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_inactive_cnt(peer, cnt)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_inactive_inc(peer)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_dis_inactive_cnt(peer) (0xff)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dis_inactive_cnt(peer, cnt)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dis_inactive_inc(peer)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_dp_cnt(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dp_cnt(peer, cnt)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_dp_inc(peer)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_start_seq(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_start_seq(peer, seq)
 | |
| 
 | |
| #define cvg_prm_get_peer_rf_rcv_bm(peer) (0)
 | |
| 
 | |
| #define cvg_prm_set_peer_rf_rcv_bm(peer, rcv_bm)
 | |
| 
 | |
| #endif /* HPLC_RF_SUPPORT */
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif /* CVG_PRM_H */
 |