Commit Graph

33 Commits

Author SHA1 Message Date
Andreea Florescu
f1c4742e71 [i2c] reworked the abstractions
The I2cAdapterTrait was introduced because of a need to test the i2c
implementation without having access to a physical device on the host
running the tests. This abstraction though still made the tests pretty
hard to write, so it is now replaced by another abstractions: I2cDevice.

This abstraction is written working backwards from what we DO NOT have
access to on the host where we want to run the tests. This is the i2c
device. So, this abstraction is just abstracting the way all the ioctl
calls that need to be handled by an i2c device. This way, we can test
all the other wrappers that are implemented in this crate.

The abstraction is implemented for a physical device to keep backwards
compatibility with existing code.

This abstraction still needs improvements such as marking the functions
as unsafe. For now the tests are commented out because they need to be
re-written with this abstraction. Since we still have refactoring work
to do (i.e. separate the parsing from the device operation), writing
tests is postponed so that it does not involve duplicated work.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-09-15 17:34:00 +03:00
Andreea Florescu
683869411e [i2c] remove get_func from I2cAdapter trait
This function does not need to be in the trait. Having it as a public
function also makes the code hard to use because the return of the
`is_smbus` function is only valid after an initial call to `get_func`.

To get rid of this behavior, we can make the `get_func` a private
function in the `I2cAdapter` implementation, and call this function on
`new`.

The function was renamed to `read_func` to make the name more "mutable"
compatible (the function needs a mutable reference, but it was called
`get`; get functions don't typically need mutable references).

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-09-15 16:17:10 +03:00
Andreea Florescu
1a9b9e3fd6 [i2c] separate imports
We've typically separated imports in 3 categories:
- Rust standard library
- external crates
- project internal imports (such as imports from user defined modules)

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-09-15 15:21:30 +03:00
Andreea Florescu
850cbce112 [i2c] rename bus to adapter_no
This seems to be the way that it is defined & used in other examples
written for i2c.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-09-15 15:18:16 +03:00
Andreea Florescu
77aa88dc77 [i2c] move parsing of bus id outside of trait impl
This is a first change in a series meant for moving all the parsing of
strings in a single place, with the goal of separating parsing from the
device operation. This helps with separating concerns, mocking, and
writing unit tests.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-09-15 15:04:08 +03:00
Viresh Kumar
c5e90cfee9 i2c: Add tests to cover basic backend operations
This still doesn't emulate the descriptors and descriptor chains over
the vrings. That will be added later.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-14 11:00:56 +03:00
Viresh Kumar
cd23ce7502 i2c: Separate out start_daemon() and remove dryrun
Separate out daemon's handling and remove the ugly dryrun parameter.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-14 11:00:56 +03:00
Viresh Kumar
f7c76ad25a i2c: Upgrade to new version of backend
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-14 11:00:56 +03:00
Jiang Liu
119cd6f2f1
Merge pull request #20 from vireshk/dependabot-update
dependabot: Allow updating crate dependencies automatically
2021-09-08 15:30:41 +08:00
Viresh Kumar
67e2a7e15e
Merge branch 'main' into dependabot-update 2021-09-07 08:54:58 +05:30
Viresh Kumar
b150b8011d
Merge pull request #19 from rust-vmm/dependabot/submodules/rust-vmm-ci-ae7db2d
build(deps): bump rust-vmm-ci from `1311bfa` to `ae7db2d`
2021-09-07 08:54:41 +05:30
Viresh Kumar
620dd5fd01 dependabot: Allow updating dependencies
Remove the incorrect file dependabot.yaml and edit the correct one to
allow crate updates on weekly basis.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-06 12:54:53 +05:30
dependabot[bot]
025977bf6c
build(deps): bump rust-vmm-ci from 1311bfa to ae7db2d
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `1311bfa` to `ae7db2d`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](1311bfa03f...ae7db2d98a)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-06 06:57:46 +00:00
Viresh Kumar
28bb62a9c7
Merge pull request #16 from vireshk/i2c-breakage
i2c: Fix dependency to a working commit of backend
2021-09-06 12:27:02 +05:30
Viresh Kumar
b91f074ae5 i2c: Fix dependency to a working commit of backend
To avoid breaking the crate with a newer version of the
vhost-user-backend crate, fix the dependency to a known good version of
the crate.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-03 21:17:05 +05:30
Andreea Florescu
f9440ac8cd update dependabot formatting 2021-09-03 10:22:01 +03:00
dependabot[bot]
d9d95d8e80 build(deps): bump rust-vmm-ci from 8901e77 to 1311bfa
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `8901e77` to `1311bfa`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](8901e77522...1311bfa03f)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-02 09:51:04 +03:00
Viresh Kumar
8633b0fde4
Merge pull request #13 from rust-vmm/dependabot/submodules/rust-vmm-ci-8901e77
build(deps): bump rust-vmm-ci from `877d1fb` to `8901e77`
2021-08-31 20:01:36 +05:30
dependabot[bot]
8c66d0e1be
build(deps): bump rust-vmm-ci from 877d1fb to 8901e77
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `877d1fb` to `8901e77`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](877d1fb680...8901e77522)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-31 13:28:14 +00:00
Viresh Kumar
591175750b
Merge pull request #15 from vireshk/i2c-breakage
i2c: Fix breakage introduced by vhost-user-backend updates
2021-08-31 18:57:32 +05:30
Viresh Kumar
9e786e4032 i2c: Fix breakage introduced by vhost-user-backend
vhost-user-backend repository received few updates recently, which
caused this one to break.

Update the code here to fix the breakage.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-31 15:10:23 +05:30
Viresh Kumar
65da614d8b Update coverage to match with CI update
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-20 10:08:45 +03:00
dependabot[bot]
84658d21c1 build(deps): bump rust-vmm-ci from 24d66cd to 877d1fb
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `24d66cd` to `877d1fb`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](24d66cdae6...877d1fb680)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-20 10:08:45 +03:00
Viresh Kumar
019e755c61 i2c: Reduce test coverage score
Reduce the test coverage score as the files apart from i2c.rs are
mostly boilerplate code and it is difficult to test them as well as it
may not be worth it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
801802254b i2c: Add unit tests
This adds unit tests for the i2c workspace.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
890eafaa10 i2c: Update CODEOWNERS
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
cc46cab80d i2c: Update README.md and add one for i2c
This updates the main README and adds a specific one for i2c crate.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
6c7873ef1c i2c: Process virtio requests
This patch implements process_queue() to process incoming requests.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
0eedf21f4e i2c: Implement low level I2C helpers
This patch implements the low level I2C helpers responsible for
transferring data and parsing the adapters and their clients.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
0142902927 i2c: Add boilerplate code
This adds the boilerplate code and its dependencies to get the basic
structure for the i2c crate.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
cae4278e16 Convert to virtual manifest and add i2c workspace
This converts the Cargo.toml to a virtual manifest, removes the
src/lib.rs file and adds basic workspace for i2c backend device.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Viresh Kumar
8758a028cb Add .gitignore
Add .gitignore file in order not to show unwanted files in git status.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-08-19 09:52:14 +03:00
Andreea Florescu
72710f3a89 Initial commit 2021-05-26 10:18:40 +03:00