Move location of __rte_aligned(a) to new conventional location. The new placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for both C and C++. Additionally, it avoids confusion by Doxygen when generating documentation.
Signed-off-by: Tyler Retzlaff <roret...@linux.microsoft.com> --- app/test-flow-perf/actions_gen.c | 51 ++++++++++++++++++++++------------------ app/test-flow-perf/items_gen.c | 22 +++++++++-------- app/test-flow-perf/main.c | 8 +++---- 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c index f1d5931..b5336e8 100644 --- a/app/test-flow-perf/actions_gen.c +++ b/app/test-flow-perf/actions_gen.c @@ -62,7 +62,8 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_mark mark_actions[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) + struct rte_flow_action_mark mark_actions[RTE_MAX_LCORE]; uint32_t counter = para.counter; do { @@ -79,7 +80,8 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_queue queue_actions[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) + struct rte_flow_action_queue queue_actions[RTE_MAX_LCORE]; do { queue_actions[para.core_idx].index = para.queue; @@ -109,7 +111,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct action_rss_data *rss_data[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct action_rss_data *rss_data[RTE_MAX_LCORE]; uint16_t queue; @@ -208,7 +210,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_mac set_macs[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_mac set_macs[RTE_MAX_LCORE]; uint32_t mac = para.counter; uint16_t i; @@ -231,7 +233,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_mac set_macs[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_mac set_macs[RTE_MAX_LCORE]; uint32_t mac = para.counter; uint16_t i; @@ -254,7 +256,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_ipv4 set_ipv4[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_ipv4 set_ipv4[RTE_MAX_LCORE]; uint32_t ip = para.counter; /* Fixed value */ @@ -273,7 +275,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_ipv4 set_ipv4[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_ipv4 set_ipv4[RTE_MAX_LCORE]; uint32_t ip = para.counter; /* Fixed value */ @@ -292,7 +294,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_ipv6 set_ipv6[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_ipv6 set_ipv6[RTE_MAX_LCORE]; uint32_t ipv6 = para.counter; uint8_t i; @@ -315,7 +317,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_ipv6 set_ipv6[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_ipv6 set_ipv6[RTE_MAX_LCORE]; uint32_t ipv6 = para.counter; uint8_t i; @@ -338,7 +340,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_tp set_tp[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_tp set_tp[RTE_MAX_LCORE]; uint32_t tp = para.counter; /* Fixed value */ @@ -359,7 +361,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_tp set_tp[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_tp set_tp[RTE_MAX_LCORE]; uint32_t tp = para.counter; /* Fixed value */ @@ -381,7 +383,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static rte_be32_t value[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) rte_be32_t value[RTE_MAX_LCORE]; uint32_t ack_value = para.counter; /* Fixed value */ @@ -399,7 +401,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static rte_be32_t value[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) rte_be32_t value[RTE_MAX_LCORE]; uint32_t ack_value = para.counter; /* Fixed value */ @@ -417,7 +419,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static rte_be32_t value[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) rte_be32_t value[RTE_MAX_LCORE]; uint32_t seq_value = para.counter; /* Fixed value */ @@ -435,7 +437,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static rte_be32_t value[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) rte_be32_t value[RTE_MAX_LCORE]; uint32_t seq_value = para.counter; /* Fixed value */ @@ -453,7 +455,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_ttl set_ttl[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_ttl set_ttl[RTE_MAX_LCORE]; uint32_t ttl_value = para.counter; /* Fixed value */ @@ -482,7 +484,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_dscp set_dscp[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_dscp set_dscp[RTE_MAX_LCORE]; uint32_t dscp_value = para.counter; /* Fixed value */ @@ -503,7 +505,7 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct rte_flow_action_set_dscp set_dscp[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_set_dscp set_dscp[RTE_MAX_LCORE]; uint32_t dscp_value = para.counter; /* Fixed value */ @@ -770,7 +772,8 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct action_raw_encap_data *action_encap_data[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) + struct action_raw_encap_data *action_encap_data[RTE_MAX_LCORE]; uint64_t encap_data = para.encap_data; uint8_t *header; uint8_t i; @@ -807,7 +810,8 @@ struct action_rss_data { uint8_t actions_counter, struct additional_para para) { - static struct action_raw_decap_data *action_decap_data[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) + struct action_raw_decap_data *action_decap_data[RTE_MAX_LCORE]; uint64_t decap_data = para.decap_data; uint8_t *header; uint8_t i; @@ -844,7 +848,8 @@ struct action_rss_data { uint8_t actions_counter, __rte_unused struct additional_para para) { - static struct rte_flow_action_vxlan_encap vxlan_encap[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) + struct rte_flow_action_vxlan_encap vxlan_encap[RTE_MAX_LCORE]; static struct rte_flow_item items[5]; static struct rte_flow_item_eth item_eth; static struct rte_flow_item_ipv4 item_ipv4; @@ -900,8 +905,8 @@ struct action_rss_data { uint8_t actions_counter, __rte_unused struct additional_para para) { - static struct rte_flow_action_meter - meters[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_action_meter + meters[RTE_MAX_LCORE]; meters[para.core_idx].mtr_id = para.counter; actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_METER; diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c index 8592834..4ae7250 100644 --- a/app/test-flow-perf/items_gen.c +++ b/app/test-flow-perf/items_gen.c @@ -52,8 +52,8 @@ struct additional_para { add_ipv4(struct rte_flow_item *items, uint8_t items_counter, struct additional_para para) { - static struct rte_flow_item_ipv4 ipv4_specs[RTE_MAX_LCORE] __rte_cache_aligned; - static struct rte_flow_item_ipv4 ipv4_masks[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_ipv4 ipv4_specs[RTE_MAX_LCORE]; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_ipv4 ipv4_masks[RTE_MAX_LCORE]; uint8_t ti = para.core_idx; ipv4_specs[ti].hdr.src_addr = RTE_BE32(para.src_ip); @@ -69,8 +69,8 @@ struct additional_para { add_ipv6(struct rte_flow_item *items, uint8_t items_counter, struct additional_para para) { - static struct rte_flow_item_ipv6 ipv6_specs[RTE_MAX_LCORE] __rte_cache_aligned; - static struct rte_flow_item_ipv6 ipv6_masks[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_ipv6 ipv6_specs[RTE_MAX_LCORE]; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_ipv6 ipv6_masks[RTE_MAX_LCORE]; uint8_t ti = para.core_idx; uint8_t i; @@ -118,8 +118,8 @@ struct additional_para { uint8_t items_counter, struct additional_para para) { - static struct rte_flow_item_vxlan vxlan_specs[RTE_MAX_LCORE] __rte_cache_aligned; - static struct rte_flow_item_vxlan vxlan_masks[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_vxlan vxlan_specs[RTE_MAX_LCORE]; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_vxlan vxlan_masks[RTE_MAX_LCORE]; uint8_t ti = para.core_idx; uint32_t vni_value; uint8_t i; @@ -145,8 +145,10 @@ struct additional_para { uint8_t items_counter, __rte_unused struct additional_para para) { - static struct rte_flow_item_vxlan_gpe vxlan_gpe_specs[RTE_MAX_LCORE] __rte_cache_aligned; - static struct rte_flow_item_vxlan_gpe vxlan_gpe_masks[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) + struct rte_flow_item_vxlan_gpe vxlan_gpe_specs[RTE_MAX_LCORE]; + static alignas(RTE_CACHE_LINE_SIZE) + struct rte_flow_item_vxlan_gpe vxlan_gpe_masks[RTE_MAX_LCORE]; uint8_t ti = para.core_idx; uint32_t vni_value; uint8_t i; @@ -189,8 +191,8 @@ struct additional_para { uint8_t items_counter, __rte_unused struct additional_para para) { - static struct rte_flow_item_geneve geneve_specs[RTE_MAX_LCORE] __rte_cache_aligned; - static struct rte_flow_item_geneve geneve_masks[RTE_MAX_LCORE] __rte_cache_aligned; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_geneve geneve_specs[RTE_MAX_LCORE]; + static alignas(RTE_CACHE_LINE_SIZE) struct rte_flow_item_geneve geneve_masks[RTE_MAX_LCORE]; uint8_t ti = para.core_idx; uint32_t vni_value; uint8_t i; diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index e224ef6..07ddfe0 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -113,7 +113,7 @@ struct stream { int rx_queue; }; -struct lcore_info { +struct __rte_cache_aligned lcore_info { int mode; int streams_nb; struct stream streams[MAX_STREAMS]; @@ -122,7 +122,7 @@ struct lcore_info { uint64_t tx_drops; uint64_t rx_pkts; struct rte_mbuf *pkts[MAX_PKT_BURST]; -} __rte_cache_aligned; +}; static struct lcore_info lcore_infos[RTE_MAX_LCORE]; @@ -131,14 +131,14 @@ struct used_cpu_time { double deletion[MAX_PORTS][RTE_MAX_LCORE]; }; -struct multi_cores_pool { +struct __rte_cache_aligned multi_cores_pool { uint32_t cores_count; uint32_t rules_count; struct used_cpu_time meters_record; struct used_cpu_time flows_record; int64_t last_alloc[RTE_MAX_LCORE]; int64_t current_alloc[RTE_MAX_LCORE]; -} __rte_cache_aligned; +}; static struct multi_cores_pool mc_pool = { .cores_count = 1, -- 1.8.3.1