netxen: remove sub 64-bit mem accesses

Sub 64-bit / unaligned access to oncard memory was only used
by old diagnostic tools, causes some intermittent issues when
memory controller agent is used.  The new access method was
added by commit ea6828b8aa
("netxen: improve pci memory access").  Firmware init anyway
uses 8-byte strides.

This also fixes address/offset calculation for NX2031 context
memory (SIU). For NX3031, SIU uses same register offsets
as packet memory (MIU).

Signed-off-by: Amit Kumar Salecha <amit@netxen.com>
Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Amit Kumar Salecha 2009-10-13 05:31:41 +00:00 committed by David S. Miller
parent 89d71a66c4
commit 1f5e055db3
4 changed files with 192 additions and 316 deletions

View file

@ -1180,8 +1180,8 @@ struct netxen_adapter {
u32 (*crb_read)(struct netxen_adapter *, ulong); u32 (*crb_read)(struct netxen_adapter *, ulong);
int (*crb_write)(struct netxen_adapter *, ulong, u32); int (*crb_write)(struct netxen_adapter *, ulong, u32);
int (*pci_mem_read)(struct netxen_adapter *, u64, void *, int); int (*pci_mem_read)(struct netxen_adapter *, u64, u64 *);
int (*pci_mem_write)(struct netxen_adapter *, u64, void *, int); int (*pci_mem_write)(struct netxen_adapter *, u64, u64);
unsigned long (*pci_set_window)(struct netxen_adapter *, unsigned long (*pci_set_window)(struct netxen_adapter *,
unsigned long long); unsigned long long);

View file

@ -661,40 +661,47 @@ enum {
#define NETXEN_NIU_AP_STATION_ADDR_0(I) (NETXEN_CRB_NIU+0xa0040+(I)*0x10000) #define NETXEN_NIU_AP_STATION_ADDR_0(I) (NETXEN_CRB_NIU+0xa0040+(I)*0x10000)
#define NETXEN_NIU_AP_STATION_ADDR_1(I) (NETXEN_CRB_NIU+0xa0044+(I)*0x10000) #define NETXEN_NIU_AP_STATION_ADDR_1(I) (NETXEN_CRB_NIU+0xa0044+(I)*0x10000)
#define TEST_AGT_CTRL (0x00)
#define TA_CTL_START 1
#define TA_CTL_ENABLE 2
#define TA_CTL_WRITE 4
#define TA_CTL_BUSY 8
/* /*
* Register offsets for MN * Register offsets for MN
*/ */
#define MIU_CONTROL (0x000) #define MIU_TEST_AGT_BASE (0x90)
#define MIU_TEST_AGT_CTRL (0x090)
#define MIU_TEST_AGT_ADDR_LO (0x094)
#define MIU_TEST_AGT_ADDR_HI (0x098)
#define MIU_TEST_AGT_WRDATA_LO (0x0a0)
#define MIU_TEST_AGT_WRDATA_HI (0x0a4)
#define MIU_TEST_AGT_WRDATA(i) (0x0a0+(4*(i)))
#define MIU_TEST_AGT_RDDATA_LO (0x0a8)
#define MIU_TEST_AGT_RDDATA_HI (0x0ac)
#define MIU_TEST_AGT_RDDATA(i) (0x0a8+(4*(i)))
#define MIU_TEST_AGT_ADDR_MASK 0xfffffff8
#define MIU_TEST_AGT_UPPER_ADDR(off) (0)
/* MIU_TEST_AGT_CTRL flags. work for SIU as well */ #define MIU_TEST_AGT_ADDR_LO (0x04)
#define MIU_TA_CTL_START 1 #define MIU_TEST_AGT_ADDR_HI (0x08)
#define MIU_TA_CTL_ENABLE 2 #define MIU_TEST_AGT_WRDATA_LO (0x10)
#define MIU_TA_CTL_WRITE 4 #define MIU_TEST_AGT_WRDATA_HI (0x14)
#define MIU_TA_CTL_BUSY 8 #define MIU_TEST_AGT_WRDATA(i) (0x10+(4*(i)))
#define MIU_TEST_AGT_RDDATA_LO (0x18)
#define MIU_TEST_AGT_RDDATA_HI (0x1c)
#define MIU_TEST_AGT_RDDATA(i) (0x18+(4*(i)))
#define SIU_TEST_AGT_CTRL (0x060) #define MIU_TEST_AGT_ADDR_MASK 0xfffffff8
#define SIU_TEST_AGT_ADDR_LO (0x064) #define MIU_TEST_AGT_UPPER_ADDR(off) (0)
#define SIU_TEST_AGT_ADDR_HI (0x078)
#define SIU_TEST_AGT_WRDATA_LO (0x068)
#define SIU_TEST_AGT_WRDATA_HI (0x06c)
#define SIU_TEST_AGT_WRDATA(i) (0x068+(4*(i)))
#define SIU_TEST_AGT_RDDATA_LO (0x070)
#define SIU_TEST_AGT_RDDATA_HI (0x074)
#define SIU_TEST_AGT_RDDATA(i) (0x070+(4*(i)))
#define SIU_TEST_AGT_ADDR_MASK 0x3ffff8 /*
#define SIU_TEST_AGT_UPPER_ADDR(off) ((off)>>22) * Register offsets for MS
*/
#define SIU_TEST_AGT_BASE (0x60)
#define SIU_TEST_AGT_ADDR_LO (0x04)
#define SIU_TEST_AGT_ADDR_HI (0x18)
#define SIU_TEST_AGT_WRDATA_LO (0x08)
#define SIU_TEST_AGT_WRDATA_HI (0x0c)
#define SIU_TEST_AGT_WRDATA(i) (0x08+(4*(i)))
#define SIU_TEST_AGT_RDDATA_LO (0x10)
#define SIU_TEST_AGT_RDDATA_HI (0x14)
#define SIU_TEST_AGT_RDDATA(i) (0x10+(4*(i)))
#define SIU_TEST_AGT_ADDR_MASK 0x3ffff8
#define SIU_TEST_AGT_UPPER_ADDR(off) ((off)>>22)
/* XG Link status */ /* XG Link status */
#define XG_LINK_UP 0x10 #define XG_LINK_UP 0x10

View file

@ -1458,101 +1458,69 @@ netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
static int static int
netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter, netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
u64 off, void *data, int size) u64 off, u64 data)
{ {
unsigned long flags; unsigned long flags;
int i, j, ret = 0, loop, sz[2], off0; int j, ret;
uint32_t temp; u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo;
uint64_t off8, tmpw, word[2] = {0, 0};
void __iomem *mem_crb; void __iomem *mem_crb;
if (size != 8) /* Only 64-bit aligned access */
if (off & 7)
return -EIO; return -EIO;
/* P2 has different SIU and MIU test agent base addr */
if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET, if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET,
NETXEN_ADDR_QDR_NET_MAX_P2)) { NETXEN_ADDR_QDR_NET_MAX_P2)) {
mem_crb = pci_base_offset(adapter, NETXEN_CRB_QDR_NET); mem_crb = pci_base_offset(adapter,
NETXEN_CRB_QDR_NET+SIU_TEST_AGT_BASE);
addr_hi = SIU_TEST_AGT_ADDR_HI;
data_lo = SIU_TEST_AGT_WRDATA_LO;
data_hi = SIU_TEST_AGT_WRDATA_HI;
off_lo = off & SIU_TEST_AGT_ADDR_MASK;
off_hi = SIU_TEST_AGT_UPPER_ADDR(off);
goto correct; goto correct;
} }
if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) { if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
mem_crb = pci_base_offset(adapter, NETXEN_CRB_DDR_NET); mem_crb = pci_base_offset(adapter,
NETXEN_CRB_DDR_NET+MIU_TEST_AGT_BASE);
addr_hi = MIU_TEST_AGT_ADDR_HI;
data_lo = MIU_TEST_AGT_WRDATA_LO;
data_hi = MIU_TEST_AGT_WRDATA_HI;
off_lo = off & MIU_TEST_AGT_ADDR_MASK;
off_hi = 0;
goto correct; goto correct;
} }
return -EIO; return -EIO;
correct: correct:
off8 = off & 0xfffffff8;
off0 = off & 0x7;
sz[0] = (size < (8 - off0)) ? size : (8 - off0);
sz[1] = size - sz[0];
loop = ((off0 + size - 1) >> 3) + 1;
if ((size != 8) || (off0 != 0)) {
for (i = 0; i < loop; i++) {
if (adapter->pci_mem_read(adapter,
off8 + (i << 3), &word[i], 8))
return -1;
}
}
switch (size) {
case 1:
tmpw = *((uint8_t *)data);
break;
case 2:
tmpw = *((uint16_t *)data);
break;
case 4:
tmpw = *((uint32_t *)data);
break;
case 8:
default:
tmpw = *((uint64_t *)data);
break;
}
word[0] &= ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8));
word[0] |= tmpw << (off0 * 8);
if (loop == 2) {
word[1] &= ~(~0ULL << (sz[1] * 8));
word[1] |= tmpw >> (sz[0] * 8);
}
write_lock_irqsave(&adapter->adapter_lock, flags); write_lock_irqsave(&adapter->adapter_lock, flags);
netxen_nic_pci_change_crbwindow_128M(adapter, 0); netxen_nic_pci_change_crbwindow_128M(adapter, 0);
for (i = 0; i < loop; i++) { writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO));
writel((uint32_t)(off8 + (i << 3)), writel(off_hi, (mem_crb + addr_hi));
(mem_crb+MIU_TEST_AGT_ADDR_LO)); writel(data & 0xffffffff, (mem_crb + data_lo));
writel(0, writel((data >> 32) & 0xffffffff, (mem_crb + data_hi));
(mem_crb+MIU_TEST_AGT_ADDR_HI)); writel((TA_CTL_ENABLE | TA_CTL_WRITE), (mem_crb + TEST_AGT_CTRL));
writel(word[i] & 0xffffffff, writel((TA_CTL_START | TA_CTL_ENABLE | TA_CTL_WRITE),
(mem_crb+MIU_TEST_AGT_WRDATA_LO)); (mem_crb + TEST_AGT_CTRL));
writel((word[i] >> 32) & 0xffffffff,
(mem_crb+MIU_TEST_AGT_WRDATA_HI));
writel(MIU_TA_CTL_ENABLE|MIU_TA_CTL_WRITE,
(mem_crb+MIU_TEST_AGT_CTRL));
writel(MIU_TA_CTL_START|MIU_TA_CTL_ENABLE|MIU_TA_CTL_WRITE,
(mem_crb+MIU_TEST_AGT_CTRL));
for (j = 0; j < MAX_CTL_CHECK; j++) { for (j = 0; j < MAX_CTL_CHECK; j++) {
temp = readl( temp = readl((mem_crb + TEST_AGT_CTRL));
(mem_crb+MIU_TEST_AGT_CTRL)); if ((temp & TA_CTL_BUSY) == 0)
if ((temp & MIU_TA_CTL_BUSY) == 0)
break;
}
if (j >= MAX_CTL_CHECK) {
if (printk_ratelimit())
dev_err(&adapter->pdev->dev,
"failed to write through agent\n");
ret = -1;
break; break;
}
} }
if (j >= MAX_CTL_CHECK) {
if (printk_ratelimit())
dev_err(&adapter->pdev->dev,
"failed to write through agent\n");
ret = -EIO;
} else
ret = 0;
netxen_nic_pci_change_crbwindow_128M(adapter, 1); netxen_nic_pci_change_crbwindow_128M(adapter, 1);
write_unlock_irqrestore(&adapter->adapter_lock, flags); write_unlock_irqrestore(&adapter->adapter_lock, flags);
return ret; return ret;
@ -1560,304 +1528,202 @@ netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
static int static int
netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter, netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
u64 off, void *data, int size) u64 off, u64 *data)
{ {
unsigned long flags; unsigned long flags;
int i, j = 0, k, start, end, loop, sz[2], off0[2]; int j, ret;
uint32_t temp; u32 temp, off_lo, off_hi, addr_hi, data_hi, data_lo;
uint64_t off8, val, word[2] = {0, 0}; u64 val;
void __iomem *mem_crb; void __iomem *mem_crb;
if (size != 8) /* Only 64-bit aligned access */
if (off & 7)
return -EIO; return -EIO;
/* P2 has different SIU and MIU test agent base addr */
if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET, if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET,
NETXEN_ADDR_QDR_NET_MAX_P2)) { NETXEN_ADDR_QDR_NET_MAX_P2)) {
mem_crb = pci_base_offset(adapter, NETXEN_CRB_QDR_NET); mem_crb = pci_base_offset(adapter,
NETXEN_CRB_QDR_NET+SIU_TEST_AGT_BASE);
addr_hi = SIU_TEST_AGT_ADDR_HI;
data_lo = SIU_TEST_AGT_RDDATA_LO;
data_hi = SIU_TEST_AGT_RDDATA_HI;
off_lo = off & SIU_TEST_AGT_ADDR_MASK;
off_hi = SIU_TEST_AGT_UPPER_ADDR(off);
goto correct; goto correct;
} }
if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) { if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
mem_crb = pci_base_offset(adapter, NETXEN_CRB_DDR_NET); mem_crb = pci_base_offset(adapter,
NETXEN_CRB_DDR_NET+MIU_TEST_AGT_BASE);
addr_hi = MIU_TEST_AGT_ADDR_HI;
data_lo = MIU_TEST_AGT_RDDATA_LO;
data_hi = MIU_TEST_AGT_RDDATA_HI;
off_lo = off & MIU_TEST_AGT_ADDR_MASK;
off_hi = 0;
goto correct; goto correct;
} }
return -EIO; return -EIO;
correct: correct:
off8 = off & 0xfffffff8;
off0[0] = off & 0x7;
off0[1] = 0;
sz[0] = (size < (8 - off0[0])) ? size : (8 - off0[0]);
sz[1] = size - sz[0];
loop = ((off0[0] + size - 1) >> 3) + 1;
write_lock_irqsave(&adapter->adapter_lock, flags); write_lock_irqsave(&adapter->adapter_lock, flags);
netxen_nic_pci_change_crbwindow_128M(adapter, 0); netxen_nic_pci_change_crbwindow_128M(adapter, 0);
for (i = 0; i < loop; i++) { writel(off_lo, (mem_crb + MIU_TEST_AGT_ADDR_LO));
writel((uint32_t)(off8 + (i << 3)), writel(off_hi, (mem_crb + addr_hi));
(mem_crb+MIU_TEST_AGT_ADDR_LO)); writel(TA_CTL_ENABLE, (mem_crb + TEST_AGT_CTRL));
writel(0, writel((TA_CTL_START|TA_CTL_ENABLE), (mem_crb + TEST_AGT_CTRL));
(mem_crb+MIU_TEST_AGT_ADDR_HI));
writel(MIU_TA_CTL_ENABLE,
(mem_crb+MIU_TEST_AGT_CTRL));
writel(MIU_TA_CTL_START|MIU_TA_CTL_ENABLE,
(mem_crb+MIU_TEST_AGT_CTRL));
for (j = 0; j < MAX_CTL_CHECK; j++) { for (j = 0; j < MAX_CTL_CHECK; j++) {
temp = readl( temp = readl(mem_crb + TEST_AGT_CTRL);
(mem_crb+MIU_TEST_AGT_CTRL)); if ((temp & TA_CTL_BUSY) == 0)
if ((temp & MIU_TA_CTL_BUSY) == 0)
break;
}
if (j >= MAX_CTL_CHECK) {
if (printk_ratelimit())
dev_err(&adapter->pdev->dev,
"failed to read through agent\n");
break; break;
} }
start = off0[i] >> 2; if (j >= MAX_CTL_CHECK) {
end = (off0[i] + sz[i] - 1) >> 2; if (printk_ratelimit())
for (k = start; k <= end; k++) { dev_err(&adapter->pdev->dev,
word[i] |= ((uint64_t) readl( "failed to read through agent\n");
(mem_crb + ret = -EIO;
MIU_TEST_AGT_RDDATA(k))) << (32*k)); } else {
}
temp = readl(mem_crb + data_hi);
val = ((u64)temp << 32);
val |= readl(mem_crb + data_lo);
*data = val;
ret = 0;
} }
netxen_nic_pci_change_crbwindow_128M(adapter, 1); netxen_nic_pci_change_crbwindow_128M(adapter, 1);
write_unlock_irqrestore(&adapter->adapter_lock, flags); write_unlock_irqrestore(&adapter->adapter_lock, flags);
if (j >= MAX_CTL_CHECK) return ret;
return -1;
if (sz[0] == 8) {
val = word[0];
} else {
val = ((word[0] >> (off0[0] * 8)) & (~(~0ULL << (sz[0] * 8)))) |
((word[1] & (~(~0ULL << (sz[1] * 8)))) << (sz[0] * 8));
}
switch (size) {
case 1:
*(uint8_t *)data = val;
break;
case 2:
*(uint16_t *)data = val;
break;
case 4:
*(uint32_t *)data = val;
break;
case 8:
*(uint64_t *)data = val;
break;
}
return 0;
} }
static int static int
netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter, netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
u64 off, void *data, int size) u64 off, u64 data)
{ {
int i, j, ret = 0, loop, sz[2], off0; unsigned long flags;
uint32_t temp; int j, ret;
uint64_t off8, tmpw, word[2] = {0, 0}; u32 temp, off8;
void __iomem *mem_crb; void __iomem *mem_crb;
if (size != 8) /* Only 64-bit aligned access */
if (off & 7)
return -EIO; return -EIO;
/* P3 onward, test agent base for MIU and SIU is same */
if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET, if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET,
NETXEN_ADDR_QDR_NET_MAX_P3)) { NETXEN_ADDR_QDR_NET_MAX_P3)) {
mem_crb = netxen_get_ioaddr(adapter, NETXEN_CRB_QDR_NET); mem_crb = netxen_get_ioaddr(adapter,
NETXEN_CRB_QDR_NET+MIU_TEST_AGT_BASE);
goto correct; goto correct;
} }
if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) { if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
mem_crb = netxen_get_ioaddr(adapter, NETXEN_CRB_DDR_NET); mem_crb = netxen_get_ioaddr(adapter,
NETXEN_CRB_DDR_NET+MIU_TEST_AGT_BASE);
goto correct; goto correct;
} }
return -EIO; return -EIO;
correct: correct:
off8 = off & 0xfffffff8; off8 = off & MIU_TEST_AGT_ADDR_MASK;
off0 = off & 0x7;
sz[0] = (size < (8 - off0)) ? size : (8 - off0);
sz[1] = size - sz[0];
loop = ((off0 + size - 1) >> 3) + 1;
if ((size != 8) || (off0 != 0)) { write_lock_irqsave(&adapter->adapter_lock, flags);
for (i = 0; i < loop; i++) {
if (adapter->pci_mem_read(adapter,
off8 + (i << 3), &word[i], 8))
return -1;
}
}
switch (size) { writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO));
case 1: writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI));
tmpw = *((uint8_t *)data); writel(data & 0xffffffff, mem_crb + MIU_TEST_AGT_WRDATA_LO);
break; writel((data >> 32) & 0xffffffff, mem_crb + MIU_TEST_AGT_WRDATA_HI);
case 2: writel((TA_CTL_ENABLE | TA_CTL_WRITE), (mem_crb + TEST_AGT_CTRL));
tmpw = *((uint16_t *)data); writel((TA_CTL_START | TA_CTL_ENABLE | TA_CTL_WRITE),
break; (mem_crb + TEST_AGT_CTRL));
case 4:
tmpw = *((uint32_t *)data);
break;
case 8:
default:
tmpw = *((uint64_t *)data);
break;
}
word[0] &= ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8)); for (j = 0; j < MAX_CTL_CHECK; j++) {
word[0] |= tmpw << (off0 * 8); temp = readl(mem_crb + TEST_AGT_CTRL);
if ((temp & TA_CTL_BUSY) == 0)
if (loop == 2) {
word[1] &= ~(~0ULL << (sz[1] * 8));
word[1] |= tmpw >> (sz[0] * 8);
}
/*
* don't lock here - write_wx gets the lock if each time
* write_lock_irqsave(&adapter->adapter_lock, flags);
* netxen_nic_pci_change_crbwindow_128M(adapter, 0);
*/
for (i = 0; i < loop; i++) {
writel(off8 + (i << 3), mem_crb+MIU_TEST_AGT_ADDR_LO);
writel(0, mem_crb+MIU_TEST_AGT_ADDR_HI);
writel(word[i] & 0xffffffff, mem_crb+MIU_TEST_AGT_WRDATA_LO);
writel((word[i] >> 32) & 0xffffffff,
mem_crb+MIU_TEST_AGT_WRDATA_HI);
writel((MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE),
mem_crb+MIU_TEST_AGT_CTRL);
writel(MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE,
mem_crb+MIU_TEST_AGT_CTRL);
for (j = 0; j < MAX_CTL_CHECK; j++) {
temp = readl(mem_crb + MIU_TEST_AGT_CTRL);
if ((temp & MIU_TA_CTL_BUSY) == 0)
break;
}
if (j >= MAX_CTL_CHECK) {
if (printk_ratelimit())
dev_err(&adapter->pdev->dev,
"failed to write through agent\n");
ret = -1;
break; break;
}
} }
/* if (j >= MAX_CTL_CHECK) {
* netxen_nic_pci_change_crbwindow_128M(adapter, 1); if (printk_ratelimit())
* write_unlock_irqrestore(&adapter->adapter_lock, flags); dev_err(&adapter->pdev->dev,
*/ "failed to write through agent\n");
ret = -EIO;
} else
ret = 0;
write_unlock_irqrestore(&adapter->adapter_lock, flags);
return ret; return ret;
} }
static int static int
netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter, netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
u64 off, void *data, int size) u64 off, u64 *data)
{ {
int i, j = 0, k, start, end, loop, sz[2], off0[2]; unsigned long flags;
uint32_t temp; int j, ret;
uint64_t off8, val, word[2] = {0, 0}; u32 temp, off8;
u64 val;
void __iomem *mem_crb; void __iomem *mem_crb;
if (size != 8) /* Only 64-bit aligned access */
if (off & 7)
return -EIO; return -EIO;
/* P3 onward, test agent base for MIU and SIU is same */
if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET, if (ADDR_IN_RANGE(off, NETXEN_ADDR_QDR_NET,
NETXEN_ADDR_QDR_NET_MAX_P3)) { NETXEN_ADDR_QDR_NET_MAX_P3)) {
mem_crb = netxen_get_ioaddr(adapter, NETXEN_CRB_QDR_NET); mem_crb = netxen_get_ioaddr(adapter,
NETXEN_CRB_QDR_NET+MIU_TEST_AGT_BASE);
goto correct; goto correct;
} }
if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) { if (ADDR_IN_RANGE(off, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
mem_crb = netxen_get_ioaddr(adapter, NETXEN_CRB_DDR_NET); mem_crb = netxen_get_ioaddr(adapter,
NETXEN_CRB_DDR_NET+MIU_TEST_AGT_BASE);
goto correct; goto correct;
} }
return -EIO; return -EIO;
correct: correct:
off8 = off & 0xfffffff8; off8 = off & MIU_TEST_AGT_ADDR_MASK;
off0[0] = off & 0x7;
off0[1] = 0;
sz[0] = (size < (8 - off0[0])) ? size : (8 - off0[0]);
sz[1] = size - sz[0];
loop = ((off0[0] + size - 1) >> 3) + 1;
/* write_lock_irqsave(&adapter->adapter_lock, flags);
* don't lock here - write_wx gets the lock if each time
* write_lock_irqsave(&adapter->adapter_lock, flags);
* netxen_nic_pci_change_crbwindow_128M(adapter, 0);
*/
for (i = 0; i < loop; i++) { writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO));
writel(off8 + (i << 3), mem_crb + MIU_TEST_AGT_ADDR_LO); writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI));
writel(0, mem_crb + MIU_TEST_AGT_ADDR_HI); writel(TA_CTL_ENABLE, (mem_crb + TEST_AGT_CTRL));
writel(MIU_TA_CTL_ENABLE, mem_crb + MIU_TEST_AGT_CTRL); writel((TA_CTL_START | TA_CTL_ENABLE), (mem_crb + TEST_AGT_CTRL));
writel(MIU_TA_CTL_START | MIU_TA_CTL_ENABLE,
mem_crb + MIU_TEST_AGT_CTRL);
for (j = 0; j < MAX_CTL_CHECK; j++) { for (j = 0; j < MAX_CTL_CHECK; j++) {
temp = readl(mem_crb + MIU_TEST_AGT_CTRL); temp = readl(mem_crb + TEST_AGT_CTRL);
if ((temp & MIU_TA_CTL_BUSY) == 0) if ((temp & TA_CTL_BUSY) == 0)
break;
}
if (j >= MAX_CTL_CHECK) {
if (printk_ratelimit())
dev_err(&adapter->pdev->dev,
"failed to read through agent\n");
break; break;
}
start = off0[i] >> 2;
end = (off0[i] + sz[i] - 1) >> 2;
for (k = start; k <= end; k++) {
temp = readl(mem_crb + MIU_TEST_AGT_RDDATA(k));
word[i] |= ((uint64_t)temp << (32 * k));
}
} }
/* if (j >= MAX_CTL_CHECK) {
* netxen_nic_pci_change_crbwindow_128M(adapter, 1); if (printk_ratelimit())
* write_unlock_irqrestore(&adapter->adapter_lock, flags); dev_err(&adapter->pdev->dev,
*/ "failed to read through agent\n");
ret = -EIO;
if (j >= MAX_CTL_CHECK)
return -1;
if (sz[0] == 8) {
val = word[0];
} else { } else {
val = ((word[0] >> (off0[0] * 8)) & (~(~0ULL << (sz[0] * 8)))) | temp = readl(mem_crb + MIU_TEST_AGT_RDDATA_HI);
((word[1] & (~(~0ULL << (sz[1] * 8)))) << (sz[0] * 8)); val = (u64)temp << 32;
val |= readl(mem_crb + MIU_TEST_AGT_RDDATA_LO);
*data = val;
ret = 0;
} }
switch (size) { write_unlock_irqrestore(&adapter->adapter_lock, flags);
case 1:
*(uint8_t *)data = val; return ret;
break;
case 2:
*(uint16_t *)data = val;
break;
case 4:
*(uint32_t *)data = val;
break;
case 8:
*(uint64_t *)data = val;
break;
}
return 0;
} }
void void

View file

@ -702,7 +702,10 @@ netxen_load_firmware(struct netxen_adapter *adapter)
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
data = cpu_to_le64(ptr64[i]); data = cpu_to_le64(ptr64[i]);
adapter->pci_mem_write(adapter, flashaddr, &data, 8); if (adapter->pci_mem_write(adapter,
flashaddr, data))
return -EIO;
flashaddr += 8; flashaddr += 8;
} }
@ -716,7 +719,7 @@ netxen_load_firmware(struct netxen_adapter *adapter)
data = cpu_to_le64(ptr64[i]); data = cpu_to_le64(ptr64[i]);
if (adapter->pci_mem_write(adapter, if (adapter->pci_mem_write(adapter,
flashaddr, &data, 8)) flashaddr, data))
return -EIO; return -EIO;
flashaddr += 8; flashaddr += 8;
@ -730,17 +733,17 @@ netxen_load_firmware(struct netxen_adapter *adapter)
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
if (netxen_rom_fast_read(adapter, if (netxen_rom_fast_read(adapter,
flashaddr, &lo) != 0) flashaddr, (int *)&lo) != 0)
return -EIO; return -EIO;
if (netxen_rom_fast_read(adapter, if (netxen_rom_fast_read(adapter,
flashaddr + 4, &hi) != 0) flashaddr + 4, (int *)&hi) != 0)
return -EIO; return -EIO;
/* hi, lo are already in host endian byteorder */ /* hi, lo are already in host endian byteorder */
data = (((u64)hi << 32) | lo); data = (((u64)hi << 32) | lo);
if (adapter->pci_mem_write(adapter, if (adapter->pci_mem_write(adapter,
flashaddr, &data, 8)) flashaddr, data))
return -EIO; return -EIO;
flashaddr += 8; flashaddr += 8;