From owner-svn-src-projects@FreeBSD.ORG Thu Mar 26 15:20:10 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5AEB81DC; Thu, 26 Mar 2015 15:20:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2D85C8BA; Thu, 26 Mar 2015 15:20:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2QFKAHN024771; Thu, 26 Mar 2015 15:20:10 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2QFKAnq024770; Thu, 26 Mar 2015 15:20:10 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201503261520.t2QFKAnq024770@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 26 Mar 2015 15:20:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r280694 - projects/ifnet/sys/net X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2015 15:20:10 -0000 Author: glebius Date: Thu Mar 26 15:20:09 2015 New Revision: 280694 URL: https://svnweb.freebsd.org/changeset/base/280694 Log: In SIOCSIFCAP case provide the logic that will enforce dependency of TSO on hardware checksum offloading. Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: projects/ifnet/sys/net/if.c Modified: projects/ifnet/sys/net/if.c ============================================================================== --- projects/ifnet/sys/net/if.c Thu Mar 26 15:19:03 2015 (r280693) +++ projects/ifnet/sys/net/if.c Thu Mar 26 15:20:09 2015 (r280694) @@ -2447,13 +2447,38 @@ if_drvioctl(struct ifnet *ifp, u_long cm error = priv_check(td, PRIV_NET_SETIFCAP); if (error) return (error); + /* + * All(?) NICs that do TSO require to perform VLAN tagging + * and checksum offloading in hardware, when doing TSO. + * Thus, turning TSO on implicitly turns on these features, + * and turning these features off implicitly turns off TSO. + */ if ((ifr->ifr_reqcap & IFCAP_VLAN_HWTSO) != 0) ifr->ifr_reqcap |= IFCAP_VLAN_HWTAGGING; + if ((ifr->ifr_reqcap & IFCAP_VLAN_HWTAGGING) == 0) + ifr->ifr_reqcap &= ~IFCAP_VLAN_HWTSO; + if ((ifr->ifr_reqcap & IFCAP_TSO4) != 0) + ifr->ifr_reqcap |= IFCAP_TXCSUM; + if ((ifr->ifr_reqcap & IFCAP_TXCSUM) == 0) + ifr->ifr_reqcap &= ~IFCAP_TSO4; + if ((ifr->ifr_reqcap & IFCAP_TSO6) != 0) + ifr->ifr_reqcap |= IFCAP_TXCSUM_IPV6; + if ((ifr->ifr_reqcap & IFCAP_TXCSUM_IPV6) == 0) + ifr->ifr_reqcap &= ~IFCAP_TSO6; + /* + * Now check that requested capabilities match + * what interface can actually do, and whether + * there is any change in the capenable. + */ if (ifr->ifr_reqcap & ~ifp->if_capabilities) return (EINVAL); if (ifr->ifr_reqcap == ifp->if_capenable) return (0); ifr->ifr_curcap = ifp->if_capenable; + /* + * See if driver accepts ifr_reqcap. It may also + * adjust them. Driver also fills in ifr_hwassist. + */ error = if_ioctl(ifp, cmd, data, td); if (error != 0) break;