ice.h 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2018, Intel Corporation. */
  3. #ifndef _ICE_H_
  4. #define _ICE_H_
  5. #include <linux/types.h>
  6. #include <linux/errno.h>
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/firmware.h>
  10. #include <linux/netdevice.h>
  11. #include <linux/compiler.h>
  12. #include <linux/etherdevice.h>
  13. #include <linux/skbuff.h>
  14. #include <linux/cpumask.h>
  15. #include <linux/rtnetlink.h>
  16. #include <linux/if_vlan.h>
  17. #include <linux/dma-mapping.h>
  18. #include <linux/pci.h>
  19. #include <linux/workqueue.h>
  20. #include <linux/wait.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/ethtool.h>
  23. #include <linux/timer.h>
  24. #include <linux/delay.h>
  25. #include <linux/bitmap.h>
  26. #include <linux/log2.h>
  27. #include <linux/ip.h>
  28. #include <linux/sctp.h>
  29. #include <linux/ipv6.h>
  30. #include <linux/pkt_sched.h>
  31. #include <linux/if_bridge.h>
  32. #include <linux/ctype.h>
  33. #include <linux/linkmode.h>
  34. #include <linux/bpf.h>
  35. #include <linux/btf.h>
  36. #include <linux/auxiliary_bus.h>
  37. #include <linux/avf/virtchnl.h>
  38. #include <linux/cpu_rmap.h>
  39. #include <linux/dim.h>
  40. #include <linux/gnss.h>
  41. #include <net/pkt_cls.h>
  42. #include <net/pkt_sched.h>
  43. #include <net/tc_act/tc_mirred.h>
  44. #include <net/tc_act/tc_gact.h>
  45. #include <net/ip.h>
  46. #include <net/devlink.h>
  47. #include <net/ipv6.h>
  48. #include <net/xdp_sock.h>
  49. #include <net/xdp_sock_drv.h>
  50. #include <net/geneve.h>
  51. #include <net/gre.h>
  52. #include <net/udp_tunnel.h>
  53. #include <net/vxlan.h>
  54. #include <net/gtp.h>
  55. #include <linux/ppp_defs.h>
  56. #include "ice_devids.h"
  57. #include "ice_type.h"
  58. #include "ice_txrx.h"
  59. #include "ice_dcb.h"
  60. #include "ice_switch.h"
  61. #include "ice_common.h"
  62. #include "ice_flow.h"
  63. #include "ice_sched.h"
  64. #include "ice_idc_int.h"
  65. #include "ice_sriov.h"
  66. #include "ice_vf_mbx.h"
  67. #include "ice_ptp.h"
  68. #include "ice_fdir.h"
  69. #include "ice_xsk.h"
  70. #include "ice_arfs.h"
  71. #include "ice_repr.h"
  72. #include "ice_eswitch.h"
  73. #include "ice_lag.h"
  74. #include "ice_vsi_vlan_ops.h"
  75. #include "ice_gnss.h"
  76. #include "ice_irq.h"
  77. #include "ice_dpll.h"
  78. #include "ice_adapter.h"
  79. #define ICE_BAR0 0
  80. #define ICE_REQ_DESC_MULTIPLE 32
  81. #define ICE_MIN_NUM_DESC 64
  82. #define ICE_MAX_NUM_DESC 8160
  83. #define ICE_DFLT_MIN_RX_DESC 512
  84. #define ICE_DFLT_NUM_TX_DESC 256
  85. #define ICE_DFLT_NUM_RX_DESC 2048
  86. #define ICE_DFLT_TRAFFIC_CLASS BIT(0)
  87. #define ICE_INT_NAME_STR_LEN (IFNAMSIZ + 16)
  88. #define ICE_AQ_LEN 192
  89. #define ICE_MBXSQ_LEN 64
  90. #define ICE_SBQ_LEN 64
  91. #define ICE_MIN_LAN_TXRX_MSIX 1
  92. #define ICE_MIN_LAN_OICR_MSIX 1
  93. #define ICE_MIN_MSIX (ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_LAN_OICR_MSIX)
  94. #define ICE_FDIR_MSIX 2
  95. #define ICE_RDMA_NUM_AEQ_MSIX 4
  96. #define ICE_MIN_RDMA_MSIX 2
  97. #define ICE_ESWITCH_MSIX 1
  98. #define ICE_NO_VSI 0xffff
  99. #define ICE_VSI_MAP_CONTIG 0
  100. #define ICE_VSI_MAP_SCATTER 1
  101. #define ICE_MAX_SCATTER_TXQS 16
  102. #define ICE_MAX_SCATTER_RXQS 16
  103. #define ICE_Q_WAIT_RETRY_LIMIT 10
  104. #define ICE_Q_WAIT_MAX_RETRY (5 * ICE_Q_WAIT_RETRY_LIMIT)
  105. #define ICE_MAX_LG_RSS_QS 256
  106. #define ICE_INVAL_Q_INDEX 0xffff
  107. #define ICE_MAX_RXQS_PER_TC 256 /* Used when setting VSI context per TC Rx queues */
  108. #define ICE_CHNL_START_TC 1
  109. #define ICE_MAX_RESET_WAIT 20
  110. #define ICE_VSIQF_HKEY_ARRAY_SIZE ((VSIQF_HKEY_MAX_INDEX + 1) * 4)
  111. #define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
  112. #define ICE_MAX_MTU (ICE_AQ_SET_MAC_FRAME_SIZE_MAX - ICE_ETH_PKT_HDR_PAD)
  113. #define ICE_MAX_TSO_SIZE 131072
  114. #define ICE_UP_TABLE_TRANSLATE(val, i) \
  115. (((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \
  116. ICE_AQ_VSI_UP_TABLE_UP##i##_M)
  117. #define ICE_TX_DESC(R, i) (&(((struct ice_tx_desc *)((R)->desc))[i]))
  118. #define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i]))
  119. #define ICE_TX_CTX_DESC(R, i) (&(((struct ice_tx_ctx_desc *)((R)->desc))[i]))
  120. #define ICE_TX_FDIRDESC(R, i) (&(((struct ice_fltr_desc *)((R)->desc))[i]))
  121. /* Minimum BW limit is 500 Kbps for any scheduler node */
  122. #define ICE_MIN_BW_LIMIT 500
  123. /* User can specify BW in either Kbit/Mbit/Gbit and OS converts it in bytes.
  124. * use it to convert user specified BW limit into Kbps
  125. */
  126. #define ICE_BW_KBPS_DIVISOR 125
  127. /* Default recipes have priority 4 and below, hence priority values between 5..7
  128. * can be used as filter priority for advanced switch filter (advanced switch
  129. * filters need new recipe to be created for specified extraction sequence
  130. * because default recipe extraction sequence does not represent custom
  131. * extraction)
  132. */
  133. #define ICE_SWITCH_FLTR_PRIO_QUEUE 7
  134. /* prio 6 is reserved for future use (e.g. switch filter with L3 fields +
  135. * (Optional: IP TOS/TTL) + L4 fields + (optionally: TCP fields such as
  136. * SYN/FIN/RST))
  137. */
  138. #define ICE_SWITCH_FLTR_PRIO_RSVD 6
  139. #define ICE_SWITCH_FLTR_PRIO_VSI 5
  140. #define ICE_SWITCH_FLTR_PRIO_QGRP ICE_SWITCH_FLTR_PRIO_VSI
  141. /* Macro for each VSI in a PF */
  142. #define ice_for_each_vsi(pf, i) \
  143. for ((i) = 0; (i) < (pf)->num_alloc_vsi; (i)++)
  144. /* Macros for each Tx/Xdp/Rx ring in a VSI */
  145. #define ice_for_each_txq(vsi, i) \
  146. for ((i) = 0; (i) < (vsi)->num_txq; (i)++)
  147. #define ice_for_each_xdp_txq(vsi, i) \
  148. for ((i) = 0; (i) < (vsi)->num_xdp_txq; (i)++)
  149. #define ice_for_each_rxq(vsi, i) \
  150. for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
  151. /* Macros for each allocated Tx/Rx ring whether used or not in a VSI */
  152. #define ice_for_each_alloc_txq(vsi, i) \
  153. for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++)
  154. #define ice_for_each_alloc_rxq(vsi, i) \
  155. for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++)
  156. #define ice_for_each_q_vector(vsi, i) \
  157. for ((i) = 0; (i) < (vsi)->num_q_vectors; (i)++)
  158. #define ice_for_each_chnl_tc(i) \
  159. for ((i) = ICE_CHNL_START_TC; (i) < ICE_CHNL_MAX_TC; (i)++)
  160. #define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_UCAST_RX)
  161. #define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \
  162. ICE_PROMISC_UCAST_RX | \
  163. ICE_PROMISC_VLAN_TX | \
  164. ICE_PROMISC_VLAN_RX)
  165. #define ICE_MCAST_PROMISC_BITS (ICE_PROMISC_MCAST_TX | ICE_PROMISC_MCAST_RX)
  166. #define ICE_MCAST_VLAN_PROMISC_BITS (ICE_PROMISC_MCAST_TX | \
  167. ICE_PROMISC_MCAST_RX | \
  168. ICE_PROMISC_VLAN_TX | \
  169. ICE_PROMISC_VLAN_RX)
  170. #define ice_pf_to_dev(pf) (&((pf)->pdev->dev))
  171. #define ice_pf_src_tmr_owned(pf) ((pf)->hw.func_caps.ts_func_info.src_tmr_owned)
  172. enum ice_feature {
  173. ICE_F_DSCP,
  174. ICE_F_PHY_RCLK,
  175. ICE_F_SMA_CTRL,
  176. ICE_F_CGU,
  177. ICE_F_GNSS,
  178. ICE_F_ROCE_LAG,
  179. ICE_F_SRIOV_LAG,
  180. ICE_F_MBX_LIMIT,
  181. ICE_F_MAX
  182. };
  183. DECLARE_STATIC_KEY_FALSE(ice_xdp_locking_key);
  184. struct ice_channel {
  185. struct list_head list;
  186. u8 type;
  187. u16 sw_id;
  188. u16 base_q;
  189. u16 num_rxq;
  190. u16 num_txq;
  191. u16 vsi_num;
  192. u8 ena_tc;
  193. struct ice_aqc_vsi_props info;
  194. u64 max_tx_rate;
  195. u64 min_tx_rate;
  196. atomic_t num_sb_fltr;
  197. struct ice_vsi *ch_vsi;
  198. };
  199. struct ice_txq_meta {
  200. u32 q_teid; /* Tx-scheduler element identifier */
  201. u16 q_id; /* Entry in VSI's txq_map bitmap */
  202. u16 q_handle; /* Relative index of Tx queue within TC */
  203. u16 vsi_idx; /* VSI index that Tx queue belongs to */
  204. u8 tc; /* TC number that Tx queue belongs to */
  205. };
  206. struct ice_tc_info {
  207. u16 qoffset;
  208. u16 qcount_tx;
  209. u16 qcount_rx;
  210. u8 netdev_tc;
  211. };
  212. struct ice_tc_cfg {
  213. u8 numtc; /* Total number of enabled TCs */
  214. u16 ena_tc; /* Tx map */
  215. struct ice_tc_info tc_info[ICE_MAX_TRAFFIC_CLASS];
  216. };
  217. struct ice_qs_cfg {
  218. struct mutex *qs_mutex; /* will be assigned to &pf->avail_q_mutex */
  219. unsigned long *pf_map;
  220. unsigned long pf_map_size;
  221. unsigned int q_count;
  222. unsigned int scatter_count;
  223. u16 *vsi_map;
  224. u16 vsi_map_offset;
  225. u8 mapping_mode;
  226. };
  227. struct ice_sw {
  228. struct ice_pf *pf;
  229. u16 sw_id; /* switch ID for this switch */
  230. u16 bridge_mode; /* VEB/VEPA/Port Virtualizer */
  231. };
  232. enum ice_pf_state {
  233. ICE_TESTING,
  234. ICE_DOWN,
  235. ICE_NEEDS_RESTART,
  236. ICE_PREPARED_FOR_RESET, /* set by driver when prepared */
  237. ICE_RESET_OICR_RECV, /* set by driver after rcv reset OICR */
  238. ICE_PFR_REQ, /* set by driver */
  239. ICE_CORER_REQ, /* set by driver */
  240. ICE_GLOBR_REQ, /* set by driver */
  241. ICE_CORER_RECV, /* set by OICR handler */
  242. ICE_GLOBR_RECV, /* set by OICR handler */
  243. ICE_EMPR_RECV, /* set by OICR handler */
  244. ICE_SUSPENDED, /* set on module remove path */
  245. ICE_RESET_FAILED, /* set by reset/rebuild */
  246. /* When checking for the PF to be in a nominal operating state, the
  247. * bits that are grouped at the beginning of the list need to be
  248. * checked. Bits occurring before ICE_STATE_NOMINAL_CHECK_BITS will
  249. * be checked. If you need to add a bit into consideration for nominal
  250. * operating state, it must be added before
  251. * ICE_STATE_NOMINAL_CHECK_BITS. Do not move this entry's position
  252. * without appropriate consideration.
  253. */
  254. ICE_STATE_NOMINAL_CHECK_BITS,
  255. ICE_ADMINQ_EVENT_PENDING,
  256. ICE_MAILBOXQ_EVENT_PENDING,
  257. ICE_SIDEBANDQ_EVENT_PENDING,
  258. ICE_MDD_EVENT_PENDING,
  259. ICE_VFLR_EVENT_PENDING,
  260. ICE_FLTR_OVERFLOW_PROMISC,
  261. ICE_VF_DIS,
  262. ICE_CFG_BUSY,
  263. ICE_SERVICE_SCHED,
  264. ICE_SERVICE_DIS,
  265. ICE_FD_FLUSH_REQ,
  266. ICE_OICR_INTR_DIS, /* Global OICR interrupt disabled */
  267. ICE_MDD_VF_PRINT_PENDING, /* set when MDD event handle */
  268. ICE_VF_RESETS_DISABLED, /* disable resets during ice_remove */
  269. ICE_LINK_DEFAULT_OVERRIDE_PENDING,
  270. ICE_PHY_INIT_COMPLETE,
  271. ICE_FD_VF_FLUSH_CTX, /* set at FD Rx IRQ or timeout */
  272. ICE_AUX_ERR_PENDING,
  273. ICE_STATE_NBITS /* must be last */
  274. };
  275. enum ice_vsi_state {
  276. ICE_VSI_DOWN,
  277. ICE_VSI_NEEDS_RESTART,
  278. ICE_VSI_NETDEV_ALLOCD,
  279. ICE_VSI_NETDEV_REGISTERED,
  280. ICE_VSI_UMAC_FLTR_CHANGED,
  281. ICE_VSI_MMAC_FLTR_CHANGED,
  282. ICE_VSI_PROMISC_CHANGED,
  283. ICE_VSI_REBUILD_PENDING,
  284. ICE_VSI_STATE_NBITS /* must be last */
  285. };
  286. struct ice_vsi_stats {
  287. struct ice_ring_stats **tx_ring_stats; /* Tx ring stats array */
  288. struct ice_ring_stats **rx_ring_stats; /* Rx ring stats array */
  289. };
  290. /* struct that defines a VSI, associated with a dev */
  291. struct ice_vsi {
  292. struct net_device *netdev;
  293. struct ice_sw *vsw; /* switch this VSI is on */
  294. struct ice_pf *back; /* back pointer to PF */
  295. struct ice_rx_ring **rx_rings; /* Rx ring array */
  296. struct ice_tx_ring **tx_rings; /* Tx ring array */
  297. struct ice_q_vector **q_vectors; /* q_vector array */
  298. irqreturn_t (*irq_handler)(int irq, void *data);
  299. u64 tx_linearize;
  300. DECLARE_BITMAP(state, ICE_VSI_STATE_NBITS);
  301. unsigned int current_netdev_flags;
  302. u32 tx_restart;
  303. u32 tx_busy;
  304. u32 rx_buf_failed;
  305. u32 rx_page_failed;
  306. u16 num_q_vectors;
  307. /* tell if only dynamic irq allocation is allowed */
  308. bool irq_dyn_alloc;
  309. u16 vsi_num; /* HW (absolute) index of this VSI */
  310. u16 idx; /* software index in pf->vsi[] */
  311. u16 num_gfltr;
  312. u16 num_bfltr;
  313. /* RSS config */
  314. u16 rss_table_size; /* HW RSS table size */
  315. u16 rss_size; /* Allocated RSS queues */
  316. u8 rss_hfunc; /* User configured hash type */
  317. u8 *rss_hkey_user; /* User configured hash keys */
  318. u8 *rss_lut_user; /* User configured lookup table entries */
  319. u8 rss_lut_type; /* used to configure Get/Set RSS LUT AQ call */
  320. /* aRFS members only allocated for the PF VSI */
  321. #define ICE_MAX_ARFS_LIST 1024
  322. #define ICE_ARFS_LST_MASK (ICE_MAX_ARFS_LIST - 1)
  323. struct hlist_head *arfs_fltr_list;
  324. struct ice_arfs_active_fltr_cntrs *arfs_fltr_cntrs;
  325. spinlock_t arfs_lock; /* protects aRFS hash table and filter state */
  326. atomic_t *arfs_last_fltr_id;
  327. struct ice_aqc_vsi_props info; /* VSI properties */
  328. struct ice_vsi_vlan_info vlan_info; /* vlan config to be restored */
  329. /* VSI stats */
  330. struct rtnl_link_stats64 net_stats;
  331. struct rtnl_link_stats64 net_stats_prev;
  332. struct ice_eth_stats eth_stats;
  333. struct ice_eth_stats eth_stats_prev;
  334. struct list_head tmp_sync_list; /* MAC filters to be synced */
  335. struct list_head tmp_unsync_list; /* MAC filters to be unsynced */
  336. u8 irqs_ready:1;
  337. u8 current_isup:1; /* Sync 'link up' logging */
  338. u8 stat_offsets_loaded:1;
  339. struct ice_vsi_vlan_ops inner_vlan_ops;
  340. struct ice_vsi_vlan_ops outer_vlan_ops;
  341. u16 num_vlan;
  342. /* queue information */
  343. u8 tx_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
  344. u8 rx_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
  345. u16 *txq_map; /* index in pf->avail_txqs */
  346. u16 *rxq_map; /* index in pf->avail_rxqs */
  347. u16 alloc_txq; /* Allocated Tx queues */
  348. u16 num_txq; /* Used Tx queues */
  349. u16 alloc_rxq; /* Allocated Rx queues */
  350. u16 num_rxq; /* Used Rx queues */
  351. u16 req_txq; /* User requested Tx queues */
  352. u16 req_rxq; /* User requested Rx queues */
  353. u16 num_rx_desc;
  354. u16 num_tx_desc;
  355. u16 qset_handle[ICE_MAX_TRAFFIC_CLASS];
  356. struct ice_tc_cfg tc_cfg;
  357. struct bpf_prog *xdp_prog;
  358. struct ice_tx_ring **xdp_rings; /* XDP ring array */
  359. u16 num_xdp_txq; /* Used XDP queues */
  360. u8 xdp_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
  361. struct mutex xdp_state_lock;
  362. struct net_device **target_netdevs;
  363. struct tc_mqprio_qopt_offload mqprio_qopt; /* queue parameters */
  364. /* Channel Specific Fields */
  365. struct ice_vsi *tc_map_vsi[ICE_CHNL_MAX_TC];
  366. u16 cnt_q_avail;
  367. u16 next_base_q; /* next queue to be used for channel setup */
  368. struct list_head ch_list;
  369. u16 num_chnl_rxq;
  370. u16 num_chnl_txq;
  371. u16 ch_rss_size;
  372. u16 num_chnl_fltr;
  373. /* store away rss size info before configuring ADQ channels so that,
  374. * it can be used after tc-qdisc delete, to get back RSS setting as
  375. * they were before
  376. */
  377. u16 orig_rss_size;
  378. /* this keeps tracks of all enabled TC with and without DCB
  379. * and inclusive of ADQ, vsi->mqprio_opt keeps track of queue
  380. * information
  381. */
  382. u8 all_numtc;
  383. u16 all_enatc;
  384. /* store away TC info, to be used for rebuild logic */
  385. u8 old_numtc;
  386. u16 old_ena_tc;
  387. /* setup back reference, to which aggregator node this VSI
  388. * corresponds to
  389. */
  390. struct ice_agg_node *agg_node;
  391. struct_group_tagged(ice_vsi_cfg_params, params,
  392. struct ice_port_info *port_info; /* back pointer to port_info */
  393. struct ice_channel *ch; /* VSI's channel structure, may be NULL */
  394. union {
  395. /* VF associated with this VSI, may be NULL */
  396. struct ice_vf *vf;
  397. /* SF associated with this VSI, may be NULL */
  398. struct ice_dynamic_port *sf;
  399. };
  400. u32 flags; /* VSI flags used for rebuild and configuration */
  401. enum ice_vsi_type type; /* the type of the VSI */
  402. );
  403. } ____cacheline_internodealigned_in_smp;
  404. /* struct that defines an interrupt vector */
  405. struct ice_q_vector {
  406. struct ice_vsi *vsi;
  407. u16 v_idx; /* index in the vsi->q_vector array. */
  408. u16 reg_idx; /* PF relative register index */
  409. u8 num_ring_rx; /* total number of Rx rings in vector */
  410. u8 num_ring_tx; /* total number of Tx rings in vector */
  411. u8 wb_on_itr:1; /* if true, WB on ITR is enabled */
  412. /* in usecs, need to use ice_intrl_to_usecs_reg() before writing this
  413. * value to the device
  414. */
  415. u8 intrl;
  416. struct napi_struct napi;
  417. struct ice_ring_container rx;
  418. struct ice_ring_container tx;
  419. cpumask_t affinity_mask;
  420. struct irq_affinity_notify affinity_notify;
  421. struct ice_channel *ch;
  422. char name[ICE_INT_NAME_STR_LEN];
  423. u16 total_events; /* net_dim(): number of interrupts processed */
  424. u16 vf_reg_idx; /* VF relative register index */
  425. struct msi_map irq;
  426. } ____cacheline_internodealigned_in_smp;
  427. enum ice_pf_flags {
  428. ICE_FLAG_FLTR_SYNC,
  429. ICE_FLAG_RDMA_ENA,
  430. ICE_FLAG_RSS_ENA,
  431. ICE_FLAG_SRIOV_ENA,
  432. ICE_FLAG_SRIOV_CAPABLE,
  433. ICE_FLAG_DCB_CAPABLE,
  434. ICE_FLAG_DCB_ENA,
  435. ICE_FLAG_FD_ENA,
  436. ICE_FLAG_PTP_SUPPORTED, /* PTP is supported by NVM */
  437. ICE_FLAG_ADV_FEATURES,
  438. ICE_FLAG_TC_MQPRIO, /* support for Multi queue TC */
  439. ICE_FLAG_CLS_FLOWER,
  440. ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA,
  441. ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA,
  442. ICE_FLAG_NO_MEDIA,
  443. ICE_FLAG_FW_LLDP_AGENT,
  444. ICE_FLAG_MOD_POWER_UNSUPPORTED,
  445. ICE_FLAG_PHY_FW_LOAD_FAILED,
  446. ICE_FLAG_ETHTOOL_CTXT, /* set when ethtool holds RTNL lock */
  447. ICE_FLAG_LEGACY_RX,
  448. ICE_FLAG_VF_TRUE_PROMISC_ENA,
  449. ICE_FLAG_MDD_AUTO_RESET_VF,
  450. ICE_FLAG_VF_VLAN_PRUNING,
  451. ICE_FLAG_LINK_LENIENT_MODE_ENA,
  452. ICE_FLAG_PLUG_AUX_DEV,
  453. ICE_FLAG_UNPLUG_AUX_DEV,
  454. ICE_FLAG_MTU_CHANGED,
  455. ICE_FLAG_GNSS, /* GNSS successfully initialized */
  456. ICE_FLAG_DPLL, /* SyncE/PTP dplls initialized */
  457. ICE_PF_FLAGS_NBITS /* must be last */
  458. };
  459. enum ice_misc_thread_tasks {
  460. ICE_MISC_THREAD_TX_TSTAMP,
  461. ICE_MISC_THREAD_NBITS /* must be last */
  462. };
  463. struct ice_eswitch {
  464. struct ice_vsi *uplink_vsi;
  465. struct ice_esw_br_offloads *br_offloads;
  466. struct xarray reprs;
  467. bool is_running;
  468. };
  469. struct ice_agg_node {
  470. u32 agg_id;
  471. #define ICE_MAX_VSIS_IN_AGG_NODE 64
  472. u32 num_vsis;
  473. u8 valid;
  474. };
  475. struct ice_pf {
  476. struct pci_dev *pdev;
  477. struct ice_adapter *adapter;
  478. struct devlink_region *nvm_region;
  479. struct devlink_region *sram_region;
  480. struct devlink_region *devcaps_region;
  481. /* devlink port data */
  482. struct devlink_port devlink_port;
  483. /* OS reserved IRQ details */
  484. struct msix_entry *msix_entries;
  485. struct ice_irq_tracker irq_tracker;
  486. /* First MSIX vector used by SR-IOV VFs. Calculated by subtracting the
  487. * number of MSIX vectors needed for all SR-IOV VFs from the number of
  488. * MSIX vectors allowed on this PF.
  489. */
  490. u16 sriov_base_vector;
  491. unsigned long *sriov_irq_bm; /* bitmap to track irq usage */
  492. u16 sriov_irq_size; /* size of the irq_bm bitmap */
  493. u16 ctrl_vsi_idx; /* control VSI index in pf->vsi array */
  494. struct ice_vsi **vsi; /* VSIs created by the driver */
  495. struct ice_vsi_stats **vsi_stats;
  496. struct ice_sw *first_sw; /* first switch created by firmware */
  497. u16 eswitch_mode; /* current mode of eswitch */
  498. struct dentry *ice_debugfs_pf;
  499. struct dentry *ice_debugfs_pf_fwlog;
  500. /* keep track of all the dentrys for FW log modules */
  501. struct dentry **ice_debugfs_pf_fwlog_modules;
  502. struct ice_vfs vfs;
  503. DECLARE_BITMAP(features, ICE_F_MAX);
  504. DECLARE_BITMAP(state, ICE_STATE_NBITS);
  505. DECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS);
  506. DECLARE_BITMAP(misc_thread, ICE_MISC_THREAD_NBITS);
  507. unsigned long *avail_txqs; /* bitmap to track PF Tx queue usage */
  508. unsigned long *avail_rxqs; /* bitmap to track PF Rx queue usage */
  509. unsigned long serv_tmr_period;
  510. unsigned long serv_tmr_prev;
  511. struct timer_list serv_tmr;
  512. struct work_struct serv_task;
  513. struct mutex avail_q_mutex; /* protects access to avail_[rx|tx]qs */
  514. struct mutex sw_mutex; /* lock for protecting VSI alloc flow */
  515. struct mutex tc_mutex; /* lock to protect TC changes */
  516. struct mutex adev_mutex; /* lock to protect aux device access */
  517. struct mutex lag_mutex; /* protect ice_lag struct in PF */
  518. u32 msg_enable;
  519. struct ice_ptp ptp;
  520. struct gnss_serial *gnss_serial;
  521. struct gnss_device *gnss_dev;
  522. u16 num_rdma_msix; /* Total MSIX vectors for RDMA driver */
  523. u16 rdma_base_vector;
  524. /* spinlock to protect the AdminQ wait list */
  525. spinlock_t aq_wait_lock;
  526. struct hlist_head aq_wait_list;
  527. wait_queue_head_t aq_wait_queue;
  528. bool fw_emp_reset_disabled;
  529. wait_queue_head_t reset_wait_queue;
  530. u32 hw_csum_rx_error;
  531. u32 hw_rx_eipe_error;
  532. u32 oicr_err_reg;
  533. struct msi_map oicr_irq; /* Other interrupt cause MSIX vector */
  534. struct msi_map ll_ts_irq; /* LL_TS interrupt MSIX vector */
  535. u16 max_pf_txqs; /* Total Tx queues PF wide */
  536. u16 max_pf_rxqs; /* Total Rx queues PF wide */
  537. u16 num_lan_msix; /* Total MSIX vectors for base driver */
  538. u16 num_lan_tx; /* num LAN Tx queues setup */
  539. u16 num_lan_rx; /* num LAN Rx queues setup */
  540. u16 next_vsi; /* Next free slot in pf->vsi[] - 0-based! */
  541. u16 num_alloc_vsi;
  542. u16 corer_count; /* Core reset count */
  543. u16 globr_count; /* Global reset count */
  544. u16 empr_count; /* EMP reset count */
  545. u16 pfr_count; /* PF reset count */
  546. u8 wol_ena : 1; /* software state of WoL */
  547. u32 wakeup_reason; /* last wakeup reason */
  548. struct ice_hw_port_stats stats;
  549. struct ice_hw_port_stats stats_prev;
  550. struct ice_hw hw;
  551. u8 stat_prev_loaded:1; /* has previous stats been loaded */
  552. u8 rdma_mode;
  553. u16 dcbx_cap;
  554. u32 tx_timeout_count;
  555. unsigned long tx_timeout_last_recovery;
  556. u32 tx_timeout_recovery_level;
  557. char int_name[ICE_INT_NAME_STR_LEN];
  558. char int_name_ll_ts[ICE_INT_NAME_STR_LEN];
  559. struct auxiliary_device *adev;
  560. int aux_idx;
  561. u32 sw_int_count;
  562. /* count of tc_flower filters specific to channel (aka where filter
  563. * action is "hw_tc <tc_num>")
  564. */
  565. u16 num_dmac_chnl_fltrs;
  566. struct hlist_head tc_flower_fltr_list;
  567. u64 supported_rxdids;
  568. __le64 nvm_phy_type_lo; /* NVM PHY type low */
  569. __le64 nvm_phy_type_hi; /* NVM PHY type high */
  570. struct ice_link_default_override_tlv link_dflt_override;
  571. struct ice_lag *lag; /* Link Aggregation information */
  572. struct ice_eswitch eswitch;
  573. struct ice_esw_br_port *br_port;
  574. struct xarray dyn_ports;
  575. struct xarray sf_nums;
  576. #define ICE_INVALID_AGG_NODE_ID 0
  577. #define ICE_PF_AGG_NODE_ID_START 1
  578. #define ICE_MAX_PF_AGG_NODES 32
  579. struct ice_agg_node pf_agg_node[ICE_MAX_PF_AGG_NODES];
  580. #define ICE_VF_AGG_NODE_ID_START 65
  581. #define ICE_MAX_VF_AGG_NODES 32
  582. struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES];
  583. struct ice_dplls dplls;
  584. struct device *hwmon_dev;
  585. };
  586. extern struct workqueue_struct *ice_lag_wq;
  587. struct ice_netdev_priv {
  588. struct ice_vsi *vsi;
  589. struct ice_repr *repr;
  590. /* indirect block callbacks on registered higher level devices
  591. * (e.g. tunnel devices)
  592. *
  593. * tc_indr_block_cb_priv_list is used to look up indirect callback
  594. * private data
  595. */
  596. struct list_head tc_indr_block_priv_list;
  597. };
  598. /**
  599. * ice_vector_ch_enabled
  600. * @qv: pointer to q_vector, can be NULL
  601. *
  602. * This function returns true if vector is channel enabled otherwise false
  603. */
  604. static inline bool ice_vector_ch_enabled(struct ice_q_vector *qv)
  605. {
  606. return !!qv->ch; /* Enable it to run with TC */
  607. }
  608. /**
  609. * ice_ptp_pf_handles_tx_interrupt - Check if PF handles Tx interrupt
  610. * @pf: Board private structure
  611. *
  612. * Return true if this PF should respond to the Tx timestamp interrupt
  613. * indication in the miscellaneous OICR interrupt handler.
  614. */
  615. static inline bool ice_ptp_pf_handles_tx_interrupt(struct ice_pf *pf)
  616. {
  617. return pf->ptp.tx_interrupt_mode != ICE_PTP_TX_INTERRUPT_NONE;
  618. }
  619. /**
  620. * ice_irq_dynamic_ena - Enable default interrupt generation settings
  621. * @hw: pointer to HW struct
  622. * @vsi: pointer to VSI struct, can be NULL
  623. * @q_vector: pointer to q_vector, can be NULL
  624. */
  625. static inline void
  626. ice_irq_dynamic_ena(struct ice_hw *hw, struct ice_vsi *vsi,
  627. struct ice_q_vector *q_vector)
  628. {
  629. u32 vector = (vsi && q_vector) ? q_vector->reg_idx :
  630. ((struct ice_pf *)hw->back)->oicr_irq.index;
  631. int itr = ICE_ITR_NONE;
  632. u32 val;
  633. /* clear the PBA here, as this function is meant to clean out all
  634. * previous interrupts and enable the interrupt
  635. */
  636. val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M |
  637. (itr << GLINT_DYN_CTL_ITR_INDX_S);
  638. if (vsi)
  639. if (test_bit(ICE_VSI_DOWN, vsi->state))
  640. return;
  641. wr32(hw, GLINT_DYN_CTL(vector), val);
  642. }
  643. /**
  644. * ice_netdev_to_pf - Retrieve the PF struct associated with a netdev
  645. * @netdev: pointer to the netdev struct
  646. */
  647. static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)
  648. {
  649. struct ice_netdev_priv *np = netdev_priv(netdev);
  650. return np->vsi->back;
  651. }
  652. static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi)
  653. {
  654. return !!READ_ONCE(vsi->xdp_prog);
  655. }
  656. static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)
  657. {
  658. ring->flags |= ICE_TX_FLAGS_RING_XDP;
  659. }
  660. /**
  661. * ice_get_xp_from_qid - get ZC XSK buffer pool bound to a queue ID
  662. * @vsi: pointer to VSI
  663. * @qid: index of a queue to look at XSK buff pool presence
  664. *
  665. * Return: A pointer to xsk_buff_pool structure if there is a buffer pool
  666. * attached and configured as zero-copy, NULL otherwise.
  667. */
  668. static inline struct xsk_buff_pool *ice_get_xp_from_qid(struct ice_vsi *vsi,
  669. u16 qid)
  670. {
  671. struct xsk_buff_pool *pool = xsk_get_pool_from_qid(vsi->netdev, qid);
  672. if (!ice_is_xdp_ena_vsi(vsi))
  673. return NULL;
  674. return (pool && pool->dev) ? pool : NULL;
  675. }
  676. /**
  677. * ice_rx_xsk_pool - assign XSK buff pool to Rx ring
  678. * @ring: Rx ring to use
  679. *
  680. * Sets XSK buff pool pointer on Rx ring.
  681. */
  682. static inline void ice_rx_xsk_pool(struct ice_rx_ring *ring)
  683. {
  684. struct ice_vsi *vsi = ring->vsi;
  685. u16 qid = ring->q_index;
  686. WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
  687. }
  688. /**
  689. * ice_tx_xsk_pool - assign XSK buff pool to XDP ring
  690. * @vsi: pointer to VSI
  691. * @qid: index of a queue to look at XSK buff pool presence
  692. *
  693. * Sets XSK buff pool pointer on XDP ring.
  694. *
  695. * XDP ring is picked from Rx ring, whereas Rx ring is picked based on provided
  696. * queue id. Reason for doing so is that queue vectors might have assigned more
  697. * than one XDP ring, e.g. when user reduced the queue count on netdev; Rx ring
  698. * carries a pointer to one of these XDP rings for its own purposes, such as
  699. * handling XDP_TX action, therefore we can piggyback here on the
  700. * rx_ring->xdp_ring assignment that was done during XDP rings initialization.
  701. */
  702. static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid)
  703. {
  704. struct ice_tx_ring *ring;
  705. ring = vsi->rx_rings[qid]->xdp_ring;
  706. if (!ring)
  707. return;
  708. WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
  709. }
  710. /**
  711. * ice_get_main_vsi - Get the PF VSI
  712. * @pf: PF instance
  713. *
  714. * returns pf->vsi[0], which by definition is the PF VSI
  715. */
  716. static inline struct ice_vsi *ice_get_main_vsi(struct ice_pf *pf)
  717. {
  718. if (pf->vsi)
  719. return pf->vsi[0];
  720. return NULL;
  721. }
  722. /**
  723. * ice_get_netdev_priv_vsi - return VSI associated with netdev priv.
  724. * @np: private netdev structure
  725. */
  726. static inline struct ice_vsi *ice_get_netdev_priv_vsi(struct ice_netdev_priv *np)
  727. {
  728. /* In case of port representor return source port VSI. */
  729. if (np->repr)
  730. return np->repr->src_vsi;
  731. else
  732. return np->vsi;
  733. }
  734. /**
  735. * ice_get_ctrl_vsi - Get the control VSI
  736. * @pf: PF instance
  737. */
  738. static inline struct ice_vsi *ice_get_ctrl_vsi(struct ice_pf *pf)
  739. {
  740. /* if pf->ctrl_vsi_idx is ICE_NO_VSI, control VSI was not set up */
  741. if (!pf->vsi || pf->ctrl_vsi_idx == ICE_NO_VSI)
  742. return NULL;
  743. return pf->vsi[pf->ctrl_vsi_idx];
  744. }
  745. /**
  746. * ice_find_vsi - Find the VSI from VSI ID
  747. * @pf: The PF pointer to search in
  748. * @vsi_num: The VSI ID to search for
  749. */
  750. static inline struct ice_vsi *ice_find_vsi(struct ice_pf *pf, u16 vsi_num)
  751. {
  752. int i;
  753. ice_for_each_vsi(pf, i)
  754. if (pf->vsi[i] && pf->vsi[i]->vsi_num == vsi_num)
  755. return pf->vsi[i];
  756. return NULL;
  757. }
  758. /**
  759. * ice_is_switchdev_running - check if switchdev is configured
  760. * @pf: pointer to PF structure
  761. *
  762. * Returns true if eswitch mode is set to DEVLINK_ESWITCH_MODE_SWITCHDEV
  763. * and switchdev is configured, false otherwise.
  764. */
  765. static inline bool ice_is_switchdev_running(struct ice_pf *pf)
  766. {
  767. return pf->eswitch.is_running;
  768. }
  769. #define ICE_FD_STAT_CTR_BLOCK_COUNT 256
  770. #define ICE_FD_STAT_PF_IDX(base_idx) \
  771. ((base_idx) * ICE_FD_STAT_CTR_BLOCK_COUNT)
  772. #define ICE_FD_SB_STAT_IDX(base_idx) ICE_FD_STAT_PF_IDX(base_idx)
  773. #define ICE_FD_STAT_CH 1
  774. #define ICE_FD_CH_STAT_IDX(base_idx) \
  775. (ICE_FD_STAT_PF_IDX(base_idx) + ICE_FD_STAT_CH)
  776. /**
  777. * ice_is_adq_active - any active ADQs
  778. * @pf: pointer to PF
  779. *
  780. * This function returns true if there are any ADQs configured (which is
  781. * determined by looking at VSI type (which should be VSI_PF), numtc, and
  782. * TC_MQPRIO flag) otherwise return false
  783. */
  784. static inline bool ice_is_adq_active(struct ice_pf *pf)
  785. {
  786. struct ice_vsi *vsi;
  787. vsi = ice_get_main_vsi(pf);
  788. if (!vsi)
  789. return false;
  790. /* is ADQ configured */
  791. if (vsi->tc_cfg.numtc > ICE_CHNL_START_TC &&
  792. test_bit(ICE_FLAG_TC_MQPRIO, pf->flags))
  793. return true;
  794. return false;
  795. }
  796. void ice_debugfs_fwlog_init(struct ice_pf *pf);
  797. void ice_debugfs_pf_deinit(struct ice_pf *pf);
  798. void ice_debugfs_init(void);
  799. void ice_debugfs_exit(void);
  800. void ice_pf_fwlog_update_module(struct ice_pf *pf, int log_level, int module);
  801. bool netif_is_ice(const struct net_device *dev);
  802. int ice_vsi_setup_tx_rings(struct ice_vsi *vsi);
  803. int ice_vsi_setup_rx_rings(struct ice_vsi *vsi);
  804. int ice_vsi_open_ctrl(struct ice_vsi *vsi);
  805. int ice_vsi_open(struct ice_vsi *vsi);
  806. void ice_set_ethtool_ops(struct net_device *netdev);
  807. void ice_set_ethtool_repr_ops(struct net_device *netdev);
  808. void ice_set_ethtool_safe_mode_ops(struct net_device *netdev);
  809. void ice_set_ethtool_sf_ops(struct net_device *netdev);
  810. u16 ice_get_avail_txq_count(struct ice_pf *pf);
  811. u16 ice_get_avail_rxq_count(struct ice_pf *pf);
  812. int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx, bool locked);
  813. void ice_update_vsi_stats(struct ice_vsi *vsi);
  814. void ice_update_pf_stats(struct ice_pf *pf);
  815. void
  816. ice_fetch_u64_stats_per_ring(struct u64_stats_sync *syncp,
  817. struct ice_q_stats stats, u64 *pkts, u64 *bytes);
  818. int ice_up(struct ice_vsi *vsi);
  819. int ice_down(struct ice_vsi *vsi);
  820. int ice_down_up(struct ice_vsi *vsi);
  821. int ice_vsi_cfg_lan(struct ice_vsi *vsi);
  822. struct ice_vsi *ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi);
  823. enum ice_xdp_cfg {
  824. ICE_XDP_CFG_FULL, /* Fully apply new config in .ndo_bpf() */
  825. ICE_XDP_CFG_PART, /* Save/use part of config in VSI rebuild */
  826. };
  827. int ice_vsi_determine_xdp_res(struct ice_vsi *vsi);
  828. int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog,
  829. enum ice_xdp_cfg cfg_type);
  830. int ice_destroy_xdp_rings(struct ice_vsi *vsi, enum ice_xdp_cfg cfg_type);
  831. void ice_map_xdp_rings(struct ice_vsi *vsi);
  832. int
  833. ice_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
  834. u32 flags);
  835. int ice_set_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size);
  836. int ice_get_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size);
  837. int ice_set_rss_key(struct ice_vsi *vsi, u8 *seed);
  838. int ice_get_rss_key(struct ice_vsi *vsi, u8 *seed);
  839. int ice_set_rss_hfunc(struct ice_vsi *vsi, u8 hfunc);
  840. void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size);
  841. int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset);
  842. void ice_print_link_msg(struct ice_vsi *vsi, bool isup);
  843. int ice_plug_aux_dev(struct ice_pf *pf);
  844. void ice_unplug_aux_dev(struct ice_pf *pf);
  845. int ice_init_rdma(struct ice_pf *pf);
  846. void ice_deinit_rdma(struct ice_pf *pf);
  847. const char *ice_aq_str(enum ice_aq_err aq_err);
  848. bool ice_is_wol_supported(struct ice_hw *hw);
  849. void ice_fdir_del_all_fltrs(struct ice_vsi *vsi);
  850. int
  851. ice_fdir_write_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input, bool add,
  852. bool is_tun);
  853. void ice_vsi_manage_fdir(struct ice_vsi *vsi, bool ena);
  854. int ice_add_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd);
  855. int ice_del_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd);
  856. int ice_get_ethtool_fdir_entry(struct ice_hw *hw, struct ethtool_rxnfc *cmd);
  857. int
  858. ice_get_fdir_fltr_ids(struct ice_hw *hw, struct ethtool_rxnfc *cmd,
  859. u32 *rule_locs);
  860. void ice_fdir_rem_adq_chnl(struct ice_hw *hw, u16 vsi_idx);
  861. void ice_fdir_release_flows(struct ice_hw *hw);
  862. void ice_fdir_replay_flows(struct ice_hw *hw);
  863. void ice_fdir_replay_fltrs(struct ice_pf *pf);
  864. int ice_fdir_create_dflt_rules(struct ice_pf *pf);
  865. enum ice_aq_task_state {
  866. ICE_AQ_TASK_NOT_PREPARED,
  867. ICE_AQ_TASK_WAITING,
  868. ICE_AQ_TASK_COMPLETE,
  869. ICE_AQ_TASK_CANCELED,
  870. };
  871. struct ice_aq_task {
  872. struct hlist_node entry;
  873. struct ice_rq_event_info event;
  874. enum ice_aq_task_state state;
  875. u16 opcode;
  876. };
  877. void ice_aq_prep_for_event(struct ice_pf *pf, struct ice_aq_task *task,
  878. u16 opcode);
  879. int ice_aq_wait_for_event(struct ice_pf *pf, struct ice_aq_task *task,
  880. unsigned long timeout);
  881. int ice_open(struct net_device *netdev);
  882. int ice_open_internal(struct net_device *netdev);
  883. int ice_stop(struct net_device *netdev);
  884. void ice_service_task_schedule(struct ice_pf *pf);
  885. int ice_load(struct ice_pf *pf);
  886. void ice_unload(struct ice_pf *pf);
  887. void ice_adv_lnk_speed_maps_init(void);
  888. int ice_init_dev(struct ice_pf *pf);
  889. void ice_deinit_dev(struct ice_pf *pf);
  890. int ice_change_mtu(struct net_device *netdev, int new_mtu);
  891. void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue);
  892. int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp);
  893. void ice_set_netdev_features(struct net_device *netdev);
  894. int ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid);
  895. int ice_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid);
  896. void ice_get_stats64(struct net_device *netdev,
  897. struct rtnl_link_stats64 *stats);
  898. /**
  899. * ice_set_rdma_cap - enable RDMA support
  900. * @pf: PF struct
  901. */
  902. static inline void ice_set_rdma_cap(struct ice_pf *pf)
  903. {
  904. if (pf->hw.func_caps.common_cap.rdma && pf->num_rdma_msix) {
  905. set_bit(ICE_FLAG_RDMA_ENA, pf->flags);
  906. set_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags);
  907. }
  908. }
  909. /**
  910. * ice_clear_rdma_cap - disable RDMA support
  911. * @pf: PF struct
  912. */
  913. static inline void ice_clear_rdma_cap(struct ice_pf *pf)
  914. {
  915. /* defer unplug to service task to avoid RTNL lock and
  916. * clear PLUG bit so that pending plugs don't interfere
  917. */
  918. clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags);
  919. set_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags);
  920. clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
  921. }
  922. static inline enum ice_phy_model ice_get_phy_model(const struct ice_hw *hw)
  923. {
  924. return hw->ptp.phy_model;
  925. }
  926. extern const struct xdp_metadata_ops ice_xdp_md_ops;
  927. #endif /* _ICE_H_ */