summaryrefslogtreecommitdiff
path: root/cl/test/overide/mac/sar/sar.h
blob: 229ac643699da24318cb9d095f65455560219507 (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
#ifndef SAR_H_
#define SAR_H_

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    sar.h
 * \brief   The SAR overwrite.
 * \ingroup cl/test/inc/sar.h
 * 
 */

#include "mac/common/mfs.h"
#include "mac/common/store.h"
#include "mac/pbproc/pbproc.h"

/**
 * Segmentation job done for the segmentation module, it send a data to inform 
 * the upper layer that a job had been processed.
 * 
 * \param  user upper layer context
 * \param  buffer the buffer which is no more used.
 * \param  length the length of the buffer.
 * \param  mfs the mfs correponding to the payload in the buffer.
 * 
 * The MFS reference is given to the CL it do not make a addref on it.
 */
typedef void (*sar_segmentation_done_cb_t) (void *user, u8* buffer);

/**
 * Inform the upper layer that the buffer given in parameter is not used anymore.
 * 
 * \param  user upper layer context pointer
 * \param  buffer the buffer which is no more used.
 * \param  length the length of the buffer. 
 * \param  mfs the mfs correponding to the payload in the buffer.
 * 
 * The MFS reference is given to the CL it do not make a addref on it.
 */
typedef void (*sar_reassembly_done_cb_t) (void *user, u8* buffer,
        uint length, mfs_rx_t *mfs);

struct sar_expiration_t
{
    mac_store_t *mfs_store;
};
typedef struct sar_expiration_t sar_expiration_t;

struct sar_t
{
    void *ul_data_ctx;
    void *ul_msg_ctx;

    sar_segmentation_done_cb_t sar_msg_segmentation_done;
    sar_segmentation_done_cb_t sar_data_segmentation_done;

    sar_reassembly_done_cb_t sar_rea_mme_done;
    sar_reassembly_done_cb_t sar_rea_data_done;

    sar_expiration_t expiration;
};
typedef struct sar_t sar_t;

sar_t * sar_init (mac_store_t *mac_store, pbproc_t *pbproc, ca_t *ca);

void sar_uninit (sar_t *ctx);

/**
 * Add the mac store to the SAR.
 * 
 * \param  ctx the sar context
 * \param  mac_store the mac store ctx.
 */
void sar_init_mac_store (sar_t *ctx, mac_store_t *mac_store);

bool sar_msdu_add (sar_t *sar_ctx, u8* buffer, u16 length,
        u32 ats_confounder, mfs_tx_t *mfs);

/**
 * Used by the upper layers to send or received messages.
 * 
 * \param  ctx the sar context
 * \param sar_seg_done used by the segmentation to inform the upper layer the 
 * buffer is not used anymore.
 */
void sar_init_segmentation_mme_cb (sar_t *ctx,
        sar_segmentation_done_cb_t sar_seg_done);

/**
 * Add the upper data layer context to the SAR. It allows the sar to use
 * the context in the callbacks to this layer.
 * 
 * \param  ctx the sar context
 * \param  user the upper layer msg context.
 */
void sar_init_mme_context (sar_t *ctx, void *user);

/**
 * Initialise the callback pointer and return the contexte to the Upper layers
 * 
 * \param  ctx the sar context
 * \param  sar_rea_done inform the upper layers that the buffer is filled.
 * \param  data a boolean to indicate if it is a data stream or not.
 */
void sar_init_reassembly_ul (sar_t *ctx,
        sar_reassembly_done_cb_t sar_rea_done, bool data);

/**
 * Initialise the callback pointer and return the contexte to the Control Plane
 * to manage MME data
 * 
 * \param  ctx the sar context
 * \param  sar_rea_done the function to call when the bridge DMA ends a job.
 */
extern inline void sar_init_reassembly_mme_cb (sar_t *ctx,
        sar_reassembly_done_cb_t sar_rea_done)
{
    sar_init_reassembly_ul (ctx, sar_rea_done, false);
}

/**
 * Add the upper data layer context to the SAR. It allows the sar to use
 * the context in the callbacks to this layer.
 * 
 * \param  ctx the sar context
 * \param  user the upper layer data context.
 */
void sar_init_data_context (sar_t *ctx, void *user);

/**
 * Used by the upper layers to send or received data.
 * 
 * \param  ctx the sar context 
 * \param sar_seg_done used by the segmentation to inform the upper layer the 
 * buffer is not used anymore.
 */
void sar_init_segmentation_data_cb (sar_t *ctx,
        sar_segmentation_done_cb_t sar_seg_done);

/**
 * Initialise the callback pointer and return the contexte to the Convergence 
 * layer to manage data
 * 
 * \param  ctx the sar context
 * \param  sar_rea_done  the function to call when the bridge DMA ends a job.
 */
extern inline void sar_init_reassembly_data_cb (sar_t *ctx,
        sar_reassembly_done_cb_t sar_rea_done)
{
    sar_init_reassembly_ul (ctx, sar_rea_done, true);
}

bool sar_mme_buffer_add (sar_t *ctx, u8* buffer_addr);

bool sar_data_buffer_add (sar_t *ctx, u8* buffer_addr);

#endif /*SAR_H_*/