Lines Matching +full:pk +full:- +full:pk
1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
3 * proc.c - procfs support for Protocol family CAN core module
5 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
48 #include <linux/can/can-ml.h>
81 struct can_pkg_stats *pkg_stats = net->can.pkg_stats; in can_init_stats()
82 struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; in can_init_stats()
89 pkg_stats->jiffies_init = jiffies; in can_init_stats()
91 rcv_lists_stats->stats_reset++; in can_init_stats()
95 rcv_lists_stats->user_reset++; in can_init_stats()
105 /* see can_stat_update() - this should NEVER happen! */ in calc_rate()
112 return (count * HZ) / (newjif - oldjif); in calc_rate()
118 struct can_pkg_stats *pkg_stats = net->can.pkg_stats; in can_stat_update()
121 long rx_frames = atomic_long_read(&pkg_stats->rx_frames); in can_stat_update()
122 long tx_frames = atomic_long_read(&pkg_stats->tx_frames); in can_stat_update()
123 long matches = atomic_long_read(&pkg_stats->matches); in can_stat_update()
124 long rx_frames_delta = atomic_long_read(&pkg_stats->rx_frames_delta); in can_stat_update()
125 long tx_frames_delta = atomic_long_read(&pkg_stats->tx_frames_delta); in can_stat_update()
126 long matches_delta = atomic_long_read(&pkg_stats->matches_delta); in can_stat_update()
133 if (j < pkg_stats->jiffies_init) in can_stat_update()
144 /* matches overflow - very improbable */ in can_stat_update()
150 pkg_stats->total_rx_match_ratio = (matches * 100) / rx_frames; in can_stat_update()
152 pkg_stats->total_tx_rate = calc_rate(pkg_stats->jiffies_init, j, in can_stat_update()
154 pkg_stats->total_rx_rate = calc_rate(pkg_stats->jiffies_init, j, in can_stat_update()
159 pkg_stats->current_rx_match_ratio = in can_stat_update()
162 pkg_stats->current_tx_rate = calc_rate(0, HZ, tx_frames_delta); in can_stat_update()
163 pkg_stats->current_rx_rate = calc_rate(0, HZ, rx_frames_delta); in can_stat_update()
166 if (pkg_stats->max_tx_rate < pkg_stats->current_tx_rate) in can_stat_update()
167 pkg_stats->max_tx_rate = pkg_stats->current_tx_rate; in can_stat_update()
169 if (pkg_stats->max_rx_rate < pkg_stats->current_rx_rate) in can_stat_update()
170 pkg_stats->max_rx_rate = pkg_stats->current_rx_rate; in can_stat_update()
172 if (pkg_stats->max_rx_match_ratio < pkg_stats->current_rx_match_ratio) in can_stat_update()
173 pkg_stats->max_rx_match_ratio = pkg_stats->current_rx_match_ratio; in can_stat_update()
176 atomic_long_set(&pkg_stats->tx_frames_delta, 0); in can_stat_update()
177 atomic_long_set(&pkg_stats->rx_frames_delta, 0); in can_stat_update()
178 atomic_long_set(&pkg_stats->matches_delta, 0); in can_stat_update()
181 mod_timer(&net->can.stattimer, round_jiffies(jiffies + HZ)); in can_stat_update()
194 char *fmt = (r->can_id & CAN_EFF_FLAG)? in can_print_rcvlist()
195 " %-5s %08x %08x %pK %pK %8ld %s\n" : in can_print_rcvlist()
196 " %-5s %03x %08x %pK %pK %8ld %s\n"; in can_print_rcvlist()
198 seq_printf(m, fmt, DNAME(dev), r->can_id, r->mask, in can_print_rcvlist()
199 r->func, r->data, r->matches, r->ident); in can_print_rcvlist()
217 struct net *net = m->private; in can_stats_proc_show()
218 struct can_pkg_stats *pkg_stats = net->can.pkg_stats; in can_stats_proc_show()
219 struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; in can_stats_proc_show()
223 atomic_long_read(&pkg_stats->tx_frames)); in can_stats_proc_show()
225 atomic_long_read(&pkg_stats->rx_frames)); in can_stats_proc_show()
227 atomic_long_read(&pkg_stats->matches)); in can_stats_proc_show()
231 if (net->can.stattimer.function == can_stat_update) { in can_stats_proc_show()
233 pkg_stats->total_rx_match_ratio); in can_stats_proc_show()
236 pkg_stats->total_tx_rate); in can_stats_proc_show()
238 pkg_stats->total_rx_rate); in can_stats_proc_show()
243 pkg_stats->current_rx_match_ratio); in can_stats_proc_show()
246 pkg_stats->current_tx_rate); in can_stats_proc_show()
248 pkg_stats->current_rx_rate); in can_stats_proc_show()
253 pkg_stats->max_rx_match_ratio); in can_stats_proc_show()
256 pkg_stats->max_tx_rate); in can_stats_proc_show()
258 pkg_stats->max_rx_rate); in can_stats_proc_show()
264 rcv_lists_stats->rcv_entries); in can_stats_proc_show()
266 rcv_lists_stats->rcv_entries_max); in can_stats_proc_show()
268 if (rcv_lists_stats->stats_reset) in can_stats_proc_show()
270 rcv_lists_stats->stats_reset); in can_stats_proc_show()
272 if (rcv_lists_stats->user_reset) in can_stats_proc_show()
274 rcv_lists_stats->user_reset); in can_stats_proc_show()
282 struct net *net = m->private; in can_reset_stats_proc_show()
283 struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; in can_reset_stats_proc_show()
284 struct can_pkg_stats *pkg_stats = net->can.pkg_stats; in can_reset_stats_proc_show()
288 if (net->can.stattimer.function == can_stat_update) { in can_reset_stats_proc_show()
290 rcv_lists_stats->stats_reset + 1); in can_reset_stats_proc_show()
292 if (pkg_stats->jiffies_init != jiffies) in can_reset_stats_proc_show()
296 rcv_lists_stats->stats_reset); in can_reset_stats_proc_show()
305 if (!hlist_empty(&dev_rcv_lists->rx[idx])) { in can_rcvlist_proc_show_one()
307 can_print_rcvlist(m, &dev_rcv_lists->rx[idx], dev); in can_rcvlist_proc_show_one()
316 int idx = (int)(long)pde_data(m->file->f_inode); in can_rcvlist_proc_show()
319 struct net *net = m->private; in can_rcvlist_proc_show()
326 dev_rcv_lists = net->can.rx_alldev_list; in can_rcvlist_proc_show()
335 &can_ml->dev_rcv_lists); in can_rcvlist_proc_show()
352 /* check whether at least one list is non-empty */ in can_rcvlist_proc_show_array()
373 struct net *net = m->private; in can_rcvlist_sff_proc_show()
381 dev_rcv_lists = net->can.rx_alldev_list; in can_rcvlist_sff_proc_show()
382 can_rcvlist_proc_show_array(m, NULL, dev_rcv_lists->rx_sff, in can_rcvlist_sff_proc_show()
383 ARRAY_SIZE(dev_rcv_lists->rx_sff)); in can_rcvlist_sff_proc_show()
390 dev_rcv_lists = &can_ml->dev_rcv_lists; in can_rcvlist_sff_proc_show()
391 can_rcvlist_proc_show_array(m, dev, dev_rcv_lists->rx_sff, in can_rcvlist_sff_proc_show()
392 ARRAY_SIZE(dev_rcv_lists->rx_sff)); in can_rcvlist_sff_proc_show()
406 struct net *net = m->private; in can_rcvlist_eff_proc_show()
414 dev_rcv_lists = net->can.rx_alldev_list; in can_rcvlist_eff_proc_show()
415 can_rcvlist_proc_show_array(m, NULL, dev_rcv_lists->rx_eff, in can_rcvlist_eff_proc_show()
416 ARRAY_SIZE(dev_rcv_lists->rx_eff)); in can_rcvlist_eff_proc_show()
423 dev_rcv_lists = &can_ml->dev_rcv_lists; in can_rcvlist_eff_proc_show()
424 can_rcvlist_proc_show_array(m, dev, dev_rcv_lists->rx_eff, in can_rcvlist_eff_proc_show()
425 ARRAY_SIZE(dev_rcv_lists->rx_eff)); in can_rcvlist_eff_proc_show()
436 * can_init_proc - create main CAN proc directory and procfs entries
441 net->can.proc_dir = proc_net_mkdir(net, "can", net->proc_net); in can_init_proc()
443 if (!net->can.proc_dir) { in can_init_proc()
450 net->can.pde_stats = proc_create_net_single(CAN_PROC_STATS, 0644, in can_init_proc()
451 net->can.proc_dir, can_stats_proc_show, NULL); in can_init_proc()
452 net->can.pde_reset_stats = proc_create_net_single(CAN_PROC_RESET_STATS, in can_init_proc()
453 0644, net->can.proc_dir, can_reset_stats_proc_show, in can_init_proc()
455 net->can.pde_rcvlist_err = proc_create_net_single(CAN_PROC_RCVLIST_ERR, in can_init_proc()
456 0644, net->can.proc_dir, can_rcvlist_proc_show, in can_init_proc()
458 net->can.pde_rcvlist_all = proc_create_net_single(CAN_PROC_RCVLIST_ALL, in can_init_proc()
459 0644, net->can.proc_dir, can_rcvlist_proc_show, in can_init_proc()
461 net->can.pde_rcvlist_fil = proc_create_net_single(CAN_PROC_RCVLIST_FIL, in can_init_proc()
462 0644, net->can.proc_dir, can_rcvlist_proc_show, in can_init_proc()
464 net->can.pde_rcvlist_inv = proc_create_net_single(CAN_PROC_RCVLIST_INV, in can_init_proc()
465 0644, net->can.proc_dir, can_rcvlist_proc_show, in can_init_proc()
467 net->can.pde_rcvlist_eff = proc_create_net_single(CAN_PROC_RCVLIST_EFF, in can_init_proc()
468 0644, net->can.proc_dir, can_rcvlist_eff_proc_show, NULL); in can_init_proc()
469 net->can.pde_rcvlist_sff = proc_create_net_single(CAN_PROC_RCVLIST_SFF, in can_init_proc()
470 0644, net->can.proc_dir, can_rcvlist_sff_proc_show, NULL); in can_init_proc()
474 * can_remove_proc - remove procfs entries and main CAN proc directory
478 if (!net->can.proc_dir) in can_remove_proc()
481 if (net->can.pde_stats) in can_remove_proc()
482 remove_proc_entry(CAN_PROC_STATS, net->can.proc_dir); in can_remove_proc()
484 if (net->can.pde_reset_stats) in can_remove_proc()
485 remove_proc_entry(CAN_PROC_RESET_STATS, net->can.proc_dir); in can_remove_proc()
487 if (net->can.pde_rcvlist_err) in can_remove_proc()
488 remove_proc_entry(CAN_PROC_RCVLIST_ERR, net->can.proc_dir); in can_remove_proc()
490 if (net->can.pde_rcvlist_all) in can_remove_proc()
491 remove_proc_entry(CAN_PROC_RCVLIST_ALL, net->can.proc_dir); in can_remove_proc()
493 if (net->can.pde_rcvlist_fil) in can_remove_proc()
494 remove_proc_entry(CAN_PROC_RCVLIST_FIL, net->can.proc_dir); in can_remove_proc()
496 if (net->can.pde_rcvlist_inv) in can_remove_proc()
497 remove_proc_entry(CAN_PROC_RCVLIST_INV, net->can.proc_dir); in can_remove_proc()
499 if (net->can.pde_rcvlist_eff) in can_remove_proc()
500 remove_proc_entry(CAN_PROC_RCVLIST_EFF, net->can.proc_dir); in can_remove_proc()
502 if (net->can.pde_rcvlist_sff) in can_remove_proc()
503 remove_proc_entry(CAN_PROC_RCVLIST_SFF, net->can.proc_dir); in can_remove_proc()
505 remove_proc_entry("can", net->proc_net); in can_remove_proc()