From patchwork Thu Feb 20 08:02:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lukas Bartosik [C]" X-Patchwork-Id: 65949 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D62E6A0555; Thu, 20 Feb 2020 09:03:59 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AA8421BFF4; Thu, 20 Feb 2020 09:02:46 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 7203F1BFEF for ; Thu, 20 Feb 2020 09:02:43 +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 01K81pSO011750; Thu, 20 Feb 2020 00:02:42 -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=Kv5DjJR/tEArIZj3tRj6WHHmtf0AjIdh/PO+YLCmEoJDOki12Hr3HT4oZTXQcPFXjJ4r vEZ79O9JlBypmtwXKQcSvKG/PKWUVzmbvfK+dcby4hvFTfmTiMeEUVPjcaroHSA9Fo1W XU4Sa0/g4kegDzc5ai/uFg6G8z6TWDXha3xzcWe17WXJ2R0L++c+MnZ9ExKxquouGWI1 c7I7OUArqTWrogOU/H2sAUcdKUBwlhaNh4ziNoO43FRRwh3CqYDzcvTVPX2uPRLjYMUR ngVqw/n2H5+W4+kQ3HqkUIB1FpUEcaMguZoCnUARMFU4cP7I/T8KJO2E+1SXW3AM5xy0 2g== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2y8ubv6eb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 20 Feb 2020 00:02:42 -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, 20 Feb 2020 00:02:40 -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, 20 Feb 2020 00:02:40 -0800 Received: from luke.marvell.com (unknown [10.95.130.24]) by maili.marvell.com (Postfix) with ESMTP id B2FB03F7059; Thu, 20 Feb 2020 00:02:37 -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, 20 Feb 2020 09:02:01 +0100 Message-ID: <1582185727-6749-10-git-send-email-lbartosik@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582185727-6749-1-git-send-email-lbartosik@marvell.com> References: <1580824721-21527-1-git-send-email-lbartosik@marvell.com> <1582185727-6749-1-git-send-email-lbartosik@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-20_02:2020-02-19, 2020-02-20 signatures=0 Subject: [dpdk-dev] [PATCH v4 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