qed_eth_if.h 9.1 KB

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