1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016-2018 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
14 #include <rte_mempool.h>
15 #include <rte_ethdev_driver.h>
19 #include "sfc_dp_rx.h"
29 * Software Rx descriptor information associated with hardware Rx
32 struct sfc_efx_rx_sw_desc {
33 struct rte_mbuf *mbuf;
38 /** Receive queue state bits */
39 enum sfc_rxq_state_bit {
40 SFC_RXQ_INITIALIZED_BIT = 0,
41 #define SFC_RXQ_INITIALIZED (1 << SFC_RXQ_INITIALIZED_BIT)
43 #define SFC_RXQ_STARTED (1 << SFC_RXQ_STARTED_BIT)
45 #define SFC_RXQ_FLUSHING (1 << SFC_RXQ_FLUSHING_BIT)
47 #define SFC_RXQ_FLUSHED (1 << SFC_RXQ_FLUSHED_BIT)
48 SFC_RXQ_FLUSH_FAILED_BIT,
49 #define SFC_RXQ_FLUSH_FAILED (1 << SFC_RXQ_FLUSH_FAILED_BIT)
53 * Receive queue control information.
54 * Allocated on the socket specified on the queue setup.
60 unsigned int hw_index;
61 unsigned int refill_threshold;
62 struct rte_mempool *refill_mb_pool;
63 struct sfc_dp_rxq *dp;
67 static inline unsigned int
68 sfc_rxq_sw_index_by_hw_index(unsigned int hw_index)
73 static inline unsigned int
74 sfc_rxq_sw_index(const struct sfc_rxq *rxq)
76 return sfc_rxq_sw_index_by_hw_index(rxq->hw_index);
79 struct sfc_rxq *sfc_rxq_by_dp_rxq(const struct sfc_dp_rxq *dp_rxq);
82 * Receive queue information used on libefx-based data path.
83 * Allocated on the socket specified on the queue setup.
86 /* Used on data path */
89 #define SFC_EFX_RXQ_FLAG_STARTED 0x1
90 #define SFC_EFX_RXQ_FLAG_RUNNING 0x2
91 #define SFC_EFX_RXQ_FLAG_RSS_HASH 0x4
92 unsigned int ptr_mask;
94 unsigned int completed;
97 struct sfc_efx_rx_sw_desc *sw_desc;
102 unsigned int max_fill_level;
103 unsigned int refill_threshold;
105 struct rte_mempool *refill_mb_pool;
108 /* Datapath receive queue anchor */
109 struct sfc_dp_rxq dp;
112 static inline struct sfc_efx_rxq *
113 sfc_efx_rxq_by_dp_rxq(struct sfc_dp_rxq *dp_rxq)
115 return container_of(dp_rxq, struct sfc_efx_rxq, dp);
119 * Receive queue information used during setup/release only.
120 * Allocated on the same socket as adapter data.
122 struct sfc_rxq_info {
123 unsigned int max_entries;
124 unsigned int entries;
126 unsigned int type_flags;
128 boolean_t deferred_start;
129 boolean_t deferred_started;
132 int sfc_rx_configure(struct sfc_adapter *sa);
133 void sfc_rx_close(struct sfc_adapter *sa);
134 int sfc_rx_start(struct sfc_adapter *sa);
135 void sfc_rx_stop(struct sfc_adapter *sa);
137 int sfc_rx_qinit(struct sfc_adapter *sa, unsigned int rx_queue_id,
138 uint16_t nb_rx_desc, unsigned int socket_id,
139 const struct rte_eth_rxconf *rx_conf,
140 struct rte_mempool *mb_pool);
141 void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
142 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
143 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
145 uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
146 uint64_t sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa);
148 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
149 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
151 unsigned int sfc_rx_qdesc_npending(struct sfc_adapter *sa,
152 unsigned int sw_index);
153 int sfc_rx_qdesc_done(struct sfc_dp_rxq *dp_rxq, unsigned int offset);
155 efx_rx_hash_type_t sfc_rte_to_efx_hash_type(uint64_t rss_hf);
156 uint64_t sfc_efx_to_rte_hash_type(efx_rx_hash_type_t efx_hash_types);
161 #endif /* _SFC_RX_H */