From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo02.seg.att.com (nbfkord-smmo02.seg.att.com [209.65.160.78]) by dpdk.org (Postfix) with ESMTP id E916DFA4C for ; Fri, 2 Dec 2016 08:45:26 +0100 (CET) Received: from unknown [12.187.104.26] (EHLO nbfkord-smmo02.seg.att.com) by nbfkord-smmo02.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id 79621485.2b081985b940.106171.00-2464.246025.nbfkord-smmo02.seg.att.com (envelope-from ); Fri, 02 Dec 2016 07:45:27 +0000 (UTC) X-MXL-Hash: 5841269760cce8a4-584f02c8d6a38480f9b1f924f7023acdf7f76d16 Received: from unknown [12.187.104.26] by nbfkord-smmo02.seg.att.com(mxl_mta-7.2.4-7) with SMTP id 49621485.0.106140.00-2380.246012.nbfkord-smmo02.seg.att.com (envelope-from ); Fri, 02 Dec 2016 07:45:25 +0000 (UTC) X-MXL-Hash: 584126954691203b-842d893748ca986a917f26d9a8b9ed4f25d627a2 Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Thu, 1 Dec 2016 23:45:02 -0800 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Thu, 1 Dec 2016 23:45:02 -0800 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uB27j1px005923; Fri, 2 Dec 2016 07:45:01 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uB27ixx2026628; Fri, 2 Dec 2016 07:45:01 GMT From: Andrew Rybchenko To: CC: Ivan Malov Date: Fri, 2 Dec 2016 07:44:45 +0000 Message-ID: <1480664691-26561-26-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1480664691-26561-1-git-send-email-arybchenko@solarflare.com> References: <1480664691-26561-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-AnalysisOut: [v=2.1 cv=NIXTjhOg c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=n5n_aSjo0skA:10 a=pK7X0mNQAAAA:8 a=zRKbQ67AAAAA:8 a=] X-AnalysisOut: [mB4y2rj18qse6KXDo2YA:9 a=5HA-qpC1VU4iIGLgRoNS:22 a=PA03WX8] X-AnalysisOut: [tBzeizutn5_OT:22] X-Spam: [F=0.4713508026; CM=0.500; S=0.471(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH 25/31] net/sfc: add basic stubs for RSS support on driver attach 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: Fri, 02 Dec 2016 07:45:27 -0000 From: Ivan Malov Reviewed-by: Andrew Lee Reviewed-by: Robert Stonehouse Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- doc/guides/nics/sfc_efx.rst | 2 ++ drivers/net/sfc/efsys.h | 2 +- drivers/net/sfc/sfc.c | 76 +++++++++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc.h | 17 ++++++++++ drivers/net/sfc/sfc_ethdev.c | 8 +++++ drivers/net/sfc/sfc_rx.c | 81 +++++++++++++++++++++++++++++++++++++++++++- drivers/net/sfc/sfc_rx.h | 8 +++++ 7 files changed, 192 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index ee2ba27..4f674c0 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -66,6 +66,8 @@ SFC EFX PMD has support for: - Received packet type information +- Receive side scaling (RSS) + - Scattered Rx DMA for packet that are larger that a single Rx descriptor - Deferred receive and transmit queue start diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h index 0f941e6..fb2f3b5 100644 --- a/drivers/net/sfc/efsys.h +++ b/drivers/net/sfc/efsys.h @@ -195,7 +195,7 @@ prefetch_read_once(const volatile void *addr) #define EFSYS_OPT_BOOTCFG 0 #define EFSYS_OPT_DIAG 0 -#define EFSYS_OPT_RX_SCALE 0 +#define EFSYS_OPT_RX_SCALE 1 #define EFSYS_OPT_QSTATS 0 /* Filters support is required for SFN7xxx and SFN8xx */ #define EFSYS_OPT_FILTER 1 diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index e2e6c9e..e79367d 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -484,6 +484,73 @@ sfc_mem_bar_fini(struct sfc_adapter *sa) memset(ebp, 0, sizeof(*ebp)); } +#if EFSYS_OPT_RX_SCALE +/* + * A fixed RSS key which has a property of being symmetric + * (symmetrical flows are distributed to the same CPU) + * and also known to give a uniform distribution + * (a good distribution of traffic between different CPUs) + */ +static const uint8_t default_rss_key[SFC_RSS_KEY_SIZE] = { + 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, + 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, + 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, + 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, + 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, +}; +#endif + +static int +sfc_set_rss_defaults(struct sfc_adapter *sa) +{ +#if EFSYS_OPT_RX_SCALE + int rc; + + rc = efx_intr_init(sa->nic, sa->intr.type, NULL); + if (rc != 0) + goto fail_intr_init; + + rc = efx_ev_init(sa->nic); + if (rc != 0) + goto fail_ev_init; + + rc = efx_rx_init(sa->nic); + if (rc != 0) + goto fail_rx_init; + + rc = efx_rx_scale_support_get(sa->nic, &sa->rss_support); + if (rc != 0) + goto fail_scale_support_get; + + rc = efx_rx_hash_support_get(sa->nic, &sa->hash_support); + if (rc != 0) + goto fail_hash_support_get; + + efx_rx_fini(sa->nic); + efx_ev_fini(sa->nic); + efx_intr_fini(sa->nic); + + sa->rss_hash_types = sfc_rte_to_efx_hash_type(SFC_RSS_OFFLOADS); + + rte_memcpy(sa->rss_key, default_rss_key, sizeof(sa->rss_key)); + + return 0; + +fail_hash_support_get: +fail_scale_support_get: +fail_rx_init: + efx_ev_fini(sa->nic); + +fail_ev_init: + efx_intr_fini(sa->nic); + +fail_intr_init: + return rc; +#else + return 0; +#endif +} + int sfc_attach(struct sfc_adapter *sa) { @@ -550,6 +617,10 @@ sfc_attach(struct sfc_adapter *sa) efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_PERM, &sa->port.phy_adv_cap_mask); + rc = sfc_set_rss_defaults(sa); + if (rc != 0) + goto fail_set_rss_defaults; + sfc_log_init(sa, "fini nic"); efx_nic_fini(enp); @@ -558,7 +629,12 @@ sfc_attach(struct sfc_adapter *sa) sfc_log_init(sa, "done"); return 0; +fail_set_rss_defaults: + sfc_intr_detach(sa); + fail_intr_attach: + efx_nic_fini(sa->nic); + fail_estimate_rsrc_limits: fail_nic_reset: sfc_log_init(sa, "unprobe nic"); diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index f0bbaf8..01dbfb6 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -42,6 +42,13 @@ extern "C" { #endif +#if EFSYS_OPT_RX_SCALE +/** RSS key length (bytes) */ +#define SFC_RSS_KEY_SIZE 40 +/** RSS hash offloads mask */ +#define SFC_RSS_OFFLOADS (ETH_RSS_IP | ETH_RSS_TCP) +#endif + /* * +---------------+ * | UNINITIALIZED |<-----------+ @@ -187,6 +194,16 @@ struct sfc_adapter { unsigned int txq_count; struct sfc_txq_info *txq_info; + + unsigned int rss_channels; + +#if EFSYS_OPT_RX_SCALE + efx_rx_scale_support_t rss_support; + efx_rx_hash_support_t hash_support; + unsigned int rss_hash_types; + unsigned int rss_tbl[EFX_RSS_TBL_SIZE]; + uint8_t rss_key[SFC_RSS_KEY_SIZE]; +#endif }; /* diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 0de17ca..b17607f 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -85,6 +85,14 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) else dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_VLAN_INSERT; +#if EFSYS_OPT_RX_SCALE + if (sa->rss_support != EFX_RX_SCALE_UNAVAILABLE) { + dev_info->reta_size = EFX_RSS_TBL_SIZE; + dev_info->hash_key_size = SFC_RSS_KEY_SIZE; + dev_info->flow_type_rss_offloads = SFC_RSS_OFFLOADS; + } +#endif + dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS; dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS; /* The RXQ hardware requires that the descriptor count is a power diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 3bfce1c..f0fe1b8 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -411,7 +411,8 @@ sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index) if (sw_index == 0) { rc = efx_mac_filter_default_rxq_set(sa->nic, rxq->common, - B_FALSE); + (sa->rss_channels > 1) ? + B_TRUE : B_FALSE); if (rc != 0) goto fail_mac_filter_default_rxq_set; } @@ -683,6 +684,11 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index, rxq->batch_max = encp->enc_rx_batch_max; rxq->prefix_size = encp->enc_rx_prefix_size; +#if EFSYS_OPT_RX_SCALE + if (sa->hash_support == EFX_RX_HASH_AVAILABLE) + rxq->flags |= SFC_RXQ_RSS_HASH; +#endif + rxq->state = SFC_RXQ_INITIALIZED; rxq_info->rxq = rxq; @@ -728,6 +734,56 @@ sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index) rte_free(rxq); } +#if EFSYS_OPT_RX_SCALE +unsigned int +sfc_rte_to_efx_hash_type(uint64_t rss_hf) +{ + unsigned int efx_hash_types = 0; + + if ((rss_hf & (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | + ETH_RSS_NONFRAG_IPV4_OTHER)) != 0) + efx_hash_types |= (1 << EFX_RX_HASH_IPV4); + + if ((rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) != 0) + efx_hash_types |= (1 << EFX_RX_HASH_TCPIPV4); + + if ((rss_hf & (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | + ETH_RSS_NONFRAG_IPV6_OTHER | ETH_RSS_IPV6_EX)) != 0) + efx_hash_types |= (1 << EFX_RX_HASH_IPV6); + + if ((rss_hf & (ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_IPV6_TCP_EX)) != 0) + efx_hash_types |= (1 << EFX_RX_HASH_TCPIPV6); + + return efx_hash_types; +} +#endif + +static int +sfc_rx_rss_config(struct sfc_adapter *sa) +{ + int rc = 0; + +#if EFSYS_OPT_RX_SCALE + if (sa->rss_channels > 1) { + rc = efx_rx_scale_mode_set(sa->nic, EFX_RX_HASHALG_TOEPLITZ, + sa->rss_hash_types, B_TRUE); + if (rc != 0) + goto finish; + + rc = efx_rx_scale_key_set(sa->nic, sa->rss_key, + sizeof(sa->rss_key)); + if (rc != 0) + goto finish; + + rc = efx_rx_scale_tbl_set(sa->nic, sa->rss_tbl, + sizeof(sa->rss_tbl)); + } + +finish: +#endif + return rc; +} + int sfc_rx_start(struct sfc_adapter *sa) { @@ -740,6 +796,10 @@ sfc_rx_start(struct sfc_adapter *sa) if (rc != 0) goto fail_rx_init; + rc = sfc_rx_rss_config(sa); + if (rc != 0) + goto fail_rss_config; + for (sw_index = 0; sw_index < sa->rxq_count; ++sw_index) { if ((!sa->rxq_info[sw_index].deferred_start || sa->rxq_info[sw_index].deferred_started)) { @@ -755,6 +815,7 @@ sfc_rx_start(struct sfc_adapter *sa) while (sw_index-- > 0) sfc_rx_qstop(sa, sw_index); +fail_rss_config: efx_rx_fini(sa->nic); fail_rx_init: @@ -801,6 +862,14 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode) case ETH_MQ_RX_NONE: /* No special checks are required */ break; +#if EFSYS_OPT_RX_SCALE + case ETH_MQ_RX_RSS: + if (sa->rss_support == EFX_RX_SCALE_UNAVAILABLE) { + sfc_err(sa, "RSS is not available"); + rc = EINVAL; + } + break; +#endif default: sfc_err(sa, "Rx multi-queue mode %u not supported", rxmode->mq_mode); @@ -876,6 +945,16 @@ sfc_rx_init(struct sfc_adapter *sa) goto fail_rx_qinit_info; } +#if EFSYS_OPT_RX_SCALE + sa->rss_channels = (dev_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) ? + MIN(sa->rxq_count, EFX_MAXRSS) : 1; + + if (sa->rss_channels > 1) { + for (sw_index = 0; sw_index < EFX_RSS_TBL_SIZE; ++sw_index) + sa->rss_tbl[sw_index] = sw_index % sa->rss_channels; + } +#endif + return 0; fail_rx_qinit_info: diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h index 4aa6aea..2b8b9eb 100644 --- a/drivers/net/sfc/sfc_rx.h +++ b/drivers/net/sfc/sfc_rx.h @@ -83,6 +83,10 @@ struct sfc_rxq { unsigned int completed; uint16_t batch_max; uint16_t prefix_size; +#if EFSYS_OPT_RX_SCALE + unsigned int flags; +#define SFC_RXQ_RSS_HASH 0x1 +#endif /* Used on refill */ unsigned int added; @@ -146,6 +150,10 @@ unsigned int sfc_rx_qdesc_npending(struct sfc_adapter *sa, unsigned int sw_index); int sfc_rx_qdesc_done(struct sfc_rxq *rxq, unsigned int offset); +#if EFSYS_OPT_RX_SCALE +unsigned int sfc_rte_to_efx_hash_type(uint64_t rss_hf); +#endif + #ifdef __cplusplus } #endif -- 2.5.5