bmv2
Designing your own switch target with bmv2
simple_pre_lag.h
Go to the documentation of this file.
1 /* Copyright 2013-present Barefoot Networks, Inc.
2  *
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 /*
17  * Srikrishna Gopu (krishna@barefootnetworks.com)
18  * Antonin Bas (antonin@barefootnetworks.com)
19  *
20  */
21 
23 
24 #ifndef BM_BM_SIM_SIMPLE_PRE_LAG_H_
25 #define BM_BM_SIM_SIMPLE_PRE_LAG_H_
26 
27 #include <string>
28 #include <unordered_map>
29 #include <vector>
30 
31 #include "pre.h"
32 #include "simple_pre.h"
33 
34 namespace bm {
35 
37 class McSimplePreLAG : public McSimplePre {
38  public:
39  static constexpr int LAG_MAX_ENTRIES = 256;
40  using lag_id_t = uint16_t;
41 
42  McReturnCode mc_node_create(const rid_t rid,
43  const PortMap &port_map,
44  const LagMap &lag_map,
45  l1_hdl_t *l1_hdl);
46  McReturnCode mc_node_update(const l1_hdl_t l1_hdl,
47  const PortMap &port_map,
48  const LagMap &lag_map);
49 
50  McReturnCode mc_set_lag_membership(const lag_id_t lag_index,
51  const PortMap &port_map);
52 
53  std::string mc_get_entries() const;
54 
55  void reset_state();
56 
57  std::vector<McOut> replicate(const McIn) const;
58 
59  private:
60  struct LagEntry {
61  uint16_t member_count;
62  PortMap port_map{};
63 
64  LagEntry() {}
65  LagEntry(uint16_t member_count, const PortMap &port_map)
66  : member_count(member_count), port_map(port_map) {}
67  };
68 
69  std::unordered_map<lag_id_t, LagEntry> lag_entries{};
70 };
71 
72 } // namespace bm
73 
74 #endif // BM_BM_SIM_SIMPLE_PRE_LAG_H_
bm::McSimplePre::rid_t
unsigned int rid_t
NC.
Definition: simple_pre.h:52
bm::McSimplePre
Definition: simple_pre.h:47
bm::McSimplePre::McIn
Input to replicate() method.
Definition: simple_pre.h:71
bm::McSimplePreLAG
Enhances McSimplePre with LAG (link aggregation) support.
Definition: simple_pre_lag.h:37
simple_pre.h