DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::dpdklibs Namespace Reference

Namespaces

namespace  arp
 
namespace  cyclicdatagenerator
 
namespace  ealutils
 
namespace  ifaceutils
 
namespace  nicreader
 
namespace  nicsender
 
namespace  opmon
 
namespace  udp
 

Classes

struct  IfaceXstats
 
struct  IpAddr
 
class  SourceConcept
 
class  SourceModel
 

Functions

struct rte_flow * generate_ipv4_flow (uint16_t port_id, uint16_t rx_q, uint32_t src_ip, uint32_t src_mask, uint32_t dest_ip, uint32_t dest_mask, struct rte_flow_error *error)
 
struct rte_flow * generate_drop_flow (uint16_t port_id, struct rte_flow_error *error)
 
struct rte_flow * generate_arp_flow (uint16_t port_id, uint16_t rx_q, struct rte_flow_error *error)
 
std::shared_ptr< SourceConceptcreateSourceModel (const std::string &conn_uid, bool callback_mode)
 

Variables

static constexpr uint32_t MAX_PATTERN_NUM = 3
 
static constexpr uint32_t MAX_ACTION_NUM = 2
 

Function Documentation

◆ createSourceModel()

std::shared_ptr< SourceConcept > dunedaq::dpdklibs::createSourceModel ( const std::string & conn_uid,
bool callback_mode )

Definition at line 29 of file CreateSource.hpp.

30{
31 auto datatypes = dunedaq::iomanager::IOManager::get()->get_datatypes(conn_uid);
32 if (datatypes.size() != 1) {
33 ers::error(dunedaq::datahandlinglibs::GenericConfigurationError(ERS_HERE,
34 "Multiple output data types specified! Expected only a single type!"));
35 }
36 std::string raw_dt{ *datatypes.begin() };
37 TLOG() << "Choosing specializations for SourceModel for output connection "
38 << " [uid:" << conn_uid << " , data_type:" << raw_dt << ']';
39
40 if (raw_dt.find("WIBEthFrame") != std::string::npos) {
41 // Create Model
42 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DUNEWIBEthTypeAdapter>>();
43
44 // For callback acquisition later (lazy)
45 source_model->set_sink_name(conn_uid);
46
47 // Setup sink (acquire pointer from QueueRegistry)
48 source_model->set_sink(conn_uid, callback_mode);
49
50 // Get parser and sink
51 //auto& parser = source_model->get_parser();
52 //auto& sink = source_model->get_sink();
53 //auto& error_sink = source_model->get_error_sink();
54
55 // Modify parser as needed...
56 //parser.process_chunk_func = parsers::fixsizedChunkInto<fdreadoutlibs::types::ProtoWIBSuperChunkTypeAdapter>(sink);
57 //if (error_sink != nullptr) {
58 // parser.process_chunk_with_error_func = parsers::errorChunkIntoSink(error_sink);
59 //}
60 // parser.process_block_func = ...
61
62 // Return with setup model
63 return source_model;
64
65 } else if (raw_dt.find("TDEEthFrame") != std::string::npos) {
66 // WIB2 specific char arrays
67 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::TDEEthTypeAdapter>>();
68 source_model->set_sink_name(conn_uid);
69 source_model->set_sink(conn_uid, callback_mode);
70 //auto& parser = source_model->get_parser();
71 //parser.process_chunk_func = parsers::fixsizedChunkInto<fdreadoutlibs::types::DUNEWIBSuperChunkTypeAdapter>(sink);
72 return source_model;
73 }
74
75 return nullptr;
76}
#define ERS_HERE
static std::shared_ptr< IOManager > get()
Definition IOManager.hpp:40
#define TLOG(...)
Definition macro.hpp:22
void error(const Issue &issue)
Definition ers.hpp:81

◆ generate_arp_flow()

struct rte_flow * dunedaq::dpdklibs::generate_arp_flow ( uint16_t port_id,
uint16_t rx_q,
struct rte_flow_error * error )

Definition at line 168 of file FlowControl.cpp.

169{
170 struct rte_flow_attr attr;
171 struct rte_flow_item pattern[MAX_PATTERN_NUM];
172 struct rte_flow_action action[MAX_ACTION_NUM];
173 struct rte_flow *flow = NULL;
174 struct rte_flow_action_queue queue = { .index = rx_q };
175 int res;
176
177 memset(pattern, 0, sizeof(pattern));
178 memset(action, 0, sizeof(action));
179
180 // Set the rule attribute, only ingress packets will be checked.
181 memset(&attr, 0, sizeof(struct rte_flow_attr));
182 attr.ingress = 1;
183 attr.egress = 0;
184 attr.priority = 1; // TODO the higher the lower?
185
186 // Action -> queue steering
187 action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
188 action[0].conf = &queue;
189 action[1].type = RTE_FLOW_ACTION_TYPE_END;
190
191 // Rule prep
192 struct rte_flow_item_eth item_eth_mask = {};
193 struct rte_flow_item_eth item_eth_spec = {};
194 // Rule marker
195 item_eth_spec.hdr.ether_type = RTE_BE16(RTE_ETHER_TYPE_ARP);
196 item_eth_mask.hdr.ether_type = RTE_BE16(0xFFFF);
197 // Rule pattern
198 pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH;
199 pattern[0].mask = &item_eth_mask;
200 pattern[0].spec = &item_eth_spec;
201 pattern[1].type = RTE_FLOW_ITEM_TYPE_END;
202
203 // Validate the rule and create it.
204 res = rte_flow_validate(port_id, &attr, pattern, action, error);
205 if (not res) {
206 flow = rte_flow_create(port_id, &attr, pattern, action, error);
207 }
208
209 return flow;
210}
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34

◆ generate_drop_flow()

struct rte_flow * dunedaq::dpdklibs::generate_drop_flow ( uint16_t port_id,
struct rte_flow_error * error )

Definition at line 115 of file FlowControl.cpp.

116{
117 struct rte_flow_attr attr;
118 struct rte_flow_item pattern[MAX_PATTERN_NUM];
119 struct rte_flow_action action[MAX_ACTION_NUM];
120 struct rte_flow *flow = NULL;
121 int res;
122
123 memset(pattern, 0, sizeof(pattern));
124 memset(action, 0, sizeof(action));
125
126 // Set the rule attribute, only ingress packets will be checked.
127 memset(&attr, 0, sizeof(struct rte_flow_attr));
128 attr.ingress = 1;
129 attr.egress = 0;
130 attr.priority = 1; // TODO the higher the lower?
131
132 /*
133 * create the action sequence.
134 * one action only, Drop the packet
135 */
136 action[0].type = RTE_FLOW_ACTION_TYPE_DROP;
137 action[1].type = RTE_FLOW_ACTION_TYPE_END;
138
139 /*
140 * set the first level of the pattern (ETH).
141 * since in this example we just want to get the
142 * ipv4 we set this level to allow all.
143 */
144
145 // Set this level to allow all.
146 pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH;
147
148 /*
149 * setting the second level of the pattern (IP).
150 * in this example this is the level we care about
151 * so we set it according to the parameters.
152 */
153
154 // The final level must be always type end.
155 pattern[1].type = RTE_FLOW_ITEM_TYPE_END;
156
157 // Validate the rule and create it.
158 res = rte_flow_validate(port_id, &attr, pattern, action, error);
159 if (not res) {
160 flow = rte_flow_create(port_id, &attr, pattern, action, error);
161 }
162
163 return flow;
164}

◆ generate_ipv4_flow()

struct rte_flow * dunedaq::dpdklibs::generate_ipv4_flow ( uint16_t port_id,
uint16_t rx_q,
uint32_t src_ip,
uint32_t src_mask,
uint32_t dest_ip,
uint32_t dest_mask,
struct rte_flow_error * error )

create a flow rule that sends packets with matching src and dest ip to selected queue.

Parameters
port_idThe selected port.
rx_qThe selected target queue.
src_ipThe src ip value to match the input packet.
src_maskThe mask to apply to the src ip.
dest_ipThe dest ip value to match the input packet.
dest_maskThe mask to apply to the dest ip.
[out]errorPerform verbose error reporting if not NULL.
Returns
A flow if the rule could be created else return NULL.

Definition at line 42 of file FlowControl.cpp.

46{
47 // Declaring structs being used.
48 struct rte_flow_attr attr;
49 struct rte_flow_item pattern[MAX_PATTERN_NUM];
50 struct rte_flow_action action[MAX_ACTION_NUM];
51 struct rte_flow *flow = NULL;
52 struct rte_flow_action_queue queue = { .index = rx_q };
53 struct rte_flow_item_ipv4 ip_spec;
54 struct rte_flow_item_ipv4 ip_mask;
55
56 int res;
57
58 memset(pattern, 0, sizeof(pattern));
59 memset(action, 0, sizeof(action));
60
61 // Set the rule attribute, only ingress packets will be checked.
62 memset(&attr, 0, sizeof(struct rte_flow_attr));
63 attr.ingress = 1;
64
65 /*
66 * create the action sequence.
67 * one action only, move packet to queue
68 */
69 action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
70 action[0].conf = &queue;
71 action[1].type = RTE_FLOW_ACTION_TYPE_END;
72
73 /*
74 * set the first level of the pattern (ETH).
75 * since in this example we just want to get the
76 * ipv4 we set this level to allow all.
77 */
78
79 // Set this level to allow all.
80
81 /*
82 * setting the second level of the pattern (IP).
83 * in this example this is the level we care about
84 * so we set it according to the parameters.
85 */
86
87 // Setting the second level of the pattern.
88 memset(&ip_spec, 0, sizeof(struct rte_flow_item_ipv4));
89 memset(&ip_mask, 0, sizeof(struct rte_flow_item_ipv4));
90 ip_spec.hdr.dst_addr = htonl(dest_ip);
91 ip_mask.hdr.dst_addr = 0;
92 ip_spec.hdr.src_addr = htonl(src_ip);
93 ip_mask.hdr.src_addr = src_mask;
94
95 pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH;
96
97 pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV4;
98 pattern[1].spec = &ip_spec;
99 pattern[1].mask = &ip_mask;
100
101
102 pattern[2].type = RTE_FLOW_ITEM_TYPE_END;
103
104 // Validate the rule and create it.
105 res = rte_flow_validate(port_id, &attr, pattern, action, error);
106 if (not res) {
107 flow = rte_flow_create(port_id, &attr, pattern, action, error);
108 }
109
110 return flow;
111}

Variable Documentation

◆ MAX_ACTION_NUM

uint32_t dunedaq::dpdklibs::MAX_ACTION_NUM = 2
staticconstexpr

Definition at line 19 of file FlowControl.hpp.

◆ MAX_PATTERN_NUM

uint32_t dunedaq::dpdklibs::MAX_PATTERN_NUM = 3
staticconstexpr

Definition at line 18 of file FlowControl.hpp.