From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw0534.ocn.ad.jp (mogw0534.ocn.ad.jp [118.23.178.176]) by dpdk.org (Postfix) with ESMTP id 7E7AE1B78F for ; Wed, 31 Jan 2018 12:20:59 +0100 (CET) Received: from mf-smf-ucb018.ocn.ad.jp (mf-smf-ucb018.ocn.ad.jp [153.149.227.67]) by mogw0534.ocn.ad.jp (Postfix) with ESMTP id E7FDB3482EB; Wed, 31 Jan 2018 20:20:57 +0900 (JST) Received: from mf-smf-ucb018.ocn.ad.jp (mf-smf-ucb018 [153.149.227.67]) by mf-smf-ucb018.ocn.ad.jp (Postfix) with ESMTP id CF06920627; Wed, 31 Jan 2018 20:20:57 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb029 (mv-mta-ucb029.ocn.ad.jp [153.149.230.163]) by mf-smf-ucb018.ocn.ad.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id w0VBKk06041122; Wed, 31 Jan 2018 20:20:57 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.133]) by ntt.pod01.mv-mta-ucb029 with id 4zLx1x00A2tKTyH01zLxih; Wed, 31 Jan 2018 11:20:57 +0000 Received: from mugwort.jp (p6535076-ipngn12202marunouchi.tokyo.ocn.ne.jp [118.22.122.76]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Wed, 31 Jan 2018 20:20:57 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, geminoa@juno.ocn.ne.jp Cc: ogawa.yasufumi@lab.ntt.co.jp, Naoki Takada Date: Wed, 31 Jan 2018 20:21:12 +0900 Message-Id: <20180131105606.1345-3-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180131105606.1345-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20180131105606.1345-1-ogawa.yasufumi@lab.ntt.co.jp> X-Account-Key: account3 X-UIDL: 8823.60Uyzq5H7zUA1loNnqAA4avV40k= X-Mozilla-Status: 0000 Received: from mzcmta003.ocn.ad.jp (LHLO mzcmta003.ocn.ad.jp) (118.23.184.202) by mzcstore251.ocn.ad.jp with LMTP; Wed, 31 Jan 2018 19:55:37 +0900 (JST) Received: from mfgw691.ocn.ad.jp (mfgw691.ocn.ad.jp [153.153.63.98]) by mzcmta003.ocn.ad.jp (Postfix) with ESMTP id 3FE8D3D566E for ; Wed, 31 Jan 2018 19:55:37 +0900 (JST) Received-SPF: softfail (mf-ofc-ucb069: domain of transitioning dose not designate client-ip as permitted sender) client-ip=153.149.228.26; envelope-from=; helo=mogw0625.ocn.ad.jp; Authentication-Results: mf-ofc-ucb069; spf=softfail smtp.mailfrom=ogawa.yasufumi@lab.ntt.co.jp Received: from mogw0625.ocn.ad.jp (mogw0625.ocn.ad.jp [153.149.228.26]) by mfgw691.ocn.ad.jp (Postfix) with ESMTP id B90C6A802A3 for ; Wed, 31 Jan 2018 19:55:36 +0900 (JST) Received: from mf-smf-ucb007.ocn.ad.jp (mf-smf-ucb007.ocn.ad.jp [153.149.231.6]) by mogw0625.ocn.ad.jp (Postfix) with ESMTP id 7C3F5500470; Wed, 31 Jan 2018 19:55:36 +0900 (JST) Received: from mf-smf-ucb007.ocn.ad.jp (mf-smf-ucb007 [153.149.231.6]) by mf-smf-ucb007.ocn.ad.jp (Postfix) with ESMTP id 61AE8805F8; Wed, 31 Jan 2018 19:55:36 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb025 (mv-mta-ucb025.ocn.ad.jp [153.149.142.99]) by mf-smf-ucb007.ocn.ad.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id w0VAtZe7012783; Wed, 31 Jan 2018 19:55:36 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.166]) by ntt.pod01.mv-mta-ucb025 with id 4yvb1x00H3c2f7501yvbDt; Wed, 31 Jan 2018 10:55:35 +0000 Received: from mugwort.jp (p6535076-ipngn12202marunouchi.tokyo.ocn.ne.jp [118.22.122.76]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Wed, 31 Jan 2018 19:55:35 +0900 (JST) X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180131105606.1345-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20180131105606.1345-1-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 3/4] spp_nfv: add null pmd X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jan 2018 11:21:00 -0000 From: ogawa.yasufumi@lab.ntt.co.jp From: Yasufumi Ogawa Null PMD is a virtual device for DPDK performance test[1]. It provides '/dev/null' like PMD which means that it is able to send/receive packets no limitation. [1] https://dpdk.org/ml/archives/dev/2015-February/012482.html Signed-off-by: Yasufumi Ogawa Signed-off-by: Naoki Takada --- src/nfv/nfv.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/common.c | 5 ++++ src/shared/common.h | 10 +++++++ 3 files changed, 97 insertions(+) diff --git a/src/nfv/nfv.c b/src/nfv/nfv.c index c1a48e9..a3e04bf 100644 --- a/src/nfv/nfv.c +++ b/src/nfv/nfv.c @@ -369,6 +369,19 @@ do_del(char *token_list[], int max_token) return -1; rte_eth_dev_detach(port_id, name); + + } else if (!strcmp(token_list[1], "nullpmd")) { + char name[RTE_ETH_NAME_MAX_LEN]; + + if (spp_atoi(token_list[2], &id) < 0) + return 0; + + port_id = find_port_id(id, NULLPMD); + if (port_id < 0) + return -1; + + rte_eth_dev_detach(port_id, name); + } forward_array_remove(port_id); @@ -560,6 +573,68 @@ add_pcap_pmd(int index) } static int +add_null_pmd(int index) +{ + struct rte_eth_conf port_conf = { + .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN } + }; + + struct rte_mempool *mp; + const char *name; + char devargs[64]; + uint16_t null_pmd_port_id; + uint16_t nr_queues = 1; + + int ret; + + mp = rte_mempool_lookup(PKTMBUF_POOL_NAME); + if (mp == NULL) + rte_exit(EXIT_FAILURE, "Cannon get mempool for mbuf\n"); + + name = get_null_pmd_name(index); + sprintf(devargs, "%s", name); + ret = rte_eth_dev_attach(devargs, &null_pmd_port_id); + if (ret < 0) + return ret; + + ret = rte_eth_dev_configure( + null_pmd_port_id, nr_queues, nr_queues, + &port_conf); + if (ret < 0) + return ret; + + /* Allocate and set up 1 RX queue per Ethernet port. */ + uint16_t q; + for (q = 0; q < nr_queues; q++) { + ret = rte_eth_rx_queue_setup( + null_pmd_port_id, q, NR_DESCS, + rte_eth_dev_socket_id( + null_pmd_port_id), NULL, mp); + if (ret < 0) + return ret; + } + + /* Allocate and set up 1 TX queue per Ethernet port. */ + for (q = 0; q < nr_queues; q++) { + ret = rte_eth_tx_queue_setup( + null_pmd_port_id, q, NR_DESCS, + rte_eth_dev_socket_id( + null_pmd_port_id), + NULL); + if (ret < 0) + return ret; + } + + ret = rte_eth_dev_start(null_pmd_port_id); + if (ret < 0) + return ret; + + RTE_LOG(DEBUG, APP, "null port id %d\n", null_pmd_port_id); + + return null_pmd_port_id; +} + +static int do_add(char *token_list[], int max_token) { enum port_type type = UNDEF; @@ -589,6 +664,13 @@ do_add(char *token_list[], int max_token) type = PCAP; port_id = add_pcap_pmd(id); + + } else if (!strcmp(token_list[1], "nullpmd")) { + if (spp_atoi(token_list[2], &id) < 0) + return 0; + + type = NULLPMD; + port_id = add_null_pmd(id); } if (port_id < 0) diff --git a/src/shared/common.c b/src/shared/common.c index c577d12..4176b6d 100644 --- a/src/shared/common.c +++ b/src/shared/common.c @@ -302,6 +302,11 @@ print_active_ports(char *str, uint16_t client_id, sprintf(str + strlen(str), "PCAP(%u),", port_map[i].id); break; + case NULLPMD: + RTE_LOG(INFO, APP, "Type: NULLPMD\n"); + sprintf(str + strlen(str), "NULLPMD(%u),", + port_map[i].id); + break; case UNDEF: RTE_LOG(INFO, APP, "Type: UDF\n"); sprintf(str + strlen(str), "UDF,"); diff --git a/src/shared/common.h b/src/shared/common.h index c5f39d1..f0d68e5 100644 --- a/src/shared/common.h +++ b/src/shared/common.h @@ -119,6 +119,7 @@ enum port_type { RING, VHOST, PCAP, + NULLPMD, UNDEF, }; @@ -145,6 +146,7 @@ struct port { #define VHOST_BACKEND_NAME "eth_vhost%u" #define VHOST_IFACE_NAME "/tmp/sock%u" #define PCAP_PMD_DEV_NAME "eth_pcap%u" +#define NULL_PMD_DEV_NAME "eth_null%u" /* * Given the rx queue name template above, get the queue name @@ -196,6 +198,14 @@ get_pcap_pmd_name(int id) return buffer; } +static inline const char * +get_null_pmd_name(int id) +{ + static char buffer[sizeof(NULL_PMD_DEV_NAME) + 2]; + snprintf(buffer, sizeof(buffer) - 1, NULL_PMD_DEV_NAME, id); + return buffer; +} + void check_all_ports_link_status(struct port_info *ports, uint16_t port_num, uint32_t port_mask); -- 2.13.1