summaryrefslogtreecommitdiff
path: root/cesar/cl/src
diff options
context:
space:
mode:
authormercadie2009-09-08 14:41:09 +0000
committermercadie2009-09-08 14:41:09 +0000
commit4b6631e81de402b12c299d4ab4424532f6b98ebc (patch)
treee33d89d86330b365c38f40e85f080ee8eae8a222 /cesar/cl/src
parent2194ca385f957b0725c0c1c97590bbb03d8e61eb (diff)
* various corrections about commits r5440 and r5445
- initialise data_rate at first use - the data_rate field of struct data_rate is now u32 - time data have now a corresponding suffix - correct the case when interval > period - remove override/mac/common/ntb.h - correct header of data_rate_test.c git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5451 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cl/src')
-rw-r--r--cesar/cl/src/data_rate.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/cesar/cl/src/data_rate.c b/cesar/cl/src/data_rate.c
index 7a20064a91..ca4aaf2ece 100644
--- a/cesar/cl/src/data_rate.c
+++ b/cesar/cl/src/data_rate.c
@@ -22,55 +22,57 @@
void
data_rate_update_info (cl_data_rate_t *p_dr, uint data_size)
{
- static u32 phy_period = 0;
- static u64 ecos_period = 0;
- u64 new_ecos_time; /* in ecos tick (10ms so far) */
- u32 new_phy_time; /* in phy ticks (40ns so far) */
- u32 interval; /* delay between last time and now (in phy ticks) */
+ static u32 period_tck = 0;
+ static u64 period_rtc = 0;
+ u64 new_time_rtc; /* in ecos tick (10ms so far) */
+ u32 new_time_tck; /* in phy ticks (40ns so far) */
+ u32 interval_tck; /* delay between last time and now (in phy ticks) */
u64 new_rate; /* in octets per phy ticks */
/* This is the period (in ns) over which the data rate is evaluated */
- u64 data_rate_period = 1000000000LL;
+ u32 period_ns = 1000000000;
- if (!phy_period)
+ if (!period_tck)
{
/* evaluate the periods phy tick counts only once for all */
cyg_resolution_t res =
cyg_clock_get_resolution (cyg_real_time_clock ());
- ecos_period = div(res.divisor*data_rate_period, res.dividend);
- phy_period = div(data_rate_period, 40);
+ period_rtc = div(res.divisor * period_ns, res.dividend);
+ period_tck = div(period_ns, 40);
}
/* Get delay between last time data rate was evaluated and now */
- new_ecos_time = cyg_current_time();
- new_phy_time = mac_date ();
+ new_time_rtc = cyg_current_time ();
+ new_time_tck = mac_date ();
- if ((new_ecos_time - p_dr->ecos_time) > ecos_period)
+ if (((new_time_rtc - p_dr->time_rtc) > period_rtc)
+ || (p_dr->data_rate == CL_DATA_RATE_REQ_INIT))
{
- /* maximise the delay */
- interval = phy_period;
+ /* maximise the delay when the interval is larger than the period
+ * and when it's the first data for this data rate. */
+ interval_tck = period_tck;
}
else
{
/* mesure delay with phy time */
- interval = new_phy_time - p_dr->phy_time;
+ interval_tck = new_time_tck - p_dr->time_tck;
}
- if (interval >= phy_period)
+ if (interval_tck >= period_tck)
{
/* mesure the new rate over one period */
- new_rate = div(data_size , phy_period);
+ new_rate = data_size;
}
else
{
/* fine mesure of the delay with phy clock */
- new_rate = div(p_dr->data_rate * (phy_period - interval), phy_period)
- + data_size;
+ new_rate = (u64)(p_dr->data_rate) * (period_tck - interval_tck);
+ new_rate = div(new_rate, period_tck) + data_size;
}
/* update the data_rate structure */
- p_dr->data_rate = new_rate;
- p_dr->phy_time = new_phy_time;
- p_dr->ecos_time = new_ecos_time;
+ p_dr->data_rate = (u32)new_rate;
+ p_dr->time_tck = new_time_tck;
+ p_dr->time_rtc = new_time_rtc;
}