]> git.proxmox.com Git - mirror_frr.git/blob - pathd/path_pcep_pcc.h
Merge pull request #12837 from donaldsharp/unlikely_routemap
[mirror_frr.git] / pathd / path_pcep_pcc.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2020 NetDEF, Inc.
4 */
5
6 #ifndef _PATH_PCEP_PCC_H_
7 #define _PATH_PCEP_PCC_H_
8
9 #include "typesafe.h"
10 #include "pathd/path_pcep.h"
11
12 enum pcc_status {
13 PCEP_PCC_INITIALIZED = 0,
14 PCEP_PCC_DISCONNECTED,
15 PCEP_PCC_CONNECTING,
16 PCEP_PCC_SYNCHRONIZING,
17 PCEP_PCC_OPERATING
18 };
19
20 PREDECL_HASH(plspid_map);
21 PREDECL_HASH(nbkey_map);
22 PREDECL_HASH(req_map);
23
24 struct plspid_map_data {
25 struct plspid_map_item mi;
26 struct lsp_nb_key nbkey;
27 uint32_t plspid;
28 };
29
30 struct nbkey_map_data {
31 struct nbkey_map_item mi;
32 struct lsp_nb_key nbkey;
33 uint32_t plspid;
34 };
35
36 struct req_map_data {
37 struct req_map_item mi;
38 struct lsp_nb_key nbkey;
39 uint32_t reqid;
40 };
41
42 struct req_entry {
43 RB_ENTRY(req_entry) entry;
44 struct event *t_retry;
45 int retry_count;
46 bool was_sent;
47 struct path *path;
48 };
49 RB_HEAD(req_entry_head, req_entry);
50 RB_PROTOTYPE(req_entry_head, req_entry, entry, req_entry_compare);
51
52 struct pcc_state {
53 int id;
54 char tag[MAX_TAG_SIZE];
55 enum pcc_status status;
56 uint16_t flags;
57 #define F_PCC_STATE_HAS_IPV4 0x0002
58 #define F_PCC_STATE_HAS_IPV6 0x0004
59 struct pcc_opts *pcc_opts;
60 struct pce_opts *pce_opts;
61 struct in_addr pcc_addr_v4;
62 struct in6_addr pcc_addr_v6;
63 /* PCC transport source address */
64 struct ipaddr pcc_addr_tr;
65 char *originator;
66 pcep_session *sess;
67 uint32_t retry_count;
68 bool synchronized;
69 struct event *t_reconnect;
70 struct event *t_update_best;
71 struct event *t_session_timeout;
72 uint32_t next_reqid;
73 uint32_t next_plspid;
74 struct plspid_map_head plspid_map;
75 struct nbkey_map_head nbkey_map;
76 struct req_map_head req_map;
77 struct req_entry_head requests;
78 struct pcep_caps caps;
79 bool is_best;
80 bool previous_best;
81 };
82
83 struct pcc_state *pcep_pcc_initialize(struct ctrl_state *ctrl_state,
84 int pcc_id);
85 void pcep_pcc_finalize(struct ctrl_state *ctrl_state,
86 struct pcc_state *pcc_state);
87 int pcep_pcc_enable(struct ctrl_state *ctrl_state, struct pcc_state *pcc_state);
88 int pcep_pcc_disable(struct ctrl_state *ctrl_state,
89 struct pcc_state *pcc_state);
90 int pcep_pcc_update(struct ctrl_state *ctrl_state, struct pcc_state *pcc_state,
91 struct pcc_opts *pcc_opts, struct pce_opts *pce_opts);
92 void pcep_pcc_reconnect(struct ctrl_state *ctrl_state,
93 struct pcc_state *pcc_state);
94 void pcep_pcc_pcep_event_handler(struct ctrl_state *ctrl_state,
95 struct pcc_state *pcc_state,
96 pcep_event *event);
97 void pcep_pcc_pathd_event_handler(struct ctrl_state *ctrl_state,
98 struct pcc_state *pcc_state,
99 enum pcep_pathd_event_type type,
100 struct path *path);
101 void pcep_pcc_timeout_handler(struct ctrl_state *ctrl_state,
102 struct pcc_state *pcc_state,
103 enum pcep_ctrl_timeout_type type, void *param);
104 void pcep_pcc_sync_path(struct ctrl_state *ctrl_state,
105 struct pcc_state *pcc_state, struct path *path);
106 void pcep_pcc_sync_done(struct ctrl_state *ctrl_state,
107 struct pcc_state *pcc_state);
108 /* Send a report explicitly. When doing so the PCC may send multiple reports
109 * due to expectations from vendors for the first report to be with a DOWN
110 * status. The parameter is_stable is used for that purpose as a hint wheter
111 * to expect an update for the report */
112 void pcep_pcc_send_report(struct ctrl_state *ctrl_state,
113 struct pcc_state *pcc_state, struct path *path,
114 bool is_stable);
115 void pcep_pcc_send_error(struct ctrl_state *ctrl_state,
116 struct pcc_state *pcc_state, struct pcep_error *path,
117 bool is_stable);
118 int pcep_pcc_multi_pce_sync_path(struct ctrl_state *ctrl_state, int pcc_id,
119 struct pcc_state **pcc_state_list);
120 int pcep_pcc_multi_pce_remove_pcc(struct ctrl_state *ctrl_state,
121 struct pcc_state **pcc_state_list);
122 int pcep_pcc_timer_update_best_pce(struct ctrl_state *ctrl_state, int pcc_id);
123 int pcep_pcc_calculate_best_pce(struct pcc_state **pcc);
124 int pcep_pcc_get_pcc_id_by_ip_port(struct pcc_state **pcc,
125 struct pce_opts *pce_opts);
126 int pcep_pcc_get_pcc_id_by_idx(struct pcc_state **pcc, int idx);
127 struct pcc_state *pcep_pcc_get_pcc_by_id(struct pcc_state **pcc, int id);
128 struct pcc_state *pcep_pcc_get_pcc_by_name(struct pcc_state **pcc,
129 const char *pce_name);
130 int pcep_pcc_get_pcc_idx_by_id(struct pcc_state **pcc, int id);
131 int pcep_pcc_get_free_pcc_idx(struct pcc_state **pcc);
132 int pcep_pcc_get_pcc_id(struct pcc_state *pcc);
133 void pcep_pcc_copy_pcc_info(struct pcc_state **pcc,
134 struct pcep_pcc_info *pcc_info);
135
136 #endif // _PATH_PCEP_PCC_H_