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 41E40A04C5; Fri, 4 Sep 2020 12:19:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C2CD1C0D5; Fri, 4 Sep 2020 12:19:09 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 547D31C0CC for ; Fri, 4 Sep 2020 12:19:06 +0200 (CEST) IronPort-SDR: 4dYoq56K1Az0x/a6lcBSldumIToCkrjjbjrIvLKdp2fbtHlCBB8F8zQPjlhXCEdAXoejrvUl9m FvTvxixarHxw== X-IronPort-AV: E=McAfee;i="6000,8403,9733"; a="175774415" X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="175774415" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2020 03:19:05 -0700 IronPort-SDR: 1hK7tYXt9ZEX52o45YJRUO1hy9KZpaRjiHke9gcKSPj7Bo9/NOY8BklE9KeN6RFFIkeb78Q5nN ltJqonJOW9aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="334809998" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 04 Sep 2020 03:19:04 -0700 Received: from sivswdev09.ir.intel.com (sivswdev09.ir.intel.com [10.237.217.48]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 084AJ3s5030495; Fri, 4 Sep 2020 11:19:03 +0100 Received: from sivswdev09.ir.intel.com (localhost [127.0.0.1]) by sivswdev09.ir.intel.com with ESMTP id 084AJ37w003990; Fri, 4 Sep 2020 11:19:03 +0100 Received: (from lma25@localhost) by sivswdev09.ir.intel.com with LOCAL id 084AJ3Qq003986; Fri, 4 Sep 2020 11:19:03 +0100 From: Liang Ma To: dev@dpdk.org Cc: david.hunt@intel.com, anatoly.burakov@intel.com, Liang Ma Date: Fri, 4 Sep 2020 11:18:56 +0100 Message-Id: <1599214740-3927-2-git-send-email-liang.j.ma@intel.com> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1599214740-3927-1-git-send-email-liang.j.ma@intel.com> References: <1597141666-20621-1-git-send-email-liang.j.ma@intel.com> <1599214740-3927-1-git-send-email-liang.j.ma@intel.com> Subject: [dpdk-dev] [PATCH v3 2/6] ethdev: add simple power management API 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 a simple API allow ethdev get the last available queue descriptor address from PMD. Also include internal structure update. Signed-off-by: Liang Ma Signed-off-by: Anatoly Burakov --- lib/librte_ethdev/rte_ethdev.h | 22 ++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 46 +++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 70295d7ab7..d9312d3e11 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -157,6 +157,7 @@ extern "C" { #include #include #include +#include #include "rte_ethdev_trace_fp.h" #include "rte_dev_info.h" @@ -775,6 +776,7 @@ rte_eth_rss_hf_refine(uint64_t rss_hf) /** Maximum nb. of vlan per mirror rule */ #define ETH_MIRROR_MAX_VLANS 64 +#define ETH_EMPTYPOLL_MAX 512 /**< Empty poll number threshlold */ #define ETH_MIRROR_VIRTUAL_POOL_UP 0x01 /**< Virtual Pool uplink Mirroring. */ #define ETH_MIRROR_UPLINK_PORT 0x02 /**< Uplink Port Mirroring. */ #define ETH_MIRROR_DOWNLINK_PORT 0x04 /**< Downlink Port Mirroring. */ @@ -1602,6 +1604,26 @@ enum rte_eth_dev_state { RTE_ETH_DEV_REMOVED, }; +#define RTE_ETH_PAUSE_NUM 64 /* How many times to pause */ +/** + * Possible power management states of an ethdev port. + */ +enum rte_eth_dev_power_mgmt_state { + /** Device power management is disabled. */ + RTE_ETH_DEV_POWER_MGMT_DISABLED = 0, + /** Device power management is enabled. */ + RTE_ETH_DEV_POWER_MGMT_ENABLED, +}; + +enum rte_eth_dev_power_mgmt_cb_mode { + /** WAIT callback mode. */ + RTE_ETH_DEV_POWER_MGMT_CB_WAIT = 1, + /** PAUSE callback mode. */ + RTE_ETH_DEV_POWER_MGMT_CB_PAUSE, + /** Freq Scaling callback mode. */ + RTE_ETH_DEV_POWER_MGMT_CB_SCALE, +}; + struct rte_eth_dev_sriov { uint8_t active; /**< SRIOV is active with 16, 32 or 64 pools */ uint8_t nb_q_per_pool; /**< rx queue number per pool */ diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h index 32407dd418..16e54bb4e4 100644 --- a/lib/librte_ethdev/rte_ethdev_core.h +++ b/lib/librte_ethdev/rte_ethdev_core.h @@ -603,6 +603,30 @@ typedef int (*eth_tx_hairpin_queue_setup_t) uint16_t nb_tx_desc, const struct rte_eth_hairpin_conf *hairpin_conf); +/** + * @internal + * Get the next RX ring descriptor address. + * + * @param rxq + * ethdev queue pointer. + * @param tail_desc_addr + * the pointer point to descriptor address var. + * @param expected + * the pointer point to value to be expected when descriptor is set. + * @param mask + * the pointer point to comparison bitmask for the expected value. + * @return + * Negative errno value on error, 0 on success. + * + * @retval 0 + * Success. + * @retval -EINVAL + * Failed to get descriptor address. + */ +typedef int (*eth_next_rx_desc_t) + (void *rxq, volatile void **tail_desc_addr, + uint64_t *expected, uint64_t *mask); + /** * @internal A structure containing the functions exported by an Ethernet driver. */ @@ -752,6 +776,8 @@ struct eth_dev_ops { /**< Set up device RX hairpin queue. */ eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup; /**< Set up device TX hairpin queue. */ + eth_next_rx_desc_t next_rx_desc; + /**< Get next RX ring descriptor address. */ }; /** @@ -768,6 +794,14 @@ struct rte_eth_rxtx_callback { void *param; }; +/** + * @internal + * Structure used to hold counters for empty poll + */ +struct rte_eth_ep_stat { + uint64_t num; +} __rte_cache_aligned; + /** * @internal * The generic data structure associated with each ethernet device. @@ -807,8 +841,16 @@ struct rte_eth_dev { enum rte_eth_dev_state state; /**< Flag indicating the port state */ void *security_ctx; /**< Context for security ops */ - uint64_t reserved_64s[4]; /**< Reserved for future fields */ - void *reserved_ptrs[4]; /**< Reserved for future fields */ + /**< Empty poll number */ + enum rte_eth_dev_power_mgmt_state pwr_mgmt_state; + /**< Power mgmt Callback mode */ + enum rte_eth_dev_power_mgmt_cb_mode cb_mode; + uint64_t reserved_64s[3]; /**< Reserved for future fields */ + + /**< Flag indicating the port power state */ + struct rte_eth_ep_stat *empty_poll_stats; + const struct rte_eth_rxtx_callback *cur_pwr_cb; + void *reserved_ptrs[2]; /**< Reserved for future fields */ } __rte_cache_aligned; struct rte_eth_dev_sriov; -- 2.17.1