iproute2-next: police: support 64bit rate and peakrate in tc utility
Subsystems (3)
PATCH v2 1/1 iproute2-next: police: support 64bit rate and peakrate in tc utility
For high speed adapter like Mellanox CX-5 card, it can reach upto 100 Gbits per second bandwidth. Currently htb already supports 64bit rate in tc utility. However police action rate and peakrate are still limited to 32bit value (upto 32 Gbits per second). Taking advantage of the 2 new attributes TCA_POLICE_RATE64 and TCA_POLICE_PEAKRATE64 from kernel, tc can use them to break the 32bit limit, and still keep the backward binary compatibility.
---
Changelog:v1->v2:
- Change patch submit component from iproute2 to iproute2-next
- Move 2 attributes TCA_POLICE_RATE64 TCA_POLICE_PEAKRATE64 after TCA_POLICE_PAD in pkt_cls.h header to be consistent with kernel's pkt_cls.h header.
--- include/uapi/linux/pkt_cls.h | 2 + tc/m_police.c | 64 +++++++++++++++++++++++++++-------------- tc/tc_core.c | 29 +++++++++++++++++++ tc/tc_core.h | 3 ++ 4 files changed, 76 insertions(+), 22 deletions(-)
include/uapi/linux/pkt_cls.h +2 -0
@@ -160,6 +160,8 @@ enum {TCA_POLICE_RESULT ,TCA_POLICE_TM ,TCA_POLICE_PAD , +TCA_POLICE_RATE64 , +TCA_POLICE_PEAKRATE64 , __TCA_POLICE_MAX#define TCA_POLICE_RESULT TCA_POLICE_RESULT };
tc/m_police.c +42 -22
147 lines not on this page · raw message
tc/tc_core.c +29 -0
@@ -152,6 +152,35 @@ int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,return cell_log; } +int tc_calc_rtable_64 (struct tc_ratespec *r,__u32 *rtab, +int cell_log,unsigned int mtu, +enum link_layer linklayer,__u64 rate) +{ +int i; +unsigned int sz; +__u64 bps = rate; +unsigned int mpu = r->mpu; + +if (mtu ==0 ) + mtu =2047 ; + +if (cell_log <0 ) { + cell_log =0 ; +while ((mtu >> cell_log) >255 ) + cell_log++; + } + +for (i =0 ; i <256 ; i++) { + sz =tc_adjust_size ((i +1 ) << cell_log, mpu, linklayer); + rtab[i] =tc_calc_xmittime (bps, sz); + } + + r->cell_align =-1 ; + r->cell_log = cell_log; + r->linklayer = (linklayer &TC_LINKLAYER_MASK ); +return cell_log; +} +/* stab[pkt_len>>cell_log] = pkt_xmit_size>>size_log */
tc/tc_core.h +3 -0
@@ -21,6 +21,9 @@ unsigned tc_calc_xmittime(__u64 rate, unsigned size);unsigned tc_calc_xmitsize (__u64 rate,unsigned ticks);int tc_calc_rtable (struct tc_ratespec *r,__u32 *rtab,int cell_log,unsigned mtu,enum link_layer link_layer); +int tc_calc_rtable_64 (struct tc_ratespec *r,__u32 *rtab, +int cell_log,unsigned mtu,enum link_layer link_layer, +__u64 rate);int tc_calc_size_table (struct tc_sizespec *s,__u16 **stab);int tc_setup_estimator (unsigned A ,unsigned time_const,struct tc_estimator *est);
Signature · 1 line
1.7.1
tc/m_police.c static int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p, · line 128
Quoted 4 lines · On Fri, 30 Aug 2019 14:07:17 -0500 David Dai <[email protected]> wrote:
tc/m_police.c +1
-0+if (rate64) {fprintf (stderr,"Double \"rate\" spec\n" );return -1 ; }
The m_police filter should start using the common functions for duparg and invarg that are in lib/utils.c