From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8ECF6A0A01; Mon, 4 Jan 2021 13:21:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24D971606FA; Mon, 4 Jan 2021 13:21:50 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 887541606C7 for ; Mon, 4 Jan 2021 13:21:46 +0100 (CET) IronPort-SDR: nucsb20kUSkkn/yh/LMAArMloX8uOempZR6HJjviWRBKo+UrG0pufpOuSUTyRRN/6K0rysQw6V 7C50G8dseiKQ== X-IronPort-AV: E=McAfee;i="6000,8403,9853"; a="164012328" X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="164012328" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2021 04:21:43 -0800 IronPort-SDR: g7xYnuqfma/OWFGdEDqV6i8FR01SGuyGbSrqpwH0qp0H1le2568vkS18u3paHZ1iw0ja/yT6DM JK8fUwKaSPzg== X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="378398758" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.251.93.148]) ([10.251.93.148]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2021 04:21:43 -0800 To: selwin.sebastian@amd.com, dev@dpdk.org Cc: amaranath.somalapuram@amd.com References: <12017189-0d86-2cea-8f65-f38dc57a8120@intel.com> <20201229070947.14073-1-selwin.sebastian@amd.com> From: Ferruh Yigit Message-ID: Date: Mon, 4 Jan 2021 12:21:39 +0000 MIME-Version: 1.0 In-Reply-To: <20201229070947.14073-1-selwin.sebastian@amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2] net/axgbe: add support for reading FW version 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 Sender: "dev" On 12/29/2020 7:09 AM, selwin.sebastian@amd.com wrote: > From: Selwin Sebastian > > Added support for fw_version_get API > > Signed-off-by: Selwin Sebastian > --- > doc/guides/nics/features/axgbe.ini | 1 + > drivers/net/axgbe/axgbe_ethdev.c | 1 + > drivers/net/axgbe/axgbe_rxtx.c | 25 +++++++++++++++++++++++++ > drivers/net/axgbe/axgbe_rxtx.h | 3 +++ > 4 files changed, 30 insertions(+) > > diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini > index 34df0d1ee..3adc5639f 100644 > --- a/doc/guides/nics/features/axgbe.ini > +++ b/doc/guides/nics/features/axgbe.ini > @@ -17,6 +17,7 @@ CRC offload = Y > L3 checksum offload = Y > L4 checksum offload = Y > Basic stats = Y > +FW version = Y > Linux UIO = Y > x86-32 = Y > x86-64 = Y > diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c > index cfe6aba73..1982c6a8e 100644 > --- a/drivers/net/axgbe/axgbe_ethdev.c > +++ b/drivers/net/axgbe/axgbe_ethdev.c > @@ -257,6 +257,7 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = { > .timesync_adjust_time = axgbe_timesync_adjust_time, > .timesync_read_time = axgbe_timesync_read_time, > .timesync_write_time = axgbe_timesync_write_time, > + .fw_version_get = axgbe_dev_fw_version_get, > }; > > static int axgbe_phy_reset(struct axgbe_port *pdata) > diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c > index 032e3cebc..3298a294e 100644 > --- a/drivers/net/axgbe/axgbe_rxtx.c > +++ b/drivers/net/axgbe/axgbe_rxtx.c > @@ -571,6 +571,31 @@ int axgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, > return 0; > } > > +int axgbe_dev_fw_version_get(struct rte_eth_dev *eth_dev, > + char *fw_version, size_t fw_size) > +{ > + struct axgbe_port *pdata; > + struct axgbe_hw_features *hw_feat; > + int ret; > + > + pdata = (struct axgbe_port *)eth_dev->data->dev_private; > + hw_feat = &pdata->hw_feat; > + > + if (fw_version == NULL || fw_size <= 0) 'size_t' can't be negative, no need to compare '< 0' case. > + return -EINVAL; > + > + ret = snprintf(fw_version, fw_size, "%d.%d.%d", > + AXGMAC_GET_BITS(hw_feat->version, MAC_VR, USERVER), > + AXGMAC_GET_BITS(hw_feat->version, MAC_VR, DEVID), > + AXGMAC_GET_BITS(hw_feat->version, MAC_VR, SNPSVER)); > + ret += 1; /* add the size of '\0' */ > + 'snprintf' can return error, which should be taken into account. > + if (fw_size < (u32)ret) instead of casting to 'u32', can cast to 'size_t' which is the type of the 'fw_size'. > + return ret; > + else > + return 0; > +} > + > static void axgbe_txq_prepare_tx_stop(struct axgbe_port *pdata, > unsigned int queue) > { > diff --git a/drivers/net/axgbe/axgbe_rxtx.h b/drivers/net/axgbe/axgbe_rxtx.h > index f2fbe9299..c2b11bb0e 100644 > --- a/drivers/net/axgbe/axgbe_rxtx.h > +++ b/drivers/net/axgbe/axgbe_rxtx.h > @@ -162,6 +162,9 @@ void axgbe_dev_disable_tx(struct rte_eth_dev *dev); > int axgbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); > int axgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); > > +int axgbe_dev_fw_version_get(struct rte_eth_dev *eth_dev, > + char *fw_version, size_t fw_size); > + > uint16_t axgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, > uint16_t nb_pkts); > uint16_t axgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, >