forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 147
Enabling Node.js applications - tested with lkl and dpdk #369
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
Closed
Closed
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 hidden or 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 |
|---|---|---|
|
|
@@ -33,11 +33,10 @@ static char *ealargs[4] = { | |
| /* XXX: disable cache due to no thread-safe on mempool cache. */ | ||
| #define MEMPOOL_CACHE_SZ 0 | ||
| /* for TSO pkt */ | ||
| /* default recommended for ixgbe and vmxnet3 drivers */ | ||
| #define MAX_PACKET_SZ (65535 \ | ||
| - (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)) | ||
| #define MBUF_NUM (512*2) /* vmxnet3 requires 1024 */ | ||
| #define MBUF_SIZ \ | ||
| (MAX_PACKET_SZ + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) | ||
| #define NUMDESC 512 /* nb_min on vmxnet3 is 512 */ | ||
| #define NUMQUEUE 1 | ||
|
|
||
|
|
@@ -332,6 +331,47 @@ struct lkl_dev_net_ops dpdk_net_ops = { | |
| .free = dpdk_net_free, | ||
| }; | ||
|
|
||
| /* | ||
| * this function assumes strtok was called with on a non-NULL string and | ||
| * the max_packet_sz or p_mbuf_num (or both) are eventually in the remaining | ||
| * string to be read here. | ||
| */ | ||
| static int read_maxpacketsz_mbufnum(int *p_max_packet_sz, int *p_mbuf_num) | ||
| { | ||
|
|
||
| int idx; | ||
| char *pch; | ||
|
|
||
| for (idx = 0; idx < 2; idx++) { | ||
| pch = strtok(NULL, "= "); | ||
| if (pch == 0) | ||
| break; | ||
|
|
||
| if (strcmp(pch, "max_packet_sz") == 0) { | ||
| pch = strtok(NULL, " ,"); | ||
| if (pch != 0) | ||
| *p_max_packet_sz = atoi(pch); | ||
| else | ||
| return 0; | ||
| } else if (strcmp(pch, "mbuf_num") == 0) { | ||
| pch = strtok(NULL, " ,"); | ||
| if (pch != 0) | ||
| *p_mbuf_num = atoi(pch); | ||
| else { | ||
| /* | ||
| * dpdk: value absent for indicated flag in | ||
| * LKL_HIJACK_NET_IFPARAMS | ||
| */ | ||
| return 0; | ||
| } | ||
| } else { | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| return 1; | ||
|
|
||
| } | ||
|
|
||
| static int dpdk_init; | ||
| struct lkl_netdev *lkl_netdev_dpdk_create(const char *ifparams, int offload, | ||
|
|
@@ -345,6 +385,12 @@ struct lkl_netdev *lkl_netdev_dpdk_create(const char *ifparams, int offload, | |
| char poolname[RTE_MEMZONE_NAMESIZE]; | ||
| char *debug = getenv("LKL_HIJACK_DEBUG"); | ||
| int lkl_debug = 0; | ||
| int max_packet_sz = MAX_PACKET_SZ; | ||
| int mbuf_num = MBUF_NUM; | ||
| int mbuf_size = 0; | ||
| int ifparams_len = 0; | ||
| char *ifparams_local = NULL; | ||
| char *ifparams_first_token = NULL; | ||
|
|
||
| if (!dpdk_init) { | ||
| if (debug) | ||
|
|
@@ -369,10 +415,29 @@ struct lkl_netdev *lkl_netdev_dpdk_create(const char *ifparams, int offload, | |
| /* we always enable big_packet mode with dpdk. */ | ||
| nd->offload = offload; | ||
|
|
||
| snprintf(poolname, RTE_MEMZONE_NAMESIZE, "%s%s", "tx-", ifparams); | ||
| ifparams_len = strlen(ifparams); | ||
|
Member
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. could you document somewhere (maybe https://github.com/lkl/linux/wiki/Howto:-DPDK-with-LKL should be good). at least in the code comment block and commit message will be helpful. |
||
| ifparams_local = (char *)alloca(ifparams_len + 1); | ||
| strcpy(ifparams_local, ifparams); | ||
|
|
||
| /* isolate the first token */ | ||
| ifparams_first_token = strtok(ifparams_local, ",="); | ||
|
|
||
| if (read_maxpacketsz_mbufnum(&max_packet_sz, &mbuf_num) == 0) { | ||
| lkl_printf( | ||
| "dpdk: failed to read max_packet_sz or mbuf_num\n"); | ||
| free(nd); | ||
| return NULL; | ||
| } | ||
|
|
||
| snprintf(poolname, RTE_MEMZONE_NAMESIZE, "%s%s", "tx-", | ||
| ifparams_first_token); | ||
|
|
||
| mbuf_size = (max_packet_sz + sizeof(struct rte_mbuf) + | ||
| RTE_PKTMBUF_HEADROOM); | ||
|
|
||
| nd->txpool = | ||
| rte_mempool_create(poolname, | ||
| MBUF_NUM, MBUF_SIZ, MEMPOOL_CACHE_SZ, | ||
| mbuf_num, mbuf_size, MEMPOOL_CACHE_SZ, | ||
| sizeof(struct rte_pktmbuf_pool_private), | ||
| rte_pktmbuf_pool_init, NULL, | ||
| rte_pktmbuf_init, NULL, 0, 0); | ||
|
|
@@ -383,10 +448,11 @@ struct lkl_netdev *lkl_netdev_dpdk_create(const char *ifparams, int offload, | |
| return NULL; | ||
| } | ||
|
|
||
| snprintf(poolname, RTE_MEMZONE_NAMESIZE, "%s%s", "rx-", | ||
| ifparams_first_token); | ||
|
|
||
| snprintf(poolname, RTE_MEMZONE_NAMESIZE, "%s%s", "rx-", ifparams); | ||
| nd->rxpool = | ||
| rte_mempool_create(poolname, MBUF_NUM, MBUF_SIZ, 0, | ||
| rte_mempool_create(poolname, mbuf_num, mbuf_size, 0, | ||
| sizeof(struct rte_pktmbuf_pool_private), | ||
| rte_pktmbuf_pool_init, NULL, | ||
| rte_pktmbuf_init, NULL, 0, 0); | ||
|
|
||
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.
times fly: since #385 introduces JSON configuration interface, it would be nicer that this configuration can be done via this new way: you can have your private parameters as a json key to configure internal behavior of your code.
If you want to keep this parameter hidden, you can just implement it. if you intended to be a public one, then you can document in lkl.txt.