Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net...
[firefly-linux-kernel-4.4.55.git] / drivers / net / ethernet / intel / ixgbe / ixgbe_main.c
index a34ee7d63563193302c0aca95749ee7d4183f3af..b54bc40f00b0dbb8c4557b90c2d1c0e0bbd654b1 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/ethtool.h>
 #include <linux/if.h>
 #include <linux/if_vlan.h>
+#include <linux/if_bridge.h>
 #include <linux/prefetch.h>
 #include <scsi/fc/fc_fcoe.h>
 
@@ -355,13 +356,37 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter)
 
        /* Transmit Descriptor Formats
         *
-        * Advanced Transmit Descriptor
+        * 82598 Advanced Transmit Descriptor
         *   +--------------------------------------------------------------+
         * 0 |         Buffer Address [63:0]                                |
         *   +--------------------------------------------------------------+
-        * 8 |  PAYLEN  | PORTS  | IDX | STA | DCMD  |DTYP |  RSV |  DTALEN |
+        * 8 |  PAYLEN  | POPTS  | IDX | STA | DCMD  |DTYP |  RSV |  DTALEN |
         *   +--------------------------------------------------------------+
         *   63       46 45    40 39 36 35 32 31   24 23 20 19              0
+        *
+        * 82598 Advanced Transmit Descriptor (Write-Back Format)
+        *   +--------------------------------------------------------------+
+        * 0 |                          RSV [63:0]                          |
+        *   +--------------------------------------------------------------+
+        * 8 |            RSV           |  STA  |          NXTSEQ           |
+        *   +--------------------------------------------------------------+
+        *   63                       36 35   32 31                         0
+        *
+        * 82599+ Advanced Transmit Descriptor
+        *   +--------------------------------------------------------------+
+        * 0 |         Buffer Address [63:0]                                |
+        *   +--------------------------------------------------------------+
+        * 8 |PAYLEN  |POPTS|CC|IDX  |STA  |DCMD  |DTYP |MAC  |RSV  |DTALEN |
+        *   +--------------------------------------------------------------+
+        *   63     46 45 40 39 38 36 35 32 31  24 23 20 19 18 17 16 15     0
+        *
+        * 82599+ Advanced Transmit Descriptor (Write-Back Format)
+        *   +--------------------------------------------------------------+
+        * 0 |                          RSV [63:0]                          |
+        *   +--------------------------------------------------------------+
+        * 8 |            RSV           |  STA  |           RSV             |
+        *   +--------------------------------------------------------------+
+        *   63                       36 35   32 31                         0
         */
 
        for (n = 0; n < adapter->num_tx_queues; n++) {
@@ -422,7 +447,9 @@ rx_ring_summary:
 
        dev_info(&adapter->pdev->dev, "RX Rings Dump\n");
 
-       /* Advanced Receive Descriptor (Read) Format
+       /* Receive Descriptor Formats
+        *
+        * 82598 Advanced Receive Descriptor (Read) Format
         *    63                                           1        0
         *    +-----------------------------------------------------+
         *  0 |       Packet Buffer Address [63:1]           |A0/NSE|
@@ -431,17 +458,40 @@ rx_ring_summary:
         *    +-----------------------------------------------------+
         *
         *
-        * Advanced Receive Descriptor (Write-Back) Format
+        * 82598 Advanced Receive Descriptor (Write-Back) Format
         *
         *   63       48 47    32 31  30      21 20 16 15   4 3     0
         *   +------------------------------------------------------+
-        * 0 | Packet     IP     |SPH| HDR_LEN   | RSV|Packet|  RSS |
-        *   | Checksum   Ident  |   |           |    | Type | Type |
+        * 0 |       RSS Hash /  |SPH| HDR_LEN  | RSV |Packet|  RSS |
+        *   | Packet   | IP     |   |          |     | Type | Type |
+        *   | Checksum | Ident  |   |          |     |      |      |
         *   +------------------------------------------------------+
         * 8 | VLAN Tag | Length | Extended Error | Extended Status |
         *   +------------------------------------------------------+
         *   63       48 47    32 31            20 19               0
+        *
+        * 82599+ Advanced Receive Descriptor (Read) Format
+        *    63                                           1        0
+        *    +-----------------------------------------------------+
+        *  0 |       Packet Buffer Address [63:1]           |A0/NSE|
+        *    +----------------------------------------------+------+
+        *  8 |       Header Buffer Address [63:1]           |  DD  |
+        *    +-----------------------------------------------------+
+        *
+        *
+        * 82599+ Advanced Receive Descriptor (Write-Back) Format
+        *
+        *   63       48 47    32 31  30      21 20 17 16   4 3     0
+        *   +------------------------------------------------------+
+        * 0 |RSS / Frag Checksum|SPH| HDR_LEN  |RSC- |Packet|  RSS |
+        *   |/ RTT / PCoE_PARAM |   |          | CNT | Type | Type |
+        *   |/ Flow Dir Flt ID  |   |          |     |      |      |
+        *   +------------------------------------------------------+
+        * 8 | VLAN Tag | Length |Extended Error| Xtnd Status/NEXTP |
+        *   +------------------------------------------------------+
+        *   63       48 47    32 31          20 19                 0
         */
+
        for (n = 0; n < adapter->num_rx_queues; n++) {
                rx_ring = adapter->rx_ring[n];
                pr_info("------------------------------------\n");
@@ -791,10 +841,8 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,
                total_bytes += tx_buffer->bytecount;
                total_packets += tx_buffer->gso_segs;
 
-#ifdef CONFIG_IXGBE_PTP
                if (unlikely(tx_buffer->tx_flags & IXGBE_TX_FLAGS_TSTAMP))
                        ixgbe_ptp_tx_hwtstamp(q_vector, tx_buffer->skb);
-#endif
 
                /* free the skb */
                dev_kfree_skb_any(tx_buffer->skb);
@@ -1382,9 +1430,7 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring,
 
        ixgbe_rx_checksum(rx_ring, rx_desc, skb);
 
-#ifdef CONFIG_IXGBE_PTP
        ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, rx_desc, skb);
-#endif
 
        if ((dev->features & NETIF_F_HW_VLAN_RX) &&
            ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) {
@@ -1926,20 +1972,6 @@ static void ixgbe_configure_msix(struct ixgbe_adapter *adapter)
                ixgbe_for_each_ring(ring, q_vector->tx)
                        ixgbe_set_ivar(adapter, 1, ring->reg_idx, v_idx);
 
-               if (q_vector->tx.ring && !q_vector->rx.ring) {
-                       /* tx only vector */
-                       if (adapter->tx_itr_setting == 1)
-                               q_vector->itr = IXGBE_10K_ITR;
-                       else
-                               q_vector->itr = adapter->tx_itr_setting;
-               } else {
-                       /* rx or rx/tx vector */
-                       if (adapter->rx_itr_setting == 1)
-                               q_vector->itr = IXGBE_20K_ITR;
-                       else
-                               q_vector->itr = adapter->rx_itr_setting;
-               }
-
                ixgbe_write_eitr(q_vector);
        }
 
@@ -2336,10 +2368,8 @@ static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter, bool queues,
                break;
        }
 
-#ifdef CONFIG_IXGBE_PTP
        if (adapter->hw.mac.type == ixgbe_mac_X540)
                mask |= IXGBE_EIMS_TIMESYNC;
-#endif
 
        if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) &&
            !(adapter->flags2 & IXGBE_FLAG2_FDIR_REQUIRES_REINIT))
@@ -2405,10 +2435,8 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
 
        ixgbe_check_fan_failure(adapter, eicr);
 
-#ifdef CONFIG_IXGBE_PTP
        if (unlikely(eicr & IXGBE_EICR_TIMESYNC))
                ixgbe_ptp_check_pps_event(adapter, eicr);
-#endif
 
        /* re-enable the original interrupt state, no lsc, no queues */
        if (!test_bit(__IXGBE_DOWN, &adapter->state))
@@ -2600,10 +2628,8 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
        }
 
        ixgbe_check_fan_failure(adapter, eicr);
-#ifdef CONFIG_IXGBE_PTP
        if (unlikely(eicr & IXGBE_EICR_TIMESYNC))
                ixgbe_ptp_check_pps_event(adapter, eicr);
-#endif
 
        /* would disable interrupts here but EIAM disabled it */
        napi_schedule(&q_vector->napi);
@@ -2711,12 +2737,6 @@ static void ixgbe_configure_msi_and_legacy(struct ixgbe_adapter *adapter)
 {
        struct ixgbe_q_vector *q_vector = adapter->q_vector[0];
 
-       /* rx/tx vector */
-       if (adapter->rx_itr_setting == 1)
-               q_vector->itr = IXGBE_20K_ITR;
-       else
-               q_vector->itr = adapter->rx_itr_setting;
-
        ixgbe_write_eitr(q_vector);
 
        ixgbe_set_ivar(adapter, 0, 0, 0);
@@ -3223,7 +3243,6 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter)
        IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset ^ 1), reg_offset - 1);
        IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset), (~0) << vf_shift);
        IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset ^ 1), reg_offset - 1);
-       IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
 
        /* Map PF MAC address in RAR Entry 0 to first pool following VFs */
        hw->mac.ops.set_vmdq(hw, 0, VMDQ_P(0));
@@ -3246,8 +3265,6 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter)
 
        IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, gcr_ext);
 
-       /* enable Tx loopback for VF/PF communication */
-       IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
 
        /* Enable MAC Anti-Spoofing */
        hw->mac.ops.set_mac_anti_spoofing(hw, (adapter->num_vfs != 0),
@@ -4204,10 +4221,8 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)
        if (hw->mac.san_mac_rar_index)
                hw->mac.ops.set_vmdq_san_mac(hw, VMDQ_P(0));
 
-#ifdef CONFIG_IXGBE_PTP
        if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)
                ixgbe_ptp_reset(adapter);
-#endif
 }
 
 /**
@@ -4914,9 +4929,7 @@ static int ixgbe_open(struct net_device *netdev)
        if (err)
                goto err_set_queues;
 
-#ifdef CONFIG_IXGBE_PTP
        ixgbe_ptp_init(adapter);
-#endif /* CONFIG_IXGBE_PTP*/
 
        ixgbe_up_complete(adapter);
 
@@ -4949,9 +4962,7 @@ static int ixgbe_close(struct net_device *netdev)
 {
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
-#ifdef CONFIG_IXGBE_PTP
        ixgbe_ptp_stop(adapter);
-#endif
 
        ixgbe_down(adapter);
        ixgbe_free_irq(adapter);
@@ -5514,10 +5525,8 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
                break;
        }
 
-#ifdef CONFIG_IXGBE_PTP
        if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)
                ixgbe_ptp_start_cyclecounter(adapter);
-#endif
 
        e_info(drv, "NIC Link is Up %s, Flow Control: %s\n",
               (link_speed == IXGBE_LINK_SPEED_10GB_FULL ?
@@ -5562,10 +5571,8 @@ static void ixgbe_watchdog_link_is_down(struct ixgbe_adapter *adapter)
        if (ixgbe_is_sfp(hw) && hw->mac.type == ixgbe_mac_82598EB)
                adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP;
 
-#ifdef CONFIG_IXGBE_PTP
        if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)
                ixgbe_ptp_start_cyclecounter(adapter);
-#endif
 
        e_info(drv, "NIC Link is Down\n");
        netif_carrier_off(netdev);
@@ -5870,9 +5877,7 @@ static void ixgbe_service_task(struct work_struct *work)
        ixgbe_watchdog_subtask(adapter);
        ixgbe_fdir_reinit_subtask(adapter);
        ixgbe_check_hang_subtask(adapter);
-#ifdef CONFIG_IXGBE_PTP
        ixgbe_ptp_overflow_check(adapter);
-#endif
 
        ixgbe_service_event_complete(adapter);
 }
@@ -6025,10 +6030,8 @@ static __le32 ixgbe_tx_cmd_type(u32 tx_flags)
        if (tx_flags & IXGBE_TX_FLAGS_HW_VLAN)
                cmd_type |= cpu_to_le32(IXGBE_ADVTXD_DCMD_VLE);
 
-#ifdef CONFIG_IXGBE_PTP
        if (tx_flags & IXGBE_TX_FLAGS_TSTAMP)
                cmd_type |= cpu_to_le32(IXGBE_ADVTXD_MAC_TSTAMP);
-#endif
 
        /* set segmentation enable bits for TSO/FSO */
 #ifdef IXGBE_FCOE
@@ -6430,12 +6433,10 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
 
        skb_tx_timestamp(skb);
 
-#ifdef CONFIG_IXGBE_PTP
        if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
                skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
                tx_flags |= IXGBE_TX_FLAGS_TSTAMP;
        }
-#endif
 
 #ifdef CONFIG_PCI_IOV
        /*
@@ -6585,10 +6586,8 @@ static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
        switch (cmd) {
-#ifdef CONFIG_IXGBE_PTP
        case SIOCSHWTSTAMP:
                return ixgbe_ptp_hwtstamp_ioctl(adapter, req, cmd);
-#endif
        default:
                return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd);
        }
@@ -7012,6 +7011,59 @@ static int ixgbe_ndo_fdb_dump(struct sk_buff *skb,
        return idx;
 }
 
+static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
+                                   struct nlmsghdr *nlh)
+{
+       struct ixgbe_adapter *adapter = netdev_priv(dev);
+       struct nlattr *attr, *br_spec;
+       int rem;
+
+       if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
+               return -EOPNOTSUPP;
+
+       br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
+
+       nla_for_each_nested(attr, br_spec, rem) {
+               __u16 mode;
+               u32 reg = 0;
+
+               if (nla_type(attr) != IFLA_BRIDGE_MODE)
+                       continue;
+
+               mode = nla_get_u16(attr);
+               if (mode == BRIDGE_MODE_VEPA)
+                       reg = 0;
+               else if (mode == BRIDGE_MODE_VEB)
+                       reg = IXGBE_PFDTXGSWC_VT_LBEN;
+               else
+                       return -EINVAL;
+
+               IXGBE_WRITE_REG(&adapter->hw, IXGBE_PFDTXGSWC, reg);
+
+               e_info(drv, "enabling bridge mode: %s\n",
+                       mode == BRIDGE_MODE_VEPA ? "VEPA" : "VEB");
+       }
+
+       return 0;
+}
+
+static int ixgbe_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
+                                   struct net_device *dev)
+{
+       struct ixgbe_adapter *adapter = netdev_priv(dev);
+       u16 mode;
+
+       if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
+               return 0;
+
+       if (IXGBE_READ_REG(&adapter->hw, IXGBE_PFDTXGSWC) & 1)
+               mode = BRIDGE_MODE_VEB;
+       else
+               mode = BRIDGE_MODE_VEPA;
+
+       return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode);
+}
+
 static const struct net_device_ops ixgbe_netdev_ops = {
        .ndo_open               = ixgbe_open,
        .ndo_stop               = ixgbe_close,
@@ -7051,6 +7103,8 @@ static const struct net_device_ops ixgbe_netdev_ops = {
        .ndo_fdb_add            = ixgbe_ndo_fdb_add,
        .ndo_fdb_del            = ixgbe_ndo_fdb_del,
        .ndo_fdb_dump           = ixgbe_ndo_fdb_dump,
+       .ndo_bridge_setlink     = ixgbe_ndo_bridge_setlink,
+       .ndo_bridge_getlink     = ixgbe_ndo_bridge_getlink,
 };
 
 /**