net/sched/sch_mqprio_lib.c
Source file repositories/reference/linux-study-clean/net/sched/sch_mqprio_lib.c
File Facts
- System
- Linux kernel
- Corpus path
net/sched/sch_mqprio_lib.c- Extension
.c- Size
- 3474 bytes
- Lines
- 133
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/net.hlinux/netdevice.hlinux/netlink.hlinux/types.hnet/pkt_sched.hsch_mqprio_lib.h
Detected Declarations
function intervals_overlapfunction mqprio_validate_queue_countsfunction mqprio_validate_qoptfunction mqprio_qopt_reconstructfunction mqprio_fp_to_offloadexport mqprio_validate_qoptexport mqprio_qopt_reconstructexport mqprio_fp_to_offload
Annotated Snippet
if (!qopt->count[i]) {
NL_SET_ERR_MSG_FMT_MOD(extack, "No queues for TC %d",
i);
return -EINVAL;
}
/* Verify the queue count is in tx range being equal to the
* real_num_tx_queues indicates the last queue is in use.
*/
if (qopt->offset[i] >= dev->real_num_tx_queues ||
last > dev->real_num_tx_queues) {
NL_SET_ERR_MSG_FMT_MOD(extack,
"Queues %d:%d for TC %d exceed the %d TX queues available",
qopt->count[i], qopt->offset[i],
i, dev->real_num_tx_queues);
return -EINVAL;
}
if (allow_overlapping_txqs)
continue;
/* Verify that the offset and counts do not overlap */
for (j = i + 1; j < qopt->num_tc; j++) {
if (intervals_overlap(qopt->offset[i], last,
qopt->offset[j],
qopt->offset[j] +
qopt->count[j])) {
NL_SET_ERR_MSG_FMT_MOD(extack,
"TC %d queues %d@%d overlap with TC %d queues %d@%d",
i, qopt->count[i], qopt->offset[i],
j, qopt->count[j], qopt->offset[j]);
return -EINVAL;
}
}
}
return 0;
}
int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
bool validate_queue_counts,
bool allow_overlapping_txqs,
struct netlink_ext_ack *extack)
{
int i, err;
/* Verify num_tc is not out of max range */
if (qopt->num_tc > TC_MAX_QUEUE) {
NL_SET_ERR_MSG(extack,
"Number of traffic classes is outside valid range");
return -EINVAL;
}
/* Verify priority mapping uses valid tcs */
for (i = 0; i <= TC_BITMASK; i++) {
if (qopt->prio_tc_map[i] >= qopt->num_tc) {
NL_SET_ERR_MSG(extack,
"Invalid traffic class in priority to traffic class mapping");
return -EINVAL;
}
}
if (validate_queue_counts) {
err = mqprio_validate_queue_counts(dev, qopt,
allow_overlapping_txqs,
extack);
if (err)
return err;
}
return 0;
}
EXPORT_SYMBOL_GPL(mqprio_validate_qopt);
void mqprio_qopt_reconstruct(struct net_device *dev, struct tc_mqprio_qopt *qopt)
{
int tc, num_tc = netdev_get_num_tc(dev);
qopt->num_tc = num_tc;
memcpy(qopt->prio_tc_map, dev->prio_tc_map, sizeof(qopt->prio_tc_map));
for (tc = 0; tc < num_tc; tc++) {
qopt->count[tc] = dev->tc_to_txq[tc].count;
qopt->offset[tc] = dev->tc_to_txq[tc].offset;
}
}
EXPORT_SYMBOL_GPL(mqprio_qopt_reconstruct);
void mqprio_fp_to_offload(u32 fp[TC_QOPT_MAX_QUEUE],
struct tc_mqprio_qopt_offload *mqprio)
Annotation
- Immediate include surface: `linux/net.h`, `linux/netdevice.h`, `linux/netlink.h`, `linux/types.h`, `net/pkt_sched.h`, `sch_mqprio_lib.h`.
- Detected declarations: `function intervals_overlap`, `function mqprio_validate_queue_counts`, `function mqprio_validate_qopt`, `function mqprio_qopt_reconstruct`, `function mqprio_fp_to_offload`, `export mqprio_validate_qopt`, `export mqprio_qopt_reconstruct`, `export mqprio_fp_to_offload`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.