Commit Graph

26 Commits

Author SHA1 Message Date
Dmitry Rozhkov
70f862f2aa add golangci linter
In this initial commit the following checks are disabled due to
excessive amount of changes required:
- dupl (duplicate code)
- funlen (function length)
- goerr113 (errors handling expressions)
- gomnd (magic numbers)
- gosec (security)
- nakedret (naked returns)
- wsl (forces to use empty lines)
- errcheck (checking for unchecked errors)
- staticcheck (static analysis)
2020-06-08 14:01:13 +03:00
Ed Bartosh
a668c596b2 fpga_crihook: improve unit tests
- increased test coverage to 91.4%
- cleaned up the code
- removed unused test data

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2020-03-31 11:57:06 +03:00
Graham Whaley
71d08224ee fpga: move to using klog for logs and debug
Move all the fpga components to using klog for logging
and debug. This includes replacing our homebrew 'fatal()'
with klog.Error().

Modify the deployment files to move from `-debug` to
`-v`, and set their default level to '1' (Info), rather
than full debug mode ('4').

Signed-off-by: Graham Whaley <graham.whaley@intel.com>
2020-03-24 14:31:53 +00:00
Dmitry Rozhkov
456c8f3ff1 fpga: fix stutter reported by golint 2020-01-30 15:17:27 +02:00
Dmitry Rozhkov
7695e450de fpga_crihook: remove unused struct field 2020-01-29 17:17:06 +02:00
Dmitry Rozhkov
3a845cfe15 fpga: rename files to make them linux-only 2020-01-29 17:17:06 +02:00
Ed Bartosh
57b4927eda crihook: simplified NewHookEnv signature 2019-09-16 12:56:35 +03:00
Ed Bartosh
8d21aff5ac crihook: removed unused field 2019-09-16 12:51:50 +03:00
Ed Bartosh
73ac87cd8d crihook; fix forgotten error check 2019-09-16 12:50:29 +03:00
Ed Bartosh
a6b3a217e8 crihook: fix ineffective Errorf call
Returned error instead of calling errors.Errorf with no effect.
2019-09-16 12:49:26 +03:00
Alexander Kanevskiy
71bb38f496 Implemented native FPGA flashing
Removed dependency to OPAE libraries
2019-08-25 02:37:01 +03:00
Ed Bartosh
de9df8373e fpga_plugin: support in-tree kernel driver
Extended fpga plugin to support both in-tree(DFL) and
out-of-tree (OPAE) kernel drivers.

- fpga_crihook: move JSON parsing to separate functions
- decreased cyclomatic complexity of the CRI hook main() function
- increased readability
- increased test coverage

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2019-08-24 18:27:15 +03:00
Alexander Kanevskiy
186ec6613c FPGA: migrate to ClearLinux environment
- Migrate to OPAE 1.3.2
- Build all the tools from the source
- ignore files in workspace
- minimal fpga_tool utility to check gbs/aocx file parsing and flashing
- implemented kernel IOCTL based flashing of bitstreams
- add PCI and sysfs functions
2019-08-24 02:55:19 +03:00
Alexander Kanevskiy
4dc19851ee Pass correct PCI bus/device/function to fpgaconf
Partially helps with #148
2019-05-29 16:08:52 +03:00
Dmitry Rozhkov
06487dcded crihook: do program multiple devices at once 2018-10-04 10:19:23 +03:00
Dmitry Rozhkov
dc21749a83 crihook: optimize regexp application 2018-10-04 10:19:23 +03:00
Ed Bartosh
44fd8aef54 fpga_crihook: use -s fpgaconf option
Different versions of OPAE tool fpgaconf use different command line
options to specify socket number. Latest version uses -S, which CRI-O
hook used so far.

However, fpgaconf in initcontainer comes from older OPAE version, which
uses -s option for the same purpose. This caused fpgaconf and CRI-O hook
to fail with "Invalid cmdline options".

Used 'fpgaconf-wrapper -s' in the CRI-O hook to fix this.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2018-09-05 15:33:42 +03:00
Ed Bartosh
79a0928646 fpga_crihook: use tools installed by initcontainer
intel-fpga-initcontainer installs OPAE and OpenCL tools
into /opt/intel/fpga-sw directory.

Used fpgaconf-wrapper, aocl-wrapper and packager tools by
CRI hook to program OPAE and OpenCL bitstreams.

Added support for OpenCL bitstreams: the hook tries to find
either OPAE or OpenCL bitstream suitable for requested region
and AFU and programs it using OPAE or OpenCL tools.

Fixes #71
2018-09-04 17:18:36 +03:00
Dmitry Rozhkov
2ff6c5929a Use annotated errors for tracing 2018-08-16 17:31:19 +03:00
Alexander D. Kanevskiy
2a6eda891a
Merge pull request #68 from bart0sh/PR0030-fix-annotation-value
fpga_crihook: fix annotation value
2018-08-08 01:18:18 +03:00
Ed Bartosh
9de82c819f fpga_crihook: fix annotation value
Annotation value has been changed in FPGA plugin code recently.
Updated fpga_crihook to use the same value.
2018-08-07 17:40:16 +03:00
Ed Bartosh
71e8ea471a fpga_crihook: specify socket number when programming device
Added -S <device number> parameter to fpgaconf command line to
ensure usage of allocated device.
2018-08-07 17:32:59 +03:00
Ed Bartosh
b1b2edf1b8 fpga_crihook: check if requested AF is programmed
Check if programmed AF id is equal to the requested AF id
after re-programming a device.
2018-07-18 12:27:45 +03:00
Ed Bartosh
9df1afdf43 fpga_crihook: check if intel annotation is set
Check if container annotation com.intel.fpga.mode is set to
"intel.com/fpga-region". This annotation is set by device plugin.
So, the check should help to filter out unwanted workflow that
device plugin is not aware of.
2018-07-16 16:12:59 +03:00
Ed Bartosh
2f9debe35b fpga_crihook: check if bitstream is already programmed
FPGA device can be already programmed with requested bitstream.
In this case hook should not programm the device again.
2018-07-13 14:16:27 +03:00
Ed Bartosh
b4476110f8 implement CRI prestart hook
The hook gets FPGA_REGION and FPGA_BITSTREAM environment variables
defined in a pod spec, finds bitstream file, verifies it and programs
FPGA device with it using fpga-configure tool from OPAE.
2018-07-05 13:49:09 +03:00