From: Avnish Chouhan <avnish@linux.ibm.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, brking@linux.ibm.com,
meghanaprakash@in.ibm.com, Avnish Chouhan <avnish@linux.ibm.com>,
Diego Domingos <diegodo@br.ibm.com>
Subject: [PATCH v3 1/6] ieee1275/powerpc: implements fibre channel discovery for ofpathname
Date: Thu, 6 Jun 2024 18:07:22 +0530 [thread overview]
Message-ID: <20240606123727.38614-2-avnish@linux.ibm.com> (raw)
In-Reply-To: <20240606123727.38614-1-avnish@linux.ibm.com>
grub-ofpathname doesn't work with fibre channel because there is no
function currently implemented for it.
This patch enables it by prividing a function that looks for the port
name, building the entire path for OF devices.
Signed-off-by: Diego Domingos <diegodo@br.ibm.com>
Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com>
---
grub-core/osdep/linux/ofpath.c | 49 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
index a6153d35954..0f5d54e9f2d 100644
--- a/grub-core/osdep/linux/ofpath.c
+++ b/grub-core/osdep/linux/ofpath.c
@@ -350,6 +350,38 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi
return ret;
}
+
+static void
+of_fc_port_name (const char *path, const char *subpath, char *port_name)
+{
+ char *bname, *basepath, *p;
+ int fd;
+
+ bname = xmalloc (sizeof (char) * 150);
+ basepath = xmalloc (strlen (path));
+
+ /* Generate the path to get port name information from the drive */
+ strncpy (basepath, path, subpath-path);
+ basepath[subpath-path - 1] = '\0';
+ p = get_basename (basepath);
+ snprintf (bname, sizeof (char) * 150, "%s/fc_transport/%s/port_name", basepath, p);
+
+ /* Read the information from the port name */
+ fd = open (bname, O_RDONLY);
+ if (fd < 0)
+ grub_util_error (_("cannot open `%s': %s"), bname, strerror (errno));
+
+ if (read (fd, port_name, sizeof (char) *19) < 0)
+ grub_util_error (_("cannot read `%s': %s"), bname, strerror (errno));
+
+ sscanf (port_name, "0x%s", port_name);
+
+ close (fd);
+
+ free (bname);
+ free (basepath);
+}
+
#ifdef __sparc__
static char *
of_path_of_nvme(const char *sys_devname __attribute__((unused)),
@@ -577,6 +609,16 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
digit_string = trailing_digits (device);
if (strncmp (of_path, "/vdevice/", sizeof ("/vdevice/") - 1) == 0)
{
+ if (strstr (of_path, "vfc-client"))
+ {
+ char * port_name = xmalloc (sizeof (char) * 17);
+ of_fc_port_name (sysfs_path, p, port_name);
+
+ snprintf (disk, sizeof (disk), "/%s@%s", disk_name, port_name);
+ free (port_name);
+ }
+ else
+ {
unsigned long id = 0x8000 | (tgt << 8) | (bus << 5) | lun;
if (*digit_string == '\0')
{
@@ -590,6 +632,13 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
snprintf(disk, sizeof (disk),
"/%s@%04lx000000000000:%c", disk_name, id, 'a' + (part - 1));
}
+ }
+ } else if (strstr (of_path, "fibre-channel") || (strstr (of_path, "vfc-client"))){
+ char * port_name = xmalloc (sizeof (char) * 17);
+ of_fc_port_name (sysfs_path, p, port_name);
+
+ snprintf (disk, sizeof (disk), "/%s@%s", disk_name, port_name);
+ free (port_name);
}
else
{
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next prev parent reply other threads:[~2024-06-06 12:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 12:37 [PATCH v3 0/6] NVMeoFC support on Grub Avnish Chouhan
2024-06-06 12:37 ` Avnish Chouhan [this message]
2024-06-26 10:17 ` [PATCH v3 1/6] ieee1275/powerpc: implements fibre channel discovery for ofpathname Michael Chang via Grub-devel
2024-06-06 12:37 ` [PATCH v3 2/6] ieee1275/powerpc: enables device mapper discovery Avnish Chouhan
2024-06-06 15:34 ` Vladimir 'phcoder' Serbinenko
2024-06-07 8:34 ` avnish
2024-06-07 9:34 ` Vladimir 'phcoder' Serbinenko
2024-06-06 12:37 ` [PATCH v3 3/6] ieee1275: implement FCP methods for WWPN and LUNs Avnish Chouhan
2024-07-01 7:34 ` Michael Chang via Grub-devel
2024-07-01 10:40 ` avnish
2024-06-06 12:37 ` [PATCH v3 4/6] ieee1275: change the logic of ieee1275_get_devargs() Avnish Chouhan
2024-06-06 12:37 ` [PATCH v3 5/6] ieee1275: add support for NVMeoFC Avnish Chouhan
2024-06-06 12:37 ` [PATCH v3 6/6] ieee1275: ofpath enable NVMeoF logical device translate Avnish Chouhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240606123727.38614-2-avnish@linux.ibm.com \
--to=avnish@linux.ibm.com \
--cc=brking@linux.ibm.com \
--cc=daniel.kiper@oracle.com \
--cc=diegodo@br.ibm.com \
--cc=grub-devel@gnu.org \
--cc=meghanaprakash@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.