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 inline int phy_lock(struct netxen_adapter *adapter)
46 int done = 0, timeout = 0;
51 (adapter, NETXEN_PCIE_REG(PCIE_SEM3_LOCK)));
54 if (timeout >= phy_lock_timeout) {
61 for (i = 0; i < 20; i++)
66 writel(PHY_LOCK_DRIVER,
67 NETXEN_CRB_NORMALIZE(adapter, NETXEN_PHY_LOCK_ID));
71 static inline int phy_unlock(struct netxen_adapter *adapter)
73 readl(pci_base_offset(adapter, NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK)));
79 * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
80 * mii management interface.
82 * Note: The MII management interface goes through port 0.
83 * Individual phys are addressed as follows:
84 * @param phy [15:8] phy id
85 * @param reg [7:0] register number
87 * @returns 0 on success
91 int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
97 long phy = physical_port[adapter->portnum];
103 if (phy_lock(adapter) != 0) {
108 * MII mgmt all goes through port 0 MAC interface,
109 * so it cannot be in reset
112 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
115 if (netxen_gb_get_soft_reset(mac_cfg0)) {
118 netxen_gb_tx_reset_pb(temp);
119 netxen_gb_rx_reset_pb(temp);
120 netxen_gb_tx_reset_mac(temp);
121 netxen_gb_rx_reset_mac(temp);
122 if (netxen_nic_hw_write_wx(adapter,
123 NETXEN_NIU_GB_MAC_CONFIG_0(0),
130 netxen_gb_mii_mgmt_reg_addr(address, reg);
131 netxen_gb_mii_mgmt_phy_addr(address, phy);
132 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
135 command = 0; /* turn off any prior activity */
136 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
139 /* send read command */
140 netxen_gb_mii_mgmt_set_read_cycle(command);
141 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
147 if (netxen_nic_hw_read_wx(adapter,
148 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
152 } while ((netxen_get_gb_mii_mgmt_busy(status)
153 || netxen_get_gb_mii_mgmt_notvalid(status))
154 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
156 if (timeout < NETXEN_NIU_PHY_WAITMAX) {
157 if (netxen_nic_hw_read_wx(adapter,
158 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
166 if (netxen_nic_hw_write_wx(adapter,
167 NETXEN_NIU_GB_MAC_CONFIG_0(0),
175 * netxen_niu_gbe_phy_write - write a register to the GbE PHY via
176 * mii management interface.
178 * Note: The MII management interface goes through port 0.
179 * Individual phys are addressed as follows:
180 * @param phy [15:8] phy id
181 * @param reg [7:0] register number
183 * @returns 0 on success
187 int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
193 long phy = physical_port[adapter->portnum];
200 * MII mgmt all goes through port 0 MAC interface, so it
204 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
207 if (netxen_gb_get_soft_reset(mac_cfg0)) {
210 netxen_gb_tx_reset_pb(temp);
211 netxen_gb_rx_reset_pb(temp);
212 netxen_gb_tx_reset_mac(temp);
213 netxen_gb_rx_reset_mac(temp);
215 if (netxen_nic_hw_write_wx(adapter,
216 NETXEN_NIU_GB_MAC_CONFIG_0(0),
222 command = 0; /* turn off any prior activity */
223 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
228 netxen_gb_mii_mgmt_reg_addr(address, reg);
229 netxen_gb_mii_mgmt_phy_addr(address, phy);
230 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
234 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0),
240 if (netxen_nic_hw_read_wx(adapter,
241 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
245 } while ((netxen_get_gb_mii_mgmt_busy(status))
246 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
248 if (timeout < NETXEN_NIU_PHY_WAITMAX)
253 /* restore the state of port 0 MAC in case we tampered with it */
255 if (netxen_nic_hw_write_wx(adapter,
256 NETXEN_NIU_GB_MAC_CONFIG_0(0),
263 int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter)
265 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f);
269 int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter)
273 netxen_set_phy_int_link_status_changed(enable);
274 netxen_set_phy_int_autoneg_completed(enable);
275 netxen_set_phy_int_speed_changed(enable);
278 netxen_niu_gbe_phy_write(adapter,
279 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE,
286 int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter)
288 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f);
292 int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter)
296 netxen_niu_gbe_phy_write(adapter,
297 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);
309 int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter)
313 netxen_niu_gbe_phy_write(adapter,
314 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
322 * netxen_niu_gbe_set_mii_mode- Set 10/100 Mbit Mode for GbE MAC
325 void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter,
326 int port, long enable)
328 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
329 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
331 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
333 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
335 netxen_crb_writelit_adapter(adapter,
336 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 0);
337 netxen_crb_writelit_adapter(adapter,
338 NETXEN_NIU_GB0_MII_MODE + (port << 3), 1);
339 netxen_crb_writelit_adapter(adapter,
340 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
341 netxen_crb_writelit_adapter(adapter,
342 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
346 * Do NOT enable flow control until a suitable solution for
347 * shutting down pause frames is found.
349 netxen_crb_writelit_adapter(adapter,
350 NETXEN_NIU_GB_MAC_CONFIG_0(port),
354 if (netxen_niu_gbe_enable_phy_interrupts(adapter))
355 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
356 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
357 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
361 * netxen_niu_gbe_set_gmii_mode- Set GbE Mode for GbE MAC
363 void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter,
364 int port, long enable)
366 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
367 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
369 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
371 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
373 netxen_crb_writelit_adapter(adapter,
374 NETXEN_NIU_GB0_MII_MODE + (port << 3), 0);
375 netxen_crb_writelit_adapter(adapter,
376 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 1);
377 netxen_crb_writelit_adapter(adapter,
378 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
379 netxen_crb_writelit_adapter(adapter,
380 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
384 * Do NOT enable flow control until a suitable solution for
385 * shutting down pause frames is found.
387 netxen_crb_writelit_adapter(adapter,
388 NETXEN_NIU_GB_MAC_CONFIG_0(port),
392 if (netxen_niu_gbe_enable_phy_interrupts(adapter))
393 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
394 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
395 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
398 int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
402 if (adapter->disable_phy_interrupts)
403 adapter->disable_phy_interrupts(adapter);
407 netxen_niu_gbe_phy_read(adapter,
408 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
410 if (netxen_get_phy_link(status)) {
411 if (netxen_get_phy_speed(status) == 2) {
412 netxen_niu_gbe_set_gmii_mode(adapter, port, 1);
413 } else if ((netxen_get_phy_speed(status) == 1)
414 || (netxen_get_phy_speed(status) == 0)) {
415 netxen_niu_gbe_set_mii_mode(adapter, port, 1);
422 * We don't have link. Cable must be unconnected.
423 * Enable phy interrupts so we take action when
427 netxen_crb_writelit_adapter(adapter,
428 NETXEN_NIU_GB_MAC_CONFIG_0
430 NETXEN_GB_MAC_SOFT_RESET);
431 netxen_crb_writelit_adapter(adapter,
432 NETXEN_NIU_GB_MAC_CONFIG_0
434 NETXEN_GB_MAC_RESET_PROT_BLK
435 | NETXEN_GB_MAC_ENABLE_TX_RX
437 NETXEN_GB_MAC_PAUSED_FRMS);
438 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
440 "ERROR clearing PHY interrupts\n");
441 if (netxen_niu_gbe_enable_phy_interrupts(adapter))
443 "ERROR enabling PHY interrupts\n");
444 if (netxen_niu_gbe_clear_phy_interrupts(adapter))
446 "ERROR clearing PHY interrupts\n");
455 int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
458 u32 portnum = physical_port[adapter->portnum];
460 netxen_crb_writelit_adapter(adapter,
461 NETXEN_NIU_XGE_CONFIG_0+(0x10000*portnum), 0x5);
462 netxen_nic_hw_read_wx(adapter,
463 NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), ®, 4);
464 reg = (reg & ~0x2000UL);
465 netxen_crb_writelit_adapter(adapter,
466 NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), reg);
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. Illegal speed.\n");
557 "ERROR reading PHY status.\n");
562 printk(KERN_INFO "\n");
568 * Return the current station MAC address.
569 * Note that the passed-in value must already be in network byte order.
571 int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
572 netxen_ethernet_macaddr_t * addr)
576 int phy = physical_port[adapter->portnum];
581 if ((phy < 0) || (phy > 3))
584 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy),
587 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy),
590 ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
591 ((__le32 *)val)[0] = cpu_to_le32(stationlow);
593 memcpy(addr, val + 2, 6);
599 * Set the station MAC address.
600 * Note that the passed-in value must already be in network byte order.
602 int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
603 netxen_ethernet_macaddr_t addr)
607 int phy = physical_port[adapter->portnum];
608 unsigned char mac_addr[6];
611 for (i = 0; i < 10; i++) {
612 temp[0] = temp[1] = 0;
613 memcpy(temp + 2, addr, 2);
614 val = le32_to_cpu(*(__le32 *)temp);
615 if (netxen_nic_hw_write_wx
616 (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4))
619 memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32));
620 val = le32_to_cpu(*(__le32 *)temp);
621 if (netxen_nic_hw_write_wx
622 (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4))
625 netxen_niu_macaddr_get(adapter,
626 (netxen_ethernet_macaddr_t *) mac_addr);
627 if (memcmp(mac_addr, addr, 6) == 0)
632 printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
633 netxen_nic_driver_name, adapter->netdev->name);
634 printk(KERN_ERR "MAC address set: "
635 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
636 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
638 printk(KERN_ERR "MAC address get: "
639 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
642 mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
647 /* Enable a GbE interface */
648 int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter,
649 int port, netxen_niu_gbe_ifmode_t mode)
655 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
659 netxen_gb_soft_reset(mac_cfg0);
660 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
664 netxen_gb_enable_tx(mac_cfg0);
665 netxen_gb_enable_rx(mac_cfg0);
666 netxen_gb_unset_rx_flowctl(mac_cfg0);
667 netxen_gb_tx_reset_pb(mac_cfg0);
668 netxen_gb_rx_reset_pb(mac_cfg0);
669 netxen_gb_tx_reset_mac(mac_cfg0);
670 netxen_gb_rx_reset_mac(mac_cfg0);
672 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
676 netxen_gb_set_preamblelen(mac_cfg1, 0xf);
677 netxen_gb_set_duplex(mac_cfg1);
678 netxen_gb_set_crc_enable(mac_cfg1);
679 netxen_gb_set_padshort(mac_cfg1);
680 netxen_gb_set_checklength(mac_cfg1);
681 netxen_gb_set_hugeframes(mac_cfg1);
683 if (mode == NETXEN_NIU_10_100_MB) {
684 netxen_gb_set_intfmode(mac_cfg1, 1);
685 if (netxen_nic_hw_write_wx(adapter,
686 NETXEN_NIU_GB_MAC_CONFIG_1(port),
691 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
693 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
696 } else if (mode == NETXEN_NIU_1000_MB) {
697 netxen_gb_set_intfmode(mac_cfg1, 2);
698 if (netxen_nic_hw_write_wx(adapter,
699 NETXEN_NIU_GB_MAC_CONFIG_1(port),
703 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
705 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
709 netxen_gb_set_mii_mgmt_clockselect(mii_cfg, 7);
710 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(port),
714 netxen_gb_enable_tx(mac_cfg0);
715 netxen_gb_enable_rx(mac_cfg0);
716 netxen_gb_unset_rx_flowctl(mac_cfg0);
717 netxen_gb_unset_tx_flowctl(mac_cfg0);
719 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
725 /* Disable a GbE interface */
726 int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter)
729 u32 port = physical_port[adapter->portnum];
731 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
734 netxen_gb_soft_reset(mac_cfg0);
735 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
741 /* Disable an XG interface */
742 int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
745 u32 port = physical_port[adapter->portnum];
750 netxen_xg_soft_reset(mac_cfg);
751 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_CONFIG_0,
757 /* Set promiscuous mode for a GbE interface */
758 int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
759 netxen_niu_prom_mode_t mode)
762 u32 port = physical_port[adapter->portnum];
764 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
767 /* save previous contents */
768 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
771 if (mode == NETXEN_NIU_PROMISC_MODE) {
774 netxen_clear_gb_drop_gb0(reg);
777 netxen_clear_gb_drop_gb1(reg);
780 netxen_clear_gb_drop_gb2(reg);
783 netxen_clear_gb_drop_gb3(reg);
791 netxen_set_gb_drop_gb0(reg);
794 netxen_set_gb_drop_gb1(reg);
797 netxen_set_gb_drop_gb2(reg);
800 netxen_set_gb_drop_gb3(reg);
806 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
813 * Set the MAC address for an XG port
814 * Note that the passed-in value must already be in network byte order.
816 int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
817 netxen_ethernet_macaddr_t addr)
819 int phy = physical_port[adapter->portnum];
823 if ((phy < 0) || (phy > NETXEN_NIU_MAX_XG_PORTS))
826 temp[0] = temp[1] = 0;
829 memcpy(temp + 2, addr, 2);
830 val = le32_to_cpu(*(__le32 *)temp);
831 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
835 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
836 val = le32_to_cpu(*(__le32 *)temp);
837 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
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,
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,
857 printk(KERN_ERR "Unknown port %d\n", phy);
865 * Return the current station MAC address.
866 * Note that the passed-in value must already be in network byte order.
868 int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter,
869 netxen_ethernet_macaddr_t * addr)
871 int phy = physical_port[adapter->portnum];
881 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
884 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
887 ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
888 ((__le32 *)val)[0] = cpu_to_le32(stationlow);
890 memcpy(addr, val + 2, 6);
895 int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
896 netxen_niu_prom_mode_t mode)
899 u32 port = physical_port[adapter->portnum];
901 if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS))
904 if (netxen_nic_hw_read_wx(adapter,
905 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), ®, 4))
907 if (mode == NETXEN_NIU_PROMISC_MODE)
908 reg = (reg | 0x2000UL);
910 reg = (reg & ~0x2000UL);
912 netxen_crb_writelit_adapter(adapter,
913 NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), reg);