drivers/usb/usbip/vudc_tx.c
Source file repositories/reference/linux-study-clean/drivers/usb/usbip/vudc_tx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/usbip/vudc_tx.c- Extension
.c- Size
- 6434 bytes
- Lines
- 285
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/sock.hlinux/list.hlinux/kthread.husbip_common.hvudc.h
Detected Declarations
function Copyrightfunction setup_ret_submit_pdufunction setup_ret_unlink_pdufunction v_send_ret_unlinkfunction v_send_ret_submitfunction usb_pipeinfunction usb_pipeinfunction v_send_retfunction v_tx_loopfunction v_enqueue_ret_unlinkfunction v_enqueue_ret_submit
Annotated Snippet
usb_pipein(urb->pipe) && urb->actual_length > 0) {
iov[iovnum].iov_base = urb->transfer_buffer;
iov[iovnum].iov_len = urb->actual_length;
iovnum++;
txsize += urb->actual_length;
} else if (urb_p->type == USB_ENDPOINT_XFER_ISOC &&
usb_pipein(urb->pipe)) {
/* FIXME - copypasted from stub_tx, refactor */
int i;
for (i = 0; i < urb->number_of_packets; i++) {
iov[iovnum].iov_base = urb->transfer_buffer +
urb->iso_frame_desc[i].offset;
iov[iovnum].iov_len =
urb->iso_frame_desc[i].actual_length;
iovnum++;
txsize += urb->iso_frame_desc[i].actual_length;
}
if (txsize != sizeof(pdu_header) + urb->actual_length) {
usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP);
ret = -EPIPE;
goto out;
}
}
/* else - no buffer to send */
/* 3. setup iso_packet_descriptor */
if (urb_p->type == USB_ENDPOINT_XFER_ISOC) {
ssize_t len = 0;
iso_buffer = usbip_alloc_iso_desc_pdu(urb, &len);
if (!iso_buffer) {
usbip_event_add(&udc->ud,
VUDC_EVENT_ERROR_MALLOC);
ret = -ENOMEM;
goto out;
}
iov[iovnum].iov_base = iso_buffer;
iov[iovnum].iov_len = len;
txsize += len;
iovnum++;
}
ret = kernel_sendmsg(udc->ud.tcp_socket, &msg,
iov, iovnum, txsize);
if (ret != txsize) {
usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP);
if (ret >= 0)
ret = -EPIPE;
goto out;
}
out:
kfree(iov);
kfree(iso_buffer);
free_urbp_and_urb(urb_p);
if (ret < 0)
return ret;
return txsize;
}
static int v_send_ret(struct vudc *udc)
{
unsigned long flags;
struct tx_item *txi;
size_t total_size = 0;
int ret = 0;
spin_lock_irqsave(&udc->lock_tx, flags);
while (!list_empty(&udc->tx_queue)) {
txi = list_first_entry(&udc->tx_queue, struct tx_item,
tx_entry);
list_del(&txi->tx_entry);
spin_unlock_irqrestore(&udc->lock_tx, flags);
switch (txi->type) {
case TX_SUBMIT:
ret = v_send_ret_submit(udc, txi->s);
break;
case TX_UNLINK:
ret = v_send_ret_unlink(udc, txi->u);
break;
}
kfree(txi);
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `net/sock.h`, `linux/list.h`, `linux/kthread.h`, `usbip_common.h`, `vudc.h`.
- Detected declarations: `function Copyright`, `function setup_ret_submit_pdu`, `function setup_ret_unlink_pdu`, `function v_send_ret_unlink`, `function v_send_ret_submit`, `function usb_pipein`, `function usb_pipein`, `function v_send_ret`, `function v_tx_loop`, `function v_enqueue_ret_unlink`.
- 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.