MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dev_id_from_dev_name

Function dev_id_from_dev_name

dpdk/usertools/dpdk-devbind.py:304–322  ·  view source on GitHub ↗

Take a device "name" - a string passed in by user to identify a NIC device, and determine the device id - i.e. the domain:bus:slot.func - for it, which can then be used to index into the devices array

(dev_name)

Source from the content-addressed store, hash-verified

302
303
304def dev_id_from_dev_name(dev_name):
305 '''Take a device "name" - a string passed in by user to identify a NIC
306 device, and determine the device id - i.e. the domain:bus:slot.func - for
307 it, which can then be used to index into the devices array'''
308
309 # check if it's already a suitable index
310 if dev_name in devices:
311 return dev_name
312 # check if it's an index just missing the domain part
313 if "0000:" + dev_name in devices:
314 return "0000:" + dev_name
315
316 # check if it's an interface name, e.g. eth1
317 for d in devices.keys():
318 if dev_name in devices[d]["Interface"].split(","):
319 return devices[d]["Slot"]
320 # if nothing else matches - error
321 raise ValueError("Unknown device: %s. "
322 "Please specify device in \"bus:slot.func\" format" % dev_name)
323
324
325def unbind_one(dev_id, force):

Callers 1

bind_allFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected