summaryrefslogtreecommitdiff
path: root/cesar/mac/pbproc/inc/context.h
blob: 28eb86c8b9474540f0b18c6d96d0e69b80841896 (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
#ifndef mac_pbproc_inc_context_h
#define mac_pbproc_inc_context_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/pbproc/inc/context.h
 * \brief   PB Processing context.
 * \ingroup mac_pbproc
 */
#include "mac/pbproc/pbproc.h"
#include "mac/ca/ca.h"
#include "hal/phy/phy.h"

#include "mac/pbproc/inc/fsm.h"
#include "mac/pbproc/inc/prep_mpdu.h"
#include "mac/pbproc/inc/trace.h"
#include "mac/pbproc/inc/sacki_enc.h"

#include "mac/common/timings.h"

/** General anticipation for whole PBProc. */
#define PBPROC_ANTICIP_TCK MAC_US_TO_TCK (60)

/** If the total number of PB exceed this threshold, request an interrupt
 * before the end of frame reception to compute SACKD. */
#define PBPROC_SACKD_ANTICIP_PB_THRESHOLD 30

/** Number of PB before frame end for first step of SACKD computation (there
 * can be only one PB in the last symbol, and at most three PB in the symbol
 * before. */
#define PBPROC_SACKD_ANTICIP_PB_NB 4

/** Information on the received MPDU. */
struct pbproc_recv_mpdu_t
{
    /** RX parameters. */
    pbproc_rx_params_t rx_params;
    /** RX parameters for beacons, located inside PB. */
    pbproc_rx_beacon_params_t *rx_beacon_params;
    /** Number of PB. */
    uint pb_nb;
    /** Acknowledgement TX date. */
    u32 ack_date;
    /** Prepared SACKI. */
    pbproc_sacki_enc_t sacki_enc;
};
typedef struct pbproc_recv_mpdu_t pbproc_recv_mpdu_t;

/** Precomputed times. */
struct pbproc_times_t
{
    /** EIFS in ticks. */
    uint eifs_tck;
    /** Preamble + frame controls in ticks. */
    uint pre_fcs_tck;
    /** SACK in ticks. */
    uint sack_tck;
    /** RTS + RCG in ticks. */
    uint rts_rcg_tck;
    /** RTS + RCG + CTS + CMG in ticks. */
    uint rts_rcg_cts_cmg_tck;
    /** Maximum frame length in ticks. */
    uint max_fl_tck;
};
typedef struct pbproc_times_t pbproc_times_t;

/** PB Processing statistics. */
struct pbproc_stat_t
{
    /** No CTS response. */
    uint rts_fail;
    /** Badly constructed CTS response. */
    uint rts_bad_cts;
    /** Lost contention in PRP. */
    uint prp_lost;
    /** Lost contention in CW. */
    uint cw_lost;
    /** Data transmission failed. */
    uint data_fail;
};
typedef struct pbproc_stat_t pbproc_stat_t;

/** The mighty PB Processing context. */
struct pbproc_t
{
    /** The PB Processing FSM. */
    pbproc_fsm_t fsm;
    /** Global configuration. */
    mac_config_t *config;
    /** MAC STA & MFS store. */
    mac_store_t *store;
    /** Phy context. */
    phy_t *phy;
    /** Channel access context. */
    ca_t *ca;
#if CONFIG_TRACE
    /** PBProc trace. */
    trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
    /** User data passed to any callback. */
    void *user_data;
    /** MPDU RX callback. */
    pbproc_rx_cb_t rx_cb;
    /** Beacon RX callback. */
    pbproc_rx_beacon_cb_t rx_beacon_cb;
    /** Received MPDU. */
    pbproc_recv_mpdu_t recv_mpdu;
    /** Obtained access. */
    ca_access_param_t access;
    /** PBDMA status. */
    phy_pbdma_status_t pbdma_status;
    /** Prepared MPDU. */
    pbproc_prep_mpdu_t prep_mpdu;
    /** Current allocation characteristics. */
    ca_access_alloc_param_t alloc;
    /** Precomputed times, indexed with "is hybrid?". */
    pbproc_times_t times[2];
    /** Symbol length in ticks, depends of the guard length. */
    uint symbol_tck[PHY_GIL_NB];
    /** Statistics. */
    pbproc_stat_t stats;
    /** RX PB pool head. */
    pb_t *rx_pool_head;
    /** RX PB pool tail. */
    pb_t *rx_pool_tail;
    /** RX PB pool size. */
    uint rx_pool_size;
};
/* Forward declaration in mac/pbproc/pbproc.h. */

#endif /* mac_pbproc_inc_context_h */