pci.h (fd1a2f3dfc0e8fb20d0d397d586000bb918aab47) | pci.h (b15491b4773af99ce2470144ef6bcd9146cc9a98) |
---|---|
1/*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * Copyright (c) 2020-2022 The FreeBSD Foundation 8 * --- 319 unchanged lines hidden (view full) --- 328 uint8_t msi_cap; 329 uint8_t msix_cap; 330 bool managed; /* devres "pcim_*(). */ 331 bool want_iomap_res; 332 bool msi_enabled; 333 bool msix_enabled; 334 phys_addr_t rom; 335 size_t romlen; | 1/*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * Copyright (c) 2020-2022 The FreeBSD Foundation 8 * --- 319 unchanged lines hidden (view full) --- 328 uint8_t msi_cap; 329 uint8_t msix_cap; 330 bool managed; /* devres "pcim_*(). */ 331 bool want_iomap_res; 332 bool msi_enabled; 333 bool msix_enabled; 334 phys_addr_t rom; 335 size_t romlen; |
336 /* 337 * msi_desc should be an array one day? For as long as we only support 338 * 1 MSI vector this is fine. 339 */ 340 struct msi_desc *msi_desc; | 336 struct msi_desc **msi_desc; |
341 342 TAILQ_HEAD(, pci_mmio_region) mmio; 343}; 344 345/* We need some meta-struct to keep track of these for devres. */ 346struct pci_devres { 347 bool enable_io; 348 /* PCIR_MAX_BAR_0 + 1 = 6 => BIT(0..5). */ --- 535 unchanged lines hidden (view full) --- 884 } while (rc); 885 return (nvec); 886} 887 888#define pci_enable_msi(pdev) \ 889 linux_pci_enable_msi(pdev) 890 891static inline int | 337 338 TAILQ_HEAD(, pci_mmio_region) mmio; 339}; 340 341/* We need some meta-struct to keep track of these for devres. */ 342struct pci_devres { 343 bool enable_io; 344 /* PCIR_MAX_BAR_0 + 1 = 6 => BIT(0..5). */ --- 535 unchanged lines hidden (view full) --- 880 } while (rc); 881 return (nvec); 882} 883 884#define pci_enable_msi(pdev) \ 885 linux_pci_enable_msi(pdev) 886 887static inline int |
892pci_enable_msi(struct pci_dev *pdev) | 888_lkpi_pci_enable_msi_range(struct pci_dev *pdev, int minvec, int maxvec) |
893{ 894 struct resource_list_entry *rle; 895 int error; | 889{ 890 struct resource_list_entry *rle; 891 int error; |
896 int avail; | 892 int nvec; |
897 | 893 |
898 avail = pci_msi_count(pdev->dev.bsddev); 899 if (avail < 1) 900 return -EINVAL; | 894 if (maxvec < minvec) 895 return (-EINVAL); |
901 | 896 |
902 avail = 1; /* this function only enable one MSI IRQ */ 903 if ((error = -pci_alloc_msi(pdev->dev.bsddev, &avail)) != 0) | 897 nvec = pci_msi_count(pdev->dev.bsddev); 898 if (nvec < 1 || nvec < minvec) 899 return (-ENOSPC); 900 901 nvec = min(nvec, maxvec); 902 if ((error = -pci_alloc_msi(pdev->dev.bsddev, &nvec)) != 0) |
904 return error; 905 | 903 return error; 904 |
905 /* Native PCI might only ever ask for 32 vectors. */ 906 if (nvec < minvec) { 907 pci_release_msi(pdev->dev.bsddev); 908 return (-ENOSPC); 909 } 910 |
|
906 rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1, false); 907 pdev->dev.irq_start = rle->start; | 911 rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1, false); 912 pdev->dev.irq_start = rle->start; |
908 pdev->dev.irq_end = rle->start + avail; | 913 pdev->dev.irq_end = rle->start + nvec; |
909 pdev->irq = rle->start; 910 pdev->msi_enabled = true; 911 return (0); 912} 913 914static inline int | 914 pdev->irq = rle->start; 915 pdev->msi_enabled = true; 916 return (0); 917} 918 919static inline int |
920pci_enable_msi(struct pci_dev *pdev) 921{ 922 923 return (_lkpi_pci_enable_msi_range(pdev, 1, 1)); 924} 925 926static inline int |
|
915pci_channel_offline(struct pci_dev *pdev) 916{ 917 918 return (pci_read_config(pdev->dev.bsddev, PCIR_VENDOR, 2) == PCIV_INVALID); 919} 920 921static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) 922{ --- 683 unchanged lines hidden (view full) --- 1606 } 1607 1608 return (-EINVAL); 1609} 1610 1611/* 1612 * We cannot simply re-define pci_get_device() as we would normally do 1613 * and then hide it in linux_pci.c as too many semi-native drivers still | 927pci_channel_offline(struct pci_dev *pdev) 928{ 929 930 return (pci_read_config(pdev->dev.bsddev, PCIR_VENDOR, 2) == PCIV_INVALID); 931} 932 933static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) 934{ --- 683 unchanged lines hidden (view full) --- 1618 } 1619 1620 return (-EINVAL); 1621} 1622 1623/* 1624 * We cannot simply re-define pci_get_device() as we would normally do 1625 * and then hide it in linux_pci.c as too many semi-native drivers still |
1614 * inlucde linux/pci.h and run into the conflict with native PCI. Linux drivers | 1626 * include linux/pci.h and run into the conflict with native PCI. Linux drivers |
1615 * using pci_get_device() need to be changed to call linuxkpi_pci_get_device(). 1616 */ 1617static inline struct pci_dev * 1618linuxkpi_pci_get_device(uint16_t vendor, uint16_t device, struct pci_dev *odev) 1619{ 1620 1621 return (lkpi_pci_get_device(vendor, device, odev)); 1622} --- 91 unchanged lines hidden --- | 1627 * using pci_get_device() need to be changed to call linuxkpi_pci_get_device(). 1628 */ 1629static inline struct pci_dev * 1630linuxkpi_pci_get_device(uint16_t vendor, uint16_t device, struct pci_dev *odev) 1631{ 1632 1633 return (lkpi_pci_get_device(vendor, device, odev)); 1634} --- 91 unchanged lines hidden --- |