summaryrefslogtreecommitdiff
path: root/mac/ca/inc/context.h
blob: 44f7b0de1a925ca36c9d1a870189871bad9aa68a (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
#ifndef mac_ca_inc_context_h
#define mac_ca_inc_context_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/ca/inc/context.h
 * \brief   Channel Access private context.
 * \ingroup mac_ca
 */

#include "mac/ca/ca.h"
#include "mac/common/mfs.h"

#include "mac/ca/inc/backoff.h"
#include "mac/ca/inc/trace.h"

/** Channel Access state. */
enum ca_state_t
{
    /** Still not activated, no access will be programmed. */
    CA_STATE_IDLE,
    /** Activated, but access programming is held until explicitly
     * requested. */
    CA_STATE_HOLD,
    /** Activated, but no access programmed. */
    CA_STATE_ACTIVATED,
    /** TODO: more to come. */
};
typedef enum ca_state_t ca_state_t;

/** Channel Access context. */
struct ca_t
{
    /** Current state. */
    ca_state_t state;
    /** Phy context. */
    phy_t *phy;
    /** Global configuration. */
    mac_config_t *config;
    /** MAC STA & MFS store. */
    mac_store_t *store;
#if CONFIG_TRACE
    /** CA trace. */
    trace_buffer_t trace;
#endif /* !CONFIG_TRACE */
    /** Next ACCESS event parameters. */
    ca_access_param_t access_param;
    /** Start date of the current VCS. */
    u32 vcs_start_date;
    /** Length of the current VCS. */
    uint vcs_length_tck;
    /** Is current VCS a EIFS. */
    bool vcs_eifs;
    /** Programmed anticipation, may be needed if the timer must be
     * reprogrammed. */
    uint anticipation_tck;
    /** Backoff context. */
    ca_backoff_t backoff;
    /** Beacon period circular buffer head and tail. */
    uint beacon_periods_head, beacon_periods_tail;
    /** Beacon period circular buffer. */
    ca_beacon_period_t beacon_periods[CA_BEACON_PERIOD_NB];
    /** Schedules table. */
    ca_schedule_t schedules[CA_SCHEDULE_NB];
    /** Current beacon period index in buffer, or tail if not set. */
    uint current_beacon_period;
    /** Current allocation index in current schedule. */
    uint current_allocation_index;
    /** Current allocation parameters. */
    ca_access_alloc_param_t current_allocation_param;
    /** Priority sorted MFS heap. */
    heap_t mfs_heap;
    /** List of MFS held until the next beacon period. */
    list_t held;
};
/* Forward declaration in mac/ca/ca.h. */

#endif /* mac_ca_inc_context_h */