Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | */ |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 16 | package org.onosproject.driver.pipeline; |
| 17 | |
| 18 | import static org.slf4j.LoggerFactory.getLogger; |
| 19 | |
| 20 | import org.onosproject.net.flow.DefaultFlowRule; |
| 21 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 22 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 23 | import org.onosproject.net.flow.FlowRule; |
| 24 | import org.onosproject.net.flow.FlowRuleOperations; |
| 25 | import org.onosproject.net.flow.FlowRuleOperationsContext; |
| 26 | import org.onosproject.net.flow.TrafficSelector; |
| 27 | import org.onosproject.net.flow.TrafficTreatment; |
| 28 | import org.slf4j.Logger; |
| 29 | |
| 30 | |
| 31 | /** |
Saurav Das | 822c4e2 | 2015-10-23 10:51:11 -0700 | [diff] [blame] | 32 | * Driver for software switch emulation of the OFDPA 2.0 pipeline. |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 33 | * The software switch is the CPqD OF 1.3 switch. |
| 34 | */ |
Saurav Das | 822c4e2 | 2015-10-23 10:51:11 -0700 | [diff] [blame] | 35 | public class CpqdOFDPA2Pipeline extends OFDPA2Pipeline { |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 36 | |
| 37 | private final Logger log = getLogger(getClass()); |
| 38 | |
| 39 | @Override |
| 40 | protected void initializePipeline() { |
| 41 | processPortTable(); |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 42 | processTmacTable(); |
| 43 | processIpTable(); |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 44 | processBridgingTable(); |
Saurav Das | 337c7a4 | 2015-06-02 15:12:06 -0700 | [diff] [blame] | 45 | processAclTable(); |
Saurav Das | 822c4e2 | 2015-10-23 10:51:11 -0700 | [diff] [blame] | 46 | // XXX implement table miss entries and default groups |
| 47 | //processVlanTable(); |
| 48 | //processMPLSTable(); |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 49 | //processGroupTable(); |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | protected void processPortTable() { |
| 54 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 55 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 56 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
| 57 | treatment.transition(VLAN_TABLE); |
| 58 | FlowRule tmisse = DefaultFlowRule.builder() |
| 59 | .forDevice(deviceId) |
| 60 | .withSelector(selector.build()) |
| 61 | .withTreatment(treatment.build()) |
| 62 | .withPriority(LOWEST_PRIORITY) |
| 63 | .fromApp(driverId) |
| 64 | .makePermanent() |
| 65 | .forTable(PORT_TABLE).build(); |
| 66 | ops = ops.add(tmisse); |
| 67 | |
| 68 | flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { |
| 69 | @Override |
| 70 | public void onSuccess(FlowRuleOperations ops) { |
| 71 | log.info("Initialized port table"); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public void onError(FlowRuleOperations ops) { |
| 76 | log.info("Failed to initialize port table"); |
| 77 | } |
| 78 | })); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | protected void processTmacTable() { |
| 83 | //table miss entry |
| 84 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 85 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 86 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
| 87 | selector = DefaultTrafficSelector.builder(); |
| 88 | treatment = DefaultTrafficTreatment.builder(); |
| 89 | treatment.transition(BRIDGING_TABLE); |
| 90 | FlowRule rule = DefaultFlowRule.builder() |
| 91 | .forDevice(deviceId) |
| 92 | .withSelector(selector.build()) |
| 93 | .withTreatment(treatment.build()) |
| 94 | .withPriority(LOWEST_PRIORITY) |
| 95 | .fromApp(driverId) |
| 96 | .makePermanent() |
| 97 | .forTable(TMAC_TABLE).build(); |
| 98 | ops = ops.add(rule); |
| 99 | flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { |
| 100 | @Override |
| 101 | public void onSuccess(FlowRuleOperations ops) { |
| 102 | log.info("Initialized tmac table"); |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public void onError(FlowRuleOperations ops) { |
| 107 | log.info("Failed to initialize tmac table"); |
| 108 | } |
| 109 | })); |
| 110 | } |
| 111 | |
| 112 | @Override |
| 113 | protected void processIpTable() { |
| 114 | //table miss entry |
| 115 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 116 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 117 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
| 118 | selector = DefaultTrafficSelector.builder(); |
| 119 | treatment = DefaultTrafficTreatment.builder(); |
| 120 | treatment.transition(ACL_TABLE); |
| 121 | FlowRule rule = DefaultFlowRule.builder() |
| 122 | .forDevice(deviceId) |
| 123 | .withSelector(selector.build()) |
| 124 | .withTreatment(treatment.build()) |
| 125 | .withPriority(LOWEST_PRIORITY) |
| 126 | .fromApp(driverId) |
| 127 | .makePermanent() |
| 128 | .forTable(UNICAST_ROUTING_TABLE).build(); |
| 129 | ops = ops.add(rule); |
| 130 | flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { |
| 131 | @Override |
| 132 | public void onSuccess(FlowRuleOperations ops) { |
| 133 | log.info("Initialized IP table"); |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public void onError(FlowRuleOperations ops) { |
| 138 | log.info("Failed to initialize unicast IP table"); |
| 139 | } |
| 140 | })); |
| 141 | } |
| 142 | |
| 143 | private void processBridgingTable() { |
| 144 | //table miss entry |
| 145 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 146 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 147 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
| 148 | selector = DefaultTrafficSelector.builder(); |
| 149 | treatment = DefaultTrafficTreatment.builder(); |
| 150 | treatment.transition(ACL_TABLE); |
| 151 | FlowRule rule = DefaultFlowRule.builder() |
| 152 | .forDevice(deviceId) |
| 153 | .withSelector(selector.build()) |
| 154 | .withTreatment(treatment.build()) |
| 155 | .withPriority(LOWEST_PRIORITY) |
| 156 | .fromApp(driverId) |
| 157 | .makePermanent() |
| 158 | .forTable(BRIDGING_TABLE).build(); |
| 159 | ops = ops.add(rule); |
| 160 | flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { |
| 161 | @Override |
| 162 | public void onSuccess(FlowRuleOperations ops) { |
| 163 | log.info("Initialized Bridging table"); |
| 164 | } |
| 165 | |
| 166 | @Override |
| 167 | public void onError(FlowRuleOperations ops) { |
| 168 | log.info("Failed to initialize Bridging table"); |
| 169 | } |
| 170 | })); |
Saurav Das | 337c7a4 | 2015-06-02 15:12:06 -0700 | [diff] [blame] | 171 | } |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 172 | |
Saurav Das | 822c4e2 | 2015-10-23 10:51:11 -0700 | [diff] [blame] | 173 | @Override |
Saurav Das | a07f203 | 2015-10-19 14:37:36 -0700 | [diff] [blame] | 174 | protected void processAclTable() { |
Saurav Das | 337c7a4 | 2015-06-02 15:12:06 -0700 | [diff] [blame] | 175 | //table miss entry - catch all to executed action-set |
| 176 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 177 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 178 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
| 179 | selector = DefaultTrafficSelector.builder(); |
| 180 | treatment = DefaultTrafficTreatment.builder(); |
| 181 | FlowRule rule = DefaultFlowRule.builder() |
| 182 | .forDevice(deviceId) |
| 183 | .withSelector(selector.build()) |
| 184 | .withTreatment(treatment.build()) |
| 185 | .withPriority(LOWEST_PRIORITY) |
| 186 | .fromApp(driverId) |
| 187 | .makePermanent() |
| 188 | .forTable(ACL_TABLE).build(); |
| 189 | ops = ops.add(rule); |
| 190 | flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { |
| 191 | @Override |
| 192 | public void onSuccess(FlowRuleOperations ops) { |
| 193 | log.info("Initialized Acl table"); |
| 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public void onError(FlowRuleOperations ops) { |
| 198 | log.info("Failed to initialize Acl table"); |
| 199 | } |
| 200 | })); |
Saurav Das | 558afec | 2015-05-31 17:12:48 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | } |