MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>");
-#ifdef CONFIG_CAN_DEBUG_DEVICES
-static int vcan_debug;
-module_param_named(debug, vcan_debug, int, S_IRUGO);
-#endif
-
-/* To be moved to linux/can/dev.h */
-#ifdef CONFIG_CAN_DEBUG_DEVICES
-#define DBG(fmt, args...) (vcan_debug & 1 ? \
- printk(KERN_DEBUG "vcan %s: " fmt, \
- __func__, ##args) : 0)
-#else
-#define DBG(fmt, args...)
-#endif
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
static void *kzalloc(size_t size, unsigned int __nocast flags)
{
skb->dev = dev;
skb->ip_summed = CHECKSUM_UNNECESSARY;
- DBG("received skbuff on interface %d\n", dev->ifindex);
-
netif_rx(skb);
}
#endif
int loop;
- DBG("sending skbuff on interface %s\n", dev->name);
-
stats->tx_packets++;
stats->tx_bytes += skb->len;
static void vcan_setup(struct net_device *dev)
{
- DBG("dev %s\n", dev->name);
-
dev->type = ARPHRD_CAN;
dev->mtu = sizeof(struct can_frame);
dev->hard_header_len = 0;
free_netdev(vcan_devs[i]);
vcan_devs[i] = NULL;
goto out;
-
- } else {
- DBG("successfully registered interface %s\n",
- vcan_devs[i]->name);
}
}
extern int can_send(struct sk_buff *skb, int loop);
-#ifdef CONFIG_CAN_DEBUG_CORE
-extern void can_debug_skb(struct sk_buff *skb);
-extern void can_debug_cframe(const char *msg, struct can_frame *cframe);
-#define DBG(fmt, args...) \
- do if (DBG_VAR & 1) printk(KERN_DEBUG DBG_PREFIX ": %s: " fmt, \
- __func__, ##args) : 0); \
- while (0)
-
-#define DBG_FRAME(fmt, cf) \
- do if (DBG_VAR & 2) can_debug_cframe(fmt, cf); while (0)
-
-#define DBG_SKB(skb) \
- do if (DBG_VAR & 4) can_debug_skb(skb); while (0)
-#else
-#define DBG(fmt, args...)
-#define DBG_FRAME(fmt, cf)
-#define DBG_SKB(skb)
-#endif
-
#endif /* CAN_CORE_H */
CAN messages are used on the bus (e.g. in automotive environments).
To use the Broadcast Manager, use AF_CAN with protocol CAN_BCM.
-config CAN_DEBUG_CORE
- bool "CAN Core debugging messages"
- depends on CAN
- ---help---
- Say Y here if you want the CAN core to produce a bunch of debug
- messages. Select this if you are having a problem with CAN
- support and want to see more of what is going on.
-
source "drivers/net/can/Kconfig"
module_param(stats_timer, int, S_IRUGO);
MODULE_PARM_DESC(stats_timer, "enable timer for statistics (default:on)");
-#ifdef CONFIG_CAN_DEBUG_CORE
-#define DBG_PREFIX "can"
-#define DBG_VAR can_debug
-static int can_debug __read_mostly;
-module_param_named(debug, can_debug, int, S_IRUGO);
-MODULE_PARM_DESC(debug, "debug print mask: 1:debug, 2:frames, 4:skbs");
-#endif
-
HLIST_HEAD(rx_dev_list);
static struct dev_rcv_lists rx_alldev_list;
static DEFINE_SPINLOCK(rcv_lists_lock);
static void can_sock_destruct(struct sock *sk)
{
- DBG("called for sock %p\n", sk);
-
skb_queue_purge(&sk->sk_receive_queue);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
if (sk->sk_protinfo)
char module_name[sizeof("can-proto-000")];
int err = 0;
- DBG("socket %p, type %d, proto %d\n", sock, sock->type, protocol);
-
sock->state = SS_UNCONNECTED;
if (protocol < 0 || protocol >= CAN_NPROTO)
return -EAFNOSUPPORT;
#endif
- DBG("looking up proto %d in proto_tab[]\n", protocol);
-
/* try to load protocol module, when CONFIG_KMOD is defined */
if (!proto_tab[protocol]) {
sprintf(module_name, "can-proto-%d", protocol);
sock_init_data(sock, sk);
sk->sk_destruct = can_sock_destruct;
- DBG("created sock: %p\n", sk);
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
if (sk->sk_prot->init)
err = sk->sk_prot->init(sk);
/* insert new receiver (dev,canid,mask) -> (func,data) */
- DBG("dev %p (%s), id %03X, mask %03X, callback %p, data %p, "
- "ident %s\n", dev, DNAME(dev), can_id, mask, func, data, ident);
-
r = kmem_cache_alloc(rcv_cache, GFP_KERNEL);
if (!r)
return -ENOMEM;
if (pstats.rcv_entries_max < pstats.rcv_entries)
pstats.rcv_entries_max = pstats.rcv_entries;
} else {
- DBG("receive list not found for dev %s, id %03X, mask %03X\n",
- DNAME(dev), can_id, mask);
kmem_cache_free(rcv_cache, r);
err = -ENODEV;
}
{
struct dev_rcv_lists *d = container_of(rp, struct dev_rcv_lists, rcu);
- DBG("removing dev_rcv_list at %p\n", d);
kfree(d);
}
{
struct receiver *r = container_of(rp, struct receiver, rcu);
- DBG("removing receiver at %p\n", r);
kmem_cache_free(rcv_cache, r);
}
struct hlist_node *next;
struct dev_rcv_lists *d;
- DBG("dev %p (%s), id %03X, mask %03X, callback %p, data %p\n",
- dev, DNAME(dev), can_id, mask, func, data);
-
spin_lock(&rcv_lists_lock);
d = find_dev_rcv_lists(dev);
pstats.rcv_entries--;
/* remove device structure requested by NETDEV_UNREGISTER */
- if (d->remove_on_zero_entries && !d->entries) {
- DBG("removing dev_rcv_list for %s on zero entries\n",
- dev->name);
+ if (d->remove_on_zero_entries && !d->entries)
hlist_del_rcu(&d->list);
- } else
+ else
d = NULL;
out:
{
struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
- DBG("skbuff %p cloned to %p\n", skb, clone);
if (clone) {
clone->sk = skb->sk;
r->func(clone, r->data);
/* check for error frame entries only */
hlist_for_each_entry_rcu(r, n, &d->rx[RX_ERR], list) {
if (can_id & r->mask) {
- DBG("match on rx_err skbuff %p\n", skb);
deliver(skb, r);
matches++;
}
/* check for unfiltered entries */
hlist_for_each_entry_rcu(r, n, &d->rx[RX_ALL], list) {
- DBG("match on rx_all skbuff %p\n", skb);
deliver(skb, r);
matches++;
}
/* check for can_id/mask entries */
hlist_for_each_entry_rcu(r, n, &d->rx[RX_FIL], list) {
if ((can_id & r->mask) == r->can_id) {
- DBG("match on rx_fil skbuff %p\n", skb);
deliver(skb, r);
matches++;
}
/* check for inverted can_id/mask entries */
hlist_for_each_entry_rcu(r, n, &d->rx[RX_INV], list) {
if ((can_id & r->mask) != r->can_id) {
- DBG("match on rx_inv skbuff %p\n", skb);
deliver(skb, r);
matches++;
}
if (can_id & CAN_EFF_FLAG) {
hlist_for_each_entry_rcu(r, n, &d->rx[RX_EFF], list) {
if (r->can_id == can_id) {
- DBG("match on rx_eff skbuff %p\n", skb);
deliver(skb, r);
matches++;
}
} else {
can_id &= CAN_SFF_MASK;
hlist_for_each_entry_rcu(r, n, &d->rx_sff[can_id], list) {
- DBG("match on rx_sff skbuff %p\n", skb);
deliver(skb, r);
matches++;
}
struct dev_rcv_lists *d;
int matches;
- DBG("received skbuff on device %s, ptype %04x\n",
- dev->name, ntohs(pt->type));
- DBG_SKB(skb);
- DBG_FRAME("can: can_rcv: received CAN frame",
- (struct can_frame *)skb->data);
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
if (dev->type != ARPHRD_CAN || dev->nd_net != &init_net) {
#else
rcu_read_unlock();
/* free the skbuff allocated by the netdevice driver */
- DBG("freeing skbuff %p\n", skb);
kfree_skb(skb);
if (matches > 0) {
struct net_device *dev = (struct net_device *)data;
struct dev_rcv_lists *d;
- DBG("msg %ld for dev %p (%s idx %d)\n",
- msg, dev, dev->name, dev->ifindex);
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
if (dev->nd_net != &init_net)
return NOTIFY_DONE;
* explicit initialization.
*/
- DBG("creating new dev_rcv_lists for %s\n", dev->name);
-
d = kzalloc(sizeof(*d), GFP_KERNEL);
if (!d) {
printk(KERN_ERR
d = find_dev_rcv_lists(dev);
if (d) {
- DBG("remove dev_rcv_list for %s (%d entries)\n",
- dev->name, d->entries);
-
if (d->entries) {
d->remove_on_zero_entries = 1;
d = NULL;
return NOTIFY_DONE;
}
-/*
- * af_can debugging stuff
- */
-
-#ifdef CONFIG_CAN_DEBUG_CORE
-
-/**
- * can_debug_cframe - print CAN frame
- * @msg: pointer to message printed before the given CAN frame
- * @cf: pointer to CAN frame
- */
-void can_debug_cframe(const char *msg, struct can_frame *cf)
-{
- char idbuf[12];
- char hexbuf[28];
- int dlc;
-
- dlc = cf->can_dlc;
- if (dlc > 8)
- dlc = 8;
-
- if (cf->can_id & CAN_EFF_FLAG)
- sprintf(idbuf, "<%08X>", cf->can_id & CAN_EFF_MASK);
- else
- sprintf(idbuf, "<%03X>", cf->can_id & CAN_SFF_MASK);
-
- if (cf->can_id & CAN_RTR_FLAG)
- sprintf(hexbuf, "(RTR)");
- else
- hex_dump_to_buffer(cf->data, dlc, 16, 1, hexbuf, 28, 0);
-
- printk(KERN_DEBUG "%s: %s [%d] %s\n", msg, idbuf, dlc, hexbuf);
-}
-EXPORT_SYMBOL(can_debug_cframe);
-
-/**
- * can_debug_skb - print socket buffer content to kernel log
- * @skb: pointer to socket buffer
- */
-void can_debug_skb(struct sk_buff *skb)
-{
- printk(KERN_DEBUG " skbuff at %p, dev: %d, proto: %04x\n"
- KERN_DEBUG " users: %d, dataref: %d, nr_frags: %d, "
- "h,d,t,e,l: %p %+d %+d %+d, %d\n",
- skb, skb->dev ? skb->dev->ifindex : -1,
- ntohs(skb->protocol),
- atomic_read(&skb->users),
- atomic_read(&(skb_shinfo(skb)->dataref)),
- skb_shinfo(skb)->nr_frags,
- skb->head, skb->data - skb->head,
- skb->tail - skb->head, skb->end - skb->head, skb->len);
-
- print_hex_dump(KERN_DEBUG, "skb_head: ", DUMP_PREFIX_NONE,
- 16, 1, skb->head, skb->end - skb->head, 0);
-}
-EXPORT_SYMBOL(can_debug_skb);
-
-#endif
-
/*
* af_can module init/exit functions
*/
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
-#ifdef CONFIG_CAN_DEBUG_CORE
-#define DBG_PREFIX "can-bcm"
-#define DBG_VAR bcm_debug
-static int bcm_debug;
-module_param_named(debug, bcm_debug, int, S_IRUGO);
-MODULE_PARM_DESC(debug, "debug print mask: 1:debug, 2:frames, 4:skbs");
-#endif
-
/* easy access to can_frame payload */
static inline u64 GET_U64(const struct can_frame *cp)
{
struct net_device *dev;
struct can_frame *cf = &op->frames[op->currframe];
- DBG_FRAME("BCM: bcm_can_tx: sending frame", cf);
-
/* no target device? => exit */
if (!op->ifindex)
return;
if (err < 0) {
struct bcm_sock *bo = bcm_sk(sk);
- DBG("sock_queue_rcv_skb failed: %d\n", err);
kfree_skb(skb);
/* don't care about overflows in this statistic */
bo->dropped_usr_msgs++;
{
struct bcm_op *op = (struct bcm_op *)data;
- DBG("Called with bcm_op %p\n", op);
-
if (op->j_ival1 && (op->count > 0)) {
op->count--;
struct bcm_msg_head msg_head;
/* create notification to user */
- DBG("sending TX_EXPIRED for can_id %03X\n",
- op->can_id);
-
msg_head.opcode = TX_EXPIRED;
msg_head.flags = op->flags;
msg_head.count = op->count;
}
}
- DBG("count=%d j_ival1=%ld j_ival2=%ld\n",
- op->count, op->j_ival1, op->j_ival2);
-
if (op->j_ival1 && (op->count > 0)) {
op->timer.expires = jiffies + op->j_ival1;
add_timer(&op->timer);
- DBG("adding timer ival1. func=%p data=%p exp=0x%08X\n",
- op->timer.function,
- (char *) op->timer.data,
- (unsigned int) op->timer.expires);
-
/* send (next) frame */
bcm_can_tx(op);
op->timer.expires = jiffies + op->j_ival2;
add_timer(&op->timer);
- DBG("adding timer ival2. func=%p data=%p exp=0x%08X\n",
- op->timer.function,
- (char *) op->timer.data,
- (unsigned int) op->timer.expires);
-
/* send (next) frame */
bcm_can_tx(op);
- } else
- DBG("no timer restart\n");
+ }
}
return;
if (op->frames_filtered > ULONG_MAX/100)
op->frames_filtered = op->frames_abs = 0;
- DBG("setting j_lastmsg to 0x%08X for rx_op %p\n",
- (unsigned int) op->j_lastmsg, op);
- DBG("sending notification\n");
-
head.opcode = RX_CHANGED;
head.flags = op->flags;
head.count = op->count;
/* start the timer only the first time */
op->thrtimer.expires = nexttx;
add_timer(&op->thrtimer);
-
- DBG("adding thrtimer. func=%p data=%p exp=0x%08X\n",
- op->thrtimer.function,
- (char *) op->thrtimer.data,
- (unsigned int) op->thrtimer.expires);
}
} else {
if (!(op->last_frames[index].can_dlc & RX_RECV)) {
/* received data for the first time => send update to user */
- DBG("first time :)\n");
bcm_rx_update_and_send(op, &op->last_frames[index], rxdata);
return;
}
/* do a real check in can_frame data section */
- DBG("op->frames[index].data = 0x%016llx\n",
- GET_U64(&op->frames[index]));
- DBG("op->last_frames[index].data = 0x%016llx\n",
- GET_U64(&op->last_frames[index]));
- DBG("rxdata->data = 0x%016llx\n", GET_U64(rxdata));
-
if ((GET_U64(&op->frames[index]) & GET_U64(rxdata)) !=
(GET_U64(&op->frames[index]) & GET_U64(&op->last_frames[index]))) {
- DBG("relevant data change :)\n");
bcm_rx_update_and_send(op, &op->last_frames[index], rxdata);
return;
}
/* do a real check in can_frame dlc */
if (rxdata->can_dlc != (op->last_frames[index].can_dlc &
BCM_CAN_DLC_MASK)) {
- DBG("dlc change :)\n");
bcm_rx_update_and_send(op, &op->last_frames[index],
rxdata);
return;
}
}
- DBG("no relevant change :(\n");
}
/*
if (op->j_ival1) {
op->timer.expires = jiffies + op->j_ival1;
-
- DBG("adding rx timeout timer ival1. func=%p data=%p "
- "exp=0x%08X\n",
- op->timer.function,
- (char *) op->timer.data,
- (unsigned int) op->timer.expires);
-
add_timer(&op->timer);
}
}
struct bcm_op *op = (struct bcm_op *)data;
struct bcm_msg_head msg_head;
- DBG("sending RX_TIMEOUT for can_id %03X. op is %p\n", op->can_id, op);
-
msg_head.opcode = RX_TIMEOUT;
msg_head.flags = op->flags;
msg_head.count = op->count;
if ((op->flags & RX_ANNOUNCE_RESUME) && op->last_frames) {
/* clear received can_frames to indicate 'nothing received' */
memset(op->last_frames, 0, op->nframes * CFSIZ);
- DBG("RX_ANNOUNCE_RESTART\n");
}
}
op->thrtimer.expires = 0;
if (op->nframes > 1) {
- DBG("sending MUX RX_CHANGED for can_id %03X. op is %p\n",
- op->can_id, op);
/* for MUX filter we start at index 1 */
for (i = 1; i < op->nframes; i++) {
if ((op->last_frames) &&
}
} else {
- DBG("sending simple RX_CHANGED for can_id %03X. op is %p\n",
- op->can_id, op);
/* for RX_FILTER_ID and simple filter */
if (op->last_frames && (op->last_frames[0].can_dlc & RX_THR)) {
op->last_frames[0].can_dlc &= ~RX_THR;
/* disable timeout */
del_timer(&op->timer);
- DBG("Called with bcm_op %p\n", op);
-
if (skb->len == sizeof(rxframe)) {
memcpy(&rxframe, skb->data, sizeof(rxframe));
/* save rx timestamp */
/* update statistics */
op->frames_abs++;
kfree_skb(skb);
- DBG("got can_frame with can_id %03X\n", rxframe.can_id);
} else {
- DBG("Wrong skb->len = %d\n", skb->len);
kfree_skb(skb);
return;
}
- DBG_FRAME("BCM: bcm_rx_handler: CAN frame", &rxframe);
-
- if (op->can_id != rxframe.can_id) {
- DBG("ERROR! Got wrong can_id %03X! Expected %03X.\n",
- rxframe.can_id, op->can_id);
+ if (op->can_id != rxframe.can_id)
return;
- }
if (op->flags & RX_RTR_FRAME) {
/* send reply for RTR-request */
- DBG("RTR-request\n");
-
/* send op->frames[0] to CAN device */
bcm_can_tx(op);
return;
if (op->flags & RX_FILTER_ID) {
/* the easiest case */
- DBG("Easy does it with RX_FILTER_ID\n");
bcm_rx_update_and_send(op, &op->last_frames[0], &rxframe);
bcm_rx_starttimer(op);
if (op->nframes == 1) {
/* simple compare with index 0 */
- DBG("Simple compare\n");
bcm_rx_cmp_to_index(op, 0, &rxframe);
bcm_rx_starttimer(op);
}
if (op->nframes > 1) {
- /* multiplex compare */
- DBG("Multiplex compare\n");
-
- /*
+ /* multiplex compare
+ *
* find the first multiplex mask that fits.
* Remark: The MUX-mask is stored in index 0
*/
if ((GET_U64(&op->frames[0]) & GET_U64(&rxframe)) ==
(GET_U64(&op->frames[0]) &
GET_U64(&op->frames[i]))) {
- DBG("found MUX index %d\n", i);
bcm_rx_cmp_to_index(op, i, &rxframe);
break;
}
list_for_each_entry_safe(op, n, ops, list) {
if ((op->can_id == can_id) && (op->ifindex == ifindex)) {
- DBG("removing rx_op %p for can_id %03X\n",
- op, op->can_id);
/*
* Don't care if we're bound or not (due to netdev
list_for_each_entry_safe(op, n, ops, list) {
if ((op->can_id == can_id) && (op->ifindex == ifindex)) {
- DBG("removing rx_op %p for can_id %03X\n",
- op, op->can_id);
list_del(&op->list);
bcm_remove_op(op);
return 1; /* done */
{
struct bcm_op *op = bcm_find_op(ops, msg_head->can_id, ifindex);
- if (!op) {
- DBG("TRX_READ: did not find op for can_id %03X\n",
- msg_head->can_id);
+ if (!op)
return -EINVAL;
- }
- DBG("TRX_READ: sending status for can_id %03X\n",
- msg_head->can_id);
/* put current values into msg_head */
msg_head->flags = op->flags;
msg_head->count = op->count;
op = bcm_find_op(&bo->tx_ops, msg_head->can_id, ifindex);
if (op) {
- /* update existing BCM operation */
-
- DBG("TX_SETUP: modifying existing tx_op %p for can_id %03X\n",
- op, msg_head->can_id);
-
- /*
+ /* update existing BCM operation
+ *
* Do we need more space for the can_frames than currently
* allocated? -> This is a _really_ unusual use-case and
* therefore (complexity / locking) it is not supported.
if (!op)
return -ENOMEM;
- DBG("TX_SETUP: creating new tx_op %p for can_id %03X\n",
- op, msg_head->can_id);
-
op->can_id = msg_head->can_id;
/* create array for can_frames and copy the data */
op->j_ival1 = rounded_tv2jif(&msg_head->ival1);
op->j_ival2 = rounded_tv2jif(&msg_head->ival2);
- DBG("TX_SETUP: SETTIMER count=%d j_ival1=%ld j_ival2=%ld\n",
- op->count, op->j_ival1, op->j_ival2);
-
/* disable an active timer due to zero values? */
- if (!op->j_ival1 && !op->j_ival2) {
+ if (!op->j_ival1 && !op->j_ival2)
del_timer(&op->timer);
- DBG("TX_SETUP: SETTIMER disabled timer.\n");
- }
}
if ((op->flags & STARTTIMER) &&
if (op->j_ival1 && (op->count > 0)) {
op->timer.expires = jiffies + op->j_ival1;
/* op->count-- is done in bcm_tx_timeout_handler */
- DBG("TX_SETUP: adding timer ival1. func=%p data=%p "
- "exp=0x%08X\n",
- op->timer.function,
- (char *) op->timer.data,
- (unsigned int) op->timer.expires);
-
- } else {
+ } else
op->timer.expires = jiffies + op->j_ival2;
- DBG("TX_SETUP: adding timer ival2. func=%p data=%p "
- "exp=0x%08X\n",
- op->timer.function,
- (char *) op->timer.data,
- (unsigned int) op->timer.expires);
- }
add_timer(&op->timer);
}
if ((msg_head->flags & RX_RTR_FRAME) &&
((msg_head->nframes != 1) ||
- (!(msg_head->can_id & CAN_RTR_FLAG)))) {
-
- DBG("RX_SETUP: bad RX_RTR_FRAME setup!\n");
+ (!(msg_head->can_id & CAN_RTR_FLAG))))
return -EINVAL;
- }
/* check the given can_id */
op = bcm_find_op(&bo->rx_ops, msg_head->can_id, ifindex);
if (op) {
- /* update existing BCM operation */
-
- DBG("RX_SETUP: modifying existing rx_op %p for can_id %03X\n",
- op, msg_head->can_id);
-
- /*
+ /* update existing BCM operation
+ *
* Do we need more space for the can_frames than currently
* allocated? -> This is a _really_ unusual use-case and
* therefore (complexity / locking) it is not supported.
if (!op)
return -ENOMEM;
- DBG("RX_SETUP: creating new rx_op %p for can_id %03X\n",
- op, msg_head->can_id);
-
op->can_id = msg_head->can_id;
op->nframes = msg_head->nframes;
op->j_ival1 = rounded_tv2jif(&msg_head->ival1);
op->j_ival2 = rounded_tv2jif(&msg_head->ival2);
- DBG("RX_SETUP: SETTIMER j_ival1=%ld j_ival2=%ld\n",
- op->j_ival1, op->j_ival2);
-
/* disable an active timer due to zero value? */
- if (!op->j_ival1) {
+ if (!op->j_ival1)
del_timer(&op->timer);
- DBG("RX_SETUP: disabled timer rx timeouts.\n");
- }
/* free currently blocked msgs ? */
if (op->thrtimer.expires) {
- DBG("RX_SETUP: unblocking throttled msgs.\n");
del_timer(&op->thrtimer);
/* send blocked msgs hereafter */
op->thrtimer.expires = jiffies + 2;
}
if ((op->flags & STARTTIMER) && op->j_ival1) {
-
del_timer(&op->timer);
op->timer.expires = jiffies + op->j_ival1;
-
- DBG("RX_SETUP: adding timer ival1. func=%p data=%p"
- " exp=0x%08X\n",
- (char *) op->timer.function,
- (char *) op->timer.data,
- (unsigned int) op->timer.expires);
-
add_timer(&op->timer);
}
}
/* now we can register for can_ids, if we added a new bcm_op */
if (do_rx_register) {
- DBG("RX_SETUP: can_rx_register() for can_id %03X. "
- "rx_op is %p\n", op->can_id, op);
-
if (ifindex) {
struct net_device *dev;
return err;
}
- DBG_FRAME("BCM: TX_SEND: sending frame",
- (struct can_frame *)skb->data);
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
dev = dev_get_by_index(&init_net, ifindex);
#else
struct bcm_msg_head msg_head;
int ret; /* read bytes or error codes as return value */
- if (!bo->bound) {
- DBG("sock %p not bound\n", sk);
+ if (!bo->bound)
return -ENOTCONN;
- }
/* check for alternative ifindex for this bcm_op */
#else
dev = dev_get_by_index(ifindex);
#endif
- if (!dev) {
- DBG("device %d not found\n", ifindex);
+ if (!dev)
return -ENODEV;
- }
if (dev->type != ARPHRD_CAN) {
- DBG("device %d no CAN device\n", ifindex);
dev_put(dev);
return -ENODEV;
}
if (ret < 0)
return ret;
- DBG("opcode %d for can_id %03X\n", msg_head.opcode, msg_head.can_id);
-
lock_sock(sk);
switch (msg_head.opcode) {
break;
default:
- DBG("Unknown opcode %d\n", msg_head.opcode);
ret = -EINVAL;
break;
}
struct bcm_op *op;
int notify_enodev = 0;
- DBG("msg %ld for dev %p (%s idx %d) sk %p bo->ifindex %d\n",
- msg, dev, dev->name, dev->ifindex, sk, bo->ifindex);
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
if (dev->nd_net != &init_net)
return NOTIFY_DONE;
struct bcm_sock *bo = bcm_sk(sk);
struct bcm_op *op, *next;
- DBG("socket %p, sk %p\n", sock, sk);
-
/* remove bcm_ops, timer, rx_unregister(), etc. */
unregister_netdevice_notifier(&bo->notifier);
lock_sock(sk);
- list_for_each_entry_safe(op, next, &bo->tx_ops, list) {
- DBG("removing tx_op %p for can_id %03X\n", op, op->can_id);
+ list_for_each_entry_safe(op, next, &bo->tx_ops, list)
bcm_remove_op(op);
- }
list_for_each_entry_safe(op, next, &bo->rx_ops, list) {
- DBG("removing rx_op %p for can_id %03X\n", op, op->can_id);
-
/*
* Don't care if we're bound or not (due to netdev problems)
* can_rx_unregister() is always a save thing to do here.
#else
dev = dev_get_by_index(addr->can_ifindex);
#endif
- if (!dev) {
- DBG("could not find device index %d\n",
- addr->can_ifindex);
+ if (!dev)
return -ENODEV;
- }
if (dev->type != ARPHRD_CAN) {
- DBG("device %d no CAN device\n", addr->can_ifindex);
dev_put(dev);
return -ENODEV;
}
bo->ifindex = dev->ifindex;
dev_put(dev);
- DBG("socket %p bound to device %s (idx %d)\n",
- sock, dev->name, dev->ifindex);
-
} else {
/* no interface reference for ifindex = 0 ('any' CAN device) */
bo->ifindex = 0;
int noblock;
int err;
- DBG("socket %p, sk %p\n", sock, sk);
-
noblock = flags & MSG_DONTWAIT;
flags &= ~MSG_DONTWAIT;
skb = skb_recv_datagram(sk, flags, noblock, &error);
if (!skb)
return error;
- DBG("delivering skbuff %p\n", skb);
- DBG_SKB(skb);
-
if (skb->len < size)
size = skb->len;
memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
}
- DBG("freeing sock %p, skbuff %p\n", sk, skb);
skb_free_datagram(sk, skb);
return size;
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>");
-#ifdef CONFIG_CAN_DEBUG_CORE
-#define DBG_PREFIX "can-raw"
-#define DBG_VAR raw_debug
-static int raw_debug;
-module_param_named(debug, raw_debug, int, S_IRUGO);
-MODULE_PARM_DESC(debug, "debug print mask: 1:debug, 2:frames, 4:skbs");
-#endif
-
#define MASK_ALL 0
/*
struct sockaddr_can *addr;
int error;
- DBG("received skbuff %p, sk %p\n", skb, sk);
- DBG_SKB(skb);
-
if (!ro->recv_own_msgs) {
/* check the received tx sock reference */
if (skb->sk == sk) {
- DBG("trashed own tx msg\n");
kfree_skb(skb);
return;
}
addr->can_ifindex = skb->dev->ifindex;
error = sock_queue_rcv_skb(sk, skb);
- if (error < 0) {
- DBG("sock_queue_rcv_skb failed: %d\n", error);
- DBG("freeing skbuff %p\n", skb);
+ if (error < 0)
kfree_skb(skb);
- }
}
static int raw_enable_filters(struct net_device *dev, struct sock *sk,
int i;
for (i = 0; i < count; i++) {
- DBG("filter can_id %08X, can_mask %08X%s, sk %p\n",
- filter[i].can_id, filter[i].can_mask,
- filter[i].can_id & CAN_INV_FILTER ? " (inv)" : "", sk);
-
err = can_rx_register(dev, filter[i].can_id,
filter[i].can_mask,
raw_rcv, sk, "raw");
-
if (err) {
/* clean up successfully registered filters */
while (--i >= 0)
{
int i;
- for (i = 0; i < count; i++) {
- DBG("filter can_id %08X, can_mask %08X%s, sk %p\n",
- filter[i].can_id, filter[i].can_mask,
- filter[i].can_id & CAN_INV_FILTER ? " (inv)" : "", sk);
-
+ for (i = 0; i < count; i++)
can_rx_unregister(dev, filter[i].can_id, filter[i].can_mask,
raw_rcv, sk);
- }
}
static inline void raw_disable_errfilter(struct net_device *dev,
struct sock *sk = ro->sk;
#endif
- DBG("msg %ld for dev %p (%s idx %d) sk %p ro->ifindex %d\n",
- msg, dev, dev->name, dev->ifindex, sk, ro->ifindex);
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
if (dev->nd_net != &init_net)
return NOTIFY_DONE;
struct sock *sk = sock->sk;
struct raw_sock *ro = raw_sk(sk);
- DBG("socket %p, sk %p, refcnt %d\n", sock, sk,
- atomic_read(&sk->sk_refcnt));
-
unregister_netdevice_notifier(&ro->notifier);
lock_sock(sk);
int err = 0;
int notify_enetdown = 0;
- DBG("socket %p to device %d\n", sock, addr->can_ifindex);
-
if (len < sizeof(*addr))
return -EINVAL;
dev = dev_get_by_index(addr->can_ifindex);
#endif
if (!dev) {
- DBG("could not find device %d\n", addr->can_ifindex);
err = -ENODEV;
goto out;
}
if (dev->type != ARPHRD_CAN) {
- DBG("device %d no CAN device\n", addr->can_ifindex);
dev_put(dev);
err = -ENODEV;
goto out;
int ifindex;
int err;
- DBG("socket %p, sk %p\n", sock, sk);
-
if (msg->msg_name) {
struct sockaddr_can *addr =
(struct sockaddr_can *)msg->msg_name;
#else
dev = dev_get_by_index(ifindex);
#endif
- if (!dev) {
- DBG("device %d not found\n", ifindex);
+ if (!dev)
return -ENXIO;
- }
skb = sock_alloc_send_skb(sk, size, msg->msg_flags & MSG_DONTWAIT,
&err);
skb->dev = dev;
skb->sk = sk;
- DBG("sending skbuff to interface %d\n", ifindex);
- DBG_SKB(skb);
-
err = can_send(skb, ro->loopback);
dev_put(dev);
int error = 0;
int noblock;
- DBG("socket %p, sk %p\n", sock, sk);
-
noblock = flags & MSG_DONTWAIT;
flags &= ~MSG_DONTWAIT;
if (!skb)
return error;
- DBG("delivering skbuff %p\n", skb);
- DBG_SKB(skb);
-
if (size < skb->len)
msg->msg_flags |= MSG_TRUNC;
else
memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
}
- DBG("freeing sock %p, skbuff %p\n", sk, skb);
skb_free_datagram(sk, skb);
return size;