Skip to content

Commit

Permalink
vmxnet3: import new vmxnet3 poll mode driver implementation
Browse files Browse the repository at this point in the history
Poll Mode Driver for Paravirtual VMXNET3 NIC.
As a PMD, the VMXNET3 driver provides the packet reception and transmission
callbacks, vmxnet3_recv_pkts and vmxnet3_xmit_pkts. It does not support
scattered packet reception as part of vmxnet3_recv_pkts and
vmxnet3_xmit_pkts. Also, it does not support scattered packet reception as part of
the device operations supported.

The VMXNET3 PMD handles all the packet buffer memory allocation and resides in
guest address space and it is solely responsible to free that memory when not needed.
The packet buffers and features to be supported are made available to hypervisor via
VMXNET3 PCI configuration space BARs. During RX/TX, the packet buffers are
exchanged by their GPAs, and the hypervisor loads the buffers with packets in the RX
case and sends packets to vSwitch in the TX case.

The VMXNET3 PMD is compiled with vmxnet3 device headers. The interface is similar
to that of the other PMDs available in the Intel(R) DPDK API. The driver pre-allocates the
packet buffers and loads the command ring descriptors in advance. The hypervisor fills
those packet buffers on packet arrival and write completion ring descriptors, which are
eventually pulled by the PMD. After reception, the Intel(R) DPDK application frees the
descriptors and loads new packet buffers for the coming packets. The interrupts are
disabled and there is no notification required. This keeps performance up on the RX
side, even though the device provides a notification feature.

In the transmit routine, the Intel(R) DPDK application fills packet buffer pointers in the
descriptors of the command ring and notifies the hypervisor. In response the hypervisor
takes packets and passes them to the vSwitch. It writes into the completion descriptors
ring. The rings are read by the PMD in the next transmit routine call and the buffers
and descriptors are freed from memory.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
  • Loading branch information
bruce-richardson authored and David Marchand committed Feb 26, 2014
1 parent d0c5ae3 commit dfaff37
Show file tree
Hide file tree
Showing 20 changed files with 3,364 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/defconfig_i686-default-linuxapp-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DRIVER=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n

#
# Compile burst-oriented VMXNET3 PMD driver
#
CONFIG_RTE_LIBRTE_VMXNET3_PMD=y
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_INIT=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_RX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n

#
# Do prefetch of packet data within PMD driver receive function
#
Expand Down
10 changes: 10 additions & 0 deletions config/defconfig_i686-default-linuxapp-icc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DRIVER=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n

#
# Compile burst-oriented VMXNET3 PMD driver
#
CONFIG_RTE_LIBRTE_VMXNET3_PMD=y
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_INIT=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_RX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n

#
# Do prefetch of packet data within PMD driver receive function
#
Expand Down
10 changes: 10 additions & 0 deletions config/defconfig_x86_64-default-linuxapp-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DRIVER=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n

#
# Compile burst-oriented VMXNET3 PMD driver
#
CONFIG_RTE_LIBRTE_VMXNET3_PMD=y
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_INIT=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_RX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n

#
# Compile example software rings based PMD
#
Expand Down
10 changes: 10 additions & 0 deletions config/defconfig_x86_64-default-linuxapp-icc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DRIVER=n
CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n

#
# Compile burst-oriented VMXNET3 PMD driver
#
CONFIG_RTE_LIBRTE_VMXNET3_PMD=y
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_INIT=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_RX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n
CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n

#
# Compile example software rings based PMD
#
Expand Down
1 change: 1 addition & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
Expand Down
19 changes: 19 additions & 0 deletions lib/librte_ether/rte_ethdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,16 @@ extern int rte_ixgbevf_pmd_init(void);
*/
extern int rte_virtio_pmd_init(void);

/**
* The initialization function of the driver for VMware VMXNET3
* Ethernet devices.
* Invoked once at EAL start time.
* @return
* 0 on success
*/
extern int rte_vmxnet3_pmd_init(void);


/**
* The initialization function of *all* supported and enabled drivers.
* Right now, the following PMDs are supported:
Expand All @@ -1343,6 +1353,8 @@ extern int rte_virtio_pmd_init(void);
* - em
* - ixgbe
* - ixgbevf
* - virtio
* - vmxnet3
* This function is invoked once at EAL start time.
* @return
* 0 on success.
Expand Down Expand Up @@ -1391,6 +1403,13 @@ int rte_pmd_init_all(void)
}
#endif /* RTE_LIBRTE_VIRTIO_PMD */

#ifdef RTE_LIBRTE_VMXNET3_PMD
if ((ret = rte_vmxnet3_pmd_init()) != 0) {
RTE_LOG(ERR, PMD, "Cannot init vmxnet3 PMD\n");
return (ret);
}
#endif /* RTE_LIBRTE_VMXNET3_PMD */

if (ret == -ENODEV)
RTE_LOG(ERR, PMD, "No PMD(s) are configured\n");
return (ret);
Expand Down
72 changes: 72 additions & 0 deletions lib/librte_pmd_vmxnet3/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# BSD LICENSE
#
# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

include $(RTE_SDK)/mk/rte.vars.mk

#
# library name
#
LIB = librte_pmd_vmxnet3.a

CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)

ifeq ($(CC), icc)
#
# CFLAGS for icc
#
CFLAGS_LAD = -wd174 -wd593 -wd869 -wd981 -wd2259
else
#
# CFLAGS for gcc
#
ifneq ($(shell test $(GCC_MAJOR_VERSION) -le 4 -a $(GCC_MINOR_VERSION) -le 3 && echo 1), 1)
CFLAGS += -Wno-deprecated
endif
CFLAGS_LAD = -Wno-unused-parameter -Wno-unused-value
CFLAGS_LAD += -Wno-strict-aliasing -Wno-format-extra-args

endif

VPATH += $(RTE_SDK)/lib/librte_pmd_vmxnet3/vmxnet3

#
# all source are stored in SRCS-y
#
SRCS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3_rxtx.c
SRCS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3_ethdev.c

# this lib depends upon:
DEPDIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += lib/librte_eal lib/librte_ether
DEPDIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += lib/librte_mempool lib/librte_mbuf
DEPDIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += lib/librte_net lib/librte_malloc

include $(RTE_SDK)/mk/rte.lib.mk
50 changes: 50 additions & 0 deletions lib/librte_pmd_vmxnet3/vmxnet3/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
..
BSD LICENSE

Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Intel VMXNET3 driver
===================

This directory contains source code of FreeBSD VMXNET3 driver released by VMware.
In which, upt1_defs.h and vmxnet3_defs.h is introduced without any change.
The other 4 files: includeCheck.h, vmware_pack_begin.h, vmware_pack_end.h and vmxnet3_osdep.h
are crated to adapt to the needs from above 2 files.

Updating driver
===============

The following modifications have been made to this code to integrate it with the
Intel DPDK:


-------------


40 changes: 40 additions & 0 deletions lib/librte_pmd_vmxnet3/vmxnet3/includeCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*-
* BSD LICENSE
*
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _INCLUDECHECK_H
#define _INCLUDECHECK_H

#include "vmxnet3_osdep.h"

#endif /* _INCLUDECHECK_H */

117 changes: 117 additions & 0 deletions lib/librte_pmd_vmxnet3/vmxnet3/upt1_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*********************************************************
* Copyright (C) 2007 VMware, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*********************************************************/

/* upt1_defs.h
*
* Definitions for UPTv1
*
* Some of the defs are duplicated in vmkapi_net_upt.h, because
* vmkapi_net_upt.h cannot distribute with OSS yet and vmkapi headers can
* only include vmkapi headers. Make sure they are kept in sync!
*/

#ifndef _UPT1_DEFS_H
#define _UPT1_DEFS_H

#define UPT1_MAX_TX_QUEUES 64
#define UPT1_MAX_RX_QUEUES 64

#define UPT1_MAX_INTRS (UPT1_MAX_TX_QUEUES + UPT1_MAX_RX_QUEUES)

typedef
#include "vmware_pack_begin.h"
struct UPT1_TxStats {
uint64 TSOPktsTxOK; /* TSO pkts post-segmentation */
uint64 TSOBytesTxOK;
uint64 ucastPktsTxOK;
uint64 ucastBytesTxOK;
uint64 mcastPktsTxOK;
uint64 mcastBytesTxOK;
uint64 bcastPktsTxOK;
uint64 bcastBytesTxOK;
uint64 pktsTxError;
uint64 pktsTxDiscard;
}
#include "vmware_pack_end.h"
UPT1_TxStats;

typedef
#include "vmware_pack_begin.h"
struct UPT1_RxStats {
uint64 LROPktsRxOK; /* LRO pkts */
uint64 LROBytesRxOK; /* bytes from LRO pkts */
/* the following counters are for pkts from the wire, i.e., pre-LRO */
uint64 ucastPktsRxOK;
uint64 ucastBytesRxOK;
uint64 mcastPktsRxOK;
uint64 mcastBytesRxOK;
uint64 bcastPktsRxOK;
uint64 bcastBytesRxOK;
uint64 pktsRxOutOfBuf;
uint64 pktsRxError;
}
#include "vmware_pack_end.h"
UPT1_RxStats;

/* interrupt moderation level */
#define UPT1_IML_NONE 0 /* no interrupt moderation */
#define UPT1_IML_HIGHEST 7 /* least intr generated */
#define UPT1_IML_ADAPTIVE 8 /* adpative intr moderation */

/* values for UPT1_RSSConf.hashFunc */
#define UPT1_RSS_HASH_TYPE_NONE 0x0
#define UPT1_RSS_HASH_TYPE_IPV4 0x01
#define UPT1_RSS_HASH_TYPE_TCP_IPV4 0x02
#define UPT1_RSS_HASH_TYPE_IPV6 0x04
#define UPT1_RSS_HASH_TYPE_TCP_IPV6 0x08

#define UPT1_RSS_HASH_FUNC_NONE 0x0
#define UPT1_RSS_HASH_FUNC_TOEPLITZ 0x01

#define UPT1_RSS_MAX_KEY_SIZE 40
#define UPT1_RSS_MAX_IND_TABLE_SIZE 128

typedef
#include "vmware_pack_begin.h"
struct UPT1_RSSConf {
uint16 hashType;
uint16 hashFunc;
uint16 hashKeySize;
uint16 indTableSize;
uint8 hashKey[UPT1_RSS_MAX_KEY_SIZE];
uint8 indTable[UPT1_RSS_MAX_IND_TABLE_SIZE];
}
#include "vmware_pack_end.h"
UPT1_RSSConf;

/* features */
#define UPT1_F_RXCSUM 0x0001 /* rx csum verification */
#define UPT1_F_RSS 0x0002
#define UPT1_F_RXVLAN 0x0004 /* VLAN tag stripping */
#define UPT1_F_LRO 0x0008

#endif
Loading

0 comments on commit dfaff37

Please sign in to comment.