net/dsa/tag_hellcreek.c
Source file repositories/reference/linux-study-clean/net/dsa/tag_hellcreek.c
File Facts
- System
- Linux kernel
- Corpus path
net/dsa/tag_hellcreek.c- Extension
.c- Size
- 1804 bytes
- Lines
- 74
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/skbuff.hnet/dsa.htag.h
Detected Declarations
function Copyright
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/*
* net/dsa/tag_hellcreek.c - Hirschmann Hellcreek switch tag format handling
*
* Copyright (C) 2019,2020 Linutronix GmbH
* Author Kurt Kanzenbach <kurt@linutronix.de>
*
* Based on tag_ksz.c.
*/
#include <linux/skbuff.h>
#include <net/dsa.h>
#include "tag.h"
#define HELLCREEK_NAME "hellcreek"
#define HELLCREEK_TAG_LEN 1
static struct sk_buff *hellcreek_xmit(struct sk_buff *skb,
struct net_device *dev)
{
u8 *tag;
/* Calculate checksums (if required) before adding the trailer tag to
* avoid including it in calculations. That would lead to wrong
* checksums after the switch strips the tag.
*/
if (skb->ip_summed == CHECKSUM_PARTIAL &&
skb_checksum_help(skb))
return NULL;
/* Tag encoding */
tag = skb_put(skb, HELLCREEK_TAG_LEN);
*tag = dsa_xmit_port_mask(skb, dev);
return skb;
}
static struct sk_buff *hellcreek_rcv(struct sk_buff *skb,
struct net_device *dev)
{
/* Tag decoding */
u8 *tag = skb_tail_pointer(skb) - HELLCREEK_TAG_LEN;
unsigned int port = tag[0] & 0x03;
skb->dev = dsa_conduit_find_user(dev, 0, port);
if (!skb->dev) {
netdev_warn_once(dev, "Failed to get source port: %d\n", port);
return NULL;
}
if (pskb_trim_rcsum(skb, skb->len - HELLCREEK_TAG_LEN))
return NULL;
dsa_default_offload_fwd_mark(skb);
return skb;
}
static const struct dsa_device_ops hellcreek_netdev_ops = {
.name = HELLCREEK_NAME,
.proto = DSA_TAG_PROTO_HELLCREEK,
.xmit = hellcreek_xmit,
.rcv = hellcreek_rcv,
.needed_tailroom = HELLCREEK_TAG_LEN,
};
MODULE_DESCRIPTION("DSA tag driver for Hirschmann Hellcreek TSN switches");
MODULE_LICENSE("Dual MIT/GPL");
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_HELLCREEK, HELLCREEK_NAME);
module_dsa_tag_driver(hellcreek_netdev_ops);
Annotation
- Immediate include surface: `linux/skbuff.h`, `net/dsa.h`, `tag.h`.
- Detected declarations: `function Copyright`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.