tcp: move some parts from tcp_write_xmit