HC2VPP-354: use hw_interface_set_mtu for Ethernet interfaces 91/12991/1
authorMarek Gradzki <mgradzki@cisco.com>
Mon, 11 Jun 2018 14:45:47 +0000 (16:45 +0200)
committerMarek Gradzki <mgradzki@cisco.com>
Mon, 11 Jun 2018 15:43:03 +0000 (17:43 +0200)
The API was renamed by
https://gerrit.fd.io/r/#/c/12930/

The VPP change spearates setting of hardware interface
and software interface MTU.

More details:
https://git.fd.io/vpp/tree/src/vnet/MTU.md

HC supports only hardware interface MTU configuration
for Ethernet interfaces.

MTU for software interfaces (per protocol MTU) is not
supported (HC2VPP-355).

Change-Id: I7eb1cb035a7b0f428a7bc7a9bb1c73819b52f0fa
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
v3po/api/src/main/yang/v3po@2017-06-07.yang
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizer.java
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/EthernetCustomizer.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java

index 50b8233..6a1eb38 100644 (file)
@@ -337,7 +337,9 @@ module v3po {
       default 9216;
       description
       "The size, in octets, of the largest packet that the
-       hardware interface will send and receive.";
+       hardware interface will send and receive.
+
+       Mapped to hw_interface_set_mtu VPP API message which programs the NIC.";
     }
   }
 
index 6945f45..dfac5b9 100644 (file)
@@ -21,7 +21,7 @@ import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.honeycomb.translate.write.WriteContext;
 import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetMtu;
+import io.fd.vpp.jvpp.core.dto.HwInterfaceSetMtu;
 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
 import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
@@ -75,10 +75,16 @@ public class EthernetCustomizer extends AbstractInterfaceTypeCustomizer<Ethernet
         final String name = id.firstKeyOf(Interface.class).getName();
         final int index = interfaceContext.getIndex(name, writeContext.getMappingContext());
         LOG.debug("Setting Ethernet attributes for interface: {}, {}. Ethernet: {}", name, index, dataAfter);
-        final SwInterfaceSetMtu request = new SwInterfaceSetMtu();
+
+        // Set the physical payload MTU. I.e. not including L2 overhead.
+        // Setting the hardware MTU will program the NIC.
+        // Setting MTU for software interfaces is currently not supported (TODO: HC2VPP-355).
+        // More details:
+        // https://git.fd.io/vpp/tree/src/vnet/MTU.md
+        final HwInterfaceSetMtu request = new HwInterfaceSetMtu();
         request.swIfIndex = index;
         request.mtu = dataAfter.getMtu().shortValue();
-        getReplyForWrite(getFutureJVpp().swInterfaceSetMtu(request).toCompletableFuture(), id);
+        getReplyForWrite(getFutureJVpp().hwInterfaceSetMtu(request).toCompletableFuture(), id);
         LOG.debug("Ethernet attributes set successfully for: {}, {}. Ethernet: {}", name, index, dataAfter);
     }
 }
index 8bb01a9..de329da 100644 (file)
@@ -65,6 +65,11 @@ public class EthernetCustomizer
         final SwInterfaceDetails iface = dumpManager.getInterfaceDetail(id, ctx, key.getName());
 
         if (iface.linkMtu != 0) {
+            // Read physical payload MTU (link_mtu) if given.
+            // VPP since 18.07 supports also setting MTUs for software interfaces,
+            // but these are not supported by HC (TODO: HC2VPP-355).
+            // More details:
+            // https://git.fd.io/vpp/tree/src/vnet/MTU.md
             builder.setMtu((int) iface.linkMtu);
         }
 
index eb47fdd..6ddcc9b 100644 (file)
@@ -24,8 +24,8 @@ import static org.mockito.Mockito.when;
 import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetMtu;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetMtuReply;
+import io.fd.vpp.jvpp.core.dto.HwInterfaceSetMtu;
+import io.fd.vpp.jvpp.core.dto.HwInterfaceSetMtuReply;
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
@@ -55,22 +55,22 @@ public class EthernetCustomizerTest extends WriterCustomizerTest {
 
     @Test
     public void testWrite() throws WriteFailedException {
-        when(api.swInterfaceSetMtu(any())).thenReturn(future(new SwInterfaceSetMtuReply()));
+        when(api.hwInterfaceSetMtu(any())).thenReturn(future(new HwInterfaceSetMtuReply()));
         final int mtu = 1234;
         customizer.writeCurrentAttributes(IF_IID, ethernet(mtu), writeContext);
-        verify(api).swInterfaceSetMtu(mtuSetRequest(mtu));
+        verify(api).hwInterfaceSetMtu(mtuSetRequest(mtu));
     }
 
     @Test
     public void testUpdate() throws WriteFailedException {
-        when(api.swInterfaceSetMtu(any())).thenReturn(future(new SwInterfaceSetMtuReply()));
+        when(api.hwInterfaceSetMtu(any())).thenReturn(future(new HwInterfaceSetMtuReply()));
         final int mtu = 5678;
         customizer.updateCurrentAttributes(IF_IID, mock(Ethernet.class), ethernet(mtu), writeContext);
-        verify(api).swInterfaceSetMtu(mtuSetRequest(mtu));
+        verify(api).hwInterfaceSetMtu(mtuSetRequest(mtu));
     }
 
-    private SwInterfaceSetMtu mtuSetRequest(final int mtu) {
-        final SwInterfaceSetMtu request = new SwInterfaceSetMtu();
+    private HwInterfaceSetMtu mtuSetRequest(final int mtu) {
+        final HwInterfaceSetMtu request = new HwInterfaceSetMtu();
         request.swIfIndex = IF_INDEX;
         request.mtu = (short)mtu;
         return request;