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(void)
46 int done
= 0, timeout
= 0;
49 done
= readl((void __iomem
*)NETXEN_PCIE_REG(PCIE_SEM3_LOCK
));
52 if (timeout
>= phy_lock_timeout
) {
59 for (i
= 0; i
< 20; i
++)
64 writel(NETXEN_PHY_LOCK_ID
, (void __iomem
*)PHY_LOCK_DRIVER
);
68 static inline int phy_unlock(void)
70 readl((void __iomem
*)NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK
));
75 * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
76 * mii management interface.
78 * Note: The MII management interface goes through port 0.
79 * Individual phys are addressed as follows:
80 * @param phy [15:8] phy id
81 * @param reg [7:0] register number
83 * @returns 0 on success
87 int netxen_niu_gbe_phy_read(struct netxen_adapter
*adapter
, long phy
,
88 long reg
, __le32
* readval
)
98 if (phy_lock() != 0) {
103 * MII mgmt all goes through port 0 MAC interface,
104 * so it cannot be in reset
107 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(0),
110 if (netxen_gb_get_soft_reset(mac_cfg0
)) {
113 netxen_gb_tx_reset_pb(temp
);
114 netxen_gb_rx_reset_pb(temp
);
115 netxen_gb_tx_reset_mac(temp
);
116 netxen_gb_rx_reset_mac(temp
);
117 if (netxen_nic_hw_write_wx(adapter
,
118 NETXEN_NIU_GB_MAC_CONFIG_0(0),
125 netxen_gb_mii_mgmt_reg_addr(address
, reg
);
126 netxen_gb_mii_mgmt_phy_addr(address
, phy
);
127 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
130 command
= 0; /* turn off any prior activity */
131 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
134 /* send read command */
135 netxen_gb_mii_mgmt_set_read_cycle(command
);
136 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
142 if (netxen_nic_hw_read_wx(adapter
,
143 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
147 } while ((netxen_get_gb_mii_mgmt_busy(status
)
148 || netxen_get_gb_mii_mgmt_notvalid(status
))
149 && (timeout
++ < NETXEN_NIU_PHY_WAITMAX
));
151 if (timeout
< NETXEN_NIU_PHY_WAITMAX
) {
152 if (netxen_nic_hw_read_wx(adapter
,
153 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
161 if (netxen_nic_hw_write_wx(adapter
,
162 NETXEN_NIU_GB_MAC_CONFIG_0(0),
170 * netxen_niu_gbe_phy_write - write a register to the GbE PHY via
171 * mii management interface.
173 * Note: The MII management interface goes through port 0.
174 * Individual phys are addressed as follows:
175 * @param phy [15:8] phy id
176 * @param reg [7:0] register number
178 * @returns 0 on success
182 int netxen_niu_gbe_phy_write(struct netxen_adapter
*adapter
,
183 long phy
, long reg
, __le32 val
)
194 * MII mgmt all goes through port 0 MAC interface, so it
198 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(0),
201 if (netxen_gb_get_soft_reset(mac_cfg0
)) {
204 netxen_gb_tx_reset_pb(temp
);
205 netxen_gb_rx_reset_pb(temp
);
206 netxen_gb_tx_reset_mac(temp
);
207 netxen_gb_rx_reset_mac(temp
);
209 if (netxen_nic_hw_write_wx(adapter
,
210 NETXEN_NIU_GB_MAC_CONFIG_0(0),
216 command
= 0; /* turn off any prior activity */
217 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
222 netxen_gb_mii_mgmt_reg_addr(address
, reg
);
223 netxen_gb_mii_mgmt_phy_addr(address
, phy
);
224 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
228 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_CTRL(0),
234 if (netxen_nic_hw_read_wx(adapter
,
235 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
239 } while ((netxen_get_gb_mii_mgmt_busy(status
))
240 && (timeout
++ < NETXEN_NIU_PHY_WAITMAX
));
242 if (timeout
< NETXEN_NIU_PHY_WAITMAX
)
247 /* restore the state of port 0 MAC in case we tampered with it */
249 if (netxen_nic_hw_write_wx(adapter
,
250 NETXEN_NIU_GB_MAC_CONFIG_0(0),
257 int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter
*adapter
,
260 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_INT_MASK
, 0x3f);
264 int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter
*adapter
,
269 netxen_set_phy_int_link_status_changed(enable
);
270 netxen_set_phy_int_autoneg_completed(enable
);
271 netxen_set_phy_int_speed_changed(enable
);
274 netxen_niu_gbe_phy_write(adapter
, port
,
275 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE
,
282 int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter
*adapter
,
285 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_INT_MASK
, 0x7f);
289 int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter
*adapter
,
294 netxen_niu_gbe_phy_write(adapter
, port
,
295 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE
, 0))
301 int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter
*adapter
,
304 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_ACTIVE_INT
, -1);
308 int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter
*adapter
,
313 netxen_niu_gbe_phy_write(adapter
, port
,
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
, port
))
355 printk(KERN_ERR PFX
"ERROR enabling PHY interrupts\n");
356 if (netxen_niu_gbe_clear_phy_interrupts(adapter
, port
))
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
, port
))
393 printk(KERN_ERR PFX
"ERROR enabling PHY interrupts\n");
394 if (netxen_niu_gbe_clear_phy_interrupts(adapter
, port
))
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
->ops
->disable_phy_interrupts
)
403 adapter
->ops
->disable_phy_interrupts(adapter
, port
);
407 netxen_niu_gbe_phy_read(adapter
, port
,
408 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
409 (__le32
*) & 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
, port
))
440 "ERROR clearing PHY interrupts\n");
441 if (netxen_niu_gbe_enable_phy_interrupts(adapter
, port
))
443 "ERROR enabling PHY interrupts\n");
444 if (netxen_niu_gbe_clear_phy_interrupts(adapter
, port
))
446 "ERROR clearing PHY interrupts\n");
455 int netxen_niu_xg_init_port(struct netxen_adapter
*adapter
, int port
)
457 long reg
= 0, ret
= 0;
459 if (adapter
->ahw
.boardcfg
.board_type
== NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
) {
460 netxen_crb_writelit_adapter(adapter
,
461 NETXEN_NIU_XG1_CONFIG_0
, 0x5);
462 /* XXX hack for Mez cards: both ports in promisc mode */
463 netxen_nic_hw_read_wx(adapter
,
464 NETXEN_NIU_XGE_CONFIG_1
, ®
, 4);
465 reg
= (reg
| 0x2000UL
);
466 netxen_crb_writelit_adapter(adapter
,
467 NETXEN_NIU_XGE_CONFIG_1
, reg
);
469 netxen_nic_hw_read_wx(adapter
,
470 NETXEN_NIU_XG1_CONFIG_1
, ®
, 4);
471 reg
= (reg
| 0x2000UL
);
472 netxen_crb_writelit_adapter(adapter
,
473 NETXEN_NIU_XG1_CONFIG_1
, reg
);
480 * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts
481 * @param enable 0 means don't enable the port
482 * 1 means enable (or re-enable) the port
484 int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter
*adapter
,
485 int port
, long enable
)
490 printk(KERN_INFO PFX
"NETXEN: Handling PHY interrupt on port %d"
491 " (device enable = %d)\n", (int)port
, (int)enable
);
494 * The read of the PHY INT status will clear the pending
497 if (netxen_niu_gbe_phy_read(adapter
, port
,
498 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS
,
502 printk(KERN_INFO PFX
"PHY Interrupt source = 0x%x \n", int_src
);
503 if (netxen_get_phy_int_jabber(int_src
))
504 printk(KERN_INFO PFX
"jabber Interrupt ");
505 if (netxen_get_phy_int_polarity_changed(int_src
))
506 printk(KERN_INFO PFX
"polarity changed ");
507 if (netxen_get_phy_int_energy_detect(int_src
))
508 printk(KERN_INFO PFX
"energy detect \n");
509 if (netxen_get_phy_int_downshift(int_src
))
510 printk(KERN_INFO PFX
"downshift \n");
511 if (netxen_get_phy_int_mdi_xover_changed(int_src
))
512 printk(KERN_INFO PFX
"mdi_xover_changed ");
513 if (netxen_get_phy_int_fifo_over_underflow(int_src
))
514 printk(KERN_INFO PFX
"fifo_over_underflow ");
515 if (netxen_get_phy_int_false_carrier(int_src
))
516 printk(KERN_INFO PFX
"false_carrier ");
517 if (netxen_get_phy_int_symbol_error(int_src
))
518 printk(KERN_INFO PFX
"symbol_error ");
519 if (netxen_get_phy_int_autoneg_completed(int_src
))
520 printk(KERN_INFO PFX
"autoneg_completed ");
521 if (netxen_get_phy_int_page_received(int_src
))
522 printk(KERN_INFO PFX
"page_received ");
523 if (netxen_get_phy_int_duplex_changed(int_src
))
524 printk(KERN_INFO PFX
"duplex_changed ");
525 if (netxen_get_phy_int_autoneg_error(int_src
))
526 printk(KERN_INFO PFX
"autoneg_error ");
527 if ((netxen_get_phy_int_speed_changed(int_src
))
528 || (netxen_get_phy_int_link_status_changed(int_src
))) {
532 "speed_changed or link status changed");
533 if (netxen_niu_gbe_phy_read
535 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
537 if (netxen_get_phy_speed(status
) == 2) {
539 (KERN_INFO PFX
"Link speed changed"
541 netxen_niu_gbe_set_gmii_mode(adapter
,
544 } else if (netxen_get_phy_speed(status
) == 1) {
546 (KERN_INFO PFX
"Link speed changed"
548 netxen_niu_gbe_set_mii_mode(adapter
,
551 } else if (netxen_get_phy_speed(status
) == 0) {
553 (KERN_INFO PFX
"Link speed changed"
555 netxen_niu_gbe_set_mii_mode(adapter
,
559 printk(KERN_ERR PFX
"ERROR reading"
560 "PHY status. Illegal speed.\n");
565 "ERROR reading PHY status.\n");
570 printk(KERN_INFO
"\n");
576 * Return the current station MAC address.
577 * Note that the passed-in value must already be in network byte order.
579 int netxen_niu_macaddr_get(struct netxen_adapter
*adapter
,
580 int phy
, netxen_ethernet_macaddr_t
* addr
)
588 if ((phy
< 0) || (phy
> 3))
591 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_STATION_ADDR_0(phy
),
594 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_STATION_ADDR_1(phy
),
598 result
= (u64
) netxen_gb_get_stationaddress_low(stationlow
);
599 result
|= (u64
) stationhigh
<< 16;
600 memcpy(*addr
, &result
, sizeof(netxen_ethernet_macaddr_t
));
606 * Set the station MAC address.
607 * Note that the passed-in value must already be in network byte order.
609 int netxen_niu_macaddr_set(struct netxen_port
*port
,
610 netxen_ethernet_macaddr_t addr
)
613 struct netxen_adapter
*adapter
= port
->adapter
;
614 int phy
= port
->portnum
;
615 unsigned char mac_addr
[MAX_ADDR_LEN
];
618 for (i
= 0; i
< 10; i
++) {
619 memcpy(&temp
, addr
, 2);
621 if (netxen_nic_hw_write_wx
622 (adapter
, NETXEN_NIU_GB_STATION_ADDR_1(phy
), &temp
, 4))
627 memcpy(&temp
, ((u8
*) addr
) + 2, sizeof(__le32
));
628 if (netxen_nic_hw_write_wx
629 (adapter
, NETXEN_NIU_GB_STATION_ADDR_0(phy
), &temp
, 4))
632 netxen_niu_macaddr_get(adapter
, phy
,
633 (netxen_ethernet_macaddr_t
*) mac_addr
);
634 if (memcmp(mac_addr
, addr
, MAX_ADDR_LEN
== 0))
639 printk(KERN_ERR
"%s: cannot set Mac addr for %s\n",
640 netxen_nic_driver_name
, port
->netdev
->name
);
641 printk(KERN_ERR
"MAC address set: "
642 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
643 addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5]);
645 printk(KERN_ERR
"MAC address get: "
646 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
649 mac_addr
[2], mac_addr
[3], mac_addr
[4], mac_addr
[5]);
654 /* Enable a GbE interface */
655 int netxen_niu_enable_gbe_port(struct netxen_adapter
*adapter
,
656 int port
, netxen_niu_gbe_ifmode_t mode
)
662 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
666 netxen_gb_soft_reset(mac_cfg0
);
667 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
671 netxen_gb_enable_tx(mac_cfg0
);
672 netxen_gb_enable_rx(mac_cfg0
);
673 netxen_gb_unset_rx_flowctl(mac_cfg0
);
674 netxen_gb_tx_reset_pb(mac_cfg0
);
675 netxen_gb_rx_reset_pb(mac_cfg0
);
676 netxen_gb_tx_reset_mac(mac_cfg0
);
677 netxen_gb_rx_reset_mac(mac_cfg0
);
679 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
683 netxen_gb_set_preamblelen(mac_cfg1
, 0xf);
684 netxen_gb_set_duplex(mac_cfg1
);
685 netxen_gb_set_crc_enable(mac_cfg1
);
686 netxen_gb_set_padshort(mac_cfg1
);
687 netxen_gb_set_checklength(mac_cfg1
);
688 netxen_gb_set_hugeframes(mac_cfg1
);
690 if (mode
== NETXEN_NIU_10_100_MB
) {
691 netxen_gb_set_intfmode(mac_cfg1
, 1);
692 if (netxen_nic_hw_write_wx(adapter
,
693 NETXEN_NIU_GB_MAC_CONFIG_1(port
),
698 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_GMII_MODE
+
700 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_MII_MODE
+
703 } else if (mode
== NETXEN_NIU_1000_MB
) {
704 netxen_gb_set_intfmode(mac_cfg1
, 2);
705 if (netxen_nic_hw_write_wx(adapter
,
706 NETXEN_NIU_GB_MAC_CONFIG_1(port
),
710 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_MII_MODE
+
712 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_GMII_MODE
+
716 netxen_gb_set_mii_mgmt_clockselect(mii_cfg
, 7);
717 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_CONFIG(port
),
721 netxen_gb_enable_tx(mac_cfg0
);
722 netxen_gb_enable_rx(mac_cfg0
);
723 netxen_gb_unset_rx_flowctl(mac_cfg0
);
724 netxen_gb_unset_tx_flowctl(mac_cfg0
);
726 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
732 /* Disable a GbE interface */
733 int netxen_niu_disable_gbe_port(struct netxen_adapter
*adapter
, int port
)
737 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
741 netxen_gb_soft_reset(mac_cfg0
);
742 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
748 /* Disable an XG interface */
749 int netxen_niu_disable_xg_port(struct netxen_adapter
*adapter
, int port
)
757 netxen_xg_soft_reset(mac_cfg
);
758 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_XGE_CONFIG_0
,
764 /* Set promiscuous mode for a GbE interface */
765 int netxen_niu_set_promiscuous_mode(struct netxen_adapter
*adapter
, int port
,
766 netxen_niu_prom_mode_t mode
)
770 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
773 /* save previous contents */
774 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_DROP_WRONGADDR
,
777 if (mode
== NETXEN_NIU_PROMISC_MODE
) {
780 netxen_clear_gb_drop_gb0(reg
);
783 netxen_clear_gb_drop_gb1(reg
);
786 netxen_clear_gb_drop_gb2(reg
);
789 netxen_clear_gb_drop_gb3(reg
);
797 netxen_set_gb_drop_gb0(reg
);
800 netxen_set_gb_drop_gb1(reg
);
803 netxen_set_gb_drop_gb2(reg
);
806 netxen_set_gb_drop_gb3(reg
);
812 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_DROP_WRONGADDR
,
819 * Set the MAC address for an XG port
820 * Note that the passed-in value must already be in network byte order.
822 int netxen_niu_xg_macaddr_set(struct netxen_port
*port
,
823 netxen_ethernet_macaddr_t addr
)
826 struct netxen_adapter
*adapter
= port
->adapter
;
828 memcpy(&temp
, addr
, 2);
829 temp
= cpu_to_le32(temp
);
831 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_1
,
837 memcpy(&temp
, ((u8
*) addr
) + 2, sizeof(__le32
));
838 temp
= cpu_to_le32(temp
);
839 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_HI
,
847 * Return the current station MAC address.
848 * Note that the passed-in value must already be in network byte order.
850 int netxen_niu_xg_macaddr_get(struct netxen_adapter
*adapter
, int phy
,
851 netxen_ethernet_macaddr_t
* addr
)
862 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_HI
,
865 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_1
,
869 result
= ((u64
) stationlow
) >> 16;
870 result
|= (u64
) stationhigh
<< 16;
871 memcpy(*addr
, &result
, sizeof(netxen_ethernet_macaddr_t
));
876 int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter
*adapter
,
877 int port
, netxen_niu_prom_mode_t mode
)
881 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
884 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_XGE_CONFIG_1
, ®
, 4))
886 if (mode
== NETXEN_NIU_PROMISC_MODE
)
887 reg
= (reg
| 0x2000UL
);
889 reg
= (reg
& ~0x2000UL
);
891 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_XGE_CONFIG_1
, reg
);