Adding QAT support 52/74052/1
authorLuc Provoost <luc.provoost@gmail.com>
Mon, 26 Jun 2023 12:13:54 +0000 (14:13 +0200)
committerLuc Provoost <luc.provoost@gmail.com>
Mon, 26 Jun 2023 12:13:54 +0000 (14:13 +0200)
When qat devices are assigned to a pod, the code will now detect that
through the qat entry in the env of the pod. The qat devices will be
added to the PDK eal command line so they can by PROX.
For the PCI network devices, we only search for PCIDEVICE instead of
PCIDEVICE_INTEL_COM.

Signed-off-by: Luc Provoost <luc.provoost@gmail.com>
Change-Id: Ic801d20adac4a29e6c44e542121686f42778d61a

VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py
VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_pod.py
VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py
VNFs/DPPD-PROX/helper-scripts/rapid/start.sh

index 74f3a04..1d1112f 100644 (file)
@@ -176,6 +176,7 @@ class K8sDeployment:
         for pod in self._pods:
             pod.set_ssh_credentials(K8sDeployment.SSH_USER, K8sDeployment.SSH_PRIVATE_KEY)
             pod.get_sriov_dev_mac()
+            pod.get_qat_dev()
 
     def save_runtime_config(self, config_file_name):
         self._log.info("Saving config %s for runrapid script...",
@@ -212,6 +213,10 @@ class K8sDeployment:
                                      "dp_mac1", pod.get_dp_mac())
             self._runtime_config.set("M%d" % pod.get_id(),
                                      "dp_pci_dev", pod.get_dp_pci_dev())
+            if (pod.get_qat_pci_dev()):
+                for qat_index, qat_device in enumerate(pod.get_qat_pci_dev()):
+                    self._runtime_config.set("M%d" % pod.get_id(),
+                                           "qat_pci_dev%d" % qat_index, qat_device)
             self._runtime_config.set("M%d" % pod.get_id(),
                                      "dp_ip1", pod.get_dp_ip() + "/" +
                                      pod.get_dp_subnet())
index 8ddff3b..beaedd6 100644 (file)
@@ -50,6 +50,7 @@ class Pod:
         self._name = name
         self._namespace = namespace
         self._ssh_client = SSHClient(logger_name = logger_name)
+        self.qat_vf = []
 
     def __del__(self):
         """Destroy POD. Do a cleanup.
@@ -142,6 +143,9 @@ class Pod:
     def get_dp_pci_dev(self):
         return self._sriov_vf
 
+    def get_qat_pci_dev(self):
+        return self.qat_vf
+
     def get_id(self):
         return self._id
 
@@ -157,6 +161,28 @@ class Pod:
         self._last_status = pod.status.phase
         return self._last_status
 
+    def get_qat_dev(self):
+        """Get qat devices if any, assigned by k8s QAT device plugin.
+        """
+        self._log.info("Checking assigned QAT VF for POD %s" % self._name)
+        ret = self._ssh_client.run_cmd("cat /opt/rapid/k8s_qat_device_plugin_envs")
+        if ret != 0:
+            self._log.error("Failed to check assigned QAT VF!"
+                            "Error %s" % self._ssh_client.get_error())
+            return -1
+
+        cmd_output = self._ssh_client.get_output().decode("utf-8").rstrip()
+
+        if cmd_output:
+            self._log.debug("Before: Using QAT VF %s" % self.qat_vf)
+            self._log.debug("Environment variable %s" % cmd_output)
+            for line in cmd_output.splitlines():
+                self.qat_vf.append(line.split("=")[1])
+            self._log.debug("Using QAT VF %s" % self.qat_vf)
+        else:
+            self._log.debug("No QAT devices for this pod")
+            self.qat_vf = None
+
     def get_sriov_dev_mac(self):
         """Get assigned by k8s SRIOV network device plugin SRIOV VF devices.
         Return 0 in case of sucessfull configuration.
index 5430d2e..9f0a069 100644 (file)
@@ -160,6 +160,16 @@ class RapidMachine(object):
                 eal_line = 'eal=\"--file-prefix {}{} --{} {} --force-max-simd-bitwidth=512'.format(
                         self.name, str(uuid.uuid4()), allow_parameter,
                         self.machine_params['dp_pci_dev'])
+                looking_for_qat = True
+                index = 0
+                while (looking_for_qat):
+                    if  'qat_pci_dev{}'.format(index) in self.machine_params:
+                        eal_line += ' --{} {}'.format(allow_parameter,
+                            self.machine_params['qat_pci_dev{}'.format(index)])
+                        index += 1
+                    else:
+                        looking_for_qat = False
+                        eal_line += '"\n'
                 LuaFile.write(eal_line)
             else:
                 LuaFile.write("eal=\"\"\n")
index 0ff7d9b..78772dd 100755 (executable)
@@ -17,7 +17,8 @@
 
 function save_k8s_envs()
 {
-       printenv | grep "PCIDEVICE_INTEL_COM" > /opt/rapid/k8s_sriov_device_plugin_envs
+       printenv | grep "PCIDEVICE" > /opt/rapid/k8s_sriov_device_plugin_envs
+       printenv | grep "QAT[0-9]" > /opt/rapid/k8s_qat_device_plugin_envs
 }
 
 function create_tun()