diff options
author | Mithlesh Thukral <mithlesh@netxen.com> | 2007-04-20 10:55:26 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 11:01:06 -0400 |
commit | 6c80b18df3537d1221ab34555c150bccbfd90260 (patch) | |
tree | b82c057feb8a4c5c4ba0171b268599ea357eb2a9 /drivers/net/netxen/netxen_nic_niu.c | |
parent | 5d512f5594f9f4829b099c87f7bc6f683ef146ca (diff) |
NetXen: Port swap feature for multi port cards
NetXen: Port Swap feature
This patch will allow a port numbers on the card to be swapped in
host driver. This feature is applicable to cards having more than
1 port.
Signed-off by: Milan Bag <mbag@netxen.com>
Signed-off by: Mithlesh Thukral <mithlesh@netxen.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_niu.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_niu.c | 93 |
1 files changed, 63 insertions, 30 deletions
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c index ad2486f2f646..cef90a78351e 100644 --- a/drivers/net/netxen/netxen_nic_niu.c +++ b/drivers/net/netxen/netxen_nic_niu.c | |||
@@ -94,7 +94,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg, | |||
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 = adapter->portnum; | 97 | long phy = physical_port[adapter->portnum]; |
98 | __u32 address; | 98 | __u32 address; |
99 | __u32 command; | 99 | __u32 command; |
100 | __u32 status; | 100 | __u32 status; |
@@ -190,7 +190,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg, | |||
190 | long timeout = 0; | 190 | long timeout = 0; |
191 | long result = 0; | 191 | long result = 0; |
192 | long restore = 0; | 192 | long restore = 0; |
193 | long phy = adapter->portnum; | 193 | long phy = physical_port[adapter->portnum]; |
194 | __u32 address; | 194 | __u32 address; |
195 | __u32 command; | 195 | __u32 command; |
196 | __u32 status; | 196 | __u32 status; |
@@ -454,16 +454,18 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port) | |||
454 | 454 | ||
455 | 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) |
456 | { | 456 | { |
457 | u32 ret = 0; | 457 | u32 reg; |
458 | int portnum = adapter->portnum; | 458 | u32 portnum = physical_port[adapter->portnum]; |
459 | netxen_crb_writelit_adapter(adapter, | 459 | |
460 | NETXEN_NIU_XGE_CONFIG_1 +(0x10000 * portnum), | 460 | netxen_crb_writelit_adapter(adapter, |
461 | 0x1447); | 461 | NETXEN_NIU_XGE_CONFIG_0+(0x10000*portnum), 0x5); |
462 | netxen_crb_writelit_adapter(adapter, | 462 | netxen_nic_hw_read_wx(adapter, |
463 | NETXEN_NIU_XG1_CONFIG_1 + | 463 | NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), ®, 4); |
464 | (0x10000 * portnum), 0x5); | 464 | reg = (reg & ~0x2000UL); |
465 | netxen_crb_writelit_adapter(adapter, | ||
466 | NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), reg); | ||
465 | 467 | ||
466 | return ret; | 468 | return 0; |
467 | } | 469 | } |
468 | 470 | ||
469 | /* | 471 | /* |
@@ -571,7 +573,7 @@ int netxen_niu_macaddr_get(struct netxen_adapter *adapter, | |||
571 | { | 573 | { |
572 | u32 stationhigh; | 574 | u32 stationhigh; |
573 | u32 stationlow; | 575 | u32 stationlow; |
574 | int phy = adapter->portnum; | 576 | int phy = physical_port[adapter->portnum]; |
575 | u8 val[8]; | 577 | u8 val[8]; |
576 | 578 | ||
577 | if (addr == NULL) | 579 | if (addr == NULL) |
@@ -602,7 +604,7 @@ int netxen_niu_macaddr_set(struct netxen_adapter *adapter, | |||
602 | { | 604 | { |
603 | u8 temp[4]; | 605 | u8 temp[4]; |
604 | u32 val; | 606 | u32 val; |
605 | int phy = adapter->portnum; | 607 | int phy = physical_port[adapter->portnum]; |
606 | unsigned char mac_addr[6]; | 608 | unsigned char mac_addr[6]; |
607 | int i; | 609 | int i; |
608 | 610 | ||
@@ -724,8 +726,10 @@ int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter, | |||
724 | int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter) | 726 | int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter) |
725 | { | 727 | { |
726 | __u32 mac_cfg0; | 728 | __u32 mac_cfg0; |
727 | int port = adapter->portnum; | 729 | u32 port = physical_port[adapter->portnum]; |
728 | 730 | ||
731 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) | ||
732 | return -EINVAL; | ||
729 | mac_cfg0 = 0; | 733 | mac_cfg0 = 0; |
730 | netxen_gb_soft_reset(mac_cfg0); | 734 | netxen_gb_soft_reset(mac_cfg0); |
731 | 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), |
@@ -738,7 +742,10 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter) | |||
738 | int netxen_niu_disable_xg_port(struct netxen_adapter *adapter) | 742 | int netxen_niu_disable_xg_port(struct netxen_adapter *adapter) |
739 | { | 743 | { |
740 | __u32 mac_cfg; | 744 | __u32 mac_cfg; |
745 | u32 port = physical_port[adapter->portnum]; | ||
741 | 746 | ||
747 | if (port != 0) | ||
748 | return -EINVAL; | ||
742 | mac_cfg = 0; | 749 | mac_cfg = 0; |
743 | netxen_xg_soft_reset(mac_cfg); | 750 | netxen_xg_soft_reset(mac_cfg); |
744 | 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, |
@@ -752,7 +759,7 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, | |||
752 | netxen_niu_prom_mode_t mode) | 759 | netxen_niu_prom_mode_t mode) |
753 | { | 760 | { |
754 | __u32 reg; | 761 | __u32 reg; |
755 | int port = adapter->portnum; | 762 | u32 port = physical_port[adapter->portnum]; |
756 | 763 | ||
757 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) | 764 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) |
758 | return -EINVAL; | 765 | return -EINVAL; |
@@ -809,21 +816,47 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, | |||
809 | int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter, | 816 | int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter, |
810 | netxen_ethernet_macaddr_t addr) | 817 | netxen_ethernet_macaddr_t addr) |
811 | { | 818 | { |
819 | int phy = physical_port[adapter->portnum]; | ||
812 | u8 temp[4]; | 820 | u8 temp[4]; |
813 | u32 val; | 821 | u32 val; |
814 | 822 | ||
823 | if ((phy < 0) || (phy > NETXEN_NIU_MAX_XG_PORTS)) | ||
824 | return -EIO; | ||
825 | |||
815 | temp[0] = temp[1] = 0; | 826 | temp[0] = temp[1] = 0; |
816 | memcpy(temp + 2, addr, 2); | 827 | switch (phy) { |
817 | val = le32_to_cpu(*(__le32 *)temp); | 828 | case 0: |
818 | if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1, | 829 | memcpy(temp + 2, addr, 2); |
819 | &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)) | ||
820 | return -EIO; | 833 | return -EIO; |
821 | 834 | ||
822 | memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); | 835 | memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); |
823 | val = le32_to_cpu(*(__le32 *)temp); | 836 | val = le32_to_cpu(*(__le32 *)temp); |
824 | 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, |
825 | &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)) | ||
826 | return -EIO; | 853 | return -EIO; |
854 | break; | ||
855 | |||
856 | default: | ||
857 | printk(KERN_ERR "Unknown port %d\n", phy); | ||
858 | break; | ||
859 | } | ||
827 | 860 | ||
828 | return 0; | 861 | return 0; |
829 | } | 862 | } |
@@ -835,7 +868,7 @@ int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter, | |||
835 | int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, | 868 | int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, |
836 | netxen_ethernet_macaddr_t * addr) | 869 | netxen_ethernet_macaddr_t * addr) |
837 | { | 870 | { |
838 | int phy = adapter->portnum; | 871 | int phy = physical_port[adapter->portnum]; |
839 | u32 stationhigh; | 872 | u32 stationhigh; |
840 | u32 stationlow; | 873 | u32 stationlow; |
841 | u8 val[8]; | 874 | u8 val[8]; |
@@ -863,21 +896,21 @@ int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, | |||
863 | netxen_niu_prom_mode_t mode) | 896 | netxen_niu_prom_mode_t mode) |
864 | { | 897 | { |
865 | __u32 reg; | 898 | __u32 reg; |
866 | int port = adapter->portnum; | 899 | u32 port = physical_port[adapter->portnum]; |
867 | 900 | ||
868 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) | 901 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) |
869 | return -EINVAL; | 902 | return -EINVAL; |
870 | 903 | ||
871 | if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_CONFIG_1 + | 904 | if (netxen_nic_hw_read_wx(adapter, |
872 | (0x10000 * port), ®, 4)) | 905 | NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), ®, 4)) |
873 | return -EIO; | 906 | return -EIO; |
874 | if (mode == NETXEN_NIU_PROMISC_MODE) | 907 | if (mode == NETXEN_NIU_PROMISC_MODE) |
875 | reg = (reg | 0x2000UL); | 908 | reg = (reg | 0x2000UL); |
876 | else | 909 | else |
877 | reg = (reg & ~0x2000UL); | 910 | reg = (reg & ~0x2000UL); |
878 | 911 | ||
879 | netxen_crb_writelit_adapter(adapter, NETXEN_NIU_XGE_CONFIG_1 + | 912 | netxen_crb_writelit_adapter(adapter, |
880 | (0x10000 * port), reg); | 913 | NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), reg); |
881 | 914 | ||
882 | return 0; | 915 | return 0; |
883 | } | 916 | } |