Implement task #11620: Add outgoing VLAN PCP support for Ethernet level QoS

Apply rebased patch from Timmy Brolin
This commit is contained in:
Dirk Ziegelmeier 2018-10-19 22:30:17 +02:00
parent 64bc2c3df7
commit 95aba99f41
5 changed files with 66 additions and 34 deletions

View File

@ -892,6 +892,9 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
lpcb->netif_idx = NETIF_NO_INDEX; lpcb->netif_idx = NETIF_NO_INDEX;
lpcb->ttl = pcb->ttl; lpcb->ttl = pcb->ttl;
lpcb->tos = pcb->tos; lpcb->tos = pcb->tos;
#if LWIP_VLAN_PCP
lpcb->netif_hints.tci = pcb->netif_hints.tci;
#endif /* LWIP_VLAN_PCP */
#if LWIP_IPV4 && LWIP_IPV6 #if LWIP_IPV4 && LWIP_IPV6
IP_SET_TYPE_VAL(lpcb->remote_ip, pcb->local_ip.type); IP_SET_TYPE_VAL(lpcb->remote_ip, pcb->local_ip.type);
#endif /* LWIP_IPV4 && LWIP_IPV6 */ #endif /* LWIP_IPV4 && LWIP_IPV6 */

View File

@ -690,6 +690,9 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
#if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG #if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG
npcb->listener = pcb; npcb->listener = pcb;
#endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */ #endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */
#if LWIP_VLAN_PCP
npcb->netif_hints.tci = pcb->netif_hints.tci;
#endif /* LWIP_VLAN_PCP */
/* inherit socket options */ /* inherit socket options */
npcb->so_options = pcb->so_options & SOF_INHERITED; npcb->so_options = pcb->so_options & SOF_INHERITED;
npcb->netif_idx = pcb->netif_idx; npcb->netif_idx = pcb->netif_idx;

View File

@ -248,14 +248,20 @@ typedef u8_t netif_addr_idx_t;
#define NETIF_ADDR_IDX_MAX 0x7F #define NETIF_ADDR_IDX_MAX 0x7F
#endif #endif
#if LWIP_NETIF_HWADDRHINT #if LWIP_NETIF_HWADDRHINT || LWIP_VLAN_PCP
#define LWIP_NETIF_USE_HINTS 1 #define LWIP_NETIF_USE_HINTS 1
struct netif_hint { struct netif_hint {
netif_addr_idx_t addr_hint; #if LWIP_NETIF_HWADDRHINT
u8_t addr_hint;
#endif
#if LWIP_VLAN_PCP
/** VLAN hader is set if this is >= 0 (but must be <= 0xFFFF) */
s32_t tci;
#endif
}; };
#else /* LWIP_NETIF_HWADDRHINT */ #else /* LWIP_NETIF_HWADDRHINT || LWIP_VLAN_PCP */
#define LWIP_NETIF_USE_HINTS 0 #define LWIP_NETIF_USE_HINTS 0
#endif /* LWIP_NETIF_HWADDRHINT */ #endif /* LWIP_NETIF_HWADDRHINT || LWIP_VLAN_PCP*/
/** Generic data structure used for all lwIP network interfaces. /** Generic data structure used for all lwIP network interfaces.
* The following fields should be filled in by the initialization * The following fields should be filled in by the initialization

View File

@ -677,6 +677,18 @@
#define ETHARP_SUPPORT_VLAN 0 #define ETHARP_SUPPORT_VLAN 0
#endif #endif
/**
* LWIP_VLAN_PCP==1: Enable outgoing VLAN taggning of frames on a per-PCB basis
* for QoS purposes. With this feature enabled, each PCB has a new variable: "tci".
* (Tag Control Identifier). The TCI contains three fields: VID, CFI and PCP.
* VID is the VLAN ID, which should be set to zero.
* The "CFI" bit is used to enable or disable VLAN tags for the PCB.
* PCP (Priority Code Point) is a 3 bit field used for Ethernet level QoS.
*/
#ifndef LWIP_VLAN_PCP
#define LWIP_VLAN_PCP 0
#endif
/** LWIP_ETHERNET==1: enable ethernet support even though ARP might be disabled /** LWIP_ETHERNET==1: enable ethernet support even though ARP might be disabled
*/ */
#if !defined LWIP_ETHERNET || defined __DOXYGEN__ #if !defined LWIP_ETHERNET || defined __DOXYGEN__
@ -1549,11 +1561,11 @@
* Ethernet. * Ethernet.
*/ */
#if !defined PBUF_LINK_HLEN || defined __DOXYGEN__ #if !defined PBUF_LINK_HLEN || defined __DOXYGEN__
#if defined LWIP_HOOK_VLAN_SET && !defined __DOXYGEN__ #if (defined LWIP_HOOK_VLAN_SET || LWIP_VLAN_PCP) && !defined __DOXYGEN__
#define PBUF_LINK_HLEN (18 + ETH_PAD_SIZE) #define PBUF_LINK_HLEN (18 + ETH_PAD_SIZE)
#else /* LWIP_HOOK_VLAN_SET */ #else /* LWIP_HOOK_VLAN_SET || LWIP_VLAN_PCP */
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) #define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#endif /* LWIP_HOOK_VLAN_SET */ #endif /* LWIP_HOOK_VLAN_SET || LWIP_VLAN_PCP */
#endif #endif
/** /**

View File

@ -273,8 +273,16 @@ ethernet_output(struct netif * netif, struct pbuf * p,
struct eth_hdr *ethhdr; struct eth_hdr *ethhdr;
u16_t eth_type_be = lwip_htons(eth_type); u16_t eth_type_be = lwip_htons(eth_type);
#if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) #if ETHARP_SUPPORT_VLAN
s32_t vlan_prio_vid = LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type); s32_t vlan_prio_vid;
#ifdef LWIP_HOOK_VLAN_SET
vlan_prio_vid = LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type);
#elif LWIP_VLAN_PCP
vlan_prio_vid = -1;
if (netif->hints && (netif->hints->tci >= 0)) {
vlan_prio_vid = (u16_t)netif->hints->tci;
}
#endif
if (vlan_prio_vid >= 0) { if (vlan_prio_vid >= 0) {
struct eth_vlan_hdr *vlanhdr; struct eth_vlan_hdr *vlanhdr;