diff options
| author | songyanchao <[email protected]> | 2023-03-27 09:42:19 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2023-03-27 09:42:19 +0000 |
| commit | 71b697019a3d52fac8577dc658d82faed04b2ed0 (patch) | |
| tree | 3f040eebffc4359b7f9affc93249e7f3218c81d7 | |
| parent | 311e7bd06f97d225792e6e61aeaf8eb79ec88251 (diff) | |
✨ feat(DPISDN-3): 修改 mrzcpd service 添加 dev unbind 流程v4.6.19-20230327
修改 mrzcpd service 添加 dev unbind 流程
| -rw-r--r-- | tools/devbind/devbind.py | 34 | ||||
| -rw-r--r-- | tools/systemd/mrzcpd.service.in | 3 |
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 |
