summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/inc/sar_expiration.h
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/sar/inc/sar_expiration.h')
-rw-r--r--cesar/mac/sar/inc/sar_expiration.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/cesar/mac/sar/inc/sar_expiration.h b/cesar/mac/sar/inc/sar_expiration.h
new file mode 100644
index 0000000000..4c72d2503b
--- /dev/null
+++ b/cesar/mac/sar/inc/sar_expiration.h
@@ -0,0 +1,162 @@
+#ifndef SAR_EXPIRATION_H_
+#define SAR_EXPIRATION_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file sar_expiration.h
+ * \brief the function for the sar expiration process.
+ * \ingroup mac/sar/inc
+ *
+ */
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "mac/sar/sar_mfs_expiration_cb.h"
+#include "mac/sar/inc/sar_mf.h"
+#include "mac/sar/inc/sar_mfs.h"
+#include "mac/sar/inc/sar_pb.h"
+
+#define RELEASE_TIMER_VALUE 25000000
+#define CA_DELAY_RELEASE 25000000
+
+#define SAR_MAX_REASSEMBLY_TIMER_NTB 25000000
+#define SAR_MAX_SEGMENTATION_TIMER_NTB 25000000
+
+struct sar_expiration_t
+{
+ /** Heap expiration for the mfs_tx
+ * Data initialized in the sar_init */
+ heap_t mfs_expiration_heap;
+ /** mutex to access the expiration heap
+ * Data initialized in the sar_init */
+ cyg_mutex_t expiration_heap_mutex;
+
+ /** The MFS Store to create MFS in the reassembly process
+ * Data initialized in the sar_init
+ * (given in parameter) */
+ mac_store_t *mfs_store;
+
+ /**
+ * Callback to inform the upper layer that a MFS will go to the release
+ * state.
+ */
+ sar_mfs_expired_cb_t mfs_expiration_cb;
+
+ /**
+ * Channel access context to add and remove MFSs.
+ */
+ ca_t *ca;
+};
+typedef struct sar_expiration_t sar_expiration_t;
+
+/**
+ * initialize the sar expiration and returns a context.
+ *
+ * \param ctx the context.
+ * \param ca the Channel Access context.
+ */
+void sar_expiration_init (sar_expiration_t *ctx, ca_t *ca);
+
+/**
+ * initialize the sar expiration and returns a context.
+ *
+ * \param ctx the context.
+ */
+void sar_expiration_uninit (sar_expiration_t *ctx);
+
+/** Add a MFS to the SAR.
+ *
+ * \param ctx the expiration context
+ * \param mfs the mfs to add to the SAR.
+ */
+void sar_expiration_mfs_add (sar_expiration_t *ctx, mfs_t *mfs);
+
+/** Remove a MFS from the SAR
+ *
+ * \param ctx the expiration context
+ * \param mfs the mfs to remove from the SAR.
+ */
+void sar_expiration_mfs_remove (sar_expiration_t *ctx, mfs_t *mfs);
+
+/** Destroy a MFS from the SAR
+ *
+ * \param ctx the sar expiration context
+ * \param mfs the mfs to remove from the SAR.
+ *
+ * \return true if successed, false otherwise.
+ */
+bool sar_expiration_mfs_destroy (sar_expiration_t *ctx, mfs_t *mfs);
+
+/**
+ * get the next mfs to expire.
+ *
+ * \param ctx the sar expiration context
+ *
+ * \return the mfs on the root element of the heap.
+ */
+mfs_t* sar_expiration_get_mfs (sar_expiration_t *ctx);
+
+/**
+ * ajust the expiration heap
+ *
+ * \param ctx the sar expiration context
+ * \param mfs the mfs to adjust in the expiration machanism
+ */
+void sar_expiration_ajust (sar_expiration_t *ctx, mfs_t *mfs);
+
+/**
+ * remove the mfs from the sar expiration mechanism.
+ *
+ * \param ctx the sar expiration context
+ * \param mfs the mfs to remove
+ */
+void sar_expiration_mfs_remove_element (sar_expiration_t *ctx, mfs_t *mfs);
+
+/**
+ * Update the expiration date of the RX MFS
+ *
+ * \param ctx the sar expiration ctx to update the expiration machanism
+ * \param mfs the mfs to update
+ * \param date the current date
+ */
+void sar_expiration_mfs_update_date (sar_expiration_t *ctx, mfs_t *mfs,
+ u32 date);
+
+/**
+ * Launch the expiration mechanism and verify if the mfs had expired or not.
+ *
+ * \param ctx the sar expiration context
+ * \param phy_curr_date current date.
+ */
+void sar_expiration_mfs (sar_expiration_t *ctx, u32 phy_curr_date);
+
+/**
+ * Compare the two nodes of the tree, if the left side is lesser than the right
+ * it returns true otherwise it returns false.
+ *
+ * \param left the left heap node
+ * \param right the right heap node
+ * \return true if left expires before right, wrong otherwise.
+ */
+bool sar_expiration_mfs_less (heap_node_t *left, heap_node_t *right);
+
+/**
+ * Called by the mfs_manage_expiration to expire the pbs in the MFS.
+ *
+ * \param head the first pb to check.
+ * \param expiration_delay expiration delay
+ * \param phy_curr_date the current phy date.
+ * \return the new head of the chain.
+ */
+pb_t
+ * sar_expiration_pb (pb_t *head, uint expiration_delay,
+ u32 phy_curr_date);
+
+#endif /*SAR_EXPIRATION_H_*/