| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
#ifndef __DCB_H__ |
| 3 |
#define __DCB_H__ 1 |
| 4 |
|
| 5 |
#include <libmnl/libmnl.h> |
| 6 |
#include <stdbool.h> |
| 7 |
#include <stddef.h> |
| 8 |
|
| 9 |
/* dcb.c */ |
| 10 |
|
| 11 |
struct dcb { |
| 12 |
char *buf; |
| 13 |
struct mnl_socket *nl; |
| 14 |
bool json_output; |
| 15 |
bool stats; |
| 16 |
bool use_iec; |
| 17 |
bool numeric; |
| 18 |
}; |
| 19 |
|
| 20 |
int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key, |
| 21 |
const char *what_value, __u64 value, __u64 max_value, |
| 22 |
void (*set_array)(__u32 index, __u64 value, void *data), |
| 23 |
void *set_array_data); |
| 24 |
int dcb_cmd_parse_dev(struct dcb *dcb, int argc, char **argv, |
| 25 |
int (*and_then)(struct dcb *dcb, const char *dev, |
| 26 |
int argc, char **argv), |
| 27 |
void (*help)(void)); |
| 28 |
|
| 29 |
void dcb_set_u8(__u32 key, __u64 value, void *data); |
| 30 |
void dcb_set_u32(__u32 key, __u64 value, void *data); |
| 31 |
void dcb_set_u64(__u32 key, __u64 value, void *data); |
| 32 |
|
| 33 |
int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr, |
| 34 |
void *data, size_t data_len); |
| 35 |
int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, |
| 36 |
const void *data, size_t data_len); |
| 37 |
int dcb_get_attribute_va(struct dcb *dcb, const char *dev, int attr, |
| 38 |
void **payload_p, __u16 *payload_len_p); |
| 39 |
int dcb_set_attribute_va(struct dcb *dcb, int command, const char *dev, |
| 40 |
int (*cb)(struct dcb *dcb, struct nlmsghdr *nlh, void *data), |
| 41 |
void *data); |
| 42 |
int dcb_get_attribute_bare(struct dcb *dcb, int cmd, const char *dev, int attr, |
| 43 |
void **payload_p, __u16 *payload_len_p); |
| 44 |
int dcb_set_attribute_bare(struct dcb *dcb, int command, const char *dev, |
| 45 |
int attr, const void *data, size_t data_len, |
| 46 |
int response_attr); |
| 47 |
|
| 48 |
void dcb_print_named_array(const char *json_name, const char *fp_name, |
| 49 |
const __u8 *array, size_t size, |
| 50 |
void (*print_array)(const __u8 *, size_t)); |
| 51 |
void dcb_print_array_u8(const __u8 *array, size_t size); |
| 52 |
void dcb_print_array_u64(const __u64 *array, size_t size); |
| 53 |
void dcb_print_array_on_off(const __u8 *array, size_t size); |
| 54 |
void dcb_print_array_kw(const __u8 *array, size_t array_size, |
| 55 |
const char *const kw[], size_t kw_size); |
| 56 |
|
| 57 |
/* dcp_rewr.c */ |
| 58 |
|
| 59 |
int dcb_cmd_rewr(struct dcb *dcb, int argc, char **argv); |
| 60 |
|
| 61 |
/* dcb_app.c */ |
| 62 |
|
| 63 |
struct dcb_app_table { |
| 64 |
struct dcb_app *apps; |
| 65 |
size_t n_apps; |
| 66 |
int attr; |
| 67 |
}; |
| 68 |
|
| 69 |
struct dcb_app_parse_mapping { |
| 70 |
__u8 selector; |
| 71 |
struct dcb_app_table *tab; |
| 72 |
int err; |
| 73 |
}; |
| 74 |
|
| 75 |
#define DCB_APP_PCP_MAX 15 |
| 76 |
#define DCB_APP_DSCP_MAX 63 |
| 77 |
|
| 78 |
int dcb_cmd_app(struct dcb *dcb, int argc, char **argv); |
| 79 |
|
| 80 |
int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *tab); |
| 81 |
int dcb_app_add_del(struct dcb *dcb, const char *dev, int command, |
| 82 |
const struct dcb_app_table *tab, |
| 83 |
bool (*filter)(const struct dcb_app *)); |
| 84 |
|
| 85 |
bool dcb_app_is_dscp(const struct dcb_app *app); |
| 86 |
bool dcb_app_is_pcp(const struct dcb_app *app); |
| 87 |
|
| 88 |
int dcb_app_print_pid_dscp(__u16 protocol); |
| 89 |
int dcb_app_print_pid_pcp(__u16 protocol); |
| 90 |
int dcb_app_print_pid_dec(__u16 protocol); |
| 91 |
void dcb_app_print_filtered(const struct dcb_app_table *tab, |
| 92 |
bool (*filter)(const struct dcb_app *), |
| 93 |
void (*print_pid_prio)(int (*print_pid)(__u16), |
| 94 |
const struct dcb_app *), |
| 95 |
int (*print_pid)(__u16 protocol), |
| 96 |
const char *json_name, |
| 97 |
const char *fp_name); |
| 98 |
|
| 99 |
enum ieee_attrs_app dcb_app_attr_type_get(__u8 selector); |
| 100 |
bool dcb_app_attr_type_validate(enum ieee_attrs_app type); |
| 101 |
bool dcb_app_selector_validate(enum ieee_attrs_app type, __u8 selector); |
| 102 |
|
| 103 |
int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app); |
| 104 |
int dcb_app_table_copy(struct dcb_app_table *a, |
| 105 |
const struct dcb_app_table *b); |
| 106 |
void dcb_app_table_sort(struct dcb_app_table *tab); |
| 107 |
void dcb_app_table_fini(struct dcb_app_table *tab); |
| 108 |
void dcb_app_table_remove_existing(struct dcb_app_table *a, |
| 109 |
const struct dcb_app_table *b); |
| 110 |
void dcb_app_table_remove_replaced(struct dcb_app_table *a, |
| 111 |
const struct dcb_app_table *b, |
| 112 |
bool (*key_eq)(const struct dcb_app *aa, |
| 113 |
const struct dcb_app *ab)); |
| 114 |
|
| 115 |
int dcb_app_parse_pcp(__u32 *key, const char *arg); |
| 116 |
int dcb_app_parse_dscp(__u32 *key, const char *arg); |
| 117 |
|
| 118 |
/* dcb_apptrust.c */ |
| 119 |
|
| 120 |
int dcb_cmd_apptrust(struct dcb *dcb, int argc, char **argv); |
| 121 |
|
| 122 |
/* dcb_buffer.c */ |
| 123 |
|
| 124 |
int dcb_cmd_buffer(struct dcb *dcb, int argc, char **argv); |
| 125 |
|
| 126 |
/* dcb_dcbx.c */ |
| 127 |
|
| 128 |
int dcb_cmd_dcbx(struct dcb *dcb, int argc, char **argv); |
| 129 |
|
| 130 |
/* dcb_ets.c */ |
| 131 |
|
| 132 |
int dcb_cmd_ets(struct dcb *dcb, int argc, char **argv); |
| 133 |
|
| 134 |
/* dcb_maxrate.c */ |
| 135 |
|
| 136 |
int dcb_cmd_maxrate(struct dcb *dcb, int argc, char **argv); |
| 137 |
|
| 138 |
/* dcb_pfc.c */ |
| 139 |
|
| 140 |
int dcb_cmd_pfc(struct dcb *dcb, int argc, char **argv); |
| 141 |
|
| 142 |
#endif /* __DCB_H__ */ |