Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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