New upstream version 17.11.4
[deb_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   - **CONFIG_RTE_LIBRTE_ENIC_DEBUG** (default n): Enables or disables debug
56     logging within the ENIC PMD driver.
57
58 - **vNIC Configuration Parameters**
59
60   - **Number of Queues**
61
62     The maximum number of receive queues (RQs), work queues (WQs) and
63     completion queues (CQs) are configurable on a per vNIC basis
64     through the Cisco UCS Manager (CIMC or UCSM).
65
66     These values should be configured as follows:
67
68     - The number of WQs should be greater or equal to the value of the
69       expected nb_tx_q parameter in the call to the
70       rte_eth_dev_configure()
71
72     - The number of RQs configured in the vNIC should be greater or
73       equal to *twice* the value of the expected nb_rx_q parameter in
74       the call to rte_eth_dev_configure().  With the addition of Rx
75       scatter, a pair of RQs on the vnic is needed for each receive
76       queue used by DPDK, even if Rx scatter is not being used.
77       Having a vNIC with only 1 RQ is not a valid configuration, and
78       will fail with an error message.
79
80     - The number of CQs should set so that there is one CQ for each
81       WQ, and one CQ for each pair of RQs.
82
83     For example: If the application requires 3 Rx queues, and 3 Tx
84     queues, the vNIC should be configured to have at least 3 WQs, 6
85     RQs (3 pairs), and 6 CQs (3 for use by WQs + 3 for use by the 3
86     pairs of RQs).
87
88   - **Size of Queues**
89
90     Likewise, the number of receive and transmit descriptors are configurable on
91     a per vNIC bases via the UCS Manager and should be greater than or equal to
92     the nb_rx_desc and   nb_tx_desc parameters expected to be used in the calls
93     to rte_eth_rx_queue_setup() and rte_eth_tx_queue_setup() respectively.
94     An application requesting more than the set size will be limited to that
95     size.
96
97     Unless there is a lack of resources due to creating many vNICs, it
98     is recommended that the WQ and RQ sizes be set to the maximum.  This
99     gives the application the greatest amount of flexibility in its
100     queue configuration.
101
102     - *Note*: Since the introduction of Rx scatter, for performance
103       reasons, this PMD uses two RQs on the vNIC per receive queue in
104       DPDK.  One RQ holds descriptors for the start of a packet the
105       second RQ holds the descriptors for the rest of the fragments of
106       a packet.  This means that the nb_rx_desc parameter to
107       rte_eth_rx_queue_setup() can be a greater than 4096.  The exact
108       amount will depend on the size of the mbufs being used for
109       receives, and the MTU size.
110
111       For example: If the mbuf size is 2048, and the MTU is 9000, then
112       receiving a full size packet will take 5 descriptors, 1 from the
113       start of packet queue, and 4 from the second queue.  Assuming
114       that the RQ size was set to the maximum of 4096, then the
115       application can specify up to 1024 + 4096 as the nb_rx_desc
116       parameter to rte_eth_rx_queue_setup().
117
118   - **Interrupts**
119
120     Only one interrupt per vNIC interface should be configured in the UCS
121     manager regardless of the number receive/transmit queues. The ENIC PMD
122     uses this interrupt to get information about link status and errors
123     in the fast path.
124
125 .. _enic-flow-director:
126
127 Flow director support
128 ---------------------
129
130 Advanced filtering support was added to 1300 series VIC firmware starting
131 with version 2.0.13 for C-series UCS servers and version 3.1.2 for UCSM
132 managed blade servers. In order to enable advanced filtering the 'Advanced
133 filter' radio button should be enabled via CIMC or UCSM followed by a reboot
134 of the server.
135
136 With advanced filters, perfect matching of all fields of IPv4, IPv6 headers
137 as well as TCP, UDP and SCTP L4 headers is available through flow director.
138 Masking of these fields for partial match is also supported.
139
140 Without advanced filter support, the flow director is limited to IPv4
141 perfect filtering of the 5-tuple with no masking of fields supported.
142
143 SR-IOV mode utilization
144 -----------------------
145
146 UCS blade servers configured with dynamic vNIC connection policies in UCS
147 manager are capable of supporting assigned devices on virtual machines (VMs)
148 through a KVM hypervisor. Assigned devices, also known as 'passthrough'
149 devices, are SR-IOV virtual functions (VFs) on the host which are exposed
150 to VM instances.
151
152 The Cisco Virtual Machine Fabric Extender (VM-FEX) gives the VM a dedicated
153 interface on the Fabric Interconnect (FI). Layer 2 switching is done at
154 the FI. This may eliminate the requirement for software switching on the
155 host to route intra-host VM traffic.
156
157 Please refer to `Creating a Dynamic vNIC Connection Policy
158 <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>`_
159 for information on configuring SR-IOV Adapter policies using UCS manager.
160
161 Once the policies are in place and the host OS is rebooted, VFs should be
162 visible on the host, E.g.:
163
164 .. code-block:: console
165
166      # lspci | grep Cisco | grep Ethernet
167      0d:00.0 Ethernet controller: Cisco Systems Inc VIC Ethernet NIC (rev a2)
168      0d:00.1 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
169      0d:00.2 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
170      0d:00.3 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
171      0d:00.4 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
172      0d:00.5 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
173      0d:00.6 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
174      0d:00.7 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
175
176 Enable Intel IOMMU on the host and install KVM and libvirt. A VM instance should
177 be created with an assigned device. When using libvirt, this configuration can
178 be done within the domain (i.e. VM) config file. For example this entry maps
179 host VF 0d:00:01 into the VM.
180
181 .. code-block:: console
182
183     <interface type='hostdev' managed='yes'>
184       <mac address='52:54:00:ac:ff:b6'/>
185       <source>
186         <address type='pci' domain='0x0000' bus='0x0d' slot='0x00' function='0x1'/>
187       </source>
188
189 Alternatively, the configuration can be done in a separate file using the
190 ``network`` keyword. These methods are described in the libvirt documentation for
191 `Network XML format <https://libvirt.org/formatnetwork.html>`_.
192
193 When the VM instance is started, the ENIC KVM driver will bind the host VF to
194 vfio, complete provisioning on the FI and bring up the link.
195
196 .. note::
197
198     It is not possible to use a VF directly from the host because it is not
199     fully provisioned until the hypervisor brings up the VM that it is assigned
200     to.
201
202 In the VM instance, the VF will now be visible. E.g., here the VF 00:04.0 is
203 seen on the VM instance and should be available for binding to a DPDK.
204
205 .. code-block:: console
206
207      # lspci | grep Ether
208      00:04.0 Ethernet controller: Cisco Systems Inc VIC SR-IOV VF (rev a2)
209
210 Follow the normal DPDK install procedure, binding the VF to either ``igb_uio``
211 or ``vfio`` in non-IOMMU mode.
212
213 Please see :ref:`Limitations <enic_limitations>` for limitations in
214 the use of SR-IOV.
215
216 .. _enic-genic-flow-api:
217
218 Generic Flow API support
219 ------------------------
220
221 Generic Flow API is supported. The baseline support is:
222
223 - **1200 series VICs**
224
225   5-tuple exact Flow support for 1200 series adapters. This allows:
226
227   - Attributes: ingress
228   - Items: ipv4, ipv6, udp, tcp (must exactly match src/dst IP
229     addresses and ports and all must be specified).
230   - Actions: queue and void
231   - Selectors: 'is'
232
233 - **1300 series VICS with Advanced filters disabled**
234
235   With advanced filters disabled, an IPv4 or IPv6 item must be specified
236   in the pattern.
237
238   - Attributes: ingress
239   - Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth, ipv4, ipv6, udp, tcp
240   - Actions: queue and void
241   - Selectors: 'is', 'spec' and 'mask'. 'last' is not supported
242   - In total, up to 64 bytes of mask is allowed across all haeders
243
244 - **1300 series VICS with Advanced filters enabled**
245
246   - Attributes: ingress
247   - Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth, ipv4, ipv6, udp, tcp
248   - Actions: queue, mark, flag and void
249   - Selectors: 'is', 'spec' and 'mask'. 'last' is not supported
250   - In total, up to 64 bytes of mask is allowed across all haeders
251
252 More features may be added in future firmware and new versions of the VIC.
253 Please refer to the release notes.
254
255 Ingress VLAN Rewrite
256 --------------------
257
258 VIC adapters can tag, untag, or modify the VLAN headers of ingress
259 packets. The ingress VLAN rewrite mode controls this behavior. By
260 default, it is set to pass-through, where the NIC does not modify the
261 VLAN header in any way so that the application can see the original
262 header. This mode is sufficient for many applications, but may not be
263 suitable for others. Such applications may change the mode by setting
264 ``devargs`` parameter ``ig-vlan-rewrite`` to one of the following.
265
266 - ``pass``: Pass-through mode. The NIC does not modify the VLAN
267   header. This is the default mode.
268
269 - ``priority``: Priority-tag default VLAN mode. If the ingress packet
270   is tagged with the default VLAN, the NIC replaces its VLAN header
271   with the priority tag (VLAN ID 0).
272
273 - ``trunk``: Default trunk mode. The NIC tags untagged ingress packets
274   with the default VLAN. Tagged ingress packets are not modified. To
275   the application, every packet appears as tagged.
276
277 - ``untag``: Untag default VLAN mode. If the ingress packet is tagged
278   with the default VLAN, the NIC removes or untags its VLAN header so
279   that the application sees an untagged packet. As a result, the
280   default VLAN becomes `untagged`. This mode can be useful for
281   applications such as OVS-DPDK performance benchmarks that utilize
282   only the default VLAN and want to see only untagged packets.
283
284 .. _enic_limitations:
285
286 Limitations
287 -----------
288
289 - **VLAN 0 Priority Tagging**
290
291   If a vNIC is configured in TRUNK mode by the UCS manager, the adapter will
292   priority tag egress packets according to 802.1Q if they were not already
293   VLAN tagged by software. If the adapter is connected to a properly configured
294   switch, there will be no unexpected behavior.
295
296   In test setups where an Ethernet port of a Cisco adapter in TRUNK mode is
297   connected point-to-point to another adapter port or connected though a router
298   instead of a switch, all ingress packets will be VLAN tagged. Programs such
299   as l3fwd may not account for VLAN tags in packets and may misbehave. One
300   solution is to enable VLAN stripping on ingress so the VLAN tag is removed
301   from the packet and put into the mbuf->vlan_tci field. Here is an example
302   of how to accomplish this:
303
304 .. code-block:: console
305
306      vlan_offload = rte_eth_dev_get_vlan_offload(port);
307      vlan_offload |= ETH_VLAN_STRIP_OFFLOAD;
308      rte_eth_dev_set_vlan_offload(port, vlan_offload);
309
310 Another alternative is modify the adapter's ingress VLAN rewrite mode so that
311 packets with the default VLAN tag are stripped by the adapter and presented to
312 DPDK as untagged packets. In this case mbuf->vlan_tci and the PKT_RX_VLAN and
313 PKT_RX_VLAN_STRIPPED mbuf flags would not be set. This mode is enabled with the
314 ``devargs`` parameter ``ig-vlan-rewrite=untag``. For example::
315
316     -w 12:00.0,ig-vlan-rewrite=untag
317
318 - Limited flow director support on 1200 series and 1300 series Cisco VIC
319   adapters with old firmware. Please see :ref:`enic-flow-director`.
320
321 - Flow director features are not supported on generation 1 Cisco VIC adapters
322   (M81KR and P81E)
323
324 - **SR-IOV**
325
326   - KVM hypervisor support only. VMware has not been tested.
327   - Requires VM-FEX, and so is only available on UCS managed servers connected
328     to Fabric Interconnects. It is not on standalone C-Series servers.
329   - VF devices are not usable directly from the host. They can  only be used
330     as assigned devices on VM instances.
331   - Currently, unbind of the ENIC kernel mode driver 'enic.ko' on the VM
332     instance may hang. As a workaround, enic.ko should blacklisted or removed
333     from the boot process.
334   - pci_generic cannot be used as the uio module in the VM. igb_uio or
335     vfio in non-IOMMU mode can be used.
336   - The number of RQs in UCSM dynamic vNIC configurations must be at least 2.
337   - The number of SR-IOV devices is limited to 256. Components on target system
338     might limit this number to fewer than 256.
339
340 - **Flow API**
341
342   - The number of filters that can be specified with the Generic Flow API is
343     dependent on how many header fields are being masked. Use 'flow create' in
344     a loop to determine how many filters your VIC will support (not more than
345     1000 for 1300 series VICs). Filter are checked for matching in the order they
346     were added. Since there currently is no grouping or priority support,
347     'catch-all' filters should be added last.
348
349 How to build the suite
350 ----------------------
351
352 The build instructions for the DPDK suite should be followed. By default
353 the ENIC PMD library will be built into the DPDK library.
354
355 Refer to the document :ref:`compiling and testing a PMD for a NIC
356 <pmd_build_and_test>` for details.
357
358 By default the ENIC PMD library will be built into the DPDK library.
359
360 For configuring and using UIO and VFIO frameworks, please refer to the
361 documentation that comes with DPDK suite.
362
363 Supported Cisco VIC adapters
364 ----------------------------
365
366 ENIC PMD supports all recent generations of Cisco VIC adapters including:
367
368 - VIC 1280
369 - VIC 1240
370 - VIC 1225
371 - VIC 1285
372 - VIC 1225T
373 - VIC 1227
374 - VIC 1227T
375 - VIC 1380
376 - VIC 1340
377 - VIC 1385
378 - VIC 1387
379
380 Supported Operating Systems
381 ---------------------------
382
383 Any Linux distribution fulfilling the conditions described in Dependencies
384 section of DPDK documentation.
385
386 Supported features
387 ------------------
388
389 - Unicast, multicast and broadcast transmission and reception
390 - Receive queue polling
391 - Port Hardware Statistics
392 - Hardware VLAN acceleration
393 - IP checksum offload
394 - Receive side VLAN stripping
395 - Multiple receive and transmit queues
396 - Flow Director ADD, UPDATE, DELETE, STATS operation support IPv4 and IPv6
397 - Promiscuous mode
398 - Setting RX VLAN (supported via UCSM/CIMC only)
399 - VLAN filtering (supported via UCSM/CIMC only)
400 - Execution of application by unprivileged system users
401 - IPV4, IPV6 and TCP RSS hashing
402 - Scattered Rx
403 - MTU update
404 - SR-IOV on UCS managed servers connected to Fabric Interconnects.
405 - Flow API
406
407 Known bugs and unsupported features in this release
408 ---------------------------------------------------
409
410 - Signature or flex byte based flow direction
411 - Drop feature of flow direction
412 - VLAN based flow direction
413 - non-IPV4 flow direction
414 - Setting of extended VLAN
415 - UDP RSS hashing
416 - MTU update only works if Scattered Rx mode is disabled
417
418 Prerequisites
419 -------------
420
421 - Prepare the system as recommended by DPDK suite.  This includes environment
422   variables, hugepages configuration, tool-chains and configuration
423 - Insert vfio-pci kernel module using the command 'modprobe vfio-pci' if the
424   user wants to use VFIO framework
425 - Insert uio kernel module using the command 'modprobe uio' if the user wants
426   to use UIO framework
427 - DPDK suite should be configured based on the user's decision to use VFIO or
428   UIO framework
429 - If the vNIC device(s) to be used is bound to the kernel mode Ethernet driver
430   use 'ifconfig' to bring the interface down. The dpdk-devbind.py tool can
431   then be used to unbind the device's bus id from the ENIC kernel mode driver.
432 - Bind the intended vNIC to vfio-pci in case the user wants ENIC PMD to use
433   VFIO framework using dpdk-devbind.py.
434 - Bind the intended vNIC to igb_uio in case the user wants ENIC PMD to use
435   UIO framework using dpdk-devbind.py.
436
437 At this point the system should be ready to run DPDK applications. Once the
438 application runs to completion, the vNIC can be detached from vfio-pci or
439 igb_uio if necessary.
440
441 Root privilege is required to bind and unbind vNICs to/from VFIO/UIO.
442 VFIO framework helps an unprivileged user to run the applications.
443 For an unprivileged user to run the applications on DPDK and ENIC PMD,
444 it may be necessary to increase the maximum locked memory of the user.
445 The following command could be used to do this.
446
447 .. code-block:: console
448
449     sudo sh -c "ulimit -l <value in Kilo Bytes>"
450
451 The value depends on the memory configuration of the application, DPDK and
452 PMD.  Typically, the limit has to be raised to higher than 2GB.
453 e.g., 2621440
454
455 The compilation of any unused drivers can be disabled using the
456 configuration file in config/ directory (e.g., config/common_linuxapp).
457 This would help in bringing down the time taken for building the
458 libraries and the initialization time of the application.
459
460 Additional Reference
461 --------------------
462
463 - http://www.cisco.com/c/en/us/products/servers-unified-computing
464
465 Contact Information
466 -------------------
467
468 Any questions or bugs should be reported to DPDK community and to the ENIC PMD
469 maintainers:
470
471 - John Daley <johndale@cisco.com>
472 - Nelson Escobar <neescoba@cisco.com>