Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2022 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _GVE_ETHDEV_H_
6 : : #define _GVE_ETHDEV_H_
7 : :
8 : : #include <ethdev_driver.h>
9 : : #include <ethdev_pci.h>
10 : : #include <rte_alarm.h>
11 : : #include <rte_ether.h>
12 : : #include <rte_pci.h>
13 : : #include <pthread.h>
14 : : #include <rte_bitmap.h>
15 : : #include <rte_memzone.h>
16 : : #include <rte_thread.h>
17 : :
18 : : #include "base/gve.h"
19 : :
20 : : /* TODO: this is a workaround to ensure that Tx complq is enough */
21 : : #define DQO_TX_MULTIPLIER 4
22 : :
23 : : #define GVE_DEFAULT_MAX_RING_SIZE 1024
24 : : #define GVE_MAX_RING_SIZE_GQ_QPL 2048
25 : : #define GVE_DEFAULT_MIN_RX_RING_SIZE 512
26 : : #define GVE_DEFAULT_MIN_TX_RING_SIZE 256
27 : :
28 : : #define GVE_DEFAULT_RX_FREE_THRESH 64
29 : : #define GVE_DEFAULT_TX_FREE_THRESH 32
30 : : #define GVE_DEFAULT_TX_RS_THRESH 32
31 : : #define GVE_TX_MAX_FREE_SZ 512
32 : :
33 : : #define GVE_RX_BUF_ALIGN_DQO 128
34 : : #define GVE_RX_MIN_BUF_SIZE_DQO 1024
35 : : #define GVE_RX_MAX_BUF_SIZE_DQO ((16 * 1024) - GVE_RX_BUF_ALIGN_DQO)
36 : : #define GVE_MAX_QUEUE_SIZE_DQO 4096
37 : :
38 : : #define GVE_RX_BUF_ALIGN_GQI 2048
39 : : #define GVE_RX_MIN_BUF_SIZE_GQI 2048
40 : : #define GVE_RX_MAX_BUF_SIZE_GQI 4096
41 : :
42 : : #define GVE_RSS_HASH_KEY_SIZE 40
43 : : #define GVE_RSS_INDIR_SIZE 128
44 : :
45 : : #define GVE_NIC_CLOCK_READ_PERIOD_MS 250
46 : : #define GVE_NIC_CLOCK_READ_MAX_FAILS 7
47 : :
48 : : #define GVE_TX_CKSUM_OFFLOAD_MASK ( \
49 : : RTE_MBUF_F_TX_L4_MASK | \
50 : : RTE_MBUF_F_TX_TCP_SEG)
51 : :
52 : : #define GVE_TX_CKSUM_OFFLOAD_MASK_DQO ( \
53 : : GVE_TX_CKSUM_OFFLOAD_MASK | \
54 : : RTE_MBUF_F_TX_IP_CKSUM)
55 : :
56 : : #define GVE_RTE_RSS_OFFLOAD_ALL ( \
57 : : RTE_ETH_RSS_IPV4 | \
58 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
59 : : RTE_ETH_RSS_IPV6 | \
60 : : RTE_ETH_RSS_IPV6_EX | \
61 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
62 : : RTE_ETH_RSS_IPV6_TCP_EX | \
63 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
64 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
65 : : RTE_ETH_RSS_IPV6_UDP_EX)
66 : :
67 : : #define GVE_DEV_POLL_INTERVAL_US (1 * 1000 * 1000) /* 1 second in microseconds */
68 : :
69 : : /* A list of pages registered with the device during setup and used by a queue
70 : : * as buffers
71 : : */
72 : : struct gve_queue_page_list {
73 : : uint32_t id; /* unique id */
74 : : uint32_t num_entries;
75 : : dma_addr_t *page_buses; /* the dma addrs of the pages */
76 : : union {
77 : : const struct rte_memzone *mz; /* memzone allocated for TX queue */
78 : : void **qpl_bufs; /* RX qpl-buffer list allocated using malloc*/
79 : : };
80 : : };
81 : :
82 : : /* A TX desc ring entry */
83 : : union gve_tx_desc {
84 : : struct gve_tx_pkt_desc pkt; /* first desc for a packet */
85 : : struct gve_tx_seg_desc seg; /* subsequent descs for a packet */
86 : : };
87 : :
88 : : /* Tx desc for DQO format */
89 : : union gve_tx_desc_dqo {
90 : : struct gve_tx_pkt_desc_dqo pkt;
91 : : struct gve_tx_tso_context_desc_dqo tso_ctx;
92 : : struct gve_tx_general_context_desc_dqo general_ctx;
93 : : };
94 : :
95 : : /* Offload features */
96 : : union gve_tx_offload {
97 : : uint64_t data;
98 : : struct {
99 : : uint64_t l2_len:7; /* L2 (MAC) Header Length. */
100 : : uint64_t l3_len:9; /* L3 (IP) Header Length. */
101 : : uint64_t l4_len:8; /* L4 Header Length. */
102 : : uint64_t tso_segsz:16; /* TCP TSO segment size */
103 : : /* uint64_t unused : 24; */
104 : : };
105 : : };
106 : :
107 : : struct gve_tx_iovec {
108 : : uint32_t iov_base; /* offset in fifo */
109 : : uint32_t iov_len;
110 : : };
111 : :
112 : : struct gve_tx_stats {
113 : : uint64_t packets;
114 : : uint64_t bytes;
115 : : uint64_t errors;
116 : : uint64_t too_many_descs;
117 : : uint64_t invalid_mbufs;
118 : : uint64_t invalid_pkts;
119 : : };
120 : :
121 : : struct gve_rx_stats {
122 : : uint64_t packets;
123 : : uint64_t bytes;
124 : : uint64_t errors;
125 : : uint64_t no_mbufs;
126 : : uint64_t no_mbufs_bulk;
127 : : uint64_t imissed;
128 : : };
129 : :
130 : : struct gve_xstats_name_offset {
131 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
132 : : unsigned int offset;
133 : : };
134 : :
135 : : struct gve_tx_pkt {
136 : : struct rte_mbuf *mbuf;
137 : : int16_t next_avail_pkt; /* Entry in software ring for next free packet slot */
138 : : };
139 : :
140 : : struct gve_tx_queue {
141 : : volatile union gve_tx_desc *tx_desc_ring;
142 : : const struct rte_memzone *mz;
143 : : uint64_t tx_ring_phys_addr;
144 : : union {
145 : : struct rte_mbuf **sw_ring;
146 : : struct gve_tx_pkt *pkt_ring_dqo;
147 : : };
148 : : volatile rte_be32_t *qtx_tail;
149 : : volatile rte_be32_t *qtx_head;
150 : :
151 : : uint32_t tx_tail;
152 : : uint16_t nb_tx_desc;
153 : : uint16_t nb_complq_desc;
154 : : uint16_t nb_free;
155 : : uint16_t nb_used;
156 : : uint32_t next_to_clean;
157 : : uint16_t free_thresh;
158 : : uint16_t rs_thresh;
159 : :
160 : : /* Only valid for DQO_QPL queue format */
161 : : uint16_t sw_tail;
162 : : uint16_t sw_ntc;
163 : : uint16_t sw_nb_free;
164 : : uint32_t fifo_size;
165 : : uint32_t fifo_head;
166 : : uint32_t fifo_avail;
167 : : uint64_t fifo_base;
168 : : struct gve_queue_page_list *qpl;
169 : : struct gve_tx_iovec *iov_ring;
170 : :
171 : : /* stats items */
172 : : struct gve_tx_stats stats;
173 : :
174 : : uint16_t port_id;
175 : : uint16_t queue_id;
176 : :
177 : : uint16_t ntfy_id;
178 : : volatile rte_be32_t *ntfy_addr;
179 : :
180 : : struct gve_priv *hw;
181 : : const struct rte_memzone *qres_mz;
182 : : struct gve_queue_resources *qres;
183 : :
184 : : /* newly added for DQO */
185 : : volatile union gve_tx_desc_dqo *tx_ring;
186 : : struct gve_tx_compl_desc *compl_ring;
187 : :
188 : : /* List of free completion tags that map into sw_ring. */
189 : : int16_t free_compl_tags_head;
190 : : uint16_t num_free_compl_tags;
191 : :
192 : : const struct rte_memzone *compl_ring_mz;
193 : : uint64_t compl_ring_phys_addr;
194 : : uint32_t complq_tail;
195 : : uint16_t sw_size;
196 : : uint8_t cur_gen_bit;
197 : : uint32_t last_desc_cleaned;
198 : : uint16_t last_re_idx;
199 : :
200 : : /* Only valid for DQO_RDA queue format */
201 : : struct gve_tx_queue *complq;
202 : :
203 : : uint8_t is_gqi_qpl;
204 : : };
205 : :
206 : : struct gve_rx_ctx {
207 : : struct rte_mbuf *mbuf_head;
208 : : struct rte_mbuf *mbuf_tail;
209 : : uint16_t total_frags;
210 : : bool drop_pkt;
211 : : };
212 : :
213 : : struct gve_rx_queue {
214 : : volatile struct gve_rx_desc *rx_desc_ring;
215 : : volatile union gve_rx_data_slot *rx_data_ring;
216 : : const struct rte_memzone *mz;
217 : : const struct rte_memzone *data_mz;
218 : : uint64_t rx_ring_phys_addr;
219 : : struct rte_mbuf **sw_ring;
220 : : struct rte_mempool *mpool;
221 : : struct gve_rx_ctx ctx;
222 : :
223 : : uint16_t rx_tail;
224 : : uint16_t nb_rx_desc;
225 : : uint16_t expected_seqno; /* the next expected seqno */
226 : : uint16_t free_thresh;
227 : : uint16_t nb_rx_hold;
228 : : uint32_t next_avail;
229 : : uint32_t nb_avail;
230 : :
231 : : volatile rte_be32_t *qrx_tail;
232 : : volatile rte_be32_t *ntfy_addr;
233 : :
234 : : /* only valid for GQI_QPL queue format */
235 : : struct gve_queue_page_list *qpl;
236 : :
237 : : /* stats items */
238 : : struct gve_rx_stats stats;
239 : :
240 : : struct gve_priv *hw;
241 : : const struct rte_memzone *qres_mz;
242 : : struct gve_queue_resources *qres;
243 : :
244 : : uint16_t port_id;
245 : : uint16_t queue_id;
246 : : uint16_t ntfy_id;
247 : : uint16_t rx_buf_len;
248 : :
249 : : /* newly added for DQO */
250 : : volatile struct gve_rx_desc_dqo *rx_ring;
251 : : struct gve_rx_compl_desc_dqo *compl_ring;
252 : : const struct rte_memzone *compl_ring_mz;
253 : : uint64_t compl_ring_phys_addr;
254 : : uint8_t cur_gen_bit;
255 : : uint16_t bufq_tail;
256 : :
257 : : /* List of buffers which are known to be completed by the hardware. */
258 : : int16_t *completed_buf_list;
259 : : int16_t completed_buf_list_head;
260 : :
261 : : /* Only valid for DQO_RDA queue format */
262 : : struct gve_rx_queue *bufq;
263 : : struct rte_mbuf **refill_bufs;
264 : :
265 : : uint8_t is_gqi_qpl;
266 : : /* the port enabled RTE_ETH_RX_OFFLOAD_SCATTER (GQI) */
267 : : bool scatter;
268 : : bool timestamp_enabled;
269 : : };
270 : :
271 : : struct gve_flow {
272 : : uint32_t rule_id;
273 : : TAILQ_ENTRY(gve_flow) list_handle;
274 : : };
275 : :
276 : : extern const struct rte_flow_ops gve_flow_ops;
277 : :
278 : : struct gve_priv;
279 : : struct gve_flow_rule_params;
280 : :
281 : : enum gve_dev_clk_type {
282 : : GVE_DEV_CLK_UNSUPPORTED = 0,
283 : : GVE_DEV_CLK_CMD,
284 : : };
285 : :
286 : : struct gve_ctrl_ops {
287 : : int (*init_ctrl_plane)(struct gve_priv *priv);
288 : : void (*free_ctrl_plane)(struct gve_priv *priv);
289 : : int (*get_device_properties)(struct gve_priv *priv);
290 : : int (*get_ptype_map)(struct gve_priv *priv);
291 : : int (*get_interrupt_dbs)(struct gve_priv *priv);
292 : : int (*create_tx_queues)(struct gve_priv *priv, uint32_t num_queues);
293 : : int (*destroy_tx_queues)(struct gve_priv *priv, uint32_t num_queues);
294 : : int (*create_rx_queues)(struct gve_priv *priv, uint32_t num_queues);
295 : : int (*destroy_rx_queues)(struct gve_priv *priv, uint32_t num_queues);
296 : : int (*report_link_speed)(struct gve_priv *priv);
297 : : int (*configure_rss)(struct gve_priv *priv,
298 : : struct gve_rss_config *rss_conf);
299 : : int (*add_flow_rule)(struct gve_priv *priv,
300 : : struct gve_flow_rule_params *rule, uint32_t loc);
301 : : int (*del_flow_rule)(struct gve_priv *priv, uint32_t loc);
302 : : int (*reset_flow_rules)(struct gve_priv *priv);
303 : : int (*free_db_resources)(struct gve_priv *priv);
304 : : int (*setup_stats_report)(struct gve_priv *priv,
305 : : uint64_t stats_report_len,
306 : : dma_addr_t stats_report_addr,
307 : : uint64_t interval_ms);
308 : : int (*report_nic_timestamp)(struct gve_priv *priv, dma_addr_t dma_addr);
309 : : int (*set_mtu)(struct gve_priv *priv, uint64_t mtu);
310 : : int (*register_page_list)(struct gve_priv *priv,
311 : : struct gve_queue_page_list *qpl);
312 : : int (*unregister_page_list)(struct gve_priv *priv,
313 : : uint32_t page_list_id);
314 : :
315 : : /* Optional, may be NULL. Callers must check before use. */
316 : : int (*query_rss)(struct gve_priv *priv);
317 : : };
318 : :
319 : : struct gve_process_private {
320 : : const struct gve_ctrl_ops *ctrl_ops;
321 : : };
322 : :
323 : : struct gve_priv {
324 : : struct gve_irq_db *irq_dbs; /* array of num_ntfy_blks */
325 : : const struct rte_memzone *irq_dbs_mz;
326 : : uint32_t mgmt_msix_idx;
327 : : rte_be32_t *cnt_array; /* array of num_event_counters */
328 : : const struct rte_memzone *cnt_array_mz;
329 : :
330 : : uint16_t num_event_counters;
331 : :
332 : : /* TX ring size default and limits. */
333 : : uint16_t default_tx_desc_cnt;
334 : : uint16_t max_tx_desc_cnt;
335 : : uint16_t min_tx_desc_cnt;
336 : :
337 : : /* RX ring size default and limits. */
338 : : uint16_t default_rx_desc_cnt;
339 : : uint16_t max_rx_desc_cnt;
340 : : uint16_t min_rx_desc_cnt;
341 : :
342 : : uint16_t tx_pages_per_qpl;
343 : :
344 : : /* Only valid for DQO_RDA queue format */
345 : : uint16_t tx_compq_size; /* tx completion queue size */
346 : : uint16_t rx_bufq_size; /* rx buff queue size */
347 : :
348 : : uint64_t max_registered_pages;
349 : : uint64_t num_registered_pages; /* num pages registered with NIC */
350 : : uint16_t default_tx_num_queues; /* default num tx queues to set up */
351 : : uint16_t default_rx_num_queues; /* default num rx queues to set up */
352 : : enum gve_queue_format queue_format; /* see enum gve_queue_format */
353 : : uint8_t enable_rsc;
354 : :
355 : : uint16_t max_nb_txq;
356 : : uint16_t max_nb_rxq;
357 : : uint32_t num_ntfy_blks; /* spilt between TX and RX so must be even */
358 : :
359 : : struct gve_registers __iomem *reg_bar0; /* see gve_register.h */
360 : : rte_be32_t __iomem *db_bar; /* "array" of doorbells */
361 : : struct rte_pci_device *pci_dev;
362 : : uint16_t port_id;
363 : :
364 : : /* Admin queue - see gve_adminq.h*/
365 : : union gve_adminq_command *adminq;
366 : : struct gve_dma_mem adminq_dma_mem;
367 : : uint32_t adminq_mask; /* masks prod_cnt to adminq size */
368 : : uint32_t adminq_prod_cnt; /* free-running count of AQ cmds executed */
369 : : uint32_t adminq_cmd_fail; /* free-running count of AQ cmds failed */
370 : : uint32_t adminq_timeouts; /* free-running count of AQ cmds timeouts */
371 : : /* free-running count of per AQ cmd executed */
372 : : uint32_t adminq_describe_device_cnt;
373 : : uint32_t adminq_cfg_device_resources_cnt;
374 : : uint32_t adminq_register_page_list_cnt;
375 : : uint32_t adminq_unregister_page_list_cnt;
376 : : uint32_t adminq_create_tx_queue_cnt;
377 : : uint32_t adminq_create_rx_queue_cnt;
378 : : uint32_t adminq_destroy_tx_queue_cnt;
379 : : uint32_t adminq_destroy_rx_queue_cnt;
380 : : uint32_t adminq_dcfg_device_resources_cnt;
381 : : uint32_t adminq_cfg_rss_cnt;
382 : : uint32_t adminq_set_driver_parameter_cnt;
383 : : uint32_t adminq_report_stats_cnt;
384 : : uint32_t adminq_report_link_speed_cnt;
385 : : uint32_t adminq_get_ptype_map_cnt;
386 : : uint32_t adminq_verify_driver_compatibility_cnt;
387 : : uint32_t adminq_cfg_flow_rule_cnt;
388 : : uint32_t adminq_report_nic_timestamp_cnt;
389 : : volatile uint32_t state_flags;
390 : :
391 : : /* Gvnic device link speed from hypervisor. */
392 : : uint64_t link_speed;
393 : :
394 : : uint16_t max_mtu;
395 : : struct rte_ether_addr dev_addr; /* mac address */
396 : :
397 : : struct gve_tx_queue **txqs;
398 : : struct gve_rx_queue **rxqs;
399 : :
400 : : pthread_mutex_t adminq_lock; /* Protects AdminQ command execution */
401 : : uint32_t stats_report_len;
402 : : const struct rte_memzone *stats_report_mem;
403 : : uint16_t stats_start_idx; /* start index of array of stats written by NIC */
404 : : uint16_t stats_end_idx; /* end index of array of stats written by NIC */
405 : :
406 : : struct gve_rss_config rss_config;
407 : : bool rss_cache_dirty;
408 : : struct gve_ptype_lut *ptype_lut_dqo;
409 : :
410 : : /* Flow rule management */
411 : : uint32_t max_flow_rules;
412 : : uint32_t flow_rule_bmp_size;
413 : : struct rte_bitmap *avail_flow_rule_bmp; /* Tracks available rule IDs (1 = available) */
414 : : void *avail_flow_rule_bmp_mem; /* Backing memory for the bitmap */
415 : : pthread_mutex_t flow_rule_lock; /* Lock for bitmap and tailq access */
416 : : TAILQ_HEAD(, gve_flow) active_flows;
417 : :
418 : : /* HW Timestamping Fields */
419 : : enum gve_dev_clk_type clk_read_type;
420 : : const struct rte_memzone *nic_ts_report_mz;
421 : : struct gve_nic_ts_report *nic_ts_report;
422 : : pthread_mutex_t nic_ts_lock;
423 : : RTE_ATOMIC(uint64_t) last_read_nic_timestamp;
424 : : RTE_ATOMIC(uint32_t) nic_ts_read_fails;
425 : : RTE_ATOMIC(uint8_t) nic_ts_stale;
426 : : rte_thread_t nic_ts_thread_id;
427 : : RTE_ATOMIC(uint8_t) nic_ts_thread_should_stop;
428 : :
429 : : int mbuf_timestamp_offset;
430 : : uint64_t mbuf_timestamp_mask;
431 : : };
432 : :
433 : : /* Expand the hardware timestamp to the full 64 bits of width.
434 : : *
435 : : * This algorithm works by using the passed hardware timestamp to generate a
436 : : * diff relative to the last read of the nic clock. This diff can be positive or
437 : : * negative, as it is possible that we have read the clock more recently than
438 : : * the hardware has received this packet. To detect this, we use the high bit of
439 : : * the diff, and assume that the read is more recent if the high bit is set. In
440 : : * this case we invert the process.
441 : : *
442 : : * Note that this means if the time delta between packet reception and the last
443 : : * clock read is greater than ~2 seconds, this will provide invalid results.
444 : : */
445 : : static inline uint64_t
446 : : gve_reconstruct_ts(uint64_t last_sync, uint32_t ts)
447 : : {
448 : 0 : uint32_t low = (uint32_t)last_sync;
449 : 0 : int32_t diff = (int32_t)(ts - low);
450 : :
451 : 0 : return last_sync + diff;
452 : : }
453 : :
454 : : static inline bool
455 : : gve_is_gqi(struct gve_priv *priv)
456 : : {
457 [ # # # # : 0 : return priv->queue_format == GVE_GQI_RDA_FORMAT ||
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
458 : : priv->queue_format == GVE_GQI_QPL_FORMAT;
459 : : }
460 : :
461 : : /* GQI places GVE_RX_PAD bytes ahead of the frame in its first Rx buffer
462 : : * and chains the rest of a larger frame into further buffers.
463 : : */
464 : : static inline bool
465 : : gve_rx_gqi_needs_scatter(uint16_t mtu, uint16_t rx_buf_len)
466 : : {
467 [ # # ]: 0 : return (uint32_t)mtu + RTE_ETHER_HDR_LEN + GVE_RX_PAD > rx_buf_len;
468 : : }
469 : :
470 : : static inline bool
471 : : gve_get_admin_queue_ok(struct gve_priv *priv)
472 : : {
473 : : return !!rte_bit_relaxed_get32(GVE_PRIV_FLAGS_ADMIN_QUEUE_OK,
474 : : &priv->state_flags);
475 : : }
476 : :
477 : : static inline void
478 : : gve_set_admin_queue_ok(struct gve_priv *priv)
479 : : {
480 : : rte_bit_relaxed_set32(GVE_PRIV_FLAGS_ADMIN_QUEUE_OK,
481 : : &priv->state_flags);
482 : : }
483 : :
484 : : static inline void
485 : : gve_clear_admin_queue_ok(struct gve_priv *priv)
486 : : {
487 : : rte_bit_relaxed_clear32(GVE_PRIV_FLAGS_ADMIN_QUEUE_OK,
488 : : &priv->state_flags);
489 : 0 : }
490 : :
491 : : static inline bool
492 : : gve_get_device_resources_ok(struct gve_priv *priv)
493 : : {
494 : : return !!rte_bit_relaxed_get32(GVE_PRIV_FLAGS_DEVICE_RESOURCES_OK,
495 : : &priv->state_flags);
496 : : }
497 : :
498 : : static inline void
499 : : gve_set_device_resources_ok(struct gve_priv *priv)
500 : : {
501 : : rte_bit_relaxed_set32(GVE_PRIV_FLAGS_DEVICE_RESOURCES_OK,
502 : : &priv->state_flags);
503 : : }
504 : :
505 : : static inline void
506 : : gve_clear_device_resources_ok(struct gve_priv *priv)
507 : : {
508 : : rte_bit_relaxed_clear32(GVE_PRIV_FLAGS_DEVICE_RESOURCES_OK,
509 : : &priv->state_flags);
510 : : }
511 : :
512 : : static inline bool
513 : : gve_get_device_rings_ok(struct gve_priv *priv)
514 : : {
515 : : return !!rte_bit_relaxed_get32(GVE_PRIV_FLAGS_DEVICE_RINGS_OK,
516 : : &priv->state_flags);
517 : : }
518 : :
519 : : static inline void
520 : : gve_set_device_rings_ok(struct gve_priv *priv)
521 : : {
522 : : rte_bit_relaxed_set32(GVE_PRIV_FLAGS_DEVICE_RINGS_OK,
523 : : &priv->state_flags);
524 : : }
525 : :
526 : : static inline void
527 : : gve_clear_device_rings_ok(struct gve_priv *priv)
528 : : {
529 : : rte_bit_relaxed_clear32(GVE_PRIV_FLAGS_DEVICE_RINGS_OK,
530 : : &priv->state_flags);
531 : : }
532 : :
533 : : static inline bool
534 : : gve_get_flow_subsystem_ok(struct gve_priv *priv)
535 : : {
536 : : bool ret;
537 : :
538 : : ret = !!rte_bit_relaxed_get32(GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK,
539 : : &priv->state_flags);
540 : : rte_atomic_thread_fence(rte_memory_order_acquire);
541 : :
542 : : return ret;
543 : : }
544 : :
545 : : static inline void
546 : : gve_set_flow_subsystem_ok(struct gve_priv *priv)
547 : : {
548 : : rte_atomic_thread_fence(rte_memory_order_release);
549 : : rte_bit_relaxed_set32(GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK,
550 : : &priv->state_flags);
551 : : }
552 : :
553 : : static inline void
554 : : gve_clear_flow_subsystem_ok(struct gve_priv *priv)
555 : : {
556 : : rte_atomic_thread_fence(rte_memory_order_release);
557 : : rte_bit_relaxed_clear32(GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK,
558 : : &priv->state_flags);
559 : : }
560 : :
561 : : int
562 : : gve_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id, uint16_t nb_desc,
563 : : unsigned int socket_id, const struct rte_eth_rxconf *conf,
564 : : struct rte_mempool *pool);
565 : : int
566 : : gve_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id, uint16_t nb_desc,
567 : : unsigned int socket_id, const struct rte_eth_txconf *conf);
568 : :
569 : : void
570 : : gve_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
571 : :
572 : : void
573 : : gve_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
574 : :
575 : : int
576 : : gve_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
577 : :
578 : : int
579 : : gve_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
580 : :
581 : : int
582 : : gve_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
583 : :
584 : : int
585 : : gve_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
586 : :
587 : : void
588 : : gve_stop_tx_queues(struct rte_eth_dev *dev);
589 : :
590 : : void
591 : : gve_stop_rx_queues(struct rte_eth_dev *dev);
592 : :
593 : : uint16_t
594 : : gve_rx_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
595 : :
596 : : uint16_t
597 : : gve_tx_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
598 : :
599 : : void
600 : : gve_set_rx_function(struct rte_eth_dev *dev);
601 : :
602 : : void
603 : : gve_set_tx_function(struct rte_eth_dev *dev);
604 : :
605 : : struct gve_queue_page_list *
606 : : gve_setup_queue_page_list(struct gve_priv *priv, uint16_t queue_id, bool is_rx,
607 : : uint32_t num_pages);
608 : : int
609 : : gve_teardown_queue_page_list(struct gve_priv *priv,
610 : : struct gve_queue_page_list *qpl);
611 : :
612 : : /* Below functions are used for DQO */
613 : :
614 : : int
615 : : gve_rx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id,
616 : : uint16_t nb_desc, unsigned int socket_id,
617 : : const struct rte_eth_rxconf *conf,
618 : : struct rte_mempool *pool);
619 : : int
620 : : gve_tx_queue_setup_dqo(struct rte_eth_dev *dev, uint16_t queue_id,
621 : : uint16_t nb_desc, unsigned int socket_id,
622 : : const struct rte_eth_txconf *conf);
623 : :
624 : : void
625 : : gve_tx_queue_release_dqo(struct rte_eth_dev *dev, uint16_t qid);
626 : :
627 : : void
628 : : gve_rx_queue_release_dqo(struct rte_eth_dev *dev, uint16_t qid);
629 : :
630 : : int
631 : : gve_rx_queue_start_dqo(struct rte_eth_dev *dev, uint16_t rx_queue_id);
632 : :
633 : : int
634 : : gve_tx_queue_start_dqo(struct rte_eth_dev *dev, uint16_t tx_queue_id);
635 : :
636 : : int
637 : : gve_rx_queue_stop_dqo(struct rte_eth_dev *dev, uint16_t rx_queue_id);
638 : :
639 : : int
640 : : gve_tx_queue_stop_dqo(struct rte_eth_dev *dev, uint16_t tx_queue_id);
641 : :
642 : : void
643 : : gve_stop_tx_queues_dqo(struct rte_eth_dev *dev);
644 : :
645 : : void
646 : : gve_stop_rx_queues_dqo(struct rte_eth_dev *dev);
647 : :
648 : : uint16_t
649 : : gve_rx_burst_dqo(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
650 : :
651 : : uint16_t
652 : : gve_tx_burst_dqo(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
653 : :
654 : : uint16_t
655 : : gve_tx_pkt_prepare_dqo(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
656 : :
657 : : void
658 : : gve_set_rx_function_dqo(struct rte_eth_dev *dev);
659 : :
660 : : void
661 : : gve_set_tx_function_dqo(struct rte_eth_dev *dev);
662 : :
663 : : #endif /* _GVE_ETHDEV_H_ */
|