File: error.inc

package info (click to toggle)
intel-ipsec-mb 2.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,404 kB
  • sloc: ansic: 104,071; asm: 64,976; pascal: 18,149; javascript: 5,637; python: 1,464; makefile: 799
file content (169 lines) | stat: -rw-r--r-- 5,570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
;;
;; Copyright (c) 2021-2024, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;;     * Redistributions of source code must retain the above copyright notice,
;;       this list of conditions and the following disclaimer.
;;     * Redistributions in binary form must reproduce the above copyright
;;       notice, this list of conditions and the following disclaimer in the
;;       documentation and/or other materials provided with the distribution.
;;     * Neither the name of Intel Corporation nor the names of its contributors
;;       may be used to endorse or promote products derived from this software
;;       without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;

%ifndef ERROR_ASM_INCLUDED
%define ERROR_ASM_INCLUDED

%include "include/reg_sizes.inc"

extern imb_errno
extern imb_errno_types

;; Macro to define error types
%macro SET_ERRNO_TYPES 1-*

%assign i 0
%rep  %0
;; set address of next error type in imb_errno_type array
%xdefine %1 [rel imb_errno_types + i]
%rotate 1
%assign i (i + 4)
%endrep

%endmacro

SET_ERRNO_TYPES \
    IMB_ERR_NULL_MBMGR,         \
    IMB_ERR_JOB_NULL_SRC,       \
    IMB_ERR_JOB_NULL_DST,       \
    IMB_ERR_JOB_NULL_KEY,       \
    IMB_ERR_JOB_NULL_IV,        \
    IMB_ERR_JOB_NULL_AUTH,      \
    IMB_ERR_JOB_NULL_AAD,       \
    IMB_ERR_JOB_CIPH_LEN,       \
    IMB_ERR_JOB_AUTH_LEN,       \
    IMB_ERR_JOB_IV_LEN,         \
    IMB_ERR_JOB_KEY_LEN,        \
    IMB_ERR_JOB_AUTH_TAG_LEN,   \
    IMB_ERR_JOB_AAD_LEN,        \
    IMB_ERR_JOB_SRC_OFFSET,     \
    IMB_ERR_JOB_CHAIN_ORDER,    \
    IMB_ERR_CIPH_MODE,          \
    IMB_ERR_HASH_ALGO,          \
    IMB_ERR_JOB_NULL_AUTH_KEY,  \
    IMB_ERR_JOB_NULL_SGL_CTX,   \
    IMB_ERR_JOB_NULL_NEXT_IV,   \
    IMB_ERR_JOB_PON_PLI,        \
    IMB_ERR_NULL_SRC,           \
    IMB_ERR_NULL_DST,           \
    IMB_ERR_NULL_KEY,           \
    IMB_ERR_NULL_EXP_KEY,       \
    IMB_ERR_NULL_IV,            \
    IMB_ERR_NULL_AUTH,          \
    IMB_ERR_NULL_AAD,           \
    IMB_ERR_CIPH_LEN,           \
    IMB_ERR_AUTH_LEN,           \
    IMB_ERR_IV_LEN,             \
    IMB_ERR_KEY_LEN,            \
    IMB_ERR_AUTH_TAG_LEN,       \
    IMB_ERR_AAD_LEN,            \
    IMB_ERR_SRC_OFFSET,         \
    IMB_ERR_NULL_AUTH_KEY,      \
    IMB_ERR_NULL_CTX,           \
    IMB_ERR_JOB_NULL_HMAC_OPAD, \
    IMB_ERR_JOB_NULL_HMAC_IPAD, \
    IMB_ERR_JOB_NULL_XCBC_K1_EXP,       \
    IMB_ERR_JOB_NULL_XCBC_K2,   \
    IMB_ERR_JOB_NULL_XCBC_K3,   \
    IMB_ERR_JOB_CIPH_DIR,       \
    IMB_ERR_JOB_NULL_GHASH_INIT_TAG, \
    IMB_ERR_MISSING_CPUFLAGS_INIT_MGR, \
    IMB_ERR_NULL_JOB, \
    IMB_ERR_QUEUE_SPACE, \
    IMB_ERR_NULL_BURST, \
    IMB_ERR_BURST_SIZE, \
    IMB_ERR_BURST_OOO, \
    IMB_ERR_SELFTEST, \
    IMB_ERR_BURST_SUITE_ID, \
    IMB_ERR_JOB_SGL_STATE

;; Reset global imb_errno to 0
%macro IMB_ERR_CHECK_RESET 0

        cmp     dword [rel imb_errno], 0
        jz      %%do_not_reset
        mov     dword [rel imb_errno], 0
%%do_not_reset:
%endmacro

;; Set GP reg and global imb_errno to 0
%macro IMB_ERR_CHECK_START 1
%define %%REG   %1 ;; [clobbered] 64 bit GP reg

        xor     %%REG, %%REG
        mov     [rel imb_errno], DWORD(%%REG)
%endmacro

;; Set global imb_errno to specified error type
%macro IMB_ERR_CHECK_END 1
%define %%ERR   %1 ;; [in] 64 bit GP reg containing error type

        mov     [rel imb_errno], DWORD(%%ERR)
%endmacro

;; Set error type if value is 0
%macro IMB_ERR_CHECK_ZERO 3
%define %%VAL   %1 ;; [in] value to check for 0
%define %%REG   %2 ;; [out] GP reg to store error type
%define %%ERR   %3 ;; [in] error type

        cmp     %%VAL, 0
        cmovz   DWORD(%%REG), %%ERR
%endmacro

;; Set error type if value is null
%macro IMB_ERR_CHECK_NULL 3
%define %%VAL   %1 ;; [in] value to check for null
%define %%REG   %2 ;; [out] GP reg to store error type
%define %%ERR   %3 ;; [in] error type

        IMB_ERR_CHECK_ZERO %%VAL, %%REG, %%ERR
%endmacro

;; Set error type if value is above compare value
%macro IMB_ERR_CHECK_ABOVE 4
%define %%VAL   %1 ;; [in] value to check
%define %%CVAL  %2 ;; [in] value to compare against
%define %%REG   %3 ;; [out] GP reg to store error type
%define %%ERR   %4 ;; [in] error type

        cmp     %%VAL, %%CVAL
        cmova   DWORD(%%REG), %%ERR
%endmacro

;; Set error type if value is below compare value
%macro IMB_ERR_CHECK_BELOW 4
%define %%VAL   %1 ;; [in] value to check
%define %%CVAL  %2 ;; [in] value to compare against
%define %%REG   %3 ;; [out] GP reg to store error type
%define %%ERR   %4 ;; [in] error type

        cmp     %%VAL, %%CVAL
        cmovb   DWORD(%%REG), %%ERR
%endmacro

%endif ;; ERROR_ASM_INCLUDED