X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fip_pipeline%2Fpipeline.c;h=7ebabcae984d2ae9a9502d95e549103fd9ab0cd6;hb=38d232b9b804eebd458d758f2face173220ee2f8;hp=b23d6c09afc8de0a121841790cc211a40798a370;hpb=e1884698f688eddee352c1bbe0ecb007bd2ed205;p=dpdk.git diff --git a/examples/ip_pipeline/pipeline.c b/examples/ip_pipeline/pipeline.c index b23d6c09af..7ebabcae98 100644 --- a/examples/ip_pipeline/pipeline.c +++ b/examples/ip_pipeline/pipeline.c @@ -11,7 +11,7 @@ #include #include -#ifdef RTE_LIBRTE_KNI +#ifdef RTE_LIB_KNI #include #endif #include @@ -28,7 +28,7 @@ #include #include -#ifdef RTE_LIBRTE_KNI +#ifdef RTE_LIB_KNI #include "kni.h" #endif #include "link.h" @@ -160,7 +160,7 @@ pipeline_port_in_create(const char *pipeline_name, struct rte_port_ring_reader_params ring; struct rte_port_sched_reader_params sched; struct rte_port_fd_reader_params fd; -#ifdef RTE_LIBRTE_KNI +#ifdef RTE_LIB_KNI struct rte_port_kni_reader_params kni; #endif struct rte_port_source_params source; @@ -264,7 +264,7 @@ pipeline_port_in_create(const char *pipeline_name, break; } -#ifdef RTE_LIBRTE_KNI +#ifdef RTE_LIB_KNI case PORT_IN_KNI: { struct kni *kni; @@ -404,7 +404,7 @@ pipeline_port_out_create(const char *pipeline_name, struct rte_port_ring_writer_params ring; struct rte_port_sched_writer_params sched; struct rte_port_fd_writer_params fd; -#ifdef RTE_LIBRTE_KNI +#ifdef RTE_LIB_KNI struct rte_port_kni_writer_params kni; #endif struct rte_port_sink_params sink; @@ -415,7 +415,7 @@ pipeline_port_out_create(const char *pipeline_name, struct rte_port_ethdev_writer_nodrop_params ethdev; struct rte_port_ring_writer_nodrop_params ring; struct rte_port_fd_writer_nodrop_params fd; -#ifdef RTE_LIBRTE_KNI +#ifdef RTE_LIB_KNI struct rte_port_kni_writer_nodrop_params kni; #endif struct rte_port_sym_crypto_writer_nodrop_params sym_crypto; @@ -537,7 +537,7 @@ pipeline_port_out_create(const char *pipeline_name, break; } -#ifdef RTE_LIBRTE_KNI +#ifdef RTE_LIB_KNI case PORT_OUT_KNI: { struct kni *kni; @@ -636,7 +636,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv4[] = { .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) */ @@ -645,7 +645,7 @@ static const struct rte_acl_field_def table_acl_field_format_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) */ @@ -654,7 +654,7 @@ static const struct rte_acl_field_def table_acl_field_format_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 */ @@ -663,8 +663,8 @@ static const struct rte_acl_field_def table_acl_field_format_ipv4[] = { .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 */ @@ -673,8 +673,8 @@ static const struct rte_acl_field_def table_acl_field_format_ipv4[] = { .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), }, }; @@ -685,7 +685,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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) */ @@ -694,7 +694,7 @@ static const struct rte_acl_field_def table_acl_field_format_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] = { @@ -702,7 +702,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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] = { @@ -710,7 +710,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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] = { @@ -718,7 +718,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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) */ @@ -727,7 +727,7 @@ static const struct rte_acl_field_def table_acl_field_format_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] = { @@ -735,7 +735,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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] = { @@ -743,7 +743,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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] = { @@ -751,7 +751,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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 */ @@ -760,8 +760,8 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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 */ @@ -770,8 +770,8 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = { .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), }, }; @@ -1041,7 +1041,95 @@ pipeline_table_create(const char *pipeline_name, 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; +}