File tree 3 files changed +57
-0
lines changed
3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -163,4 +163,11 @@ config SAMPLE_RUST_SELFTESTS
163
163
164
164
If unsure, say N.
165
165
166
+ config SAMPLE_RUST_MLX4
167
+ tristate "infiniband mlx4"
168
+ help
169
+ This option builds the infiniband mlx4 driver cases for Rust.
170
+
171
+ If unsure, say N.
172
+
166
173
endif # SAMPLES_RUST
Original file line number Diff line number Diff line change @@ -15,5 +15,6 @@ obj-$(CONFIG_SAMPLE_RUST_NETFILTER) += rust_netfilter.o
15
15
obj-$(CONFIG_SAMPLE_RUST_ECHO_SERVER) += rust_echo_server.o
16
16
obj-$(CONFIG_SAMPLE_RUST_FS) += rust_fs.o
17
17
obj-$(CONFIG_SAMPLE_RUST_SELFTESTS) += rust_selftests.o
18
+ obj-$(CONFIG_SAMPLE_RUST_MLX4) += rust_mlx4.o
18
19
19
20
subdir-$(CONFIG_SAMPLE_RUST_HOSTPROGS) += hostprogs
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0
2
+
3
+ //! Rust infiniband mls4 device sample.
4
+
5
+ use kernel:: mlx4;
6
+ use kernel:: prelude:: * ;
7
+
8
+ module ! {
9
+ type : RustMlx4 ,
10
+ name: "rust_mlx4" ,
11
+ author: "Rust for Linux Contributors" ,
12
+ description: "Rust infiniband mlx4 device sample" ,
13
+ license: "GPL" ,
14
+ }
15
+
16
+ struct RustMlx4Ops ;
17
+
18
+ #[ vtable]
19
+ impl mlx4:: Mlx4Operation for RustMlx4Ops {
20
+ fn add ( ) -> Result {
21
+ Ok ( ( ) )
22
+ }
23
+ fn remove ( ) -> Result {
24
+ Ok ( ( ) )
25
+ }
26
+ fn event ( ) -> Result {
27
+ Ok ( ( ) )
28
+ }
29
+ }
30
+
31
+ struct RustMlx4 {
32
+ _dev : Pin < Box < mlx4:: Registration < RustMlx4Ops > > > ,
33
+ }
34
+
35
+ impl kernel:: Module for RustMlx4 {
36
+ fn init ( name : & ' static CStr , _module : & ' static ThisModule ) -> Result < Self > {
37
+ pr_info ! ( "Rust infiniband mlx4 driver sample (init)\n " ) ;
38
+
39
+ Ok ( RustMlx4 {
40
+ _dev : mlx4:: Registration :: new_pinned ( name) ?,
41
+ } )
42
+ }
43
+ }
44
+
45
+ impl Drop for RustMlx4 {
46
+ fn drop ( & mut self ) {
47
+ pr_info ! ( "Rust infiniband mlx4 driver sample (exit)\n " ) ;
48
+ }
49
+ }
You can’t perform that action at this time.
0 commit comments