abf_itf_attach.h revision 669d07dc
1/*
2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __ABF_ITF_ATTACH_H__
17#define __ABF_ITF_ATTACH_H__
18
19#include <plugins/abf/abf_policy.h>
20#include <vnet/fib/fib_path_list.h>
21
22/**
23 * Attachment data for an ABF policy to an interface
24 */
25typedef struct abf_itf_attach_t_
26{
27  CLIB_CACHE_LINE_ALIGN_MARK (marker);
28  /**
29   * The ACL and DPO are cached for fast DP access
30   */
31  /**
32   * ACL index to match
33   */
34  u32 aia_acl;
35
36  /**
37   * The DPO actually used for forwarding
38   */
39  dpo_id_t aia_dpo;
40
41  /**
42   * Linkage into the FIB graph
43   */
44  fib_node_t aia_node;
45
46  /**
47   * The VPP index of the ABF policy
48   */
49  u32 aia_abf;
50
51  /**
52   * Sibling index on the policy's path list
53   */
54  u32 aia_sibling;
55
56  /**
57   * The protocol for the attachment. i.e. the protocol
58   * of the packets that are being forwarded
59   */
60  fib_protocol_t aia_proto;
61
62  /**
63   * The interface for the attachment
64   */
65  u32 aia_sw_if_index;
66
67  /**
68   * The priority of this policy for attachment.
69   * The lower the value the higher the priority.
70   * The higher priority policies are matched first.
71   */
72  u32 aia_prio;
73} abf_itf_attach_t;
74
75/**
76 * Pool of ABF interface attachment objects
77 */
78extern abf_itf_attach_t *abf_itf_attach_pool;
79
80static inline abf_itf_attach_t *
81abf_itf_attach_get (u32 index)
82{
83  return (pool_elt_at_index (abf_itf_attach_pool, index));
84}
85
86extern int abf_itf_attach (fib_protocol_t fproto,
87			   u32 policy_id, u32 priority, u32 sw_if_index);
88
89extern int abf_itf_detach (fib_protocol_t fproto,
90			   u32 policy_id, u32 sw_if_index);
91
92typedef int (*abf_itf_attach_walk_cb_t) (index_t aii, void *ctx0);
93
94extern void abf_itf_attach_walk (abf_itf_attach_walk_cb_t cb, void *ctx);
95
96/*
97 * fd.io coding-style-patch-verification: ON
98 *
99 * Local Variables:
100 * eval: (c-set-style "gnu")
101 * End:
102 */
103
104#endif
105