From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 606BBA0096 for ; Mon, 3 Jun 2019 19:40:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8CD0E1BBEE; Mon, 3 Jun 2019 19:37:10 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 3DBF71B9FB for ; Mon, 3 Jun 2019 19:37:08 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x53HKkeW000882; Mon, 3 Jun 2019 10:37:07 -0700 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-transfer-encoding : content-type; s=pfpt0818; bh=WUTU2yeKalcAKiiIgQpDfE1R6BIe6N1eIdyKyRwzf4w=; b=uZVUXBwnY4PzkG0zZL/Gx0ov6wwprup1SNGsz3RustuC6ZFr4ymoDKRNKe2RHtFttoeD 17CY03hN9TYIhzy7Iv6ey6Caj5J3BLAosgioU9Sir52rY+oKnDFSrKKJsNHR9+p3tZ8P vU+jmlrh8xWaNRd4c034TkFzM/1zUTfQcsSwS8mMUO/J7tjP0+9mqs9cNmQftexKOtm0 AO7HtV6FV4L0QofzXsj44fu4ptTR0V3iUm8ta37hjdgT3uhbgEwBxoWQVCPWSTGxImQP lHQRN08ZcIV6ndeUy5cGej8qQ4pg+YFUJ9pXQtxWWSgKHHiMgAYNxFFOb2PDvzKwS5DN rw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2sw2wmhdvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2019 10:36:49 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 3 Jun 2019 10:36:43 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 3 Jun 2019 10:36:43 -0700 Received: from ajoseph83.caveonetworks.com.com (unknown [10.29.45.56]) by maili.marvell.com (Postfix) with ESMTP id 7ABC43F703F; Mon, 3 Jun 2019 10:36:38 -0700 (PDT) From: Anoob Joseph To: Jerin Jacob , Nikhil Rao , "Erik Gabriel Carrillo" , Abhinandan Gujjar , Bruce Richardson , Pablo de Lara CC: Anoob Joseph , Narayana Prasad , , Lukasz Bartosik , Pavan Nikhilesh , Hemant Agrawal , "Nipun Gupta" , Harry van Haaren , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Liang Ma Date: Mon, 3 Jun 2019 23:02:33 +0530 Message-ID: <1559583160-13944-34-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559583160-13944-1-git-send-email-anoobj@marvell.com> References: <1559583160-13944-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-03_13:, , signatures=0 Subject: [dpdk-dev] [PATCH 33/39] eventdev: add Tx adapter support 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" Adding support for Tx adapter. Signed-off-by: Anoob Joseph Signed-off-by: Lukasz Bartosik --- lib/librte_eventdev/rte_eventmode_helper.c | 349 ++++++++++++++++++++- lib/librte_eventdev/rte_eventmode_helper.h | 24 ++ .../rte_eventmode_helper_internal.h | 30 ++ lib/librte_eventdev/rte_eventmode_helper_prints.c | 9 + 4 files changed, 399 insertions(+), 13 deletions(-) diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c index 77a5a4e..f237cab 100644 --- a/lib/librte_eventdev/rte_eventmode_helper.c +++ b/lib/librte_eventdev/rte_eventmode_helper.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "rte_eventmode_helper_internal.h" @@ -50,25 +51,51 @@ internal_parse_decimal(const char *str) return num; } +static int +internal_get_enabled_cores(unsigned int core_mask) +{ + int i; + int count = 0; + + RTE_LCORE_FOREACH(i) { + /* Check if this core is enabled in core_mask*/ + if (core_mask & (1 << i)) { + /* We have enabled core */ + count++; + } + } + return count; +} + static inline unsigned int -internal_get_next_rx_core(struct eventmode_conf *em_conf, - unsigned int prev_core) +internal_get_next_eth_core(struct eventmode_conf *em_conf) { unsigned int next_core; + static unsigned int prev_core = -1; + + /* + * Make sure we have atleast one eth core running, else the following + * logic would lead to an infinite loop. + */ + if (internal_get_enabled_cores(em_conf->eth_core_mask) == 0) { + RTE_EM_HLPR_LOG_INFO("No enabled eth core found"); + return RTE_MAX_LCORE; + } get_next_core: /* Get the next core */ - next_core = rte_get_next_lcore(prev_core, 0, 0); + next_core = rte_get_next_lcore(prev_core, 0, 1); /* Check if we have reached max lcores */ if (next_core == RTE_MAX_LCORE) return next_core; + /* Update prev_core */ + prev_core = next_core; + /* Only some cores would be marked as rx cores. Skip others */ - if (!(em_conf->eth_core_mask & (1 << next_core))) { - prev_core = next_core; + if (!(em_conf->eth_core_mask & (1 << next_core))) goto get_next_core; - } return next_core; } @@ -164,7 +191,7 @@ static void em_initialize_helper_conf(struct rte_eventmode_helper_conf *conf) { struct eventmode_conf *em_conf = NULL; - unsigned int rx_core_id; + unsigned int eth_core_id; /* Set default conf */ @@ -180,12 +207,21 @@ em_initialize_helper_conf(struct rte_eventmode_helper_conf *conf) /* Schedule type: ordered */ /* FIXME */ em_conf->ext_params.sched_type = RTE_SCHED_TYPE_ORDERED; - /* Set rx core. Use first core other than master core as Rx core */ - rx_core_id = rte_get_next_lcore(0, /* curr core */ - 1, /* skip master core */ - 0 /* wrap */); + /* 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 */); - em_conf->eth_core_mask = (1 << rx_core_id); + em_conf->eth_core_mask = (1 << 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 */); + + em_conf->eth_core_mask |= (1 << eth_core_id); } struct rte_eventmode_helper_conf * __rte_experimental @@ -354,7 +390,7 @@ rte_eventmode_helper_set_default_conf_rx_adapter(struct eventmode_conf *em_conf) /* Set adapter conf */ adapter->eventdev_id = eventdev_id; adapter->adapter_id = adapter_id; - adapter->rx_core_id = internal_get_next_rx_core(em_conf, -1); + adapter->rx_core_id = internal_get_next_eth_core(em_conf); /* * All queues of one eth device (port) will be mapped to one event @@ -403,6 +439,100 @@ rte_eventmode_helper_set_default_conf_rx_adapter(struct eventmode_conf *em_conf) } static int +rte_eventmode_helper_set_default_conf_tx_adapter(struct eventmode_conf *em_conf) +{ + int nb_eth_dev; + int eventdev_id; + int adapter_id; + int i; + int conn_id; + struct eventdev_params *eventdev_config; + struct tx_adapter_conf *tx_adapter; + struct tx_adapter_connection_info *conn; + + /* + * Create one Tx adapter with all eth queues mapped to event queues + * 1:1. + */ + + if (em_conf->nb_eventdev == 0) { + RTE_EM_HLPR_LOG_ERR("No event devs registered"); + return -1; + } + + /* Get the number of eth devs */ + nb_eth_dev = rte_eth_dev_count_avail(); + + /* Use the first event dev */ + eventdev_config = &(em_conf->eventdev_config[0]); + + /* Get eventdev ID */ + eventdev_id = eventdev_config->eventdev_id; + adapter_id = 0; + + /* Get adapter conf */ + tx_adapter = &(em_conf->tx_adapter[adapter_id]); + + /* Set adapter conf */ + tx_adapter->eventdev_id = eventdev_id; + tx_adapter->adapter_id = adapter_id; + + /* TODO: Tx core is required only when internal port is not present */ + + tx_adapter->tx_core_id = internal_get_next_eth_core(em_conf); + + /* + * Application would need to use one event queue per adapter for + * submitting packets for Tx. Reserving the last queue available + * and decrementing the total available event queues for this + */ + + /* Queue numbers start at 0 */ + tx_adapter->tx_ev_queue = eventdev_config->nb_eventqueue - 1; + + /* Update the number of event queues available in eventdev */ + eventdev_config->nb_eventqueue--; + + /* + * All Tx queues of the eth device (port) will be mapped to the event + * device. + */ + + /* Set defaults for connections */ + + /* + * One eth device (port) would be one connection. All Tx queues of + * the device would be mapped to the Tx adapter. + */ + + for (i = 0; i < nb_eth_dev; i++) { + + /* Use only the ports enabled */ + if ((em_conf->eth_portmask & (1 << i)) == 0) + continue; + + /* Get the connection id */ + conn_id = tx_adapter->nb_connections; + + /* Get the connection */ + conn = &(tx_adapter->conn[conn_id]); + + /* Add ethdev to connections */ + conn->ethdev_id = i; + + /* Add all eth tx queues to adapter */ + conn->ethdev_tx_qid = -1; + + /* Update no of connections */ + tx_adapter->nb_connections++; + } + + /* We have setup one adapter */ + em_conf->nb_tx_adapter = 1; + return 0; +} + +static int rte_eventmode_helper_set_default_conf_link(struct eventmode_conf *em_conf) { int i, j; @@ -501,6 +631,16 @@ rte_eventmode_helper_validate_conf(struct eventmode_conf *em_conf) } /* + * See if tx adapters are specified. Else generate a default conf + * with one tx adapter. + */ + if (em_conf->nb_tx_adapter == 0) { + ret = rte_eventmode_helper_set_default_conf_tx_adapter(em_conf); + if (ret != 0) + return ret; + } + + /* * See if links are specified. Else generate a default conf for * the event ports used. */ @@ -799,6 +939,150 @@ rte_eventmode_helper_initialize_rx_adapter(struct eventmode_conf *em_conf) return 0; } +static int +tx_adapter_configure(struct eventmode_conf *em_conf, + struct tx_adapter_conf *adapter) +{ + int ret, j; + uint8_t tx_port_id = 0; + uint8_t eventdev_id; + uint32_t service_id; + struct rte_event_port_conf port_conf = {0}; + struct rte_event_dev_info evdev_default_conf = {0}; + struct tx_adapter_connection_info *conn; + struct eventdev_params *eventdev_config; + + /* Get event dev ID */ + eventdev_id = adapter->eventdev_id; + + /* Get event device conf */ + eventdev_config = internal_get_eventdev_params(em_conf, eventdev_id); + + /* Create Tx adapter */ + + /* Get default configuration of event dev */ + ret = rte_event_dev_info_get(eventdev_id, &evdev_default_conf); + if (ret < 0) { + RTE_EM_HLPR_LOG_ERR( + "Error in getting event device info[devID:%d]", + eventdev_id); + return ret; + } + + /* Setup port conf */ + port_conf.new_event_threshold = + evdev_default_conf.max_num_events; + port_conf.dequeue_depth = + evdev_default_conf.max_event_port_dequeue_depth; + port_conf.enqueue_depth = + evdev_default_conf.max_event_port_enqueue_depth; + + /* Create Tx adapter */ + ret = rte_event_eth_tx_adapter_create(adapter->adapter_id, + adapter->eventdev_id, + &port_conf); + if (ret < 0) { + RTE_EM_HLPR_LOG_ERR("Error in Tx adapter creation"); + return ret; + } + + /* Setup various connections in the adapter */ + for (j = 0; j < adapter->nb_connections; j++) { + + /* Get connection */ + conn = &(adapter->conn[j]); + + /* Add queue to the adapter */ + ret = rte_event_eth_tx_adapter_queue_add( + adapter->adapter_id, + conn->ethdev_id, + conn->ethdev_tx_qid); + if (ret < 0) { + RTE_EM_HLPR_LOG_ERR( + "Error in adding eth queue in Tx adapter"); + return ret; + } + } + + /* Get event port used by the adapter */ + ret = rte_event_eth_tx_adapter_event_port_get( + adapter->adapter_id, + &tx_port_id); + if (ret) { + RTE_EM_HLPR_LOG_ERR("Failed to get Tx adapter port ID"); + return ret; + } + + /* + * TODO: event queue for Tx adapter is required only if the + * INTERNAL PORT is not present. + */ + + /* + * Tx event queue would be reserved for Tx adapter. Need to unlink + * this queue from all other ports + * + */ + for (j = 0; j < eventdev_config->nb_eventport; j++) { + rte_event_port_unlink(eventdev_id, j, + &(adapter->tx_ev_queue), 1); + } + + ret = rte_event_port_link( + eventdev_id, + tx_port_id, + &(adapter->tx_ev_queue), + NULL, 1); + if (ret != 1) { + RTE_EM_HLPR_LOG_ERR("Failed to link event queue to port"); + return ret; + } + + /* Get the service ID used by Tx adapter */ + ret = rte_event_eth_tx_adapter_service_id_get(adapter->adapter_id, + &service_id); + if (ret != -ESRCH && ret != 0) { + RTE_EM_HLPR_LOG_ERR( + "Error getting service ID used by adapter"); + return ret; + } + + /* + * TODO + * Tx core will invoke the service when required. The runstate check + * is not required. + * + */ + rte_service_set_runstate_mapped_check(service_id, 0); + + /* Start adapter */ + ret = rte_event_eth_tx_adapter_start(adapter->adapter_id); + if (ret) { + RTE_EM_HLPR_LOG_ERR("Error in starting Tx adapter"); + return ret; + } + + return 0; +} + +static int +rte_eventmode_helper_initialize_tx_adapter(struct eventmode_conf *em_conf) +{ + int i, ret; + struct tx_adapter_conf *adapter; + + /* Configure Tx adapters */ + for (i = 0; i < em_conf->nb_tx_adapter; i++) { + adapter = &(em_conf->tx_adapter[i]); + ret = tx_adapter_configure(em_conf, adapter); + if (ret < 0) { + RTE_EM_HLPR_LOG_ERR("Tx adapter configuration failed"); + return ret; + } + } + return 0; +} + int32_t __rte_experimental rte_eventmode_helper_initialize_devs( struct rte_eventmode_helper_conf *mode_conf) @@ -861,6 +1145,11 @@ rte_eventmode_helper_initialize_devs( if (ret != 0) return ret; + /* Setup Tx adapter */ + ret = rte_eventmode_helper_initialize_tx_adapter(em_conf); + if (ret != 0) + return ret; + /* Start eth devices after setting up adapter */ RTE_ETH_FOREACH_DEV(portid) { @@ -1001,6 +1290,7 @@ rte_eventmode_helper_start_worker_eth_core(struct eventmode_conf *em_conf, { uint32_t service_id[EVENT_MODE_MAX_ADAPTERS_PER_RX_CORE]; struct rx_adapter_conf *rx_adapter; + struct tx_adapter_conf *tx_adapter; int service_count = 0; int adapter_id; int32_t ret; @@ -1042,6 +1332,39 @@ rte_eventmode_helper_start_worker_eth_core(struct eventmode_conf *em_conf, service_count++; } + /* + * Need to parse adapter conf to see which all Tx adapters need to be + * handled this core. + */ + for (i = 0; i < em_conf->nb_tx_adapter; i++) { + /* Check if we have exceeded the max allowed */ + if (service_count > EVENT_MODE_MAX_ADAPTERS_PER_TX_CORE) { + RTE_EM_HLPR_LOG_ERR( + "Exceeded the max allowed adapters per Tx core"); + break; + } + + tx_adapter = &(em_conf->tx_adapter[i]); + if (tx_adapter->tx_core_id != lcore_id) + continue; + + /* Adapter need to be handled by this core */ + adapter_id = tx_adapter->adapter_id; + + /* Get the service ID for the adapters */ + ret = rte_event_eth_tx_adapter_service_id_get(adapter_id, + &(service_id[service_count])); + + if (ret != -ESRCH && ret != 0) { + RTE_EM_HLPR_LOG_ERR( + "Error getting service ID used by Tx adapter"); + return ret; + } + + /* Update service count */ + service_count++; + } + eth_core_running = true; while (eth_core_running) { diff --git a/lib/librte_eventdev/rte_eventmode_helper.h b/lib/librte_eventdev/rte_eventmode_helper.h index 1235ca4..2212622 100644 --- a/lib/librte_eventdev/rte_eventmode_helper.h +++ b/lib/librte_eventdev/rte_eventmode_helper.h @@ -10,6 +10,14 @@ extern "C" { #include #include +#include +#include + +/* Flag to indicate that the event device used by all adapters is same */ +#define RTE_EM_HELPER_TX_EV_LINK_COMMON_EVENT_DEV (1 << 0) + +/* Flag to indicate that the event queue to be used for all adapters is same */ +#define RTE_EM_HELPER_TX_EV_LINK_COMMON_EVENT_QUEUE (1 << 1) /* Packet transfer mode of the application */ enum rte_eventmode_helper_pkt_transfer_mode { @@ -55,6 +63,22 @@ struct rte_eventmode_helper_event_link_info { /**< Lcore to be polling on this port */ }; +/* + * Tx event queue - port link conf + * + * Application would need to know which event queue would correspond to which + * eth port, so that it can send out accordingly. + */ +struct rte_eventmode_helper_tx_ev_link_conf { + uint8_t flags; + struct { + uint8_t eventdev_id; + /**< Event device ID */ + uint8_t tx_ev_queue; + /**< Tx event queue */ + } ports[RTE_MAX_ETHPORTS]; +}; + /* Workers registered by the application */ struct rte_eventmode_helper_app_worker_params { union { diff --git a/lib/librte_eventdev/rte_eventmode_helper_internal.h b/lib/librte_eventdev/rte_eventmode_helper_internal.h index 906766c..1daca22 100644 --- a/lib/librte_eventdev/rte_eventmode_helper_internal.h +++ b/lib/librte_eventdev/rte_eventmode_helper_internal.h @@ -38,9 +38,15 @@ /* Max Rx adapters supported */ #define EVENT_MODE_MAX_RX_ADAPTERS RTE_EVENT_MAX_DEVS +/* Max Tx adapters supported */ +#define EVENT_MODE_MAX_TX_ADAPTERS RTE_EVENT_MAX_DEVS + /* Max Rx adapter connections */ #define EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER 16 +/* Max Tx adapter connections */ +#define EVENT_MODE_MAX_CONNECTIONS_PER_TX_ADAPTER 16 + /* Max event queues supported per event device */ #define EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV RTE_EVENT_MAX_QUEUES_PER_DEV @@ -51,6 +57,9 @@ /* Max adapters that one Rx core can handle */ #define EVENT_MODE_MAX_ADAPTERS_PER_RX_CORE EVENT_MODE_MAX_RX_ADAPTERS +/* Max adapters that one Tx core can handle */ +#define EVENT_MODE_MAX_ADAPTERS_PER_TX_CORE EVENT_MODE_MAX_TX_ADAPTERS + /* Event dev params */ struct eventdev_params { uint8_t eventdev_id; @@ -76,6 +85,23 @@ struct rx_adapter_conf { conn[EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER]; }; +/* Tx adapter connection info */ +struct tx_adapter_connection_info { + uint8_t ethdev_id; + int32_t ethdev_tx_qid; +}; + +/* Tx adapter conf */ +struct tx_adapter_conf { + int32_t eventdev_id; + int32_t adapter_id; + uint32_t tx_core_id; + uint8_t nb_connections; + struct tx_adapter_connection_info + conn[EVENT_MODE_MAX_CONNECTIONS_PER_TX_ADAPTER]; + uint8_t tx_ev_queue; +}; + /* Eventmode conf data */ struct eventmode_conf { int nb_eventdev; @@ -86,6 +112,10 @@ struct eventmode_conf { /**< No of Rx adapters */ struct rx_adapter_conf rx_adapter[EVENT_MODE_MAX_RX_ADAPTERS]; /**< Rx adapter conf */ + uint8_t nb_tx_adapter; + /**< No of Tx adapters */ + struct tx_adapter_conf tx_adapter[EVENT_MODE_MAX_TX_ADAPTERS]; + /** Tx adapter conf */ uint8_t nb_link; /**< No of links */ struct rte_eventmode_helper_event_link_info diff --git a/lib/librte_eventdev/rte_eventmode_helper_prints.c b/lib/librte_eventdev/rte_eventmode_helper_prints.c index 3114d29..387302a 100644 --- a/lib/librte_eventdev/rte_eventmode_helper_prints.c +++ b/lib/librte_eventdev/rte_eventmode_helper_prints.c @@ -95,6 +95,12 @@ rte_eventmode_display_rx_adapter_conf(struct eventmode_conf *em_conf) } static void +rte_eventmode_display_tx_adapter_conf(struct eventmode_conf *em_conf) +{ + RTE_SET_USED(em_conf); +} + +static void rte_eventmode_display_link_conf(struct eventmode_conf *em_conf) { int i; @@ -155,6 +161,9 @@ rte_eventmode_helper_display_conf(struct rte_eventmode_helper_conf *mode_conf) /* Display Rx adapter conf */ rte_eventmode_display_rx_adapter_conf(em_conf); + /* Display Tx adapter conf */ + rte_eventmode_display_tx_adapter_conf(em_conf); + /* Display event-lcore link */ rte_eventmode_display_link_conf(em_conf); } -- 2.7.4