From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07621A0544; Fri, 2 Sep 2022 15:10:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB57E40A81; Fri, 2 Sep 2022 15:10:55 +0200 (CEST) Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by mails.dpdk.org (Postfix) with ESMTP id 0749940685 for ; Fri, 2 Sep 2022 15:10:55 +0200 (CEST) Received: by mail-qt1-f176.google.com with SMTP id h22so1399160qtu.2 for ; Fri, 02 Sep 2022 06:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=4NVXEwJ6mzrxXRt5+jTfPa9lr7wqxFw17naAXB3vRCo=; b=SxsaqOprNDejUBhjCqHidxuMggl4fKn/WuiFYTPv9sOHdZPh13xabNHwDObZdbw7ZD BQs1Sb6X6VIIMgV9SFX3R7yZIRV6QahoOX5gQ4RvW+V503jyE9xTV+W542M8lKKQ+60W QHtLSFpguid0Fw5a0v0xBiliQ6iNL1sH3MNwyLEqBbTpFEt3qNFgP8+rZFNYWhLt07zL AoeFkN/CbhzY1FySULB4rtCwrtPz0M9aq7HEFWKcC+g2DGpVJNvsvZyzBWHsbfbdtINC ApVN4l7sKeTUwCZLfV3TaGAFHCcZXRTGj/CWrn49Foj4i9IPr7d0TtEEoRYEcaqWt3mG QT2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=4NVXEwJ6mzrxXRt5+jTfPa9lr7wqxFw17naAXB3vRCo=; b=4BDxBvB7ZurfW/mlJrVKXdPE+NKygCG7bdcmjRuEfSSQQoCv0o5J49JtRjhlq+x4E8 6Q+uZ2zfLPCcdwtKBk0KZLLE2mDx9vWfZg61CAZ7MMqbm9rUc8IEg5C1VgqCSuOfdp/H 2V5R3YUc7lvAl65n82gdSVUOJNkeBAt4Ninp72cnvjk+ixJ+oq87pxgwivbhnWWfs2IN fouAVz2qw/xfu6mnXPLtzCijwFfBvTy6A0rUYtVSUGX15YDgfCe3CqvDXsI8VBzjry3k rZk+zr2tI5q35qUdmR0LbH4EhZe1dedRVjuCvW0iTdnxkVl5OOeCQhy0ff3D3k4qyT2I XO6g== X-Gm-Message-State: ACgBeo0c5MukG88Roa8UfqxzQg+7/fOc1zM5UgQ+YprDkNTcBDhe1rbc Pm6F7V5G/PZyKjjMvj0CLEO8qgCW237wzO9E+SM= X-Google-Smtp-Source: AA6agR52dW/Bh3fisKQSJeuKq6WQQ4JrFi0uVOsHy+igeS/Mi5iyDfq/wxcXrH7GOJ6NfGLXgGArgyL0HuNGm+GsMyc= X-Received: by 2002:ac8:4e92:0:b0:342:fb5b:5864 with SMTP id 18-20020ac84e92000000b00342fb5b5864mr27966822qtp.410.1662124254227; Fri, 02 Sep 2022 06:10:54 -0700 (PDT) MIME-Version: 1.0 References: <20220719082538.274845-1-ganapati.kundapura@intel.com> <20220829081437.3114188-1-ganapati.kundapura@intel.com> <20220829081437.3114188-4-ganapati.kundapura@intel.com> In-Reply-To: <20220829081437.3114188-4-ganapati.kundapura@intel.com> From: Jerin Jacob Date: Fri, 2 Sep 2022 18:40:28 +0530 Message-ID: Subject: Re: [PATCH v12 4/6] eventdev/eth_tx: add instance get API To: Ganapati Kundapura Cc: dpdk-dev , Jerin Jacob , "Jayatheerthan, Jay" , "Naga Harish K, S V" Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, Aug 29, 2022 at 1:45 PM Ganapati Kundapura wrote: > > Added rte_event_eth_tx_adapter_instance_get() to get the > adapter instance id for specified ethernet device id and > tx queue index. > > Added rte_event_eth_tx_adapter_instance_get() details in > prog_guide/event_ethernet_tx_adapter.rst > > Signed-off-by: Ganapati Kundapura > > Reviewed-by: Naga Harish K S V > Acked-by: Jay Jayatheerthan Acked-by: Jerin Jacob > > diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst > index f80d226..4da9bcd 100644 > --- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst > +++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst > @@ -165,6 +165,12 @@ in struct ``rte_event_eth_tx_adapter_stats``. The counter values are the sum of > the counts from the eventdev PMD callback if the callback is supported, and > the counts maintained by the service function, if one exists. > > +Getting Adapter instance id > +~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + > +The ``rte_event_eth_tx_adapter_instance_get()`` function reports > +tx adapter instance id for a specified ethernet device id and tx queue index. > + > Tx event vectorization > ~~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h > index c58ba05..f514a37 100644 > --- a/lib/eventdev/eventdev_pmd.h > +++ b/lib/eventdev/eventdev_pmd.h > @@ -1274,6 +1274,27 @@ typedef int (*eventdev_eth_tx_adapter_stats_get_t)( > typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id, > const struct rte_eventdev *dev); > > +/** > + * Get TX adapter instance id for TX queue > + * > + * @param eth_dev_id > + * Port identifier of Ethernet device > + * > + * @param tx_queue_id > + * Ethernet device TX queue index > + * > + * @param[out] txa_inst_id > + * Pointer to TX adapter instance identifier > + * Contains valid Tx adapter instance id when return value is 0 > + * > + * @return > + * - 0: Success > + * - <0: Error code on failure > + */ > +typedef int (*eventdev_eth_tx_adapter_instance_get_t) > + (uint16_t eth_dev_id, uint16_t tx_queue_id, uint8_t *txa_inst_id); > + > + > /** Event device operations function pointer table */ > struct eventdev_ops { > eventdev_info_get_t dev_infos_get; /**< Get device info. */ > @@ -1386,6 +1407,8 @@ struct eventdev_ops { > /**< Get eth Tx adapter statistics */ > eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset; > /**< Reset eth Tx adapter statistics */ > + eventdev_eth_tx_adapter_instance_get_t eth_tx_adapter_instance_get; > + /**< Get Tx adapter instance id for Tx queue */ > > eventdev_selftest dev_selftest; > /**< Start eventdev Selftest */ > diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c > index b4b37f1..aaef352 100644 > --- a/lib/eventdev/rte_event_eth_tx_adapter.c > +++ b/lib/eventdev/rte_event_eth_tx_adapter.c > @@ -18,6 +18,9 @@ > #define TXA_INVALID_DEV_ID INT32_C(-1) > #define TXA_INVALID_SERVICE_ID INT64_C(-1) > > +#define TXA_ADAPTER_ARRAY "txa_adapter_array" > +#define TXA_SERVICE_DATA_ARRAY "txa_service_data_array" > + > #define txa_evdev(id) (&rte_eventdevs[txa_dev_id_array[(id)]]) > > #define txa_dev_caps_get(id) txa_evdev((id))->dev_ops->eth_tx_adapter_caps_get > @@ -41,6 +44,9 @@ > > #define txa_dev_stats_get(t) txa_evdev(t)->dev_ops->eth_tx_adapter_stats_get > > +#define txa_dev_instance_get(id) \ > + txa_evdev(id)->dev_ops->eth_tx_adapter_instance_get > + > #define RTE_EVENT_ETH_TX_ADAPTER_ID_VALID_OR_ERR_RET(id, retval) \ > do { \ > if (!txa_valid_id(id)) { \ > @@ -194,12 +200,34 @@ txa_memzone_array_get(const char *name, unsigned int elt_size, int nb_elems) > } > > static int > +txa_lookup(void) > +{ > + const struct rte_memzone *mz; > + > + if (txa_dev_id_array == NULL) { > + mz = rte_memzone_lookup(TXA_ADAPTER_ARRAY); > + if (mz == NULL) > + return -ENOMEM; > + txa_dev_id_array = mz->addr; > + } > + > + if (txa_service_data_array == NULL) { > + mz = rte_memzone_lookup(TXA_SERVICE_DATA_ARRAY); > + if (mz == NULL) > + return -ENOMEM; > + txa_service_data_array = mz->addr; > + } > + > + return 0; > +} > + > +static int > txa_dev_id_array_init(void) > { > if (txa_dev_id_array == NULL) { > int i; > > - txa_dev_id_array = txa_memzone_array_get("txa_adapter_array", > + txa_dev_id_array = txa_memzone_array_get(TXA_ADAPTER_ARRAY, > sizeof(int), > RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE); > if (txa_dev_id_array == NULL) > @@ -222,12 +250,18 @@ static int > txa_service_data_init(void) > { > if (txa_service_data_array == NULL) { > + int i; > + > txa_service_data_array = > - txa_memzone_array_get("txa_service_data_array", > + txa_memzone_array_get(TXA_SERVICE_DATA_ARRAY, > sizeof(*txa_service_data_array), > RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE); > if (txa_service_data_array == NULL) > return -ENOMEM; > + > + /* Reset the txa service pointers */ > + for (i = 0; i < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; i++) > + txa_service_data_array[i] = NULL; > } > > return 0; > @@ -1222,3 +1256,67 @@ rte_event_eth_tx_adapter_stop(uint8_t id) > rte_eventdev_trace_eth_tx_adapter_stop(id, ret); > return ret; > } > + > +int > +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id, > + uint16_t tx_queue_id, > + uint8_t *txa_inst_id) > +{ > + uint8_t id; > + int ret = -EINVAL; > + uint32_t caps; > + struct txa_service_data *txa; > + > + if (txa_lookup()) > + return -ENOMEM; > + > + if (eth_dev_id >= rte_eth_dev_count_avail()) { > + RTE_EDEV_LOG_ERR("Invalid ethernet port id %u", eth_dev_id); > + return -EINVAL; > + } > + > + if (tx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_tx_queues) { > + RTE_EDEV_LOG_ERR("Invalid tx queue id %u", tx_queue_id); > + return -EINVAL; > + } > + > + if (txa_inst_id == NULL) { > + RTE_EDEV_LOG_ERR("txa_instance_id cannot be NULL"); > + return -EINVAL; > + } > + > + /* Iterate through all Tx adapter instances */ > + for (id = 0; id < RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE; id++) { > + txa = txa_service_id_to_data(id); > + if (!txa) > + continue; > + > + caps = 0; > + if (rte_event_eth_tx_adapter_caps_get(txa->eventdev_id, > + eth_dev_id, > + &caps)) > + continue; > + > + if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) { > + ret = txa_dev_instance_get(id) ? > + txa_dev_instance_get(id)(eth_dev_id, > + tx_queue_id, > + txa_inst_id) > + : -EINVAL; > + if (ret == 0) > + return ret; > + } else { > + struct rte_eth_dev *eth_dev; > + > + eth_dev = &rte_eth_devices[eth_dev_id]; > + > + if (txa_service_is_queue_added(txa, eth_dev, > + tx_queue_id)) { > + *txa_inst_id = txa->id; > + return 0; > + } > + } > + } > + > + return -EINVAL; > +} > diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h > index 3908c2d..9432b74 100644 > --- a/lib/eventdev/rte_event_eth_tx_adapter.h > +++ b/lib/eventdev/rte_event_eth_tx_adapter.h > @@ -34,6 +34,7 @@ > * - rte_event_eth_tx_adapter_enqueue() > * - rte_event_eth_tx_adapter_event_port_get() > * - rte_event_eth_tx_adapter_service_id_get() > + * - rte_event_eth_tx_adapter_instance_get() > * > * The application creates the adapter using > * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext(). > @@ -423,6 +424,29 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id); > int > rte_event_eth_tx_adapter_service_id_get(uint8_t id, uint32_t *service_id); > > +/** > + * Get TX adapter instance id for TX queue > + * > + * @param eth_dev_id > + * Port identifier of Ethernet device > + * > + * @param tx_queue_id > + * Etherdev device TX queue index > + * > + * @param[out] txa_inst_id > + * Pointer to TX adapter instance identifier > + * Contains valid Tx adapter instance id when return value is 0 > + * > + * @return > + * - 0: Success > + * - <0: Error code on failure > + */ > +__rte_experimental > +int > +rte_event_eth_tx_adapter_instance_get(uint16_t eth_dev_id, > + uint16_t tx_queue_id, > + uint8_t *txa_inst_id); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map > index 0066187..9a71cf3 100644 > --- a/lib/eventdev/version.map > +++ b/lib/eventdev/version.map > @@ -115,6 +115,7 @@ EXPERIMENTAL { > > # added in 22.11 > rte_event_eth_rx_adapter_instance_get; > + rte_event_eth_tx_adapter_instance_get; > }; > > INTERNAL { > -- > 2.6.4 >