2 * Copyright IBM Corp. 2012
5 * Jan Glauber <jang@linux.vnet.ibm.com>
8 #define COMPONENT "zPCI"
9 #define pr_fmt(fmt) COMPONENT ": " fmt
11 #include <linux/kernel.h>
12 #include <linux/pci.h>
14 /* Content Code Description for PCI Function Error */
15 struct zpci_ccdf_err
{
17 u32 fh
; /* function handle */
18 u32 fid
; /* function id */
19 u32 ett
: 4; /* expected table type */
20 u32 mvn
: 12; /* MSI vector number */
21 u32 dmaas
: 8; /* DMA address space */
23 u32 q
: 1; /* event qualifier */
24 u32 rw
: 1; /* read/write */
25 u64 faddr
; /* failing address */
28 u16 pec
; /* PCI event code */
31 /* Content Code Description for PCI Function Availability */
32 struct zpci_ccdf_avail
{
34 u32 fh
; /* function handle */
35 u32 fid
; /* function id */
41 u16 pec
; /* PCI event code */
44 static void zpci_event_log_err(struct zpci_ccdf_err
*ccdf
)
46 struct zpci_dev
*zdev
= get_zdev_by_fid(ccdf
->fid
);
48 zpci_err("SEI error CCD:\n");
49 zpci_err_hex(ccdf
, sizeof(*ccdf
));
50 dev_err(&zdev
->pdev
->dev
, "event code: 0x%x\n", ccdf
->pec
);
53 static void zpci_event_log_avail(struct zpci_ccdf_avail
*ccdf
)
55 struct zpci_dev
*zdev
= get_zdev_by_fid(ccdf
->fid
);
57 pr_err("%s%s: availability event: fh: 0x%x fid: 0x%x event code: 0x%x reason:",
58 (zdev
) ? dev_driver_string(&zdev
->pdev
->dev
) : "?",
59 (zdev
) ? dev_name(&zdev
->pdev
->dev
) : "?",
60 ccdf
->fh
, ccdf
->fid
, ccdf
->pec
);
61 print_hex_dump(KERN_CONT
, "ccdf", DUMP_PREFIX_OFFSET
,
62 16, 1, ccdf
, sizeof(*ccdf
), false);
66 zpci_enable_device(zdev
);
69 clp_add_pci_device(ccdf
->fid
, ccdf
->fh
, 0);
72 clp_rescan_pci_devices();
79 void zpci_event_error(void *data
)
81 struct zpci_ccdf_err
*ccdf
= data
;
82 struct zpci_dev
*zdev
;
84 zpci_event_log_err(ccdf
);
85 zdev
= get_zdev_by_fid(ccdf
->fid
);
87 pr_err("Error event for unknown fid: %x", ccdf
->fid
);
92 void zpci_event_availability(void *data
)
94 zpci_event_log_avail(data
);