* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 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
* * 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.
* * 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
* 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
portid = strtoul(ifname, &endptr, 10);
if (endptr == ifname || *endptr != '\0' ||
portid >= RTE_DIM(ports) || errno != 0)
portid = strtoul(ifname, &endptr, 10);
if (endptr == ifname || *endptr != '\0' ||
portid >= RTE_DIM(ports) || errno != 0)
/**
* Given a Netmap ring and a slot index for that ring, construct a dpdk mbuf
* from the data held in the buffer associated with the slot.
/**
* Given a Netmap ring and a slot index for that ring, construct a dpdk mbuf
* from the data held in the buffer associated with the slot.
/* if we still have a valid port attached, release the port */
if (port < RTE_DIM(ports) && ports[port].fd == idx) {
/* if we still have a valid port attached, release the port */
if (port < RTE_DIM(ports) && ports[port].fd == idx) {
}
if ((rc = ifname_to_portid(req->nr_name, &portid)) != 0) {
RTE_LOG(ERR, USER1, "Invalid interface name:\"%s\" "
"in NIOCGINFO call\n", req->nr_name);
}
if ((rc = ifname_to_portid(req->nr_name, &portid)) != 0) {
RTE_LOG(ERR, USER1, "Invalid interface name:\"%s\" "
"in NIOCGINFO call\n", req->nr_name);
}
if (ports[portid].pool == NULL) {
RTE_LOG(ERR, USER1, "Misconfigured portid %hhu\n", portid);
}
if (ports[portid].pool == NULL) {
RTE_LOG(ERR, USER1, "Misconfigured portid %hhu\n", portid);
req = (struct nmreq *)param;
if ((rc = check_nmreq(req, &portid)) != 0)
req = (struct nmreq *)param;
if ((rc = check_nmreq(req, &portid)) != 0)
req->nr_tx_rings = (uint16_t)(ports[portid].nr_tx_rings - 1);
req->nr_rx_rings = (uint16_t)(ports[portid].nr_rx_rings - 1);
req->nr_tx_rings = (uint16_t)(ports[portid].nr_tx_rings - 1);
req->nr_rx_rings = (uint16_t)(ports[portid].nr_rx_rings - 1);
for (j = 0; j < ring->num_slots; j++) {
ring->slot[j].buf_idx = BUF_IDX(port, ringid, j);
ring->slot[j].len = 0;
for (j = 0; j < ring->num_slots; j++) {
ring->slot[j].buf_idx = BUF_IDX(port, ringid, j);
ring->slot[j].len = 0;
if (ports[port].fd < RTE_DIM(fd_port)) {
RTE_LOG(ERR, USER1, "port %hhu already in use by fd: %u\n",
port, IDX_TO_FD(ports[port].fd));
if (ports[port].fd < RTE_DIM(fd_port)) {
RTE_LOG(ERR, USER1, "port %hhu already in use by fd: %u\n",
port, IDX_TO_FD(ports[port].fd));
}
if (fd_port[idx].port != FD_PORT_RSRV) {
RTE_LOG(ERR, USER1, "fd: %u is misconfigured\n",
IDX_TO_FD(idx));
}
if (fd_port[idx].port != FD_PORT_RSRV) {
RTE_LOG(ERR, USER1, "fd: %u is misconfigured\n",
IDX_TO_FD(idx));
- rte_snprintf(nmif->ni_name, sizeof(nmif->ni_name), "%s", req->nr_name);
+ snprintf(nmif->ni_name, sizeof(nmif->ni_name), "%s", req->nr_name);
req = (struct nmreq *)param;
if ((rc = check_nmreq(req, &portid)) != 0)
req = (struct nmreq *)param;
if ((rc = check_nmreq(req, &portid)) != 0)
rc = netmap_regif(req, idx, portid);
rte_spinlock_unlock(&netmap_lock);
rc = netmap_regif(req, idx, portid);
rte_spinlock_unlock(&netmap_lock);
burst_size = (uint16_t)RTE_MIN(n_used_slots, RTE_DIM(tx_mbufs));
for (i = 0; i < burst_size; i++) {
burst_size = (uint16_t)RTE_MIN(n_used_slots, RTE_DIM(tx_mbufs));
for (i = 0; i < burst_size; i++) {
port_num = RTE_MAX_ETHPORTS;
port_rings = 2 * conf->max_rings;
port_slots = port_rings * conf->max_slots;
port_num = RTE_MAX_ETHPORTS;
port_rings = 2 * conf->max_rings;
port_slots = port_rings * conf->max_slots;
sz = buf_ofs + port_bufs * conf->max_bufsz * port_num;
if (sz > UINT32_MAX ||
(netmap.mem = rte_zmalloc_socket(__func__, sz,
sz = buf_ofs + port_bufs * conf->max_bufsz * port_num;
if (sz > UINT32_MAX ||
(netmap.mem = rte_zmalloc_socket(__func__, sz,
RTE_LOG(ERR, USER1, "%s: failed to allocate %zu bytes\n",
__func__, sz);
RTE_LOG(ERR, USER1, "%s: failed to allocate %zu bytes\n",
__func__, sz);
conf->nr_rx_rings > netmap.conf.max_rings) {
RTE_LOG(ERR, USER1, "%s(%hhu): invalid parameters\n",
__func__, portid);
conf->nr_rx_rings > netmap.conf.max_rings) {
RTE_LOG(ERR, USER1, "%s(%hhu): invalid parameters\n",
__func__, portid);
rx_slots > netmap.conf.max_slots) {
RTE_LOG(ERR, USER1, "%s(%hhu): invalid parameters\n",
__func__, portid);
rx_slots > netmap.conf.max_slots) {
RTE_LOG(ERR, USER1, "%s(%hhu): invalid parameters\n",
__func__, portid);
}
ret = rte_eth_dev_configure(portid, conf->nr_rx_rings,
conf->nr_tx_rings, conf->eth_conf);
}
ret = rte_eth_dev_configure(portid, conf->nr_rx_rings,
conf->nr_tx_rings, conf->eth_conf);
if (ret < 0) {
RTE_LOG(ERR, USER1, "Couldn't configure port %hhu\n", portid);
if (ret < 0) {
RTE_LOG(ERR, USER1, "Couldn't configure port %hhu\n", portid);
}
for (i = 0; i < conf->nr_tx_rings; i++) {
ret = rte_eth_tx_queue_setup(portid, i, tx_slots,
}
for (i = 0; i < conf->nr_tx_rings; i++) {
ret = rte_eth_tx_queue_setup(portid, i, tx_slots,
}
ret = rte_eth_rx_queue_setup(portid, i, rx_slots,
}
ret = rte_eth_rx_queue_setup(portid, i, rx_slots,
ports[portid].pool = conf->pool;
ports[portid].socket_id = conf->socket_id;
ports[portid].nr_tx_rings = conf->nr_tx_rings;
ports[portid].pool = conf->pool;
ports[portid].socket_id = conf->socket_id;
ports[portid].nr_tx_rings = conf->nr_tx_rings;
* Return a "fake" file descriptor with a value above RLIMIT_NOFILE so that
* any attempt to use that file descriptor with the usual API will fail.
*/
* Return a "fake" file descriptor with a value above RLIMIT_NOFILE so that
* any attempt to use that file descriptor with the usual API will fail.
*/