From patchwork Thu Sep 22 09:05:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 673237 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sfrFx1SvCz9t1h for ; Thu, 22 Sep 2016 19:06:29 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=RvWOAMko; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756713AbcIVJGD (ORCPT ); Thu, 22 Sep 2016 05:06:03 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36495 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751468AbcIVJGA (ORCPT ); Thu, 22 Sep 2016 05:06:00 -0400 Received: by mail-pf0-f196.google.com with SMTP id n24so3528561pfb.3; Thu, 22 Sep 2016 02:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ssIZYP2Kg/NfhMy7ZqE/DT9v8MBZdkF6PGPnwzBRqCk=; b=RvWOAMkobjSsq30bGiOaM3AttYH/JRxPfGdX2clhJHvkzdlU2HDOgt3Rs+92Spo9X7 Dcaz/eOPQK/TsBsL8pNmywMBiFTVNrkha85YFH99/Tqtjt9PfIxUcm3jrTMWx/cQEDnh +xkF/tbPc3sYvKWDRS1QS2GI0wVFS3P34XGAjAkDD256f/btWFsJdxp5koe9hCGqjDB9 s2MPR4BqoVJzI7lG/xgBp26VpkjYmroK+2IXTcqPR4X6/AfwY3CxAM7UDbXbYshQjMK/ TVrxbSFwXrLMi6h2P1UYTX7jaIYFX9ZbhB97K7lBFxPG5ebew7KOgdtBMa1h1AlejmXT ZP9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ssIZYP2Kg/NfhMy7ZqE/DT9v8MBZdkF6PGPnwzBRqCk=; b=QIPYsFCZC80UANvHUq9O4SvkVJavCkz+wINMdSFndGBYMNbh6LEPLDmrQ4/A6ZapsU aZP+X1m5XxfU1LPVEReLdR3DMK+V9M6i0Hxuj6P3+LYN3SEjqWZbbgogRnLyrhngYuDf +5pxjcREzGilFvRTYP1dmADeDancSZUp5USrE6kTLUyUch/qXqZC3t7Ptq7fSOlZIShZ O/2pfk8iUER6ew0S5VO2zJKRIWfBAUuppeEqKyjAvxH678zzxiBJqTKx++d1t/xQPEaH VFa0Zt2Ad2hbm7QB3IWxF1rogK1Kw7WUsME5YRsk61v7hgExKuzWRDL+WWa0SHjH6FwV fVFw== X-Gm-Message-State: AE9vXwO5HzxfwIuKxQMRw+VL2YB4zEdhc9qBWniwEzFQ10mVuUCAc42iJVrs1s/iWY76Vw== X-Received: by 10.98.29.140 with SMTP id d134mr1491975pfd.142.1474535158436; Thu, 22 Sep 2016 02:05:58 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id t16sm2216020pfj.76.2016.09.22.02.05.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 02:05:57 -0700 (PDT) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sunil Goutham Subject: [PATCH 2/2] net: thunderx: Support for byte queue limits Date: Thu, 22 Sep 2016 14:35:21 +0530 Message-Id: <1474535121-13958-3-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474535121-13958-1-git-send-email-sunil.kovvuri@gmail.com> References: <1474535121-13958-1-git-send-email-sunil.kovvuri@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sunil Goutham This patch adds support for byte queue limits Signed-off-by: Sunil Goutham --- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 11 ++++++-- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 30 ++++++++++++++-------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index 7d00162..453e3a0 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -516,7 +516,8 @@ static int nicvf_init_resources(struct nicvf *nic) static void nicvf_snd_pkt_handler(struct net_device *netdev, struct cmp_queue *cq, struct cqe_send_t *cqe_tx, - int cqe_type, int budget) + int cqe_type, int budget, + unsigned int *tx_pkts, unsigned int *tx_bytes) { struct sk_buff *skb = NULL; struct nicvf *nic = netdev_priv(netdev); @@ -547,6 +548,8 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev, } nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1); prefetch(skb); + (*tx_pkts)++; + *tx_bytes += skb->len; napi_consume_skb(skb, budget); sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL; } else { @@ -662,6 +665,7 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx, struct cmp_queue *cq = &qs->cq[cq_idx]; struct cqe_rx_t *cq_desc; struct netdev_queue *txq; + unsigned int tx_pkts = 0, tx_bytes = 0; spin_lock_bh(&cq->lock); loop: @@ -701,7 +705,7 @@ loop: case CQE_TYPE_SEND: nicvf_snd_pkt_handler(netdev, cq, (void *)cq_desc, CQE_TYPE_SEND, - budget); + budget, &tx_pkts, &tx_bytes); tx_done++; break; case CQE_TYPE_INVALID: @@ -730,6 +734,9 @@ done: netdev = nic->pnicvf->netdev; txq = netdev_get_tx_queue(netdev, nicvf_netdev_qidx(nic, cq_idx)); + if (tx_pkts) + netdev_tx_completed_queue(txq, tx_pkts, tx_bytes); + nic = nic->pnicvf; if (netif_tx_queue_stopped(txq) && netif_carrier_ok(netdev)) { netif_tx_start_queue(txq); diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index 178c5c7..a4fc501 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -1082,6 +1082,24 @@ static inline void nicvf_sq_add_cqe_subdesc(struct snd_queue *sq, int qentry, imm->len = 1; } +static inline void nicvf_sq_doorbell(struct nicvf *nic, struct sk_buff *skb, + int sq_num, int desc_cnt) +{ + struct netdev_queue *txq; + + txq = netdev_get_tx_queue(nic->pnicvf->netdev, + skb_get_queue_mapping(skb)); + + netdev_tx_sent_queue(txq, skb->len); + + /* make sure all memory stores are done before ringing doorbell */ + smp_wmb(); + + /* Inform HW to xmit all TSO segments */ + nicvf_queue_reg_write(nic, NIC_QSET_SQ_0_7_DOOR, + sq_num, desc_cnt); +} + /* Segment a TSO packet into 'gso_size' segments and append * them to SQ for transfer */ @@ -1141,12 +1159,8 @@ static int nicvf_sq_append_tso(struct nicvf *nic, struct snd_queue *sq, /* Save SKB in the last segment for freeing */ sq->skbuff[hdr_qentry] = (u64)skb; - /* make sure all memory stores are done before ringing doorbell */ - smp_wmb(); + nicvf_sq_doorbell(nic, skb, sq_num, desc_cnt); - /* Inform HW to xmit all TSO segments */ - nicvf_queue_reg_write(nic, NIC_QSET_SQ_0_7_DOOR, - sq_num, desc_cnt); nic->drv_stats.tx_tso++; return 1; } @@ -1219,12 +1233,8 @@ doorbell: nicvf_sq_add_cqe_subdesc(sq, qentry, tso_sqe, skb); } - /* make sure all memory stores are done before ringing doorbell */ - smp_wmb(); + nicvf_sq_doorbell(nic, skb, sq_num, subdesc_cnt); - /* Inform HW to xmit new packet */ - nicvf_queue_reg_write(nic, NIC_QSET_SQ_0_7_DOOR, - sq_num, subdesc_cnt); return 1; append_fail: