1c1d14583SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 2c1d14583SBruce Richardson * Copyright(c) 2018 Intel Corporation 3c1d14583SBruce Richardson */ 4c1d14583SBruce Richardson 5c1d14583SBruce Richardson #ifndef _ICE_RXTX_H_ 6c1d14583SBruce Richardson #define _ICE_RXTX_H_ 7c1d14583SBruce Richardson 8*5cc9919fSBruce Richardson #include "../common/tx.h" 9c1d14583SBruce Richardson #include "ice_ethdev.h" 10c1d14583SBruce Richardson 11c1d14583SBruce Richardson #define ICE_ALIGN_RING_DESC 32 12c1d14583SBruce Richardson #define ICE_MIN_RING_DESC 64 13c1d14583SBruce Richardson #define ICE_MAX_RING_DESC (8192 - 32) 14c1d14583SBruce Richardson #define ICE_DMA_MEM_ALIGN 4096 15c1d14583SBruce Richardson #define ICE_RING_BASE_ALIGN 128 16c1d14583SBruce Richardson 17c1d14583SBruce Richardson #define ICE_RX_MAX_BURST 32 18c1d14583SBruce Richardson #define ICE_TX_MAX_BURST 32 19c1d14583SBruce Richardson 20c1d14583SBruce Richardson /* Maximal number of segments to split. */ 21c1d14583SBruce Richardson #define ICE_RX_MAX_NSEG 2 22c1d14583SBruce Richardson 23c1d14583SBruce Richardson #define ICE_CHK_Q_ENA_COUNT 100 24c1d14583SBruce Richardson #define ICE_CHK_Q_ENA_INTERVAL_US 100 25c1d14583SBruce Richardson 26c1d14583SBruce Richardson #ifdef RTE_LIBRTE_ICE_16BYTE_RX_DESC 27c1d14583SBruce Richardson #define ice_rx_flex_desc ice_16b_rx_flex_desc 28c1d14583SBruce Richardson #else 29c1d14583SBruce Richardson #define ice_rx_flex_desc ice_32b_rx_flex_desc 30c1d14583SBruce Richardson #endif 31c1d14583SBruce Richardson 32c1d14583SBruce Richardson #define ICE_SUPPORT_CHAIN_NUM 5 33c1d14583SBruce Richardson 34c1d14583SBruce Richardson #define ICE_TD_CMD ICE_TX_DESC_CMD_EOP 35c1d14583SBruce Richardson 36c1d14583SBruce Richardson #define ICE_VPMD_RX_BURST 32 37c1d14583SBruce Richardson #define ICE_VPMD_TX_BURST 32 38c1d14583SBruce Richardson #define ICE_RXQ_REARM_THRESH 64 39c1d14583SBruce Richardson #define ICE_MAX_RX_BURST ICE_RXQ_REARM_THRESH 40c1d14583SBruce Richardson #define ICE_TX_MAX_FREE_BUF_SZ 64 41c1d14583SBruce Richardson #define ICE_DESCS_PER_LOOP 4 42c1d14583SBruce Richardson 43c1d14583SBruce Richardson #define ICE_FDIR_PKT_LEN 512 44c1d14583SBruce Richardson 45c1d14583SBruce Richardson #define ICE_RXDID_COMMS_OVS 22 46c1d14583SBruce Richardson 47c1d14583SBruce Richardson #define ICE_TX_MIN_PKT_LEN 17 48c1d14583SBruce Richardson 49c1d14583SBruce Richardson #define ICE_TX_OFFLOAD_MASK ( \ 50c1d14583SBruce Richardson RTE_MBUF_F_TX_OUTER_IPV6 | \ 51c1d14583SBruce Richardson RTE_MBUF_F_TX_OUTER_IPV4 | \ 52c1d14583SBruce Richardson RTE_MBUF_F_TX_OUTER_IP_CKSUM | \ 53c1d14583SBruce Richardson RTE_MBUF_F_TX_VLAN | \ 54c1d14583SBruce Richardson RTE_MBUF_F_TX_IPV6 | \ 55c1d14583SBruce Richardson RTE_MBUF_F_TX_IPV4 | \ 56c1d14583SBruce Richardson RTE_MBUF_F_TX_IP_CKSUM | \ 57c1d14583SBruce Richardson RTE_MBUF_F_TX_L4_MASK | \ 58c1d14583SBruce Richardson RTE_MBUF_F_TX_IEEE1588_TMST | \ 59c1d14583SBruce Richardson RTE_MBUF_F_TX_TCP_SEG | \ 60c1d14583SBruce Richardson RTE_MBUF_F_TX_QINQ | \ 61c1d14583SBruce Richardson RTE_MBUF_F_TX_TUNNEL_MASK | \ 62c1d14583SBruce Richardson RTE_MBUF_F_TX_UDP_SEG | \ 63c1d14583SBruce Richardson RTE_MBUF_F_TX_OUTER_UDP_CKSUM) 64c1d14583SBruce Richardson 65c1d14583SBruce Richardson #define ICE_TX_OFFLOAD_NOTSUP_MASK \ 66c1d14583SBruce Richardson (RTE_MBUF_F_TX_OFFLOAD_MASK ^ ICE_TX_OFFLOAD_MASK) 67c1d14583SBruce Richardson 68c1d14583SBruce Richardson extern uint64_t ice_timestamp_dynflag; 69c1d14583SBruce Richardson extern int ice_timestamp_dynfield_offset; 70c1d14583SBruce Richardson 71c1d14583SBruce Richardson /* Max header size can be 2K - 64 bytes */ 72c1d14583SBruce Richardson #define ICE_RX_HDR_BUF_SIZE (2048 - 64) 73c1d14583SBruce Richardson 74c1d14583SBruce Richardson /* Max data buffer size must be 16K - 128 bytes */ 75c1d14583SBruce Richardson #define ICE_RX_MAX_DATA_BUF_SIZE (16 * 1024 - 128) 76c1d14583SBruce Richardson 77c1d14583SBruce Richardson #define ICE_HEADER_SPLIT_ENA BIT(0) 78c1d14583SBruce Richardson 79c1d14583SBruce Richardson #define ICE_TX_MTU_SEG_MAX 8 80c1d14583SBruce Richardson 81c1d14583SBruce Richardson typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq); 82c1d14583SBruce Richardson typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq); 83c1d14583SBruce Richardson typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq, 84c1d14583SBruce Richardson struct rte_mbuf *mb, 85c1d14583SBruce Richardson volatile union ice_rx_flex_desc *rxdp); 86c1d14583SBruce Richardson 87c1d14583SBruce Richardson struct ice_rx_entry { 88c1d14583SBruce Richardson struct rte_mbuf *mbuf; 89c1d14583SBruce Richardson }; 90c1d14583SBruce Richardson 91c1d14583SBruce Richardson enum ice_rx_dtype { 92c1d14583SBruce Richardson ICE_RX_DTYPE_NO_SPLIT = 0, 93c1d14583SBruce Richardson ICE_RX_DTYPE_HEADER_SPLIT = 1, 94c1d14583SBruce Richardson ICE_RX_DTYPE_SPLIT_ALWAYS = 2, 95c1d14583SBruce Richardson }; 96c1d14583SBruce Richardson 97c1d14583SBruce Richardson struct ice_rx_queue { 98c1d14583SBruce Richardson struct rte_mempool *mp; /* mbuf pool to populate RX ring */ 99c1d14583SBruce Richardson volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */ 100c1d14583SBruce Richardson rte_iova_t rx_ring_dma; /* RX ring DMA address */ 101c1d14583SBruce Richardson struct ice_rx_entry *sw_ring; /* address of RX soft ring */ 102c1d14583SBruce Richardson uint16_t nb_rx_desc; /* number of RX descriptors */ 103c1d14583SBruce Richardson uint16_t rx_free_thresh; /* max free RX desc to hold */ 104c1d14583SBruce Richardson uint16_t rx_tail; /* current value of tail */ 105c1d14583SBruce Richardson uint16_t nb_rx_hold; /* number of held free RX desc */ 106c1d14583SBruce Richardson struct rte_mbuf *pkt_first_seg; /**< first segment of current packet */ 107c1d14583SBruce Richardson struct rte_mbuf *pkt_last_seg; /**< last segment of current packet */ 108c1d14583SBruce Richardson uint16_t rx_nb_avail; /**< number of staged packets ready */ 109c1d14583SBruce Richardson uint16_t rx_next_avail; /**< index of next staged packets */ 110c1d14583SBruce Richardson uint16_t rx_free_trigger; /**< triggers rx buffer allocation */ 111c1d14583SBruce Richardson struct rte_mbuf fake_mbuf; /**< dummy mbuf */ 112c1d14583SBruce Richardson struct rte_mbuf *rx_stage[ICE_RX_MAX_BURST * 2]; 113c1d14583SBruce Richardson 114c1d14583SBruce Richardson uint16_t rxrearm_nb; /**< number of remaining to be re-armed */ 115c1d14583SBruce Richardson uint16_t rxrearm_start; /**< the idx we start the re-arming from */ 116c1d14583SBruce Richardson uint64_t mbuf_initializer; /**< value to init mbufs */ 117c1d14583SBruce Richardson 118c1d14583SBruce Richardson uint16_t port_id; /* device port ID */ 119c1d14583SBruce Richardson uint8_t crc_len; /* 0 if CRC stripped, 4 otherwise */ 120c1d14583SBruce Richardson uint8_t fdir_enabled; /* 0 if FDIR disabled, 1 when enabled */ 121c1d14583SBruce Richardson uint16_t queue_id; /* RX queue index */ 122c1d14583SBruce Richardson uint16_t reg_idx; /* RX queue register index */ 123c1d14583SBruce Richardson uint8_t drop_en; /* if not 0, set register bit */ 124c1d14583SBruce Richardson volatile uint8_t *qrx_tail; /* register address of tail */ 125c1d14583SBruce Richardson struct ice_vsi *vsi; /* the VSI this queue belongs to */ 126c1d14583SBruce Richardson uint16_t rx_buf_len; /* The packet buffer size */ 127c1d14583SBruce Richardson uint16_t rx_hdr_len; /* The header buffer size */ 128c1d14583SBruce Richardson uint16_t max_pkt_len; /* Maximum packet length */ 129c1d14583SBruce Richardson bool q_set; /* indicate if rx queue has been configured */ 130c1d14583SBruce Richardson bool rx_deferred_start; /* don't start this queue in dev start */ 131c1d14583SBruce Richardson uint8_t proto_xtr; /* Protocol extraction from flexible descriptor */ 132c1d14583SBruce Richardson int xtr_field_offs; /*Protocol extraction matedata offset*/ 133c1d14583SBruce Richardson uint64_t xtr_ol_flag; /* Protocol extraction offload flag */ 134c1d14583SBruce Richardson uint32_t rxdid; /* Receive Flex Descriptor profile ID */ 135c1d14583SBruce Richardson ice_rx_release_mbufs_t rx_rel_mbufs; 136c1d14583SBruce Richardson uint64_t offloads; 137c1d14583SBruce Richardson uint32_t time_high; 138c1d14583SBruce Richardson uint32_t hw_register_set; 139c1d14583SBruce Richardson const struct rte_memzone *mz; 140c1d14583SBruce Richardson uint32_t hw_time_high; /* high 32 bits of timestamp */ 141c1d14583SBruce Richardson uint32_t hw_time_low; /* low 32 bits of timestamp */ 142c1d14583SBruce Richardson uint64_t hw_time_update; /* SW time of HW record updating */ 143c1d14583SBruce Richardson struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG]; 144c1d14583SBruce Richardson uint32_t rxseg_nb; 145c1d14583SBruce Richardson bool ts_enable; /* if rxq timestamp is enabled */ 146c1d14583SBruce Richardson }; 147c1d14583SBruce Richardson 148c1d14583SBruce Richardson struct ice_tx_queue { 149c1d14583SBruce Richardson uint16_t nb_tx_desc; /* number of TX descriptors */ 150c1d14583SBruce Richardson rte_iova_t tx_ring_dma; /* TX ring DMA address */ 151c1d14583SBruce Richardson volatile struct ice_tx_desc *tx_ring; /* TX ring virtual address */ 152*5cc9919fSBruce Richardson struct ci_tx_entry *sw_ring; /* virtual address of SW ring */ 153c1d14583SBruce Richardson uint16_t tx_tail; /* current value of tail register */ 154c1d14583SBruce Richardson volatile uint8_t *qtx_tail; /* register address of tail */ 155c1d14583SBruce Richardson uint16_t nb_tx_used; /* number of TX desc used since RS bit set */ 156c1d14583SBruce Richardson /* index to last TX descriptor to have been cleaned */ 157c1d14583SBruce Richardson uint16_t last_desc_cleaned; 158c1d14583SBruce Richardson /* Total number of TX descriptors ready to be allocated. */ 159c1d14583SBruce Richardson uint16_t nb_tx_free; 160c1d14583SBruce Richardson /* Start freeing TX buffers if there are less free descriptors than 161c1d14583SBruce Richardson * this value. 162c1d14583SBruce Richardson */ 163c1d14583SBruce Richardson uint16_t tx_free_thresh; 164c1d14583SBruce Richardson /* Number of TX descriptors to use before RS bit is set. */ 165c1d14583SBruce Richardson uint16_t tx_rs_thresh; 166c1d14583SBruce Richardson uint8_t pthresh; /**< Prefetch threshold register. */ 167c1d14583SBruce Richardson uint8_t hthresh; /**< Host threshold register. */ 168c1d14583SBruce Richardson uint8_t wthresh; /**< Write-back threshold reg. */ 169c1d14583SBruce Richardson uint16_t port_id; /* Device port identifier. */ 170c1d14583SBruce Richardson uint16_t queue_id; /* TX queue index. */ 171c1d14583SBruce Richardson uint32_t q_teid; /* TX schedule node id. */ 172c1d14583SBruce Richardson uint16_t reg_idx; 173c1d14583SBruce Richardson uint64_t offloads; 174c1d14583SBruce Richardson struct ice_vsi *vsi; /* the VSI this queue belongs to */ 175c1d14583SBruce Richardson uint16_t tx_next_dd; 176c1d14583SBruce Richardson uint16_t tx_next_rs; 177c1d14583SBruce Richardson uint64_t mbuf_errors; 178c1d14583SBruce Richardson bool tx_deferred_start; /* don't start this queue in dev start */ 179c1d14583SBruce Richardson bool q_set; /* indicate if tx queue has been configured */ 180c1d14583SBruce Richardson ice_tx_release_mbufs_t tx_rel_mbufs; 181c1d14583SBruce Richardson const struct rte_memzone *mz; 182c1d14583SBruce Richardson }; 183c1d14583SBruce Richardson 184c1d14583SBruce Richardson /* Offload features */ 185c1d14583SBruce Richardson union ice_tx_offload { 186c1d14583SBruce Richardson uint64_t data; 187c1d14583SBruce Richardson struct { 188c1d14583SBruce Richardson uint64_t l2_len:7; /* L2 (MAC) Header Length. */ 189c1d14583SBruce Richardson uint64_t l3_len:9; /* L3 (IP) Header Length. */ 190c1d14583SBruce Richardson uint64_t l4_len:8; /* L4 Header Length. */ 191c1d14583SBruce Richardson uint64_t tso_segsz:16; /* TCP TSO segment size */ 192c1d14583SBruce Richardson uint64_t outer_l2_len:8; /* outer L2 Header Length */ 193c1d14583SBruce Richardson uint64_t outer_l3_len:16; /* outer L3 Header Length */ 194c1d14583SBruce Richardson }; 195c1d14583SBruce Richardson }; 196c1d14583SBruce Richardson 197c1d14583SBruce Richardson /* Rx Flex Descriptor for Comms Package Profile 198c1d14583SBruce Richardson * RxDID Profile ID 22 (swap Hash and FlowID) 199c1d14583SBruce Richardson * Flex-field 0: Flow ID lower 16-bits 200c1d14583SBruce Richardson * Flex-field 1: Flow ID upper 16-bits 201c1d14583SBruce Richardson * Flex-field 2: RSS hash lower 16-bits 202c1d14583SBruce Richardson * Flex-field 3: RSS hash upper 16-bits 203c1d14583SBruce Richardson * Flex-field 4: AUX0 204c1d14583SBruce Richardson * Flex-field 5: AUX1 205c1d14583SBruce Richardson */ 206c1d14583SBruce Richardson struct ice_32b_rx_flex_desc_comms_ovs { 207c1d14583SBruce Richardson /* Qword 0 */ 208c1d14583SBruce Richardson u8 rxdid; 209c1d14583SBruce Richardson u8 mir_id_umb_cast; 210c1d14583SBruce Richardson __le16 ptype_flexi_flags0; 211c1d14583SBruce Richardson __le16 pkt_len; 212c1d14583SBruce Richardson __le16 hdr_len_sph_flex_flags1; 213c1d14583SBruce Richardson 214c1d14583SBruce Richardson /* Qword 1 */ 215c1d14583SBruce Richardson __le16 status_error0; 216c1d14583SBruce Richardson __le16 l2tag1; 217c1d14583SBruce Richardson __le32 flow_id; 218c1d14583SBruce Richardson 219c1d14583SBruce Richardson /* Qword 2 */ 220c1d14583SBruce Richardson __le16 status_error1; 221c1d14583SBruce Richardson u8 flexi_flags2; 222c1d14583SBruce Richardson u8 ts_low; 223c1d14583SBruce Richardson __le16 l2tag2_1st; 224c1d14583SBruce Richardson __le16 l2tag2_2nd; 225c1d14583SBruce Richardson 226c1d14583SBruce Richardson /* Qword 3 */ 227c1d14583SBruce Richardson __le32 rss_hash; 228c1d14583SBruce Richardson union { 229c1d14583SBruce Richardson struct { 230c1d14583SBruce Richardson __le16 aux0; 231c1d14583SBruce Richardson __le16 aux1; 232c1d14583SBruce Richardson } flex; 233c1d14583SBruce Richardson __le32 ts_high; 234c1d14583SBruce Richardson } flex_ts; 235c1d14583SBruce Richardson }; 236c1d14583SBruce Richardson 237c1d14583SBruce Richardson int ice_rx_queue_setup(struct rte_eth_dev *dev, 238c1d14583SBruce Richardson uint16_t queue_idx, 239c1d14583SBruce Richardson uint16_t nb_desc, 240c1d14583SBruce Richardson unsigned int socket_id, 241c1d14583SBruce Richardson const struct rte_eth_rxconf *rx_conf, 242c1d14583SBruce Richardson struct rte_mempool *mp); 243c1d14583SBruce Richardson int ice_tx_queue_setup(struct rte_eth_dev *dev, 244c1d14583SBruce Richardson uint16_t queue_idx, 245c1d14583SBruce Richardson uint16_t nb_desc, 246c1d14583SBruce Richardson unsigned int socket_id, 247c1d14583SBruce Richardson const struct rte_eth_txconf *tx_conf); 248c1d14583SBruce Richardson int ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); 249c1d14583SBruce Richardson int ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); 250c1d14583SBruce Richardson int ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); 251c1d14583SBruce Richardson int ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); 252c1d14583SBruce Richardson int ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); 253c1d14583SBruce Richardson int ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); 254c1d14583SBruce Richardson int ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); 255c1d14583SBruce Richardson int ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); 256c1d14583SBruce Richardson void ice_rx_queue_release(void *rxq); 257c1d14583SBruce Richardson void ice_tx_queue_release(void *txq); 258c1d14583SBruce Richardson void ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 259c1d14583SBruce Richardson void ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid); 260c1d14583SBruce Richardson void ice_free_queues(struct rte_eth_dev *dev); 261c1d14583SBruce Richardson int ice_fdir_setup_tx_resources(struct ice_pf *pf); 262c1d14583SBruce Richardson int ice_fdir_setup_rx_resources(struct ice_pf *pf); 263c1d14583SBruce Richardson uint16_t ice_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 264c1d14583SBruce Richardson uint16_t nb_pkts); 265c1d14583SBruce Richardson uint16_t ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 266c1d14583SBruce Richardson uint16_t nb_pkts); 267c1d14583SBruce Richardson void ice_set_rx_function(struct rte_eth_dev *dev); 268c1d14583SBruce Richardson uint16_t ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, 269c1d14583SBruce Richardson uint16_t nb_pkts); 270c1d14583SBruce Richardson void ice_set_tx_function_flag(struct rte_eth_dev *dev, 271c1d14583SBruce Richardson struct ice_tx_queue *txq); 272c1d14583SBruce Richardson void ice_set_tx_function(struct rte_eth_dev *dev); 273c1d14583SBruce Richardson uint32_t ice_rx_queue_count(void *rx_queue); 274c1d14583SBruce Richardson void ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, 275c1d14583SBruce Richardson struct rte_eth_rxq_info *qinfo); 276c1d14583SBruce Richardson void ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, 277c1d14583SBruce Richardson struct rte_eth_txq_info *qinfo); 278c1d14583SBruce Richardson int ice_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id, 279c1d14583SBruce Richardson struct rte_eth_burst_mode *mode); 280c1d14583SBruce Richardson int ice_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id, 281c1d14583SBruce Richardson struct rte_eth_burst_mode *mode); 282c1d14583SBruce Richardson int ice_rx_descriptor_status(void *rx_queue, uint16_t offset); 283c1d14583SBruce Richardson int ice_tx_descriptor_status(void *tx_queue, uint16_t offset); 284c1d14583SBruce Richardson void ice_set_default_ptype_table(struct rte_eth_dev *dev); 285c1d14583SBruce Richardson const uint32_t *ice_dev_supported_ptypes_get(struct rte_eth_dev *dev, 286c1d14583SBruce Richardson size_t *no_of_elements); 287c1d14583SBruce Richardson void ice_select_rxd_to_pkt_fields_handler(struct ice_rx_queue *rxq, 288c1d14583SBruce Richardson uint32_t rxdid); 289c1d14583SBruce Richardson 290c1d14583SBruce Richardson int ice_rx_vec_dev_check(struct rte_eth_dev *dev); 291c1d14583SBruce Richardson int ice_tx_vec_dev_check(struct rte_eth_dev *dev); 292c1d14583SBruce Richardson int ice_rxq_vec_setup(struct ice_rx_queue *rxq); 293c1d14583SBruce Richardson int ice_txq_vec_setup(struct ice_tx_queue *txq); 294c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, 295c1d14583SBruce Richardson uint16_t nb_pkts); 296c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, 297c1d14583SBruce Richardson uint16_t nb_pkts); 298c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, 299c1d14583SBruce Richardson uint16_t nb_pkts); 300c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, 301c1d14583SBruce Richardson uint16_t nb_pkts); 302c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts, 303c1d14583SBruce Richardson uint16_t nb_pkts); 304c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue, 305c1d14583SBruce Richardson struct rte_mbuf **rx_pkts, 306c1d14583SBruce Richardson uint16_t nb_pkts); 307c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue, 308c1d14583SBruce Richardson struct rte_mbuf **rx_pkts, 309c1d14583SBruce Richardson uint16_t nb_pkts); 310c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, 311c1d14583SBruce Richardson uint16_t nb_pkts); 312c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts, 313c1d14583SBruce Richardson uint16_t nb_pkts); 314c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts, 315c1d14583SBruce Richardson uint16_t nb_pkts); 316c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx512_offload(void *rx_queue, 317c1d14583SBruce Richardson struct rte_mbuf **rx_pkts, 318c1d14583SBruce Richardson uint16_t nb_pkts); 319c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx512(void *rx_queue, 320c1d14583SBruce Richardson struct rte_mbuf **rx_pkts, 321c1d14583SBruce Richardson uint16_t nb_pkts); 322c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx512_offload(void *rx_queue, 323c1d14583SBruce Richardson struct rte_mbuf **rx_pkts, 324c1d14583SBruce Richardson uint16_t nb_pkts); 325c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts, 326c1d14583SBruce Richardson uint16_t nb_pkts); 327c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx512_offload(void *tx_queue, 328c1d14583SBruce Richardson struct rte_mbuf **tx_pkts, 329c1d14583SBruce Richardson uint16_t nb_pkts); 330c1d14583SBruce Richardson int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc); 331c1d14583SBruce Richardson int ice_tx_done_cleanup(void *txq, uint32_t free_cnt); 332c1d14583SBruce Richardson int ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc); 333c1d14583SBruce Richardson 334c1d14583SBruce Richardson #define FDIR_PARSING_ENABLE_PER_QUEUE(ad, on) do { \ 335c1d14583SBruce Richardson int i; \ 336c1d14583SBruce Richardson for (i = 0; i < (ad)->pf.dev_data->nb_rx_queues; i++) { \ 337c1d14583SBruce Richardson struct ice_rx_queue *rxq = (ad)->pf.dev_data->rx_queues[i]; \ 338c1d14583SBruce Richardson if (!rxq) \ 339c1d14583SBruce Richardson continue; \ 340c1d14583SBruce Richardson rxq->fdir_enabled = on; \ 341c1d14583SBruce Richardson } \ 342c1d14583SBruce Richardson PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \ 343c1d14583SBruce Richardson } while (0) 344c1d14583SBruce Richardson 345c1d14583SBruce Richardson /* Enable/disable flow director parsing from Rx descriptor in data path. */ 346c1d14583SBruce Richardson static inline 347c1d14583SBruce Richardson void ice_fdir_rx_parsing_enable(struct ice_adapter *ad, bool on) 348c1d14583SBruce Richardson { 349c1d14583SBruce Richardson if (on) { 350c1d14583SBruce Richardson /* Enable flow director parsing from Rx descriptor */ 351c1d14583SBruce Richardson FDIR_PARSING_ENABLE_PER_QUEUE(ad, on); 352c1d14583SBruce Richardson ad->fdir_ref_cnt++; 353c1d14583SBruce Richardson } else { 354c1d14583SBruce Richardson if (ad->fdir_ref_cnt >= 1) { 355c1d14583SBruce Richardson ad->fdir_ref_cnt--; 356c1d14583SBruce Richardson 357c1d14583SBruce Richardson if (ad->fdir_ref_cnt == 0) 358c1d14583SBruce Richardson FDIR_PARSING_ENABLE_PER_QUEUE(ad, on); 359c1d14583SBruce Richardson } 360c1d14583SBruce Richardson } 361c1d14583SBruce Richardson } 362c1d14583SBruce Richardson 363c1d14583SBruce Richardson #define ICE_TIMESYNC_REG_WRAP_GUARD_BAND 10000 364c1d14583SBruce Richardson 365c1d14583SBruce Richardson /* Helper function to convert a 32b nanoseconds timestamp to 64b. */ 366c1d14583SBruce Richardson static inline 367c1d14583SBruce Richardson uint64_t ice_tstamp_convert_32b_64b(struct ice_hw *hw, struct ice_adapter *ad, 368c1d14583SBruce Richardson uint32_t flag, uint32_t in_timestamp) 369c1d14583SBruce Richardson { 370c1d14583SBruce Richardson uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc; 371c1d14583SBruce Richardson const uint64_t mask = 0xFFFFFFFF; 372c1d14583SBruce Richardson uint32_t hi, lo, lo2, delta; 373c1d14583SBruce Richardson uint64_t ns; 374c1d14583SBruce Richardson 375c1d14583SBruce Richardson if (flag) { 376c1d14583SBruce Richardson lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); 377c1d14583SBruce Richardson hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx)); 378c1d14583SBruce Richardson 379c1d14583SBruce Richardson /* 380c1d14583SBruce Richardson * On typical system, the delta between lo and lo2 is ~1000ns, 381c1d14583SBruce Richardson * so 10000 seems a large-enough but not overly-big guard band. 382c1d14583SBruce Richardson */ 383c1d14583SBruce Richardson if (lo > (UINT32_MAX - ICE_TIMESYNC_REG_WRAP_GUARD_BAND)) 384c1d14583SBruce Richardson lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); 385c1d14583SBruce Richardson else 386c1d14583SBruce Richardson lo2 = lo; 387c1d14583SBruce Richardson 388c1d14583SBruce Richardson if (lo2 < lo) { 389c1d14583SBruce Richardson lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx)); 390c1d14583SBruce Richardson hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx)); 391c1d14583SBruce Richardson } 392c1d14583SBruce Richardson 393c1d14583SBruce Richardson ad->time_hw = ((uint64_t)hi << 32) | lo; 394c1d14583SBruce Richardson } 395c1d14583SBruce Richardson 396c1d14583SBruce Richardson delta = (in_timestamp - (uint32_t)(ad->time_hw & mask)); 397c1d14583SBruce Richardson if (delta > (mask / 2)) { 398c1d14583SBruce Richardson delta = ((uint32_t)(ad->time_hw & mask) - in_timestamp); 399c1d14583SBruce Richardson ns = ad->time_hw - delta; 400c1d14583SBruce Richardson } else { 401c1d14583SBruce Richardson ns = ad->time_hw + delta; 402c1d14583SBruce Richardson } 403c1d14583SBruce Richardson 404c1d14583SBruce Richardson return ns; 405c1d14583SBruce Richardson } 406c1d14583SBruce Richardson 407c1d14583SBruce Richardson #endif /* _ICE_RXTX_H_ */ 408