Created
October 11, 2016 14:50
-
-
Save ctrautma/bb1a3442f89d358d5931778629c9851b to your computer and use it in GitHub Desktop.
PMD Mask creator for DPDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
print("PMD Mask calculator") | |
print("*******************\n\n") | |
numcores = input("How many cores in the system?") | |
if int(numcores) % 4 != 0: | |
print( | |
"No Support for core totals not being divisble by 4. Number of cores = {}".format( | |
numcores)) | |
sys.exit(1) | |
pmdlist = ' ' | |
while ' ' in pmdlist: | |
pmdlist = input( | |
"Which cores for PMDS? (use command separated list; ex: 5,7,9,11):") | |
if ' ' in pmdlist: | |
print("No spaces please") | |
pmdlist = pmdlist.split(',') | |
binstr = str() | |
for x in range(int(numcores)): | |
if str(x) in pmdlist: | |
binstr += '1' | |
else: | |
binstr += '0' | |
print("Binary string for PMD mask = {}".format(binstr)) | |
print("Converting to PMD mask") | |
pmdmask = str() | |
pointer = 4 | |
starter = 0 | |
while pointer <= len(binstr): | |
pmdmask += str(hex(int(binstr[starter:pointer][::-1], 2))).replace('0x', '') | |
starter += 4 | |
pointer += 4 | |
print("Use PMD Mask of {}".format(pmdmask)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment