@@ -10,3 +10,4 @@ CFG_REG_MASK = 0x10
CFG_REG_RSH = 0x11
CFG_REG_LSH = 0x12
CFG_REG_ORD = 0x13
+CFG_IO_FAULT = 0x20
@@ -8,6 +8,7 @@
from .driver import Driver
from .mockup import Mockup
+from .consts import CFG_IO_FAULT
class DriverModel(object):
bus = None
@@ -89,3 +90,6 @@ class DriverModel(object):
def write_regs(self, addr, data):
self.mockup.write_regs(addr, data)
+
+ def trigger_io_fault(self, count = 1):
+ self.mockup.write_config(CFG_IO_FAULT, count)
@@ -18,6 +18,7 @@
#define BPF_CONF_REG_RSHIFT 0x11
#define BPF_CONF_REG_LSHIFT 0x12
#define BPF_CONF_REG_XBSWAP 0x13
+#define BPF_CONF_IO_FAULT 0x20
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
@@ -28,6 +29,7 @@ struct {
static u32 bpf_reg_mask, bpf_reg_xbswap;
static u32 bpf_reg_rshift, bpf_reg_lshift;
+static u32 bpf_io_fault;
static u32 bpf_xfer_read_conf(u32 key)
{
@@ -59,6 +61,7 @@ static int bpf_xfer_update_config(void)
bpf_reg_rshift = bpf_xfer_read_conf(BPF_CONF_REG_RSHIFT);
bpf_reg_lshift = bpf_xfer_read_conf(BPF_CONF_REG_LSHIFT);
bpf_reg_xbswap = bpf_xfer_read_conf(BPF_CONF_REG_XBSWAP);
+ bpf_io_fault = bpf_xfer_read_conf(BPF_CONF_IO_FAULT);
return 0;
}
@@ -108,4 +111,14 @@ u32 bpf_xfer_reg_u32(u32 reg)
reg = reg << bpf_reg_lshift;
return reg;
}
+
+bool bpf_xfer_should_fault(void)
+{
+ bpf_xfer_update_config();
+
+ if (bpf_io_fault)
+ bpf_xfer_write_conf(BPF_CONF_IO_FAULT, bpf_io_fault - 1);
+
+ return !!bpf_io_fault;
+}
#endif