qed_l2.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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_L2_H
  33. #define _QED_L2_H
  34. #include <linux/types.h>
  35. #include <linux/io.h>
  36. #include <linux/kernel.h>
  37. #include <linux/slab.h>
  38. #include <linux/qed/qed_eth_if.h>
  39. #include "qed.h"
  40. #include "qed_hw.h"
  41. #include "qed_sp.h"
  42. struct qed_rss_params {
  43. u8 update_rss_config;
  44. u8 rss_enable;
  45. u8 rss_eng_id;
  46. u8 update_rss_capabilities;
  47. u8 update_rss_ind_table;
  48. u8 update_rss_key;
  49. u8 rss_caps;
  50. u8 rss_table_size_log;
  51. /* Indirection table consist of rx queue handles */
  52. void *rss_ind_table[QED_RSS_IND_TABLE_SIZE];
  53. u32 rss_key[QED_RSS_KEY_SIZE];
  54. };
  55. struct qed_sge_tpa_params {
  56. u8 max_buffers_per_cqe;
  57. u8 update_tpa_en_flg;
  58. u8 tpa_ipv4_en_flg;
  59. u8 tpa_ipv6_en_flg;
  60. u8 tpa_ipv4_tunn_en_flg;
  61. u8 tpa_ipv6_tunn_en_flg;
  62. u8 update_tpa_param_flg;
  63. u8 tpa_pkt_split_flg;
  64. u8 tpa_hdr_data_split_flg;
  65. u8 tpa_gro_consistent_flg;
  66. u8 tpa_max_aggs_num;
  67. u16 tpa_max_size;
  68. u16 tpa_min_size_to_start;
  69. u16 tpa_min_size_to_cont;
  70. };
  71. enum qed_filter_opcode {
  72. QED_FILTER_ADD,
  73. QED_FILTER_REMOVE,
  74. QED_FILTER_MOVE,
  75. QED_FILTER_REPLACE, /* Delete all MACs and add new one instead */
  76. QED_FILTER_FLUSH, /* Removes all filters */
  77. };
  78. enum qed_filter_ucast_type {
  79. QED_FILTER_MAC,
  80. QED_FILTER_VLAN,
  81. QED_FILTER_MAC_VLAN,
  82. QED_FILTER_INNER_MAC,
  83. QED_FILTER_INNER_VLAN,
  84. QED_FILTER_INNER_PAIR,
  85. QED_FILTER_INNER_MAC_VNI_PAIR,
  86. QED_FILTER_MAC_VNI_PAIR,
  87. QED_FILTER_VNI,
  88. };
  89. struct qed_filter_ucast {
  90. enum qed_filter_opcode opcode;
  91. enum qed_filter_ucast_type type;
  92. u8 is_rx_filter;
  93. u8 is_tx_filter;
  94. u8 vport_to_add_to;
  95. u8 vport_to_remove_from;
  96. unsigned char mac[ETH_ALEN];
  97. u8 assert_on_error;
  98. u16 vlan;
  99. u32 vni;
  100. };
  101. struct qed_filter_mcast {
  102. /* MOVE is not supported for multicast */
  103. enum qed_filter_opcode opcode;
  104. u8 vport_to_add_to;
  105. u8 vport_to_remove_from;
  106. u8 num_mc_addrs;
  107. #define QED_MAX_MC_ADDRS 64
  108. unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN];
  109. };
  110. /**
  111. * @brief qed_eth_rx_queue_stop - This ramrod closes an Rx queue
  112. *
  113. * @param p_hwfn
  114. * @param p_rxq Handler of queue to close
  115. * @param eq_completion_only If True completion will be on
  116. * EQe, if False completion will be
  117. * on EQe if p_hwfn opaque
  118. * different from the RXQ opaque
  119. * otherwise on CQe.
  120. * @param cqe_completion If True completion will be
  121. * receive on CQe.
  122. * @return int
  123. */
  124. int
  125. qed_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
  126. void *p_rxq,
  127. bool eq_completion_only, bool cqe_completion);
  128. /**
  129. * @brief qed_eth_tx_queue_stop - closes a Tx queue
  130. *
  131. * @param p_hwfn
  132. * @param p_txq - handle to Tx queue needed to be closed
  133. *
  134. * @return int
  135. */
  136. int qed_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, void *p_txq);
  137. enum qed_tpa_mode {
  138. QED_TPA_MODE_NONE,
  139. QED_TPA_MODE_UNUSED,
  140. QED_TPA_MODE_GRO,
  141. QED_TPA_MODE_MAX
  142. };
  143. struct qed_sp_vport_start_params {
  144. enum qed_tpa_mode tpa_mode;
  145. bool remove_inner_vlan;
  146. bool tx_switching;
  147. bool handle_ptp_pkts;
  148. bool only_untagged;
  149. bool drop_ttl0;
  150. u8 max_buffers_per_cqe;
  151. u32 concrete_fid;
  152. u16 opaque_fid;
  153. u8 vport_id;
  154. u16 mtu;
  155. bool check_mac;
  156. bool check_ethtype;
  157. };
  158. int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
  159. struct qed_sp_vport_start_params *p_params);
  160. struct qed_filter_accept_flags {
  161. u8 update_rx_mode_config;
  162. u8 update_tx_mode_config;
  163. u8 rx_accept_filter;
  164. u8 tx_accept_filter;
  165. #define QED_ACCEPT_NONE 0x01
  166. #define QED_ACCEPT_UCAST_MATCHED 0x02
  167. #define QED_ACCEPT_UCAST_UNMATCHED 0x04
  168. #define QED_ACCEPT_MCAST_MATCHED 0x08
  169. #define QED_ACCEPT_MCAST_UNMATCHED 0x10
  170. #define QED_ACCEPT_BCAST 0x20
  171. };
  172. struct qed_sp_vport_update_params {
  173. u16 opaque_fid;
  174. u8 vport_id;
  175. u8 update_vport_active_rx_flg;
  176. u8 vport_active_rx_flg;
  177. u8 update_vport_active_tx_flg;
  178. u8 vport_active_tx_flg;
  179. u8 update_inner_vlan_removal_flg;
  180. u8 inner_vlan_removal_flg;
  181. u8 silent_vlan_removal_flg;
  182. u8 update_default_vlan_enable_flg;
  183. u8 default_vlan_enable_flg;
  184. u8 update_default_vlan_flg;
  185. u16 default_vlan;
  186. u8 update_tx_switching_flg;
  187. u8 tx_switching_flg;
  188. u8 update_approx_mcast_flg;
  189. u8 update_anti_spoofing_en_flg;
  190. u8 anti_spoofing_en;
  191. u8 update_accept_any_vlan_flg;
  192. u8 accept_any_vlan;
  193. unsigned long bins[8];
  194. struct qed_rss_params *rss_params;
  195. struct qed_filter_accept_flags accept_flags;
  196. struct qed_sge_tpa_params *sge_tpa_params;
  197. };
  198. int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
  199. struct qed_sp_vport_update_params *p_params,
  200. enum spq_mode comp_mode,
  201. struct qed_spq_comp_cb *p_comp_data);
  202. /**
  203. * @brief qed_sp_vport_stop -
  204. *
  205. * This ramrod closes a VPort after all its RX and TX queues are terminated.
  206. * An Assert is generated if any queues are left open.
  207. *
  208. * @param p_hwfn
  209. * @param opaque_fid
  210. * @param vport_id VPort ID
  211. *
  212. * @return int
  213. */
  214. int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);
  215. int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
  216. u16 opaque_fid,
  217. struct qed_filter_ucast *p_filter_cmd,
  218. enum spq_mode comp_mode,
  219. struct qed_spq_comp_cb *p_comp_data);
  220. /**
  221. * @brief qed_sp_rx_eth_queues_update -
  222. *
  223. * This ramrod updates an RX queue. It is used for setting the active state
  224. * of the queue and updating the TPA and SGE parameters.
  225. *
  226. * @note At the moment - only used by non-linux VFs.
  227. *
  228. * @param p_hwfn
  229. * @param pp_rxq_handlers An array of queue handlers to be updated.
  230. * @param num_rxqs number of queues to update.
  231. * @param complete_cqe_flg Post completion to the CQE Ring if set
  232. * @param complete_event_flg Post completion to the Event Ring if set
  233. * @param comp_mode
  234. * @param p_comp_data
  235. *
  236. * @return int
  237. */
  238. int
  239. qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
  240. void **pp_rxq_handlers,
  241. u8 num_rxqs,
  242. u8 complete_cqe_flg,
  243. u8 complete_event_flg,
  244. enum spq_mode comp_mode,
  245. struct qed_spq_comp_cb *p_comp_data);
  246. void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats);
  247. void qed_reset_vport_stats(struct qed_dev *cdev);
  248. struct qed_queue_cid {
  249. /* 'Relative' is a relative term ;-). Usually the indices [not counting
  250. * SBs] would be PF-relative, but there are some cases where that isn't
  251. * the case - specifically for a PF configuring its VF indices it's
  252. * possible some fields [E.g., stats-id] in 'rel' would already be abs.
  253. */
  254. struct qed_queue_start_common_params rel;
  255. struct qed_queue_start_common_params abs;
  256. u32 cid;
  257. u16 opaque_fid;
  258. /* VFs queues are mapped differently, so we need to know the
  259. * relative queue associated with them [0-based].
  260. * Notice this is relevant on the *PF* queue-cid of its VF's queues,
  261. * and not on the VF itself.
  262. */
  263. bool is_vf;
  264. u8 vf_qid;
  265. /* Legacy VFs might have Rx producer located elsewhere */
  266. bool b_legacy_vf;
  267. struct qed_hwfn *p_owner;
  268. };
  269. void qed_eth_queue_cid_release(struct qed_hwfn *p_hwfn,
  270. struct qed_queue_cid *p_cid);
  271. struct qed_queue_cid *_qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
  272. u16 opaque_fid,
  273. u32 cid,
  274. u8 vf_qid,
  275. struct qed_queue_start_common_params
  276. *p_params);
  277. int
  278. qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
  279. struct qed_sp_vport_start_params *p_params);
  280. /**
  281. * @brief - Starts an Rx queue, when queue_cid is already prepared
  282. *
  283. * @param p_hwfn
  284. * @param p_cid
  285. * @param bd_max_bytes
  286. * @param bd_chain_phys_addr
  287. * @param cqe_pbl_addr
  288. * @param cqe_pbl_size
  289. *
  290. * @return int
  291. */
  292. int
  293. qed_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
  294. struct qed_queue_cid *p_cid,
  295. u16 bd_max_bytes,
  296. dma_addr_t bd_chain_phys_addr,
  297. dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);
  298. /**
  299. * @brief - Starts a Tx queue, where queue_cid is already prepared
  300. *
  301. * @param p_hwfn
  302. * @param p_cid
  303. * @param pbl_addr
  304. * @param pbl_size
  305. * @param p_pq_params - parameters for choosing the PQ for this Tx queue
  306. *
  307. * @return int
  308. */
  309. int
  310. qed_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
  311. struct qed_queue_cid *p_cid,
  312. dma_addr_t pbl_addr, u16 pbl_size, u16 pq_id);
  313. u8 qed_mcast_bin_from_mac(u8 *mac);
  314. #endif /* _QED_L2_H */