Lines Matching refs:ctx
135 AttachDevice(struct mtcp_thread_context* ctx) in AttachDevice() argument
138 mtcp_manager_t mtcp = ctx->mtcp_manager; in AttachDevice()
141 working = mtcp->iom->link_devices(ctx); in AttachDevice()
201 mtcp->ctx->cpu, in PrintThreadNetworkStats()
236 mtcp->ctx->cpu, rs->rounds / ROUND_DIV, in PrintThreadRoundStats()
253 "select: (%4luus, %4luus)\n", mtcp->ctx->cpu, in PrintThreadRoundTime()
802 "CPU %d: Flushing remaining flows.\n", mtcp->ctx->cpu); in DestroyRemainingFlows()
807 "CPU %d: Destroying stream %d\n", mtcp->ctx->cpu, walk->id); in DestroyRemainingFlows()
846 sem_wait(&g_done_sem[mtcp->ctx->cpu]); in RunPassiveLoop()
847 sem_destroy(&g_done_sem[mtcp->ctx->cpu]); in RunPassiveLoop()
852 RunMainLoop(struct mtcp_thread_context *ctx) in RunMainLoop() argument
854 mtcp_manager_t mtcp = ctx->mtcp_manager; in RunMainLoop()
869 TRACE_DBG("CPU %d: mtcp thread running.\n", ctx->cpu); in RunMainLoop()
883 while ((!ctx->done || mtcp->flow_cnt) && !ctx->exit) { in RunMainLoop()
899 recv_cnt = mtcp->iom->recv_pkts(ctx, rx_inf); in RunMainLoop()
905 pktbuf = mtcp->iom->get_rptr(mtcp->ctx, rx_inf, i, &len); in RunMainLoop()
925 struct mtcp_context mctx = {.cpu = ctx->cpu}; in RunMainLoop()
1006 mtcp->iom->send_pkts(ctx, tx_inf); in RunMainLoop()
1018 if (ctx->cpu == printer) { in RunMainLoop()
1030 mtcp->iom->select(ctx); in RunMainLoop()
1032 if (ctx->interrupt) { in RunMainLoop()
1041 TRACE_DBG("MTCP thread %d out of main loop.\n", ctx->cpu); in RunMainLoop()
1044 TRACE_DBG("MTCP thread %d flushed logs.\n", ctx->cpu); in RunMainLoop()
1046 TRACE_INFO("MTCP thread %d finished.\n", ctx->cpu); in RunMainLoop()
1079 InitializeMTCPManager(struct mtcp_thread_context* ctx) in InitializeMTCPManager() argument
1093 g_mtcp[ctx->cpu] = mtcp; in InitializeMTCPManager()
1206 mtcp->ctx = ctx; in InitializeMTCPManager()
1210 g_config.mos->mos_log, ctx->cpu); in InitializeMTCPManager()
1217 mtcp->sp_fd = g_logctx[ctx->cpu]->pair_sp_fd; in InitializeMTCPManager()
1218 mtcp->logger = g_logctx[ctx->cpu]; in InitializeMTCPManager()
1288 struct mtcp_thread_context *ctx; in MTCPRunThread() local
1295 ctx = calloc(1, sizeof(*ctx)); in MTCPRunThread()
1296 if (!ctx) { in MTCPRunThread()
1301 ctx->thread = pthread_self(); in MTCPRunThread()
1302 ctx->cpu = cpu; in MTCPRunThread()
1303 mtcp = ctx->mtcp_manager = InitializeMTCPManager(ctx); in MTCPRunThread()
1314 mtcp->iom->init_handle(ctx); in MTCPRunThread()
1316 if (pthread_mutex_init(&ctx->flow_pool_lock, NULL)) { in MTCPRunThread()
1321 if (pthread_mutex_init(&ctx->socket_pool_lock, NULL)) { in MTCPRunThread()
1326 SQ_LOCK_INIT(&ctx->connect_lock, "ctx->connect_lock", exit(-1)); in MTCPRunThread()
1327 SQ_LOCK_INIT(&ctx->close_lock, "ctx->close_lock", exit(-1)); in MTCPRunThread()
1328 SQ_LOCK_INIT(&ctx->reset_lock, "ctx->reset_lock", exit(-1)); in MTCPRunThread()
1329 SQ_LOCK_INIT(&ctx->sendq_lock, "ctx->sendq_lock", exit(-1)); in MTCPRunThread()
1330 SQ_LOCK_INIT(&ctx->ackq_lock, "ctx->ackq_lock", exit(-1)); in MTCPRunThread()
1331 SQ_LOCK_INIT(&ctx->destroyq_lock, "ctx->destroyq_lock", exit(-1)); in MTCPRunThread()
1334 g_pctx[cpu] = ctx; in MTCPRunThread()
1338 working = AttachDevice(ctx); in MTCPRunThread()
1340 sem_post(&g_init_sem[ctx->cpu]); in MTCPRunThread()
1341 TRACE_DBG("MTCP thread %d finished. Not attached any device\n", ctx->cpu); in MTCPRunThread()
1346 sem_post(&g_init_sem[ctx->cpu]); in MTCPRunThread()
1349 RunMainLoop(ctx); in MTCPRunThread()
1351 TRACE_DBG("MTCP thread %d finished.\n", ctx->cpu); in MTCPRunThread()
1471 struct mtcp_thread_context *ctx = g_pctx[mctx->cpu]; in mtcp_destroy_context() local
1472 if (ctx != NULL) in mtcp_destroy_context()
1473 ctx->done = 1; in mtcp_destroy_context()
1487 struct mtcp_thread_context *ctx = g_pctx[mctx->cpu]; in mtcp_free_context() local
1488 struct mtcp_manager *mtcp = ctx->mtcp_manager; in mtcp_free_context()
1497 if (!ctx->exit) { in mtcp_free_context()
1510 ctx->done = 1; in mtcp_free_context()
1511 ctx->exit = 1; in mtcp_free_context()
1548 if ((ret = pthread_join(log_thread[ctx->cpu], NULL) != 0)) { in mtcp_free_context()
1604 SQ_LOCK_DESTROY(&ctx->connect_lock); in mtcp_free_context()
1605 SQ_LOCK_DESTROY(&ctx->close_lock); in mtcp_free_context()
1606 SQ_LOCK_DESTROY(&ctx->reset_lock); in mtcp_free_context()
1607 SQ_LOCK_DESTROY(&ctx->sendq_lock); in mtcp_free_context()
1608 SQ_LOCK_DESTROY(&ctx->ackq_lock); in mtcp_free_context()
1609 SQ_LOCK_DESTROY(&ctx->destroyq_lock); in mtcp_free_context()
1613 mtcp->iom->destroy_handle(ctx); in mtcp_free_context()
1618 free(ctx); in mtcp_free_context()