Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
e6fddd63
Commit
e6fddd63
authored
12 years ago
by
Dor Laor
Browse files
Options
Downloads
Patches
Plain Diff
Fixed add_bug function to work correctly w/ the ring
parent
6ab38129
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/virtio-vring.cc
+30
-17
30 additions, 17 deletions
drivers/virtio-vring.cc
drivers/virtio-vring.hh
+11
-0
11 additions, 0 deletions
drivers/virtio-vring.hh
with
41 additions
and
17 deletions
drivers/virtio-vring.cc
+
30
−
17
View file @
e6fddd63
...
...
@@ -29,12 +29,22 @@ namespace virtio {
sizeof
(
u16
)
+
VIRTIO_PCI_VRING_ALIGN
-
1
)
&
~
(
VIRTIO_PCI_VRING_ALIGN
-
1
));
// initialize the next pointer within the available ring
for
(
int
i
=
0
;
i
<
num
;
i
++
)
_avail
->
_ring
[
i
]
=
i
+
1
;
for
(
int
i
=
0
;
i
<
num
;
i
++
)
_desc
[
i
].
_next
=
i
+
1
;
_desc
[
num
-
1
].
_next
=
0
;
_cookie
=
new
void
*
[
num
];
_avail_head
=
0
;
_used_guest_head
=
0
;
_avail_added
=
0
;
_avail_count
=
num
;
}
vring
::~
vring
()
{
free
(
_vring_ptr
);
delete
[]
_cookie
;
}
u64
vring
::
get_paddr
(
void
)
...
...
@@ -61,27 +71,30 @@ namespace virtio {
bool
vring
::
add_buf
(
sglist
*
sg
,
u16
out
,
u16
in
,
void
*
cookie
)
{
//if (_avail->count() < (in+out)) {
// what should I do?
//}
if
(
_avail_count
<
(
in
+
out
))
{
//make sure the interrupts get there
kick
();
return
false
;
}
int
i
=
0
;
vring_desc
*
desc
=
&
_desc
[
_avail
->
_ring
[
_avail
->
_idx
]]
;
int
i
=
0
,
idx
,
prev_idx
;
idx
=
prev_idx
=
_avail_head
;
for
(
auto
ii
=
sg
->
_nodes
.
begin
();
i
<
in
+
out
;
ii
++
)
{
desc
->
_flags
=
vring_desc
::
VRING_DESC_F_NEXT
|
(
i
>
in
)
?
vring_desc
::
VRING_DESC_F_WRITE
:
0
;
desc
->
_paddr
=
(
*
ii
).
_paddr
;
desc
->
_len
=
(
*
ii
).
_len
;
desc
->
_next
=
_avail
->
_ring
[
_avail
->
_idx
];
_avail
->
_idx
++
;
desc
=
&
_desc
[
_avail
->
_ring
[
desc
->
_next
]];
i
++
;
_desc
[
idx
].
_flags
=
vring_desc
::
VRING_DESC_F_NEXT
;
_desc
[
idx
].
_flags
|=
(
i
++>
in
)
?
vring_desc
::
VRING_DESC_F_WRITE
:
0
;
_desc
[
idx
].
_paddr
=
(
*
ii
).
_paddr
;
_desc
[
idx
].
_len
=
(
*
ii
).
_len
;
prev_idx
=
idx
;
idx
=
_avail
->
_ring
[
_desc
[
idx
].
_next
];
}
desc
->
_flags
&=
~
vring_desc
::
VRING_DESC_F_NEXT
;
_desc
[
prev_idx
].
_flags
&=
~
vring_desc
::
VRING_DESC_F_NEXT
;
_avail
->
_idx
=
_avail_head
;
_cookie
[
_avail_head
]
=
cookie
;
//_avail->add(sg, in, out, cookie);
//used idx math
_avail_added
+=
i
;
_avail_count
-=
i
;
_avail_head
=
idx
;
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/virtio-vring.hh
+
11
−
0
View file @
e6fddd63
...
...
@@ -129,12 +129,23 @@ class virtio_driver;
// Total number of descriptors in ring
unsigned
int
_num
;
// Position of the next available descriptor
u16
_avail_head
;
// Position of the used descriptor we've last seen
u16
_used_guest_head
;
// The amount of avail descriptors we've added since last kick
u16
_avail_added
;
u16
_avail_count
;
// Flat list of chained descriptors
vring_desc
*
_desc
;
// Available for host consumption
vring_avail
*
_avail
;
// Available for guest consumption
vring_used
*
_used
;
// cookies to store access to the upper layer pointers
void
**
_cookie
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment