+ clib_warning ("VCL<%d>: vpp handle 0x%llx, sid %u: Got a client request! "
+ "vpp handle 0x%llx, sid %u, flags %d, is_nonblocking %u",
+ getpid (), listen_vpp_handle, listen_session_index,
+ client_session->vpp_handle, client_session_index,
+ flags, client_session->is_nonblocking);
+
+ if (ep)
+ {
+ ep->vrf = client_session->vrf;
+ ep->is_cut_thru = client_session->is_cut_thru;
+ ep->is_ip4 = client_session->peer_addr.is_ip4;
+ ep->port = client_session->peer_port;
+ if (client_session->peer_addr.is_ip4)
+ clib_memcpy (ep->ip, &client_session->peer_addr.ip46.ip4,
+ sizeof (ip4_address_t));
+ else
+ clib_memcpy (ep->ip, &client_session->peer_addr.ip46.ip6,
+ sizeof (ip6_address_t));
+ }
+
+ if (client_session->is_server && client_session->is_cut_thru)
+ {
+ static svm_fifo_segment_create_args_t _a;
+ svm_fifo_segment_create_args_t *a = &_a;
+ svm_fifo_segment_private_t *seg;
+
+ cut_thru_str = " cut-thru ";
+
+ /* Create the segment */
+ memset (a, 0, sizeof (*a));
+ a->segment_name = (char *)
+ format ((u8 *) a->segment_name, "%d:segment%d%c",
+ getpid (), vcm->unique_segment_index++, 0);
+ a->segment_size = vcm->cfg.segment_size;
+ a->preallocated_fifo_pairs = vcm->cfg.preallocated_fifo_pairs;
+ a->rx_fifo_size = vcm->cfg.rx_fifo_size;
+ a->tx_fifo_size = vcm->cfg.tx_fifo_size;
+
+ rv = svm_fifo_segment_create (a);
+ if (PREDICT_FALSE (rv))
+ {
+ clib_warning ("VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: "
+ "client sid %u svm_fifo_segment_create ('%s') "
+ "failed! rv %d", getpid (), listen_vpp_handle,
+ listen_session_index, client_session_index,
+ a->segment_name, rv);
+ vec_reset_length (a->new_segment_indices);
+ rv = VNET_API_ERROR_URI_FIFO_CREATE_FAILED;
+ vppcom_send_connect_session_reply (client_session,
+ client_session_index,
+ client_session->vpp_handle,
+ client_session->client_context,
+ rv);
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ rv = VPPCOM_ENOMEM;
+ goto done;
+ }
+
+ client_session->segment_name = vec_dup ((u8 *) a->segment_name);
+ client_session->sm_seg_index = a->new_segment_indices[0];
+ vec_free (a->new_segment_indices);
+
+ seg = svm_fifo_segment_get_segment (client_session->sm_seg_index);
+ client_session->server_rx_fifo =
+ svm_fifo_segment_alloc_fifo (seg, vcm->cfg.rx_fifo_size,
+ FIFO_SEGMENT_RX_FREELIST);
+ if (PREDICT_FALSE (!client_session->server_rx_fifo))
+ {
+ svm_fifo_segment_delete (seg);
+ clib_warning ("VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: "
+ "client sid %u rx fifo alloc failed! "
+ "size %ld (0x%lx)", getpid (), listen_vpp_handle,
+ listen_session_index, client_session_index,
+ vcm->cfg.rx_fifo_size, vcm->cfg.rx_fifo_size);
+ rv = VNET_API_ERROR_URI_FIFO_CREATE_FAILED;
+ vppcom_send_connect_session_reply (client_session,
+ client_session_index,
+ client_session->vpp_handle,
+ client_session->client_context,
+ rv);
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ rv = VPPCOM_ENOMEM;
+ goto done;
+ }
+ client_session->server_rx_fifo->master_session_index =
+ client_session_index;
+
+ client_session->server_tx_fifo =
+ svm_fifo_segment_alloc_fifo (seg, vcm->cfg.tx_fifo_size,
+ FIFO_SEGMENT_TX_FREELIST);
+ if (PREDICT_FALSE (!client_session->server_tx_fifo))
+ {
+ svm_fifo_segment_delete (seg);
+ clib_warning ("VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: "
+ "client sid %u tx fifo alloc failed! "
+ "size %ld (0x%lx)", getpid (), listen_vpp_handle,
+ listen_session_index, client_session_index,
+ vcm->cfg.tx_fifo_size, vcm->cfg.tx_fifo_size);
+ rv = VNET_API_ERROR_URI_FIFO_CREATE_FAILED;
+ vppcom_send_connect_session_reply (client_session,
+ client_session_index,
+ client_session->vpp_handle,
+ client_session->client_context,
+ rv);
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ rv = VPPCOM_ENOMEM;
+ goto done;
+ }
+ client_session->server_tx_fifo->master_session_index =
+ client_session_index;
+
+ if (VPPCOM_DEBUG > 1)
+ clib_warning ("VCL<%d>: vpp handle 0x%llx, sid %u: client sid %u "
+ "created segment '%s', rx_fifo %p, tx_fifo %p",
+ getpid (), listen_vpp_handle, listen_session_index,
+ client_session_index, client_session->segment_name,
+ client_session->server_rx_fifo,
+ client_session->server_tx_fifo);
+
+#ifdef CUT_THRU_EVENT_QUEUE /* TBD */
+ {
+ void *oldheap;
+ ssvm_shared_header_t *sh = seg->ssvm.sh;
+
+ ssvm_lock_non_recursive (sh, 1);
+ oldheap = ssvm_push_heap (sh);
+ event_q = client_session->vpp_event_queue =
+ svm_queue_init (vcm->cfg.event_queue_size,
+ sizeof (session_fifo_event_t),
+ getpid (), 0 /* signal not sent */ );
+ ssvm_pop_heap (oldheap);
+ ssvm_unlock_non_recursive (sh);
+ }
+#endif
+ vppcom_send_connect_session_reply (client_session,
+ client_session_index,
+ client_session->vpp_handle,
+ client_session->client_context,
+ 0 /* retval OK */ );
+ }