1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
4  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
5  */
6 
7 #if !defined(__EFCT_DRIVER_H__)
8 #define __EFCT_DRIVER_H__
9 
10 /***************************************************************************
11  * OS specific includes
12  */
13 #include <stdarg.h>
14 #include <linux/module.h>
15 #include <linux/debugfs.h>
16 #include <linux/firmware.h>
17 #include "../include/efc_common.h"
18 #include "../libefc/efclib.h"
19 #include "efct_hw.h"
20 #include "efct_io.h"
21 #include "efct_xport.h"
22 
23 #define EFCT_DRIVER_NAME			"efct"
24 #define EFCT_DRIVER_VERSION			"1.0.0.0"
25 
26 /* EFCT_DEFAULT_FILTER-
27  * MRQ filter to segregate the IO flow.
28  */
29 #define EFCT_DEFAULT_FILTER			"0x01ff22ff,0,0,0"
30 
31 /* EFCT_OS_MAX_ISR_TIME_MSEC -
32  * maximum time driver code should spend in an interrupt
33  * or kernel thread context without yielding
34  */
35 #define EFCT_OS_MAX_ISR_TIME_MSEC		1000
36 
37 #define EFCT_FC_MAX_SGL				64
38 #define EFCT_FC_DIF_SEED			0
39 
40 /* Watermark */
41 #define EFCT_WATERMARK_HIGH_PCT			90
42 #define EFCT_WATERMARK_LOW_PCT			80
43 #define EFCT_IO_WATERMARK_PER_INITIATOR		8
44 
45 #define EFCT_PCI_MAX_REGS			6
46 #define MAX_PCI_INTERRUPTS			16
47 
48 struct efct_intr_context {
49 	struct efct		*efct;
50 	u32			index;
51 };
52 
53 struct efct {
54 	struct pci_dev			*pci;
55 	void __iomem			*reg[EFCT_PCI_MAX_REGS];
56 
57 	u32				n_msix_vec;
58 	bool				attached;
59 	bool				soft_wwn_enable;
60 	u8				efct_req_fw_upgrade;
61 	struct efct_intr_context	intr_context[MAX_PCI_INTERRUPTS];
62 	u32				numa_node;
63 
64 	char				name[EFC_NAME_LENGTH];
65 	u32				instance_index;
66 	struct list_head		list_entry;
67 	struct efct_scsi_tgt		tgt_efct;
68 	struct efct_xport		*xport;
69 	struct efc			*efcport;
70 	struct Scsi_Host		*shost;
71 	int				logmask;
72 	u32				max_isr_time_msec;
73 
74 	const char			*desc;
75 
76 	const char			*model;
77 
78 	struct efct_hw			hw;
79 
80 	u32				rq_selection_policy;
81 	char				*filter_def;
82 	int				topology;
83 
84 	/* Look up for target node */
85 	struct xarray			lookup;
86 
87 	/*
88 	 * Target IO timer value:
89 	 * Zero: target command timeout disabled.
90 	 * Non-zero: Timeout value, in seconds, for target commands
91 	 */
92 	u32				target_io_timer_sec;
93 
94 	int				speed;
95 	struct dentry			*sess_debugfs_dir;
96 };
97 
98 #define FW_WRITE_BUFSIZE		(64 * 1024)
99 
100 struct efct_fw_write_result {
101 	struct completion done;
102 	int status;
103 	u32 actual_xfer;
104 	u32 change_status;
105 };
106 
107 extern struct list_head			efct_devices;
108 
109 #endif /* __EFCT_DRIVER_H__ */
110