-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtio_netmap: Use half the vring's size as netmap slots #726
Open
awelzel
wants to merge
1
commit into
luigirizzo:master
Choose a base branch
from
awelzel:virtio-use-half-the-slots
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -632,6 +632,17 @@ virtio_netmap_init_buffers(struct virtnet_info *vi) | |
for (i = 0; i < na->num_rx_desc; i++) { | ||
void *addr; | ||
|
||
/* | ||
* As the comment above states, we need to add exactly | ||
* num_rx_desc descriptors and so the queue is not | ||
* allowed to become full. | ||
*/ | ||
if (vq->num_free == 0) { | ||
nm_prerr("No space left in vq! %d/%d", | ||
i, na->num_rx_desc); | ||
break; | ||
} | ||
|
||
slot = &ring->slot[i]; | ||
addr = NMB(na, slot); | ||
COMPAT_INIT_SG(sg); | ||
|
@@ -644,9 +655,6 @@ virtio_netmap_init_buffers(struct virtnet_info *vi) | |
return 0; | ||
} | ||
RXNUM_INC(vi, r); | ||
|
||
if (VQ_FULL(vq, err)) | ||
break; | ||
} | ||
nm_prinf("added %d inbufs on queue %d", i, r); | ||
virtqueue_kick(vq); | ||
|
@@ -677,6 +685,20 @@ virtio_netmap_intr(struct netmap_adapter *na, int onoff) | |
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defining this function is unnecessary, because nothing is going to change the values listed in |
||
static int | ||
virtio_netmap_config(struct netmap_adapter *na, struct nm_config_info *info) | ||
{ | ||
int ret = netmap_rings_config_get(na, info); | ||
if (ret) | ||
return ret; | ||
|
||
/* Take whatever we had at init time. */ | ||
info->num_tx_descs = na->num_tx_desc; | ||
info->num_rx_descs = na->num_rx_desc; | ||
info->rx_buf_maxsize = na->rx_buf_maxsize; | ||
return 0; | ||
} | ||
|
||
static void | ||
virtio_netmap_attach(struct virtnet_info *vi) | ||
{ | ||
|
@@ -686,13 +708,14 @@ virtio_netmap_attach(struct virtnet_info *vi) | |
bzero(&na, sizeof(na)); | ||
|
||
na.ifp = vi->dev; | ||
na.num_tx_desc = virtqueue_get_vring_size(GET_TX_VQ(vi, 0)); | ||
na.num_rx_desc = virtqueue_get_vring_size(GET_RX_VQ(vi, 0)); | ||
na.num_tx_desc = virtqueue_get_vring_size(GET_TX_VQ(vi, 0)) / 2; | ||
na.num_rx_desc = virtqueue_get_vring_size(GET_RX_VQ(vi, 0)) / 2; | ||
na.num_tx_rings = na.num_rx_rings = 1; | ||
na.nm_register = virtio_netmap_reg; | ||
na.nm_txsync = virtio_netmap_txsync; | ||
na.nm_rxsync = virtio_netmap_rxsync; | ||
na.nm_intr = virtio_netmap_intr; | ||
na.nm_config = virtio_netmap_config; | ||
|
||
ret = netmap_attach_ext(&na, sizeof(struct netmap_virtio_adapter), 1); | ||
if (ret) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the
VQ_FULL
macro for portability