Lines Matching refs:nc

66 	struct ntb_child *nc;  in ntb_register_device()  local
103 nc = malloc(sizeof(*nc), M_DEVBUF, M_WAITOK | M_ZERO); in ntb_register_device()
104 nc->function = i; in ntb_register_device()
105 nc->mwoff = mwu; in ntb_register_device()
106 nc->mwcnt = mw; in ntb_register_device()
107 nc->spadoff = spadu; in ntb_register_device()
108 nc->spadcnt = spad; in ntb_register_device()
109 nc->dboff = dbu; in ntb_register_device()
110 nc->dbcnt = db; in ntb_register_device()
111 nc->dbmask = (db == 0) ? 0 : (0xffffffffffffffff >> (64 - db)); in ntb_register_device()
112 rm_init(&nc->ctx_lock, "ntb ctx"); in ntb_register_device()
113 nc->dev = device_add_child(dev, name, -1); in ntb_register_device()
114 if (nc->dev == NULL) { in ntb_register_device()
118 device_set_ivars(nc->dev, nc); in ntb_register_device()
119 *cpp = nc; in ntb_register_device()
120 cpp = &nc->next; in ntb_register_device()
156 struct ntb_child *nc; in ntb_unregister_device() local
159 while ((nc = *cpp) != NULL) { in ntb_unregister_device()
161 error = device_delete_child(dev, nc->dev); in ntb_unregister_device()
164 rm_destroy(&nc->ctx_lock); in ntb_unregister_device()
165 free(nc, M_DEVBUF); in ntb_unregister_device()
174 struct ntb_child *nc = device_get_ivars(child); in ntb_child_location_str() local
176 snprintf(buf, buflen, "function=%d", nc->function); in ntb_child_location_str()
183 struct ntb_child *nc = device_get_ivars(child); in ntb_print_child() local
187 if (nc->mwcnt > 0) { in ntb_print_child()
188 printf(" mw %d", nc->mwoff); in ntb_print_child()
189 if (nc->mwcnt > 1) in ntb_print_child()
190 printf("-%d", nc->mwoff + nc->mwcnt - 1); in ntb_print_child()
192 if (nc->spadcnt > 0) { in ntb_print_child()
193 printf(" spad %d", nc->spadoff); in ntb_print_child()
194 if (nc->spadcnt > 1) in ntb_print_child()
195 printf("-%d", nc->spadoff + nc->spadcnt - 1); in ntb_print_child()
197 if (nc->dbcnt > 0) { in ntb_print_child()
198 printf(" db %d", nc->dboff); in ntb_print_child()
199 if (nc->dbcnt > 1) in ntb_print_child()
200 printf("-%d", nc->dboff + nc->dbcnt - 1); in ntb_print_child()
202 retval += printf(" at function %d", nc->function); in ntb_print_child()
220 struct ntb_child *nc; in ntb_link_event() local
231 for (nc = *cpp; nc != NULL; nc = nc->next) { in ntb_link_event()
232 rm_rlock(&nc->ctx_lock, &ctx_tracker); in ntb_link_event()
233 if (nc->ctx_ops != NULL && nc->ctx_ops->link_event != NULL) in ntb_link_event()
234 nc->ctx_ops->link_event(nc->ctx); in ntb_link_event()
235 rm_runlock(&nc->ctx_lock, &ctx_tracker); in ntb_link_event()
243 struct ntb_child *nc; in ntb_db_event() local
246 for (nc = *cpp; nc != NULL; nc = nc->next) { in ntb_db_event()
247 rm_rlock(&nc->ctx_lock, &ctx_tracker); in ntb_db_event()
248 if (nc->ctx_ops != NULL && nc->ctx_ops->db_event != NULL) in ntb_db_event()
249 nc->ctx_ops->db_event(nc->ctx, vec); in ntb_db_event()
250 rm_runlock(&nc->ctx_lock, &ctx_tracker); in ntb_db_event()
288 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_enable() local
289 struct ntb_child **cpp = device_get_softc(device_get_parent(nc->dev)); in ntb_link_enable()
294 nc->enabled = 1; in ntb_link_enable()
298 nc->enabled = 1; in ntb_link_enable()
305 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_disable() local
306 struct ntb_child **cpp = device_get_softc(device_get_parent(nc->dev)); in ntb_link_disable()
309 if (!nc->enabled) in ntb_link_disable()
311 nc->enabled = 0; in ntb_link_disable()
322 struct ntb_child *nc = device_get_ivars(ntb); in ntb_link_enabled() local
324 return (nc->enabled && NTB_LINK_ENABLED(device_get_parent(ntb))); in ntb_link_enabled()
330 struct ntb_child *nc = device_get_ivars(ntb); in ntb_set_ctx() local
335 rm_wlock(&nc->ctx_lock); in ntb_set_ctx()
336 if (nc->ctx_ops != NULL) { in ntb_set_ctx()
337 rm_wunlock(&nc->ctx_lock); in ntb_set_ctx()
340 nc->ctx = ctx; in ntb_set_ctx()
341 nc->ctx_ops = ctx_ops; in ntb_set_ctx()
349 rm_wunlock(&nc->ctx_lock); in ntb_set_ctx()
357 struct ntb_child *nc = device_get_ivars(ntb); in ntb_get_ctx() local
359 KASSERT(nc->ctx != NULL && nc->ctx_ops != NULL, ("bogus")); in ntb_get_ctx()
361 *ctx_ops = nc->ctx_ops; in ntb_get_ctx()
362 return (nc->ctx); in ntb_get_ctx()
368 struct ntb_child *nc = device_get_ivars(ntb); in ntb_clear_ctx() local
370 rm_wlock(&nc->ctx_lock); in ntb_clear_ctx()
371 nc->ctx = NULL; in ntb_clear_ctx()
372 nc->ctx_ops = NULL; in ntb_clear_ctx()
373 rm_wunlock(&nc->ctx_lock); in ntb_clear_ctx()
379 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_count() local
381 return (nc->mwcnt); in ntb_mw_count()
389 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_get_range() local
391 return (NTB_MW_GET_RANGE(device_get_parent(ntb), mw_idx + nc->mwoff, in ntb_mw_get_range()
398 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_set_trans() local
400 return (NTB_MW_SET_TRANS(device_get_parent(ntb), mw_idx + nc->mwoff, in ntb_mw_set_trans()
407 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_clear_trans() local
409 return (NTB_MW_CLEAR_TRANS(device_get_parent(ntb), mw_idx + nc->mwoff)); in ntb_mw_clear_trans()
415 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_get_wc() local
417 return (NTB_MW_GET_WC(device_get_parent(ntb), mw_idx + nc->mwoff, mode)); in ntb_mw_get_wc()
423 struct ntb_child *nc = device_get_ivars(ntb); in ntb_mw_set_wc() local
425 return (NTB_MW_SET_WC(device_get_parent(ntb), mw_idx + nc->mwoff, mode)); in ntb_mw_set_wc()
431 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_count() local
433 return (nc->spadcnt); in ntb_spad_count()
439 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_clear() local
442 for (i = 0; i < nc->spadcnt; i++) in ntb_spad_clear()
443 NTB_SPAD_WRITE(device_get_parent(ntb), i + nc->spadoff, 0); in ntb_spad_clear()
449 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_write() local
451 return (NTB_SPAD_WRITE(device_get_parent(ntb), idx + nc->spadoff, val)); in ntb_spad_write()
457 struct ntb_child *nc = device_get_ivars(ntb); in ntb_spad_read() local
459 return (NTB_SPAD_READ(device_get_parent(ntb), idx + nc->spadoff, val)); in ntb_spad_read()
465 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_spad_write() local
467 return (NTB_PEER_SPAD_WRITE(device_get_parent(ntb), idx + nc->spadoff, in ntb_peer_spad_write()
474 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_spad_read() local
476 return (NTB_PEER_SPAD_READ(device_get_parent(ntb), idx + nc->spadoff, in ntb_peer_spad_read()
483 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_valid_mask() local
485 return (nc->dbmask); in ntb_db_valid_mask()
498 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_vector_mask() local
501 >> nc->dboff) & nc->dbmask); in ntb_db_vector_mask()
514 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_clear() local
516 return (NTB_DB_CLEAR(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_clear()
522 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_clear_mask() local
524 return (NTB_DB_CLEAR_MASK(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_clear_mask()
530 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_read() local
532 return ((NTB_DB_READ(device_get_parent(ntb)) >> nc->dboff) in ntb_db_read()
533 & nc->dbmask); in ntb_db_read()
539 struct ntb_child *nc = device_get_ivars(ntb); in ntb_db_set_mask() local
541 return (NTB_DB_SET_MASK(device_get_parent(ntb), bits << nc->dboff)); in ntb_db_set_mask()
547 struct ntb_child *nc = device_get_ivars(ntb); in ntb_peer_db_set() local
549 return (NTB_PEER_DB_SET(device_get_parent(ntb), bits << nc->dboff)); in ntb_peer_db_set()