net/ethernet: Add capabilities exposed by device drivers
Curently only link speed is exposed. Opportunity taken to remove any post-fix enumerating the iface init and/or the api: these must be generic and used by all the instances. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
15ccd9cc0d
commit
e996b37c0a
9 changed files with 79 additions and 46 deletions
|
@ -329,6 +329,20 @@ static void eth_initialize(struct net_if *iface)
|
|||
}
|
||||
}
|
||||
|
||||
static enum eth_hw_caps eth_dw_get_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETH_LINK_10BASE_T | ETH_LINK_100BASE_T;
|
||||
}
|
||||
|
||||
static const struct ethernet_api api_funcs = {
|
||||
.iface_api.init = eth_initialize,
|
||||
.iface_api.send = eth_tx,
|
||||
|
||||
.get_capabilities = eth_dw_get_capabilities,
|
||||
};
|
||||
|
||||
/* Bindings to the plaform */
|
||||
#if CONFIG_ETH_DW_0
|
||||
static void eth_config_0_irq(struct device *port)
|
||||
|
@ -373,11 +387,6 @@ static struct eth_runtime eth_0_runtime = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static const struct ethernet_api api_funcs = {
|
||||
.iface_api.init = eth_initialize,
|
||||
.iface_api.send = eth_tx,
|
||||
};
|
||||
|
||||
NET_DEVICE_INIT(eth_dw_0, CONFIG_ETH_DW_0_NAME,
|
||||
eth_setup, ð_0_runtime,
|
||||
ð_config_0, CONFIG_ETH_INIT_PRIORITY, &api_funcs,
|
||||
|
|
|
@ -764,6 +764,13 @@ static int eth_net_tx(struct net_if *iface, struct net_pkt *pkt)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static enum eth_hw_caps eth_enc28j60_get_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETH_LINK_10BASE_T;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ETH_ENC28J60_0
|
||||
|
||||
static u8_t mac_address_0[6] = { MICROCHIP_OUI_B0,
|
||||
|
@ -773,7 +780,7 @@ static u8_t mac_address_0[6] = { MICROCHIP_OUI_B0,
|
|||
CONFIG_ETH_ENC28J60_0_MAC4,
|
||||
CONFIG_ETH_ENC28J60_0_MAC5 };
|
||||
|
||||
static void eth_enc28j60_iface_init_0(struct net_if *iface)
|
||||
static void eth_enc28j60_iface_init(struct net_if *iface)
|
||||
{
|
||||
struct device *dev = net_if_get_device(iface);
|
||||
struct eth_enc28j60_runtime *context = dev->driver_data;
|
||||
|
@ -785,9 +792,11 @@ static void eth_enc28j60_iface_init_0(struct net_if *iface)
|
|||
context->iface = iface;
|
||||
}
|
||||
|
||||
static const struct ethernet_api api_funcs_0 = {
|
||||
.iface_api.init = eth_enc28j60_iface_init_0,
|
||||
static const struct ethernet_api api_funcs = {
|
||||
.iface_api.init = eth_enc28j60_iface_init,
|
||||
.iface_api.send = eth_net_tx,
|
||||
|
||||
.get_capabilities = eth_enc28j60_get_capabilities,
|
||||
};
|
||||
|
||||
static struct eth_enc28j60_runtime eth_enc28j60_0_runtime;
|
||||
|
@ -808,7 +817,7 @@ static const struct eth_enc28j60_config eth_enc28j60_0_config = {
|
|||
|
||||
NET_DEVICE_INIT(enc28j60_0, CONFIG_ETH_ENC28J60_0_NAME,
|
||||
eth_enc28j60_init, ð_enc28j60_0_runtime,
|
||||
ð_enc28j60_0_config, CONFIG_ETH_INIT_PRIORITY, &api_funcs_0,
|
||||
ð_enc28j60_0_config, CONFIG_ETH_INIT_PRIORITY, &api_funcs,
|
||||
ETHERNET_L2, NET_L2_GET_CTX_TYPE(ETHERNET_L2), 1500);
|
||||
|
||||
#endif /* CONFIG_ETH_ENC28J60_0 */
|
||||
|
|
|
@ -643,7 +643,7 @@ static void net_if_mcast_cb(struct net_if *iface,
|
|||
}
|
||||
#endif /* CONFIG_NET_IPV6 */
|
||||
|
||||
static void eth_0_iface_init(struct net_if *iface)
|
||||
static void eth_iface_init(struct net_if *iface)
|
||||
{
|
||||
struct device *dev = net_if_get_device(iface);
|
||||
struct eth_context *context = dev->driver_data;
|
||||
|
@ -664,22 +664,18 @@ static void eth_0_iface_init(struct net_if *iface)
|
|||
ethernet_init(iface);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
static enum eth_hw_caps eth_capabilities(struct device *dev)
|
||||
static enum eth_hw_caps eth_mcux_get_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETH_HW_VLAN;
|
||||
return ETH_HW_VLAN | ETH_LINK_10BASE_T | ETH_LINK_100BASE_T;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct ethernet_api api_funcs_0 = {
|
||||
.iface_api.init = eth_0_iface_init,
|
||||
static const struct ethernet_api api_funcs = {
|
||||
.iface_api.init = eth_iface_init,
|
||||
.iface_api.send = eth_tx,
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
.get_capabilities = eth_capabilities,
|
||||
#endif
|
||||
.get_capabilities = eth_mcux_get_capabilities,
|
||||
};
|
||||
|
||||
static void eth_mcux_rx_isr(void *p)
|
||||
|
@ -728,7 +724,7 @@ static struct eth_context eth_0_context = {
|
|||
|
||||
ETH_NET_DEVICE_INIT(eth_mcux_0, CONFIG_ETH_MCUX_0_NAME, eth_0_init,
|
||||
ð_0_context, NULL, CONFIG_ETH_INIT_PRIORITY,
|
||||
&api_funcs_0, 1500);
|
||||
&api_funcs, 1500);
|
||||
|
||||
static void eth_0_config_func(void)
|
||||
{
|
||||
|
|
|
@ -269,22 +269,18 @@ static void eth_iface_init(struct net_if *iface)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
static enum eth_hw_caps eth_capabilities(struct device *dev)
|
||||
static enum eth_hw_caps eth_posix_native_get_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETH_HW_VLAN;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct ethernet_api eth_if_api = {
|
||||
.iface_api.init = eth_iface_init,
|
||||
.iface_api.send = eth_send,
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
.get_capabilities = eth_capabilities,
|
||||
#endif
|
||||
.get_capabilities = eth_posix_native_get_capabilities,
|
||||
};
|
||||
|
||||
ETH_NET_DEVICE_INIT(eth_native_posix, CONFIG_ETH_NATIVE_POSIX_DRV_NAME,
|
||||
|
|
|
@ -899,22 +899,18 @@ static void eth0_iface_init(struct net_if *iface)
|
|||
init_done = true;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
static enum eth_hw_caps eth_capabilities(struct device *dev)
|
||||
static enum eth_hw_caps eth_sam_gmac_get_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETH_HW_VLAN;
|
||||
return ETH_HW_VLAN | ETH_LINK_10BASE_T | ETH_LINK_100BASE_T;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct ethernet_api eth0_api = {
|
||||
static const struct ethernet_api eth_api = {
|
||||
.iface_api.init = eth0_iface_init,
|
||||
.iface_api.send = eth_tx,
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
.get_capabilities = eth_capabilities,
|
||||
#endif
|
||||
.get_capabilities = eth_sam_gmac_get_capabilities,
|
||||
};
|
||||
|
||||
static struct device DEVICE_NAME_GET(eth0_sam_gmac);
|
||||
|
@ -992,4 +988,4 @@ static struct eth_sam_dev_data eth0_data = {
|
|||
|
||||
ETH_NET_DEVICE_INIT(eth0_sam_gmac, CONFIG_ETH_SAM_GMAC_NAME, eth_initialize,
|
||||
ð0_data, ð0_config, CONFIG_ETH_INIT_PRIORITY,
|
||||
ð0_api, GMAC_MTU);
|
||||
ð_api, GMAC_MTU);
|
||||
|
|
|
@ -306,7 +306,7 @@ static void generate_mac(u8_t *mac_addr)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void eth0_iface_init(struct net_if *iface)
|
||||
static void eth_iface_init(struct net_if *iface)
|
||||
{
|
||||
struct device *dev;
|
||||
struct eth_stm32_hal_dev_data *dev_data;
|
||||
|
@ -369,9 +369,18 @@ static void eth0_iface_init(struct net_if *iface)
|
|||
NET_LINK_ETHERNET);
|
||||
}
|
||||
|
||||
static const struct ethernet_api eth0_api = {
|
||||
.iface_api.init = eth0_iface_init,
|
||||
static enum eth_hw_caps eth_stm32_hal_get_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETH_LINK_10BASE_T | ETH_LINK_100BASE_T;
|
||||
}
|
||||
|
||||
static const struct ethernet_api eth_api = {
|
||||
.iface_api.init = eth_iface_init,
|
||||
.iface_api.send = eth_tx,
|
||||
|
||||
.get_capabilities = eth_stm32_hal_get_capabilities,
|
||||
};
|
||||
|
||||
static struct device DEVICE_NAME_GET(eth0_stm32_hal);
|
||||
|
@ -420,5 +429,5 @@ static struct eth_stm32_hal_dev_data eth0_data = {
|
|||
};
|
||||
|
||||
NET_DEVICE_INIT(eth0_stm32_hal, CONFIG_ETH_STM32_HAL_NAME, eth_initialize,
|
||||
ð0_data, ð0_config, CONFIG_ETH_INIT_PRIORITY, ð0_api,
|
||||
ð0_data, ð0_config, CONFIG_ETH_INIT_PRIORITY, ð_api,
|
||||
ETHERNET_L2, NET_L2_GET_CTX_TYPE(ETHERNET_L2), ETH_STM32_HAL_MTU);
|
||||
|
|
|
@ -508,23 +508,19 @@ use_random_mac:
|
|||
|
||||
static struct slip_context slip_context_data;
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
static enum eth_hw_caps eth_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETH_HW_VLAN;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SLIP_TAP) && defined(CONFIG_NET_L2_ETHERNET)
|
||||
static const struct ethernet_api slip_if_api = {
|
||||
.iface_api.init = slip_iface_init,
|
||||
.iface_api.send = slip_send,
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
.get_capabilities = eth_capabilities,
|
||||
#endif
|
||||
};
|
||||
|
||||
#define _SLIP_L2_LAYER ETHERNET_L2
|
||||
|
|
|
@ -45,13 +45,28 @@ extern "C" {
|
|||
|
||||
enum eth_hw_caps {
|
||||
/** TX Checksum offloading supported */
|
||||
ETH_HW_TX_CHKSUM_OFFLOAD = BIT(0),
|
||||
ETH_HW_TX_CHKSUM_OFFLOAD = BIT(0),
|
||||
|
||||
/** RX Checksum offloading supported */
|
||||
ETH_HW_RX_CHKSUM_OFFLOAD = BIT(1),
|
||||
ETH_HW_RX_CHKSUM_OFFLOAD = BIT(1),
|
||||
|
||||
/** VLAN supported */
|
||||
ETH_HW_VLAN = BIT(2),
|
||||
ETH_HW_VLAN = BIT(2),
|
||||
|
||||
/** Enabling/disabling auto negotiation supported */
|
||||
ETH_AUTO_NEGOTIATION_SET = BIT(3),
|
||||
|
||||
/** 10 Mbits link supported */
|
||||
ETH_LINK_10BASE_T = BIT(4),
|
||||
|
||||
/** 100 Mbits link supported */
|
||||
ETH_LINK_100BASE_T = BIT(5),
|
||||
|
||||
/** 1 Gbits link supported */
|
||||
ETH_LINK_1000BASE_T = BIT(6),
|
||||
|
||||
/** Changing duplex (half/full) supported */
|
||||
ETH_DUPLEX_SET = BIT(7),
|
||||
};
|
||||
|
||||
struct ethernet_api {
|
||||
|
|
|
@ -220,9 +220,16 @@ static enum eth_hw_caps eth_offloading_enabled(struct device *dev)
|
|||
ETH_HW_RX_CHKSUM_OFFLOAD;
|
||||
}
|
||||
|
||||
static enum eth_hw_caps eth_offloading_disabled(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ethernet_api api_funcs_offloading_disabled = {
|
||||
.iface_api.init = eth_iface_init,
|
||||
.iface_api.send = eth_tx_offloading_disabled,
|
||||
|
||||
.get_capabilities = eth_offloading_disabled,
|
||||
};
|
||||
|
||||
static struct ethernet_api api_funcs_offloading_enabled = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue