Lines Matching refs:nc

64 	struct ntb_child *nc;  in ntb_register_device()  local
101 nc = malloc(sizeof(*nc), M_DEVBUF, M_WAITOK | M_ZERO); in ntb_register_device()
102 nc->function = i; in ntb_register_device()
103 nc->mwoff = mwu; in ntb_register_device()
104 nc->mwcnt = mw; in ntb_register_device()
105 nc->spadoff = spadu; in ntb_register_device()
106 nc->spadcnt = spad; in ntb_register_device()
107 nc->dboff = dbu; in ntb_register_device()
108 nc->dbcnt = db; in ntb_register_device()
109 nc->dbmask = (db == 0) ? 0 : (0xffffffffffffffff >> (64 - db)); in ntb_register_device()
110 rm_init(&nc->ctx_lock, "ntb ctx"); in ntb_register_device()
111 nc->dev = device_add_child(dev, name, -1); in ntb_register_device()
112 if (nc->dev == NULL) { in ntb_register_device()
116 device_set_ivars(nc->dev, nc); in ntb_register_device()
117 *cpp = nc; in ntb_register_device()
118 cpp = &nc->next; in ntb_register_device()
154 struct ntb_child *nc; in ntb_unregister_device() local
157 while ((nc = *cpp) != NULL) { in ntb_unregister_device()
159 error = device_delete_child(dev, nc->dev); in ntb_unregister_device()
162 rm_destroy(&nc->ctx_lock); in ntb_unregister_device()
163 free(nc, M_DEVBUF); in ntb_unregister_device()
171 struct ntb_child *nc = device_get_ivars(child); in ntb_child_location() local
173 sbuf_printf(sb, "function=%d", nc->function); in ntb_child_location()
180 struct ntb_child *nc = device_get_ivars(child); in ntb_print_child() local
184 if (nc->mwcnt > 0) { in ntb_print_child()
185 printf(" mw %d", nc->mwoff); in ntb_print_child()
186 if (nc->mwcnt > 1) in ntb_print_child()
187 printf("-%d", nc->mwoff + nc->mwcnt - 1); in ntb_print_child()
189 if (nc->spadcnt > 0) { in ntb_print_child()
190 printf(" spad %d", nc->spadoff); in ntb_print_child()
191 if (nc->spadcnt > 1) in ntb_print_child()
192 printf("-%d", nc->spadoff + nc->spadcnt - 1); in ntb_print_child()
194 if (nc->dbcnt > 0) { in ntb_print_child()
195 printf(" db %d", nc->dboff); in ntb_print_child()
196 if (nc->dbcnt > 1) in ntb_print_child()
197 printf("-%d", nc->dboff + nc->dbcnt - 1); in ntb_print_child()
199 retval += printf(" at function %d", nc->function); in ntb_print_child()
217 struct ntb_child *nc; in ntb_link_event() local
228 for (nc = *cpp; nc != NULL; nc = nc->next) { in ntb_link_event()
229 rm_rlock(&nc->ctx_lock, &ctx_tracker); in ntb_link_event()
230 if (nc->ctx_ops != NULL && nc->ctx_ops->link_event != NULL) in ntb_link_event()
231 nc->ctx_ops->link_event(nc->ctx); in ntb_link_event()
232 rm_runlock(&nc->ctx_lock, &ctx_tracker); in ntb_link_event()
240 struct ntb_child *nc; in ntb_db_event() local
243 for (nc = *cpp; nc != NULL; nc = nc->next) { in ntb_db_event()
244 rm_rlock(&nc->ctx_lock, &ctx_tracker); in ntb_db_event()
245 if (nc->ctx_ops != NULL && nc->ctx_ops->db_event != NULL) in ntb_db_event()
246 nc->ctx_ops->db_event(nc->ctx, vec); in ntb_db_event()
247 rm_runlock(&nc->ctx_lock, &ctx_tracker); in ntb_db_event()
285 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_enable() local
286 struct ntb_child **cpp = device_get_softc(device_get_parent(nc->dev)); in ntb_link_enable()
291 nc->enabled = 1; in ntb_link_enable()
295 nc->enabled = 1; in ntb_link_enable()
302 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_disable() local
303 struct ntb_child **cpp = device_get_softc(device_get_parent(nc->dev)); in ntb_link_disable()
306 if (!nc->enabled) in ntb_link_disable()
308 nc->enabled = 0; in ntb_link_disable()
319 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_enabled() local
321 return (nc->enabled && NTB_LINK_ENABLED(device_get_parent(ntb))); in ntb_link_enabled()
327 struct ntb_child *nc = device_get_ivars(ntb); in ntb_set_ctx() local
332 rm_wlock(&nc->ctx_lock); in ntb_set_ctx()
333 if (nc->ctx_ops != NULL) { in ntb_set_ctx()
334 rm_wunlock(&nc->ctx_lock); in ntb_set_ctx()
337 nc->ctx = ctx; in ntb_set_ctx()
338 nc->ctx_ops = ctx_ops; in ntb_set_ctx()
346 rm_wunlock(&nc->ctx_lock); in ntb_set_ctx()
354 struct ntb_child *nc = device_get_ivars(ntb); in ntb_get_ctx() local
356 KASSERT(nc->ctx != NULL && nc->ctx_ops != NULL, ("bogus")); in ntb_get_ctx()
358 *ctx_ops = nc->ctx_ops; in ntb_get_ctx()
359 return (nc->ctx); in ntb_get_ctx()
365 struct ntb_child *nc = device_get_ivars(ntb); in ntb_clear_ctx() local
367 rm_wlock(&nc->ctx_lock); in ntb_clear_ctx()
368 nc->ctx = NULL; in ntb_clear_ctx()
369 nc->ctx_ops = NULL; in ntb_clear_ctx()
370 rm_wunlock(&nc->ctx_lock); in ntb_clear_ctx()
376 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_count() local
378 return (nc->mwcnt); in ntb_mw_count()
386 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_get_range() local
388 return (NTB_MW_GET_RANGE(device_get_parent(ntb), mw_idx + nc->mwoff, in ntb_mw_get_range()
395 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_set_trans() local
397 return (NTB_MW_SET_TRANS(device_get_parent(ntb), mw_idx + nc->mwoff, in ntb_mw_set_trans()
404 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_clear_trans() local
406 return (NTB_MW_CLEAR_TRANS(device_get_parent(ntb), mw_idx + nc->mwoff)); in ntb_mw_clear_trans()
412 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_get_wc() local
414 return (NTB_MW_GET_WC(device_get_parent(ntb), mw_idx + nc->mwoff, mode)); in ntb_mw_get_wc()
420 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_set_wc() local
422 return (NTB_MW_SET_WC(device_get_parent(ntb), mw_idx + nc->mwoff, mode)); in ntb_mw_set_wc()
428 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_count() local
430 return (nc->spadcnt); in ntb_spad_count()
436 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_clear() local
439 for (i = 0; i < nc->spadcnt; i++) in ntb_spad_clear()
440 NTB_SPAD_WRITE(device_get_parent(ntb), i + nc->spadoff, 0); in ntb_spad_clear()
446 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_write() local
448 return (NTB_SPAD_WRITE(device_get_parent(ntb), idx + nc->spadoff, val)); in ntb_spad_write()
454 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_read() local
456 return (NTB_SPAD_READ(device_get_parent(ntb), idx + nc->spadoff, val)); in ntb_spad_read()
462 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_spad_write() local
464 return (NTB_PEER_SPAD_WRITE(device_get_parent(ntb), idx + nc->spadoff, in ntb_peer_spad_write()
471 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_spad_read() local
473 return (NTB_PEER_SPAD_READ(device_get_parent(ntb), idx + nc->spadoff, in ntb_peer_spad_read()
480 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_valid_mask() local
482 return (nc->dbmask); in ntb_db_valid_mask()
495 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_vector_mask() local
498 >> nc->dboff) & nc->dbmask); in ntb_db_vector_mask()
511 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_clear() local
513 return (NTB_DB_CLEAR(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_clear()
519 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_clear_mask() local
521 return (NTB_DB_CLEAR_MASK(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_clear_mask()
527 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_read() local
529 return ((NTB_DB_READ(device_get_parent(ntb)) >> nc->dboff) in ntb_db_read()
530 & nc->dbmask); in ntb_db_read()
536 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_set_mask() local
538 return (NTB_DB_SET_MASK(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_set_mask()
544 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_db_set() local
546 return (NTB_PEER_DB_SET(device_get_parent(ntb), bits << nc->dboff)); in ntb_peer_db_set()