From patchwork Fri Jun 24 22:29:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "John Daley (johndale)" X-Patchwork-Id: 14378 X-Patchwork-Delegate: bruce.richardson@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id EFC5FC67A; Sat, 25 Jun 2016 00:30:44 +0200 (CEST) Received: from rcdn-iport-9.cisco.com (rcdn-iport-9.cisco.com [173.37.86.80]) by dpdk.org (Postfix) with ESMTP id AE091C67C for ; Sat, 25 Jun 2016 00:30:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5038; q=dns/txt; s=iport; t=1466807442; x=1468017042; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=RQq5FDcCn6TvEuKXQ8YfdoewiuVr4gdjpliz4TA+qPY=; b=PXfgFu/MvdffwqYPC/eFTo0fj+v1YV5Iw9kGEExD5hKe684NWYtIxSij SUAP2GU4XhN6PN5MW9tPNJjaH59qjJrReoT5uCROPqB1vraIfbcivANwj W+U7+GtD/rsX2Sc4xGJxctf8lZR0p3zwbbvcjvMKxtKcgBM0vFv4Ore2V s=; X-IronPort-AV: E=Sophos;i="5.26,523,1459814400"; d="scan'208";a="116648941" Received: from alln-core-6.cisco.com ([173.36.13.139]) by rcdn-iport-9.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Jun 2016 22:30:40 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-6.cisco.com (8.14.5/8.14.5) with ESMTP id u5OMUesC028442; Fri, 24 Jun 2016 22:30:40 GMT Received: by cisco.com (Postfix, from userid 392789) id 333663FAAE0D; Fri, 24 Jun 2016 15:30:40 -0700 (PDT) From: John Daley To: bruce.richardson@intel.com Cc: dev@dpdk.org, John Daley Date: Fri, 24 Jun 2016 15:29:28 -0700 Message-Id: <1466807368-7215-2-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1466807368-7215-1-git-send-email-johndale@cisco.com> References: <20160624110103.GE13456@bricha3-MOBL3> <1466807368-7215-1-git-send-email-johndale@cisco.com> Subject: [dpdk-dev] [PATCH v2 2/2] enic: add an update MTU function for non-Rx scatter mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Provide an update MTU callback. The function returns -ENOTSUP if Rx scatter is enabled. Updating the MTU to be greater than the value configured via the Cisco CIMC/UCSM management interface is allowed provided it is still less than the maximum egress packet size allowed by the NIC minus the size of the L2 header. Signed-off-by: John Daley --- v2: Squished 3/4 and 4/4 into 1 patch. Slight change of wording and fixed typo in commit message. doc/guides/nics/overview.rst | 2 +- drivers/net/enic/enic.h | 1 + drivers/net/enic/enic_ethdev.c | 10 +++++++++- drivers/net/enic/enic_main.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst index f94f6a2..872392b 100644 --- a/doc/guides/nics/overview.rst +++ b/doc/guides/nics/overview.rst @@ -92,7 +92,7 @@ Most of these differences are summarized below. Queue status event Y Rx interrupt Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Queue start/stop Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y - MTU update Y Y Y Y Y Y Y Y Y Y Y Y Y + MTU update Y Y Y Y Y Y Y Y Y Y Y Y Y Y Jumbo frame Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Scattered Rx Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y LRO Y Y Y Y diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index b557e12..9f5740d 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -263,4 +263,5 @@ uint16_t enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +int enic_set_mtu(struct enic *enic, uint16_t new_mtu); #endif /* _ENIC_H_ */ diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 6fa54b2..a7ce064 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -528,6 +528,14 @@ static void enicpmd_remove_mac_addr(struct rte_eth_dev *eth_dev, __rte_unused ui enic_del_mac_address(enic); } +static int enicpmd_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) +{ + struct enic *enic = pmd_priv(eth_dev); + + ENICPMD_FUNC_TRACE(); + return enic_set_mtu(enic, mtu); +} + static const struct eth_dev_ops enicpmd_eth_dev_ops = { .dev_configure = enicpmd_dev_configure, .dev_start = enicpmd_dev_start, @@ -545,7 +553,7 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = { .queue_stats_mapping_set = NULL, .dev_infos_get = enicpmd_dev_info_get, .dev_supported_ptypes_get = enicpmd_dev_supported_ptypes_get, - .mtu_set = NULL, + .mtu_set = enicpmd_mtu_set, .vlan_filter_set = enicpmd_vlan_filter_set, .vlan_tpid_set = NULL, .vlan_offload_set = enicpmd_vlan_offload_set, diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 91883f8..1d16f0e 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -1005,6 +1005,50 @@ int enic_set_vnic_res(struct enic *enic) return rc; } +/* The Cisco NIC can send and receive packets up to a max packet size + * determined by the NIC type and firmware. There is also an MTU + * configured into the NIC via the CIMC/UCSM management interface + * which can be overridden by this function (up to the max packet size). + * Depending on the network setup, doing so may cause packet drops + * and unexpected behavior. + */ +int enic_set_mtu(struct enic *enic, uint16_t new_mtu) +{ + uint16_t old_mtu; /* previous setting */ + uint16_t config_mtu; /* Value configured into NIC via CIMC/UCSM */ + struct rte_eth_dev *eth_dev = enic->rte_dev; + + old_mtu = eth_dev->data->mtu; + config_mtu = enic->config.mtu; + + /* only works with Rx scatter disabled */ + if (enic->rte_dev->data->dev_conf.rxmode.enable_scatter) + return -ENOTSUP; + + if (new_mtu > enic->max_mtu) { + dev_err(enic, + "MTU not updated: requested (%u) greater than max (%u)\n", + new_mtu, enic->max_mtu); + return -EINVAL; + } + if (new_mtu < ENIC_MIN_MTU) { + dev_info(enic, + "MTU not updated: requested (%u) less than min (%u)\n", + new_mtu, ENIC_MIN_MTU); + return -EINVAL; + } + if (new_mtu > config_mtu) + dev_warning(enic, + "MTU (%u) is greater than value configured in NIC (%u)\n", + new_mtu, config_mtu); + + /* update the mtu */ + eth_dev->data->mtu = new_mtu; + + dev_info(enic, "MTU changed from %u to %u\n", old_mtu, new_mtu); + return 0; +} + static int enic_dev_init(struct enic *enic) { int err;