Merge branch 'for-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
[linux-2.6-block.git] / include / linux / qed / qed_iscsi_if.h
CommitLineData
fc831825 1/* QLogic qed NIC Driver
e8f1cb50 2 * Copyright (c) 2015-2017 QLogic Corporation
fc831825 3 *
e8f1cb50
MY
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:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
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.
22 *
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
30 * SOFTWARE.
fc831825
YM
31 */
32
33#ifndef _QED_ISCSI_IF_H
34#define _QED_ISCSI_IF_H
35#include <linux/types.h>
36#include <linux/qed/qed_if.h>
37
38typedef int (*iscsi_event_cb_t) (void *context,
39 u8 fw_event_code, void *fw_handle);
40struct 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;
47
48 u64 iscsi_rx_dropped_pdus_task_not_valid;
49
50 u64 iscsi_rx_data_pdu_cnt;
51 u64 iscsi_rx_r2t_pdu_cnt;
52 u64 iscsi_rx_total_pdu_cnt;
53
54 u64 iscsi_tx_go_to_slow_start_event_cnt;
55 u64 iscsi_tx_fast_retransmit_event_cnt;
56
57 u64 iscsi_tx_data_pdu_cnt;
58 u64 iscsi_tx_r2t_pdu_cnt;
59 u64 iscsi_tx_total_pdu_cnt;
60
61 u64 iscsi_tx_bytes_cnt;
62 u64 iscsi_tx_packet_cnt;
63};
64
65struct qed_dev_iscsi_info {
66 struct qed_dev_info common;
67
68 void __iomem *primary_dbq_rq_addr;
69 void __iomem *secondary_bdq_rq_addr;
70};
71
72struct qed_iscsi_id_params {
73 u8 mac[ETH_ALEN];
74 u32 ip[4];
75 u16 port;
76};
77
78struct qed_iscsi_params_offload {
79 u8 layer_code;
80 dma_addr_t sq_pbl_addr;
81 u32 initial_ack;
82
83 struct qed_iscsi_id_params src;
84 struct qed_iscsi_id_params dst;
85 u16 vlan_id;
86 u8 tcp_flags;
87 u8 ip_version;
88 u8 default_cq;
89
90 u8 ka_max_probe_cnt;
91 u8 dup_ack_theshold;
92 u32 rcv_next;
93 u32 snd_una;
94 u32 snd_next;
95 u32 snd_max;
96 u32 snd_wnd;
97 u32 rcv_wnd;
98 u32 snd_wl1;
99 u32 cwnd;
100 u32 ss_thresh;
101 u16 srtt;
102 u16 rtt_var;
103 u32 ts_time;
104 u32 ts_recent;
105 u32 ts_recent_age;
106 u32 total_rt;
107 u32 ka_timeout_delta;
108 u32 rt_timeout_delta;
109 u8 dup_ack_cnt;
110 u8 snd_wnd_probe_cnt;
111 u8 ka_probe_cnt;
112 u8 rt_cnt;
113 u32 flow_label;
114 u32 ka_timeout;
115 u32 ka_interval;
116 u32 max_rt_time;
117 u32 initial_rcv_wnd;
118 u8 ttl;
119 u8 tos_or_tc;
120 u16 remote_port;
121 u16 local_port;
122 u16 mss;
123 u8 snd_wnd_scale;
124 u8 rcv_wnd_scale;
125 u32 ts_ticks_per_second;
126 u16 da_timeout_value;
127 u8 ack_frequency;
128};
129
130struct qed_iscsi_params_update {
131 u8 update_flag;
132#define QED_ISCSI_CONN_HD_EN BIT(0)
133#define QED_ISCSI_CONN_DD_EN BIT(1)
134#define QED_ISCSI_CONN_INITIAL_R2T BIT(2)
135#define QED_ISCSI_CONN_IMMEDIATE_DATA BIT(3)
136
137 u32 max_seq_size;
138 u32 max_recv_pdu_length;
139 u32 max_send_pdu_length;
140 u32 first_seq_length;
141 u32 exp_stat_sn;
142};
143
144#define MAX_TID_BLOCKS_ISCSI (512)
145struct qed_iscsi_tid {
146 u32 size; /* In bytes per task */
147 u32 num_tids_per_block;
148 u8 *blocks[MAX_TID_BLOCKS_ISCSI];
149};
150
151struct qed_iscsi_cb_ops {
152 struct qed_common_cb_ops common;
153};
154
155/**
156 * struct qed_iscsi_ops - qed iSCSI operations.
157 * @common: common operations pointer
158 * @ll2: light L2 operations pointer
159 * @fill_dev_info: fills iSCSI specific information
160 * @param cdev
161 * @param info
162 * @return 0 on sucesss, otherwise error value.
163 * @register_ops: register iscsi operations
164 * @param cdev
165 * @param ops - specified using qed_iscsi_cb_ops
166 * @param cookie - driver private
167 * @start: iscsi in FW
168 * @param cdev
169 * @param tasks - qed will fill information about tasks
170 * return 0 on success, otherwise error value.
171 * @stop: iscsi in FW
172 * @param cdev
173 * return 0 on success, otherwise error value.
174 * @acquire_conn: acquire a new iscsi connection
175 * @param cdev
176 * @param handle - qed will fill handle that should be
177 * used henceforth as identifier of the
178 * connection.
179 * @param p_doorbell - qed will fill the address of the
180 * doorbell.
181 * @return 0 on sucesss, otherwise error value.
182 * @release_conn: release a previously acquired iscsi connection
183 * @param cdev
184 * @param handle - the connection handle.
185 * @return 0 on success, otherwise error value.
186 * @offload_conn: configures an offloaded connection
187 * @param cdev
188 * @param handle - the connection handle.
189 * @param conn_info - the configuration to use for the
190 * offload.
191 * @return 0 on success, otherwise error value.
192 * @update_conn: updates an offloaded connection
193 * @param cdev
194 * @param handle - the connection handle.
195 * @param conn_info - the configuration to use for the
196 * offload.
197 * @return 0 on success, otherwise error value.
198 * @destroy_conn: stops an offloaded connection
199 * @param cdev
200 * @param handle - the connection handle.
201 * @return 0 on success, otherwise error value.
202 * @clear_sq: clear all task in sq
203 * @param cdev
204 * @param handle - the connection handle.
205 * @return 0 on success, otherwise error value.
206 * @get_stats: iSCSI related statistics
207 * @param cdev
208 * @param stats - pointer to struck that would be filled
209 * we stats
210 * @return 0 on success, error otherwise.
211 */
212struct qed_iscsi_ops {
213 const struct qed_common_ops *common;
214
215 const struct qed_ll2_ops *ll2;
216
217 int (*fill_dev_info)(struct qed_dev *cdev,
218 struct qed_dev_iscsi_info *info);
219
220 void (*register_ops)(struct qed_dev *cdev,
221 struct qed_iscsi_cb_ops *ops, void *cookie);
222
223 int (*start)(struct qed_dev *cdev,
224 struct qed_iscsi_tid *tasks,
225 void *event_context, iscsi_event_cb_t async_event_cb);
226
227 int (*stop)(struct qed_dev *cdev);
228
229 int (*acquire_conn)(struct qed_dev *cdev,
230 u32 *handle,
231 u32 *fw_cid, void __iomem **p_doorbell);
232
233 int (*release_conn)(struct qed_dev *cdev, u32 handle);
234
235 int (*offload_conn)(struct qed_dev *cdev,
236 u32 handle,
237 struct qed_iscsi_params_offload *conn_info);
238
239 int (*update_conn)(struct qed_dev *cdev,
240 u32 handle,
241 struct qed_iscsi_params_update *conn_info);
242
243 int (*destroy_conn)(struct qed_dev *cdev, u32 handle, u8 abrt_conn);
244
245 int (*clear_sq)(struct qed_dev *cdev, u32 handle);
246
247 int (*get_stats)(struct qed_dev *cdev,
248 struct qed_iscsi_stats *stats);
249};
250
251const struct qed_iscsi_ops *qed_get_iscsi_ops(void);
252void qed_put_iscsi_ops(void);
253#endif