summaryrefslogtreecommitdiff
path: root/cesar/mac/pbproc/inc
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/mac/pbproc/inc
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/mac/pbproc/inc')
-rw-r--r--cesar/mac/pbproc/inc/context.h136
-rw-r--r--cesar/mac/pbproc/inc/fc.h439
-rw-r--r--cesar/mac/pbproc/inc/fsm.h158
-rw-r--r--cesar/mac/pbproc/inc/fsm_handle_fc.h36
-rw-r--r--cesar/mac/pbproc/inc/fsm_rx_beacon.h44
-rw-r--r--cesar/mac/pbproc/inc/fsm_rx_data.h67
-rw-r--r--cesar/mac/pbproc/inc/fsm_top.h44
-rw-r--r--cesar/mac/pbproc/inc/fsm_tx_data.h89
-rw-r--r--cesar/mac/pbproc/inc/fsm_tx_rts_cts.h51
-rw-r--r--cesar/mac/pbproc/inc/mfs.h31
-rw-r--r--cesar/mac/pbproc/inc/prep_mpdu.h166
-rw-r--r--cesar/mac/pbproc/inc/sacki_dec.h41
-rw-r--r--cesar/mac/pbproc/inc/sacki_enc.h57
-rw-r--r--cesar/mac/pbproc/inc/trace.h71
14 files changed, 1430 insertions, 0 deletions
diff --git a/cesar/mac/pbproc/inc/context.h b/cesar/mac/pbproc/inc/context.h
new file mode 100644
index 0000000000..28eb86c8b9
--- /dev/null
+++ b/cesar/mac/pbproc/inc/context.h
@@ -0,0 +1,136 @@
+#ifndef mac_pbproc_inc_context_h
+#define mac_pbproc_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/context.h
+ * \brief PB Processing context.
+ * \ingroup mac_pbproc
+ */
+#include "mac/pbproc/pbproc.h"
+#include "mac/ca/ca.h"
+#include "hal/phy/phy.h"
+
+#include "mac/pbproc/inc/fsm.h"
+#include "mac/pbproc/inc/prep_mpdu.h"
+#include "mac/pbproc/inc/trace.h"
+#include "mac/pbproc/inc/sacki_enc.h"
+
+#include "mac/common/timings.h"
+
+/** General anticipation for whole PBProc. */
+#define PBPROC_ANTICIP_TCK MAC_US_TO_TCK (60)
+
+/** If the total number of PB exceed this threshold, request an interrupt
+ * before the end of frame reception to compute SACKD. */
+#define PBPROC_SACKD_ANTICIP_PB_THRESHOLD 30
+
+/** Number of PB before frame end for first step of SACKD computation (there
+ * can be only one PB in the last symbol, and at most three PB in the symbol
+ * before. */
+#define PBPROC_SACKD_ANTICIP_PB_NB 4
+
+/** Information on the received MPDU. */
+struct pbproc_recv_mpdu_t
+{
+ /** RX parameters. */
+ pbproc_rx_params_t rx_params;
+ /** RX parameters for beacons, located inside PB. */
+ pbproc_rx_beacon_params_t *rx_beacon_params;
+ /** Number of PB. */
+ uint pb_nb;
+ /** Acknowledgement TX date. */
+ u32 ack_date;
+ /** Prepared SACKI. */
+ pbproc_sacki_enc_t sacki_enc;
+};
+typedef struct pbproc_recv_mpdu_t pbproc_recv_mpdu_t;
+
+/** Precomputed times. */
+struct pbproc_times_t
+{
+ /** EIFS in ticks. */
+ uint eifs_tck;
+ /** Preamble + frame controls in ticks. */
+ uint pre_fcs_tck;
+ /** SACK in ticks. */
+ uint sack_tck;
+ /** RTS + RCG in ticks. */
+ uint rts_rcg_tck;
+ /** RTS + RCG + CTS + CMG in ticks. */
+ uint rts_rcg_cts_cmg_tck;
+ /** Maximum frame length in ticks. */
+ uint max_fl_tck;
+};
+typedef struct pbproc_times_t pbproc_times_t;
+
+/** PB Processing statistics. */
+struct pbproc_stat_t
+{
+ /** No CTS response. */
+ uint rts_fail;
+ /** Badly constructed CTS response. */
+ uint rts_bad_cts;
+ /** Lost contention in PRP. */
+ uint prp_lost;
+ /** Lost contention in CW. */
+ uint cw_lost;
+ /** Data transmission failed. */
+ uint data_fail;
+};
+typedef struct pbproc_stat_t pbproc_stat_t;
+
+/** The mighty PB Processing context. */
+struct pbproc_t
+{
+ /** The PB Processing FSM. */
+ pbproc_fsm_t fsm;
+ /** Global configuration. */
+ mac_config_t *config;
+ /** MAC STA & MFS store. */
+ mac_store_t *store;
+ /** Phy context. */
+ phy_t *phy;
+ /** Channel access context. */
+ ca_t *ca;
+#if CONFIG_TRACE
+ /** PBProc trace. */
+ trace_buffer_t trace;
+#endif /* !CONFIG_TRACE */
+ /** User data passed to any callback. */
+ void *user_data;
+ /** MPDU RX callback. */
+ pbproc_rx_cb_t rx_cb;
+ /** Beacon RX callback. */
+ pbproc_rx_beacon_cb_t rx_beacon_cb;
+ /** Received MPDU. */
+ pbproc_recv_mpdu_t recv_mpdu;
+ /** Obtained access. */
+ ca_access_param_t access;
+ /** PBDMA status. */
+ phy_pbdma_status_t pbdma_status;
+ /** Prepared MPDU. */
+ pbproc_prep_mpdu_t prep_mpdu;
+ /** Current allocation characteristics. */
+ ca_access_alloc_param_t alloc;
+ /** Precomputed times, indexed with "is hybrid?". */
+ pbproc_times_t times[2];
+ /** Symbol length in ticks, depends of the guard length. */
+ uint symbol_tck[PHY_GIL_NB];
+ /** Statistics. */
+ pbproc_stat_t stats;
+ /** RX PB pool head. */
+ pb_t *rx_pool_head;
+ /** RX PB pool tail. */
+ pb_t *rx_pool_tail;
+ /** RX PB pool size. */
+ uint rx_pool_size;
+};
+/* Forward declaration in mac/pbproc/pbproc.h. */
+
+#endif /* mac_pbproc_inc_context_h */
diff --git a/cesar/mac/pbproc/inc/fc.h b/cesar/mac/pbproc/inc/fc.h
new file mode 100644
index 0000000000..76f551686b
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fc.h
@@ -0,0 +1,439 @@
+#ifndef mac_pbproc_inc_fc_h
+#define mac_pbproc_inc_fc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fc.h
+ * \brief Frame control structure.
+ * \ingroup mac_pbproc
+ *
+ * Be careful to bit order.
+ */
+
+/** Delimiter type. */
+enum pbproc_fc_dt_t
+{
+ PBPROC_FC_DT_BEACON,
+ PBPROC_FC_DT_SOF,
+ PBPROC_FC_DT_SACK,
+ PBPROC_FC_DT_RTS_CTS,
+ PBPROC_FC_DT_SOUND,
+ PBPROC_FC_DT_RSOF,
+ PBPROC_FC_DT_NB,
+ PBPROC_FC_DT_MASK = 0x7
+};
+typedef enum pbproc_fc_dt_t pbproc_fc_dt_t;
+
+/** MFS FSM commands. */
+enum pbproc_fc_mfs_cmd_t
+{
+ PBPROC_FC_MFS_CMD_INIT,
+ PBPROC_FC_MFS_CMD_IN_SYNC,
+ PBPROC_FC_MFS_CMD_RE_SYNC,
+ PBPROC_FC_MFS_CMD_RELEASE,
+ PBPROC_FC_MFS_CMD_NOP,
+};
+typedef enum pbproc_fc_mfs_cmd_t pbproc_fc_mfs_cmd_t;
+
+/** MFS FSM response. */
+enum pbproc_fc_mfs_rsp_t
+{
+ PBPROC_FC_MFS_RSP_ACK,
+ PBPROC_FC_MFS_RSP_NACK,
+ PBPROC_FC_MFS_RSP_FAIL,
+ PBPROC_FC_MFS_RSP_HOLD,
+};
+typedef enum pbproc_fc_mfs_rsp_t pbproc_fc_mfs_rsp_t;
+
+/** Generic frame control. */
+struct pbproc_fc_generic_t
+{
+ BITFIELDS_WORD(
+ /** Delimiter type. */
+ pbproc_fc_dt_t dt_av:3;,
+ /** Access field. */
+ bool access:1;,
+ /** Short network identifier. */
+ uint snid:4;,
+ uint :24;)
+ uint :32;
+ uint :32;
+ BITFIELDS_WORD(
+ uint :8;,
+ /** FCCS. */
+ uint fccs_av:24;)
+};
+typedef struct pbproc_fc_generic_t pbproc_fc_generic_t;
+
+/** Beacon frame control. */
+struct pbproc_fc_beacon_t
+{
+ BITFIELDS_WORD(
+ /** Delimiter type. */
+ pbproc_fc_dt_t dt_av:3;,
+ /** Access field. */
+ bool access:1;,
+ /** Short network identifier. */
+ uint snid:4;,
+ /** Beacon time stamp, LSB. */
+ uint bts_lsb24:24;)
+ BITFIELDS_WORD(
+ /** Beacon time stamp, MSB. */
+ uint bts_msb8:8;,
+ /** Beacon transmission offset 0. */
+ uint bto0:16;,
+ /** Beacon transmission offset 1, LSB. */
+ uint bto1_lsb8:8;)
+ BITFIELDS_WORD(
+ /** Beacon transmission offset 1, MSB. */
+ uint bto1_msb8:8;,
+ /** Beacon transmission offset 2. */
+ uint bto2:16;,
+ /** Beacon transmission offset 3, LSB. */
+ uint bto3_lsb8:8;)
+ BITFIELDS_WORD(
+ /** Beacon transmission offset 3, MSB. */
+ uint bto3_msb8:8;,
+ /** FCCS. */
+ uint fccs_av:24;)
+};
+typedef struct pbproc_fc_beacon_t pbproc_fc_beacon_t;
+
+/** Start Of Frame frame control. */
+struct pbproc_fc_sof_t
+{
+ BITFIELDS_WORD(
+ /** Delimiter type. */
+ pbproc_fc_dt_t dt_av:3;,
+ /** Access field. */
+ bool access:1;,
+ /** Short network identifier. */
+ uint snid:4;,
+ /** Source terminal equipment identifier. */
+ uint stei:8;,
+ /** Destination terminal equipment identifier. */
+ uint dtei:8;,
+ /** Link identifier. */
+ uint lid:8;)
+ BITFIELDS_WORD(
+ /** Contention free session. */
+ bool cfs:1;,
+ /** Beacon detect flag. */
+ bool bdf:1;,
+ /** Homeplug 1.0.1 detect flag. */
+ bool hp10df:1;,
+ /** Homeplug 1.1 detect flag. */
+ bool hp11df:1;,
+ /** Encryption key select. */
+ uint eks:4;,
+ /** Pending PB. */
+ uint ppb:8;,
+ /** Bit loading estimate. */
+ uint ble:8;,
+ /** PB size, true for 136. */
+ bool pbsz:1;,
+ /** Number of symbols. */
+ uint num_sym:2;,
+ /** Tone map index. */
+ uint tmi_av:5;)
+ BITFIELDS_WORD(
+ /** Frame length. */
+ uint fl_av:12;,
+ /** MPDU count. */
+ uint mpdu_cnt:2;,
+ /** Burst count. */
+ uint burst_cnt:2;,
+ /** Bidirectional burst flag. */
+ bool bbf:1;,
+ /** Max reverse transmission frame length. */
+ uint mrtfl:4;,
+ /** Different CP PHY clock flag. */
+ bool dcppcf:1;,
+ /** Multicast flag. */
+ bool mcf:1;,
+ /** Multi-network broadcast flag. */
+ bool mnbf:1;,
+ /** Request SACK retransmission. */
+ bool rsr:1;,
+ /** Convergence layer SAP type. */
+ uint clst:1;,
+ /** Management MFS command. */
+ uint mfs_cmd_mgmt:3;,
+ /** Data MFS command. */
+ uint mfs_cmd_data:3;)
+ BITFIELDS_WORD(
+ /** Management MFS response for the preceding RSOF. */
+ uint mfs_rsp_mgmt:2;,
+ /** Data MFS response for the preceding RSOF. */
+ uint mfs_rsp_data:2;,
+ /** Bit map SACK info for the preceding RSOF. */
+ uint bm_sacki:4;,
+ /** FCCS. */
+ uint fccs_av:24;)
+};
+typedef struct pbproc_fc_sof_t pbproc_fc_sof_t;
+
+/** SACK Type. */
+enum pbproc_fc_sackt_t
+{
+ PBPROC_FC_SACKT_MIXED = 0,
+ PBPROC_FC_SACKT_MIXED_COMPRESSED = 1,
+ PBPROC_FC_SACKT_NOT_RECEIVED = 2,
+ PBPROC_FC_SACKT_UNIFORM = 3,
+};
+
+/** Uniform SACK information. */
+enum pbproc_fc_sacki_uniform_t
+{
+ PBPROC_FC_SACKI_UNIFORM_ALL_ERROR = 0,
+ PBPROC_FC_SACKI_UNIFORM_ALL_OK = 1,
+ PBPROC_FC_SACKI_UNIFORM_NOT_AVAILABLE = 2,
+ PBPROC_FC_SACKI_UNIFORM_TMI_DEFAULT_ROBO = 3,
+ PBPROC_FC_SACKI_UNIFORM_TMI_DEFAULT_RESTART = 4,
+ PBPROC_FC_SACKI_UNIFORM_TMI_RESTART = 5,
+ PBPROC_FC_SACKI_UNIFORM_NEK_ERROR = 6,
+ PBPROC_FC_SACKI_UNIFORM_NB
+};
+
+/** Maximum number of bits in a SACK. */
+#define PBPROC_FC_SACK_SACKI_BITS 72
+
+/** Selective Acknowledgment frame control. */
+struct pbproc_fc_sack_t
+{
+ BITFIELDS_WORD(
+ /** Delimiter type. */
+ pbproc_fc_dt_t dt_av:3;,
+ /** Access field. */
+ bool access:1;,
+ /** Short network identifier. */
+ uint snid:4;,
+ /** Destination terminal equipment identifier. */
+ uint dtei:8;,
+ /** Contention free session. */
+ bool cfs:1;,
+ /** Beacon detect flag. */
+ bool bdf:1;,
+ /** SACK version number. */
+ uint svn:1;,
+ /** Request reverse transmission flag. */
+ bool rrtf:1;,
+ /** Data MFS response. */
+ uint mfs_rsp_data:2;,
+ /** Management MFS response. */
+ uint mfs_rsp_mgmt:2;,
+ /** SACK type for MPDU count = 3. */
+ uint sackt3:2;,
+ /** SACK type for MPDU count = 2. */
+ uint sackt2:2;,
+ /** SACK type for MPDU count = 1. */
+ uint sackt1:2;,
+ /** SACK type for MPDU count = 0. */
+ uint sackt0:2;)
+ /** SACK information. */
+ uint sacki[2];
+ BITFIELDS_WORD(
+ /** SACK information last byte and/or RX window size and/or request
+ * reverse transmission length. */
+ uint sacki_last:8;,
+ /** FCCS. */
+ uint fccs_av:24;)
+};
+typedef struct pbproc_fc_sack_t pbproc_fc_sack_t;
+
+/** Request to send/Clear to send frame control. */
+struct pbproc_fc_rts_cts_t
+{
+ BITFIELDS_WORD(
+ /** Delimiter type. */
+ pbproc_fc_dt_t dt_av:3;,
+ /** Access field. */
+ bool access:1;,
+ /** Short network identifier. */
+ uint snid:4;,
+ /** Source terminal equipment identifier. */
+ uint stei:8;,
+ /** Destination terminal equipment identifier. */
+ uint dtei:8;,
+ /** Link identifier. */
+ uint lid:8;)
+ BITFIELDS_WORD(
+ /** Contention free session. */
+ bool cfs:1;,
+ /** Beacon detect flag. */
+ bool bdf:1;,
+ /** Homeplug 1.0.1 detect flag. */
+ bool hp10df:1;,
+ /** Homeplug 1.1 detect flag. */
+ bool hp11df:1;,
+ /** RTS flag. */
+ bool rtsf:1;,
+ /** Immediate grant flag. */
+ bool igf:1;,
+ /** Multi-network broadcast flag. */
+ bool mnbf:1;,
+ /** Multicast flag. */
+ bool mcf:1;,
+ /** Duration. */
+ uint dur:14;,
+ uint :10;)
+ uint :32;
+ BITFIELDS_WORD(
+ uint :8;,
+ /** FCCS. */
+ uint fccs_av:24;)
+};
+typedef struct pbproc_fc_rts_cts_t pbproc_fc_rts_cts_t;
+
+/** Sound reason code. */
+enum pbproc_fc_sound_reason_code_t
+{
+ PBPROC_FC_SRC_TMI_MIN = 0x04,
+ PBPROC_FC_SRC_TMI_MAX = 0x1f,
+ PBPROC_FC_SRC_ERROR = 0xfc,
+ PBPROC_FC_SRC_INITIAL = 0xfd,
+ PBPROC_FC_SRC_INTERVAL_UNAVAILABLE = 0xfe,
+ PBPROC_FC_SRC_INTERVAL_UNUSABLE = 0xff,
+};
+
+/** Sound frame control. */
+struct pbproc_fc_sound_t
+{
+ BITFIELDS_WORD(
+ /** Delimiter type. */
+ pbproc_fc_dt_t dt_av:3;,
+ /** Access field. */
+ bool access:1;,
+ /** Short network identifier. */
+ uint snid:4;,
+ /** Source terminal equipment identifier. */
+ uint stei:8;,
+ /** Destination terminal equipment identifier. */
+ uint dtei:8;,
+ /** Link identifier. */
+ uint lid:8;)
+ BITFIELDS_WORD(
+ /** Contention free session. */
+ bool cfs:1;,
+ /** PB size, true for 136. */
+ bool pbsz:1;,
+ /** Beacon detect flag. */
+ bool bdf:1;,
+ /** Sound ACK flag. */
+ bool saf:1;,
+ /** Sound complete flag. */
+ bool scf:1;,
+ /** Max tone map requested. */
+ uint req_tm:3;,
+ /** Frame length. */
+ uint fl_av:12;,
+ /** MPDU count. */
+ uint mpdu_cnt:2;,
+ uint :2;,
+ /** Pending PB. */
+ uint ppb:8;)
+ BITFIELDS_WORD(
+ /** Sound reason code. */
+ uint src:8;,
+ uint :24;)
+ BITFIELDS_WORD(
+ uint :8;,
+ /** FCCS. */
+ uint fccs_av:24;)
+};
+typedef struct pbproc_fc_sound_t pbproc_fc_sound_t;
+
+/** Reverse SOF frame control. */
+struct pbproc_fc_rsof_t
+{
+ BITFIELDS_WORD(
+ /** Delimiter type. */
+ pbproc_fc_dt_t dt_av:3;,
+ /** Access field. */
+ bool access:1;,
+ /** Short network identifier. */
+ uint snid:4;,
+ /** Destination terminal equipment identifier. */
+ uint dtei:8;,
+ /** Contention free session. */
+ bool cfs:1;,
+ /** Beacon detect flag. */
+ bool bdf:1;,
+ /** SACK version number. */
+ uint svn:1;,
+ /** Request reverse transmission flag. */
+ bool rrtf:1;,
+ /** Data MFS response. */
+ uint mfs_rsp_data:2;,
+ /** Management MFS response. */
+ uint mfs_rsp_mgmt:2;,
+ /** SACK type for MPDU count = 3. */
+ uint sackt3:2;,
+ /** SACK type for MPDU count = 2. */
+ uint sackt2:2;,
+ /** SACK type for MPDU count = 1. */
+ uint sackt1:2;,
+ /** SACK type for MPDU count = 0. */
+ uint sackt0:2;)
+ /** SACK information, LSB. */
+ uint sacki_lsb;
+ BITFIELDS_WORD(
+ /** SACK information, MSB, and/or RX window size and/or request reverse
+ * transmission length. */
+ uint sacki_msb:16;,
+ /** Reverse SOF frame length. */
+ uint rsof_fl_av:10;,
+ /** Tone map index. */
+ uint tmi_av:5;,
+ /** PB size, true for 136. */
+ bool pbsz:1;)
+ BITFIELDS_WORD(
+ /** Number of symbols. */
+ uint num_sym:2;,
+ /** Management MFS command. */
+ uint mfs_cmd_mgmt:3;,
+ /** Data MFS command. */
+ uint mfs_cmd_data:3;,
+ /** FCCS. */
+ uint fccs_av:24;)
+};
+typedef struct pbproc_fc_rsof_t pbproc_fc_rsof_t;
+
+/** Union for any frame control. */
+union pbproc_fc_t
+{
+ /** Direct word access. */
+ uint words[4];
+ /** Generic FC access. */
+ pbproc_fc_generic_t generic;
+ /** Beacon FC access. */
+ pbproc_fc_beacon_t beacon;
+ /** SOF FC access. */
+ pbproc_fc_sof_t sof;
+ /** SACK FC access. */
+ pbproc_fc_sack_t sack;
+ /** RTS/CTS FC access. */
+ pbproc_fc_rts_cts_t rts_cts;
+ /** Sound FC access. */
+ pbproc_fc_sound_t sound;
+ /** RSOF FC access. */
+ pbproc_fc_rsof_t rsof;
+};
+typedef union pbproc_fc_t pbproc_fc_t;
+
+BEGIN_DECLS
+
+/**
+ * Compute the Pending Phy Blocks Frame Control field.
+ * \param n integer number of Pending Phy Blocks
+ * \return floating point coded value
+ */
+u8
+pbproc_fc_pbb (uint n);
+
+#endif /* mac_pbproc_inc_fc_h */
diff --git a/cesar/mac/pbproc/inc/fsm.h b/cesar/mac/pbproc/inc/fsm.h
new file mode 100644
index 0000000000..fccf919c63
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fsm.h
@@ -0,0 +1,158 @@
+#ifndef mac_pbproc_inc_fsm_h
+#define mac_pbproc_inc_fsm_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fsm.h
+ * \brief FSM engine.
+ * \ingroup mac_pbproc
+ *
+ * Finite State Machine engine for the PB Processing.
+ */
+
+#include "mac/pbproc/inc/fc.h"
+
+/** FSM states. */
+enum pbproc_fsm_state_t
+{
+ PBPROC_FSM_STATE_IDLE,
+ PBPROC_FSM_STATE_RX_DATA_WACK,
+ PBPROC_FSM_STATE_RX_DATA_WACK_LAST_PB,
+ PBPROC_FSM_STATE_RX_BURST,
+ PBPROC_FSM_STATE_RX_BEACON,
+ PBPROC_FSM_STATE_TX_WAIT_CTS,
+ PBPROC_FSM_STATE_TX_WAIT_ACCESS_CONF,
+ PBPROC_FSM_STATE_TX_WAIT_SACKD,
+ PBPROC_FSM_STATE_TX_WAIT_TX_END,
+ PBPROC_FSM_STATE_TX_BURST,
+ PBPROC_FSM_STATE_NB
+};
+typedef enum pbproc_fsm_state_t pbproc_fsm_state_t;
+
+/** FSM RX FC event callback. */
+typedef void (*pbproc_fsm_rx_fc_cb_t) (pbproc_t *ctx,
+ u32 rx_date,
+ const pbproc_fc_t *fc_av);
+
+/** FSM ACCESS event callback. */
+typedef void (*pbproc_fsm_access_cb_t) (pbproc_t *ctx);
+
+/** FSM ACCESS CONFIRM event callback. */
+typedef void (*pbproc_fsm_access_conf_cb_t) (pbproc_t *ctx);
+
+/** FSM DSR event callback. */
+typedef void (*pbproc_fsm_deferred_cb_t) (pbproc_t *ctx);
+
+/** FSM state description. */
+struct pbproc_fsm_state_desc_t
+{
+ /** RX FC event callback. */
+ pbproc_fsm_rx_fc_cb_t rx_fc_cb;
+ /** ACCESS event callback. */
+ pbproc_fsm_access_cb_t access_cb;
+ /** ACCESS CONFIRM event callback. */
+ pbproc_fsm_access_conf_cb_t access_conf_cb;
+};
+typedef struct pbproc_fsm_state_desc_t pbproc_fsm_state_desc_t;
+
+/** FSM context. */
+struct pbproc_fsm_t
+{
+ /** Current state. */
+ pbproc_fsm_state_t current_state;
+ /** Table indexed with state. The cells contains the callback to be
+ * called on a transition from a defined state triggered by a defined
+ * event. */
+ pbproc_fsm_state_desc_t states[PBPROC_FSM_STATE_NB];
+ /** Deferred treatment, this function is called during DSR. */
+ pbproc_fsm_deferred_cb_t deferred_cb;
+};
+typedef struct pbproc_fsm_t pbproc_fsm_t;
+
+/**
+ * Initialise FSM.
+ * \param ctx pbproc context
+ */
+void
+pbproc_fsm_init (pbproc_t *ctx);
+
+/**
+ * Handle RX FC event from HAL Phy.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ * \return true if a DSR is requested
+ */
+bool
+pbproc_fsm_handle_rx_fc_event (pbproc_t *ctx, u32 rx_date, const u32 *fc_av);
+
+/**
+ * Handle ACCESS event from HAL Phy.
+ * \param ctx pbproc context
+ * \return true if a DSR is requested
+ */
+bool
+pbproc_fsm_handle_access_event (pbproc_t *ctx);
+
+/**
+ * Handle ACCESS CONFIRM event from HAL Phy.
+ * \param ctx pbproc context
+ * \return true if a DSR is requested
+ */
+bool
+pbproc_fsm_handle_access_conf_event (pbproc_t *ctx);
+
+/**
+ * Handle PBDMA event from HAL Phy.
+ * \param ctx pbproc context
+ * \param status_word status read from PB DMA
+ * \return true if a DSR is requested
+ */
+bool
+pbproc_fsm_handle_pbdma_event (pbproc_t *ctx, u32 status_word);
+
+/**
+ * Handle TX FALSE ALARM event from HAL Phy.
+ * \param ctx pbproc context
+ * \return true if a DSR is requested
+ */
+bool
+pbproc_fsm_handle_tx_false_alarm_event (pbproc_t *ctx);
+
+/**
+ * Handle deferred treatment event from HAL Phy.
+ * \param ctx pbproc context
+ */
+void
+pbproc_fsm_handle_deferred (pbproc_t *ctx);
+
+/**
+ * Change to a new state.
+ * \param ctx pbproc context
+ * \param state the new state
+ */
+void
+pbproc_fsm_change_state (pbproc_t *ctx, pbproc_fsm_state_t state);
+
+/**
+ * Schedule a deferred function call in DSR.
+ * \param ctx pbproc context
+ * \param deferred_cb the deferred call
+ */
+void
+pbproc_fsm_schedule_deferred (pbproc_t *ctx,
+ pbproc_fsm_deferred_cb_t deferred_cb);
+
+/**
+ * Called when a unexpected event is triggered.
+ * \param ctx pbproc context
+ */
+void
+pbproc_fsm_unexpected (pbproc_t *ctx);
+
+#endif /* mac_pbproc_inc_fsm_h */
diff --git a/cesar/mac/pbproc/inc/fsm_handle_fc.h b/cesar/mac/pbproc/inc/fsm_handle_fc.h
new file mode 100644
index 0000000000..960391cd49
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fsm_handle_fc.h
@@ -0,0 +1,36 @@
+#ifndef mac_pbproc_inc_fsm_handle_fc_h
+#define mac_pbproc_inc_fsm_handle_fc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fsm_handle_fc.h
+ * \brief FSM handle FC part.
+ * \ingroup mac_pbproc
+ */
+
+BEGIN_DECLS
+
+/**
+ * Initialise FSM handle FC part.
+ * \param ctx pbproc context
+ */
+void
+pbproc_fhfc_init (pbproc_t *ctx);
+
+/**
+ * Handle a FC and change to the following state.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ */
+void
+pbproc_fhfc_handle_fc (pbproc_t *ctx, u32 rx_date, const pbproc_fc_t *fc_av);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_fsm_handle_fc_h */
diff --git a/cesar/mac/pbproc/inc/fsm_rx_beacon.h b/cesar/mac/pbproc/inc/fsm_rx_beacon.h
new file mode 100644
index 0000000000..ce87a60e3f
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fsm_rx_beacon.h
@@ -0,0 +1,44 @@
+#ifndef mac_pbproc_inc_fsm_rx_beacon_h
+#define mac_pbproc_inc_fsm_rx_beacon_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fsm_rx_beacon.h
+ * \brief FSM RX beacon part.
+ * \ingroup mac_pbproc
+ */
+
+BEGIN_DECLS
+
+/**
+ * Initialise FSM RX beacon part.
+ * \param ctx pbproc context
+ */
+void
+pbproc_frbe_init (pbproc_t *ctx);
+
+/**
+ * Handle a RX beacon, called from handle_fc.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param beacon BEACON FC
+ */
+void
+pbproc_frbe__handle (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_beacon_t *beacon);
+
+/**
+ * RX BEACON =ACCESS (PB)=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_frbe__rx_beacon__access (pbproc_t *ctx);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_fsm_rx_beacon_h */
diff --git a/cesar/mac/pbproc/inc/fsm_rx_data.h b/cesar/mac/pbproc/inc/fsm_rx_data.h
new file mode 100644
index 0000000000..60ed3e5d75
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fsm_rx_data.h
@@ -0,0 +1,67 @@
+#ifndef mac_pbproc_inc_fsm_rx_data_h
+#define mac_pbproc_inc_fsm_rx_data_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fsm_rx_data.h
+ * \brief FSM RX data part.
+ * \ingroup mac_pbproc
+ */
+
+BEGIN_DECLS
+
+/**
+ * Initialise FSM RX data part.
+ * \param ctx pbproc context
+ */
+void
+pbproc_frda_init (pbproc_t *ctx);
+
+/**
+ * Handle a RX data, called from handle_fc.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param sof SOF frame control
+ */
+void
+pbproc_frda__handle (pbproc_t *ctx, u32 rx_date, const pbproc_fc_sof_t *sof);
+
+/**
+ * RX DATA WACK =ACCESS (PB)=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_frda__rx_data_wack__access (pbproc_t *ctx);
+
+/**
+ * RX DATA WACK LAST PB =ACCESS (PB)=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_frda__rx_data_wack_last_pb__access (pbproc_t *ctx);
+
+/**
+ * RX BURST =RX=FC=>.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ */
+void
+pbproc_frda__rx_burst__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av);
+
+/**
+ * RX BURST =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_frda__rx_burst__access (pbproc_t *ctx);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_fsm_rx_data_h */
diff --git a/cesar/mac/pbproc/inc/fsm_top.h b/cesar/mac/pbproc/inc/fsm_top.h
new file mode 100644
index 0000000000..3e52053b43
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fsm_top.h
@@ -0,0 +1,44 @@
+#ifndef mac_pbproc_inc_fsm_top_h
+#define mac_pbproc_inc_fsm_top_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fsm_top.h
+ * \brief FSM top part, handle idle and generic transitions.
+ * \ingroup mac_pbproc
+ */
+
+BEGIN_DECLS
+
+/**
+ * Initialise FSM top part.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftop_init (pbproc_t *ctx);
+
+/**
+ * IDLE =RX=FC=>.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ */
+void
+pbproc_ftop__idle__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av);
+
+/**
+ * IDLE =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftop__idle__access (pbproc_t *ctx);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_fsm_top_h */
diff --git a/cesar/mac/pbproc/inc/fsm_tx_data.h b/cesar/mac/pbproc/inc/fsm_tx_data.h
new file mode 100644
index 0000000000..76930488ba
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fsm_tx_data.h
@@ -0,0 +1,89 @@
+#ifndef mac_pbproc_inc_fsm_tx_data_h
+#define mac_pbproc_inc_fsm_tx_data_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fsm_tx_data.h
+ * \brief FSM TX data part.
+ * \ingroup mac_pbproc
+ */
+
+BEGIN_DECLS
+
+/**
+ * Initialise FSM TX data part.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftda_init (pbproc_t *ctx);
+
+/**
+ * Handle a TX data, called from FSM top.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftda__handle (pbproc_t *ctx);
+
+/**
+ * TX WAIT ACCESS CONF =RX=FC=>.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ */
+void
+pbproc_ftda__tx_wait_access_conf__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av);
+
+/**
+ * TX WAIT ACCESS CONF =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftda__tx_wait_access_conf__access (pbproc_t *ctx);
+
+/**
+ * TX WAIT ACCESS CONF =ACCESS=CONF=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftda__tx_wait_access_conf__access_conf (pbproc_t *ctx);
+
+/**
+ * TX WAIT SACKD =RX=FC=>.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ */
+void
+pbproc_ftda__tx_wait_sackd__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av);
+
+/**
+ * TX WAIT SACKD =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftda__tx_wait_sackd__access (pbproc_t *ctx);
+
+/**
+ * TX WAIT TX END =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftda__tx_wait_tx_end__access (pbproc_t *ctx);
+
+/**
+ * TX BURST =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftda__tx_burst__access (pbproc_t *ctx);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_fsm_tx_data_h */
diff --git a/cesar/mac/pbproc/inc/fsm_tx_rts_cts.h b/cesar/mac/pbproc/inc/fsm_tx_rts_cts.h
new file mode 100644
index 0000000000..f73c888728
--- /dev/null
+++ b/cesar/mac/pbproc/inc/fsm_tx_rts_cts.h
@@ -0,0 +1,51 @@
+#ifndef mac_pbproc_inc_fsm_tx_rts_cts_h
+#define mac_pbproc_inc_fsm_tx_rts_cts_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/fsm_tx_rts_cts.h
+ * \brief FSM TX RTS CTS part.
+ * \ingroup mac_pbproc
+ */
+
+BEGIN_DECLS
+
+/**
+ * Initialise FSM TX RTS CTS part.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftrc_init (pbproc_t *ctx);
+
+/**
+ * Handle a TX RTS CTS, called from FSM top.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftrc__handle (pbproc_t *ctx);
+
+/**
+ * TX WAIT CTS =RX=FC=>.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ */
+void
+pbproc_ftrc__tx_wait_cts__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av);
+
+/**
+ * TX WAIT CTS =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftrc__tx_wait_cts__access (pbproc_t *ctx);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_fsm_tx_rts_cts_h */
diff --git a/cesar/mac/pbproc/inc/mfs.h b/cesar/mac/pbproc/inc/mfs.h
new file mode 100644
index 0000000000..e1d9045bcc
--- /dev/null
+++ b/cesar/mac/pbproc/inc/mfs.h
@@ -0,0 +1,31 @@
+#ifndef mac_pbproc_inc_mfs_h
+#define mac_pbproc_inc_mfs_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/mfs.h
+ * \brief MFS related PB Processing functions.
+ * \ingroup mac_pbproc
+ */
+
+BEGIN_DECLS
+
+/**
+ * Update CAP after a segment removal.
+ * \param mfs mfs from which segments are removed.
+ * \param nb number of segments removed.
+ *
+ * \todo This does not work! It would only works if acknowledged segments
+ * where always the first ones.
+ */
+void
+pbproc_mfs_cap_update (mfs_tx_t *mfs, uint nb);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_mfs_h */
diff --git a/cesar/mac/pbproc/inc/prep_mpdu.h b/cesar/mac/pbproc/inc/prep_mpdu.h
new file mode 100644
index 0000000000..a44b76f393
--- /dev/null
+++ b/cesar/mac/pbproc/inc/prep_mpdu.h
@@ -0,0 +1,166 @@
+#ifndef mac_pbproc_inc_prep_mpdu_h
+#define mac_pbproc_inc_prep_mpdu_h
+/* Maria project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/prep_mpdu.h
+ * \brief Prepare MPDU complex function.
+ * \ingroup mac_pbproc
+ */
+#include "mac/pbproc/pbproc.h"
+#include "mac/pbproc/inc/fc.h"
+
+/** Information about the prepared MPDU. Only contains information for one
+ * SOF frame, not a complete burst. */
+struct pbproc_prep_mpdu_t
+{
+ /** Destination TEI. */
+ u8 dtei;
+ /** Link identifier. */
+ u8 lid;
+ /** Is there a prepared frame. */
+ bool valid;
+ /** With acknowledgement (unicast or multicast partial
+ * acknowledgement). */
+ bool wack;
+ /** Use RTS/CTS. */
+ bool rts_cts;
+ /** Is a burst, TODO: this may become a MPDU count. */
+ bool burst;
+ /** RTS TX date of start of preamble. */
+ u32 rts_tx_date;
+ /** RTS frame control. */
+ pbproc_fc_t rts_fc_av;
+ /** RTS frame control 1.0. */
+ u32 rts_fc_10;
+ /** Frame control mode. */
+ phy_fc_mode_t fc_mode;
+ /** Modulation type. */
+ phy_mod_t mod;
+ /** TCC rate. */
+ phy_fecrate_t fecrate;
+ /** PB size. */
+ phy_pb_size_t pb_size;
+ /** Guard interval. */
+ phy_gil_t gil;
+ /** Tonemap. */
+ blk_t *tonemap;
+ /** SOF TX date of start of preamble. */
+ u32 tx_date;
+ /** SOF frame control. */
+ pbproc_fc_t fc_av;
+ /** SOF frame control 1.0. */
+ u32 fc_10;
+ /** Frame length with preamble (including IFS). */
+ uint flp_tck;
+ /** Used main MFS. */
+ mfs_tx_t *main_mfs;
+ /** Main MFS first segment. */
+ pb_t *main_head;
+ /** Main MFS last segment. */
+ pb_t *main_tail;
+ /** Number of main MFS segment. */
+ uint main_seg_nb;
+ /** Number of reserved main MFS segment from MFS still to be queued. */
+ uint main_seg_nb_reserved;
+ /** Used combined MFS. */
+ mfs_tx_t *combined_mfs;
+ /** Combined MFS first segment. */
+ pb_t *combined_head;
+ /** Combined MFS last segment. */
+ pb_t *combined_tail;
+ /** Number of combined MFS segment. */
+ uint combined_seg_nb;
+ /** Number of reserved combined MFS segment from MFS still to be
+ * queued. */
+ uint combined_seg_nb_reserved;
+ /** Number of pending segments, if no new segment is available, they will
+ * be sent as PB null. */
+ uint seg_nb_pending;
+ /** First PB. */
+ pb_t *head;
+ /** Last PB. */
+ pb_t *tail;
+ /** Total number of PB. */
+ uint pb_nb_total;
+ /** Do not use AES encryption. */
+ bool bypass_aes;
+ /** First three AES initialisation vector words. */
+ u32 iv[3];
+ /** AES network encryption key. */
+ u32 *nek;
+};
+typedef struct pbproc_prep_mpdu_t pbproc_prep_mpdu_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialise prepared MPDU structure.
+ * \param ctx pbproc context
+ */
+void
+pbproc_prep_mpdu_init (pbproc_t *ctx);
+
+/**
+ * Prepare a beacon, using informations from CA.
+ * \param ctx pbproc context
+ */
+void
+pbproc_prep_beacon (pbproc_t *ctx);
+
+/**
+ * Prepare the next MPDU, using informations from CA.
+ * \param ctx pbproc context
+ */
+void
+pbproc_prep_mpdu (pbproc_t *ctx);
+
+/**
+ * Chain the remaining segments.
+ * \param ctx pbproc context
+ */
+void
+pbproc_prep_mpdu_chain (pbproc_t *ctx);
+
+/**
+ * Cancel a MPDU preparation and repair MFS.
+ * \param ctx pbproc context
+ */
+void
+pbproc_prep_mpdu_cancel (pbproc_t *ctx);
+
+/**
+ * Acknowledge every PB.
+ * \param ctx pbproc context
+ */
+void
+pbproc_prep_mpdu_ack_all (pbproc_t *ctx);
+
+/**
+ * Acknowledge a selection of PBs based on bitmap information.
+ * \param ctx pbproc context
+ * \param bmp bitmap
+ * \param bmps bitmap start offset
+ * \param bmpl bitmap available bits
+ */
+void
+pbproc_prep_mpdu_ack_bitmap (pbproc_t *ctx, const u32 *bmp,
+ uint bmps, uint bmpl);
+
+/**
+ * Acknowledge a selection of PBs based on compressed bitmap information.
+ * \param ctx pbproc context
+ * \param si SACKI bits
+ * \param sil number of SACKI bits
+ */
+void
+pbproc_prep_mpdu_ack_encoded (pbproc_t *ctx, u32 si[3], uint sil);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_prep_mpdu_h */
diff --git a/cesar/mac/pbproc/inc/sacki_dec.h b/cesar/mac/pbproc/inc/sacki_dec.h
new file mode 100644
index 0000000000..b078efacbe
--- /dev/null
+++ b/cesar/mac/pbproc/inc/sacki_dec.h
@@ -0,0 +1,41 @@
+#ifndef mac_pbproc_inc_sacki_dec_h
+#define mac_pbproc_inc_sacki_dec_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/sacki_dec.h
+ * \brief SACKI decompression.
+ * \ingroup mac_pbproc
+ */
+
+/**
+ * Called on each not OK PB range.
+ * \param user user pointer given as parameter
+ * \param first first not OK PB
+ * \param nb number of not OK PB
+ */
+typedef void (*pbproc_sacki_dec_nok_cb_t) (void *user, uint first, uint nb);
+
+BEGIN_DECLS
+
+/**
+ * Handle a SACKI compressed bitmap.
+ * \param si SACKI words
+ * \param sil number of SACKI bits left
+ * \param pbl number of PB
+ * \param user user data passed to nok_cb
+ * \param nok_cb not OK callback
+ * \return number of SACKI bits left
+ */
+uint
+pbproc_sacki_dec_process (u32 si[3], uint sil, uint pbl,
+ void *user, pbproc_sacki_dec_nok_cb_t nok_cb);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_sacki_dec_h */
diff --git a/cesar/mac/pbproc/inc/sacki_enc.h b/cesar/mac/pbproc/inc/sacki_enc.h
new file mode 100644
index 0000000000..6597a72c29
--- /dev/null
+++ b/cesar/mac/pbproc/inc/sacki_enc.h
@@ -0,0 +1,57 @@
+#ifndef mac_pbproc_inc_sacki_enc_h
+#define mac_pbproc_inc_sacki_enc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/sacki_enc.h
+ * \brief SACKI compression.
+ * \ingroup mac_pbproc
+ */
+
+/** SACKI compression context. */
+struct pbproc_sacki_enc_t
+{
+ /** SACKI buffer. */
+ u32 si[3];
+ /** SACKI buffer start offset. */
+ uint sis;
+ /** SACKI buffer available length. */
+ uint sil;
+ /** CRC bitmap start offset. */
+ u32 bmps;
+};
+typedef struct pbproc_sacki_enc_t pbproc_sacki_enc_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialise context.
+ * \param ctx SACKI compression context
+ * \param sil SACKI buffer size
+ */
+void
+pbproc_sacki_enc_init (pbproc_sacki_enc_t *ctx, uint sil);
+
+/**
+ * Process bitmap CRC bits.
+ * \param ctx SACKI compression context
+ * \param bmp CRC bitmap address
+ * \param bmpl CRC bitmap total number of available bits (including those
+ * precessed yet)
+ * \param final true if no more bits is following
+ *
+ * The compression can be done in several steps. In this case, this function
+ * should be called again.
+ */
+void
+pbproc_sacki_enc_process (pbproc_sacki_enc_t *ctx, const volatile u32 *bmp,
+ uint bmpl, bool final);
+
+END_DECLS
+
+#endif /* mac_pbproc_inc_sacki_enc_h */
diff --git a/cesar/mac/pbproc/inc/trace.h b/cesar/mac/pbproc/inc/trace.h
new file mode 100644
index 0000000000..1a4de39325
--- /dev/null
+++ b/cesar/mac/pbproc/inc/trace.h
@@ -0,0 +1,71 @@
+#ifndef mac_pbproc_inc_trace_h
+#define mac_pbproc_inc_trace_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/pbproc/inc/trace.h
+ * \brief Define PBProc trace events.
+ * \ingroup mac_pbproc
+ */
+#include "lib/trace.h"
+
+/** Shortcut for tracing inside PBProc. */
+#define PBPROC_TRACE(id, args...) \
+ TRACE_FAST_SHORT (PBPROC_TRACE_, &ctx->trace, id, ## args)
+
+#if CONFIG_TRACE
+
+enum
+{
+ PBPROC_TRACE_INIT,
+ PBPROC_TRACE_UNINIT,
+ PBPROC_TRACE_ACTIVATE,
+ PBPROC_TRACE_RX_SEG_REFILL,
+ PBPROC_TRACE_FSM_RX_FC,
+ PBPROC_TRACE_FSM_ACCESS,
+ PBPROC_TRACE_FSM_ACCESS_CONF,
+ PBPROC_TRACE_FSM_PBDMA,
+ PBPROC_TRACE_FSM_DEFERRED,
+ PBPROC_TRACE_FSM_CHANGE_STATE,
+ PBPROC_TRACE_FSM_SCHEDULE_DEFERRED,
+ PBPROC_TRACE_FSM_UNEXPECTED,
+ PBPROC_TRACE_FTOP_AIFS,
+ PBPROC_TRACE_FTOP_PRP_LOST,
+ PBPROC_TRACE_FTOP_TX,
+ PBPROC_TRACE_FHFC_BEACON,
+ PBPROC_TRACE_FHFC_SOF,
+ PBPROC_TRACE_FRDA_RX_CB,
+ PBPROC_TRACE_FRBE_RX_BEACON_CB,
+};
+
+BEGIN_DECLS
+
+/**
+ * Initialise trace buffer.
+ * \param ctx pbproc context
+ */
+void
+pbproc_trace_init (pbproc_t *ctx);
+
+/**
+ * Uninitialise trace buffer.
+ * \param ctx pbproc context
+ */
+void
+pbproc_trace_uninit (pbproc_t *ctx);
+
+END_DECLS
+
+#else /* !CONFIG_TRACE */
+
+# define pbproc_trace_init(ctx) ((void) 0)
+# define pbproc_trace_uninit(ctx) ((void) 0)
+
+#endif /* !CONFIG_TRACE */
+
+#endif /* mac_pbproc_inc_trace_h */