summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/inc/sar_context.h
blob: 92336ec2da04c91f03c701ac4fdb1b755360bab1 (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
#ifndef SAR_CONTEXT_H_
#define SAR_CONTEXT_H_

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/sar/inc/sar_context.h
 * \brief   SAR context declarations.
 * \ingroup mac_sar
 */

#include "mac/pbproc/pbproc.h"
#include "lib/mbox.h"
#include "lib/rnd.h"

#ifdef STATION_H_
#include "hal/phy/bridgedma.h"
#include "hal/phy/forward.h"
#include "hal/phy/maximus/inc/maximus_interrupts.h"
#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
#include "hal/phy/maximus/inc/maximus_bridgedma_ctx.h"
#else
#include "mac/sar/bridgedma/inc/bridge.h"
#endif

#include "mac/sar/sar_mf.h"
#include "mac/sar/inc/sar_expiration.h"
#include "mac/sar/inc/sar_pb.h"
#include "mac/sar/inc/bridge_dma.h"
#include "mac/sar/inc/trace.h"

#include "common/defs/priority.h"

struct sar_mpdu_t
{
    /** Received frame. */
    pbproc_rx_t rx;
    /** Expiration date of the frame. */
    u32 expiration_ntb;
};
typedef struct sar_mpdu_t sar_mpdu_t;

struct sar_msdu_t
{
    /** Ats confounder field*/
    u32 ats_confounder;
    /** type and length of the data to segment */
    u16 length;
    /** The buffer address to use */
    u8 *buffer_address;
    /** the associated MFS */
    mfs_tx_t *mfs;
    /** User data. */
    void *user_data;
    /** Expiration time in NTB ticks. */
    u32 expiration_time_ntb;
};
typedef struct sar_msdu_t sar_msdu_t;

struct sar_reassembly_ctx_t
{
    sar_reassembly_done_cb_t sar_rea_done;
    sar_bridge_dma_list_t jobs_pending_list;

    mbox_t buffers;
};
typedef struct sar_reassembly_ctx_t sar_reassembly_ctx_t;

enum message_type_t
{
    SAR_MSG_SEG,
    SAR_MSG_REA,
    SAR_MSG_ADD_BUFFER,
    SAR_MSG_BRIDGE,
    SAR_MSG_MFS_CMD,
    SAR_MSG_NONE
};
typedef enum message_type_t message_type_t;

struct sar_buffer_add_t
{
    /** Data or MME context. */
    sar_reassembly_ctx_t *ctx;
    /** Buffer address. */
    u8 *buffer;
};
typedef struct sar_buffer_add_t sar_buffer_add_t;

union sar_work_message_union_t
{
    /** MPDU data for the reassembly */
    sar_msdu_t msdu;
    /** MSDU data for the segmentation */
    sar_mpdu_t mpdu;
    /** buffer add. */
    sar_buffer_add_t buffer_add;
    /** MFS TX for the MFS CMD process. */
    mfs_tx_t *mfs;
};
typedef union sar_work_message_union_t sar_work_message_union_t;

/** Work message, fit into a block descriptor (note the member order to match
 * next and data in blk_t). */
union sar_work_message_t
{
    /** Common block descriptor. */
    blk_t blk;
    struct
    {
        /** Mailbox node. */
        mbox_node_t node;
        /** Message. */
        sar_work_message_union_t *msg;
        /** Message type. */
        message_type_t type;
    };
};
typedef union sar_work_message_t sar_work_message_t;

/** SAR context */
struct sar_t
{
    /** The list of job for the bridge DMA
     * Data initialized in the sar_init */
    sar_bridge_dma_list_t bridge_dma_jobs;

    /**
     * SAR expiration context
     */
    sar_expiration_t expiration;

    /** Mailbox. */
    mbox_t mbox;

    /** inform the upper layer when a job had been bridged
     * Initialized in sar_segmentation_init_mme_cb */
    sar_segmentation_done_cb_t sar_seg_data_done_cb;

    /** inform the upper layer when a job had been bridged
     * Initialized in sar_segmentation_init_data_cb*/
    sar_segmentation_done_cb_t sar_seg_msg_done_cb;

    /** Call back pointer for measurement data
     * Data initialized in the sar_init_measurement_cb */
    sar_measurement_cb_t sar_measurement;

    /** SAR context for the DATA reassembly
     * sar_init_reassembly_data_cb */
    sar_reassembly_ctx_t data_ctx;

    /** SAR context for the MME reassembly
     * sar_init_reassembly_mme_cb */
    sar_reassembly_ctx_t mme_ctx;

    /** beacon function call back */
    void *beacon_user_data;
    sar_beacon_cb_t beacon_function_cb;

    /** Tick per RTC eCos. */
    u32 tck_per_rtc;

    /** Activated. */
    bool activate;

    /** Last expiration date in NTB. */
    u32 expiration_last_ntb;

    /** Random generator context. */
    lib_rnd_t rnd_gen;

    /** ****************** Layers context ***************/

    /** Bridge DMA context
     * Data initialized in the sar_init */
    phy_bridgedma_t *bridgedma_ctx;

    /** Pb proc call back to provide pbs */
    pbproc_t *pbproc_ctx;

    /** Channel estimation ctx */
    void *ul_ce_ctx;

    /** data context */
    void *ul_data_ctx;

    /** message context */
    void *ul_msg_ctx;

    /** Thread context. */
    u8 thread_stack [MAC_SAR_THREAD_STACK_SIZE];
    cyg_handle_t thread_handle;
    cyg_thread thread;

    /** Tracing system */
#if CONFIG_TRACE
    /** SAR Trace */
    trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
};

#endif /*SAR_CONTEXT_H_*/