ixgbe: Fix memory leak in ixgbe when receiving traffic on DDP enabled rings
[deliverable/linux.git] / drivers / net / ethernet / intel / ixgbe / ixgbe_main.c
index 467948e9ecd951dcff54d4bcf43e4adc0ddde8c0..cbb05d65960fa2f082fba86c5728fe3fcb679841 100644 (file)
@@ -63,8 +63,8 @@ static char ixgbe_default_device_descr[] =
                              "Intel(R) 10 Gigabit Network Connection";
 #endif
 #define MAJ 3
-#define MIN 8
-#define BUILD 21
+#define MIN 9
+#define BUILD 15
 #define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \
        __stringify(BUILD) "-k"
 const char ixgbe_driver_version[] = DRV_VERSION;
@@ -133,7 +133,7 @@ static struct notifier_block dca_notifier = {
 static unsigned int max_vfs;
 module_param(max_vfs, uint, 0);
 MODULE_PARM_DESC(max_vfs,
-                "Maximum number of virtual functions to allocate per physical function");
+                "Maximum number of virtual functions to allocate per physical function - default is zero and maximum value is 63");
 #endif /* CONFIG_PCI_IOV */
 
 static unsigned int allow_unsupported_sfp;
@@ -610,35 +610,50 @@ void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *ring,
        /* tx_buffer must be completely set up in the transmit path */
 }
 
-static void ixgbe_update_xoff_received(struct ixgbe_adapter *adapter)
+static void ixgbe_update_xoff_rx_lfc(struct ixgbe_adapter *adapter)
 {
        struct ixgbe_hw *hw = &adapter->hw;
        struct ixgbe_hw_stats *hwstats = &adapter->stats;
-       u32 data = 0;
-       u32 xoff[8] = {0};
        int i;
+       u32 data;
 
-       if ((hw->fc.current_mode == ixgbe_fc_full) ||
-           (hw->fc.current_mode == ixgbe_fc_rx_pause)) {
-               switch (hw->mac.type) {
-               case ixgbe_mac_82598EB:
-                       data = IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
-                       break;
-               default:
-                       data = IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
-               }
-               hwstats->lxoffrxc += data;
+       if ((hw->fc.current_mode != ixgbe_fc_full) &&
+           (hw->fc.current_mode != ixgbe_fc_rx_pause))
+               return;
 
-               /* refill credits (no tx hang) if we received xoff */
-               if (!data)
-                       return;
+       switch (hw->mac.type) {
+       case ixgbe_mac_82598EB:
+               data = IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
+               break;
+       default:
+               data = IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
+       }
+       hwstats->lxoffrxc += data;
 
-               for (i = 0; i < adapter->num_tx_queues; i++)
-                       clear_bit(__IXGBE_HANG_CHECK_ARMED,
-                                 &adapter->tx_ring[i]->state);
+       /* refill credits (no tx hang) if we received xoff */
+       if (!data)
                return;
-       } else if (!(adapter->dcb_cfg.pfc_mode_enable))
+
+       for (i = 0; i < adapter->num_tx_queues; i++)
+               clear_bit(__IXGBE_HANG_CHECK_ARMED,
+                         &adapter->tx_ring[i]->state);
+}
+
+static void ixgbe_update_xoff_received(struct ixgbe_adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       struct ixgbe_hw_stats *hwstats = &adapter->stats;
+       u32 xoff[8] = {0};
+       int i;
+       bool pfc_en = adapter->dcb_cfg.pfc_mode_enable;
+
+       if (adapter->ixgbe_ieee_pfc)
+               pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en);
+
+       if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED) || !pfc_en) {
+               ixgbe_update_xoff_rx_lfc(adapter);
                return;
+       }
 
        /* update stats for each tc, only valid with PFC enabled */
        for (i = 0; i < MAX_TX_PACKET_BUFFERS; i++) {
@@ -774,6 +789,13 @@ 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);
 
@@ -1126,7 +1148,7 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring,
 
        /* alloc new page for storage */
        if (likely(!page)) {
-               page = alloc_pages(GFP_ATOMIC | __GFP_COLD,
+               page = alloc_pages(GFP_ATOMIC | __GFP_COLD | __GFP_COMP,
                                   ixgbe_rx_pg_order(rx_ring));
                if (unlikely(!page)) {
                        rx_ring->rx_stats.alloc_rx_page_failed++;
@@ -1144,7 +1166,7 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring,
         * there isn't much point in holding memory we can't use
         */
        if (dma_mapping_error(rx_ring->dev, dma)) {
-               put_page(page);
+               __free_pages(page, ixgbe_rx_pg_order(rx_ring));
                bi->page = NULL;
 
                rx_ring->rx_stats.alloc_rx_page_failed++;
@@ -1368,20 +1390,28 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring,
                                     union ixgbe_adv_rx_desc *rx_desc,
                                     struct sk_buff *skb)
 {
+       struct net_device *dev = rx_ring->netdev;
+
        ixgbe_update_rsc_stats(rx_ring, skb);
 
        ixgbe_rx_hash(rx_ring, rx_desc, skb);
 
        ixgbe_rx_checksum(rx_ring, rx_desc, skb);
 
-       if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) {
+#ifdef CONFIG_IXGBE_PTP
+       if (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS))
+               ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, skb);
+#endif
+
+       if ((dev->features & NETIF_F_HW_VLAN_RX) &&
+           ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) {
                u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan);
                __vlan_hwaccel_put_tag(skb, vid);
        }
 
        skb_record_rx_queue(skb, rx_ring->queue_index);
 
-       skb->protocol = eth_type_trans(skb, rx_ring->netdev);
+       skb->protocol = eth_type_trans(skb, dev);
 }
 
 static void ixgbe_rx_skb(struct ixgbe_q_vector *q_vector,
@@ -2295,6 +2325,9 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
        }
 
        ixgbe_check_fan_failure(adapter, eicr);
+#ifdef CONFIG_IXGBE_PTP
+       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))
@@ -2487,6 +2520,9 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
        }
 
        ixgbe_check_fan_failure(adapter, eicr);
+#ifdef CONFIG_IXGBE_PTP
+       ixgbe_ptp_check_pps_event(adapter, eicr);
+#endif
 
        /* would disable interrupts here but EIAM disabled it */
        napi_schedule(&q_vector->napi);
@@ -2756,6 +2792,61 @@ static void ixgbe_configure_tx(struct ixgbe_adapter *adapter)
                ixgbe_configure_tx_ring(adapter, adapter->tx_ring[i]);
 }
 
+static void ixgbe_enable_rx_drop(struct ixgbe_adapter *adapter,
+                                struct ixgbe_ring *ring)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       u8 reg_idx = ring->reg_idx;
+       u32 srrctl = IXGBE_READ_REG(hw, IXGBE_SRRCTL(reg_idx));
+
+       srrctl |= IXGBE_SRRCTL_DROP_EN;
+
+       IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(reg_idx), srrctl);
+}
+
+static void ixgbe_disable_rx_drop(struct ixgbe_adapter *adapter,
+                                 struct ixgbe_ring *ring)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       u8 reg_idx = ring->reg_idx;
+       u32 srrctl = IXGBE_READ_REG(hw, IXGBE_SRRCTL(reg_idx));
+
+       srrctl &= ~IXGBE_SRRCTL_DROP_EN;
+
+       IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(reg_idx), srrctl);
+}
+
+#ifdef CONFIG_IXGBE_DCB
+void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter)
+#else
+static void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter)
+#endif
+{
+       int i;
+       bool pfc_en = adapter->dcb_cfg.pfc_mode_enable;
+
+       if (adapter->ixgbe_ieee_pfc)
+               pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en);
+
+       /*
+        * We should set the drop enable bit if:
+        *  SR-IOV is enabled
+        *   or
+        *  Number of Rx queues > 1 and flow control is disabled
+        *
+        *  This allows us to avoid head of line blocking for security
+        *  and performance reasons.
+        */
+       if (adapter->num_vfs || (adapter->num_rx_queues > 1 &&
+           !(adapter->hw.fc.current_mode & ixgbe_fc_tx_pause) && !pfc_en)) {
+               for (i = 0; i < adapter->num_rx_queues; i++)
+                       ixgbe_enable_rx_drop(adapter, adapter->rx_ring[i]);
+       } else {
+               for (i = 0; i < adapter->num_rx_queues; i++)
+                       ixgbe_disable_rx_drop(adapter, adapter->rx_ring[i]);
+       }
+}
+
 #define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2
 
 static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter,
@@ -2902,33 +2993,6 @@ static void ixgbe_configure_rscctl(struct ixgbe_adapter *adapter,
        IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(reg_idx), rscctrl);
 }
 
-/**
- *  ixgbe_set_uta - Set unicast filter table address
- *  @adapter: board private structure
- *
- *  The unicast table address is a register array of 32-bit registers.
- *  The table is meant to be used in a way similar to how the MTA is used
- *  however due to certain limitations in the hardware it is necessary to
- *  set all the hash bits to 1 and use the VMOLR ROPE bit as a promiscuous
- *  enable bit to allow vlan tag stripping when promiscuous mode is enabled
- **/
-static void ixgbe_set_uta(struct ixgbe_adapter *adapter)
-{
-       struct ixgbe_hw *hw = &adapter->hw;
-       int i;
-
-       /* The UTA table only exists on 82599 hardware and newer */
-       if (hw->mac.type < ixgbe_mac_82599EB)
-               return;
-
-       /* we only need to do this if VMDq is enabled */
-       if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
-               return;
-
-       for (i = 0; i < 128; i++)
-               IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
-}
-
 #define IXGBE_MAX_RX_DESC_POLL 10
 static void ixgbe_rx_desc_queue_enable(struct ixgbe_adapter *adapter,
                                       struct ixgbe_ring *ring)
@@ -3214,8 +3278,6 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
        /* Program registers for the distribution of queues */
        ixgbe_setup_mrqc(adapter);
 
-       ixgbe_set_uta(adapter);
-
        /* set_rx_buffer_len must be called before ring initialization */
        ixgbe_set_rx_buffer_len(adapter);
 
@@ -3452,16 +3514,17 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
                }
                ixgbe_vlan_filter_enable(adapter);
                hw->addr_ctrl.user_set_promisc = false;
-               /*
-                * Write addresses to available RAR registers, if there is not
-                * sufficient space to store all the addresses then enable
-                * unicast promiscuous mode
-                */
-               count = ixgbe_write_uc_addr_list(netdev);
-               if (count < 0) {
-                       fctrl |= IXGBE_FCTRL_UPE;
-                       vmolr |= IXGBE_VMOLR_ROPE;
-               }
+       }
+
+       /*
+        * Write addresses to available RAR registers, if there is not
+        * sufficient space to store all the addresses then enable
+        * unicast promiscuous mode
+        */
+       count = ixgbe_write_uc_addr_list(netdev);
+       if (count < 0) {
+               fctrl |= IXGBE_FCTRL_UPE;
+               vmolr |= IXGBE_VMOLR_ROPE;
        }
 
        if (adapter->num_vfs) {
@@ -3547,10 +3610,6 @@ static void ixgbe_configure_dcb(struct ixgbe_adapter *adapter)
        if (hw->mac.type == ixgbe_mac_82598EB)
                netif_set_gso_max_size(adapter->netdev, 32768);
 
-
-       /* Enable VLAN tag insert/strip */
-       adapter->netdev->features |= NETIF_F_HW_VLAN_RX;
-
        hw->mac.ops.set_vfta(&adapter->hw, 0, 0, true);
 
 #ifdef IXGBE_FCOE
@@ -4128,7 +4187,8 @@ static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring)
                                       DMA_FROM_DEVICE);
                rx_buffer->dma = 0;
                if (rx_buffer->page)
-                       put_page(rx_buffer->page);
+                       __free_pages(rx_buffer->page,
+                                    ixgbe_rx_pg_order(rx_ring));
                rx_buffer->page = NULL;
        }
 
@@ -4426,9 +4486,6 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
        /* default flow control settings */
        hw->fc.requested_mode = ixgbe_fc_full;
        hw->fc.current_mode = ixgbe_fc_full;    /* init for ethtool output */
-#ifdef CONFIG_DCB
-       adapter->last_lfc_mode = hw->fc.current_mode;
-#endif
        ixgbe_pbthresh_setup(adapter);
        hw->fc.pause_time = IXGBE_DEFAULT_FCPAUSE;
        hw->fc.send_xon = true;
@@ -4993,9 +5050,6 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
        if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
                u64 rsc_count = 0;
                u64 rsc_flush = 0;
-               for (i = 0; i < 16; i++)
-                       adapter->hw_rx_no_dma_resources +=
-                               IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
                for (i = 0; i < adapter->num_rx_queues; i++) {
                        rsc_count += adapter->rx_ring[i]->rx_stats.rsc_count;
                        rsc_flush += adapter->rx_ring[i]->rx_stats.rsc_flush;
@@ -5098,6 +5152,9 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
                hwstats->b2ospc += IXGBE_READ_REG(hw, IXGBE_B2OSPC);
                hwstats->b2ogprc += IXGBE_READ_REG(hw, IXGBE_B2OGPRC);
        case ixgbe_mac_82599EB:
+               for (i = 0; i < 16; i++)
+                       adapter->hw_rx_no_dma_resources +=
+                                            IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
                hwstats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
                IXGBE_READ_REG(hw, IXGBE_GORCH); /* to clear */
                hwstats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
@@ -5275,7 +5332,7 @@ static void ixgbe_watchdog_update_link(struct ixgbe_adapter *adapter)
        struct ixgbe_hw *hw = &adapter->hw;
        u32 link_speed = adapter->link_speed;
        bool link_up = adapter->link_up;
-       int i;
+       bool pfc_en = adapter->dcb_cfg.pfc_mode_enable;
 
        if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE))
                return;
@@ -5287,13 +5344,13 @@ static void ixgbe_watchdog_update_link(struct ixgbe_adapter *adapter)
                link_speed = IXGBE_LINK_SPEED_10GB_FULL;
                link_up = true;
        }
-       if (link_up) {
-               if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
-                       for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
-                               hw->mac.ops.fc_enable(hw, i);
-               } else {
-                       hw->mac.ops.fc_enable(hw, 0);
-               }
+
+       if (adapter->ixgbe_ieee_pfc)
+               pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en);
+
+       if (link_up && !((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && pfc_en)) {
+               hw->mac.ops.fc_enable(hw);
+               ixgbe_set_rx_drop_en(adapter);
        }
 
        if (link_up ||
@@ -5347,6 +5404,11 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
                flow_rx = false;
                break;
        }
+
+#ifdef CONFIG_IXGBE_PTP
+       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 ?
               "10 Gbps" :
@@ -5384,6 +5446,10 @@ 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
+       ixgbe_ptp_start_cyclecounter(adapter);
+#endif
+
        e_info(drv, "NIC Link is Down\n");
        netif_carrier_off(netdev);
 }
@@ -5683,6 +5749,9 @@ 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);
 }
@@ -5833,6 +5902,11 @@ 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
        if (tx_flags & (IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_FSO))
@@ -6223,6 +6297,15 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
                tx_flags |= IXGBE_TX_FLAGS_SW_VLAN;
        }
 
+       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
        /*
         * Use the l2switch_enable flag - would be false if the DMA
@@ -6375,7 +6458,14 @@ static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)
 {
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
-       return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd);
+       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);
+       }
 }
 
 /**
@@ -6567,15 +6657,17 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
 
        if (tc) {
                netdev_set_num_tc(dev, tc);
-               adapter->last_lfc_mode = adapter->hw.fc.current_mode;
                adapter->flags |= IXGBE_FLAG_DCB_ENABLED;
                adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
 
-               if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+               if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
+                       adapter->last_lfc_mode = adapter->hw.fc.requested_mode;
                        adapter->hw.fc.requested_mode = ixgbe_fc_none;
+               }
        } else {
                netdev_reset_tc(dev);
-               adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
+               if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+                       adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
 
                adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
                adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
@@ -6608,11 +6700,6 @@ static netdev_features_t ixgbe_fix_features(struct net_device *netdev,
 {
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
-#ifdef CONFIG_DCB
-       if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
-               features &= ~NETIF_F_HW_VLAN_RX;
-#endif
-
        /* return error if RXHASH is being enabled when RSS is not supported */
        if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED))
                features &= ~NETIF_F_RXHASH;
@@ -6624,7 +6711,6 @@ static netdev_features_t ixgbe_fix_features(struct net_device *netdev,
        /* Turn off LRO if not RSC capable */
        if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE))
                features &= ~NETIF_F_LRO;
-       
 
        return features;
 }
@@ -6673,6 +6759,11 @@ static int ixgbe_set_features(struct net_device *netdev,
                need_reset = true;
        }
 
+       if (features & NETIF_F_HW_VLAN_RX)
+               ixgbe_vlan_strip_enable(adapter);
+       else
+               ixgbe_vlan_strip_disable(adapter);
+
        if (changed & NETIF_F_RXALL)
                need_reset = true;
 
@@ -6683,6 +6774,74 @@ static int ixgbe_set_features(struct net_device *netdev,
        return 0;
 }
 
+static int ixgbe_ndo_fdb_add(struct ndmsg *ndm,
+                            struct net_device *dev,
+                            unsigned char *addr,
+                            u16 flags)
+{
+       struct ixgbe_adapter *adapter = netdev_priv(dev);
+       int err = -EOPNOTSUPP;
+
+       if (ndm->ndm_state & NUD_PERMANENT) {
+               pr_info("%s: FDB only supports static addresses\n",
+                       ixgbe_driver_name);
+               return -EINVAL;
+       }
+
+       if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
+               if (is_unicast_ether_addr(addr))
+                       err = dev_uc_add_excl(dev, addr);
+               else if (is_multicast_ether_addr(addr))
+                       err = dev_mc_add_excl(dev, addr);
+               else
+                       err = -EINVAL;
+       }
+
+       /* Only return duplicate errors if NLM_F_EXCL is set */
+       if (err == -EEXIST && !(flags & NLM_F_EXCL))
+               err = 0;
+
+       return err;
+}
+
+static int ixgbe_ndo_fdb_del(struct ndmsg *ndm,
+                            struct net_device *dev,
+                            unsigned char *addr)
+{
+       struct ixgbe_adapter *adapter = netdev_priv(dev);
+       int err = -EOPNOTSUPP;
+
+       if (ndm->ndm_state & NUD_PERMANENT) {
+               pr_info("%s: FDB only supports static addresses\n",
+                       ixgbe_driver_name);
+               return -EINVAL;
+       }
+
+       if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
+               if (is_unicast_ether_addr(addr))
+                       err = dev_uc_del(dev, addr);
+               else if (is_multicast_ether_addr(addr))
+                       err = dev_mc_del(dev, addr);
+               else
+                       err = -EINVAL;
+       }
+
+       return err;
+}
+
+static int ixgbe_ndo_fdb_dump(struct sk_buff *skb,
+                             struct netlink_callback *cb,
+                             struct net_device *dev,
+                             int idx)
+{
+       struct ixgbe_adapter *adapter = netdev_priv(dev);
+
+       if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
+               idx = ndo_dflt_fdb_dump(skb, cb, dev, idx);
+
+       return idx;
+}
+
 static const struct net_device_ops ixgbe_netdev_ops = {
        .ndo_open               = ixgbe_open,
        .ndo_stop               = ixgbe_close,
@@ -6719,6 +6878,9 @@ static const struct net_device_ops ixgbe_netdev_ops = {
 #endif /* IXGBE_FCOE */
        .ndo_set_features = ixgbe_set_features,
        .ndo_fix_features = ixgbe_fix_features,
+       .ndo_fdb_add            = ixgbe_ndo_fdb_add,
+       .ndo_fdb_del            = ixgbe_ndo_fdb_del,
+       .ndo_fdb_dump           = ixgbe_ndo_fdb_dump,
 };
 
 static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
@@ -6733,13 +6895,65 @@ static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
        /* The 82599 supports up to 64 VFs per physical function
         * but this implementation limits allocation to 63 so that
         * basic networking resources are still available to the
-        * physical function
+        * physical function.  If the user requests greater thn
+        * 63 VFs then it is an error - reset to default of zero.
         */
-       adapter->num_vfs = (max_vfs > 63) ? 63 : max_vfs;
+       adapter->num_vfs = (max_vfs > 63) ? 0 : max_vfs;
        ixgbe_enable_sriov(adapter, ii);
 #endif /* CONFIG_PCI_IOV */
 }
 
+/**
+ * ixgbe_wol_supported - Check whether device supports WoL
+ * @hw: hw specific details
+ * @device_id: the device ID
+ * @subdev_id: the subsystem device ID
+ *
+ * This function is used by probe and ethtool to determine
+ * which devices have WoL support
+ *
+ **/
+int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
+                       u16 subdevice_id)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       u16 wol_cap = adapter->eeprom_cap & IXGBE_DEVICE_CAPS_WOL_MASK;
+       int is_wol_supported = 0;
+
+       switch (device_id) {
+       case IXGBE_DEV_ID_82599_SFP:
+               /* Only these subdevices could supports WOL */
+               switch (subdevice_id) {
+               case IXGBE_SUBDEV_ID_82599_560FLR:
+                       /* only support first port */
+                       if (hw->bus.func != 0)
+                               break;
+               case IXGBE_SUBDEV_ID_82599_SFP:
+                       is_wol_supported = 1;
+                       break;
+               }
+               break;
+       case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
+               /* All except this subdevice support WOL */
+               if (subdevice_id != IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ)
+                       is_wol_supported = 1;
+               break;
+       case IXGBE_DEV_ID_82599_KX4:
+               is_wol_supported = 1;
+               break;
+       case IXGBE_DEV_ID_X540T:
+               /* check eeprom to see if enabled wol */
+               if ((wol_cap == IXGBE_DEVICE_CAPS_WOL_PORT0_1) ||
+                   ((wol_cap == IXGBE_DEVICE_CAPS_WOL_PORT0) &&
+                    (hw->bus.func == 0))) {
+                       is_wol_supported = 1;
+               }
+               break;
+       }
+
+       return is_wol_supported;
+}
+
 /**
  * ixgbe_probe - Device Initialization Routine
  * @pdev: PCI device information struct
@@ -6766,7 +6980,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
        u16 device_caps;
 #endif
        u32 eec;
-       u16 wol_cap;
 
        /* Catch broken hardware that put the wrong VF device ID in
         * the PCIe SR-IOV capability.
@@ -7030,42 +7243,18 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
                netdev->features &= ~NETIF_F_RXHASH;
        }
 
-       /* WOL not supported for all but the following */
+       /* WOL not supported for all devices */
        adapter->wol = 0;
-       switch (pdev->device) {
-       case IXGBE_DEV_ID_82599_SFP:
-               /* Only these subdevice supports WOL */
-               switch (pdev->subsystem_device) {
-               case IXGBE_SUBDEV_ID_82599_560FLR:
-                       /* only support first port */
-                       if (hw->bus.func != 0)
-                               break;
-               case IXGBE_SUBDEV_ID_82599_SFP:
-                       adapter->wol = IXGBE_WUFC_MAG;
-                       break;
-               }
-               break;
-       case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
-               /* All except this subdevice support WOL */
-               if (pdev->subsystem_device != IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ)
-                       adapter->wol = IXGBE_WUFC_MAG;
-               break;
-       case IXGBE_DEV_ID_82599_KX4:
+       hw->eeprom.ops.read(hw, 0x2c, &adapter->eeprom_cap);
+       if (ixgbe_wol_supported(adapter, pdev->device, pdev->subsystem_device))
                adapter->wol = IXGBE_WUFC_MAG;
-               break;
-       case IXGBE_DEV_ID_X540T:
-               /* Check eeprom to see if it is enabled */
-               hw->eeprom.ops.read(hw, 0x2c, &adapter->eeprom_cap);
-               wol_cap = adapter->eeprom_cap & IXGBE_DEVICE_CAPS_WOL_MASK;
 
-               if ((wol_cap == IXGBE_DEVICE_CAPS_WOL_PORT0_1) ||
-                   ((wol_cap == IXGBE_DEVICE_CAPS_WOL_PORT0) &&
-                    (hw->bus.func == 0)))
-                       adapter->wol = IXGBE_WUFC_MAG;
-               break;
-       }
        device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
 
+#ifdef CONFIG_IXGBE_PTP
+       ixgbe_ptp_init(adapter);
+#endif /* CONFIG_IXGBE_PTP*/
+
        /* save off EEPROM version number */
        hw->eeprom.ops.read(hw, 0x2e, &adapter->eeprom_verh);
        hw->eeprom.ops.read(hw, 0x2d, &adapter->eeprom_verl);
@@ -7152,6 +7341,12 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
 
        e_dev_info("%s\n", ixgbe_default_device_descr);
        cards_found++;
+
+#ifdef CONFIG_IXGBE_HWMON
+       if (ixgbe_sysfs_init(adapter))
+               e_err(probe, "failed to allocate sysfs resources\n");
+#endif /* CONFIG_IXGBE_HWMON */
+
        return 0;
 
 err_register:
@@ -7190,6 +7385,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
        set_bit(__IXGBE_DOWN, &adapter->state);
        cancel_work_sync(&adapter->service_task);
 
+#ifdef CONFIG_IXGBE_PTP
+       ixgbe_ptp_stop(adapter);
+#endif
+
 #ifdef CONFIG_IXGBE_DCA
        if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) {
                adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED;
@@ -7198,6 +7397,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
        }
 
 #endif
+#ifdef CONFIG_IXGBE_HWMON
+       ixgbe_sysfs_exit(adapter);
+#endif /* CONFIG_IXGBE_HWMON */
+
 #ifdef IXGBE_FCOE
        if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
                ixgbe_cleanup_fcoe(adapter);
This page took 0.035936 seconds and 5 git commands to generate.