18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * CXL Flash Device Driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
68c2ecf20Sopenharmony_ci *             Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright (C) 2015 IBM Corporation
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef _CXLFLASH_COMMON_H
128c2ecf20Sopenharmony_ci#define _CXLFLASH_COMMON_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/async.h>
158c2ecf20Sopenharmony_ci#include <linux/cdev.h>
168c2ecf20Sopenharmony_ci#include <linux/irq_poll.h>
178c2ecf20Sopenharmony_ci#include <linux/list.h>
188c2ecf20Sopenharmony_ci#include <linux/rwsem.h>
198c2ecf20Sopenharmony_ci#include <linux/types.h>
208c2ecf20Sopenharmony_ci#include <scsi/scsi.h>
218c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h>
228c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include "backend.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciextern const struct file_operations cxlflash_cxl_fops;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define MAX_CONTEXT	CXLFLASH_MAX_CONTEXT	/* num contexts per afu */
298c2ecf20Sopenharmony_ci#define MAX_FC_PORTS	CXLFLASH_MAX_FC_PORTS	/* max ports per AFU */
308c2ecf20Sopenharmony_ci#define LEGACY_FC_PORTS	2			/* legacy ports per AFU */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define CHAN2PORTBANK(_x)	((_x) >> ilog2(CXLFLASH_NUM_FC_PORTS_PER_BANK))
338c2ecf20Sopenharmony_ci#define CHAN2BANKPORT(_x)	((_x) & (CXLFLASH_NUM_FC_PORTS_PER_BANK - 1))
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define CHAN2PORTMASK(_x)	(1 << (_x))	/* channel to port mask */
368c2ecf20Sopenharmony_ci#define PORTMASK2CHAN(_x)	(ilog2((_x)))	/* port mask to channel */
378c2ecf20Sopenharmony_ci#define PORTNUM2CHAN(_x)	((_x) - 1)	/* port number to channel */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define CXLFLASH_BLOCK_SIZE	4096		/* 4K blocks */
408c2ecf20Sopenharmony_ci#define CXLFLASH_MAX_XFER_SIZE	16777216	/* 16MB transfer */
418c2ecf20Sopenharmony_ci#define CXLFLASH_MAX_SECTORS	(CXLFLASH_MAX_XFER_SIZE/512)	/* SCSI wants
428c2ecf20Sopenharmony_ci								 * max_sectors
438c2ecf20Sopenharmony_ci								 * in units of
448c2ecf20Sopenharmony_ci								 * 512 byte
458c2ecf20Sopenharmony_ci								 * sectors
468c2ecf20Sopenharmony_ci								 */
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define MAX_RHT_PER_CONTEXT (PAGE_SIZE / sizeof(struct sisl_rht_entry))
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* AFU command retry limit */
518c2ecf20Sopenharmony_ci#define MC_RETRY_CNT	5	/* Sufficient for SCSI and certain AFU errors */
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* Command management definitions */
548c2ecf20Sopenharmony_ci#define CXLFLASH_MAX_CMDS               256
558c2ecf20Sopenharmony_ci#define CXLFLASH_MAX_CMDS_PER_LUN       CXLFLASH_MAX_CMDS
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* RRQ for master issued cmds */
588c2ecf20Sopenharmony_ci#define NUM_RRQ_ENTRY                   CXLFLASH_MAX_CMDS
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* SQ for master issued cmds */
618c2ecf20Sopenharmony_ci#define NUM_SQ_ENTRY			CXLFLASH_MAX_CMDS
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* Hardware queue definitions */
648c2ecf20Sopenharmony_ci#define CXLFLASH_DEF_HWQS		1
658c2ecf20Sopenharmony_ci#define CXLFLASH_MAX_HWQS		8
668c2ecf20Sopenharmony_ci#define PRIMARY_HWQ			0
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic inline void check_sizes(void)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	BUILD_BUG_ON_NOT_POWER_OF_2(CXLFLASH_NUM_FC_PORTS_PER_BANK);
728c2ecf20Sopenharmony_ci	BUILD_BUG_ON_NOT_POWER_OF_2(CXLFLASH_MAX_CMDS);
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* AFU defines a fixed size of 4K for command buffers (borrow 4K page define) */
768c2ecf20Sopenharmony_ci#define CMD_BUFSIZE     SIZE_4K
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cienum cxlflash_lr_state {
798c2ecf20Sopenharmony_ci	LINK_RESET_INVALID,
808c2ecf20Sopenharmony_ci	LINK_RESET_REQUIRED,
818c2ecf20Sopenharmony_ci	LINK_RESET_COMPLETE
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_cienum cxlflash_init_state {
858c2ecf20Sopenharmony_ci	INIT_STATE_NONE,
868c2ecf20Sopenharmony_ci	INIT_STATE_PCI,
878c2ecf20Sopenharmony_ci	INIT_STATE_AFU,
888c2ecf20Sopenharmony_ci	INIT_STATE_SCSI,
898c2ecf20Sopenharmony_ci	INIT_STATE_CDEV
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cienum cxlflash_state {
938c2ecf20Sopenharmony_ci	STATE_PROBING,	/* Initial state during probe */
948c2ecf20Sopenharmony_ci	STATE_PROBED,	/* Temporary state, probe completed but EEH occurred */
958c2ecf20Sopenharmony_ci	STATE_NORMAL,	/* Normal running state, everything good */
968c2ecf20Sopenharmony_ci	STATE_RESET,	/* Reset state, trying to reset/recover */
978c2ecf20Sopenharmony_ci	STATE_FAILTERM	/* Failed/terminating state, error out users/threads */
988c2ecf20Sopenharmony_ci};
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cienum cxlflash_hwq_mode {
1018c2ecf20Sopenharmony_ci	HWQ_MODE_RR,	/* Roundrobin (default) */
1028c2ecf20Sopenharmony_ci	HWQ_MODE_TAG,	/* Distribute based on block MQ tag */
1038c2ecf20Sopenharmony_ci	HWQ_MODE_CPU,	/* CPU affinity */
1048c2ecf20Sopenharmony_ci	MAX_HWQ_MODE
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci/*
1088c2ecf20Sopenharmony_ci * Each context has its own set of resource handles that is visible
1098c2ecf20Sopenharmony_ci * only from that context.
1108c2ecf20Sopenharmony_ci */
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_cistruct cxlflash_cfg {
1138c2ecf20Sopenharmony_ci	struct afu *afu;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	const struct cxlflash_backend_ops *ops;
1168c2ecf20Sopenharmony_ci	struct pci_dev *dev;
1178c2ecf20Sopenharmony_ci	struct pci_device_id *dev_id;
1188c2ecf20Sopenharmony_ci	struct Scsi_Host *host;
1198c2ecf20Sopenharmony_ci	int num_fc_ports;
1208c2ecf20Sopenharmony_ci	struct cdev cdev;
1218c2ecf20Sopenharmony_ci	struct device *chardev;
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	ulong cxlflash_regs_pci;
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci	struct work_struct work_q;
1268c2ecf20Sopenharmony_ci	enum cxlflash_init_state init_state;
1278c2ecf20Sopenharmony_ci	enum cxlflash_lr_state lr_state;
1288c2ecf20Sopenharmony_ci	int lr_port;
1298c2ecf20Sopenharmony_ci	atomic_t scan_host_needed;
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	void *afu_cookie;
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci	atomic_t recovery_threads;
1348c2ecf20Sopenharmony_ci	struct mutex ctx_recovery_mutex;
1358c2ecf20Sopenharmony_ci	struct mutex ctx_tbl_list_mutex;
1368c2ecf20Sopenharmony_ci	struct rw_semaphore ioctl_rwsem;
1378c2ecf20Sopenharmony_ci	struct ctx_info *ctx_tbl[MAX_CONTEXT];
1388c2ecf20Sopenharmony_ci	struct list_head ctx_err_recovery; /* contexts w/ recovery pending */
1398c2ecf20Sopenharmony_ci	struct file_operations cxl_fops;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	/* Parameters that are LUN table related */
1428c2ecf20Sopenharmony_ci	int last_lun_index[MAX_FC_PORTS];
1438c2ecf20Sopenharmony_ci	int promote_lun_index;
1448c2ecf20Sopenharmony_ci	struct list_head lluns; /* list of llun_info structs */
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	wait_queue_head_t tmf_waitq;
1478c2ecf20Sopenharmony_ci	spinlock_t tmf_slock;
1488c2ecf20Sopenharmony_ci	bool tmf_active;
1498c2ecf20Sopenharmony_ci	bool ws_unmap;		/* Write-same unmap supported */
1508c2ecf20Sopenharmony_ci	wait_queue_head_t reset_waitq;
1518c2ecf20Sopenharmony_ci	enum cxlflash_state state;
1528c2ecf20Sopenharmony_ci	async_cookie_t async_reset_cookie;
1538c2ecf20Sopenharmony_ci};
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_cistruct afu_cmd {
1568c2ecf20Sopenharmony_ci	struct sisl_ioarcb rcb;	/* IOARCB (cache line aligned) */
1578c2ecf20Sopenharmony_ci	struct sisl_ioasa sa;	/* IOASA must follow IOARCB */
1588c2ecf20Sopenharmony_ci	struct afu *parent;
1598c2ecf20Sopenharmony_ci	struct scsi_cmnd *scp;
1608c2ecf20Sopenharmony_ci	struct completion cevent;
1618c2ecf20Sopenharmony_ci	struct list_head queue;
1628c2ecf20Sopenharmony_ci	u32 hwq_index;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	u8 cmd_tmf:1,
1658c2ecf20Sopenharmony_ci	   cmd_aborted:1;
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	struct list_head list;	/* Pending commands link */
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	/* As per the SISLITE spec the IOARCB EA has to be 16-byte aligned.
1708c2ecf20Sopenharmony_ci	 * However for performance reasons the IOARCB/IOASA should be
1718c2ecf20Sopenharmony_ci	 * cache line aligned.
1728c2ecf20Sopenharmony_ci	 */
1738c2ecf20Sopenharmony_ci} __aligned(cache_line_size());
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_cistatic inline struct afu_cmd *sc_to_afuc(struct scsi_cmnd *sc)
1768c2ecf20Sopenharmony_ci{
1778c2ecf20Sopenharmony_ci	return PTR_ALIGN(scsi_cmd_priv(sc), __alignof__(struct afu_cmd));
1788c2ecf20Sopenharmony_ci}
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cistatic inline struct afu_cmd *sc_to_afuci(struct scsi_cmnd *sc)
1818c2ecf20Sopenharmony_ci{
1828c2ecf20Sopenharmony_ci	struct afu_cmd *afuc = sc_to_afuc(sc);
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	INIT_LIST_HEAD(&afuc->queue);
1858c2ecf20Sopenharmony_ci	return afuc;
1868c2ecf20Sopenharmony_ci}
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_cistatic inline struct afu_cmd *sc_to_afucz(struct scsi_cmnd *sc)
1898c2ecf20Sopenharmony_ci{
1908c2ecf20Sopenharmony_ci	struct afu_cmd *afuc = sc_to_afuc(sc);
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	memset(afuc, 0, sizeof(*afuc));
1938c2ecf20Sopenharmony_ci	return sc_to_afuci(sc);
1948c2ecf20Sopenharmony_ci}
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_cistruct hwq {
1978c2ecf20Sopenharmony_ci	/* Stuff requiring alignment go first. */
1988c2ecf20Sopenharmony_ci	struct sisl_ioarcb sq[NUM_SQ_ENTRY];		/* 16K SQ */
1998c2ecf20Sopenharmony_ci	u64 rrq_entry[NUM_RRQ_ENTRY];			/* 2K RRQ */
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	/* Beware of alignment till here. Preferably introduce new
2028c2ecf20Sopenharmony_ci	 * fields after this point
2038c2ecf20Sopenharmony_ci	 */
2048c2ecf20Sopenharmony_ci	struct afu *afu;
2058c2ecf20Sopenharmony_ci	void *ctx_cookie;
2068c2ecf20Sopenharmony_ci	struct sisl_host_map __iomem *host_map;		/* MC host map */
2078c2ecf20Sopenharmony_ci	struct sisl_ctrl_map __iomem *ctrl_map;		/* MC control map */
2088c2ecf20Sopenharmony_ci	ctx_hndl_t ctx_hndl;	/* master's context handle */
2098c2ecf20Sopenharmony_ci	u32 index;		/* Index of this hwq */
2108c2ecf20Sopenharmony_ci	int num_irqs;		/* Number of interrupts requested for context */
2118c2ecf20Sopenharmony_ci	struct list_head pending_cmds;	/* Commands pending completion */
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	atomic_t hsq_credits;
2148c2ecf20Sopenharmony_ci	spinlock_t hsq_slock;	/* Hardware send queue lock */
2158c2ecf20Sopenharmony_ci	struct sisl_ioarcb *hsq_start;
2168c2ecf20Sopenharmony_ci	struct sisl_ioarcb *hsq_end;
2178c2ecf20Sopenharmony_ci	struct sisl_ioarcb *hsq_curr;
2188c2ecf20Sopenharmony_ci	spinlock_t hrrq_slock;
2198c2ecf20Sopenharmony_ci	u64 *hrrq_start;
2208c2ecf20Sopenharmony_ci	u64 *hrrq_end;
2218c2ecf20Sopenharmony_ci	u64 *hrrq_curr;
2228c2ecf20Sopenharmony_ci	bool toggle;
2238c2ecf20Sopenharmony_ci	bool hrrq_online;
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci	s64 room;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	struct irq_poll irqpoll;
2288c2ecf20Sopenharmony_ci} __aligned(cache_line_size());
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistruct afu {
2318c2ecf20Sopenharmony_ci	struct hwq hwqs[CXLFLASH_MAX_HWQS];
2328c2ecf20Sopenharmony_ci	int (*send_cmd)(struct afu *afu, struct afu_cmd *cmd);
2338c2ecf20Sopenharmony_ci	int (*context_reset)(struct hwq *hwq);
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	/* AFU HW */
2368c2ecf20Sopenharmony_ci	struct cxlflash_afu_map __iomem *afu_map;	/* entire MMIO map */
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	atomic_t cmds_active;	/* Number of currently active AFU commands */
2398c2ecf20Sopenharmony_ci	struct mutex sync_active;	/* Mutex to serialize AFU commands */
2408c2ecf20Sopenharmony_ci	u64 hb;
2418c2ecf20Sopenharmony_ci	u32 internal_lun;	/* User-desired LUN mode for this AFU */
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	u32 num_hwqs;		/* Number of hardware queues */
2448c2ecf20Sopenharmony_ci	u32 desired_hwqs;	/* Desired h/w queues, effective on AFU reset */
2458c2ecf20Sopenharmony_ci	enum cxlflash_hwq_mode hwq_mode; /* Steering mode for h/w queues */
2468c2ecf20Sopenharmony_ci	u32 hwq_rr_count;	/* Count to distribute traffic for roundrobin */
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	char version[16];
2498c2ecf20Sopenharmony_ci	u64 interface_version;
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	u32 irqpoll_weight;
2528c2ecf20Sopenharmony_ci	struct cxlflash_cfg *parent; /* Pointer back to parent cxlflash_cfg */
2538c2ecf20Sopenharmony_ci};
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_cistatic inline struct hwq *get_hwq(struct afu *afu, u32 index)
2568c2ecf20Sopenharmony_ci{
2578c2ecf20Sopenharmony_ci	WARN_ON(index >= CXLFLASH_MAX_HWQS);
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	return &afu->hwqs[index];
2608c2ecf20Sopenharmony_ci}
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_cistatic inline bool afu_is_irqpoll_enabled(struct afu *afu)
2638c2ecf20Sopenharmony_ci{
2648c2ecf20Sopenharmony_ci	return !!afu->irqpoll_weight;
2658c2ecf20Sopenharmony_ci}
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_cistatic inline bool afu_has_cap(struct afu *afu, u64 cap)
2688c2ecf20Sopenharmony_ci{
2698c2ecf20Sopenharmony_ci	u64 afu_cap = afu->interface_version >> SISL_INTVER_CAP_SHIFT;
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	return afu_cap & cap;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic inline bool afu_is_ocxl_lisn(struct afu *afu)
2758c2ecf20Sopenharmony_ci{
2768c2ecf20Sopenharmony_ci	return afu_has_cap(afu, SISL_INTVER_CAP_OCXL_LISN);
2778c2ecf20Sopenharmony_ci}
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_cistatic inline bool afu_is_afu_debug(struct afu *afu)
2808c2ecf20Sopenharmony_ci{
2818c2ecf20Sopenharmony_ci	return afu_has_cap(afu, SISL_INTVER_CAP_AFU_DEBUG);
2828c2ecf20Sopenharmony_ci}
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_cistatic inline bool afu_is_lun_provision(struct afu *afu)
2858c2ecf20Sopenharmony_ci{
2868c2ecf20Sopenharmony_ci	return afu_has_cap(afu, SISL_INTVER_CAP_LUN_PROVISION);
2878c2ecf20Sopenharmony_ci}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_cistatic inline bool afu_is_sq_cmd_mode(struct afu *afu)
2908c2ecf20Sopenharmony_ci{
2918c2ecf20Sopenharmony_ci	return afu_has_cap(afu, SISL_INTVER_CAP_SQ_CMD_MODE);
2928c2ecf20Sopenharmony_ci}
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_cistatic inline bool afu_is_ioarrin_cmd_mode(struct afu *afu)
2958c2ecf20Sopenharmony_ci{
2968c2ecf20Sopenharmony_ci	return afu_has_cap(afu, SISL_INTVER_CAP_IOARRIN_CMD_MODE);
2978c2ecf20Sopenharmony_ci}
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistatic inline u64 lun_to_lunid(u64 lun)
3008c2ecf20Sopenharmony_ci{
3018c2ecf20Sopenharmony_ci	__be64 lun_id;
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	int_to_scsilun(lun, (struct scsi_lun *)&lun_id);
3048c2ecf20Sopenharmony_ci	return be64_to_cpu(lun_id);
3058c2ecf20Sopenharmony_ci}
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_cistatic inline struct fc_port_bank __iomem *get_fc_port_bank(
3088c2ecf20Sopenharmony_ci					    struct cxlflash_cfg *cfg, int i)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	struct afu *afu = cfg->afu;
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	return &afu->afu_map->global.bank[CHAN2PORTBANK(i)];
3138c2ecf20Sopenharmony_ci}
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_cistatic inline __be64 __iomem *get_fc_port_regs(struct cxlflash_cfg *cfg, int i)
3168c2ecf20Sopenharmony_ci{
3178c2ecf20Sopenharmony_ci	struct fc_port_bank __iomem *fcpb = get_fc_port_bank(cfg, i);
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	return &fcpb->fc_port_regs[CHAN2BANKPORT(i)][0];
3208c2ecf20Sopenharmony_ci}
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_cistatic inline __be64 __iomem *get_fc_port_luns(struct cxlflash_cfg *cfg, int i)
3238c2ecf20Sopenharmony_ci{
3248c2ecf20Sopenharmony_ci	struct fc_port_bank __iomem *fcpb = get_fc_port_bank(cfg, i);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	return &fcpb->fc_port_luns[CHAN2BANKPORT(i)][0];
3278c2ecf20Sopenharmony_ci}
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ciint cxlflash_afu_sync(struct afu *afu, ctx_hndl_t c, res_hndl_t r, u8 mode);
3308c2ecf20Sopenharmony_civoid cxlflash_list_init(void);
3318c2ecf20Sopenharmony_civoid cxlflash_term_global_luns(void);
3328c2ecf20Sopenharmony_civoid cxlflash_free_errpage(void);
3338c2ecf20Sopenharmony_ciint cxlflash_ioctl(struct scsi_device *sdev, unsigned int cmd,
3348c2ecf20Sopenharmony_ci		   void __user *arg);
3358c2ecf20Sopenharmony_civoid cxlflash_stop_term_user_contexts(struct cxlflash_cfg *cfg);
3368c2ecf20Sopenharmony_ciint cxlflash_mark_contexts_error(struct cxlflash_cfg *cfg);
3378c2ecf20Sopenharmony_civoid cxlflash_term_local_luns(struct cxlflash_cfg *cfg);
3388c2ecf20Sopenharmony_civoid cxlflash_restore_luntable(struct cxlflash_cfg *cfg);
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci#endif /* ifndef _CXLFLASH_COMMON_H */
341