1151 lines
		
	
	
		
			37 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			1151 lines
		
	
	
		
			37 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_H
							 | 
						||
| 
								 | 
							
								#define CVG_NWM_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* os shim includes */
							 | 
						||
| 
								 | 
							
								#include "os_types.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* public api includes */
							 | 
						||
| 
								 | 
							
								#include "cvg_api.h"
							 | 
						||
| 
								 | 
							
								#include "plc_protocol.h"
							 | 
						||
| 
								 | 
							
								#include "plc_utils.h"
							 | 
						||
| 
								 | 
							
								#include "plc_rf_scan_tbl.h"
							 | 
						||
| 
								 | 
							
								#include "mac_data_api.h"
							 | 
						||
| 
								 | 
							
								#include "mac_bcm_api.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* cvg module internal includes */
							 | 
						||
| 
								 | 
							
								#include "cvg.h"
							 | 
						||
| 
								 | 
							
								#include "cvg_prm.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* common includes */
							 | 
						||
| 
								 | 
							
								#include "iot_pkt.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* this value defined the default allowed re-assoc retry duration in assoc
							 | 
						||
| 
								 | 
							
								 * reject reponse frame. unit is 1ms.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CVG_CCO_RE_ASSOC_INTERVAL       (10 * 1000)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* this value defined the maximum allowed min beacon period limit. unit is 1s. */
							 | 
						||
| 
								 | 
							
								#define CVG_CCO_MIN_BC_PERIOD_LIMIT     (4)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if (PLC_SUPPORT_CCO_ROLE == 1) && (RUN_IN_PSRAM == 0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* maximum allowed number of PCO devices in the whole network, this value
							 | 
						||
| 
								 | 
							
								 * should be small enough and less than cvg_nwm_cco_get_non_cco_bc_slot_max_sg
							 | 
						||
| 
								 | 
							
								 * and cvg_nwm_cco_get_non_cco_bc_slot_max_spg so that we can reserve enough
							 | 
						||
| 
								 | 
							
								 * beacon slot for discovery beacon.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CVG_PCO_MAX_CNT \
							 | 
						||
| 
								 | 
							
								    (PLC_TEI_MAX_NUM < 32 ? PLC_TEI_MAX_NUM : 32)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#else /* (PLC_SUPPORT_CCO_ROLE == 1) && (RUN_IN_PSRAM == 0) */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if HPLC_RF_SUPPORT
							 | 
						||
| 
								 | 
							
								/* maximum allowed number of PCO devices in the whole network, this value
							 | 
						||
| 
								 | 
							
								 * should be small enough and less than cvg_nwm_cco_get_non_cco_bc_slot_max_sg
							 | 
						||
| 
								 | 
							
								 * and cvg_nwm_cco_get_non_cco_bc_slot_max_spg so that we can reserve enough
							 | 
						||
| 
								 | 
							
								 * beacon slot for discovery beacon.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CVG_PCO_MAX_CNT \
							 | 
						||
| 
								 | 
							
								    (PLC_TEI_MAX_NUM < 150 ? PLC_TEI_MAX_NUM : 150)
							 | 
						||
| 
								 | 
							
								#else /* HPLC_RF_SUPPORT */
							 | 
						||
| 
								 | 
							
								/* maximum allowed number of PCO devices in the whole network, this value
							 | 
						||
| 
								 | 
							
								 * should be small enough and less than cvg_nwm_cco_get_non_cco_bc_slot_max_sg
							 | 
						||
| 
								 | 
							
								 * and cvg_nwm_cco_get_non_cco_bc_slot_max_spg so that we can reserve enough
							 | 
						||
| 
								 | 
							
								 * beacon slot for discovery beacon.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CVG_PCO_MAX_CNT \
							 | 
						||
| 
								 | 
							
								    (PLC_TEI_MAX_NUM < 110 ? PLC_TEI_MAX_NUM : 110)
							 | 
						||
| 
								 | 
							
								#endif /* HPLC_RF_SUPPORT */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* (PLC_SUPPORT_CCO_ROLE == 1) && (RUN_IN_PSRAM == 0) */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* max number of assoc conf mme fragments supported */
							 | 
						||
| 
								 | 
							
								#define CVG_NWM_MAX_ASSOC_FRAG          (15)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* max number of proxy change conf mme fragments supported
							 | 
						||
| 
								 | 
							
								 * ---non bitmap version.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CVG_NWM_MAX_PROXY_CHAGE_FRAG    CVG_NWM_MAX_ASSOC_FRAG
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* configure the iot pkt size when reply proxy change conf mme --non bitmap
							 | 
						||
| 
								 | 
							
								 * version and assoc conf mme.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CVG_CONF_FRAG_USE_PKT_SIZE      PLC_SHORT_BUF_SIZE
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* zc collect on invalid edge */
							 | 
						||
| 
								 | 
							
								#define CVG_ZC_CT_EDGE_INVALID          0
							 | 
						||
| 
								 | 
							
								/* zc collect on falling edge */
							 | 
						||
| 
								 | 
							
								#define CVG_ZC_CT_EDGE_FALLING          1
							 | 
						||
| 
								 | 
							
								/* zc collect on rising edge */
							 | 
						||
| 
								 | 
							
								#define CVG_ZC_CT_EDGE_RISING           2
							 | 
						||
| 
								 | 
							
								/* zc collect on falling and rising edge */
							 | 
						||
| 
								 | 
							
								#define CVG_ZC_CT_EDGE_ALL              3
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* device watch dog duration. unit is 1 min */
							 | 
						||
| 
								 | 
							
								#if IOT_SMART_CONFIG
							 | 
						||
| 
								 | 
							
								#define CVG_NWM_WDG_DUR                 (30)
							 | 
						||
| 
								 | 
							
								#else
							 | 
						||
| 
								 | 
							
								#define CVG_NWM_WDG_DUR                 (51)
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* join check code, it is "XY" for hunan,
							 | 
						||
| 
								 | 
							
								 * the low byte is "Y" and the high byte is "X"
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CVG_NWM_JOIN_CHECK_CODE         0x5859
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* local network info */
							 | 
						||
| 
								 | 
							
								typedef struct _cvg_nw_info {
							 | 
						||
| 
								 | 
							
								    /* tei of the cco */
							 | 
						||
| 
								 | 
							
								    tei_t       cco;
							 | 
						||
| 
								 | 
							
								    /* mac address of the cco */
							 | 
						||
| 
								 | 
							
								    uint8_t     addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* tei of the PCo. PLC_TEI_INVAL for CCo as CCo has no PCo. */
							 | 
						||
| 
								 | 
							
								    tei_t       pco_tei;
							 | 
						||
| 
								 | 
							
								    /* network serial number */
							 | 
						||
| 
								 | 
							
								    uint8_t     network_sn;
							 | 
						||
| 
								 | 
							
								    /* flag to mark if allow to use beacon to eveluate the channel */
							 | 
						||
| 
								 | 
							
								    uint8_t     allow_chan_eval     :1,
							 | 
						||
| 
								 | 
							
								    /* for CCO role case, flag to mark if whole network formation done
							 | 
						||
| 
								 | 
							
								     * for STA role case, flag to makr if local device network formation done
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								                nw_fmt_done         :1,
							 | 
						||
| 
								 | 
							
								    /* for CCO role case, flag to mark if whole network route learning done
							 | 
						||
| 
								 | 
							
								     * for STA role case, flag to mark if local device route learning done
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								                route_learn_done    :1,
							 | 
						||
| 
								 | 
							
								    /* only for CCO role case, flag to mark if cco device test is detected. */
							 | 
						||
| 
								 | 
							
								                cco_test_detected   :1,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if in in_cco_wl flag is valid */
							 | 
						||
| 
								 | 
							
								                in_cco_wl_valid     :1,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if local device is in white list of the network */
							 | 
						||
| 
								 | 
							
								                in_cco_wl           :1,
							 | 
						||
| 
								 | 
							
								    /* logic phase */
							 | 
						||
| 
								 | 
							
								                logic_phase         :2;
							 | 
						||
| 
								 | 
							
								    /* network id */
							 | 
						||
| 
								 | 
							
								    uint32_t    nid;
							 | 
						||
| 
								 | 
							
								    /* smart grid device type, used in sta device only */
							 | 
						||
| 
								 | 
							
								    uint8_t     dev_type;
							 | 
						||
| 
								 | 
							
								    /* hplc rx snr from the network to local device */
							 | 
						||
| 
								 | 
							
								    int8_t      snr;
							 | 
						||
| 
								 | 
							
								    /* flag to mark if force link communication */
							 | 
						||
| 
								 | 
							
								    uint8_t     force_link_valid    :1,
							 | 
						||
| 
								 | 
							
								    /* force link type, 1 - force rf, 0 - force hplc */
							 | 
						||
| 
								 | 
							
								                force_rf_link       :1,
							 | 
						||
| 
								 | 
							
								    /* conn less mr only */
							 | 
						||
| 
								 | 
							
								                cco_rf_tx_only_conn :1,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if production test is detected */
							 | 
						||
| 
								 | 
							
								                pt_detected         :1,
							 | 
						||
| 
								 | 
							
								    /* reserved for future  */
							 | 
						||
| 
								 | 
							
								                rsvd                :4;
							 | 
						||
| 
								 | 
							
								} cvg_nw_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* transformer area detect status */
							 | 
						||
| 
								 | 
							
								typedef struct _cvg_tsfm_status {
							 | 
						||
| 
								 | 
							
								    /* transformer area detect status. see IOT_PLC_TSFM_DETECT_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t             status;
							 | 
						||
| 
								 | 
							
								    /* mac address of the transformer area that local device possibly
							 | 
						||
| 
								 | 
							
								     * belong to. this value is is only available when transformer detect
							 | 
						||
| 
								 | 
							
								     * feature is enabled.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t             tsfm_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								    /* CCO mac address of the transformer area that local device possibly
							 | 
						||
| 
								 | 
							
								     * belong to. this value is is only available when transformer detect
							 | 
						||
| 
								 | 
							
								     * feature is enabled.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t             cco_addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cvg_tsfm_status_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* physical phase info */
							 | 
						||
| 
								 | 
							
								typedef struct _cvg_phase_info {
							 | 
						||
| 
								 | 
							
								    /* identification done */
							 | 
						||
| 
								 | 
							
								    uint8_t    done:              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,
							 | 
						||
| 
								 | 
							
								    /* physical phase of the device, bit0-2 means phaseA/B/C, set "1" to
							 | 
						||
| 
								 | 
							
								     * indicate which phase the device belongs to.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								               phy_phase:         3,
							 | 
						||
| 
								 | 
							
								    /* logical phase of the device, see PLC_PHASE_XXX */
							 | 
						||
| 
								 | 
							
								               logic_phase:       2,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if L/N reversed in Three-phase power meter */
							 | 
						||
| 
								 | 
							
								               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.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    uint8_t    opposite_3p_pos:   2,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if the 3phase device have the zc repeat phase */
							 | 
						||
| 
								 | 
							
								               zc_repeat_3p:      1,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								               reserved1:         5;
							 | 
						||
| 
								 | 
							
								} cvg_phase_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* neighbour network information */
							 | 
						||
| 
								 | 
							
								typedef struct _cvg_nwm_nn_info_t {
							 | 
						||
| 
								 | 
							
								    /* nid of the neighbour network */
							 | 
						||
| 
								 | 
							
								    uint32_t    nid             :24,
							 | 
						||
| 
								 | 
							
								    /* flag indicate if neighbour network is single-pass to local network
							 | 
						||
| 
								 | 
							
								     * 1 means single-pass. 0 means double-pass.
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								                sp_flag         :1,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if beacon data is available */
							 | 
						||
| 
								 | 
							
								                bc_data_flag    :1,
							 | 
						||
| 
								 | 
							
								    /* flag to mark if cco mac address is available */
							 | 
						||
| 
								 | 
							
								                addr_flag       :1,
							 | 
						||
| 
								 | 
							
								    /* reserved for future */
							 | 
						||
| 
								 | 
							
								                rsvd            :5;
							 | 
						||
| 
								 | 
							
								    /* bandwidth taken by neighbour network in millisecond */
							 | 
						||
| 
								 | 
							
								    uint32_t    bandwidth;
							 | 
						||
| 
								 | 
							
								    /* each phase snr of the network */
							 | 
						||
| 
								 | 
							
								    int8_t      snr[PLC_PHASE_CNT];
							 | 
						||
| 
								 | 
							
								    /* beacon data info */
							 | 
						||
| 
								 | 
							
								    uint8_t     bc_data[MAC_BC_APP_DATA_MAX];
							 | 
						||
| 
								 | 
							
								    /* cco mac address */
							 | 
						||
| 
								 | 
							
								    uint8_t     addr[IOT_MAC_ADDR_LEN];
							 | 
						||
| 
								 | 
							
								} cvg_nwm_nn_info_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_init() - global init of network management module
							 | 
						||
| 
								 | 
							
								 * @glb:    pointer of cvg global data
							 | 
						||
| 
								 | 
							
								 * @cfg:    pointer of cvg configuration
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:
							 | 
						||
| 
								 | 
							
								 *      0         -- for success case
							 | 
						||
| 
								 | 
							
								 *      othersie  -- error code
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_init(cvg_global_t *glb, cvg_cfg_t *cfg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_init_vdev() - vdev init of network 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_nwm_init_vdev(cvg_vdev_t *vdev, cvg_vdev_cfg_t *cfg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_deinit_vdev() - vdev deinit of network management module
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev to be deinit
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_deinit_vdev(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_reset_vdev() - vdev reset of network management module
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev to be reset
							 | 
						||
| 
								 | 
							
								 * @cfg:    pointer of vdev configuration
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_reset_vdev(cvg_vdev_t *vdev, cvg_vdev_cfg_t *cfg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief   dump nwm 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_nwm_status_dump(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_vdev_sm() - vdev state machine entry function
							 | 
						||
| 
								 | 
							
								 * @vdev:   vdev pointer of the state machine
							 | 
						||
| 
								 | 
							
								 * @event:  event to be delivered
							 | 
						||
| 
								 | 
							
								 * @data:   data pointer of the event
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_vdev_sm(cvg_vdev_t *vdev, cvg_vdev_event_t event, void *data);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_get_self_peer() - get self peer pointer
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return: pointer to self peer of the vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								cvg_peer_info_t *cvg_nwm_get_self_peer(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_get_local_tei() - get tei of local device
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return: tei of local device
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								tei_t cvg_nwm_get_local_tei(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_get_proxy_peer() - get proxy peer pointer
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return: pointer to proxy peer of the vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								cvg_peer_info_t *cvg_nwm_get_proxy_peer(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_get_nw_info() - get network info
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @info:   pointer to memory to receive the network info
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_get_nw_info(cvg_vdev_t *vdev, cvg_nw_info_t *info);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_get_bc_msdu_sn() - get next available msdu sn for broadcast frame tx
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:
							 | 
						||
| 
								 | 
							
								 *  msdu sn
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint16_t cvg_nwm_get_bc_msdu_sn(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_get_uc_msdu_sn() - get next available msdu sn for unicast frame tx
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:
							 | 
						||
| 
								 | 
							
								 *  msdu sn
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint16_t cvg_nwm_get_uc_msdu_sn(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_get_reboot_cnt() - get vdev reboot count
							 | 
						||
| 
								 | 
							
								 * @param vdev:         vdev to be retrieved
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @retval 0 - 15       -- reboot count
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_get_reboot_cnt(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* cvg_nwm_is_vdev_ready() - check if vdev network is ready
							 | 
						||
| 
								 | 
							
								 * @vdev:   the vdev to be checked
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:
							 | 
						||
| 
								 | 
							
								 *  1   -   if vdev network is ready
							 | 
						||
| 
								 | 
							
								 *  0   -   otherwise
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_vdev_ready(cvg_vdev_t* vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* cvg_nwm_is_vdev_started() - check if vdev is started
							 | 
						||
| 
								 | 
							
								 * @vdev:   the vdev to be checked
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:
							 | 
						||
| 
								 | 
							
								 *  1   -   if vdev is started
							 | 
						||
| 
								 | 
							
								 *  0   -   otherwise
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_vdev_started(cvg_vdev_t* vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* @brief:      check if vdev is idle
							 | 
						||
| 
								 | 
							
								 * @param vdev: the vdev to be checked
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @retval:
							 | 
						||
| 
								 | 
							
								 *  1   -   if vdev is idle
							 | 
						||
| 
								 | 
							
								 *  0   -   otherwise
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_vdev_idle(cvg_vdev_t* vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_mac_tx_info_init() - init mac tx info
							 | 
						||
| 
								 | 
							
								 * @param vdev:     vdev pointer
							 | 
						||
| 
								 | 
							
								 * @param tx_info:  pointer to tx_info to be init
							 | 
						||
| 
								 | 
							
								 * @param bcast:    set to 1 to enable broadcast
							 | 
						||
| 
								 | 
							
								 * @param lid:      link id
							 | 
						||
| 
								 | 
							
								 * @param dest:     destination tei
							 | 
						||
| 
								 | 
							
								 * @param is_rf:    flag to mark if this packet is sent to rf link, if is_rf ==
							 | 
						||
| 
								 | 
							
								 *                  NULL means that it is determined by the internal function
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return  ERR_OK for success case
							 | 
						||
| 
								 | 
							
								 *          otherwise for failure case
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_mac_tx_info_init(cvg_vdev_t *vdev, mac_tx_info *tx_info,
							 | 
						||
| 
								 | 
							
								    uint8_t bcast, lid_t lid, tei_t dest, uint8_t *is_rf);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_is_vdev_testing() -  check if vdev is testing.
							 | 
						||
| 
								 | 
							
								 * @param vdev:   the vdev to be checked.
							 | 
						||
| 
								 | 
							
								 * @retval:   1   --   if vdev is testing.
							 | 
						||
| 
								 | 
							
								 * @retval:   0   --   otherwise.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_vdev_testing(cvg_vdev_t* vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_get_vdev_state() - get vdev state
							 | 
						||
| 
								 | 
							
								 * @param vdev:     the vdev to be checked.
							 | 
						||
| 
								 | 
							
								 * @retval:         vdev state. see cco_state_XXX and sta_state_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_get_vdev_state(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_vdev_modif_start_reason() -  modify the last startup reason
							 | 
						||
| 
								 | 
							
								 *                                             of vdev.
							 | 
						||
| 
								 | 
							
								 * @param vdev:           the vdev to be modified.
							 | 
						||
| 
								 | 
							
								 * @param start_reason:   start reason, see CVG_VDEV_START_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_vdev_modify_start_reason(cvg_vdev_t *vdev, uint8_t start_reason);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_vdev_get_start_reason() -  get the last startup reason
							 | 
						||
| 
								 | 
							
								 *                                           of vdev.
							 | 
						||
| 
								 | 
							
								 * @param vdev:           the vdev to be queried.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_vdev_get_start_reason(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_vdev_get_leave_reason() -  get the last leave network reason
							 | 
						||
| 
								 | 
							
								 *                                           of vdev.
							 | 
						||
| 
								 | 
							
								 * @param vdev:           the vdev to be queried.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_vdev_get_leave_reason(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief  get neighbor network info from vde by index
							 | 
						||
| 
								 | 
							
								 * @param vdev:           the vdev to be queried.
							 | 
						||
| 
								 | 
							
								 * @param index:          the index of neighbor to be queried.
							 | 
						||
| 
								 | 
							
								 * @param n_info:         return neighbor network information of the index.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_get_nb_nw_info_by_index(cvg_vdev_t *vdev, uint8_t index,
							 | 
						||
| 
								 | 
							
								    cvg_nwm_nn_info_t *n_info);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_get_nb_nw_info_by_nid() - get neighbor network info from vdev
							 | 
						||
| 
								 | 
							
								 *        by nid
							 | 
						||
| 
								 | 
							
								 * @param vdev:   the vdev to be queried.
							 | 
						||
| 
								 | 
							
								 * @param nid:    network id.
							 | 
						||
| 
								 | 
							
								 * @param n_info: return neighbor network information.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_get_nb_nw_info_by_nid(cvg_vdev_t *vdev, uint32_t nid,
							 | 
						||
| 
								 | 
							
								    cvg_nwm_nn_info_t *n_info);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief check if association of current network is done
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @retval:
							 | 
						||
| 
								 | 
							
								 *      0 - network association is not done
							 | 
						||
| 
								 | 
							
								 *      otherwise - network association is done
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_assoc_done(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief enable/disable discovered node report
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @retval:
							 | 
						||
| 
								 | 
							
								 *      0 - request accepted
							 | 
						||
| 
								 | 
							
								 *      otherwise - see ERR_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_enable_discovery(cvg_vdev_t *vdev, uint8_t enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_get_fixed_rate_level() - get nwm fix rate level config.
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:         fixed rate level, see PLC_RATE_ADAPT_RATE_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_get_fixed_rate_level(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_get_fixed_rate() - get nwm fix rate mode config.
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param is_local: 0 - get whole network config, 1 - get local config
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:         0 - auto rate mode, 1 - fix rate mode.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_get_fixed_rate(cvg_vdev_t *vdev, uint8_t is_local);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_set_fixed_rate() - set nwm fix rate config.
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param is_local: 0 - set whole network config, 1 - set local config
							 | 
						||
| 
								 | 
							
								 * @param enable:   0 - set to fix rate mode, others - set to auto rate mode.
							 | 
						||
| 
								 | 
							
								 * @param rate_level: fixed rate level, see PLC_RATE_ADAPT_RATE_XXX.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:         none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_set_fixed_rate(cvg_vdev_t *vdev, uint8_t is_local,
							 | 
						||
| 
								 | 
							
								    uint8_t enable, uint8_t rate_level);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief  cvg_nwm_set_force_link() - set force link communication
							 | 
						||
| 
								 | 
							
								 * @param vdev:          pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @param enable:        flag to mark if force link communication
							 | 
						||
| 
								 | 
							
								 *                       0 - disable, 1 - enable
							 | 
						||
| 
								 | 
							
								 * @param is_rf:         force link type, 1 - force rf, 0 - force hplc
							 | 
						||
| 
								 | 
							
								 * @return  0 - for success case
							 | 
						||
| 
								 | 
							
								 *          otherwise - error code. see ERR_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_set_force_link(cvg_vdev_t *vdev, uint8_t enable, uint8_t is_rf);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_vdev_get_zc_edge_type() -  get the zc collection edge type
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @retval: collection type. see CVG_ZC_CT_EDGE_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_vdev_get_zc_edge_type(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_join_check() - join check handle
							 | 
						||
| 
								 | 
							
								 * @param vdev:       pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param join_check: flag to mark if enable join check,
							 | 
						||
| 
								 | 
							
								 *                    1 - enable, 0 - disable
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:           none
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_join_check(cvg_vdev_t *vdev, uint8_t join_check);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_addr_check() - check if the addr is same as vdev addr,
							 | 
						||
| 
								 | 
							
								                                 or is included in pm addr list
							 | 
						||
| 
								 | 
							
								 * @param vdev:       pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param addr:       mac address to be checked, big-endian
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:           1 - same addr, 0 - not same addr
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_addr_check(cvg_vdev_t *vdev, uint8_t *addr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_app_sniffer_cfg() - configure app sniffer function request
							 | 
						||
| 
								 | 
							
								 * @param vdev:      pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param cmd:       0 - disabled, other - enable.
							 | 
						||
| 
								 | 
							
								 * @return:          1 - config change, 0 - config no change.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_app_sniffer_cfg_req(cvg_vdev_t *vdev, uint8_t cmd);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_convert_dev_type_to_pro() - convert device type from smart
							 | 
						||
| 
								 | 
							
								 *                                        grid to the actual transmission proto
							 | 
						||
| 
								 | 
							
								 * @param: sg_dev  -  smart grid device type, see PLC_DEV_TYPE_XXX
							 | 
						||
| 
								 | 
							
								 * @return         -  device type of the actual transmission proto
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_convert_dev_type_to_pro(uint8_t sg_dev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_convert_pro_to_dev_type() - convert device type from the
							 | 
						||
| 
								 | 
							
								 *                                      actual transmission proto to smart grid
							 | 
						||
| 
								 | 
							
								 * @param: pro_dev   -  device type of the actual transmission proto,
							 | 
						||
| 
								 | 
							
								 *                      see PLC_DEV_TYPE_I1901_XXX
							 | 
						||
| 
								 | 
							
								 * @return           -  smart grid device type
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_convert_pro_to_dev_type(uint8_t pro_dev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief convert assoc result code from sg to the actual transmission proto
							 | 
						||
| 
								 | 
							
								 * @param sg_ret:      smart grid associate result code
							 | 
						||
| 
								 | 
							
								 * @return             associate result code of the actual transmission proto
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_convert_assoc_result_to_pro(uint8_t sg_ret);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief convert assoc result code from the actual transmission proto to sg
							 | 
						||
| 
								 | 
							
								 * @param pro_ret:     associate result code of the actual transmission proto
							 | 
						||
| 
								 | 
							
								 * @return             smart grid associate result code
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_convert_pro_to_assoc_result(uint8_t pro_ret);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief convert role type from sg to the actual transmission proto
							 | 
						||
| 
								 | 
							
								 * @param sg_role:     smart grid role type, PLC_DEV_ROLE_XXX
							 | 
						||
| 
								 | 
							
								 * @return             role type of the actual transmission proto
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_convert_role_to_pro(uint8_t sg_role);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief convert role type from the actual transmission proto to sg
							 | 
						||
| 
								 | 
							
								 * @param pro_role:    role type of the actual transmission proto,
							 | 
						||
| 
								 | 
							
								 *                     see I1901_PLC_DEV_ROLE_XXX
							 | 
						||
| 
								 | 
							
								 * @return             smart grid role type
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_convert_pro_to_role(uint8_t pro_role);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_is_3_phase_dev_type() - check if device type is 3 phase device
							 | 
						||
| 
								 | 
							
								 * @param dev_type:    device type, see PLC_DEV_TYPE_XXX.
							 | 
						||
| 
								 | 
							
								 * @return:            0 - single phase device, 1 - 3 phase device
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_3_phase_dev_type(uint8_t dev_type);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sof_rx_statistic() - sof rx msdu info statistic
							 | 
						||
| 
								 | 
							
								 * @param vdev:       pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param is_mme:     flag to mark if it is mme packet
							 | 
						||
| 
								 | 
							
								 * @param is_rf:      flag to mark if it is rf link packet
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sof_rx_statistic(cvg_vdev_t *vdev, uint8_t is_mme, uint8_t is_rf);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_crypto_async_done() - async crypto done handling func,
							 | 
						||
| 
								 | 
							
								 *                               same as iot_crypto_async_done_func_t
							 | 
						||
| 
								 | 
							
								 * @param result:     iot_pkt containing async crypto handling result
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_crypto_async_done(iot_pkt_t *result);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_is_lock_phase_en() - check if level 1 device has been
							 | 
						||
| 
								 | 
							
								 *                                     locked logical phase
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  0           -- not locked
							 | 
						||
| 
								 | 
							
								 *  otherwise   -- locked
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_lock_phase_en(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_is_bc_d_with_non() - check if discovery beacon send with non
							 | 
						||
| 
								 | 
							
								 *                                     cco node info
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  0           -- send without non cco node info
							 | 
						||
| 
								 | 
							
								 *  otherwise   -- send with non cco node info
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_is_bc_d_with_non(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if (PLC_SUPPORT_CCO_ROLE)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_cco_disconnect_peer() - Disconnect peers
							 | 
						||
| 
								 | 
							
								 * @vdev:   vdev pointer
							 | 
						||
| 
								 | 
							
								 * @cnt:    the number of PCO/STA
							 | 
						||
| 
								 | 
							
								 * @addr:   the address of PCO/STA need to disconnect
							 | 
						||
| 
								 | 
							
								 * @reason: the reasons of disconnect peers, see IOT_PLC_INVD_MAC_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_disconnect_peer(cvg_vdev_t *vdev, uint32_t cnt,
							 | 
						||
| 
								 | 
							
								    uint8_t addr[][IOT_MAC_ADDR_LEN], uint8_t reason);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_wbl_changed() - notify nwm cco module that
							 | 
						||
| 
								 | 
							
								 *                                    white list or black list changed
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_wbl_changed(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_set_wl_joined_done() - set whitelist nodes joined network
							 | 
						||
| 
								 | 
							
								 *        status.
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @param wl_joined_done: 1 - whitelist nodes join network completed.
							 | 
						||
| 
								 | 
							
								 *         0 - whitelist nodes join network not completed.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_set_wl_joined_done(cvg_vdev_t *vdev, uint8_t wl_joined_done);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_get_wl_joined_done() - get whitelist nodes joined network
							 | 
						||
| 
								 | 
							
								 *        status.
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @return 1 - whitelist nodes join network completed.
							 | 
						||
| 
								 | 
							
								 *         0 - whitelist nodes join network not completed.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_cco_get_wl_joined_done(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief   set beacon data. beacon data can be broadcast to whole network in
							 | 
						||
| 
								 | 
							
								 *          each beacon period.
							 | 
						||
| 
								 | 
							
								 * @param   vdev:   pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param   data:   data to be carried in each beacon
							 | 
						||
| 
								 | 
							
								 * @param   len:    length of the data
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return  0 - for success case
							 | 
						||
| 
								 | 
							
								 *          otherwise - error code. see ERR_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_cco_set_beacon_data(cvg_vdev_t *vdev, uint8_t *data,
							 | 
						||
| 
								 | 
							
								    uint8_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief   set tx power cap for whole network
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param power:    tx power cap. unit is 1dbm
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  0           -- for success case
							 | 
						||
| 
								 | 
							
								 *  otherwise   -- error code
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_cco_set_tx_power_cap(cvg_vdev_t *vdev, uint8_t power);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_is_auto_power_en() - check whether auto high power
							 | 
						||
| 
								 | 
							
								 *        is allowed if detected connected hotline.
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @retval: 0 - not allowed, 1 - allowed
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_cco_is_hot_high_power_en(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief       calculate max allowed none cco beacon slot count in one beacon
							 | 
						||
| 
								 | 
							
								 *              period
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param bc_pld_min: flag to mark if CCO device using minimum beacon payload
							 | 
						||
| 
								 | 
							
								 *              size
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  number of none cco beacon slot allowed
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_cco_get_non_cco_bc_slot_max(cvg_vdev_t *vdev,
							 | 
						||
| 
								 | 
							
								    uint8_t bc_pld_min);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_get_bc_vendor_spec_valid() - get vendor beacon entry is
							 | 
						||
| 
								 | 
							
								 *        valid
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer to vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  0         -- vendor bc entry is not valid
							 | 
						||
| 
								 | 
							
								 *  otherwise -- vendor bc entry is valid
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_cco_get_bc_vendor_spec_valid(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_update_bc_vendor_valid() - update vendor beacon entry
							 | 
						||
| 
								 | 
							
								 *        valid flag
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer to vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_update_bc_vendor_valid(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set network lock status
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param enable:   NULL - not set network lock state.
							 | 
						||
| 
								 | 
							
								 *                  0 - disable network lock.
							 | 
						||
| 
								 | 
							
								 *                  1 - enable network lock.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_set_nw_lock(cvg_vdev_t *vdev, uint32_t *enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set network monitor & ident enable status
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param enable:   0 - disable, 1 - enable.
							 | 
						||
| 
								 | 
							
								 * @param wl_notify_enable: flag to mark if white list notification enable,
							 | 
						||
| 
								 | 
							
								 *                  0 - disable, 1 - enable.
							 | 
						||
| 
								 | 
							
								 * @param zc_notify_enable: flag to mark if zc ntb notification enable,
							 | 
						||
| 
								 | 
							
								 *                  0 - disable, 1 - enable.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_set_nw_monitor_enable(cvg_vdev_t * vdev, uint32_t enable,
							 | 
						||
| 
								 | 
							
								    uint32_t wl_notify_enable, uint32_t zc_notify_enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set repeater addr range.
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param start_addr: allowed to join network start address.
							 | 
						||
| 
								 | 
							
								 * @param end_addr: allowed to join network end address.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_set_repeater_addr_range(cvg_vdev_t *vdev, uint8_t *start_addr,
							 | 
						||
| 
								 | 
							
								    uint8_t *end_addr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_cco_set_abnormal_tei() - set tei of abnormal sta deivce
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param tei: abnormal sta tei
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_set_abnormal_tei(cvg_vdev_t *vdev, tei_t tei);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief           route error handling
							 | 
						||
| 
								 | 
							
								 * @param vdev:     vdev pointer
							 | 
						||
| 
								 | 
							
								 * @param src_tei:  tei of device reporting the issue
							 | 
						||
| 
								 | 
							
								 * @param sta_cnt:  route error destination count
							 | 
						||
| 
								 | 
							
								 * @param sta_list: route error destination list. note that, to resolve
							 | 
						||
| 
								 | 
							
								 *                  address align issue, use uint8_t* here.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_route_err_notify(cvg_vdev_t *vdev, tei_t src_tei,
							 | 
						||
| 
								 | 
							
								    uint8_t sta_cnt, uint8_t *tei_list);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief               enable or disable pco snr report feature
							 | 
						||
| 
								 | 
							
								 * @param vdev:         vdev pointer
							 | 
						||
| 
								 | 
							
								 * @param pco_snr_rpt:  set to non zero to enable this feature.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_set_pco_snr_rpt(cvg_vdev_t *vdev, uint8_t pco_snr_rpt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief               enable or disable rtc tx
							 | 
						||
| 
								 | 
							
								 * @param vdev:         vdev pointer
							 | 
						||
| 
								 | 
							
								 * @param rtc_tx:       set non zero to enable rtc tx
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_set_rtc_tx(cvg_vdev_t *vdev, uint8_t rtc_tx);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief               reset assoc done counter
							 | 
						||
| 
								 | 
							
								 * @param vdev:         vdev pointer
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_reset_assoc_done(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief   get phase info of local device
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param info:     buffer to receive the status
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_get_phase(cvg_vdev_t * vdev,cvg_phase_info_t * info);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief   cvg_nwm_cco_set_app_load() - set application layer data traffic load
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @param load:     application layer data traffic load level,
							 | 
						||
| 
								 | 
							
								 *                  see CVG_NWM_APP_LOAD_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_set_app_load(cvg_vdev_t *vdev, uint8_t load);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief   cvg_nwm_cco_get_app_load() - get application layer data traffic load
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *   application layer data traffic load level, see CVG_NWM_APP_LOAD_XXX.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_cco_get_app_load(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief  cvg_nwm_cco_set_rf_cod() - set rf channel coordination enable
							 | 
						||
| 
								 | 
							
								 * @param vdev:          pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @param rf_cod_enable: flag to mark if enable rf channel coordination,
							 | 
						||
| 
								 | 
							
								 *                       0 - disable, 1 - enable
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_set_rf_cod(cvg_vdev_t *vdev, uint8_t rf_cod_enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief  cvg_nwm_cco_get_rf_cod() - get rf channel coordination enable
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *   flag to mark if enable rf channel coordination, 0 - disable, 1 - enable
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_cco_get_rf_cod(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_reset_freq_band_detect() - freq band detect state reset.
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param clear_wl_joined_done: clear freq band detect wl_joined_done flag
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_reset_freq_band_detect(cvg_vdev_t *vdev,
							 | 
						||
| 
								 | 
							
								    uint8_t clear_wl_joined_done);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_cco_wl_check() - check mac addr added to while list table
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_cco_wl_check(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief  cvg_nwm_cco_set_phy_phase_ident() - physical phase identification
							 | 
						||
| 
								 | 
							
								 *                       enable
							 | 
						||
| 
								 | 
							
								 * @param vdev:          pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @param enable:        flag to mark if enable physical phase identification,
							 | 
						||
| 
								 | 
							
								 *                       0 - disable, 1 - enable
							 | 
						||
| 
								 | 
							
								 * @return  0 - for success case
							 | 
						||
| 
								 | 
							
								 *          otherwise - error code. see ERR_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_cco_set_phy_phase_ident(cvg_vdev_t *vdev, uint8_t enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#else /* PLC_SUPPORT_CCO_ROLE */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_disconnect_peer(vdev, cnt, addr, reason)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_wbl_changed(vdev)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_beacon_data(vdev, data, len) (ERR_NOSUPP)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_tx_power_cap(vdev, power) (ERR_NOSUPP)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_get_non_cco_bc_slot_max(vdev, bc_pld_min) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_get_bc_vendor_spec_valid(vdev) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_update_bc_vendor_valid(vdev)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_nw_lock(vdev, enable)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_nw_monitor_enable(vdev, enable, wl_notify_enable, \
							 | 
						||
| 
								 | 
							
								    zc_notify_enable)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_repeater_addr_range(vdev, start_addr, end_addr)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_abnormal_tei(vdev, tei)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_route_err_notify(vdev, src_tei, sta_cnt, sta_list)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_set_pco_snr_rpt(vdev, pco_snr_rpt)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_set_rtc_tx(vdev, rtc_tx)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_reset_assoc_done(vdev)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_get_phase(vdev, info)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_app_load(vdev, load)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_get_app_load(vdev) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_rf_cod(vdev, rf_cod_enable)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_get_rf_cod(vdev) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_reset_freq_band_detect(vdev, clear_wl_joined_done)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_wl_joined_done(vdev, wl_joined_done)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_set_phy_phase_ident(vdev, enable) (ERR_NOSUPP)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_cco_wl_check(vdev)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* PLC_SUPPORT_CCO_ROLE */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if (PLC_SUPPORT_STA_ROLE)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_clear_nid_blist() - clear sta role device NID black list
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_clear_nid_blist(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * cvg_nwm_clear_pco_blist() - clear sta role device PCO black list
							 | 
						||
| 
								 | 
							
								 * @vdev:   pointer of vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_clear_pco_blist(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_get_bc_role() - get local device assigned by cco in beacon
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return: device role in beacon. see PLC_DEV_ROLE_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_sta_get_bc_role(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set logical phase of local device.
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param phase:    phase
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_set_logical_phase(cvg_vdev_t *vdev, uint8_t phase);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set watch dog status
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param enable:   0 - disable watch dog, 1 - enable watch dog.
							 | 
						||
| 
								 | 
							
								 * @param interval: watch dog bite interval, unit is 1 min, less than 30
							 | 
						||
| 
								 | 
							
								 *                  minutes is disallowed.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_wdg_set(cvg_vdev_t *vdev, uint8_t enable, uint16_t interval);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_wbl_changed() - sta white list or black list changed
							 | 
						||
| 
								 | 
							
								 *                                    handling function
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_wbl_changed(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set network lock status
							 | 
						||
| 
								 | 
							
								 * @param vdev:            pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param enable:          NULL - not set network lock state.
							 | 
						||
| 
								 | 
							
								 *                         0 - disable network lock.
							 | 
						||
| 
								 | 
							
								 *                         1 - enable network lock.
							 | 
						||
| 
								 | 
							
								 * @param tsfm_addr:       transformer mac address, if NULL, not set tsfm_addr.
							 | 
						||
| 
								 | 
							
								 * @param nor_lock_time:   network lock time, 0 means no lock. uint is 1min.
							 | 
						||
| 
								 | 
							
								 * @param abn_lock_time:   the lock time of abnormal leave network,
							 | 
						||
| 
								 | 
							
								 *                         0 means no lock. uint is 1min.
							 | 
						||
| 
								 | 
							
								 * @param unlock_delay:    network unlock delay time, unit is 1min.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_set_nw_lock(cvg_vdev_t *vdev, uint32_t *enable,
							 | 
						||
| 
								 | 
							
								    uint8_t *tsfm_addr, uint16_t *nor_lock_time, uint16_t *abn_lock_time,
							 | 
						||
| 
								 | 
							
								    uint16_t *unlock_delay);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set network monitor & ident enable status
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param enable:   0 - disable, 1 - enable, 2 - enable for a while and not
							 | 
						||
| 
								 | 
							
								                    allow switch tsfm, 3 - enable for a while and allow switch
							 | 
						||
| 
								 | 
							
								                    tsfm.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_set_nw_monitor_enable(cvg_vdev_t * vdev,uint32_t enable);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief set local device tx power cap for sta role device
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param local:    flag to mark if the source of the tx power control is
							 | 
						||
| 
								 | 
							
								 *                  from local device or network.
							 | 
						||
| 
								 | 
							
								 * @param power:    tx power cap. unit is 1dbm
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  0           -- for success case
							 | 
						||
| 
								 | 
							
								 *  otherwise   -- error code
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t cvg_nwm_sta_set_tx_power_cap(cvg_vdev_t *vdev, uint8_t local,
							 | 
						||
| 
								 | 
							
								    uint8_t power);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief   get anchor hop of local device
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  PLC_TEI_INVAL   - anchor hop is not available
							 | 
						||
| 
								 | 
							
								 *  otherwise       - tei of the anchor hop
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								tei_t cvg_nwm_sta_get_anchor_hop(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief   get transformer detect status
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param info:     buffer to receive the status
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_get_tsfm_status(cvg_vdev_t *vdev, cvg_tsfm_status_t *info);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief   get phase info of local device
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param info:     buffer to receive the status
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_get_phase(cvg_vdev_t *vdev, cvg_phase_info_t *info);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_set_phase_mask() - setting up a phase information mask
							 | 
						||
| 
								 | 
							
								 *        that does not need to be reported
							 | 
						||
| 
								 | 
							
								 * @param vdev:       pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param phase_mask: phase zero-crossing info mask for not needed to be
							 | 
						||
| 
								 | 
							
								 *                    reported to CCO, bit 0~2 corresponds phase 1/2/3 of
							 | 
						||
| 
								 | 
							
								 *                    device.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_set_phase_mask(cvg_vdev_t *vdev, uint8_t phase_mask);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief check if the joined cco is from the same vendor as us
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @retval:
							 | 
						||
| 
								 | 
							
								 *      0 - not same vendor
							 | 
						||
| 
								 | 
							
								 *      1 - same vendor
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_sta_is_same_vendor(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief get sta network state
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @retval: return sta network state, see IOT_PLC_STA_STATE_XXX
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_sta_get_network_state(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_set_pm_addr() - set address of power meter connected
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param addr:     address of power meter connected, big-endian
							 | 
						||
| 
								 | 
							
								 * @param  cnt:     count of power meter connected, 0 means clear address of
							 | 
						||
| 
								 | 
							
								 *                  power meter connected
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_set_pm_addr(cvg_vdev_t *vdev,
							 | 
						||
| 
								 | 
							
								    uint8_t addr[][IOT_MAC_ADDR_LEN], uint8_t cnt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_hw_tsfm_pa_send() - hw tsfm pa data send
							 | 
						||
| 
								 | 
							
								 * @param vdev:     pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param data:     data
							 | 
						||
| 
								 | 
							
								 * @param  len:     length of the data, must be qeual or less than
							 | 
						||
| 
								 | 
							
								 *                  MAC_HW_TSFM_DATA_BYTE_MAX
							 | 
						||
| 
								 | 
							
								 * @param freq_tone_num:   send encode frequency tone num
							 | 
						||
| 
								 | 
							
								 * @param send_cnt: pa send count
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_hw_tsfm_pa_send(cvg_vdev_t *vdev, uint8_t *data, uint8_t len,
							 | 
						||
| 
								 | 
							
								    uint8_t send_cnt, uint32_t freq_tone_num);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief   get network normal & abnormal lock time
							 | 
						||
| 
								 | 
							
								 * @param vdev:              pointer to vdev
							 | 
						||
| 
								 | 
							
								 * @param nor_lock_time:     return normal lock time
							 | 
						||
| 
								 | 
							
								 * @param abn_lock_time:     return abnormal lock time
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_get_nw_lock_time(cvg_vdev_t *vdev, uint16_t *nor_lock_time,
							 | 
						||
| 
								 | 
							
								    uint16_t *abn_lock_time);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_is_possible_pco() - check if local device may be pco role.
							 | 
						||
| 
								 | 
							
								 * @param vdev: pointer of vdev
							 | 
						||
| 
								 | 
							
								 * @return:
							 | 
						||
| 
								 | 
							
								 *  0           -- is not pco role
							 | 
						||
| 
								 | 
							
								 *  otherwise   -- is pco role
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_sta_is_possible_pco(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_get_rf_link_valid() - get device rf link is valid
							 | 
						||
| 
								 | 
							
								 * @param vdev:     vdev pointer
							 | 
						||
| 
								 | 
							
								 * @return
							 | 
						||
| 
								 | 
							
								 *  0           -- rf link is invalid
							 | 
						||
| 
								 | 
							
								 *  1           -- rf link is valid
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t cvg_nwm_sta_get_rf_link_valid(cvg_vdev_t *vdev);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief cvg_nwm_sta_set_rf_link_valid() - set device rf link valid flag
							 | 
						||
| 
								 | 
							
								 * @param vdev:     vdev pointer
							 | 
						||
| 
								 | 
							
								 * @param valid:    valid flag
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cvg_nwm_sta_set_rf_link_valid(cvg_vdev_t *vdev, uint8_t valid);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#else /* PLC_SUPPORT_STA_ROLE */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_clear_nid_blist(vdev)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_clear_pco_blist(vdev)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_get_bc_role(vdev) (PLC_DEV_ROLE_CCO)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_set_logical_phase(vdev, phase)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_wdg_set(vdev, enable, interval)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_wbl_changed(vdev)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_set_nw_lock(vdev, enable, tsfm_addr, nor_lock_time, \
							 | 
						||
| 
								 | 
							
								    abn_lock_time, unlock_delay)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_set_nw_monitor_enable(vdev, enable)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_set_tx_power_cap(vdev, local, power) (ERR_NOSUPP)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_get_anchor_hop(vdev) (PLC_TEI_INVAL)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_get_tsfm_status(vdev, info)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_get_phase(vdev, info)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_set_phase_mask(vdev, phase_mask)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_is_same_vendor(vdev) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_get_network_state(vdev) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_set_pm_addr(vdev, addr, cnt)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_hw_tsfm_pa_send(vdev, data, len, freq_tone_num)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_get_nw_lock_time(vdev, nor_lock_time, abn_lock_time)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_is_possible_pco(vdev) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_set_rf_link_valid(vdev, valid)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define cvg_nwm_sta_get_rf_link_valid(vdev) (0)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* PLC_SUPPORT_STA_ROLE */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* CVG_NWM_H */
							 |