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;
71 * Allocate and initialize datapath transmit queue.
73 * @param port_id The port identifier
74 * @param queue_id The queue identifier
75 * @param pci_addr PCI function address
76 * @param socket_id Socket identifier to allocate memory
77 * @param info Tx queue details wrapped in structure
78 * @param dp_txqp Location for generic datapath transmit queue pointer
80 * @return 0 or positive errno.
82 typedef int (sfc_dp_tx_qcreate_t)(uint16_t port_id, uint16_t queue_id,
83 const struct rte_pci_addr *pci_addr,
85 const struct sfc_dp_tx_qcreate_info *info,
86 struct sfc_dp_txq **dp_txqp);
89 * Free resources allocated for datapath transmit queue.
91 typedef void (sfc_dp_tx_qdestroy_t)(struct sfc_dp_txq *dp_txq);
94 * Transmit queue start callback.
96 * It handovers EvQ to the datapath.
98 typedef int (sfc_dp_tx_qstart_t)(struct sfc_dp_txq *dp_txq,
99 unsigned int evq_read_ptr,
100 unsigned int txq_desc_index);
103 * Transmit queue stop function called before the queue flush.
105 * It returns EvQ to the control path.
107 typedef void (sfc_dp_tx_qstop_t)(struct sfc_dp_txq *dp_txq,
108 unsigned int *evq_read_ptr);
111 * Transmit queue function called after the queue flush.
113 typedef void (sfc_dp_tx_qreap_t)(struct sfc_dp_txq *dp_txq);
115 /** Transmit datapath definition */
119 sfc_dp_tx_qcreate_t *qcreate;
120 sfc_dp_tx_qdestroy_t *qdestroy;
121 sfc_dp_tx_qstart_t *qstart;
122 sfc_dp_tx_qstop_t *qstop;
123 sfc_dp_tx_qreap_t *qreap;
124 eth_tx_burst_t pkt_burst;
127 static inline struct sfc_dp_tx *
128 sfc_dp_find_tx_by_name(struct sfc_dp_list *head, const char *name)
130 struct sfc_dp *p = sfc_dp_find_by_name(head, SFC_DP_TX, name);
132 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
135 static inline struct sfc_dp_tx *
136 sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps)
138 struct sfc_dp *p = sfc_dp_find_by_caps(head, SFC_DP_TX, avail_caps);
140 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
143 extern struct sfc_dp_tx sfc_efx_tx;
148 #endif /* _SFC_DP_TX_H */