aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tokenring/olympic.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2007-10-03 20:59:30 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:51:42 -0400
commit0795af5729b18218767fab27c44b1384f72dc9ad (patch)
tree67c16df84aa6ec219340b8ea1b5cfb0e8150a216 /drivers/net/tokenring/olympic.c
parent95ea36275f3c9a1d3d04c217b4b576c657c4e70e (diff)
[NET]: Introduce and use print_mac() and DECLARE_MAC_BUF()
This is nicer than the MAC_FMT stuff. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tokenring/olympic.c')
-rw-r--r--drivers/net/tokenring/olympic.c138
1 files changed, 60 insertions, 78 deletions
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index a149d5e2965c..74c1f0f189f5 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -418,14 +418,15 @@ static int __devinit olympic_init(struct net_device *dev)
418 writel(uaa_addr,olympic_mmio+LAPA); 418 writel(uaa_addr,olympic_mmio+LAPA);
419 adapter_addr=olympic_priv->olympic_lap + (uaa_addr & (~0xf800)); 419 adapter_addr=olympic_priv->olympic_lap + (uaa_addr & (~0xf800));
420 420
421 memcpy_fromio(&dev->dev_addr[0], adapter_addr,6);
422
421#if OLYMPIC_DEBUG 423#if OLYMPIC_DEBUG
422 printk("adapter address: %02x:%02x:%02x:%02x:%02x:%02x\n", 424 {
423 readb(adapter_addr), readb(adapter_addr+1),readb(adapter_addr+2), 425 DECLARE_MAC_BUF(mac);
424 readb(adapter_addr+3),readb(adapter_addr+4),readb(adapter_addr+5)); 426 printk("adapter address: %s\n", print_mac(mac, dev->dev_addr));
427 }
425#endif 428#endif
426 429
427 memcpy_fromio(&dev->dev_addr[0], adapter_addr,6);
428
429 olympic_priv->olympic_addr_table_addr = swab16(readw(init_srb + 12)); 430 olympic_priv->olympic_addr_table_addr = swab16(readw(init_srb + 12));
430 olympic_priv->olympic_parms_addr = swab16(readw(init_srb + 14)); 431 olympic_priv->olympic_parms_addr = swab16(readw(init_srb + 14));
431 432
@@ -440,6 +441,7 @@ static int olympic_open(struct net_device *dev)
440 unsigned long flags, t; 441 unsigned long flags, t;
441 int i, open_finished = 1 ; 442 int i, open_finished = 1 ;
442 u8 resp, err; 443 u8 resp, err;
444 DECLARE_MAC_BUF(mac);
443 445
444 DECLARE_WAITQUEUE(wait,current) ; 446 DECLARE_WAITQUEUE(wait,current) ;
445 447
@@ -567,14 +569,8 @@ static int olympic_open(struct net_device *dev)
567 goto out; 569 goto out;
568 570
569 case 0x32: 571 case 0x32:
570 printk(KERN_WARNING "%s: Invalid LAA: %02x:%02x:%02x:%02x:%02x:%02x\n", 572 printk(KERN_WARNING "%s: Invalid LAA: %s\n",
571 dev->name, 573 dev->name, print_mac(mac, olympic_priv->olympic_laa));
572 olympic_priv->olympic_laa[0],
573 olympic_priv->olympic_laa[1],
574 olympic_priv->olympic_laa[2],
575 olympic_priv->olympic_laa[3],
576 olympic_priv->olympic_laa[4],
577 olympic_priv->olympic_laa[5]) ;
578 goto out; 574 goto out;
579 575
580 default: 576 default:
@@ -704,30 +700,26 @@ static int olympic_open(struct net_device *dev)
704#endif 700#endif
705 701
706 if (olympic_priv->olympic_network_monitor) { 702 if (olympic_priv->olympic_network_monitor) {
707 u8 __iomem *oat ; 703 u8 __iomem *oat;
708 u8 __iomem *opt ; 704 u8 __iomem *opt;
709 oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr) ; 705 int i;
710 opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr) ; 706 u8 addr[6];
711 707 DECLARE_MAC_BUF(mac);
712 printk("%s: Node Address: %02x:%02x:%02x:%02x:%02x:%02x\n",dev->name, 708 oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr);
713 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)), 709 opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr);
714 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+1), 710
715 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+2), 711 for (i = 0; i < 6; i++)
716 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+3), 712 addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+i);
717 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+4), 713 printk("%s: Node Address: %s\n",dev->name, print_mac(mac, addr));
718 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+5));
719 printk("%s: Functional Address: %02x:%02x:%02x:%02x\n",dev->name, 714 printk("%s: Functional Address: %02x:%02x:%02x:%02x\n",dev->name,
720 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)), 715 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)),
721 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1), 716 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1),
722 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2), 717 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2),
723 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+3)); 718 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+3));
724 printk("%s: NAUN Address: %02x:%02x:%02x:%02x:%02x:%02x\n",dev->name, 719
725 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)), 720 for (i = 0; i < 6; i++)
726 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+1), 721 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+i);
727 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+2), 722 printk("%s: NAUN Address: %s\n",dev->name, print_mac(mac, addr));
728 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+3),
729 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+4),
730 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+5));
731 } 723 }
732 724
733 netif_start_queue(dev); 725 netif_start_queue(dev);
@@ -1445,11 +1437,14 @@ static void olympic_arb_cmd(struct net_device *dev)
1445 mac_frame->protocol = tr_type_trans(mac_frame, dev); 1437 mac_frame->protocol = tr_type_trans(mac_frame, dev);
1446 1438
1447 if (olympic_priv->olympic_network_monitor) { 1439 if (olympic_priv->olympic_network_monitor) {
1448 struct trh_hdr *mac_hdr ; 1440 struct trh_hdr *mac_hdr;
1449 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name) ; 1441 DECLARE_MAC_BUF(mac);
1442 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name);
1450 mac_hdr = tr_hdr(mac_frame); 1443 mac_hdr = tr_hdr(mac_frame);
1451 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: %02x:%02x:%02x:%02x:%02x:%02x \n", dev->name , mac_hdr->daddr[0], mac_hdr->daddr[1], mac_hdr->daddr[2], mac_hdr->daddr[3], mac_hdr->daddr[4], mac_hdr->daddr[5]) ; 1444 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: %s\n",
1452 printk(KERN_WARNING "%s: MAC Frame Srce. Addr: %02x:%02x:%02x:%02x:%02x:%02x \n", dev->name , mac_hdr->saddr[0], mac_hdr->saddr[1], mac_hdr->saddr[2], mac_hdr->saddr[3], mac_hdr->saddr[4], mac_hdr->saddr[5]) ; 1445 dev->name, print_mac(mac, mac_hdr->daddr));
1446 printk(KERN_WARNING "%s: MAC Frame Srce. Addr: %s\n",
1447 dev->name, print_mac(mac, mac_hdr->saddr));
1453 } 1448 }
1454 netif_rx(mac_frame); 1449 netif_rx(mac_frame);
1455 dev->last_rx = jiffies; 1450 dev->last_rx = jiffies;
@@ -1644,26 +1639,24 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1644 int len=0; 1639 int len=0;
1645 off_t begin=0; 1640 off_t begin=0;
1646 off_t pos=0; 1641 off_t pos=0;
1647 1642 u8 addr[6];
1643 u8 addr2[6];
1644 int i;
1645 DECLARE_MAC_BUF(mac);
1646 DECLARE_MAC_BUF(mac2);
1647
1648 size = sprintf(buffer, 1648 size = sprintf(buffer,
1649 "IBM Pit/Pit-Phy/Olympic Chipset Token Ring Adapter %s\n",dev->name); 1649 "IBM Pit/Pit-Phy/Olympic Chipset Token Ring Adapter %s\n",dev->name);
1650 size += sprintf(buffer+size, "\n%6s: Adapter Address : Node Address : Functional Addr\n", 1650 size += sprintf(buffer+size, "\n%6s: Adapter Address : Node Address : Functional Addr\n",
1651 dev->name); 1651 dev->name);
1652 1652
1653 size += sprintf(buffer+size, "%6s: %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x\n", 1653 for (i = 0 ; i < 6 ; i++)
1654 addr[i] = readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr) + i);
1655
1656 size += sprintf(buffer+size, "%6s: %s : %s : %02x:%02x:%02x:%02x\n",
1654 dev->name, 1657 dev->name,
1655 dev->dev_addr[0], 1658 print_mac(mac, dev->dev_addr),
1656 dev->dev_addr[1], 1659 print_mac(mac2, addr),
1657 dev->dev_addr[2],
1658 dev->dev_addr[3],
1659 dev->dev_addr[4],
1660 dev->dev_addr[5],
1661 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)),
1662 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+1),
1663 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+2),
1664 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+3),
1665 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+4),
1666 readb(oat+offsetof(struct olympic_adapter_addr_table,node_addr)+5),
1667 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)), 1660 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)),
1668 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1), 1661 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+1),
1669 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2), 1662 readb(oat+offsetof(struct olympic_adapter_addr_table,func_addr)+2),
@@ -1673,25 +1666,20 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1673 1666
1674 size += sprintf(buffer+size, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n", 1667 size += sprintf(buffer+size, "%6s: Physical Addr : Up Node Address : Poll Address : AccPri : Auth Src : Att Code :\n",
1675 dev->name) ; 1668 dev->name) ;
1676 1669
1677 size += sprintf(buffer+size, "%6s: %02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %04x : %04x : %04x :\n", 1670 for (i = 0 ; i < 6 ; i++)
1671 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, up_node_addr) + i);
1672 for (i = 0 ; i < 6 ; i++)
1673 addr2[i] = readb(opt+offsetof(struct olympic_parameters_table, poll_addr) + i);
1674
1675 size += sprintf(buffer+size, "%6s: %02x:%02x:%02x:%02x : %s : %s : %04x : %04x : %04x :\n",
1678 dev->name, 1676 dev->name,
1679 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)), 1677 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)),
1680 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+1), 1678 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+1),
1681 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+2), 1679 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+2),
1682 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+3), 1680 readb(opt+offsetof(struct olympic_parameters_table, phys_addr)+3),
1683 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)), 1681 print_mac(mac, addr),
1684 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+1), 1682 print_mac(mac2, addr2),
1685 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+2),
1686 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+3),
1687 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+4),
1688 readb(opt+offsetof(struct olympic_parameters_table, up_node_addr)+5),
1689 readb(opt+offsetof(struct olympic_parameters_table, poll_addr)),
1690 readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+1),
1691 readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+2),
1692 readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+3),
1693 readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+4),
1694 readb(opt+offsetof(struct olympic_parameters_table, poll_addr)+5),
1695 swab16(readw(opt+offsetof(struct olympic_parameters_table, acc_priority))), 1683 swab16(readw(opt+offsetof(struct olympic_parameters_table, acc_priority))),
1696 swab16(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))), 1684 swab16(readw(opt+offsetof(struct olympic_parameters_table, auth_source_class))),
1697 swab16(readw(opt+offsetof(struct olympic_parameters_table, att_code)))); 1685 swab16(readw(opt+offsetof(struct olympic_parameters_table, att_code))));
@@ -1699,14 +1687,11 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1699 size += sprintf(buffer+size, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", 1687 size += sprintf(buffer+size, "%6s: Source Address : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n",
1700 dev->name) ; 1688 dev->name) ;
1701 1689
1702 size += sprintf(buffer+size, "%6s: %02x:%02x:%02x:%02x:%02x:%02x : %04x : %04x : %04x : %04x : %04x : %04x : \n", 1690 for (i = 0 ; i < 6 ; i++)
1691 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, source_addr) + i);
1692 size += sprintf(buffer+size, "%6s: %s : %04x : %04x : %04x : %04x : %04x : %04x : \n",
1703 dev->name, 1693 dev->name,
1704 readb(opt+offsetof(struct olympic_parameters_table, source_addr)), 1694 print_mac(mac, addr),
1705 readb(opt+offsetof(struct olympic_parameters_table, source_addr)+1),
1706 readb(opt+offsetof(struct olympic_parameters_table, source_addr)+2),
1707 readb(opt+offsetof(struct olympic_parameters_table, source_addr)+3),
1708 readb(opt+offsetof(struct olympic_parameters_table, source_addr)+4),
1709 readb(opt+offsetof(struct olympic_parameters_table, source_addr)+5),
1710 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))), 1695 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_type))),
1711 swab16(readw(opt+offsetof(struct olympic_parameters_table, major_vector))), 1696 swab16(readw(opt+offsetof(struct olympic_parameters_table, major_vector))),
1712 swab16(readw(opt+offsetof(struct olympic_parameters_table, lan_status))), 1697 swab16(readw(opt+offsetof(struct olympic_parameters_table, lan_status))),
@@ -1717,16 +1702,13 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt
1717 size += sprintf(buffer+size, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n", 1702 size += sprintf(buffer+size, "%6s: Beacon Details : Tx : Rx : NAUN Node Address : NAUN Node Phys : \n",
1718 dev->name) ; 1703 dev->name) ;
1719 1704
1720 size += sprintf(buffer+size, "%6s: : %02x : %02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x : \n", 1705 for (i = 0 ; i < 6 ; i++)
1706 addr[i] = readb(opt+offsetof(struct olympic_parameters_table, beacon_naun) + i);
1707 size += sprintf(buffer+size, "%6s: : %02x : %02x : %s : %02x:%02x:%02x:%02x : \n",
1721 dev->name, 1708 dev->name,
1722 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))), 1709 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_transmit))),
1723 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))), 1710 swab16(readw(opt+offsetof(struct olympic_parameters_table, beacon_receive))),
1724 readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)), 1711 print_mac(mac, addr),
1725 readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)+1),
1726 readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)+2),
1727 readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)+3),
1728 readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)+4),
1729 readb(opt+offsetof(struct olympic_parameters_table, beacon_naun)+5),
1730 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)), 1712 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)),
1731 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+1), 1713 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+1),
1732 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+2), 1714 readb(opt+offsetof(struct olympic_parameters_table, beacon_phys)+2),