xref: /OK3568_Linux_fs/kernel/Documentation/sparc/oradax/dax-hv-api.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunExcerpt from UltraSPARC Virtual Machine Specification
2*4882a593SmuzhiyunCompiled from version 3.0.20+15
3*4882a593SmuzhiyunPublication date 2017-09-25 08:21
4*4882a593SmuzhiyunCopyright © 2008, 2015 Oracle and/or its affiliates. All rights reserved.
5*4882a593SmuzhiyunExtracted via "pdftotext -f 547 -l 572 -layout sun4v_20170925.pdf"
6*4882a593SmuzhiyunAuthors:
7*4882a593Smuzhiyun	 Charles Kunzman
8*4882a593Smuzhiyun	 Sam Glidden
9*4882a593Smuzhiyun	 Mark Cianchetti
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunChapter 36. Coprocessor services
13*4882a593Smuzhiyun        The following APIs provide access via the Hypervisor to hardware assisted data processing functionality.
14*4882a593Smuzhiyun        These APIs may only be provided by certain platforms, and may not be available to all virtual machines
15*4882a593Smuzhiyun        even on supported platforms. Restrictions on the use of these APIs may be imposed in order to support
16*4882a593Smuzhiyun        live-migration and other system management activities.
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun36.1. Data Analytics Accelerator
19*4882a593Smuzhiyun        The Data Analytics Accelerator (DAX) functionality is a collection of hardware coprocessors that provide
20*4882a593Smuzhiyun        high speed processoring of database-centric operations. The coprocessors may support one or more of
21*4882a593Smuzhiyun        the following data query operations: search, extraction, compression, decompression, and translation. The
22*4882a593Smuzhiyun        functionality offered may vary by virtual machine implementation.
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun        The DAX is a virtual device to sun4v guests, with supported data operations indicated by the virtual device
25*4882a593Smuzhiyun        compatibilty property. Functionality is accessed through the submission of Command Control Blocks
26*4882a593Smuzhiyun        (CCBs) via the ccb_submit API function. The operations are processed asynchronously, with the status
27*4882a593Smuzhiyun        of the submitted operations reported through a Completion Area linked to each CCB. Each CCB has a
28*4882a593Smuzhiyun        separate Completion Area and, unless execution order is specifically restricted through the use of serial-
29*4882a593Smuzhiyun        conditional flags, the execution order of submitted CCBs is arbitrary. Likewise, the time to completion
30*4882a593Smuzhiyun        for a given CCB is never guaranteed.
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun        Guest software may implement a software timeout on CCB operations, and if the timeout is exceeded, the
33*4882a593Smuzhiyun        operation may be cancelled or killed via the ccb_kill API function. It is recommended for guest software
34*4882a593Smuzhiyun        to implement a software timeout to account for certain RAS errors which may result in lost CCBs. It is
35*4882a593Smuzhiyun        recommended such implementation use the ccb_info API function to check the status of a CCB prior to
36*4882a593Smuzhiyun        killing it in order to determine if the CCB is still in queue, or may have been lost due to a RAS error.
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun        There is no fixed limit on the number of outstanding CCBs guest software may have queued in the virtual
39*4882a593Smuzhiyun        machine, however, internal resource limitations within the virtual machine can cause CCB submissions
40*4882a593Smuzhiyun        to be temporarily rejected with EWOULDBLOCK. In such cases, guests should continue to attempt
41*4882a593Smuzhiyun        submissions until they succeed; waiting for an outstanding CCB to complete is not necessary, and would
42*4882a593Smuzhiyun        not be a guarantee that a future submission would succeed.
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun        The availablility of DAX coprocessor command service is indicated by the presence of the DAX virtual
45*4882a593Smuzhiyun        device node in the guest MD (Section 8.24.17, “Database Analytics Accelerators (DAX) virtual-device
46*4882a593Smuzhiyun        node”).
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun36.1.1. DAX Compatibility Property
49*4882a593Smuzhiyun        The query functionality may vary based on the compatibility property of the virtual device:
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun36.1.1.1. "ORCL,sun4v-dax" Device Compatibility
52*4882a593Smuzhiyun        Available CCB commands:
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunNo-op/Sync
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun        • Extract
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun        • Scan Value
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun        • Inverted Scan Value
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun        • Scan Range
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun                                                     509
66*4882a593Smuzhiyun                                             Coprocessor services
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun        • Inverted Scan Range
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun        • Translate
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun        • Inverted Translate
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun        • Select
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun        See Section 36.2.1, “Query CCB Command Formats” for the corresponding CCB input and output formats.
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun        Only version 0 CCBs are available.
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun36.1.1.2. "ORCL,sun4v-dax-fc" Device Compatibility
82*4882a593Smuzhiyun        "ORCL,sun4v-dax-fc" is compatible with the "ORCL,sun4v-dax" interface, and includes additional CCB
83*4882a593Smuzhiyun        bit fields and controls.
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun36.1.1.3. "ORCL,sun4v-dax2" Device Compatibility
86*4882a593Smuzhiyun        Available CCB commands:
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunNo-op/Sync
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun        • Extract
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun        • Scan Value
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun        • Inverted Scan Value
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun        • Scan Range
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun        • Inverted Scan Range
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun        • Translate
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun        • Inverted Translate
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun        • Select
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun        See Section 36.2.1, “Query CCB Command Formats” for the corresponding CCB input and output formats.
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun        Version 0 and 1 CCBs are available. Only version 0 CCBs may use Huffman encoded data, whereas only
109*4882a593Smuzhiyun        version 1 CCBs may use OZIP.
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun36.1.2. DAX Virtual Device Interrupts
112*4882a593Smuzhiyun        The DAX virtual device has multiple interrupts associated with it which may be used by the guest if
113*4882a593Smuzhiyun        desired. The number of device interrupts available to the guest is indicated in the virtual device node of the
114*4882a593Smuzhiyun        guest MD (Section 8.24.17, “Database Analytics Accelerators (DAX) virtual-device node”). If the device
115*4882a593Smuzhiyun        node indicates N interrupts available, the guest may use any value from 0 to N - 1 (inclusive) in a CCB
116*4882a593Smuzhiyun        interrupt number field. Using values outside this range will result in the CCB being rejected for an invalid
117*4882a593Smuzhiyun        field value.
118*4882a593Smuzhiyun
119*4882a593Smuzhiyun        The interrupts may be bound and managed using the standard sun4v device interrupts API (Chapter 16,
120*4882a593Smuzhiyun        Device interrupt services). Sysino interrupts are not available for DAX devices.
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun36.2. Coprocessor Control Block (CCB)
123*4882a593Smuzhiyun        CCBs are either 64 or 128 bytes long, depending on the operation type. The exact contents of the CCB
124*4882a593Smuzhiyun        are command specific, but all CCBs contain at least one memory buffer address. All memory locations
125*4882a593Smuzhiyun
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun                                                      510
128*4882a593Smuzhiyun                                    Coprocessor services
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun
131*4882a593Smuzhiyunreferenced by a CCB must be pinned in memory until the CCB either completes execution or is killed
132*4882a593Smuzhiyunvia the ccb_kill API call. Changes in virtual address mappings occurring after CCB submission are not
133*4882a593Smuzhiyunguaranteed to be visible, and as such all virtual address updates need to be synchronized with CCB
134*4882a593Smuzhiyunexecution.
135*4882a593Smuzhiyun
136*4882a593SmuzhiyunAll CCBs begin with a common 32-bit header.
137*4882a593Smuzhiyun
138*4882a593SmuzhiyunTable 36.1. CCB Header Format
139*4882a593SmuzhiyunBits          Field Description
140*4882a593Smuzhiyun[31:28]       CCB version. For API version 2.0: set to 1 if CCB uses OZIP encoding; set to 0 if the CCB
141*4882a593Smuzhiyun              uses Huffman encoding; otherwise either 0 or 1. For API version 1.0: always set to 0.
142*4882a593Smuzhiyun[27]          When API version 2.0 is negotiated, this is the Pipeline Flag [512]. It is reserved in
143*4882a593Smuzhiyun              API version 1.0
144*4882a593Smuzhiyun[26]          Long CCB flag [512]
145*4882a593Smuzhiyun[25]          Conditional synchronization flag [512]
146*4882a593Smuzhiyun[24]          Serial synchronization flag
147*4882a593Smuzhiyun[23:16]       CCB operation code:
148*4882a593Smuzhiyun               0x00        No Operation (No-op) or Sync
149*4882a593Smuzhiyun               0x01        Extract
150*4882a593Smuzhiyun               0x02        Scan Value
151*4882a593Smuzhiyun               0x12        Inverted Scan Value
152*4882a593Smuzhiyun               0x03        Scan Range
153*4882a593Smuzhiyun               0x13        Inverted Scan Range
154*4882a593Smuzhiyun               0x04        Translate
155*4882a593Smuzhiyun               0x14        Inverted Translate
156*4882a593Smuzhiyun               0x05        Select
157*4882a593Smuzhiyun[15:13]       Reserved
158*4882a593Smuzhiyun[12:11]       Table address type
159*4882a593Smuzhiyun               0b'00       No address
160*4882a593Smuzhiyun               0b'01       Alternate context virtual address
161*4882a593Smuzhiyun               0b'10       Real address
162*4882a593Smuzhiyun               0b'11       Primary context virtual address
163*4882a593Smuzhiyun[10:8]        Output/Destination address type
164*4882a593Smuzhiyun               0b'000      No address
165*4882a593Smuzhiyun               0b'001      Alternate context virtual address
166*4882a593Smuzhiyun               0b'010      Real address
167*4882a593Smuzhiyun               0b'011      Primary context virtual address
168*4882a593Smuzhiyun               0b'100      Reserved
169*4882a593Smuzhiyun               0b'101      Reserved
170*4882a593Smuzhiyun               0b'110      Reserved
171*4882a593Smuzhiyun               0b'111      Reserved
172*4882a593Smuzhiyun[7:5]         Secondary source address type
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun                                            511
176*4882a593Smuzhiyun                                    Coprocessor services
177*4882a593Smuzhiyun
178*4882a593Smuzhiyun
179*4882a593SmuzhiyunBits           Field Description
180*4882a593Smuzhiyun                0b'000       No address
181*4882a593Smuzhiyun                0b'001       Alternate context virtual address
182*4882a593Smuzhiyun                0b'010       Real address
183*4882a593Smuzhiyun                0b'011       Primary context virtual address
184*4882a593Smuzhiyun                0b'100       Reserved
185*4882a593Smuzhiyun                0b'101       Reserved
186*4882a593Smuzhiyun                0b'110       Reserved
187*4882a593Smuzhiyun                0b'111       Reserved
188*4882a593Smuzhiyun[4:2]          Primary source address type
189*4882a593Smuzhiyun                0b'000       No address
190*4882a593Smuzhiyun                0b'001       Alternate context virtual address
191*4882a593Smuzhiyun                0b'010       Real address
192*4882a593Smuzhiyun                0b'011       Primary context virtual address
193*4882a593Smuzhiyun                0b'100       Reserved
194*4882a593Smuzhiyun                0b'101       Reserved
195*4882a593Smuzhiyun                0b'110       Reserved
196*4882a593Smuzhiyun                0b'111       Reserved
197*4882a593Smuzhiyun[1:0]          Completion area address type
198*4882a593Smuzhiyun                0b'00        No address
199*4882a593Smuzhiyun                0b'01        Alternate context virtual address
200*4882a593Smuzhiyun                0b'10        Real address
201*4882a593Smuzhiyun                0b'11        Primary context virtual address
202*4882a593Smuzhiyun
203*4882a593SmuzhiyunThe Long CCB flag indicates whether the submitted CCB is 64 or 128 bytes long; value is 0 for 64 bytes
204*4882a593Smuzhiyunand 1 for 128 bytes.
205*4882a593Smuzhiyun
206*4882a593SmuzhiyunThe Serial and Conditional flags allow simple relative ordering between CCBs. Any CCB with the Serial
207*4882a593Smuzhiyunflag set will execute sequentially relative to any previous CCB that is also marked as Serial in the same
208*4882a593SmuzhiyunCCB submission. CCBs without the Serial flag set execute independently, even if they are between CCBs
209*4882a593Smuzhiyunwith the Serial flag set. CCBs marked solely with the Serial flag will execute upon the completion of the
210*4882a593Smuzhiyunprevious Serial CCB, regardless of the completion status of that CCB. The Conditional flag allows CCBs
211*4882a593Smuzhiyunto conditionally execute based on the successful execution of the closest CCB marked with the Serial flag.
212*4882a593SmuzhiyunA CCB may only be conditional on exactly one CCB, however, a CCB may be marked both Conditional
213*4882a593Smuzhiyunand Serial to allow execution chaining. The flags do NOT allow fan-out chaining, where multiple CCBs
214*4882a593Smuzhiyunexecute in parallel based on the completion of another CCB.
215*4882a593Smuzhiyun
216*4882a593SmuzhiyunThe Pipeline flag is an optimization that directs the output of one CCB (the "source" CCB) directly to
217*4882a593Smuzhiyunthe input of the next CCB (the "target" CCB). The target CCB thus does not need to read the input from
218*4882a593Smuzhiyunmemory. The Pipeline flag is advisory and may be dropped.
219*4882a593Smuzhiyun
220*4882a593SmuzhiyunBoth the Pipeline and Serial bits must be set in the source CCB. The Conditional bit must be set in the
221*4882a593Smuzhiyuntarget CCB. Exactly one CCB must be made conditional on the source CCB; either 0 or 2 target CCBs
222*4882a593Smuzhiyunis invalid. However, Pipelines can be extended beyond two CCBs: the sequence would start with a CCB
223*4882a593Smuzhiyunwith both the Pipeline and Serial bits set, proceed through CCBs with the Pipeline, Serial, and Conditional
224*4882a593Smuzhiyunbits set, and terminate at a CCB that has the Conditional bit set, but not the Pipeline bit.
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun                                             512
228*4882a593Smuzhiyun                                               Coprocessor services
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun
231*4882a593Smuzhiyun          The input of the target CCB must start within 64 bytes of the output of the source CCB or the pipeline flag
232*4882a593Smuzhiyun          will be ignored. All CCBs in a pipeline must be submitted in the same call to ccb_submit.
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun          The various address type fields indicate how the various address values used in the CCB should be
235*4882a593Smuzhiyun          interpreted by the virtual machine. Not all of the types specified are used by every CCB format. Types
236*4882a593Smuzhiyun          which are not applicable to the given CCB command should be indicated as type 0 (No address). Virtual
237*4882a593Smuzhiyun          addresses used in the CCB must have translation entries present in either the TLB or a configured TSB
238*4882a593Smuzhiyun          for the submitting virtual processor. Virtual addresses which cannot be translated by the virtual machine
239*4882a593Smuzhiyun          will result in the CCB submission being rejected, with the causal virtual address indicated. The CCB
240*4882a593Smuzhiyun          may be resubmitted after inserting the translation, or the address may be translated by guest software and
241*4882a593Smuzhiyun          resubmitted using the real address translation.
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun36.2.1. Query CCB Command Formats
244*4882a593Smuzhiyun36.2.1.1. Supported Data Formats, Elements Sizes and Offsets
245*4882a593Smuzhiyun          Data for query commands may be encoded in multiple possible formats. The data query commands use a
246*4882a593Smuzhiyun          common set of values to indicate the encoding formats of the data being processed. Some encoding formats
247*4882a593Smuzhiyun          require multiple data streams for processing, requiring the specification of both primary data formats (the
248*4882a593Smuzhiyun          encoded data) and secondary data streams (meta-data for the encoded data).
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun36.2.1.1.1. Primary Input Format
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun          The primary input format code is a 4-bit field when it is used. There are 10 primary input formats available.
253*4882a593Smuzhiyun          The packed formats are not endian neutral. Code values not listed below are reserved.
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun          Code        Format                              Description
256*4882a593Smuzhiyun          0x0         Fixed width byte packed             Up to 16 bytes
257*4882a593Smuzhiyun          0x1         Fixed width bit packed              Up to 15 bits (CCB version 0) or 23 bits (CCB version
258*4882a593Smuzhiyun                                                          1); bits are read most significant bit to least significant bit
259*4882a593Smuzhiyun                                                          within a byte
260*4882a593Smuzhiyun          0x2         Variable width byte packed          Data stream of lengths must be provided as a secondary
261*4882a593Smuzhiyun                                                          input
262*4882a593Smuzhiyun          0x4         Fixed width byte packed with run Up to 16 bytes; data stream of run lengths must be
263*4882a593Smuzhiyun                      length encoding                  provided as a secondary input
264*4882a593Smuzhiyun          0x5         Fixed width bit packed with run Up to 15 bits (CCB version 0) or 23 bits (CCB version
265*4882a593Smuzhiyun                      length encoding                 1); bits are read most significant bit to least significant bit
266*4882a593Smuzhiyun                                                      within a byte; data stream of run lengths must be provided
267*4882a593Smuzhiyun                                                      as a secondary input
268*4882a593Smuzhiyun          0x8         Fixed width byte packed with Up to 16 bytes before the encoding; compressed stream
269*4882a593Smuzhiyun                      Huffman (CCB version 0) or bits are read most significant bit to least significant bit
270*4882a593Smuzhiyun                      OZIP (CCB version 1) encoding within a byte; pointer to the encoding table must be
271*4882a593Smuzhiyun                                                    provided
272*4882a593Smuzhiyun          0x9         Fixed width bit packed with Up to 15 bits (CCB version 0) or 23 bits (CCB version
273*4882a593Smuzhiyun                      Huffman (CCB version 0) or 1); compressed stream bits are read most significant bit to
274*4882a593Smuzhiyun                      OZIP (CCB version 1) encoding least significant bit within a byte; pointer to the encoding
275*4882a593Smuzhiyun                                                    table must be provided
276*4882a593Smuzhiyun          0xA         Variable width byte packed with Up to 16 bytes before the encoding; compressed stream
277*4882a593Smuzhiyun                      Huffman (CCB version 0) or bits are read most significant bit to least significant bit
278*4882a593Smuzhiyun                      OZIP (CCB version 1) encoding within a byte; data stream of lengths must be provided as
279*4882a593Smuzhiyun                                                      a secondary input; pointer to the encoding table must be
280*4882a593Smuzhiyun                                                      provided
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun                                                        513
284*4882a593Smuzhiyun                                               Coprocessor services
285*4882a593Smuzhiyun
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun          Code        Format                              Description
288*4882a593Smuzhiyun          0xC         Fixed width byte packed with        Up to 16 bytes before the encoding; compressed stream
289*4882a593Smuzhiyun                      run length encoding, followed by    bits are read most significant bit to least significant bit
290*4882a593Smuzhiyun                      Huffman (CCB version 0) or          within a byte; data stream of run lengths must be provided
291*4882a593Smuzhiyun                      OZIP (CCB version 1) encoding       as a secondary input; pointer to the encoding table must
292*4882a593Smuzhiyun                                                          be provided
293*4882a593Smuzhiyun          0xD         Fixed width bit packed with         Up to 15 bits (CCB version 0) or 23 bits(CCB version 1)
294*4882a593Smuzhiyun                      run length encoding, followed by    before the encoding; compressed stream bits are read most
295*4882a593Smuzhiyun                      Huffman (CCB version 0) or          significant bit to least significant bit within a byte; data
296*4882a593Smuzhiyun                      OZIP (CCB version 1) encoding       stream of run lengths must be provided as a secondary
297*4882a593Smuzhiyun                                                          input; pointer to the encoding table must be provided
298*4882a593Smuzhiyun
299*4882a593Smuzhiyun          If OZIP encoding is used, there must be no reserved bytes in the table.
300*4882a593Smuzhiyun
301*4882a593Smuzhiyun36.2.1.1.2. Primary Input Element Size
302*4882a593Smuzhiyun
303*4882a593Smuzhiyun          For primary input data streams with fixed size elements, the element size must be indicated in the CCB
304*4882a593Smuzhiyun          command. The size is encoded as the number of bits or bytes, minus one. The valid value range for this
305*4882a593Smuzhiyun          field depends on the input format selected, as listed in the table above.
306*4882a593Smuzhiyun
307*4882a593Smuzhiyun36.2.1.1.3. Secondary Input Format
308*4882a593Smuzhiyun
309*4882a593Smuzhiyun          For primary input data streams which require a secondary input stream, the secondary input stream is
310*4882a593Smuzhiyun          always encoded in a fixed width, bit-packed format. The bits are read from most significant bit to least
311*4882a593Smuzhiyun          significant bit within a byte. There are two encoding options for the secondary input stream data elements,
312*4882a593Smuzhiyun          depending on whether the value of 0 is needed:
313*4882a593Smuzhiyun
314*4882a593Smuzhiyun          Secondary           Input Description
315*4882a593Smuzhiyun          Format Code
316*4882a593Smuzhiyun          0                          Element is stored as value minus 1 (0 evalutes to 1, 1 evalutes
317*4882a593Smuzhiyun                                     to 2, etc)
318*4882a593Smuzhiyun          1                          Element is stored as value
319*4882a593Smuzhiyun
320*4882a593Smuzhiyun36.2.1.1.4. Secondary Input Element Size
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun          Secondary input element size is encoded as a two bit field:
323*4882a593Smuzhiyun
324*4882a593Smuzhiyun          Secondary Input Size Description
325*4882a593Smuzhiyun          Code
326*4882a593Smuzhiyun          0x0                        1 bit
327*4882a593Smuzhiyun          0x1                        2 bits
328*4882a593Smuzhiyun          0x2                        4 bits
329*4882a593Smuzhiyun          0x3                        8 bits
330*4882a593Smuzhiyun
331*4882a593Smuzhiyun36.2.1.1.5. Input Element Offsets
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun          Bit-wise input data streams may have any alignment within the base addressed byte. The offset, specified
334*4882a593Smuzhiyun          from most significant bit to least significant bit, is provided as a fixed 3 bit field for each input type. A
335*4882a593Smuzhiyun          value of 0 indicates that the first input element begins at the most significant bit in the first byte, and a
336*4882a593Smuzhiyun          value of 7 indicates it begins with the least significant bit.
337*4882a593Smuzhiyun
338*4882a593Smuzhiyun          This field should be zero for any byte-wise primary input data streams.
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun
341*4882a593Smuzhiyun                                                        514
342*4882a593Smuzhiyun                                              Coprocessor services
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun36.2.1.1.6. Output Format
346*4882a593Smuzhiyun
347*4882a593Smuzhiyun          Query commands support multiple sizes and encodings for output data streams. There are four possible
348*4882a593Smuzhiyun          output encodings, and up to four supported element sizes per encoding. Not all output encodings are
349*4882a593Smuzhiyun          supported for every command. The format is indicated by a 4-bit field in the CCB:
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun           Output Format Code        Description
352*4882a593Smuzhiyun           0x0                       Byte aligned, 1 byte elements
353*4882a593Smuzhiyun           0x1                       Byte aligned, 2 byte elements
354*4882a593Smuzhiyun           0x2                       Byte aligned, 4 byte elements
355*4882a593Smuzhiyun           0x3                       Byte aligned, 8 byte elements
356*4882a593Smuzhiyun           0x4                       16 byte aligned, 16 byte elements
357*4882a593Smuzhiyun           0x5                       Reserved
358*4882a593Smuzhiyun           0x6                       Reserved
359*4882a593Smuzhiyun           0x7                       Reserved
360*4882a593Smuzhiyun           0x8                       Packed vector of single bit elements
361*4882a593Smuzhiyun           0x9                       Reserved
362*4882a593Smuzhiyun           0xA                       Reserved
363*4882a593Smuzhiyun           0xB                       Reserved
364*4882a593Smuzhiyun           0xC                       Reserved
365*4882a593Smuzhiyun           0xD                       2 byte elements where each element is the index value of a bit,
366*4882a593Smuzhiyun                                     from an bit vector, which was 1.
367*4882a593Smuzhiyun           0xE                       4 byte elements where each element is the index value of a bit,
368*4882a593Smuzhiyun                                     from an bit vector, which was 1.
369*4882a593Smuzhiyun           0xF                       Reserved
370*4882a593Smuzhiyun
371*4882a593Smuzhiyun36.2.1.1.7. Application Data Integrity (ADI)
372*4882a593Smuzhiyun
373*4882a593Smuzhiyun          On platforms which support ADI, the ADI version number may be specified for each separate memory
374*4882a593Smuzhiyun          access type used in the CCB command. ADI checking only occurs when reading data. When writing data,
375*4882a593Smuzhiyun          the specified ADI version number overwrites any existing ADI value in memory.
376*4882a593Smuzhiyun
377*4882a593Smuzhiyun          An ADI version value of 0 or 0xF indicates the ADI checking is disabled for that data access, even if it is
378*4882a593Smuzhiyun          enabled in memory. By setting the appropriate flag in CCB_SUBMIT (Section 36.3.1, “ccb_submit”) it is
379*4882a593Smuzhiyun          also an option to disable ADI checking for all inputs accessed via virtual address for all CCBs submitted
380*4882a593Smuzhiyun          during that hypercall invocation.
381*4882a593Smuzhiyun
382*4882a593Smuzhiyun          The ADI value is only guaranteed to be checked on the first 64 bytes of each data access. Mismatches on
383*4882a593Smuzhiyun          subsequent data chunks may not be detected, so guest software should be careful to use page size checking
384*4882a593Smuzhiyun          to protect against buffer overruns.
385*4882a593Smuzhiyun
386*4882a593Smuzhiyun36.2.1.1.8. Page size checking
387*4882a593Smuzhiyun
388*4882a593Smuzhiyun          All data accesses used in CCB commands must be bounded within a single memory page. When addresses
389*4882a593Smuzhiyun          are provided using a virtual address, the page size for checking is extracted from the TTE for that virtual
390*4882a593Smuzhiyun          address. When using real addresses, the guest must supply the page size in the same field as the address
391*4882a593Smuzhiyun          value. The page size must be one of the sizes supported by the underlying virtual machine. Using a value
392*4882a593Smuzhiyun          that is not supported may result in the CCB submission being rejected or the generation of a CCB parsing
393*4882a593Smuzhiyun          error in the completion area.
394*4882a593Smuzhiyun
395*4882a593Smuzhiyun
396*4882a593Smuzhiyun                                                       515
397*4882a593Smuzhiyun                                               Coprocessor services
398*4882a593Smuzhiyun
399*4882a593Smuzhiyun
400*4882a593Smuzhiyun36.2.1.2. Extract command
401*4882a593Smuzhiyun
402*4882a593Smuzhiyun        Converts an input vector in one format to an output vector in another format. All input format types are
403*4882a593Smuzhiyun        supported.
404*4882a593Smuzhiyun
405*4882a593Smuzhiyun        The only supported output format is a padded, byte-aligned output stream, using output codes 0x0 - 0x4.
406*4882a593Smuzhiyun        When the specified output element size is larger than the extracted input element size, zeros are padded to
407*4882a593Smuzhiyun        the extracted input element. First, if the decompressed input size is not a whole number of bytes, 0 bits are
408*4882a593Smuzhiyun        padded to the most significant bit side till the next byte boundary. Next, if the output element size is larger
409*4882a593Smuzhiyun        than the byte padded input element, bytes of value 0 are added based on the Padding Direction bit in the
410*4882a593Smuzhiyun        CCB. If the output element size is smaller than the byte-padded input element size, the input element is
411*4882a593Smuzhiyun        truncated by dropped from the least significant byte side until the selected output size is reached.
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun        The return value of the CCB completion area is invalid. The “number of elements processed” field in the
414*4882a593Smuzhiyun        CCB completion area will be valid.
415*4882a593Smuzhiyun
416*4882a593Smuzhiyun        The extract CCB is a 64-byte “short format” CCB.
417*4882a593Smuzhiyun
418*4882a593Smuzhiyun        The extract CCB command format can be specified by the following packed C structure for a big-endian
419*4882a593Smuzhiyun        machine:
420*4882a593Smuzhiyun
421*4882a593Smuzhiyun
422*4882a593Smuzhiyun                  struct extract_ccb {
423*4882a593Smuzhiyun                         uint32_t header;
424*4882a593Smuzhiyun                         uint32_t control;
425*4882a593Smuzhiyun                         uint64_t completion;
426*4882a593Smuzhiyun                         uint64_t primary_input;
427*4882a593Smuzhiyun                         uint64_t data_access_control;
428*4882a593Smuzhiyun                         uint64_t secondary_input;
429*4882a593Smuzhiyun                         uint64_t reserved;
430*4882a593Smuzhiyun                         uint64_t output;
431*4882a593Smuzhiyun                         uint64_t table;
432*4882a593Smuzhiyun                  };
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun        The exact field offsets, sizes, and composition are as follows:
436*4882a593Smuzhiyun
437*4882a593Smuzhiyun         Offset         Size            Field Description
438*4882a593Smuzhiyun         0              4               CCB header (Table 36.1, “CCB Header Format”)
439*4882a593Smuzhiyun         4              4               Command control
440*4882a593Smuzhiyun                                        Bits        Field Description
441*4882a593Smuzhiyun                                        [31:28]     Primary Input Format (see Section 36.2.1.1.1, “Primary Input
442*4882a593Smuzhiyun                                                    Format”)
443*4882a593Smuzhiyun                                        [27:23]     Primary Input Element Size (see Section 36.2.1.1.2, “Primary
444*4882a593Smuzhiyun                                                    Input Element Size”)
445*4882a593Smuzhiyun                                        [22:20]     Primary Input Starting Offset (see Section 36.2.1.1.5, “Input
446*4882a593Smuzhiyun                                                    Element Offsets”)
447*4882a593Smuzhiyun                                        [19]        Secondary Input Format (see Section 36.2.1.1.3, “Secondary
448*4882a593Smuzhiyun                                                    Input Format”)
449*4882a593Smuzhiyun                                        [18:16]     Secondary Input Starting Offset (see Section 36.2.1.1.5, “Input
450*4882a593Smuzhiyun                                                    Element Offsets”)
451*4882a593Smuzhiyun
452*4882a593Smuzhiyun
453*4882a593Smuzhiyun                                                       516
454*4882a593Smuzhiyun                        Coprocessor services
455*4882a593Smuzhiyun
456*4882a593Smuzhiyun
457*4882a593SmuzhiyunOffset   Size   Field Description
458*4882a593Smuzhiyun                Bits         Field Description
459*4882a593Smuzhiyun                [15:14]      Secondary Input Element Size (see Section 36.2.1.1.4,
460*4882a593Smuzhiyun                             “Secondary Input Element Size”
461*4882a593Smuzhiyun                [13:10]      Output Format (see Section 36.2.1.1.6, “Output Format”)
462*4882a593Smuzhiyun                [9]          Padding Direction selector: A value of 1 causes padding bytes
463*4882a593Smuzhiyun                             to be added to the left side of output elements. A value of 0
464*4882a593Smuzhiyun                             causes padding bytes to be added to the right side of output
465*4882a593Smuzhiyun                             elements.
466*4882a593Smuzhiyun                [8:0]        Reserved
467*4882a593Smuzhiyun8        8      Completion
468*4882a593Smuzhiyun                Bits         Field Description
469*4882a593Smuzhiyun                [63:60]      ADI version (see Section 36.2.1.1.7, “Application Data
470*4882a593Smuzhiyun                             Integrity (ADI)”)
471*4882a593Smuzhiyun                [59]         If set to 1, a virtual device interrupt will be generated using
472*4882a593Smuzhiyun                             the device interrupt number specified in the lower bits of this
473*4882a593Smuzhiyun                             completion word. If 0, the lower bits of this completion word
474*4882a593Smuzhiyun                             are ignored.
475*4882a593Smuzhiyun                [58:6]       Completion area address bits [58:6]. Address type is
476*4882a593Smuzhiyun                             determined by CCB header.
477*4882a593Smuzhiyun                [5:0]        Virtual device interrupt number for completion interrupt, if
478*4882a593Smuzhiyun                             enabled.
479*4882a593Smuzhiyun16       8      Primary Input
480*4882a593Smuzhiyun                Bits         Field Description
481*4882a593Smuzhiyun                [63:60]      ADI version (see Section 36.2.1.1.7, “Application Data
482*4882a593Smuzhiyun                             Integrity (ADI)”)
483*4882a593Smuzhiyun                [59:56]      If using real address, these bits should be filled in with the
484*4882a593Smuzhiyun                             page size code for the page boundary checking the guest wants
485*4882a593Smuzhiyun                             the virtual machine to use when accessing this data stream
486*4882a593Smuzhiyun                             (checking is only guaranteed to be performed when using API
487*4882a593Smuzhiyun                             version 1.1 and later). If using a virtual address, this field will
488*4882a593Smuzhiyun                             be used as as primary input address bits [59:56].
489*4882a593Smuzhiyun                [55:0]       Primary input address bits [55:0]. Address type is determined
490*4882a593Smuzhiyun                             by CCB header.
491*4882a593Smuzhiyun24       8      Data Access Control
492*4882a593Smuzhiyun                Bits         Field Description
493*4882a593Smuzhiyun                [63:62]      Flow Control
494*4882a593Smuzhiyun                             Value      Description
495*4882a593Smuzhiyun                             0b'00      Disable flow control
496*4882a593Smuzhiyun                             0b'01      Enable flow control (only valid with "ORCL,sun4v-
497*4882a593Smuzhiyun                                        dax-fc" compatible virtual device variants)
498*4882a593Smuzhiyun                             0b'10      Reserved
499*4882a593Smuzhiyun                             0b'11      Reserved
500*4882a593Smuzhiyun                [61:60]      Reserved (API 1.0)
501*4882a593Smuzhiyun
502*4882a593Smuzhiyun
503*4882a593Smuzhiyun                                517
504*4882a593Smuzhiyun                       Coprocessor services
505*4882a593Smuzhiyun
506*4882a593Smuzhiyun
507*4882a593SmuzhiyunOffset   Size   Field Description
508*4882a593Smuzhiyun                Bits        Field Description
509*4882a593Smuzhiyun                            Pipeline target (API 2.0)
510*4882a593Smuzhiyun                            Value      Description
511*4882a593Smuzhiyun                            0b'00      Connect to primary input
512*4882a593Smuzhiyun                            0b'01      Connect to secondary input
513*4882a593Smuzhiyun                            0b'10      Reserved
514*4882a593Smuzhiyun                            0b'11      Reserved
515*4882a593Smuzhiyun                [59:40]     Output buffer size given in units of 64 bytes, minus 1. Value of
516*4882a593Smuzhiyun                            0 means 64 bytes, value of 1 means 128 bytes, etc. Buffer size is
517*4882a593Smuzhiyun                            only enforced if flow control is enabled in Flow Control field.
518*4882a593Smuzhiyun                [39:32]     Reserved
519*4882a593Smuzhiyun                [31:30]     Output Data Cache Allocation
520*4882a593Smuzhiyun                            Value      Description
521*4882a593Smuzhiyun                            0b'00      Do not allocate cache lines for output data stream.
522*4882a593Smuzhiyun                            0b'01      Force cache lines for output data stream to be
523*4882a593Smuzhiyun                                       allocated in the cache that is local to the submitting
524*4882a593Smuzhiyun                                       virtual cpu.
525*4882a593Smuzhiyun                            0b'10      Allocate cache lines for output data stream, but allow
526*4882a593Smuzhiyun                                       existing cache lines associated with the data to remain
527*4882a593Smuzhiyun                                       in their current cache instance. Any memory not
528*4882a593Smuzhiyun                                       already in cache will be allocated in the cache local
529*4882a593Smuzhiyun                                       to the submitting virtual cpu.
530*4882a593Smuzhiyun                            0b'11      Reserved
531*4882a593Smuzhiyun                [29:26]     Reserved
532*4882a593Smuzhiyun                [25:24]     Primary Input Length Format
533*4882a593Smuzhiyun                            Value      Description
534*4882a593Smuzhiyun                            0b'00      Number of primary symbols
535*4882a593Smuzhiyun                            0b'01      Number of primary bytes
536*4882a593Smuzhiyun                            0b'10      Number of primary bits
537*4882a593Smuzhiyun                            0b'11      Reserved
538*4882a593Smuzhiyun                [23:0]      Primary Input Length
539*4882a593Smuzhiyun                            Format                      Field Value
540*4882a593Smuzhiyun                            # of primary symbols        Number of input elements to process,
541*4882a593Smuzhiyun                                                        minus 1. Command execution stops
542*4882a593Smuzhiyun                                                        once count is reached.
543*4882a593Smuzhiyun                            # of primary bytes          Number of input bytes to process,
544*4882a593Smuzhiyun                                                        minus 1. Command execution stops
545*4882a593Smuzhiyun                                                        once count is reached. The count is
546*4882a593Smuzhiyun                                                        done before any decompression or
547*4882a593Smuzhiyun                                                        decoding.
548*4882a593Smuzhiyun                            # of primary bits           Number of input bits to process,
549*4882a593Smuzhiyun                                                        minus 1. Command execution stops
550*4882a593Smuzhiyun
551*4882a593Smuzhiyun
552*4882a593Smuzhiyun
553*4882a593Smuzhiyun                               518
554*4882a593Smuzhiyun                                                Coprocessor services
555*4882a593Smuzhiyun
556*4882a593Smuzhiyun
557*4882a593Smuzhiyun        Offset          Size           Field Description
558*4882a593Smuzhiyun                                        Bits         Field Description
559*4882a593Smuzhiyun                                                     Format                     Field Value
560*4882a593Smuzhiyun                                                                                once count is reached. The count is
561*4882a593Smuzhiyun                                                                                done before any decompression or
562*4882a593Smuzhiyun                                                                                decoding, and does not include any
563*4882a593Smuzhiyun                                                                                bits skipped by the Primary Input
564*4882a593Smuzhiyun                                                                                Offset field value of the command
565*4882a593Smuzhiyun                                                                                control word.
566*4882a593Smuzhiyun        32              8              Secondary Input, if used by Primary Input Format. Same fields as Primary
567*4882a593Smuzhiyun                                       Input.
568*4882a593Smuzhiyun        40              8              Reserved
569*4882a593Smuzhiyun        48              8              Output (same fields as Primary Input)
570*4882a593Smuzhiyun        56              8              Symbol Table (if used by Primary Input)
571*4882a593Smuzhiyun                                        Bits         Field Description
572*4882a593Smuzhiyun                                        [63:60]      ADI version (see Section 36.2.1.1.7, “Application Data
573*4882a593Smuzhiyun                                                     Integrity (ADI)”)
574*4882a593Smuzhiyun                                        [59:56]      If using real address, these bits should be filled in with the
575*4882a593Smuzhiyun                                                     page size code for the page boundary checking the guest wants
576*4882a593Smuzhiyun                                                     the virtual machine to use when accessing this data stream
577*4882a593Smuzhiyun                                                     (checking is only guaranteed to be performed when using API
578*4882a593Smuzhiyun                                                     version 1.1 and later). If using a virtual address, this field will
579*4882a593Smuzhiyun                                                     be used as as symbol table address bits [59:56].
580*4882a593Smuzhiyun                                        [55:4]       Symbol table address bits [55:4]. Address type is determined
581*4882a593Smuzhiyun                                                     by CCB header.
582*4882a593Smuzhiyun                                        [3:0]        Symbol table version
583*4882a593Smuzhiyun                                                     Value     Description
584*4882a593Smuzhiyun                                                     0         Huffman encoding. Must use 64 byte aligned table
585*4882a593Smuzhiyun                                                               address. (Only available when using version 0 CCBs)
586*4882a593Smuzhiyun                                                     1         OZIP encoding. Must use 16 byte aligned table
587*4882a593Smuzhiyun                                                               address. (Only available when using version 1 CCBs)
588*4882a593Smuzhiyun
589*4882a593Smuzhiyun
590*4882a593Smuzhiyun36.2.1.3. Scan commands
591*4882a593Smuzhiyun
592*4882a593Smuzhiyun        The scan commands search a stream of input data elements for values which match the selection criteria.
593*4882a593Smuzhiyun        All the input format types are supported. There are multiple formats for the scan commands, allowing the
594*4882a593Smuzhiyun        scan to search for exact matches to one value, exact matches to either of two values, or any value within
595*4882a593Smuzhiyun        a specified range. The specific type of scan is indicated by the command code in the CCB header. For the
596*4882a593Smuzhiyun        scan range commands, the boundary conditions can be specified as greater-than-or-equal-to a value, less-
597*4882a593Smuzhiyun        than-or-equal-to a value, or both by using two boundary values.
598*4882a593Smuzhiyun
599*4882a593Smuzhiyun        There are two supported formats for the output stream: the bit vector and index array formats (codes 0x8,
600*4882a593Smuzhiyun        0xD, and 0xE). For the standard scan command using the bit vector output, for each input element there
601*4882a593Smuzhiyun        exists one bit in the vector that is set if the input element matched the scan criteria, or clear if not. The
602*4882a593Smuzhiyun        inverted scan command inverts the polarity of the bits in the output. The most significant bit of the first
603*4882a593Smuzhiyun        byte of the output stream corresponds to the first element in the input stream. The standard index array
604*4882a593Smuzhiyun        output format contains one array entry for each input element that matched the scan criteria. Each array
605*4882a593Smuzhiyun
606*4882a593Smuzhiyun
607*4882a593Smuzhiyun
608*4882a593Smuzhiyun                                                         519
609*4882a593Smuzhiyun                                       Coprocessor services
610*4882a593Smuzhiyun
611*4882a593Smuzhiyun
612*4882a593Smuzhiyunentry is the index of an input element that matched the scan criteria. An inverted scan command produces
613*4882a593Smuzhiyuna similar array, but of all the input elements which did NOT match the scan criteria.
614*4882a593Smuzhiyun
615*4882a593SmuzhiyunThe return value of the CCB completion area contains the number of input elements found which match
616*4882a593Smuzhiyunthe scan criteria (or number that did not match for the inverted scans). The “number of elements processed”
617*4882a593Smuzhiyunfield in the CCB completion area will be valid, indicating the number of input elements processed.
618*4882a593Smuzhiyun
619*4882a593SmuzhiyunThese commands are 128-byte “long format” CCBs.
620*4882a593Smuzhiyun
621*4882a593SmuzhiyunThe scan CCB command format can be specified by the following packed C structure for a big-endian
622*4882a593Smuzhiyunmachine:
623*4882a593Smuzhiyun
624*4882a593Smuzhiyun
625*4882a593Smuzhiyun         struct scan_ccb         {
626*4882a593Smuzhiyun                uint32_t         header;
627*4882a593Smuzhiyun                uint32_t         control;
628*4882a593Smuzhiyun                uint64_t         completion;
629*4882a593Smuzhiyun                uint64_t         primary_input;
630*4882a593Smuzhiyun                uint64_t         data_access_control;
631*4882a593Smuzhiyun                uint64_t         secondary_input;
632*4882a593Smuzhiyun                uint64_t         match_criteria0;
633*4882a593Smuzhiyun                uint64_t         output;
634*4882a593Smuzhiyun                uint64_t         table;
635*4882a593Smuzhiyun                uint64_t         match_criteria1;
636*4882a593Smuzhiyun                uint64_t         match_criteria2;
637*4882a593Smuzhiyun                uint64_t         match_criteria3;
638*4882a593Smuzhiyun                uint64_t         reserved[5];
639*4882a593Smuzhiyun         };
640*4882a593Smuzhiyun
641*4882a593Smuzhiyun
642*4882a593SmuzhiyunThe exact field offsets, sizes, and composition are as follows:
643*4882a593Smuzhiyun
644*4882a593SmuzhiyunOffset         Size            Field Description
645*4882a593Smuzhiyun0              4               CCB header (Table 36.1, “CCB Header Format”)
646*4882a593Smuzhiyun4              4               Command control
647*4882a593Smuzhiyun                               Bits         Field Description
648*4882a593Smuzhiyun                               [31:28]      Primary Input Format (see Section 36.2.1.1.1, “Primary Input
649*4882a593Smuzhiyun                                            Format”)
650*4882a593Smuzhiyun                               [27:23]      Primary Input Element Size (see Section 36.2.1.1.2, “Primary
651*4882a593Smuzhiyun                                            Input Element Size”)
652*4882a593Smuzhiyun                               [22:20]      Primary Input Starting Offset (see Section 36.2.1.1.5, “Input
653*4882a593Smuzhiyun                                            Element Offsets”)
654*4882a593Smuzhiyun                               [19]         Secondary Input Format (see Section 36.2.1.1.3, “Secondary
655*4882a593Smuzhiyun                                            Input Format”)
656*4882a593Smuzhiyun                               [18:16]      Secondary Input Starting Offset (see Section 36.2.1.1.5, “Input
657*4882a593Smuzhiyun                                            Element Offsets”)
658*4882a593Smuzhiyun                               [15:14]      Secondary Input Element Size (see Section 36.2.1.1.4,
659*4882a593Smuzhiyun                                            “Secondary Input Element Size”
660*4882a593Smuzhiyun                               [13:10]      Output Format (see Section 36.2.1.1.6, “Output Format”)
661*4882a593Smuzhiyun                               [9:5]        Operand size for first scan criteria value. In a scan value
662*4882a593Smuzhiyun                                            operation, this is one of two potential extact match values.
663*4882a593Smuzhiyun                                            In a scan range operation, this is the size of the upper range
664*4882a593Smuzhiyun
665*4882a593Smuzhiyun
666*4882a593Smuzhiyun                                               520
667*4882a593Smuzhiyun                        Coprocessor services
668*4882a593Smuzhiyun
669*4882a593Smuzhiyun
670*4882a593SmuzhiyunOffset   Size   Field Description
671*4882a593Smuzhiyun                Bits         Field Description
672*4882a593Smuzhiyun                             boundary. The value of this field is the number of bytes in the
673*4882a593Smuzhiyun                             operand, minus 1. Values 0xF-0x1E are reserved. A value of
674*4882a593Smuzhiyun                             0x1F indicates this operand is not in use for this scan operation.
675*4882a593Smuzhiyun                [4:0]        Operand size for second scan criteria value. In a scan value
676*4882a593Smuzhiyun                             operation, this is one of two potential extact match values.
677*4882a593Smuzhiyun                             In a scan range operation, this is the size of the lower range
678*4882a593Smuzhiyun                             boundary. The value of this field is the number of bytes in the
679*4882a593Smuzhiyun                             operand, minus 1. Values 0xF-0x1E are reserved. A value of
680*4882a593Smuzhiyun                             0x1F indicates this operand is not in use for this scan operation.
681*4882a593Smuzhiyun8        8      Completion (same fields as Section 36.2.1.2, “Extract command”)
682*4882a593Smuzhiyun16       8      Primary Input (same fields as Section 36.2.1.2, “Extract command”)
683*4882a593Smuzhiyun24       8      Data Access Control (same fields as Section 36.2.1.2, “Extract command”)
684*4882a593Smuzhiyun32       8      Secondary Input, if used by Primary Input Format. Same fields as Primary
685*4882a593Smuzhiyun                Input.
686*4882a593Smuzhiyun40       4      Most significant 4 bytes of first scan criteria operand. If first operand is less
687*4882a593Smuzhiyun                than 4 bytes, the value is left-aligned to the lowest address bytes.
688*4882a593Smuzhiyun44       4      Most significant 4 bytes of second scan criteria operand. If second operand
689*4882a593Smuzhiyun                is less than 4 bytes, the value is left-aligned to the lowest address bytes.
690*4882a593Smuzhiyun48       8      Output (same fields as Primary Input)
691*4882a593Smuzhiyun56       8      Symbol Table (if used by Primary Input). Same fields as Section 36.2.1.2,
692*4882a593Smuzhiyun                “Extract command”
693*4882a593Smuzhiyun64       4      Next 4 most significant bytes of first scan criteria operand occuring after the
694*4882a593Smuzhiyun                bytes specified at offset 40, if needed by the operand size. If first operand
695*4882a593Smuzhiyun                is less than 8 bytes, the valid bytes are left-aligned to the lowest address.
696*4882a593Smuzhiyun68       4      Next 4 most significant bytes of second scan criteria operand occuring after
697*4882a593Smuzhiyun                the bytes specified at offset 44, if needed by the operand size. If second
698*4882a593Smuzhiyun                operand is less than 8 bytes, the valid bytes are left-aligned to the lowest
699*4882a593Smuzhiyun                address.
700*4882a593Smuzhiyun72       4      Next 4 most significant bytes of first scan criteria operand occuring after the
701*4882a593Smuzhiyun                bytes specified at offset 64, if needed by the operand size. If first operand
702*4882a593Smuzhiyun                is less than 12 bytes, the valid bytes are left-aligned to the lowest address.
703*4882a593Smuzhiyun76       4      Next 4 most significant bytes of second scan criteria operand occuring after
704*4882a593Smuzhiyun                the bytes specified at offset 68, if needed by the operand size. If second
705*4882a593Smuzhiyun                operand is less than 12 bytes, the valid bytes are left-aligned to the lowest
706*4882a593Smuzhiyun                address.
707*4882a593Smuzhiyun80       4      Next 4 most significant bytes of first scan criteria operand occuring after the
708*4882a593Smuzhiyun                bytes specified at offset 72, if needed by the operand size. If first operand
709*4882a593Smuzhiyun                is less than 16 bytes, the valid bytes are left-aligned to the lowest address.
710*4882a593Smuzhiyun84       4      Next 4 most significant bytes of second scan criteria operand occuring after
711*4882a593Smuzhiyun                the bytes specified at offset 76, if needed by the operand size. If second
712*4882a593Smuzhiyun                operand is less than 16 bytes, the valid bytes are left-aligned to the lowest
713*4882a593Smuzhiyun                address.
714*4882a593Smuzhiyun
715*4882a593Smuzhiyun
716*4882a593Smuzhiyun
717*4882a593Smuzhiyun
718*4882a593Smuzhiyun                                521
719*4882a593Smuzhiyun                                               Coprocessor services
720*4882a593Smuzhiyun
721*4882a593Smuzhiyun
722*4882a593Smuzhiyun36.2.1.4. Translate commands
723*4882a593Smuzhiyun
724*4882a593Smuzhiyun        The translate commands takes an input array of indicies, and a table of single bit values indexed by those
725*4882a593Smuzhiyun        indicies, and outputs a bit vector or index array created by reading the tables bit value at each index in
726*4882a593Smuzhiyun        the input array. The output should therefore contain exactly one bit per index in the input data stream,
727*4882a593Smuzhiyun        when outputing as a bit vector. When outputing as an index array, the number of elements depends on the
728*4882a593Smuzhiyun        values read in the bit table, but will always be less than, or equal to, the number of input elements. Only
729*4882a593Smuzhiyun        a restricted subset of the possible input format types are supported. No variable width or Huffman/OZIP
730*4882a593Smuzhiyun        encoded input streams are allowed. The primary input data element size must be 3 bytes or less.
731*4882a593Smuzhiyun
732*4882a593Smuzhiyun        The maximum table index size allowed is 15 bits, however, larger input elements may be used to provide
733*4882a593Smuzhiyun        additional processing of the output values. If 2 or 3 byte values are used, the least significant 15 bits are
734*4882a593Smuzhiyun        used as an index into the bit table. The most significant 9 bits (when using 3-byte input elements) or single
735*4882a593Smuzhiyun        bit (when using 2-byte input elements) are compared against a fixed 9-bit test value provided in the CCB.
736*4882a593Smuzhiyun        If the values match, the value from the bit table is used as the output element value. If the values do not
737*4882a593Smuzhiyun        match, the output data element value is forced to 0.
738*4882a593Smuzhiyun
739*4882a593Smuzhiyun        In the inverted translate operation, the bit value read from bit table is inverted prior to its use. The additional
740*4882a593Smuzhiyun        additional processing based on any additional non-index bits remains unchanged, and still forces the output
741*4882a593Smuzhiyun        element value to 0 on a mismatch. The specific type of translate command is indicated by the command
742*4882a593Smuzhiyun        code in the CCB header.
743*4882a593Smuzhiyun
744*4882a593Smuzhiyun        There are two supported formats for the output stream: the bit vector and index array formats (codes 0x8,
745*4882a593Smuzhiyun        0xD, and 0xE). The index array format is an array of indicies of bits which would have been set if the
746*4882a593Smuzhiyun        output format was a bit array.
747*4882a593Smuzhiyun
748*4882a593Smuzhiyun        The return value of the CCB completion area contains the number of bits set in the output bit vector,
749*4882a593Smuzhiyun        or number of elements in the output index array. The “number of elements processed” field in the CCB
750*4882a593Smuzhiyun        completion area will be valid, indicating the number of input elements processed.
751*4882a593Smuzhiyun
752*4882a593Smuzhiyun        These commands are 64-byte “short format” CCBs.
753*4882a593Smuzhiyun
754*4882a593Smuzhiyun        The translate CCB command format can be specified by the following packed C structure for a big-endian
755*4882a593Smuzhiyun        machine:
756*4882a593Smuzhiyun
757*4882a593Smuzhiyun
758*4882a593Smuzhiyun                 struct translate_ccb {
759*4882a593Smuzhiyun                        uint32_t header;
760*4882a593Smuzhiyun                        uint32_t control;
761*4882a593Smuzhiyun                        uint64_t completion;
762*4882a593Smuzhiyun                        uint64_t primary_input;
763*4882a593Smuzhiyun                        uint64_t data_access_control;
764*4882a593Smuzhiyun                        uint64_t secondary_input;
765*4882a593Smuzhiyun                        uint64_t reserved;
766*4882a593Smuzhiyun                        uint64_t output;
767*4882a593Smuzhiyun                        uint64_t table;
768*4882a593Smuzhiyun                 };
769*4882a593Smuzhiyun
770*4882a593Smuzhiyun
771*4882a593Smuzhiyun        The exact field offsets, sizes, and composition are as follows:
772*4882a593Smuzhiyun
773*4882a593Smuzhiyun
774*4882a593Smuzhiyun        Offset          Size             Field Description
775*4882a593Smuzhiyun        0               4                CCB header (Table 36.1, “CCB Header Format”)
776*4882a593Smuzhiyun
777*4882a593Smuzhiyun
778*4882a593Smuzhiyun                                                        522
779*4882a593Smuzhiyun                        Coprocessor services
780*4882a593Smuzhiyun
781*4882a593Smuzhiyun
782*4882a593SmuzhiyunOffset   Size   Field Description
783*4882a593Smuzhiyun4        4      Command control
784*4882a593Smuzhiyun                Bits         Field Description
785*4882a593Smuzhiyun                [31:28]      Primary Input Format (see Section 36.2.1.1.1, “Primary Input
786*4882a593Smuzhiyun                             Format”)
787*4882a593Smuzhiyun                [27:23]      Primary Input Element Size (see Section 36.2.1.1.2, “Primary
788*4882a593Smuzhiyun                             Input Element Size”)
789*4882a593Smuzhiyun                [22:20]      Primary Input Starting Offset (see Section 36.2.1.1.5, “Input
790*4882a593Smuzhiyun                             Element Offsets”)
791*4882a593Smuzhiyun                [19]         Secondary Input Format (see Section 36.2.1.1.3, “Secondary
792*4882a593Smuzhiyun                             Input Format”)
793*4882a593Smuzhiyun                [18:16]      Secondary Input Starting Offset (see Section 36.2.1.1.5, “Input
794*4882a593Smuzhiyun                             Element Offsets”)
795*4882a593Smuzhiyun                [15:14]      Secondary Input Element Size (see Section 36.2.1.1.4,
796*4882a593Smuzhiyun                             “Secondary Input Element Size”
797*4882a593Smuzhiyun                [13:10]      Output Format (see Section 36.2.1.1.6, “Output Format”)
798*4882a593Smuzhiyun                [9]          Reserved
799*4882a593Smuzhiyun                [8:0]        Test value used for comparison against the most significant bits
800*4882a593Smuzhiyun                             in the input values, when using 2 or 3 byte input elements.
801*4882a593Smuzhiyun8        8      Completion (same fields as Section 36.2.1.2, “Extract command”
802*4882a593Smuzhiyun16       8      Primary Input (same fields as Section 36.2.1.2, “Extract command”
803*4882a593Smuzhiyun24       8      Data Access Control (same fields as Section 36.2.1.2, “Extract command”,
804*4882a593Smuzhiyun                except Primary Input Length Format may not use the 0x0 value)
805*4882a593Smuzhiyun32       8      Secondary Input, if used by Primary Input Format. Same fields as Primary
806*4882a593Smuzhiyun                Input.
807*4882a593Smuzhiyun40       8      Reserved
808*4882a593Smuzhiyun48       8      Output (same fields as Primary Input)
809*4882a593Smuzhiyun56       8      Bit Table
810*4882a593Smuzhiyun                Bits         Field Description
811*4882a593Smuzhiyun                [63:60]      ADI version (see Section 36.2.1.1.7, “Application Data
812*4882a593Smuzhiyun                             Integrity (ADI)”)
813*4882a593Smuzhiyun                [59:56]      If using real address, these bits should be filled in with the
814*4882a593Smuzhiyun                             page size code for the page boundary checking the guest wants
815*4882a593Smuzhiyun                             the virtual machine to use when accessing this data stream
816*4882a593Smuzhiyun                             (checking is only guaranteed to be performed when using API
817*4882a593Smuzhiyun                             version 1.1 and later). If using a virtual address, this field will
818*4882a593Smuzhiyun                             be used as as bit table address bits [59:56]
819*4882a593Smuzhiyun                [55:4]       Bit table address bits [55:4]. Address type is determined by
820*4882a593Smuzhiyun                             CCB header. Address must be 64-byte aligned (CCB version
821*4882a593Smuzhiyun                             0) or 16-byte aligned (CCB version 1).
822*4882a593Smuzhiyun                [3:0]        Bit table version
823*4882a593Smuzhiyun                             Value      Description
824*4882a593Smuzhiyun                             0          4KB table size
825*4882a593Smuzhiyun                             1          8KB table size
826*4882a593Smuzhiyun
827*4882a593Smuzhiyun
828*4882a593Smuzhiyun
829*4882a593Smuzhiyun                                 523
830*4882a593Smuzhiyun                                              Coprocessor services
831*4882a593Smuzhiyun
832*4882a593Smuzhiyun
833*4882a593Smuzhiyun36.2.1.5. Select command
834*4882a593Smuzhiyun        The select command filters the primary input data stream by using a secondary input bit vector to determine
835*4882a593Smuzhiyun        which input elements to include in the output. For each bit set at a given index N within the bit vector,
836*4882a593Smuzhiyun        the Nth input element is included in the output. If the bit is not set, the element is not included. Only a
837*4882a593Smuzhiyun        restricted subset of the possible input format types are supported. No variable width or run length encoded
838*4882a593Smuzhiyun        input streams are allowed, since the secondary input stream is used for the filtering bit vector.
839*4882a593Smuzhiyun
840*4882a593Smuzhiyun        The only supported output format is a padded, byte-aligned output stream. The stream follows the same
841*4882a593Smuzhiyun        rules and restrictions as padded output stream described in Section 36.2.1.2, “Extract command”.
842*4882a593Smuzhiyun
843*4882a593Smuzhiyun        The return value of the CCB completion area contains the number of bits set in the input bit vector. The
844*4882a593Smuzhiyun        "number of elements processed" field in the CCB completion area will be valid, indicating the number
845*4882a593Smuzhiyun        of input elements processed.
846*4882a593Smuzhiyun
847*4882a593Smuzhiyun        The select CCB is a 64-byte “short format” CCB.
848*4882a593Smuzhiyun
849*4882a593Smuzhiyun        The select CCB command format can be specified by the following packed C structure for a big-endian
850*4882a593Smuzhiyun        machine:
851*4882a593Smuzhiyun
852*4882a593Smuzhiyun
853*4882a593Smuzhiyun                  struct select_ccb {
854*4882a593Smuzhiyun                         uint32_t header;
855*4882a593Smuzhiyun                         uint32_t control;
856*4882a593Smuzhiyun                         uint64_t completion;
857*4882a593Smuzhiyun                         uint64_t primary_input;
858*4882a593Smuzhiyun                         uint64_t data_access_control;
859*4882a593Smuzhiyun                         uint64_t secondary_input;
860*4882a593Smuzhiyun                         uint64_t reserved;
861*4882a593Smuzhiyun                         uint64_t output;
862*4882a593Smuzhiyun                         uint64_t table;
863*4882a593Smuzhiyun                  };
864*4882a593Smuzhiyun
865*4882a593Smuzhiyun
866*4882a593Smuzhiyun        The exact field offsets, sizes, and composition are as follows:
867*4882a593Smuzhiyun
868*4882a593Smuzhiyun         Offset        Size            Field Description
869*4882a593Smuzhiyun         0             4               CCB header (Table 36.1, “CCB Header Format”)
870*4882a593Smuzhiyun         4             4               Command control
871*4882a593Smuzhiyun                                       Bits        Field Description
872*4882a593Smuzhiyun                                       [31:28]     Primary Input Format (see Section 36.2.1.1.1, “Primary Input
873*4882a593Smuzhiyun                                                   Format”)
874*4882a593Smuzhiyun                                       [27:23]     Primary Input Element Size (see Section 36.2.1.1.2, “Primary
875*4882a593Smuzhiyun                                                   Input Element Size”)
876*4882a593Smuzhiyun                                       [22:20]     Primary Input Starting Offset (see Section 36.2.1.1.5, “Input
877*4882a593Smuzhiyun                                                   Element Offsets”)
878*4882a593Smuzhiyun                                       [19]        Secondary Input Format (see Section 36.2.1.1.3, “Secondary
879*4882a593Smuzhiyun                                                   Input Format”)
880*4882a593Smuzhiyun                                       [18:16]     Secondary Input Starting Offset (see Section 36.2.1.1.5, “Input
881*4882a593Smuzhiyun                                                   Element Offsets”)
882*4882a593Smuzhiyun                                       [15:14]     Secondary Input Element Size (see Section 36.2.1.1.4,
883*4882a593Smuzhiyun                                                   “Secondary Input Element Size”
884*4882a593Smuzhiyun
885*4882a593Smuzhiyun
886*4882a593Smuzhiyun                                                      524
887*4882a593Smuzhiyun                                               Coprocessor services
888*4882a593Smuzhiyun
889*4882a593Smuzhiyun
890*4882a593Smuzhiyun        Offset         Size            Field Description
891*4882a593Smuzhiyun                                       Bits         Field Description
892*4882a593Smuzhiyun                                       [13:10]      Output Format (see Section 36.2.1.1.6, “Output Format”)
893*4882a593Smuzhiyun                                       [9]          Padding Direction selector: A value of 1 causes padding bytes
894*4882a593Smuzhiyun                                                    to be added to the left side of output elements. A value of 0
895*4882a593Smuzhiyun                                                    causes padding bytes to be added to the right side of output
896*4882a593Smuzhiyun                                                    elements.
897*4882a593Smuzhiyun                                       [8:0]        Reserved
898*4882a593Smuzhiyun        8              8               Completion (same fields as Section 36.2.1.2, “Extract command”
899*4882a593Smuzhiyun        16             8               Primary Input (same fields as Section 36.2.1.2, “Extract command”
900*4882a593Smuzhiyun        24             8               Data Access Control (same fields as Section 36.2.1.2, “Extract command”)
901*4882a593Smuzhiyun        32             8               Secondary Bit Vector Input. Same fields as Primary Input.
902*4882a593Smuzhiyun        40             8               Reserved
903*4882a593Smuzhiyun        48             8               Output (same fields as Primary Input)
904*4882a593Smuzhiyun        56             8               Symbol Table (if used by Primary Input). Same fields as Section 36.2.1.2,
905*4882a593Smuzhiyun                                       “Extract command”
906*4882a593Smuzhiyun
907*4882a593Smuzhiyun36.2.1.6. No-op and Sync commands
908*4882a593Smuzhiyun        The no-op (no operation) command is a CCB which has no processing effect. The CCB, when processed
909*4882a593Smuzhiyun        by the virtual machine, simply updates the completion area with its execution status. The CCB may have
910*4882a593Smuzhiyun        the serial-conditional flags set in order to restrict when it executes.
911*4882a593Smuzhiyun
912*4882a593Smuzhiyun        The sync command is a variant of the no-op command which with restricted execution timing. A sync
913*4882a593Smuzhiyun        command CCB will only execute when all previous commands submitted in the same request have
914*4882a593Smuzhiyun        completed. This is stronger than the conditional flag sequencing, which is only dependent on a single
915*4882a593Smuzhiyun        previous serial CCB. While the relative ordering is guaranteed, virtual machine implementations with
916*4882a593Smuzhiyun        shared hardware resources may cause the sync command to wait for longer than the minimum required
917*4882a593Smuzhiyun        time.
918*4882a593Smuzhiyun
919*4882a593Smuzhiyun        The return value of the CCB completion area is invalid for these CCBs. The “number of elements
920*4882a593Smuzhiyun        processed” field is also invalid for these CCBs.
921*4882a593Smuzhiyun
922*4882a593Smuzhiyun        These commands are 64-byte “short format” CCBs.
923*4882a593Smuzhiyun
924*4882a593Smuzhiyun        The no-op CCB command format can be specified by the following packed C structure for a big-endian
925*4882a593Smuzhiyun        machine:
926*4882a593Smuzhiyun
927*4882a593Smuzhiyun
928*4882a593Smuzhiyun                 struct nop_ccb {
929*4882a593Smuzhiyun                        uint32_t header;
930*4882a593Smuzhiyun                        uint32_t control;
931*4882a593Smuzhiyun                        uint64_t completion;
932*4882a593Smuzhiyun                        uint64_t reserved[6];
933*4882a593Smuzhiyun                 };
934*4882a593Smuzhiyun
935*4882a593Smuzhiyun
936*4882a593Smuzhiyun        The exact field offsets, sizes, and composition are as follows:
937*4882a593Smuzhiyun
938*4882a593Smuzhiyun        Offset         Size            Field Description
939*4882a593Smuzhiyun        0              4               CCB header (Table 36.1, “CCB Header Format”)
940*4882a593Smuzhiyun
941*4882a593Smuzhiyun
942*4882a593Smuzhiyun                                                       525
943*4882a593Smuzhiyun                                          Coprocessor services
944*4882a593Smuzhiyun
945*4882a593Smuzhiyun
946*4882a593Smuzhiyun       Offset        Size          Field Description
947*4882a593Smuzhiyun       4             4             Command control
948*4882a593Smuzhiyun                                   Bits        Field Description
949*4882a593Smuzhiyun                                   [31]        If set, this CCB functions as a Sync command. If clear, this
950*4882a593Smuzhiyun                                               CCB functions as a No-op command.
951*4882a593Smuzhiyun                                   [30:0]      Reserved
952*4882a593Smuzhiyun       8             8             Completion (same fields as Section 36.2.1.2, “Extract command”
953*4882a593Smuzhiyun       16            46            Reserved
954*4882a593Smuzhiyun
955*4882a593Smuzhiyun36.2.2. CCB Completion Area
956*4882a593Smuzhiyun       All CCB commands use a common 128-byte Completion Area format, which can be specified by the
957*4882a593Smuzhiyun       following packed C structure for a big-endian machine:
958*4882a593Smuzhiyun
959*4882a593Smuzhiyun
960*4882a593Smuzhiyun                struct completion_area {
961*4882a593Smuzhiyun                       uint8_t status_flag;
962*4882a593Smuzhiyun                       uint8_t error_note;
963*4882a593Smuzhiyun                       uint8_t rsvd0[2];
964*4882a593Smuzhiyun                       uint32_t error_values;
965*4882a593Smuzhiyun                       uint32_t output_size;
966*4882a593Smuzhiyun                       uint32_t rsvd1;
967*4882a593Smuzhiyun                       uint64_t run_time;
968*4882a593Smuzhiyun                       uint64_t run_stats;
969*4882a593Smuzhiyun                       uint32_t elements;
970*4882a593Smuzhiyun                       uint8_t rsvd2[20];
971*4882a593Smuzhiyun                       uint64_t return_value;
972*4882a593Smuzhiyun                       uint64_t extra_return_value[8];
973*4882a593Smuzhiyun                };
974*4882a593Smuzhiyun
975*4882a593Smuzhiyun
976*4882a593Smuzhiyun       The Completion Area must be a 128-byte aligned memory location. The exact layout can be described
977*4882a593Smuzhiyun       using byte offsets and sizes relative to the memory base:
978*4882a593Smuzhiyun
979*4882a593Smuzhiyun       Offset        Size          Field Description
980*4882a593Smuzhiyun       0             1             CCB execution status
981*4882a593Smuzhiyun                                   0x0                  Command not yet completed
982*4882a593Smuzhiyun                                   0x1                  Command ran and succeeded
983*4882a593Smuzhiyun                                   0x2                  Command ran and failed (partial results may be been
984*4882a593Smuzhiyun                                                        produced)
985*4882a593Smuzhiyun                                   0x3                  Command ran and was killed (partial execution may
986*4882a593Smuzhiyun                                                        have occurred)
987*4882a593Smuzhiyun                                   0x4                  Command was not run
988*4882a593Smuzhiyun                                   0x5-0xF              Reserved
989*4882a593Smuzhiyun       1             1             Error reason code
990*4882a593Smuzhiyun                                   0x0                  Reserved
991*4882a593Smuzhiyun                                   0x1                  Buffer overflow
992*4882a593Smuzhiyun
993*4882a593Smuzhiyun
994*4882a593Smuzhiyun                                                  526
995*4882a593Smuzhiyun                                      Coprocessor services
996*4882a593Smuzhiyun
997*4882a593Smuzhiyun
998*4882a593SmuzhiyunOffset          Size           Field Description
999*4882a593Smuzhiyun                                0x2                 CCB decoding error
1000*4882a593Smuzhiyun                                0x3                 Page overflow
1001*4882a593Smuzhiyun                                0x4-0x6             Reserved
1002*4882a593Smuzhiyun                                0x7                 Command was killed
1003*4882a593Smuzhiyun                                0x8                 Command execution timeout
1004*4882a593Smuzhiyun                                0x9                 ADI miscompare error
1005*4882a593Smuzhiyun                                0xA                 Data format error
1006*4882a593Smuzhiyun                                0xB-0xD             Reserved
1007*4882a593Smuzhiyun                                0xE                 Unexpected hardware error (Do not retry)
1008*4882a593Smuzhiyun                                0xF                 Unexpected hardware error (Retry is ok)
1009*4882a593Smuzhiyun                                0x10-0x7F           Reserved
1010*4882a593Smuzhiyun                                0x80                Partial Symbol Warning
1011*4882a593Smuzhiyun                                0x81-0xFF           Reserved
1012*4882a593Smuzhiyun2               2              Reserved
1013*4882a593Smuzhiyun4               4              If a partial symbol warning was generated, this field contains the number
1014*4882a593Smuzhiyun                               of remaining bits which were not decoded.
1015*4882a593Smuzhiyun8               4              Number of bytes of output produced
1016*4882a593Smuzhiyun12              4              Reserved
1017*4882a593Smuzhiyun16              8              Runtime of command (unspecified time units)
1018*4882a593Smuzhiyun24              8              Reserved
1019*4882a593Smuzhiyun32              4              Number of elements processed
1020*4882a593Smuzhiyun36              20             Reserved
1021*4882a593Smuzhiyun56              8              Return value
1022*4882a593Smuzhiyun64              64             Extended return value
1023*4882a593Smuzhiyun
1024*4882a593SmuzhiyunThe CCB completion area should be treated as read-only by guest software. The CCB execution status
1025*4882a593Smuzhiyunbyte will be cleared by the Hypervisor to reflect the pending execution status when the CCB is submitted
1026*4882a593Smuzhiyunsuccessfully. All other fields are considered invalid upon CCB submission until the CCB execution status
1027*4882a593Smuzhiyunbyte becomes non-zero.
1028*4882a593Smuzhiyun
1029*4882a593SmuzhiyunCCBs which complete with status 0x2 or 0x3 may produce partial results and/or side effects due to partial
1030*4882a593Smuzhiyunexecution of the CCB command. Some valid data may be accessible depending on the fault type, however,
1031*4882a593Smuzhiyunit is recommended that guest software treat the destination buffer as being in an unknown state. If a CCB
1032*4882a593Smuzhiyuncompletes with a status byte of 0x2, the error reason code byte can be read to determine what corrective
1033*4882a593Smuzhiyunaction should be taken.
1034*4882a593Smuzhiyun
1035*4882a593SmuzhiyunA buffer overflow indicates that the results of the operation exceeded the size of the output buffer indicated
1036*4882a593Smuzhiyunin the CCB. The operation can be retried by resubmitting the CCB with a larger output buffer.
1037*4882a593Smuzhiyun
1038*4882a593SmuzhiyunA CCB decoding error indicates that the CCB contained some invalid field values. It may be also be
1039*4882a593Smuzhiyuntriggered if the CCB output is directed at a non-existent secondary input and the pipelining hint is followed.
1040*4882a593Smuzhiyun
1041*4882a593SmuzhiyunA page overflow error indicates that the operation required accessing a memory location beyond the page
1042*4882a593Smuzhiyunsize associated with a given address. No data will have been read or written past the page boundary, but
1043*4882a593Smuzhiyunpartial results may have been written to the destination buffer. The CCB can be resubmitted with a larger
1044*4882a593Smuzhiyunpage size memory allocation to complete the operation.
1045*4882a593Smuzhiyun
1046*4882a593Smuzhiyun
1047*4882a593Smuzhiyun                                              527
1048*4882a593Smuzhiyun                                            Coprocessor services
1049*4882a593Smuzhiyun
1050*4882a593Smuzhiyun
1051*4882a593Smuzhiyun       In the case of pipelined CCBs, a page overflow error will be triggered if the output from the pipeline source
1052*4882a593Smuzhiyun       CCB ends before the input of the pipeline target CCB. Page boundaries are ignored when the pipeline
1053*4882a593Smuzhiyun       hint is followed.
1054*4882a593Smuzhiyun
1055*4882a593Smuzhiyun       Command kill indicates that the CCB execution was halted or prevented by use of the ccb_kill API call.
1056*4882a593Smuzhiyun
1057*4882a593Smuzhiyun       Command timeout indicates that the CCB execution began, but did not complete within a pre-determined
1058*4882a593Smuzhiyun       limit set by the virtual machine. The command may have produced some or no output. The CCB may be
1059*4882a593Smuzhiyun       resubmitted with no alterations.
1060*4882a593Smuzhiyun
1061*4882a593Smuzhiyun       ADI miscompare indicates that the memory buffer version specified in the CCB did not match the value
1062*4882a593Smuzhiyun       in memory when accessed by the virtual machine. Guest software should not attempt to resubmit the CCB
1063*4882a593Smuzhiyun       without determining the cause of the version mismatch.
1064*4882a593Smuzhiyun
1065*4882a593Smuzhiyun       A data format error indicates that the input data stream did not follow the specified data input formatting
1066*4882a593Smuzhiyun       selected in the CCB.
1067*4882a593Smuzhiyun
1068*4882a593Smuzhiyun       Some CCBs which encounter hardware errors may be resubmitted without change. Persistent hardware
1069*4882a593Smuzhiyun       errors may result in multiple failures until RAS software can identify and isolate the faulty component.
1070*4882a593Smuzhiyun
1071*4882a593Smuzhiyun       The output size field indicates the number of bytes of valid output in the destination buffer. This field is
1072*4882a593Smuzhiyun       not valid for all possible CCB commands.
1073*4882a593Smuzhiyun
1074*4882a593Smuzhiyun       The runtime field indicates the execution time of the CCB command once it leaves the internal virtual
1075*4882a593Smuzhiyun       machine queue. The time units are fixed, but unspecified, allowing only relative timing comparisons
1076*4882a593Smuzhiyun       by guest software. The time units may also vary by hardware platform, and should not be construed to
1077*4882a593Smuzhiyun       represent any absolute time value.
1078*4882a593Smuzhiyun
1079*4882a593Smuzhiyun       Some data query commands process data in units of elements. If applicable to the command, the number of
1080*4882a593Smuzhiyun       elements processed is indicated in the listed field. This field is not valid for all possible CCB commands.
1081*4882a593Smuzhiyun
1082*4882a593Smuzhiyun       The return value and extended return value fields are output locations for commands which do not use
1083*4882a593Smuzhiyun       a destination output buffer, or have secondary return results. The field is not valid for all possible CCB
1084*4882a593Smuzhiyun       commands.
1085*4882a593Smuzhiyun
1086*4882a593Smuzhiyun36.3. Hypervisor API Functions
1087*4882a593Smuzhiyun36.3.1. ccb_submit
1088*4882a593Smuzhiyun       trap#             FAST_TRAP
1089*4882a593Smuzhiyun       function#         CCB_SUBMIT
1090*4882a593Smuzhiyun       arg0              address
1091*4882a593Smuzhiyun       arg1              length
1092*4882a593Smuzhiyun       arg2              flags
1093*4882a593Smuzhiyun       arg3              reserved
1094*4882a593Smuzhiyun       ret0              status
1095*4882a593Smuzhiyun       ret1              length
1096*4882a593Smuzhiyun       ret2              status data
1097*4882a593Smuzhiyun       ret3              reserved
1098*4882a593Smuzhiyun
1099*4882a593Smuzhiyun       Submit one or more coprocessor control blocks (CCBs) for evaluation and processing by the virtual
1100*4882a593Smuzhiyun       machine. The CCBs are passed in a linear array indicated by address. length indicates the size of
1101*4882a593Smuzhiyun       the array in bytes.
1102*4882a593Smuzhiyun
1103*4882a593Smuzhiyun
1104*4882a593Smuzhiyun                                                     528
1105*4882a593Smuzhiyun                                      Coprocessor services
1106*4882a593Smuzhiyun
1107*4882a593Smuzhiyun
1108*4882a593SmuzhiyunThe address should be aligned to the size indicated by length, rounded up to the nearest power of
1109*4882a593Smuzhiyuntwo. Virtual machines implementations may reject submissions which do not adhere to that alignment.
1110*4882a593Smuzhiyunlength must be a multiple of 64 bytes. If length is zero, the maximum supported array length will be
1111*4882a593Smuzhiyunreturned as length in ret1. In all other cases, the length value in ret1 will reflect the number of bytes
1112*4882a593Smuzhiyunsuccessfully consumed from the input CCB array.
1113*4882a593Smuzhiyun
1114*4882a593Smuzhiyun      Implementation note
1115*4882a593Smuzhiyun      Virtual machines should never reject submissions based on the alignment of address if the
1116*4882a593Smuzhiyun      entire array is contained within a single memory page of the smallest page size supported by the
1117*4882a593Smuzhiyun      virtual machine.
1118*4882a593Smuzhiyun
1119*4882a593SmuzhiyunA guest may choose to submit addresses used in this API function, including the CCB array address,
1120*4882a593Smuzhiyunas either a real or virtual addresses, with the type of each address indicated in flags. Virtual addresses
1121*4882a593Smuzhiyunmust be present in either the TLB or an active TSB to be processed. The translation context for virtual
1122*4882a593Smuzhiyunaddresses is determined by a combination of CCB contents and the flags argument.
1123*4882a593Smuzhiyun
1124*4882a593SmuzhiyunThe flags argument is divided into multiple fields defined as follows:
1125*4882a593Smuzhiyun
1126*4882a593Smuzhiyun
1127*4882a593SmuzhiyunBits            Field Description
1128*4882a593Smuzhiyun[63:16]         Reserved
1129*4882a593Smuzhiyun[15]            Disable ADI for VA reads (in API 2.0)
1130*4882a593Smuzhiyun                Reserved (in API 1.0)
1131*4882a593Smuzhiyun[14]            Virtual addresses within CCBs are translated in privileged context
1132*4882a593Smuzhiyun[13:12]         Alternate translation context for virtual addresses within CCBs:
1133*4882a593Smuzhiyun                 0b'00        CCBs requesting alternate context are rejected
1134*4882a593Smuzhiyun                 0b'01        Reserved
1135*4882a593Smuzhiyun                 0b'10        CCBs requesting alternate context use secondary context
1136*4882a593Smuzhiyun                 0b'11        CCBs requesting alternate context use nucleus context
1137*4882a593Smuzhiyun[11:9]          Reserved
1138*4882a593Smuzhiyun[8]             Queue info flag
1139*4882a593Smuzhiyun[7]             All-or-nothing flag
1140*4882a593Smuzhiyun[6]             If address is a virtual address, treat its translation context as privileged
1141*4882a593Smuzhiyun[5:4]           Address type of address:
1142*4882a593Smuzhiyun                 0b'00        Real address
1143*4882a593Smuzhiyun                 0b'01        Virtual address in primary context
1144*4882a593Smuzhiyun                 0b'10        Virtual address in secondary context
1145*4882a593Smuzhiyun                 0b'11        Virtual address in nucleus context
1146*4882a593Smuzhiyun[3:2]           Reserved
1147*4882a593Smuzhiyun[1:0]           CCB command type:
1148*4882a593Smuzhiyun                 0b'00        Reserved
1149*4882a593Smuzhiyun                 0b'01        Reserved
1150*4882a593Smuzhiyun                 0b'10        Query command
1151*4882a593Smuzhiyun                 0b'11        Reserved
1152*4882a593Smuzhiyun
1153*4882a593Smuzhiyun
1154*4882a593Smuzhiyun
1155*4882a593Smuzhiyun                                              529
1156*4882a593Smuzhiyun                                             Coprocessor services
1157*4882a593Smuzhiyun
1158*4882a593Smuzhiyun
1159*4882a593Smuzhiyun         The CCB submission type and address type for the CCB array must be provided in the flags argument.
1160*4882a593Smuzhiyun         All other fields are optional values which change the default behavior of the CCB processing.
1161*4882a593Smuzhiyun
1162*4882a593Smuzhiyun         When set to one, the "Disable ADI for VA reads" bit will turn off ADI checking when using a virtual
1163*4882a593Smuzhiyun         address to load data. ADI checking will still be done when loading real-addressed memory. This bit is only
1164*4882a593Smuzhiyun         available when using major version 2 of the coprocessor API group; at major version 1 it is reserved. For
1165*4882a593Smuzhiyun         more information about using ADI and DAX, see Section 36.2.1.1.7, “Application Data Integrity (ADI)”.
1166*4882a593Smuzhiyun
1167*4882a593Smuzhiyun         By default, all virtual addresses are treated as user addresses. If the virtual address translations are
1168*4882a593Smuzhiyun         privileged, they must be marked as such in the appropriate flags field. The virtual addresses used within
1169*4882a593Smuzhiyun         the submitted CCBs must all be translated with the same privilege level.
1170*4882a593Smuzhiyun
1171*4882a593Smuzhiyun         By default, all virtual addresses used within the submitted CCBs are translated using the primary context
1172*4882a593Smuzhiyun         active at the time of the submission. The address type field within a CCB allows each address to request
1173*4882a593Smuzhiyun         translation in an alternate address context. The address context used when the alternate address context is
1174*4882a593Smuzhiyun         requested is selected in the flags argument.
1175*4882a593Smuzhiyun
1176*4882a593Smuzhiyun         The all-or-nothing flag specifies whether the virtual machine should allow partial submissions of the
1177*4882a593Smuzhiyun         input CCB array. When using CCBs with serial-conditional flags, it is strongly recommended to use
1178*4882a593Smuzhiyun         the all-or-nothing flag to avoid broken conditional chains. Using long CCB chains on a machine under
1179*4882a593Smuzhiyun         high coprocessor load may make this impractical, however, and require submitting without the flag.
1180*4882a593Smuzhiyun         When submitting serial-conditional CCBs without the all-or-nothing flag, guest software must manually
1181*4882a593Smuzhiyun         implement the serial-conditional behavior at any point where the chain was not submitted in a single API
1182*4882a593Smuzhiyun         call, and resubmission of the remaining CCBs should clear any conditional flag that might be set in the
1183*4882a593Smuzhiyun         first remaining CCB. Failure to do so will produce indeterminate CCB execution status and ordering.
1184*4882a593Smuzhiyun
1185*4882a593Smuzhiyun         When the all-or-nothing flag is not specified, callers should check the value of length in ret1 to determine
1186*4882a593Smuzhiyun         how many CCBs from the array were successfully submitted. Any remaining CCBs can be resubmitted
1187*4882a593Smuzhiyun         without modifications.
1188*4882a593Smuzhiyun
1189*4882a593Smuzhiyun         The value of length in ret1 is also valid when the API call returns an error, and callers should always
1190*4882a593Smuzhiyun         check its value to determine which CCBs in the array were already processed. This will additionally
1191*4882a593Smuzhiyun         identify which CCB encountered the processing error, and was not submitted successfully.
1192*4882a593Smuzhiyun
1193*4882a593Smuzhiyun         If the queue info flag is used during submission, and at least one CCB was successfully submitted, the
1194*4882a593Smuzhiyun         length value in ret1 will be a multi-field value defined as follows:
1195*4882a593Smuzhiyun          Bits          Field Description
1196*4882a593Smuzhiyun          [63:48]       DAX unit instance identifier
1197*4882a593Smuzhiyun          [47:32]       DAX queue instance identifier
1198*4882a593Smuzhiyun          [31:16]       Reserved
1199*4882a593Smuzhiyun          [15:0]        Number of CCB bytes successfully submitted
1200*4882a593Smuzhiyun
1201*4882a593Smuzhiyun         The value of status data depends on the status value. See error status code descriptions for details.
1202*4882a593Smuzhiyun         The value is undefined for status values that do not specifically list a value for the status data.
1203*4882a593Smuzhiyun
1204*4882a593Smuzhiyun         The API has a reserved input and output register which will be used in subsequent minor versions of this
1205*4882a593Smuzhiyun         API function. Guest software implementations should treat that register as voltile across the function call
1206*4882a593Smuzhiyun         in order to maintain forward compatibility.
1207*4882a593Smuzhiyun
1208*4882a593Smuzhiyun36.3.1.1. Errors
1209*4882a593Smuzhiyun          EOK                       One or more CCBs have been accepted and enqueued in the virtual machine
1210*4882a593Smuzhiyun                                    and no errors were been encountered during submission. Some submitted
1211*4882a593Smuzhiyun                                    CCBs may not have been enqueued due to internal virtual machine limitations,
1212*4882a593Smuzhiyun                                    and may be resubmitted without changes.
1213*4882a593Smuzhiyun
1214*4882a593Smuzhiyun
1215*4882a593Smuzhiyun                                                       530
1216*4882a593Smuzhiyun                        Coprocessor services
1217*4882a593Smuzhiyun
1218*4882a593Smuzhiyun
1219*4882a593SmuzhiyunEWOULDBLOCK    An internal resource conflict within the virtual machine has prevented it from
1220*4882a593Smuzhiyun               being able to complete the CCB submissions sufficiently quickly, requiring
1221*4882a593Smuzhiyun               it to abandon processing before it was complete. Some CCBs may have been
1222*4882a593Smuzhiyun               successfully enqueued prior to the block, and all remaining CCBs may be
1223*4882a593Smuzhiyun               resubmitted without changes.
1224*4882a593SmuzhiyunEBADALIGN      CCB array is not on a 64-byte boundary, or the array length is not a multiple
1225*4882a593Smuzhiyun               of 64 bytes.
1226*4882a593SmuzhiyunENORADDR       A real address used either for the CCB array, or within one of the submitted
1227*4882a593Smuzhiyun               CCBs, is not valid for the guest. Some CCBs may have been enqueued prior
1228*4882a593Smuzhiyun               to the error being detected.
1229*4882a593SmuzhiyunENOMAP         A virtual address used either for the CCB array, or within one of the submitted
1230*4882a593Smuzhiyun               CCBs, could not be translated by the virtual machine using either the TLB
1231*4882a593Smuzhiyun               or TSB contents. The submission may be retried after adding the required
1232*4882a593Smuzhiyun               mapping, or by converting the virtual address into a real address. Due to the
1233*4882a593Smuzhiyun               shared nature of address translation resources, there is no theoretical limit on
1234*4882a593Smuzhiyun               the number of times the translation may fail, and it is recommended all guests
1235*4882a593Smuzhiyun               implement some real address based backup. The virtual address which failed
1236*4882a593Smuzhiyun               translation is returned as status data in ret2. Some CCBs may have been
1237*4882a593Smuzhiyun               enqueued prior to the error being detected.
1238*4882a593SmuzhiyunEINVAL         The virtual machine detected an invalid CCB during submission, or invalid
1239*4882a593Smuzhiyun               input arguments, such as bad flag values. Note that not all invalid CCB values
1240*4882a593Smuzhiyun               will be detected during submission, and some may be reported as errors in the
1241*4882a593Smuzhiyun               completion area instead. Some CCBs may have been enqueued prior to the
1242*4882a593Smuzhiyun               error being detected. This error may be returned if the CCB version is invalid.
1243*4882a593SmuzhiyunETOOMANY       The request was submitted with the all-or-nothing flag set, and the array size is
1244*4882a593Smuzhiyun               greater than the virtual machine can support in a single request. The maximum
1245*4882a593Smuzhiyun               supported size for the current virtual machine can be queried by submitting a
1246*4882a593Smuzhiyun               request with a zero length array, as described above.
1247*4882a593SmuzhiyunENOACCESS      The guest does not have permission to submit CCBs, or an address used in a
1248*4882a593Smuzhiyun               CCBs lacks sufficient permissions to perform the required operation (no write
1249*4882a593Smuzhiyun               permission on the destination buffer address, for example). A virtual address
1250*4882a593Smuzhiyun               which fails permission checking is returned as status data in ret2. Some
1251*4882a593Smuzhiyun               CCBs may have been enqueued prior to the error being detected.
1252*4882a593SmuzhiyunEUNAVAILABLE   The requested CCB operation could not be performed at this time. The
1253*4882a593Smuzhiyun               restricted operation availability may apply only to the first unsuccessfully
1254*4882a593Smuzhiyun               submitted CCB, or may apply to a larger scope. The status should not be
1255*4882a593Smuzhiyun               interpreted as permanent, and the guest should attempt to submit CCBs in
1256*4882a593Smuzhiyun               the future which had previously been unable to be performed. The status
1257*4882a593Smuzhiyun               data provides additional information about scope of the retricted availability
1258*4882a593Smuzhiyun               as follows:
1259*4882a593Smuzhiyun               Value       Description
1260*4882a593Smuzhiyun               0           Processing for the exact CCB instance submitted was unavailable,
1261*4882a593Smuzhiyun                           and it is recommended the guest emulate the operation. The
1262*4882a593Smuzhiyun                           guest should continue to submit all other CCBs, and assume no
1263*4882a593Smuzhiyun                           restrictions beyond this exact CCB instance.
1264*4882a593Smuzhiyun               1           Processing is unavailable for all CCBs using the requested opcode,
1265*4882a593Smuzhiyun                           and it is recommended the guest emulate the operation. The
1266*4882a593Smuzhiyun                           guest should continue to submit all other CCBs that use different
1267*4882a593Smuzhiyun                           opcodes, but can expect continued rejections of CCBs using the
1268*4882a593Smuzhiyun                           same opcode in the near future.
1269*4882a593Smuzhiyun
1270*4882a593Smuzhiyun
1271*4882a593Smuzhiyun                                 531
1272*4882a593Smuzhiyun                                              Coprocessor services
1273*4882a593Smuzhiyun
1274*4882a593Smuzhiyun
1275*4882a593Smuzhiyun                                      Value     Description
1276*4882a593Smuzhiyun                                      2         Processing is unavailable for all CCBs using the requested CCB
1277*4882a593Smuzhiyun                                                version, and it is recommended the guest emulate the operation.
1278*4882a593Smuzhiyun                                                The guest should continue to submit all other CCBs that use
1279*4882a593Smuzhiyun                                                different CCB versions, but can expect continued rejections of
1280*4882a593Smuzhiyun                                                CCBs using the same CCB version in the near future.
1281*4882a593Smuzhiyun                                      3         Processing is unavailable for all CCBs on the submitting vcpu,
1282*4882a593Smuzhiyun                                                and it is recommended the guest emulate the operation or resubmit
1283*4882a593Smuzhiyun                                                the CCB on a different vcpu. The guest should continue to submit
1284*4882a593Smuzhiyun                                                CCBs on all other vcpus but can expect continued rejections of all
1285*4882a593Smuzhiyun                                                CCBs on this vcpu in the near future.
1286*4882a593Smuzhiyun                                      4         Processing is unavailable for all CCBs, and it is recommended
1287*4882a593Smuzhiyun                                                the guest emulate the operation. The guest should expect all CCB
1288*4882a593Smuzhiyun                                                submissions to be similarly rejected in the near future.
1289*4882a593Smuzhiyun
1290*4882a593Smuzhiyun
1291*4882a593Smuzhiyun36.3.2. ccb_info
1292*4882a593Smuzhiyun
1293*4882a593Smuzhiyun        trap#               FAST_TRAP
1294*4882a593Smuzhiyun        function#           CCB_INFO
1295*4882a593Smuzhiyun        arg0                address
1296*4882a593Smuzhiyun        ret0                status
1297*4882a593Smuzhiyun        ret1                CCB state
1298*4882a593Smuzhiyun        ret2                position
1299*4882a593Smuzhiyun        ret3                dax
1300*4882a593Smuzhiyun        ret4                queue
1301*4882a593Smuzhiyun
1302*4882a593Smuzhiyun       Requests status information on a previously submitted CCB. The previously submitted CCB is identified
1303*4882a593Smuzhiyun       by the 64-byte aligned real address of the CCBs completion area.
1304*4882a593Smuzhiyun
1305*4882a593Smuzhiyun       A CCB can be in one of 4 states:
1306*4882a593Smuzhiyun
1307*4882a593Smuzhiyun
1308*4882a593Smuzhiyun        State                     Value       Description
1309*4882a593Smuzhiyun        COMPLETED                 0           The CCB has been fetched and executed, and is no longer active in
1310*4882a593Smuzhiyun                                              the virtual machine.
1311*4882a593Smuzhiyun        ENQUEUED                  1           The requested CCB is current in a queue awaiting execution.
1312*4882a593Smuzhiyun        INPROGRESS                2           The CCB has been fetched and is currently being executed. It may still
1313*4882a593Smuzhiyun                                              be possible to stop the execution using the ccb_kill hypercall.
1314*4882a593Smuzhiyun        NOTFOUND                  3           The CCB could not be located in the virtual machine, and does not
1315*4882a593Smuzhiyun                                              appear to have been executed. This may occur if the CCB was lost
1316*4882a593Smuzhiyun                                              due to a hardware error, or the CCB may not have been successfully
1317*4882a593Smuzhiyun                                              submitted to the virtual machine in the first place.
1318*4882a593Smuzhiyun
1319*4882a593Smuzhiyun               Implementation note
1320*4882a593Smuzhiyun               Some platforms may not be able to report CCBs that are currently being processed, and therefore
1321*4882a593Smuzhiyun               guest software should invoke the ccb_kill hypercall prior to assuming the request CCB will never
1322*4882a593Smuzhiyun               be executed because it was in the NOTFOUND state.
1323*4882a593Smuzhiyun
1324*4882a593Smuzhiyun
1325*4882a593Smuzhiyun                                                       532
1326*4882a593Smuzhiyun                                             Coprocessor services
1327*4882a593Smuzhiyun
1328*4882a593Smuzhiyun
1329*4882a593Smuzhiyun         The position return value is only valid when the state is ENQUEUED. The value returned is the number
1330*4882a593Smuzhiyun         of other CCBs ahead of the requested CCB, to provide a relative estimate of when the CCB may execute.
1331*4882a593Smuzhiyun
1332*4882a593Smuzhiyun         The dax return value is only valid when the state is ENQUEUED. The value returned is the DAX unit
1333*4882a593Smuzhiyun         instance indentifier for the DAX unit processing the queue where the requested CCB is located. The value
1334*4882a593Smuzhiyun         matches the value that would have been, or was, returned by ccb_submit using the queue info flag.
1335*4882a593Smuzhiyun
1336*4882a593Smuzhiyun         The queue return value is only valid when the state is ENQUEUED. The value returned is the DAX
1337*4882a593Smuzhiyun         queue instance indentifier for the DAX unit processing the queue where the requested CCB is located. The
1338*4882a593Smuzhiyun         value matches the value that would have been, or was, returned by ccb_submit using the queue info flag.
1339*4882a593Smuzhiyun
1340*4882a593Smuzhiyun36.3.2.1. Errors
1341*4882a593Smuzhiyun
1342*4882a593Smuzhiyun          EOK                       The request was proccessed and the CCB state is valid.
1343*4882a593Smuzhiyun          EBADALIGN                 address is not on a 64-byte aligned.
1344*4882a593Smuzhiyun          ENORADDR                  The real address provided for address is not valid.
1345*4882a593Smuzhiyun          EINVAL                    The CCB completion area contents are not valid.
1346*4882a593Smuzhiyun          EWOULDBLOCK               Internal resource contraints prevented the CCB state from being queried at this
1347*4882a593Smuzhiyun                                    time. The guest should retry the request.
1348*4882a593Smuzhiyun          ENOACCESS                 The guest does not have permission to access the coprocessor virtual device
1349*4882a593Smuzhiyun                                    functionality.
1350*4882a593Smuzhiyun
1351*4882a593Smuzhiyun36.3.3. ccb_kill
1352*4882a593Smuzhiyun
1353*4882a593Smuzhiyun          trap#           FAST_TRAP
1354*4882a593Smuzhiyun          function#       CCB_KILL
1355*4882a593Smuzhiyun          arg0            address
1356*4882a593Smuzhiyun          ret0            status
1357*4882a593Smuzhiyun          ret1            result
1358*4882a593Smuzhiyun
1359*4882a593Smuzhiyun         Request to stop execution of a previously submitted CCB. The previously submitted CCB is identified by
1360*4882a593Smuzhiyun         the 64-byte aligned real address of the CCBs completion area.
1361*4882a593Smuzhiyun
1362*4882a593Smuzhiyun         The kill attempt can produce one of several values in the result return value, reflecting the CCB state
1363*4882a593Smuzhiyun         and actions taken by the Hypervisor:
1364*4882a593Smuzhiyun
1365*4882a593Smuzhiyun          Result                Value       Description
1366*4882a593Smuzhiyun          COMPLETED             0           The CCB has been fetched and executed, and is no longer active in
1367*4882a593Smuzhiyun                                            the virtual machine. It could not be killed and no action was taken.
1368*4882a593Smuzhiyun          DEQUEUED              1           The requested CCB was still enqueued when the kill request was
1369*4882a593Smuzhiyun                                            submitted, and has been removed from the queue. Since the CCB
1370*4882a593Smuzhiyun                                            never began execution, no memory modifications were produced by
1371*4882a593Smuzhiyun                                            it, and the completion area will never be updated. The same CCB may
1372*4882a593Smuzhiyun                                            be submitted again, if desired, with no modifications required.
1373*4882a593Smuzhiyun          KILLED                2           The CCB had been fetched and was being executed when the kill
1374*4882a593Smuzhiyun                                            request was submitted. The CCB execution was stopped, and the CCB
1375*4882a593Smuzhiyun                                            is no longer active in the virtual machine. The CCB completion area
1376*4882a593Smuzhiyun                                            will reflect the killed status, with the subsequent implications that
1377*4882a593Smuzhiyun                                            partial results may have been produced. Partial results may include full
1378*4882a593Smuzhiyun
1379*4882a593Smuzhiyun
1380*4882a593Smuzhiyun                                                      533
1381*4882a593Smuzhiyun                                              Coprocessor services
1382*4882a593Smuzhiyun
1383*4882a593Smuzhiyun
1384*4882a593Smuzhiyun          Result                 Value       Description
1385*4882a593Smuzhiyun                                             command execution if the command was stopped just prior to writing
1386*4882a593Smuzhiyun                                             to the completion area.
1387*4882a593Smuzhiyun          NOTFOUND               3           The CCB could not be located in the virtual machine, and does not
1388*4882a593Smuzhiyun                                             appear to have been executed. This may occur if the CCB was lost
1389*4882a593Smuzhiyun                                             due to a hardware error, or the CCB may not have been successfully
1390*4882a593Smuzhiyun                                             submitted to the virtual machine in the first place. CCBs in the state
1391*4882a593Smuzhiyun                                             are guaranteed to never execute in the future unless resubmitted.
1392*4882a593Smuzhiyun
1393*4882a593Smuzhiyun36.3.3.1. Interactions with Pipelined CCBs
1394*4882a593Smuzhiyun
1395*4882a593Smuzhiyun         If the pipeline target CCB is killed but the pipeline source CCB was skipped, the completion area of the
1396*4882a593Smuzhiyun         target CCB may contain status (4,0) "Command was skipped" instead of (3,7) "Command was killed".
1397*4882a593Smuzhiyun
1398*4882a593Smuzhiyun         If the pipeline source CCB is killed, the pipeline target CCB's completion status may read (1,0) "Success".
1399*4882a593Smuzhiyun         This does not mean the target CCB was processed; since the source CCB was killed, there was no
1400*4882a593Smuzhiyun         meaningful output on which the target CCB could operate.
1401*4882a593Smuzhiyun
1402*4882a593Smuzhiyun36.3.3.2. Errors
1403*4882a593Smuzhiyun
1404*4882a593Smuzhiyun          EOK                        The request was proccessed and the result is valid.
1405*4882a593Smuzhiyun          EBADALIGN                  address is not on a 64-byte aligned.
1406*4882a593Smuzhiyun          ENORADDR                   The real address provided for address is not valid.
1407*4882a593Smuzhiyun          EINVAL                     The CCB completion area contents are not valid.
1408*4882a593Smuzhiyun          EWOULDBLOCK                Internal resource contraints prevented the CCB from being killed at this time.
1409*4882a593Smuzhiyun                                     The guest should retry the request.
1410*4882a593Smuzhiyun          ENOACCESS                  The guest does not have permission to access the coprocessor virtual device
1411*4882a593Smuzhiyun                                     functionality.
1412*4882a593Smuzhiyun
1413*4882a593Smuzhiyun36.3.4. dax_info
1414*4882a593Smuzhiyun          trap#            FAST_TRAP
1415*4882a593Smuzhiyun          function#        DAX_INFO
1416*4882a593Smuzhiyun          ret0             status
1417*4882a593Smuzhiyun          ret1             Number of enabled DAX units
1418*4882a593Smuzhiyun          ret2             Number of disabled DAX units
1419*4882a593Smuzhiyun
1420*4882a593Smuzhiyun         Returns the number of DAX units that are enabled for the calling guest to submit CCBs. The number of
1421*4882a593Smuzhiyun         DAX units that are disabled for the calling guest are also returned. A disabled DAX unit would have been
1422*4882a593Smuzhiyun         available for CCB submission to the calling guest had it not been offlined.
1423*4882a593Smuzhiyun
1424*4882a593Smuzhiyun36.3.4.1. Errors
1425*4882a593Smuzhiyun
1426*4882a593Smuzhiyun          EOK                        The request was proccessed and the number of enabled/disabled DAX units
1427*4882a593Smuzhiyun                                     are valid.
1428*4882a593Smuzhiyun
1429*4882a593Smuzhiyun
1430*4882a593Smuzhiyun
1431*4882a593Smuzhiyun
1432*4882a593Smuzhiyun                                                       534
1433*4882a593Smuzhiyun
1434