/*-
* BSD LICENSE
- *
- * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *
+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
memset(&conf, 0, sizeof(conf));
rte_eth_dev_info_get(port_id, &info);
- rte_snprintf(conf.name, sizeof(conf.name), "vEth%u", port_id);
+ snprintf(conf.name, sizeof(conf.name), "vEth%u", port_id);
conf.addr = info.pci_dev->addr;
conf.id = info.pci_dev->id;
conf.group_id = (uint16_t)port_id;
}
}
- rte_snprintf(intf_name, RTE_KNI_NAMESIZE, conf->name);
- rte_snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "KNI_INFO_%s", intf_name);
- mz = kni_memzone_reserve(mz_name, sizeof(struct rte_kni),
+ snprintf(intf_name, RTE_KNI_NAMESIZE, "%s", conf->name);
+ snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "KNI_INFO_%s", intf_name);
+ mz = kni_memzone_reserve(mz_name, sizeof(struct rte_kni),
SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx = mz->addr;
dev_info.function = conf->addr.function;
dev_info.vendor_id = conf->id.vendor_id;
dev_info.device_id = conf->id.device_id;
+ dev_info.core_id = conf->core_id;
+ dev_info.force_bind = conf->force_bind;
dev_info.group_id = conf->group_id;
dev_info.mbuf_size = conf->mbuf_size;
- rte_snprintf(ctx->name, RTE_KNI_NAMESIZE, intf_name);
- rte_snprintf(dev_info.name, RTE_KNI_NAMESIZE, intf_name);
+ snprintf(ctx->name, RTE_KNI_NAMESIZE, "%s", intf_name);
+ snprintf(dev_info.name, RTE_KNI_NAMESIZE, "%s", intf_name);
RTE_LOG(INFO, KNI, "pci: %02x:%02x:%02x \t %02x:%02x\n",
dev_info.bus, dev_info.devid, dev_info.function,
dev_info.vendor_id, dev_info.device_id);
/* TX RING */
- rte_snprintf(obj_name, OBJNAMSIZ, "kni_tx_%s", intf_name);
+ snprintf(obj_name, OBJNAMSIZ, "kni_tx_%s", intf_name);
mz = kni_memzone_reserve(obj_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx->tx_q = mz->addr;
dev_info.tx_phys = mz->phys_addr;
/* RX RING */
- rte_snprintf(obj_name, OBJNAMSIZ, "kni_rx_%s", intf_name);
+ snprintf(obj_name, OBJNAMSIZ, "kni_rx_%s", intf_name);
mz = kni_memzone_reserve(obj_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx->rx_q = mz->addr;
dev_info.rx_phys = mz->phys_addr;
/* ALLOC RING */
- rte_snprintf(obj_name, OBJNAMSIZ, "kni_alloc_%s", intf_name);
+ snprintf(obj_name, OBJNAMSIZ, "kni_alloc_%s", intf_name);
mz = kni_memzone_reserve(obj_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx->alloc_q = mz->addr;
dev_info.alloc_phys = mz->phys_addr;
/* FREE RING */
- rte_snprintf(obj_name, OBJNAMSIZ, "kni_free_%s", intf_name);
+ snprintf(obj_name, OBJNAMSIZ, "kni_free_%s", intf_name);
mz = kni_memzone_reserve(obj_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx->free_q = mz->addr;
dev_info.free_phys = mz->phys_addr;
/* Request RING */
- rte_snprintf(obj_name, OBJNAMSIZ, "kni_req_%s", intf_name);
+ snprintf(obj_name, OBJNAMSIZ, "kni_req_%s", intf_name);
mz = kni_memzone_reserve(obj_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx->req_q = mz->addr;
dev_info.req_phys = mz->phys_addr;
/* Response RING */
- rte_snprintf(obj_name, OBJNAMSIZ, "kni_resp_%s", intf_name);
+ snprintf(obj_name, OBJNAMSIZ, "kni_resp_%s", intf_name);
mz = kni_memzone_reserve(obj_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx->resp_q = mz->addr;
dev_info.resp_phys = mz->phys_addr;
/* Req/Resp sync mem area */
- rte_snprintf(obj_name, OBJNAMSIZ, "kni_sync_%s", intf_name);
+ snprintf(obj_name, OBJNAMSIZ, "kni_sync_%s", intf_name);
mz = kni_memzone_reserve(obj_name, KNI_FIFO_SIZE, SOCKET_ID_ANY, 0);
KNI_MZ_CHECK(mz == NULL);
ctx->sync_addr = mz->addr;
dev_info.sync_phys = mz->phys_addr;
/* MBUF mempool */
- rte_snprintf(mz_name, sizeof(mz_name), "MP_%s", pktmbuf_pool->name);
+ snprintf(mz_name, sizeof(mz_name), RTE_MEMPOOL_OBJ_NAME,
+ pktmbuf_pool->name);
mz = rte_memzone_lookup(mz_name);
KNI_MZ_CHECK(mz == NULL);
dev_info.mbuf_va = mz->addr;
if (!kni || !kni->in_use)
return -1;
- rte_snprintf(dev_info.name, sizeof(dev_info.name), kni->name);
+ snprintf(dev_info.name, sizeof(dev_info.name), "%s", kni->name);
if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) {
RTE_LOG(ERR, KNI, "Fail to release kni device\n");
return -1;
if (!name || !name[0])
return NULL;
- rte_snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "KNI_INFO_%s", name);
+ snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "KNI_INFO_%s", name);
mz = rte_memzone_lookup(mz_name);
if (!mz)
return NULL;
if (port_id >= RTE_MAX_ETHPORTS)
return NULL;
- rte_snprintf(name, RTE_MEMZONE_NAMESIZE, "vEth%u", port_id);
+ snprintf(name, RTE_MEMZONE_NAMESIZE, "vEth%u", port_id);
return rte_kni_get(name);
}
/* check if KNI request ops has been registered*/
if( NULL == ops )
return KNI_REQ_NO_REGISTER;
-
+
if((NULL == ops->change_mtu) && (NULL == ops->config_network_if))
return KNI_REQ_NO_REGISTER;
rte_kni_register_handlers(struct rte_kni *kni,struct rte_kni_ops *ops)
{
enum kni_ops_status req_status;
-
+
if (NULL == ops) {
RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n");
return -1;
return -1;
}
- memcpy(&kni->ops, ops, sizeof(struct rte_kni_ops));
+ memcpy(&kni->ops, ops, sizeof(struct rte_kni_ops));
return 0;
}
RTE_LOG(ERR, KNI, "Invalid kni info.\n");
return -1;
}
-
+
kni->ops.change_mtu = NULL;
kni->ops.config_network_if = NULL;
return 0;
}
+void
+rte_kni_close(void)
+{
+ if (kni_fd < 0)
+ return;
+
+ close(kni_fd);
+ kni_fd = -1;
+}