ice_common.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2018, Intel Corporation. */
  3. #ifndef _ICE_COMMON_H_
  4. #define _ICE_COMMON_H_
  5. #include <linux/bitfield.h>
  6. #include "ice.h"
  7. #include "ice_type.h"
  8. #include "ice_nvm.h"
  9. #include "ice_flex_pipe.h"
  10. #include "ice_parser.h"
  11. #include <linux/avf/virtchnl.h>
  12. #include "ice_switch.h"
  13. #include "ice_fdir.h"
  14. #define ICE_SQ_SEND_DELAY_TIME_MS 10
  15. #define ICE_SQ_SEND_MAX_EXECUTE 3
  16. #define FEC_REG_SHIFT 2
  17. #define FEC_RECV_ID_SHIFT 4
  18. #define FEC_CORR_LOW_REG_PORT0 (0x02 << FEC_REG_SHIFT)
  19. #define FEC_CORR_HIGH_REG_PORT0 (0x03 << FEC_REG_SHIFT)
  20. #define FEC_UNCORR_LOW_REG_PORT0 (0x04 << FEC_REG_SHIFT)
  21. #define FEC_UNCORR_HIGH_REG_PORT0 (0x05 << FEC_REG_SHIFT)
  22. #define FEC_CORR_LOW_REG_PORT1 (0x42 << FEC_REG_SHIFT)
  23. #define FEC_CORR_HIGH_REG_PORT1 (0x43 << FEC_REG_SHIFT)
  24. #define FEC_UNCORR_LOW_REG_PORT1 (0x44 << FEC_REG_SHIFT)
  25. #define FEC_UNCORR_HIGH_REG_PORT1 (0x45 << FEC_REG_SHIFT)
  26. #define FEC_CORR_LOW_REG_PORT2 (0x4A << FEC_REG_SHIFT)
  27. #define FEC_CORR_HIGH_REG_PORT2 (0x4B << FEC_REG_SHIFT)
  28. #define FEC_UNCORR_LOW_REG_PORT2 (0x4C << FEC_REG_SHIFT)
  29. #define FEC_UNCORR_HIGH_REG_PORT2 (0x4D << FEC_REG_SHIFT)
  30. #define FEC_CORR_LOW_REG_PORT3 (0x52 << FEC_REG_SHIFT)
  31. #define FEC_CORR_HIGH_REG_PORT3 (0x53 << FEC_REG_SHIFT)
  32. #define FEC_UNCORR_LOW_REG_PORT3 (0x54 << FEC_REG_SHIFT)
  33. #define FEC_UNCORR_HIGH_REG_PORT3 (0x55 << FEC_REG_SHIFT)
  34. #define FEC_RECEIVER_ID_PCS0 (0x33 << FEC_RECV_ID_SHIFT)
  35. #define FEC_RECEIVER_ID_PCS1 (0x34 << FEC_RECV_ID_SHIFT)
  36. int ice_init_hw(struct ice_hw *hw);
  37. void ice_deinit_hw(struct ice_hw *hw);
  38. int ice_check_reset(struct ice_hw *hw);
  39. int ice_reset(struct ice_hw *hw, enum ice_reset_req req);
  40. int ice_create_all_ctrlq(struct ice_hw *hw);
  41. int ice_init_all_ctrlq(struct ice_hw *hw);
  42. void ice_shutdown_all_ctrlq(struct ice_hw *hw, bool unloading);
  43. void ice_destroy_all_ctrlq(struct ice_hw *hw);
  44. int
  45. ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
  46. struct ice_rq_event_info *e, u16 *pending);
  47. int
  48. ice_get_link_status(struct ice_port_info *pi, bool *link_up);
  49. int ice_update_link_info(struct ice_port_info *pi);
  50. int
  51. ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,
  52. enum ice_aq_res_access_type access, u32 timeout);
  53. void ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res);
  54. int
  55. ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res);
  56. int
  57. ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res);
  58. int ice_aq_alloc_free_res(struct ice_hw *hw,
  59. struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size,
  60. enum ice_adminq_opc opc);
  61. bool ice_is_sbq_supported(struct ice_hw *hw);
  62. struct ice_ctl_q_info *ice_get_sbq(struct ice_hw *hw);
  63. int
  64. ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
  65. struct ice_aq_desc *desc, void *buf, u16 buf_size,
  66. struct ice_sq_cd *cd);
  67. void ice_clear_pxe_mode(struct ice_hw *hw);
  68. int ice_get_caps(struct ice_hw *hw);
  69. void ice_set_safe_mode_caps(struct ice_hw *hw);
  70. int ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx,
  71. u32 rxq_index);
  72. int
  73. ice_aq_get_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *get_params);
  74. int
  75. ice_aq_set_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *set_params);
  76. int
  77. ice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle,
  78. struct ice_aqc_get_set_rss_keys *keys);
  79. int
  80. ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
  81. struct ice_aqc_get_set_rss_keys *keys);
  82. bool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq);
  83. int ice_aq_q_shutdown(struct ice_hw *hw, bool unloading);
  84. void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode);
  85. extern const struct ice_ctx_ele ice_tlan_ctx_info[];
  86. int ice_set_ctx(struct ice_hw *hw, u8 *src_ctx, u8 *dest_ctx,
  87. const struct ice_ctx_ele *ce_info);
  88. extern struct mutex ice_global_cfg_lock_sw;
  89. int
  90. ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc,
  91. void *buf, u16 buf_size, struct ice_sq_cd *cd);
  92. int ice_aq_get_fw_ver(struct ice_hw *hw, struct ice_sq_cd *cd);
  93. int
  94. ice_aq_send_driver_ver(struct ice_hw *hw, struct ice_driver_ver *dv,
  95. struct ice_sq_cd *cd);
  96. int
  97. ice_aq_set_port_params(struct ice_port_info *pi, bool double_vlan,
  98. struct ice_sq_cd *cd);
  99. int
  100. ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
  101. struct ice_aqc_get_phy_caps_data *caps,
  102. struct ice_sq_cd *cd);
  103. bool ice_is_pf_c827(struct ice_hw *hw);
  104. bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw);
  105. bool ice_is_clock_mux_in_netlist(struct ice_hw *hw);
  106. bool ice_is_cgu_in_netlist(struct ice_hw *hw);
  107. bool ice_is_gps_in_netlist(struct ice_hw *hw);
  108. int
  109. ice_aq_get_netlist_node(struct ice_hw *hw, struct ice_aqc_get_link_topo *cmd,
  110. u8 *node_part_number, u16 *node_handle);
  111. int
  112. ice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
  113. enum ice_adminq_opc opc, struct ice_sq_cd *cd);
  114. int
  115. ice_discover_dev_caps(struct ice_hw *hw, struct ice_hw_dev_caps *dev_caps);
  116. void
  117. ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,
  118. u16 link_speeds_bitmap);
  119. int
  120. ice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags,
  121. struct ice_sq_cd *cd);
  122. bool ice_is_generic_mac(struct ice_hw *hw);
  123. bool ice_is_e810(struct ice_hw *hw);
  124. int ice_clear_pf_cfg(struct ice_hw *hw);
  125. int
  126. ice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi,
  127. struct ice_aqc_set_phy_cfg_data *cfg, struct ice_sq_cd *cd);
  128. bool ice_fw_supports_link_override(struct ice_hw *hw);
  129. int
  130. ice_get_link_default_override(struct ice_link_default_override_tlv *ldo,
  131. struct ice_port_info *pi);
  132. bool ice_is_phy_caps_an_enabled(struct ice_aqc_get_phy_caps_data *caps);
  133. int ice_aq_get_phy_equalization(struct ice_hw *hw, u16 data_in, u16 op_code,
  134. u8 serdes_num, int *output);
  135. int
  136. ice_aq_get_fec_stats(struct ice_hw *hw, u16 pcs_quad, u16 pcs_port,
  137. enum ice_fec_stats_types fec_type, u32 *output);
  138. enum ice_fc_mode ice_caps_to_fc_mode(u8 caps);
  139. enum ice_fec_mode ice_caps_to_fec_mode(u8 caps, u8 fec_options);
  140. int
  141. ice_set_fc(struct ice_port_info *pi, u8 *aq_failures,
  142. bool ena_auto_link_update);
  143. int
  144. ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
  145. enum ice_fc_mode req_mode);
  146. bool
  147. ice_phy_caps_equals_cfg(struct ice_aqc_get_phy_caps_data *caps,
  148. struct ice_aqc_set_phy_cfg_data *cfg);
  149. void
  150. ice_copy_phy_caps_to_cfg(struct ice_port_info *pi,
  151. struct ice_aqc_get_phy_caps_data *caps,
  152. struct ice_aqc_set_phy_cfg_data *cfg);
  153. int
  154. ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
  155. enum ice_fec_mode fec);
  156. int
  157. ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
  158. struct ice_sq_cd *cd);
  159. int
  160. ice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd);
  161. int
  162. ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
  163. struct ice_link_status *link, struct ice_sq_cd *cd);
  164. int
  165. ice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask,
  166. struct ice_sq_cd *cd);
  167. int
  168. ice_aq_set_mac_loopback(struct ice_hw *hw, bool ena_lpbk, struct ice_sq_cd *cd);
  169. int
  170. ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
  171. struct ice_sq_cd *cd);
  172. int
  173. ice_aq_get_port_options(struct ice_hw *hw,
  174. struct ice_aqc_get_port_options_elem *options,
  175. u8 *option_count, u8 lport, bool lport_valid,
  176. u8 *active_option_idx, bool *active_option_valid,
  177. u8 *pending_option_idx, bool *pending_option_valid);
  178. int
  179. ice_aq_set_port_option(struct ice_hw *hw, u8 lport, u8 lport_valid,
  180. u8 new_option);
  181. int ice_get_phy_lane_number(struct ice_hw *hw);
  182. int
  183. ice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr,
  184. u16 mem_addr, u8 page, u8 set_page, u8 *data, u8 length,
  185. bool write, struct ice_sq_cd *cd);
  186. u32 ice_get_link_speed(u16 index);
  187. int
  188. ice_cfg_vsi_rdma(struct ice_port_info *pi, u16 vsi_handle, u16 tc_bitmap,
  189. u16 *max_rdmaqs);
  190. int
  191. ice_ena_vsi_rdma_qset(struct ice_port_info *pi, u16 vsi_handle, u8 tc,
  192. u16 *rdma_qset, u16 num_qsets, u32 *qset_teid);
  193. int
  194. ice_dis_vsi_rdma_qset(struct ice_port_info *pi, u16 count, u32 *qset_teid,
  195. u16 *q_id);
  196. int
  197. ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
  198. u16 *q_handle, u16 *q_ids, u32 *q_teids,
  199. enum ice_disq_rst_src rst_src, u16 vmvf_num,
  200. struct ice_sq_cd *cd);
  201. int
  202. ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap,
  203. u16 *max_lanqs);
  204. int
  205. ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
  206. u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
  207. struct ice_sq_cd *cd);
  208. int
  209. ice_aq_cfg_lan_txq(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *buf,
  210. u16 buf_size, u16 num_qs, u8 oldport, u8 newport,
  211. struct ice_sq_cd *cd);
  212. int ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle);
  213. void ice_replay_post(struct ice_hw *hw);
  214. struct ice_q_ctx *
  215. ice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle);
  216. int ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in, u16 flag);
  217. int
  218. ice_aq_get_cgu_abilities(struct ice_hw *hw,
  219. struct ice_aqc_get_cgu_abilities *abilities);
  220. int
  221. ice_aq_set_input_pin_cfg(struct ice_hw *hw, u8 input_idx, u8 flags1, u8 flags2,
  222. u32 freq, s32 phase_delay);
  223. int
  224. ice_aq_get_input_pin_cfg(struct ice_hw *hw, u8 input_idx, u8 *status, u8 *type,
  225. u8 *flags1, u8 *flags2, u32 *freq, s32 *phase_delay);
  226. int
  227. ice_aq_set_output_pin_cfg(struct ice_hw *hw, u8 output_idx, u8 flags,
  228. u8 src_sel, u32 freq, s32 phase_delay);
  229. int
  230. ice_aq_get_output_pin_cfg(struct ice_hw *hw, u8 output_idx, u8 *flags,
  231. u8 *src_sel, u32 *freq, u32 *src_freq);
  232. int
  233. ice_aq_get_cgu_dpll_status(struct ice_hw *hw, u8 dpll_num, u8 *ref_state,
  234. u8 *dpll_state, u8 *config, s64 *phase_offset,
  235. u8 *eec_mode);
  236. int
  237. ice_aq_set_cgu_dpll_config(struct ice_hw *hw, u8 dpll_num, u8 ref_state,
  238. u8 config, u8 eec_mode);
  239. int
  240. ice_aq_set_cgu_ref_prio(struct ice_hw *hw, u8 dpll_num, u8 ref_idx,
  241. u8 ref_priority);
  242. int
  243. ice_aq_get_cgu_ref_prio(struct ice_hw *hw, u8 dpll_num, u8 ref_idx,
  244. u8 *ref_prio);
  245. int
  246. ice_aq_get_cgu_info(struct ice_hw *hw, u32 *cgu_id, u32 *cgu_cfg_ver,
  247. u32 *cgu_fw_ver);
  248. int
  249. ice_aq_set_phy_rec_clk_out(struct ice_hw *hw, u8 phy_output, bool enable,
  250. u32 *freq);
  251. int
  252. ice_aq_get_phy_rec_clk_out(struct ice_hw *hw, u8 *phy_output, u8 *port_num,
  253. u8 *flags, u16 *node_handle);
  254. int ice_aq_get_sensor_reading(struct ice_hw *hw,
  255. struct ice_aqc_get_sensor_reading_resp *data);
  256. void
  257. ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
  258. u64 *prev_stat, u64 *cur_stat);
  259. void
  260. ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
  261. u64 *prev_stat, u64 *cur_stat);
  262. bool ice_is_e810t(struct ice_hw *hw);
  263. bool ice_is_e822(struct ice_hw *hw);
  264. bool ice_is_e823(struct ice_hw *hw);
  265. bool ice_is_e825c(struct ice_hw *hw);
  266. int
  267. ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
  268. struct ice_aqc_txsched_elem_data *buf);
  269. int
  270. ice_aq_set_gpio(struct ice_hw *hw, u16 gpio_ctrl_handle, u8 pin_idx, bool value,
  271. struct ice_sq_cd *cd);
  272. int
  273. ice_aq_get_gpio(struct ice_hw *hw, u16 gpio_ctrl_handle, u8 pin_idx,
  274. bool *value, struct ice_sq_cd *cd);
  275. bool ice_is_100m_speed_supported(struct ice_hw *hw);
  276. u16 ice_get_link_speed_based_on_phy_type(u64 phy_type_low, u64 phy_type_high);
  277. int
  278. ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
  279. struct ice_sq_cd *cd);
  280. bool ice_fw_supports_lldp_fltr_ctrl(struct ice_hw *hw);
  281. int
  282. ice_lldp_fltr_add_remove(struct ice_hw *hw, u16 vsi_num, bool add);
  283. int ice_lldp_execute_pending_mib(struct ice_hw *hw);
  284. int
  285. ice_aq_read_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
  286. u16 bus_addr, __le16 addr, u8 params, u8 *data,
  287. struct ice_sq_cd *cd);
  288. int
  289. ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
  290. u16 bus_addr, __le16 addr, u8 params, const u8 *data,
  291. struct ice_sq_cd *cd);
  292. bool ice_fw_supports_report_dflt_cfg(struct ice_hw *hw);
  293. #endif /* _ICE_COMMON_H_ */