diff options
Diffstat (limited to 'drivers/ntb/ntb_hw.h')
-rw-r--r-- | drivers/ntb/ntb_hw.h | 112 |
1 files changed, 91 insertions, 21 deletions
diff --git a/drivers/ntb/ntb_hw.h b/drivers/ntb/ntb_hw.h index 3a3038ca83e6..bbdb7edca10c 100644 --- a/drivers/ntb/ntb_hw.h +++ b/drivers/ntb/ntb_hw.h @@ -47,16 +47,36 @@ */ #define PCI_DEVICE_ID_INTEL_NTB_B2B_JSF 0x3725 -#define PCI_DEVICE_ID_INTEL_NTB_CLASSIC_JSF 0x3726 -#define PCI_DEVICE_ID_INTEL_NTB_RP_JSF 0x3727 -#define PCI_DEVICE_ID_INTEL_NTB_RP_SNB 0x3C08 +#define PCI_DEVICE_ID_INTEL_NTB_PS_JSF 0x3726 +#define PCI_DEVICE_ID_INTEL_NTB_SS_JSF 0x3727 #define PCI_DEVICE_ID_INTEL_NTB_B2B_SNB 0x3C0D -#define PCI_DEVICE_ID_INTEL_NTB_CLASSIC_SNB 0x3C0E -#define PCI_DEVICE_ID_INTEL_NTB_2ND_SNB 0x3C0F +#define PCI_DEVICE_ID_INTEL_NTB_PS_SNB 0x3C0E +#define PCI_DEVICE_ID_INTEL_NTB_SS_SNB 0x3C0F +#define PCI_DEVICE_ID_INTEL_NTB_B2B_IVT 0x0E0D +#define PCI_DEVICE_ID_INTEL_NTB_PS_IVT 0x0E0E +#define PCI_DEVICE_ID_INTEL_NTB_SS_IVT 0x0E0F +#define PCI_DEVICE_ID_INTEL_NTB_B2B_HSX 0x2F0D +#define PCI_DEVICE_ID_INTEL_NTB_PS_HSX 0x2F0E +#define PCI_DEVICE_ID_INTEL_NTB_SS_HSX 0x2F0F #define PCI_DEVICE_ID_INTEL_NTB_B2B_BWD 0x0C4E #define msix_table_size(control) ((control & PCI_MSIX_FLAGS_QSIZE)+1) +#ifndef readq +static inline u64 readq(void __iomem *addr) +{ + return readl(addr) | (((u64) readl(addr + 4)) << 32LL); +} +#endif + +#ifndef writeq +static inline void writeq(u64 val, void __iomem *addr) +{ + writel(val & 0xffffffff, addr); + writel(val >> 32, addr + 4); +} +#endif + #define NTB_BAR_MMIO 0 #define NTB_BAR_23 2 #define NTB_BAR_45 4 @@ -68,7 +88,7 @@ #define NTB_HB_TIMEOUT msecs_to_jiffies(1000) -#define NTB_NUM_MW 2 +#define NTB_MAX_NUM_MW 2 enum ntb_hw_event { NTB_EVENT_SW_EVENT0 = 0, @@ -86,28 +106,30 @@ struct ntb_mw { }; struct ntb_db_cb { - void (*callback) (void *data, int db_num); + int (*callback)(void *data, int db_num); unsigned int db_num; void *data; struct ntb_device *ndev; + struct tasklet_struct irq_work; }; struct ntb_device { struct pci_dev *pdev; struct msix_entry *msix_entries; void __iomem *reg_base; - struct ntb_mw mw[NTB_NUM_MW]; + struct ntb_mw mw[NTB_MAX_NUM_MW]; struct { - unsigned int max_spads; - unsigned int max_db_bits; - unsigned int msix_cnt; + unsigned char max_mw; + unsigned char max_spads; + unsigned char max_db_bits; + unsigned char msix_cnt; } limits; struct { - void __iomem *pdb; - void __iomem *pdb_mask; - void __iomem *sdb; - void __iomem *sbar2_xlat; - void __iomem *sbar4_xlat; + void __iomem *ldb; + void __iomem *ldb_mask; + void __iomem *rdb; + void __iomem *bar2_xlat; + void __iomem *bar4_xlat; void __iomem *spad_write; void __iomem *spad_read; void __iomem *lnk_cntl; @@ -124,12 +146,45 @@ struct ntb_device { unsigned char num_msix; unsigned char bits_per_vector; unsigned char max_cbs; + unsigned char link_width; + unsigned char link_speed; unsigned char link_status; + struct delayed_work hb_timer; unsigned long last_ts; + + struct delayed_work lr_timer; + + struct dentry *debugfs_dir; }; /** + * ntb_max_cbs() - return the max callbacks + * @ndev: pointer to ntb_device instance + * + * Given the ntb pointer, return the maximum number of callbacks + * + * RETURNS: the maximum number of callbacks + */ +static inline unsigned char ntb_max_cbs(struct ntb_device *ndev) +{ + return ndev->max_cbs; +} + +/** + * ntb_max_mw() - return the max number of memory windows + * @ndev: pointer to ntb_device instance + * + * Given the ntb pointer, return the maximum number of memory windows + * + * RETURNS: the maximum number of memory windows + */ +static inline unsigned char ntb_max_mw(struct ntb_device *ndev) +{ + return ndev->limits.max_mw; +} + +/** * ntb_hw_link_status() - return the hardware link status * @ndev: pointer to ntb_device instance * @@ -146,7 +201,7 @@ static inline bool ntb_hw_link_status(struct ntb_device *ndev) * ntb_query_pdev() - return the pci_dev pointer * @ndev: pointer to ntb_device instance * - * Given the ntb pointer return the pci_dev pointerfor the NTB hardware device + * Given the ntb pointer, return the pci_dev pointer for the NTB hardware device * * RETURNS: a pointer to the ntb pci_dev */ @@ -155,13 +210,27 @@ static inline struct pci_dev *ntb_query_pdev(struct ntb_device *ndev) return ndev->pdev; } +/** + * ntb_query_debugfs() - return the debugfs pointer + * @ndev: pointer to ntb_device instance + * + * Given the ntb pointer, return the debugfs directory pointer for the NTB + * hardware device + * + * RETURNS: a pointer to the debugfs directory + */ +static inline struct dentry *ntb_query_debugfs(struct ntb_device *ndev) +{ + return ndev->debugfs_dir; +} + struct ntb_device *ntb_register_transport(struct pci_dev *pdev, void *transport); void ntb_unregister_transport(struct ntb_device *ndev); void ntb_set_mw_addr(struct ntb_device *ndev, unsigned int mw, u64 addr); int ntb_register_db_callback(struct ntb_device *ndev, unsigned int idx, - void *data, void (*db_cb_func) (void *data, - int db_num)); + void *data, int (*db_cb_func)(void *data, + int db_num)); void ntb_unregister_db_callback(struct ntb_device *ndev, unsigned int idx); int ntb_register_event_callback(struct ntb_device *ndev, void (*event_cb_func) (void *handle, @@ -172,9 +241,10 @@ int ntb_write_local_spad(struct ntb_device *ndev, unsigned int idx, u32 val); int ntb_read_local_spad(struct ntb_device *ndev, unsigned int idx, u32 *val); int ntb_write_remote_spad(struct ntb_device *ndev, unsigned int idx, u32 val); int ntb_read_remote_spad(struct ntb_device *ndev, unsigned int idx, u32 *val); +resource_size_t ntb_get_mw_base(struct ntb_device *ndev, unsigned int mw); void __iomem *ntb_get_mw_vbase(struct ntb_device *ndev, unsigned int mw); -resource_size_t ntb_get_mw_size(struct ntb_device *ndev, unsigned int mw); -void ntb_ring_sdb(struct ntb_device *ndev, unsigned int idx); +u64 ntb_get_mw_size(struct ntb_device *ndev, unsigned int mw); +void ntb_ring_doorbell(struct ntb_device *ndev, unsigned int idx); void *ntb_find_transport(struct pci_dev *pdev); int ntb_transport_init(struct pci_dev *pdev); |