diff options
author | Dave Barach <dbarach@cisco.com> | 2018-05-03 08:26:39 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2018-05-04 15:15:22 +0000 |
commit | eb987d3a09f669787014b1553f032219522149e1 (patch) | |
tree | 8d092c7368cfc2e02fc1869c6ded7410ad734392 /src/vnet | |
parent | 432bf677c6decadd05e3edfe54c02b1d01b2c64e (diff) |
Harmonize vec/pool_get_aligned object sizes and alignment requests
Object sizes must evenly divide alignment requests, or vice
versa. Otherwise, only the first object will be aligned as
requested.
Three choices: add CLIB_CACHE_LINE_ALIGN_MARK(align_me) at
the end of structures, manually pad to an even divisor or multiple of
the alignment request, or use plain vectors/pools.
static assert for enforcement.
Change-Id: I41aa6ff1a58267301d32aaf4b9cd24678ac1c147
Signed-off-by: Dave Barach <dbarach@cisco.com>
Diffstat (limited to 'src/vnet')
35 files changed, 146 insertions, 12 deletions
diff --git a/src/vnet/bier/bier_disp_entry.h b/src/vnet/bier/bier_disp_entry.h index 34ca5d4a09a..1647a7e166a 100644 --- a/src/vnet/bier/bier_disp_entry.h +++ b/src/vnet/bier/bier_disp_entry.h @@ -31,6 +31,11 @@ */ typedef struct bier_disp_entry_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The DPO contirubted from the per-payload protocol parents * on cachline 1. */ diff --git a/src/vnet/bier/bier_disp_table.h b/src/vnet/bier/bier_disp_table.h index 6f9380a507f..c5b211001e2 100644 --- a/src/vnet/bier/bier_disp_table.h +++ b/src/vnet/bier/bier_disp_table.h @@ -30,6 +30,11 @@ typedef struct bier_disp_table_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * number of locks on the table */ u16 bdt_locks; diff --git a/src/vnet/bier/bier_fmask.h b/src/vnet/bier/bier_fmask.h index 81b3923f54c..56930f6cd44 100644 --- a/src/vnet/bier/bier_fmask.h +++ b/src/vnet/bier/bier_fmask.h @@ -98,6 +98,11 @@ typedef enum bier_fmask_flags_t_ */ typedef struct bier_fmask_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The BIER fmask is a child of a FIB entry in the FIB graph. */ fib_node_t bfm_node; diff --git a/src/vnet/bier/bier_imp.h b/src/vnet/bier/bier_imp.h index 5b21b06b12d..cdc4dbb4fc1 100644 --- a/src/vnet/bier/bier_imp.h +++ b/src/vnet/bier/bier_imp.h @@ -33,6 +33,11 @@ */ typedef struct bier_imp_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The DPO contirubted from the resolving BIER table. * One per-IP protocol. This allows us to share a BIER imposition * object for a IPv4 and IPv6 mfib path. diff --git a/src/vnet/bier/bier_table.h b/src/vnet/bier/bier_table.h index a22e2e335b2..5af275f104a 100644 --- a/src/vnet/bier/bier_table.h +++ b/src/vnet/bier/bier_table.h @@ -37,6 +37,12 @@ struct bier_route_update_t_; */ typedef struct bier_table_t_ { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * Save the MPLS local label associated with the table */ mpls_label_t bt_ll; @@ -65,11 +71,6 @@ typedef struct bier_table_t_ { index_t *bt_entries; /** - * Everything before this declaration is unused in the switch path - */ - CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); - - /** * The identity/key or the table. we need the hdr_len in the data-path */ bier_table_id_t bt_id; diff --git a/src/vnet/dpo/classify_dpo.h b/src/vnet/dpo/classify_dpo.h index 48f4b2bf8a5..439727d351f 100644 --- a/src/vnet/dpo/classify_dpo.h +++ b/src/vnet/dpo/classify_dpo.h @@ -25,6 +25,11 @@ */ typedef struct classify_dpo_t { + /** + * required for pool_get_aligned. + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + dpo_proto_t cd_proto; u32 cd_table_index; diff --git a/src/vnet/dpo/l3_proxy_dpo.h b/src/vnet/dpo/l3_proxy_dpo.h index f17ace50876..fcc28b3bf97 100644 --- a/src/vnet/dpo/l3_proxy_dpo.h +++ b/src/vnet/dpo/l3_proxy_dpo.h @@ -27,6 +27,12 @@ typedef struct l3_proxy_dpo_t_ { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The Software interface index on which traffic is l3_proxyd */ u32 l3p_sw_if_index; diff --git a/src/vnet/dpo/load_balance.h b/src/vnet/dpo/load_balance.h index d37f07d579f..dd9589f9ee8 100644 --- a/src/vnet/dpo/load_balance.h +++ b/src/vnet/dpo/load_balance.h @@ -83,6 +83,12 @@ typedef struct load_balance_path_t_ { */ typedef struct load_balance_t_ { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * number of buckets in the load-balance. always a power of 2. */ u16 lb_n_buckets; diff --git a/src/vnet/dpo/load_balance_map.h b/src/vnet/dpo/load_balance_map.h index f9344c01c1e..82dd36b41b1 100644 --- a/src/vnet/dpo/load_balance_map.h +++ b/src/vnet/dpo/load_balance_map.h @@ -29,6 +29,12 @@ struct load_balance_map_path_t_; */ typedef struct load_balance_map_t_ { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The buckets of the map that provide the index to index translation. * In the first cacheline. */ diff --git a/src/vnet/dpo/lookup_dpo.h b/src/vnet/dpo/lookup_dpo.h index 4ebd6050fc6..21aecadc280 100644 --- a/src/vnet/dpo/lookup_dpo.h +++ b/src/vnet/dpo/lookup_dpo.h @@ -65,6 +65,12 @@ typedef enum lookup_cast_t_ { typedef struct lookup_dpo_t { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The FIB, or interface from which to get a FIB, in which to perform * the next lookup; */ diff --git a/src/vnet/dpo/mpls_disposition.h b/src/vnet/dpo/mpls_disposition.h index 9c3cc46ff30..86dd60ae290 100644 --- a/src/vnet/dpo/mpls_disposition.h +++ b/src/vnet/dpo/mpls_disposition.h @@ -27,6 +27,12 @@ typedef struct mpls_disp_dpo_t { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * Next DPO in the graph */ dpo_id_t mdd_dpo; diff --git a/src/vnet/dpo/mpls_label_dpo.h b/src/vnet/dpo/mpls_label_dpo.h index 98c88f7d812..4e032d33458 100644 --- a/src/vnet/dpo/mpls_label_dpo.h +++ b/src/vnet/dpo/mpls_label_dpo.h @@ -67,6 +67,12 @@ extern u8* format_mpls_label_dpo_flags(u8 *s, va_list *args); typedef struct mpls_label_dpo_t { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The MPLS label header to impose. Outer most label first. * Each DPO will occupy one cache line, stuff that many labels in. */ diff --git a/src/vnet/dpo/receive_dpo.h b/src/vnet/dpo/receive_dpo.h index 2420fd7843c..9ab86a824c6 100644 --- a/src/vnet/dpo/receive_dpo.h +++ b/src/vnet/dpo/receive_dpo.h @@ -26,6 +26,12 @@ typedef struct receive_dpo_t_ { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * The Software interface index on which traffic is received */ u32 rd_sw_if_index; diff --git a/src/vnet/dpo/replicate_dpo.h b/src/vnet/dpo/replicate_dpo.h index ccb25630e16..7b075394bc3 100644 --- a/src/vnet/dpo/replicate_dpo.h +++ b/src/vnet/dpo/replicate_dpo.h @@ -53,6 +53,12 @@ extern replicate_main_t replicate_main; */ typedef struct replicate_t_ { /** + * required for pool_get_aligned. + * memebers used in the switch path come first! + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * number of buckets in the replicate. */ u16 rep_n_buckets; diff --git a/src/vnet/fib/ip4_fib.c b/src/vnet/fib/ip4_fib.c index ef3324645c3..4ab6b1bcff6 100644 --- a/src/vnet/fib/ip4_fib.c +++ b/src/vnet/fib/ip4_fib.c @@ -108,7 +108,7 @@ ip4_create_fib_with_table_id (u32 table_id, ip4_fib_t *v4_fib; void *old_heap; - pool_get_aligned(ip4_main.fibs, fib_table, CLIB_CACHE_LINE_BYTES); + pool_get(ip4_main.fibs, fib_table); memset(fib_table, 0, sizeof(*fib_table)); old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap); diff --git a/src/vnet/fib/ip4_fib.h b/src/vnet/fib/ip4_fib.h index 84800eb2397..7fc2d3f53c9 100644 --- a/src/vnet/fib/ip4_fib.h +++ b/src/vnet/fib/ip4_fib.h @@ -57,6 +57,8 @@ typedef struct ip4_fib_t_ u32 fwd_classify_table_index; u32 rev_classify_table_index; + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); } ip4_fib_t; extern fib_node_index_t ip4_fib_table_lookup(const ip4_fib_t *fib, diff --git a/src/vnet/fib/ip6_fib.c b/src/vnet/fib/ip6_fib.c index fa9eb112986..da2f1ea3368 100644 --- a/src/vnet/fib/ip6_fib.c +++ b/src/vnet/fib/ip6_fib.c @@ -60,7 +60,7 @@ create_fib_with_table_id (u32 table_id, fib_table_t *fib_table; ip6_fib_t *v6_fib; - pool_get_aligned(ip6_main.fibs, fib_table, CLIB_CACHE_LINE_BYTES); + pool_get(ip6_main.fibs, fib_table); pool_get_aligned(ip6_main.v6_fibs, v6_fib, CLIB_CACHE_LINE_BYTES); memset(fib_table, 0, sizeof(*fib_table)); diff --git a/src/vnet/fib/mpls_fib.c b/src/vnet/fib/mpls_fib.c index 15931203122..223a0ddd753 100644 --- a/src/vnet/fib/mpls_fib.c +++ b/src/vnet/fib/mpls_fib.c @@ -92,7 +92,7 @@ mpls_fib_create_with_table_id (u32 table_id, mpls_fib_t *mf; int i; - pool_get_aligned(mpls_main.fibs, fib_table, CLIB_CACHE_LINE_BYTES); + pool_get(mpls_main.fibs, fib_table); pool_get_aligned(mpls_main.mpls_fibs, mf, CLIB_CACHE_LINE_BYTES); ASSERT((fib_table - mpls_main.fibs) == diff --git a/src/vnet/fib/mpls_fib.h b/src/vnet/fib/mpls_fib.h index 9e0c7d76ff8..8d18b008b0e 100644 --- a/src/vnet/fib/mpls_fib.h +++ b/src/vnet/fib/mpls_fib.h @@ -41,6 +41,11 @@ typedef struct mpls_fib_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * A hash table of entries. 21 bit key * Hash table for reduced memory footprint */ diff --git a/src/vnet/geneve/geneve.h b/src/vnet/geneve/geneve.h index cce57c8873b..8f028df517f 100644 --- a/src/vnet/geneve/geneve.h +++ b/src/vnet/geneve/geneve.h @@ -75,6 +75,9 @@ typedef CLIB_PACKED (struct typedef struct { + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + /* Rewrite string. $$$$ embed vnet_rewrite header */ u8 *rewrite; diff --git a/src/vnet/gre/gre.h b/src/vnet/gre/gre.h index b3b0b545190..416ab300877 100644 --- a/src/vnet/gre/gre.h +++ b/src/vnet/gre/gre.h @@ -176,6 +176,11 @@ typedef struct typedef struct { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + + /** * Linkage into the FIB object graph */ fib_node_t node; diff --git a/src/vnet/ip/ip6.h b/src/vnet/ip/ip6.h index 359c461d1e0..4b24774c277 100644 --- a/src/vnet/ip/ip6.h +++ b/src/vnet/ip/ip6.h @@ -66,6 +66,9 @@ typedef struct typedef struct { + /* required for pool_get_aligned. */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + /* Table ID (hash key) for this FIB. */ u32 table_id; diff --git a/src/vnet/ip/ip_source_and_port_range_check.h b/src/vnet/ip/ip_source_and_port_range_check.h index b04fe613d1c..ece2ec216e4 100644 --- a/src/vnet/ip/ip_source_and_port_range_check.h +++ b/src/vnet/ip/ip_source_and_port_range_check.h @@ -102,6 +102,11 @@ typedef struct typedef struct protocol_port_range_dpo_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + + /** * The number of blocks from the 'block' array below * that have rnages configured. We keep this count so that in the data-path * we can limit the loop to be only over the blocks we need diff --git a/src/vnet/ipip/ipip.h b/src/vnet/ipip/ipip.h index e9277d8a061..f52094f1f0c 100644 --- a/src/vnet/ipip/ipip.h +++ b/src/vnet/ipip/ipip.h @@ -68,6 +68,9 @@ typedef enum */ typedef struct { + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + ipip_mode_t mode; ipip_transport_t transport; ipip_tunnel_key_t *key; diff --git a/src/vnet/ipsec-gre/ipsec_gre.h b/src/vnet/ipsec-gre/ipsec_gre.h index 5d56b4e1e1f..caf2ecf8b30 100644 --- a/src/vnet/ipsec-gre/ipsec_gre.h +++ b/src/vnet/ipsec-gre/ipsec_gre.h @@ -49,6 +49,8 @@ typedef enum */ typedef struct { + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); ip4_address_t tunnel_src; /**< tunnel IPv4 src address */ ip4_address_t tunnel_dst; /**< tunnel IPv4 dst address */ u32 local_sa; /**< local IPSec SA index */ diff --git a/src/vnet/ipsec/ipsec.h b/src/vnet/ipsec/ipsec.h index 0269eb05261..bf9fab2c42c 100644 --- a/src/vnet/ipsec/ipsec.h +++ b/src/vnet/ipsec/ipsec.h @@ -242,6 +242,8 @@ typedef struct typedef struct { + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); u32 input_sa_index; u32 output_sa_index; u32 hw_if_index; diff --git a/src/vnet/map/map.h b/src/vnet/map/map.h index 5700cc1c191..c304a1ea38a 100644 --- a/src/vnet/map/map.h +++ b/src/vnet/map/map.h @@ -80,6 +80,8 @@ typedef enum */ typedef struct { + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); ip6_address_t ip6_src; ip6_address_t ip6_prefix; ip6_address_t *rules; diff --git a/src/vnet/mfib/mfib_itf.h b/src/vnet/mfib/mfib_itf.h index fe39c895d8b..295be1b20e5 100644 --- a/src/vnet/mfib/mfib_itf.h +++ b/src/vnet/mfib/mfib_itf.h @@ -25,6 +25,11 @@ typedef struct mfib_itf_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * @brief Forwarding Flags on the entry - checked in the data-path */ mfib_itf_flags_t mfi_flags; diff --git a/src/vnet/mfib/mfib_table.h b/src/vnet/mfib/mfib_table.h index 63af25b0151..b8ade8b5cd9 100644 --- a/src/vnet/mfib/mfib_table.h +++ b/src/vnet/mfib/mfib_table.h @@ -35,6 +35,11 @@ typedef struct mfib_table_t_ { /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + + /** * A union of the protocol specific FIBs that provide the * underlying LPM mechanism. * This element is first in the struct so that it is in the diff --git a/src/vnet/qos/qos_egress_map.h b/src/vnet/qos/qos_egress_map.h index f4b282cb7ba..92baf6bf3b2 100644 --- a/src/vnet/qos/qos_egress_map.h +++ b/src/vnet/qos/qos_egress_map.h @@ -36,10 +36,15 @@ typedef u32 qos_egress_map_id_t; */ typedef struct qos_egress_map_t_ { - /** - * The array of output mapped values; - * output = eq_qos[input-source][input-value] - */ + /** + * Required for pool_get_aligned + */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + + /** + * The array of output mapped values; + * output = eq_qos[input-source][input-value] + */ qos_bits_t qem_output[QOS_N_SOURCES][256]; } qos_egress_map_t; diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h index ffe3e1b195f..5f19566d240 100644 --- a/src/vnet/sctp/sctp.h +++ b/src/vnet/sctp/sctp.h @@ -192,6 +192,9 @@ typedef struct _sctp_user_configuration typedef struct _sctp_connection { + /** Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + sctp_sub_connection_t sub_conn[MAX_SCTP_CONNECTIONS]; /**< Common transport data. First! */ sctp_user_configuration_t conn_config; /**< Allows tuning of some SCTP behaviors */ diff --git a/src/vnet/session/session_table.h b/src/vnet/session/session_table.h index 31b1f647e23..f7f8c91b26c 100644 --- a/src/vnet/session/session_table.h +++ b/src/vnet/session/session_table.h @@ -49,6 +49,8 @@ typedef struct _session_lookup_table * byproduct of fib table ids not necessarily being the same for * identical fib idices of v4 and v6 fib protos */ u8 active_fib_proto; + /* Required for pool_get_aligned(...) */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); } session_table_t; #define SESSION_TABLE_INVALID_INDEX ((u32)~0) diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h index 8e3ab9ec59e..c60dea07114 100644 --- a/src/vnet/udp/udp.h +++ b/src/vnet/udp/udp.h @@ -36,6 +36,8 @@ typedef enum typedef struct { + /** Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); transport_connection_t connection; /**< must be first */ clib_spinlock_t rx_lock; /**< rx fifo lock */ u8 is_connected; /**< connected mode */ diff --git a/src/vnet/vxlan-gpe/vxlan_gpe.h b/src/vnet/vxlan-gpe/vxlan_gpe.h index 8c0d37eb07a..794ed7ef706 100644 --- a/src/vnet/vxlan-gpe/vxlan_gpe.h +++ b/src/vnet/vxlan-gpe/vxlan_gpe.h @@ -101,6 +101,9 @@ typedef CLIB_PACKED(struct { */ typedef struct { + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + /** Rewrite string. $$$$ embed vnet_rewrite header */ u8 *rewrite; diff --git a/src/vnet/vxlan/vxlan.h b/src/vnet/vxlan/vxlan.h index 8fb031d4af5..3c74bfd4e8e 100644 --- a/src/vnet/vxlan/vxlan.h +++ b/src/vnet/vxlan/vxlan.h @@ -66,6 +66,9 @@ typedef CLIB_PACKED(struct { }) vxlan6_tunnel_key_t; typedef struct { + /* Required for pool_get_aligned */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); + /* FIB DPO for IP forwarding of VXLAN encap packet */ dpo_id_t next_dpo; |