blob: e212655836d2f048c8334c4af5287438825dffeb [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
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070023 /**
24 * Return an IOFSwitch object based on switch's manufacturer description
25 * from OFDescStatsReply.
26 *
27 * @param desc DescriptionStatistics reply from the switch
28 * @return A IOFSwitch instance if the driver found an implementation for
29 * the given description. Otherwise it returns OFSwitchImplBase
30 */
31 public static IOFSwitch getOFSwitchImpl(OFDescStatsReply desc, OFVersion ofv) {
32 String vendor = desc.getMfrDesc();
33 String hw = desc.getHwDesc();
34 if (vendor.startsWith("Stanford University, Ericsson Research and CPqD Research")
35 &&
36 hw.startsWith("OpenFlow 1.3 Reference Userspace Switch")) {
Jonathan Hartcb34f382014-08-12 21:11:03 -070037 return new OFSwitchImplCPqD13(desc, cpqdUsePipeline13);
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070038 }
39
40 if (vendor.startsWith("Nicira") &&
41 hw.startsWith("Open vSwitch")) {
42 if (ofv == OFVersion.OF_10) {
43 return new OFSwitchImplOVS10(desc);
44 } else if (ofv == OFVersion.OF_13) {
45 return new OFSwitchImplOVS13(desc);
46 }
47 }
48
49 log.warn("DriverManager could not identify switch desc: {}. "
50 + "Assigning OFSwitchImplBase", desc);
51 OFSwitchImplBase base = new OFSwitchImplBase();
52 base.setSwitchDescription(desc);
53 // XXX S must set counter here - unidentified switch
54 return base;
55 }
56
57 /**
58 * Private constructor to avoid instantiation.
59 */
60 private DriverManager() {
61 }
Jonathan Hartcb34f382014-08-12 21:11:03 -070062
63 /**
64 * Sets the configuration parameter which determines how the CPqD switch
65 * is set up. If usePipeline13 is true, a 1.3 pipeline will be set up on
66 * the switch. Otherwise, the switch will be set up in a 1.0 style with
67 * a single table where missed packets are sent to the controller.
68 *
69 * @param usePipeline13 whether to use a 1.3 pipeline or not
70 */
71 public static void setConfigForCpqd(boolean usePipeline13) {
72 cpqdUsePipeline13 = usePipeline13;
73 }
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070074}