#include <rte_ip.h>
#include <rte_tcp.h>
+#include <rte_string_fns.h>
#include <rte_port_ethdev.h>
#ifdef RTE_LIBRTE_KNI
#include <rte_port_kni.h>
#include <rte_port_source_sink.h>
#include <rte_port_fd.h>
#include <rte_port_sched.h>
+#include <rte_port_sym_crypto.h>
#include <rte_table_acl.h>
#include <rte_table_array.h>
#include <rte_table_hash.h>
+#include <rte_table_hash_func.h>
#include <rte_table_lpm.h>
#include <rte_table_lpm_ipv6.h>
#include <rte_table_stub.h>
#include "tap.h"
#include "tmgr.h"
#include "swq.h"
-
-#include "hash_func.h"
+#include "cryptodev.h"
#ifndef PIPELINE_MSGQ_SIZE
#define PIPELINE_MSGQ_SIZE 64
}
/* Node fill in */
- strncpy(pipeline->name, name, sizeof(pipeline->name));
+ strlcpy(pipeline->name, name, sizeof(pipeline->name));
pipeline->p = p;
pipeline->n_ports_in = 0;
pipeline->n_ports_out = 0;
struct rte_port_kni_reader_params kni;
#endif
struct rte_port_source_params source;
+ struct rte_port_sym_crypto_reader_params sym_crypto;
} pp;
struct pipeline *pipeline;
break;
}
+ case PORT_IN_CRYPTODEV:
+ {
+ struct cryptodev *cryptodev;
+
+ cryptodev = cryptodev_find(params->dev_name);
+ if (cryptodev == NULL)
+ return -1;
+
+ if (params->rxq.queue_id > cryptodev->n_queues - 1)
+ return -1;
+
+ pp.sym_crypto.cryptodev_id = cryptodev->dev_id;
+ pp.sym_crypto.queue_id = params->cryptodev.queue_id;
+ pp.sym_crypto.f_callback = params->cryptodev.f_callback;
+ pp.sym_crypto.arg_callback = params->cryptodev.arg_callback;
+ p.ops = &rte_port_sym_crypto_reader_ops;
+ p.arg_create = &pp.sym_crypto;
+
+ break;
+ }
+
default:
return -1;
}
struct rte_port_kni_writer_params kni;
#endif
struct rte_port_sink_params sink;
+ struct rte_port_sym_crypto_writer_params sym_crypto;
} pp;
union {
#ifdef RTE_LIBRTE_KNI
struct rte_port_kni_writer_nodrop_params kni;
#endif
+ struct rte_port_sym_crypto_writer_nodrop_params sym_crypto;
} pp_nodrop;
struct pipeline *pipeline;
break;
}
+ case PORT_OUT_CRYPTODEV:
+ {
+ struct cryptodev *cryptodev;
+
+ cryptodev = cryptodev_find(params->dev_name);
+ if (cryptodev == NULL)
+ return -1;
+
+ if (params->cryptodev.queue_id >= cryptodev->n_queues)
+ return -1;
+
+ pp.sym_crypto.cryptodev_id = cryptodev->dev_id;
+ pp.sym_crypto.queue_id = params->cryptodev.queue_id;
+ pp.sym_crypto.tx_burst_sz = params->burst_size;
+ pp.sym_crypto.crypto_op_offset = params->cryptodev.op_offset;
+
+ pp_nodrop.sym_crypto.cryptodev_id = cryptodev->dev_id;
+ pp_nodrop.sym_crypto.queue_id = params->cryptodev.queue_id;
+ pp_nodrop.sym_crypto.tx_burst_sz = params->burst_size;
+ pp_nodrop.sym_crypto.n_retries = params->retry;
+ pp_nodrop.sym_crypto.crypto_op_offset =
+ params->cryptodev.op_offset;
+
+ if (params->retry == 0) {
+ p.ops = &rte_port_sym_crypto_writer_ops;
+ p.arg_create = &pp.sym_crypto;
+ } else {
+ p.ops = &rte_port_sym_crypto_writer_nodrop_ops;
+ p.arg_create = &pp_nodrop.sym_crypto;
+ }
+
+ break;
+ }
+
default:
return -1;
}
.size = sizeof(uint8_t),
.field_index = 0,
.input_index = 0,
- .offset = offsetof(struct ipv4_hdr, next_proto_id),
+ .offset = offsetof(struct rte_ipv4_hdr, next_proto_id),
},
/* Source IP address (IPv4) */
.size = sizeof(uint32_t),
.field_index = 1,
.input_index = 1,
- .offset = offsetof(struct ipv4_hdr, src_addr),
+ .offset = offsetof(struct rte_ipv4_hdr, src_addr),
},
/* Destination IP address (IPv4) */
.size = sizeof(uint32_t),
.field_index = 2,
.input_index = 2,
- .offset = offsetof(struct ipv4_hdr, dst_addr),
+ .offset = offsetof(struct rte_ipv4_hdr, dst_addr),
},
/* Source Port */
.size = sizeof(uint16_t),
.field_index = 3,
.input_index = 3,
- .offset = sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, src_port),
+ .offset = sizeof(struct rte_ipv4_hdr) +
+ offsetof(struct rte_tcp_hdr, src_port),
},
/* Destination Port */
.size = sizeof(uint16_t),
.field_index = 4,
.input_index = 3,
- .offset = sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, dst_port),
+ .offset = sizeof(struct rte_ipv4_hdr) +
+ offsetof(struct rte_tcp_hdr, dst_port),
},
};
.size = sizeof(uint8_t),
.field_index = 0,
.input_index = 0,
- .offset = offsetof(struct ipv6_hdr, proto),
+ .offset = offsetof(struct rte_ipv6_hdr, proto),
},
/* Source IP address (IPv6) */
.size = sizeof(uint32_t),
.field_index = 1,
.input_index = 1,
- .offset = offsetof(struct ipv6_hdr, src_addr[0]),
+ .offset = offsetof(struct rte_ipv6_hdr, src_addr[0]),
},
[2] = {
.size = sizeof(uint32_t),
.field_index = 2,
.input_index = 2,
- .offset = offsetof(struct ipv6_hdr, src_addr[4]),
+ .offset = offsetof(struct rte_ipv6_hdr, src_addr[4]),
},
[3] = {
.size = sizeof(uint32_t),
.field_index = 3,
.input_index = 3,
- .offset = offsetof(struct ipv6_hdr, src_addr[8]),
+ .offset = offsetof(struct rte_ipv6_hdr, src_addr[8]),
},
[4] = {
.size = sizeof(uint32_t),
.field_index = 4,
.input_index = 4,
- .offset = offsetof(struct ipv6_hdr, src_addr[12]),
+ .offset = offsetof(struct rte_ipv6_hdr, src_addr[12]),
},
/* Destination IP address (IPv6) */
.size = sizeof(uint32_t),
.field_index = 5,
.input_index = 5,
- .offset = offsetof(struct ipv6_hdr, dst_addr[0]),
+ .offset = offsetof(struct rte_ipv6_hdr, dst_addr[0]),
},
[6] = {
.size = sizeof(uint32_t),
.field_index = 6,
.input_index = 6,
- .offset = offsetof(struct ipv6_hdr, dst_addr[4]),
+ .offset = offsetof(struct rte_ipv6_hdr, dst_addr[4]),
},
[7] = {
.size = sizeof(uint32_t),
.field_index = 7,
.input_index = 7,
- .offset = offsetof(struct ipv6_hdr, dst_addr[8]),
+ .offset = offsetof(struct rte_ipv6_hdr, dst_addr[8]),
},
[8] = {
.size = sizeof(uint32_t),
.field_index = 8,
.input_index = 8,
- .offset = offsetof(struct ipv6_hdr, dst_addr[12]),
+ .offset = offsetof(struct rte_ipv6_hdr, dst_addr[12]),
},
/* Source Port */
.size = sizeof(uint16_t),
.field_index = 9,
.input_index = 9,
- .offset = sizeof(struct ipv6_hdr) +
- offsetof(struct tcp_hdr, src_port),
+ .offset = sizeof(struct rte_ipv6_hdr) +
+ offsetof(struct rte_tcp_hdr, src_port),
},
/* Destination Port */
.size = sizeof(uint16_t),
.field_index = 10,
.input_index = 9,
- .offset = sizeof(struct ipv6_hdr) +
- offsetof(struct tcp_hdr, dst_port),
+ .offset = sizeof(struct rte_ipv6_hdr) +
+ offsetof(struct rte_tcp_hdr, dst_port),
},
};
switch (params->match.hash.key_size) {
case 8:
- f_hash = hash_default_key8;
+ f_hash = rte_table_hash_crc_key8;
break;
case 16:
- f_hash = hash_default_key16;
+ f_hash = rte_table_hash_crc_key16;
break;
case 24:
- f_hash = hash_default_key24;
+ f_hash = rte_table_hash_crc_key24;
break;
case 32:
- f_hash = hash_default_key32;
+ f_hash = rte_table_hash_crc_key32;
break;
case 40:
- f_hash = hash_default_key40;
+ f_hash = rte_table_hash_crc_key40;
break;
case 48:
- f_hash = hash_default_key48;
+ f_hash = rte_table_hash_crc_key48;
break;
case 56:
- f_hash = hash_default_key56;
+ f_hash = rte_table_hash_crc_key56;
break;
case 64:
- f_hash = hash_default_key64;
+ f_hash = rte_table_hash_crc_key64;
break;
default:
return -1;
memcpy(&table->params, params, sizeof(*params));
table->ap = ap;
table->a = action;
+ TAILQ_INIT(&table->rules);
+ table->rule_default = NULL;
+
pipeline->n_tables++;
return 0;
}
+
+struct table_rule *
+table_rule_find(struct table *table,
+ struct table_rule_match *match)
+{
+ struct table_rule *rule;
+
+ TAILQ_FOREACH(rule, &table->rules, node)
+ if (memcmp(&rule->match, match, sizeof(*match)) == 0)
+ return rule;
+
+ return NULL;
+}
+
+void
+table_rule_add(struct table *table,
+ struct table_rule *new_rule)
+{
+ struct table_rule *existing_rule;
+
+ existing_rule = table_rule_find(table, &new_rule->match);
+ if (existing_rule == NULL)
+ TAILQ_INSERT_TAIL(&table->rules, new_rule, node);
+ else {
+ TAILQ_INSERT_AFTER(&table->rules, existing_rule, new_rule, node);
+ TAILQ_REMOVE(&table->rules, existing_rule, node);
+ free(existing_rule);
+ }
+}
+
+void
+table_rule_add_bulk(struct table *table,
+ struct table_rule_list *list,
+ uint32_t n_rules)
+{
+ uint32_t i;
+
+ for (i = 0; i < n_rules; i++) {
+ struct table_rule *existing_rule, *new_rule;
+
+ new_rule = TAILQ_FIRST(list);
+ if (new_rule == NULL)
+ break;
+
+ TAILQ_REMOVE(list, new_rule, node);
+
+ existing_rule = table_rule_find(table, &new_rule->match);
+ if (existing_rule == NULL)
+ TAILQ_INSERT_TAIL(&table->rules, new_rule, node);
+ else {
+ TAILQ_INSERT_AFTER(&table->rules, existing_rule, new_rule, node);
+ TAILQ_REMOVE(&table->rules, existing_rule, node);
+ free(existing_rule);
+ }
+ }
+}
+
+void
+table_rule_delete(struct table *table,
+ struct table_rule_match *match)
+{
+ struct table_rule *rule;
+
+ rule = table_rule_find(table, match);
+ if (rule == NULL)
+ return;
+
+ TAILQ_REMOVE(&table->rules, rule, node);
+ free(rule);
+}
+
+void
+table_rule_default_add(struct table *table,
+ struct table_rule *rule)
+{
+ free(table->rule_default);
+ table->rule_default = rule;
+}
+
+void
+table_rule_default_delete(struct table *table)
+{
+ free(table->rule_default);
+ table->rule_default = NULL;
+}