Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pw1Q3-00006d-UY for mharc-grub-devel@gnu.org; Mon, 08 May 2023 10:00:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw1Pg-0008HB-5o for grub-devel@gnu.org; Mon, 08 May 2023 10:00:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw1Pc-0006Hi-2T for grub-devel@gnu.org; Mon, 08 May 2023 10:00:25 -0400 Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 348DrNPd019118 for ; Mon, 8 May 2023 14:00:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=DH7yw93BOL0kziq7t2OaH9I1b5sl3pF6Bu6x0Kn5gW0=; b=HEx3aqt1ifnX0Jq8e72yGCcAvzGuU/MmekcelEjMhiJ0GiaDOY1XnUck8y/IXweMKQXB ZZHXaJ2jvpEJULkPy34ktyWUKwLHuqScomafoeUiORuq+5NwlRvBJjsF6afh+2FEgKcs vSwll9tzjqLRVMc/GWVqmnxPiiEJt67W5DIur09R9T7CrhAkhTqpDa6a0z81yc0kWYFj u0wxpyq8TouN7Elf99O9bdnYlYEGmUnu/Pa4r0cnd5wjOd2mwEhts55GBdkz4+UQvVnY NJ9LcgzC22cbYGAwhfgsBrscpM+y+uRJ5GkaRAP+pxKD0+337LqEG+suBW9Jj8QqnZHW qQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qf2c3g8eq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 08 May 2023 14:00:21 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 348Dv0nn000825 for ; Mon, 8 May 2023 14:00:21 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qf2c3g8an-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 May 2023 14:00:20 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 348BXPnB007850; Mon, 8 May 2023 14:00:17 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3qdeh6gxn2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 May 2023 14:00:17 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 348E0DUG31064750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 May 2023 14:00:13 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58EFC20040; Mon, 8 May 2023 14:00:13 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 590E02004E; Mon, 8 May 2023 14:00:10 +0000 (GMT) Received: from li-5fd77d4c-2a67-11b2-a85c-de894c326bed.ibm.com.com (unknown [9.43.93.74]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 8 May 2023 14:00:10 +0000 (GMT) From: Avnish Chouhan To: grub-devel@gnu.org Cc: meghanaprakash@in.ibm.com, brking@linux.vnet.ibm.com, mchauras@linux.vnet.ibm.com, mamatha4@linux.vnet.ibm.com, rharwood@redhat.com, mlewando@redhat.com, Avnish Chouhan , Diego Domingos Subject: [PATCH 3/6] ieee1275: implement FCP methods for WWPN and LUNs Date: Mon, 8 May 2023 19:28:37 +0530 Message-Id: <20230508135840.47765-4-avnish@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230508135840.47765-1-avnish@linux.vnet.ibm.com> References: <20230508135840.47765-1-avnish@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fSAnVlMhYjBCY7sW9Axz0r85LQDwKZEC X-Proofpoint-GUID: oEXZmmSbepyEj639sZamqDJlKc55owcZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-08_10,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 clxscore=1015 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=969 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305080091 Received-SPF: none client-ip=148.163.156.1; envelope-from=avnish@linux.vnet.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 May 2023 14:00:45 -0000 This patch enables the fcp-targets and fcp-luns methods which are responsible to get WWPNs and LUNs for fibre channel devices. Those methods are specially necessary if the boot directory and grub installation are in different FCP disks, allowing the dev_iterate() to find the WWPNs and LUNs when called by searchfs.uuid tool. Signed-off-by: Diego Domingos Signed-off-by: Avnish Chouhan --- grub-core/disk/ieee1275/ofdisk.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 5534684..5958e5e 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -209,7 +209,116 @@ dev_iterate_real (const char *name, const char *path) static void dev_iterate (const struct grub_ieee1275_devalias *alias) { - if (grub_strcmp (alias->type, "vscsi") == 0) + if (grub_strcmp (alias->type, "fcp") == 0) + { + /* + * If we are dealing with fcp devices, we need + * to find the WWPNs and LUNs to iterate them + */ + grub_ieee1275_ihandle_t ihandle; + grub_uint64_t *ptr_targets, *ptr_luns, k, l; + unsigned int i, j, pos; + char *buf, *bufptr; + struct set_fcp_targets_args + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t nentries; + grub_ieee1275_cell_t table; + } args_targets; + + struct set_fcp_luns_args + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t wwpn_h; + grub_ieee1275_cell_t wwpn_l; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t nentries; + grub_ieee1275_cell_t table; + } args_luns; + + struct args_ret + { + grub_uint64_t addr; + grub_uint64_t len; + }; + + if(grub_ieee1275_open (alias->path, &ihandle)) + { + grub_dprintf("disk", "failed to open the disk while iterating FCP disk path=%s\n", alias->path); + return; + } + + /* Setup the fcp-targets method to call via pfw*/ + INIT_IEEE1275_COMMON (&args_targets.common, "call-method", 2, 3); + args_targets.method = (grub_ieee1275_cell_t) "fcp-targets"; + args_targets.ihandle = ihandle; + + /* Setup the fcp-luns method to call via pfw */ + INIT_IEEE1275_COMMON (&args_luns.common, "call-method", 4, 3); + args_luns.method = (grub_ieee1275_cell_t) "fcp-luns"; + args_luns.ihandle = ihandle; + if (IEEE1275_CALL_ENTRY_FN (&args_targets) == -1) + { + grub_dprintf("disk", "failed to get the targets while iterating FCP disk path=%s\n", alias->path); + grub_ieee1275_close(ihandle); + return; + } + buf = grub_malloc (grub_strlen (alias->path) + 32 + 32); + if (!buf) + { + grub_ieee1275_close(ihandle); + return; + } + bufptr = grub_stpcpy (buf, alias->path); + + /* + * Iterate over entries returned by pfw. Each entry contains a + * pointer to wwpn table and his length. + */ + struct args_ret *targets_table = (struct args_ret *)(args_targets.table); + for (i=0; i< args_targets.nentries; i++) + { + ptr_targets = (grub_uint64_t*)(grub_uint32_t) targets_table[i].addr; + /* Iterate over all wwpns in given table */ + for(k=0;k> 32); + pos = grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, + *ptr_targets++); + /* Get the luns for given wwpn target */ + if (IEEE1275_CALL_ENTRY_FN (&args_luns) == -1) + { + grub_dprintf("disk", "failed to get the LUNS while iterating FCP disk path=%s\n", buf); + grub_ieee1275_close (ihandle); + grub_free (buf); + return; + } + struct args_ret *luns_table = (struct args_ret *)(args_luns.table); + + /* Iterate over all LUNs */ + for(j=0;jtype, "vscsi") == 0) { static grub_ieee1275_ihandle_t ihandle; struct set_color_args -- 2.31.1