mbuf: Factor function to set mbuf hash.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 17 Dec 2016 13:20:58 +0000 (21:20 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 17 Dec 2016 13:20:58 +0000 (21:20 +0800)
sys/dev/netif/bce/if_bce.c
sys/dev/netif/bnx/if_bnx.c
sys/dev/netif/emx/if_emx.c
sys/dev/netif/igb/if_igb.c
sys/dev/netif/ix/if_ix.c
sys/dev/netif/jme/if_jme.c
sys/net/netisr.c
sys/netinet/ip_demux.c
sys/netproto/mpls/mpls_demux.c
sys/sys/mbuf.h

index f008aeb..3cda368 100644 (file)
@@ -4495,9 +4495,8 @@ bce_rx_intr(struct bce_rx_ring *rxr, int count, uint16_t hw_cons)
                                pi = bce_rss_pktinfo(&pi0, status, l2fhdr);
                                if (pi != NULL &&
                                    (status & L2_FHDR_STATUS_RSS_HASH)) {
-                                       m->m_flags |= M_HASH;
-                                       m->m_pkthdr.hash =
-                                           toeplitz_hash(l2fhdr->l2_fhdr_hash);
+                                       m_sethash(m,
+                                           toeplitz_hash(l2fhdr->l2_fhdr_hash));
                                }
                        }
 
index de550a3..0511b46 100644 (file)
@@ -2856,11 +2856,8 @@ bnx_rxeof(struct bnx_rx_ret_ring *ret, uint16_t rx_prod, int count)
                if (ifp->if_capenable & IFCAP_RSS) {
                        pi = bnx_rss_info(&pi0, cur_rx);
                        if (pi != NULL &&
-                           (cur_rx->bge_flags & BGE_RXBDFLAG_RSS_HASH)) {
-                               m->m_flags |= M_HASH;
-                               m->m_pkthdr.hash =
-                                   toeplitz_hash(cur_rx->bge_hash);
-                       }
+                           (cur_rx->bge_flags & BGE_RXBDFLAG_RSS_HASH))
+                               m_sethash(m, toeplitz_hash(cur_rx->bge_hash));
                }
 
                /*
index 0f95280..41f95d9 100644 (file)
@@ -407,8 +407,7 @@ emx_rssinfo(struct mbuf *m, struct pktinfo *pi,
                return NULL;
        }
 
-       m->m_flags |= M_HASH;
-       m->m_pkthdr.hash = toeplitz_hash(hash);
+       m_sethash(m, toeplitz_hash(hash));
        return pi;
 }
 
index 5e2c67a..a55db7a 100644 (file)
@@ -349,8 +349,7 @@ igb_rssinfo(struct mbuf *m, struct pktinfo *pi,
                return NULL;
        }
 
-       m->m_flags |= M_HASH;
-       m->m_pkthdr.hash = toeplitz_hash(hash);
+       m_sethash(m, toeplitz_hash(hash));
        return pi;
 }
 
index e807fa2..bfb9b9f 100644 (file)
@@ -2704,8 +2704,7 @@ ix_rssinfo(struct mbuf *m, struct pktinfo *pi,
                return NULL;
        }
 
-       m->m_flags |= M_HASH;
-       m->m_pkthdr.hash = toeplitz_hash(hash);
+       m_sethash(m, toeplitz_hash(hash));
        return pi;
 }
 
index 98e5c17..79affc3 100644 (file)
@@ -2469,8 +2469,8 @@ jme_rxpkt(struct jme_rxdata *rdata, int cpuid)
                        if (pi != NULL &&
                            (hashinfo & JME_RD_HASH_FN_MASK) ==
                            JME_RD_HASH_FN_TOEPLITZ) {
-                               m->m_flags |= (M_HASH | M_CKHASH);
-                               m->m_pkthdr.hash = toeplitz_hash(hash);
+                               m_sethash(m, toeplitz_hash(hash));
+                               m->m_flags |= M_CKHASH;
                        }
 
 #ifdef JME_RSS_DEBUG
index 3bce1ea..25f645d 100644 (file)
@@ -462,8 +462,7 @@ netisr_characterize(int num, struct mbuf **mp, int hoff)
 
        if (num < 0 || num >= NETISR_MAX) {
                if (num == NETISR_MAX) {
-                       m->m_flags |= M_HASH;
-                       m->m_pkthdr.hash = 0;
+                       m_sethash(m, 0);
                        return;
                }
                panic("Bad isr %d", num);
@@ -566,10 +565,8 @@ cpu0_ctlport(int cmd __unused, struct sockaddr *sa __unused,
 static void
 netisr_hashfn0(struct mbuf **mp, int hoff __unused)
 {
-       struct mbuf *m = *mp;
 
-       m->m_flags |= M_HASH;
-       m->m_pkthdr.hash = 0;
+       m_sethash(*mp, 0);
 }
 
 /*
index 1f1b818..49725ea 100644 (file)
@@ -313,8 +313,7 @@ ip_hashfn(struct mbuf **mptr, int hoff)
                break;
        }
 back:
-       m->m_flags |= M_HASH;
-       m->m_pkthdr.hash = hash;
+       m_sethash(m, hash);
 }
 
 /*
index a958930..9d04f0c 100644 (file)
@@ -98,7 +98,6 @@ mpls_hashfn(struct mbuf **mp, int hoff)
 
        label = MPLS_LABEL(ntohl(mpls->mpls_shim));
        ifp = m->m_pkthdr.rcvif;
-       m->m_pkthdr.hash = MPLSP_MPORT_HASH(label, ifp->if_index);
-       m->m_flags |= M_HASH;
+       m_sethash(m, MPLSP_MPORT_HASH(label, ifp->if_index));
 }
 
index 95cd7e9..6065805 100644 (file)
@@ -555,6 +555,13 @@ void               mbuftrackid(struct mbuf *, int);
 
 #endif
 
+static __inline void
+m_sethash(struct mbuf *m, uint16_t hash)
+{
+       m->m_flags |= M_HASH;
+       m->m_pkthdr.hash = hash;
+}
+
 /*
  * Allocate the right type of mbuf for the desired total length.
  * The mbuf returned does not necessarily cover the entire requested length.