From f568be48d079d52aaa673309ef440dbdaa05cb03 Mon Sep 17 00:00:00 2001 From: Tomasz Gorochowik Date: Mon, 30 Jul 2018 15:51:01 +0200 Subject: [PATCH] net: eth: mgmt: Add Qav status hooks Add calls responsible for getting and setting on/off status of Qav on capable priority queues. Signed-off-by: Tomasz Gorochowik --- include/net/ethernet.h | 2 ++ include/net/ethernet_mgmt.h | 12 +++++++++++ subsys/net/l2/ethernet/ethernet_mgmt.c | 30 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/net/ethernet.h b/include/net/ethernet.h index 4b67268f1cf..a82d4756999 100644 --- a/include/net/ethernet.h +++ b/include/net/ethernet.h @@ -96,6 +96,7 @@ enum ethernet_config_type { ETHERNET_CONFIG_TYPE_MAC_ADDRESS, ETHERNET_CONFIG_TYPE_QAV_DELTA_BANDWIDTH, ETHERNET_CONFIG_TYPE_QAV_IDLE_SLOPE, + ETHERNET_CONFIG_TYPE_QAV_STATUS, ETHERNET_CONFIG_TYPE_PROMISC_MODE, ETHERNET_CONFIG_TYPE_PRIORITY_QUEUES_NUM, ETHERNET_CONFIG_TYPE_FILTER, @@ -104,6 +105,7 @@ enum ethernet_config_type { struct ethernet_qav_queue_param { int queue_id; union { + bool enabled; unsigned int delta_bandwidth; unsigned int idle_slope; }; diff --git a/include/net/ethernet_mgmt.h b/include/net/ethernet_mgmt.h index 3d76e35b165..3eaac1cd4a2 100644 --- a/include/net/ethernet_mgmt.h +++ b/include/net/ethernet_mgmt.h @@ -40,8 +40,10 @@ enum net_request_ethernet_cmd { NET_REQUEST_ETHERNET_CMD_SET_MAC_ADDRESS, NET_REQUEST_ETHERNET_CMD_SET_QAV_DELTA_BANDWIDTH, NET_REQUEST_ETHERNET_CMD_SET_QAV_IDLE_SLOPE, + NET_REQUEST_ETHERNET_CMD_SET_QAV_STATUS, NET_REQUEST_ETHERNET_CMD_SET_PROMISC_MODE, NET_REQUEST_ETHERNET_CMD_GET_PRIORITY_QUEUES_NUM, + NET_REQUEST_ETHERNET_CMD_GET_QAV_STATUS, }; #define NET_REQUEST_ETHERNET_SET_AUTO_NEGOTIATION \ @@ -74,6 +76,11 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_DELTA_BANDWIDTH); NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_IDLE_SLOPE); +#define NET_REQUEST_ETHERNET_SET_QAV_STATUS \ + (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_QAV_STATUS) + +NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_STATUS); + #define NET_REQUEST_ETHERNET_SET_PROMISC_MODE \ (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_SET_PROMISC_MODE) @@ -84,6 +91,11 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_PROMISC_MODE); NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM); +#define NET_REQUEST_ETHERNET_GET_QAV_STATUS \ + (_NET_ETHERNET_BASE | NET_REQUEST_ETHERNET_CMD_GET_QAV_STATUS) + +NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QAV_STATUS); + struct net_eth_addr; struct ethernet_qav_queue_param; diff --git a/subsys/net/l2/ethernet/ethernet_mgmt.c b/subsys/net/l2/ethernet/ethernet_mgmt.c index ff6698da9fb..b9052f3cba6 100644 --- a/subsys/net/l2/ethernet/ethernet_mgmt.c +++ b/subsys/net/l2/ethernet/ethernet_mgmt.c @@ -114,6 +114,14 @@ static int ethernet_set_config(u32_t mgmt_request, memcpy(&config.qav_queue_param, ¶ms->qav_queue_param, sizeof(struct ethernet_qav_queue_param)); type = ETHERNET_CONFIG_TYPE_QAV_IDLE_SLOPE; + } else if (mgmt_request == NET_REQUEST_ETHERNET_SET_QAV_STATUS) { + if (!is_hw_caps_supported(dev, ETHERNET_QAV)) { + return -ENOTSUP; + } + + memcpy(&config.qav_queue_param, ¶ms->qav_queue_param, + sizeof(struct ethernet_qav_queue_param)); + type = ETHERNET_CONFIG_TYPE_QAV_STATUS; } else if (mgmt_request == NET_REQUEST_ETHERNET_SET_PROMISC_MODE) { if (!is_hw_caps_supported(dev, ETHERNET_PROMISC_MODE)) { return -ENOTSUP; @@ -146,6 +154,9 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_DELTA_BANDWIDTH, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_IDLE_SLOPE, ethernet_set_config); +NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_QAV_STATUS, + ethernet_set_config); + NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_PROMISC_MODE, ethernet_set_config); @@ -181,6 +192,22 @@ static int ethernet_get_config(u32_t mgmt_request, } params->priority_queues_num = config.priority_queues_num; + } else if (mgmt_request == NET_REQUEST_ETHERNET_GET_QAV_STATUS) { + if (!is_hw_caps_supported(dev, ETHERNET_QAV)) { + return -ENOTSUP; + } + + config.qav_queue_param.queue_id = + params->qav_queue_param.queue_id; + + type = ETHERNET_CONFIG_TYPE_QAV_STATUS; + ret = api->get_config(dev, type, &config); + if (ret) { + return ret; + } + + params->qav_queue_param.enabled = + config.qav_queue_param.enabled; } else { return -EINVAL; } @@ -191,6 +218,9 @@ static int ethernet_get_config(u32_t mgmt_request, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM, ethernet_get_config); +NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_GET_QAV_STATUS, + ethernet_get_config); + void ethernet_mgmt_raise_carrier_on_event(struct net_if *iface) { net_mgmt_event_notify(NET_EVENT_ETHERNET_CARRIER_ON, iface);