FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
ptx_machine.h
Go to the documentation of this file.
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 ___LACP_PTX_MACHINE_H__
17
#define ___LACP_PTX_MACHINE_H__
18
19
#include <stdint.h>
20
#include <
lacp/machine.h
>
21
22
#define foreach_lacp_ptx_event \
23
_(0, NO_PERIODIC, "no periodic") \
24
_(1, LONG_TIMEOUT, "long tiemout") \
25
_(2, TIMER_EXPIRED, "timer expired") \
26
_(3, SHORT_TIMEOUT, "short timeout")
27
28
typedef
enum
29
{
30
#define _(a, b, c) LACP_PTX_EVENT_##b = (a),
31
foreach_lacp_ptx_event
32
#undef _
33
}
lacp_ptx_event_t
;
34
35
#define foreach_lacp_ptx_sm_state \
36
_(0, NO_PERIODIC, "no periodic") \
37
_(1, FAST_PERIODIC, "fast periodic") \
38
_(2, SLOW_PERIODIC, "slow periodic") \
39
_(3, PERIODIC_TX, "periodic transmission")
40
41
typedef
enum
42
{
43
#define _(a, b, c) LACP_PTX_STATE_##b = (a),
44
foreach_lacp_ptx_sm_state
45
#undef _
46
}
lacp_ptx_sm_state_t
;
47
48
extern
lacp_machine_t
lacp_ptx_machine
;
49
50
int
lacp_ptx_action_no_periodic
(
void
*p1,
void
*p2);
51
int
lacp_ptx_action_slow_periodic
(
void
*p1,
void
*p2);
52
int
lacp_ptx_action_fast_periodic
(
void
*p1,
void
*p2);
53
int
lacp_ptx_action_timer_expired
(
void
*p1,
void
*p2);
54
void
lacp_ptx_debug_func
(
member_if_t
* mif,
int
event,
int
state
,
55
lacp_fsm_state_t
* transition);
56
57
#define LACP_ACTION_NO_PERIODIC \
58
LACP_ACTION_ROUTINE(lacp_ptx_action_no_periodic)
59
#define LACP_ACTION_SLOW_PERIODIC \
60
LACP_ACTION_ROUTINE(lacp_ptx_action_slow_periodic)
61
#define LACP_ACTION_FAST_PERIODIC \
62
LACP_ACTION_ROUTINE(lacp_ptx_action_fast_periodic)
63
#define LACP_ACTION_TIMER_EXPIRED \
64
LACP_ACTION_ROUTINE(lacp_ptx_action_timer_expired)
65
66
static
inline
void
67
lacp_start_periodic_timer
(
vlib_main_t
*
vm
,
member_if_t
* mif,
u8
expiration)
68
{
69
mif->
periodic_timer
=
vlib_time_now
(
vm
) + expiration;
70
}
71
72
static
inline
void
73
lacp_schedule_periodic_timer
(
vlib_main_t
*
vm
,
member_if_t
* mif)
74
{
75
// do fast rate if partner is in short timeout or
76
// we are not yet synchronized
77
if
((mif->
partner
.state & LACP_STATE_LACP_TIMEOUT) ||
78
(((mif->
actor
.state & (LACP_STATE_SYNCHRONIZATION |
79
LACP_STATE_COLLECTING |
80
LACP_STATE_DISTRIBUTING)) !=
81
(LACP_STATE_SYNCHRONIZATION | LACP_STATE_COLLECTING |
82
LACP_STATE_DISTRIBUTING))
83
&& (mif->
partner
.state & LACP_STATE_AGGREGATION)))
84
lacp_start_periodic_timer
(
vm
, mif,
LACP_FAST_PERIODIC_TIMER
);
85
else
86
lacp_start_periodic_timer
(
vm
, mif,
LACP_SLOW_PERIODIC_TIMER
);
87
}
88
89
static
inline
void
90
lacp_ptx_post_short_timeout_event
(
vlib_main_t
*
vm
,
member_if_t
* mif)
91
{
92
if
(mif->
lacp_enabled
&& mif->
port_enabled
&&
93
((mif->
partner
.state & LACP_STATE_LACP_ACTIVITY) ||
94
(mif->
actor
.state & LACP_STATE_LACP_ACTIVITY)))
95
lacp_machine_dispatch
(&
lacp_ptx_machine
,
vm
, mif,
96
LACP_PTX_EVENT_SHORT_TIMEOUT, &mif->
ptx_state
);
97
}
98
99
#endif
/* __LACP_PTX_MACHINE_H__ */
100
101
/*
102
* fd.io coding-style-patch-verification: ON
103
*
104
* Local Variables:
105
* eval: (c-set-style "gnu")
106
* End:
107
*/
lacp_start_periodic_timer
static void lacp_start_periodic_timer(vlib_main_t *vm, member_if_t *mif, u8 expiration)
Definition:
ptx_machine.h:67
lacp_ptx_machine
lacp_machine_t lacp_ptx_machine
Definition:
ptx_machine.c:69
lacp_ptx_post_short_timeout_event
static void lacp_ptx_post_short_timeout_event(vlib_main_t *vm, member_if_t *mif)
Definition:
ptx_machine.h:90
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition:
nat44_ei.c:3047
state
vl_api_dhcp_client_state_t state
Definition:
dhcp.api:201
lacp_fsm_state_t
Definition:
machine.h:26
LACP_FAST_PERIODIC_TIMER
#define LACP_FAST_PERIODIC_TIMER
Definition:
node.h:25
lacp_ptx_event_t
lacp_ptx_event_t
Definition:
ptx_machine.h:28
member_if_t::partner
lacp_port_info_t partner
Definition:
node.h:254
LACP_SLOW_PERIODIC_TIMER
#define LACP_SLOW_PERIODIC_TIMER
Definition:
node.h:27
foreach_lacp_ptx_event
#define foreach_lacp_ptx_event
Definition:
ptx_machine.h:22
member_if_t::periodic_timer
f64 periodic_timer
Definition:
node.h:304
machine.h
lacp_ptx_action_slow_periodic
int lacp_ptx_action_slow_periodic(void *p1, void *p2)
Definition:
ptx_machine.c:86
member_if_t::actor
lacp_port_info_t actor
Definition:
node.h:255
lacp_ptx_sm_state_t
lacp_ptx_sm_state_t
Definition:
ptx_machine.h:41
lacp_machine_dispatch
int lacp_machine_dispatch(lacp_machine_t *machine, vlib_main_t *vm, member_if_t *mif, int event, int *state)
Definition:
lacp.c:317
member_if_t::port_enabled
u8 port_enabled
Definition:
node.h:265
member_if_t
Definition:
node.h:213
lacp_schedule_periodic_timer
static void lacp_schedule_periodic_timer(vlib_main_t *vm, member_if_t *mif)
Definition:
ptx_machine.h:73
vlib_main_t
Definition:
main.h:102
lacp_ptx_action_no_periodic
int lacp_ptx_action_no_periodic(void *p1, void *p2)
Definition:
ptx_machine.c:75
lacp_ptx_action_fast_periodic
int lacp_ptx_action_fast_periodic(void *p1, void *p2)
Definition:
ptx_machine.c:115
u8
unsigned char u8
Definition:
types.h:56
foreach_lacp_ptx_sm_state
#define foreach_lacp_ptx_sm_state
Definition:
ptx_machine.h:35
lacp_ptx_debug_func
void lacp_ptx_debug_func(member_if_t *mif, int event, int state, lacp_fsm_state_t *transition)
Definition:
ptx_machine.c:194
member_if_t::ptx_state
int ptx_state
Definition:
node.h:316
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition:
main.h:327
member_if_t::lacp_enabled
u8 lacp_enabled
Definition:
node.h:271
lacp_ptx_action_timer_expired
int lacp_ptx_action_timer_expired(void *p1, void *p2)
Definition:
ptx_machine.c:148
lacp_machine_t
Definition:
machine.h:40
src
plugins
lacp
ptx_machine.h
Generated on Sat Jan 8 2022 10:35:30 for FD.io VPP by
1.8.17