ixl_iw.c (1a36faad54665288ed4eb839d2a4699ae2ead45e) | ixl_iw.c (ceebc2f348c028b21bf9bcc99f7a3c4b0cb7d926) |
---|---|
1/****************************************************************************** 2 | 1/****************************************************************************** 2 |
3 Copyright (c) 2013-2015, Intel Corporation | 3 Copyright (c) 2013-2017, Intel Corporation |
4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 357 unchanged lines hidden (view full) --- 369 return (0); 370} 371 372int 373ixl_iw_register(struct ixl_iw_ops *ops) 374{ 375 struct ixl_iw_pf_entry *pf_entry; 376 int err = 0; | 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 357 unchanged lines hidden (view full) --- 369 return (0); 370} 371 372int 373ixl_iw_register(struct ixl_iw_ops *ops) 374{ 375 struct ixl_iw_pf_entry *pf_entry; 376 int err = 0; |
377 int iwarp_cap_on_pfs = 0; |
|
377 378 INIT_DEBUGOUT("begin"); | 378 379 INIT_DEBUGOUT("begin"); |
379 | 380 LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) 381 iwarp_cap_on_pfs += pf_entry->pf->hw.func_caps.iwarp; 382 if (!iwarp_cap_on_pfs && ixl_enable_iwarp) { 383 printf("%s: the device is not iwarp-capable, registering dropped\n", 384 __func__); 385 return (ENODEV); 386 } |
380 if (ixl_enable_iwarp == 0) { 381 printf("%s: enable_iwarp is off, registering dropped\n", 382 __func__); 383 return (EACCES); 384 } 385 386 if ((ops->init == NULL) || (ops->stop == NULL)) { 387 printf("%s: invalid iwarp driver ops\n", __func__); 388 return (EINVAL); 389 } 390 391 mtx_lock(&ixl_iw.mtx); | 387 if (ixl_enable_iwarp == 0) { 388 printf("%s: enable_iwarp is off, registering dropped\n", 389 __func__); 390 return (EACCES); 391 } 392 393 if ((ops->init == NULL) || (ops->stop == NULL)) { 394 printf("%s: invalid iwarp driver ops\n", __func__); 395 return (EINVAL); 396 } 397 398 mtx_lock(&ixl_iw.mtx); |
392 | |
393 if (ixl_iw.registered) { 394 printf("%s: iwarp driver already registered\n", __func__); | 399 if (ixl_iw.registered) { 400 printf("%s: iwarp driver already registered\n", __func__); |
395 err = EBUSY; | 401 err = (EBUSY); |
396 goto out; 397 } | 402 goto out; 403 } |
404 ixl_iw.registered = true; 405 mtx_unlock(&ixl_iw.mtx); |
|
398 399 ixl_iw.tq = taskqueue_create("ixl_iw", M_NOWAIT, 400 taskqueue_thread_enqueue, &ixl_iw.tq); 401 if (ixl_iw.tq == NULL) { 402 printf("%s: failed to create queue\n", __func__); | 406 407 ixl_iw.tq = taskqueue_create("ixl_iw", M_NOWAIT, 408 taskqueue_thread_enqueue, &ixl_iw.tq); 409 if (ixl_iw.tq == NULL) { 410 printf("%s: failed to create queue\n", __func__); |
403 err = ENOMEM; 404 goto out; | 411 ixl_iw.registered = false; 412 return (ENOMEM); |
405 } 406 taskqueue_start_threads(&ixl_iw.tq, 1, PI_NET, "ixl iw"); 407 408 ixl_iw.ops = malloc(sizeof(struct ixl_iw_ops), 409 M_DEVBUF, M_NOWAIT | M_ZERO); 410 if (ixl_iw.ops == NULL) { 411 printf("%s: failed to allocate memory\n", __func__); 412 taskqueue_free(ixl_iw.tq); | 413 } 414 taskqueue_start_threads(&ixl_iw.tq, 1, PI_NET, "ixl iw"); 415 416 ixl_iw.ops = malloc(sizeof(struct ixl_iw_ops), 417 M_DEVBUF, M_NOWAIT | M_ZERO); 418 if (ixl_iw.ops == NULL) { 419 printf("%s: failed to allocate memory\n", __func__); 420 taskqueue_free(ixl_iw.tq); |
413 err = ENOMEM; 414 goto out; | 421 ixl_iw.registered = false; 422 return (ENOMEM); |
415 } 416 417 ixl_iw.ops->init = ops->init; 418 ixl_iw.ops->stop = ops->stop; | 423 } 424 425 ixl_iw.ops->init = ops->init; 426 ixl_iw.ops->stop = ops->stop; |
419 ixl_iw.registered = true; | |
420 | 427 |
428 mtx_lock(&ixl_iw.mtx); |
|
421 LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) 422 if (pf_entry->state.pf == IXL_IW_PF_STATE_ON) { 423 pf_entry->state.iw_scheduled = IXL_IW_PF_STATE_ON; 424 taskqueue_enqueue(ixl_iw.tq, &pf_entry->iw_task); 425 } | 429 LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) 430 if (pf_entry->state.pf == IXL_IW_PF_STATE_ON) { 431 pf_entry->state.iw_scheduled = IXL_IW_PF_STATE_ON; 432 taskqueue_enqueue(ixl_iw.tq, &pf_entry->iw_task); 433 } |
426 | |
427out: 428 mtx_unlock(&ixl_iw.mtx); 429 430 return (err); 431} 432 433int 434ixl_iw_unregister(void) 435{ 436 struct ixl_iw_pf_entry *pf_entry; | 434out: 435 mtx_unlock(&ixl_iw.mtx); 436 437 return (err); 438} 439 440int 441ixl_iw_unregister(void) 442{ 443 struct ixl_iw_pf_entry *pf_entry; |
444 int iwarp_cap_on_pfs = 0; |
|
437 438 INIT_DEBUGOUT("begin"); 439 | 445 446 INIT_DEBUGOUT("begin"); 447 |
448 LIST_FOREACH(pf_entry, &ixl_iw.pfs, node) 449 iwarp_cap_on_pfs += pf_entry->pf->hw.func_caps.iwarp; 450 if (!iwarp_cap_on_pfs && ixl_enable_iwarp) { 451 printf("%s: attempt to unregister driver when no iwarp-capable device present\n", 452 __func__); 453 return (ENODEV); 454 } 455 456 if (ixl_enable_iwarp == 0) { 457 printf("%s: attempt to unregister driver when enable_iwarp is off\n", 458 __func__); 459 return (ENODEV); 460 } |
|
440 mtx_lock(&ixl_iw.mtx); 441 442 if (!ixl_iw.registered) { 443 printf("%s: failed - iwarp driver has not been registered\n", 444 __func__); 445 mtx_unlock(&ixl_iw.mtx); 446 return (ENOENT); 447 } --- 22 unchanged lines hidden --- | 461 mtx_lock(&ixl_iw.mtx); 462 463 if (!ixl_iw.registered) { 464 printf("%s: failed - iwarp driver has not been registered\n", 465 __func__); 466 mtx_unlock(&ixl_iw.mtx); 467 return (ENOENT); 468 } --- 22 unchanged lines hidden --- |