aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen
diff options
context:
space:
mode:
authorMithlesh Thukral <mithlesh@netxen.com>2007-04-20 10:53:52 -0400
committerJeff Garzik <jeff@garzik.org>2007-04-28 11:01:05 -0400
commit595e3fb8cf0c3c1c6d63dc3d7fd166e50bf150ff (patch)
treedb94c0f9fe01a2a34eeae896d502689e2de83118 /drivers/net/netxen
parent13ba9c7714cfa40821d29090442de14d01d6eb33 (diff)
NetXen: Multi PCI support for Quad cards
NetXen: Fix the multi PCI function for cards with more than 2 ports. This patch fixes the working of multi PCI capable driver on cards with more than 2 ports by adding the addresses for their rings and sizes. Signed-off by: Mithlesh Thukral <mithlesh@netxen.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c115
-rw-r--r--drivers/net/netxen/netxen_nic_init.c4
-rw-r--r--drivers/net/netxen/netxen_nic_main.c61
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h6
4 files changed, 144 insertions, 42 deletions
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 5ed8c60c906f..74517b640c2b 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -143,8 +143,105 @@ struct netxen_recv_crb recv_crb_registers[] = {
143 NETXEN_NIC_REG(0x180), 143 NETXEN_NIC_REG(0x180),
144 /* crb_status_ring_size */ 144 /* crb_status_ring_size */
145 NETXEN_NIC_REG(0x184), 145 NETXEN_NIC_REG(0x184),
146
147 }, 146 },
147 /*
148 * Instance 3,
149 */
150 {
151 {
152 {
153 /* crb_rcv_producer_offset: */
154 NETXEN_NIC_REG(0x1d8),
155 /* crb_rcv_consumer_offset: */
156 NETXEN_NIC_REG(0x1dc),
157 /* crb_gloablrcv_ring: */
158 NETXEN_NIC_REG(0x1f0),
159 /* crb_rcv_ring_size */
160 NETXEN_NIC_REG(0x1f4),
161 },
162 /* Jumbo frames */
163 {
164 /* crb_rcv_producer_offset: */
165 NETXEN_NIC_REG(0x1f8),
166 /* crb_rcv_consumer_offset: */
167 NETXEN_NIC_REG(0x1fc),
168 /* crb_gloablrcv_ring: */
169 NETXEN_NIC_REG(0x200),
170 /* crb_rcv_ring_size */
171 NETXEN_NIC_REG(0x204),
172 },
173 /* LRO */
174 {
175 /* crb_rcv_producer_offset: */
176 NETXEN_NIC_REG(0x208),
177 /* crb_rcv_consumer_offset: */
178 NETXEN_NIC_REG(0x20c),
179 /* crb_gloablrcv_ring: */
180 NETXEN_NIC_REG(0x210),
181 /* crb_rcv_ring_size */
182 NETXEN_NIC_REG(0x214),
183 }
184 },
185 /* crb_rcvstatus_ring: */
186 NETXEN_NIC_REG(0x218),
187 /* crb_rcv_status_producer: */
188 NETXEN_NIC_REG(0x21c),
189 /* crb_rcv_status_consumer: */
190 NETXEN_NIC_REG(0x220),
191 /* crb_rcvpeg_state: */
192 NETXEN_NIC_REG(0x224),
193 /* crb_status_ring_size */
194 NETXEN_NIC_REG(0x228),
195 },
196 /*
197 * Instance 4,
198 */
199 {
200 {
201 {
202 /* crb_rcv_producer_offset: */
203 NETXEN_NIC_REG(0x22c),
204 /* crb_rcv_consumer_offset: */
205 NETXEN_NIC_REG(0x230),
206 /* crb_gloablrcv_ring: */
207 NETXEN_NIC_REG(0x234),
208 /* crb_rcv_ring_size */
209 NETXEN_NIC_REG(0x238),
210 },
211 /* Jumbo frames */
212 {
213 /* crb_rcv_producer_offset: */
214 NETXEN_NIC_REG(0x23c),
215 /* crb_rcv_consumer_offset: */
216 NETXEN_NIC_REG(0x240),
217 /* crb_gloablrcv_ring: */
218 NETXEN_NIC_REG(0x244),
219 /* crb_rcv_ring_size */
220 NETXEN_NIC_REG(0x248),
221 },
222 /* LRO */
223 {
224 /* crb_rcv_producer_offset: */
225 NETXEN_NIC_REG(0x24c),
226 /* crb_rcv_consumer_offset: */
227 NETXEN_NIC_REG(0x250),
228 /* crb_gloablrcv_ring: */
229 NETXEN_NIC_REG(0x254),
230 /* crb_rcv_ring_size */
231 NETXEN_NIC_REG(0x258),
232 }
233 },
234 /* crb_rcvstatus_ring: */
235 NETXEN_NIC_REG(0x25c),
236 /* crb_rcv_status_producer: */
237 NETXEN_NIC_REG(0x260),
238 /* crb_rcv_status_consumer: */
239 NETXEN_NIC_REG(0x264),
240 /* crb_rcvpeg_state: */
241 NETXEN_NIC_REG(0x268),
242 /* crb_status_ring_size */
243 NETXEN_NIC_REG(0x26c),
244 },
148}; 245};
149 246
150u64 ctx_addr_sig_regs[][3] = { 247u64 ctx_addr_sig_regs[][3] = {
@@ -296,6 +393,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
296 u32 card_cmdring = 0; 393 u32 card_cmdring = 0;
297 struct netxen_recv_context *recv_ctx; 394 struct netxen_recv_context *recv_ctx;
298 struct netxen_rcv_desc_ctx *rcv_desc; 395 struct netxen_rcv_desc_ctx *rcv_desc;
396 int func_id = adapter->portnum;
299 397
300 DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE, 398 DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE,
301 PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); 399 PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE));
@@ -351,6 +449,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
351 } 449 }
352 memset(addr, 0, sizeof(struct netxen_ring_ctx)); 450 memset(addr, 0, sizeof(struct netxen_ring_ctx));
353 adapter->ctx_desc = (struct netxen_ring_ctx *)addr; 451 adapter->ctx_desc = (struct netxen_ring_ctx *)addr;
452 adapter->ctx_desc->ctx_id = adapter->portnum;
354 adapter->ctx_desc->cmd_consumer_offset = 453 adapter->ctx_desc->cmd_consumer_offset =
355 cpu_to_le64(adapter->ctx_desc_phys_addr + 454 cpu_to_le64(adapter->ctx_desc_phys_addr +
356 sizeof(struct netxen_ring_ctx)); 455 sizeof(struct netxen_ring_ctx));
@@ -421,11 +520,11 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
421 /* Window = 1 */ 520 /* Window = 1 */
422 521
423 writel(lower32(adapter->ctx_desc_phys_addr), 522 writel(lower32(adapter->ctx_desc_phys_addr),
424 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO)); 523 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO(func_id)));
425 writel(upper32(adapter->ctx_desc_phys_addr), 524 writel(upper32(adapter->ctx_desc_phys_addr),
426 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI)); 525 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI(func_id)));
427 writel(NETXEN_CTX_SIGNATURE, 526 writel(NETXEN_CTX_SIGNATURE | func_id,
428 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG)); 527 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG(func_id)));
429 return err; 528 return err;
430} 529}
431 530
@@ -965,9 +1064,11 @@ int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu)
965{ 1064{
966 new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE; 1065 new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE;
967 if (adapter->portnum == 0) 1066 if (adapter->portnum == 0)
968 netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu); 1067 netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE,
1068 new_mtu);
969 else if (adapter->portnum == 1) 1069 else if (adapter->portnum == 1)
970 netxen_nic_write_w0(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, new_mtu); 1070 netxen_nic_write_w0(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE,
1071 new_mtu);
971 return 0; 1072 return 0;
972} 1073}
973 1074
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index e625d3c496d1..2a3a91d2c389 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -226,7 +226,6 @@ void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
226 adapter->unset_promisc = netxen_niu_set_promiscuous_mode; 226 adapter->unset_promisc = netxen_niu_set_promiscuous_mode;
227 adapter->phy_read = netxen_niu_gbe_phy_read; 227 adapter->phy_read = netxen_niu_gbe_phy_read;
228 adapter->phy_write = netxen_niu_gbe_phy_write; 228 adapter->phy_write = netxen_niu_gbe_phy_write;
229 adapter->init_port = netxen_niu_gbe_init_port;
230 adapter->init_niu = netxen_nic_init_niu_gb; 229 adapter->init_niu = netxen_nic_init_niu_gb;
231 adapter->stop_port = netxen_niu_disable_gbe_port; 230 adapter->stop_port = netxen_niu_disable_gbe_port;
232 break; 231 break;
@@ -438,7 +437,6 @@ do_rom_fast_read_words(struct netxen_adapter *adapter, int addr,
438 437
439 for (addridx = addr; addridx < (addr + size); addridx += 4) { 438 for (addridx = addr; addridx < (addr + size); addridx += 4) {
440 ret = do_rom_fast_read(adapter, addridx, (int *)bytes); 439 ret = do_rom_fast_read(adapter, addridx, (int *)bytes);
441 *(int *)bytes = cpu_to_le32(*(int *)bytes);
442 if (ret != 0) 440 if (ret != 0)
443 break; 441 break;
444 bytes += 4; 442 bytes += 4;
@@ -498,7 +496,7 @@ static inline int do_rom_fast_write_words(struct netxen_adapter *adapter,
498 int timeout = 0; 496 int timeout = 0;
499 int data; 497 int data;
500 498
501 data = le32_to_cpu((*(u32*)bytes)); 499 data = *(u32*)bytes;
502 500
503 ret = do_rom_fast_write(adapter, addridx, data); 501 ret = do_rom_fast_write(adapter, addridx, data);
504 if (ret < 0) 502 if (ret < 0)
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 4e1a6aa91412..137fb579bd15 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -286,7 +286,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
286 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; 286 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
287 adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS; 287 adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS;
288 288
289 pci_set_drvdata(pdev, adapter); 289 pci_set_drvdata(pdev, netdev);
290 290
291 adapter->netdev = netdev; 291 adapter->netdev = netdev;
292 adapter->pdev = pdev; 292 adapter->pdev = pdev;
@@ -388,6 +388,11 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
388 adapter->ahw.db_len = db_len; 388 adapter->ahw.db_len = db_len;
389 spin_lock_init(&adapter->tx_lock); 389 spin_lock_init(&adapter->tx_lock);
390 spin_lock_init(&adapter->lock); 390 spin_lock_init(&adapter->lock);
391 /* initialize the adapter */
392 netxen_initialize_adapter_hw(adapter);
393
394 netxen_initialize_adapter_ops(adapter);
395
391 netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */ 396 netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */
392 /* Mezz cards have PCI function 0,2,3 enabled */ 397 /* Mezz cards have PCI function 0,2,3 enabled */
393 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) 398 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
@@ -412,11 +417,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
412 * initializing the ports 417 * initializing the ports
413 */ 418 */
414 419
415 /* initialize the adapter */
416 netxen_initialize_adapter_hw(adapter);
417
418 netxen_initialize_adapter_ops(adapter);
419
420 init_timer(&adapter->watchdog_timer); 420 init_timer(&adapter->watchdog_timer);
421 adapter->ahw.xg_linkup = 0; 421 adapter->ahw.xg_linkup = 0;
422 adapter->watchdog_timer.function = &netxen_watchdog; 422 adapter->watchdog_timer.function = &netxen_watchdog;
@@ -578,8 +578,8 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
578 int i; 578 int i;
579 int ctxid, ring; 579 int ctxid, ring;
580 580
581 adapter = pci_get_drvdata(pdev); 581 netdev = pci_get_drvdata(pdev);
582 netdev = adapter->netdev; 582 adapter = netdev_priv(netdev);
583 if (adapter == NULL) 583 if (adapter == NULL)
584 return; 584 return;
585 585
@@ -588,15 +588,15 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
588 588
589 if (adapter->irq) 589 if (adapter->irq)
590 free_irq(adapter->irq, adapter); 590 free_irq(adapter->irq, adapter);
591 /* leave the hw in the same state as reboot */ 591 if(adapter->portnum == 0) {
592 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 592 /* leave the hw in the same state as reboot */
593 netxen_pinit_from_rom(adapter, 0); 593 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
594 netxen_load_firmware(adapter); 594 netxen_pinit_from_rom(adapter, 0);
595 netxen_free_adapter_offload(adapter); 595 netxen_load_firmware(adapter);
596 netxen_free_adapter_offload(adapter);
597 }
596 598
597 udelay(500); 599 udelay(500);
598 unregister_netdev(netdev);
599 free_netdev(netdev);
600 600
601 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED)) 601 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED))
602 pci_disable_msi(pdev); 602 pci_disable_msi(pdev);
@@ -608,10 +608,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
608 iounmap(adapter->ahw.pci_base1); 608 iounmap(adapter->ahw.pci_base1);
609 iounmap(adapter->ahw.pci_base2); 609 iounmap(adapter->ahw.pci_base2);
610 610
611 pci_release_regions(pdev);
612 pci_disable_device(pdev);
613 pci_set_drvdata(pdev, NULL);
614
615 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { 611 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
616 recv_ctx = &adapter->recv_ctx[ctxid]; 612 recv_ctx = &adapter->recv_ctx[ctxid];
617 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 613 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
@@ -631,7 +627,13 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
631 } 627 }
632 628
633 vfree(adapter->cmd_buf_arr); 629 vfree(adapter->cmd_buf_arr);
634 kfree(adapter); 630 unregister_netdev(netdev);
631 free_netdev(netdev);
632
633 pci_release_regions(pdev);
634 pci_disable_device(pdev);
635 pci_set_drvdata(pdev, NULL);
636
635} 637}
636 638
637/* 639/*
@@ -651,8 +653,6 @@ static int netxen_nic_open(struct net_device *netdev)
651 return -EIO; 653 return -EIO;
652 } 654 }
653 netxen_nic_flash_print(adapter); 655 netxen_nic_flash_print(adapter);
654 if (adapter->init_niu)
655 adapter->init_niu(adapter);
656 656
657 /* setup all the resources for the Phantom... */ 657 /* setup all the resources for the Phantom... */
658 /* this include the descriptors for rcv, tx, and status */ 658 /* this include the descriptors for rcv, tx, and status */
@@ -663,13 +663,6 @@ static int netxen_nic_open(struct net_device *netdev)
663 err); 663 err);
664 return err; 664 return err;
665 } 665 }
666 if (adapter->init_port
667 && adapter->init_port(adapter, adapter->portnum) != 0) {
668 printk(KERN_ERR "%s: Failed to initialize port %d\n",
669 netxen_nic_driver_name, adapter->portnum);
670 netxen_free_hw_resources(adapter);
671 return -EIO;
672 }
673 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 666 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
674 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) 667 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
675 netxen_post_rx_buffers(adapter, ctx, ring); 668 netxen_post_rx_buffers(adapter, ctx, ring);
@@ -695,6 +688,15 @@ static int netxen_nic_open(struct net_device *netdev)
695 * we set it */ 688 * we set it */
696 if (adapter->macaddr_set) 689 if (adapter->macaddr_set)
697 adapter->macaddr_set(adapter, netdev->dev_addr); 690 adapter->macaddr_set(adapter, netdev->dev_addr);
691 if (adapter->init_port
692 && adapter->init_port(adapter, adapter->portnum) != 0) {
693 printk(KERN_ERR "%s: Failed to initialize port %d\n",
694 netxen_nic_driver_name, adapter->portnum);
695 free_irq(adapter->irq, adapter);
696 netxen_free_hw_resources(adapter);
697 return -EIO;
698 }
699
698 netxen_nic_set_link_parameters(adapter); 700 netxen_nic_set_link_parameters(adapter);
699 701
700 netxen_nic_set_multi(netdev); 702 netxen_nic_set_multi(netdev);
@@ -1028,6 +1030,7 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
1028 u32 ret = 0; 1030 u32 ret = 0;
1029 1031
1030 DPRINTK(INFO, "Entered handle ISR\n"); 1032 DPRINTK(INFO, "Entered handle ISR\n");
1033 adapter->stats.ints++;
1031 1034
1032 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 1035 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1033 int count = 0; 1036 int count = 0;
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
index f7eb627f81c2..cb9acf16af30 100644
--- a/drivers/net/netxen/netxen_nic_phan_reg.h
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -151,9 +151,9 @@ struct netxen_recv_crb {
151extern struct netxen_recv_crb recv_crb_registers[]; 151extern struct netxen_recv_crb recv_crb_registers[];
152extern u64 ctx_addr_sig_regs[][3]; 152extern u64 ctx_addr_sig_regs[][3];
153#endif /* DEFINE_GLOBAL_RECEIVE_CRB */ 153#endif /* DEFINE_GLOBAL_RECEIVE_CRB */
154#define CRB_CTX_ADDR_REG_LO (ctx_addr_sig_regs[0][0]) 154#define CRB_CTX_ADDR_REG_LO(FUNC_ID) (ctx_addr_sig_regs[FUNC_ID][0])
155#define CRB_CTX_ADDR_REG_HI (ctx_addr_sig_regs[0][2]) 155#define CRB_CTX_ADDR_REG_HI(FUNC_ID) (ctx_addr_sig_regs[FUNC_ID][2])
156#define CRB_CTX_SIGNATURE_REG (ctx_addr_sig_regs[0][1]) 156#define CRB_CTX_SIGNATURE_REG(FUNC_ID) (ctx_addr_sig_regs[FUNC_ID][1])
157 157
158/* 158/*
159 * Temperature control. 159 * Temperature control.