From: Giovanni Meo Date: Wed, 22 May 2013 12:17:49 +0000 (+0000) Subject: Merge "- Respond to switch Echo Request immediately. It bypasses transmit queue and... X-Git-Tag: releasepom-0.1.0~435 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=b571c5f3e6e9b2dcf2cff2314537c7b1c61533b4;hp=fb99d767417ba5a92c24412aa15ddb56f1f292a3 Merge "- Respond to switch Echo Request immediately. It bypasses transmit queue and sends the message over the socket directly. - Send PACKET_OUT (lldp/arp etc) at high priority. When the controller sends down large amount of flowmod messages, the switch may take some time to install/update all the rules in HW. At high priority, the PACKET_OUT messages do not have to wait for the whole flowmod operation to be complete." --- diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java index 91606f4a41..5d51d26a98 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java @@ -228,7 +228,7 @@ public class SwitchHandler implements ISwitch { * should be used for non-critical messages such as statistics request, * discovery packets, etc. An unique XID is generated automatically and * inserted into the message. - * + * * @param msg * The OF message to be sent * @return The XID used @@ -247,7 +247,7 @@ public class SwitchHandler implements ISwitch { * priority. It will be served after high priority messages. The method * should be used for non-critical messages such as statistics request, * discovery packets, etc. The specified XID is inserted into the message. - * + * * @param msg * The OF message to be Sent * @param xid @@ -269,7 +269,7 @@ public class SwitchHandler implements ISwitch { * method should be used for critical messages such as hello, echo reply * etc. An unique XID is generated automatically and inserted into the * message. - * + * * @param msg * The OF message to be sent * @return The XID used @@ -284,7 +284,7 @@ public class SwitchHandler implements ISwitch { * priority. It will be served first before normal priority messages. The * method should be used for critical messages such as hello, echo reply * etc. The specified XID is inserted into the message. - * + * * @param msg * The OF message to be sent * @return The XID used @@ -308,6 +308,48 @@ public class SwitchHandler implements ISwitch { } } + /** + * This method bypasses the transmit queue and sends the message over the + * socket directly. If the input xid is not null, the specified xid is + * inserted into the message. Otherwise, an unique xid is generated + * automatically and inserted into the message. + * + * @param msg + * Message to be sent + * @param xid + * Message xid + */ + private void asyncSendNow(OFMessage msg, Integer xid) { + if (xid == null) { + xid = getNextXid(); + } + msg.setXid(xid); + + asyncSendNow(msg); + } + + /** + * This method bypasses the transmit queue and sends the message over the + * socket directly. + * + * @param msg + * Message to be sent + */ + private void asyncSendNow(OFMessage msg) { + if (msgReadWriteService == null) { + logger.warn( + "asyncSendNow: {} is not sent because Message ReadWrite Service is not available.", + msg); + return; + } + + try { + msgReadWriteService.asyncSend(msg); + } catch (Exception e) { + reportError(e); + } + } + public void handleMessages() { List msgs = null; @@ -349,7 +391,8 @@ public class SwitchHandler implements ISwitch { case ECHO_REQUEST: OFEchoReply echoReply = (OFEchoReply) factory .getMessage(OFType.ECHO_REPLY); - asyncFastSend(echoReply); + // respond immediately + asyncSendNow(echoReply, msg.getXid()); break; case ECHO_REPLY: this.probeSent = false; @@ -822,7 +865,7 @@ public class SwitchHandler implements ISwitch { barrierMsg.setXid(xid); transmitQ.add(new PriorityMessage(barrierMsg, 0, true)); - + return Boolean.TRUE; } @@ -830,7 +873,7 @@ public class SwitchHandler implements ISwitch { * This method returns the switch liveness timeout value. If controller did * not receive any message from the switch for such a long period, * controller will tear down the connection to the switch. - * + * * @return The timeout value */ private static int getSwitchLivenessTimeout() { @@ -853,7 +896,7 @@ public class SwitchHandler implements ISwitch { * Barrier request message. Then it's blocked until the Barrier rely arrives * or timeout. If syncRequest is false, it simply skips the message send and * just waits for the response back. - * + * * @param msg * Message to be sent * @param xid diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java index 7614a4d128..dc84304a04 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java @@ -290,7 +290,8 @@ public class DataPacketMuxDemux implements IContainerListener, + data.length); po.setPacketData(data); - sw.asyncSend(po); + // send PACKET_OUT at high priority + sw.asyncFastSend(po); logger.trace("Transmitted a frame of size: {}", data.length); }