Lines Matching refs:psample
81 static void nsim_dev_psample_md_prepare(const struct nsim_dev_psample *psample, in nsim_dev_psample_md_prepare() argument
85 md->trunc_size = psample->trunc_size ? psample->trunc_size : len; in nsim_dev_psample_md_prepare()
86 md->in_ifindex = psample->in_ifindex; in nsim_dev_psample_md_prepare()
87 md->out_ifindex = psample->out_ifindex; in nsim_dev_psample_md_prepare()
89 if (psample->out_tc != NSIM_PSAMPLE_INVALID_TC) { in nsim_dev_psample_md_prepare()
90 md->out_tc = psample->out_tc; in nsim_dev_psample_md_prepare()
94 if (psample->out_tc_occ_max) { in nsim_dev_psample_md_prepare()
98 md->out_tc_occ = out_tc_occ & (psample->out_tc_occ_max - 1); in nsim_dev_psample_md_prepare()
102 if (psample->latency_max) { in nsim_dev_psample_md_prepare()
106 md->latency = latency & (psample->latency_max - 1); in nsim_dev_psample_md_prepare()
113 struct nsim_dev_psample *psample; in nsim_dev_psample_report_work() local
118 psample = container_of(work, struct nsim_dev_psample, psample_dw.work); in nsim_dev_psample_report_work()
124 nsim_dev_psample_md_prepare(psample, &md, skb->len); in nsim_dev_psample_report_work()
125 psample_sample_packet(psample->group, skb, psample->rate, &md); in nsim_dev_psample_report_work()
130 schedule_delayed_work(&psample->psample_dw, delay); in nsim_dev_psample_report_work()
135 struct nsim_dev_psample *psample = nsim_dev->psample; in nsim_dev_psample_enable() local
139 if (psample->is_active) in nsim_dev_psample_enable()
143 psample->group = psample_group_get(devlink_net(devlink), in nsim_dev_psample_enable()
144 psample->group_num); in nsim_dev_psample_enable()
145 if (!psample->group) in nsim_dev_psample_enable()
149 schedule_delayed_work(&psample->psample_dw, delay); in nsim_dev_psample_enable()
151 psample->is_active = true; in nsim_dev_psample_enable()
158 struct nsim_dev_psample *psample = nsim_dev->psample; in nsim_dev_psample_disable() local
160 if (!psample->is_active) in nsim_dev_psample_disable()
163 psample->is_active = false; in nsim_dev_psample_disable()
165 cancel_delayed_work_sync(&psample->psample_dw); in nsim_dev_psample_disable()
166 psample_group_put(psample->group); in nsim_dev_psample_disable()
200 struct nsim_dev_psample *psample; in nsim_dev_psample_init() local
203 psample = kzalloc(sizeof(*psample), GFP_KERNEL); in nsim_dev_psample_init()
204 if (!psample) in nsim_dev_psample_init()
206 nsim_dev->psample = psample; in nsim_dev_psample_init()
208 INIT_DELAYED_WORK(&psample->psample_dw, nsim_dev_psample_report_work); in nsim_dev_psample_init()
210 psample->ddir = debugfs_create_dir("psample", nsim_dev->ddir); in nsim_dev_psample_init()
211 if (IS_ERR(psample->ddir)) { in nsim_dev_psample_init()
212 err = PTR_ERR(psample->ddir); in nsim_dev_psample_init()
217 psample->rate = 100; in nsim_dev_psample_init()
218 debugfs_create_u32("rate", 0600, psample->ddir, &psample->rate); in nsim_dev_psample_init()
220 psample->group_num = 10; in nsim_dev_psample_init()
221 debugfs_create_u32("group_num", 0600, psample->ddir, in nsim_dev_psample_init()
222 &psample->group_num); in nsim_dev_psample_init()
224 psample->trunc_size = 0; in nsim_dev_psample_init()
225 debugfs_create_u32("trunc_size", 0600, psample->ddir, in nsim_dev_psample_init()
226 &psample->trunc_size); in nsim_dev_psample_init()
228 psample->in_ifindex = 1; in nsim_dev_psample_init()
229 debugfs_create_u32("in_ifindex", 0600, psample->ddir, in nsim_dev_psample_init()
230 &psample->in_ifindex); in nsim_dev_psample_init()
232 psample->out_ifindex = 2; in nsim_dev_psample_init()
233 debugfs_create_u32("out_ifindex", 0600, psample->ddir, in nsim_dev_psample_init()
234 &psample->out_ifindex); in nsim_dev_psample_init()
236 psample->out_tc = 0; in nsim_dev_psample_init()
237 debugfs_create_u16("out_tc", 0600, psample->ddir, &psample->out_tc); in nsim_dev_psample_init()
239 psample->out_tc_occ_max = 10000; in nsim_dev_psample_init()
240 debugfs_create_u64("out_tc_occ_max", 0600, psample->ddir, in nsim_dev_psample_init()
241 &psample->out_tc_occ_max); in nsim_dev_psample_init()
243 psample->latency_max = 50; in nsim_dev_psample_init()
244 debugfs_create_u64("latency_max", 0600, psample->ddir, in nsim_dev_psample_init()
245 &psample->latency_max); in nsim_dev_psample_init()
247 debugfs_create_file("enable", 0200, psample->ddir, nsim_dev, in nsim_dev_psample_init()
253 kfree(nsim_dev->psample); in nsim_dev_psample_init()
259 debugfs_remove_recursive(nsim_dev->psample->ddir); in nsim_dev_psample_exit()
260 if (nsim_dev->psample->is_active) { in nsim_dev_psample_exit()
261 cancel_delayed_work_sync(&nsim_dev->psample->psample_dw); in nsim_dev_psample_exit()
262 psample_group_put(nsim_dev->psample->group); in nsim_dev_psample_exit()
264 kfree(nsim_dev->psample); in nsim_dev_psample_exit()