blob: 769f3b1c4f5905788816aaa277f00a6edc7527b8 [file] [log] [blame]
Saurav Das558afec2015-05-31 17:12:48 -07001package org.onosproject.driver.pipeline;
2
3import static org.slf4j.LoggerFactory.getLogger;
4
5import org.onosproject.net.flow.DefaultFlowRule;
6import org.onosproject.net.flow.DefaultTrafficSelector;
7import org.onosproject.net.flow.DefaultTrafficTreatment;
8import org.onosproject.net.flow.FlowRule;
9import org.onosproject.net.flow.FlowRuleOperations;
10import org.onosproject.net.flow.FlowRuleOperationsContext;
11import org.onosproject.net.flow.TrafficSelector;
12import org.onosproject.net.flow.TrafficTreatment;
13import 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 */
20public 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();
32 //processAclTable();
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 }));
155
156 }
157
158}