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
86d99972
Commit
86d99972
authored
12 years ago
by
Dor Laor
Browse files
Options
Downloads
Patches
Plain Diff
Change the header to be a regular field within the virtio_net_req
structure. The later was already allocated on the heap.
parent
e7f5d083
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/virtio-net.cc
+8
-9
8 additions, 9 deletions
drivers/virtio-net.cc
with
8 additions
and
9 deletions
drivers/virtio-net.cc
+
8
−
9
View file @
86d99972
...
@@ -132,12 +132,12 @@ namespace virtio {
...
@@ -132,12 +132,12 @@ namespace virtio {
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
struct
virtio_net_req
{
struct
virtio_net_req
{
virtio_net
::
virtio_net_hdr
*
hdr
;
struct
virtio_net
::
virtio_net_hdr
hdr
;
sglist
payload
;
sglist
payload
;
u8
*
buffer
;
u8
*
buffer
;
virtio_net_req
()
:
buffer
(
nullptr
)
{};
virtio_net_req
()
:
buffer
(
nullptr
)
{};
~
virtio_net_req
()
{
delete
hdr
;
if
(
buffer
)
delete
buffer
;}
~
virtio_net_req
()
{
if
(
buffer
)
delete
buffer
;}
};
};
void
virtio_net
::
receiver
()
{
void
virtio_net
::
receiver
()
{
...
@@ -158,7 +158,7 @@ namespace virtio {
...
@@ -158,7 +158,7 @@ namespace virtio {
char
*
buf
=
reinterpret_cast
<
char
*>
(
mmu
::
phys_to_virt
(
ii
->
_paddr
));
char
*
buf
=
reinterpret_cast
<
char
*>
(
mmu
::
phys_to_virt
(
ii
->
_paddr
));
virtio_net_d
(
fmt
(
"
\t
len=%d"
)
%
ii
->
_len
);
virtio_net_d
(
fmt
(
"
\t
len=%d"
)
%
ii
->
_len
);
virtio_net_d
(
fmt
(
"
\t
got hdr len:%d = %d vaddr=%p"
)
%
i
++
%
(
int
)
req
->
hdr
->
hdr_len
%
(
void
*
)
buf
);
virtio_net_d
(
fmt
(
"
\t
got hdr len:%d = %d vaddr=%p"
)
%
i
++
%
(
int
)
req
->
hdr
.
hdr_len
%
(
void
*
)
buf
);
ethhdr
*
eh
=
reinterpret_cast
<
ethhdr
*>
(
buf
);
ethhdr
*
eh
=
reinterpret_cast
<
ethhdr
*>
(
buf
);
virtio_net_d
(
fmt
(
"The src %x:%x:%x:%x:%x:%x dst %x:%x:%x:%x:%x:%x type %d "
)
%
virtio_net_d
(
fmt
(
"The src %x:%x:%x:%x:%x:%x dst %x:%x:%x:%x:%x:%x type %d "
)
%
...
@@ -209,11 +209,10 @@ namespace virtio {
...
@@ -209,11 +209,10 @@ namespace virtio {
while
(
queue
->
avail_ring_has_room
(
2
))
{
while
(
queue
->
avail_ring_has_room
(
2
))
{
virtio_net_req
*
req
=
new
virtio_net_req
;
virtio_net_req
*
req
=
new
virtio_net_req
;
req
->
hdr
=
new
virtio_net_hdr
;
void
*
buf
=
malloc
(
page_size
);
void
*
buf
=
malloc
(
page_size
);
memset
(
buf
,
0
,
page_size
);
memset
(
buf
,
0
,
page_size
);
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
buf
),
page_size
);
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
buf
),
page_size
);
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
static_cast
<
void
*>
(
req
->
hdr
)),
sizeof
(
struct
virtio_net_hdr
),
true
);
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
static_cast
<
void
*>
(
&
req
->
hdr
)),
sizeof
(
struct
virtio_net_hdr
),
true
);
if
(
!
queue
->
add_buf
(
&
req
->
payload
,
0
,
2
,
req
))
{
if
(
!
queue
->
add_buf
(
&
req
->
payload
,
0
,
2
,
req
))
{
delete
req
;
delete
req
;
...
@@ -241,9 +240,8 @@ namespace virtio {
...
@@ -241,9 +240,8 @@ namespace virtio {
virtio_net_req
*
req
=
new
virtio_net_req
;
virtio_net_req
*
req
=
new
virtio_net_req
;
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
out
),
len
);
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
out
),
len
);
req
->
hdr
=
new
virtio_net_hdr
;
req
->
hdr
.
hdr_len
=
ETH_ALEN
+
sizeof
(
iphdr
);
req
->
hdr
->
hdr_len
=
ETH_ALEN
+
sizeof
(
iphdr
);
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
static_cast
<
void
*>
(
&
req
->
hdr
)),
sizeof
(
struct
virtio_net_hdr
),
true
);
req
->
payload
.
add
(
mmu
::
virt_to_phys
(
static_cast
<
void
*>
(
req
->
hdr
)),
sizeof
(
struct
virtio_net_hdr
),
true
);
req
->
buffer
=
(
u8
*
)
out
;
req
->
buffer
=
(
u8
*
)
out
;
if
(
!
queue
->
add_buf
(
&
req
->
payload
,
2
,
0
,
req
))
{
if
(
!
queue
->
add_buf
(
&
req
->
payload
,
2
,
0
,
req
))
{
...
@@ -313,7 +311,8 @@ namespace virtio {
...
@@ -313,7 +311,8 @@ namespace virtio {
memset
(
buf
,
0
,
1000
);
memset
(
buf
,
0
,
1000
);
// set the src& dst to self
// set the src& dst to self
memcpy
(
buf
,
_config
.
mac
,
sizeof
(
_config
.
mac
));
memcpy
(
buf
,
_config
.
mac
,
sizeof
(
_config
.
mac
));
memcpy
(
buf
+
6
,
_config
.
mac
,
sizeof
(
_config
.
mac
));
//deliberate have offset so src != dst, just for this test
memcpy
(
buf
+
7
,
_config
.
mac
,
sizeof
(
_config
.
mac
));
virtio_net_d
(
fmt
(
"%s: sending packet %d"
)
%
__FUNCTION__
%
i
++
);
virtio_net_d
(
fmt
(
"%s: sending packet %d"
)
%
__FUNCTION__
%
i
++
);
tx
(
buf
,
1000
);
tx
(
buf
,
1000
);
...
...
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