summaryrefslogtreecommitdiff
path: root/cesar/mac/common/timings.h
blob: 16d48302b476f27949acb3c9b4d1e7fc2eea3570 (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
188
189
190
191
192
193
#ifndef mac_common_timings_h
#define mac_common_timings_h
/* Maria project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/common/timings.h
 * \brief   Homeplug AV timings.
 * \ingroup mac_common
 */

/** Number of ticks per microsecond. */
#define MAC_TCK_PER_US 25

/** Number of ticks per frame length unit. */
#define MAC_TCK_PER_FL 32

/** Convert NTB tick to RTC eCos ticks. */
#define MAC_NTB_TO_RTC(ntb, rtc) ((ntb) / (rtc))
/** Convert seconds to milliseconds. */
#define MAC_SEC_TO_MS(sec) ((sec) * 1000)
/** Convert milliseconds to ticks. */
#define MAC_MS_TO_TCK(ms) ((ms) * MAC_TCK_PER_US * 1000)
/** Convert microseconds to ticks. */
#define MAC_US_TO_TCK(us) ((us) * MAC_TCK_PER_US)
/** Convert ticks to microseconds.
 * \warning truncate to zero. */
#define MAC_TCK_TO_US(tck) ((tck) / MAC_TCK_PER_US)
/** Convert ticks to allocation time unit.
 * \warning returned value rounded up. */
#define MAC_TCK_TO_ATU(tck) CEIL_DIV ((tck), 256)
/** Convert allocation time unit to ticks. */
#define MAC_ATU_TO_TCK(atu) ((atu) * 256)
/** Convert frame length unit to ticks. */
#define MAC_FL_TO_TCK(fl) ((fl) * MAC_TCK_PER_FL)
/** Convert ticks to frame length unit, round up. */
#define MAC_TCK_TO_FL(fl) (((fl) + MAC_TCK_PER_FL - 1) / MAC_TCK_PER_FL)

/** Minimum allocation interframe spacing (us). */
#define MAC_AIFS_MIN_US 30
/** Allocation interframe spacing (us). */
#define MAC_AIFS_US 200
/** Allocation interframe spacing (ticks). */
#define MAC_AIFS_TCK MAC_US_TO_TCK (MAC_AIFS_US)

/** Default AV response interframe spacing (ticks). */
#define MAC_RIFS_DEFAULT_TCK MAC_US_TO_TCK (140)

/** Minimum rifs value in frame length unit that can be used for MPDU transmission
 * with negociated tonemap. (30 us)  */
#define MAC_RIFS_AV_MIN_FL 24

/** Maximum rifs value in frame length unit that can be used for MPDU transmission
 * with negociated tonemap. (160 us)  */
#define MAC_RIFS_AV_MAX_FL 125

/** RIFS value used by our implementation for negotiated tonemap, independent
 * of the number of symbols (fl). */
#define MAC_RIFS_SPC_ANY_FL 109

/** RIFS value used by our implementation for negotiated tonemap, independent
 * of the number of symbols (ticks). */
#define MAC_RIFS_SPC_ANY_TCK MAC_FL_TO_TCK (MAC_RIFS_SPC_ANY_FL)

/** Rifs value in frame length unit that can be used for MPDU transmission
 * with negociated tonemap containing one OFDM symbol. */
#define MAC_RIFS_AV_ONE_SYM_FL MAC_RIFS_SPC_ANY_FL

/** Rifs value in ticks that can be used for MPDU transmission
 * with negociated tonemap containing one OFDM symbol. */
#define MAC_RIFS_AV_ONE_SYM_TCK MAC_FL_TO_TCK (MAC_RIFS_AV_ONE_SYM_FL)

/** Rifs value in frame length unit that can be used for MPDU transmission
 * with negociated tonemap containing two OFDM symbols. */
#define MAC_RIFS_AV_TWO_SYM_FL MAC_RIFS_SPC_ANY_FL

/** Rifs value in ticks that can be used for MPDU transmission
 * with negociated tonemap containing two OFDM symbols. */
#define MAC_RIFS_AV_TWO_SYM_TCK MAC_FL_TO_TCK (MAC_RIFS_AV_TWO_SYM_FL)

/** Rifs value in frame length unit that can be used for MPDU transmission
 * with negociated tonemap containing more than two OFDM symbols. */
#define MAC_RIFS_AV_G2_SYM_FL MAC_RIFS_SPC_ANY_FL

/** Rifs value in ticks that can be used for MPDU transmission
 * with negociated tonemap containing more than two OFDM symbols. */
#define MAC_RIFS_AV_G2_SYM_TCK MAC_FL_TO_TCK (MAC_RIFS_AV_G2_SYM_FL)

/** Homeplug 1.0 response interframe spacing (ticks). */
#define MAC_RIFS_10_TCK (1975 / 3)

/** RTS to CTS gap (ticks). */
#define MAC_RCG_TCK MAC_US_TO_TCK (120)

/** CTS to MPDU gap (ticks). */
#define MAC_CMG_TCK MAC_US_TO_TCK (120)

/** Burst interframe spacing (ticks). */
#define MAC_BIFS_TCK MAC_US_TO_TCK (20)

/** Beacon to beacon interframe spacing (ticks). */
#define MAC_B2BIFS_TCK MAC_US_TO_TCK (90)

/** Extended interframe spacing for hybrid networks (ticks). */
#define MAC_EIFS_10_TCK (127125 / 3)

/** Extended interframe spacing for AV networks (ticks). */
#define MAC_EIFS_AV_TCK (219048 / 3)

/** Contention interframe spacing (ticks). */
#define MAC_CIFS_TCK MAC_US_TO_TCK (100)

/** Contention free interframe spacing minimum value (ticks). */
#define MAC_CFIFS_MIN_TCK MAC_US_TO_TCK (30)

/** Contention free interframe spacing maximum value (ticks). */
#define MAC_CFIFS_MAX_TCK MAC_US_TO_TCK (140)

/** Minimum value of maximum frame length (fl). */
#define MAC_MAX_FL_MIN_FL 0x7a2

/** Maximum value of maximum frame length (fl). */
#define MAC_MAX_FL_MAX_FL 0xfff

/** PRP shift to enhance preamble detection (ticks). */
#define MAC_PRP_SHIFT_TCK 64

/** Preamble (ticks). */
#define MAC_PREAMBLE_TCK (3840/3)

/** Hybrid preamble (ticks). */
#define MAC_PREAMBLE_HYBRID_TCK (3456/3)

/** Homeplug 1.0 Frame Control (ticks). */
#define MAC_FC_10_TCK (2892/3)

/** Homeplug AV Frame Control (ticks). */
#define MAC_FC_AV_TCK (4446/3)

/** Symbol with a 417 sample guard length (ticks). */
#define MAC_DX417_TCK (3489/3)

/** Symbol with a 567 sample guard length (ticks). */
#define MAC_DX567_TCK (3639/3)

/** Symbol with a 3534 sample guard length (ticks). */
#define MAC_DX3534_TCK (6606/3)

/** Payload length for a given symbol size and number of symbols (ticks).
 * The first two symbols are always MAC_DX567_TCK long. */
#define MAC_PAYLOAD_TCK(symb_nb, dx) \
    ((symb_nb) < 2 \
     ? (symb_nb) * MAC_DX567_TCK \
     : 2 * MAC_DX567_TCK + ((symb_nb) - 2) * (dx))

/** Contention window slot, PRS (ticks). */
#define MAC_SLOT_TCK (2688/3)

/** Tolerance for IFS (ticks), includes:
 *  - Homeplug tolerance,
 *  - hardware preamble date precision,
 *  - extra tolerance for long cables. */
#define MAC_TOLERANCE_TCK ((37 + 2 * 384 + (3 - 1)) / 3 + MAC_US_TO_TCK (16))

/** Tonemap tolerance (ticks). */
#define MAC_TM_TOLERANCE_TCK MAC_US_TO_TCK (150)

/** HP 1.0 preamble synchronisation position difference.  AV hybrid preamble
 * is longer than the 1.0 preamble, there is extra symbols in front of
 * preamble.  This delta is needed because synchronisation is done on the
 * SYNCP/SYNCM transition. */
#define MAC_HP10_PREAMBLE_DELTA_TCK ((384 / 2 + 384) / 3)

/** HP 1.0 symbol (ticks). */
#define MAC_HP10_SYMBOL_TCK (420 / 2)

/** HP 1.0 delimiter (ticks). */
#define MAC_HP10_DELIMITER_TCK ((7 * 256 + 124) / 2 + 4 * MAC_HP10_SYMBOL_TCK)

/** HP 1.0 EOF gap (ticks). */
#define MAC_HP10_EFG_TCK 37

/** HP 1.0 CIFS (ticks). */
#define MAC_HP10_CIFS_TCK 896

/** HP 1.0 RIFS (ticks). */
#define MAC_HP10_RIFS_TCK 650

#endif /* mac_common_timings_h */