Commit bce83697 authored by David Vrabel's avatar David Vrabel

uwb: use dev_dbg() for debug messages

Instead of the home-grown d_fnstart(), d_fnend() and d_printf() macros,
use dev_dbg() or remove the message entirely.
Signed-off-by: default avatarDavid Vrabel <david.vrabel@csr.com>
parent 02f11ee1
......@@ -62,16 +62,12 @@
#include "../wusbcore/wa-hc.h"
#include "../wusbcore/wusbhc.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
struct hwahc {
struct wusbhc wusbhc; /* has to be 1st */
struct wahc wa;
u8 buffer[16]; /* for misc usb transactions */
};
/**
/*
* FIXME should be wusbhc
*
* NOTE: we need to cache the Cluster ID because later...there is no
......@@ -125,7 +121,6 @@ static int hwahc_op_reset(struct usb_hcd *usb_hcd)
struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
struct device *dev = &hwahc->wa.usb_iface->dev;
d_fnstart(4, dev, "(hwahc %p)\n", hwahc);
mutex_lock(&wusbhc->mutex);
wa_nep_disarm(&hwahc->wa);
result = __wa_set_feature(&hwahc->wa, WA_RESET);
......@@ -133,7 +128,6 @@ static int hwahc_op_reset(struct usb_hcd *usb_hcd)
dev_err(dev, "error commanding HC to reset: %d\n", result);
goto error_unlock;
}
d_printf(3, dev, "reset: waiting for device to change state\n");
result = __wa_wait_status(&hwahc->wa, WA_STATUS_RESETTING, 0);
if (result < 0) {
dev_err(dev, "error waiting for HC to reset: %d\n", result);
......@@ -141,7 +135,6 @@ static int hwahc_op_reset(struct usb_hcd *usb_hcd)
}
error_unlock:
mutex_unlock(&wusbhc->mutex);
d_fnend(4, dev, "(hwahc %p) = %d\n", hwahc, result);
return result;
}
......@@ -154,15 +147,9 @@ static int hwahc_op_start(struct usb_hcd *usb_hcd)
int result;
struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd);
struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
struct device *dev = &hwahc->wa.usb_iface->dev;
/* Set up a Host Info WUSB Information Element */
d_fnstart(4, dev, "(hwahc %p)\n", hwahc);
result = -ENOSPC;
mutex_lock(&wusbhc->mutex);
/* Start the numbering from the top so that the bottom
* range of the unauth addr space is used for devices,
* the top for HCs; use 0xfe - RC# */
addr = wusb_cluster_id_get();
if (addr == 0)
goto error_cluster_id_get;
......@@ -176,7 +163,6 @@ static int hwahc_op_start(struct usb_hcd *usb_hcd)
result = 0;
out:
mutex_unlock(&wusbhc->mutex);
d_fnend(4, dev, "(hwahc %p) = %d\n", hwahc, result);
return result;
error_set_cluster_id:
......@@ -213,18 +199,11 @@ static int hwahc_op_resume(struct usb_hcd *usb_hcd)
*/
static void hwahc_op_stop(struct usb_hcd *usb_hcd)
{
int result;
struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd);
struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
struct wahc *wa = &hwahc->wa;
struct device *dev = &wa->usb_iface->dev;
d_fnstart(4, dev, "(hwahc %p)\n", hwahc);
mutex_lock(&wusbhc->mutex);
wusb_cluster_id_put(wusbhc->cluster_id);
mutex_unlock(&wusbhc->mutex);
d_fnend(4, dev, "(hwahc %p) = %d\n", hwahc, result);
return;
}
static int hwahc_op_get_frame_number(struct usb_hcd *usb_hcd)
......@@ -573,7 +552,7 @@ static int wa_fill_descr(struct wahc *wa)
itr_size = le16_to_cpu(usb_dev->actconfig->desc.wTotalLength);
while (itr_size >= sizeof(*hdr)) {
hdr = (struct usb_descriptor_header *) itr;
d_printf(3, dev, "Extra device descriptor: "
dev_dbg(dev, "Extra device descriptor: "
"type %02x/%u bytes @ %zu (%zu left)\n",
hdr->bDescriptorType, hdr->bLength,
(itr - usb_dev->rawdescriptors[actconfig_idx]),
......@@ -786,7 +765,6 @@ static void hwahc_destroy(struct hwahc *hwahc)
{
struct wusbhc *wusbhc = &hwahc->wusbhc;
d_fnstart(1, NULL, "(hwahc %p)\n", hwahc);
mutex_lock(&wusbhc->mutex);
__wa_destroy(&hwahc->wa);
wusbhc_destroy(&hwahc->wusbhc);
......@@ -796,7 +774,6 @@ static void hwahc_destroy(struct hwahc *hwahc)
usb_put_intf(hwahc->wa.usb_iface);
usb_put_dev(hwahc->wa.usb_dev);
mutex_unlock(&wusbhc->mutex);
d_fnend(1, NULL, "(hwahc %p) = void\n", hwahc);
}
static void hwahc_init(struct hwahc *hwahc)
......@@ -813,7 +790,6 @@ static int hwahc_probe(struct usb_interface *usb_iface,
struct hwahc *hwahc;
struct device *dev = &usb_iface->dev;
d_fnstart(4, dev, "(%p, %p)\n", usb_iface, id);
result = -ENOMEM;
usb_hcd = usb_create_hcd(&hwahc_hc_driver, &usb_iface->dev, "wusb-hwa");
if (usb_hcd == NULL) {
......@@ -840,7 +816,6 @@ static int hwahc_probe(struct usb_interface *usb_iface,
dev_err(dev, "Cannot setup phase B of WUSBHC: %d\n", result);
goto error_wusbhc_b_create;
}
d_fnend(4, dev, "(%p, %p) = 0\n", usb_iface, id);
return 0;
error_wusbhc_b_create:
......@@ -850,7 +825,6 @@ static int hwahc_probe(struct usb_interface *usb_iface,
error_hwahc_create:
usb_put_hcd(usb_hcd);
error_alloc:
d_fnend(4, dev, "(%p, %p) = %d\n", usb_iface, id, result);
return result;
}
......@@ -864,16 +838,12 @@ static void hwahc_disconnect(struct usb_interface *usb_iface)
wusbhc = usb_hcd_to_wusbhc(usb_hcd);
hwahc = container_of(wusbhc, struct hwahc, wusbhc);
d_fnstart(1, NULL, "(hwahc %p [usb_iface %p])\n", hwahc, usb_iface);
wusbhc_b_destroy(&hwahc->wusbhc);
usb_remove_hcd(usb_hcd);
hwahc_destroy(hwahc);
usb_put_hcd(usb_hcd);
d_fnend(1, NULL, "(hwahc %p [usb_iface %p]) = void\n", hwahc,
usb_iface);
}
/** USB device ID's that we handle */
static struct usb_device_id hwahc_id_table[] = {
/* FIXME: use class labels for this */
{ USB_INTERFACE_INFO(0xe0, 0x02, 0x01), },
......@@ -890,18 +860,7 @@ static struct usb_driver hwahc_driver = {
static int __init hwahc_driver_init(void)
{
int result;
result = usb_register(&hwahc_driver);
if (result < 0) {
printk(KERN_ERR "WA-CDS: Cannot register USB driver: %d\n",
result);
goto error_usb_register;
}
return 0;
error_usb_register:
return result;
return usb_register(&hwahc_driver);
}
module_init(hwahc_driver_init);
......
......@@ -51,7 +51,6 @@
#include <linux/uwb.h>
#include <linux/usb/wusb.h>
#include <linux/scatterlist.h>
#define D_LOCAL 0
#include <linux/uwb/debug.h>
static int debug_crypto_verify = 0;
......@@ -207,9 +206,6 @@ static int wusb_ccm_mac(struct crypto_blkcipher *tfm_cbc,
const u8 bzero[16] = { 0 };
size_t zero_padding;
d_fnstart(3, NULL, "(tfm_cbc %p, tfm_aes %p, mic %p, "
"n %p, a %p, b %p, blen %zu)\n",
tfm_cbc, tfm_aes, mic, n, a, b, blen);
/*
* These checks should be compile time optimized out
* ensure @a fills b1's mac_header and following fields
......@@ -251,16 +247,6 @@ static int wusb_ccm_mac(struct crypto_blkcipher *tfm_cbc,
b1.la = cpu_to_be16(blen + 14);
memcpy(&b1.mac_header, a, sizeof(*a));
d_printf(4, NULL, "I: B0 (%zu bytes)\n", sizeof(b0));
d_dump(4, NULL, &b0, sizeof(b0));
d_printf(4, NULL, "I: B1 (%zu bytes)\n", sizeof(b1));
d_dump(4, NULL, &b1, sizeof(b1));
d_printf(4, NULL, "I: B (%zu bytes)\n", blen);
d_dump(4, NULL, b, blen);
d_printf(4, NULL, "I: B 0-padding (%zu bytes)\n", zero_padding);
d_printf(4, NULL, "D: IV before crypto (%zu)\n", ivsize);
d_dump(4, NULL, iv, ivsize);
sg_init_table(sg, ARRAY_SIZE(sg));
sg_set_buf(&sg[0], &b0, sizeof(b0));
sg_set_buf(&sg[1], &b1, sizeof(b1));
......@@ -277,8 +263,6 @@ static int wusb_ccm_mac(struct crypto_blkcipher *tfm_cbc,
result);
goto error_cbc_crypt;
}
d_printf(4, NULL, "D: MIC tag\n");
d_dump(4, NULL, iv, ivsize);
/* Now we crypt the MIC Tag (*iv) with Ax -- values per WUSB1.0[6.5]
* The procedure is to AES crypt the A0 block and XOR the MIC
......@@ -293,17 +277,10 @@ static int wusb_ccm_mac(struct crypto_blkcipher *tfm_cbc,
ax.counter = 0;
crypto_cipher_encrypt_one(tfm_aes, (void *)&ax, (void *)&ax);
bytewise_xor(mic, &ax, iv, 8);
d_printf(4, NULL, "D: CTR[MIC]\n");
d_dump(4, NULL, &ax, 8);
d_printf(4, NULL, "D: CCM-MIC tag\n");
d_dump(4, NULL, mic, 8);
result = 8;
error_cbc_crypt:
kfree(dst_buf);
error_dst_buf:
d_fnend(3, NULL, "(tfm_cbc %p, tfm_aes %p, mic %p, "
"n %p, a %p, b %p, blen %zu)\n",
tfm_cbc, tfm_aes, mic, n, a, b, blen);
return result;
}
......@@ -325,10 +302,6 @@ ssize_t wusb_prf(void *out, size_t out_size,
u64 sfn = 0;
__le64 sfn_le;
d_fnstart(3, NULL, "(out %p, out_size %zu, key %p, _n %p, "
"a %p, b %p, blen %zu, len %zu)\n", out, out_size,
key, _n, a, b, blen, len);
tfm_cbc = crypto_alloc_blkcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm_cbc)) {
result = PTR_ERR(tfm_cbc);
......@@ -370,9 +343,6 @@ ssize_t wusb_prf(void *out, size_t out_size,
error_setkey_cbc:
crypto_free_blkcipher(tfm_cbc);
error_alloc_cbc:
d_fnend(3, NULL, "(out %p, out_size %zu, key %p, _n %p, "
"a %p, b %p, blen %zu, len %zu) = %d\n", out, out_size,
key, _n, a, b, blen, len, (int)bytes);
return result;
}
......
......@@ -28,10 +28,6 @@
#include <linux/workqueue.h>
#include "wusbhc.h"
#undef D_LOCAL
#define D_LOCAL 4
#include <linux/uwb/debug.h>
static ssize_t wusb_disconnect_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
......
......@@ -91,10 +91,6 @@
#include <linux/workqueue.h>
#include "wusbhc.h"
#undef D_LOCAL
#define D_LOCAL 1
#include <linux/uwb/debug.h>
static void wusbhc_devconnect_acked_work(struct work_struct *work);
static void wusb_dev_free(struct wusb_dev *wusb_dev)
......@@ -234,6 +230,7 @@ static struct wusb_dev *wusbhc_cack_add(struct wusbhc *wusbhc,
list_add_tail(&wusb_dev->cack_node, &wusbhc->cack_list);
wusbhc->cack_count++;
wusbhc_fill_cack_ie(wusbhc);
return wusb_dev;
}
......@@ -244,12 +241,9 @@ static struct wusb_dev *wusbhc_cack_add(struct wusbhc *wusbhc,
*/
static void wusbhc_cack_rm(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
{
struct device *dev = wusbhc->dev;
d_fnstart(3, dev, "(wusbhc %p wusb_dev %p)\n", wusbhc, wusb_dev);
list_del_init(&wusb_dev->cack_node);
wusbhc->cack_count--;
wusbhc_fill_cack_ie(wusbhc);
d_fnend(3, dev, "(wusbhc %p wusb_dev %p) = void\n", wusbhc, wusb_dev);
}
/*
......@@ -257,14 +251,11 @@ static void wusbhc_cack_rm(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
static
void wusbhc_devconnect_acked(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
{
struct device *dev = wusbhc->dev;
d_fnstart(3, dev, "(wusbhc %p wusb_dev %p)\n", wusbhc, wusb_dev);
wusbhc_cack_rm(wusbhc, wusb_dev);
if (wusbhc->cack_count)
wusbhc_mmcie_set(wusbhc, 0, 0, &wusbhc->cack_ie.hdr);
else
wusbhc_mmcie_rm(wusbhc, &wusbhc->cack_ie.hdr);
d_fnend(3, dev, "(wusbhc %p wusb_dev %p) = void\n", wusbhc, wusb_dev);
}
static void wusbhc_devconnect_acked_work(struct work_struct *work)
......@@ -314,7 +305,6 @@ void wusbhc_devconnect_ack(struct wusbhc *wusbhc, struct wusb_dn_connect *dnc,
struct wusb_port *port;
unsigned idx, devnum;
d_fnstart(3, dev, "(%p, %p, %s)\n", wusbhc, dnc, pr_cdid);
mutex_lock(&wusbhc->mutex);
/* Check we are not handling it already */
......@@ -367,7 +357,6 @@ void wusbhc_devconnect_ack(struct wusbhc *wusbhc, struct wusb_dn_connect *dnc,
*/
error_unlock:
mutex_unlock(&wusbhc->mutex);
d_fnend(3, dev, "(%p, %p, %s) = void\n", wusbhc, dnc, pr_cdid);
return;
}
......@@ -390,10 +379,8 @@ void wusbhc_devconnect_ack(struct wusbhc *wusbhc, struct wusb_dn_connect *dnc,
static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc,
struct wusb_port *port)
{
struct device *dev = wusbhc->dev;
struct wusb_dev *wusb_dev = port->wusb_dev;
d_fnstart(3, dev, "(wusbhc %p, port %p)\n", wusbhc, port);
port->status &= ~(USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE
| USB_PORT_STAT_SUSPEND | USB_PORT_STAT_RESET
| USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED);
......@@ -410,7 +397,6 @@ static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc,
* section 6.2.11.2). */
wusbhc_gtk_rekey(wusbhc);
d_fnend(3, dev, "(wusbhc %p, port %p) = void\n", wusbhc, port);
/* The Wireless USB part has forgotten about the device already; now
* khubd's timer will pick up the disconnection and remove the USB
* device from the system
......@@ -535,10 +521,6 @@ static struct wusb_dev *wusbhc_find_dev_by_addr(struct wusbhc *wusbhc, u8 addr)
*/
static void wusbhc_handle_dn_alive(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
{
struct device *dev = wusbhc->dev;
d_printf(2, dev, "DN ALIVE: device 0x%02x pong\n", wusb_dev->addr);
mutex_lock(&wusbhc->mutex);
wusb_dev->entry_ts = jiffies;
__wusbhc_keep_alive(wusbhc);
......@@ -571,11 +553,10 @@ static void wusbhc_handle_dn_connect(struct wusbhc *wusbhc,
"no-beacon"
};
d_fnstart(3, dev, "(%p, %p, %zu)\n", wusbhc, dn_hdr, size);
if (size < sizeof(*dnc)) {
dev_err(dev, "DN CONNECT: short notification (%zu < %zu)\n",
size, sizeof(*dnc));
goto out;
return;
}
dnc = container_of(dn_hdr, struct wusb_dn_connect, hdr);
......@@ -587,10 +568,6 @@ static void wusbhc_handle_dn_connect(struct wusbhc *wusbhc,
wusb_dn_connect_new_connection(dnc) ? "connect" : "reconnect");
/* ACK the connect */
wusbhc_devconnect_ack(wusbhc, dnc, pr_cdid);
out:
d_fnend(3, dev, "(%p, %p, %zu) = void\n",
wusbhc, dn_hdr, size);
return;
}
/*
......@@ -631,19 +608,17 @@ void wusbhc_handle_dn(struct wusbhc *wusbhc, u8 srcaddr,
struct device *dev = wusbhc->dev;
struct wusb_dev *wusb_dev;
d_fnstart(3, dev, "(%p, %p)\n", wusbhc, dn_hdr);
if (size < sizeof(struct wusb_dn_hdr)) {
dev_err(dev, "DN data shorter than DN header (%d < %d)\n",
(int)size, (int)sizeof(struct wusb_dn_hdr));
goto out;
return;
}
wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
if (wusb_dev == NULL && dn_hdr->bType != WUSB_DN_CONNECT) {
dev_dbg(dev, "ignoring DN %d from unconnected device %02x\n",
dn_hdr->bType, srcaddr);
goto out;
return;
}
switch (dn_hdr->bType) {
......@@ -668,9 +643,6 @@ void wusbhc_handle_dn(struct wusbhc *wusbhc, u8 srcaddr,
dev_warn(dev, "unknown DN %u (%d octets) from %u\n",
dn_hdr->bType, (int)size, srcaddr);
}
out:
d_fnend(3, dev, "(%p, %p) = void\n", wusbhc, dn_hdr);
return;
}
EXPORT_SYMBOL_GPL(wusbhc_handle_dn);
......@@ -700,59 +672,30 @@ void __wusbhc_dev_disable(struct wusbhc *wusbhc, u8 port_idx)
struct wusb_dev *wusb_dev;
struct wuie_disconnect *ie;
d_fnstart(3, dev, "(%p, %u)\n", wusbhc, port_idx);
result = 0;
wusb_dev = wusb_port_by_idx(wusbhc, port_idx)->wusb_dev;
if (wusb_dev == NULL) {
/* reset no device? ignore */
dev_dbg(dev, "DISCONNECT: no device at port %u, ignoring\n",
port_idx);
goto error;
return;
}
__wusbhc_dev_disconnect(wusbhc, wusb_port_by_idx(wusbhc, port_idx));
result = -ENOMEM;
ie = kzalloc(sizeof(*ie), GFP_KERNEL);
if (ie == NULL)
goto error;
return;
ie->hdr.bLength = sizeof(*ie);
ie->hdr.bIEIdentifier = WUIE_ID_DEVICE_DISCONNECT;
ie->bDeviceAddress = wusb_dev->addr;
result = wusbhc_mmcie_set(wusbhc, 0, 0, &ie->hdr);
if (result < 0) {
if (result < 0)
dev_err(dev, "DISCONNECT: can't set MMC: %d\n", result);
goto error_kfree;
}
/* 120ms, hopefully 6 MMCs */
msleep(100);
else {
/* At least 6 MMCs, assuming at least 1 MMC per zone. */
msleep(7*4);
wusbhc_mmcie_rm(wusbhc, &ie->hdr);
error_kfree:
}
kfree(ie);
error:
d_fnend(3, dev, "(%p, %u) = %d\n", wusbhc, port_idx, result);
return;
}
static void wusb_cap_descr_printf(const unsigned level, struct device *dev,
const struct usb_wireless_cap_descriptor *wcd)
{
d_printf(level, dev,
"WUSB Capability Descriptor\n"
" bDevCapabilityType 0x%02x\n"
" bmAttributes 0x%02x\n"
" wPhyRates 0x%04x\n"
" bmTFITXPowerInfo 0x%02x\n"
" bmFFITXPowerInfo 0x%02x\n"
" bmBandGroup 0x%04x\n"
" bReserved 0x%02x\n",
wcd->bDevCapabilityType,
wcd->bmAttributes,
le16_to_cpu(wcd->wPHYRates),
wcd->bmTFITXPowerInfo,
wcd->bmFFITXPowerInfo,
wcd->bmBandGroup,
wcd->bReserved);
}
/*
......@@ -795,8 +738,6 @@ static int wusb_dev_bos_grok(struct usb_device *usb_dev,
}
cap_size = cap_hdr->bLength;
cap_type = cap_hdr->bDevCapabilityType;
d_printf(4, dev, "BOS Capability: 0x%02x (%zu bytes)\n",
cap_type, cap_size);
if (cap_size == 0)
break;
if (cap_size > top - itr) {
......@@ -808,7 +749,6 @@ static int wusb_dev_bos_grok(struct usb_device *usb_dev,
result = -EBADF;
goto error_bad_cap;
}
d_dump(3, dev, itr, cap_size);
switch (cap_type) {
case USB_CAP_TYPE_WIRELESS_USB:
if (cap_size != sizeof(*wusb_dev->wusb_cap_descr))
......@@ -816,10 +756,8 @@ static int wusb_dev_bos_grok(struct usb_device *usb_dev,
"descriptor is %zu bytes vs %zu "
"needed\n", cap_size,
sizeof(*wusb_dev->wusb_cap_descr));
else {
else
wusb_dev->wusb_cap_descr = itr;
wusb_cap_descr_printf(3, dev, itr);
}
break;
default:
dev_err(dev, "BUG? Unknown BOS capability 0x%02x "
......@@ -884,9 +822,7 @@ static int wusb_dev_bos_add(struct usb_device *usb_dev,
"%zu bytes): %zd\n", desc_size, result);
goto error_get_descriptor;
}
d_printf(2, dev, "Got BOS descriptor %zd bytes, %u capabilities\n",
result, bos->bNumDeviceCaps);
d_dump(2, dev, bos, result);
result = wusb_dev_bos_grok(usb_dev, wusb_dev, bos, result);
if (result < 0)
goto error_bad_bos;
......@@ -952,8 +888,6 @@ static void wusb_dev_add_ncb(struct usb_device *usb_dev)
if (usb_dev->wusb == 0 || usb_dev->devnum == 1)
return; /* skip non wusb and wusb RHs */
d_fnstart(3, dev, "(usb_dev %p)\n", usb_dev);
wusbhc = wusbhc_get_by_usb_dev(usb_dev);
if (wusbhc == NULL)
goto error_nodev;
......@@ -983,7 +917,6 @@ static void wusb_dev_add_ncb(struct usb_device *usb_dev)
wusb_dev_put(wusb_dev);
wusbhc_put(wusbhc);
error_nodev:
d_fnend(3, dev, "(usb_dev %p) = void\n", usb_dev);
return;
wusb_dev_sysfs_rm(wusb_dev);
......@@ -1070,11 +1003,10 @@ EXPORT_SYMBOL_GPL(__wusb_dev_get_by_usb_dev);
void wusb_dev_destroy(struct kref *_wusb_dev)
{
struct wusb_dev *wusb_dev
= container_of(_wusb_dev, struct wusb_dev, refcnt);
struct wusb_dev *wusb_dev = container_of(_wusb_dev, struct wusb_dev, refcnt);
list_del_init(&wusb_dev->cack_node);
wusb_dev_free(wusb_dev);
d_fnend(1, NULL, "%s (wusb_dev %p) = void\n", __func__, wusb_dev);
}
EXPORT_SYMBOL_GPL(wusb_dev_destroy);
......@@ -1086,8 +1018,6 @@ EXPORT_SYMBOL_GPL(wusb_dev_destroy);
*/
int wusbhc_devconnect_create(struct wusbhc *wusbhc)
{
d_fnstart(3, wusbhc->dev, "(wusbhc %p)\n", wusbhc);
wusbhc->keep_alive_ie.hdr.bIEIdentifier = WUIE_ID_KEEP_ALIVE;
wusbhc->keep_alive_ie.hdr.bLength = sizeof(wusbhc->keep_alive_ie.hdr);
INIT_DELAYED_WORK(&wusbhc->keep_alive_timer, wusbhc_keep_alive_run);
......@@ -1096,7 +1026,6 @@ int wusbhc_devconnect_create(struct wusbhc *wusbhc)
wusbhc->cack_ie.hdr.bLength = sizeof(wusbhc->cack_ie.hdr);
INIT_LIST_HEAD(&wusbhc->cack_list);
d_fnend(3, wusbhc->dev, "(wusbhc %p) = void\n", wusbhc);
return 0;
}
......@@ -1105,8 +1034,7 @@ int wusbhc_devconnect_create(struct wusbhc *wusbhc)
*/
void wusbhc_devconnect_destroy(struct wusbhc *wusbhc)
{
d_fnstart(3, wusbhc->dev, "(wusbhc %p)\n", wusbhc);
d_fnend(3, wusbhc->dev, "(wusbhc %p) = void\n", wusbhc);
/* no op */
}
/*
......
......@@ -71,9 +71,6 @@
*/
#include "wusbhc.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
/*
* Reset a fake port
*
......@@ -142,7 +139,6 @@ int wusbhc_rh_status_data(struct usb_hcd *usb_hcd, char *_buf)
size_t cnt, size;
unsigned long *buf = (unsigned long *) _buf;
d_fnstart(1, wusbhc->dev, "(wusbhc %p)\n", wusbhc);
/* WE DON'T LOCK, see comment */
size = wusbhc->ports_max + 1 /* hub bit */;
size = (size + 8 - 1) / 8; /* round to bytes */
......@@ -151,8 +147,6 @@ int wusbhc_rh_status_data(struct usb_hcd *usb_hcd, char *_buf)
set_bit(cnt + 1, buf);
else
clear_bit(cnt + 1, buf);
d_fnend(1, wusbhc->dev, "(wusbhc %p) %u, buffer:\n", wusbhc, (int)size);
d_dump(1, wusbhc->dev, _buf, size);
return size;
}
EXPORT_SYMBOL_GPL(wusbhc_rh_status_data);
......@@ -201,9 +195,7 @@ static int wusbhc_rh_get_hub_descr(struct wusbhc *wusbhc, u16 wValue,
static int wusbhc_rh_clear_hub_feat(struct wusbhc *wusbhc, u16 feature)
{
int result;
struct device *dev = wusbhc->dev;
d_fnstart(4, dev, "(%p, feature 0x%04u)\n", wusbhc, feature);
switch (feature) {
case C_HUB_LOCAL_POWER:
/* FIXME: maybe plug bit 0 to the power input status,
......@@ -215,7 +207,6 @@ static int wusbhc_rh_clear_hub_feat(struct wusbhc *wusbhc, u16 feature)
default:
result = -EPIPE;
}
d_fnend(4, dev, "(%p, feature 0x%04u), %d\n", wusbhc, feature, result);
return result;
}
......@@ -242,14 +233,10 @@ static int wusbhc_rh_get_hub_status(struct wusbhc *wusbhc, u32 *buf,
static int wusbhc_rh_set_port_feat(struct wusbhc *wusbhc, u16 feature,
u8 selector, u8 port_idx)
{
int result = -EINVAL;
struct device *dev = wusbhc->dev;
d_fnstart(4, dev, "(feat 0x%04u, selector 0x%u, port_idx %d)\n",
feature, selector, port_idx);
if (port_idx > wusbhc->ports_max)
goto error;
return -EINVAL;
switch (feature) {
/* According to USB2.0[11.24.2.13]p2, these features
......@@ -259,35 +246,27 @@ static int wusbhc_rh_set_port_feat(struct wusbhc *wusbhc, u16 feature,
case USB_PORT_FEAT_C_SUSPEND:
case USB_PORT_FEAT_C_CONNECTION:
case USB_PORT_FEAT_C_RESET:
result = 0;
break;
return 0;
case USB_PORT_FEAT_POWER:
/* No such thing, but we fake it works */
mutex_lock(&wusbhc->mutex);
wusb_port_by_idx(wusbhc, port_idx)->status |= USB_PORT_STAT_POWER;
mutex_unlock(&wusbhc->mutex);
result = 0;
break;
return 0;
case USB_PORT_FEAT_RESET:
result = wusbhc_rh_port_reset(wusbhc, port_idx);
break;
return wusbhc_rh_port_reset(wusbhc, port_idx);
case USB_PORT_FEAT_ENABLE:
case USB_PORT_FEAT_SUSPEND:
dev_err(dev, "(port_idx %d) set feat %d/%d UNIMPLEMENTED\n",
port_idx, feature, selector);
result = -ENOSYS;
break;
return -ENOSYS;
default:
dev_err(dev, "(port_idx %d) set feat %d/%d UNKNOWN\n",
port_idx, feature, selector);
result = -EPIPE;
break;
return -EPIPE;
}
error:
d_fnend(4, dev, "(feat 0x%04u, selector 0x%u, port_idx %d) = %d\n",
feature, selector, port_idx, result);
return result;
return 0;
}
/*
......@@ -298,17 +277,13 @@ static int wusbhc_rh_set_port_feat(struct wusbhc *wusbhc, u16 feature,
static int wusbhc_rh_clear_port_feat(struct wusbhc *wusbhc, u16 feature,
u8 selector, u8 port_idx)
{
int result = -EINVAL;
int result = 0;
struct device *dev = wusbhc->dev;
d_fnstart(4, dev, "(wusbhc %p feat 0x%04x selector %d port_idx %d)\n",
wusbhc, feature, selector, port_idx);
if (port_idx > wusbhc->ports_max)
goto error;
return -EINVAL;
mutex_lock(&wusbhc->mutex);
result = 0;
switch (feature) {
case USB_PORT_FEAT_POWER: /* fake port always on */
/* According to USB2.0[11.24.2.7.1.4], no need to implement? */
......@@ -328,10 +303,8 @@ static int wusbhc_rh_clear_port_feat(struct wusbhc *wusbhc, u16 feature,
break;
case USB_PORT_FEAT_SUSPEND:
case USB_PORT_FEAT_C_SUSPEND:
case 0xffff: /* ??? FIXME */
dev_err(dev, "(port_idx %d) Clear feat %d/%d UNIMPLEMENTED\n",
port_idx, feature, selector);
/* dump_stack(); */
result = -ENOSYS;
break;
default:
......@@ -341,9 +314,7 @@ static int wusbhc_rh_clear_port_feat(struct wusbhc *wusbhc, u16 feature,
break;
}
mutex_unlock(&wusbhc->mutex);
error:
d_fnend(4, dev, "(wusbhc %p feat 0x%04x selector %d port_idx %d) = "
"%d\n", wusbhc, feature, selector, port_idx, result);
return result;
}
......@@ -355,22 +326,17 @@ static int wusbhc_rh_clear_port_feat(struct wusbhc *wusbhc, u16 feature,
static int wusbhc_rh_get_port_status(struct wusbhc *wusbhc, u16 port_idx,
u32 *_buf, u16 wLength)
{
int result = -EINVAL;
u16 *buf = (u16 *) _buf;
d_fnstart(1, wusbhc->dev, "(wusbhc %p port_idx %u wLength %u)\n",
wusbhc, port_idx, wLength);
if (port_idx > wusbhc->ports_max)
goto error;
return -EINVAL;
mutex_lock(&wusbhc->mutex);
buf[0] = cpu_to_le16(wusb_port_by_idx(wusbhc, port_idx)->status);
buf[1] = cpu_to_le16(wusb_port_by_idx(wusbhc, port_idx)->change);
result = 0;
mutex_unlock(&wusbhc->mutex);
error:
d_fnend(1, wusbhc->dev, "(wusbhc %p) = %d, buffer:\n", wusbhc, result);
d_dump(1, wusbhc->dev, _buf, wLength);
return result;
return 0;
}
/*
......
......@@ -27,19 +27,6 @@
#include <linux/random.h>
#include "wusbhc.h"
/*
* DEBUG & SECURITY WARNING!!!!
*
* If you enable this past 1, the debug code will weaken the
* cryptographic safety of the system (on purpose, for debugging).
*
* Weaken means:
* we print secret keys and intermediate values all the way,
*/
#undef D_LOCAL
#define D_LOCAL 2
#include <linux/uwb/debug.h>
static void wusbhc_set_gtk_callback(struct urb *urb);
static void wusbhc_gtk_rekey_done_work(struct work_struct *work);
......@@ -219,7 +206,6 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
const void *itr, *top;
char buf[64];
d_fnstart(3, dev, "(usb_dev %p, wusb_dev %p)\n", usb_dev, wusb_dev);
result = usb_get_descriptor(usb_dev, USB_DT_SECURITY,
0, &secd, sizeof(secd));
if (result < sizeof(secd)) {
......@@ -228,8 +214,6 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
goto error_secd;
}
secd_size = le16_to_cpu(secd.wTotalLength);
d_printf(5, dev, "got %d bytes of sec descriptor, total is %d\n",
result, secd_size);
secd_buf = kmalloc(secd_size, GFP_KERNEL);
if (secd_buf == NULL) {
dev_err(dev, "Can't allocate space for security descriptors\n");
......@@ -242,7 +226,6 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
"not enough data: %d\n", result);
goto error_secd_all;
}
d_printf(5, dev, "got %d bytes of sec descriptors\n", result);
bytes = 0;
itr = secd_buf + sizeof(secd);
top = secd_buf + result;
......@@ -279,14 +262,12 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
goto error_no_ccm1;
}
wusb_dev->ccm1_etd = *ccm1_etd;
dev_info(dev, "supported encryption: %s; using %s (0x%02x/%02x)\n",
dev_dbg(dev, "supported encryption: %s; using %s (0x%02x/%02x)\n",
buf, wusb_et_name(ccm1_etd->bEncryptionType),
ccm1_etd->bEncryptionValue, ccm1_etd->bAuthKeyIndex);
result = 0;
kfree(secd_buf);
out:
d_fnend(3, dev, "(usb_dev %p, wusb_dev %p) = %d\n",
usb_dev, wusb_dev, result);
return result;
......@@ -303,32 +284,6 @@ void wusb_dev_sec_rm(struct wusb_dev *wusb_dev)
/* Nothing so far */
}
static void hs_printk(unsigned level, struct device *dev,
struct usb_handshake *hs)
{
d_printf(level, dev,
" bMessageNumber: %u\n"
" bStatus: %u\n"
" tTKID: %02x %02x %02x\n"
" CDID: %02x %02x %02x %02x %02x %02x %02x %02x\n"
" %02x %02x %02x %02x %02x %02x %02x %02x\n"
" nonce: %02x %02x %02x %02x %02x %02x %02x %02x\n"
" %02x %02x %02x %02x %02x %02x %02x %02x\n"
" MIC: %02x %02x %02x %02x %02x %02x %02x %02x\n",
hs->bMessageNumber, hs->bStatus,
hs->tTKID[2], hs->tTKID[1], hs->tTKID[0],
hs->CDID[0], hs->CDID[1], hs->CDID[2], hs->CDID[3],
hs->CDID[4], hs->CDID[5], hs->CDID[6], hs->CDID[7],
hs->CDID[8], hs->CDID[9], hs->CDID[10], hs->CDID[11],
hs->CDID[12], hs->CDID[13], hs->CDID[14], hs->CDID[15],
hs->nonce[0], hs->nonce[1], hs->nonce[2], hs->nonce[3],
hs->nonce[4], hs->nonce[5], hs->nonce[6], hs->nonce[7],
hs->nonce[8], hs->nonce[9], hs->nonce[10], hs->nonce[11],
hs->nonce[12], hs->nonce[13], hs->nonce[14], hs->nonce[15],
hs->MIC[0], hs->MIC[1], hs->MIC[2], hs->MIC[3],
hs->MIC[4], hs->MIC[5], hs->MIC[6], hs->MIC[7]);
}
/**
* Update the address of an unauthenticated WUSB device
*
......@@ -421,9 +376,6 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
get_random_bytes(&hs[0].nonce, sizeof(hs[0].nonce));
memset(hs[0].MIC, 0, sizeof(hs[0].MIC)); /* Per WUSB1.0[T7-22] */
d_printf(1, dev, "I: sending hs1:\n");
hs_printk(2, dev, &hs[0]);
result = usb_control_msg(
usb_dev, usb_sndctrlpipe(usb_dev, 0),
USB_REQ_SET_HANDSHAKE,
......@@ -444,8 +396,6 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
dev_err(dev, "Handshake2: request failed: %d\n", result);
goto error_hs2;
}
d_printf(1, dev, "got HS2:\n");
hs_printk(2, dev, &hs[1]);
result = -EINVAL;
if (hs[1].bMessageNumber != 2) {
......@@ -486,10 +436,6 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
result);
goto error_hs2;
}
d_printf(2, dev, "KCK:\n");
d_dump(2, dev, keydvt_out.kck, sizeof(keydvt_out.kck));
d_printf(2, dev, "PTK:\n");
d_dump(2, dev, keydvt_out.ptk, sizeof(keydvt_out.ptk));
/* Compute MIC and verify it */
result = wusb_oob_mic(mic, keydvt_out.kck, &ccm_n, &hs[1]);
......@@ -499,8 +445,6 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
goto error_hs2;
}
d_printf(2, dev, "MIC:\n");
d_dump(2, dev, mic, sizeof(mic));
if (memcmp(hs[1].MIC, mic, sizeof(hs[1].MIC))) {
dev_err(dev, "Handshake2 failed: MIC mismatch\n");
goto error_hs2;
......@@ -520,9 +464,6 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
goto error_hs2;
}
d_printf(1, dev, "I: sending hs3:\n");
hs_printk(2, dev, &hs[2]);
result = usb_control_msg(
usb_dev, usb_sndctrlpipe(usb_dev, 0),
USB_REQ_SET_HANDSHAKE,
......@@ -533,14 +474,11 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
goto error_hs3;
}
d_printf(1, dev, "I: turning on encryption on host for device\n");
d_dump(2, dev, keydvt_out.ptk, sizeof(keydvt_out.ptk));
result = wusbhc->set_ptk(wusbhc, wusb_dev->port_idx, tkid,
keydvt_out.ptk, sizeof(keydvt_out.ptk));
if (result < 0)
goto error_wusbhc_set_ptk;
d_printf(1, dev, "I: setting a GTK\n");
result = wusb_dev_set_gtk(wusbhc, wusb_dev);
if (result < 0) {
dev_err(dev, "Set GTK for device: request failed: %d\n",
......@@ -550,13 +488,12 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
/* Update the device's address from unauth to auth */
if (usb_dev->authenticated == 0) {
d_printf(1, dev, "I: updating addres to auth from non-auth\n");
result = wusb_dev_update_address(wusbhc, wusb_dev);
if (result < 0)
goto error_dev_update_address;
}
result = 0;
d_printf(1, dev, "I: 4way handshke done, device authenticated\n");
dev_info(dev, "device authenticated\n");
error_dev_update_address:
error_wusbhc_set_gtk:
......@@ -569,10 +506,8 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
memset(&keydvt_in, 0, sizeof(keydvt_in));
memset(&ccm_n, 0, sizeof(ccm_n));
memset(mic, 0, sizeof(mic));
if (result < 0) {
/* error path */
if (result < 0)
wusb_dev_set_encryption(usb_dev, 0);
}
error_dev_set_encryption:
kfree(hs);
error_kzalloc:
......
......@@ -60,13 +60,10 @@
#include <linux/init.h>
#include <asm/atomic.h>
#include <linux/bitmap.h>
#include "wusbhc.h"
#include "wa-hc.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
static int __rpipe_get_descr(struct wahc *wa,
struct usb_rpipe_descriptor *descr, u16 index)
{
......@@ -76,7 +73,6 @@ static int __rpipe_get_descr(struct wahc *wa,
/* Get the RPIPE descriptor -- we cannot use the usb_get_descriptor()
* function because the arguments are different.
*/
d_printf(1, dev, "rpipe %u: get descr\n", index);
result = usb_control_msg(
wa->usb_dev, usb_rcvctrlpipe(wa->usb_dev, 0),
USB_REQ_GET_DESCRIPTOR,
......@@ -115,7 +111,6 @@ static int __rpipe_set_descr(struct wahc *wa,
/* we cannot use the usb_get_descriptor() function because the
* arguments are different.
*/
d_printf(1, dev, "rpipe %u: set descr\n", index);
result = usb_control_msg(
wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
USB_REQ_SET_DESCRIPTOR,
......@@ -174,13 +169,12 @@ void rpipe_destroy(struct kref *_rpipe)
{
struct wa_rpipe *rpipe = container_of(_rpipe, struct wa_rpipe, refcnt);
u8 index = le16_to_cpu(rpipe->descr.wRPipeIndex);
d_fnstart(1, NULL, "(rpipe %p %u)\n", rpipe, index);
if (rpipe->ep)
rpipe->ep->hcpriv = NULL;
rpipe_put_idx(rpipe->wa, index);
wa_put(rpipe->wa);
kfree(rpipe);
d_fnend(1, NULL, "(rpipe %p %u)\n", rpipe, index);
}
EXPORT_SYMBOL_GPL(rpipe_destroy);
......@@ -202,7 +196,6 @@ static int rpipe_get_idle(struct wa_rpipe **prpipe, struct wahc *wa, u8 crs,
struct wa_rpipe *rpipe;
struct device *dev = &wa->usb_iface->dev;
d_fnstart(3, dev, "(wa %p crs 0x%02x)\n", wa, crs);
rpipe = kzalloc(sizeof(*rpipe), gfp);
if (rpipe == NULL)
return -ENOMEM;
......@@ -223,14 +216,12 @@ static int rpipe_get_idle(struct wa_rpipe **prpipe, struct wahc *wa, u8 crs,
}
*prpipe = NULL;
kfree(rpipe);
d_fnend(3, dev, "(wa %p crs 0x%02x) = -ENXIO\n", wa, crs);
return -ENXIO;
found:
set_bit(rpipe_idx, wa->rpipe_bm);
rpipe->wa = wa_get(wa);
*prpipe = rpipe;
d_fnstart(3, dev, "(wa %p crs 0x%02x) = 0\n", wa, crs);
return 0;
}
......@@ -239,7 +230,6 @@ static int __rpipe_reset(struct wahc *wa, unsigned index)
int result;
struct device *dev = &wa->usb_iface->dev;
d_printf(1, dev, "rpipe %u: reset\n", index);
result = usb_control_msg(
wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
USB_REQ_RPIPE_RESET,
......@@ -276,7 +266,6 @@ static struct usb_wireless_ep_comp_descriptor *rpipe_epc_find(
struct usb_descriptor_header *hdr;
struct usb_wireless_ep_comp_descriptor *epcd;
d_fnstart(3, dev, "(ep %p)\n", ep);
if (ep->desc.bEndpointAddress == 0) {
epcd = &epc0;
goto out;
......@@ -310,7 +299,6 @@ static struct usb_wireless_ep_comp_descriptor *rpipe_epc_find(
itr_size -= hdr->bDescriptorType;
}
out:
d_fnend(3, dev, "(ep %p) = %p\n", ep, epcd);
return epcd;
}
......@@ -329,8 +317,6 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc *wa,
struct usb_wireless_ep_comp_descriptor *epcd;
u8 unauth;
d_fnstart(3, dev, "(rpipe %p wa %p ep %p, urb %p)\n",
rpipe, wa, ep, urb);
epcd = rpipe_epc_find(dev, ep);
if (epcd == NULL) {
dev_err(dev, "ep 0x%02x: can't find companion descriptor\n",
......@@ -350,10 +336,12 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc *wa,
/* FIXME: use maximum speed as supported or recommended by device */
rpipe->descr.bSpeed = usb_pipeendpoint(urb->pipe) == 0 ?
UWB_PHY_RATE_53 : UWB_PHY_RATE_200;
d_printf(2, dev, "addr %u (0x%02x) rpipe #%u ep# %u speed %d\n",
dev_dbg(dev, "addr %u (0x%02x) rpipe #%u ep# %u speed %d\n",
urb->dev->devnum, urb->dev->devnum | unauth,
le16_to_cpu(rpipe->descr.wRPipeIndex),
usb_pipeendpoint(urb->pipe), rpipe->descr.bSpeed);
/* see security.c:wusb_update_address() */
if (unlikely(urb->dev->devnum == 0x80))
rpipe->descr.bDeviceAddress = 0;
......@@ -384,8 +372,6 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc *wa,
}
result = 0;
error:
d_fnend(3, dev, "(rpipe %p wa %p ep %p urb %p) = %d\n",
rpipe, wa, ep, urb, result);
return result;
}
......@@ -405,8 +391,6 @@ static int rpipe_check_aim(const struct wa_rpipe *rpipe, const struct wahc *wa,
u8 unauth = (usb_dev->wusb && !usb_dev->authenticated) ? 0x80 : 0;
u8 portnum = wusb_port_no_to_idx(urb->dev->portnum);
d_fnstart(3, dev, "(rpipe %p wa %p ep %p, urb %p)\n",
rpipe, wa, ep, urb);
#define AIM_CHECK(rdf, val, text) \
do { \
if (rpipe->descr.rdf != (val)) { \
......@@ -451,8 +435,6 @@ int rpipe_get_by_ep(struct wahc *wa, struct usb_host_endpoint *ep,
struct wa_rpipe *rpipe;
u8 eptype;
d_fnstart(3, dev, "(wa %p ep %p urb %p gfp 0x%08x)\n", wa, ep, urb,
gfp);
mutex_lock(&wa->rpipe_mutex);
rpipe = ep->hcpriv;
if (rpipe != NULL) {
......@@ -462,7 +444,7 @@ int rpipe_get_by_ep(struct wahc *wa, struct usb_host_endpoint *ep,
goto error;
}
__rpipe_get(rpipe);
d_printf(2, dev, "ep 0x%02x: reusing rpipe %u\n",
dev_dbg(dev, "ep 0x%02x: reusing rpipe %u\n",
ep->desc.bEndpointAddress,
le16_to_cpu(rpipe->descr.wRPipeIndex));
} else {
......@@ -480,14 +462,12 @@ int rpipe_get_by_ep(struct wahc *wa, struct usb_host_endpoint *ep,
ep->hcpriv = rpipe;
rpipe->ep = ep;
__rpipe_get(rpipe); /* for caching into ep->hcpriv */
d_printf(2, dev, "ep 0x%02x: using rpipe %u\n",
dev_dbg(dev, "ep 0x%02x: using rpipe %u\n",
ep->desc.bEndpointAddress,
le16_to_cpu(rpipe->descr.wRPipeIndex));
}
d_dump(4, dev, &rpipe->descr, sizeof(rpipe->descr));
error:
mutex_unlock(&wa->rpipe_mutex);
d_fnend(3, dev, "(wa %p ep %p urb %p gfp 0x%08x)\n", wa, ep, urb, gfp);
return result;
}
......@@ -507,7 +487,7 @@ int wa_rpipes_create(struct wahc *wa)
void wa_rpipes_destroy(struct wahc *wa)
{
struct device *dev = &wa->usb_iface->dev;
d_fnstart(3, dev, "(wa %p)\n", wa);
if (!bitmap_empty(wa->rpipe_bm, wa->rpipes)) {
char buf[256];
WARN_ON(1);
......@@ -515,7 +495,6 @@ void wa_rpipes_destroy(struct wahc *wa)
dev_err(dev, "BUG: pipes not released on exit: %s\n", buf);
}
kfree(wa->rpipe_bm);
d_fnend(3, dev, "(wa %p)\n", wa);
}
/*
......@@ -530,33 +509,20 @@ void wa_rpipes_destroy(struct wahc *wa)
*/
void rpipe_ep_disable(struct wahc *wa, struct usb_host_endpoint *ep)
{
struct device *dev = &wa->usb_iface->dev;
struct wa_rpipe *rpipe;
d_fnstart(2, dev, "(wa %p ep %p)\n", wa, ep);
mutex_lock(&wa->rpipe_mutex);
rpipe = ep->hcpriv;
if (rpipe != NULL) {
unsigned rc = atomic_read(&rpipe->refcnt.refcount);
int result;
u16 index = le16_to_cpu(rpipe->descr.wRPipeIndex);
if (rc != 1)
d_printf(1, dev, "(wa %p ep %p) rpipe %p refcnt %u\n",
wa, ep, rpipe, rc);
d_printf(1, dev, "rpipe %u: abort\n", index);
result = usb_control_msg(
usb_control_msg(
wa->usb_dev, usb_rcvctrlpipe(wa->usb_dev, 0),
USB_REQ_RPIPE_ABORT,
USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE,
0, index, NULL, 0, 1000 /* FIXME: arbitrary */);
if (result < 0 && result != -ENODEV /* dev is gone */)
d_printf(1, dev, "(wa %p rpipe %u): abort failed: %d\n",
wa, index, result);
rpipe_put(rpipe);
}
mutex_unlock(&wa->rpipe_mutex);
d_fnend(2, dev, "(wa %p ep %p)\n", wa, ep);
return;
}
EXPORT_SYMBOL_GPL(rpipe_ep_disable);
This diff is collapsed.
......@@ -22,19 +22,16 @@
*
* FIXME: docs
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kdev_t.h>
#include "uwb-internal.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
#include "uwb-internal.h"
/** Start Beaconing command structure */
/* Start Beaconing command structure */
struct uwb_rc_cmd_start_beacon {
struct uwb_rccb rccb;
__le16 wBPSTOffset;
......@@ -176,9 +173,6 @@ struct uwb_beca_e *__uwb_beca_find_bydev(struct uwb_rc *rc,
{
struct uwb_beca_e *bce, *next;
list_for_each_entry_safe(bce, next, &rc->uwb_beca.list, node) {
d_printf(6, NULL, "looking for addr %02x:%02x in %02x:%02x\n",
dev_addr->data[0], dev_addr->data[1],
bce->dev_addr.data[0], bce->dev_addr.data[1]);
if (!memcmp(&bce->dev_addr, dev_addr, sizeof(bce->dev_addr)))
goto out;
}
......
......@@ -40,10 +40,8 @@
* uwb_est_get_size()
*/
#include <linux/spinlock.h>
#define D_LOCAL 0
#include <linux/uwb/debug.h>
#include "uwb-internal.h"
#include "uwb-internal.h"
struct uwb_est {
u16 type_event_high;
......@@ -52,7 +50,6 @@ struct uwb_est {
const struct uwb_est_entry *entry;
};
static struct uwb_est *uwb_est;
static u8 uwb_est_size;
static u8 uwb_est_used;
......@@ -440,21 +437,12 @@ ssize_t uwb_est_find_size(struct uwb_rc *rc, const struct uwb_rceb *rceb,
u8 *ptr = (u8 *) rceb;
read_lock_irqsave(&uwb_est_lock, flags);
d_printf(2, dev, "Size query for event 0x%02x/%04x/%02x,"
" buffer size %ld\n",
(unsigned) rceb->bEventType,
(unsigned) le16_to_cpu(rceb->wEvent),
(unsigned) rceb->bEventContext,
(long) rceb_size);
size = -ENOSPC;
if (rceb_size < sizeof(*rceb))
goto out;
event = le16_to_cpu(rceb->wEvent);
type_event_high = rceb->bEventType << 8 | (event & 0xff00) >> 8;
for (itr = 0; itr < uwb_est_used; itr++) {
d_printf(3, dev, "Checking EST 0x%04x/%04x/%04x\n",
uwb_est[itr].type_event_high, uwb_est[itr].vendor,
uwb_est[itr].product);
if (uwb_est[itr].type_event_high != type_event_high)
continue;
size = uwb_est_get_size(rc, &uwb_est[itr],
......
......@@ -57,9 +57,8 @@
#include <linux/usb/wusb.h>
#include <linux/usb/wusb-wa.h>
#include <linux/uwb.h>
#include "uwb-internal.h"
#define D_LOCAL 1
#include <linux/uwb/debug.h>
/* The device uses commands and events from the WHCI specification, although
* reporting itself as WUSB compliant. */
......@@ -630,17 +629,13 @@ void hwarc_neep_cb(struct urb *urb)
switch (result = urb->status) {
case 0:
d_printf(3, dev, "NEEP: receive stat %d, %zu bytes\n",
urb->status, (size_t)urb->actual_length);
uwb_rc_neh_grok(hwarc->uwb_rc, urb->transfer_buffer,
urb->actual_length);
break;
case -ECONNRESET: /* Not an error, but a controlled situation; */
case -ENOENT: /* (we killed the URB)...so, no broadcast */
d_printf(2, dev, "NEEP: URB reset/noent %d\n", urb->status);
goto out;
case -ESHUTDOWN: /* going away! */
d_printf(2, dev, "NEEP: URB down %d\n", urb->status);
goto out;
default: /* On general errors, retry unless it gets ugly */
if (edc_inc(&hwarc->neep_edc, EDC_MAX_ERRORS,
......@@ -649,7 +644,6 @@ void hwarc_neep_cb(struct urb *urb)
dev_err(dev, "NEEP: URB error %d\n", urb->status);
}
result = usb_submit_urb(urb, GFP_ATOMIC);
d_printf(3, dev, "NEEP: submit %d\n", result);
if (result < 0) {
dev_err(dev, "NEEP: Can't resubmit URB (%d) resetting device\n",
result);
......@@ -758,7 +752,7 @@ static int hwarc_get_version(struct uwb_rc *rc)
itr_size = le16_to_cpu(usb_dev->actconfig->desc.wTotalLength);
while (itr_size >= sizeof(*hdr)) {
hdr = (struct usb_descriptor_header *) itr;
d_printf(3, dev, "Extra device descriptor: "
dev_dbg(dev, "Extra device descriptor: "
"type %02x/%u bytes @ %zu (%zu left)\n",
hdr->bDescriptorType, hdr->bLength,
(itr - usb_dev->rawdescriptors[actconfig_idx]),
......@@ -794,8 +788,7 @@ static int hwarc_get_version(struct uwb_rc *rc)
goto error;
}
rc->version = version;
d_printf(3, dev, "Device supports WUSB protocol version 0x%04x \n",
rc->version);
dev_dbg(dev, "Device supports WUSB protocol version 0x%04x \n", rc->version);
result = 0;
error:
return result;
......@@ -876,7 +869,6 @@ static void hwarc_disconnect(struct usb_interface *iface)
uwb_rc_rm(uwb_rc);
usb_put_intf(hwarc->usb_iface);
usb_put_dev(hwarc->usb_dev);
d_printf(1, &hwarc->usb_iface->dev, "freed hwarc %p\n", hwarc);
kfree(hwarc);
uwb_rc_put(uwb_rc); /* when creating the device, refcount = 1 */
}
......@@ -924,13 +916,7 @@ static struct usb_driver hwarc_driver = {
static int __init hwarc_driver_init(void)
{
int result;
result = usb_register(&hwarc_driver);
if (result < 0)
printk(KERN_ERR "HWA-RC: Cannot register USB driver: %d\n",
result);
return result;
return usb_register(&hwarc_driver);
}
module_init(hwarc_driver_init);
......
......@@ -34,10 +34,7 @@
#include <linux/uwb.h>
#include <linux/random.h>
#define D_LOCAL 0
#include <linux/uwb/debug.h>
/**
/*
* i1480_rceb_check - Check RCEB for expected field values
* @i1480: pointer to device for which RCEB is being checked
* @rceb: RCEB being checked
......@@ -83,7 +80,7 @@ int i1480_rceb_check(const struct i1480 *i1480, const struct uwb_rceb *rceb,
EXPORT_SYMBOL_GPL(i1480_rceb_check);
/**
/*
* Execute a Radio Control Command
*
* Command data has to be in i1480->cmd_buf.
......@@ -101,7 +98,6 @@ ssize_t i1480_cmd(struct i1480 *i1480, const char *cmd_name, size_t cmd_size,
u8 expected_type = reply->bEventType;
u8 context;
d_fnstart(3, i1480->dev, "(%p, %s, %zu)\n", i1480, cmd_name, cmd_size);
init_completion(&i1480->evt_complete);
i1480->evt_result = -EINPROGRESS;
do {
......@@ -150,8 +146,6 @@ ssize_t i1480_cmd(struct i1480 *i1480, const char *cmd_name, size_t cmd_size,
result = i1480_rceb_check(i1480, i1480->evt_buf, cmd_name, context,
expected_type, expected_event);
error:
d_fnend(3, i1480->dev, "(%p, %s, %zu) = %zd\n",
i1480, cmd_name, cmd_size, result);
return result;
}
EXPORT_SYMBOL_GPL(i1480_cmd);
......
......@@ -31,9 +31,6 @@
#include <linux/uwb.h>
#include "i1480-dfu.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
/*
* Descriptor for a continuous segment of MAC fw data
*/
......@@ -184,10 +181,6 @@ ssize_t i1480_fw_cmp(struct i1480 *i1480, struct fw_hdr *hdr)
}
if (memcmp(i1480->cmd_buf, bin + src_itr, result)) {
u8 *buf = i1480->cmd_buf;
d_printf(2, i1480->dev,
"original data @ %p + %u, %zu bytes\n",
bin, src_itr, result);
d_dump(4, i1480->dev, bin + src_itr, result);
for (cnt = 0; cnt < result; cnt++)
if (bin[src_itr + cnt] != buf[cnt]) {
dev_err(i1480->dev, "byte failed at "
......@@ -224,7 +217,6 @@ int mac_fw_hdrs_push(struct i1480 *i1480, struct fw_hdr *hdr,
struct fw_hdr *hdr_itr;
int verif_retry_count;
d_fnstart(3, dev, "(%p, %p)\n", i1480, hdr);
/* Now, header by header, push them to the hw */
for (hdr_itr = hdr; hdr_itr != NULL; hdr_itr = hdr_itr->next) {
verif_retry_count = 0;
......@@ -264,7 +256,6 @@ int mac_fw_hdrs_push(struct i1480 *i1480, struct fw_hdr *hdr,
break;
}
}
d_fnend(3, dev, "(%zd)\n", result);
return result;
}
......@@ -337,11 +328,9 @@ int __mac_fw_upload(struct i1480 *i1480, const char *fw_name,
const struct firmware *fw;
struct fw_hdr *fw_hdrs;
d_fnstart(3, i1480->dev, "(%p, %s, %s)\n", i1480, fw_name, fw_tag);
result = request_firmware(&fw, fw_name, i1480->dev);
if (result < 0) /* Up to caller to complain on -ENOENT */
goto out;
d_printf(3, i1480->dev, "%s fw '%s': uploading\n", fw_tag, fw_name);
result = fw_hdrs_load(i1480, &fw_hdrs, fw->data, fw->size);
if (result < 0) {
dev_err(i1480->dev, "%s fw '%s': failed to parse firmware "
......@@ -363,8 +352,6 @@ int __mac_fw_upload(struct i1480 *i1480, const char *fw_name,
out_release:
release_firmware(fw);
out:
d_fnend(3, i1480->dev, "(%p, %s, %s) = %d\n", i1480, fw_name, fw_tag,
result);
return result;
}
......@@ -433,7 +420,6 @@ int i1480_fw_is_running_q(struct i1480 *i1480)
int result;
u32 *val = (u32 *) i1480->cmd_buf;
d_fnstart(3, i1480->dev, "(i1480 %p)\n", i1480);
for (cnt = 0; cnt < 10; cnt++) {
msleep(100);
result = i1480->read(i1480, 0x80080000, 4);
......@@ -447,7 +433,6 @@ int i1480_fw_is_running_q(struct i1480 *i1480)
dev_err(i1480->dev, "Timed out waiting for fw to start\n");
result = -ETIMEDOUT;
out:
d_fnend(3, i1480->dev, "(i1480 %p) = %d\n", i1480, result);
return result;
}
......@@ -467,7 +452,6 @@ int i1480_mac_fw_upload(struct i1480 *i1480)
int result = 0, deprecated_name = 0;
struct i1480_rceb *rcebe = (void *) i1480->evt_buf;
d_fnstart(3, i1480->dev, "(%p)\n", i1480);
result = __mac_fw_upload(i1480, i1480->mac_fw_name, "MAC");
if (result == -ENOENT) {
result = __mac_fw_upload(i1480, i1480->mac_fw_name_deprecate,
......@@ -501,7 +485,6 @@ int i1480_mac_fw_upload(struct i1480 *i1480)
dev_err(i1480->dev, "MAC fw '%s': initialization event returns "
"wrong size (%zu bytes vs %zu needed)\n",
i1480->mac_fw_name, i1480->evt_result, sizeof(*rcebe));
dump_bytes(i1480->dev, rcebe, min(i1480->evt_result, (ssize_t)32));
goto error_size;
}
result = -EIO;
......@@ -522,6 +505,5 @@ int i1480_mac_fw_upload(struct i1480 *i1480)
error_init_timeout:
error_size:
error_setup:
d_fnend(3, i1480->dev, "(i1480 %p) = %d\n", i1480, result);
return result;
}
......@@ -43,10 +43,6 @@
#include <linux/usb/wusb-wa.h>
#include "i1480-dfu.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
struct i1480_usb {
struct i1480 i1480;
struct usb_device *usb_dev;
......@@ -117,8 +113,6 @@ int i1480_usb_write(struct i1480 *i1480, u32 memory_address,
struct i1480_usb *i1480_usb = container_of(i1480, struct i1480_usb, i1480);
size_t buffer_size, itr = 0;
d_fnstart(3, i1480->dev, "(%p, 0x%08x, %p, %zu)\n",
i1480, memory_address, buffer, size);
BUG_ON(size & 0x3); /* Needs to be a multiple of 4 */
while (size > 0) {
buffer_size = size < i1480->buf_size ? size : i1480->buf_size;
......@@ -131,16 +125,10 @@ int i1480_usb_write(struct i1480 *i1480, u32 memory_address,
i1480->cmd_buf, buffer_size, 100 /* FIXME: arbitrary */);
if (result < 0)
break;
d_printf(3, i1480->dev,
"wrote @ 0x%08x %u bytes (of %zu bytes requested)\n",
memory_address, result, buffer_size);
d_dump(4, i1480->dev, i1480->cmd_buf, result);
itr += result;
memory_address += result;
size -= result;
}
d_fnend(3, i1480->dev, "(%p, 0x%08x, %p, %zu) = %d\n",
i1480, memory_address, buffer, size, result);
return result;
}
......@@ -165,8 +153,6 @@ int i1480_usb_read(struct i1480 *i1480, u32 addr, size_t size)
size_t itr, read_size = i1480->buf_size;
struct i1480_usb *i1480_usb = container_of(i1480, struct i1480_usb, i1480);
d_fnstart(3, i1480->dev, "(%p, 0x%08x, %zu)\n",
i1480, addr, size);
BUG_ON(size > i1480->buf_size);
BUG_ON(size & 0x3); /* Needs to be a multiple of 4 */
BUG_ON(read_size > 512);
......@@ -200,10 +186,6 @@ int i1480_usb_read(struct i1480 *i1480, u32 addr, size_t size)
}
result = bytes;
out:
d_fnend(3, i1480->dev, "(%p, 0x%08x, %zu) = %zd\n",
i1480, addr, size, result);
if (result > 0)
d_dump(4, i1480->dev, i1480->cmd_buf, result);
return result;
}
......@@ -259,7 +241,6 @@ int i1480_usb_wait_init_done(struct i1480 *i1480)
struct i1480_usb *i1480_usb = container_of(i1480, struct i1480_usb, i1480);
struct usb_endpoint_descriptor *epd;
d_fnstart(3, dev, "(%p)\n", i1480);
init_completion(&i1480->evt_complete);
i1480->evt_result = -EINPROGRESS;
epd = &i1480_usb->usb_iface->cur_altsetting->endpoint[0].desc;
......@@ -281,14 +262,12 @@ int i1480_usb_wait_init_done(struct i1480 *i1480)
goto error_wait;
}
usb_kill_urb(i1480_usb->neep_urb);
d_fnend(3, dev, "(%p) = 0\n", i1480);
return 0;
error_wait:
usb_kill_urb(i1480_usb->neep_urb);
error_submit:
i1480->evt_result = result;
d_fnend(3, dev, "(%p) = %d\n", i1480, result);
return result;
}
......@@ -319,7 +298,6 @@ int i1480_usb_cmd(struct i1480 *i1480, const char *cmd_name, size_t cmd_size)
struct uwb_rccb *cmd = i1480->cmd_buf;
u8 iface_no;
d_fnstart(3, dev, "(%p, %s, %zu)\n", i1480, cmd_name, cmd_size);
/* Post a read on the notification & event endpoint */
iface_no = i1480_usb->usb_iface->cur_altsetting->desc.bInterfaceNumber;
epd = &i1480_usb->usb_iface->cur_altsetting->endpoint[0].desc;
......@@ -347,15 +325,11 @@ int i1480_usb_cmd(struct i1480 *i1480, const char *cmd_name, size_t cmd_size)
cmd_name, result);
goto error_submit_ep0;
}
d_fnend(3, dev, "(%p, %s, %zu) = %d\n",
i1480, cmd_name, cmd_size, result);
return result;
error_submit_ep0:
usb_kill_urb(i1480_usb->neep_urb);
error_submit_ep1:
d_fnend(3, dev, "(%p, %s, %zu) = %d\n",
i1480, cmd_name, cmd_size, result);
return result;
}
......
......@@ -68,11 +68,7 @@
#include <linux/etherdevice.h>
#include "i1480u-wlp.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
/**
/*
* Setup the RX context
*
* Each URB is provided with a transfer_buffer that is the data field
......@@ -129,7 +125,7 @@ int i1480u_rx_setup(struct i1480u *i1480u)
}
/** Release resources associated to the rx context */
/* Release resources associated to the rx context */
void i1480u_rx_release(struct i1480u *i1480u)
{
int cnt;
......@@ -155,7 +151,7 @@ void i1480u_rx_unlink_urbs(struct i1480u *i1480u)
}
}
/** Fix an out-of-sequence packet */
/* Fix an out-of-sequence packet */
#define i1480u_fix(i1480u, msg...) \
do { \
if (printk_ratelimit()) \
......@@ -166,7 +162,7 @@ do { \
} while (0)
/** Drop an out-of-sequence packet */
/* Drop an out-of-sequence packet */
#define i1480u_drop(i1480u, msg...) \
do { \
if (printk_ratelimit()) \
......@@ -177,7 +173,7 @@ do { \
/** Finalizes setting up the SKB and delivers it
/* Finalizes setting up the SKB and delivers it
*
* We first pass the incoming frame to WLP substack for verification. It
* may also be a WLP association frame in which case WLP will take over the
......@@ -192,18 +188,11 @@ void i1480u_skb_deliver(struct i1480u *i1480u)
struct net_device *net_dev = i1480u->net_dev;
struct device *dev = &i1480u->usb_iface->dev;
d_printf(6, dev, "RX delivered pre skb(%p), %u bytes\n",
i1480u->rx_skb, i1480u->rx_skb->len);
d_dump(7, dev, i1480u->rx_skb->data, i1480u->rx_skb->len);
should_parse = wlp_receive_frame(dev, &i1480u->wlp, i1480u->rx_skb,
&i1480u->rx_srcaddr);
if (!should_parse)
goto out;
i1480u->rx_skb->protocol = eth_type_trans(i1480u->rx_skb, net_dev);
d_printf(5, dev, "RX delivered skb(%p), %u bytes\n",
i1480u->rx_skb, i1480u->rx_skb->len);
d_dump(7, dev, i1480u->rx_skb->data,
i1480u->rx_skb->len > 72 ? 72 : i1480u->rx_skb->len);
i1480u->stats.rx_packets++;
i1480u->stats.rx_bytes += i1480u->rx_untd_pkt_size;
net_dev->last_rx = jiffies;
......@@ -216,7 +205,7 @@ void i1480u_skb_deliver(struct i1480u *i1480u)
}
/**
/*
* Process a buffer of data received from the USB RX endpoint
*
* First fragment arrives with next or last fragment. All other fragments
......@@ -404,7 +393,7 @@ void i1480u_rx_buffer(struct i1480u_rx_buf *rx_buf)
}
/**
/*
* Called when an RX URB has finished receiving or has found some kind
* of error condition.
*
......
......@@ -55,8 +55,6 @@
*/
#include "i1480u-wlp.h"
#define D_LOCAL 5
#include <linux/uwb/debug.h>
enum {
/* This is only for Next and Last TX packets */
......@@ -64,7 +62,7 @@ enum {
- sizeof(struct untd_hdr_rst),
};
/** Free resources allocated to a i1480u tx context. */
/* Free resources allocated to a i1480u tx context. */
static
void i1480u_tx_free(struct i1480u_tx *wtx)
{
......@@ -99,7 +97,7 @@ void i1480u_tx_unlink_urbs(struct i1480u *i1480u)
}
/**
/*
* Callback for a completed tx USB URB.
*
* TODO:
......@@ -149,8 +147,6 @@ void i1480u_tx_cb(struct urb *urb)
<= i1480u->tx_inflight.threshold
&& netif_queue_stopped(net_dev)
&& i1480u->tx_inflight.threshold != 0) {
if (d_test(2) && printk_ratelimit())
d_printf(2, dev, "Restart queue. \n");
netif_start_queue(net_dev);
atomic_inc(&i1480u->tx_inflight.restart_count);
}
......@@ -158,7 +154,7 @@ void i1480u_tx_cb(struct urb *urb)
}
/**
/*
* Given a buffer that doesn't fit in a single fragment, create an
* scatter/gather structure for delivery to the USB pipe.
*
......@@ -253,15 +249,11 @@ int i1480u_tx_create_n(struct i1480u_tx *wtx, struct sk_buff *skb,
/* Now do each remaining fragment */
result = -EINVAL;
while (pl_size_left > 0) {
d_printf(5, NULL, "ITR HDR: pl_size_left %zu buf_itr %zu\n",
pl_size_left, buf_itr - wtx->buf);
if (buf_itr + sizeof(*untd_hdr_rst) - wtx->buf
> wtx->buf_size) {
printk(KERN_ERR "BUG: no space for header\n");
goto error_bug;
}
d_printf(5, NULL, "ITR HDR 2: pl_size_left %zu buf_itr %zu\n",
pl_size_left, buf_itr - wtx->buf);
untd_hdr_rst = buf_itr;
buf_itr += sizeof(*untd_hdr_rst);
if (pl_size_left > i1480u_MAX_PL_SIZE) {
......@@ -271,9 +263,6 @@ int i1480u_tx_create_n(struct i1480u_tx *wtx, struct sk_buff *skb,
frg_pl_size = pl_size_left;
untd_hdr_set_type(&untd_hdr_rst->hdr, i1480u_PKT_FRAG_LST);
}
d_printf(5, NULL,
"ITR PL: pl_size_left %zu buf_itr %zu frg_pl_size %zu\n",
pl_size_left, buf_itr - wtx->buf, frg_pl_size);
untd_hdr_set_rx_tx(&untd_hdr_rst->hdr, 0);
untd_hdr_rst->hdr.len = cpu_to_le16(frg_pl_size);
untd_hdr_rst->padding = 0;
......@@ -286,9 +275,6 @@ int i1480u_tx_create_n(struct i1480u_tx *wtx, struct sk_buff *skb,
buf_itr += frg_pl_size;
pl_itr += frg_pl_size;
pl_size_left -= frg_pl_size;
d_printf(5, NULL,
"ITR PL 2: pl_size_left %zu buf_itr %zu frg_pl_size %zu\n",
pl_size_left, buf_itr - wtx->buf, frg_pl_size);
}
dev_kfree_skb_irq(skb);
return 0;
......@@ -308,7 +294,7 @@ int i1480u_tx_create_n(struct i1480u_tx *wtx, struct sk_buff *skb,
}
/**
/*
* Given a buffer that fits in a single fragment, fill out a @wtx
* struct for transmitting it down the USB pipe.
*
......@@ -346,7 +332,7 @@ int i1480u_tx_create_1(struct i1480u_tx *wtx, struct sk_buff *skb,
}
/**
/*
* Given a skb to transmit, massage it to become palatable for the TX pipe
*
* This will break the buffer in chunks smaller than
......@@ -425,7 +411,7 @@ struct i1480u_tx *i1480u_tx_create(struct i1480u *i1480u,
return NULL;
}
/**
/*
* Actual fragmentation and transmission of frame
*
* @wlp: WLP substack data structure
......@@ -447,20 +433,12 @@ int i1480u_xmit_frame(struct wlp *wlp, struct sk_buff *skb,
struct i1480u_tx *wtx;
struct wlp_tx_hdr *wlp_tx_hdr;
static unsigned char dev_bcast[2] = { 0xff, 0xff };
#if 0
int lockup = 50;
#endif
d_fnstart(6, dev, "(skb %p (%u), net_dev %p)\n", skb, skb->len,
net_dev);
BUG_ON(i1480u->wlp.rc == NULL);
if ((net_dev->flags & IFF_UP) == 0)
goto out;
result = -EBUSY;
if (atomic_read(&i1480u->tx_inflight.count) >= i1480u->tx_inflight.max) {
if (d_test(2) && printk_ratelimit())
d_printf(2, dev, "Max frames in flight "
"stopping queue.\n");
netif_stop_queue(net_dev);
goto error_max_inflight;
}
......@@ -489,21 +467,6 @@ int i1480u_xmit_frame(struct wlp *wlp, struct sk_buff *skb,
wlp_tx_hdr_set_delivery_id_type(wlp_tx_hdr, i1480u->options.pca_base_priority);
}
#if 0
dev_info(dev, "TX delivering skb -> USB, %zu bytes\n", skb->len);
dump_bytes(dev, skb->data, skb->len > 72 ? 72 : skb->len);
#endif
#if 0
/* simulates a device lockup after every lockup# packets */
if (lockup && ((i1480u->stats.tx_packets + 1) % lockup) == 0) {
/* Simulate a dropped transmit interrupt */
net_dev->trans_start = jiffies;
netif_stop_queue(net_dev);
dev_err(dev, "Simulate lockup at %ld\n", jiffies);
return result;
}
#endif
result = usb_submit_urb(wtx->urb, GFP_ATOMIC); /* Go baby */
if (result < 0) {
dev_err(dev, "TX: cannot submit URB: %d\n", result);
......@@ -513,8 +476,6 @@ int i1480u_xmit_frame(struct wlp *wlp, struct sk_buff *skb,
}
atomic_inc(&i1480u->tx_inflight.count);
net_dev->trans_start = jiffies;
d_fnend(6, dev, "(skb %p (%u), net_dev %p) = %d\n", skb, skb->len,
net_dev, result);
return result;
error_tx_urb_submit:
......@@ -522,13 +483,11 @@ int i1480u_xmit_frame(struct wlp *wlp, struct sk_buff *skb,
error_wtx_alloc:
error_max_inflight:
out:
d_fnend(6, dev, "(skb %p (%u), net_dev %p) = %d\n", skb, skb->len,
net_dev, result);
return result;
}
/**
/*
* Transmit an skb Called when an skbuf has to be transmitted
*
* The skb is first passed to WLP substack to ensure this is a valid
......@@ -551,9 +510,6 @@ int i1480u_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
struct device *dev = &i1480u->usb_iface->dev;
struct uwb_dev_addr dst;
d_fnstart(6, dev, "(skb %p (%u), net_dev %p)\n", skb, skb->len,
net_dev);
BUG_ON(i1480u->wlp.rc == NULL);
if ((net_dev->flags & IFF_UP) == 0)
goto error;
result = wlp_prepare_tx_frame(dev, &i1480u->wlp, skb, &dst);
......@@ -562,31 +518,25 @@ int i1480u_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
"Dropping packet.\n", result);
goto error;
} else if (result == 1) {
d_printf(6, dev, "WLP will transmit frame. \n");
/* trans_start time will be set when WLP actually transmits
* the frame */
goto out;
}
d_printf(6, dev, "Transmitting frame. \n");
result = i1480u_xmit_frame(&i1480u->wlp, skb, &dst);
if (result < 0) {
dev_err(dev, "Frame TX failed (%d).\n", result);
goto error;
}
d_fnend(6, dev, "(skb %p (%u), net_dev %p) = %d\n", skb, skb->len,
net_dev, result);
return NETDEV_TX_OK;
error:
dev_kfree_skb_any(skb);
i1480u->stats.tx_dropped++;
out:
d_fnend(6, dev, "(skb %p (%u), net_dev %p) = %d\n", skb, skb->len,
net_dev, result);
return NETDEV_TX_OK;
}
/**
/*
* Called when a pkt transmission doesn't complete in a reasonable period
* Device reset may sleep - do it outside of interrupt context (delayed)
*/
......
......@@ -22,7 +22,6 @@
*
* FIXME: docs
*/
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/err.h>
......@@ -30,10 +29,6 @@
#include <linux/random.h>
#include "uwb-internal.h"
#define D_LOCAL 1
#include <linux/uwb/debug.h>
/* We initialize addresses to 0xff (invalid, as it is bcast) */
static inline void uwb_dev_addr_init(struct uwb_dev_addr *addr)
{
......@@ -104,12 +99,9 @@ static void uwb_dev_sys_release(struct device *dev)
{
struct uwb_dev *uwb_dev = to_uwb_dev(dev);
d_fnstart(4, NULL, "(dev %p uwb_dev %p)\n", dev, uwb_dev);
uwb_bce_put(uwb_dev->bce);
d_printf(0, &uwb_dev->dev, "uwb_dev %p freed\n", uwb_dev);
memset(uwb_dev, 0x69, sizeof(*uwb_dev));
kfree(uwb_dev);
d_fnend(4, NULL, "(dev %p uwb_dev %p) = void\n", dev, uwb_dev);
}
/*
......@@ -275,12 +267,8 @@ static struct attribute_group *groups[] = {
*/
static int __uwb_dev_sys_add(struct uwb_dev *uwb_dev, struct device *parent_dev)
{
int result;
struct device *dev;
d_fnstart(4, NULL, "(uwb_dev %p parent_dev %p)\n", uwb_dev, parent_dev);
BUG_ON(parent_dev == NULL);
dev = &uwb_dev->dev;
/* Device sysfs files are only useful for neighbor devices not
local radio controllers. */
......@@ -289,18 +277,14 @@ static int __uwb_dev_sys_add(struct uwb_dev *uwb_dev, struct device *parent_dev)
dev->parent = parent_dev;
dev_set_drvdata(dev, uwb_dev);
result = device_add(dev);
d_fnend(4, NULL, "(uwb_dev %p parent_dev %p) = %d\n", uwb_dev, parent_dev, result);
return result;
return device_add(dev);
}
static void __uwb_dev_sys_rm(struct uwb_dev *uwb_dev)
{
d_fnstart(4, NULL, "(uwb_dev %p)\n", uwb_dev);
dev_set_drvdata(&uwb_dev->dev, NULL);
device_del(&uwb_dev->dev);
d_fnend(4, NULL, "(uwb_dev %p) = void\n", uwb_dev);
}
......@@ -384,7 +368,6 @@ int __uwb_dev_offair(struct uwb_dev *uwb_dev, struct uwb_rc *rc)
struct device *dev = &uwb_dev->dev;
char macbuf[UWB_ADDR_STRSIZE], devbuf[UWB_ADDR_STRSIZE];
d_fnstart(3, NULL, "(dev %p [uwb_dev %p], uwb_rc %p)\n", dev, uwb_dev, rc);
uwb_mac_addr_print(macbuf, sizeof(macbuf), &uwb_dev->mac_addr);
uwb_dev_addr_print(devbuf, sizeof(devbuf), &uwb_dev->dev_addr);
dev_info(dev, "uwb device (mac %s dev %s) disconnected from %s %s\n",
......@@ -393,7 +376,7 @@ int __uwb_dev_offair(struct uwb_dev *uwb_dev, struct uwb_rc *rc)
rc ? dev_name(rc->uwb_dev.dev.parent) : "");
uwb_dev_rm(uwb_dev);
uwb_dev_put(uwb_dev); /* for the creation in _onair() */
d_fnend(3, NULL, "(dev %p [uwb_dev %p], uwb_rc %p) = 0\n", dev, uwb_dev, rc);
return 0;
}
......
......@@ -86,8 +86,6 @@
#include <linux/err.h>
#include "uwb-internal.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
/*
* UWB Radio Controller Notification/Event Handle
......@@ -479,8 +477,6 @@ void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size)
size_t size, real_size, event_size;
int needtofree;
d_fnstart(3, dev, "(rc %p buf %p %zu buf_size)\n", rc, buf, buf_size);
d_printf(2, dev, "groking event block: %zu bytes\n", buf_size);
itr = buf;
size = buf_size;
while (size > 0) {
......@@ -528,10 +524,7 @@ void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size)
itr += real_size;
size -= real_size;
d_printf(2, dev, "consumed %zd bytes, %zu left\n",
event_size, size);
}
d_fnend(3, dev, "(rc %p buf %p %zu buf_size) = void\n", rc, buf, buf_size);
}
EXPORT_SYMBOL_GPL(uwb_rc_neh_grok);
......
......@@ -32,8 +32,6 @@
#include <linux/err.h>
#include "uwb-internal.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
/**
* Command result codes (WUSB1.0[T8-69])
......
......@@ -7,8 +7,6 @@
*/
#include <linux/kernel.h>
#include <linux/uwb/umc.h>
#define D_LOCAL 0
#include <linux/uwb/debug.h>
static void umc_device_release(struct device *dev)
{
......@@ -53,8 +51,6 @@ int umc_device_register(struct umc_dev *umc)
{
int err;
d_fnstart(3, &umc->dev, "(umc_dev %p)\n", umc);
err = request_resource(umc->resource.parent, &umc->resource);
if (err < 0) {
dev_err(&umc->dev, "can't allocate resource range "
......@@ -68,13 +64,11 @@ int umc_device_register(struct umc_dev *umc)
err = device_register(&umc->dev);
if (err < 0)
goto error_device_register;
d_fnend(3, &umc->dev, "(umc_dev %p) = 0\n", umc);
return 0;
error_device_register:
release_resource(&umc->resource);
error_request_resource:
d_fnend(3, &umc->dev, "(umc_dev %p) = %d\n", umc, err);
return err;
}
EXPORT_SYMBOL_GPL(umc_device_register);
......@@ -94,10 +88,8 @@ void umc_device_unregister(struct umc_dev *umc)
if (!umc)
return;
dev = get_device(&umc->dev);
d_fnstart(3, dev, "(umc_dev %p)\n", umc);
device_unregister(&umc->dev);
release_resource(&umc->resource);
d_fnend(3, dev, "(umc_dev %p) = void\n", umc);
put_device(dev);
}
EXPORT_SYMBOL_GPL(umc_device_unregister);
......@@ -68,17 +68,13 @@
*
* Handler functions are called normally uwbd_evt_handle_*().
*/
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/freezer.h>
#include "uwb-internal.h"
#define D_LOCAL 1
#include <linux/uwb/debug.h>
#include "uwb-internal.h"
/**
/*
* UWBD Event handler function signature
*
* Return !0 if the event needs not to be freed (ie the handler
......@@ -101,9 +97,8 @@ struct uwbd_event {
const char *name;
};
/** Table of handlers for and properties of the UWBD Radio Control Events */
static
struct uwbd_event uwbd_events[] = {
/* Table of handlers for and properties of the UWBD Radio Control Events */
static struct uwbd_event uwbd_urc_events[] = {
[UWB_RC_EVT_IE_RCV] = {
.handler = uwbd_evt_handle_rc_ie_rcv,
.name = "IE_RECEIVED"
......@@ -146,23 +141,15 @@ struct uwbd_evt_type_handler {
size_t size;
};
#define UWBD_EVT_TYPE_HANDLER(n,a) { \
.name = (n), \
.uwbd_events = (a), \
.size = sizeof(a)/sizeof((a)[0]) \
}
/** Table of handlers for each UWBD Event type. */
static
struct uwbd_evt_type_handler uwbd_evt_type_handlers[] = {
[UWB_RC_CET_GENERAL] = UWBD_EVT_TYPE_HANDLER("RC", uwbd_events)
/* Table of handlers for each UWBD Event type. */
static struct uwbd_evt_type_handler uwbd_urc_evt_type_handlers[] = {
[UWB_RC_CET_GENERAL] = {
.name = "URC",
.uwbd_events = uwbd_urc_events,
.size = ARRAY_SIZE(uwbd_urc_events),
},
};
static const
size_t uwbd_evt_type_handlers_len =
sizeof(uwbd_evt_type_handlers) / sizeof(uwbd_evt_type_handlers[0]);
static const struct uwbd_event uwbd_message_handlers[] = {
[UWB_EVT_MSG_RESET] = {
.handler = uwbd_msg_handle_reset,
......@@ -170,7 +157,7 @@ static const struct uwbd_event uwbd_message_handlers[] = {
},
};
/**
/*
* Handle an URC event passed to the UWB Daemon
*
* @evt: the event to handle
......@@ -190,6 +177,7 @@ static const struct uwbd_event uwbd_message_handlers[] = {
static
int uwbd_event_handle_urc(struct uwb_event *evt)
{
int result = -EINVAL;
struct uwbd_evt_type_handler *type_table;
uwbd_evt_handler_f handler;
u8 type, context;
......@@ -199,26 +187,24 @@ int uwbd_event_handle_urc(struct uwb_event *evt)
event = le16_to_cpu(evt->notif.rceb->wEvent);
context = evt->notif.rceb->bEventContext;
if (type > uwbd_evt_type_handlers_len) {
printk(KERN_ERR "UWBD: event type %u: unknown (too high)\n", type);
return -EINVAL;
}
type_table = &uwbd_evt_type_handlers[type];
if (type_table->uwbd_events == NULL) {
printk(KERN_ERR "UWBD: event type %u: unknown\n", type);
return -EINVAL;
}
if (event > type_table->size) {
printk(KERN_ERR "UWBD: event %s[%u]: unknown (too high)\n",
type_table->name, event);
return -EINVAL;
}
if (type > ARRAY_SIZE(uwbd_urc_evt_type_handlers))
goto out;
type_table = &uwbd_urc_evt_type_handlers[type];
if (type_table->uwbd_events == NULL)
goto out;
if (event > type_table->size)
goto out;
handler = type_table->uwbd_events[event].handler;
if (handler == NULL) {
printk(KERN_ERR "UWBD: event %s[%u]: unknown\n", type_table->name, event);
return -EINVAL;
}
return (*handler)(evt);
if (handler == NULL)
goto out;
result = (*handler)(evt);
out:
if (result < 0)
dev_err(&evt->rc->uwb_dev.dev,
"UWBD: event 0x%02x/%04x/%02x, handling failed: %d\n",
type, event, context, result);
return result;
}
static void uwbd_event_handle_message(struct uwb_event *evt)
......
......@@ -48,10 +48,8 @@
#include <linux/uwb.h>
#include <linux/uwb/whci.h>
#include <linux/uwb/umc.h>
#include "uwb-internal.h"
#define D_LOCAL 0
#include <linux/uwb/debug.h>
#include "uwb-internal.h"
/**
* Descriptor for an instance of the UWB Radio Control Driver that
......@@ -97,13 +95,8 @@ static int whcrc_cmd(struct uwb_rc *uwb_rc,
struct device *dev = &whcrc->umc_dev->dev;
u32 urccmd;
d_fnstart(3, dev, "(%p, %p, %zu)\n", uwb_rc, cmd, cmd_size);
might_sleep();
if (cmd_size >= 4096) {
result = -E2BIG;
goto error;
}
if (cmd_size >= 4096)
return -EINVAL;
/*
* If the URC is halted, then the hardware has reset itself.
......@@ -114,16 +107,14 @@ static int whcrc_cmd(struct uwb_rc *uwb_rc,
if (le_readl(whcrc->rc_base + URCSTS) & URCSTS_HALTED) {
dev_err(dev, "requesting reset of halted radio controller\n");
uwb_rc_reset_all(uwb_rc);
result = -EIO;
goto error;
return -EIO;
}
result = wait_event_timeout(whcrc->cmd_wq,
!(le_readl(whcrc->rc_base + URCCMD) & URCCMD_ACTIVE), HZ/2);
if (result == 0) {
dev_err(dev, "device is not ready to execute commands\n");
result = -ETIMEDOUT;
goto error;
return -ETIMEDOUT;
}
memmove(whcrc->cmd_buf, cmd, cmd_size);
......@@ -136,10 +127,7 @@ static int whcrc_cmd(struct uwb_rc *uwb_rc,
whcrc->rc_base + URCCMD);
spin_unlock(&whcrc->irq_lock);
error:
d_fnend(3, dev, "(%p, %p, %zu) = %d\n",
uwb_rc, cmd, cmd_size, result);
return result;
return 0;
}
static int whcrc_reset(struct uwb_rc *rc)
......@@ -166,34 +154,25 @@ static int whcrc_reset(struct uwb_rc *rc)
static
void whcrc_enable_events(struct whcrc *whcrc)
{
struct device *dev = &whcrc->umc_dev->dev;
u32 urccmd;
d_fnstart(4, dev, "(whcrc %p)\n", whcrc);
le_writeq(whcrc->evt_dma_buf, whcrc->rc_base + URCEVTADDR);
spin_lock(&whcrc->irq_lock);
urccmd = le_readl(whcrc->rc_base + URCCMD) & ~URCCMD_ACTIVE;
le_writel(urccmd | URCCMD_EARV, whcrc->rc_base + URCCMD);
spin_unlock(&whcrc->irq_lock);
d_fnend(4, dev, "(whcrc %p) = void\n", whcrc);
}
static void whcrc_event_work(struct work_struct *work)
{
struct whcrc *whcrc = container_of(work, struct whcrc, event_work);
struct device *dev = &whcrc->umc_dev->dev;
size_t size;
u64 urcevtaddr;
urcevtaddr = le_readq(whcrc->rc_base + URCEVTADDR);
size = urcevtaddr & URCEVTADDR_OFFSET_MASK;
d_printf(3, dev, "received %zu octet event\n", size);
d_dump(4, dev, whcrc->evt_buf, size > 32 ? 32 : size);
uwb_rc_neh_grok(whcrc->uwb_rc, whcrc->evt_buf, size);
whcrc_enable_events(whcrc);
}
......@@ -216,22 +195,15 @@ irqreturn_t whcrc_irq_cb(int irq, void *_whcrc)
return IRQ_NONE;
le_writel(urcsts & URCSTS_INT_MASK, whcrc->rc_base + URCSTS);
d_printf(4, dev, "acked 0x%08x, urcsts 0x%08x\n",
le_readl(whcrc->rc_base + URCSTS), urcsts);
if (urcsts & URCSTS_HSE) {
dev_err(dev, "host system error -- hardware halted\n");
/* FIXME: do something sensible here */
goto out;
}
if (urcsts & URCSTS_ER) {
d_printf(3, dev, "ER: event ready\n");
if (urcsts & URCSTS_ER)
schedule_work(&whcrc->event_work);
}
if (urcsts & URCSTS_RCI) {
d_printf(3, dev, "RCI: ready to execute another command\n");
if (urcsts & URCSTS_RCI)
wake_up_all(&whcrc->cmd_wq);
}
out:
return IRQ_HANDLED;
}
......@@ -250,8 +222,7 @@ int whcrc_setup_rc_umc(struct whcrc *whcrc)
whcrc->area = umc_dev->resource.start;
whcrc->rc_len = umc_dev->resource.end - umc_dev->resource.start + 1;
result = -EBUSY;
if (request_mem_region(whcrc->area, whcrc->rc_len, KBUILD_MODNAME)
== NULL) {
if (request_mem_region(whcrc->area, whcrc->rc_len, KBUILD_MODNAME) == NULL) {
dev_err(dev, "can't request URC region (%zu bytes @ 0x%lx): %d\n",
whcrc->rc_len, whcrc->area, result);
goto error_request_region;
......@@ -286,8 +257,6 @@ int whcrc_setup_rc_umc(struct whcrc *whcrc)
dev_err(dev, "Can't allocate evt transfer buffer\n");
goto error_evt_buffer;
}
d_printf(3, dev, "UWB RC Interface: %zu bytes at 0x%p, irq %u\n",
whcrc->rc_len, whcrc->rc_base, umc_dev->irq);
return 0;
error_evt_buffer:
......@@ -396,7 +365,6 @@ int whcrc_probe(struct umc_dev *umc_dev)
struct whcrc *whcrc;
struct device *dev = &umc_dev->dev;
d_fnstart(3, dev, "(umc_dev %p)\n", umc_dev);
result = -ENOMEM;
uwb_rc = uwb_rc_alloc();
if (uwb_rc == NULL) {
......@@ -428,7 +396,6 @@ int whcrc_probe(struct umc_dev *umc_dev)
if (result < 0)
goto error_rc_add;
umc_set_drvdata(umc_dev, whcrc);
d_fnend(3, dev, "(umc_dev %p) = 0\n", umc_dev);
return 0;
error_rc_add:
......@@ -438,7 +405,6 @@ int whcrc_probe(struct umc_dev *umc_dev)
error_alloc:
uwb_rc_put(uwb_rc);
error_rc_alloc:
d_fnend(3, dev, "(umc_dev %p) = %d\n", umc_dev, result);
return result;
}
......@@ -461,7 +427,6 @@ static void whcrc_remove(struct umc_dev *umc_dev)
whcrc_release_rc_umc(whcrc);
kfree(whcrc);
uwb_rc_put(uwb_rc);
d_printf(1, &umc_dev->dev, "freed whcrc %p\n", whcrc);
}
static int whcrc_pre_reset(struct umc_dev *umc)
......
......@@ -51,9 +51,7 @@
* the tag and address of the transmitting neighbor.
*/
#define D_LOCAL 5
#include <linux/netdevice.h>
#include <linux/uwb/debug.h>
#include <linux/etherdevice.h>
#include <linux/wlp.h>
#include "wlp-internal.h"
......@@ -304,7 +302,6 @@ int wlp_eda_for_virtual(struct wlp_eda *eda,
{
int result = 0;
struct wlp *wlp = container_of(eda, struct wlp, eda);
struct device *dev = &wlp->rc->uwb_dev.dev;
struct wlp_eda_node *itr;
unsigned long flags;
int found = 0;
......@@ -313,40 +310,14 @@ int wlp_eda_for_virtual(struct wlp_eda *eda,
list_for_each_entry(itr, &eda->cache, list_node) {
if (!memcmp(itr->virt_addr, virt_addr,
sizeof(itr->virt_addr))) {
d_printf(6, dev, "EDA: looking for "
"%02x:%02x:%02x:%02x:%02x:%02x hit %02x:%02x "
"wss %p tag 0x%02x state %u\n",
virt_addr[0], virt_addr[1],
virt_addr[2], virt_addr[3],
virt_addr[4], virt_addr[5],
itr->dev_addr.data[1],
itr->dev_addr.data[0], itr->wss,
itr->tag, itr->state);
result = (*function)(wlp, itr, priv);
*dev_addr = itr->dev_addr;
found = 1;
break;
} else
d_printf(6, dev, "EDA: looking for "
"%02x:%02x:%02x:%02x:%02x:%02x "
"against "
"%02x:%02x:%02x:%02x:%02x:%02x miss\n",
virt_addr[0], virt_addr[1],
virt_addr[2], virt_addr[3],
virt_addr[4], virt_addr[5],
itr->virt_addr[0], itr->virt_addr[1],
itr->virt_addr[2], itr->virt_addr[3],
itr->virt_addr[4], itr->virt_addr[5]);
}
if (!found) {
if (printk_ratelimit())
dev_err(dev, "EDA: Eth addr %02x:%02x:%02x"
":%02x:%02x:%02x not found.\n",
virt_addr[0], virt_addr[1],
virt_addr[2], virt_addr[3],
virt_addr[4], virt_addr[5]);
result = -ENODEV;
}
if (!found)
result = -ENODEV;
spin_unlock_irqrestore(&eda->lock, flags);
return result;
}
......
This diff is collapsed.
......@@ -23,8 +23,8 @@
* FIXME: Docs
*
*/
#include <linux/wlp.h>
#include "wlp-internal.h"
static
......
......@@ -26,12 +26,10 @@
#include <linux/etherdevice.h>
#include <linux/wlp.h>
#define D_LOCAL 5
#include <linux/uwb/debug.h>
#include "wlp-internal.h"
#include "wlp-internal.h"
/**
/*
* Direct incoming association msg to correct parsing routine
*
* We only expect D1, E1, C1, C3 messages as new. All other incoming
......@@ -48,35 +46,31 @@ void wlp_direct_assoc_frame(struct wlp *wlp, struct sk_buff *skb,
struct device *dev = &wlp->rc->uwb_dev.dev;
struct wlp_frame_assoc *assoc = (void *) skb->data;
struct wlp_assoc_frame_ctx *frame_ctx;
d_fnstart(5, dev, "wlp %p, skb %p\n", wlp, skb);
frame_ctx = kmalloc(sizeof(*frame_ctx), GFP_ATOMIC);
if (frame_ctx == NULL) {
dev_err(dev, "WLP: Unable to allocate memory for association "
"frame handling.\n");
kfree_skb(skb);
goto out;
return;
}
frame_ctx->wlp = wlp;
frame_ctx->skb = skb;
frame_ctx->src = *src;
switch (assoc->type) {
case WLP_ASSOC_D1:
d_printf(5, dev, "Received a D1 frame.\n");
INIT_WORK(&frame_ctx->ws, wlp_handle_d1_frame);
schedule_work(&frame_ctx->ws);
break;
case WLP_ASSOC_E1:
d_printf(5, dev, "Received a E1 frame. FIXME?\n");
kfree_skb(skb); /* Temporary until we handle it */
kfree(frame_ctx); /* Temporary until we handle it */
break;
case WLP_ASSOC_C1:
d_printf(5, dev, "Received a C1 frame.\n");
INIT_WORK(&frame_ctx->ws, wlp_handle_c1_frame);
schedule_work(&frame_ctx->ws);
break;
case WLP_ASSOC_C3:
d_printf(5, dev, "Received a C3 frame.\n");
INIT_WORK(&frame_ctx->ws, wlp_handle_c3_frame);
schedule_work(&frame_ctx->ws);
break;
......@@ -87,11 +81,9 @@ void wlp_direct_assoc_frame(struct wlp *wlp, struct sk_buff *skb,
kfree(frame_ctx);
break;
}
out:
d_fnend(5, dev, "wlp %p\n", wlp);
}
/**
/*
* Process incoming association frame
*
* Although it could be possible to deal with some incoming association
......@@ -112,7 +104,6 @@ void wlp_receive_assoc_frame(struct wlp *wlp, struct sk_buff *skb,
struct wlp_frame_assoc *assoc = (void *) skb->data;
struct wlp_session *session = wlp->session;
u8 version;
d_fnstart(5, dev, "wlp %p, skb %p\n", wlp, skb);
if (wlp_get_version(wlp, &assoc->version, &version,
sizeof(assoc->version)) < 0)
......@@ -150,14 +141,12 @@ void wlp_receive_assoc_frame(struct wlp *wlp, struct sk_buff *skb,
} else {
wlp_direct_assoc_frame(wlp, skb, src);
}
d_fnend(5, dev, "wlp %p\n", wlp);
return;
error:
kfree_skb(skb);
d_fnend(5, dev, "wlp %p\n", wlp);
}
/**
/*
* Verify incoming frame is from connected neighbor, prep to pass to WLP client
*
* Verification proceeds according to WLP 0.99 [7.3.1]. The source address
......@@ -176,7 +165,6 @@ int wlp_verify_prep_rx_frame(struct wlp *wlp, struct sk_buff *skb,
struct wlp_eda_node eda_entry;
struct wlp_frame_std_abbrv_hdr *hdr = (void *) skb->data;
d_fnstart(6, dev, "wlp %p, skb %p \n", wlp, skb);
/*verify*/
result = wlp_copy_eda_node(&wlp->eda, src, &eda_entry);
if (result < 0) {
......@@ -207,11 +195,10 @@ int wlp_verify_prep_rx_frame(struct wlp *wlp, struct sk_buff *skb,
/*prep*/
skb_pull(skb, sizeof(*hdr));
out:
d_fnend(6, dev, "wlp %p, skb %p, result = %d \n", wlp, skb, result);
return result;
}
/**
/*
* Receive a WLP frame from device
*
* @returns: 1 if calling function should free the skb
......@@ -226,14 +213,12 @@ int wlp_receive_frame(struct device *dev, struct wlp *wlp, struct sk_buff *skb,
struct wlp_frame_hdr *hdr;
int result = 0;
d_fnstart(6, dev, "skb (%p), len (%u)\n", skb, len);
if (len < sizeof(*hdr)) {
dev_err(dev, "Not enough data to parse WLP header.\n");
result = -EINVAL;
goto out;
}
hdr = ptr;
d_dump(6, dev, hdr, sizeof(*hdr));
if (le16_to_cpu(hdr->mux_hdr) != WLP_PROTOCOL_ID) {
dev_err(dev, "Not a WLP frame type.\n");
result = -EINVAL;
......@@ -270,7 +255,6 @@ int wlp_receive_frame(struct device *dev, struct wlp *wlp, struct sk_buff *skb,
"WLP header.\n");
goto out;
}
d_printf(5, dev, "Association frame received.\n");
wlp_receive_assoc_frame(wlp, skb, src);
break;
default:
......@@ -283,13 +267,12 @@ int wlp_receive_frame(struct device *dev, struct wlp *wlp, struct sk_buff *skb,
kfree_skb(skb);
result = 0;
}
d_fnend(6, dev, "skb (%p)\n", skb);
return result;
}
EXPORT_SYMBOL_GPL(wlp_receive_frame);
/**
/*
* Verify frame from network stack, prepare for further transmission
*
* @skb: the socket buffer that needs to be prepared for transmission (it
......@@ -343,9 +326,7 @@ int wlp_prepare_tx_frame(struct device *dev, struct wlp *wlp,
int result = -EINVAL;
struct ethhdr *eth_hdr = (void *) skb->data;
d_fnstart(6, dev, "wlp (%p), skb (%p) \n", wlp, skb);
if (is_broadcast_ether_addr(eth_hdr->h_dest)) {
d_printf(6, dev, "WLP: handling broadcast frame. \n");
result = wlp_eda_for_each(&wlp->eda, wlp_wss_send_copy, skb);
if (result < 0) {
if (printk_ratelimit())
......@@ -357,7 +338,6 @@ int wlp_prepare_tx_frame(struct device *dev, struct wlp *wlp,
result = 1;
/* Frame will be transmitted by WLP. */
} else {
d_printf(6, dev, "WLP: handling unicast frame. \n");
result = wlp_eda_for_virtual(&wlp->eda, eth_hdr->h_dest, dst,
wlp_wss_prep_hdr, skb);
if (unlikely(result < 0)) {
......@@ -368,7 +348,6 @@ int wlp_prepare_tx_frame(struct device *dev, struct wlp *wlp,
}
}
out:
d_fnend(6, dev, "wlp (%p), skb (%p). result = %d \n", wlp, skb, result);
return result;
}
EXPORT_SYMBOL_GPL(wlp_prepare_tx_frame);
......@@ -21,12 +21,9 @@
*
* FIXME: docs
*/
#include <linux/wlp.h>
#define D_LOCAL 6
#include <linux/uwb/debug.h>
#include "wlp-internal.h"
#include "wlp-internal.h"
static
void wlp_neighbor_init(struct wlp_neighbor_e *neighbor)
......@@ -61,11 +58,6 @@ int __wlp_alloc_device_info(struct wlp *wlp)
static
void __wlp_fill_device_info(struct wlp *wlp)
{
struct device *dev = &wlp->rc->uwb_dev.dev;
BUG_ON(wlp->fill_device_info == NULL);
d_printf(6, dev, "Retrieving device information "
"from device driver.\n");
wlp->fill_device_info(wlp, wlp->dev_info);
}
......@@ -127,7 +119,7 @@ void wlp_remove_neighbor_tmp_info(struct wlp_neighbor_e *neighbor)
}
}
/**
/*
* Populate WLP neighborhood cache with neighbor information
*
* A new neighbor is found. If it is discoverable then we add it to the
......@@ -141,10 +133,7 @@ int wlp_add_neighbor(struct wlp *wlp, struct uwb_dev *dev)
int discoverable;
struct wlp_neighbor_e *neighbor;
d_fnstart(6, &dev->dev, "uwb %p \n", dev);
d_printf(6, &dev->dev, "Found neighbor device %02x:%02x \n",
dev->dev_addr.data[1], dev->dev_addr.data[0]);
/**
/*
* FIXME:
* Use contents of WLP IE found in beacon cache to determine if
* neighbor is discoverable.
......@@ -167,7 +156,6 @@ int wlp_add_neighbor(struct wlp *wlp, struct uwb_dev *dev)
list_add(&neighbor->node, &wlp->neighbors);
}
error_no_mem:
d_fnend(6, &dev->dev, "uwb %p, result = %d \n", dev, result);
return result;
}
......@@ -255,8 +243,6 @@ int wlp_d1d2_exchange(struct wlp *wlp, struct wlp_neighbor_e *neighbor,
dev_err(dev, "Unable to send D1 frame to neighbor "
"%02x:%02x (%d)\n", dev_addr->data[1],
dev_addr->data[0], result);
d_printf(6, dev, "Add placeholders into buffer next to "
"neighbor information we have (dev address).\n");
goto out;
}
/* Create session, wait for response */
......@@ -284,8 +270,6 @@ int wlp_d1d2_exchange(struct wlp *wlp, struct wlp_neighbor_e *neighbor,
/* Parse message in session->data: it will be either D2 or F0 */
skb = session.data;
resp = (void *) skb->data;
d_printf(6, dev, "Received response to D1 frame. \n");
d_dump(6, dev, skb->data, skb->len > 72 ? 72 : skb->len);
if (resp->type == WLP_ASSOC_F0) {
result = wlp_parse_f0(wlp, skb);
......@@ -337,10 +321,9 @@ int wlp_enroll_neighbor(struct wlp *wlp, struct wlp_neighbor_e *neighbor,
struct device *dev = &wlp->rc->uwb_dev.dev;
char buf[WLP_WSS_UUID_STRSIZE];
struct uwb_dev_addr *dev_addr = &neighbor->uwb_dev->dev_addr;
wlp_wss_uuid_print(buf, sizeof(buf), wssid);
d_fnstart(6, dev, "wlp %p, neighbor %p, wss %p, wssid %p (%s)\n",
wlp, neighbor, wss, wssid, buf);
d_printf(6, dev, "Complete me.\n");
result = wlp_d1d2_exchange(wlp, neighbor, wss, wssid);
if (result < 0) {
dev_err(dev, "WLP: D1/D2 message exchange for enrollment "
......@@ -360,13 +343,10 @@ int wlp_enroll_neighbor(struct wlp *wlp, struct wlp_neighbor_e *neighbor,
goto error;
} else {
wss->state = WLP_WSS_STATE_ENROLLED;
d_printf(2, dev, "WLP: Success Enrollment into unsecure WSS "
"%s using neighbor %02x:%02x. \n", buf,
dev_addr->data[1], dev_addr->data[0]);
dev_dbg(dev, "WLP: Success Enrollment into unsecure WSS "
"%s using neighbor %02x:%02x. \n",
buf, dev_addr->data[1], dev_addr->data[0]);
}
d_fnend(6, dev, "wlp %p, neighbor %p, wss %p, wssid %p (%s)\n",
wlp, neighbor, wss, wssid, buf);
out:
return result;
error:
......@@ -449,7 +429,6 @@ ssize_t wlp_discover(struct wlp *wlp)
int result = 0;
struct device *dev = &wlp->rc->uwb_dev.dev;
d_fnstart(6, dev, "wlp %p \n", wlp);
mutex_lock(&wlp->nbmutex);
/* Clear current neighborhood cache. */
__wlp_neighbors_release(wlp);
......@@ -469,7 +448,6 @@ ssize_t wlp_discover(struct wlp *wlp)
}
error_dev_for_each:
mutex_unlock(&wlp->nbmutex);
d_fnend(6, dev, "wlp %p \n", wlp);
return result;
}
......@@ -492,9 +470,6 @@ void wlp_uwb_notifs_cb(void *_wlp, struct uwb_dev *uwb_dev,
int result;
switch (event) {
case UWB_NOTIF_ONAIR:
d_printf(6, dev, "UWB device %02x:%02x is onair\n",
uwb_dev->dev_addr.data[1],
uwb_dev->dev_addr.data[0]);
result = wlp_eda_create_node(&wlp->eda,
uwb_dev->mac_addr.data,
&uwb_dev->dev_addr);
......@@ -505,19 +480,12 @@ void wlp_uwb_notifs_cb(void *_wlp, struct uwb_dev *uwb_dev,
uwb_dev->dev_addr.data[0]);
break;
case UWB_NOTIF_OFFAIR:
d_printf(6, dev, "UWB device %02x:%02x is offair\n",
uwb_dev->dev_addr.data[1],
uwb_dev->dev_addr.data[0]);
wlp_eda_rm_node(&wlp->eda, &uwb_dev->dev_addr);
mutex_lock(&wlp->nbmutex);
list_for_each_entry_safe(neighbor, next, &wlp->neighbors,
node) {
if (neighbor->uwb_dev == uwb_dev) {
d_printf(6, dev, "Removing device from "
"neighborhood.\n");
list_for_each_entry_safe(neighbor, next, &wlp->neighbors, node) {
if (neighbor->uwb_dev == uwb_dev)
__wlp_neighbor_release(neighbor);
}
}
mutex_unlock(&wlp->nbmutex);
break;
default:
......@@ -538,14 +506,13 @@ static void wlp_channel_changed(struct uwb_pal *pal, int channel)
int wlp_setup(struct wlp *wlp, struct uwb_rc *rc, struct net_device *ndev)
{
struct device *dev = &rc->uwb_dev.dev;
int result;
d_fnstart(6, dev, "wlp %p\n", wlp);
BUG_ON(wlp->fill_device_info == NULL);
BUG_ON(wlp->xmit_frame == NULL);
BUG_ON(wlp->stop_queue == NULL);
BUG_ON(wlp->start_queue == NULL);
wlp->rc = rc;
wlp->ndev = ndev;
wlp_eda_init(&wlp->eda);/* Set up address cache */
......@@ -560,15 +527,12 @@ int wlp_setup(struct wlp *wlp, struct uwb_rc *rc, struct net_device *ndev)
if (result < 0)
uwb_notifs_deregister(wlp->rc, &wlp->uwb_notifs_handler);
d_fnend(6, dev, "wlp %p, result = %d\n", wlp, result);
return result;
}
EXPORT_SYMBOL_GPL(wlp_setup);
void wlp_remove(struct wlp *wlp)
{
struct device *dev = &wlp->rc->uwb_dev.dev;
d_fnstart(6, dev, "wlp %p\n", wlp);
wlp_neighbors_release(wlp);
uwb_pal_unregister(&wlp->pal);
uwb_notifs_deregister(wlp->rc, &wlp->uwb_notifs_handler);
......@@ -578,9 +542,6 @@ void wlp_remove(struct wlp *wlp)
kfree(wlp->dev_info);
mutex_unlock(&wlp->mutex);
wlp->rc = NULL;
/* We have to use NULL here because this function can be called
* when the device disappeared. */
d_fnend(6, NULL, "wlp %p\n", wlp);
}
EXPORT_SYMBOL_GPL(wlp_remove);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment