summaryrefslogtreecommitdiff
path: root/ce/inc/mpdu_measure_store.h
blob: f8b7f5e92db95d6edef787490d9a79423c87645d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef ce_inc_mpdu_measure_store_h
#define ce_inc_mpdu_measure_store_h
/* Cesar  project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \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 */