From patchwork Tue Oct 17 10:23:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 116059 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4706183qgn; Tue, 17 Oct 2017 03:24:14 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RcztuTseeYIklcJKm74T+orVczGorASMTdGVTB7dld03KjT5t2AdhS+wMgPjVhkk/wosCj X-Received: by 10.98.55.133 with SMTP id e127mr2890987pfa.130.1508235854353; Tue, 17 Oct 2017 03:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508235854; cv=none; d=google.com; s=arc-20160816; b=h8n30dDSVmfStva8NWU6cVji9Pk/xyMcJiF0vwgNc2bSVfxHjxlOA0urrPtPFz7ZCz 4FhJqUP/PmpOOdKafhszP0P5vsd/HWxvgQ4xoJ3PgBVVUIc8jcHGOFUex22YVRyUC/7p 1owKQOAcwVuX5XVPpq7jy3XF4wVNZtAAyz485IFwx42KJ+rAAd1/z7+TWZzLkLYC3s7p G8DPAbDyCbajxTGD0KOdFPhPsx08j9Pe8MheWmyOQOhyPRb7XmkjboPfHB6Jq1XkdbE/ E21g1/ztpeeTKXyy3jj8ghygAY7Jh2pAOyUD/WCHO4/tl+dZtRyWVC7eaPm762RhlyGX WgCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XFH6gFIeTF2H1RXu13E8jXAGF6wFXj8rrFAaOAfqUrY=; b=ZVGahFsSbIz7jTazNkItDf2Y3S5KCsxrDOemWkjgaQnspQ5cr4zDxNiw/MP4mG9yyM 04hg3G6C3Q/jrTFvyW+2TgWT9TQVarAqev7UYXBTDWKsrKlgUFrTXvim0Ac81bRXNlYG BaaYeDK/UJxeONwz3hY/pIDEFoDNVKeZwafyJ0Vnrz2mRRoaIKg/kyK/UJ4am6lB+QTh 3NLTtx0PUYSVfMJYRZ2vBOibAlWXs1Y9aGSELQ7dkCrD7et3h2AHeLSEAtyvmaESkkHu gqSYhLpKDcwPV2+zpQ2F4rYqmXIVKxQwkHsIOLO/8bzLl6HhoFsPfowBrpF65tuNixiV lsAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si5257578pgp.174.2017.10.17.03.24.14; Tue, 17 Oct 2017 03:24:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935099AbdJQKYM (ORCPT + 27 others); Tue, 17 Oct 2017 06:24:12 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:56185 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754544AbdJQKYI (ORCPT ); Tue, 17 Oct 2017 06:24:08 -0400 Received: from wuerfel.lan ([46.223.139.202]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0MBBkT-1duGgY11HB-00ADLr; Tue, 17 Oct 2017 12:23:55 +0200 From: Arnd Bergmann To: Jeff Kirsher Cc: Arnd Bergmann , Jacob Keller , Mitch Williams , Alexander Duyck , Amritha Nambiar , Filip Sadowski , "David S. Miller" , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH, net-next] i40e: avoid 64-bit division where possible Date: Tue, 17 Oct 2017 12:23:36 +0200 Message-Id: <20171017102351.492492-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:xbo1ouKZWEJ4GyEa4I7Y1NnAXnw8F+beb+gxWn7D0I1E/3B7mIw HJiL1lMvuo4/DNyy9n9iDRj0g4at2US4pnWLq1Mh5igbI2NQ95rMBq+G0WuBrWS+4mEq30c Xd5ZbEs3Kj93s4cIqQuRSgzttIbHLXG/llJkL5k0enye6r99L3A+mWBPM9zWltTSPitXVhh OmDepAqUDu4JzVaCbi2ZA== X-UI-Out-Filterresults: notjunk:1; V01:K0:w8iUwhG6S9o=:mwn38+FA+mH/AMs/nDhgF2 MoMc3DVWb/ChW4NHS7FtytfSHrTosjwRroqAyOS2+kg9wzO9bJAU7hiT9egFSDjg3cifElzem yfbm5Uf+VS52l4XxyDKWmLli96puQgUyV07SjRb0131B8cxK3BG7WLtibi70GURURZkwQB3oM i+YZvfLLDrgcR8EfeBrhy0xS5P1+phrNp7tEBQjgnrg9gVCZ5Q0TNX1Bpr9Lr6NGlb1C02jmJ PoWZyiG8pX2/7njnVeIIYNU5VSLhpf1FI7HLvUlpkL1FxuDOP4PV2G3oWXoIVQzOv6HxBF9tG qzB8EkZR7m5THTw38O6exgdg4yyC37P1auor0Kf9e1qYdoU0jsMP+jRb2rKtcy8VLZvdOiJjM wlY41FbIIKh8VX1IknBdDGXUdKinNbEh/PX+ICjMFXEom9d2HKbRDKSTNF/ClUv77MjuPENeI HvwwxxhmQv2o3sL1ihAoJGLHxT2g1wwjOhebHh4w/X1hb4sJ12kA9eSCbzW28tHFJ0xCTnDC8 0y912HyvlcLjM/5Yj+22fMindXvYr5cUpo3UCPWsJ8QziQAZoK59Ekufa6k2dQ0MgGlqne5Xm faghDC0lNVLOqrQASUSaXFlnn1qT2Z8eRpmvyuifocSVOfNrEveE/Yl+KlNqHy5GhjEQ09QzP c5JAQKlvrh2/y5b5YfGe9QHii5KD9PqZM4h1H7vTZUONV1yN5FunuQCqKArucL10H59M65Eyz iqYv8qs05NZFOkFm41LkmetyjBoWQS/AFpPwng== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new bandwidth calculation causes a link error on 32-bit architectures, like ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/intel/i40e/i40e.ko] undefined! The problem is the max_tx_rate calculation that uses 64-bit integers. This is not really necessary since the numbers are in MBit/s so they won't be higher than 40000 for the highest support rate, and are guaranteed to not exceed 2^32 in future generations either. This changes the representation to 'u32' when dealing with MBit/s and uses div_u64() to convert from u64 numbers in byte/s. Fixes: 2027d4deacb1 ("i40e: Add support setting TC max bandwidth rates") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/intel/i40e/i40e.h | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) -- 2.9.0 diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index 266e1dc5e786..45155ef15d24 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -359,7 +359,7 @@ struct i40e_channel { u8 enabled_tc; struct i40e_aqc_vsi_properties_data info; - u64 max_tx_rate; + u32 max_tx_rate; /* in Mbits/s */ /* track this channel belongs to which VSI */ struct i40e_vsi *parent_vsi; @@ -1045,5 +1045,5 @@ static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi) } int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch); -int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate); +int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u32 max_tx_rate); #endif /* _I40E_H_ */ diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 624a2bc8a1df..e71fece72506 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -5439,7 +5439,7 @@ int i40e_get_link_speed(struct i40e_vsi *vsi) * * Helper function to set BW limit for a given VSI **/ -int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate) +int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u32 max_tx_rate) { struct i40e_pf *pf = vsi->back; int speed = 0; @@ -5448,7 +5448,7 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate) speed = i40e_get_link_speed(vsi); if (max_tx_rate > speed) { dev_err(&pf->pdev->dev, - "Invalid max tx rate %llu specified for VSI seid %d.", + "Invalid max tx rate %u specified for VSI seid %d.", max_tx_rate, seid); return -EINVAL; } @@ -5464,7 +5464,7 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate) I40E_MAX_BW_INACTIVE_ACCUM, NULL); if (ret) dev_err(&pf->pdev->dev, - "Failed set tx rate (%llu Mbps) for vsi->seid %u, err %s aq_err %s\n", + "Failed set tx rate (%u Mbps) for vsi->seid %u, err %s aq_err %s\n", max_tx_rate, seid, i40e_stat_str(&pf->hw, ret), i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); return ret; @@ -6067,7 +6067,7 @@ int i40e_create_queue_channel(struct i40e_vsi *vsi, return -EINVAL; dev_dbg(&pf->pdev->dev, - "Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n", + "Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\n", ch->max_tx_rate, ch->max_tx_rate / I40E_BW_CREDIT_DIVISOR, ch->seid); } @@ -6110,8 +6110,8 @@ static int i40e_configure_queue_channels(struct i40e_vsi *vsi) /* Bandwidth limit through tc interface is in bytes/s, * change to Mbit/s */ - ch->max_tx_rate = - vsi->mqprio_qopt.max_rate[i] / (1000000 / 8); + ch->max_tx_rate = div_u64(vsi->mqprio_qopt.max_rate[i], + 1000000 / 8); list_add_tail(&ch->list, &vsi->ch_list); @@ -6554,7 +6554,7 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi, "Invalid min tx rate (greater than 0) specified\n"); return -EINVAL; } - sum_max_rate += (mqprio_qopt->max_rate[i] / (1000000 / 8)); + sum_max_rate += div_u64(mqprio_qopt->max_rate[i], 1000000 / 8); if (i >= mqprio_qopt->qopt.num_tc - 1) break; @@ -6698,12 +6698,12 @@ static int i40e_setup_tc(struct net_device *netdev, void *type_data) if (pf->flags & I40E_FLAG_TC_MQPRIO) { if (vsi->mqprio_qopt.max_rate[0]) { - u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0] / - (1000000 / 8); + u32 max_tx_rate = div_u64(vsi->mqprio_qopt.max_rate[0], + 1000000 / 8); ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate); if (!ret) { dev_dbg(&vsi->back->pdev->dev, - "Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n", + "Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\n", max_tx_rate, max_tx_rate / I40E_BW_CREDIT_DIVISOR, vsi->seid); @@ -8171,7 +8171,7 @@ static int i40e_rebuild_channels(struct i40e_vsi *vsi) return -EINVAL; dev_dbg(&vsi->back->pdev->dev, - "Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n", + "Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\n", ch->max_tx_rate, ch->max_tx_rate / I40E_BW_CREDIT_DIVISOR, ch->seid); @@ -8446,12 +8446,13 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) } if (vsi->mqprio_qopt.max_rate[0]) { - u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0] / (1000000 / 8); + u32 max_tx_rate = div_u64(vsi->mqprio_qopt.max_rate[0], + 1000000 / 8); ret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate); if (!ret) dev_dbg(&vsi->back->pdev->dev, - "Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\n", + "Set tx rate of %u Mbps (count of 50Mbps %u) for vsi->seid %u\n", max_tx_rate, max_tx_rate / I40E_BW_CREDIT_DIVISOR, vsi->seid);