From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 93193A00E6 for ; Tue, 6 Aug 2019 09:29:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 89BBF1B954; Tue, 6 Aug 2019 09:29:09 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 3E6221B954 for ; Tue, 6 Aug 2019 09:29:08 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id r1so41005689pfq.12 for ; Tue, 06 Aug 2019 00:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=PrwtanloCl8bSv99YDSy2XGx6nH//iI+s1EbLPv5Dnk=; b=LP+5MbL822DoTa2yOLRU8PP/TEMokhT1/OyPWxVQzII0gWAkQszaB6vHfzENQ23Ngr RRSnCEwnAWHEhybzpXMXVq99RO+8ylKp+TYxSKVGwG1jeoml8t1V88kJRxOy6Xf1YHQD DHivNqHYi10mSNF8JV1v7fsN3A6rnMnF9VWhAqigIvGzlIydyNkQREsuwahazsBWU+mv fZitfvFO9xQPcgt5HWmgmI4dEFvdI+UYNmTC0cjpvf0rH/lSJUn7+p6n59RFxLIqwZIl /Qh5lEKXtrJQf7N1mpx/X2jOrlVEuuJRjUGxJ2KuRV6bjsFIzzx1TOt1/lt8qrdEYNJ3 +UTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=PrwtanloCl8bSv99YDSy2XGx6nH//iI+s1EbLPv5Dnk=; b=jaWabvmbzor1J+xQukDtXFY5nCWmKMZ6KcdAORvL4OHSpCXWknbm5ZcVbAm7QdtMz3 Cr5RV9eFpZGRLxGkE5sApIPZBol8Gtrrb4qYOa1m4czd85BwV/ixlGUI9H2lhT+RvGKo fjDNRvKUZAeP9TR6ozbm1gi99J8DwKLGMHofnK28K3vWr/ny/EwJgCCc2xfqEQ1eI0rl 2M6GPjJT7d+75BZk7/hxh7F9d9VR57cfRDVsysE6h955sNXk+CqVcWXqGzB5hqJ7tqtW eoJDqZRxTPfioA3UlE8uBuYsZT5fr2F7gWUahSFAzQxOvMreYVMtWwNFnJ7UYJ02+pur d7Ow== X-Gm-Message-State: APjAAAWidYxIYiea0jZW8T9BI/4ZfFNJv7vc4NHSXStZFA4kJWckHy8V 1ggy0rXl7gvlepH40Dn7UkLVXMUo X-Google-Smtp-Source: APXvYqzVkryw7SjcIN9IN/dxd9W7ThdbrD5tdE/pg62E5PdugjXr/m3PMip3Rypds5X5yMBs+54dpA== X-Received: by 2002:a17:90a:db08:: with SMTP id g8mr1691679pjv.39.1565076547197; Tue, 06 Aug 2019 00:29:07 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id m6sm86445953pfb.151.2019.08.06.00.29.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 00:29:06 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Tue, 6 Aug 2019 16:29:03 +0900 Message-Id: <20190806072903.11586-1-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [spp] [PATCH] shared: move primary specific functions 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: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa Move functions for primary from `shared/common.c` to `primary/main.c`. * parse_num_clients() * get_sec_dir() Signed-off-by: Yasufumi Ogawa --- src/primary/args.c | 23 +++++++++++++++++++- src/primary/main.c | 26 +++++++++++++++++++++++ src/shared/common.c | 51 --------------------------------------------- src/shared/common.h | 11 ---------- 4 files changed, 48 insertions(+), 63 deletions(-) diff --git a/src/primary/args.c b/src/primary/args.c index 020e731..7df5557 100644 --- a/src/primary/args.c +++ b/src/primary/args.c @@ -71,6 +71,27 @@ parse_portmask(struct port_info *ports, uint16_t max_ports, return 0; } +/** + * Take the number of clients passed with `-n` option and convert to + * to a number to store in the num_clients variable. + */ +static int +parse_nof_rings(uint16_t *num_clients, const char *clients) +{ + char *end = NULL; + unsigned long temp; + + if (clients == NULL || *clients == '\0') + return -1; + + temp = strtoul(clients, &end, 10); + if (end == NULL || *end != '\0' || temp == 0) + return -1; + + *num_clients = (uint16_t)temp; + return 0; +} + /** * The application specific arguments follow the DPDK-specific * arguments which are stripped by the DPDK init. This function @@ -97,7 +118,7 @@ parse_app_args(uint16_t max_ports, int argc, char *argv[]) } break; case 'n': - if (parse_num_clients(&num_rings, optarg) != 0) { + if (parse_nof_rings(&num_rings, optarg) != 0) { usage(); return -1; } diff --git a/src/primary/main.c b/src/primary/main.c index 55bb532..afa26c4 100644 --- a/src/primary/main.c +++ b/src/primary/main.c @@ -192,6 +192,32 @@ do_send(int *connected, int *sock, char *str) return 0; } +/* Get directory name of given proc_name */ +static int get_sec_dir(char *proc_name, char *dir_name) +{ + if (!strcmp(proc_name, "spp_nfv")) { + sprintf(dir_name, "%s", "nfv"); + RTE_LOG(DEBUG, PRIMARY, "Found dir 'nfv' for '%s'.\n", + proc_name); + } else if (!strcmp(proc_name, "spp_vf")) { + sprintf(dir_name, "%s", "vf"); + RTE_LOG(DEBUG, PRIMARY, "Found dir 'vf' for '%s'.\n", + proc_name); + } else if (!strcmp(proc_name, "spp_mirror")) { + sprintf(dir_name, "%s", "mirror"); + RTE_LOG(DEBUG, PRIMARY, "Found dir 'mirror' for '%s'.\n", + proc_name); + } else if (!strcmp(proc_name, "spp_pcap")) { + sprintf(dir_name, "%s", "pcap"); + RTE_LOG(DEBUG, PRIMARY, "Found dir 'pcap' for '%s'.\n", + proc_name); + } else { + RTE_LOG(DEBUG, PRIMARY, "No dir found for '%s'.\n", + proc_name); + } + return 0; +} + /** * Launch secondary process of given name and ID. * diff --git a/src/shared/common.c b/src/shared/common.c index afdc774..3145617 100644 --- a/src/shared/common.c +++ b/src/shared/common.c @@ -43,31 +43,6 @@ set_user_log_debug(int num_user_log) return 0; } -/** - * Take the number of clients passed with `-n` option and convert to - * to a number to store in the num_clients variable. - * - * TODO(yasufum): Revise the usage of this function for spp_primary because - * it does not use for the number of ring ports, but clients. The name of - * function is inadequte. - */ -int -parse_num_clients(uint16_t *num_clients, const char *clients) -{ - char *end = NULL; - unsigned long temp; - - if (clients == NULL || *clients == '\0') - return -1; - - temp = strtoul(clients, &end, 10); - if (end == NULL || *end != '\0' || temp == 0) - return -1; - - *num_clients = (uint16_t)temp; - return 0; -} - int parse_server(char **server_ip, int *server_port, char *server_addr) { @@ -90,32 +65,6 @@ parse_server(char **server_ip, int *server_port, char *server_addr) return 0; } -/* Get directory name of given proc_name */ -int get_sec_dir(char *proc_name, char *dir_name) -{ - if (!strcmp(proc_name, "spp_nfv")) { - sprintf(dir_name, "%s", "nfv"); - RTE_LOG(DEBUG, SHARED, "Found dir 'nfv' for '%s'.\n", - proc_name); - } else if (!strcmp(proc_name, "spp_vf")) { - sprintf(dir_name, "%s", "vf"); - RTE_LOG(DEBUG, SHARED, "Found dir 'vf' for '%s'.\n", - proc_name); - } else if (!strcmp(proc_name, "spp_mirror")) { - sprintf(dir_name, "%s", "mirror"); - RTE_LOG(DEBUG, SHARED, "Found dir 'mirror' for '%s'.\n", - proc_name); - } else if (!strcmp(proc_name, "spp_pcap")) { - sprintf(dir_name, "%s", "pcap"); - RTE_LOG(DEBUG, SHARED, "Found dir 'pcap' for '%s'.\n", - proc_name); - } else { - RTE_LOG(DEBUG, SHARED, "No dir found for '%s'.\n", - proc_name); - } - return 0; -} - /** * Get port type and port ID from ethdev name, such as `eth_vhost1` which * can be retrieved with rte_eth_dev_get_name_by_port(). diff --git a/src/shared/common.h b/src/shared/common.h index e414522..cbd1bcf 100644 --- a/src/shared/common.h +++ b/src/shared/common.h @@ -123,19 +123,8 @@ int set_user_log_level(int num_user_log, uint32_t log_level); /* Set log level of type RTE_LOGTYPE_USER* to RTE_LOG_DEBUG. */ int set_user_log_debug(int num_user_log); -int parse_num_clients(uint16_t *num_clients, const char *clients); - int parse_server(char **server_ip, int *server_port, char *server_addr); -/** - * Get directory name of given proc_name. - * - * @param[in] proc_name Name of sec process such as spp_nfv. - * @param[out] dir_name Directory name. - * @return 0 - */ -int get_sec_dir(char *proc_name, char *dir_name); - extern uint8_t lcore_id_used[RTE_MAX_LCORE]; /** -- 2.17.1