diff options
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r-- | drivers/net/sky2.c | 155 |
1 files changed, 87 insertions, 68 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 8b9b88457267..d3c090dae879 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -3905,6 +3905,86 @@ static const struct ethtool_ops sky2_ethtool_ops = { | |||
3905 | 3905 | ||
3906 | static struct dentry *sky2_debug; | 3906 | static struct dentry *sky2_debug; |
3907 | 3907 | ||
3908 | |||
3909 | /* | ||
3910 | * Read and parse the first part of Vital Product Data | ||
3911 | */ | ||
3912 | #define VPD_SIZE 128 | ||
3913 | #define VPD_MAGIC 0x82 | ||
3914 | |||
3915 | static const struct vpd_tag { | ||
3916 | char tag[2]; | ||
3917 | char *label; | ||
3918 | } vpd_tags[] = { | ||
3919 | { "PN", "Part Number" }, | ||
3920 | { "EC", "Engineering Level" }, | ||
3921 | { "MN", "Manufacturer" }, | ||
3922 | { "SN", "Serial Number" }, | ||
3923 | { "YA", "Asset Tag" }, | ||
3924 | { "VL", "First Error Log Message" }, | ||
3925 | { "VF", "Second Error Log Message" }, | ||
3926 | { "VB", "Boot Agent ROM Configuration" }, | ||
3927 | { "VE", "EFI UNDI Configuration" }, | ||
3928 | }; | ||
3929 | |||
3930 | static void sky2_show_vpd(struct seq_file *seq, struct sky2_hw *hw) | ||
3931 | { | ||
3932 | size_t vpd_size; | ||
3933 | loff_t offs; | ||
3934 | u8 len; | ||
3935 | unsigned char *buf; | ||
3936 | u16 reg2; | ||
3937 | |||
3938 | reg2 = sky2_pci_read16(hw, PCI_DEV_REG2); | ||
3939 | vpd_size = 1 << ( ((reg2 & PCI_VPD_ROM_SZ) >> 14) + 8); | ||
3940 | |||
3941 | seq_printf(seq, "%s Product Data\n", pci_name(hw->pdev)); | ||
3942 | buf = kmalloc(vpd_size, GFP_KERNEL); | ||
3943 | if (!buf) { | ||
3944 | seq_puts(seq, "no memory!\n"); | ||
3945 | return; | ||
3946 | } | ||
3947 | |||
3948 | if (pci_read_vpd(hw->pdev, 0, vpd_size, buf) < 0) { | ||
3949 | seq_puts(seq, "VPD read failed\n"); | ||
3950 | goto out; | ||
3951 | } | ||
3952 | |||
3953 | if (buf[0] != VPD_MAGIC) { | ||
3954 | seq_printf(seq, "VPD tag mismatch: %#x\n", buf[0]); | ||
3955 | goto out; | ||
3956 | } | ||
3957 | len = buf[1]; | ||
3958 | if (len == 0 || len > vpd_size - 4) { | ||
3959 | seq_printf(seq, "Invalid id length: %d\n", len); | ||
3960 | goto out; | ||
3961 | } | ||
3962 | |||
3963 | seq_printf(seq, "%.*s\n", len, buf + 3); | ||
3964 | offs = len + 3; | ||
3965 | |||
3966 | while (offs < vpd_size - 4) { | ||
3967 | int i; | ||
3968 | |||
3969 | if (!memcmp("RW", buf + offs, 2)) /* end marker */ | ||
3970 | break; | ||
3971 | len = buf[offs + 2]; | ||
3972 | if (offs + len + 3 >= vpd_size) | ||
3973 | break; | ||
3974 | |||
3975 | for (i = 0; i < ARRAY_SIZE(vpd_tags); i++) { | ||
3976 | if (!memcmp(vpd_tags[i].tag, buf + offs, 2)) { | ||
3977 | seq_printf(seq, " %s: %.*s\n", | ||
3978 | vpd_tags[i].label, len, buf + offs + 3); | ||
3979 | break; | ||
3980 | } | ||
3981 | } | ||
3982 | offs += len + 3; | ||
3983 | } | ||
3984 | out: | ||
3985 | kfree(buf); | ||
3986 | } | ||
3987 | |||
3908 | static int sky2_debug_show(struct seq_file *seq, void *v) | 3988 | static int sky2_debug_show(struct seq_file *seq, void *v) |
3909 | { | 3989 | { |
3910 | struct net_device *dev = seq->private; | 3990 | struct net_device *dev = seq->private; |
@@ -3914,14 +3994,18 @@ static int sky2_debug_show(struct seq_file *seq, void *v) | |||
3914 | unsigned idx, last; | 3994 | unsigned idx, last; |
3915 | int sop; | 3995 | int sop; |
3916 | 3996 | ||
3917 | if (!netif_running(dev)) | 3997 | sky2_show_vpd(seq, hw); |
3918 | return -ENETDOWN; | ||
3919 | 3998 | ||
3920 | seq_printf(seq, "IRQ src=%x mask=%x control=%x\n", | 3999 | seq_printf(seq, "\nIRQ src=%x mask=%x control=%x\n", |
3921 | sky2_read32(hw, B0_ISRC), | 4000 | sky2_read32(hw, B0_ISRC), |
3922 | sky2_read32(hw, B0_IMSK), | 4001 | sky2_read32(hw, B0_IMSK), |
3923 | sky2_read32(hw, B0_Y2_SP_ICR)); | 4002 | sky2_read32(hw, B0_Y2_SP_ICR)); |
3924 | 4003 | ||
4004 | if (!netif_running(dev)) { | ||
4005 | seq_printf(seq, "network not running\n"); | ||
4006 | return 0; | ||
4007 | } | ||
4008 | |||
3925 | napi_disable(&hw->napi); | 4009 | napi_disable(&hw->napi); |
3926 | last = sky2_read16(hw, STAT_PUT_IDX); | 4010 | last = sky2_read16(hw, STAT_PUT_IDX); |
3927 | 4011 | ||
@@ -4245,69 +4329,6 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw) | |||
4245 | return err; | 4329 | return err; |
4246 | } | 4330 | } |
4247 | 4331 | ||
4248 | /* | ||
4249 | * Read and parse the first part of Vital Product Data | ||
4250 | */ | ||
4251 | #define VPD_SIZE 128 | ||
4252 | #define VPD_MAGIC 0x82 | ||
4253 | |||
4254 | static void __devinit sky2_vpd_info(struct sky2_hw *hw) | ||
4255 | { | ||
4256 | int cap = pci_find_capability(hw->pdev, PCI_CAP_ID_VPD); | ||
4257 | const u8 *p; | ||
4258 | u8 *vpd_buf = NULL; | ||
4259 | u16 len; | ||
4260 | static struct vpd_tag { | ||
4261 | char tag[2]; | ||
4262 | char *label; | ||
4263 | } vpd_tags[] = { | ||
4264 | { "PN", "Part Number" }, | ||
4265 | { "EC", "Engineering Level" }, | ||
4266 | { "MN", "Manufacturer" }, | ||
4267 | }; | ||
4268 | |||
4269 | if (!cap) | ||
4270 | goto out; | ||
4271 | |||
4272 | vpd_buf = kmalloc(VPD_SIZE, GFP_KERNEL); | ||
4273 | if (!vpd_buf) | ||
4274 | goto out; | ||
4275 | |||
4276 | if (sky2_vpd_read(hw, cap, vpd_buf, 0, VPD_SIZE)) | ||
4277 | goto out; | ||
4278 | |||
4279 | if (vpd_buf[0] != VPD_MAGIC) | ||
4280 | goto out; | ||
4281 | len = vpd_buf[1]; | ||
4282 | if (len == 0 || len > VPD_SIZE - 4) | ||
4283 | goto out; | ||
4284 | p = vpd_buf + 3; | ||
4285 | dev_info(&hw->pdev->dev, "%.*s\n", len, p); | ||
4286 | p += len; | ||
4287 | |||
4288 | while (p < vpd_buf + VPD_SIZE - 4) { | ||
4289 | int i; | ||
4290 | |||
4291 | if (!memcmp("RW", p, 2)) /* end marker */ | ||
4292 | break; | ||
4293 | |||
4294 | len = p[2]; | ||
4295 | if (len > (p - vpd_buf) - 4) | ||
4296 | break; | ||
4297 | |||
4298 | for (i = 0; i < ARRAY_SIZE(vpd_tags); i++) { | ||
4299 | if (!memcmp(vpd_tags[i].tag, p, 2)) { | ||
4300 | printk(KERN_DEBUG " %s: %.*s\n", | ||
4301 | vpd_tags[i].label, len, p + 3); | ||
4302 | break; | ||
4303 | } | ||
4304 | } | ||
4305 | p += len + 3; | ||
4306 | } | ||
4307 | out: | ||
4308 | kfree(vpd_buf); | ||
4309 | } | ||
4310 | |||
4311 | /* This driver supports yukon2 chipset only */ | 4332 | /* This driver supports yukon2 chipset only */ |
4312 | static const char *sky2_name(u8 chipid, char *buf, int sz) | 4333 | static const char *sky2_name(u8 chipid, char *buf, int sz) |
4313 | { | 4334 | { |
@@ -4411,8 +4432,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
4411 | 4432 | ||
4412 | sky2_reset(hw); | 4433 | sky2_reset(hw); |
4413 | 4434 | ||
4414 | sky2_vpd_info(hw); | ||
4415 | |||
4416 | dev = sky2_init_netdev(hw, 0, using_dac, wol_default); | 4435 | dev = sky2_init_netdev(hw, 0, using_dac, wol_default); |
4417 | if (!dev) { | 4436 | if (!dev) { |
4418 | err = -ENOMEM; | 4437 | err = -ENOMEM; |