summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/devbind/devbind.py34
-rw-r--r--tools/systemd/mrzcpd.service.in3
2 files changed, 30 insertions, 7 deletions
diff --git a/tools/devbind/devbind.py b/tools/devbind/devbind.py
index 62d4a5b..c0ec822 100644
--- a/tools/devbind/devbind.py
+++ b/tools/devbind/devbind.py
@@ -26,7 +26,12 @@ def init():
with open("/etc/sysconfig/mrzcpd", 'r') as drive_fp:
for line in drive_fp.readlines():
if re.search("DEFAULT_UIO_MODULE=*", line):
- dpdk_driver = line.split('DEFAULT_UIO_MODULE=')[1]
+ str_driver = line.split('DEFAULT_UIO_MODULE=')[1]
+ match = re.search(r'"(.*?)"', str_driver)
+ if match:
+ dpdk_driver = match.group(1)
+ if match.group(1) == "vfio_pci".strip():
+ dpdk_driver = "vfio-pci"
if re.search("MRZCPD_ROOT=*", line):
mrzcpd_root = line.split('MRZCPD_ROOT=')[1]
@@ -79,18 +84,35 @@ def nic_bind():
for d in interfaces:
if d in hwinfo and hwinfo.get(d).get('driver') != 'mlx5_core':
bind_cmd = dpdk_bind + ' --bind=' + \
- dpdk_driver.replace("\n", " ") + hwinfo.get(d).get('pci')
+ dpdk_driver + " " + hwinfo.get(d).get('pci')
print("bind cmd:", bind_cmd)
if os.system(bind_cmd):
print("bind dev err")
sys.exit(1)
+def nic_unbind():
+ for d in interfaces:
+ if d in hwinfo and hwinfo.get(d).get('driver') != 'mlx5_core':
+ dpdk_driver_unbind = hwinfo.get(d).get('driver')
+ unbind_cmd = dpdk_bind + ' --bind=' + \
+ dpdk_driver_unbind + " " + hwinfo.get(d).get('pci')
+ print("unbind cmd:", unbind_cmd)
+ if os.system(unbind_cmd):
+ print("unbind dev err")
+ sys.exit(1)
+
+
def main():
- # module load
- module_load()
- # bind dev
- nic_bind()
+ args = sys.argv
+ if args[1] == "bind":
+ # module load
+ module_load()
+ # bind dev
+ nic_bind()
+ elif args[1] == "unbind":
+ # unbind dev
+ nic_unbind()
if __name__ == "__main__":
diff --git a/tools/systemd/mrzcpd.service.in b/tools/systemd/mrzcpd.service.in
index 2521991..c840394 100644
--- a/tools/systemd/mrzcpd.service.in
+++ b/tools/systemd/mrzcpd.service.in
@@ -7,12 +7,13 @@ After=mrzcpd-hugepages-setup.service mrzcpd-hwdb-setup.service k3s.service
Environment=SYSTEMD_LOG_LEVEL=debug
Environment=MLX5_GLUE_PATH=@MR_INSTALL_LIBDIR@
EnvironmentFile=/etc/sysconfig/mrzcpd
-ExecStartPre=python3 @MR_INSTALL_BINDIR@/devbind.py
+ExecStartPre=python3 @MR_INSTALL_BINDIR@/devbind.py bind
ExecStart=@MR_INSTALL_BINDIR@/mrzcpd -c @MR_INSTALL_SYSCONFDIR@/mrglobal.conf
ExecStopPost=/bin/bash -c 'rm -f /run/mrzcpd/huge_pages/rtemap_*'
ExecStopPost=/usr/bin/rm -f /run/.rte_config
ExecStopPost=/usr/bin/rm -f /run/.rte_hugepage_info
ExecStopPost=/usr/bin/rm -rf /run/.dpdk
+ExecStopPost=python3 @MR_INSTALL_BINDIR@/devbind.py unbind
Restart=always
RestartSec=5s