blob: ff4f2d93bf78e95d00697edb14567a2717fb363c [file] [log] [blame]
Andrea Campanella241896c2017-05-10 13:11:04 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Andrea Campanella241896c2017-05-10 13:11:04 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.drivers.bmv2;
18
19import org.apache.felix.scr.annotations.Component;
Carmelo Cascone44daf562017-07-16 23:55:08 -040020import org.apache.felix.scr.annotations.Reference;
21import org.apache.felix.scr.annotations.ReferenceCardinality;
Andrea Campanella241896c2017-05-10 13:11:04 -070022import org.onosproject.net.driver.AbstractDriverLoader;
Carmelo Cascone44daf562017-07-16 23:55:08 -040023import org.onosproject.net.pi.runtime.PiPipeconfService;
Andrea Campanella241896c2017-05-10 13:11:04 -070024
25/**
26 * Loader for P4Runtime device drivers.
27 */
28@Component(immediate = true)
29public class Bmv2DriversLoader extends AbstractDriverLoader {
30
Carmelo Cascone44daf562017-07-16 23:55:08 -040031 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
32 protected PiPipeconfService pipeconfService;
33
Andrea Campanella241896c2017-05-10 13:11:04 -070034 public Bmv2DriversLoader() {
35 super("/bmv2-drivers.xml");
36 }
Carmelo Cascone44daf562017-07-16 23:55:08 -040037
38 @Override
39 public void activate() {
40 pipeconfService.register(Bmv2DefaultPipeconfFactory.get());
41 super.activate();
42 }
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020043
44 @Override
45 public void deactivate() {
46 pipeconfService.remove(Bmv2DefaultPipeconfFactory.get().id());
Yi Tseng94f5c492017-08-09 22:47:15 -070047 super.deactivate();
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020048 }
Andrea Campanella241896c2017-05-10 13:11:04 -070049}