213 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			213 lines
		
	
	
		
			8.6 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_MSDU_H
							 | 
						||
| 
								 | 
							
								#define MAC_MSDU_H
							 | 
						||
| 
								 | 
							
								#include "iot_pkt_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_queue.h"
							 | 
						||
| 
								 | 
							
								#include "tx_mpdu_start.h"
							 | 
						||
| 
								 | 
							
								#include "tx_msdu_start.h"
							 | 
						||
| 
								 | 
							
								#include "rx_mpdu_start.h"
							 | 
						||
| 
								 | 
							
								#include "rx_pb_start.h"
							 | 
						||
| 
								 | 
							
								#include "mac_pdev.h"
							 | 
						||
| 
								 | 
							
								#if HPLC_RF_DEV_SUPPORT
							 | 
						||
| 
								 | 
							
								#include "rf_tx_mpdu_desc.h"
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _mac_msdu {
							 | 
						||
| 
								 | 
							
								    union {
							 | 
						||
| 
								 | 
							
								        tx_mpdu_start mpdu_list; /* one or more mpdus for this msdu */
							 | 
						||
| 
								 | 
							
								        tx_msdu_start msdu; /* single msdu desc for this msdu */
							 | 
						||
| 
								 | 
							
								#if HPLC_RF_DEV_SUPPORT
							 | 
						||
| 
								 | 
							
								        rf_tx_mpdu_start rf_mpdu_list; /* one or more mpdus for this msdu */
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								    } hw_desc; /* must be the first place for tx */
							 | 
						||
| 
								 | 
							
								    iot_pkt_t *buf; // the buf desc for the msdu
							 | 
						||
| 
								 | 
							
								    void *ref_mac_stream;
							 | 
						||
| 
								 | 
							
								    uint32_t buf_need_free : 1,
							 | 
						||
| 
								 | 
							
								        /* this field would be updated as the tx process
							 | 
						||
| 
								 | 
							
								         * it means no single pb successfully received for per PB
							 | 
						||
| 
								 | 
							
								         * normally start with 0, it turns to 1 when at least one
							 | 
						||
| 
								 | 
							
								         * PB received by RX side;
							 | 
						||
| 
								 | 
							
								         * but if for CERT test, this filed means the first try
							 | 
						||
| 
								 | 
							
								         * 0 for the first time, 1 for the rest time, no matter
							 | 
						||
| 
								 | 
							
								         * be successfully received or not
							 | 
						||
| 
								 | 
							
								         */
							 | 
						||
| 
								 | 
							
								        retry : 1,
							 | 
						||
| 
								 | 
							
								        is_bcast : 1,
							 | 
						||
| 
								 | 
							
								        phase : 2,
							 | 
						||
| 
								 | 
							
								        in_hwq : 1, /* is already in hwq but not recycle */
							 | 
						||
| 
								 | 
							
								        retry_cnt : 5, /* sw retry cnt per msdu */
							 | 
						||
| 
								 | 
							
								        rate_idx : 9,
							 | 
						||
| 
								 | 
							
								        last_pos: 5, /* last sent index of pb in this msdu */
							 | 
						||
| 
								 | 
							
								        tx_3phase: 1, /* this msdu tx with 3 phase or not */
							 | 
						||
| 
								 | 
							
								        /* this field means if it's the first time sending of
							 | 
						||
| 
								 | 
							
								         * this msdu.
							 | 
						||
| 
								 | 
							
								         * it's used for calculate the send position of the
							 | 
						||
| 
								 | 
							
								         * send bitmap
							 | 
						||
| 
								 | 
							
								         * 0: first sending is not done yet
							 | 
						||
| 
								 | 
							
								         * 1: this msdu has already been sent before
							 | 
						||
| 
								 | 
							
								         */
							 | 
						||
| 
								 | 
							
								        is_first_try_done: 1,
							 | 
						||
| 
								 | 
							
								        is_dbg_pkt : 1,
							 | 
						||
| 
								 | 
							
								        /* flag to mark if fix rate required */
							 | 
						||
| 
								 | 
							
								        fix_rate :1,
							 | 
						||
| 
								 | 
							
								        hw_retry_cnt : 3; /* hw retry cnt per mpdu */
							 | 
						||
| 
								 | 
							
								    uint32_t send_bitmap;    /* 1' need to send */
							 | 
						||
| 
								 | 
							
								    int8_t ppm_step;      /* ppm adjust step */
							 | 
						||
| 
								 | 
							
								    /* ppm step adjust type, see MAC_PPM_STEP_TYPE_XXX  */
							 | 
						||
| 
								 | 
							
								    uint8_t ppm_step_type   : 2,
							 | 
						||
| 
								 | 
							
								    /* record total retry cnt */
							 | 
						||
| 
								 | 
							
								            rd_retry_cnt    : 4,
							 | 
						||
| 
								 | 
							
								            need_encrypt    : 1,
							 | 
						||
| 
								 | 
							
								            key_idx         : 1;
							 | 
						||
| 
								 | 
							
								} mac_msdu_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* used for iot pkt list without mpdu hw desc */
							 | 
						||
| 
								 | 
							
								typedef struct _mac_msdu_frame {
							 | 
						||
| 
								 | 
							
								    iot_pkt_t *buf; // the buf desc for the msdu
							 | 
						||
| 
								 | 
							
								    uint16_t is_bcast : 1,
							 | 
						||
| 
								 | 
							
								        phase : 2,
							 | 
						||
| 
								 | 
							
								        retry_cnt : 5,
							 | 
						||
| 
								 | 
							
								        /* tx logical phase of this frame, for sta role device,
							 | 
						||
| 
								 | 
							
								         * we always send packet in phase A hwq. this value save the
							 | 
						||
| 
								 | 
							
								         * logical phase to be send.
							 | 
						||
| 
								 | 
							
								         */
							 | 
						||
| 
								 | 
							
								        l_phase: 2,
							 | 
						||
| 
								 | 
							
								        tx_3phase: 1, /* this msdu tx with 3 phase or not */
							 | 
						||
| 
								 | 
							
								        /* indicate whether this msdu is dbg pkt */
							 | 
						||
| 
								 | 
							
								        is_dbg_pkt : 1,
							 | 
						||
| 
								 | 
							
								        /* flag to mark if fix rate required */
							 | 
						||
| 
								 | 
							
								        fix_rate : 1,
							 | 
						||
| 
								 | 
							
								        /* ppm step adjust type, see MAC_PPM_STEP_TYPE_XXX  */
							 | 
						||
| 
								 | 
							
								        ppm_step_type : 2,
							 | 
						||
| 
								 | 
							
								        need_encrypt : 1;
							 | 
						||
| 
								 | 
							
								    /* ppm adjust step */
							 | 
						||
| 
								 | 
							
								    int8_t  ppm_step;
							 | 
						||
| 
								 | 
							
								    uint8_t key_idx : 1,
							 | 
						||
| 
								 | 
							
								            resv    : 7;
							 | 
						||
| 
								 | 
							
								    struct _mac_msdu_frame *next;
							 | 
						||
| 
								 | 
							
								} mac_msdu_frame_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_msdu_is_std_mac_header     check mac header is standard or not.
							 | 
						||
| 
								 | 
							
								 *@param data               msdu frame data point
							 | 
						||
| 
								 | 
							
								 *@return                   1 - standard mac header, 0 - short mac header
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								#define mac_msdu_is_std_mac_header(data) \
							 | 
						||
| 
								 | 
							
								    (uint8_t)(MAC_HEADER_VERSION == ((mac_header_t *)data)->version)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t mac_msdu_init(mac_msdu_t *msdu, uint32_t buf_need_free,\
							 | 
						||
| 
								 | 
							
								    void *stream, iot_pkt_t *msdu_buf, uint8_t retry_cnt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t mac_msdu_deinit(mac_msdu_t *msdu);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint8_t mac_frame_list_init(mac_msdu_frame_t * mac_frame_list,
							 | 
						||
| 
								 | 
							
								    iot_pkt_t *buf, uint8_t bcat, uint8_t phase, uint8_t l_phase,
							 | 
						||
| 
								 | 
							
								    uint8_t retry_cnt, uint8_t is_dbg_pkt, uint16_t is_tx_3phase,
							 | 
						||
| 
								 | 
							
								    uint8_t fix_rate, int8_t ppm_step, uint8_t ppm_step_type);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint8_t mac_msdu_retry_cnt_get(uint8_t proto, void *data);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void mac_msdu_frame_info_get(uint8_t proto, iot_pkt_t *msdu_buf, \
							 | 
						||
| 
								 | 
							
								                                uint8_t **pptr, uint16_t *msdu_len, \
							 | 
						||
| 
								 | 
							
								                                 uint16_t *mac_hdr_len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_get_hdr_len    mac get mac header len.
							 | 
						||
| 
								 | 
							
								 *@param proto              [proto sg spg]
							 | 
						||
| 
								 | 
							
								 *@param msdu_buf           [mac frame]
							 | 
						||
| 
								 | 
							
								 *@return                   [return - 0 means error: other means mac header len]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								uint32_t mac_get_hdr_len(uint8_t proto, iot_pkt_t *msdu_buf);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_msdu_update_with_acked_ssn    mac update msdu send bitmap.
							 | 
						||
| 
								 | 
							
								 *@param msdu                              [cur msdu]
							 | 
						||
| 
								 | 
							
								 *@param tx_ok_pb_ssn                      [cur tx ok pb seq]
							 | 
						||
| 
								 | 
							
								 *@return                                  send bitmap
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_msdu_update_with_acked_ssn(mac_msdu_t *msdu, uint32_t tx_ok_pb_ssn);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t mac_tx_msdu(mac_pdev_t *pdev, \
							 | 
						||
| 
								 | 
							
								    mac_msdu_t *msdu, \
							 | 
						||
| 
								 | 
							
								    uint32_t pb_sz, uint32_t pb_num_per_mpdu, \
							 | 
						||
| 
								 | 
							
								    uint32_t mpdu_num_to_send, \
							 | 
						||
| 
								 | 
							
								    uint32_t delimiter_type, \
							 | 
						||
| 
								 | 
							
								    uint32_t nid, tei_t stei, tei_t dtei, uint32_t lid, \
							 | 
						||
| 
								 | 
							
								    uint8_t is_bcast, phase_t phase, uint32_t proto, \
							 | 
						||
| 
								 | 
							
								    uint32_t port, uint32_t tmi, uint32_t ext_tmi, \
							 | 
						||
| 
								 | 
							
								    uint32_t rate_mode, uint32_t proto_single_band
							 | 
						||
| 
								 | 
							
								);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if HPLC_RF_DEV_SUPPORT
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_tx_rf_msdu                    mac tx rf msdu.
							 | 
						||
| 
								 | 
							
								 *@param rf_pdev                           [the point of rf pdev]
							 | 
						||
| 
								 | 
							
								 *@param msdu                              [cur msdu]
							 | 
						||
| 
								 | 
							
								 *@param option                            [option. PHY_RF_OPTIONXXX]
							 | 
						||
| 
								 | 
							
								 *@param delimiter_type                    [delimiter type]
							 | 
						||
| 
								 | 
							
								 *@param dtei                              [dtei]
							 | 
						||
| 
								 | 
							
								 *@param lid                               [link id]
							 | 
						||
| 
								 | 
							
								 *@param is_bcast                          [is bcast]
							 | 
						||
| 
								 | 
							
								 *@param nid                               [nid]
							 | 
						||
| 
								 | 
							
								 *@param stei                              [source tei]
							 | 
						||
| 
								 | 
							
								 *@param blkz                              [block size id]
							 | 
						||
| 
								 | 
							
								 *@param pbsz                              [pb size]
							 | 
						||
| 
								 | 
							
								 *@param phr_mcs                           [phy header mcs]
							 | 
						||
| 
								 | 
							
								 *@param mcs                               [mcs]
							 | 
						||
| 
								 | 
							
								 *@param msdu_len                          [msdu length]
							 | 
						||
| 
								 | 
							
								 *@return ret                              [tx success or not]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								uint32_t mac_tx_rf_msdu(mac_rf_pdev_t *rf_pdev, mac_msdu_t *msdu,
							 | 
						||
| 
								 | 
							
								    uint32_t option, uint32_t delimiter_type, tei_t dtei, lid_t lid,
							 | 
						||
| 
								 | 
							
								    uint8_t is_bcast, uint32_t nid, tei_t stei, uint32_t blkz, uint32_t pbsz,
							 | 
						||
| 
								 | 
							
								    uint32_t phr_mcs, uint32_t mcs, uint32_t msdu_len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#else /* HPLC_RF_DEV_SUPPORT */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define mac_tx_rf_msdu(rf_pdev, msdu, option, delimiter_type, dtei,         \
							 | 
						||
| 
								 | 
							
								    lid, is_bcast, nid, stei, blkz, pbsz, phr_mcs, mcs, msdu_len)           \                \
							 | 
						||
| 
								 | 
							
								    ERR_NOSUPP;                                                             \
							 | 
						||
| 
								 | 
							
								    do {                                                                    \
							 | 
						||
| 
								 | 
							
								        (void)(rf_pdev);                                                    \
							 | 
						||
| 
								 | 
							
								        (void)(msdu);                                                       \                                               \
							 | 
						||
| 
								 | 
							
								        (void)(option);                                                     \
							 | 
						||
| 
								 | 
							
								        (void)(delimiter_type);                                             \
							 | 
						||
| 
								 | 
							
								        (void)(dtei);                                                       \
							 | 
						||
| 
								 | 
							
								        (void)(lid);                                                        \
							 | 
						||
| 
								 | 
							
								        (void)(is_bcast);                                                   \
							 | 
						||
| 
								 | 
							
								        (void)(nid);                                                        \
							 | 
						||
| 
								 | 
							
								        (void)(stei);                                                       \
							 | 
						||
| 
								 | 
							
								        (void)(blkz);                                                       \
							 | 
						||
| 
								 | 
							
								        (void)(pbsz);                                                       \
							 | 
						||
| 
								 | 
							
								        (void)(phr_mcs);                                                    \
							 | 
						||
| 
								 | 
							
								        (void)(mcs);                                                        \
							 | 
						||
| 
								 | 
							
								        (void)(msdu_len);                                                   \
							 | 
						||
| 
								 | 
							
								    } while(0);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* HPLC_RF_DEV_SUPPORT */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif // !MAC_MSDU_H
							 |