sky2: Refactor sky2_get_regs into two functions
Separate code deciding which registers can be accessed out of sky2_get_regs in preparation for adding more conditions into it. Signed-off-by: Mike McCormack <mikem@ring3k.org> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
ceba0b29e0
commit
c32bbff81c
@@ -3837,33 +3837,14 @@ static int sky2_get_regs_len(struct net_device *dev)
|
|||||||
return 0x4000;
|
return 0x4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static int sky2_reg_access_ok(struct sky2_hw *hw, unsigned int b)
|
||||||
* Returns copy of control register region
|
|
||||||
* Note: ethtool_get_regs always provides full size (16k) buffer
|
|
||||||
*/
|
|
||||||
static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
|
|
||||||
void *p)
|
|
||||||
{
|
{
|
||||||
const struct sky2_port *sky2 = netdev_priv(dev);
|
|
||||||
const void __iomem *io = sky2->hw->regs;
|
|
||||||
unsigned int b;
|
|
||||||
|
|
||||||
regs->version = 1;
|
|
||||||
|
|
||||||
for (b = 0; b < 128; b++) {
|
|
||||||
/* This complicated switch statement is to make sure and
|
/* This complicated switch statement is to make sure and
|
||||||
* only access regions that are unreserved.
|
* only access regions that are unreserved.
|
||||||
* Some blocks are only valid on dual port cards.
|
* Some blocks are only valid on dual port cards.
|
||||||
* and block 3 has some special diagnostic registers that
|
|
||||||
* are poison.
|
|
||||||
*/
|
*/
|
||||||
switch (b) {
|
switch (b) {
|
||||||
case 3:
|
/* second port */
|
||||||
/* skip diagnostic ram region */
|
|
||||||
memcpy_fromio(p + 0x10, io + 0x10, 128 - 0x10);
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* dual port cards only */
|
|
||||||
case 5: /* Tx Arbiter 2 */
|
case 5: /* Tx Arbiter 2 */
|
||||||
case 9: /* RX2 */
|
case 9: /* RX2 */
|
||||||
case 14 ... 15: /* TX2 */
|
case 14 ... 15: /* TX2 */
|
||||||
@@ -3875,9 +3856,8 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
|
|||||||
case 40 ... 47: /* Pattern Ram 2 */
|
case 40 ... 47: /* Pattern Ram 2 */
|
||||||
case 52: case 54: /* TCP Segmentation 2 */
|
case 52: case 54: /* TCP Segmentation 2 */
|
||||||
case 112 ... 116: /* GMAC 2 */
|
case 112 ... 116: /* GMAC 2 */
|
||||||
if (sky2->hw->ports == 1)
|
return hw->ports > 1;
|
||||||
goto reserved;
|
|
||||||
/* fall through */
|
|
||||||
case 0: /* Control */
|
case 0: /* Control */
|
||||||
case 2: /* Mac address */
|
case 2: /* Mac address */
|
||||||
case 4: /* Tx Arbiter 1 */
|
case 4: /* Tx Arbiter 1 */
|
||||||
@@ -3894,12 +3874,34 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
|
|||||||
case 48: case 50: /* TCP Segmentation 1 */
|
case 48: case 50: /* TCP Segmentation 1 */
|
||||||
case 56 ... 60: /* PCI space */
|
case 56 ... 60: /* PCI space */
|
||||||
case 80 ... 84: /* GMAC 1 */
|
case 80 ... 84: /* GMAC 1 */
|
||||||
memcpy_fromio(p, io, 128);
|
return 1;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
reserved:
|
return 0;
|
||||||
memset(p, 0, 128);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns copy of control register region
|
||||||
|
* Note: ethtool_get_regs always provides full size (16k) buffer
|
||||||
|
*/
|
||||||
|
static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
|
||||||
|
void *p)
|
||||||
|
{
|
||||||
|
const struct sky2_port *sky2 = netdev_priv(dev);
|
||||||
|
const void __iomem *io = sky2->hw->regs;
|
||||||
|
unsigned int b;
|
||||||
|
|
||||||
|
regs->version = 1;
|
||||||
|
|
||||||
|
for (b = 0; b < 128; b++) {
|
||||||
|
/* skip poisonous diagnostic ram region in block 3 */
|
||||||
|
if (b == 3)
|
||||||
|
memcpy_fromio(p + 0x10, io + 0x10, 128 - 0x10);
|
||||||
|
else if (sky2_reg_access_ok(sky2->hw, b))
|
||||||
|
memcpy_fromio(p, io, 128);
|
||||||
|
else
|
||||||
|
memset(p, 0, 128);
|
||||||
|
|
||||||
p += 128;
|
p += 128;
|
||||||
io += 128;
|
io += 128;
|
||||||
|
Reference in New Issue
Block a user