]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/powerpc/include/asm/vas.h
044748f547f5920a222081f0dda0f6592d35f14b
[mirror_ubuntu-bionic-kernel.git] / arch / powerpc / include / asm / vas.h
1 /*
2 * Copyright 2016-17 IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10 #ifndef _ASM_POWERPC_VAS_H
11 #define _ASM_POWERPC_VAS_H
12
13 /*
14 * Min and max FIFO sizes are based on Version 1.05 Section 3.1.4.25
15 * (Local FIFO Size Register) of the VAS workbook.
16 */
17 #define VAS_RX_FIFO_SIZE_MIN (1 << 10) /* 1KB */
18 #define VAS_RX_FIFO_SIZE_MAX (8 << 20) /* 8MB */
19
20 /*
21 * Threshold Control Mode: Have paste operation fail if the number of
22 * requests in receive FIFO exceeds a threshold.
23 *
24 * NOTE: No special error code yet if paste is rejected because of these
25 * limits. So users can't distinguish between this and other errors.
26 */
27 #define VAS_THRESH_DISABLED 0
28 #define VAS_THRESH_FIFO_GT_HALF_FULL 1
29 #define VAS_THRESH_FIFO_GT_QTR_FULL 2
30 #define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3
31
32 /*
33 * Get/Set bit fields
34 */
35 #define GET_FIELD(m, v) (((v) & (m)) >> MASK_LSH(m))
36 #define MASK_LSH(m) (__builtin_ffsl(m) - 1)
37 #define SET_FIELD(m, v, val) \
38 (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_LSH(m)) & (m)))
39
40 /*
41 * Co-processor Engine type.
42 */
43 enum vas_cop_type {
44 VAS_COP_TYPE_FAULT,
45 VAS_COP_TYPE_842,
46 VAS_COP_TYPE_842_HIPRI,
47 VAS_COP_TYPE_GZIP,
48 VAS_COP_TYPE_GZIP_HIPRI,
49 VAS_COP_TYPE_FTW,
50 VAS_COP_TYPE_MAX,
51 };
52
53 /*
54 * Receive window attributes specified by the (in-kernel) owner of window.
55 */
56 struct vas_rx_win_attr {
57 void *rx_fifo;
58 int rx_fifo_size;
59 int wcreds_max;
60
61 bool pin_win;
62 bool rej_no_credit;
63 bool tx_wcred_mode;
64 bool rx_wcred_mode;
65 bool tx_win_ord_mode;
66 bool rx_win_ord_mode;
67 bool data_stamp;
68 bool nx_win;
69 bool fault_win;
70 bool user_win;
71 bool notify_disable;
72 bool intr_disable;
73 bool notify_early;
74
75 int lnotify_lpid;
76 int lnotify_pid;
77 int lnotify_tid;
78 u32 pswid;
79
80 int tc_mode;
81 };
82
83 /*
84 * Window attributes specified by the in-kernel owner of a send window.
85 */
86 struct vas_tx_win_attr {
87 enum vas_cop_type cop;
88 int wcreds_max;
89 int lpid;
90 int pidr; /* hardware PID (from SPRN_PID) */
91 int pid; /* linux process id */
92 int pswid;
93 int rsvd_txbuf_count;
94 int tc_mode;
95
96 bool user_win;
97 bool pin_win;
98 bool rej_no_credit;
99 bool rsvd_txbuf_enable;
100 bool tx_wcred_mode;
101 bool rx_wcred_mode;
102 bool tx_win_ord_mode;
103 bool rx_win_ord_mode;
104 };
105
106 /*
107 * Helper to map a chip id to VAS id.
108 * For POWER9, this is a 1:1 mapping. In the future this maybe a 1:N
109 * mapping in which case, we will need to update this helper.
110 *
111 * Return the VAS id or -1 if no matching vasid is found.
112 */
113 int chip_to_vas_id(int chipid);
114
115 /*
116 * Helper to initialize receive window attributes to defaults for an
117 * NX window.
118 */
119 void vas_init_rx_win_attr(struct vas_rx_win_attr *rxattr, enum vas_cop_type cop);
120
121 /*
122 * Open a VAS receive window for the instance of VAS identified by @vasid
123 * Use @attr to initialize the attributes of the window.
124 *
125 * Return a handle to the window or ERR_PTR() on error.
126 */
127 struct vas_window *vas_rx_win_open(int vasid, enum vas_cop_type cop,
128 struct vas_rx_win_attr *attr);
129
130 /*
131 * Helper to initialize send window attributes to defaults for an NX window.
132 */
133 extern void vas_init_tx_win_attr(struct vas_tx_win_attr *txattr,
134 enum vas_cop_type cop);
135
136 /*
137 * Open a VAS send window for the instance of VAS identified by @vasid
138 * and the co-processor type @cop. Use @attr to initialize attributes
139 * of the window.
140 *
141 * Note: The instance of VAS must already have an open receive window for
142 * the coprocessor type @cop.
143 *
144 * Return a handle to the send window or ERR_PTR() on error.
145 */
146 struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,
147 struct vas_tx_win_attr *attr);
148
149 /*
150 * Close the send or receive window identified by @win. For receive windows
151 * return -EAGAIN if there are active send windows attached to this receive
152 * window.
153 */
154 int vas_win_close(struct vas_window *win);
155
156 /*
157 * Copy the co-processor request block (CRB) @crb into the local L2 cache.
158 */
159 int vas_copy_crb(void *crb, int offset);
160
161 /*
162 * Paste a previously copied CRB (see vas_copy_crb()) from the L2 cache to
163 * the hardware address associated with the window @win. @re is expected/
164 * assumed to be true for NX windows.
165 */
166 int vas_paste_crb(struct vas_window *win, int offset, bool re);
167
168 #endif /* __ASM_POWERPC_VAS_H */