FD.io VPP  v18.07.1-19-g511ce25
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, BEGIN, "begin") \
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),
32 #undef _
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),
45 #undef _
47 
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 (slave_if_t * sif, 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
68 {
69  sif->periodic_timer = vlib_time_now (vm) + expiration;
70 }
71 
72 static inline void
74 {
75  // do fast rate if partner is in short timeout or
76  // we are not yet synchronized
77  if ((sif->partner.state & LACP_STATE_LACP_TIMEOUT) ||
78  (((sif->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  && (sif->partner.state & LACP_STATE_AGGREGATION)))
85  else
87 }
88 
89 #endif /* __LACP_PTX_MACHINE_H__ */
90 
91 /*
92  * fd.io coding-style-patch-verification: ON
93  *
94  * Local Variables:
95  * eval: (c-set-style "gnu")
96  * End:
97  */
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:228
#define LACP_FAST_PERIODIC_TIMER
Definition: node.h:25
unsigned char u8
Definition: types.h:56
f64 periodic_timer
Definition: node.h:260
lacp_ptx_sm_state_t
Definition: ptx_machine.h:41
lacp_port_info_t actor
Definition: node.h:220
int lacp_ptx_action_timer_expired(void *p1, void *p2)
Definition: ptx_machine.c:139
vhost_vring_state_t state
Definition: vhost_user.h:115
#define LACP_SLOW_PERIODIC_TIMER
Definition: node.h:27
lacp_machine_t lacp_ptx_machine
Definition: ptx_machine.c:69
lacp_ptx_event_t
Definition: ptx_machine.h:28
vlib_main_t * vm
Definition: buffer.c:294
int lacp_ptx_action_no_periodic(void *p1, void *p2)
Definition: ptx_machine.c:75
lacp_port_info_t partner
Definition: node.h:219
void lacp_ptx_debug_func(slave_if_t *sif, int event, int state, lacp_fsm_state_t *transition)
Definition: ptx_machine.c:179
#define foreach_lacp_ptx_event
Definition: ptx_machine.h:22
static void lacp_schedule_periodic_timer(vlib_main_t *vm, slave_if_t *sif)
Definition: ptx_machine.h:73
#define foreach_lacp_ptx_sm_state
Definition: ptx_machine.h:35
static void lacp_start_periodic_timer(vlib_main_t *vm, slave_if_t *sif, u8 expiration)
Definition: ptx_machine.h:67
int lacp_ptx_action_slow_periodic(void *p1, void *p2)
Definition: ptx_machine.c:89
int lacp_ptx_action_fast_periodic(void *p1, void *p2)
Definition: ptx_machine.c:112