Commit 42114017 authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr 8139too] make features more persistent; fix PCI DAC mode

* only set PCIDAC (64-bit PCI) bit in hardware if
  sizeof(dma_addr_t) > 32.  Need a better test for whether
  64-bit mode is _really_ needed.
* cache chip command register in private struct.  this allows
  the setting of rx-vlan, rx-csum, and other features to be
  persistent across the entire lifetime of the net device.
* remove dead private struct members frag_skb, dropping_frag,
  and pci_using_dac.
parent dd2e0b6e
...@@ -362,10 +362,7 @@ struct cp_private { ...@@ -362,10 +362,7 @@ struct cp_private {
struct pci_dev *pdev; struct pci_dev *pdev;
u32 rx_config; u32 rx_config;
u16 cpcmd;
struct sk_buff *frag_skb;
unsigned dropping_frag : 1;
unsigned pci_using_dac : 1;
unsigned int wol_enabled : 1; /* Is Wake-on-LAN enabled? */ unsigned int wol_enabled : 1; /* Is Wake-on-LAN enabled? */
u32 power_state[16]; u32 power_state[16];
...@@ -431,7 +428,8 @@ static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) ...@@ -431,7 +428,8 @@ static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
spin_lock_irq(&cp->lock); spin_lock_irq(&cp->lock);
cp->vlgrp = grp; cp->vlgrp = grp;
cpw16(CpCmd, cpr16(CpCmd) | RxVlanOn); cp->cpcmd |= RxVlanOn;
cpw16(CpCmd, cp->cpcmd);
spin_unlock_irq(&cp->lock); spin_unlock_irq(&cp->lock);
} }
...@@ -440,7 +438,8 @@ static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) ...@@ -440,7 +438,8 @@ static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
struct cp_private *cp = dev->priv; struct cp_private *cp = dev->priv;
spin_lock_irq(&cp->lock); spin_lock_irq(&cp->lock);
cpw16(CpCmd, cpr16(CpCmd) & ~RxVlanOn); cp->cpcmd &= ~RxVlanOn;
cpw16(CpCmd, cp->cpcmd);
if (cp->vlgrp) if (cp->vlgrp)
cp->vlgrp->vlan_devices[vid] = NULL; cp->vlgrp->vlan_devices[vid] = NULL;
spin_unlock_irq(&cp->lock); spin_unlock_irq(&cp->lock);
...@@ -997,8 +996,7 @@ static void cp_reset_hw (struct cp_private *cp) ...@@ -997,8 +996,7 @@ static void cp_reset_hw (struct cp_private *cp)
static inline void cp_start_hw (struct cp_private *cp) static inline void cp_start_hw (struct cp_private *cp)
{ {
u16 pci_dac = cp->pci_using_dac ? PCIDAC : 0; cpw16(CpCmd, cp->cpcmd);
cpw16(CpCmd, pci_dac | PCIMulRW | RxChkSum | CpRxOn | CpTxOn);
cpw8(Cmd, RxOn | TxOn); cpw8(Cmd, RxOn | TxOn);
} }
...@@ -1387,7 +1385,7 @@ static u32 cp_get_rx_csum(struct net_device *dev) ...@@ -1387,7 +1385,7 @@ static u32 cp_get_rx_csum(struct net_device *dev)
static int cp_set_rx_csum(struct net_device *dev, u32 data) static int cp_set_rx_csum(struct net_device *dev, u32 data)
{ {
struct cp_private *cp = dev->priv; struct cp_private *cp = dev->priv;
u16 cmd = cpr16(CpCmd), newcmd; u16 cmd = cp->cpcmd, newcmd;
newcmd = cmd; newcmd = cmd;
...@@ -1398,6 +1396,7 @@ static int cp_set_rx_csum(struct net_device *dev, u32 data) ...@@ -1398,6 +1396,7 @@ static int cp_set_rx_csum(struct net_device *dev, u32 data)
if (newcmd != cmd) { if (newcmd != cmd) {
spin_lock_irq(&cp->lock); spin_lock_irq(&cp->lock);
cp->cpcmd = newcmd;
cpw16_f(CpCmd, newcmd); cpw16_f(CpCmd, newcmd);
spin_unlock_irq(&cp->lock); spin_unlock_irq(&cp->lock);
} }
...@@ -1617,7 +1616,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1617,7 +1616,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
int rc; int rc;
void *regs; void *regs;
long pciaddr; long pciaddr;
unsigned int addr_len, i; unsigned int addr_len, i, pci_using_dac;
u8 pci_rev, cache_size; u8 pci_rev, cache_size;
#ifndef MODULE #ifndef MODULE
...@@ -1684,8 +1683,9 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1684,8 +1683,9 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
} }
/* Configure DMA attributes. */ /* Configure DMA attributes. */
if (!pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) { if ((sizeof(dma_addr_t) > 32) &&
cp->pci_using_dac = 1; !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
pci_using_dac = 1;
} else { } else {
rc = pci_set_dma_mask(pdev, 0xffffffffULL); rc = pci_set_dma_mask(pdev, 0xffffffffULL);
if (rc) { if (rc) {
...@@ -1693,9 +1693,12 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1693,9 +1693,12 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
"aborting.\n"); "aborting.\n");
goto err_out_res; goto err_out_res;
} }
cp->pci_using_dac = 0; pci_using_dac = 0;
} }
cp->cpcmd = (pci_using_dac ? PCIDAC : 0) |
PCIMulRW | RxChkSum | CpRxOn | CpTxOn;
regs = ioremap_nocache(pciaddr, CP_REGS_SIZE); regs = ioremap_nocache(pciaddr, CP_REGS_SIZE);
if (!regs) { if (!regs) {
rc = -EIO; rc = -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment