1285242Sachim/******************************************************************************* 2285242Sachim*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3285242Sachim* 4285242Sachim*Redistribution and use in source and binary forms, with or without modification, are permitted provided 5285242Sachim*that the following conditions are met: 6285242Sachim*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7285242Sachim*following disclaimer. 8285242Sachim*2. Redistributions in binary form must reproduce the above copyright notice, 9285242Sachim*this list of conditions and the following disclaimer in the documentation and/or other materials provided 10285242Sachim*with the distribution. 11285242Sachim* 12285242Sachim*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13285242Sachim*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14285242Sachim*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15285242Sachim*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16285242Sachim*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17285242Sachim*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18285242Sachim*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19285242Sachim*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20285242Sachim* 21285242Sachim* $FreeBSD: releng/11.0/sys/dev/pms/freebsd/driver/common/encrypt_ioctl.h 285242 2015-07-07 13:17:02Z achim $ 22285242Sachim* 23285242Sachim*******************************************************************************/ 24285242Sachim/******************************************************************************* 25285242Sachim** 26285242Sachim** Version Control Information: 27285242Sachim** 28285242Sachim** $Revision: 114125 $ 29285242Sachim** $Author: lindfors $ 30285242Sachim** $Date: 2012-01-06 17:12:27 -0800 (Fri, 06 Jan 2012) $ 31285242Sachim** $Id: encrypt_ioctl.h 112360 2012-01-07 01:12:27Z mcleanda $ 32285242Sachim** 33285242Sachim*******************************************************************************/ 34285242Sachim#include <linux/ioctl.h> 35285242Sachim 36285242Sachim#ifndef __ENCRYPT_IOCTL_H__ 37285242Sachim#define __ENCRYPT_IOCTL_H__ 38285242Sachim 39285242Sachim#include <dev/pms/RefTisa/tisa/api/tiapi.h> 40285242Sachim#include <dev/pms/RefTisa/tisa/api/ostiapi.h> 41285242Sachim#include <dev/pms/RefTisa/tisa/api/tidefs.h> 42285242Sachim#include <dev/pms/RefTisa/tisa/api/tiglobal.h> 43285242Sachim#include <dev/pms/RefTisa/tisa/api/titypes.h> 44285242Sachim#include <dev/pms/RefTisa/tisa/sassata/common/tdioctl.h> 45285242Sachim#include <dev/pms/freebsd/driver/common/osenv.h> 46285242Sachim#include <dev/pms/freebsd/driver/common/ostypes.h> 47285242Sachim#include <dev/pms/freebsd/driver/common/osdebug.h> 48285242Sachim 49285242Sachimtypedef struct IoctlEncryptGetInfo_s { 50285242Sachim tiEncryptInfo_t tisaEncryptInfo; 51285242Sachim} __attribute__ ((packed)) IoctlEncryptGetInfo_t; 52285242Sachim 53285242Sachimtypedef struct IoctlEncryptSetMode_s { 54285242Sachim bit32 securityCipherMode; 55285242Sachim} __attribute__ ((packed)) IoctlEncryptSetMode_t; 56285242Sachim 57285242Sachimtypedef struct IoctlEncryptKekAdd_s { 58285242Sachim bit32 kekIndex; 59285242Sachim bit32 wrapperKekIndex; 60285242Sachim bit32 blobFormat; 61285242Sachim tiEncryptKekBlob_t *EncryptKekBlob; 62285242Sachim} __attribute__ ((packed)) IoctlEncryptKekAdd_t; 63285242Sachim 64285242Sachimtypedef struct IoctlEncryptDekAdd_s { 65285242Sachim bit32 kekIndex; 66285242Sachim bit32 dekTable; 67285242Sachim bit32 dekIndex; 68285242Sachim bit32 dekBlobFormat; 69285242Sachim bit32 dekTableKeyEntrySize; 70285242Sachim tiEncryptDekBlob_t *dekBlob; 71285242Sachim} __attribute__ ((packed)) IoctlEncryptDekAdd_t; 72285242Sachim 73285242Sachimtypedef struct IoctlEncryptDekInvalidate_s { 74285242Sachim tiEncryptDek_t dek; 75285242Sachim} __attribute__ ((packed)) IoctlEncryptDekInvalidate_t; 76285242Sachim 77285242Sachimtypedef struct IoctlEncryptKekNVRAM_s { 78285242Sachim bit32 index; 79285242Sachim} __attribute__ ((packed)) IoctlEncryptKekNVRAM_t; 80285242Sachim 81285242Sachimtypedef struct IoctlEncryptDekTable_s { 82285242Sachim tiMem_t DekTable1Addr; 83285242Sachim tiMem_t DekTable2Addr; 84285242Sachim} __attribute__ ((packed)) IoctlEncryptDekTable_t; 85285242Sachim 86285242Sachimtypedef struct EncryptDekMapEntry_s { 87285242Sachim#define ENCRYPT_DEK_MAP_ENTRY_CLEAR 0x00000001UL 88285242Sachim#define ENCRYPT_DEK_MAP_ENTRY_VALID 0x80000000UL 89285242Sachim bit32 flags; 90285242Sachim unsigned long long startLBA; 91285242Sachim unsigned long long endLBA; 92285242Sachim tiEncryptDek_t dek; 93285242Sachim} __attribute__ ((packed)) EncryptDekMapEntry_t; 94285242Sachim 95285242Sachimtypedef struct EncryptDeviceDekMap_s { 96285242Sachim bit32 host; 97285242Sachim bit32 channel; 98285242Sachim bit32 device; 99285242Sachim bit32 lun; 100285242Sachim bit32 keytag_check; 101285242Sachim bit32 keytag[2]; 102285242Sachim EncryptDekMapEntry_t dekMapEntry[1]; 103285242Sachim} __attribute__ ((packed)) EncryptDeviceDekMap_t; 104285242Sachim 105285242Sachimtypedef struct IoctlEncryptDekMapTable_s { 106285242Sachim EncryptDeviceDekMap_t dekMap[1]; 107285242Sachim} __attribute__ ((packed)) IoctlEncryptDekMapTable_t; 108285242Sachim 109285242Sachimtypedef struct IoctlEncryptIOError_s { 110285242Sachim bit64 error_id; 111285242Sachim bit64 timestamp; 112285242Sachim bit32 error_type; 113285242Sachim bit32 host; 114285242Sachim bit32 channel; 115285242Sachim bit32 device; 116285242Sachim bit32 lun; 117285242Sachim bit32 scsi_cmd; 118285242Sachim bit32 dek_index; 119285242Sachim bit32 dek_table; 120285242Sachim bit32 kek_index; 121285242Sachim bit32 encrypt_mode; 122285242Sachim bit32 keytag_check; 123285242Sachim bit32 keytag[2]; 124285242Sachim} __attribute__ ((packed)) IoctlEncryptIOError_t; 125285242Sachim 126285242Sachimtypedef struct __attribute__ ((packed)) IoctlEncryptErrorQuery_s { 127285242Sachim#define ERROR_QUERY_FLAG_BLOCK 1 128285242Sachim bit32 query_flag; 129285242Sachim bit32 valid_mask; 130285242Sachim IoctlEncryptIOError_t error[32]; 131285242Sachim} __attribute__ ((packed)) IoctlEncryptErrorQuery_t; 132285242Sachim 133285242Sachimtypedef union IoctlEncryptOp_u { 134285242Sachim IoctlEncryptGetInfo_t encryptGetInfo; 135285242Sachim IoctlEncryptSetMode_t encryptSetMode; 136285242Sachim IoctlEncryptKekAdd_t encryptKekAdd; 137285242Sachim IoctlEncryptDekAdd_t encryptDekAdd; 138285242Sachim IoctlEncryptDekInvalidate_t encryptDekInvalidate; 139285242Sachim IoctlEncryptKekNVRAM_t encryptKekNVRAM; 140285242Sachim IoctlEncryptDekMapTable_t encryptDekMap; 141285242Sachim IoctlEncryptErrorQuery_t encryptErrorQuery; 142285242Sachim} __attribute__ ((packed)) IoctlEncryptOp_t; 143285242Sachim 144285242Sachimtypedef struct tiIOCTLPayloadHeader_s { 145285242Sachim bit32 Signature; 146285242Sachim bit16 MajorFunction; 147285242Sachim bit16 MinorFunction; 148285242Sachim bit16 Length; 149285242Sachim bit16 Status; 150285242Sachim} __attribute__ ((packed)) tiIOCTLPayloadHeader_t; 151285242Sachim 152285242Sachimtypedef struct IoctlTISAEncrypt_s { 153285242Sachim#define encryptGetInfo 0x00000001 154285242Sachim#define encryptSetMode 0x00000002 155285242Sachim#define encryptKekAdd 0x00000003 156285242Sachim#define encryptDekAdd 0x00000004 157285242Sachim#define encryptDekInvalidate 0x00000005 158285242Sachim#define encryptKekStore 0x00000006 159285242Sachim#define encryptKekLoad 0x00000007 160285242Sachim#define encryptGetDekTable 0x00000008 161285242Sachim#define encryptSetDekMap 0x00000009 162285242Sachim#define encryptDekDump 0x0000000a 163285242Sachim#define encryptErrorQuery 0x0000000c 164285242Sachim bit32 encryptFunction; 165285242Sachim bit32 status; 166285242Sachim bit32 subEvent; 167285242Sachim IoctlEncryptOp_t request; 168285242Sachim} __attribute__ ((packed)) IoctlTISAEncrypt_t; 169285242Sachim 170285242Sachimtypedef struct IOCTLEncrypt_s { 171285242Sachim tiIOCTLPayloadHeader_t hdr; 172285242Sachim IoctlTISAEncrypt_t body; 173285242Sachim} __attribute__ ((packed)) IoctlEncrypt_t; 174285242Sachim 175285242Sachim#endif 176