From patchwork Tue Jan 7 14:56:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Hardy X-Patchwork-Id: 64274 X-Patchwork-Delegate: ferruh.yigit@amd.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 B78FDA046B; Tue, 7 Jan 2020 15:57:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4FF121D9C2; Tue, 7 Jan 2020 15:57:28 +0100 (CET) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by dpdk.org (Postfix) with ESMTP id CBEC61D9B0 for ; Tue, 7 Jan 2020 15:57:26 +0100 (CET) Received: by mail-wm1-f66.google.com with SMTP id c127so14382713wme.1 for ; Tue, 07 Jan 2020 06:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IUMs+isQjToFjSGsYXcl6Sbc2s0qHfrj4l8Mkd7P5FA=; b=PsJ5aZYOFJZ/rHSh/gxL7EM4bwbkcD1V0B8FvPf4Y0ZKpCHu/rMrW78BEc3sscanwQ 0wZGdESDxTW/d+4dAq0aD1t5bcEdaALypTrsRdA3NSwfLR+noYP0DfAfWhnbRwlT65bK epAxF5kOJhj7D7dhkjMYeHGoFe80VwuBoiOafw9IrZLEmERyt8CDCg211RT0jVl6Jp2Y eT85AI0c92yVPdraLmZpeoqqnz5ewt9w67X3NsMWmAxGWveqDB2tv/18Ox42uMjt+4AK KEJjVZlVwfTK0cJGEFUqIaais7maiK+Ez7W/7KQW8XXTWrqKJHTX4/LZWOpoDiWmDUVj fNaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IUMs+isQjToFjSGsYXcl6Sbc2s0qHfrj4l8Mkd7P5FA=; b=QQvJjzrhEiuRUMW7Mm+l0GJTST1muWY1RCjAeXDezd86IEva2sQZuvZGithGNZgbyl GH6HgLIy3i9JVqMXUm6gJgiMTFjWVBEwN18wlTFsGuyv97rhAjLmqfcCtEymOlqLNYcm XK0ifcO6UmJsdHgIz3t6NuOz4zrgKMC2cQ26w69cgM5c6DHXJz0VgbWgO5NdB4yNYYiq M2R0pAm0w42qzPfGI5bjEUMVcmG3I5Oq1rt3nwzFXZ5ksb5eAq3Z3VEgI3VOzmnH9kRc DvLteXZcutlj1vtqkTozL5Gdysf13yl8YkXLzkxgEa8Z/dn3wMVFBys+2me6l4D94vj5 1MOw== X-Gm-Message-State: APjAAAU+YFiyMuGwB9jWLky9t0XRVx6sIkd1XfjPZXgodglTvShAoGb1 6xgJi7JFq9WvmyY9JdJSUGnc/b2m/R0= X-Google-Smtp-Source: APXvYqzXaj3WW2Suu/MKNWg2cXsBaykvtb+3/+p1uWQQZQVsQ/x0bikeqPMOPK2yqNJH271aktcTxA== X-Received: by 2002:a05:600c:2409:: with SMTP id 9mr38148057wmp.109.1578409046043; Tue, 07 Jan 2020 06:57:26 -0800 (PST) Received: from sphinx.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id f17sm27257216wmc.8.2020.01.07.06.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 06:57:24 -0800 (PST) From: Laurent Hardy To: dev@dpdk.org Cc: olivier.matz@6wind.com Date: Tue, 7 Jan 2020 15:56:37 +0100 Message-Id: <20200107145637.8922-1-laurent.hardy@6wind.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] librte_ethdev: extend dpdk api led control to query capability 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" In current led control API we have no way to know if a device is able to handle on/off requests coming from the application. Knowing if the device is led control capable could be useful to avoid exchanges between application and kernel. Using the on/off requests to flag if the device is led control capable (based on the ENOSUP returned error) is not convenient as such request can change the led state on device. This patch adds a new function rte_eth_led_ctrl_capable() that will look for led_off/on dev ops availability on the related pmd, to know if the device is able to handle such led control requests (on/off). Signed-off-by: Laurent Hardy --- doc/guides/nics/features.rst | 5 +++++ lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ lib/librte_ethdev/rte_ethdev.h | 15 +++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 4 ++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 5 files changed, 37 insertions(+) diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index 8394a6595..012645dc5 100644 --- a/doc/guides/nics/features.rst +++ b/doc/guides/nics/features.rst @@ -732,6 +732,11 @@ registers and register size). LED --- +Interrogates device to know if it is led control capable. + +* **[implements] eth_dev_ops**: ``dev_led_ctrl_capable``. +* **[related] API**: ``rte_eth_led_ctrl_capable()``. + Supports turning on/off a software controllable LED on a device. * **[implements] eth_dev_ops**: ``dev_led_on``, ``dev_led_off``. diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 6e9cb243e..b259b6b19 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3612,6 +3612,18 @@ rte_eth_led_off(uint16_t port_id) return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev)); } +int +rte_eth_led_ctrl_capable(uint16_t port_id) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP); + return 0; +} + /* * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find * an empty spot. diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 18a9defc2..a5bacd643 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -3204,6 +3204,21 @@ int rte_eth_led_on(uint16_t port_id); */ int rte_eth_led_off(uint16_t port_id); +/** + * Interrogate the Ethernet device to know if it is led control capable. + * + * @param port_id + * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if underlying hardware OR driver doesn't support + * that operation. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + */ +int __rte_experimental +rte_eth_led_ctrl_capable(uint16_t port_id); + /** * Get current status of the Ethernet link flow control for Ethernet device * diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h index 7bf97e24e..6cf2a5242 100644 --- a/lib/librte_ethdev/rte_ethdev_core.h +++ b/lib/librte_ethdev/rte_ethdev_core.h @@ -388,6 +388,9 @@ typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev); typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev); /**< @internal Turn off SW controllable LED on an Ethernet device */ +typedef int (*eth_dev_led_ctrl_capable_t)(struct rte_eth_dev *dev); +/**< @internal Get led control capability on an Ethernet device */ + typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index); /**< @internal Remove MAC address from receive address register */ @@ -675,6 +678,7 @@ struct eth_dev_ops { eth_dev_led_on_t dev_led_on; /**< Turn on LED. */ eth_dev_led_off_t dev_led_off; /**< Turn off LED. */ + eth_dev_led_ctrl_capable_t dev_led_ctrl_capable; /**< Get led control capability. */ flow_ctrl_get_t flow_ctrl_get; /**< Get flow control. */ flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control. */ diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index a7dacf2cf..776f3b5d6 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -227,4 +227,5 @@ EXPERIMENTAL { rte_flow_dynf_metadata_mask; rte_flow_dynf_metadata_register; rte_eth_dev_set_ptypes; + rte_eth_led_ctrl_capable; };