Best Python code snippet using lisa_python
dpdktestpmd.py
Source:dpdktestpmd.py  
...206        exclude_flags = ""207        for nic in exclude_nics:208            exclude_flags += f' -b "{nic.pci_slot}"'209        return vdev_info + exclude_flags210    def _calculate_core_count(211        self,212        cores_available: int,213        txq: int,214        rxq: int,215        use_max_nics: bool,216        service_cores: int = 1,217    ) -> int:218        # Use either:219        #   - as many cores as are available, minus a core for the system220        #   - 1 per queue on each nic + one per NIC PMD221        # this is a no-op for now,222        # test does not correctly handle multiple nics yet223        if use_max_nics:224            pass225        nics_available = 1226        return min(227            cores_available - 1,228            (nics_available * (txq + rxq)) + (nics_available * service_cores),229        )230    def generate_testpmd_command(231        self,232        nic_to_include: NicInfo,233        vdev_id: int,234        mode: str,235        pmd: str,236        extra_args: str = "",237        txq: int = 0,238        rxq: int = 0,239        service_cores: int = 1,240        use_max_nics: bool = False,241    ) -> str:242        #   testpmd \243        #   -l <core-list> \244        #   -n <num of mem channels> \245        #   -w <pci address of the device you plan to use> \246        #   --vdev="net_vdev_netvsc<id>,iface=<the iface to attach to>" \247        #   -- --port-topology=chained \248        #   --nb-cores <number of cores to use for test pmd> \249        #   --forward-mode=txonly \250        #   --eth-peer=<port id>,<receiver peer MAC address> \251        #   --stats-period <display interval in seconds>252        # if test asks for multicore, it implies using more than one nic253        # otherwise default core count for single nic will be used254        # and then adjusted for queue count255        if not (rxq or txq):256            txq = 1257            rxq = 1258        # calculate the available cores per numa node, infer the offset259        # required for core selection argument260        cores_available = self.node.tools[Lscpu].get_core_count()261        numa_node_count = self.node.tools[Lscpu].get_numa_node_count()262        nic_numa_node = self.node.nics._get_nic_numa_node(nic_to_include.lower)263        cores_per_numa = cores_available // numa_node_count264        numa_core_offset = cores_per_numa * nic_numa_node265        # calculate how many cores to use based on txq/rxq per nic and how many nics266        use_core_count = self._calculate_core_count(267            cores_per_numa, txq, rxq, use_max_nics, service_cores=service_cores268        )269        nic_include_info = self.generate_testpmd_include(270            nic_to_include, vdev_id, use_max_nics271        )272        # set up queue arguments273        if txq or rxq:274            # set number of queues to use for txq and rxq (per nic, default is 1)275            assert_that(txq).described_as(276                "TX queue value must be greater than 0 if txq is used"277            ).is_greater_than(0)278            assert_that(rxq).described_as(279                "RX queue value must be greater than 0 if rxq is used"280            ).is_greater_than(0)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
