1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Functions for incremental construction of fcx enabled I/O control blocks.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright IBM Corp. 2008
6*4882a593Smuzhiyun * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #include <linux/kernel.h>
10*4882a593Smuzhiyun #include <linux/types.h>
11*4882a593Smuzhiyun #include <linux/string.h>
12*4882a593Smuzhiyun #include <linux/errno.h>
13*4882a593Smuzhiyun #include <linux/err.h>
14*4882a593Smuzhiyun #include <linux/module.h>
15*4882a593Smuzhiyun #include <asm/fcx.h>
16*4882a593Smuzhiyun #include <asm/itcw.h>
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun /*
19*4882a593Smuzhiyun * struct itcw - incremental tcw helper data type
20*4882a593Smuzhiyun *
21*4882a593Smuzhiyun * This structure serves as a handle for the incremental construction of a
22*4882a593Smuzhiyun * tcw and associated tccb, tsb, data tidaw-list plus an optional interrogate
23*4882a593Smuzhiyun * tcw and associated data. The data structures are contained inside a single
24*4882a593Smuzhiyun * contiguous buffer provided by the user.
25*4882a593Smuzhiyun *
26*4882a593Smuzhiyun * The itcw construction functions take care of overall data integrity:
27*4882a593Smuzhiyun * - reset unused fields to zero
28*4882a593Smuzhiyun * - fill in required pointers
29*4882a593Smuzhiyun * - ensure required alignment for data structures
30*4882a593Smuzhiyun * - prevent data structures to cross 4k-byte boundary where required
31*4882a593Smuzhiyun * - calculate tccb-related length fields
32*4882a593Smuzhiyun * - optionally provide ready-made interrogate tcw and associated structures
33*4882a593Smuzhiyun *
34*4882a593Smuzhiyun * Restrictions apply to the itcws created with these construction functions:
35*4882a593Smuzhiyun * - tida only supported for data address, not for tccb
36*4882a593Smuzhiyun * - only contiguous tidaw-lists (no ttic)
37*4882a593Smuzhiyun * - total number of bytes required per itcw may not exceed 4k bytes
38*4882a593Smuzhiyun * - either read or write operation (may not work with r=0 and w=0)
39*4882a593Smuzhiyun *
40*4882a593Smuzhiyun * Example:
41*4882a593Smuzhiyun * struct itcw *itcw;
42*4882a593Smuzhiyun * void *buffer;
43*4882a593Smuzhiyun * size_t size;
44*4882a593Smuzhiyun *
45*4882a593Smuzhiyun * size = itcw_calc_size(1, 2, 0);
46*4882a593Smuzhiyun * buffer = kmalloc(size, GFP_KERNEL | GFP_DMA);
47*4882a593Smuzhiyun * if (!buffer)
48*4882a593Smuzhiyun * return -ENOMEM;
49*4882a593Smuzhiyun * itcw = itcw_init(buffer, size, ITCW_OP_READ, 1, 2, 0);
50*4882a593Smuzhiyun * if (IS_ERR(itcw))
51*4882a593Smuzhiyun * return PTR_ER(itcw);
52*4882a593Smuzhiyun * itcw_add_dcw(itcw, 0x2, 0, NULL, 0, 72);
53*4882a593Smuzhiyun * itcw_add_tidaw(itcw, 0, 0x30000, 20);
54*4882a593Smuzhiyun * itcw_add_tidaw(itcw, 0, 0x40000, 52);
55*4882a593Smuzhiyun * itcw_finalize(itcw);
56*4882a593Smuzhiyun *
57*4882a593Smuzhiyun */
58*4882a593Smuzhiyun struct itcw {
59*4882a593Smuzhiyun struct tcw *tcw;
60*4882a593Smuzhiyun struct tcw *intrg_tcw;
61*4882a593Smuzhiyun int num_tidaws;
62*4882a593Smuzhiyun int max_tidaws;
63*4882a593Smuzhiyun int intrg_num_tidaws;
64*4882a593Smuzhiyun int intrg_max_tidaws;
65*4882a593Smuzhiyun };
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun /**
68*4882a593Smuzhiyun * itcw_get_tcw - return pointer to tcw associated with the itcw
69*4882a593Smuzhiyun * @itcw: address of the itcw
70*4882a593Smuzhiyun *
71*4882a593Smuzhiyun * Return pointer to the tcw associated with the itcw.
72*4882a593Smuzhiyun */
itcw_get_tcw(struct itcw * itcw)73*4882a593Smuzhiyun struct tcw *itcw_get_tcw(struct itcw *itcw)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun return itcw->tcw;
76*4882a593Smuzhiyun }
77*4882a593Smuzhiyun EXPORT_SYMBOL(itcw_get_tcw);
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun /**
80*4882a593Smuzhiyun * itcw_calc_size - return the size of an itcw with the given parameters
81*4882a593Smuzhiyun * @intrg: if non-zero, add an interrogate tcw
82*4882a593Smuzhiyun * @max_tidaws: maximum number of tidaws to be used for data addressing or zero
83*4882a593Smuzhiyun * if no tida is to be used.
84*4882a593Smuzhiyun * @intrg_max_tidaws: maximum number of tidaws to be used for data addressing
85*4882a593Smuzhiyun * by the interrogate tcw, if specified
86*4882a593Smuzhiyun *
87*4882a593Smuzhiyun * Calculate and return the number of bytes required to hold an itcw with the
88*4882a593Smuzhiyun * given parameters and assuming tccbs with maximum size.
89*4882a593Smuzhiyun *
90*4882a593Smuzhiyun * Note that the resulting size also contains bytes needed for alignment
91*4882a593Smuzhiyun * padding as well as padding to ensure that data structures don't cross a
92*4882a593Smuzhiyun * 4k-boundary where required.
93*4882a593Smuzhiyun */
itcw_calc_size(int intrg,int max_tidaws,int intrg_max_tidaws)94*4882a593Smuzhiyun size_t itcw_calc_size(int intrg, int max_tidaws, int intrg_max_tidaws)
95*4882a593Smuzhiyun {
96*4882a593Smuzhiyun size_t len;
97*4882a593Smuzhiyun int cross_count;
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun /* Main data. */
100*4882a593Smuzhiyun len = sizeof(struct itcw);
101*4882a593Smuzhiyun len += /* TCW */ sizeof(struct tcw) + /* TCCB */ TCCB_MAX_SIZE +
102*4882a593Smuzhiyun /* TSB */ sizeof(struct tsb) +
103*4882a593Smuzhiyun /* TIDAL */ max_tidaws * sizeof(struct tidaw);
104*4882a593Smuzhiyun /* Interrogate data. */
105*4882a593Smuzhiyun if (intrg) {
106*4882a593Smuzhiyun len += /* TCW */ sizeof(struct tcw) + /* TCCB */ TCCB_MAX_SIZE +
107*4882a593Smuzhiyun /* TSB */ sizeof(struct tsb) +
108*4882a593Smuzhiyun /* TIDAL */ intrg_max_tidaws * sizeof(struct tidaw);
109*4882a593Smuzhiyun }
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun /* Maximum required alignment padding. */
112*4882a593Smuzhiyun len += /* Initial TCW */ 63 + /* Interrogate TCCB */ 7;
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun /* TIDAW lists may not cross a 4k boundary. To cross a
115*4882a593Smuzhiyun * boundary we need to add a TTIC TIDAW. We need to reserve
116*4882a593Smuzhiyun * one additional TIDAW for a TTIC that we may need to add due
117*4882a593Smuzhiyun * to the placement of the data chunk in memory, and a further
118*4882a593Smuzhiyun * TIDAW for each page boundary that the TIDAW list may cross
119*4882a593Smuzhiyun * due to it's own size.
120*4882a593Smuzhiyun */
121*4882a593Smuzhiyun if (max_tidaws) {
122*4882a593Smuzhiyun cross_count = 1 + ((max_tidaws * sizeof(struct tidaw) - 1)
123*4882a593Smuzhiyun >> PAGE_SHIFT);
124*4882a593Smuzhiyun len += cross_count * sizeof(struct tidaw);
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun if (intrg_max_tidaws) {
127*4882a593Smuzhiyun cross_count = 1 + ((intrg_max_tidaws * sizeof(struct tidaw) - 1)
128*4882a593Smuzhiyun >> PAGE_SHIFT);
129*4882a593Smuzhiyun len += cross_count * sizeof(struct tidaw);
130*4882a593Smuzhiyun }
131*4882a593Smuzhiyun return len;
132*4882a593Smuzhiyun }
133*4882a593Smuzhiyun EXPORT_SYMBOL(itcw_calc_size);
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun #define CROSS4K(x, l) (((x) & ~4095) != ((x + l) & ~4095))
136*4882a593Smuzhiyun
fit_chunk(addr_t * start,addr_t end,size_t len,int align,int check_4k)137*4882a593Smuzhiyun static inline void *fit_chunk(addr_t *start, addr_t end, size_t len,
138*4882a593Smuzhiyun int align, int check_4k)
139*4882a593Smuzhiyun {
140*4882a593Smuzhiyun addr_t addr;
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun addr = ALIGN(*start, align);
143*4882a593Smuzhiyun if (check_4k && CROSS4K(addr, len)) {
144*4882a593Smuzhiyun addr = ALIGN(addr, 4096);
145*4882a593Smuzhiyun addr = ALIGN(addr, align);
146*4882a593Smuzhiyun }
147*4882a593Smuzhiyun if (addr + len > end)
148*4882a593Smuzhiyun return ERR_PTR(-ENOSPC);
149*4882a593Smuzhiyun *start = addr + len;
150*4882a593Smuzhiyun return (void *) addr;
151*4882a593Smuzhiyun }
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun /**
154*4882a593Smuzhiyun * itcw_init - initialize incremental tcw data structure
155*4882a593Smuzhiyun * @buffer: address of buffer to use for data structures
156*4882a593Smuzhiyun * @size: number of bytes in buffer
157*4882a593Smuzhiyun * @op: %ITCW_OP_READ for a read operation tcw, %ITCW_OP_WRITE for a write
158*4882a593Smuzhiyun * operation tcw
159*4882a593Smuzhiyun * @intrg: if non-zero, add and initialize an interrogate tcw
160*4882a593Smuzhiyun * @max_tidaws: maximum number of tidaws to be used for data addressing or zero
161*4882a593Smuzhiyun * if no tida is to be used.
162*4882a593Smuzhiyun * @intrg_max_tidaws: maximum number of tidaws to be used for data addressing
163*4882a593Smuzhiyun * by the interrogate tcw, if specified
164*4882a593Smuzhiyun *
165*4882a593Smuzhiyun * Prepare the specified buffer to be used as an incremental tcw, i.e. a
166*4882a593Smuzhiyun * helper data structure that can be used to construct a valid tcw by
167*4882a593Smuzhiyun * successive calls to other helper functions. Note: the buffer needs to be
168*4882a593Smuzhiyun * located below the 2G address limit. The resulting tcw has the following
169*4882a593Smuzhiyun * restrictions:
170*4882a593Smuzhiyun * - no tccb tidal
171*4882a593Smuzhiyun * - input/output tidal is contiguous (no ttic)
172*4882a593Smuzhiyun * - total data should not exceed 4k
173*4882a593Smuzhiyun * - tcw specifies either read or write operation
174*4882a593Smuzhiyun *
175*4882a593Smuzhiyun * On success, return pointer to the resulting incremental tcw data structure,
176*4882a593Smuzhiyun * ERR_PTR otherwise.
177*4882a593Smuzhiyun */
itcw_init(void * buffer,size_t size,int op,int intrg,int max_tidaws,int intrg_max_tidaws)178*4882a593Smuzhiyun struct itcw *itcw_init(void *buffer, size_t size, int op, int intrg,
179*4882a593Smuzhiyun int max_tidaws, int intrg_max_tidaws)
180*4882a593Smuzhiyun {
181*4882a593Smuzhiyun struct itcw *itcw;
182*4882a593Smuzhiyun void *chunk;
183*4882a593Smuzhiyun addr_t start;
184*4882a593Smuzhiyun addr_t end;
185*4882a593Smuzhiyun int cross_count;
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun /* Check for 2G limit. */
188*4882a593Smuzhiyun start = (addr_t) buffer;
189*4882a593Smuzhiyun end = start + size;
190*4882a593Smuzhiyun if (end > (1 << 31))
191*4882a593Smuzhiyun return ERR_PTR(-EINVAL);
192*4882a593Smuzhiyun memset(buffer, 0, size);
193*4882a593Smuzhiyun /* ITCW. */
194*4882a593Smuzhiyun chunk = fit_chunk(&start, end, sizeof(struct itcw), 1, 0);
195*4882a593Smuzhiyun if (IS_ERR(chunk))
196*4882a593Smuzhiyun return chunk;
197*4882a593Smuzhiyun itcw = chunk;
198*4882a593Smuzhiyun /* allow for TTIC tidaws that may be needed to cross a page boundary */
199*4882a593Smuzhiyun cross_count = 0;
200*4882a593Smuzhiyun if (max_tidaws)
201*4882a593Smuzhiyun cross_count = 1 + ((max_tidaws * sizeof(struct tidaw) - 1)
202*4882a593Smuzhiyun >> PAGE_SHIFT);
203*4882a593Smuzhiyun itcw->max_tidaws = max_tidaws + cross_count;
204*4882a593Smuzhiyun cross_count = 0;
205*4882a593Smuzhiyun if (intrg_max_tidaws)
206*4882a593Smuzhiyun cross_count = 1 + ((intrg_max_tidaws * sizeof(struct tidaw) - 1)
207*4882a593Smuzhiyun >> PAGE_SHIFT);
208*4882a593Smuzhiyun itcw->intrg_max_tidaws = intrg_max_tidaws + cross_count;
209*4882a593Smuzhiyun /* Main TCW. */
210*4882a593Smuzhiyun chunk = fit_chunk(&start, end, sizeof(struct tcw), 64, 0);
211*4882a593Smuzhiyun if (IS_ERR(chunk))
212*4882a593Smuzhiyun return chunk;
213*4882a593Smuzhiyun itcw->tcw = chunk;
214*4882a593Smuzhiyun tcw_init(itcw->tcw, (op == ITCW_OP_READ) ? 1 : 0,
215*4882a593Smuzhiyun (op == ITCW_OP_WRITE) ? 1 : 0);
216*4882a593Smuzhiyun /* Interrogate TCW. */
217*4882a593Smuzhiyun if (intrg) {
218*4882a593Smuzhiyun chunk = fit_chunk(&start, end, sizeof(struct tcw), 64, 0);
219*4882a593Smuzhiyun if (IS_ERR(chunk))
220*4882a593Smuzhiyun return chunk;
221*4882a593Smuzhiyun itcw->intrg_tcw = chunk;
222*4882a593Smuzhiyun tcw_init(itcw->intrg_tcw, 1, 0);
223*4882a593Smuzhiyun tcw_set_intrg(itcw->tcw, itcw->intrg_tcw);
224*4882a593Smuzhiyun }
225*4882a593Smuzhiyun /* Data TIDAL. */
226*4882a593Smuzhiyun if (max_tidaws > 0) {
227*4882a593Smuzhiyun chunk = fit_chunk(&start, end, sizeof(struct tidaw) *
228*4882a593Smuzhiyun itcw->max_tidaws, 16, 0);
229*4882a593Smuzhiyun if (IS_ERR(chunk))
230*4882a593Smuzhiyun return chunk;
231*4882a593Smuzhiyun tcw_set_data(itcw->tcw, chunk, 1);
232*4882a593Smuzhiyun }
233*4882a593Smuzhiyun /* Interrogate data TIDAL. */
234*4882a593Smuzhiyun if (intrg && (intrg_max_tidaws > 0)) {
235*4882a593Smuzhiyun chunk = fit_chunk(&start, end, sizeof(struct tidaw) *
236*4882a593Smuzhiyun itcw->intrg_max_tidaws, 16, 0);
237*4882a593Smuzhiyun if (IS_ERR(chunk))
238*4882a593Smuzhiyun return chunk;
239*4882a593Smuzhiyun tcw_set_data(itcw->intrg_tcw, chunk, 1);
240*4882a593Smuzhiyun }
241*4882a593Smuzhiyun /* TSB. */
242*4882a593Smuzhiyun chunk = fit_chunk(&start, end, sizeof(struct tsb), 8, 0);
243*4882a593Smuzhiyun if (IS_ERR(chunk))
244*4882a593Smuzhiyun return chunk;
245*4882a593Smuzhiyun tsb_init(chunk);
246*4882a593Smuzhiyun tcw_set_tsb(itcw->tcw, chunk);
247*4882a593Smuzhiyun /* Interrogate TSB. */
248*4882a593Smuzhiyun if (intrg) {
249*4882a593Smuzhiyun chunk = fit_chunk(&start, end, sizeof(struct tsb), 8, 0);
250*4882a593Smuzhiyun if (IS_ERR(chunk))
251*4882a593Smuzhiyun return chunk;
252*4882a593Smuzhiyun tsb_init(chunk);
253*4882a593Smuzhiyun tcw_set_tsb(itcw->intrg_tcw, chunk);
254*4882a593Smuzhiyun }
255*4882a593Smuzhiyun /* TCCB. */
256*4882a593Smuzhiyun chunk = fit_chunk(&start, end, TCCB_MAX_SIZE, 8, 0);
257*4882a593Smuzhiyun if (IS_ERR(chunk))
258*4882a593Smuzhiyun return chunk;
259*4882a593Smuzhiyun tccb_init(chunk, TCCB_MAX_SIZE, TCCB_SAC_DEFAULT);
260*4882a593Smuzhiyun tcw_set_tccb(itcw->tcw, chunk);
261*4882a593Smuzhiyun /* Interrogate TCCB. */
262*4882a593Smuzhiyun if (intrg) {
263*4882a593Smuzhiyun chunk = fit_chunk(&start, end, TCCB_MAX_SIZE, 8, 0);
264*4882a593Smuzhiyun if (IS_ERR(chunk))
265*4882a593Smuzhiyun return chunk;
266*4882a593Smuzhiyun tccb_init(chunk, TCCB_MAX_SIZE, TCCB_SAC_INTRG);
267*4882a593Smuzhiyun tcw_set_tccb(itcw->intrg_tcw, chunk);
268*4882a593Smuzhiyun tccb_add_dcw(chunk, TCCB_MAX_SIZE, DCW_CMD_INTRG, 0, NULL,
269*4882a593Smuzhiyun sizeof(struct dcw_intrg_data), 0);
270*4882a593Smuzhiyun tcw_finalize(itcw->intrg_tcw, 0);
271*4882a593Smuzhiyun }
272*4882a593Smuzhiyun return itcw;
273*4882a593Smuzhiyun }
274*4882a593Smuzhiyun EXPORT_SYMBOL(itcw_init);
275*4882a593Smuzhiyun
276*4882a593Smuzhiyun /**
277*4882a593Smuzhiyun * itcw_add_dcw - add a dcw to the itcw
278*4882a593Smuzhiyun * @itcw: address of the itcw
279*4882a593Smuzhiyun * @cmd: the dcw command
280*4882a593Smuzhiyun * @flags: flags for the dcw
281*4882a593Smuzhiyun * @cd: address of control data for this dcw or NULL if none is required
282*4882a593Smuzhiyun * @cd_count: number of control data bytes for this dcw
283*4882a593Smuzhiyun * @count: number of data bytes for this dcw
284*4882a593Smuzhiyun *
285*4882a593Smuzhiyun * Add a new dcw to the specified itcw by writing the dcw information specified
286*4882a593Smuzhiyun * by @cmd, @flags, @cd, @cd_count and @count to the tca of the tccb. Return
287*4882a593Smuzhiyun * a pointer to the newly added dcw on success or -%ENOSPC if the new dcw
288*4882a593Smuzhiyun * would exceed the available space.
289*4882a593Smuzhiyun *
290*4882a593Smuzhiyun * Note: the tcal field of the tccb header will be updated to reflect added
291*4882a593Smuzhiyun * content.
292*4882a593Smuzhiyun */
itcw_add_dcw(struct itcw * itcw,u8 cmd,u8 flags,void * cd,u8 cd_count,u32 count)293*4882a593Smuzhiyun struct dcw *itcw_add_dcw(struct itcw *itcw, u8 cmd, u8 flags, void *cd,
294*4882a593Smuzhiyun u8 cd_count, u32 count)
295*4882a593Smuzhiyun {
296*4882a593Smuzhiyun return tccb_add_dcw(tcw_get_tccb(itcw->tcw), TCCB_MAX_SIZE, cmd,
297*4882a593Smuzhiyun flags, cd, cd_count, count);
298*4882a593Smuzhiyun }
299*4882a593Smuzhiyun EXPORT_SYMBOL(itcw_add_dcw);
300*4882a593Smuzhiyun
301*4882a593Smuzhiyun /**
302*4882a593Smuzhiyun * itcw_add_tidaw - add a tidaw to the itcw
303*4882a593Smuzhiyun * @itcw: address of the itcw
304*4882a593Smuzhiyun * @flags: flags for the new tidaw
305*4882a593Smuzhiyun * @addr: address value for the new tidaw
306*4882a593Smuzhiyun * @count: count value for the new tidaw
307*4882a593Smuzhiyun *
308*4882a593Smuzhiyun * Add a new tidaw to the input/output data tidaw-list of the specified itcw
309*4882a593Smuzhiyun * (depending on the value of the r-flag and w-flag). Return a pointer to
310*4882a593Smuzhiyun * the new tidaw on success or -%ENOSPC if the new tidaw would exceed the
311*4882a593Smuzhiyun * available space.
312*4882a593Smuzhiyun *
313*4882a593Smuzhiyun * Note: TTIC tidaws are automatically added when needed, so explicitly calling
314*4882a593Smuzhiyun * this interface with the TTIC flag is not supported. The last-tidaw flag
315*4882a593Smuzhiyun * for the last tidaw in the list will be set by itcw_finalize.
316*4882a593Smuzhiyun */
itcw_add_tidaw(struct itcw * itcw,u8 flags,void * addr,u32 count)317*4882a593Smuzhiyun struct tidaw *itcw_add_tidaw(struct itcw *itcw, u8 flags, void *addr, u32 count)
318*4882a593Smuzhiyun {
319*4882a593Smuzhiyun struct tidaw *following;
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun if (itcw->num_tidaws >= itcw->max_tidaws)
322*4882a593Smuzhiyun return ERR_PTR(-ENOSPC);
323*4882a593Smuzhiyun /*
324*4882a593Smuzhiyun * Is the tidaw, which follows the one we are about to fill, on the next
325*4882a593Smuzhiyun * page? Then we have to insert a TTIC tidaw first, that points to the
326*4882a593Smuzhiyun * tidaw on the new page.
327*4882a593Smuzhiyun */
328*4882a593Smuzhiyun following = ((struct tidaw *) tcw_get_data(itcw->tcw))
329*4882a593Smuzhiyun + itcw->num_tidaws + 1;
330*4882a593Smuzhiyun if (itcw->num_tidaws && !((unsigned long) following & ~PAGE_MASK)) {
331*4882a593Smuzhiyun tcw_add_tidaw(itcw->tcw, itcw->num_tidaws++,
332*4882a593Smuzhiyun TIDAW_FLAGS_TTIC, following, 0);
333*4882a593Smuzhiyun if (itcw->num_tidaws >= itcw->max_tidaws)
334*4882a593Smuzhiyun return ERR_PTR(-ENOSPC);
335*4882a593Smuzhiyun }
336*4882a593Smuzhiyun return tcw_add_tidaw(itcw->tcw, itcw->num_tidaws++, flags, addr, count);
337*4882a593Smuzhiyun }
338*4882a593Smuzhiyun EXPORT_SYMBOL(itcw_add_tidaw);
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun /**
341*4882a593Smuzhiyun * itcw_set_data - set data address and tida flag of the itcw
342*4882a593Smuzhiyun * @itcw: address of the itcw
343*4882a593Smuzhiyun * @addr: the data address
344*4882a593Smuzhiyun * @use_tidal: zero of the data address specifies a contiguous block of data,
345*4882a593Smuzhiyun * non-zero if it specifies a list if tidaws.
346*4882a593Smuzhiyun *
347*4882a593Smuzhiyun * Set the input/output data address of the itcw (depending on the value of the
348*4882a593Smuzhiyun * r-flag and w-flag). If @use_tidal is non-zero, the corresponding tida flag
349*4882a593Smuzhiyun * is set as well.
350*4882a593Smuzhiyun */
itcw_set_data(struct itcw * itcw,void * addr,int use_tidal)351*4882a593Smuzhiyun void itcw_set_data(struct itcw *itcw, void *addr, int use_tidal)
352*4882a593Smuzhiyun {
353*4882a593Smuzhiyun tcw_set_data(itcw->tcw, addr, use_tidal);
354*4882a593Smuzhiyun }
355*4882a593Smuzhiyun EXPORT_SYMBOL(itcw_set_data);
356*4882a593Smuzhiyun
357*4882a593Smuzhiyun /**
358*4882a593Smuzhiyun * itcw_finalize - calculate length and count fields of the itcw
359*4882a593Smuzhiyun * @itcw: address of the itcw
360*4882a593Smuzhiyun *
361*4882a593Smuzhiyun * Calculate tcw input-/output-count and tccbl fields and add a tcat the tccb.
362*4882a593Smuzhiyun * In case input- or output-tida is used, the tidaw-list must be stored in
363*4882a593Smuzhiyun * continuous storage (no ttic). The tcal field in the tccb must be
364*4882a593Smuzhiyun * up-to-date.
365*4882a593Smuzhiyun */
itcw_finalize(struct itcw * itcw)366*4882a593Smuzhiyun void itcw_finalize(struct itcw *itcw)
367*4882a593Smuzhiyun {
368*4882a593Smuzhiyun tcw_finalize(itcw->tcw, itcw->num_tidaws);
369*4882a593Smuzhiyun }
370*4882a593Smuzhiyun EXPORT_SYMBOL(itcw_finalize);
371