| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* Copyright (c) Microsoft Corporation. |
| 4 |
* |
| 5 |
* Author: |
| 6 |
* Haiyang Zhang <[email protected]> |
| 7 |
* |
| 8 |
* This small module is a helper driver allows other drivers to |
| 9 |
* have a common interface with the Hyper-V PCI frontend driver. |
| 10 |
*/ |
| 11 |
|
| 12 |
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 13 |
|
| 14 |
#include <linux/kernel.h> |
| 15 |
#include <linux/module.h> |
| 16 |
#include <linux/hyperv.h> |
| 17 |
#include <linux/export.h> |
| 18 |
|
| 19 |
struct hyperv_pci_block_ops hvpci_block_ops; |
| 20 |
EXPORT_SYMBOL_GPL(hvpci_block_ops); |
| 21 |
|
| 22 |
int hyperv_read_cfg_blk(struct pci_dev *dev, void *buf, unsigned int buf_len, |
| 23 |
unsigned int block_id, unsigned int *bytes_returned) |
| 24 |
{ |
| 25 |
if (!hvpci_block_ops.read_block) |
| 26 |
return -EOPNOTSUPP; |
| 27 |
|
| 28 |
return hvpci_block_ops.read_block(dev, buf, buf_len, block_id, |
| 29 |
bytes_returned); |
| 30 |
} |
| 31 |
EXPORT_SYMBOL_GPL(hyperv_read_cfg_blk); |
| 32 |
|
| 33 |
int hyperv_write_cfg_blk(struct pci_dev *dev, void *buf, unsigned int len, |
| 34 |
unsigned int block_id) |
| 35 |
{ |
| 36 |
if (!hvpci_block_ops.write_block) |
| 37 |
return -EOPNOTSUPP; |
| 38 |
|
| 39 |
return hvpci_block_ops.write_block(dev, buf, len, block_id); |
| 40 |
} |
| 41 |
EXPORT_SYMBOL_GPL(hyperv_write_cfg_blk); |
| 42 |
|
| 43 |
int hyperv_reg_block_invalidate(struct pci_dev *dev, void *context, |
| 44 |
void (*block_invalidate)(void *context, |
| 45 |
u64 block_mask)) |
| 46 |
{ |
| 47 |
if (!hvpci_block_ops.reg_blk_invalidate) |
| 48 |
return -EOPNOTSUPP; |
| 49 |
|
| 50 |
return hvpci_block_ops.reg_blk_invalidate(dev, context, |
| 51 |
block_invalidate); |
| 52 |
} |
| 53 |
EXPORT_SYMBOL_GPL(hyperv_reg_block_invalidate); |
| 54 |
|
| 55 |
MODULE_DESCRIPTION("Hyper-V PCI Interface"); |
| 56 |
MODULE_LICENSE("GPL v2"); |