#ifndef bsu_inc_context_h #define bsu_inc_context_h /* Cesar project {{{ * * Copyright (C) 2010 Spidcom * * <<>> * * }}} */ /** * \file bsu/inc/context.h * \brief BSU context. * \ingroup bsu */ #include "common/defs/homeplugAV.h" #include "bsu/bsu.h" #include "bsu/ntb/ntb_sync.h" #include "bsu/beacon/beacon.h" #include "bsu/inc/trace.h" #include "lib/stats.h" /** Number of foreign AVLNs handled. */ #define BSU_FOREIGN_AVLNS_NB (HPAV_AVLNS_NB_MAX - 1) /** Index of processed data used by the merge schedule process. */ struct bsu_avln_schedules_process_t { /** Persistent schedules to use. */ bsu_beacon_bmi_persistent_schedule_desc_t *ps; /** Persistent schedules allocation index. */ uint ps_alloc_index; /** Non persistent schedules allocation index. */ uint nps_alloc_index; }; typedef struct bsu_avln_schedules_process_t bsu_avln_schedules_process_t; /** Statistics. */ struct bsu_stats_t { /** Current NTB offset tck. */ u32 ntb_offset_tck; /** Current frequency error in q30. */ uint frequency_error_q30; /** Number of beacon received from a neighbor network. */ uint neighbor_beacon_nb; /** Last MAC received from a neighbor network. */ mac_t neighbor_beacon_last_mac; }; typedef struct bsu_stats_t bsu_stats_t; /** BSU AVLN data. */ struct bsu_avln_t { /** The beacon received. */ bsu_beacon_t beacon; /** NTB synchronisation data. */ bsu_ntb_sync_t sync; /** BTOs. */ s16 bto [HPAV_BEACON_BTO_NB]; /** SNID. */ u8 snid; /** CCo's Mac address. */ mac_t cco_mac_address; }; struct bsu_t { /** Mac config. */ mac_config_t *mac_config; /** Mac Store. */ mac_store_t *mac_store; /** Channel access context. */ ca_t *ca; /** SAR context. */ sar_t *sar; /** Phy context. */ phy_t *phy; /** Upper layer user data.*/ void *ul_data; /** Call back to provide the beacon to the upper layer. */ bsu_beacon_processed_t ul_cb; /** ACLF context. */ bsu_aclf_t *aclf; /** PBProc context. */ pbproc_t *pbproc; /** Station's AVLN. */ bsu_avln_t *sta_avln; /** Others AVLN's data. */ bsu_avln_t avlns[HPAV_AVLNS_NB_MAX]; /** Number of others AVLN NTB. */ uint avlns_nb; /** Special power on AVLN data. */ bsu_avln_t poweron; /** NID to track. */ u64 nid_track; /** SNID to track. */ u8 snid_track; /** TEI to track. */ u8 tei_track; /** Mac address of the CCo the station tracks. * Zero if the CCo does not provide the mac address in the central beacon. */ mac_t cco_mac_address_track; /** Track a new AVLN. */ bool track_new; /** Channel access schedules in use. */ uint ca_schedules_in_use[BSU_BEACON_SCHEDULES_NB]; /** Is station */ bsu_update_sta_type_t is_sta; /** HAL timer context. */ hal_timer_t *hal_timer; /** HAL timer instance. */ hal_timer_instance_t timer; /** Activated status. */ bool activate; /** Beacons MFS. */ mfs_tx_t *mfs_beacons[BSU_BEACON_TYPE_NB]; /** Statistics sent beacons. */ u32 beacon_nb_sent[BSU_BEACON_TYPE_NB]; /** Statistics received beacons. */ u32 beacon_nb_recv[BSU_BEACON_TYPE_NB]; /** NEK switch. */ uint nek_switch; /** Station's discover info updated by CP. */ bsu_beacon_bmi_discover_info_t discover_info; /** NTB clock synchronization weight configuration. k is for 1/2^k. */ uint ntb_clk_sync_weight_k; /** Number of NTB clock synchronizations for stable error measure. */ uint ntb_clk_sync_nb_stable; #if CONFIG_TRACE /** Trace system. */ trace_buffer_t trace; #endif /* !CONFIG_TRACE */ /** Statistics. */ bsu_stats_t stats; }; #endif /* bsu_inc_context_h */