Merge branch 'regulator-drivers' into regulator-next
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / core / dev.c
index 99e1d759f41ec42c6efc2dc3debbfc7dead6e88b..84f01ba81a34655becfd3be7af5fed76251d21ca 100644 (file)
@@ -208,7 +208,8 @@ static inline void dev_base_seq_inc(struct net *net)
 
 static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)
 {
-       unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ));
+       unsigned int hash = full_name_hash(name, strnlen(name, IFNAMSIZ));
+
        return &net->dev_name_head[hash_32(hash, NETDEV_HASHBITS)];
 }
 
@@ -299,10 +300,9 @@ static const unsigned short netdev_lock_type[] =
         ARPHRD_BIF, ARPHRD_SIT, ARPHRD_IPDDP, ARPHRD_IPGRE,
         ARPHRD_PIMREG, ARPHRD_HIPPI, ARPHRD_ASH, ARPHRD_ECONET,
         ARPHRD_IRDA, ARPHRD_FCPP, ARPHRD_FCAL, ARPHRD_FCPL,
-        ARPHRD_FCFABRIC, ARPHRD_IEEE802_TR, ARPHRD_IEEE80211,
-        ARPHRD_IEEE80211_PRISM, ARPHRD_IEEE80211_RADIOTAP, ARPHRD_PHONET,
-        ARPHRD_PHONET_PIPE, ARPHRD_IEEE802154,
-        ARPHRD_VOID, ARPHRD_NONE};
+        ARPHRD_FCFABRIC, ARPHRD_IEEE80211, ARPHRD_IEEE80211_PRISM,
+        ARPHRD_IEEE80211_RADIOTAP, ARPHRD_PHONET, ARPHRD_PHONET_PIPE,
+        ARPHRD_IEEE802154, ARPHRD_VOID, ARPHRD_NONE};
 
 static const char *const netdev_lock_name[] =
        {"_xmit_NETROM", "_xmit_ETHER", "_xmit_EETHER", "_xmit_AX25",
@@ -317,10 +317,9 @@ static const char *const netdev_lock_name[] =
         "_xmit_BIF", "_xmit_SIT", "_xmit_IPDDP", "_xmit_IPGRE",
         "_xmit_PIMREG", "_xmit_HIPPI", "_xmit_ASH", "_xmit_ECONET",
         "_xmit_IRDA", "_xmit_FCPP", "_xmit_FCAL", "_xmit_FCPL",
-        "_xmit_FCFABRIC", "_xmit_IEEE802_TR", "_xmit_IEEE80211",
-        "_xmit_IEEE80211_PRISM", "_xmit_IEEE80211_RADIOTAP", "_xmit_PHONET",
-        "_xmit_PHONET_PIPE", "_xmit_IEEE802154",
-        "_xmit_VOID", "_xmit_NONE"};
+        "_xmit_FCFABRIC", "_xmit_IEEE80211", "_xmit_IEEE80211_PRISM",
+        "_xmit_IEEE80211_RADIOTAP", "_xmit_PHONET", "_xmit_PHONET_PIPE",
+        "_xmit_IEEE802154", "_xmit_VOID", "_xmit_NONE"};
 
 static struct lock_class_key netdev_xmit_lock_key[ARRAY_SIZE(netdev_lock_type)];
 static struct lock_class_key netdev_addr_lock_key[ARRAY_SIZE(netdev_lock_type)];
@@ -1137,8 +1136,8 @@ void dev_load(struct net *net, const char *name)
                no_module = request_module("netdev-%s", name);
        if (no_module && capable(CAP_SYS_MODULE)) {
                if (!request_module("%s", name))
-                       pr_err("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
-                              name);
+                       pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated).  Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
+                               name);
        }
 }
 EXPORT_SYMBOL(dev_load);
@@ -1676,10 +1675,9 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 
                        if (skb_network_header(skb2) < skb2->data ||
                            skb2->network_header > skb2->tail) {
-                               if (net_ratelimit())
-                                       pr_crit("protocol %04x is buggy, dev %s\n",
-                                               ntohs(skb2->protocol),
-                                               dev->name);
+                               net_crit_ratelimited("protocol %04x is buggy, dev %s\n",
+                                                    ntohs(skb2->protocol),
+                                                    dev->name);
                                skb_reset_network_header(skb2);
                        }
 
@@ -2091,25 +2089,6 @@ static int dev_gso_segment(struct sk_buff *skb, netdev_features_t features)
        return 0;
 }
 
-/*
- * Try to orphan skb early, right before transmission by the device.
- * We cannot orphan skb if tx timestamp is requested or the sk-reference
- * is needed on driver level for other reasons, e.g. see net/can/raw.c
- */
-static inline void skb_orphan_try(struct sk_buff *skb)
-{
-       struct sock *sk = skb->sk;
-
-       if (sk && !skb_shinfo(skb)->tx_flags) {
-               /* skb_tx_hash() wont be able to get sk.
-                * We copy sk_hash into skb->rxhash
-                */
-               if (!skb->rxhash)
-                       skb->rxhash = sk->sk_hash;
-               skb_orphan(skb);
-       }
-}
-
 static bool can_checksum_protocol(netdev_features_t features, __be16 protocol)
 {
        return ((features & NETIF_F_GEN_CSUM) ||
@@ -2195,8 +2174,6 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
                if (!list_empty(&ptype_all))
                        dev_queue_xmit_nit(skb, dev);
 
-               skb_orphan_try(skb);
-
                features = netif_skb_features(skb);
 
                if (vlan_tx_tag_present(skb) &&
@@ -2306,7 +2283,7 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
        if (skb->sk && skb->sk->sk_hash)
                hash = skb->sk->sk_hash;
        else
-               hash = (__force u16) skb->protocol ^ skb->rxhash;
+               hash = (__force u16) skb->protocol;
        hash = jhash_1word(hash, hashrnd);
 
        return (u16) (((u64) hash * qcount) >> 32) + qoffset;
@@ -2316,11 +2293,9 @@ EXPORT_SYMBOL(__skb_tx_hash);
 static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index)
 {
        if (unlikely(queue_index >= dev->real_num_tx_queues)) {
-               if (net_ratelimit()) {
-                       pr_warn("%s selects TX queue %d, but real number of TX queues is %d\n",
-                               dev->name, queue_index,
-                               dev->real_num_tx_queues);
-               }
+               net_warn_ratelimited("%s selects TX queue %d, but real number of TX queues is %d\n",
+                                    dev->name, queue_index,
+                                    dev->real_num_tx_queues);
                return 0;
        }
        return queue_index;
@@ -2562,17 +2537,15 @@ int dev_queue_xmit(struct sk_buff *skb)
                                }
                        }
                        HARD_TX_UNLOCK(dev, txq);
-                       if (net_ratelimit())
-                               pr_crit("Virtual device %s asks to queue packet!\n",
-                                       dev->name);
+                       net_crit_ratelimited("Virtual device %s asks to queue packet!\n",
+                                            dev->name);
                } else {
                        /* Recursion is detected! It is possible,
                         * unfortunately
                         */
 recursion_alert:
-                       if (net_ratelimit())
-                               pr_crit("Dead loop on virtual device %s, fix it urgently!\n",
-                                       dev->name);
+                       net_crit_ratelimited("Dead loop on virtual device %s, fix it urgently!\n",
+                                            dev->name);
                }
        }
 
@@ -3053,9 +3026,8 @@ static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq)
        struct Qdisc *q;
 
        if (unlikely(MAX_RED_LOOP < ttl++)) {
-               if (net_ratelimit())
-                       pr_warn("Redir loop detected Dropping packet (%d->%d)\n",
-                               skb->skb_iif, dev->ifindex);
+               net_warn_ratelimited("Redir loop detected Dropping packet (%d->%d)\n",
+                                    skb->skb_iif, dev->ifindex);
                return TC_ACT_SHOT;
        }
 
@@ -3515,10 +3487,16 @@ gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb)
                break;
 
        case GRO_DROP:
-       case GRO_MERGED_FREE:
                kfree_skb(skb);
                break;
 
+       case GRO_MERGED_FREE:
+               if (NAPI_GRO_CB(skb)->free == NAPI_GRO_FREE_STOLEN_HEAD)
+                       kmem_cache_free(skbuff_head_cache, skb);
+               else
+                       __kfree_skb(skb);
+               break;
+
        case GRO_HELD:
        case GRO_MERGED:
                break;
@@ -3603,7 +3581,7 @@ gro_result_t napi_frags_finish(struct napi_struct *napi, struct sk_buff *skb,
 }
 EXPORT_SYMBOL(napi_frags_finish);
 
-struct sk_buff *napi_frags_skb(struct napi_struct *napi)
+static struct sk_buff *napi_frags_skb(struct napi_struct *napi)
 {
        struct sk_buff *skb = napi->skb;
        struct ethhdr *eth;
@@ -3638,7 +3616,6 @@ struct sk_buff *napi_frags_skb(struct napi_struct *napi)
 out:
        return skb;
 }
-EXPORT_SYMBOL(napi_frags_skb);
 
 gro_result_t napi_gro_frags(struct napi_struct *napi)
 {
@@ -4592,9 +4569,9 @@ void dev_set_rx_mode(struct net_device *dev)
  *
  *     Get the combination of flag bits exported through APIs to userspace.
  */
-unsigned dev_get_flags(const struct net_device *dev)
+unsigned int dev_get_flags(const struct net_device *dev)
 {
-       unsigned flags;
+       unsigned int flags;
 
        flags = (dev->flags & ~(IFF_PROMISC |
                                IFF_ALLMULTI |