4 * Copyright (c) 2017 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
24 #include <vppinfra/error.h>
25 #include <lacp/node.h>
27 #define __plugin_msg_base lacp_test_main.msg_id_base
28 #include <vlibapi/vat_helper_macros.h>
30 /* declare message IDs */
31 #include <lacp/lacp.api_enum.h>
32 #include <lacp/lacp.api_types.h>
33 #include <vpp/api/vpe.api_types.h>
37 /* API message ID base */
43 lacp_test_main_t lacp_test_main;
46 static void vl_api_sw_interface_lacp_details_t_handler
47 (vl_api_sw_interface_lacp_details_t * mp)
49 vat_main_t *vam = &vat_main;
52 "%-25s %-12d %-16s %3x %3x %3x %3x %3x %3x %3x %3x "
53 "%4x %3x %3x %3x %3x %3x %3x %3x\n",
54 mp->interface_name, ntohl (mp->sw_if_index),
55 mp->bond_interface_name,
56 lacp_bit_test (mp->actor_state, 7),
57 lacp_bit_test (mp->actor_state, 6),
58 lacp_bit_test (mp->actor_state, 5),
59 lacp_bit_test (mp->actor_state, 4),
60 lacp_bit_test (mp->actor_state, 3),
61 lacp_bit_test (mp->actor_state, 2),
62 lacp_bit_test (mp->actor_state, 1),
63 lacp_bit_test (mp->actor_state, 0),
64 lacp_bit_test (mp->partner_state, 7),
65 lacp_bit_test (mp->partner_state, 6),
66 lacp_bit_test (mp->partner_state, 5),
67 lacp_bit_test (mp->partner_state, 4),
68 lacp_bit_test (mp->partner_state, 3),
69 lacp_bit_test (mp->partner_state, 2),
70 lacp_bit_test (mp->partner_state, 1),
71 lacp_bit_test (mp->partner_state, 0));
73 " LAG ID: [(%04x,%02x-%02x-%02x-%02x-%02x-%02x,%04x,%04x,%04x), "
74 "(%04x,%02x-%02x-%02x-%02x-%02x-%02x,%04x,%04x,%04x)]\n",
75 ntohs (mp->actor_system_priority), mp->actor_system[0],
76 mp->actor_system[1], mp->actor_system[2], mp->actor_system[3],
77 mp->actor_system[4], mp->actor_system[5], ntohs (mp->actor_key),
78 ntohs (mp->actor_port_priority), ntohs (mp->actor_port_number),
79 ntohs (mp->partner_system_priority), mp->partner_system[0],
80 mp->partner_system[1], mp->partner_system[2],
81 mp->partner_system[3], mp->partner_system[4],
82 mp->partner_system[5], ntohs (mp->partner_key),
83 ntohs (mp->partner_port_priority),
84 ntohs (mp->partner_port_number));
86 " RX-state: %U, TX-state: %U, MUX-state: %U, PTX-state: %U\n",
87 format_rx_sm_state, ntohl (mp->rx_state), format_tx_sm_state,
88 ntohl (mp->tx_state), format_mux_sm_state, ntohl (mp->mux_state),
89 format_ptx_sm_state, ntohl (mp->ptx_state));
93 api_sw_interface_lacp_dump (vat_main_t * vam)
95 lacp_test_main_t *lm = &lacp_test_main;
96 vl_api_sw_interface_lacp_dump_t *mp;
97 vl_api_control_ping_t *mp_ping;
100 if (vam->json_output)
102 clib_warning ("JSON output not supported for sw_interface_lacp_dump");
106 fformat (vam->ofp, "%-55s %-32s %-32s\n", " ", "actor state",
108 fformat (vam->ofp, "%-25s %-12s %-16s %-31s %-31s\n", "interface name",
109 "sw_if_index", "bond interface", "exp/def/dis/col/syn/agg/tim/act",
110 "exp/def/dis/col/syn/agg/tim/act");
112 /* Get list of lacp interfaces */
113 M (SW_INTERFACE_LACP_DUMP, mp);
116 /* Use a control ping for synchronization */
117 mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
118 mp_ping->_vl_msg_id = htons (lm->ping_id);
119 mp_ping->client_index = vam->my_client_index;
121 fformat (vam->ofp, "Sending ping id=%d\n", lm->ping_id);
123 vam->result_ready = 0;
130 #include <lacp/lacp.api_test.c>
133 * fd.io coding-style-patch-verification: ON
136 * eval: (c-set-style "gnu")