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