From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id CA024CFA0 for ; Tue, 14 Mar 2017 09:24:09 +0100 (CET) Received: from 6wind.com (unknown [10.16.0.184]) by proxy.6wind.com (Postfix) with SMTP id F2A3326980; Tue, 14 Mar 2017 09:24:03 +0100 (CET) Received: by 6wind.com (sSMTP sendmail emulation); Tue, 14 Mar 2017 09:23:05 +0100 From: Pascal Mazon To: keith.wiles@intel.com Cc: dev@dpdk.org, Pascal Mazon Date: Tue, 14 Mar 2017 09:22:48 +0100 Message-Id: <91aad7612f6a7b5d2f3173be90fcda2d72dc6dbc.1489479553.git.pascal.mazon@6wind.com> X-Mailer: git-send-email 2.8.0.rc0 In-Reply-To: References: <1488904298-31395-1-git-send-email-pascal.mazon@6wind.com> Subject: [dpdk-dev] [PATCH v4 4/8] net/tap: add MTU management X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Mar 2017 08:24:09 -0000 The MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size. As a new rte_eth_dev_data is allocated during tap device init, ensure it is set again dev->data->mtu. Once the actual netdevice is created via tun_alloc(), make sure to apply the desired MTU to the netdevice. Signed-off-by: Pascal Mazon --- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/doc/guides/nics/features/tap.ini b/doc/guides/nics/features/tap.ini index d9b47a003654..b80577753240 100644 --- a/doc/guides/nics/features/tap.ini +++ b/doc/guides/nics/features/tap.ini @@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +MTU update = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 06c1faa92dce..3e61f7bda555 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -302,6 +302,7 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request, break; case SIOCGIFHWADDR: case SIOCSIFHWADDR: + case SIOCSIFMTU: break; default: RTE_LOG(WARNING, PMD, "%s: ioctl() called with wrong arg\n", @@ -547,6 +548,15 @@ tap_setup_queue(struct rte_eth_dev *dev, pmd->name, qid); return -1; } + if (qid == 0) { + struct ifreq ifr; + + ifr.ifr_mtu = dev->data->mtu; + if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1) < 0) { + close(fd); + return -1; + } + } } } @@ -642,6 +652,20 @@ tap_tx_queue_setup(struct rte_eth_dev *dev, return 0; } +static int +tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct pmd_internals *pmd = dev->data->dev_private; + struct ifreq ifr = { .ifr_mtu = mtu }; + int err = 0; + + err = tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1); + if (!err) + dev->data->mtu = mtu; + + return err; +} + static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop, @@ -660,6 +684,7 @@ static const struct eth_dev_ops ops = { .allmulticast_enable = tap_allmulti_enable, .allmulticast_disable = tap_allmulti_disable, .mac_addr_set = tap_mac_set, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, }; @@ -710,6 +735,7 @@ eth_dev_tap_create(const char *name, char *tap_name) /* Setup some default values */ data->dev_private = pmd; data->port_id = dev->data->port_id; + data->mtu = dev->data->mtu; data->dev_flags = RTE_ETH_DEV_DETACHABLE; data->kdrv = RTE_KDRV_NONE; data->drv_name = pmd_tap_drv.driver.name; -- 2.8.0.rc0