qed_iscsi_if.h 7.1 KB

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