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

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/sar/inc/sar.h
 * \brief   private declaration functions of the SAR.
 * \ingroup mac/sar/inc
 *
 */
#include <cyg/hal/hal_arch.h>
#include <cyg/kernel/kapi.h>

#define SAR_MPDU_RX_REFILL 1

BEGIN_DECLS

/**
 * Initialize the reassembly context.
 * \param  ctx  the SAR reassembly context.
 */
void
sar_reassembly_init (sar_reassembly_ctx_t *ctx);

/**
 * Alloc pb_nb chained PB list for the PB Pool.
 * \param  ctx  the SAR context.
 * \param  pb_nb  the quantity of PBs to allocate.
 */
void
sar_pb_pool_refill (sar_t *ctx, uint pb_nb);

/**
 * Parse the chain of PBs received from the pb proc.
 * \param  ctx  the sar context
 * \param  rx  the mpdu_rx containing the PB to add to the MFS
 *
 * it:
 * - Verifies if the PB is valid
 * - Transmit the data to the CE.
 * - Update the mfs window according with the HomePlug AV specification.
 * - Verifies if the PB is in the window
 * - Insert it in the right place in the corresponding MFS.
 */
void
sar_rx_mpdu_process (sar_t *ctx, sar_mpdu_t * rx);

/**
 * Provide the next reassembly job to the bridge DMA.
 * \param  sar_ctx  the SAR context.
 * \param  ctx the reassembly context to transmit the data.
 *
 * It only provided the job to the bridge DMA if a reassembly buffer is
 * available. It will loop to provide a maximum of jobs to the bridge DMA
 * until it has available buffers and jobs.
 */
void
sar_rx_upper_layer_transmit_data (sar_t *sar_ctx, sar_reassembly_ctx_t *ctx);

/**
 * Create the job descriptor and allocate the PB to store the MSDU.
 * \param  ctx  the sar context.
 * \param  md_data  the data to segment.
 * \param  mfs  the corresponding MFS.
 * \param  job_mfs  the job to fill.
 * \return the last pb of the chain.
 */
pb_t*
sar_tx_job_desc_create (sar_t *ctx, sar_msdu_t *md_data, mfs_tx_t * mfs,
                        sar_job_mfs_t *job_mfs);


/**
 * Prepare the segmentation process for the MSDU provided.
 * \param  ctx  the SAR context.
 * \param  md_data  the Mac Frame to segment.
 */
void
sar_tx_mac_framing (sar_t *ctx, sar_msdu_t *md_data);

/**
 * Launch the reassembly process to realize reassembly a new MPDU.
 * \param  ctx  the SAR context.
 * \param  rx  the RX data to process.
 */
void
sar_reassembly_run (sar_t *ctx, sar_mpdu_t *rx);

/**
 * Process the head of the bridge DMA list.
 * \param  ctx  the SAR context.
 *
 * Only call after a bridge DMA process.
 */
void
sar_bridge_dma_free_head (sar_t *ctx);

/**
 * Process the MFS to reconstitute Mac Frames.
 * \param  ctx  the SAR context
 * \param  mfs  the MFS to process.
 * \param  rea_ctx  the reassembly context.
 *
 * Process the contiguous PB list in the MFS and reconstitute all possibles
 * Mac Frames the sub list contains. If PBs are missing to reassembly the next
 * Mac Frame, the procedure is stopped until the missing PBs are received or
 * the PBs are expired.
 */
void
sar_rx_mfs_process (sar_t *ctx, mfs_rx_t * mfs,
                    sar_reassembly_ctx_t *rea_ctx);

/**
 * SAR thread entry function.
 * \param  data  the SAR context.
 */
void
sar_process (cyg_addrword_t data);

END_DECLS

#endif /* MAC_SAR_INC_SAR_H_ */