]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - arch/powerpc/include/asm/vas.h
2 * Copyright 2016-17 IBM Corp.
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.
10 #ifndef _ASM_POWERPC_VAS_H
11 #define _ASM_POWERPC_VAS_H
16 * Min and max FIFO sizes are based on Version 1.05 Section 3.1.4.25
17 * (Local FIFO Size Register) of the VAS workbook.
19 #define VAS_RX_FIFO_SIZE_MIN (1 << 10) /* 1KB */
20 #define VAS_RX_FIFO_SIZE_MAX (8 << 20) /* 8MB */
23 * Threshold Control Mode: Have paste operation fail if the number of
24 * requests in receive FIFO exceeds a threshold.
26 * NOTE: No special error code yet if paste is rejected because of these
27 * limits. So users can't distinguish between this and other errors.
29 #define VAS_THRESH_DISABLED 0
30 #define VAS_THRESH_FIFO_GT_HALF_FULL 1
31 #define VAS_THRESH_FIFO_GT_QTR_FULL 2
32 #define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3
37 #define GET_FIELD(m, v) (((v) & (m)) >> MASK_LSH(m))
38 #define MASK_LSH(m) (__builtin_ffsl(m) - 1)
39 #define SET_FIELD(m, v, val) \
40 (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_LSH(m)) & (m)))
43 * Co-processor Engine type.
48 VAS_COP_TYPE_842_HIPRI
,
50 VAS_COP_TYPE_GZIP_HIPRI
,
56 * Receive window attributes specified by the (in-kernel) owner of window.
58 struct vas_rx_win_attr
{
86 * Window attributes specified by the in-kernel owner of a send window.
88 struct vas_tx_win_attr
{
89 enum vas_cop_type cop
;
92 int pidr
; /* hardware PID (from SPRN_PID) */
93 int pid
; /* linux process id */
101 bool rsvd_txbuf_enable
;
104 bool tx_win_ord_mode
;
105 bool rx_win_ord_mode
;
109 * Helper to map a chip id to VAS id.
110 * For POWER9, this is a 1:1 mapping. In the future this maybe a 1:N
111 * mapping in which case, we will need to update this helper.
113 * Return the VAS id or -1 if no matching vasid is found.
115 int chip_to_vas_id(int chipid
);
118 * Helper to initialize receive window attributes to defaults for an
121 void vas_init_rx_win_attr(struct vas_rx_win_attr
*rxattr
, enum vas_cop_type cop
);
124 * Open a VAS receive window for the instance of VAS identified by @vasid
125 * Use @attr to initialize the attributes of the window.
127 * Return a handle to the window or ERR_PTR() on error.
129 struct vas_window
*vas_rx_win_open(int vasid
, enum vas_cop_type cop
,
130 struct vas_rx_win_attr
*attr
);
133 * Helper to initialize send window attributes to defaults for an NX window.
135 extern void vas_init_tx_win_attr(struct vas_tx_win_attr
*txattr
,
136 enum vas_cop_type cop
);
139 * Open a VAS send window for the instance of VAS identified by @vasid
140 * and the co-processor type @cop. Use @attr to initialize attributes
143 * Note: The instance of VAS must already have an open receive window for
144 * the coprocessor type @cop.
146 * Return a handle to the send window or ERR_PTR() on error.
148 struct vas_window
*vas_tx_win_open(int vasid
, enum vas_cop_type cop
,
149 struct vas_tx_win_attr
*attr
);
152 * Close the send or receive window identified by @win. For receive windows
153 * return -EAGAIN if there are active send windows attached to this receive
156 int vas_win_close(struct vas_window
*win
);
159 * Copy the co-processor request block (CRB) @crb into the local L2 cache.
161 int vas_copy_crb(void *crb
, int offset
);
164 * Paste a previously copied CRB (see vas_copy_crb()) from the L2 cache to
165 * the hardware address associated with the window @win. @re is expected/
166 * assumed to be true for NX windows.
168 int vas_paste_crb(struct vas_window
*win
, int offset
, bool re
);
171 * Return a system-wide unique id for the VAS window @win.
173 extern u32
vas_win_id(struct vas_window
*win
);
176 * Return the power bus paste address associated with @win so the caller
177 * can map that address into their address space.
179 extern u64
vas_win_paste_addr(struct vas_window
*win
);
180 #endif /* __ASM_POWERPC_VAS_H */