From patchwork Tue Sep 1 21:51:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Awogbemila X-Patchwork-Id: 261669 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_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 57A5BC433E6 for ; Tue, 1 Sep 2020 21:52:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2141C206FA for ; Tue, 1 Sep 2020 21:52:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="hB3MqYsB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729305AbgIAVwF (ORCPT ); Tue, 1 Sep 2020 17:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgIAVwB (ORCPT ); Tue, 1 Sep 2020 17:52:01 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E88DC061245 for ; Tue, 1 Sep 2020 14:52:00 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id x10so2663955ybj.19 for ; Tue, 01 Sep 2020 14:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=YBDBTYJyAAyHSIMfe7u64IQoZsgba0wVm0w4On0MyKI=; b=hB3MqYsBs7cw/1Ipshxwo2lyNYatyRkdhq/cgNhag9zfjGsHTfzQVndgM7pF/RHhE7 BZ/yHS19zCQJ8hXCk6m6mfl55T/GQClu56RJtzi+y5l3i6rEjeV8+8lh84iWXcvo1YaZ RYhxvYyFYogxqRAmlIbzpR9u3XNK0bqGRZ4B0ikukCzQ2sbxrzulflng/KZq7ioDycZM xfdYd97akpmbmWkPAm1jIJ7cY/GMyWOZvh7HJzlsdDxvsQ1ls1NAf9g+XT+pl4nTQgzd UKI1fryC51bRCA5l9FSRjbVDDZCx18N6LxtbF9TMrQlQ7dc+enad15zwqKYX5PddhIf1 YUkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YBDBTYJyAAyHSIMfe7u64IQoZsgba0wVm0w4On0MyKI=; b=pGtMd91MSO2zD6pAf6ESQFnpSc+1GtkdQZAKxMWLAAJadv1Ru3We7ZWyyJk4CZAqQN 0xgALGT8yjjOJ6O080mQAFuZLuwyZTSJ2Wng/KGpJGAQ2araqlM+LZuEynZpSeX2tku/ Jqji+mD79FjnCnwyw4tIVzC8Juc3zM597+9CIeYNDYMN6Xlp+2lM4mqJL4hS0ooYKU+i Fv0+48MX0xV3KcBgrZrh7KIOnJrOKt6uPOTud0EMV7/JenbIvNN2wY+wSeOCml9LBph9 xgkhDbJQ0PvJvpdMPrk8JL1T6mb/4yAkbUL1FJPmeGoOlsmAMS/AuDUGxf5c2CIWoFij vkkQ== X-Gm-Message-State: AOAM533cEEzQhg+Aj3N7dMNpdBgmihJBE9/DjzfrrQFJWwe7NSkQ7Trn kGyPbTc9/Iu8ZcvQgmoJM1W5mMA+mFF9edDpumeQkEfgpobZOsI8nPFOdF3CgsN9+cFmPt9dD0+ uxScZLkn8bwwSj1XUKDLYtioH+WZ3TCauO3GPKi8aFj9vmEt7H9r0O8cJk/+nhOOmkuS0DQQX X-Google-Smtp-Source: ABdhPJyf4yi7uQ4xUkuRMAoPEU+A59shwoVs9toIGPiSMbCERQemo5tki7J0Ngsh5KLxzvjL/+rlOiWnaFF18jxv X-Received: from awogbemila.sea.corp.google.com ([2620:15c:100:202:1ea0:b8ff:fe73:6cc0]) (user=awogbemila job=sendgmr) by 2002:a25:5755:: with SMTP id l82mr6008189ybb.175.1598997118828; Tue, 01 Sep 2020 14:51:58 -0700 (PDT) Date: Tue, 1 Sep 2020 14:51:41 -0700 In-Reply-To: <20200901215149.2685117-1-awogbemila@google.com> Message-Id: <20200901215149.2685117-2-awogbemila@google.com> Mime-Version: 1.0 References: <20200901215149.2685117-1-awogbemila@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH net-next v2 1/9] gve: Get and set Rx copybreak via ethtool From: David Awogbemila To: netdev@vger.kernel.org Cc: Kuo Zhao , Yangchun Fu , David Awogbemila Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Kuo Zhao This adds support for getting and setting the RX copybreak value via ethtool. Reviewed-by: Yangchun Fu Signed-off-by: Kuo Zhao Signed-off-by: David Awogbemila --- drivers/net/ethernet/google/gve/gve_ethtool.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c index d8fa816f4473..1a80d38e66ec 100644 --- a/drivers/net/ethernet/google/gve/gve_ethtool.c +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c @@ -230,6 +230,38 @@ static int gve_user_reset(struct net_device *netdev, u32 *flags) return -EOPNOTSUPP; } +static int gve_get_tunable(struct net_device *netdev, + const struct ethtool_tunable *etuna, void *value) +{ + struct gve_priv *priv = netdev_priv(netdev); + + switch (etuna->id) { + case ETHTOOL_RX_COPYBREAK: + *(u32 *)value = priv->rx_copybreak; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int gve_set_tunable(struct net_device *netdev, + const struct ethtool_tunable *etuna, const void *value) +{ + struct gve_priv *priv = netdev_priv(netdev); + u32 len; + + switch (etuna->id) { + case ETHTOOL_RX_COPYBREAK: + len = *(u32 *)value; + if (len > PAGE_SIZE / 2) + return -EINVAL; + priv->rx_copybreak = len; + return 0; + default: + return -EOPNOTSUPP; + } +} + const struct ethtool_ops gve_ethtool_ops = { .get_drvinfo = gve_get_drvinfo, .get_strings = gve_get_strings, @@ -242,4 +274,6 @@ const struct ethtool_ops gve_ethtool_ops = { .get_link = ethtool_op_get_link, .get_ringparam = gve_get_ringparam, .reset = gve_user_reset, + .get_tunable = gve_get_tunable, + .set_tunable = gve_set_tunable, }; From patchwork Tue Sep 1 21:51:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Awogbemila X-Patchwork-Id: 261667 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_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 481E8C433E2 for ; Tue, 1 Sep 2020 21:52:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11CC2206FA for ; Tue, 1 Sep 2020 21:52:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qRBVToSZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729673AbgIAVwR (ORCPT ); Tue, 1 Sep 2020 17:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728802AbgIAVwE (ORCPT ); Tue, 1 Sep 2020 17:52:04 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F16C061244 for ; Tue, 1 Sep 2020 14:52:04 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id mu14so1132139pjb.7 for ; Tue, 01 Sep 2020 14:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=MPnRJ02GXcB1odHc4kcWJHJj72ELeZL12/LRGhlXO+U=; b=qRBVToSZfxNMEyfWWSIskImVuySB8g67Eb7zRAQTcCDaaIlUt5Zu4RbT/hBp1rqZvF 30MRkG2njqcJmm9ijRFjcsi8aXDYi3keFLMePQaQAtneawGSsJsigyW5D6F3XCUX1RW2 qD8siljKgA/ejJps++ABrv+a50r9vdLJWFGpkHtyll2aHoulqIHgvu6GXIJPAMmr9qY0 Lb9+lBd6mObbloeFLifYmP+XQ9UK85qc2RrZkfh/K3x404fSqcSSNzpj66tjggTUCtvI 1EMFTklY9u3yFK8i3xFbztJzAjrektSvQabr0sknQdtjDWL7a8OwxO0iNazDfHt7yeHP Ejyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MPnRJ02GXcB1odHc4kcWJHJj72ELeZL12/LRGhlXO+U=; b=DXSbOGn9MW59FF3oDkvHwc5Xg2tgrkHs9tllu4BVWTutISiXfEXN49OpJ2ctBisesF xPtTbNaxahYUyibnWepAKqlxWS5P7Hkf0/Onx6pt9dxr9aKokU9UBqIzuKZ8ESUEPp0v rPd9/m+c8dMdNqipb3cPEqa1qCuf+yC/rpyVxge/csStbuZeyaV5bt8SlTkSy5CWTsPf nMe6CA4bqSazHvI0Le9JmaqU4D+1zpJwU87H7YwGTdczLubjVCvEQndvsTlpzDlkJbWy VbJYF0n7LEHm5Fa46Aoj/zLwVC9Ok7FyQht1GGBCPL47pjiq1ZemvCtRzBSQS42YiypS Vt2w== X-Gm-Message-State: AOAM530/MuNYtfZyi4kzVM2kjbkYrj5mTMx5+iWCDOTQyN6bVtAZieBc tg1BNNUIVPeKcegfAzKkhs9nngT1sRDAyp8FgCVu8UtB9QtgwNe6aBER+9k50Rlyuq6piyEXiYc ZWUwKdml71Yi7gvSIMuFuc+TJrEOkhMH5Iw6zJusBGh+SEohNz1SnJCdiEWQkkj/0S+ywGm0e X-Google-Smtp-Source: ABdhPJybTnBmQYOME4o5MQlGsHvt8TUROxTdAu5pz2MdMd1iFBW1+jqbaGsXALnGUdIaaBNNSQ8wBLA4himo/BT9 X-Received: from awogbemila.sea.corp.google.com ([2620:15c:100:202:1ea0:b8ff:fe73:6cc0]) (user=awogbemila job=sendgmr) by 2002:a62:7c43:0:b029:139:858b:8033 with SMTP id x64-20020a627c430000b0290139858b8033mr3845788pfc.3.1598997123848; Tue, 01 Sep 2020 14:52:03 -0700 (PDT) Date: Tue, 1 Sep 2020 14:51:44 -0700 In-Reply-To: <20200901215149.2685117-1-awogbemila@google.com> Message-Id: <20200901215149.2685117-5-awogbemila@google.com> Mime-Version: 1.0 References: <20200901215149.2685117-1-awogbemila@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH net-next v2 4/9] gve: Add support for dma_mask register From: David Awogbemila To: netdev@vger.kernel.org Cc: Catherine Sullivan , Yangchun Fu , David Awogbemila Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Catherine Sullivan Add the dma_mask register and read it to set the dma_masks. gve_alloc_page will alloc_page with: GFP_DMA if priv->dma_mask is 24, GFP_DMA32 if priv->dma_mask is 32. Reviewed-by: Yangchun Fu Signed-off-by: Catherine Sullivan Signed-off-by: David Awogbemila --- drivers/net/ethernet/google/gve/gve.h | 6 ++- drivers/net/ethernet/google/gve/gve_main.c | 42 ++++++++++++------- .../net/ethernet/google/gve/gve_register.h | 3 +- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h index 55b34b437764..37a3bbced36a 100644 --- a/drivers/net/ethernet/google/gve/gve.h +++ b/drivers/net/ethernet/google/gve/gve.h @@ -232,6 +232,9 @@ struct gve_priv { struct work_struct service_task; unsigned long service_task_flags; unsigned long state_flags; + + /* Gvnic device's dma mask, set during probe. */ + u8 dma_mask; }; enum gve_service_task_flags { @@ -451,8 +454,7 @@ static inline bool gve_can_recycle_pages(struct net_device *dev) } /* buffers */ -int gve_alloc_page(struct gve_priv *priv, struct device *dev, - struct page **page, dma_addr_t *dma, +int gve_alloc_page(struct gve_priv *priv, struct device *dev, struct page **page, dma_addr_t *dma, enum dma_data_direction); void gve_free_page(struct device *dev, struct page *page, dma_addr_t dma, enum dma_data_direction); diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c index a0b8c1e8ed98..b176fcef19de 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c @@ -518,7 +518,14 @@ int gve_alloc_page(struct gve_priv *priv, struct device *dev, struct page **page, dma_addr_t *dma, enum dma_data_direction dir) { - *page = alloc_page(GFP_KERNEL); + gfp_t gfp_flags = GFP_KERNEL; + + if (priv->dma_mask == 24) + gfp_flags |= GFP_DMA; + else if (priv->dma_mask == 32) + gfp_flags |= GFP_DMA32; + + *page = alloc_page(gfp_flags); if (!*page) { priv->page_alloc_fail++; return -ENOMEM; @@ -1083,6 +1090,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) __be32 __iomem *db_bar; struct gve_registers __iomem *reg_bar; struct gve_priv *priv; + u8 dma_mask; int err; err = pci_enable_device(pdev); @@ -1095,19 +1103,6 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_master(pdev); - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); - if (err) { - dev_err(&pdev->dev, "Failed to set dma mask: err=%d\n", err); - goto abort_with_pci_region; - } - - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); - if (err) { - dev_err(&pdev->dev, - "Failed to set consistent dma mask: err=%d\n", err); - goto abort_with_pci_region; - } - reg_bar = pci_iomap(pdev, GVE_REGISTER_BAR, 0); if (!reg_bar) { dev_err(&pdev->dev, "Failed to map pci bar!\n"); @@ -1122,10 +1117,28 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto abort_with_reg_bar; } + dma_mask = readb(®_bar->dma_mask); + // Default to 64 if the register isn't set + if (!dma_mask) + dma_mask = 64; gve_write_version(®_bar->driver_version); /* Get max queues to alloc etherdev */ max_rx_queues = ioread32be(®_bar->max_tx_queues); max_tx_queues = ioread32be(®_bar->max_rx_queues); + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); + if (err) { + dev_err(&pdev->dev, "Failed to set dma mask: err=%d\n", err); + goto abort_with_reg_bar; + } + + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); + if (err) { + dev_err(&pdev->dev, + "Failed to set consistent dma mask: err=%d\n", err); + goto abort_with_reg_bar; + } + /* Alloc and setup the netdev and priv */ dev = alloc_etherdev_mqs(sizeof(*priv), max_tx_queues, max_rx_queues); if (!dev) { @@ -1160,6 +1173,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) priv->db_bar2 = db_bar; priv->service_task_flags = 0x0; priv->state_flags = 0x0; + priv->dma_mask = dma_mask; gve_set_probe_in_progress(priv); diff --git a/drivers/net/ethernet/google/gve/gve_register.h b/drivers/net/ethernet/google/gve/gve_register.h index 84ab8893aadd..fad8813d1bb1 100644 --- a/drivers/net/ethernet/google/gve/gve_register.h +++ b/drivers/net/ethernet/google/gve/gve_register.h @@ -16,7 +16,8 @@ struct gve_registers { __be32 adminq_pfn; __be32 adminq_doorbell; __be32 adminq_event_counter; - u8 reserved[3]; + u8 reserved[2]; + u8 dma_mask; u8 driver_version; }; From patchwork Tue Sep 1 21:51:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Awogbemila X-Patchwork-Id: 261666 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_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 76573C433E2 for ; Tue, 1 Sep 2020 21:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C4BE206FA for ; Tue, 1 Sep 2020 21:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="lt2nq6eG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729759AbgIAVwZ (ORCPT ); Tue, 1 Sep 2020 17:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727946AbgIAVwI (ORCPT ); Tue, 1 Sep 2020 17:52:08 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C91CC061245 for ; Tue, 1 Sep 2020 14:52:08 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id j20so2704905ybt.10 for ; Tue, 01 Sep 2020 14:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=c20ktH6NmViBNAmU75r3cg0aTyG4UTJz4SQKC6m12jk=; b=lt2nq6eGWWdymykMHQ5DOmFQG5Q6XG3eSBSqqh/wavQqePoE48wAh8rtlP+bgRY6rK 6GfgB7CyKx+DApz3XdEFZtHZrS9Y/h2Ae4Rsk9djLLte+Q9sB/jG76Lh6mPfAGP1+4ks BJvHVKELX5Kam4X7yhpHMqr+3ZYmZSCEUB8cteCST2ooo1cRvtZYgIJ+hv6ApMhC1U9Y txT/DbnDlmOwPqdAZpPLd8tGmq0R7z+ByE1KaFkWtg3bnKTDAMBUa79ceVxdYyb+U/ML 8lv0/l0bvtfddZrI6ZHTqLUNrGgueewXjjLMGButB+Hg2QNRiu9BXTOfk7onfADmEGB9 VJQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=c20ktH6NmViBNAmU75r3cg0aTyG4UTJz4SQKC6m12jk=; b=LC9IAsaOT+2bn1j+f9Fnq4m+j87PZhj3/Hte0CJJ3EN2cNP3v4o0r9DACHTGkevqNg M3cry0NCA/C9flsdmFrH7U6WxIt7Cwdj3/Wg3xQaGT5EEuQiNNbbuZJ0q9Bj5ePGqWhL yi5nIKN1cg9hy/6b5umRkIHSk3x9pie04KlcJo0tuUo0BbHtd+pp5DOu5LsKa+UOAaIo lZFdscOMwYKjRnBF7gdh38YtMXX9Mb+78/FgJo8xe/1GfCRjUTSZFneSlbDSaPp6/+9u 3tcG7k53XnpRz8R88mB4DhpN24A7DMbLcsE0/KOTG9fhfU/ry68ih2kWz9j9LHuYWZPn MyiQ== X-Gm-Message-State: AOAM5327roSLpbGS/tiZ7zKblWTJ+kZ/WNqdNO3LViP4BejPcxLxGijF RgSy4BXexf+FTro0CuUmx0FGacMN+NvIeZEN3Qp6hf3fF7R4HqoA5PW0t58UPJEDfjFtBVFqOJQ 46L1pr89BeAtqqv1E9mZnagm/Yd91g2PL338Xdb4NyyRC10aWb+Aa5Hq9DDP14SyHGEay9QnD X-Google-Smtp-Source: ABdhPJz7dJDsRcYmnipGrb2aoIM3GSEb7unIJ711RdZSF46jnA3PQKFR4X2NK8AWo/p3JiFHbrL2XK0hG37dd+Ck X-Received: from awogbemila.sea.corp.google.com ([2620:15c:100:202:1ea0:b8ff:fe73:6cc0]) (user=awogbemila job=sendgmr) by 2002:a25:2e12:: with SMTP id u18mr5295029ybu.437.1598997127259; Tue, 01 Sep 2020 14:52:07 -0700 (PDT) Date: Tue, 1 Sep 2020 14:51:46 -0700 In-Reply-To: <20200901215149.2685117-1-awogbemila@google.com> Message-Id: <20200901215149.2685117-7-awogbemila@google.com> Mime-Version: 1.0 References: <20200901215149.2685117-1-awogbemila@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH net-next v2 6/9] gve: NIC stats for report-stats and for ethtool From: David Awogbemila To: netdev@vger.kernel.org Cc: David Awogbemila Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This adds per queue NIC stats to ethtool stats and to report-stats. These stats are always exposed to guest whether or not the report-stats flag is turned on. Signed-off-by: David Awogbemila --- drivers/net/ethernet/google/gve/gve.h | 4 + drivers/net/ethernet/google/gve/gve_adminq.h | 5 ++ drivers/net/ethernet/google/gve/gve_ethtool.c | 83 ++++++++++++++++++- drivers/net/ethernet/google/gve/gve_main.c | 4 +- 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h index 9957a7d535ad..bc54059f9b2e 100644 --- a/drivers/net/ethernet/google/gve/gve.h +++ b/drivers/net/ethernet/google/gve/gve.h @@ -31,6 +31,10 @@ #define GVE_TX_STATS_REPORT_NUM 5 #define GVE_RX_STATS_REPORT_NUM 2 +/* Numbers of NIC tx/rx stats in stats report. */ +#define NIC_TX_STATS_REPORT_NUM 0 +#define NIC_RX_STATS_REPORT_NUM 4 + /* Interval to schedule a service task, 20000ms. */ #define GVE_SERVICE_TIMER_PERIOD 20000 diff --git a/drivers/net/ethernet/google/gve/gve_adminq.h b/drivers/net/ethernet/google/gve/gve_adminq.h index b81a3bb76d5e..a6c8c29f0d13 100644 --- a/drivers/net/ethernet/google/gve/gve_adminq.h +++ b/drivers/net/ethernet/google/gve/gve_adminq.h @@ -205,6 +205,11 @@ enum gve_stat_names { TX_LAST_COMPLETION_PROCESSED = 5, RX_NEXT_EXPECTED_SEQUENCE = 6, RX_BUFFERS_POSTED = 7, + // stats from NIC + RX_QUEUE_DROP_CNT = 65, + RX_NO_BUFFERS_POSTED = 66, + RX_DROPS_PACKET_OVER_MRU = 67, + RX_DROPS_INVALID_CHECKSUM = 68, }; union gve_adminq_command { diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c index 8d70df2447ef..db5642fe966f 100644 --- a/drivers/net/ethernet/google/gve/gve_ethtool.c +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c @@ -43,6 +43,8 @@ static const char gve_gstrings_main_stats[][ETH_GSTRING_LEN] = { static const char gve_gstrings_rx_stats[][ETH_GSTRING_LEN] = { "rx_posted_desc[%u]", "rx_completed_desc[%u]", "rx_bytes[%u]", "rx_dropped_pkt[%u]", "rx_copybreak_pkt[%u]", "rx_copied_pkt[%u]", + "rx_queue_drop_cnt[%u]", "rx_no_buffers_posted[%u]", + "rx_drops_packet_over_mru[%u]", "rx_drops_invalid_checksum[%u]", }; static const char gve_gstrings_tx_stats[][ETH_GSTRING_LEN] = { @@ -138,14 +140,30 @@ gve_get_ethtool_stats(struct net_device *netdev, tmp_rx_desc_err_dropped_pkt, tmp_tx_pkts, tmp_tx_bytes; u64 rx_buf_alloc_fail, rx_desc_err_dropped_pkt, rx_pkts, rx_skb_alloc_fail, rx_bytes, tx_pkts, tx_bytes; + int stats_idx, base_stats_idx, max_stats_idx; + struct stats *report_stats; + int *rx_qid_to_stats_idx; + int *tx_qid_to_stats_idx; struct gve_priv *priv; + bool skip_nic_stats; unsigned int start; int ring; - int i; + int i, j; ASSERT_RTNL(); priv = netdev_priv(netdev); + report_stats = priv->stats_report->stats; + rx_qid_to_stats_idx = kmalloc_array(priv->rx_cfg.num_queues, + sizeof(int), GFP_KERNEL); + if (!rx_qid_to_stats_idx) + return; + tx_qid_to_stats_idx = kmalloc_array(priv->tx_cfg.num_queues, + sizeof(int), GFP_KERNEL); + if (!tx_qid_to_stats_idx) { + kfree(rx_qid_to_stats_idx); + return; + } for (rx_pkts = 0, rx_bytes = 0, rx_skb_alloc_fail = 0, rx_buf_alloc_fail = 0, rx_desc_err_dropped_pkt = 0, ring = 0; ring < priv->rx_cfg.num_queues; ring++) { @@ -206,6 +224,25 @@ gve_get_ethtool_stats(struct net_device *netdev, data[i++] = priv->dma_mapping_error; i = GVE_MAIN_STATS_LEN; + /* For rx cross-reporting stats, start from nic rx stats in report */ + base_stats_idx = GVE_TX_STATS_REPORT_NUM * priv->tx_cfg.num_queues + + GVE_RX_STATS_REPORT_NUM * priv->rx_cfg.num_queues; + max_stats_idx = NIC_RX_STATS_REPORT_NUM * priv->rx_cfg.num_queues + + base_stats_idx; + /* Preprocess the stats report for rx, map queue id to start index */ + skip_nic_stats = false; + for (stats_idx = base_stats_idx; stats_idx < max_stats_idx; + stats_idx += NIC_RX_STATS_REPORT_NUM) { + u32 stat_name = be32_to_cpu(report_stats[stats_idx].stat_name); + u32 queue_id = be32_to_cpu(report_stats[stats_idx].queue_id); + + if (stat_name == 0) { + /* no stats written by NIC yet */ + skip_nic_stats = true; + break; + } + rx_qid_to_stats_idx[queue_id] = stats_idx; + } /* walk RX rings */ if (priv->rx) { for (ring = 0; ring < priv->rx_cfg.num_queues; ring++) { @@ -230,11 +267,41 @@ gve_get_ethtool_stats(struct net_device *netdev, tmp_rx_desc_err_dropped_pkt; data[i++] = rx->rx_copybreak_pkt; data[i++] = rx->rx_copied_pkt; + /* stats from NIC */ + if (skip_nic_stats) { + /* skip NIC rx stats */ + i += NIC_RX_STATS_REPORT_NUM; + continue; + } + for (j = 0; j < NIC_RX_STATS_REPORT_NUM; j++) { + u64 value = + be64_to_cpu(report_stats[rx_qid_to_stats_idx[ring] + j].value); + + data[i++] = value; + } } } else { i += priv->rx_cfg.num_queues * NUM_GVE_RX_CNTS; } + /* For tx cross-reporting stats, start from nic tx stats in report */ + base_stats_idx = max_stats_idx; + max_stats_idx = NIC_TX_STATS_REPORT_NUM * priv->tx_cfg.num_queues + + max_stats_idx; + /* Preprocess the stats report for tx, map queue id to start index */ + skip_nic_stats = false; + for (stats_idx = base_stats_idx; stats_idx < max_stats_idx; + stats_idx += NIC_TX_STATS_REPORT_NUM) { + u32 stat_name = be32_to_cpu(report_stats[stats_idx].stat_name); + u32 queue_id = be32_to_cpu(report_stats[stats_idx].queue_id); + + if (stat_name == 0) { + /* no stats written by NIC yet */ + skip_nic_stats = true; + break; + } + tx_qid_to_stats_idx[queue_id] = stats_idx; + } /* walk TX rings */ if (priv->tx) { for (ring = 0; ring < priv->tx_cfg.num_queues; ring++) { @@ -253,11 +320,25 @@ gve_get_ethtool_stats(struct net_device *netdev, data[i++] = tx->stop_queue; data[i++] = be32_to_cpu(gve_tx_load_event_counter(priv, tx)); + /* stats from NIC */ + if (skip_nic_stats) { + /* skip NIC tx stats */ + i += NIC_TX_STATS_REPORT_NUM; + continue; + } + for (j = 0; j < NIC_TX_STATS_REPORT_NUM; j++) { + u64 value = + be64_to_cpu(report_stats[tx_qid_to_stats_idx[ring] + j].value); + data[i++] = value; + } } } else { i += priv->tx_cfg.num_queues * NUM_GVE_TX_CNTS; } + kfree(rx_qid_to_stats_idx); + kfree(tx_qid_to_stats_idx); + /* AQ Stats */ data[i++] = priv->adminq_prod_cnt; data[i++] = priv->adminq_cmd_fail; diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c index b76fc547cf5d..0c94dda67ba4 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c @@ -101,9 +101,9 @@ static int gve_alloc_stats_report(struct gve_priv *priv) { int tx_stats_num, rx_stats_num; - tx_stats_num = (GVE_TX_STATS_REPORT_NUM) * + tx_stats_num = (GVE_TX_STATS_REPORT_NUM + NIC_TX_STATS_REPORT_NUM) * priv->tx_cfg.num_queues; - rx_stats_num = (GVE_RX_STATS_REPORT_NUM) * + rx_stats_num = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) * priv->rx_cfg.num_queues; priv->stats_report_len = sizeof(struct gve_stats_report) + (tx_stats_num + rx_stats_num) * From patchwork Tue Sep 1 21:51:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Awogbemila X-Patchwork-Id: 261665 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_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 2A579C433E7 for ; Tue, 1 Sep 2020 21:52:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5D46206FA for ; Tue, 1 Sep 2020 21:52:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="YQ8ryqvG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729840AbgIAVw0 (ORCPT ); Tue, 1 Sep 2020 17:52:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729520AbgIAVwN (ORCPT ); Tue, 1 Sep 2020 17:52:13 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0881FC061244 for ; Tue, 1 Sep 2020 14:52:13 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id y13so1311279plr.1 for ; Tue, 01 Sep 2020 14:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=CZOU5zNBV7YhreEpl/ZEvsx5azVAeeK7Om2FNRiEDWc=; b=YQ8ryqvG4mlgnTuOKdOdPXJiTFgnoYN/VnEpah/ALSxc2cpBcRZ/TJ8sh/MODzz50n 6gAlb4xtoATrwCMvTpJRmksBCO6h+px6J/+kmv3wIAPpaeskfpxAVoumjccEpQsm7C6e 13NVTr7FAsFuUyFDwsdyN2e+17+rY5+bKjXyF54W7qdQxFIwwp2fXXAzGFFjBP0u8val 8uo3m0Nsl8dU9vjHPL6ar8PDo7h7d8qsI0HZq5EQmWaQSy+P4IpJ1EhOtLqpnjSWDSI9 I8azsIzhd7b2RBnrjXUlN88mh2P4CIxknTsWenPqn1phJKv+SDuR26IJrPfcvG6H7sG+ HIDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CZOU5zNBV7YhreEpl/ZEvsx5azVAeeK7Om2FNRiEDWc=; b=lZuJMeV+sa5oX7wfkPeiwk1raFnf+csBq9jXqC9z/E1EcxIXLcjN3s+Nsot/gaHWwZ 9bZVeyO9XBlHCGhTB8TIk+XxBjBrcvGBtARdhw4FGI6LoYnypjj3QXJPL6By4WkLpabJ ANIRuzrKd7s/htBawa0O1R9+HrkVouAOPxGA0iH6uU4chpurW61uGJHx2j8UoH3j0AEh ya3fhuCryjp+5igsnbP1jPuIG8s/9ARxJRw2RpzB2DT7VxoYgm1EhPK8Y/OHT0sQU2Ea bUoaGOhm0GnPVGAEf3Mwe6+Lwtny85k2WDiwxm+hy1Z+kHL0lT0PVo6fnZ6UD6W/xLvc II1g== X-Gm-Message-State: AOAM533lfezSeY9NCE5lCHjSuRoz/zo0TGPTQJLc75fHk/Vjudpd1cZ/ ZzMfFvgwTPoPKI62Ro8HIrDUkT/3wqTJo2JAAdkOCp99RH/BkCUk62brYmh/hKCwmamJzSUeEEx nxpPYiyjwrS3wkCwZPbJvhqc3XVDyjzCJOW14Cb/3Oh/Xum5KzTnUAwqHfrU75OnGSSy4bPEK X-Google-Smtp-Source: ABdhPJytCp2/XLOMlTBB0VJ/Wj4TJc3zYWe3phfQndPbuJOkHSjFr8IdVzPN8Ik+AU5QOgCKwVpkgkPpH0/SxxXc X-Received: from awogbemila.sea.corp.google.com ([2620:15c:100:202:1ea0:b8ff:fe73:6cc0]) (user=awogbemila job=sendgmr) by 2002:a17:90b:4b89:: with SMTP id lr9mr3542807pjb.126.1598997132456; Tue, 01 Sep 2020 14:52:12 -0700 (PDT) Date: Tue, 1 Sep 2020 14:51:49 -0700 In-Reply-To: <20200901215149.2685117-1-awogbemila@google.com> Message-Id: <20200901215149.2685117-10-awogbemila@google.com> Mime-Version: 1.0 References: <20200901215149.2685117-1-awogbemila@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH net-next v2 9/9] gve: Enable Link Speed Reporting in the driver. From: David Awogbemila To: netdev@vger.kernel.org Cc: David Awogbemila , Yangchun Fu Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This change allows the driver to report the device link speed when the ethtool command: ethtool is run. Getting the link speed is done via a new admin queue command: ReportLinkSpeed. Reviewed-by: Yangchun Fu Signed-off-by: David Awogbemila --- drivers/net/ethernet/google/gve/gve.h | 4 +++ drivers/net/ethernet/google/gve/gve_adminq.c | 31 +++++++++++++++++++ drivers/net/ethernet/google/gve/gve_adminq.h | 9 ++++++ drivers/net/ethernet/google/gve/gve_ethtool.c | 14 ++++++++- 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h index bc54059f9b2e..4a8d77013ebe 100644 --- a/drivers/net/ethernet/google/gve/gve.h +++ b/drivers/net/ethernet/google/gve/gve.h @@ -232,6 +232,7 @@ struct gve_priv { u32 adminq_dcfg_device_resources_cnt; u32 adminq_set_driver_parameter_cnt; u32 adminq_report_stats_cnt; + u32 adminq_report_link_speed_cnt; /* Global stats */ u32 interface_up_cnt; /* count of times interface turned up since last reset */ @@ -252,6 +253,9 @@ struct gve_priv { unsigned long service_timer_period; struct timer_list service_timer; + /* Gvnic device link speed from hypervisor. */ + u64 link_speed; + /* Gvnic device's dma mask, set during probe. */ u8 dma_mask; }; diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c index 341a17b36f06..2372e18943b8 100644 --- a/drivers/net/ethernet/google/gve/gve_adminq.c +++ b/drivers/net/ethernet/google/gve/gve_adminq.c @@ -36,6 +36,7 @@ int gve_adminq_alloc(struct device *dev, struct gve_priv *priv) priv->adminq_dcfg_device_resources_cnt = 0; priv->adminq_set_driver_parameter_cnt = 0; priv->adminq_report_stats_cnt = 0; + priv->adminq_report_link_speed_cnt = 0; /* Setup Admin queue with the device */ iowrite32be(priv->adminq_bus_addr / PAGE_SIZE, @@ -238,6 +239,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv, case GVE_ADMINQ_REPORT_STATS: priv->adminq_report_stats_cnt++; break; + case GVE_ADMINQ_REPORT_LINK_SPEED: + priv->adminq_report_link_speed_cnt++; + break; default: dev_err(&priv->pdev->dev, "unknown AQ command opcode %d\n", opcode); } @@ -596,3 +600,30 @@ int gve_adminq_report_stats(struct gve_priv *priv, u64 stats_report_len, return gve_adminq_execute_cmd(priv, &cmd); } +int gve_adminq_report_link_speed(struct gve_priv *priv) +{ + union gve_adminq_command gvnic_cmd; + dma_addr_t link_speed_region_bus; + __be64 *link_speed_region; + int err; + + link_speed_region = + dma_alloc_coherent(&priv->pdev->dev, sizeof(*link_speed_region), + &link_speed_region_bus, GFP_KERNEL); + + if (!link_speed_region) + return -ENOMEM; + + memset(&gvnic_cmd, 0, sizeof(gvnic_cmd)); + gvnic_cmd.opcode = cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED); + gvnic_cmd.report_link_speed.link_speed_address = + cpu_to_be64(link_speed_region_bus); + + err = gve_adminq_execute_cmd(priv, &gvnic_cmd); + + priv->link_speed = be64_to_cpu(*link_speed_region); + dma_free_coherent(&priv->pdev->dev, sizeof(*link_speed_region), link_speed_region, + link_speed_region_bus); + return err; +} + diff --git a/drivers/net/ethernet/google/gve/gve_adminq.h b/drivers/net/ethernet/google/gve/gve_adminq.h index 784830f75b7c..281de8326bc5 100644 --- a/drivers/net/ethernet/google/gve/gve_adminq.h +++ b/drivers/net/ethernet/google/gve/gve_adminq.h @@ -22,6 +22,7 @@ enum gve_adminq_opcodes { GVE_ADMINQ_DECONFIGURE_DEVICE_RESOURCES = 0x9, GVE_ADMINQ_SET_DRIVER_PARAMETER = 0xB, GVE_ADMINQ_REPORT_STATS = 0xC, + GVE_ADMINQ_REPORT_LINK_SPEED = 0xD }; /* Admin queue status codes */ @@ -181,6 +182,12 @@ struct gve_adminq_report_stats { static_assert(sizeof(struct gve_adminq_report_stats) == 24); +struct gve_adminq_report_link_speed { + __be64 link_speed_address; +}; + +static_assert(sizeof(struct gve_adminq_report_link_speed) == 8); + struct stats { __be32 stat_name; __be32 queue_id; @@ -228,6 +235,7 @@ union gve_adminq_command { struct gve_adminq_unregister_page_list unreg_page_list; struct gve_adminq_set_driver_parameter set_driver_param; struct gve_adminq_report_stats report_stats; + struct gve_adminq_report_link_speed report_link_speed; }; }; u8 reserved[64]; @@ -255,4 +263,5 @@ int gve_adminq_unregister_page_list(struct gve_priv *priv, u32 page_list_id); int gve_adminq_set_mtu(struct gve_priv *priv, u64 mtu); int gve_adminq_report_stats(struct gve_priv *priv, u64 stats_report_len, dma_addr_t stats_report_addr, u64 interval); +int gve_adminq_report_link_speed(struct gve_priv *priv); #endif /* _GVE_ADMINQ_H */ diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c index db5642fe966f..4830c873cd78 100644 --- a/drivers/net/ethernet/google/gve/gve_ethtool.c +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c @@ -59,7 +59,7 @@ static const char gve_gstrings_adminq_stats[][ETH_GSTRING_LEN] = { "adminq_create_tx_queue_cnt", "adminq_create_rx_queue_cnt", "adminq_destroy_tx_queue_cnt", "adminq_destroy_rx_queue_cnt", "adminq_dcfg_device_resources_cnt", "adminq_set_driver_parameter_cnt", - "adminq_report_stats_cnt", + "adminq_report_stats_cnt", "adminq_report_link_speed_cnt" }; static const char gve_gstrings_priv_flags[][ETH_GSTRING_LEN] = { @@ -354,6 +354,7 @@ gve_get_ethtool_stats(struct net_device *netdev, data[i++] = priv->adminq_dcfg_device_resources_cnt; data[i++] = priv->adminq_set_driver_parameter_cnt; data[i++] = priv->adminq_report_stats_cnt; + data[i++] = priv->adminq_report_link_speed_cnt; } static void gve_get_channels(struct net_device *netdev, @@ -506,6 +507,16 @@ static int gve_set_priv_flags(struct net_device *netdev, u32 flags) return 0; } +static int gve_get_link_ksettings(struct net_device *netdev, + struct ethtool_link_ksettings *cmd) +{ + struct gve_priv *priv = netdev_priv(netdev); + int err = gve_adminq_report_link_speed(priv); + + cmd->base.speed = priv->link_speed; + return err; +} + const struct ethtool_ops gve_ethtool_ops = { .get_drvinfo = gve_get_drvinfo, .get_strings = gve_get_strings, @@ -522,4 +533,5 @@ const struct ethtool_ops gve_ethtool_ops = { .set_tunable = gve_set_tunable, .get_priv_flags = gve_get_priv_flags, .set_priv_flags = gve_set_priv_flags, + .get_link_ksettings = gve_get_link_ksettings };