Re: [lng-odp] [PATCHv3 2/3] linux-generic: pktio: add tap pktio type
On Tue, Dec 08, 2015 at 02:51:40PM +0300, Ilya Maximets wrote: > On 08.12.2015 14:24, Stuart Haslam wrote: > > On Mon, Dec 07, 2015 at 01:55:31PM +0300, Ilya Maximets wrote: > >> Creates a new pktio type that allows for creating and > >> sending/receiving packets through TAP interface. > >> It is intended for use as a simple conventional communication > >> method between applications that use kernel network stack > >> (ping, ssh, iperf, etc.) and ODP applications for the purpose > >> of functional testing and can be used as it is with some > >> of the existing example applications. > >> > >> To use this interface the name passed to odp_pktio_open() must > >> begin with "tap:" and be in the format: > >> > >> tap:iface > >> > >>iface the name of TAP device to be created. > >> > >> TUN/TAP kernel module should be loaded to use this pktio. > >> There should be no device named 'iface' in the system. > >> The total length of the 'iface' is limited by IF_NAMESIZE. > >> > >> Signed-off-by: Ilya Maximets> >> --- > >> platform/linux-generic/Makefile.am | 2 + > >> .../linux-generic/include/odp_packet_io_internal.h | 3 + > >> platform/linux-generic/include/odp_packet_tap.h| 21 ++ > >> platform/linux-generic/pktio/io_ops.c | 1 + > >> platform/linux-generic/pktio/tap.c | 317 > >> + > >> 5 files changed, 344 insertions(+) > >> create mode 100644 platform/linux-generic/include/odp_packet_tap.h > >> create mode 100644 platform/linux-generic/pktio/tap.c > >> > >> diff --git a/platform/linux-generic/Makefile.am > >> b/platform/linux-generic/Makefile.am > >> index 70bd8fe..4639ebc 100644 > >> --- a/platform/linux-generic/Makefile.am > >> +++ b/platform/linux-generic/Makefile.am > >> @@ -92,6 +92,7 @@ noinst_HEADERS = \ > >> ${srcdir}/include/odp_packet_io_queue.h \ > >> ${srcdir}/include/odp_packet_netmap.h \ > >> ${srcdir}/include/odp_packet_socket.h \ > >> +${srcdir}/include/odp_packet_tap.h \ > >> ${srcdir}/include/odp_pool_internal.h \ > >> ${srcdir}/include/odp_queue_internal.h \ > >> ${srcdir}/include/odp_schedule_internal.h \ > >> @@ -120,6 +121,7 @@ __LIB__libodp_la_SOURCES = \ > >> pktio/netmap.c \ > >> pktio/socket.c \ > >> pktio/socket_mmap.c \ > >> + pktio/tap.c \ > >> odp_pool.c \ > >> odp_queue.c \ > >> odp_rwlock.c \ > >> diff --git a/platform/linux-generic/include/odp_packet_io_internal.h > >> b/platform/linux-generic/include/odp_packet_io_internal.h > >> index 1a1118c..de29557 100644 > >> --- a/platform/linux-generic/include/odp_packet_io_internal.h > >> +++ b/platform/linux-generic/include/odp_packet_io_internal.h > >> @@ -22,6 +22,7 @@ extern "C" { > >> #include > >> #include > >> #include > >> +#include > >> #include > >> #include > >> #include > >> @@ -78,6 +79,7 @@ struct pktio_entry { > >> #ifdef HAVE_PCAP > >>pkt_pcap_t pkt_pcap;/**< Using pcap for IO */ > >> #endif > >> + pkt_tap_t pkt_tap; /**< using TAP for IO */ > >>}; > >>enum { > >>STATE_START = 0, > >> @@ -157,6 +159,7 @@ extern const pktio_if_ops_t loopback_pktio_ops; > >> #ifdef HAVE_PCAP > >> extern const pktio_if_ops_t pcap_pktio_ops; > >> #endif > >> +extern const pktio_if_ops_t tap_pktio_ops; > >> extern const pktio_if_ops_t * const pktio_if_ops[]; > >> > >> #ifdef __cplusplus > >> diff --git a/platform/linux-generic/include/odp_packet_tap.h > >> b/platform/linux-generic/include/odp_packet_tap.h > >> new file mode 100644 > >> index 000..7877586 > >> --- /dev/null > >> +++ b/platform/linux-generic/include/odp_packet_tap.h > >> @@ -0,0 +1,21 @@ > >> +/* Copyright (c) 2015, Ilya Maximets > >> + * All rights reserved. > >> + * > >> + * SPDX-License-Identifier: BSD-3-Clause > >> + */ > >> + > >> +#ifndef ODP_PACKET_TAP_H_ > >> +#define ODP_PACKET_TAP_H_ > >> + > >> +#include > >> + > >> +typedef struct { > >> + int fd; /**< file descriptor for tap interface*/ > >> + int skfd; /**< socket descriptor */ > >> + uint32_t mtu; /**< cached mtu */ > >> + unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a > >> + MAC address of kernel interface)*/ > >> + odp_pool_t pool;/**< pool to alloc packets from */ > >> +} pkt_tap_t; > >> + > >> +#endif > >> diff --git a/platform/linux-generic/pktio/io_ops.c > >> b/platform/linux-generic/pktio/io_ops.c > >> index 3b344e6..1933abc 100644 > >> --- a/platform/linux-generic/pktio/io_ops.c > >> +++ b/platform/linux-generic/pktio/io_ops.c > >> @@ -18,6 +18,7 @@ const pktio_if_ops_t * const
Re: [lng-odp] [PATCHv3 2/3] linux-generic: pktio: add tap pktio type
On 08.12.2015 14:24, Stuart Haslam wrote: > On Mon, Dec 07, 2015 at 01:55:31PM +0300, Ilya Maximets wrote: >> Creates a new pktio type that allows for creating and >> sending/receiving packets through TAP interface. >> It is intended for use as a simple conventional communication >> method between applications that use kernel network stack >> (ping, ssh, iperf, etc.) and ODP applications for the purpose >> of functional testing and can be used as it is with some >> of the existing example applications. >> >> To use this interface the name passed to odp_pktio_open() must >> begin with "tap:" and be in the format: >> >> tap:iface >> >>iface the name of TAP device to be created. >> >> TUN/TAP kernel module should be loaded to use this pktio. >> There should be no device named 'iface' in the system. >> The total length of the 'iface' is limited by IF_NAMESIZE. >> >> Signed-off-by: Ilya Maximets>> --- >> platform/linux-generic/Makefile.am | 2 + >> .../linux-generic/include/odp_packet_io_internal.h | 3 + >> platform/linux-generic/include/odp_packet_tap.h| 21 ++ >> platform/linux-generic/pktio/io_ops.c | 1 + >> platform/linux-generic/pktio/tap.c | 317 >> + >> 5 files changed, 344 insertions(+) >> create mode 100644 platform/linux-generic/include/odp_packet_tap.h >> create mode 100644 platform/linux-generic/pktio/tap.c >> >> diff --git a/platform/linux-generic/Makefile.am >> b/platform/linux-generic/Makefile.am >> index 70bd8fe..4639ebc 100644 >> --- a/platform/linux-generic/Makefile.am >> +++ b/platform/linux-generic/Makefile.am >> @@ -92,6 +92,7 @@ noinst_HEADERS = \ >>${srcdir}/include/odp_packet_io_queue.h \ >>${srcdir}/include/odp_packet_netmap.h \ >>${srcdir}/include/odp_packet_socket.h \ >> + ${srcdir}/include/odp_packet_tap.h \ >>${srcdir}/include/odp_pool_internal.h \ >>${srcdir}/include/odp_queue_internal.h \ >>${srcdir}/include/odp_schedule_internal.h \ >> @@ -120,6 +121,7 @@ __LIB__libodp_la_SOURCES = \ >> pktio/netmap.c \ >> pktio/socket.c \ >> pktio/socket_mmap.c \ >> + pktio/tap.c \ >> odp_pool.c \ >> odp_queue.c \ >> odp_rwlock.c \ >> diff --git a/platform/linux-generic/include/odp_packet_io_internal.h >> b/platform/linux-generic/include/odp_packet_io_internal.h >> index 1a1118c..de29557 100644 >> --- a/platform/linux-generic/include/odp_packet_io_internal.h >> +++ b/platform/linux-generic/include/odp_packet_io_internal.h >> @@ -22,6 +22,7 @@ extern "C" { >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -78,6 +79,7 @@ struct pktio_entry { >> #ifdef HAVE_PCAP >> pkt_pcap_t pkt_pcap;/**< Using pcap for IO */ >> #endif >> +pkt_tap_t pkt_tap; /**< using TAP for IO */ >> }; >> enum { >> STATE_START = 0, >> @@ -157,6 +159,7 @@ extern const pktio_if_ops_t loopback_pktio_ops; >> #ifdef HAVE_PCAP >> extern const pktio_if_ops_t pcap_pktio_ops; >> #endif >> +extern const pktio_if_ops_t tap_pktio_ops; >> extern const pktio_if_ops_t * const pktio_if_ops[]; >> >> #ifdef __cplusplus >> diff --git a/platform/linux-generic/include/odp_packet_tap.h >> b/platform/linux-generic/include/odp_packet_tap.h >> new file mode 100644 >> index 000..7877586 >> --- /dev/null >> +++ b/platform/linux-generic/include/odp_packet_tap.h >> @@ -0,0 +1,21 @@ >> +/* Copyright (c) 2015, Ilya Maximets >> + * All rights reserved. >> + * >> + * SPDX-License-Identifier: BSD-3-Clause >> + */ >> + >> +#ifndef ODP_PACKET_TAP_H_ >> +#define ODP_PACKET_TAP_H_ >> + >> +#include >> + >> +typedef struct { >> +int fd; /**< file descriptor for tap interface*/ >> +int skfd; /**< socket descriptor */ >> +uint32_t mtu; /**< cached mtu */ >> +unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a >> + MAC address of kernel interface)*/ >> +odp_pool_t pool;/**< pool to alloc packets from */ >> +} pkt_tap_t; >> + >> +#endif >> diff --git a/platform/linux-generic/pktio/io_ops.c >> b/platform/linux-generic/pktio/io_ops.c >> index 3b344e6..1933abc 100644 >> --- a/platform/linux-generic/pktio/io_ops.c >> +++ b/platform/linux-generic/pktio/io_ops.c >> @@ -18,6 +18,7 @@ const pktio_if_ops_t * const pktio_if_ops[] = { >> #ifdef HAVE_PCAP >> _pktio_ops, >> #endif >> +_pktio_ops, >> _mmap_pktio_ops, >> _mmsg_pktio_ops, >> NULL >> diff --git a/platform/linux-generic/pktio/tap.c >> b/platform/linux-generic/pktio/tap.c >> new file
Re: [lng-odp] [PATCHv3 2/3] linux-generic: pktio: add tap pktio type
On Tue, Dec 08, 2015 at 03:25:01PM +0300, Ilya Maximets wrote: > > > On 08.12.2015 15:16, Stuart Haslam wrote: > > On Tue, Dec 08, 2015 at 02:51:40PM +0300, Ilya Maximets wrote: > >> On 08.12.2015 14:24, Stuart Haslam wrote: > >>> On Mon, Dec 07, 2015 at 01:55:31PM +0300, Ilya Maximets wrote: > Creates a new pktio type that allows for creating and > sending/receiving packets through TAP interface. > It is intended for use as a simple conventional communication > method between applications that use kernel network stack > (ping, ssh, iperf, etc.) and ODP applications for the purpose > of functional testing and can be used as it is with some > of the existing example applications. > > To use this interface the name passed to odp_pktio_open() must > begin with "tap:" and be in the format: > > tap:iface > > iface the name of TAP device to be created. > > TUN/TAP kernel module should be loaded to use this pktio. > There should be no device named 'iface' in the system. > The total length of the 'iface' is limited by IF_NAMESIZE. > > Signed-off-by: Ilya Maximets> --- > platform/linux-generic/Makefile.am | 2 + > .../linux-generic/include/odp_packet_io_internal.h | 3 + > platform/linux-generic/include/odp_packet_tap.h| 21 ++ > platform/linux-generic/pktio/io_ops.c | 1 + > platform/linux-generic/pktio/tap.c | 317 > + > 5 files changed, 344 insertions(+) > create mode 100644 platform/linux-generic/include/odp_packet_tap.h > create mode 100644 platform/linux-generic/pktio/tap.c > > diff --git a/platform/linux-generic/Makefile.am > b/platform/linux-generic/Makefile.am > index 70bd8fe..4639ebc 100644 > --- a/platform/linux-generic/Makefile.am > +++ b/platform/linux-generic/Makefile.am > @@ -92,6 +92,7 @@ noinst_HEADERS = \ > ${srcdir}/include/odp_packet_io_queue.h \ > ${srcdir}/include/odp_packet_netmap.h \ > ${srcdir}/include/odp_packet_socket.h \ > + ${srcdir}/include/odp_packet_tap.h \ > ${srcdir}/include/odp_pool_internal.h \ > ${srcdir}/include/odp_queue_internal.h \ > ${srcdir}/include/odp_schedule_internal.h \ > @@ -120,6 +121,7 @@ __LIB__libodp_la_SOURCES = \ > pktio/netmap.c \ > pktio/socket.c \ > pktio/socket_mmap.c \ > + pktio/tap.c \ > odp_pool.c \ > odp_queue.c \ > odp_rwlock.c \ > diff --git a/platform/linux-generic/include/odp_packet_io_internal.h > b/platform/linux-generic/include/odp_packet_io_internal.h > index 1a1118c..de29557 100644 > --- a/platform/linux-generic/include/odp_packet_io_internal.h > +++ b/platform/linux-generic/include/odp_packet_io_internal.h > @@ -22,6 +22,7 @@ extern "C" { > #include > #include > #include > +#include > #include > #include > #include > @@ -78,6 +79,7 @@ struct pktio_entry { > #ifdef HAVE_PCAP > pkt_pcap_t pkt_pcap;/**< Using pcap for IO > */ > #endif > +pkt_tap_t pkt_tap; /**< using TAP for IO */ > }; > enum { > STATE_START = 0, > @@ -157,6 +159,7 @@ extern const pktio_if_ops_t loopback_pktio_ops; > #ifdef HAVE_PCAP > extern const pktio_if_ops_t pcap_pktio_ops; > #endif > +extern const pktio_if_ops_t tap_pktio_ops; > extern const pktio_if_ops_t * const pktio_if_ops[]; > > #ifdef __cplusplus > diff --git a/platform/linux-generic/include/odp_packet_tap.h > b/platform/linux-generic/include/odp_packet_tap.h > new file mode 100644 > index 000..7877586 > --- /dev/null > +++ b/platform/linux-generic/include/odp_packet_tap.h > @@ -0,0 +1,21 @@ > +/* Copyright (c) 2015, Ilya Maximets > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +#ifndef ODP_PACKET_TAP_H_ > +#define ODP_PACKET_TAP_H_ > + > +#include > + > +typedef struct { > +int fd; /**< file descriptor for tap > interface*/ > +int skfd; /**< socket descriptor */ > +uint32_t mtu; /**< cached mtu */ > +unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side > (not a >
Re: [lng-odp] [PATCHv3 2/3] linux-generic: pktio: add tap pktio type
On Mon, Dec 07, 2015 at 01:55:31PM +0300, Ilya Maximets wrote: > Creates a new pktio type that allows for creating and > sending/receiving packets through TAP interface. > It is intended for use as a simple conventional communication > method between applications that use kernel network stack > (ping, ssh, iperf, etc.) and ODP applications for the purpose > of functional testing and can be used as it is with some > of the existing example applications. > > To use this interface the name passed to odp_pktio_open() must > begin with "tap:" and be in the format: > > tap:iface > >iface the name of TAP device to be created. > > TUN/TAP kernel module should be loaded to use this pktio. > There should be no device named 'iface' in the system. > The total length of the 'iface' is limited by IF_NAMESIZE. > > Signed-off-by: Ilya Maximets> --- > platform/linux-generic/Makefile.am | 2 + > .../linux-generic/include/odp_packet_io_internal.h | 3 + > platform/linux-generic/include/odp_packet_tap.h| 21 ++ > platform/linux-generic/pktio/io_ops.c | 1 + > platform/linux-generic/pktio/tap.c | 317 > + > 5 files changed, 344 insertions(+) > create mode 100644 platform/linux-generic/include/odp_packet_tap.h > create mode 100644 platform/linux-generic/pktio/tap.c > > diff --git a/platform/linux-generic/Makefile.am > b/platform/linux-generic/Makefile.am > index 70bd8fe..4639ebc 100644 > --- a/platform/linux-generic/Makefile.am > +++ b/platform/linux-generic/Makefile.am > @@ -92,6 +92,7 @@ noinst_HEADERS = \ > ${srcdir}/include/odp_packet_io_queue.h \ > ${srcdir}/include/odp_packet_netmap.h \ > ${srcdir}/include/odp_packet_socket.h \ > + ${srcdir}/include/odp_packet_tap.h \ > ${srcdir}/include/odp_pool_internal.h \ > ${srcdir}/include/odp_queue_internal.h \ > ${srcdir}/include/odp_schedule_internal.h \ > @@ -120,6 +121,7 @@ __LIB__libodp_la_SOURCES = \ > pktio/netmap.c \ > pktio/socket.c \ > pktio/socket_mmap.c \ > +pktio/tap.c \ > odp_pool.c \ > odp_queue.c \ > odp_rwlock.c \ > diff --git a/platform/linux-generic/include/odp_packet_io_internal.h > b/platform/linux-generic/include/odp_packet_io_internal.h > index 1a1118c..de29557 100644 > --- a/platform/linux-generic/include/odp_packet_io_internal.h > +++ b/platform/linux-generic/include/odp_packet_io_internal.h > @@ -22,6 +22,7 @@ extern "C" { > #include > #include > #include > +#include > #include > #include > #include > @@ -78,6 +79,7 @@ struct pktio_entry { > #ifdef HAVE_PCAP > pkt_pcap_t pkt_pcap;/**< Using pcap for IO */ > #endif > + pkt_tap_t pkt_tap; /**< using TAP for IO */ > }; > enum { > STATE_START = 0, > @@ -157,6 +159,7 @@ extern const pktio_if_ops_t loopback_pktio_ops; > #ifdef HAVE_PCAP > extern const pktio_if_ops_t pcap_pktio_ops; > #endif > +extern const pktio_if_ops_t tap_pktio_ops; > extern const pktio_if_ops_t * const pktio_if_ops[]; > > #ifdef __cplusplus > diff --git a/platform/linux-generic/include/odp_packet_tap.h > b/platform/linux-generic/include/odp_packet_tap.h > new file mode 100644 > index 000..7877586 > --- /dev/null > +++ b/platform/linux-generic/include/odp_packet_tap.h > @@ -0,0 +1,21 @@ > +/* Copyright (c) 2015, Ilya Maximets > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +#ifndef ODP_PACKET_TAP_H_ > +#define ODP_PACKET_TAP_H_ > + > +#include > + > +typedef struct { > + int fd; /**< file descriptor for tap interface*/ > + int skfd; /**< socket descriptor */ > + uint32_t mtu; /**< cached mtu */ > + unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a > + MAC address of kernel interface)*/ > + odp_pool_t pool;/**< pool to alloc packets from */ > +} pkt_tap_t; > + > +#endif > diff --git a/platform/linux-generic/pktio/io_ops.c > b/platform/linux-generic/pktio/io_ops.c > index 3b344e6..1933abc 100644 > --- a/platform/linux-generic/pktio/io_ops.c > +++ b/platform/linux-generic/pktio/io_ops.c > @@ -18,6 +18,7 @@ const pktio_if_ops_t * const pktio_if_ops[] = { > #ifdef HAVE_PCAP > _pktio_ops, > #endif > + _pktio_ops, > _mmap_pktio_ops, > _mmsg_pktio_ops, > NULL > diff --git a/platform/linux-generic/pktio/tap.c > b/platform/linux-generic/pktio/tap.c > new file mode 100644 > index 000..b11e64f > --- /dev/null > +++ b/platform/linux-generic/pktio/tap.c > @@ -0,0 +1,317 @@ > +/* Copyright
Re: [lng-odp] [PATCHv3 2/3] linux-generic: pktio: add tap pktio type
On 08.12.2015 15:16, Stuart Haslam wrote: > On Tue, Dec 08, 2015 at 02:51:40PM +0300, Ilya Maximets wrote: >> On 08.12.2015 14:24, Stuart Haslam wrote: >>> On Mon, Dec 07, 2015 at 01:55:31PM +0300, Ilya Maximets wrote: Creates a new pktio type that allows for creating and sending/receiving packets through TAP interface. It is intended for use as a simple conventional communication method between applications that use kernel network stack (ping, ssh, iperf, etc.) and ODP applications for the purpose of functional testing and can be used as it is with some of the existing example applications. To use this interface the name passed to odp_pktio_open() must begin with "tap:" and be in the format: tap:iface iface the name of TAP device to be created. TUN/TAP kernel module should be loaded to use this pktio. There should be no device named 'iface' in the system. The total length of the 'iface' is limited by IF_NAMESIZE. Signed-off-by: Ilya Maximets--- platform/linux-generic/Makefile.am | 2 + .../linux-generic/include/odp_packet_io_internal.h | 3 + platform/linux-generic/include/odp_packet_tap.h| 21 ++ platform/linux-generic/pktio/io_ops.c | 1 + platform/linux-generic/pktio/tap.c | 317 + 5 files changed, 344 insertions(+) create mode 100644 platform/linux-generic/include/odp_packet_tap.h create mode 100644 platform/linux-generic/pktio/tap.c diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 70bd8fe..4639ebc 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -92,6 +92,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_io_queue.h \ ${srcdir}/include/odp_packet_netmap.h \ ${srcdir}/include/odp_packet_socket.h \ +${srcdir}/include/odp_packet_tap.h \ ${srcdir}/include/odp_pool_internal.h \ ${srcdir}/include/odp_queue_internal.h \ ${srcdir}/include/odp_schedule_internal.h \ @@ -120,6 +121,7 @@ __LIB__libodp_la_SOURCES = \ pktio/netmap.c \ pktio/socket.c \ pktio/socket_mmap.c \ + pktio/tap.c \ odp_pool.c \ odp_queue.c \ odp_rwlock.c \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 1a1118c..de29557 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -22,6 +22,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -78,6 +79,7 @@ struct pktio_entry { #ifdef HAVE_PCAP pkt_pcap_t pkt_pcap;/**< Using pcap for IO */ #endif + pkt_tap_t pkt_tap; /**< using TAP for IO */ }; enum { STATE_START = 0, @@ -157,6 +159,7 @@ extern const pktio_if_ops_t loopback_pktio_ops; #ifdef HAVE_PCAP extern const pktio_if_ops_t pcap_pktio_ops; #endif +extern const pktio_if_ops_t tap_pktio_ops; extern const pktio_if_ops_t * const pktio_if_ops[]; #ifdef __cplusplus diff --git a/platform/linux-generic/include/odp_packet_tap.h b/platform/linux-generic/include/odp_packet_tap.h new file mode 100644 index 000..7877586 --- /dev/null +++ b/platform/linux-generic/include/odp_packet_tap.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2015, Ilya Maximets + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PACKET_TAP_H_ +#define ODP_PACKET_TAP_H_ + +#include + +typedef struct { + int fd; /**< file descriptor for tap interface*/ + int skfd; /**< socket descriptor */ + uint32_t mtu; /**< cached mtu */ + unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a + MAC address of kernel interface)*/ + odp_pool_t pool;/**< pool to alloc packets from */ +} pkt_tap_t; + +#endif diff --git a/platform/linux-generic/pktio/io_ops.c b/platform/linux-generic/pktio/io_ops.c index 3b344e6..1933abc 100644 --- a/platform/linux-generic/pktio/io_ops.c +++ b/platform/linux-generic/pktio/io_ops.c @@ -18,6
Re: [lng-odp] [PATCHv3 2/3] linux-generic: pktio: add tap pktio type
On 08.12.2015 15:35, Stuart Haslam wrote: > On Tue, Dec 08, 2015 at 03:25:01PM +0300, Ilya Maximets wrote: >> >> >> On 08.12.2015 15:16, Stuart Haslam wrote: >>> On Tue, Dec 08, 2015 at 02:51:40PM +0300, Ilya Maximets wrote: On 08.12.2015 14:24, Stuart Haslam wrote: > On Mon, Dec 07, 2015 at 01:55:31PM +0300, Ilya Maximets wrote: >> Creates a new pktio type that allows for creating and >> sending/receiving packets through TAP interface. >> It is intended for use as a simple conventional communication >> method between applications that use kernel network stack >> (ping, ssh, iperf, etc.) and ODP applications for the purpose >> of functional testing and can be used as it is with some >> of the existing example applications. >> >> To use this interface the name passed to odp_pktio_open() must >> begin with "tap:" and be in the format: >> >> tap:iface >> >>iface the name of TAP device to be created. >> >> TUN/TAP kernel module should be loaded to use this pktio. >> There should be no device named 'iface' in the system. >> The total length of the 'iface' is limited by IF_NAMESIZE. >> >> Signed-off-by: Ilya Maximets>> --- >> platform/linux-generic/Makefile.am | 2 + >> .../linux-generic/include/odp_packet_io_internal.h | 3 + >> platform/linux-generic/include/odp_packet_tap.h| 21 ++ >> platform/linux-generic/pktio/io_ops.c | 1 + >> platform/linux-generic/pktio/tap.c | 317 >> + >> 5 files changed, 344 insertions(+) >> create mode 100644 platform/linux-generic/include/odp_packet_tap.h >> create mode 100644 platform/linux-generic/pktio/tap.c >> >> diff --git a/platform/linux-generic/Makefile.am >> b/platform/linux-generic/Makefile.am >> index 70bd8fe..4639ebc 100644 >> --- a/platform/linux-generic/Makefile.am >> +++ b/platform/linux-generic/Makefile.am >> @@ -92,6 +92,7 @@ noinst_HEADERS = \ >>${srcdir}/include/odp_packet_io_queue.h \ >>${srcdir}/include/odp_packet_netmap.h \ >>${srcdir}/include/odp_packet_socket.h \ >> + ${srcdir}/include/odp_packet_tap.h \ >>${srcdir}/include/odp_pool_internal.h \ >>${srcdir}/include/odp_queue_internal.h \ >>${srcdir}/include/odp_schedule_internal.h \ >> @@ -120,6 +121,7 @@ __LIB__libodp_la_SOURCES = \ >> pktio/netmap.c \ >> pktio/socket.c \ >> pktio/socket_mmap.c \ >> + pktio/tap.c \ >> odp_pool.c \ >> odp_queue.c \ >> odp_rwlock.c \ >> diff --git a/platform/linux-generic/include/odp_packet_io_internal.h >> b/platform/linux-generic/include/odp_packet_io_internal.h >> index 1a1118c..de29557 100644 >> --- a/platform/linux-generic/include/odp_packet_io_internal.h >> +++ b/platform/linux-generic/include/odp_packet_io_internal.h >> @@ -22,6 +22,7 @@ extern "C" { >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -78,6 +79,7 @@ struct pktio_entry { >> #ifdef HAVE_PCAP >> pkt_pcap_t pkt_pcap;/**< Using pcap for IO >> */ >> #endif >> +pkt_tap_t pkt_tap; /**< using TAP for IO */ >> }; >> enum { >> STATE_START = 0, >> @@ -157,6 +159,7 @@ extern const pktio_if_ops_t loopback_pktio_ops; >> #ifdef HAVE_PCAP >> extern const pktio_if_ops_t pcap_pktio_ops; >> #endif >> +extern const pktio_if_ops_t tap_pktio_ops; >> extern const pktio_if_ops_t * const pktio_if_ops[]; >> >> #ifdef __cplusplus >> diff --git a/platform/linux-generic/include/odp_packet_tap.h >> b/platform/linux-generic/include/odp_packet_tap.h >> new file mode 100644 >> index 000..7877586 >> --- /dev/null >> +++ b/platform/linux-generic/include/odp_packet_tap.h >> @@ -0,0 +1,21 @@ >> +/* Copyright (c) 2015, Ilya Maximets >> + * All rights reserved. >> + * >> + * SPDX-License-Identifier: BSD-3-Clause >> + */ >> + >> +#ifndef ODP_PACKET_TAP_H_ >> +#define ODP_PACKET_TAP_H_ >> + >> +#include >> + >> +typedef struct { >> +int fd; /**< file descriptor for tap >> interface*/ >> +int skfd; /**< socket descriptor */ >> +uint32_t mtu; /**< cached mtu */ >> +unsigned char if_mac[ETH_ALEN];
[lng-odp] [PATCHv3 2/3] linux-generic: pktio: add tap pktio type
Creates a new pktio type that allows for creating and sending/receiving packets through TAP interface. It is intended for use as a simple conventional communication method between applications that use kernel network stack (ping, ssh, iperf, etc.) and ODP applications for the purpose of functional testing and can be used as it is with some of the existing example applications. To use this interface the name passed to odp_pktio_open() must begin with "tap:" and be in the format: tap:iface iface the name of TAP device to be created. TUN/TAP kernel module should be loaded to use this pktio. There should be no device named 'iface' in the system. The total length of the 'iface' is limited by IF_NAMESIZE. Signed-off-by: Ilya Maximets--- platform/linux-generic/Makefile.am | 2 + .../linux-generic/include/odp_packet_io_internal.h | 3 + platform/linux-generic/include/odp_packet_tap.h| 21 ++ platform/linux-generic/pktio/io_ops.c | 1 + platform/linux-generic/pktio/tap.c | 317 + 5 files changed, 344 insertions(+) create mode 100644 platform/linux-generic/include/odp_packet_tap.h create mode 100644 platform/linux-generic/pktio/tap.c diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 70bd8fe..4639ebc 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -92,6 +92,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_io_queue.h \ ${srcdir}/include/odp_packet_netmap.h \ ${srcdir}/include/odp_packet_socket.h \ + ${srcdir}/include/odp_packet_tap.h \ ${srcdir}/include/odp_pool_internal.h \ ${srcdir}/include/odp_queue_internal.h \ ${srcdir}/include/odp_schedule_internal.h \ @@ -120,6 +121,7 @@ __LIB__libodp_la_SOURCES = \ pktio/netmap.c \ pktio/socket.c \ pktio/socket_mmap.c \ + pktio/tap.c \ odp_pool.c \ odp_queue.c \ odp_rwlock.c \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 1a1118c..de29557 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -22,6 +22,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -78,6 +79,7 @@ struct pktio_entry { #ifdef HAVE_PCAP pkt_pcap_t pkt_pcap;/**< Using pcap for IO */ #endif + pkt_tap_t pkt_tap; /**< using TAP for IO */ }; enum { STATE_START = 0, @@ -157,6 +159,7 @@ extern const pktio_if_ops_t loopback_pktio_ops; #ifdef HAVE_PCAP extern const pktio_if_ops_t pcap_pktio_ops; #endif +extern const pktio_if_ops_t tap_pktio_ops; extern const pktio_if_ops_t * const pktio_if_ops[]; #ifdef __cplusplus diff --git a/platform/linux-generic/include/odp_packet_tap.h b/platform/linux-generic/include/odp_packet_tap.h new file mode 100644 index 000..7877586 --- /dev/null +++ b/platform/linux-generic/include/odp_packet_tap.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2015, Ilya Maximets + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PACKET_TAP_H_ +#define ODP_PACKET_TAP_H_ + +#include + +typedef struct { + int fd; /**< file descriptor for tap interface*/ + int skfd; /**< socket descriptor */ + uint32_t mtu; /**< cached mtu */ + unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a +MAC address of kernel interface)*/ + odp_pool_t pool;/**< pool to alloc packets from */ +} pkt_tap_t; + +#endif diff --git a/platform/linux-generic/pktio/io_ops.c b/platform/linux-generic/pktio/io_ops.c index 3b344e6..1933abc 100644 --- a/platform/linux-generic/pktio/io_ops.c +++ b/platform/linux-generic/pktio/io_ops.c @@ -18,6 +18,7 @@ const pktio_if_ops_t * const pktio_if_ops[] = { #ifdef HAVE_PCAP _pktio_ops, #endif + _pktio_ops, _mmap_pktio_ops, _mmsg_pktio_ops, NULL diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c new file mode 100644 index 000..b11e64f --- /dev/null +++ b/platform/linux-generic/pktio/tap.c @@ -0,0 +1,317 @@ +/* Copyright (c) 2015, Ilya Maximets + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * TAP pktio type + * + * This file provides a pktio interface that allows for creating and + * send/receive