Skip to content

Commit

Permalink
pcap: add new driver
Browse files Browse the repository at this point in the history
This PMD uses libpcap to send/receive packets to/from any NIC.
It can also read/write to/from a file.

Signed-off-by: Intel
  • Loading branch information
Intel authored and Thomas Monjalon committed Oct 9, 2013
1 parent e1e4017 commit 4c17330
Show file tree
Hide file tree
Showing 15 changed files with 1,227 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/test-pmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ APP = testpmd
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)

ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
LDFLAGS += -lpcap
endif

#
# all source are stored in SRCS-y
#
Expand Down
6 changes: 6 additions & 0 deletions config/defconfig_i686-default-linuxapp-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ CONFIG_RTE_LIBRTE_PMD_RING=y
CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16
CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16

#
# Compile software PMD backed by PCAP files
#
CONFIG_RTE_LIBRTE_PMD_PCAP=n


#
# Compile librte_ring
#
Expand Down
5 changes: 5 additions & 0 deletions config/defconfig_i686-default-linuxapp-icc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ CONFIG_RTE_LIBRTE_PMD_RING=y
CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16
CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16

#
# Compile software PMD backed by PCAP files
#
CONFIG_RTE_LIBRTE_PMD_PCAP=n

#
# Compile librte_ring
#
Expand Down
5 changes: 5 additions & 0 deletions config/defconfig_x86_64-default-linuxapp-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ CONFIG_RTE_LIBRTE_PMD_RING=y
CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16
CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16

#
# Compile software PMD backed by PCAP files
#
CONFIG_RTE_LIBRTE_PMD_PCAP=n

#
# Do prefetch of packet data within PMD driver receive function
#
Expand Down
5 changes: 5 additions & 0 deletions config/defconfig_x86_64-default-linuxapp-icc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ CONFIG_RTE_LIBRTE_PMD_RING=y
CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16
CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16

#
# Compile software PMD backed by PCAP files
#
CONFIG_RTE_LIBRTE_PMD_PCAP=n

#
# Do prefetch of packet data within PMD driver receive function
#
Expand Down
1 change: 1 addition & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
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_HASH) += librte_hash
DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net
Expand Down
9 changes: 9 additions & 0 deletions lib/librte_eal/common/eal_common_nonpci_devs.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#ifdef RTE_LIBRTE_PMD_RING
#include <rte_eth_ring.h>
#endif
#ifdef RTE_LIBRTE_PMD_PCAP
#include <rte_eth_pcap.h>
#endif
#include "eal_private.h"

struct device_init {
Expand All @@ -50,6 +53,12 @@ struct device_init dev_types[] = {
.dev_prefix = RTE_ETH_RING_PARAM_NAME,
.init_fn = rte_pmd_ring_init
},
#endif
#ifdef RTE_LIBRTE_PMD_PCAP
{
.dev_prefix = RTE_ETH_PCAP_PARAM_NAME,
.init_fn = rte_pmd_pcap_init
},
#endif
{
.dev_prefix = "-nodev-",
Expand Down
6 changes: 6 additions & 0 deletions lib/librte_eal/common/eal_common_whitelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
#ifdef RTE_LIBRTE_PMD_RING
#include <rte_eth_ring.h>
#endif
#ifdef RTE_LIBRTE_PMD_PCAP
#include <rte_eth_pcap.h>
#endif
#include "eal_private.h"

static char dev_list_str[4096];
Expand Down Expand Up @@ -96,6 +99,9 @@ is_valid_wl_entry(const char *device_str, size_t dev_buf_len)
static const char *non_pci_prefixes[] = {
#ifdef RTE_LIBRTE_PMD_RING
RTE_ETH_RING_PARAM_NAME,
#endif
#ifdef RTE_LIBRTE_PMD_PCAP
RTE_ETH_PCAP_PARAM_NAME,
#endif
"-nodev-" /* dummy value to prevent compiler warnings */
};
Expand Down
1 change: 1 addition & 0 deletions lib/librte_eal/linuxapp/eal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_mempool
CFLAGS += -I$(RTE_SDK)/lib/librte_malloc
CFLAGS += -I$(RTE_SDK)/lib/librte_ether
CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_ring
CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_pcap
CFLAGS += $(WERROR_FLAGS) -O3

# specific to linuxapp exec-env
Expand Down
58 changes: 58 additions & 0 deletions lib/librte_pmd_pcap/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# BSD LICENSE
#
# Copyright(c) 2010-2013 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_pcap.a

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

#
# all source are stored in SRCS-y
#
SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += rte_eth_pcap.c
SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += rte_eth_pcap_arg_parser.c


#
# Export include files
#
SYMLINK-y-include += rte_eth_pcap.h
SYMLINK-y-include += rte_eth_pcap_arg_parser.h

# this lib depends upon:
DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_mbuf lib/librte_ether

include $(RTE_SDK)/mk/rte.lib.mk
Loading

0 comments on commit 4c17330

Please sign in to comment.