qed_l2.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015 QLogic Corporation
  3. *
  4. * This software is available under the terms of the GNU General Public License
  5. * (GPL) Version 2, available from the file COPYING in the main directory of
  6. * this source tree.
  7. */
  8. #ifndef _QED_L2_H
  9. #define _QED_L2_H
  10. #include <linux/types.h>
  11. #include <linux/io.h>
  12. #include <linux/kernel.h>
  13. #include <linux/slab.h>
  14. #include <linux/qed/qed_eth_if.h>
  15. #include "qed.h"
  16. #include "qed_hw.h"
  17. #include "qed_sp.h"
  18. struct qed_sge_tpa_params {
  19. u8 max_buffers_per_cqe;
  20. u8 update_tpa_en_flg;
  21. u8 tpa_ipv4_en_flg;
  22. u8 tpa_ipv6_en_flg;
  23. u8 tpa_ipv4_tunn_en_flg;
  24. u8 tpa_ipv6_tunn_en_flg;
  25. u8 update_tpa_param_flg;
  26. u8 tpa_pkt_split_flg;
  27. u8 tpa_hdr_data_split_flg;
  28. u8 tpa_gro_consistent_flg;
  29. u8 tpa_max_aggs_num;
  30. u16 tpa_max_size;
  31. u16 tpa_min_size_to_start;
  32. u16 tpa_min_size_to_cont;
  33. };
  34. enum qed_filter_opcode {
  35. QED_FILTER_ADD,
  36. QED_FILTER_REMOVE,
  37. QED_FILTER_MOVE,
  38. QED_FILTER_REPLACE, /* Delete all MACs and add new one instead */
  39. QED_FILTER_FLUSH, /* Removes all filters */
  40. };
  41. enum qed_filter_ucast_type {
  42. QED_FILTER_MAC,
  43. QED_FILTER_VLAN,
  44. QED_FILTER_MAC_VLAN,
  45. QED_FILTER_INNER_MAC,
  46. QED_FILTER_INNER_VLAN,
  47. QED_FILTER_INNER_PAIR,
  48. QED_FILTER_INNER_MAC_VNI_PAIR,
  49. QED_FILTER_MAC_VNI_PAIR,
  50. QED_FILTER_VNI,
  51. };
  52. struct qed_filter_ucast {
  53. enum qed_filter_opcode opcode;
  54. enum qed_filter_ucast_type type;
  55. u8 is_rx_filter;
  56. u8 is_tx_filter;
  57. u8 vport_to_add_to;
  58. u8 vport_to_remove_from;
  59. unsigned char mac[ETH_ALEN];
  60. u8 assert_on_error;
  61. u16 vlan;
  62. u32 vni;
  63. };
  64. struct qed_filter_mcast {
  65. /* MOVE is not supported for multicast */
  66. enum qed_filter_opcode opcode;
  67. u8 vport_to_add_to;
  68. u8 vport_to_remove_from;
  69. u8 num_mc_addrs;
  70. #define QED_MAX_MC_ADDRS 64
  71. unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN];
  72. };
  73. int qed_sp_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
  74. u16 rx_queue_id,
  75. bool eq_completion_only, bool cqe_completion);
  76. int qed_sp_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, u16 tx_queue_id);
  77. enum qed_tpa_mode {
  78. QED_TPA_MODE_NONE,
  79. QED_TPA_MODE_UNUSED,
  80. QED_TPA_MODE_GRO,
  81. QED_TPA_MODE_MAX
  82. };
  83. struct qed_sp_vport_start_params {
  84. enum qed_tpa_mode tpa_mode;
  85. bool remove_inner_vlan;
  86. bool tx_switching;
  87. bool only_untagged;
  88. bool drop_ttl0;
  89. u8 max_buffers_per_cqe;
  90. u32 concrete_fid;
  91. u16 opaque_fid;
  92. u8 vport_id;
  93. u16 mtu;
  94. };
  95. int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
  96. struct qed_sp_vport_start_params *p_params);
  97. struct qed_rss_params {
  98. u8 update_rss_config;
  99. u8 rss_enable;
  100. u8 rss_eng_id;
  101. u8 update_rss_capabilities;
  102. u8 update_rss_ind_table;
  103. u8 update_rss_key;
  104. u8 rss_caps;
  105. u8 rss_table_size_log;
  106. u16 rss_ind_table[QED_RSS_IND_TABLE_SIZE];
  107. u32 rss_key[QED_RSS_KEY_SIZE];
  108. };
  109. struct qed_filter_accept_flags {
  110. u8 update_rx_mode_config;
  111. u8 update_tx_mode_config;
  112. u8 rx_accept_filter;
  113. u8 tx_accept_filter;
  114. #define QED_ACCEPT_NONE 0x01
  115. #define QED_ACCEPT_UCAST_MATCHED 0x02
  116. #define QED_ACCEPT_UCAST_UNMATCHED 0x04
  117. #define QED_ACCEPT_MCAST_MATCHED 0x08
  118. #define QED_ACCEPT_MCAST_UNMATCHED 0x10
  119. #define QED_ACCEPT_BCAST 0x20
  120. };
  121. struct qed_sp_vport_update_params {
  122. u16 opaque_fid;
  123. u8 vport_id;
  124. u8 update_vport_active_rx_flg;
  125. u8 vport_active_rx_flg;
  126. u8 update_vport_active_tx_flg;
  127. u8 vport_active_tx_flg;
  128. u8 update_inner_vlan_removal_flg;
  129. u8 inner_vlan_removal_flg;
  130. u8 silent_vlan_removal_flg;
  131. u8 update_default_vlan_enable_flg;
  132. u8 default_vlan_enable_flg;
  133. u8 update_default_vlan_flg;
  134. u16 default_vlan;
  135. u8 update_tx_switching_flg;
  136. u8 tx_switching_flg;
  137. u8 update_approx_mcast_flg;
  138. u8 update_anti_spoofing_en_flg;
  139. u8 anti_spoofing_en;
  140. u8 update_accept_any_vlan_flg;
  141. u8 accept_any_vlan;
  142. unsigned long bins[8];
  143. struct qed_rss_params *rss_params;
  144. struct qed_filter_accept_flags accept_flags;
  145. struct qed_sge_tpa_params *sge_tpa_params;
  146. };
  147. int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
  148. struct qed_sp_vport_update_params *p_params,
  149. enum spq_mode comp_mode,
  150. struct qed_spq_comp_cb *p_comp_data);
  151. /**
  152. * @brief qed_sp_vport_stop -
  153. *
  154. * This ramrod closes a VPort after all its RX and TX queues are terminated.
  155. * An Assert is generated if any queues are left open.
  156. *
  157. * @param p_hwfn
  158. * @param opaque_fid
  159. * @param vport_id VPort ID
  160. *
  161. * @return int
  162. */
  163. int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);
  164. int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
  165. u16 opaque_fid,
  166. struct qed_filter_ucast *p_filter_cmd,
  167. enum spq_mode comp_mode,
  168. struct qed_spq_comp_cb *p_comp_data);
  169. /**
  170. * @brief qed_sp_rx_eth_queues_update -
  171. *
  172. * This ramrod updates an RX queue. It is used for setting the active state
  173. * of the queue and updating the TPA and SGE parameters.
  174. *
  175. * @note At the moment - only used by non-linux VFs.
  176. *
  177. * @param p_hwfn
  178. * @param rx_queue_id RX Queue ID
  179. * @param num_rxqs Allow to update multiple rx
  180. * queues, from rx_queue_id to
  181. * (rx_queue_id + num_rxqs)
  182. * @param complete_cqe_flg Post completion to the CQE Ring if set
  183. * @param complete_event_flg Post completion to the Event Ring if set
  184. *
  185. * @return int
  186. */
  187. int
  188. qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
  189. u16 rx_queue_id,
  190. u8 num_rxqs,
  191. u8 complete_cqe_flg,
  192. u8 complete_event_flg,
  193. enum spq_mode comp_mode,
  194. struct qed_spq_comp_cb *p_comp_data);
  195. int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
  196. struct qed_sp_vport_start_params *p_params);
  197. int qed_sp_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
  198. u16 opaque_fid,
  199. u32 cid,
  200. struct qed_queue_start_common_params *params,
  201. u8 stats_id,
  202. u16 bd_max_bytes,
  203. dma_addr_t bd_chain_phys_addr,
  204. dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);
  205. int qed_sp_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
  206. u16 opaque_fid,
  207. u32 cid,
  208. struct qed_queue_start_common_params *p_params,
  209. u8 stats_id,
  210. dma_addr_t pbl_addr,
  211. u16 pbl_size,
  212. union qed_qm_pq_params *p_pq_params);
  213. u8 qed_mcast_bin_from_mac(u8 *mac);
  214. #endif /* _QED_L2_H */