Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp114933ybg; Sun, 31 May 2020 18:44:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2TJjyXei5uOCCzDOzaURIYCgN1m0CY56InYPjoXqNzw9maHKyhpHPqVbppCNuuoRjhLDc X-Received: by 2002:aa7:d1c6:: with SMTP id g6mr19626305edp.303.1590975882631; Sun, 31 May 2020 18:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590975882; cv=none; d=google.com; s=arc-20160816; b=mNJyzHdBl+VFv05t82y6tPQZTiA+PerJGJijetal5JJOmcoLLEC0ZwEfCLCHdY/7JT QKEUn8UCEIxlvMotWjVzn1c1pbow4NAnB27+6ct3VfHz/mbXhVqNglfSPeRPINJc//Fb akwezVrlnoH3Gk8lPnuj2yLzPPBv0kp9TwsRJywmGFqwvanCDjlLWphBBlfhx+sOBKQ0 x/tibuVs06UiiNIv9iUB8DTV36dAfFrxucyOf6tk80H/JB0efR9WK7vg8s3KAAkf//kV Ifwt1G7R3ZNG8JNOHDXP4tsvuN9R4Uj4k5M5C6okGFpY1Z38YA5NZDAFnrHPCYcaUuKr PDng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=A+B3V9rydWyy3Z2HLzHB3M6niG7pP/PFLbmbW5Iv9GU=; b=nWN0cG1U9B/s6ekigDn5ZUwCXpt0v1XuY/v4D05Qg1O/DKGu6qObL7MCgqufDmlgvr 3fpyhHH+m3aQn5I+h+zLIQCUJG8EpLOGwpyDKf2fbDNBtk3uXVO9QGDg09nV5DuqViSn UPf1tj5kTtqAqgSmZvEDEYbZBQpHvF08iheqo5OjnnYf0RgfrPwN577Bk8Ne1WJPFBRA HeGG8DLpuwbMxBe2MHwHumI2w1iu4T35WTiZwKasIOEPl9kFXzZL+e62IHxnMPe+E53m unM5118zBknVgZGsqbbrp4NrqhSLNe+gRt7nbCdZkns/V6upZrqsD+dL11fIzOlQKH8S tGxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si4589950edr.130.2020.05.31.18.44.19; Sun, 31 May 2020 18:44:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgFABm3 (ORCPT + 99 others); Sun, 31 May 2020 21:42:29 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51878 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726555AbgFABm3 (ORCPT ); Sun, 31 May 2020 21:42:29 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id BD284578D53846DD7C27; Mon, 1 Jun 2020 09:42:26 +0800 (CST) Received: from localhost.localdomain (10.175.118.36) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Mon, 1 Jun 2020 09:42:18 +0800 From: Luo bin To: CC: , , , , , Subject: [PATCH net-next v4] hinic: add set_channels ethtool_ops support Date: Mon, 1 Jun 2020 09:42:06 +0000 Message-ID: <20200601094206.20785-1-luobin9@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.118.36] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org add support to change TX/RX queue number with ethtool -L ethx combined Signed-off-by: Luo bin --- .../net/ethernet/huawei/hinic/hinic_ethtool.c | 40 +++++++++++++++---- .../net/ethernet/huawei/hinic/hinic_main.c | 2 +- drivers/net/ethernet/huawei/hinic/hinic_tx.c | 5 +++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c index ace18d258049..efb02e03e7da 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c @@ -619,14 +619,37 @@ static void hinic_get_channels(struct net_device *netdev, struct hinic_dev *nic_dev = netdev_priv(netdev); struct hinic_hwdev *hwdev = nic_dev->hwdev; - channels->max_rx = hwdev->nic_cap.max_qps; - channels->max_tx = hwdev->nic_cap.max_qps; - channels->max_other = 0; - channels->max_combined = 0; - channels->rx_count = hinic_hwdev_num_qps(hwdev); - channels->tx_count = hinic_hwdev_num_qps(hwdev); - channels->other_count = 0; - channels->combined_count = 0; + channels->max_combined = nic_dev->max_qps; + channels->combined_count = hinic_hwdev_num_qps(hwdev); +} + +static int hinic_set_channels(struct net_device *netdev, + struct ethtool_channels *channels) +{ + struct hinic_dev *nic_dev = netdev_priv(netdev); + unsigned int count = channels->combined_count; + int err; + + netif_info(nic_dev, drv, netdev, "Set max combined queue number from %d to %d\n", + hinic_hwdev_num_qps(nic_dev->hwdev), count); + + if (netif_running(netdev)) { + netif_info(nic_dev, drv, netdev, "Restarting netdev\n"); + hinic_close(netdev); + + nic_dev->hwdev->nic_cap.num_qps = count; + + err = hinic_open(netdev); + if (err) { + netif_err(nic_dev, drv, netdev, + "Failed to open netdev\n"); + return -EFAULT; + } + } else { + nic_dev->hwdev->nic_cap.num_qps = count; + } + + return 0; } static int hinic_get_rss_hash_opts(struct hinic_dev *nic_dev, @@ -1219,6 +1242,7 @@ static const struct ethtool_ops hinic_ethtool_ops = { .get_ringparam = hinic_get_ringparam, .set_ringparam = hinic_set_ringparam, .get_channels = hinic_get_channels, + .set_channels = hinic_set_channels, .get_rxnfc = hinic_get_rxnfc, .set_rxnfc = hinic_set_rxnfc, .get_rxfh_key_size = hinic_get_rxfh_key_size, diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c index c8ab129a7ae8..e9e6f4c9309a 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c @@ -326,7 +326,6 @@ static void hinic_enable_rss(struct hinic_dev *nic_dev) int i, node, err = 0; u16 num_cpus = 0; - nic_dev->max_qps = hinic_hwdev_max_num_qps(hwdev); if (nic_dev->max_qps <= 1) { nic_dev->flags &= ~HINIC_RSS_ENABLE; nic_dev->rss_limit = nic_dev->max_qps; @@ -1031,6 +1030,7 @@ static int nic_dev_init(struct pci_dev *pdev) nic_dev->rq_depth = HINIC_RQ_DEPTH; nic_dev->sriov_info.hwdev = hwdev; nic_dev->sriov_info.pdev = pdev; + nic_dev->max_qps = num_qps; sema_init(&nic_dev->mgmt_lock, 1); diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.c b/drivers/net/ethernet/huawei/hinic/hinic_tx.c index 4c66a0bc1b28..6da761d7a6ef 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_tx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.c @@ -470,6 +470,11 @@ netdev_tx_t hinic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) struct hinic_txq *txq; struct hinic_qp *qp; + if (unlikely(!netif_carrier_ok(netdev))) { + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } + txq = &nic_dev->txqs[q_id]; qp = container_of(txq->sq, struct hinic_qp, sq); -- 2.17.1