From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id BD093590F for ; Thu, 17 Mar 2016 16:39:25 +0100 (CET) Received: by mail-wm0-f50.google.com with SMTP id l124so89838947wmf.1 for ; Thu, 17 Mar 2016 08:39:25 -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; bh=NbRN9k1/KwK788zkFec3Gfxq+7iOYMb8cxsBpiDLFsQ=; b=cmE97C0qFLFyLsS41WfnR2MxtqPDtX5V/ICZl/n+wq9g1qi2XHkuoPzdscBTFezDlT K2+Dg/arax1SeQb8TVxdig//QwDeKfmLGU7fING2mv4LN0le1o9W/oEFlBBt1bREU0cq Ag3Rqmpp3y29RYpb/qqgKV33vhqtArRrSODsiaq0248BQpn2Gab3wLnCEDkhlbsRSmDi 12Och5nj5ucmanS2xK/K8npaig0L0fEpv5wwd8/lMq7aa2GD8OH/pJIDHciqspje1USG EH0pyz0o7NTH0vBp9LbtJ/aiqGp+SdkE3q9SPxZP1pytfxXRbh1mwi5dj6zHCoJsQHp0 WXaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NbRN9k1/KwK788zkFec3Gfxq+7iOYMb8cxsBpiDLFsQ=; b=fzQilZBFnd2kWW9e92z+p+Z64LQmwfug03hhLqI56AwEovri4P9+ufRlsDAvn929tT Cz2vaGcKRPii0GJVvu5tU+dzRkxmj6gIkCvWG6PX1+w0MyQVYGG4XvDshoqDm4hHc7eW fwjRgy8ijbM9XhAejq4VCtWGfn7SUBLA8hakrJO5oKsqNMAvLEackAfI4KSy5Fxa/Ee8 AoVmLRT/F5QhVVvS8zW6Q51360ggEZuUHPAfTYNMOGJI9nnLU/1FQb4uzuWrYe3nkxtl guxga0pPFjidx/5cfKx8juYDwRSfAron1LevZLHkNixg7/i/hvPBREK/+qQVvAg5nfpl Wlew== X-Gm-Message-State: AD7BkJJJXhlLcw/l7mV9wTJuWsKzK298kWb3OZKFHX4djcSnVABW+QTsc0u0P/e8/UGq6vYH X-Received: by 10.28.213.66 with SMTP id m63mr38066261wmg.2.1458229165627; Thu, 17 Mar 2016 08:39:25 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id b1sm8218623wjy.0.2016.03.17.08.39.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Mar 2016 08:39:25 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Cc: Olga Shern Date: Thu, 17 Mar 2016 16:38:56 +0100 Message-Id: <1458229138-20597-4-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458229138-20597-1-git-send-email-adrien.mazarguil@6wind.com> References: <1457015279-3089-1-git-send-email-adrien.mazarguil@6wind.com> <1458229138-20597-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH v3 3/5] mlx5: add RX CRC stripping configuration 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: Thu, 17 Mar 2016 15:39:26 -0000 From: Olga Shern Until now, CRC was always stripped by hardware. This feature can be configured since MLNX_OFED >= 3.2. Signed-off-by: Olga Shern --- doc/guides/nics/mlx5.rst | 2 ++ doc/guides/rel_notes/release_16_04.rst | 6 ++++++ drivers/net/mlx5/Makefile | 5 +++++ drivers/net/mlx5/mlx5.c | 7 +++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_rxq.c | 24 ++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 6 ++++-- drivers/net/mlx5/mlx5_rxtx.h | 1 + 8 files changed, 50 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index f0d8a7e..8b63f3f 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -84,6 +84,7 @@ Features - Support for multiple MAC addresses. - VLAN filtering. - RX VLAN stripping. +- RX CRC stripping configuration. - Promiscuous mode. - Multicast promiscuous mode. - Hardware checksum offloads. @@ -232,6 +233,7 @@ Currently supported by DPDK: - Flow director. - RX VLAN stripping. + - RX CRC stripping configuration. - Minimum firmware version: diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst index ceef9b7..a498ef7 100644 --- a/doc/guides/rel_notes/release_16_04.rst +++ b/doc/guides/rel_notes/release_16_04.rst @@ -138,6 +138,12 @@ This section should contain new features added in this release. Sample format: Implemented TX support in secondary processes (like mlx4). +* **Added mlx5 RX CRC stripping configuration.** + + Until now, CRC was always stripped. It can now be configured. + + Only available with Mellanox OFED >= 3.2. + * **Added af_packet dynamic removal function.** Af_packet device can now be detached using API, like other PMD devices. diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 7076ae3..cc6de2d 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -137,6 +137,11 @@ mlx5_autoconf.h: $(RTE_SDK)/scripts/auto-config-h.sh infiniband/verbs.h \ enum IBV_EXP_CQ_RX_TCP_PACKET \ $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_VERBS_FCS \ + infiniband/verbs.h \ + enum IBV_EXP_CREATE_WQ_FLAG_SCATTER_FCS \ + $(AUTOCONF_OUTPUT) $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 998e6f0..acfb365 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -417,6 +417,13 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) DEBUG("VLAN stripping is %ssupported", (priv->hw_vlan_strip ? "" : "not ")); +#ifdef HAVE_VERBS_FCS + priv->hw_fcs_strip = !!(exp_device_attr.exp_device_cap_flags & + IBV_EXP_DEVICE_SCATTER_FCS); +#endif /* HAVE_VERBS_FCS */ + DEBUG("FCS stripping configuration is %ssupported", + (priv->hw_fcs_strip ? "" : "not ")); + #else /* HAVE_EXP_QUERY_DEVICE */ priv->ind_table_max_size = RSS_INDIRECTION_TABLE_SIZE; #endif /* HAVE_EXP_QUERY_DEVICE */ diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index bad9283..9690827 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -103,6 +103,7 @@ struct priv { unsigned int hw_csum:1; /* Checksum offload is supported. */ unsigned int hw_csum_l2tun:1; /* Same for L2 tunnels. */ unsigned int hw_vlan_strip:1; /* VLAN stripping is supported. */ + unsigned int hw_fcs_strip:1; /* FCS stripping is supported. */ unsigned int vf:1; /* This is a VF device. */ unsigned int pending_alarm:1; /* An alarm is pending. */ /* RX/TX queues. */ diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 3d84f41..19a1119 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1258,6 +1258,30 @@ rxq_setup(struct rte_eth_dev *dev, struct rxq *rxq, uint16_t desc, 0), #endif /* HAVE_EXP_DEVICE_ATTR_VLAN_OFFLOADS */ }; + +#ifdef HAVE_VERBS_FCS + /* By default, FCS (CRC) is stripped by hardware. */ + if (dev->data->dev_conf.rxmode.hw_strip_crc) { + tmpl.crc_present = 0; + } else if (priv->hw_fcs_strip) { + /* Ask HW/Verbs to leave CRC in place when supported. */ + attr.wq.flags |= IBV_EXP_CREATE_WQ_FLAG_SCATTER_FCS; + attr.wq.comp_mask |= IBV_EXP_CREATE_WQ_FLAGS; + tmpl.crc_present = 1; + } else { + WARN("%p: CRC stripping has been disabled but will still" + " be performed by hardware, make sure MLNX_OFED and" + " firmware are up to date", + (void *)dev); + tmpl.crc_present = 0; + } + DEBUG("%p: CRC stripping is %s, %u bytes will be subtracted from" + " incoming frames to hide it", + (void *)dev, + tmpl.crc_present ? "disabled" : "enabled", + tmpl.crc_present << 2); +#endif /* HAVE_VERBS_FCS */ + tmpl.wq = ibv_exp_create_wq(priv->ctx, &attr.wq); if (tmpl.wq == NULL) { ret = (errno ? errno : EINVAL); diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 4919189..34340d2 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -828,7 +828,8 @@ mlx5_rx_burst_sp(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) } if (ret == 0) break; - len = ret; + assert(ret >= (rxq->crc_present << 2)); + len = ret - (rxq->crc_present << 2); pkt_buf_len = len; /* * Replace spent segments with new ones, concatenate and @@ -1040,7 +1041,8 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) } if (ret == 0) break; - len = ret; + assert(ret >= (rxq->crc_present << 2)); + len = ret - (rxq->crc_present << 2); rep = __rte_mbuf_raw_alloc(rxq->mp); if (unlikely(rep == NULL)) { /* diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 6a0087e..61be3e4 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -116,6 +116,7 @@ struct rxq { unsigned int csum:1; /* Enable checksum offloading. */ unsigned int csum_l2tun:1; /* Same for L2 tunnels. */ unsigned int vlan_strip:1; /* Enable VLAN stripping. */ + unsigned int crc_present:1; /* CRC must be subtracted. */ union { struct rxq_elt_sp (*sp)[]; /* Scattered RX elements. */ struct rxq_elt (*no_sp)[]; /* RX elements. */ -- 2.1.4