speedtch usbatm.c,1.49,1.50 usbatm.h,1.21,1.22
Duncan Sands
duncan at infradead.org
Fri Sep 30 05:56:54 EDT 2005
Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv20504
Modified Files:
usbatm.c usbatm.h
Log Message:
Make Matthieu happy by rate limiting debugging output. Change some
KERN_DEBUG log levels to something more serious. Decisions as to when
things are errors vs warnings etc were made kind of arbitrarily -
suggestions welcome.
Index: usbatm.c
===================================================================
RCS file: /home/cvs/speedtch/usbatm.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- usbatm.c 26 Sep 2005 20:19:41 -0000 1.49
+++ usbatm.c 30 Sep 2005 09:56:51 -0000 1.50
@@ -234,8 +234,9 @@
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret) {
- atm_dbg(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n",
- __func__, urb, ret);
+ if (printk_ratelimit())
+ atm_warn(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n",
+ __func__, urb, ret);
/* consider all errors transient and return the buffer back to the queue */
urb->status = -EAGAIN;
@@ -317,7 +318,7 @@
cached_vcc = usbatm_find_vcc(instance, vpi, vci);
if (!cached_vcc)
- atm_dbg(instance, "%s: unknown vpi/vci (%hd/%d)!\n", __func__, vpi, vci);
+ atm_rldbg(instance, "%s: unknown vpi/vci (%hd/%d)!\n", __func__, vpi, vci);
}
if (!cached_vcc)
@@ -327,7 +328,9 @@
/* OAM F5 end-to-end */
if (pti == ATM_PTI_E2EF5) {
- atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n", __func__, vpi, vci);
+ if (printk_ratelimit())
+ atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
+ __func__, vpi, vci);
atomic_inc(&vcc->stats->rx_err);
continue;
}
@@ -335,8 +338,8 @@
sarb = cached_vcc->sarb;
if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) {
- atm_dbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n",
- __func__, sarb->len, vcc);
+ atm_rldbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n",
+ __func__, sarb->len, vcc);
/* discard cells already received */
skb_trim(sarb, 0);
UDSL_ASSERT(sarb->tail + ATM_CELL_PAYLOAD <= sarb->end);
@@ -354,8 +357,8 @@
/* guard against overflow */
if (length > ATM_MAX_AAL5_PDU) {
- atm_dbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
- __func__, length, vcc);
+ atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
+ __func__, length, vcc);
atomic_inc(&vcc->stats->rx_err);
goto out;
}
@@ -363,15 +366,15 @@
pdu_length = usbatm_pdu_length(length);
if (sarb->len < pdu_length) {
- atm_dbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
- __func__, pdu_length, sarb->len, vcc);
+ atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
+ __func__, pdu_length, sarb->len, vcc);
atomic_inc(&vcc->stats->rx_err);
goto out;
}
if (crc32_be(~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
- atm_dbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
- __func__, vcc);
+ atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
+ __func__, vcc);
atomic_inc(&vcc->stats->rx_err);
goto out;
}
@@ -379,7 +382,9 @@
vdbg("%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", __func__, length, pdu_length, vcc);
if (!(skb = dev_alloc_skb(length))) {
- atm_dbg(instance, "%s: no memory for skb (length: %u)!\n", __func__, length);
+ if (printk_ratelimit())
+ atm_err(instance, "%s: no memory for skb (length: %u)!\n",
+ __func__, length);
atomic_inc(&vcc->stats->rx_drop);
goto out;
}
@@ -387,7 +392,8 @@
vdbg("%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", __func__, skb, skb->truesize);
if (!atm_charge(vcc, skb->truesize)) {
- atm_dbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n", __func__, skb->truesize);
+ atm_rldbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n",
+ __func__, skb->truesize);
dev_kfree_skb(skb);
goto out; /* atm_charge increments rx_drop */
}
@@ -594,20 +600,23 @@
vdbg("%s called (skb 0x%p, len %u)", __func__, skb, skb->len);
if (!instance) {
- dbg("%s: NULL data!", __func__);
+#ifdef DEBUG
+ if (printk_ratelimit())
+ printk(KERN_DEBUG "%s: NULL data!\n", __func__);
+#endif
err = -ENODEV;
goto fail;
}
if (vcc->qos.aal != ATM_AAL5) {
- atm_dbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
+ atm_rldbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
err = -EINVAL;
goto fail;
}
if (skb->len > ATM_MAX_AAL5_PDU) {
- atm_dbg(instance, "%s: packet too long (%d vs %d)!\n",
- __func__, skb->len, ATM_MAX_AAL5_PDU);
+ atm_rldbg(instance, "%s: packet too long (%d vs %d)!\n",
+ __func__, skb->len, ATM_MAX_AAL5_PDU);
err = -EINVAL;
goto fail;
}
@@ -735,9 +744,14 @@
atm_dbg(instance, "%s: vpi %hd, vci %d\n", __func__, vpi, vci);
/* only support AAL5 */
- if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0)
- || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
- atm_dbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
+ if ((vcc->qos.aal != ATM_AAL5)) {
+ atm_warn(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
+ return -EINVAL;
+ }
+
+ /* sanity checks */
+ if ((vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
+ atm_dbg(instance, "%s: max_sdu %d out of range!\n", __func__, vcc->qos.rxtp.max_sdu);
return -EINVAL;
}
@@ -750,7 +764,7 @@
}
if (!(new = kzalloc(sizeof(struct usbatm_vcc_data), GFP_KERNEL))) {
- atm_dbg(instance, "%s: no memory for vcc_data!\n", __func__);
+ atm_err(instance, "%s: no memory for vcc_data!\n", __func__);
ret = -ENOMEM;
goto fail;
}
@@ -761,7 +775,7 @@
new->sarb = alloc_skb(usbatm_pdu_length(vcc->qos.rxtp.max_sdu), GFP_KERNEL);
if (!new->sarb) {
- atm_dbg(instance, "%s: no memory for SAR buffer!\n", __func__);
+ atm_err(instance, "%s: no memory for SAR buffer!\n", __func__);
ret = -ENOMEM;
goto fail;
}
@@ -847,7 +861,7 @@
/* ATM init */
atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL);
if (!atm_dev) {
- usb_dbg(instance, "%s: failed to register ATM device!\n", __func__);
+ usb_err(instance, "%s: failed to register ATM device!\n", __func__);
return -1;
}
@@ -861,7 +875,7 @@
atm_dev->link_rate = 128 * 1000 / 424;
if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) {
- atm_dbg(instance, "%s: atm_start failed: %d!\n", __func__, ret);
+ atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret);
goto fail;
}
@@ -914,7 +928,7 @@
int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_KERNEL);
if (ret < 0) {
- usb_dbg(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret);
+ usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret);
return ret;
}
Index: usbatm.h
===================================================================
RCS file: /home/cvs/speedtch/usbatm.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- usbatm.h 26 Sep 2005 20:19:41 -0000 1.21
+++ usbatm.h 30 Sep 2005 09:56:51 -0000 1.22
@@ -30,6 +30,7 @@
#include <linux/completion.h>
#include <linux/config.h>
#include <linux/device.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/stringify.h>
@@ -78,9 +79,14 @@
#ifdef DEBUG
#define atm_dbg(instance, format, arg...) \
atm_printk(KERN_DEBUG, instance , format , ## arg)
+#define atm_rldbg(instance, format, arg...) \
+ if (printk_ratelimit()) \
+ atm_printk(KERN_DEBUG, instance , format , ## arg)
#else
#define atm_dbg(instance, format, arg...) \
do {} while (0)
+#define atm_rldbg(instance, format, arg...) \
+ do {} while (0)
#endif
More information about the Usbatm-commits
mailing list