2 * Copyright (C) 2003 - 2006 NetXen, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
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
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
23 * Contact Information:
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
30 * Provides access to the Network Interface Unit h/w block.
34 #include "netxen_nic.h"
36 #define NETXEN_GB_MAC_SOFT_RESET 0x80000000
37 #define NETXEN_GB_MAC_RESET_PROT_BLK 0x000F0000
38 #define NETXEN_GB_MAC_ENABLE_TX_RX 0x00000005
39 #define NETXEN_GB_MAC_PAUSED_FRMS 0x00000020
41 static long phy_lock_timeout = 100000000;
43 static int phy_lock(struct netxen_adapter *adapter)
46 int done = 0, timeout = 0;
49 done = netxen_nic_reg_read(adapter,
50 NETXEN_PCIE_REG(PCIE_SEM3_LOCK));
53 if (timeout >= phy_lock_timeout) {
60 for (i = 0; i < 20; i++)
65 netxen_crb_writelit_adapter(adapter,
66 NETXEN_PHY_LOCK_ID, PHY_LOCK_DRIVER);
70 static int phy_unlock(struct netxen_adapter *adapter)
72 adapter->pci_read_immediate(adapter, NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK));
78 * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
79 * mii management interface.
81 * Note: The MII management interface goes through port 0.
82 * Individual phys are addressed as follows:
83 * @param phy [15:8] phy id
84 * @param reg [7:0] register number
86 * @returns 0 on success
90 int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
96 long phy = adapter->physical_port;
102 if (phy_lock(adapter) != 0) {
107 * MII mgmt all goes through port 0 MAC interface,
108 * so it cannot be in reset
111 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
114 if (netxen_gb_get_soft_reset(mac_cfg0)) {
117 netxen_gb_tx_reset_pb(temp);
118 netxen_gb_rx_reset_pb(temp);
119 netxen_gb_tx_reset_mac(temp);
120 netxen_gb_rx_reset_mac(temp);
121 if (adapter->hw_write_wx(adapter,
122 NETXEN_NIU_GB_MAC_CONFIG_0(0),
129 netxen_gb_mii_mgmt_reg_addr(address, reg);
130 netxen_gb_mii_mgmt_phy_addr(address, phy);
131 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
134 command = 0; /* turn off any prior activity */
135 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
138 /* send read command */
139 netxen_gb_mii_mgmt_set_read_cycle(command);
140 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
146 if (adapter->hw_read_wx(adapter,
147 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
151 } while ((netxen_get_gb_mii_mgmt_busy(status)
152 || netxen_get_gb_mii_mgmt_notvalid(status))
153 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
155 if (timeout < NETXEN_NIU_PHY_WAITMAX) {
156 if (adapter->hw_read_wx(adapter,
157 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
165 if (adapter->hw_write_wx(adapter,
166 NETXEN_NIU_GB_MAC_CONFIG_0(0),
174 * netxen_niu_gbe_phy_write - write a register to the GbE PHY via
175 * mii management interface.
177 * Note: The MII management interface goes through port 0.
178 * Individual phys are addressed as follows:
179 * @param phy [15:8] phy id
180 * @param reg [7:0] register number
182 * @returns 0 on success
186 int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
192 long phy = adapter->physical_port;
199 * MII mgmt all goes through port 0 MAC interface, so it
203 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
206 if (netxen_gb_get_soft_reset(mac_cfg0)) {
209 netxen_gb_tx_reset_pb(temp);
210 netxen_gb_rx_reset_pb(temp);
211 netxen_gb_tx_reset_mac(temp);
212 netxen_gb_rx_reset_mac(temp);
214 if (adapter->hw_write_wx(adapter,
215 NETXEN_NIU_GB_MAC_CONFIG_0(0),
221 command = 0; /* turn off any prior activity */
222 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
227 netxen_gb_mii_mgmt_reg_addr(address, reg);
228 netxen_gb_mii_mgmt_phy_addr(address, phy);
229 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
233 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0),
239 if (adapter->hw_read_wx(adapter,
240 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
244 } while ((netxen_get_gb_mii_mgmt_busy(status))
245 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
247 if (timeout < NETXEN_NIU_PHY_WAITMAX)
252 /* restore the state of port 0 MAC in case we tampered with it */
254 if (adapter->hw_write_wx(adapter,
255 NETXEN_NIU_GB_MAC_CONFIG_0(0),
262 int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter)
264 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f);
268 int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter)
272 netxen_set_phy_int_link_status_changed(enable);
273 netxen_set_phy_int_autoneg_completed(enable);
274 netxen_set_phy_int_speed_changed(enable);
277 netxen_niu_gbe_phy_write(adapter,
278 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE,
285 int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter)
287 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f);
291 int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter)
295 netxen_niu_gbe_phy_write(adapter,
296 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE, 0))
303 int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter)
305 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_ACTIVE_INT, -1);
310 static int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter)
314 netxen_niu_gbe_phy_write(adapter,
315 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
323 * netxen_niu_gbe_set_mii_mode- Set 10/100 Mbit Mode for GbE MAC
326 static void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter,
327 int port, long enable)
329 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
330 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
332 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
334 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
336 netxen_crb_writelit_adapter(adapter,
337 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 0);
338 netxen_crb_writelit_adapter(adapter,
339 NETXEN_NIU_GB0_MII_MODE + (port << 3), 1);
340 netxen_crb_writelit_adapter(adapter,
341 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
342 netxen_crb_writelit_adapter(adapter,
343 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
347 * Do NOT enable flow control until a suitable solution for
348 * shutting down pause frames is found.
350 netxen_crb_writelit_adapter(adapter,
351 NETXEN_NIU_GB_MAC_CONFIG_0(port),
355 if (netxen_niu_gbe_enable_phy_interrupts(adapter))
356 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
357 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
358 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
362 * netxen_niu_gbe_set_gmii_mode- Set GbE Mode for GbE MAC
364 static void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter,
365 int port, long enable)
367 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
368 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
370 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
372 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
374 netxen_crb_writelit_adapter(adapter,
375 NETXEN_NIU_GB0_MII_MODE + (port << 3), 0);
376 netxen_crb_writelit_adapter(adapter,
377 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 1);
378 netxen_crb_writelit_adapter(adapter,
379 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
380 netxen_crb_writelit_adapter(adapter,
381 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
385 * Do NOT enable flow control until a suitable solution for
386 * shutting down pause frames is found.
388 netxen_crb_writelit_adapter(adapter,
389 NETXEN_NIU_GB_MAC_CONFIG_0(port),
393 if (netxen_niu_gbe_enable_phy_interrupts(adapter))
394 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
395 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
396 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
399 int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
404 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
407 if (adapter->disable_phy_interrupts)
408 adapter->disable_phy_interrupts(adapter);
411 if (0 == netxen_niu_gbe_phy_read(adapter,
412 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, &status)) {
413 if (netxen_get_phy_link(status)) {
414 if (netxen_get_phy_speed(status) == 2) {
415 netxen_niu_gbe_set_gmii_mode(adapter, port, 1);
416 } else if ((netxen_get_phy_speed(status) == 1)
417 || (netxen_get_phy_speed(status) == 0)) {
418 netxen_niu_gbe_set_mii_mode(adapter, port, 1);
425 * We don't have link. Cable must be unconnected.
426 * Enable phy interrupts so we take action when
430 netxen_crb_writelit_adapter(adapter,
431 NETXEN_NIU_GB_MAC_CONFIG_0
433 NETXEN_GB_MAC_SOFT_RESET);
434 netxen_crb_writelit_adapter(adapter,
435 NETXEN_NIU_GB_MAC_CONFIG_0
437 NETXEN_GB_MAC_RESET_PROT_BLK
438 | NETXEN_GB_MAC_ENABLE_TX_RX
440 NETXEN_GB_MAC_PAUSED_FRMS);
441 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
443 "ERROR clearing PHY interrupts\n");
444 if (netxen_niu_gbe_enable_phy_interrupts(adapter))
446 "ERROR enabling PHY interrupts\n");
447 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
449 "ERROR clearing PHY interrupts\n");
458 int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
460 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
461 netxen_crb_writelit_adapter(adapter,
462 NETXEN_NIU_XGE_CONFIG_1+(0x10000*port), 0x1447);
463 netxen_crb_writelit_adapter(adapter,
464 NETXEN_NIU_XGE_CONFIG_0+(0x10000*port), 0x5);
472 * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts
473 * @param enable 0 means don't enable the port
474 * 1 means enable (or re-enable) the port
476 int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter,
477 int port, long enable)
482 printk(KERN_INFO PFX "NETXEN: Handling PHY interrupt on port %d"
483 " (device enable = %d)\n", (int)port, (int)enable);
486 * The read of the PHY INT status will clear the pending
489 if (netxen_niu_gbe_phy_read(adapter,
490 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
494 printk(KERN_INFO PFX "PHY Interrupt source = 0x%x \n", int_src);
495 if (netxen_get_phy_int_jabber(int_src))
496 printk(KERN_INFO PFX "jabber Interrupt ");
497 if (netxen_get_phy_int_polarity_changed(int_src))
498 printk(KERN_INFO PFX "polarity changed ");
499 if (netxen_get_phy_int_energy_detect(int_src))
500 printk(KERN_INFO PFX "energy detect \n");
501 if (netxen_get_phy_int_downshift(int_src))
502 printk(KERN_INFO PFX "downshift \n");
503 if (netxen_get_phy_int_mdi_xover_changed(int_src))
504 printk(KERN_INFO PFX "mdi_xover_changed ");
505 if (netxen_get_phy_int_fifo_over_underflow(int_src))
506 printk(KERN_INFO PFX "fifo_over_underflow ");
507 if (netxen_get_phy_int_false_carrier(int_src))
508 printk(KERN_INFO PFX "false_carrier ");
509 if (netxen_get_phy_int_symbol_error(int_src))
510 printk(KERN_INFO PFX "symbol_error ");
511 if (netxen_get_phy_int_autoneg_completed(int_src))
512 printk(KERN_INFO PFX "autoneg_completed ");
513 if (netxen_get_phy_int_page_received(int_src))
514 printk(KERN_INFO PFX "page_received ");
515 if (netxen_get_phy_int_duplex_changed(int_src))
516 printk(KERN_INFO PFX "duplex_changed ");
517 if (netxen_get_phy_int_autoneg_error(int_src))
518 printk(KERN_INFO PFX "autoneg_error ");
519 if ((netxen_get_phy_int_speed_changed(int_src))
520 || (netxen_get_phy_int_link_status_changed(int_src))) {
524 "speed_changed or link status changed");
525 if (netxen_niu_gbe_phy_read
527 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
529 if (netxen_get_phy_speed(status) == 2) {
531 (KERN_INFO PFX "Link speed changed"
533 netxen_niu_gbe_set_gmii_mode(adapter,
536 } else if (netxen_get_phy_speed(status) == 1) {
538 (KERN_INFO PFX "Link speed changed"
540 netxen_niu_gbe_set_mii_mode(adapter,
543 } else if (netxen_get_phy_speed(status) == 0) {
545 (KERN_INFO PFX "Link speed changed"
547 netxen_niu_gbe_set_mii_mode(adapter,
551 printk(KERN_ERR PFX "ERROR reading "
552 "PHY status. Invalid speed.\n");
557 "ERROR reading PHY status.\n");
562 printk(KERN_INFO "\n");
569 * Return the current station MAC address.
570 * Note that the passed-in value must already be in network byte order.
572 static int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
573 netxen_ethernet_macaddr_t * addr)
577 int phy = adapter->physical_port;
582 if ((phy < 0) || (phy > 3))
585 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy),
588 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy),
591 ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
592 ((__le32 *)val)[0] = cpu_to_le32(stationlow);
594 memcpy(addr, val + 2, 6);
600 * Set the station MAC address.
601 * Note that the passed-in value must already be in network byte order.
603 int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
604 netxen_ethernet_macaddr_t addr)
608 int phy = adapter->physical_port;
609 unsigned char mac_addr[6];
611 DECLARE_MAC_BUF(mac);
613 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
616 for (i = 0; i < 10; i++) {
617 temp[0] = temp[1] = 0;
618 memcpy(temp + 2, addr, 2);
619 val = le32_to_cpu(*(__le32 *)temp);
620 if (adapter->hw_write_wx(adapter,
621 NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4))
624 memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32));
625 val = le32_to_cpu(*(__le32 *)temp);
626 if (adapter->hw_write_wx(adapter,
627 NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4))
630 netxen_niu_macaddr_get(adapter,
631 (netxen_ethernet_macaddr_t *) mac_addr);
632 if (memcmp(mac_addr, addr, 6) == 0)
637 printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
638 netxen_nic_driver_name, adapter->netdev->name);
639 printk(KERN_ERR "MAC address set: %s.\n",
640 print_mac(mac, addr));
641 printk(KERN_ERR "MAC address get: %s.\n",
642 print_mac(mac, mac_addr));
648 /* Enable a GbE interface */
649 int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter,
650 int port, netxen_niu_gbe_ifmode_t mode)
656 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
660 netxen_gb_soft_reset(mac_cfg0);
661 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
665 netxen_gb_enable_tx(mac_cfg0);
666 netxen_gb_enable_rx(mac_cfg0);
667 netxen_gb_unset_rx_flowctl(mac_cfg0);
668 netxen_gb_tx_reset_pb(mac_cfg0);
669 netxen_gb_rx_reset_pb(mac_cfg0);
670 netxen_gb_tx_reset_mac(mac_cfg0);
671 netxen_gb_rx_reset_mac(mac_cfg0);
673 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
677 netxen_gb_set_preamblelen(mac_cfg1, 0xf);
678 netxen_gb_set_duplex(mac_cfg1);
679 netxen_gb_set_crc_enable(mac_cfg1);
680 netxen_gb_set_padshort(mac_cfg1);
681 netxen_gb_set_checklength(mac_cfg1);
682 netxen_gb_set_hugeframes(mac_cfg1);
684 if (mode == NETXEN_NIU_10_100_MB) {
685 netxen_gb_set_intfmode(mac_cfg1, 1);
686 if (adapter->hw_write_wx(adapter,
687 NETXEN_NIU_GB_MAC_CONFIG_1(port),
692 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
694 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
697 } else if (mode == NETXEN_NIU_1000_MB) {
698 netxen_gb_set_intfmode(mac_cfg1, 2);
699 if (adapter->hw_write_wx(adapter,
700 NETXEN_NIU_GB_MAC_CONFIG_1(port),
704 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
706 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
710 netxen_gb_set_mii_mgmt_clockselect(mii_cfg, 7);
711 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(port),
715 netxen_gb_enable_tx(mac_cfg0);
716 netxen_gb_enable_rx(mac_cfg0);
717 netxen_gb_unset_rx_flowctl(mac_cfg0);
718 netxen_gb_unset_tx_flowctl(mac_cfg0);
720 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
727 /* Disable a GbE interface */
728 int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter)
731 u32 port = adapter->physical_port;
733 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
736 if (port > NETXEN_NIU_MAX_GBE_PORTS)
739 netxen_gb_soft_reset(mac_cfg0);
740 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
746 /* Disable an XG interface */
747 int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
750 u32 port = adapter->physical_port;
752 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
755 if (port > NETXEN_NIU_MAX_XG_PORTS)
759 if (adapter->hw_write_wx(adapter,
760 NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), &mac_cfg, 4))
765 /* Set promiscuous mode for a GbE interface */
766 int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
770 u32 port = adapter->physical_port;
772 if (port > NETXEN_NIU_MAX_GBE_PORTS)
775 /* save previous contents */
776 if (adapter->hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
779 if (mode == NETXEN_NIU_PROMISC_MODE) {
782 netxen_clear_gb_drop_gb0(reg);
785 netxen_clear_gb_drop_gb1(reg);
788 netxen_clear_gb_drop_gb2(reg);
791 netxen_clear_gb_drop_gb3(reg);
799 netxen_set_gb_drop_gb0(reg);
802 netxen_set_gb_drop_gb1(reg);
805 netxen_set_gb_drop_gb2(reg);
808 netxen_set_gb_drop_gb3(reg);
814 if (adapter->hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
821 * Set the MAC address for an XG port
822 * Note that the passed-in value must already be in network byte order.
824 int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
825 netxen_ethernet_macaddr_t addr)
827 int phy = adapter->physical_port;
831 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
834 if ((phy < 0) || (phy > NETXEN_NIU_MAX_XG_PORTS))
837 temp[0] = temp[1] = 0;
840 memcpy(temp + 2, addr, 2);
841 val = le32_to_cpu(*(__le32 *)temp);
842 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
846 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
847 val = le32_to_cpu(*(__le32 *)temp);
848 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
854 memcpy(temp + 2, addr, 2);
855 val = le32_to_cpu(*(__le32 *)temp);
856 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_1,
860 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
861 val = le32_to_cpu(*(__le32 *)temp);
862 if (adapter->hw_write_wx(adapter, NETXEN_NIU_XG1_STATION_ADDR_0_HI,
868 printk(KERN_ERR "Unknown port %d\n", phy);
877 * Return the current station MAC address.
878 * Note that the passed-in value must already be in network byte order.
880 int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter,
881 netxen_ethernet_macaddr_t * addr)
883 int phy = adapter->physical_port;
893 if (adapter->hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
896 if (adapter->hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
899 ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
900 ((__le32 *)val)[0] = cpu_to_le32(stationlow);
902 memcpy(addr, val + 2, 6);
908 int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
912 u32 port = adapter->physical_port;
914 if (port > NETXEN_NIU_MAX_XG_PORTS)
917 if (adapter->hw_read_wx(adapter,
918 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), ®, 4))
920 if (mode == NETXEN_NIU_PROMISC_MODE)
921 reg = (reg | 0x2000UL);
923 reg = (reg & ~0x2000UL);
925 if (mode == NETXEN_NIU_ALLMULTI_MODE)
926 reg = (reg | 0x1000UL);
928 reg = (reg & ~0x1000UL);
930 netxen_crb_writelit_adapter(adapter,
931 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), reg);