diff mbox series

[iproute2-next,05/10] dcb: Add dcb_set_u32(), dcb_set_u64()

Message ID 3cc56cf0415b035561885ae3d48986e248ec3c7e.1607640819.git.me@pmachata.org (mailing list archive)
State Accepted
Delegated to: David Ahern
Headers show
Series dcb: Support PFC, buffer, maxrate objects | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Petr Machata Dec. 10, 2020, 11:02 p.m. UTC
The DCB buffer object has a settable array of 32-bit quantities, and the
maxrate object of 64-bit ones. Adjust dcb_parse_mapping() and related
helpers to support 64-bit values in mappings, and add appropriate helpers.

Signed-off-by: Petr Machata <me@pmachata.org>
---
 dcb/dcb.c | 22 ++++++++++++++++++----
 dcb/dcb.h |  8 +++++---
 2 files changed, 23 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/dcb/dcb.c b/dcb/dcb.c
index 217dd640d7e5..7c0beee43686 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -229,8 +229,8 @@  void dcb_print_named_array(const char *json_name, const char *fp_name,
 }
 
 int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
-		      const char *what_value, __u32 value, __u32 max_value,
-		      void (*set_array)(__u32 index, __u32 value, void *data),
+		      const char *what_value, __u64 value, __u64 max_value,
+		      void (*set_array)(__u32 index, __u64 value, void *data),
 		      void *set_array_data)
 {
 	bool is_all = key == (__u32) -1;
@@ -242,7 +242,7 @@  int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
 	}
 
 	if (value > max_value) {
-		fprintf(stderr, "In %s:%s mapping, %s is expected to be 0..%d\n",
+		fprintf(stderr, "In %s:%s mapping, %s is expected to be 0..%llu\n",
 			what_key, what_value, what_value, max_value);
 		return -EINVAL;
 	}
@@ -257,13 +257,27 @@  int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
 	return 0;
 }
 
-void dcb_set_u8(__u32 key, __u32 value, void *data)
+void dcb_set_u8(__u32 key, __u64 value, void *data)
 {
 	__u8 *array = data;
 
 	array[key] = value;
 }
 
+void dcb_set_u32(__u32 key, __u64 value, void *data)
+{
+	__u32 *array = data;
+
+	array[key] = value;
+}
+
+void dcb_set_u64(__u32 key, __u64 value, void *data)
+{
+	__u64 *array = data;
+
+	array[key] = value;
+}
+
 int dcb_cmd_parse_dev(struct dcb *dcb, int argc, char **argv,
 		      int (*and_then)(struct dcb *dcb, const char *dev,
 				      int argc, char **argv),
diff --git a/dcb/dcb.h b/dcb/dcb.h
index 6f135ed06b08..d22176888811 100644
--- a/dcb/dcb.h
+++ b/dcb/dcb.h
@@ -14,15 +14,17 @@  struct dcb {
 };
 
 int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
-		      const char *what_value, __u32 value, __u32 max_value,
-		      void (*set_array)(__u32 index, __u32 value, void *data),
+		      const char *what_value, __u64 value, __u64 max_value,
+		      void (*set_array)(__u32 index, __u64 value, void *data),
 		      void *set_array_data);
 int dcb_cmd_parse_dev(struct dcb *dcb, int argc, char **argv,
 		      int (*and_then)(struct dcb *dcb, const char *dev,
 				      int argc, char **argv),
 		      void (*help)(void));
 
-void dcb_set_u8(__u32 key, __u32 value, void *data);
+void dcb_set_u8(__u32 key, __u64 value, void *data);
+void dcb_set_u32(__u32 key, __u64 value, void *data);
+void dcb_set_u64(__u32 key, __u64 value, void *data);
 
 int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr,
 		      void *data, size_t data_len);