summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/inc/sar.h
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/sar/inc/sar.h')
-rw-r--r--cesar/mac/sar/inc/sar.h199
1 files changed, 199 insertions, 0 deletions
diff --git a/cesar/mac/sar/inc/sar.h b/cesar/mac/sar/inc/sar.h
new file mode 100644
index 0000000000..cb7f4d3ce4
--- /dev/null
+++ b/cesar/mac/sar/inc/sar.h
@@ -0,0 +1,199 @@
+#ifndef MAC_SAR_INC_SAR_H_
+#define MAC_SAR_INC_SAR_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/inc/sar.h
+ * \brief private declaration functions of the SAR.
+ * \ingroup mac/sar/inc
+ *
+ */
+
+#define SAR_GET_WORK_DELAY_RTC 5
+
+/**
+ * Initialize the reassembly context
+ *
+ * \param ctx the sar reassembly context
+ * \param buffer the buffer to stock the addresses.
+ * \param nb_slots the quantity of slots.
+ */
+void sar_reassembly_init (sar_reassembly_ctx_t *ctx, u8 **buffer, uint nb_slots);
+
+/**
+ * Allocate a new list of chained PB of the size of pb_nb to give it to the
+ * pbproc.
+ *
+ * \param ctx the sar context
+ * \param pb_nb the quantity of PBs to allocate.
+ */
+void pb_pool_refill (sar_t *ctx, uint pb_nb);
+
+/**
+ * Get the first work to do by the SAR
+ *
+ * \param ctx the sar context.
+ * \return the work message
+ */
+sar_work_message_t* sar_work_get (sar_t *ctx);
+
+/**
+ * Parse the chain of PBs recevived from the pb proc.
+ * - Verifies if the PB is valid
+ * - Transmit the data to the CE.
+ * - Update the mfs window according with the HomePlug AV specification.
+ * - Verifies if the PB is in the window
+ * - Insert it in the right place in the corresponding MFS.
+ *
+ * \param ctx the sar context
+ * \param rx the mpdu_rx containing the PB to add to the MFS
+ */
+void rx_mpdu_process (sar_t *ctx, sar_mpdu_t * rx);
+
+/**
+ * Verify if one or various buffers are available for the CP. If they are the
+ * a list of jobs are chained to the bridge DMA job list to be processed.
+ *
+ * This function never loop cause of the implementation, When a buffer is
+ * haded this function is called as the same is done at each reconstitution of
+ * a MF.
+ *
+ * \param sar_ctx the sar context.
+ * \param ctx the reassembly context to transmit the data.
+ */
+void rx_upper_layer_transmit_data (sar_t *sar_ctx, sar_reassembly_ctx_t *ctx);
+
+/**
+ * Create a job with all the minimum configuration for the bridge dma
+ *
+ * \param tx if it is a TX way
+ * \return sar job mfs for the bridge dma.
+ */
+sar_job_mfs_t *sar_job_mfs_create (bool tx);
+
+/**
+ * Get the mfs from mac store or create it using the rx_params lid and dtei.
+ *
+ * \param sar the sar context.
+ * \param rx the rx_mpdu
+ * \param pb the PB from which it is possible to know if it needs the mme mfs
+ * or the data mfs
+ *
+ * \return the mfs corresponding, or the new one.
+ */
+mfs_rx_t *rx_get_associated_mfs (sar_t *sar, sar_mpdu_t * rx, pb_t *pb);
+
+/**
+ * Create a job_desc_t from the md_data and allocate the PBs neccessary to stock
+ * the MF contained in the md_data
+ *
+ * Create the list of PBs necessary to contain the MF and put it via the
+ * PB proc in the MFS.
+ *
+ * \param md_data the data to segment
+ * \param mfs the corresponding mfs
+ * \param job_mfs the job to fill
+ *
+ * \return the last pb of the chain
+ */
+pb_t * tx_job_desc_create (sar_msdu_t *md_data, mfs_tx_t * mfs,
+ sar_job_mfs_t *job_mfs);
+
+/**
+ * Create a complete or a partial list of PBs for the mac framing
+ * \param length the length of the complete MF or the end of the MF
+ * \param ssn the next ssn to put on the header
+ * \param mme if the segments will contain messages.
+ * \param begin the first pb of the chain
+ * \param last the last pb of the chain.
+ * \return the number of PBs allocated
+ */
+u8 tx_job_desc_create_complete_list (u16 length, u8 ssn, bool mme,
+ pb_t **begin, pb_t **last);
+
+/** create mac frame to transmit in preparing next job of bridge dma for
+ * segmentation
+ *
+ * \param ctx the sar context.
+ * \param md_data the Mac Frame to fill the job descriptor
+ */
+sar_job_mfs_t * tx_mac_framing (sar_t *ctx, sar_msdu_t *md_data);
+
+/**
+ * Msdu expiration
+ * cf the specification HomePlug AV on page 260 (5.4.1.6.1 Transmit buffer
+ * management).
+ *
+ * \param ctx the sar context
+ * \param msdu the msdu to verify
+ * \return true if it had expired, false otherwise.
+ */
+bool tx_msdu_expiration (sar_t *ctx, sar_msdu_t * msdu);
+
+/**
+ * Segmentation process for the SAR module.
+ *
+ * \param ctx the sar context
+ * \param msdu the msdu to process
+ */
+void segmentation_run (sar_t *ctx, sar_msdu_t *msdu);
+
+/**
+ * Launch the reassembly process to realize reassembly a new mpdu.
+ *
+ * \param ctx the sar context
+ * \param rx the rx data to process
+ */
+void reassembly_run (sar_t *ctx, sar_mpdu_t *rx);
+
+/**
+ * Search where the PB with the ssn given can be inserted in the chain.
+ *
+ * \param mfs the mfs to search
+ * \param ssn the ssn of the current pb
+ * \return - the last after the one the PB can be inserted in the list.
+ * - null if the chain is empty
+ * - null if it can not be inserted (the value already already
+ * exists in the chain).
+ */
+pb_t *rx_mfs_search_where_to_insert_pb (mfs_rx_t *mfs, u16 ssn);
+
+/**
+ * Function called by the phy hal when the bridge return an IT
+ *
+ * \param user user data
+ * \param status_word l'etat du bridge
+ */
+bool bridge_dma_interruption (void *user, u32 status_word);
+
+/**
+ * Function called by the phy hal when the bridge return an IT
+ *
+ * \param user user data
+ */
+void bridge_dma_deffered_interruption (void *user);
+
+/**
+ * Free the head of the bridge dma and call the rigth function.
+ *
+ * \param ctx the sar context.
+ */
+void
+bridge_dma_free_head (sar_t *ctx);
+
+/**
+ * Process the MFS to reconstitute MF until the MFS contains PBs or the MF
+ * can not be reconsitute because of missing PBs.
+ *
+ * \param ctx the sar context
+ * \param mfs the mfs to proccess.
+ */
+void rx_mfs_process (sar_t *ctx, mfs_rx_t * mfs);
+
+#endif /* MAC_SAR_INC_SAR_H_ */