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 537E0A2EFC for ; Tue, 15 Oct 2019 10:25:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6D7FF1E8E1; Tue, 15 Oct 2019 10:23:30 +0200 (CEST) Received: from mail.ntop.org (mail-digitalocean.ntop.org [167.99.215.164]) by dpdk.org (Postfix) with ESMTP id 1B84C1DFED for ; Tue, 15 Oct 2019 10:22:51 +0200 (CEST) Received: from devele.ntop.org (net-93-145-196-230.cust.vodafonedsl.it [93.145.196.230]) by mail.ntop.org (Postfix) with ESMTPSA id BA90C41C1E; Tue, 15 Oct 2019 10:22:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntop.org; s=mail; t=1571127770; bh=kjb7TUvjL6uABZczGZspzz754oaDNa30RCJkTfxTPFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h00lOswlEIRYJYBMZaACDBqCGFz4GYQLMiFTEMadRThMMEJEpptNzQLExA62jmKUY r9xw1NcIye6L7TykuhE4DV4Snyd9P1IRjD+CJr2IptMBYsniWYnj70GwfiDCB2otR7 N4uMw5ME7x6vZf9E2SkpCzq0kC/9DZKVzRiWD1V4= From: Alfredo Cardigliano To: Alfredo Cardigliano , John McNamara , Marko Kovacevic Cc: dev@dpdk.org Date: Tue, 15 Oct 2019 10:22:35 +0200 Message-Id: <20191015082235.28639-18-cardigliano@ntop.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191015082235.28639-1-cardigliano@ntop.org> References: <20191015082235.28639-1-cardigliano@ntop.org> Subject: [dpdk-dev] [PATCH v2 17/17] net/ionic: read fw version 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 support for reading the firmware version. Signed-off-by: Alfredo Cardigliano Reviewed-by: Shannon Nelson --- doc/guides/nics/features/ionic.ini | 1 + drivers/net/ionic/ionic.h | 1 + drivers/net/ionic/ionic_dev.c | 8 ++++++++ drivers/net/ionic/ionic_ethdev.c | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/doc/guides/nics/features/ionic.ini b/doc/guides/nics/features/ionic.ini index b937092ac..54beb0bd1 100644 --- a/doc/guides/nics/features/ionic.ini +++ b/doc/guides/nics/features/ionic.ini @@ -29,6 +29,7 @@ Packet type parsing = Y Basic stats = Y Extended stats = Y Stats per queue = Y +FW version = Y Linux UIO = Y Linux VFIO = Y x86-64 = Y diff --git a/drivers/net/ionic/ionic.h b/drivers/net/ionic/ionic.h index 05f1df061..4f691b429 100644 --- a/drivers/net/ionic/ionic.h +++ b/drivers/net/ionic/ionic.h @@ -60,6 +60,7 @@ struct ionic_adapter { bool intrs[IONIC_INTR_CTRL_REGS_MAX]; bool is_mgmt_nic; bool link_up; + char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN]; struct rte_pci_device *pci_dev; LIST_ENTRY(ionic_adapter) pci_adapters; }; diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c index fc165d0a8..dfa41f99a 100644 --- a/drivers/net/ionic/ionic_dev.c +++ b/drivers/net/ionic/ionic_dev.c @@ -15,6 +15,7 @@ ionic_dev_setup(struct ionic_adapter *adapter) unsigned int num_bars = adapter->num_bars; struct ionic_dev *idev = &adapter->idev; uint32_t sig; + unsigned int i; /* BAR0: dev_cmd and interrupts */ if (num_bars < 1) { @@ -41,6 +42,13 @@ ionic_dev_setup(struct ionic_adapter *adapter) return -EFAULT; } + for (i = 0; i < IONIC_DEVINFO_FWVERS_BUFLEN; i++) + adapter->fw_version[i] = + ioread8(&idev->dev_info->fw_version[i]); + adapter->fw_version[IONIC_DEVINFO_FWVERS_BUFLEN - 1] = '\0'; + + ionic_init_print(DEBUG, "Firmware version: %s", adapter->fw_version); + /* BAR1: doorbells */ bar++; if (num_bars < 2) { diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c index 3894ffe17..c556076ff 100644 --- a/drivers/net/ionic/ionic_ethdev.c +++ b/drivers/net/ionic/ionic_ethdev.c @@ -56,6 +56,8 @@ static int ionic_dev_xstats_get_names(struct rte_eth_dev *dev, static int ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, const uint64_t *ids, unsigned int limit); +static int ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev, + char *fw_version, size_t fw_size); int ionic_logtype_init; int ionic_logtype_driver; @@ -123,6 +125,7 @@ static const struct eth_dev_ops ionic_eth_dev_ops = { .xstats_reset = ionic_dev_xstats_reset, .xstats_get_names = ionic_dev_xstats_get_names, .xstats_get_names_by_id = ionic_dev_xstats_get_names_by_id, + .fw_version_get = ionic_dev_fw_version_get, }; /* @@ -220,6 +223,23 @@ static const struct rte_ionic_xstats_name_off rte_ionic_xstats_strings[] = { #define IONIC_NB_HW_STATS (sizeof(rte_ionic_xstats_strings) / \ sizeof(rte_ionic_xstats_strings[0])) +static int +ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev, + char *fw_version, size_t fw_size) +{ + struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); + struct ionic_adapter *adapter = lif->adapter; + + if (fw_version == NULL || fw_size <= 0) + return -EINVAL; + + snprintf(fw_version, fw_size, "%s", + adapter->fw_version); + fw_version[fw_size - 1] = '\0'; + + return 0; +} + /* * Set device link up, enable tx. */ -- 2.17.1