diff --git a/docs/Install.md b/docs/Install.md index fdb1b40df..a98535576 100644 --- a/docs/Install.md +++ b/docs/Install.md @@ -18,9 +18,30 @@ Check System your Kernel version should be higher than 2.6.33. 3. Install dependencies + + Install the Linux Kernel headers package for your kernel version. ```sh sudo apt-get install build-essential linux-headers-$(uname -r) git ``` + If your distribution didn't come with Python or came with an earlier version, you will need to install Python 3 v3.4+. + + See if Python is already installed with + + ```sh + python3 --version + ``` + Install Python with your distribution's package manager (Note: the command and package name may vary). + + On Debian derivatives such as Ubuntu, use `apt`. Check the apt repository for the versions of Python available to you. Then, run the following command: + ```sh + sudo apt-get install python3 + ``` + + Verify that Python installed correctly with + ```sh + python3 --version + ``` + 4. Assure your kernel supports uio ```sh locate uio diff --git a/scripts/corehelper.py b/scripts/corehelper.py index dfb3c666c..edc115e75 100755 --- a/scripts/corehelper.py +++ b/scripts/corehelper.py @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 # openNetVM # https://github.com/sdnfv/openNetVM @@ -37,6 +37,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" Setup and display ONVM core list info """ + import sys import argparse import os @@ -56,77 +58,77 @@ This function reads the /proc/cpuinfo file and determines the CPU architecture which will be used to determine corelists for each openNetVM NF and the manager. -From Intel DPDK tools/cpu_layout.py +From Intel DPDK usertools/cpu_layout.py """ def dpdk_cpu_info(): - global core_map - global cores - global core_map - - fd=open("/proc/cpuinfo") - lines = fd.readlines() - fd.close() - - core_details = [] - core_lines = {} - for line in lines: - if len(line.strip()) != 0: - name, value = line.split(":", 1) - core_lines[name.strip()] = value.strip() - else: - core_details.append(core_lines) - core_lines = {} - - for core in core_details: - for field in ["processor", "core id", "physical id"]: - if field not in core: - print "Error getting '%s' value from /proc/cpuinfo" % field - sys.exit(1) - core[field] = int(core[field]) - - if core["core id"] not in cores: - cores.append(core["core id"]) - if core["physical id"] not in sockets: - sockets.append(core["physical id"]) - key = (core["physical id"], core["core id"]) - if key not in core_map: - core_map[key] = [] - core_map[key].append(core["processor"]) + global core_map + global cores + global core_map + + fd=open("/proc/cpuinfo") + lines = fd.readlines() + fd.close() + + core_details = [] + core_lines = {} + for line in lines: + if len(line.strip()) != 0: + name, value = line.split(":", 1) + core_lines[name.strip()] = value.strip() + else: + core_details.append(core_lines) + core_lines = {} + + for core in core_details: + for field in ["processor", "core id", "physical id"]: + if field not in core: + print("Error getting '%s' value from /proc/cpuinfo" % field) + sys.exit(1) + core[field] = int(core[field]) + + if core["core id"] not in cores: + cores.append(core["core id"]) + if core["physical id"] not in sockets: + sockets.append(core["physical id"]) + key = (core["physical id"], core["core id"]) + if key not in core_map: + core_map[key] = [] + core_map[key].append(core["processor"]) """ Print out CPU architecture info. -From Intel DPDK tools/cpu_layout.py +From Intel DPDK usertools/cpu_layout.py """ def dpdk_cpu_info_print(): - global core_map - global cores - global core_map - - max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1)) - max_core_map_len = max_processor_len * 2 + len('[, ]') + len('Socket ') - max_core_id_len = len(str(max(cores))) - - print "" - print "============================================================" - print "Core and Socket Information (as reported by '/proc/cpuinfo')" - print "============================================================\n" - print "cores = ",cores - print "sockets = ", sockets - print "" - print " ".ljust(max_core_id_len + len('Core ')), - for s in sockets: - print "Socket %s" % str(s).ljust(max_core_map_len - len('Socket ')), - print "" - print " ".ljust(max_core_id_len + len('Core ')), - for s in sockets: - print "--------".ljust(max_core_map_len), - print "" - - for c in cores: - print "Core %s" % str(c).ljust(max_core_id_len), - for s in sockets: - print str(core_map[(s,c)]).ljust(max_core_map_len), - print "\n" + global core_map + global cores + global core_map + + max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1)) + max_core_map_len = max_processor_len * 2 + len('[, ]') + len('Socket ') + max_core_id_len = len(str(max(cores))) + + print("") + print("============================================================") + print("Core and Socket Information (as reported by '/proc/cpuinfo')") + print("============================================================\n") + print("cores = ",cores) + print("sockets = ", sockets) + print("") + print(" ".ljust(max_core_id_len + len('Core '))) + for s in sockets: + print("Socket %s" % str(s).ljust(max_core_map_len - len('Socket '))) + print("") + print(" ".ljust(max_core_id_len + len('Core '))) + for s in sockets: + print("--------".ljust(max_core_map_len)) + print("") + + for c in cores: + print("Core %s" % str(c).ljust(max_core_id_len)) + for s in sockets: + print(str(core_map[(s,c)]).ljust(max_core_map_len)) + print("\n") ### End Intel DPDK Codeblock ### @@ -135,141 +137,141 @@ def dpdk_cpu_info_print(): the corelists for each openNetVM process: the manager and each NF. """ def onvm_corelist(): - global core_map - global cores - global core_map - global onvm_mgr_corelist - global onvm_nfs_corelist + global core_map + global cores + global core_map + global onvm_mgr_corelist + global onvm_nfs_corelist - core_index = 0 - total_cores = len(cores) + core_index = 0 + total_cores = len(cores) # Run calculations for openNetVM corelists # ONVM Manager defaults to three threads 1x RX, 1x TX, 1x stat - while core_index < ONVM_CONST_MGR_THRD: - core = core_map.get((0, core_index), None) - if core is None: - print "Not enough cores: onvm requires {} to run manager. (You have {})".format(ONVM_CONST_MGR_THRD, len(core_map)) - exit(1) - onvm_mgr_corelist.append(core) - core_index += 1 + while core_index < ONVM_CONST_MGR_THRD: + core = core_map.get((0, core_index), None) + if core is None: + print("Not enough cores: onvm requires {} to run manager. (You have {})".format(ONVM_CONST_MGR_THRD, len(core_map))) + sys.exit(1) + onvm_mgr_corelist.append(core) + core_index += 1 - while core_index < total_cores: - onvm_nfs_corelist.append(core_map[(0, cores[core_index])]) - core_index += 1 + while core_index < total_cores: + onvm_nfs_corelist.append(core_map[(0, cores[core_index])]) + core_index += 1 """ Reads the output of lscpu to determine if hyperthreading is enabled. """ def onvm_ht_isEnabled(): - lscpu_output = os.popen('lscpu -p').readlines() - for line in lscpu_output: - try: - line_csv = line.split(',') - phys_core = int(line_csv[0]) - logical_core = int(line_csv[1]) - if phys_core != logical_core: - return True - except ValueError: - pass - - return False + lscpu_output = os.popen('lscpu -p').readlines() + for line in lscpu_output: + try: + line_csv = line.split(',') + phys_core = int(line_csv[0]) + logical_core = int(line_csv[1]) + if phys_core != logical_core: + return True + except ValueError: + pass + + return False """ Print out openNetVM corelist info """ def onvm_corelist_print(): - global onvm_mgr_corelist - global onvm_nfs_corelist - - onvm_print_header() - - if onvm_ht_isEnabled(): - print "This script only works if hyperthreading is disabled." - print "Run no_hyperthread.sh to disable hyperthreading before " - print "running this script again." - print "" - exit(1) - - print "** MAKE SURE HYPERTHREADING IS DISABLED **" - print "" - print "openNetVM requires at least three cores for the manager:" - print "one for NIC RX, one for statistics, and one for NIC TX." - print "For rates beyond 10Gbps it may be necessary to run multiple TX" - print "or RX threads." - print "" - print "Each NF running on openNetVM needs its own core too." - print "" - - print "Use the following information to run openNetVM on this system:" - print "" - - mgr_corelist="" - for c in onvm_mgr_corelist: - for i in c: - mgr_corelist += "%s," %(i) - print "\t- openNetVM Manager corelist: %s" %(mgr_corelist[:len(mgr_corelist)-1]) - - print "" - - print "\t- openNetVM can handle %d NFs on this system" %(len(onvm_nfs_corelist)) - - for i, cores in enumerate(onvm_nfs_corelist, 1): - print "\t\t- NF %d:" %(i), - for c in cores: - print "%s" %(c) + global onvm_mgr_corelist + global onvm_nfs_corelist + + onvm_print_header() + + if onvm_ht_isEnabled(): + print("This script only works if hyperthreading is disabled.") + print("Run no_hyperthread.sh to disable hyperthreading before ") + print("running this script again.") + print("") + sys.exit(1) + + print("** MAKE SURE HYPERTHREADING IS DISABLED **") + print("") + print("openNetVM requires at least three cores for the manager:") + print("one for NIC RX, one for statistics, and one for NIC TX.") + print("For rates beyond 10Gbps it may be necessary to run multiple TX") + print("or RX threads.") + print("") + print("Each NF running on openNetVM needs its own core too.") + print("") + + print("Use the following information to run openNetVM on this system:") + print("") + + mgr_corelist="" + for c in onvm_mgr_corelist: + for i in c: + mgr_corelist += "%s," %(i) + print("\t- openNetVM Manager corelist: %s" %(mgr_corelist[:len(mgr_corelist)-1])) + + print("") + + print("\t- openNetVM can handle %d NFs on this system" %(len(onvm_nfs_corelist))) + + for i, cores in enumerate(onvm_nfs_corelist, 1): + print("\t\t- NF %d:" %i) + for c in cores: + print("%s" %(c)) def onvm_print_header(): - print "===============================================================" - print "\t\t openNetVM CPU Corelist Helper" - print "===============================================================" - print "" + print("===============================================================") + print("\t\t openNetVM CPU Corelist Helper") + print("===============================================================") + print("") """ Function contains program execution sequence """ def run(): - if args.all: - dpdk_cpu_info() - onvm_corelist() - dpdk_cpu_info_print() - onvm_corelist_print() - elif args.onvm: - dpdk_cpu_info() - onvm_corelist() - onvm_corelist_print() - elif args.cpu: - dpdk_cpu_info() - dpdk_cpu_info_print() - else: - print "You supplied 0 arguments, running with flag --onvm" - print "" - - dpdk_cpu_info() - onvm_corelist() - onvm_corelist_print() + if args.all: + dpdk_cpu_info() + onvm_corelist() + dpdk_cpu_info_print() + onvm_corelist_print() + elif args.onvm: + dpdk_cpu_info() + onvm_corelist() + onvm_corelist_print() + elif args.cpu: + dpdk_cpu_info() + dpdk_cpu_info_print() + else: + print("You supplied 0 arguments, running with flag --onvm") + print("") + + dpdk_cpu_info() + onvm_corelist() + onvm_corelist_print() if __name__ == "__main__": ### Set up arg parsing - parser = argparse.ArgumentParser(description='openNetVM corelist helper script') - - parser.add_argument("-o", "--onvm", - action="store_true", - help="[Default option] Display openNetVM corelist information.") - parser.add_argument("-c", "--cpu", - action="store_true", - help="Display CPU architecture only.") - parser.add_argument("-a", "--all", - action="store_true", - help="Display all CPU information.") - parser.add_argument("-v", "--verbose", - action="store_true", - help="Verbose mode displays detailed corelist info.") - - args = parser.parse_args() + parser = argparse.ArgumentParser(description='openNetVM corelist helper script') + + parser.add_argument("-o", "--onvm", + action="store_true", + help="[Default option] Display openNetVM corelist information.") + parser.add_argument("-c", "--cpu", + action="store_true", + help="Display CPU architecture only.") + parser.add_argument("-a", "--all", + action="store_true", + help="Display all CPU information.") + parser.add_argument("-v", "--verbose", + action="store_true", + help="Verbose mode displays detailed corelist info.") + + args = parser.parse_args() # Function call to run program - run() + run() \ No newline at end of file diff --git a/scripts/csv-analysis.py b/scripts/csv-analysis.py index 8ce4c30b1..d89e420ba 100644 --- a/scripts/csv-analysis.py +++ b/scripts/csv-analysis.py @@ -1,4 +1,5 @@ -#!/usr/bin/python +#!/usr/bin/python3 +""" Analyze and convert packet data into .csv file """ import sys import os.path @@ -9,15 +10,15 @@ def main(): if len(sys.argv) != 2: - print "Invalid number of arguments!" - print USAGE_INFO + print("Invalid number of arguments!") + print(USAGE_INFO) sys.exit(-1) file_name = sys.argv[1] if not(os.path.isfile(file_name)): - print "Invalid file path!" - print USAGE_INFO + print("Invalid file path!") + print(USAGE_INFO) sys.exit(-1) data_table = parse_data(file_name) @@ -31,24 +32,24 @@ def main(): def print_output(analyses): for a in analyses: - print a["label"] - print "-------------------------" - print "Packet Data (pps)" - print "Min: " + str(a["min"]) - print "Max: " + str(a["max"]) - print "Avg: " + str(a["avg"]) - print "Median: " + str(a["median"]) - - print "" - - print "Time Data (seconds)" - print "Start Time: " + str(a["start"]) + print(a["label"]) + print("-------------------------") + print("Packet Data (pps)") + print("Min: " + str(a["min"])) + print("Max: " + str(a["max"])) + print("Avg: " + str(a["avg"])) + print("Median: " + str(a["median"])) + + print("") + + print("Time Data (seconds)") + print("Start Time: " + str(a["start"])) if(a["end"] != -1): - print "End Time: " + str(a["end"]) + print("End Time: " + str(a["end"])) else: - print "End Time: Does not end!" + print("End Time: Does not end!") - print "" + print("") def analyze_data(info, label): data = info["data"]