Release 4.7 drivers/usb/usbip/usbip_common.c
/*
* Copyright (C) 2003-2008 Takahiro Hirofuchi
* Copyright (C) 2015-2016 Samsung Electronics
* Krzysztof Opasiak <k.opasiak@samsung.com>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <asm/byteorder.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <net/sock.h>
#include "usbip_common.h"
#define DRIVER_AUTHOR "Takahiro Hirofuchi <hirofuchi@users.sourceforge.net>"
#define DRIVER_DESC "USB/IP Core"
#ifdef CONFIG_USBIP_DEBUG
unsigned long usbip_debug_flag = 0xffffffff;
#else
unsigned long usbip_debug_flag;
#endif
EXPORT_SYMBOL_GPL(usbip_debug_flag);
module_param(usbip_debug_flag, ulong, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(usbip_debug_flag, "debug flags (defined in usbip_common.h)");
/* FIXME */
struct device_attribute dev_attr_usbip_debug;
EXPORT_SYMBOL_GPL(dev_attr_usbip_debug);
static ssize_t usbip_debug_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%lx\n", usbip_debug_flag);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 29 | 96.67% | 1 | 50.00% |
greg kroah-hartman | greg kroah-hartman | 1 | 3.33% | 1 | 50.00% |
| Total | 30 | 100.00% | 2 | 100.00% |
static ssize_t usbip_debug_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
if (sscanf(buf, "%lx", &usbip_debug_flag) != 1)
return -EINVAL;
return count;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 34 | 75.56% | 1 | 25.00% |
john de la garza | john de la garza | 9 | 20.00% | 1 | 25.00% |
himanshu chauhan | himanshu chauhan | 1 | 2.22% | 1 | 25.00% |
greg kroah-hartman | greg kroah-hartman | 1 | 2.22% | 1 | 25.00% |
| Total | 45 | 100.00% | 4 | 100.00% |
DEVICE_ATTR_RW(usbip_debug);
static void usbip_dump_buffer(char *buff, int bufflen)
{
print_hex_dump(KERN_DEBUG, "usbip-core", DUMP_PREFIX_OFFSET, 16, 4,
buff, bufflen, false);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 21 | 65.62% | 1 | 25.00% |
himanshu chauhan | himanshu chauhan | 9 | 28.12% | 1 | 25.00% |
matt mooney | matt mooney | 1 | 3.12% | 1 | 25.00% |
brian g. merrell | brian g. merrell | 1 | 3.12% | 1 | 25.00% |
| Total | 32 | 100.00% | 4 | 100.00% |
static void usbip_dump_pipe(unsigned int p)
{
unsigned char type = usb_pipetype(p);
unsigned char ep = usb_pipeendpoint(p);
unsigned char dev = usb_pipedevice(p);
unsigned char dir = usb_pipein(p);
pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT");
switch (type) {
case PIPE_ISOCHRONOUS:
pr_debug("ISO\n");
break;
case PIPE_INTERRUPT:
pr_debug("INT\n");
break;
case PIPE_CONTROL:
pr_debug("CTRL\n");
break;
case PIPE_BULK:
pr_debug("BULK\n");
break;
default:
pr_debug("ERR\n");
break;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 97 | 88.18% | 1 | 33.33% |
matt mooney | matt mooney | 13 | 11.82% | 2 | 66.67% |
| Total | 110 | 100.00% | 3 | 100.00% |
static void usbip_dump_usb_device(struct usb_device *udev)
{
struct device *dev = &udev->dev;
int i;
dev_dbg(dev, " devnum(%d) devpath(%s) usb speed(%s)",
udev->devnum, udev->devpath, usb_speed_string(udev->speed));
pr_debug("tt %p, ttport %d\n", udev->tt, udev->ttport);
dev_dbg(dev, " ");
for (i = 0; i < 16; i++)
pr_debug(" %2u", i);
pr_debug("\n");
dev_dbg(dev, " toggle0(IN) :");
for (i = 0; i < 16; i++)
pr_debug(" %2u", (udev->toggle[0] & (1 << i)) ? 1 : 0);
pr_debug("\n");
dev_dbg(dev, " toggle1(OUT):");
for (i = 0; i < 16; i++)
pr_debug(" %2u", (udev->toggle[1] & (1 << i)) ? 1 : 0);
pr_debug("\n");
dev_dbg(dev, " epmaxp_in :");
for (i = 0; i < 16; i++) {
if (udev->ep_in[i])
pr_debug(" %2u",
le16_to_cpu(udev->ep_in[i]->desc.wMaxPacketSize));
}
pr_debug("\n");
dev_dbg(dev, " epmaxp_out :");
for (i = 0; i < 16; i++) {
if (udev->ep_out[i])
pr_debug(" %2u",
le16_to_cpu(udev->ep_out[i]->desc.wMaxPacketSize));
}
pr_debug("\n");
dev_dbg(dev, "parent %p, bus %p\n", udev->parent, udev->bus);
dev_dbg(dev,
"descriptor %p, config %p, actconfig %p, rawdescriptors %p\n",
&udev->descriptor, udev->config,
udev->actconfig, udev->rawdescriptors);
dev_dbg(dev, "have_langid %d, string_langid %d\n",
udev->have_langid, udev->string_langid);
dev_dbg(dev, "maxchild %d\n", udev->maxchild);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 346 | 95.05% | 1 | 20.00% |
matt mooney | matt mooney | 12 | 3.30% | 1 | 20.00% |
shuah khan | shuah khan | 4 | 1.10% | 1 | 20.00% |
lan tianyu | lan tianyu | 1 | 0.27% | 1 | 20.00% |
himangi saraogi | himangi saraogi | 1 | 0.27% | 1 | 20.00% |
| Total | 364 | 100.00% | 5 | 100.00% |
static void usbip_dump_request_type(__u8 rt)
{
switch (rt & USB_RECIP_MASK) {
case USB_RECIP_DEVICE:
pr_debug("DEVICE");
break;
case USB_RECIP_INTERFACE:
pr_debug("INTERF");
break;
case USB_RECIP_ENDPOINT:
pr_debug("ENDPOI");
break;
case USB_RECIP_OTHER:
pr_debug("OTHER ");
break;
default:
pr_debug("------");
break;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 54 | 90.00% | 1 | 33.33% |
matt mooney | matt mooney | 6 | 10.00% | 2 | 66.67% |
| Total | 60 | 100.00% | 3 | 100.00% |
static void usbip_dump_usb_ctrlrequest(struct usb_ctrlrequest *cmd)
{
if (!cmd) {
pr_debug(" : null pointer\n");
return;
}
pr_debug(" ");
pr_debug("bRequestType(%02X) bRequest(%02X) wValue(%04X) wIndex(%04X) wLength(%04X) ",
cmd->bRequestType, cmd->bRequest,
cmd->wValue, cmd->wIndex, cmd->wLength);
pr_debug("\n ");
if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
pr_debug("STANDARD ");
switch (cmd->bRequest) {
case USB_REQ_GET_STATUS:
pr_debug("GET_STATUS\n");
break;
case USB_REQ_CLEAR_FEATURE:
pr_debug("CLEAR_FEAT\n");
break;
case USB_REQ_SET_FEATURE:
pr_debug("SET_FEAT\n");
break;
case USB_REQ_SET_ADDRESS:
pr_debug("SET_ADDRRS\n");
break;
case USB_REQ_GET_DESCRIPTOR:
pr_debug("GET_DESCRI\n");
break;
case USB_REQ_SET_DESCRIPTOR:
pr_debug("SET_DESCRI\n");
break;
case USB_REQ_GET_CONFIGURATION:
pr_debug("GET_CONFIG\n");
break;
case USB_REQ_SET_CONFIGURATION:
pr_debug("SET_CONFIG\n");
break;
case USB_REQ_GET_INTERFACE:
pr_debug("GET_INTERF\n");
break;
case USB_REQ_SET_INTERFACE:
pr_debug("SET_INTERF\n");
break;
case USB_REQ_SYNCH_FRAME:
pr_debug("SYNC_FRAME\n");
break;
default:
pr_debug("REQ(%02X)\n", cmd->bRequest);
break;
}
usbip_dump_request_type(cmd->bRequestType);
} else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) {
pr_debug("CLASS\n");
} else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_VENDOR) {
pr_debug("VENDOR\n");
} else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_RESERVED) {
pr_debug("RESERVED\n");
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 219 | 83.27% | 1 | 20.00% |
matt mooney | matt mooney | 39 | 14.83% | 2 | 40.00% |
akshay joshi | akshay joshi | 4 | 1.52% | 1 | 20.00% |
cedric cabessa | cedric cabessa | 1 | 0.38% | 1 | 20.00% |
| Total | 263 | 100.00% | 5 | 100.00% |
void usbip_dump_urb(struct urb *urb)
{
struct device *dev;
if (!urb) {
pr_debug("urb: null pointer!!\n");
return;
}
if (!urb->dev) {
pr_debug("urb->dev: null pointer!!\n");
return;
}
dev = &urb->dev->dev;
dev_dbg(dev, " urb :%p\n", urb);
dev_dbg(dev, " dev :%p\n", urb->dev);
usbip_dump_usb_device(urb->dev);
dev_dbg(dev, " pipe :%08x ", urb->pipe);
usbip_dump_pipe(urb->pipe);
dev_dbg(dev, " status :%d\n", urb->status);
dev_dbg(dev, " transfer_flags :%08X\n", urb->transfer_flags);
dev_dbg(dev, " transfer_buffer :%p\n", urb->transfer_buffer);
dev_dbg(dev, " transfer_buffer_length:%d\n",
urb->transfer_buffer_length);
dev_dbg(dev, " actual_length :%d\n", urb->actual_length);
dev_dbg(dev, " setup_packet :%p\n", urb->setup_packet);
if (urb->setup_packet && usb_pipetype(urb->pipe) == PIPE_CONTROL)
usbip_dump_usb_ctrlrequest(
(struct usb_ctrlrequest *)urb->setup_packet);
dev_dbg(dev, " start_frame :%d\n", urb->start_frame);
dev_dbg(dev, " number_of_packets :%d\n", urb->number_of_packets);
dev_dbg(dev, " interval :%d\n", urb->interval);
dev_dbg(dev, " error_count :%d\n", urb->error_count);
dev_dbg(dev, " context :%p\n", urb->context);
dev_dbg(dev, " complete :%p\n", urb->complete);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 250 | 97.66% | 1 | 50.00% |
matt mooney | matt mooney | 6 | 2.34% | 1 | 50.00% |
| Total | 256 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_dump_urb);
void usbip_dump_header(struct usbip_header *pdu)
{
pr_debug("BASE: cmd %u seq %u devid %u dir %u ep %u\n",
pdu->base.command,
pdu->base.seqnum,
pdu->base.devid,
pdu->base.direction,
pdu->base.ep);
switch (pdu->base.command) {
case USBIP_CMD_SUBMIT:
pr_debug("USBIP_CMD_SUBMIT: x_flags %u x_len %u sf %u #p %d iv %d\n",
pdu->u.cmd_submit.transfer_flags,
pdu->u.cmd_submit.transfer_buffer_length,
pdu->u.cmd_submit.start_frame,
pdu->u.cmd_submit.number_of_packets,
pdu->u.cmd_submit.interval);
break;
case USBIP_CMD_UNLINK:
pr_debug("USBIP_CMD_UNLINK: seq %u\n",
pdu->u.cmd_unlink.seqnum);
break;
case USBIP_RET_SUBMIT:
pr_debug("USBIP_RET_SUBMIT: st %d al %u sf %d #p %d ec %d\n",
pdu->u.ret_submit.status,
pdu->u.ret_submit.actual_length,
pdu->u.ret_submit.start_frame,
pdu->u.ret_submit.number_of_packets,
pdu->u.ret_submit.error_count);
break;
case USBIP_RET_UNLINK:
pr_debug("USBIP_RET_UNLINK: status %d\n",
pdu->u.ret_unlink.status);
break;
default:
/* NOT REACHED */
pr_err("unknown command\n");
break;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 174 | 89.23% | 1 | 20.00% |
matt mooney | matt mooney | 12 | 6.15% | 2 | 40.00% |
arjan mels | arjan mels | 8 | 4.10% | 1 | 20.00% |
cedric cabessa | cedric cabessa | 1 | 0.51% | 1 | 20.00% |
| Total | 195 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_dump_header);
/* Receive data over TCP/IP. */
int usbip_recv(struct socket *sock, void *buf, int size)
{
int result;
struct msghdr msg;
struct kvec iov;
int total = 0;
/* for blocks of if (usbip_dbg_flag_xmit) */
char *bp = buf;
int osize = size;
usbip_dbg_xmit("enter\n");
if (!sock || !buf || !size) {
pr_err("invalid arg, sock %p buff %p size %d\n", sock, buf,
size);
return -EINVAL;
}
do {
sock->sk->sk_allocation = GFP_NOIO;
iov.iov_base = buf;
iov.iov_len = size;
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = MSG_NOSIGNAL;
result = kernel_recvmsg(sock, &msg, &iov, 1, size, MSG_WAITALL);
if (result <= 0) {
pr_debug("receive sock %p buf %p size %u ret %d total %d\n",
sock, buf, size, result, total);
goto err;
}
size -= result;
buf += result;
total += result;
} while (size > 0);
if (usbip_dbg_flag_xmit) {
if (!in_interrupt())
pr_debug("%-10s:", current->comm);
else
pr_debug("interrupt :");
pr_debug("receiving....\n");
usbip_dump_buffer(bp, osize);
pr_debug("received, osize %d ret %d size %d total %d\n",
osize, result, size, total);
}
return total;
err:
return result;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 239 | 93.73% | 1 | 25.00% |
matt mooney | matt mooney | 9 | 3.53% | 1 | 25.00% |
brian g. merrell | brian g. merrell | 4 | 1.57% | 1 | 25.00% |
bart westgeest | bart westgeest | 3 | 1.18% | 1 | 25.00% |
| Total | 255 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_recv);
/* there may be more cases to tweak the flags. */
static unsigned int tweak_transfer_flags(unsigned int flags)
{
flags &= ~URB_NO_TRANSFER_DMA_MAP;
return flags;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 19 | 100.00% | 1 | 100.00% |
| Total | 19 | 100.00% | 1 | 100.00% |
static void usbip_pack_cmd_submit(struct usbip_header *pdu, struct urb *urb,
int pack)
{
struct usbip_header_cmd_submit *spdu = &pdu->u.cmd_submit;
/*
* Some members are not still implemented in usbip. I hope this issue
* will be discussed when usbip is ported to other operating systems.
*/
if (pack) {
spdu->transfer_flags =
tweak_transfer_flags(urb->transfer_flags);
spdu->transfer_buffer_length = urb->transfer_buffer_length;
spdu->start_frame = urb->start_frame;
spdu->number_of_packets = urb->number_of_packets;
spdu->interval = urb->interval;
} else {
urb->transfer_flags = spdu->transfer_flags;
urb->transfer_buffer_length = spdu->transfer_buffer_length;
urb->start_frame = spdu->start_frame;
urb->number_of_packets = spdu->number_of_packets;
urb->interval = spdu->interval;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 124 | 100.00% | 1 | 100.00% |
| Total | 124 | 100.00% | 1 | 100.00% |
static void usbip_pack_ret_submit(struct usbip_header *pdu, struct urb *urb,
int pack)
{
struct usbip_header_ret_submit *rpdu = &pdu->u.ret_submit;
if (pack) {
rpdu->status = urb->status;
rpdu->actual_length = urb->actual_length;
rpdu->start_frame = urb->start_frame;
rpdu->number_of_packets = urb->number_of_packets;
rpdu->error_count = urb->error_count;
} else {
urb->status = rpdu->status;
urb->actual_length = rpdu->actual_length;
urb->start_frame = rpdu->start_frame;
urb->number_of_packets = rpdu->number_of_packets;
urb->error_count = rpdu->error_count;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 104 | 86.67% | 1 | 50.00% |
arjan mels | arjan mels | 16 | 13.33% | 1 | 50.00% |
| Total | 120 | 100.00% | 2 | 100.00% |
void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
int pack)
{
switch (cmd) {
case USBIP_CMD_SUBMIT:
usbip_pack_cmd_submit(pdu, urb, pack);
break;
case USBIP_RET_SUBMIT:
usbip_pack_ret_submit(pdu, urb, pack);
break;
default:
/* NOT REACHED */
pr_err("unknown command\n");
break;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 57 | 93.44% | 1 | 33.33% |
matt mooney | matt mooney | 4 | 6.56% | 2 | 66.67% |
| Total | 61 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_pack_pdu);
static void correct_endian_basic(struct usbip_header_basic *base, int send)
{
if (send) {
base->command = cpu_to_be32(base->command);
base->seqnum = cpu_to_be32(base->seqnum);
base->devid = cpu_to_be32(base->devid);
base->direction = cpu_to_be32(base->direction);
base->ep = cpu_to_be32(base->ep);
} else {
base->command = be32_to_cpu(base->command);
base->seqnum = be32_to_cpu(base->seqnum);
base->devid = be32_to_cpu(base->devid);
base->direction = be32_to_cpu(base->direction);
base->ep = be32_to_cpu(base->ep);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 133 | 100.00% | 1 | 100.00% |
| Total | 133 | 100.00% | 1 | 100.00% |
static void correct_endian_cmd_submit(struct usbip_header_cmd_submit *pdu,
int send)
{
if (send) {
pdu->transfer_flags = cpu_to_be32(pdu->transfer_flags);
cpu_to_be32s(&pdu->transfer_buffer_length);
cpu_to_be32s(&pdu->start_frame);
cpu_to_be32s(&pdu->number_of_packets);
cpu_to_be32s(&pdu->interval);
} else {
pdu->transfer_flags = be32_to_cpu(pdu->transfer_flags);
be32_to_cpus(&pdu->transfer_buffer_length);
be32_to_cpus(&pdu->start_frame);
be32_to_cpus(&pdu->number_of_packets);
be32_to_cpus(&pdu->interval);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 109 | 100.00% | 1 | 100.00% |
| Total | 109 | 100.00% | 1 | 100.00% |
static void correct_endian_ret_submit(struct usbip_header_ret_submit *pdu,
int send)
{
if (send) {
cpu_to_be32s(&pdu->status);
cpu_to_be32s(&pdu->actual_length);
cpu_to_be32s(&pdu->start_frame);
cpu_to_be32s(&pdu->number_of_packets);
cpu_to_be32s(&pdu->error_count);
} else {
be32_to_cpus(&pdu->status);
be32_to_cpus(&pdu->actual_length);
be32_to_cpus(&pdu->start_frame);
be32_to_cpus(&pdu->number_of_packets);
be32_to_cpus(&pdu->error_count);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 87 | 84.47% | 1 | 33.33% |
arjan mels | arjan mels | 15 | 14.56% | 1 | 33.33% |
david chang | david chang | 1 | 0.97% | 1 | 33.33% |
| Total | 103 | 100.00% | 3 | 100.00% |
static void correct_endian_cmd_unlink(struct usbip_header_cmd_unlink *pdu,
int send)
{
if (send)
pdu->seqnum = cpu_to_be32(pdu->seqnum);
else
pdu->seqnum = be32_to_cpu(pdu->seqnum);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 41 | 100.00% | 1 | 100.00% |
| Total | 41 | 100.00% | 1 | 100.00% |
static void correct_endian_ret_unlink(struct usbip_header_ret_unlink *pdu,
int send)
{
if (send)
cpu_to_be32s(&pdu->status);
else
be32_to_cpus(&pdu->status);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 35 | 100.00% | 1 | 100.00% |
| Total | 35 | 100.00% | 1 | 100.00% |
void usbip_header_correct_endian(struct usbip_header *pdu, int send)
{
__u32 cmd = 0;
if (send)
cmd = pdu->base.command;
correct_endian_basic(&pdu->base, send);
if (!send)
cmd = pdu->base.command;
switch (cmd) {
case USBIP_CMD_SUBMIT:
correct_endian_cmd_submit(&pdu->u.cmd_submit, send);
break;
case USBIP_RET_SUBMIT:
correct_endian_ret_submit(&pdu->u.ret_submit, send);
break;
case USBIP_CMD_UNLINK:
correct_endian_cmd_unlink(&pdu->u.cmd_unlink, send);
break;
case USBIP_RET_UNLINK:
correct_endian_ret_unlink(&pdu->u.ret_unlink, send);
break;
default:
/* NOT REACHED */
pr_err("unknown command\n");
break;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 127 | 96.95% | 1 | 33.33% |
matt mooney | matt mooney | 4 | 3.05% | 2 | 66.67% |
| Total | 131 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_header_correct_endian);
static void usbip_iso_packet_correct_endian(
struct usbip_iso_packet_descriptor *iso, int send)
{
/* does not need all members. but copy all simply. */
if (send) {
iso->offset = cpu_to_be32(iso->offset);
iso->length = cpu_to_be32(iso->length);
iso->status = cpu_to_be32(iso->status);
iso->actual_length = cpu_to_be32(iso->actual_length);
} else {
iso->offset = be32_to_cpu(iso->offset);
iso->length = be32_to_cpu(iso->length);
iso->status = be32_to_cpu(iso->status);
iso->actual_length = be32_to_cpu(iso->actual_length);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 111 | 99.11% | 1 | 50.00% |
matt mooney | matt mooney | 1 | 0.89% | 1 | 50.00% |
| Total | 112 | 100.00% | 2 | 100.00% |
static void usbip_pack_iso(struct usbip_iso_packet_descriptor *iso,
struct usb_iso_packet_descriptor *uiso, int pack)
{
if (pack) {
iso->offset = uiso->offset;
iso->length = uiso->length;
iso->status = uiso->status;
iso->actual_length = uiso->actual_length;
} else {
uiso->offset = iso->offset;
uiso->length = iso->length;
uiso->status = iso->status;
uiso->actual_length = iso->actual_length;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 92 | 100.00% | 1 | 100.00% |
| Total | 92 | 100.00% | 1 | 100.00% |
/* must free buffer */
struct usbip_iso_packet_descriptor*
usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen)
{
struct usbip_iso_packet_descriptor *iso;
int np = urb->number_of_packets;
ssize_t size = np * sizeof(*iso);
int i;
iso = kzalloc(size, GFP_KERNEL);
if (!iso)
return NULL;
for (i = 0; i < np; i++) {
usbip_pack_iso(&iso[i], &urb->iso_frame_desc[i], 1);
usbip_iso_packet_correct_endian(&iso[i], 1);
}
*bufflen = size;
return iso;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 98 | 87.50% | 1 | 33.33% |
bart westgeest | bart westgeest | 13 | 11.61% | 1 | 33.33% |
matt mooney | matt mooney | 1 | 0.89% | 1 | 33.33% |
| Total | 112 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_alloc_iso_desc_pdu);
/* some members of urb must be substituted before. */
int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
{
void *buff;
struct usbip_iso_packet_descriptor *iso;
int np = urb->number_of_packets;
int size = np * sizeof(*iso);
int i;
int ret;
int total_length = 0;
if (!usb_pipeisoc(urb->pipe))
return 0;
/* my Bluetooth dongle gets ISO URBs which are np = 0 */
if (np == 0)
return 0;
buff = kzalloc(size, GFP_KERNEL);
if (!buff)
return -ENOMEM;
ret = usbip_recv(ud->tcp_socket, buff, size);
if (ret != size) {
dev_err(&urb->dev->dev, "recv iso_frame_descriptor, %d\n",
ret);
kfree(buff);
if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC)
usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
else
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return -EPIPE;
}
iso = (struct usbip_iso_packet_descriptor *) buff;
for (i = 0; i < np; i++) {
usbip_iso_packet_correct_endian(&iso[i], 0);
usbip_pack_iso(&iso[i], &urb->iso_frame_desc[i], 0);
total_length += urb->iso_frame_desc[i].actual_length;
}
kfree(buff);
if (total_length != urb->actual_length) {
dev_err(&urb->dev->dev,
"total length of iso packets %d not equal to actual length of buffer %d\n",
total_length, urb->actual_length);
if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC)
usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
else
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return -EPIPE;
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 199 | 66.11% | 1 | 14.29% |
arjan mels | arjan mels | 70 | 23.26% | 1 | 14.29% |
bart westgeest | bart westgeest | 18 | 5.98% | 2 | 28.57% |
igor kotrasinski | igor kotrasinski | 12 | 3.99% | 1 | 14.29% |
cedric cabessa | cedric cabessa | 1 | 0.33% | 1 | 14.29% |
matt mooney | matt mooney | 1 | 0.33% | 1 | 14.29% |
| Total | 301 | 100.00% | 7 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_recv_iso);
/*
* This functions restores the padding which was removed for optimizing
* the bandwidth during transfer over tcp/ip
*
* buffer and iso packets need to be stored and be in propeper endian in urb
* before calling this function
*/
void usbip_pad_iso(struct usbip_device *ud, struct urb *urb)
{
int np = urb->number_of_packets;
int i;
int actualoffset = urb->actual_length;
if (!usb_pipeisoc(urb->pipe))
return;
/* if no packets or length of data is 0, then nothing to unpack */
if (np == 0 || urb->actual_length == 0)
return;
/*
* if actual_length is transfer_buffer_length then no padding is
* present.
*/
if (urb->actual_length == urb->transfer_buffer_length)
return;
/*
* loop over all packets from last to first (to prevent overwritting
* memory when padding) and move them into the proper place
*/
for (i = np-1; i > 0; i--) {
actualoffset -= urb->iso_frame_desc[i].actual_length;
memmove(urb->transfer_buffer + urb->iso_frame_desc[i].offset,
urb->transfer_buffer + actualoffset,
urb->iso_frame_desc[i].actual_length);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
arjan mels | arjan mels | 124 | 96.12% | 1 | 33.33% |
bart westgeest | bart westgeest | 5 | 3.88% | 2 | 66.67% |
| Total | 129 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_pad_iso);
/* some members of urb must be substituted before. */
int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
{
int ret;
int size;
if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC) {
/* the direction of urb must be OUT. */
if (usb_pipein(urb->pipe))
return 0;
size = urb->transfer_buffer_length;
} else {
/* the direction of urb must be IN. */
if (usb_pipeout(urb->pipe))
return 0;
size = urb->actual_length;
}
/* no need to recv xbuff */
if (!(size > 0))
return 0;
if (size > urb->transfer_buffer_length) {
/* should not happen, probably malicious packet */
if (ud->side == USBIP_STUB) {
usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
return 0;
} else {
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return -EPIPE;
}
}
ret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size);
if (ret != size) {
dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret);
if (ud->side == USBIP_STUB || ud->side == USBIP_VUDC) {
usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
} else {
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return -EPIPE;
}
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 155 | 72.77% | 1 | 25.00% |
ignat korchagin | ignat korchagin | 45 | 21.13% | 1 | 25.00% |
igor kotrasinski | igor kotrasinski | 12 | 5.63% | 1 | 25.00% |
bart westgeest | bart westgeest | 1 | 0.47% | 1 | 25.00% |
| Total | 213 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(usbip_recv_xbuff);
static int __init usbip_core_init(void)
{
int ret;
pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
ret = usbip_init_eh();
if (ret)
return ret;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nobuo iwata | nobuo iwata | 15 | 42.86% | 1 | 20.00% |
takahiro hirofuchi | takahiro hirofuchi | 13 | 37.14% | 1 | 20.00% |
matt mooney | matt mooney | 7 | 20.00% | 3 | 60.00% |
| Total | 35 | 100.00% | 5 | 100.00% |
static void __exit usbip_core_exit(void)
{
usbip_finish_eh();
return;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 9 | 69.23% | 1 | 33.33% |
nobuo iwata | nobuo iwata | 3 | 23.08% | 1 | 33.33% |
matt mooney | matt mooney | 1 | 7.69% | 1 | 33.33% |
| Total | 13 | 100.00% | 3 | 100.00% |
module_init(usbip_core_init);
module_exit(usbip_core_exit);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
MODULE_VERSION(USBIP_VERSION);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
takahiro hirofuchi | takahiro hirofuchi | 3095 | 84.38% | 1 | 3.12% |
arjan mels | arjan mels | 239 | 6.52% | 2 | 6.25% |
matt mooney | matt mooney | 132 | 3.60% | 8 | 25.00% |
ignat korchagin | ignat korchagin | 45 | 1.23% | 1 | 3.12% |
bart westgeest | bart westgeest | 42 | 1.15% | 4 | 12.50% |
igor kotrasinski | igor kotrasinski | 25 | 0.68% | 1 | 3.12% |
w. trevor king | w. trevor king | 24 | 0.65% | 1 | 3.12% |
nobuo iwata | nobuo iwata | 18 | 0.49% | 1 | 3.12% |
himanshu chauhan | himanshu chauhan | 10 | 0.27% | 2 | 6.25% |
john de la garza | john de la garza | 9 | 0.25% | 1 | 3.12% |
brian g. merrell | brian g. merrell | 7 | 0.19% | 1 | 3.12% |
shuah khan | shuah khan | 4 | 0.11% | 1 | 3.12% |
akshay joshi | akshay joshi | 4 | 0.11% | 1 | 3.12% |
cedric cabessa | cedric cabessa | 3 | 0.08% | 1 | 3.12% |
greg kroah-hartman | greg kroah-hartman | 3 | 0.08% | 1 | 3.12% |
paul gortmaker | paul gortmaker | 3 | 0.08% | 1 | 3.12% |
tejun heo | tejun heo | 2 | 0.05% | 1 | 3.12% |
himangi saraogi | himangi saraogi | 1 | 0.03% | 1 | 3.12% |
lan tianyu | lan tianyu | 1 | 0.03% | 1 | 3.12% |
david chang | david chang | 1 | 0.03% | 1 | 3.12% |
| Total | 3668 | 100.00% | 32 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.