DPDK  17.05.2
rte_distributor_private.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2017 Intel Corporation. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Intel Corporation nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _RTE_DIST_PRIV_H_
34 #define _RTE_DIST_PRIV_H_
35 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #define NO_FLAGS 0
49 #define RTE_DISTRIB_PREFIX "DT_"
50 
51 /*
52  * We will use the bottom four bits of pointer for flags, shifting out
53  * the top four bits to make room (since a 64-bit pointer actually only uses
54  * 48 bits). An arithmetic-right-shift will then appropriately restore the
55  * original pointer value with proper sign extension into the top bits.
56  */
57 #define RTE_DISTRIB_FLAG_BITS 4
58 #define RTE_DISTRIB_FLAGS_MASK (0x0F)
59 #define RTE_DISTRIB_NO_BUF 0
60 #define RTE_DISTRIB_GET_BUF (1)
61 #define RTE_DISTRIB_RETURN_BUF (2)
62 #define RTE_DISTRIB_VALID_BUF (4)
64 #define RTE_DISTRIB_BACKLOG_SIZE 8
65 #define RTE_DISTRIB_BACKLOG_MASK (RTE_DISTRIB_BACKLOG_SIZE - 1)
66 
67 #define RTE_DISTRIB_MAX_RETURNS 128
68 #define RTE_DISTRIB_RETURNS_MASK (RTE_DISTRIB_MAX_RETURNS - 1)
69 
75 #define RTE_DISTRIB_MAX_WORKERS 64
76 
77 #define RTE_DISTRIBUTOR_NAMESIZE 32
86 union rte_distributor_buffer_v20 {
87  volatile int64_t bufptr64;
88  char pad[RTE_CACHE_LINE_SIZE*3];
90 
91 /*
92  * Transfer up to 8 mbufs at a time to/from workers, and
93  * flow matching algorithm optimised for 8 flow IDs at a time
94  */
95 #define RTE_DIST_BURST_SIZE 8
96 
97 struct rte_distributor_backlog {
98  unsigned int start;
99  unsigned int count;
100  int64_t pkts[RTE_DIST_BURST_SIZE] __rte_cache_aligned;
101  uint16_t *tags; /* will point to second cacheline of inflights */
103 
104 
106  unsigned int start;
107  unsigned int count;
108  struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS];
109 };
110 
111 struct rte_distributor_v20 {
112  TAILQ_ENTRY(rte_distributor_v20) next;
114  char name[RTE_DISTRIBUTOR_NAMESIZE];
115  unsigned int num_workers;
117  uint32_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS];
119  uint64_t in_flight_bitmask;
125  struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS];
126 
127  union rte_distributor_buffer_v20 bufs[RTE_DISTRIB_MAX_WORKERS];
128 
129  struct rte_distributor_returned_pkts returns;
130 };
131 
132 /* All different signature compare functions */
133 enum rte_distributor_match_function {
134  RTE_DIST_MATCH_SCALAR = 0,
135  RTE_DIST_MATCH_VECTOR,
136  RTE_DIST_NUM_MATCH_FNS
137 };
138 
148  volatile int64_t bufptr64[RTE_DIST_BURST_SIZE]
149  __rte_cache_aligned; /* <= outgoing to worker */
150 
151  int64_t pad1 __rte_cache_aligned; /* <= one cache line */
152 
153  volatile int64_t retptr64[RTE_DIST_BURST_SIZE]
154  __rte_cache_aligned; /* <= incoming from worker */
155 
156  int64_t pad2 __rte_cache_aligned; /* <= one cache line */
157 
158  int count __rte_cache_aligned; /* <= number of current mbufs */
159 };
160 
161 struct rte_distributor {
162  TAILQ_ENTRY(rte_distributor) next;
164  char name[RTE_DISTRIBUTOR_NAMESIZE];
165  unsigned int num_workers;
166  unsigned int alg_type;
173  uint16_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS][RTE_DIST_BURST_SIZE*2]
175 
176  struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS]
177  __rte_cache_aligned;
178 
180 
181  struct rte_distributor_returned_pkts returns;
182 
183  enum rte_distributor_match_function dist_match_fn;
184 
185  struct rte_distributor_v20 *d_v20;
186 };
187 
188 void
189 find_match_scalar(struct rte_distributor *d,
190  uint16_t *data_ptr,
191  uint16_t *output_ptr);
192 
193 void
194 find_match_vec(struct rte_distributor *d,
195  uint16_t *data_ptr,
196  uint16_t *output_ptr);
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif