From patchwork Wed Feb 28 15:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 207910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3446622dyb; Wed, 28 Feb 2024 08:11:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLHAaGxionmUB6LONSRTsCXHGeyrsCUMzWVhMUSGaK8E2AcZbWFYR5KZBcBkQUxfEuYKqzPS+a26ee0BtHh97pFfkI8g== X-Google-Smtp-Source: AGHT+IF6am4P1zwyuZHCU/sKZ5zmu4lUwISoTPkXK586UJd9XBWajlFO3pjyTy7rJ8yXuf6iQ+3t X-Received: by 2002:aa7:db5a:0:b0:566:2be1:5277 with SMTP id n26-20020aa7db5a000000b005662be15277mr4903713edt.30.1709136714466; Wed, 28 Feb 2024 08:11:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709136714; cv=pass; d=google.com; s=arc-20160816; b=Crp8aO1rOHyS4ADObEnyKvaf1wXs2oK0cKK43dH76wcuJRRvoZNVluX8pJKodgylFh SuiNeKds16XUWwDQ/mRvITbBes6/bFO1+N6iVlNhy7J0OwBbfofGT+BsMs2Z7K4fLzkI 23XR9+qnsM0OE03Izmoshw8C7r+ZslpHROAGNWNHhk6iHHfmzgrR6ublDSawdroq/R4s JsORUVTnFwhpWxRb8P+ZxOXm5j7sOe5OxSg94MUdA+EVwk737g18fA45uIZRhtmVDVVz 0CP4e4ubsUrnJ1dWrTxkzerVrglywQ3dRdZnoAWxzZwAp2ewN+99SyqZD9YXyxqUK9U+ PUUg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85316-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l2-20020a50d6c2000000b00564951ae492si1831582edj.118.2024.02.28.08.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85316-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85316-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id F000C1F2A7D5 for ; Wed, 28 Feb 2024 16:04:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 617B915E5C3; Wed, 28 Feb 2024 16:04:18 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792159739321892439 X-GMAIL-MSGID: 1792159739321892439 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) { } From patchwork Wed Feb 28 15:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 207905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3441047dyb; Wed, 28 Feb 2024 08:05:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUEcPM4fve1xW5OlrZhB5chnbIIFxtAbtn22vgb1pXPIjLtNyOZ8K6o7o0OytlMSV0GpdUk20pDUtEUg47pg0XCAgu9FQ== X-Google-Smtp-Source: AGHT+IFxlaRd7WQ82jK2M1RV+AkREZ52YCFxXG9AbXQWV8ysZ2kTDLB3gbIfKHi7A1BVoJlwTR3R X-Received: by 2002:a6b:f01a:0:b0:7c7:e215:fbeb with SMTP id w26-20020a6bf01a000000b007c7e215fbebmr5833589ioc.21.1709136301122; Wed, 28 Feb 2024 08:05:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709136301; cv=pass; d=google.com; s=arc-20160816; b=0cmy063mnSEKuWbNA7iUiD+r3CVDqzof6eUqdFZGu33jroQZ9xCmlUQVu2/PSd+vG9 d38mi5OJQ55o0eizFW6H+4sbJSbsmjC7IFSwrMp0m5BlNqaaYolSP58Lo9n78OjQuqmI vH7nVKmDFhlAlQM6OgHj6yY0WlMfLvil5Mj6LsQik3x3KfI4DSpzkM9Jyeae0k4Xq5X9 zi9CldHdi5XE5lyITNes0smyyVCkX2wm4tCUUHaUmzj3KWv7wn3guXawz0VrCNrk98pg vV7iIfev91DwpGY35AGnbIGjAP3pHQRLVCqZESrGdmTZurN53rx30ai8JdM24rIiLPor iuPg== 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=7Pk5U//ZVPQPExQ9A4E0uQW+cR32sT/LD38cIH9X+2E=; fh=XF5dR1hZ6bmHhiCesO+5NPfXhTaDjas2E0STvyrxXLQ=; b=wG9p+PTkwngJUhJyz88kSbO6wv3/S0iuYassfKAjmRPUm7PxpmUkK7UeCSWLzz3DNA 36LlNyKzrCzoLcBewk1g1tQALNgCvX6IPZF4OQiHoY2bPqV7WfnawRD9ogqmSQIgCn4G Uprh6VfLedDC/5AJoebRFw6X1v5u2qlS2/H61TT8MI72vDXVyh3F1GyryE67HwVznEEf Q/rtKzRimLUdZHXd2CHhytaSi4O93IKj9Y2VhFavqgZa9my7AouGJFcJW8BZZ5BIkPVa jrcGe+0w3GW+ahEGTK4//iKtelMzykqYyZdJaGu40gA0ULs0EZHyUjCBmYDeJhZAlJ4d 8m3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fxX+Zwyf; 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-85317-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85317-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c22-20020a02c9d6000000b004746742056csi2928057jap.163.2024.02.28.08.05.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:05:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85317-ouuuleilei=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=fxX+Zwyf; 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-85317-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85317-ouuuleilei=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 DFB352826A4 for ; Wed, 28 Feb 2024 16:05:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5558B15E5D4; Wed, 28 Feb 2024 16:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fxX+Zwyf" 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 B121615DBC3; Wed, 28 Feb 2024 16:04:15 +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=1709136257; cv=none; b=orJqVnYGu8oGDNOpry6zM0SRrqAAQ338XfqUOy4Yx2csSxGjGVlMk/zSNIFaQ712RCScIOJwmwP7TJHZxUc47CwKQZvQOQ9qhxRU8d36AZQVvAcWiVstRCRAo57Y1/WhYvcv3jfhHP/tqoyrljmVX5np+Zlju2Awf+nqVjcQ6jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136257; c=relaxed/simple; bh=R61ecFgc4lXqLojo0yvyMnIKMCsRpjfsVyCvjTYWt2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SI1ilRpRKXeIxzibZGmMY9K8PGvCC0fuptl8TMfdlbulUp8acaRDHFlEUgBZzYZ8BkAYPjhDZOvPEJ0VFIq2+ySbGyzzRPpAjGqt3RYZkq9yOgmawdOZ30qPtw9gV1qzr73Ae0M7BRIoS9NXye3YwAj4Lm1GTiH2elNBTZ/Gr2c= 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=fxX+Zwyf; 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=1709136256; x=1740672256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R61ecFgc4lXqLojo0yvyMnIKMCsRpjfsVyCvjTYWt2U=; b=fxX+Zwyfc7JBscIKN4+Uy5jivXITpWq/e9bdT2lzxgNPEHfOsR3JPEf5 Qzibv3zVfz61XygTqr7wVCjOB1EeuhbJ/NAX/P1qJEiSKNg1tkFhVXFUm SCJCB4cDLhD76AfhayMlcnf93Nwauz5+gUoxUEECcLwGhuI5fyxw7RHyj XZrsnVIECA/6zOiJCIf4T/QAY7l2DDHiK4SkMofdJIHB1GpKo6bI8H6je txIqVNeGS00TX0KbTCLGKQdR3XV5MCHYwusTNbTl1O3zH/PUPYf8l4gie ueMSx9ao2SgiKPeSY7LdAmq1ZBCgL6bjAMHT+Shgf53vXtFroTj2zySjG A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3706596" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="3706596" 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:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="7527713" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa009.jf.intel.com with ESMTP; 28 Feb 2024 08:04:11 -0800 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id E397D36826; Wed, 28 Feb 2024 16:04:08 +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 2/5] ice: Fix check for existing switch rule Date: Wed, 28 Feb 2024 16:59:46 +0100 Message-ID: <20240228155957.408036-3-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792159306511762656 X-GMAIL-MSGID: 1792159306511762656 From: Mateusz Pacuszka In case the rule already exists and another VSI wants to subscribe to it new VSI list is being created and both VSIs are moved to it. Currently, the check for already existing VSI with the same rule is done based on fdw_id.hw_vsi_id, which applies only to LOOKUP_RX flag. Change it to vsi_handle. This is software VSI ID, but it can be applied here, because vsi_map itself is also based on it. Additionally change return status in case the VSI already exists in the VSI map to "Already exists". Such case should be handled by the caller. Signed-off-by: Mateusz Pacuszka Reviewed-by: Przemek Kitszel Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c index f84bab80ca42..bf2ab2b6ef68 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -3004,7 +3004,7 @@ ice_add_update_vsi_list(struct ice_hw *hw, u16 vsi_handle_arr[2]; /* A rule already exists with the new VSI being added */ - if (cur_fltr->fwd_id.hw_vsi_id == new_fltr->fwd_id.hw_vsi_id) + if (cur_fltr->vsi_handle == new_fltr->vsi_handle) return -EEXIST; vsi_handle_arr[0] = cur_fltr->vsi_handle; @@ -3052,7 +3052,7 @@ ice_add_update_vsi_list(struct ice_hw *hw, /* A rule already exists with the new VSI being added */ if (test_bit(vsi_handle, m_entry->vsi_list_info->vsi_map)) - return 0; + return -EEXIST; /* Update the previously created VSI list set with * the new VSI ID passed in From patchwork Wed Feb 28 15:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 207906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3442456dyb; Wed, 28 Feb 2024 08:06:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+O/zAJQbbGOpXW9GCXqYAHE7rm5bqkm/rcjGQ5+SLFUYFj+ZTr+IMfySx7OCiccSc3+8M0zSxSjMMyv9K2m4lq8dGyg== X-Google-Smtp-Source: AGHT+IHrthVU7gSiEsPrYpEFQaXxJAncqmgPryKgIrKD8sjdz5va6FjGk3H2vHzgFnl2OW0Y3t+S X-Received: by 2002:a05:6359:4588:b0:17b:571e:b507 with SMTP id no8-20020a056359458800b0017b571eb507mr16640438rwb.4.1709136391723; Wed, 28 Feb 2024 08:06:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709136391; cv=pass; d=google.com; s=arc-20160816; b=JWf0E2HSjnXtVFB02z+OHBTtk9M8n4H2kwxBU+bWAILYQqlWFgKl8dEdOw2//sGx+5 /mzHd37dx4Y/1L+TWPZWWEixYdUmnMjh/ccA6omTHkhyQzHhTxTtoWzLH7LMoxz4VXa6 /WV+WtdsHQHDKpUvonWHUej0SB0GhzfhyDIjSfEv99upyumLIMch2/4uOf2lJoeZ/lCs EzF+BXuKlVVHvrWZ0SwFv2L0NRdCSiQw2yw2+YCRpbKBekHxGPZ9/EFUqq6W9INMVjZu /AB4Vz9WXUAolxYJTztjH4TFsrTwjcQpyGS/wKxmRdEnBdEpHwFxd/+lITyiyFfXuXBP MeMQ== 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=gC9DWd/VFnGYj2PYaWvqnwuz3ak6t7n9xovrBIk2kyA=; fh=XF5dR1hZ6bmHhiCesO+5NPfXhTaDjas2E0STvyrxXLQ=; b=fJzNEoc4656gZ1+Rn8Ok83Tdy3LEdOXWiAUTJpREv1g4mm9BtSE/UxKYStH1sW4r8e pxTpOzdyVwvBSVDtSN2AROdYdQw9xW9RUiG59a87lBwsrYOYbOmVPUPPEK5ljJfJmEBV dH5oZ0LFAFNOBS4MjI+RNl3H/Jakxh8TQkFDd5EAe47n4B4jqeQrOg6IrzTyRxcZRSke lFGfO8xF5Toy5IHBLbE/bLSyGSpj4AuBUBye3gGXT41FxoqmjjCLAp8nWdLotwkATEqo XqW4qObgRgQR9yv778otx/3c0GqR5oJqSOzUfaw0RtQj3or3Xf9YgHn7wZn0//cAV/Me 9iHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lI0S+4B7; 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-85319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d10-20020ac85d8a000000b0042e74a36807si10499961qtx.555.2024.02.28.08.06.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:06:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lI0S+4B7; 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-85319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85319-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3FA151C26213 for ; Wed, 28 Feb 2024 16:05:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98402163A97; Wed, 28 Feb 2024 16:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lI0S+4B7" 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 8A3D515E5DD; Wed, 28 Feb 2024 16:04:22 +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=1709136264; cv=none; b=WFDvYLIB9r8S4zsMOVV7nvAlBzq3VENk0HcqmJDFxQFajEwuquOcYW80O//WxDJbt3KOUjtZrWY/nyaMNzhZbF0MRinsB/Lwaj9UiymeBnXzbqTZihNc7wQYgChqh7/KhxdzaN+n0IVdcgcuQEAEr/ZouGe8F6V3FK8bQUwYIRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136264; c=relaxed/simple; bh=uZmeeZD3VWIvcaruww88Mst1ibscMXXKLJg4+styrpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mNpEmRmPongRRYWcy4U7qbJQGsKp4vXuDrzJsezdsCQFpWN2LA+/Px3R4vtf/etkTnr8Ay8bOovoAG8dHxt0FuinSdLqKGY3jMw1B4Dkui3VRS5m1kztKiaWArOiJwJJ5ZmmjapCsV6XqQk4Qzjc6CnlVLeNUGtOwTVYbI20zdE= 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=lI0S+4B7; 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=1709136262; x=1740672262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uZmeeZD3VWIvcaruww88Mst1ibscMXXKLJg4+styrpY=; b=lI0S+4B7cxeuLuzbA68hlJ6rLR0LXZYOFQcjhBs6T76QVLTKbdKoIIcJ Ywc2LW8ymOHgwGAT56dNUki9XlViBxVWgB500Scy65Lk5NubMT2JPwWIb 4DV2/wzaOPSs2D/y2I4BNhBRkSuI1CuKe9t0Z7pinvTCUKEAqTlM/qCD+ suXQeSir30CzLnAKJyXQSlN9328205k74J/KD1H/wgUeBaKpOxahUA4ii 0YQ0N3llMtoDjiwM5VGEa5IxFRq9YWxuPOBy+++ZfxjLjd1FGYplv03s6 Xur3CsSQvfqBqajR4Sz/XXmFoz6b0xsRFkOLoAlAM9rxvLXBySMe/ldKo g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3706623" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="3706623" 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:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="7527778" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa009.jf.intel.com with ESMTP; 28 Feb 2024 08:04:14 -0800 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 0D7E536820; Wed, 28 Feb 2024 16:04:11 +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 3/5] ice: Do not add LLDP-specific filter Date: Wed, 28 Feb 2024 16:59:47 +0100 Message-ID: <20240228155957.408036-4-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792159401081531955 X-GMAIL-MSGID: 1792159401081531955 Commit 34295a3696fbd0d90ee7 ("ice: implement new LLDP filter command") has introduced the ability to use LLDP-specific filter that directs all LLDP traffic to a single VSI. However, current goal is for all trusted VFs to be able to see LLDP neighbors. Therefore, replace the functionality with previously used generic ethernet protocol filter. The command was added as a way to solve an "issue with some NVMs where an already existent LLDP filter is blocking the creation of a filter to allow LLDP packets". Preserve this utility and remove LLDP-specific filter before configuring another one. Signed-off-by: Larysa Zaremba --- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 1 - drivers/net/ethernet/intel/ice/ice_common.c | 26 --------------- drivers/net/ethernet/intel/ice/ice_common.h | 2 -- drivers/net/ethernet/intel/ice/ice_lib.c | 33 +++++++++++++++---- 4 files changed, 26 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h index 8040317c9561..2855c955d8b4 100644 --- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h @@ -1883,7 +1883,6 @@ struct ice_aqc_lldp_stop_start_specific_agent { /* LLDP Filter Control (direct 0x0A0A) */ struct ice_aqc_lldp_filter_ctrl { u8 cmd_flags; -#define ICE_AQC_LLDP_FILTER_ACTION_ADD 0x0 #define ICE_AQC_LLDP_FILTER_ACTION_DELETE 0x1 u8 reserved1; __le16 vsi_num; diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c index 9266f25a9978..f5cca0e2ead6 100644 --- a/drivers/net/ethernet/intel/ice/ice_common.c +++ b/drivers/net/ethernet/intel/ice/ice_common.c @@ -5911,32 +5911,6 @@ bool ice_fw_supports_lldp_fltr_ctrl(struct ice_hw *hw) ICE_FW_API_LLDP_FLTR_PATCH); } -/** - * ice_lldp_fltr_add_remove - add or remove a LLDP Rx switch filter - * @hw: pointer to HW struct - * @vsi_num: absolute HW index for VSI - * @add: boolean for if adding or removing a filter - */ -int -ice_lldp_fltr_add_remove(struct ice_hw *hw, u16 vsi_num, bool add) -{ - struct ice_aqc_lldp_filter_ctrl *cmd; - struct ice_aq_desc desc; - - cmd = &desc.params.lldp_filter_ctrl; - - ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_filter_ctrl); - - if (add) - cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_ADD; - else - cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_DELETE; - - cmd->vsi_num = cpu_to_le16(vsi_num); - - return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL); -} - /** * ice_lldp_execute_pending_mib - execute LLDP pending MIB request * @hw: pointer to HW struct diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h index 32fd10de620c..900926e6414c 100644 --- a/drivers/net/ethernet/intel/ice/ice_common.h +++ b/drivers/net/ethernet/intel/ice/ice_common.h @@ -267,8 +267,6 @@ int ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size, struct ice_sq_cd *cd); bool ice_fw_supports_lldp_fltr_ctrl(struct ice_hw *hw); -int -ice_lldp_fltr_add_remove(struct ice_hw *hw, u16 vsi_num, bool add); int ice_lldp_execute_pending_mib(struct ice_hw *hw); int ice_aq_read_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr, diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 60e0d824195e..a774bcdcc0c4 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -2039,6 +2039,27 @@ static void ice_vsi_set_tc_cfg(struct ice_vsi *vsi) ice_vsi_set_dcb_tc_cfg(vsi); } +/** + * ice_lldp_fltr_remove_from_port - Remove a LLDP Rx filter from the port + * @hw: port + * + * Remove a LLDP Rx switch filter from the port. For some NVMs, + * such leftover filter can prevent us from configuring another one. + */ +static void ice_lldp_fltr_remove_from_port(struct ice_hw *hw) +{ + struct ice_aqc_lldp_filter_ctrl *cmd; + struct ice_aq_desc desc; + + cmd = &desc.params.lldp_filter_ctrl; + + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_filter_ctrl); + + cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_DELETE; + + ice_aq_send_cmd(hw, &desc, NULL, 0, NULL); +} + /** * ice_cfg_sw_lldp - Config switch rules for LLDP packet handling * @vsi: the VSI being configured @@ -2060,13 +2081,11 @@ void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create) status = eth_fltr(vsi, ETH_P_LLDP, ICE_FLTR_TX, ICE_DROP_PACKET); } else { - if (ice_fw_supports_lldp_fltr_ctrl(&pf->hw)) { - status = ice_lldp_fltr_add_remove(&pf->hw, vsi->vsi_num, - create); - } else { - status = eth_fltr(vsi, ETH_P_LLDP, ICE_FLTR_RX, - ICE_FWD_TO_VSI); - } + if (create && ice_fw_supports_lldp_fltr_ctrl(&pf->hw)) + ice_lldp_fltr_remove_from_port(&vsi->back->hw); + + status = eth_fltr(vsi, ETH_P_LLDP, ICE_FLTR_RX, + ICE_FWD_TO_VSI); } if (status) From patchwork Wed Feb 28 15:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 207907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3442476dyb; Wed, 28 Feb 2024 08:06:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW+TYm58LpaLZRb1QNFu/DqN8tCQwYGi8GfmAdpTwH39oZvE+SkYTDB6aB6vYb8TC1VZo8aTM6kxOv3JcwFji6qqIr0xg== X-Google-Smtp-Source: AGHT+IE6hMFQlEWilItxiIpMQKN0iwQKCP+jRGC2m/2XpSSmsFFuu//fVRdbAK8u0gMUeaaQdscl X-Received: by 2002:a05:6e02:1d89:b0:365:3a69:1e20 with SMTP id h9-20020a056e021d8900b003653a691e20mr1971658ila.3.1709136393322; Wed, 28 Feb 2024 08:06:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709136393; cv=pass; d=google.com; s=arc-20160816; b=l0jenVe7f7mdNd5MUkb3Tw3YUhxQ10gHQz4Ay8/yof36jU6Q9oh+kCEyb4KLE73dtm 9gRyodRHNwbSUU5fxYovMQtNCTBdV2Ca+nyrOtYslQ7RcA/1lXXjPcLfC9UTHa8dbgzS V4rMZFprZCM+t/tGI7a8pa58wJDFu0wyyxo6qr2aX/mi9XkxlhfRRQvyUVUcOmdEZqeC Qi5CMGxPwf2giBrsln5VRiWEuk/3U7cIJaBiAZEm8uiDN4As/ZmgZrRlMl72wIpdgJRY exjKTtn8BBC6ju5PjEEmIqBfEjhXzmfkyTBETL0F/DA6doH+Ho675wbpvXMz0Raaa822 cHiw== 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=k75BY/My/UBUijEW2zTjvVdRtkt5PiCY1vhtTE+2++0=; fh=XF5dR1hZ6bmHhiCesO+5NPfXhTaDjas2E0STvyrxXLQ=; b=goi9i/jZeXDD91XkIKs39zfUjqrGZSu8C93kOvpD3ewdw4py0m5tap7Eesv9SflaRB BjNcQLY0HMFVI0qf3+BleqOBp0mhFq+5SSM0B6i9uIf2UQTaKyXldJecCE90rfPerMf8 rEtAeL1oaTaGnxlY/2uFjZtGM7fZpqYGXH7X8AxcSPmenM6MsIm9BxaaWAVwg0QFAgdX pro15oTkvIp5Aickv05FaxTkx1qp8ohbRoehh75mSepyjFYAhBtdx4f26YpMkNnMB2Wn /vTr00msm9/yWevilvx/uEZXhU6Sxlyd//dvqLX9/O87umGCGDoYHqnxcpqfoWdtchdh tOHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gpjT2Zsy; 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-85318-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85318-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c16-20020a92b750000000b00364ff2fccd0si2915103ilm.127.2024.02.28.08.06.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:06:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85318-ouuuleilei=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=gpjT2Zsy; 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-85318-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85318-ouuuleilei=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 48FDD286A01 for ; Wed, 28 Feb 2024 16:05:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 015E315DBB5; Wed, 28 Feb 2024 16:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gpjT2Zsy" 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 8919515E5DB; Wed, 28 Feb 2024 16:04:20 +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=1709136262; cv=none; b=K+RaW6/QXO6Q8nXuwTWMQ+O3kyzSxj+QfHO2jdA9DnonRyFDemrG9mIfqtxrhNjk5xjc7MW5gEJ4tOhoo0oNr2AmXDxo5i33z/B7DeEFmpEvXN+LcMBL46WFCYDlpxJmCDo2hZubzxIPvata2KSpyp4AMHq0RpfwV7/uPvhQtSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136262; c=relaxed/simple; bh=kjxgC/aVSCUWtEC5c6qjFlGNa0rOxl4TrK/MLmqCnfk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LnzKuVKEjG/0aJLZIbHDaHfl+zqXHh2gjt48XwJfL5haDEl9HOvlfhxjmGhu8Nr4pbFnoRHt0yqJb5g1OS4L5+m+SjILWMgg2yb9W1SNvWkKiyQsvgAtGMs7Ga2vHnQGSofsLMIVmmKKYh6nVox6ZikaANSwdhELUWZhL+YztvE= 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=gpjT2Zsy; 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=1709136260; x=1740672260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kjxgC/aVSCUWtEC5c6qjFlGNa0rOxl4TrK/MLmqCnfk=; b=gpjT2ZsyyxmyJ5jSlHa0++xw62IZz+jasN6rXyZ3H968y8Tu3+SYx+Lu ylsZLa5CAl7qaenWGpBfSm0YymNB8tqlWsBtyDZRb+eZgbur2kem00PvA IEtZVEbNq9cVFPk4wgE/nj0Bu/Uqfhq9YEUzYFesiI27RI4I//cJIhGpk M3MhCnH4Oh72yX866dSCF7BQH13WLtX1hUGNoFVUYDbU0zOxap9PQfCSf pLYA2gCg9XxzUJr8im63CM9I+Jw7uHxopM2YvjcH8koxeBf0B1MIBRlTn 1xXyPKzmTWnvlDczEqnPv8FrPFCjZlbfx333YsKwW/a4bx61ztlXss1pJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3706617" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="3706617" 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:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="7527773" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa009.jf.intel.com with ESMTP; 28 Feb 2024 08:04:16 -0800 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 44B5D36827; Wed, 28 Feb 2024 16:04:13 +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 4/5] ice: Implement VF LLDP RX support on VF Date: Wed, 28 Feb 2024 16:59:48 +0100 Message-ID: <20240228155957.408036-5-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792159402926807829 X-GMAIL-MSGID: 1792159402926807829 From: Mateusz Pacuszka Add rx_lldp sysfs to allow user to disable (enabled by default) RX LLDP packets on PF when FW LLDP agent is disabled and the support for VF LLDP is present. Configure LLDP multicast MAC address on trusted VF to allow it to receive LLDP packets. Signed-off-by: Mateusz Pacuszka Co-developed-by: Jakub Buchocki Signed-off-by: Jakub Buchocki Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 +- drivers/net/ethernet/intel/ice/ice_lib.c | 47 +++++++++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 4 ++ drivers/net/ethernet/intel/ice/ice_main.c | 58 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 59 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 6 ++ drivers/net/ethernet/intel/ice/ice_virtchnl.c | 11 ++++ 8 files changed, 191 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 365c03d1c462..992c0dfaab6f 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -344,6 +344,8 @@ struct ice_vsi { u32 tx_busy; u32 rx_buf_failed; u32 rx_page_failed; + u8 lldp_macs; /* counter for LLDP MACs added to VSI */ + u8 rx_lldp_ena : 1; /* Rx LLDP filter enabled */ u16 num_q_vectors; /* tell if only dynamic irq allocation is allowed */ bool irq_dyn_alloc; diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index 3cc364a4d682..8ae448af51e7 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -1480,6 +1480,8 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) if (status) dev_warn(dev, "Fail to init DCB\n"); + ice_ena_all_vfs_rx_lldp(pf); + pf->dcbx_cap &= ~DCB_CAP_DCBX_LLD_MANAGED; pf->dcbx_cap |= DCB_CAP_DCBX_HOST; } else { @@ -1493,10 +1495,10 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) goto ethtool_exit; } - /* Remove rule to direct LLDP packets to default VSI. + /* Remove rules to direct LLDP packets to PF/VF VSIs. * The FW LLDP engine will now be consuming them. */ - ice_cfg_sw_lldp(vsi, false, false); + ice_dis_sw_lldp(pf); /* AQ command to start FW LLDP agent will return an * error if the agent is already started diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index a774bcdcc0c4..19f08f2e0139 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -2039,6 +2039,50 @@ static void ice_vsi_set_tc_cfg(struct ice_vsi *vsi) ice_vsi_set_dcb_tc_cfg(vsi); } +/** + * ice_dis_sw_lldp - Disable SW LLDP on PFs and VFs + * @pf: pointer to PF structure + * + * Disable SW LLDP settings on each entity that can have it + */ +void ice_dis_sw_lldp(struct ice_pf *pf) +{ + struct ice_vsi *vsi; + struct ice_vf *vf; + unsigned int bkt; + + vsi = ice_get_main_vsi(pf); + ice_cfg_sw_lldp(vsi, false, false); + + if (!test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) + return; + + ice_for_each_vf(pf, bkt, vf) { + vsi = ice_get_vf_vsi(vf); + + if (vsi && vsi->rx_lldp_ena) + ice_cfg_sw_lldp(vsi, false, false); + } +} + +/** + * ice_is_mc_lldp_eth_addr - Check if given MAC is an LLDP multicast address + * @mac: MAC address + * + * Check if given MAC is one of three possible LLDP multicast addresses. + */ +bool ice_is_mc_lldp_eth_addr(const u8 *mac) +{ + u8 lldp_mac_base[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; + + /* Compare the first 5 octets of given and multicast LLDP address */ + if (memcmp(mac, lldp_mac_base, (ETH_ALEN - 1) * sizeof(*mac))) + return false; + + /* Compare the possible last octets of LLDP address and the given one */ + return (mac[5] == 0x0e || mac[5] == 0x03 || mac[5] == 0x00); +} + /** * ice_lldp_fltr_remove_from_port - Remove a LLDP Rx filter from the port * @hw: port @@ -2086,6 +2130,9 @@ void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create) status = eth_fltr(vsi, ETH_P_LLDP, ICE_FLTR_RX, ICE_FWD_TO_VSI); + + if (!status) + vsi->rx_lldp_ena = create; } if (status) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h index 0c77d581416a..befd7dec7e55 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.h +++ b/drivers/net/ethernet/intel/ice/ice_lib.h @@ -68,6 +68,10 @@ int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi); void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create); +void ice_dis_sw_lldp(struct ice_pf *pf); + +bool ice_is_mc_lldp_eth_addr(const u8 *mac); + int ice_set_link(struct ice_vsi *vsi, bool ena); void ice_vsi_delete(struct ice_vsi *vsi); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 9c2c8637b4a7..af3611055e60 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -4704,9 +4704,60 @@ void ice_deinit_dev(struct ice_pf *pf) ice_clear_interrupt_scheme(pf); } +static ssize_t rx_lldp_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct ice_pf *pf = dev_get_drvdata(dev); + struct ice_vsi *vsi = ice_get_main_vsi(pf); + + return sysfs_emit(buf, "%u\n", vsi->rx_lldp_ena); +} + +static ssize_t rx_lldp_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ice_pf *pf = dev_get_drvdata(dev); + struct ice_vsi *vsi; + bool ena; + int err; + + if (test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) { + dev_err(dev, "Toggling Rx LLDP for PF is only allowed when FW LLDP Agent is disabled"); + return -EPERM; + } + + err = kstrtobool(buf, &ena); + if (err) + return -EINVAL; + + vsi = ice_get_main_vsi(pf); + + if (ena == vsi->rx_lldp_ena) { + dev_dbg(dev, "Rx LLDP already %sabled", ena ? "en" : "dis"); + return count; + } + + ice_cfg_sw_lldp(vsi, false, ena); + + return count; +} + +static DEVICE_ATTR_RW(rx_lldp); + +static int ice_init_rx_lldp_sysfs(struct ice_pf *pf) +{ + return device_create_file(ice_pf_to_dev(pf), &dev_attr_rx_lldp); +} + +static void ice_deinit_rx_lldp_sysfs(struct ice_pf *pf) +{ + device_remove_file(ice_pf_to_dev(pf), &dev_attr_rx_lldp); +} + static void ice_init_features(struct ice_pf *pf) { struct device *dev = ice_pf_to_dev(pf); + int err; if (ice_is_safe_mode(pf)) return; @@ -4734,6 +4785,11 @@ static void ice_init_features(struct ice_pf *pf) ice_cfg_lldp_mib_change(&pf->hw, true); } + err = ice_init_rx_lldp_sysfs(pf); + if (err) + dev_err(dev, "could not init rx_lldp sysfs entry, err: %d", + err); + if (ice_init_lag(pf)) dev_warn(dev, "Failed to init link aggregation support\n"); @@ -4757,6 +4813,8 @@ static void ice_deinit_features(struct ice_pf *pf) ice_dpll_deinit(pf); if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV) xa_destroy(&pf->eswitch.reprs); + + ice_deinit_rx_lldp_sysfs(pf); } static void ice_init_wakeup(struct ice_pf *pf) diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c index 21d22e3ad0ba..2de6ef3661cf 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c @@ -518,6 +518,65 @@ static void ice_vf_rebuild_aggregator_node_cfg(struct ice_vsi *vsi) vsi->agg_node->num_vsis++; } +/** + * ice_ena_vf_rx_lldp + * @vf: VF to configure Rx LLDP for + * + * Configure Rx filters for VF to receive LLDP + */ +int ice_ena_vf_rx_lldp(struct ice_vf *vf) +{ + struct ice_pf *pf = vf->pf; + struct ice_vsi *vsi; + + if (test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) { + dev_err(ice_pf_to_dev(pf), "FW LLDP agent is enabled, cannot enable Rx LLDP on VF %d\n", + vf->vf_id); + return -EPERM; + } + + if (!vf->trusted) { + dev_dbg(ice_pf_to_dev(pf), "VF %d is not trusted - cannot configure Rx LLDP filter.\n", + vf->vf_id); + return -EPERM; + } + + vsi = ice_get_vf_vsi(vf); + if (!vsi) + return -ENOENT; + + if (vsi->rx_lldp_ena) + return 0; + + ice_cfg_sw_lldp(vsi, false, true); + + return 0; +} + +/** + * ice_ena_all_vfs_rx_lldp - Re-add RX LLDP filter on applicable VFs. + * @pf: ptr to PF + * + * That is in case when fw-lldp-agent is toggled and LLDP multicast addresses + * are added to the interface. + * RX LLDP filter will be added for trusted VFs only. + */ +void ice_ena_all_vfs_rx_lldp(struct ice_pf *pf) +{ + struct ice_vf *vf; + unsigned int bkt; + + if (!test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) + return; + + ice_for_each_vf(pf, bkt, vf) { + struct ice_vsi *vsi = ice_get_vf_vsi(vf); + + if (vsi && vsi->lldp_macs > 0 && !vsi->rx_lldp_ena) + ice_ena_vf_rx_lldp(vf); + } +} + /** * ice_vf_rebuild_host_cfg - host admin configuration is persistent across reset * @vf: VF to rebuild host configuration on diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h index 48f4cdbd6d27..81f734f2ae41 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h @@ -232,6 +232,8 @@ ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m); int ice_reset_vf(struct ice_vf *vf, u32 flags); void ice_reset_all_vfs(struct ice_pf *pf); struct ice_vsi *ice_get_vf_ctrl_vsi(struct ice_pf *pf, struct ice_vsi *vsi); +void ice_ena_all_vfs_rx_lldp(struct ice_pf *pf); +int ice_ena_vf_rx_lldp(struct ice_vf *vf); #else /* CONFIG_PCI_IOV */ static inline struct ice_vf *ice_get_vf_by_id(struct ice_pf *pf, u16 vf_id) { @@ -307,6 +309,10 @@ ice_get_vf_ctrl_vsi(struct ice_pf *pf, struct ice_vsi *vsi) { return NULL; } + +static inline void ice_ena_all_vfs_rx_lldp(struct ice_pf *pf) +{ +} #endif /* !CONFIG_PCI_IOV */ #endif /* _ICE_VF_LIB_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c index c925813ec9ca..259fcbb0f397 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c @@ -1958,6 +1958,11 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, return ret; } else { vf->num_mac++; + + if (ice_is_mc_lldp_eth_addr(mac_addr)) { + vsi->lldp_macs++; + ice_ena_vf_rx_lldp(vf); + } } ice_vfhw_mac_add(vf, vc_ether_addr); @@ -2049,6 +2054,12 @@ ice_vc_del_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, return -EIO; } + if (ice_is_mc_lldp_eth_addr(mac_addr)) + vsi->lldp_macs--; + + if (vsi->rx_lldp_ena && !vsi->lldp_macs) + ice_cfg_sw_lldp(vsi, false, false); + ice_vfhw_mac_del(vf, vc_ether_addr); vf->num_mac--; From patchwork Wed Feb 28 15:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 207911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3446965dyb; Wed, 28 Feb 2024 08:12:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVbyOvqoZguSPGjzXirTOH4cNwBpNXfDqG14JqdKO/arn+6Qsk7GtArzJgQ11uGsiOlbbKsoeBNk2P9l6eKvEObRq9dUQ== X-Google-Smtp-Source: AGHT+IGLhUvewiLmKpkNtEM6KP/bquUpzJFokDPeyw7orH8sJyA55sDqDxE7NUMaH539ZHzqmFCz X-Received: by 2002:a17:906:eb59:b0:a3f:d2f3:d226 with SMTP id mc25-20020a170906eb5900b00a3fd2f3d226mr114615ejb.17.1709136738741; Wed, 28 Feb 2024 08:12:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709136738; cv=pass; d=google.com; s=arc-20160816; b=fXU248C15LLJvUJe4RLSTwj9axKGjfzB6k+UkLHFFu7GUR07liWQQrAKAFzDblzBtp t7MDkak9MvGAQdD/MVa0pyX8nu8OpXNMrDPYh15ML8YwhfRG5A2rad5y3pSeJ5JC1mdt ZGjF6vmABoOiPc0/nyypVC16QhhjkNGnMzwpIpR6dGy1s4wVoWd/bR0UEelSkO7RiSjc bDbjlqS6REppxsFJUdvx8nWoF45fxrSkqYa6PEAzkXb54K7wVWMcm99lwEWJQcTQMnyB HxgGhjTrrVoxGocifHJAE5FtbPn2zfNylloya+hcnULa2UQWRZNrD0eqA7cApTqKQ49v M/GQ== 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=l6jluIBiYyAZT+5MxIjbRkWwNlF/wEafoYy7rn3oXQI=; fh=XF5dR1hZ6bmHhiCesO+5NPfXhTaDjas2E0STvyrxXLQ=; b=EsYwCrHt4AdQgItQRUr0zBEYFJ7eskcr+I4KTjzhLWYMp5bD+jIJ0PrSWsxQYdd+UC lB7pH0fnnLMSPe+nazJTen4rCggD4vZiQW+2yZa1dKIppmhFjULwlcrP74WDbChgfixZ mMyw+kPR2RuO59j7Loyu+szoQByh4aoVi6GR6GSdLbUIh4S/5G7XaVtau3F3axUvmQH5 P0IQ8TBLYjOfthHFdtrBtHLJ2SFAvA8hzRn01FvoxRdYQH4603qUsclou9SDkMpj/IFI 4pAitbWbYpdgKnomXrNOLhijKuz+qBCprxx7hpjKXIsy/m1ypNdDg6I+G1vVVVivAH1z hv3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aoCYPUHg; 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-85320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85320-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h6-20020a1709066d8600b00a431d6cc657si1724683ejt.782.2024.02.28.08.12.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:12:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aoCYPUHg; 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-85320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85320-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id EA22B1F2B735 for ; Wed, 28 Feb 2024 16:05:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2F391649C8; Wed, 28 Feb 2024 16:04:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aoCYPUHg" 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 6B40515F316; Wed, 28 Feb 2024 16:04:24 +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=1709136266; cv=none; b=k23oYlnQ6VLkPtZ56vygT0N+VIHTMktz8kI/sBWmHBjzdIxZ9WAjYTGGOReV+c3SAf3rK+Ct+Mb4OT2kEsZGh8Hc6Nc+jGB146GUxTCz6CBWSTLvqL2DX+9u2V1yOlrg63zsaXA+tmOqRzroT701fl6Qx+XPnsK83QUiJxZrqR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709136266; c=relaxed/simple; bh=Bjrp1tTlD6ezzWfPdYM+Tqz2X4qeW6q9D/krqY8Q3+k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hq4p5Rv0eAxEuAQdD4ph+cgjhfAVpYjdzPKPkoZun0P/R3PxE1G2t8oIXkPdw7M3zPcCN6zZm6VxWTPwVZ7EvifiioP/A6YoUBpm1qXpPE5Wb1PIwZ0aBv+BDpDDRfFXMdMwEHCrE2pLpBwN+qaRkjs1qj1SHI84HGYfHczmQ5c= 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=aoCYPUHg; 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=1709136264; x=1740672264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Bjrp1tTlD6ezzWfPdYM+Tqz2X4qeW6q9D/krqY8Q3+k=; b=aoCYPUHgwnZd05PMTrhcI8yQ9mIdLjJsI6ae/CC9rk8IQ8vuSSXjp2qJ h9nTrctbQqVGZYkZBSiig4jKXwlO4uCFQolEJJrfnm/ssvKQYn8Wizqmd wlpVpojaNy9P1GOxwUSc9HjgRWsSCKQrS3xfGJ4ie7d2dGzF643maEafq G+rVJ0e0z4YgXqzNb7cQd7Z4TYMzrV5fYlrKuanSoqvdy4z19s4pf+kFM T+YGHD/Xk++4V1HN7gTKIUCdd2dLcOBFOeJuGC9ULvH5wfSpfBdFvbHwx Zj9IxzjqPWVLR7K30uu8bmBmBzGiJYZ3PUW6rsAq0I7U/Qt/ZUjEA4hdZ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3706637" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="3706637" 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:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="7527818" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa009.jf.intel.com with ESMTP; 28 Feb 2024 08:04:18 -0800 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 87BD536825; Wed, 28 Feb 2024 16:04:15 +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 5/5] ice: Implement VF LLDP TX support for VF Date: Wed, 28 Feb 2024 16:59:49 +0100 Message-ID: <20240228155957.408036-6-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792159764958298846 X-GMAIL-MSGID: 1792159764958298846 From: Mateusz Pacuszka Add option to enable transmit LLDP on single trusted VF via a sysfs entry, for example: echo '1' > /sys/class/net//device/virtfn0/transmit_lldp Signed-off-by: Mateusz Pacuszka Co-developed-by: Jakub Buchocki Signed-off-by: Jakub Buchocki Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_lib.c | 3 + drivers/net/ethernet/intel/ice/ice_sriov.c | 4 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 163 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 14 ++ 4 files changed, 184 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 19f08f2e0139..32b1ed74bfa4 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -2062,6 +2062,9 @@ void ice_dis_sw_lldp(struct ice_pf *pf) if (vsi && vsi->rx_lldp_ena) ice_cfg_sw_lldp(vsi, false, false); + + if (vf->transmit_lldp) + ice_handle_vf_tx_lldp(vf, false); } } diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c index a94a1c48c3de..0fe07330cc1a 100644 --- a/drivers/net/ethernet/intel/ice/ice_sriov.c +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c @@ -832,6 +832,10 @@ static int ice_create_vf_entries(struct ice_pf *pf, u16 num_vfs) vf->vfdev = vfdev; vf->vf_sw_id = pf->first_sw; + err = ice_init_vf_sysfs(vf); + if (err) + goto err_free_entries; + pci_dev_get(vfdev); /* set default number of MSI-X */ diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c index 2de6ef3661cf..244d0ac7c9c4 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c @@ -577,6 +577,165 @@ void ice_ena_all_vfs_rx_lldp(struct ice_pf *pf) } } +static bool ice_is_transmit_lldp_enabled(struct ice_pf *pf) +{ + struct ice_vf *vf; + unsigned int bkt; + + ice_for_each_vf(pf, bkt, vf) { + if (vf->transmit_lldp) + return true; + } + + return false; +} + +/** + * ice_handle_vf_tx_lldp - enable/disable LLDP TX on VF + * @vf: VF to configure Tx LLDP for + * @ena: Enable or disable Tx LLDP switch rule + * + * Configure Tx filters for VF to transmit LLDP + */ +int ice_handle_vf_tx_lldp(struct ice_vf *vf, bool ena) +{ + void (*allow_override)(struct ice_vsi_ctx *ctx); + struct ice_vsi *vsi, *main_vsi; + struct ice_pf *pf = vf->pf; + struct device *dev; + bool prev_ena; + + dev = ice_pf_to_dev(pf); + vsi = ice_get_vf_vsi(vf); + main_vsi = ice_get_main_vsi(pf); + if (!vsi || !main_vsi) + return -ENOENT; + + if (ena && test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) { + dev_err(dev, "Transmit LLDP VF is only allowed when FW LLDP Agent is disabled"); + return -EPERM; + } + + if (ena && ice_is_transmit_lldp_enabled(pf)) { + dev_err(dev, "Only a single VF per port is allowed to transmit LLDP packets, ignoring the settings"); + return -EPERM; + } + + allow_override = ena ? ice_vsi_ctx_set_allow_override + : ice_vsi_ctx_clear_allow_override; + prev_ena = vsi->info.sec_flags & ICE_AQ_VSI_SEC_FLAG_ALLOW_DEST_OVRD; + + if (ice_vsi_update_security(vsi, allow_override)) + return -ENOENT; + + /* If VF can transmit LLDP, then PF cannot and vice versa */ + allow_override = ena ? ice_vsi_ctx_clear_allow_override + : ice_vsi_ctx_set_allow_override; + + if (ice_vsi_update_security(main_vsi, allow_override)) { + allow_override = prev_ena ? ice_vsi_ctx_set_allow_override + : ice_vsi_ctx_clear_allow_override; + ice_vsi_update_security(vsi, allow_override); + return -ENOENT; + } + + vf->transmit_lldp = ena; + return 0; +} + +static ssize_t ice_transmit_lldp_vf_attr_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ice_vf *vf = ice_get_vf_by_dev(dev); + + if (!vf) + return -ENOENT; + + return sysfs_emit(buf, "%u\n", vf->transmit_lldp); +} + +static ssize_t ice_transmit_lldp_vf_attr_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pci_dev *vfdev = container_of(dev, struct pci_dev, dev); + struct ice_vf *vf = ice_get_vf_by_dev(dev); + struct pci_dev *pdev = vfdev->physfn; + struct ice_pf *pf; + bool ena; + int err; + + if (!vf) + return -ENOENT; + + pf = pci_get_drvdata(pdev); + if (!pf) + return -ENOENT; + + err = kstrtobool(buf, &ena); + if (err) + return -EINVAL; + + if (ena == vf->transmit_lldp) { + dev_dbg(dev, "Transmit LLDP value already set for VF %d", + vf->vf_id); + return count; + } + + err = ice_handle_vf_tx_lldp(vf, ena); + if (err) + return err; + + return count; +} + +static int ice_init_vf_transmit_lldp_sysfs(struct ice_vf *vf) +{ + struct device_attribute tmp = __ATTR(transmit_lldp, 0644, + ice_transmit_lldp_vf_attr_show, + ice_transmit_lldp_vf_attr_store); + + vf->transmit_lldp_attr = tmp; + + return device_create_file(&vf->vfdev->dev, &vf->transmit_lldp_attr); +} + +/** + * ice_init_vf_sysfs - Initialize sysfs entries for a VF + * @vf: VF to init sysfs for + * + * Initialize sysfs entries (accessible from the host) for a VF + */ +int ice_init_vf_sysfs(struct ice_vf *vf) +{ + struct device *dev = ice_pf_to_dev(vf->pf); + int err = 0; + + if (!vf->vfdev) { + dev_err(dev, "%s: no vfdev", __func__); + return -ENOENT; + } + + err = ice_init_vf_transmit_lldp_sysfs(vf); + if (err) + dev_err(dev, "could not init transmit_lldp sysfs entry, err: %d", + err); + + return err; +} + +static int ice_vf_apply_tx_lldp(struct ice_vf *vf) +{ + if (!vf->transmit_lldp) + return 0; + + /* Disable it so it can be applied again. */ + vf->transmit_lldp = false; + + return ice_handle_vf_tx_lldp(vf, true); +} + /** * ice_vf_rebuild_host_cfg - host admin configuration is persistent across reset * @vf: VF to rebuild host configuration on @@ -607,6 +766,10 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf) dev_err(dev, "failed to rebuild spoofchk configuration for VF %d\n", vf->vf_id); + if (ice_vf_apply_tx_lldp(vf)) + dev_err(dev, "failed to rebuild transmit LLDP configuration for VF %d\n", + vf->vf_id); + /* rebuild aggregator node config for main VF VSI */ ice_vf_rebuild_aggregator_node_cfg(vsi); } diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h index 81f734f2ae41..63e53591541e 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h @@ -104,9 +104,11 @@ struct ice_vf { struct ice_vlan port_vlan_info; /* Port VLAN ID, QoS, and TPID */ struct virtchnl_vlan_caps vlan_v2_caps; struct ice_mbx_vf_info mbx_info; + struct device_attribute transmit_lldp_attr; u8 pf_set_mac:1; /* VF MAC address set by VMM admin */ u8 trusted:1; u8 spoofchk:1; + u8 transmit_lldp:1; u8 link_forced:1; u8 link_up:1; /* only valid if VF link is forced */ /* VSI indices - actual VSI pointers are maintained in the PF structure @@ -234,6 +236,8 @@ void ice_reset_all_vfs(struct ice_pf *pf); struct ice_vsi *ice_get_vf_ctrl_vsi(struct ice_pf *pf, struct ice_vsi *vsi); void ice_ena_all_vfs_rx_lldp(struct ice_pf *pf); int ice_ena_vf_rx_lldp(struct ice_vf *vf); +int ice_init_vf_sysfs(struct ice_vf *vf); +int ice_handle_vf_tx_lldp(struct ice_vf *vf, bool ena); #else /* CONFIG_PCI_IOV */ static inline struct ice_vf *ice_get_vf_by_id(struct ice_pf *pf, u16 vf_id) { @@ -313,6 +317,16 @@ ice_get_vf_ctrl_vsi(struct ice_pf *pf, struct ice_vsi *vsi) static inline void ice_ena_all_vfs_rx_lldp(struct ice_pf *pf) { } + +static inline int ice_handle_vf_tx_lldp(struct ice_vf *vf, bool ena) +{ + return -EOPNOTSUPP; +} + +static inline int ice_init_vf_sysfs(struct ice_vf *vf) +{ + return 0; +} #endif /* !CONFIG_PCI_IOV */ #endif /* _ICE_VF_LIB_H_ */