summaryrefslogtreecommitdiffstats
path: root/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-02-06 00:54:12 +0100
committerGerrit Code Review <gerrit@fd.io>2016-02-14 00:02:31 +0000
commitcfb2d804ce4a9262577c63b9c0245d45b2335e64 (patch)
tree1a2a0724261fc014cb654e80e57d364bd6840959 /vlib
parent161781988918e2403c0fb1e7f6ebe0d3051985b4 (diff)
Make size of per-thread mini counter vector equal to number of threads
Change-Id: Icfd91cca3cd686e5efa8a988f04483238605e1cb Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vlib')
-rw-r--r--vlib/vlib/counter.c26
-rw-r--r--vlib/vlib/counter.h42
2 files changed, 30 insertions, 38 deletions
diff --git a/vlib/vlib/counter.c b/vlib/vlib/counter.c
index 1b94884e319..9c5e0db8427 100644
--- a/vlib/vlib/counter.c
+++ b/vlib/vlib/counter.c
@@ -44,7 +44,7 @@ void vlib_clear_simple_counters (vlib_simple_counter_main_t * cm)
uword i, j;
u16 * my_minis;
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
+ for (i = 0; i < vec_len(cm->minis); i++)
{
my_minis = cm->minis[i];
@@ -67,7 +67,7 @@ void vlib_clear_combined_counters (vlib_combined_counter_main_t * cm)
uword i, j;
vlib_mini_counter_t * my_minis;
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
+ for (i = 0; i < vec_len(cm->minis); i++)
{
my_minis = cm->minis[i];
@@ -92,6 +92,28 @@ void vlib_clear_combined_counters (vlib_combined_counter_main_t * cm)
}
}
+void vlib_validate_simple_counter (vlib_simple_counter_main_t *cm, u32 index)
+{
+ vlib_thread_main_t * tm = vlib_get_thread_main();
+ int i;
+
+ vec_validate (cm->minis, tm->n_vlib_mains - 1);
+ for (i = 0; i < tm->n_vlib_mains; i++)
+ vec_validate_aligned (cm->minis[i], index, CLIB_CACHE_LINE_BYTES);
+ vec_validate_aligned (cm->maxi, index, CLIB_CACHE_LINE_BYTES);
+}
+
+void vlib_validate_combined_counter (vlib_combined_counter_main_t *cm, u32 index)
+{
+ vlib_thread_main_t * tm = vlib_get_thread_main();
+ int i;
+
+ vec_validate (cm->minis, tm->n_vlib_mains - 1);
+ for (i = 0; i < tm->n_vlib_mains ; i++)
+ vec_validate_aligned (cm->minis[i], index, CLIB_CACHE_LINE_BYTES);
+ vec_validate_aligned (cm->maxi, index, CLIB_CACHE_LINE_BYTES);
+}
+
void serialize_vlib_simple_counter_main (serialize_main_t * m, va_list * va)
{
clib_warning ("unimplemented");
diff --git a/vlib/vlib/counter.h b/vlib/vlib/counter.h
index 804757173bb..8db999c3a94 100644
--- a/vlib/vlib/counter.h
+++ b/vlib/vlib/counter.h
@@ -45,7 +45,6 @@
* the CPU configuration is available, so we have to
* preallocate the mini-counter per-cpu vectors
*/
-#define VLIB_COUNTER_MAX_CPUS 32
typedef struct {
/* Compact counters that (rarely) can overflow. */
@@ -101,7 +100,7 @@ vlib_get_simple_counter (vlib_simple_counter_main_t * cm, u32 index)
v = 0;
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
+ for (i = 0; i < vec_len(cm->minis); i++)
{
my_minis = cm->minis[i];
mini = vec_elt_at_index (my_minis, index);
@@ -127,7 +126,7 @@ vlib_zero_simple_counter (vlib_simple_counter_main_t * cm, u32 index)
ASSERT (index < vec_len (cm->maxi));
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
+ for (i = 0; i < vec_len(cm->minis); i++)
{
my_minis = cm->minis[i];
my_minis[index] = 0;
@@ -257,7 +256,7 @@ vlib_get_combined_counter (vlib_combined_counter_main_t * cm,
result->packets = 0;
result->bytes = 0;
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
+ for (i = 0; i < vec_len(cm->minis); i++)
{
my_minis = cm->minis[i];
@@ -281,7 +280,7 @@ vlib_zero_combined_counter (vlib_combined_counter_main_t * cm,
vlib_mini_counter_t * mini, * my_minis;
int i;
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
+ for (i = 0; i < vec_len(cm->minis); i++)
{
my_minis = cm->minis[i];
@@ -295,37 +294,8 @@ vlib_zero_combined_counter (vlib_combined_counter_main_t * cm,
vlib_counter_zero (&cm->value_at_last_clear[index]);
}
-/* Initialize/allocate given counter index.
- Works for both simple and combined counters. */
-#define vlib_validate_counter_DEPRECATED(cm,index) \
- do { \
- int i; \
- \
- vec_validate ((cm)->minis, VLIB_COUNTER_MAX_CPUS-1); \
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++) \
- vec_validate ((cm)->minis[i], (index)); \
- vec_validate ((cm)->maxi, (index)); \
- } while (0)
-
-static inline void
-vlib_validate_simple_counter (vlib_simple_counter_main_t *cm, u32 index)
-{
- int i;
- vec_validate (cm->minis, VLIB_COUNTER_MAX_CPUS-1);
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
- vec_validate_aligned (cm->minis[i], index, CLIB_CACHE_LINE_BYTES);
- vec_validate_aligned (cm->maxi, index, CLIB_CACHE_LINE_BYTES);
-}
-
-static inline void
-vlib_validate_combined_counter (vlib_combined_counter_main_t *cm, u32 index)
-{
- int i;
- vec_validate (cm->minis, VLIB_COUNTER_MAX_CPUS-1);
- for (i = 0; i < VLIB_COUNTER_MAX_CPUS; i++)
- vec_validate_aligned (cm->minis[i], index, CLIB_CACHE_LINE_BYTES);
- vec_validate_aligned (cm->maxi, index, CLIB_CACHE_LINE_BYTES);
-}
+void vlib_validate_simple_counter (vlib_simple_counter_main_t *cm, u32 index);
+void vlib_validate_combined_counter (vlib_combined_counter_main_t *cm, u32 index);
/* Number of simple/combined counters allocated. */
#define vlib_counter_len(cm) vec_len((cm)->maxi)
* * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef included_ip_ip6_error_h #define included_ip_ip6_error_h #define foreach_ip6_error \ /* Must be first. */ \ _ (NONE, "valid ip6 packets") \ \ /* Errors signalled by ip6-input */ \ _ (TOO_SHORT, "ip6 length < 40 bytes") \ _ (BAD_LENGTH, "ip6 length > l2 length") \ _ (VERSION, "ip6 version != 6") \ _ (TIME_EXPIRED, "ip6 ttl <= 1") \ \ /* Errors signalled by ip6-rewrite. */ \ _ (MTU_EXCEEDED, "ip6 MTU exceeded") \ _ (DST_LOOKUP_MISS, "ip6 destination lookup miss") \ _ (SRC_LOOKUP_MISS, "ip6 source lookup miss") \ _ (DROP, "ip6 drop") \ _ (PUNT, "ip6 punt") \ \ /* Errors signalled by ip6-local. */ \ _ (UNKNOWN_PROTOCOL, "unknown ip protocol") \ _ (UDP_CHECKSUM, "bad udp checksum") \ _ (ICMP_CHECKSUM, "bad icmp checksum") \ _ (UDP_LENGTH, "inconsistent udp/ip lengths") \ \ /* Errors signalled by udp6-lookup. */ \ _ (UNKNOWN_UDP_PORT, "no listener for udp port") \ \ /* Spoofed packets in ip6-rewrite-local */ \ _(SPOOFED_LOCAL_PACKETS, "ip4 spoofed local-address packet drops") \ \ /* Erros singalled by ip6-inacl */ \ _ (INACL_TABLE_MISS, "input ACL table-miss drops") \ _ (INACL_SESSION_DENY, "input ACL session deny drops") \ /* Erros singalled by ip6-outacl */ \ _ (OUTACL_TABLE_MISS, "output ACL table-miss drops") \ _ (OUTACL_SESSION_DENY, "output ACL session deny drops") \ \ /* Errors signalled by ip6-reassembly */ \ _ (REASS_MISSING_UPPER, "missing-upper layer drops") \ _ (REASS_DUPLICATE_FRAGMENT, "duplicate fragments") \ _ (REASS_OVERLAPPING_FRAGMENT, "overlapping fragments") \ _ (REASS_LIMIT_REACHED, "drops due to concurrent reassemblies limit") \ _ (REASS_TIMEOUT, "fragments dropped due to reassembly timeout") typedef enum { #define _(sym,str) IP6_ERROR_##sym, foreach_ip6_error #undef _ IP6_N_ERROR, } ip6_error_t; #endif /* included_ip_ip6_error_h */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */