]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/x86/crypto/sha1-mb/sha1_mb_mgr.h
Merge branch 'for-4.8/core' of git://git.kernel.dk/linux-block
[karo-tx-linux.git] / arch / x86 / crypto / sha1-mb / sha1_mb_mgr.h
1 /*
2  * Header file for multi buffer SHA1 algorithm manager
3  *
4  * This file is provided under a dual BSD/GPLv2 license.  When using or
5  * redistributing this file, you may do so under either license.
6  *
7  * GPL LICENSE SUMMARY
8  *
9  *  Copyright(c) 2014 Intel Corporation.
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of version 2 of the GNU General Public License as
13  *  published by the Free Software Foundation.
14  *
15  *  This program is distributed in the hope that it will be useful, but
16  *  WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  General Public License for more details.
19  *
20  *  Contact Information:
21  *      James Guilford <james.guilford@intel.com>
22  *      Tim Chen <tim.c.chen@linux.intel.com>
23  *
24  *  BSD LICENSE
25  *
26  *  Copyright(c) 2014 Intel Corporation.
27  *
28  *  Redistribution and use in source and binary forms, with or without
29  *  modification, are permitted provided that the following conditions
30  *  are met:
31  *
32  *    * Redistributions of source code must retain the above copyright
33  *      notice, this list of conditions and the following disclaimer.
34  *    * Redistributions in binary form must reproduce the above copyright
35  *      notice, this list of conditions and the following disclaimer in
36  *      the documentation and/or other materials provided with the
37  *      distribution.
38  *    * Neither the name of Intel Corporation nor the names of its
39  *      contributors may be used to endorse or promote products derived
40  *      from this software without specific prior written permission.
41  *
42  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53  */
54 #ifndef __SHA_MB_MGR_H
55 #define __SHA_MB_MGR_H
56
57
58 #include <linux/types.h>
59
60 #define NUM_SHA1_DIGEST_WORDS 5
61
62 enum job_sts {  STS_UNKNOWN = 0,
63                 STS_BEING_PROCESSED = 1,
64                 STS_COMPLETED = 2,
65                 STS_INTERNAL_ERROR = 3,
66                 STS_ERROR = 4
67 };
68
69 struct job_sha1 {
70         u8      *buffer;
71         u32     len;
72         u32     result_digest[NUM_SHA1_DIGEST_WORDS] __aligned(32);
73         enum    job_sts status;
74         void    *user_data;
75 };
76
77 /* SHA1 out-of-order scheduler */
78
79 /* typedef uint32_t sha1_digest_array[5][8]; */
80
81 struct sha1_args_x8 {
82         uint32_t        digest[5][8];
83         uint8_t         *data_ptr[8];
84 };
85
86 struct sha1_lane_data {
87         struct job_sha1 *job_in_lane;
88 };
89
90 struct sha1_mb_mgr {
91         struct sha1_args_x8 args;
92
93         uint32_t lens[8];
94
95         /* each byte is index (0...7) of unused lanes */
96         uint64_t unused_lanes;
97         /* byte 4 is set to FF as a flag */
98         struct sha1_lane_data ldata[8];
99 };
100
101
102 #define SHA1_MB_MGR_NUM_LANES_AVX2 8
103
104 void sha1_mb_mgr_init_avx2(struct sha1_mb_mgr *state);
105 struct job_sha1 *sha1_mb_mgr_submit_avx2(struct sha1_mb_mgr *state,
106                                          struct job_sha1 *job);
107 struct job_sha1 *sha1_mb_mgr_flush_avx2(struct sha1_mb_mgr *state);
108 struct job_sha1 *sha1_mb_mgr_get_comp_job_avx2(struct sha1_mb_mgr *state);
109
110 #endif