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 /** Minimum number of unused Tx descriptors to do reap */
61 unsigned int free_thresh;
62 /** Transmit queue configuration flags */
65 unsigned int txq_entries;
66 /** Maximum size of data in the DMA descriptor */
67 uint16_t dma_desc_size_max;
68 /** DMA-mapped Tx descriptors ring */
70 /** Associated event queue size */
71 unsigned int evq_entries;
72 /** Hardware event ring */
74 /** The queue index in hardware (required to push right doorbell) */
75 unsigned int hw_index;
76 /** Virtual address of the memory-mapped BAR to push Tx doorbell */
77 volatile void *mem_bar;
81 * Allocate and initialize datapath transmit queue.
83 * @param port_id The port identifier
84 * @param queue_id The queue identifier
85 * @param pci_addr PCI function address
86 * @param socket_id Socket identifier to allocate memory
87 * @param info Tx queue details wrapped in structure
88 * @param dp_txqp Location for generic datapath transmit queue pointer
90 * @return 0 or positive errno.
92 typedef int (sfc_dp_tx_qcreate_t)(uint16_t port_id, uint16_t queue_id,
93 const struct rte_pci_addr *pci_addr,
95 const struct sfc_dp_tx_qcreate_info *info,
96 struct sfc_dp_txq **dp_txqp);
99 * Free resources allocated for datapath transmit queue.
101 typedef void (sfc_dp_tx_qdestroy_t)(struct sfc_dp_txq *dp_txq);
104 * Transmit queue start callback.
106 * It handovers EvQ to the datapath.
108 typedef int (sfc_dp_tx_qstart_t)(struct sfc_dp_txq *dp_txq,
109 unsigned int evq_read_ptr,
110 unsigned int txq_desc_index);
113 * Transmit queue stop function called before the queue flush.
115 * It returns EvQ to the control path.
117 typedef void (sfc_dp_tx_qstop_t)(struct sfc_dp_txq *dp_txq,
118 unsigned int *evq_read_ptr);
121 * Transmit event handler used during queue flush only.
123 typedef bool (sfc_dp_tx_qtx_ev_t)(struct sfc_dp_txq *dp_txq, unsigned int id);
126 * Transmit queue function called after the queue flush.
128 typedef void (sfc_dp_tx_qreap_t)(struct sfc_dp_txq *dp_txq);
131 * Check Tx descriptor status
133 typedef int (sfc_dp_tx_qdesc_status_t)(struct sfc_dp_txq *dp_txq,
136 /** Transmit datapath definition */
140 unsigned int features;
141 #define SFC_DP_TX_FEAT_VLAN_INSERT 0x1
142 #define SFC_DP_TX_FEAT_TSO 0x2
143 #define SFC_DP_TX_FEAT_MULTI_SEG 0x4
144 #define SFC_DP_TX_FEAT_MULTI_PROCESS 0x8
145 #define SFC_DP_TX_FEAT_MULTI_POOL 0x10
146 #define SFC_DP_TX_FEAT_REFCNT 0x20
147 sfc_dp_tx_qcreate_t *qcreate;
148 sfc_dp_tx_qdestroy_t *qdestroy;
149 sfc_dp_tx_qstart_t *qstart;
150 sfc_dp_tx_qstop_t *qstop;
151 sfc_dp_tx_qtx_ev_t *qtx_ev;
152 sfc_dp_tx_qreap_t *qreap;
153 sfc_dp_tx_qdesc_status_t *qdesc_status;
154 eth_tx_burst_t pkt_burst;
157 static inline struct sfc_dp_tx *
158 sfc_dp_find_tx_by_name(struct sfc_dp_list *head, const char *name)
160 struct sfc_dp *p = sfc_dp_find_by_name(head, SFC_DP_TX, name);
162 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
165 static inline struct sfc_dp_tx *
166 sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps)
168 struct sfc_dp *p = sfc_dp_find_by_caps(head, SFC_DP_TX, avail_caps);
170 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
173 extern struct sfc_dp_tx sfc_efx_tx;
174 extern struct sfc_dp_tx sfc_ef10_tx;
175 extern struct sfc_dp_tx sfc_ef10_simple_tx;
180 #endif /* _SFC_DP_TX_H */