From patchwork Tue Jan 23 16:51:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dayanand, Avinash" X-Patchwork-Id: 864987 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zQzVF4BlNz9s9Y for ; Wed, 24 Jan 2018 06:52:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2A81A2FD8B; Tue, 23 Jan 2018 19:52:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NbMPtzLxvrpJ; Tue, 23 Jan 2018 19:52:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 8F3652FDB6; Tue, 23 Jan 2018 19:52:32 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 04B491C0521 for ; Tue, 23 Jan 2018 19:52:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id EB158881F4 for ; Tue, 23 Jan 2018 19:52:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OludxhSXXQ-1 for ; Tue, 23 Jan 2018 19:52:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by hemlock.osuosl.org (Postfix) with ESMTPS id E659688227 for ; Tue, 23 Jan 2018 19:52:22 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2018 11:52:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,402,1511856000"; d="scan'208";a="25768875" Received: from avi-linux2.jf.intel.com ([10.166.244.156]) by orsmga001.jf.intel.com with ESMTP; 23 Jan 2018 11:52:06 -0800 From: Avinash Dayanand To: intel-wired-lan@lists.osuosl.org Date: Tue, 23 Jan 2018 08:51:01 -0800 Message-Id: <20180123165106.28900-8-avinash.dayanand@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20180123165106.28900-1-avinash.dayanand@intel.com> References: <20180123165106.28900-1-avinash.dayanand@intel.com> Subject: [Intel-wired-lan] [PATCH v3 next-queue 07/12] i40evf: Add support to configure bw via tc tool X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Harshitha Ramamurthy This patch adds support to configure bandwidth for the traffic classes via tc tool. The required information is passed to the PF which is used in the process of setting up the traffic classes. Signed-off-by: Harshitha Ramamurthy Tested-by: Andrew Bowers --- drivers/net/ethernet/intel/i40evf/i40evf.h | 1 + drivers/net/ethernet/intel/i40evf/i40evf_main.c | 66 +++++++++++++++++++++- .../net/ethernet/intel/i40evf/i40evf_virtchnl.c | 3 + 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/i40evf/i40evf.h b/drivers/net/ethernet/intel/i40evf/i40evf.h index c8d68c8..150d676 100644 --- a/drivers/net/ethernet/intel/i40evf/i40evf.h +++ b/drivers/net/ethernet/intel/i40evf/i40evf.h @@ -107,6 +107,7 @@ struct i40e_vsi { #define I40EVF_HKEY_ARRAY_SIZE ((I40E_VFQF_HKEY_MAX_INDEX + 1) * 4) #define I40EVF_HLUT_ARRAY_SIZE ((I40E_VFQF_HLUT_MAX_INDEX + 1) * 4) +#define I40EVF_MBPS_DIVISOR 125000 /* divisor to convert to Mbps */ /* MAX_MSIX_Q_VECTORS of these are allocated, * but we only use one per queue-specific vector. diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c index 9d36553..91fff5f 100644 --- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c +++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c @@ -2218,6 +2218,48 @@ void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter) } /** + * i40evf_validate_tx_bandwidth - validate the max tx bandwidth + * @adapter: board private structure + * @max_tx_rate: max tx bw for a tc + **/ +static int i40evf_validate_tx_bandwidth(struct i40evf_adapter *adapter, + u64 max_tx_rate) +{ + int speed = 0, ret = 0; + + switch (adapter->link_speed) { + case I40E_LINK_SPEED_40GB: + speed = 40000; + break; + case I40E_LINK_SPEED_25GB: + speed = 25000; + break; + case I40E_LINK_SPEED_20GB: + speed = 20000; + break; + case I40E_LINK_SPEED_10GB: + speed = 10000; + break; + case I40E_LINK_SPEED_1GB: + speed = 1000; + break; + case I40E_LINK_SPEED_100MB: + speed = 100; + break; + default: + break; + } + + if (max_tx_rate > speed) { + dev_err(&adapter->pdev->dev, + "Invalid tx rate specified\n"); + ret = -EINVAL; + } + + return ret; +} + +/** * i40evf_validate_channel_config - validate queue mapping info * @adapter: board private structure * @mqprio_qopt: queue parameters @@ -2229,7 +2271,10 @@ void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter) static int i40evf_validate_ch_config(struct i40evf_adapter *adapter, struct tc_mqprio_qopt_offload *mqprio_qopt) { + u64 total_max_rate = 0; int i, num_qps = 0; + u64 tx_rate = 0; + int ret = 0; if (mqprio_qopt->qopt.num_tc > I40EVF_MAX_TRAFFIC_CLASS || mqprio_qopt->qopt.num_tc < 1) @@ -2237,16 +2282,24 @@ static int i40evf_validate_ch_config(struct i40evf_adapter *adapter, for (i = 0; i <= mqprio_qopt->qopt.num_tc - 1; i++) { if (!mqprio_qopt->qopt.count[i] || - mqprio_qopt->min_rate[i] || - mqprio_qopt->max_rate[i] || mqprio_qopt->qopt.offset[i] != num_qps) return -EINVAL; + if (mqprio_qopt->min_rate[i]) { + dev_err(&adapter->pdev->dev, + "Invalid min tx rate (greater than 0) specified\n"); + return -EINVAL; + } + /*convert to Mbps */ + tx_rate = div_u64(mqprio_qopt->max_rate[i], + I40EVF_MBPS_DIVISOR); + total_max_rate += tx_rate; num_qps += mqprio_qopt->qopt.count[i]; } if (num_qps > MAX_QUEUES) return -EINVAL; - return 0; + ret = i40evf_validate_tx_bandwidth(adapter, total_max_rate); + return ret; } /** @@ -2267,6 +2320,7 @@ static int __i40evf_setup_tc(struct net_device *netdev, void *type_data) struct virtchnl_vf_resource *vfres = adapter->vf_res; u8 num_tc = 0, total_qps = 0; int ret = 0, netdev_tc = 0; + u64 max_tx_rate; u16 mode; int i; @@ -2314,6 +2368,12 @@ static int __i40evf_setup_tc(struct net_device *netdev, void *type_data) adapter->ch_config.ch_info[i].offset = mqprio_qopt->qopt.offset[i]; total_qps += mqprio_qopt->qopt.count[i]; + max_tx_rate = mqprio_qopt->max_rate[i]; + /* convert to Mbps */ + max_tx_rate = div_u64(max_tx_rate, + I40EVF_MBPS_DIVISOR); + adapter->ch_config.ch_info[i].max_tx_rate = + max_tx_rate; } else { adapter->ch_config.ch_info[i].count = 1; adapter->ch_config.ch_info[i].offset = 0; diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c index 8329f37..76bce1a 100644 --- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c +++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c @@ -1003,6 +1003,9 @@ void i40evf_enable_channels(struct i40evf_adapter *adapter) for (i = 0; i < vti->num_tc; i++) { vti->list[i].count = adapter->ch_config.ch_info[i].count; vti->list[i].offset = adapter->ch_config.ch_info[i].offset; + vti->list[i].pad = 0; + vti->list[i].max_tx_rate = + adapter->ch_config.ch_info[i].max_tx_rate; } adapter->ch_config.state = __I40EVF_TC_RUNNING;