Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2015 Karol Kosik <karo9@interia.eu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2015-2016 Samsung Electronics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *               Igor Kotrasinski <i.kotrasinsk@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "usbip_common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "vudc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static int alloc_urb_from_cmd(struct urb **urbp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 			      struct usbip_header *pdu, u8 type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	struct urb *urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	if (type == USB_ENDPOINT_XFER_ISOC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		urb = usb_alloc_urb(pdu->u.cmd_submit.number_of_packets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 					  GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		urb = usb_alloc_urb(0, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	if (!urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	usbip_pack_pdu(pdu, urb, USBIP_CMD_SUBMIT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	if (urb->transfer_buffer_length > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		urb->transfer_buffer = kzalloc(urb->transfer_buffer_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 			GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		if (!urb->transfer_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 			goto free_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	urb->setup_packet = kmemdup(&pdu->u.cmd_submit.setup, 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			    GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	if (!urb->setup_packet)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		goto free_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	 * FIXME - we only setup pipe enough for usbip functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	 * to behave nicely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	urb->pipe |= pdu->base.direction == USBIP_DIR_IN ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			USB_DIR_IN : USB_DIR_OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	*urbp = urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) free_buffer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	kfree(urb->transfer_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	urb->transfer_buffer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) free_urb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	usb_free_urb(urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static int v_recv_cmd_unlink(struct vudc *udc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				struct usbip_header *pdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	struct urbp *urb_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	spin_lock_irqsave(&udc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	list_for_each_entry(urb_p, &udc->urb_queue, urb_entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		if (urb_p->seqnum != pdu->u.cmd_unlink.seqnum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		urb_p->urb->unlinked = -ECONNRESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		urb_p->seqnum = pdu->base.seqnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		v_kick_timer(udc, jiffies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		spin_unlock_irqrestore(&udc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	/* Not found, completed / not queued */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	spin_lock(&udc->lock_tx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	v_enqueue_ret_unlink(udc, pdu->base.seqnum, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	wake_up(&udc->tx_waitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	spin_unlock(&udc->lock_tx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	spin_unlock_irqrestore(&udc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static int v_recv_cmd_submit(struct vudc *udc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 				 struct usbip_header *pdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	struct urbp *urb_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	u8 address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	urb_p = alloc_urbp();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (!urb_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_MALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	/* base.ep is pipeendpoint(pipe) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	address = pdu->base.ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	if (pdu->base.direction == USBIP_DIR_IN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		address |= USB_DIR_IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	spin_lock_irq(&udc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	urb_p->ep = vudc_find_endpoint(udc, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	if (!urb_p->ep) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		/* we don't know the type, there may be isoc data! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		dev_err(&udc->pdev->dev, "request to nonexistent endpoint");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		spin_unlock_irq(&udc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		ret = -EPIPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		goto free_urbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	urb_p->type = urb_p->ep->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	spin_unlock_irq(&udc->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	urb_p->new = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	urb_p->seqnum = pdu->base.seqnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (urb_p->ep->type == USB_ENDPOINT_XFER_ISOC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		/* validate packet size and number of packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		unsigned int maxp, packets, bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		maxp = usb_endpoint_maxp(urb_p->ep->desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		maxp *= usb_endpoint_maxp_mult(urb_p->ep->desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		bytes = pdu->u.cmd_submit.transfer_buffer_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		packets = DIV_ROUND_UP(bytes, maxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		if (pdu->u.cmd_submit.number_of_packets < 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		    pdu->u.cmd_submit.number_of_packets > packets) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			dev_err(&udc->gadget.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 				"CMD_SUBMIT: isoc invalid num packets %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 				pdu->u.cmd_submit.number_of_packets);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			ret = -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			goto free_urbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	ret = alloc_urb_from_cmd(&urb_p->urb, pdu, urb_p->ep->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_MALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		goto free_urbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	urb_p->urb->status = -EINPROGRESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	/* FIXME: more pipe setup to please usbip_common */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	urb_p->urb->pipe &= ~(3 << 30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	switch (urb_p->ep->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	case USB_ENDPOINT_XFER_BULK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		urb_p->urb->pipe |= (PIPE_BULK << 30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	case USB_ENDPOINT_XFER_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		urb_p->urb->pipe |= (PIPE_INTERRUPT << 30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	case USB_ENDPOINT_XFER_CONTROL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		urb_p->urb->pipe |= (PIPE_CONTROL << 30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	case USB_ENDPOINT_XFER_ISOC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		urb_p->urb->pipe |= (PIPE_ISOCHRONOUS << 30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	ret = usbip_recv_xbuff(&udc->ud, urb_p->urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		goto free_urbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	ret = usbip_recv_iso(&udc->ud, urb_p->urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		goto free_urbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	spin_lock_irqsave(&udc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	v_kick_timer(udc, jiffies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	list_add_tail(&urb_p->urb_entry, &udc->urb_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	spin_unlock_irqrestore(&udc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) free_urbp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	free_urbp_and_urb(urb_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static int v_rx_pdu(struct usbip_device *ud)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	struct usbip_header pdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	struct vudc *udc = container_of(ud, struct vudc, ud);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	memset(&pdu, 0, sizeof(pdu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	ret = usbip_recv(ud->tcp_socket, &pdu, sizeof(pdu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	if (ret != sizeof(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		usbip_event_add(ud, VUDC_EVENT_ERROR_TCP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		if (ret >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			return -EPIPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	usbip_header_correct_endian(&pdu, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	spin_lock_irq(&ud->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	ret = (ud->status == SDEV_ST_USED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	spin_unlock_irq(&ud->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		usbip_event_add(ud, VUDC_EVENT_ERROR_TCP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	switch (pdu.base.command) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	case USBIP_CMD_UNLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		ret = v_recv_cmd_unlink(udc, &pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	case USBIP_CMD_SUBMIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		ret = v_recv_cmd_submit(udc, &pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		ret = -EPIPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		pr_err("rx: unknown command");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) int v_rx_loop(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	struct usbip_device *ud = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	while (!kthread_should_stop()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		if (usbip_event_happened(ud))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		ret = v_rx_pdu(ud);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			pr_warn("v_rx exit with error %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }