diff options
author | sam <sam@FreeBSD.org> | 2002-11-14 23:43:16 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2002-11-14 23:43:16 +0000 |
commit | 5852b81f42f17cad7b33e793f254c3d809f49eac (patch) | |
tree | c0e86a6a9baea6d266a3c48629bcbd42b458e5a0 /sys/net/if_vlan_var.h | |
parent | f868f190bf1238315b629c408ba562297d32c04a (diff) | |
download | FreeBSD-src-5852b81f42f17cad7b33e793f254c3d809f49eac.zip FreeBSD-src-5852b81f42f17cad7b33e793f254c3d809f49eac.tar.gz |
o eliminate separate callback interface for h/w tagged input packets; instead
drivers "tag packets" with an m_tag and the input packet handling recognizes
such packets and does the right thing
o track the number of active vlans on an interface; this lets lots of places
only do vlan-specific processing when needed
o track changes to ether_ifdetach/ether_ifattach
o track bpf changes
o eliminate the use of M_PROTO1 for communicating to drivers about tagged
packets
o eliminate the use of IFF_LINK0 for drivers communicating to the vlan code
that they support h/w tagging; replaced by explicit interface capabilities
o add ifnet capabilities for h/w tagging and support of "large mtu's"
o use new interface capabilities to auto-configure use of large mtu's and h/w
tagging
o add support for proper handling of promiscuous mode
o document driver/vlan communication conventions
Reviewed by: many
Approved by: re
Diffstat (limited to 'sys/net/if_vlan_var.h')
-rw-r--r-- | sys/net/if_vlan_var.h | 79 |
1 files changed, 57 insertions, 22 deletions
diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index c74064a..42f2dcc 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -32,27 +32,6 @@ #ifndef _NET_IF_VLAN_VAR_H_ #define _NET_IF_VLAN_VAR_H_ 1 -#ifdef _KERNEL -struct vlan_mc_entry { - struct ether_addr mc_addr; - SLIST_ENTRY(vlan_mc_entry) mc_entries; -}; - -struct ifvlan { - struct arpcom ifv_ac; /* make this an interface */ - struct ifnet *ifv_p; /* parent inteface of this vlan */ - struct ifv_linkmib { - int ifvm_parent; - u_int16_t ifvm_proto; /* encapsulation ethertype */ - u_int16_t ifvm_tag; /* tag to apply on packets leaving if */ - } ifv_mib; - SLIST_HEAD(__vlan_mchead, vlan_mc_entry) vlan_mc_listhead; - LIST_ENTRY(ifvlan) ifv_list; -}; -#define ifv_if ifv_ac.ac_if -#define ifv_tag ifv_mib.ifvm_tag -#endif /* _KERNEL */ - struct ether_vlan_header { u_char evl_dhost[ETHER_ADDR_LEN]; u_char evl_shost[ETHER_ADDR_LEN]; @@ -63,7 +42,6 @@ struct ether_vlan_header { #define EVL_VLANOFTAG(tag) ((tag) & 4095) #define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7) -#define EVL_ENCAPLEN 4 /* length in octets of encapsulation */ /* sysctl(3) tags, for compatibility purposes */ #define VLANCTL_PROTO 1 @@ -79,4 +57,61 @@ struct vlanreq { #define SIOCSETVLAN SIOCSIFGENERIC #define SIOCGETVLAN SIOCGIFGENERIC +#ifdef _KERNEL +/* + * Drivers that are capable of adding and removing the VLAN header + * in hardware indicate they support this by marking IFCAP_VLAN_HWTAGGING + * in if_capabilities. Drivers for hardware that is also capable + * of handling larger MTU's that may include a software-appended + * VLAN header w/o lowering the normal MTU should mark IFCAP_VLA_MTU + * in if_capabilities; this notfies the VLAN code it can leave the + * MTU on the vlan interface at the normal setting. + */ + +/* + * 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_INPUT_TAG(ifp, m, 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 ifnet to see if any VLANs are + * in use and only then check for a packet tag; this is done with: + * + * struct m_tag *mtag; + * mtag = VLAN_OUTPUT_TAG(ifp, m); + * if (mtag != NULL) { + * ... = VLAN_TAG_VALUE(mtag); + * ... pass tag to hardware ... + * } + * + * Note that a driver must indicate it supports hardware VLAN + * tagging by marking IFCAP_VLAN_HWTAGGING in if_capabilities. + */ +#define MTAG_VLAN 1035328035 +#define MTAG_VLAN_TAG 0 /* tag of VLAN interface */ + +#define VLAN_INPUT_TAG(_ifp, _m, _t, _errcase) do { \ + struct m_tag *mtag; \ + mtag = m_tag_alloc(MTAG_VLAN, MTAG_VLAN_TAG, \ + sizeof (u_int), M_DONTWAIT); \ + if (mtag == NULL) { \ + (_ifp)->if_ierrors++; \ + m_freem(_m); \ + _errcase; \ + } \ + *(u_int *)(mtag+1) = (_t); \ + m_tag_prepend((_m), mtag); \ +} while (0) + +#define VLAN_OUTPUT_TAG(_ifp, _m) \ + ((_ifp)->if_nvlans != 0 ? \ + m_tag_locate((_m), MTAG_VLAN, MTAG_VLAN_TAG, NULL) : NULL) +#define VLAN_TAG_VALUE(_mt) (*(u_int *)((_mt)+1)) +#endif /* _KERNEL */ + #endif /* _NET_IF_VLAN_VAR_H_ */ |