summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2008-03-25 09:16:46 +0000
committerlaranjeiro2008-03-25 09:16:46 +0000
commit0b2f42f4cf16e6269d3caed70ee49cf66f7115b5 (patch)
tree0a9ff24a95119f2bfa3ee415985f4e8d5a28bfd7
parent7deab2a6b8b5faa285bc264b6c6229f47f24fb37 (diff)
Update the sar to include the sar thread and run it when the sar is not
in unit test. Update the integration tests with those modification and the interface buffer modifications. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1628 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--mac/sar/inc/sar_context.h5
-rw-r--r--mac/sar/sar.h3
-rw-r--r--mac/sar/src/sar.c14
-rw-r--r--mac/sar/test/unit_test/ecos/Makefile2
-rw-r--r--mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c13
-rw-r--r--test_general/integration/interface-dp/src/station.c11
-rw-r--r--test_general/integration/interface-dp/test1.py21
7 files changed, 49 insertions, 20 deletions
diff --git a/mac/sar/inc/sar_context.h b/mac/sar/inc/sar_context.h
index 4a75e8ec48..551427db72 100644
--- a/mac/sar/inc/sar_context.h
+++ b/mac/sar/inc/sar_context.h
@@ -172,6 +172,11 @@ struct sar_t
/** message context */
void *ul_msg_ctx;
+ /** Thread context. */
+ u8 thread_stack [SAR_THREAD_STACK_SIZE];
+ cyg_handle_t thread_handle;
+ cyg_thread thread;
+
/** Tracing system */
#if CONFIG_TRACE
/** sar Trace */
diff --git a/mac/sar/sar.h b/mac/sar/sar.h
index fad7093f8a..f4666600c4 100644
--- a/mac/sar/sar.h
+++ b/mac/sar/sar.h
@@ -22,6 +22,9 @@
#include "mac/pbproc/pbproc.h"
#include "mac/sar/sar_mfs_expiration_cb.h"
+#define SAR_THREAD_PRIORITY 9
+#define SAR_THREAD_STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
+
/* forward declaration */
typedef struct sar_t sar_t;
diff --git a/mac/sar/src/sar.c b/mac/sar/src/sar.c
index 92d66f4a34..cfcecb2810 100644
--- a/mac/sar/src/sar.c
+++ b/mac/sar/src/sar.c
@@ -91,6 +91,16 @@ sar_t *sar_init (mac_store_t *mac_store, pbproc_t *pbproc, ca_t *ca)
SAR_TRACE (INIT, mac_ntb());
+ // Create the Thread for the SAR.
+ cyg_thread_create (SAR_THREAD_PRIORITY, &sar_process, (cyg_addrword_t) ctx,
+ "SAR", ctx->thread_stack, SAR_THREAD_STACK_SIZE,
+ &ctx->thread_handle, &ctx->thread);
+
+ /* Resume the thread only if the SAR is not in unit test. */
+#ifndef SAR_UNIT_TEST
+ cyg_thread_resume (ctx->thread_handle);
+#endif
+
return &sar_global;
}
@@ -254,6 +264,9 @@ void sar_init_expiration (sar_t *ctx, sar_mfs_expired_cb_t cb)
*/
void sar_uninit (sar_t *ctx)
{
+ cyg_thread_suspend (ctx->thread_handle);
+ cyg_thread_delete (ctx->thread_handle);
+
bridge_dma_uninit_list (&ctx->bridge_dma_jobs);
cyg_mbox_delete (ctx->mailbox_handle);
@@ -1252,6 +1265,7 @@ void rx_upper_layer_transmit_data (sar_t *sar_ctx, sar_reassembly_ctx_t *ctx)
else
{
job_tail->next = bridge_dma_get_head (&ctx->jobs_pending_list);
+ job_tail->job.next = &job_tail->next->job;
job_tail = job_tail->next;
}
job_tail->job.data_addr = address;
diff --git a/mac/sar/test/unit_test/ecos/Makefile b/mac/sar/test/unit_test/ecos/Makefile
index 649aa4b378..c6de8cafc3 100644
--- a/mac/sar/test/unit_test/ecos/Makefile
+++ b/mac/sar/test/unit_test/ecos/Makefile
@@ -2,6 +2,8 @@ BASE = ../../../../../
ECOS = y
+DEFS = -DSAR_UNIT_TEST=1
+
TARGET_PROGRAMS = reassembly_complete rea_cov_test \
reassembly_create_mfs lib_sar_mfs reassembly_measurement \
reassembly_mfs_update_expiration_date sar_call_back_ul \
diff --git a/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c b/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c
index d76937b894..7c060d1488 100644
--- a/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c
+++ b/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c
@@ -144,7 +144,7 @@ int main (void)
mfs->tx.head = (pb_t *) blk_alloc_desc ();
mfs->tx.head->next = NULL;
sar_expiration_mfs_remove (&sar->expiration, mfs);
- sar_expiration_mfs (&sar->expiration, 100);
+ sar_expiration_mfs (&sar->expiration, -1);
blk_release (mfs);
@@ -185,11 +185,11 @@ int main (void)
sar->expiration.mfs_expiration_cb = mfs_expired;
sar_mailbox_timeout (sar);
+ dbg_check (mac_store_sta_remove (mac_store, 1));
/* Test the expiration of an MPDU. */
this_test_mpdu_expired (sar);
- dbg_check (mac_store_sta_remove (mac_store, 1));
mac_store_uninit (mac_store);
blk_release (ca);
blk_release (sar);
@@ -586,16 +586,13 @@ void
this_test_mpdu_expired (sar_t *sar)
{
pb_t *pb;
- ca_t *ca;
uint phy;
mac_config_t mac_config;
- pbproc_rx_params_t rx_params;
sar_mpdu_t mpdu;
pb = (pb_t *) blk_alloc_desc ();
pb->next = NULL;
- ca = blk_alloc ();
phy = 28000000;
mac_ntb_init ((phy_t *) &phy, &mac_config);
@@ -603,8 +600,6 @@ this_test_mpdu_expired (sar_t *sar)
* modified. */
sar->pbproc_ctx = (pbproc_t *) sar;
- mpdu.rx_params = blk_alloc();
- *mpdu.rx_params = rx_params;
mpdu.chandata = NULL;
mpdu.nb_chandata = 0;
mpdu.mfs = NULL;
@@ -612,7 +607,7 @@ this_test_mpdu_expired (sar_t *sar)
mpdu.head = pb;
mpdu.tail = pb;
mpdu.number = 1;
- mpdu.expiration_ntb = 10;
+ mpdu.expiration_ntb = 0;
reassembly_run (sar, &mpdu);
@@ -638,8 +633,6 @@ this_test_mpdu_expired (sar_t *sar)
}
test_end;
- blk_release (ca);
- blk_release (mpdu.rx_params);
blk_release_desc ((blk_t *)mpdu.chandata);
}
diff --git a/test_general/integration/interface-dp/src/station.c b/test_general/integration/interface-dp/src/station.c
index 6481427d1f..20fa8a1db4 100644
--- a/test_general/integration/interface-dp/src/station.c
+++ b/test_general/integration/interface-dp/src/station.c
@@ -273,6 +273,7 @@ int fc_station_mme_send (fcall_ctx_t *fcall, fcall_param_t **param,
if (buffer == NULL)
{
+ printf ("Warning : No MME buffer available");
fcall_param_reset (*param);
return false;
}
@@ -464,17 +465,17 @@ cp_mme_recv (void *user_data, mfs_rx_t *mfs, u8 *buffer, uint length,
/* Get the MMTYPE from the buffer. */
- mmtype = read_u16_from_word (buffer + 0x13);
+ mmtype = read_u16_from_word (buffer + 0xF);
if (mmtype == 0xA030)
{
printf ("/ Configuration MME MMTYPE : 0xA030 *********/\n");
printf ("/ Module : %d *********/\n",
- read_u8_from_word(buffer + 0x17));
+ read_u8_from_word(buffer + 0x13));
printf ("/ Mask : 0x%x *********/\n",
- read_u8_from_word (buffer + 0x19));
+ read_u8_from_word (buffer + 0x15));
- interface_configure (station_test.interface, buffer + 0x017);
+ interface_configure (station_test.interface, buffer + 0x013);
}
@@ -557,7 +558,7 @@ cesar_init (void)
station_test.hle = hle_init (station_test.cl);
// Interface init.
- station_test.interface = interface_init (hle_get_ipmbox(station_test.hle),
+ station_test.interface = interface_init (station_test.hle,
station_test.cl, station_test.sar,
&station_test.mac_config);
diff --git a/test_general/integration/interface-dp/test1.py b/test_general/integration/interface-dp/test1.py
index 7292489199..9cc12d866b 100644
--- a/test_general/integration/interface-dp/test1.py
+++ b/test_general/integration/interface-dp/test1.py
@@ -27,10 +27,10 @@ maximus = Maximus()
maximus.init (sys.argv + ['-e', './obj/station.elf'])
sta1 = maximus.create_sta()
-sta1.debug()
+#sta1.debug()
sta2 = maximus.create_sta()
-#sta2.debug()
+sta2.debug()
# Configure the station.
fc = maximus.create_fcall ("fc_station_config")
@@ -79,6 +79,14 @@ fc.send()
# Alloc mme buffers the first two ones will be kept by the interface module.
alloc_mme_buffer (maximus, sta2)
alloc_mme_buffer (maximus, sta2)
+alloc_interface_buffer (maximus, sta2)
+alloc_interface_buffer (maximus, sta2)
+
+alloc_mme_buffer (maximus, sta1)
+alloc_mme_buffer (maximus, sta1)
+alloc_interface_buffer (maximus, sta1)
+alloc_interface_buffer (maximus, sta1)
+
#this one will be provide to the CP.
alloc_mme_buffer (maximus, sta2)
@@ -91,7 +99,7 @@ s=''
for i in range (0, len(mme_payload)):
s+=pack('B', mme_payload[i])
-mme = MME(MMHeader=MMHeader(ODA=sta2_mac_str, OSA=sta2_mac_str, VLANTag=0,MTYPE=0x88E1, MMV=0, MMTYPE=0xA030, FMI=0),MMEntry=MMEntry(s))
+mme = MME(MMHeader=MMHeader(ODA=sta2_mac_str, OSA=sta2_mac_str, MTYPE=0x88E1, MMV=0, MMTYPE=0xA030, FMI=0),MMEntry=MMEntry(s))
mme.send(maximus, sta2)
mme.send(maximus, sta1)
@@ -100,6 +108,7 @@ mme.send(maximus, sta2)
#Catch the ethernet packets
rsp = recv(maximus, count=1, filter=my_eth_filter)[0]
+alloc_interface_buffer (maximus, sta2)
alloc_mme_buffer (maximus, sta2)
rsp.display()
@@ -120,14 +129,16 @@ if rsp is not None:
rsp[0].display()
#send a beacon
+alloc_interface_buffer (maximus, sta2);
+alloc_mme_buffer (maximus, sta2);
fc = maximus.create_fcall ("fc_station_beacon_send")
fc.set_sta (sta2)
fc.send()
#Catch the ethernet packets
rsp = recv(maximus, count=2, filter=my_eth_filter)
-alloc_mme_buffer (maximus, sta2)
-alloc_mme_buffer (maximus, sta1)
+alloc_interface_buffer (maximus, sta2)
+alloc_interface_buffer (maximus, sta1)
if rsp is not None:
rsp[0].display()
rsp[1].display()