53 FLOW_TABLE_CONFIG_ID = 1,
54 TIMESTAMP_CONFIG_ID = 2,
55 RATE_LIMIT_CONFIG_ID = 3,
56 FALLBACK_QUEUES_CONFIG_ID = 4
59struct __attribute__((__packed__)) FlowTableConfig {
67 uint32_t enso_pipe_id;
71struct __attribute__((__packed__)) TimestampConfig {
79struct __attribute__((__packed__)) RateLimitConfig {
88struct __attribute__((__packed__)) FallbackQueueConfig {
91 uint32_t nb_fallback_queues;
92 uint32_t fallback_queue_mask;
98 uint16_t dst_port, uint16_t src_port, uint32_t dst_ip,
99 uint32_t src_ip, uint32_t protocol,
100 uint32_t enso_pipe_id) {
101 struct FlowTableConfig config;
104 config.config_id = FLOW_TABLE_CONFIG_ID;
105 config.dst_port = dst_port;
106 config.src_port = src_port;
107 config.dst_ip = dst_ip;
108 config.src_ip = src_ip;
109 config.protocol = protocol;
110 config.enso_pipe_id = enso_pipe_id;
112 std::cout <<
"Inserting flow entry: dst_port=" << dst_port
113 <<
", src_port=" << src_port <<
", dst_ip=";
114 print_ip(htonl(dst_ip));
115 std::cout <<
", src_ip=";
116 print_ip(htonl(src_ip));
117 std::cout <<
", protocol=" << protocol <<
", enso_pipe_id=" << enso_pipe_id
120 return send_config(notification_buf_pair, (
struct TxNotification*)&config);
129 TimestampConfig config;
132 config.config_id = TIMESTAMP_CONFIG_ID;
134 config.offset = offset;
136 return send_config(notification_buf_pair, (
struct TxNotification*)&config);
140 TimestampConfig config;
143 config.config_id = TIMESTAMP_CONFIG_ID;
146 return send_config(notification_buf_pair, (
struct TxNotification*)&config);
150 uint16_t num, uint16_t den) {
151 struct RateLimitConfig config;
154 config.config_id = RATE_LIMIT_CONFIG_ID;
155 config.denominator = den;
156 config.numerator = num;
159 return send_config(notification_buf_pair, (
struct TxNotification*)&config);
163 struct RateLimitConfig config;
166 config.config_id = RATE_LIMIT_CONFIG_ID;
169 return send_config(notification_buf_pair, (
struct TxNotification*)&config);
172static int configure_fallback_queues(
173 struct NotificationBufPair* notification_buf_pair,
174 uint32_t nb_fallback_queues,
bool enable_rr) {
175 struct FallbackQueueConfig config;
178 config.config_id = FALLBACK_QUEUES_CONFIG_ID;
179 config.nb_fallback_queues = nb_fallback_queues;
180 config.enable_rr = enable_rr ? -1 : 0;
184 while (nb_fallback_queues) {
185 nb_fallback_queues >>= 1;
188 config.fallback_queue_mask = cnt ? (1 << (cnt - 1)) - 1 : 0;
190 return send_config(notification_buf_pair, (
struct TxNotification*)&config);
193static int set_round_robin(
struct NotificationBufPair* notification_buf_pair,
196 if (nb_fallback_queues < 0) {
197 return nb_fallback_queues;
204 return configure_fallback_queues(notification_buf_pair, nb_fallback_queues,
209 return set_round_robin(notification_buf_pair,
true);
213 return set_round_robin(notification_buf_pair,
false);
225 if (nb_fallback_queues < 0) {
226 return nb_fallback_queues;
229 return configure_fallback_queues(notification_buf_pair, nb_fallback_queues,
Functions to configure the data plane.
int enable_timestamp(struct NotificationBufPair *notification_buf_pair, uint8_t offset=kDefaultRttOffset)
Enables hardware timestamping.
int enable_round_robin(struct NotificationBufPair *notification_buf_pair)
Enables packet round robin for the fallback pipes.
int disable_timestamp(struct NotificationBufPair *notification_buf_pair)
Disables hardware timestamping.
int enable_rate_limit(struct NotificationBufPair *notification_buf_pair, uint16_t num, uint16_t den)
Enables hardware rate limit.
int update_fallback_queues_config(struct NotificationBufPair *notification_buf_pair)
Update the device's fallback queues configuration.
int disable_rate_limit(struct NotificationBufPair *notification_buf_pair)
Disables hardware rate limit.
int insert_flow_entry(struct NotificationBufPair *notification_buf_pair, uint16_t dst_port, uint16_t src_port, uint32_t dst_ip, uint32_t src_ip, uint32_t protocol, uint32_t enso_pipe_id)
Inserts flow entry in the data plane flow table that will direct all packets matching the flow entry ...
int disable_round_robin(struct NotificationBufPair *notification_buf_pair)
Disables packet round robin for the fallback pipes. Using a hash of the packet's five tuple to select...
Constants used throughout the codebase. Some of these constants need to be kept in sync with the hard...
Miscellaneous helper functions.
Definitions that are internal to Enso. They should not be exposed to applications.
int set_round_robin_status(struct NotificationBufPair *notification_buf_pair, bool round_robin)
Sets the round robin status for the device.
int send_config(struct NotificationBufPair *notification_buf_pair, struct TxNotification *config_notification)
Sends configuration to the NIC.
int get_nb_fallback_queues(struct NotificationBufPair *notification_buf_pair)
Get number of fallback queues currently in use.
int get_round_robin_status(struct NotificationBufPair *notification_buf_pair)
Gets the round robin status for the device.