Skip to content

Commit

Permalink
Adding support for nvme splitter in pci_hotplug.py
Browse files Browse the repository at this point in the history
nvme splitter location codes(slot numbers) are slightly different.
They ends with R1/R2 values hence the script is failing.
So added a method that handles to get the right slots numbers.

Signed-off-by: Naresh Bannoth <nbannoth@in.ibm.com>
  • Loading branch information
Naresh-ibm committed Nov 12, 2024
1 parent 1ff3f35 commit 6a56b96
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion io/pci/pci_hotplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from avocado import Test
from avocado.utils import cpu
from avocado.utils import nvme
from avocado.utils import process
from avocado.utils import wait, multipath
from avocado.utils import linux_modules, genio, pci
from avocado.utils.software_manager.manager import SoftwareManager
Expand Down Expand Up @@ -63,6 +64,7 @@ def setUp(self):
self.device = self.params.get('pci_devices', default="")
self.peer_ip = self.params.get('peer_ip', default="")
self.count = int(self.params.get('count', default='1'))
self.adaptertype = self.params.get('adapter_type', default="None")
if not self.device:
self.cancel("PCI_address not given")
self.device = self.device.split(" ")
Expand All @@ -73,10 +75,14 @@ def setUp(self):
for pci_addr in self.device:
if not os.path.isdir('/sys/bus/pci/devices/%s' % pci_addr):
self.cancel("%s not present in device path" % pci_addr)
slot = pci.get_slot_from_sysfs(pci_addr)
if self.adaptertype == "nvme_splitter":
slot = self.nvme_splitter_slot(pci_addr)
else:
slot = pci.get_slot_from_sysfs(pci_addr)
if not slot:
self.cancel("slot number not available for: %s" % pci_addr)
self.dic[pci_addr] = slot
self.log.info(f"Final pci_adress and respective slots {self.dic}")
self.adapter_type = pci.get_pci_class_name(self.device[0])
if self.adapter_type == 'nvme':
self.contr_name = nvme.get_controller_name(self.device[0])
Expand Down Expand Up @@ -119,6 +125,21 @@ def is_removed():

return wait.wait_for(is_removed, timeout=10) or False

def nvme_splitter_slot(self, pci_addrs):
"""
Returs the physical slot of a nvme splitter drive
:param pci_addrs: pci_adress of the drive
:rtype: string
"""
process.run("drmgr -c pci", ignore_status=True, shell=False)
cmd = "lsslot -c pci"
out = process.getoutput(cmd, ignore_status=True)
for line in out.splitlines():
if pci_addrs in line:
return str(line.split(" ")[0].strip())
return None

def hotplug_add(self, slot, pci_addr):
"""
Hot plug add operation and recovery check
Expand Down
2 changes: 2 additions & 0 deletions io/pci/pci_hotplug.py.data/pci_hotplug.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pci_devices: ""
count: 10
#This option is for nvme splitter adapter, Value: nvme_splitter
adapter_type: ""
peer_ip:

0 comments on commit 6a56b96

Please sign in to comment.