summaryrefslogtreecommitdiff
path: root/dcb
diff options
context:
space:
mode:
authorPetr Machata <me@pmachata.org>2020-12-11 00:02:19 +0100
committerDavid Ahern <dsahern@gmail.com>2020-12-14 16:41:45 +0000
commit11a72186a05710b290f1527f6f995b044a4fc501 (patch)
tree8d9f50800ed1deff156d8854e0a585692b97865c /dcb
parent7e94711c71cc40c0ab47c07de6b31bd788ead096 (diff)
dcb: Add dcb_set_u32(), dcb_set_u64()
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>
Diffstat (limited to 'dcb')
-rw-r--r--dcb/dcb.c22
-rw-r--r--dcb/dcb.h8
2 files changed, 23 insertions, 7 deletions
diff --git a/dcb/dcb.c b/dcb/dcb.c
index 217dd640..7c0beee4 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 6f135ed0..d2217688 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);