mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
--- ./samples/hello_fpga.c.orig 2017-12-21 00:57:58.000000000 +0200
|
|
+++ ./samples/hello_fpga.c 2018-03-14 16:44:34.108462134 +0200
|
|
@@ -103,15 +103,19 @@
|
|
|
|
int opt;
|
|
int open_flags = 0;
|
|
+ long bus = 0;
|
|
|
|
/* Parse command line for exclusive or shared access */
|
|
- while ((opt = getopt(argc, argv, "s")) != -1) {
|
|
+ while ((opt = getopt(argc, argv, "b:s")) != -1) {
|
|
switch (opt) {
|
|
case 's':
|
|
open_flags |= FPGA_OPEN_SHARED;
|
|
break;
|
|
+ case 'b':
|
|
+ bus = (int)strtol(optarg, NULL, 0);
|
|
+ break;
|
|
default:
|
|
- printf("USAGE: %s [-s]\n", argv[0]);
|
|
+ printf("USAGE: %s [-s] [-b <bus>]\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
}
|
|
@@ -131,17 +135,24 @@
|
|
res = fpgaPropertiesSetGUID(filter, guid);
|
|
ON_ERR_GOTO(res, out_destroy_prop, "setting GUID");
|
|
|
|
+ if (bus) {
|
|
+ res = fpgaPropertiesSetBus(filter, bus);
|
|
+ ON_ERR_GOTO(res, out_destroy_prop, "setting bus");
|
|
+ }
|
|
+
|
|
/* TODO: Add selection via BDF / device ID */
|
|
|
|
res = fpgaEnumerate(&filter, 1, &accelerator_token, 1, &num_matches);
|
|
ON_ERR_GOTO(res, out_destroy_prop, "enumerating accelerators");
|
|
|
|
if (num_matches < 1) {
|
|
- fprintf(stderr, "accelerator not found.\n");
|
|
+ fprintf(stderr, "Error: accelerator not found.\n");
|
|
res = fpgaDestroyProperties(&filter);
|
|
return FPGA_INVALID_PARAM;
|
|
}
|
|
|
|
+ printf("Found %d accelerator[s]\n", num_matches);
|
|
+
|
|
/* Open accelerator and map MMIO */
|
|
res = fpgaOpen(accelerator_token, &accelerator_handle, open_flags);
|
|
ON_ERR_GOTO(res, out_destroy_tok, "opening accelerator");
|