From: Stephen Hemminger <shemminger@vyatta.com>
To: Jeff Garzik <jgarzik@pobox.com>, Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: netdev@vger.kernel.org, linux-pci@vger.kernel.org,
Ben Hutchings <bhutchings@solarflare.com>,
Ivan Vecera <ivecera@redhat.com>
Subject: [PATCH 5/9] sky2: move VPD display into debug interface
Date: Thu, 25 Sep 2008 09:48:56 -0700 [thread overview]
Message-ID: <20080925165223.538702289@vyatta.com> (raw)
In-Reply-To: 20080925164851.694359776@vyatta.com
[-- Attachment #1: sky2-vpd-debug.patch --]
[-- Type: text/plain, Size: 4504 bytes --]
The VPD stuff has more data and isn't generally that useful, so move
it into the existing debugfs display and use the new PCI VPD
accessor routines.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/sky2.c 2008-09-09 13:57:07.000000000 -0700
+++ b/drivers/net/sky2.c 2008-09-09 13:57:08.000000000 -0700
@@ -3861,6 +3861,86 @@ static const struct ethtool_ops sky2_eth
static struct dentry *sky2_debug;
+
+/*
+ * Read and parse the first part of Vital Product Data
+ */
+#define VPD_SIZE 128
+#define VPD_MAGIC 0x82
+
+static const struct vpd_tag {
+ char tag[2];
+ char *label;
+} vpd_tags[] = {
+ { "PN", "Part Number" },
+ { "EC", "Engineering Level" },
+ { "MN", "Manufacturer" },
+ { "SN", "Serial Number" },
+ { "YA", "Asset Tag" },
+ { "VL", "First Error Log Message" },
+ { "VF", "Second Error Log Message" },
+ { "VB", "Boot Agent ROM Configuration" },
+ { "VE", "EFI UNDI Configuration" },
+};
+
+static void sky2_show_vpd(struct seq_file *seq, struct sky2_hw *hw)
+{
+ size_t vpd_size;
+ loff_t offs;
+ u8 len;
+ unsigned char *buf;
+ u16 reg2;
+
+ reg2 = sky2_pci_read16(hw, PCI_DEV_REG2);
+ vpd_size = 1 << ( ((reg2 & PCI_VPD_ROM_SZ) >> 14) + 8);
+
+ seq_printf(seq, "%s Product Data\n", pci_name(hw->pdev));
+ buf = kmalloc(vpd_size, GFP_KERNEL);
+ if (!buf) {
+ seq_puts(seq, "no memory!\n");
+ return;
+ }
+
+ if (pci_read_vpd(hw->pdev, 0, vpd_size, buf) < 0) {
+ seq_puts(seq, "VPD read failed\n");
+ goto out;
+ }
+
+ if (buf[0] != VPD_MAGIC) {
+ seq_printf(seq, "VPD tag mismatch: %#x\n", buf[0]);
+ goto out;
+ }
+ len = buf[1];
+ if (len == 0 || len > vpd_size - 4) {
+ seq_printf(seq, "Invalid id length: %d\n", len);
+ goto out;
+ }
+
+ seq_printf(seq, "%.*s\n", len, buf + 3);
+ offs = len + 3;
+
+ while (offs < vpd_size - 4) {
+ int i;
+
+ if (!memcmp("RW", buf + offs, 2)) /* end marker */
+ break;
+ len = buf[offs + 2];
+ if (offs + len + 3 >= vpd_size)
+ break;
+
+ for (i = 0; i < ARRAY_SIZE(vpd_tags); i++) {
+ if (!memcmp(vpd_tags[i].tag, buf + offs, 2)) {
+ seq_printf(seq, " %s: %.*s\n",
+ vpd_tags[i].label, len, buf + offs + 3);
+ break;
+ }
+ }
+ offs += len + 3;
+ }
+out:
+ kfree(buf);
+}
+
static int sky2_debug_show(struct seq_file *seq, void *v)
{
struct net_device *dev = seq->private;
@@ -3870,14 +3950,18 @@ static int sky2_debug_show(struct seq_fi
unsigned idx, last;
int sop;
- if (!netif_running(dev))
- return -ENETDOWN;
+ sky2_show_vpd(seq, hw);
- seq_printf(seq, "IRQ src=%x mask=%x control=%x\n",
+ seq_printf(seq, "\nIRQ src=%x mask=%x control=%x\n",
sky2_read32(hw, B0_ISRC),
sky2_read32(hw, B0_IMSK),
sky2_read32(hw, B0_Y2_SP_ICR));
+ if (!netif_running(dev)) {
+ seq_printf(seq, "network not running\n");
+ return 0;
+ }
+
napi_disable(&hw->napi);
last = sky2_read16(hw, STAT_PUT_IDX);
@@ -4191,69 +4275,6 @@ static int __devinit pci_wake_enabled(st
return value & PCI_PM_CTRL_PME_ENABLE;
}
-/*
- * Read and parse the first part of Vital Product Data
- */
-#define VPD_SIZE 128
-#define VPD_MAGIC 0x82
-
-static void __devinit sky2_vpd_info(struct sky2_hw *hw)
-{
- int cap = pci_find_capability(hw->pdev, PCI_CAP_ID_VPD);
- const u8 *p;
- u8 *vpd_buf = NULL;
- u16 len;
- static struct vpd_tag {
- char tag[2];
- char *label;
- } vpd_tags[] = {
- { "PN", "Part Number" },
- { "EC", "Engineering Level" },
- { "MN", "Manufacturer" },
- };
-
- if (!cap)
- goto out;
-
- vpd_buf = kmalloc(VPD_SIZE, GFP_KERNEL);
- if (!vpd_buf)
- goto out;
-
- if (sky2_vpd_read(hw, cap, vpd_buf, 0, VPD_SIZE))
- goto out;
-
- if (vpd_buf[0] != VPD_MAGIC)
- goto out;
- len = vpd_buf[1];
- if (len == 0 || len > VPD_SIZE - 4)
- goto out;
- p = vpd_buf + 3;
- dev_info(&hw->pdev->dev, "%.*s\n", len, p);
- p += len;
-
- while (p < vpd_buf + VPD_SIZE - 4) {
- int i;
-
- if (!memcmp("RW", p, 2)) /* end marker */
- break;
-
- len = p[2];
- if (len > (p - vpd_buf) - 4)
- break;
-
- for (i = 0; i < ARRAY_SIZE(vpd_tags); i++) {
- if (!memcmp(vpd_tags[i].tag, p, 2)) {
- printk(KERN_DEBUG " %s: %.*s\n",
- vpd_tags[i].label, len, p + 3);
- break;
- }
- }
- p += len + 3;
- }
-out:
- kfree(vpd_buf);
-}
-
/* This driver supports yukon2 chipset only */
static const char *sky2_name(u8 chipid, char *buf, int sz)
{
@@ -4374,8 +4395,6 @@ static int __devinit sky2_probe(struct p
sky2_reset(hw);
- sky2_vpd_info(hw);
-
dev = sky2_init_netdev(hw, 0, using_dac, wol_default);
if (!dev) {
err = -ENOMEM;
--
next prev parent reply other threads:[~2008-09-25 16:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-25 16:48 [PATCH 0/9] PCI vpd patches (rev4) Stephen Hemminger
2008-09-25 16:48 ` [PATCH 1/9] PCI: vpd handle longer delays in access (rev3) Stephen Hemminger
2008-09-25 18:54 ` Matthew Wilcox
2008-09-25 16:48 ` [PATCH 2/9] PCI: revise VPD access interface (rev3) Stephen Hemminger
2008-09-25 17:58 ` Ben Hutchings
2008-09-25 16:48 ` [PATCH 3/9] PCI: add interface to set visible size of VPD (rev3) Stephen Hemminger
2008-09-25 17:22 ` Jeff Garzik
2008-09-25 17:49 ` Ben Hutchings
2008-09-25 16:48 ` [PATCH 4/9] sky2: set VPD size Stephen Hemminger
2008-09-25 16:48 ` Stephen Hemminger [this message]
2008-09-25 16:48 ` [PATCH 6/9] sky2: remove VPD eeprom Stephen Hemminger
2008-09-25 16:48 ` [PATCH 7/9] skge: set VPD size Stephen Hemminger
2008-09-25 16:48 ` [PATCH 8/9] skge: add VPD display into debug interface Stephen Hemminger
2008-09-25 17:23 ` Jeff Garzik
2008-09-25 16:49 ` [PATCH 9/9] skge: remove VPD eeprom Stephen Hemminger
-- strict thread matches above, loose matches on Subject: below --
2008-10-13 20:13 [PATCH 0/9] Vital Product Data (VPD) patches relating to skge/sky2 Stephen Hemminger
2008-10-13 20:13 ` [PATCH 5/9] sky2: move VPD display into debug interface Stephen Hemminger
2008-09-09 18:20 [PATCH 0/9] PCI VPD related patches Stephen Hemminger
2008-09-09 18:20 ` [PATCH 5/9] sky2: move VPD display into debug interface Stephen Hemminger
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=20080925165223.538702289@vyatta.com \
--to=shemminger@vyatta.com \
--cc=bhutchings@solarflare.com \
--cc=ivecera@redhat.com \
--cc=jbarnes@virtuousgeek.org \
--cc=jgarzik@pobox.com \
--cc=linux-pci@vger.kernel.org \
--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).