summaryrefslogtreecommitdiffstats
path: root/include/misc
diff options
context:
space:
mode:
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>2016-07-13 17:17:14 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2016-07-14 06:28:11 -0400
commitb0b5e5918ad1babfd1d43d98c7281926a7b57b9f (patch)
tree02d0c2ac8790191db591c477b72e8612e456b7d8 /include/misc
parent5473a6bf635d35d5c1d12d0e132b51a861a5c973 (diff)
cxl: Add cxl_check_and_switch_mode() API to switch bi-modal cards
Add a new API, cxl_check_and_switch_mode() to allow for switching of bi-modal CAPI cards, such as the Mellanox CX-4 network card. When a driver requests to switch a card to CAPI mode, use PCI hotplug infrastructure to remove all PCI devices underneath the slot. We then write an updated mode control register to the CAPI VSEC, hot reset the card, and reprobe the card. As the card may present a different set of PCI devices after the mode switch, use the infrastructure provided by the pnv_php driver and the OPAL PCI slot management facilities to ensure that: * the old devices are removed from both the OPAL and Linux device trees * the new devices are probed by OPAL and added to the OPAL device tree * the new devices are added to the Linux device tree and probed through the regular PCI device probe path As such, introduce a new option, CONFIG_CXL_BIMODAL, with a dependency on the pnv_php driver. Refactor existing code that touches the mode control register in the regular single mode case into a new function, setup_cxl_protocol_area(). Co-authored-by: Ian Munsie <imunsie@au1.ibm.com> Cc: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'include/misc')
-rw-r--r--include/misc/cxl.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/misc/cxl.h b/include/misc/cxl.h
index 6c52cbcdfd79..480d50a0b8ba 100644
--- a/include/misc/cxl.h
+++ b/include/misc/cxl.h
@@ -39,6 +39,31 @@
39bool cxl_slot_is_supported(struct pci_dev *dev, int flags); 39bool cxl_slot_is_supported(struct pci_dev *dev, int flags);
40 40
41 41
42#define CXL_BIMODE_CXL 1
43#define CXL_BIMODE_PCI 2
44
45/*
46 * Check the mode that the given bi-modal CXL adapter is currently in and
47 * change it if necessary. This does not apply to AFU drivers.
48 *
49 * If the mode matches the requested mode this function will return 0 - if the
50 * driver was expecting the generic CXL driver to have bound to the adapter and
51 * it gets this return value it should fail the probe function to give the CXL
52 * driver a chance to probe it.
53 *
54 * If the mode does not match it will start a background task to unplug the
55 * device from Linux and switch its mode, and will return -EBUSY. At this
56 * point the calling driver should make sure it has released the device and
57 * fail its probe function.
58 *
59 * The offset of the CXL VSEC can be provided to this function. If 0 is passed,
60 * this function will search for a CXL VSEC with ID 0x1280 and return -ENODEV
61 * if it is not found.
62 */
63#ifdef CONFIG_CXL_BIMODAL
64int cxl_check_and_switch_mode(struct pci_dev *dev, int mode, int vsec);
65#endif
66
42/* Get the AFU associated with a pci_dev */ 67/* Get the AFU associated with a pci_dev */
43struct cxl_afu *cxl_pci_to_afu(struct pci_dev *dev); 68struct cxl_afu *cxl_pci_to_afu(struct pci_dev *dev);
44 69