blob: 213119f09f9cd337c38625f6a1c0cdba223a84ad [file] [log] [blame]
Brian O'Connorc67f9fa2014-08-07 18:17:46 -07001package net.onrc.onos.core.drivermanager;
2
3import net.floodlightcontroller.core.IOFSwitch;
4import net.floodlightcontroller.core.internal.OFSwitchImplBase;
5
6import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
7import org.projectfloodlight.openflow.protocol.OFVersion;
8import org.slf4j.Logger;
9import org.slf4j.LoggerFactory;
10
11/**
12 * A simple implementation of a driver manager that differentiates between
13 * connected switches using the OF Description Statistics Reply message.
14 */
15public final class DriverManager {
16
17 private static final Logger log = LoggerFactory.getLogger(DriverManager.class);
18
Jonathan Hartcb34f382014-08-12 21:11:03 -070019 // Whether to use an OF 1.3 configured TTP, or to use an OF 1.0-style
20 // single table with packet-ins.
21 private static boolean cpqdUsePipeline13 = false;
22
Jonathan Hart2c44a642014-08-19 03:40:43 -070023 // This flag can be set to prevent the driver manager from classifying
24 // switches as OVS switches (and thereby the default switch implementation
25 // will be used).
26 private static boolean disableOvsClassification = false;
27
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070028 /**
29 * Return an IOFSwitch object based on switch's manufacturer description
30 * from OFDescStatsReply.
31 *
32 * @param desc DescriptionStatistics reply from the switch
33 * @return A IOFSwitch instance if the driver found an implementation for
34 * the given description. Otherwise it returns OFSwitchImplBase
35 */
36 public static IOFSwitch getOFSwitchImpl(OFDescStatsReply desc, OFVersion ofv) {
37 String vendor = desc.getMfrDesc();
38 String hw = desc.getHwDesc();
39 if (vendor.startsWith("Stanford University, Ericsson Research and CPqD Research")
40 &&
41 hw.startsWith("OpenFlow 1.3 Reference Userspace Switch")) {
Srikanth Vavilapalli8a661e72014-10-27 15:40:22 -070042 return new OFSwitchImplCpqdOSR(desc, cpqdUsePipeline13);
43 }
44
45 if (vendor.contains("Dell")
46 &&
47 hw.contains("OpenFlow 1.3")) {
48 return new OFSwitchImplDellOSR(desc, cpqdUsePipeline13);
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070049 }
50
Jonathan Hart2c44a642014-08-19 03:40:43 -070051 if (!disableOvsClassification && vendor.startsWith("Nicira") &&
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070052 hw.startsWith("Open vSwitch")) {
53 if (ofv == OFVersion.OF_10) {
54 return new OFSwitchImplOVS10(desc);
55 } else if (ofv == OFVersion.OF_13) {
56 return new OFSwitchImplOVS13(desc);
57 }
58 }
59
60 log.warn("DriverManager could not identify switch desc: {}. "
61 + "Assigning OFSwitchImplBase", desc);
62 OFSwitchImplBase base = new OFSwitchImplBase();
63 base.setSwitchDescription(desc);
64 // XXX S must set counter here - unidentified switch
65 return base;
66 }
67
68 /**
69 * Private constructor to avoid instantiation.
70 */
71 private DriverManager() {
72 }
Jonathan Hartcb34f382014-08-12 21:11:03 -070073
74 /**
75 * Sets the configuration parameter which determines how the CPqD switch
76 * is set up. If usePipeline13 is true, a 1.3 pipeline will be set up on
77 * the switch. Otherwise, the switch will be set up in a 1.0 style with
78 * a single table where missed packets are sent to the controller.
79 *
80 * @param usePipeline13 whether to use a 1.3 pipeline or not
81 */
82 public static void setConfigForCpqd(boolean usePipeline13) {
83 cpqdUsePipeline13 = usePipeline13;
84 }
Jonathan Hart2c44a642014-08-19 03:40:43 -070085
86 /**
87 * Sets the configuration parameter which determines whether switches can
88 * be classified as OVS switches or as the default switch implementation.
89 *
90 * Our use case for this is when running OVS under the Flow Space Firewall
91 * (FSFW). The FSFW relays the switch desc reply (containing OVS
92 * description) from the switch to the controller. This causes us to
93 * classify the fake FSFW switch as OVS, however the FSFW switch doesn't
94 * support Nicira role requests and it breaks if we try to send them.
95 * Our workaround is to disable classifying switches as OVS.
96 *
97 * @param disableOvsClassificationFlag whether to use OVS switches or not
98 */
99 public static void setDisableOvsClassification(
100 boolean disableOvsClassificationFlag) {
101 disableOvsClassification = disableOvsClassificationFlag;
102 }
Brian O'Connorc67f9fa2014-08-07 18:17:46 -0700103}