net/enic: enable overlay offload for VXLAN and GENEVE
[dpdk.git] / doc / guides / nics / enic.rst
1 ..  BSD LICENSE
2     Copyright (c) 2017, Cisco Systems, Inc.
3     All rights reserved.
4
5     Redistribution and use in source and binary forms, with or without
6     modification, are permitted provided that the following conditions
7     are met:
8
9     1. Redistributions of source code must retain the above copyright
10     notice, this list of conditions and the following disclaimer.
11
12     2. Redistributions in binary form must reproduce the above copyright
13     notice, this list of conditions and the following disclaimer in
14     the documentation and/or other materials provided with the
15     distribution.
16
17     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28     POSSIBILITY OF SUCH DAMAGE.
29
30 ENIC Poll Mode Driver
31 =====================
32
33 ENIC PMD is the DPDK poll-mode driver for the Cisco System Inc. VIC Ethernet
34 NICs. These adapters are also referred to as vNICs below. If you are running
35 or would like to run DPDK software applications on Cisco UCS servers using
36 Cisco VIC adapters the following documentation is relevant.
37
38 How to obtain ENIC PMD integrated DPDK
39 --------------------------------------
40
41 ENIC PMD support is integrated into the DPDK suite. dpdk-<version>.tar.gz
42 should be downloaded from http://dpdk.org
43
44
45 Configuration information
46 -------------------------
47
48 - **DPDK Configuration Parameters**
49
50   The following configuration options are available for the ENIC PMD:
51
52   - **CONFIG_RTE_LIBRTE_ENIC_PMD** (default y): Enables or disables inclusion
53     of the ENIC PMD driver in the DPDK compilation.
54
55 - **vNIC Configuration Parameters**
56
57   - **Number of Queues**
58
59     The maximum number of receive queues (RQs), work queues (WQs) and
60     completion queues (CQs) are configurable on a per vNIC basis
61     through the Cisco UCS Manager (CIMC or UCSM).
62
63     These values should be configured as follows:
64
65     - The number of WQs should be greater or equal to the value of the
66       expected nb_tx_q parameter in the call to
67       rte_eth_dev_configure()
68
69     - The number of RQs configured in the vNIC should be greater or
70       equal to *twice* the value of the expected nb_rx_q parameter in
71       the call to rte_eth_dev_configure().  With the addition of Rx
72       scatter, a pair of RQs on the vnic is needed for each receive
73       queue used by DPDK, even if Rx scatter is not being used.
74       Having a vNIC with only 1 RQ is not a valid configuration, and
75       will fail with an error message.
76
77     - The number of CQs should set so that there is one CQ for each
78       WQ, and one CQ for each pair of RQs.
79
80     For example: If the application requires 3 Rx queues, and 3 Tx
81     queues, the vNIC should be configured to have at least 3 WQs, 6
82     RQs (3 pairs), and 6 CQs (3 for use by WQs + 3 for use by the 3
83     pairs of RQs).
84
85   - **Size of Queues**
86
87     Likewise, the number of receive and transmit descriptors are configurable on
88     a per-vNIC basis via the UCS Manager and should be greater than or equal to
89     the nb_rx_desc and   nb_tx_desc parameters expected to be used in the calls
90     to rte_eth_rx_queue_setup() and rte_eth_tx_queue_setup() respectively.
91     An application requesting more than the set size will be limited to that
92     size.
93
94     Unless there is a lack of resources due to creating many vNICs, it
95     is recommended that the WQ and RQ sizes be set to the maximum.  This
96     gives the application the greatest amount of flexibility in its
97     queue configuration.
98
99     - *Note*: Since the introduction of Rx scatter, for performance
100       reasons, this PMD uses two RQs on the vNIC per receive queue in
101       DPDK.  One RQ holds descriptors for the start of a packet, and the
102       second RQ holds the descriptors for the rest of the fragments of
103       a packet.  This means that the nb_rx_desc parameter to
104       rte_eth_rx_queue_setup() can be a greater than 4096.  The exact
105       amount will depend on the size of the mbufs being used for
106       receives, and the MTU size.
107
108       For example: If the mbuf size is 2048, and the MTU is 9000, then
109       receiving a full size packet will take 5 descriptors, 1 from the
110       start-of-packet queue, and 4 from the second queue.  Assuming
111       that the RQ size was set to the maximum of 4096, then the
112       application can specify up to 1024 + 4096 as the nb_rx_desc
113       parameter to rte_eth_rx_queue_setup().
114
115   - **Interrupts**
116
117     At least one interrupt per vNIC interface should be configured in the UCS
118     manager regardless of the number receive/transmit queues. The ENIC PMD
119     uses this interrupt to get information about link status and errors
120     in the fast path.
121
122     In addition to the interrupt for link status and errors, when using Rx queue
123     interrupts, increase the number of configured interrupts so that there is at
124     least one interrupt for each Rx queue. For example, if the app uses 3 Rx
125     queues and wants to use per-queue interrupts, configure 4 (3 + 1) interrupts.
126
127 .. _enic-flow-director:
128
129 Flow director support
130 ---------------------
131
132 Advanced filtering support was added to 1300 series VIC firmware starting
133 with version 2.0.13 for C-series UCS servers and version 3.1.2 for UCSM
134 managed blade servers. In order to enable advanced filtering the 'Advanced
135 filter' radio button should be enabled via CIMC or UCSM followed by a reboot
136 of the server.
137
138 With advanced filters, perfect matching of all fields of IPv4, IPv6 headers
139 as well as TCP, UDP and SCTP L4 headers is available through flow director.
140 Masking of these fields for partial match is also supported.
141
142 Without advanced filter support, the flow director is limited to IPv4
143 perfect filtering of the 5-tuple with no masking of fields supported.
144
145 SR-IOV mode utilization
146 -----------------------
147
148 UCS blade servers configured with dynamic vNIC connection policies in UCS
149 manager are capable of supporting assigned devices on virtual machines (VMs)
150 through a KVM hypervisor. Assigned devices, also known as 'passthrough'
151 devices, are SR-IOV virtual functions (VFs) on the host which are exposed
152 to VM instances.
153
154 The Cisco Virtual Machine Fabric Extender (VM-FEX) gives the VM a dedicated
155 interface on the Fabric Interconnect (FI). Layer 2 switching is done at
156 the FI. This may eliminate the requirement for software switching on the
157 host to route intra-host VM traffic.
158
159 Please refer to `Creating a Dynamic vNIC Connection Policy
160 <http://www.cisco.com/c/en/us/td/docs/unified_computing/ucs/sw/vm_fex/vmware/gui/config_guide/b_GUI_VMware_VM-FEX_UCSM_Configuration_Guide/b_GUI_VMware_VM-FEX_UCSM_Configuration_Guide_chapter_010.html#task_433E01651F69464783A68E66DA8A47A5>`_
161 for information on configuring SR-IOV adapter policies using UCS manager.
162
163 Once the policies are in place and the host OS is rebooted, VFs should be
164 visible on the host, E.g.:
165
166 .. code-block:: console
167
168      # lspci | grep Cisco | grep Ethernet
169      0d:00.0 Ethernet controller: Cisco Systems Inc VIC Ethernet NIC (rev a2)
170      0d:00.1 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
171      0d:00.2 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
172      0d:00.3 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
173      0d:00.4 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
174      0d:00.5 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
175      0d:00.6 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
176      0d:00.7 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
177
178 Enable Intel IOMMU on the host and install KVM and libvirt. A VM instance should
179 be created with an assigned device. When using libvirt, this configuration can
180 be done within the domain (i.e. VM) config file. For example this entry maps
181 host VF 0d:00:01 into the VM.
182
183 .. code-block:: console
184
185     <interface type='hostdev' managed='yes'>
186       <mac address='52:54:00:ac:ff:b6'/>
187       <source>
188         <address type='pci' domain='0x0000' bus='0x0d' slot='0x00' function='0x1'/>
189       </source>
190
191 Alternatively, the configuration can be done in a separate file using the
192 ``network`` keyword. These methods are described in the libvirt documentation for
193 `Network XML format <https://libvirt.org/formatnetwork.html>`_.
194
195 When the VM instance is started, the ENIC KVM driver will bind the host VF to
196 vfio, complete provisioning on the FI and bring up the link.
197
198 .. note::
199
200     It is not possible to use a VF directly from the host because it is not
201     fully provisioned until the hypervisor brings up the VM that it is assigned
202     to.
203
204 In the VM instance, the VF will now be visible. E.g., here the VF 00:04.0 is
205 seen on the VM instance and should be available for binding to a DPDK.
206
207 .. code-block:: console
208
209      # lspci | grep Ether
210      00:04.0 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
211
212 Follow the normal DPDK install procedure, binding the VF to either ``igb_uio``
213 or ``vfio`` in non-IOMMU mode.
214
215 Please see :ref:`Limitations <enic_limitations>` for limitations in
216 the use of SR-IOV.
217
218 .. _enic-genic-flow-api:
219
220 Generic Flow API support
221 ------------------------
222
223 Generic Flow API is supported. The baseline support is:
224
225 - **1200 series VICs**
226
227   5-tuple exact flow support for 1200 series adapters. This allows:
228
229   - Attributes: ingress
230   - Items: ipv4, ipv6, udp, tcp (must exactly match src/dst IP
231     addresses and ports and all must be specified)
232   - Actions: queue and void
233   - Selectors: 'is'
234
235 - **1300 and later series VICS with advanced filters disabled**
236
237   With advanced filters disabled, an IPv4 or IPv6 item must be specified
238   in the pattern.
239
240   - Attributes: ingress
241   - Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth, ipv4, ipv6, udp, tcp
242   - Actions: queue and void
243   - Selectors: 'is', 'spec' and 'mask'. 'last' is not supported
244   - In total, up to 64 bytes of mask is allowed across all headers
245
246 - **1300 and later series VICS with advanced filters enabled**
247
248   - Attributes: ingress
249   - Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth, ipv4, ipv6, udp, tcp
250   - Actions: queue, mark, drop, flag and void
251   - Selectors: 'is', 'spec' and 'mask'. 'last' is not supported
252   - In total, up to 64 bytes of mask is allowed across all headers
253
254 More features may be added in future firmware and new versions of the VIC.
255 Please refer to the release notes.
256
257 .. _overlay_offload:
258
259 Overlay Offload
260 ---------------
261
262 Recent hardware models support overlay offload. When enabled, the NIC performs
263 the following operations for VXLAN, NVGRE, and GENEVE packets. In all cases,
264 inner and outer packets can be IPv4 or IPv6.
265
266 - TSO for VXLAN and GENEVE packets.
267
268   Hardware supports NVGRE TSO, but DPDK currently has no NVGRE offload flags.
269
270 - Tx checksum offloads.
271
272   The NIC fills in IPv4/UDP/TCP checksums for both inner and outer packets.
273
274 - Rx checksum offloads.
275
276   The NIC validates IPv4/UDP/TCP checksums of both inner and outer packets.
277   Good checksum flags (e.g. ``PKT_RX_L4_CKSUM_GOOD``) indicate that the inner
278   packet has the correct checksum, and if applicable, the outer packet also
279   has the correct checksum. Bad checksum flags (e.g. ``PKT_RX_L4_CKSUM_BAD``)
280   indicate that the inner and/or outer packets have invalid checksum values.
281
282 - Inner Rx packet type classification
283
284   PMD sets inner L3/L4 packet types (e.g. ``RTE_PTYPE_INNER_L4_TCP``), and
285   ``RTE_PTYPE_TUNNEL_GRENAT`` to indicate that the packet is tunneled.
286   PMD does not set L3/L4 packet types for outer packets.
287
288 - Inner RSS
289
290   RSS hash calculation, therefore queue selection, is done on inner packets.
291
292 In order to enable overlay offload, the 'Enable VXLAN' box should be checked
293 via CIMC or UCSM followed by a reboot of the server. When PMD successfully
294 enables overlay offload, it prints the following message on the console.
295
296 .. code-block:: console
297
298     Overlay offload is enabled
299
300 By default, PMD enables overlay offload if hardware supports it. To disable
301 it, set ``devargs`` parameter ``disable-overlay=1``. For example::
302
303     -w 12:00.0,disable-overlay=1
304
305 .. _enic_limitations:
306
307 Limitations
308 -----------
309
310 - **VLAN 0 Priority Tagging**
311
312   If a vNIC is configured in TRUNK mode by the UCS manager, the adapter will
313   priority tag egress packets according to 802.1Q if they were not already
314   VLAN tagged by software. If the adapter is connected to a properly configured
315   switch, there will be no unexpected behavior.
316
317   In test setups where an Ethernet port of a Cisco adapter in TRUNK mode is
318   connected point-to-point to another adapter port or connected though a router
319   instead of a switch, all ingress packets will be VLAN tagged. Programs such
320   as l3fwd which do not account for VLAN tags in packets will misbehave. The
321   solution is to enable VLAN stripping on ingress. The following code fragment is
322   an example of how to accomplish this:
323
324 .. code-block:: console
325
326      vlan_offload = rte_eth_dev_get_vlan_offload(port);
327      vlan_offload |= ETH_VLAN_STRIP_OFFLOAD;
328      rte_eth_dev_set_vlan_offload(port, vlan_offload);
329
330 - Limited flow director support on 1200 series and 1300 series Cisco VIC
331   adapters with old firmware. Please see :ref:`enic-flow-director`.
332
333 - Flow director features are not supported on generation 1 Cisco VIC adapters
334   (M81KR and P81E)
335
336 - **SR-IOV**
337
338   - KVM hypervisor support only. VMware has not been tested.
339   - Requires VM-FEX, and so is only available on UCS managed servers connected
340     to Fabric Interconnects. It is not on standalone C-Series servers.
341   - VF devices are not usable directly from the host. They can  only be used
342     as assigned devices on VM instances.
343   - Currently, unbind of the ENIC kernel mode driver 'enic.ko' on the VM
344     instance may hang. As a workaround, enic.ko should be blacklisted or removed
345     from the boot process.
346   - pci_generic cannot be used as the uio module in the VM. igb_uio or
347     vfio in non-IOMMU mode can be used.
348   - The number of RQs in UCSM dynamic vNIC configurations must be at least 2.
349   - The number of SR-IOV devices is limited to 256. Components on target system
350     might limit this number to fewer than 256.
351
352 - **Flow API**
353
354   - The number of filters that can be specified with the Generic Flow API is
355     dependent on how many header fields are being masked. Use 'flow create' in
356     a loop to determine how many filters your VIC will support (not more than
357     1000 for 1300 series VICs). Filters are checked for matching in the order they
358     were added. Since there currently is no grouping or priority support,
359     'catch-all' filters should be added last.
360
361 - **Statistics**
362
363   - ``rx_good_bytes`` (ibytes) always includes VLAN header (4B) and CRC bytes (4B).
364     This behavior applies to 1300 and older series VIC adapters.
365     1400 series VICs do not count CRC bytes, and count VLAN header only when VLAN
366     stripping is disabled.
367   - When the NIC drops a packet because the Rx queue has no free buffers,
368     ``rx_good_bytes`` still increments by 4B if the packet is not VLAN tagged or
369     VLAN stripping is disabled, or by 8B if the packet is VLAN tagged and stripping
370     is enabled.
371     This behavior applies to 1300 and older series VIC adapters. 1400 series VICs
372     do not increment this byte counter when packets are dropped.
373
374 - **RSS Hashing**
375
376   - Hardware enables and disables UDP and TCP RSS hashing together. The driver
377     cannot control UDP and TCP hashing individually.
378
379 How to build the suite
380 ----------------------
381
382 The build instructions for the DPDK suite should be followed. By default
383 the ENIC PMD library will be built into the DPDK library.
384
385 Refer to the document :ref:`compiling and testing a PMD for a NIC
386 <pmd_build_and_test>` for details.
387
388 For configuring and using UIO and VFIO frameworks, please refer to the
389 documentation that comes with DPDK suite.
390
391 Supported Cisco VIC adapters
392 ----------------------------
393
394 ENIC PMD supports all recent generations of Cisco VIC adapters including:
395
396 - VIC 1200 series
397 - VIC 1300 series
398 - VIC 1400 series
399
400 Supported Operating Systems
401 ---------------------------
402
403 Any Linux distribution fulfilling the conditions described in Dependencies
404 section of DPDK documentation.
405
406 Supported features
407 ------------------
408
409 - Unicast, multicast and broadcast transmission and reception
410 - Receive queue polling
411 - Port Hardware Statistics
412 - Hardware VLAN acceleration
413 - IP checksum offload
414 - Receive side VLAN stripping
415 - Multiple receive and transmit queues
416 - Flow Director ADD, UPDATE, DELETE, STATS operation support IPv4 and IPv6
417 - Promiscuous mode
418 - Setting RX VLAN (supported via UCSM/CIMC only)
419 - VLAN filtering (supported via UCSM/CIMC only)
420 - Execution of application by unprivileged system users
421 - IPV4, IPV6 and TCP RSS hashing
422 - UDP hashing (1400 series and later adapters)
423 - Scattered Rx
424 - MTU update
425 - SR-IOV on UCS managed servers connected to Fabric Interconnects
426 - Flow API
427 - Overlay offload
428
429   - Rx/Tx checksum offloads for VXLAN, NVGRE, GENEVE
430   - TSO for VXLAN and GENEVE packets
431   - Inner RSS
432
433 Known bugs and unsupported features in this release
434 ---------------------------------------------------
435
436 - Signature or flex byte based flow direction
437 - Drop feature of flow direction
438 - VLAN based flow direction
439 - Non-IPV4 flow direction
440 - Setting of extended VLAN
441 - MTU update only works if Scattered Rx mode is disabled
442 - Maximum receive packet length is ignored if Scattered Rx mode is used
443
444 Prerequisites
445 -------------
446
447 - Prepare the system as recommended by DPDK suite.  This includes environment
448   variables, hugepages configuration, tool-chains and configuration.
449 - Insert vfio-pci kernel module using the command 'modprobe vfio-pci' if the
450   user wants to use VFIO framework.
451 - Insert uio kernel module using the command 'modprobe uio' if the user wants
452   to use UIO framework.
453 - DPDK suite should be configured based on the user's decision to use VFIO or
454   UIO framework.
455 - If the vNIC device(s) to be used is bound to the kernel mode Ethernet driver
456   use 'ip' to bring the interface down. The dpdk-devbind.py tool can
457   then be used to unbind the device's bus id from the ENIC kernel mode driver.
458 - Bind the intended vNIC to vfio-pci in case the user wants ENIC PMD to use
459   VFIO framework using dpdk-devbind.py.
460 - Bind the intended vNIC to igb_uio in case the user wants ENIC PMD to use
461   UIO framework using dpdk-devbind.py.
462
463 At this point the system should be ready to run DPDK applications. Once the
464 application runs to completion, the vNIC can be detached from vfio-pci or
465 igb_uio if necessary.
466
467 Root privilege is required to bind and unbind vNICs to/from VFIO/UIO.
468 VFIO framework helps an unprivileged user to run the applications.
469 For an unprivileged user to run the applications on DPDK and ENIC PMD,
470 it may be necessary to increase the maximum locked memory of the user.
471 The following command could be used to do this.
472
473 .. code-block:: console
474
475     sudo sh -c "ulimit -l <value in Kilo Bytes>"
476
477 The value depends on the memory configuration of the application, DPDK and
478 PMD.  Typically, the limit has to be raised to higher than 2GB.
479 e.g., 2621440
480
481 The compilation of any unused drivers can be disabled using the
482 configuration file in config/ directory (e.g., config/common_linuxapp).
483 This would help in bringing down the time taken for building the
484 libraries and the initialization time of the application.
485
486 Additional Reference
487 --------------------
488
489 - https://www.cisco.com/c/en/us/products/servers-unified-computing/index.html
490 - https://www.cisco.com/c/en/us/products/interfaces-modules/unified-computing-system-adapters/index.html
491
492 Contact Information
493 -------------------
494
495 Any questions or bugs should be reported to DPDK community and to the ENIC PMD
496 maintainers:
497
498 - John Daley <johndale@cisco.com>
499 - Nelson Escobar <neescoba@cisco.com>