| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ |
| 2 |
/* Copyright (c) 2019 Mellanox Technologies. */ |
| 3 |
|
| 4 |
#ifndef __LIB_HV_VHCA_H__ |
| 5 |
#define __LIB_HV_VHCA_H__ |
| 6 |
|
| 7 |
#include "en.h" |
| 8 |
#include "lib/hv.h" |
| 9 |
|
| 10 |
struct mlx5_hv_vhca_agent; |
| 11 |
struct mlx5_hv_vhca; |
| 12 |
struct mlx5_hv_vhca_control_block; |
| 13 |
|
| 14 |
enum mlx5_hv_vhca_agent_type { |
| 15 |
MLX5_HV_VHCA_AGENT_CONTROL = 0, |
| 16 |
MLX5_HV_VHCA_AGENT_STATS = 1, |
| 17 |
MLX5_HV_VHCA_AGENT_MAX = 32, |
| 18 |
}; |
| 19 |
|
| 20 |
#if IS_ENABLED(CONFIG_PCI_HYPERV_INTERFACE) |
| 21 |
|
| 22 |
struct mlx5_hv_vhca_control_block { |
| 23 |
u32 capabilities; |
| 24 |
u32 control; |
| 25 |
u16 command; |
| 26 |
u16 command_ack; |
| 27 |
u16 version; |
| 28 |
u16 rings; |
| 29 |
u32 reserved1[28]; |
| 30 |
}; |
| 31 |
|
| 32 |
struct mlx5_hv_vhca *mlx5_hv_vhca_create(struct mlx5_core_dev *dev); |
| 33 |
void mlx5_hv_vhca_destroy(struct mlx5_hv_vhca *hv_vhca); |
| 34 |
int mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca); |
| 35 |
void mlx5_hv_vhca_cleanup(struct mlx5_hv_vhca *hv_vhca); |
| 36 |
void mlx5_hv_vhca_invalidate(void *context, u64 block_mask); |
| 37 |
|
| 38 |
struct mlx5_hv_vhca_agent * |
| 39 |
mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca, |
| 40 |
enum mlx5_hv_vhca_agent_type type, |
| 41 |
void (*control)(struct mlx5_hv_vhca_agent*, |
| 42 |
struct mlx5_hv_vhca_control_block *block), |
| 43 |
void (*invalidate)(struct mlx5_hv_vhca_agent*, |
| 44 |
u64 block_mask), |
| 45 |
void (*cleanup)(struct mlx5_hv_vhca_agent *agent), |
| 46 |
void *context); |
| 47 |
|
| 48 |
void mlx5_hv_vhca_agent_destroy(struct mlx5_hv_vhca_agent *agent); |
| 49 |
int mlx5_hv_vhca_agent_write(struct mlx5_hv_vhca_agent *agent, |
| 50 |
void *buf, int len); |
| 51 |
void *mlx5_hv_vhca_agent_priv(struct mlx5_hv_vhca_agent *agent); |
| 52 |
|
| 53 |
#else |
| 54 |
|
| 55 |
static inline struct mlx5_hv_vhca * |
| 56 |
mlx5_hv_vhca_create(struct mlx5_core_dev *dev) |
| 57 |
{ |
| 58 |
return NULL; |
| 59 |
} |
| 60 |
|
| 61 |
static inline void mlx5_hv_vhca_destroy(struct mlx5_hv_vhca *hv_vhca) |
| 62 |
{ |
| 63 |
} |
| 64 |
|
| 65 |
static inline int mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca) |
| 66 |
{ |
| 67 |
return 0; |
| 68 |
} |
| 69 |
|
| 70 |
static inline void mlx5_hv_vhca_cleanup(struct mlx5_hv_vhca *hv_vhca) |
| 71 |
{ |
| 72 |
} |
| 73 |
|
| 74 |
static inline void mlx5_hv_vhca_invalidate(void *context, |
| 75 |
u64 block_mask) |
| 76 |
{ |
| 77 |
} |
| 78 |
|
| 79 |
static inline struct mlx5_hv_vhca_agent * |
| 80 |
mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca, |
| 81 |
enum mlx5_hv_vhca_agent_type type, |
| 82 |
void (*control)(struct mlx5_hv_vhca_agent*, |
| 83 |
struct mlx5_hv_vhca_control_block *block), |
| 84 |
void (*invalidate)(struct mlx5_hv_vhca_agent*, |
| 85 |
u64 block_mask), |
| 86 |
void (*cleanup)(struct mlx5_hv_vhca_agent *agent), |
| 87 |
void *context) |
| 88 |
{ |
| 89 |
return NULL; |
| 90 |
} |
| 91 |
|
| 92 |
static inline void mlx5_hv_vhca_agent_destroy(struct mlx5_hv_vhca_agent *agent) |
| 93 |
{ |
| 94 |
} |
| 95 |
#endif |
| 96 |
|
| 97 |
#endif /* __LIB_HV_VHCA_H__ */ |