4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
35 #define __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
40 #include <rte_sched.h>
41 #include <rte_ethdev.h>
42 #include <rte_tm_driver.h>
44 #include "rte_eth_softnic.h"
51 PMD_FEATURE_TM = 1, /**< Traffic Management (TM) */
59 /** Parameters for the soft device (to be created) */
61 const char *name; /**< Name */
62 uint32_t flags; /**< Flags */
64 /** 0 = Access hard device though API only (potentially slower,
66 * 1 = Access hard device private data structures is allowed
67 * (potentially faster).
71 /** Traffic Management (TM) */
73 uint32_t rate; /**< Rate (bytes/second) */
74 uint32_t nb_queues; /**< Number of queues */
75 uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
76 /**< Queue size per traffic class */
77 uint32_t enq_bsz; /**< Enqueue burst size */
78 uint32_t deq_bsz; /**< Dequeue burst size */
82 /** Parameters for the hard device (existing) */
84 char *name; /**< Name */
85 uint16_t tx_queue_id; /**< TX queue ID */
93 #ifndef DEFAULT_BURST_SIZE
94 #define DEFAULT_BURST_SIZE 32
97 #ifndef FLUSH_COUNT_THRESHOLD
98 #define FLUSH_COUNT_THRESHOLD (1 << 17)
101 struct default_internals {
102 struct rte_mbuf **pkts;
105 uint32_t flush_count;
109 * Traffic Management (TM) Internals
112 #ifndef TM_MAX_SUBPORTS
113 #define TM_MAX_SUBPORTS 8
116 #ifndef TM_MAX_PIPES_PER_SUBPORT
117 #define TM_MAX_PIPES_PER_SUBPORT 4096
121 struct rte_sched_port_params port_params;
123 struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
125 struct rte_sched_pipe_params
126 pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
127 uint32_t n_pipe_profiles;
128 uint32_t pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
133 TM_NODE_LEVEL_PORT = 0,
134 TM_NODE_LEVEL_SUBPORT,
143 TAILQ_ENTRY(tm_node) node;
145 uint32_t parent_node_id;
149 struct tm_node *parent_node;
150 struct rte_tm_node_params params;
151 struct rte_tm_node_stats stats;
155 TAILQ_HEAD(tm_node_list, tm_node);
157 /* TM Hierarchy Specification */
158 struct tm_hierarchy {
159 struct tm_node_list nodes;
161 uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
164 struct tm_internals {
165 /** Hierarchy specification
167 * -Hierarchy is unfrozen at init and when port is stopped.
168 * -Hierarchy is frozen on successful hierarchy commit.
169 * -Run-time hierarchy changes are not allowed, therefore it makes
170 * sense to keep the hierarchy frozen after the port is started.
172 struct tm_hierarchy h;
175 struct tm_params params;
178 struct rte_sched_port *sched;
179 struct rte_mbuf **pkts_enq;
180 struct rte_mbuf **pkts_deq;
181 uint32_t pkts_enq_len;
183 uint32_t flush_count;
189 struct pmd_internals {
191 struct pmd_params params;
195 struct default_internals def; /**< Default */
196 struct tm_internals tm; /**< Traffic Management */
205 struct pmd_rx_queue {
209 uint16_t rx_queue_id;
214 * Traffic Management (TM) Operation
216 extern const struct rte_tm_ops pmd_tm_ops;
219 tm_params_check(struct pmd_params *params, uint32_t hard_rate);
222 tm_init(struct pmd_internals *p, struct pmd_params *params, int numa_node);
225 tm_free(struct pmd_internals *p);
228 tm_start(struct pmd_internals *p);
231 tm_stop(struct pmd_internals *p);
234 tm_enabled(struct rte_eth_dev *dev)
236 struct pmd_internals *p = dev->data->dev_private;
238 return (p->params.soft.flags & PMD_FEATURE_TM);
242 tm_used(struct rte_eth_dev *dev)
244 struct pmd_internals *p = dev->data->dev_private;
246 return (p->params.soft.flags & PMD_FEATURE_TM) &&
247 p->soft.tm.h.n_tm_nodes[TM_NODE_LEVEL_PORT];
250 #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */