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

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

#include "mac/pbproc/pbproc.h"
#include "lib/circular_buffer.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/inc/sar_expiration.h"
#include "mac/sar/inc/sar_mf.h"
#include "mac/sar/inc/sar_pb.h"
#include "mac/sar/inc/bridge_dma.h"
#include "mac/sar/inc/trace.h"


#define SAR_NUMBER_OF_SLOTS_DATA 128
#define SAR_NUMBER_OF_SLOTS_MSG 1

/** mpdu_rx_t */
struct sar_mpdu_t
{
    pbproc_rx_params_t *rx_params;
    pb_t *chandata;
    uint nb_chandata;
    mfs_rx_t *mfs;
    mfs_rx_t *mme;
    pb_t *head;
    pb_t *tail;
    uint number;
    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;
};
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;
    
    circular_buffer_t buffer_address_list;
};
typedef struct sar_reassembly_ctx_t sar_reassembly_ctx_t;

enum message_type_t
{
    SEG,
    REA,
    ADD_BUFFER,
    BRIDGE
};
typedef enum message_type_t message_type_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 address */
    u8 *buffer_addr;
    /** Bridge direction */
    bool bridge_direction;
};
typedef union sar_work_message_union_t sar_work_message_union_t;

struct sar_work_message_t
{
    /**TODO To be removed if the use of the ecos mailbox is kept*/
    //struct work_message_t *next;
    message_type_t type;
    /** reassembly ctx */
    sar_reassembly_ctx_t *ctx;
    sar_work_message_union_t msg;
};
typedef struct sar_work_message_t sar_work_message_t;

/** Sar context */
struct sar_t
{
    /** Data initialized in the sar_init */

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

    /** work mailbox for the segmentation process 
     * Data initialized in the sar_init */
    cyg_mbox mailbox;
    /** msdu mailbox handle to use the mailbox 
     * Data initialized in the sar_init */
    cyg_handle_t mailbox_handle;

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

    /** inform the upper layer when a job hab been bridged 
     * Initiliazed 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;
    u8 *data_slots[SAR_NUMBER_OF_SLOTS_DATA];

    /** sar context for the mme reassembly 
     * sar_init_reassembly_mme_cb */
    sar_reassembly_ctx_t mme_ctx;
    u8 *mme_slots[SAR_NUMBER_OF_SLOTS_MSG];

    /** beacon function call back */
    void *beacon_user_data;
    sar_beacon_cb_t beacon_function_cb;
    
    /** ****************** 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 [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_*/