drivers/net/ethernet/mscc/ocelot_devlink.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mscc/ocelot_devlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mscc/ocelot_devlink.c- Extension
.c- Size
- 27745 bytes
- Lines
- 917
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/devlink.hocelot.h
Detected Declarations
function ocelot_wm_readfunction ocelot_wm_writefunction ocelot_wm_statusfunction ocelot_disable_reservation_watermarksfunction utilizationfunction ocelot_get_buf_rsrvfunction ocelot_get_ref_rsrvfunction ocelot_setup_sharing_watermarksfunction ocelot_watermark_validatefunction onefunction ocelot_wm_encfunction ocelot_wm_decfunction ocelot_wm_statfunction ocelot_sb_pool_getfunction ingressfunction ocelot_sb_port_pool_getfunction ocelot_sb_port_pool_setfunction ocelot_sb_tc_pool_bind_getfunction ocelot_sb_tc_pool_bind_setfunction ocelot_sb_occ_snapshotfunction ocelot_sb_occ_max_clearfunction ocelot_sb_occ_port_pool_getfunction ocelot_sb_occ_tc_port_bind_getfunction ocelot_devlink_sb_registerfunction ocelot_devlink_sb_unregisterexport ocelot_wm_encexport ocelot_wm_decexport ocelot_wm_statexport ocelot_sb_pool_getexport ocelot_sb_pool_setexport ocelot_sb_port_pool_getexport ocelot_sb_port_pool_setexport ocelot_sb_tc_pool_bind_getexport ocelot_sb_tc_pool_bind_setexport ocelot_sb_occ_snapshotexport ocelot_sb_occ_max_clearexport ocelot_sb_occ_port_pool_getexport ocelot_sb_occ_tc_port_bind_getexport ocelot_devlink_sb_registerexport ocelot_devlink_sb_unregister
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/* Copyright 2020-2021 NXP
*/
#include <net/devlink.h>
#include "ocelot.h"
/* The queue system tracks four resource consumptions:
* Resource 0: Memory tracked per source port
* Resource 1: Frame references tracked per source port
* Resource 2: Memory tracked per destination port
* Resource 3: Frame references tracked per destination port
*/
#define OCELOT_RESOURCE_SZ 256
#define OCELOT_NUM_RESOURCES 4
#define BUF_xxxx_I (0 * OCELOT_RESOURCE_SZ)
#define REF_xxxx_I (1 * OCELOT_RESOURCE_SZ)
#define BUF_xxxx_E (2 * OCELOT_RESOURCE_SZ)
#define REF_xxxx_E (3 * OCELOT_RESOURCE_SZ)
/* For each resource type there are 4 types of watermarks:
* Q_RSRV: reservation per QoS class per port
* PRIO_SHR: sharing watermark per QoS class across all ports
* P_RSRV: reservation per port
* COL_SHR: sharing watermark per color (drop precedence) across all ports
*/
#define xxx_Q_RSRV_x 0
#define xxx_PRIO_SHR_x 216
#define xxx_P_RSRV_x 224
#define xxx_COL_SHR_x 254
/* Reservation Watermarks
* ----------------------
*
* For setting up the reserved areas, egress watermarks exist per port and per
* QoS class for both ingress and egress.
*/
/* Amount of packet buffer
* | per QoS class
* | | reserved
* | | | per egress port
* | | | |
* V V v v
* BUF_Q_RSRV_E
*/
#define BUF_Q_RSRV_E(port, prio) \
(BUF_xxxx_E + xxx_Q_RSRV_x + OCELOT_NUM_TC * (port) + (prio))
/* Amount of packet buffer
* | for all port's traffic classes
* | | reserved
* | | | per egress port
* | | | |
* V V v v
* BUF_P_RSRV_E
*/
#define BUF_P_RSRV_E(port) \
(BUF_xxxx_E + xxx_P_RSRV_x + (port))
/* Amount of packet buffer
* | per QoS class
* | | reserved
* | | | per ingress port
* | | | |
* V V v v
* BUF_Q_RSRV_I
*/
#define BUF_Q_RSRV_I(port, prio) \
(BUF_xxxx_I + xxx_Q_RSRV_x + OCELOT_NUM_TC * (port) + (prio))
/* Amount of packet buffer
* | for all port's traffic classes
* | | reserved
* | | | per ingress port
* | | | |
* V V v v
* BUF_P_RSRV_I
*/
#define BUF_P_RSRV_I(port) \
(BUF_xxxx_I + xxx_P_RSRV_x + (port))
/* Amount of frame references
* | per QoS class
* | | reserved
* | | | per egress port
* | | | |
* V V v v
* REF_Q_RSRV_E
*/
Annotation
- Immediate include surface: `net/devlink.h`, `ocelot.h`.
- Detected declarations: `function ocelot_wm_read`, `function ocelot_wm_write`, `function ocelot_wm_status`, `function ocelot_disable_reservation_watermarks`, `function utilization`, `function ocelot_get_buf_rsrv`, `function ocelot_get_ref_rsrv`, `function ocelot_setup_sharing_watermarks`, `function ocelot_watermark_validate`, `function one`.
- Atlas domain: Driver Families / drivers/net.
- 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.