Lines Matching refs:dp

71 static int vsw_setup_rx_dring(vsw_ldc_t *ldcp, dring_info_t *dp);
111 dring_info_t *dp; in vsw_create_rx_dring_info() local
121 if ((dp = vsw_create_rx_dring(ldcp)) == NULL) in vsw_create_rx_dring_info()
124 mp = kmem_zalloc(VNET_DRING_REG_EXT_MSG_SIZE(dp->data_ncookies), in vsw_create_rx_dring_info()
133 mp->num_descriptors = dp->num_descriptors; in vsw_create_rx_dring_info()
134 mp->descriptor_size = dp->descriptor_size; in vsw_create_rx_dring_info()
135 mp->options = dp->options; in vsw_create_rx_dring_info()
136 mp->ncookies = dp->dring_ncookies; in vsw_create_rx_dring_info()
137 bcopy(&dp->dring_cookie[0], &mp->cookie[0], in vsw_create_rx_dring_info()
151 emsg->data_ncookies = dp->data_ncookies; in vsw_create_rx_dring_info()
154 emsg->data_area_size = dp->data_sz; in vsw_create_rx_dring_info()
157 bcopy(dp->data_cookie, (ldc_mem_cookie_t *)emsg->data_cookie, in vsw_create_rx_dring_info()
158 sizeof (ldc_mem_cookie_t) * dp->data_ncookies); in vsw_create_rx_dring_info()
174 dring_info_t *dp; in vsw_create_rx_dring() local
176 dp = (dring_info_t *)kmem_zalloc(sizeof (dring_info_t), KM_SLEEP); in vsw_create_rx_dring()
177 mutex_init(&dp->dlock, NULL, MUTEX_DRIVER, NULL); in vsw_create_rx_dring()
178 ldcp->lane_out.dringp = dp; in vsw_create_rx_dring()
182 sizeof (vnet_rx_dringdata_desc_t), &dp->dring_handle)) != 0) { in vsw_create_rx_dring()
188 ASSERT(dp->dring_handle != NULL); in vsw_create_rx_dring()
191 if ((ldc_mem_dring_info(dp->dring_handle, &minfo)) != 0) { in vsw_create_rx_dring()
197 dp->pub_addr = minfo.vaddr; in vsw_create_rx_dring()
200 dp->num_descriptors = vsw_num_descriptors; in vsw_create_rx_dring()
201 dp->descriptor_size = sizeof (vnet_rx_dringdata_desc_t); in vsw_create_rx_dring()
202 dp->options = VIO_RX_DRING_DATA; in vsw_create_rx_dring()
203 dp->dring_ncookies = 1; /* guaranteed by ldc */ in vsw_create_rx_dring()
204 dp->num_bufs = VSW_RXDRING_NRBUFS; in vsw_create_rx_dring()
211 dp->rxdp_to_vmp = kmem_zalloc(dp->num_descriptors * sizeof (uintptr_t), in vsw_create_rx_dring()
215 if (vsw_setup_rx_dring(ldcp, dp)) { in vsw_create_rx_dring()
224 if ((ldc_mem_dring_bind(ldcp->ldc_handle, dp->dring_handle, in vsw_create_rx_dring()
226 &dp->dring_cookie[0], &dp->dring_ncookies)) != 0) { in vsw_create_rx_dring()
233 dp->end_idx = 0; in vsw_create_rx_dring()
234 dp->last_ack_recv = -1; in vsw_create_rx_dring()
235 dp->next_rxi = 0; in vsw_create_rx_dring()
236 return (dp); in vsw_create_rx_dring()
248 vsw_setup_rx_dring(vsw_ldc_t *ldcp, dring_info_t *dp) in vsw_setup_rx_dring() argument
282 dp->desc_data_sz = data_sz; in vsw_setup_rx_dring()
283 dp->data_sz = (dp->num_bufs * data_sz); in vsw_setup_rx_dring()
284 data_addr = kmem_zalloc(dp->data_sz, KM_SLEEP); in vsw_setup_rx_dring()
285 dp->data_addr = data_addr; in vsw_setup_rx_dring()
288 dp->data_sz, dp->data_addr); in vsw_setup_rx_dring()
291 rv = ldc_mem_alloc_handle(ldcp->ldc_handle, &dp->data_handle); in vsw_setup_rx_dring()
298 dp->data_cookie = kmem_zalloc(VNET_DATA_AREA_COOKIES * in vsw_setup_rx_dring()
304 rv = ldc_mem_bind_handle(dp->data_handle, (caddr_t)data_addr, in vsw_setup_rx_dring()
305 dp->data_sz, LDC_DIRECT_MAP, LDC_MEM_W, in vsw_setup_rx_dring()
306 dp->data_cookie, &ncookies); in vsw_setup_rx_dring()
315 dp->data_ncookies = ncookies; in vsw_setup_rx_dring()
318 rv = ldc_mem_nextcookie(dp->data_handle, in vsw_setup_rx_dring()
319 &(dp->data_cookie[j])); in vsw_setup_rx_dring()
336 rv = vio_create_mblks(dp->num_bufs, data_sz, (uint8_t *)data_addr, in vsw_setup_rx_dring()
337 &dp->rx_vmp); in vsw_setup_rx_dring()
342 pub_addr = dp->pub_addr; in vsw_setup_rx_dring()
343 rxdp_to_vmp = dp->rxdp_to_vmp; in vsw_setup_rx_dring()
344 for (i = 0; i < dp->num_descriptors; i++) { in vsw_setup_rx_dring()
347 vmp = vio_allocb(dp->rx_vmp); in vsw_setup_rx_dring()
369 dring_info_t *dp; in vsw_destroy_rx_dring() local
371 dp = lp->dringp; in vsw_destroy_rx_dring()
372 if (dp == NULL) { in vsw_destroy_rx_dring()
376 mutex_enter(&dp->dlock); in vsw_destroy_rx_dring()
378 if (dp->rx_vmp != NULL) { in vsw_destroy_rx_dring()
379 vio_clobber_pool(dp->rx_vmp); in vsw_destroy_rx_dring()
387 if (vio_destroy_mblks(dp->rx_vmp) != 0) { in vsw_destroy_rx_dring()
389 vsw_destroy_rxpools, dp->rx_vmp, DDI_SLEEP); in vsw_destroy_rx_dring()
394 if (dp->data_cookie != NULL) { in vsw_destroy_rx_dring()
395 kmem_free(dp->data_cookie, VNET_DATA_AREA_COOKIES * in vsw_destroy_rx_dring()
397 dp->data_cookie = NULL; in vsw_destroy_rx_dring()
401 if (dp->data_ncookies != 0) { in vsw_destroy_rx_dring()
402 (void) ldc_mem_unbind_handle(dp->data_handle); in vsw_destroy_rx_dring()
403 dp->data_ncookies = 0; in vsw_destroy_rx_dring()
407 if (dp->data_handle) { in vsw_destroy_rx_dring()
408 (void) ldc_mem_free_handle(dp->data_handle); in vsw_destroy_rx_dring()
409 dp->data_handle = 0; in vsw_destroy_rx_dring()
413 if (dp->data_addr != NULL) { in vsw_destroy_rx_dring()
414 kmem_free(dp->data_addr, dp->data_sz); in vsw_destroy_rx_dring()
418 if (dp->dring_handle != NULL) { in vsw_destroy_rx_dring()
419 (void) ldc_mem_dring_unbind(dp->dring_handle); in vsw_destroy_rx_dring()
420 (void) ldc_mem_dring_destroy(dp->dring_handle); in vsw_destroy_rx_dring()
423 if (dp->rxdp_to_vmp != NULL) { in vsw_destroy_rx_dring()
424 kmem_free(dp->rxdp_to_vmp, in vsw_destroy_rx_dring()
425 dp->num_descriptors * sizeof (uintptr_t)); in vsw_destroy_rx_dring()
426 dp->rxdp_to_vmp = NULL; in vsw_destroy_rx_dring()
429 mutex_exit(&dp->dlock); in vsw_destroy_rx_dring()
430 mutex_destroy(&dp->dlock); in vsw_destroy_rx_dring()
431 mutex_destroy(&dp->restart_lock); in vsw_destroy_rx_dring()
432 kmem_free(dp, sizeof (dring_info_t)); in vsw_destroy_rx_dring()
445 dring_info_t *dp; in vsw_map_tx_dring() local
450 dp = vsw_map_dring_cmn(ldcp, dring_pkt); in vsw_map_tx_dring()
451 if (dp == NULL) { in vsw_map_tx_dring()
456 mutex_init(&dp->txlock, NULL, MUTEX_DRIVER, NULL); in vsw_map_tx_dring()
457 mutex_init(&dp->restart_lock, NULL, MUTEX_DRIVER, NULL); in vsw_map_tx_dring()
458 dp->next_txi = dp->restart_peer_txi = 0; in vsw_map_tx_dring()
459 dp->restart_reqd = B_TRUE; in vsw_map_tx_dring()
461 ldcp->lane_in.dringp = dp; in vsw_map_tx_dring()
484 txdp = (vnet_rx_dringdata_desc_t *)dp->pub_addr; in vsw_map_tx_dring()
485 for (i = 0; i < dp->num_descriptors; i++) { in vsw_map_tx_dring()
491 return (dp); in vsw_map_tx_dring()
494 if (dp->dring_handle != NULL) { in vsw_map_tx_dring()
495 (void) ldc_mem_dring_unmap(dp->dring_handle); in vsw_map_tx_dring()
497 kmem_free(dp, sizeof (*dp)); in vsw_map_tx_dring()
508 dring_info_t *dp; in vsw_unmap_tx_dring() local
510 if ((dp = lp->dringp) == NULL) { in vsw_unmap_tx_dring()
515 if (dp->data_handle != NULL) { in vsw_unmap_tx_dring()
516 (void) ldc_mem_unmap(dp->data_handle); in vsw_unmap_tx_dring()
517 (void) ldc_mem_free_handle(dp->data_handle); in vsw_unmap_tx_dring()
518 dp->data_handle = NULL; in vsw_unmap_tx_dring()
522 if (dp->data_cookie != NULL) { in vsw_unmap_tx_dring()
523 kmem_free(dp->data_cookie, dp->data_ncookies * in vsw_unmap_tx_dring()
525 dp->data_cookie = NULL; in vsw_unmap_tx_dring()
526 dp->data_ncookies = 0; in vsw_unmap_tx_dring()
530 if (dp->dring_handle != NULL) { in vsw_unmap_tx_dring()
531 (void) ldc_mem_dring_unmap(dp->dring_handle); in vsw_unmap_tx_dring()
532 dp->dring_handle = NULL; in vsw_unmap_tx_dring()
535 mutex_destroy(&dp->txlock); in vsw_unmap_tx_dring()
536 kmem_free(dp, sizeof (dring_info_t)); in vsw_unmap_tx_dring()
615 dring_info_t *dp = lp->dringp; in vsw_ldc_rcv_shm() local
675 } while (total_count < dp->num_bufs); in vsw_ldc_rcv_shm()
686 DECR_RXI(dp, end_ix); in vsw_ldc_rcv_shm()
727 dring_info_t *dp = ldcp->lane_out.dringp; in vsw_receive_packet() local
728 vnet_rx_dringdata_desc_t *pub_addr = dp->pub_addr; in vsw_receive_packet()
730 rxi = dp->next_rxi; in vsw_receive_packet()
732 vmp = dp->rxdp_to_vmp[rxi]; in vsw_receive_packet()
764 new_vmp = vio_allocb(dp->rx_vmp); in vsw_receive_packet()
793 dp->rxdp_to_vmp[rxi] = new_vmp; in vsw_receive_packet()
818 INCR_RXI(dp, rxi); in vsw_receive_packet()
821 dp->next_rxi = rxi; in vsw_receive_packet()
876 dring_info_t *dp = lane_in->dringp; in vsw_dringsend_shm() local
888 if (dp == NULL) { in vsw_dringsend_shm()
894 pub_addr = dp->pub_addr; in vsw_dringsend_shm()
937 if (mutex_owned(&dp->txlock)) { in vsw_dringsend_shm()
938 mutex_exit(&dp->txlock); in vsw_dringsend_shm()
940 if (mutex_owned(&dp->restart_lock)) { in vsw_dringsend_shm()
941 mutex_exit(&dp->restart_lock); in vsw_dringsend_shm()
949 mutex_enter(&dp->txlock); in vsw_dringsend_shm()
950 txi = next_txi = dp->next_txi; in vsw_dringsend_shm()
951 INCR_TXI(dp, next_txi); in vsw_dringsend_shm()
955 mutex_exit(&dp->txlock); in vsw_dringsend_shm()
963 dp->next_txi = next_txi; in vsw_dringsend_shm()
964 mutex_exit(&dp->txlock); in vsw_dringsend_shm()
973 dst = (caddr_t)dp->data_addr + buf_offset; in vsw_dringsend_shm()
991 mutex_enter(&dp->restart_lock); in vsw_dringsend_shm()
999 if (dp->restart_reqd == B_TRUE && dp->restart_peer_txi == txi) { in vsw_dringsend_shm()
1000 dp->restart_reqd = B_FALSE; in vsw_dringsend_shm()
1012 mutex_exit(&dp->restart_lock); in vsw_dringsend_shm()
1037 mutex_enter(&dp->restart_lock); in vsw_dringsend_shm()
1039 dp->restart_reqd = B_TRUE; in vsw_dringsend_shm()
1040 mutex_exit(&dp->restart_lock); in vsw_dringsend_shm()
1089 dring_info_t *dp = ldcp->lane_in.dringp; in vsw_process_dringdata_info_shm() local
1093 if (dp->ident != msg->dring_ident) { in vsw_process_dringdata_info_shm()
1119 dring_info_t *dp; in vsw_process_dringdata_ack_shm() local
1131 dp = ldcp->lane_in.dringp; in vsw_process_dringdata_ack_shm()
1134 pub_addr = dp->pub_addr; in vsw_process_dringdata_ack_shm()
1141 if (((start != VNET_START_IDX_UNSPEC) && !(CHECK_TXI(dp, start))) || in vsw_process_dringdata_ack_shm()
1142 !(CHECK_TXI(dp, end))) { in vsw_process_dringdata_ack_shm()
1178 if (mutex_owned(&dp->restart_lock)) { in vsw_process_dringdata_ack_shm()
1179 mutex_exit(&dp->restart_lock); in vsw_process_dringdata_ack_shm()
1189 mutex_enter(&dp->restart_lock); in vsw_process_dringdata_ack_shm()
1193 INCR_TXI(dp, txi); in vsw_process_dringdata_ack_shm()
1209 dp->restart_reqd = B_TRUE; in vsw_process_dringdata_ack_shm()
1210 dp->restart_peer_txi = txi; in vsw_process_dringdata_ack_shm()
1211 mutex_exit(&dp->restart_lock); in vsw_process_dringdata_ack_shm()
1219 dp->restart_reqd = B_FALSE; in vsw_process_dringdata_ack_shm()
1220 mutex_exit(&dp->restart_lock); in vsw_process_dringdata_ack_shm()
1233 mutex_enter(&dp->restart_lock); in vsw_process_dringdata_ack_shm()
1234 dp->restart_reqd = B_TRUE; in vsw_process_dringdata_ack_shm()
1235 mutex_exit(&dp->restart_lock); in vsw_process_dringdata_ack_shm()