Carmelo Cascone | 360c9e5 | 2018-01-31 16:00:48 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | * |
| 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 | |
| 17 | package org.onosproject.drivers.cavium.pro; |
| 18 | |
Carmelo Cascone | ce1bf71 | 2018-02-01 13:38:30 -0800 | [diff] [blame] | 19 | import org.onosproject.drivers.bmv2.Bmv2PipelineProgrammable; |
Carmelo Cascone | 360c9e5 | 2018-01-31 16:00:48 -0800 | [diff] [blame] | 20 | import org.onosproject.net.behaviour.PiPipelineProgrammable; |
| 21 | import org.onosproject.net.pi.model.PiPipeconf; |
| 22 | import org.onosproject.net.pi.model.PiPipeconfId; |
| 23 | import org.onosproject.net.pi.service.PiPipeconfService; |
| 24 | |
| 25 | import java.nio.ByteBuffer; |
| 26 | import java.util.Optional; |
| 27 | |
| 28 | import static com.google.common.base.Preconditions.checkArgument; |
| 29 | import static java.lang.String.format; |
| 30 | |
| 31 | /** |
| 32 | * Implementation of the PiPipelineProgrammable behaviour for a Xpliant-based |
| 33 | * switch. |
| 34 | */ |
Carmelo Cascone | ce1bf71 | 2018-02-01 13:38:30 -0800 | [diff] [blame] | 35 | public class XpliantProPipelineProgrammable extends Bmv2PipelineProgrammable |
Carmelo Cascone | 360c9e5 | 2018-01-31 16:00:48 -0800 | [diff] [blame] | 36 | implements PiPipelineProgrammable { |
| 37 | |
| 38 | private static final PiPipeconfId FABRIC_PIPECONF_ID = |
| 39 | new PiPipeconfId("org.onosproject.pipelines.fabric"); |
| 40 | |
| 41 | @Override |
| 42 | public ByteBuffer createDeviceDataBuffer(PiPipeconf pipeconf) { |
| 43 | checkArgument(pipeconf.id().equals(FABRIC_PIPECONF_ID), |
| 44 | format("Cannot program XPliant device with a pipeconf " + |
| 45 | "other than '%s' (found '%s')", |
| 46 | FABRIC_PIPECONF_ID, pipeconf.id())); |
Carmelo Cascone | ce1bf71 | 2018-02-01 13:38:30 -0800 | [diff] [blame] | 47 | return super.createDeviceDataBuffer(pipeconf); |
Carmelo Cascone | 360c9e5 | 2018-01-31 16:00:48 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public Optional<PiPipeconf> getDefaultPipeconf() { |
| 52 | return handler().get(PiPipeconfService.class) |
| 53 | .getPipeconf(FABRIC_PIPECONF_ID); |
| 54 | } |
| 55 | } |