Thread (46 messages) flat view 46 messages, 4 authors, 2016-07-12

Re: [PATCH 14/14] cxl: Add cxl_check_and_switch_mode() API to switch bi-modal cards

From: Andrew Donnellan <hidden>
Date: 2016-07-07 08:15:14

On 07/07/16 16:44, Andrew Donnellan wrote:
We can match the vendor, device ID *and* class code - unfortunately
there isn't a macro for this, which makes it a little bit less
aesthetically pleasing, but I'm pretty sure this works.
Something like the below, which works fine:

/*
  * Matches a given PCI vendor ID and device ID, but only for class 12
  * (processing accelerators). Useful for bi-modal cards, such as the
  * Mellanox ConnectX-4, which keep the same vendor/device ID
  * post-mode-switch.
  */
#define PCI_DEVICE_ACCEL(vend, dev) \
	.vendor = (vend), .device = (dev), \
	.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
	.class = 0x120000, .class_mask = 0xff0000

static const struct pci_device_id cxl_pci_tbl[] = {
	/* FPGA devices */
	{ PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0477), },
	{ PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x044b), },
	{ PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x04cf), },
	{ PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0601), },
	/* Mellanox ConnectX-4 */
	{ PCI_DEVICE_ACCEL(PCI_VENDOR_ID_MELLANOX, 0x1013), },
	{ }
};
MODULE_DEVICE_TABLE(pci, cxl_pci_tbl);


-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help