Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* net/sched/sch_ingress.c - Ingress and clsact qdisc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Authors:     Jamal Hadi Salim 1999
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/rtnetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <net/netlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <net/pkt_sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <net/pkt_cls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct ingress_sched_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	struct tcf_block *block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	struct tcf_block_ext_info block_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	struct mini_Qdisc_pair miniqp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static unsigned long ingress_find(struct Qdisc *sch, u32 classid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	return TC_H_MIN(classid) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static unsigned long ingress_bind_filter(struct Qdisc *sch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 					 unsigned long parent, u32 classid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	return ingress_find(sch, classid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static void ingress_unbind_filter(struct Qdisc *sch, unsigned long cl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static struct tcf_block *ingress_tcf_block(struct Qdisc *sch, unsigned long cl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 					   struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct ingress_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	return q->block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static void clsact_chain_head_change(struct tcf_proto *tp_head, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct mini_Qdisc_pair *miniqp = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	mini_qdisc_pair_swap(miniqp, tp_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static void ingress_ingress_block_set(struct Qdisc *sch, u32 block_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct ingress_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	q->block_info.block_index = block_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static u32 ingress_ingress_block_get(struct Qdisc *sch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct ingress_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	return q->block_info.block_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) static int ingress_init(struct Qdisc *sch, struct nlattr *opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct ingress_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct net_device *dev = qdisc_dev(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	net_inc_ingress_queue();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	q->block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	q->block_info.chain_head_change = clsact_chain_head_change;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	q->block_info.chain_head_change_priv = &q->miniqp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	err = tcf_block_get_ext(&q->block, sch, &q->block_info, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	mini_qdisc_pair_block_init(&q->miniqp, q->block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static void ingress_destroy(struct Qdisc *sch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct ingress_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	tcf_block_put_ext(q->block, sch, &q->block_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	net_dec_ingress_queue();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct nlattr *nest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (nest == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		goto nla_put_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	return nla_nest_end(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) nla_put_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	nla_nest_cancel(skb, nest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static const struct Qdisc_class_ops ingress_class_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	.flags		=	QDISC_CLASS_OPS_DOIT_UNLOCKED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	.leaf		=	ingress_leaf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	.find		=	ingress_find,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	.walk		=	ingress_walk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	.tcf_block	=	ingress_tcf_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	.bind_tcf	=	ingress_bind_filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	.unbind_tcf	=	ingress_unbind_filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	.cl_ops			=	&ingress_class_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	.id			=	"ingress",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	.priv_size		=	sizeof(struct ingress_sched_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	.static_flags		=	TCQ_F_CPUSTATS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	.init			=	ingress_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	.destroy		=	ingress_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	.dump			=	ingress_dump,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	.ingress_block_set	=	ingress_ingress_block_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	.ingress_block_get	=	ingress_ingress_block_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	.owner			=	THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct clsact_sched_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct tcf_block *ingress_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	struct tcf_block *egress_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	struct tcf_block_ext_info ingress_block_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct tcf_block_ext_info egress_block_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	struct mini_Qdisc_pair miniqp_ingress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	struct mini_Qdisc_pair miniqp_egress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static unsigned long clsact_find(struct Qdisc *sch, u32 classid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	switch (TC_H_MIN(classid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	case TC_H_MIN(TC_H_MIN_INGRESS):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	case TC_H_MIN(TC_H_MIN_EGRESS):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		return TC_H_MIN(classid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static unsigned long clsact_bind_filter(struct Qdisc *sch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 					unsigned long parent, u32 classid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	return clsact_find(sch, classid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static struct tcf_block *clsact_tcf_block(struct Qdisc *sch, unsigned long cl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 					  struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct clsact_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	switch (cl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	case TC_H_MIN(TC_H_MIN_INGRESS):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		return q->ingress_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	case TC_H_MIN(TC_H_MIN_EGRESS):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		return q->egress_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static void clsact_ingress_block_set(struct Qdisc *sch, u32 block_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct clsact_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	q->ingress_block_info.block_index = block_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static void clsact_egress_block_set(struct Qdisc *sch, u32 block_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	struct clsact_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	q->egress_block_info.block_index = block_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static u32 clsact_ingress_block_get(struct Qdisc *sch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct clsact_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	return q->ingress_block_info.block_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static u32 clsact_egress_block_get(struct Qdisc *sch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	struct clsact_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	return q->egress_block_info.block_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static int clsact_init(struct Qdisc *sch, struct nlattr *opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		       struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	struct clsact_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	struct net_device *dev = qdisc_dev(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	net_inc_ingress_queue();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	net_inc_egress_queue();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	mini_qdisc_pair_init(&q->miniqp_ingress, sch, &dev->miniq_ingress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	q->ingress_block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	q->ingress_block_info.chain_head_change = clsact_chain_head_change;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	q->ingress_block_info.chain_head_change_priv = &q->miniqp_ingress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	err = tcf_block_get_ext(&q->ingress_block, sch, &q->ingress_block_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	mini_qdisc_pair_block_init(&q->miniqp_ingress, q->ingress_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	mini_qdisc_pair_init(&q->miniqp_egress, sch, &dev->miniq_egress);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	q->egress_block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	q->egress_block_info.chain_head_change = clsact_chain_head_change;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	q->egress_block_info.chain_head_change_priv = &q->miniqp_egress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	return tcf_block_get_ext(&q->egress_block, sch, &q->egress_block_info, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static void clsact_destroy(struct Qdisc *sch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	struct clsact_sched_data *q = qdisc_priv(sch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	net_dec_ingress_queue();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	net_dec_egress_queue();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static const struct Qdisc_class_ops clsact_class_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	.flags		=	QDISC_CLASS_OPS_DOIT_UNLOCKED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	.leaf		=	ingress_leaf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	.find		=	clsact_find,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	.walk		=	ingress_walk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	.tcf_block	=	clsact_tcf_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	.bind_tcf	=	clsact_bind_filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	.unbind_tcf	=	ingress_unbind_filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static struct Qdisc_ops clsact_qdisc_ops __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	.cl_ops			=	&clsact_class_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	.id			=	"clsact",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	.priv_size		=	sizeof(struct clsact_sched_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	.static_flags		=	TCQ_F_CPUSTATS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	.init			=	clsact_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	.destroy		=	clsact_destroy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	.dump			=	ingress_dump,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	.ingress_block_set	=	clsact_ingress_block_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	.egress_block_set	=	clsact_egress_block_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	.ingress_block_get	=	clsact_ingress_block_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	.egress_block_get	=	clsact_egress_block_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	.owner			=	THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) static int __init ingress_module_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	ret = register_qdisc(&ingress_qdisc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		ret = register_qdisc(&clsact_qdisc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 			unregister_qdisc(&ingress_qdisc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) static void __exit ingress_module_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	unregister_qdisc(&ingress_qdisc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	unregister_qdisc(&clsact_qdisc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) module_init(ingress_module_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) module_exit(ingress_module_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) MODULE_ALIAS("sch_clsact");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) MODULE_LICENSE("GPL");