drivers/net/ethernet/chelsio/cxgb4/sched.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4/sched.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb4/sched.c- Extension
.c- Size
- 16427 bytes
- Lines
- 694
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/netdevice.hcxgb4.hsched.h
Detected Declarations
function Copyrightfunction t4_sched_bind_unbind_opfunction list_for_each_entryfunction list_for_each_entryfunction t4_sched_queue_unbindfunction t4_sched_queue_bindfunction t4_sched_flowc_unbindfunction t4_sched_flowc_bindfunction t4_sched_class_unbind_allfunction t4_sched_class_bind_unbind_opfunction entityfunction entityfunction cxgb4_sched_class_freefunction t4_sched_class_freefunction t4_cleanup_schedfunction for_each_port
Annotated Snippet
switch (type) {
case SCHED_QUEUE: {
struct sched_queue_entry *qe;
list_for_each_entry(qe, &e->entry_list, list) {
if (qe->cntxt_id == val) {
found = qe;
break;
}
}
break;
}
case SCHED_FLOWC: {
struct sched_flowc_entry *fe;
list_for_each_entry(fe, &e->entry_list, list) {
if (fe->param.tid == val) {
found = fe;
break;
}
}
break;
}
default:
return NULL;
}
if (found)
break;
}
return found;
}
struct ch_sched_class *cxgb4_sched_queue_lookup(struct net_device *dev,
struct ch_sched_queue *p)
{
struct port_info *pi = netdev2pinfo(dev);
struct sched_queue_entry *qe = NULL;
struct adapter *adap = pi->adapter;
struct sge_eth_txq *txq;
if (p->queue < 0 || p->queue >= pi->nqsets)
return NULL;
txq = &adap->sge.ethtxq[pi->first_qset + p->queue];
qe = t4_sched_entry_lookup(pi, SCHED_QUEUE, txq->q.cntxt_id);
return qe ? &pi->sched_tbl->tab[qe->param.class] : NULL;
}
static int t4_sched_queue_unbind(struct port_info *pi, struct ch_sched_queue *p)
{
struct sched_queue_entry *qe = NULL;
struct adapter *adap = pi->adapter;
struct sge_eth_txq *txq;
struct ch_sched_class *e;
int err = 0;
if (p->queue < 0 || p->queue >= pi->nqsets)
return -ERANGE;
txq = &adap->sge.ethtxq[pi->first_qset + p->queue];
/* Find the existing entry that the queue is bound to */
qe = t4_sched_entry_lookup(pi, SCHED_QUEUE, txq->q.cntxt_id);
if (qe) {
err = t4_sched_bind_unbind_op(pi, (void *)qe, SCHED_QUEUE,
false);
if (err)
return err;
e = &pi->sched_tbl->tab[qe->param.class];
list_del(&qe->list);
kvfree(qe);
if (atomic_dec_and_test(&e->refcnt))
cxgb4_sched_class_free(adap->port[pi->port_id], e->idx);
}
return err;
}
static int t4_sched_queue_bind(struct port_info *pi, struct ch_sched_queue *p)
{
struct sched_table *s = pi->sched_tbl;
struct sched_queue_entry *qe = NULL;
struct adapter *adap = pi->adapter;
struct sge_eth_txq *txq;
struct ch_sched_class *e;
unsigned int qid;
int err = 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/netdevice.h`, `cxgb4.h`, `sched.h`.
- Detected declarations: `function Copyright`, `function t4_sched_bind_unbind_op`, `function list_for_each_entry`, `function list_for_each_entry`, `function t4_sched_queue_unbind`, `function t4_sched_queue_bind`, `function t4_sched_flowc_unbind`, `function t4_sched_flowc_bind`, `function t4_sched_class_unbind_all`, `function t4_sched_class_bind_unbind_op`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.