Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PCI addr in veth alias, fallback to scanning #42

Merged
merged 1 commit into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions conf/spgwu.bess
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,29 @@ class Port:
self.init_fastpath(**kwargs)

elif mode == 'dpdk':
# if port list is empty, scan for dpdk_ports first
if not dpdk_ports and scan_dpdk_ports() == False:
print('Registered dpdk ports do not exist.')
sys.exit()
# Initialize DPDK fastpath
fidx = dpdk_ports.get(mac_by_interface(name))
if fidx is None:
raise Exception('Registered port for {} not detected!'.format(name))
kwargs = {"port_id" : fidx, "num_out_q": workers}
self.init_fastpath( **kwargs)
kwargs = None
pci = alias_by_interface(name)
if pci is not None:
kwargs = {"pci": pci, "num_out_q": workers}
try:
self.init_fastpath(**kwargs)
except:
kwargs = None
print('Unable to initialize {} fastpath using alias {},\
falling back to scan'.format(name, pci))
if kwargs is None:
# Fallback to scanning ports
# if port list is empty, scan for dpdk_ports first
if not dpdk_ports and scan_dpdk_ports() == False:
print('Registered dpdk ports do not exist.')
sys.exit()
# Initialize DPDK fastpath
fidx = dpdk_ports.get(mac_by_interface(name))
if fidx is None:
raise Exception(
'Registered port for {} not detected!'.format(name))
kwargs = {"port_id": fidx, "num_out_q": workers}
self.init_fastpath(**kwargs)

# Initialize kernel slowpath port and RX/TX modules
try:
Expand Down
6 changes: 6 additions & 0 deletions conf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def getpythonpid(process_name):
return proc.info['pid']
return


def get_json_conf(path, dump):
conf = json.loads(open(path).read())
if dump:
Expand All @@ -55,6 +56,11 @@ def ips_by_interface(name):
return [ipobj[0] for ipobj in ipdb.interfaces[name]['ipaddr'].ipv4]


def alias_by_interface(name):
ipdb = IPDB()
return ipdb.interfaces[name]['ifalias']


def mac_by_interface(name):
ipdb = IPDB()
return ipdb.interfaces[name]['address']
Expand Down