summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-04-19 06:40:01 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-04-19 06:40:01 +0000
commit4a139c89513bc7fb60152589c64b28b0d15bfb7d (patch)
treee9f1d79705c16af39a6c7b98c0a7011d751dc63f /sys
parent9873abfd553e8078fda39a0864114cc39ad22074 (diff)
add rxprio support
this is modelled on vlan(4) where the packet prio is put in the bpe header in tx, and the bpe header prio is put on the packet in rx.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_bpe.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/net/if_bpe.c b/sys/net/if_bpe.c
index 1cc6516f162..7b34a02dd13 100644
--- a/sys/net/if_bpe.c
+++ b/sys/net/if_bpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bpe.c,v 1.2 2019/01/16 00:26:45 jsg Exp $ */
+/* $OpenBSD: if_bpe.c,v 1.3 2019/04/19 06:40:00 dlg Exp $ */
/*
* Copyright (c) 2018 David Gwynne <dlg@openbsd.org>
*
@@ -99,6 +99,7 @@ struct bpe_softc {
struct arpcom sc_ac;
struct ifmedia sc_media;
int sc_txhprio;
+ int sc_rxhprio;
uint8_t sc_group[ETHER_ADDR_LEN];
void * sc_lh_cookie;
@@ -175,6 +176,7 @@ bpe_clone_create(struct if_clone *ifc, int unit)
bpe_set_group(sc, 0);
sc->sc_txhprio = IF_HDRPRIO_PACKET;
+ sc->sc_txhprio = IF_HDRPRIO_OUTER;
rw_init(&sc->sc_bridge_lock, "bpebr");
RBT_INIT(bpe_map, &sc->sc_bridge_map);
@@ -494,6 +496,22 @@ bpe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
ifr->ifr_hdrprio = sc->sc_txhprio;
break;
+ case SIOCSRXHPRIO:
+ if (ifr->ifr_hdrprio == IF_HDRPRIO_OUTER ||
+ ifr->ifr_hdrprio == IF_HDRPRIO_PACKET) /* use mbuf prio */
+ ;
+ else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
+ ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
+ error = EINVAL;
+ break;
+ }
+
+ sc->sc_rxhprio = ifr->ifr_hdrprio;
+ break;
+ case SIOCGRXHPRIO:
+ ifr->ifr_hdrprio = sc->sc_rxhprio;
+ break;
+
case SIOCGIFMEDIA:
error = bpe_media_get(sc, ifr);
break;
@@ -890,6 +908,7 @@ bpe_input(struct ifnet *ifp0, struct mbuf *m)
unsigned int hlen = sizeof(*beh) + sizeof(*itagp) + sizeof(*ceh);
struct mbuf *n;
int off;
+ int prio;
if (m->m_len < hlen) {
m = m_pullup(m, hlen);
@@ -938,6 +957,19 @@ bpe_input(struct ifnet *ifp0, struct mbuf *m)
ifp = &sc->sc_ac.ac_if;
+ prio = sc->sc_rxhprio;
+ switch (prio) {
+ case IF_HDRPRIO_PACKET:
+ break;
+ case IF_HDRPRIO_OUTER:
+ m->m_pkthdr.pf.prio = (itag & PBB_ITAG_PCP_MASK) >>
+ PBB_ITAG_PCP_SHIFT;
+ break;
+ default:
+ m->m_pkthdr.pf.prio = prio;
+ break;
+ }
+
m->m_flags &= ~(M_BCAST|M_MCAST);
m->m_pkthdr.ph_ifidx = ifp->if_index;
m->m_pkthdr.ph_rtableid = ifp->if_rdomain;