aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_niu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/netxen/netxen_nic_niu.c')
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c110
1 files changed, 45 insertions, 65 deletions
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
index 3310471ba1a0..b54a63a64e7b 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -105,9 +105,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
105 * so it cannot be in reset 105 * so it cannot be in reset
106 */ 106 */
107 107
108 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), 108 mac_cfg0 = adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0));
109 &mac_cfg0, 4))
110 return -EIO;
111 if (netxen_gb_get_soft_reset(mac_cfg0)) { 109 if (netxen_gb_get_soft_reset(mac_cfg0)) {
112 __u32 temp; 110 __u32 temp;
113 temp = 0; 111 temp = 0;
@@ -116,8 +114,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
116 netxen_gb_tx_reset_mac(temp); 114 netxen_gb_tx_reset_mac(temp);
117 netxen_gb_rx_reset_mac(temp); 115 netxen_gb_rx_reset_mac(temp);
118 if (adapter->hw_write_wx(adapter, 116 if (adapter->hw_write_wx(adapter,
119 NETXEN_NIU_GB_MAC_CONFIG_0(0), 117 NETXEN_NIU_GB_MAC_CONFIG_0(0), temp))
120 &temp, 4))
121 return -EIO; 118 return -EIO;
122 restore = 1; 119 restore = 1;
123 } 120 }
@@ -125,43 +122,38 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
125 address = 0; 122 address = 0;
126 netxen_gb_mii_mgmt_reg_addr(address, reg); 123 netxen_gb_mii_mgmt_reg_addr(address, reg);
127 netxen_gb_mii_mgmt_phy_addr(address, phy); 124 netxen_gb_mii_mgmt_phy_addr(address, phy);
128 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0), 125 if (adapter->hw_write_wx(adapter,
129 &address, 4)) 126 NETXEN_NIU_GB_MII_MGMT_ADDR(0), address))
130 return -EIO; 127 return -EIO;
131 command = 0; /* turn off any prior activity */ 128 command = 0; /* turn off any prior activity */
132 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), 129 if (adapter->hw_write_wx(adapter,
133 &command, 4)) 130 NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
134 return -EIO; 131 return -EIO;
135 /* send read command */ 132 /* send read command */
136 netxen_gb_mii_mgmt_set_read_cycle(command); 133 netxen_gb_mii_mgmt_set_read_cycle(command);
137 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), 134 if (adapter->hw_write_wx(adapter,
138 &command, 4)) 135 NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
139 return -EIO; 136 return -EIO;
140 137
141 status = 0; 138 status = 0;
142 do { 139 do {
143 if (adapter->hw_read_wx(adapter, 140 status = adapter->hw_read_wx(adapter,
144 NETXEN_NIU_GB_MII_MGMT_INDICATE(0), 141 NETXEN_NIU_GB_MII_MGMT_INDICATE(0));
145 &status, 4))
146 return -EIO;
147 timeout++; 142 timeout++;
148 } while ((netxen_get_gb_mii_mgmt_busy(status) 143 } while ((netxen_get_gb_mii_mgmt_busy(status)
149 || netxen_get_gb_mii_mgmt_notvalid(status)) 144 || netxen_get_gb_mii_mgmt_notvalid(status))
150 && (timeout++ < NETXEN_NIU_PHY_WAITMAX)); 145 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
151 146
152 if (timeout < NETXEN_NIU_PHY_WAITMAX) { 147 if (timeout < NETXEN_NIU_PHY_WAITMAX) {
153 if (adapter->hw_read_wx(adapter, 148 *readval = adapter->hw_read_wx(adapter,
154 NETXEN_NIU_GB_MII_MGMT_STATUS(0), 149 NETXEN_NIU_GB_MII_MGMT_STATUS(0));
155 readval, 4))
156 return -EIO;
157 result = 0; 150 result = 0;
158 } else 151 } else
159 result = -1; 152 result = -1;
160 153
161 if (restore) 154 if (restore)
162 if (adapter->hw_write_wx(adapter, 155 if (adapter->hw_write_wx(adapter,
163 NETXEN_NIU_GB_MAC_CONFIG_0(0), 156 NETXEN_NIU_GB_MAC_CONFIG_0(0), mac_cfg0))
164 &mac_cfg0, 4))
165 return -EIO; 157 return -EIO;
166 phy_unlock(adapter); 158 phy_unlock(adapter);
167 return result; 159 return result;
@@ -197,9 +189,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
197 * cannot be in reset 189 * cannot be in reset
198 */ 190 */
199 191
200 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), 192 mac_cfg0 = adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0));
201 &mac_cfg0, 4))
202 return -EIO;
203 if (netxen_gb_get_soft_reset(mac_cfg0)) { 193 if (netxen_gb_get_soft_reset(mac_cfg0)) {
204 __u32 temp; 194 __u32 temp;
205 temp = 0; 195 temp = 0;
@@ -209,34 +199,31 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
209 netxen_gb_rx_reset_mac(temp); 199 netxen_gb_rx_reset_mac(temp);
210 200
211 if (adapter->hw_write_wx(adapter, 201 if (adapter->hw_write_wx(adapter,
212 NETXEN_NIU_GB_MAC_CONFIG_0(0), 202 NETXEN_NIU_GB_MAC_CONFIG_0(0), temp))
213 &temp, 4))
214 return -EIO; 203 return -EIO;
215 restore = 1; 204 restore = 1;
216 } 205 }
217 206
218 command = 0; /* turn off any prior activity */ 207 command = 0; /* turn off any prior activity */
219 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0), 208 if (adapter->hw_write_wx(adapter,
220 &command, 4)) 209 NETXEN_NIU_GB_MII_MGMT_COMMAND(0), command))
221 return -EIO; 210 return -EIO;
222 211
223 address = 0; 212 address = 0;
224 netxen_gb_mii_mgmt_reg_addr(address, reg); 213 netxen_gb_mii_mgmt_reg_addr(address, reg);
225 netxen_gb_mii_mgmt_phy_addr(address, phy); 214 netxen_gb_mii_mgmt_phy_addr(address, phy);
226 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0), 215 if (adapter->hw_write_wx(adapter,
227 &address, 4)) 216 NETXEN_NIU_GB_MII_MGMT_ADDR(0), address))
228 return -EIO; 217 return -EIO;
229 218
230 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0), 219 if (adapter->hw_write_wx(adapter,
231 &val, 4)) 220 NETXEN_NIU_GB_MII_MGMT_CTRL(0), val))
232 return -EIO; 221 return -EIO;
233 222
234 status = 0; 223 status = 0;
235 do { 224 do {
236 if (adapter->hw_read_wx(adapter, 225 status = adapter->hw_read_wx(adapter,
237 NETXEN_NIU_GB_MII_MGMT_INDICATE(0), 226 NETXEN_NIU_GB_MII_MGMT_INDICATE(0));
238 &status, 4))
239 return -EIO;
240 timeout++; 227 timeout++;
241 } while ((netxen_get_gb_mii_mgmt_busy(status)) 228 } while ((netxen_get_gb_mii_mgmt_busy(status))
242 && (timeout++ < NETXEN_NIU_PHY_WAITMAX)); 229 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
@@ -249,8 +236,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
249 /* restore the state of port 0 MAC in case we tampered with it */ 236 /* restore the state of port 0 MAC in case we tampered with it */
250 if (restore) 237 if (restore)
251 if (adapter->hw_write_wx(adapter, 238 if (adapter->hw_write_wx(adapter,
252 NETXEN_NIU_GB_MAC_CONFIG_0(0), 239 NETXEN_NIU_GB_MAC_CONFIG_0(0), mac_cfg0))
253 &mac_cfg0, 4))
254 return -EIO; 240 return -EIO;
255 241
256 return result; 242 return result;
@@ -473,12 +459,10 @@ static int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
473 if ((phy < 0) || (phy > 3)) 459 if ((phy < 0) || (phy > 3))
474 return -EINVAL; 460 return -EINVAL;
475 461
476 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), 462 stationhigh = adapter->hw_read_wx(adapter,
477 &stationhigh, 4)) 463 NETXEN_NIU_GB_STATION_ADDR_0(phy));
478 return -EIO; 464 stationlow = adapter->hw_read_wx(adapter,
479 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), 465 NETXEN_NIU_GB_STATION_ADDR_1(phy));
480 &stationlow, 4))
481 return -EIO;
482 ((__le32 *)val)[1] = cpu_to_le32(stationhigh); 466 ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
483 ((__le32 *)val)[0] = cpu_to_le32(stationlow); 467 ((__le32 *)val)[0] = cpu_to_le32(stationlow);
484 468
@@ -508,13 +492,13 @@ int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
508 memcpy(temp + 2, addr, 2); 492 memcpy(temp + 2, addr, 2);
509 val = le32_to_cpu(*(__le32 *)temp); 493 val = le32_to_cpu(*(__le32 *)temp);
510 if (adapter->hw_write_wx(adapter, 494 if (adapter->hw_write_wx(adapter,
511 NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4)) 495 NETXEN_NIU_GB_STATION_ADDR_1(phy), val))
512 return -EIO; 496 return -EIO;
513 497
514 memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32)); 498 memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32));
515 val = le32_to_cpu(*(__le32 *)temp); 499 val = le32_to_cpu(*(__le32 *)temp);
516 if (adapter->hw_write_wx(adapter, 500 if (adapter->hw_write_wx(adapter,
517 NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4)) 501 NETXEN_NIU_GB_STATION_ADDR_0(phy), val))
518 return -2; 502 return -2;
519 503
520 netxen_niu_macaddr_get(adapter, 504 netxen_niu_macaddr_get(adapter,
@@ -545,8 +529,8 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter)
545 return -EINVAL; 529 return -EINVAL;
546 mac_cfg0 = 0; 530 mac_cfg0 = 0;
547 netxen_gb_soft_reset(mac_cfg0); 531 netxen_gb_soft_reset(mac_cfg0);
548 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), 532 if (adapter->hw_write_wx(adapter,
549 &mac_cfg0, 4)) 533 NETXEN_NIU_GB_MAC_CONFIG_0(port), mac_cfg0))
550 return -EIO; 534 return -EIO;
551 return 0; 535 return 0;
552} 536}
@@ -565,7 +549,7 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
565 549
566 mac_cfg = 0; 550 mac_cfg = 0;
567 if (adapter->hw_write_wx(adapter, 551 if (adapter->hw_write_wx(adapter,
568 NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), &mac_cfg, 4)) 552 NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), mac_cfg))
569 return -EIO; 553 return -EIO;
570 return 0; 554 return 0;
571} 555}
@@ -581,9 +565,7 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
581 return -EINVAL; 565 return -EINVAL;
582 566
583 /* save previous contents */ 567 /* save previous contents */
584 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR, 568 reg = adapter->hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR);
585 &reg, 4))
586 return -EIO;
587 if (mode == NETXEN_NIU_PROMISC_MODE) { 569 if (mode == NETXEN_NIU_PROMISC_MODE) {
588 switch (port) { 570 switch (port) {
589 case 0: 571 case 0:
@@ -619,8 +601,7 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
619 return -EIO; 601 return -EIO;
620 } 602 }
621 } 603 }
622 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR, 604 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR, reg))
623 &reg, 4))
624 return -EIO; 605 return -EIO;
625 return 0; 606 return 0;
626} 607}
@@ -647,28 +628,28 @@ int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
647 case 0: 628 case 0:
648 memcpy(temp + 2, addr, 2); 629 memcpy(temp + 2, addr, 2);
649 val = le32_to_cpu(*(__le32 *)temp); 630 val = le32_to_cpu(*(__le32 *)temp);
650 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1, 631 if (adapter->hw_write_wx(adapter,
651 &val, 4)) 632 NETXEN_NIU_XGE_STATION_ADDR_0_1, val))
652 return -EIO; 633 return -EIO;
653 634
654 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); 635 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
655 val = le32_to_cpu(*(__le32 *)temp); 636 val = le32_to_cpu(*(__le32 *)temp);
656 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI, 637 if (adapter->hw_write_wx(adapter,
657 &val, 4)) 638 NETXEN_NIU_XGE_STATION_ADDR_0_HI, val))
658 return -EIO; 639 return -EIO;
659 break; 640 break;
660 641
661 case 1: 642 case 1:
662 memcpy(temp + 2, addr, 2); 643 memcpy(temp + 2, addr, 2);
663 val = le32_to_cpu(*(__le32 *)temp); 644 val = le32_to_cpu(*(__le32 *)temp);
664 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_1, 645 if (adapter->hw_write_wx(adapter,
665 &val, 4)) 646 NETXEN_NIU_XG1_STATION_ADDR_0_1, val))
666 return -EIO; 647 return -EIO;
667 648
668 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); 649 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
669 val = le32_to_cpu(*(__le32 *)temp); 650 val = le32_to_cpu(*(__le32 *)temp);
670 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_HI, 651 if (adapter->hw_write_wx(adapter,
671 &val, 4)) 652 NETXEN_NIU_XG1_STATION_ADDR_0_HI, val))
672 return -EIO; 653 return -EIO;
673 break; 654 break;
674 655
@@ -689,9 +670,8 @@ int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
689 if (port > NETXEN_NIU_MAX_XG_PORTS) 670 if (port > NETXEN_NIU_MAX_XG_PORTS)
690 return -EINVAL; 671 return -EINVAL;
691 672
692 if (adapter->hw_read_wx(adapter, 673 reg = adapter->hw_read_wx(adapter,
693 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), &reg, 4)) 674 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port));
694 return -EIO;
695 if (mode == NETXEN_NIU_PROMISC_MODE) 675 if (mode == NETXEN_NIU_PROMISC_MODE)
696 reg = (reg | 0x2000UL); 676 reg = (reg | 0x2000UL);
697 else 677 else