summaryrefslogtreecommitdiff
path: root/lib/librte_kni/rte_kni.c
diff options
context:
space:
mode:
authorHemant Agrawal <hemant.agrawal@nxp.com>2018-01-18 11:42:59 +0530
committerThomas Monjalon <thomas@monjalon.net>2018-02-01 01:03:10 +0100
commit528057df4c4fb5b5b45bd8060267cb4105eda212 (patch)
tree64fb65f00156ca15fb5ca4fc72181c5bb431c9d2 /lib/librte_kni/rte_kni.c
parent1cfe212ed17a505be53d09845554cd51607dd2a6 (diff)
downloaddpdk-528057df4c4fb5b5b45bd8060267cb4105eda212.zip
dpdk-528057df4c4fb5b5b45bd8060267cb4105eda212.tar.gz
dpdk-528057df4c4fb5b5b45bd8060267cb4105eda212.tar.xz
kni: support promiscuous mode set
Inform userspace app about promisc mode change Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Diffstat (limited to 'lib/librte_kni/rte_kni.c')
-rw-r--r--lib/librte_kni/rte_kni.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index a140dfc..c089a49 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -525,6 +525,26 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
return ret;
}
+/* default callback for request of configuring promiscuous mode */
+static int
+kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
+{
+ if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) {
+ RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
+ return -EINVAL;
+ }
+
+ RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n",
+ port_id, to_on);
+
+ if (to_on)
+ rte_eth_promiscuous_enable(port_id);
+ else
+ rte_eth_promiscuous_disable(port_id);
+
+ return 0;
+}
+
int
rte_kni_handle_request(struct rte_kni *kni)
{
@@ -564,6 +584,14 @@ rte_kni_handle_request(struct rte_kni *kni)
req->result = kni_config_mac_address(
kni->ops.port_id, req->mac_addr);
break;
+ case RTE_KNI_REQ_CHANGE_PROMISC: /* Change PROMISCUOUS MODE */
+ if (kni->ops.config_promiscusity)
+ req->result = kni->ops.config_promiscusity(
+ kni->ops.port_id, req->promiscusity);
+ else if (kni->ops.port_id != UINT16_MAX)
+ req->result = kni_config_promiscusity(
+ kni->ops.port_id, req->promiscusity);
+ break;
default:
RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id);
req->result = -EINVAL;
@@ -714,7 +742,8 @@ kni_check_request_register(struct rte_kni_ops *ops)
if ((ops->change_mtu == NULL)
&& (ops->config_network_if == NULL)
- && (ops->config_mac_address == NULL))
+ && (ops->config_mac_address == NULL)
+ && (ops->config_promiscusity == NULL))
return KNI_REQ_NO_REGISTER;
return KNI_REQ_REGISTERED;