t4_tom.c (241394) | t4_tom.c (245274) |
---|---|
1/*- 2 * Copyright (c) 2012 Chelsio Communications, Inc. 3 * All rights reserved. 4 * Written by: Navdeep Parhar <np@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2012 Chelsio Communications, Inc. 3 * All rights reserved. 4 * Written by: Navdeep Parhar <np@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/cxgbe/tom/t4_tom.c 241394 2012-10-10 08:36:38Z kevlo $"); | 29__FBSDID("$FreeBSD: head/sys/dev/cxgbe/tom/t4_tom.c 245274 2013-01-10 23:56:50Z np $"); |
30 31#include "opt_inet.h" 32 33#include <sys/param.h> 34#include <sys/types.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/ktr.h> --- 559 unchanged lines hidden (view full) --- 597 */ 598static int 599t4_tom_activate(struct adapter *sc) 600{ 601 struct tom_data *td; 602 struct toedev *tod; 603 int i, rc; 604 | 30 31#include "opt_inet.h" 32 33#include <sys/param.h> 34#include <sys/types.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/ktr.h> --- 559 unchanged lines hidden (view full) --- 597 */ 598static int 599t4_tom_activate(struct adapter *sc) 600{ 601 struct tom_data *td; 602 struct toedev *tod; 603 int i, rc; 604 |
605 ADAPTER_LOCK_ASSERT_OWNED(sc); /* for sc->flags */ | 605 ASSERT_SYNCHRONIZED_OP(sc); |
606 607 /* per-adapter softc for TOM */ 608 td = malloc(sizeof(*td), M_CXGBE, M_ZERO | M_NOWAIT); 609 if (td == NULL) 610 return (ENOMEM); 611 612 /* List of TOE PCBs and associated lock */ 613 mtx_init(&td->toep_list_lock, "PCB list lock", NULL, MTX_DEF); --- 49 unchanged lines hidden (view full) --- 663} 664 665static int 666t4_tom_deactivate(struct adapter *sc) 667{ 668 int rc = 0; 669 struct tom_data *td = sc->tom_softc; 670 | 606 607 /* per-adapter softc for TOM */ 608 td = malloc(sizeof(*td), M_CXGBE, M_ZERO | M_NOWAIT); 609 if (td == NULL) 610 return (ENOMEM); 611 612 /* List of TOE PCBs and associated lock */ 613 mtx_init(&td->toep_list_lock, "PCB list lock", NULL, MTX_DEF); --- 49 unchanged lines hidden (view full) --- 663} 664 665static int 666t4_tom_deactivate(struct adapter *sc) 667{ 668 int rc = 0; 669 struct tom_data *td = sc->tom_softc; 670 |
671 ADAPTER_LOCK_ASSERT_OWNED(sc); /* for sc->flags */ | 671 ASSERT_SYNCHRONIZED_OP(sc); |
672 673 if (td == NULL) 674 return (0); /* XXX. KASSERT? */ 675 676 if (sc->offload_map != 0) 677 return (EBUSY); /* at least one port has IFCAP_TOE enabled */ 678 679 mtx_lock(&td->toep_list_lock); --- 36 unchanged lines hidden (view full) --- 716 t4_tom_mod_unload(); 717 718 return (rc); 719} 720 721static void 722tom_uninit(struct adapter *sc, void *arg __unused) 723{ | 672 673 if (td == NULL) 674 return (0); /* XXX. KASSERT? */ 675 676 if (sc->offload_map != 0) 677 return (EBUSY); /* at least one port has IFCAP_TOE enabled */ 678 679 mtx_lock(&td->toep_list_lock); --- 36 unchanged lines hidden (view full) --- 716 t4_tom_mod_unload(); 717 718 return (rc); 719} 720 721static void 722tom_uninit(struct adapter *sc, void *arg __unused) 723{ |
724 if (begin_synchronized_op(sc, NULL, HOLD_LOCK, "t4tomun")) 725 return; 726 |
|
724 /* Try to free resources (works only if no port has IFCAP_TOE) */ | 727 /* Try to free resources (works only if no port has IFCAP_TOE) */ |
725 ADAPTER_LOCK(sc); | |
726 if (sc->flags & TOM_INIT_DONE) 727 t4_deactivate_uld(sc, ULD_TOM); | 728 if (sc->flags & TOM_INIT_DONE) 729 t4_deactivate_uld(sc, ULD_TOM); |
728 ADAPTER_UNLOCK(sc); | 730 731 end_synchronized_op(sc, LOCK_HELD); |
729} 730 731static int 732t4_tom_mod_unload(void) 733{ 734 t4_iterate(tom_uninit, NULL); 735 736 if (t4_unregister_uld(&tom_uld_info) == EBUSY) --- 41 unchanged lines hidden --- | 732} 733 734static int 735t4_tom_mod_unload(void) 736{ 737 t4_iterate(tom_uninit, NULL); 738 739 if (t4_unregister_uld(&tom_uld_info) == EBUSY) --- 41 unchanged lines hidden --- |