1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
7 #ifndef _QED_ISCSI_IF_H
8 #define _QED_ISCSI_IF_H
9 #include <linux/types.h>
10 #include <linux/qed/qed_if.h>
12 typedef int (*iscsi_event_cb_t) (void *context,
13 u8 fw_event_code, void *fw_handle);
14 struct qed_iscsi_stats {
15 u64 iscsi_rx_bytes_cnt;
16 u64 iscsi_rx_packet_cnt;
17 u64 iscsi_rx_new_ooo_isle_events_cnt;
18 u32 iscsi_cmdq_threshold_cnt;
19 u32 iscsi_rq_threshold_cnt;
20 u32 iscsi_immq_threshold_cnt;
22 u64 iscsi_rx_dropped_pdus_task_not_valid;
24 u64 iscsi_rx_data_pdu_cnt;
25 u64 iscsi_rx_r2t_pdu_cnt;
26 u64 iscsi_rx_total_pdu_cnt;
28 u64 iscsi_tx_go_to_slow_start_event_cnt;
29 u64 iscsi_tx_fast_retransmit_event_cnt;
31 u64 iscsi_tx_data_pdu_cnt;
32 u64 iscsi_tx_r2t_pdu_cnt;
33 u64 iscsi_tx_total_pdu_cnt;
35 u64 iscsi_tx_bytes_cnt;
36 u64 iscsi_tx_packet_cnt;
39 struct qed_dev_iscsi_info {
40 struct qed_dev_info common;
42 void __iomem *primary_dbq_rq_addr;
43 void __iomem *secondary_bdq_rq_addr;
48 struct qed_iscsi_id_params {
54 struct qed_iscsi_params_offload {
56 dma_addr_t sq_pbl_addr;
59 struct qed_iscsi_id_params src;
60 struct qed_iscsi_id_params dst;
100 u16 da_timeout_value;
104 struct qed_iscsi_params_update {
106 #define QED_ISCSI_CONN_HD_EN BIT(0)
107 #define QED_ISCSI_CONN_DD_EN BIT(1)
108 #define QED_ISCSI_CONN_INITIAL_R2T BIT(2)
109 #define QED_ISCSI_CONN_IMMEDIATE_DATA BIT(3)
112 u32 max_recv_pdu_length;
113 u32 max_send_pdu_length;
114 u32 first_seq_length;
118 #define MAX_TID_BLOCKS_ISCSI (512)
119 struct qed_iscsi_tid {
120 u32 size; /* In bytes per task */
121 u32 num_tids_per_block;
122 u8 *blocks[MAX_TID_BLOCKS_ISCSI];
125 struct qed_iscsi_cb_ops {
126 struct qed_common_cb_ops common;
130 * struct qed_iscsi_ops - qed iSCSI operations.
131 * @common: common operations pointer
132 * @ll2: light L2 operations pointer
133 * @fill_dev_info: fills iSCSI specific information
136 * @return 0 on sucesss, otherwise error value.
137 * @register_ops: register iscsi operations
139 * @param ops - specified using qed_iscsi_cb_ops
140 * @param cookie - driver private
141 * @start: iscsi in FW
143 * @param tasks - qed will fill information about tasks
144 * return 0 on success, otherwise error value.
147 * return 0 on success, otherwise error value.
148 * @acquire_conn: acquire a new iscsi connection
150 * @param handle - qed will fill handle that should be
151 * used henceforth as identifier of the
153 * @param p_doorbell - qed will fill the address of the
155 * @return 0 on sucesss, otherwise error value.
156 * @release_conn: release a previously acquired iscsi connection
158 * @param handle - the connection handle.
159 * @return 0 on success, otherwise error value.
160 * @offload_conn: configures an offloaded connection
162 * @param handle - the connection handle.
163 * @param conn_info - the configuration to use for the
165 * @return 0 on success, otherwise error value.
166 * @update_conn: updates an offloaded connection
168 * @param handle - the connection handle.
169 * @param conn_info - the configuration to use for the
171 * @return 0 on success, otherwise error value.
172 * @destroy_conn: stops an offloaded connection
174 * @param handle - the connection handle.
175 * @return 0 on success, otherwise error value.
176 * @clear_sq: clear all task in sq
178 * @param handle - the connection handle.
179 * @return 0 on success, otherwise error value.
180 * @get_stats: iSCSI related statistics
182 * @param stats - pointer to struck that would be filled
184 * @return 0 on success, error otherwise.
185 * @change_mac Change MAC of interface
187 * @param handle - the connection handle.
188 * @param mac - new MAC to configure.
189 * @return 0 on success, otherwise error value.
191 struct qed_iscsi_ops {
192 const struct qed_common_ops *common;
194 const struct qed_ll2_ops *ll2;
196 int (*fill_dev_info)(struct qed_dev *cdev,
197 struct qed_dev_iscsi_info *info);
199 void (*register_ops)(struct qed_dev *cdev,
200 struct qed_iscsi_cb_ops *ops, void *cookie);
202 int (*start)(struct qed_dev *cdev,
203 struct qed_iscsi_tid *tasks,
204 void *event_context, iscsi_event_cb_t async_event_cb);
206 int (*stop)(struct qed_dev *cdev);
208 int (*acquire_conn)(struct qed_dev *cdev,
210 u32 *fw_cid, void __iomem **p_doorbell);
212 int (*release_conn)(struct qed_dev *cdev, u32 handle);
214 int (*offload_conn)(struct qed_dev *cdev,
216 struct qed_iscsi_params_offload *conn_info);
218 int (*update_conn)(struct qed_dev *cdev,
220 struct qed_iscsi_params_update *conn_info);
222 int (*destroy_conn)(struct qed_dev *cdev, u32 handle, u8 abrt_conn);
224 int (*clear_sq)(struct qed_dev *cdev, u32 handle);
226 int (*get_stats)(struct qed_dev *cdev,
227 struct qed_iscsi_stats *stats);
229 int (*change_mac)(struct qed_dev *cdev, u32 handle, const u8 *mac);
232 const struct qed_iscsi_ops *qed_get_iscsi_ops(void);
233 void qed_put_iscsi_ops(void);