This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 5a63614fd03e4fafe24ea576790c44792d998a1c (commit) via ccb26bd2248598b5f6327ff1f7f335f1827475e7 (commit) via 440c1585eef9f5b6d27bae422bfac36c15094101 (commit) via 7459f7cc1eb2235f283ef18e69567e2da6eea035 (commit) via 00707d7ce917a860f29e4a55e82d95cc6a849d4e (commit) from c6d92eeac0e503d53a8e805635ec78a9e9e31338 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 5a63614fd03e4fafe24ea576790c44792d998a1c Author: Matias Elo matias.elo@nokia.com Date: Thu Sep 12 12:42:57 2019 +0300
linux-gen: README: add documentation for pktio type specification
Document how to explicitly specify the used implementation internal pktio type. Includes also additional cleanup.
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Petri Savolainen petri.savolainen@nokia.com
diff --git a/platform/linux-generic/README b/platform/linux-generic/README index 532f3768f..04267909b 100644 --- a/platform/linux-generic/README +++ b/platform/linux-generic/README @@ -1,17 +1,43 @@ Copyright (c) 2014-2018, Linaro Limited +Copyright (c) 2019, Nokia All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
1. Intro - -OpenDataPlane implementation for Linux generic. Directory linux-generic contains ODP headers and implementation -for linux-generic target. This drop does not target high -performance. It is rather proof of ODP API functionality. It still uses -linux-generic's SW scheduler. + OpenDataPlane API generic Linux implementation. Directory linux-generic + contains the header and source files and additional platform test scripts + for ODP linux-generic implementation.
2. Build -# To compile ODP -./bootstrap -./configure -make + See DEPENDENCIES file about system requirements and dependencies to external + libraries/packages. It contains also more detailed build instructions. + + Generally, ODP is built with these three steps: + ./bootstrap + ./configure + make + +3. Configuration file + See config/README for application runtime configuration options. + +4. Packet I/O + When passing a packet I/O device name to odp_pktio_open() one can explicitly + specify the used implementation internal pktio type. The pktio type can be + selected by adding a pktio type prefix to the device name separated by a + colon (<pktio_type>:<if_name>). + + E.g. + socket:eth1 + netmap:eth2 + + The supported pktio types are: + dpdk + ipc + loop + netmap + null + pcap + socket + socket_mmap + tap
commit ccb26bd2248598b5f6327ff1f7f335f1827475e7 Author: Matias Elo matias.elo@nokia.com Date: Thu Sep 12 10:59:05 2019 +0300
linux-gen: pktio: explicitly define pktio type for validation tests
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Petri Savolainen petri.savolainen@nokia.com
diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh b/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh index 6140fb4c9..39b540228 100755 --- a/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh +++ b/platform/linux-generic/test/validation/api/pktio/pktio_run_dpdk.sh @@ -75,8 +75,8 @@ run() if [ "$ODP_PKTIO_IF0" = "" ]; then setup_pktio_env clean export ODP_PKTIO_DPDK_PARAMS="--no-pci --vdev net_pcap0,iface=$IF0 --vdev net_pcap1,iface=$IF1" - export ODP_PKTIO_IF0=0 - export ODP_PKTIO_IF1=1 + export ODP_PKTIO_IF0=dpdk:0 + export ODP_PKTIO_IF1=dpdk:1 fi
run_test diff --git a/platform/linux-generic/test/validation/api/pktio/pktio_run_netmap.sh b/platform/linux-generic/test/validation/api/pktio/pktio_run_netmap.sh index 2b58f28f0..f4851483b 100755 --- a/platform/linux-generic/test/validation/api/pktio/pktio_run_netmap.sh +++ b/platform/linux-generic/test/validation/api/pktio/pktio_run_netmap.sh @@ -84,8 +84,8 @@ run_test_veth() fi
setup_pktio_env clean - export ODP_PKTIO_IF0=$IF0 - export ODP_PKTIO_IF1=$IF1 + export ODP_PKTIO_IF0=netmap:$IF0 + export ODP_PKTIO_IF1=netmap:$IF1 run_test return $? }
commit 440c1585eef9f5b6d27bae422bfac36c15094101 Author: Matias Elo matias.elo@nokia.com Date: Wed Sep 11 17:17:30 2019 +0300
linux-gen: pktio: enable explicit pktio type definition
Previously, the odp_pktio_open() implementation called open() for all implementation internal pktio types in predefined order until the call succeeded or all pktio types failed.
Add option to explicitly define the used pktio type per device. This enables the user to use multiple pktio types within a single application.
The pktio type is selected by adding pktio_type prefix in front of device name separated by a colon (<pktio_type>:<if_name>).
E.g. socket:eth1 netmap:eth2
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Petri Savolainen petri.savolainen@nokia.com Suggested-by: Risto Teittinen risto.teittinen@nokia-bell-labs.com
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 40f5f5a3e..18bbf6de8 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -1,4 +1,5 @@ /* Copyright (c) 2013-2018, Linaro Limited + * Copyright (c) 2019, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -93,8 +94,10 @@ struct pktio_entry { odp_proto_chksums_t in_chksums; /**< Checksums validation settings */ pktio_stats_type_t stats_type; char name[PKTIO_NAME_LEN]; /**< name of pktio provided to - pktio_open() */ - + internal pktio_open() calls */ + char full_name[PKTIO_NAME_LEN]; /**< original pktio name passed to + odp_pktio_open() and returned by + odp_pktio_info() */ odp_pool_t pool; odp_pktio_param_t param; odp_pktio_capability_t capa; /**< Packet IO capabilities */ diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index bb3c46a7b..91555c680 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -195,6 +195,56 @@ static odp_pktio_t alloc_lock_pktio_entry(void) return ODP_PKTIO_INVALID; }
+/** + * Strip optional pktio type from device name by moving start pointer + * + * @param name Packet IO device name + * @param[out] type_out Optional char array (len = PKTIO_NAME_LEN) for storing + * pktio type. Ignored when NULL. + * + * @return Pointer to the beginning of device name + */ +static const char *strip_pktio_type(const char *name, char *type_out) +{ + const char *if_name; + + if (type_out) + type_out[0] = '\0'; + + /* Strip pktio type prefix <pktio_type>:<if_name> */ + if_name = strchr(name, ':'); + + if (if_name) { + int pktio_if; + int type_len = if_name - name; + char pktio_type[type_len + 1]; + + strncpy(pktio_type, name, type_len); + pktio_type[type_len] = '\0'; + + /* Remove colon */ + if_name++; + + /* Match if_type to enabled pktio devices */ + for (pktio_if = 0; pktio_if_ops[pktio_if]; pktio_if++) { + if (!strcmp(pktio_type, pktio_if_ops[pktio_if]->name)) { + if (type_out) + strcpy(type_out, pktio_type); + /* Some pktio devices expect device names to + * begin with pktio type */ + if (!strcmp(pktio_type, "ipc") || + !strcmp(pktio_type, "null") || + !strcmp(pktio_type, "pcap") || + !strcmp(pktio_type, "tap")) + return name; + + return if_name; + } + } + } + return name; +} + static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, const odp_pktio_param_t *param) { @@ -202,6 +252,8 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, pktio_entry_t *pktio_entry; int ret = -1; int pktio_if; + char pktio_type[PKTIO_NAME_LEN]; + const char *if_name;
if (strlen(name) >= PKTIO_NAME_LEN - 1) { /* ioctl names limitation */ @@ -210,6 +262,8 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, return ODP_PKTIO_INVALID; }
+ if_name = strip_pktio_type(name, pktio_type); + hdl = alloc_lock_pktio_entry(); if (hdl == ODP_PKTIO_INVALID) { ODP_ERR("No resources available.\n"); @@ -230,7 +284,12 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, odp_pktio_config_init(&pktio_entry->s.config);
for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) { - ret = pktio_if_ops[pktio_if]->open(hdl, pktio_entry, name, + /* Only use explicitly defined pktio type */ + if (strlen(pktio_type) && + strcmp(pktio_if_ops[pktio_if]->name, pktio_type)) + continue; + + ret = pktio_if_ops[pktio_if]->open(hdl, pktio_entry, if_name, pool); if (!ret) break; @@ -244,7 +303,9 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, }
snprintf(pktio_entry->s.name, - sizeof(pktio_entry->s.name), "%s", name); + sizeof(pktio_entry->s.name), "%s", if_name); + snprintf(pktio_entry->s.full_name, + sizeof(pktio_entry->s.full_name), "%s", name); pktio_entry->s.state = PKTIO_STATE_OPENED; pktio_entry->s.ops = pktio_if_ops[pktio_if]; unlock_entry(pktio_entry); @@ -588,8 +649,11 @@ odp_pktio_t odp_pktio_lookup(const char *name) { odp_pktio_t hdl = ODP_PKTIO_INVALID; pktio_entry_t *entry; + const char *ifname; int i;
+ ifname = strip_pktio_type(name, NULL); + odp_spinlock_lock(&pktio_tbl->lock);
for (i = 0; i < ODP_CONFIG_PKTIO_ENTRIES; ++i) { @@ -600,7 +664,7 @@ odp_pktio_t odp_pktio_lookup(const char *name) lock_entry(entry);
if (entry->s.state >= PKTIO_STATE_ACTIVE && - strncmp(entry->s.name, name, sizeof(entry->s.name)) == 0) + strncmp(entry->s.name, ifname, sizeof(entry->s.name)) == 0) hdl = _odp_cast_scalar(odp_pktio_t, i + 1);
unlock_entry(entry); @@ -1139,7 +1203,7 @@ int odp_pktio_info(odp_pktio_t hdl, odp_pktio_info_t *info) }
memset(info, 0, sizeof(odp_pktio_info_t)); - info->name = entry->s.name; + info->name = entry->s.full_name; info->drv_name = entry->s.ops->name; info->pool = entry->s.pool; memcpy(&info->param, &entry->s.param, sizeof(odp_pktio_param_t));
commit 7459f7cc1eb2235f283ef18e69567e2da6eea035 Author: Matias Elo matias.elo@nokia.com Date: Fri Sep 13 10:49:20 2019 +0300
linux-gen: netmap: lower interface MTU if necessary
Netmap has introduced additional check to nm_open() to verify that interface MTU <= netmap buffer size. To pass this check interface MTU may have to be lowered before nm_open() call.
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Petri Savolainen petri.savolainen@nokia.com
diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 8fb231534..8b38c08db 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -1,4 +1,5 @@ /* Copyright (c) 2015-2018, Linaro Limited + * Copyright (c) 2019, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -34,7 +35,6 @@ #include <odp_classification_internal.h> #include <odp_libconfig_internal.h>
- #include <inttypes.h>
/* Disable netmap debug prints */ @@ -52,6 +52,8 @@
#define NM_MAX_DESC 64
+#define NM_BUF_SIZE "/sys/module/netmap/parameters/buf_size" + /** netmap runtime configuration options */ typedef struct { int nr_rx_slots; @@ -114,6 +116,29 @@ static inline pkt_netmap_t *pkt_priv(pktio_entry_t *pktio_entry) static int disable_pktio; /** !0 this pktio disabled, 0 enabled */ static int netmap_stats_reset(pktio_entry_t *pktio_entry);
+static int read_netmap_buf_size(void) +{ + FILE *file; + char str[128]; + int size = 0; + + file = fopen(NM_BUF_SIZE, "rt"); + if (file == NULL) { + /* File not found */ + return 0; + } + + if (fgets(str, sizeof(str), file) != NULL) { + /* Read netmap buffer size */ + if (sscanf(str, "%i", &size) != 1) + size = 0; + } + + fclose(file); + + return size; +} + static int lookup_opt(const char *opt_name, const char *drv_name, int *val) { const char *base = "pktio_netmap"; @@ -443,10 +468,9 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, int sockfd; const char *prefix; uint32_t mtu; - uint32_t buf_size; + uint32_t nm_buf_size; pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); struct nm_desc *desc; - struct netmap_ring *ring; odp_pktin_hash_proto_t hash_proto; odp_pktio_stats_t cur_stats;
@@ -480,6 +504,39 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, return -1; }
+ /* Read netmap buffer size */ + nm_buf_size = read_netmap_buf_size(); + if (!nm_buf_size) { + ODP_ERR("Unable to read netmap buf size\n"); + return -1; + } + + if (!pkt_nm->is_virtual) { + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + ODP_ERR("Cannot get device control socket\n"); + return -1; + } + pkt_nm->sockfd = sockfd; + + /* Use either interface MTU or netmap buffer size as MTU, + * whichever is smaller. */ + mtu = mtu_get_fd(pkt_nm->sockfd, pkt_nm->if_name); + if (mtu == 0) { + ODP_ERR("Unable to read interface MTU\n"); + goto error; + } + pkt_nm->mtu = (mtu < nm_buf_size) ? mtu : nm_buf_size; + + /* Netmap requires that interface MTU size <= nm buf size */ + if (mtu > nm_buf_size) { + if (mtu_set_fd(pkt_nm->sockfd, pkt_nm->if_name, + nm_buf_size)) { + ODP_ERR("Unable to set interface MTU\n"); + goto error; + } + } + } /* Dummy open here to check if netmap module is available and to read * capability info. */ desc = nm_open(pkt_nm->nm_name, NULL, 0, NULL); @@ -492,8 +549,6 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,
netmap_init_capability(pktio_entry);
- ring = NETMAP_RXRING(desc->nifp, desc->cur_rx_ring); - buf_size = ring->nr_buf_size; nm_close(desc);
for (i = 0; i < PKTIO_MAX_QUEUES; i++) { @@ -511,7 +566,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,
pktio_entry->s.capa.max_input_queues = 1; pktio_entry->s.capa.set_op.op.promisc_mode = 0; - pkt_nm->mtu = buf_size; + pkt_nm->mtu = nm_buf_size; pktio_entry->s.stats_type = STATS_UNSUPPORTED; /* Set MAC address for virtual interface */ pkt_nm->if_mac[0] = 0x2; @@ -524,24 +579,9 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, return 0; }
- sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd == -1) { - ODP_ERR("Cannot get device control socket\n"); - goto error; - } - pkt_nm->sockfd = sockfd; - - /* Use either interface MTU or netmap buffer size as MTU, whichever is - * smaller. */ - mtu = mtu_get_fd(pkt_priv(pktio_entry)->sockfd, pkt_nm->if_name); - if (mtu == 0) { - ODP_ERR("Unable to read interface MTU\n"); - goto error; - } - pkt_nm->mtu = (mtu < buf_size) ? mtu : buf_size; - /* Check if RSS is supported. If not, set 'max_input_queues' to 1. */ - if (rss_conf_get_supported_fd(sockfd, netdev, &hash_proto) == 0) { + if (rss_conf_get_supported_fd(pkt_nm->sockfd, netdev, + &hash_proto) == 0) { ODP_DBG("RSS not supported\n"); pktio_entry->s.capa.max_input_queues = 1; } @@ -552,13 +592,12 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, if ((pkt_nm->if_flags & IFF_UP) == 0) ODP_DBG("%s is down\n", pkt_nm->if_name);
- err = mac_addr_get_fd(sockfd, netdev, pkt_nm->if_mac); + err = mac_addr_get_fd(pkt_nm->sockfd, netdev, pkt_nm->if_mac); if (err) goto error;
/* netmap uses only ethtool to get statistics counters */ - err = ethtool_stats_get_fd(pkt_priv(pktio_entry)->sockfd, - pkt_nm->if_name, &cur_stats); + err = ethtool_stats_get_fd(pkt_nm->sockfd, pkt_nm->if_name, &cur_stats); if (err) { ODP_ERR("netmap pktio %s does not support statistics counters\n", pkt_nm->if_name);
commit 00707d7ce917a860f29e4a55e82d95cc6a849d4e Author: Matias Elo matias.elo@nokia.com Date: Fri Sep 13 10:48:45 2019 +0300
linux-gen: pktio: add helper function for setting interface mtu
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Petri Savolainen petri.savolainen@nokia.com
diff --git a/platform/linux-generic/include/odp_socket_common.h b/platform/linux-generic/include/odp_socket_common.h index 4c6b3e636..afce0f55d 100644 --- a/platform/linux-generic/include/odp_socket_common.h +++ b/platform/linux-generic/include/odp_socket_common.h @@ -1,4 +1,5 @@ /* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2019, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -36,6 +37,11 @@ int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]); */ uint32_t mtu_get_fd(int fd, const char *name);
+/** + * Set a packet socket MTU + */ +int mtu_set_fd(int fd, const char *name, int mtu); + /** * Enable/Disable promisc mode for a packet socket */ diff --git a/platform/linux-generic/pktio/socket_common.c b/platform/linux-generic/pktio/socket_common.c index f5bf9e008..7dbba6d27 100644 --- a/platform/linux-generic/pktio/socket_common.c +++ b/platform/linux-generic/pktio/socket_common.c @@ -1,4 +1,5 @@ /* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2019, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -66,6 +67,27 @@ uint32_t mtu_get_fd(int fd, const char *name) return ifr.ifr_mtu + _ODP_ETHHDR_LEN; }
+/* + * ODP_PACKET_NETMAP: + */ +int mtu_set_fd(int fd, const char *name, int mtu) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ifr.ifr_mtu = mtu; + + ret = ioctl(fd, SIOCSIFMTU, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCSIFMTU): %s: "%s".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + return 0; +} + /* * ODP_PACKET_SOCKET_MMSG: * ODP_PACKET_SOCKET_MMAP:
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/README | 44 ++++++++--- .../linux-generic/include/odp_packet_io_internal.h | 7 +- platform/linux-generic/include/odp_socket_common.h | 6 ++ platform/linux-generic/odp_packet_io.c | 72 ++++++++++++++++- platform/linux-generic/pktio/netmap.c | 91 +++++++++++++++------- platform/linux-generic/pktio/socket_common.c | 22 ++++++ .../test/validation/api/pktio/pktio_run_dpdk.sh | 4 +- .../test/validation/api/pktio/pktio_run_netmap.sh | 4 +- 8 files changed, 205 insertions(+), 45 deletions(-)
hooks/post-receive