intel / idxd-config

Accel-config / libaccel-config
Other
56 stars 35 forks source link

enabled/disabled query #25

Closed jurobystricky closed 1 year ago

jurobystricky commented 1 year ago

If you try to enable/disable a device or work queue which is already enabled or disabled, the call returns an error with a message. For example:

$ accel-config enable-device iax1
iax1 is in enabled state already, skipping...
failed in iax1
enabled 0 device(s) out of 1
$ echo $?
1

Is there any reason this is considered to be an an error? What is the proper way to query if the device/wq is already enabled/disabled in order to avoid such an error? How does one check if a device/wq is enabled/disabled (for example in a shell script) without actually parsing the accel-config output string?

ramesh-thomas commented 1 year ago

You can enable a range of devices or wqs. It will enable the devices and wqs that can be enabled and print the count of devices successfully enabled. If necessary, you can ignore the message, check the error and take actions as follows sudo accel-config enable-wq dsa0/wq0.0 dsa/wq0.1 2> /dev/null rc=$? if [ $rc -eq 0 ]; then Success actions else Failure actions fi

Alternatively, you can write your own app using the libaccel-config library and call the following APIs to check the state. enum accfg_device_state accfg_device_get_state(struct accfg_device device); enum accfg_wq_state accfg_wq_get_state(struct accfg_wq wq);