From nobody Mon Sep 18 14:59:55 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rq7Hv49mpz4tKWn; Mon, 18 Sep 2023 14:59:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rq7Hv3R62z4fZY; Mon, 18 Sep 2023 14:59:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695049195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mXohJFqB5e+uVx62osqhE5cS/lxNt3oXwnLH6KXVzoU=; b=izzo9PARmbkca2vlgqd5pFXS3ubU67I7XxLhJjpl4OiWSvFxp01+Zxzi79+fM/tr2Okibr MLVRdKGY6YZViJccx9ngXmPduS3PJ64oG246ut79DrN2cFHW1gehcjzxlvyU9Nw91tYyKP GCW56IoIzcNUDtnsj5dB05X9ujWoEfXdLmg0VPmaPiSHpK7JNIte/R9a4ZcOmutfy4DGgK czezHkGu5cZh3d3BJAL84M3JEAnyEn3czTH78qofadQ/kIjT6Zl7YtLZ5qSNu/4KKQGUJs HBX9G8dCkLG3b8HDEVIPh1/HiRAhFnA+SJXRxrw3mg4T74EVyeCmcoiLUhM2uw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695049195; a=rsa-sha256; cv=none; b=jOMHET92X9LYshIbhNZ0ZkEUsvDuFHxZgJG+NMkADLJAS8UXcPyEccBQDouza2IHbAMiNN mxWZ0LzSPu5noTN2G+Z7oljszrrvZi394RqnZ3MSgz5XahPud+GC7FtftSAMh4lrw/gQNl s4pL87BqMx949hJZi7b+o+Fbr0seXxZK8Pn+KU2HWpJEYFCmz9LQAWxXqpW6RQ+TsD9NJS 6u7959iYeCYohXig+GHyoWd0EeUjOnRtmGVV4018tVHeB3qcGKT8KmFaJe7LkpwXntM9xQ ZGR9YEwQ9wGIvRXNqc7tq8HgKkjBtexkmo4vdiS8/PBPCq4srQSgeVQKcu7KkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695049195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mXohJFqB5e+uVx62osqhE5cS/lxNt3oXwnLH6KXVzoU=; b=xfJEQ2cE2cyJyty5QA6kY4tijgYNMYJ/kw+v2Bxtw6ObriWpdV/XGnuHTEzSSxcez93ELq +eKLy3sVfsyELjGnvXAEtJQSrW9rVqWlcef4NZG/lnF9ksqRWiT9H7CnB5/JxpTErhJrkN Mn6qcVZDC8pZxl8hkp00Zal8qPhKANlYkdebx4llOwFGdEj8x9qT8BRnCSv0BBumb7ijFo GcyKYCwf9De9LXl5Uv3tg++QgVqpYMa/45/biEeD8iE32pC5PvxcMR7VoGdqlmMrrLthGB hnyTlcfWz/B09SRVxL5Oz7JYRJDJb+GghhT10D2ZRzvCk93ePFpmdKxkl/JCEQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rq7Hv2Vbfzbdf; Mon, 18 Sep 2023 14:59:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38IExtFG047207; Mon, 18 Sep 2023 14:59:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38IExtWY047204; Mon, 18 Sep 2023 14:59:55 GMT (envelope-from git) Date: Mon, 18 Sep 2023 14:59:55 GMT Message-Id: <202309181459.38IExtWY047204@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Wei Hu Subject: git: f35cec70639f - releng/14.0 - mana: add ioctl to support toggling offloading features List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: whu X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: f35cec70639f3c937807feb6dc4081ae7d605265 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=f35cec70639f3c937807feb6dc4081ae7d605265 commit f35cec70639f3c937807feb6dc4081ae7d605265 Author: Wei Hu AuthorDate: 2023-09-13 10:48:02 +0000 Commit: Wei Hu CommitDate: 2023-09-18 14:56:48 +0000 mana: add ioctl to support toggling offloading features With this support, users can enable or disable offloading features such as txcsum, rxcsum, tso and software lro through ifconfig. To enable or disable tx features, do it on mana interface first, then hn/netvsc to sync it up with mana. For example: ifconfig mana0 -txcsum ifconfig hn0 -tscsum To enable or disable rx features, just applying on mana interface would be sufficient. Disabling txcsum imples disabling tso. Enabling tso when txcsum is disabled will result in an error message in dmesg requesting to enable txcsum first. Above applies to ipv6 offloading features as well. Approved by: re (gjb) Tested by: whu Sponsored by: Microsoft (cherry picked from commit ab7dc1ceb6d36fd804bedb818086ae3ff6692bf7) (cherry picked from commit 4edfbe719bf6a15dee388e65b39a116e9307be7f) --- sys/dev/mana/mana_en.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c index 56fa4e51ba26..064b28fa94a4 100644 --- a/sys/dev/mana/mana_en.c +++ b/sys/dev/mana/mana_en.c @@ -169,7 +169,7 @@ mana_ioctl(if_t ifp, u_long command, caddr_t data) struct ifrsshash *ifrh; struct ifreq *ifr; uint16_t new_mtu; - int rc = 0; + int rc = 0, mask; switch (command) { case SIOCSIFMTU: @@ -214,6 +214,81 @@ mana_ioctl(if_t ifp, u_long command, caddr_t data) } break; + case SIOCSIFCAP: + MANA_APC_LOCK_LOCK(apc); + ifr = (struct ifreq *)data; + /* + * Fix up requested capabilities w/ supported capabilities, + * since the supported capabilities could have been changed. + */ + mask = (ifr->ifr_reqcap & if_getcapabilities(ifp)) ^ + if_getcapenable(ifp); + + if (mask & IFCAP_TXCSUM) { + if_togglecapenable(ifp, IFCAP_TXCSUM); + if_togglehwassist(ifp, (CSUM_TCP | CSUM_UDP | CSUM_IP)); + + if ((IFCAP_TSO4 & if_getcapenable(ifp)) && + !(IFCAP_TXCSUM & if_getcapenable(ifp))) { + mask &= ~IFCAP_TSO4; + if_setcapenablebit(ifp, 0, IFCAP_TSO4); + if_sethwassistbits(ifp, 0, CSUM_IP_TSO); + mana_warn(NULL, + "Also disabled tso4 due to -txcsum.\n"); + } + } + + if (mask & IFCAP_TXCSUM_IPV6) { + if_togglecapenable(ifp, IFCAP_TXCSUM_IPV6); + if_togglehwassist(ifp, (CSUM_UDP_IPV6 | CSUM_TCP_IPV6)); + + if ((IFCAP_TSO6 & if_getcapenable(ifp)) && + !(IFCAP_TXCSUM_IPV6 & if_getcapenable(ifp))) { + mask &= ~IFCAP_TSO6; + if_setcapenablebit(ifp, 0, IFCAP_TSO6); + if_sethwassistbits(ifp, 0, CSUM_IP6_TSO); + mana_warn(ifp, + "Also disabled tso6 due to -txcsum6.\n"); + } + } + + if (mask & IFCAP_RXCSUM) + if_togglecapenable(ifp, IFCAP_RXCSUM); + /* We can't diff IPv6 packets from IPv4 packets on RX path. */ + if (mask & IFCAP_RXCSUM_IPV6) + if_togglecapenable(ifp, IFCAP_RXCSUM_IPV6); + + if (mask & IFCAP_LRO) + if_togglecapenable(ifp, IFCAP_LRO); + + if (mask & IFCAP_TSO4) { + if (!(IFCAP_TSO4 & if_getcapenable(ifp)) && + !(IFCAP_TXCSUM & if_getcapenable(ifp))) { + MANA_APC_LOCK_UNLOCK(apc); + if_printf(ifp, "Enable txcsum first.\n"); + rc = EAGAIN; + goto out; + } + if_togglecapenable(ifp, IFCAP_TSO4); + if_togglehwassist(ifp, CSUM_IP_TSO); + } + + if (mask & IFCAP_TSO6) { + if (!(IFCAP_TSO6 & if_getcapenable(ifp)) && + !(IFCAP_TXCSUM_IPV6 & if_getcapenable(ifp))) { + MANA_APC_LOCK_UNLOCK(apc); + if_printf(ifp, "Enable txcsum6 first.\n"); + rc = EAGAIN; + goto out; + } + if_togglecapenable(ifp, IFCAP_TSO6); + if_togglehwassist(ifp, CSUM_IP6_TSO); + } + + MANA_APC_LOCK_UNLOCK(apc); +out: + break; + case SIOCSIFMEDIA: case SIOCGIFMEDIA: case SIOCGIFXMEDIA: