0001
0002
0003 #ifndef _OCXL_INTERNAL_H_
0004 #define _OCXL_INTERNAL_H_
0005
0006 #include <linux/pci.h>
0007 #include <linux/cdev.h>
0008 #include <linux/list.h>
0009 #include <misc/ocxl.h>
0010
0011 #define MAX_IRQ_PER_LINK 2000
0012 #define MAX_IRQ_PER_CONTEXT MAX_IRQ_PER_LINK
0013
0014 extern struct pci_driver ocxl_pci_driver;
0015
0016 struct ocxl_fn {
0017 struct device dev;
0018 int bar_used[3];
0019 struct ocxl_fn_config config;
0020 struct list_head afu_list;
0021 int pasid_base;
0022 int actag_base;
0023 int actag_enabled;
0024 int actag_supported;
0025 struct list_head pasid_list;
0026 struct list_head actag_list;
0027 void *link;
0028 };
0029
0030 struct ocxl_file_info {
0031 struct ocxl_afu *afu;
0032 struct device dev;
0033 struct cdev cdev;
0034 struct bin_attribute attr_global_mmio;
0035 };
0036
0037 struct ocxl_afu {
0038 struct kref kref;
0039 struct ocxl_fn *fn;
0040 struct list_head list;
0041 struct ocxl_afu_config config;
0042 int pasid_base;
0043 int pasid_count;
0044 int pasid_max;
0045 int actag_base;
0046 int actag_enabled;
0047 struct mutex contexts_lock;
0048 struct idr contexts_idr;
0049 struct mutex afu_control_lock;
0050 u64 global_mmio_start;
0051 u64 irq_base_offset;
0052 void __iomem *global_mmio_ptr;
0053 u64 pp_mmio_start;
0054 void *private;
0055 };
0056
0057 enum ocxl_context_status {
0058 CLOSED,
0059 OPENED,
0060 ATTACHED,
0061 };
0062
0063
0064 struct ocxl_xsl_error {
0065 u64 addr;
0066 u64 dsisr;
0067 u64 count;
0068 };
0069
0070 struct ocxl_context {
0071 struct ocxl_afu *afu;
0072 int pasid;
0073 struct mutex status_mutex;
0074 enum ocxl_context_status status;
0075 struct address_space *mapping;
0076 struct mutex mapping_lock;
0077 wait_queue_head_t events_wq;
0078 struct mutex xsl_error_lock;
0079 struct ocxl_xsl_error xsl_error;
0080 struct mutex irq_lock;
0081 struct idr irq_idr;
0082 u16 tidr;
0083 };
0084
0085 struct ocxl_process_element {
0086 __be64 config_state;
0087 __be32 pasid;
0088 __be16 bdf;
0089 __be16 reserved1;
0090 __be32 reserved2[9];
0091 __be32 lpid;
0092 __be32 tid;
0093 __be32 pid;
0094 __be32 reserved3[10];
0095 __be64 amr;
0096 __be32 reserved4[3];
0097 __be32 software_state;
0098 };
0099
0100 int ocxl_create_cdev(struct ocxl_afu *afu);
0101 void ocxl_destroy_cdev(struct ocxl_afu *afu);
0102 int ocxl_file_register_afu(struct ocxl_afu *afu);
0103 void ocxl_file_unregister_afu(struct ocxl_afu *afu);
0104
0105 int ocxl_file_init(void);
0106 void ocxl_file_exit(void);
0107
0108 int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
0109 void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
0110 int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
0111 void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
0112
0113
0114
0115
0116 int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
0117
0118
0119
0120
0121 int ocxl_config_get_reset_reload(struct pci_dev *dev, int *val);
0122 int ocxl_config_set_reset_reload(struct pci_dev *dev, int val);
0123
0124
0125
0126
0127
0128
0129
0130 int ocxl_config_check_afu_index(struct pci_dev *dev,
0131 struct ocxl_fn_config *fn, int afu_idx);
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
0142
0143 int ocxl_context_mmap(struct ocxl_context *ctx,
0144 struct vm_area_struct *vma);
0145 void ocxl_context_detach_all(struct ocxl_afu *afu);
0146
0147 int ocxl_sysfs_register_afu(struct ocxl_file_info *info);
0148 void ocxl_sysfs_unregister_afu(struct ocxl_file_info *info);
0149
0150 int ocxl_irq_offset_to_id(struct ocxl_context *ctx, u64 offset);
0151 u64 ocxl_irq_id_to_offset(struct ocxl_context *ctx, int irq_id);
0152 void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
0153
0154 #endif