257 lines
8.8 KiB
C
257 lines
8.8 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 MAC_RF_VDEV_H
|
|
#define MAC_RF_VDEV_H
|
|
|
|
#include "beacon.h"
|
|
#include "plc_utils.h"
|
|
#include "iot_queue.h"
|
|
#include "os_timer_api.h"
|
|
#include "mac_vdev_api.h"
|
|
#include "mac_bcm_api.h"
|
|
#include "mac_data_api.h"
|
|
#include "mac_ppm_scan.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* rate control callback */
|
|
typedef uint32_t(*rf_rate_control_func_t)(void *peer, void *arg);
|
|
|
|
/* more cfg to be added later */
|
|
typedef struct _mac_rf_vdev_start_cfg {
|
|
/* beacon rx callback of the vdev */
|
|
mac_bc_rx_func_t mac_bc_rx_func;
|
|
/* data frame rx callback of the vdev */
|
|
mac_recv_msdu_func_t mac_data_rx_func;
|
|
/* beacon period end alert callback of the vdev */
|
|
mac_bp_end_alert_func_t mac_bp_end_alert_func;
|
|
} mac_rf_vdev_start_cfg_t;
|
|
|
|
/* NB: not to expose the structs to the upper layer directly */
|
|
typedef struct _mac_rf_vdev {
|
|
vdevid_t rf_vdev_id;
|
|
/* uplay set power */
|
|
uint32_t fixed_rf_power_cap : 8,
|
|
/* stop or start flag */
|
|
stop_flag : 1,
|
|
/* is rf sync_nid inited */
|
|
rf_sync_nid_inited : 1,
|
|
/* is fixed power or not, used when upper layer set power */
|
|
fixed_rf_power_flag : 1,
|
|
/* flag to mark if rf tx power temperature compensation enable */
|
|
power_temp_compen_en : 1,
|
|
/* whether bcsma slot exist in current beacon period */
|
|
bcsma_slot_exist : 1,
|
|
/* bcsma nonentity cnt */
|
|
bcsma_non_exist_cnt : 3,
|
|
/* flag to mark if suspend sending and receiving */
|
|
tx_rx_suspend : 1,
|
|
resv0 : 15;
|
|
/* tx power compensation region index */
|
|
int8_t power_temp_compen_idx;
|
|
/* the index meeting the temperature compensation region from the
|
|
* latest check.
|
|
*/
|
|
int8_t last_temp_compen_chk_idx;
|
|
/* rf ntb ppm, unit: 1/64 ppm */
|
|
int16_t rf_ntb_ppm;
|
|
/* rf ntb ppm update to hw count */
|
|
uint32_t ntb_ppm_update_cnt;
|
|
/* entering and exiting the temperature compensated condition stability
|
|
* counter.
|
|
*/
|
|
uint32_t stable_cnt;
|
|
vdevid_t parent_vdev_id;
|
|
pdevid_t ref_pdev_id;
|
|
mac_rf_vdev_start_cfg_t rf_start_cfg;
|
|
/* rate control callback */
|
|
rf_rate_control_func_t ra_cb;
|
|
/* scheduler context */
|
|
void *rf_sched_ctx;
|
|
/* mac rf record ppm */
|
|
mac_ntb_record_ctxt_t mac_rf_ppm;
|
|
/* sync ntb record context */
|
|
mac_ntb_record_ctxt_t sync_ntb_record;
|
|
/* current ppm sync target nid */
|
|
uint32_t rf_sync_nid;
|
|
/* current ppm sync target proxy */
|
|
tei_t rf_sync_proxy;
|
|
// TODO: add config
|
|
} mac_rf_vdev_t;
|
|
|
|
#if HPLC_RF_DEV_SUPPORT
|
|
|
|
/*
|
|
* rf_vdev_get_tei() - rf vdev get tei.
|
|
* @rf_vdev: - the point of rf vdev.
|
|
* return: - tei.
|
|
*/
|
|
tei_t rf_vdev_get_tei(mac_rf_vdev_t* rf_vdev);
|
|
|
|
/*
|
|
* mac_rf_vdev_set_tei() - rf vdev set tei.
|
|
* @rf_vdev: - the point of rf vdev.
|
|
* @tei: - tei.
|
|
* return: void.
|
|
*/
|
|
void mac_rf_vdev_set_tei(mac_rf_vdev_t* rf_vdev, tei_t tei);
|
|
|
|
/*
|
|
* @brief mac_rf_vdev_get_sync_nid() - get target nid current rf_vdev is syncing to
|
|
* @param rf_vdev: - mac rf vdev pointer
|
|
* @return uint32_t: - network id
|
|
*/
|
|
uint32_t mac_rf_vdev_get_sync_nid(mac_rf_vdev_t *rf_vdev, nid_t *rf_sync_nid);
|
|
|
|
/*
|
|
* @brief mac_rf_vdev_set_sync_nid() - set target nid current rf_vdev is syncing to
|
|
* @param rf_vdev: - mac rf vdev pointer
|
|
* @return void: - void
|
|
*/
|
|
void mac_rf_vdev_set_sync_nid(mac_rf_vdev_t *rf_vdev, uint32_t nid);
|
|
|
|
/*
|
|
* @brief mac_rf_vdev_reset_sync_nid() - reset nid current rf_vdev is syncing to
|
|
* @param rf_vdev: - mac rf vdev pointer
|
|
* @return void: - void
|
|
*/
|
|
void mac_rf_vdev_reset_sync_nid(mac_rf_vdev_t *rf_vdev);
|
|
|
|
/*
|
|
* @brief mac_rf_vdev_get_sync_proxy() - get target proxy current rf_vdev is
|
|
* syncing to
|
|
* @param rf_vdev: - mac rf vdev pointer
|
|
* @return tei_t - target proxy tei
|
|
*/
|
|
tei_t mac_rf_vdev_get_sync_proxy(mac_rf_vdev_t *rf_vdev);
|
|
|
|
/*
|
|
* @brief mac_rf_vdev_set_sync_proxy() - set target proxy current rf_vdev is syncing to
|
|
* @param rf_vdev: - mac rfvdev pointer
|
|
* @return void: - void
|
|
*/
|
|
void mac_rf_vdev_set_sync_proxy(mac_rf_vdev_t *rf_vdev, tei_t proxy);
|
|
|
|
/*
|
|
* rf_vdev_get_node_role() - rf vdev get node role.
|
|
* @rf_vdev: - the point of rf vdev.
|
|
* return: - tei.
|
|
*/
|
|
uint8_t rf_vdev_get_node_role(mac_rf_vdev_t* rf_vdev);
|
|
|
|
/*
|
|
* get_rf_vdev_ptr() - get the point of rf vdev.
|
|
* @plc_pdev_id: - plc phasical mac device id.
|
|
* @rf_pdev_id: - rf phasical mac device id.
|
|
* @rf_vdev_id: - rf virtual mac device id
|
|
* return: rf vdev - the point of rf vdev
|
|
*/
|
|
mac_rf_vdev_t *get_rf_vdev_ptr(uint32_t plc_pdev_id, uint32_t rf_pdev_id,
|
|
uint32_t rf_vdev_id);
|
|
|
|
/*
|
|
* rf_vdev_set_ra() - set rf vdev rate control callback.
|
|
* @rf_vdev: - the pointer of rf vdev.
|
|
* @ra: - callback function.
|
|
* return: - none
|
|
*/
|
|
void rf_vdev_set_ra(mac_rf_vdev_t *rf_vdev, rf_rate_control_func_t ra);
|
|
|
|
/*
|
|
* mac_create_rf_vdev_internal() - create mac layer virtual device.
|
|
* @plc_pdev_id: - plc phasical mac device id.
|
|
* @plc_vdev_id: - plc virtual mac device id.
|
|
* @rf_pdev_id: - rf phasical mac device id.
|
|
* @rf_vdev_id_created: - pointer to receive the created vdev id
|
|
* return:
|
|
* 0 -- for success case
|
|
* othersie -- error code
|
|
*/
|
|
uint32_t mac_create_rf_vdev_internal(uint8_t plc_pdev_id, uint8_t plc_vdev_id,
|
|
uint8_t rf_pdev_id, uint8_t *rf_vdev_id_created);
|
|
|
|
/*
|
|
* mac_start_rf_vdev_internal() - start mac layer virtual device.
|
|
* @plc_pdev_id: - plc phasical mac device id.
|
|
* @rf_pdev_id: - rf phasical mac device id.
|
|
* @rf_vdev_id: - rf virtual mac device id.
|
|
* @cfg: - pointer to start config
|
|
* return:
|
|
* 0 -- for success case
|
|
* othersie -- error code
|
|
*/
|
|
uint32_t mac_start_rf_vdev_internal(uint8_t plc_pdev_id, uint8_t rf_pdev_id,
|
|
uint8_t rf_vdev_id, mac_vdev_start_cfg_t *rf_cfg);
|
|
|
|
/*
|
|
* mac_stop_rf_vdev_internal() - stop mac layer virtual device.
|
|
* @plc_pdev_id: - plc phasical mac device id.
|
|
* @rf_pdev_id: - rf phasical mac device id.
|
|
* @rf_vdev_id: - rf virtual mac device id.
|
|
* return:
|
|
* 0 -- for success case
|
|
* othersie -- error code
|
|
*/
|
|
uint32_t mac_stop_rf_vdev_internal(uint8_t plc_pdev_id, uint8_t rf_pdev_id,
|
|
uint8_t rf_vdev_id);
|
|
|
|
#else /* HPLC_RF_DEV_SUPPORT */
|
|
|
|
#define rf_vdev_set_ra(rf_vdev, ra) \
|
|
do { \
|
|
(void)(rf_vdev); \
|
|
(void)(ra); \
|
|
} while(0);
|
|
|
|
#define mac_rf_vdev_reset_sync_nid(rf_vdev) \
|
|
do { \
|
|
(void)(rf_vdev); \
|
|
} while(0);
|
|
|
|
#define get_rf_vdev_ptr(plc_pdev_id, rf_pdev_id, rf_vdev_id) NULL; \
|
|
do { \
|
|
(void)plc_pdev_id;(void)rf_pdev_id;(void)rf_vdev_id; \
|
|
} while(0)
|
|
|
|
#define mac_create_rf_vdev_internal(plc_pdev_id, plc_vdev_id, \
|
|
rf_pdev_id, rf_vdev_id_created) ERR_NOSUPP; \
|
|
do { \
|
|
(void)plc_pdev_id;(void)plc_vdev_id;(void)rf_pdev_id;\
|
|
(void)rf_vdev_id_created; \
|
|
} while(0)
|
|
|
|
#define mac_start_rf_vdev_internal(plc_pdev_id, rf_pdev_id, rf_vdev_id, cfg) \
|
|
ERR_NOSUPP; \
|
|
do { \
|
|
(void)plc_pdev_id;(void)rf_pdev_id;(void)rf_vdev_id;(void)cfg; \
|
|
} while(0)
|
|
|
|
#define mac_stop_rf_vdev_internal(plc_pdev_id, rf_pdev_id, rf_vdev_id) \
|
|
ERR_NOSUPP; \
|
|
do { \
|
|
(void)plc_pdev_id;(void)rf_pdev_id;(void)rf_vdev_id; \
|
|
} while(0)
|
|
|
|
#endif /* HPLC_RF_DEV_SUPPORT */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // !MAC_VDEV_H
|