Lines Matching +full:max +full:- +full:msg +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* In-kernel rxperf server for testing purposes.
54 size_t req_len; /* Size of request blob */
55 size_t reply_len; /* Size of reply blob */
85 call->state = to; in rxperf_set_call_state()
91 if (call->state != RXPERF_CALL_COMPLETE) { in rxperf_set_call_complete()
92 call->abort_code = remote_abort; in rxperf_set_call_complete()
93 call->error = error; in rxperf_set_call_complete()
94 call->state = RXPERF_CALL_COMPLETE; in rxperf_set_call_complete()
112 queue_work(rxperf_workqueue, &call->work); in rxperf_queue_call_work()
120 if (call->state != RXPERF_CALL_COMPLETE) in rxperf_notify_rx()
128 call->rxcall = rxcall; in rxperf_rx_attach()
151 call->type = "unset"; in rxperf_charge_preallocation()
152 call->debug_id = atomic_inc_return(&rxrpc_debug_id); in rxperf_charge_preallocation()
153 call->deliver = rxperf_deliver_param_block; in rxperf_charge_preallocation()
154 call->state = RXPERF_CALL_SV_AWAIT_PARAMS; in rxperf_charge_preallocation()
155 call->service_id = RX_PERF_SERVICE; in rxperf_charge_preallocation()
156 call->iov_len = sizeof(call->params); in rxperf_charge_preallocation()
157 call->kvec[0].iov_len = sizeof(call->params); in rxperf_charge_preallocation()
158 call->kvec[0].iov_base = &call->params; in rxperf_charge_preallocation()
159 iov_iter_kvec(&call->iter, READ, call->kvec, 1, call->iov_len); in rxperf_charge_preallocation()
160 INIT_WORK(&call->work, rxperf_deliver_to_call); in rxperf_charge_preallocation()
167 call->debug_id) < 0) in rxperf_charge_preallocation()
177 * - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT
190 socket->sk->sk_allocation = GFP_NOFS; in rxperf_open_socket()
201 ret = rxrpc_sock_set_min_security_level(socket->sk, in rxperf_open_socket()
206 ret = rxrpc_sock_set_security_keyring(socket->sk, rxperf_sec_keyring); in rxperf_open_socket()
247 static int max = 0; in rxperf_log_error() local
248 const char *msg; in rxperf_log_error() local
252 case RX_EOF: msg = "unexpected EOF"; break; in rxperf_log_error()
253 case RXGEN_CC_MARSHAL: msg = "client marshalling"; break; in rxperf_log_error()
254 case RXGEN_CC_UNMARSHAL: msg = "client unmarshalling"; break; in rxperf_log_error()
255 case RXGEN_SS_MARSHAL: msg = "server marshalling"; break; in rxperf_log_error()
256 case RXGEN_SS_UNMARSHAL: msg = "server unmarshalling"; break; in rxperf_log_error()
257 case RXGEN_DECODE: msg = "opcode decode"; break; in rxperf_log_error()
258 case RXGEN_SS_XDRFREE: msg = "server XDR cleanup"; break; in rxperf_log_error()
259 case RXGEN_CC_XDRFREE: msg = "client XDR cleanup"; break; in rxperf_log_error()
260 case -32: msg = "insufficient data"; break; in rxperf_log_error()
265 m = max; in rxperf_log_error()
267 max = m + 1; in rxperf_log_error()
268 pr_info("Peer reported %s failure on %s\n", msg, call->type); in rxperf_log_error()
282 if (call->state == RXPERF_CALL_COMPLETE) in rxperf_deliver_to_call()
285 while (state = call->state, in rxperf_deliver_to_call()
291 if (!rxrpc_kernel_check_life(rxperf_socket, call->rxcall)) in rxperf_deliver_to_call()
296 ret = call->deliver(call); in rxperf_deliver_to_call()
303 case -EINPROGRESS: in rxperf_deliver_to_call()
304 case -EAGAIN: in rxperf_deliver_to_call()
306 case -ECONNABORTED: in rxperf_deliver_to_call()
307 rxperf_log_error(call, call->abort_code); in rxperf_deliver_to_call()
309 case -EOPNOTSUPP: in rxperf_deliver_to_call()
311 rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, in rxperf_deliver_to_call()
315 case -ENOTSUPP: in rxperf_deliver_to_call()
317 rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, in rxperf_deliver_to_call()
321 case -EIO: in rxperf_deliver_to_call()
323 call->debug_id, call->state); in rxperf_deliver_to_call()
325 case -ENODATA: in rxperf_deliver_to_call()
326 case -EBADMSG: in rxperf_deliver_to_call()
327 case -EMSGSIZE: in rxperf_deliver_to_call()
328 case -ENOMEM: in rxperf_deliver_to_call()
329 case -EFAULT: in rxperf_deliver_to_call()
330 rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, in rxperf_deliver_to_call()
335 rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, in rxperf_deliver_to_call()
345 rxrpc_kernel_shutdown_call(rxperf_socket, call->rxcall); in rxperf_deliver_to_call()
346 rxrpc_kernel_put_call(rxperf_socket, call->rxcall); in rxperf_deliver_to_call()
347 cancel_work(&call->work); in rxperf_deliver_to_call()
359 ret = rxrpc_kernel_recv_data(rxperf_socket, call->rxcall, &call->iter, in rxperf_extract_data()
360 &call->iov_len, want_more, &remote_abort, in rxperf_extract_data()
361 &call->service_id); in rxperf_extract_data()
363 iov_iter_count(&call->iter), call->iov_len, want_more, ret); in rxperf_extract_data()
364 if (ret == 0 || ret == -EAGAIN) in rxperf_extract_data()
368 switch (call->state) { in rxperf_extract_data()
373 pr_debug("premature completion %d", call->error); in rxperf_extract_data()
374 return call->error; in rxperf_extract_data()
398 version = ntohl(call->params.version); in rxperf_deliver_param_block()
399 call->operation_id = ntohl(call->params.type); in rxperf_deliver_param_block()
400 call->deliver = rxperf_deliver_request; in rxperf_deliver_param_block()
404 return -ENOTSUPP; in rxperf_deliver_param_block()
407 switch (call->operation_id) { in rxperf_deliver_param_block()
409 call->type = "send"; in rxperf_deliver_param_block()
410 call->reply_len = 0; in rxperf_deliver_param_block()
411 call->iov_len = 4; /* Expect req size */ in rxperf_deliver_param_block()
414 call->type = "recv"; in rxperf_deliver_param_block()
415 call->req_len = 0; in rxperf_deliver_param_block()
416 call->iov_len = 4; /* Expect reply size */ in rxperf_deliver_param_block()
419 call->type = "rpc"; in rxperf_deliver_param_block()
420 call->iov_len = 8; /* Expect req size and reply size */ in rxperf_deliver_param_block()
423 call->type = "file"; in rxperf_deliver_param_block()
426 return -EOPNOTSUPP; in rxperf_deliver_param_block()
430 return call->deliver(call); in rxperf_deliver_param_block()
440 switch (call->unmarshal) { in rxperf_deliver_request()
442 call->kvec[0].iov_len = call->iov_len; in rxperf_deliver_request()
443 call->kvec[0].iov_base = call->tmp; in rxperf_deliver_request()
444 iov_iter_kvec(&call->iter, READ, call->kvec, 1, call->iov_len); in rxperf_deliver_request()
445 call->unmarshal++; in rxperf_deliver_request()
452 switch (call->operation_id) { in rxperf_deliver_request()
454 call->type = "send"; in rxperf_deliver_request()
455 call->req_len = ntohl(call->tmp[0]); in rxperf_deliver_request()
456 call->reply_len = 0; in rxperf_deliver_request()
459 call->type = "recv"; in rxperf_deliver_request()
460 call->req_len = 0; in rxperf_deliver_request()
461 call->reply_len = ntohl(call->tmp[0]); in rxperf_deliver_request()
464 call->type = "rpc"; in rxperf_deliver_request()
465 call->req_len = ntohl(call->tmp[0]); in rxperf_deliver_request()
466 call->reply_len = ntohl(call->tmp[1]); in rxperf_deliver_request()
470 return -EIO; in rxperf_deliver_request()
474 call->type, call->req_len, call->reply_len); in rxperf_deliver_request()
476 call->iov_len = call->req_len; in rxperf_deliver_request()
477 iov_iter_discard(&call->iter, READ, call->req_len); in rxperf_deliver_request()
478 call->unmarshal++; in rxperf_deliver_request()
486 call->iov_len = 4; in rxperf_deliver_request()
487 call->kvec[0].iov_len = call->iov_len; in rxperf_deliver_request()
488 call->kvec[0].iov_base = call->tmp; in rxperf_deliver_request()
489 iov_iter_kvec(&call->iter, READ, call->kvec, 1, call->iov_len); in rxperf_deliver_request()
490 call->unmarshal++; in rxperf_deliver_request()
496 call->unmarshal++; in rxperf_deliver_request()
508 struct msghdr msg = {}; in rxperf_process_call() local
512 size_t reply_len = call->reply_len, len; in rxperf_process_call()
514 rxrpc_kernel_set_tx_length(rxperf_socket, call->rxcall, in rxperf_process_call()
520 iov_iter_bvec(&msg.msg_iter, WRITE, &bv, 1, len); in rxperf_process_call()
521 msg.msg_flags = MSG_MORE; in rxperf_process_call()
522 n = rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, in rxperf_process_call()
527 return -EIO; in rxperf_process_call()
528 reply_len -= n; in rxperf_process_call()
534 iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len); in rxperf_process_call()
535 msg.msg_flags = 0; in rxperf_process_call()
536 n = rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, len, in rxperf_process_call()
541 if (n == -ENOMEM) in rxperf_process_call()
542 rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, in rxperf_process_call()
543 RXGEN_SS_MARSHAL, -ENOMEM, in rxperf_process_call()
583 int ret = -ENOMEM; in rxperf_init()