Lines Matching refs:nc
63 struct ntb_child *nc; in ntb_register_device() local
100 nc = malloc(sizeof(*nc), M_DEVBUF, M_WAITOK | M_ZERO); in ntb_register_device()
101 nc->function = i; in ntb_register_device()
102 nc->mwoff = mwu; in ntb_register_device()
103 nc->mwcnt = mw; in ntb_register_device()
104 nc->spadoff = spadu; in ntb_register_device()
105 nc->spadcnt = spad; in ntb_register_device()
106 nc->dboff = dbu; in ntb_register_device()
107 nc->dbcnt = db; in ntb_register_device()
108 nc->dbmask = (db == 0) ? 0 : (0xffffffffffffffff >> (64 - db)); in ntb_register_device()
109 rm_init(&nc->ctx_lock, "ntb ctx"); in ntb_register_device()
110 nc->dev = device_add_child(dev, name, DEVICE_UNIT_ANY); in ntb_register_device()
111 if (nc->dev == NULL) { in ntb_register_device()
115 device_set_ivars(nc->dev, nc); in ntb_register_device()
116 *cpp = nc; in ntb_register_device()
117 cpp = &nc->next; in ntb_register_device()
153 struct ntb_child *nc; in ntb_unregister_device() local
156 while ((nc = *cpp) != NULL) { in ntb_unregister_device()
158 error = device_delete_child(dev, nc->dev); in ntb_unregister_device()
161 rm_destroy(&nc->ctx_lock); in ntb_unregister_device()
162 free(nc, M_DEVBUF); in ntb_unregister_device()
170 struct ntb_child *nc = device_get_ivars(child); in ntb_child_location() local
172 sbuf_printf(sb, "function=%d", nc->function); in ntb_child_location()
179 struct ntb_child *nc = device_get_ivars(child); in ntb_print_child() local
183 if (nc->mwcnt > 0) { in ntb_print_child()
184 printf(" mw %d", nc->mwoff); in ntb_print_child()
185 if (nc->mwcnt > 1) in ntb_print_child()
186 printf("-%d", nc->mwoff + nc->mwcnt - 1); in ntb_print_child()
188 if (nc->spadcnt > 0) { in ntb_print_child()
189 printf(" spad %d", nc->spadoff); in ntb_print_child()
190 if (nc->spadcnt > 1) in ntb_print_child()
191 printf("-%d", nc->spadoff + nc->spadcnt - 1); in ntb_print_child()
193 if (nc->dbcnt > 0) { in ntb_print_child()
194 printf(" db %d", nc->dboff); in ntb_print_child()
195 if (nc->dbcnt > 1) in ntb_print_child()
196 printf("-%d", nc->dboff + nc->dbcnt - 1); in ntb_print_child()
198 retval += printf(" at function %d", nc->function); in ntb_print_child()
216 struct ntb_child *nc; in ntb_link_event() local
227 for (nc = *cpp; nc != NULL; nc = nc->next) { in ntb_link_event()
228 rm_rlock(&nc->ctx_lock, &ctx_tracker); in ntb_link_event()
229 if (nc->ctx_ops != NULL && nc->ctx_ops->link_event != NULL) in ntb_link_event()
230 nc->ctx_ops->link_event(nc->ctx); in ntb_link_event()
231 rm_runlock(&nc->ctx_lock, &ctx_tracker); in ntb_link_event()
239 struct ntb_child *nc; in ntb_db_event() local
242 for (nc = *cpp; nc != NULL; nc = nc->next) { in ntb_db_event()
243 rm_rlock(&nc->ctx_lock, &ctx_tracker); in ntb_db_event()
244 if (nc->ctx_ops != NULL && nc->ctx_ops->db_event != NULL) in ntb_db_event()
245 nc->ctx_ops->db_event(nc->ctx, vec); in ntb_db_event()
246 rm_runlock(&nc->ctx_lock, &ctx_tracker); in ntb_db_event()
284 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_enable() local
285 struct ntb_child **cpp = device_get_softc(device_get_parent(nc->dev)); in ntb_link_enable()
290 nc->enabled = 1; in ntb_link_enable()
294 nc->enabled = 1; in ntb_link_enable()
301 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_disable() local
302 struct ntb_child **cpp = device_get_softc(device_get_parent(nc->dev)); in ntb_link_disable()
305 if (!nc->enabled) in ntb_link_disable()
307 nc->enabled = 0; in ntb_link_disable()
318 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_enabled() local
320 return (nc->enabled && NTB_LINK_ENABLED(device_get_parent(ntb))); in ntb_link_enabled()
326 struct ntb_child *nc = device_get_ivars(ntb); in ntb_set_ctx() local
331 rm_wlock(&nc->ctx_lock); in ntb_set_ctx()
332 if (nc->ctx_ops != NULL) { in ntb_set_ctx()
333 rm_wunlock(&nc->ctx_lock); in ntb_set_ctx()
336 nc->ctx = ctx; in ntb_set_ctx()
337 nc->ctx_ops = ctx_ops; in ntb_set_ctx()
345 rm_wunlock(&nc->ctx_lock); in ntb_set_ctx()
353 struct ntb_child *nc = device_get_ivars(ntb); in ntb_get_ctx() local
355 KASSERT(nc->ctx != NULL && nc->ctx_ops != NULL, ("bogus")); in ntb_get_ctx()
357 *ctx_ops = nc->ctx_ops; in ntb_get_ctx()
358 return (nc->ctx); in ntb_get_ctx()
364 struct ntb_child *nc = device_get_ivars(ntb); in ntb_clear_ctx() local
366 rm_wlock(&nc->ctx_lock); in ntb_clear_ctx()
367 nc->ctx = NULL; in ntb_clear_ctx()
368 nc->ctx_ops = NULL; in ntb_clear_ctx()
369 rm_wunlock(&nc->ctx_lock); in ntb_clear_ctx()
375 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_count() local
377 return (nc->mwcnt); in ntb_mw_count()
385 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_get_range() local
387 return (NTB_MW_GET_RANGE(device_get_parent(ntb), mw_idx + nc->mwoff, in ntb_mw_get_range()
394 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_set_trans() local
396 return (NTB_MW_SET_TRANS(device_get_parent(ntb), mw_idx + nc->mwoff, in ntb_mw_set_trans()
403 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_clear_trans() local
405 return (NTB_MW_CLEAR_TRANS(device_get_parent(ntb), mw_idx + nc->mwoff)); in ntb_mw_clear_trans()
411 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_get_wc() local
413 return (NTB_MW_GET_WC(device_get_parent(ntb), mw_idx + nc->mwoff, mode)); in ntb_mw_get_wc()
419 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_set_wc() local
421 return (NTB_MW_SET_WC(device_get_parent(ntb), mw_idx + nc->mwoff, mode)); in ntb_mw_set_wc()
427 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_count() local
429 return (nc->spadcnt); in ntb_spad_count()
435 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_clear() local
438 for (i = 0; i < nc->spadcnt; i++) in ntb_spad_clear()
439 NTB_SPAD_WRITE(device_get_parent(ntb), i + nc->spadoff, 0); in ntb_spad_clear()
445 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_write() local
447 return (NTB_SPAD_WRITE(device_get_parent(ntb), idx + nc->spadoff, val)); in ntb_spad_write()
453 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_read() local
455 return (NTB_SPAD_READ(device_get_parent(ntb), idx + nc->spadoff, val)); in ntb_spad_read()
461 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_spad_write() local
463 return (NTB_PEER_SPAD_WRITE(device_get_parent(ntb), idx + nc->spadoff, in ntb_peer_spad_write()
470 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_spad_read() local
472 return (NTB_PEER_SPAD_READ(device_get_parent(ntb), idx + nc->spadoff, in ntb_peer_spad_read()
479 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_valid_mask() local
481 return (nc->dbmask); in ntb_db_valid_mask()
494 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_vector_mask() local
497 >> nc->dboff) & nc->dbmask); in ntb_db_vector_mask()
510 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_clear() local
512 return (NTB_DB_CLEAR(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_clear()
518 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_clear_mask() local
520 return (NTB_DB_CLEAR_MASK(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_clear_mask()
526 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_read() local
528 return ((NTB_DB_READ(device_get_parent(ntb)) >> nc->dboff) in ntb_db_read()
529 & nc->dbmask); in ntb_db_read()
535 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_set_mask() local
537 return (NTB_DB_SET_MASK(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_set_mask()
543 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_db_set() local
545 return (NTB_PEER_DB_SET(device_get_parent(ntb), bits << nc->dboff)); in ntb_peer_db_set()