summaryrefslogtreecommitdiff
path: root/cesar/cl/src/cl.c
diff options
context:
space:
mode:
authorCeline Buret2011-12-23 18:51:12 +0100
committerCeline Buret2011-12-23 18:51:12 +0100
commit4a195dc3b04f8a9c67ea6a0c1902dd31e23355d7 (patch)
tree2b69b5393e7b8167ee78dad624449650008a588a /cesar/cl/src/cl.c
parent112636d5a37f4024bd954b922a46e887c3d47635 (diff)
parentf5c6b799cdce5b4bb1618f4789bb683efa7967ab (diff)
Merge branch 'master' of pessac:/git/cesar into eoc
Conflicts: cesar/cl/src/cl.c cesar/cp/sta/action/Config cesar/mac/pbproc/src/prep_mpdu.c cesar/test_general/station/cco0/s2/Config cleopatre/Makefile cleopatre/application/libspid/src/config_line.c cleopatre/application/libspid/src/image.c cleopatre/application/libspid/src/misc.c cleopatre/application/libspid/src/system.c cleopatre/application/managerd/inc/vs_mme.h cleopatre/application/managerd/src/managerd.c cleopatre/application/managerd/src/vs_mme.c cleopatre/devkit/plcdrv/arm/src/linux_drv.c cleopatre/devkit/tests/libmme/utests/src/mme_utests.c cleopatre/devkit/tests/libspid/utests/Makefile cleopatre/devkit/tests/libspid/utests/inc/system_utests.h cleopatre/devkit/tests/libspid/utests/src/config_line_utests.c cleopatre/devkit/tests/libspid/utests/src/image_utests.c cleopatre/devkit/tests/libspid/utests/src/system_utests.c cleopatre/devkit/tests/libspid/utests/testfiles/nvram1.tst cleopatre/devkit/tests/libspid/utests/testfiles/nvram2.tst cleopatre/devkit/tests/managerd/ftests/Makefile cleopatre/devkit/tests/managerd/utests/Makefile cleopatre/devkit/tests/managerd/utests/override/src/libmme_stub.c cleopatre/devkit/tests/managerd/utests/override/src/libspid_stub.c cleopatre/devkit/tests/managerd/utests/src/vs_mme_utests.c cleopatre/devkit/tests/plcd/Makefile cleopatre/devkit/tests/utests_makerules cleopatre/linux-2.6.25.10-spc300/arch/arm/boot/Makefile common/tests/tests
Diffstat (limited to 'cesar/cl/src/cl.c')
-rw-r--r--cesar/cl/src/cl.c84
1 files changed, 41 insertions, 43 deletions
diff --git a/cesar/cl/src/cl.c b/cesar/cl/src/cl.c
index 11d721149f..39d4c1d12c 100644
--- a/cesar/cl/src/cl.c
+++ b/cesar/cl/src/cl.c
@@ -17,7 +17,6 @@
#include "lib/bitstream.h"
#include "lib/seq_check.h"
-#include "config/cl.h"
#include "cl/cl.h"
#include "cl/data_rate.h"
#include "mac/sar/sar.h"
@@ -80,6 +79,10 @@ cl_classifer_get_lid_ (cl_t *ctx, uint tei, uint tag,
static uint lid_table[] = { 1, 0, 0, 1, 2, 2, 3, 3 };
uint lid;
+ dbg_assert (ctx);
+ dbg_assert (bcast);
+ dbg_assert (acs);
+ dbg_assert (drop);
dbg_assert (tag < COUNT (lid_table));
if (tei == MAC_TEI_BCAST)
@@ -115,6 +118,31 @@ cl_classifer_get_lid (cl_t *ctx, uint tei, uint tag,
dbg_assert (drop);
return cl_classifer_get_lid_ (ctx, tei, tag,bcast, acs, drop);
}
+
+/**
+ * Compute the data rate for a station based on the TEI.
+ * \param ctx CL context.
+ * \param mfs the MFS used for the transmission or reception.
+ * \param length the data length.
+ */
+PRIVATE void
+cl_compute_datarate_on_sta (cl_t *ctx, mfs_t *mfs, uint length)
+{
+#if CONFIG_CL_DATA_RATE
+ if (MAC_TEI_IS_STA (mfs->common.tei))
+ {
+ sta_t *sta = mac_store_sta_get (ctx->mac_store, mfs->common.tei);
+ if (sta)
+ {
+ data_rate_update_info (
+ mfs->common.tx ? &sta->tx_data_rate : &sta->rx_data_rate,
+ length);
+ blk_release (sta);
+ }
+ }
+#endif
+}
+
/**
* Send a data once the TEI has been find.
*
@@ -190,19 +218,7 @@ cl_data_send_with_tei (cl_t *ctx, u8 *buffer, uint length, uint tei,
ctx->data_send_link.tag = tag;
sar_msdu_add (ctx->sar, buffer, length, mfs, cl_data,
arrival_time_ntb);
-
- /* update data rate informations associated to the TX
- * from the local sta to the associated sta */
-
- if (MAC_TEI_IS_STA (tei) && CONFIG_CL_DATA_RATE)
- {
- sta_t * sta = mac_store_sta_get (ctx->mac_store, tei);
- if (sta)
- {
- data_rate_update_info (&(sta->tx_data_rate), length);
- blk_release (sta);
- }
- }
+ cl_compute_datarate_on_sta (ctx, PARENT_OF (mfs_t, tx, mfs), length);
}
else
{
@@ -610,18 +626,8 @@ cl_send_multiunicast (cl_t *ctx, u8 *buffer, uint length, bool mme, uint tag,
slab_addref (cl_data);
sar_msdu_add (ctx->sar, buffer, length, mfs, cl_data,
arrival_time_ntb);
-
- /* update data rate informations associated to the TX
- * from the local sta to the associated sta */
- if (CONFIG_CL_DATA_RATE)
- {
- sta = mac_store_sta_get (ctx->mac_store, tei);
- if (sta)
- {
- data_rate_update_info (&(sta->tx_data_rate), length);
- blk_release (sta);
- }
- }
+ cl_compute_datarate_on_sta (
+ ctx, PARENT_OF (mfs_t, tx, mfs), length);
}
else
{
@@ -750,9 +756,13 @@ cl_data_send (cl_t *ctx, u8 *buffer, uint length, uint tag,
(*ctx->data_tx.cb) (ctx->data_tx.user, buffer);
else
#endif
+ {
sar_msdu_add (ctx->sar, buffer, length,
ctx->data_send_link.mfs, NULL,
arrival_time_ntb);
+ cl_compute_datarate_on_sta (
+ ctx, PARENT_OF (mfs_t, tx, ctx->data_send_link.mfs), length);
+ }
}
else
{
@@ -1001,8 +1011,6 @@ void cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user)
*/
void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs)
{
- uint tei;
-
dbg_assert (ctx);
dbg_assert (buffer);
dbg_assert ((length >= ETH_PACKET_MIN_SIZE_ALLOWED)
@@ -1021,26 +1029,16 @@ void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs)
#if !CONFIG_CL_EOC_ROUTE
cl_brg_rx_add (ctx, smac, mfs->common.tei);
-#endif
- /* update data rate informations associated to the RX
- * from the associated sta to the local sta */
- tei = mfs->common.tei;
-#if CONFIG_CL_EOC_ROUTE
+#else
bool ok = true;
if (MAC_TEI_IS_EOC_CCO(ctx->mac_config->tei))
- ok = cl_eoc_mactotei_entry_insert (ctx, smac, tei);
+ ok = cl_eoc_mactotei_entry_insert (ctx, smac, mfs->common.tei);
dbg_assert (ok);
#endif
- if (MAC_TEI_IS_STA (tei) && CONFIG_CL_DATA_RATE)
- {
- sta_t * sta = mac_store_sta_get (ctx->mac_store, tei);
- if (sta)
- {
- data_rate_update_info(&(sta->rx_data_rate), length);
- blk_release (sta);
- }
- }
+ /* update data rate informations associated to the RX
+ * from the associated sta to the local sta */
+ cl_compute_datarate_on_sta (ctx, PARENT_OF (mfs_t, rx, mfs), length);
/* Debug info. */
GPIO_TOGGLE (LED_CL_RX);
}