drivers/usb/usbip/vhci_rx.c
Source file repositories/reference/linux-study-clean/drivers/usb/usbip/vhci_rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/usbip/vhci_rx.c- Extension
.c- Size
- 6316 bytes
- Lines
- 271
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kthread.hlinux/slab.husbip_common.hvhci.h
Detected Declarations
function Copyrightfunction list_for_each_entry_safefunction vhci_recv_ret_submitfunction list_for_each_entry_safefunction vhci_recv_ret_unlinkfunction vhci_priv_tx_emptyfunction vhci_rx_pdufunction vhci_rx_loop
Annotated Snippet
switch (status) {
case -ENOENT:
fallthrough;
case -ECONNRESET:
dev_dbg(&urb->dev->dev,
"urb seq# %u was unlinked %ssynchronously\n",
seqnum, status == -ENOENT ? "" : "a");
break;
case -EINPROGRESS:
/* no info output */
break;
default:
dev_dbg(&urb->dev->dev,
"urb seq# %u may be in a error, status %d\n",
seqnum, status);
}
list_del(&priv->list);
kfree(priv);
urb->hcpriv = NULL;
break;
}
return urb;
}
static void vhci_recv_ret_submit(struct vhci_device *vdev,
struct usbip_header *pdu)
{
struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
struct vhci *vhci = vhci_hcd->vhci;
struct usbip_device *ud = &vdev->ud;
struct urb *urb;
unsigned long flags;
spin_lock_irqsave(&vdev->priv_lock, flags);
urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
spin_unlock_irqrestore(&vdev->priv_lock, flags);
if (!urb) {
pr_err("cannot find a urb of seqnum %u max seqnum %u\n",
pdu->base.seqnum,
atomic_read(&vhci_hcd->seqnum));
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
/* unpack the pdu to a urb */
usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0);
/* recv transfer buffer */
if (usbip_recv_xbuff(ud, urb) < 0) {
urb->status = -EPROTO;
goto error;
}
/* recv iso_packet_descriptor */
if (usbip_recv_iso(ud, urb) < 0) {
urb->status = -EPROTO;
goto error;
}
/* restore the padding in iso packets */
usbip_pad_iso(ud, urb);
error:
if (usbip_dbg_flag_vhci_rx)
usbip_dump_urb(urb);
if (urb->num_sgs)
urb->transfer_flags &= ~URB_DMA_MAP_SG;
usbip_dbg_vhci_rx("now giveback urb %u\n", pdu->base.seqnum);
spin_lock_irqsave(&vhci->lock, flags);
usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci_hcd), urb);
spin_unlock_irqrestore(&vhci->lock, flags);
usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci_hcd), urb, urb->status);
usbip_dbg_vhci_rx("Leave\n");
}
static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
struct usbip_header *pdu)
{
struct vhci_unlink *unlink, *tmp;
unsigned long flags;
Annotation
- Immediate include surface: `linux/kthread.h`, `linux/slab.h`, `usbip_common.h`, `vhci.h`.
- Detected declarations: `function Copyright`, `function list_for_each_entry_safe`, `function vhci_recv_ret_submit`, `function list_for_each_entry_safe`, `function vhci_recv_ret_unlink`, `function vhci_priv_tx_empty`, `function vhci_rx_pdu`, `function vhci_rx_loop`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.