10bfe5d8cSNeale Ranns/*
20bfe5d8cSNeale Ranns * Copyright (c) 2016 Cisco and/or its affiliates.
30bfe5d8cSNeale Ranns * Licensed under the Apache License, Version 2.0 (the "License");
40bfe5d8cSNeale Ranns * you may not use this file except in compliance with the License.
50bfe5d8cSNeale Ranns * You may obtain a copy of the License at:
60bfe5d8cSNeale Ranns *
70bfe5d8cSNeale Ranns *     http://www.apache.org/licenses/LICENSE-2.0
80bfe5d8cSNeale Ranns *
90bfe5d8cSNeale Ranns * Unless required by applicable law or agreed to in writing, software
100bfe5d8cSNeale Ranns * distributed under the License is distributed on an "AS IS" BASIS,
110bfe5d8cSNeale Ranns * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120bfe5d8cSNeale Ranns * See the License for the specific language governing permissions and
130bfe5d8cSNeale Ranns * limitations under the License.
140bfe5d8cSNeale Ranns */
150bfe5d8cSNeale Ranns
160bfe5d8cSNeale Ranns#include <vnet/dpo/dpo.h>
170bfe5d8cSNeale Ranns#include <vnet/lisp-gpe/lisp_gpe.h>
180bfe5d8cSNeale Ranns#include <vnet/lisp-cp/control.h>
190bfe5d8cSNeale Ranns
205e575b1dSNeale Ranns/**
215e575b1dSNeale Ranns * The static array of LISP punt DPOs
225e575b1dSNeale Ranns */
235e575b1dSNeale Rannsstatic dpo_id_t lisp_cp_dpos[DPO_PROTO_NUM];
245e575b1dSNeale Ranns
255e575b1dSNeale Rannsconst dpo_id_t *
265e575b1dSNeale Rannslisp_cp_dpo_get (dpo_proto_t proto)
270bfe5d8cSNeale Ranns{
285e575b1dSNeale Ranns  /*
295e575b1dSNeale Ranns   * there are only two instances of this DPO type.
305e575b1dSNeale Ranns   * we can use the protocol as the index
315e575b1dSNeale Ranns   */
325e575b1dSNeale Ranns  return (&lisp_cp_dpos[proto]);
330bfe5d8cSNeale Ranns}
340bfe5d8cSNeale Ranns
355e575b1dSNeale Rannsstatic u8 *
365e575b1dSNeale Rannsformat_lisp_cp_dpo (u8 * s, va_list * args)
370bfe5d8cSNeale Ranns{
385e575b1dSNeale Ranns  index_t index = va_arg (*args, index_t);
395e575b1dSNeale Ranns  CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
400bfe5d8cSNeale Ranns
415e575b1dSNeale Ranns  return (format (s, "lisp-cp-punt-%U", format_dpo_proto, index));
420bfe5d8cSNeale Ranns}
430bfe5d8cSNeale Ranns
440bfe5d8cSNeale Rannsstatic void
455e575b1dSNeale Rannslisp_cp_dpo_lock (dpo_id_t * dpo)
460bfe5d8cSNeale Ranns{
470bfe5d8cSNeale Ranns}
480bfe5d8cSNeale Ranns
490bfe5d8cSNeale Rannsstatic void
505e575b1dSNeale Rannslisp_cp_dpo_unlock (dpo_id_t * dpo)
510bfe5d8cSNeale Ranns{
520bfe5d8cSNeale Ranns}
530bfe5d8cSNeale Ranns
540bfe5d8cSNeale Rannsconst static dpo_vft_t lisp_cp_vft = {
555e575b1dSNeale Ranns  .dv_lock = lisp_cp_dpo_lock,
565e575b1dSNeale Ranns  .dv_unlock = lisp_cp_dpo_unlock,
575e575b1dSNeale Ranns  .dv_format = format_lisp_cp_dpo,
580bfe5d8cSNeale Ranns};
590bfe5d8cSNeale Ranns
600bfe5d8cSNeale Ranns/**
610bfe5d8cSNeale Ranns * @brief The per-protocol VLIB graph nodes that are assigned to a LISP-CP
620bfe5d8cSNeale Ranns *        object.
630bfe5d8cSNeale Ranns *
640bfe5d8cSNeale Ranns * this means that these graph nodes are ones from which a LISP-CP is the
650bfe5d8cSNeale Ranns * parent object in the DPO-graph.
660bfe5d8cSNeale Ranns */
675e575b1dSNeale Rannsconst static char *const lisp_cp_ip4_nodes[] = {
685e575b1dSNeale Ranns  "lisp-cp-lookup-ip4",
695e575b1dSNeale Ranns  NULL,
700bfe5d8cSNeale Ranns};
715e575b1dSNeale Ranns
725e575b1dSNeale Rannsconst static char *const lisp_cp_ip6_nodes[] = {
735e575b1dSNeale Ranns  "lisp-cp-lookup-ip6",
745e575b1dSNeale Ranns  NULL,
750bfe5d8cSNeale Ranns};
760bfe5d8cSNeale Ranns
775e575b1dSNeale Rannsconst static char *const lisp_cp_ethernet_nodes[] = {
785e575b1dSNeale Ranns  "lisp-cp-lookup-l2",
795e575b1dSNeale Ranns  NULL,
805e575b1dSNeale Ranns};
815e575b1dSNeale Ranns
82ce1b4c7fSFlorin Corasconst static char *const lisp_cp_nsh_nodes[] = {
83ce1b4c7fSFlorin Coras  "lisp-cp-lookup-nsh",
84ce1b4c7fSFlorin Coras  NULL,
85ce1b4c7fSFlorin Coras};
865e575b1dSNeale Ranns
875e575b1dSNeale Rannsconst static char *const *const lisp_cp_nodes[DPO_PROTO_NUM] = {
885e575b1dSNeale Ranns  [DPO_PROTO_IP4] = lisp_cp_ip4_nodes,
895e575b1dSNeale Ranns  [DPO_PROTO_IP6] = lisp_cp_ip6_nodes,
905e575b1dSNeale Ranns  [DPO_PROTO_ETHERNET] = lisp_cp_ethernet_nodes,
915e575b1dSNeale Ranns  [DPO_PROTO_MPLS] = NULL,
92ce1b4c7fSFlorin Coras  [DPO_PROTO_NSH] = lisp_cp_nsh_nodes,
930bfe5d8cSNeale Ranns};
940bfe5d8cSNeale Ranns
950bfe5d8cSNeale Rannsclib_error_t *
960bfe5d8cSNeale Rannslisp_cp_dpo_module_init (vlib_main_t * vm)
970bfe5d8cSNeale Ranns{
985e575b1dSNeale Ranns  dpo_proto_t dproto;
995e575b1dSNeale Ranns
1005e575b1dSNeale Ranns  /*
1015e575b1dSNeale Ranns   * there are no exit arcs from the LIS-CP VLIB node, so we
1025e575b1dSNeale Ranns   * pass NULL as said node array.
1035e575b1dSNeale Ranns   */
1045e575b1dSNeale Ranns  dpo_register (DPO_LISP_CP, &lisp_cp_vft, lisp_cp_nodes);
1055e575b1dSNeale Ranns
1065e575b1dSNeale Ranns  FOR_EACH_DPO_PROTO (dproto)
1075e575b1dSNeale Ranns  {
1085e575b1dSNeale Ranns    dpo_set (&lisp_cp_dpos[dproto], DPO_LISP_CP, dproto, dproto);
1095e575b1dSNeale Ranns  }
1100bfe5d8cSNeale Ranns
1115e575b1dSNeale Ranns  return (NULL);
1120bfe5d8cSNeale Ranns}
1130bfe5d8cSNeale Ranns
1145e575b1dSNeale RannsVLIB_INIT_FUNCTION (lisp_cp_dpo_module_init);
1155e575b1dSNeale Ranns
1165e575b1dSNeale Ranns/*
1175e575b1dSNeale Ranns * fd.io coding-style-patch-verification: ON
1185e575b1dSNeale Ranns *
1195e575b1dSNeale Ranns * Local Variables:
1205e575b1dSNeale Ranns * eval: (c-set-style "gnu")
1215e575b1dSNeale Ranns * End:
1225e575b1dSNeale Ranns */