drivers/net/ethernet/microchip/fdma/fdma_api.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/fdma/fdma_api.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/fdma/fdma_api.c- Extension
.c- Size
- 3564 bytes
- Lines
- 147
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
fdma_api.hlinux/bits.hlinux/etherdevice.hlinux/types.h
Detected Declarations
function __fdma_db_addfunction fdma_db_addfunction __fdma_dcb_addfunction fdma_dcb_addfunction fdma_dcbs_initfunction fdma_alloc_coherentfunction fdma_alloc_physfunction fdma_free_coherentfunction fdma_free_physfunction fdma_get_sizefunction fdma_get_size_contiguousexport __fdma_dcb_addexport fdma_dcb_addexport fdma_dcbs_initexport fdma_alloc_coherentexport fdma_alloc_physexport fdma_free_coherentexport fdma_free_physexport fdma_get_sizeexport fdma_get_size_contiguous
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include "fdma_api.h"
#include <linux/bits.h>
#include <linux/etherdevice.h>
#include <linux/types.h>
/* Add a DB to a DCB, providing a callback for getting the DB dataptr. */
static int __fdma_db_add(struct fdma *fdma, int dcb_idx, int db_idx, u64 status,
int (*cb)(struct fdma *fdma, int dcb_idx,
int db_idx, u64 *dataptr))
{
struct fdma_db *db = fdma_db_get(fdma, dcb_idx, db_idx);
db->status = status;
return cb(fdma, dcb_idx, db_idx, &db->dataptr);
}
/* Add a DB to a DCB, using the callback set in the fdma_ops struct. */
int fdma_db_add(struct fdma *fdma, int dcb_idx, int db_idx, u64 status)
{
return __fdma_db_add(fdma,
dcb_idx,
db_idx,
status,
fdma->ops.dataptr_cb);
}
/* Add a DCB with callbacks for getting the DB dataptr and the DCB nextptr. */
int __fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 info, u64 status,
int (*dcb_cb)(struct fdma *fdma, int dcb_idx, u64 *nextptr),
int (*db_cb)(struct fdma *fdma, int dcb_idx, int db_idx,
u64 *dataptr))
{
struct fdma_dcb *dcb = fdma_dcb_get(fdma, dcb_idx);
int i, err;
for (i = 0; i < fdma->n_dbs; i++) {
err = __fdma_db_add(fdma, dcb_idx, i, status, db_cb);
if (unlikely(err))
return err;
}
err = dcb_cb(fdma, dcb_idx, &fdma->last_dcb->nextptr);
if (unlikely(err))
return err;
fdma->last_dcb = dcb;
dcb->nextptr = FDMA_DCB_INVALID_DATA;
dcb->info = info;
return 0;
}
EXPORT_SYMBOL_GPL(__fdma_dcb_add);
/* Add a DCB, using the preset callbacks in the fdma_ops struct. */
int fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 info, u64 status)
{
return __fdma_dcb_add(fdma,
dcb_idx,
info, status,
fdma->ops.nextptr_cb,
fdma->ops.dataptr_cb);
}
EXPORT_SYMBOL_GPL(fdma_dcb_add);
/* Initialize the DCB's and DB's. */
int fdma_dcbs_init(struct fdma *fdma, u64 info, u64 status)
{
int i, err;
fdma->last_dcb = fdma->dcbs;
fdma->db_index = 0;
fdma->dcb_index = 0;
for (i = 0; i < fdma->n_dcbs; i++) {
err = fdma_dcb_add(fdma, i, info, status);
if (err)
return err;
}
return 0;
}
EXPORT_SYMBOL_GPL(fdma_dcbs_init);
/* Allocate coherent DMA memory for FDMA. */
int fdma_alloc_coherent(struct device *dev, struct fdma *fdma)
Annotation
- Immediate include surface: `fdma_api.h`, `linux/bits.h`, `linux/etherdevice.h`, `linux/types.h`.
- Detected declarations: `function __fdma_db_add`, `function fdma_db_add`, `function __fdma_dcb_add`, `function fdma_dcb_add`, `function fdma_dcbs_init`, `function fdma_alloc_coherent`, `function fdma_alloc_phys`, `function fdma_free_coherent`, `function fdma_free_phys`, `function fdma_get_size`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.