Files
kunlun/plc/inc/mac_vdev_api.h

221 lines
7.4 KiB
C
Raw Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
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_VDEV_API_H
#define MAC_VDEV_API_H
#include "os_types.h"
#include "plc_utils.h"
#include "mac_bcm_api.h"
#include "mac_data_api.h"
#include "mac_uni_cfg_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/* nid list report format. as we are not using packed struct, so we need to
* make sure all members in this struct are 4 bytes aligned.
*/
typedef struct _mac_nid_rpt {
/* 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 :8;
/* bandwidth taken by neighbour network in millisecond, 0 means invalid */
uint32_t bandwidth :16,
/* rf channel of the neighbour network */
rf_channel :8,
/* rf option of the neighbour network */
rf_option :2,
/* reserved for future */
rsvd :6;
} mac_nid_rpt_t;
typedef struct _mac_nid_list_rpt {
/* available nid count in the array */
uint32_t nid_cnt :8,
/* reserved for future */
rsvd :24;
/* nid array */
mac_nid_rpt_t nid_list[0];
} mac_nid_list_rpt_t;
/* cco snr report format */
typedef struct _mac_cco_snr_rpt {
/* nid of the neighbour network */
uint32_t nid :24,
/* rf channel of the neighbour network */
rf_channel :8;
/* rx snr of the fc */
int8_t snr;
/* flag to mark if come from rf link */
uint8_t is_rf :1,
/* rf option, see RF_OPTION_XXX */
rf_option :2,
/* reserved for future */
rsvd1 :5;
/* hplc band id, see BEACON_FREQ_BAND_ID_XXX */
uint8_t band_id;
/* reserved for future */
uint8_t rsvd;
} mac_cco_snr_rpt_t;
/*
* function callback to receive beacon period end alert
* @arg: arg parameter registered alone with the callback
*/
typedef void (*mac_bp_end_alert_func_t)(void *arg);
/*
* @biref function callback to receive watched nid list report
* @param arg: arg parameter registered alone with the callback
* @param nid_list: iot pkt to contain the nid list. the ownership will
* be transferred to callback function. see
* mac_nid_list_rpt_t for more details.
*/
typedef void (*mac_nid_rpt_func_t)(void *arg, iot_pkt_t *nid_list);
/*
* @biref function callback to receive zero-cross status report
* @param arg: arg parameter registered alone with the callback
* @param status: indicate if the phase zc info is valid.
* bit0 - Phase A, bit1 - Phase B, bit2 - Phase C...
* 0 - invalid, 1 - valid.
*/
typedef void (*mac_zc_status_rpt_func_t)(void *arg, uint32_t status);
/* more cfg to be added later */
typedef struct _mac_vdev_cfg {
/* CCO, STA or PCO */
uint16_t node_role : 8,
/* number of supported physical phases. The range should be from 1 - 3.
* for STA/PCO role device, only 1 physical phase supported.
* for CCO role device:
* if set to 1, only phase A supported.
* if set to 2, both phase A and B are supported.
* if set to 3, Phase A, B and C are supported.
*/
p_phase_cnt : 2,
/* flag this vdev is reduced */
is_reduced_vdev : 1,
/* flag this vdev need time division tx nncco 3 phase */
is_td_tx_nncco_3phase : 1,
resv0 : 4;
} mac_vdev_cfg_t;
/* more cfg to be added later */
typedef struct _mac_vdev_start_cfg {
/* mac address of the vdev */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* parameter to be transferred back with those callbacks */
void *mac_callback_arg;
/* 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;
/* payload error or no payload cco frame snr rx callback of the vdev */
mac_recv_snr_from_cco_func_t mac_cco_snr_rx_func;
/* beacon period end alert callback of the vdev */
mac_bp_end_alert_func_t mac_bp_end_alert_func;
/* watched nid list report callback of the vdev */
mac_nid_rpt_func_t mac_nid_rpt_func;
/* zero-cross status changed report callback of the vdev */
mac_zc_status_rpt_func_t mac_zc_status_rpt_func;
} mac_vdev_start_cfg_t;
/*
* mac_create_vdev() - create mac layer virtual device
* @pdev_id: phasical mac device on top of which to create the vdev
* @vdev_id: pointer to receive the created vdev id
* @cfg: configuration for the created vdev
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t mac_create_vdev(uint8_t pdev_id, uint8_t *vdev_id,
mac_vdev_cfg_t *cfg);
/*
* mac_start_vdev() - start mac layer virtual device
* @pdev_id: phasical mac device id
* @vdev_id: virtual mac device id
* @cfg: configuration for the start
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t mac_start_vdev(uint8_t pdev_id, uint8_t vdev_id,
mac_vdev_start_cfg_t *cfg);
/*
* mac_stop_vdev() - stop mac layer virtual device
* @pdev_id: phasical mac device id
* @vdev_id: virtual mac device id
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t mac_stop_vdev(uint8_t pdev_id, uint8_t vdev_id);
/*
* mac_set_vdev_cfg() - set a vdev's config
* @pdev_id: which pdev to config
* @vdev_id: which vdev to config
* @cfg_struct_ptr: the pointer to the param config structure which can be
* decoded according to the type.
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t mac_set_vdev_cfg(pdevid_t pdev_id, vdevid_t vdev_id,
cfg_data_tlv *cfg_struct_ptr);
/*
* mac_get_reduce_vdev_id() - get dbg pkt vdev id
* @pdev_id: phasical mac device id
*
* return: dbg pkt vdev id
*/
uint32_t mac_get_reduce_vdev_id(uint32_t pdev_id);
/*
* mac_get_vdev_cfg() - get a vdev's config
* @pdev_id: which pdev to config
* @vdev_id: which vdev to config
* @cfg_struct_ptr: the pointer to the param config structure which can be
* decoded according to the type.
*
* return:
* 0 -- for success case
* othersie -- error code
*/
uint32_t mac_get_vdev_cfg(pdevid_t pdev_id, vdevid_t vdev_id,
cfg_data_tlv *tlv);
#ifdef __cplusplus
}
#endif
#endif