From: Shannon Nelson <snelson@pensando.io>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next 02/18] ionic: Add hardware init and device commands
Date: Fri, 21 Jun 2019 15:22:22 -0700 [thread overview]
Message-ID: <65461426-92d8-cd87-942d-1fd82bd64fe4@pensando.io> (raw)
In-Reply-To: <20190620215430.GK31306@lunn.ch>
On 6/20/19 2:54 PM, Andrew Lunn wrote:
> On Thu, Jun 20, 2019 at 01:24:08PM -0700, Shannon Nelson wrote:
>> + err = ionic_debugfs_add_dev(ionic);
>> + if (err) {
>> + dev_err(dev, "Cannot add device debugfs: %d , aborting\n", err);
>> + goto err_out_clear_drvdata;
>> + }
> Hi Shannon
>
> debugfs should not fail, since it is optional. debugfs failing should
> also not be considered fatal. And lastly, debugfs is not very liked by
> network people, so you should avoid it as much as possible. Use
> ethtool, lspci, devlink, etc.
Yes, we can drop this error check.
>
>> +
>> +#ifdef CONFIG_DEBUG_FS
>> +
>> +static int blob_open(struct inode *inode, struct file *filp)
>> +{
>> + filp->private_data = inode->i_private;
>> + return 0;
>> +}
>> +
>> +static ssize_t blob_read(struct file *filp, char __user *buffer,
>> + size_t count, loff_t *ppos)
>> +{
>> + struct debugfs_blob_wrapper *blob = filp->private_data;
>> +
>> + if (*ppos >= blob->size)
>> + return 0;
>> + if (*ppos + count > blob->size)
>> + count = blob->size - *ppos;
>> +
>> + if (copy_to_user(buffer, blob->data + *ppos, count))
>> + return -EFAULT;
>> +
>> + *ppos += count;
>> +
>> + return count;
>> +}
>> +
>> +static ssize_t blob_write(struct file *filp, const char __user *buffer,
>> + size_t count, loff_t *ppos)
>> +{
>> + struct debugfs_blob_wrapper *blob = filp->private_data;
>> +
>> + if (*ppos >= blob->size)
>> + return 0;
>> + if (*ppos + count > blob->size)
>> + count = blob->size - *ppos;
>> +
>> + if (copy_from_user(blob->data + *ppos, buffer, count))
>> + return -EFAULT;
>> +
>> + *ppos += count;
>> +
>> + return count;
>> +}
> Write is pretty much a no-no. We don't want proprietary user space
> tools manipulating the hardware/driver state.
Yep, this needs to come out.
>
>> +
>> +static const struct file_operations blob_fops = {
>> + .owner = THIS_MODULE,
>> + .open = blob_open,
>> + .read = blob_read,
>> + .write = blob_write,
>> +};
>> +
>> +struct dentry *debugfs_create_blob(const char *name, umode_t mode,
>> + struct dentry *parent,
>> + struct debugfs_blob_wrapper *blob)
>> +{
>> + return debugfs_create_file(name, mode | 0200, parent, blob,
>> + &blob_fops);
>> +}
>> +
>> +static const struct debugfs_reg32 dev_cmd_regs[] = {
>> + { .name = "db", .offset = 0, },
>> + { .name = "done", .offset = 4, },
>> + { .name = "cmd.word[0]", .offset = 8, },
>> + { .name = "cmd.word[1]", .offset = 12, },
>> + { .name = "cmd.word[2]", .offset = 16, },
>> + { .name = "cmd.word[3]", .offset = 20, },
>> + { .name = "cmd.word[4]", .offset = 24, },
>> + { .name = "cmd.word[5]", .offset = 28, },
>> + { .name = "cmd.word[6]", .offset = 32, },
>> + { .name = "cmd.word[7]", .offset = 36, },
>> + { .name = "cmd.word[8]", .offset = 40, },
>> + { .name = "cmd.word[9]", .offset = 44, },
>> + { .name = "cmd.word[10]", .offset = 48, },
>> + { .name = "cmd.word[11]", .offset = 52, },
>> + { .name = "cmd.word[12]", .offset = 56, },
>> + { .name = "cmd.word[13]", .offset = 60, },
>> + { .name = "cmd.word[14]", .offset = 64, },
>> + { .name = "cmd.word[15]", .offset = 68, },
>> + { .name = "comp.word[0]", .offset = 72, },
>> + { .name = "comp.word[1]", .offset = 76, },
>> + { .name = "comp.word[2]", .offset = 80, },
>> + { .name = "comp.word[3]", .offset = 84, },
>> +};
>> +
>> +int ionic_debugfs_add_dev_cmd(struct ionic *ionic)
>> +{
>> + struct debugfs_regset32 *dev_cmd_regset;
>> + struct device *dev = ionic->dev;
>> + struct dentry *dentry;
>> +
>> + dev_cmd_regset = devm_kzalloc(dev, sizeof(*dev_cmd_regset),
>> + GFP_KERNEL);
>> + if (!dev_cmd_regset)
>> + return -ENOMEM;
>> + dev_cmd_regset->regs = dev_cmd_regs;
>> + dev_cmd_regset->nregs = ARRAY_SIZE(dev_cmd_regs);
>> + dev_cmd_regset->base = ionic->idev.dev_cmd_regs;
>> +
>> + dentry = debugfs_create_regset32("dev_cmd", 0400,
>> + ionic->dentry, dev_cmd_regset);
>> + if (IS_ERR_OR_NULL(dentry))
>> + return PTR_ERR(dentry);
> ethtool -d seems like a more acceptable method for exporting
> registers.
Yes, that is one of the near future additions planned.
>
>> +static int identity_show(struct seq_file *seq, void *v)
>> +{
>> + struct ionic *ionic = seq->private;
>> + struct identity *ident = &ionic->ident;
>> + struct ionic_dev *idev = &ionic->idev;
>> +
>> + seq_printf(seq, "asic_type: 0x%x\n", idev->dev_info.asic_type);
>> + seq_printf(seq, "asic_rev: 0x%x\n", idev->dev_info.asic_rev);
>> + seq_printf(seq, "serial_num: %s\n", idev->dev_info.serial_num);
>> + seq_printf(seq, "fw_version: %s\n", idev->dev_info.fw_version);
>> + seq_printf(seq, "fw_status: 0x%x\n",
>> + ioread8(&idev->dev_info_regs->fw_status));
>> + seq_printf(seq, "fw_heartbeat: 0x%x\n",
>> + ioread32(&idev->dev_info_regs->fw_heartbeat));
> devlink just gained a much more flexible version of ethtool -i. Please
> remove all this and use that.
Yes, we intend to add a devlink interface, it just isn't in this first
patchset, which is already plenty big.
>
>> +int ionic_dev_setup(struct ionic *ionic)
>> +{
>> + struct ionic_dev_bar *bar = ionic->bars;
>> + unsigned int num_bars = ionic->num_bars;
>> + struct ionic_dev *idev = &ionic->idev;
>> + struct device *dev = ionic->dev;
>> + u32 sig;
>> +
>> + /* BAR0: dev_cmd and interrupts */
>> + if (num_bars < 1) {
>> + dev_info(dev, "No bars found, aborting\n");
> dev_err(), since this is fatal. The same for most of these dev_info()
> calls.
Will do
>
>> +enum os_type {
>> + IONIC_OS_TYPE_LINUX = 1,
>> + IONIC_OS_TYPE_WIN = 2,
>> + IONIC_OS_TYPE_DPDK = 3,
>> + IONIC_OS_TYPE_FREEBSD = 4,
>> + IONIC_OS_TYPE_IPXE = 5,
>> + IONIC_OS_TYPE_ESXI = 6,
>> +};
>> +
>> +/**
>> + * union drv_identity - driver identity information
>> + * @os_type: OS type (see enum os_type)
>> + * @os_dist: OS distribution, numeric format
>> + * @os_dist_str: OS distribution, string format
>> + * @kernel_ver: Kernel version, numeric format
>> + * @kernel_ver_str: Kernel version, string format
>> + * @driver_ver_str: Driver version, string format
>> + */
>> +union drv_identity {
>> + struct {
>> + __le32 os_type;
>> + __le32 os_dist;
>> + char os_dist_str[128];
>> + __le32 kernel_ver;
>> + char kernel_ver_str[32];
>> + char driver_ver_str[32];
>> + };
>> + __le32 words[512];
>> +};
>> +int ionic_identify(struct ionic *ionic)
>> +{
>> + struct identity *ident = &ionic->ident;
>> + struct ionic_dev *idev = &ionic->idev;
>> + size_t sz;
>> + int err;
>> +
>> + memset(ident, 0, sizeof(*ident));
>> +
>> + ident->drv.os_type = cpu_to_le32(IONIC_OS_TYPE_LINUX);
>> + ident->drv.os_dist = 0;
>> + strncpy(ident->drv.os_dist_str, utsname()->release,
>> + sizeof(ident->drv.os_dist_str) - 1);
>> + ident->drv.kernel_ver = cpu_to_le32(LINUX_VERSION_CODE);
>> + strncpy(ident->drv.kernel_ver_str, utsname()->version,
>> + sizeof(ident->drv.kernel_ver_str) - 1);
>> + strncpy(ident->drv.driver_ver_str, DRV_VERSION,
>> + sizeof(ident->drv.driver_ver_str) - 1);
> Creepy.
It does seem odd at first to be telling your NIC about the OS, but this
is becomes part of a larger whole and is used in our device support and
management.
Thanks,
sln
>
> Andrew
next prev parent reply other threads:[~2019-06-21 22:22 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 20:24 [PATCH net-next 00/18] Add ionic driver Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 01/18] ionic: Add basic framework for IONIC Network device driver Shannon Nelson
2019-06-20 21:24 ` Andrew Lunn
2019-06-21 22:13 ` Shannon Nelson
2019-06-24 20:07 ` Jakub Kicinski
2019-06-24 21:54 ` Shannon Nelson
2019-06-24 20:03 ` Jakub Kicinski
2019-06-24 21:46 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 02/18] ionic: Add hardware init and device commands Shannon Nelson
2019-06-20 21:54 ` Andrew Lunn
2019-06-21 22:22 ` Shannon Nelson [this message]
2019-06-24 20:13 ` Jakub Kicinski
2019-06-24 21:50 ` Shannon Nelson
2019-06-21 9:27 ` kbuild test robot
2019-06-21 9:27 ` [PATCH] ionic: fix simple_open.cocci warnings kbuild test robot
2019-06-21 15:42 ` Shannon Nelson
2019-06-21 13:03 ` [PATCH net-next 02/18] ionic: Add hardware init and device commands kbuild test robot
2019-06-24 20:53 ` Jakub Kicinski
2019-06-24 22:29 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 03/18] ionic: Add port management commands Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 04/18] ionic: Add basic lif support Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 05/18] ionic: Add interrupts and doorbells Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 06/18] ionic: Add basic adminq support Shannon Nelson
2019-06-21 6:03 ` kbuild test robot
2019-06-20 20:24 ` [PATCH net-next 07/18] ionic: Add adminq action Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 08/18] ionic: Add notifyq support Shannon Nelson
2019-06-25 23:21 ` Jakub Kicinski
2019-06-26 15:26 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 09/18] ionic: Add the basic NDO callbacks for netdev support Shannon Nelson
2019-06-25 23:27 ` Jakub Kicinski
2019-06-26 15:41 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 10/18] ionic: Add management of rx filters Shannon Nelson
2019-06-25 23:37 ` Jakub Kicinski
2019-06-26 15:52 ` Shannon Nelson
2019-06-27 15:59 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 11/18] ionic: Add Rx filter and rx_mode nod support Shannon Nelson
2019-06-21 10:30 ` kbuild test robot
2019-06-21 10:30 ` [PATCH] ionic: fix semicolon.cocci warnings kbuild test robot
2019-06-21 15:43 ` Shannon Nelson
2019-06-25 23:44 ` [PATCH net-next 11/18] ionic: Add Rx filter and rx_mode nod support Jakub Kicinski
2019-06-26 15:53 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 12/18] ionic: Add async link status check and basic stats Shannon Nelson
2019-06-25 23:47 ` Jakub Kicinski
2019-06-26 15:54 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 13/18] ionic: Add initial ethtool support Shannon Nelson
2019-06-21 2:32 ` Michal Kubecek
2019-06-21 22:30 ` Shannon Nelson
2019-06-24 7:26 ` Michal Kubecek
2019-06-24 21:44 ` Shannon Nelson
2019-06-25 23:54 ` Jakub Kicinski
2019-06-26 16:07 ` Shannon Nelson
2019-06-26 16:18 ` Jakub Kicinski
2019-06-20 20:24 ` [PATCH net-next 14/18] ionic: Add Tx and Rx handling Shannon Nelson
2019-06-26 0:08 ` Jakub Kicinski
2019-06-26 16:49 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 15/18] ionic: Add netdev-event handling Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 16/18] ionic: Add driver stats Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 17/18] ionic: Add RSS support Shannon Nelson
2019-06-26 0:20 ` Jakub Kicinski
2019-06-26 17:04 ` Shannon Nelson
2019-06-20 20:24 ` [PATCH net-next 18/18] ionic: Add coalesce and other features Shannon Nelson
2019-06-24 20:19 ` [PATCH net-next 00/18] Add ionic driver Jakub Kicinski
2019-06-24 21:53 ` David Miller
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=65461426-92d8-cd87-942d-1fd82bd64fe4@pensando.io \
--to=snelson@pensando.io \
--cc=andrew@lunn.ch \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).