2005-04-17 05:20:36 +07:00
|
|
|
#ifndef __ASM_S390_PCI_H
|
|
|
|
#define __ASM_S390_PCI_H
|
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
/* must be set before including asm-generic/pci.h */
|
2005-04-17 05:20:36 +07:00
|
|
|
#define PCI_DMA_BUS_IS_PHYS (0)
|
2012-11-29 18:50:30 +07:00
|
|
|
/* must be set before including pci_clp.h */
|
|
|
|
#define PCI_BAR_COUNT 6
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-08-30 00:40:01 +07:00
|
|
|
#include <linux/pci.h>
|
2015-04-10 19:34:33 +07:00
|
|
|
#include <linux/mutex.h>
|
2012-11-29 18:50:30 +07:00
|
|
|
#include <asm-generic/pci.h>
|
2012-11-29 18:55:21 +07:00
|
|
|
#include <asm/pci_clp.h>
|
2012-12-11 20:53:35 +07:00
|
|
|
#include <asm/pci_debug.h>
|
2016-07-18 19:05:21 +07:00
|
|
|
#include <asm/sclp.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
#define PCIBIOS_MIN_IO 0x1000
|
|
|
|
#define PCIBIOS_MIN_MEM 0x10000000
|
|
|
|
|
|
|
|
#define pcibios_assign_all_busses() (0)
|
|
|
|
|
|
|
|
void __iomem *pci_iomap(struct pci_dev *, int, unsigned long);
|
|
|
|
void pci_iounmap(struct pci_dev *, void __iomem *);
|
|
|
|
int pci_domain_nr(struct pci_bus *);
|
|
|
|
int pci_proc_domain(struct pci_bus *);
|
|
|
|
|
|
|
|
#define ZPCI_BUS_NR 0 /* default bus number */
|
|
|
|
#define ZPCI_DEVFN 0 /* default device number */
|
|
|
|
|
|
|
|
/* PCI Function Controls */
|
|
|
|
#define ZPCI_FC_FN_ENABLED 0x80
|
|
|
|
#define ZPCI_FC_ERROR 0x40
|
|
|
|
#define ZPCI_FC_BLOCKED 0x20
|
|
|
|
#define ZPCI_FC_DMA_ENABLED 0x10
|
|
|
|
|
2015-06-29 23:47:28 +07:00
|
|
|
#define ZPCI_FMB_DMA_COUNTER_VALID (1 << 23)
|
|
|
|
|
|
|
|
struct zpci_fmb_fmt0 {
|
|
|
|
u64 dma_rbytes;
|
|
|
|
u64 dma_wbytes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct zpci_fmb_fmt1 {
|
|
|
|
u64 rx_bytes;
|
|
|
|
u64 rx_packets;
|
|
|
|
u64 tx_bytes;
|
|
|
|
u64 tx_packets;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct zpci_fmb_fmt2 {
|
|
|
|
u64 consumed_work_units;
|
|
|
|
u64 max_work_units;
|
|
|
|
};
|
|
|
|
|
2012-12-11 20:53:35 +07:00
|
|
|
struct zpci_fmb {
|
2015-06-29 23:47:28 +07:00
|
|
|
u32 format : 8;
|
|
|
|
u32 fmt_ind : 24;
|
2012-12-11 20:53:35 +07:00
|
|
|
u32 samples;
|
|
|
|
u64 last_update;
|
2015-06-29 23:47:28 +07:00
|
|
|
/* common counters */
|
2012-12-11 20:53:35 +07:00
|
|
|
u64 ld_ops;
|
|
|
|
u64 st_ops;
|
|
|
|
u64 stb_ops;
|
|
|
|
u64 rpcit_ops;
|
2015-06-29 23:47:28 +07:00
|
|
|
/* format specific counters */
|
|
|
|
union {
|
|
|
|
struct zpci_fmb_fmt0 fmt0;
|
|
|
|
struct zpci_fmb_fmt1 fmt1;
|
|
|
|
struct zpci_fmb_fmt2 fmt2;
|
|
|
|
};
|
2016-03-31 16:48:31 +07:00
|
|
|
} __packed __aligned(128);
|
2012-12-11 20:53:35 +07:00
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
enum zpci_state {
|
|
|
|
ZPCI_FN_STATE_RESERVED,
|
|
|
|
ZPCI_FN_STATE_STANDBY,
|
|
|
|
ZPCI_FN_STATE_CONFIGURED,
|
|
|
|
ZPCI_FN_STATE_ONLINE,
|
|
|
|
NR_ZPCI_FN_STATES,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct zpci_bar_struct {
|
2013-11-13 01:33:06 +07:00
|
|
|
struct resource *res; /* bus resource */
|
2012-11-29 18:50:30 +07:00
|
|
|
u32 val; /* bar start & 3 flag bits */
|
|
|
|
u16 map_idx; /* index into bar mapping array */
|
2013-11-13 01:33:06 +07:00
|
|
|
u8 size; /* order 2 exponent */
|
2012-11-29 18:50:30 +07:00
|
|
|
};
|
|
|
|
|
2015-08-27 20:33:03 +07:00
|
|
|
struct s390_domain;
|
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
/* Private data per function */
|
|
|
|
struct zpci_dev {
|
|
|
|
struct pci_bus *bus;
|
|
|
|
struct list_head entry; /* list of all zpci_devices, needed for hotplug, etc. */
|
|
|
|
|
|
|
|
enum zpci_state state;
|
|
|
|
u32 fid; /* function ID, used by sclp */
|
|
|
|
u32 fh; /* function handle, used by insn's */
|
2014-04-16 21:12:05 +07:00
|
|
|
u16 vfn; /* virtual function number */
|
2012-11-29 18:50:30 +07:00
|
|
|
u16 pchid; /* physical channel ID */
|
|
|
|
u8 pfgid; /* function group ID */
|
2014-04-16 21:12:05 +07:00
|
|
|
u8 pft; /* pci function type */
|
2012-11-29 18:50:30 +07:00
|
|
|
u16 domain;
|
|
|
|
|
2015-04-10 19:34:33 +07:00
|
|
|
struct mutex lock;
|
2014-04-16 21:12:05 +07:00
|
|
|
u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */
|
|
|
|
u32 uid; /* user defined id */
|
|
|
|
u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */
|
|
|
|
|
2012-11-29 19:05:05 +07:00
|
|
|
/* IRQ stuff */
|
|
|
|
u64 msi_addr; /* MSI address */
|
2014-10-30 01:12:04 +07:00
|
|
|
unsigned int max_msi; /* maximum number of MSI's */
|
2013-06-25 21:36:29 +07:00
|
|
|
struct airq_iv *aibv; /* adapter interrupt bit vector */
|
2012-11-29 19:05:05 +07:00
|
|
|
unsigned int aisb; /* number of the summary bit */
|
|
|
|
|
2012-11-29 20:33:30 +07:00
|
|
|
/* DMA stuff */
|
|
|
|
unsigned long *dma_table;
|
|
|
|
spinlock_t dma_table_lock;
|
|
|
|
int tlb_refresh;
|
|
|
|
|
|
|
|
spinlock_t iommu_bitmap_lock;
|
|
|
|
unsigned long *iommu_bitmap;
|
2016-09-08 18:25:01 +07:00
|
|
|
unsigned long *lazy_bitmap;
|
2012-11-29 20:33:30 +07:00
|
|
|
unsigned long iommu_size;
|
|
|
|
unsigned long iommu_pages;
|
|
|
|
unsigned int next_bit;
|
|
|
|
|
2013-11-13 01:33:06 +07:00
|
|
|
char res_name[16];
|
2012-11-29 18:50:30 +07:00
|
|
|
struct zpci_bar_struct bars[PCI_BAR_COUNT];
|
|
|
|
|
2012-11-29 20:33:30 +07:00
|
|
|
u64 start_dma; /* Start of available DMA addresses */
|
|
|
|
u64 end_dma; /* End of available DMA addresses */
|
|
|
|
u64 dma_mask; /* DMA address space mask */
|
|
|
|
|
2012-12-11 20:53:35 +07:00
|
|
|
/* Function measurement block */
|
|
|
|
struct zpci_fmb *fmb;
|
|
|
|
u16 fmb_update; /* update interval */
|
2015-04-10 19:33:08 +07:00
|
|
|
/* software counters */
|
|
|
|
atomic64_t allocated_pages;
|
|
|
|
atomic64_t mapped_pages;
|
|
|
|
atomic64_t unmapped_pages;
|
2012-12-11 20:53:35 +07:00
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
enum pci_bus_speed max_bus_speed;
|
2012-12-11 20:53:35 +07:00
|
|
|
|
|
|
|
struct dentry *debugfs_dev;
|
|
|
|
struct dentry *debugfs_perf;
|
2015-08-27 20:33:03 +07:00
|
|
|
|
|
|
|
struct s390_domain *s390_domain; /* s390 IOMMU domain data */
|
2012-11-29 18:50:30 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool zdev_enabled(struct zpci_dev *zdev)
|
|
|
|
{
|
|
|
|
return (zdev->fh & (1UL << 31)) ? true : false;
|
|
|
|
}
|
|
|
|
|
2014-04-16 21:11:00 +07:00
|
|
|
extern const struct attribute_group *zpci_attr_groups[];
|
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
Prototypes
|
|
|
|
----------------------------------------------------------------------------- */
|
|
|
|
/* Base stuff */
|
|
|
|
int zpci_create_device(struct zpci_dev *);
|
|
|
|
int zpci_enable_device(struct zpci_dev *);
|
2013-04-16 19:12:17 +07:00
|
|
|
int zpci_disable_device(struct zpci_dev *);
|
2012-11-29 18:50:30 +07:00
|
|
|
void zpci_stop_device(struct zpci_dev *);
|
2012-11-29 20:33:30 +07:00
|
|
|
int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
|
|
|
|
int zpci_unregister_ioat(struct zpci_dev *, u8);
|
2012-11-29 18:50:30 +07:00
|
|
|
|
2012-11-29 18:55:21 +07:00
|
|
|
/* CLP */
|
2013-08-30 00:37:28 +07:00
|
|
|
int clp_scan_pci_devices(void);
|
|
|
|
int clp_rescan_pci_devices(void);
|
2013-08-30 00:40:01 +07:00
|
|
|
int clp_rescan_pci_devices_simple(void);
|
2012-11-29 18:55:21 +07:00
|
|
|
int clp_add_pci_device(u32, u32, int);
|
|
|
|
int clp_enable_fh(struct zpci_dev *, u8);
|
|
|
|
int clp_disable_fh(struct zpci_dev *);
|
|
|
|
|
2013-01-16 01:04:39 +07:00
|
|
|
#ifdef CONFIG_PCI
|
2012-11-29 20:34:48 +07:00
|
|
|
/* Error handling and recovery */
|
|
|
|
void zpci_event_error(void *);
|
|
|
|
void zpci_event_availability(void *);
|
2013-08-30 00:40:01 +07:00
|
|
|
void zpci_rescan(void);
|
2013-12-12 23:48:32 +07:00
|
|
|
bool zpci_is_enabled(void);
|
2013-01-16 01:04:39 +07:00
|
|
|
#else /* CONFIG_PCI */
|
|
|
|
static inline void zpci_event_error(void *e) {}
|
|
|
|
static inline void zpci_event_availability(void *e) {}
|
2013-08-30 00:40:01 +07:00
|
|
|
static inline void zpci_rescan(void) {}
|
2013-01-16 01:04:39 +07:00
|
|
|
#endif /* CONFIG_PCI */
|
2012-11-29 20:34:48 +07:00
|
|
|
|
2013-08-30 00:33:16 +07:00
|
|
|
#ifdef CONFIG_HOTPLUG_PCI_S390
|
|
|
|
int zpci_init_slot(struct zpci_dev *);
|
|
|
|
void zpci_exit_slot(struct zpci_dev *);
|
|
|
|
#else /* CONFIG_HOTPLUG_PCI_S390 */
|
|
|
|
static inline int zpci_init_slot(struct zpci_dev *zdev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void zpci_exit_slot(struct zpci_dev *zdev) {}
|
|
|
|
#endif /* CONFIG_HOTPLUG_PCI_S390 */
|
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
/* Helpers */
|
2015-06-23 19:06:35 +07:00
|
|
|
static inline struct zpci_dev *to_zpci(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
return pdev->sysdata;
|
|
|
|
}
|
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
struct zpci_dev *get_zdev_by_fid(u32);
|
|
|
|
|
2012-11-29 20:33:30 +07:00
|
|
|
/* DMA */
|
|
|
|
int zpci_dma_init(void);
|
|
|
|
void zpci_dma_exit(void);
|
|
|
|
|
2012-12-11 20:53:35 +07:00
|
|
|
/* FMB */
|
|
|
|
int zpci_fmb_enable_device(struct zpci_dev *);
|
|
|
|
int zpci_fmb_disable_device(struct zpci_dev *);
|
|
|
|
|
|
|
|
/* Debug */
|
|
|
|
int zpci_debug_init(void);
|
|
|
|
void zpci_debug_exit(void);
|
2016-01-29 21:13:30 +07:00
|
|
|
void zpci_debug_init_device(struct zpci_dev *, const char *);
|
2012-12-11 20:53:35 +07:00
|
|
|
void zpci_debug_exit_device(struct zpci_dev *);
|
|
|
|
void zpci_debug_info(struct zpci_dev *, struct seq_file *);
|
|
|
|
|
2016-07-18 19:05:21 +07:00
|
|
|
/* Error reporting */
|
|
|
|
int zpci_report_error(struct pci_dev *, struct zpci_report_error_header *);
|
|
|
|
|
2014-03-07 00:25:13 +07:00
|
|
|
#ifdef CONFIG_NUMA
|
|
|
|
|
|
|
|
/* Returns the node based on PCI bus */
|
|
|
|
static inline int __pcibus_to_node(const struct pci_bus *bus)
|
|
|
|
{
|
|
|
|
return NUMA_NO_NODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const struct cpumask *
|
|
|
|
cpumask_of_pcibus(const struct pci_bus *bus)
|
|
|
|
{
|
|
|
|
return cpu_online_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_NUMA */
|
|
|
|
|
2012-11-29 18:50:30 +07:00
|
|
|
#endif
|