t4_main.c (284052) | t4_main.c (284089) |
---|---|
1/*- 2 * Copyright (c) 2011 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) 2011 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: stable/10/sys/dev/cxgbe/t4_main.c 284052 2015-06-06 09:28:40Z np $"); | 29__FBSDID("$FreeBSD: stable/10/sys/dev/cxgbe/t4_main.c 284089 2015-06-06 18:00:36Z np $"); |
30 31#include "opt_inet.h" 32#include "opt_inet6.h" 33 34#include <sys/param.h> 35#include <sys/conf.h> 36#include <sys/priv.h> 37#include <sys/kernel.h> --- 7014 unchanged lines hidden (view full) --- 7052 return (rc); 7053 7054 if (sc->tids.ftids_in_use > 0) { 7055 rc = EBUSY; 7056 goto done; 7057 } 7058 7059#ifdef TCP_OFFLOAD | 30 31#include "opt_inet.h" 32#include "opt_inet6.h" 33 34#include <sys/param.h> 35#include <sys/conf.h> 36#include <sys/priv.h> 37#include <sys/kernel.h> --- 7014 unchanged lines hidden (view full) --- 7052 return (rc); 7053 7054 if (sc->tids.ftids_in_use > 0) { 7055 rc = EBUSY; 7056 goto done; 7057 } 7058 7059#ifdef TCP_OFFLOAD |
7060 if (sc->offload_map) { | 7060 if (uld_active(sc, ULD_TOM)) { |
7061 rc = EBUSY; 7062 goto done; 7063 } 7064#endif 7065 7066 rc = -t4_set_filter_mode(sc, fconf); 7067done: 7068 end_synchronized_op(sc, LOCK_HELD); --- 1068 unchanged lines hidden (view full) --- 8137 rc = cxgbe_init_synchronized(pi); 8138 if (rc) 8139 return (rc); 8140 } 8141 8142 if (isset(&sc->offload_map, pi->port_id)) 8143 return (0); 8144 | 7061 rc = EBUSY; 7062 goto done; 7063 } 7064#endif 7065 7066 rc = -t4_set_filter_mode(sc, fconf); 7067done: 7068 end_synchronized_op(sc, LOCK_HELD); --- 1068 unchanged lines hidden (view full) --- 8137 rc = cxgbe_init_synchronized(pi); 8138 if (rc) 8139 return (rc); 8140 } 8141 8142 if (isset(&sc->offload_map, pi->port_id)) 8143 return (0); 8144 |
8145 if (!(sc->flags & TOM_INIT_DONE)) { | 8145 if (!uld_active(sc, ULD_TOM)) { |
8146 rc = t4_activate_uld(sc, ULD_TOM); 8147 if (rc == EAGAIN) { 8148 log(LOG_WARNING, 8149 "You must kldload t4_tom.ko before trying " 8150 "to enable TOE on a cxgbe interface.\n"); 8151 } 8152 if (rc != 0) 8153 return (rc); 8154 KASSERT(sc->tom_softc != NULL, 8155 ("%s: TOM activated but softc NULL", __func__)); | 8146 rc = t4_activate_uld(sc, ULD_TOM); 8147 if (rc == EAGAIN) { 8148 log(LOG_WARNING, 8149 "You must kldload t4_tom.ko before trying " 8150 "to enable TOE on a cxgbe interface.\n"); 8151 } 8152 if (rc != 0) 8153 return (rc); 8154 KASSERT(sc->tom_softc != NULL, 8155 ("%s: TOM activated but softc NULL", __func__)); |
8156 KASSERT(sc->flags & TOM_INIT_DONE, | 8156 KASSERT(uld_active(sc, ULD_TOM), |
8157 ("%s: TOM activated but flag not set", __func__)); 8158 } 8159 | 8157 ("%s: TOM activated but flag not set", __func__)); 8158 } 8159 |
8160 /* Activate iWARP and iSCSI too, if the modules are loaded. */ 8161 if (!uld_active(sc, ULD_IWARP)) 8162 (void) t4_activate_uld(sc, ULD_IWARP); 8163 if (!uld_active(sc, ULD_ISCSI)) 8164 (void) t4_activate_uld(sc, ULD_ISCSI); 8165 |
|
8160 setbit(&sc->offload_map, pi->port_id); 8161 } else { 8162 if (!isset(&sc->offload_map, pi->port_id)) 8163 return (0); 8164 | 8166 setbit(&sc->offload_map, pi->port_id); 8167 } else { 8168 if (!isset(&sc->offload_map, pi->port_id)) 8169 return (0); 8170 |
8165 KASSERT(sc->flags & TOM_INIT_DONE, | 8171 KASSERT(uld_active(sc, ULD_TOM), |
8166 ("%s: TOM never initialized?", __func__)); 8167 clrbit(&sc->offload_map, pi->port_id); 8168 } 8169 8170 return (0); 8171} 8172 8173/* --- 43 unchanged lines hidden (view full) --- 8217done: 8218 sx_xunlock(&t4_uld_list_lock); 8219 return (rc); 8220} 8221 8222int 8223t4_activate_uld(struct adapter *sc, int id) 8224{ | 8172 ("%s: TOM never initialized?", __func__)); 8173 clrbit(&sc->offload_map, pi->port_id); 8174 } 8175 8176 return (0); 8177} 8178 8179/* --- 43 unchanged lines hidden (view full) --- 8223done: 8224 sx_xunlock(&t4_uld_list_lock); 8225 return (rc); 8226} 8227 8228int 8229t4_activate_uld(struct adapter *sc, int id) 8230{ |
8225 int rc = EAGAIN; | 8231 int rc; |
8226 struct uld_info *ui; 8227 8228 ASSERT_SYNCHRONIZED_OP(sc); 8229 | 8232 struct uld_info *ui; 8233 8234 ASSERT_SYNCHRONIZED_OP(sc); 8235 |
8236 if (id < 0 || id > ULD_MAX) 8237 return (EINVAL); 8238 rc = EAGAIN; /* kldoad the module with this ULD and try again. */ 8239 |
|
8230 sx_slock(&t4_uld_list_lock); 8231 8232 SLIST_FOREACH(ui, &t4_uld_list, link) { 8233 if (ui->uld_id == id) { 8234 if (!(sc->flags & FULL_INIT_DONE)) { 8235 rc = adapter_full_init(sc); 8236 if (rc != 0) | 8240 sx_slock(&t4_uld_list_lock); 8241 8242 SLIST_FOREACH(ui, &t4_uld_list, link) { 8243 if (ui->uld_id == id) { 8244 if (!(sc->flags & FULL_INIT_DONE)) { 8245 rc = adapter_full_init(sc); 8246 if (rc != 0) |
8237 goto done; | 8247 break; |
8238 } 8239 8240 rc = ui->activate(sc); | 8248 } 8249 8250 rc = ui->activate(sc); |
8241 if (rc == 0) | 8251 if (rc == 0) { 8252 setbit(&sc->active_ulds, id); |
8242 ui->refcount++; | 8253 ui->refcount++; |
8243 goto done; | 8254 } 8255 break; |
8244 } 8245 } | 8256 } 8257 } |
8246done: | 8258 |
8247 sx_sunlock(&t4_uld_list_lock); 8248 8249 return (rc); 8250} 8251 8252int 8253t4_deactivate_uld(struct adapter *sc, int id) 8254{ | 8259 sx_sunlock(&t4_uld_list_lock); 8260 8261 return (rc); 8262} 8263 8264int 8265t4_deactivate_uld(struct adapter *sc, int id) 8266{ |
8255 int rc = EINVAL; | 8267 int rc; |
8256 struct uld_info *ui; 8257 8258 ASSERT_SYNCHRONIZED_OP(sc); 8259 | 8268 struct uld_info *ui; 8269 8270 ASSERT_SYNCHRONIZED_OP(sc); 8271 |
8272 if (id < 0 || id > ULD_MAX) 8273 return (EINVAL); 8274 rc = ENXIO; 8275 |
|
8260 sx_slock(&t4_uld_list_lock); 8261 8262 SLIST_FOREACH(ui, &t4_uld_list, link) { 8263 if (ui->uld_id == id) { 8264 rc = ui->deactivate(sc); | 8276 sx_slock(&t4_uld_list_lock); 8277 8278 SLIST_FOREACH(ui, &t4_uld_list, link) { 8279 if (ui->uld_id == id) { 8280 rc = ui->deactivate(sc); |
8265 if (rc == 0) | 8281 if (rc == 0) { 8282 clrbit(&sc->active_ulds, id); |
8266 ui->refcount--; | 8283 ui->refcount--; |
8267 goto done; | 8284 } 8285 break; |
8268 } 8269 } | 8286 } 8287 } |
8270done: | 8288 |
8271 sx_sunlock(&t4_uld_list_lock); 8272 8273 return (rc); 8274} | 8289 sx_sunlock(&t4_uld_list_lock); 8290 8291 return (rc); 8292} |
8293 8294int 8295uld_active(struct adapter *sc, int uld_id) 8296{ 8297 8298 MPASS(uld_id >= 0 && uld_id <= ULD_MAX); 8299 8300 return (isset(&sc->active_ulds, uld_id)); 8301} |
|
8275#endif 8276 8277/* 8278 * Come up with reasonable defaults for some of the tunables, provided they're 8279 * not set by the user (in which case we'll use the values as is). 8280 */ 8281static void 8282tweak_tunables(void) --- 166 unchanged lines hidden --- | 8302#endif 8303 8304/* 8305 * Come up with reasonable defaults for some of the tunables, provided they're 8306 * not set by the user (in which case we'll use the values as is). 8307 */ 8308static void 8309tweak_tunables(void) --- 166 unchanged lines hidden --- |