summaryrefslogtreecommitdiff
path: root/cesar/mac/pbproc/inc/prep_mpdu.h
blob: 113353bb04fb6386f62d61aea5b5e5587c9047b5 (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
#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"

/** Information about the prepared MPDU.  Only contains information for one
 * SOF frame, not a complete 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;
    /** Is a burst, TODO: this may become a MPDU count. */
    bool burst;
    /** 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;
    /** Modulation type. */
    phy_mod_t mod;
    /** 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;
    /** Frame length with preamble (including IFS). */
    uint flp_tck;
    /** Used main MFS. */
    mfs_tx_t *main_mfs;
    /** 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;
    /** 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;
    /** Used combined MFS. */
    mfs_tx_t *combined_mfs;
    /** Combined MFS first segment. */
    pb_t *combined_head;
    /** Combined MFS last segment. */
    pb_t *combined_tail;
    /** Number of combined MFS segment. */
    uint combined_seg_nb;
    /** Number of reserved combined MFS segment from MFS still to be
     * queued. */
    uint combined_seg_nb_reserved;
    /** Combined MFS FSM command. */
    mfs_fsm_cmd_t combined_mfs_cmd;
    /** Combined MFS FSM response. */
    mfs_fsm_rsp_t combined_mfs_rsp;
    /** Number of pending segments, if no new segment is available, they will
     * be sent as PB null. */
    uint seg_nb_pending;
    /** First PB. */
    pb_t *head;
    /** Last PB. */
    pb_t *tail;
    /** Total number of PB. */
    uint pb_nb_total;
    /** Do not use AES encryption. */
    bool bypass_aes;
    /** AES network encryption key. */
    u32 *nek;
};
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
 */
void
pbproc_prep_beacon (pbproc_t *ctx);

/**
 * Prepare the next MPDU, using informations from CA.
 * \param  ctx  pbproc context
 */
void
pbproc_prep_mpdu (pbproc_t *ctx);

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

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

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

/**
 * Acknowledge a selection of PBs based on bitmap information.
 * \param  ctx  pbproc context
 * \param  bmp  bitmap
 * \param  bmps  bitmap start offset
 * \param  bmpl  bitmap available bits
 */
void
pbproc_prep_mpdu_ack_bitmap (pbproc_t *ctx, const u32 *bmp,
                             uint bmps, uint bmpl);

/**
 * Acknowledge a selection of PBs based on compressed bitmap information.
 * \param  ctx  pbproc context
 * \param  si  SACKI bits
 * \param  sil  number of SACKI bits
 */
void
pbproc_prep_mpdu_ack_encoded (pbproc_t *ctx, u32 si[3], uint sil);

/**
 * Set received FSM response, will be handled on commit.
 * \param  ctx  pbproc context
 * \param  mfs_rsp_data  data response
 * \param  mfs_rsp_mgmt  MME response
 */
void
pbproc_prep_mpdu_fsm_response (pbproc_t *ctx, mfs_fsm_rsp_t mfs_rsp_data,
                               mfs_fsm_rsp_t mfs_rsp_mgmt);

/**
 * 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 */