Files
kunlun/plc/inc/mme/plc_mme_discover_list.h
2024-09-28 14:24:04 +08:00

170 lines
6.0 KiB
C
Executable File

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef PLC_MME_DISCOVER_LIST_H
#define PLC_MME_DISCOVER_LIST_H
/* os shim includes */
#include "os_types.h"
#include "plc_mme.h"
#include "plc_utils.h"
#ifdef __cplusplus
extern "C" {
#endif
/* pack for the structures in the whole file */
#pragma pack(push) // save the pack status
#pragma pack(1) // 1 byte align
#if SUPPORT_SMART_GRID
typedef struct _ul_rt_ent {
uint16_t next_hop : 12; // tei of next hop STA
uint16_t route_type : 4; // route type
} ul_rt_ent_t;
typedef struct _mme_dis_sta_list {
uint32_t sta :12; // the STA sending this discover list
uint32_t proxy :12; // proxy of the STA
uint32_t role : 4; // role of the STA
uint32_t level : 4; // level of the STA
uint8_t mac_addr[IOT_MAC_ADDR_LEN]; // mac of the STA
uint8_t cco_mac_addr[IOT_MAC_ADDR_LEN]; // mac of the STA's CCo
// estimated power line phase sorted by possibility
uint8_t phase_1 : 2;
uint8_t phase_2 : 2;
uint8_t phase_3 : 2;
/* send phase of this discovery node list mme frame.
* CCO role device will broadcast this mme with same msdu_sn in different
* phase. STA role can use this info to estimate the best phase.
* Note that in CPLC spec, this value is reserved.
*/
uint8_t phase_s : 2;
int8_t proxy_snr; // estimated channel snr from proxy
uint8_t proxy_tf_sr; // proxy traffic succeed rate
uint8_t proxy_dl_tf_sr; // proxy down link traffic sucessful rate
uint16_t sta_cnt; // number of STA in discover list
uint8_t dnl_send_cnt; // discover node list sent in last route period
uint8_t ul_rt_ent_cnt; // uplink route entry count
uint16_t remaining_rt_period; // remaining time in a route peroid
uint16_t bitmap_size;
uint8_t min_tf_sr; // minimal traffic succeed rate
/* reserve 3 byte according to spec we reuse to cary vendor specific info */
uint16_t vendor_mark;
/* flag to mark if previous route period is a partial route period */
uint8_t partial_rp :1,
/* noise floor of local device. 0 means noise floor is not available.
* 1 ~ 63 is mapped from noise floor range 31 ~ 93.
*/
noise_floor :6,
/* reserved for future */
rsvd :1;
ul_rt_ent_t rt_ent[0]; // uplink route entry
/* following two fields are not defined in this data structure
* due to rt_ent has variable length.
* uint8_t bitmap[bitmap_size];
* uint8_t received_dis_node_cnt[sta_cnt];
*/
} mme_dis_sta_list_t;
#endif //SUPPORT_SMART_GRID
#if SUPPORT_SOUTHERN_POWER_GRID
/* discover node list bitmap length */
#define SPG_DIS_STA_LIST_MAP_LEN (128)
/* uplink route entry count limit */
#define SPG_DIS_UL_RT_COUNT (4)
/* the entry length of received discover node count, default is 8 bit. */
#define SPG_DIS_CNT_ENT_SIZE (8)
typedef struct _spg_ul_rt_ent {
tei_t next_hop;
uint8_t route_type;
} spg_ul_rt_ent_t;
typedef struct _spg_mme_dis_sta_list {
/* the STA sending this discover list */
tei_t sta;
/* role of the STA */
uint8_t role;
/* level of the STA */
uint8_t level;
/* mac of the STA */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* proxy of the STA */
tei_t proxy;
/* reserved for future */
uint32_t resv1 : 31;
/* traffic succeed rate calculation completion flag */
uint32_t proxy_tf_sr_cmp : 1;
/* proxy traffic succeed rate */
uint32_t proxy_tf_sr;
/* proxy down link traffic sucessful rate */
uint32_t proxy_dl_tf_sr;
/* number of STA in discover list */
uint16_t sta_cnt;
/* discover node list sent in last route period */
uint16_t dnl_send_cnt;
/* uplink route entry count */
uint16_t ul_rt_ent_cnt;
/* the entry length of received discover node count, default is 8 bit. */
uint8_t rt_ent_len;
/* reserved for future */
uint16_t resv2;
/* remaining time in a route peroid */
uint16_t remaining_rt_period;
/* estimated power line phase sorted by possibility */
uint8_t phase_3 : 2;
uint8_t phase_2 : 2;
uint8_t phase_1 : 2;
uint8_t phase_s : 2;
/* minimal traffic succeed rate */
uint8_t min_tf_sr;
/* reserve 3 byte according to spec we reuse to cary vendor specific info */
uint16_t vendor_mark;
/* flag to mark if previous route period is a partial route period */
uint8_t partial_rp :1,
/* noise floor of local device. 0 means noise floor is not available.
* 1 ~ 63 is mapped from noise floor range 31 ~ 93.
*/
noise_floor :6,
/* reserved for future */
rsvd :1;
uint8_t resv4[2];
/* uplink route entry */
spg_ul_rt_ent_t rt_ent[0];
/* following two fields are not defined in this data structure
* due to rt_ent has variable length.
* uint8_t bitmap[128];
* uint8_t received_dis_node_cnt[sta_cnt];
*/
} spg_mme_dis_sta_list_t;
#endif //SUPPORT_SOUTHERN_POWER_GRID
#pragma pack(pop) // restore the pack status
#ifdef __cplusplus
}
#endif
#endif /* PLC_MME_DISCOVER_LIST_H */