drivers/net/ethernet/amd/xgbe/xgbe-selftest.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/amd/xgbe/xgbe-selftest.c- Extension
.c- Size
- 7415 bytes
- Lines
- 347
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- 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
linux/crc32.hlinux/ip.hlinux/udp.hnet/tcp.hnet/udp.hnet/checksum.hnet/selftests.hxgbe.hxgbe-common.h
Detected Declarations
struct xgbe_testfunction xgbe_test_loopback_validatefunction __xgbe_test_loopbackfunction xgbe_test_mac_loopbackfunction xgbe_test_phy_loopbackfunction xgbe_test_sphfunction xgbe_test_jumbofunction xgbe_selftest_runfunction xgbe_selftest_get_stringsfunction xgbe_selftest_get_count
Annotated Snippet
struct xgbe_test {
char name[ETH_GSTRING_LEN];
int lb;
int (*fn)(struct xgbe_prv_data *pdata);
};
static u8 xgbe_test_id;
static int xgbe_test_loopback_validate(struct sk_buff *skb,
struct net_device *ndev,
struct packet_type *pt,
struct net_device *orig_ndev)
{
struct net_test_priv *tdata = pt->af_packet_priv;
const unsigned char *dst = tdata->packet->dst;
const unsigned char *src = tdata->packet->src;
struct netsfhdr *hdr;
struct ethhdr *eh;
struct tcphdr *th;
struct udphdr *uh;
struct iphdr *ih;
int eat;
skb = skb_unshare(skb, GFP_ATOMIC);
if (!skb)
goto out;
eat = (skb->tail + skb->data_len) - skb->end;
if (eat > 0 && skb_shared(skb)) {
skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb)
goto out;
}
if (skb_linearize(skb))
goto out;
if (skb_headlen(skb) < (NET_TEST_PKT_SIZE - ETH_HLEN))
goto out;
eh = (struct ethhdr *)skb_mac_header(skb);
if (dst) {
if (!ether_addr_equal_unaligned(eh->h_dest, dst))
goto out;
}
if (src) {
if (!ether_addr_equal_unaligned(eh->h_source, src))
goto out;
}
ih = ip_hdr(skb);
if (tdata->packet->tcp) {
if (ih->protocol != IPPROTO_TCP)
goto out;
th = (struct tcphdr *)((u8 *)ih + 4 * ih->ihl);
if (th->dest != htons(tdata->packet->dport))
goto out;
hdr = (struct netsfhdr *)((u8 *)th + sizeof(*th));
} else {
if (ih->protocol != IPPROTO_UDP)
goto out;
uh = (struct udphdr *)((u8 *)ih + 4 * ih->ihl);
if (uh->dest != htons(tdata->packet->dport))
goto out;
hdr = (struct netsfhdr *)((u8 *)uh + sizeof(*uh));
}
if (hdr->magic != cpu_to_be64(NET_TEST_PKT_MAGIC))
goto out;
if (tdata->packet->id != hdr->id)
goto out;
tdata->ok = true;
complete(&tdata->comp);
out:
kfree_skb(skb);
return 0;
}
static int __xgbe_test_loopback(struct xgbe_prv_data *pdata,
struct net_packet_attrs *attr)
{
struct net_test_priv *tdata;
struct sk_buff *skb = NULL;
int ret = 0;
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/ip.h`, `linux/udp.h`, `net/tcp.h`, `net/udp.h`, `net/checksum.h`, `net/selftests.h`, `xgbe.h`.
- Detected declarations: `struct xgbe_test`, `function xgbe_test_loopback_validate`, `function __xgbe_test_loopback`, `function xgbe_test_mac_loopback`, `function xgbe_test_phy_loopback`, `function xgbe_test_sph`, `function xgbe_test_jumbo`, `function xgbe_selftest_run`, `function xgbe_selftest_get_strings`, `function xgbe_selftest_get_count`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.