]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/scsi/cxlflash/vlun.h
scsi: cxlflash: Fix warnings/errors
[mirror_ubuntu-zesty-kernel.git] / drivers / scsi / cxlflash / vlun.h
1 /*
2 * CXL Flash Device Driver
3 *
4 * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
5 * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
6 *
7 * Copyright (C) 2015 IBM Corporation
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15 #ifndef _CXLFLASH_VLUN_H
16 #define _CXLFLASH_VLUN_H
17
18 /* RHT - Resource Handle Table */
19 #define MC_RHT_NMASK 16 /* in bits */
20 #define MC_CHUNK_SHIFT MC_RHT_NMASK /* shift to go from LBA to chunk# */
21
22 #define HIBIT (BITS_PER_LONG - 1)
23
24 #define MAX_AUN_CLONE_CNT 0xFF
25
26 /*
27 * LXT - LBA Translation Table
28 *
29 * +-------+-------+-------+-------+-------+-------+-------+---+---+
30 * | RLBA_BASE |LUN_IDX| P |SEL|
31 * +-------+-------+-------+-------+-------+-------+-------+---+---+
32 *
33 * The LXT Entry contains the physical LBA where the chunk starts (RLBA_BASE).
34 * AFU ORes the low order bits from the virtual LBA (offset into the chunk)
35 * with RLBA_BASE. The result is the physical LBA to be sent to storage.
36 * The LXT Entry also contains an index to a LUN TBL and a bitmask of which
37 * outgoing (FC) * ports can be selected. The port select bit-mask is ANDed
38 * with a global port select bit-mask maintained by the driver.
39 * In addition, it has permission bits that are ANDed with the
40 * RHT permissions to arrive at the final permissions for the chunk.
41 *
42 * LXT tables are allocated dynamically in groups. This is done to avoid
43 * a malloc/free overhead each time the LXT has to grow or shrink.
44 *
45 * Based on the current lxt_cnt (used), it is always possible to know
46 * how many are allocated (used+free). The number of allocated entries is
47 * not stored anywhere.
48 *
49 * The LXT table is re-allocated whenever it needs to cross into another group.
50 */
51 #define LXT_GROUP_SIZE 8
52 #define LXT_NUM_GROUPS(lxt_cnt) (((lxt_cnt) + 7)/8) /* alloc'ed groups */
53 #define LXT_LUNIDX_SHIFT 8 /* LXT entry, shift for LUN index */
54 #define LXT_PERM_SHIFT 4 /* LXT entry, shift for permission bits */
55
56 struct ba_lun_info {
57 u64 *lun_alloc_map;
58 u32 lun_bmap_size;
59 u32 total_aus;
60 u64 free_aun_cnt;
61
62 /* indices to be used for elevator lookup of free map */
63 u32 free_low_idx;
64 u32 free_curr_idx;
65 u32 free_high_idx;
66
67 u8 *aun_clone_map;
68 };
69
70 struct ba_lun {
71 u64 lun_id;
72 u64 wwpn;
73 size_t lsize; /* LUN size in number of LBAs */
74 size_t lba_size; /* LBA size in number of bytes */
75 size_t au_size; /* Allocation Unit size in number of LBAs */
76 struct ba_lun_info *ba_lun_handle;
77 };
78
79 /* Block Allocator */
80 struct blka {
81 struct ba_lun ba_lun;
82 u64 nchunk; /* number of chunks */
83 struct mutex mutex;
84 };
85
86 #endif /* ifndef _CXLFLASH_SUPERPIPE_H */