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 18666A055F; Thu, 27 Feb 2020 17:20:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A0411C026; Thu, 27 Feb 2020 17:19:16 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 3CC5D2C4F for ; Thu, 27 Feb 2020 17:19:12 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01RFsgap002477; Thu, 27 Feb 2020 08:19:11 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=56hv1fEUQpgjUcj/adH7rv695hZsV2WEQpocMqORJwM=; b=l4nmXV/VjvOshxJEreDvASRjVt9eQpzuauheGKzAE2YvQfCsrO9B+pbulrOJ/BL0LPgy TLsnVIGhUDOLtp21LY/6Tg/g97YYIRZJxX2Snmm9mtd4nJHmInXwyTERwzWQcsgqQCm0 lCqmMbUJZt4982ndfc/1341KACFGJ2pVNLRRIYWiFWfJkl9B503pojmJs2QYYyQy/yk+ 0NdsTr6H37OH+XpnMuHQS4lHJ+Z6rz/sUDqxpUkbnMS/Qa6ukfqkNIvdWZmurAU1v0sw lUIRWkOsBsZLOHMB0ZIJh18midefWRG9srzcapOpH9IEFgp9FVHw5N7X57WV/diK0q6K Xw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2ydchth8g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 27 Feb 2020 08:19:11 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 27 Feb 2020 08:19:09 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 27 Feb 2020 08:19:09 -0800 Received: from luke.marvell.com (unknown [10.95.130.81]) by maili.marvell.com (Postfix) with ESMTP id A389B3F704C; Thu, 27 Feb 2020 08:19:06 -0800 (PST) From: Lukasz Bartosik To: Akhil Goyal , Radu Nicolau , Thomas Monjalon CC: Jerin Jacob , Narayana Prasad , Ankur Dwivedi , Anoob Joseph , Archana Muniganti , Tejasree Kondoj , Vamsi Attunuru , "Konstantin Ananyev" , Date: Thu, 27 Feb 2020 17:18:31 +0100 Message-ID: <1582820317-7333-10-git-send-email-lbartosik@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582820317-7333-1-git-send-email-lbartosik@marvell.com> References: <1582185727-6749-1-git-send-email-lbartosik@marvell.com> <1582820317-7333-1-git-send-email-lbartosik@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-27_05:2020-02-26, 2020-02-27 signatures=0 Subject: [dpdk-dev] [PATCH v5 09/15] examples/ipsec-secgw: add event helper config init/uninit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add eventmode helper eh_conf_init and eh_conf_uninit functions which purpose is to initialize and unitialize eventmode helper configuration. Signed-off-by: Anoob Joseph Signed-off-by: Lukasz Bartosik --- examples/ipsec-secgw/event_helper.c | 103 ++++++++++++++++++++++++++++++++++++ examples/ipsec-secgw/event_helper.h | 23 ++++++++ 2 files changed, 126 insertions(+) diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/event_helper.c index fe047ab..0854fc2 100644 --- a/examples/ipsec-secgw/event_helper.c +++ b/examples/ipsec-secgw/event_helper.c @@ -1379,6 +1379,109 @@ eh_display_link_conf(struct eventmode_conf *em_conf) EH_LOG_INFO(""); } +struct eh_conf * +eh_conf_init(void) +{ + struct eventmode_conf *em_conf = NULL; + struct eh_conf *conf = NULL; + unsigned int eth_core_id; + void *bitmap = NULL; + uint32_t nb_bytes; + + /* Allocate memory for config */ + conf = calloc(1, sizeof(struct eh_conf)); + if (conf == NULL) { + EH_LOG_ERR("Failed to allocate memory for eventmode helper " + "config"); + return NULL; + } + + /* Set default conf */ + + /* Packet transfer mode: poll */ + conf->mode = EH_PKT_TRANSFER_MODE_POLL; + + /* Keep all ethernet ports enabled by default */ + conf->eth_portmask = -1; + + /* Allocate memory for event mode params */ + conf->mode_params = calloc(1, sizeof(struct eventmode_conf)); + if (conf->mode_params == NULL) { + EH_LOG_ERR("Failed to allocate memory for event mode params"); + goto free_conf; + } + + /* Get eventmode conf */ + em_conf = conf->mode_params; + + /* Allocate and initialize bitmap for eth cores */ + nb_bytes = rte_bitmap_get_memory_footprint(RTE_MAX_LCORE); + if (!nb_bytes) { + EH_LOG_ERR("Failed to get bitmap footprint"); + goto free_em_conf; + } + + bitmap = rte_zmalloc("event-helper-ethcore-bitmap", nb_bytes, + RTE_CACHE_LINE_SIZE); + if (!bitmap) { + EH_LOG_ERR("Failed to allocate memory for eth cores bitmap\n"); + goto free_em_conf; + } + + em_conf->eth_core_mask = rte_bitmap_init(RTE_MAX_LCORE, bitmap, + nb_bytes); + if (!em_conf->eth_core_mask) { + EH_LOG_ERR("Failed to initialize bitmap"); + goto free_bitmap; + } + + /* Set schedule type as not set */ + em_conf->ext_params.sched_type = SCHED_TYPE_NOT_SET; + + /* Set two cores as eth cores for Rx & Tx */ + + /* Use first core other than master core as Rx core */ + eth_core_id = rte_get_next_lcore(0, /* curr core */ + 1, /* skip master core */ + 0 /* wrap */); + + rte_bitmap_set(em_conf->eth_core_mask, eth_core_id); + + /* Use next core as Tx core */ + eth_core_id = rte_get_next_lcore(eth_core_id, /* curr core */ + 1, /* skip master core */ + 0 /* wrap */); + + rte_bitmap_set(em_conf->eth_core_mask, eth_core_id); + + return conf; + +free_bitmap: + rte_free(bitmap); +free_em_conf: + free(em_conf); +free_conf: + free(conf); + return NULL; +} + +void +eh_conf_uninit(struct eh_conf *conf) +{ + struct eventmode_conf *em_conf = NULL; + + if (!conf || !conf->mode_params) + return; + + /* Get eventmode conf */ + em_conf = conf->mode_params; + + /* Free evenmode configuration memory */ + rte_free(em_conf->eth_core_mask); + free(em_conf); + free(conf); +} + void eh_display_conf(struct eh_conf *conf) { diff --git a/examples/ipsec-secgw/event_helper.h b/examples/ipsec-secgw/event_helper.h index 25c8563..e17cab1 100644 --- a/examples/ipsec-secgw/event_helper.h +++ b/examples/ipsec-secgw/event_helper.h @@ -46,6 +46,9 @@ /* Max adapters that one Tx core can handle */ #define EVENT_MODE_MAX_ADAPTERS_PER_TX_CORE EVENT_MODE_MAX_TX_ADAPTERS +/* Used to indicate that queue schedule type is not set */ +#define SCHED_TYPE_NOT_SET 3 + /** * Packet transfer mode of the application */ @@ -200,6 +203,26 @@ struct eh_app_worker_params { }; /** + * Allocate memory for event helper configuration and initialize + * it with default values. + * + * @return + * - pointer to event helper configuration structure on success. + * - NULL on failure. + */ +struct eh_conf * +eh_conf_init(void); + +/** + * Uninitialize event helper configuration and release its memory +. * + * @param conf + * Event helper configuration + */ +void +eh_conf_uninit(struct eh_conf *conf); + +/** * Initialize event mode devices * * Application can call this function to get the event devices, eth devices -- 2.7.4