From: Stephen Hemminger <stephen@networkplumber•org>
To: Neel Patel <neepatel@cisco•com>
Cc: netdev@vger•kernel.org, Nishank Trivedi <nistrive@cisco•com>,
Christian Benvenuti <benve@cisco•com>
Subject: Re: [PATCH 3/4] drivers/net: enic: Make ASIC information available to USNIC
Date: Fri, 9 Aug 2013 15:21:35 -0700 [thread overview]
Message-ID: <20130809152135.11c19869@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <1376071941-17001-4-git-send-email-neepatel@cisco.com>
On Fri, 9 Aug 2013 11:12:20 -0700
Neel Patel <neepatel@cisco•com> wrote:
> This patch provides asic information via ethtool.
>
> Signed-off-by: Neel Patel <neepatel@cisco•com>
> Signed-off-by: Nishank Trivedi <nistrive@cisco•com>
> Signed-off-by: Christian Benvenuti <benve@cisco•com>
> ---
> drivers/net/ethernet/cisco/enic/driver_utils.h | 49 ++++++++++++++++++++++++++
> drivers/net/ethernet/cisco/enic/enic_ethtool.c | 4 +++
> 2 files changed, 53 insertions(+)
> create mode 100644 drivers/net/ethernet/cisco/enic/driver_utils.h
>
> diff --git a/drivers/net/ethernet/cisco/enic/driver_utils.h b/drivers/net/ethernet/cisco/enic/driver_utils.h
> new file mode 100644
> index 0000000..e654b4d
> --- /dev/null
> +++ b/drivers/net/ethernet/cisco/enic/driver_utils.h
> @@ -0,0 +1,49 @@
> +/**
> + * Copyright 2013 Cisco Systems, Inc. All rights reserved.
> + *
> + * This program is free software; you may redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 2 of the License.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + *
> + */
> +
> +#ifndef __DRIVER_UTILS_H__
> +#define __DRIVER_UTILS_H__
> +
> +#include <linux/string.h>
> +
> +static inline int driver_encode_asic_info(char *str, int strlen, u16 asic_type,
> + u16 asic_rev)
> +{
> + if (strlen < sizeof(asic_type) + sizeof(asic_rev))
> + return -EINVAL;
> +
> + memcpy(str, &asic_type, sizeof(asic_type));
> + memcpy(str + sizeof(asic_type), &asic_rev, sizeof(asic_rev));
> +
> + return 0;
> +}
> +
> +static inline int driver_decode_asic_info(char *str, int strlen, u16 *asic_type,
> + u16 *asic_rev)
> +{
> + if (strlen < sizeof(*asic_type) + sizeof(*asic_rev))
> + return -EINVAL;
> +
> + if (asic_type)
> + memcpy(asic_type, str, sizeof(*asic_type));
> + if (asic_rev)
> + memcpy(asic_rev, str + sizeof(*asic_type), sizeof(*asic_rev));
> + return 0;
> +}
> +
> +#endif /*!__DRIVER_UTILS_H__*/
> diff --git a/drivers/net/ethernet/cisco/enic/enic_ethtool.c b/drivers/net/ethernet/cisco/enic/enic_ethtool.c
> index 47e3562..c5d938a 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_ethtool.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_ethtool.c
> @@ -19,6 +19,7 @@
> #include <linux/netdevice.h>
> #include <linux/ethtool.h>
>
> +#include "driver_utils.h"
> #include "enic_res.h"
> #include "enic.h"
> #include "enic_dev.h"
> @@ -116,6 +117,9 @@ static void enic_get_drvinfo(struct net_device *netdev,
> sizeof(drvinfo->fw_version));
> strlcpy(drvinfo->bus_info, pci_name(enic->pdev),
> sizeof(drvinfo->bus_info));
> + memset(drvinfo->reserved1, 0, sizeof(drvinfo->reserved1));
> + driver_encode_asic_info(drvinfo->reserved1, sizeof(drvinfo->reserved1),
> + fw_info->asic_type, fw_info->asic_rev);
> }
If you want to use a reserved field, then make it a first class citizen.
Rename it to asic_info, make sure the result is okay for other drivers
and add send patch so Ben can make it part of normal ethtool support.
Otherwise, this code is likely to break when someone else actually unreserves
that field.
next prev parent reply other threads:[~2013-08-09 22:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-09 18:12 [PATCH 0/4] enic: This patchset adds support for Cisco Low Latency NIC Neel Patel
2013-08-09 18:12 ` [PATCH 1/4] drivers/net: enic: Adding " Neel Patel
2013-08-09 18:12 ` [PATCH 2/4] drivers/net: enic: Add an interface for USNIC to interact with firmware Neel Patel
2013-08-09 18:12 ` [PATCH 3/4] drivers/net: enic: Make ASIC information available to USNIC Neel Patel
2013-08-09 22:21 ` Stephen Hemminger [this message]
2013-08-10 16:13 ` Ben Hutchings
2013-08-13 5:10 ` Nishank Trivedi
2013-08-13 8:31 ` Ben Hutchings
2013-08-09 18:12 ` [PATCH 4/4] drivers/net: enic: Generate notification of hardware crash Neel Patel
-- strict thread matches above, loose matches on Subject: below --
2013-08-09 18:38 [PATCH 0/4] enic: This patchset adds support for Cisco Low Latency NIC Neel Patel
2013-08-09 18:38 ` [PATCH 3/4] drivers/net: enic: Make ASIC information available to USNIC Neel Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130809152135.11c19869@nehalam.linuxnetplumber.net \
--to=stephen@networkplumber$(echo .)org \
--cc=benve@cisco$(echo .)com \
--cc=neepatel@cisco$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nistrive@cisco$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox