net/sched/sch_taprio.c
Source file repositories/reference/linux-study-clean/net/sched/sch_taprio.c
File Facts
- System
- Linux kernel
- Corpus path
net/sched/sch_taprio.c- Extension
.c- Size
- 68743 bytes
- Lines
- 2583
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
linux/ethtool.hlinux/ethtool_netlink.hlinux/types.hlinux/slab.hlinux/kernel.hlinux/string.hlinux/list.hlinux/errno.hlinux/skbuff.hlinux/math64.hlinux/module.hlinux/spinlock.hlinux/rcupdate.hlinux/time.hnet/gso.hnet/netlink.hnet/pkt_sched.hnet/pkt_cls.hnet/sch_generic.hnet/sock.hnet/tcp.hsch_mqprio_lib.h
Detected Declarations
struct sched_entrystruct sched_gate_liststruct taprio_schedstruct __tc_taprio_qopt_offloadfunction taprio_calculate_gate_durationsfunction list_for_each_entryfunction taprio_entry_allows_txfunction sched_base_timefunction taprio_mono_to_anyfunction taprio_get_timefunction taprio_free_sched_cbfunction list_for_each_entry_safefunction switch_schedulesfunction get_cycle_time_elapsedfunction get_interval_end_timefunction length_to_durationfunction duration_to_lengthfunction taprio_update_queue_max_sdufunction list_for_each_entryfunction is_valid_intervalfunction get_tcp_tstampfunction get_packet_txtimefunction taprio_skb_exceeds_queue_max_sdufunction taprio_enqueue_onefunction taprio_enqueue_segmentedfunction skb_list_walk_safefunction qdisc_create_dfltfunction taprio_set_budgetsfunction taprio_update_budgetsfunction taprio_next_tc_txqfunction qdisc_create_dfltfunction should_restart_cyclefunction should_change_schedulesfunction advance_schedfunction fill_sched_entryfunction parse_sched_entryfunction parse_sched_listfunction nla_for_each_nestedfunction parse_taprio_schedulefunction taprio_parse_mqprio_optfunction taprio_get_start_timefunction setup_first_end_timefunction taprio_start_schedfunction taprio_set_picos_per_bytefunction taprio_dev_notifierfunction list_for_each_entryfunction setup_txtimefunction list_for_each_entry
Annotated Snippet
const struct net_device_ops *ops = dev->netdev_ops;
struct tc_taprio_qopt_offload *offload;
struct tc_taprio_caps caps;
int tc, err = 0;
if (!ops->ndo_setup_tc) {
NL_SET_ERR_MSG(extack,
"Device does not support taprio offload");
return -EOPNOTSUPP;
}
qdisc_offload_query_caps(dev, TC_SETUP_QDISC_TAPRIO,
&caps, sizeof(caps));
if (!caps.supports_queue_max_sdu) {
for (tc = 0; tc < TC_MAX_QUEUE; tc++) {
if (q->max_sdu[tc]) {
NL_SET_ERR_MSG_MOD(extack,
"Device does not handle queueMaxSDU");
return -EOPNOTSUPP;
}
}
}
offload = taprio_offload_alloc(sched->num_entries);
if (!offload) {
NL_SET_ERR_MSG(extack,
"Not enough memory for enabling offload mode");
return -ENOMEM;
}
offload->cmd = TAPRIO_CMD_REPLACE;
offload->extack = extack;
mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt);
offload->mqprio.extack = extack;
taprio_sched_to_offload(dev, sched, offload, &caps);
mqprio_fp_to_offload(q->fp, &offload->mqprio);
for (tc = 0; tc < TC_MAX_QUEUE; tc++)
offload->max_sdu[tc] = q->max_sdu[tc];
err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload);
if (err < 0) {
NL_SET_ERR_MSG_WEAK(extack,
"Device failed to setup taprio offload");
goto done;
}
q->offloaded = true;
done:
/* The offload structure may linger around via a reference taken by the
* device driver, so clear up the netlink extack pointer so that the
* driver isn't tempted to dereference data which stopped being valid
*/
offload->extack = NULL;
offload->mqprio.extack = NULL;
taprio_offload_free(offload);
return err;
}
static int taprio_disable_offload(struct net_device *dev,
struct taprio_sched *q,
struct netlink_ext_ack *extack)
{
const struct net_device_ops *ops = dev->netdev_ops;
struct tc_taprio_qopt_offload *offload;
int err;
if (!q->offloaded)
return 0;
offload = taprio_offload_alloc(0);
if (!offload) {
NL_SET_ERR_MSG(extack,
"Not enough memory to disable offload mode");
return -ENOMEM;
}
offload->cmd = TAPRIO_CMD_DESTROY;
err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload);
if (err < 0) {
NL_SET_ERR_MSG(extack,
"Device failed to disable offload");
goto out;
}
q->offloaded = false;
out:
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/ethtool_netlink.h`, `linux/types.h`, `linux/slab.h`, `linux/kernel.h`, `linux/string.h`, `linux/list.h`, `linux/errno.h`.
- Detected declarations: `struct sched_entry`, `struct sched_gate_list`, `struct taprio_sched`, `struct __tc_taprio_qopt_offload`, `function taprio_calculate_gate_durations`, `function list_for_each_entry`, `function taprio_entry_allows_tx`, `function sched_base_time`, `function taprio_mono_to_any`, `function taprio_get_time`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.