| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 |
/* |
| 3 |
* Copyright(c) 2018 Intel Corporation. |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef _HFI1_FAULT_H |
| 7 |
#define _HFI1_FAULT_H |
| 8 |
|
| 9 |
#include <linux/fault-inject.h> |
| 10 |
#include <linux/dcache.h> |
| 11 |
#include <linux/bitops.h> |
| 12 |
#include <linux/kernel.h> |
| 13 |
#include <rdma/rdma_vt.h> |
| 14 |
|
| 15 |
#include "hfi.h" |
| 16 |
|
| 17 |
struct hfi1_ibdev; |
| 18 |
|
| 19 |
#if defined(CONFIG_FAULT_INJECTION) && defined(CONFIG_FAULT_INJECTION_DEBUG_FS) |
| 20 |
struct fault { |
| 21 |
struct fault_attr attr; |
| 22 |
struct dentry *dir; |
| 23 |
u64 n_rxfaults[(1U << BITS_PER_BYTE)]; |
| 24 |
u64 n_txfaults[(1U << BITS_PER_BYTE)]; |
| 25 |
u64 fault_skip; |
| 26 |
u64 skip; |
| 27 |
u64 fault_skip_usec; |
| 28 |
unsigned long skip_usec; |
| 29 |
unsigned long opcodes[(1U << BITS_PER_BYTE) / BITS_PER_LONG]; |
| 30 |
bool enable; |
| 31 |
bool suppress_err; |
| 32 |
bool opcode; |
| 33 |
u8 direction; |
| 34 |
}; |
| 35 |
|
| 36 |
int hfi1_fault_init_debugfs(struct hfi1_ibdev *ibd); |
| 37 |
bool hfi1_dbg_should_fault_tx(struct rvt_qp *qp, u32 opcode); |
| 38 |
bool hfi1_dbg_should_fault_rx(struct hfi1_packet *packet); |
| 39 |
bool hfi1_dbg_fault_suppress_err(struct hfi1_ibdev *ibd); |
| 40 |
void hfi1_fault_exit_debugfs(struct hfi1_ibdev *ibd); |
| 41 |
|
| 42 |
#else |
| 43 |
|
| 44 |
static inline int hfi1_fault_init_debugfs(struct hfi1_ibdev *ibd) |
| 45 |
{ |
| 46 |
return 0; |
| 47 |
} |
| 48 |
|
| 49 |
static inline bool hfi1_dbg_should_fault_rx(struct hfi1_packet *packet) |
| 50 |
{ |
| 51 |
return false; |
| 52 |
} |
| 53 |
|
| 54 |
static inline bool hfi1_dbg_should_fault_tx(struct rvt_qp *qp, |
| 55 |
u32 opcode) |
| 56 |
{ |
| 57 |
return false; |
| 58 |
} |
| 59 |
|
| 60 |
static inline bool hfi1_dbg_fault_suppress_err(struct hfi1_ibdev *ibd) |
| 61 |
{ |
| 62 |
return false; |
| 63 |
} |
| 64 |
|
| 65 |
static inline void hfi1_fault_exit_debugfs(struct hfi1_ibdev *ibd) |
| 66 |
{ |
| 67 |
} |
| 68 |
#endif |
| 69 |
#endif /* _HFI1_FAULT_H */ |