Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 134284
b: refs/heads/master
c: e4c2abe
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Feb 3, 2009
1 parent 8e185b4 commit 5c2845c
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 69 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 454e6cb6868dd5c88d8bcdab407caa3738d30c2b
refs/heads/master: e4c2abe29e1ec5d68908848ffa77b39f61a83f7c
155 changes: 87 additions & 68 deletions trunk/drivers/net/sky2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3905,6 +3905,86 @@ static const struct ethtool_ops sky2_ethtool_ops = {

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;
Expand All @@ -3914,14 +3994,18 @@ static int sky2_debug_show(struct seq_file *seq, void *v)
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);

Expand Down Expand Up @@ -4245,69 +4329,6 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
return err;
}

/*
* 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)
{
Expand Down Expand Up @@ -4411,8 +4432,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev,

sky2_reset(hw);

sky2_vpd_info(hw);

dev = sky2_init_netdev(hw, 0, using_dac, wol_default);
if (!dev) {
err = -ENOMEM;
Expand Down

0 comments on commit 5c2845c

Please sign in to comment.