wil6210: ethtool ops
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / ath / wil6210 / netdev.c
index 7afce6e8c5078fb92257a64f6c1e3fabaa65298c..c3f0ddfaa5da507461975d5708f832136f5b29b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Qualcomm Atheros, Inc.
+ * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
 #include <linux/etherdevice.h>
 
 #include "wil6210.h"
+#include "txrx.h"
 
 static int wil_open(struct net_device *ndev)
 {
        struct wil6210_priv *wil = ndev_to_wil(ndev);
 
+       wil_dbg_misc(wil, "%s()\n", __func__);
+
        return wil_up(wil);
 }
 
@@ -29,6 +32,8 @@ static int wil_stop(struct net_device *ndev)
 {
        struct wil6210_priv *wil = ndev_to_wil(ndev);
 
+       wil_dbg_misc(wil, "%s()\n", __func__);
+
        return wil_down(wil);
 }
 
@@ -36,8 +41,10 @@ static int wil_change_mtu(struct net_device *ndev, int new_mtu)
 {
        struct wil6210_priv *wil = ndev_to_wil(ndev);
 
-       if (new_mtu < 68 || new_mtu > IEEE80211_MAX_DATA_LEN_DMG)
+       if (new_mtu < 68 || new_mtu > (TX_BUF_LEN - ETH_HLEN)) {
+               wil_err(wil, "invalid MTU %d\n", new_mtu);
                return -EINVAL;
+       }
 
        wil_dbg_misc(wil, "change MTU %d -> %d\n", ndev->mtu, new_mtu);
        ndev->mtu = new_mtu;
@@ -121,6 +128,8 @@ void *wil_if_alloc(struct device *dev, void __iomem *csr)
        wil->csr = csr;
        wil->wdev = wdev;
 
+       wil_dbg_misc(wil, "%s()\n", __func__);
+
        rc = wil_priv_init(wil);
        if (rc) {
                dev_err(dev, "wil_priv_init failed\n");
@@ -140,6 +149,7 @@ void *wil_if_alloc(struct device *dev, void __iomem *csr)
        }
 
        ndev->netdev_ops = &wil_netdev_ops;
+       wil_set_ethtoolops(ndev);
        ndev->ieee80211_ptr = wdev;
        ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
                            NETIF_F_SG | NETIF_F_GRO;
@@ -168,11 +178,17 @@ void *wil_if_alloc(struct device *dev, void __iomem *csr)
 void wil_if_free(struct wil6210_priv *wil)
 {
        struct net_device *ndev = wil_to_ndev(wil);
+
+       wil_dbg_misc(wil, "%s()\n", __func__);
+
        if (!ndev)
                return;
 
-       free_netdev(ndev);
        wil_priv_deinit(wil);
+
+       wil_to_ndev(wil) = NULL;
+       free_netdev(ndev);
+
        wil_wdev_free(wil);
 }
 
@@ -181,6 +197,8 @@ int wil_if_add(struct wil6210_priv *wil)
        struct net_device *ndev = wil_to_ndev(wil);
        int rc;
 
+       wil_dbg_misc(wil, "%s()\n", __func__);
+
        rc = register_netdev(ndev);
        if (rc < 0) {
                dev_err(&ndev->dev, "Failed to register netdev: %d\n", rc);
@@ -196,5 +214,7 @@ void wil_if_remove(struct wil6210_priv *wil)
 {
        struct net_device *ndev = wil_to_ndev(wil);
 
+       wil_dbg_misc(wil, "%s()\n", __func__);
+
        unregister_netdev(ndev);
 }