Skip to content

Commit

Permalink
Merge pull request #100 from lagopus/release-0.2
Browse files Browse the repository at this point in the history
Lagopus Release 0.2.10
  • Loading branch information
Yoshihiro Nakajima committed Dec 20, 2016
2 parents 0b48a9a + 9924230 commit 290402f
Show file tree
Hide file tree
Showing 52 changed files with 1,139 additions and 1,307 deletions.
2 changes: 1 addition & 1 deletion mk/make_dpdk.sh
Expand Up @@ -80,7 +80,7 @@ edit_dpdk_config CONFIG_RTE_BUILD_SHARED_LIB=y $NEWCONFIG
#edit_dpdk_config CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y $NEWCONFIG
edit_dpdk_config CONFIG_RTE_IXGBE_INC_VECTOR=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_LIBRTE_PMD_PCAP=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_LIBRTE_PMD_VHOST=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_LIBRTE_PMD_VHOST=y $NEWCONFIG
edit_dpdk_config CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_LIBRTE_PMD_BOND=n $NEWCONFIG
edit_dpdk_config CONFIG_RTE_APP_TEST=n $NEWCONFIG
Expand Down
12 changes: 6 additions & 6 deletions src/dataplane/dpdk/dpdk.h
Expand Up @@ -207,42 +207,42 @@
#endif

#ifndef APP_DEFAULT_BURST_SIZE_IO_RX_READ
#define APP_DEFAULT_BURST_SIZE_IO_RX_READ 144
#define APP_DEFAULT_BURST_SIZE_IO_RX_READ 32
#endif
#if (APP_DEFAULT_BURST_SIZE_IO_RX_READ > APP_MBUF_ARRAY_SIZE)
#error "APP_DEFAULT_BURST_SIZE_IO_RX_READ is too big"
#endif

#ifndef APP_DEFAULT_BURST_SIZE_IO_RX_WRITE
#define APP_DEFAULT_BURST_SIZE_IO_RX_WRITE 144
#define APP_DEFAULT_BURST_SIZE_IO_RX_WRITE 32
#endif
#if (APP_DEFAULT_BURST_SIZE_IO_RX_WRITE > APP_MBUF_ARRAY_SIZE)
#error "APP_DEFAULT_BURST_SIZE_IO_RX_WRITE is too big"
#endif

#ifndef APP_DEFAULT_BURST_SIZE_IO_TX_READ
#define APP_DEFAULT_BURST_SIZE_IO_TX_READ 144
#define APP_DEFAULT_BURST_SIZE_IO_TX_READ 32
#endif
#if (APP_DEFAULT_BURST_SIZE_IO_TX_READ > APP_MBUF_ARRAY_SIZE)
#error "APP_DEFAULT_BURST_SIZE_IO_TX_READ is too big"
#endif

#ifndef APP_DEFAULT_BURST_SIZE_IO_TX_WRITE
#define APP_DEFAULT_BURST_SIZE_IO_TX_WRITE 144
#define APP_DEFAULT_BURST_SIZE_IO_TX_WRITE 32
#endif
#if (APP_DEFAULT_BURST_SIZE_IO_TX_WRITE > APP_MBUF_ARRAY_SIZE)
#error "APP_DEFAULT_BURST_SIZE_IO_TX_WRITE is too big"
#endif

#ifndef APP_DEFAULT_BURST_SIZE_WORKER_READ
#define APP_DEFAULT_BURST_SIZE_WORKER_READ 144
#define APP_DEFAULT_BURST_SIZE_WORKER_READ 32
#endif
#if ((2 * APP_DEFAULT_BURST_SIZE_WORKER_READ) > APP_MBUF_ARRAY_SIZE)
#error "APP_DEFAULT_BURST_SIZE_WORKER_READ is too big"
#endif

#ifndef APP_DEFAULT_BURST_SIZE_WORKER_WRITE
#define APP_DEFAULT_BURST_SIZE_WORKER_WRITE 144
#define APP_DEFAULT_BURST_SIZE_WORKER_WRITE 32
#endif
#if (APP_DEFAULT_BURST_SIZE_WORKER_WRITE > APP_MBUF_ARRAY_SIZE)
#error "APP_DEFAULT_BURST_SIZE_WORKER_WRITE is too big"
Expand Down
60 changes: 31 additions & 29 deletions src/dataplane/dpdk/dpdk_io.c
Expand Up @@ -297,7 +297,6 @@ app_lcore_io_rx(struct app_lcore_params_io *lpio,
for (i = 0; i < lpio->rx.nifs; i++) {
uint32_t n_mbufs;

portid = lpio->rx.ifp[i]->info.eth.port_number;
n_mbufs = dpdk_rx_burst(lpio->rx.ifp[i], mbufs, bsz_rd);
if (n_mbufs != 0) {
dp_bulk_match_and_action(mbufs, n_mbufs, lp->worker.cache);
Expand Down Expand Up @@ -382,6 +381,9 @@ app_lcore_io_tx(struct app_lcore_params_io *lp,
int ret;

n_mbufs = lp->tx.mbuf_out[port].n_mbufs;
if (ring == NULL) {
continue;
}
ret = rte_ring_sc_dequeue_burst(ring,
(void **) &lp->tx.mbuf_out[port].array[n_mbufs],
bsz_rd - n_mbufs);
Expand Down Expand Up @@ -776,6 +778,7 @@ dpdk_configure_interface(struct interface *ifp) {
uint32_t n_rx_queues, n_tx_queues;
uint8_t portid;
struct rte_mempool *pool;
struct app_lcore_params_io *lp;

if (is_rawsocket_only_mode() == true) {
return LAGOPUS_RESULT_INVALID_ARGS;
Expand Down Expand Up @@ -820,6 +823,10 @@ dpdk_configure_interface(struct interface *ifp) {

/* Init port */
printf("Initializing NIC port %u ...\n", (unsigned) portid);
if (!rte_eth_dev_is_valid_port(portid)) {
printf("NIC port %u cannot used for DPDK\n", (unsigned) portid);
return LAGOPUS_RESULT_INVALID_ARGS;
}
if ((rte_eth_devices[portid].data->dev_flags & RTE_ETH_DEV_INTR_LSC) != 0) {
port_conf.intr_conf.lsc = 1;
ret = rte_eth_dev_configure(portid,
Expand Down Expand Up @@ -883,36 +890,16 @@ dpdk_configure_interface(struct interface *ifp) {
if (lp == NULL) {
lagopus_exit_fatal("Unassigned I/O core\n");
}
lp->io.tx.nic_ports[lp->io.tx.n_nic_ports] = portid;
lp->io.tx.n_nic_ports++;
app.nic_tx_port_mask[portid] = 1;
lp->io.rx.nic_queues[lp->io.rx.n_nic_queues].port = portid;
lp->io.rx.nic_queues[lp->io.rx.n_nic_queues].queue = 0;
lp->io.rx.n_nic_queues++;
app.nic_rx_queue_mask[portid][0] = NIC_RX_QUEUE_ENABLED;
lp->io.tx.nic_ports[lp->io.tx.n_nic_ports] = portid;
lp->io.tx.n_nic_ports++;
lp->io.rx.ifp[lp->io.rx.nifs++] = ifp;
app.nic_tx_port_mask[portid] = 1;
} else {
struct app_lcore_params *lp;
unsigned lcore;
int i;

if (app_get_lcore_for_nic_rx(portid, 0, &lcore) < 0) {
lagopus_exit_fatal("lcore not found for port %d queue %d\n",
portid, 0);
}
lp = &app.lcore_params[lcore];
for (i = 0; i < lp->io.rx.nifs; i++) {
if (lp->io.rx.ifp[i]->info.eth.port_number == portid) {
break;
}
}
if (i == lp->io.rx.nifs) {
lp->io.rx.ifp[lp->io.rx.nifs++] = ifp;
}
}
/* Init RX queues */
for (queue = 0; queue < APP_MAX_RX_QUEUES_PER_NIC_PORT; queue ++) {
struct app_lcore_params_io *lp;
for (queue = 0; queue < APP_MAX_RX_QUEUES_PER_NIC_PORT; queue++) {
uint8_t i;

if (app.nic_rx_queue_mask[portid][queue] == NIC_RX_QUEUE_UNCONFIGURED) {
Expand Down Expand Up @@ -975,13 +962,20 @@ dpdk_configure_interface(struct interface *ifp) {

ifp->stats = dpdk_port_stats;
dpdk_interface_set_index(ifp);
/* finally, enable rx */
app_get_lcore_for_nic_rx(portid, 0, &lcore);
lp = &app.lcore_params[lcore].io;
lp->rx.ifp[lp->rx.nifs++] = ifp;

return LAGOPUS_RESULT_OK;
}

lagopus_result_t
dpdk_unconfigure_interface(struct interface *ifp) {
uint8_t portid, queue;
struct app_lcore_params_io *lp;
uint32_t lcore;
uint8_t i;

if (strlen(ifp->info.eth_dpdk_phy.device) > 0) {
uint8_t actual_portid;
Expand All @@ -998,11 +992,19 @@ dpdk_unconfigure_interface(struct interface *ifp) {
portid = (uint8_t)ifp->info.eth.port_number;

dpdk_stop_interface(portid);
if (app_get_lcore_for_nic_rx(portid, 0, &lcore) < 0) {
lagopus_exit_fatal("lcore not found for port %d queue 0\n", portid);
}
lp = &app.lcore_params[lcore].io;
for (i = 0; i < lp->rx.nifs; i++) {
if (lp->rx.ifp[i] == ifp) {
lp->rx.nifs--;
memmove(&lp->rx.ifp[i], &lp->rx.ifp[i + 1],
sizeof(ifp) * (lp->rx.nifs - i));
break;
}
}
for (queue = 0; queue < APP_MAX_RX_QUEUES_PER_NIC_PORT; queue ++) {
struct app_lcore_params_io *lp;
uint32_t lcore;
uint8_t i;

if (app.nic_rx_queue_mask[portid][queue] == NIC_RX_QUEUE_UNCONFIGURED) {
continue;
}
Expand Down
15 changes: 9 additions & 6 deletions src/dataplane/dpdk/worker.c
Expand Up @@ -472,11 +472,11 @@ dpdk_send_packet_physical(struct lagopus_packet *pkt, struct interface *ifp) {
switch (IPV4_PROTO(pkt->ipv4)) {
case IPPROTO_TCP:
m->ol_flags |= PKT_TX_TCP_CKSUM;
pkt->tcp[8] = rte_ipv4_phdr_cksum(pkt->ipv4, m->ol_flags);
TCP_CKSUM(pkt->tcp) = rte_ipv4_phdr_cksum(pkt->ipv4, m->ol_flags);
break;
case IPPROTO_UDP:
m->ol_flags |= PKT_TX_UDP_CKSUM;
pkt->udp[3] = rte_ipv4_phdr_cksum(pkt->ipv4, m->ol_flags);
UDP_CKSUM(pkt->udp) = rte_ipv4_phdr_cksum(pkt->ipv4, m->ol_flags);
break;
case IPPROTO_SCTP:
m->ol_flags |= PKT_TX_SCTP_CKSUM;
Expand All @@ -492,11 +492,11 @@ dpdk_send_packet_physical(struct lagopus_packet *pkt, struct interface *ifp) {
switch (IPV4_PROTO(pkt->ipv4)) {
case IPPROTO_TCP:
m->ol_flags |= PKT_TX_TCP_CKSUM;
pkt->tcp[8] = rte_ipv6_phdr_cksum(pkt->ipv4, m->ol_flags);
TCP_CKSUM(pkt->tcp) = rte_ipv6_phdr_cksum(pkt->ipv4, m->ol_flags);
break;
case IPPROTO_UDP:
m->ol_flags |= PKT_TX_UDP_CKSUM;
pkt->udp[3] = rte_ipv6_phdr_cksum(pkt->ipv4, m->ol_flags);
UDP_CKSUM(pkt->udp) = rte_ipv6_phdr_cksum(pkt->ipv4, m->ol_flags);
break;
case IPPROTO_SCTP:
m->ol_flags |= PKT_TX_SCTP_CKSUM;
Expand Down Expand Up @@ -547,7 +547,10 @@ dpdk_get_worker_id(void) {
uint32_t lcore;
struct app_lcore_params_worker *lp;
lcore = rte_lcore_id();
lp = &app.lcore_params[lcore].worker;
return lp->worker_id;
if (lcore < UINT32_MAX) {
lp = &app.lcore_params[lcore].worker;
return lp->worker_id;
}
return UINT32_MAX;
}
#endif /* HYBRID */
53 changes: 28 additions & 25 deletions src/dataplane/mgr/dp_apis.c
Expand Up @@ -46,7 +46,6 @@ static lagopus_hashmap_t port_hashmap;
static lagopus_hashmap_t bridge_hashmap;
static lagopus_hashmap_t dpid_hashmap;
static lagopus_hashmap_t queue_hashmap;
static lagopus_hashmap_t queueid_hashmap;

/**
* physical port id --> struct port table
Expand Down Expand Up @@ -92,11 +91,6 @@ dp_api_init(void) {
LAGOPUS_HASHMAP_TYPE_STRING,
dp_queue_free);
}
if (rv == LAGOPUS_RESULT_OK) {
rv = lagopus_hashmap_create(&queueid_hashmap,
LAGOPUS_HASHMAP_TYPE_ONE_WORD,
NULL);
}
/* Initialize read write lock. */
flowdb_lock_init(NULL);
init_dp_timer();
Expand All @@ -113,7 +107,6 @@ dp_api_fini(void) {
lagopus_hashmap_destroy(&bridge_hashmap, true);
lagopus_hashmap_destroy(&dpid_hashmap, false);
lagopus_hashmap_destroy(&queue_hashmap, true);
lagopus_hashmap_destroy(&queueid_hashmap, true);
for (i = 0; i < DATASTORE_INTERFACE_TYPE_MAX + 1; i++) {
lagopus_hashmap_destroy(&portid_hashmap[i], false);
}
Expand Down Expand Up @@ -1313,20 +1306,13 @@ lagopus_result_t
dp_queue_create(const char *name,
datastore_queue_info_t *queue_info) {
datastore_queue_info_t *queue;
uint64_t id;
lagopus_result_t rv;

rv = lagopus_hashmap_find(&queue_hashmap, (void *)name, (void **)&queue);
if (rv == LAGOPUS_RESULT_OK) {
rv = LAGOPUS_RESULT_ALREADY_EXISTS;
goto out;
}
id = queue_info->id;
rv = lagopus_hashmap_find(&queueid_hashmap, (void *)id, (void **)&queue);
if (rv == LAGOPUS_RESULT_OK) {
rv = LAGOPUS_RESULT_ALREADY_EXISTS;
goto out;
}
queue = calloc(1, sizeof(datastore_queue_info_t));
if (queue == NULL) {
rv = LAGOPUS_RESULT_NO_MEMORY;
Expand All @@ -1335,15 +1321,6 @@ dp_queue_create(const char *name,
memcpy(queue, queue_info, sizeof(datastore_queue_info_t));
rv = lagopus_hashmap_add(&queue_hashmap, (void *)name,
(void **)&queue, false);
if (rv == LAGOPUS_RESULT_OK) {
rv = lagopus_hashmap_find(&queue_hashmap, (void *)name, (void **)&queue);
if (rv != LAGOPUS_RESULT_OK) {
goto out;
}
id = queue_info->id;
rv = lagopus_hashmap_add(&queueid_hashmap, (void *)id,
(void **)&queue, false);
}
out:
return rv;
}
Expand All @@ -1362,12 +1339,38 @@ dp_queue_destroy(const char *name) {
dp_queue_stop(name);
rv = lagopus_hashmap_find(&queue_hashmap, (void *)name, (void **)&queue);
if (rv == LAGOPUS_RESULT_OK) {
id = queue->id;
lagopus_hashmap_delete(&queueid_hashmap, (void *)id, NULL, false);
lagopus_hashmap_delete(&queue_hashmap, (void *)name, NULL, true);
}
}

lagopus_result_t
dp_queue_id_set(const char *name, uint32_t id) {
datastore_queue_info_t *queue;
lagopus_result_t rv;

rv = lagopus_hashmap_find(&queue_hashmap, (void *)name,
(void **)&queue);
if (rv != LAGOPUS_RESULT_OK) {
return rv;
}
queue->id = id;
return LAGOPUS_RESULT_OK;
}

lagopus_result_t
dp_queue_id_unset(const char *name) {
datastore_queue_info_t *queue;
lagopus_result_t rv;

rv = lagopus_hashmap_find(&queue_hashmap, (void *)name,
(void **)&queue);
if (rv != LAGOPUS_RESULT_OK) {
return rv;
}
queue->id = 0;
return LAGOPUS_RESULT_OK;
}

lagopus_result_t
dp_queue_start(const char *name) {
(void) name;
Expand Down

0 comments on commit 290402f

Please sign in to comment.