Skip to content

Commit

Permalink
net: eth: Add helper to return VLAN info for an interface
Browse files Browse the repository at this point in the history
A small helper function will return information whether
a given network interface has VLAN enabled or not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Jul 3, 2018
1 parent 3fd2d53 commit 65b15c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/net/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@ struct net_if *net_eth_get_vlan_iface(struct net_if *iface, u16_t tag);
bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
struct net_if *iface);

/**
* @brief Get VLAN status for a given network interface (enabled or not).
*
* @param iface Network interface
*
* @return True if VLAN is enabled for this network interface, false if not.
*/
bool net_eth_get_vlan_status(struct net_if *iface);

#define ETH_NET_DEVICE_INIT(dev_name, drv_name, init_fn, \
data, cfg_info, prio, api, mtu) \
DEVICE_AND_API_INIT(dev_name, drv_name, init_fn, data, \
Expand Down Expand Up @@ -404,6 +413,11 @@ struct net_if *net_eth_get_vlan_iface(struct net_if *iface, u16_t tag)
{
return NULL;
}

static inline bool net_eth_get_vlan_status(struct net_if *iface)
{
return false;
}
#endif /* CONFIG_NET_VLAN */

/**
Expand Down
12 changes: 12 additions & 0 deletions subsys/net/l2/ethernet/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,18 @@ u16_t net_eth_get_vlan_tag(struct net_if *iface)
return NET_VLAN_TAG_UNSPEC;
}

bool net_eth_get_vlan_status(struct net_if *iface)
{
struct ethernet_context *ctx = net_if_l2_data(iface);

if (ctx->vlan_enabled &&
net_eth_get_vlan_tag(iface) != NET_VLAN_TAG_UNSPEC) {
return true;
}

return false;
}

static struct ethernet_vlan *get_vlan(struct ethernet_context *ctx,
struct net_if *iface,
u16_t vlan_tag)
Expand Down

0 comments on commit 65b15c3

Please sign in to comment.