@@ -202,6 +202,8 @@ static void PinToFirstCpu(const cpu_set_t* cpus)
202202 }
203203}
204204
205+ int lkl_debug ;
206+
205207void __attribute__((constructor (102 )))
206208hijack_init (void )
207209{
@@ -234,11 +236,17 @@ hijack_init(void)
234236 char * single_cpu = getenv ("LKL_HIJACK_SINGLE_CPU" );
235237 int single_cpu_mode = 0 ;
236238 cpu_set_t ori_cpu ;
239+ char * offload1 = getenv ("LKL_HIJACK_OFFLOAD" );
240+ int offload = 0 ;
237241
238- if (!debug )
242+ if (!debug ) {
239243 lkl_host_ops .print = NULL ;
240- else
244+ } else {
241245 lkl_register_dbg_handler ();
246+ lkl_debug = strtol (debug , NULL , 0 );
247+ }
248+ if (offload1 )
249+ offload = strtol (offload1 , NULL , 0 );
242250
243251 if (single_cpu ) {
244252 single_cpu_mode = atoi (single_cpu );
@@ -274,18 +282,28 @@ hijack_init(void)
274282 "WARN: variable LKL_HIJACK_NET_TAP is now obsoleted.\n"
275283 " please use LKL_HIJACK_NET_IFTYPE and "
276284 "LKL_HIJACK_NET_IFPARAMS instead.\n" );
277- nd = lkl_netdev_tap_create (tap );
285+ nd = lkl_netdev_tap_create (tap , offload );
278286 }
279287
280288 if (!nd && iftype && ifparams ) {
281- if ((strcmp (iftype , "tap" ) == 0 ))
282- nd = lkl_netdev_tap_create (ifparams );
283- else if (strcmp (iftype , "dpdk" ) == 0 )
284- nd = lkl_netdev_dpdk_create (ifparams );
285- else if (strcmp (iftype , "vde" ) == 0 )
286- nd = lkl_netdev_vde_create (ifparams );
287- else if (strcmp (iftype , "raw" ) == 0 )
288- nd = lkl_netdev_raw_create (ifparams );
289+ if ((strcmp (iftype , "tap" ) == 0 )) {
290+ nd = lkl_netdev_tap_create (ifparams , offload );
291+ } else {
292+ if (offload ) {
293+ fprintf (stderr ,
294+ "WARN: LKL_HIJACK_OFFLOAD is only "
295+ "supported on tap device (for now)!\n"
296+ "No offload features will be "
297+ "enabled.\n" );
298+ }
299+ offload = 0 ;
300+ if (strcmp (iftype , "dpdk" ) == 0 )
301+ nd = lkl_netdev_dpdk_create (ifparams );
302+ else if (strcmp (iftype , "vde" ) == 0 )
303+ nd = lkl_netdev_vde_create (ifparams );
304+ else if (strcmp (iftype , "raw" ) == 0 )
305+ nd = lkl_netdev_raw_create (ifparams );
306+ }
289307 }
290308
291309 if (nd ) {
@@ -295,9 +313,9 @@ hijack_init(void)
295313 fprintf (stderr , "failed to parse mac\n" );
296314 return ;
297315 } else if (ret > 0 ) {
298- ret = lkl_netdev_add (nd , mac );
316+ ret = lkl_netdev_add (nd , mac , offload );
299317 } else {
300- ret = lkl_netdev_add (nd , NULL );
318+ ret = lkl_netdev_add (nd , NULL , offload );
301319 }
302320
303321 if (ret < 0 ) {
@@ -388,6 +406,13 @@ hijack_fini(void)
388406 int i ;
389407 char * dump = getenv ("LKL_HIJACK_DUMP" );
390408
409+ /* The following pauses the kernel before exiting allowing one
410+ * to debug or collect stattistics/diagnosis info from it.
411+ */
412+ if (lkl_debug & 0x100 ) {
413+ while (1 )
414+ pause ();
415+ }
391416 if (dump )
392417 mount_cmds_exec (dump , dump_file );
393418
0 commit comments