bmv2
Designing your own switch target with bmv2
Loading...
Searching...
No Matches
phv_source.h
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 * Antonin Bas (antonin@barefootnetworks.com)
18 *
19 */
20
21#ifndef BM_BM_SIM_PHV_SOURCE_H_
22#define BM_BM_SIM_PHV_SOURCE_H_
23
24#include <memory>
25
26#include "device_id.h"
27#include "phv_forward.h"
28
29namespace bm {
30
31class PHVSourceIface {
32 public:
33 virtual ~PHVSourceIface() { }
34
35 std::unique_ptr<PHV> get(cxt_id_t cxt);
36
37 void release(cxt_id_t cxt, std::unique_ptr<PHV> phv);
38
39 void set_phv_factory(cxt_id_t cxt, const PHVFactory *factory);
40
41 size_t phvs_in_use(cxt_id_t cxt);
42
43 static std::unique_ptr<PHVSourceIface> make_phv_source(size_t size = 1);
44
45 private:
46 virtual std::unique_ptr<PHV> get_(cxt_id_t cxt) = 0;
47
48 virtual void release_(cxt_id_t cxt, std::unique_ptr<PHV> phv) = 0;
49
50 virtual void set_phv_factory_(cxt_id_t cxt, const PHVFactory *factory) = 0;
51
52 virtual size_t phvs_in_use_(cxt_id_t cxt) = 0;
53};
54
55} // namespace bm
56
57#endif // BM_BM_SIM_PHV_SOURCE_H_