Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2640792rbb; Wed, 28 Feb 2024 08:04:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+JCOA5f08X04dhxN0SDrboESJLkJEIeHJ450/SvLp4DCm7Osy/gypVGnbNfkA1XQF388CzIvWk7lwDY6j7lhCbUMXBYkjUYoh5Kmq7Q== X-Google-Smtp-Source: AGHT+IGV5mV4cVSwnoxLxqg4841zvvbi9kcNondlF80roW8azykYIawFvWoPRQ30dsUSdjrBGjOk X-Received: by 2002:a5d:9b02:0:b0:7c7:47d8:9486 with SMTP id y2-20020a5d9b02000000b007c747d89486mr15578613ion.2.1709136283424; Wed, 28 Feb 2024 08:04:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709136283; cv=pass; d=google.com; s=arc-20160816; b=lie0ePywibduQoYK++kcrpECRj6DYqeIg5yldth5+bakqrFC0Z8IscdXg2YPUCntV+ g3D4094HJRxh6qvV68rAkQNlbhDtmztO7wHQ7cOKuP6mOLUEJTxly9GUbKFIeYQHu/PR 8gsfgOsjwioo/CUIvQXOeMQUjesW/x5l0SEVdL+L6i260tFm2DJsBKJ85+uZU8ZO0anw VvHkktEn4uwBLQDPCORRBsCxLygQs/SY1OZ3TQUnErKUhFgFIQ9HbLH2CeLPfDgsKWhL 3PQdsA+lgxyN9F538c9KhOAB5tJ53bqu5hsVh7ihcTLCAipQ1MHwoia16Uu7KVlxlkm/ aV4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=suU515v4P/RN9aDdgILWwByW4yNO8k6eXfq9Cl0Uirw=; fh=XF5dR1hZ6bmHhiCesO+5NPfXhTaDjas2E0STvyrxXLQ=; b=0io01q12UNxjetw8i81hiu/FFE05aAdOQ2NYICHDRPBSwW1Qx5zx3jEF41MxhvA5ye bmGL8Or6/xFvtWZAF/2ZFVzbSStr9zZKMNFCqOQF4o2zcNUHhcgjEksg9HU10QK3Yvvy q/JqFZEAakYncDtfMdMh2eHgIKTld3XfvvHAOu8G8ULdyIhhqE0DSPqwd+kLfPviIYk2 Bb7104E0p4WgTWXESmczVjjW6g8q1c/3V7Vjo4dgnDEHQSOxZ9EnZgHrUXvufkuy0Bk4 Xnuc2LZrY4MGK946HM4cJ1sgWN2t/HVA1kQD+0oHpJ3oIUA0EJ7Sw8tdvyzSZxfJXvWx NhmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YEnWwjqM; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85316-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h2-20020a02c4c2000000b0047414ccf757si2814517jaj.24.2024.02.28.08.04.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:04:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85316-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YEnWwjqM; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85316-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6F81D283F82 for ; Wed, 28 Feb 2024 16:04:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F21515DBD6; Wed, 28 Feb 2024 16:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YEnWwjqM" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 A918815D5CE; Wed, 28 Feb 2024 16:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136255; cv=none; b=hFXTS0RPOd2mZrI40OblKjyyNwNoXSNuGKlLOzMtroKO9tMI1Imtf8djPRBLjUTiBL8JOLLZuvi+0isloByCCMaZMSTgPVLhgCgTgru01ovQPpDnGZl756pLiX7mtTstOHx9rhc+WrVMvY4OOI0RJf+LJEICeKuzYSAa79kLn8M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136255; c=relaxed/simple; bh=OUeJ0q/Q4TSugz58SFBLkzeTCYbClmf+g/buseTVPBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SzC0cZmO6LuZ9YApUlzV6cz154qwjHx31RPh4f+zlLm5uhCWLkdVZbFzxYfJL4s8nlIOXNMaCM1FNvvmB4hjp7eHKq43FydnXTV0sewhxPUyAPucvr77YDZXNGgQ2J4pFFtWFjIPBlE4rHlSj7DmR3ZE53t28JaQ79VvdZhF59k= 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=YEnWwjqM; arc=none smtp.client-ip=198.175.65.17 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709136254; x=1740672254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OUeJ0q/Q4TSugz58SFBLkzeTCYbClmf+g/buseTVPBw=; b=YEnWwjqMLxPo702o4EjLFENJMkCU1T2MkfjU0XXtM4bJU2yIKAF4Bzr9 OUxwAQTBH6Z3bDbx7MC5661Zdf/hK363VLFhIMN3oxrRFXnboKMyfuMY4 caE7MIEz4WOqp9bDBTf/o704VybhYlPHvV3tvEcZmDnGYPNWKJrIbaOve vjcJmd4MmjZ9maqd0602Gv3Ycxqfhr9Bfomfgyl2+UF/m+tQ5XwC6ZX6B zkDobeLm272P82f9EMKh6kqLgriZFJAt6SNF7WVO+kR/z8qZq8TltqHwh L+5eDdyBWKFrctcPOQDm+eC6Q6S/mlkxpIcXBzRCmw+pr3koY+cizO5ta g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3706577" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="3706577" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 08:04:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="7527702" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa009.jf.intel.com with ESMTP; 28 Feb 2024 08:04:10 -0800 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id DA1AD36825; Wed, 28 Feb 2024 16:04:04 +0000 (GMT) From: Larysa Zaremba To: intel-wired-lan@lists.osuosl.org Cc: Larysa Zaremba , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Mateusz Pacuszka , Tony Nguyen , Lukasz Plachno , Jakub Buchocki , Pawel Kaminski , Przemek Kitszel , Michal Swiatkowski , Mateusz Polchlopek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Pawel Chmielewski , Jesse Brandeburg Subject: [PATCH iwl-net 1/5] ice: Add function to get VF from device struct Date: Wed, 28 Feb 2024 16:59:45 +0100 Message-ID: <20240228155957.408036-2-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240228155957.408036-1-larysa.zaremba@intel.com> References: <20240228155957.408036-1-larysa.zaremba@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mateusz Polchlopek Introduce a helper ice_get_vf_by_dev() to look up VF for a given struct device. Signed-off-by: Mateusz Polchlopek Reviewed-by: Przemek Kitszel Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 30 +++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 6 +++++ 2 files changed, 36 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c index 2ffdae9a82df..21d22e3ad0ba 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c @@ -45,6 +45,36 @@ struct ice_vf *ice_get_vf_by_id(struct ice_pf *pf, u16 vf_id) return NULL; } +/** + * ice_get_vf_by_dev - Get pointer to VF by device + * @dev: the device structure + * + * Locate and return a pointer to the VF structure associated with a given + * device. + * Return: valid VF structure associated with the device, NULL if none exists + */ +struct ice_vf *ice_get_vf_by_dev(struct device *dev) +{ + struct pci_dev *vfdev; + struct pci_dev *pdev; + struct ice_pf *pf; + struct ice_vf *vf; + unsigned int bkt; + + vfdev = container_of(dev, struct pci_dev, dev); + pdev = vfdev->physfn; + pf = pci_get_drvdata(pdev); + + rcu_read_lock(); + ice_for_each_vf_rcu(pf, bkt, vf) { + if (vf->vfdev == vfdev) + break; + } + rcu_read_unlock(); + + return vf; +} + /** * ice_release_vf - Release VF associated with a refcount * @ref: the kref decremented to zero diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h index 0cc9034065c5..48f4cdbd6d27 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h @@ -213,6 +213,7 @@ static inline u16 ice_vf_get_port_vlan_tpid(struct ice_vf *vf) #ifdef CONFIG_PCI_IOV struct ice_vf *ice_get_vf_by_id(struct ice_pf *pf, u16 vf_id); +struct ice_vf *ice_get_vf_by_dev(struct device *dev); void ice_put_vf(struct ice_vf *vf); bool ice_has_vfs(struct ice_pf *pf); u16 ice_get_num_vfs(struct ice_pf *pf); @@ -237,6 +238,11 @@ static inline struct ice_vf *ice_get_vf_by_id(struct ice_pf *pf, u16 vf_id) return NULL; } +static inline struct ice_vf *ice_get_vf_by_dev(struct device *dev) +{ + return NULL; +} + static inline void ice_put_vf(struct ice_vf *vf) { } -- 2.43.0