[PATCH 2/7] ATM cell alignment.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Stephen Hemminger <stephen.hemminger@...>
Cc: netdev <netdev@...>, David S. Miller <davem@...>, Patrick McHardy <kaber@...>
Date: Wednesday, April 9, 2008 - 5:01 pm

Introducing the function that does the ATM cell alignment, and
modifying tc_calc_rtable() to use this based upon a linklayer
parameter.

Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
---
  tc/tc_core.c |   36 +++++++++++++++++++++++++++++++++++-
  tc/tc_core.h |    6 +++++-
  2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/tc/tc_core.c b/tc/tc_core.c
index 9ae4d8e..a9b8076 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -65,11 +65,35 @@ unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
  	return ((double)rate*tc_core_tick2time(ticks))/TIME_UNITS_PER_SEC;
  }

+#define ATM_CELL_SIZE               53  /* ATM cell size incl. header */
+#define ATM_CELL_PAYLOAD            48  /* ATM payload size */
+/*
+ The align to ATM cells is used for determining the (ATM) SAR
+ alignment overhead at the ATM layer. (SAR = Segmentation And
+ Reassembly).  This is for example needed when scheduling packet on an
+ ADSL connection.  Note that the extra ATM-AAL overhead is _not_
+ included in this calculation. This overhead is added in the kernel
+ before doing the rate table lookup, as this gives better precision
+ (as the table will always be aligned for 48 bytes).
+  --Hawk, d.7/11-2004. <hawk@diku.dk>
+ */
+unsigned tc_align_to_atm(unsigned size)
+{
+	int linksize, cells;
+	cells = size / ATM_CELL_PAYLOAD;
+	if ((size % ATM_CELL_PAYLOAD) > 0) {
+		cells++;
+	}
+	linksize = cells * ATM_CELL_SIZE; /* Use full cell size to add ATM tax */
+	return linksize;
+}
+
  /*
     rtab[pkt_len>>cell_log] = pkt_xmit_time
   */

-int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab, int cell_log, unsigned mtu)
+int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab, int cell_log, unsigned mtu,
+		   unsigned int linklayer)
  {
  	int i;
  	unsigned bps = r->rate;
@@ -87,6 +111,16 @@ int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab, int cell_log, unsigned mt
  		unsigned sz = ((i+1)<<cell_log);
  		if (sz < mpu)
  			sz = mpu;
+		switch (linklayer) {
+		case LINKLAYER_ATM:
+			sz = tc_align_to_atm(sz);
+			break;
+		case LINKLAYER_ETHERNET:
+			// No size adjustments on Ethernet
+			break;
+		default:
+			break;
+		}
  		rtab[i] = tc_calc_xmittime(bps, sz);
  	}
  	r->cell_align=-1; // Due to the sz calc
diff --git a/tc/tc_core.h b/tc/tc_core.h
index 080a0cd..7b2eaa0 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -6,6 +6,9 @@

  #define TIME_UNITS_PER_SEC	1000000

+#define LINKLAYER_ETHERNET 1
+#define LINKLAYER_ATM      2
+
  int  tc_core_time2big(unsigned time);
  unsigned tc_core_time2tick(unsigned time);
  unsigned tc_core_tick2time(unsigned tick);
@@ -13,7 +16,8 @@ unsigned tc_core_time2ktime(unsigned time);
  unsigned tc_core_ktime2time(unsigned ktime);
  unsigned tc_calc_xmittime(unsigned rate, unsigned size);
  unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks);
-int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab, int cell_log, unsigned mtu);
+int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab, int cell_log, unsigned mtu,
+		   unsigned int linklayer);

  int tc_setup_estimator(unsigned A, unsigned time_const, struct tc_estimator *est);

-- 
1.5.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/7] Final ADSL-optimizer patch series, Jesper Dangaard Brouer, (Wed Apr 9, 4:57 pm)
Re: [PATCH 0/7] Final ADSL-optimizer patch series, Stephen Hemminger, (Thu Apr 17, 1:10 pm)
Re: [PATCH 0/7] Final ADSL-optimizer patch series, David Miller, (Mon Apr 14, 1:40 am)
[PATCH 7/7] Add linklayer parameter to TBF., Jesper Dangaard Brouer, (Wed Apr 9, 5:07 pm)
[PATCH 6/7] Add linklayer parameter to HTB., Jesper Dangaard Brouer, (Wed Apr 9, 5:06 pm)
[PATCH 5/7] Add linklayer parameter to CBQ., Jesper Dangaard Brouer, (Wed Apr 9, 5:04 pm)
[PATCH 4/7] Add linklayer parameter to filter action police., Jesper Dangaard Brouer, (Wed Apr 9, 5:03 pm)
[PATCH 3/7] Parsing linklayer types., Jesper Dangaard Brouer, (Wed Apr 9, 5:02 pm)
[PATCH 2/7] ATM cell alignment., Jesper Dangaard Brouer, (Wed Apr 9, 5:01 pm)
Re: [PATCH 2/7] ATM cell alignment., Andy Furniss, (Sun Apr 13, 7:24 am)
Re: [PATCH 2/7] ATM cell alignment., Jesper Dangaard Brouer, (Mon Apr 14, 1:59 am)
Re: [PATCH 2/7] ATM cell alignment., Andy Furniss, (Tue Apr 15, 7:41 pm)
Re: [PATCH 2/7] ATM cell alignment., Patrick McHardy, (Fri Apr 11, 8:51 am)
Re: [PATCH 2/7] ATM cell alignment., Jesper Dangaard Brouer, (Fri Apr 11, 1:35 pm)
Re: [PATCH 2/7] ATM cell alignment., Patrick McHardy, (Sun Apr 13, 12:44 am)
Re: [PATCH 2/7] ATM cell alignment., Chas Williams (CONTRACTOR)..., (Thu Apr 10, 10:35 am)
Re: [PATCH 2/7] ATM cell alignment., Jesper Dangaard Brouer, (Fri Apr 11, 12:53 am)
Re: [PATCH 2/7] ATM cell alignment., Chas Williams (CONTRACTOR)..., (Fri Apr 11, 10:18 am)
[PATCH 1/7] In police, fix uninitialized "overhead" variable., Jesper Dangaard Brouer, (Wed Apr 9, 4:59 pm)