1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #ifndef _QED_ISCSI_IF_H
34 #define _QED_ISCSI_IF_H
35 #include <linux/types.h>
36 #include <linux/qed/qed_if.h>
38 typedef int (*iscsi_event_cb_t) (void *context,
39 u8 fw_event_code, void *fw_handle);
40 struct qed_iscsi_stats {
41 u64 iscsi_rx_bytes_cnt;
42 u64 iscsi_rx_packet_cnt;
43 u64 iscsi_rx_new_ooo_isle_events_cnt;
44 u32 iscsi_cmdq_threshold_cnt;
45 u32 iscsi_rq_threshold_cnt;
46 u32 iscsi_immq_threshold_cnt;
48 u64 iscsi_rx_dropped_pdus_task_not_valid;
50 u64 iscsi_rx_data_pdu_cnt;
51 u64 iscsi_rx_r2t_pdu_cnt;
52 u64 iscsi_rx_total_pdu_cnt;
54 u64 iscsi_tx_go_to_slow_start_event_cnt;
55 u64 iscsi_tx_fast_retransmit_event_cnt;
57 u64 iscsi_tx_data_pdu_cnt;
58 u64 iscsi_tx_r2t_pdu_cnt;
59 u64 iscsi_tx_total_pdu_cnt;
61 u64 iscsi_tx_bytes_cnt;
62 u64 iscsi_tx_packet_cnt;
65 struct qed_dev_iscsi_info {
66 struct qed_dev_info common;
68 void __iomem *primary_dbq_rq_addr;
69 void __iomem *secondary_bdq_rq_addr;
74 struct qed_iscsi_id_params {
80 struct qed_iscsi_params_offload {
82 dma_addr_t sq_pbl_addr;
85 struct qed_iscsi_id_params src;
86 struct qed_iscsi_id_params dst;
109 u32 ka_timeout_delta;
110 u32 rt_timeout_delta;
112 u8 snd_wnd_probe_cnt;
127 u32 ts_ticks_per_second;
128 u16 da_timeout_value;
132 struct qed_iscsi_params_update {
134 #define QED_ISCSI_CONN_HD_EN BIT(0)
135 #define QED_ISCSI_CONN_DD_EN BIT(1)
136 #define QED_ISCSI_CONN_INITIAL_R2T BIT(2)
137 #define QED_ISCSI_CONN_IMMEDIATE_DATA BIT(3)
140 u32 max_recv_pdu_length;
141 u32 max_send_pdu_length;
142 u32 first_seq_length;
146 #define MAX_TID_BLOCKS_ISCSI (512)
147 struct qed_iscsi_tid {
148 u32 size; /* In bytes per task */
149 u32 num_tids_per_block;
150 u8 *blocks[MAX_TID_BLOCKS_ISCSI];
153 struct qed_iscsi_cb_ops {
154 struct qed_common_cb_ops common;
158 * struct qed_iscsi_ops - qed iSCSI operations.
159 * @common: common operations pointer
160 * @ll2: light L2 operations pointer
161 * @fill_dev_info: fills iSCSI specific information
164 * @return 0 on sucesss, otherwise error value.
165 * @register_ops: register iscsi operations
167 * @param ops - specified using qed_iscsi_cb_ops
168 * @param cookie - driver private
169 * @start: iscsi in FW
171 * @param tasks - qed will fill information about tasks
172 * return 0 on success, otherwise error value.
175 * return 0 on success, otherwise error value.
176 * @acquire_conn: acquire a new iscsi connection
178 * @param handle - qed will fill handle that should be
179 * used henceforth as identifier of the
181 * @param p_doorbell - qed will fill the address of the
183 * @return 0 on sucesss, otherwise error value.
184 * @release_conn: release a previously acquired iscsi connection
186 * @param handle - the connection handle.
187 * @return 0 on success, otherwise error value.
188 * @offload_conn: configures an offloaded connection
190 * @param handle - the connection handle.
191 * @param conn_info - the configuration to use for the
193 * @return 0 on success, otherwise error value.
194 * @update_conn: updates an offloaded connection
196 * @param handle - the connection handle.
197 * @param conn_info - the configuration to use for the
199 * @return 0 on success, otherwise error value.
200 * @destroy_conn: stops an offloaded connection
202 * @param handle - the connection handle.
203 * @return 0 on success, otherwise error value.
204 * @clear_sq: clear all task in sq
206 * @param handle - the connection handle.
207 * @return 0 on success, otherwise error value.
208 * @get_stats: iSCSI related statistics
210 * @param stats - pointer to struck that would be filled
212 * @return 0 on success, error otherwise.
213 * @change_mac Change MAC of interface
215 * @param handle - the connection handle.
216 * @param mac - new MAC to configure.
217 * @return 0 on success, otherwise error value.
219 struct qed_iscsi_ops {
220 const struct qed_common_ops *common;
222 const struct qed_ll2_ops *ll2;
224 int (*fill_dev_info)(struct qed_dev *cdev,
225 struct qed_dev_iscsi_info *info);
227 void (*register_ops)(struct qed_dev *cdev,
228 struct qed_iscsi_cb_ops *ops, void *cookie);
230 int (*start)(struct qed_dev *cdev,
231 struct qed_iscsi_tid *tasks,
232 void *event_context, iscsi_event_cb_t async_event_cb);
234 int (*stop)(struct qed_dev *cdev);
236 int (*acquire_conn)(struct qed_dev *cdev,
238 u32 *fw_cid, void __iomem **p_doorbell);
240 int (*release_conn)(struct qed_dev *cdev, u32 handle);
242 int (*offload_conn)(struct qed_dev *cdev,
244 struct qed_iscsi_params_offload *conn_info);
246 int (*update_conn)(struct qed_dev *cdev,
248 struct qed_iscsi_params_update *conn_info);
250 int (*destroy_conn)(struct qed_dev *cdev, u32 handle, u8 abrt_conn);
252 int (*clear_sq)(struct qed_dev *cdev, u32 handle);
254 int (*get_stats)(struct qed_dev *cdev,
255 struct qed_iscsi_stats *stats);
257 int (*change_mac)(struct qed_dev *cdev, u32 handle, const u8 *mac);
260 const struct qed_iscsi_ops *qed_get_iscsi_ops(void);
261 void qed_put_iscsi_ops(void);