drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c- Extension
.c- Size
- 10160 bytes
- Lines
- 376
- 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.
- 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
linux/etherdevice.hlinux/mlx5/driver.hmlx5_core.hlib/mlx5.hlib/eq.hfpga/core.hfpga/conn.h
Detected Declarations
function mlx5_is_fpga_lookasidefunction mlx5_fpga_device_load_checkfunction mlx5_fpga_device_brbfunction fpga_err_eventfunction fpga_qp_err_eventfunction mlx5_fpga_device_startfunction mlx5_fpga_initfunction mlx5_fpga_device_stopfunction mlx5_fpga_cleanupfunction mlx5_fpga_event
Annotated Snippet
#include <linux/etherdevice.h>
#include <linux/mlx5/driver.h>
#include "mlx5_core.h"
#include "lib/mlx5.h"
#include "lib/eq.h"
#include "fpga/core.h"
#include "fpga/conn.h"
static const char *const mlx5_fpga_error_strings[] = {
"Null Syndrome",
"Corrupted DDR",
"Flash Timeout",
"Internal Link Error",
"Watchdog HW Failure",
"I2C Failure",
"Image Changed",
"Temperature Critical",
};
static const char * const mlx5_fpga_qp_error_strings[] = {
"Null Syndrome",
"Retry Counter Expired",
"RNR Expired",
};
static struct mlx5_fpga_device *mlx5_fpga_device_alloc(void)
{
struct mlx5_fpga_device *fdev;
fdev = kzalloc_obj(*fdev);
if (!fdev)
return NULL;
spin_lock_init(&fdev->state_lock);
fdev->state = MLX5_FPGA_STATUS_NONE;
return fdev;
}
static const char *mlx5_fpga_image_name(enum mlx5_fpga_image image)
{
switch (image) {
case MLX5_FPGA_IMAGE_USER:
return "user";
case MLX5_FPGA_IMAGE_FACTORY:
return "factory";
default:
return "unknown";
}
}
static const char *mlx5_fpga_name(u32 fpga_id)
{
static char ret[32];
switch (fpga_id) {
case MLX5_FPGA_NEWTON:
return "Newton";
case MLX5_FPGA_EDISON:
return "Edison";
case MLX5_FPGA_MORSE:
return "Morse";
case MLX5_FPGA_MORSEQ:
return "MorseQ";
}
snprintf(ret, sizeof(ret), "Unknown %d", fpga_id);
return ret;
}
static int mlx5_is_fpga_lookaside(u32 fpga_id)
{
return fpga_id != MLX5_FPGA_NEWTON && fpga_id != MLX5_FPGA_EDISON;
}
static int mlx5_fpga_device_load_check(struct mlx5_fpga_device *fdev)
{
struct mlx5_fpga_query query;
int err;
err = mlx5_fpga_query(fdev->mdev, &query);
if (err) {
mlx5_fpga_err(fdev, "Failed to query status: %d\n", err);
return err;
}
fdev->last_admin_image = query.admin_image;
fdev->last_oper_image = query.oper_image;
mlx5_fpga_info(fdev, "Status %u; Admin image %u; Oper image %u\n",
query.status, query.admin_image, query.oper_image);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/mlx5/driver.h`, `mlx5_core.h`, `lib/mlx5.h`, `lib/eq.h`, `fpga/core.h`, `fpga/conn.h`.
- Detected declarations: `function mlx5_is_fpga_lookaside`, `function mlx5_fpga_device_load_check`, `function mlx5_fpga_device_brb`, `function fpga_err_event`, `function fpga_qp_err_event`, `function mlx5_fpga_device_start`, `function mlx5_fpga_init`, `function mlx5_fpga_device_stop`, `function mlx5_fpga_cleanup`, `function mlx5_fpga_event`.
- 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.