drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c- Extension
.c- Size
- 4761 bytes
- Lines
- 199
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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
rtrs-clt.h
Detected Declarations
function Copyrightfunction rtrs_clt_inc_failover_cntfunction rtrs_clt_stats_migration_from_cnt_to_strfunction rtrs_clt_stats_migration_to_cnt_to_strfunction rtrs_clt_stats_reconnects_to_strfunction rtrs_clt_stats_rdma_to_strfunction for_each_possible_cpufunction rtrs_clt_reset_all_helpfunction rtrs_clt_reset_rdma_statsfunction for_each_possible_cpufunction rtrs_clt_reset_cpu_migr_statsfunction for_each_possible_cpufunction rtrs_clt_reset_reconnects_statfunction rtrs_clt_reset_all_statsfunction rtrs_clt_update_rdma_statsfunction rtrs_clt_update_all_statsfunction rtrs_clt_init_stats
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* RDMA Transport Layer
*
* Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
* Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
* Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
*/
#undef pr_fmt
#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
#include "rtrs-clt.h"
void rtrs_clt_update_wc_stats(struct rtrs_clt_con *con)
{
struct rtrs_clt_path *clt_path = to_clt_path(con->c.path);
struct rtrs_clt_stats *stats = clt_path->stats;
struct rtrs_clt_stats_pcpu *s;
int cpu;
cpu = raw_smp_processor_id();
s = get_cpu_ptr(stats->pcpu_stats);
if (con->cpu != cpu) {
s->cpu_migr.to++;
/* Careful here, override s pointer */
s = per_cpu_ptr(stats->pcpu_stats, con->cpu);
atomic_inc(&s->cpu_migr.from);
}
put_cpu_ptr(stats->pcpu_stats);
}
void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats)
{
this_cpu_inc(stats->pcpu_stats->rdma.failover_cnt);
}
int rtrs_clt_stats_migration_from_cnt_to_str(struct rtrs_clt_stats *stats, char *buf)
{
struct rtrs_clt_stats_pcpu *s;
size_t used;
int cpu;
used = 0;
for_each_possible_cpu(cpu) {
s = per_cpu_ptr(stats->pcpu_stats, cpu);
used += sysfs_emit_at(buf, used, "%d ",
atomic_read(&s->cpu_migr.from));
}
used += sysfs_emit_at(buf, used, "\n");
return used;
}
int rtrs_clt_stats_migration_to_cnt_to_str(struct rtrs_clt_stats *stats, char *buf)
{
struct rtrs_clt_stats_pcpu *s;
size_t used;
int cpu;
used = 0;
for_each_possible_cpu(cpu) {
s = per_cpu_ptr(stats->pcpu_stats, cpu);
used += sysfs_emit_at(buf, used, "%d ", s->cpu_migr.to);
}
used += sysfs_emit_at(buf, used, "\n");
return used;
}
int rtrs_clt_stats_reconnects_to_str(struct rtrs_clt_stats *stats, char *buf)
{
return sysfs_emit(buf, "%d %d\n", stats->reconnects.successful_cnt,
stats->reconnects.fail_cnt);
}
ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, char *page)
{
struct rtrs_clt_stats_rdma sum;
struct rtrs_clt_stats_rdma *r;
int cpu;
memset(&sum, 0, sizeof(sum));
for_each_possible_cpu(cpu) {
r = &per_cpu_ptr(stats->pcpu_stats, cpu)->rdma;
Annotation
- Immediate include surface: `rtrs-clt.h`.
- Detected declarations: `function Copyright`, `function rtrs_clt_inc_failover_cnt`, `function rtrs_clt_stats_migration_from_cnt_to_str`, `function rtrs_clt_stats_migration_to_cnt_to_str`, `function rtrs_clt_stats_reconnects_to_str`, `function rtrs_clt_stats_rdma_to_str`, `function for_each_possible_cpu`, `function rtrs_clt_reset_all_help`, `function rtrs_clt_reset_rdma_stats`, `function for_each_possible_cpu`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.