summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/test
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-02-07 15:27:12 +0100
committerNélio Laranjeiro2011-02-07 17:39:30 +0100
commit4412d4f10c03c2d5fa6d6be58dd59a990906630d (patch)
tree7eea8ebdedfb6bbb4c4246a034b7742b95575021 /cesar/mac/sar/test
parentaf8f9179d6494dca546637f2c0a4359cb25aa72c (diff)
cesar/mac/sar: allow TX for MFS with few traffic, refs #2232
If a segmentation is requested and the MFS concerned has less or equal than MAC_SAR_EM_MAX_PB_ALLOWED (5 PBs) then the slack is not used and the process goes on.
Diffstat (limited to 'cesar/mac/sar/test')
-rw-r--r--cesar/mac/sar/test/unit_test/ecos/src/segmentation.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/cesar/mac/sar/test/unit_test/ecos/src/segmentation.c b/cesar/mac/sar/test/unit_test/ecos/src/segmentation.c
index 3349e64463..3cfa678fb2 100644
--- a/cesar/mac/sar/test/unit_test/ecos/src/segmentation.c
+++ b/cesar/mac/sar/test/unit_test/ecos/src/segmentation.c
@@ -19,6 +19,9 @@
#include "mac/sar/sar.h"
#include "mac/sar/inc/sar_context.h"
+#include "mac/sar/inc/sar.h"
+#include <string.h>
+#include "config.h"
/* Override context. */
#include "mac/pbproc/inc/context.h"
@@ -256,6 +259,51 @@ test_case_segmentation_mfs_release (test_t test)
}
void
+test_case_segmentation_em_max_pb_allowed_test (test_t test, sar_test_t ctx,
+ mfs_tx_t *mfs)
+{
+ u8 buffer[ETH_PACKET_MIN_SIZE_ALLOWED];
+ memset (buffer, 0xff, ETH_PACKET_MIN_SIZE_ALLOWED);
+ test_within (test);
+ sar_msdu_add (ctx.sar, buffer, ETH_PACKET_MIN_SIZE_ALLOWED, mfs,
+ NULL, 0x0);
+ sar_bridge_dma_free_head (ctx.sar);
+ test_fail_unless (mfs->seg_nb == MAC_SAR_EM_MAX_PB_ALLOWED + 1);
+}
+
+void
+test_case_segmentation_em_max_pb_allowed (test_t test)
+{
+ sar_test_t ctx;
+ bool added;
+ test_case_begin (test, "Test MAC_SAR_EM_MAX_PB_ALLOWED");
+ sar_test_init (&ctx, INVALID_PTR, INVALID_PTR);
+ mfs_tx_t *mfs = mac_store_mfs_add_tx (ctx.mac_store, false, false, 1,
+ 1, &added);
+ blk_t *head, *tail;
+ /* Allocate all available memory less some block under the slack value. */
+ head = blk_alloc_desc_range (CONFIG_BLK_NB - CONFIG_BLK_SLACK + 2, &tail);
+ sar_activate (ctx.sar, true);
+ test_begin (test, "TX > MAC_SAR_EM_MAX_PB_ALLOWED")
+ {
+ mfs->seg_nb = MAC_SAR_EM_MAX_PB_ALLOWED + 1;
+ test_case_segmentation_em_max_pb_allowed_test (test, ctx, mfs);
+ }
+ test_end;
+ test_begin (test, "TX <= MAC_SAR_EM_MAX_PB_ALLOWED")
+ {
+ mfs->seg_nb = MAC_SAR_EM_MAX_PB_ALLOWED;
+ test_case_segmentation_em_max_pb_allowed_test (test, ctx, mfs);
+ }
+ test_end;
+ blk_release_desc_range (head, tail);
+ sar_mfs_remove (ctx.sar, PARENT_OF (mfs_t, tx, mfs));
+ blk_release (mfs);
+ sar_sta_remove (ctx.sar, 1);
+ sar_test_uninit (&ctx);
+}
+
+void
test_suite_segmentation (test_t test)
{
test_suite_begin (test, "Segmentation");
@@ -263,6 +311,7 @@ test_suite_segmentation (test_t test)
test_case_segmentation_message_too_short (test);
test_case_segmentation (test);
test_case_segmentation_mfs_release (test);
+ test_case_segmentation_em_max_pb_allowed (test);
test_begin (test, "Memory")
{