Lines Matching +full:atomic +full:- +full:threshold +full:- +full:us
14 * - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
70 if (cp->cp_xmit_rm) { in rds_send_path_reset()
71 rm = cp->cp_xmit_rm; in rds_send_path_reset()
72 cp->cp_xmit_rm = NULL; in rds_send_path_reset()
81 cp->cp_xmit_sg = 0; in rds_send_path_reset()
82 cp->cp_xmit_hdr_off = 0; in rds_send_path_reset()
83 cp->cp_xmit_data_off = 0; in rds_send_path_reset()
84 cp->cp_xmit_atomic_sent = 0; in rds_send_path_reset()
85 cp->cp_xmit_rdma_sent = 0; in rds_send_path_reset()
86 cp->cp_xmit_data_sent = 0; in rds_send_path_reset()
88 cp->cp_conn->c_map_queued = 0; in rds_send_path_reset()
90 cp->cp_unacked_packets = rds_sysctl_max_unacked_packets; in rds_send_path_reset()
91 cp->cp_unacked_bytes = rds_sysctl_max_unacked_bytes; in rds_send_path_reset()
94 spin_lock_irqsave(&cp->cp_lock, flags); in rds_send_path_reset()
95 list_for_each_entry_safe(rm, tmp, &cp->cp_retrans, m_conn_item) { in rds_send_path_reset()
96 set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags); in rds_send_path_reset()
97 set_bit(RDS_MSG_RETRANSMITTED, &rm->m_flags); in rds_send_path_reset()
99 list_splice_init(&cp->cp_retrans, &cp->cp_send_queue); in rds_send_path_reset()
100 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_path_reset()
106 return test_and_set_bit_lock(RDS_IN_XMIT, &cp->cp_flags) == 0; in acquire_in_xmit()
111 clear_bit_unlock(RDS_IN_XMIT, &cp->cp_flags); in release_in_xmit()
115 * the system-wide hashed waitqueue buckets in the fast path only to in release_in_xmit()
118 if (waitqueue_active(&cp->cp_waitq)) in release_in_xmit()
119 wake_up_all(&cp->cp_waitq); in release_in_xmit()
123 * We're making the conscious trade-off here to only send one message
126 * - tx queueing is a simple fifo list
127 * - reassembly is optional and easily done by transports per conn
128 * - no per flow rx lookup at all, straight to the socket
129 * - less per-frag memory and wire overhead
131 * - queued acks can be delayed behind large messages
133 * - small message latency is higher behind queued large messages
134 * - large message latency isn't starved by intervening small sends
138 struct rds_connection *conn = cp->cp_conn; in rds_send_xmit()
156 * avoids blocking the caller and trading per-connection data between in rds_send_xmit()
161 ret = -ENOMEM; in rds_send_xmit()
165 if (rds_destroy_pending(cp->cp_conn)) { in rds_send_xmit()
167 ret = -ENETUNREACH; /* dont requeue send work */ in rds_send_xmit()
179 send_gen = READ_ONCE(cp->cp_send_gen) + 1; in rds_send_xmit()
180 WRITE_ONCE(cp->cp_send_gen, send_gen); in rds_send_xmit()
192 if (conn->c_trans->xmit_path_prepare) in rds_send_xmit()
193 conn->c_trans->xmit_path_prepare(cp); in rds_send_xmit()
201 rm = cp->cp_xmit_rm; in rds_send_xmit()
209 ret = -EAGAIN; in rds_send_xmit()
218 if (!rm && test_and_clear_bit(0, &conn->c_map_queued)) { in rds_send_xmit()
224 rm->data.op_active = 1; in rds_send_xmit()
225 rm->m_inc.i_conn_path = cp; in rds_send_xmit()
226 rm->m_inc.i_conn = cp->cp_conn; in rds_send_xmit()
228 cp->cp_xmit_rm = rm; in rds_send_xmit()
251 spin_lock_irqsave(&cp->cp_lock, flags); in rds_send_xmit()
253 if (!list_empty(&cp->cp_send_queue)) { in rds_send_xmit()
254 rm = list_entry(cp->cp_send_queue.next, in rds_send_xmit()
263 list_move_tail(&rm->m_conn_item, in rds_send_xmit()
264 &cp->cp_retrans); in rds_send_xmit()
267 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_xmit()
279 if (test_bit(RDS_MSG_FLUSH, &rm->m_flags) || in rds_send_xmit()
280 (rm->rdma.op_active && in rds_send_xmit()
281 test_bit(RDS_MSG_RETRANSMITTED, &rm->m_flags))) { in rds_send_xmit()
282 spin_lock_irqsave(&cp->cp_lock, flags); in rds_send_xmit()
283 if (test_and_clear_bit(RDS_MSG_ON_CONN, &rm->m_flags)) in rds_send_xmit()
284 list_move(&rm->m_conn_item, &to_be_dropped); in rds_send_xmit()
285 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_xmit()
290 len = ntohl(rm->m_inc.i_hdr.h_len); in rds_send_xmit()
291 if (cp->cp_unacked_packets == 0 || in rds_send_xmit()
292 cp->cp_unacked_bytes < len) { in rds_send_xmit()
293 set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags); in rds_send_xmit()
295 cp->cp_unacked_packets = in rds_send_xmit()
297 cp->cp_unacked_bytes = in rds_send_xmit()
301 cp->cp_unacked_bytes -= len; in rds_send_xmit()
302 cp->cp_unacked_packets--; in rds_send_xmit()
305 cp->cp_xmit_rm = rm; in rds_send_xmit()
309 if (rm->rdma.op_active && !cp->cp_xmit_rdma_sent) { in rds_send_xmit()
310 rm->m_final_op = &rm->rdma; in rds_send_xmit()
314 set_bit(RDS_MSG_MAPPED, &rm->m_flags); in rds_send_xmit()
315 ret = conn->c_trans->xmit_rdma(conn, &rm->rdma); in rds_send_xmit()
317 clear_bit(RDS_MSG_MAPPED, &rm->m_flags); in rds_send_xmit()
318 wake_up_interruptible(&rm->m_flush_wait); in rds_send_xmit()
321 cp->cp_xmit_rdma_sent = 1; in rds_send_xmit()
325 if (rm->atomic.op_active && !cp->cp_xmit_atomic_sent) { in rds_send_xmit()
326 rm->m_final_op = &rm->atomic; in rds_send_xmit()
330 set_bit(RDS_MSG_MAPPED, &rm->m_flags); in rds_send_xmit()
331 ret = conn->c_trans->xmit_atomic(conn, &rm->atomic); in rds_send_xmit()
333 clear_bit(RDS_MSG_MAPPED, &rm->m_flags); in rds_send_xmit()
334 wake_up_interruptible(&rm->m_flush_wait); in rds_send_xmit()
337 cp->cp_xmit_atomic_sent = 1; in rds_send_xmit()
344 * We permit 0-byte sends; rds-ping depends on this. in rds_send_xmit()
348 if (rm->data.op_nents == 0) { in rds_send_xmit()
352 ops_present = (rm->atomic.op_active || rm->rdma.op_active); in rds_send_xmit()
353 if (rm->atomic.op_active && !rm->atomic.op_silent) in rds_send_xmit()
355 if (rm->rdma.op_active && !rm->rdma.op_silent) in rds_send_xmit()
359 && !rm->m_rdma_cookie) in rds_send_xmit()
360 rm->data.op_active = 0; in rds_send_xmit()
363 if (rm->data.op_active && !cp->cp_xmit_data_sent) { in rds_send_xmit()
364 rm->m_final_op = &rm->data; in rds_send_xmit()
366 ret = conn->c_trans->xmit(conn, rm, in rds_send_xmit()
367 cp->cp_xmit_hdr_off, in rds_send_xmit()
368 cp->cp_xmit_sg, in rds_send_xmit()
369 cp->cp_xmit_data_off); in rds_send_xmit()
373 if (cp->cp_xmit_hdr_off < sizeof(struct rds_header)) { in rds_send_xmit()
375 sizeof(struct rds_header) - in rds_send_xmit()
376 cp->cp_xmit_hdr_off); in rds_send_xmit()
377 cp->cp_xmit_hdr_off += tmp; in rds_send_xmit()
378 ret -= tmp; in rds_send_xmit()
381 sg = &rm->data.op_sg[cp->cp_xmit_sg]; in rds_send_xmit()
383 tmp = min_t(int, ret, sg->length - in rds_send_xmit()
384 cp->cp_xmit_data_off); in rds_send_xmit()
385 cp->cp_xmit_data_off += tmp; in rds_send_xmit()
386 ret -= tmp; in rds_send_xmit()
387 if (cp->cp_xmit_data_off == sg->length) { in rds_send_xmit()
388 cp->cp_xmit_data_off = 0; in rds_send_xmit()
390 cp->cp_xmit_sg++; in rds_send_xmit()
391 BUG_ON(ret != 0 && cp->cp_xmit_sg == in rds_send_xmit()
392 rm->data.op_nents); in rds_send_xmit()
396 if (cp->cp_xmit_hdr_off == sizeof(struct rds_header) && in rds_send_xmit()
397 (cp->cp_xmit_sg == rm->data.op_nents)) in rds_send_xmit()
398 cp->cp_xmit_data_sent = 1; in rds_send_xmit()
406 if (!rm->data.op_active || cp->cp_xmit_data_sent) { in rds_send_xmit()
407 cp->cp_xmit_rm = NULL; in rds_send_xmit()
408 cp->cp_xmit_sg = 0; in rds_send_xmit()
409 cp->cp_xmit_hdr_off = 0; in rds_send_xmit()
410 cp->cp_xmit_data_off = 0; in rds_send_xmit()
411 cp->cp_xmit_rdma_sent = 0; in rds_send_xmit()
412 cp->cp_xmit_atomic_sent = 0; in rds_send_xmit()
413 cp->cp_xmit_data_sent = 0; in rds_send_xmit()
420 if (conn->c_trans->xmit_path_complete) in rds_send_xmit()
421 conn->c_trans->xmit_path_complete(cp); in rds_send_xmit()
440 * call us when more room is available, such as from the tx in rds_send_xmit()
451 raced = send_gen != READ_ONCE(cp->cp_send_gen); in rds_send_xmit()
453 if ((test_bit(0, &conn->c_map_queued) || in rds_send_xmit()
454 !list_empty(&cp->cp_send_queue)) && !raced) { in rds_send_xmit()
458 if (rds_destroy_pending(cp->cp_conn)) in rds_send_xmit()
459 ret = -ENETUNREACH; in rds_send_xmit()
461 queue_delayed_work(rds_wq, &cp->cp_send_w, 1); in rds_send_xmit()
474 u32 len = be32_to_cpu(rm->m_inc.i_hdr.h_len); in rds_send_sndbuf_remove()
476 assert_spin_locked(&rs->rs_lock); in rds_send_sndbuf_remove()
478 BUG_ON(rs->rs_snd_bytes < len); in rds_send_sndbuf_remove()
479 rs->rs_snd_bytes -= len; in rds_send_sndbuf_remove()
481 if (rs->rs_snd_bytes == 0) in rds_send_sndbuf_remove()
490 return be64_to_cpu(rm->m_inc.i_hdr.h_sequence) <= ack; in rds_send_is_acked()
495 * handling code - except that we call here as soon as we get
506 spin_lock_irqsave(&rm->m_rs_lock, flags); in rds_rdma_send_complete()
508 ro = &rm->rdma; in rds_rdma_send_complete()
509 if (test_bit(RDS_MSG_ON_SOCK, &rm->m_flags) && in rds_rdma_send_complete()
510 ro->op_active && ro->op_notify && ro->op_notifier) { in rds_rdma_send_complete()
511 notifier = ro->op_notifier; in rds_rdma_send_complete()
512 rs = rm->m_rs; in rds_rdma_send_complete()
515 notifier->n_status = status; in rds_rdma_send_complete()
516 spin_lock(&rs->rs_lock); in rds_rdma_send_complete()
517 list_add_tail(¬ifier->n_list, &rs->rs_notify_queue); in rds_rdma_send_complete()
518 spin_unlock(&rs->rs_lock); in rds_rdma_send_complete()
520 ro->op_notifier = NULL; in rds_rdma_send_complete()
523 spin_unlock_irqrestore(&rm->m_rs_lock, flags); in rds_rdma_send_complete()
533 * Just like above, except looks at atomic op
542 spin_lock_irqsave(&rm->m_rs_lock, flags); in rds_atomic_send_complete()
544 ao = &rm->atomic; in rds_atomic_send_complete()
545 if (test_bit(RDS_MSG_ON_SOCK, &rm->m_flags) in rds_atomic_send_complete()
546 && ao->op_active && ao->op_notify && ao->op_notifier) { in rds_atomic_send_complete()
547 notifier = ao->op_notifier; in rds_atomic_send_complete()
548 rs = rm->m_rs; in rds_atomic_send_complete()
551 notifier->n_status = status; in rds_atomic_send_complete()
552 spin_lock(&rs->rs_lock); in rds_atomic_send_complete()
553 list_add_tail(¬ifier->n_list, &rs->rs_notify_queue); in rds_atomic_send_complete()
554 spin_unlock(&rs->rs_lock); in rds_atomic_send_complete()
556 ao->op_notifier = NULL; in rds_atomic_send_complete()
559 spin_unlock_irqrestore(&rm->m_rs_lock, flags); in rds_atomic_send_complete()
570 * don't do any locking - we have all the ingredients (message,
579 ro = &rm->rdma; in __rds_send_complete()
580 if (ro->op_active && ro->op_notify && ro->op_notifier) { in __rds_send_complete()
581 ro->op_notifier->n_status = status; in __rds_send_complete()
582 list_add_tail(&ro->op_notifier->n_list, &rs->rs_notify_queue); in __rds_send_complete()
583 ro->op_notifier = NULL; in __rds_send_complete()
586 ao = &rm->atomic; in __rds_send_complete()
587 if (ao->op_active && ao->op_notify && ao->op_notifier) { in __rds_send_complete()
588 ao->op_notifier->n_status = status; in __rds_send_complete()
589 list_add_tail(&ao->op_notifier->n_list, &rs->rs_notify_queue); in __rds_send_complete()
590 ao->op_notifier = NULL; in __rds_send_complete()
593 /* No need to wake the app - caller does this */ in __rds_send_complete()
613 rm = list_entry(messages->next, struct rds_message, in rds_send_remove_from_sock()
615 list_del_init(&rm->m_conn_item); in rds_send_remove_from_sock()
619 * else beat us to removing it from the sock. If we race in rds_send_remove_from_sock()
623 * The message spinlock makes sure nobody clears rm->m_rs in rds_send_remove_from_sock()
627 spin_lock_irqsave(&rm->m_rs_lock, flags); in rds_send_remove_from_sock()
628 if (!test_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) in rds_send_remove_from_sock()
631 if (rs != rm->m_rs) { in rds_send_remove_from_sock()
636 rs = rm->m_rs; in rds_send_remove_from_sock()
642 spin_lock(&rs->rs_lock); in rds_send_remove_from_sock()
644 if (test_and_clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) { in rds_send_remove_from_sock()
645 struct rm_rdma_op *ro = &rm->rdma; in rds_send_remove_from_sock()
648 list_del_init(&rm->m_sock_item); in rds_send_remove_from_sock()
651 if (ro->op_active && ro->op_notifier && in rds_send_remove_from_sock()
652 (ro->op_notify || (ro->op_recverr && status))) { in rds_send_remove_from_sock()
653 notifier = ro->op_notifier; in rds_send_remove_from_sock()
654 list_add_tail(¬ifier->n_list, in rds_send_remove_from_sock()
655 &rs->rs_notify_queue); in rds_send_remove_from_sock()
656 if (!notifier->n_status) in rds_send_remove_from_sock()
657 notifier->n_status = status; in rds_send_remove_from_sock()
658 rm->rdma.op_notifier = NULL; in rds_send_remove_from_sock()
662 spin_unlock(&rs->rs_lock); in rds_send_remove_from_sock()
665 spin_unlock_irqrestore(&rm->m_rs_lock, flags); in rds_send_remove_from_sock()
682 * assigned the m_ack_seq yet - but that's fine as long as tcp_is_acked
692 spin_lock_irqsave(&cp->cp_lock, flags); in rds_send_path_drop_acked()
694 list_for_each_entry_safe(rm, tmp, &cp->cp_retrans, m_conn_item) { in rds_send_path_drop_acked()
698 list_move(&rm->m_conn_item, &list); in rds_send_path_drop_acked()
699 clear_bit(RDS_MSG_ON_CONN, &rm->m_flags); in rds_send_path_drop_acked()
706 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_path_drop_acked()
716 WARN_ON(conn->c_trans->t_mp_capable); in rds_send_drop_acked()
717 rds_send_path_drop_acked(&conn->c_path[0], ack, is_acked); in rds_send_drop_acked()
730 spin_lock_irqsave(&rs->rs_lock, flags); in rds_send_drop_to()
732 list_for_each_entry_safe(rm, tmp, &rs->rs_send_queue, m_sock_item) { in rds_send_drop_to()
734 (!ipv6_addr_equal(&dest->sin6_addr, &rm->m_daddr) || in rds_send_drop_to()
735 dest->sin6_port != rm->m_inc.i_hdr.h_dport)) in rds_send_drop_to()
738 list_move(&rm->m_sock_item, &list); in rds_send_drop_to()
740 clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags); in rds_send_drop_to()
746 spin_unlock_irqrestore(&rs->rs_lock, flags); in rds_send_drop_to()
754 conn = rm->m_inc.i_conn; in rds_send_drop_to()
755 if (conn->c_trans->t_mp_capable) in rds_send_drop_to()
756 cp = rm->m_inc.i_conn_path; in rds_send_drop_to()
758 cp = &conn->c_path[0]; in rds_send_drop_to()
760 spin_lock_irqsave(&cp->cp_lock, flags); in rds_send_drop_to()
762 * Maybe someone else beat us to removing rm from the conn. in rds_send_drop_to()
766 if (!test_and_clear_bit(RDS_MSG_ON_CONN, &rm->m_flags)) { in rds_send_drop_to()
767 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_drop_to()
770 list_del_init(&rm->m_conn_item); in rds_send_drop_to()
771 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_drop_to()
777 spin_lock_irqsave(&rm->m_rs_lock, flags); in rds_send_drop_to()
779 spin_lock(&rs->rs_lock); in rds_send_drop_to()
781 spin_unlock(&rs->rs_lock); in rds_send_drop_to()
783 spin_unlock_irqrestore(&rm->m_rs_lock, flags); in rds_send_drop_to()
792 list_del_init(&rm->m_sock_item); in rds_send_drop_to()
797 * taking m_rs_lock is the only thing that keeps us in rds_send_drop_to()
800 spin_lock_irqsave(&rm->m_rs_lock, flags); in rds_send_drop_to()
802 spin_lock(&rs->rs_lock); in rds_send_drop_to()
804 spin_unlock(&rs->rs_lock); in rds_send_drop_to()
806 spin_unlock_irqrestore(&rm->m_rs_lock, flags); in rds_send_drop_to()
814 * possible that another thread can race with us and remove the
828 len = be32_to_cpu(rm->m_inc.i_hdr.h_len); in rds_send_queue_rm()
832 spin_lock_irqsave(&rs->rs_lock, flags); in rds_send_queue_rm()
836 * and userspace gets -EAGAIN. But poll() indicates there's send in rds_send_queue_rm()
842 if (rs->rs_snd_bytes < rds_sk_sndbuf(rs)) { in rds_send_queue_rm()
843 rs->rs_snd_bytes += len; in rds_send_queue_rm()
848 * throughput hits a certain threshold. in rds_send_queue_rm()
850 if (rs->rs_snd_bytes >= rds_sk_sndbuf(rs) / 2) in rds_send_queue_rm()
851 set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags); in rds_send_queue_rm()
853 list_add_tail(&rm->m_sock_item, &rs->rs_send_queue); in rds_send_queue_rm()
854 set_bit(RDS_MSG_ON_SOCK, &rm->m_flags); in rds_send_queue_rm()
857 rm->m_rs = rs; in rds_send_queue_rm()
861 rds_message_populate_header(&rm->m_inc.i_hdr, sport, dport, 0); in rds_send_queue_rm()
862 rm->m_inc.i_conn = conn; in rds_send_queue_rm()
863 rm->m_inc.i_conn_path = cp; in rds_send_queue_rm()
866 spin_lock(&cp->cp_lock); in rds_send_queue_rm()
867 rm->m_inc.i_hdr.h_sequence = cpu_to_be64(cp->cp_next_tx_seq++); in rds_send_queue_rm()
868 list_add_tail(&rm->m_conn_item, &cp->cp_send_queue); in rds_send_queue_rm()
869 set_bit(RDS_MSG_ON_CONN, &rm->m_flags); in rds_send_queue_rm()
870 spin_unlock(&cp->cp_lock); in rds_send_queue_rm()
873 rm, len, rs, rs->rs_snd_bytes, in rds_send_queue_rm()
874 (unsigned long long)be64_to_cpu(rm->m_inc.i_hdr.h_sequence)); in rds_send_queue_rm()
879 spin_unlock_irqrestore(&rs->rs_lock, flags); in rds_send_queue_rm()
899 return -EINVAL; in rds_rm_size()
903 return -EINVAL; in rds_rm_size()
905 if (cmsg->cmsg_level != SOL_RDS) in rds_rm_size()
908 switch (cmsg->cmsg_type) { in rds_rm_size()
910 if (vct->indx >= vct->len) { in rds_rm_size()
911 vct->len += vct->incr; in rds_rm_size()
913 krealloc(vct->vec, in rds_rm_size()
914 vct->len * in rds_rm_size()
918 vct->len -= vct->incr; in rds_rm_size()
919 return -ENOMEM; in rds_rm_size()
921 vct->vec = tmp_iov; in rds_rm_size()
923 iov = &vct->vec[vct->indx]; in rds_rm_size()
925 vct->indx++; in rds_rm_size()
953 return -EINVAL; in rds_rm_size()
958 if ((msg->msg_flags & MSG_ZEROCOPY) && !zcopy_cookie) in rds_rm_size()
959 return -EINVAL; in rds_rm_size()
963 /* Ensure (DEST, MAP) are never used with (ARGS, ATOMIC) */ in rds_rm_size()
965 return -EINVAL; in rds_rm_size()
975 if (cmsg->cmsg_len < CMSG_LEN(sizeof(*cookie)) || in rds_cmsg_zcopy()
976 !rm->data.op_mmp_znotifier) in rds_cmsg_zcopy()
977 return -EINVAL; in rds_cmsg_zcopy()
979 rm->data.op_mmp_znotifier->z_cookie = *cookie; in rds_cmsg_zcopy()
992 return -EINVAL; in rds_cmsg_send()
994 if (cmsg->cmsg_level != SOL_RDS) in rds_cmsg_send()
998 * rm->rdma.m_rdma_cookie and rm->rdma.m_rdma_mr. in rds_cmsg_send()
1000 switch (cmsg->cmsg_type) { in rds_cmsg_send()
1002 if (ind >= vct->indx) in rds_cmsg_send()
1003 return -ENOMEM; in rds_cmsg_send()
1004 ret = rds_cmsg_rdma_args(rs, rm, cmsg, &vct->vec[ind]); in rds_cmsg_send()
1016 else if (ret == -ENODEV) in rds_cmsg_send()
1020 ret = -EAGAIN; in rds_cmsg_send()
1034 return -EINVAL; in rds_cmsg_send()
1049 if (conn->c_npaths == 0) in rds_send_mprds_hash()
1052 hash = RDS_MPATH_HASH(rs, conn->c_npaths); in rds_send_mprds_hash()
1053 if (conn->c_npaths == 0 && hash != 0) { in rds_send_mprds_hash()
1057 * until it is up to be sure that the non-zero c_path can be in rds_send_mprds_hash()
1059 * c_path in case the connection ends up being non-MP capable. in rds_send_mprds_hash()
1061 if (conn->c_npaths == 0) { in rds_send_mprds_hash()
1067 if (wait_event_interruptible(conn->c_hs_waitq, in rds_send_mprds_hash()
1068 conn->c_npaths != 0)) in rds_send_mprds_hash()
1071 if (conn->c_npaths == 1) in rds_send_mprds_hash()
1084 return -EINVAL; in rds_rdma_bytes()
1086 if (cmsg->cmsg_level != SOL_RDS) in rds_rdma_bytes()
1089 if (cmsg->cmsg_type == RDS_CMSG_RDMA_ARGS) { in rds_rdma_bytes()
1090 if (cmsg->cmsg_len < in rds_rdma_bytes()
1092 return -EINVAL; in rds_rdma_bytes()
1094 *rdma_bytes += args->remote_vec.bytes; in rds_rdma_bytes()
1102 struct sock *sk = sock->sk; in rds_sendmsg()
1104 DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); in rds_sendmsg()
1105 DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name); in rds_sendmsg()
1111 int nonblock = msg->msg_flags & MSG_DONTWAIT; in rds_sendmsg()
1117 bool zcopy = ((msg->msg_flags & MSG_ZEROCOPY) && in rds_sendmsg()
1131 if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_CMSG_COMPAT | MSG_ZEROCOPY)) { in rds_sendmsg()
1132 ret = -EOPNOTSUPP; in rds_sendmsg()
1136 namelen = msg->msg_namelen; in rds_sendmsg()
1139 ret = -EINVAL; in rds_sendmsg()
1142 switch (usin->sin_family) { in rds_sendmsg()
1144 if (usin->sin_addr.s_addr == htonl(INADDR_ANY) || in rds_sendmsg()
1145 usin->sin_addr.s_addr == htonl(INADDR_BROADCAST) || in rds_sendmsg()
1146 ipv4_is_multicast(usin->sin_addr.s_addr)) { in rds_sendmsg()
1147 ret = -EINVAL; in rds_sendmsg()
1150 ipv6_addr_set_v4mapped(usin->sin_addr.s_addr, &daddr); in rds_sendmsg()
1151 dport = usin->sin_port; in rds_sendmsg()
1159 ret = -EINVAL; in rds_sendmsg()
1162 addr_type = ipv6_addr_type(&sin6->sin6_addr); in rds_sendmsg()
1167 ret = -EINVAL; in rds_sendmsg()
1174 addr4 = sin6->sin6_addr.s6_addr32[3]; in rds_sendmsg()
1178 ret = -EINVAL; in rds_sendmsg()
1183 if (sin6->sin6_scope_id == 0) { in rds_sendmsg()
1184 ret = -EINVAL; in rds_sendmsg()
1187 scope_id = sin6->sin6_scope_id; in rds_sendmsg()
1190 daddr = sin6->sin6_addr; in rds_sendmsg()
1191 dport = sin6->sin6_port; in rds_sendmsg()
1197 ret = -EINVAL; in rds_sendmsg()
1201 /* We only care about consistency with ->connect() */ in rds_sendmsg()
1203 daddr = rs->rs_conn_addr; in rds_sendmsg()
1204 dport = rs->rs_conn_port; in rds_sendmsg()
1205 scope_id = rs->rs_bound_scope_id; in rds_sendmsg()
1210 if (ipv6_addr_any(&rs->rs_bound_addr) || ipv6_addr_any(&daddr)) { in rds_sendmsg()
1212 ret = -ENOTCONN; in rds_sendmsg()
1220 ipv6_addr_v4mapped(&rs->rs_bound_addr)) { in rds_sendmsg()
1222 ret = -EOPNOTSUPP; in rds_sendmsg()
1227 * communicating between link local and non-link local address. in rds_sendmsg()
1229 if (scope_id != rs->rs_bound_scope_id) { in rds_sendmsg()
1231 scope_id = rs->rs_bound_scope_id; in rds_sendmsg()
1232 } else if (rs->rs_bound_scope_id) { in rds_sendmsg()
1234 ret = -EINVAL; in rds_sendmsg()
1246 ret = -EMSGSIZE; in rds_sendmsg()
1251 ret = -EMSGSIZE; in rds_sendmsg()
1256 if (rs->rs_transport->t_type != RDS_TRANS_TCP) { in rds_sendmsg()
1257 ret = -EOPNOTSUPP; in rds_sendmsg()
1260 num_sgs = iov_iter_npages(&msg->msg_iter, INT_MAX); in rds_sendmsg()
1269 ret = -ENOMEM; in rds_sendmsg()
1275 rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs); in rds_sendmsg()
1276 if (IS_ERR(rm->data.op_sg)) { in rds_sendmsg()
1277 ret = PTR_ERR(rm->data.op_sg); in rds_sendmsg()
1280 ret = rds_message_copy_from_user(rm, &msg->msg_iter, zcopy); in rds_sendmsg()
1284 rm->data.op_active = 1; in rds_sendmsg()
1286 rm->m_daddr = daddr; in rds_sendmsg()
1290 if (rs->rs_conn && ipv6_addr_equal(&rs->rs_conn->c_faddr, &daddr) && in rds_sendmsg()
1291 rs->rs_tos == rs->rs_conn->c_tos) { in rds_sendmsg()
1292 conn = rs->rs_conn; in rds_sendmsg()
1294 conn = rds_conn_create_outgoing(sock_net(sock->sk), in rds_sendmsg()
1295 &rs->rs_bound_addr, &daddr, in rds_sendmsg()
1296 rs->rs_transport, rs->rs_tos, in rds_sendmsg()
1297 sock->sk->sk_allocation, in rds_sendmsg()
1303 rs->rs_conn = conn; in rds_sendmsg()
1306 if (conn->c_trans->t_mp_capable) in rds_sendmsg()
1307 cpath = &conn->c_path[rds_send_mprds_hash(rs, conn, nonblock)]; in rds_sendmsg()
1309 cpath = &conn->c_path[0]; in rds_sendmsg()
1311 rm->m_conn_path = cpath; in rds_sendmsg()
1318 if (rm->rdma.op_active && !conn->c_trans->xmit_rdma) { in rds_sendmsg()
1320 &rm->rdma, conn->c_trans->xmit_rdma); in rds_sendmsg()
1321 ret = -EOPNOTSUPP; in rds_sendmsg()
1325 if (rm->atomic.op_active && !conn->c_trans->xmit_atomic) { in rds_sendmsg()
1327 &rm->atomic, conn->c_trans->xmit_atomic); in rds_sendmsg()
1328 ret = -EOPNOTSUPP; in rds_sendmsg()
1333 ret = -EAGAIN; in rds_sendmsg()
1340 ret = rds_cong_wait(conn->c_fcong, dport, nonblock, rs); in rds_sendmsg()
1342 rs->rs_seen_congestion = 1; in rds_sendmsg()
1345 while (!rds_send_queue_rm(rs, conn, cpath, rm, rs->rs_bound_port, in rds_sendmsg()
1350 ret = -EAGAIN; in rds_sendmsg()
1356 rs->rs_bound_port, in rds_sendmsg()
1366 ret = -ETIMEDOUT; in rds_sendmsg()
1372 * to retry sends in the rds thread if the transport asks us to. in rds_sendmsg()
1377 if (ret == -ENOMEM || ret == -EAGAIN) { in rds_sendmsg()
1380 if (rds_destroy_pending(cpath->cp_conn)) in rds_sendmsg()
1381 ret = -ENETUNREACH; in rds_sendmsg()
1383 queue_delayed_work(rds_wq, &cpath->cp_send_w, 1); in rds_sendmsg()
1405 rds_rdma_unuse(rs, rds_rdma_cookie_key(rm->m_rdma_cookie), 1); in rds_sendmsg()
1430 ret = -ENOMEM; in rds_send_probe()
1434 rm->m_daddr = cp->cp_conn->c_faddr; in rds_send_probe()
1435 rm->data.op_active = 1; in rds_send_probe()
1439 ret = rds_cong_wait(cp->cp_conn->c_fcong, dport, 1, NULL); in rds_send_probe()
1443 spin_lock_irqsave(&cp->cp_lock, flags); in rds_send_probe()
1444 list_add_tail(&rm->m_conn_item, &cp->cp_send_queue); in rds_send_probe()
1445 set_bit(RDS_MSG_ON_CONN, &rm->m_flags); in rds_send_probe()
1447 rm->m_inc.i_conn = cp->cp_conn; in rds_send_probe()
1448 rm->m_inc.i_conn_path = cp; in rds_send_probe()
1450 rds_message_populate_header(&rm->m_inc.i_hdr, sport, dport, in rds_send_probe()
1451 cp->cp_next_tx_seq); in rds_send_probe()
1452 rm->m_inc.i_hdr.h_flags |= h_flags; in rds_send_probe()
1453 cp->cp_next_tx_seq++; in rds_send_probe()
1456 cp->cp_conn->c_trans->t_mp_capable) { in rds_send_probe()
1458 u32 my_gen_num = cpu_to_be32(cp->cp_conn->c_my_gen_num); in rds_send_probe()
1460 rds_message_add_extension(&rm->m_inc.i_hdr, in rds_send_probe()
1463 rds_message_add_extension(&rm->m_inc.i_hdr, in rds_send_probe()
1468 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_probe()
1475 if (!rds_destroy_pending(cp->cp_conn)) in rds_send_probe()
1476 queue_delayed_work(rds_wq, &cp->cp_send_w, 1); in rds_send_probe()
1498 struct rds_conn_path *cp = &conn->c_path[cp_index]; in rds_send_ping()
1500 spin_lock_irqsave(&cp->cp_lock, flags); in rds_send_ping()
1501 if (conn->c_ping_triggered) { in rds_send_ping()
1502 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_ping()
1505 conn->c_ping_triggered = 1; in rds_send_ping()
1506 spin_unlock_irqrestore(&cp->cp_lock, flags); in rds_send_ping()