#ifndef mac_ca_inc_context_h #define mac_ca_inc_context_h /* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \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 */