Lines Matching refs:gact
30 static int gact_net_rand(struct tcf_gact *gact) in gact_net_rand() argument
33 if (prandom_u32() % gact->tcfg_pval) in gact_net_rand()
34 return gact->tcf_action; in gact_net_rand()
35 return gact->tcfg_paction; in gact_net_rand()
38 static int gact_determ(struct tcf_gact *gact) in gact_determ() argument
40 u32 pack = atomic_inc_return(&gact->packets); in gact_determ()
43 if (pack % gact->tcfg_pval) in gact_determ()
44 return gact->tcf_action; in gact_determ()
45 return gact->tcfg_paction; in gact_determ()
48 typedef int (*g_rand)(struct tcf_gact *gact);
65 struct tcf_gact *gact; in tcf_gact_init() local
114 gact = to_gact(*a); in tcf_gact_init()
116 spin_lock_bh(&gact->tcf_lock); in tcf_gact_init()
117 gact->tcf_action = parm->action; in tcf_gact_init()
120 gact->tcfg_paction = p_parm->paction; in tcf_gact_init()
121 gact->tcfg_pval = max_t(u16, 1, p_parm->pval); in tcf_gact_init()
126 gact->tcfg_ptype = p_parm->ptype; in tcf_gact_init()
129 spin_unlock_bh(&gact->tcf_lock); in tcf_gact_init()
139 struct tcf_gact *gact = to_gact(a); in tcf_gact_act() local
140 int action = READ_ONCE(gact->tcf_action); in tcf_gact_act()
144 u32 ptype = READ_ONCE(gact->tcfg_ptype); in tcf_gact_act()
147 action = gact_rand[ptype](gact); in tcf_gact_act()
150 bstats_cpu_update(this_cpu_ptr(gact->common.cpu_bstats), skb); in tcf_gact_act()
152 qstats_drop_inc(this_cpu_ptr(gact->common.cpu_qstats)); in tcf_gact_act()
154 tcf_lastuse_update(&gact->tcf_tm); in tcf_gact_act()
162 struct tcf_gact *gact = to_gact(a); in tcf_gact_stats_update() local
163 int action = READ_ONCE(gact->tcf_action); in tcf_gact_stats_update()
164 struct tcf_t *tm = &gact->tcf_tm; in tcf_gact_stats_update()
166 _bstats_cpu_update(this_cpu_ptr(gact->common.cpu_bstats), bytes, in tcf_gact_stats_update()
169 this_cpu_ptr(gact->common.cpu_qstats)->drops += packets; in tcf_gact_stats_update()
178 struct tcf_gact *gact = to_gact(a); in tcf_gact_dump() local
180 .index = gact->tcf_index, in tcf_gact_dump()
181 .refcnt = refcount_read(&gact->tcf_refcnt) - ref, in tcf_gact_dump()
182 .bindcnt = atomic_read(&gact->tcf_bindcnt) - bind, in tcf_gact_dump()
186 spin_lock_bh(&gact->tcf_lock); in tcf_gact_dump()
187 opt.action = gact->tcf_action; in tcf_gact_dump()
191 if (gact->tcfg_ptype) { in tcf_gact_dump()
193 .paction = gact->tcfg_paction, in tcf_gact_dump()
194 .pval = gact->tcfg_pval, in tcf_gact_dump()
195 .ptype = gact->tcfg_ptype, in tcf_gact_dump()
202 tcf_tm_dump(&t, &gact->tcf_tm); in tcf_gact_dump()
205 spin_unlock_bh(&gact->tcf_lock); in tcf_gact_dump()
210 spin_unlock_bh(&gact->tcf_lock); in tcf_gact_dump()