aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/endpoint/pci-epc-core.c30
-rw-r--r--include/linux/pci-epc.h22
2 files changed, 52 insertions, 0 deletions
diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index 094dcc3203b8..5a099479d9ab 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -84,6 +84,36 @@ err:
84EXPORT_SYMBOL_GPL(pci_epc_get); 84EXPORT_SYMBOL_GPL(pci_epc_get);
85 85
86/** 86/**
87 * pci_epc_get_features() - get the features supported by EPC
88 * @epc: the features supported by *this* EPC device will be returned
89 * @func_no: the features supported by the EPC device specific to the
90 * endpoint function with func_no will be returned
91 *
92 * Invoke to get the features provided by the EPC which may be
93 * specific to an endpoint function. Returns pci_epc_features on success
94 * and NULL for any failures.
95 */
96const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc,
97 u8 func_no)
98{
99 const struct pci_epc_features *epc_features;
100 unsigned long flags;
101
102 if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions)
103 return NULL;
104
105 if (!epc->ops->get_features)
106 return NULL;
107
108 spin_lock_irqsave(&epc->lock, flags);
109 epc_features = epc->ops->get_features(epc, func_no);
110 spin_unlock_irqrestore(&epc->lock, flags);
111
112 return epc_features;
113}
114EXPORT_SYMBOL_GPL(pci_epc_get_features);
115
116/**
87 * pci_epc_stop() - stop the PCI link 117 * pci_epc_stop() - stop the PCI link
88 * @epc: the link of the EPC device that has to be stopped 118 * @epc: the link of the EPC device that has to be stopped
89 * 119 *
diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
index 37dab8116901..79fbcf94e14d 100644
--- a/include/linux/pci-epc.h
+++ b/include/linux/pci-epc.h
@@ -59,6 +59,8 @@ struct pci_epc_ops {
59 enum pci_epc_irq_type type, u16 interrupt_num); 59 enum pci_epc_irq_type type, u16 interrupt_num);
60 int (*start)(struct pci_epc *epc); 60 int (*start)(struct pci_epc *epc);
61 void (*stop)(struct pci_epc *epc); 61 void (*stop)(struct pci_epc *epc);
62 const struct pci_epc_features* (*get_features)(struct pci_epc *epc,
63 u8 func_no);
62 struct module *owner; 64 struct module *owner;
63}; 65};
64 66
@@ -100,6 +102,24 @@ struct pci_epc {
100 unsigned int features; 102 unsigned int features;
101}; 103};
102 104
105/**
106 * struct pci_epc_features - features supported by a EPC device per function
107 * @linkup_notifier: indicate if the EPC device can notify EPF driver on link up
108 * @msi_capable: indicate if the endpoint function has MSI capability
109 * @msix_capable: indicate if the endpoint function has MSI-X capability
110 * @reserved_bar: bitmap to indicate reserved BAR unavailable to function driver
111 * @bar_fixed_64bit: bitmap to indicate fixed 64bit BARs
112 * @bar_fixed_size: Array specifying the size supported by each BAR
113 */
114struct pci_epc_features {
115 unsigned int linkup_notifier : 1;
116 unsigned int msi_capable : 1;
117 unsigned int msix_capable : 1;
118 u8 reserved_bar;
119 u8 bar_fixed_64bit;
120 u64 bar_fixed_size[BAR_5 + 1];
121};
122
103#define EPC_FEATURE_NO_LINKUP_NOTIFIER BIT(0) 123#define EPC_FEATURE_NO_LINKUP_NOTIFIER BIT(0)
104#define EPC_FEATURE_BAR_MASK (BIT(1) | BIT(2) | BIT(3)) 124#define EPC_FEATURE_BAR_MASK (BIT(1) | BIT(2) | BIT(3))
105#define EPC_FEATURE_MSIX_AVAILABLE BIT(4) 125#define EPC_FEATURE_MSIX_AVAILABLE BIT(4)
@@ -158,6 +178,8 @@ int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no,
158 enum pci_epc_irq_type type, u16 interrupt_num); 178 enum pci_epc_irq_type type, u16 interrupt_num);
159int pci_epc_start(struct pci_epc *epc); 179int pci_epc_start(struct pci_epc *epc);
160void pci_epc_stop(struct pci_epc *epc); 180void pci_epc_stop(struct pci_epc *epc);
181const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc,
182 u8 func_no);
161struct pci_epc *pci_epc_get(const char *epc_name); 183struct pci_epc *pci_epc_get(const char *epc_name);
162void pci_epc_put(struct pci_epc *epc); 184void pci_epc_put(struct pci_epc *epc);
163 185