event/dpaa2: support max event port value
[dpdk.git] / lib / librte_kni / rte_kni.c
index c089a49..65f6a2b 100644 (file)
@@ -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);
 
@@ -509,7 +510,7 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
 {
        int ret = 0;
 
-       if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) {
+       if (!rte_eth_dev_is_valid_port(port_id)) {
                RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
                return -EINVAL;
        }
@@ -529,7 +530,7 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
 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) {
+       if (!rte_eth_dev_is_valid_port(port_id)) {
                RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
                return -EINVAL;
        }
@@ -714,6 +715,9 @@ rte_kni_get(const char *name)
        struct rte_kni_memzone_slot *it;
        struct rte_kni *kni;
 
+       if (name == NULL || name[0] == '\0')
+               return NULL;
+
        /* Note: could be improved perf-wise if necessary */
        for (i = 0; i < kni_memzone_pool.max_ifaces; i++) {
                it = &kni_memzone_pool.slots[i];