2006-10-21 15:33:03 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003 - 2006 NetXen, Inc.
|
|
|
|
* All rights reserved.
|
2006-12-04 12:18:00 -05:00
|
|
|
*
|
2006-10-21 15:33:03 -04:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-04-20 10:52:37 -04:00
|
|
|
*
|
2006-10-21 15:33:03 -04:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2007-04-20 10:52:37 -04:00
|
|
|
*
|
2006-10-21 15:33:03 -04:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
|
|
* MA 02111-1307, USA.
|
2006-12-04 12:18:00 -05:00
|
|
|
*
|
2006-10-21 15:33:03 -04:00
|
|
|
* The full GNU General Public License is included in this distribution
|
|
|
|
* in the file called LICENSE.
|
2006-12-04 12:18:00 -05:00
|
|
|
*
|
2006-10-21 15:33:03 -04:00
|
|
|
* Contact Information:
|
|
|
|
* info@netxen.com
|
|
|
|
* NetXen,
|
|
|
|
* 3965 Freedom Circle, Fourth floor,
|
|
|
|
* Santa Clara, CA 95054
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
#include "netxen_nic.h"
|
|
|
|
#include "netxen_nic_hw.h"
|
|
|
|
#include "netxen_nic_phan_reg.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* netxen_nic_get_stats - Get System Network Statistics
|
|
|
|
* @netdev: network interface device structure
|
|
|
|
*/
|
|
|
|
struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
|
|
|
|
{
|
2007-04-20 10:55:26 -04:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(netdev);
|
2007-04-20 10:52:37 -04:00
|
|
|
struct net_device_stats *stats = &adapter->net_stats;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
memset(stats, 0, sizeof(*stats));
|
|
|
|
|
|
|
|
/* total packets received */
|
2007-04-20 10:55:26 -04:00
|
|
|
stats->rx_packets = adapter->stats.no_rcv;
|
2006-10-21 15:33:03 -04:00
|
|
|
/* total packets transmitted */
|
2007-11-23 21:23:36 -05:00
|
|
|
stats->tx_packets = adapter->stats.xmitedframes +
|
2007-04-20 10:55:26 -04:00
|
|
|
adapter->stats.xmitfinished;
|
2006-10-21 15:33:03 -04:00
|
|
|
/* total bytes received */
|
2007-04-20 10:55:26 -04:00
|
|
|
stats->rx_bytes = adapter->stats.rxbytes;
|
2006-10-21 15:33:03 -04:00
|
|
|
/* total bytes transmitted */
|
2007-04-20 10:55:26 -04:00
|
|
|
stats->tx_bytes = adapter->stats.txbytes;
|
2006-10-21 15:33:03 -04:00
|
|
|
/* bad packets received */
|
2007-04-20 10:55:26 -04:00
|
|
|
stats->rx_errors = adapter->stats.rcvdbadskb;
|
2006-10-21 15:33:03 -04:00
|
|
|
/* packet transmit problems */
|
2007-04-20 10:55:26 -04:00
|
|
|
stats->tx_errors = adapter->stats.nocmddescriptor;
|
2006-10-21 15:33:03 -04:00
|
|
|
/* no space in linux buffers */
|
2008-03-17 22:59:51 -04:00
|
|
|
stats->rx_dropped = adapter->stats.rxdropped;
|
2006-10-21 15:33:03 -04:00
|
|
|
/* no space available in linux */
|
2007-04-20 10:55:26 -04:00
|
|
|
stats->tx_dropped = adapter->stats.txdropped;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
return stats;
|
|
|
|
}
|
2007-04-20 10:55:26 -04:00
|
|
|
|
2007-11-05 12:07:31 -05:00
|
|
|
static void netxen_indicate_link_status(struct netxen_adapter *adapter,
|
|
|
|
u32 link)
|
2006-10-21 15:33:03 -04:00
|
|
|
{
|
2007-04-20 10:52:37 -04:00
|
|
|
struct net_device *netdev = adapter->netdev;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
if (link)
|
|
|
|
netif_carrier_on(netdev);
|
|
|
|
else
|
|
|
|
netif_carrier_off(netdev);
|
|
|
|
}
|
|
|
|
|
2007-11-05 12:07:31 -05:00
|
|
|
#if 0
|
2007-04-20 10:52:37 -04:00
|
|
|
void netxen_handle_port_int(struct netxen_adapter *adapter, u32 enable)
|
2006-10-21 15:33:03 -04:00
|
|
|
{
|
2007-01-02 05:39:10 -05:00
|
|
|
__u32 int_src;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
/* This should clear the interrupt source */
|
2006-12-04 12:18:00 -05:00
|
|
|
if (adapter->phy_read)
|
2007-11-23 21:23:36 -05:00
|
|
|
adapter->phy_read(adapter,
|
2006-12-04 12:18:00 -05:00
|
|
|
NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
|
|
|
|
&int_src);
|
2006-10-21 15:33:03 -04:00
|
|
|
if (int_src == 0) {
|
|
|
|
DPRINTK(INFO, "No phy interrupts for port #%d\n", portno);
|
|
|
|
return;
|
|
|
|
}
|
2006-12-04 12:18:00 -05:00
|
|
|
if (adapter->disable_phy_interrupts)
|
2007-04-20 10:53:05 -04:00
|
|
|
adapter->disable_phy_interrupts(adapter);
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
if (netxen_get_phy_int_jabber(int_src))
|
2006-12-04 12:18:00 -05:00
|
|
|
DPRINTK(INFO, "Jabber interrupt \n");
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
if (netxen_get_phy_int_polarity_changed(int_src))
|
2006-12-04 12:18:00 -05:00
|
|
|
DPRINTK(INFO, "POLARITY CHANGED int \n");
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
if (netxen_get_phy_int_energy_detect(int_src))
|
2006-12-04 12:18:00 -05:00
|
|
|
DPRINTK(INFO, "ENERGY DETECT INT \n");
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
if (netxen_get_phy_int_downshift(int_src))
|
2006-12-04 12:18:00 -05:00
|
|
|
DPRINTK(INFO, "DOWNSHIFT INT \n");
|
2006-10-21 15:33:03 -04:00
|
|
|
/* write it down later.. */
|
|
|
|
if ((netxen_get_phy_int_speed_changed(int_src))
|
|
|
|
|| (netxen_get_phy_int_link_status_changed(int_src))) {
|
2007-01-02 05:39:10 -05:00
|
|
|
__u32 status;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2006-12-04 12:18:00 -05:00
|
|
|
DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n");
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2006-12-04 12:18:00 -05:00
|
|
|
if (adapter->phy_read
|
2007-11-23 21:23:36 -05:00
|
|
|
&& adapter->phy_read(adapter,
|
2006-12-04 12:18:00 -05:00
|
|
|
NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
|
|
|
|
&status) == 0) {
|
2006-10-21 15:33:03 -04:00
|
|
|
if (netxen_get_phy_int_link_status_changed(int_src)) {
|
|
|
|
if (netxen_get_phy_link(status)) {
|
2007-04-20 10:52:37 -04:00
|
|
|
printk(KERN_INFO "%s: %s Link UP\n",
|
2006-10-21 15:33:03 -04:00
|
|
|
netxen_nic_driver_name,
|
2007-04-20 10:52:37 -04:00
|
|
|
adapter->netdev->name);
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
} else {
|
2007-04-20 10:52:37 -04:00
|
|
|
printk(KERN_INFO "%s: %s Link DOWN\n",
|
2006-10-21 15:33:03 -04:00
|
|
|
netxen_nic_driver_name,
|
2007-04-20 10:52:37 -04:00
|
|
|
adapter->netdev->name);
|
2006-10-21 15:33:03 -04:00
|
|
|
}
|
2007-11-23 21:23:36 -05:00
|
|
|
netxen_indicate_link_status(adapter,
|
2006-10-21 15:33:03 -04:00
|
|
|
netxen_get_phy_link
|
|
|
|
(status));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-12-04 12:18:00 -05:00
|
|
|
if (adapter->enable_phy_interrupts)
|
2007-04-20 10:53:05 -04:00
|
|
|
adapter->enable_phy_interrupts(adapter);
|
2006-10-21 15:33:03 -04:00
|
|
|
}
|
2007-11-05 12:07:31 -05:00
|
|
|
#endif /* 0 */
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2007-11-05 12:07:31 -05:00
|
|
|
static void netxen_nic_isr_other(struct netxen_adapter *adapter)
|
2006-10-21 15:33:03 -04:00
|
|
|
{
|
2007-04-20 10:52:37 -04:00
|
|
|
int portno = adapter->portnum;
|
2006-11-29 12:00:10 -05:00
|
|
|
u32 val, linkup, qg_linksup;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
/* verify the offset */
|
2006-11-29 12:00:10 -05:00
|
|
|
val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
|
2007-04-20 10:55:26 -04:00
|
|
|
val = val >> physical_port[adapter->portnum];
|
2006-11-29 12:00:10 -05:00
|
|
|
if (val == adapter->ahw.qg_linksup)
|
|
|
|
return;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2006-11-29 12:00:10 -05:00
|
|
|
qg_linksup = adapter->ahw.qg_linksup;
|
|
|
|
adapter->ahw.qg_linksup = val;
|
2006-12-04 12:18:00 -05:00
|
|
|
DPRINTK(INFO, "link update 0x%08x\n", val);
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2007-04-20 10:52:37 -04:00
|
|
|
linkup = val & 1;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2007-04-20 10:52:37 -04:00
|
|
|
if (linkup != (qg_linksup & 1)) {
|
|
|
|
printk(KERN_INFO "%s: %s PORT %d link %s\n",
|
|
|
|
adapter->netdev->name,
|
|
|
|
netxen_nic_driver_name, portno,
|
|
|
|
((linkup == 0) ? "down" : "up"));
|
|
|
|
netxen_indicate_link_status(adapter, linkup);
|
|
|
|
if (linkup)
|
|
|
|
netxen_nic_set_link_parameters(adapter);
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2007-04-20 10:52:37 -04:00
|
|
|
}
|
2006-10-21 15:33:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter)
|
|
|
|
{
|
2006-11-29 12:00:10 -05:00
|
|
|
netxen_nic_isr_other(adapter);
|
2006-10-21 15:33:03 -04:00
|
|
|
}
|
|
|
|
|
2008-03-30 19:22:14 -04:00
|
|
|
#if 0
|
2007-06-11 06:30:58 -04:00
|
|
|
int netxen_nic_link_ok(struct netxen_adapter *adapter)
|
|
|
|
{
|
|
|
|
switch (adapter->ahw.board_type) {
|
|
|
|
case NETXEN_NIC_GBE:
|
|
|
|
return ((adapter->ahw.qg_linksup) & 1);
|
|
|
|
|
|
|
|
case NETXEN_NIC_XGBE:
|
|
|
|
return ((adapter->ahw.xg_linkup) & 1);
|
|
|
|
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR"%s: Function: %s, Unknown board type\n",
|
|
|
|
netxen_nic_driver_name, __FUNCTION__);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-30 19:22:14 -04:00
|
|
|
#endif /* 0 */
|
2007-06-11 06:30:58 -04:00
|
|
|
|
2006-10-21 15:33:03 -04:00
|
|
|
void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter)
|
|
|
|
{
|
2007-04-20 10:52:37 -04:00
|
|
|
struct net_device *netdev = adapter->netdev;
|
2008-03-17 22:59:49 -04:00
|
|
|
u32 val;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
|
|
|
/* WINDOW = 1 */
|
|
|
|
val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
|
2007-04-20 10:55:26 -04:00
|
|
|
val >>= (physical_port[adapter->portnum] * 8);
|
2008-03-17 22:59:49 -04:00
|
|
|
val &= 0xff;
|
2006-10-21 15:33:03 -04:00
|
|
|
|
2008-03-17 22:59:49 -04:00
|
|
|
if (adapter->ahw.xg_linkup == 1 && val != XG_LINK_UP) {
|
2006-10-21 15:33:03 -04:00
|
|
|
printk(KERN_INFO "%s: %s NIC Link is down\n",
|
|
|
|
netxen_nic_driver_name, netdev->name);
|
|
|
|
adapter->ahw.xg_linkup = 0;
|
2007-06-11 06:30:58 -04:00
|
|
|
if (netif_running(netdev)) {
|
|
|
|
netif_carrier_off(netdev);
|
|
|
|
netif_stop_queue(netdev);
|
|
|
|
}
|
2008-03-17 22:59:49 -04:00
|
|
|
} else if (adapter->ahw.xg_linkup == 0 && val == XG_LINK_UP) {
|
2006-10-21 15:33:03 -04:00
|
|
|
printk(KERN_INFO "%s: %s NIC Link is up\n",
|
|
|
|
netxen_nic_driver_name, netdev->name);
|
|
|
|
adapter->ahw.xg_linkup = 1;
|
2007-06-11 06:30:58 -04:00
|
|
|
netif_carrier_on(netdev);
|
|
|
|
netif_wake_queue(netdev);
|
2006-10-21 15:33:03 -04:00
|
|
|
}
|
|
|
|
}
|