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) 2003-2008 Takahiro Hirofuchi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "usbip_common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "vhci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) /* get URB from transmitted urb queue. caller must hold vdev->priv_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	struct vhci_priv *priv, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	struct urb *urb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	list_for_each_entry_safe(priv, tmp, &vdev->priv_rx, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 		if (priv->seqnum != seqnum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 		urb = priv->urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		status = urb->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		usbip_dbg_vhci_rx("find urb seqnum %u\n", seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		switch (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		case -ENOENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 			fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		case -ECONNRESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 			dev_dbg(&urb->dev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 				 "urb seq# %u was unlinked %ssynchronously\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 				 seqnum, status == -ENOENT ? "" : "a");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		case -EINPROGRESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 			/* no info output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			dev_dbg(&urb->dev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 				 "urb seq# %u may be in a error, status %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 				 seqnum, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		list_del(&priv->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		kfree(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		urb->hcpriv = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	return urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static void vhci_recv_ret_submit(struct vhci_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 				 struct usbip_header *pdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct vhci *vhci = vhci_hcd->vhci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct usbip_device *ud = &vdev->ud;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct urb *urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	spin_lock_irqsave(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	spin_unlock_irqrestore(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (!urb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		pr_err("cannot find a urb of seqnum %u max seqnum %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			pdu->base.seqnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			atomic_read(&vhci_hcd->seqnum));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	/* unpack the pdu to a urb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	/* recv transfer buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	if (usbip_recv_xbuff(ud, urb) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		urb->status = -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* recv iso_packet_descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (usbip_recv_iso(ud, urb) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		urb->status = -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* restore the padding in iso packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	usbip_pad_iso(ud, urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (usbip_dbg_flag_vhci_rx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		usbip_dump_urb(urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if (urb->num_sgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		urb->transfer_flags &= ~URB_DMA_MAP_SG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	usbip_dbg_vhci_rx("now giveback urb %u\n", pdu->base.seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	spin_lock_irqsave(&vhci->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci_hcd), urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	spin_unlock_irqrestore(&vhci->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci_hcd), urb, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	usbip_dbg_vhci_rx("Leave\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 						  struct usbip_header *pdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct vhci_unlink *unlink, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	spin_lock_irqsave(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		pr_info("unlink->seqnum %lu\n", unlink->seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		if (unlink->seqnum == pdu->base.seqnum) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			usbip_dbg_vhci_rx("found pending unlink, %lu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 					  unlink->seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			list_del(&unlink->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			spin_unlock_irqrestore(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			return unlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	spin_unlock_irqrestore(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static void vhci_recv_ret_unlink(struct vhci_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 				 struct usbip_header *pdu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct vhci *vhci = vhci_hcd->vhci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	struct vhci_unlink *unlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	struct urb *urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	usbip_dump_header(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	unlink = dequeue_pending_unlink(vdev, pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (!unlink) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		pr_info("cannot find the pending unlink %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			pdu->base.seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	spin_lock_irqsave(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	spin_unlock_irqrestore(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (!urb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		 * I get the result of a unlink request. But, it seems that I
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		 * already received the result of its submit result and gave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		 * back the URB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		pr_info("the urb (seqnum %d) was already given back\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			pdu->base.seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		usbip_dbg_vhci_rx("now giveback urb %d\n", pdu->base.seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		/* If unlink is successful, status is -ECONNRESET */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		urb->status = pdu->u.ret_unlink.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		pr_info("urb->status %d\n", urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		spin_lock_irqsave(&vhci->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci_hcd), urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		spin_unlock_irqrestore(&vhci->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci_hcd), urb, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	kfree(unlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static int vhci_priv_tx_empty(struct vhci_device *vdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	int empty = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	spin_lock_irqsave(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	empty = list_empty(&vdev->priv_rx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	spin_unlock_irqrestore(&vdev->priv_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	return empty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /* recv a pdu */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static void vhci_rx_pdu(struct usbip_device *ud)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	struct usbip_header pdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	usbip_dbg_vhci_rx("Enter\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	memset(&pdu, 0, sizeof(pdu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	/* receive a pdu header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	ret = usbip_recv(ud->tcp_socket, &pdu, sizeof(pdu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		if (ret == -ECONNRESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			pr_info("connection reset by peer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		else if (ret == -EAGAIN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			/* ignore if connection was idle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			if (vhci_priv_tx_empty(vdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			pr_info("connection timed out with pending urbs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		} else if (ret != -ERESTARTSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			pr_info("xmit failed %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	if (ret == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		pr_info("connection closed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		usbip_event_add(ud, VDEV_EVENT_DOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (ret != sizeof(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		pr_err("received pdu size is %d, should be %d\n", ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		       (unsigned int)sizeof(pdu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	usbip_header_correct_endian(&pdu, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if (usbip_dbg_flag_vhci_rx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		usbip_dump_header(&pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	switch (pdu.base.command) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	case USBIP_RET_SUBMIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		vhci_recv_ret_submit(vdev, &pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	case USBIP_RET_UNLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		vhci_recv_ret_unlink(vdev, &pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		/* NOT REACHED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		pr_err("unknown pdu %u\n", pdu.base.command);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		usbip_dump_header(&pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) int vhci_rx_loop(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	struct usbip_device *ud = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	while (!kthread_should_stop()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		if (usbip_event_happened(ud))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		vhci_rx_pdu(ud);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }