From a2fdc5671475e29036fe901b16d6b2fab90f992c Mon Sep 17 00:00:00 2001 From: sephe Date: Tue, 10 Oct 2017 02:57:30 +0000 Subject: [PATCH] MFC 323175 hyperv/hn: Implement SIOCGIFRSS{KEY,HASH}. The conditional compiling in the review request is removed, since these IOCTLs will be available in stable/10 and stable/11. Reviewed by: gallatin Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12175 git-svn-id: svn://svn.freebsd.org/base/stable/10@324463 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/hyperv/netvsc/if_hn.c | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 7f5dfc66f..95c3fab64 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -3303,6 +3303,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr = (struct ifreq *)data, ifr_vf; struct ifnet *vf_ifp; int mask, error = 0; + struct ifrsskey *ifrk; + struct ifrsshash *ifrh; switch (cmd) { case SIOCSIFMTU: @@ -3560,6 +3562,56 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd); break; + case SIOCGIFRSSHASH: + ifrh = (struct ifrsshash *)data; + HN_LOCK(sc); + if (sc->hn_rx_ring_inuse == 1) { + HN_UNLOCK(sc); + ifrh->ifrh_func = RSS_FUNC_NONE; + ifrh->ifrh_types = 0; + break; + } + + if (sc->hn_rss_hash & NDIS_HASH_FUNCTION_TOEPLITZ) + ifrh->ifrh_func = RSS_FUNC_TOEPLITZ; + else + ifrh->ifrh_func = RSS_FUNC_PRIVATE; + + ifrh->ifrh_types = 0; + if (sc->hn_rss_hash & NDIS_HASH_IPV4) + ifrh->ifrh_types |= RSS_TYPE_IPV4; + if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV4) + ifrh->ifrh_types |= RSS_TYPE_TCP_IPV4; + if (sc->hn_rss_hash & NDIS_HASH_IPV6) + ifrh->ifrh_types |= RSS_TYPE_IPV6; + if (sc->hn_rss_hash & NDIS_HASH_IPV6_EX) + ifrh->ifrh_types |= RSS_TYPE_IPV6_EX; + if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV6) + ifrh->ifrh_types |= RSS_TYPE_TCP_IPV6; + if (sc->hn_rss_hash & NDIS_HASH_TCP_IPV6_EX) + ifrh->ifrh_types |= RSS_TYPE_TCP_IPV6_EX; + HN_UNLOCK(sc); + break; + + case SIOCGIFRSSKEY: + ifrk = (struct ifrsskey *)data; + HN_LOCK(sc); + if (sc->hn_rx_ring_inuse == 1) { + HN_UNLOCK(sc); + ifrk->ifrk_func = RSS_FUNC_NONE; + ifrk->ifrk_keylen = 0; + break; + } + if (sc->hn_rss_hash & NDIS_HASH_FUNCTION_TOEPLITZ) + ifrk->ifrk_func = RSS_FUNC_TOEPLITZ; + else + ifrk->ifrk_func = RSS_FUNC_PRIVATE; + ifrk->ifrk_keylen = NDIS_HASH_KEYSIZE_TOEPLITZ; + memcpy(ifrk->ifrk_key, sc->hn_rss.rss_key, + NDIS_HASH_KEYSIZE_TOEPLITZ); + HN_UNLOCK(sc); + break; + default: error = ether_ioctl(ifp, cmd, data); break; -- 2.45.0