sky2.c (d1b803f4ca4f25d6f171219d039f9410a10b29ee) sky2.c (0efcc3f201452aa42670d2da1d72858f95d0b7f7)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * New driver for Marvell Yukon 2 chipset.
4 * Based on earlier sk98lin, and skge driver.
5 *
6 * This driver intentionally does not support all the features
7 * of the original driver such as link fail-over and link management because
8 * those should be done at higher levels.

--- 4426 unchanged lines hidden (view full) ---

4435 .get_link_ksettings = sky2_get_link_ksettings,
4436 .set_link_ksettings = sky2_set_link_ksettings,
4437};
4438
4439#ifdef CONFIG_SKY2_DEBUG
4440
4441static struct dentry *sky2_debug;
4442
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * New driver for Marvell Yukon 2 chipset.
4 * Based on earlier sk98lin, and skge driver.
5 *
6 * This driver intentionally does not support all the features
7 * of the original driver such as link fail-over and link management because
8 * those should be done at higher levels.

--- 4426 unchanged lines hidden (view full) ---

4435 .get_link_ksettings = sky2_get_link_ksettings,
4436 .set_link_ksettings = sky2_set_link_ksettings,
4437};
4438
4439#ifdef CONFIG_SKY2_DEBUG
4440
4441static struct dentry *sky2_debug;
4442
4443
4444/*
4445 * Read and parse the first part of Vital Product Data
4446 */
4447#define VPD_SIZE 128
4448#define VPD_MAGIC 0x82
4449
4450static const struct vpd_tag {
4451 char tag[2];
4452 char *label;
4453} vpd_tags[] = {
4454 { "PN", "Part Number" },
4455 { "EC", "Engineering Level" },
4456 { "MN", "Manufacturer" },
4457 { "SN", "Serial Number" },
4458 { "YA", "Asset Tag" },
4459 { "VL", "First Error Log Message" },
4460 { "VF", "Second Error Log Message" },
4461 { "VB", "Boot Agent ROM Configuration" },
4462 { "VE", "EFI UNDI Configuration" },
4463};
4464
4465static void sky2_show_vpd(struct seq_file *seq, struct sky2_hw *hw)
4466{
4467 size_t vpd_size;
4468 loff_t offs;
4469 u8 len;
4470 unsigned char *buf;
4471 u16 reg2;
4472
4473 reg2 = sky2_pci_read16(hw, PCI_DEV_REG2);
4474 vpd_size = 1 << ( ((reg2 & PCI_VPD_ROM_SZ) >> 14) + 8);
4475
4476 seq_printf(seq, "%s Product Data\n", pci_name(hw->pdev));
4477 buf = kmalloc(vpd_size, GFP_KERNEL);
4478 if (!buf) {
4479 seq_puts(seq, "no memory!\n");
4480 return;
4481 }
4482
4483 if (pci_read_vpd(hw->pdev, 0, vpd_size, buf) < 0) {
4484 seq_puts(seq, "VPD read failed\n");
4485 goto out;
4486 }
4487
4488 if (buf[0] != VPD_MAGIC) {
4489 seq_printf(seq, "VPD tag mismatch: %#x\n", buf[0]);
4490 goto out;
4491 }
4492 len = buf[1];
4493 if (len == 0 || len > vpd_size - 4) {
4494 seq_printf(seq, "Invalid id length: %d\n", len);
4495 goto out;
4496 }
4497
4498 seq_printf(seq, "%.*s\n", len, buf + 3);
4499 offs = len + 3;
4500
4501 while (offs < vpd_size - 4) {
4502 int i;
4503
4504 if (!memcmp("RW", buf + offs, 2)) /* end marker */
4505 break;
4506 len = buf[offs + 2];
4507 if (offs + len + 3 >= vpd_size)
4508 break;
4509
4510 for (i = 0; i < ARRAY_SIZE(vpd_tags); i++) {
4511 if (!memcmp(vpd_tags[i].tag, buf + offs, 2)) {
4512 seq_printf(seq, " %s: %.*s\n",
4513 vpd_tags[i].label, len, buf + offs + 3);
4514 break;
4515 }
4516 }
4517 offs += len + 3;
4518 }
4519out:
4520 kfree(buf);
4521}
4522
4523static int sky2_debug_show(struct seq_file *seq, void *v)
4524{
4525 struct net_device *dev = seq->private;
4526 const struct sky2_port *sky2 = netdev_priv(dev);
4527 struct sky2_hw *hw = sky2->hw;
4528 unsigned port = sky2->port;
4529 unsigned idx, last;
4530 int sop;
4531
4443static int sky2_debug_show(struct seq_file *seq, void *v)
4444{
4445 struct net_device *dev = seq->private;
4446 const struct sky2_port *sky2 = netdev_priv(dev);
4447 struct sky2_hw *hw = sky2->hw;
4448 unsigned port = sky2->port;
4449 unsigned idx, last;
4450 int sop;
4451
4532 sky2_show_vpd(seq, hw);
4533
4534 seq_printf(seq, "\nIRQ src=%x mask=%x control=%x\n",
4452 seq_printf(seq, "IRQ src=%x mask=%x control=%x\n",
4535 sky2_read32(hw, B0_ISRC),
4536 sky2_read32(hw, B0_IMSK),
4537 sky2_read32(hw, B0_Y2_SP_ICR));
4538
4539 if (!netif_running(dev)) {
4540 seq_puts(seq, "network not running\n");
4541 return 0;
4542 }

--- 759 unchanged lines hidden ---
4453 sky2_read32(hw, B0_ISRC),
4454 sky2_read32(hw, B0_IMSK),
4455 sky2_read32(hw, B0_Y2_SP_ICR));
4456
4457 if (!netif_running(dev)) {
4458 seq_puts(seq, "network not running\n");
4459 return 0;
4460 }

--- 759 unchanged lines hidden ---