Lines Matching full:can
2 /* af_can.c - Protocol family CAN core module
3 * (used by different CAN protocol modules)
58 #include <linux/can.h>
59 #include <linux/can/core.h>
60 #include <linux/can/skb.h>
61 #include <linux/can/can-ml.h>
81 /* table of registered CAN protocols */
132 err = request_module("can-proto-%d", protocol); in can_create()
139 pr_err_ratelimited("can: request_module (can-proto-%d) failed.\n", in can_create()
185 * can_send - transmit a CAN frame (optional with local loopback)
186 * @skb: pointer to socket buffer with CAN frame in data section
187 * @loop: loopback for listeners on local CAN sockets (recommended default!)
196 * -EPERM when trying to send on a non-CAN interface
197 * -EMSGSIZE CAN frame size is bigger than CAN interface MTU
198 * -EINVAL when the skb->data does not contain a valid CAN frame
203 struct can_pkg_stats *pkg_stats = dev_net(skb->dev)->can.pkg_stats; in can_send()
215 /* set CAN FD flag for CAN FD frames by default */ in can_send()
221 /* Make sure the CAN frame can pass the selected CAN netdevice. */ in can_send()
244 /* local loopback of sent CAN frames */ in can_send()
246 /* indication for the CAN driver: do loopback */ in can_send()
272 /* indication for the CAN driver: no loopback required */ in can_send()
310 return net->can.rx_alldev_list; in can_dev_rcv_lists_find()
315 * effhash - hash function for 29 bit CAN identifier reduction
316 * @can_id: 29 bit CAN identifier
319 * To reduce the linear traversal in one linked list of _single_ EFF CAN
339 * @can_id: pointer to CAN identifier of a given can_filter
340 * @mask: pointer to CAN mask of a given can_filter
355 * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can
412 * can_rx_register - subscribe CAN frames from a specific interface
414 * @dev: pointer to netdevice (NULL => subscribe from 'all' CAN devices list)
415 * @can_id: CAN identifier (see description)
416 * @mask: CAN mask (see description)
428 * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can
449 struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; in can_rx_register()
463 spin_lock_bh(&net->can.rcvlists_lock); in can_rx_register()
482 spin_unlock_bh(&net->can.rcvlists_lock); in can_rx_register()
500 * can_rx_unregister - unsubscribe CAN frames from a specific interface
502 * @dev: pointer to netdevice (NULL => unsubscribe from 'all' CAN devices list)
503 * @can_id: CAN identifier
504 * @mask: CAN mask
517 struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; in can_rx_unregister()
526 spin_lock_bh(&net->can.rcvlists_lock); in can_rx_unregister()
541 /* Check for bugs in CAN protocol implementations using af_can.c: in can_rx_unregister()
544 * the notifier for removing the CAN netdev is running we just print in can_rx_unregister()
548 pr_warn("can: receive list entry not found for dev %s, id %03X, mask %03X\n", in can_rx_unregister()
560 spin_unlock_bh(&net->can.rcvlists_lock); in can_rx_unregister()
646 struct can_pkg_stats *pkg_stats = net->can.pkg_stats; in can_receive()
660 matches = can_rcv_filter(net->can.rx_alldev_list, skb); in can_receive()
681 pr_warn_once("PF_CAN: dropped non conform CAN skbuff: dev type %d, len %d\n", in can_rcv()
696 pr_warn_once("PF_CAN: dropped non conform CAN FD skbuff: dev type %d, len %d\n", in canfd_rcv()
711 pr_warn_once("PF_CAN: dropped non conform CAN XL skbuff: dev type %d, len %d\n", in canxl_rcv()
725 * can_proto_register - register CAN transport protocol
726 * @cp: pointer to CAN protocol structure
740 pr_err("can: protocol number %d out of range\n", proto); in can_proto_register()
751 pr_err("can: protocol %d already registered\n", proto); in can_proto_register()
767 * can_proto_unregister - unregister CAN transport protocol
768 * @cp: pointer to CAN protocol structure
787 spin_lock_init(&net->can.rcvlists_lock); in can_pernet_init()
788 net->can.rx_alldev_list = in can_pernet_init()
789 kzalloc(sizeof(*net->can.rx_alldev_list), GFP_KERNEL); in can_pernet_init()
790 if (!net->can.rx_alldev_list) in can_pernet_init()
792 net->can.pkg_stats = kzalloc(sizeof(*net->can.pkg_stats), GFP_KERNEL); in can_pernet_init()
793 if (!net->can.pkg_stats) in can_pernet_init()
795 net->can.rcv_lists_stats = kzalloc(sizeof(*net->can.rcv_lists_stats), GFP_KERNEL); in can_pernet_init()
796 if (!net->can.rcv_lists_stats) in can_pernet_init()
802 timer_setup(&net->can.stattimer, can_stat_update, in can_pernet_init()
804 mod_timer(&net->can.stattimer, in can_pernet_init()
807 net->can.pkg_stats->jiffies_init = jiffies; in can_pernet_init()
814 kfree(net->can.pkg_stats); in can_pernet_init()
816 kfree(net->can.rx_alldev_list); in can_pernet_init()
826 del_timer_sync(&net->can.stattimer); in can_pernet_exit()
829 kfree(net->can.rx_alldev_list); in can_pernet_exit()
830 kfree(net->can.pkg_stats); in can_pernet_exit()
831 kfree(net->can.rcv_lists_stats); in can_pernet_exit()
872 pr_info("can: controller area network core\n"); in can_init()