From owner-svn-src-head@freebsd.org Thu Aug 16 23:46:39 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C392D107A8B1; Thu, 16 Aug 2018 23:46:39 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7A7587FD26; Thu, 16 Aug 2018 23:46:39 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5AF8A20804; Thu, 16 Aug 2018 23:46:39 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7GNkds8006826; Thu, 16 Aug 2018 23:46:39 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7GNkc2p006822; Thu, 16 Aug 2018 23:46:38 GMT (envelope-from np@FreeBSD.org) Message-Id: <201808162346.w7GNkc2p006822@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 16 Aug 2018 23:46:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337932 - in head/sys: net netinet X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: in head/sys: net netinet X-SVN-Commit-Revision: 337932 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2018 23:46:40 -0000 Author: np Date: Thu Aug 16 23:46:38 2018 New Revision: 337932 URL: https://svnweb.freebsd.org/changeset/base/337932 Log: Add the ability to look up the 3b PCP of a VLAN interface. Use it in toe_l2_resolve to fill up the complete vtag and not just the vid. Reviewed by: kib@ MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D16752 Modified: head/sys/net/if.c head/sys/net/if_vlan.c head/sys/net/if_vlan_var.h head/sys/netinet/toecore.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Thu Aug 16 22:13:43 2018 (r337931) +++ head/sys/net/if.c Thu Aug 16 23:46:38 2018 (r337932) @@ -2298,6 +2298,7 @@ void (*vlan_trunk_cap_p)(struct ifnet *); /* XXX: pri struct ifnet *(*vlan_trunkdev_p)(struct ifnet *); struct ifnet *(*vlan_devat_p)(struct ifnet *, uint16_t); int (*vlan_tag_p)(struct ifnet *, uint16_t *); +int (*vlan_pcp_p)(struct ifnet *, uint16_t *); int (*vlan_setcookie_p)(struct ifnet *, void *); void *(*vlan_cookie_p)(struct ifnet *); Modified: head/sys/net/if_vlan.c ============================================================================== --- head/sys/net/if_vlan.c Thu Aug 16 22:13:43 2018 (r337931) +++ head/sys/net/if_vlan.c Thu Aug 16 23:46:38 2018 (r337932) @@ -758,6 +758,18 @@ vlan_tag(struct ifnet *ifp, uint16_t *vidp) return (0); } +static int +vlan_pcp(struct ifnet *ifp, uint16_t *pcpp) +{ + struct ifvlan *ifv; + + if (ifp->if_type != IFT_L2VLAN) + return (EINVAL); + ifv = ifp->if_softc; + *pcpp = ifv->ifv_pcp; + return (0); +} + /* * Return a driver specific cookie for this interface. Synchronization * with setcookie must be provided by the driver. @@ -861,6 +873,7 @@ vlan_modevent(module_t mod, int type, void *data) vlan_cookie_p = vlan_cookie; vlan_setcookie_p = vlan_setcookie; vlan_tag_p = vlan_tag; + vlan_pcp_p = vlan_pcp; vlan_devat_p = vlan_devat; #ifndef VIMAGE vlan_cloner = if_clone_advanced(vlanname, 0, vlan_clone_match, Modified: head/sys/net/if_vlan_var.h ============================================================================== --- head/sys/net/if_vlan_var.h Thu Aug 16 22:13:43 2018 (r337931) +++ head/sys/net/if_vlan_var.h Thu Aug 16 23:46:38 2018 (r337932) @@ -132,6 +132,8 @@ struct vlanreq { ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL) #define VLAN_TAG(_ifp, _vid) \ ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_vid)) : EINVAL) +#define VLAN_PCP(_ifp, _pcp) \ + ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_pcp_p)((_ifp), (_pcp)) : EINVAL) #define VLAN_COOKIE(_ifp) \ ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL) #define VLAN_SETCOOKIE(_ifp, _cookie) \ @@ -144,6 +146,7 @@ extern void (*vlan_trunk_cap_p)(struct ifnet *); extern struct ifnet *(*vlan_trunkdev_p)(struct ifnet *); extern struct ifnet *(*vlan_devat_p)(struct ifnet *, uint16_t); extern int (*vlan_tag_p)(struct ifnet *, uint16_t *); +extern int (*vlan_pcp_p)(struct ifnet *, uint16_t *); extern int (*vlan_setcookie_p)(struct ifnet *, void *); extern void *(*vlan_cookie_p)(struct ifnet *); Modified: head/sys/netinet/toecore.c ============================================================================== --- head/sys/netinet/toecore.c Thu Aug 16 22:13:43 2018 (r337931) +++ head/sys/netinet/toecore.c Thu Aug 16 23:46:38 2018 (r337932) @@ -400,7 +400,7 @@ toe_lle_event(void *arg __unused, struct llentry *lle, struct ifnet *ifp; struct sockaddr *sa; uint8_t *lladdr; - uint16_t vtag; + uint16_t vid, pcp; int family; struct sockaddr_in6 sin6; @@ -425,7 +425,8 @@ toe_lle_event(void *arg __unused, struct llentry *lle, sa = (struct sockaddr *)&sin6; lltable_fill_sa_entry(lle, sa); - vtag = 0xfff; + vid = 0xfff; + pcp = 0; if (evt != LLENTRY_RESOLVED) { /* @@ -440,12 +441,11 @@ toe_lle_event(void *arg __unused, struct llentry *lle, ("%s: %p resolved but not valid?", __func__, lle)); lladdr = (uint8_t *)lle->ll_addr; -#ifdef VLAN_TAG - VLAN_TAG(ifp, &vtag); -#endif + VLAN_TAG(ifp, &vid); + VLAN_PCP(ifp, &pcp); } - tod->tod_l2_update(tod, ifp, sa, lladdr, vtag); + tod->tod_l2_update(tod, ifp, sa, lladdr, EVL_MAKETAG(vid, pcp, 0)); } /* @@ -458,6 +458,7 @@ toe_l2_resolve(struct toedev *tod, struct ifnet *ifp, uint8_t *lladdr, uint16_t *vtag) { int rc; + uint16_t vid, pcp; switch (sa->sa_family) { #ifdef INET @@ -475,10 +476,16 @@ toe_l2_resolve(struct toedev *tod, struct ifnet *ifp, } if (rc == 0) { -#ifdef VLAN_TAG - if (VLAN_TAG(ifp, vtag) != 0) -#endif - *vtag = 0xfff; + vid = 0xfff; + pcp = 0; + if (ifp->if_type == IFT_L2VLAN) { + VLAN_TAG(ifp, &vid); + VLAN_PCP(ifp, &pcp); + } else if (ifp->if_pcp != IFNET_PCP_NONE) { + vid = 0; + pcp = ifp->if_pcp; + } + *vtag = EVL_MAKETAG(vid, pcp, 0); } return (rc);