diff options
author | andre <andre@FreeBSD.org> | 2006-09-17 13:33:30 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2006-09-17 13:33:30 +0000 |
commit | 2d9e7e4a32c8c33011a4a625f3560ff186124090 (patch) | |
tree | 0c60fd4adaa245ddeb4255e5c579b7939f52463f /sys/net/if_vlan_var.h | |
parent | 9f404382211c4f1a6f9dccff7813b9ce26b9fcef (diff) | |
download | FreeBSD-src-2d9e7e4a32c8c33011a4a625f3560ff186124090.zip FreeBSD-src-2d9e7e4a32c8c33011a4a625f3560ff186124090.tar.gz |
Move ethernet VLAN tags from mtags to its own mbuf packet header field
m_pkthdr.ether_vlan. The presence of the M_VLANTAG flag on the mbuf
signifies the presence and validity of its content.
Drivers that support hardware VLAN tag stripping fill in the received
VLAN tag (containing both vlan and priority information) into the
ether_vtag mbuf packet header field:
m->m_pkthdr.ether_vtag = vlan_id; /* ntohs()? */
m->m_flags |= M_VLANTAG;
to mark the packet m with the specified VLAN tag.
On output the driver should check the mbuf for the M_VLANTAG flag to
see if a VLAN tag is present and valid:
if (m->m_flags & M_VLANTAG) {
... = m->m_pkthdr.ether_vtag; /* htons()? */
... pass tag to hardware ...
}
VLAN tags are stored in host byte order. Byte swapping may be necessary.
(Note: This driver conversion was mechanic and did not add or remove any
byte swapping in the drivers.)
Remove zone_mtag_vlan UMA zone and MTAG_VLAN definition. No more tag
memory allocation have to be done.
Reviewed by: thompsa, yar
Sponsored by: TCP/IP Optimization Fundraise 2005
Diffstat (limited to 'sys/net/if_vlan_var.h')
-rw-r--r-- | sys/net/if_vlan_var.h | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index d4a2448..79bc461 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -70,53 +70,30 @@ struct vlanreq { */ /* - * Drivers that support hardware VLAN tagging pass a packet's tag - * up through the stack by appending a packet tag with this value. - * Output is handled likewise, the driver must locate the packet - * tag to extract the VLAN tag. The following macros are used to - * do this work. On input, do: + * VLAN tags are stored in host byte order. Byte swapping may be + * necessary. * - * VLAN_INPUT_TAG(ifp, m, tag,); + * Drivers that support hardware VLAN tag stripping fill in the + * received VLAN tag (containing both vlan and priority information) + * into the ether_vtag mbuf packet header field: + * + * m->m_pkthdr.ether_vtag = vlan_id; // ntohs()? + * m->m_flags |= M_VLANTAG; + * + * to mark the packet m with the specified VLAN tag. * - * to mark the packet m with the specified VLAN tag. The last - * parameter provides code to execute in case of an error. On - * output the driver should check mbuf to see if a VLAN tag is - * present and only then check for a tag; this is done with: + * On output the driver should check the mbuf for the M_VLANTAG + * flag to see if a VLAN tag is present and valid: * - * struct m_tag *mtag; - * mtag = VLAN_OUTPUT_TAG(ifp, m); - * if (mtag != NULL) { - * ... = VLAN_TAG_VALUE(mtag); + * if (m->m_flags & M_VLANTAG) { + * ... = m->m_pkthdr.ether_vtag; // htons()? * ... pass tag to hardware ... * } * * Note that a driver must indicate it supports hardware VLAN - * tagging by marking IFCAP_VLAN_HWTAGGING in if_capabilities. - */ - -/* - * This macro must expand to a lvalue so that it can be used - * to set a tag with a simple assignment. + * stripping/insertion by marking IFCAP_VLAN_HWTAGGING in + * if_capabilities. */ -#define VLAN_TAG_VALUE(_mt) (*(u_int *)((_mt) + 1)) - -#define VLAN_INPUT_TAG(_ifp, _m, _t) do { \ - struct m_tag *mtag = (struct m_tag *) \ - uma_zalloc(zone_mtag_vlan, M_NOWAIT); \ - if (mtag != NULL) { \ - VLAN_TAG_VALUE(mtag) = (_t); \ - m_tag_prepend((_m), mtag); \ - (_m)->m_flags |= M_VLANTAG; \ - } else { \ - (_ifp)->if_ierrors++; \ - m_freem(_m); \ - _m = NULL; \ - } \ -} while (0) - -#define VLAN_OUTPUT_TAG(_ifp, _m) \ - ((_m)->m_flags & M_VLANTAG ? \ - m_tag_locate((_m), MTAG_VLAN, MTAG_VLAN_TAG, NULL) : NULL) #define VLAN_CAPABILITIES(_ifp) do { \ if ((_ifp)->if_vlantrunk != NULL) \ |