[dpdk-dev] [PATCH v5] drivers/net:new PMD using tun/tap host interface
Regards, Keith > On Oct 12, 2016, at 1:19 PM, Wiles, Keith wrote: > > > Regards, > Keith > >> On Oct 12, 2016, at 9:56 AM, Yigit, Ferruh wrote: >> >>> + >>> +static void >>> +tap_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *tap_stats) >>> +{ >>> + unsigned i, imax; >> >> checkpatch complain about not using "unsigned int? > > I ran checkpatch on the patch and saw no errors reported via the > scripts/checkpatch.sh. Which checkpatch are you using here? OK, the scripts/checkpatch.sh does not seem to report any failures, but running checkpatch.pl does report problems. Is the scripts/checkpatch.sh script suppose to display the errors or what? It seems odd for the script file not to display warnings and errors, unless it is just for validating patch. I would expect the script show the problems normally or at least with an option.
[dpdk-dev] [PATCH v5] drivers/net:new PMD using tun/tap host interface
Regards, Keith > On Oct 12, 2016, at 9:56 AM, Yigit, Ferruh wrote: > > On 10/11/2016 10:51 PM, Keith Wiles wrote: >> The rte_eth_tap.c PMD creates a device using TUN/TAP interfaces >> on the local host. The PMD allows for DPDK and the host to >> communicate using a raw device interface on the host and in >> the DPDK application. The device created is a Tap device with >> a L2 packet header. >> >> v5 - merge in changes from list review see related emails. >> fixed checkpatch issues and many minor edits >> v4 - merge with latest driver changes >> v3 - fix includes by removing ifdef for other type besides Linux. >> Fix the copyright notice in the Makefile >> v2 - merge all of the patches into one patch. >> Fix a typo on naming the tap device. >> Update the maintainers list >> >> Signed-off-by: Keith Wiles >> --- > > <..> > >> diff --git a/config/common_base b/config/common_base >> index f5d2eff..356c631 100644 >> --- a/config/common_base >> +++ b/config/common_base >> @@ -592,3 +592,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n >> CONFIG_RTE_TEST_PMD=y >> CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n >> CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n >> + >> +# >> +# Set TAP PMD to 'n' as it is only supported in Linux for now. > > This comments moved to final .config and creates confusion, can we > remove it if you don't have a strong option to keep it? What do you mean, the statement is confusing or causes problems? > > <..> > >> diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst >> new file mode 100644 >> index 000..eed81ec >> --- /dev/null >> +++ b/doc/guides/nics/tap.rst > > <..> > >> +.. code-block:: console >> + >> + The interfaced name can be changed by adding the iface=foo0 >> + e.g. --vdev=eth_tap,iface=foo0 --vdev=eth_tap,iface=foo1, ... > > For all file: > %s/eth_tap/net_tap/g, there are multiple lines with this usage Missed that one. > > > <..> > >> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c >> new file mode 100644 >> index 000..c13aa1b >> --- /dev/null >> +++ b/drivers/net/tap/rte_eth_tap.c > > <..> > >> + >> +struct tap_info { >> +char name[RTE_ETH_NAME_MAX_LEN]; /* Interface name supplied/given */ >> +int speed; /* Speed of interface */ >> +}; > > This struct can go away, it is not used, since with the updated code > rte_pmd_tap_probe() used tap_name and speed as seperate variables > instead of struct. > OK. > > <..> > >> + >> +/* If the name is different that new name as default */ >> +if (name && strcmp(name, ifr.ifr_name)) >> +snprintf(name, RTE_ETH_NAME_MAX_LEN-1, "%s", ifr.ifr_name); > > syntax, space around "-" > > <..> > >> + >> +static void >> +tap_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *tap_stats) >> +{ >> +unsigned i, imax; > > checkpatch complain about not using "unsigned int? I ran checkpatch on the patch and saw no errors reported via the scripts/checkpatch.sh. Which checkpatch are you using here? > > > <..> > >> +static int >> +tap_setup_queue(struct rte_eth_dev *dev, >> +struct pmd_internals *internals, >> +uint16_t qid) >> +{ >> +struct rx_queue *rx = >rxq[qid]; >> +struct tx_queue *tx = >txq[qid]; >> +int fd; >> + >> +if ((fd = rx->fd) < 0) >> +if ((fd = tx->fd) < 0) { >> +RTE_LOG(INFO, PMD, "Add queue to TAP %s for qid %d\n", >> +dev->data->name, qid); >> +if ((fd = tun_alloc(dev->data->name)) < 0) { > > checkpatch complain about assignment in the if condition > > > <..> > >> +/* Now get the space available for data in the mbuf */ >> +buf_size = (uint16_t) (rte_pktmbuf_data_room_size(mp) - > > syntax, no space after cast > > > <..> > >> +/* Create the first Tap device */ >> +if ((fd = tun_alloc(tap_name)) < 0) { > > checkpatch complains about assignment in if condition > >> +RTE_LOG(ERR, PMD, "tun_alloc(%s) failed\n", dev->data->name); >> +rte_free(pmd); > > rte_free(data) or goto error_exit; ? > >> +rte_eth_dev_release_port(dev); >> +return -EINVAL; >> +} >> + >> +/* Presetup the fds to -1 as being not working */ >> +for(i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { >> +pmd->fds[i] = -1; >> +pmd->rxq[i].fd = -1; >> +pmd->txq[i].fd = -1; >> +} >> + >> +/* Take the TUN/TAP fd and place in the first location */ >> +pmd->rxq[0].fd = fd; >> +pmd->txq[0].fd = fd; >> +pmd->fds[0] = fd; >> + >> +if (pmd_mac_address(fd, dev, >eth_addr) < 0) { >> +rte_free(pmd); > > rte_free(data) or goto error_exit; ? > > > <..> > >> +static int >> +set_interface_name(const char *key __rte_unused, >> + const char *value, >> + void *extra_args) >> +{ >> +char *name = (char *)extra_args; >> + >> +if (value) >> +
[dpdk-dev] [PATCH v5] drivers/net:new PMD using tun/tap host interface
On 10/11/2016 10:51 PM, Keith Wiles wrote: > The rte_eth_tap.c PMD creates a device using TUN/TAP interfaces > on the local host. The PMD allows for DPDK and the host to > communicate using a raw device interface on the host and in > the DPDK application. The device created is a Tap device with > a L2 packet header. > > v5 - merge in changes from list review see related emails. > fixed checkpatch issues and many minor edits > v4 - merge with latest driver changes > v3 - fix includes by removing ifdef for other type besides Linux. > Fix the copyright notice in the Makefile > v2 - merge all of the patches into one patch. > Fix a typo on naming the tap device. > Update the maintainers list > > Signed-off-by: Keith Wiles > --- <..> > diff --git a/config/common_base b/config/common_base > index f5d2eff..356c631 100644 > --- a/config/common_base > +++ b/config/common_base > @@ -592,3 +592,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n > CONFIG_RTE_TEST_PMD=y > CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n > CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n > + > +# > +# Set TAP PMD to 'n' as it is only supported in Linux for now. This comments moved to final .config and creates confusion, can we remove it if you don't have a strong option to keep it? <..> > diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst > new file mode 100644 > index 000..eed81ec > --- /dev/null > +++ b/doc/guides/nics/tap.rst <..> > +.. code-block:: console > + > + The interfaced name can be changed by adding the iface=foo0 > + e.g. --vdev=eth_tap,iface=foo0 --vdev=eth_tap,iface=foo1, ... For all file: %s/eth_tap/net_tap/g, there are multiple lines with this usage <..> > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c > new file mode 100644 > index 000..c13aa1b > --- /dev/null > +++ b/drivers/net/tap/rte_eth_tap.c <..> > + > +struct tap_info { > + char name[RTE_ETH_NAME_MAX_LEN]; /* Interface name supplied/given */ > + int speed; /* Speed of interface */ > +}; This struct can go away, it is not used, since with the updated code rte_pmd_tap_probe() used tap_name and speed as seperate variables instead of struct. <..> > + > + /* If the name is different that new name as default */ > + if (name && strcmp(name, ifr.ifr_name)) > + snprintf(name, RTE_ETH_NAME_MAX_LEN-1, "%s", ifr.ifr_name); syntax, space around "-" <..> > + > +static void > +tap_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *tap_stats) > +{ > + unsigned i, imax; checkpatch complain about not using "unsigned int" <..> > +static int > +tap_setup_queue(struct rte_eth_dev *dev, > + struct pmd_internals *internals, > + uint16_t qid) > +{ > + struct rx_queue *rx = >rxq[qid]; > + struct tx_queue *tx = >txq[qid]; > + int fd; > + > + if ((fd = rx->fd) < 0) > + if ((fd = tx->fd) < 0) { > + RTE_LOG(INFO, PMD, "Add queue to TAP %s for qid %d\n", > + dev->data->name, qid); > + if ((fd = tun_alloc(dev->data->name)) < 0) { checkpatch complain about assignment in the if condition <..> > + /* Now get the space available for data in the mbuf */ > + buf_size = (uint16_t) (rte_pktmbuf_data_room_size(mp) - syntax, no space after cast <..> > + /* Create the first Tap device */ > + if ((fd = tun_alloc(tap_name)) < 0) { checkpatch complains about assignment in if condition > + RTE_LOG(ERR, PMD, "tun_alloc(%s) failed\n", dev->data->name); > + rte_free(pmd); rte_free(data) or goto error_exit; ? > + rte_eth_dev_release_port(dev); > + return -EINVAL; > + } > + > + /* Presetup the fds to -1 as being not working */ > + for(i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { > + pmd->fds[i] = -1; > + pmd->rxq[i].fd = -1; > + pmd->txq[i].fd = -1; > + } > + > + /* Take the TUN/TAP fd and place in the first location */ > + pmd->rxq[0].fd = fd; > + pmd->txq[0].fd = fd; > + pmd->fds[0] = fd; > + > + if (pmd_mac_address(fd, dev, >eth_addr) < 0) { > + rte_free(pmd); rte_free(data) or goto error_exit; ? <..> > +static int > +set_interface_name(const char *key __rte_unused, > +const char *value, > +void *extra_args) > +{ > + char *name = (char *)extra_args; > + > + if (value) > + snprintf(name, RTE_ETH_NAME_MAX_LEN-1, "%s", value); syntax, space around "-" > + else > + snprintf(name, RTE_ETH_NAME_MAX_LEN-1, "%s%d", syntax, space around "-" > + DEFAULT_TAP_NAME, (tap_unit-1)); syntax, space around "-" > + > + return 0; > +} > + > +static int > +set_interface_speed(const char *key __rte_unused, > + const char *value, > + void *extra_args) > +{ > + *(int *)extra_args = (value)?
[dpdk-dev] [PATCH v5] drivers/net:new PMD using tun/tap host interface
The rte_eth_tap.c PMD creates a device using TUN/TAP interfaces on the local host. The PMD allows for DPDK and the host to communicate using a raw device interface on the host and in the DPDK application. The device created is a Tap device with a L2 packet header. v5 - merge in changes from list review see related emails. fixed checkpatch issues and many minor edits v4 - merge with latest driver changes v3 - fix includes by removing ifdef for other type besides Linux. Fix the copyright notice in the Makefile v2 - merge all of the patches into one patch. Fix a typo on naming the tap device. Update the maintainers list Signed-off-by: Keith Wiles --- MAINTAINERS | 5 + config/common_base | 5 + config/common_linuxapp | 1 + doc/guides/nics/tap.rst | 138 ++ drivers/net/Makefile| 1 + drivers/net/tap/Makefile| 57 +++ drivers/net/tap/rte_eth_tap.c | 767 drivers/net/tap/rte_pmd_tap_version.map | 4 + mk/rte.app.mk | 1 + 9 files changed, 979 insertions(+) create mode 100644 doc/guides/nics/tap.rst create mode 100644 drivers/net/tap/Makefile create mode 100644 drivers/net/tap/rte_eth_tap.c create mode 100644 drivers/net/tap/rte_pmd_tap_version.map diff --git a/MAINTAINERS b/MAINTAINERS index cd8d167..f905709 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -394,6 +394,11 @@ F: doc/guides/nics/pcap_ring.rst F: app/test/test_pmd_ring.c F: app/test/test_pmd_ring_perf.c +Tap PMD +M: Keith Wiles +F: drivers/net/tap +F: doc/guides/nics/tap.rst + Null Networking PMD M: Tetsuya Mukawa F: drivers/net/null/ diff --git a/config/common_base b/config/common_base index f5d2eff..356c631 100644 --- a/config/common_base +++ b/config/common_base @@ -592,3 +592,8 @@ CONFIG_RTE_APP_TEST_RESOURCE_TAR=n CONFIG_RTE_TEST_PMD=y CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES=n CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS=n + +# +# Set TAP PMD to 'n' as it is only supported in Linux for now. +# +CONFIG_RTE_LIBRTE_PMD_TAP=n diff --git a/config/common_linuxapp b/config/common_linuxapp index 2483dfa..782b503 100644 --- a/config/common_linuxapp +++ b/config/common_linuxapp @@ -44,3 +44,4 @@ CONFIG_RTE_LIBRTE_PMD_VHOST=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_POWER=y CONFIG_RTE_VIRTIO_USER=y +CONFIG_RTE_LIBRTE_PMD_TAP=y diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst new file mode 100644 index 000..eed81ec --- /dev/null +++ b/doc/guides/nics/tap.rst @@ -0,0 +1,138 @@ +.. BSD LICENSE +Copyright(c) 2016 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. + +Tun/Tap Poll Mode Driver + + +The rte_eth_tap.c PMD creates a device using TUN/TAP interfaces on the local +host. The PMD allows for DPDK and the host to communicate using a raw device +interface on the host and in the DPDK application. + +The device created is a TAP device, which sends/receives packet in a raw format +with a L2 header. The usage for a TAP PMD is for connectivity to the local host +using a TAP interface. When the TAP PMD is initialized it will create a number +of tap devices in the host accessed via 'ifconfig -a' or 'ip' command. The +commands can be used to assign and query the virtual like device. + +These TAP interfaces can be used with wireshark