From patchwork Mon Jul 10 23:19:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 26750 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 5E69D7CAE; Tue, 11 Jul 2017 01:20:34 +0200 (CEST) Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id C97087CEC for ; Tue, 11 Jul 2017 01:20:15 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id c11so159283151wrc.3 for ; Mon, 10 Jul 2017 16:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=NPCn59SnhmVWUxD5xbmVfZUcS+OK4XXg0o2WVTdcbpA=; b=UbICcqGS5luguodCe3mMK/lZB/6rvr4j6KOyF9FKV85ssro8s1VvoOrcgqD2RcDzPk BqBsPxa0YYwP47C+z/oYGnaiRAq0iXoyzOY+m1+7Y0099oB7uUhfxNnvkadYJob/suhf eHuozAgndFp3SRLNHyU1UkfxE+UBAAHI9TL+zSGtMQSkQW7Yatc6kHFnSdoRzngkhRJz gFWe3h2WuF3lXpMFrOIIB5PbOeXEMkWB2mSIRgdB7w9Kqu3xf9Yx78+e9rx10NrxR8/q amgAX22jO42v22+CJsgy8AMBMU7w7vvtjnEQmbcGcHiuP4RUW3fEqqBZ/b21hs+tK3Fh W3iw== 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:in-reply-to:references; bh=NPCn59SnhmVWUxD5xbmVfZUcS+OK4XXg0o2WVTdcbpA=; b=ZZToNxFqRqQykQhFG8a6l4MRy+4Nde6PbUiQ6+8VzSnBCt3BBgANdgMgzhM++4GtDO 14FwUwRJv4S7FUe0Q/i/rHM4rivJvLfwcoXJ7GRxyMAI3EWdM45MfjhN/bBTX6Mwq3Do p3TVDfcohovQQUat72P1aZ6RomBfB9kv6uOqamFrfcGq9lGYi9gkVg+YyEfcSutVwloH CdoMTxmVU1Di1YsoQHC6lCCpi1wTJ+QaQnJu5ImKlLSi5YdLlEn93t6HXP3EEL4TwX17 wXMYeUiQqJhL/PCwY26NN9ByHs+GgenOviwklZpF7t9LocDPjKC+M/M14RegGSIjJVJ8 PwkA== X-Gm-Message-State: AIVw113zrtavnOt4muujBpPJ3dR0DGCfaUmftCTcal1PNLxU59DHm8vY XmTMDI3o7dHesBWo5bk= X-Received: by 10.28.133.76 with SMTP id h73mr9149296wmd.92.1499728815180; Mon, 10 Jul 2017 16:20:15 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id k137sm11805038wmd.22.2017.07.10.16.20.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jul 2017 16:20:14 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 11 Jul 2017 01:19:48 +0200 Message-Id: <9383f7932233304e05077c58507a71577453698e.1499728587.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v8 07/11] net/failsafe: support offload capabilities 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Gaetan Rivet Acked-by: Olga Shern --- doc/guides/nics/features/failsafe.ini | 6 ++ drivers/net/failsafe/failsafe_ops.c | 131 +++++++++++++++++++++++++++++++++- 2 files changed, 135 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features/failsafe.ini b/doc/guides/nics/features/failsafe.ini index 9167b59..257f579 100644 --- a/doc/guides/nics/features/failsafe.ini +++ b/doc/guides/nics/features/failsafe.ini @@ -14,6 +14,12 @@ Unicast MAC filter = Y Multicast MAC filter = Y VLAN filter = Y Flow API = Y +VLAN offload = Y +QinQ offload = Y +L3 checksum offload = Y +L4 checksum offload = Y +Inner L3 checksum = Y +Inner L4 checksum = Y Packet type parsing = Y Basic stats = Y Stats per queue = Y diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 4cb2e90..5fb0135 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -63,22 +63,149 @@ static struct rte_eth_dev_info default_infos = { .nb_seg_max = UINT16_MAX, .nb_mtu_seg_max = UINT16_MAX, }, - /* Set of understood capabilities */ - .rx_offload_capa = 0x0, + /* + * Set of capabilities that can be verified upon + * configuring a sub-device. + */ + .rx_offload_capa = + DEV_RX_OFFLOAD_VLAN_STRIP | + DEV_RX_OFFLOAD_QINQ_STRIP | + DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM | + DEV_RX_OFFLOAD_TCP_LRO, .tx_offload_capa = 0x0, .flow_type_rss_offloads = 0x0, }; +/** + * Check whether a specific offloading capability + * is supported by a sub_device. + * + * @return + * 0: all requested capabilities are supported by the sub_device + * positive value: This flag at least is not supported by the sub_device + */ +static int +fs_port_offload_validate(struct rte_eth_dev *dev, + struct sub_device *sdev) +{ + struct rte_eth_dev_info infos = {0}; + struct rte_eth_conf *cf; + uint32_t cap; + + cf = &dev->data->dev_conf; + SUBOPS(sdev, dev_infos_get)(ETH(sdev), &infos); + /* RX capabilities */ + cap = infos.rx_offload_capa; + if (cf->rxmode.hw_vlan_strip && + ((cap & DEV_RX_OFFLOAD_VLAN_STRIP) == 0)) { + WARN("VLAN stripping offload requested but not supported by sub_device %d", + SUB_ID(sdev)); + return DEV_RX_OFFLOAD_VLAN_STRIP; + } + if (cf->rxmode.hw_ip_checksum && + ((cap & (DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM)) != + (DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM))) { + WARN("IP checksum offload requested but not supported by sub_device %d", + SUB_ID(sdev)); + return DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM; + } + if (cf->rxmode.enable_lro && + ((cap & DEV_RX_OFFLOAD_TCP_LRO) == 0)) { + WARN("TCP LRO offload requested but not supported by sub_device %d", + SUB_ID(sdev)); + return DEV_RX_OFFLOAD_TCP_LRO; + } + if (cf->rxmode.hw_vlan_extend && + ((cap & DEV_RX_OFFLOAD_QINQ_STRIP) == 0)) { + WARN("Stacked VLAN stripping offload requested but not supported by sub_device %d", + SUB_ID(sdev)); + return DEV_RX_OFFLOAD_QINQ_STRIP; + } + /* TX capabilities */ + /* Nothing to do, no tx capa supported */ + return 0; +} + +/* + * Disable the dev_conf flag related to an offload capability flag + * within an ethdev configuration. + */ +static int +fs_port_disable_offload(struct rte_eth_conf *cf, + uint32_t ol_cap) +{ + switch (ol_cap) { + case DEV_RX_OFFLOAD_VLAN_STRIP: + INFO("Disabling VLAN stripping offload"); + cf->rxmode.hw_vlan_strip = 0; + break; + case DEV_RX_OFFLOAD_IPV4_CKSUM: + case DEV_RX_OFFLOAD_UDP_CKSUM: + case DEV_RX_OFFLOAD_TCP_CKSUM: + case (DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM): + INFO("Disabling IP checksum offload"); + cf->rxmode.hw_ip_checksum = 0; + break; + case DEV_RX_OFFLOAD_TCP_LRO: + INFO("Disabling TCP LRO offload"); + cf->rxmode.enable_lro = 0; + break; + case DEV_RX_OFFLOAD_QINQ_STRIP: + INFO("Disabling stacked VLAN stripping offload"); + cf->rxmode.hw_vlan_extend = 0; + break; + default: + DEBUG("Unable to disable offload capability: %" PRIx32, + ol_cap); + return -1; + } + return 0; +} + static int fs_dev_configure(struct rte_eth_dev *dev) { struct sub_device *sdev; uint8_t i; + int capa_flag; int ret; FOREACH_SUBDEV(sdev, i, dev) { if (sdev->state != DEV_PROBED) continue; + DEBUG("Checking capabilities for sub_device %d", i); + while ((capa_flag = fs_port_offload_validate(dev, sdev))) { + /* + * Refuse to change configuration if multiple devices + * are present and we already have configured at least + * some of them. + */ + if (PRIV(dev)->state >= DEV_ACTIVE && + PRIV(dev)->subs_tail > 1) { + ERROR("device already configured, cannot fix live configuration"); + return -1; + } + ret = fs_port_disable_offload(&dev->data->dev_conf, + capa_flag); + if (ret) { + ERROR("Unable to disable offload capability"); + return ret; + } + } + } + FOREACH_SUBDEV(sdev, i, dev) { + if (sdev->state != DEV_PROBED) + continue; DEBUG("Configuring sub-device %d", i); ret = rte_eth_dev_configure(PORT_ID(sdev), dev->data->nb_rx_queues,