From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by dpdk.org (Postfix) with ESMTP id D58F02C37 for ; Wed, 3 Oct 2018 09:22:22 +0200 (CEST) Received: by mail-lj1-f195.google.com with SMTP id p89-v6so4119317ljb.3 for ; Wed, 03 Oct 2018 00:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MVh48DRO/EzfdVkJVYpCQzNYoayZE/d3qIpcOPKTuys=; b=yW4H0AXDNMuylN3mLO93qhatRB4zpvo93EF2NjH6y75+HExfb8UFlcPHZXWZw/1lqg X/U/hHDreAxKKISJMXQxM5B6GZ/QoB3SnFKHTb77iqE1xG3K2HR1HOSXCVbuC7XSZaot Rivn5rbgS/TuSNszHtcIIcw/taElRta4zqn62I8WknC/eG/oIxNuywmHJE1zOlJZp86B 3yZQ6N7C9Qsckt8Yy0UKrGDe2USpV0E57NE8EgC49gExpK2kiBkrqM0pR3BXqPOgI8/D fiAbF9G6o3TlNZh9XexFq98QaXuvpuMZeDXkJQYbVHv8GFMLXNsCsAmSYRkweavjzcSV d3ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MVh48DRO/EzfdVkJVYpCQzNYoayZE/d3qIpcOPKTuys=; b=oozF6yNgm5NwLvA7daRTCP0kByCsxeq+Tw7CmApENqMlpdJmoiTn/ObtXmVc3W9GG3 99qj9thsw1aQazzxPbbVls53G0bntjT6hNCmNAqz4JMDQJfgKLvVc72xLCfobzOVSV3D IbGzjl9FE8gCBEcQhEtdt1uc1PC2jo3ALroOjNGcSyKHTvuDrFdLJPHkhUjcjW6vyD1f TKgWzVii+yrUEeb5XbZzKrpoqMZdxiJEhbI6Qe7x5SG4qOoT0K3KAXXY1tEpT80JtCMH githE3dKHAMJvIyU0f49HwURnVCpc9VY+WwfeU1W9A8tZF6HTBuFiP4JpP1PJuo70tDx /l2A== X-Gm-Message-State: ABuFfoi3aSalAAVW8/xR++gnYZu6wWUBh516oC1DHL1BnY6OYsoAa4WF 35OJe2ZppSKV5fw1ND2hMPWOj2ubN9uesQ== X-Google-Smtp-Source: ACcGV63Q5rQe8ATfDGh0Rr/OY0uF1z7QO3q/gLotshGR3vOJFdByrhGjbv+QenN02pZ3hcoKntDgdw== X-Received: by 2002:a2e:458b:: with SMTP id s133-v6mr182229lja.60.1538551342255; Wed, 03 Oct 2018 00:22:22 -0700 (PDT) Received: from amok.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.googlemail.com with ESMTPSA id f73-v6sm123659lfl.80.2018.10.03.00.22.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Oct 2018 00:22:21 -0700 (PDT) From: Andrzej Ostruszka X-Google-Original-From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, nadavh@marvell.com, zr@semihalf.com, tdu@semihalf.com Date: Wed, 3 Oct 2018 09:22:11 +0200 Message-Id: <1538551336-19259-4-git-send-email-andrzej.ostruszka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538551336-19259-1-git-send-email-andrzej.ostruszka@gmail.com> References: <1538385970-21260-1-git-send-email-andrzej.ostruszka@gmail.com> <1538551336-19259-1-git-send-email-andrzej.ostruszka@gmail.com> Subject: [dpdk-dev] [PATCH v7 3/8] net/mvneta: support for setting of MTU 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: Wed, 03 Oct 2018 07:22:23 -0000 From: Zyta Szpak Add callback for setting of MTU. Signed-off-by: Natalie Samsonov Signed-off-by: Zyta Szpak --- doc/guides/nics/features/mvneta.ini | 1 + doc/guides/nics/mvneta.rst | 1 + drivers/net/mvneta/mvneta_ethdev.c | 78 +++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/doc/guides/nics/features/mvneta.ini b/doc/guides/nics/features/mvneta.ini index 0a89e2f..bc4e400 100644 --- a/doc/guides/nics/features/mvneta.ini +++ b/doc/guides/nics/features/mvneta.ini @@ -5,6 +5,7 @@ ; [Features] Speed capabilities = Y +MTU update = Y Jumbo frame = Y CRC offload = Y L3 checksum offload = Y diff --git a/doc/guides/nics/mvneta.rst b/doc/guides/nics/mvneta.rst index 7ea003c..aadeacb 100644 --- a/doc/guides/nics/mvneta.rst +++ b/doc/guides/nics/mvneta.rst @@ -30,6 +30,7 @@ Features of the MVNETA PMD are: - tx/rx_burst - Speed capabilities - Jumbo frame +- MTU update - CRC offload - L3 checksum offload - L4 checksum offload diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c index 146b249..24f87e2 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -218,6 +218,77 @@ mvneta_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) } /** + * DPDK callback to change the MTU. + * + * Setting the MTU affects hardware MRU (packets larger than the MRU + * will be dropped). + * + * @param dev + * Pointer to Ethernet device structure. + * @param mtu + * New MTU. + * + * @return + * 0 on success, negative error value otherwise. + */ +static int +mvneta_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct mvneta_priv *priv = dev->data->dev_private; + uint16_t mbuf_data_size = 0; /* SW buffer size */ + uint16_t mru; + int ret; + + mru = MRVL_NETA_MTU_TO_MRU(mtu); + /* + * min_rx_buf_size is equal to mbuf data size + * if pmd didn't set it differently + */ + mbuf_data_size = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM; + /* Prevent PMD from: + * - setting mru greater than the mbuf size resulting in + * hw and sw buffer size mismatch + * - setting mtu that requires the support of scattered packets + * when this feature has not been enabled/supported so far. + */ + if (!dev->data->scattered_rx && + (mru + MRVL_NETA_PKT_OFFS > mbuf_data_size)) { + mru = mbuf_data_size - MRVL_NETA_PKT_OFFS; + mtu = MRVL_NETA_MRU_TO_MTU(mru); + MVNETA_LOG(WARNING, "MTU too big, max MTU possible limitted by" + " current mbuf size: %u. Set MTU to %u, MRU to %u", + mbuf_data_size, mtu, mru); + } + + if (mtu < ETHER_MIN_MTU || mru > MVNETA_PKT_SIZE_MAX) { + MVNETA_LOG(ERR, "Invalid MTU [%u] or MRU [%u]", mtu, mru); + return -EINVAL; + } + + dev->data->mtu = mtu; + dev->data->dev_conf.rxmode.max_rx_pkt_len = mru - MV_MH_SIZE; + + if (!priv->ppio) + /* It is OK. New MTU will be set later on mvneta_dev_start */ + return 0; + + ret = neta_ppio_set_mru(priv->ppio, mru); + if (ret) { + MVNETA_LOG(ERR, "Failed to change MRU"); + return ret; + } + + ret = neta_ppio_set_mtu(priv->ppio, mtu); + if (ret) { + MVNETA_LOG(ERR, "Failed to change MTU"); + return ret; + } + MVNETA_LOG(INFO, "MTU changed to %u, MRU = %u", mtu, mru); + + return 0; +} + +/** * DPDK callback to bring the link up. * * @param dev @@ -307,6 +378,12 @@ mvneta_dev_start(struct rte_eth_dev *dev) if (ret) goto out; + ret = mvneta_mtu_set(dev, dev->data->mtu); + if (ret) { + MVNETA_LOG(ERR, "Failed to set MTU %d", dev->data->mtu); + goto out; + } + ret = mvneta_dev_set_link_up(dev); if (ret) { MVNETA_LOG(ERR, "Failed to set link up"); @@ -408,6 +485,7 @@ static const struct eth_dev_ops mvneta_ops = { .dev_set_link_down = mvneta_dev_set_link_down, .dev_close = mvneta_dev_close, .mac_addr_set = mvneta_mac_addr_set, + .mtu_set = mvneta_mtu_set, .dev_infos_get = mvneta_dev_infos_get, .dev_supported_ptypes_get = mvneta_dev_supported_ptypes_get, .rxq_info_get = mvneta_rxq_info_get, -- 2.7.4