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 phy
,
92 long reg
, __u32
* readval
)
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 (netxen_nic_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 (netxen_nic_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 (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
134 command
= 0; /* turn off any prior activity */
135 if (netxen_nic_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 (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
146 if (netxen_nic_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 (netxen_nic_hw_read_wx(adapter
,
157 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
165 if (netxen_nic_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
,
187 long phy
, long reg
, __u32 val
)
198 * MII mgmt all goes through port 0 MAC interface, so it
202 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(0),
205 if (netxen_gb_get_soft_reset(mac_cfg0
)) {
208 netxen_gb_tx_reset_pb(temp
);
209 netxen_gb_rx_reset_pb(temp
);
210 netxen_gb_tx_reset_mac(temp
);
211 netxen_gb_rx_reset_mac(temp
);
213 if (netxen_nic_hw_write_wx(adapter
,
214 NETXEN_NIU_GB_MAC_CONFIG_0(0),
220 command
= 0; /* turn off any prior activity */
221 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
226 netxen_gb_mii_mgmt_reg_addr(address
, reg
);
227 netxen_gb_mii_mgmt_phy_addr(address
, phy
);
228 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
232 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_CTRL(0),
238 if (netxen_nic_hw_read_wx(adapter
,
239 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
243 } while ((netxen_get_gb_mii_mgmt_busy(status
))
244 && (timeout
++ < NETXEN_NIU_PHY_WAITMAX
));
246 if (timeout
< NETXEN_NIU_PHY_WAITMAX
)
251 /* restore the state of port 0 MAC in case we tampered with it */
253 if (netxen_nic_hw_write_wx(adapter
,
254 NETXEN_NIU_GB_MAC_CONFIG_0(0),
261 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
,
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
, port
,
279 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE
,
286 int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter
*adapter
,
289 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_INT_MASK
, 0x7f);
293 int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter
*adapter
,
298 netxen_niu_gbe_phy_write(adapter
, port
,
299 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE
, 0))
305 int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter
*adapter
,
308 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_ACTIVE_INT
, -1);
312 int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter
*adapter
,
317 netxen_niu_gbe_phy_write(adapter
, port
,
318 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS
,
326 * netxen_niu_gbe_set_mii_mode- Set 10/100 Mbit Mode for GbE MAC
329 void netxen_niu_gbe_set_mii_mode(struct netxen_adapter
*adapter
,
330 int port
, long enable
)
332 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_MODE
, 0x2);
333 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
335 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
337 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB_MAC_CONFIG_1(port
),
339 netxen_crb_writelit_adapter(adapter
,
340 NETXEN_NIU_GB0_GMII_MODE
+ (port
<< 3), 0);
341 netxen_crb_writelit_adapter(adapter
,
342 NETXEN_NIU_GB0_MII_MODE
+ (port
<< 3), 1);
343 netxen_crb_writelit_adapter(adapter
,
344 (NETXEN_NIU_GB0_HALF_DUPLEX
+ port
* 4), 0);
345 netxen_crb_writelit_adapter(adapter
,
346 NETXEN_NIU_GB_MII_MGMT_CONFIG(port
), 0x7);
350 * Do NOT enable flow control until a suitable solution for
351 * shutting down pause frames is found.
353 netxen_crb_writelit_adapter(adapter
,
354 NETXEN_NIU_GB_MAC_CONFIG_0(port
),
358 if (netxen_niu_gbe_enable_phy_interrupts(adapter
, port
))
359 printk(KERN_ERR PFX
"ERROR enabling PHY interrupts\n");
360 if (netxen_niu_gbe_clear_phy_interrupts(adapter
, port
))
361 printk(KERN_ERR PFX
"ERROR clearing PHY interrupts\n");
365 * netxen_niu_gbe_set_gmii_mode- Set GbE Mode for GbE MAC
367 void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter
*adapter
,
368 int port
, long enable
)
370 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_MODE
, 0x2);
371 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
373 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
375 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB_MAC_CONFIG_1(port
),
377 netxen_crb_writelit_adapter(adapter
,
378 NETXEN_NIU_GB0_MII_MODE
+ (port
<< 3), 0);
379 netxen_crb_writelit_adapter(adapter
,
380 NETXEN_NIU_GB0_GMII_MODE
+ (port
<< 3), 1);
381 netxen_crb_writelit_adapter(adapter
,
382 (NETXEN_NIU_GB0_HALF_DUPLEX
+ port
* 4), 0);
383 netxen_crb_writelit_adapter(adapter
,
384 NETXEN_NIU_GB_MII_MGMT_CONFIG(port
), 0x7);
388 * Do NOT enable flow control until a suitable solution for
389 * shutting down pause frames is found.
391 netxen_crb_writelit_adapter(adapter
,
392 NETXEN_NIU_GB_MAC_CONFIG_0(port
),
396 if (netxen_niu_gbe_enable_phy_interrupts(adapter
, port
))
397 printk(KERN_ERR PFX
"ERROR enabling PHY interrupts\n");
398 if (netxen_niu_gbe_clear_phy_interrupts(adapter
, port
))
399 printk(KERN_ERR PFX
"ERROR clearing PHY interrupts\n");
402 int netxen_niu_gbe_init_port(struct netxen_adapter
*adapter
, int port
)
406 if (adapter
->disable_phy_interrupts
)
407 adapter
->disable_phy_interrupts(adapter
, port
);
411 netxen_niu_gbe_phy_read(adapter
, port
,
412 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
414 if (netxen_get_phy_link(status
)) {
415 if (netxen_get_phy_speed(status
) == 2) {
416 netxen_niu_gbe_set_gmii_mode(adapter
, port
, 1);
417 } else if ((netxen_get_phy_speed(status
) == 1)
418 || (netxen_get_phy_speed(status
) == 0)) {
419 netxen_niu_gbe_set_mii_mode(adapter
, port
, 1);
426 * We don't have link. Cable must be unconnected.
427 * Enable phy interrupts so we take action when
431 netxen_crb_writelit_adapter(adapter
,
432 NETXEN_NIU_GB_MAC_CONFIG_0
434 NETXEN_GB_MAC_SOFT_RESET
);
435 netxen_crb_writelit_adapter(adapter
,
436 NETXEN_NIU_GB_MAC_CONFIG_0
438 NETXEN_GB_MAC_RESET_PROT_BLK
439 | NETXEN_GB_MAC_ENABLE_TX_RX
441 NETXEN_GB_MAC_PAUSED_FRMS
);
442 if (netxen_niu_gbe_clear_phy_interrupts(adapter
, port
))
444 "ERROR clearing PHY interrupts\n");
445 if (netxen_niu_gbe_enable_phy_interrupts(adapter
, port
))
447 "ERROR enabling PHY interrupts\n");
448 if (netxen_niu_gbe_clear_phy_interrupts(adapter
, port
))
450 "ERROR clearing PHY interrupts\n");
459 int netxen_niu_xg_init_port(struct netxen_adapter
*adapter
, int port
)
461 long reg
= 0, ret
= 0;
463 if (adapter
->ahw
.boardcfg
.board_type
== NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
) {
464 netxen_crb_writelit_adapter(adapter
,
465 NETXEN_NIU_XG1_CONFIG_0
, 0x5);
466 /* XXX hack for Mez cards: both ports in promisc mode */
467 netxen_nic_hw_read_wx(adapter
,
468 NETXEN_NIU_XGE_CONFIG_1
, ®
, 4);
469 reg
= (reg
| 0x2000UL
);
470 netxen_crb_writelit_adapter(adapter
,
471 NETXEN_NIU_XGE_CONFIG_1
, reg
);
473 netxen_nic_hw_read_wx(adapter
,
474 NETXEN_NIU_XG1_CONFIG_1
, ®
, 4);
475 reg
= (reg
| 0x2000UL
);
476 netxen_crb_writelit_adapter(adapter
,
477 NETXEN_NIU_XG1_CONFIG_1
, reg
);
484 * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts
485 * @param enable 0 means don't enable the port
486 * 1 means enable (or re-enable) the port
488 int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter
*adapter
,
489 int port
, long enable
)
494 printk(KERN_INFO PFX
"NETXEN: Handling PHY interrupt on port %d"
495 " (device enable = %d)\n", (int)port
, (int)enable
);
498 * The read of the PHY INT status will clear the pending
501 if (netxen_niu_gbe_phy_read(adapter
, port
,
502 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS
,
506 printk(KERN_INFO PFX
"PHY Interrupt source = 0x%x \n", int_src
);
507 if (netxen_get_phy_int_jabber(int_src
))
508 printk(KERN_INFO PFX
"jabber Interrupt ");
509 if (netxen_get_phy_int_polarity_changed(int_src
))
510 printk(KERN_INFO PFX
"polarity changed ");
511 if (netxen_get_phy_int_energy_detect(int_src
))
512 printk(KERN_INFO PFX
"energy detect \n");
513 if (netxen_get_phy_int_downshift(int_src
))
514 printk(KERN_INFO PFX
"downshift \n");
515 if (netxen_get_phy_int_mdi_xover_changed(int_src
))
516 printk(KERN_INFO PFX
"mdi_xover_changed ");
517 if (netxen_get_phy_int_fifo_over_underflow(int_src
))
518 printk(KERN_INFO PFX
"fifo_over_underflow ");
519 if (netxen_get_phy_int_false_carrier(int_src
))
520 printk(KERN_INFO PFX
"false_carrier ");
521 if (netxen_get_phy_int_symbol_error(int_src
))
522 printk(KERN_INFO PFX
"symbol_error ");
523 if (netxen_get_phy_int_autoneg_completed(int_src
))
524 printk(KERN_INFO PFX
"autoneg_completed ");
525 if (netxen_get_phy_int_page_received(int_src
))
526 printk(KERN_INFO PFX
"page_received ");
527 if (netxen_get_phy_int_duplex_changed(int_src
))
528 printk(KERN_INFO PFX
"duplex_changed ");
529 if (netxen_get_phy_int_autoneg_error(int_src
))
530 printk(KERN_INFO PFX
"autoneg_error ");
531 if ((netxen_get_phy_int_speed_changed(int_src
))
532 || (netxen_get_phy_int_link_status_changed(int_src
))) {
536 "speed_changed or link status changed");
537 if (netxen_niu_gbe_phy_read
539 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
541 if (netxen_get_phy_speed(status
) == 2) {
543 (KERN_INFO PFX
"Link speed changed"
545 netxen_niu_gbe_set_gmii_mode(adapter
,
548 } else if (netxen_get_phy_speed(status
) == 1) {
550 (KERN_INFO PFX
"Link speed changed"
552 netxen_niu_gbe_set_mii_mode(adapter
,
555 } else if (netxen_get_phy_speed(status
) == 0) {
557 (KERN_INFO PFX
"Link speed changed"
559 netxen_niu_gbe_set_mii_mode(adapter
,
563 printk(KERN_ERR PFX
"ERROR reading"
564 "PHY status. Illegal speed.\n");
569 "ERROR reading PHY status.\n");
574 printk(KERN_INFO
"\n");
580 * Return the current station MAC address.
581 * Note that the passed-in value must already be in network byte order.
583 int netxen_niu_macaddr_get(struct netxen_adapter
*adapter
,
584 int phy
, netxen_ethernet_macaddr_t
* addr
)
592 if ((phy
< 0) || (phy
> 3))
595 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_STATION_ADDR_0(phy
),
598 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_STATION_ADDR_1(phy
),
601 ((__le32
*)val
)[1] = cpu_to_le32(stationhigh
);
602 ((__le32
*)val
)[0] = cpu_to_le32(stationlow
);
604 memcpy(addr
, val
+ 2, 6);
610 * Set the station MAC address.
611 * Note that the passed-in value must already be in network byte order.
613 int netxen_niu_macaddr_set(struct netxen_port
*port
,
614 netxen_ethernet_macaddr_t addr
)
618 struct netxen_adapter
*adapter
= port
->adapter
;
619 int phy
= port
->portnum
;
620 unsigned char mac_addr
[6];
623 for (i
= 0; i
< 10; i
++) {
624 temp
[0] = temp
[1] = 0;
625 memcpy(temp
+ 2, addr
, 2);
626 val
= le32_to_cpu(*(__le32
*)temp
);
627 if (netxen_nic_hw_write_wx
628 (adapter
, NETXEN_NIU_GB_STATION_ADDR_1(phy
), &val
, 4))
631 memcpy(temp
, ((u8
*) addr
) + 2, sizeof(__le32
));
632 val
= le32_to_cpu(*(__le32
*)temp
);
633 if (netxen_nic_hw_write_wx
634 (adapter
, NETXEN_NIU_GB_STATION_ADDR_0(phy
), &val
, 4))
637 netxen_niu_macaddr_get(adapter
, phy
,
638 (netxen_ethernet_macaddr_t
*) mac_addr
);
639 if (memcmp(mac_addr
, addr
, 6) == 0)
644 printk(KERN_ERR
"%s: cannot set Mac addr for %s\n",
645 netxen_nic_driver_name
, port
->netdev
->name
);
646 printk(KERN_ERR
"MAC address set: "
647 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
648 addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5]);
650 printk(KERN_ERR
"MAC address get: "
651 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
654 mac_addr
[2], mac_addr
[3], mac_addr
[4], mac_addr
[5]);
659 /* Enable a GbE interface */
660 int netxen_niu_enable_gbe_port(struct netxen_adapter
*adapter
,
661 int port
, netxen_niu_gbe_ifmode_t mode
)
667 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
671 netxen_gb_soft_reset(mac_cfg0
);
672 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
676 netxen_gb_enable_tx(mac_cfg0
);
677 netxen_gb_enable_rx(mac_cfg0
);
678 netxen_gb_unset_rx_flowctl(mac_cfg0
);
679 netxen_gb_tx_reset_pb(mac_cfg0
);
680 netxen_gb_rx_reset_pb(mac_cfg0
);
681 netxen_gb_tx_reset_mac(mac_cfg0
);
682 netxen_gb_rx_reset_mac(mac_cfg0
);
684 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
688 netxen_gb_set_preamblelen(mac_cfg1
, 0xf);
689 netxen_gb_set_duplex(mac_cfg1
);
690 netxen_gb_set_crc_enable(mac_cfg1
);
691 netxen_gb_set_padshort(mac_cfg1
);
692 netxen_gb_set_checklength(mac_cfg1
);
693 netxen_gb_set_hugeframes(mac_cfg1
);
695 if (mode
== NETXEN_NIU_10_100_MB
) {
696 netxen_gb_set_intfmode(mac_cfg1
, 1);
697 if (netxen_nic_hw_write_wx(adapter
,
698 NETXEN_NIU_GB_MAC_CONFIG_1(port
),
703 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_GMII_MODE
+
705 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_MII_MODE
+
708 } else if (mode
== NETXEN_NIU_1000_MB
) {
709 netxen_gb_set_intfmode(mac_cfg1
, 2);
710 if (netxen_nic_hw_write_wx(adapter
,
711 NETXEN_NIU_GB_MAC_CONFIG_1(port
),
715 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_MII_MODE
+
717 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_GB0_GMII_MODE
+
721 netxen_gb_set_mii_mgmt_clockselect(mii_cfg
, 7);
722 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MII_MGMT_CONFIG(port
),
726 netxen_gb_enable_tx(mac_cfg0
);
727 netxen_gb_enable_rx(mac_cfg0
);
728 netxen_gb_unset_rx_flowctl(mac_cfg0
);
729 netxen_gb_unset_tx_flowctl(mac_cfg0
);
731 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
737 /* Disable a GbE interface */
738 int netxen_niu_disable_gbe_port(struct netxen_adapter
*adapter
, int port
)
742 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
746 netxen_gb_soft_reset(mac_cfg0
);
747 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
753 /* Disable an XG interface */
754 int netxen_niu_disable_xg_port(struct netxen_adapter
*adapter
, int port
)
762 netxen_xg_soft_reset(mac_cfg
);
763 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_XGE_CONFIG_0
,
769 /* Set promiscuous mode for a GbE interface */
770 int netxen_niu_set_promiscuous_mode(struct netxen_adapter
*adapter
, int port
,
771 netxen_niu_prom_mode_t mode
)
775 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
778 /* save previous contents */
779 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_GB_DROP_WRONGADDR
,
782 if (mode
== NETXEN_NIU_PROMISC_MODE
) {
785 netxen_clear_gb_drop_gb0(reg
);
788 netxen_clear_gb_drop_gb1(reg
);
791 netxen_clear_gb_drop_gb2(reg
);
794 netxen_clear_gb_drop_gb3(reg
);
802 netxen_set_gb_drop_gb0(reg
);
805 netxen_set_gb_drop_gb1(reg
);
808 netxen_set_gb_drop_gb2(reg
);
811 netxen_set_gb_drop_gb3(reg
);
817 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_GB_DROP_WRONGADDR
,
824 * Set the MAC address for an XG port
825 * Note that the passed-in value must already be in network byte order.
827 int netxen_niu_xg_macaddr_set(struct netxen_port
*port
,
828 netxen_ethernet_macaddr_t addr
)
832 struct netxen_adapter
*adapter
= port
->adapter
;
834 temp
[0] = temp
[1] = 0;
835 memcpy(temp
+ 2, addr
, 2);
836 val
= le32_to_cpu(*(__le32
*)temp
);
837 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_1
,
841 memcpy(&temp
, ((u8
*) addr
) + 2, sizeof(__le32
));
842 val
= le32_to_cpu(*(__le32
*)temp
);
843 if (netxen_nic_hw_write_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_HI
,
851 * Return the current station MAC address.
852 * Note that the passed-in value must already be in network byte order.
854 int netxen_niu_xg_macaddr_get(struct netxen_adapter
*adapter
, int phy
,
855 netxen_ethernet_macaddr_t
* addr
)
866 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_HI
,
869 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_XGE_STATION_ADDR_0_1
,
872 ((__le32
*)val
)[1] = cpu_to_le32(stationhigh
);
873 ((__le32
*)val
)[0] = cpu_to_le32(stationlow
);
875 memcpy(addr
, val
+ 2, 6);
880 int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter
*adapter
,
881 int port
, netxen_niu_prom_mode_t mode
)
885 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
888 if (netxen_nic_hw_read_wx(adapter
, NETXEN_NIU_XGE_CONFIG_1
, ®
, 4))
890 if (mode
== NETXEN_NIU_PROMISC_MODE
)
891 reg
= (reg
| 0x2000UL
);
893 reg
= (reg
& ~0x2000UL
);
895 netxen_crb_writelit_adapter(adapter
, NETXEN_NIU_XGE_CONFIG_1
, reg
);