1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3 *
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7 *following disclaimer.
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
11 *
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20 *
21 *
22 *******************************************************************************/
23 /*******************************************************************************
24 **
25 ** Version Control Information:
26 **
27 **  $Revision: 114125 $
28 **  $Author: lindfors $
29 **  $Date: 2012-01-06 17:12:27 -0800 (Fri, 06 Jan 2012) $
30 **  $Id: lxencrypt.h 112360 2012-01-07 01:12:27Z mcleanda $
31 **
32 *******************************************************************************/
33 
34 //#ifndef __LXENCRYPT_H__
35 //#define __LXENCRYPT_H__
36 
37 
38 #include <dev/pms/RefTisa/tisa/api/tiapi.h>
39 #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
40 #include <dev/pms/RefTisa/tisa/api/tidefs.h>
41 #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
42 #include <dev/pms/RefTisa/tisa/api/titypes.h>
43 #include <dev/pms/RefTisa/tisa/sassata/common/tdioctl.h>
44 #include <dev/pms/freebsd/driver/common/osenv.h>
45 #include <dev/pms/freebsd/driver/common/ostypes.h>
46 #include <dev/pms/freebsd/driver/common/osdebug.h>
47 #include <sys/param.h>		//zone allocation
48 #include <sys/queue.h>		//zone allocation
49 #include <vm/uma.h>		//zone allocation
50 
51 
52 #ifndef __LXENCRYPT_H__
53 #define __LXENCRYPT_H__
54 
55 #define IOERR_QUEUE_DEPTH_MAX 1024
56 
57 enum {
58     E_SUCCESS = 0,
59     E_DEK_INDEX,
60     E_DEK_TABLE,
61     E_KEK_INDEX,
62     E_CHANNEL_INDEX,
63     E_DEVICE_INDEX,
64     E_LUN_INDEX,
65     E_LBA_RANGE,
66     E_MEMPOOL_ALLOC,
67     E_FLAGS,
68     E_ENCRYPTION_DISABLED,
69     E_BAD_CIPHER_MODE,
70     E_NO_TARGET_MAP,
71     E_NO_LBA_MAP,
72     E_NOT_FOUND,
73 } encrypt_error_e;
74 
75 typedef struct ag_encrypt_ioerr_s {
76     struct list_head *list;
77 } ag_encrypt_ioerr_t;
78 
79 struct agtiapi_softc *pCard;
80 #ifdef ENCRYPT_ENHANCE
81 
82 
83 ssize_t set_dek_table_entry0(struct device *dev, struct device_attribute *attr, const char *buf, size_t len);
84 ssize_t show_dek_table_entry0(struct device *dev, struct device_attribute *attr, char *buf);
85 ssize_t set_dek_table_entry1(struct device *dev, struct device_attribute *attr, const char *buf, size_t len);
86 ssize_t show_dek_table_entry1(struct device *dev, struct device_attribute *attr, char *buf);
87 ssize_t show_kek_table(struct device *dev, struct device_attribute *attr, char *buf);
88 ssize_t show_dek_kek_map0(struct device *dev, struct device_attribute *attr, char *buf);
89 ssize_t show_dek_kek_map1(struct device *dev, struct device_attribute *attr, char *buf);
90 ssize_t show_target_dek_map(struct device *dev, struct device_attribute *attr, char *buf);
91 
92 #endif
93 int agtiapi_SetupEncryption(struct agtiapi_softc *pCard);
94 int agtiapi_SetupEncryptionPools(struct agtiapi_softc *pCard);
95 void agtiapi_CleanupEncryption(struct agtiapi_softc *pCard);
96 void agtiapi_CleanupEncryptionPools(struct agtiapi_softc *pCard);
97 int agtiapi_SetupEncryptedIO(struct agtiapi_softc *pCard, ccb_t *pccb, unsigned long long block);
98 void agtiapi_CleanupEncryptedIO(struct agtiapi_softc *pCard, ccb_t *pccb);
99 void agtiapi_HandleEncryptedIOFailure(ag_device_t *pDev, ccb_t *pccb);
100 
101 #endif
102 
103