drivers/net/ethernet/mellanox/mlx5/core/lib/hv.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/lib/hv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lib/hv.c- Extension
.c- Size
- 1634 bytes
- Lines
- 65
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hyperv.hmlx5_core.hlib/hv.h
Detected Declarations
function mlx5_hv_config_commonfunction mlx5_hv_read_configfunction mlx5_hv_write_configfunction mlx5_hv_register_invalidatefunction mlx5_hv_unregister_invalidate
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
// Copyright (c) 2018 Mellanox Technologies
#include <linux/hyperv.h>
#include "mlx5_core.h"
#include "lib/hv.h"
static int mlx5_hv_config_common(struct mlx5_core_dev *dev, void *buf, int len,
int offset, bool read)
{
int rc = -EOPNOTSUPP;
int bytes_returned;
int block_id;
if (offset % HV_CONFIG_BLOCK_SIZE_MAX || len != HV_CONFIG_BLOCK_SIZE_MAX)
return -EINVAL;
block_id = offset / HV_CONFIG_BLOCK_SIZE_MAX;
rc = read ?
hyperv_read_cfg_blk(dev->pdev, buf,
HV_CONFIG_BLOCK_SIZE_MAX, block_id,
&bytes_returned) :
hyperv_write_cfg_blk(dev->pdev, buf,
HV_CONFIG_BLOCK_SIZE_MAX, block_id);
/* Make sure len bytes were read successfully */
if (read && !rc && len != bytes_returned)
rc = -EIO;
if (rc) {
mlx5_core_err(dev, "Failed to %s hv config, err = %d, len = %d, offset = %d\n",
read ? "read" : "write", rc, len,
offset);
return rc;
}
return 0;
}
int mlx5_hv_read_config(struct mlx5_core_dev *dev, void *buf, int len,
int offset)
{
return mlx5_hv_config_common(dev, buf, len, offset, true);
}
int mlx5_hv_write_config(struct mlx5_core_dev *dev, void *buf, int len,
int offset)
{
return mlx5_hv_config_common(dev, buf, len, offset, false);
}
int mlx5_hv_register_invalidate(struct mlx5_core_dev *dev, void *context,
void (*block_invalidate)(void *context,
u64 block_mask))
{
return hyperv_reg_block_invalidate(dev->pdev, context,
block_invalidate);
}
void mlx5_hv_unregister_invalidate(struct mlx5_core_dev *dev)
{
hyperv_reg_block_invalidate(dev->pdev, NULL, NULL);
}
Annotation
- Immediate include surface: `linux/hyperv.h`, `mlx5_core.h`, `lib/hv.h`.
- Detected declarations: `function mlx5_hv_config_common`, `function mlx5_hv_read_config`, `function mlx5_hv_write_config`, `function mlx5_hv_register_invalidate`, `function mlx5_hv_unregister_invalidate`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.