Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 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 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 16 | #include "vom/l2_binding_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 17 | |
| 18 | namespace VOM { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 19 | namespace l2_binding_cmds { |
| 20 | bind_cmd::bind_cmd(HW::item<bool>& item, |
| 21 | const handle_t& itf, |
| 22 | uint32_t bd, |
| 23 | bool is_bvi) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 24 | : rpc_cmd(item) |
| 25 | , m_itf(itf) |
| 26 | , m_bd(bd) |
| 27 | , m_is_bvi(is_bvi) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 32 | bind_cmd::operator==(const bind_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 33 | { |
| 34 | return ((m_itf == other.m_itf) && (m_bd == other.m_bd) && |
| 35 | (m_is_bvi == other.m_is_bvi)); |
| 36 | } |
| 37 | |
| 38 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 39 | bind_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 40 | { |
| 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 | |
| 57 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 58 | bind_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 59 | { |
| 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 Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 67 | unbind_cmd::unbind_cmd(HW::item<bool>& item, |
| 68 | const handle_t& itf, |
| 69 | uint32_t bd, |
| 70 | bool is_bvi) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 71 | : rpc_cmd(item) |
| 72 | , m_itf(itf) |
| 73 | , m_bd(bd) |
| 74 | , m_is_bvi(is_bvi) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 79 | unbind_cmd::operator==(const unbind_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 80 | { |
| 81 | return ((m_itf == other.m_itf) && (m_bd == other.m_bd) && |
| 82 | (m_is_bvi == other.m_is_bvi)); |
| 83 | } |
| 84 | |
| 85 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 86 | unbind_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 87 | { |
| 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 | |
| 105 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 106 | unbind_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 107 | { |
| 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 Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 115 | set_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 Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 118 | : rpc_cmd(item) |
| 119 | , m_itf(itf) |
| 120 | , m_tag(tag) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | bool |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 125 | set_vtr_op_cmd::operator==(const set_vtr_op_cmd& other) const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 126 | { |
| 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 | |
| 132 | rc_t |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 133 | set_vtr_op_cmd::issue(connection& con) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 134 | { |
| 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 | |
| 151 | std::string |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 152 | set_vtr_op_cmd::to_string() const |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 153 | { |
| 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 Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 160 | |
| 161 | }; // namespace l2_binding_cmds |
| 162 | }; // namespace VOM |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 163 | |
| 164 | /* |
| 165 | * fd.io coding-style-patch-verification: ON |
| 166 | * |
| 167 | * Local Variables: |
| 168 | * eval: (c-set-style "mozilla") |
| 169 | * End: |
| 170 | */ |