net: eth: Add start and stop L2 functions

If the driver has created start() and stop() functions, then those
are called when ethernet L2 is enabled or disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2018-08-09 16:08:27 +03:00
parent 45a1c1fb67
commit 31f89b0303
2 changed files with 17 additions and 0 deletions

View File

@ -185,6 +185,12 @@ struct ethernet_api {
struct net_stats_eth *(*get_stats)(struct device *dev);
#endif
/** Start the device */
int (*start)(struct device *dev);
/** Stop the device */
int (*stop)(struct device *dev);
/** Get the device capabilities */
enum ethernet_hw_caps (*get_capabilities)(struct device *dev);

View File

@ -576,8 +576,19 @@ static inline u16_t ethernet_reserve(struct net_if *iface, void *unused)
static inline int ethernet_enable(struct net_if *iface, bool state)
{
const struct ethernet_api *eth =
net_if_get_device(iface)->driver_api;
if (!state) {
net_arp_clear_cache(iface);
if (eth->stop) {
eth->stop(net_if_get_device(iface));
}
} else {
if (eth->start) {
eth->start(net_if_get_device(iface));
}
}
return 0;