Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp331218lqp; Thu, 21 Mar 2024 02:33:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGFMvbs0OLs2o9Ji5XewSdYHs3hQvI1WA03u1uhhIKZTHVPjm0029KjBndmE4rkk1twrolZLZneXfRmVrFCYfPTPM4hIjRIc4eNALuCA== X-Google-Smtp-Source: AGHT+IE2gyhzWOWi3BPRQHEMb6pOn+rGY3GzDNuQdtoSZX8qrEpib/XgffonNh6Z0SKQPMIFaPpt X-Received: by 2002:a05:6a20:7fa2:b0:1a3:64be:752c with SMTP id d34-20020a056a207fa200b001a364be752cmr3111080pzj.26.1711013622891; Thu, 21 Mar 2024 02:33:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711013622; cv=pass; d=google.com; s=arc-20160816; b=MrvNIuvdox1qXMg1VRmT3Lj6et1lc69xVCL5J8uiY+m+uTmhs1qYtrXffDmQ3GlsBl pVpXT563/jksOwezqMqDxbSthFaZZ15EcIL4Hk9IJWesZpKcXep3oEWX6/anM2Kb9szI g8kL04nqhpcSpy//xGheOg7OCh/E6yM3PoWksoVV5QDeOre35OJUN6UxnvN+zfn/j6sO gKnO8nm456i8k+ZldeSTfKbFG/kPKehMErdbI2H3NmaFKWhSTzJX/fpsDzSZ7ui0Bebo ptUHyBFufX2zEtLMgbZ01DX0EXsS53hv4CqxtQjBkkbMqTDVEXemGwDy5rPzR3iEh2le rYPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Rs6XYbBWQxRBg0YMTrNuobAVa9pvsnukIpqnddxJZbc=; fh=4VLEW5ahMoNtJx5KXD4P8+jyEOT2kWIUIoBRcJENllQ=; b=U0DDn9WKUlKGiQUHiG4ijzHY1gysQ3MeUG5LnRaHly7zwwqn0Kqr1iRozOtde/09fw vBNMHw2Ywp63Zb7snCeoy7a806tY5PDphblFAFVl3ie4fFQH0E7yfoz3az0yblcBpCwg P4LZOaJOigEgdBmD8y1aLaf0tJp/swCPfoXNJkW2EmF1tk7YqzrGmCUqnuWUzhzyE+Z1 B3SDH4+AUEpopiIYcHZqk7J9kG6BlRi3uunbSRhOzNzAi39QzTPOOSOI8p3b+73p/9I3 WlsDxugCbW+e2PicusZCaZFIDuGCIz4FC7EBRsvb8j+AfejLGTZR/KTffCVNywqAxO4Y vfIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ql67lD25; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-109857-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fn24-20020a056a002fd800b006e69e2a97aesi14782608pfb.267.2024.03.21.02.33.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 02:33:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109857-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=@redhat.com header.s=mimecast20190719 header.b=Ql67lD25; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-109857-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 84984282F7F for ; Thu, 21 Mar 2024 09:33:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2A2F54F91; Thu, 21 Mar 2024 09:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ql67lD25" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 636074E1D5 for ; Thu, 21 Mar 2024 09:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711013613; cv=none; b=dK9Zihm4s594iY2oI1ohHfxc/oQNZejd6OIjv6cnNjW42hDInUySHFcMsQYUKz0BHfpimv5c4hd5B5mqaDIZZWP/hA24d99VqzC/nbEf7v/r0DjLfFNbv7dwVnKdvjzep6hnw3fzmMU6GMfkRjdeGjw1Y0SSB0GWr+VPFTKjLNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711013613; c=relaxed/simple; bh=yqdjQVNbcauOFxaogP8b3/2502Vi0LT+CvmPhASCPlU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rph0E65QltD/5O2tbzUigeyt4BEunQgtqOQ3qwBj0Q0AtNRqkiyNDR8yCj5+ozMmItl6DU9p3p9qKdfsRXWIxXidKMx2t06+FICXVdLEVL2wB9TwKuTH9qEICDxJPasVaysClIPBQzXSPWqMuT1tbuHsDu4Sw/d3RQSK333/hLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ql67lD25; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711013611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rs6XYbBWQxRBg0YMTrNuobAVa9pvsnukIpqnddxJZbc=; b=Ql67lD25mjYGPiGx5fcGug7MFFT+p1AXSGgULTZASu5MgCtecDhpjJOf8J921qasdEaD1B AW+ccmGe5gKX9/gTTjnGeN/zKro309MoENq3S9ooVDg3tzDBWJK47jilbeP+NXGzmy9/LC Xt87SXMuykEml3suAWs6JeoSb7nvVlY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-Dob_UXorNx2b4J-k8THHIg-1; Thu, 21 Mar 2024 05:33:27 -0400 X-MC-Unique: Dob_UXorNx2b4J-k8THHIg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4759D89C661; Thu, 21 Mar 2024 09:33:27 +0000 (UTC) Received: from [10.45.225.240] (unknown [10.45.225.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B6331D091; Thu, 21 Mar 2024 09:33:25 +0000 (UTC) Message-ID: <3540c6da-edbd-48e8-8bcb-effe64470ca0@redhat.com> Date: Thu, 21 Mar 2024 10:33:21 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH iwl-next 5/7] i40e: Consolidate checks whether given VSI is main To: Paolo Abeni , intel-wired-lan@lists.osuosl.org Cc: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "open list:NETWORKING DRIVERS" , open list References: <20240318143058.287014-1-ivecera@redhat.com> <20240318143058.287014-6-ivecera@redhat.com> <557e819bc6acdfc2311fe2254b1f382bad8368fc.camel@redhat.com> Content-Language: en-US From: Ivan Vecera In-Reply-To: <557e819bc6acdfc2311fe2254b1f382bad8368fc.camel@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 On 19. 03. 24 11:17, Paolo Abeni wrote: > On Mon, 2024-03-18 at 15:30 +0100, Ivan Vecera wrote: >> In the driver code there are 3 types of checks whether given >> VSI is main or not: >> 1. vsi->type ==/!= I40E_VSI_MAIN >> 2. vsi ==/!= pf->vsi[pf->lan_vsi] >> 3. vsi->seid ==/!= pf->vsi[pf->lan_vsi]->seid >> >> All of them are equivalent and can be consolidated. Convert cases >> 2 and 3 to case 1. > > Minor nit: while at it, what about introducing an helper for such > check? > Reordering the patches you could use it also in i40e_pf_get_main_vsi() No, I couldn't, that helper does not check vsi->type value: /** * i40e_pf_get_main_vsi - get pointer to main VSI * @pf: pointer to a PF * * Return pointer to main VSI or NULL if it does not exist **/ static inline struct i40e_vsi *i40e_pf_get_main_vsi(struct i40e_pf *pf) { return (pf->lan_vsi != I40E_NO_VSI) ? pf->vsi[pf->lan_vsi] : NULL; } I had an idea with helper like: static inline bool i40e_is_main_vsi(struct i40e_vsi *vsi) { struct i40e_pf *pf = vsi->back; return (pf->vsi[pf->lan_vsi] == vsi); } but I think that `vsi->type == I40E_VSI_MAIN` is simple enough. Thanks, Ivan