#ifndef MAC_SAR_SAR_H_ #define MAC_SAR_SAR_H_ /* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file mac/sar/sar.h * \brief Public intefaces of the SAR. * \ingroup mac_sar * */ #include "mac/common/store.h" #include "mac/pbproc/pbproc.h" #include "bufmgr/bufmgr.h" /* forward declaration */ typedef struct sar_t sar_t; /** * Call back prototype to provide measure to the CE. * \param data the context of the CE RX. * \param rx_params general information on measures (date, from). * \param total_pb_count number of PB available in the frame. * \param chan_data the head of the channel data. * \param chan_data_count the count of PBs in the channel data. * \param false_pb_count number of false PBs (CRC error) inside the frame. * \param ber_sum sum of each BER of each PBs with no CRC error inside the * frame */ typedef void (*sar_measurement_cb_t) (void *data, pbproc_rx_params_t *rx_params, uint total_pb_count, pb_t *chan_data, uint chan_data_count, u8 false_pb_count, u32 ber_sum); /** * Provide a new frame to the upper layer. * \param user_data the data store by the init callback * \param buffer the buffer containing the new frame. * \param length the message length in the buffer. * \param mfs the MFS used to reassembly. * \param encrypted encryption information on the medium. */ typedef void (*sar_reassembly_cb_t) ( void *user, u8* buffer, uint length, mfs_rx_t *mfs, bool encrypted); /** * Provides the beacon to the Control Plane * * \param user user data * \param beacon the beacon data * \param params the rx params at the pb reception */ typedef void (*sar_beacon_cb_t) (void *user, pb_beacon_t *pb, pbproc_rx_beacon_params_t *params); BEGIN_DECLS /** * Initialize the SAR context. * \param mac_store the mac store * \param pbproc the PBProc context. * \param ca the Channel Access context. * \param bufmgr the buffer manager context. * \return the SAR context. */ sar_t * sar_init (mac_store_t *mac_store, pbproc_t *pbproc, ca_t *ca, bufmgr_t *bufmgr, u32 seed); /** * Release all the data used in the sar. * \param ctx the sar context. */ void sar_uninit (sar_t *ctx); /** * Initialize the callback to send the measurement contained in the PBs. * \param ctx the SAR context * \param sar_measurement the function to call. * \param user_data a user data provided with the callback. */ void sar_init_measurement_cb (sar_t *ctx, sar_measurement_cb_t sar_measurement, void *user_data); /** * Initialise the SAR to call the function on each new frame available. * \param ctx the SAR context * \param data_cb callback for DATA. * \param mme_cb callback for MME. * \param user_data a user data provided with the callbacks. */ void sar_init_reassembly_callbacks ( sar_t *ctx, sar_reassembly_cb_t data_cb, sar_reassembly_cb_t mme_cb, void *user_data); /** * Add a Mac Frame to send over the medium. * \param ctx sar context * \param buffer the buffer containing the Mac Frame. * \param length the length of the Mac Frame. * \param mfs the MFS to stock the PB generated * \param arrival_time_ntb the arrival time of the MSDU in the station. */ void sar_msdu_process (sar_t *ctx, u8 *buffer, u16 length, mfs_tx_t *mfs, u32 arrival_time_ntb); /** * Add an MFS to the SAR expiration mechanism. * \param ctx the SAR context * \param mfs the MFS to add to the SAR. * * Always called in DSR context. */ void sar_mfs_add (sar_t *ctx, mfs_t *mfs); /** * Put the MFS in the release state. * \param ctx the SAR context * \param mfs the MFS to remove from the SAR. */ void sar_mfs_remove (sar_t *ctx, mfs_t *mfs); /** * Initialise the SAR to call the function on beacon reception. * \param ctx the SAR context * \param user_data * \param uf_upper_layer function to call */ void sar_init_beacon_cb (sar_t *sar, void *user_data, sar_beacon_cb_t uf); /** * Request the SAR to send a beacon. * \param ctx the SAR context. * \param beacon the beacon to send. * \param beacon_mfs the MFS use to send the beacon * \param bto_bpsto the address to provide to the pbproc. */ void sar_beacon_send (sar_t *sar, pb_beacon_t *beacon, mfs_tx_t *beacon_mfs, void *bto_bpsto); /** * Remove a station from the SAR and the mac store. * \param ctx the ctx context. * \param tei the station TEI. * * Remove all the MFS from the expiration mechanism of the SAR and ends to * remove the station from the mac store. */ void sar_sta_remove (sar_t *ctx, u8 tei); /** * SAR Activate. * \param ctx the SAR context. * \param activate true to activate, false to disable. */ void sar_activate (sar_t *ctx, bool activate); /** * SAR clean up all the MFS in the store and the SAR. * \param ctx the SAR context. */ void sar_cleanup (sar_t *ctx); /** * Process the command present in the MFS. * \param ctx the SAR context. * \param mfs the MFS to process. */ void sar_mfs_cmd (sar_t *ctx, mfs_tx_t *mfs); /** * Remove the MFS from Datapath layers. * \param ctx the context. * \param mfs the MFS. * * It removes the MFS from the CA. * Request the PBProc to release all the PBs. * Remove the MFS from the expiration mechanism. * Remove the MFS from the STORE. * * \warn the user reference must be released by the user. * This function should be always called with DSR locked. */ void sar_mfs_free_tx (sar_t *ctx, mfs_tx_t *mfs); /** * Remove the MFS from the datapath layers. * \param ctx the context. * \param mfs the MFS RX to remove. * * Remove the MFS from the expiration mechanism. * Remove the MFS from the STORE. * * \warn the user reference must be released by the user. * This function should be always called with DSR locked. */ void sar_mfs_free_rx (sar_t *ctx, mfs_rx_t *mfs); /** * Callback which activate the pb_stats module * \param state Value found in internal.conf file. */ void sar_pb_stats_load_write_cb (u64 state); /** * Callback which indicate if the module is activated * \return state if not zero then the module is loaded */ u8* sar_pb_stats_load_read_cb (void); END_DECLS #endif /*MAC_SAR_SAR_H_*/