svn commit: r337986 - head/sys/dev/cxgbe/tom

Navdeep Parhar np at FreeBSD.org
Fri Aug 17 19:22:48 UTC 2018


Author: np
Date: Fri Aug 17 19:22:46 2018
New Revision: 337986
URL: https://svnweb.freebsd.org/changeset/base/337986

Log:
  cxgbe/tom: Put the ifnet or VLAN's PCP value in the 802.1Q tag of frames
  generated by the TOE.  Works with vid 0 (no VLAN, just priority) too.
  
  MFC after:	1 week
  Sponsored by:	Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_connect.c
  head/sys/dev/cxgbe/tom/t4_listen.c
  head/sys/dev/cxgbe/tom/t4_tom.c
  head/sys/dev/cxgbe/tom/t4_tom_l2t.c

Modified: head/sys/dev/cxgbe/tom/t4_connect.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_connect.c	Fri Aug 17 19:18:59 2018	(r337985)
+++ head/sys/dev/cxgbe/tom/t4_connect.c	Fri Aug 17 19:22:46 2018	(r337986)
@@ -326,7 +326,7 @@ t4_connect(struct toedev *tod, struct socket *so, stru
 	struct tcpcb *tp = intotcpcb(inp);
 	int reason;
 	struct offload_settings settings;
-	uint16_t vid = 0xffff;
+	uint16_t vid = 0xfff, pcp = 0;
 
 	INP_WLOCK_ASSERT(inp);
 	KASSERT(nam->sa_family == AF_INET || nam->sa_family == AF_INET6,
@@ -339,13 +339,15 @@ t4_connect(struct toedev *tod, struct socket *so, stru
 
 		vi = ifp->if_softc;
 		VLAN_TAG(rt_ifp, &vid);
+		VLAN_PCP(rt_ifp, &pcp);
 	} else if (rt_ifp->if_type == IFT_IEEE8023ADLAG)
 		DONT_OFFLOAD_ACTIVE_OPEN(ENOSYS); /* XXX: implement lagg+TOE */
 	else
 		DONT_OFFLOAD_ACTIVE_OPEN(ENOTSUP);
 
 	rw_rlock(&sc->policy_lock);
-	settings = *lookup_offload_policy(sc, OPEN_TYPE_ACTIVE, NULL, vid, inp);
+	settings = *lookup_offload_policy(sc, OPEN_TYPE_ACTIVE, NULL,
+	    EVL_MAKETAG(vid, pcp, 0), inp);
 	rw_runlock(&sc->policy_lock);
 	if (!settings.offload)
 		DONT_OFFLOAD_ACTIVE_OPEN(EPERM);

Modified: head/sys/dev/cxgbe/tom/t4_listen.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_listen.c	Fri Aug 17 19:18:59 2018	(r337985)
+++ head/sys/dev/cxgbe/tom/t4_listen.c	Fri Aug 17 19:22:46 2018	(r337986)
@@ -521,8 +521,8 @@ t4_listen_start(struct toedev *tod, struct tcpcb *tp)
 	INP_WLOCK_ASSERT(inp);
 
 	rw_rlock(&sc->policy_lock);
-	settings = *lookup_offload_policy(sc, OPEN_TYPE_LISTEN, NULL, 0xffff,
-	    inp);
+	settings = *lookup_offload_policy(sc, OPEN_TYPE_LISTEN, NULL,
+	    EVL_MAKETAG(0xfff, 0, 0), inp);
 	rw_runlock(&sc->policy_lock);
 	if (!settings.offload)
 		return (0);
@@ -1305,7 +1305,7 @@ found:
 	 * XXX: lagg support, lagg + vlan support.
 	 */
 	vid = EVL_VLANOFTAG(be16toh(cpl->vlan));
-	if (vid != 0xfff) {
+	if (vid != 0xfff && vid != 0) {
 		ifp = VLAN_DEVAT(hw_ifp, vid);
 		if (ifp == NULL)
 			REJECT_PASS_ACCEPT();
@@ -1396,7 +1396,8 @@ found:
 	}
 	so = inp->inp_socket;
 	rw_rlock(&sc->policy_lock);
-	settings = *lookup_offload_policy(sc, OPEN_TYPE_PASSIVE, m, 0xffff, inp);
+	settings = *lookup_offload_policy(sc, OPEN_TYPE_PASSIVE, m,
+	    EVL_MAKETAG(0xfff, 0, 0), inp);
 	rw_runlock(&sc->policy_lock);
 	if (!settings.offload) {
 		INP_WUNLOCK(inp);

Modified: head/sys/dev/cxgbe/tom/t4_tom.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.c	Fri Aug 17 19:18:59 2018	(r337985)
+++ head/sys/dev/cxgbe/tom/t4_tom.c	Fri Aug 17 19:22:46 2018	(r337986)
@@ -649,7 +649,7 @@ select_ntuple(struct vi_info *vi, struct l2t_entry *e)
 	 * Initialize each of the fields which we care about which are present
 	 * in the Compressed Filter Tuple.
 	 */
-	if (tp->vlan_shift >= 0 && e->vlan != CPL_L2T_VLAN_NONE)
+	if (tp->vlan_shift >= 0 && EVL_VLANOFTAG(e->vlan) != CPL_L2T_VLAN_NONE)
 		ntuple |= (uint64_t)(F_FT_VLAN_VLD | e->vlan) << tp->vlan_shift;
 
 	if (tp->port_shift >= 0)
@@ -1130,7 +1130,7 @@ prepare_pkt(int open_type, uint16_t vtag, struct inpcb
 	ipv6 = inp->inp_vflag & INP_IPV6;
 	len = 0;
 
-	if (vtag == 0xffff) {
+	if (EVL_VLANOFTAG(vtag) == 0xfff) {
 		struct ether_header *eh = (void *)pkt;
 
 		if (ipv6)

Modified: head/sys/dev/cxgbe/tom/t4_tom_l2t.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom_l2t.c	Fri Aug 17 19:18:59 2018	(r337985)
+++ head/sys/dev/cxgbe/tom/t4_tom_l2t.c	Fri Aug 17 19:22:46 2018	(r337986)
@@ -236,7 +236,7 @@ resolve_entry(struct adapter *sc, struct l2t_entry *e)
 	struct sockaddr_in6 sin6 = {0};
 	struct sockaddr *sa;
 	uint8_t dmac[ETHER_HDR_LEN];
-	uint16_t vtag = VLAN_NONE;
+	uint16_t vtag;
 	int rc;
 
 	if (e->ipv6 == 0) {
@@ -251,6 +251,7 @@ resolve_entry(struct adapter *sc, struct l2t_entry *e)
 		sa = (void *)&sin6;
 	}
 
+	vtag = EVL_MAKETAG(VLAN_NONE, 0, 0);
 	rc = toe_l2_resolve(tod, e->ifp, sa, dmac, &vtag);
 	if (rc == EWOULDBLOCK)
 		return (rc);
@@ -355,20 +356,27 @@ t4_l2t_get(struct port_info *pi, struct ifnet *ifp, st
 	struct adapter *sc = pi->adapter;
 	struct l2t_data *d = sc->l2t;
 	u_int hash, smt_idx = pi->port_id;
+	uint16_t vid, pcp, vtag;
 
 	KASSERT(sa->sa_family == AF_INET || sa->sa_family == AF_INET6,
 	    ("%s: sa %p has unexpected sa_family %d", __func__, sa,
 	    sa->sa_family));
 
-#ifndef VLAN_TAG
-	if (ifp->if_type == IFT_L2VLAN)
-		return (NULL);
-#endif
+	vid = VLAN_NONE;
+	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);
 
 	hash = l2_hash(d, sa, ifp->if_index);
 	rw_wlock(&d->lock);
 	for (e = d->l2tab[hash].first; e; e = e->next) {
-		if (l2_cmp(sa, e) == 0 && e->ifp == ifp &&
+		if (l2_cmp(sa, e) == 0 && e->ifp == ifp && e->vlan == vtag &&
 		    e->smt_idx == smt_idx) {
 			l2t_hold(d, e);
 			goto done;
@@ -391,12 +399,7 @@ t4_l2t_get(struct port_info *pi, struct ifnet *ifp, st
 		e->wrq = &sc->sge.ctrlq[pi->port_id];
 		e->iqid = sc->sge.ofld_rxq[pi->vi[0].first_ofld_rxq].iq.abs_id;
 		atomic_store_rel_int(&e->refcnt, 1);
-#ifdef VLAN_TAG
-		if (ifp->if_type == IFT_L2VLAN)
-			VLAN_TAG(ifp, &e->vlan);
-		else
-			e->vlan = VLAN_NONE;
-#endif
+		e->vlan = vtag;
 		mtx_unlock(&e->lock);
 	}
 done:


More information about the svn-src-head mailing list