Skip to content

Commit

Permalink
net: mgmt: Add VLAN enabled / disabled event support
Browse files Browse the repository at this point in the history
Send network management event if VLAN tag is enabled or disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Jul 3, 2018
1 parent 3ed763a commit 3fd2d53
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/net/ethernet_mgmt.h
Expand Up @@ -80,6 +80,8 @@ struct ethernet_req_params {
enum net_event_ethernet_cmd {
NET_EVENT_ETHERNET_CMD_CARRIER_ON = 1,
NET_EVENT_ETHERNET_CMD_CARRIER_OFF,
NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED,
NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED,
};

#define NET_EVENT_ETHERNET_CARRIER_ON \
Expand All @@ -88,12 +90,20 @@ enum net_event_ethernet_cmd {
#define NET_EVENT_ETHERNET_CARRIER_OFF \
(_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_CARRIER_OFF)

#define NET_EVENT_ETHERNET_VLAN_TAG_ENABLED \
(_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED)

#define NET_EVENT_ETHERNET_VLAN_TAG_DISABLED \
(_NET_ETHERNET_EVENT | NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED)

struct net_if;

#if defined(CONFIG_NET_L2_ETHERNET_MGMT)
void ethernet_mgmt_raise_carrier_on_event(struct net_if *iface);

void ethernet_mgmt_raise_carrier_off_event(struct net_if *iface);
void ethernet_mgmt_raise_vlan_enabled_event(struct net_if *iface, u16_t tag);
void ethernet_mgmt_raise_vlan_disabled_event(struct net_if *iface, u16_t tag);
#else
static inline void ethernet_mgmt_raise_carrier_on_event(struct net_if *iface)
{
Expand All @@ -104,6 +114,20 @@ static inline void ethernet_mgmt_raise_carrier_off_event(struct net_if *iface)
{
ARG_UNUSED(iface);
}

static inline void ethernet_mgmt_raise_vlan_enabled_event(struct net_if *iface,
u16_t tag)
{
ARG_UNUSED(iface);
ARG_UNUSED(tag);
}

static inline void ethernet_mgmt_raise_vlan_disabled_event(struct net_if *iface,
u16_t tag)
{
ARG_UNUSED(iface);
ARG_UNUSED(tag);
}
#endif
/**
* @}
Expand Down
4 changes: 4 additions & 0 deletions subsys/net/l2/ethernet/ethernet.c
Expand Up @@ -717,6 +717,8 @@ int net_eth_vlan_enable(struct net_if *iface, u16_t tag)
ctx->vlan_enabled = NET_VLAN_MAX_COUNT;
}

ethernet_mgmt_raise_vlan_enabled_event(iface, tag);

return 0;
}

Expand Down Expand Up @@ -753,6 +755,8 @@ int net_eth_vlan_disable(struct net_if *iface, u16_t tag)
eth->vlan_setup(net_if_get_device(iface), iface, tag, false);
}

ethernet_mgmt_raise_vlan_disabled_event(iface, tag);

ctx->vlan_enabled--;
if (ctx->vlan_enabled < 0) {
ctx->vlan_enabled = 0;
Expand Down
21 changes: 21 additions & 0 deletions subsys/net/l2/ethernet/ethernet_mgmt.c
Expand Up @@ -121,3 +121,24 @@ void ethernet_mgmt_raise_carrier_off_event(struct net_if *iface)
{
net_mgmt_event_notify(NET_EVENT_ETHERNET_CARRIER_OFF, iface);
}

void ethernet_mgmt_raise_vlan_enabled_event(struct net_if *iface, u16_t tag)
{
#if defined(CONFIG_NET_MGMT_EVENT_INFO)
net_mgmt_event_notify_with_info(NET_EVENT_ETHERNET_VLAN_TAG_ENABLED,
iface, &tag, sizeof(tag));
#else
net_mgmt_event_notify(NET_EVENT_ETHERNET_VLAN_TAG_ENABLED,
iface);
#endif
}

void ethernet_mgmt_raise_vlan_disabled_event(struct net_if *iface, u16_t tag)
{
#if defined(CONFIG_NET_MGMT_EVENT_INFO)
net_mgmt_event_notify_with_info(NET_EVENT_ETHERNET_VLAN_TAG_DISABLED,
iface, &tag, sizeof(tag));
#else
net_mgmt_event_notify(NET_EVENT_ETHERNET_VLAN_TAG_DISABLED, iface);
#endif
}

0 comments on commit 3fd2d53

Please sign in to comment.