qed_eth_if.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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_ETH_IF_H
  33. #define _QED_ETH_IF_H
  34. #include <linux/list.h>
  35. #include <linux/if_link.h>
  36. #include <linux/qed/eth_common.h>
  37. #include <linux/qed/qed_if.h>
  38. #include <linux/qed/qed_iov_if.h>
  39. struct qed_queue_start_common_params {
  40. /* Should always be relative to entity sending this. */
  41. u8 vport_id;
  42. u16 queue_id;
  43. /* Relative, but relevant only for PFs */
  44. u8 stats_id;
  45. struct qed_sb_info *p_sb;
  46. u8 sb_idx;
  47. };
  48. struct qed_rxq_start_ret_params {
  49. void __iomem *p_prod;
  50. void *p_handle;
  51. };
  52. struct qed_txq_start_ret_params {
  53. void __iomem *p_doorbell;
  54. void *p_handle;
  55. };
  56. enum qed_filter_config_mode {
  57. QED_FILTER_CONFIG_MODE_DISABLE,
  58. QED_FILTER_CONFIG_MODE_5_TUPLE,
  59. QED_FILTER_CONFIG_MODE_L4_PORT,
  60. QED_FILTER_CONFIG_MODE_IP_DEST,
  61. QED_FILTER_CONFIG_MODE_IP_SRC,
  62. };
  63. struct qed_ntuple_filter_params {
  64. /* Physically mapped address containing header of buffer to be used
  65. * as filter.
  66. */
  67. dma_addr_t addr;
  68. /* Length of header in bytes */
  69. u16 length;
  70. /* Relative queue-id to receive classified packet */
  71. #define QED_RFS_NTUPLE_QID_RSS ((u16)-1)
  72. u16 qid;
  73. /* Identifier can either be according to vport-id or vfid */
  74. bool b_is_vf;
  75. u8 vport_id;
  76. u8 vf_id;
  77. /* true iff this filter is to be added. Else to be removed */
  78. bool b_is_add;
  79. /* If flow needs to be dropped */
  80. bool b_is_drop;
  81. };
  82. struct qed_dev_eth_info {
  83. struct qed_dev_info common;
  84. u8 num_queues;
  85. u8 num_tc;
  86. u8 port_mac[ETH_ALEN];
  87. u16 num_vlan_filters;
  88. u16 num_mac_filters;
  89. /* Legacy VF - this affects the datapath, so qede has to know */
  90. bool is_legacy;
  91. /* Might depend on available resources [in case of VF] */
  92. bool xdp_supported;
  93. };
  94. struct qed_update_vport_rss_params {
  95. void *rss_ind_table[128];
  96. u32 rss_key[10];
  97. u8 rss_caps;
  98. };
  99. struct qed_update_vport_params {
  100. u8 vport_id;
  101. u8 update_vport_active_flg;
  102. u8 vport_active_flg;
  103. u8 update_tx_switching_flg;
  104. u8 tx_switching_flg;
  105. u8 update_accept_any_vlan_flg;
  106. u8 accept_any_vlan;
  107. u8 update_rss_flg;
  108. struct qed_update_vport_rss_params rss_params;
  109. };
  110. struct qed_start_vport_params {
  111. bool remove_inner_vlan;
  112. bool handle_ptp_pkts;
  113. bool gro_enable;
  114. bool drop_ttl0;
  115. u8 vport_id;
  116. u16 mtu;
  117. bool clear_stats;
  118. };
  119. enum qed_filter_rx_mode_type {
  120. QED_FILTER_RX_MODE_TYPE_REGULAR,
  121. QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
  122. QED_FILTER_RX_MODE_TYPE_PROMISC,
  123. };
  124. enum qed_filter_xcast_params_type {
  125. QED_FILTER_XCAST_TYPE_ADD,
  126. QED_FILTER_XCAST_TYPE_DEL,
  127. QED_FILTER_XCAST_TYPE_REPLACE,
  128. };
  129. struct qed_filter_ucast_params {
  130. enum qed_filter_xcast_params_type type;
  131. u8 vlan_valid;
  132. u16 vlan;
  133. u8 mac_valid;
  134. unsigned char mac[ETH_ALEN];
  135. };
  136. struct qed_filter_mcast_params {
  137. enum qed_filter_xcast_params_type type;
  138. u8 num;
  139. unsigned char mac[64][ETH_ALEN];
  140. };
  141. union qed_filter_type_params {
  142. enum qed_filter_rx_mode_type accept_flags;
  143. struct qed_filter_ucast_params ucast;
  144. struct qed_filter_mcast_params mcast;
  145. };
  146. enum qed_filter_type {
  147. QED_FILTER_TYPE_UCAST,
  148. QED_FILTER_TYPE_MCAST,
  149. QED_FILTER_TYPE_RX_MODE,
  150. QED_MAX_FILTER_TYPES,
  151. };
  152. struct qed_filter_params {
  153. enum qed_filter_type type;
  154. union qed_filter_type_params filter;
  155. };
  156. struct qed_tunn_params {
  157. u16 vxlan_port;
  158. u8 update_vxlan_port;
  159. u16 geneve_port;
  160. u8 update_geneve_port;
  161. };
  162. struct qed_eth_cb_ops {
  163. struct qed_common_cb_ops common;
  164. void (*force_mac) (void *dev, u8 *mac, bool forced);
  165. void (*ports_update)(void *dev, u16 vxlan_port, u16 geneve_port);
  166. };
  167. #define QED_MAX_PHC_DRIFT_PPB 291666666
  168. enum qed_ptp_filter_type {
  169. QED_PTP_FILTER_NONE,
  170. QED_PTP_FILTER_ALL,
  171. QED_PTP_FILTER_V1_L4_EVENT,
  172. QED_PTP_FILTER_V1_L4_GEN,
  173. QED_PTP_FILTER_V2_L4_EVENT,
  174. QED_PTP_FILTER_V2_L4_GEN,
  175. QED_PTP_FILTER_V2_L2_EVENT,
  176. QED_PTP_FILTER_V2_L2_GEN,
  177. QED_PTP_FILTER_V2_EVENT,
  178. QED_PTP_FILTER_V2_GEN
  179. };
  180. enum qed_ptp_hwtstamp_tx_type {
  181. QED_PTP_HWTSTAMP_TX_OFF,
  182. QED_PTP_HWTSTAMP_TX_ON,
  183. };
  184. #ifdef CONFIG_DCB
  185. /* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
  186. * of dcbnl_rtnl_ops structure.
  187. */
  188. struct qed_eth_dcbnl_ops {
  189. /* IEEE 802.1Qaz std */
  190. int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
  191. int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
  192. int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
  193. int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
  194. int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
  195. int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
  196. int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
  197. int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
  198. /* CEE std */
  199. u8 (*getstate)(struct qed_dev *cdev);
  200. u8 (*setstate)(struct qed_dev *cdev, u8 state);
  201. void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
  202. u8 *pgid, u8 *bw_pct, u8 *up_map);
  203. void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
  204. void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
  205. u8 *pgid, u8 *bw_pct, u8 *up_map);
  206. void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
  207. void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
  208. void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
  209. u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
  210. int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
  211. u8 (*getpfcstate)(struct qed_dev *cdev);
  212. int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
  213. u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
  214. /* DCBX configuration */
  215. u8 (*getdcbx)(struct qed_dev *cdev);
  216. void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
  217. u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
  218. void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
  219. u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
  220. void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
  221. void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
  222. u8 (*setall)(struct qed_dev *cdev);
  223. int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
  224. void (*setpfcstate)(struct qed_dev *cdev, u8 state);
  225. int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
  226. u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
  227. u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
  228. /* Peer apps */
  229. int (*peer_getappinfo)(struct qed_dev *cdev,
  230. struct dcb_peer_app_info *info,
  231. u16 *app_count);
  232. int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
  233. /* CEE peer */
  234. int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
  235. int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
  236. };
  237. #endif
  238. struct qed_eth_ptp_ops {
  239. int (*cfg_filters)(struct qed_dev *, enum qed_ptp_filter_type,
  240. enum qed_ptp_hwtstamp_tx_type);
  241. int (*read_rx_ts)(struct qed_dev *, u64 *);
  242. int (*read_tx_ts)(struct qed_dev *, u64 *);
  243. int (*read_cc)(struct qed_dev *, u64 *);
  244. int (*disable)(struct qed_dev *);
  245. int (*adjfreq)(struct qed_dev *, s32);
  246. int (*enable)(struct qed_dev *);
  247. };
  248. struct qed_eth_ops {
  249. const struct qed_common_ops *common;
  250. #ifdef CONFIG_QED_SRIOV
  251. const struct qed_iov_hv_ops *iov;
  252. #endif
  253. #ifdef CONFIG_DCB
  254. const struct qed_eth_dcbnl_ops *dcb;
  255. #endif
  256. const struct qed_eth_ptp_ops *ptp;
  257. int (*fill_dev_info)(struct qed_dev *cdev,
  258. struct qed_dev_eth_info *info);
  259. void (*register_ops)(struct qed_dev *cdev,
  260. struct qed_eth_cb_ops *ops,
  261. void *cookie);
  262. bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
  263. int (*vport_start)(struct qed_dev *cdev,
  264. struct qed_start_vport_params *params);
  265. int (*vport_stop)(struct qed_dev *cdev,
  266. u8 vport_id);
  267. int (*vport_update)(struct qed_dev *cdev,
  268. struct qed_update_vport_params *params);
  269. int (*q_rx_start)(struct qed_dev *cdev,
  270. u8 rss_num,
  271. struct qed_queue_start_common_params *params,
  272. u16 bd_max_bytes,
  273. dma_addr_t bd_chain_phys_addr,
  274. dma_addr_t cqe_pbl_addr,
  275. u16 cqe_pbl_size,
  276. struct qed_rxq_start_ret_params *ret_params);
  277. int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
  278. int (*q_tx_start)(struct qed_dev *cdev,
  279. u8 rss_num,
  280. struct qed_queue_start_common_params *params,
  281. dma_addr_t pbl_addr,
  282. u16 pbl_size,
  283. struct qed_txq_start_ret_params *ret_params);
  284. int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
  285. int (*filter_config)(struct qed_dev *cdev,
  286. struct qed_filter_params *params);
  287. int (*fastpath_stop)(struct qed_dev *cdev);
  288. int (*eth_cqe_completion)(struct qed_dev *cdev,
  289. u8 rss_id,
  290. struct eth_slow_path_rx_cqe *cqe);
  291. void (*get_vport_stats)(struct qed_dev *cdev,
  292. struct qed_eth_stats *stats);
  293. int (*tunn_config)(struct qed_dev *cdev,
  294. struct qed_tunn_params *params);
  295. int (*ntuple_filter_config)(struct qed_dev *cdev,
  296. void *cookie,
  297. struct qed_ntuple_filter_params *params);
  298. int (*configure_arfs_searcher)(struct qed_dev *cdev,
  299. enum qed_filter_config_mode mode);
  300. int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
  301. int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac);
  302. };
  303. const struct qed_eth_ops *qed_get_eth_ops(void);
  304. void qed_put_eth_ops(void);
  305. #endif