blob: 6b67c7096e8ca69e9900b62c62c6dfdc3518184e [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070016#include "vom/l2_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070017
18namespace VOM {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070019namespace l2_binding_cmds {
20bind_cmd::bind_cmd(HW::item<bool>& item,
21 const handle_t& itf,
22 uint32_t bd,
23 bool is_bvi)
Neale Ranns812ed392017-10-16 04:20:13 -070024 : rpc_cmd(item)
25 , m_itf(itf)
26 , m_bd(bd)
27 , m_is_bvi(is_bvi)
28{
29}
30
31bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070032bind_cmd::operator==(const bind_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -070033{
34 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
35 (m_is_bvi == other.m_is_bvi));
36}
37
38rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070039bind_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070040{
41 msg_t req(con.ctx(), std::ref(*this));
42
43 auto& payload = req.get_request().get_payload();
44 payload.rx_sw_if_index = m_itf.value();
45 payload.bd_id = m_bd;
46 payload.shg = 0;
47 payload.bvi = m_is_bvi;
48 payload.enable = 1;
49
50 VAPI_CALL(req.execute());
51
52 m_hw_item.set(wait());
53
54 return (rc_t::OK);
55}
56
57std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070058bind_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -070059{
60 std::ostringstream s;
61 s << "L2-bind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
62 << " bd:" << m_bd;
63
64 return (s.str());
65}
66
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070067unbind_cmd::unbind_cmd(HW::item<bool>& item,
68 const handle_t& itf,
69 uint32_t bd,
70 bool is_bvi)
Neale Ranns812ed392017-10-16 04:20:13 -070071 : rpc_cmd(item)
72 , m_itf(itf)
73 , m_bd(bd)
74 , m_is_bvi(is_bvi)
75{
76}
77
78bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070079unbind_cmd::operator==(const unbind_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -070080{
81 return ((m_itf == other.m_itf) && (m_bd == other.m_bd) &&
82 (m_is_bvi == other.m_is_bvi));
83}
84
85rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070086unbind_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070087{
88 msg_t req(con.ctx(), std::ref(*this));
89
90 auto& payload = req.get_request().get_payload();
91 payload.rx_sw_if_index = m_itf.value();
92 payload.bd_id = m_bd;
93 payload.shg = 0;
94 payload.bvi = m_is_bvi;
95 payload.enable = 0;
96
97 VAPI_CALL(req.execute());
98
99 wait();
100 m_hw_item.set(rc_t::NOOP);
101
102 return (rc_t::OK);
103}
104
105std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700106unbind_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700107{
108 std::ostringstream s;
109 s << "L2-unbind: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
110 << " bd:" << m_bd;
111
112 return (s.str());
113}
114
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700115set_vtr_op_cmd::set_vtr_op_cmd(HW::item<l2_binding::l2_vtr_op_t>& item,
116 const handle_t& itf,
117 uint16_t tag)
Neale Ranns812ed392017-10-16 04:20:13 -0700118 : rpc_cmd(item)
119 , m_itf(itf)
120 , m_tag(tag)
121{
122}
123
124bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700125set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700126{
127 return (
128 (m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
129 (m_tag == other.m_tag));
130}
131
132rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700133set_vtr_op_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700134{
135 msg_t req(con.ctx(), std::ref(*this));
136
137 auto& payload = req.get_request().get_payload();
138 payload.sw_if_index = m_itf.value();
139 payload.vtr_op = m_hw_item.data().value();
140 payload.push_dot1q = 1;
141 payload.tag1 = m_tag;
142
143 VAPI_CALL(req.execute());
144
145 wait();
146 m_hw_item.set(rc_t::NOOP);
147
148 return (rc_t::OK);
149}
150
151std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700152set_vtr_op_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700153{
154 std::ostringstream s;
155 s << "L2-set-vtr-op: " << m_hw_item.to_string()
156 << " itf:" << m_itf.to_string() << " tag:" << m_tag;
157
158 return (s.str());
159}
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700160
161}; // namespace l2_binding_cmds
162}; // namespace VOM
Neale Ranns812ed392017-10-16 04:20:13 -0700163
164/*
165 * fd.io coding-style-patch-verification: ON
166 *
167 * Local Variables:
168 * eval: (c-set-style "mozilla")
169 * End:
170 */