static int npa_remote_cb(struct msm_rpc_client *client, struct msm_rpc_xdr *xdr) { int err = 0; int array_length = 0; unsigned int status = RPC_ACCEPTSTAT_SYSTEM_ERR; struct npa_remote_cb_data arg; npa_remote_callback cb_fn = NULL; xdr_recv_uint32(xdr, &arg.cb_id); xdr_recv_uint32(xdr, &arg.context); xdr_recv_uint32(xdr, &arg.type); xdr_recv_array(xdr, (void **)&arg.buffer, &array_length, INT_MAX, sizeof(int32_t), (void *)xdr_recv_int32); xdr_recv_uint32(xdr, &arg.size); cb_fn = (npa_remote_callback) msm_rpc_get_cb_func(client, arg.cb_id); if (cb_fn) { cb_fn((void *)arg.context, arg.type, arg.buffer, arg.size); status = RPC_ACCEPTSTAT_SUCCESS; } xdr_start_accepted_reply(xdr, status); err = xdr_send_msg(xdr); if (err) { pr_err("NPA Remote callback %s: send accepted reply failed: " "%d\n", __func__, err); BUG(); } kfree(arg.buffer); return 0; }
static void makdi_dump_nfv_groups_cmd(struct c_ofp_s_chain_nfv_group_info *nfv_group_info, void *arg, void (*cb_fn)(void *arg, void *pbuf)) { char *pbuf = calloc(1, SERV_CHAIN_PBUF_SZ); struct c_ofp_s_chain_nfv_info *_nfv_info; int nfv_counter = 0; uint8_t len = 0; if (!pbuf) return; nfv_group_info->nfv_group[MAX_NFV_NAME - 1] = '\0'; len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, "add makdi-nfv-group %s\r\n", nfv_group_info->nfv_group); while (nfv_counter < nfv_group_info->nfv_list.num_nfvs) { _nfv_info = &nfv_group_info->nfv_list.nfv_info[nfv_counter++]; _nfv_info->nfv[MAX_NFV_NAME - 1] = '\0'; len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, "add makdi-nfv group %s nfv %s switch 0x%llx " "in-port %hu out-port %hu\r\n", nfv_group_info->nfv_group, _nfv_info->nfv, U642ULL(ntohll(_nfv_info->dpid)), ntohs(_nfv_info->iif), ntohs(_nfv_info->oif)); } assert(len < SERV_CHAIN_PBUF_SZ - 1); cb_fn(arg, pbuf); free(pbuf); return; }
/** * mul_fabric_show_hosts - * */ void mul_fabric_show_hosts(void *service, bool active, bool dump_cmd, void *arg, void (*cb_fn)(void *arg, char *pbuf)) { struct cbuf *b; struct c_ofp_auxapp_cmd *cofp_auc; struct c_ofp_host_mod *cofp_hm; char *pbuf; b = of_prep_msg(sizeof(struct c_ofp_auxapp_cmd), C_OFPT_AUX_CMD, 0); cofp_auc = (void *)(b->data); cofp_auc->cmd_code = active ? htonl(C_AUX_CMD_FAB_SHOW_ACTIVE_HOSTS): htonl(C_AUX_CMD_FAB_SHOW_INACTIVE_HOSTS); c_service_send(service, b); while (1) { b = c_service_wait_response(service); if (b) { if (check_reply_type(b, C_AUX_CMD_SUCCESS) || !check_reply_type(b, C_AUX_CMD_FAB_HOST_ADD)) { free_cbuf(b); break; } cofp_auc = (void *)(b->data); cofp_hm = (void *)(cofp_auc->data); if (ntohs(cofp_auc->header.length) < sizeof(*cofp_auc) + sizeof(*cofp_hm)) { free_cbuf(b); break; } if (!dump_cmd) { pbuf = fab_dump_single_host_from_flow( ntohll(cofp_hm->switch_id.datapath_id), &cofp_hm->host_flow); } else { pbuf = fab_dump_add_host_cmd_from_flow( ntohll(cofp_hm->switch_id.datapath_id), &cofp_hm->host_flow); } if (pbuf) { cb_fn(arg, pbuf); free(pbuf); } free_cbuf(b); } else { break; } } }
/* * * mul_makdi_show_nfv_stats - return the nfv ingress/egress port statistics * */ void mul_makdi_show_nfv_stats(void *service, char* nfv_name, void *arg, bool nbapi UNUSED, void (*cb_fn)(void *arg, void *pbuf)) { struct cbuf *b; struct c_ofp_auxapp_cmd *cofp_auc; struct c_ofp_nfv_stats_show *cofp_nfv_stats; char *pbuf; if (!service) return; b = of_prep_msg(sizeof(struct c_ofp_auxapp_cmd) + sizeof(struct c_ofp_nfv_stats_show), C_OFPT_AUX_CMD, 0); cofp_auc = (void *) (b->data); cofp_auc->cmd_code = htonl(C_AUX_CMD_MAKDI_NFV_STATS); cofp_nfv_stats = (void *) (cofp_auc->data); strncpy(cofp_nfv_stats->name, nfv_name, MAX_NFV_NAME); c_service_send(service, b); while (1) { b = c_service_wait_response(service); if (b) { if (check_reply_type(b, C_AUX_CMD_SUCCESS) || !check_reply_type(b, C_AUX_CMD_MUL_SWITCH_PORT_QUERY)) { free_cbuf(b); break; } pbuf = mul_dump_port_stats(b, true); if (pbuf) { cb_fn(arg, pbuf); free(pbuf); } free_cbuf(b); } else { break; } } }
/** * mul_makdi_show_service_chain_cmd - * * Dump service chain user information in command format */ static void makdi_dump_service_chain_cmd(struct c_ofp_s_chain_show *sc_info, void *arg, void (*cb_fn)(void *arg, void *pbuf)) { char *pbuf = calloc(1, SERV_CHAIN_PBUF_SZ); struct c_ofp_s_chain_show *_chain_info; struct c_ofp_s_chain_nfv_info *_nfv_info; int nfv_counter = 0; uint8_t len = 0; struct in_addr in; if (!pbuf) return; _chain_info = sc_info; in.s_addr = _chain_info->nw_src; len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, "add makdi-service-chain switch 0x%llx service %s " "host-ip %s", U642ULL(ntohll(_chain_info->dpid)), _chain_info->service, inet_ntoa(in)); while (nfv_counter < 6) { /* Max number allowed by CLI may change */ _nfv_info = &_chain_info->nfv_list.nfv_info[nfv_counter]; len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, " nfv-grp%d %s", nfv_counter+1, nfv_counter < _chain_info->nfv_list.num_nfvs ? _nfv_info->nfv_group : "*"); nfv_counter++; assert(len < SERV_CHAIN_PBUF_SZ - 1); } len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, "\r\n"); assert(len < SERV_CHAIN_PBUF_SZ - 1); cb_fn(arg, pbuf); free(pbuf); return; }
/** * makdi_dump_services_cmd - */ static void makdi_dump_services_cmd(struct c_ofp_service_info *service_info, void *arg, void (*cb_fn)(void *arg, void *pbuf)) { char *pbuf = calloc(1, SERV_CHAIN_PBUF_SZ); struct c_ofp_service_info *_service_info; uint8_t len = 0; if (!pbuf) return; /*Dumping Service list*/ _service_info = service_info; _service_info->service[MAX_NFV_NAME - 1] = '\0'; len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, "add makdi-service %s vlan %hu\r\n", _service_info->service, ntohs(_service_info->vlan)); assert(len < SERV_CHAIN_PBUF_SZ - 1); cb_fn(arg, pbuf); free(pbuf); return; }
int dispc_gralloc_queue(setup_dispc_data_t *psDispcData, int ui32DispcDataLength, void (*cb_fn)(void *, int), void *cb_arg) { __disp_layer_info_t layer_info; int i,disp,hdl; int start_idx, layer_num = 0; __u32 num_screens; num_screens = bsp_disp_feat_get_num_screens(); bsp_disp_cmd_cache(0); bsp_disp_cmd_cache(1); for(disp = 0; disp < num_screens; disp++) { if(disp == 0) { start_idx = 0; layer_num = psDispcData->primary_display_layer_num; } else { start_idx = psDispcData->primary_display_layer_num; layer_num = psDispcData->post2_layers - psDispcData->primary_display_layer_num; } for(i=0; i<4; i++) { hdl = 100 + i; bsp_disp_layer_get_para(disp, hdl, &layer_info); if(layer_info.mode == DISP_LAYER_WORK_MODE_SCALER) { if((i >= layer_num) || (psDispcData->layer_info[start_idx + i].mode == DISP_LAYER_WORK_MODE_NORMAL)) { bsp_disp_layer_release(disp, hdl); bsp_disp_layer_request(disp, DISP_LAYER_WORK_MODE_NORMAL); } } } } for(disp = 0; disp < num_screens; disp++) { int haveFbTarget = 0; if(disp == 0) { start_idx = 0; layer_num = psDispcData->primary_display_layer_num; } else { start_idx = psDispcData->primary_display_layer_num; layer_num = psDispcData->post2_layers - psDispcData->primary_display_layer_num; } for(i=0; i<4; i++) { hdl = 100 + i; if(i < layer_num) { memcpy(&layer_info, &psDispcData->layer_info[start_idx + i], sizeof(__disp_layer_info_t)); if(layer_info.fb.mode == DISP_MOD_NON_MB_PLANAR) { if(layer_info.fb.format == DISP_FORMAT_YUV420) { layer_info.fb.addr[2] = layer_info.fb.addr[0] + layer_info.fb.size.width * layer_info.fb.size.height; layer_info.fb.addr[1] = layer_info.fb.addr[2] + (layer_info.fb.size.width * layer_info.fb.size.height)/4; } } bsp_disp_layer_set_para(disp, hdl, &layer_info); bsp_disp_layer_open(disp, hdl); bsp_disp_layer_set_top(disp, hdl); if(i==1 && (psDispcData->layer_info[start_idx + 1].prio < psDispcData->layer_info[start_idx].prio)) { haveFbTarget = 1; } } else { bsp_disp_layer_close(disp, hdl); } if(haveFbTarget) { bsp_disp_layer_set_top(disp, 100); } } } bsp_disp_cmd_submit(0); bsp_disp_cmd_submit(1); mutex_lock(&g_fbi.runtime_lock); if(g_fbi.b_no_output) { cb_fn(cb_arg, 1); } else { g_fbi.cb_fn = cb_fn; if(g_fbi.cb_w_conut >= 9) { g_fbi.cb_w_conut = 0; } else { g_fbi.cb_w_conut++; } g_fbi.cb_arg[g_fbi.cb_w_conut] = cb_arg; //printk(KERN_WARNING "##w_conut:%d %x %d\n", g_fbi.cb_w_conut, (unsigned int)cb_arg, psDispcData->post2_layers); } /* have external display */ if(psDispcData->post2_layers > psDispcData->primary_display_layer_num) { g_fbi.reg_active[0] = 0; g_fbi.reg_active[1] = 0; } else { g_fbi.reg_active[0] = 0; g_fbi.reg_active[1] = 1; } mutex_unlock(&g_fbi.runtime_lock); return 0; }
/* * * mul_makdi_show_nfv_stats_all - return the every nfv ingress/egress port statistics * */ void mul_makdi_show_nfv_stats_all(void *service, void *arg, bool nbapi, void (*cb_fn)(void *arg, void *pbuf)) { struct cbuf *b; struct c_ofp_auxapp_cmd *cofp_auc; struct c_ofp_switch_port_query *cofp_pq; int n_nfvs = 0; struct cbuf_head bufs; int retries = 0; char *pbuf; if (!service) return; cbuf_list_head_init(&bufs); try_again: b = of_prep_msg(sizeof(struct c_ofp_auxapp_cmd), C_OFPT_AUX_CMD, 0); cofp_auc = (void *) (b->data); cofp_auc->cmd_code = htonl(C_AUX_CMD_MAKDI_NFV_STATS_ALL); c_service_send(service, b); while (1) { b = c_service_wait_response(service); if (b) { if (check_reply_type(b, C_AUX_CMD_SUCCESS) || !check_reply_type(b, C_AUX_CMD_MUL_SWITCH_PORT_QUERY)) { free_cbuf(b); break; } cofp_auc = (void *) (b->data); cofp_pq = (void *) (cofp_auc->data); if (ntohs(cofp_auc->header.length) < sizeof(*cofp_pq) + sizeof(*cofp_auc)) { free_cbuf(b); goto try_restart; } b = cbuf_realloc_headroom(b, 0, true); cbuf_list_queue_tail(&bufs, b); n_nfvs++; } else { goto try_restart; } } while ((b = cbuf_list_dequeue(&bufs))) { cofp_auc = (void *) (b->data); cofp_pq = (void *) (cofp_auc->data); if (nbapi) { cb_fn(arg, cofp_pq); } else { pbuf = makdi_dump_port_stats(cofp_auc, cofp_pq); if (pbuf) { cb_fn(arg, pbuf); free(pbuf); } free_cbuf(b); } } return; try_restart: cbuf_list_purge(&bufs); if (retries++ >= C_SERV_RETRY_CNT) { cbuf_list_purge(&bufs); c_log_err("%s: Restarting serv msg", FN); goto try_again; } c_log_err("%s: Can't restart serv msg", FN); return; }
/** * mul_makdi_show_nfv - */ int mul_makdi_show_servicechain_default(void *service, void *arg, bool nbapi, void (*cb_fn)(void *arg, void *pbuf)) { struct cbuf *b; struct c_ofp_auxapp_cmd *cofp_auc; struct c_ofp_default_rule_info *cofp_servicechain_default; char *pbuf; int n_services = 0; struct cbuf_head bufs; int retries = 0; if (!service) return -1; cbuf_list_head_init(&bufs); try_again: b = of_prep_msg(sizeof(struct c_ofp_auxapp_cmd), C_OFPT_AUX_CMD, 0); cofp_auc = (void *) (b->data); cofp_auc->cmd_code = htonl(C_AUX_CMD_MAKDI_SHOW_DEFAULT_SERVICE); c_service_send(service, b); while (1) { b = c_service_wait_response(service); if (b) { if (check_reply_type(b, C_AUX_CMD_SUCCESS) || !check_reply_type(b, C_AUX_CMD_MAKDI_SHOW_DEFAULT_SERVICE)) { free_cbuf(b); break; } cofp_auc = (void *) (b->data); cofp_servicechain_default = (void *) (cofp_auc->data); /* FIXME : Length missmtach, header.length == 2050 if (ntohs(cofp_nfv_group->header.length) < sizeof(*cofp_nfv_group)) { free_cbuf(b); goto try_restart; } */ b = cbuf_realloc_headroom(b, 0, true); cbuf_list_queue_tail(&bufs, b); n_services++; } else { goto try_restart; } } while ((b = cbuf_list_dequeue(&bufs))) { cofp_auc = (void *) (b->data); cofp_servicechain_default = (void *)(cofp_auc->data); if (nbapi) { cb_fn(arg, cofp_servicechain_default); } else { pbuf = makdi_dump_servicechain_default( cofp_servicechain_default); if (pbuf) { cb_fn(arg, pbuf); free(pbuf); } free_cbuf(b); } } return n_services; try_restart: cbuf_list_purge(&bufs); if (retries++ >= C_SERV_RETRY_CNT) { cbuf_list_purge(&bufs); c_log_err("%s: Restarting serv msg", FN); goto try_again; } c_log_err("%s: Can't restart serv msg", FN); return 0; }
/** * mul_makdi_show_nfv - */ int mul_makdi_show_nfv(void *service, void *arg, bool dump_cmd, void (*cb_fn)(void *arg, void *pbuf)) { struct cbuf *b; struct c_ofp_auxapp_cmd *cofp_auc; struct c_ofp_s_chain_nfv_group_info *cofp_nfv_group; char *pbuf; int n_groups = 0; struct cbuf_head bufs; int retries = 0; if (!service) return -1; cbuf_list_head_init(&bufs); try_again: b = of_prep_msg(sizeof(struct c_ofp_auxapp_cmd), C_OFPT_AUX_CMD, 0); cofp_auc = (void *) (b->data); cofp_auc->cmd_code = htonl(C_AUX_CMD_MAKDI_SHOW_NFV); c_service_send(service, b); while (1) { b = c_service_wait_response(service); if (b) { if (check_reply_type(b, C_AUX_CMD_SUCCESS) || !check_reply_type(b, C_AUX_CMD_MAKDI_SHOW_NFV_GROUP)) { free_cbuf(b); break; } cofp_auc = (void *) (b->data); cofp_nfv_group = (void *) (cofp_auc->data); if (ntohs(cofp_auc->header.length) < sizeof(*cofp_nfv_group) + sizeof(*cofp_auc)) { free_cbuf(b); goto try_restart; } b = cbuf_realloc_headroom(b, 0, true); cbuf_list_queue_tail(&bufs, b); n_groups++; } else { goto try_restart; break; } } while ((b = cbuf_list_dequeue(&bufs))) { cofp_auc = (void *) (b->data); cofp_nfv_group = (void *)(cofp_auc->data); if (dump_cmd) { makdi_dump_nfv_groups_cmd(cofp_nfv_group, arg, cb_fn); } else { pbuf = makdi_dump_nfv_groups(cofp_nfv_group); if (pbuf) { cb_fn(arg, pbuf); free(pbuf); } } free_cbuf(b); } return n_groups; try_restart: cbuf_list_purge(&bufs); if (retries++ < C_SERV_RETRY_CNT) { cbuf_list_purge(&bufs); c_log_err("%s: Restarting serv msg", FN); goto try_again; } c_log_err("%s: Can't restart serv msg", FN); return 0; }
/* * mul_makdi_show_user_stats_all - * * Return the every user statistics on service chain domain * */ int mul_makdi_show_user_stats_all(void *service, void *arg, bool nbapi, void (*cb_fn)(void *arg, void *pbuf)) { struct cbuf *b; struct c_ofp_auxapp_cmd *cofp_auc; struct c_ofp_user_stats_show *cofp_user_stats; struct cbuf_head bufs; int retries = 0; int n_chains = 0; if (!service) return n_chains; cbuf_list_head_init(&bufs); try_again: b = of_prep_msg(sizeof(struct c_ofp_auxapp_cmd), C_OFPT_AUX_CMD, 0); cofp_auc = (void *) (b->data); cofp_auc->cmd_code = htonl(C_AUX_CMD_MAKDI_USER_STATS_ALL); c_service_send(service, b); while (1) { b = c_service_wait_response(service); if (b) { if (check_reply_type(b, C_AUX_CMD_SUCCESS) || !check_reply_type(b, C_AUX_CMD_MAKDI_USER_STATS_ALL)) { free_cbuf(b); break; } cofp_auc = (void *) (b->data); cofp_user_stats = (void *) (cofp_auc->data); n_chains++; if (nbapi) { cb_fn(arg, &cofp_user_stats->stats); } else { char *pbuf = calloc(1, SERV_CHAIN_PBUF_SZ); uint8_t len = 0; len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, "User Flow : %sPacket_Count(%llu) : Byte_Count(%llu) : Bps(%s) : PPS(%s) \r\n", of_dump_flow(&cofp_user_stats->stats.flow, 0), U642ULL(ntohll(cofp_user_stats->stats.packet_count)), U642ULL(ntohll(cofp_user_stats->stats.byte_count)), cofp_user_stats->stats.bps, cofp_user_stats->stats.pps); cb_fn(arg, pbuf); free_cbuf(b); free(pbuf); } } else { goto try_restart; } } return n_chains; try_restart: cbuf_list_purge(&bufs); if (retries++ >= C_SERV_RETRY_CNT) { cbuf_list_purge(&bufs); c_log_err("%s: Restarting serv msg", FN); goto try_again; } c_log_err("%s: Can't restart serv msg", FN); return -1; }
/* * mul_makdi_show_service_stats_all - * * Return every service ingress/egress port statistics * */ int mul_makdi_show_service_stats_all(void *service, void *arg, bool nbapi, void (*cb_fn)(void *arg, void *pbuf)) { struct cbuf *b; struct c_ofp_auxapp_cmd *cofp_auc; struct c_ofp_service_stats_show *cofp_services; struct cbuf_head bufs; int retries = 0; int n_chains = 0; if (!service) return n_chains; cbuf_list_head_init(&bufs); try_again: b = of_prep_msg(sizeof(struct c_ofp_auxapp_cmd), C_OFPT_AUX_CMD, 0); cofp_auc = (void *) (b->data); cofp_auc->cmd_code = htonl(C_AUX_CMD_MAKDI_SERVICE_STATS_ALL); c_service_send(service, b); while (1) { b = c_service_wait_response(service); if (b) { if (check_reply_type(b, C_AUX_CMD_SUCCESS) || !check_reply_type(b, C_AUX_CMD_MAKDI_SERVICE_STATS_ALL)) { free_cbuf(b); break; } cofp_auc = (void *) (b->data); cofp_services = (void *) (cofp_auc->data); if (ntohs(cofp_auc->header.length) < sizeof(*cofp_services) + sizeof(*cofp_auc)) { free_cbuf(b); goto try_restart; } n_chains++; if (nbapi) { cb_fn(arg, &cofp_services->stats); } else { char *pbuf = calloc(1, SERV_CHAIN_PBUF_SZ); uint8_t len = 0; len += snprintf(pbuf + len, SERV_CHAIN_PBUF_SZ - len - 1, "Service(%s) : User IP(0x%04x) : dpid(0x%016llx) :" " vlan(%hu) : Packet_Count(%llu) : Byte_Count(%llu)" " : Bps(%s) : PPS(%s) : Inport(%hu) \r\n", cofp_services->service_name, ntohl(cofp_services->stats.flow.ip.nw_src & 0xffffffff), U642ULL(ntohll(cofp_services->stats.datapath_id)), ntohs(cofp_services->stats.flow.dl_vlan), U642ULL(ntohll(cofp_services->stats.packet_count)), U642ULL(ntohll(cofp_services->stats.byte_count)), cofp_services->stats.bps, cofp_services->stats.pps, ntohl(cofp_services->stats.flow.in_port)); cb_fn(arg, pbuf); free_cbuf(b); free(pbuf); } } else { goto try_restart; } } return n_chains; try_restart: cbuf_list_purge(&bufs); if (retries++ >= C_SERV_RETRY_CNT) { cbuf_list_purge(&bufs); c_log_err("%s: Restarting serv msg", FN); goto try_again; } c_log_err("%s: Can't restart serv msg", FN); return 0; }
void LearnEngine::LearnList::buffer_transmit() { milliseconds time_to_sleep; size_t num_samples_to_send; std::unique_lock<std::mutex> lock(mutex); clock::time_point now = clock::now(); while(!stop_transmit_thread && buffer_tmp.size() == 0 && (!with_timeout || num_samples == 0 || now < (buffer_started + timeout))) { if(with_timeout && num_samples > 0) { b_can_send.wait_until(lock, buffer_started + timeout); } else { b_can_send.wait(lock); } now = clock::now(); } if(stop_transmit_thread) return; if(buffer_tmp.size() == 0) { // timeout -> we need to swap here num_samples_to_send = num_samples; swap_buffers(); } else { // buffer full -> swapping was already done num_samples_to_send = max_samples; } last_sent = now; writer_busy = true; lock.unlock(); msg_hdr_t msg_hdr = {0, list_id, buffer_id - 1, (unsigned int) num_samples_to_send}; if(learn_mode == LearnMode::WRITER) { // do not forget the -1 !!! // swap_buffers() is in charge of incrementing the count TransportIface::MsgBuf buf_hdr = {(char *) &msg_hdr, sizeof(msg_hdr)}; TransportIface::MsgBuf buf_samples = {buffer_tmp.data(), (unsigned int) buffer_tmp.size()}; writer->send_msgs({buf_hdr, buf_samples}); // no lock for I/O } else if(learn_mode == LearnMode::CB) { std::unique_ptr<char []> buf(new char[buffer_tmp.size()]); std::copy(buffer_tmp.begin(), buffer_tmp.end(), &buf[0]); cb_fn(msg_hdr, buffer_tmp.size(), std::move(buf), cb_cookie); } else { assert(learn_mode == LearnMode::NONE); } lock.lock(); writer_busy = false; can_change_writer.notify_all(); buffer_tmp.clear(); b_can_swap.notify_one(); }