diff options
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 189 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 212 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hdr.h | 12 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 401 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.h | 85 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 130 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_isr.c | 101 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 769 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_niu.c | 168 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_phan_reg.h | 134 |
10 files changed, 1235 insertions, 966 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index dd8ce35332fe..ad6688eab265 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -64,9 +64,9 @@ | |||
64 | #include "netxen_nic_hw.h" | 64 | #include "netxen_nic_hw.h" |
65 | 65 | ||
66 | #define _NETXEN_NIC_LINUX_MAJOR 3 | 66 | #define _NETXEN_NIC_LINUX_MAJOR 3 |
67 | #define _NETXEN_NIC_LINUX_MINOR 3 | 67 | #define _NETXEN_NIC_LINUX_MINOR 4 |
68 | #define _NETXEN_NIC_LINUX_SUBVERSION 3 | 68 | #define _NETXEN_NIC_LINUX_SUBVERSION 2 |
69 | #define NETXEN_NIC_LINUX_VERSIONID "3.3.3" | 69 | #define NETXEN_NIC_LINUX_VERSIONID "3.4.2" |
70 | 70 | ||
71 | #define NUM_FLASH_SECTORS (64) | 71 | #define NUM_FLASH_SECTORS (64) |
72 | #define FLASH_SECTOR_SIZE (64 * 1024) | 72 | #define FLASH_SECTOR_SIZE (64 * 1024) |
@@ -131,8 +131,8 @@ extern struct workqueue_struct *netxen_workq; | |||
131 | #define FIRST_PAGE_GROUP_START 0 | 131 | #define FIRST_PAGE_GROUP_START 0 |
132 | #define FIRST_PAGE_GROUP_END 0x100000 | 132 | #define FIRST_PAGE_GROUP_END 0x100000 |
133 | 133 | ||
134 | #define SECOND_PAGE_GROUP_START 0x4000000 | 134 | #define SECOND_PAGE_GROUP_START 0x6000000 |
135 | #define SECOND_PAGE_GROUP_END 0x66BC000 | 135 | #define SECOND_PAGE_GROUP_END 0x68BC000 |
136 | 136 | ||
137 | #define THIRD_PAGE_GROUP_START 0x70E4000 | 137 | #define THIRD_PAGE_GROUP_START 0x70E4000 |
138 | #define THIRD_PAGE_GROUP_END 0x8000000 | 138 | #define THIRD_PAGE_GROUP_END 0x8000000 |
@@ -205,6 +205,8 @@ enum { | |||
205 | 205 | ||
206 | #define MAX_CMD_DESCRIPTORS 1024 | 206 | #define MAX_CMD_DESCRIPTORS 1024 |
207 | #define MAX_RCV_DESCRIPTORS 16384 | 207 | #define MAX_RCV_DESCRIPTORS 16384 |
208 | #define MAX_CMD_DESCRIPTORS_HOST (MAX_CMD_DESCRIPTORS / 4) | ||
209 | #define MAX_RCV_DESCRIPTORS_1G (MAX_RCV_DESCRIPTORS / 4) | ||
208 | #define MAX_JUMBO_RCV_DESCRIPTORS 1024 | 210 | #define MAX_JUMBO_RCV_DESCRIPTORS 1024 |
209 | #define MAX_LRO_RCV_DESCRIPTORS 64 | 211 | #define MAX_LRO_RCV_DESCRIPTORS 64 |
210 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS | 212 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS |
@@ -230,7 +232,9 @@ enum { | |||
230 | (((index) + (count)) & ((length) - 1)) | 232 | (((index) + (count)) & ((length) - 1)) |
231 | 233 | ||
232 | #define MPORT_SINGLE_FUNCTION_MODE 0x1111 | 234 | #define MPORT_SINGLE_FUNCTION_MODE 0x1111 |
235 | #define MPORT_MULTI_FUNCTION_MODE 0x2222 | ||
233 | 236 | ||
237 | #include "netxen_nic_phan_reg.h" | ||
234 | extern unsigned long long netxen_dma_mask; | 238 | extern unsigned long long netxen_dma_mask; |
235 | extern unsigned long last_schedule_time; | 239 | extern unsigned long last_schedule_time; |
236 | 240 | ||
@@ -300,6 +304,8 @@ struct netxen_ring_ctx { | |||
300 | 304 | ||
301 | #define netxen_set_cmd_desc_port(cmd_desc, var) \ | 305 | #define netxen_set_cmd_desc_port(cmd_desc, var) \ |
302 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) | 306 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) |
307 | #define netxen_set_cmd_desc_ctxid(cmd_desc, var) \ | ||
308 | ((cmd_desc)->port_ctxid |= ((var) & 0xF0)) | ||
303 | 309 | ||
304 | #define netxen_set_cmd_desc_flags(cmd_desc, val) \ | 310 | #define netxen_set_cmd_desc_flags(cmd_desc, val) \ |
305 | ((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x7f), \ | 311 | ((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x7f), \ |
@@ -442,7 +448,7 @@ struct status_desc { | |||
442 | /* Bit pattern: 0-6 lro_count indicates frag sequence, | 448 | /* Bit pattern: 0-6 lro_count indicates frag sequence, |
443 | 7 last_frag indicates last frag */ | 449 | 7 last_frag indicates last frag */ |
444 | u8 lro; | 450 | u8 lro; |
445 | } __attribute__ ((aligned(8))); | 451 | } __attribute__ ((aligned(16))); |
446 | 452 | ||
447 | enum { | 453 | enum { |
448 | NETXEN_RCV_PEG_0 = 0, | 454 | NETXEN_RCV_PEG_0 = 0, |
@@ -703,10 +709,8 @@ extern char netxen_nic_driver_name[]; | |||
703 | #else | 709 | #else |
704 | #define DPRINTK(klevel, fmt, args...) do { \ | 710 | #define DPRINTK(klevel, fmt, args...) do { \ |
705 | printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ | 711 | printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ |
706 | (adapter != NULL && \ | 712 | (adapter != NULL && adapter->netdev != NULL) ? \ |
707 | adapter->port[0] != NULL && \ | 713 | adapter->netdev->name : NULL, \ |
708 | adapter->port[0]->netdev != NULL) ? \ | ||
709 | adapter->port[0]->netdev->name : NULL, \ | ||
710 | ## args); } while(0) | 714 | ## args); } while(0) |
711 | #endif | 715 | #endif |
712 | 716 | ||
@@ -722,6 +726,18 @@ struct netxen_skb_frag { | |||
722 | u32 length; | 726 | u32 length; |
723 | }; | 727 | }; |
724 | 728 | ||
729 | #define _netxen_set_bits(config_word, start, bits, val) {\ | ||
730 | unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start));\ | ||
731 | unsigned long long __tvalue = (val); \ | ||
732 | (config_word) &= ~__tmask; \ | ||
733 | (config_word) |= (((__tvalue) << (start)) & __tmask); \ | ||
734 | } | ||
735 | |||
736 | #define _netxen_clear_bits(config_word, start, bits) {\ | ||
737 | unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start)); \ | ||
738 | (config_word) &= ~__tmask; \ | ||
739 | } | ||
740 | |||
725 | /* Following defines are for the state of the buffers */ | 741 | /* Following defines are for the state of the buffers */ |
726 | #define NETXEN_BUFFER_FREE 0 | 742 | #define NETXEN_BUFFER_FREE 0 |
727 | #define NETXEN_BUFFER_BUSY 1 | 743 | #define NETXEN_BUFFER_BUSY 1 |
@@ -766,6 +782,8 @@ struct netxen_hardware_context { | |||
766 | void __iomem *pci_base0; | 782 | void __iomem *pci_base0; |
767 | void __iomem *pci_base1; | 783 | void __iomem *pci_base1; |
768 | void __iomem *pci_base2; | 784 | void __iomem *pci_base2; |
785 | unsigned long first_page_group_end; | ||
786 | unsigned long first_page_group_start; | ||
769 | void __iomem *db_base; | 787 | void __iomem *db_base; |
770 | unsigned long db_len; | 788 | unsigned long db_len; |
771 | 789 | ||
@@ -780,6 +798,7 @@ struct netxen_hardware_context { | |||
780 | struct pci_dev *cmd_desc_pdev; | 798 | struct pci_dev *cmd_desc_pdev; |
781 | dma_addr_t cmd_desc_phys_addr; | 799 | dma_addr_t cmd_desc_phys_addr; |
782 | struct netxen_adapter *adapter; | 800 | struct netxen_adapter *adapter; |
801 | int pci_func; | ||
783 | }; | 802 | }; |
784 | 803 | ||
785 | #define RCV_RING_LRO RCV_DESC_LRO | 804 | #define RCV_RING_LRO RCV_DESC_LRO |
@@ -788,17 +807,27 @@ struct netxen_hardware_context { | |||
788 | #define ETHERNET_FCS_SIZE 4 | 807 | #define ETHERNET_FCS_SIZE 4 |
789 | 808 | ||
790 | struct netxen_adapter_stats { | 809 | struct netxen_adapter_stats { |
791 | u64 ints; | 810 | u64 rcvdbadskb; |
792 | u64 hostints; | 811 | u64 xmitcalled; |
793 | u64 otherints; | 812 | u64 xmitedframes; |
794 | u64 process_rcv; | 813 | u64 xmitfinished; |
795 | u64 process_xmit; | 814 | u64 badskblen; |
796 | u64 noxmitdone; | 815 | u64 nocmddescriptor; |
797 | u64 xmitcsummed; | 816 | u64 polled; |
798 | u64 post_called; | 817 | u64 uphappy; |
799 | u64 posted; | 818 | u64 updropped; |
800 | u64 lastposted; | 819 | u64 uplcong; |
801 | u64 goodskbposts; | 820 | u64 uphcong; |
821 | u64 upmcong; | ||
822 | u64 updunno; | ||
823 | u64 skbfreed; | ||
824 | u64 txdropped; | ||
825 | u64 txnullskb; | ||
826 | u64 csummed; | ||
827 | u64 no_rcv; | ||
828 | u64 rxbytes; | ||
829 | u64 txbytes; | ||
830 | u64 ints; | ||
802 | }; | 831 | }; |
803 | 832 | ||
804 | /* | 833 | /* |
@@ -846,13 +875,20 @@ struct netxen_dummy_dma { | |||
846 | 875 | ||
847 | struct netxen_adapter { | 876 | struct netxen_adapter { |
848 | struct netxen_hardware_context ahw; | 877 | struct netxen_hardware_context ahw; |
849 | int port_count; /* Number of configured ports */ | 878 | |
850 | int active_ports; /* Number of open ports */ | 879 | struct netxen_adapter *master; |
851 | struct netxen_port *port[NETXEN_MAX_PORTS]; /* ptr to each port */ | 880 | struct net_device *netdev; |
881 | struct pci_dev *pdev; | ||
882 | struct net_device_stats net_stats; | ||
883 | unsigned char mac_addr[ETH_ALEN]; | ||
884 | int mtu; | ||
885 | int portnum; | ||
886 | |||
852 | spinlock_t tx_lock; | 887 | spinlock_t tx_lock; |
853 | spinlock_t lock; | 888 | spinlock_t lock; |
854 | struct work_struct watchdog_task; | 889 | struct work_struct watchdog_task; |
855 | struct timer_list watchdog_timer; | 890 | struct timer_list watchdog_timer; |
891 | struct work_struct tx_timeout_task; | ||
856 | 892 | ||
857 | u32 curr_window; | 893 | u32 curr_window; |
858 | 894 | ||
@@ -875,6 +911,15 @@ struct netxen_adapter { | |||
875 | u32 temp; | 911 | u32 temp; |
876 | 912 | ||
877 | struct netxen_adapter_stats stats; | 913 | struct netxen_adapter_stats stats; |
914 | |||
915 | u16 portno; | ||
916 | u16 link_speed; | ||
917 | u16 link_duplex; | ||
918 | u16 state; | ||
919 | u16 link_autoneg; | ||
920 | int rcsum; | ||
921 | int status; | ||
922 | spinlock_t stats_lock; | ||
878 | 923 | ||
879 | struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */ | 924 | struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */ |
880 | 925 | ||
@@ -891,65 +936,23 @@ struct netxen_adapter { | |||
891 | struct netxen_ring_ctx *ctx_desc; | 936 | struct netxen_ring_ctx *ctx_desc; |
892 | struct pci_dev *ctx_desc_pdev; | 937 | struct pci_dev *ctx_desc_pdev; |
893 | dma_addr_t ctx_desc_phys_addr; | 938 | dma_addr_t ctx_desc_phys_addr; |
894 | int (*enable_phy_interrupts) (struct netxen_adapter *, int); | 939 | int (*enable_phy_interrupts) (struct netxen_adapter *); |
895 | int (*disable_phy_interrupts) (struct netxen_adapter *, int); | 940 | int (*disable_phy_interrupts) (struct netxen_adapter *); |
896 | void (*handle_phy_intr) (struct netxen_adapter *); | 941 | void (*handle_phy_intr) (struct netxen_adapter *); |
897 | int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t); | 942 | int (*macaddr_set) (struct netxen_adapter *, netxen_ethernet_macaddr_t); |
898 | int (*set_mtu) (struct netxen_port *, int); | 943 | int (*set_mtu) (struct netxen_adapter *, int); |
899 | int (*set_promisc) (struct netxen_adapter *, int, | 944 | int (*set_promisc) (struct netxen_adapter *, netxen_niu_prom_mode_t); |
900 | netxen_niu_prom_mode_t); | 945 | int (*unset_promisc) (struct netxen_adapter *, netxen_niu_prom_mode_t); |
901 | int (*unset_promisc) (struct netxen_adapter *, int, | 946 | int (*phy_read) (struct netxen_adapter *, long reg, u32 *); |
902 | netxen_niu_prom_mode_t); | 947 | int (*phy_write) (struct netxen_adapter *, long reg, u32 val); |
903 | int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *); | ||
904 | int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val); | ||
905 | int (*init_port) (struct netxen_adapter *, int); | 948 | int (*init_port) (struct netxen_adapter *, int); |
906 | void (*init_niu) (struct netxen_adapter *); | 949 | void (*init_niu) (struct netxen_adapter *); |
907 | int (*stop_port) (struct netxen_adapter *, int); | 950 | int (*stop_port) (struct netxen_adapter *); |
908 | }; /* netxen_adapter structure */ | 951 | }; /* netxen_adapter structure */ |
909 | 952 | ||
910 | /* Max number of xmit producer threads that can run simultaneously */ | 953 | /* Max number of xmit producer threads that can run simultaneously */ |
911 | #define MAX_XMIT_PRODUCERS 16 | 954 | #define MAX_XMIT_PRODUCERS 16 |
912 | 955 | ||
913 | struct netxen_port_stats { | ||
914 | u64 rcvdbadskb; | ||
915 | u64 xmitcalled; | ||
916 | u64 xmitedframes; | ||
917 | u64 xmitfinished; | ||
918 | u64 badskblen; | ||
919 | u64 nocmddescriptor; | ||
920 | u64 polled; | ||
921 | u64 uphappy; | ||
922 | u64 updropped; | ||
923 | u64 uplcong; | ||
924 | u64 uphcong; | ||
925 | u64 upmcong; | ||
926 | u64 updunno; | ||
927 | u64 skbfreed; | ||
928 | u64 txdropped; | ||
929 | u64 txnullskb; | ||
930 | u64 csummed; | ||
931 | u64 no_rcv; | ||
932 | u64 rxbytes; | ||
933 | u64 txbytes; | ||
934 | }; | ||
935 | |||
936 | struct netxen_port { | ||
937 | struct netxen_adapter *adapter; | ||
938 | |||
939 | u16 portnum; /* GBE port number */ | ||
940 | u16 link_speed; | ||
941 | u16 link_duplex; | ||
942 | u16 link_autoneg; | ||
943 | |||
944 | int flags; | ||
945 | |||
946 | struct net_device *netdev; | ||
947 | struct pci_dev *pdev; | ||
948 | struct net_device_stats net_stats; | ||
949 | struct netxen_port_stats stats; | ||
950 | struct work_struct tx_timeout_task; | ||
951 | }; | ||
952 | |||
953 | #define PCI_OFFSET_FIRST_RANGE(adapter, off) \ | 956 | #define PCI_OFFSET_FIRST_RANGE(adapter, off) \ |
954 | ((adapter)->ahw.pci_base0 + (off)) | 957 | ((adapter)->ahw.pci_base0 + (off)) |
955 | #define PCI_OFFSET_SECOND_RANGE(adapter, off) \ | 958 | #define PCI_OFFSET_SECOND_RANGE(adapter, off) \ |
@@ -987,32 +990,26 @@ static inline void __iomem *pci_base(struct netxen_adapter *adapter, | |||
987 | return NULL; | 990 | return NULL; |
988 | } | 991 | } |
989 | 992 | ||
990 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 993 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter); |
991 | int port); | 994 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter); |
992 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 995 | int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter); |
993 | int port); | 996 | int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter); |
994 | int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter, | 997 | int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter); |
995 | int port); | 998 | int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter); |
996 | int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter, | ||
997 | int port); | ||
998 | int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter, | ||
999 | int port); | ||
1000 | int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter, | ||
1001 | int port); | ||
1002 | void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter); | 999 | void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter); |
1003 | void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter); | 1000 | void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter); |
1004 | void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, int port, | 1001 | void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, int port, |
1005 | long enable); | 1002 | long enable); |
1006 | void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, int port, | 1003 | void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, int port, |
1007 | long enable); | 1004 | long enable); |
1008 | int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, long reg, | 1005 | int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg, |
1009 | __u32 * readval); | 1006 | __u32 * readval); |
1010 | int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy, | 1007 | int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, |
1011 | long reg, __u32 val); | 1008 | long reg, __u32 val); |
1012 | 1009 | ||
1013 | /* Functions available from netxen_nic_hw.c */ | 1010 | /* Functions available from netxen_nic_hw.c */ |
1014 | int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu); | 1011 | int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu); |
1015 | int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu); | 1012 | int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu); |
1016 | void netxen_nic_init_niu_gb(struct netxen_adapter *adapter); | 1013 | void netxen_nic_init_niu_gb(struct netxen_adapter *adapter); |
1017 | void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw); | 1014 | void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw); |
1018 | void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val); | 1015 | void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val); |
@@ -1027,6 +1024,7 @@ int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, | |||
1027 | int len); | 1024 | int len); |
1028 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, | 1025 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, |
1029 | unsigned long off, int data); | 1026 | unsigned long off, int data); |
1027 | int netxen_nic_erase_pxe(struct netxen_adapter *adapter); | ||
1030 | 1028 | ||
1031 | /* Functions from netxen_nic_init.c */ | 1029 | /* Functions from netxen_nic_init.c */ |
1032 | void netxen_free_adapter_offload(struct netxen_adapter *adapter); | 1030 | void netxen_free_adapter_offload(struct netxen_adapter *adapter); |
@@ -1051,11 +1049,8 @@ int netxen_do_rom_se(struct netxen_adapter *adapter, int addr); | |||
1051 | 1049 | ||
1052 | /* Functions from netxen_nic_isr.c */ | 1050 | /* Functions from netxen_nic_isr.c */ |
1053 | void netxen_nic_isr_other(struct netxen_adapter *adapter); | 1051 | void netxen_nic_isr_other(struct netxen_adapter *adapter); |
1054 | void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 port, | 1052 | void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 link); |
1055 | u32 link); | 1053 | void netxen_handle_port_int(struct netxen_adapter *adapter, u32 enable); |
1056 | void netxen_handle_port_int(struct netxen_adapter *adapter, u32 port, | ||
1057 | u32 enable); | ||
1058 | void netxen_nic_stop_all_ports(struct netxen_adapter *adapter); | ||
1059 | void netxen_initialize_adapter_sw(struct netxen_adapter *adapter); | 1054 | void netxen_initialize_adapter_sw(struct netxen_adapter *adapter); |
1060 | void netxen_initialize_adapter_hw(struct netxen_adapter *adapter); | 1055 | void netxen_initialize_adapter_hw(struct netxen_adapter *adapter); |
1061 | void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr, | 1056 | void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr, |
@@ -1110,6 +1105,7 @@ static inline void netxen_nic_enable_int(struct netxen_adapter *adapter) | |||
1110 | 1105 | ||
1111 | if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { | 1106 | if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { |
1112 | mask = 0xbff; | 1107 | mask = 0xbff; |
1108 | writel(0X0, NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); | ||
1113 | writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, | 1109 | writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, |
1114 | ISR_INT_TARGET_MASK)); | 1110 | ISR_INT_TARGET_MASK)); |
1115 | } | 1111 | } |
@@ -1174,4 +1170,5 @@ extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, | |||
1174 | 1170 | ||
1175 | extern struct ethtool_ops netxen_nic_ethtool_ops; | 1171 | extern struct ethtool_ops netxen_nic_ethtool_ops; |
1176 | 1172 | ||
1173 | extern int physical_port[]; /* physical port # from virtual port.*/ | ||
1177 | #endif /* __NETXEN_NIC_H_ */ | 1174 | #endif /* __NETXEN_NIC_H_ */ |
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index ee1b5a24cbe7..16fabb377488 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c | |||
@@ -40,8 +40,8 @@ | |||
40 | #include <linux/ethtool.h> | 40 | #include <linux/ethtool.h> |
41 | #include <linux/version.h> | 41 | #include <linux/version.h> |
42 | 42 | ||
43 | #include "netxen_nic_hw.h" | ||
44 | #include "netxen_nic.h" | 43 | #include "netxen_nic.h" |
44 | #include "netxen_nic_hw.h" | ||
45 | #include "netxen_nic_phan_reg.h" | 45 | #include "netxen_nic_phan_reg.h" |
46 | 46 | ||
47 | struct netxen_nic_stats { | 47 | struct netxen_nic_stats { |
@@ -50,8 +50,8 @@ struct netxen_nic_stats { | |||
50 | int stat_offset; | 50 | int stat_offset; |
51 | }; | 51 | }; |
52 | 52 | ||
53 | #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \ | 53 | #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \ |
54 | offsetof(struct netxen_port, m) | 54 | offsetof(struct netxen_adapter, m) |
55 | 55 | ||
56 | #define NETXEN_NIC_PORT_WINDOW 0x10000 | 56 | #define NETXEN_NIC_PORT_WINDOW 0x10000 |
57 | #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF | 57 | #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF |
@@ -100,8 +100,7 @@ static int netxen_nic_get_eeprom_len(struct net_device *dev) | |||
100 | static void | 100 | static void |
101 | netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | 101 | netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) |
102 | { | 102 | { |
103 | struct netxen_port *port = netdev_priv(dev); | 103 | struct netxen_adapter *adapter = netdev_priv(dev); |
104 | struct netxen_adapter *adapter = port->adapter; | ||
105 | u32 fw_major = 0; | 104 | u32 fw_major = 0; |
106 | u32 fw_minor = 0; | 105 | u32 fw_minor = 0; |
107 | u32 fw_build = 0; | 106 | u32 fw_build = 0; |
@@ -115,7 +114,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
115 | fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB)); | 114 | fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB)); |
116 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); | 115 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); |
117 | 116 | ||
118 | strncpy(drvinfo->bus_info, pci_name(port->pdev), 32); | 117 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
119 | drvinfo->n_stats = NETXEN_NIC_STATS_LEN; | 118 | drvinfo->n_stats = NETXEN_NIC_STATS_LEN; |
120 | drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN; | 119 | drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN; |
121 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; | 120 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; |
@@ -125,8 +124,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
125 | static int | 124 | static int |
126 | netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 125 | netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
127 | { | 126 | { |
128 | struct netxen_port *port = netdev_priv(dev); | 127 | struct netxen_adapter *adapter = netdev_priv(dev); |
129 | struct netxen_adapter *adapter = port->adapter; | ||
130 | struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg; | 128 | struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg; |
131 | 129 | ||
132 | /* read which mode */ | 130 | /* read which mode */ |
@@ -146,8 +144,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
146 | ecmd->port = PORT_TP; | 144 | ecmd->port = PORT_TP; |
147 | 145 | ||
148 | if (netif_running(dev)) { | 146 | if (netif_running(dev)) { |
149 | ecmd->speed = port->link_speed; | 147 | ecmd->speed = adapter->link_speed; |
150 | ecmd->duplex = port->link_duplex; | 148 | ecmd->duplex = adapter->link_duplex; |
151 | } else | 149 | } else |
152 | return -EIO; /* link absent */ | 150 | return -EIO; /* link absent */ |
153 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | 151 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { |
@@ -165,7 +163,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
165 | } else | 163 | } else |
166 | return -EIO; | 164 | return -EIO; |
167 | 165 | ||
168 | ecmd->phy_address = port->portnum; | 166 | ecmd->phy_address = adapter->portnum; |
169 | ecmd->transceiver = XCVR_EXTERNAL; | 167 | ecmd->transceiver = XCVR_EXTERNAL; |
170 | 168 | ||
171 | switch ((netxen_brdtype_t) boardinfo->board_type) { | 169 | switch ((netxen_brdtype_t) boardinfo->board_type) { |
@@ -179,7 +177,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
179 | ecmd->port = PORT_TP; | 177 | ecmd->port = PORT_TP; |
180 | ecmd->autoneg = (boardinfo->board_type == | 178 | ecmd->autoneg = (boardinfo->board_type == |
181 | NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? | 179 | NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? |
182 | (AUTONEG_DISABLE) : (port->link_autoneg); | 180 | (AUTONEG_DISABLE) : (adapter->link_autoneg); |
183 | break; | 181 | break; |
184 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: | 182 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: |
185 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: | 183 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: |
@@ -206,23 +204,22 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
206 | static int | 204 | static int |
207 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 205 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
208 | { | 206 | { |
209 | struct netxen_port *port = netdev_priv(dev); | 207 | struct netxen_adapter *adapter = netdev_priv(dev); |
210 | struct netxen_adapter *adapter = port->adapter; | ||
211 | __u32 status; | 208 | __u32 status; |
212 | 209 | ||
213 | /* read which mode */ | 210 | /* read which mode */ |
214 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 211 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
215 | /* autonegotiation */ | 212 | /* autonegotiation */ |
216 | if (adapter->phy_write | 213 | if (adapter->phy_write |
217 | && adapter->phy_write(adapter, port->portnum, | 214 | && adapter->phy_write(adapter, |
218 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 215 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
219 | ecmd->autoneg) != 0) | 216 | ecmd->autoneg) != 0) |
220 | return -EIO; | 217 | return -EIO; |
221 | else | 218 | else |
222 | port->link_autoneg = ecmd->autoneg; | 219 | adapter->link_autoneg = ecmd->autoneg; |
223 | 220 | ||
224 | if (adapter->phy_read | 221 | if (adapter->phy_read |
225 | && adapter->phy_read(adapter, port->portnum, | 222 | && adapter->phy_read(adapter, |
226 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 223 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
227 | &status) != 0) | 224 | &status) != 0) |
228 | return -EIO; | 225 | return -EIO; |
@@ -245,13 +242,13 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
245 | if (ecmd->duplex == DUPLEX_FULL) | 242 | if (ecmd->duplex == DUPLEX_FULL) |
246 | netxen_set_phy_duplex(status); | 243 | netxen_set_phy_duplex(status); |
247 | if (adapter->phy_write | 244 | if (adapter->phy_write |
248 | && adapter->phy_write(adapter, port->portnum, | 245 | && adapter->phy_write(adapter, |
249 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 246 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
250 | *((int *)&status)) != 0) | 247 | *((int *)&status)) != 0) |
251 | return -EIO; | 248 | return -EIO; |
252 | else { | 249 | else { |
253 | port->link_speed = ecmd->speed; | 250 | adapter->link_speed = ecmd->speed; |
254 | port->link_duplex = ecmd->duplex; | 251 | adapter->link_duplex = ecmd->duplex; |
255 | } | 252 | } |
256 | } else | 253 | } else |
257 | return -EOPNOTSUPP; | 254 | return -EOPNOTSUPP; |
@@ -360,15 +357,14 @@ static struct netxen_niu_regs niu_registers[] = { | |||
360 | static void | 357 | static void |
361 | netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | 358 | netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) |
362 | { | 359 | { |
363 | struct netxen_port *port = netdev_priv(dev); | 360 | struct netxen_adapter *adapter = netdev_priv(dev); |
364 | struct netxen_adapter *adapter = port->adapter; | ||
365 | __u32 mode, *regs_buff = p; | 361 | __u32 mode, *regs_buff = p; |
366 | void __iomem *addr; | 362 | void __iomem *addr; |
367 | int i, window; | 363 | int i, window; |
368 | 364 | ||
369 | memset(p, 0, NETXEN_NIC_REGS_LEN); | 365 | memset(p, 0, NETXEN_NIC_REGS_LEN); |
370 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | | 366 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | |
371 | (port->pdev)->device; | 367 | (adapter->pdev)->device; |
372 | /* which mode */ | 368 | /* which mode */ |
373 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, ®s_buff[0]); | 369 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, ®s_buff[0]); |
374 | mode = regs_buff[0]; | 370 | mode = regs_buff[0]; |
@@ -383,7 +379,8 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | |||
383 | for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { | 379 | for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { |
384 | /* GB: port specific registers */ | 380 | /* GB: port specific registers */ |
385 | if (mode == 0 && i >= 19) | 381 | if (mode == 0 && i >= 19) |
386 | window = port->portnum * NETXEN_NIC_PORT_WINDOW; | 382 | window = physical_port[adapter->portnum] * |
383 | NETXEN_NIC_PORT_WINDOW; | ||
387 | 384 | ||
388 | NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. | 385 | NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. |
389 | reg[i - 3] + window, | 386 | reg[i - 3] + window, |
@@ -395,15 +392,14 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | |||
395 | 392 | ||
396 | static u32 netxen_nic_test_link(struct net_device *dev) | 393 | static u32 netxen_nic_test_link(struct net_device *dev) |
397 | { | 394 | { |
398 | struct netxen_port *port = netdev_priv(dev); | 395 | struct netxen_adapter *adapter = netdev_priv(dev); |
399 | struct netxen_adapter *adapter = port->adapter; | ||
400 | __u32 status; | 396 | __u32 status; |
401 | int val; | 397 | int val; |
402 | 398 | ||
403 | /* read which mode */ | 399 | /* read which mode */ |
404 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 400 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
405 | if (adapter->phy_read | 401 | if (adapter->phy_read |
406 | && adapter->phy_read(adapter, port->portnum, | 402 | && adapter->phy_read(adapter, |
407 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 403 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
408 | &status) != 0) | 404 | &status) != 0) |
409 | return -EIO; | 405 | return -EIO; |
@@ -422,15 +418,15 @@ static int | |||
422 | netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | 418 | netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
423 | u8 * bytes) | 419 | u8 * bytes) |
424 | { | 420 | { |
425 | struct netxen_port *port = netdev_priv(dev); | 421 | struct netxen_adapter *adapter = netdev_priv(dev); |
426 | struct netxen_adapter *adapter = port->adapter; | ||
427 | int offset; | 422 | int offset; |
428 | int ret; | 423 | int ret; |
429 | 424 | ||
430 | if (eeprom->len == 0) | 425 | if (eeprom->len == 0) |
431 | return -EINVAL; | 426 | return -EINVAL; |
432 | 427 | ||
433 | eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16); | 428 | eeprom->magic = (adapter->pdev)->vendor | |
429 | ((adapter->pdev)->device << 16); | ||
434 | offset = eeprom->offset; | 430 | offset = eeprom->offset; |
435 | 431 | ||
436 | ret = netxen_rom_fast_read_words(adapter, offset, bytes, | 432 | ret = netxen_rom_fast_read_words(adapter, offset, bytes, |
@@ -445,8 +441,7 @@ static int | |||
445 | netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | 441 | netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
446 | u8 * bytes) | 442 | u8 * bytes) |
447 | { | 443 | { |
448 | struct netxen_port *port = netdev_priv(dev); | 444 | struct netxen_adapter *adapter = netdev_priv(dev); |
449 | struct netxen_adapter *adapter = port->adapter; | ||
450 | int offset = eeprom->offset; | 445 | int offset = eeprom->offset; |
451 | static int flash_start; | 446 | static int flash_start; |
452 | static int ready_to_flash; | 447 | static int ready_to_flash; |
@@ -516,8 +511,7 @@ netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |||
516 | static void | 511 | static void |
517 | netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) | 512 | netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) |
518 | { | 513 | { |
519 | struct netxen_port *port = netdev_priv(dev); | 514 | struct netxen_adapter *adapter = netdev_priv(dev); |
520 | struct netxen_adapter *adapter = port->adapter; | ||
521 | int i; | 515 | int i; |
522 | 516 | ||
523 | ring->rx_pending = 0; | 517 | ring->rx_pending = 0; |
@@ -541,19 +535,45 @@ static void | |||
541 | netxen_nic_get_pauseparam(struct net_device *dev, | 535 | netxen_nic_get_pauseparam(struct net_device *dev, |
542 | struct ethtool_pauseparam *pause) | 536 | struct ethtool_pauseparam *pause) |
543 | { | 537 | { |
544 | struct netxen_port *port = netdev_priv(dev); | 538 | struct netxen_adapter *adapter = netdev_priv(dev); |
545 | struct netxen_adapter *adapter = port->adapter; | ||
546 | __u32 val; | 539 | __u32 val; |
540 | int port = physical_port[adapter->portnum]; | ||
547 | 541 | ||
548 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 542 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
543 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) | ||
544 | return; | ||
549 | /* get flow control settings */ | 545 | /* get flow control settings */ |
550 | netxen_nic_read_w0(adapter, | 546 | netxen_nic_read_w0(adapter,NETXEN_NIU_GB_MAC_CONFIG_0(port), |
551 | NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), | 547 | &val); |
552 | &val); | ||
553 | pause->rx_pause = netxen_gb_get_rx_flowctl(val); | 548 | pause->rx_pause = netxen_gb_get_rx_flowctl(val); |
554 | pause->tx_pause = netxen_gb_get_tx_flowctl(val); | 549 | netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val); |
555 | /* get autoneg settings */ | 550 | switch (port) { |
556 | pause->autoneg = port->link_autoneg; | 551 | case 0: |
552 | pause->tx_pause = !(netxen_gb_get_gb0_mask(val)); | ||
553 | break; | ||
554 | case 1: | ||
555 | pause->tx_pause = !(netxen_gb_get_gb1_mask(val)); | ||
556 | break; | ||
557 | case 2: | ||
558 | pause->tx_pause = !(netxen_gb_get_gb2_mask(val)); | ||
559 | break; | ||
560 | case 3: | ||
561 | default: | ||
562 | pause->tx_pause = !(netxen_gb_get_gb3_mask(val)); | ||
563 | break; | ||
564 | } | ||
565 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | ||
566 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) | ||
567 | return; | ||
568 | pause->rx_pause = 1; | ||
569 | netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val); | ||
570 | if (port == 0) | ||
571 | pause->tx_pause = !(netxen_xg_get_xg0_mask(val)); | ||
572 | else | ||
573 | pause->tx_pause = !(netxen_xg_get_xg1_mask(val)); | ||
574 | } else { | ||
575 | printk(KERN_ERR"%s: Unknown board type: %x\n", | ||
576 | netxen_nic_driver_name, adapter->ahw.board_type); | ||
557 | } | 577 | } |
558 | } | 578 | } |
559 | 579 | ||
@@ -561,42 +581,76 @@ static int | |||
561 | netxen_nic_set_pauseparam(struct net_device *dev, | 581 | netxen_nic_set_pauseparam(struct net_device *dev, |
562 | struct ethtool_pauseparam *pause) | 582 | struct ethtool_pauseparam *pause) |
563 | { | 583 | { |
564 | struct netxen_port *port = netdev_priv(dev); | 584 | struct netxen_adapter *adapter = netdev_priv(dev); |
565 | struct netxen_adapter *adapter = port->adapter; | ||
566 | __u32 val; | 585 | __u32 val; |
567 | unsigned int autoneg; | 586 | int port = physical_port[adapter->portnum]; |
568 | |||
569 | /* read mode */ | 587 | /* read mode */ |
570 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 588 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
589 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) | ||
590 | return -EIO; | ||
571 | /* set flow control */ | 591 | /* set flow control */ |
572 | netxen_nic_read_w0(adapter, | 592 | netxen_nic_read_w0(adapter, |
573 | NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), | 593 | NETXEN_NIU_GB_MAC_CONFIG_0(port), &val); |
574 | (u32 *) & val); | 594 | |
575 | if (pause->tx_pause) | ||
576 | netxen_gb_tx_flowctl(val); | ||
577 | else | ||
578 | netxen_gb_unset_tx_flowctl(val); | ||
579 | if (pause->rx_pause) | 595 | if (pause->rx_pause) |
580 | netxen_gb_rx_flowctl(val); | 596 | netxen_gb_rx_flowctl(val); |
581 | else | 597 | else |
582 | netxen_gb_unset_rx_flowctl(val); | 598 | netxen_gb_unset_rx_flowctl(val); |
583 | 599 | ||
584 | netxen_nic_write_w0(adapter, | 600 | netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), |
585 | NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), | 601 | val); |
586 | *&val); | ||
587 | /* set autoneg */ | 602 | /* set autoneg */ |
588 | autoneg = pause->autoneg; | 603 | netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val); |
589 | if (adapter->phy_write | 604 | switch (port) { |
590 | && adapter->phy_write(adapter, port->portnum, | 605 | case 0: |
591 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 606 | if (pause->tx_pause) |
592 | autoneg) != 0) | 607 | netxen_gb_unset_gb0_mask(val); |
608 | else | ||
609 | netxen_gb_set_gb0_mask(val); | ||
610 | break; | ||
611 | case 1: | ||
612 | if (pause->tx_pause) | ||
613 | netxen_gb_unset_gb1_mask(val); | ||
614 | else | ||
615 | netxen_gb_set_gb1_mask(val); | ||
616 | break; | ||
617 | case 2: | ||
618 | if (pause->tx_pause) | ||
619 | netxen_gb_unset_gb2_mask(val); | ||
620 | else | ||
621 | netxen_gb_set_gb2_mask(val); | ||
622 | break; | ||
623 | case 3: | ||
624 | default: | ||
625 | if (pause->tx_pause) | ||
626 | netxen_gb_unset_gb3_mask(val); | ||
627 | else | ||
628 | netxen_gb_set_gb3_mask(val); | ||
629 | break; | ||
630 | } | ||
631 | netxen_nic_write_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, val); | ||
632 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | ||
633 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) | ||
593 | return -EIO; | 634 | return -EIO; |
594 | else { | 635 | netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val); |
595 | port->link_autoneg = pause->autoneg; | 636 | if (port == 0) { |
596 | return 0; | 637 | if (pause->tx_pause) |
638 | netxen_xg_unset_xg0_mask(val); | ||
639 | else | ||
640 | netxen_xg_set_xg0_mask(val); | ||
641 | } else { | ||
642 | if (pause->tx_pause) | ||
643 | netxen_xg_unset_xg1_mask(val); | ||
644 | else | ||
645 | netxen_xg_set_xg1_mask(val); | ||
597 | } | 646 | } |
598 | } else | 647 | netxen_nic_write_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, val); |
599 | return -EOPNOTSUPP; | 648 | } else { |
649 | printk(KERN_ERR "%s: Unknown board type: %x\n", | ||
650 | netxen_nic_driver_name, | ||
651 | adapter->ahw.board_type); | ||
652 | } | ||
653 | return 0; | ||
600 | } | 654 | } |
601 | 655 | ||
602 | static int netxen_nic_reg_test(struct net_device *dev) | 656 | static int netxen_nic_reg_test(struct net_device *dev) |
@@ -627,23 +681,12 @@ static void | |||
627 | netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, | 681 | netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, |
628 | u64 * data) | 682 | u64 * data) |
629 | { | 683 | { |
630 | if (eth_test->flags == ETH_TEST_FL_OFFLINE) { /* offline tests */ | 684 | memset(data, 0, sizeof(uint64_t) * NETXEN_NIC_TEST_LEN); |
631 | /* link test */ | 685 | if ((data[0] = netxen_nic_reg_test(dev))) |
632 | if ((data[1] = (u64) netxen_nic_test_link(dev))) | 686 | eth_test->flags |= ETH_TEST_FL_FAILED; |
633 | eth_test->flags |= ETH_TEST_FL_FAILED; | 687 | /* link test */ |
634 | 688 | if ((data[1] = (u64) netxen_nic_test_link(dev))) | |
635 | /* register tests */ | 689 | eth_test->flags |= ETH_TEST_FL_FAILED; |
636 | if ((data[0] = netxen_nic_reg_test(dev))) | ||
637 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
638 | } else { /* online tests */ | ||
639 | /* register tests */ | ||
640 | if((data[0] = netxen_nic_reg_test(dev))) | ||
641 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
642 | |||
643 | /* link test */ | ||
644 | if ((data[1] = (u64) netxen_nic_test_link(dev))) | ||
645 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
646 | } | ||
647 | } | 690 | } |
648 | 691 | ||
649 | static void | 692 | static void |
@@ -675,12 +718,13 @@ static void | |||
675 | netxen_nic_get_ethtool_stats(struct net_device *dev, | 718 | netxen_nic_get_ethtool_stats(struct net_device *dev, |
676 | struct ethtool_stats *stats, u64 * data) | 719 | struct ethtool_stats *stats, u64 * data) |
677 | { | 720 | { |
678 | struct netxen_port *port = netdev_priv(dev); | 721 | struct netxen_adapter *adapter = netdev_priv(dev); |
679 | int index; | 722 | int index; |
680 | 723 | ||
681 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { | 724 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { |
682 | char *p = | 725 | char *p = |
683 | (char *)port + netxen_nic_gstrings_stats[index].stat_offset; | 726 | (char *)adapter + |
727 | netxen_nic_gstrings_stats[index].stat_offset; | ||
684 | data[index] = | 728 | data[index] = |
685 | (netxen_nic_gstrings_stats[index].sizeof_stat == | 729 | (netxen_nic_gstrings_stats[index].sizeof_stat == |
686 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; | 730 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; |
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index fe8b675f9e72..608e37b349b4 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h | |||
@@ -467,6 +467,8 @@ enum { | |||
467 | #define NETXEN_PCI_OCM1 (0x05100000UL) | 467 | #define NETXEN_PCI_OCM1 (0x05100000UL) |
468 | #define NETXEN_PCI_OCM1_MAX (0x051fffffUL) | 468 | #define NETXEN_PCI_OCM1_MAX (0x051fffffUL) |
469 | #define NETXEN_PCI_CRBSPACE (0x06000000UL) | 469 | #define NETXEN_PCI_CRBSPACE (0x06000000UL) |
470 | #define NETXEN_PCI_128MB_SIZE (0x08000000UL) | ||
471 | #define NETXEN_PCI_32MB_SIZE (0x02000000UL) | ||
470 | 472 | ||
471 | #define NETXEN_CRB_CAM NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_CAM) | 473 | #define NETXEN_CRB_CAM NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_CAM) |
472 | 474 | ||
@@ -484,6 +486,7 @@ enum { | |||
484 | /* 10 seconds before we give up */ | 486 | /* 10 seconds before we give up */ |
485 | #define NETXEN_NIU_PHY_WAITMAX 50 | 487 | #define NETXEN_NIU_PHY_WAITMAX 50 |
486 | #define NETXEN_NIU_MAX_GBE_PORTS 4 | 488 | #define NETXEN_NIU_MAX_GBE_PORTS 4 |
489 | #define NETXEN_NIU_MAX_XG_PORTS 2 | ||
487 | 490 | ||
488 | #define NETXEN_NIU_MODE (NETXEN_CRB_NIU + 0x00000) | 491 | #define NETXEN_NIU_MODE (NETXEN_CRB_NIU + 0x00000) |
489 | 492 | ||
@@ -527,6 +530,7 @@ enum { | |||
527 | #define NETXEN_NIU_XG_PAUSE_CTL (NETXEN_CRB_NIU + 0x00098) | 530 | #define NETXEN_NIU_XG_PAUSE_CTL (NETXEN_CRB_NIU + 0x00098) |
528 | #define NETXEN_NIU_XG_PAUSE_LEVEL (NETXEN_CRB_NIU + 0x000dc) | 531 | #define NETXEN_NIU_XG_PAUSE_LEVEL (NETXEN_CRB_NIU + 0x000dc) |
529 | #define NETXEN_NIU_XG_SEL (NETXEN_CRB_NIU + 0x00128) | 532 | #define NETXEN_NIU_XG_SEL (NETXEN_CRB_NIU + 0x00128) |
533 | #define NETXEN_NIU_GB_PAUSE_CTL (NETXEN_CRB_NIU + 0x0030c) | ||
530 | 534 | ||
531 | #define NETXEN_NIU_FULL_LEVEL_XG (NETXEN_CRB_NIU + 0x00450) | 535 | #define NETXEN_NIU_FULL_LEVEL_XG (NETXEN_CRB_NIU + 0x00450) |
532 | 536 | ||
@@ -649,11 +653,19 @@ enum { | |||
649 | #define PCIX_MS_WINDOW (0x10204) | 653 | #define PCIX_MS_WINDOW (0x10204) |
650 | #define PCIX_SN_WINDOW (0x10208) | 654 | #define PCIX_SN_WINDOW (0x10208) |
651 | #define PCIX_CRB_WINDOW (0x10210) | 655 | #define PCIX_CRB_WINDOW (0x10210) |
656 | #define PCIX_CRB_WINDOW_F0 (0x10210) | ||
657 | #define PCIX_CRB_WINDOW_F1 (0x10230) | ||
658 | #define PCIX_CRB_WINDOW_F2 (0x10250) | ||
659 | #define PCIX_CRB_WINDOW_F3 (0x10270) | ||
652 | 660 | ||
653 | #define PCIX_TARGET_STATUS (0x10118) | 661 | #define PCIX_TARGET_STATUS (0x10118) |
654 | #define PCIX_TARGET_MASK (0x10128) | 662 | #define PCIX_TARGET_MASK (0x10128) |
655 | 663 | ||
656 | #define PCIX_MSI_F0 (0x13000) | 664 | #define PCIX_MSI_F0 (0x13000) |
665 | #define PCIX_MSI_F1 (0x13004) | ||
666 | #define PCIX_MSI_F2 (0x13008) | ||
667 | #define PCIX_MSI_F3 (0x1300c) | ||
668 | #define PCIX_MSI_F(i) (0x13000+((i)*4)) | ||
657 | 669 | ||
658 | #define PCIX_PS_MEM_SPACE (0x90000) | 670 | #define PCIX_PS_MEM_SPACE (0x90000) |
659 | 671 | ||
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 0fba8f190762..baff17a24d63 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -33,10 +33,225 @@ | |||
33 | 33 | ||
34 | #include "netxen_nic.h" | 34 | #include "netxen_nic.h" |
35 | #include "netxen_nic_hw.h" | 35 | #include "netxen_nic_hw.h" |
36 | #define DEFINE_GLOBAL_RECV_CRB | ||
36 | #include "netxen_nic_phan_reg.h" | 37 | #include "netxen_nic_phan_reg.h" |
37 | 38 | ||
39 | |||
38 | #include <net/ip.h> | 40 | #include <net/ip.h> |
39 | 41 | ||
42 | struct netxen_recv_crb recv_crb_registers[] = { | ||
43 | /* | ||
44 | * Instance 0. | ||
45 | */ | ||
46 | { | ||
47 | /* rcv_desc_crb: */ | ||
48 | { | ||
49 | { | ||
50 | /* crb_rcv_producer_offset: */ | ||
51 | NETXEN_NIC_REG(0x100), | ||
52 | /* crb_rcv_consumer_offset: */ | ||
53 | NETXEN_NIC_REG(0x104), | ||
54 | /* crb_gloablrcv_ring: */ | ||
55 | NETXEN_NIC_REG(0x108), | ||
56 | /* crb_rcv_ring_size */ | ||
57 | NETXEN_NIC_REG(0x10c), | ||
58 | |||
59 | }, | ||
60 | /* Jumbo frames */ | ||
61 | { | ||
62 | /* crb_rcv_producer_offset: */ | ||
63 | NETXEN_NIC_REG(0x110), | ||
64 | /* crb_rcv_consumer_offset: */ | ||
65 | NETXEN_NIC_REG(0x114), | ||
66 | /* crb_gloablrcv_ring: */ | ||
67 | NETXEN_NIC_REG(0x118), | ||
68 | /* crb_rcv_ring_size */ | ||
69 | NETXEN_NIC_REG(0x11c), | ||
70 | }, | ||
71 | /* LRO */ | ||
72 | { | ||
73 | /* crb_rcv_producer_offset: */ | ||
74 | NETXEN_NIC_REG(0x120), | ||
75 | /* crb_rcv_consumer_offset: */ | ||
76 | NETXEN_NIC_REG(0x124), | ||
77 | /* crb_gloablrcv_ring: */ | ||
78 | NETXEN_NIC_REG(0x128), | ||
79 | /* crb_rcv_ring_size */ | ||
80 | NETXEN_NIC_REG(0x12c), | ||
81 | } | ||
82 | }, | ||
83 | /* crb_rcvstatus_ring: */ | ||
84 | NETXEN_NIC_REG(0x130), | ||
85 | /* crb_rcv_status_producer: */ | ||
86 | NETXEN_NIC_REG(0x134), | ||
87 | /* crb_rcv_status_consumer: */ | ||
88 | NETXEN_NIC_REG(0x138), | ||
89 | /* crb_rcvpeg_state: */ | ||
90 | NETXEN_NIC_REG(0x13c), | ||
91 | /* crb_status_ring_size */ | ||
92 | NETXEN_NIC_REG(0x140), | ||
93 | |||
94 | }, | ||
95 | /* | ||
96 | * Instance 1, | ||
97 | */ | ||
98 | { | ||
99 | /* rcv_desc_crb: */ | ||
100 | { | ||
101 | { | ||
102 | /* crb_rcv_producer_offset: */ | ||
103 | NETXEN_NIC_REG(0x144), | ||
104 | /* crb_rcv_consumer_offset: */ | ||
105 | NETXEN_NIC_REG(0x148), | ||
106 | /* crb_globalrcv_ring: */ | ||
107 | NETXEN_NIC_REG(0x14c), | ||
108 | /* crb_rcv_ring_size */ | ||
109 | NETXEN_NIC_REG(0x150), | ||
110 | |||
111 | }, | ||
112 | /* Jumbo frames */ | ||
113 | { | ||
114 | /* crb_rcv_producer_offset: */ | ||
115 | NETXEN_NIC_REG(0x154), | ||
116 | /* crb_rcv_consumer_offset: */ | ||
117 | NETXEN_NIC_REG(0x158), | ||
118 | /* crb_globalrcv_ring: */ | ||
119 | NETXEN_NIC_REG(0x15c), | ||
120 | /* crb_rcv_ring_size */ | ||
121 | NETXEN_NIC_REG(0x160), | ||
122 | }, | ||
123 | /* LRO */ | ||
124 | { | ||
125 | /* crb_rcv_producer_offset: */ | ||
126 | NETXEN_NIC_REG(0x164), | ||
127 | /* crb_rcv_consumer_offset: */ | ||
128 | NETXEN_NIC_REG(0x168), | ||
129 | /* crb_globalrcv_ring: */ | ||
130 | NETXEN_NIC_REG(0x16c), | ||
131 | /* crb_rcv_ring_size */ | ||
132 | NETXEN_NIC_REG(0x170), | ||
133 | } | ||
134 | |||
135 | }, | ||
136 | /* crb_rcvstatus_ring: */ | ||
137 | NETXEN_NIC_REG(0x174), | ||
138 | /* crb_rcv_status_producer: */ | ||
139 | NETXEN_NIC_REG(0x178), | ||
140 | /* crb_rcv_status_consumer: */ | ||
141 | NETXEN_NIC_REG(0x17c), | ||
142 | /* crb_rcvpeg_state: */ | ||
143 | NETXEN_NIC_REG(0x180), | ||
144 | /* crb_status_ring_size */ | ||
145 | NETXEN_NIC_REG(0x184), | ||
146 | }, | ||
147 | /* | ||
148 | * Instance 2, | ||
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 3, | ||
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 | }, | ||
245 | }; | ||
246 | |||
247 | u64 ctx_addr_sig_regs[][3] = { | ||
248 | {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)}, | ||
249 | {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)}, | ||
250 | {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)}, | ||
251 | {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)} | ||
252 | }; | ||
253 | |||
254 | |||
40 | /* PCI Windowing for DDR regions. */ | 255 | /* PCI Windowing for DDR regions. */ |
41 | 256 | ||
42 | #define ADDR_IN_RANGE(addr, low, high) \ | 257 | #define ADDR_IN_RANGE(addr, low, high) \ |
@@ -70,8 +285,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter); | |||
70 | 285 | ||
71 | int netxen_nic_set_mac(struct net_device *netdev, void *p) | 286 | int netxen_nic_set_mac(struct net_device *netdev, void *p) |
72 | { | 287 | { |
73 | struct netxen_port *port = netdev_priv(netdev); | 288 | struct netxen_adapter *adapter = netdev_priv(netdev); |
74 | struct netxen_adapter *adapter = port->adapter; | ||
75 | struct sockaddr *addr = p; | 289 | struct sockaddr *addr = p; |
76 | 290 | ||
77 | if (netif_running(netdev)) | 291 | if (netif_running(netdev)) |
@@ -84,7 +298,7 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p) | |||
84 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | 298 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); |
85 | 299 | ||
86 | if (adapter->macaddr_set) | 300 | if (adapter->macaddr_set) |
87 | adapter->macaddr_set(port, addr->sa_data); | 301 | adapter->macaddr_set(adapter, addr->sa_data); |
88 | 302 | ||
89 | return 0; | 303 | return 0; |
90 | } | 304 | } |
@@ -94,56 +308,19 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p) | |||
94 | */ | 308 | */ |
95 | void netxen_nic_set_multi(struct net_device *netdev) | 309 | void netxen_nic_set_multi(struct net_device *netdev) |
96 | { | 310 | { |
97 | struct netxen_port *port = netdev_priv(netdev); | 311 | struct netxen_adapter *adapter = netdev_priv(netdev); |
98 | struct netxen_adapter *adapter = port->adapter; | ||
99 | struct dev_mc_list *mc_ptr; | 312 | struct dev_mc_list *mc_ptr; |
100 | __u32 netxen_mac_addr_cntl_data = 0; | ||
101 | 313 | ||
102 | mc_ptr = netdev->mc_list; | 314 | mc_ptr = netdev->mc_list; |
103 | if (netdev->flags & IFF_PROMISC) { | 315 | if (netdev->flags & IFF_PROMISC) { |
104 | if (adapter->set_promisc) | 316 | if (adapter->set_promisc) |
105 | adapter->set_promisc(adapter, | 317 | adapter->set_promisc(adapter, |
106 | port->portnum, | ||
107 | NETXEN_NIU_PROMISC_MODE); | 318 | NETXEN_NIU_PROMISC_MODE); |
108 | } else { | 319 | } else { |
109 | if (adapter->unset_promisc && | 320 | if (adapter->unset_promisc) |
110 | adapter->ahw.boardcfg.board_type | ||
111 | != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) | ||
112 | adapter->unset_promisc(adapter, | 321 | adapter->unset_promisc(adapter, |
113 | port->portnum, | ||
114 | NETXEN_NIU_NON_PROMISC_MODE); | 322 | NETXEN_NIU_NON_PROMISC_MODE); |
115 | } | 323 | } |
116 | if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | ||
117 | netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03); | ||
118 | netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00); | ||
119 | netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x00); | ||
120 | netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x00); | ||
121 | netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x00); | ||
122 | netxen_nic_mcr_set_enable_xtnd0(netxen_mac_addr_cntl_data); | ||
123 | netxen_nic_mcr_set_enable_xtnd1(netxen_mac_addr_cntl_data); | ||
124 | netxen_nic_mcr_set_enable_xtnd2(netxen_mac_addr_cntl_data); | ||
125 | netxen_nic_mcr_set_enable_xtnd3(netxen_mac_addr_cntl_data); | ||
126 | } else { | ||
127 | netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x00); | ||
128 | netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00); | ||
129 | netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x01); | ||
130 | netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x02); | ||
131 | netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x03); | ||
132 | } | ||
133 | writel(netxen_mac_addr_cntl_data, | ||
134 | NETXEN_CRB_NORMALIZE(adapter, NETXEN_MAC_ADDR_CNTL_REG)); | ||
135 | if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | ||
136 | writel(netxen_mac_addr_cntl_data, | ||
137 | NETXEN_CRB_NORMALIZE(adapter, | ||
138 | NETXEN_MULTICAST_ADDR_HI_0)); | ||
139 | } else { | ||
140 | writel(netxen_mac_addr_cntl_data, | ||
141 | NETXEN_CRB_NORMALIZE(adapter, | ||
142 | NETXEN_MULTICAST_ADDR_HI_1)); | ||
143 | } | ||
144 | netxen_mac_addr_cntl_data = 0; | ||
145 | writel(netxen_mac_addr_cntl_data, | ||
146 | NETXEN_CRB_NORMALIZE(adapter, NETXEN_NIU_GB_DROP_WRONGADDR)); | ||
147 | } | 324 | } |
148 | 325 | ||
149 | /* | 326 | /* |
@@ -152,8 +329,7 @@ void netxen_nic_set_multi(struct net_device *netdev) | |||
152 | */ | 329 | */ |
153 | int netxen_nic_change_mtu(struct net_device *netdev, int mtu) | 330 | int netxen_nic_change_mtu(struct net_device *netdev, int mtu) |
154 | { | 331 | { |
155 | struct netxen_port *port = netdev_priv(netdev); | 332 | struct netxen_adapter *adapter = netdev_priv(netdev); |
156 | struct netxen_adapter *adapter = port->adapter; | ||
157 | int eff_mtu = mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE; | 333 | int eff_mtu = mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE; |
158 | 334 | ||
159 | if ((eff_mtu > NETXEN_MAX_MTU) || (eff_mtu < NETXEN_MIN_MTU)) { | 335 | if ((eff_mtu > NETXEN_MAX_MTU) || (eff_mtu < NETXEN_MIN_MTU)) { |
@@ -163,7 +339,7 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu) | |||
163 | } | 339 | } |
164 | 340 | ||
165 | if (adapter->set_mtu) | 341 | if (adapter->set_mtu) |
166 | adapter->set_mtu(port, mtu); | 342 | adapter->set_mtu(adapter, mtu); |
167 | netdev->mtu = mtu; | 343 | netdev->mtu = mtu; |
168 | 344 | ||
169 | return 0; | 345 | return 0; |
@@ -180,9 +356,9 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
180 | void *addr; | 356 | void *addr; |
181 | int loops = 0, err = 0; | 357 | int loops = 0, err = 0; |
182 | int ctx, ring; | 358 | int ctx, ring; |
183 | u32 card_cmdring = 0; | ||
184 | struct netxen_recv_context *recv_ctx; | 359 | struct netxen_recv_context *recv_ctx; |
185 | struct netxen_rcv_desc_ctx *rcv_desc; | 360 | struct netxen_rcv_desc_ctx *rcv_desc; |
361 | int func_id = adapter->portnum; | ||
186 | 362 | ||
187 | DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE, | 363 | DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE, |
188 | PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); | 364 | PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); |
@@ -191,11 +367,6 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
191 | DPRINTK(INFO, "cam RAM: %lx %x", NETXEN_CAM_RAM_BASE, | 367 | DPRINTK(INFO, "cam RAM: %lx %x", NETXEN_CAM_RAM_BASE, |
192 | pci_base_offset(adapter, NETXEN_CAM_RAM_BASE)); | 368 | pci_base_offset(adapter, NETXEN_CAM_RAM_BASE)); |
193 | 369 | ||
194 | /* Window 1 call */ | ||
195 | card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING)); | ||
196 | |||
197 | DPRINTK(INFO, "Command Peg sends 0x%x for cmdring base\n", | ||
198 | card_cmdring); | ||
199 | 370 | ||
200 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 371 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
201 | DPRINTK(INFO, "Command Peg ready..waiting for rcv peg\n"); | 372 | DPRINTK(INFO, "Command Peg ready..waiting for rcv peg\n"); |
@@ -229,7 +400,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
229 | (dma_addr_t *) & adapter->ctx_desc_phys_addr, | 400 | (dma_addr_t *) & adapter->ctx_desc_phys_addr, |
230 | &adapter->ctx_desc_pdev); | 401 | &adapter->ctx_desc_pdev); |
231 | 402 | ||
232 | printk("ctx_desc_phys_addr: 0x%llx\n", | 403 | printk(KERN_INFO "ctx_desc_phys_addr: 0x%llx\n", |
233 | (unsigned long long) adapter->ctx_desc_phys_addr); | 404 | (unsigned long long) adapter->ctx_desc_phys_addr); |
234 | if (addr == NULL) { | 405 | if (addr == NULL) { |
235 | DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); | 406 | DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); |
@@ -238,6 +409,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
238 | } | 409 | } |
239 | memset(addr, 0, sizeof(struct netxen_ring_ctx)); | 410 | memset(addr, 0, sizeof(struct netxen_ring_ctx)); |
240 | adapter->ctx_desc = (struct netxen_ring_ctx *)addr; | 411 | adapter->ctx_desc = (struct netxen_ring_ctx *)addr; |
412 | adapter->ctx_desc->ctx_id = cpu_to_le32(adapter->portnum); | ||
241 | adapter->ctx_desc->cmd_consumer_offset = | 413 | adapter->ctx_desc->cmd_consumer_offset = |
242 | cpu_to_le64(adapter->ctx_desc_phys_addr + | 414 | cpu_to_le64(adapter->ctx_desc_phys_addr + |
243 | sizeof(struct netxen_ring_ctx)); | 415 | sizeof(struct netxen_ring_ctx)); |
@@ -249,7 +421,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
249 | adapter->max_tx_desc_count, | 421 | adapter->max_tx_desc_count, |
250 | (dma_addr_t *) & hw->cmd_desc_phys_addr, | 422 | (dma_addr_t *) & hw->cmd_desc_phys_addr, |
251 | &adapter->ahw.cmd_desc_pdev); | 423 | &adapter->ahw.cmd_desc_pdev); |
252 | printk("cmd_desc_phys_addr: 0x%llx\n", | 424 | printk(KERN_INFO "cmd_desc_phys_addr: 0x%llx\n", |
253 | (unsigned long long) hw->cmd_desc_phys_addr); | 425 | (unsigned long long) hw->cmd_desc_phys_addr); |
254 | 426 | ||
255 | if (addr == NULL) { | 427 | if (addr == NULL) { |
@@ -308,11 +480,11 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
308 | /* Window = 1 */ | 480 | /* Window = 1 */ |
309 | 481 | ||
310 | writel(lower32(adapter->ctx_desc_phys_addr), | 482 | writel(lower32(adapter->ctx_desc_phys_addr), |
311 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO)); | 483 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO(func_id))); |
312 | writel(upper32(adapter->ctx_desc_phys_addr), | 484 | writel(upper32(adapter->ctx_desc_phys_addr), |
313 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI)); | 485 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI(func_id))); |
314 | writel(NETXEN_CTX_SIGNATURE, | 486 | writel(NETXEN_CTX_SIGNATURE | func_id, |
315 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG)); | 487 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG(func_id))); |
316 | return err; | 488 | return err; |
317 | } | 489 | } |
318 | 490 | ||
@@ -339,10 +511,6 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) | |||
339 | adapter->ahw.cmd_desc_phys_addr); | 511 | adapter->ahw.cmd_desc_phys_addr); |
340 | adapter->ahw.cmd_desc_head = NULL; | 512 | adapter->ahw.cmd_desc_head = NULL; |
341 | } | 513 | } |
342 | /* Special handling: there are 2 ports on this board */ | ||
343 | if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) { | ||
344 | adapter->ahw.max_ports = 2; | ||
345 | } | ||
346 | 514 | ||
347 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 515 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
348 | recv_ctx = &adapter->recv_ctx[ctx]; | 516 | recv_ctx = &adapter->recv_ctx[ctx]; |
@@ -385,7 +553,6 @@ void netxen_tso_check(struct netxen_adapter *adapter, | |||
385 | return; | 553 | return; |
386 | } | 554 | } |
387 | } | 555 | } |
388 | adapter->stats.xmitcsummed++; | ||
389 | desc->tcp_hdr_offset = skb_transport_offset(skb); | 556 | desc->tcp_hdr_offset = skb_transport_offset(skb); |
390 | desc->ip_hdr_offset = skb_network_offset(skb); | 557 | desc->ip_hdr_offset = skb_network_offset(skb); |
391 | } | 558 | } |
@@ -475,7 +642,30 @@ void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw) | |||
475 | 642 | ||
476 | if (adapter->curr_window == wndw) | 643 | if (adapter->curr_window == wndw) |
477 | return; | 644 | return; |
478 | 645 | switch(adapter->ahw.pci_func) { | |
646 | case 0: | ||
647 | offset = PCI_OFFSET_SECOND_RANGE(adapter, | ||
648 | NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW)); | ||
649 | break; | ||
650 | case 1: | ||
651 | offset = PCI_OFFSET_SECOND_RANGE(adapter, | ||
652 | NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW_F1)); | ||
653 | break; | ||
654 | case 2: | ||
655 | offset = PCI_OFFSET_SECOND_RANGE(adapter, | ||
656 | NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW_F2)); | ||
657 | break; | ||
658 | case 3: | ||
659 | offset = PCI_OFFSET_SECOND_RANGE(adapter, | ||
660 | NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW_F3)); | ||
661 | break; | ||
662 | default: | ||
663 | printk(KERN_INFO "Changing the window for PCI function" | ||
664 | "%d\n", adapter->ahw.pci_func); | ||
665 | offset = PCI_OFFSET_SECOND_RANGE(adapter, | ||
666 | NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW)); | ||
667 | break; | ||
668 | } | ||
479 | /* | 669 | /* |
480 | * Move the CRB window. | 670 | * Move the CRB window. |
481 | * We need to write to the "direct access" region of PCI | 671 | * We need to write to the "direct access" region of PCI |
@@ -484,9 +674,6 @@ void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw) | |||
484 | * register address is received by PCI. The direct region bypasses | 674 | * register address is received by PCI. The direct region bypasses |
485 | * the CRB bus. | 675 | * the CRB bus. |
486 | */ | 676 | */ |
487 | offset = | ||
488 | PCI_OFFSET_SECOND_RANGE(adapter, | ||
489 | NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW)); | ||
490 | 677 | ||
491 | if (wndw & 0x1) | 678 | if (wndw & 0x1) |
492 | wndw = NETXEN_WINDOW_ONE; | 679 | wndw = NETXEN_WINDOW_ONE; |
@@ -504,7 +691,10 @@ void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw) | |||
504 | count++; | 691 | count++; |
505 | } | 692 | } |
506 | 693 | ||
507 | adapter->curr_window = wndw; | 694 | if (wndw == NETXEN_WINDOW_ONE) |
695 | adapter->curr_window = 1; | ||
696 | else | ||
697 | adapter->curr_window = 0; | ||
508 | } | 698 | } |
509 | 699 | ||
510 | void netxen_load_firmware(struct netxen_adapter *adapter) | 700 | void netxen_load_firmware(struct netxen_adapter *adapter) |
@@ -749,6 +939,17 @@ netxen_nic_pci_set_window(struct netxen_adapter *adapter, | |||
749 | return addr; | 939 | return addr; |
750 | } | 940 | } |
751 | 941 | ||
942 | int | ||
943 | netxen_nic_erase_pxe(struct netxen_adapter *adapter) | ||
944 | { | ||
945 | if (netxen_rom_fast_write(adapter, PXE_START, 0) == -1) { | ||
946 | printk(KERN_ERR "%s: erase pxe failed\n", | ||
947 | netxen_nic_driver_name); | ||
948 | return -1; | ||
949 | } | ||
950 | return 0; | ||
951 | } | ||
952 | |||
752 | int netxen_nic_get_board_info(struct netxen_adapter *adapter) | 953 | int netxen_nic_get_board_info(struct netxen_adapter *adapter) |
753 | { | 954 | { |
754 | int rv = 0; | 955 | int rv = 0; |
@@ -810,43 +1011,29 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter) | |||
810 | 1011 | ||
811 | /* NIU access sections */ | 1012 | /* NIU access sections */ |
812 | 1013 | ||
813 | int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu) | 1014 | int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu) |
814 | { | 1015 | { |
815 | struct netxen_adapter *adapter = port->adapter; | ||
816 | netxen_nic_write_w0(adapter, | 1016 | netxen_nic_write_w0(adapter, |
817 | NETXEN_NIU_GB_MAX_FRAME_SIZE(port->portnum), | 1017 | NETXEN_NIU_GB_MAX_FRAME_SIZE( |
818 | new_mtu); | 1018 | physical_port[adapter->portnum]), new_mtu); |
819 | return 0; | 1019 | return 0; |
820 | } | 1020 | } |
821 | 1021 | ||
822 | int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu) | 1022 | int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu) |
823 | { | 1023 | { |
824 | struct netxen_adapter *adapter = port->adapter; | ||
825 | new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE; | 1024 | new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE; |
826 | if (port->portnum == 0) | 1025 | if (physical_port[adapter->portnum] == 0) |
827 | netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu); | 1026 | netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, |
828 | else if (port->portnum == 1) | 1027 | new_mtu); |
829 | netxen_nic_write_w0(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, new_mtu); | 1028 | else |
1029 | netxen_nic_write_w0(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, | ||
1030 | new_mtu); | ||
830 | return 0; | 1031 | return 0; |
831 | } | 1032 | } |
832 | 1033 | ||
833 | void netxen_nic_init_niu_gb(struct netxen_adapter *adapter) | 1034 | void netxen_nic_init_niu_gb(struct netxen_adapter *adapter) |
834 | { | 1035 | { |
835 | int portno; | 1036 | netxen_niu_gbe_init_port(adapter, physical_port[adapter->portnum]); |
836 | for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) | ||
837 | netxen_niu_gbe_init_port(adapter, portno); | ||
838 | } | ||
839 | |||
840 | void netxen_nic_stop_all_ports(struct netxen_adapter *adapter) | ||
841 | { | ||
842 | int port_nr; | ||
843 | struct netxen_port *port; | ||
844 | |||
845 | for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) { | ||
846 | port = adapter->port[port_nr]; | ||
847 | if (adapter->stop_port) | ||
848 | adapter->stop_port(adapter, port->portnum); | ||
849 | } | ||
850 | } | 1037 | } |
851 | 1038 | ||
852 | void | 1039 | void |
@@ -865,9 +1052,8 @@ netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off, | |||
865 | } | 1052 | } |
866 | } | 1053 | } |
867 | 1054 | ||
868 | void netxen_nic_set_link_parameters(struct netxen_port *port) | 1055 | void netxen_nic_set_link_parameters(struct netxen_adapter *adapter) |
869 | { | 1056 | { |
870 | struct netxen_adapter *adapter = port->adapter; | ||
871 | __u32 status; | 1057 | __u32 status; |
872 | __u32 autoneg; | 1058 | __u32 autoneg; |
873 | __u32 mode; | 1059 | __u32 mode; |
@@ -876,47 +1062,47 @@ void netxen_nic_set_link_parameters(struct netxen_port *port) | |||
876 | if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ | 1062 | if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ |
877 | if (adapter->phy_read | 1063 | if (adapter->phy_read |
878 | && adapter-> | 1064 | && adapter-> |
879 | phy_read(adapter, port->portnum, | 1065 | phy_read(adapter, |
880 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 1066 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
881 | &status) == 0) { | 1067 | &status) == 0) { |
882 | if (netxen_get_phy_link(status)) { | 1068 | if (netxen_get_phy_link(status)) { |
883 | switch (netxen_get_phy_speed(status)) { | 1069 | switch (netxen_get_phy_speed(status)) { |
884 | case 0: | 1070 | case 0: |
885 | port->link_speed = SPEED_10; | 1071 | adapter->link_speed = SPEED_10; |
886 | break; | 1072 | break; |
887 | case 1: | 1073 | case 1: |
888 | port->link_speed = SPEED_100; | 1074 | adapter->link_speed = SPEED_100; |
889 | break; | 1075 | break; |
890 | case 2: | 1076 | case 2: |
891 | port->link_speed = SPEED_1000; | 1077 | adapter->link_speed = SPEED_1000; |
892 | break; | 1078 | break; |
893 | default: | 1079 | default: |
894 | port->link_speed = -1; | 1080 | adapter->link_speed = -1; |
895 | break; | 1081 | break; |
896 | } | 1082 | } |
897 | switch (netxen_get_phy_duplex(status)) { | 1083 | switch (netxen_get_phy_duplex(status)) { |
898 | case 0: | 1084 | case 0: |
899 | port->link_duplex = DUPLEX_HALF; | 1085 | adapter->link_duplex = DUPLEX_HALF; |
900 | break; | 1086 | break; |
901 | case 1: | 1087 | case 1: |
902 | port->link_duplex = DUPLEX_FULL; | 1088 | adapter->link_duplex = DUPLEX_FULL; |
903 | break; | 1089 | break; |
904 | default: | 1090 | default: |
905 | port->link_duplex = -1; | 1091 | adapter->link_duplex = -1; |
906 | break; | 1092 | break; |
907 | } | 1093 | } |
908 | if (adapter->phy_read | 1094 | if (adapter->phy_read |
909 | && adapter-> | 1095 | && adapter-> |
910 | phy_read(adapter, port->portnum, | 1096 | phy_read(adapter, |
911 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 1097 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
912 | &autoneg) != 0) | 1098 | &autoneg) != 0) |
913 | port->link_autoneg = autoneg; | 1099 | adapter->link_autoneg = autoneg; |
914 | } else | 1100 | } else |
915 | goto link_down; | 1101 | goto link_down; |
916 | } else { | 1102 | } else { |
917 | link_down: | 1103 | link_down: |
918 | port->link_speed = -1; | 1104 | adapter->link_speed = -1; |
919 | port->link_duplex = -1; | 1105 | adapter->link_duplex = -1; |
920 | } | 1106 | } |
921 | } | 1107 | } |
922 | } | 1108 | } |
@@ -930,7 +1116,7 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter) | |||
930 | char brd_name[NETXEN_MAX_SHORT_NAME]; | 1116 | char brd_name[NETXEN_MAX_SHORT_NAME]; |
931 | struct netxen_new_user_info user_info; | 1117 | struct netxen_new_user_info user_info; |
932 | int i, addr = USER_START; | 1118 | int i, addr = USER_START; |
933 | u32 *ptr32; | 1119 | __le32 *ptr32; |
934 | 1120 | ||
935 | struct netxen_board_info *board_info = &(adapter->ahw.boardcfg); | 1121 | struct netxen_board_info *board_info = &(adapter->ahw.boardcfg); |
936 | if (board_info->magic != NETXEN_BDINFO_MAGIC) { | 1122 | if (board_info->magic != NETXEN_BDINFO_MAGIC) { |
@@ -956,7 +1142,6 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter) | |||
956 | netxen_nic_driver_name); | 1142 | netxen_nic_driver_name); |
957 | return; | 1143 | return; |
958 | } | 1144 | } |
959 | *ptr32 = le32_to_cpu(*ptr32); | ||
960 | ptr32++; | 1145 | ptr32++; |
961 | addr += sizeof(u32); | 1146 | addr += sizeof(u32); |
962 | } | 1147 | } |
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h index ab1112eb1b0d..245bf13c7ba2 100644 --- a/drivers/net/netxen/netxen_nic_hw.h +++ b/drivers/net/netxen/netxen_nic_hw.h | |||
@@ -6,12 +6,12 @@ | |||
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
8 | * of the License, or (at your option) any later version. | 8 | * of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, but | 10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
@@ -87,7 +87,7 @@ struct netxen_adapter; | |||
87 | *(u32 *)Y = readl((void __iomem*) addr); | 87 | *(u32 *)Y = readl((void __iomem*) addr); |
88 | 88 | ||
89 | struct netxen_port; | 89 | struct netxen_port; |
90 | void netxen_nic_set_link_parameters(struct netxen_port *port); | 90 | void netxen_nic_set_link_parameters(struct netxen_adapter *adapter); |
91 | void netxen_nic_flash_print(struct netxen_adapter *adapter); | 91 | void netxen_nic_flash_print(struct netxen_adapter *adapter); |
92 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, | 92 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, |
93 | void *data, int len); | 93 | void *data, int len); |
@@ -220,6 +220,69 @@ typedef enum { | |||
220 | _netxen_crb_get_bit(config_word, 1) | 220 | _netxen_crb_get_bit(config_word, 1) |
221 | #define netxen_get_gb_mii_mgmt_notvalid(config_word) \ | 221 | #define netxen_get_gb_mii_mgmt_notvalid(config_word) \ |
222 | _netxen_crb_get_bit(config_word, 2) | 222 | _netxen_crb_get_bit(config_word, 2) |
223 | /* | ||
224 | * NIU XG Pause Ctl Register | ||
225 | * | ||
226 | * Bit 0 : xg0_mask => 1:disable tx pause frames | ||
227 | * Bit 1 : xg0_request => 1:request single pause frame | ||
228 | * Bit 2 : xg0_on_off => 1:request is pause on, 0:off | ||
229 | * Bit 3 : xg1_mask => 1:disable tx pause frames | ||
230 | * Bit 4 : xg1_request => 1:request single pause frame | ||
231 | * Bit 5 : xg1_on_off => 1:request is pause on, 0:off | ||
232 | */ | ||
233 | |||
234 | #define netxen_xg_set_xg0_mask(config_word) \ | ||
235 | ((config_word) |= 1 << 0) | ||
236 | #define netxen_xg_set_xg1_mask(config_word) \ | ||
237 | ((config_word) |= 1 << 3) | ||
238 | |||
239 | #define netxen_xg_get_xg0_mask(config_word) \ | ||
240 | _netxen_crb_get_bit((config_word), 0) | ||
241 | #define netxen_xg_get_xg1_mask(config_word) \ | ||
242 | _netxen_crb_get_bit((config_word), 3) | ||
243 | |||
244 | #define netxen_xg_unset_xg0_mask(config_word) \ | ||
245 | ((config_word) &= ~(1 << 0)) | ||
246 | #define netxen_xg_unset_xg1_mask(config_word) \ | ||
247 | ((config_word) &= ~(1 << 3)) | ||
248 | |||
249 | /* | ||
250 | * NIU XG Pause Ctl Register | ||
251 | * | ||
252 | * Bit 0 : xg0_mask => 1:disable tx pause frames | ||
253 | * Bit 1 : xg0_request => 1:request single pause frame | ||
254 | * Bit 2 : xg0_on_off => 1:request is pause on, 0:off | ||
255 | * Bit 3 : xg1_mask => 1:disable tx pause frames | ||
256 | * Bit 4 : xg1_request => 1:request single pause frame | ||
257 | * Bit 5 : xg1_on_off => 1:request is pause on, 0:off | ||
258 | */ | ||
259 | #define netxen_gb_set_gb0_mask(config_word) \ | ||
260 | ((config_word) |= 1 << 0) | ||
261 | #define netxen_gb_set_gb1_mask(config_word) \ | ||
262 | ((config_word) |= 1 << 2) | ||
263 | #define netxen_gb_set_gb2_mask(config_word) \ | ||
264 | ((config_word) |= 1 << 4) | ||
265 | #define netxen_gb_set_gb3_mask(config_word) \ | ||
266 | ((config_word) |= 1 << 6) | ||
267 | |||
268 | #define netxen_gb_get_gb0_mask(config_word) \ | ||
269 | _netxen_crb_get_bit((config_word), 0) | ||
270 | #define netxen_gb_get_gb1_mask(config_word) \ | ||
271 | _netxen_crb_get_bit((config_word), 2) | ||
272 | #define netxen_gb_get_gb2_mask(config_word) \ | ||
273 | _netxen_crb_get_bit((config_word), 4) | ||
274 | #define netxen_gb_get_gb3_mask(config_word) \ | ||
275 | _netxen_crb_get_bit((config_word), 6) | ||
276 | |||
277 | #define netxen_gb_unset_gb0_mask(config_word) \ | ||
278 | ((config_word) &= ~(1 << 0)) | ||
279 | #define netxen_gb_unset_gb1_mask(config_word) \ | ||
280 | ((config_word) &= ~(1 << 2)) | ||
281 | #define netxen_gb_unset_gb2_mask(config_word) \ | ||
282 | ((config_word) &= ~(1 << 4)) | ||
283 | #define netxen_gb_unset_gb3_mask(config_word) \ | ||
284 | ((config_word) &= ~(1 << 6)) | ||
285 | |||
223 | 286 | ||
224 | /* | 287 | /* |
225 | * PHY-Specific MII control/status registers. | 288 | * PHY-Specific MII control/status registers. |
@@ -452,21 +515,21 @@ typedef enum { | |||
452 | ((config) |= (((val) & 0x0f) << 28)) | 515 | ((config) |= (((val) & 0x0f) << 28)) |
453 | 516 | ||
454 | /* Set promiscuous mode for a GbE interface */ | 517 | /* Set promiscuous mode for a GbE interface */ |
455 | int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port, | 518 | int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, |
456 | netxen_niu_prom_mode_t mode); | 519 | netxen_niu_prom_mode_t mode); |
457 | int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, | 520 | int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, |
458 | int port, netxen_niu_prom_mode_t mode); | 521 | netxen_niu_prom_mode_t mode); |
459 | 522 | ||
460 | /* get/set the MAC address for a given MAC */ | 523 | /* get/set the MAC address for a given MAC */ |
461 | int netxen_niu_macaddr_get(struct netxen_adapter *adapter, int port, | 524 | int netxen_niu_macaddr_get(struct netxen_adapter *adapter, |
462 | netxen_ethernet_macaddr_t * addr); | 525 | netxen_ethernet_macaddr_t * addr); |
463 | int netxen_niu_macaddr_set(struct netxen_port *port, | 526 | int netxen_niu_macaddr_set(struct netxen_adapter *adapter, |
464 | netxen_ethernet_macaddr_t addr); | 527 | netxen_ethernet_macaddr_t addr); |
465 | 528 | ||
466 | /* XG versons */ | 529 | /* XG versons */ |
467 | int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int port, | 530 | int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, |
468 | netxen_ethernet_macaddr_t * addr); | 531 | netxen_ethernet_macaddr_t * addr); |
469 | int netxen_niu_xg_macaddr_set(struct netxen_port *port, | 532 | int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter, |
470 | netxen_ethernet_macaddr_t addr); | 533 | netxen_ethernet_macaddr_t addr); |
471 | 534 | ||
472 | /* Generic enable for GbE ports. Will detect the speed of the link. */ | 535 | /* Generic enable for GbE ports. Will detect the speed of the link. */ |
@@ -475,8 +538,8 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port); | |||
475 | int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port); | 538 | int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port); |
476 | 539 | ||
477 | /* Disable a GbE interface */ | 540 | /* Disable a GbE interface */ |
478 | int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port); | 541 | int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter); |
479 | 542 | ||
480 | int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port); | 543 | int netxen_niu_disable_xg_port(struct netxen_adapter *adapter); |
481 | 544 | ||
482 | #endif /* __NETXEN_NIC_HW_H_ */ | 545 | #endif /* __NETXEN_NIC_HW_H_ */ |
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 5cd40562da7c..cf0e96adfe44 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -139,7 +139,7 @@ int netxen_init_firmware(struct netxen_adapter *adapter) | |||
139 | return err; | 139 | return err; |
140 | } | 140 | } |
141 | /* Window 1 call */ | 141 | /* Window 1 call */ |
142 | writel(MPORT_SINGLE_FUNCTION_MODE, | 142 | writel(MPORT_MULTI_FUNCTION_MODE, |
143 | NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE)); | 143 | NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE)); |
144 | writel(PHAN_INITIALIZE_ACK, | 144 | writel(PHAN_INITIALIZE_ACK, |
145 | NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); | 145 | NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); |
@@ -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; |
@@ -277,8 +276,8 @@ u32 netxen_decode_crb_addr(u32 addr) | |||
277 | return (pci_base + offset); | 276 | return (pci_base + offset); |
278 | } | 277 | } |
279 | 278 | ||
280 | static long rom_max_timeout = 10000; | 279 | static long rom_max_timeout = 100; |
281 | static long rom_lock_timeout = 1000000; | 280 | static long rom_lock_timeout = 10000; |
282 | static long rom_write_timeout = 700; | 281 | static long rom_write_timeout = 700; |
283 | 282 | ||
284 | static inline int rom_lock(struct netxen_adapter *adapter) | 283 | static inline int rom_lock(struct netxen_adapter *adapter) |
@@ -438,9 +437,9 @@ 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; |
442 | *(int *)bytes = cpu_to_le32(*(int *)bytes); | ||
444 | bytes += 4; | 443 | bytes += 4; |
445 | } | 444 | } |
446 | 445 | ||
@@ -499,7 +498,6 @@ static inline int do_rom_fast_write_words(struct netxen_adapter *adapter, | |||
499 | int data; | 498 | int data; |
500 | 499 | ||
501 | data = le32_to_cpu((*(u32*)bytes)); | 500 | data = le32_to_cpu((*(u32*)bytes)); |
502 | |||
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) |
505 | return ret; | 503 | return ret; |
@@ -953,7 +951,8 @@ void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) | |||
953 | 951 | ||
954 | if (!pegtune_val) { | 952 | if (!pegtune_val) { |
955 | val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); | 953 | val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); |
956 | while (val != PHAN_INITIALIZE_COMPLETE && loops < 200000) { | 954 | while (val != PHAN_INITIALIZE_COMPLETE && |
955 | val != PHAN_INITIALIZE_ACK && loops < 200000) { | ||
957 | udelay(100); | 956 | udelay(100); |
958 | schedule(); | 957 | schedule(); |
959 | val = | 958 | val = |
@@ -990,9 +989,7 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter) | |||
990 | 989 | ||
991 | static inline int netxen_nic_check_temp(struct netxen_adapter *adapter) | 990 | static inline int netxen_nic_check_temp(struct netxen_adapter *adapter) |
992 | { | 991 | { |
993 | int port_num; | 992 | struct net_device *netdev = adapter->netdev; |
994 | struct netxen_port *port; | ||
995 | struct net_device *netdev; | ||
996 | uint32_t temp, temp_state, temp_val; | 993 | uint32_t temp, temp_state, temp_val; |
997 | int rv = 0; | 994 | int rv = 0; |
998 | 995 | ||
@@ -1006,14 +1003,9 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter) | |||
1006 | "%s: Device temperature %d degrees C exceeds" | 1003 | "%s: Device temperature %d degrees C exceeds" |
1007 | " maximum allowed. Hardware has been shut down.\n", | 1004 | " maximum allowed. Hardware has been shut down.\n", |
1008 | netxen_nic_driver_name, temp_val); | 1005 | netxen_nic_driver_name, temp_val); |
1009 | for (port_num = 0; port_num < adapter->ahw.max_ports; | ||
1010 | port_num++) { | ||
1011 | port = adapter->port[port_num]; | ||
1012 | netdev = port->netdev; | ||
1013 | 1006 | ||
1014 | netif_carrier_off(netdev); | 1007 | netif_carrier_off(netdev); |
1015 | netif_stop_queue(netdev); | 1008 | netif_stop_queue(netdev); |
1016 | } | ||
1017 | rv = 1; | 1009 | rv = 1; |
1018 | } else if (temp_state == NX_TEMP_WARN) { | 1010 | } else if (temp_state == NX_TEMP_WARN) { |
1019 | if (adapter->temp == NX_TEMP_NORMAL) { | 1011 | if (adapter->temp == NX_TEMP_NORMAL) { |
@@ -1037,29 +1029,23 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter) | |||
1037 | 1029 | ||
1038 | void netxen_watchdog_task(struct work_struct *work) | 1030 | void netxen_watchdog_task(struct work_struct *work) |
1039 | { | 1031 | { |
1040 | int port_num; | ||
1041 | struct netxen_port *port; | ||
1042 | struct net_device *netdev; | 1032 | struct net_device *netdev; |
1043 | struct netxen_adapter *adapter = | 1033 | struct netxen_adapter *adapter = |
1044 | container_of(work, struct netxen_adapter, watchdog_task); | 1034 | container_of(work, struct netxen_adapter, watchdog_task); |
1045 | 1035 | ||
1046 | if (netxen_nic_check_temp(adapter)) | 1036 | if ((adapter->portnum == 0) && netxen_nic_check_temp(adapter)) |
1047 | return; | 1037 | return; |
1048 | 1038 | ||
1049 | for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) { | 1039 | netdev = adapter->netdev; |
1050 | port = adapter->port[port_num]; | 1040 | if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) { |
1051 | netdev = port->netdev; | 1041 | printk(KERN_INFO "%s port %d, %s carrier is now ok\n", |
1052 | 1042 | netxen_nic_driver_name, adapter->portnum, netdev->name); | |
1053 | if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) { | 1043 | netif_carrier_on(netdev); |
1054 | printk(KERN_INFO "%s port %d, %s carrier is now ok\n", | ||
1055 | netxen_nic_driver_name, port_num, netdev->name); | ||
1056 | netif_carrier_on(netdev); | ||
1057 | } | ||
1058 | |||
1059 | if (netif_queue_stopped(netdev)) | ||
1060 | netif_wake_queue(netdev); | ||
1061 | } | 1044 | } |
1062 | 1045 | ||
1046 | if (netif_queue_stopped(netdev)) | ||
1047 | netif_wake_queue(netdev); | ||
1048 | |||
1063 | if (adapter->handle_phy_intr) | 1049 | if (adapter->handle_phy_intr) |
1064 | adapter->handle_phy_intr(adapter); | 1050 | adapter->handle_phy_intr(adapter); |
1065 | mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); | 1051 | mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); |
@@ -1074,9 +1060,8 @@ void | |||
1074 | netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, | 1060 | netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, |
1075 | struct status_desc *desc) | 1061 | struct status_desc *desc) |
1076 | { | 1062 | { |
1077 | struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)]; | 1063 | struct pci_dev *pdev = adapter->pdev; |
1078 | struct pci_dev *pdev = port->pdev; | 1064 | struct net_device *netdev = adapter->netdev; |
1079 | struct net_device *netdev = port->netdev; | ||
1080 | int index = netxen_get_sts_refhandle(desc); | 1065 | int index = netxen_get_sts_refhandle(desc); |
1081 | struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); | 1066 | struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); |
1082 | struct netxen_rx_buffer *buffer; | 1067 | struct netxen_rx_buffer *buffer; |
@@ -1126,7 +1111,7 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, | |||
1126 | skb = (struct sk_buff *)buffer->skb; | 1111 | skb = (struct sk_buff *)buffer->skb; |
1127 | 1112 | ||
1128 | if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) { | 1113 | if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) { |
1129 | port->stats.csummed++; | 1114 | adapter->stats.csummed++; |
1130 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 1115 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
1131 | } | 1116 | } |
1132 | if (desc_ctx == RCV_DESC_LRO_CTXID) { | 1117 | if (desc_ctx == RCV_DESC_LRO_CTXID) { |
@@ -1146,27 +1131,27 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, | |||
1146 | */ | 1131 | */ |
1147 | switch (ret) { | 1132 | switch (ret) { |
1148 | case NET_RX_SUCCESS: | 1133 | case NET_RX_SUCCESS: |
1149 | port->stats.uphappy++; | 1134 | adapter->stats.uphappy++; |
1150 | break; | 1135 | break; |
1151 | 1136 | ||
1152 | case NET_RX_CN_LOW: | 1137 | case NET_RX_CN_LOW: |
1153 | port->stats.uplcong++; | 1138 | adapter->stats.uplcong++; |
1154 | break; | 1139 | break; |
1155 | 1140 | ||
1156 | case NET_RX_CN_MOD: | 1141 | case NET_RX_CN_MOD: |
1157 | port->stats.upmcong++; | 1142 | adapter->stats.upmcong++; |
1158 | break; | 1143 | break; |
1159 | 1144 | ||
1160 | case NET_RX_CN_HIGH: | 1145 | case NET_RX_CN_HIGH: |
1161 | port->stats.uphcong++; | 1146 | adapter->stats.uphcong++; |
1162 | break; | 1147 | break; |
1163 | 1148 | ||
1164 | case NET_RX_DROP: | 1149 | case NET_RX_DROP: |
1165 | port->stats.updropped++; | 1150 | adapter->stats.updropped++; |
1166 | break; | 1151 | break; |
1167 | 1152 | ||
1168 | default: | 1153 | default: |
1169 | port->stats.updunno++; | 1154 | adapter->stats.updunno++; |
1170 | break; | 1155 | break; |
1171 | } | 1156 | } |
1172 | 1157 | ||
@@ -1178,14 +1163,13 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, | |||
1178 | /* | 1163 | /* |
1179 | * We just consumed one buffer so post a buffer. | 1164 | * We just consumed one buffer so post a buffer. |
1180 | */ | 1165 | */ |
1181 | adapter->stats.post_called++; | ||
1182 | buffer->skb = NULL; | 1166 | buffer->skb = NULL; |
1183 | buffer->state = NETXEN_BUFFER_FREE; | 1167 | buffer->state = NETXEN_BUFFER_FREE; |
1184 | buffer->lro_current_frags = 0; | 1168 | buffer->lro_current_frags = 0; |
1185 | buffer->lro_expected_frags = 0; | 1169 | buffer->lro_expected_frags = 0; |
1186 | 1170 | ||
1187 | port->stats.no_rcv++; | 1171 | adapter->stats.no_rcv++; |
1188 | port->stats.rxbytes += length; | 1172 | adapter->stats.rxbytes += length; |
1189 | } | 1173 | } |
1190 | 1174 | ||
1191 | /* Process Receive status ring */ | 1175 | /* Process Receive status ring */ |
@@ -1226,7 +1210,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) | |||
1226 | 1210 | ||
1227 | /* update the consumer index in phantom */ | 1211 | /* update the consumer index in phantom */ |
1228 | if (count) { | 1212 | if (count) { |
1229 | adapter->stats.process_rcv++; | ||
1230 | recv_ctx->status_rx_consumer = consumer; | 1213 | recv_ctx->status_rx_consumer = consumer; |
1231 | recv_ctx->status_rx_producer = producer; | 1214 | recv_ctx->status_rx_producer = producer; |
1232 | 1215 | ||
@@ -1249,13 +1232,10 @@ int netxen_process_cmd_ring(unsigned long data) | |||
1249 | int count1 = 0; | 1232 | int count1 = 0; |
1250 | int count2 = 0; | 1233 | int count2 = 0; |
1251 | struct netxen_cmd_buffer *buffer; | 1234 | struct netxen_cmd_buffer *buffer; |
1252 | struct netxen_port *port; /* port #1 */ | ||
1253 | struct netxen_port *nport; | ||
1254 | struct pci_dev *pdev; | 1235 | struct pci_dev *pdev; |
1255 | struct netxen_skb_frag *frag; | 1236 | struct netxen_skb_frag *frag; |
1256 | u32 i; | 1237 | u32 i; |
1257 | struct sk_buff *skb = NULL; | 1238 | struct sk_buff *skb = NULL; |
1258 | int p; | ||
1259 | int done; | 1239 | int done; |
1260 | 1240 | ||
1261 | spin_lock(&adapter->tx_lock); | 1241 | spin_lock(&adapter->tx_lock); |
@@ -1276,7 +1256,6 @@ int netxen_process_cmd_ring(unsigned long data) | |||
1276 | } | 1256 | } |
1277 | 1257 | ||
1278 | adapter->proc_cmd_buf_counter++; | 1258 | adapter->proc_cmd_buf_counter++; |
1279 | adapter->stats.process_xmit++; | ||
1280 | /* | 1259 | /* |
1281 | * Not needed - does not seem to be used anywhere. | 1260 | * Not needed - does not seem to be used anywhere. |
1282 | * adapter->cmd_consumer = consumer; | 1261 | * adapter->cmd_consumer = consumer; |
@@ -1285,8 +1264,7 @@ int netxen_process_cmd_ring(unsigned long data) | |||
1285 | 1264 | ||
1286 | while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { | 1265 | while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { |
1287 | buffer = &adapter->cmd_buf_arr[last_consumer]; | 1266 | buffer = &adapter->cmd_buf_arr[last_consumer]; |
1288 | port = adapter->port[buffer->port]; | 1267 | pdev = adapter->pdev; |
1289 | pdev = port->pdev; | ||
1290 | frag = &buffer->frag_array[0]; | 1268 | frag = &buffer->frag_array[0]; |
1291 | skb = buffer->skb; | 1269 | skb = buffer->skb; |
1292 | if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) { | 1270 | if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) { |
@@ -1299,24 +1277,23 @@ int netxen_process_cmd_ring(unsigned long data) | |||
1299 | PCI_DMA_TODEVICE); | 1277 | PCI_DMA_TODEVICE); |
1300 | } | 1278 | } |
1301 | 1279 | ||
1302 | port->stats.skbfreed++; | 1280 | adapter->stats.skbfreed++; |
1303 | dev_kfree_skb_any(skb); | 1281 | dev_kfree_skb_any(skb); |
1304 | skb = NULL; | 1282 | skb = NULL; |
1305 | } else if (adapter->proc_cmd_buf_counter == 1) { | 1283 | } else if (adapter->proc_cmd_buf_counter == 1) { |
1306 | port->stats.txnullskb++; | 1284 | adapter->stats.txnullskb++; |
1307 | } | 1285 | } |
1308 | if (unlikely(netif_queue_stopped(port->netdev) | 1286 | if (unlikely(netif_queue_stopped(adapter->netdev) |
1309 | && netif_carrier_ok(port->netdev)) | 1287 | && netif_carrier_ok(adapter->netdev)) |
1310 | && ((jiffies - port->netdev->trans_start) > | 1288 | && ((jiffies - adapter->netdev->trans_start) > |
1311 | port->netdev->watchdog_timeo)) { | 1289 | adapter->netdev->watchdog_timeo)) { |
1312 | SCHEDULE_WORK(&port->tx_timeout_task); | 1290 | SCHEDULE_WORK(&adapter->tx_timeout_task); |
1313 | } | 1291 | } |
1314 | 1292 | ||
1315 | last_consumer = get_next_index(last_consumer, | 1293 | last_consumer = get_next_index(last_consumer, |
1316 | adapter->max_tx_desc_count); | 1294 | adapter->max_tx_desc_count); |
1317 | count1++; | 1295 | count1++; |
1318 | } | 1296 | } |
1319 | adapter->stats.noxmitdone += count1; | ||
1320 | 1297 | ||
1321 | count2 = 0; | 1298 | count2 = 0; |
1322 | spin_lock(&adapter->tx_lock); | 1299 | spin_lock(&adapter->tx_lock); |
@@ -1336,13 +1313,10 @@ int netxen_process_cmd_ring(unsigned long data) | |||
1336 | } | 1313 | } |
1337 | } | 1314 | } |
1338 | if (count1 || count2) { | 1315 | if (count1 || count2) { |
1339 | for (p = 0; p < adapter->ahw.max_ports; p++) { | 1316 | if (netif_queue_stopped(adapter->netdev) |
1340 | nport = adapter->port[p]; | 1317 | && (adapter->flags & NETXEN_NETDEV_STATUS)) { |
1341 | if (netif_queue_stopped(nport->netdev) | 1318 | netif_wake_queue(adapter->netdev); |
1342 | && (nport->flags & NETXEN_NETDEV_STATUS)) { | 1319 | adapter->flags &= ~NETXEN_NETDEV_STATUS; |
1343 | netif_wake_queue(nport->netdev); | ||
1344 | nport->flags &= ~NETXEN_NETDEV_STATUS; | ||
1345 | } | ||
1346 | } | 1320 | } |
1347 | } | 1321 | } |
1348 | /* | 1322 | /* |
@@ -1388,7 +1362,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1388 | netxen_ctx_msg msg = 0; | 1362 | netxen_ctx_msg msg = 0; |
1389 | dma_addr_t dma; | 1363 | dma_addr_t dma; |
1390 | 1364 | ||
1391 | adapter->stats.post_called++; | ||
1392 | rcv_desc = &recv_ctx->rcv_desc[ringid]; | 1365 | rcv_desc = &recv_ctx->rcv_desc[ringid]; |
1393 | 1366 | ||
1394 | producer = rcv_desc->producer; | 1367 | producer = rcv_desc->producer; |
@@ -1441,8 +1414,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1441 | if (count) { | 1414 | if (count) { |
1442 | rcv_desc->begin_alloc = index; | 1415 | rcv_desc->begin_alloc = index; |
1443 | rcv_desc->rcv_pending += count; | 1416 | rcv_desc->rcv_pending += count; |
1444 | adapter->stats.lastposted = count; | ||
1445 | adapter->stats.posted += count; | ||
1446 | rcv_desc->producer = producer; | 1417 | rcv_desc->producer = producer; |
1447 | if (rcv_desc->rcv_free >= 32) { | 1418 | if (rcv_desc->rcv_free >= 32) { |
1448 | rcv_desc->rcv_free = 0; | 1419 | rcv_desc->rcv_free = 0; |
@@ -1450,7 +1421,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1450 | writel((producer - 1) & | 1421 | writel((producer - 1) & |
1451 | (rcv_desc->max_rx_desc_count - 1), | 1422 | (rcv_desc->max_rx_desc_count - 1), |
1452 | NETXEN_CRB_NORMALIZE(adapter, | 1423 | NETXEN_CRB_NORMALIZE(adapter, |
1453 | recv_crb_registers[0]. | 1424 | recv_crb_registers[ |
1425 | adapter->portnum]. | ||
1454 | rcv_desc_crb[ringid]. | 1426 | rcv_desc_crb[ringid]. |
1455 | crb_rcv_producer_offset)); | 1427 | crb_rcv_producer_offset)); |
1456 | /* | 1428 | /* |
@@ -1463,7 +1435,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1463 | ((producer - | 1435 | ((producer - |
1464 | 1) & (rcv_desc-> | 1436 | 1) & (rcv_desc-> |
1465 | max_rx_desc_count - 1))); | 1437 | max_rx_desc_count - 1))); |
1466 | netxen_set_msg_ctxid(msg, 0); | 1438 | netxen_set_msg_ctxid(msg, adapter->portnum); |
1467 | netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); | 1439 | netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); |
1468 | writel(msg, | 1440 | writel(msg, |
1469 | DB_NORMALIZE(adapter, | 1441 | DB_NORMALIZE(adapter, |
@@ -1485,7 +1457,6 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx, | |||
1485 | int count = 0; | 1457 | int count = 0; |
1486 | int index = 0; | 1458 | int index = 0; |
1487 | 1459 | ||
1488 | adapter->stats.post_called++; | ||
1489 | rcv_desc = &recv_ctx->rcv_desc[ringid]; | 1460 | rcv_desc = &recv_ctx->rcv_desc[ringid]; |
1490 | 1461 | ||
1491 | producer = rcv_desc->producer; | 1462 | producer = rcv_desc->producer; |
@@ -1532,8 +1503,6 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx, | |||
1532 | if (count) { | 1503 | if (count) { |
1533 | rcv_desc->begin_alloc = index; | 1504 | rcv_desc->begin_alloc = index; |
1534 | rcv_desc->rcv_pending += count; | 1505 | rcv_desc->rcv_pending += count; |
1535 | adapter->stats.lastposted = count; | ||
1536 | adapter->stats.posted += count; | ||
1537 | rcv_desc->producer = producer; | 1506 | rcv_desc->producer = producer; |
1538 | if (rcv_desc->rcv_free >= 32) { | 1507 | if (rcv_desc->rcv_free >= 32) { |
1539 | rcv_desc->rcv_free = 0; | 1508 | rcv_desc->rcv_free = 0; |
@@ -1541,7 +1510,8 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx, | |||
1541 | writel((producer - 1) & | 1510 | writel((producer - 1) & |
1542 | (rcv_desc->max_rx_desc_count - 1), | 1511 | (rcv_desc->max_rx_desc_count - 1), |
1543 | NETXEN_CRB_NORMALIZE(adapter, | 1512 | NETXEN_CRB_NORMALIZE(adapter, |
1544 | recv_crb_registers[0]. | 1513 | recv_crb_registers[ |
1514 | adapter->portnum]. | ||
1545 | rcv_desc_crb[ringid]. | 1515 | rcv_desc_crb[ringid]. |
1546 | crb_rcv_producer_offset)); | 1516 | crb_rcv_producer_offset)); |
1547 | wmb(); | 1517 | wmb(); |
@@ -1562,13 +1532,7 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter) | |||
1562 | 1532 | ||
1563 | void netxen_nic_clear_stats(struct netxen_adapter *adapter) | 1533 | void netxen_nic_clear_stats(struct netxen_adapter *adapter) |
1564 | { | 1534 | { |
1565 | struct netxen_port *port; | ||
1566 | int port_num; | ||
1567 | |||
1568 | memset(&adapter->stats, 0, sizeof(adapter->stats)); | 1535 | memset(&adapter->stats, 0, sizeof(adapter->stats)); |
1569 | for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) { | 1536 | return; |
1570 | port = adapter->port[port_num]; | ||
1571 | memset(&port->stats, 0, sizeof(port->stats)); | ||
1572 | } | ||
1573 | } | 1537 | } |
1574 | 1538 | ||
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c index be366e48007c..b213b062eb56 100644 --- a/drivers/net/netxen/netxen_nic_isr.c +++ b/drivers/net/netxen/netxen_nic_isr.c | |||
@@ -6,12 +6,12 @@ | |||
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
8 | * of the License, or (at your option) any later version. | 8 | * of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, but | 10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
@@ -40,35 +40,35 @@ | |||
40 | */ | 40 | */ |
41 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) | 41 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) |
42 | { | 42 | { |
43 | struct netxen_port *port = netdev_priv(netdev); | 43 | struct netxen_adapter *adapter = netdev_priv(netdev); |
44 | struct net_device_stats *stats = &port->net_stats; | 44 | struct net_device_stats *stats = &adapter->net_stats; |
45 | 45 | ||
46 | memset(stats, 0, sizeof(*stats)); | 46 | memset(stats, 0, sizeof(*stats)); |
47 | 47 | ||
48 | /* total packets received */ | 48 | /* total packets received */ |
49 | stats->rx_packets = port->stats.no_rcv; | 49 | stats->rx_packets = adapter->stats.no_rcv; |
50 | /* total packets transmitted */ | 50 | /* total packets transmitted */ |
51 | stats->tx_packets = port->stats.xmitedframes + port->stats.xmitfinished; | 51 | stats->tx_packets = adapter->stats.xmitedframes + |
52 | adapter->stats.xmitfinished; | ||
52 | /* total bytes received */ | 53 | /* total bytes received */ |
53 | stats->rx_bytes = port->stats.rxbytes; | 54 | stats->rx_bytes = adapter->stats.rxbytes; |
54 | /* total bytes transmitted */ | 55 | /* total bytes transmitted */ |
55 | stats->tx_bytes = port->stats.txbytes; | 56 | stats->tx_bytes = adapter->stats.txbytes; |
56 | /* bad packets received */ | 57 | /* bad packets received */ |
57 | stats->rx_errors = port->stats.rcvdbadskb; | 58 | stats->rx_errors = adapter->stats.rcvdbadskb; |
58 | /* packet transmit problems */ | 59 | /* packet transmit problems */ |
59 | stats->tx_errors = port->stats.nocmddescriptor; | 60 | stats->tx_errors = adapter->stats.nocmddescriptor; |
60 | /* no space in linux buffers */ | 61 | /* no space in linux buffers */ |
61 | stats->rx_dropped = port->stats.updropped; | 62 | stats->rx_dropped = adapter->stats.updropped; |
62 | /* no space available in linux */ | 63 | /* no space available in linux */ |
63 | stats->tx_dropped = port->stats.txdropped; | 64 | stats->tx_dropped = adapter->stats.txdropped; |
64 | 65 | ||
65 | return stats; | 66 | return stats; |
66 | } | 67 | } |
67 | 68 | ||
68 | void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno, | 69 | void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 link) |
69 | u32 link) | ||
70 | { | 70 | { |
71 | struct net_device *netdev = (adapter->port[portno])->netdev; | 71 | struct net_device *netdev = adapter->netdev; |
72 | 72 | ||
73 | if (link) | 73 | if (link) |
74 | netif_carrier_on(netdev); | 74 | netif_carrier_on(netdev); |
@@ -76,15 +76,13 @@ void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno, | |||
76 | netif_carrier_off(netdev); | 76 | netif_carrier_off(netdev); |
77 | } | 77 | } |
78 | 78 | ||
79 | void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, | 79 | void netxen_handle_port_int(struct netxen_adapter *adapter, u32 enable) |
80 | u32 enable) | ||
81 | { | 80 | { |
82 | __u32 int_src; | 81 | __u32 int_src; |
83 | struct netxen_port *port; | ||
84 | 82 | ||
85 | /* This should clear the interrupt source */ | 83 | /* This should clear the interrupt source */ |
86 | if (adapter->phy_read) | 84 | if (adapter->phy_read) |
87 | adapter->phy_read(adapter, portno, | 85 | adapter->phy_read(adapter, |
88 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, | 86 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, |
89 | &int_src); | 87 | &int_src); |
90 | if (int_src == 0) { | 88 | if (int_src == 0) { |
@@ -92,9 +90,7 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, | |||
92 | return; | 90 | return; |
93 | } | 91 | } |
94 | if (adapter->disable_phy_interrupts) | 92 | if (adapter->disable_phy_interrupts) |
95 | adapter->disable_phy_interrupts(adapter, portno); | 93 | adapter->disable_phy_interrupts(adapter); |
96 | |||
97 | port = adapter->port[portno]; | ||
98 | 94 | ||
99 | if (netxen_get_phy_int_jabber(int_src)) | 95 | if (netxen_get_phy_int_jabber(int_src)) |
100 | DPRINTK(INFO, "Jabber interrupt \n"); | 96 | DPRINTK(INFO, "Jabber interrupt \n"); |
@@ -115,64 +111,57 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, | |||
115 | DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n"); | 111 | DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n"); |
116 | 112 | ||
117 | if (adapter->phy_read | 113 | if (adapter->phy_read |
118 | && adapter->phy_read(adapter, portno, | 114 | && adapter->phy_read(adapter, |
119 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 115 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
120 | &status) == 0) { | 116 | &status) == 0) { |
121 | if (netxen_get_phy_int_link_status_changed(int_src)) { | 117 | if (netxen_get_phy_int_link_status_changed(int_src)) { |
122 | if (netxen_get_phy_link(status)) { | 118 | if (netxen_get_phy_link(status)) { |
123 | netxen_niu_gbe_init_port(adapter, | 119 | printk(KERN_INFO "%s: %s Link UP\n", |
124 | portno); | ||
125 | printk("%s: %s Link UP\n", | ||
126 | netxen_nic_driver_name, | 120 | netxen_nic_driver_name, |
127 | port->netdev->name); | 121 | adapter->netdev->name); |
128 | 122 | ||
129 | } else { | 123 | } else { |
130 | printk("%s: %s Link DOWN\n", | 124 | printk(KERN_INFO "%s: %s Link DOWN\n", |
131 | netxen_nic_driver_name, | 125 | netxen_nic_driver_name, |
132 | port->netdev->name); | 126 | adapter->netdev->name); |
133 | } | 127 | } |
134 | netxen_indicate_link_status(adapter, portno, | 128 | netxen_indicate_link_status(adapter, |
135 | netxen_get_phy_link | 129 | netxen_get_phy_link |
136 | (status)); | 130 | (status)); |
137 | } | 131 | } |
138 | } | 132 | } |
139 | } | 133 | } |
140 | if (adapter->enable_phy_interrupts) | 134 | if (adapter->enable_phy_interrupts) |
141 | adapter->enable_phy_interrupts(adapter, portno); | 135 | adapter->enable_phy_interrupts(adapter); |
142 | } | 136 | } |
143 | 137 | ||
144 | void netxen_nic_isr_other(struct netxen_adapter *adapter) | 138 | void netxen_nic_isr_other(struct netxen_adapter *adapter) |
145 | { | 139 | { |
146 | u32 portno; | 140 | int portno = adapter->portnum; |
147 | u32 val, linkup, qg_linksup; | 141 | u32 val, linkup, qg_linksup; |
148 | 142 | ||
149 | /* verify the offset */ | 143 | /* verify the offset */ |
150 | val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); | 144 | val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); |
145 | val = val >> physical_port[adapter->portnum]; | ||
151 | if (val == adapter->ahw.qg_linksup) | 146 | if (val == adapter->ahw.qg_linksup) |
152 | return; | 147 | return; |
153 | 148 | ||
154 | qg_linksup = adapter->ahw.qg_linksup; | 149 | qg_linksup = adapter->ahw.qg_linksup; |
155 | adapter->ahw.qg_linksup = val; | 150 | adapter->ahw.qg_linksup = val; |
156 | DPRINTK(INFO, "link update 0x%08x\n", val); | 151 | DPRINTK(INFO, "link update 0x%08x\n", val); |
157 | for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) { | ||
158 | linkup = val & 1; | ||
159 | if (linkup != (qg_linksup & 1)) { | ||
160 | printk(KERN_INFO "%s: %s PORT %d link %s\n", | ||
161 | adapter->port[portno]->netdev->name, | ||
162 | netxen_nic_driver_name, portno, | ||
163 | ((linkup == 0) ? "down" : "up")); | ||
164 | netxen_indicate_link_status(adapter, portno, linkup); | ||
165 | if (linkup) | ||
166 | netxen_nic_set_link_parameters(adapter-> | ||
167 | port[portno]); | ||
168 | 152 | ||
169 | } | 153 | linkup = val & 1; |
170 | val = val >> 1; | ||
171 | qg_linksup = qg_linksup >> 1; | ||
172 | } | ||
173 | 154 | ||
174 | adapter->stats.otherints++; | 155 | if (linkup != (qg_linksup & 1)) { |
156 | printk(KERN_INFO "%s: %s PORT %d link %s\n", | ||
157 | adapter->netdev->name, | ||
158 | netxen_nic_driver_name, portno, | ||
159 | ((linkup == 0) ? "down" : "up")); | ||
160 | netxen_indicate_link_status(adapter, linkup); | ||
161 | if (linkup) | ||
162 | netxen_nic_set_link_parameters(adapter); | ||
175 | 163 | ||
164 | } | ||
176 | } | 165 | } |
177 | 166 | ||
178 | void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter) | 167 | void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter) |
@@ -182,26 +171,28 @@ void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter) | |||
182 | 171 | ||
183 | void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter) | 172 | void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter) |
184 | { | 173 | { |
185 | struct net_device *netdev = adapter->port[0]->netdev; | 174 | struct net_device *netdev = adapter->netdev; |
186 | u32 val; | 175 | u32 val, val1; |
187 | 176 | ||
188 | /* WINDOW = 1 */ | 177 | /* WINDOW = 1 */ |
189 | val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); | 178 | val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); |
179 | val >>= (physical_port[adapter->portnum] * 8); | ||
180 | val1 = val & 0xff; | ||
190 | 181 | ||
191 | if (adapter->ahw.xg_linkup == 1 && val != XG_LINK_UP) { | 182 | if (adapter->ahw.xg_linkup == 1 && val1 != XG_LINK_UP) { |
192 | printk(KERN_INFO "%s: %s NIC Link is down\n", | 183 | printk(KERN_INFO "%s: %s NIC Link is down\n", |
193 | netxen_nic_driver_name, netdev->name); | 184 | netxen_nic_driver_name, netdev->name); |
194 | adapter->ahw.xg_linkup = 0; | 185 | adapter->ahw.xg_linkup = 0; |
195 | /* read twice to clear sticky bits */ | 186 | /* read twice to clear sticky bits */ |
196 | /* WINDOW = 0 */ | 187 | /* WINDOW = 0 */ |
197 | netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val); | 188 | netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val1); |
198 | netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val); | 189 | netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val1); |
199 | 190 | ||
200 | if ((val & 0xffb) != 0xffb) { | 191 | if ((val & 0xffb) != 0xffb) { |
201 | printk(KERN_INFO "%s ISR: Sync/Align BAD: 0x%08x\n", | 192 | printk(KERN_INFO "%s ISR: Sync/Align BAD: 0x%08x\n", |
202 | netxen_nic_driver_name, val); | 193 | netxen_nic_driver_name, val1); |
203 | } | 194 | } |
204 | } else if (adapter->ahw.xg_linkup == 0 && val == XG_LINK_UP) { | 195 | } else if (adapter->ahw.xg_linkup == 0 && val1 == XG_LINK_UP) { |
205 | printk(KERN_INFO "%s: %s NIC Link is up\n", | 196 | printk(KERN_INFO "%s: %s NIC Link is up\n", |
206 | netxen_nic_driver_name, netdev->name); | 197 | netxen_nic_driver_name, netdev->name); |
207 | adapter->ahw.xg_linkup = 1; | 198 | adapter->ahw.xg_linkup = 1; |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index ab25c225a07e..4e32bb678ea9 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include "netxen_nic_hw.h" | 36 | #include "netxen_nic_hw.h" |
37 | 37 | ||
38 | #include "netxen_nic.h" | 38 | #include "netxen_nic.h" |
39 | #define DEFINE_GLOBAL_RECV_CRB | ||
40 | #include "netxen_nic_phan_reg.h" | 39 | #include "netxen_nic_phan_reg.h" |
41 | 40 | ||
42 | #include <linux/dma-mapping.h> | 41 | #include <linux/dma-mapping.h> |
@@ -77,6 +76,8 @@ static void netxen_nic_poll_controller(struct net_device *netdev); | |||
77 | #endif | 76 | #endif |
78 | static irqreturn_t netxen_intr(int irq, void *data); | 77 | static irqreturn_t netxen_intr(int irq, void *data); |
79 | 78 | ||
79 | int physical_port[] = {0, 1, 2, 3}; | ||
80 | |||
80 | /* PCI Device ID Table */ | 81 | /* PCI Device ID Table */ |
81 | static struct pci_device_id netxen_pci_tbl[] __devinitdata = { | 82 | static struct pci_device_id netxen_pci_tbl[] __devinitdata = { |
82 | {PCI_DEVICE(0x4040, 0x0001)}, | 83 | {PCI_DEVICE(0x4040, 0x0001)}, |
@@ -94,6 +95,67 @@ MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); | |||
94 | struct workqueue_struct *netxen_workq; | 95 | struct workqueue_struct *netxen_workq; |
95 | static void netxen_watchdog(unsigned long); | 96 | static void netxen_watchdog(unsigned long); |
96 | 97 | ||
98 | static inline void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, | ||
99 | uint32_t crb_producer) | ||
100 | { | ||
101 | switch (adapter->portnum) { | ||
102 | case 0: | ||
103 | writel(crb_producer, NETXEN_CRB_NORMALIZE | ||
104 | (adapter, CRB_CMD_PRODUCER_OFFSET)); | ||
105 | return; | ||
106 | case 1: | ||
107 | writel(crb_producer, NETXEN_CRB_NORMALIZE | ||
108 | (adapter, CRB_CMD_PRODUCER_OFFSET_1)); | ||
109 | return; | ||
110 | case 2: | ||
111 | writel(crb_producer, NETXEN_CRB_NORMALIZE | ||
112 | (adapter, CRB_CMD_PRODUCER_OFFSET_2)); | ||
113 | return; | ||
114 | case 3: | ||
115 | writel(crb_producer, NETXEN_CRB_NORMALIZE | ||
116 | (adapter, CRB_CMD_PRODUCER_OFFSET_3)); | ||
117 | return; | ||
118 | default: | ||
119 | printk(KERN_WARNING "We tried to update " | ||
120 | "CRB_CMD_PRODUCER_OFFSET for invalid " | ||
121 | "PCI function id %d\n", | ||
122 | adapter->portnum); | ||
123 | return; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | static inline void netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter, | ||
128 | u32 crb_consumer) | ||
129 | { | ||
130 | switch (adapter->portnum) { | ||
131 | case 0: | ||
132 | writel(crb_consumer, NETXEN_CRB_NORMALIZE | ||
133 | (adapter, CRB_CMD_CONSUMER_OFFSET)); | ||
134 | return; | ||
135 | case 1: | ||
136 | writel(crb_consumer, NETXEN_CRB_NORMALIZE | ||
137 | (adapter, CRB_CMD_CONSUMER_OFFSET_1)); | ||
138 | return; | ||
139 | case 2: | ||
140 | writel(crb_consumer, NETXEN_CRB_NORMALIZE | ||
141 | (adapter, CRB_CMD_CONSUMER_OFFSET_2)); | ||
142 | return; | ||
143 | case 3: | ||
144 | writel(crb_consumer, NETXEN_CRB_NORMALIZE | ||
145 | (adapter, CRB_CMD_CONSUMER_OFFSET_3)); | ||
146 | return; | ||
147 | default: | ||
148 | printk(KERN_WARNING "We tried to update " | ||
149 | "CRB_CMD_PRODUCER_OFFSET for invalid " | ||
150 | "PCI function id %d\n", | ||
151 | adapter->portnum); | ||
152 | return; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | #define ADAPTER_LIST_SIZE 12 | ||
157 | int netxen_cards_found; | ||
158 | |||
97 | /* | 159 | /* |
98 | * netxen_nic_probe() | 160 | * netxen_nic_probe() |
99 | * | 161 | * |
@@ -111,26 +173,30 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
111 | { | 173 | { |
112 | struct net_device *netdev = NULL; | 174 | struct net_device *netdev = NULL; |
113 | struct netxen_adapter *adapter = NULL; | 175 | struct netxen_adapter *adapter = NULL; |
114 | struct netxen_port *port = NULL; | ||
115 | void __iomem *mem_ptr0 = NULL; | 176 | void __iomem *mem_ptr0 = NULL; |
116 | void __iomem *mem_ptr1 = NULL; | 177 | void __iomem *mem_ptr1 = NULL; |
117 | void __iomem *mem_ptr2 = NULL; | 178 | void __iomem *mem_ptr2 = NULL; |
179 | unsigned long first_page_group_end; | ||
180 | unsigned long first_page_group_start; | ||
181 | |||
118 | 182 | ||
119 | u8 __iomem *db_ptr = NULL; | 183 | u8 __iomem *db_ptr = NULL; |
120 | unsigned long mem_base, mem_len, db_base, db_len; | 184 | unsigned long mem_base, mem_len, db_base, db_len; |
121 | int pci_using_dac, i, err; | 185 | int pci_using_dac, i = 0, err; |
122 | int ring; | 186 | int ring; |
123 | struct netxen_recv_context *recv_ctx = NULL; | 187 | struct netxen_recv_context *recv_ctx = NULL; |
124 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; | 188 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; |
125 | struct netxen_cmd_buffer *cmd_buf_arr = NULL; | 189 | struct netxen_cmd_buffer *cmd_buf_arr = NULL; |
126 | u64 mac_addr[FLASH_NUM_PORTS + 1]; | 190 | u64 mac_addr[FLASH_NUM_PORTS + 1]; |
127 | int valid_mac = 0; | 191 | int valid_mac = 0; |
192 | u32 val; | ||
193 | int pci_func_id = PCI_FUNC(pdev->devfn); | ||
128 | 194 | ||
129 | printk(KERN_INFO "%s \n", netxen_nic_driver_string); | 195 | printk(KERN_INFO "%s \n", netxen_nic_driver_string); |
130 | /* In current scheme, we use only PCI function 0 */ | 196 | |
131 | if (PCI_FUNC(pdev->devfn) != 0) { | 197 | if (pdev->class != 0x020000) { |
132 | DPRINTK(ERR, "NetXen function %d will not be enabled.\n", | 198 | printk(KERN_ERR"NetXen function %d, class %x will not" |
133 | PCI_FUNC(pdev->devfn)); | 199 | "be enabled.\n",pci_func_id, pdev->class); |
134 | return -ENODEV; | 200 | return -ENODEV; |
135 | } | 201 | } |
136 | if ((err = pci_enable_device(pdev))) | 202 | if ((err = pci_enable_device(pdev))) |
@@ -157,18 +223,52 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
157 | pci_using_dac = 0; | 223 | pci_using_dac = 0; |
158 | } | 224 | } |
159 | 225 | ||
226 | |||
227 | netdev = alloc_etherdev(sizeof(struct netxen_adapter)); | ||
228 | if(!netdev) { | ||
229 | printk(KERN_ERR"%s: Failed to allocate memory for the " | ||
230 | "device block.Check system memory resource" | ||
231 | " usage.\n", netxen_nic_driver_name); | ||
232 | goto err_out_free_res; | ||
233 | } | ||
234 | |||
235 | SET_MODULE_OWNER(netdev); | ||
236 | SET_NETDEV_DEV(netdev, &pdev->dev); | ||
237 | |||
238 | adapter = netdev->priv; | ||
239 | memset(adapter, 0 , sizeof(struct netxen_adapter)); | ||
240 | |||
241 | adapter->ahw.pdev = pdev; | ||
242 | adapter->ahw.pci_func = pci_func_id; | ||
243 | spin_lock_init(&adapter->tx_lock); | ||
244 | spin_lock_init(&adapter->lock); | ||
245 | |||
160 | /* remap phys address */ | 246 | /* remap phys address */ |
161 | mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ | 247 | mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ |
162 | mem_len = pci_resource_len(pdev, 0); | 248 | mem_len = pci_resource_len(pdev, 0); |
163 | 249 | ||
164 | /* 128 Meg of memory */ | 250 | /* 128 Meg of memory */ |
165 | mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); | 251 | if (mem_len == NETXEN_PCI_128MB_SIZE) { |
166 | mem_ptr1 = | 252 | mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); |
167 | ioremap(mem_base + SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_SIZE); | 253 | mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, |
168 | mem_ptr2 = | 254 | SECOND_PAGE_GROUP_SIZE); |
169 | ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); | 255 | mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, |
256 | THIRD_PAGE_GROUP_SIZE); | ||
257 | first_page_group_start = FIRST_PAGE_GROUP_START; | ||
258 | first_page_group_end = FIRST_PAGE_GROUP_END; | ||
259 | } else if (mem_len == NETXEN_PCI_32MB_SIZE) { | ||
260 | mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); | ||
261 | mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - | ||
262 | SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); | ||
263 | first_page_group_start = 0; | ||
264 | first_page_group_end = 0; | ||
265 | } else { | ||
266 | err = -EIO; | ||
267 | goto err_out_free_netdev; | ||
268 | } | ||
170 | 269 | ||
171 | if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) { | 270 | if (((mem_ptr0 == 0UL) && (mem_len == NETXEN_PCI_128MB_SIZE)) || |
271 | (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) { | ||
172 | DPRINTK(ERR, | 272 | DPRINTK(ERR, |
173 | "Cannot remap adapter memory aborting.:" | 273 | "Cannot remap adapter memory aborting.:" |
174 | "0 -> %p, 1 -> %p, 2 -> %p\n", | 274 | "0 -> %p, 1 -> %p, 2 -> %p\n", |
@@ -198,30 +298,87 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
198 | } | 298 | } |
199 | DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); | 299 | DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); |
200 | 300 | ||
201 | /* | 301 | adapter->ahw.pci_base0 = mem_ptr0; |
202 | * Allocate a adapter structure which will manage all the initialization | 302 | adapter->ahw.first_page_group_start = first_page_group_start; |
203 | * as well as the common resources for all ports... | 303 | adapter->ahw.first_page_group_end = first_page_group_end; |
204 | * all the ports will have pointer to this adapter as well as Adapter | 304 | adapter->ahw.pci_base1 = mem_ptr1; |
205 | * will have pointers of all the ports structures. | 305 | adapter->ahw.pci_base2 = mem_ptr2; |
206 | */ | 306 | adapter->ahw.db_base = db_ptr; |
307 | adapter->ahw.db_len = db_len; | ||
207 | 308 | ||
208 | /* One adapter structure for all 4 ports.... */ | 309 | adapter->netdev = netdev; |
209 | adapter = kzalloc(sizeof(struct netxen_adapter), GFP_KERNEL); | 310 | adapter->pdev = pdev; |
210 | if (adapter == NULL) { | 311 | adapter->portnum = pci_func_id; |
211 | printk(KERN_ERR "%s: Could not allocate adapter memory:%d\n", | 312 | |
212 | netxen_nic_driver_name, | 313 | netdev->open = netxen_nic_open; |
213 | (int)sizeof(struct netxen_adapter)); | 314 | netdev->stop = netxen_nic_close; |
214 | err = -ENOMEM; | 315 | netdev->hard_start_xmit = netxen_nic_xmit_frame; |
215 | goto err_out_dbunmap; | 316 | netdev->get_stats = netxen_nic_get_stats; |
216 | } | 317 | netdev->set_multicast_list = netxen_nic_set_multi; |
318 | netdev->set_mac_address = netxen_nic_set_mac; | ||
319 | netdev->change_mtu = netxen_nic_change_mtu; | ||
320 | netdev->tx_timeout = netxen_tx_timeout; | ||
321 | netdev->watchdog_timeo = HZ; | ||
322 | |||
323 | netxen_nic_change_mtu(netdev, netdev->mtu); | ||
324 | |||
325 | SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); | ||
326 | netdev->poll = netxen_nic_poll; | ||
327 | netdev->weight = NETXEN_NETDEV_WEIGHT; | ||
328 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
329 | netdev->poll_controller = netxen_nic_poll_controller; | ||
330 | #endif | ||
331 | /* ScatterGather support */ | ||
332 | netdev->features = NETIF_F_SG; | ||
333 | netdev->features |= NETIF_F_IP_CSUM; | ||
334 | netdev->features |= NETIF_F_TSO; | ||
335 | |||
336 | if (pci_using_dac) | ||
337 | netdev->features |= NETIF_F_HIGHDMA; | ||
338 | |||
339 | if (pci_enable_msi(pdev)) { | ||
340 | adapter->flags &= ~NETXEN_NIC_MSI_ENABLED; | ||
341 | printk(KERN_WARNING "%s: unable to allocate MSI interrupt" | ||
342 | " error\n", netxen_nic_driver_name); | ||
343 | } else | ||
344 | adapter->flags |= NETXEN_NIC_MSI_ENABLED; | ||
345 | |||
346 | netdev->irq = pdev->irq; | ||
347 | INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task); | ||
217 | 348 | ||
218 | adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS; | 349 | /* |
219 | adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS; | 350 | * Set the CRB window to invalid. If any register in window 0 is |
351 | * accessed it should set the window to 0 and then reset it to 1. | ||
352 | */ | ||
353 | adapter->curr_window = 255; | ||
354 | |||
355 | /* initialize the adapter */ | ||
356 | netxen_initialize_adapter_hw(adapter); | ||
357 | |||
358 | #ifdef CONFIG_PPC | ||
359 | if ((adapter->ahw.boardcfg.board_type == | ||
360 | NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) && | ||
361 | (pci_func_id == 2)) | ||
362 | goto err_out_free_adapter; | ||
363 | #endif /* CONFIG_PPC */ | ||
364 | |||
365 | /* | ||
366 | * Adapter in our case is quad port so initialize it before | ||
367 | * initializing the ports | ||
368 | */ | ||
369 | |||
370 | netxen_initialize_adapter_ops(adapter); | ||
371 | |||
372 | adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS_HOST; | ||
373 | if ((adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB35_4G) || | ||
374 | (adapter->ahw.boardcfg.board_type == | ||
375 | NETXEN_BRDTYPE_P2_SB31_2G)) | ||
376 | adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; | ||
377 | else | ||
378 | adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS; | ||
220 | adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; | 379 | adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; |
221 | adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS; | 380 | adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS; |
222 | 381 | ||
223 | pci_set_drvdata(pdev, adapter); | ||
224 | |||
225 | cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); | 382 | cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); |
226 | if (cmd_buf_arr == NULL) { | 383 | if (cmd_buf_arr == NULL) { |
227 | printk(KERN_ERR | 384 | printk(KERN_ERR |
@@ -231,6 +388,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
231 | goto err_out_free_adapter; | 388 | goto err_out_free_adapter; |
232 | } | 389 | } |
233 | memset(cmd_buf_arr, 0, TX_RINGSIZE); | 390 | memset(cmd_buf_arr, 0, TX_RINGSIZE); |
391 | adapter->cmd_buf_arr = cmd_buf_arr; | ||
234 | 392 | ||
235 | for (i = 0; i < MAX_RCV_CTX; ++i) { | 393 | for (i = 0; i < MAX_RCV_CTX; ++i) { |
236 | recv_ctx = &adapter->recv_ctx[i]; | 394 | recv_ctx = &adapter->recv_ctx[i]; |
@@ -278,33 +436,20 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
278 | 436 | ||
279 | } | 437 | } |
280 | 438 | ||
281 | adapter->cmd_buf_arr = cmd_buf_arr; | ||
282 | adapter->ahw.pci_base0 = mem_ptr0; | ||
283 | adapter->ahw.pci_base1 = mem_ptr1; | ||
284 | adapter->ahw.pci_base2 = mem_ptr2; | ||
285 | adapter->ahw.db_base = db_ptr; | ||
286 | adapter->ahw.db_len = db_len; | ||
287 | spin_lock_init(&adapter->tx_lock); | ||
288 | spin_lock_init(&adapter->lock); | ||
289 | netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */ | 439 | netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */ |
290 | #ifdef CONFIG_IA64 | ||
291 | netxen_pinit_from_rom(adapter, 0); | ||
292 | udelay(500); | ||
293 | netxen_load_firmware(adapter); | ||
294 | #endif | ||
295 | 440 | ||
296 | /* | 441 | /* Mezz cards have PCI function 0,2,3 enabled */ |
297 | * Set the CRB window to invalid. If any register in window 0 is | 442 | if ((adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) |
298 | * accessed it should set the window to 0 and then reset it to 1. | 443 | && (pci_func_id >= 2)) |
299 | */ | 444 | adapter->portnum = pci_func_id - 2; |
300 | adapter->curr_window = 255; | ||
301 | /* | ||
302 | * Adapter in our case is quad port so initialize it before | ||
303 | * initializing the ports | ||
304 | */ | ||
305 | netxen_initialize_adapter_hw(adapter); /* initialize the adapter */ | ||
306 | 445 | ||
307 | netxen_initialize_adapter_ops(adapter); | 446 | #ifdef CONFIG_IA64 |
447 | if(adapter->portnum == 0) { | ||
448 | netxen_pinit_from_rom(adapter, 0); | ||
449 | udelay(500); | ||
450 | netxen_load_firmware(adapter); | ||
451 | } | ||
452 | #endif | ||
308 | 453 | ||
309 | init_timer(&adapter->watchdog_timer); | 454 | init_timer(&adapter->watchdog_timer); |
310 | adapter->ahw.xg_linkup = 0; | 455 | adapter->ahw.xg_linkup = 0; |
@@ -315,12 +460,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
315 | adapter->proc_cmd_buf_counter = 0; | 460 | adapter->proc_cmd_buf_counter = 0; |
316 | adapter->ahw.revision_id = nx_p2_id; | 461 | adapter->ahw.revision_id = nx_p2_id; |
317 | 462 | ||
318 | if (pci_enable_msi(pdev)) { | 463 | /* make sure Window == 1 */ |
319 | adapter->flags &= ~NETXEN_NIC_MSI_ENABLED; | 464 | netxen_nic_pci_change_crbwindow(adapter, 1); |
320 | printk(KERN_WARNING "%s: unable to allocate MSI interrupt" | 465 | |
321 | " error\n", netxen_nic_driver_name); | 466 | netxen_nic_update_cmd_producer(adapter, 0); |
322 | } else | 467 | netxen_nic_update_cmd_consumer(adapter, 0); |
323 | adapter->flags |= NETXEN_NIC_MSI_ENABLED; | 468 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); |
324 | 469 | ||
325 | if (netxen_is_flash_supported(adapter) == 0 && | 470 | if (netxen_is_flash_supported(adapter) == 0 && |
326 | netxen_get_flash_mac_addr(adapter, mac_addr) == 0) | 471 | netxen_get_flash_mac_addr(adapter, mac_addr) == 0) |
@@ -328,153 +473,118 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
328 | else | 473 | else |
329 | valid_mac = 0; | 474 | valid_mac = 0; |
330 | 475 | ||
331 | /* | 476 | if (valid_mac) { |
332 | * Initialize all the CRB registers here. | 477 | unsigned char *p = (unsigned char *)&mac_addr[adapter->portnum]; |
333 | */ | 478 | netdev->dev_addr[0] = *(p + 5); |
334 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET)); | 479 | netdev->dev_addr[1] = *(p + 4); |
335 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); | 480 | netdev->dev_addr[2] = *(p + 3); |
336 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); | 481 | netdev->dev_addr[3] = *(p + 2); |
337 | 482 | netdev->dev_addr[4] = *(p + 1); | |
338 | /* do this before waking up pegs so that we have valid dummy dma addr */ | 483 | netdev->dev_addr[5] = *(p + 0); |
339 | err = netxen_initialize_adapter_offload(adapter); | 484 | |
340 | if (err) { | 485 | memcpy(netdev->perm_addr, netdev->dev_addr, |
341 | goto err_out_free_dev; | 486 | netdev->addr_len); |
487 | if (!is_valid_ether_addr(netdev->perm_addr)) { | ||
488 | printk(KERN_ERR "%s: Bad MAC address " | ||
489 | "%02x:%02x:%02x:%02x:%02x:%02x.\n", | ||
490 | netxen_nic_driver_name, | ||
491 | netdev->dev_addr[0], | ||
492 | netdev->dev_addr[1], | ||
493 | netdev->dev_addr[2], | ||
494 | netdev->dev_addr[3], | ||
495 | netdev->dev_addr[4], | ||
496 | netdev->dev_addr[5]); | ||
497 | } else { | ||
498 | if (adapter->macaddr_set) | ||
499 | adapter->macaddr_set(adapter, | ||
500 | netdev->dev_addr); | ||
501 | } | ||
342 | } | 502 | } |
343 | 503 | ||
344 | /* Unlock the HW, prompting the boot sequence */ | 504 | if (adapter->portnum == 0) { |
345 | writel(1, | 505 | err = netxen_initialize_adapter_offload(adapter); |
346 | NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); | 506 | if (err) |
347 | 507 | goto err_out_free_rx_buffer; | |
348 | /* Handshake with the card before we register the devices. */ | 508 | val = readl(NETXEN_CRB_NORMALIZE(adapter, |
349 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); | 509 | NETXEN_CAM_RAM(0x1fc))); |
350 | 510 | if (val == 0x55555555) { | |
351 | /* initialize the all the ports */ | 511 | /* This is the first boot after power up */ |
352 | adapter->active_ports = 0; | 512 | val = readl(NETXEN_CRB_NORMALIZE(adapter, |
353 | 513 | NETXEN_ROMUSB_GLB_SW_RESET)); | |
354 | for (i = 0; i < adapter->ahw.max_ports; i++) { | 514 | printk(KERN_INFO"NetXen: read 0x%08x for reset reg.\n",val); |
355 | netdev = alloc_etherdev(sizeof(struct netxen_port)); | 515 | if (val != 0x80000f) { |
356 | if (!netdev) { | 516 | /* clear the register for future unloads/loads */ |
357 | printk(KERN_ERR "%s: could not allocate netdev for port" | 517 | writel(0, NETXEN_CRB_NORMALIZE(adapter, |
358 | " %d\n", netxen_nic_driver_name, i + 1); | 518 | NETXEN_CAM_RAM(0x1fc))); |
519 | printk(KERN_ERR "ERROR in NetXen HW init sequence.\n"); | ||
520 | err = -ENODEV; | ||
359 | goto err_out_free_dev; | 521 | goto err_out_free_dev; |
360 | } | 522 | } |
361 | 523 | ||
362 | SET_MODULE_OWNER(netdev); | 524 | /* clear the register for future unloads/loads */ |
363 | SET_NETDEV_DEV(netdev, &pdev->dev); | 525 | writel(0, NETXEN_CRB_NORMALIZE(adapter, |
364 | 526 | NETXEN_CAM_RAM(0x1fc))); | |
365 | port = netdev_priv(netdev); | ||
366 | port->netdev = netdev; | ||
367 | port->pdev = pdev; | ||
368 | port->adapter = adapter; | ||
369 | port->portnum = i; /* Gigabit port number from 0-3 */ | ||
370 | |||
371 | netdev->open = netxen_nic_open; | ||
372 | netdev->stop = netxen_nic_close; | ||
373 | netdev->hard_start_xmit = netxen_nic_xmit_frame; | ||
374 | netdev->get_stats = netxen_nic_get_stats; | ||
375 | netdev->set_multicast_list = netxen_nic_set_multi; | ||
376 | netdev->set_mac_address = netxen_nic_set_mac; | ||
377 | netdev->change_mtu = netxen_nic_change_mtu; | ||
378 | netdev->tx_timeout = netxen_tx_timeout; | ||
379 | netdev->watchdog_timeo = HZ; | ||
380 | |||
381 | netxen_nic_change_mtu(netdev, netdev->mtu); | ||
382 | |||
383 | SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); | ||
384 | netdev->poll = netxen_nic_poll; | ||
385 | netdev->weight = NETXEN_NETDEV_WEIGHT; | ||
386 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
387 | netdev->poll_controller = netxen_nic_poll_controller; | ||
388 | #endif | ||
389 | /* ScatterGather support */ | ||
390 | netdev->features = NETIF_F_SG; | ||
391 | netdev->features |= NETIF_F_IP_CSUM; | ||
392 | netdev->features |= NETIF_F_TSO; | ||
393 | |||
394 | if (pci_using_dac) | ||
395 | netdev->features |= NETIF_F_HIGHDMA; | ||
396 | |||
397 | if (valid_mac) { | ||
398 | unsigned char *p = (unsigned char *)&mac_addr[i]; | ||
399 | netdev->dev_addr[0] = *(p + 5); | ||
400 | netdev->dev_addr[1] = *(p + 4); | ||
401 | netdev->dev_addr[2] = *(p + 3); | ||
402 | netdev->dev_addr[3] = *(p + 2); | ||
403 | netdev->dev_addr[4] = *(p + 1); | ||
404 | netdev->dev_addr[5] = *(p + 0); | ||
405 | |||
406 | memcpy(netdev->perm_addr, netdev->dev_addr, | ||
407 | netdev->addr_len); | ||
408 | if (!is_valid_ether_addr(netdev->perm_addr)) { | ||
409 | printk(KERN_ERR "%s: Bad MAC address " | ||
410 | "%02x:%02x:%02x:%02x:%02x:%02x.\n", | ||
411 | netxen_nic_driver_name, | ||
412 | netdev->dev_addr[0], | ||
413 | netdev->dev_addr[1], | ||
414 | netdev->dev_addr[2], | ||
415 | netdev->dev_addr[3], | ||
416 | netdev->dev_addr[4], | ||
417 | netdev->dev_addr[5]); | ||
418 | } else { | ||
419 | if (adapter->macaddr_set) | ||
420 | adapter->macaddr_set(port, | ||
421 | netdev->dev_addr); | ||
422 | } | ||
423 | } | 527 | } |
424 | INIT_WORK(&port->tx_timeout_task, netxen_tx_timeout_task); | 528 | printk(KERN_INFO "State: 0x%0x\n", |
425 | netif_carrier_off(netdev); | 529 | readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE))); |
426 | netif_stop_queue(netdev); | ||
427 | 530 | ||
428 | if ((err = register_netdev(netdev))) { | 531 | /* |
429 | printk(KERN_ERR "%s: register_netdev failed port #%d" | 532 | * Tell the hardware our version number. |
430 | " aborting\n", netxen_nic_driver_name, i + 1); | 533 | */ |
431 | err = -EIO; | 534 | i = (_NETXEN_NIC_LINUX_MAJOR << 16) |
432 | free_netdev(netdev); | 535 | | ((_NETXEN_NIC_LINUX_MINOR << 8)) |
433 | goto err_out_free_dev; | 536 | | (_NETXEN_NIC_LINUX_SUBVERSION); |
434 | } | 537 | writel(i, NETXEN_CRB_NORMALIZE(adapter, CRB_DRIVER_VERSION)); |
435 | adapter->port_count++; | 538 | |
436 | adapter->port[i] = port; | 539 | /* Unlock the HW, prompting the boot sequence */ |
540 | writel(1, | ||
541 | NETXEN_CRB_NORMALIZE(adapter, | ||
542 | NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); | ||
543 | /* Handshake with the card before we register the devices. */ | ||
544 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); | ||
437 | } | 545 | } |
438 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); | 546 | |
439 | netxen_pinit_from_rom(adapter, 0); | ||
440 | udelay(500); | ||
441 | netxen_load_firmware(adapter); | ||
442 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); | ||
443 | /* | 547 | /* |
444 | * delay a while to ensure that the Pegs are up & running. | 548 | * See if the firmware gave us a virtual-physical port mapping. |
445 | * Otherwise, we might see some flaky behaviour. | ||
446 | */ | 549 | */ |
447 | udelay(100); | 550 | i = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_V2P(adapter->portnum))); |
551 | if (i != 0x55555555) | ||
552 | physical_port[adapter->portnum] = i; | ||
553 | |||
554 | netif_carrier_off(netdev); | ||
555 | netif_stop_queue(netdev); | ||
556 | |||
557 | if ((err = register_netdev(netdev))) { | ||
558 | printk(KERN_ERR "%s: register_netdev failed port #%d" | ||
559 | " aborting\n", netxen_nic_driver_name, | ||
560 | adapter->portnum); | ||
561 | err = -EIO; | ||
562 | goto err_out_free_dev; | ||
563 | } | ||
564 | |||
565 | pci_set_drvdata(pdev, adapter); | ||
448 | 566 | ||
449 | switch (adapter->ahw.board_type) { | 567 | switch (adapter->ahw.board_type) { |
450 | case NETXEN_NIC_GBE: | 568 | case NETXEN_NIC_GBE: |
451 | printk("%s: QUAD GbE board initialized\n", | 569 | printk(KERN_INFO "%s: QUAD GbE board initialized\n", |
452 | netxen_nic_driver_name); | 570 | netxen_nic_driver_name); |
453 | break; | 571 | break; |
454 | 572 | ||
455 | case NETXEN_NIC_XGBE: | 573 | case NETXEN_NIC_XGBE: |
456 | printk("%s: XGbE board initialized\n", netxen_nic_driver_name); | 574 | printk(KERN_INFO "%s: XGbE board initialized\n", |
457 | break; | 575 | netxen_nic_driver_name); |
576 | break; | ||
458 | } | 577 | } |
459 | 578 | ||
460 | adapter->driver_mismatch = 0; | 579 | adapter->driver_mismatch = 0; |
461 | 580 | ||
462 | return 0; | 581 | return 0; |
463 | 582 | ||
464 | err_out_free_dev: | 583 | err_out_free_dev: |
465 | if (adapter->flags & NETXEN_NIC_MSI_ENABLED) | 584 | if (adapter->portnum == 0) |
466 | pci_disable_msi(pdev); | 585 | netxen_free_adapter_offload(adapter); |
467 | for (i = 0; i < adapter->port_count; i++) { | ||
468 | port = adapter->port[i]; | ||
469 | if ((port) && (port->netdev)) { | ||
470 | unregister_netdev(port->netdev); | ||
471 | free_netdev(port->netdev); | ||
472 | } | ||
473 | } | ||
474 | 586 | ||
475 | netxen_free_adapter_offload(adapter); | 587 | err_out_free_rx_buffer: |
476 | |||
477 | err_out_free_rx_buffer: | ||
478 | for (i = 0; i < MAX_RCV_CTX; ++i) { | 588 | for (i = 0; i < MAX_RCV_CTX; ++i) { |
479 | recv_ctx = &adapter->recv_ctx[i]; | 589 | recv_ctx = &adapter->recv_ctx[i]; |
480 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { | 590 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { |
@@ -487,15 +597,16 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
487 | } | 597 | } |
488 | vfree(cmd_buf_arr); | 598 | vfree(cmd_buf_arr); |
489 | 599 | ||
490 | err_out_free_adapter: | 600 | err_out_free_adapter: |
601 | if (adapter->flags & NETXEN_NIC_MSI_ENABLED) | ||
602 | pci_disable_msi(pdev); | ||
603 | |||
491 | pci_set_drvdata(pdev, NULL); | 604 | pci_set_drvdata(pdev, NULL); |
492 | kfree(adapter); | ||
493 | 605 | ||
494 | err_out_dbunmap: | ||
495 | if (db_ptr) | 606 | if (db_ptr) |
496 | iounmap(db_ptr); | 607 | iounmap(db_ptr); |
497 | 608 | ||
498 | err_out_iounmap: | 609 | err_out_iounmap: |
499 | if (mem_ptr0) | 610 | if (mem_ptr0) |
500 | iounmap(mem_ptr0); | 611 | iounmap(mem_ptr0); |
501 | if (mem_ptr1) | 612 | if (mem_ptr1) |
@@ -503,9 +614,13 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
503 | if (mem_ptr2) | 614 | if (mem_ptr2) |
504 | iounmap(mem_ptr2); | 615 | iounmap(mem_ptr2); |
505 | 616 | ||
506 | err_out_free_res: | 617 | err_out_free_netdev: |
618 | free_netdev(netdev); | ||
619 | |||
620 | err_out_free_res: | ||
507 | pci_release_regions(pdev); | 621 | pci_release_regions(pdev); |
508 | err_out_disable_pdev: | 622 | |
623 | err_out_disable_pdev: | ||
509 | pci_disable_device(pdev); | 624 | pci_disable_device(pdev); |
510 | return err; | 625 | return err; |
511 | } | 626 | } |
@@ -513,7 +628,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
513 | static void __devexit netxen_nic_remove(struct pci_dev *pdev) | 628 | static void __devexit netxen_nic_remove(struct pci_dev *pdev) |
514 | { | 629 | { |
515 | struct netxen_adapter *adapter; | 630 | struct netxen_adapter *adapter; |
516 | struct netxen_port *port; | 631 | struct net_device *netdev; |
517 | struct netxen_rx_buffer *buffer; | 632 | struct netxen_rx_buffer *buffer; |
518 | struct netxen_recv_context *recv_ctx; | 633 | struct netxen_recv_context *recv_ctx; |
519 | struct netxen_rcv_desc_ctx *rcv_desc; | 634 | struct netxen_rcv_desc_ctx *rcv_desc; |
@@ -524,38 +639,34 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
524 | if (adapter == NULL) | 639 | if (adapter == NULL) |
525 | return; | 640 | return; |
526 | 641 | ||
642 | netdev = adapter->netdev; | ||
643 | |||
644 | netxen_nic_disable_int(adapter); | ||
527 | if (adapter->irq) | 645 | if (adapter->irq) |
528 | free_irq(adapter->irq, adapter); | 646 | free_irq(adapter->irq, adapter); |
529 | netxen_nic_stop_all_ports(adapter); | 647 | |
530 | /* leave the hw in the same state as reboot */ | 648 | if (adapter->stop_port) |
531 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); | 649 | adapter->stop_port(adapter); |
532 | netxen_pinit_from_rom(adapter, 0); | ||
533 | udelay(500); | ||
534 | netxen_load_firmware(adapter); | ||
535 | netxen_free_adapter_offload(adapter); | ||
536 | |||
537 | mdelay(1000); /* Delay for a while to drain the DMA engines */ | ||
538 | for (i = 0; i < adapter->port_count; i++) { | ||
539 | port = adapter->port[i]; | ||
540 | if ((port) && (port->netdev)) { | ||
541 | unregister_netdev(port->netdev); | ||
542 | free_netdev(port->netdev); | ||
543 | } | ||
544 | } | ||
545 | 650 | ||
546 | if ((adapter->flags & NETXEN_NIC_MSI_ENABLED)) | 651 | if ((adapter->flags & NETXEN_NIC_MSI_ENABLED)) |
547 | pci_disable_msi(pdev); | 652 | pci_disable_msi(pdev); |
548 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) | ||
549 | netxen_free_hw_resources(adapter); | ||
550 | 653 | ||
551 | iounmap(adapter->ahw.db_base); | 654 | if (adapter->portnum == 0) |
552 | iounmap(adapter->ahw.pci_base0); | 655 | netxen_free_adapter_offload(adapter); |
553 | iounmap(adapter->ahw.pci_base1); | ||
554 | iounmap(adapter->ahw.pci_base2); | ||
555 | 656 | ||
556 | pci_release_regions(pdev); | 657 | if (adapter->irq) |
557 | pci_disable_device(pdev); | 658 | free_irq(adapter->irq, adapter); |
558 | pci_set_drvdata(pdev, NULL); | 659 | if(adapter->portnum == 0) { |
660 | /* leave the hw in the same state as reboot */ | ||
661 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); | ||
662 | netxen_pinit_from_rom(adapter, 0); | ||
663 | udelay(500); | ||
664 | netxen_load_firmware(adapter); | ||
665 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); | ||
666 | } | ||
667 | |||
668 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) | ||
669 | netxen_free_hw_resources(adapter); | ||
559 | 670 | ||
560 | for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { | 671 | for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { |
561 | recv_ctx = &adapter->recv_ctx[ctxid]; | 672 | recv_ctx = &adapter->recv_ctx[ctxid]; |
@@ -575,8 +686,20 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
575 | } | 686 | } |
576 | } | 687 | } |
577 | 688 | ||
689 | unregister_netdev(netdev); | ||
690 | |||
578 | vfree(adapter->cmd_buf_arr); | 691 | vfree(adapter->cmd_buf_arr); |
579 | kfree(adapter); | 692 | |
693 | iounmap(adapter->ahw.db_base); | ||
694 | iounmap(adapter->ahw.pci_base0); | ||
695 | iounmap(adapter->ahw.pci_base1); | ||
696 | iounmap(adapter->ahw.pci_base2); | ||
697 | |||
698 | pci_release_regions(pdev); | ||
699 | pci_disable_device(pdev); | ||
700 | pci_set_drvdata(pdev, NULL); | ||
701 | |||
702 | free_netdev(netdev); | ||
580 | } | 703 | } |
581 | 704 | ||
582 | /* | 705 | /* |
@@ -585,8 +708,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
585 | */ | 708 | */ |
586 | static int netxen_nic_open(struct net_device *netdev) | 709 | static int netxen_nic_open(struct net_device *netdev) |
587 | { | 710 | { |
588 | struct netxen_port *port = netdev_priv(netdev); | 711 | struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv; |
589 | struct netxen_adapter *adapter = port->adapter; | ||
590 | int err = 0; | 712 | int err = 0; |
591 | int ctx, ring; | 713 | int ctx, ring; |
592 | 714 | ||
@@ -597,8 +719,6 @@ static int netxen_nic_open(struct net_device *netdev) | |||
597 | return -EIO; | 719 | return -EIO; |
598 | } | 720 | } |
599 | netxen_nic_flash_print(adapter); | 721 | netxen_nic_flash_print(adapter); |
600 | if (adapter->init_niu) | ||
601 | adapter->init_niu(adapter); | ||
602 | 722 | ||
603 | /* setup all the resources for the Phantom... */ | 723 | /* setup all the resources for the Phantom... */ |
604 | /* this include the descriptors for rcv, tx, and status */ | 724 | /* this include the descriptors for rcv, tx, and status */ |
@@ -609,21 +729,14 @@ static int netxen_nic_open(struct net_device *netdev) | |||
609 | err); | 729 | err); |
610 | return err; | 730 | return err; |
611 | } | 731 | } |
612 | if (adapter->init_port | ||
613 | && adapter->init_port(adapter, port->portnum) != 0) { | ||
614 | printk(KERN_ERR "%s: Failed to initialize port %d\n", | ||
615 | netxen_nic_driver_name, port->portnum); | ||
616 | netxen_free_hw_resources(adapter); | ||
617 | return -EIO; | ||
618 | } | ||
619 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 732 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
620 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) | 733 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) |
621 | netxen_post_rx_buffers(adapter, ctx, ring); | 734 | netxen_post_rx_buffers(adapter, ctx, ring); |
622 | } | 735 | } |
623 | adapter->irq = adapter->ahw.pdev->irq; | 736 | adapter->irq = adapter->ahw.pdev->irq; |
624 | err = request_irq(adapter->ahw.pdev->irq, &netxen_intr, | 737 | err = request_irq(adapter->ahw.pdev->irq, netxen_intr, |
625 | IRQF_SHARED | IRQF_SAMPLE_RANDOM, | 738 | SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, |
626 | netdev->name, adapter); | 739 | adapter); |
627 | if (err) { | 740 | if (err) { |
628 | printk(KERN_ERR "request_irq failed with: %d\n", err); | 741 | printk(KERN_ERR "request_irq failed with: %d\n", err); |
629 | netxen_free_hw_resources(adapter); | 742 | netxen_free_hw_resources(adapter); |
@@ -632,23 +745,28 @@ static int netxen_nic_open(struct net_device *netdev) | |||
632 | 745 | ||
633 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; | 746 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; |
634 | } | 747 | } |
635 | adapter->active_ports++; | 748 | if (!adapter->driver_mismatch) |
636 | if (adapter->active_ports == 1) { | 749 | mod_timer(&adapter->watchdog_timer, jiffies); |
637 | if (!adapter->driver_mismatch) | ||
638 | mod_timer(&adapter->watchdog_timer, jiffies); | ||
639 | 750 | ||
640 | netxen_nic_enable_int(adapter); | 751 | netxen_nic_enable_int(adapter); |
641 | } | ||
642 | 752 | ||
643 | /* Done here again so that even if phantom sw overwrote it, | 753 | /* Done here again so that even if phantom sw overwrote it, |
644 | * we set it */ | 754 | * we set it */ |
645 | if (adapter->macaddr_set) | 755 | if (adapter->macaddr_set) |
646 | adapter->macaddr_set(port, netdev->dev_addr); | 756 | adapter->macaddr_set(adapter, netdev->dev_addr); |
647 | netxen_nic_set_link_parameters(port); | 757 | if (adapter->init_port |
758 | && adapter->init_port(adapter, adapter->portnum) != 0) { | ||
759 | del_timer_sync(&adapter->watchdog_timer); | ||
760 | printk(KERN_ERR "%s: Failed to initialize port %d\n", | ||
761 | netxen_nic_driver_name, adapter->portnum); | ||
762 | return -EIO; | ||
763 | } | ||
764 | |||
765 | netxen_nic_set_link_parameters(adapter); | ||
648 | 766 | ||
649 | netxen_nic_set_multi(netdev); | 767 | netxen_nic_set_multi(netdev); |
650 | if (adapter->set_mtu) | 768 | if (adapter->set_mtu) |
651 | adapter->set_mtu(port, netdev->mtu); | 769 | adapter->set_mtu(adapter, netdev->mtu); |
652 | 770 | ||
653 | if (!adapter->driver_mismatch) | 771 | if (!adapter->driver_mismatch) |
654 | netif_start_queue(netdev); | 772 | netif_start_queue(netdev); |
@@ -661,8 +779,7 @@ static int netxen_nic_open(struct net_device *netdev) | |||
661 | */ | 779 | */ |
662 | static int netxen_nic_close(struct net_device *netdev) | 780 | static int netxen_nic_close(struct net_device *netdev) |
663 | { | 781 | { |
664 | struct netxen_port *port = netdev_priv(netdev); | 782 | struct netxen_adapter *adapter = netdev_priv(netdev); |
665 | struct netxen_adapter *adapter = port->adapter; | ||
666 | int i, j; | 783 | int i, j; |
667 | struct netxen_cmd_buffer *cmd_buff; | 784 | struct netxen_cmd_buffer *cmd_buff; |
668 | struct netxen_skb_frag *buffrag; | 785 | struct netxen_skb_frag *buffrag; |
@@ -670,47 +787,39 @@ static int netxen_nic_close(struct net_device *netdev) | |||
670 | netif_carrier_off(netdev); | 787 | netif_carrier_off(netdev); |
671 | netif_stop_queue(netdev); | 788 | netif_stop_queue(netdev); |
672 | 789 | ||
673 | adapter->active_ports--; | 790 | cmd_buff = adapter->cmd_buf_arr; |
674 | 791 | for (i = 0; i < adapter->max_tx_desc_count; i++) { | |
675 | if (!adapter->active_ports) { | 792 | buffrag = cmd_buff->frag_array; |
676 | netxen_nic_disable_int(adapter); | 793 | if (buffrag->dma) { |
677 | cmd_buff = adapter->cmd_buf_arr; | 794 | pci_unmap_single(adapter->pdev, buffrag->dma, |
678 | for (i = 0; i < adapter->max_tx_desc_count; i++) { | 795 | buffrag->length, PCI_DMA_TODEVICE); |
679 | buffrag = cmd_buff->frag_array; | 796 | buffrag->dma = (u64) NULL; |
797 | } | ||
798 | for (j = 0; j < cmd_buff->frag_count; j++) { | ||
799 | buffrag++; | ||
680 | if (buffrag->dma) { | 800 | if (buffrag->dma) { |
681 | pci_unmap_single(port->pdev, buffrag->dma, | 801 | pci_unmap_page(adapter->pdev, buffrag->dma, |
682 | buffrag->length, | 802 | buffrag->length, |
683 | PCI_DMA_TODEVICE); | 803 | PCI_DMA_TODEVICE); |
684 | buffrag->dma = (u64) NULL; | 804 | buffrag->dma = (u64) NULL; |
685 | } | 805 | } |
686 | for (j = 0; j < cmd_buff->frag_count; j++) { | ||
687 | buffrag++; | ||
688 | if (buffrag->dma) { | ||
689 | pci_unmap_page(port->pdev, | ||
690 | buffrag->dma, | ||
691 | buffrag->length, | ||
692 | PCI_DMA_TODEVICE); | ||
693 | buffrag->dma = (u64) NULL; | ||
694 | } | ||
695 | } | ||
696 | /* Free the skb we received in netxen_nic_xmit_frame */ | ||
697 | if (cmd_buff->skb) { | ||
698 | dev_kfree_skb_any(cmd_buff->skb); | ||
699 | cmd_buff->skb = NULL; | ||
700 | } | ||
701 | cmd_buff++; | ||
702 | } | 806 | } |
703 | FLUSH_SCHEDULED_WORK(); | 807 | /* Free the skb we received in netxen_nic_xmit_frame */ |
704 | del_timer_sync(&adapter->watchdog_timer); | 808 | if (cmd_buff->skb) { |
809 | dev_kfree_skb_any(cmd_buff->skb); | ||
810 | cmd_buff->skb = NULL; | ||
811 | } | ||
812 | cmd_buff++; | ||
705 | } | 813 | } |
814 | FLUSH_SCHEDULED_WORK(); | ||
815 | del_timer_sync(&adapter->watchdog_timer); | ||
706 | 816 | ||
707 | return 0; | 817 | return 0; |
708 | } | 818 | } |
709 | 819 | ||
710 | static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | 820 | static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) |
711 | { | 821 | { |
712 | struct netxen_port *port = netdev_priv(netdev); | 822 | struct netxen_adapter *adapter = netdev_priv(netdev); |
713 | struct netxen_adapter *adapter = port->adapter; | ||
714 | struct netxen_hardware_context *hw = &adapter->ahw; | 823 | struct netxen_hardware_context *hw = &adapter->ahw; |
715 | unsigned int first_seg_len = skb->len - skb->data_len; | 824 | unsigned int first_seg_len = skb->len - skb->data_len; |
716 | struct netxen_skb_frag *buffrag; | 825 | struct netxen_skb_frag *buffrag; |
@@ -728,12 +837,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
728 | u32 last_cmd_consumer = 0; | 837 | u32 last_cmd_consumer = 0; |
729 | int no_of_desc; | 838 | int no_of_desc; |
730 | 839 | ||
731 | port->stats.xmitcalled++; | 840 | adapter->stats.xmitcalled++; |
732 | frag_count = skb_shinfo(skb)->nr_frags + 1; | 841 | frag_count = skb_shinfo(skb)->nr_frags + 1; |
733 | 842 | ||
734 | if (unlikely(skb->len <= 0)) { | 843 | if (unlikely(skb->len <= 0)) { |
735 | dev_kfree_skb_any(skb); | 844 | dev_kfree_skb_any(skb); |
736 | port->stats.badskblen++; | 845 | adapter->stats.badskblen++; |
737 | return NETDEV_TX_OK; | 846 | return NETDEV_TX_OK; |
738 | } | 847 | } |
739 | 848 | ||
@@ -742,7 +851,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
742 | "too large, can handle only %d frags\n", | 851 | "too large, can handle only %d frags\n", |
743 | netxen_nic_driver_name, netdev->name, | 852 | netxen_nic_driver_name, netdev->name, |
744 | frag_count, MAX_BUFFERS_PER_CMD); | 853 | frag_count, MAX_BUFFERS_PER_CMD); |
745 | port->stats.txdropped++; | 854 | adapter->stats.txdropped++; |
746 | if ((++dropped_packet & 0xff) == 0xff) | 855 | if ((++dropped_packet & 0xff) == 0xff) |
747 | printk("%s: %s droppped packets = %d\n", | 856 | printk("%s: %s droppped packets = %d\n", |
748 | netxen_nic_driver_name, netdev->name, | 857 | netxen_nic_driver_name, netdev->name, |
@@ -759,7 +868,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
759 | */ | 868 | */ |
760 | retry_getting_window: | 869 | retry_getting_window: |
761 | spin_lock_bh(&adapter->tx_lock); | 870 | spin_lock_bh(&adapter->tx_lock); |
762 | if (adapter->total_threads == MAX_XMIT_PRODUCERS) { | 871 | if (adapter->total_threads >= MAX_XMIT_PRODUCERS) { |
763 | spin_unlock_bh(&adapter->tx_lock); | 872 | spin_unlock_bh(&adapter->tx_lock); |
764 | /* | 873 | /* |
765 | * Yield CPU | 874 | * Yield CPU |
@@ -792,15 +901,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
792 | if ((k + no_of_desc) >= | 901 | if ((k + no_of_desc) >= |
793 | ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : | 902 | ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : |
794 | last_cmd_consumer)) { | 903 | last_cmd_consumer)) { |
795 | port->stats.nocmddescriptor++; | ||
796 | DPRINTK(ERR, "No command descriptors available," | ||
797 | " producer = %d, consumer = %d count=%llu," | ||
798 | " dropping packet\n", producer, | ||
799 | adapter->last_cmd_consumer, | ||
800 | port->stats.nocmddescriptor); | ||
801 | |||
802 | netif_stop_queue(netdev); | 904 | netif_stop_queue(netdev); |
803 | port->flags |= NETXEN_NETDEV_STATUS; | 905 | adapter->flags |= NETXEN_NETDEV_STATUS; |
804 | spin_unlock_bh(&adapter->tx_lock); | 906 | spin_unlock_bh(&adapter->tx_lock); |
805 | return NETDEV_TX_BUSY; | 907 | return NETDEV_TX_BUSY; |
806 | } | 908 | } |
@@ -828,16 +930,17 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
828 | pbuf->skb = skb; | 930 | pbuf->skb = skb; |
829 | pbuf->cmd = TX_ETHER_PKT; | 931 | pbuf->cmd = TX_ETHER_PKT; |
830 | pbuf->frag_count = frag_count; | 932 | pbuf->frag_count = frag_count; |
831 | pbuf->port = port->portnum; | 933 | pbuf->port = adapter->portnum; |
832 | buffrag = &pbuf->frag_array[0]; | 934 | buffrag = &pbuf->frag_array[0]; |
833 | buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len, | 935 | buffrag->dma = pci_map_single(adapter->pdev, skb->data, first_seg_len, |
834 | PCI_DMA_TODEVICE); | 936 | PCI_DMA_TODEVICE); |
835 | buffrag->length = first_seg_len; | 937 | buffrag->length = first_seg_len; |
836 | netxen_set_cmd_desc_totallength(hwdesc, skb->len); | 938 | netxen_set_cmd_desc_totallength(hwdesc, skb->len); |
837 | netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count); | 939 | netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count); |
838 | netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT); | 940 | netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT); |
839 | 941 | ||
840 | netxen_set_cmd_desc_port(hwdesc, port->portnum); | 942 | netxen_set_cmd_desc_port(hwdesc, adapter->portnum); |
943 | netxen_set_cmd_desc_ctxid(hwdesc, adapter->portnum); | ||
841 | hwdesc->buffer1_length = cpu_to_le16(first_seg_len); | 944 | hwdesc->buffer1_length = cpu_to_le16(first_seg_len); |
842 | hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); | 945 | hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); |
843 | 946 | ||
@@ -860,7 +963,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
860 | offset = frag->page_offset; | 963 | offset = frag->page_offset; |
861 | 964 | ||
862 | temp_len = len; | 965 | temp_len = len; |
863 | temp_dma = pci_map_page(port->pdev, frag->page, offset, | 966 | temp_dma = pci_map_page(adapter->pdev, frag->page, offset, |
864 | len, PCI_DMA_TODEVICE); | 967 | len, PCI_DMA_TODEVICE); |
865 | 968 | ||
866 | buffrag++; | 969 | buffrag++; |
@@ -927,21 +1030,29 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
927 | producer = get_next_index(producer, max_tx_desc_count); | 1030 | producer = get_next_index(producer, max_tx_desc_count); |
928 | } | 1031 | } |
929 | } | 1032 | } |
1033 | |||
1034 | i = netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]); | ||
1035 | |||
1036 | hw->cmd_desc_head[saved_producer].flags_opcode = | ||
1037 | cpu_to_le16(hw->cmd_desc_head[saved_producer].flags_opcode); | ||
1038 | hw->cmd_desc_head[saved_producer].num_of_buffers_total_length = | ||
1039 | cpu_to_le32(hw->cmd_desc_head[saved_producer]. | ||
1040 | num_of_buffers_total_length); | ||
1041 | |||
930 | spin_lock_bh(&adapter->tx_lock); | 1042 | spin_lock_bh(&adapter->tx_lock); |
931 | port->stats.txbytes += | 1043 | adapter->stats.txbytes += i; |
932 | netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]); | 1044 | |
933 | /* Code to update the adapter considering how many producer threads | 1045 | /* Code to update the adapter considering how many producer threads |
934 | are currently working */ | 1046 | are currently working */ |
935 | if ((--adapter->num_threads) == 0) { | 1047 | if ((--adapter->num_threads) == 0) { |
936 | /* This is the last thread */ | 1048 | /* This is the last thread */ |
937 | u32 crb_producer = adapter->cmd_producer; | 1049 | u32 crb_producer = adapter->cmd_producer; |
938 | writel(crb_producer, | 1050 | netxen_nic_update_cmd_producer(adapter, crb_producer); |
939 | NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET)); | ||
940 | wmb(); | 1051 | wmb(); |
941 | adapter->total_threads = 0; | 1052 | adapter->total_threads = 0; |
942 | } | 1053 | } |
943 | 1054 | ||
944 | port->stats.xmitfinished++; | 1055 | adapter->stats.xmitfinished++; |
945 | spin_unlock_bh(&adapter->tx_lock); | 1056 | spin_unlock_bh(&adapter->tx_lock); |
946 | 1057 | ||
947 | netdev->trans_start = jiffies; | 1058 | netdev->trans_start = jiffies; |
@@ -961,27 +1072,26 @@ static void netxen_watchdog(unsigned long v) | |||
961 | 1072 | ||
962 | static void netxen_tx_timeout(struct net_device *netdev) | 1073 | static void netxen_tx_timeout(struct net_device *netdev) |
963 | { | 1074 | { |
964 | struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); | 1075 | struct netxen_adapter *adapter = (struct netxen_adapter *) |
965 | 1076 | netdev_priv(netdev); | |
966 | SCHEDULE_WORK(&port->tx_timeout_task); | 1077 | SCHEDULE_WORK(&adapter->tx_timeout_task); |
967 | } | 1078 | } |
968 | 1079 | ||
969 | static void netxen_tx_timeout_task(struct work_struct *work) | 1080 | static void netxen_tx_timeout_task(struct work_struct *work) |
970 | { | 1081 | { |
971 | struct netxen_port *port = | 1082 | struct netxen_adapter *adapter = |
972 | container_of(work, struct netxen_port, tx_timeout_task); | 1083 | container_of(work, struct netxen_adapter, tx_timeout_task); |
973 | struct net_device *netdev = port->netdev; | ||
974 | unsigned long flags; | 1084 | unsigned long flags; |
975 | 1085 | ||
976 | printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", | 1086 | printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", |
977 | netxen_nic_driver_name, netdev->name); | 1087 | netxen_nic_driver_name, adapter->netdev->name); |
978 | 1088 | ||
979 | spin_lock_irqsave(&port->adapter->lock, flags); | 1089 | spin_lock_irqsave(&adapter->lock, flags); |
980 | netxen_nic_close(netdev); | 1090 | netxen_nic_close(adapter->netdev); |
981 | netxen_nic_open(netdev); | 1091 | netxen_nic_open(adapter->netdev); |
982 | spin_unlock_irqrestore(&port->adapter->lock, flags); | 1092 | spin_unlock_irqrestore(&adapter->lock, flags); |
983 | netdev->trans_start = jiffies; | 1093 | adapter->netdev->trans_start = jiffies; |
984 | netif_wake_queue(netdev); | 1094 | netif_wake_queue(adapter->netdev); |
985 | } | 1095 | } |
986 | 1096 | ||
987 | static int | 1097 | static int |
@@ -990,17 +1100,16 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) | |||
990 | u32 ret = 0; | 1100 | u32 ret = 0; |
991 | 1101 | ||
992 | DPRINTK(INFO, "Entered handle ISR\n"); | 1102 | DPRINTK(INFO, "Entered handle ISR\n"); |
993 | |||
994 | adapter->stats.ints++; | 1103 | adapter->stats.ints++; |
995 | 1104 | ||
996 | if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { | 1105 | if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { |
997 | int count = 0; | 1106 | int count = 0; |
998 | u32 mask; | 1107 | u32 mask; |
999 | mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR)); | 1108 | u32 our_int = 0; |
1000 | if ((mask & 0x80) == 0) { | 1109 | our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); |
1001 | /* not our interrupt */ | 1110 | /* not our interrupt */ |
1111 | if ((our_int & (0x80 << adapter->portnum)) == 0) | ||
1002 | return ret; | 1112 | return ret; |
1003 | } | ||
1004 | netxen_nic_disable_int(adapter); | 1113 | netxen_nic_disable_int(adapter); |
1005 | /* Window = 0 or 1 */ | 1114 | /* Window = 0 or 1 */ |
1006 | do { | 1115 | do { |
@@ -1012,7 +1121,6 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) | |||
1012 | printk("Could not disable interrupt completely\n"); | 1121 | printk("Could not disable interrupt completely\n"); |
1013 | 1122 | ||
1014 | } | 1123 | } |
1015 | adapter->stats.hostints++; | ||
1016 | 1124 | ||
1017 | if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) { | 1125 | if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) { |
1018 | if (netif_rx_schedule_prep(netdev)) { | 1126 | if (netif_rx_schedule_prep(netdev)) { |
@@ -1046,33 +1154,24 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) | |||
1046 | irqreturn_t netxen_intr(int irq, void *data) | 1154 | irqreturn_t netxen_intr(int irq, void *data) |
1047 | { | 1155 | { |
1048 | struct netxen_adapter *adapter; | 1156 | struct netxen_adapter *adapter; |
1049 | struct netxen_port *port; | ||
1050 | struct net_device *netdev; | 1157 | struct net_device *netdev; |
1051 | int i; | ||
1052 | 1158 | ||
1053 | if (unlikely(!irq)) { | 1159 | if (unlikely(!irq)) { |
1054 | return IRQ_NONE; /* Not our interrupt */ | 1160 | return IRQ_NONE; /* Not our interrupt */ |
1055 | } | 1161 | } |
1056 | 1162 | ||
1057 | adapter = (struct netxen_adapter *)data; | 1163 | adapter = (struct netxen_adapter *)data; |
1058 | for (i = 0; i < adapter->ahw.max_ports; i++) { | 1164 | netdev = adapter->netdev; |
1059 | port = adapter->port[i]; | 1165 | /* process our status queue (for all 4 ports) */ |
1060 | netdev = port->netdev; | 1166 | if (netif_running(netdev)) |
1061 | 1167 | netxen_handle_int(adapter, netdev); | |
1062 | /* process our status queue (for all 4 ports) */ | ||
1063 | if (netif_running(netdev)) { | ||
1064 | netxen_handle_int(adapter, netdev); | ||
1065 | break; | ||
1066 | } | ||
1067 | } | ||
1068 | 1168 | ||
1069 | return IRQ_HANDLED; | 1169 | return IRQ_HANDLED; |
1070 | } | 1170 | } |
1071 | 1171 | ||
1072 | static int netxen_nic_poll(struct net_device *netdev, int *budget) | 1172 | static int netxen_nic_poll(struct net_device *netdev, int *budget) |
1073 | { | 1173 | { |
1074 | struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); | 1174 | struct netxen_adapter *adapter = netdev_priv(netdev); |
1075 | struct netxen_adapter *adapter = port->adapter; | ||
1076 | int work_to_do = min(*budget, netdev->quota); | 1175 | int work_to_do = min(*budget, netdev->quota); |
1077 | int done = 1; | 1176 | int done = 1; |
1078 | int ctx; | 1177 | int ctx; |
@@ -1080,7 +1179,6 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget) | |||
1080 | int work_done = 0; | 1179 | int work_done = 0; |
1081 | 1180 | ||
1082 | DPRINTK(INFO, "polling for %d descriptors\n", *budget); | 1181 | DPRINTK(INFO, "polling for %d descriptors\n", *budget); |
1083 | port->stats.polled++; | ||
1084 | 1182 | ||
1085 | work_done = 0; | 1183 | work_done = 0; |
1086 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 1184 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
@@ -1124,8 +1222,7 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget) | |||
1124 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1222 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1125 | static void netxen_nic_poll_controller(struct net_device *netdev) | 1223 | static void netxen_nic_poll_controller(struct net_device *netdev) |
1126 | { | 1224 | { |
1127 | struct netxen_port *port = netdev_priv(netdev); | 1225 | struct netxen_adapter *adapter = netdev_priv(netdev); |
1128 | struct netxen_adapter *adapter = port->adapter; | ||
1129 | disable_irq(adapter->irq); | 1226 | disable_irq(adapter->irq); |
1130 | netxen_intr(adapter->irq, adapter); | 1227 | netxen_intr(adapter->irq, adapter); |
1131 | enable_irq(adapter->irq); | 1228 | enable_irq(adapter->irq); |
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c index d5d95074e569..cef90a78351e 100644 --- a/drivers/net/netxen/netxen_nic_niu.c +++ b/drivers/net/netxen/netxen_nic_niu.c | |||
@@ -88,12 +88,13 @@ static inline int phy_unlock(struct netxen_adapter *adapter) | |||
88 | * -1 on error | 88 | * -1 on error |
89 | * | 89 | * |
90 | */ | 90 | */ |
91 | int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, | 91 | int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg, |
92 | long reg, __u32 * readval) | 92 | __u32 * readval) |
93 | { | 93 | { |
94 | long timeout = 0; | 94 | long timeout = 0; |
95 | long result = 0; | 95 | long result = 0; |
96 | long restore = 0; | 96 | long restore = 0; |
97 | long phy = physical_port[adapter->portnum]; | ||
97 | __u32 address; | 98 | __u32 address; |
98 | __u32 command; | 99 | __u32 command; |
99 | __u32 status; | 100 | __u32 status; |
@@ -183,12 +184,13 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, | |||
183 | * -1 on error | 184 | * -1 on error |
184 | * | 185 | * |
185 | */ | 186 | */ |
186 | int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, | 187 | int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg, |
187 | long phy, long reg, __u32 val) | 188 | __u32 val) |
188 | { | 189 | { |
189 | long timeout = 0; | 190 | long timeout = 0; |
190 | long result = 0; | 191 | long result = 0; |
191 | long restore = 0; | 192 | long restore = 0; |
193 | long phy = physical_port[adapter->portnum]; | ||
192 | __u32 address; | 194 | __u32 address; |
193 | __u32 command; | 195 | __u32 command; |
194 | __u32 status; | 196 | __u32 status; |
@@ -258,15 +260,13 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, | |||
258 | return result; | 260 | return result; |
259 | } | 261 | } |
260 | 262 | ||
261 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 263 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter) |
262 | int port) | ||
263 | { | 264 | { |
264 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f); | 265 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f); |
265 | return 0; | 266 | return 0; |
266 | } | 267 | } |
267 | 268 | ||
268 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 269 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter) |
269 | int port) | ||
270 | { | 270 | { |
271 | int result = 0; | 271 | int result = 0; |
272 | __u32 enable = 0; | 272 | __u32 enable = 0; |
@@ -275,7 +275,7 @@ int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, | |||
275 | netxen_set_phy_int_speed_changed(enable); | 275 | netxen_set_phy_int_speed_changed(enable); |
276 | 276 | ||
277 | if (0 != | 277 | if (0 != |
278 | netxen_niu_gbe_phy_write(adapter, port, | 278 | netxen_niu_gbe_phy_write(adapter, |
279 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE, | 279 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE, |
280 | enable)) | 280 | enable)) |
281 | result = -EIO; | 281 | result = -EIO; |
@@ -283,38 +283,34 @@ int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, | |||
283 | return result; | 283 | return result; |
284 | } | 284 | } |
285 | 285 | ||
286 | int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter, | 286 | int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter) |
287 | int port) | ||
288 | { | 287 | { |
289 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f); | 288 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f); |
290 | return 0; | 289 | return 0; |
291 | } | 290 | } |
292 | 291 | ||
293 | int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter, | 292 | int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter) |
294 | int port) | ||
295 | { | 293 | { |
296 | int result = 0; | 294 | int result = 0; |
297 | if (0 != | 295 | if (0 != |
298 | netxen_niu_gbe_phy_write(adapter, port, | 296 | netxen_niu_gbe_phy_write(adapter, |
299 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE, 0)) | 297 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE, 0)) |
300 | result = -EIO; | 298 | result = -EIO; |
301 | 299 | ||
302 | return result; | 300 | return result; |
303 | } | 301 | } |
304 | 302 | ||
305 | int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter, | 303 | int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter) |
306 | int port) | ||
307 | { | 304 | { |
308 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_ACTIVE_INT, -1); | 305 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_ACTIVE_INT, -1); |
309 | return 0; | 306 | return 0; |
310 | } | 307 | } |
311 | 308 | ||
312 | int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter, | 309 | int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter) |
313 | int port) | ||
314 | { | 310 | { |
315 | int result = 0; | 311 | int result = 0; |
316 | if (0 != | 312 | if (0 != |
317 | netxen_niu_gbe_phy_write(adapter, port, | 313 | netxen_niu_gbe_phy_write(adapter, |
318 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, | 314 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, |
319 | -EIO)) | 315 | -EIO)) |
320 | result = -EIO; | 316 | result = -EIO; |
@@ -355,9 +351,9 @@ void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, | |||
355 | 0x5); | 351 | 0x5); |
356 | } | 352 | } |
357 | 353 | ||
358 | if (netxen_niu_gbe_enable_phy_interrupts(adapter, port)) | 354 | if (netxen_niu_gbe_enable_phy_interrupts(adapter)) |
359 | printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n"); | 355 | printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n"); |
360 | if (netxen_niu_gbe_clear_phy_interrupts(adapter, port)) | 356 | if (netxen_niu_gbe_clear_phy_interrupts(adapter)) |
361 | printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n"); | 357 | printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n"); |
362 | } | 358 | } |
363 | 359 | ||
@@ -393,9 +389,9 @@ void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, | |||
393 | 0x5); | 389 | 0x5); |
394 | } | 390 | } |
395 | 391 | ||
396 | if (netxen_niu_gbe_enable_phy_interrupts(adapter, port)) | 392 | if (netxen_niu_gbe_enable_phy_interrupts(adapter)) |
397 | printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n"); | 393 | printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n"); |
398 | if (netxen_niu_gbe_clear_phy_interrupts(adapter, port)) | 394 | if (netxen_niu_gbe_clear_phy_interrupts(adapter)) |
399 | printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n"); | 395 | printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n"); |
400 | } | 396 | } |
401 | 397 | ||
@@ -404,11 +400,11 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port) | |||
404 | int result = 0; | 400 | int result = 0; |
405 | __u32 status; | 401 | __u32 status; |
406 | if (adapter->disable_phy_interrupts) | 402 | if (adapter->disable_phy_interrupts) |
407 | adapter->disable_phy_interrupts(adapter, port); | 403 | adapter->disable_phy_interrupts(adapter); |
408 | mdelay(2); | 404 | mdelay(2); |
409 | 405 | ||
410 | if (0 == | 406 | if (0 == |
411 | netxen_niu_gbe_phy_read(adapter, port, | 407 | netxen_niu_gbe_phy_read(adapter, |
412 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 408 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
413 | &status)) { | 409 | &status)) { |
414 | if (netxen_get_phy_link(status)) { | 410 | if (netxen_get_phy_link(status)) { |
@@ -439,13 +435,13 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port) | |||
439 | | NETXEN_GB_MAC_ENABLE_TX_RX | 435 | | NETXEN_GB_MAC_ENABLE_TX_RX |
440 | | | 436 | | |
441 | NETXEN_GB_MAC_PAUSED_FRMS); | 437 | NETXEN_GB_MAC_PAUSED_FRMS); |
442 | if (netxen_niu_gbe_clear_phy_interrupts(adapter, port)) | 438 | if (netxen_niu_gbe_clear_phy_interrupts(adapter)) |
443 | printk(KERN_ERR PFX | 439 | printk(KERN_ERR PFX |
444 | "ERROR clearing PHY interrupts\n"); | 440 | "ERROR clearing PHY interrupts\n"); |
445 | if (netxen_niu_gbe_enable_phy_interrupts(adapter, port)) | 441 | if (netxen_niu_gbe_enable_phy_interrupts(adapter)) |
446 | printk(KERN_ERR PFX | 442 | printk(KERN_ERR PFX |
447 | "ERROR enabling PHY interrupts\n"); | 443 | "ERROR enabling PHY interrupts\n"); |
448 | if (netxen_niu_gbe_clear_phy_interrupts(adapter, port)) | 444 | if (netxen_niu_gbe_clear_phy_interrupts(adapter)) |
449 | printk(KERN_ERR PFX | 445 | printk(KERN_ERR PFX |
450 | "ERROR clearing PHY interrupts\n"); | 446 | "ERROR clearing PHY interrupts\n"); |
451 | result = -1; | 447 | result = -1; |
@@ -458,26 +454,18 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port) | |||
458 | 454 | ||
459 | int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port) | 455 | int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port) |
460 | { | 456 | { |
461 | u32 reg = 0, ret = 0; | 457 | u32 reg; |
458 | u32 portnum = physical_port[adapter->portnum]; | ||
462 | 459 | ||
463 | if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) { | 460 | netxen_crb_writelit_adapter(adapter, |
464 | netxen_crb_writelit_adapter(adapter, | 461 | NETXEN_NIU_XGE_CONFIG_0+(0x10000*portnum), 0x5); |
465 | NETXEN_NIU_XG1_CONFIG_0, 0x5); | 462 | netxen_nic_hw_read_wx(adapter, |
466 | /* XXX hack for Mez cards: both ports in promisc mode */ | 463 | NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), ®, 4); |
467 | netxen_nic_hw_read_wx(adapter, | 464 | reg = (reg & ~0x2000UL); |
468 | NETXEN_NIU_XGE_CONFIG_1, ®, 4); | 465 | netxen_crb_writelit_adapter(adapter, |
469 | reg = (reg | 0x2000UL); | 466 | NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), reg); |
470 | netxen_crb_writelit_adapter(adapter, | ||
471 | NETXEN_NIU_XGE_CONFIG_1, reg); | ||
472 | reg = 0; | ||
473 | netxen_nic_hw_read_wx(adapter, | ||
474 | NETXEN_NIU_XG1_CONFIG_1, ®, 4); | ||
475 | reg = (reg | 0x2000UL); | ||
476 | netxen_crb_writelit_adapter(adapter, | ||
477 | NETXEN_NIU_XG1_CONFIG_1, reg); | ||
478 | } | ||
479 | 467 | ||
480 | return ret; | 468 | return 0; |
481 | } | 469 | } |
482 | 470 | ||
483 | /* | 471 | /* |
@@ -498,7 +486,7 @@ int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter, | |||
498 | * The read of the PHY INT status will clear the pending | 486 | * The read of the PHY INT status will clear the pending |
499 | * interrupt status | 487 | * interrupt status |
500 | */ | 488 | */ |
501 | if (netxen_niu_gbe_phy_read(adapter, port, | 489 | if (netxen_niu_gbe_phy_read(adapter, |
502 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, | 490 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, |
503 | &int_src) != 0) | 491 | &int_src) != 0) |
504 | result = -EINVAL; | 492 | result = -EINVAL; |
@@ -535,7 +523,7 @@ int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter, | |||
535 | printk(KERN_INFO PFX | 523 | printk(KERN_INFO PFX |
536 | "speed_changed or link status changed"); | 524 | "speed_changed or link status changed"); |
537 | if (netxen_niu_gbe_phy_read | 525 | if (netxen_niu_gbe_phy_read |
538 | (adapter, port, | 526 | (adapter, |
539 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 527 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
540 | &status) == 0) { | 528 | &status) == 0) { |
541 | if (netxen_get_phy_speed(status) == 2) { | 529 | if (netxen_get_phy_speed(status) == 2) { |
@@ -581,10 +569,11 @@ int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter, | |||
581 | * Note that the passed-in value must already be in network byte order. | 569 | * Note that the passed-in value must already be in network byte order. |
582 | */ | 570 | */ |
583 | int netxen_niu_macaddr_get(struct netxen_adapter *adapter, | 571 | int netxen_niu_macaddr_get(struct netxen_adapter *adapter, |
584 | int phy, netxen_ethernet_macaddr_t * addr) | 572 | netxen_ethernet_macaddr_t * addr) |
585 | { | 573 | { |
586 | u32 stationhigh; | 574 | u32 stationhigh; |
587 | u32 stationlow; | 575 | u32 stationlow; |
576 | int phy = physical_port[adapter->portnum]; | ||
588 | u8 val[8]; | 577 | u8 val[8]; |
589 | 578 | ||
590 | if (addr == NULL) | 579 | if (addr == NULL) |
@@ -610,13 +599,12 @@ int netxen_niu_macaddr_get(struct netxen_adapter *adapter, | |||
610 | * Set the station MAC address. | 599 | * Set the station MAC address. |
611 | * Note that the passed-in value must already be in network byte order. | 600 | * Note that the passed-in value must already be in network byte order. |
612 | */ | 601 | */ |
613 | int netxen_niu_macaddr_set(struct netxen_port *port, | 602 | int netxen_niu_macaddr_set(struct netxen_adapter *adapter, |
614 | netxen_ethernet_macaddr_t addr) | 603 | netxen_ethernet_macaddr_t addr) |
615 | { | 604 | { |
616 | u8 temp[4]; | 605 | u8 temp[4]; |
617 | u32 val; | 606 | u32 val; |
618 | struct netxen_adapter *adapter = port->adapter; | 607 | int phy = physical_port[adapter->portnum]; |
619 | int phy = port->portnum; | ||
620 | unsigned char mac_addr[6]; | 608 | unsigned char mac_addr[6]; |
621 | int i; | 609 | int i; |
622 | 610 | ||
@@ -634,7 +622,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port, | |||
634 | (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4)) | 622 | (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4)) |
635 | return -2; | 623 | return -2; |
636 | 624 | ||
637 | netxen_niu_macaddr_get(adapter, phy, | 625 | netxen_niu_macaddr_get(adapter, |
638 | (netxen_ethernet_macaddr_t *) mac_addr); | 626 | (netxen_ethernet_macaddr_t *) mac_addr); |
639 | if (memcmp(mac_addr, addr, 6) == 0) | 627 | if (memcmp(mac_addr, addr, 6) == 0) |
640 | break; | 628 | break; |
@@ -642,7 +630,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port, | |||
642 | 630 | ||
643 | if (i == 10) { | 631 | if (i == 10) { |
644 | printk(KERN_ERR "%s: cannot set Mac addr for %s\n", | 632 | printk(KERN_ERR "%s: cannot set Mac addr for %s\n", |
645 | netxen_nic_driver_name, port->netdev->name); | 633 | netxen_nic_driver_name, adapter->netdev->name); |
646 | printk(KERN_ERR "MAC address set: " | 634 | printk(KERN_ERR "MAC address set: " |
647 | "%02x:%02x:%02x:%02x:%02x:%02x.\n", | 635 | "%02x:%02x:%02x:%02x:%02x:%02x.\n", |
648 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); | 636 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
@@ -735,13 +723,13 @@ int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter, | |||
735 | } | 723 | } |
736 | 724 | ||
737 | /* Disable a GbE interface */ | 725 | /* Disable a GbE interface */ |
738 | int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port) | 726 | int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter) |
739 | { | 727 | { |
740 | __u32 mac_cfg0; | 728 | __u32 mac_cfg0; |
729 | u32 port = physical_port[adapter->portnum]; | ||
741 | 730 | ||
742 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) | 731 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) |
743 | return -EINVAL; | 732 | return -EINVAL; |
744 | |||
745 | mac_cfg0 = 0; | 733 | mac_cfg0 = 0; |
746 | netxen_gb_soft_reset(mac_cfg0); | 734 | netxen_gb_soft_reset(mac_cfg0); |
747 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), | 735 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), |
@@ -751,13 +739,13 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port) | |||
751 | } | 739 | } |
752 | 740 | ||
753 | /* Disable an XG interface */ | 741 | /* Disable an XG interface */ |
754 | int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port) | 742 | int netxen_niu_disable_xg_port(struct netxen_adapter *adapter) |
755 | { | 743 | { |
756 | __u32 mac_cfg; | 744 | __u32 mac_cfg; |
745 | u32 port = physical_port[adapter->portnum]; | ||
757 | 746 | ||
758 | if (port != 0) | 747 | if (port != 0) |
759 | return -EINVAL; | 748 | return -EINVAL; |
760 | |||
761 | mac_cfg = 0; | 749 | mac_cfg = 0; |
762 | netxen_xg_soft_reset(mac_cfg); | 750 | netxen_xg_soft_reset(mac_cfg); |
763 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_CONFIG_0, | 751 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_CONFIG_0, |
@@ -767,10 +755,11 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port) | |||
767 | } | 755 | } |
768 | 756 | ||
769 | /* Set promiscuous mode for a GbE interface */ | 757 | /* Set promiscuous mode for a GbE interface */ |
770 | int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port, | 758 | int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, |
771 | netxen_niu_prom_mode_t mode) | 759 | netxen_niu_prom_mode_t mode) |
772 | { | 760 | { |
773 | __u32 reg; | 761 | __u32 reg; |
762 | u32 port = physical_port[adapter->portnum]; | ||
774 | 763 | ||
775 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) | 764 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) |
776 | return -EINVAL; | 765 | return -EINVAL; |
@@ -824,25 +813,50 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port, | |||
824 | * Set the MAC address for an XG port | 813 | * Set the MAC address for an XG port |
825 | * Note that the passed-in value must already be in network byte order. | 814 | * Note that the passed-in value must already be in network byte order. |
826 | */ | 815 | */ |
827 | int netxen_niu_xg_macaddr_set(struct netxen_port *port, | 816 | int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter, |
828 | netxen_ethernet_macaddr_t addr) | 817 | netxen_ethernet_macaddr_t addr) |
829 | { | 818 | { |
819 | int phy = physical_port[adapter->portnum]; | ||
830 | u8 temp[4]; | 820 | u8 temp[4]; |
831 | u32 val; | 821 | u32 val; |
832 | struct netxen_adapter *adapter = port->adapter; | 822 | |
823 | if ((phy < 0) || (phy > NETXEN_NIU_MAX_XG_PORTS)) | ||
824 | return -EIO; | ||
833 | 825 | ||
834 | temp[0] = temp[1] = 0; | 826 | temp[0] = temp[1] = 0; |
835 | memcpy(temp + 2, addr, 2); | 827 | switch (phy) { |
836 | val = le32_to_cpu(*(__le32 *)temp); | 828 | case 0: |
837 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1, | 829 | memcpy(temp + 2, addr, 2); |
838 | &val, 4)) | 830 | val = le32_to_cpu(*(__le32 *)temp); |
831 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1, | ||
832 | &val, 4)) | ||
839 | return -EIO; | 833 | return -EIO; |
840 | 834 | ||
841 | memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); | 835 | memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); |
842 | val = le32_to_cpu(*(__le32 *)temp); | 836 | val = le32_to_cpu(*(__le32 *)temp); |
843 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI, | 837 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI, |
844 | &val, 4)) | 838 | &val, 4)) |
839 | return -EIO; | ||
840 | break; | ||
841 | |||
842 | case 1: | ||
843 | memcpy(temp + 2, addr, 2); | ||
844 | val = le32_to_cpu(*(__le32 *)temp); | ||
845 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_1, | ||
846 | &val, 4)) | ||
847 | return -EIO; | ||
848 | |||
849 | memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); | ||
850 | val = le32_to_cpu(*(__le32 *)temp); | ||
851 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_HI, | ||
852 | &val, 4)) | ||
845 | return -EIO; | 853 | return -EIO; |
854 | break; | ||
855 | |||
856 | default: | ||
857 | printk(KERN_ERR "Unknown port %d\n", phy); | ||
858 | break; | ||
859 | } | ||
846 | 860 | ||
847 | return 0; | 861 | return 0; |
848 | } | 862 | } |
@@ -851,9 +865,10 @@ int netxen_niu_xg_macaddr_set(struct netxen_port *port, | |||
851 | * Return the current station MAC address. | 865 | * Return the current station MAC address. |
852 | * Note that the passed-in value must already be in network byte order. | 866 | * Note that the passed-in value must already be in network byte order. |
853 | */ | 867 | */ |
854 | int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy, | 868 | int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, |
855 | netxen_ethernet_macaddr_t * addr) | 869 | netxen_ethernet_macaddr_t * addr) |
856 | { | 870 | { |
871 | int phy = physical_port[adapter->portnum]; | ||
857 | u32 stationhigh; | 872 | u32 stationhigh; |
858 | u32 stationlow; | 873 | u32 stationlow; |
859 | u8 val[8]; | 874 | u8 val[8]; |
@@ -878,21 +893,24 @@ int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy, | |||
878 | } | 893 | } |
879 | 894 | ||
880 | int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, | 895 | int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, |
881 | int port, netxen_niu_prom_mode_t mode) | 896 | netxen_niu_prom_mode_t mode) |
882 | { | 897 | { |
883 | __u32 reg; | 898 | __u32 reg; |
899 | u32 port = physical_port[adapter->portnum]; | ||
884 | 900 | ||
885 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) | 901 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) |
886 | return -EINVAL; | 902 | return -EINVAL; |
887 | 903 | ||
888 | if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_CONFIG_1, ®, 4)) | 904 | if (netxen_nic_hw_read_wx(adapter, |
889 | return -EIO; | 905 | NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), ®, 4)) |
906 | return -EIO; | ||
890 | if (mode == NETXEN_NIU_PROMISC_MODE) | 907 | if (mode == NETXEN_NIU_PROMISC_MODE) |
891 | reg = (reg | 0x2000UL); | 908 | reg = (reg | 0x2000UL); |
892 | else | 909 | else |
893 | reg = (reg & ~0x2000UL); | 910 | reg = (reg & ~0x2000UL); |
894 | 911 | ||
895 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_XGE_CONFIG_1, reg); | 912 | netxen_crb_writelit_adapter(adapter, |
913 | NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), reg); | ||
896 | 914 | ||
897 | return 0; | 915 | return 0; |
898 | } | 916 | } |
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h index 0c7c94328b7f..9457fc7249c8 100644 --- a/drivers/net/netxen/netxen_nic_phan_reg.h +++ b/drivers/net/netxen/netxen_nic_phan_reg.h | |||
@@ -100,8 +100,21 @@ | |||
100 | 100 | ||
101 | #define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac) | 101 | #define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac) |
102 | #define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0) | 102 | #define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0) |
103 | #define CRB_CMD_PRODUCER_OFFSET_2 NETXEN_NIC_REG(0x1b8) | ||
104 | #define CRB_CMD_CONSUMER_OFFSET_2 NETXEN_NIC_REG(0x1bc) | ||
105 | |||
106 | // 1c0 to 1cc used for signature reg | ||
107 | #define CRB_CMD_PRODUCER_OFFSET_3 NETXEN_NIC_REG(0x1d0) | ||
108 | #define CRB_CMD_CONSUMER_OFFSET_3 NETXEN_NIC_REG(0x1d4) | ||
103 | #define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4) | 109 | #define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4) |
104 | 110 | ||
111 | #define CRB_V2P_0 NETXEN_NIC_REG(0x290) | ||
112 | #define CRB_V2P_1 NETXEN_NIC_REG(0x294) | ||
113 | #define CRB_V2P_2 NETXEN_NIC_REG(0x298) | ||
114 | #define CRB_V2P_3 NETXEN_NIC_REG(0x29c) | ||
115 | #define CRB_V2P(port) (CRB_V2P_0+((port)*4)) | ||
116 | #define CRB_DRIVER_VERSION NETXEN_NIC_REG(0x2a0) | ||
117 | |||
105 | /* used for ethtool tests */ | 118 | /* used for ethtool tests */ |
106 | #define CRB_SCRATCHPAD_TEST NETXEN_NIC_REG(0x280) | 119 | #define CRB_SCRATCHPAD_TEST NETXEN_NIC_REG(0x280) |
107 | 120 | ||
@@ -139,128 +152,13 @@ struct netxen_recv_crb { | |||
139 | }; | 152 | }; |
140 | 153 | ||
141 | #if defined(DEFINE_GLOBAL_RECV_CRB) | 154 | #if defined(DEFINE_GLOBAL_RECV_CRB) |
142 | struct netxen_recv_crb recv_crb_registers[] = { | ||
143 | /* | ||
144 | * Instance 0. | ||
145 | */ | ||
146 | { | ||
147 | /* rcv_desc_crb: */ | ||
148 | { | ||
149 | { | ||
150 | /* crb_rcv_producer_offset: */ | ||
151 | NETXEN_NIC_REG(0x100), | ||
152 | /* crb_rcv_consumer_offset: */ | ||
153 | NETXEN_NIC_REG(0x104), | ||
154 | /* crb_gloablrcv_ring: */ | ||
155 | NETXEN_NIC_REG(0x108), | ||
156 | /* crb_rcv_ring_size */ | ||
157 | NETXEN_NIC_REG(0x10c), | ||
158 | |||
159 | }, | ||
160 | /* Jumbo frames */ | ||
161 | { | ||
162 | /* crb_rcv_producer_offset: */ | ||
163 | NETXEN_NIC_REG(0x110), | ||
164 | /* crb_rcv_consumer_offset: */ | ||
165 | NETXEN_NIC_REG(0x114), | ||
166 | /* crb_gloablrcv_ring: */ | ||
167 | NETXEN_NIC_REG(0x118), | ||
168 | /* crb_rcv_ring_size */ | ||
169 | NETXEN_NIC_REG(0x11c), | ||
170 | }, | ||
171 | /* LRO */ | ||
172 | { | ||
173 | /* crb_rcv_producer_offset: */ | ||
174 | NETXEN_NIC_REG(0x120), | ||
175 | /* crb_rcv_consumer_offset: */ | ||
176 | NETXEN_NIC_REG(0x124), | ||
177 | /* crb_gloablrcv_ring: */ | ||
178 | NETXEN_NIC_REG(0x128), | ||
179 | /* crb_rcv_ring_size */ | ||
180 | NETXEN_NIC_REG(0x12c), | ||
181 | } | ||
182 | }, | ||
183 | /* crb_rcvstatus_ring: */ | ||
184 | NETXEN_NIC_REG(0x130), | ||
185 | /* crb_rcv_status_producer: */ | ||
186 | NETXEN_NIC_REG(0x134), | ||
187 | /* crb_rcv_status_consumer: */ | ||
188 | NETXEN_NIC_REG(0x138), | ||
189 | /* crb_rcvpeg_state: */ | ||
190 | NETXEN_NIC_REG(0x13c), | ||
191 | /* crb_status_ring_size */ | ||
192 | NETXEN_NIC_REG(0x140), | ||
193 | |||
194 | }, | ||
195 | /* | ||
196 | * Instance 1, | ||
197 | */ | ||
198 | { | ||
199 | /* rcv_desc_crb: */ | ||
200 | { | ||
201 | { | ||
202 | /* crb_rcv_producer_offset: */ | ||
203 | NETXEN_NIC_REG(0x144), | ||
204 | /* crb_rcv_consumer_offset: */ | ||
205 | NETXEN_NIC_REG(0x148), | ||
206 | /* crb_globalrcv_ring: */ | ||
207 | NETXEN_NIC_REG(0x14c), | ||
208 | /* crb_rcv_ring_size */ | ||
209 | NETXEN_NIC_REG(0x150), | ||
210 | |||
211 | }, | ||
212 | /* Jumbo frames */ | ||
213 | { | ||
214 | /* crb_rcv_producer_offset: */ | ||
215 | NETXEN_NIC_REG(0x154), | ||
216 | /* crb_rcv_consumer_offset: */ | ||
217 | NETXEN_NIC_REG(0x158), | ||
218 | /* crb_globalrcv_ring: */ | ||
219 | NETXEN_NIC_REG(0x15c), | ||
220 | /* crb_rcv_ring_size */ | ||
221 | NETXEN_NIC_REG(0x160), | ||
222 | }, | ||
223 | /* LRO */ | ||
224 | { | ||
225 | /* crb_rcv_producer_offset: */ | ||
226 | NETXEN_NIC_REG(0x164), | ||
227 | /* crb_rcv_consumer_offset: */ | ||
228 | NETXEN_NIC_REG(0x168), | ||
229 | /* crb_globalrcv_ring: */ | ||
230 | NETXEN_NIC_REG(0x16c), | ||
231 | /* crb_rcv_ring_size */ | ||
232 | NETXEN_NIC_REG(0x170), | ||
233 | } | ||
234 | |||
235 | }, | ||
236 | /* crb_rcvstatus_ring: */ | ||
237 | NETXEN_NIC_REG(0x174), | ||
238 | /* crb_rcv_status_producer: */ | ||
239 | NETXEN_NIC_REG(0x178), | ||
240 | /* crb_rcv_status_consumer: */ | ||
241 | NETXEN_NIC_REG(0x17c), | ||
242 | /* crb_rcvpeg_state: */ | ||
243 | NETXEN_NIC_REG(0x180), | ||
244 | /* crb_status_ring_size */ | ||
245 | NETXEN_NIC_REG(0x184), | ||
246 | |||
247 | }, | ||
248 | }; | ||
249 | |||
250 | u64 ctx_addr_sig_regs[][3] = { | ||
251 | {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)}, | ||
252 | {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)}, | ||
253 | {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)}, | ||
254 | {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)} | ||
255 | }; | ||
256 | |||
257 | #else | 155 | #else |
258 | extern struct netxen_recv_crb recv_crb_registers[]; | 156 | extern struct netxen_recv_crb recv_crb_registers[]; |
259 | extern u64 ctx_addr_sig_regs[][3]; | 157 | extern u64 ctx_addr_sig_regs[][3]; |
260 | #define CRB_CTX_ADDR_REG_LO (ctx_addr_sig_regs[0][0]) | ||
261 | #define CRB_CTX_ADDR_REG_HI (ctx_addr_sig_regs[0][2]) | ||
262 | #define CRB_CTX_SIGNATURE_REG (ctx_addr_sig_regs[0][1]) | ||
263 | #endif /* DEFINE_GLOBAL_RECEIVE_CRB */ | 158 | #endif /* DEFINE_GLOBAL_RECEIVE_CRB */ |
159 | #define CRB_CTX_ADDR_REG_LO(FUNC_ID) (ctx_addr_sig_regs[FUNC_ID][0]) | ||
160 | #define CRB_CTX_ADDR_REG_HI(FUNC_ID) (ctx_addr_sig_regs[FUNC_ID][2]) | ||
161 | #define CRB_CTX_SIGNATURE_REG(FUNC_ID) (ctx_addr_sig_regs[FUNC_ID][1]) | ||
264 | 162 | ||
265 | /* | 163 | /* |
266 | * Temperature control. | 164 | * Temperature control. |