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

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

#include "mac/pbproc/pbproc.h"
#include "lib/slist.h"
#include "lib/rnd.h"
#include "lib/seq_check.h"
#include "hal/phy/bridgedma.h"
#include "bufmgr/bufmgr.h"

#ifdef STATION_H_
#include "hal/phy/forward.h"
#include "hal/phy/maximus/inc/maximus_interrupts.h"
#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
#endif

#include "mac/sar/sar.h"
#include "mac/sar/sar_pb_stats.h"
#include "mac/sar/inc/mf_header.h"
#include "mac/sar/inc/expiration.h"
#include "mac/sar/inc/sar_job_mfs.h"
#include "mac/sar/inc/trace.h"
#include "config/stats.h"
#include "config/sar.h"

/** Invalid SSN. */
#define SAR_SSN_INVALID 0x10000

struct sar_mpdu_t
{
    /** Received frame. */
    pbproc_rx_t rx;
    /** Arrival time of the frame in NTB ticks. */
    u32 arrival_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;
    /** Arrival time in NTB. */
    u32 arrival_ntb;
};
typedef struct sar_msdu_t sar_msdu_t;

struct sar_bridgedma_pending_list_t
{
    /* list head. */
    sar_job_mfs_t *head;
    /* list tail. */
    sar_job_mfs_t *tail;
};
typedef struct sar_bridgedma_pending_list_t sar_bridgedma_pending_list_t;

struct sar_reassembly_ctx_t
{
    /** SAR reassembly callback DATA function. */
    sar_reassembly_cb_t data_cb;
    /** SAR reassembly callback MME function. */
    sar_reassembly_cb_t mme_cb;
    /** SAR reassembly user data callback. */
    void *user_data;
    /** SAR job pending list. */
    sar_bridgedma_pending_list_t jobs_pending_list;
};
typedef struct sar_reassembly_ctx_t sar_reassembly_ctx_t;

/**
 * Statistics gathered by the SAR module.
 */
struct sar_stats_t
{
    /** Total number of PB received by ourself (from anyone). */
    u32 rx_pb_count;
    /** Total number of PB with a CRC error received by ourself (from
     * anyone). */
    u32 rx_pb_crc_error_count;
    /** BER sum of all PBs correct received from any station in the AVLN. */
    u64 ber_sum;
    /** Number of times the PBPool had not been filled. */
    u32 pb_pool_not_filled;
};
typedef struct sar_stats_t sar_stats_t;

struct sar_pb_stats_t
{
    blk_table_t *table;
    sar_pb_stats_entry_t *current_entry;
    uint write_index;
    uint amount_to_read;
    uint amount_read;

    uint control_reg;
    uint current_pb;
    u8 current_stei_filter;
    u8 enable;
};
typedef struct sar_pb_stats_t sar_pb_stats_t;

/** SAR context */
struct sar_t
{
    /** Mac store. */
    mac_store_t *mac_store;
    /** Channel access. */
    ca_t *ca;
    /** Call back pointer for measurement data
     * Data initialized in the sar_init_measurement_cb */
    sar_measurement_cb_t sar_measurement;

    /** SAR context for reassembly */
    sar_reassembly_ctx_t reassembly;

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

    /** Activated. */
    bool activate;

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

    /** Missing PBs number to allocate for the PB Pool. */
    uint pbs_missing_for_pbproc;
    /** DMA pointer to TX static SAR job descriptor . */
    sar_job_mfs_t *job_tx;

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

    /** Buffer manager. */
    bufmgr_t *bufmgr;

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

    /** Tracing system */
#if CONFIG_TRACE
    /** SAR Trace */
    trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
#if CONFIG_STATS
    sar_stats_t stats;
#endif
#if CONFIG_SEQ_CHECK
    lib_seq_check_t seq;
#endif
#if CONFIG_SAR_PB_STATS
    sar_pb_stats_t pb_stats;
#endif
};

#endif /*MAC_SAR_INC_CONTEXT_H*/