From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id CF6E2A05D3 for ; Tue, 23 Apr 2019 10:15:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7BC3A1B4CC; Tue, 23 Apr 2019 10:15:17 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id C90271B2AF; Tue, 23 Apr 2019 10:15:15 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us2.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id B6F3980087; Tue, 23 Apr 2019 08:15:14 +0000 (UTC) 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.1395.4; Tue, 23 Apr 2019 01:15:11 -0700 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.1395.4 via Frontend Transport; Tue, 23 Apr 2019 01:15:11 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x3N8FAbs025177; Tue, 23 Apr 2019 09:15:10 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 3283616161B; Tue, 23 Apr 2019 09:15:10 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov , Date: Tue, 23 Apr 2019 09:14:30 +0100 Message-ID: <1556007270-1511-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24568.005 X-TM-AS-Result: No-0.512500-4.000000-10 X-TMASE-MatchedRID: 9WYT2qPyU1Y2jeY+Udg/Ip7tR0mnRAg1gRykyfrH1xlMOjKUxCZwr6yq cSRToWuMDek5ZqMJFKK2mqhT200n/l2V546KEHXI4RtSDjG+z7BflOpBqBHTtxjQD3m2MCf7cHj giTON9jJOFu8ssjxG89C4I7fLwdY3pLAJQwwwMJp1e7Xbb6Im2lgy2ozNthE2wj525Dceuw9lKA +SSxl8wJ6IJVp/ZN67qiMcz9Yi4r2NBnVioBmwYQBYUD3h/NH/B6j1YlbvPTmbKItl61J/yZ+in TK0bC9eKrauXd3MZDVtw/8LaQiEDJTBz+sKKkCka110LsBKIutUp5WErF7USRa/LfITnaJW8g0X Qmsd8NHaH5tWfimiL8hf7Eu/XMygsGrVYmGkA+AQRuntbv102jigZBQJvBjlD6DuZ3COjrnoW0N kKZgEnVjylogJTbSO73QlCBbmrKs= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-0.512500-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24568.005 X-MDID: 1556007315-Y_1GxaqibO-8 Subject: [dpdk-dev] [PATCH] net/sfc: fix MTU change to check Rx scatter consistency 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" Message-ID: <20190423081430.0l4VQXA9ev_FH4JkZn9K9DG_28iD8Rl5z4F2sC3SdjU@z> From: Igor Romanov Rx queue setup function checks configured MTU to make sure that no oversized packets can be received. But a following call to set MTU function might make this check irrelevant. Add a function to check MTU size against Rx buffer size and additional Rx queue info, including Rx scatter offload. Fixes: e961cf425e02 ("net/sfc: support MTU change") Cc: stable@dpdk.org Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_ethdev.c | 34 ++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc_rx.c | 22 ++++++++++++++++++---- drivers/net/sfc/sfc_rx.h | 4 ++++ 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index ff192314d..a007d4564 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -865,6 +865,34 @@ sfc_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) return -rc; } +static int +sfc_check_scatter_on_all_rx_queues(struct sfc_adapter *sa, size_t pdu) +{ + struct sfc_adapter_shared * const sas = sfc_sa2shared(sa); + const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); + boolean_t scatter_enabled; + const char *error; + unsigned int i; + + for (i = 0; i < sas->rxq_count; i++) { + if ((sas->rxq_info[i].state & SFC_RXQ_INITIALIZED) == 0) + continue; + + scatter_enabled = (sas->rxq_info[i].type_flags & + EFX_RXQ_FLAG_SCATTER); + + if (!sfc_rx_check_scatter(pdu, sa->rxq_ctrl[i].buf_size, + encp->enc_rx_prefix_size, + scatter_enabled, &error)) { + sfc_err(sa, "MTU check for RxQ %u failed: %s", i, + error); + return EINVAL; + } + } + + return 0; +} + static int sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) { @@ -891,6 +919,10 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) sfc_adapter_lock(sa); + rc = sfc_check_scatter_on_all_rx_queues(sa, pdu); + if (rc != 0) + goto fail_check_scatter; + if (pdu != sa->port.pdu) { if (sa->state == SFC_ADAPTER_STARTED) { sfc_stop(sa); @@ -927,6 +959,8 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) sfc_err(sa, "cannot start with neither new (%u) nor old (%u) " "PDU max size - port is stopped", (unsigned int)pdu, (unsigned int)old_pdu); + +fail_check_scatter: sfc_adapter_unlock(sa); fail_inval: diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 5d8c2765c..f2221119c 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -360,6 +360,18 @@ sfc_efx_rx_qdesc_status(struct sfc_dp_rxq *dp_rxq, uint16_t offset) return RTE_ETH_RX_DESC_UNAVAIL; } +boolean_t +sfc_rx_check_scatter(size_t pdu, size_t rx_buf_size, uint32_t rx_prefix_size, + boolean_t rx_scatter_enabled, const char **error) +{ + if ((rx_buf_size < pdu + rx_prefix_size) && !rx_scatter_enabled) { + *error = "Rx scatter is disabled and RxQ mbuf pool object size is too small"; + return B_FALSE; + } + + return B_TRUE; +} + /** Get Rx datapath ops by the datapath RxQ handle */ const struct sfc_dp_rx * sfc_dp_rx_by_dp_rxq(const struct sfc_dp_rxq *dp_rxq) @@ -975,6 +987,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index, struct sfc_dp_rx_qcreate_info info; struct sfc_dp_rx_hw_limits hw_limits; uint16_t rx_free_thresh; + const char *error; memset(&hw_limits, 0, sizeof(hw_limits)); hw_limits.rxq_max_entries = sa->rxq_max_entries; @@ -1005,10 +1018,11 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index, goto fail_bad_conf; } - if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) && - (~offloads & DEV_RX_OFFLOAD_SCATTER)) { - sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool " - "object size is too small", sw_index); + if (!sfc_rx_check_scatter(sa->port.pdu, buf_size, + encp->enc_rx_prefix_size, + (offloads & DEV_RX_OFFLOAD_SCATTER), + &error)) { + sfc_err(sa, "RxQ %u MTU check failed: %s", sw_index, error); sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs " "PDU size %u plus Rx prefix %u bytes", sw_index, buf_size, (unsigned int)sa->port.pdu, diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h index ee1402022..aca0925b5 100644 --- a/drivers/net/sfc/sfc_rx.h +++ b/drivers/net/sfc/sfc_rx.h @@ -142,6 +142,10 @@ void sfc_rx_hash_fini(struct sfc_adapter *sa); int sfc_rx_hf_rte_to_efx(struct sfc_adapter *sa, uint64_t rte, efx_rx_hash_type_t *efx); uint64_t sfc_rx_hf_efx_to_rte(struct sfc_rss *rss, efx_rx_hash_type_t efx); +boolean_t sfc_rx_check_scatter(size_t pdu, size_t rx_buf_size, + uint32_t rx_prefix_size, + boolean_t rx_scatter_enabled, + const char **error); #ifdef __cplusplus } -- 2.17.1