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_ethdev_driver.h>
18 #include "sfc_dp_tx.h"
28 * Software Tx descriptor information associated with hardware Tx
31 struct sfc_efx_tx_sw_desc {
32 struct rte_mbuf *mbuf;
33 uint8_t *tsoh; /* Buffer to store TSO header */
36 enum sfc_txq_state_bit {
37 SFC_TXQ_INITIALIZED_BIT = 0,
38 #define SFC_TXQ_INITIALIZED (1 << SFC_TXQ_INITIALIZED_BIT)
40 #define SFC_TXQ_STARTED (1 << SFC_TXQ_STARTED_BIT)
42 #define SFC_TXQ_FLUSHING (1 << SFC_TXQ_FLUSHING_BIT)
44 #define SFC_TXQ_FLUSHED (1 << SFC_TXQ_FLUSHED_BIT)
45 SFC_TXQ_FLUSH_FAILED_BIT,
46 #define SFC_TXQ_FLUSH_FAILED (1 << SFC_TXQ_FLUSH_FAILED_BIT)
50 * Transmit queue control information. Not used on datapath.
51 * Allocated on the socket specified on the queue setup.
55 unsigned int hw_index;
58 struct sfc_dp_txq *dp;
60 unsigned int free_thresh;
65 static inline unsigned int
66 sfc_txq_sw_index_by_hw_index(unsigned int hw_index)
71 static inline unsigned int
72 sfc_txq_sw_index(const struct sfc_txq *txq)
74 return sfc_txq_sw_index_by_hw_index(txq->hw_index);
77 struct sfc_txq *sfc_txq_by_dp_txq(const struct sfc_dp_txq *dp_txq);
80 * Transmit queue information used on libefx-based data path.
81 * Allocated on the socket specified on the queue setup.
85 struct sfc_efx_tx_sw_desc *sw_ring;
86 unsigned int ptr_mask;
87 efx_desc_t *pend_desc;
91 unsigned int completed;
92 unsigned int max_fill_level;
93 unsigned int free_thresh;
95 uint16_t dma_desc_size_max;
97 unsigned int hw_index;
99 #define SFC_EFX_TXQ_FLAG_STARTED 0x1
100 #define SFC_EFX_TXQ_FLAG_RUNNING 0x2
102 /* Datapath transmit queue anchor */
103 struct sfc_dp_txq dp;
106 static inline struct sfc_efx_txq *
107 sfc_efx_txq_by_dp_txq(struct sfc_dp_txq *dp_txq)
109 return container_of(dp_txq, struct sfc_efx_txq, dp);
112 struct sfc_txq_info {
113 unsigned int entries;
115 boolean_t deferred_start;
116 boolean_t deferred_started;
119 int sfc_tx_configure(struct sfc_adapter *sa);
120 void sfc_tx_close(struct sfc_adapter *sa);
122 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
123 uint16_t nb_tx_desc, unsigned int socket_id,
124 const struct rte_eth_txconf *tx_conf);
125 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
127 void sfc_tx_qflush_done(struct sfc_txq *txq);
128 int sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
129 void sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
130 int sfc_tx_start(struct sfc_adapter *sa);
131 void sfc_tx_stop(struct sfc_adapter *sa);
133 uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
134 uint64_t sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa);
136 /* From 'sfc_tso.c' */
137 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
138 unsigned int txq_entries,
139 unsigned int socket_id);
140 void sfc_efx_tso_free_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
141 unsigned int txq_entries);
142 int sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx,
143 struct rte_mbuf **in_seg, size_t *in_off, efx_desc_t **pend,
144 unsigned int *pkt_descs, size_t *pkt_len);
149 #endif /* _SFC_TX_H */