11dbcf30bSNeale Ranns/*
21dbcf30bSNeale Ranns * Copyright (c) 2019 Cisco and/or its affiliates.
31dbcf30bSNeale Ranns * Licensed under the Apache License, Version 2.0 (the "License");
41dbcf30bSNeale Ranns * you may not use this file except in compliance with the License.
51dbcf30bSNeale Ranns * You may obtain a copy of the License at:
61dbcf30bSNeale Ranns *
71dbcf30bSNeale Ranns *     http://www.apache.org/licenses/LICENSE-2.0
81dbcf30bSNeale Ranns *
91dbcf30bSNeale Ranns * Unless required by applicable law or agreed to in writing, software
101dbcf30bSNeale Ranns * distributed under the License is distributed on an "AS IS" BASIS,
111dbcf30bSNeale Ranns * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121dbcf30bSNeale Ranns * See the License for the specific language governing permissions and
131dbcf30bSNeale Ranns * limitations under the License.
141dbcf30bSNeale Ranns */
151dbcf30bSNeale Ranns
161dbcf30bSNeale Ranns#ifndef __PW_CW_DPO_H__
171dbcf30bSNeale Ranns#define __PW_CW_DPO_H__
181dbcf30bSNeale Ranns
191dbcf30bSNeale Ranns#include <vnet/vnet.h>
201dbcf30bSNeale Ranns#include <vnet/mpls/packet.h>
211dbcf30bSNeale Ranns#include <vnet/dpo/dpo.h>
221dbcf30bSNeale Ranns
231dbcf30bSNeale Ranns/**
241dbcf30bSNeale Ranns * A Psuedo Wire Control Word is 4 bytes
251dbcf30bSNeale Ranns */
261dbcf30bSNeale Rannstypedef u32 pw_cw_t;
271dbcf30bSNeale Ranns
281dbcf30bSNeale Ranns/**
291dbcf30bSNeale Ranns * A representation of a Psuedo Wire Control Word pop DPO
301dbcf30bSNeale Ranns */
311dbcf30bSNeale Rannstypedef struct pw_cw_dpo_t
321dbcf30bSNeale Ranns{
331dbcf30bSNeale Ranns    /**
341dbcf30bSNeale Ranns     * Next DPO in the graph
351dbcf30bSNeale Ranns     */
361dbcf30bSNeale Ranns    dpo_id_t pwcw_parent;
371dbcf30bSNeale Ranns
381dbcf30bSNeale Ranns    /**
391dbcf30bSNeale Ranns     * Number of locks/users of the label
401dbcf30bSNeale Ranns     */
411dbcf30bSNeale Ranns    u16 pwcw_locks;
421dbcf30bSNeale Ranns} pw_cw_dpo_t;
431dbcf30bSNeale Ranns
441dbcf30bSNeale Ranns/**
451dbcf30bSNeale Ranns * @brief Assert that the MPLS label object is less than a cache line in size.
461dbcf30bSNeale Ranns * Should this get any bigger then we will need to reconsider how many labels
471dbcf30bSNeale Ranns * can be pushed in one object.
481dbcf30bSNeale Ranns */
491dbcf30bSNeale RannsSTATIC_ASSERT_SIZEOF(pw_cw_dpo_t, 2 * sizeof(u64));
501dbcf30bSNeale Ranns
511dbcf30bSNeale Ranns/* #define STATIC_ASSERT_ALIGNOF(d, s)                                      \ */
521dbcf30bSNeale Ranns/*     STATIC_ASSERT (alignof (d) == sizeof(s), "Align of " #d " must be " # s " bytes") */
531dbcf30bSNeale Ranns
541dbcf30bSNeale Ranns/* STATIC_ASSERT_AIGNOF(pw_cw_dpo_t, u64); */
551dbcf30bSNeale Ranns
561dbcf30bSNeale Ranns/**
571dbcf30bSNeale Ranns * @brief Create an PW CW pop
581dbcf30bSNeale Ranns *
591dbcf30bSNeale Ranns * @param parent The parent of the created MPLS label object
601dbcf30bSNeale Ranns * @param dpo The PW CW DPO created
611dbcf30bSNeale Ranns */
621dbcf30bSNeale Rannsextern void pw_cw_dpo_create(const dpo_id_t *paremt,
631dbcf30bSNeale Ranns                             dpo_id_t *dpo);
641dbcf30bSNeale Ranns
651dbcf30bSNeale Rannsextern u8* format_pw_cw_dpo(u8 *s, va_list *args);
661dbcf30bSNeale Ranns
671dbcf30bSNeale Ranns/*
681dbcf30bSNeale Ranns * Encapsulation violation for fast data-path access
691dbcf30bSNeale Ranns */
701dbcf30bSNeale Rannsextern pw_cw_dpo_t *pw_cw_dpo_pool;
711dbcf30bSNeale Ranns
721dbcf30bSNeale Rannsstatic inline pw_cw_dpo_t *
731dbcf30bSNeale Rannspw_cw_dpo_get (index_t index)
741dbcf30bSNeale Ranns{
751dbcf30bSNeale Ranns    return (pool_elt_at_index(pw_cw_dpo_pool, index));
761dbcf30bSNeale Ranns}
771dbcf30bSNeale Ranns
781dbcf30bSNeale Rannsextern void pw_cw_dpo_module_init(void);
791dbcf30bSNeale Ranns
801dbcf30bSNeale Ranns#endif
81