mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 09:48:07 +07:00
2874c5fd28
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 3029 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
83 lines
2.6 KiB
C
83 lines
2.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* CXL Flash Device Driver
|
|
*
|
|
* Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
|
|
* Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
|
|
*
|
|
* Copyright (C) 2015 IBM Corporation
|
|
*/
|
|
|
|
#ifndef _CXLFLASH_VLUN_H
|
|
#define _CXLFLASH_VLUN_H
|
|
|
|
/* RHT - Resource Handle Table */
|
|
#define MC_RHT_NMASK 16 /* in bits */
|
|
#define MC_CHUNK_SHIFT MC_RHT_NMASK /* shift to go from LBA to chunk# */
|
|
|
|
#define HIBIT (BITS_PER_LONG - 1)
|
|
|
|
#define MAX_AUN_CLONE_CNT 0xFF
|
|
|
|
/*
|
|
* LXT - LBA Translation Table
|
|
*
|
|
* +-------+-------+-------+-------+-------+-------+-------+---+---+
|
|
* | RLBA_BASE |LUN_IDX| P |SEL|
|
|
* +-------+-------+-------+-------+-------+-------+-------+---+---+
|
|
*
|
|
* The LXT Entry contains the physical LBA where the chunk starts (RLBA_BASE).
|
|
* AFU ORes the low order bits from the virtual LBA (offset into the chunk)
|
|
* with RLBA_BASE. The result is the physical LBA to be sent to storage.
|
|
* The LXT Entry also contains an index to a LUN TBL and a bitmask of which
|
|
* outgoing (FC) * ports can be selected. The port select bit-mask is ANDed
|
|
* with a global port select bit-mask maintained by the driver.
|
|
* In addition, it has permission bits that are ANDed with the
|
|
* RHT permissions to arrive at the final permissions for the chunk.
|
|
*
|
|
* LXT tables are allocated dynamically in groups. This is done to avoid
|
|
* a malloc/free overhead each time the LXT has to grow or shrink.
|
|
*
|
|
* Based on the current lxt_cnt (used), it is always possible to know
|
|
* how many are allocated (used+free). The number of allocated entries is
|
|
* not stored anywhere.
|
|
*
|
|
* The LXT table is re-allocated whenever it needs to cross into another group.
|
|
*/
|
|
#define LXT_GROUP_SIZE 8
|
|
#define LXT_NUM_GROUPS(lxt_cnt) (((lxt_cnt) + 7)/8) /* alloc'ed groups */
|
|
#define LXT_LUNIDX_SHIFT 8 /* LXT entry, shift for LUN index */
|
|
#define LXT_PERM_SHIFT 4 /* LXT entry, shift for permission bits */
|
|
|
|
struct ba_lun_info {
|
|
u64 *lun_alloc_map;
|
|
u32 lun_bmap_size;
|
|
u32 total_aus;
|
|
u64 free_aun_cnt;
|
|
|
|
/* indices to be used for elevator lookup of free map */
|
|
u32 free_low_idx;
|
|
u32 free_curr_idx;
|
|
u32 free_high_idx;
|
|
|
|
u8 *aun_clone_map;
|
|
};
|
|
|
|
struct ba_lun {
|
|
u64 lun_id;
|
|
u64 wwpn;
|
|
size_t lsize; /* LUN size in number of LBAs */
|
|
size_t lba_size; /* LBA size in number of bytes */
|
|
size_t au_size; /* Allocation Unit size in number of LBAs */
|
|
struct ba_lun_info *ba_lun_handle;
|
|
};
|
|
|
|
/* Block Allocator */
|
|
struct blka {
|
|
struct ba_lun ba_lun;
|
|
u64 nchunk; /* number of chunks */
|
|
struct mutex mutex;
|
|
};
|
|
|
|
#endif /* ifndef _CXLFLASH_SUPERPIPE_H */
|