Skip to content
GitLab
    • Explore Projects Groups Topics Snippets
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • P Proj265-Network Stack Offloading
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Lu Jun
  • Proj265-Network Stack Offloading
  • Merge requests
  • !3
An error occurred while fetching the assigned milestone of the selected merge_request.

fix(dpdk.c+init.c): dpdk+lwip works well

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Lu Jun requested to merge dev into master 1 year ago
  • Overview 0
  • Commits 4
  • Pipelines 0
  • Changes 3

tcpip_thread is created by posix syscall rather than dpdk framework, leading to ret_lcore_id() returns an uninitialized lcore_id value.

Compare
  • master (base)

and
  • latest version
    45ba8cba
    4 commits, 1 year ago

3 files
+ 28
− 11

    Preferences

    File browser
    Compare changes
netstack/dpdk.c
+ 14
− 4
  • View file @ 45ba8cba

  • Edit in single-file editor

  • Open in Web IDE


@@ -161,11 +161,14 @@ void dpdk_poll(void)
struct rte_mbuf *rx_pkts[BATCH_SIZE];
lcoreid = rte_lcore_id();
if (lcoreid > rte_lcore_count()) {
printf("current thread is tcpip_thread\n");
lcoreid = 0;
}
qconf = &lcore_conf[lcoreid];
netif = get_netif();
// printf("lcore id: %d, queue id: %d\n", rte_lcore_id(), RTE_PER_LCORE(queue_id));
// ret = rte_eth_rx_burst(1, RTE_PER_LCORE(queue_id), rx_pkts, BATCH_SIZE);
ret = rte_eth_rx_burst(PORT_ID, qconf->rx_queue_id, rx_pkts, BATCH_SIZE);
for (i = 0; i < ret; i++) {
@@ -228,12 +231,19 @@ int dpdk_send_burst(struct lcore_conf *qconf, struct rte_mbuf *m)
err_t dpdk_output(struct netif *netif, struct pbuf *p)
{
uint32_t ret, lcore_id;
int32_t ret;
uint32_t lcore_id;
struct lcore_conf *qconf;
struct rte_mbuf *pkt_buf;
unsigned char *buf_addr;
lcore_id = rte_lcore_id();
if (lcore_id > rte_lcore_count()) {
printf("current thread is tcpip_thread\n");
lcore_id = 0;
}
printf("dpdk_output, lcore_id: %u\n", lcore_id);
qconf = &lcore_conf[lcore_id];
pkt_buf = rte_pktmbuf_alloc(pktmbuf_pool);
@@ -243,12 +253,11 @@ err_t dpdk_output(struct netif *netif, struct pbuf *p)
pkt_buf->pkt_len = p->len;
pkt_buf->data_len = p->len;
buf_addr = rte_pktmbuf_mtod(pkt_buf, unsigned char *);
// rte_memcpy(rte_pktmbuf_mtod(pkt_buf, unsigned char *), p->payload, p->len);
rte_memcpy(buf_addr, p->payload, p->len);
ret = dpdk_send_burst(qconf, pkt_buf);
printf("dpdk_output, tx buffer: %u byte\n", ret);
printf("dpdk_output, tx: %u packet\n", ret);
if (ret < 0)
return ERR_VAL;
return 0;
@@ -259,6 +268,7 @@ int lcore_setup(void)
int lcoreid = 0, core_cnt = 0;
core_cnt = rte_lcore_count();
printf("lcore_setup, core cnt: %u\n", core_cnt);
printf("lcore_setup, current core id: %u\n", rte_lcore_id());
for (lcoreid = START_CORE; lcoreid < core_cnt + START_CORE; lcoreid++) {
printf("lcore_setup, lcoreid: %d\n", lcoreid);
lcore_conf[lcoreid - START_CORE].n_rx_queue = NUM_RX_QUEUES_PER_LCORE;
netstack/init.c
+ 13
− 7
  • View file @ 45ba8cba

  • Edit in single-file editor

  • Open in Web IDE


@@ -30,6 +30,12 @@ uint8_t mac[] = {0xb8, 0x59, 0x9f, 0x40, 0x23, 0xfb};
static err_t device_init(struct netif* netif) {
struct lcore_conf *qconf;
uint32_t lcoreid = rte_lcore_id();
if (lcoreid > rte_lcore_count()) {
printf("current thread is tcpip_thread\n");
lcoreid = 0;
}
printf("device_init, lcore_id: %u\n", lcoreid);
qconf = &lcore_conf[lcoreid-START_CORE];
if (!qconf) {
return ERR_MEM;
@@ -42,17 +48,16 @@ static err_t device_init(struct netif* netif) {
netif->linkoutput = dpdk_output;
netif->mtu = 1500;
netif->hwaddr_len = 6;
// netif->flags = NETIF_FLAG_LINK_UP | NETIF_FLAG_ETHARP | NETIF_FLAG_BROADCAST; /*Not enabling ETHARP on this, so might need to change netif->output */
netif->flags = NETIF_FLAG_ETHARP | NETIF_FLAG_BROADCAST; /*Not enabling ETHARP on this, so might need to change netif->output */
netif->flags = NETIF_FLAG_LINK_UP | NETIF_FLAG_ETHARP | NETIF_FLAG_BROADCAST; /*Not enabling ETHARP on this, so might need to change netif->output */
// netif->flags = NETIF_FLAG_ETHARP | NETIF_FLAG_BROADCAST; /*Not enabling ETHARP on this, so might need to change netif->output */
MEMCPY(netif->hwaddr, mac, NETIF_MAX_HWADDR_LEN);
printf("device_init, flags: %x\n", netif->flags);
printf("device_init, flags: 0x%x\n", netif->flags);
return ERR_OK;
}
static int main_thread(void *arg)
{
// int q_id = (int)(long)arg;
arg = arg;
RTE_PER_LCORE(tx_buf) =
rte_malloc(NULL, RTE_ETH_TX_BUFFER_SIZE(4 * ETH_DEV_TX_QUEUE_SZ), 0);
@@ -81,13 +86,13 @@ int main(int argc, char **argv)
int ret, count;
unsigned lcore_id;
tcpip_init(tcpip_init_done, NULL);
printf("tcpip_init done\n");
/*initialise dpdk*/
dpdk_init(&argc, &argv);
printf("dpdk_init done\n");
tcpip_init(tcpip_init_done, NULL);
printf("tcpip_init done\n");
/* Run the application initialisation function */
LOCK_TCPIP_CORE();
if (net_thread_init()) {
@@ -96,6 +101,7 @@ int main(int argc, char **argv)
}
printf("net_thread_init done\n");
UNLOCK_TCPIP_CORE();
printf("main, 1, current core id: %u\n", rte_lcore_id());
/* launch main function on all cores */
count = 0;
.gitignore
+ 1
− 0
  • View file @ 45ba8cba

  • Edit in single-file editor

  • Open in Web IDE


@@ -2,5 +2,6 @@
*.so
*.a
*.log
*.swap
tags
nic-echo
Assignee
Lu Jun's avatar
Lu Jun
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 Participants
Reference:
Source branch: dev

Menu

Explore Projects Groups Topics Snippets