@@ -71,6 +71,8 @@ static bool g_indent_newline;
#define INDENT_STR_MAXLEN 32
static char g_indent_str[INDENT_STR_MAXLEN + 1] = "";
+static bool use_iec = false;
+
static void __attribute__((format(printf, 1, 2)))
pr_err(const char *fmt, ...)
{
@@ -4537,7 +4539,7 @@ static void pr_out_port_fn_rate(struct dl *dl, struct nlattr **tb)
mnl_attr_get_u64(tb[DEVLINK_ATTR_RATE_TX_SHARE]);
if (rate)
- print_rate(false, PRINT_ANY, "tx_share",
+ print_rate(use_iec, PRINT_ANY, "tx_share",
" tx_share %s", rate);
}
if (tb[DEVLINK_ATTR_RATE_TX_MAX]) {
@@ -4545,7 +4547,7 @@ static void pr_out_port_fn_rate(struct dl *dl, struct nlattr **tb)
mnl_attr_get_u64(tb[DEVLINK_ATTR_RATE_TX_MAX]);
if (rate)
- print_rate(false, PRINT_ANY, "tx_max",
+ print_rate(use_iec, PRINT_ANY, "tx_max",
" tx_max %s", rate);
}
if (tb[DEVLINK_ATTR_RATE_PARENT_NODE_NAME]) {
@@ -9066,6 +9068,7 @@ int main(int argc, char **argv)
{ "verbose", no_argument, NULL, 'v' },
{ "statistics", no_argument, NULL, 's' },
{ "Netns", required_argument, NULL, 'N' },
+ { "iec", no_argument, NULL, 'i' },
{ NULL, 0, NULL, 0 }
};
const char *batch_file = NULL;
@@ -9081,7 +9084,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- while ((opt = getopt_long(argc, argv, "Vfb:njpvsN:",
+ while ((opt = getopt_long(argc, argv, "Vfb:njpvsN:i",
long_options, NULL)) >= 0) {
switch (opt) {
@@ -9116,6 +9119,9 @@ int main(int argc, char **argv)
goto dl_free;
}
break;
+ case 'i':
+ use_iec = true;
+ break;
default:
pr_err("Unknown option.\n");
help();
@@ -15,7 +15,7 @@ devlink-rate \- devlink rate management
.ti -8
.IR OPTIONS " := { "
-.BR -j [ \fIson "] | " -p [ \fIretty "] }"
+.BR -j [ \fIson "] | " -p [ \fIretty "] | " -i [ \fIec "] }"
.ti -8
.B devlink port function rate show
@@ -61,9 +61,10 @@ except decimal number, to avoid collisions with leafs.
.PP
Command output show rate object identifier, it's type and rate values along with
parent node name. Rate values printed in SI units which are more suitable to
-represent specific value. JSON (\fB-j\fR) output always print rate values in
-bytes per second. Zero rate values means "unlimited" rates and ommited in
-output, as well as parent node name.
+represent specific value. To print values in IEC units \fB-i\fR switch is
+used. JSON (\fB-j\fR) output always print rate values in bytes per second. Zero
+rate values means "unlimited" rates and ommited in output, as well as parent
+node name.
.SS devlink port function rate set - set rate object parameters.
Allows set rate object's parameters. If any parameter specified multiple times
@@ -85,7 +86,7 @@ rate group.
.TP 8
.I VALUE
These parameter accept a floating point number, possibly followed by either a
-unit.
+unit (both SI and IEC units supported).
.RS
.TP
bit or a bare number
@@ -117,6 +118,9 @@ Gigabytes per second
.TP
tbps
Terabytes per second
+.P
+To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with IEC prefix
+(ki-, mi-, gi- and ti-) respectively. Input is case-insensitive.
.RE
.PP
.BI parent " NODE_NAME \fR| " noparent
@@ -169,6 +173,16 @@ pci/0000:03:00.0/1 type leaf
.RE
.PP
+\fB*\fR Display leaf rate object rate values using IEC units:
+.RS 4
+.PP
+# devlink -i port function rate show pci/0000:03:00.0/2
+.br
+pci/0000:03:00.0/2 type leaf 11718Kibit
+.br
+.RE
+
+.PP
\fB*\fR Display node rate object with name some_group of the pci/0000:03:00.0 device:
.RS 4
.PP
@@ -59,6 +59,10 @@ Output statistics.
.BR "\-N", " \-Netns " <NETNSNAME>
Switches to the specified network namespace.
+.TP
+.BR "\-i", " --iec"
+Print human readable rates in IEC units (e.g. 1Ki = 1024).
+
.SS
.I OBJECT