summaryrefslogtreecommitdiff
path: root/cesar/mac/common/mfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/common/mfs.h')
-rw-r--r--cesar/mac/common/mfs.h215
1 files changed, 215 insertions, 0 deletions
diff --git a/cesar/mac/common/mfs.h b/cesar/mac/common/mfs.h
new file mode 100644
index 0000000000..f01a1105a1
--- /dev/null
+++ b/cesar/mac/common/mfs.h
@@ -0,0 +1,215 @@
+#ifndef mac_common_mfs_h
+#define mac_common_mfs_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/common/mfs.h
+ * \brief MAC frame stream.
+ * \ingroup mac_common
+ */
+
+#include "mac/common/pb.h"
+#include "mac/ca/mfs.h"
+#include "lib/heap.h"
+#include "lib/list.h"
+
+/** Common fields for TX and RX. */
+struct mfs_common_t
+{
+ /** True if this is a TX MFS. */
+ bool tx;
+ /** Whether this is a multicast MFS. */
+ bool bcast;
+ /** True if this is a MME MFS. */
+ bool mme;
+ /** Include the ATS field in MAC frames. */
+ bool ats;
+ /** Link identifier. */
+ u8 lid;
+ /** Destination TEI for TX, source TEI for RX. */
+ u8 tei;
+ /** Aliased link identifier or MAC_LID_NONE. When a global link is
+ * created, it is first created as a local link, then promoted to a global
+ * link. This field store the local link which still have to be valid
+ * after the promotion. */
+ u8 lid_alias;
+
+ /** Heap link for the expiration process */
+ heap_node_t expiration_heap_node;
+ /** expiration date of the mfs */
+ u32 expiration_ntb;
+ /** delay for the expiration */
+ u32 expiration_delay_ntb;
+ /** The MFS state release == 1 */
+ bool release;
+};
+typedef struct mfs_common_t mfs_common_t;
+
+/** TX MFS.
+ *
+ * Here are the clarifications that may be needed about segments chaining:
+ *
+ * There is four distinct segments lists for any given MFS. The first one is
+ * not contained in the MFS. It lists the segments which are currently being
+ * sent by the PB Processing. The second one lists the segments reserved by
+ * the PB Processing which are planned to be sent soon. The third one lists
+ * the segments which are owned by the PB Processing but are not currently
+ * being sent neither planned to be sent. Finally, the last list contains
+ * segments belonging to the SAR layer. Theses segments are not currently
+ * sent of course, and are not available to the PB Processing. They will be
+ * available when the segmentation will be finished.
+ *
+ * The first list is contained in the PB Processing context.
+ *
+ * The segments from the second list are the first segments between
+ * \c head and \c tail pointer counted by the PB Processing context.
+ *
+ * The segments from the third list are the next \c seg_nb segments between
+ * \c head and \c tail pointer. The segments from the last list are the
+ * \c pending_seg_nb next segments.
+ *
+ * If \c pending_seg_nb is greater than 0, this means that the segment pointed
+ * to by \c tail belongs to the SAR layer and therefore this pointer can not
+ * be changed by the PB Processing. The SAR can update this segment at will.
+ *
+ * The number of segments between \c head and \c tail minus those reserved by
+ * the PB Processing is always \c seg_nb + \c pending_seg_nb.
+ *
+ * When dynamic CAP is used, \c cap_seg_nb counts the total number of segments
+ * for each priority. Its sum should also always be equal to \c seg_nb +
+ * \c pending_seg_nb.
+ */
+struct mfs_tx_t
+{
+ /** Common fields for TX and RX. */
+ mfs_common_t common;
+ /** Whether this MFS is using a contention free period. */
+ bool cfp;
+
+ /** Burst count for global links. */
+ u8 burst_count;
+
+ /** Heap link used by Channel Access. */
+ heap_node_t ca_prio_link;
+ /** List link used by Channel Access for MFS to be held until next beacon
+ * period. */
+ list_node_t ca_held_link;
+ /** Channel Access MFS state. */
+ ca_mfs_state_t ca_state;
+
+ /** Number of available segments. */
+ int seg_nb;
+ /** Number of pending segments, they will be available once the bridge DMA
+ * job is finished. */
+ int pending_seg_nb;
+
+ /** Minimum SSN expected by the receiver. */
+ u16 min_ssn;
+ /** Window size at the receiver. */
+ u16 window_size;
+ /** Number of holes in the window, i.e. number of acknowledged or canceled
+ * segment in the window. */
+ int window_holes_seg_nb;
+
+ /** Channel Access Priority. */
+ uint cap;
+ /** Use dynamic CAP adaptation (for MME). */
+ bool dynamic_cap;
+ /** Number of available or pending segments for each CAP if dynamic CAP
+ * adaptation is used. */
+ int cap_seg_nb[4];
+
+ /** First segment not being transmitted. This pointer is used by the PB
+ * Processing to find the first segment to transmit or the segment which
+ * was queued to the last one being transmitted. It is also used by the
+ * SAR to expire segments. */
+ pb_t *head;
+ /** Last segment. */
+ pb_t *tail;
+ /** Offset in the last segment. Used by the SAR to indicate where in the
+ * last segment the segmentation should restart. */
+ uint last_seg_offset;
+ /** SSN to use for the next created segments. */
+ u16 next_ssn;
+
+ /** True if this is a beacon MFS.
+ * A beacon MFS looks like a real MFS but there could be only one segment
+ * at a time.
+ * Beacon transmission offsets are placed right after the payload in the
+ * beacon PB. */
+ bool beacon;
+
+ /** Number of pending jobs in this MFS. */
+ uint pending_jobs;
+};
+typedef struct mfs_tx_t mfs_tx_t;
+
+/** RX MFS. */
+struct mfs_rx_t
+{
+ /** Common fields for TX and RX. */
+ mfs_common_t common;
+ pb_t * head;
+ /** Points to the last contiguous PB of the chain from the first PB */
+ pb_t * last_contiguous;
+ /** allow to chain the last pb of the mfs with the new ones. */
+ pb_t * tail;
+ /** contains the last offset processed on the pb */
+ u16 last_offset_processed;
+ /** min ssn */
+ u16 ssn_min;
+ /** ssn window size */
+ u16 window_size;
+};
+typedef struct mfs_rx_t mfs_rx_t;
+
+/** Any MFS, RX or TX. */
+union mfs_t
+{
+ /** Common fields for TX and RX. */
+ mfs_common_t common;
+ /** RX MFS. */
+ mfs_rx_t rx;
+ /** TX MFS. */
+ mfs_tx_t tx;
+};
+typedef union mfs_t mfs_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialise a RX MFS, called from MAC store.
+ * \param mfs MFS to initialise
+ * \param bcast broadcast flag
+ * \param mme MME flag
+ * \param lid link identifier
+ * \param tei TEI
+ *
+ * All other parameters are default initialised. This function should only be
+ * called from MAC store or for unassociated station MFS.
+ */
+void
+mfs_rx_init (mfs_rx_t *mfs, bool bcast, bool mme, uint lid, uint tei);
+
+/**
+ * Initialise a TX MFS, called from MAC store.
+ * \param mfs MFS to initialise
+ * \param bcast broadcast flag
+ * \param mme MME flag
+ * \param lid link identifier
+ * \param tei TEI
+ *
+ * All other parameters are default initialised. This function should only be
+ * called from MAC store or for unassociated station MFS.
+ */
+void
+mfs_tx_init (mfs_tx_t *mfs, bool bcast, bool mme, uint lid, uint tei);
+
+END_DECLS
+
+#endif /* mac_common_mfs_h */