1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * CXL Flash Device Driver
5 * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
6 * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
8 * Copyright (C) 2015 IBM Corporation
11 #ifndef _CXLFLASH_VLUN_H
12 #define _CXLFLASH_VLUN_H
14 /* RHT - Resource Handle Table */
15 #define MC_RHT_NMASK 16 /* in bits */
16 #define MC_CHUNK_SHIFT MC_RHT_NMASK /* shift to go from LBA to chunk# */
18 #define HIBIT (BITS_PER_LONG - 1)
20 #define MAX_AUN_CLONE_CNT 0xFF
23 * LXT - LBA Translation Table
25 * +-------+-------+-------+-------+-------+-------+-------+---+---+
26 * | RLBA_BASE |LUN_IDX| P |SEL|
27 * +-------+-------+-------+-------+-------+-------+-------+---+---+
29 * The LXT Entry contains the physical LBA where the chunk starts (RLBA_BASE).
30 * AFU ORes the low order bits from the virtual LBA (offset into the chunk)
31 * with RLBA_BASE. The result is the physical LBA to be sent to storage.
32 * The LXT Entry also contains an index to a LUN TBL and a bitmask of which
33 * outgoing (FC) * ports can be selected. The port select bit-mask is ANDed
34 * with a global port select bit-mask maintained by the driver.
35 * In addition, it has permission bits that are ANDed with the
36 * RHT permissions to arrive at the final permissions for the chunk.
38 * LXT tables are allocated dynamically in groups. This is done to avoid
39 * a malloc/free overhead each time the LXT has to grow or shrink.
41 * Based on the current lxt_cnt (used), it is always possible to know
42 * how many are allocated (used+free). The number of allocated entries is
43 * not stored anywhere.
45 * The LXT table is re-allocated whenever it needs to cross into another group.
47 #define LXT_GROUP_SIZE 8
48 #define LXT_NUM_GROUPS(lxt_cnt) (((lxt_cnt) + 7)/8) /* alloc'ed groups */
49 #define LXT_LUNIDX_SHIFT 8 /* LXT entry, shift for LUN index */
50 #define LXT_PERM_SHIFT 4 /* LXT entry, shift for permission bits */
58 /* indices to be used for elevator lookup of free map */
69 size_t lsize
; /* LUN size in number of LBAs */
70 size_t lba_size
; /* LBA size in number of bytes */
71 size_t au_size
; /* Allocation Unit size in number of LBAs */
72 struct ba_lun_info
*ba_lun_handle
;
78 u64 nchunk
; /* number of chunks */
82 #endif /* ifndef _CXLFLASH_SUPERPIPE_H */