summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h
blob: c7cc92c85b01f612dfe256c3586fe91c4a863e20 (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
#ifndef hal_phy_maximus_inc_maximus_phy_ctrl_h
#define hal_phy_maximus_inc_maximus_phy_ctrl_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/phy/maximus/inc/maximus_phy_ctrl.h
 * \brief   HAL Phy control declarations for Maximus.
 * \ingroup hal_phy_maximus
 */

#include "maximus/common/types/phy_types.h"
#include "hal/phy/forward.h"
#include "host/fwd.h"

/**
 * Used to display medium state.
 * \param ctx current phy context
 * \return a string describing the Maximus PHY medium state if ok,
 * NULL if it fails with errno =
 * - EINVAL if ctx is NULL, or if ctx->access.medium_state is out-of-range
 */
const char *
maximus_phy_get_medium_state(phy_t *ctx);

/**
 * Fill a blank phy header
 * \param ctx current phy context
 * \param msg pointer to sci message to fill header
 * \param type type of message (PREAMBLE, FC_HYBRID_MODE, FC_AV_ONLY_MODE, PRS, MPDU_PAYLOAD, TONEMASK, TONEMAP, NOISE, RX, ZERO_CROSS)
 * \param mpdu_format MPDU format of message (BEACON, SOF, SACK, RTS_CTS, SOUND, RSOF)
 * \param pb_nb number of PBs into message
 * \param fc_mode Frame Control mode
 * \param short_ppdu short PPDU
 * \param mod modulation
 * \param fecrate FEC rate
 * \param gil Guard Interval
 * \param tonemap_index tone map index used for message
 * \param tx_id transmission ID used for message
 * \param flags flags of message
 * \param symbol_nb number of symbols into message
 * \param iv iv used for message
 * \param nek nek used for message
 * \param pb_measurement ber, halfit and crc measured for each PB of message
 * \param pb_header PB header for each PB of message
 * \return 0 if ok, -1 if it fails with errno =
 * - EINVAL if ctx or msg are NULL, or if arguments are out-of-range
 */
int
maximus_phy_fill_hdr(phy_t *ctx,
                     sci_msg_t *msg,
                     uint8_t type,
                     uint8_t mpdu_format,
                     uint8_t pb_nb,
                     uint8_t msg_nb,
                     uint8_t fc_mode,
                     uint8_t short_ppdu,
                     uint8_t mod,
                     uint8_t fecrate,
                     uint8_t gil,
                     uint8_t tonemap_index,
                     uint16_t tx_id,
                     uint16_t flags,
                     uint32_t symbol_nb,
                     uint32_t iv[3],
                     uint32_t nek[4],
                     uint32_t pb_measurement[PHY_PB_MAX_NB],
                     uint32_t pb_header[PHY_PB_MAX_NB]);

/**
 * Process phy message received by the sci layer.
 * This function must be registred to SCI layer with SCI_MSG_TYPE_PHY type.
 * \param msg message to process
 * \param phy phy current context
 * \return 0 if ok, -1 if it fails with errno =
 * - EINVAL if msg or phy are NULL
 * - EPROTO if msg->hdr.phy is null, or if msg->hdr.phy values are out-of-range or incoherent
 */
int maximus_phy_recv (sci_msg_t *msg, void *phy);

/**
 * Process phy message received by the sci layer, depending on the phy header type.
 * \param phy phy current context
 * \param msg message to process
 * \return 0 if ok, -1 if if it fails with errno =
 * - EINVAL if ctx, msg, msg->sci_hdr or ctx->control.rx_fc_cb are null
 * - EPROTO if msg->hdr.phy->type is incorrect, if msg->hdr.phy values are incorrect, incoherent or out-of-range,
 *   if recv MPDU payload but medium state is not RX or RX has not been prepared,
 *   or if chandata is null
 */
int maximus_phy_recv_none (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_preamble (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_fc_hybrid_mode (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_fc_av_only_mode (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_prs (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_mpdu_payload (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_tonemask (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_tonemap (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_noise (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_rx (phy_t *ctx, sci_msg_t *msg);
int maximus_phy_recv_zero_cross (phy_t *ctx, sci_msg_t *msg);

/**
 * Maximus PHY preamble reception callback called when the corresponding netclock message is received.
 * \param  data  pointer to 'maximus_phy_recv_preamble_t' structure,
 *               containing flag PHY_FLAG_WRONG_PREAMBLE of the received preamble message.
 * set errno to:
 * - EINVAL if data is null
 */
void maximus_phy_recv_preamble_cb (void *data);

/**  Maximus structure for Maximus preamble reception callback */
struct maximus_phy_recv_preamble_t
{
    phy_t *ctx;
    bool wrong_preamble;
    uint16_t src_tx_id;
    uint16_t src_station_id;
};
typedef struct maximus_phy_recv_preamble_t maximus_phy_recv_preamble_t;

/**
 * Send a PHY SCI message of type TONEMASK, TONEMAP or RX to Maximus.
 * \param ctx phy current context
 * \return 0 if ok, -1 if if it fails with errno =
 * - EINVAL if ctx is null
 * if 'sci_send()' fails, it sets errno
 */
int maximus_phy_send_tonemask (phy_t *ctx);
int maximus_phy_send_tonemap (phy_t *ctx);
int maximus_phy_send_rx (phy_t *ctx);

/**
 * Cancel the next TX frame request.
 * \param  ctx  phy context.
 * set errno to:
 * - EINVAL if ctx is null
 * if 'netclock_unschedule()' fails, it sets errno
 */
void maximus_phy_next_tx_frame_cancel (phy_t *ctx);

/**
 * Cancel the current TX frame request.
 * \param  ctx  phy context.
 * set errno to:
 * - EINVAL if ctx is null
 * if 'netclock_unschedule()' fails, it sets errno
 */
void maximus_phy_current_tx_frame_cancel (phy_t *ctx);

/**
 * Cancel the previous RX activate request.
 * \param  ctx  phy context.
 * set errno to:
 * - EINVAL if ctx is null
 * if 'netclock_unschedule()' fails, it sets errno
 */
void maximus_phy_rx_activate_cancel (phy_t *ctx);

/**
 * Compute schedule tick.
 * \param  date  programmed date
 * \return schedule tick if ok, -1 if programmed date is considered to be in the past with errno = EINVAL
 */
tick_t maximus_phy_schedule_tick (u32 date);

/**
 * Maximus TX frame first callback called when the corresponding netclock message is received.
 * \param  data  pointer to 'maximus_tx_frame_t' structure, containing argument 'want_conf' of 'phy_tx_frame'.
 * set errno to:
 * - EINVAL if data, ctx->control.access_conf_cb or ctx->control.deferred_cb are null
 * - EPROTO if medium state is not idle
 * if 'netclock_schedule()' fails, it sets errno
 */
void maximus_phy_tx_frame_cb (void *data);

/**  Maximus structure for Maximus TX frame first callback */
struct maximus_phy_tx_frame_t
{
    phy_t *ctx;
    bool want_conf;
};
typedef struct maximus_phy_tx_frame_t maximus_phy_tx_frame_t;

/**
 * Maximus TX frame second callback called when the corresponding netclock message is received.
 * \param  data  pointer to 'phy_t' structure.
 * set errno to:
 * - EINVAL if data is null
 * - EPROTO if medium state is not tx
 * if 'sci_send()' or 'netclock_schedule()' fails, it sets errno
 */
void maximus_phy_tx_pre_cb (void *data);

/**
 * Maximus TX frame third callback called when the corresponding netclock message is received.
 * \param  data  pointer to 'phy_t' structure.
 * set errno to:
 * - EINVAL if data is null
 * - EPROTO if medium state is not tx
 * if 'sci_send()' or 'netclock_schedule()' fails, it sets errno
 */
void maximus_phy_tx_fc_cb (void *data);

/**
 * Maximus TX frame fourth callback called when the corresponding netclock message is received.
 * \param  data  pointer to 'phy_t' structure.
 * set errno to:
 * - EINVAL if data is null
 * - EPROTO if medium state is not tx
 * if 'sci_send()' fails, it sets errno
 */
void maximus_phy_tx_mpdu_cb (void *data);

/**
 * Maximus RX activate callback called when the corresponding netclock message is received.
 * \param  data  pointer to 'maximus_phy_rx_activate_t' structure, containing argument 'flag' of 'phy_rx_activate'.
 * set errno to:
 * - EINVAL if data is null
 */
void maximus_phy_rx_activate_cb (void *data);

/**  Maximus structure for Maximus RX activate callback */
struct maximus_phy_rx_activate_t
{
    phy_t *ctx;
    bool pre_detection;
};
typedef struct maximus_phy_rx_activate_t maximus_phy_rx_activate_t;

/**
 * Maximus extra timer program callback called when the corresponding netclock message is received.
 * \param  data  pointer to 'phy_t' structure.
 * set errno to:
 * - EINVAL if data or ctx->control.extra_timer_cb are null
 */
void maximus_phy_extra_timer_cb (void *data);

#endif /* hal_phy_maximus_inc_maximus_phy_ctrl_h */