X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_kni%2Frte_kni.c;h=28674115ffa155ebcdf4dbf18cbd9ae1272e32a0;hb=32fa181c542c1acb7b6d883d5215c72447fc5847;hp=a140dfcadfcc9d5c460b883450b63974d355c73d;hpb=1cfe212ed17a505be53d09845554cd51607dd2a6;p=dpdk.git diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index a140dfcadf..28674115ff 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -340,6 +340,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, dev_info.force_bind = conf->force_bind; dev_info.group_id = conf->group_id; dev_info.mbuf_size = conf->mbuf_size; + dev_info.mtu = conf->mtu; memcpy(dev_info.mac_addr, conf->mac_addr, ETHER_ADDR_LEN); @@ -525,6 +526,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 +585,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 +743,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;