//--------------------------------------------------------------------------- void nas_teardown(struct net_device *dev){ //--------------------------------------------------------------------------- int cxi; struct nas_priv *priv; int inst; if (dev) { priv = netdev_priv(dev); inst = find_inst(dev); if (inst<0) { printk("nas_teardown: ERROR, couldn't find instance\n"); } printk("nas_teardown instance %d: begin\n",inst); nas_CLASS_flush_rclassifier(priv); for (cxi=0;cxi<NAS_CX_MAX;cxi++) { nas_COMMON_flush_rb(priv->cx+cxi); nas_CLASS_flush_sclassifier(priv->cx+cxi); } printk("nas_teardown: end\n"); } // check dev else { printk("nas_teardown: Device is null\n"); } }
//--------------------------------------------------------------------------- // int nas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev){ //--------------------------------------------------------------------------- // Start debug information int inst; if (dev) inst = find_inst(dev); else { printk("nas_hard_start_xmit: ERROR, device is null\n"); return -1; } if (inst>=0) { #ifdef DEBUG_DEVICE printk("HARD_START_XMIT: inst %d, begin\n",inst); #endif if (!skb){ printk("HARD_START_XMIT - input parameter skb is NULL \n"); return -1; } // End debug information netif_stop_queue(dev); dev->trans_start = jiffies; #ifdef DEBUG_DEVICE printk("HARD_START_XMIT: step 1\n"); #endif nas_CLASS_send(skb,inst); #ifdef DEBUG_DEVICE printk("HARD_START_XMIT: step 2\n"); #endif // if (skb==NULL){ // printk("HARD_START_XMIT - parameter skb is NULL \n"); // return -1; // }else dev_kfree_skb(skb); #ifdef DEBUG_DEVICE printk("HARD_START_XMIT: step 3\n"); #endif netif_wake_queue(dev); #ifdef DEBUG_DEVICE printk("HARD_START_XMIT: end\n"); #endif } else { printk("nas_hard_start_xmit: ERROR, couldn't find instnace\n"); return(-1); } return 0; }
extern void sf_combine (struct sf *out, struct sf *in) { uint64_t type; uint64_t ntypes = sf_getSysCount(out); struct elan_sysInstanceE *instIn, *instOut; int id; for ( type = 0 ; type < ntypes ; type++ ) { id = 0; instIn = sf_dataGetInst(in,type,id); while ( instIn ) { instOut = find_inst(out,instIn); if ( instOut && ( instOut->stats != 0 ) && (instIn->stats!=0) ) merge_all(out, type, &out->database[instOut->stats], &in->database[instIn->stats]); id++; instIn = sf_dataGetInst(in,type,id); } } }
//--------------------------------------------------------------------------- // Initialisation of the network device void nas_init(struct net_device *dev){ //--------------------------------------------------------------------------- u8 cxi, dscpi; struct nas_priv *priv; // int inst; if (dev) { priv = netdev_priv(dev); //memset(dev->priv, 0, sizeof(struct nas_priv)); memset(priv, 0, sizeof(struct nas_priv)); // priv=(struct nas_priv *)(dev->priv); priv=netdev_priv(dev); // #ifdef KERNEL_VERSION_GREATER_THAN_2629 dev->netdev_ops = &nasmesh_netdev_ops; #else dev->open = nas_open; dev->stop = nas_stop; dev->set_config = nas_set_config; dev->hard_start_xmit = nas_hard_start_xmit; dev->do_ioctl = nas_CTL_ioctl; dev->get_stats = nas_get_stats; // dev->rebuild_header = NULL; // dev->hard_header = NULL; dev->change_mtu = nas_change_mtu; // dev->hard_header_cache = NULL; // dev->header_cache_update = NULL; dev->tx_timeout = nas_tx_timeout; // #endif // dev->type = ARPHRD_EUROPENAIRMESH; //dev->type = ARPHRD_ETHER; // dev->features = NETIF_F_NO_CSUM; dev->hard_header_len = 0; dev->addr_len = NAS_ADDR_LEN; dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP; dev->tx_queue_len = NAS_TX_QUEUE_LEN; dev->mtu = NAS_MTU; // // Initialize private structure // priv->sap[NAS_GC_SAPI] = RRC_DEVICE_GC; // priv->sap[NAS_NT_SAPI] = RRC_DEVICE_NT; priv->sap[NAS_RAB_INPUT_SAPI] = PDCP2NAS_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT; priv->sap[NAS_RAB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT; // priv->retry_limit=RETRY_LIMIT_DEFAULT; // priv->timer_establishment=TIMER_ESTABLISHMENT_DEFAULT; // priv->timer_release=TIMER_RELEASE_DEFAULT; for (dscpi=0; dscpi<65; ++dscpi) priv->rclassifier[dscpi]=NULL; priv->nrclassifier=0; // for (cxi=0;cxi<NAS_CX_MAX;cxi++) { #ifdef DEBUG_DEVICE printk("INIT: init classifiers, state and timer for MT %u\n", cxi); #endif // priv->cx[cxi].sap[NAS_DC_INPUT_SAPI] = RRC_DEVICE_DC_INPUT0; // priv->cx[cxi].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT0; priv->cx[cxi].state=NAS_IDLE; priv->cx[cxi].countimer=NAS_TIMER_IDLE; priv->cx[cxi].retry=0; priv->cx[cxi].lcr=cxi; priv->cx[cxi].rb=NULL; priv->cx[cxi].num_rb=0; // initialisation of the classifier for (dscpi=0; dscpi<65; ++dscpi) { priv->cx[cxi].sclassifier[dscpi]=NULL; priv->cx[cxi].fclassifier[dscpi]=NULL; } priv->cx[cxi].nsclassifier=0; priv->cx[cxi].nfclassifier=0; // initialisation of the IP address // TOOL_imei2iid(IMEI, (u8 *)priv->cx[cxi].iid6); priv->cx[cxi].iid4=0; // } spin_lock_init(&priv->lock); //this requires kernel patch for OAI driver: typically for RF/hard realtime emu experimentation #ifdef ADDRCONF #ifdef NETLINK nas_TOOL_imei2iid(IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address) nas_TOOL_imei2iid(IMEI, (u8 *)priv->cx[0].iid6); #else nas_TOOL_imei2iid(nas_IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address) nas_TOOL_imei2iid(nas_IMEI, (u8 *)priv->cx[0].iid6); #endif // this is more appropriate for user space soft realtime emulation #else memcpy(dev->dev_addr,&nas_IMEI[0],8); printk("Setting HW addr to : %X%X\n",*((unsigned int *)&dev->dev_addr[0]),*((unsigned int *)&dev->dev_addr[4])); ((unsigned char*)dev->dev_addr)[7] = (unsigned char)find_inst(dev); memcpy((u8 *)priv->cx[0].iid6,&nas_IMEI[0],8); printk("INIT: init IMEI to IID\n"); #endif printk("INIT: end\n"); return; } // instance value check else { printk("nas_init(): ERROR, Device is NULL!!\n"); return; } }
int main(int argc, char **argv) { init_scas_runtime(); parse_arguments(argc, argv); init_log(scas_runtime.verbosity); validate_scas_runtime(); instruction_set_t *instruction_set = find_inst(); scas_log(L_INFO, "Loaded instruction set: %s", instruction_set->arch); list_t *include_path = split_include_path(); list_t *errors = create_list(); list_t *warnings = create_list(); list_t *objects = create_list(); int i; for (i = 0; i < scas_runtime.input_files->length; ++i) { scas_log(L_INFO, "Assembling input file: '%s'", scas_runtime.input_files->items[i]); indent_log(); FILE *f; if (strcasecmp(scas_runtime.input_files->items[i], "-") == 0) { f = stdin; } else { f = fopen(scas_runtime.input_files->items[i], "r"); } if (!f) { scas_abort("Unable to open '%s' for assembly.", scas_runtime.input_files->items[i]); } char magic[7]; bool is_object = false; if (fread(magic, sizeof(char), 7, f) == 7) { if (strncmp("SCASOBJ", magic, 7) == 0) { is_object = true; } } fseek(f, 0L, SEEK_SET); object_t *o; if (is_object) { scas_log(L_INFO, "Loading object file '%s'", scas_runtime.input_files->items[i]); o = freadobj(f, scas_runtime.input_files->items[i]); } else { assembler_settings_t settings = { .include_path = include_path, .set = instruction_set, .errors = errors, .warnings = warnings, .macros = scas_runtime.macros, }; o = assemble(f, scas_runtime.input_files->items[i], &settings); fclose(f); scas_log(L_INFO, "Assembler returned %d errors, %d warnings for '%s'", errors->length, warnings->length, scas_runtime.input_files->items[i]); } list_add(objects, o); deindent_log(); } scas_log(L_DEBUG, "Opening output file for writing: %s", scas_runtime.output_file); FILE *out; if (strcasecmp(scas_runtime.output_file, "-") == 0) { out = stdout; } else { out = fopen(scas_runtime.output_file, "w+"); } if (!out) { scas_abort("Unable to open '%s' for output.", scas_runtime.output_file); } if ((scas_runtime.jobs & LINK) == LINK) { scas_log(L_INFO, "Passing objects to linker"); linker_settings_t settings = { .automatic_relocation = scas_runtime.options.auto_relocation, .merge_only = (scas_runtime.jobs & MERGE) == MERGE, .errors = errors, .warnings = warnings, .write_output = scas_runtime.options.output_format }; if (settings.merge_only) { object_t *merged = merge_objects(objects); fwriteobj(out, merged); } else { link_objects(out, objects, &settings); } scas_log(L_INFO, "Linker returned %d errors, %d warnings", errors->length, warnings->length); } else { scas_log(L_INFO, "Skipping linking - writing to object file"); object_t *merged = merge_objects(objects); fwriteobj(out, merged); fflush(out); fclose(out); } if (errors->length != 0) { int i; for (i = 0; i < errors->length; ++i) { error_t *error = errors->items[i]; fprintf(stderr, "%s:%d:%d: error #%d: %s\n", error->file_name, (int)error->line_number, (int)error->column, error->code, error->message); fprintf(stderr, "%s\n", error->line); if (error->column != 0) { int j; for (j = error->column; j > 0; --j) { fprintf(stderr, "."); } fprintf(stderr, "^\n"); } else { fprintf(stderr, "\n"); } } remove(scas_runtime.output_file); } if (warnings->length != 0) { int i; for (i = 0; i < errors->length; ++i) { warning_t *warning = warnings->items[i]; fprintf(stderr, "%s:%d:%d: warning #%d: %s\n", warning->file_name, (int)warning->line_number, (int)warning->column, warning->code, get_warning_string(warning)); fprintf(stderr, "%s\n", warning->line); if (warning->column != 0) { int j; for (j = warning->column; j > 0; --j) { fprintf(stderr, "."); } fprintf(stderr, "^\n"); } } } int ret = errors->length; scas_log(L_DEBUG, "Exiting with status code %d, cleaning up", ret); list_free(scas_runtime.input_files); free_flat_list(include_path); list_free(objects); list_free(errors); list_free(warnings); instruction_set_free(instruction_set); return ret; }