Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEEE 802.1Q VLAN Support (IDFGH-7213) #8807

Closed
franz-ms-muc opened this issue Apr 21, 2022 · 1 comment
Closed

IEEE 802.1Q VLAN Support (IDFGH-7213) #8807

franz-ms-muc opened this issue Apr 21, 2022 · 1 comment
Labels
Awaiting Response awaiting a response from the author Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Feature Request Feature request for IDF

Comments

@franz-ms-muc
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I'm always frustrated when Customers want to use IEEE 802.1Q VLAN Supported Networks (most Wifi, but sometimes Ethernet) with VLAN Support, and i have to use others than ESP32 Family Microcontrollers. Because we love ESP32, we would like to use them here as well.

Describe the solution you'd like

A clear and concise description of what you want to happen.
IEEE 802.1Q VLAN Support to be added to ESP-IDF.
https://de.wikipedia.org/wiki/IEEE_802.1Q

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.
https://zephyrproject.org/ has VLAN Support on ESP32. but i never tested this on ESP32, and i am unsure about the maturity it has, especially on the newest Chip: ESP32-S3

@franz-ms-muc franz-ms-muc added the Type: Feature Request Feature request for IDF label Apr 21, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 21, 2022
@github-actions github-actions bot changed the title IEEE 802.1Q VLAN Support IEEE 802.1Q VLAN Support (IDFGH-7213) Apr 21, 2022
@david-cermak
Copy link
Collaborator

Hi @franz-ms-muc

lwIP supports basic VLAN functionality, as described here:

https://github.com/espressif/esp-lwip/blob/fb1f3552349bfa53d2977409f204d385ed0aa217/src/include/lwip/opt.h#L670-L675

It just checks the VLAN header ( 0x8100 /* 802.1Q VLAN tag */) and if enabled the packet could be processed or dropped based on user definition.

The easiest option is to

  • enable VLAN: ETHARP_SUPPORT_VLAN=1
  • define our VLAN header: ETHARP_VLAN_CHECK=*our_id*

It's also possible to define a function that receives the vlan header and decides what we want to do with the packet.
Here's the example:

Project Makefile:

idf_component_get_property(lwip lwip COMPONENT_LIB)
target_compile_options(${lwip} PRIVATE "-I${PROJECT_DIR}/main")
target_compile_definitions(${lwip} PRIVATE "-DETHARP_SUPPORT_VLAN=1" "-DLWIP_HOOK_VLAN_CHECK=vlan_hook" "-DESP_IDF_LWIP_HOOK_FILENAME=\"vlan_hook.h\"")

Hook header

#pragma once

struct netif;
struct eth_hdr;
struct eth_vlan_hdr;

int vlan_hook(struct netif *netif, struct eth_hdr *eth_hdr, struct eth_vlan_hdr *vlan_hdr);

Definition

#include "lwip/netif.h"
#include "lwip/etharp.h"

int vlan_hook(struct netif *netif, struct eth_hdr *eth_hdr, struct eth_vlan_hdr *vlan_hdr)
{
    // Processing (return 1 if for us)
    return 0;
}

@espressif-bot espressif-bot added the Awaiting Response awaiting a response from the author label May 6, 2022
@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally and removed Status: Opened Issue is new labels Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Response awaiting a response from the author Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

3 participants