From patchwork Tue Sep 1 18:20:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 261675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C623C433E2 for ; Tue, 1 Sep 2020 18:21:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E056206FA for ; Tue, 1 Sep 2020 18:21:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pensando.io header.i=@pensando.io header.b="GbGrKgDt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730512AbgIASVd (ORCPT ); Tue, 1 Sep 2020 14:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730152AbgIASUe (ORCPT ); Tue, 1 Sep 2020 14:20:34 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCCB4C061245 for ; Tue, 1 Sep 2020 11:20:32 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id nv17so1037786pjb.3 for ; Tue, 01 Sep 2020 11:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/YhURs6thIRKQENuEmMUz6hEKmtfEBpZ2ukYj2UWP5c=; b=GbGrKgDtG4dfFfsPFw11x5/iiMA2l/sj2RjNniXXfjhFSDLz6WQ8kamnOGMbZ5ol5L V96oA1KII23vYWGH0ODsCx7Ja1rm9i4rIxS9jloYzTNeJxwZIJByITjIJE899nWRyHhV srjd5ocP/m25w1MFq09vrCwgP5s6Qh+EA1LG6ScQUdFOLVyTgh8cqxExMeHy26AiYonh cWbUBDZbHV5CLHMX07r7Ji/arhIYUtR+m45FW+fJ1EMmiaWChIKm4xhmBfSOdJfNeSWX WFEhL3m1vnCI/F3Ve59Y6YTkQkF4/Hu2OPUAmY+2iuttmC66tSe90F45bZMPSwG1Dxiw a21A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/YhURs6thIRKQENuEmMUz6hEKmtfEBpZ2ukYj2UWP5c=; b=U2M57VFObKkZ2vU+KVqCd46eeaSsFpjOdv9lmHiw8NiZukGlawC01DnVbgPZpF3MHS h0/SD0zGYN/Lb/wt5ned1+oTNDloFOOJzV2qqUsIqqbuRXTMn0JxSRlWEtM3r+Z2gwKe CLcYssKRhOt85Tp5D0qvlcUkuexZI/k+3SPF0d4UKjjxis8nSLFaPMVtG78vRdC+ReUy 0oWDVDzN8Mx03t+Xpl0Q/TJXcpCpp7c/Ii+41jgZFx0w1oy9x3ELx/O1+hdIYVoSqV/h isqWbW90mZd8jdVxgTzn6jhP7U61JTtxCUi2r3zkXSPD+xqyJ/ZbUEiWSdBf50rYOEVK SQkw== X-Gm-Message-State: AOAM531gtfNFe4prLEkksSaNC1m8NfguIjcv/mNlxspo/DDLnnwqT2lx RNPlFy4W24YErlMGud1nIbjPxzflGDQnUQ== X-Google-Smtp-Source: ABdhPJwY2qm2/RgjQ03NcAzzhw/33KzVBhoz/16xrU5GHOTCsA9jytuic9pXUXiKscR/MoHHLnfKxQ== X-Received: by 2002:a17:902:8690:: with SMTP id g16mr2549832plo.257.1598984431929; Tue, 01 Sep 2020 11:20:31 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id j81sm2747086pfd.213.2020.09.01.11.20.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 11:20:31 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v2 net-next 1/6] ionic: clean up page handling code Date: Tue, 1 Sep 2020 11:20:19 -0700 Message-Id: <20200901182024.64101-2-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901182024.64101-1-snelson@pensando.io> References: <20200901182024.64101-1-snelson@pensando.io> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The internal page handling can be cleaned up by passing our local page struct rather than dma addresses, and by putting more of the mgmt code into the alloc and free routines. Co-developed-by: Neel Patel Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_txrx.c | 71 +++++++++++-------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index c3291decd4c3..bbc926bc3852 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -266,40 +266,49 @@ void ionic_rx_flush(struct ionic_cq *cq) work_done, IONIC_INTR_CRED_RESET_COALESCE); } -static struct page *ionic_rx_page_alloc(struct ionic_queue *q, - dma_addr_t *dma_addr) +static int ionic_rx_page_alloc(struct ionic_queue *q, + struct ionic_page_info *page_info) { struct ionic_lif *lif = q->lif; struct ionic_rx_stats *stats; struct net_device *netdev; struct device *dev; - struct page *page; netdev = lif->netdev; dev = lif->ionic->dev; stats = q_to_rx_stats(q); - page = alloc_page(GFP_ATOMIC); - if (unlikely(!page)) { - net_err_ratelimited("%s: Page alloc failed on %s!\n", + + if (unlikely(!page_info)) { + net_err_ratelimited("%s: %s invalid page_info in alloc\n", + netdev->name, q->name); + return -EINVAL; + } + + page_info->page = dev_alloc_page(); + if (unlikely(!page_info->page)) { + net_err_ratelimited("%s: %s page alloc failed\n", netdev->name, q->name); stats->alloc_err++; - return NULL; + return -ENOMEM; } - *dma_addr = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE); - if (unlikely(dma_mapping_error(dev, *dma_addr))) { - __free_page(page); - net_err_ratelimited("%s: DMA single map failed on %s!\n", + page_info->dma_addr = dma_map_page(dev, page_info->page, 0, PAGE_SIZE, + DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(dev, page_info->dma_addr))) { + put_page(page_info->page); + page_info->dma_addr = 0; + page_info->page = NULL; + net_err_ratelimited("%s: %s dma map failed\n", netdev->name, q->name); stats->dma_map_err++; - return NULL; + return -EIO; } - return page; + return 0; } -static void ionic_rx_page_free(struct ionic_queue *q, struct page *page, - dma_addr_t dma_addr) +static void ionic_rx_page_free(struct ionic_queue *q, + struct ionic_page_info *page_info) { struct ionic_lif *lif = q->lif; struct net_device *netdev; @@ -308,15 +317,23 @@ static void ionic_rx_page_free(struct ionic_queue *q, struct page *page, netdev = lif->netdev; dev = lif->ionic->dev; - if (unlikely(!page)) { - net_err_ratelimited("%s: Trying to free unallocated buffer on %s!\n", + if (unlikely(!page_info)) { + net_err_ratelimited("%s: %s invalid page_info in free\n", netdev->name, q->name); return; } - dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); + if (unlikely(!page_info->page)) { + net_err_ratelimited("%s: %s invalid page in free\n", + netdev->name, q->name); + return; + } - __free_page(page); + dma_unmap_page(dev, page_info->dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); + + put_page(page_info->page); + page_info->dma_addr = 0; + page_info->page = NULL; } void ionic_rx_fill(struct ionic_queue *q) @@ -352,8 +369,7 @@ void ionic_rx_fill(struct ionic_queue *q) desc->opcode = (nfrags > 1) ? IONIC_RXQ_DESC_OPCODE_SG : IONIC_RXQ_DESC_OPCODE_SIMPLE; desc_info->npages = nfrags; - page_info->page = ionic_rx_page_alloc(q, &page_info->dma_addr); - if (unlikely(!page_info->page)) { + if (unlikely(ionic_rx_page_alloc(q, page_info))) { desc->addr = 0; desc->len = 0; return; @@ -370,8 +386,7 @@ void ionic_rx_fill(struct ionic_queue *q) continue; sg_elem = &sg_desc->elems[j]; - page_info->page = ionic_rx_page_alloc(q, &page_info->dma_addr); - if (unlikely(!page_info->page)) { + if (unlikely(ionic_rx_page_alloc(q, page_info))) { sg_elem->addr = 0; sg_elem->len = 0; return; @@ -409,14 +424,8 @@ void ionic_rx_empty(struct ionic_queue *q) desc->addr = 0; desc->len = 0; - for (i = 0; i < desc_info->npages; i++) { - if (likely(desc_info->pages[i].page)) { - ionic_rx_page_free(q, desc_info->pages[i].page, - desc_info->pages[i].dma_addr); - desc_info->pages[i].page = NULL; - desc_info->pages[i].dma_addr = 0; - } - } + for (i = 0; i < desc_info->npages; i++) + ionic_rx_page_free(q, &desc_info->pages[i]); desc_info->cb_arg = NULL; idx = (idx + 1) & (q->num_descs - 1); From patchwork Tue Sep 1 18:20:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 261678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBA17C433E2 for ; Tue, 1 Sep 2020 18:20:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95B152071B for ; Tue, 1 Sep 2020 18:20:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pensando.io header.i=@pensando.io header.b="nC4mzWja" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730365AbgIASUv (ORCPT ); Tue, 1 Sep 2020 14:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728216AbgIASUe (ORCPT ); Tue, 1 Sep 2020 14:20:34 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7A8FC061246 for ; Tue, 1 Sep 2020 11:20:33 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id t9so1282394pfq.8 for ; Tue, 01 Sep 2020 11:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d313eD54a7wBpf4xIcIfjkC0vS1lqfvdWPstPVu4Iqw=; b=nC4mzWjaQJdYMTkfgDEpFZ1dR1FHJu4B1aEtQDUDt79VYBWHqpzcOt0SoNF7XKmFJf oXCzacNl3ISYRJwNRi2bo97noEa2BewTFhqPHXcrmeKl99SFxO06pJTvYeh8eSl3+qyT sZ/pW6Hu0xc9sOmU2FnSG710ei2DT3ErHhHOtvV87wLHWmFbDs8r4WR978ncxgfikhUX Lty980B31xMITP1scTDIxInD+TbjldnFnt4k74WaRhkfCDDrG+9/avU6yoqUE+Axvkv8 LiZtX/Lf9rlxke+fcNXJGCiHgJ+SNiSBxdrDYWAPBwa949+YeBw9z+5JlPLeXEiYRxBm 5oaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d313eD54a7wBpf4xIcIfjkC0vS1lqfvdWPstPVu4Iqw=; b=Jy4PKvgMz2QW6S+556s3xllbH45nJ5XPo3CWwCnfl+GcI0mX8ItVnLzqxP626xgvJP uTWhmCQMEQilqAJjkI+/jgzyASzwRMDuK8wCsopLR7KrLvRMCBD+H/eyyoZO6auUP7AN R06O3H4g1MyghnFzwI4Q/sAxo+sRk/EsvbYi/vbrH3nSw+BIbaVNwguaFOBuNHR0IOXr wxHIwp26+fXpTxsa57uvbuUziTCzb8sQKDcOLxA8hy4B0+KlUGP7cTRa6442B0bYeblu DkLPekUVpKiw9bnjJ+SqNfas27WejbDCbCdZZou5Mv2n8YnP0NS9UyUm1g2g4wyvXxjQ ITSg== X-Gm-Message-State: AOAM530RWsrRnoJvCcmLqdEPVdUQ95x6yC6ET2FYnVhJvRezOpZm8c7p 1Q7C3BVGSj4vhYszBHwtuOS+onMpCmSX8Q== X-Google-Smtp-Source: ABdhPJy4hUcPF6QOQRZbY+XFtCApZfJfP1xRwcDuvrWe4jj/s9U1tynLe13YLRpVawttjNL8uc9Zlw== X-Received: by 2002:a62:1d44:: with SMTP id d65mr3096700pfd.150.1598984433143; Tue, 01 Sep 2020 11:20:33 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id j81sm2747086pfd.213.2020.09.01.11.20.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 11:20:32 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v2 net-next 2/6] ionic: struct reorder for faster access Date: Tue, 1 Sep 2020 11:20:20 -0700 Message-Id: <20200901182024.64101-3-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901182024.64101-1-snelson@pensando.io> References: <20200901182024.64101-1-snelson@pensando.io> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move a few active struct fields to the front of the struct for a little better cache use and performance. Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.h | 18 +++++++++--------- .../net/ethernet/pensando/ionic/ionic_lif.h | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 9e2ac2b8a082..0641ca2e1780 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -199,16 +199,17 @@ struct ionic_desc_info { struct ionic_queue { struct device *dev; - u64 dbell_count; - u64 drop; - u64 stop; - u64 wake; struct ionic_lif *lif; struct ionic_desc_info *info; - struct ionic_dev *idev; u16 head_idx; u16 tail_idx; unsigned int index; + unsigned int num_descs; + u64 dbell_count; + u64 stop; + u64 wake; + u64 drop; + struct ionic_dev *idev; unsigned int type; unsigned int hw_index; unsigned int hw_type; @@ -226,7 +227,6 @@ struct ionic_queue { }; dma_addr_t base_pa; dma_addr_t sg_base_pa; - unsigned int num_descs; unsigned int desc_size; unsigned int sg_desc_size; unsigned int pid; @@ -246,8 +246,6 @@ struct ionic_intr_info { }; struct ionic_cq { - void *base; - dma_addr_t base_pa; struct ionic_lif *lif; struct ionic_cq_info *info; struct ionic_queue *bound_q; @@ -255,8 +253,10 @@ struct ionic_cq { u16 tail_idx; bool done_color; unsigned int num_descs; - u64 compl_count; unsigned int desc_size; + u64 compl_count; + void *base; + dma_addr_t base_pa; }; struct ionic; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h index e1e6ff1a0918..11ea9e0c6a4a 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h @@ -16,32 +16,32 @@ #define IONIC_TX_BUDGET_DEFAULT 256 struct ionic_tx_stats { - u64 dma_map_err; u64 pkts; u64 bytes; - u64 clean; - u64 linearize; u64 csum_none; u64 csum; - u64 crc32_csum; u64 tso; u64 tso_bytes; u64 frags; u64 vlan_inserted; + u64 clean; + u64 linearize; + u64 crc32_csum; u64 sg_cntr[IONIC_MAX_NUM_SG_CNTR]; + u64 dma_map_err; }; struct ionic_rx_stats { - u64 dma_map_err; - u64 alloc_err; u64 pkts; u64 bytes; u64 csum_none; u64 csum_complete; - u64 csum_error; u64 buffers_posted; u64 dropped; u64 vlan_stripped; + u64 csum_error; + u64 dma_map_err; + u64 alloc_err; }; #define IONIC_QCQ_F_INITED BIT(0) From patchwork Tue Sep 1 18:20:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 261676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2921CC433E6 for ; Tue, 1 Sep 2020 18:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EEB1C206FA for ; Tue, 1 Sep 2020 18:21:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pensando.io header.i=@pensando.io header.b="gJngleML" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730207AbgIASVW (ORCPT ); Tue, 1 Sep 2020 14:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730181AbgIASUi (ORCPT ); Tue, 1 Sep 2020 14:20:38 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D1FC061247 for ; Tue, 1 Sep 2020 11:20:36 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id np15so980026pjb.0 for ; Tue, 01 Sep 2020 11:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IiN+v9uzS1MIl2xbDXaV9FYs3HkOjRzyqudFSsdwrj4=; b=gJngleMLP24C35VVlrKIabcMJtxx8qykpof6e6/cEkZ19zhwpv2OcnfiHtwXc0hxum pluJ1j3Wt3VHxGLas2YqwfEMQBsE9A9xbx0Ri96gXsmFReAofnzh7J2c0lKPfCzUo9el 66fVH/bs7l89F1DlZhDZmbiL8ZCrU47QeKdEWyF4pwWIIetOABlmYbqx/7ULGnwwwLuO eJZypa2XQIWnmgS+zUix7nR3/Z2lICGFM3oUnCze0ImYEgFE6W/bQkarbgjLdJhQDKOQ tlyinnqlibKnMPaYtfkgE16sAN9La4npPOviLgEhUw9ugVURweNA3UA3rlFlPm4etKtt G74A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IiN+v9uzS1MIl2xbDXaV9FYs3HkOjRzyqudFSsdwrj4=; b=IvJB6lBoIW84A32OjvUyUl3j+UxQLcelg+6ferLbhV2c2l3fuPLDvpS25YEdx1lags qhPYgce3KFBMYMUINWmSo/JXaMt3qI61BFtS0VENzeL1ay64yDdRAQ/ytO6pk2Huheqz 9nt/Y9YWr9H9xrRc2rBPjrsRFK1MSIjKZYMQzRFV3vsPy5R/FulRPJPl8VAh7fwSrAnv AE4ZUj8Qv+ICebs19PS9Hb9lmdk5WmljOVI6cQvu3YQR2be/NXSsp8y/Ux419k+YiTmX 0RWNQ5hW52GOHN9W+OMzTzi2BXpOOMVnE8Z1MeqbkwL7QJtmce0qdzbhjA1Ky7QXKJAC OgKQ== X-Gm-Message-State: AOAM531Kk3/ruSHJ5bejt+H0J+MXucqyf9n7B4B/ZF5oLfxVuBbnU2xJ BWQaO90G7UFwNK+rkxV3hN5OK9mqzdUqdg== X-Google-Smtp-Source: ABdhPJwbbv//1scQfVLm3vOrCpuMxu7b7wDReyfu8UbRGWmlR1q2zm50Y30YL+bs72BzG6PuBwfckA== X-Received: by 2002:a17:902:7b83:: with SMTP id w3mr2522977pll.28.1598984435561; Tue, 01 Sep 2020 11:20:35 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id j81sm2747086pfd.213.2020.09.01.11.20.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 11:20:34 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v2 net-next 4/6] ionic: clean adminq service routine Date: Tue, 1 Sep 2020 11:20:22 -0700 Message-Id: <20200901182024.64101-5-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901182024.64101-1-snelson@pensando.io> References: <20200901182024.64101-1-snelson@pensando.io> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The only thing calling ionic_napi any more is the adminq processing, so combine and simplify. Co-developed-by: Neel Patel Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic.h | 3 -- .../net/ethernet/pensando/ionic/ionic_lif.c | 44 +++++++++++-------- .../net/ethernet/pensando/ionic/ionic_main.c | 26 ----------- 3 files changed, 25 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic.h b/drivers/net/ethernet/pensando/ionic/ionic.h index f699ed19eb4f..084a924431d5 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic.h +++ b/drivers/net/ethernet/pensando/ionic/ionic.h @@ -64,9 +64,6 @@ struct ionic_admin_ctx { union ionic_adminq_comp comp; }; -int ionic_napi(struct napi_struct *napi, int budget, ionic_cq_cb cb, - ionic_cq_done_cb done_cb, void *done_arg); - int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx); int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait); int ionic_set_dma_mask(struct ionic *ionic); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index eeaa73650986..ee683cb142a8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -800,21 +800,6 @@ static bool ionic_notifyq_service(struct ionic_cq *cq, return true; } -static int ionic_notifyq_clean(struct ionic_lif *lif, int budget) -{ - struct ionic_dev *idev = &lif->ionic->idev; - struct ionic_cq *cq = &lif->notifyqcq->cq; - u32 work_done; - - work_done = ionic_cq_service(cq, budget, ionic_notifyq_service, - NULL, NULL); - if (work_done) - ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index, - work_done, IONIC_INTR_CRED_RESET_COALESCE); - - return work_done; -} - static bool ionic_adminq_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info) { @@ -830,15 +815,36 @@ static bool ionic_adminq_service(struct ionic_cq *cq, static int ionic_adminq_napi(struct napi_struct *napi, int budget) { + struct ionic_intr_info *intr = napi_to_cq(napi)->bound_intr; struct ionic_lif *lif = napi_to_cq(napi)->lif; + struct ionic_dev *idev = &lif->ionic->idev; + unsigned int flags = 0; int n_work = 0; int a_work = 0; + int work_done; + + if (lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED) + n_work = ionic_cq_service(&lif->notifyqcq->cq, budget, + ionic_notifyq_service, NULL, NULL); - if (likely(lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED)) - n_work = ionic_notifyq_clean(lif, budget); - a_work = ionic_napi(napi, budget, ionic_adminq_service, NULL, NULL); + if (lif->adminqcq && lif->adminqcq->flags & IONIC_QCQ_F_INITED) + a_work = ionic_cq_service(&lif->adminqcq->cq, budget, + ionic_adminq_service, NULL, NULL); + + work_done = max(n_work, a_work); + if (work_done < budget && napi_complete_done(napi, work_done)) { + flags |= IONIC_INTR_CRED_UNMASK; + DEBUG_STATS_INTR_REARM(intr); + } - return max(n_work, a_work); + if (work_done || flags) { + flags |= IONIC_INTR_CRED_RESET_COALESCE; + ionic_intr_credits(idev->intr_ctrl, + intr->index, + n_work + a_work, flags); + } + + return work_done; } void ionic_get_stats64(struct net_device *netdev, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 2b72a51be1d0..cfb90bf605fe 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -305,32 +305,6 @@ int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx) return ionic_adminq_check_err(lif, ctx, (remaining == 0)); } -int ionic_napi(struct napi_struct *napi, int budget, ionic_cq_cb cb, - ionic_cq_done_cb done_cb, void *done_arg) -{ - struct ionic_qcq *qcq = napi_to_qcq(napi); - struct ionic_cq *cq = &qcq->cq; - u32 work_done, flags = 0; - - work_done = ionic_cq_service(cq, budget, cb, done_cb, done_arg); - - if (work_done < budget && napi_complete_done(napi, work_done)) { - flags |= IONIC_INTR_CRED_UNMASK; - DEBUG_STATS_INTR_REARM(cq->bound_intr); - } - - if (work_done || flags) { - flags |= IONIC_INTR_CRED_RESET_COALESCE; - ionic_intr_credits(cq->lif->ionic->idev.intr_ctrl, - cq->bound_intr->index, - work_done, flags); - } - - DEBUG_STATS_NAPI_POLL(qcq, work_done); - - return work_done; -} - static void ionic_dev_cmd_clean(struct ionic *ionic) { union ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs;