netxen: pci probe and firmware init changes

Add initialization code in pci probe for new chip and retain
compatibility with old revisions.

Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
This commit is contained in:
Dhananjay Phadke 2008-07-21 19:44:04 -07:00 committed by Jeff Garzik
parent 3ce06a320f
commit 2956640d4a
4 changed files with 897 additions and 463 deletions

View File

@ -801,6 +801,7 @@ struct netxen_hardware_context {
unsigned long db_len; unsigned long db_len;
unsigned long pci_len0; unsigned long pci_len0;
u8 cut_through;
int qdr_sn_window; int qdr_sn_window;
int ddr_mn_window; int ddr_mn_window;
unsigned long mn_win_crb; unsigned long mn_win_crb;
@ -871,9 +872,16 @@ struct netxen_recv_context {
struct status_desc *rcv_status_desc_head; struct status_desc *rcv_status_desc_head;
}; };
#define NETXEN_NIC_MSI_ENABLED 0x02 #define NETXEN_NIC_MSI_ENABLED 0x02
#define NETXEN_DMA_MASK 0xfffffffe #define NETXEN_NIC_MSIX_ENABLED 0x04
#define NETXEN_DB_MAPSIZE_BYTES 0x1000 #define NETXEN_IS_MSI_FAMILY(adapter) \
((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED))
#define MSIX_ENTRIES_PER_ADAPTER 8
#define NETXEN_MSIX_TBL_SPACE 8192
#define NETXEN_PCI_REG_MSIX_TBL 0x44
#define NETXEN_DB_MAPSIZE_BYTES 0x1000
struct netxen_dummy_dma { struct netxen_dummy_dma {
void *addr; void *addr;
@ -885,6 +893,7 @@ struct netxen_adapter {
struct net_device *netdev; struct net_device *netdev;
struct pci_dev *pdev; struct pci_dev *pdev;
int pci_using_dac;
struct napi_struct napi; struct napi_struct napi;
struct net_device_stats net_stats; struct net_device_stats net_stats;
unsigned char mac_addr[ETH_ALEN]; unsigned char mac_addr[ETH_ALEN];
@ -895,6 +904,8 @@ struct netxen_adapter {
uint8_t mc_enabled; uint8_t mc_enabled;
uint8_t max_mc_count; uint8_t max_mc_count;
struct netxen_legacy_intr_set legacy_intr;
struct work_struct watchdog_task; struct work_struct watchdog_task;
struct timer_list watchdog_timer; struct timer_list watchdog_timer;
struct work_struct tx_timeout_task; struct work_struct tx_timeout_task;
@ -903,6 +914,8 @@ struct netxen_adapter {
u32 crb_win; u32 crb_win;
rwlock_t adapter_lock; rwlock_t adapter_lock;
uint64_t dma_mask;
u32 cmd_producer; u32 cmd_producer;
__le32 *cmd_consumer; __le32 *cmd_consumer;
u32 last_cmd_consumer; u32 last_cmd_consumer;
@ -919,6 +932,12 @@ struct netxen_adapter {
int driver_mismatch; int driver_mismatch;
u32 temp; u32 temp;
u32 fw_major;
u8 msix_supported;
u8 max_possible_rss_rings;
struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER];
struct netxen_adapter_stats stats; struct netxen_adapter_stats stats;
u16 link_speed; u16 link_speed;
@ -1092,8 +1111,10 @@ unsigned long netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
void netxen_free_adapter_offload(struct netxen_adapter *adapter); void netxen_free_adapter_offload(struct netxen_adapter *adapter);
int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
int netxen_receive_peg_ready(struct netxen_adapter *adapter);
int netxen_load_firmware(struct netxen_adapter *adapter); int netxen_load_firmware(struct netxen_adapter *adapter);
int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp); int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr,
u8 *bytes, size_t size); u8 *bytes, size_t size);
@ -1107,14 +1128,19 @@ void netxen_halt_pegs(struct netxen_adapter *adapter);
int netxen_rom_se(struct netxen_adapter *adapter, int addr); int netxen_rom_se(struct netxen_adapter *adapter, int addr);
/* Functions from netxen_nic_isr.c */ int netxen_alloc_sw_resources(struct netxen_adapter *adapter);
void netxen_initialize_adapter_sw(struct netxen_adapter *adapter); void netxen_free_sw_resources(struct netxen_adapter *adapter);
int netxen_alloc_hw_resources(struct netxen_adapter *adapter);
void netxen_free_hw_resources(struct netxen_adapter *adapter);
void netxen_release_rx_buffers(struct netxen_adapter *adapter);
void netxen_release_tx_buffers(struct netxen_adapter *adapter);
void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
int netxen_init_firmware(struct netxen_adapter *adapter); int netxen_init_firmware(struct netxen_adapter *adapter);
void netxen_free_hw_resources(struct netxen_adapter *adapter);
void netxen_tso_check(struct netxen_adapter *adapter, void netxen_tso_check(struct netxen_adapter *adapter,
struct cmd_desc_type0 *desc, struct sk_buff *skb); struct cmd_desc_type0 *desc, struct sk_buff *skb);
int netxen_nic_hw_resources(struct netxen_adapter *adapter);
void netxen_nic_clear_stats(struct netxen_adapter *adapter); void netxen_nic_clear_stats(struct netxen_adapter *adapter);
void netxen_watchdog_task(struct work_struct *work); void netxen_watchdog_task(struct work_struct *work);
void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,

View File

@ -359,8 +359,6 @@ static u64 ctx_addr_sig_regs[][3] = {
#define ADDR_IN_RANGE(addr, low, high) \ #define ADDR_IN_RANGE(addr, low, high) \
(((addr) <= (high)) && ((addr) >= (low))) (((addr) <= (high)) && ((addr) >= (low)))
#define NETXEN_FLASH_BASE (NETXEN_BOOTLD_START)
#define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE)
#define NETXEN_MAX_MTU 8000 + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE #define NETXEN_MAX_MTU 8000 + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE
#define NETXEN_MIN_MTU 64 #define NETXEN_MIN_MTU 64
#define NETXEN_ETH_FCS_SIZE 4 #define NETXEN_ETH_FCS_SIZE 4
@ -381,8 +379,6 @@ static u64 ctx_addr_sig_regs[][3] = {
#define NETXEN_NIC_WINDOW_MARGIN 0x100000 #define NETXEN_NIC_WINDOW_MARGIN 0x100000
void netxen_free_hw_resources(struct netxen_adapter *adapter);
int netxen_nic_set_mac(struct net_device *netdev, void *p) int netxen_nic_set_mac(struct net_device *netdev, void *p)
{ {
struct netxen_adapter *adapter = netdev_priv(netdev); struct netxen_adapter *adapter = netdev_priv(netdev);
@ -564,41 +560,22 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
* check if the firmware has been downloaded and ready to run and * check if the firmware has been downloaded and ready to run and
* setup the address for the descriptors in the adapter * setup the address for the descriptors in the adapter
*/ */
int netxen_nic_hw_resources(struct netxen_adapter *adapter) int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
{ {
struct netxen_hardware_context *hw = &adapter->ahw; struct netxen_hardware_context *hw = &adapter->ahw;
u32 state = 0; u32 state = 0;
void *addr; void *addr;
int loops = 0, err = 0; int err = 0;
int ctx, ring; int ctx, ring;
struct netxen_recv_context *recv_ctx; struct netxen_recv_context *recv_ctx;
struct netxen_rcv_desc_ctx *rcv_desc; struct netxen_rcv_desc_ctx *rcv_desc;
int func_id = adapter->portnum; int func_id = adapter->portnum;
DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE, err = netxen_receive_peg_ready(adapter);
PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); if (err) {
DPRINTK(INFO, "cam base: %lx %x", NETXEN_CRB_CAM, printk(KERN_ERR "Rcv Peg initialization not complete:%x.\n",
pci_base_offset(adapter, NETXEN_CRB_CAM)); state);
DPRINTK(INFO, "cam RAM: %lx %x", NETXEN_CAM_RAM_BASE, return err;
pci_base_offset(adapter, NETXEN_CAM_RAM_BASE));
for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
loops = 0;
state = 0;
do {
/* Window 1 call */
state = adapter->pci_read_normalize(adapter,
CRB_RCVPEG_STATE);
msleep(1);
loops++;
} while (state != PHAN_PEG_RCV_INITIALIZED && loops < 20);
if (loops >= 20) {
printk(KERN_ERR "Rcv Peg initialization not complete:"
"%x.\n", state);
err = -EIO;
return err;
}
} }
adapter->intr_scheme = adapter->pci_read_normalize(adapter, adapter->intr_scheme = adapter->pci_read_normalize(adapter,
CRB_NIC_CAPABILITIES_FW); CRB_NIC_CAPABILITIES_FW);
@ -992,10 +969,12 @@ int netxen_load_firmware(struct netxen_adapter *adapter)
{ {
int i; int i;
u32 data, size = 0; u32 data, size = 0;
u32 flashaddr = NETXEN_FLASH_BASE, memaddr = NETXEN_PHANTOM_MEM_BASE; u32 flashaddr = NETXEN_BOOTLD_START, memaddr = NETXEN_BOOTLD_START;
size = NETXEN_FIRMWARE_LEN; size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START)/4;
adapter->pci_write_normalize(adapter,
if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
adapter->pci_write_normalize(adapter,
NETXEN_ROMUSB_GLB_CAS_RST, 1); NETXEN_ROMUSB_GLB_CAS_RST, 1);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
@ -1007,12 +986,17 @@ int netxen_load_firmware(struct netxen_adapter *adapter)
memaddr += 4; memaddr += 4;
cond_resched(); cond_resched();
} }
udelay(100); msleep(1);
/* make sure Casper is powered on */
adapter->pci_write_normalize(adapter, if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
adapter->pci_write_normalize(adapter,
NETXEN_ROMUSB_GLB_SW_RESET, 0x80001d);
else {
adapter->pci_write_normalize(adapter,
NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL, 0x3fff); NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL, 0x3fff);
adapter->pci_write_normalize(adapter, adapter->pci_write_normalize(adapter,
NETXEN_ROMUSB_GLB_CAS_RST, 0); NETXEN_ROMUSB_GLB_CAS_RST, 0);
}
return 0; return 0;
} }
@ -2241,6 +2225,8 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter)
adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MINOR, &fw_minor, 4); adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_MINOR, &fw_minor, 4);
adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB, &fw_build, 4); adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB, &fw_build, 4);
adapter->fw_major = fw_major;
if (adapter->portnum == 0) { if (adapter->portnum == 0) {
get_brd_name_by_type(board_info->board_type, brd_name); get_brd_name_by_type(board_info->board_type, brd_name);
@ -2262,16 +2248,5 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter)
adapter->netdev->name); adapter->netdev->name);
return; return;
} }
switch (adapter->ahw.board_type) {
case NETXEN_NIC_GBE:
dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n",
adapter->netdev->name);
break;
case NETXEN_NIC_XGBE:
dev_info(&adapter->pdev->dev, "%s: XGbE port initialized\n",
adapter->netdev->name);
break;
}
} }

View File

@ -130,7 +130,7 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
return 0; return 0;
while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) { while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
udelay(100); msleep(1);
/* Window 1 call */ /* Window 1 call */
state = adapter->pci_read_normalize(adapter, CRB_CMDPEG_STATE); state = adapter->pci_read_normalize(adapter, CRB_CMDPEG_STATE);
@ -155,34 +155,165 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
return err; return err;
} }
void netxen_initialize_adapter_sw(struct netxen_adapter *adapter) void netxen_release_rx_buffers(struct netxen_adapter *adapter)
{ {
int ctxid, ring; struct netxen_recv_context *recv_ctx;
u32 i;
u32 num_rx_bufs = 0;
struct netxen_rcv_desc_ctx *rcv_desc; struct netxen_rcv_desc_ctx *rcv_desc;
struct netxen_rx_buffer *rx_buf;
int i, ctxid, ring;
DPRINTK(INFO, "initializing some queues: %p\n", adapter);
for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
recv_ctx = &adapter->recv_ctx[ctxid];
for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
struct netxen_rx_buffer *rx_buf; rcv_desc = &recv_ctx->rcv_desc[ring];
rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring]; for (i = 0; i < rcv_desc->max_rx_desc_count; ++i) {
rx_buf = &(rcv_desc->rx_buf_arr[i]);
if (rx_buf->state == NETXEN_BUFFER_FREE)
continue;
pci_unmap_single(adapter->pdev,
rx_buf->dma,
rcv_desc->dma_size,
PCI_DMA_FROMDEVICE);
if (rx_buf->skb != NULL)
dev_kfree_skb_any(rx_buf->skb);
}
}
}
}
void netxen_release_tx_buffers(struct netxen_adapter *adapter)
{
struct netxen_cmd_buffer *cmd_buf;
struct netxen_skb_frag *buffrag;
int i, j;
cmd_buf = adapter->cmd_buf_arr;
for (i = 0; i < adapter->max_tx_desc_count; i++) {
buffrag = cmd_buf->frag_array;
if (buffrag->dma) {
pci_unmap_single(adapter->pdev, buffrag->dma,
buffrag->length, PCI_DMA_TODEVICE);
buffrag->dma = 0ULL;
}
for (j = 0; j < cmd_buf->frag_count; j++) {
buffrag++;
if (buffrag->dma) {
pci_unmap_page(adapter->pdev, buffrag->dma,
buffrag->length,
PCI_DMA_TODEVICE);
buffrag->dma = 0ULL;
}
}
/* Free the skb we received in netxen_nic_xmit_frame */
if (cmd_buf->skb) {
dev_kfree_skb_any(cmd_buf->skb);
cmd_buf->skb = NULL;
}
cmd_buf++;
}
}
void netxen_free_sw_resources(struct netxen_adapter *adapter)
{
struct netxen_recv_context *recv_ctx;
struct netxen_rcv_desc_ctx *rcv_desc;
int ctx, ring;
for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) {
recv_ctx = &adapter->recv_ctx[ctx];
for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
rcv_desc = &recv_ctx->rcv_desc[ring];
if (rcv_desc->rx_buf_arr) {
vfree(rcv_desc->rx_buf_arr);
rcv_desc->rx_buf_arr = NULL;
}
}
}
if (adapter->cmd_buf_arr)
vfree(adapter->cmd_buf_arr);
return;
}
int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
{
struct netxen_recv_context *recv_ctx;
struct netxen_rcv_desc_ctx *rcv_desc;
struct netxen_rx_buffer *rx_buf;
int ctx, ring, i, num_rx_bufs;
struct netxen_cmd_buffer *cmd_buf_arr;
struct net_device *netdev = adapter->netdev;
cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE);
if (cmd_buf_arr == NULL) {
printk(KERN_ERR "%s: Failed to allocate cmd buffer ring\n",
netdev->name);
return -ENOMEM;
}
memset(cmd_buf_arr, 0, TX_RINGSIZE);
adapter->cmd_buf_arr = cmd_buf_arr;
for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) {
recv_ctx = &adapter->recv_ctx[ctx];
for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
rcv_desc = &recv_ctx->rcv_desc[ring];
switch (RCV_DESC_TYPE(ring)) {
case RCV_DESC_NORMAL:
rcv_desc->max_rx_desc_count =
adapter->max_rx_desc_count;
rcv_desc->flags = RCV_DESC_NORMAL;
rcv_desc->dma_size = RX_DMA_MAP_LEN;
rcv_desc->skb_size = MAX_RX_BUFFER_LENGTH;
break;
case RCV_DESC_JUMBO:
rcv_desc->max_rx_desc_count =
adapter->max_jumbo_rx_desc_count;
rcv_desc->flags = RCV_DESC_JUMBO;
rcv_desc->dma_size = RX_JUMBO_DMA_MAP_LEN;
rcv_desc->skb_size =
MAX_RX_JUMBO_BUFFER_LENGTH;
break;
case RCV_RING_LRO:
rcv_desc->max_rx_desc_count =
adapter->max_lro_rx_desc_count;
rcv_desc->flags = RCV_DESC_LRO;
rcv_desc->dma_size = RX_LRO_DMA_MAP_LEN;
rcv_desc->skb_size = MAX_RX_LRO_BUFFER_LENGTH;
break;
}
rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *)
vmalloc(RCV_BUFFSIZE);
if (rcv_desc->rx_buf_arr == NULL) {
printk(KERN_ERR "%s: Failed to allocate "
"rx buffer ring %d\n",
netdev->name, ring);
/* free whatever was already allocated */
goto err_out;
}
memset(rcv_desc->rx_buf_arr, 0, RCV_BUFFSIZE);
rcv_desc->begin_alloc = 0; rcv_desc->begin_alloc = 0;
rx_buf = rcv_desc->rx_buf_arr;
num_rx_bufs = rcv_desc->max_rx_desc_count;
/* /*
* Now go through all of them, set reference handles * Now go through all of them, set reference handles
* and put them in the queues. * and put them in the queues.
*/ */
num_rx_bufs = rcv_desc->max_rx_desc_count;
rx_buf = rcv_desc->rx_buf_arr;
for (i = 0; i < num_rx_bufs; i++) { for (i = 0; i < num_rx_bufs; i++) {
rx_buf->ref_handle = i; rx_buf->ref_handle = i;
rx_buf->state = NETXEN_BUFFER_FREE; rx_buf->state = NETXEN_BUFFER_FREE;
DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:"
"%p\n", ctxid, i, rx_buf);
rx_buf++; rx_buf++;
} }
} }
} }
return 0;
err_out:
netxen_free_sw_resources(adapter);
return -ENOMEM;
} }
void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
@ -730,19 +861,18 @@ int netxen_flash_unlock(struct netxen_adapter *adapter)
#define NETXEN_BOARDTYPE 0x4008 #define NETXEN_BOARDTYPE 0x4008
#define NETXEN_BOARDNUM 0x400c #define NETXEN_BOARDNUM 0x400c
#define NETXEN_CHIPNUM 0x4010 #define NETXEN_CHIPNUM 0x4010
#define NETXEN_ROMBUS_RESET 0xFFFFFFFF
int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
{ {
int addr, val; int addr, val;
int n, i; int i, init_delay = 0;
int init_delay = 0;
struct crb_addr_pair *buf; struct crb_addr_pair *buf;
unsigned offset, n;
u32 off; u32 off;
/* resetall */ /* resetall */
netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
NETXEN_ROMBUS_RESET); 0xffffffff);
if (verbose) { if (verbose) {
if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0) if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0)
@ -759,108 +889,141 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
printk("Could not read chip number\n"); printk("Could not read chip number\n");
} }
if (netxen_rom_fast_read(adapter, 0, &n) == 0 && (n & 0x80000000)) { if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
n &= ~0x80000000; if (netxen_rom_fast_read(adapter, 0, &n) != 0 ||
if (n < 0x400) { (n != 0xcafecafeUL) ||
if (verbose) netxen_rom_fast_read(adapter, 4, &n) != 0) {
printk("%s: %d CRB init values found" printk(KERN_ERR "%s: ERROR Reading crb_init area: "
" in ROM.\n", netxen_nic_driver_name, n); "n: %08x\n", netxen_nic_driver_name, n);
} else {
printk("%s:n=0x%x Error! NetXen card flash not"
" initialized.\n", __FUNCTION__, n);
return -EIO; return -EIO;
} }
buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL); offset = n & 0xffffU;
if (buf == NULL) { n = (n >> 16) & 0xffffU;
printk("%s: netxen_pinit_from_rom: Unable to calloc " } else {
"memory.\n", netxen_nic_driver_name); if (netxen_rom_fast_read(adapter, 0, &n) != 0 ||
return -ENOMEM; !(n & 0x80000000)) {
printk(KERN_ERR "%s: ERROR Reading crb_init area: "
"n: %08x\n", netxen_nic_driver_name, n);
return -EIO;
} }
for (i = 0; i < n; i++) { offset = 1;
if (netxen_rom_fast_read(adapter, 8 * i + 4, &val) != 0 n &= ~0x80000000;
|| netxen_rom_fast_read(adapter, 8 * i + 8, }
&addr) != 0)
return -EIO;
buf[i].addr = addr; if (n < 1024) {
buf[i].data = val; if (verbose)
printk(KERN_DEBUG "%s: %d CRB init values found"
" in ROM.\n", netxen_nic_driver_name, n);
} else {
printk(KERN_ERR "%s:n=0x%x Error! NetXen card flash not"
" initialized.\n", __func__, n);
return -EIO;
}
if (verbose) buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
printk("%s: PCI: 0x%08x == 0x%08x\n", if (buf == NULL) {
netxen_nic_driver_name, (unsigned int) printk("%s: netxen_pinit_from_rom: Unable to calloc memory.\n",
netxen_decode_crb_addr(addr), val); netxen_nic_driver_name);
} return -ENOMEM;
for (i = 0; i < n; i++) { }
for (i = 0; i < n; i++) {
if (netxen_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 ||
netxen_rom_fast_read(adapter, 8*i + 4*offset + 4, &addr) != 0)
return -EIO;
off = netxen_decode_crb_addr(buf[i].addr); buf[i].addr = addr;
if (off == NETXEN_ADDR_ERROR) { buf[i].data = val;
printk(KERN_ERR"CRB init value out of range %x\n",
if (verbose)
printk(KERN_DEBUG "%s: PCI: 0x%08x == 0x%08x\n",
netxen_nic_driver_name,
(u32)netxen_decode_crb_addr(addr), val);
}
for (i = 0; i < n; i++) {
off = netxen_decode_crb_addr(buf[i].addr);
if (off == NETXEN_ADDR_ERROR) {
printk(KERN_ERR"CRB init value out of range %x\n",
buf[i].addr); buf[i].addr);
continue; continue;
} }
off += NETXEN_PCI_CRBSPACE; off += NETXEN_PCI_CRBSPACE;
/* skipping cold reboot MAGIC */ /* skipping cold reboot MAGIC */
if (off == NETXEN_CAM_RAM(0x1fc)) if (off == NETXEN_CAM_RAM(0x1fc))
continue; continue;
/* After writing this register, HW needs time for CRB */ if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
/* to quiet down (else crb_window returns 0xffffffff) */ /* do not reset PCI */
if (off == NETXEN_ROMUSB_GLB_SW_RESET) { if (off == (ROMUSB_GLB + 0xbc))
init_delay = 1; continue;
if (off == (NETXEN_CRB_PEG_NET_1 + 0x18))
buf[i].data = 0x1020;
/* skip the function enable register */
if (off == NETXEN_PCIE_REG(PCIE_SETUP_FUNCTION))
continue;
if (off == NETXEN_PCIE_REG(PCIE_SETUP_FUNCTION2))
continue;
if ((off & 0x0ff00000) == NETXEN_CRB_SMB)
continue;
}
if (off == NETXEN_ADDR_ERROR) {
printk(KERN_ERR "%s: Err: Unknown addr: 0x%08x\n",
netxen_nic_driver_name, buf[i].addr);
continue;
}
/* After writing this register, HW needs time for CRB */
/* to quiet down (else crb_window returns 0xffffffff) */
if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
init_delay = 1;
if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
/* hold xdma in reset also */ /* hold xdma in reset also */
buf[i].data = NETXEN_NIC_XDMA_RESET; buf[i].data = NETXEN_NIC_XDMA_RESET;
} }
adapter->hw_write_wx(adapter, off, &buf[i].data, 4);
if (init_delay == 1) {
msleep(1000);
init_delay = 0;
}
msleep(1);
} }
kfree(buf);
/* disable_peg_cache_all */ adapter->hw_write_wx(adapter, off, &buf[i].data, 4);
/* unreset_net_cache */ if (init_delay == 1) {
adapter->hw_read_wx(adapter, NETXEN_ROMUSB_GLB_SW_RESET, &val, msleep(1000);
4); init_delay = 0;
netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, }
(val & 0xffffff0f)); msleep(1);
/* p2dn replyCount */
netxen_crb_writelit_adapter(adapter,
NETXEN_CRB_PEG_NET_D + 0xec, 0x1e);
/* disable_peg_cache 0 */
netxen_crb_writelit_adapter(adapter,
NETXEN_CRB_PEG_NET_D + 0x4c, 8);
/* disable_peg_cache 1 */
netxen_crb_writelit_adapter(adapter,
NETXEN_CRB_PEG_NET_I + 0x4c, 8);
/* peg_clr_all */
/* peg_clr 0 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x8,
0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0xc,
0);
/* peg_clr 1 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x8,
0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0xc,
0);
/* peg_clr 2 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x8,
0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0xc,
0);
/* peg_clr 3 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x8,
0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0xc,
0);
} }
kfree(buf);
/* disable_peg_cache_all */
/* unreset_net_cache */
if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
adapter->hw_read_wx(adapter,
NETXEN_ROMUSB_GLB_SW_RESET, &val, 4);
netxen_crb_writelit_adapter(adapter,
NETXEN_ROMUSB_GLB_SW_RESET, (val & 0xffffff0f));
}
/* p2dn replyCount */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_D + 0xec, 0x1e);
/* disable_peg_cache 0 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_D + 0x4c, 8);
/* disable_peg_cache 1 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_I + 0x4c, 8);
/* peg_clr_all */
/* peg_clr 0 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x8, 0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0xc, 0);
/* peg_clr 1 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x8, 0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0xc, 0);
/* peg_clr 2 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x8, 0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0xc, 0);
/* peg_clr 3 */
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x8, 0);
netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0xc, 0);
return 0; return 0;
} }
@ -876,7 +1039,7 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
&adapter->dummy_dma.phys_addr); &adapter->dummy_dma.phys_addr);
if (adapter->dummy_dma.addr == NULL) { if (adapter->dummy_dma.addr == NULL) {
printk("%s: ERROR: Could not allocate dummy DMA memory\n", printk("%s: ERROR: Could not allocate dummy DMA memory\n",
__FUNCTION__); __func__);
return -ENOMEM; return -ENOMEM;
} }
@ -887,6 +1050,11 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi); adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi);
adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo); adapter->pci_write_normalize(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
uint32_t temp = 0;
adapter->hw_write_wx(adapter, CRB_HOST_DUMMY_BUF, &temp, 4);
}
return 0; return 0;
} }
@ -920,22 +1088,24 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter)
int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
{ {
u32 val = 0; u32 val = 0;
int retries = 30; int retries = 60;
if (!pegtune_val) { if (!pegtune_val) {
do { do {
val = adapter->pci_read_normalize(adapter, val = adapter->pci_read_normalize(adapter,
CRB_CMDPEG_STATE); CRB_CMDPEG_STATE);
pegtune_val = adapter->pci_read_normalize(adapter,
NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
if (val == PHAN_INITIALIZE_COMPLETE || if (val == PHAN_INITIALIZE_COMPLETE ||
val == PHAN_INITIALIZE_ACK) val == PHAN_INITIALIZE_ACK)
return 0; return 0;
msleep(1000); msleep(500);
} while (--retries); } while (--retries);
if (!retries) { if (!retries) {
pegtune_val = adapter->pci_read_normalize(adapter,
NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
printk(KERN_WARNING "netxen_phantom_init: init failed, " printk(KERN_WARNING "netxen_phantom_init: init failed, "
"pegtune_val=%x\n", pegtune_val); "pegtune_val=%x\n", pegtune_val);
return -1; return -1;
@ -945,6 +1115,30 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
return 0; return 0;
} }
int netxen_receive_peg_ready(struct netxen_adapter *adapter)
{
u32 val = 0;
int retries = 2000;
do {
val = adapter->pci_read_normalize(adapter, CRB_RCVPEG_STATE);
if (val == PHAN_PEG_RCV_INITIALIZED)
return 0;
msleep(10);
} while (--retries);
if (!retries) {
printk(KERN_ERR "Receive Peg initialization not "
"complete, state: 0x%x.\n", val);
return -EIO;
}
return 0;
}
static int netxen_nic_check_temp(struct netxen_adapter *adapter) static int netxen_nic_check_temp(struct netxen_adapter *adapter)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;

File diff suppressed because it is too large Load Diff