1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* AF_RXRPC sendmsg() implementation.
4 * Copyright (C) 2007, 2016 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/net.h>
11 #include <linux/gfp.h>
12 #include <linux/skbuff.h>
13 #include <linux/export.h>
14 #include <linux/sched/signal.h>
17 #include <net/af_rxrpc.h>
18 #include "ar-internal.h"
21 * Return true if there's sufficient Tx queue space.
23 static bool rxrpc_check_tx_space(struct rxrpc_call *call, rxrpc_seq_t *_tx_win)
25 unsigned int win_size =
26 min_t(unsigned int, call->tx_winsize,
27 call->cong_cwnd + call->cong_extra);
28 rxrpc_seq_t tx_win = READ_ONCE(call->tx_hard_ack);
32 return call->tx_top - tx_win < win_size;
36 * Wait for space to appear in the Tx queue or a signal to occur.
38 static int rxrpc_wait_for_tx_window_intr(struct rxrpc_sock *rx,
39 struct rxrpc_call *call,
43 set_current_state(TASK_INTERRUPTIBLE);
44 if (rxrpc_check_tx_space(call, NULL))
47 if (call->state >= RXRPC_CALL_COMPLETE)
50 if (signal_pending(current))
51 return sock_intr_errno(*timeo);
53 trace_rxrpc_transmit(call, rxrpc_transmit_wait);
54 *timeo = schedule_timeout(*timeo);
59 * Wait for space to appear in the Tx queue uninterruptibly, but with
60 * a timeout of 2*RTT if no progress was made and a signal occurred.
62 static int rxrpc_wait_for_tx_window_waitall(struct rxrpc_sock *rx,
63 struct rxrpc_call *call)
65 rxrpc_seq_t tx_start, tx_win;
66 signed long rtt, timeout;
68 rtt = READ_ONCE(call->peer->srtt_us) >> 3;
69 rtt = usecs_to_jiffies(rtt) * 2;
74 tx_start = READ_ONCE(call->tx_hard_ack);
77 set_current_state(TASK_UNINTERRUPTIBLE);
79 tx_win = READ_ONCE(call->tx_hard_ack);
80 if (rxrpc_check_tx_space(call, &tx_win))
83 if (call->state >= RXRPC_CALL_COMPLETE)
87 tx_win == tx_start && signal_pending(current))
90 if (tx_win != tx_start) {
95 trace_rxrpc_transmit(call, rxrpc_transmit_wait);
96 timeout = schedule_timeout(timeout);
101 * Wait for space to appear in the Tx queue uninterruptibly.
103 static int rxrpc_wait_for_tx_window_nonintr(struct rxrpc_sock *rx,
104 struct rxrpc_call *call,
108 set_current_state(TASK_UNINTERRUPTIBLE);
109 if (rxrpc_check_tx_space(call, NULL))
112 if (call->state >= RXRPC_CALL_COMPLETE)
115 trace_rxrpc_transmit(call, rxrpc_transmit_wait);
116 *timeo = schedule_timeout(*timeo);
121 * wait for space to appear in the transmit/ACK window
122 * - caller holds the socket locked
124 static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx,
125 struct rxrpc_call *call,
129 DECLARE_WAITQUEUE(myself, current);
132 _enter(",{%u,%u,%u}",
133 call->tx_hard_ack, call->tx_top, call->tx_winsize);
135 add_wait_queue(&call->waitq, &myself);
137 switch (call->interruptibility) {
138 case RXRPC_INTERRUPTIBLE:
140 ret = rxrpc_wait_for_tx_window_waitall(rx, call);
142 ret = rxrpc_wait_for_tx_window_intr(rx, call, timeo);
144 case RXRPC_PREINTERRUPTIBLE:
145 case RXRPC_UNINTERRUPTIBLE:
147 ret = rxrpc_wait_for_tx_window_nonintr(rx, call, timeo);
151 remove_wait_queue(&call->waitq, &myself);
152 set_current_state(TASK_RUNNING);
153 _leave(" = %d", ret);
158 * Schedule an instant Tx resend.
160 static inline void rxrpc_instant_resend(struct rxrpc_call *call, int ix)
162 spin_lock_bh(&call->lock);
164 if (call->state < RXRPC_CALL_COMPLETE) {
165 call->rxtx_annotations[ix] =
166 (call->rxtx_annotations[ix] & RXRPC_TX_ANNO_LAST) |
167 RXRPC_TX_ANNO_RETRANS;
168 if (!test_and_set_bit(RXRPC_CALL_EV_RESEND, &call->events))
169 rxrpc_queue_call(call);
172 spin_unlock_bh(&call->lock);
176 * Notify the owner of the call that the transmit phase is ended and the last
177 * packet has been queued.
179 static void rxrpc_notify_end_tx(struct rxrpc_sock *rx, struct rxrpc_call *call,
180 rxrpc_notify_end_tx_t notify_end_tx)
183 notify_end_tx(&rx->sk, call, call->user_call_ID);
187 * Queue a DATA packet for transmission, set the resend timeout and send
188 * the packet immediately. Returns the error from rxrpc_send_data_packet()
189 * in case the caller wants to do something with it.
191 static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
192 struct sk_buff *skb, bool last,
193 rxrpc_notify_end_tx_t notify_end_tx)
195 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
197 rxrpc_seq_t seq = sp->hdr.seq;
199 u8 annotation = RXRPC_TX_ANNO_UNACK;
201 _net("queue skb %p [%d]", skb, seq);
203 rxrpc_inc_stat(call->rxnet, stat_tx_data);
205 ASSERTCMP(seq, ==, call->tx_top + 1);
208 annotation |= RXRPC_TX_ANNO_LAST;
210 /* We have to set the timestamp before queueing as the retransmit
211 * algorithm can see the packet as soon as we queue it.
213 skb->tstamp = ktime_get_real();
215 ix = seq & RXRPC_RXTX_BUFF_MASK;
216 rxrpc_get_skb(skb, rxrpc_skb_got);
217 call->rxtx_annotations[ix] = annotation;
219 call->rxtx_buffer[ix] = skb;
222 trace_rxrpc_transmit(call, rxrpc_transmit_queue_last);
224 trace_rxrpc_transmit(call, rxrpc_transmit_queue);
226 if (last || call->state == RXRPC_CALL_SERVER_ACK_REQUEST) {
227 _debug("________awaiting reply/ACK__________");
228 write_lock_bh(&call->state_lock);
229 switch (call->state) {
230 case RXRPC_CALL_CLIENT_SEND_REQUEST:
231 call->state = RXRPC_CALL_CLIENT_AWAIT_REPLY;
232 rxrpc_notify_end_tx(rx, call, notify_end_tx);
234 case RXRPC_CALL_SERVER_ACK_REQUEST:
235 call->state = RXRPC_CALL_SERVER_SEND_REPLY;
237 WRITE_ONCE(call->ack_at, now + MAX_JIFFY_OFFSET);
238 if (call->ackr_reason == RXRPC_ACK_DELAY)
239 call->ackr_reason = 0;
240 trace_rxrpc_timer(call, rxrpc_timer_init_for_send_reply, now);
244 case RXRPC_CALL_SERVER_SEND_REPLY:
245 call->state = RXRPC_CALL_SERVER_AWAIT_ACK;
246 rxrpc_notify_end_tx(rx, call, notify_end_tx);
251 write_unlock_bh(&call->state_lock);
254 if (seq == 1 && rxrpc_is_client_call(call))
255 rxrpc_expose_client_call(call);
257 ret = rxrpc_send_data_packet(call, skb, false);
263 rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR,
267 _debug("need instant resend %d", ret);
268 rxrpc_instant_resend(call, ix);
270 unsigned long now = jiffies;
271 unsigned long resend_at = now + call->peer->rto_j;
273 WRITE_ONCE(call->resend_at, resend_at);
274 rxrpc_reduce_call_timer(call, resend_at, now,
275 rxrpc_timer_set_for_send);
279 rxrpc_free_skb(skb, rxrpc_skb_freed);
280 _leave(" = %d", ret);
285 * send data through a socket
286 * - must be called in process context
287 * - The caller holds the call user access mutex, but not the socket lock.
289 static int rxrpc_send_data(struct rxrpc_sock *rx,
290 struct rxrpc_call *call,
291 struct msghdr *msg, size_t len,
292 rxrpc_notify_end_tx_t notify_end_tx,
295 struct rxrpc_skb_priv *sp;
297 struct sock *sk = &rx->sk;
298 enum rxrpc_call_state state;
300 bool more = msg->msg_flags & MSG_MORE;
303 timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
305 /* this should be in poll */
306 sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
310 if (sk->sk_shutdown & SEND_SHUTDOWN)
312 state = READ_ONCE(call->state);
314 if (state >= RXRPC_CALL_COMPLETE)
317 if (state != RXRPC_CALL_CLIENT_SEND_REQUEST &&
318 state != RXRPC_CALL_SERVER_ACK_REQUEST &&
319 state != RXRPC_CALL_SERVER_SEND_REPLY)
323 if (call->tx_total_len != -1) {
324 if (len - copied > call->tx_total_len)
326 if (!more && len - copied != call->tx_total_len)
330 skb = call->tx_pending;
331 call->tx_pending = NULL;
332 rxrpc_see_skb(skb, rxrpc_skb_seen);
335 /* Check to see if there's a ping ACK to reply to. */
336 if (call->ackr_reason == RXRPC_ACK_PING_RESPONSE)
337 rxrpc_send_ack_packet(call, false, NULL);
340 size_t remain, bufsize, chunk, offset;
344 if (!rxrpc_check_tx_space(call, NULL))
347 /* Work out the maximum size of a packet. Assume that
348 * the security header is going to be in the padded
349 * region (enc blocksize), but the trailer is not.
351 remain = more ? INT_MAX : msg_data_left(msg);
352 ret = call->conn->security->how_much_data(call, remain,
353 &bufsize, &chunk, &offset);
357 _debug("SIZE: %zu/%zu @%zu", chunk, bufsize, offset);
359 /* create a buffer that we can retain until it's ACK'd */
360 skb = sock_alloc_send_skb(
361 sk, bufsize, msg->msg_flags & MSG_DONTWAIT, &ret);
366 rxrpc_new_skb(skb, rxrpc_skb_new);
368 _debug("ALLOC SEND %p", skb);
370 ASSERTCMP(skb->mark, ==, 0);
372 __skb_put(skb, offset);
375 if (sp->remain > skb_tailroom(skb))
376 sp->remain = skb_tailroom(skb);
378 _net("skb: hr %d, tr %d, hl %d, rm %d",
384 skb->ip_summed = CHECKSUM_UNNECESSARY;
390 /* append next segment of data to the current buffer */
391 if (msg_data_left(msg) > 0) {
392 int copy = skb_tailroom(skb);
393 ASSERTCMP(copy, >, 0);
394 if (copy > msg_data_left(msg))
395 copy = msg_data_left(msg);
396 if (copy > sp->remain)
400 ret = skb_add_data(skb, &msg->msg_iter, copy);
407 if (call->tx_total_len != -1)
408 call->tx_total_len -= copy;
411 /* check for the far side aborting the call or a network error
413 if (call->state == RXRPC_CALL_COMPLETE)
414 goto call_terminated;
416 /* add the packet to the send queue if it's now full */
417 if (sp->remain <= 0 ||
418 (msg_data_left(msg) == 0 && !more)) {
419 struct rxrpc_connection *conn = call->conn;
422 seq = call->tx_top + 1;
426 sp->hdr.flags = conn->out_clientflag;
428 if (msg_data_left(msg) == 0 && !more)
429 sp->hdr.flags |= RXRPC_LAST_PACKET;
430 else if (call->tx_top - call->tx_hard_ack <
432 sp->hdr.flags |= RXRPC_MORE_PACKETS;
434 ret = call->security->secure_packet(call, skb, skb->mark);
438 ret = rxrpc_queue_packet(rx, call, skb,
439 !msg_data_left(msg) && !more,
441 /* Should check for failure here */
444 } while (msg_data_left(msg) > 0);
448 if (READ_ONCE(call->state) == RXRPC_CALL_COMPLETE) {
449 read_lock_bh(&call->state_lock);
452 read_unlock_bh(&call->state_lock);
455 call->tx_pending = skb;
456 _leave(" = %d", ret);
460 rxrpc_free_skb(skb, rxrpc_skb_freed);
461 _leave(" = %d", call->error);
475 if (msg->msg_flags & MSG_DONTWAIT)
477 mutex_unlock(&call->user_mutex);
478 *_dropped_lock = true;
479 ret = rxrpc_wait_for_tx_window(rx, call, &timeo,
480 msg->msg_flags & MSG_WAITALL);
483 if (call->interruptibility == RXRPC_INTERRUPTIBLE) {
484 if (mutex_lock_interruptible(&call->user_mutex) < 0) {
485 ret = sock_intr_errno(timeo);
489 mutex_lock(&call->user_mutex);
491 *_dropped_lock = false;
496 * extract control messages from the sendmsg() control buffer
498 static int rxrpc_sendmsg_cmsg(struct msghdr *msg, struct rxrpc_send_params *p)
500 struct cmsghdr *cmsg;
501 bool got_user_ID = false;
504 if (msg->msg_controllen == 0)
507 for_each_cmsghdr(cmsg, msg) {
508 if (!CMSG_OK(msg, cmsg))
511 len = cmsg->cmsg_len - sizeof(struct cmsghdr);
512 _debug("CMSG %d, %d, %d",
513 cmsg->cmsg_level, cmsg->cmsg_type, len);
515 if (cmsg->cmsg_level != SOL_RXRPC)
518 switch (cmsg->cmsg_type) {
519 case RXRPC_USER_CALL_ID:
520 if (msg->msg_flags & MSG_CMSG_COMPAT) {
521 if (len != sizeof(u32))
523 p->call.user_call_ID = *(u32 *)CMSG_DATA(cmsg);
525 if (len != sizeof(unsigned long))
527 p->call.user_call_ID = *(unsigned long *)
534 if (p->command != RXRPC_CMD_SEND_DATA)
536 p->command = RXRPC_CMD_SEND_ABORT;
537 if (len != sizeof(p->abort_code))
539 p->abort_code = *(unsigned int *)CMSG_DATA(cmsg);
540 if (p->abort_code == 0)
544 case RXRPC_CHARGE_ACCEPT:
545 if (p->command != RXRPC_CMD_SEND_DATA)
547 p->command = RXRPC_CMD_CHARGE_ACCEPT;
552 case RXRPC_EXCLUSIVE_CALL:
558 case RXRPC_UPGRADE_SERVICE:
564 case RXRPC_TX_LENGTH:
565 if (p->call.tx_total_len != -1 || len != sizeof(__s64))
567 p->call.tx_total_len = *(__s64 *)CMSG_DATA(cmsg);
568 if (p->call.tx_total_len < 0)
572 case RXRPC_SET_CALL_TIMEOUT:
573 if (len & 3 || len < 4 || len > 12)
575 memcpy(&p->call.timeouts, CMSG_DATA(cmsg), len);
576 p->call.nr_timeouts = len / 4;
577 if (p->call.timeouts.hard > INT_MAX / HZ)
579 if (p->call.nr_timeouts >= 2 && p->call.timeouts.idle > 60 * 60 * 1000)
581 if (p->call.nr_timeouts >= 3 && p->call.timeouts.normal > 60 * 60 * 1000)
592 if (p->call.tx_total_len != -1 && p->command != RXRPC_CMD_SEND_DATA)
599 * Create a new client call for sendmsg().
600 * - Called with the socket lock held, which it must release.
601 * - If it returns a call, the call's lock will need releasing by the caller.
603 static struct rxrpc_call *
604 rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
605 struct rxrpc_send_params *p)
606 __releases(&rx->sk.sk_lock.slock)
607 __acquires(&call->user_mutex)
609 struct rxrpc_conn_parameters cp;
610 struct rxrpc_call *call;
613 DECLARE_SOCKADDR(struct sockaddr_rxrpc *, srx, msg->msg_name);
617 if (!msg->msg_name) {
618 release_sock(&rx->sk);
619 return ERR_PTR(-EDESTADDRREQ);
623 if (key && !rx->key->payload.data[0])
626 memset(&cp, 0, sizeof(cp));
627 cp.local = rx->local;
629 cp.security_level = rx->min_sec_level;
630 cp.exclusive = rx->exclusive | p->exclusive;
631 cp.upgrade = p->upgrade;
632 cp.service_id = srx->srx_service;
633 call = rxrpc_new_client_call(rx, &cp, srx, &p->call, GFP_KERNEL,
634 atomic_inc_return(&rxrpc_debug_id));
635 /* The socket is now unlocked */
637 rxrpc_put_peer(cp.peer);
638 _leave(" = %p\n", call);
643 * send a message forming part of a client call through an RxRPC socket
644 * - caller holds the socket locked
645 * - the socket may be either a client socket or a server socket
647 int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
648 __releases(&rx->sk.sk_lock.slock)
649 __releases(&call->user_mutex)
651 enum rxrpc_call_state state;
652 struct rxrpc_call *call;
653 unsigned long now, j;
654 bool dropped_lock = false;
657 struct rxrpc_send_params p = {
658 .call.tx_total_len = -1,
659 .call.user_call_ID = 0,
660 .call.nr_timeouts = 0,
661 .call.interruptibility = RXRPC_INTERRUPTIBLE,
663 .command = RXRPC_CMD_SEND_DATA,
670 ret = rxrpc_sendmsg_cmsg(msg, &p);
672 goto error_release_sock;
674 if (p.command == RXRPC_CMD_CHARGE_ACCEPT) {
676 if (rx->sk.sk_state != RXRPC_SERVER_LISTENING)
677 goto error_release_sock;
678 ret = rxrpc_user_charge_accept(rx, p.call.user_call_ID);
679 goto error_release_sock;
682 call = rxrpc_find_call_by_user_ID(rx, p.call.user_call_ID);
685 if (p.command != RXRPC_CMD_SEND_DATA)
686 goto error_release_sock;
687 call = rxrpc_new_client_call_for_sendmsg(rx, msg, &p);
688 /* The socket is now unlocked... */
690 return PTR_ERR(call);
691 /* ... and we have the call lock. */
693 if (READ_ONCE(call->state) == RXRPC_CALL_COMPLETE)
696 switch (READ_ONCE(call->state)) {
697 case RXRPC_CALL_UNINITIALISED:
698 case RXRPC_CALL_CLIENT_AWAIT_CONN:
699 case RXRPC_CALL_SERVER_PREALLOC:
700 case RXRPC_CALL_SERVER_SECURING:
701 rxrpc_put_call(call, rxrpc_call_put);
703 goto error_release_sock;
708 ret = mutex_lock_interruptible(&call->user_mutex);
709 release_sock(&rx->sk);
715 if (p.call.tx_total_len != -1) {
717 if (call->tx_total_len != -1 ||
721 call->tx_total_len = p.call.tx_total_len;
725 switch (p.call.nr_timeouts) {
727 j = msecs_to_jiffies(p.call.timeouts.normal);
728 if (p.call.timeouts.normal > 0 && j == 0)
730 WRITE_ONCE(call->next_rx_timo, j);
733 j = msecs_to_jiffies(p.call.timeouts.idle);
734 if (p.call.timeouts.idle > 0 && j == 0)
736 WRITE_ONCE(call->next_req_timo, j);
739 if (p.call.timeouts.hard > 0) {
740 j = msecs_to_jiffies(p.call.timeouts.hard);
743 WRITE_ONCE(call->expect_term_by, j);
744 rxrpc_reduce_call_timer(call, j, now,
745 rxrpc_timer_set_for_hard);
750 state = READ_ONCE(call->state);
751 _debug("CALL %d USR %lx ST %d on CONN %p",
752 call->debug_id, call->user_call_ID, state, call->conn);
754 if (state >= RXRPC_CALL_COMPLETE) {
755 /* it's too late for this call */
757 } else if (p.command == RXRPC_CMD_SEND_ABORT) {
759 if (rxrpc_abort_call("CMD", call, 0, p.abort_code, -ECONNABORTED))
760 ret = rxrpc_send_abort_packet(call);
761 } else if (p.command != RXRPC_CMD_SEND_DATA) {
764 ret = rxrpc_send_data(rx, call, msg, len, NULL, &dropped_lock);
769 mutex_unlock(&call->user_mutex);
771 rxrpc_put_call(call, rxrpc_call_put);
772 _leave(" = %d", ret);
776 release_sock(&rx->sk);
781 * rxrpc_kernel_send_data - Allow a kernel service to send data on a call
782 * @sock: The socket the call is on
783 * @call: The call to send data through
784 * @msg: The data to send
785 * @len: The amount of data to send
786 * @notify_end_tx: Notification that the last packet is queued.
788 * Allow a kernel service to send data on a call. The call must be in an state
789 * appropriate to sending data. No control data should be supplied in @msg,
790 * nor should an address be supplied. MSG_MORE should be flagged if there's
791 * more data to come, otherwise this data will end the transmission phase.
793 int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
794 struct msghdr *msg, size_t len,
795 rxrpc_notify_end_tx_t notify_end_tx)
797 bool dropped_lock = false;
800 _enter("{%d,%s},", call->debug_id, rxrpc_call_states[call->state]);
802 ASSERTCMP(msg->msg_name, ==, NULL);
803 ASSERTCMP(msg->msg_control, ==, NULL);
805 mutex_lock(&call->user_mutex);
807 _debug("CALL %d USR %lx ST %d on CONN %p",
808 call->debug_id, call->user_call_ID, call->state, call->conn);
810 switch (READ_ONCE(call->state)) {
811 case RXRPC_CALL_CLIENT_SEND_REQUEST:
812 case RXRPC_CALL_SERVER_ACK_REQUEST:
813 case RXRPC_CALL_SERVER_SEND_REPLY:
814 ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len,
815 notify_end_tx, &dropped_lock);
817 case RXRPC_CALL_COMPLETE:
818 read_lock_bh(&call->state_lock);
820 read_unlock_bh(&call->state_lock);
823 /* Request phase complete for this client call */
824 trace_rxrpc_rx_eproto(call, 0, tracepoint_string("late_send"));
830 mutex_unlock(&call->user_mutex);
831 _leave(" = %d", ret);
834 EXPORT_SYMBOL(rxrpc_kernel_send_data);
837 * rxrpc_kernel_abort_call - Allow a kernel service to abort a call
838 * @sock: The socket the call is on
839 * @call: The call to be aborted
840 * @abort_code: The abort code to stick into the ABORT packet
841 * @error: Local error value
842 * @why: 3-char string indicating why.
844 * Allow a kernel service to abort a call, if it's still in an abortable state
845 * and return true if the call was aborted, false if it was already complete.
847 bool rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call,
848 u32 abort_code, int error, const char *why)
852 _enter("{%d},%d,%d,%s", call->debug_id, abort_code, error, why);
854 mutex_lock(&call->user_mutex);
856 aborted = rxrpc_abort_call(why, call, 0, abort_code, error);
858 rxrpc_send_abort_packet(call);
860 mutex_unlock(&call->user_mutex);
863 EXPORT_SYMBOL(rxrpc_kernel_abort_call);
866 * rxrpc_kernel_set_tx_length - Set the total Tx length on a call
867 * @sock: The socket the call is on
868 * @call: The call to be informed
869 * @tx_total_len: The amount of data to be transmitted for this call
871 * Allow a kernel service to set the total transmit length on a call. This
872 * allows buffer-to-packet encrypt-and-copy to be performed.
874 * This function is primarily for use for setting the reply length since the
875 * request length can be set when beginning the call.
877 void rxrpc_kernel_set_tx_length(struct socket *sock, struct rxrpc_call *call,
880 WARN_ON(call->tx_total_len != -1);
881 call->tx_total_len = tx_total_len;
883 EXPORT_SYMBOL(rxrpc_kernel_set_tx_length);