linux/arch/x86/crypto/sha256-mb/sha256_mb_mgr.h
<<
>>
Prefs
   1/*
   2 * Header file for multi buffer SHA256 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) 2016 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 *      Megha Dey <megha.dey@linux.intel.com>
  22 *
  23 *  BSD LICENSE
  24 *
  25 *  Copyright(c) 2016 Intel Corporation.
  26 *
  27 *  Redistribution and use in source and binary forms, with or without
  28 *  modification, are permitted provided that the following conditions
  29 *  are met:
  30 *
  31 *    * Redistributions of source code must retain the above copyright
  32 *      notice, this list of conditions and the following disclaimer.
  33 *    * Redistributions in binary form must reproduce the above copyright
  34 *      notice, this list of conditions and the following disclaimer in
  35 *      the documentation and/or other materials provided with the
  36 *      distribution.
  37 *    * Neither the name of Intel Corporation nor the names of its
  38 *      contributors may be used to endorse or promote products derived
  39 *      from this software without specific prior written permission.
  40 *
  41 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  42 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  43 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  44 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  45 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  46 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  47 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  48 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  49 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  50 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  51 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  52 */
  53#ifndef __SHA_MB_MGR_H
  54#define __SHA_MB_MGR_H
  55
  56#include <linux/types.h>
  57
  58#define NUM_SHA256_DIGEST_WORDS 8
  59
  60enum job_sts {  STS_UNKNOWN = 0,
  61                STS_BEING_PROCESSED = 1,
  62                STS_COMPLETED = 2,
  63                STS_INTERNAL_ERROR = 3,
  64                STS_ERROR = 4
  65};
  66
  67struct job_sha256 {
  68        u8      *buffer;
  69        u32     len;
  70        u32     result_digest[NUM_SHA256_DIGEST_WORDS] __aligned(32);
  71        enum    job_sts status;
  72        void    *user_data;
  73};
  74
  75/* SHA256 out-of-order scheduler */
  76
  77/* typedef uint32_t sha8_digest_array[8][8]; */
  78
  79struct sha256_args_x8 {
  80        uint32_t        digest[8][8];
  81        uint8_t         *data_ptr[8];
  82};
  83
  84struct sha256_lane_data {
  85        struct job_sha256 *job_in_lane;
  86};
  87
  88struct sha256_mb_mgr {
  89        struct sha256_args_x8 args;
  90
  91        uint32_t lens[8];
  92
  93        /* each byte is index (0...7) of unused lanes */
  94        uint64_t unused_lanes;
  95        /* byte 4 is set to FF as a flag */
  96        struct sha256_lane_data ldata[8];
  97};
  98
  99
 100#define SHA256_MB_MGR_NUM_LANES_AVX2 8
 101
 102void sha256_mb_mgr_init_avx2(struct sha256_mb_mgr *state);
 103struct job_sha256 *sha256_mb_mgr_submit_avx2(struct sha256_mb_mgr *state,
 104                                         struct job_sha256 *job);
 105struct job_sha256 *sha256_mb_mgr_flush_avx2(struct sha256_mb_mgr *state);
 106struct job_sha256 *sha256_mb_mgr_get_comp_job_avx2(struct sha256_mb_mgr *state);
 107
 108#endif
 109