xref: /dpdk/drivers/net/sfc/sfc_tx.h (revision 68a03efeed657e6e05f281479b33b51102797e15)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019-2021 Xilinx, Inc.
4  * Copyright(c) 2016-2019 Solarflare Communications Inc.
5  *
6  * This software was jointly developed between OKTET Labs (under contract
7  * for Solarflare) and Solarflare Communications, Inc.
8  */
9 
10 #ifndef _SFC_TX_H
11 #define _SFC_TX_H
12 
13 #include <rte_mbuf.h>
14 #include <ethdev_driver.h>
15 
16 #include "efx.h"
17 
18 #include "sfc_dp_tx.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 struct sfc_adapter;
25 struct sfc_evq;
26 
27 /**
28  * Software Tx descriptor information associated with hardware Tx
29  * descriptor.
30  */
31 struct sfc_efx_tx_sw_desc {
32 	struct rte_mbuf		*mbuf;
33 	uint8_t			*tsoh;	/* Buffer to store TSO header */
34 };
35 
36 enum sfc_txq_state_bit {
37 	SFC_TXQ_INITIALIZED_BIT = 0,
38 #define SFC_TXQ_INITIALIZED	(1 << SFC_TXQ_INITIALIZED_BIT)
39 	SFC_TXQ_STARTED_BIT,
40 #define SFC_TXQ_STARTED		(1 << SFC_TXQ_STARTED_BIT)
41 	SFC_TXQ_FLUSHING_BIT,
42 #define SFC_TXQ_FLUSHING	(1 << SFC_TXQ_FLUSHING_BIT)
43 	SFC_TXQ_FLUSHED_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)
47 };
48 
49 /**
50  * Transmit queue control primary process-only information.
51  * Not used on datapath.
52  */
53 struct sfc_txq {
54 	unsigned int			hw_index;
55 	struct sfc_evq			*evq;
56 	efsys_mem_t			mem;
57 	efx_txq_t			*common;
58 };
59 
60 struct sfc_txq *sfc_txq_by_dp_txq(const struct sfc_dp_txq *dp_txq);
61 
62 /**
63  * Transmit queue information used on libefx-based data path.
64  * Allocated on the socket specified on the queue setup.
65  */
66 struct sfc_efx_txq {
67 	struct sfc_evq			*evq;
68 	struct sfc_efx_tx_sw_desc	*sw_ring;
69 	unsigned int			ptr_mask;
70 	efx_desc_t			*pend_desc;
71 	efx_txq_t			*common;
72 	unsigned int			added;
73 	unsigned int			pending;
74 	unsigned int			completed;
75 	unsigned int			max_fill_level;
76 	unsigned int			free_thresh;
77 	uint16_t			hw_vlan_tci;
78 	uint16_t			dma_desc_size_max;
79 
80 	unsigned int			hw_index;
81 	unsigned int			flags;
82 #define SFC_EFX_TXQ_FLAG_STARTED	0x1
83 #define SFC_EFX_TXQ_FLAG_RUNNING	0x2
84 
85 	/* Datapath transmit queue anchor */
86 	struct sfc_dp_txq		dp;
87 };
88 
89 static inline struct sfc_efx_txq *
90 sfc_efx_txq_by_dp_txq(struct sfc_dp_txq *dp_txq)
91 {
92 	return container_of(dp_txq, struct sfc_efx_txq, dp);
93 }
94 
95 struct sfc_txq_info {
96 	unsigned int		state;
97 	unsigned int		entries;
98 	struct sfc_dp_txq	*dp;
99 	boolean_t		deferred_start;
100 	boolean_t		deferred_started;
101 	unsigned int		free_thresh;
102 	uint64_t		offloads;
103 };
104 
105 struct sfc_txq_info *sfc_txq_info_by_dp_txq(const struct sfc_dp_txq *dp_txq);
106 
107 int sfc_tx_configure(struct sfc_adapter *sa);
108 void sfc_tx_close(struct sfc_adapter *sa);
109 
110 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
111 		 uint16_t nb_tx_desc, unsigned int socket_id,
112 		 const struct rte_eth_txconf *tx_conf);
113 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
114 
115 void sfc_tx_qflush_done(struct sfc_txq_info *txq_info);
116 int sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
117 void sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
118 int sfc_tx_start(struct sfc_adapter *sa);
119 void sfc_tx_stop(struct sfc_adapter *sa);
120 
121 uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
122 uint64_t sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa);
123 
124 /* From 'sfc_tso.c' */
125 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
126 				unsigned int txq_entries,
127 				unsigned int socket_id);
128 void sfc_efx_tso_free_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
129 				unsigned int txq_entries);
130 int sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx,
131 		   struct rte_mbuf **in_seg, size_t *in_off, efx_desc_t **pend,
132 		   unsigned int *pkt_descs, size_t *pkt_len);
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 #endif	/* _SFC_TX_H */
138