1 #include <linux/kernel.h>
3 #include <linux/types.h>
4 #include <linux/module.h>
5 #include <linux/list.h>
9 #include <linux/sched.h>
15 #include <linux/errno.h>
19 #include <linux/ipv6.h>
21 #include <linux/tcp.h>
22 #include <linux/udp.h>
23 #include <linux/if_arp.h>
24 #include <linux/if_ether.h>
25 #include <linux/netdevice.h>
27 #include <linux/ethtool.h>
29 #include <linux/rtnetlink.h>
30 #include <linux/if_vlan.h>
44 #define QL_SIZEOF(m) FIELD_SIZEOF(struct ql_adapter, m)
45 #define QL_OFF(m) offsetof(struct ql_adapter, m)
47 static const struct ql_stats ql_gstrings_stats[] = {
96 {
"rx_undersize_fcerr_pkts",
180 "Loopback test (offline)"
182 #define QLGE_TEST_LEN (sizeof(ql_gstrings_test) / ETH_GSTRING_LEN)
183 #define QLGE_STATS_LEN ARRAY_SIZE(ql_gstrings_stats)
185 static int ql_update_ring_coalescing(
struct ql_adapter *qdev)
191 if (!netif_running(qdev->
ndev))
203 cqicb = (
struct cqicb *)rx_ring;
212 "Failed to load CQICB.\n");
219 cqicb = (
struct cqicb *)&qdev->
rx_ring[0];
225 cqicb = (
struct cqicb *)rx_ring;
234 "Failed to load CQICB.\n");
243 static void ql_update_stats(
struct ql_adapter *qdev)
252 "Couldn't get xgmac sem.\n");
258 for (i = 0x200; i < 0x280; i += 8) {
261 "Error reading status register 0x%.04x.\n",
272 for (i = 0x300; i < 0x3d0; i += 8) {
275 "Error reading status register 0x%.04x.\n",
286 for (i = 0x500; i < 0x540; i += 8) {
289 "Error reading status register 0x%.04x.\n",
300 for (i = 0x568; i < 0x5a8; i += 8) {
303 "Error reading status register 0x%.04x.\n",
316 "Error reading status register 0x%.04x.\n", i);
338 ql_gstrings_stats[index].stat_string,
345 static int ql_get_sset_count(
struct net_device *dev,
int sset)
365 ql_update_stats(qdev);
367 for (index = 0; index <
length; index++) {
368 char *
p = (
char *)qdev +
369 ql_gstrings_stats[index].stat_offset;
375 static int ql_get_settings(
struct net_device *ndev,
401 static void ql_get_drvinfo(
struct net_device *ndev,
427 unsigned short ssys_dev = qdev->
pdev->subsystem_device;
440 unsigned short ssys_dev = qdev->
pdev->subsystem_device;
446 "WOL is only supported for mezz card\n");
457 static int ql_set_phys_id(
struct net_device *ndev,
484 static int ql_start_loopback(
struct ql_adapter *qdev)
486 if (netif_carrier_ok(qdev->
ndev)) {
495 static void ql_stop_loopback(
struct ql_adapter *qdev)
505 static void ql_create_lb_frame(
struct sk_buff *
skb,
506 unsigned int frame_size)
510 memset(&skb->
data[frame_size / 2], 0xAA, frame_size / 2 - 1);
511 memset(&skb->
data[frame_size / 2 + 10], 0xBE, 1);
512 memset(&skb->
data[frame_size / 2 + 12], 0xAF, 1);
518 unsigned int frame_size = skb->
len;
520 if ((*(skb->
data + 3) == 0xFF) &&
521 (*(skb->
data + frame_size / 2 + 10) == 0xBE) &&
522 (*(skb->
data + frame_size / 2 + 12) == 0xAF)) {
528 static int ql_run_loopback_test(
struct ql_adapter *qdev)
535 for (i = 0; i < 64; i++) {
536 skb = netdev_alloc_skb(qdev->
ndev, size);
542 ql_create_lb_frame(skb, size);
554 static int ql_loopback_test(
struct ql_adapter *qdev,
u64 *data)
556 *data = ql_start_loopback(qdev);
559 *data = ql_run_loopback_test(qdev);
561 ql_stop_loopback(qdev);
565 static void ql_self_test(
struct net_device *ndev,
572 if (netif_running(ndev)) {
576 if (ql_loopback_test(qdev, &data[0]))
590 "is down, Loopback test will fail.\n");
595 static int ql_get_regs_len(
struct net_device *ndev)
605 static void ql_get_regs(
struct net_device *ndev,
668 return ql_update_ring_coalescing(qdev);
671 static void ql_get_pauseparam(
struct net_device *netdev,
674 struct ql_adapter *qdev = netdev_priv(netdev);
683 static int ql_set_pauseparam(
struct net_device *netdev,
686 struct ql_adapter *qdev = netdev_priv(netdev);
713 .get_settings = ql_get_settings,
714 .get_drvinfo = ql_get_drvinfo,
715 .get_wol = ql_get_wol,
716 .set_wol = ql_set_wol,
717 .get_regs_len = ql_get_regs_len,
718 .get_regs = ql_get_regs,
719 .get_msglevel = ql_get_msglevel,
720 .set_msglevel = ql_set_msglevel,
722 .set_phys_id = ql_set_phys_id,
723 .self_test = ql_self_test,
724 .get_pauseparam = ql_get_pauseparam,
725 .set_pauseparam = ql_set_pauseparam,
726 .get_coalesce = ql_get_coalesce,
727 .set_coalesce = ql_set_coalesce,
728 .get_sset_count = ql_get_sset_count,
729 .get_strings = ql_get_strings,
730 .get_ethtool_stats = ql_get_ethtool_stats,