11 #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
13 #include <linux/kernel.h>
14 #include <linux/if_arp.h>
15 #include <linux/net.h>
16 #include <linux/netdevice.h>
18 #include <linux/module.h>
54 static int caif_net_id;
55 static int q_high = 50;
111 caif_device_list(dev_net(dev));
114 list_for_each_entry_rcu(caifd, &caifdevs->
list,
list) {
130 caifd = caif_get(skb->
dev);
140 send_xoff = caifd->
xoff;
157 ctrlcmd(caifd->
layer.up,
163 static int transmit(
struct cflayer *layer,
struct cfpkt *pkt)
175 skb_reset_network_header(skb);
187 txq = netdev_get_tx_queue(skb->
dev, 0);
193 high = (caifd->
netdev->tx_queue_len * q_high) / 100;
212 pr_debug(
"queue has stopped(%d) or is full (%d > %d)\n",
213 netif_queue_stopped(caifd->
netdev),
225 rcu_read_unlock_bh();
248 caifd = caif_get(dev);
250 if (!caifd || !caifd->
layer.up || !caifd->
layer.up->receive ||
251 !netif_oper_up(caifd->
netdev)) {
261 err = caifd->
layer.up->receive(caifd->
layer.up, pkt);
280 static void dev_flowctrl(
struct net_device *dev,
int on)
286 caifd = caif_get(dev);
287 if (!caifd || !caifd->
layer.up || !caifd->
layer.up->ctrlcmd) {
304 struct cflayer *link_support,
int head_room,
305 struct cflayer **layer,
int (**rcv_func)(
314 caifdevs = caif_device_list(dev_net(dev));
315 caifd = caif_device_alloc(dev);
318 *layer = &caifd->
layer;
333 list_add_rcu(&caifd->
list, &caifdevs->
list);
336 sizeof(caifd->
layer.name) - 1);
337 caifd->
layer.name[
sizeof(caifd->
layer.name) - 1] = 0;
338 caifd->
layer.transmit = transmit;
360 struct cflayer *layer, *link_support;
365 caifdevs = caif_device_list(dev_net(dev));
367 caifd = caif_get(dev);
376 caifdev = netdev_priv(dev);
396 caifd = caif_get(dev);
411 caifd = caif_get(dev);
412 if (!caifd || !caifd->
layer.up || !caifd->
layer.up->ctrlcmd) {
448 caifd = caif_get(dev);
453 list_del_rcu(&caifd->
list);
467 if (caifd_refcnt_read(caifd) != 0 ||
470 pr_info(
"Wait for device inuse\n");
472 list_add_rcu(&caifd->
list, &caifdevs->
list);
489 .notifier_call = caif_device_notify,
494 static int caif_init_net(
struct net *
net)
497 INIT_LIST_HEAD(&caifn->
caifdevs.list);
507 static void caif_exit_net(
struct net *net)
511 caif_device_list(net);
519 list_del_rcu(&caifd->
list);
523 (caifd_refcnt_read(caifd) != 0 ||
526 pr_info(
"Wait for device inuse\n");
542 .init = caif_init_net,
543 .exit = caif_exit_net,
549 static int __init caif_device_init(
void)
564 static void __exit caif_device_exit(
void)