summaryrefslogtreecommitdiff
path: root/cesar/mac/pbproc/inc/prep_mpdu.h
blob: 87eee1deef402f155e7c339f93b1d5713e2f8175 (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#ifndef mac_pbproc_inc_prep_mpdu_h
#define mac_pbproc_inc_prep_mpdu_h
/* Maria project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/pbproc/inc/prep_mpdu.h
 * \brief   Prepare MPDU complex function.
 * \ingroup mac_pbproc
 */
#include "mac/pbproc/pbproc.h"
#include "mac/pbproc/inc/fc.h"
#include "mac/pbproc/inc/sacki_dec.h"

/** Maximum number of MPDU in a burst. */
#define PBPROC_PREP_MPDU_NB_MAX 2

/** Information about a single MPDU inside a burst. */
struct pbproc_prep_mpdu_single_t
{
    /** Tonemap index. */
    uint tmi;
    /** If using an interval, this is the interval index, else this is
     * TONEMAP_INTERVAL_NB. */
    uint interval;
    /** If using an interval, this is the version of the interval set. */
    uint intervals_version;
    /** Main MFS first segment. */
    pb_t *main_head;
    /** Main MFS last segment. */
    pb_t *main_tail;
    /** Number of main MFS segment. */
    uint main_seg_nb;
    /** Total number of PB. */
    uint pb_nb_total;
};
typedef struct pbproc_prep_mpdu_single_t pbproc_prep_mpdu_single_t;

/** Information about the prepared burst.  Also contain information on the
 * next prepared MPDU which is not kept during all the burst. */
struct pbproc_prep_mpdu_t
{
    /** Source TEI. */
    u8 stei;
    /** Destination TEI. */
    u8 dtei;
    /** Link identifier. */
    u8 lid;
    /** Is there a prepared frame. */
    bool valid;
    /** With acknowledgement (unicast or multicast partial
     * acknowledgement). */
    bool wack;
    /** Unassociated transmission. */
    bool unassociated;
    /** Use RTS/CTS. */
    bool rts_cts;
    /** Total number of MPDU in a burst. */
    uint burst_mpdu_nb;
    /** MPDU count for the current MPDU. */
    uint mpdu_count;
    /** RTS TX date of start of preamble. */
    u32 rts_tx_date;
    /** RTS frame control. */
    pbproc_fc_t rts_fc_av;
    /** RTS frame control 1.0. */
    u32 rts_fc10;
    /** Frame control mode. */
    phy_fc_mode_t fc_mode;
    /** Phy combo parameters. */
    u32 phy_combo_params;
    /** Guard interval. */
    phy_gil_t gil;
    /** Tonemap. */
    blk_t *tonemap;
    /** Sound reason code. */
    tonemap_sound_reason_code_t sound_reason_code;
    /** SOF TX date of start of preamble. */
    u32 tx_date;
    /** SOF frame control. */
    pbproc_fc_t fc_av;
    /** SOF frame control 1.0. */
    u32 fc10;
    /** Inter Frame Spacing (IFS). */
    uint ifs_tck;
    /** Frame length with preamble (including IFS). */
    uint flp_tck;
    /** Number of symbols. */
    uint symb_nb;
    /** Used main MFS. */
    mfs_tx_t *main_mfs;
    /** Number of reserved main MFS segment from MFS still to be queued. */
    uint main_seg_nb_reserved;
    /** Main MFS FSM command. */
    mfs_fsm_cmd_t main_mfs_cmd;
    /** Main MFS FSM response. */
    mfs_fsm_rsp_t main_mfs_rsp;
    /** Do not use AES encryption. */
    bool bypass_aes;
    /** AES network encryption key. */
    u32 *nek;
    /** Data kept for each individual MPDU. */
    pbproc_prep_mpdu_single_t mpdu[PBPROC_PREP_MPDU_NB_MAX];
    /** Pointer to current MPDU data, should be synchronised with
     * mpdu_count. */
    pbproc_prep_mpdu_single_t *current;
    /** First segment to be returned to main MFS. */
    pb_t *main_commit_return_head;
    /** Last segment to be returned to main MFS. */
    pb_t *main_commit_return_tail;
    /** Number of segments extracted from the MFS to be returned to main MFS. */
    uint main_commit_return_seg_nb;
    /** Number of reserved segments to be returned to main MFS. */
    u16 main_commit_return_seg_nb_reserved;
    /** SSN of the first segment of the global burst chain. */
    u16 burst_head_ssn;
    /** SSN of the last segment of the global burst chain. */
    u16 burst_tail_ssn;
    /** Total number of segments in the burst chain already sent. */
    u16 burst_seg_nb;
    /** Number of segments expired in the MFS after transmission. */
    u16 expired_segments_nb;
    /** Minimum SSN expected by the receiver for the next transmission. */
    u16 min_rx_ssn;
};
typedef struct pbproc_prep_mpdu_t pbproc_prep_mpdu_t;

BEGIN_DECLS

/**
 * Initialise prepared MPDU structure.
 * \param  ctx  pbproc context
 */
void
pbproc_prep_mpdu_init (pbproc_t *ctx);

/**
 * Prepare a beacon, using informations from CA.
 * \param  ctx  pbproc context
 * \param  mfs  mfs for which beacon is sent
 */
void
pbproc_prep_beacon (pbproc_t *ctx, mfs_tx_t *mfs);

/**
 * Prepare the next MPDU, using informations from CA.
 * \param  ctx  pbproc context
 * \param  mfs  mfs for which data is sent
 */
void
pbproc_prep_mpdu (pbproc_t *ctx, mfs_tx_t *mfs);

/**
 * Chain the remaining segments.
 * \param  ctx  pbproc context
 */
void
pbproc_prep_mpdu_chain (pbproc_t *ctx);

/**
 * Cancel a burst preparation and repair MFS.
 * \param  ctx  pbproc context
 */
void
pbproc_prep_mpdu_cancel_burst (pbproc_t *ctx);

/**
 * Cancel a MPDU preparation.
 * \param  ctx  pbproc context
 * \param  mpdu_count  MPDU index in burst
 */
void
pbproc_prep_mpdu_cancel (pbproc_t *ctx, uint mpdu_count);

/**
 * Acknowledge every PB in burst.
 * \param  ctx  pbproc context
 */
void
pbproc_prep_mpdu_ack_all_burst (pbproc_t *ctx);

/**
 * Acknowledge every PB.
 * \param  ctx  pbproc context
 * \param  mpdu_count  MPDU index in burst
 */
void
pbproc_prep_mpdu_ack_all (pbproc_t *ctx, uint mpdu_count);

/**
 * Acknowledge a selection of PBs based on bitmap information.
 * \param  ctx  pbproc context
 * \param  mpdu_count  MPDU index in burst
 * \param  sacki_dec  SACKI decompression context
 */
void
pbproc_prep_mpdu_ack_bitmap (pbproc_t *ctx, uint mpdu_count,
                             pbproc_sacki_dec_t *sacki_dec);

/**
 * Acknowledge a selection of PBs based on compressed bitmap information.
 * \param  ctx  pbproc context
 * \param  mpdu_count  MPDU index in burst
 * \param  sacki_dec  SACKI decompression context
 */
void
pbproc_prep_mpdu_ack_encoded (pbproc_t *ctx, uint mpdu_count,
                              pbproc_sacki_dec_t *sacki_dec);

/**
 * Uniform acknowledge.
 * \param  ctx  pbproc context
 * \param  mpdu_count  MPDU index in burst
 * \param  sacki  SACKI uniform information
 */
void
pbproc_prep_mpdu_ack_uniform (pbproc_t *ctx, uint mpdu_count, uint sacki);

/**
 * Handle acknowledge.
 * \param  ctx  pbproc context
 * \param  sackt  SACKT information
 * \param  sacki_dec  SACKI decompression context
 */
void
pbproc_prep_mpdu_ack (pbproc_t *ctx, const u8 sackt[],
                      pbproc_sacki_dec_t *sacki_dec);

/**
 * Update FSM response and window size and launch acknowledge handling.
 * \param  ctx  pbproc context
 * \param  ack_data  data extracted from SACK frame control
 */
void
pbproc_prep_mpdu_handle_sack (pbproc_t *ctx, pbproc_fc_ack_data_t *ack_data);

/**
 * Commit burst.
 * \param  ctx  pbproc context
 *
 * Commit the whole access:
 *  - return unacknowledged segments to MFS.
 *  - commit FSM.
 *  - update MFS in CA.
 *  - clear prepared burst.
 */
void
pbproc_prep_mpdu_commit_burst (pbproc_t *ctx);

/**
 * Acknowledge or cancel a SOUND frame.
 * \param  ctx  pbproc context
 * \param  scf  true if a acknowledgement has been received and SCF was set
 */
void
pbproc_prep_mpdu_sound_ack (pbproc_t *ctx, bool scf);

END_DECLS

#endif /* mac_pbproc_inc_prep_mpdu_h */