157 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
		
			5.7 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 MAC_DATA_API_H
 | 
						|
#define MAC_DATA_API_H
 | 
						|
 | 
						|
#include "os_types.h"
 | 
						|
#include "iot_pkt_api.h"
 | 
						|
#include "plc_utils.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* define mac ppm adjust type */
 | 
						|
#define MAC_PPM_STEP_TYPE_TXRX    0
 | 
						|
#define MAC_PPM_STEP_TYPE_TX      1
 | 
						|
 | 
						|
typedef struct _mac_tx_info {
 | 
						|
    /* priority of the packet */
 | 
						|
    lid_t       link_id;
 | 
						|
    /* flag to mark if this packet is broacast */
 | 
						|
    uint8_t     bcast               :1,
 | 
						|
    /* flag to mark if this packet is power collapse related */
 | 
						|
                pw_collapse         :1,
 | 
						|
    /* flag to mark if this packet should be send on 3 phases simultaneously */
 | 
						|
                tx_3_phase          :1,
 | 
						|
    /* flag to mark if this packet is debug pkt */
 | 
						|
                is_dbg_pkt          :1,
 | 
						|
    /* flag to mark if this packet is sent to our own device */
 | 
						|
                same_vendor         :1,
 | 
						|
    /* flag to mark if tx_band is valid */
 | 
						|
                tx_band_valid       :1,
 | 
						|
    /* logical phase to send the packet */
 | 
						|
                phase               :2;
 | 
						|
    /* band id to send the packet */
 | 
						|
    uint8_t     tx_band;
 | 
						|
    /* flag to mark if this packet is sent to rf link */
 | 
						|
    uint8_t     is_rf_data          :1,
 | 
						|
    /* retry count for this tx frame. this value will take affect only when
 | 
						|
     * max_send_count = 0 in mac header. if this value set to 0, it means
 | 
						|
     * mac layer could use default try count.
 | 
						|
     */
 | 
						|
                retry_cnt           :4,
 | 
						|
    /* scan ppm step type, see MAC_PPM_STEP_TYPE_XXX */
 | 
						|
                ppm_step_type       :2,
 | 
						|
    /* flag to mark if retry_cnt take priority even if max_send_count != 0
 | 
						|
     * in mac header.
 | 
						|
     */
 | 
						|
                retry_prior         :1;
 | 
						|
    /* next hop's TEI */
 | 
						|
    uint16_t    receiver            :12,
 | 
						|
    /* is encrypt or not */
 | 
						|
                is_encrypt          :1,
 | 
						|
    /* the index of key to encrypt */
 | 
						|
                key_idx             :1,
 | 
						|
                resv1               :2;
 | 
						|
    /* scan ppm step, only for is_dbg_pkt = 1 message */
 | 
						|
    int8_t      ppm_step;
 | 
						|
} mac_tx_info;
 | 
						|
 | 
						|
/*
 | 
						|
 *  send data to mac layer
 | 
						|
 *  Notice:
 | 
						|
 *      cvg layer fills mac header.
 | 
						|
 *      mac layer need to update the msdu_sn field.
 | 
						|
 *
 | 
						|
 *  @vdev_id:       the vdev on which data will be sent.
 | 
						|
 *  @msdu_buf:      the buffer containing the msdu data to be sent.
 | 
						|
 *                  msdu data is containted in data block of the iot_pkt.
 | 
						|
 *                  head block is reserved for prepending mac header.
 | 
						|
 *  @link_id:       link_id on which data to be sent.
 | 
						|
 *
 | 
						|
 *  return:
 | 
						|
 *          true for successful case.
 | 
						|
 *          false for failed case.
 | 
						|
 */
 | 
						|
 | 
						|
uint32_t mac_send_msdu_ex(pdevid_t pdev_id, vdevid_t vdev_id,
 | 
						|
    iot_pkt_t* msdu_buf, mac_tx_info *tx_info);
 | 
						|
 | 
						|
/* this is the rx desc placed at
 | 
						|
 * the start of the iot buf, no need
 | 
						|
 * to be freed seperately
 | 
						|
 */
 | 
						|
typedef struct _mac_rx_info {
 | 
						|
    /* NTB delta between local device network and remote device network.
 | 
						|
     * if local device and remote device are in the same network, the delta
 | 
						|
     * should be very very small.
 | 
						|
     * remote NTB - local NTB
 | 
						|
     */
 | 
						|
    int32_t    delta_ntb;
 | 
						|
    /* resv the 32 bit field for phy info */
 | 
						|
    struct {
 | 
						|
        int8_t      snr;            /* SNR of this mpdu */
 | 
						|
        uint8_t     resv1 : 4,    /* receive band id */
 | 
						|
                    phase : 2,      /* receive phase */
 | 
						|
                    is_rf : 1,      /* 1: rf packet, 0: plc packet */
 | 
						|
                    resv0 : 1;
 | 
						|
        /* hplc : receive rssi -87 - 33 dbm if not sw agc
 | 
						|
         * or else INV_RSSI_RF if sw agc
 | 
						|
         * rf: rssi -127 - 127 dbm  invald rssi:INV_RSSI_RF
 | 
						|
         */
 | 
						|
        int8_t      rssi;
 | 
						|
        /* rf channel id, only for rf device */
 | 
						|
        uint8_t     channel_id;
 | 
						|
        /* rf option id, only for rf device */
 | 
						|
        uint8_t     rf_option;
 | 
						|
        /* hplc band id, only for hplc device, see BEACON_FREQ_BAND_ID_XXX */
 | 
						|
        uint8_t     band_id;
 | 
						|
        /* for address 4byte alignment */
 | 
						|
        uint8_t     resv2;
 | 
						|
        uint8_t     resv3;
 | 
						|
    } phy;
 | 
						|
    uint8_t     fc[16]; // place holder for tmp, to be removed
 | 
						|
} mac_rx_info_t;
 | 
						|
 | 
						|
/*
 | 
						|
 *  callback method prototype to receive data from mac layer
 | 
						|
 *
 | 
						|
 *  @arg:           arg parameter registered alone with the callback
 | 
						|
 *  @msdu_buf:      the buffer containing the msdu data received.
 | 
						|
 *                  msdu data is containted in data block of the iot_pkt.
 | 
						|
 *                  in front of the data is the mac_rx_info_t meta info.
 | 
						|
 */
 | 
						|
typedef void (*mac_recv_msdu_func_t)(void *arg, iot_pkt_t *msdu_buf);
 | 
						|
 | 
						|
/*
 | 
						|
 * @brief           callback method prototype to receive payload error and
 | 
						|
 *                  no payload frames snr info sent by CCO from mac layer
 | 
						|
 *
 | 
						|
 * @param arg:      arg parameter registered alone with the callback
 | 
						|
 * @param cco_info: iot pkt to contain cco info. the ownership will be
 | 
						|
 *                  transferred to callback function. see mac_cco_snr_rpt_t
 | 
						|
 *                  for more details.
 | 
						|
 */
 | 
						|
typedef void (*mac_recv_snr_from_cco_func_t)(void *arg,
 | 
						|
    iot_pkt_t *cco_info);
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* MAC_DATA_API_H */
 |