From c25290420ee7b9f4a875426380d8ad042a561b9c Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 1 Dec 2014 11:45:24 +0000 Subject: [PATCH] Start process of removing the use of the deprecated "M_FLOWID" flag from the FreeBSD network code. The flag is still kept around in the "sys/mbuf.h" header file, but does no longer have any users. Instead the "m_pkthdr.rsstype" field in the mbuf structure is now used to decide the meaning of the "m_pkthdr.flowid" field. To modify the "m_pkthdr.rsstype" field please use the existing "M_HASHTYPE_XXX" macros as defined in the "sys/mbuf.h" header file. This patch introduces new behaviour in the transmit direction. Previously network drivers checked if "M_FLOWID" was set in "m_flags" before using the "m_pkthdr.flowid" field. This check has now now been replaced by checking if "M_HASHTYPE_GET(m)" is different from "M_HASHTYPE_NONE". In the future more hashtypes will be added, for example hashtypes for hardware dedicated flows. "M_HASHTYPE_OPAQUE" indicates that the "m_pkthdr.flowid" value is valid and has no particular type. This change removes the need for an "if" statement in TCP transmit code checking for the presence of a valid flowid value. The "if" statement mentioned above is now a direct variable assignment which is then later checked by the respective network drivers like before. Additional notes: - The SCTP code changes will be committed as a separate patch. - Removal of the "M_FLOWID" flag will also be done separately. - The FreeBSD version has been bumped. MFC after: 1 month Sponsored by: Mellanox Technologies --- sys/dev/bxe/bxe.c | 9 ++++----- sys/dev/cxgb/cxgb_sge.c | 12 +++++++----- sys/dev/cxgbe/t4_main.c | 3 ++- sys/dev/cxgbe/t4_sge.c | 2 +- sys/dev/e1000/if_igb.c | 7 +++---- sys/dev/ixgbe/ixgbe.c | 8 ++++---- sys/dev/ixgbe/ixv.c | 4 ++-- sys/dev/ixl/ixl_txrx.c | 6 +++--- sys/dev/mxge/if_mxge.c | 4 ++-- sys/dev/netmap/netmap_freebsd.c | 4 ++-- sys/dev/oce/oce_if.c | 4 ++-- sys/dev/qlxgbe/ql_isr.c | 4 ++-- sys/dev/qlxgbe/ql_os.c | 3 ++- sys/dev/qlxge/qls_isr.c | 2 +- sys/dev/qlxge/qls_os.c | 3 ++- sys/dev/sfxge/sfxge_rx.c | 4 ++-- sys/dev/sfxge/sfxge_tx.c | 3 ++- sys/dev/virtio/network/if_vtnet.c | 5 +++-- sys/dev/vmware/vmxnet3/if_vmx.c | 5 +++-- sys/dev/vxge/vxge.c | 4 ++-- sys/net/flowtable.c | 4 ++-- sys/net/ieee8023ad_lacp.c | 3 ++- sys/net/if_lagg.c | 7 ++++--- sys/net/if_lagg.h | 4 ++-- sys/net/if_vxlan.c | 1 + sys/net/netisr.c | 5 +++-- sys/netinet/in_pcb.h | 4 ++-- sys/netinet/in_rss.c | 11 +++++------ sys/netinet/ip_input.c | 1 - sys/netinet/ip_output.c | 4 +--- sys/netinet/tcp_input.c | 10 ++++------ sys/netinet/tcp_syncache.c | 4 +--- sys/netinet/udp_usrreq.c | 12 ++++-------- sys/netinet6/in6_pcb.c | 2 +- sys/netinet6/ip6_output.c | 6 +++--- sys/netinet6/udp6_usrreq.c | 1 - sys/ofed/drivers/net/mlx4/en_rx.c | 2 +- sys/ofed/drivers/net/mlx4/en_tx.c | 19 +++++++++---------- sys/sys/param.h | 2 +- 39 files changed, 97 insertions(+), 101 deletions(-) diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index a27b3e7a56bd..3509f2d023df 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -3219,7 +3219,7 @@ bxe_tpa_stop(struct bxe_softc *sc, #if __FreeBSD_version >= 800000 /* specify what RSS queue was used for this flow */ m->m_pkthdr.flowid = fp->index; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); @@ -3454,7 +3454,7 @@ bxe_rxeof(struct bxe_softc *sc, #if __FreeBSD_version >= 800000 /* specify what RSS queue was used for this flow */ m->m_pkthdr.flowid = fp->index; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif next_rx: @@ -6037,10 +6037,9 @@ bxe_tx_mq_start(struct ifnet *ifp, fp_index = 0; /* default is the first queue */ - /* change the queue if using flow ID */ - if ((m->m_flags & M_FLOWID) != 0) { + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) fp_index = (m->m_pkthdr.flowid % sc->num_queues); - } fp = &sc->fp[fp_index]; diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index a7f39a510109..2b08183b0cd5 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -1733,8 +1733,9 @@ cxgb_transmit(struct ifnet *ifp, struct mbuf *m) m_freem(m); return (0); } - - if (m->m_flags & M_FLOWID) + + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) qidx = (m->m_pkthdr.flowid % pi->nqsets) + pi->first_qset; qs = &pi->adapter->sge.qs[qidx]; @@ -2899,9 +2900,10 @@ process_responses(adapter_t *adap, struct sge_qset *qs, int budget) eop = get_packet(adap, drop_thresh, qs, mh, r); if (eop) { - if (r->rss_hdr.hash_type && !adap->timestamp) - mh->mh_head->m_flags |= M_FLOWID; - mh->mh_head->m_pkthdr.flowid = rss_hash; + if (r->rss_hdr.hash_type && !adap->timestamp) { + M_HASHTYPE_SET(mh->mh_head, M_HASHTYPE_OPAQUE); + mh->mh_head->m_pkthdr.flowid = rss_hash; + } } ethpad = 2; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index f9caf2eec1d8..2c384fd0f1a6 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -1440,7 +1440,8 @@ cxgbe_transmit(struct ifnet *ifp, struct mbuf *m) return (ENETDOWN); } - if (m->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) txq += ((m->m_pkthdr.flowid % (pi->ntxq - pi->rsrv_noflowq)) + pi->rsrv_noflowq); br = txq->br; diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 499f25205998..58940fe4959c 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -1734,7 +1734,7 @@ t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0) m0->m_data += fl_pktshift; m0->m_pkthdr.rcvif = ifp; - m0->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m0, M_HASHTYPE_OPAQUE); m0->m_pkthdr.flowid = be32toh(rss->hash_val); if (cpl->csum_calc && !cpl->err_vec) { diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 335aa01d95c9..75f0fb419d50 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -990,7 +990,7 @@ igb_mq_start(struct ifnet *ifp, struct mbuf *m) * If everything is setup correctly, it should be the * same bucket that the current CPU we're on is. */ - if ((m->m_flags & M_FLOWID) != 0) { + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { #ifdef RSS if (rss_hash2bucket(m->m_pkthdr.flowid, M_HASHTYPE_GET(m), &bucket_id) == 0) { @@ -5166,7 +5166,6 @@ igb_rxeof(struct igb_queue *que, int count, int *done) /* XXX set flowtype once this works right */ rxr->fmp->m_pkthdr.flowid = le32toh(cur->wb.lower.hi_dword.rss); - rxr->fmp->m_flags |= M_FLOWID; switch (pkt_info & E1000_RXDADV_RSSTYPE_MASK) { case E1000_RXDADV_RSSTYPE_IPV4_TCP: M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_RSS_TCP_IPV4); @@ -5196,11 +5195,11 @@ igb_rxeof(struct igb_queue *que, int count, int *done) default: /* XXX fallthrough */ - M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_NONE); + M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_OPAQUE); } #elif !defined(IGB_LEGACY_TX) rxr->fmp->m_pkthdr.flowid = que->msix; - rxr->fmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_OPAQUE); #endif sendmp = rxr->fmp; /* Make sure to set M_PKTHDR. */ diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index 9ac70eeac5e4..2fd126c5396e 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -833,7 +833,7 @@ ixgbe_mq_start(struct ifnet *ifp, struct mbuf *m) * If everything is setup correctly, it should be the * same bucket that the current CPU we're on is. */ - if ((m->m_flags & M_FLOWID) != 0) { + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { #ifdef RSS if (rss_hash2bucket(m->m_pkthdr.flowid, M_HASHTYPE_GET(m), &bucket_id) == 0) { @@ -4764,7 +4764,6 @@ ixgbe_rxeof(struct ix_queue *que) #ifdef RSS sendmp->m_pkthdr.flowid = le32toh(cur->wb.lower.hi_dword.rss); - sendmp->m_flags |= M_FLOWID; switch (pkt_info & IXGBE_RXDADV_RSSTYPE_MASK) { case IXGBE_RXDADV_RSSTYPE_IPV4_TCP: M_HASHTYPE_SET(sendmp, M_HASHTYPE_RSS_TCP_IPV4); @@ -4795,11 +4794,12 @@ ixgbe_rxeof(struct ix_queue *que) break; default: /* XXX fallthrough */ - M_HASHTYPE_SET(sendmp, M_HASHTYPE_NONE); + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); + break; } #else /* RSS */ sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); #endif /* RSS */ #endif /* FreeBSD_version */ } diff --git a/sys/dev/ixgbe/ixv.c b/sys/dev/ixgbe/ixv.c index 1d77e8b5a27a..edbdfca85920 100644 --- a/sys/dev/ixgbe/ixv.c +++ b/sys/dev/ixgbe/ixv.c @@ -580,7 +580,7 @@ ixv_mq_start(struct ifnet *ifp, struct mbuf *m) int i = 0, err = 0; /* Which queue to use */ - if ((m->m_flags & M_FLOWID) != 0) + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % adapter->num_queues; txr = &adapter->tx_rings[i]; @@ -3464,7 +3464,7 @@ ixv_rxeof(struct ix_queue *que, int count) ixv_rx_checksum(staterr, sendmp, ptype); #if __FreeBSD_version >= 800000 sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); #endif } next_desc: diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c index 6322f2c9fd0e..f36b8318961d 100755 --- a/sys/dev/ixl/ixl_txrx.c +++ b/sys/dev/ixl/ixl_txrx.c @@ -66,8 +66,8 @@ ixl_mq_start(struct ifnet *ifp, struct mbuf *m) struct tx_ring *txr; int err, i; - /* Which queue to use */ - if ((m->m_flags & M_FLOWID) != 0) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % vsi->num_queues; else i = curcpu % vsi->num_queues; @@ -1543,7 +1543,7 @@ ixl_rxeof(struct ixl_queue *que, int count) if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) ixl_rx_checksum(sendmp, status, error, ptype); sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); } next_desc: bus_dmamap_sync(rxr->dma.tag, rxr->dma.map, diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c index e97ae5c7130e..fe8c08a72495 100644 --- a/sys/dev/mxge/if_mxge.c +++ b/sys/dev/mxge/if_mxge.c @@ -2719,7 +2719,7 @@ mxge_rx_done_big(struct mxge_slice_state *ss, uint32_t len, /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { m->m_pkthdr.flowid = (ss - sc->ss); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); } /* pass the frame up the stack */ (*ifp->if_input)(ifp, m); @@ -2787,7 +2787,7 @@ mxge_rx_done_small(struct mxge_slice_state *ss, uint32_t len, /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { m->m_pkthdr.flowid = (ss - sc->ss); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); } /* pass the frame up the stack */ (*ifp->if_input)(ifp, m); diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index 322670814553..dd968ca51577 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -204,7 +204,7 @@ netmap_catch_tx(struct netmap_generic_adapter *gna, int enable) * of the transmission does not consume resources. * * On FreeBSD, and on multiqueue cards, we can force the queue using - * if ((m->m_flags & M_FLOWID) != 0) + * if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) * i = m->m_pkthdr.flowid % adapter->num_queues; * else * i = curcpu % adapter->num_queues; @@ -240,7 +240,7 @@ generic_xmit_frame(struct ifnet *ifp, struct mbuf *m, m->m_len = m->m_pkthdr.len = len; // inc refcount. All ours, we could skip the atomic atomic_fetchadd_int(PNT_MBUF_REFCNT(m), 1); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); m->m_pkthdr.flowid = ring_nr; m->m_pkthdr.rcvif = ifp; /* used for tx notification */ ret = NA(ifp)->if_transmit(ifp, m); diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c index fe48007e8973..062181b2367b 100644 --- a/sys/dev/oce/oce_if.c +++ b/sys/dev/oce/oce_if.c @@ -563,7 +563,7 @@ oce_multiq_start(struct ifnet *ifp, struct mbuf *m) int queue_index = 0; int status = 0; - if ((m->m_flags & M_FLOWID) != 0) + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) queue_index = m->m_pkthdr.flowid % sc->nwqs; wq = sc->wq[queue_index]; @@ -1374,7 +1374,7 @@ oce_rx(struct oce_rq *rq, uint32_t rqe_idx, struct oce_nic_rx_cqe *cqe) m->m_pkthdr.flowid = (rq->queue_index - 1); else m->m_pkthdr.flowid = rq->queue_index; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif /* This deternies if vlan tag is Valid */ if (oce_cqe_vtp_valid(sc, cqe)) { diff --git a/sys/dev/qlxgbe/ql_isr.c b/sys/dev/qlxgbe/ql_isr.c index db0029822927..dee8e198e8f4 100644 --- a/sys/dev/qlxgbe/ql_isr.c +++ b/sys/dev/qlxgbe/ql_isr.c @@ -159,7 +159,7 @@ qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx) if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); mpf->m_pkthdr.flowid = sgc->rss_hash; - mpf->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE); (*ifp->if_input)(ifp, mpf); @@ -324,7 +324,7 @@ qla_lro_intr(qla_host_t *ha, qla_sgl_lro_t *sgc, uint32_t sds_idx) mpf->m_pkthdr.csum_data = 0xFFFF; mpf->m_pkthdr.flowid = sgc->rss_hash; - mpf->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE); if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); diff --git a/sys/dev/qlxgbe/ql_os.c b/sys/dev/qlxgbe/ql_os.c index 1684c070fcd8..04fbf7195529 100644 --- a/sys/dev/qlxgbe/ql_os.c +++ b/sys/dev/qlxgbe/ql_os.c @@ -1140,7 +1140,8 @@ qla_send(qla_host_t *ha, struct mbuf **m_headp) QL_DPRINT8(ha, (ha->pci_dev, "%s: enter\n", __func__)); - if (m_head->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m_head) != M_HASHTYPE_NONE) txr_idx = m_head->m_pkthdr.flowid & (ha->hw.num_tx_rings - 1); tx_idx = ha->hw.tx_cntxt[txr_idx].txr_next; diff --git a/sys/dev/qlxge/qls_isr.c b/sys/dev/qlxge/qls_isr.c index 14b4839be913..03b3a3c52152 100644 --- a/sys/dev/qlxge/qls_isr.c +++ b/sys/dev/qlxge/qls_isr.c @@ -190,7 +190,7 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e) if ((cq_e->flags1 & Q81_RX_FLAGS1_RSS_MATCH_MASK)) { rxr->rss_int++; mp->m_pkthdr.flowid = cq_e->rss; - mp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mp, M_HASHTYPE_OPAQUE); } if (cq_e->flags0 & (Q81_RX_FLAGS0_TE | Q81_RX_FLAGS0_NU | Q81_RX_FLAGS0_IE)) { diff --git a/sys/dev/qlxge/qls_os.c b/sys/dev/qlxge/qls_os.c index 4f4097935f0c..1617d24095e1 100644 --- a/sys/dev/qlxge/qls_os.c +++ b/sys/dev/qlxge/qls_os.c @@ -1136,7 +1136,8 @@ qls_send(qla_host_t *ha, struct mbuf **m_headp) QL_DPRINT8((ha->pci_dev, "%s: enter\n", __func__)); - if (m_head->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m_head) != M_HASHTYPE_NONE) txr_idx = m_head->m_pkthdr.flowid & (ha->num_tx_rings - 1); tx_idx = ha->tx_ring[txr_idx].txr_next; diff --git a/sys/dev/sfxge/sfxge_rx.c b/sys/dev/sfxge/sfxge_rx.c index 66083d832857..ccfdfb023d07 100644 --- a/sys/dev/sfxge/sfxge_rx.c +++ b/sys/dev/sfxge/sfxge_rx.c @@ -302,7 +302,7 @@ sfxge_rx_deliver(struct sfxge_softc *sc, struct sfxge_rx_sw_desc *rx_desc) if (rx_desc->flags & EFX_PKT_TCP) { m->m_pkthdr.flowid = EFX_RX_HASH_VALUE(EFX_RX_HASHALG_TOEPLITZ, mtod(m, uint8_t *)); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); } #endif m->m_data += sc->rx_prefix_size; @@ -353,7 +353,7 @@ sfxge_lro_deliver(struct sfxge_lro_state *st, struct sfxge_lro_conn *c) #ifdef SFXGE_HAVE_MQ m->m_pkthdr.flowid = c->conn_hash; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif m->m_pkthdr.csum_flags = csum_flags; __sfxge_rx_deliver(sc, m); diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c index a12c74756ea5..3fb76d92b6db 100644 --- a/sys/dev/sfxge/sfxge_tx.c +++ b/sys/dev/sfxge/sfxge_tx.c @@ -631,7 +631,8 @@ sfxge_if_transmit(struct ifnet *ifp, struct mbuf *m) if (m->m_pkthdr.csum_flags & (CSUM_DELAY_DATA | CSUM_TSO)) { int index = 0; - if (m->m_flags & M_FLOWID) { + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { uint32_t hash = m->m_pkthdr.flowid; index = sc->rx_indir_table[hash % SFXGE_RX_SCALE_MAX]; diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 83cb2d79fe25..9fba9bdabe0b 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1701,7 +1701,7 @@ vtnet_rxq_input(struct vtnet_rxq *rxq, struct mbuf *m, } m->m_pkthdr.flowid = rxq->vtnrx_id; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); /* * BMV: FreeBSD does not have the UNNECESSARY and PARTIAL checksum @@ -2347,7 +2347,8 @@ vtnet_txq_mq_start(struct ifnet *ifp, struct mbuf *m) sc = ifp->if_softc; npairs = sc->vtnet_act_vq_pairs; - if (m->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % npairs; else i = curcpu % npairs; diff --git a/sys/dev/vmware/vmxnet3/if_vmx.c b/sys/dev/vmware/vmxnet3/if_vmx.c index 1d8c12e2fc9b..5faf716acf4d 100644 --- a/sys/dev/vmware/vmxnet3/if_vmx.c +++ b/sys/dev/vmware/vmxnet3/if_vmx.c @@ -2059,7 +2059,7 @@ vmxnet3_rxq_input(struct vmxnet3_rxqueue *rxq, } #else m->m_pkthdr.flowid = rxq->vxrxq_id; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif if (!rxcd->no_csum) @@ -3002,7 +3002,8 @@ vmxnet3_txq_mq_start(struct ifnet *ifp, struct mbuf *m) sc = ifp->if_softc; ntxq = sc->vmx_ntxqueues; - if (m->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % ntxq; else i = curcpu % ntxq; diff --git a/sys/dev/vxge/vxge.c b/sys/dev/vxge/vxge.c index b89ba6cca51e..9a3cab654f95 100644 --- a/sys/dev/vxge/vxge.c +++ b/sys/dev/vxge/vxge.c @@ -660,7 +660,7 @@ vxge_mq_send(ifnet_t ifp, mbuf_t m_head) if (vdev->config.tx_steering) { i = vxge_vpath_get(vdev, m_head); - } else if ((m_head->m_flags & M_FLOWID) != 0) { + } else if (M_HASHTYPE_GET(m_head) != M_HASHTYPE_NONE) { i = m_head->m_pkthdr.flowid % vdev->no_of_vpath; } @@ -1070,7 +1070,7 @@ vxge_rx_compl(vxge_hal_vpath_h vpath_handle, vxge_hal_rxd_h rxdh, vxge_rx_checksum(ext_info, mbuf_up); #if __FreeBSD_version >= 800000 - mbuf_up->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mbuf_up, M_HASHTYPE_OPAQUE); mbuf_up->m_pkthdr.flowid = vpath->vp_index; #endif /* Post-Read sync for buffers */ diff --git a/sys/net/flowtable.c b/sys/net/flowtable.c index fe6a52cd3c10..0d584fea3581 100644 --- a/sys/net/flowtable.c +++ b/sys/net/flowtable.c @@ -688,8 +688,8 @@ flowtable_lookup(sa_family_t sa, struct mbuf *m, struct route *ro) if (fle == NULL) return (EHOSTUNREACH); - if (!(m->m_flags & M_FLOWID)) { - m->m_flags |= M_FLOWID; + if (M_HASHTYPE_GET(m) == M_HASHTYPE_NONE) { + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); m->m_pkthdr.flowid = fle->f_hash; } diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index 106df68e807a..75f6366e7888 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -835,7 +835,8 @@ lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m) return (NULL); } - if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && (m->m_flags & M_FLOWID)) + if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && + M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) hash = m->m_pkthdr.flowid >> sc->flowid_shift; else hash = lagg_hashmbuf(sc, m, lsc->lsc_hashkey); diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 5c8b2e1d2bdf..45315b6b3b55 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -247,14 +247,14 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(lagg_failover_rx_all), 0, "Accept input from any interface in a failover lagg"); -/* Default value for using M_FLOWID */ +/* Default value for using flowid */ static VNET_DEFINE(int, def_use_flowid) = 1; #define V_def_use_flowid VNET(def_use_flowid) SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RWTUN, &VNET_NAME(def_use_flowid), 0, "Default setting for using flow id for load sharing"); -/* Default value for using M_FLOWID */ +/* Default value for flowid shift */ static VNET_DEFINE(int, def_flowid_shift) = 16; #define V_def_flowid_shift VNET(def_flowid_shift) SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RWTUN, @@ -2148,7 +2148,8 @@ lagg_lb_start(struct lagg_softc *sc, struct mbuf *m) struct lagg_port *lp = NULL; uint32_t p = 0; - if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && (m->m_flags & M_FLOWID)) + if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && + M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) p = m->m_pkthdr.flowid >> sc->flowid_shift; else p = lagg_hashmbuf(sc, m, lb->lb_key); diff --git a/sys/net/if_lagg.h b/sys/net/if_lagg.h index e86ed06fcca7..8d6decd3c069 100644 --- a/sys/net/if_lagg.h +++ b/sys/net/if_lagg.h @@ -143,9 +143,9 @@ struct lagg_reqopts { int ro_opts; /* Option bitmap */ #define LAGG_OPT_NONE 0x00 -#define LAGG_OPT_USE_FLOWID 0x01 /* use M_FLOWID */ +#define LAGG_OPT_USE_FLOWID 0x01 /* enable use of flowid */ /* Pseudo flags which are used in ro_opts but not stored into sc_opts. */ -#define LAGG_OPT_FLOWIDSHIFT 0x02 /* Set flowid */ +#define LAGG_OPT_FLOWIDSHIFT 0x02 /* set flowid shift */ #define LAGG_OPT_FLOWIDSHIFT_MASK 0x1f /* flowid is uint32_t */ #define LAGG_OPT_LACP_STRICT 0x10 /* LACP strict mode */ #define LAGG_OPT_LACP_TXTEST 0x20 /* LACP debug: txtest */ diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index 5badf00051fd..59c76ebf4f1b 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -2236,6 +2236,7 @@ vxlan_pick_source_port(struct vxlan_softc *sc, struct mbuf *m) range = sc->vxl_max_port - sc->vxl_min_port + 1; + /* check if flowid is set and not opaque */ if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE && M_HASHTYPE_GET(m) != M_HASHTYPE_OPAQUE) hash = m->m_pkthdr.flowid; diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 049bbf192b53..178c3cbd1479 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -682,12 +682,13 @@ netisr_select_cpuid(struct netisr_proto *npp, u_int dispatch_policy, } if (policy == NETISR_POLICY_FLOW) { - if (!(m->m_flags & M_FLOWID) && npp->np_m2flow != NULL) { + if (M_HASHTYPE_GET(m) == M_HASHTYPE_NONE && + npp->np_m2flow != NULL) { m = npp->np_m2flow(m, source); if (m == NULL) return (NULL); } - if (m->m_flags & M_FLOWID) { + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { *cpuidp = netisr_default_flow2cpu(m->m_pkthdr.flowid); return (m); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 04ed0b0bdf83..606795a69bb0 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -530,8 +530,8 @@ short inp_so_options(const struct inpcb *inp); #define INP_ONESBCAST 0x02000000 /* send all-ones broadcast */ #define INP_DROPPED 0x04000000 /* protocol drop flag */ #define INP_SOCKREF 0x08000000 /* strong socket reference */ -#define INP_SW_FLOWID 0x10000000 /* software generated flow id */ -#define INP_HW_FLOWID 0x20000000 /* hardware generated flow id */ +#define INP_RESERVED_0 0x10000000 /* reserved field */ +#define INP_RESERVED_1 0x20000000 /* reserved field */ #define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */ #define IN6P_MTU 0x80000000 /* receive path MTU */ diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c index 7a548c2a8d2e..5d4f3c0dd37f 100644 --- a/sys/netinet/in_rss.c +++ b/sys/netinet/in_rss.c @@ -568,6 +568,8 @@ rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, uint32_t *hashval, const struct ip *ip; const struct tcphdr *th; const struct udphdr *uh; + uint32_t flowid; + uint32_t flowtype; uint8_t proto; int iphlen; int is_frag = 0; @@ -617,12 +619,10 @@ rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, uint32_t *hashval, * then we shouldn't just "trust" the 2-tuple hash. We need * a 4-tuple hash. */ - if (m->m_flags & M_FLOWID) { - uint32_t flowid, flowtype; - - flowid = m->m_pkthdr.flowid; - flowtype = M_HASHTYPE_GET(m); + flowid = m->m_pkthdr.flowid; + flowtype = M_HASHTYPE_GET(m); + if (flowtype != M_HASHTYPE_NONE) { switch (proto) { case IPPROTO_UDP: if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_UDP_IPV4) && @@ -743,7 +743,6 @@ rss_soft_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid) /* hash was done; update */ m->m_pkthdr.flowid = hash_val; M_HASHTYPE_SET(m, hash_type); - m->m_flags |= M_FLOWID; *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m)); } else { /* ret < 0 */ /* no hash was done */ diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index d0229b2dccd1..7b8127e90dae 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1196,7 +1196,6 @@ ip_reass(struct mbuf *m) if (rss_mbuf_software_hash_v4(m, 0, &rss_hash, &rss_type) == 0) { m->m_pkthdr.flowid = rss_hash; M_HASHTYPE_SET(m, rss_type); - m->m_flags |= M_FLOWID; } /* diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 5d791e57e99f..611c53c7e941 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -147,11 +147,9 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, if (inp != NULL) { INP_LOCK_ASSERT(inp); M_SETFIB(m, inp->inp_inc.inc_fibnum); - if (((flags & IP_NODEFAULTFLOWID) == 0) && - inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { + if ((flags & IP_NODEFAULTFLOWID) == 0) { m->m_pkthdr.flowid = inp->inp_flowid; M_HASHTYPE_SET(m, inp->inp_flowtype); - m->m_flags |= M_FLOWID; } } diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 005ccd05b3fa..e19d05ee318c 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -884,12 +884,10 @@ tcp_input(struct mbuf **mp, int *offp, int proto) goto dropwithreset; } INP_WLOCK_ASSERT(inp); - if (!(inp->inp_flags & INP_HW_FLOWID) - && (m->m_flags & M_FLOWID) - && ((inp->inp_socket == NULL) - || !(inp->inp_socket->so_options & SO_ACCEPTCONN))) { - inp->inp_flags |= INP_HW_FLOWID; - inp->inp_flags &= ~INP_SW_FLOWID; + if ((inp->inp_flowtype == M_HASHTYPE_NONE) && + (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) && + ((inp->inp_socket == NULL) || + (inp->inp_socket->so_options & SO_ACCEPTCONN) == 0)) { inp->inp_flowid = m->m_pkthdr.flowid; inp->inp_flowtype = M_HASHTYPE_GET(m); } diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 05c50769531b..c7570e2a26d7 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -713,9 +713,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) * If there's an mbuf and it has a flowid, then let's initialise the * inp with that particular flowid. */ - if (m != NULL && m->m_flags & M_FLOWID) { - inp->inp_flags |= INP_HW_FLOWID; - inp->inp_flags &= ~INP_SW_FLOWID; + if (m != NULL && M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { inp->inp_flowid = m->m_pkthdr.flowid; inp->inp_flowtype = M_HASHTYPE_GET(m); } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index c4ef9f07f708..5fd93b3bcff9 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1106,8 +1106,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, uint8_t pr; uint16_t cscov = 0; uint32_t flowid = 0; - int flowid_type = 0; - int use_flowid = 0; + uint8_t flowtype = M_HASHTYPE_NONE; /* * udp_output() may need to temporarily bind or connect the current @@ -1184,8 +1183,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, error = EINVAL; break; } - flowid_type = *(uint32_t *) CMSG_DATA(cm); - use_flowid = 1; + flowtype = *(uint32_t *) CMSG_DATA(cm); break; #ifdef RSS @@ -1451,10 +1449,9 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, * Once the UDP code decides to set a flowid some other way, * this allows the flowid to be overridden by userland. */ - if (use_flowid) { - m->m_flags |= M_FLOWID; + if (flowtype != M_HASHTYPE_NONE) { m->m_pkthdr.flowid = flowid; - M_HASHTYPE_SET(m, flowid_type); + M_HASHTYPE_SET(m, flowtype); #ifdef RSS } else { uint32_t hash_val, hash_type; @@ -1477,7 +1474,6 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, if (rss_proto_software_hash_v4(faddr, laddr, fport, lport, pr, &hash_val, &hash_type) == 0) { m->m_pkthdr.flowid = hash_val; - m->m_flags |= M_FLOWID; M_HASHTYPE_SET(m, hash_type); } #endif diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 2a7b9dcf40f5..3b61849d4187 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1252,7 +1252,7 @@ in6_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, * XXXRW: As above, that policy belongs in the pcbgroup code. */ if (in_pcbgroup_enabled(pcbinfo) && - !(M_HASHTYPE_TEST(m, M_HASHTYPE_NONE))) { + M_HASHTYPE_TEST(m, M_HASHTYPE_NONE) == 0) { pcbgroup = in6_pcbgroup_byhash(pcbinfo, M_HASHTYPE_GET(m), m->m_pkthdr.flowid); if (pcbgroup != NULL) diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 4245a9fdb9e0..74d7483aa947 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -267,10 +267,10 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, if (inp != NULL) { M_SETFIB(m, inp->inp_inc.inc_fibnum); - if (((flags & IP_NODEFAULTFLOWID) == 0) && - (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID))) { + if ((flags & IP_NODEFAULTFLOWID) == 0) { + /* unconditionally set flowid */ m->m_pkthdr.flowid = inp->inp_flowid; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, inp->inp_flowtype); } } diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 6c6f27a6e5d3..2b07b8e63fd9 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -843,7 +843,6 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, */ #ifdef RSS m->m_pkthdr.flowid = rss_hash_ip6_2tuple(*faddr, *laddr); - m->m_flags |= M_FLOWID; M_HASHTYPE_SET(m, M_HASHTYPE_RSS_IPV6); #endif flags = 0; diff --git a/sys/ofed/drivers/net/mlx4/en_rx.c b/sys/ofed/drivers/net/mlx4/en_rx.c index 320462ec02ad..fa263266d67d 100644 --- a/sys/ofed/drivers/net/mlx4/en_rx.c +++ b/sys/ofed/drivers/net/mlx4/en_rx.c @@ -604,7 +604,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud } mb->m_pkthdr.flowid = cq->ring; - mb->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE); mb->m_pkthdr.rcvif = dev; if (be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_VLAN_PRESENT_MASK) { diff --git a/sys/ofed/drivers/net/mlx4/en_tx.c b/sys/ofed/drivers/net/mlx4/en_tx.c index d1931558bcc9..d92677fa5ce3 100644 --- a/sys/ofed/drivers/net/mlx4/en_tx.c +++ b/sys/ofed/drivers/net/mlx4/en_tx.c @@ -720,8 +720,11 @@ u16 mlx4_en_select_queue(struct net_device *dev, struct mbuf *mb) up = (vlan_tag >> 13); } - /* hash mbuf */ - queue_index = mlx4_en_hashmbuf(MLX4_F_HASHL3 | MLX4_F_HASHL4, mb, hashrandom); + /* check if flowid is set */ + if (M_HASHTYPE_GET(mb) != M_HASHTYPE_NONE) + queue_index = mb->m_pkthdr.flowid; + else + queue_index = mlx4_en_hashmbuf(MLX4_F_HASHL3 | MLX4_F_HASHL4, mb, hashrandom); return ((queue_index % rings_p_up) + (up * rings_p_up)); } @@ -1066,15 +1069,11 @@ mlx4_en_transmit(struct ifnet *dev, struct mbuf *m) struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_tx_ring *ring; struct mlx4_en_cq *cq; - int i = 0, err = 0; + int i, err = 0; + + /* Compute which queue to use */ + i = mlx4_en_select_queue(dev, m); - /* Which queue to use */ - if ((m->m_flags & (M_FLOWID | M_VLANTAG)) == M_FLOWID) { - i = m->m_pkthdr.flowid % (priv->tx_ring_num - 1); - } - else { - i = mlx4_en_select_queue(dev, m); - } ring = priv->tx_ring[i]; if (spin_trylock(&ring->tx_lock)) { diff --git a/sys/sys/param.h b/sys/sys/param.h index 1afd4ea3e920..3d97bef5266b 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100047 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100048 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,