net/core/tso.c
Source file repositories/reference/linux-study-clean/net/core/tso.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/tso.c- Extension
.c- Size
- 9554 bytes
- Lines
- 359
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/if_vlan.hnet/ip.hnet/tso.hlinux/dma-mapping.hlinux/unaligned.h
Detected Declarations
function tso_build_hdrfunction tso_build_datafunction tso_startfunction tso_dma_iova_tryfunction tso_dma_map_initfunction dma_iova_destroyfunction tso_dma_map_countfunction nextexport tso_build_hdrexport tso_build_dataexport tso_startexport tso_dma_map_initexport tso_dma_map_cleanupexport tso_dma_map_countexport tso_dma_map_next
Annotated Snippet
if (!is_last) {
/* Clear all special flags for not last packet */
tcph->psh = 0;
tcph->fin = 0;
tcph->rst = 0;
}
} else {
struct udphdr *uh = (struct udphdr *)hdr;
uh->len = htons(sizeof(*uh) + size);
}
}
EXPORT_SYMBOL(tso_build_hdr);
void tso_build_data(const struct sk_buff *skb, struct tso_t *tso, int size)
{
tso->tcp_seq += size; /* not worth avoiding this operation for UDP */
tso->size -= size;
tso->data += size;
if ((tso->size == 0) &&
(tso->next_frag_idx < skb_shinfo(skb)->nr_frags)) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[tso->next_frag_idx];
/* Move to next segment */
tso->size = skb_frag_size(frag);
tso->data = skb_frag_address(frag);
tso->next_frag_idx++;
}
}
EXPORT_SYMBOL(tso_build_data);
int tso_start(struct sk_buff *skb, struct tso_t *tso)
{
int tlen = skb_is_gso_tcp(skb) ? tcp_hdrlen(skb) : sizeof(struct udphdr);
int hdr_len = skb_transport_offset(skb) + tlen;
tso->tlen = tlen;
tso->ip_id = ntohs(ip_hdr(skb)->id);
tso->tcp_seq = (tlen != sizeof(struct udphdr)) ? ntohl(tcp_hdr(skb)->seq) : 0;
tso->next_frag_idx = 0;
tso->ipv6 = vlan_get_protocol(skb) == htons(ETH_P_IPV6);
/* Build first data */
tso->size = skb_headlen(skb) - hdr_len;
tso->data = skb->data + hdr_len;
if ((tso->size == 0) &&
(tso->next_frag_idx < skb_shinfo(skb)->nr_frags)) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[tso->next_frag_idx];
/* Move to next segment */
tso->size = skb_frag_size(frag);
tso->data = skb_frag_address(frag);
tso->next_frag_idx++;
}
return hdr_len;
}
EXPORT_SYMBOL(tso_start);
static int tso_dma_iova_try(struct device *dev, struct tso_dma_map *map,
phys_addr_t phys, size_t linear_len,
size_t total_len, size_t *offset)
{
const struct sk_buff *skb;
unsigned int nr_frags;
int i;
if (!dma_iova_try_alloc(dev, &map->iova_state, phys, total_len))
return 1;
skb = map->skb;
nr_frags = skb_shinfo(skb)->nr_frags;
if (linear_len) {
if (dma_iova_link(dev, &map->iova_state,
phys, *offset, linear_len,
DMA_TO_DEVICE, 0))
goto iova_fail;
map->linear_len = linear_len;
*offset += linear_len;
}
for (i = 0; i < nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
unsigned int frag_len = skb_frag_size(frag);
if (dma_iova_link(dev, &map->iova_state,
skb_frag_phys(frag), *offset,
frag_len, DMA_TO_DEVICE, 0)) {
map->nr_frags = i;
Annotation
- Immediate include surface: `linux/export.h`, `linux/if_vlan.h`, `net/ip.h`, `net/tso.h`, `linux/dma-mapping.h`, `linux/unaligned.h`.
- Detected declarations: `function tso_build_hdr`, `function tso_build_data`, `function tso_start`, `function tso_dma_iova_try`, `function tso_dma_map_init`, `function dma_iova_destroy`, `function tso_dma_map_count`, `function next`, `export tso_build_hdr`, `export tso_build_data`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.