Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: lpfc: Rework lpfc_sli4_fcf_rr_next_index_get()

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) <yury.norov@gmail.com>
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Link: https://patch.msgid.link/20251205235808.358258-1-yury.norov@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Yury Norov (NVIDIA) and committed by
Martin K. Petersen
1a56e63c a8cf5c1b

+18 -44
+18 -44
drivers/scsi/lpfc/lpfc_sli.c
··· 20432 20432 uint16_t 20433 20433 lpfc_sli4_fcf_rr_next_index_get(struct lpfc_hba *phba) 20434 20434 { 20435 - uint16_t next_fcf_index; 20435 + uint16_t next; 20436 20436 20437 - initial_priority: 20438 - /* Search start from next bit of currently registered FCF index */ 20439 - next_fcf_index = phba->fcf.current_rec.fcf_indx; 20437 + do { 20438 + for_each_set_bit_wrap(next, phba->fcf.fcf_rr_bmask, 20439 + LPFC_SLI4_FCF_TBL_INDX_MAX, phba->fcf.current_rec.fcf_indx) { 20440 + if (next == phba->fcf.current_rec.fcf_indx) 20441 + continue; 20440 20442 20441 - next_priority: 20442 - /* Determine the next fcf index to check */ 20443 - next_fcf_index = (next_fcf_index + 1) % LPFC_SLI4_FCF_TBL_INDX_MAX; 20444 - next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, 20445 - LPFC_SLI4_FCF_TBL_INDX_MAX, 20446 - next_fcf_index); 20443 + if (!(phba->fcf.fcf_pri[next].fcf_rec.flag & LPFC_FCF_FLOGI_FAILED)) { 20444 + lpfc_printf_log(phba, KERN_INFO, LOG_FIP, 20445 + "2845 Get next roundrobin failover FCF (x%x)\n", next); 20446 + return next; 20447 + } 20447 20448 20448 - /* Wrap around condition on phba->fcf.fcf_rr_bmask */ 20449 - if (next_fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) { 20450 - /* 20451 - * If we have wrapped then we need to clear the bits that 20452 - * have been tested so that we can detect when we should 20453 - * change the priority level. 20454 - */ 20455 - next_fcf_index = find_first_bit(phba->fcf.fcf_rr_bmask, 20456 - LPFC_SLI4_FCF_TBL_INDX_MAX); 20457 - } 20449 + if (list_is_singular(&phba->fcf.fcf_pri_list)) 20450 + return LPFC_FCOE_FCF_NEXT_NONE; 20451 + } 20458 20452 20459 - 20460 - /* Check roundrobin failover list empty condition */ 20461 - if (next_fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX || 20462 - next_fcf_index == phba->fcf.current_rec.fcf_indx) { 20463 20453 /* 20464 20454 * If next fcf index is not found check if there are lower 20465 20455 * Priority level fcf's in the fcf_priority list. 20466 20456 * Set up the rr_bmask with all of the avaiable fcf bits 20467 20457 * at that level and continue the selection process. 20468 20458 */ 20469 - if (lpfc_check_next_fcf_pri_level(phba)) 20470 - goto initial_priority; 20471 - lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, 20472 - "2844 No roundrobin failover FCF available\n"); 20459 + } while (lpfc_check_next_fcf_pri_level(phba)); 20473 20460 20474 - return LPFC_FCOE_FCF_NEXT_NONE; 20475 - } 20461 + lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, 20462 + "2844 No roundrobin failover FCF available\n"); 20476 20463 20477 - if (next_fcf_index < LPFC_SLI4_FCF_TBL_INDX_MAX && 20478 - phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag & 20479 - LPFC_FCF_FLOGI_FAILED) { 20480 - if (list_is_singular(&phba->fcf.fcf_pri_list)) 20481 - return LPFC_FCOE_FCF_NEXT_NONE; 20482 - 20483 - goto next_priority; 20484 - } 20485 - 20486 - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, 20487 - "2845 Get next roundrobin failover FCF (x%x)\n", 20488 - next_fcf_index); 20489 - 20490 - return next_fcf_index; 20464 + return LPFC_FCOE_FCF_NEXT_NONE; 20491 20465 } 20492 20466 20493 20467 /**