diff options
Diffstat (limited to 'drivers/net/netxen/netxen_nic_main.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 121 |
1 files changed, 82 insertions, 39 deletions
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index ffd272c93a6b..cd1336e899b1 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -31,6 +31,7 @@ | |||
31 | * | 31 | * |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/vmalloc.h> | ||
34 | #include "netxen_nic_hw.h" | 35 | #include "netxen_nic_hw.h" |
35 | 36 | ||
36 | #include "netxen_nic.h" | 37 | #include "netxen_nic.h" |
@@ -41,16 +42,19 @@ | |||
41 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
42 | #include <linux/vmalloc.h> | 43 | #include <linux/vmalloc.h> |
43 | 44 | ||
45 | #define PHAN_VENDOR_ID 0x4040 | ||
46 | |||
44 | MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); | 47 | MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); |
45 | MODULE_LICENSE("GPL"); | 48 | MODULE_LICENSE("GPL"); |
46 | MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); | 49 | MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); |
47 | 50 | ||
48 | char netxen_nic_driver_name[] = "netxen"; | 51 | char netxen_nic_driver_name[] = "netxen"; |
49 | static char netxen_nic_driver_string[] = "NetXen Network Driver version " | 52 | static char netxen_nic_driver_string[] = "NetXen Network Driver version " |
50 | NETXEN_NIC_LINUX_VERSIONID "-" NETXEN_NIC_BUILD_NO; | 53 | NETXEN_NIC_LINUX_VERSIONID; |
51 | 54 | ||
52 | #define NETXEN_NETDEV_WEIGHT 120 | 55 | #define NETXEN_NETDEV_WEIGHT 120 |
53 | #define NETXEN_ADAPTER_UP_MAGIC 777 | 56 | #define NETXEN_ADAPTER_UP_MAGIC 777 |
57 | #define NETXEN_NIC_PEG_TUNE 0 | ||
54 | 58 | ||
55 | /* Local functions to NetXen NIC driver */ | 59 | /* Local functions to NetXen NIC driver */ |
56 | static int __devinit netxen_nic_probe(struct pci_dev *pdev, | 60 | static int __devinit netxen_nic_probe(struct pci_dev *pdev, |
@@ -101,7 +105,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
101 | struct net_device *netdev = NULL; | 105 | struct net_device *netdev = NULL; |
102 | struct netxen_adapter *adapter = NULL; | 106 | struct netxen_adapter *adapter = NULL; |
103 | struct netxen_port *port = NULL; | 107 | struct netxen_port *port = NULL; |
104 | u8 __iomem *mem_ptr = NULL; | 108 | u8 *mem_ptr0 = NULL; |
109 | u8 *mem_ptr1 = NULL; | ||
110 | u8 *mem_ptr2 = NULL; | ||
111 | |||
105 | unsigned long mem_base, mem_len; | 112 | unsigned long mem_base, mem_len; |
106 | int pci_using_dac, i, err; | 113 | int pci_using_dac, i, err; |
107 | int ring; | 114 | int ring; |
@@ -111,6 +118,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
111 | u64 mac_addr[FLASH_NUM_PORTS + 1]; | 118 | u64 mac_addr[FLASH_NUM_PORTS + 1]; |
112 | int valid_mac; | 119 | int valid_mac; |
113 | 120 | ||
121 | printk(KERN_INFO "%s \n", netxen_nic_driver_string); | ||
114 | if ((err = pci_enable_device(pdev))) | 122 | if ((err = pci_enable_device(pdev))) |
115 | return err; | 123 | return err; |
116 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { | 124 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { |
@@ -138,11 +146,26 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
138 | mem_len = pci_resource_len(pdev, 0); | 146 | mem_len = pci_resource_len(pdev, 0); |
139 | 147 | ||
140 | /* 128 Meg of memory */ | 148 | /* 128 Meg of memory */ |
141 | mem_ptr = ioremap(mem_base, NETXEN_PCI_MAPSIZE_BYTES); | 149 | mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); |
142 | if (mem_ptr == 0UL) { | 150 | mem_ptr1 = |
143 | printk(KERN_ERR "%s: Cannot ioremap adapter memory aborting." | 151 | ioremap(mem_base + SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_SIZE); |
144 | ":%p\n", netxen_nic_driver_name, mem_ptr); | 152 | mem_ptr2 = |
153 | ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); | ||
154 | |||
155 | if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) { | ||
156 | DPRINTK(1, ERR, | ||
157 | "Cannot remap adapter memory aborting.:" | ||
158 | "0 -> %p, 1 -> %p, 2 -> %p\n", | ||
159 | mem_ptr0, mem_ptr1, mem_ptr2); | ||
160 | |||
145 | err = -EIO; | 161 | err = -EIO; |
162 | if (mem_ptr0) | ||
163 | iounmap(mem_ptr0); | ||
164 | if (mem_ptr1) | ||
165 | iounmap(mem_ptr1); | ||
166 | if (mem_ptr2) | ||
167 | iounmap(mem_ptr2); | ||
168 | |||
146 | goto err_out_free_res; | 169 | goto err_out_free_res; |
147 | } | 170 | } |
148 | 171 | ||
@@ -221,9 +244,17 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
221 | } | 244 | } |
222 | 245 | ||
223 | adapter->cmd_buf_arr = cmd_buf_arr; | 246 | adapter->cmd_buf_arr = cmd_buf_arr; |
224 | adapter->ahw.pci_base = mem_ptr; | 247 | adapter->ahw.pci_base0 = mem_ptr0; |
248 | adapter->ahw.pci_base1 = mem_ptr1; | ||
249 | adapter->ahw.pci_base2 = mem_ptr2; | ||
225 | spin_lock_init(&adapter->tx_lock); | 250 | spin_lock_init(&adapter->tx_lock); |
226 | spin_lock_init(&adapter->lock); | 251 | spin_lock_init(&adapter->lock); |
252 | #ifdef CONFIG_IA64 | ||
253 | netxen_pinit_from_rom(adapter, 0); | ||
254 | udelay(500); | ||
255 | netxen_load_firmware(adapter); | ||
256 | #endif | ||
257 | |||
227 | /* initialize the buffers in adapter */ | 258 | /* initialize the buffers in adapter */ |
228 | netxen_initialize_adapter_sw(adapter); | 259 | netxen_initialize_adapter_sw(adapter); |
229 | /* | 260 | /* |
@@ -262,6 +293,20 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
262 | else | 293 | else |
263 | valid_mac = 0; | 294 | valid_mac = 0; |
264 | 295 | ||
296 | /* | ||
297 | * Initialize all the CRB registers here. | ||
298 | */ | ||
299 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET)); | ||
300 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); | ||
301 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); | ||
302 | |||
303 | /* Unlock the HW, prompting the boot sequence */ | ||
304 | writel(1, | ||
305 | NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); | ||
306 | |||
307 | /* Handshake with the card before we register the devices. */ | ||
308 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); | ||
309 | |||
265 | /* initialize the all the ports */ | 310 | /* initialize the all the ports */ |
266 | 311 | ||
267 | for (i = 0; i < adapter->ahw.max_ports; i++) { | 312 | for (i = 0; i < adapter->ahw.max_ports; i++) { |
@@ -352,15 +397,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
352 | } | 397 | } |
353 | 398 | ||
354 | /* | 399 | /* |
355 | * Initialize all the CRB registers here. | ||
356 | */ | ||
357 | /* Window = 1 */ | ||
358 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET)); | ||
359 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); | ||
360 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); | ||
361 | |||
362 | netxen_phantom_init(adapter); | ||
363 | /* | ||
364 | * delay a while to ensure that the Pegs are up & running. | 400 | * delay a while to ensure that the Pegs are up & running. |
365 | * Otherwise, we might see some flaky behaviour. | 401 | * Otherwise, we might see some flaky behaviour. |
366 | */ | 402 | */ |
@@ -414,7 +450,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
414 | kfree(adapter); | 450 | kfree(adapter); |
415 | 451 | ||
416 | err_out_iounmap: | 452 | err_out_iounmap: |
417 | iounmap(mem_ptr); | 453 | iounmap(mem_ptr0); |
454 | iounmap(mem_ptr1); | ||
455 | iounmap(mem_ptr2); | ||
456 | |||
418 | err_out_free_res: | 457 | err_out_free_res: |
419 | pci_release_regions(pdev); | 458 | pci_release_regions(pdev); |
420 | err_out_disable_pdev: | 459 | err_out_disable_pdev: |
@@ -460,7 +499,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
460 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) | 499 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) |
461 | netxen_free_hw_resources(adapter); | 500 | netxen_free_hw_resources(adapter); |
462 | 501 | ||
463 | iounmap(adapter->ahw.pci_base); | 502 | iounmap(adapter->ahw.pci_base0); |
503 | iounmap(adapter->ahw.pci_base1); | ||
504 | iounmap(adapter->ahw.pci_base2); | ||
464 | 505 | ||
465 | pci_release_regions(pdev); | 506 | pci_release_regions(pdev); |
466 | pci_disable_device(pdev); | 507 | pci_disable_device(pdev); |
@@ -496,7 +537,6 @@ static int netxen_nic_open(struct net_device *netdev) | |||
496 | { | 537 | { |
497 | struct netxen_port *port = netdev_priv(netdev); | 538 | struct netxen_port *port = netdev_priv(netdev); |
498 | struct netxen_adapter *adapter = port->adapter; | 539 | struct netxen_adapter *adapter = port->adapter; |
499 | struct netxen_rcv_desc_ctx *rcv_desc; | ||
500 | int err = 0; | 540 | int err = 0; |
501 | int ctx, ring; | 541 | int ctx, ring; |
502 | 542 | ||
@@ -527,11 +567,8 @@ static int netxen_nic_open(struct net_device *netdev) | |||
527 | if (adapter->ops->init_niu) | 567 | if (adapter->ops->init_niu) |
528 | adapter->ops->init_niu(adapter); | 568 | adapter->ops->init_niu(adapter); |
529 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 569 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
530 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { | 570 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) |
531 | rcv_desc = | ||
532 | &adapter->recv_ctx[ctx].rcv_desc[ring]; | ||
533 | netxen_post_rx_buffers(adapter, ctx, ring); | 571 | netxen_post_rx_buffers(adapter, ctx, ring); |
534 | } | ||
535 | } | 572 | } |
536 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; | 573 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; |
537 | } | 574 | } |
@@ -579,10 +616,6 @@ static int netxen_nic_close(struct net_device *netdev) | |||
579 | netif_carrier_off(netdev); | 616 | netif_carrier_off(netdev); |
580 | netif_stop_queue(netdev); | 617 | netif_stop_queue(netdev); |
581 | 618 | ||
582 | /* disable phy_ints */ | ||
583 | if (adapter->ops->disable_phy_interrupts) | ||
584 | adapter->ops->disable_phy_interrupts(adapter, port->portnum); | ||
585 | |||
586 | adapter->active_ports--; | 619 | adapter->active_ports--; |
587 | 620 | ||
588 | if (!adapter->active_ports) { | 621 | if (!adapter->active_ports) { |
@@ -690,13 +723,16 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
690 | local_producer = adapter->cmd_producer; | 723 | local_producer = adapter->cmd_producer; |
691 | /* There 4 fragments per descriptor */ | 724 | /* There 4 fragments per descriptor */ |
692 | no_of_desc = (frag_count + 3) >> 2; | 725 | no_of_desc = (frag_count + 3) >> 2; |
693 | if (skb_shinfo(skb)->gso_size > 0) { | 726 | if (netdev->features & NETIF_F_TSO) { |
694 | no_of_desc++; | 727 | if (skb_shinfo(skb)->gso_size > 0) { |
695 | if (((skb->nh.iph)->ihl * sizeof(u32)) + | 728 | |
696 | ((skb->h.th)->doff * sizeof(u32)) + | ||
697 | sizeof(struct ethhdr) > | ||
698 | (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) { | ||
699 | no_of_desc++; | 729 | no_of_desc++; |
730 | if (((skb->nh.iph)->ihl * sizeof(u32)) + | ||
731 | ((skb->h.th)->doff * sizeof(u32)) + | ||
732 | sizeof(struct ethhdr) > | ||
733 | (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) { | ||
734 | no_of_desc++; | ||
735 | } | ||
700 | } | 736 | } |
701 | } | 737 | } |
702 | k = adapter->cmd_producer; | 738 | k = adapter->cmd_producer; |
@@ -740,7 +776,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
740 | memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); | 776 | memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); |
741 | /* Take skb->data itself */ | 777 | /* Take skb->data itself */ |
742 | pbuf = &adapter->cmd_buf_arr[producer]; | 778 | pbuf = &adapter->cmd_buf_arr[producer]; |
743 | if (skb_shinfo(skb)->gso_size > 0) { | 779 | if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size > 0) { |
744 | pbuf->mss = skb_shinfo(skb)->gso_size; | 780 | pbuf->mss = skb_shinfo(skb)->gso_size; |
745 | hwdesc->mss = skb_shinfo(skb)->gso_size; | 781 | hwdesc->mss = skb_shinfo(skb)->gso_size; |
746 | } else { | 782 | } else { |
@@ -934,9 +970,10 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) | |||
934 | /* Window = 0 or 1 */ | 970 | /* Window = 0 or 1 */ |
935 | do { | 971 | do { |
936 | writel(0xffffffff, (void __iomem *) | 972 | writel(0xffffffff, (void __iomem *) |
937 | (adapter->ahw.pci_base + ISR_INT_TARGET_STATUS)); | 973 | (PCI_OFFSET_SECOND_RANGE |
974 | (adapter, ISR_INT_TARGET_STATUS))); | ||
938 | mask = readl((void __iomem *) | 975 | mask = readl((void __iomem *) |
939 | (adapter->ahw.pci_base + ISR_INT_VECTOR)); | 976 | pci_base_offset(adapter, ISR_INT_VECTOR)); |
940 | } while (((mask & 0x80) != 0) && (++count < 32)); | 977 | } while (((mask & 0x80) != 0) && (++count < 32)); |
941 | if ((mask & 0x80) != 0) | 978 | if ((mask & 0x80) != 0) |
942 | printk("Could not disable interrupt completely\n"); | 979 | printk("Could not disable interrupt completely\n"); |
@@ -1065,8 +1102,10 @@ static int | |||
1065 | netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | 1102 | netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) |
1066 | { | 1103 | { |
1067 | int err = 0; | 1104 | int err = 0; |
1105 | unsigned long nr_bytes = 0; | ||
1068 | struct netxen_port *port = netdev_priv(netdev); | 1106 | struct netxen_port *port = netdev_priv(netdev); |
1069 | struct netxen_adapter *adapter = port->adapter; | 1107 | struct netxen_adapter *adapter = port->adapter; |
1108 | char dev_name[NETXEN_NIC_NAME_LEN]; | ||
1070 | 1109 | ||
1071 | DPRINTK(INFO, "doing ioctl for %s\n", netdev->name); | 1110 | DPRINTK(INFO, "doing ioctl for %s\n", netdev->name); |
1072 | switch (cmd) { | 1111 | switch (cmd) { |
@@ -1077,7 +1116,13 @@ netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | |||
1077 | case NETXEN_NIC_NAME: | 1116 | case NETXEN_NIC_NAME: |
1078 | DPRINTK(INFO, "ioctl cmd for NetXen\n"); | 1117 | DPRINTK(INFO, "ioctl cmd for NetXen\n"); |
1079 | if (ifr->ifr_data) { | 1118 | if (ifr->ifr_data) { |
1080 | put_user(port->portnum, (u16 __user *) ifr->ifr_data); | 1119 | sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP, |
1120 | port->portnum); | ||
1121 | nr_bytes = copy_to_user((char *)ifr->ifr_data, dev_name, | ||
1122 | NETXEN_NIC_NAME_LEN); | ||
1123 | if (nr_bytes) | ||
1124 | err = -EIO; | ||
1125 | |||
1081 | } | 1126 | } |
1082 | break; | 1127 | break; |
1083 | 1128 | ||
@@ -1101,8 +1146,6 @@ static struct pci_driver netxen_driver = { | |||
1101 | 1146 | ||
1102 | static int __init netxen_init_module(void) | 1147 | static int __init netxen_init_module(void) |
1103 | { | 1148 | { |
1104 | printk(KERN_INFO "%s \n", netxen_nic_driver_string); | ||
1105 | |||
1106 | return pci_module_init(&netxen_driver); | 1149 | return pci_module_init(&netxen_driver); |
1107 | } | 1150 | } |
1108 | 1151 | ||