]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
dcb: Add dcb_set_u32(), dcb_set_u64()
authorPetr Machata <me@pmachata.org>
Thu, 10 Dec 2020 23:02:19 +0000 (00:02 +0100)
committerDavid Ahern <dsahern@gmail.com>
Mon, 14 Dec 2020 16:41:45 +0000 (16:41 +0000)
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>
Signed-off-by: David Ahern <dsahern@gmail.com>
dcb/dcb.c
dcb/dcb.h

index 217dd640d7e5d0af3be89c8fb789bff3d82f331a..7c0beee4368682da414c99d880178b0fe7970145 100644 (file)
--- 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),
index 6f135ed06b083b44c734bbeeb867b6909934fd7a..d22176888811c53c3fbae1eba910a489c88ac200 100644 (file)
--- 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);