#ifndef ce_inc_mpdu_measure_store_h #define ce_inc_mpdu_measure_store_h /* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file ce/inc/mpdu_measure_store.h * \brief headers for storage and computation of the frames(MPDU) noise measurement.ยป * \ingroup ce * * Each time a frame is received, the DSP stores PB measurement in the PBs * descriptors and computes several type of measurement along the MPDU. PBproc * will transfer any of this measurement (TODO TBD) in block that SAR will * provide to the CE via callback function. * * This header file provides functions to manage the list of frame in which measurement have been stored. * It provides functions to add measurement within. * It provides too basic functions to process measurement. */ #include "mac/pbproc/pbproc.h" #include "hal/phy/pbdma.h" #include "mac/common/sta.h" /** Length of the circular buffer that stores the mpdu measure expressed in frame number. */ #define MPDU_MEASURE_STORE_SIZE 30 #define MPDU_MEASURE_GET_BLK_NB(data_nb, data_nb_per_blk) ((data_nb + data_nb_per_blk - 1)/data_nb_per_blk) #define MPDU_MEASURE_PB_NB_PER_BLK (BLK_SIZE / sizeof(pb_measurement_t)) /** Number of block allocated switch type of chandata*/ uint mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NB]; /** The PB measure (ber, half-it, crc_status) are stored in one or two blk switch the number of PB * in the MPDU. The pb_measure_blk must stay allocatable as a blk_t. */ struct pb_measure_blk_t { /** Pointer to the next descriptor */ struct pb_measure_blk_t *next; /** Pointer to pb measure data */ pb_measurement_t *data; /** Number of valid pb stored in data block.*/ uint pb_nb; }; typedef struct pb_measure_blk_t pb_measure_blk_t; /** All of the measurements made on a MPDU.*/ struct mpdu_measure_t { /** Pointer to the mpdu reception parameters got from pbproc.*/ pbproc_rx_params_t *rx_params; /** Pointer to the first pb measure block.*/ pb_measure_blk_t *pb_head; /** Pointers to the first of each chandata measurement.*/ phy_chandata_t *chandata_head[PHY_CHANDATA_TYPE_NB]; }; typedef struct mpdu_measure_t mpdu_measure_t; /** mpdu measure storage context. * Store has a static space. * Store is managed as a FIFO.*/ struct mpdu_measure_store_t { /** Reserved space to store mpdu measures.*/ mpdu_measure_t store[MPDU_MEASURE_STORE_SIZE]; /** head of store. To get the oldest mpdu measure.*/ uint head; /** tail of store. To put a new mpdu measure inside.*/ uint tail; /** Number of mpdu measures in store.*/ uint measure_nb; }; typedef struct mpdu_measure_store_t mpdu_measure_store_t; BEGIN_DECLS /** * Initialize the mpdu measure store. */ mpdu_measure_store_t * mpdu_measure_store_init (void); /** * todo : Release the previous one. * \return A pointer to the oldest measure present in the store. * */ mpdu_measure_t * mpdu_measure_store_get (mpdu_measure_store_t *ctx); /** * Release mpdu measure pointed data (rx_param, pb measurement block(s), * chandata(s)). * \param measure Pointer to the mpdu measure that contents measure to release; */ void mpdu_measure_store_release (mpdu_measure_store_t *ctx, mpdu_measure_t *measure); bool // Was FIFO not full? mpdu_measure_store_append (mpdu_measure_store_t *ctx, pbproc_rx_params_t *rx_params, uint pb_nb, pb_measure_blk_t ** first, pb_measure_blk_t **last, phy_chandata_t *chandata_head, uint chandata_nb, uint *blk_offset); /** * Add pb measurement in a MPDU measurement. * \param fm Frame measurement where to add pb measurement. * \param pb_nb Number of pb measurement to add. * \param first Where to write the first's' pb measurement. * \param last Where to write the following pb measurement * * first and last can already be used to store any previous pb measurement * from the same MPDU. Is this case, function keep first and last. And SAR * will fill the rest of block thanks to pb_nb information in the * pb_measure_blk and update it. * Otherwise, new allocation is done and pb_nb is reset. */ void mpdu_measure_pb_add (mpdu_measure_t *measure, uint pb_nb, pb_measure_blk_t **first, pb_measure_blk_t **last, uint *blk_offset); /** * Add a particular type noise measurement. * \param fm Frame measurement where to add noise measurement. * \param noise Noise measurement to add. * * The type is described in the phy_chandata descriptor. */ void mpdu_measure_chandata_add (mpdu_measure_t *measure, phy_chandata_t *noise); END_DECLS #endif /* ce_inc_mpdu_measure_store_h */