From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-6.cisco.com (alln-iport-6.cisco.com [173.37.142.93]) by dpdk.org (Postfix) with ESMTP id 7F802CC06 for ; Fri, 17 Jun 2016 07:22:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3694; q=dns/txt; s=iport; t=1466140973; x=1467350573; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=oEl6HIFDUyJ5ZdWP//+Fl0IXItjpp6euDZxTHtLJjig=; b=hviJKJzN0GA6ZoTMep/tMZr766ABGT9L7Kn8iXjAgUjOpn8jeOtvVxZH oJQMfq5kSMo4BaznU0789PAMjKipYnNzusLzJwdIYXRzkOpIFVaHtPBEA 17SIdBULhN3Qt7sG8ApGsqrdCRLfZrqApVxMF2PJ4+Fq6wxDkLghNty2p I=; X-IronPort-AV: E=Sophos;i="5.26,481,1459814400"; d="scan'208";a="286731923" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by alln-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jun 2016 05:22:52 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-6.cisco.com (8.14.5/8.14.5) with ESMTP id u5H5MqMU029877; Fri, 17 Jun 2016 05:22:52 GMT Received: by cisco.com (Postfix, from userid 392789) id 160343FAAE32; Thu, 16 Jun 2016 22:22:52 -0700 (PDT) From: John Daley To: dev@dpdk.org Cc: bruce.richardson@intel.com, John Daley Date: Thu, 16 Jun 2016 22:22:47 -0700 Message-Id: <1466140969-5580-3-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1466140969-5580-1-git-send-email-johndale@cisco.com> References: <1466140969-5580-1-git-send-email-johndale@cisco.com> Subject: [dpdk-dev] [PATCH 2/4] enic: set the max allowed MTU for the NIC 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: , X-List-Received-Date: Fri, 17 Jun 2016 05:22:53 -0000 The max MTU is set to the max egress packet size allowed by the VIC minus the size of a an IPv4 L2 header with .1Q (18 bytes). Signed-off-by: John Daley --- drivers/net/enic/enic.h | 1 + drivers/net/enic/enic_ethdev.c | 3 ++- drivers/net/enic/enic_res.c | 25 +++++++++++++++++-------- drivers/net/enic/enic_res.h | 4 +++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 1e6914e..78f7bd7 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -118,6 +118,7 @@ struct enic { u8 ig_vlan_strip_en; int link_status; u8 hw_ip_checksum; + u16 max_mtu; unsigned int flags; unsigned int priv_flags; diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 697ff82..31d9600 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -435,7 +435,8 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev, device_info->max_rx_queues = enic->rq_count; device_info->max_tx_queues = enic->wq_count; device_info->min_rx_bufsize = ENIC_MIN_MTU; - device_info->max_rx_pktlen = enic->config.mtu; + device_info->max_rx_pktlen = enic->rte_dev->data->mtu + + ETHER_HDR_LEN + 4; device_info->max_mac_addrs = 1; device_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP | diff --git a/drivers/net/enic/enic_res.c b/drivers/net/enic/enic_res.c index ebe379d..e82181f 100644 --- a/drivers/net/enic/enic_res.c +++ b/drivers/net/enic/enic_res.c @@ -83,6 +83,20 @@ int enic_get_vnic_config(struct enic *enic) GET_CONFIG(intr_timer_usec); GET_CONFIG(loop_tag); GET_CONFIG(num_arfs); + GET_CONFIG(max_pkt_size); + + /* max packet size is only defined in newer VIC firmware + * and will be 0 for legacy firmware and VICs + */ + if (c->max_pkt_size > ENIC_DEFAULT_MAX_PKT_SIZE) + enic->max_mtu = c->max_pkt_size - (ETHER_HDR_LEN + 4); + else + enic->max_mtu = ENIC_DEFAULT_MAX_PKT_SIZE - (ETHER_HDR_LEN + 4); + if (c->mtu == 0) + c->mtu = 1500; + + enic->rte_dev->data->mtu = min_t(u16, enic->max_mtu, + max_t(u16, ENIC_MIN_MTU, c->mtu)); c->wq_desc_count = min_t(u32, ENIC_MAX_WQ_DESCS, @@ -96,21 +110,16 @@ int enic_get_vnic_config(struct enic *enic) c->rq_desc_count)); c->rq_desc_count &= 0xffffffe0; /* must be aligned to groups of 32 */ - if (c->mtu == 0) - c->mtu = 1500; - c->mtu = min_t(u16, ENIC_MAX_MTU, - max_t(u16, ENIC_MIN_MTU, - c->mtu)); - c->intr_timer_usec = min_t(u32, c->intr_timer_usec, vnic_dev_get_intr_coal_timer_max(enic->vdev)); dev_info(enic_get_dev(enic), "vNIC MAC addr %02x:%02x:%02x:%02x:%02x:%02x " - "wq/rq %d/%d mtu %d\n", + "wq/rq %d/%d mtu %d, max mtu:%d\n", enic->mac_addr[0], enic->mac_addr[1], enic->mac_addr[2], enic->mac_addr[3], enic->mac_addr[4], enic->mac_addr[5], - c->wq_desc_count, c->rq_desc_count, c->mtu); + c->wq_desc_count, c->rq_desc_count, + enic->rte_dev->data->mtu, enic->max_mtu); dev_info(enic_get_dev(enic), "vNIC csum tx/rx %s/%s " "rss %s intr mode %s type %s timer %d usec " "loopback tag 0x%04x\n", diff --git a/drivers/net/enic/enic_res.h b/drivers/net/enic/enic_res.h index 3c8e303..303530e 100644 --- a/drivers/net/enic/enic_res.h +++ b/drivers/net/enic/enic_res.h @@ -46,7 +46,9 @@ #define ENIC_MAX_RQ_DESCS 4096 #define ENIC_MIN_MTU 68 -#define ENIC_MAX_MTU 9000 + +/* Does not include (possible) inserted VLAN tag and FCS */ +#define ENIC_DEFAULT_MAX_PKT_SIZE 9022 #define ENIC_MULTICAST_PERFECT_FILTERS 32 #define ENIC_UNICAST_PERFECT_FILTERS 32 -- 2.7.0