From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F251FA0524 for ; Mon, 31 May 2021 10:42:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE5FB40040; Mon, 31 May 2021 10:42:09 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 4C09840040 for ; Mon, 31 May 2021 10:42:08 +0200 (CEST) Received: from mail-qv1-f71.google.com ([209.85.219.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lndUu-0002NE-2z for stable@dpdk.org; Mon, 31 May 2021 08:42:08 +0000 Received: by mail-qv1-f71.google.com with SMTP id w4-20020a0c8e440000b02901f0640ffdafso8494122qvb.13 for ; Mon, 31 May 2021 01:42:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ChPOYyqaaSUQn1V+GfviDMv8b8xkjDmkWp0z3VrZSn8=; b=pX6H4f4DArRuXWFX+3JZXSmP+kxhmEnsA05TcG8FLlL0ytQW29PF52wJarK7kBvHq9 UeB/z/ztF4wThG6MF7m0ZleN3WY424qkB4kkfezetY0I1ZL6/FyLAgecs1+8oZTvOh4G XHpgx2We4CuK2VVmdKBl7N10gmUsQ7xQucuYvMVWU7t4Wcm9gNKwDis7AeP6UR5i8ign VpSH0utYPbi5JKygmlKBy7tgP38rDScJsiPe7QipHREuyYO0dwIMNRuvBtFHZqnosKDv 02YfEgnEHNAwN792DKI/pnQ8S7UbCZ6EyM0g9W+LkuQKP8Jp00ZfGQoGZtO/7fw05lPY 6/9g== X-Gm-Message-State: AOAM532Jbwe86SCJuOsbe//aWDetGHtsHgdOwPYj3tvcZ9K9ETimCrj/ 213dICxpcDZ9uOTr1mMm7v7IQRORJApgCt/dBQwSJFrNNOOgzaXqlUPUj6uI/8zYIaoZAvfAAg6 0wvtQty9juB9cIgSvgBzf/euO4PanoliR28YDQAf/ X-Received: by 2002:ae9:c016:: with SMTP id u22mr15546202qkk.114.1622450527238; Mon, 31 May 2021 01:42:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZUYlCnmIjEVmfGXn0lGaovxiHAwczC2usqxjTpmwmf2mCbtVuH5JHtRn756AHIe5Zr357A30Rhgk5Hl/CHzs= X-Received: by 2002:ae9:c016:: with SMTP id u22mr15546192qkk.114.1622450526993; Mon, 31 May 2021 01:42:06 -0700 (PDT) MIME-Version: 1.0 References: <1621666044-39902-1-git-send-email-humin29@huawei.com> In-Reply-To: <1621666044-39902-1-git-send-email-humin29@huawei.com> From: Christian Ehrhardt Date: Mon, 31 May 2021 10:41:41 +0200 Message-ID: To: "Min Hu (Connor)" Cc: dpdk stable Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Sat, May 22, 2021 at 8:47 AM Min Hu (Connor) wrote: > > From: Chengchang Tang > > [ upstream commit 25fb790f7868f8eee96f7f051a834dec01b8a369 ] Thank you for the backports, queued patches 1-3 for 19.11.9 now > After MTU changed, the buffer used to store packets in HW should be > reallocated. And buffer size is allocated based on the maximum frame > size in the PF struct. However, the value of maximum frame size is > not updated in time when MTU is changed. This would lead to a packet > loss for not enough buffer. > > This patch update the maximum frame size before reallocating the HW > buffer. And a rollback operation is added to avoid the side effects > of buffer reallocation failures. > > Fixes: 1f5ca0b460cd ("net/hns3: support some device operations") > Fixes: d51867db65c1 ("net/hns3: add initialization") > Cc: stable@dpdk.org > > Signed-off-by: Chengchang Tang > Signed-off-by: Lijun Ou > --- > drivers/net/hns3/hns3_ethdev.c | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c > index 3a799ed..952538d 100644 > --- a/drivers/net/hns3/hns3_ethdev.c > +++ b/drivers/net/hns3/hns3_ethdev.c > @@ -2418,21 +2418,35 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps) > static int > hns3_config_mtu(struct hns3_hw *hw, uint16_t mps) > { > + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); > + uint16_t original_mps = hns->pf.mps; > + int err; > int ret; > > ret = hns3_set_mac_mtu(hw, mps); > if (ret) { > - hns3_err(hw, "Failed to set mtu, ret = %d", ret); > + hns3_err(hw, "failed to set mtu, ret = %d", ret); > return ret; > } > > + hns->pf.mps = mps; > ret = hns3_buffer_alloc(hw); > if (ret) { > - hns3_err(hw, "Failed to allocate buffer, ret = %d", ret); > - return ret; > + hns3_err(hw, "failed to allocate buffer, ret = %d", ret); > + goto rollback; > } > > return 0; > + > +rollback: > + err = hns3_set_mac_mtu(hw, original_mps); > + if (err) { > + hns3_err(hw, "fail to rollback MTU, err = %d", err); > + return ret; > + } > + hns->pf.mps = original_mps; > + > + return ret; > } > > static int > @@ -2465,7 +2479,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > dev->data->port_id, mtu, ret); > return ret; > } > - hns->pf.mps = (uint16_t)frame_size; > + > if (is_jumbo_frame) > dev->data->dev_conf.rxmode.offloads |= > DEV_RX_OFFLOAD_JUMBO_FRAME; > -- > 2.7.4 > -- Christian Ehrhardt Staff Engineer, Ubuntu Server Canonical Ltd