32 #include <netlink-private/netlink.h>
33 #include <netlink-private/tc.h>
34 #include <netlink/netlink.h>
35 #include <netlink-private/route/tc-api.h>
36 #include <netlink/route/qdisc.h>
37 #include <netlink/route/qdisc/fifo.h>
38 #include <netlink/utils.h>
41 #define SCH_FIFO_ATTR_LIMIT 1
44 static int fifo_msg_parser(
struct rtnl_tc *tc,
void *data)
46 struct rtnl_fifo *fifo = data;
47 struct tc_fifo_qopt *opt;
49 if (tc->tc_opts->d_size <
sizeof(
struct tc_fifo_qopt))
52 opt = (
struct tc_fifo_qopt *) tc->tc_opts->d_data;
53 fifo->qf_limit = opt->limit;
54 fifo->qf_mask = SCH_FIFO_ATTR_LIMIT;
59 static void pfifo_dump_line(
struct rtnl_tc *tc,
void *data,
62 struct rtnl_fifo *fifo = data;
65 nl_dump(p,
" limit %u packets", fifo->qf_limit);
68 static void bfifo_dump_line(
struct rtnl_tc *tc,
void *data,
71 struct rtnl_fifo *fifo = data;
79 nl_dump(p,
" limit %.1f%s", r, unit);
82 static int fifo_msg_fill(
struct rtnl_tc *tc,
void *data,
struct nl_msg *msg)
84 struct rtnl_fifo *fifo = data;
85 struct tc_fifo_qopt opts = {0};
87 if (!fifo || !(fifo->qf_mask & SCH_FIFO_ATTR_LIMIT))
90 opts.limit = fifo->qf_limit;
92 return nlmsg_append(msg, &opts,
sizeof(opts), NL_DONTPAD);
108 struct rtnl_fifo *fifo;
113 fifo->qf_limit = limit;
114 fifo->qf_mask |= SCH_FIFO_ATTR_LIMIT;
126 struct rtnl_fifo *fifo;
131 if (fifo->qf_mask & SCH_FIFO_ATTR_LIMIT)
132 return fifo->qf_limit;
139 static struct rtnl_tc_ops pfifo_ops = {
141 .to_type = RTNL_TC_TYPE_QDISC,
142 .to_size =
sizeof(
struct rtnl_fifo),
143 .to_msg_parser = fifo_msg_parser,
145 .to_msg_fill = fifo_msg_fill,
148 static struct rtnl_tc_ops bfifo_ops = {
150 .to_type = RTNL_TC_TYPE_QDISC,
151 .to_size =
sizeof(
struct rtnl_fifo),
152 .to_msg_parser = fifo_msg_parser,
154 .to_msg_fill = fifo_msg_fill,
157 static void __init fifo_init(
void)
163 static void __exit fifo_exit(
void)