0001
0002
0003
0004
0005
0006 #ifndef _ASM_POWERPC_VAS_H
0007 #define _ASM_POWERPC_VAS_H
0008 #include <linux/sched/mm.h>
0009 #include <linux/mmu_context.h>
0010 #include <asm/icswx.h>
0011 #include <uapi/asm/vas-api.h>
0012
0013
0014
0015
0016
0017 #define VAS_RX_FIFO_SIZE_MIN (1 << 10)
0018 #define VAS_RX_FIFO_SIZE_MAX (8 << 20)
0019
0020
0021
0022
0023
0024
0025
0026
0027 #define VAS_THRESH_DISABLED 0
0028 #define VAS_THRESH_FIFO_GT_HALF_FULL 1
0029 #define VAS_THRESH_FIFO_GT_QTR_FULL 2
0030 #define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3
0031
0032
0033
0034
0035 #define VAS_WIN_ACTIVE 0x0
0036
0037
0038 #define VAS_WIN_NO_CRED_CLOSE 0x00000001
0039
0040 #define VAS_WIN_MIGRATE_CLOSE 0x00000002
0041
0042
0043
0044
0045 #define GET_FIELD(m, v) (((v) & (m)) >> MASK_LSH(m))
0046 #define MASK_LSH(m) (__builtin_ffsl(m) - 1)
0047 #define SET_FIELD(m, v, val) \
0048 (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_LSH(m)) & (m)))
0049
0050
0051
0052
0053 enum vas_cop_type {
0054 VAS_COP_TYPE_FAULT,
0055 VAS_COP_TYPE_842,
0056 VAS_COP_TYPE_842_HIPRI,
0057 VAS_COP_TYPE_GZIP,
0058 VAS_COP_TYPE_GZIP_HIPRI,
0059 VAS_COP_TYPE_FTW,
0060 VAS_COP_TYPE_MAX,
0061 };
0062
0063
0064
0065
0066
0067
0068 struct vas_user_win_ref {
0069 struct pid *pid;
0070 struct pid *tgid;
0071 struct mm_struct *mm;
0072 struct mutex mmap_mutex;
0073
0074 struct vm_area_struct *vma;
0075 };
0076
0077
0078
0079
0080 struct vas_window {
0081 u32 winid;
0082 u32 wcreds_max;
0083 u32 status;
0084 enum vas_cop_type cop;
0085 struct vas_user_win_ref task_ref;
0086 char *dbgname;
0087 struct dentry *dbgdir;
0088 };
0089
0090
0091
0092
0093 struct vas_user_win_ops {
0094 struct vas_window * (*open_win)(int vas_id, u64 flags,
0095 enum vas_cop_type);
0096 u64 (*paste_addr)(struct vas_window *);
0097 int (*close_win)(struct vas_window *);
0098 };
0099
0100 static inline void put_vas_user_win_ref(struct vas_user_win_ref *ref)
0101 {
0102
0103 put_pid(ref->pid);
0104 put_pid(ref->tgid);
0105 if (ref->mm)
0106 mmdrop(ref->mm);
0107 }
0108
0109 static inline void vas_user_win_add_mm_context(struct vas_user_win_ref *ref)
0110 {
0111 mm_context_add_vas_window(ref->mm);
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 asm volatile(PPC_CP_ABORT);
0123 }
0124
0125
0126
0127
0128 struct vas_rx_win_attr {
0129 u64 rx_fifo;
0130 int rx_fifo_size;
0131 int wcreds_max;
0132
0133 bool pin_win;
0134 bool rej_no_credit;
0135 bool tx_wcred_mode;
0136 bool rx_wcred_mode;
0137 bool tx_win_ord_mode;
0138 bool rx_win_ord_mode;
0139 bool data_stamp;
0140 bool nx_win;
0141 bool fault_win;
0142 bool user_win;
0143 bool notify_disable;
0144 bool intr_disable;
0145 bool notify_early;
0146
0147 int lnotify_lpid;
0148 int lnotify_pid;
0149 int lnotify_tid;
0150 u32 pswid;
0151
0152 int tc_mode;
0153 };
0154
0155
0156
0157
0158 struct vas_tx_win_attr {
0159 enum vas_cop_type cop;
0160 int wcreds_max;
0161 int lpid;
0162 int pidr;
0163 int pswid;
0164 int rsvd_txbuf_count;
0165 int tc_mode;
0166
0167 bool user_win;
0168 bool pin_win;
0169 bool rej_no_credit;
0170 bool rsvd_txbuf_enable;
0171 bool tx_wcred_mode;
0172 bool rx_wcred_mode;
0173 bool tx_win_ord_mode;
0174 bool rx_win_ord_mode;
0175 };
0176
0177 #ifdef CONFIG_PPC_POWERNV
0178
0179
0180
0181
0182
0183
0184
0185 int chip_to_vas_id(int chipid);
0186
0187
0188
0189
0190
0191 void vas_init_rx_win_attr(struct vas_rx_win_attr *rxattr, enum vas_cop_type cop);
0192
0193
0194
0195
0196
0197
0198
0199 struct vas_window *vas_rx_win_open(int vasid, enum vas_cop_type cop,
0200 struct vas_rx_win_attr *attr);
0201
0202
0203
0204
0205 extern void vas_init_tx_win_attr(struct vas_tx_win_attr *txattr,
0206 enum vas_cop_type cop);
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218 struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
0219 struct vas_tx_win_attr *attr);
0220
0221
0222
0223
0224
0225
0226 int vas_win_close(struct vas_window *win);
0227
0228
0229
0230
0231 int vas_copy_crb(void *crb, int offset);
0232
0233
0234
0235
0236
0237
0238 int vas_paste_crb(struct vas_window *win, int offset, bool re);
0239
0240 int vas_register_api_powernv(struct module *mod, enum vas_cop_type cop_type,
0241 const char *name);
0242 void vas_unregister_api_powernv(void);
0243 #endif
0244
0245 #ifdef CONFIG_PPC_PSERIES
0246
0247
0248 #define VAS_GZIP_QOS_FEAT 0x1
0249 #define VAS_GZIP_DEF_FEAT 0x2
0250 #define VAS_GZIP_QOS_FEAT_BIT PPC_BIT(VAS_GZIP_QOS_FEAT)
0251 #define VAS_GZIP_DEF_FEAT_BIT PPC_BIT(VAS_GZIP_DEF_FEAT)
0252
0253
0254 #define VAS_NX_GZIP_FEAT 0x1
0255 #define VAS_NX_GZIP_FEAT_BIT PPC_BIT(VAS_NX_GZIP_FEAT)
0256
0257
0258
0259
0260
0261 struct hv_vas_all_caps {
0262 __be64 descriptor;
0263 __be64 feat_type;
0264 } __packed __aligned(0x1000);
0265
0266 struct vas_all_caps {
0267 u64 descriptor;
0268 u64 feat_type;
0269 };
0270
0271 int h_query_vas_capabilities(const u64 hcall, u8 query_type, u64 result);
0272 int vas_register_api_pseries(struct module *mod,
0273 enum vas_cop_type cop_type, const char *name);
0274 void vas_unregister_api_pseries(void);
0275 #endif
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285 int vas_register_coproc_api(struct module *mod, enum vas_cop_type cop_type,
0286 const char *name,
0287 const struct vas_user_win_ops *vops);
0288 void vas_unregister_coproc_api(void);
0289
0290 int get_vas_user_win_ref(struct vas_user_win_ref *task_ref);
0291 void vas_update_csb(struct coprocessor_request_block *crb,
0292 struct vas_user_win_ref *task_ref);
0293 void vas_dump_crb(struct coprocessor_request_block *crb);
0294 #endif