From patchwork Mon Nov 11 02:55:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Lai X-Patchwork-Id: 13870196 X-Patchwork-Delegate: kuba@kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 274AF1448C7; Mon, 11 Nov 2024 02:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731293784; cv=none; b=ritaRBmPPgZ9vB6XZIUmhCOrmYrdi2mgzMf2O7BKlTyDxuuqSrsKFqd94psJ3hv5PlR/kTCzmHUlTGso9wWivWMihjyIcnJaexbEZVcyHTus4iMgnOH3MksoNn3+SwbUC/c4OS9Lwos0N3HAgiFm2ySAIkAjWNk80ICEAZsmD8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731293784; c=relaxed/simple; bh=6igfrVFofF6rOpqSFbTUsRguKoT1vFakecNmezLPA18=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=skwmjmk9Xt9fABXte41gPVOdaUHS8nRUTE0YipiIFBvUr+nNvd4GamQmqpXd+98KY6rDvsGpXNbsI2uIhrVDh47LSe5eqBEqTa1VizDgl+dGAK3muXvRjJSQxfFmvAp9YulqNZpR0+CokOxvdTez9x56x1uTuABuPoJ1K0YOZ8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; dkim=temperror (0-bit key) header.d=realtek.com header.i=@realtek.com header.b=WVIjjnYs; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=realtek.com header.i=@realtek.com header.b="WVIjjnYs" X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 4AB2u5EK11487655, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realtek.com; s=dkim; t=1731293765; bh=6igfrVFofF6rOpqSFbTUsRguKoT1vFakecNmezLPA18=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; b=WVIjjnYsknA/s+MGpp83O8m/dvD9E14YtJ1QKiWNFXEkESo9OvWAqpEhA2xb2FWWC wuPrIC9ANgEm8lRyNnBBShc8onKK93tIDgg3PzsSZ0/YNgKn2mWIqAOOoBeqJFd4m9 GFGVA5zpr9bxuXr8lSHlVGcuA79eoLvQHj4TEx3jOM2hJxqT3MHROhvJnq7Dg05Oyx PgvjpLv4OcIizxOI1OGTllJB4vbjdi8aGBabc4V7f2ga5UlYsVi1fDdiotk4wMsUiy WmC4qVyyDFQ0uLC/gQ5dAXwkYBr9WP36Zy45BHGY9C+wCzS2afmpIpi9FD0TuaPWzd w18w7tpYGbGog== Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/3.06/5.92) with ESMTPS id 4AB2u5EK11487655 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Nov 2024 10:56:05 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 11 Nov 2024 10:56:05 +0800 Received: from RTDOMAIN (172.21.210.74) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Nov 2024 10:56:04 +0800 From: Justin Lai To: CC: , , , , , , , , , Justin Lai Subject: [PATCH net-next 1/2] rtase: Add support for RTL907XD-VA PCIe port Date: Mon, 11 Nov 2024 10:55:31 +0800 Message-ID: <20241111025532.291735-2-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111025532.291735-1-justinlai0215@realtek.com> References: <20241111025532.291735-1-justinlai0215@realtek.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-Patchwork-Delegate: kuba@kernel.org Add RTL907XD-VA hardware version and modify the speed reported by .get_link_ksettings in ethtool_ops. Signed-off-by: Justin Lai --- drivers/net/ethernet/realtek/rtase/rtase.h | 10 +++++-- .../net/ethernet/realtek/rtase/rtase_main.c | 26 ++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/realtek/rtase/rtase.h b/drivers/net/ethernet/realtek/rtase/rtase.h index 583c33930f88..2bbfcad613ab 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase.h +++ b/drivers/net/ethernet/realtek/rtase/rtase.h @@ -9,7 +9,11 @@ #ifndef RTASE_H #define RTASE_H -#define RTASE_HW_VER_MASK 0x7C800000 +#define RTASE_HW_VER_MASK 0x7C800000 +#define RTASE_HW_VER_906X_7XA 0x00800000 +#define RTASE_HW_VER_906X_7XC 0x04000000 +#define RTASE_HW_VER_907XD_V1 0x04800000 +#define RTASE_HW_VER_907XD_VA 0x08000000 #define RTASE_RX_DMA_BURST_256 4 #define RTASE_TX_DMA_BURST_UNLIMITED 7 @@ -170,7 +174,7 @@ enum rtase_registers { RTASE_INT_MITI_TX = 0x0A00, RTASE_INT_MITI_RX = 0x0A80, - RTASE_VLAN_ENTRY_0 = 0xAC80, + RTASE_VLAN_ENTRY_0 = 0xAC80, }; enum rtase_desc_status_bit { @@ -327,6 +331,8 @@ struct rtase_private { u16 int_nums; u16 tx_int_mit; u16 rx_int_mit; + + u32 hw_ver; }; #define RTASE_LSO_64K 64000 diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c index f8777b7663d3..73ebdf0bc376 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -1714,10 +1714,22 @@ static int rtase_get_settings(struct net_device *dev, struct ethtool_link_ksettings *cmd) { u32 supported = SUPPORTED_MII | SUPPORTED_Pause | SUPPORTED_Asym_Pause; + const struct rtase_private *tp = netdev_priv(dev); ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, supported); - cmd->base.speed = SPEED_5000; + + switch (tp->hw_ver) { + case RTASE_HW_VER_906X_7XA: + case RTASE_HW_VER_906X_7XC: + cmd->base.speed = SPEED_5000; + break; + case RTASE_HW_VER_907XD_V1: + case RTASE_HW_VER_907XD_VA: + cmd->base.speed = SPEED_10000; + break; + } + cmd->base.duplex = DUPLEX_FULL; cmd->base.port = PORT_MII; cmd->base.autoneg = AUTONEG_DISABLE; @@ -1974,13 +1986,15 @@ static void rtase_init_software_variable(struct pci_dev *pdev, static bool rtase_check_mac_version_valid(struct rtase_private *tp) { - u32 hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK; bool known_ver = false; - switch (hw_ver) { - case 0x00800000: - case 0x04000000: - case 0x04800000: + tp->hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK; + + switch (tp->hw_ver) { + case RTASE_HW_VER_906X_7XA: + case RTASE_HW_VER_906X_7XC: + case RTASE_HW_VER_907XD_V1: + case RTASE_HW_VER_907XD_VA: known_ver = true; break; } From patchwork Mon Nov 11 02:55:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Lai X-Patchwork-Id: 13870197 X-Patchwork-Delegate: kuba@kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFBAB13A27E; Mon, 11 Nov 2024 02:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731293815; cv=none; b=mSmtjjxMrcj1zWSrJpu8e5sZSABFSUgyBQpWsPCIwG5prLULWb6A04g4bXqHap3w4R+1GUVOJx/f8uPweVn0DF2rlefXkuC9/RXiUEOzz0oLVbl7LMkTsEtAPbzfoeuz3QurBkch8cTRNJuZ0NL+jZg723d3cAvXZ8SdBQpQ4Bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731293815; c=relaxed/simple; bh=6u9gYwMYdkqbZ6KIhI6EYIbRmBK9Pq5HTFD76Ad/wK4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sKekZZhyJy9OlYVwB8GWWHL2zALJiNbSa5LcYLDXT6o+7g9Eci30j8jgn9Hsz4QBxinhGnQ6nccpYQop916bhBHCfeI1YfbP4cGyWaKVhs81Udd98gcVeoPXM6J5Z9cax+P4zTCAEBl62E3aXz4cbh+fB2C6hxpUaRw49LLdhEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; dkim=temperror (0-bit key) header.d=realtek.com header.i=@realtek.com header.b=BHuhJPP4; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=realtek.com header.i=@realtek.com header.b="BHuhJPP4" X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 4AB2uZtiD1487826, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realtek.com; s=dkim; t=1731293795; bh=6u9gYwMYdkqbZ6KIhI6EYIbRmBK9Pq5HTFD76Ad/wK4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; b=BHuhJPP4P7UdGGYIk6z6mAu5+XOBmpkID3xn5o9AxUWFQmNwJmSIc/1NUnBOscIsI xXjbgmwngr/H1yfzKNnv1bVDIwExImjD4vnjN9vbW5WRpyj/vXI13LxI06nyEZZDjt mp+XK0xDsgQbcYmY07wkAZm6C+ccPuh7q7aL6QJVtOa/XHIpmJuuo5NXJiHFwOfWJa VGaXql77r7Aai8KHhaT15bcYVIPsFPz3nf6x6SKPYE/5WCw/mRkBzBVF+x+ozkTRXj fpbv7bwo7t8ZP3IfvPBLt5pDTW3jNPpPYGrIv4vSUbkqW8m+zifUgjplSSehPMPOhE 1AVOeqemWwfkw== Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/3.06/5.92) with ESMTPS id 4AB2uZtiD1487826 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Nov 2024 10:56:35 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 11 Nov 2024 10:56:35 +0800 Received: from RTDOMAIN (172.21.210.74) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Nov 2024 10:56:35 +0800 From: Justin Lai To: CC: , , , , , , , , , Justin Lai Subject: [PATCH net-next 2/2] rtase: Fix error code in rtase_init_one() Date: Mon, 11 Nov 2024 10:55:32 +0800 Message-ID: <20241111025532.291735-3-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111025532.291735-1-justinlai0215@realtek.com> References: <20241111025532.291735-1-justinlai0215@realtek.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-Patchwork-Delegate: kuba@kernel.org Change the return type of rtase_check_mac_version_valid() to int. Add error handling for when rtase_check_mac_version_valid() returns an error. Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module") Signed-off-by: Justin Lai --- .../net/ethernet/realtek/rtase/rtase_main.c | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c index 73ebdf0bc376..ba1d376d2319 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -1984,9 +1984,9 @@ static void rtase_init_software_variable(struct pci_dev *pdev, tp->dev->max_mtu = RTASE_MAX_JUMBO_SIZE; } -static bool rtase_check_mac_version_valid(struct rtase_private *tp) +static int rtase_check_mac_version_valid(struct rtase_private *tp) { - bool known_ver = false; + int ret = -ENODEV; tp->hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK; @@ -1995,11 +1995,11 @@ static bool rtase_check_mac_version_valid(struct rtase_private *tp) case RTASE_HW_VER_906X_7XC: case RTASE_HW_VER_907XD_V1: case RTASE_HW_VER_907XD_VA: - known_ver = true; + ret = 0; break; } - return known_ver; + return ret; } static int rtase_init_board(struct pci_dev *pdev, struct net_device **dev_out, @@ -2119,9 +2119,12 @@ static int rtase_init_one(struct pci_dev *pdev, tp->pdev = pdev; /* identify chip attached to board */ - if (!rtase_check_mac_version_valid(tp)) - return dev_err_probe(&pdev->dev, -ENODEV, - "unknown chip version, contact rtase maintainers (see MAINTAINERS file)\n"); + ret = rtase_check_mac_version_valid(tp); + if (ret != 0) { + dev_err(&pdev->dev, + "unknown chip version, contact rtase maintainers (see MAINTAINERS file)\n"); + goto err_out_release_board; + } rtase_init_software_variable(pdev, tp); rtase_init_hardware(tp); @@ -2129,7 +2132,7 @@ static int rtase_init_one(struct pci_dev *pdev, ret = rtase_alloc_interrupt(pdev, tp); if (ret < 0) { dev_err(&pdev->dev, "unable to alloc MSIX/MSI\n"); - goto err_out_1; + goto err_out_del_napi; } rtase_init_netdev_ops(dev); @@ -2162,7 +2165,7 @@ static int rtase_init_one(struct pci_dev *pdev, GFP_KERNEL); if (!tp->tally_vaddr) { ret = -ENOMEM; - goto err_out; + goto err_out_free_dma; } rtase_tally_counter_clear(tp); @@ -2173,13 +2176,13 @@ static int rtase_init_one(struct pci_dev *pdev, ret = register_netdev(dev); if (ret != 0) - goto err_out; + goto err_out_free_dma; netdev_dbg(dev, "%pM, IRQ %d\n", dev->dev_addr, dev->irq); return 0; -err_out: +err_out_free_dma: if (tp->tally_vaddr) { dma_free_coherent(&pdev->dev, sizeof(*tp->tally_vaddr), @@ -2189,12 +2192,13 @@ static int rtase_init_one(struct pci_dev *pdev, tp->tally_vaddr = NULL; } -err_out_1: +err_out_del_napi: for (i = 0; i < tp->int_nums; i++) { ivec = &tp->int_vector[i]; netif_napi_del(&ivec->napi); } +err_out_release_board: rtase_release_board(pdev, dev, ioaddr); return ret;