i40iw_osdep.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*******************************************************************************
  2. *
  3. * Copyright (c) 2015-2016 Intel Corporation. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenFabrics.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. *
  33. *******************************************************************************/
  34. #ifndef I40IW_OSDEP_H
  35. #define I40IW_OSDEP_H
  36. #include <linux/kernel.h>
  37. #include <linux/string.h>
  38. #include <linux/bitops.h>
  39. #include <net/tcp.h>
  40. #include <crypto/hash.h>
  41. /* get readq/writeq support for 32 bit kernels, use the low-first version */
  42. #include <linux/io-64-nonatomic-lo-hi.h>
  43. #define STATS_TIMER_DELAY 1000
  44. static inline void set_64bit_val(u64 *wqe_words, u32 byte_index, u64 value)
  45. {
  46. wqe_words[byte_index >> 3] = value;
  47. }
  48. /**
  49. * set_32bit_val - set 32 value to hw wqe
  50. * @wqe_words: wqe addr to write
  51. * @byte_index: index in wqe
  52. * @value: value to write
  53. **/
  54. static inline void set_32bit_val(u32 *wqe_words, u32 byte_index, u32 value)
  55. {
  56. wqe_words[byte_index >> 2] = value;
  57. }
  58. /**
  59. * get_64bit_val - read 64 bit value from wqe
  60. * @wqe_words: wqe addr
  61. * @byte_index: index to read from
  62. * @value: read value
  63. **/
  64. static inline void get_64bit_val(u64 *wqe_words, u32 byte_index, u64 *value)
  65. {
  66. *value = wqe_words[byte_index >> 3];
  67. }
  68. /**
  69. * get_32bit_val - read 32 bit value from wqe
  70. * @wqe_words: wqe addr
  71. * @byte_index: index to reaad from
  72. * @value: return 32 bit value
  73. **/
  74. static inline void get_32bit_val(u32 *wqe_words, u32 byte_index, u32 *value)
  75. {
  76. *value = wqe_words[byte_index >> 2];
  77. }
  78. struct i40iw_dma_mem {
  79. void *va;
  80. dma_addr_t pa;
  81. u32 size;
  82. } __packed;
  83. struct i40iw_virt_mem {
  84. void *va;
  85. u32 size;
  86. } __packed;
  87. #define i40iw_debug(h, m, s, ...) \
  88. do { \
  89. if (((m) & (h)->debug_mask)) \
  90. pr_info("i40iw " s, ##__VA_ARGS__); \
  91. } while (0)
  92. #define i40iw_flush(a) readl((a)->hw_addr + I40E_GLGEN_STAT)
  93. #define I40E_GLHMC_VFSDCMD(_i) (0x000C8000 + ((_i) * 4)) \
  94. /* _i=0...31 */
  95. #define I40E_GLHMC_VFSDCMD_MAX_INDEX 31
  96. #define I40E_GLHMC_VFSDCMD_PMSDIDX_SHIFT 0
  97. #define I40E_GLHMC_VFSDCMD_PMSDIDX_MASK (0xFFF \
  98. << I40E_GLHMC_VFSDCMD_PMSDIDX_SHIFT)
  99. #define I40E_GLHMC_VFSDCMD_PF_SHIFT 16
  100. #define I40E_GLHMC_VFSDCMD_PF_MASK (0xF << I40E_GLHMC_VFSDCMD_PF_SHIFT)
  101. #define I40E_GLHMC_VFSDCMD_VF_SHIFT 20
  102. #define I40E_GLHMC_VFSDCMD_VF_MASK (0x1FF << I40E_GLHMC_VFSDCMD_VF_SHIFT)
  103. #define I40E_GLHMC_VFSDCMD_PMF_TYPE_SHIFT 29
  104. #define I40E_GLHMC_VFSDCMD_PMF_TYPE_MASK (0x3 \
  105. << I40E_GLHMC_VFSDCMD_PMF_TYPE_SHIFT)
  106. #define I40E_GLHMC_VFSDCMD_PMSDWR_SHIFT 31
  107. #define I40E_GLHMC_VFSDCMD_PMSDWR_MASK (0x1 << I40E_GLHMC_VFSDCMD_PMSDWR_SHIFT)
  108. #define I40E_GLHMC_VFSDDATAHIGH(_i) (0x000C8200 + ((_i) * 4)) \
  109. /* _i=0...31 */
  110. #define I40E_GLHMC_VFSDDATAHIGH_MAX_INDEX 31
  111. #define I40E_GLHMC_VFSDDATAHIGH_PMSDDATAHIGH_SHIFT 0
  112. #define I40E_GLHMC_VFSDDATAHIGH_PMSDDATAHIGH_MASK (0xFFFFFFFF \
  113. << I40E_GLHMC_VFSDDATAHIGH_PMSDDATAHIGH_SHIFT)
  114. #define I40E_GLHMC_VFSDDATALOW(_i) (0x000C8100 + ((_i) * 4)) \
  115. /* _i=0...31 */
  116. #define I40E_GLHMC_VFSDDATALOW_MAX_INDEX 31
  117. #define I40E_GLHMC_VFSDDATALOW_PMSDVALID_SHIFT 0
  118. #define I40E_GLHMC_VFSDDATALOW_PMSDVALID_MASK (0x1 \
  119. << I40E_GLHMC_VFSDDATALOW_PMSDVALID_SHIFT)
  120. #define I40E_GLHMC_VFSDDATALOW_PMSDTYPE_SHIFT 1
  121. #define I40E_GLHMC_VFSDDATALOW_PMSDTYPE_MASK (0x1 \
  122. << I40E_GLHMC_VFSDDATALOW_PMSDTYPE_SHIFT)
  123. #define I40E_GLHMC_VFSDDATALOW_PMSDBPCOUNT_SHIFT 2
  124. #define I40E_GLHMC_VFSDDATALOW_PMSDBPCOUNT_MASK (0x3FF \
  125. << I40E_GLHMC_VFSDDATALOW_PMSDBPCOUNT_SHIFT)
  126. #define I40E_GLHMC_VFSDDATALOW_PMSDDATALOW_SHIFT 12
  127. #define I40E_GLHMC_VFSDDATALOW_PMSDDATALOW_MASK (0xFFFFF \
  128. << I40E_GLHMC_VFSDDATALOW_PMSDDATALOW_SHIFT)
  129. #define I40E_GLPE_FWLDSTATUS 0x0000D200
  130. #define I40E_GLPE_FWLDSTATUS_LOAD_REQUESTED_SHIFT 0
  131. #define I40E_GLPE_FWLDSTATUS_LOAD_REQUESTED_MASK (0x1 \
  132. << I40E_GLPE_FWLDSTATUS_LOAD_REQUESTED_SHIFT)
  133. #define I40E_GLPE_FWLDSTATUS_DONE_SHIFT 1
  134. #define I40E_GLPE_FWLDSTATUS_DONE_MASK (0x1 << I40E_GLPE_FWLDSTATUS_DONE_SHIFT)
  135. #define I40E_GLPE_FWLDSTATUS_CQP_FAIL_SHIFT 2
  136. #define I40E_GLPE_FWLDSTATUS_CQP_FAIL_MASK (0x1 \
  137. << I40E_GLPE_FWLDSTATUS_CQP_FAIL_SHIFT)
  138. #define I40E_GLPE_FWLDSTATUS_TEP_FAIL_SHIFT 3
  139. #define I40E_GLPE_FWLDSTATUS_TEP_FAIL_MASK (0x1 \
  140. << I40E_GLPE_FWLDSTATUS_TEP_FAIL_SHIFT)
  141. #define I40E_GLPE_FWLDSTATUS_OOP_FAIL_SHIFT 4
  142. #define I40E_GLPE_FWLDSTATUS_OOP_FAIL_MASK (0x1 \
  143. << I40E_GLPE_FWLDSTATUS_OOP_FAIL_SHIFT)
  144. struct i40iw_sc_dev;
  145. struct i40iw_sc_qp;
  146. struct i40iw_puda_buf;
  147. struct i40iw_puda_completion_info;
  148. struct i40iw_update_sds_info;
  149. struct i40iw_hmc_fcn_info;
  150. struct i40iw_virtchnl_work_info;
  151. struct i40iw_manage_vf_pble_info;
  152. struct i40iw_device;
  153. struct i40iw_hmc_info;
  154. struct i40iw_hw;
  155. u8 __iomem *i40iw_get_hw_addr(void *dev);
  156. void i40iw_ieq_mpa_crc_ae(struct i40iw_sc_dev *dev, struct i40iw_sc_qp *qp);
  157. enum i40iw_status_code i40iw_vf_wait_vchnl_resp(struct i40iw_sc_dev *dev);
  158. bool i40iw_vf_clear_to_send(struct i40iw_sc_dev *dev);
  159. enum i40iw_status_code i40iw_ieq_check_mpacrc(struct shash_desc *desc, void *addr,
  160. u32 length, u32 value);
  161. struct i40iw_sc_qp *i40iw_ieq_get_qp(struct i40iw_sc_dev *dev, struct i40iw_puda_buf *buf);
  162. void i40iw_ieq_update_tcpip_info(struct i40iw_puda_buf *buf, u16 length, u32 seqnum);
  163. void i40iw_free_hash_desc(struct shash_desc *);
  164. enum i40iw_status_code i40iw_init_hash_desc(struct shash_desc **);
  165. enum i40iw_status_code i40iw_puda_get_tcpip_info(struct i40iw_puda_completion_info *info,
  166. struct i40iw_puda_buf *buf);
  167. enum i40iw_status_code i40iw_cqp_sds_cmd(struct i40iw_sc_dev *dev,
  168. struct i40iw_update_sds_info *info);
  169. enum i40iw_status_code i40iw_cqp_manage_hmc_fcn_cmd(struct i40iw_sc_dev *dev,
  170. struct i40iw_hmc_fcn_info *hmcfcninfo);
  171. enum i40iw_status_code i40iw_cqp_query_fpm_values_cmd(struct i40iw_sc_dev *dev,
  172. struct i40iw_dma_mem *values_mem,
  173. u8 hmc_fn_id);
  174. enum i40iw_status_code i40iw_cqp_commit_fpm_values_cmd(struct i40iw_sc_dev *dev,
  175. struct i40iw_dma_mem *values_mem,
  176. u8 hmc_fn_id);
  177. enum i40iw_status_code i40iw_alloc_query_fpm_buf(struct i40iw_sc_dev *dev,
  178. struct i40iw_dma_mem *mem);
  179. enum i40iw_status_code i40iw_cqp_manage_vf_pble_bp(struct i40iw_sc_dev *dev,
  180. struct i40iw_manage_vf_pble_info *info);
  181. void i40iw_cqp_spawn_worker(struct i40iw_sc_dev *dev,
  182. struct i40iw_virtchnl_work_info *work_info, u32 iw_vf_idx);
  183. void *i40iw_remove_head(struct list_head *list);
  184. void i40iw_term_modify_qp(struct i40iw_sc_qp *qp, u8 next_state, u8 term, u8 term_len);
  185. void i40iw_terminate_done(struct i40iw_sc_qp *qp, int timeout_occurred);
  186. void i40iw_terminate_start_timer(struct i40iw_sc_qp *qp);
  187. void i40iw_terminate_del_timer(struct i40iw_sc_qp *qp);
  188. enum i40iw_status_code i40iw_hw_manage_vf_pble_bp(struct i40iw_device *iwdev,
  189. struct i40iw_manage_vf_pble_info *info,
  190. bool wait);
  191. struct i40iw_dev_pestat;
  192. void i40iw_hw_stats_start_timer(struct i40iw_sc_dev *);
  193. void i40iw_hw_stats_del_timer(struct i40iw_sc_dev *);
  194. #define i40iw_mmiowb() mmiowb()
  195. void i40iw_wr32(struct i40iw_hw *hw, u32 reg, u32 value);
  196. u32 i40iw_rd32(struct i40iw_hw *hw, u32 reg);
  197. #endif /* _I40IW_OSDEP_H_ */