1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2020 NetDEF, Inc.
6 #ifndef _PATH_PCEP_PCC_H_
7 #define _PATH_PCEP_PCC_H_
10 #include "pathd/path_pcep.h"
13 PCEP_PCC_INITIALIZED
= 0,
14 PCEP_PCC_DISCONNECTED
,
16 PCEP_PCC_SYNCHRONIZING
,
20 PREDECL_HASH(plspid_map
);
21 PREDECL_HASH(nbkey_map
);
22 PREDECL_HASH(req_map
);
24 struct plspid_map_data
{
25 struct plspid_map_item mi
;
26 struct lsp_nb_key nbkey
;
30 struct nbkey_map_data
{
31 struct nbkey_map_item mi
;
32 struct lsp_nb_key nbkey
;
37 struct req_map_item mi
;
38 struct lsp_nb_key nbkey
;
43 RB_ENTRY(req_entry
) entry
;
44 struct event
*t_retry
;
49 RB_HEAD(req_entry_head
, req_entry
);
50 RB_PROTOTYPE(req_entry_head
, req_entry
, entry
, req_entry_compare
);
54 char tag
[MAX_TAG_SIZE
];
55 enum pcc_status status
;
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
;
69 struct event
*t_reconnect
;
70 struct event
*t_update_best
;
71 struct event
*t_session_timeout
;
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
;
83 struct pcc_state
*pcep_pcc_initialize(struct ctrl_state
*ctrl_state
,
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
,
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
,
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
,
115 void pcep_pcc_send_error(struct ctrl_state
*ctrl_state
,
116 struct pcc_state
*pcc_state
, struct pcep_error
*path
,
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
);
136 #endif // _PATH_PCEP_PCC_H_