Nathan Skrzypczak | d4a7064 | 2021-10-08 14:01:27 +0200 | [diff] [blame] | 1 | .. _mtu_doc: |
| 2 | |
| 3 | MTU in VPP |
| 4 | ========== |
| 5 | |
| 6 | Maximum Transmission Unit is a term used to describe the maximum sized |
| 7 | “thingy” that can be sent out an interface. It can refer to the maximum |
| 8 | frame size that a NIC can send. On Ethernet that would include the |
| 9 | Ethernet header but typically not the IGF. It can refer to the maximum |
| 10 | packet size, that is, on Ethernet an MTU of 1500, would allow an IPv4 |
| 11 | packet of 1500 bytes, that would result in an Ethernet frame of 1518 |
| 12 | bytes. |
| 13 | |
| 14 | |
| 15 | VPP allows setting of the physical payload MTU. I.e. not including L2 |
| 16 | overhead. Setting the hardware MTU will program the NIC. This MTU will |
| 17 | be inherited by all software interfaces. |
| 18 | |
| 19 | VPP also allows setting of the payload MTU for software interfaces. |
| 20 | Independently of the MTU set on the hardware. If the software payload |
| 21 | MTU is set higher than the capability of the NIC, the packet will be |
| 22 | dropped. |
| 23 | |
| 24 | In addition VPP supports setting the MTU of individual network layer |
| 25 | protocols. IPv4, IPv6 or MPLS. For example an IPv4 MTU of 1500 (includes |
| 26 | the IPv4 header) will fit in a hardware payload MTU of 1500. |
| 27 | |
| 28 | *Note we might consider changing the hardware payload MTU to hardware |
| 29 | MTU*. That is, the MTU includes all L2 framing. Then the payload MTU can |
| 30 | be calculated based on the interface’s configuration. E.g. 802.1q tags |
| 31 | etc. |
| 32 | |
| 33 | There are currently no checks or warnings if e.g. the user configures a |
| 34 | per-protocol MTU larger than the underlying payload MTU. If that happens |
| 35 | packets will be fragmented or dropped. |
| 36 | |
| 37 | Data structures |
| 38 | ^^^^^^^^^^^^^^^ |
| 39 | |
| 40 | The hardware payload MTU is stored in the max_packet_bytes variable in |
| 41 | the vnet_hw_interface_t structure. |
| 42 | |
| 43 | The software MTU (previously max_l3_packet_bytes) is in |
| 44 | vnet_sw_interface_t->in mtu[VNET_N_MTU]. |
| 45 | |
| 46 | MTU API |
| 47 | ------- |
| 48 | |
| 49 | Set physical MTU |
| 50 | ^^^^^^^^^^^^^^^^ |
| 51 | |
| 52 | This API message is used to set the physical MTU. It is currently |
| 53 | limited to Ethernet interfaces. Note, this programs the NIC. |
| 54 | |
| 55 | :: |
| 56 | |
| 57 | autoreply define hw_interface_set_mtu |
| 58 | { |
| 59 | u32 client_index; |
| 60 | u32 context; |
| 61 | u32 sw_if_index; |
| 62 | u16 mtu; |
| 63 | }; |
| 64 | |
| 65 | Set the L2 payload MTU |
| 66 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 67 | |
| 68 | :: note |
| 69 | (not including the L2 header) and per-protocol MTUs |
| 70 | |
| 71 | This API message sets the L3 payload MTU. E.g. on Ethernet it is the |
| 72 | maximum size of the Ethernet payload. If a value is left as 0, then the |
| 73 | default is picked from VNET_MTU_L3. |
| 74 | |
| 75 | :: |
| 76 | |
| 77 | autoreply define sw_interface_set_mtu |
| 78 | { |
| 79 | u32 client_index; |
| 80 | u32 context; |
| 81 | u32 sw_if_index; |
| 82 | /* $$$$ Replace with enum */ |
| 83 | u32 mtu[4]; /* 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */ |
| 84 | }; |
| 85 | |
| 86 | Get interface MTU |
| 87 | ^^^^^^^^^^^^^^^^^ |
| 88 | |
| 89 | The various MTUs on an interface can be queried with the |
| 90 | sw_interface_dump/sw_interface_details calls. |
| 91 | |
| 92 | :: |
| 93 | |
| 94 | define sw_interface_details |
| 95 | { |
| 96 | /* MTU */ |
| 97 | u16 link_mtu; |
| 98 | |
| 99 | /* Per protocol MTUs */ |
| 100 | u32 mtu[4]; /* 0 - L3, 1 - IP4, 2 - IP6, 3 - MPLS */ |
| 101 | }; |
| 102 | |
| 103 | MTU CLI |
| 104 | ------- |
| 105 | |
| 106 | :: |
| 107 | |
| 108 | set interface mtu [packet|ip4|ip6|mpls] <value> <interface> |