Skip to content

Move rate and size parsing and output to lib

Petr Machata netdev 2 versions – Applied

Status from this message: applied to iproute2-next. Thanks, Petr

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 1 replyApplied
  2. v16 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- Patch #2:
- Adapt q_mqprio.c patch, the file changed since v1.
- Patch #4:
- This patch is new. It addresses a request from Stephen Hemminger to clean up the sprint_size() function.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/7Move the use_iec declaration to the toolsinclude/utils.h ip/ip_common.h tc/tc_common.h+3 -10 replies
2/7lib: Move print_rate() from tc here; modernizeinclude/json_print.h lib/json_print.c tc/m_police.c +10 more+93 -910 replies
3/7lib: Move sprint_size() from tc here, add print_size()include/json_print.h lib/json_print.c tc/m_gate.c +15 more+91 -1610 replies
4/7lib: sprint_size(): Uncrustify the code a bitlib/json_print.c+6 -40 replies
5/7lib: print_color_rate(): Fix formatting small rates in IEC modelib/json_print.c+2 -10 replies
6/7lib: Move get_rate(), get_rate64() from tc hereinclude/utils.h lib/utils.c tc/tc_util.c +1 more+81 -810 replies
7/7lib: Move get_size() from tc hereinclude/utils.h lib/utils.c tc/tc_util.c +1 more+36 -360 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH iproute2-next v2 0/7] Move rate and size parsing and output to lib

The DCB tool will have commands that deal with buffer sizes and traffic rates. TC is another tool that has a number of such commands, and functions to support them: get_size(), get_rate/64(), s/print_size() and s/print_rate(). In this patchset, these functions are moved from TC to lib/ for possible reuse and modernized.

s/print_rate() has a hidden parameter of a global variable use_iec, which made the conversion non-trivial. The parameter was made explicit, print_rate() converted to a mostly json_print-like function, and sprint_rate() retired in favor of the new print_rate. Patches #1 and #2 deal with this.

The intention was to treat s/print_size() similarly, but unfortunately two use cases of sprint_size() cannot be converted to a json_print-like print_size(), and the function sprint_size() had to remain as a discouraged backdoor to print_size(). This is done in patch #3.

Patch #4 then improves the code of sprint_size() a little bit.

Patch #5 fixes a buglet in formatting small rates in IEC mode.

Patches #6 and #7 handle a routine movement of, respectively, get_rate/64() and get_size() from tc to lib.

This patchset does not actually add any new uses of these functions. A follow-up patchset will add subtools for management of DCB buffer and DCB maxrate objects that will make use of them.

v2:
- Patch #2:
- Adapt q_mqprio.c patch, the file changed since v1.
- Patch #4:
- This patch is new. It addresses a request from Stephen Hemminger to clean up the sprint_size() function.

Petr Machata (7):
Move the use_iec declaration to the tools
lib: Move print_rate() from tc here; modernize
lib: Move sprint_size() from tc here, add print_size()
lib: sprint_size(): Uncrustify the code a bit
lib: print_color_rate(): Fix formatting small rates in IEC mode
lib: Move get_rate(), get_rate64() from tc here
lib: Move get_size() from tc here

 include/json_print.h |  14 ++++
 include/utils.h      |   4 +-
 ip/ip_common.h       |   2 +
 lib/json_print.c     |  63 +++++++++++++++
 lib/utils.c          | 114 +++++++++++++++++++++++++++
 tc/m_gate.c          |   6 +-
 tc/m_police.c        |  14 ++--
 tc/q_cake.c          |  44 +++++------
 tc/q_cbq.c           |  14 +---
 tc/q_drr.c           |  10 +--
 tc/q_fifo.c          |  10 +--
 tc/q_fq.c            |  34 +++-----
 tc/q_fq_codel.c      |   5 +-
 tc/q_fq_pie.c        |   9 +--
 tc/q_gred.c          |  39 ++--------
 tc/q_hfsc.c          |   4 +-
 tc/q_hhf.c           |   9 +--
 tc/q_htb.c           |  23 +++---
 tc/q_mqprio.c        |   6 +-
 tc/q_netem.c         |   4 +-
 tc/q_red.c           |  13 +---
 tc/q_sfq.c           |  15 +---
 tc/q_tbf.c           |  32 +++-----
 tc/tc_common.h       |   1 +
 tc/tc_util.c         | 180 +++----------------------------------------
 tc/tc_util.h         |   8 +-
 26 files changed, 307 insertions(+), 370 deletions(-)
Signature · 1 line
2.25.1