aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/sky2.c94
1 files changed, 48 insertions, 46 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 1c01b96c9611..faa48410195e 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -3837,6 +3837,50 @@ static int sky2_get_regs_len(struct net_device *dev)
3837 return 0x4000; 3837 return 0x4000;
3838} 3838}
3839 3839
3840static int sky2_reg_access_ok(struct sky2_hw *hw, unsigned int b)
3841{
3842 /* This complicated switch statement is to make sure and
3843 * only access regions that are unreserved.
3844 * Some blocks are only valid on dual port cards.
3845 */
3846 switch (b) {
3847 /* second port */
3848 case 5: /* Tx Arbiter 2 */
3849 case 9: /* RX2 */
3850 case 14 ... 15: /* TX2 */
3851 case 17: case 19: /* Ram Buffer 2 */
3852 case 22 ... 23: /* Tx Ram Buffer 2 */
3853 case 25: /* Rx MAC Fifo 1 */
3854 case 27: /* Tx MAC Fifo 2 */
3855 case 31: /* GPHY 2 */
3856 case 40 ... 47: /* Pattern Ram 2 */
3857 case 52: case 54: /* TCP Segmentation 2 */
3858 case 112 ... 116: /* GMAC 2 */
3859 return hw->ports > 1;
3860
3861 case 0: /* Control */
3862 case 2: /* Mac address */
3863 case 4: /* Tx Arbiter 1 */
3864 case 7: /* PCI express reg */
3865 case 8: /* RX1 */
3866 case 12 ... 13: /* TX1 */
3867 case 16: case 18:/* Rx Ram Buffer 1 */
3868 case 20 ... 21: /* Tx Ram Buffer 1 */
3869 case 24: /* Rx MAC Fifo 1 */
3870 case 26: /* Tx MAC Fifo 1 */
3871 case 28 ... 29: /* Descriptor and status unit */
3872 case 30: /* GPHY 1*/
3873 case 32 ... 39: /* Pattern Ram 1 */
3874 case 48: case 50: /* TCP Segmentation 1 */
3875 case 56 ... 60: /* PCI space */
3876 case 80 ... 84: /* GMAC 1 */
3877 return 1;
3878
3879 default:
3880 return 0;
3881 }
3882}
3883
3840/* 3884/*
3841 * Returns copy of control register region 3885 * Returns copy of control register region
3842 * Note: ethtool_get_regs always provides full size (16k) buffer 3886 * Note: ethtool_get_regs always provides full size (16k) buffer
@@ -3851,55 +3895,13 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
3851 regs->version = 1; 3895 regs->version = 1;
3852 3896
3853 for (b = 0; b < 128; b++) { 3897 for (b = 0; b < 128; b++) {
3854 /* This complicated switch statement is to make sure and 3898 /* skip poisonous diagnostic ram region in block 3 */
3855 * only access regions that are unreserved. 3899 if (b == 3)
3856 * Some blocks are only valid on dual port cards.
3857 * and block 3 has some special diagnostic registers that
3858 * are poison.
3859 */
3860 switch (b) {
3861 case 3:
3862 /* skip diagnostic ram region */
3863 memcpy_fromio(p + 0x10, io + 0x10, 128 - 0x10); 3900 memcpy_fromio(p + 0x10, io + 0x10, 128 - 0x10);
3864 break; 3901 else if (sky2_reg_access_ok(sky2->hw, b))
3865
3866 /* dual port cards only */
3867 case 5: /* Tx Arbiter 2 */
3868 case 9: /* RX2 */
3869 case 14 ... 15: /* TX2 */
3870 case 17: case 19: /* Ram Buffer 2 */
3871 case 22 ... 23: /* Tx Ram Buffer 2 */
3872 case 25: /* Rx MAC Fifo 1 */
3873 case 27: /* Tx MAC Fifo 2 */
3874 case 31: /* GPHY 2 */
3875 case 40 ... 47: /* Pattern Ram 2 */
3876 case 52: case 54: /* TCP Segmentation 2 */
3877 case 112 ... 116: /* GMAC 2 */
3878 if (sky2->hw->ports == 1)
3879 goto reserved;
3880 /* fall through */
3881 case 0: /* Control */
3882 case 2: /* Mac address */
3883 case 4: /* Tx Arbiter 1 */
3884 case 7: /* PCI express reg */
3885 case 8: /* RX1 */
3886 case 12 ... 13: /* TX1 */
3887 case 16: case 18:/* Rx Ram Buffer 1 */
3888 case 20 ... 21: /* Tx Ram Buffer 1 */
3889 case 24: /* Rx MAC Fifo 1 */
3890 case 26: /* Tx MAC Fifo 1 */
3891 case 28 ... 29: /* Descriptor and status unit */
3892 case 30: /* GPHY 1*/
3893 case 32 ... 39: /* Pattern Ram 1 */
3894 case 48: case 50: /* TCP Segmentation 1 */
3895 case 56 ... 60: /* PCI space */
3896 case 80 ... 84: /* GMAC 1 */
3897 memcpy_fromio(p, io, 128); 3902 memcpy_fromio(p, io, 128);
3898 break; 3903 else
3899 default:
3900reserved:
3901 memset(p, 0, 128); 3904 memset(p, 0, 128);
3902 }
3903 3905
3904 p += 128; 3906 p += 128;
3905 io += 128; 3907 io += 128;