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