iproute2/tc/tc_util.h
Hangbin Liu 6035995665 tc: add new attr TCA_EXT_WARN_MSG
Currently, when the rule is not to be exclusively executed by the
hardware, extack is not passed along and offloading failures don't
get logged. Add a new attr TCA_EXT_WARN_MSG to log the extack message
so we can monitor the HW failures. e.g.

  # tc monitor
  added chain dev enp3s0f1np1 parent ffff: chain 0
  added filter dev enp3s0f1np1 ingress protocol all pref 49152 flower chain 0 handle 0x1
    ct_state +trk+new
    not_in_hw
          action order 1: gact action drop
           random type none pass val 0
           index 1 ref 1 bind 1

  mlx5_core: matching on ct_state +new isn't supported.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-01-22 11:01:11 -07:00

139 lines
4.6 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _TC_UTIL_H_
#define _TC_UTIL_H_ 1
#define MAX_MSG 16384
#include <limits.h>
#include <linux/if.h>
#include <stdbool.h>
#include <linux/pkt_sched.h>
#include <linux/pkt_cls.h>
#include <linux/gen_stats.h>
#include "tc_core.h"
#include "json_print.h"
/* This is the deprecated multiqueue interface */
#ifndef TCA_PRIO_MAX
enum
{
TCA_PRIO_UNSPEC,
TCA_PRIO_MQ,
__TCA_PRIO_MAX
};
#define TCA_PRIO_MAX (__TCA_PRIO_MAX - 1)
#endif
#define FILTER_NAMESZ 16
struct qdisc_util {
struct qdisc_util *next;
const char *id;
int (*parse_qopt)(struct qdisc_util *qu, int argc,
char **argv, struct nlmsghdr *n, const char *dev);
int (*print_qopt)(struct qdisc_util *qu,
FILE *f, struct rtattr *opt);
int (*print_xstats)(struct qdisc_util *qu,
FILE *f, struct rtattr *xstats);
int (*parse_copt)(struct qdisc_util *qu, int argc,
char **argv, struct nlmsghdr *n, const char *dev);
int (*print_copt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
int (*has_block)(struct qdisc_util *qu, struct rtattr *opt, __u32 block_idx, bool *p_has);
};
extern __u16 f_proto;
struct filter_util {
struct filter_util *next;
char id[FILTER_NAMESZ];
int (*parse_fopt)(struct filter_util *qu, char *fhandle,
int argc, char **argv, struct nlmsghdr *n);
int (*print_fopt)(struct filter_util *qu,
FILE *f, struct rtattr *opt, __u32 fhandle);
};
struct action_util {
struct action_util *next;
char id[FILTER_NAMESZ];
int (*parse_aopt)(struct action_util *a, int *argc,
char ***argv, int code, struct nlmsghdr *n);
int (*print_aopt)(struct action_util *au, FILE *f, struct rtattr *opt);
int (*print_xstats)(struct action_util *au,
FILE *f, struct rtattr *xstats);
};
struct exec_util {
struct exec_util *next;
char id[FILTER_NAMESZ];
int (*parse_eopt)(struct exec_util *eu, int argc, char **argv);
};
const char *get_tc_lib(void);
struct qdisc_util *get_qdisc_kind(const char *str);
struct filter_util *get_filter_kind(const char *str);
int get_qdisc_handle(__u32 *h, const char *str);
int get_percent_rate(unsigned int *rate, const char *str, const char *dev);
int get_percent_rate64(__u64 *rate, const char *str, const char *dev);
int get_size_and_cell(unsigned int *size, int *cell_log, char *str);
int get_linklayer(unsigned int *val, const char *arg);
void tc_print_rate(enum output_type t, const char *key, const char *fmt,
unsigned long long rate);
void print_devname(enum output_type type, int ifindex);
char *sprint_tc_classid(__u32 h, char *buf);
char *sprint_ticks(__u32 ticks, char *buf);
char *sprint_linklayer(unsigned int linklayer, char *buf);
void print_tcstats_attr(FILE *fp, struct rtattr *tb[],
const char *prefix, struct rtattr **xstats);
void print_tcstats2_attr(FILE *fp, struct rtattr *rta,
const char *prefix, struct rtattr **xstats);
int get_tc_classid(__u32 *h, const char *str);
int print_tc_classid(char *buf, int len, __u32 h);
char *sprint_tc_classid(__u32 h, char *buf);
int tc_print_police(FILE *f, struct rtattr *tb);
int parse_percent(double *val, const char *str);
int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
int parse_action_control(int *argc_p, char ***argv_p,
int *result_p, bool allow_num);
void parse_action_control_dflt(int *argc_p, char ***argv_p,
int *result_p, bool allow_num,
int default_result);
int parse_action_control_slash(int *argc_p, char ***argv_p,
int *result1_p, int *result2_p, bool allow_num);
void print_action_control(FILE *f, const char *prefix,
int action, const char *suffix);
int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb);
int tc_print_action(FILE *f, const struct rtattr *tb, unsigned short tot_acts);
int tc_print_ipt(FILE *f, const struct rtattr *tb);
int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
void print_tm(FILE *f, const struct tcf_t *tm);
int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
int cls_names_init(char *path);
void cls_names_uninit(void);
int action_a2n(char *arg, int *result, bool allow_num);
bool tc_qdisc_block_exists(__u32 block_index);
void print_masked_u32(const char *name, struct rtattr *attr,
struct rtattr *mask_attr, bool newline);
void print_masked_u16(const char *name, struct rtattr *attr,
struct rtattr *mask_attr, bool newline);
void print_masked_u8(const char *name, struct rtattr *attr,
struct rtattr *mask_attr, bool newline);
void print_masked_be16(const char *name, struct rtattr *attr,
struct rtattr *mask_attr, bool newline);
void print_ext_msg(struct rtattr **tb);
#endif