summaryrefslogtreecommitdiffstats
path: root/src/vlibapi/api.h
AgeCommit message (Expand)AuthorFilesLines
2018-06-13Stat segment / client: show run" works nowDave Barach1-1/+1
2018-01-09api: refactor vlibmemoryFlorin Coras1-9/+7
2017-10-09vppapigen: support per-file (major,minor,patch) version stampsDave Barach1-0/+2
2017-07-01Refactor API message handling codeKlement Sekera1-255/+25
2017-06-01Improve fifo allocator performanceDave Barach1-0/+3
2017-05-17Add vl_msg_api_get_message_length[_inline]Dave Barach1-0/+11
2017-05-03A sprinkling of const in vlibmemory/api.h and friendsNeale Ranns1-5/+6
2017-03-14Clean up dead API client reaper callack schemeDave Barach1-0/+44
2017-03-09vlib_mains == 0 special cases be goneDave Barach1-1/+3
2017-03-03Improve api trace replay consistency checkingDave Barach1-0/+3
2017-03-02Clean up binary api message handler registration issuesDave Barach1-0/+15
2017-01-09Self-service garbage collection for the API message allocatorDave Barach1-1/+2
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+281
0; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __BIER_BIT_STRING_H__
#define __BIER_BIT_STRING_H__

#include <vppinfra/byte_order.h>
#include <vppinfra/format.h>

#include <vnet/bier/bier_types.h>

#define BIER_BBS_LEN_TO_BUCKETS(_len) (_len)
#define BIER_BBS_LEN_TO_BITS(_len) (_len * 8)
#define BIER_BBS_LEN_TO_INTS(_len) ((_len) / sizeof(int))
#define BIER_BIT_MASK_BITS_PER_INT (sizeof(int) * 8)

/*
 * bier_find_first_bit_set
 *
 * find the position of the first bit set in a long
 */
static inline int
bier_find_first_bit_string_set (int mask)
{
    return (__builtin_ffs(clib_net_to_host_u32(mask)));
}

extern void bier_bit_string_set_bit(bier_bit_string_t *mask,
                                    bier_bp_t bp);


extern void bier_bit_string_clear_bit(bier_bit_string_t *mask,
                                      bier_bp_t bp);


extern u8 *format_bier_bit_string(u8 * s, va_list * args);

#define BIER_BBS_NUM_INT_BUKCETS(_bbs) \
    (BIER_BBS_LEN_TO_BUCKETS(_bbs->bbs_len) / sizeof(int))

always_inline int
bier_bit_string_is_zero (const bier_bit_string_t *src)
{
    u16 index;

    for (index = 0;
         index < BIER_BBS_NUM_INT_BUKCETS(src);
         index++) {
        if (((int*)src->bbs_buckets)[index] != 0) {
            return (0);
        }
    }
    return (1);
}

always_inline void
bier_bit_string_clear_string (const bier_bit_string_t *src,
                              bier_bit_string_t *dest)
{
    u16 index;

    ASSERT(src->bbs_len == dest->bbs_len);

    for (index = 0;
         index < BIER_BBS_NUM_INT_BUKCETS(src);
         index++) {
        ((int*)dest->bbs_buckets)[index] &= ~(((int*)src->bbs_buckets)[index]);
    }
}

always_inline void
bier_bit_string_logical_and_string (const bier_bit_string_t *src,
                                    bier_bit_string_t *dest)
{
    u16 index;

    ASSERT(src->bbs_len == dest->bbs_len);

    for (index = 0;
         index < BIER_BBS_NUM_INT_BUKCETS(src);
         index++) {
        ((int*)dest->bbs_buckets)[index] &= ((int*)src->bbs_buckets)[index];
    }
}

always_inline void
bier_bit_string_init (bier_bit_string_t *bbs,
                      bier_hdr_len_id_t len,
                      bier_bit_mask_bucket_t *buckets)
{
    bbs->bbs_len = bier_hdr_len_id_to_num_bytes(len);
    bbs->bbs_buckets = buckets;
}

#endif