]> git.karo-electronics.de Git - linux-beck.git/blobdiff - drivers/staging/octeon/ethernet.c
Merge branch 'work.splice_read' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-beck.git] / drivers / staging / octeon / ethernet.c
index 8d51f0584be5a0cba86fdf5974f0a11b27e0c5ee..d02e3e31ed293dbe97fbe5327ec670d8fc91ecc9 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/of_net.h>
+#include <linux/if_ether.h>
+#include <linux/if_vlan.h>
 
 #include <net/dst.h>
 
@@ -39,6 +41,8 @@
 #include <asm/octeon/cvmx-gmxx-defs.h>
 #include <asm/octeon/cvmx-smix-defs.h>
 
+#define OCTEON_MAX_MTU 65392
+
 static int num_packet_buffers = 1024;
 module_param(num_packet_buffers, int, 0444);
 MODULE_PARM_DESC(num_packet_buffers, "\n"
@@ -248,20 +252,22 @@ static int cvm_oct_common_change_mtu(struct net_device *dev, int new_mtu)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
        int interface = INTERFACE(priv->port);
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
-       int vlan_bytes = 4;
+#if IS_ENABLED(CONFIG_VLAN_8021Q)
+       int vlan_bytes = VLAN_HLEN;
 #else
        int vlan_bytes = 0;
 #endif
+       int mtu_overhead = ETH_HLEN + ETH_FCS_LEN + vlan_bytes;
 
        /*
         * Limit the MTU to make sure the ethernet packets are between
         * 64 bytes and 65535 bytes.
         */
-       if ((new_mtu + 14 + 4 + vlan_bytes < 64) ||
-           (new_mtu + 14 + 4 + vlan_bytes > 65392)) {
+       if ((new_mtu + mtu_overhead < VLAN_ETH_ZLEN) ||
+           (new_mtu + mtu_overhead > OCTEON_MAX_MTU)) {
                pr_err("MTU must be between %d and %d.\n",
-                      64 - 14 - 4 - vlan_bytes, 65392 - 14 - 4 - vlan_bytes);
+                      VLAN_ETH_ZLEN - mtu_overhead,
+                      OCTEON_MAX_MTU - mtu_overhead);
                return -EINVAL;
        }
        dev->mtu = new_mtu;
@@ -271,7 +277,7 @@ static int cvm_oct_common_change_mtu(struct net_device *dev, int new_mtu)
                CVMX_HELPER_INTERFACE_MODE_SPI)) {
                int index = INDEX(priv->port);
                /* Add ethernet header and FCS, and VLAN if configured. */
-               int max_packet = new_mtu + 14 + 4 + vlan_bytes;
+               int max_packet = new_mtu + mtu_overhead;
 
                if (OCTEON_IS_MODEL(OCTEON_CN3XXX) ||
                    OCTEON_IS_MODEL(OCTEON_CN58XX)) {
@@ -286,7 +292,7 @@ static int cvm_oct_common_change_mtu(struct net_device *dev, int new_mtu)
                        union cvmx_pip_frm_len_chkx frm_len_chk;
 
                        frm_len_chk.u64 = 0;
-                       frm_len_chk.s.minlen = 64;
+                       frm_len_chk.s.minlen = VLAN_ETH_ZLEN;
                        frm_len_chk.s.maxlen = max_packet;
                        cvmx_write_csr(CVMX_PIP_FRM_LEN_CHKX(interface),
                                       frm_len_chk.u64);
@@ -488,6 +494,8 @@ int cvm_oct_common_open(struct net_device *dev,
 
        gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
        gmx_cfg.s.en = 1;
+       if (octeon_has_feature(OCTEON_FEATURE_PKND))
+               gmx_cfg.s.pknd = priv->port;
        cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
 
        if (octeon_is_simulation())
@@ -519,8 +527,10 @@ void cvm_oct_link_poll(struct net_device *dev)
        if (link_info.u64 == priv->link_info)
                return;
 
-       link_info = cvmx_helper_link_autoconf(priv->port);
-       priv->link_info = link_info.u64;
+       if (cvmx_helper_link_set(priv->port, link_info))
+               link_info.u64 = priv->link_info;
+       else
+               priv->link_info = link_info.u64;
 
        if (link_info.s.link_up) {
                if (!netif_carrier_ok(dev))
@@ -684,7 +694,6 @@ static int cvm_oct_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-
        cvm_oct_configure_common_hw();
 
        cvmx_helper_initialize_packet_io_global();
@@ -927,7 +936,6 @@ static int cvm_oct_remove(struct platform_device *pdev)
                }
        }
 
-
        cvmx_pko_shutdown();
 
        cvmx_ipd_free_ptr();