From nobody Tue Dec 16 07:41:28 2025 Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 793004A02 for ; Fri, 5 Dec 2025 23:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764979094; cv=none; b=lSDUlleWabylWC8ovaY890UR6ao9cLCGrQYo8tKZbhEk/WU4PEmmouKNxo/QyBHcj/18IHiKkv1ihaxNg/KtieqFQDBZgOMWFrSpGyMOsBTNy6CzPgPeQ5YuOZlMrG3U0eHAnKK/y9gZoYSwtsJpZpN4pgs5iRpSxgegggT9S2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764979094; c=relaxed/simple; bh=6eXmvFRyk7c0S5Z8owqZR1SIcLC19Pl4Ruv0fhYJByk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iTLuYQnYhku3crKJzXv8710NlBMLlMz8StFzXcc8aq2/w8y1Hm1PA+vpAVoaENYpzFzlG1MbcJDeRFL2N/SDeYoixn91iDWuG8h+1alDIi4NrERoIaAz1M2DTNUwqrpi4nabaWMLBI1v2vmCAX5BbTQzxYCM6LwwjRZ01GpKWxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=joqTKcFG; arc=none smtp.client-ip=74.125.224.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="joqTKcFG" Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-6420dc2e5feso2196338d50.3 for ; Fri, 05 Dec 2025 15:58:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764979090; x=1765583890; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cPgQOdtl/tU0gJp0Qps8kqZujLmXDZbYPgzwk6SilGM=; b=joqTKcFGmhs3//4kC1kHuGSmV3Mcuy2EnB69U9jbFbq9h7wQtOZKPxWhQEN6rHiudk U3pqYOWf+EYcHCD1K7Rs+DMB2ZuXihh2/qS0qx3wc0QYZtLBE2QjMlLIc06n7Mh27rzG t4BdTLNbatcrzcOgHcuMPRL4Y0dduK6f2AujkmfB84iyBqXler6CHZ9PkfkFVp8ok5d6 dTh5TVP9PXj3lU+Y8L+ap6jBdGZqoybLVo6mBhHte4hX4DQ4lIZyOU1opNK/ltfgWGD6 LUElpC7K/+5VKrIL0B/e3REduXysmAUnnDIQD6dB7uTmRvGSZB4jKhkYMuLsEck7YEu/ 0KOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764979090; x=1765583890; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cPgQOdtl/tU0gJp0Qps8kqZujLmXDZbYPgzwk6SilGM=; b=Ld+FFVTDjuywOen/BYcHZ50P7wgp0yUgrkI55c35FoISOiRa52uLMFlJmtt4CEXhX4 n9nDlnWDyJ1ZeOb/Z0raDZOLQ9P4yTca/GwNneXXlgGijhOlxUleDmCcKEA+ejHD3k7J Q1ejbiNYX0FK464f8mwjRju0HQuYwN4xTtqTeUZ7NrFsw3jrknk0yxoyHJVcpkEhd4l0 lKGbdvDtuiJpCpgMME+k457xnu7uiSr4uv6GRQDJOg5mKD2BWGBsoAxIozZraMaggN9F JSyhqL5lffvNt1U/MtBEJJYlFlKVDhUjOBP22PlRJiW8PV918+LRm4yTtLx6rjjqVgYI 9T9Q== X-Forwarded-Encrypted: i=1; AJvYcCU6VbFEgXuK7VZvREtgcmPwi8TtaLrLQ6V/5zVDs81KrEtQa607k6RTdyjEMbADL0RINIW8naMyKaccHGU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzsn/H53bLxEy3yEabfPBb8Uo9jVG2FJ4L9Ex17eVDOpmJCzCL7 D/LGhzcZGKY30GOcw4qXpzkczJnAN4KfcPUVqqNTm8n3u/aKffkIrynH X-Gm-Gg: ASbGncuX6jU5WjdnFaMY9ML0V3wN9ADgyYGfixHpLJmhf6WP/NDI2wweDXiwC3jHCVh 4v86XXgC81PDsJkacp5xlRPemAnZ8VSRn9D0FoFUoEkt903BZOsleD0rlWLZY6cERz9cied6Hjm aEDS8ZcI/SzaYzz3ATMvjpgUaLfrSRA8ZEjDh+9hdu5yyEG2xNh2V9+4oJBYbLWXJg2+gjTGyE+ VYv9KnDqruHWnXFuThBwTF/GLwosRiHgum0rmmYzzkF6fEz5Wl1+H4SnFtu9Tkdcjs9UoP6I5rQ Uh7trBysSwQyOpKzFhXd+/aaXuM6fpqp4A1umUtG/skUdPpNOFQMkCWpSiulZnFyS12AoSswhOA S858Nn7gNS3z/kkYBNrtrTADlPgyXJZwD6kQZqfAldBJgx4PhENGS+Bu0e4eX5BWGI741bkR+Qf 7hHwWR5Q== X-Google-Smtp-Source: AGHT+IHQX3by7qUEucqLqlHVgdeo4lBeXWo2mpPEuAMYSDC6NV5CkJ3jE4tMh3tjLdeQoEyI4ORbGg== X-Received: by 2002:a05:690e:434a:b0:644:472d:daf2 with SMTP id 956f58d0204a3-6444e7b93fcmr499956d50.53.1764979090366; Fri, 05 Dec 2025 15:58:10 -0800 (PST) Received: from localhost ([2601:346:0:79bd:be2a:7e4d:3bf:3fbc]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78c1b78e5f5sm22031307b3.41.2025.12.05.15.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 15:58:10 -0800 (PST) From: "Yury Norov (NVIDIA)" To: James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" , Justin Tee , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Yury Norov (NVIDIA)" Subject: [PATCH v2] scsi: lpfc: rework lpfc_sli4_fcf_rr_next_index_get() Date: Fri, 5 Dec 2025 18:58:08 -0500 Message-ID: <20251205235808.358258-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function opencodes for_each_set_bit_wrap(). Use it, and while there switch from goto-driven codeflow to more high-level constructions. Signed-off-by: Yury Norov (NVIDIA) Reviewed-by: Justin Tee --- v1: https://lore.kernel.org/all/20250917141806.661826-1-yury.norov@gmail.co= m/ v2: tweak check against LPFC_FCF_FLOGI_FAILED flag (Justin); drivers/scsi/lpfc/lpfc_sli.c | 62 +++++++++++------------------------- 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 7ea7c4245c69..c330db3e54dc 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -20361,62 +20361,36 @@ lpfc_check_next_fcf_pri_level(struct lpfc_hba *ph= ba) uint16_t lpfc_sli4_fcf_rr_next_index_get(struct lpfc_hba *phba) { - uint16_t next_fcf_index; + uint16_t next; =20 -initial_priority: - /* Search start from next bit of currently registered FCF index */ - next_fcf_index =3D phba->fcf.current_rec.fcf_indx; - -next_priority: - /* Determine the next fcf index to check */ - next_fcf_index =3D (next_fcf_index + 1) % LPFC_SLI4_FCF_TBL_INDX_MAX; - next_fcf_index =3D find_next_bit(phba->fcf.fcf_rr_bmask, - LPFC_SLI4_FCF_TBL_INDX_MAX, - next_fcf_index); + do { + for_each_set_bit_wrap(next, phba->fcf.fcf_rr_bmask, + LPFC_SLI4_FCF_TBL_INDX_MAX, phba->fcf.current_rec.fcf_indx) { + if (next =3D=3D phba->fcf.current_rec.fcf_indx) + continue; =20 - /* Wrap around condition on phba->fcf.fcf_rr_bmask */ - if (next_fcf_index >=3D LPFC_SLI4_FCF_TBL_INDX_MAX) { - /* - * If we have wrapped then we need to clear the bits that - * have been tested so that we can detect when we should - * change the priority level. - */ - next_fcf_index =3D find_first_bit(phba->fcf.fcf_rr_bmask, - LPFC_SLI4_FCF_TBL_INDX_MAX); - } + if (!(phba->fcf.fcf_pri[next].fcf_rec.flag & LPFC_FCF_FLOGI_FAILED)) { + lpfc_printf_log(phba, KERN_INFO, LOG_FIP, + "2845 Get next roundrobin failover FCF (x%x)\n", next); + return next; + } =20 + if (list_is_singular(&phba->fcf.fcf_pri_list)) + return LPFC_FCOE_FCF_NEXT_NONE; + } =20 - /* Check roundrobin failover list empty condition */ - if (next_fcf_index >=3D LPFC_SLI4_FCF_TBL_INDX_MAX || - next_fcf_index =3D=3D phba->fcf.current_rec.fcf_indx) { /* * If next fcf index is not found check if there are lower * Priority level fcf's in the fcf_priority list. * Set up the rr_bmask with all of the avaiable fcf bits * at that level and continue the selection process. */ - if (lpfc_check_next_fcf_pri_level(phba)) - goto initial_priority; - lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, - "2844 No roundrobin failover FCF available\n"); - - return LPFC_FCOE_FCF_NEXT_NONE; - } - - if (next_fcf_index < LPFC_SLI4_FCF_TBL_INDX_MAX && - phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag & - LPFC_FCF_FLOGI_FAILED) { - if (list_is_singular(&phba->fcf.fcf_pri_list)) - return LPFC_FCOE_FCF_NEXT_NONE; + } while (lpfc_check_next_fcf_pri_level(phba)); =20 - goto next_priority; - } - - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2845 Get next roundrobin failover FCF (x%x)\n", - next_fcf_index); + lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, + "2844 No roundrobin failover FCF available\n"); =20 - return next_fcf_index; + return LPFC_FCOE_FCF_NEXT_NONE; } =20 /** --=20 2.43.0