From patchwork Fri Jun 28 20:13:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13716567 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 53C40139566 for ; Fri, 28 Jun 2024 20:13:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605624; cv=none; b=kEIxnA2sEIuccD/Xf8oDHPQeEP+Lb0G7oz3brkmRrBorI/abnCCOluIiEQbiubGxeKuhRnjClO5XGVDjuG/BSWEwC/F5ztYfyJvI+tPXyM19/YJE7a7fkSZIO8QhMurK265cOOe2t9KYckDyzDnUHYgLU1y4m7HAosIT5SoJaJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605624; c=relaxed/simple; bh=dCuzEPV0cRPvXlLaCm+FzHbMF/7LdZEG0DVnVzRUOKo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kdFjaaMfsDwYUL7qnaiCPgkrPa7D6kT4C3VQjETfiN/xLavfq1CKulG7VI2KKH4XTFjejE0iB4Jxl7sbgHLgZiqRMSai8+PDAvkkW16beQ0NPyk0SOU2xQWXjEPS+XHcgyIBtbouVeppBmj9+voPpSdrtLlTqZQmzKNOY5E3CGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gS7e7C8T; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gS7e7C8T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719605623; x=1751141623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dCuzEPV0cRPvXlLaCm+FzHbMF/7LdZEG0DVnVzRUOKo=; b=gS7e7C8T1DIznubau4Uzy8GiUO+EPZ+hlHI3v6qcJxSpnRdt2lJMCpxA AVZx4FLvP9XUkN6OCuAAy/hmqHRShRCJijBHR+u1dCMb1K0xLKGF1n7+r WKBSoV/v1aFafffZwwqC0+kNlwP/9ohFxeVPl/GnMe0Mo0rZ8dFbASF9h R5UKFgzOiMZrnoXWmeOw8E+ND8iHbLWqqE82pqBrEJAgTnSLBG+2Te06k q/d/7iIqZgMHrGbOdujtQNRkeKCDGKrLxWODXOMiLRfNyufnozu1bygSM i9ctaIsjjkoo91s6QA+h+3oaceOR9BPMIhefOckcLipnDFudDzj81Kmtv A==; X-CSE-ConnectionGUID: poMfYY6JQHOsjOTkLxiCEw== X-CSE-MsgGUID: ShTBOxZDRo2te2rYMujl4Q== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="20674902" X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="20674902" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 13:13:42 -0700 X-CSE-ConnectionGUID: TmqDj21uQWCVhNNJzbn3Kw== X-CSE-MsgGUID: /bxAUluoR6+WboSpodBXUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="49735522" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa003.jf.intel.com with ESMTP; 28 Jun 2024 13:13:42 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Jesse Brandeburg , anthony.l.nguyen@intel.com, Przemek Kitszel , Paul Menzel Subject: [PATCH net-next 1/6] MAINTAINERS: update Intel Ethernet maintainers Date: Fri, 28 Jun 2024 13:13:19 -0700 Message-ID: <20240628201328.2738672-2-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> References: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jesse Brandeburg Since Jesse has moved to a new role, replace him with a new maintainer to work with Tony on representing Intel networking drivers in the kernel. Cc: Przemek Kitszel Signed-off-by: Jesse Brandeburg Acked-by: Paul Menzel Signed-off-by: Tony Nguyen --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 22328600cfd0..e0b6b419318f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11051,8 +11051,8 @@ F: include/drm/xe* F: include/uapi/drm/xe_drm.h INTEL ETHERNET DRIVERS -M: Jesse Brandeburg M: Tony Nguyen +M: Przemek Kitszel L: intel-wired-lan@lists.osuosl.org (moderated for non-subscribers) S: Supported W: https://www.intel.com/content/www/us/en/support.html From patchwork Fri Jun 28 20:13:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13716568 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 3B4DB7711F for ; Fri, 28 Jun 2024 20:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605625; cv=none; b=H6C8C90dtW7Gzw7DBvQ6ZiNpQsLspDxKIA41mrAbjhN7rwqHmfzJ9zgj9W8PcQZLdRzTgFU8cg4rkTjZyVZZjL0gEk22AZig22ubgeYzf44okMuFhzw73dCWWQKYoHHABNuA5mXzD89ZE/WXdIwrHoBz2Zrq3NLOb9jMrpyF1tQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605625; c=relaxed/simple; bh=6q4WAI/EFcYabyuZ6vtbkn+VA24fDec0Y/Ojo4+QM5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HLIwPtF6ehxVOma0JdkKwnVBQPk87MDGVNoly5FnOKiX25ufspc7yHUBlJ7FIcTtChuQM5NgN/yTrQS0VZOSMtv3RBEd2WoE9DqaEgwZIq8eTIgXX3exDOqECOnEGMHRZ3hcvT/mdot/bJhmxVJbBey6wx8l8sbtjBsFab5fgFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CeeB14nc; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CeeB14nc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719605624; x=1751141624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6q4WAI/EFcYabyuZ6vtbkn+VA24fDec0Y/Ojo4+QM5A=; b=CeeB14ncUybNOGtdvu0Zn89t9h90mA7Hx1kWBqB/D01V5tlOVhB1RRjE A9rr4i96reorigcdjvEovCFyvoRUO2bH/4cIjCFGyeQuyhTV9tA/nq4gP G5LRQlQvnGLA0qpEZw8oIQXh8Ft7NO3qhlF/ZfZb7IYNCEwdfCF9hXXlg Lb6W4s5X+gZaMVpA76B2Me0OAt/p5YdGS/wrCtstGvRHRTyw9HItfOxkm YQPAaIgp+JBuorzACxh1FN19UqnoRhhZ8pIFOg81sVLXPbXO+wXB8fB90 rj8r4Pc5Fzc5Lrek57ri4TMaaCRKJPyXN5cFfEByOCYFLNVoR5+Z+Bwsd w==; X-CSE-ConnectionGUID: tz72MyDTQH6lMuGYG7Ovcw== X-CSE-MsgGUID: iN2FMYm0TL2rb3sHcMrY5g== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="20674911" X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="20674911" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 13:13:42 -0700 X-CSE-ConnectionGUID: O3lRJS96T9iOSnyhmT4dSA== X-CSE-MsgGUID: TBBpPuFeRgSrl0KAdlIPbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="49735525" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa003.jf.intel.com with ESMTP; 28 Jun 2024 13:13:42 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Karthik Sundaravel , anthony.l.nguyen@intel.com, Rafal Romanowski Subject: [PATCH net-next 2/6] ice: Add get/set hw address for VFs using devlink commands Date: Fri, 28 Jun 2024 13:13:20 -0700 Message-ID: <20240628201328.2738672-3-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> References: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Karthik Sundaravel Changing the MAC address of the VFs is currently unsupported via devlink. Add the function handlers to set and get the HW address for the VFs. Signed-off-by: Karthik Sundaravel Tested-by: Rafal Romanowski Signed-off-by: Tony Nguyen --- .../ethernet/intel/ice/devlink/devlink_port.c | 59 ++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_sriov.c | 34 ++++++++--- drivers/net/ethernet/intel/ice/ice_sriov.h | 8 +++ 3 files changed, 91 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c index c9fbeebf7fb9..00fed5a61d62 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c @@ -372,6 +372,62 @@ void ice_devlink_destroy_pf_port(struct ice_pf *pf) devl_port_unregister(&pf->devlink_port); } +/** + * ice_devlink_port_get_vf_fn_mac - .port_fn_hw_addr_get devlink handler + * @port: devlink port structure + * @hw_addr: MAC address of the port + * @hw_addr_len: length of MAC address + * @extack: extended netdev ack structure + * + * Callback for the devlink .port_fn_hw_addr_get operation + * Return: zero on success or an error code on failure. + */ +static int ice_devlink_port_get_vf_fn_mac(struct devlink_port *port, + u8 *hw_addr, int *hw_addr_len, + struct netlink_ext_ack *extack) +{ + struct ice_vf *vf = container_of(port, struct ice_vf, devlink_port); + + ether_addr_copy(hw_addr, vf->dev_lan_addr); + *hw_addr_len = ETH_ALEN; + + return 0; +} + +/** + * ice_devlink_port_set_vf_fn_mac - .port_fn_hw_addr_set devlink handler + * @port: devlink port structure + * @hw_addr: MAC address of the port + * @hw_addr_len: length of MAC address + * @extack: extended netdev ack structure + * + * Callback for the devlink .port_fn_hw_addr_set operation + * Return: zero on success or an error code on failure. + */ +static int ice_devlink_port_set_vf_fn_mac(struct devlink_port *port, + const u8 *hw_addr, + int hw_addr_len, + struct netlink_ext_ack *extack) + +{ + struct devlink_port_attrs *attrs = &port->attrs; + struct devlink_port_pci_vf_attrs *pci_vf; + struct devlink *devlink = port->devlink; + struct ice_pf *pf; + u16 vf_id; + + pf = devlink_priv(devlink); + pci_vf = &attrs->pci_vf; + vf_id = pci_vf->vf; + + return __ice_set_vf_mac(pf, vf_id, hw_addr); +} + +static const struct devlink_port_ops ice_devlink_vf_port_ops = { + .port_fn_hw_addr_get = ice_devlink_port_get_vf_fn_mac, + .port_fn_hw_addr_set = ice_devlink_port_set_vf_fn_mac, +}; + /** * ice_devlink_create_vf_port - Create a devlink port for this VF * @vf: the VF to create a port for @@ -407,7 +463,8 @@ int ice_devlink_create_vf_port(struct ice_vf *vf) devlink_port_attrs_set(devlink_port, &attrs); devlink = priv_to_devlink(pf); - err = devl_port_register(devlink, devlink_port, vsi->idx); + err = devl_port_register_with_ops(devlink, devlink_port, vsi->idx, + &ice_devlink_vf_port_ops); if (err) { dev_err(dev, "Failed to create devlink port for VF %d, error %d\n", vf->vf_id, err); diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c index 067712f4923f..55ef33208456 100644 --- a/drivers/net/ethernet/intel/ice/ice_sriov.c +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c @@ -1416,21 +1416,23 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi) } /** - * ice_set_vf_mac - * @netdev: network interface device structure + * __ice_set_vf_mac - program VF MAC address + * @pf: PF to be configure * @vf_id: VF identifier * @mac: MAC address * * program VF MAC address + * Return: zero on success or an error code on failure */ -int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) +int __ice_set_vf_mac(struct ice_pf *pf, u16 vf_id, const u8 *mac) { - struct ice_pf *pf = ice_netdev_to_pf(netdev); + struct device *dev; struct ice_vf *vf; int ret; + dev = ice_pf_to_dev(pf); if (is_multicast_ether_addr(mac)) { - netdev_err(netdev, "%pM not a valid unicast address\n", mac); + dev_err(dev, "%pM not a valid unicast address\n", mac); return -EINVAL; } @@ -1459,13 +1461,13 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) if (is_zero_ether_addr(mac)) { /* VF will send VIRTCHNL_OP_ADD_ETH_ADDR message with its MAC */ vf->pf_set_mac = false; - netdev_info(netdev, "Removing MAC on VF %d. VF driver will be reinitialized\n", - vf->vf_id); + dev_info(dev, "Removing MAC on VF %d. VF driver will be reinitialized\n", + vf->vf_id); } else { /* PF will add MAC rule for the VF */ vf->pf_set_mac = true; - netdev_info(netdev, "Setting MAC %pM on VF %d. VF driver will be reinitialized\n", - mac, vf_id); + dev_info(dev, "Setting MAC %pM on VF %d. VF driver will be reinitialized\n", + mac, vf_id); } ice_reset_vf(vf, ICE_VF_RESET_NOTIFY); @@ -1476,6 +1478,20 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) return ret; } +/** + * ice_set_vf_mac - .ndo_set_vf_mac handler + * @netdev: network interface device structure + * @vf_id: VF identifier + * @mac: MAC address + * + * program VF MAC address + * Return: zero on success or an error code on failure + */ +int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) +{ + return __ice_set_vf_mac(ice_netdev_to_pf(netdev), vf_id, mac); +} + /** * ice_set_vf_trust * @netdev: network interface device structure diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.h b/drivers/net/ethernet/intel/ice/ice_sriov.h index 8f22313474d6..96549ca5c52c 100644 --- a/drivers/net/ethernet/intel/ice/ice_sriov.h +++ b/drivers/net/ethernet/intel/ice/ice_sriov.h @@ -28,6 +28,7 @@ #ifdef CONFIG_PCI_IOV void ice_process_vflr_event(struct ice_pf *pf); int ice_sriov_configure(struct pci_dev *pdev, int num_vfs); +int __ice_set_vf_mac(struct ice_pf *pf, u16 vf_id, const u8 *mac); int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac); int ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi); @@ -80,6 +81,13 @@ ice_sriov_configure(struct pci_dev __always_unused *pdev, return -EOPNOTSUPP; } +static inline int +__ice_set_vf_mac(struct ice_pf __always_unused *pf, + u16 __always_unused vf_id, const u8 __always_unused *mac) +{ + return -EOPNOTSUPP; +} + static inline int ice_set_vf_mac(struct net_device __always_unused *netdev, int __always_unused vf_id, u8 __always_unused *mac) From patchwork Fri Jun 28 20:13:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13716569 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 BEA2A77F2F for ; Fri, 28 Jun 2024 20:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605626; cv=none; b=evMGxxeeri4Ob+hV3yYRSCtt2OZ5QHVsV7QoIKwuHc9mbKz6oW2BYRUpPOzriYERkC0J9dDC1/ZRkmOnW9gk0LcYXRS//9tTVBNmb9wWWcmR+LhrCR4tED/r65REBVzycu6eO0mMkTZF8Ko0hwvk1MH51dUJZwTRhJ+yEDJpoYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605626; c=relaxed/simple; bh=HvMKm6+qqdgC0Tnafr08dBAYjUwYVKrZJ9VuYKZxaZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=owNdz98BOEDSnUt2dVpFSMbE1MAzreR9nnJcwcI+1nJA5iJ/q/XyNtNhQKiPNamZDXydMBDYr5TF0+xi7amSJwSLhL5QmXhmqnGaqGetEd4FFe0ifMyOFb/fEoVxNVvAS1HPlt9BBx3Az+0x7aNkdrB/zvwj5m3j8KUGzmmO5Vc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Tt9S9hMf; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Tt9S9hMf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719605625; x=1751141625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HvMKm6+qqdgC0Tnafr08dBAYjUwYVKrZJ9VuYKZxaZA=; b=Tt9S9hMfoGUG1vHt5xHNL8ZTNJ1nl1JY6DN/n8Rc8cVhEh59Izr92F0a GJqVkOyOdtFXuKzqvj0k5zbyPobsNRoNQEiLSlqenxOhVJXO73rWJpJ7W 4LR+pRPiKZ4iihf7UsclPsDtmWOZmiF89vTOhq8lljUtncEuKl3viz8AE fsvyFcB8fFKpnf+UZFrcqRb6TkTXWnH5MLtG+Mg+YS9CSNrcX4uqC35Uz fsZHnm5XmfxqIPjeH0d74pCaZeZh5SBdHuBLY2clW35DglHxuCqFPaEzd Ae44lVNd/iJpe3Ym5sRlKF4byL6fRAcU9vdPckrg/4eOBDuhzMhSZtKD+ A==; X-CSE-ConnectionGUID: wFvvowknTLy9+AsImeLBdg== X-CSE-MsgGUID: huC0dEgFTMaeLaguKdroqA== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="20674913" X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="20674913" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 13:13:42 -0700 X-CSE-ConnectionGUID: Dytd2mLtQRW73fY6rsAjeQ== X-CSE-MsgGUID: 8cmceQzDT0ef0HjvqwnkYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="49735529" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa003.jf.intel.com with ESMTP; 28 Jun 2024 13:13:42 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Eric Joyner , anthony.l.nguyen@intel.com, Michal Swiatkowski , Przemek Kitszel , Karen Ostrowska , Pucha Himasekhar Reddy Subject: [PATCH net-next 3/6] ice: Check all ice_vsi_rebuild() errors in function Date: Fri, 28 Jun 2024 13:13:21 -0700 Message-ID: <20240628201328.2738672-4-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> References: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Eric Joyner Check the return value from ice_vsi_rebuild() and prevent the usage of incorrectly configured VSI. Reviewed-by: Michal Swiatkowski Reviewed-by: Przemek Kitszel Signed-off-by: Eric Joyner Signed-off-by: Karen Ostrowska Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/ice_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 080efb7473aa..f4a39016a675 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -4158,13 +4158,17 @@ int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx, bool locked) /* set for the next time the netdev is started */ if (!netif_running(vsi->netdev)) { - ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT); + err = ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT); + if (err) + goto rebuild_err; dev_dbg(ice_pf_to_dev(pf), "Link is down, queue count change happens when link is brought up\n"); goto done; } ice_vsi_close(vsi); - ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT); + err = ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT); + if (err) + goto rebuild_err; ice_for_each_traffic_class(i) { if (vsi->tc_cfg.ena_tc & BIT(i)) @@ -4175,6 +4179,11 @@ int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx, bool locked) } ice_pf_dcb_recfg(pf, locked); ice_vsi_open(vsi); + goto done; + +rebuild_err: + dev_err(ice_pf_to_dev(pf), "Error during VSI rebuild: %d. Unload and reload the driver.\n", + err); done: clear_bit(ICE_CFG_BUSY, pf->state); return err; From patchwork Fri Jun 28 20:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13716570 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 EB9287A715 for ; Fri, 28 Jun 2024 20:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605626; cv=none; b=ZRztHnUKHyYzxUtR/Ip76Aff9N3ja/2H4tRt342ijptbjTCXzeNLo9MqWTaQ9xFuYMKZBgDkkLrQ2ycK3RidSLD2yMlZ6ld09tJTceG5zb1oiO2fs6KxWu47OsyNDhaoSpv/BY/qcmynm5IKKuaJdjD15kO0/rNgbeMgo7gqJJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605626; c=relaxed/simple; bh=CAxcZH+NrpatAL3bUe6zzlaJe/uUM5njK7rQLTWoiRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NSKylZm8Vamwgzs5G+O5uCagww/lRGx94l/uoe0TwhOIz7NjBM+InuEfy/YLFi93DQ2RLh8mTSgMRUc9kLlZvUB2lGnj/6TtAwnXcExGBfri/SQNHowL6aH+AOn63qrcRVhUNGNeDM5WXLL0dXToEWclf8WEsiXs3hs9TvVNW9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FOwZPdDZ; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FOwZPdDZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719605625; x=1751141625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CAxcZH+NrpatAL3bUe6zzlaJe/uUM5njK7rQLTWoiRQ=; b=FOwZPdDZjg7ZgCAsejp8wbNVYueLvll4k2dV08jqkGzYbitQE4hxQwQD 2CNX8zLqCtW5XmNtGfd8JjXQDDOBl7bmO2jTac3CUokaeyljv2grCFIqO 3ACwyES3neRUuD7R90Ff0kbKTgyvUZ/t0vNbzcpGr9poUN1ZEkmBI/rjZ Xr7aUes01bkjGter1d7++Q5NaDucFOBaiv8eUCpJ418cbp1bhpkxgDSFi e2tqQ2OUVhLIXZsQOQj0v7LRIA+P4OsEy6/cHfSmYRtlYZVAubhrkjSo2 qGWZISKtLWSDrs4L+yhYqxzsp4ab9y65XNz3Yk4MBYbchk4Cg/28XI5Wb A==; X-CSE-ConnectionGUID: TPxwFG13Q1ixb9YhqRvDaQ== X-CSE-MsgGUID: Bl9PLFnoQ9+50ppdWt4MCg== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="20674921" X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="20674921" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 13:13:42 -0700 X-CSE-ConnectionGUID: 73U08+TnSxGB4cXoRRNA4g== X-CSE-MsgGUID: zf8Q4g7XQUiRj5FQrPTl+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="49735532" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa003.jf.intel.com with ESMTP; 28 Jun 2024 13:13:42 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Paul Greenwalt , anthony.l.nguyen@intel.com, Pucha Himasekhar Reddy Subject: [PATCH net-next 4/6] ice: Allow different FW API versions based on MAC type Date: Fri, 28 Jun 2024 13:13:22 -0700 Message-ID: <20240628201328.2738672-5-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> References: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Paul Greenwalt Allow the driver to be compatible with different FW API versions based on the device's MAC type. Currently, E810 is only compatible with one FW API version. Now the driver can be compatible with different FW API versions for both E810 and E830. For example, E810 FW API version is 1.5.0 and E830 is 1.7.0. Signed-off-by: Paul Greenwalt Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/ice_controlq.c | 11 +++++++---- drivers/net/ethernet/intel/ice/ice_controlq.h | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c index ffe660f34992..ca80b34f2f8a 100644 --- a/drivers/net/ethernet/intel/ice/ice_controlq.c +++ b/drivers/net/ethernet/intel/ice/ice_controlq.c @@ -510,16 +510,19 @@ static int ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) */ static bool ice_aq_ver_check(struct ice_hw *hw) { - if (hw->api_maj_ver > EXP_FW_API_VER_MAJOR) { + u8 exp_fw_api_ver_major = EXP_FW_API_VER_MAJOR_BY_MAC(hw); + u8 exp_fw_api_ver_minor = EXP_FW_API_VER_MINOR_BY_MAC(hw); + + if (hw->api_maj_ver > exp_fw_api_ver_major) { /* Major API version is newer than expected, don't load */ dev_warn(ice_hw_to_dev(hw), "The driver for the device stopped because the NVM image is newer than expected. You must install the most recent version of the network driver.\n"); return false; - } else if (hw->api_maj_ver == EXP_FW_API_VER_MAJOR) { - if (hw->api_min_ver > (EXP_FW_API_VER_MINOR + 2)) + } else if (hw->api_maj_ver == exp_fw_api_ver_major) { + if (hw->api_min_ver > (exp_fw_api_ver_minor + 2)) dev_info(ice_hw_to_dev(hw), "The driver for the device detected a newer version of the NVM image than expected. Please install the most recent version of the network driver.\n"); - else if ((hw->api_min_ver + 2) < EXP_FW_API_VER_MINOR) + else if ((hw->api_min_ver + 2) < exp_fw_api_ver_minor) dev_info(ice_hw_to_dev(hw), "The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n"); } else { diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.h b/drivers/net/ethernet/intel/ice/ice_controlq.h index 8f2fd1613a95..1d54b1cdb1c5 100644 --- a/drivers/net/ethernet/intel/ice/ice_controlq.h +++ b/drivers/net/ethernet/intel/ice/ice_controlq.h @@ -21,9 +21,18 @@ /* Defines that help manage the driver vs FW API checks. * Take a look at ice_aq_ver_check in ice_controlq.c for actual usage. */ -#define EXP_FW_API_VER_BRANCH 0x00 -#define EXP_FW_API_VER_MAJOR 0x01 -#define EXP_FW_API_VER_MINOR 0x05 +#define EXP_FW_API_VER_MAJOR_E810 0x01 +#define EXP_FW_API_VER_MINOR_E810 0x05 + +#define EXP_FW_API_VER_MAJOR_E830 0x01 +#define EXP_FW_API_VER_MINOR_E830 0x07 + +#define EXP_FW_API_VER_MAJOR_BY_MAC(hw) ((hw)->mac_type == ICE_MAC_E830 ? \ + EXP_FW_API_VER_MAJOR_E830 : \ + EXP_FW_API_VER_MAJOR_E810) +#define EXP_FW_API_VER_MINOR_BY_MAC(hw) ((hw)->mac_type == ICE_MAC_E830 ? \ + EXP_FW_API_VER_MINOR_E830 : \ + EXP_FW_API_VER_MINOR_E810) /* Different control queue types: These are mainly for SW consumption. */ enum ice_ctl_q { From patchwork Fri Jun 28 20:13:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13716571 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 0FBE813A24B for ; Fri, 28 Jun 2024 20:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605627; cv=none; b=WOzPcPOi+x/LdTrUoo1qwTmmnnsfmpbnahrdpWcfupIMz1GtwLkU42PK45/7wjIbjfdxRViFojnhgnGV2KZpIQIo7kFbMUuqrgfVKwWukBrR4byI4K1oEJlf2alTTBREv+qbZz5F5tqbdNGmENhtVY0oI+kNnZ7WlqBY+gcYOrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605627; c=relaxed/simple; bh=jeU274rfYGSdJfTv19ueZQSsyitwBisqpRyfnwB1Jkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fvzs8XOVKyTxtzKCLGsZnEDmbORWKuXDCy2MhRkIVWmilmqEq6xLC2Ls73IFhgy0TSXl72cgwnZ53jc76Qb5bNEJcoWtjgtfssCuo7pddeYt1WBVXfnsBInYMWxRwKGKULmN3nCoLzFLgMFsT56TKOvu+FDEKdezKf4e0ZIx+Dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hlg/3FPq; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hlg/3FPq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719605626; x=1751141626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jeU274rfYGSdJfTv19ueZQSsyitwBisqpRyfnwB1Jkg=; b=hlg/3FPquVxNAtCLWHmUgimTQ/tSqmpEH6a8q3tEc7/5bed5TnjNbOXA iJSSB7Rc+7gF0W4HyUdaox3RF8Kurcau1mW2kCI7ZRNYnFOD2VzqK/S4d qzCJikoZZYL4O4K0p6UnlMjUgCVBO8CLORM/2qkhh9spBpvpEfclFr3rB OR7eZWnHTVdys3GvyLrv1BmSf8wzyMK4CLOXgBEA5aeNp0JsEYpzw3aWQ 1t91YYQbyJu4YZ8dzIhcJl4CGRpYUKpG3veNqX1uGIwXqBtWOdsyuHyqN qumN0HRsj1poWTDmcENYe5ZsciQn+K5vj2iN0dJ+UizhLC69g3eX2I7pI A==; X-CSE-ConnectionGUID: PpjuoOK3TDGQMsKsu4Tgew== X-CSE-MsgGUID: qyVrCu9kTm6jZ9RmzycjRw== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="20674926" X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="20674926" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 13:13:42 -0700 X-CSE-ConnectionGUID: w8YhLI1TSH63tuv7qFPi2g== X-CSE-MsgGUID: 2Etu5c99Sj2zDwzEdlCcxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="49735535" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa003.jf.intel.com with ESMTP; 28 Jun 2024 13:13:42 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Piotr Gardocki , anthony.l.nguyen@intel.com, Ahmed Zaki , Przemek Kitszel , Marcin Szycik , Simon Horman , Pucha Himasekhar Reddy Subject: [PATCH net-next 5/6] ice: Distinguish driver reset and removal for AQ shutdown Date: Fri, 28 Jun 2024 13:13:23 -0700 Message-ID: <20240628201328.2738672-6-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> References: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Piotr Gardocki Admin queue command for shutdown AQ contains a flag to indicate driver unload. However, the flag is always set in the driver, even for resets. It can cause the firmware to consider driver as unloaded once the PF reset is triggered on all ports of device, which could lead to unexpected results. Add an additional function parameter to functions that shutdown AQ, indicating whether the driver is actually unloading. Reviewed-by: Ahmed Zaki Reviewed-by: Przemek Kitszel Signed-off-by: Piotr Gardocki Signed-off-by: Marcin Szycik Reviewed-by: Simon Horman Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/ice_common.h | 2 +- drivers/net/ethernet/intel/ice/ice_controlq.c | 19 +++++++++++-------- drivers/net/ethernet/intel/ice/ice_main.c | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h index 86cc1df469dd..40dc735dc25c 100644 --- a/drivers/net/ethernet/intel/ice/ice_common.h +++ b/drivers/net/ethernet/intel/ice/ice_common.h @@ -23,7 +23,7 @@ int ice_check_reset(struct ice_hw *hw); int ice_reset(struct ice_hw *hw, enum ice_reset_req req); int ice_create_all_ctrlq(struct ice_hw *hw); int ice_init_all_ctrlq(struct ice_hw *hw); -void ice_shutdown_all_ctrlq(struct ice_hw *hw); +void ice_shutdown_all_ctrlq(struct ice_hw *hw, bool unloading); void ice_destroy_all_ctrlq(struct ice_hw *hw); int ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq, diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c index ca80b34f2f8a..ffaa6511c455 100644 --- a/drivers/net/ethernet/intel/ice/ice_controlq.c +++ b/drivers/net/ethernet/intel/ice/ice_controlq.c @@ -687,10 +687,12 @@ struct ice_ctl_q_info *ice_get_sbq(struct ice_hw *hw) * ice_shutdown_ctrlq - shutdown routine for any control queue * @hw: pointer to the hardware structure * @q_type: specific Control queue type + * @unloading: is the driver unloading itself * * NOTE: this function does not destroy the control queue locks. */ -static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type) +static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type, + bool unloading) { struct ice_ctl_q_info *cq; @@ -698,7 +700,7 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type) case ICE_CTL_Q_ADMIN: cq = &hw->adminq; if (ice_check_sq_alive(hw, cq)) - ice_aq_q_shutdown(hw, true); + ice_aq_q_shutdown(hw, unloading); break; case ICE_CTL_Q_SB: cq = &hw->sbq; @@ -717,20 +719,21 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type) /** * ice_shutdown_all_ctrlq - shutdown routine for all control queues * @hw: pointer to the hardware structure + * @unloading: is the driver unloading itself * * NOTE: this function does not destroy the control queue locks. The driver * may call this at runtime to shutdown and later restart control queues, such * as in response to a reset event. */ -void ice_shutdown_all_ctrlq(struct ice_hw *hw) +void ice_shutdown_all_ctrlq(struct ice_hw *hw, bool unloading) { /* Shutdown FW admin queue */ - ice_shutdown_ctrlq(hw, ICE_CTL_Q_ADMIN); + ice_shutdown_ctrlq(hw, ICE_CTL_Q_ADMIN, unloading); /* Shutdown PHY Sideband */ if (ice_is_sbq_supported(hw)) - ice_shutdown_ctrlq(hw, ICE_CTL_Q_SB); + ice_shutdown_ctrlq(hw, ICE_CTL_Q_SB, unloading); /* Shutdown PF-VF Mailbox */ - ice_shutdown_ctrlq(hw, ICE_CTL_Q_MAILBOX); + ice_shutdown_ctrlq(hw, ICE_CTL_Q_MAILBOX, unloading); } /** @@ -762,7 +765,7 @@ int ice_init_all_ctrlq(struct ice_hw *hw) break; ice_debug(hw, ICE_DBG_AQ_MSG, "Retry Admin Queue init due to FW critical error\n"); - ice_shutdown_ctrlq(hw, ICE_CTL_Q_ADMIN); + ice_shutdown_ctrlq(hw, ICE_CTL_Q_ADMIN, true); msleep(ICE_CTL_Q_ADMIN_INIT_MSEC); } while (retry++ < ICE_CTL_Q_ADMIN_INIT_TIMEOUT); @@ -843,7 +846,7 @@ static void ice_destroy_ctrlq_locks(struct ice_ctl_q_info *cq) void ice_destroy_all_ctrlq(struct ice_hw *hw) { /* shut down all the control queues first */ - ice_shutdown_all_ctrlq(hw); + ice_shutdown_all_ctrlq(hw, true); ice_destroy_ctrlq_locks(&hw->adminq); if (ice_is_sbq_supported(hw)) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index f4a39016a675..14ec4ebcd9af 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -623,7 +623,7 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) if (hw->port_info) ice_sched_clear_port(hw->port_info); - ice_shutdown_all_ctrlq(hw); + ice_shutdown_all_ctrlq(hw, false); set_bit(ICE_PREPARED_FOR_RESET, pf->state); } @@ -5499,7 +5499,7 @@ static void ice_prepare_for_shutdown(struct ice_pf *pf) if (pf->vsi[v]) pf->vsi[v]->vsi_num = 0; - ice_shutdown_all_ctrlq(hw); + ice_shutdown_all_ctrlq(hw, true); } /** @@ -7759,7 +7759,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) err_sched_init_port: ice_sched_cleanup_all(hw); err_init_ctrlq: - ice_shutdown_all_ctrlq(hw); + ice_shutdown_all_ctrlq(hw, false); set_bit(ICE_RESET_FAILED, pf->state); clear_recovery: /* set this bit in PF state to control service task scheduling */ From patchwork Fri Jun 28 20:13:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13716572 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 550EF13A868 for ; Fri, 28 Jun 2024 20:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605627; cv=none; b=kveyCn943a5ZBLmp+AG5H3jo7WRXB1yCxASL6e4B6mYSnjeKECpRzr8aITQEL+saDpqp2I8hxptm2Wm6yeo1f2nz1nwjiiD9oyRORGEN9MYQTqPEXc2MvXBEYdWQmCxpUNKbcaz8BP/gV+q45HJ52EX63QVRs9WxURMMj80Pypg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719605627; c=relaxed/simple; bh=HXeKVbWfDIPfbkUWpNVYGDzMwcSp6n6eO1Gec6CByjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n9oJCktvcPPfBQ3Zuy2+mH6yLZfgquhjHMLGBAnJg7dXgGI9A27Kmsh8szL0LuJGCt+UV0c6rnbqHjlfkQPUGYYkl6Vq9AoEmsmhdHPYkd2iVZknIjH9fqjpMLNmfB1KXBXG1UY5gTGp3m9hrYw7EH8Umk68oZvA5zGAUHDj8c8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DCeJmbuO; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DCeJmbuO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719605626; x=1751141626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HXeKVbWfDIPfbkUWpNVYGDzMwcSp6n6eO1Gec6CByjE=; b=DCeJmbuOuwAIvlwzxg0moc835WrXWDOJHO5kefHII8RhgEvVnLF/yWo7 k2adEkroOsXGWfawiu9vEFMhb8mFKy1qONiQYa8EhwN3WEXcnK9nQyUYX b4hN29Ds6pjFu7Rqs2Bto7Tfkz3qja/v3f3UiEQvJlV5A9+RLMU71gYAx LYlaKv/FCoHmw2wtQ7nJNM4auPm1ha5OQWi8uQwZVRutSbMFDTVOq+o1m /0EM8yPZHs3yusvVL4AtnPu3S4Urn6KqITQmeqFc8kNoccXX+lR5dvXse yAWshTpZk5XLWA7WNIOD04bBuSnRDgUR00H64ojqLL8ZimVW/qs28Wvjw A==; X-CSE-ConnectionGUID: YOLenDY7TAqxpqxwUafmOA== X-CSE-MsgGUID: ayBI9IVYSXeKu54qKMWqjQ== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="20674931" X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="20674931" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 13:13:42 -0700 X-CSE-ConnectionGUID: IwvujCFdTd+Kr08PiLuj7w== X-CSE-MsgGUID: NEgK95v6R8WGocSJF7rMLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,170,1716274800"; d="scan'208";a="49735538" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa003.jf.intel.com with ESMTP; 28 Jun 2024 13:13:42 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Przemek Kitszel , anthony.l.nguyen@intel.com, Wojciech Drewek , Simon Horman , Michal Schmidt , Pucha Himasekhar Reddy Subject: [PATCH net-next 6/6] ice: do not init struct ice_adapter more times than needed Date: Fri, 28 Jun 2024 13:13:24 -0700 Message-ID: <20240628201328.2738672-7-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> References: <20240628201328.2738672-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Przemek Kitszel Allocate and initialize struct ice_adapter object only once per physical card instead of once per port. This is not a big deal by now, but we want to extend this struct more and more in the near future. Our plans include PTP stuff and a devlink instance representing whole-device/physical card. Transactions requiring to be sleep-able (like those doing user (here ice) memory allocation) must be performed with an additional (on top of xarray) mutex. Adding it here removes need to xa_lock() manually. Since this commit is a reimplementation of ice_adapter_get(), a rather new scoped_guard() wrapper for locking is used to simplify the logic. It's worth to mention that xa_insert() use gives us both slot reservation and checks if it is already filled, what simplifies code a tiny bit. Reviewed-by: Wojciech Drewek Signed-off-by: Przemek Kitszel Reviewed-by: Simon Horman Reviewed-by: Michal Schmidt Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/ice_adapter.c | 60 +++++++++----------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.c b/drivers/net/ethernet/intel/ice/ice_adapter.c index 52d15ef7f4b1..ad84d8ad49a6 100644 --- a/drivers/net/ethernet/intel/ice/ice_adapter.c +++ b/drivers/net/ethernet/intel/ice/ice_adapter.c @@ -11,6 +11,7 @@ #include "ice_adapter.h" static DEFINE_XARRAY(ice_adapters); +static DEFINE_MUTEX(ice_adapters_mutex); /* PCI bus number is 8 bits. Slot is 5 bits. Domain can have the rest. */ #define INDEX_FIELD_DOMAIN GENMASK(BITS_PER_LONG - 1, 13) @@ -47,8 +48,6 @@ static void ice_adapter_free(struct ice_adapter *adapter) kfree(adapter); } -DEFINE_FREE(ice_adapter_free, struct ice_adapter*, if (_T) ice_adapter_free(_T)) - /** * ice_adapter_get - Get a shared ice_adapter structure. * @pdev: Pointer to the pci_dev whose driver is getting the ice_adapter. @@ -64,27 +63,26 @@ DEFINE_FREE(ice_adapter_free, struct ice_adapter*, if (_T) ice_adapter_free(_T)) */ struct ice_adapter *ice_adapter_get(const struct pci_dev *pdev) { - struct ice_adapter *ret, __free(ice_adapter_free) *adapter = NULL; unsigned long index = ice_adapter_index(pdev); - - adapter = ice_adapter_new(); - if (!adapter) - return ERR_PTR(-ENOMEM); - - xa_lock(&ice_adapters); - ret = __xa_cmpxchg(&ice_adapters, index, NULL, adapter, GFP_KERNEL); - if (xa_is_err(ret)) { - ret = ERR_PTR(xa_err(ret)); - goto unlock; - } - if (ret) { - refcount_inc(&ret->refcount); - goto unlock; + struct ice_adapter *adapter; + int err; + + scoped_guard(mutex, &ice_adapters_mutex) { + err = xa_insert(&ice_adapters, index, NULL, GFP_KERNEL); + if (err == -EBUSY) { + adapter = xa_load(&ice_adapters, index); + refcount_inc(&adapter->refcount); + return adapter; + } + if (err) + return ERR_PTR(err); + + adapter = ice_adapter_new(); + if (!adapter) + return ERR_PTR(-ENOMEM); + xa_store(&ice_adapters, index, adapter, GFP_KERNEL); } - ret = no_free_ptr(adapter); -unlock: - xa_unlock(&ice_adapters); - return ret; + return adapter; } /** @@ -94,23 +92,21 @@ struct ice_adapter *ice_adapter_get(const struct pci_dev *pdev) * Releases the reference to ice_adapter previously obtained with * ice_adapter_get. * - * Context: Any. + * Context: Process, may sleep. */ void ice_adapter_put(const struct pci_dev *pdev) { unsigned long index = ice_adapter_index(pdev); struct ice_adapter *adapter; - xa_lock(&ice_adapters); - adapter = xa_load(&ice_adapters, index); - if (WARN_ON(!adapter)) - goto unlock; + scoped_guard(mutex, &ice_adapters_mutex) { + adapter = xa_load(&ice_adapters, index); + if (WARN_ON(!adapter)) + return; + if (!refcount_dec_and_test(&adapter->refcount)) + return; - if (!refcount_dec_and_test(&adapter->refcount)) - goto unlock; - - WARN_ON(__xa_erase(&ice_adapters, index) != adapter); + WARN_ON(xa_erase(&ice_adapters, index) != adapter); + } ice_adapter_free(adapter); -unlock: - xa_unlock(&ice_adapters); }