.. | .. |
---|
1 | | -/* |
---|
2 | | - * vcan.c - Virtual CAN interface |
---|
| 1 | +/* vcan.c - Virtual CAN interface |
---|
3 | 2 | * |
---|
4 | 3 | * Copyright (c) 2002-2017 Volkswagen Group Electronic Research |
---|
5 | 4 | * All rights reserved. |
---|
.. | .. |
---|
39 | 38 | * |
---|
40 | 39 | */ |
---|
41 | 40 | |
---|
| 41 | +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
| 42 | + |
---|
42 | 43 | #include <linux/module.h> |
---|
43 | 44 | #include <linux/init.h> |
---|
44 | 45 | #include <linux/netdevice.h> |
---|
45 | 46 | #include <linux/if_arp.h> |
---|
46 | 47 | #include <linux/if_ether.h> |
---|
47 | 48 | #include <linux/can.h> |
---|
| 49 | +#include <linux/can/can-ml.h> |
---|
48 | 50 | #include <linux/can/dev.h> |
---|
49 | 51 | #include <linux/can/skb.h> |
---|
50 | 52 | #include <linux/slab.h> |
---|
.. | .. |
---|
57 | 59 | MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>"); |
---|
58 | 60 | MODULE_ALIAS_RTNL_LINK(DRV_NAME); |
---|
59 | 61 | |
---|
60 | | - |
---|
61 | | -/* |
---|
62 | | - * CAN test feature: |
---|
| 62 | +/* CAN test feature: |
---|
63 | 63 | * Enable the echo on driver level for testing the CAN core echo modes. |
---|
64 | 64 | * See Documentation/networking/can.rst for details. |
---|
65 | 65 | */ |
---|
.. | .. |
---|
67 | 67 | static bool echo; /* echo testing. Default: 0 (Off) */ |
---|
68 | 68 | module_param(echo, bool, 0444); |
---|
69 | 69 | MODULE_PARM_DESC(echo, "Echo sent frames (for testing). Default: 0 (Off)"); |
---|
70 | | - |
---|
71 | 70 | |
---|
72 | 71 | static void vcan_rx(struct sk_buff *skb, struct net_device *dev) |
---|
73 | 72 | { |
---|
.. | .. |
---|
101 | 100 | |
---|
102 | 101 | if (!echo) { |
---|
103 | 102 | /* no echo handling available inside this driver */ |
---|
104 | | - |
---|
105 | 103 | if (loop) { |
---|
106 | | - /* |
---|
107 | | - * only count the packets here, because the |
---|
| 104 | + /* only count the packets here, because the |
---|
108 | 105 | * CAN core already did the echo for us |
---|
109 | 106 | */ |
---|
110 | 107 | stats->rx_packets++; |
---|
.. | .. |
---|
117 | 114 | /* perform standard echo handling for CAN network interfaces */ |
---|
118 | 115 | |
---|
119 | 116 | if (loop) { |
---|
120 | | - |
---|
121 | 117 | skb = can_create_echo_skb(skb); |
---|
122 | 118 | if (!skb) |
---|
123 | 119 | return NETDEV_TX_OK; |
---|
.. | .. |
---|
157 | 153 | dev->addr_len = 0; |
---|
158 | 154 | dev->tx_queue_len = 0; |
---|
159 | 155 | dev->flags = IFF_NOARP; |
---|
| 156 | + can_set_ml_priv(dev, netdev_priv(dev)); |
---|
160 | 157 | |
---|
161 | 158 | /* set flags according to driver capabilities */ |
---|
162 | 159 | if (echo) |
---|
.. | .. |
---|
167 | 164 | } |
---|
168 | 165 | |
---|
169 | 166 | static struct rtnl_link_ops vcan_link_ops __read_mostly = { |
---|
170 | | - .kind = DRV_NAME, |
---|
171 | | - .setup = vcan_setup, |
---|
| 167 | + .kind = DRV_NAME, |
---|
| 168 | + .priv_size = sizeof(struct can_ml_priv), |
---|
| 169 | + .setup = vcan_setup, |
---|
172 | 170 | }; |
---|
173 | 171 | |
---|
174 | 172 | static __init int vcan_init_module(void) |
---|
175 | 173 | { |
---|
176 | | - pr_info("vcan: Virtual CAN interface driver\n"); |
---|
| 174 | + pr_info("Virtual CAN interface driver\n"); |
---|
177 | 175 | |
---|
178 | 176 | if (echo) |
---|
179 | | - printk(KERN_INFO "vcan: enabled echo on driver level.\n"); |
---|
| 177 | + pr_info("enabled echo on driver level.\n"); |
---|
180 | 178 | |
---|
181 | 179 | return rtnl_link_register(&vcan_link_ops); |
---|
182 | 180 | } |
---|