4 * Copyright (c) 2016 Solarflare Communications Inc.
7 * This software was jointly developed between OKTET Labs (under contract
8 * for Solarflare) and Solarflare Communications, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <rte_ethdev.h>
44 * Generic transmit queue information used on data path.
45 * It must be kept as small as it is possible since it is built into
46 * the structure used on datapath.
49 struct sfc_dp_queue dpq;
53 * Datapath transmit queue creation information.
55 * The structure is used just to pass information from control path to
56 * datapath. It could be just function arguments, but it would be hardly
59 struct sfc_dp_tx_qcreate_info {
60 /** Maximum number of pushed Tx descriptors */
61 unsigned int max_fill_level;
62 /** Minimum number of unused Tx descriptors to do reap */
63 unsigned int free_thresh;
64 /** Transmit queue configuration flags */
67 unsigned int txq_entries;
68 /** Maximum size of data in the DMA descriptor */
69 uint16_t dma_desc_size_max;
70 /** DMA-mapped Tx descriptors ring */
72 /** Associated event queue size */
73 unsigned int evq_entries;
74 /** Hardware event ring */
76 /** The queue index in hardware (required to push right doorbell) */
77 unsigned int hw_index;
78 /** Virtual address of the memory-mapped BAR to push Tx doorbell */
79 volatile void *mem_bar;
83 * Get size of transmit and event queue rings by the number of Tx
86 * @param nb_tx_desc Number of Tx descriptors
87 * @param txq_entries Location for number of Tx ring entries
88 * @param evq_entries Location for number of event ring entries
89 * @param txq_max_fill_level Location for maximum Tx ring fill level
91 * @return 0 or positive errno.
93 typedef int (sfc_dp_tx_qsize_up_rings_t)(uint16_t nb_tx_desc,
94 unsigned int *txq_entries,
95 unsigned int *evq_entries,
96 unsigned int *txq_max_fill_level);
99 * Allocate and initialize datapath transmit queue.
101 * @param port_id The port identifier
102 * @param queue_id The queue identifier
103 * @param pci_addr PCI function address
104 * @param socket_id Socket identifier to allocate memory
105 * @param info Tx queue details wrapped in structure
106 * @param dp_txqp Location for generic datapath transmit queue pointer
108 * @return 0 or positive errno.
110 typedef int (sfc_dp_tx_qcreate_t)(uint16_t port_id, uint16_t queue_id,
111 const struct rte_pci_addr *pci_addr,
113 const struct sfc_dp_tx_qcreate_info *info,
114 struct sfc_dp_txq **dp_txqp);
117 * Free resources allocated for datapath transmit queue.
119 typedef void (sfc_dp_tx_qdestroy_t)(struct sfc_dp_txq *dp_txq);
122 * Transmit queue start callback.
124 * It handovers EvQ to the datapath.
126 typedef int (sfc_dp_tx_qstart_t)(struct sfc_dp_txq *dp_txq,
127 unsigned int evq_read_ptr,
128 unsigned int txq_desc_index);
131 * Transmit queue stop function called before the queue flush.
133 * It returns EvQ to the control path.
135 typedef void (sfc_dp_tx_qstop_t)(struct sfc_dp_txq *dp_txq,
136 unsigned int *evq_read_ptr);
139 * Transmit event handler used during queue flush only.
141 typedef bool (sfc_dp_tx_qtx_ev_t)(struct sfc_dp_txq *dp_txq, unsigned int id);
144 * Transmit queue function called after the queue flush.
146 typedef void (sfc_dp_tx_qreap_t)(struct sfc_dp_txq *dp_txq);
149 * Check Tx descriptor status
151 typedef int (sfc_dp_tx_qdesc_status_t)(struct sfc_dp_txq *dp_txq,
154 /** Transmit datapath definition */
158 unsigned int features;
159 #define SFC_DP_TX_FEAT_VLAN_INSERT 0x1
160 #define SFC_DP_TX_FEAT_TSO 0x2
161 #define SFC_DP_TX_FEAT_MULTI_SEG 0x4
162 #define SFC_DP_TX_FEAT_MULTI_PROCESS 0x8
163 #define SFC_DP_TX_FEAT_MULTI_POOL 0x10
164 #define SFC_DP_TX_FEAT_REFCNT 0x20
165 sfc_dp_tx_qsize_up_rings_t *qsize_up_rings;
166 sfc_dp_tx_qcreate_t *qcreate;
167 sfc_dp_tx_qdestroy_t *qdestroy;
168 sfc_dp_tx_qstart_t *qstart;
169 sfc_dp_tx_qstop_t *qstop;
170 sfc_dp_tx_qtx_ev_t *qtx_ev;
171 sfc_dp_tx_qreap_t *qreap;
172 sfc_dp_tx_qdesc_status_t *qdesc_status;
173 eth_tx_burst_t pkt_burst;
176 static inline struct sfc_dp_tx *
177 sfc_dp_find_tx_by_name(struct sfc_dp_list *head, const char *name)
179 struct sfc_dp *p = sfc_dp_find_by_name(head, SFC_DP_TX, name);
181 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
184 static inline struct sfc_dp_tx *
185 sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps)
187 struct sfc_dp *p = sfc_dp_find_by_caps(head, SFC_DP_TX, avail_caps);
189 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
192 extern struct sfc_dp_tx sfc_efx_tx;
193 extern struct sfc_dp_tx sfc_ef10_tx;
194 extern struct sfc_dp_tx sfc_ef10_simple_tx;
199 #endif /* _SFC_DP_TX_H */