From patchwork Thu Jun 20 05:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704853 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2076.outbound.protection.outlook.com [40.107.236.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE77E33981 for ; Thu, 20 Jun 2024 05:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862490; cv=fail; b=kWHu9rO+PKWs7ebdTJ0AAZZXi+oPql5u4zOVeDaH4A2XDT9PNpcNK1hOhk9kiXfvt3h6sOzUqumyvHlzCu4gmdKxKI/SrVFUzIaBmRthosncNGXH9S31YbMQa8Xx0baJmB8bMpAKqBxfYOcDvQLno8UWPJ02DMIFo2jDHShLsz4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862490; c=relaxed/simple; bh=NH/i32OBl5qEUbsvhy8xQzaefvZyIFqbjFgLtWNq+F8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cJGigfvVQZsWizplrQmkRHfiUPlUWH29ERmAX0hgjktaEss4Izy+P9G0IIheujPZVrIt8qIf/FGS9SXFddlqOMZJELfSMqfbzBimFaX6SIzdlqq8f9yTg2q2HfzB+iJ57bBZEL8nY+mlMwQmRPbtKtenlzjFzKl73gMsL2ssqnY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=dloCXOSH; arc=fail smtp.client-ip=40.107.236.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="dloCXOSH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+1troOFbpHDAvmx7/4u0CwFaEDZH3ScHrYzUfBOmE7301cxCVcazElYiwbEQK/P9RRiFQ/MVZlSU+sot7kl0vr57ps4e59n+4u1cAGFjGVXDZytdnjO9cerVtuRvOpGjAwuc7w5i+pIakU//j0abMOYaFadzDi4liKX/zoiohJu6igr0sxPX01riUP8cADWTZTr+3mItuADnaksYcpxr1+fSBbb2nsLujAeXueZJgk5HuzEjsqh6PlxqHPU4aDNf6veQ6PJp+cOtgj1xbLy89KN8lnKZPBU8gZQZtOwf9lqqrFdbhRRbsPh53R4BrSKUh8RkK5+ZsjwKbd/on24OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XpOAWH6SolhTy6HM0xygNf0nqLgapjwyT3RRowdZjOQ=; b=FXxshVl0ltMn3feyMoYK4nNcY1PD/Aua6qc9y/pEm/XMmjz+Y+YboFKLPS6D6RmIuR5o3Vso5EHtwbrjTpjWZqoKvAGRrPAPBSjJyLjkmL8Ehf9QaDlU90txo7IrF5hf/awkEDJUSk6YcV8AOqLHqsT/rJlfArFZqDkM7MIGgoWgED3vfncVVvQ+lIvldPyuuoyKJOEJEPL5ahlkkChxuVVaw45l+mMcmxN0YTqu+JSp9iBTiMEJ4uTsiEDuAxMslEK9yR0/ePtv90xQHsykFz8ruysv2/RaBfzNJB8ElWiY0+vYyRWfpUo8i6nR23qYwQK/6/OurzBmbI1ZtvooNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XpOAWH6SolhTy6HM0xygNf0nqLgapjwyT3RRowdZjOQ=; b=dloCXOSHXfUWaaw27H5kI8l+mK5O9pHlbVXPlSH0DX87qeHG/vMFEKub0S440HnHCW/JG0QW0dKFEilAJ91m7figOwTwMHmWZCEKQRRN1VBpnjLW+R9SNoRevoC5IkV4/F7ICs0fMuWBn9ZcUy2eskuF9HeXzGvg04DNX7i5LT0= Received: from SJ0PR03CA0095.namprd03.prod.outlook.com (2603:10b6:a03:333::10) by IA1PR12MB7760.namprd12.prod.outlook.com (2603:10b6:208:418::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Thu, 20 Jun 2024 05:48:06 +0000 Received: from SJ1PEPF00001CDD.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::57) by SJ0PR03CA0095.outlook.office365.com (2603:10b6:a03:333::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.33 via Frontend Transport; Thu, 20 Jun 2024 05:48:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDD.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 20 Jun 2024 05:48:05 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:01 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:47:59 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 1/9] net: move ethtool-related netdev state into its own struct Date: Thu, 20 Jun 2024 06:47:04 +0100 Message-ID: <03163fb4a362a6f72fc423d6ca7d4e2d62577bcf.1718862050.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDD:EE_|IA1PR12MB7760:EE_ X-MS-Office365-Filtering-Correlation-Id: 7db9695e-8e34-4b14-3899-08dc90ec8e4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|82310400023|36860700010|376011|7416011; X-Microsoft-Antispam-Message-Info: GHQwlPfs5dcvbLsXAPYI1h1TzJrljwc+H0o5q0xX0NXFICjOKtG0UqPi9pmn50+DW/q5MqVA4y25EbaMQWlbG/wH0+9gFSLn7mdg8Yw90/F2ThmCTDFSiSymHgRls8IYIJs9RTA1iqLvs4oWkx2ujm2sMh4b+Q4g+BYN2wl8vDbDrWxABQbEnnuQRUNrmFn0tzRvb4qhJxhvLNwGx3O5IMpQEhyPZcselKB8DYpWyt2AZD3s/+KzCtPgwR9S49mPrCzGTdxqUrUQmlslO+HU0NyvwKJcFc2bxLSx36g20ODXj5iGVBdhAs3yVeoTQAE91N3vDmPORS0MsuL8DEcthX3tQRwdDyXYuU9Ak8ge8ZFyQGwyEUWTdcHHJ5HaDaSf4MkMy3QPDrNM2n7hEHY5zkzemCPg0Xe3wB2G7t66azWPr//u8y2DINNexCKnOMYulePwjnYUEIFcmDFGqvyuZ7j2Ta/LDGeu6MfW60ILG1AUza5Nl7j6VrpcgWKA0WWrsmFaIibZAgWlje2w/zw7DtuLXLuR+dUwJHDcBQoypzu6xDMjjTNho8ADt+TmdyYpG5FBofIGsntJwjN561dRZvoF9GM0RJff4iMbwDi9Ks9FXsGoJhTt83/bfBPAJcJQH6A3bntN7R9+FXXPIQlwO6lSR2S8EIQRxDCpXDCPbL7wzEIDbFSruVHQqLNMfJOH2LhamU3yfEq+/Bn1ANyhcNn/GnZial0FGowfDtTe9ICr93OW63k9FKWjze1Huh/06lXFqcx3NOPE0j2wBQfHapkhhvDv9xyuX606dTr0M+oz9MHNPMzwLXCWKJJIw/aDasCqsSe7oPY0hcMO7ppVVPVyVBvXjsPQgOnvGddpkG+FvVKA9AmtAnzmCERDv4UetwF+fI4Dg+yRlEJLu11Fc03PuKugoxTU6QKK7P/+fjahM4FV/M4in1qBoRzJvQwEGGKQ8wAp/bRPsrM4KXBnMdkMP4hMObLwyg3VoSsTFNlgai0NqRdhsZaxeyJc8M5USmh7mTqbAmvmGYCrR/53OnqPdN/CdfzkrWijmSIUmMsDnp2MyNSVXoEN5bjsq4iNfqhDIqvUBZDmQCsrtFQSS2EAIsveQya1DCdxXuFdq2IepAOwqgAudgIeo7cmTed0V8TEwEaAxF5FM8lvDAnwPIAOqFPN5JHhVPkUNhdRfIJEWWm958f/PlANbx0ntXogvopioojJDfOTBNINPmEb7F+mRK4GCCI32kwzqEFxVaOhzriTop+nTUxufkpW3taBidQQiF/1cWOaYRKQMDa5rsZ27deQvrCwSxCIBh8TB2LZVbEnqt1NYZWuqlDYw1KYZxMbXueVFCCQOAubYdnxIwclc7lMc121SSKa91Ji0VDw7Ti+2JDpSD4Y1UfBhJKC2ztgGu4/Ul6f8ISccWOJjA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(1800799021)(82310400023)(36860700010)(376011)(7416011);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:05.2468 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7db9695e-8e34-4b14-3899-08dc90ec8e4d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CDD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7760 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree net_dev->ethtool is a pointer to new struct ethtool_netdev_state, which currently contains only the wol_enabled field. Suggested-by: Jakub Kicinski Signed-off-by: Edward Cree --- drivers/net/ethernet/realtek/r8169_main.c | 4 ++-- drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 4 ++-- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 2 +- drivers/net/phy/phy.c | 2 +- drivers/net/phy/phy_device.c | 5 +++-- drivers/net/phy/phylink.c | 2 +- include/linux/ethtool.h | 8 ++++++++ include/linux/netdevice.h | 7 ++++--- net/core/dev.c | 4 ++++ net/ethtool/ioctl.c | 2 +- net/ethtool/wol.c | 2 +- 11 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 9246ea2118ff..714d2e804694 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1608,7 +1608,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) if (!tp->dash_enabled) { rtl_set_d3_pll_down(tp, !wolopts); - tp->dev->wol_enabled = wolopts ? 1 : 0; + tp->dev->ethtool->wol_enabled = wolopts ? 1 : 0; } } @@ -5478,7 +5478,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) rtl_set_d3_pll_down(tp, true); } else { rtl_set_d3_pll_down(tp, false); - dev->wol_enabled = 1; + dev->ethtool->wol_enabled = 1; } jumbo_max = rtl_jumbo_max(tp); diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c index 46a5a3e95202..e868f7ef4920 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c @@ -37,9 +37,9 @@ static int ngbe_set_wol(struct net_device *netdev, wx->wol = 0; if (wol->wolopts & WAKE_MAGIC) wx->wol = WX_PSR_WKUP_CTL_MAG; - netdev->wol_enabled = !!(wx->wol); + netdev->ethtool->wol_enabled = !!(wx->wol); wr32(wx, WX_PSR_WKUP_CTL, wx->wol); - device_set_wakeup_enable(&pdev->dev, netdev->wol_enabled); + device_set_wakeup_enable(&pdev->dev, netdev->ethtool->wol_enabled); return 0; } diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c index e894e01d030d..a8119de60deb 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c @@ -650,7 +650,7 @@ static int ngbe_probe(struct pci_dev *pdev, if (wx->wol_hw_supported) wx->wol = NGBE_PSR_WKUP_CTL_MAG; - netdev->wol_enabled = !!(wx->wol); + netdev->ethtool->wol_enabled = !!(wx->wol); wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol); device_set_wakeup_enable(&pdev->dev, wx->wol); diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index c4236564c1cd..785182fa5fe0 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1309,7 +1309,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) if (netdev) { struct device *parent = netdev->dev.parent; - if (netdev->wol_enabled) + if (netdev->ethtool->wol_enabled) pm_system_wakeup(); else if (device_may_wakeup(&netdev->dev)) pm_wakeup_dev_event(&netdev->dev, 0, true); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 6c6ec9475709..473cbc1d497b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -296,7 +296,7 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) if (!netdev) goto out; - if (netdev->wol_enabled) + if (netdev->ethtool->wol_enabled) return false; /* As long as not all affected network drivers support the @@ -1984,7 +1984,8 @@ int phy_suspend(struct phy_device *phydev) return 0; phy_ethtool_get_wol(phydev, &wol); - phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled); + phydev->wol_enabled = wol.wolopts || + (netdev && netdev->ethtool->wol_enabled); /* If the device has WOL enabled, we cannot suspend the PHY */ if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) return -EBUSY; diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 02427378acfd..38e4e7c0f7d5 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2275,7 +2275,7 @@ void phylink_suspend(struct phylink *pl, bool mac_wol) { ASSERT_RTNL(); - if (mac_wol && (!pl->netdev || pl->netdev->wol_enabled)) { + if (mac_wol && (!pl->netdev || pl->netdev->ethtool->wol_enabled)) { /* Wake-on-Lan enabled, MAC handling */ mutex_lock(&pl->state_mutex); diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 6fd9107d3cc0..8cd6b3c993f1 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -998,6 +998,14 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, const struct ethtool_link_ksettings *cmd, u32 *dev_speed, u8 *dev_duplex); +/** + * struct ethtool_netdev_state - per-netdevice state for ethtool features + * @wol_enabled: Wake-on-LAN is enabled + */ +struct ethtool_netdev_state { + unsigned wol_enabled:1; +}; + struct phy_device; struct phy_tdr_config; struct phy_plca_cfg; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 85111502cf8f..bd88ecb61598 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -79,6 +79,7 @@ struct xdp_buff; struct xdp_frame; struct xdp_metadata_ops; struct xdp_md; +struct ethtool_netdev_state; typedef u32 xdp_features_t; @@ -1985,8 +1986,6 @@ enum netdev_reg_state { * switch driver and used to set the phys state of the * switch port. * - * @wol_enabled: Wake-on-LAN is enabled - * * @threaded: napi threaded mode is enabled * * @net_notifier_list: List of per-net netdev notifier block @@ -1998,6 +1997,7 @@ enum netdev_reg_state { * @udp_tunnel_nic_info: static structure describing the UDP tunnel * offload capabilities of the device * @udp_tunnel_nic: UDP tunnel offload state + * @ethtool: ethtool related state * @xdp_state: stores info on attached XDP BPF programs * * @nested_level: Used as a parameter of spin_lock_nested() of @@ -2372,7 +2372,6 @@ struct net_device { struct lock_class_key *qdisc_tx_busylock; bool proto_down; bool threaded; - unsigned wol_enabled:1; struct list_head net_notifier_list; @@ -2383,6 +2382,8 @@ struct net_device { const struct udp_tunnel_nic_info *udp_tunnel_nic_info; struct udp_tunnel_nic *udp_tunnel_nic; + struct ethtool_netdev_state *ethtool; + /* protected by rtnl_lock */ struct bpf_xdp_entity xdp_state[__MAX_XDP_MODE]; diff --git a/net/core/dev.c b/net/core/dev.c index c361a7b69da8..29351bbea803 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11065,6 +11065,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, dev->real_num_rx_queues = rxqs; if (netif_alloc_rx_queues(dev)) goto free_all; + dev->ethtool = kzalloc(sizeof(*dev->ethtool), GFP_KERNEL_ACCOUNT); + if (!dev->ethtool) + goto free_all; strcpy(dev->name, name); dev->name_assign_type = name_assign_type; @@ -11115,6 +11118,7 @@ void free_netdev(struct net_device *dev) return; } + kfree(dev->ethtool); netif_free_tx_queues(dev); netif_free_rx_queues(dev); diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index e645d751a5e8..998571f05deb 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1503,7 +1503,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) if (ret) return ret; - dev->wol_enabled = !!wol.wolopts; + dev->ethtool->wol_enabled = !!wol.wolopts; ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL); return 0; diff --git a/net/ethtool/wol.c b/net/ethtool/wol.c index 0ed56c9ac1bc..a39d8000d808 100644 --- a/net/ethtool/wol.c +++ b/net/ethtool/wol.c @@ -137,7 +137,7 @@ ethnl_set_wol(struct ethnl_req_info *req_info, struct genl_info *info) ret = dev->ethtool_ops->set_wol(dev, &wol); if (ret) return ret; - dev->wol_enabled = !!wol.wolopts; + dev->ethtool->wol_enabled = !!wol.wolopts; return 1; } From patchwork Thu Jun 20 05:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704852 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2070.outbound.protection.outlook.com [40.107.96.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6644A2744C for ; Thu, 20 Jun 2024 05:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862490; cv=fail; b=pF/y4WTc2drylkHt75iBF+nUlHgD3Ve/kb9nv98pO4DiwKIbI58nmSfNu+F2F8GKMFXNm6VuDCNdNyibxXineOAJvxTF0OIwQ6A33bSSZxsI0PuLf+Jf+ztgLpoOdgVxVzCn1cN6SE+JOvfIS1HUIpfbaUUavsta8pDKX/oKoGw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862490; c=relaxed/simple; bh=04/8VdElfh/OP7lEr3Z+8gjT/sPVjDNZ3DKcP/7Cz4k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=seVwKlaLLAQhqlMFQLCWwSfbgHX8o0q/nfjcU2gYYtEKQ5WvU9VPSD72qvvJ0+Auov6w0oJ/1AvWTjZ6F8jVtMn0CaZFArix9VZPDbsPJACicmDP2hJOzKvxU5t3JYj6BCjCzjCHvkM2tegU5eKcnrUsRDwvdjb8tPODqfqniRM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=L1VRZYi6; arc=fail smtp.client-ip=40.107.96.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="L1VRZYi6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YEOVqal438uOzPe75sQhHNNbEYifzzKQ01czecJ4t4dVENiD1PhamPxU9dI43IIVvZ3w00cYWaTu8HswjzlQEsDdCZLrA57r/uQT2jw9WUCaXAzA1NKS5pICg+SGn7owgjWkmSHdQ/Nl2IvGsnZBNK/8/digZjoj1keR9vVz/i+6p3Wq1/rHLvpBShb83fWYJwGShymFZrLz6mwsc0SIYPaY6o8Go39uvl9hx+E6EFMST5cC6m/7Nz6lYpVU3+rFoEeiSczEzJyzfmT6EZO/pZxhVg90NidbTJak+wVSkZPpM2miMzBkYMJZtpxZylCqa16UX4jBko76sLqt/GdCDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hu7vYa/NQnI66g0JLALDTNwgr0ksJhsmD+2gfW08FMI=; b=SgdkzSEv0v4NvEO6KUwr2Ddm4C4oyvhFnlpF3qe+EGcb6EpgquyPgLP0twdBJe+pRAiuRuaETkcyqgQVb7Qaa9XUm4b8h2JBgmC/wH+vulwSFh5NoCKpZtuImU5MkVTxXGmOSrANs6ufuJ7sUVNObOHtzItV8ysF/6Ud3h01w0prOCf6mw7n9TJMPCXTMPkNJ6wqg4v7FPiNRg37FCi6QzqaJK03Di5VL8kKq+wZIq/zXWB1nE0n+ga9sAWVf3/doYjhhjkpqd4lw+jWR8dbLBmQee/EAwvVvFJNosjFtZof2nxefNc214FMwcEQmP93RWkNuST2bcws7rWwtjhDQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hu7vYa/NQnI66g0JLALDTNwgr0ksJhsmD+2gfW08FMI=; b=L1VRZYi6Cv13S4sHWaZ8hEkctPYFSP2ONjIlKA5lFzsAY3+/78c0A8TCZUvXJZ3pryImWtgJ82dwnpmTk4ESc+RbFCCmLrfUrCgC0iHZFmV+CTlawVqMCCQoP+wIq2bd0o6ieOmT8XDkQgwmJqNllHv2AJ9aFgASnl4VY/wRFgM= Received: from CH2PR20CA0030.namprd20.prod.outlook.com (2603:10b6:610:58::40) by IA1PR12MB8238.namprd12.prod.outlook.com (2603:10b6:208:3f9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Thu, 20 Jun 2024 05:48:05 +0000 Received: from CH3PEPF00000018.namprd21.prod.outlook.com (2603:10b6:610:58:cafe::d8) by CH2PR20CA0030.outlook.office365.com (2603:10b6:610:58::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.33 via Frontend Transport; Thu, 20 Jun 2024 05:48:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CH3PEPF00000018.mail.protection.outlook.com (10.167.244.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7719.0 via Frontend Transport; Thu, 20 Jun 2024 05:48:05 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:04 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:02 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 2/9] net: ethtool: attach an XArray of custom RSS contexts to a netdevice Date: Thu, 20 Jun 2024 06:47:05 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000018:EE_|IA1PR12MB8238:EE_ X-MS-Office365-Filtering-Correlation-Id: 123daa88-a02f-459a-f5ab-08dc90ec8e3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|376011|36860700010|7416011|82310400023|1800799021; X-Microsoft-Antispam-Message-Info: Q1Mbz0H3fOceFoi8rPGPehDMRlfrrhrXoRZEi6DB0cBReW2RlqGiw6q9hMzxH5i0oq5911Vkxsn8vmbgeaXPZXr4F1ytM1didzBd5h/ENbDYKrxgDyrD5KrTC6KisFTrjKeP5mBIo6HyqmeRaTOnYJqnfRtbli9b03vHtsRp7caDmrHdknkP4akWzQpx/RSlkXmV29tnR7Ov76uDlj0WF4G9O0L0tmD9h3eHUVVd//SBQ/8lDocwR6fg5mH/4/+E3sMzmw8p250G2y2mLQBM+Cfg0DijTfK3U7snI/Xgmdtudiib5v/NtzlH/hTln5BMaUg2hvUalXlSuw7V6htxmalI4o69gT/Xm9pu1ykNZfhqx5AjtUr0NnxYjAXQ6Xd8jM2l0F/bFRbcGywBXAgNHVex43CzLBh3bHoHopoUNgiW+Zd6DQRzdsqZ+oLXCt5k0WhRh9jf+Z/+78d+25/93sse5+r1UJQUVpX5rzwPJMZNxDnS2I2bQGt655Xs+wLFgkAkPt/OF38+WoRR8b2WyPzvTv7cT/Zfic4GZyEKafybSUvRf2hn3Z+v+Lh+gaekKOoVL6K1+7cUCu3vrZuSCqP3jRZTQCbVZqheOFejofAjnyBdxPkqpnahyXIOHyQOcBFyx+h5sw46GQFWBxodevcjND3boZdDCUGlOMBUUYyOJTyE6LUmRY7Qf3fHbpEYWsL1MTH+/pMpmLoPA0eM6ZqEphfzK1v2SZrhYBr5Y243s5fFvDlMerYqJrIi3rJqwNmS5duF+BKAxcRO+3ITYYnbpOibHbUW5XY05NiXq/b6Rzst4HQy6Unuss8dUEcMzl1/w+lTC/X4cCeLhSToT3Hea1J/XoNyDcc1G+q9yQiJd6yDC6RzUXkLB4lTYR2Gvj7L0aXwIyaAy0PpZnF8OROKFqMn8COhlzscyeExXupi5HU5fb678rM7mDoQVOpye94qKoo0S1v0E2XQ5axQmpPq5VDFpw+hrFiiWuoxVeMnppQM8g+Af7njbnYi3o5jgMAObT0IS1Qr+k5uLDlBkSCDYiiyGk16l8I+hU76kOfNeWBbTIhcs1qCL+N+WmvYVeueE1TWN/Yv/jjTuoYnaCbHjnKTN/fQFoujaVbcj8zPY0IGOGgvE8E2QuQId8tZvJqwcr9TNDk7YKYLgWnpimDLdJivpNsPm50OfDX+DuA8pPjdsGtQMBtkF6p+Pr8mtGAg+uirRcVUhDW1YhAdqCvso1Z3FLxSEyU3z+zih3G5Fm8fJhrQpx0pnbYcrFVmONCrnp5B56mnL86txADvJXjlIY0uFj8ApMIvOycoKPNr/QavQ02kj7M98d0F5Z3nP3sHqe2kXxqIJMnGotpvrTUP/USKmH/rq2D8jfejYbYTtoOEKXlJcMFKJzQ1NgA4mW++6psDmnQPPNjxsEuLsw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(376011)(36860700010)(7416011)(82310400023)(1800799021);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:05.1806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 123daa88-a02f-459a-f5ab-08dc90ec8e3b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000018.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8238 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Each context stores the RXFH settings (indir, key, and hfunc) as well as optionally some driver private data. Delete any still-existing contexts at netdev unregister time. Signed-off-by: Edward Cree --- include/linux/ethtool.h | 42 +++++++++++++++++++++++++++++++++++++++++ net/core/dev.c | 27 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 8cd6b3c993f1..13c9c819de58 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -159,6 +159,46 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) return index % n_rx_rings; } +/** + * struct ethtool_rxfh_context - a custom RSS context configuration + * @indir_size: Number of u32 entries in indirection table + * @key_size: Size of hash key, in bytes + * @priv_size: Size of driver private data, in bytes + * @hfunc: RSS hash function identifier. One of the %ETH_RSS_HASH_* + * @input_xfrm: Defines how the input data is transformed. Valid values are one + * of %RXH_XFRM_*. + * @indir_configured: indir has been specified (at create time or subsequently) + * @key_configured: hkey has been specified (at create time or subsequently) + */ +struct ethtool_rxfh_context { + u32 indir_size; + u32 key_size; + u16 priv_size; + u8 hfunc; + u8 input_xfrm; + u8 indir_configured:1; + u8 key_configured:1; + /* private: driver private data, indirection table, and hash key are + * stored sequentially in @data area. Use below helpers to access. + */ + u8 data[] __aligned(sizeof(void *)); +}; + +static inline void *ethtool_rxfh_context_priv(struct ethtool_rxfh_context *ctx) +{ + return ctx->data; +} + +static inline u32 *ethtool_rxfh_context_indir(struct ethtool_rxfh_context *ctx) +{ + return (u32 *)(ctx->data + ALIGN(ctx->priv_size, sizeof(u32))); +} + +static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx) +{ + return (u8 *)(ethtool_rxfh_context_indir(ctx) + ctx->indir_size); +} + /* declare a link mode bitmap */ #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS) @@ -1000,9 +1040,11 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, /** * struct ethtool_netdev_state - per-netdevice state for ethtool features + * @rss_ctx: XArray of custom RSS contexts * @wol_enabled: Wake-on-LAN is enabled */ struct ethtool_netdev_state { + struct xarray rss_ctx; unsigned wol_enabled:1; }; diff --git a/net/core/dev.c b/net/core/dev.c index 29351bbea803..78465b69dc68 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10285,6 +10285,9 @@ int register_netdevice(struct net_device *dev) if (ret) return ret; + /* rss ctx ID 0 is reserved for the default context, start from 1 */ + xa_init_flags(&dev->ethtool->rss_ctx, XA_FLAGS_ALLOC1); + spin_lock_init(&dev->addr_list_lock); netdev_set_addr_lockdep_class(dev); @@ -11184,6 +11187,28 @@ void synchronize_net(void) } EXPORT_SYMBOL(synchronize_net); +static void netdev_rss_contexts_free(struct net_device *dev) +{ + struct ethtool_rxfh_context *ctx; + unsigned long context; + + xa_for_each(&dev->ethtool->rss_ctx, context, ctx) { + struct ethtool_rxfh_param rxfh; + + rxfh.indir = ethtool_rxfh_context_indir(ctx); + rxfh.key = ethtool_rxfh_context_key(ctx); + rxfh.hfunc = ctx->hfunc; + rxfh.input_xfrm = ctx->input_xfrm; + rxfh.rss_context = context; + rxfh.rss_delete = true; + + xa_erase(&dev->ethtool->rss_ctx, context); + dev->ethtool_ops->set_rxfh(dev, &rxfh, NULL); + kfree(ctx); + } + xa_destroy(&dev->ethtool->rss_ctx); +} + /** * unregister_netdevice_queue - remove device from the kernel * @dev: device @@ -11287,6 +11312,8 @@ void unregister_netdevice_many_notify(struct list_head *head, netdev_name_node_alt_flush(dev); netdev_name_node_free(dev->name_node); + netdev_rss_contexts_free(dev); + call_netdevice_notifiers(NETDEV_PRE_UNINIT, dev); if (dev->netdev_ops->ndo_uninit) From patchwork Thu Jun 20 05:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704854 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B8C239856 for ; Thu, 20 Jun 2024 05:48:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862493; cv=fail; b=VOFaup6Gu/VXYpIpe8iR3oUKMJ6voxWPo/suIzmaSDZWsxMmM21u7BfzQKVdFUpySw7PQRLi6fOrcRKd6iynqeXesq6fHA8pLwIBEQ2HMzXVxo8C3nKAIMFeF1Mj7BCmFaKg9C+Zr+842UZ7XVv0Pvm2Bdby3xx/RHEzC3jKZnc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862493; c=relaxed/simple; bh=rYDgen6AXGuBlTehGB8K1N00m4ISxy90Ht+BSP2iCY0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d0UfuVmJhrrGry/8MusVBsL34oDBQDHvwndUeNnyt0Z4SzjMvSFymKo0DwWftf1rhpWZy0pFLuO1OLJ2WJxQ0ZVeruuP2JPHXMF7iGWvyvSRnC30amdUAo0qr8PHpUcKoqpFm5fSW5YdwahdSCTeCrp/qwdPXknSzcN227Mt7XY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=mhU3PnPh; arc=fail smtp.client-ip=40.107.237.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mhU3PnPh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=agr09wYIbBTJHdLTot41LV9ubzyBwprfjfdhgqhscYbyQ1qjVEoOVdtAON/cFhIDDCZ3tgA9gfryrrC2VoDg8Im0O+0NhI9cYbDHH8ZH5slP5LFdzIDg5jCfbknfhLWKRp4zGO4v7IPaJh7gZOYPlx6SQXivUBCIlPCft1PO7Te62YyJkGQMK9TN0AhW+gcrC3IKRPeVZ1hzxCXm5FfoU7GubHQZARxuZ1C6baRFuN8hcfosgvO/mQG0o6AuisB/Miiwy8GYYba0OzZsuJEnI0IZqzDJ5mVVn9JlCvgfaSyg9CFiXZl4TNjulBEOF1GDKVAKuQ3tpAb/TY2ax8epiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lU+guhwk4Hup437pRZ1HEBOxeA+fuaGROLm2zcczlfU=; b=XWxk92h+PTTF8gJ33F0NZKPwO1a/wLyUmpjgKxUinTwVeRZ12lNyu/YHS9Ctu5DehoOxkKrzOcxAeItPVQ7pHlpjuYVsaXkv5lDqHPCykJOYtKG6NFVFOjLFn1OXwadFnkYd4UdTKyGOBnOH3Jzd4D73J2FptiFt36YWC9pZER/9G0dRLW8WFNP+8TKgw6Q7GLxOQzfSzwzrK+PFe7GYUAie2P6gMlDIpQ2DtAR8T0s9ZWr8ICQeHKOUD+lyKFF7+Mwe7BVvkCdymOifZVXuTFIgETRmEbKbALDr+4thEx9UCz/sew2ShfL/R4nSNHD1P1yHbWCeI+5LmYtNuSyTDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lU+guhwk4Hup437pRZ1HEBOxeA+fuaGROLm2zcczlfU=; b=mhU3PnPh3hPWCSwi6VRxP6q82MrCCap82V+piTChLrE46E09a1WKerueqgvl1+PpYEu4OFDMXLsisqiIUNZs+D3Clu2QlSKfvGbsV6LWn3lDHoycTR0WGAR2lFmez7wAot1+bW+uG1xDKFnzJLzaWN5l/Ypgoi4TfevkTewxKi4= Received: from DS7PR03CA0204.namprd03.prod.outlook.com (2603:10b6:5:3b6::29) by LV8PR12MB9084.namprd12.prod.outlook.com (2603:10b6:408:18e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31; Thu, 20 Jun 2024 05:48:08 +0000 Received: from CH3PEPF00000013.namprd21.prod.outlook.com (2603:10b6:5:3b6:cafe::7e) by DS7PR03CA0204.outlook.office365.com (2603:10b6:5:3b6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.34 via Frontend Transport; Thu, 20 Jun 2024 05:48:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CH3PEPF00000013.mail.protection.outlook.com (10.167.244.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7719.0 via Frontend Transport; Thu, 20 Jun 2024 05:48:08 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:07 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:04 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 3/9] net: ethtool: record custom RSS contexts in the XArray Date: Thu, 20 Jun 2024 06:47:06 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000013:EE_|LV8PR12MB9084:EE_ X-MS-Office365-Filtering-Correlation-Id: 5db75ab9-a57c-4ee0-82a3-08dc90ec8ff0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|376011|7416011|36860700010|82310400023|1800799021; X-Microsoft-Antispam-Message-Info: fUBJglbGyBxdj3aSB9fHGp5TWWJBeYA3SBZ5IfakrodQTkS53/Xtq04qhlPBOLDnY43yWzoSZhpFVtcu3KRbWPqvwfMAxSLO7QYv590O5hqqcb5cklZofUcJVuzPZoJVcsJvRfPacndn6/DAwYztyhU66H9v/eoHXeuvrCJ9iipBchCYxeHBttRIcLl+3I+ovunoiXQBEvS5oYIAVi6h+x1Pq7hNBIdQw3DEtfhcA9/ZM6/LP2A3JVWhyq1n1tp5r0gCMJ3gECQARBLANFmJ6S6d2dbJGG9BbcrX89oZirCZNCBfO/jwlBN0TapAKJPMHemLubocBUvJlw57g6HqOBCpJKMujiTzzKLT5/lLLkJ4zA7eDq6zbip5cCQRhazvQsBXZfOIj/2GcxtPb8mLNq5NS7lNCY9A7XMX995p+1dRRDBUwQpzW71s+3emrK+2PveVeKTRyHl6z7LBWSpjlhMORBJYUBqGKjwYn4wFvUcyMExYAIupUANqntpgI0qIya1chLQd1PLQi7vVJesJh20hpiMu37pqbfeS/oJD78x+EEGt/U94gXB4V9RuLQmOtRkoOEBAURxXvGjIYfJAFenF3ndx3vdH25orne9z/8njP83Tvl945NTRaLto/JK8kXPrkxBjDNqjT4K1rB3GYa5DnO6lASkBbbOEU5THnQptO93FjjcKfI5YcEgLkwNjrVwCPyKJX4RoZImB96IsrDpmiNkVo6FBicm29EL6DbmkeV8ssSNxeYSMgFa2w2XVjc64TfveWspSGxSnVTEVeGmMV6DSh08OZ/lUAPlGB69BwKZYcu2zvVeamXcPKMV6pzXRz/xJOCH/Z2URwVoRmzS/s22kvflgycbF+KLxxwp4pilvNQG44jk31Detrp5ExEhUOYync9bFTOVO1saV02OZCtHOZANF2MwBKG1bekreWUn4OMDT6JcnbCQ7+WiJF7HvXhuqkITKyddRdHH7EaYbJt9MUasAdaH9IjOOy778rK84DbXibRNgVBrRAvKp1Cbhq5eGirdD398Cg7tlzRI3qVxNGP8OndHWmn4ibiUOuaIaxUz86eiMevryb3tLBEg1fZ3It+sr6qZf9sr0IChxaa4bv9SlgDKJPLdWUNH714nLAtVdDPAo9Miq7GWUiJv4k/M3oPJLrFxnaoA0uObbOG2OiNFbtx7sLqJE6mqTWHItWqMNEbGLxDAu63dCe1ieEEonF+/Q8N0bd9I/Ww8ssKbO3rY/zoGPTQ9UQPRJb4TTo0cyKo2eu+4iu61oCHrBwyinZxdpgs5DQIkMyl37L3kg6gD5XSXUqUfj84h2v+nzDjooDyr3A4PKqOYMAQF89v9WN/o5QOSVsut0yRhmo083e4pieT2ImZEeKXtCqmwZFPYt8iTJD3HnBfmbBvfC+iHp46K+j3ZGUMOSpQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(376011)(7416011)(36860700010)(82310400023)(1800799021);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:08.0414 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5db75ab9-a57c-4ee0-82a3-08dc90ec8ff0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000013.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9084 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Since drivers are still choosing the context IDs, we have to force the XArray to use the ID they've chosen rather than picking one ourselves, and handle the case where they give us an ID that's already in use. Signed-off-by: Edward Cree --- include/linux/ethtool.h | 14 ++++++++ net/ethtool/ioctl.c | 74 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 13c9c819de58..283ba4aff623 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -199,6 +199,17 @@ static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx) return (u8 *)(ethtool_rxfh_context_indir(ctx) + ctx->indir_size); } +static inline size_t ethtool_rxfh_context_size(u32 indir_size, u32 key_size, + u16 priv_size) +{ + size_t indir_bytes = array_size(indir_size, sizeof(u32)); + size_t flex_len; + + flex_len = size_add(size_add(indir_bytes, key_size), + ALIGN(priv_size, sizeof(u32))); + return struct_size((struct ethtool_rxfh_context *)0, data, flex_len); +} + /* declare a link mode bitmap */ #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS) @@ -709,6 +720,8 @@ struct ethtool_rxfh_param { * contexts. * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor * RSS. + * @rxfh_priv_size: size of the driver private data area the core should + * allocate for an RSS context (in &struct ethtool_rxfh_context). * @supported_coalesce_params: supported types of interrupt coalescing. * @supported_ring_params: supported ring params. * @get_drvinfo: Report driver/device information. Modern drivers no @@ -892,6 +905,7 @@ struct ethtool_ops { u32 cap_link_lanes_supported:1; u32 cap_rss_ctx_supported:1; u32 cap_rss_sym_xor_supported:1; + u16 rxfh_priv_size; u32 supported_coalesce_params; u32 supported_ring_params; void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 998571f05deb..f879deb6ac4e 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1278,10 +1278,12 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, const struct ethtool_ops *ops = dev->ethtool_ops; u32 dev_indir_size = 0, dev_key_size = 0, i; struct ethtool_rxfh_param rxfh_dev = {}; + struct ethtool_rxfh_context *ctx = NULL; struct netlink_ext_ack *extack = NULL; struct ethtool_rxnfc rx_rings; struct ethtool_rxfh rxfh; u32 indir_bytes = 0; + bool create = false; u8 *rss_config; int ret; @@ -1309,6 +1311,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) && !ops->cap_rss_sym_xor_supported) return -EOPNOTSUPP; + create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC; /* If either indir, hash key or function is valid, proceed further. * Must request at least one change: indir size, hash key, function @@ -1374,13 +1377,42 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, } } + if (create) { + if (rxfh_dev.rss_delete) { + ret = -EINVAL; + goto out; + } + ctx = kzalloc(ethtool_rxfh_context_size(dev_indir_size, + dev_key_size, + ops->rxfh_priv_size), + GFP_KERNEL_ACCOUNT); + if (!ctx) { + ret = -ENOMEM; + goto out; + } + ctx->indir_size = dev_indir_size; + ctx->key_size = dev_key_size; + ctx->hfunc = rxfh.hfunc; + ctx->input_xfrm = rxfh.input_xfrm; + ctx->priv_size = ops->rxfh_priv_size; + } else if (rxfh.rss_context) { + ctx = xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context); + if (!ctx) { + ret = -ENOENT; + goto out; + } + } rxfh_dev.hfunc = rxfh.hfunc; rxfh_dev.rss_context = rxfh.rss_context; rxfh_dev.input_xfrm = rxfh.input_xfrm; ret = ops->set_rxfh(dev, &rxfh_dev, extack); - if (ret) + if (ret) { + if (create) + /* failed to create, free our new tracking entry */ + kfree(ctx); goto out; + } if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, rss_context), &rxfh_dev.rss_context, sizeof(rxfh_dev.rss_context))) @@ -1393,6 +1425,46 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, else if (rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE) dev->priv_flags |= IFF_RXFH_CONFIGURED; } + /* Update rss_ctx tracking */ + if (create) { + /* Ideally this should happen before calling the driver, + * so that we can fail more cleanly; but we don't have the + * context ID until the driver picks it, so we have to + * wait until after. + */ + if (WARN_ON(xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context))) { + /* context ID reused, our tracking is screwed */ + kfree(ctx); + goto out; + } + /* Allocate the exact ID the driver gave us */ + if (xa_is_err(xa_store(&dev->ethtool->rss_ctx, rxfh.rss_context, + ctx, GFP_KERNEL))) { + kfree(ctx); + goto out; + } + ctx->indir_configured = rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE; + ctx->key_configured = !!rxfh.key_size; + } + if (rxfh_dev.rss_delete) { + WARN_ON(xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context) != ctx); + kfree(ctx); + } else if (ctx) { + if (rxfh_dev.indir) { + for (i = 0; i < dev_indir_size; i++) + ethtool_rxfh_context_indir(ctx)[i] = rxfh_dev.indir[i]; + ctx->indir_configured = 1; + } + if (rxfh_dev.key) { + memcpy(ethtool_rxfh_context_key(ctx), rxfh_dev.key, + dev_key_size); + ctx->key_configured = 1; + } + if (rxfh_dev.hfunc != ETH_RSS_HASH_NO_CHANGE) + ctx->hfunc = rxfh_dev.hfunc; + if (rxfh_dev.input_xfrm != RXH_XFRM_NO_CHANGE) + ctx->input_xfrm = rxfh_dev.input_xfrm; + } out: kfree(rss_config); From patchwork Thu Jun 20 05:47:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704855 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34D9739AEB for ; Thu, 20 Jun 2024 05:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862494; cv=fail; b=s8C64PFr8dqz3EzUn9xrwG36QStPCEdDSFiKdcQILze0xtYHfPf1YxWnD4RPUDs2iYwpChUfKQyP2b2/qJhFnKMwlytu23GZuWN9F9AjKSYlsB5ud69KgxKkGUlzKdyl3i3dD0A0gkOYt5Y2xqOA2nEWZux0cOOKIHQL6UIyISE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862494; c=relaxed/simple; bh=EhoY9PHrHMwjzxsdbl9Ef+eZe0heLALeMdWqsG/Ae2I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S+/fChqtgwGV6Et6YISXfF/x79tb/hv/BIfFnEr/Q5ItSXiGdhNZiDGtApEWOClLxJCzRIA4aIe2hlw+SVlqjAKA+oAIDVDuPT33SyiBYVOv6mQ7O8mnqnWIXakTr4oK2/JUu0JFG4aqRQkwj3pWOE9Or771gmTHAxKYg1BmT0U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=cwfuNMpL; arc=fail smtp.client-ip=40.107.243.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="cwfuNMpL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z7NOUKPr6uoiks4mYC3w8r1ORDYRy3lfq3ZdcNcELkT7c7aAgzQ12YCCJFTu/vUYcfRhjJ+5px8Va/q0YzY7BW9XizU9Fa/l6El5BVfCuItWS3DMiHYtBGCeVvVaG4ayRPEstnfN35IUTWcqTB12m/wtPROPms5KC711xxE3GIOCezXSbZydAHjHVbVzQsS6GP8/GiWYQ16iVPFtH+11u9bJzZuS5J/VB6umkqzsupugwdOYBbpl1iRhs5agV3MbBwecOmfqWb0gTsR9mJyH9Lou166NED5i5klSmJSO9YLI1QWgTFpOP5oRfT2pylJoYR5/fV8Z0GY5QX1QqfG5vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6bYBlgMfSAqqqcQDsEeUcNXbmhW47Tl03x5sNmoGBTI=; b=lmTXpK87sBKLtjFNGfZDxPTTEN4b8mjhzRqrFGIqp/UsItUPXwVNRK4pPO/MbBGnUrcAu4JczFeocFvsf8lfmWcx6rQOp/PAgDe2McjrMbXpojr4Yt4R5ocLuGRadHLAMSgaQuL6p60EP6tERfAlHany1VQuZTMmK0K/IU7qI9xKKCQxILzMI2lb30agSgXS5XbGGh56SGyKtmwEm+gXWVsHm3VniQOzxRwx8h9K3ke6anwG0E2CKezaQGOpDSPXjsKnAMvYJ53JHfaAkgf7wozmWrRqLimOMH8E84YovcXlMqp2m9mdjqypzLo6x+YSE6nQ01DtuAY0x7Cx5X3law== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6bYBlgMfSAqqqcQDsEeUcNXbmhW47Tl03x5sNmoGBTI=; b=cwfuNMpLDWMykV78HuFcnP5x+wcRE4aEzqclF79vLKRmfgyt3EdAWxbAvC1KLEnrGLg2ugW3DN0UPckMa91LY9uCw0WM7V36oEzyYZBotEaZLoNhY5i7GU1XIhSVoO5TbrEpiZ43YjzY5I6JYp3bDGV6Ge/xRiYrUoj6aPPYhZc= Received: from CH5P222CA0004.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::8) by DS0PR12MB8478.namprd12.prod.outlook.com (2603:10b6:8:15a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31; Thu, 20 Jun 2024 05:48:10 +0000 Received: from CH3PEPF00000016.namprd21.prod.outlook.com (2603:10b6:610:1ee:cafe::c9) by CH5P222CA0004.outlook.office365.com (2603:10b6:610:1ee::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.33 via Frontend Transport; Thu, 20 Jun 2024 05:48:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CH3PEPF00000016.mail.protection.outlook.com (10.167.244.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7719.0 via Frontend Transport; Thu, 20 Jun 2024 05:48:10 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:09 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:07 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 4/9] net: ethtool: let the core choose RSS context IDs Date: Thu, 20 Jun 2024 06:47:07 +0100 Message-ID: <8db50fb9ae4bb623cc0cb5a5e99d70fab2f32d4d.1718862050.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000016:EE_|DS0PR12MB8478:EE_ X-MS-Office365-Filtering-Correlation-Id: 89566c3b-6f84-4ce7-2f60-08dc90ec9171 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|82310400023|1800799021|7416011|376011|36860700010; X-Microsoft-Antispam-Message-Info: FeNmEMM/yxeTyS8jnztIptA4pndpFWPXKW/ZaEJojWm3A4qRLQea/3WFC9zCqMNZMcVADg+rWCYrdT5d7IBVx3oHnOiF6yHkzYXnz9OgbBaMQQZcS8KBOxAYkpdMabFtOhM36yk5FMkmfa2kO85XQ99tScANekKmVdrtNSU5L6lgh2uSQmdGAKSGATWsvILRjNh2wssxHIJzkh3o69JJW50Nae0ArYLp5gaLg/xOd0CNLJWNS2Mz8TNgQ8OQAexT/OTEPkxzIdWmF4V1hmNxIDLuOYSImyn7dvY0nt3qDn12gu3xblSS0Qvrxg1NThIATPS0UvKoyIHi+Fn08K8LkaMz8wZ5wakmHZZJJN+ZrqMLAoSnfTLdtO/SCnCOqoFF3G2XqPjQk6KPYUU1A2OkFvXkmwFFYnmnBZayL+Fs7NWUu8Z0IKIBIXWzWns3mwgN65n9SLdN4rdWG5NE3c57Xy7S4N7vJ75Px+Qu20pcaamSCVlinfbV1IDjQ4prPJl90HxtnzPFiA+Ez35RUH0jPcAZfrtJyCFblI86LyuX/5PJvLqavOkhrB6OyFSoGeKEeUIJ/GHE2V9FxBc6sBliQNPTOdj7coQ6CIpynI016ocA+QctOrvrMipRGtX9dr6VwBIiRDHDKaIuyUehUxh/pkkx1iLB7ZizA8tN4M8hlNQ8YB3Oc2nCP48nPitMZjRh608BgJl52zwUKNHtIluI0uDQZhhnVTBNinXQwXUVl0crDizUdzT3jV/mTxzul5iXtsGLYkLXRfFjH0NDkPUBv5UyjK9sxKe8u6z3WC0rHbIc6NfLmQ+zcqLBGCRLiBGUfem3owfiDw84YLMdqgre3fPrHbPXEVt1umhUOTNIJZ9hmoAIJm46kVA0S8FH7t5CLRlW9ll8TR7HUjSrSqKhD+SEoUYU7NCGSOiwngryVyYBIpdQvEvBpCIBuGg/7IhANLJS5HFt6tXMwr3KuI8eyRbTP8TW+l5BO2ihZNXTnszMvj3hCIf1bwCRPPfC6w0gv6xMofP/24T86j2eMC2SSegR/kiY3nWPoXMfA5Wka5QXOwFUYkp5ztSTCckm19FvWgk4CTSKxeYJVI0O7E7InfJRiZZ0/DlNk3Z8w2L6GzFq6RhejpMPO0Kwo5APUZDNASH1qS4tC36NtejkUQfl50iNTRJRZGOBMPyD4KkQeIP8bNcic8CFbLUhk+xu00CctcEFjbA6AhnQ40e7bGdo/v76MTh51r28+XssDJ3lnG7Q7/ceL14GGoXjqR9l8pSMZh8svil/kAjKwcv8NlZWSbZdwT6LPruxB+io7v9X6xno3oexkySC0/J9eLxe7RR/zLGd5HPCINNWqo9GGxC/3qnhucO18CUOq89j/sI9DaaUGYtOpnU8DXHhJtOp16f4jpv9vZ6CG+XCcNdg10IiKw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(82310400023)(1800799021)(7416011)(376011)(36860700010);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:10.5782 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89566c3b-6f84-4ce7-2f60-08dc90ec9171 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000016.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8478 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Add a new API to create/modify/remove RSS contexts, that passes in the newly-chosen context ID (not as a pointer) rather than leaving the driver to choose it on create. Also pass in the ctx, allowing drivers to easily use its private data area to store their hardware-specific state. Keep the existing .set_rxfh API for now as a fallback, but deprecate it for custom contexts (rss_context != 0). Signed-off-by: Edward Cree --- include/linux/ethtool.h | 40 +++++++++++++++++++++++++++++++++++ net/core/dev.c | 6 +++++- net/ethtool/ioctl.c | 46 ++++++++++++++++++++++++++++++----------- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 283ba4aff623..d9570b97154b 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -722,6 +722,10 @@ struct ethtool_rxfh_param { * RSS. * @rxfh_priv_size: size of the driver private data area the core should * allocate for an RSS context (in &struct ethtool_rxfh_context). + * @rxfh_max_context_id: maximum (exclusive) supported RSS context ID. If this + * is zero then the core may choose any (nonzero) ID, otherwise the core + * will only use IDs strictly less than this value, as the @rss_context + * argument to @create_rxfh_context and friends. * @supported_coalesce_params: supported types of interrupt coalescing. * @supported_ring_params: supported ring params. * @get_drvinfo: Report driver/device information. Modern drivers no @@ -818,6 +822,32 @@ struct ethtool_rxfh_param { * will remain unchanged. * Returns a negative error code or zero. An error code must be returned * if at least one unsupported change was requested. + * @create_rxfh_context: Create a new RSS context with the specified RX flow + * hash indirection table, hash key, and hash function. + * The &struct ethtool_rxfh_context for this context is passed in @ctx; + * note that the indir table, hkey and hfunc are not yet populated as + * of this call. The driver does not need to update these; the core + * will do so if this op succeeds. + * However, if @rxfh.indir is set to %NULL, the driver must update the + * indir table in @ctx with the (default or inherited) table actually in + * use; similarly, if @rxfh.key is %NULL, @rxfh.hfunc is + * %ETH_RSS_HASH_NO_CHANGE, or @rxfh.input_xfrm is %RXH_XFRM_NO_CHANGE, + * the driver should update the corresponding information in @ctx. + * If the driver provides this method, it must also provide + * @modify_rxfh_context and @remove_rxfh_context. + * Returns a negative error code or zero. + * @modify_rxfh_context: Reconfigure the specified RSS context. Allows setting + * the contents of the RX flow hash indirection table, hash key, and/or + * hash function associated with the given context. + * Parameters which are set to %NULL or zero will remain unchanged. + * The &struct ethtool_rxfh_context for this context is passed in @ctx; + * note that it will still contain the *old* settings. The driver does + * not need to update these; the core will do so if this op succeeds. + * Returns a negative error code or zero. An error code must be returned + * if at least one unsupported change was requested. + * @remove_rxfh_context: Remove the specified RSS context. + * The &struct ethtool_rxfh_context for this context is passed in @ctx. + * Returns a negative error code or zero. * @get_channels: Get number of channels. * @set_channels: Set number of channels. Returns a negative error code or * zero. @@ -906,6 +936,7 @@ struct ethtool_ops { u32 cap_rss_ctx_supported:1; u32 cap_rss_sym_xor_supported:1; u16 rxfh_priv_size; + u32 rxfh_max_context_id; u32 supported_coalesce_params; u32 supported_ring_params; void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); @@ -968,6 +999,15 @@ struct ethtool_ops { int (*get_rxfh)(struct net_device *, struct ethtool_rxfh_param *); int (*set_rxfh)(struct net_device *, struct ethtool_rxfh_param *, struct netlink_ext_ack *extack); + int (*create_rxfh_context)(struct net_device *, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh); + int (*modify_rxfh_context)(struct net_device *, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh); + int (*remove_rxfh_context)(struct net_device *, + struct ethtool_rxfh_context *ctx, + u32 rss_context); void (*get_channels)(struct net_device *, struct ethtool_channels *); int (*set_channels)(struct net_device *, struct ethtool_channels *); int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); diff --git a/net/core/dev.c b/net/core/dev.c index 78465b69dc68..e875b0a579b4 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11203,7 +11203,11 @@ static void netdev_rss_contexts_free(struct net_device *dev) rxfh.rss_delete = true; xa_erase(&dev->ethtool->rss_ctx, context); - dev->ethtool_ops->set_rxfh(dev, &rxfh, NULL); + if (dev->ethtool_ops->create_rxfh_context) + dev->ethtool_ops->remove_rxfh_context(dev, ctx, + context); + else + dev->ethtool_ops->set_rxfh(dev, &rxfh, NULL); kfree(ctx); } xa_destroy(&dev->ethtool->rss_ctx); diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index f879deb6ac4e..2b75d84c3078 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1392,9 +1392,24 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, } ctx->indir_size = dev_indir_size; ctx->key_size = dev_key_size; - ctx->hfunc = rxfh.hfunc; - ctx->input_xfrm = rxfh.input_xfrm; ctx->priv_size = ops->rxfh_priv_size; + /* Initialise to an empty context */ + ctx->hfunc = ETH_RSS_HASH_NO_CHANGE; + ctx->input_xfrm = RXH_XFRM_NO_CHANGE; + if (ops->create_rxfh_context) { + u32 limit = ops->rxfh_max_context_id ?: U32_MAX; + u32 ctx_id; + + /* driver uses new API, core allocates ID */ + ret = xa_alloc(&dev->ethtool->rss_ctx, &ctx_id, ctx, + XA_LIMIT(1, limit), GFP_KERNEL_ACCOUNT); + if (ret < 0) { + kfree(ctx); + goto out; + } + WARN_ON(!ctx_id); /* can't happen */ + rxfh.rss_context = ctx_id; + } } else if (rxfh.rss_context) { ctx = xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context); if (!ctx) { @@ -1406,11 +1421,24 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, rxfh_dev.rss_context = rxfh.rss_context; rxfh_dev.input_xfrm = rxfh.input_xfrm; - ret = ops->set_rxfh(dev, &rxfh_dev, extack); - if (ret) { + if (rxfh.rss_context && ops->create_rxfh_context) { if (create) + ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev); + else if (rxfh_dev.rss_delete) + ret = ops->remove_rxfh_context(dev, ctx, + rxfh.rss_context); + else + ret = ops->modify_rxfh_context(dev, ctx, &rxfh_dev); + } else { + ret = ops->set_rxfh(dev, &rxfh_dev, extack); + } + if (ret) { + if (create) { /* failed to create, free our new tracking entry */ + if (ops->create_rxfh_context) + xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context); kfree(ctx); + } goto out; } @@ -1426,12 +1454,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, dev->priv_flags |= IFF_RXFH_CONFIGURED; } /* Update rss_ctx tracking */ - if (create) { - /* Ideally this should happen before calling the driver, - * so that we can fail more cleanly; but we don't have the - * context ID until the driver picks it, so we have to - * wait until after. - */ + if (create && !ops->create_rxfh_context) { + /* driver uses old API, it chose context ID */ if (WARN_ON(xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context))) { /* context ID reused, our tracking is screwed */ kfree(ctx); @@ -1443,8 +1467,6 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, kfree(ctx); goto out; } - ctx->indir_configured = rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE; - ctx->key_configured = !!rxfh.key_size; } if (rxfh_dev.rss_delete) { WARN_ON(xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context) != ctx); From patchwork Thu Jun 20 05:47:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704856 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2044.outbound.protection.outlook.com [40.107.220.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB90E36AE0 for ; Thu, 20 Jun 2024 05:48:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862498; cv=fail; b=PAwU4bxJ26iCEZigKsvqtKMoOJNiNRZSlmntLZsXJClDXVHXVYUrPz8gqPzhpZowSlwrplGpA4olUrlqpn0CUTBSyqIAiDeuI3nknB1Yz9LBBektkFFzk2TGhYSR0A5BXQMkzbfinEoVk66lq5BVpYUYnlwkFQRdiSyUF1E1qT0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862498; c=relaxed/simple; bh=QOyJPZTmtemYx2gxU6YbM7tx+8q1Wq5GFQ2mOqjWe8I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pjivd+Fut727Otwo4V0LgUgM002ELL38Mvs5WIrUzyGHOE8lGtZG2eNnBnsmGH4LzwNt8HRMDFHnOPlkG7Li84KBz2ZMhHdHe/IDdWnxTD5FNkqrrf2QRPuaLms0MgrH8H12cSmKjg81NcP/gTc7Cu6Two0yaeG55S0Oc8ltRf0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PNcDwllf; arc=fail smtp.client-ip=40.107.220.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PNcDwllf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L48cLjF4h9VYQeM/SzJalm777rPxQf1fySq5cPBuW31KX8p/J2KxnZeWBpVkmbpwDV0II5us0k1GwQj9yGnFAXr4+g30uSzY+1M3w3yTb2lS7q0Waes1T5HSbnS6H9mNVz7g3VB6C6uctJNobh95hnm8ZbdkG94Ja3HiXJ0sUbR4hps8m/d8/aiuuPaOFShd8KmRZaKWHHL7SL5J2eSlrejfWc5pz9j3fRnkeuotI3grxkUnxCX1zeAjh+yY3f5olhib3e7H3aNAW0JQZEbMD1I3Cat6qy8CC/Vmjjkr9nlpr4B4grInL9q74YWak4GdvKytMhH+AGOMWmFTbl7Ywg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rf4JueDXN3tzBTkABoRx+ja7YEDbKZ624T7+X1MZzY0=; b=Nf4KgF4XOJlhoeCrFH1rZ4mSZHo8CuC473JXp/zWReuby37NPFuzlvZlL9iIavtVAXODVI8z4A2JxgvKxHrC/mjeiieMM7rs6FLijytUyODOkluy4HX1XkCAZvmLljjHRD8VegVwi5L13HxLm6PtKqA87jL7DT1qFo/5xjVcf5VqL/lv+2YmEvbPU6kEY2qYpiTCeUEaZXt7da2jyBDO/kvL7mbfwlDJcI3w5BqDvImjYS5smXzYr2qm8Q7fEvqPkaQp1EmIKCNdmDpO4sJlbqw6tMMN73kZp611Y8jEVLkiAg+psUA/cjQiMRYOsGZkpWrY/84tGvQ/ts1+iuE+cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rf4JueDXN3tzBTkABoRx+ja7YEDbKZ624T7+X1MZzY0=; b=PNcDwllfhqqBCoWxyEBwwkT9xSbQXkyi73p1mIofllP53SPMeh+qZzG+Qow2kEJiwu2Frs3h7buWQDBx2LoijUWPKFfc8f4KUYCwtGeqq7kgxhdMtLZdC3W7SxOP4od2PaFE+mCDdk/exbkt64FAZTkD/LJx9jrxuUQGdH7qOi4= Received: from SJ0PR05CA0043.namprd05.prod.outlook.com (2603:10b6:a03:33f::18) by SA1PR12MB6703.namprd12.prod.outlook.com (2603:10b6:806:253::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.21; Thu, 20 Jun 2024 05:48:13 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:33f:cafe::de) by SJ0PR05CA0043.outlook.office365.com (2603:10b6:a03:33f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.34 via Frontend Transport; Thu, 20 Jun 2024 05:48:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 20 Jun 2024 05:48:12 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:12 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:10 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 5/9] net: ethtool: add an extack parameter to new rxfh_context APIs Date: Thu, 20 Jun 2024 06:47:08 +0100 Message-ID: <9bab54f2bf873605d200e6fdd0232dc7fd8d084f.1718862050.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE0:EE_|SA1PR12MB6703:EE_ X-MS-Office365-Filtering-Correlation-Id: e1043c46-dd85-441f-7d1d-08dc90ec92dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|376011|7416011|36860700010|82310400023|1800799021; X-Microsoft-Antispam-Message-Info: WyiLOChj1rQJo2YJXYioVgJxcUT6c4cCVPtC98zp3R90gYfqFvBdM0uR0U9TAJ6tcW1whUxCVS0ZmRTklnUqzPUks/PUN3pXZACk2/bjy/SkyJPybH+yKx32eyReeoEB6QxFuxurXqQjV8LG7jmGJceJIjodd2EVAWXhPV2EA/2UcEmevNNglB5+kyPkZewBpAJ5+qrwRqWsKML8ngZE1Y/tFUxGyGFMjVgS++Yg/4Oo5+O2BotzBTxgQNdCQAIhv2oOUYEjywxxlK4/Tl5puZ+hH+4MATVOCx1IDl63doDrUVXr1mWIZLU1XnbvhTpE5AzM/6qn4wPi8gH9RYk2p1U2+wK1DTJQ4pHjo7c3U4eJGz2rnewgkrdkLmXyl211FZlzHKZ4J99Naa+UJ7o0/D9677eAsbsvMvwaqRkkW8nNNWJgCbvQs1aM2scIcN3w9UkmlUuY45vWNsGMnq0PyjO1Q7OSd37Wt6hqPd5K9rl9RnY4zevFl576DD3qJfNOPkZpQ0xRvjn/FZp0N98U8H6U949yGhfB9i1OhGnEU0IriQlNO2CA/aYx/Rm2WM8qAxyex7Pgf16zaAUpun8FSLDitcKoxaSol53WXzRrdYPYtmGvDOqmd5/99uW+dwwSfP5YclhsOf4xQGvqhOE0XsXwrk8pbC6xOgNgTDEgZr3McewTLfFY1mYgEZ+vI9NW3ReLjIDm5K39THvY63laNZiaCejxcorZd35NTLelwxKEGQoCoq+twG9lL29/Ue0fGb8lqfv10S/vpS9EIu/ZnE/XvwSk0i2XI5U0CgKhPUA40zv8TpnXJzqOlp5hkm/+7vMsszyigRGHWJlDQVybph7m4a2PaTLWNr0uvQdcw9QqWwrVJJdHXq+gmcFsi72mm73tJE8bOpCio+pZh0uzqt7PvqWIkfuIE5nfoX4jqq0zrSsXKdV8ZI/jAzCcO2lRr8dMCF+CEaNIuCxlaKadJMtzrcoOWgEismVuP5k0mQIMj95wEQo1CzmfCUMoIySpY32ft3QLXOXkyNDPilTfuVhsoN9Tk/g0ZZ+ZMVgUWzfpqvgnrvlMKlMxN/JniTBCeAzObbm0SHjuyu2gSNcK8/8r0EGL8CCPg6BXDrWC03/SEnNwCWV53K2zCC30gae7l3DiN+dO8/bYGzqHpLVI+euPxYx6QiaTzCXukY6doGZN1VMaJuUz7JteqnXotdFPdKW2LqGdmbM90VnW3F4BYUglpDgkflWsYWQG00d18OZg4vCjKCRINf5RbhNFJ9LxFgh2SfvNXvnk9cLCwwX4XplpGpZ5zOp0UuaTBEF2RRm3eM2mJ57RjBBe0cprItwPx1NH6x7l3qQwYBTnWgQQiM1O3nSsJKsYTiXwkqsnkHmghALzSe52muaMgWK1iuXtOQ9SKuFBKwCAgGyUJPxc1Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(376011)(7416011)(36860700010)(82310400023)(1800799021);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:12.9122 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1043c46-dd85-441f-7d1d-08dc90ec92dc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6703 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Currently passed as NULL, but will allow drivers to report back errors when ethnl support for these ops is added. Signed-off-by: Edward Cree --- include/linux/ethtool.h | 9 ++++++--- net/core/dev.c | 2 +- net/ethtool/ioctl.c | 9 ++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index d9570b97154b..f8688e77ca62 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1001,13 +1001,16 @@ struct ethtool_ops { struct netlink_ext_ack *extack); int (*create_rxfh_context)(struct net_device *, struct ethtool_rxfh_context *ctx, - const struct ethtool_rxfh_param *rxfh); + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack); int (*modify_rxfh_context)(struct net_device *, struct ethtool_rxfh_context *ctx, - const struct ethtool_rxfh_param *rxfh); + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack); int (*remove_rxfh_context)(struct net_device *, struct ethtool_rxfh_context *ctx, - u32 rss_context); + u32 rss_context, + struct netlink_ext_ack *extack); void (*get_channels)(struct net_device *, struct ethtool_channels *); int (*set_channels)(struct net_device *, struct ethtool_channels *); int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); diff --git a/net/core/dev.c b/net/core/dev.c index e875b0a579b4..9ca9424ea8b1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11205,7 +11205,7 @@ static void netdev_rss_contexts_free(struct net_device *dev) xa_erase(&dev->ethtool->rss_ctx, context); if (dev->ethtool_ops->create_rxfh_context) dev->ethtool_ops->remove_rxfh_context(dev, ctx, - context); + context, NULL); else dev->ethtool_ops->set_rxfh(dev, &rxfh, NULL); kfree(ctx); diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 2b75d84c3078..244e565e1365 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1423,12 +1423,15 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, if (rxfh.rss_context && ops->create_rxfh_context) { if (create) - ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev); + ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev, + extack); else if (rxfh_dev.rss_delete) ret = ops->remove_rxfh_context(dev, ctx, - rxfh.rss_context); + rxfh.rss_context, + extack); else - ret = ops->modify_rxfh_context(dev, ctx, &rxfh_dev); + ret = ops->modify_rxfh_context(dev, ctx, &rxfh_dev, + extack); } else { ret = ops->set_rxfh(dev, &rxfh_dev, extack); } From patchwork Thu Jun 20 05:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704857 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2075.outbound.protection.outlook.com [40.107.93.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D805E381DE for ; Thu, 20 Jun 2024 05:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862500; cv=fail; b=K8+wkb/074/YxN5vwC68o1einp/GNtNpX2MdhCif6fzPo8SBFJat6sclaHZfU4OJUd21QfJ9WxCuCbI3Zg9izVmtn2jIBHY4XTVVwiIdSOyaJKEZ5YQxfKw39/YhghRfokLakouXueNQSTlsEb+OXfuusU+KCe7fcYT+rB228T8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862500; c=relaxed/simple; bh=K2lbEuHcgFmq46cQqGh/D0XHvl/WsPue3D7qyWPfiPA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I0O9ICV0+izYRGr1K/pUkgwauQTigS/Cou55e0kqGwiVV3pBHRmsmLvs/bqCv6JoZboNasMpGhBl/p1i/c08VkThd98xDTELlQb3oX2uOnmGH8wBhRb+xaWaz+JiL6zqssqEaMJLAFRcenIYiBgXhuzXb9YerEHAd+XBU2Pg1ro= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=OJRZdYbS; arc=fail smtp.client-ip=40.107.93.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="OJRZdYbS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MAf4nNSosxedPKiQy5OVVf+iug4yv8tNNgzlEmE0BQPdvhwVFtjF8lQUXOJN8fApyRJhgteO8MOATsO0L1CCUl1youFlN9prycncPfTnwjLcPZQgzQOTLc8xDUF4sIt7sxtOzAl0l2apankKtTCtn86H+DIPb/oZXdvOHBK3QJcIJiddYexwyRZTxVZDPJ0G8NcU7ykmr7riQb/iTUNHpbMX3PCHFIjFHc3zVM9Vf6IwOqBeyv1dZvGDcedAwV04w5LyA1x2OyQh2AY6PbF0B5vR7lD1LdNhHLr9mqBslvoR4BgzX1owHv04ST2TADic5ryhZ6AOsDTse3YwnsL17A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xl2O1y5Fp85cOgybWxSQrtQD9aT3utB2CiihAy+Sp60=; b=WeBb2vzEs8PMSRzAl5smZnzb/7ZuxMs+Nofsr5kCYBerarqZBv4ThLpRKJHD3N8u9YjUjLVKXrrqtV9gqCtBV0o0HTlw7uO1G6tOUIL0QL4AxxLx3370JIc4AqM92mLitFQr7f5jIKotCPNcSTABqJBFUlHxnYI9Kzy4Bsn5DI+CXh0V8cDJ3MTM7k0M2tsKVrP0Z42UiTIPc7oaG2MTr9565WnvrBY0sG3ID+fpGQrBdQfZMort+wB/bETL+eUxyZ45iwr5Vk8YJ5F7Ge+pkBtW/kITluYXAzBD6NnSJh68tCOhaaPNJzjqr2e6EIqcuNL47awWA7vPcmoJZZVCBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xl2O1y5Fp85cOgybWxSQrtQD9aT3utB2CiihAy+Sp60=; b=OJRZdYbSzfXYtOkBlBWpQbsS5lDtjLFHbltzR7NHvr1NqZWC7Ke2zEQehUdnFWeePlAcRjvSYcV3RLv6+uEWVggS9ximEr/Zd8vvbWv0SB/6N4vaIb/BTuLx4Uv1dvV8NlMrYqfFkLBsXn/ajritjoqEjPm82YKARBTkSZrU16I= Received: from SJ0PR05CA0039.namprd05.prod.outlook.com (2603:10b6:a03:33f::14) by MW6PR12MB8758.namprd12.prod.outlook.com (2603:10b6:303:23d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.32; Thu, 20 Jun 2024 05:48:16 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:33f:cafe::10) by SJ0PR05CA0039.outlook.office365.com (2603:10b6:a03:33f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31 via Frontend Transport; Thu, 20 Jun 2024 05:48:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 20 Jun 2024 05:48:16 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:14 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:12 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 6/9] net: ethtool: add a mutex protecting RSS contexts Date: Thu, 20 Jun 2024 06:47:09 +0100 Message-ID: <6781c564c4629c2ed9c201ab7b67296baddfded2.1718862050.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE0:EE_|MW6PR12MB8758:EE_ X-MS-Office365-Filtering-Correlation-Id: f4e3f356-ce2a-432f-53da-08dc90ec94b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|7416011|1800799021|376011|36860700010|82310400023; X-Microsoft-Antispam-Message-Info: k65RwiD8ZLVmtzjLPDXLy4oWzSgAP6/rBoVMnoab/YU5b5H83oIp/LmIogZss3EdbxUr2FdaHaH9n7ttiCeipiJxh5WIpzaglTnE3zoyxyXvYNYaFKr+fVij8gwEyoFf9MmY7mypnZYdmbov2myXupf1cSWq/zdR9F5TnSL/RNct/u9ukEjc3wDhqUWjxR+wpVVx9DQPn3E0fHmYjd+f8vwT7dzSEbesHrmNOqzvVuvMMC0i/TE1ieNZHdbksAderI6iFUUXkPBMYEfG22uE37smKIpisKao9GwhC+6v7sWt14lUCkiDi3i1jWBp81jlQSMQk//sJs6uK4WvJws37/d7O8KiTJtC06vzdwO++o16EevV0zo7X9jOMGhs1L3sehaPgRlLm1eUHvpSRBMT47H99AGeCznAaPt6jPiQgtVomi3TSa/PU+bwPAOEguoPGxPTnieZWsB02PcX2nOMhoyyOQBxXsZEZQFZtuL8iUsnll6AT7y/poMn0gAqUOqgclVXphNoXHzyCm69OQXbkS+DJIkBK/RUaO2/nwUSBp/oxAnADYmo3YqrxArUmANxTpKZWOeELl01zk5mZcefS0YXuivm9n5xHj2UOIRojbTrQcvt89fsh+kH7tljbszOxkX84NQkdHnE/llMtRHwP5+3V4sDwOylfUo7pjuzLN6vu2GZo5yN1YTXxG7SuOB9CUoEBYNyNPTZWBpCtOJwGa7cPO7aj4TC7KH7HGqe2mUKe9yMJjxAIIocKuvkhVm0TH8laCWETg/yZG/v8cC37xbagEh+DUAPGACysYmafJOTFX5EPJM44sHy+30tvUjOaG6OT0rMgU0sijtVrDFW9Hl2XlE+NtPB5F2O6af3vHY0Snxabq3KCuWrmC3JkBFMVP7LgEyTf/EfBltIvypdylqc1VVLo9/zwtTjA5TGF4cGZNDRxTqu8/1ULll1xiPUMKvltYbfPRbg/JD4Yfj1xHG5LIVjctzHauOTR8OlbPulAKnpExVzuayB0jbUIJnWWmz0p86OnK4g6yrTyCBw/6q1t32p9xwG9lfXQv9d+TkvWivtcLKlO4ChLEhumKN7OdFNc93m0DmDJZzLTMUy/+02t0z5wm1K5+sfeMpA3ez3CPHQ1s/fqq032BbxE82qIFHOJvO7FjKdhTmjv9eSDNx1xy4WE//ZQCpaJFOsJuaCiUFh5qTsciAjlVVwtOuxnOiXx8RmFjZ6Rhj4TBv25NRE6yj54U5+rQc+kefy4JzJJpaUl55Pg4TxPJ2NJ+ul/oI2fYRaD7evWoVmjYdu87fiYpgyDjlxrz+YGoTA1/1QmIXz7yI8Ni/zAIrBgAAB7PaLyOhB/xu9DbO0Hj3/3wgvNJ9bknVlkVd9x5HVZ53nKzkcmwQDr5bv5Ho7mywVEnlh5GsnitLwxKKnWr7Odw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(7416011)(1800799021)(376011)(36860700010)(82310400023);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:16.0216 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4e3f356-ce2a-432f-53da-08dc90ec94b9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8758 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree While this is not needed to serialise the ethtool entry points (which are all under RTNL), drivers may have cause to asynchronously access dev->ethtool->rss_ctx; taking dev->ethtool->rss_lock allows them to do this safely without needing to take the RTNL. Signed-off-by: Edward Cree --- include/linux/ethtool.h | 3 +++ net/core/dev.c | 5 +++++ net/ethtool/ioctl.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index f8688e77ca62..0d27e13952ad 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1098,10 +1098,13 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev, /** * struct ethtool_netdev_state - per-netdevice state for ethtool features * @rss_ctx: XArray of custom RSS contexts + * @rss_lock: Protects entries in @rss_ctx. May be taken from + * within RTNL. * @wol_enabled: Wake-on-LAN is enabled */ struct ethtool_netdev_state { struct xarray rss_ctx; + struct mutex rss_lock; unsigned wol_enabled:1; }; diff --git a/net/core/dev.c b/net/core/dev.c index 9ca9424ea8b1..4cd988b8a74a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10287,6 +10287,7 @@ int register_netdevice(struct net_device *dev) /* rss ctx ID 0 is reserved for the default context, start from 1 */ xa_init_flags(&dev->ethtool->rss_ctx, XA_FLAGS_ALLOC1); + mutex_init(&dev->ethtool->rss_lock); spin_lock_init(&dev->addr_list_lock); netdev_set_addr_lockdep_class(dev); @@ -11192,6 +11193,7 @@ static void netdev_rss_contexts_free(struct net_device *dev) struct ethtool_rxfh_context *ctx; unsigned long context; + mutex_lock(&dev->ethtool->rss_lock); xa_for_each(&dev->ethtool->rss_ctx, context, ctx) { struct ethtool_rxfh_param rxfh; @@ -11211,6 +11213,7 @@ static void netdev_rss_contexts_free(struct net_device *dev) kfree(ctx); } xa_destroy(&dev->ethtool->rss_ctx); + mutex_unlock(&dev->ethtool->rss_lock); } /** @@ -11323,6 +11326,8 @@ void unregister_netdevice_many_notify(struct list_head *head, if (dev->netdev_ops->ndo_uninit) dev->netdev_ops->ndo_uninit(dev); + mutex_destroy(&dev->ethtool->rss_lock); + if (skb) rtmsg_ifinfo_send(skb, dev, GFP_KERNEL, portid, nlh); diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 244e565e1365..9d2d677770db 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1282,6 +1282,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, struct netlink_ext_ack *extack = NULL; struct ethtool_rxnfc rx_rings; struct ethtool_rxfh rxfh; + bool locked = false; /* dev->ethtool->rss_lock taken */ u32 indir_bytes = 0; bool create = false; u8 *rss_config; @@ -1377,6 +1378,10 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, } } + if (rxfh.rss_context) { + mutex_lock(&dev->ethtool->rss_lock); + locked = true; + } if (create) { if (rxfh_dev.rss_delete) { ret = -EINVAL; @@ -1492,6 +1497,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, } out: + if (locked) + mutex_unlock(&dev->ethtool->rss_lock); kfree(rss_config); return ret; } From patchwork Thu Jun 20 05:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704858 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2056.outbound.protection.outlook.com [40.107.243.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EEAE381DE for ; Thu, 20 Jun 2024 05:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862506; cv=fail; b=QanTNqLLRAfHGAuYPqMKNkQM+DTQvMGNXfR95As7+JXTGnOAb25c3UNj43DS18PVfMV/rw1QFysGv1otXHTeBu1ecP8yQrZUwQLtuooC852h/4GsxUMaxi4iqNxhtW8Kjp1fTDhMkofiC0QtgqS37X5u2VsNRCiHzArLlndb5zk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862506; c=relaxed/simple; bh=eWypaym2s8orOMUBXf/FghP6jb79VJJdmruEKD6tWUg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XEU6qFCNBepKhVq9/u7dsG+qt6uNqjmj3ktDoO47/DrGbUlpRqLVmMZbLQdJ8fxdVynuTzxN2OmFPB/SVwIswLZB6RcwPxJXp/PAecB0P1agrrOyhV7rGgalBT1LhgNBMj7C7prSttoy28TsYHMfpESp2+T7aeGtIJIAYdYrwEw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=lQWHwsbj; arc=fail smtp.client-ip=40.107.243.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="lQWHwsbj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OjWLg0OF7ePI3ul7Mr3kyaMfNiaG/44hwC2Zdn+Jn8SiwUu/ihEhRMRzMzrJinTv6OGfPMVtMbU2pXZiesPui/bpBzk1UaPLcTGrZrhzJwocgJXggQpo8jAyx+KOVHfWd+55II0zQ+oeGKy+4dSZXXwiTexnMBCyf3FHUemFXXd2AJtEa1aEIBbO4+eavcYWDUVZYQus3myOtb1xXrIgHxiYzlAOxdBvo2elL+nsGOayFVVd3D7xZSlu9qofb8y3WqnjHbeFY2Z3lfmv3cdWwCbaib2nz/tGCwBmPy9N81tA87qA1Gvw5tAkVGix9LYO1J6PWHZHefT9UBOGZQQMTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dFq57EWAndgbrx6514onzvsi0JD7kTNtlRoPzCGnB80=; b=eOO63ZLsQE8bvIIC6VjmwpOH1aTcepXxhtLRN4r5PVQOC85ba1cxxn3KcZd49LWe/pRuu8kFeBfxVLurkb36EShU+PVHKE3p4lWsY8TXNPgzVNdPaTvQVOTwHqZ+PC58YRgX9KF9wkE2hH/8dUJx2+7figTrzVIZyqEgu8ZAAfTccq3DL2SpI0zgSnSK+raYp7cmsNtCXdBCEAh70e3/ix43VPv+fC4rWRym4b1nFBO/76y65HQOiiSCtcTrgal1Se8jIuSQmu4aV8BN7TXY5Bysk6gD9benUrhzfJ6h/sWQtOos6gSzSlBaAOF93PN5vzogmazOyHt3VxKHJPpeSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dFq57EWAndgbrx6514onzvsi0JD7kTNtlRoPzCGnB80=; b=lQWHwsbjE75zpsDvBQp+yiOxyTjIwMTZsZETioF3ibznHblNDgrk9FSK3NqIyIBWcdrrzpADIpUleoH6HZcz1D7k3ET+NueuSLMu5lXcIV95I+c4KiOc0Ld76zdQ98xDqqbmRrA1pj4M6i/cG8BXHND+Rje5ji/6t8cEYMEPmdk= Received: from SJ0PR03CA0097.namprd03.prod.outlook.com (2603:10b6:a03:333::12) by BL1PR12MB5851.namprd12.prod.outlook.com (2603:10b6:208:396::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Thu, 20 Jun 2024 05:48:19 +0000 Received: from SJ1PEPF00001CDD.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::23) by SJ0PR03CA0097.outlook.office365.com (2603:10b6:a03:333::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.33 via Frontend Transport; Thu, 20 Jun 2024 05:48:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDD.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 20 Jun 2024 05:48:18 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:17 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:15 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 7/9] sfc: use new rxfh_context API Date: Thu, 20 Jun 2024 06:47:10 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDD:EE_|BL1PR12MB5851:EE_ X-MS-Office365-Filtering-Correlation-Id: 247389db-6bf8-46bf-5f5d-08dc90ec9654 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|7416011|376011|1800799021|36860700010|82310400023; X-Microsoft-Antispam-Message-Info: YdwFCBjBNl0TYnLtwcZmUBfU7gkO+9EhGpTVi4lip3jzY+5PO+bS6IgwuxLEQT3kPesT1XxJcKAcu4RY93+YrfGIOsgcHIAr1mgWNnfm1l1fCO7QDh9KDK4YyyeA3AOjR9bMZdsFEh1au+ZKqJnlIkJogd2FaZT2bwQ/C2AGetqYnpxzPpcO7Fm1NKNRk54jaeXBcykv9q8Cd7IjKwtSAi2o31ZWUv/mQwUoGRFjOAarN6ab0zjHEjWS74hTwBvpDeWrC7cBlc3l6xbsSZmIQPTCORy/11TawXd7DUYZPvutGzxUQymDQiUeDhOgKHhdXKJScB2VCW0uXIeYs5vSBPWeABi5G1wfVvYEL/Sl2+ihwvmmB5Tf90r+Oc4rF1Ne22SjAjG7LM3V4hNV9trO1wblVJL6+icAKO1VdXm8VMQmXt+ro9wsiAd522sluwV4epSMNtDU/a85WXtC+ozDDGOmHFpvFcX9K8vCrxiuLILmIJp17w7XrqlO/fLNIPTZZGtZsskEY8zh9lUsfH/ObX2ClyN970vCbuf/c/NdAM7cl0la7iMscbQ/umCtLwi/H/MuN5c+1HMgFTLCGMJuNTQ4wxQXhvVtBno/debD+UmXeLkh9JmWTzFJItnVJJaiQUOzwZjTD7Uv57+/pTZNK3PvYOjb8wQIqaMvTJgzPbvtqbtvSoTiyygz7FzIau7Hjmcq/gOMCsWYPxbBk+1Gu56X0E1iHTf10wTWNbBgyXuHSSClzKKegVxS2y7QzSitmbwJ+JDaUpry4yJ96vX3PEAZsPYWNOVelSF3McFxIEneLNRzFr4LjqKI656QssAqtcdk+qs+PXMNwM+X/rFs33kEqfroDok6PcJylWLFcfl0KyH6VK5eRB79O2bjJOAsIcjSEIbO+jhi+ESSYPm9l/PuBXDWIlIOHqrHUhYYWGOR5uRp4qvxSJuGXMLvh2BgjyKYmSMAwt1wjlMqfc/OnsF5NadSFKrpqAlNI0AoJrkvcQ4mWdtnY3vkFZysdTQ8w0ub/VhdwzN9xx2UDFAaf8C8RUpTRDlNMhOY6G/MjjgNSqKW73TL9nukzA84+kDI40n4QpHY0hguPRyP7Yz39sG1PrypoGqZJLFyZc323r9cEvo8Dkflgz7jhJDtKdtjExzrz6JvMxop2UpBFKzTx18ep+rBYCtHd1llaVq2KWmj3gcl7uTCthveMa2FHChKAGWX60DSyUR35/FqS7w52mf7H3piP2qJ2nSY4CHZjlvdDf7RO3f2Osn8Q+cC3rWfas96AZLFjFbWWMbH9iwFqm3VzE/lBS4NQMU5DATIRmtfK0DiZUyuyFrzu763zFbgZWihS52N7S+I9RXxJVKbuy2FK7jRaSNMrxBu0NGy3d72mZCLVUmbe5prkrwmlIBss/G28FMsCm4Y4nwTuIqD8Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(7416011)(376011)(1800799021)(36860700010)(82310400023);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:18.7155 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 247389db-6bf8-46bf-5f5d-08dc90ec9654 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CDD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5851 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree The core is now responsible for allocating IDs and a memory region for us to store our state (struct efx_rss_context_priv), so we no longer need efx_alloc_rss_context_entry() and friends. Since the contexts are now maintained by the core, use the core's lock (net_dev->ethtool->rss_lock), rather than our own mutex (efx->rss_lock), to serialise access against changes; and remove the now-unused efx->rss_lock from struct efx_nic. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef10.c | 2 +- drivers/net/ethernet/sfc/ef100_ethtool.c | 4 + drivers/net/ethernet/sfc/efx.c | 2 +- drivers/net/ethernet/sfc/efx.h | 2 +- drivers/net/ethernet/sfc/efx_common.c | 10 +- drivers/net/ethernet/sfc/ethtool.c | 4 + drivers/net/ethernet/sfc/ethtool_common.c | 152 ++++++++++++---------- drivers/net/ethernet/sfc/ethtool_common.h | 12 ++ drivers/net/ethernet/sfc/mcdi_filters.c | 135 ++++++++++--------- drivers/net/ethernet/sfc/mcdi_filters.h | 8 +- drivers/net/ethernet/sfc/net_driver.h | 28 ++-- drivers/net/ethernet/sfc/rx_common.c | 64 ++------- drivers/net/ethernet/sfc/rx_common.h | 8 +- 13 files changed, 212 insertions(+), 219 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 8fa6c0e9195b..7d69302ffa0a 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -1396,7 +1396,7 @@ static void efx_ef10_table_reset_mc_allocations(struct efx_nic *efx) efx_mcdi_filter_table_reset_mc_allocations(efx); nic_data->must_restore_piobufs = true; efx_ef10_forget_old_piobufs(efx); - efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID; + efx->rss_context.priv.context_id = EFX_MCDI_RSS_CONTEXT_INVALID; /* Driver-created vswitches and vports must be re-created */ nic_data->must_probe_vswitching = true; diff --git a/drivers/net/ethernet/sfc/ef100_ethtool.c b/drivers/net/ethernet/sfc/ef100_ethtool.c index cf55202b3a7b..896ffca4aee2 100644 --- a/drivers/net/ethernet/sfc/ef100_ethtool.c +++ b/drivers/net/ethernet/sfc/ef100_ethtool.c @@ -59,8 +59,12 @@ const struct ethtool_ops ef100_ethtool_ops = { .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size, .get_rxfh_key_size = efx_ethtool_get_rxfh_key_size, + .rxfh_priv_size = sizeof(struct efx_rss_context_priv), .get_rxfh = efx_ethtool_get_rxfh, .set_rxfh = efx_ethtool_set_rxfh, + .create_rxfh_context = efx_ethtool_create_rxfh_context, + .modify_rxfh_context = efx_ethtool_modify_rxfh_context, + .remove_rxfh_context = efx_ethtool_remove_rxfh_context, .get_module_info = efx_ethtool_get_module_info, .get_module_eeprom = efx_ethtool_get_module_eeprom, diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index e9d9de8e648a..6f1a01ded7d4 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -299,7 +299,7 @@ static int efx_probe_nic(struct efx_nic *efx) if (efx->n_channels > 1) netdev_rss_key_fill(efx->rss_context.rx_hash_key, sizeof(efx->rss_context.rx_hash_key)); - efx_set_default_rx_indir_table(efx, &efx->rss_context); + efx_set_default_rx_indir_table(efx, efx->rss_context.rx_indir_table); /* Initialise the interrupt moderation settings */ efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000); diff --git a/drivers/net/ethernet/sfc/efx.h b/drivers/net/ethernet/sfc/efx.h index 48d3623735ba..7a6cab883d66 100644 --- a/drivers/net/ethernet/sfc/efx.h +++ b/drivers/net/ethernet/sfc/efx.h @@ -158,7 +158,7 @@ static inline s32 efx_filter_get_rx_ids(struct efx_nic *efx, } /* RSS contexts */ -static inline bool efx_rss_active(struct efx_rss_context *ctx) +static inline bool efx_rss_active(struct efx_rss_context_priv *ctx) { return ctx->context_id != EFX_MCDI_RSS_CONTEXT_INVALID; } diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index 4ebd5ae23eca..13cf647051af 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -714,7 +714,7 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method) mutex_lock(&efx->mac_lock); down_write(&efx->filter_sem); - mutex_lock(&efx->rss_lock); + mutex_lock(&efx->net_dev->ethtool->rss_lock); efx->type->fini(efx); } @@ -777,7 +777,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) if (efx->type->rx_restore_rss_contexts) efx->type->rx_restore_rss_contexts(efx); - mutex_unlock(&efx->rss_lock); + mutex_unlock(&efx->net_dev->ethtool->rss_lock); efx->type->filter_table_restore(efx); up_write(&efx->filter_sem); @@ -793,7 +793,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) fail: efx->port_initialized = false; - mutex_unlock(&efx->rss_lock); + mutex_unlock(&efx->net_dev->ethtool->rss_lock); up_write(&efx->filter_sem); mutex_unlock(&efx->mac_lock); @@ -1000,9 +1000,7 @@ int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev) efx->type->rx_hash_offset - efx->type->rx_prefix_size; efx->rx_packet_ts_offset = efx->type->rx_ts_offset - efx->type->rx_prefix_size; - INIT_LIST_HEAD(&efx->rss_context.list); - efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID; - mutex_init(&efx->rss_lock); + efx->rss_context.priv.context_id = EFX_MCDI_RSS_CONTEXT_INVALID; efx->vport_id = EVB_PORT_ID_ASSIGNED; spin_lock_init(&efx->stats_lock); efx->vi_stride = EFX_DEFAULT_VI_STRIDE; diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 37c69c8d90b1..0f5c68b8bab7 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -268,8 +268,12 @@ const struct ethtool_ops efx_ethtool_ops = { .set_rxnfc = efx_ethtool_set_rxnfc, .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size, .get_rxfh_key_size = efx_ethtool_get_rxfh_key_size, + .rxfh_priv_size = sizeof(struct efx_rss_context_priv), .get_rxfh = efx_ethtool_get_rxfh, .set_rxfh = efx_ethtool_set_rxfh, + .create_rxfh_context = efx_ethtool_create_rxfh_context, + .modify_rxfh_context = efx_ethtool_modify_rxfh_context, + .remove_rxfh_context = efx_ethtool_remove_rxfh_context, .get_ts_info = efx_ethtool_get_ts_info, .get_module_info = efx_ethtool_get_module_info, .get_module_eeprom = efx_ethtool_get_module_eeprom, diff --git a/drivers/net/ethernet/sfc/ethtool_common.c b/drivers/net/ethernet/sfc/ethtool_common.c index 7d5e5db4eac5..0a8d2c9ffce6 100644 --- a/drivers/net/ethernet/sfc/ethtool_common.c +++ b/drivers/net/ethernet/sfc/ethtool_common.c @@ -820,10 +820,10 @@ int efx_ethtool_get_rxnfc(struct net_device *net_dev, return 0; case ETHTOOL_GRXFH: { - struct efx_rss_context *ctx = &efx->rss_context; + struct efx_rss_context_priv *ctx = &efx->rss_context.priv; __u64 data; - mutex_lock(&efx->rss_lock); + mutex_lock(&net_dev->ethtool->rss_lock); if (info->flow_type & FLOW_RSS && info->rss_context) { ctx = efx_find_rss_context_entry(efx, info->rss_context); if (!ctx) { @@ -864,7 +864,7 @@ int efx_ethtool_get_rxnfc(struct net_device *net_dev, out_setdata_unlock: info->data = data; out_unlock: - mutex_unlock(&efx->rss_lock); + mutex_unlock(&net_dev->ethtool->rss_lock); return rc; } @@ -1167,31 +1167,33 @@ static int efx_ethtool_get_rxfh_context(struct net_device *net_dev, struct ethtool_rxfh_param *rxfh) { struct efx_nic *efx = efx_netdev_priv(net_dev); - struct efx_rss_context *ctx; + struct efx_rss_context_priv *ctx_priv; + struct efx_rss_context ctx; int rc = 0; if (!efx->type->rx_pull_rss_context_config) return -EOPNOTSUPP; - mutex_lock(&efx->rss_lock); - ctx = efx_find_rss_context_entry(efx, rxfh->rss_context); - if (!ctx) { + mutex_lock(&net_dev->ethtool->rss_lock); + ctx_priv = efx_find_rss_context_entry(efx, rxfh->rss_context); + if (!ctx_priv) { rc = -ENOENT; goto out_unlock; } - rc = efx->type->rx_pull_rss_context_config(efx, ctx); + ctx.priv = *ctx_priv; + rc = efx->type->rx_pull_rss_context_config(efx, &ctx); if (rc) goto out_unlock; rxfh->hfunc = ETH_RSS_HASH_TOP; if (rxfh->indir) - memcpy(rxfh->indir, ctx->rx_indir_table, - sizeof(ctx->rx_indir_table)); + memcpy(rxfh->indir, ctx.rx_indir_table, + sizeof(ctx.rx_indir_table)); if (rxfh->key) - memcpy(rxfh->key, ctx->rx_hash_key, + memcpy(rxfh->key, ctx.rx_hash_key, efx->type->rx_hash_key_size); out_unlock: - mutex_unlock(&efx->rss_lock); + mutex_unlock(&net_dev->ethtool->rss_lock); return rc; } @@ -1218,68 +1220,85 @@ int efx_ethtool_get_rxfh(struct net_device *net_dev, return 0; } -static int efx_ethtool_set_rxfh_context(struct net_device *net_dev, - struct ethtool_rxfh_param *rxfh, - struct netlink_ext_ack *extack) +int efx_ethtool_modify_rxfh_context(struct net_device *net_dev, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack) { struct efx_nic *efx = efx_netdev_priv(net_dev); - u32 *rss_context = &rxfh->rss_context; - struct efx_rss_context *ctx; - u32 *indir = rxfh->indir; - bool allocated = false; - u8 *key = rxfh->key; - int rc; + struct efx_rss_context_priv *priv; + const u32 *indir = rxfh->indir; + const u8 *key = rxfh->key; - if (!efx->type->rx_push_rss_context_config) + if (!efx->type->rx_push_rss_context_config) { + NL_SET_ERR_MSG_MOD(extack, + "NIC type does not support custom contexts"); return -EOPNOTSUPP; - - mutex_lock(&efx->rss_lock); - - if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) { - if (rxfh->rss_delete) { - /* alloc + delete == Nothing to do */ - rc = -EINVAL; - goto out_unlock; - } - ctx = efx_alloc_rss_context_entry(efx); - if (!ctx) { - rc = -ENOMEM; - goto out_unlock; - } - ctx->context_id = EFX_MCDI_RSS_CONTEXT_INVALID; - /* Initialise indir table and key to defaults */ - efx_set_default_rx_indir_table(efx, ctx); - netdev_rss_key_fill(ctx->rx_hash_key, sizeof(ctx->rx_hash_key)); - allocated = true; - } else { - ctx = efx_find_rss_context_entry(efx, *rss_context); - if (!ctx) { - rc = -ENOENT; - goto out_unlock; - } } - - if (rxfh->rss_delete) { - /* delete this context */ - rc = efx->type->rx_push_rss_context_config(efx, ctx, NULL, NULL); - if (!rc) - efx_free_rss_context_entry(ctx); - goto out_unlock; + /* Hash function is Toeplitz, cannot be changed */ + if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && + rxfh->hfunc != ETH_RSS_HASH_TOP) { + NL_SET_ERR_MSG_MOD(extack, "Only Toeplitz hash is supported"); + return -EOPNOTSUPP; } + priv = ethtool_rxfh_context_priv(ctx); + if (!key) - key = ctx->rx_hash_key; + key = ethtool_rxfh_context_key(ctx); if (!indir) - indir = ctx->rx_indir_table; + indir = ethtool_rxfh_context_indir(ctx); - rc = efx->type->rx_push_rss_context_config(efx, ctx, indir, key); - if (rc && allocated) - efx_free_rss_context_entry(ctx); - else - *rss_context = ctx->user_id; -out_unlock: - mutex_unlock(&efx->rss_lock); - return rc; + return efx->type->rx_push_rss_context_config(efx, priv, indir, key, + false); +} + +int efx_ethtool_create_rxfh_context(struct net_device *net_dev, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack) +{ + struct efx_nic *efx = efx_netdev_priv(net_dev); + struct efx_rss_context_priv *priv; + + priv = ethtool_rxfh_context_priv(ctx); + + priv->context_id = EFX_MCDI_RSS_CONTEXT_INVALID; + priv->rx_hash_udp_4tuple = false; + /* Generate default indir table and/or key if not specified. + * We use ctx as a place to store these; this is fine because + * we're doing a create, so if we fail then the ctx will just + * be deleted. + */ + if (!rxfh->indir) + efx_set_default_rx_indir_table(efx, ethtool_rxfh_context_indir(ctx)); + if (!rxfh->key) + netdev_rss_key_fill(ethtool_rxfh_context_key(ctx), + ctx->key_size); + if (rxfh->hfunc == ETH_RSS_HASH_NO_CHANGE) + ctx->hfunc = ETH_RSS_HASH_TOP; + if (rxfh->input_xfrm == RXH_XFRM_NO_CHANGE) + ctx->input_xfrm = 0; + return efx_ethtool_modify_rxfh_context(net_dev, ctx, rxfh, extack); +} + +int efx_ethtool_remove_rxfh_context(struct net_device *net_dev, + struct ethtool_rxfh_context *ctx, + u32 rss_context, + struct netlink_ext_ack *extack) +{ + struct efx_nic *efx = efx_netdev_priv(net_dev); + struct efx_rss_context_priv *priv; + + if (!efx->type->rx_push_rss_context_config) { + NL_SET_ERR_MSG_MOD(extack, + "NIC type does not support custom contexts"); + return -EOPNOTSUPP; + } + + priv = ethtool_rxfh_context_priv(ctx); + return efx->type->rx_push_rss_context_config(efx, priv, NULL, NULL, + true); } int efx_ethtool_set_rxfh(struct net_device *net_dev, @@ -1295,8 +1314,9 @@ int efx_ethtool_set_rxfh(struct net_device *net_dev, rxfh->hfunc != ETH_RSS_HASH_TOP) return -EOPNOTSUPP; - if (rxfh->rss_context) - return efx_ethtool_set_rxfh_context(net_dev, rxfh, extack); + /* Custom contexts should use new API */ + if (WARN_ON_ONCE(rxfh->rss_context)) + return -EIO; if (!indir && !key) return 0; diff --git a/drivers/net/ethernet/sfc/ethtool_common.h b/drivers/net/ethernet/sfc/ethtool_common.h index a680e5980213..fc52e891637d 100644 --- a/drivers/net/ethernet/sfc/ethtool_common.h +++ b/drivers/net/ethernet/sfc/ethtool_common.h @@ -49,6 +49,18 @@ int efx_ethtool_get_rxfh(struct net_device *net_dev, int efx_ethtool_set_rxfh(struct net_device *net_dev, struct ethtool_rxfh_param *rxfh, struct netlink_ext_ack *extack); +int efx_ethtool_create_rxfh_context(struct net_device *net_dev, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack); +int efx_ethtool_modify_rxfh_context(struct net_device *net_dev, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack); +int efx_ethtool_remove_rxfh_context(struct net_device *net_dev, + struct ethtool_rxfh_context *ctx, + u32 rss_context, + struct netlink_ext_ack *extack); int efx_ethtool_reset(struct net_device *net_dev, u32 *flags); int efx_ethtool_get_module_eeprom(struct net_device *net_dev, struct ethtool_eeprom *ee, diff --git a/drivers/net/ethernet/sfc/mcdi_filters.c b/drivers/net/ethernet/sfc/mcdi_filters.c index 4ff6586116ee..6ef96292909a 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.c +++ b/drivers/net/ethernet/sfc/mcdi_filters.c @@ -194,7 +194,7 @@ efx_mcdi_filter_push_prep_set_match_fields(struct efx_nic *efx, static void efx_mcdi_filter_push_prep(struct efx_nic *efx, const struct efx_filter_spec *spec, efx_dword_t *inbuf, u64 handle, - struct efx_rss_context *ctx, + struct efx_rss_context_priv *ctx, bool replacing) { u32 flags = spec->flags; @@ -245,7 +245,7 @@ static void efx_mcdi_filter_push_prep(struct efx_nic *efx, static int efx_mcdi_filter_push(struct efx_nic *efx, const struct efx_filter_spec *spec, u64 *handle, - struct efx_rss_context *ctx, bool replacing) + struct efx_rss_context_priv *ctx, bool replacing) { MCDI_DECLARE_BUF(inbuf, MC_CMD_FILTER_OP_EXT_IN_LEN); MCDI_DECLARE_BUF(outbuf, MC_CMD_FILTER_OP_EXT_OUT_LEN); @@ -345,9 +345,9 @@ static s32 efx_mcdi_filter_insert_locked(struct efx_nic *efx, bool replace_equal) { DECLARE_BITMAP(mc_rem_map, EFX_EF10_FILTER_SEARCH_LIMIT); + struct efx_rss_context_priv *ctx = NULL; struct efx_mcdi_filter_table *table; struct efx_filter_spec *saved_spec; - struct efx_rss_context *ctx = NULL; unsigned int match_pri, hash; unsigned int priv_flags; bool rss_locked = false; @@ -380,12 +380,12 @@ static s32 efx_mcdi_filter_insert_locked(struct efx_nic *efx, bitmap_zero(mc_rem_map, EFX_EF10_FILTER_SEARCH_LIMIT); if (spec->flags & EFX_FILTER_FLAG_RX_RSS) { - mutex_lock(&efx->rss_lock); + mutex_lock(&efx->net_dev->ethtool->rss_lock); rss_locked = true; if (spec->rss_context) ctx = efx_find_rss_context_entry(efx, spec->rss_context); else - ctx = &efx->rss_context; + ctx = &efx->rss_context.priv; if (!ctx) { rc = -ENOENT; goto out_unlock; @@ -548,7 +548,7 @@ static s32 efx_mcdi_filter_insert_locked(struct efx_nic *efx, out_unlock: if (rss_locked) - mutex_unlock(&efx->rss_lock); + mutex_unlock(&efx->net_dev->ethtool->rss_lock); up_write(&table->lock); return rc; } @@ -611,13 +611,13 @@ static int efx_mcdi_filter_remove_internal(struct efx_nic *efx, new_spec.priority = EFX_FILTER_PRI_AUTO; new_spec.flags = (EFX_FILTER_FLAG_RX | - (efx_rss_active(&efx->rss_context) ? + (efx_rss_active(&efx->rss_context.priv) ? EFX_FILTER_FLAG_RX_RSS : 0)); new_spec.dmaq_id = 0; new_spec.rss_context = 0; rc = efx_mcdi_filter_push(efx, &new_spec, &table->entry[filter_idx].handle, - &efx->rss_context, + &efx->rss_context.priv, true); if (rc == 0) @@ -764,7 +764,7 @@ static int efx_mcdi_filter_insert_addr_list(struct efx_nic *efx, ids = vlan->uc; } - filter_flags = efx_rss_active(&efx->rss_context) ? EFX_FILTER_FLAG_RX_RSS : 0; + filter_flags = efx_rss_active(&efx->rss_context.priv) ? EFX_FILTER_FLAG_RX_RSS : 0; /* Insert/renew filters */ for (i = 0; i < addr_count; i++) { @@ -833,7 +833,7 @@ static int efx_mcdi_filter_insert_def(struct efx_nic *efx, int rc; u16 *id; - filter_flags = efx_rss_active(&efx->rss_context) ? EFX_FILTER_FLAG_RX_RSS : 0; + filter_flags = efx_rss_active(&efx->rss_context.priv) ? EFX_FILTER_FLAG_RX_RSS : 0; efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0); @@ -1375,8 +1375,8 @@ void efx_mcdi_filter_table_restore(struct efx_nic *efx) struct efx_mcdi_filter_table *table = efx->filter_state; unsigned int invalid_filters = 0, failed = 0; struct efx_mcdi_filter_vlan *vlan; + struct efx_rss_context_priv *ctx; struct efx_filter_spec *spec; - struct efx_rss_context *ctx; unsigned int filter_idx; u32 mcdi_flags; int match_pri; @@ -1388,7 +1388,7 @@ void efx_mcdi_filter_table_restore(struct efx_nic *efx) return; down_write(&table->lock); - mutex_lock(&efx->rss_lock); + mutex_lock(&efx->net_dev->ethtool->rss_lock); for (filter_idx = 0; filter_idx < EFX_MCDI_FILTER_TBL_ROWS; filter_idx++) { spec = efx_mcdi_filter_entry_spec(table, filter_idx); @@ -1407,7 +1407,7 @@ void efx_mcdi_filter_table_restore(struct efx_nic *efx) if (spec->rss_context) ctx = efx_find_rss_context_entry(efx, spec->rss_context); else - ctx = &efx->rss_context; + ctx = &efx->rss_context.priv; if (spec->flags & EFX_FILTER_FLAG_RX_RSS) { if (!ctx) { netif_warn(efx, drv, efx->net_dev, @@ -1444,7 +1444,7 @@ void efx_mcdi_filter_table_restore(struct efx_nic *efx) } } - mutex_unlock(&efx->rss_lock); + mutex_unlock(&efx->net_dev->ethtool->rss_lock); up_write(&table->lock); /* @@ -1861,7 +1861,8 @@ bool efx_mcdi_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id, RSS_MODE_HASH_ADDRS << MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_UDP_IPV6_RSS_MODE_LBN |\ RSS_MODE_HASH_ADDRS << MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_OTHER_IPV6_RSS_MODE_LBN) -int efx_mcdi_get_rss_context_flags(struct efx_nic *efx, u32 context, u32 *flags) +static int efx_mcdi_get_rss_context_flags(struct efx_nic *efx, u32 context, + u32 *flags) { /* * Firmware had a bug (sfc bug 61952) where it would not actually @@ -1909,8 +1910,8 @@ int efx_mcdi_get_rss_context_flags(struct efx_nic *efx, u32 context, u32 *flags) * Defaults are 4-tuple for TCP and 2-tuple for UDP and other-IP, so we * just need to set the UDP ports flags (for both IP versions). */ -void efx_mcdi_set_rss_context_flags(struct efx_nic *efx, - struct efx_rss_context *ctx) +static void efx_mcdi_set_rss_context_flags(struct efx_nic *efx, + struct efx_rss_context_priv *ctx) { MCDI_DECLARE_BUF(inbuf, MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_LEN); u32 flags; @@ -1931,7 +1932,7 @@ void efx_mcdi_set_rss_context_flags(struct efx_nic *efx, } static int efx_mcdi_filter_alloc_rss_context(struct efx_nic *efx, bool exclusive, - struct efx_rss_context *ctx, + struct efx_rss_context_priv *ctx, unsigned *context_size) { MCDI_DECLARE_BUF(inbuf, MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN); @@ -2032,25 +2033,26 @@ void efx_mcdi_rx_free_indir_table(struct efx_nic *efx) { int rc; - if (efx->rss_context.context_id != EFX_MCDI_RSS_CONTEXT_INVALID) { - rc = efx_mcdi_filter_free_rss_context(efx, efx->rss_context.context_id); + if (efx->rss_context.priv.context_id != EFX_MCDI_RSS_CONTEXT_INVALID) { + rc = efx_mcdi_filter_free_rss_context(efx, efx->rss_context.priv.context_id); WARN_ON(rc != 0); } - efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID; + efx->rss_context.priv.context_id = EFX_MCDI_RSS_CONTEXT_INVALID; } static int efx_mcdi_filter_rx_push_shared_rss_config(struct efx_nic *efx, unsigned *context_size) { struct efx_mcdi_filter_table *table = efx->filter_state; - int rc = efx_mcdi_filter_alloc_rss_context(efx, false, &efx->rss_context, - context_size); + int rc = efx_mcdi_filter_alloc_rss_context(efx, false, + &efx->rss_context.priv, + context_size); if (rc != 0) return rc; table->rx_rss_context_exclusive = false; - efx_set_default_rx_indir_table(efx, &efx->rss_context); + efx_set_default_rx_indir_table(efx, efx->rss_context.rx_indir_table); return 0; } @@ -2058,26 +2060,27 @@ static int efx_mcdi_filter_rx_push_exclusive_rss_config(struct efx_nic *efx, const u32 *rx_indir_table, const u8 *key) { + u32 old_rx_rss_context = efx->rss_context.priv.context_id; struct efx_mcdi_filter_table *table = efx->filter_state; - u32 old_rx_rss_context = efx->rss_context.context_id; int rc; - if (efx->rss_context.context_id == EFX_MCDI_RSS_CONTEXT_INVALID || + if (efx->rss_context.priv.context_id == EFX_MCDI_RSS_CONTEXT_INVALID || !table->rx_rss_context_exclusive) { - rc = efx_mcdi_filter_alloc_rss_context(efx, true, &efx->rss_context, - NULL); + rc = efx_mcdi_filter_alloc_rss_context(efx, true, + &efx->rss_context.priv, + NULL); if (rc == -EOPNOTSUPP) return rc; else if (rc != 0) goto fail1; } - rc = efx_mcdi_filter_populate_rss_table(efx, efx->rss_context.context_id, - rx_indir_table, key); + rc = efx_mcdi_filter_populate_rss_table(efx, efx->rss_context.priv.context_id, + rx_indir_table, key); if (rc != 0) goto fail2; - if (efx->rss_context.context_id != old_rx_rss_context && + if (efx->rss_context.priv.context_id != old_rx_rss_context && old_rx_rss_context != EFX_MCDI_RSS_CONTEXT_INVALID) WARN_ON(efx_mcdi_filter_free_rss_context(efx, old_rx_rss_context) != 0); table->rx_rss_context_exclusive = true; @@ -2091,9 +2094,9 @@ static int efx_mcdi_filter_rx_push_exclusive_rss_config(struct efx_nic *efx, return 0; fail2: - if (old_rx_rss_context != efx->rss_context.context_id) { - WARN_ON(efx_mcdi_filter_free_rss_context(efx, efx->rss_context.context_id) != 0); - efx->rss_context.context_id = old_rx_rss_context; + if (old_rx_rss_context != efx->rss_context.priv.context_id) { + WARN_ON(efx_mcdi_filter_free_rss_context(efx, efx->rss_context.priv.context_id) != 0); + efx->rss_context.priv.context_id = old_rx_rss_context; } fail1: netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); @@ -2101,33 +2104,28 @@ static int efx_mcdi_filter_rx_push_exclusive_rss_config(struct efx_nic *efx, } int efx_mcdi_rx_push_rss_context_config(struct efx_nic *efx, - struct efx_rss_context *ctx, + struct efx_rss_context_priv *ctx, const u32 *rx_indir_table, - const u8 *key) + const u8 *key, bool delete) { int rc; - WARN_ON(!mutex_is_locked(&efx->rss_lock)); + WARN_ON(!mutex_is_locked(&efx->net_dev->ethtool->rss_lock)); if (ctx->context_id == EFX_MCDI_RSS_CONTEXT_INVALID) { + if (delete) + /* already wasn't in HW, nothing to do */ + return 0; rc = efx_mcdi_filter_alloc_rss_context(efx, true, ctx, NULL); if (rc) return rc; } - if (!rx_indir_table) /* Delete this context */ + if (delete) /* Delete this context */ return efx_mcdi_filter_free_rss_context(efx, ctx->context_id); - rc = efx_mcdi_filter_populate_rss_table(efx, ctx->context_id, - rx_indir_table, key); - if (rc) - return rc; - - memcpy(ctx->rx_indir_table, rx_indir_table, - sizeof(efx->rss_context.rx_indir_table)); - memcpy(ctx->rx_hash_key, key, efx->type->rx_hash_key_size); - - return 0; + return efx_mcdi_filter_populate_rss_table(efx, ctx->context_id, + rx_indir_table, key); } int efx_mcdi_rx_pull_rss_context_config(struct efx_nic *efx, @@ -2139,16 +2137,16 @@ int efx_mcdi_rx_pull_rss_context_config(struct efx_nic *efx, size_t outlen; int rc, i; - WARN_ON(!mutex_is_locked(&efx->rss_lock)); + WARN_ON(!mutex_is_locked(&efx->net_dev->ethtool->rss_lock)); BUILD_BUG_ON(MC_CMD_RSS_CONTEXT_GET_TABLE_IN_LEN != MC_CMD_RSS_CONTEXT_GET_KEY_IN_LEN); - if (ctx->context_id == EFX_MCDI_RSS_CONTEXT_INVALID) + if (ctx->priv.context_id == EFX_MCDI_RSS_CONTEXT_INVALID) return -ENOENT; MCDI_SET_DWORD(inbuf, RSS_CONTEXT_GET_TABLE_IN_RSS_CONTEXT_ID, - ctx->context_id); + ctx->priv.context_id); BUILD_BUG_ON(ARRAY_SIZE(ctx->rx_indir_table) != MC_CMD_RSS_CONTEXT_GET_TABLE_OUT_INDIRECTION_TABLE_LEN); rc = efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_GET_TABLE, inbuf, sizeof(inbuf), @@ -2164,7 +2162,7 @@ int efx_mcdi_rx_pull_rss_context_config(struct efx_nic *efx, RSS_CONTEXT_GET_TABLE_OUT_INDIRECTION_TABLE)[i]; MCDI_SET_DWORD(inbuf, RSS_CONTEXT_GET_KEY_IN_RSS_CONTEXT_ID, - ctx->context_id); + ctx->priv.context_id); BUILD_BUG_ON(ARRAY_SIZE(ctx->rx_hash_key) != MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN); rc = efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_GET_KEY, inbuf, sizeof(inbuf), @@ -2186,35 +2184,42 @@ int efx_mcdi_rx_pull_rss_config(struct efx_nic *efx) { int rc; - mutex_lock(&efx->rss_lock); + mutex_lock(&efx->net_dev->ethtool->rss_lock); rc = efx_mcdi_rx_pull_rss_context_config(efx, &efx->rss_context); - mutex_unlock(&efx->rss_lock); + mutex_unlock(&efx->net_dev->ethtool->rss_lock); return rc; } void efx_mcdi_rx_restore_rss_contexts(struct efx_nic *efx) { struct efx_mcdi_filter_table *table = efx->filter_state; - struct efx_rss_context *ctx; + struct ethtool_rxfh_context *ctx; + unsigned long context; int rc; - WARN_ON(!mutex_is_locked(&efx->rss_lock)); + WARN_ON(!mutex_is_locked(&efx->net_dev->ethtool->rss_lock)); if (!table->must_restore_rss_contexts) return; - list_for_each_entry(ctx, &efx->rss_context.list, list) { + xa_for_each(&efx->net_dev->ethtool->rss_ctx, context, ctx) { + struct efx_rss_context_priv *priv; + u32 *indir; + u8 *key; + + priv = ethtool_rxfh_context_priv(ctx); /* previous NIC RSS context is gone */ - ctx->context_id = EFX_MCDI_RSS_CONTEXT_INVALID; + priv->context_id = EFX_MCDI_RSS_CONTEXT_INVALID; /* so try to allocate a new one */ - rc = efx_mcdi_rx_push_rss_context_config(efx, ctx, - ctx->rx_indir_table, - ctx->rx_hash_key); + indir = ethtool_rxfh_context_indir(ctx); + key = ethtool_rxfh_context_key(ctx); + rc = efx_mcdi_rx_push_rss_context_config(efx, priv, indir, key, + false); if (rc) netif_warn(efx, probe, efx->net_dev, - "failed to restore RSS context %u, rc=%d" + "failed to restore RSS context %lu, rc=%d" "; RSS filters may fail to be applied\n", - ctx->user_id, rc); + context, rc); } table->must_restore_rss_contexts = false; } @@ -2276,7 +2281,7 @@ int efx_mcdi_vf_rx_push_rss_config(struct efx_nic *efx, bool user, { if (user) return -EOPNOTSUPP; - if (efx->rss_context.context_id != EFX_MCDI_RSS_CONTEXT_INVALID) + if (efx->rss_context.priv.context_id != EFX_MCDI_RSS_CONTEXT_INVALID) return 0; return efx_mcdi_filter_rx_push_shared_rss_config(efx, NULL); } @@ -2295,7 +2300,7 @@ int efx_mcdi_push_default_indir_table(struct efx_nic *efx, efx_mcdi_rx_free_indir_table(efx); if (rss_spread > 1) { - efx_set_default_rx_indir_table(efx, &efx->rss_context); + efx_set_default_rx_indir_table(efx, efx->rss_context.rx_indir_table); rc = efx->type->rx_push_rss_config(efx, false, efx->rss_context.rx_indir_table, NULL); } diff --git a/drivers/net/ethernet/sfc/mcdi_filters.h b/drivers/net/ethernet/sfc/mcdi_filters.h index c0d6558b9fd2..11b9f87ed9e1 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.h +++ b/drivers/net/ethernet/sfc/mcdi_filters.h @@ -145,9 +145,9 @@ void efx_mcdi_filter_del_vlan(struct efx_nic *efx, u16 vid); void efx_mcdi_rx_free_indir_table(struct efx_nic *efx); int efx_mcdi_rx_push_rss_context_config(struct efx_nic *efx, - struct efx_rss_context *ctx, + struct efx_rss_context_priv *ctx, const u32 *rx_indir_table, - const u8 *key); + const u8 *key, bool delete); int efx_mcdi_pf_rx_push_rss_config(struct efx_nic *efx, bool user, const u32 *rx_indir_table, const u8 *key); @@ -161,10 +161,6 @@ int efx_mcdi_push_default_indir_table(struct efx_nic *efx, int efx_mcdi_rx_pull_rss_config(struct efx_nic *efx); int efx_mcdi_rx_pull_rss_context_config(struct efx_nic *efx, struct efx_rss_context *ctx); -int efx_mcdi_get_rss_context_flags(struct efx_nic *efx, u32 context, - u32 *flags); -void efx_mcdi_set_rss_context_flags(struct efx_nic *efx, - struct efx_rss_context *ctx); void efx_mcdi_rx_restore_rss_contexts(struct efx_nic *efx); static inline void efx_mcdi_update_rx_scatter(struct efx_nic *efx) diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index f2dd7feb0e0c..b85c51cbe7f9 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -737,21 +737,24 @@ struct vfdi_status; /* The reserved RSS context value */ #define EFX_MCDI_RSS_CONTEXT_INVALID 0xffffffff /** - * struct efx_rss_context - A user-defined RSS context for filtering - * @list: node of linked list on which this struct is stored + * struct efx_rss_context_priv - driver private data for an RSS context * @context_id: the RSS_CONTEXT_ID returned by MC firmware, or * %EFX_MCDI_RSS_CONTEXT_INVALID if this context is not present on the NIC. - * For Siena, 0 if RSS is active, else %EFX_MCDI_RSS_CONTEXT_INVALID. - * @user_id: the rss_context ID exposed to userspace over ethtool. * @rx_hash_udp_4tuple: UDP 4-tuple hashing enabled + */ +struct efx_rss_context_priv { + u32 context_id; + bool rx_hash_udp_4tuple; +}; + +/** + * struct efx_rss_context - an RSS context + * @priv: hardware-specific state * @rx_hash_key: Toeplitz hash key for this RSS context * @indir_table: Indirection table for this RSS context */ struct efx_rss_context { - struct list_head list; - u32 context_id; - u32 user_id; - bool rx_hash_udp_4tuple; + struct efx_rss_context_priv priv; u8 rx_hash_key[40]; u32 rx_indir_table[128]; }; @@ -883,9 +886,7 @@ struct efx_mae; * @rx_packet_ts_offset: Offset of timestamp from start of packet data * (valid only if channel->sync_timestamps_enabled; always negative) * @rx_scatter: Scatter mode enabled for receives - * @rss_context: Main RSS context. Its @list member is the head of the list of - * RSS contexts created by user requests - * @rss_lock: Protects custom RSS context software state in @rss_context.list + * @rss_context: Main RSS context. * @vport_id: The function's vport ID, only relevant for PFs * @int_error_count: Number of internal errors seen recently * @int_error_expire: Time at which error count will be expired @@ -1052,7 +1053,6 @@ struct efx_nic { int rx_packet_ts_offset; bool rx_scatter; struct efx_rss_context rss_context; - struct mutex rss_lock; u32 vport_id; unsigned int_error_count; @@ -1416,9 +1416,9 @@ struct efx_nic_type { const u32 *rx_indir_table, const u8 *key); int (*rx_pull_rss_config)(struct efx_nic *efx); int (*rx_push_rss_context_config)(struct efx_nic *efx, - struct efx_rss_context *ctx, + struct efx_rss_context_priv *ctx, const u32 *rx_indir_table, - const u8 *key); + const u8 *key, bool delete); int (*rx_pull_rss_context_config)(struct efx_nic *efx, struct efx_rss_context *ctx); void (*rx_restore_rss_contexts)(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c index dcd901eccfc8..0b7dc75c40f9 100644 --- a/drivers/net/ethernet/sfc/rx_common.c +++ b/drivers/net/ethernet/sfc/rx_common.c @@ -557,69 +557,25 @@ efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf, napi_gro_frags(napi); } -/* RSS contexts. We're using linked lists and crappy O(n) algorithms, because - * (a) this is an infrequent control-plane operation and (b) n is small (max 64) - */ -struct efx_rss_context *efx_alloc_rss_context_entry(struct efx_nic *efx) +struct efx_rss_context_priv *efx_find_rss_context_entry(struct efx_nic *efx, + u32 id) { - struct list_head *head = &efx->rss_context.list; - struct efx_rss_context *ctx, *new; - u32 id = 1; /* Don't use zero, that refers to the master RSS context */ - - WARN_ON(!mutex_is_locked(&efx->rss_lock)); + struct ethtool_rxfh_context *ctx; - /* Search for first gap in the numbering */ - list_for_each_entry(ctx, head, list) { - if (ctx->user_id != id) - break; - id++; - /* Check for wrap. If this happens, we have nearly 2^32 - * allocated RSS contexts, which seems unlikely. - */ - if (WARN_ON_ONCE(!id)) - return NULL; - } + WARN_ON(!mutex_is_locked(&efx->net_dev->ethtool->rss_lock)); - /* Create the new entry */ - new = kmalloc(sizeof(*new), GFP_KERNEL); - if (!new) + ctx = xa_load(&efx->net_dev->ethtool->rss_ctx, id); + if (!ctx) return NULL; - new->context_id = EFX_MCDI_RSS_CONTEXT_INVALID; - new->rx_hash_udp_4tuple = false; - - /* Insert the new entry into the gap */ - new->user_id = id; - list_add_tail(&new->list, &ctx->list); - return new; -} - -struct efx_rss_context *efx_find_rss_context_entry(struct efx_nic *efx, u32 id) -{ - struct list_head *head = &efx->rss_context.list; - struct efx_rss_context *ctx; - - WARN_ON(!mutex_is_locked(&efx->rss_lock)); - - list_for_each_entry(ctx, head, list) - if (ctx->user_id == id) - return ctx; - return NULL; -} - -void efx_free_rss_context_entry(struct efx_rss_context *ctx) -{ - list_del(&ctx->list); - kfree(ctx); + return ethtool_rxfh_context_priv(ctx); } -void efx_set_default_rx_indir_table(struct efx_nic *efx, - struct efx_rss_context *ctx) +void efx_set_default_rx_indir_table(struct efx_nic *efx, u32 *indir) { size_t i; - for (i = 0; i < ARRAY_SIZE(ctx->rx_indir_table); i++) - ctx->rx_indir_table[i] = - ethtool_rxfh_indir_default(i, efx->rss_spread); + for (i = 0; i < ARRAY_SIZE(efx->rss_context.rx_indir_table); i++) + indir[i] = ethtool_rxfh_indir_default(i, efx->rss_spread); } /** diff --git a/drivers/net/ethernet/sfc/rx_common.h b/drivers/net/ethernet/sfc/rx_common.h index fbd2769307f9..75fa84192362 100644 --- a/drivers/net/ethernet/sfc/rx_common.h +++ b/drivers/net/ethernet/sfc/rx_common.h @@ -84,11 +84,9 @@ void efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf, unsigned int n_frags, u8 *eh, __wsum csum); -struct efx_rss_context *efx_alloc_rss_context_entry(struct efx_nic *efx); -struct efx_rss_context *efx_find_rss_context_entry(struct efx_nic *efx, u32 id); -void efx_free_rss_context_entry(struct efx_rss_context *ctx); -void efx_set_default_rx_indir_table(struct efx_nic *efx, - struct efx_rss_context *ctx); +struct efx_rss_context_priv *efx_find_rss_context_entry(struct efx_nic *efx, + u32 id); +void efx_set_default_rx_indir_table(struct efx_nic *efx, u32 *indir); bool efx_filter_is_mc_recipient(const struct efx_filter_spec *spec); bool efx_filter_spec_equal(const struct efx_filter_spec *left, From patchwork Thu Jun 20 05:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704859 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0973138DC8 for ; Thu, 20 Jun 2024 05:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862507; cv=fail; b=QiDG5uxnTw/f1ZLoYSyQijpd4fQ86x/ET4gyrQucZmaMFVr6tZmfUyvFZw0Kz0lOk+M5BA9dTUwVoyKCmZ8rcTedGaAyziyNIw0CWhkJIOAE36Mr9EYVub3qFrbx4Mtl+o0zCx+0jXlV9oqE3Gy6yKAs/l5fKONkcNErj367B+E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862507; c=relaxed/simple; bh=S58Z2DTtHqc/MWVZC/Flg4+hJICVreKJDq8ffgdVjHQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YxMdM7cmInWSg+p0sDvFyfHKCywUk9D9ck84b5B0zwMvjkSeMv+z5FLSl3PAX1uCk/de8Mfz8Fr5K5fZjx2LohiDQ0nQoh0tqcCo58ZjMbhzFEe0EowhCFSRPuL4cy/IrMCMTL5/lG7yYPSVas8dd0kVJBXAZnUCcOqLsl5Wfo8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=k4BfiLiW; arc=fail smtp.client-ip=40.107.220.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="k4BfiLiW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NzP4t3SZlvzxqLvMsug4KMl9+DlShFV/IPLFTEDPNCk59qeK8ugSFabPuMuOy5qgpB4NHhJVWoEI/dmrbpsy9i7edCgwakHCy6D6ufhf4S9W67M8JIiaK6GFYCkNsDded7CvtXfsANeVf8VzUSMesOjKZghJqrdjdphSGlkgDfeJlL6an3yp705nqrgLFOxarhlKvULzprh+tC3qISudBSh5jNaI8djUXQ9rayOIgKhGxMhsu5baPNG8do8thgXEGWhULYGEYYSVCYRX8aJZoWVsvDAWDYY7goPZRFgq+P7ZbqY+qoJrzrXrngOsaOB/o4sKfoVR64pBh2skKezKDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oqnrldJ2BlsKBOUSZzoSu/NhWcRyR9zFWqDLZ6YraNs=; b=ncuOvBxLrokUImK4uKsorKpOMg3bMocjbjJAStJxSVhoUohvi0i2XsVHdNkCCbhx/I1OZXUc8m9l/2tl2E2fRFAEB+CYTlhaSQ5PpxwmdSL5GlI/5j7Iul8Fpi7w8gUbwyq1o7waWC394JI+lqom04TUSfblSehlWbJXSfDApJ8IRCSHiQXvBjdDduWzsm+3Zj7NXDATJOMsuRg2n6eHyE5Q95EkAaALQnBUf6TwGcgBwFCz0hV4Q6M4uLUZWCD6l6qgrBEJl+Vj8wSZDkoQimdhYtqkvW7mGltjjFtEtpzijZYnEIQA18PfA4e9Ane/2OXo8ZilYZn8KP+TKWROkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oqnrldJ2BlsKBOUSZzoSu/NhWcRyR9zFWqDLZ6YraNs=; b=k4BfiLiWJjVX0WLezJBEVzHO2fvMS+dYM9YYYE+lhz4vVuwmYNZ6MpL76eZVPdMDVc92ad07goUb67GRrpxmYlX9IgAFBbSqxTBq+M/ueUjsdPI0C0kGICa4F8CwdC1l5W5eZOljwux3/VWSmZnh26lL8P9D9/TFIi4PB88oX2I= Received: from SJ0PR03CA0109.namprd03.prod.outlook.com (2603:10b6:a03:333::24) by DM4PR12MB6064.namprd12.prod.outlook.com (2603:10b6:8:af::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Thu, 20 Jun 2024 05:48:21 +0000 Received: from SJ1PEPF00001CDD.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::6d) by SJ0PR03CA0109.outlook.office365.com (2603:10b6:a03:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.34 via Frontend Transport; Thu, 20 Jun 2024 05:48:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDD.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 20 Jun 2024 05:48:21 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:20 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:17 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 8/9] net: ethtool: use the tracking array for get_rxfh on custom RSS contexts Date: Thu, 20 Jun 2024 06:47:11 +0100 Message-ID: <2f024e0b6d32880ff443c4e880af16ec2b5e456a.1718862050.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDD:EE_|DM4PR12MB6064:EE_ X-MS-Office365-Filtering-Correlation-Id: ce5aa72a-a41d-422f-d71d-08dc90ec97d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|7416011|376011|36860700010|82310400023|1800799021; X-Microsoft-Antispam-Message-Info: o0uJAhR2U0bZDQDIpTJXTYSBYhbR4td9hzUEZww/5pTnYCg1/60m03VLd6VrBqzBlvBrdYdWZpCHzDF0E7jFItWUu1df0P54ajSwZ/E3T2fMeJUjM+fQgIRM2L4fNIsNETkvyNpqPCM/hA8TJESOwSL71cSEF7Nspz286aoZ2chtU9TqXfGA2ZyONfB5QFaqNJ2SHMRLCMTD4Votmqk2GTLdt16ikZeRuqxdM+6W1orHAazLFUvCYuwsSHNv2iFRT15thm9oI2lwC3q/xiqlhP9ojQz1qk/Ep8ipg/6hnEW3fIUCDN/p1ZUwNhp+ZfrtQDNHo+vl8A7whoUDYl5FZZb+jJG2IF/iSMfSEuEkLvDXSHmQ0DZDs1h8yE1WNivziL62SO6g6g/6KT6LkmHmTcULiyazaY4rC5/KI3S72SRkXh953yVy3rqo/V17aEjg8+HMS8oIaNfrL8BpJyC0HEvd0PXXaIPZo+QSSc/d5e6cnhogwttyt36pwPsUn0o3arrgZOJT7O6Fqfz9t1j5DJBnB3vP099TqPoCRJ5kVxofUqXsSqzPTsiomA/54uMJKAZb4HMGyV8qP3df0HYw3VY6Q7NCFNiOEn5MTiKVAdZdLFPJEX1cQSYheR50Hue9Yv/jt1Y4AYFn3HSF/hYtxJTWKhtENbe8F0sjVOuUqzcGcxnXQTvKlf6AHkQZGEVGBX/cFudTOixH68mSkNcqFFmPm4bsQ5tOwlxfRJlSzCPVUpnMqyVxdOARrSfZd9wGHUO6QPAo6/isBKJhqo2AUD0ueKsyleolsG/x+WR/4bRh68Txlr+ey4jhB6+hUcqwnKPbu8UvQUxRk84wg6y6qAqn70cCcuArIxwJN5CgTTxyuP4GtQwIpMJAuSTR0C9sfVyG4yf8EGVh+5+wMrsF/cN5ywrNM3X14pHJjHGJURGoLqPpP25jtJX7WdAmQ0MZ+dTHo5AzQ6QLMZKy9Dtw0zH9RMZ0+lT5xzCpk+8oLYfg6z+MviOBVguYW8qgXwZoSa0+tPZ+Gm5o71GpfCzM/oFOsaeYWcRp2VfFDjSfceJA3SIPp2onC/ibd/tsXffIvRDedNTfflPdna+r5Wk5zV1/3ervoCp0LHEKaSi8em+UMXFO63g+LSm2DICYuaWExAZ4AjQ+fpgq5i7H7pKPNHcP9akHyK6+Iz817bfbB6qmO28IlRcnVGvp+e5yT2kLLmgMI4TNHxiMu3jl7LUkodBFBU+xKIAbRbCCotHGYhsjzPbISwvT8P3y9/mbCBPZDEVWt10YQg0KvbAxoDrN0m+sCqtcd3XEeHwvCl+rRJ4x0ZxHcB6/34WDVsIoqlECmwYT55eEnMGt1xziQWrb16V8fOoaYl9FJjAF67sKmIgPE4/XejHuM95Zrv8RzJoAmJnzMAzhbpbzfD81OGDcIQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(7416011)(376011)(36860700010)(82310400023)(1800799021);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:21.2154 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce5aa72a-a41d-422f-d71d-08dc90ec97d1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CDD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6064 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree On 'ethtool -x' with rss_context != 0, instead of calling the driver to read the RSS settings for the context, just get the settings from the rss_ctx xarray, and return them to the user with no driver involvement. Signed-off-by: Edward Cree --- net/ethtool/ioctl.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 9d2d677770db..ac562ee3662e 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1199,6 +1199,7 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, const struct ethtool_ops *ops = dev->ethtool_ops; struct ethtool_rxfh_param rxfh_dev = {}; u32 user_indir_size, user_key_size; + struct ethtool_rxfh_context *ctx; struct ethtool_rxfh rxfh; u32 indir_bytes; u8 *rss_config; @@ -1246,11 +1247,25 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, if (user_key_size) rxfh_dev.key = rss_config + indir_bytes; - rxfh_dev.rss_context = rxfh.rss_context; - - ret = dev->ethtool_ops->get_rxfh(dev, &rxfh_dev); - if (ret) - goto out; + if (rxfh.rss_context) { + ctx = xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context); + if (!ctx) { + ret = -ENOENT; + goto out; + } + if (rxfh_dev.indir) + memcpy(rxfh_dev.indir, ethtool_rxfh_context_indir(ctx), + indir_bytes); + if (rxfh_dev.key) + memcpy(rxfh_dev.key, ethtool_rxfh_context_key(ctx), + user_key_size); + rxfh_dev.hfunc = ctx->hfunc; + rxfh_dev.input_xfrm = ctx->input_xfrm; + } else { + ret = dev->ethtool_ops->get_rxfh(dev, &rxfh_dev); + if (ret) + goto out; + } if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, hfunc), &rxfh_dev.hfunc, sizeof(rxfh.hfunc))) { From patchwork Thu Jun 20 05:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: edward.cree@amd.com X-Patchwork-Id: 13704860 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5962E3BB50 for ; Thu, 20 Jun 2024 05:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862508; cv=fail; b=BEjjQv8iVXhplLmvcAYk6qtu73t9rYr2iS0MApqGScZtBg6UvTad9iCccAMnB7/uIyTy3Ce10CKwxzVj8hznEyXOAuUTI2KU2KCY562k2luonDyM0pOQYK70TxbQmegGajZDp6/cu7ETQsna72qzaSfQFf47pdKm6C/gp8qqG+8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718862508; c=relaxed/simple; bh=MVqFKwMuVbg1p1f133R9KZyczZ2dOPADbP9FY0KFgxI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RsaRfMB4mcbnBuq6Hqpul4YOLcxZI3KIUUaw74b3pq7w6YD1DQdM9c0s0Prwv5b1GRUmMOubVomE7VTFUS04VlHghM3OY4b+XDViW+MlgstKZKCEt3LaEIdMEgH5t/hgEDH75qwo6CMvxGUSVmY+D3Rs7iDiIee+XBy2ZSwTbWI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=UgZCXFPi; arc=fail smtp.client-ip=40.107.92.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="UgZCXFPi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E1vf6aK3Mx4GVqUy37LpirjJwAwBjJqWJ1kqyF0NLYRBCXOcKtaw7Mcmk1C6Yzzb8k1M4zYywQjVtOX46nNxV2Te+KGX48h6TCN3atHa1HzYf734RvueC5FWMKBjd8BumRLmOgGqRVOeQmH6krBCLUGv15mi4B7ktwu8JK0yKdj9jUW8lIR9XMLikAc/tqDDOIeZUvN/H4vDj97TLV8vpD2MS54khPb9LcowPk3omGFYYQozTIL1Idc1L40pjlhw+MsAfg2toRa1NymLqsMxPSg20WJ4WzLbr0D8j0+nps0TVfHZqPRedsmctG4YB6fspsnmwfrYkgt1jVxm+50OLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=icFCc05ET0EWxPmpOG2nMouyuNc46mfQpKKUpaY6ZtQ=; b=doQNIkJAojDciVVQgd833WfJp6yVucNFhKCI9GeiFv+R6L83576k+KsSG4DQV37Q6NWp2DAAv8Cp3k5ROs6pdZ0bQqanpQtQRk1bAPJmPgdzN9ITkZjqI50QM1MBrXzvmc965kg7us1TssM3BWBLLrLSoDJ1N1ou6vPEE3l2ue4GhPS/sInwqYjLN9nIUq2fi/WBwwu9cGOzqY0ZDtLM/5v8n2N4iLbRNBtQwyo5p6BaH6qmfg+DcY7qT37yRdTzojSWyJjiqMM2gdBAOOMu/PhdaV/mWuVc7XeOmD15cWzxl1C0sDisiF+FEGoD44mKV3e51zw3RwKPlVZdRXnlIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=icFCc05ET0EWxPmpOG2nMouyuNc46mfQpKKUpaY6ZtQ=; b=UgZCXFPi3/h1/cFQ4GBJILIf9ibO1zoid7qYVJLEGK7MP+AdZwHhoXW0AGHtkVeojWTkEuLy1GF3hUWK42AhPf3OQQhSrFAupwMdEloFAakM9gbDyzLreqz1BHBqL43w/f4z7ak0lL01c9HhhSeGRP3k0vCTJpEG4ZPkyb77Ez0= Received: from SJ0PR05CA0180.namprd05.prod.outlook.com (2603:10b6:a03:339::35) by DS0PR12MB6487.namprd12.prod.outlook.com (2603:10b6:8:c4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.21; Thu, 20 Jun 2024 05:48:24 +0000 Received: from SJ1PEPF00001CDE.namprd05.prod.outlook.com (2603:10b6:a03:339:cafe::de) by SJ0PR05CA0180.outlook.office365.com (2603:10b6:a03:339::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.33 via Frontend Transport; Thu, 20 Jun 2024 05:48:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDE.mail.protection.outlook.com (10.167.242.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Thu, 20 Jun 2024 05:48:23 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 20 Jun 2024 00:48:22 -0500 Received: from xcbecree42x.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 20 Jun 2024 00:48:20 -0500 From: To: , , , , CC: Edward Cree , , , , , , , , , , , , , , , Subject: [PATCH v6 net-next 9/9] sfc: remove get_rxfh_context dead code Date: Thu, 20 Jun 2024 06:47:12 +0100 Message-ID: <382dbfb2d2469c19beb01ffce3377b7f3158c3fd.1718862050.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: edward.cree@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDE:EE_|DS0PR12MB6487:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e644aae-943d-49a5-261e-08dc90ec994b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|82310400023|376011|36860700010|7416011; X-Microsoft-Antispam-Message-Info: gy/7sPEzLned9Z8HPmyd4M1dG6uXrEY8ww1LGtl1G3qIH4lVBsYlvaZ8mN4iWQSH6JA0Scm2K9CoZEj2cTeZ9xYEdD2ZozSdCpI+wNPD7gpfdiZPGv0il+2vdwZ0hT4HI+/ZHcKQlkH0aoUu50Oz1lr/NyEXyD+EdpyziCXgU29CQtGcWDcYnVO+77RWc6JrcqfcDPnStLqk83X/A6esJQlQerYIip7Vz6h8qgRO/eAYJSnygvJp2hxPIEJ28yQqniuaceA4YEl0bvwUHf6z1wSch/8HEGgFXhwyawv1wYu1OOaEtOhL3m9IYo4USNn68GNDVk/tzbKoKPJOdUb3O8qlP5MKwJ8REw7N2CMEFQ5ggeJ5SHVo0+rgSuZXQ8reGcqw1RcCHZIJPTz4s7mw6H93UvuDY2XOCMkwEIH4Gacve0oOfUYn3/MjCPw1d+Zq+9EpSJ/hcPrc6SqTiiCYf3y8u7YQiaT3ahqO5aVwyboUwywyKHkWjCxvW9v9H1TMcNIzzDUbiyOmc6tCh0O8fdmfBpw+pmw9QiULdzbtpgRh9RLCK9jQ8/dN9pjjRvPq+ULhMx32FdqzF7wm0oFwnOKReF25lVXT+cCYANY4CIvVHKUtpw09Aplz120m1SJ23eqLedrzDTNPXKTx2uBgxf0kV98vQoGdMCYvKwS8AlOIfR3zV7ncQZ/SnVebf15Lev4ozCHEoVSzt16VfHJf4cakIyX6Csu1wNZyR00zOjwCg4xoprpClmDpwRZ/CTL1+dAvFrSWiNPvPzMBAZi6uFdKFfu9G953kvzFlyI1DeONqrzSmWkG6IKGz2MlJnjmQGllOJfwbl8gFpuw5DVmkLsIh2wdZtIWecdnC7jB9sOcNfvueJh57lAtBy1D/tA6hMd4hsGMKw9SCRzXtIdQq3soQJUPNY19zmG6ESAg6yBiap219h4p56FfrcrQLJyNeEV4u0FVOEvbAsoOG2YyG26qX6qeG4hQkHZZ3pSgipQIHEYF4QaZPN+v2mFeojAp359bWd+Vy0XwKh6YkTzE6XBbHy0hVULYHBn1OvgypYDHLlCPsKYpdpjz7faJZNhWcw2t8NJGji6R8l0CxIK5OzLdonSQ13VcsfWl4vYjDWnsWU4rMzeiHIAq8pOn5CWj8iB8uKMVPfQGORzpbtXAEMtfD8J5RnVpt9JPQ9bUXufBk5DSIzoHjz6P64ixDKaao5APg6AgaEpoXKozn2wCm06SyXVmkkY72e2fEbeJKfksM9nqZbwnsKulA31G7wePD3anzYiPoOJwMnGoqVo4wkg52ObcvtaEEmiSDKy+mXK/59yGllLa2+6D3x6erB1RN4RjsdHRZwyB0QGfhXYtDfiioKNrV2zcQg7jquUZC57XwFx6s40QEYtGt6Uff4qAPXGi/hT3om7l8XMj51SKTQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230037)(1800799021)(82310400023)(376011)(36860700010)(7416011);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 05:48:23.6882 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e644aae-943d-49a5-261e-08dc90ec994b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CDE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6487 X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree The core now always satisfies 'ethtool -x context nonzero' from its own tracking, so our lookup code for that case is never called. Remove it. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ethtool_common.c | 38 ++--------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/sfc/ethtool_common.c b/drivers/net/ethernet/sfc/ethtool_common.c index 0a8d2c9ffce6..6ded44b86052 100644 --- a/drivers/net/ethernet/sfc/ethtool_common.c +++ b/drivers/net/ethernet/sfc/ethtool_common.c @@ -1163,48 +1163,14 @@ u32 efx_ethtool_get_rxfh_key_size(struct net_device *net_dev) return efx->type->rx_hash_key_size; } -static int efx_ethtool_get_rxfh_context(struct net_device *net_dev, - struct ethtool_rxfh_param *rxfh) -{ - struct efx_nic *efx = efx_netdev_priv(net_dev); - struct efx_rss_context_priv *ctx_priv; - struct efx_rss_context ctx; - int rc = 0; - - if (!efx->type->rx_pull_rss_context_config) - return -EOPNOTSUPP; - - mutex_lock(&net_dev->ethtool->rss_lock); - ctx_priv = efx_find_rss_context_entry(efx, rxfh->rss_context); - if (!ctx_priv) { - rc = -ENOENT; - goto out_unlock; - } - ctx.priv = *ctx_priv; - rc = efx->type->rx_pull_rss_context_config(efx, &ctx); - if (rc) - goto out_unlock; - - rxfh->hfunc = ETH_RSS_HASH_TOP; - if (rxfh->indir) - memcpy(rxfh->indir, ctx.rx_indir_table, - sizeof(ctx.rx_indir_table)); - if (rxfh->key) - memcpy(rxfh->key, ctx.rx_hash_key, - efx->type->rx_hash_key_size); -out_unlock: - mutex_unlock(&net_dev->ethtool->rss_lock); - return rc; -} - int efx_ethtool_get_rxfh(struct net_device *net_dev, struct ethtool_rxfh_param *rxfh) { struct efx_nic *efx = efx_netdev_priv(net_dev); int rc; - if (rxfh->rss_context) - return efx_ethtool_get_rxfh_context(net_dev, rxfh); + if (rxfh->rss_context) /* core should never call us for these */ + return -EINVAL; rc = efx->type->rx_pull_rss_config(efx); if (rc)