Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofpathname: add support for NVMe logical/OpenFirmware device path conversion #3

Closed
wants to merge 2 commits into from

Conversation

mfoliveira
Copy link

These 2 patches add the functions of2l_nvme() and l2of_nvme() to scripts/ofpathname.

Test scenario:

# ls -1d /dev/nvme*
/dev/nvme0
/dev/nvme0n1
/dev/nvme0n1p1
/dev/nvme0n1p2
/dev/nvme0n1p3

Test results:

l2of_nvme()

Existing devices:

# ofpathname /dev/nvme0
/pci@80000002000001c/pci1014,4f5@0

# ofpathname /dev/nvme0n1
/pci@80000002000001c/pci1014,4f5@0/namespace@1

# ofpathname /dev/nvme0n1p1
/pci@80000002000001c/pci1014,4f5@0/namespace@1:1

# ofpathname /dev/nvme0n1p2
/pci@80000002000001c/pci1014,4f5@0/namespace@1:2

# ofpathname /dev/nvme0n1p3
/pci@80000002000001c/pci1014,4f5@0/namespace@1:3

Non-existing devices:

# ofpathname /dev/nvme1
ofpathname: Could not find sysfs information for logical
            device "/dev/nvme1".

# ofpathname /dev/nvme0n2
ofpathname: Could not find sysfs information for logical
            device "/dev/nvme0n2".

# ofpathname /dev/nvme0n1p0
ofpathname: Could not find sysfs information for logical
            device "/dev/nvme0n1p0".

of2l_nvme()

Existing devices:

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0
ofpathname: Could not retrieve logical device name for
            Open Firmware path "/pci@80000002000001c/pci1014,4f5@0".

The case without a namespace ID (above) can not be handled
as there's not enough information available in the OpenFirmware
device path nor device-tree in order to match it uniquely to a
nvmeX device path.

Anything with a namespace ID (below) has enough information and works:

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1
nvme0n1

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1:1
nvme0n1p1

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1:2
nvme0n1p2

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1:3
nvme0n1p3

Non-existing devices:

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@0
ofpathname: Could not retrieve logical device name for
            Open Firmware path "/pci@80000002000001c/pci1014,4f5@0/namespace@0".

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1:0
ofpathname: Could not retrieve logical device name for
            Open Firmware path "/pci@80000002000001c/pci1014,4f5@0/namespace@1:0".

Thanks: Colleen Stouffer, for technical advice and hardware availability.

Mauricio Faria de Oliveira added 2 commits March 1, 2016 20:36
…vices

Add support to convert logical device path to Open firmware device path for NVMe devices.

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
…vices

Add support to convert a Open Firmware device path to logical device path for NVMe devices (with namespace id).

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
@mfoliveira
Copy link
Author

Hi Nathan,

Have you had a chance to check this one?
(BTW, I realize things are busy in other areas :-) )

Here's some more testing w/ 2 NVMe adapters in a system. All good.

OpenFirmware device-tree listing (2 NVMe adapters):

0 > ls
...
0000022216b0: /pci@80000002000001c
0000023330c8:   /pci1014,4f5@0
0000023422e0:     /namespace
00000222e568: /pci@80000002000001d
0000023481e0:   /pci1014,4f6@0
0000023573f8:     /namespace
...

Linux device listing (2 NVMe adapters, each w/ 1 namespace w/ 3 partitions)

# ls -1 /dev/nvme*
/dev/nvme0
/dev/nvme0n1
/dev/nvme0n1p1
/dev/nvme0n1p2
/dev/nvme0n1p3
/dev/nvme1
/dev/nvme1n1
/dev/nvme1n1p1
/dev/nvme1n1p2
/dev/nvme1n1p3

nvme_l2of()

# ofpathname /dev/nvme0
/pci@80000002000001c/pci1014,4f5@0
# ofpathname /dev/nvme0n1
/pci@80000002000001c/pci1014,4f5@0/namespace@1
# ofpathname /dev/nvme0n1p1
/pci@80000002000001c/pci1014,4f5@0/namespace@1:1
# ofpathname /dev/nvme0n1p2
/pci@80000002000001c/pci1014,4f5@0/namespace@1:2
# ofpathname /dev/nvme0n1p3
/pci@80000002000001c/pci1014,4f5@0/namespace@1:3

# ofpathname /dev/nvme1    
/pci@80000002000001d/pci1014,4f6@0
# ofpathname /dev/nvme1n1
/pci@80000002000001d/pci1014,4f6@0/namespace@1
# ofpathname /dev/nvme1n1p1
/pci@80000002000001d/pci1014,4f6@0/namespace@1:1
# ofpathname /dev/nvme1n1p2
/pci@80000002000001d/pci1014,4f6@0/namespace@1:2
# ofpathname /dev/nvme1n1p3
/pci@80000002000001d/pci1014,4f6@0/namespace@1:3

non-existing device nodes:

# ofpathname /dev/nvme2    
ofpathname: Could not find sysfs information for logical
        device "/dev/nvme2".
# ofpathname /dev/nvme0n2
ofpathname: Could not find sysfs information for logical
        device "/dev/nvme0n2".
# ofpathname /dev/nvme0n1p4
ofpathname: Could not find sysfs information for logical
        device "/dev/nvme0n1p4".

nvme_of2l():

note: as mentioned before, it's not possible to convert the
      non-namespace OF device path (not enough information)

# ofpathname -l /pci@80000002000001c/pci1014,4f5@0
ofpathname: Could not retrieve logical device name for
        Open Firmware path "/pci@80000002000001c/pci1014,4f5@0".
# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1
nvme0n1
# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1:1
nvme0n1p1
# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1:2
nvme0n1p2
# ofpathname -l /pci@80000002000001c/pci1014,4f5@0/namespace@1:3
nvme0n1p3

# ofpathname -l /pci@80000002000001d/pci1014,4f6@0
ofpathname: Could not retrieve logical device name for
        Open Firmware path "/pci@80000002000001d/pci1014,4f6@0".
# ofpathname -l /pci@80000002000001d/pci1014,4f6@0/namespace@1
nvme1n1
# ofpathname -l /pci@80000002000001d/pci1014,4f6@0/namespace@1:1
nvme1n1p1
# ofpathname -l /pci@80000002000001d/pci1014,4f6@0/namespace@1:2
nvme1n1p2
# ofpathname -l /pci@80000002000001d/pci1014,4f6@0/namespace@1:3
nvme1n1p3

non-existing devices:

# ofpathname -l /pci@80000002000001d/pci1014,4f6@0/namespace@2  
ofpathname: Could not retrieve logical device name for
        Open Firmware path "/pci@80000002000001d/pci1014,4f6@0/namespace@2".
# ofpathname -l /pci@80000002000001d/pci1014,4f6@0/namespace@1:4
ofpathname: Could not retrieve logical device name for
        Open Firmware path "/pci@80000002000001d/pci1014,4f6@0/namespace@1:4".

Test: OF boot-device set by grub-install:

# nvram --print-config=boot-device
/pci@800000020000015/pci1014,034A@0/sas/disk@5000c50067b12ab7

# grub-install /dev/nvme1n1p1 
Installing for powerpc-ieee1275 platform.
Installation finished. No error reported.

# nvram --print-config=boot-device
/pci@80000002000001d/pci1014,4f6@0/namespace@1

# grub-install /dev/nvme0n1p1 
Installing for powerpc-ieee1275 platform.
Installation finished. No error reported.

# nvram --print-config=boot-device
/pci@80000002000001c/pci1014,4f5@0/namespace@1

# reboot
...

0 > printenv boot-device 
-------------- Partition: common -------- Signature: 0x70 ---------------
boot-device              /pci@80000002000001c/pci1014,4f5@0/namespace@1 
 ok

0 > boot |
Elapsed time since release of system processors: 17157 mins 13 secs
...
                    GNU GRUB  version 2.02~beta2-36
...

Ubuntu Xenial Xerus (development branch) tul131p1 hvc0

tul131p1 login:

@nfont
Copy link
Contributor

nfont commented Mar 18, 2016

Hi Mauricio,

I added these patches to the -next branch, they will be merged into the master branch when I push out the next release.

-Nathan

@mfoliveira
Copy link
Author

Hi Nathan,

Okay, thanks!
On Mar 17, 2016 21:08, "Nathan Fontenot" notifications@github.com wrote:

Hi Mauricio,

I added these patches to the -next branch, they will be merged into the
master branch when I push out the next release.

-Nathan


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#3 (comment)

@nfont nfont closed this Mar 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants