diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2018-06-11 16:45:47 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2018-06-11 17:43:03 +0200 |
commit | 076ed09e9eaeeb751ce87bac67ae0becc7b2417b (patch) | |
tree | a78613196db4710cf4b26a6149e9bba781f62f8d | |
parent | 887fb8a181146390bccb6eaf5caeb0a84659c750 (diff) |
HC2VPP-354: use hw_interface_set_mtu for Ethernet interfaces
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>
4 files changed, 25 insertions, 12 deletions
diff --git a/v3po/api/src/main/yang/v3po@2017-06-07.yang b/v3po/api/src/main/yang/v3po@2017-06-07.yang index 50b823385..6a1eb3809 100644 --- a/v3po/api/src/main/yang/v3po@2017-06-07.yang +++ b/v3po/api/src/main/yang/v3po@2017-06-07.yang @@ -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."; } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizer.java index 6945f45e7..dfac5b99d 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizer.java @@ -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); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/EthernetCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/EthernetCustomizer.java index 8bb01a98b..de329da85 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/EthernetCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/EthernetCustomizer.java @@ -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); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java index eb47fddfb..6ddcc9bb2 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/EthernetCustomizerTest.java @@ -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; |