Merge branch 'smc-next'

Ursula Braun says:

====================
net/smc: patches 2018-07-23

here are some small patches for SMC: Just the first patch contains a
functional change. It allows to differ between the modes SMCR and SMCD
on s390 when monitoring SMC sockets. The remaining patches are cleanups
without functional changes.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2018-07-23 10:57:14 -07:00
commit 6a525818b1
12 changed files with 84 additions and 155 deletions

View file

@ -20,7 +20,7 @@ struct smc_diag_req {
struct smc_diag_msg { struct smc_diag_msg {
__u8 diag_family; __u8 diag_family;
__u8 diag_state; __u8 diag_state;
__u8 diag_fallback; __u8 diag_mode;
__u8 diag_shutdown; __u8 diag_shutdown;
struct inet_diag_sockid id; struct inet_diag_sockid id;
@ -28,6 +28,13 @@ struct smc_diag_msg {
__u64 diag_inode; __u64 diag_inode;
}; };
/* Mode of a connection */
enum {
SMC_DIAG_MODE_SMCR,
SMC_DIAG_MODE_FALLBACK_TCP,
SMC_DIAG_MODE_SMCD,
};
/* Extensions */ /* Extensions */
enum { enum {

View file

@ -1755,12 +1755,8 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,
smc->sk.sk_state == SMC_CLOSED) { smc->sk.sk_state == SMC_CLOSED) {
answ = 0; answ = 0;
} else { } else {
smc_curs_write(&cons, smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
smc_curs_read(&conn->local_tx_ctrl.cons, conn), smc_curs_copy(&urg, &conn->urg_curs, conn);
conn);
smc_curs_write(&urg,
smc_curs_read(&conn->urg_curs, conn),
conn);
answ = smc_curs_diff(conn->rmb_desc->len, answ = smc_curs_diff(conn->rmb_desc->len,
&cons, &urg) == 1; &cons, &urg) == 1;
} }

View file

@ -34,14 +34,15 @@ static void smc_cdc_tx_handler(struct smc_wr_tx_pend_priv *pnd_snd,
enum ib_wc_status wc_status) enum ib_wc_status wc_status)
{ {
struct smc_cdc_tx_pend *cdcpend = (struct smc_cdc_tx_pend *)pnd_snd; struct smc_cdc_tx_pend *cdcpend = (struct smc_cdc_tx_pend *)pnd_snd;
struct smc_connection *conn = cdcpend->conn;
struct smc_sock *smc; struct smc_sock *smc;
int diff; int diff;
if (!cdcpend->conn) if (!conn)
/* already dismissed */ /* already dismissed */
return; return;
smc = container_of(cdcpend->conn, struct smc_sock, conn); smc = container_of(conn, struct smc_sock, conn);
bh_lock_sock(&smc->sk); bh_lock_sock(&smc->sk);
if (!wc_status) { if (!wc_status) {
diff = smc_curs_diff(cdcpend->conn->sndbuf_desc->len, diff = smc_curs_diff(cdcpend->conn->sndbuf_desc->len,
@ -52,9 +53,7 @@ static void smc_cdc_tx_handler(struct smc_wr_tx_pend_priv *pnd_snd,
atomic_add(diff, &cdcpend->conn->sndbuf_space); atomic_add(diff, &cdcpend->conn->sndbuf_space);
/* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */ /* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
smp_mb__after_atomic(); smp_mb__after_atomic();
smc_curs_write(&cdcpend->conn->tx_curs_fin, smc_curs_copy(&conn->tx_curs_fin, &cdcpend->cursor, conn);
smc_curs_read(&cdcpend->cursor, cdcpend->conn),
cdcpend->conn);
} }
smc_tx_sndbuf_nonfull(smc); smc_tx_sndbuf_nonfull(smc);
bh_unlock_sock(&smc->sk); bh_unlock_sock(&smc->sk);
@ -110,9 +109,8 @@ int smc_cdc_msg_send(struct smc_connection *conn,
&conn->local_tx_ctrl, conn); &conn->local_tx_ctrl, conn);
rc = smc_wr_tx_send(link, (struct smc_wr_tx_pend_priv *)pend); rc = smc_wr_tx_send(link, (struct smc_wr_tx_pend_priv *)pend);
if (!rc) if (!rc)
smc_curs_write(&conn->rx_curs_confirmed, smc_curs_copy(&conn->rx_curs_confirmed,
smc_curs_read(&conn->local_tx_ctrl.cons, conn), &conn->local_tx_ctrl.cons, conn);
conn);
return rc; return rc;
} }
@ -194,8 +192,8 @@ int smcd_cdc_msg_send(struct smc_connection *conn)
rc = smcd_tx_ism_write(conn, &cdc, sizeof(cdc), 0, 1); rc = smcd_tx_ism_write(conn, &cdc, sizeof(cdc), 0, 1);
if (rc) if (rc)
return rc; return rc;
smc_curs_write(&conn->rx_curs_confirmed, smc_curs_copy(&conn->rx_curs_confirmed, &conn->local_tx_ctrl.cons,
smc_curs_read(&conn->local_tx_ctrl.cons, conn), conn); conn);
/* Calculate transmitted data and increment free send buffer space */ /* Calculate transmitted data and increment free send buffer space */
diff = smc_curs_diff(conn->sndbuf_desc->len, &conn->tx_curs_fin, diff = smc_curs_diff(conn->sndbuf_desc->len, &conn->tx_curs_fin,
&conn->tx_curs_sent); &conn->tx_curs_sent);
@ -204,8 +202,7 @@ int smcd_cdc_msg_send(struct smc_connection *conn)
atomic_add(diff, &conn->sndbuf_space); atomic_add(diff, &conn->sndbuf_space);
/* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */ /* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
smp_mb__after_atomic(); smp_mb__after_atomic();
smc_curs_write(&conn->tx_curs_fin, smc_curs_copy(&conn->tx_curs_fin, &conn->tx_curs_sent, conn);
smc_curs_read(&conn->tx_curs_sent, conn), conn);
smc_tx_sndbuf_nonfull(smc); smc_tx_sndbuf_nonfull(smc);
return rc; return rc;
@ -225,9 +222,7 @@ static void smc_cdc_handle_urg_data_arrival(struct smc_sock *smc,
char *base; char *base;
/* new data included urgent business */ /* new data included urgent business */
smc_curs_write(&conn->urg_curs, smc_curs_copy(&conn->urg_curs, &conn->local_rx_ctrl.prod, conn);
smc_curs_read(&conn->local_rx_ctrl.prod, conn),
conn);
conn->urg_state = SMC_URG_VALID; conn->urg_state = SMC_URG_VALID;
if (!sock_flag(&smc->sk, SOCK_URGINLINE)) if (!sock_flag(&smc->sk, SOCK_URGINLINE))
/* we'll skip the urgent byte, so don't account for it */ /* we'll skip the urgent byte, so don't account for it */
@ -247,12 +242,8 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
struct smc_connection *conn = &smc->conn; struct smc_connection *conn = &smc->conn;
int diff_cons, diff_prod; int diff_cons, diff_prod;
smc_curs_write(&prod_old, smc_curs_copy(&prod_old, &conn->local_rx_ctrl.prod, conn);
smc_curs_read(&conn->local_rx_ctrl.prod, conn), smc_curs_copy(&cons_old, &conn->local_rx_ctrl.cons, conn);
conn);
smc_curs_write(&cons_old,
smc_curs_read(&conn->local_rx_ctrl.cons, conn),
conn);
smc_cdc_msg_to_host(&conn->local_rx_ctrl, cdc, conn); smc_cdc_msg_to_host(&conn->local_rx_ctrl, cdc, conn);
diff_cons = smc_curs_diff(conn->peer_rmbe_size, &cons_old, diff_cons = smc_curs_diff(conn->peer_rmbe_size, &cons_old,
@ -374,7 +365,7 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf)
return; /* invalid message */ return; /* invalid message */
/* lookup connection */ /* lookup connection */
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]); lgr = smc_get_lgr(link);
read_lock_bh(&lgr->conns_lock); read_lock_bh(&lgr->conns_lock);
conn = smc_lgr_find_conn(ntohl(cdc->token), lgr); conn = smc_lgr_find_conn(ntohl(cdc->token), lgr);
read_unlock_bh(&lgr->conns_lock); read_unlock_bh(&lgr->conns_lock);

View file

@ -104,47 +104,34 @@ static inline u64 smc_curs_read(union smc_host_cursor *curs,
#endif #endif
} }
static inline u64 smc_curs_read_net(union smc_cdc_cursor *curs, /* Copy cursor src into tgt */
struct smc_connection *conn) static inline void smc_curs_copy(union smc_host_cursor *tgt,
union smc_host_cursor *src,
struct smc_connection *conn)
{ {
#ifndef KERNEL_HAS_ATOMIC64 #ifndef KERNEL_HAS_ATOMIC64
unsigned long flags; unsigned long flags;
u64 ret;
spin_lock_irqsave(&conn->acurs_lock, flags); spin_lock_irqsave(&conn->acurs_lock, flags);
ret = curs->acurs; tgt->acurs = src->acurs;
spin_unlock_irqrestore(&conn->acurs_lock, flags); spin_unlock_irqrestore(&conn->acurs_lock, flags);
return ret;
#else #else
return atomic64_read(&curs->acurs); atomic64_set(&tgt->acurs, atomic64_read(&src->acurs));
#endif #endif
} }
static inline void smc_curs_write(union smc_host_cursor *curs, u64 val, static inline void smc_curs_copy_net(union smc_cdc_cursor *tgt,
struct smc_connection *conn) union smc_cdc_cursor *src,
struct smc_connection *conn)
{ {
#ifndef KERNEL_HAS_ATOMIC64 #ifndef KERNEL_HAS_ATOMIC64
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&conn->acurs_lock, flags); spin_lock_irqsave(&conn->acurs_lock, flags);
curs->acurs = val; tgt->acurs = src->acurs;
spin_unlock_irqrestore(&conn->acurs_lock, flags); spin_unlock_irqrestore(&conn->acurs_lock, flags);
#else #else
atomic64_set(&curs->acurs, val); atomic64_set(&tgt->acurs, atomic64_read(&src->acurs));
#endif
}
static inline void smc_curs_write_net(union smc_cdc_cursor *curs, u64 val,
struct smc_connection *conn)
{
#ifndef KERNEL_HAS_ATOMIC64
unsigned long flags;
spin_lock_irqsave(&conn->acurs_lock, flags);
curs->acurs = val;
spin_unlock_irqrestore(&conn->acurs_lock, flags);
#else
atomic64_set(&curs->acurs, val);
#endif #endif
} }
@ -179,7 +166,7 @@ static inline void smc_host_cursor_to_cdc(union smc_cdc_cursor *peer,
{ {
union smc_host_cursor temp; union smc_host_cursor temp;
smc_curs_write(&temp, smc_curs_read(local, conn), conn); smc_curs_copy(&temp, local, conn);
peer->count = htonl(temp.count); peer->count = htonl(temp.count);
peer->wrap = htons(temp.wrap); peer->wrap = htons(temp.wrap);
/* peer->reserved = htons(0); must be ensured by caller */ /* peer->reserved = htons(0); must be ensured by caller */
@ -206,8 +193,8 @@ static inline void smc_cdc_cursor_to_host(union smc_host_cursor *local,
union smc_host_cursor temp, old; union smc_host_cursor temp, old;
union smc_cdc_cursor net; union smc_cdc_cursor net;
smc_curs_write(&old, smc_curs_read(local, conn), conn); smc_curs_copy(&old, local, conn);
smc_curs_write_net(&net, smc_curs_read_net(peer, conn), conn); smc_curs_copy_net(&net, peer, conn);
temp.count = ntohl(net.count); temp.count = ntohl(net.count);
temp.wrap = ntohs(net.wrap); temp.wrap = ntohs(net.wrap);
if ((old.wrap > temp.wrap) && temp.wrap) if ((old.wrap > temp.wrap) && temp.wrap)
@ -215,7 +202,7 @@ static inline void smc_cdc_cursor_to_host(union smc_host_cursor *local,
if ((old.wrap == temp.wrap) && if ((old.wrap == temp.wrap) &&
(old.count > temp.count)) (old.count > temp.count))
return; return;
smc_curs_write(local, smc_curs_read(&temp, conn), conn); smc_curs_copy(local, &temp, conn);
} }
static inline void smcr_cdc_msg_to_host(struct smc_host_cdc_msg *local, static inline void smcr_cdc_msg_to_host(struct smc_host_cdc_msg *local,

View file

@ -192,8 +192,7 @@ struct smc_link_group {
struct smc_rtoken rtokens[SMC_RMBS_PER_LGR_MAX] struct smc_rtoken rtokens[SMC_RMBS_PER_LGR_MAX]
[SMC_LINKS_PER_LGR_MAX]; [SMC_LINKS_PER_LGR_MAX];
/* remote addr/key pairs */ /* remote addr/key pairs */
unsigned long rtokens_used_mask[BITS_TO_LONGS DECLARE_BITMAP(rtokens_used_mask, SMC_RMBS_PER_LGR_MAX);
(SMC_RMBS_PER_LGR_MAX)];
/* used rtoken elements */ /* used rtoken elements */
}; };
struct { /* SMC-D */ struct { /* SMC-D */
@ -266,4 +265,9 @@ int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact,
u64 peer_gid); u64 peer_gid);
void smcd_conn_free(struct smc_connection *conn); void smcd_conn_free(struct smc_connection *conn);
void smc_core_exit(void); void smc_core_exit(void);
static inline struct smc_link_group *smc_get_lgr(struct smc_link *link)
{
return container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
}
#endif #endif

View file

@ -91,7 +91,12 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
r = nlmsg_data(nlh); r = nlmsg_data(nlh);
smc_diag_msg_common_fill(r, sk); smc_diag_msg_common_fill(r, sk);
r->diag_state = sk->sk_state; r->diag_state = sk->sk_state;
r->diag_fallback = smc->use_fallback; if (smc->use_fallback)
r->diag_mode = SMC_DIAG_MODE_FALLBACK_TCP;
else if (smc->conn.lgr && smc->conn.lgr->is_smcd)
r->diag_mode = SMC_DIAG_MODE_SMCD;
else
r->diag_mode = SMC_DIAG_MODE_SMCR;
user_ns = sk_user_ns(NETLINK_CB(cb->skb).sk); user_ns = sk_user_ns(NETLINK_CB(cb->skb).sk);
if (smc_diag_msg_attrs_fill(sk, skb, r, user_ns)) if (smc_diag_msg_attrs_fill(sk, skb, r, user_ns))
goto errout; goto errout;

View file

@ -112,8 +112,7 @@ int smc_ib_modify_qp_reset(struct smc_link *lnk)
int smc_ib_ready_link(struct smc_link *lnk) int smc_ib_ready_link(struct smc_link *lnk)
{ {
struct smc_link_group *lgr = struct smc_link_group *lgr = smc_get_lgr(lnk);
container_of(lnk, struct smc_link_group, lnk[0]);
int rc = 0; int rc = 0;
rc = smc_ib_modify_qp_init(lnk); rc = smc_ib_modify_qp_init(lnk);

View file

@ -186,8 +186,7 @@ int smc_llc_send_confirm_link(struct smc_link *link, u8 mac[],
union ib_gid *gid, union ib_gid *gid,
enum smc_llc_reqresp reqresp) enum smc_llc_reqresp reqresp)
{ {
struct smc_link_group *lgr = container_of(link, struct smc_link_group, struct smc_link_group *lgr = smc_get_lgr(link);
lnk[SMC_SINGLE_LINK]);
struct smc_llc_msg_confirm_link *confllc; struct smc_llc_msg_confirm_link *confllc;
struct smc_wr_tx_pend_priv *pend; struct smc_wr_tx_pend_priv *pend;
struct smc_wr_buf *wr_buf; struct smc_wr_buf *wr_buf;
@ -381,11 +380,9 @@ static int smc_llc_send_message(struct smc_link *link, void *llcbuf, int llclen)
static void smc_llc_rx_confirm_link(struct smc_link *link, static void smc_llc_rx_confirm_link(struct smc_link *link,
struct smc_llc_msg_confirm_link *llc) struct smc_llc_msg_confirm_link *llc)
{ {
struct smc_link_group *lgr; struct smc_link_group *lgr = smc_get_lgr(link);
int conf_rc; int conf_rc;
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
/* RMBE eyecatchers are not supported */ /* RMBE eyecatchers are not supported */
if (llc->hd.flags & SMC_LLC_FLAG_NO_RMBE_EYEC) if (llc->hd.flags & SMC_LLC_FLAG_NO_RMBE_EYEC)
conf_rc = 0; conf_rc = 0;
@ -411,8 +408,7 @@ static void smc_llc_rx_confirm_link(struct smc_link *link,
static void smc_llc_rx_add_link(struct smc_link *link, static void smc_llc_rx_add_link(struct smc_link *link,
struct smc_llc_msg_add_link *llc) struct smc_llc_msg_add_link *llc)
{ {
struct smc_link_group *lgr = container_of(link, struct smc_link_group, struct smc_link_group *lgr = smc_get_lgr(link);
lnk[SMC_SINGLE_LINK]);
if (llc->hd.flags & SMC_LLC_FLAG_RESP) { if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
if (link->state == SMC_LNK_ACTIVATING) if (link->state == SMC_LNK_ACTIVATING)
@ -442,8 +438,7 @@ static void smc_llc_rx_add_link(struct smc_link *link,
static void smc_llc_rx_delete_link(struct smc_link *link, static void smc_llc_rx_delete_link(struct smc_link *link,
struct smc_llc_msg_del_link *llc) struct smc_llc_msg_del_link *llc)
{ {
struct smc_link_group *lgr = container_of(link, struct smc_link_group, struct smc_link_group *lgr = smc_get_lgr(link);
lnk[SMC_SINGLE_LINK]);
if (llc->hd.flags & SMC_LLC_FLAG_RESP) { if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
if (lgr->role == SMC_SERV) if (lgr->role == SMC_SERV)
@ -476,17 +471,14 @@ static void smc_llc_rx_test_link(struct smc_link *link,
static void smc_llc_rx_confirm_rkey(struct smc_link *link, static void smc_llc_rx_confirm_rkey(struct smc_link *link,
struct smc_llc_msg_confirm_rkey *llc) struct smc_llc_msg_confirm_rkey *llc)
{ {
struct smc_link_group *lgr;
int rc; int rc;
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
if (llc->hd.flags & SMC_LLC_FLAG_RESP) { if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
link->llc_confirm_rkey_rc = llc->hd.flags & link->llc_confirm_rkey_rc = llc->hd.flags &
SMC_LLC_FLAG_RKEY_NEG; SMC_LLC_FLAG_RKEY_NEG;
complete(&link->llc_confirm_rkey); complete(&link->llc_confirm_rkey);
} else { } else {
rc = smc_rtoken_add(lgr, rc = smc_rtoken_add(smc_get_lgr(link),
llc->rtoken[0].rmb_vaddr, llc->rtoken[0].rmb_vaddr,
llc->rtoken[0].rmb_key); llc->rtoken[0].rmb_key);
@ -514,18 +506,15 @@ static void smc_llc_rx_confirm_rkey_cont(struct smc_link *link,
static void smc_llc_rx_delete_rkey(struct smc_link *link, static void smc_llc_rx_delete_rkey(struct smc_link *link,
struct smc_llc_msg_delete_rkey *llc) struct smc_llc_msg_delete_rkey *llc)
{ {
struct smc_link_group *lgr;
u8 err_mask = 0; u8 err_mask = 0;
int i, max; int i, max;
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
if (llc->hd.flags & SMC_LLC_FLAG_RESP) { if (llc->hd.flags & SMC_LLC_FLAG_RESP) {
/* unused as long as we don't send this type of msg */ /* unused as long as we don't send this type of msg */
} else { } else {
max = min_t(u8, llc->num_rkeys, SMC_LLC_DEL_RKEY_MAX); max = min_t(u8, llc->num_rkeys, SMC_LLC_DEL_RKEY_MAX);
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
if (smc_rtoken_delete(lgr, llc->rkey[i])) if (smc_rtoken_delete(smc_get_lgr(link), llc->rkey[i]))
err_mask |= 1 << (SMC_LLC_DEL_RKEY_MAX - 1 - i); err_mask |= 1 << (SMC_LLC_DEL_RKEY_MAX - 1 - i);
} }
@ -583,12 +572,10 @@ static void smc_llc_testlink_work(struct work_struct *work)
struct smc_link *link = container_of(to_delayed_work(work), struct smc_link *link = container_of(to_delayed_work(work),
struct smc_link, llc_testlink_wrk); struct smc_link, llc_testlink_wrk);
unsigned long next_interval; unsigned long next_interval;
struct smc_link_group *lgr;
unsigned long expire_time; unsigned long expire_time;
u8 user_data[16] = { 0 }; u8 user_data[16] = { 0 };
int rc; int rc;
lgr = container_of(link, struct smc_link_group, lnk[SMC_SINGLE_LINK]);
if (link->state != SMC_LNK_ACTIVE) if (link->state != SMC_LNK_ACTIVE)
return; /* don't reschedule worker */ return; /* don't reschedule worker */
expire_time = link->wr_rx_tstamp + link->llc_testlink_time; expire_time = link->wr_rx_tstamp + link->llc_testlink_time;
@ -602,7 +589,7 @@ static void smc_llc_testlink_work(struct work_struct *work)
rc = wait_for_completion_interruptible_timeout(&link->llc_testlink_resp, rc = wait_for_completion_interruptible_timeout(&link->llc_testlink_resp,
SMC_LLC_WAIT_TIME); SMC_LLC_WAIT_TIME);
if (rc <= 0) { if (rc <= 0) {
smc_lgr_terminate(lgr); smc_lgr_terminate(smc_get_lgr(link));
return; return;
} }
next_interval = link->llc_testlink_time; next_interval = link->llc_testlink_time;
@ -613,8 +600,7 @@ static void smc_llc_testlink_work(struct work_struct *work)
int smc_llc_link_init(struct smc_link *link) int smc_llc_link_init(struct smc_link *link)
{ {
struct smc_link_group *lgr = container_of(link, struct smc_link_group, struct smc_link_group *lgr = smc_get_lgr(link);
lnk[SMC_SINGLE_LINK]);
link->llc_wq = alloc_ordered_workqueue("llc_wq-%x:%x)", WQ_MEM_RECLAIM, link->llc_wq = alloc_ordered_workqueue("llc_wq-%x:%x)", WQ_MEM_RECLAIM,
*((u32 *)lgr->id), *((u32 *)lgr->id),
link->link_id); link->link_id);

View file

@ -82,8 +82,7 @@ static int smc_rx_update_consumer(struct smc_sock *smc,
} }
} }
smc_curs_write(&conn->local_tx_ctrl.cons, smc_curs_read(&cons, conn), smc_curs_copy(&conn->local_tx_ctrl.cons, &cons, conn);
conn);
/* send consumer cursor update if required */ /* send consumer cursor update if required */
/* similar to advertising new TCP rcv_wnd if required */ /* similar to advertising new TCP rcv_wnd if required */
@ -97,8 +96,7 @@ static void smc_rx_update_cons(struct smc_sock *smc, size_t len)
struct smc_connection *conn = &smc->conn; struct smc_connection *conn = &smc->conn;
union smc_host_cursor cons; union smc_host_cursor cons;
smc_curs_write(&cons, smc_curs_read(&conn->local_tx_ctrl.cons, conn), smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
conn);
smc_rx_update_consumer(smc, cons, len); smc_rx_update_consumer(smc, cons, len);
} }
@ -157,10 +155,8 @@ static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len,
struct splice_pipe_desc spd; struct splice_pipe_desc spd;
struct partial_page partial; struct partial_page partial;
struct smc_spd_priv *priv; struct smc_spd_priv *priv;
struct page *page;
int bytes; int bytes;
page = virt_to_page(smc->conn.rmb_desc->cpu_addr);
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -172,7 +168,7 @@ static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len,
spd.nr_pages_max = 1; spd.nr_pages_max = 1;
spd.nr_pages = 1; spd.nr_pages = 1;
spd.pages = &page; spd.pages = &smc->conn.rmb_desc->pages;
spd.partial = &partial; spd.partial = &partial;
spd.ops = &smc_pipe_ops; spd.ops = &smc_pipe_ops;
spd.spd_release = smc_rx_spd_release; spd.spd_release = smc_rx_spd_release;
@ -245,10 +241,7 @@ static int smc_rx_recv_urg(struct smc_sock *smc, struct msghdr *msg, int len,
if (!(flags & MSG_TRUNC)) if (!(flags & MSG_TRUNC))
rc = memcpy_to_msg(msg, &conn->urg_rx_byte, 1); rc = memcpy_to_msg(msg, &conn->urg_rx_byte, 1);
len = 1; len = 1;
smc_curs_write(&cons, smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
smc_curs_read(&conn->local_tx_ctrl.cons,
conn),
conn);
if (smc_curs_diff(conn->rmb_desc->len, &cons, if (smc_curs_diff(conn->rmb_desc->len, &cons,
&conn->urg_curs) > 1) &conn->urg_curs) > 1)
conn->urg_rx_skip_pend = true; conn->urg_rx_skip_pend = true;
@ -370,9 +363,7 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,
continue; continue;
} }
smc_curs_write(&cons, smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
smc_curs_read(&conn->local_tx_ctrl.cons, conn),
conn);
/* subsequent splice() calls pick up where previous left */ /* subsequent splice() calls pick up where previous left */
if (splbytes) if (splbytes)
smc_curs_add(conn->rmb_desc->len, &cons, splbytes); smc_curs_add(conn->rmb_desc->len, &cons, splbytes);

View file

@ -181,9 +181,7 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
copylen = min_t(size_t, send_remaining, writespace); copylen = min_t(size_t, send_remaining, writespace);
/* determine start of sndbuf */ /* determine start of sndbuf */
sndbuf_base = conn->sndbuf_desc->cpu_addr; sndbuf_base = conn->sndbuf_desc->cpu_addr;
smc_curs_write(&prep, smc_curs_copy(&prep, &conn->tx_curs_prep, conn);
smc_curs_read(&conn->tx_curs_prep, conn),
conn);
tx_cnt_prep = prep.count; tx_cnt_prep = prep.count;
/* determine chunks where to write into sndbuf */ /* determine chunks where to write into sndbuf */
/* either unwrapped case, or 1st chunk of wrapped case */ /* either unwrapped case, or 1st chunk of wrapped case */
@ -214,9 +212,7 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
smc_sndbuf_sync_sg_for_device(conn); smc_sndbuf_sync_sg_for_device(conn);
/* update cursors */ /* update cursors */
smc_curs_add(conn->sndbuf_desc->len, &prep, copylen); smc_curs_add(conn->sndbuf_desc->len, &prep, copylen);
smc_curs_write(&conn->tx_curs_prep, smc_curs_copy(&conn->tx_curs_prep, &prep, conn);
smc_curs_read(&prep, conn),
conn);
/* increased in send tasklet smc_cdc_tx_handler() */ /* increased in send tasklet smc_cdc_tx_handler() */
smp_mb__before_atomic(); smp_mb__before_atomic();
atomic_sub(copylen, &conn->sndbuf_space); atomic_sub(copylen, &conn->sndbuf_space);
@ -417,8 +413,8 @@ static int smc_tx_rdma_writes(struct smc_connection *conn)
int rc; int rc;
/* source: sndbuf */ /* source: sndbuf */
smc_curs_write(&sent, smc_curs_read(&conn->tx_curs_sent, conn), conn); smc_curs_copy(&sent, &conn->tx_curs_sent, conn);
smc_curs_write(&prep, smc_curs_read(&conn->tx_curs_prep, conn), conn); smc_curs_copy(&prep, &conn->tx_curs_prep, conn);
/* cf. wmem_alloc - (snd_max - snd_una) */ /* cf. wmem_alloc - (snd_max - snd_una) */
to_send = smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep); to_send = smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep);
if (to_send <= 0) if (to_send <= 0)
@ -429,12 +425,8 @@ static int smc_tx_rdma_writes(struct smc_connection *conn)
rmbespace = atomic_read(&conn->peer_rmbe_space); rmbespace = atomic_read(&conn->peer_rmbe_space);
if (rmbespace <= 0) if (rmbespace <= 0)
return 0; return 0;
smc_curs_write(&prod, smc_curs_copy(&prod, &conn->local_tx_ctrl.prod, conn);
smc_curs_read(&conn->local_tx_ctrl.prod, conn), smc_curs_copy(&cons, &conn->local_rx_ctrl.cons, conn);
conn);
smc_curs_write(&cons,
smc_curs_read(&conn->local_rx_ctrl.cons, conn),
conn);
/* if usable snd_wnd closes ask peer to advertise once it opens again */ /* if usable snd_wnd closes ask peer to advertise once it opens again */
pflags = &conn->local_tx_ctrl.prod_flags; pflags = &conn->local_tx_ctrl.prod_flags;
@ -481,14 +473,9 @@ static int smc_tx_rdma_writes(struct smc_connection *conn)
pflags->urg_data_present = 1; pflags->urg_data_present = 1;
smc_tx_advance_cursors(conn, &prod, &sent, len); smc_tx_advance_cursors(conn, &prod, &sent, len);
/* update connection's cursors with advanced local cursors */ /* update connection's cursors with advanced local cursors */
smc_curs_write(&conn->local_tx_ctrl.prod, smc_curs_copy(&conn->local_tx_ctrl.prod, &prod, conn);
smc_curs_read(&prod, conn),
conn);
/* dst: peer RMBE */ /* dst: peer RMBE */
smc_curs_write(&conn->tx_curs_sent, smc_curs_copy(&conn->tx_curs_sent, &sent, conn);/* src: local sndbuf */
smc_curs_read(&sent, conn),
conn);
/* src: local sndbuf */
return 0; return 0;
} }
@ -606,17 +593,11 @@ void smc_tx_consumer_update(struct smc_connection *conn, bool force)
int sender_free = conn->rmb_desc->len; int sender_free = conn->rmb_desc->len;
int to_confirm; int to_confirm;
smc_curs_write(&cons, smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
smc_curs_read(&conn->local_tx_ctrl.cons, conn), smc_curs_copy(&cfed, &conn->rx_curs_confirmed, conn);
conn);
smc_curs_write(&cfed,
smc_curs_read(&conn->rx_curs_confirmed, conn),
conn);
to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons); to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons);
if (to_confirm > conn->rmbe_update_limit) { if (to_confirm > conn->rmbe_update_limit) {
smc_curs_write(&prod, smc_curs_copy(&prod, &conn->local_rx_ctrl.prod, conn);
smc_curs_read(&conn->local_rx_ctrl.prod, conn),
conn);
sender_free = conn->rmb_desc->len - sender_free = conn->rmb_desc->len -
smc_curs_diff(conn->rmb_desc->len, &prod, &cfed); smc_curs_diff(conn->rmb_desc->len, &prod, &cfed);
} }
@ -632,9 +613,8 @@ void smc_tx_consumer_update(struct smc_connection *conn, bool force)
SMC_TX_WORK_DELAY); SMC_TX_WORK_DELAY);
return; return;
} }
smc_curs_write(&conn->rx_curs_confirmed, smc_curs_copy(&conn->rx_curs_confirmed,
smc_curs_read(&conn->local_tx_ctrl.cons, conn), &conn->local_tx_ctrl.cons, conn);
conn);
conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0; conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0;
} }
if (conn->local_rx_ctrl.prod_flags.write_blocked && if (conn->local_rx_ctrl.prod_flags.write_blocked &&

View file

@ -22,8 +22,8 @@ static inline int smc_tx_prepared_sends(struct smc_connection *conn)
{ {
union smc_host_cursor sent, prep; union smc_host_cursor sent, prep;
smc_curs_write(&sent, smc_curs_read(&conn->tx_curs_sent, conn), conn); smc_curs_copy(&sent, &conn->tx_curs_sent, conn);
smc_curs_write(&prep, smc_curs_read(&conn->tx_curs_prep, conn), conn); smc_curs_copy(&prep, &conn->tx_curs_prep, conn);
return smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep); return smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep);
} }

View file

@ -92,8 +92,6 @@ static inline void smc_wr_tx_process_cqe(struct ib_wc *wc)
if (!test_and_clear_bit(pnd_snd_idx, link->wr_tx_mask)) if (!test_and_clear_bit(pnd_snd_idx, link->wr_tx_mask))
return; return;
if (wc->status) { if (wc->status) {
struct smc_link_group *lgr;
for_each_set_bit(i, link->wr_tx_mask, link->wr_tx_cnt) { for_each_set_bit(i, link->wr_tx_mask, link->wr_tx_cnt) {
/* clear full struct smc_wr_tx_pend including .priv */ /* clear full struct smc_wr_tx_pend including .priv */
memset(&link->wr_tx_pends[i], 0, memset(&link->wr_tx_pends[i], 0,
@ -103,9 +101,7 @@ static inline void smc_wr_tx_process_cqe(struct ib_wc *wc)
clear_bit(i, link->wr_tx_mask); clear_bit(i, link->wr_tx_mask);
} }
/* terminate connections of this link group abnormally */ /* terminate connections of this link group abnormally */
lgr = container_of(link, struct smc_link_group, smc_lgr_terminate(smc_get_lgr(link));
lnk[SMC_SINGLE_LINK]);
smc_lgr_terminate(lgr);
} }
if (pnd_snd.handler) if (pnd_snd.handler)
pnd_snd.handler(&pnd_snd.priv, link, wc->status); pnd_snd.handler(&pnd_snd.priv, link, wc->status);
@ -188,8 +184,7 @@ int smc_wr_tx_get_free_slot(struct smc_link *link,
} else { } else {
struct smc_link_group *lgr; struct smc_link_group *lgr;
lgr = container_of(link, struct smc_link_group, lgr = smc_get_lgr(link);
lnk[SMC_SINGLE_LINK]);
rc = wait_event_timeout( rc = wait_event_timeout(
link->wr_tx_wait, link->wr_tx_wait,
list_empty(&lgr->list) || /* lgr terminated */ list_empty(&lgr->list) || /* lgr terminated */
@ -250,12 +245,8 @@ int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx], rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx],
&failed_wr); &failed_wr);
if (rc) { if (rc) {
struct smc_link_group *lgr =
container_of(link, struct smc_link_group,
lnk[SMC_SINGLE_LINK]);
smc_wr_tx_put_slot(link, priv); smc_wr_tx_put_slot(link, priv);
smc_lgr_terminate(lgr); smc_lgr_terminate(smc_get_lgr(link));
} }
return rc; return rc;
} }
@ -283,11 +274,7 @@ int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr)
SMC_WR_REG_MR_WAIT_TIME); SMC_WR_REG_MR_WAIT_TIME);
if (!rc) { if (!rc) {
/* timeout - terminate connections */ /* timeout - terminate connections */
struct smc_link_group *lgr; smc_lgr_terminate(smc_get_lgr(link));
lgr = container_of(link, struct smc_link_group,
lnk[SMC_SINGLE_LINK]);
smc_lgr_terminate(lgr);
return -EPIPE; return -EPIPE;
} }
if (rc == -ERESTARTSYS) if (rc == -ERESTARTSYS)
@ -380,8 +367,6 @@ static inline void smc_wr_rx_process_cqes(struct ib_wc wc[], int num)
smc_wr_rx_demultiplex(&wc[i]); smc_wr_rx_demultiplex(&wc[i]);
smc_wr_rx_post(link); /* refill WR RX */ smc_wr_rx_post(link); /* refill WR RX */
} else { } else {
struct smc_link_group *lgr;
/* handle status errors */ /* handle status errors */
switch (wc[i].status) { switch (wc[i].status) {
case IB_WC_RETRY_EXC_ERR: case IB_WC_RETRY_EXC_ERR:
@ -390,9 +375,7 @@ static inline void smc_wr_rx_process_cqes(struct ib_wc wc[], int num)
/* terminate connections of this link group /* terminate connections of this link group
* abnormally * abnormally
*/ */
lgr = container_of(link, struct smc_link_group, smc_lgr_terminate(smc_get_lgr(link));
lnk[SMC_SINGLE_LINK]);
smc_lgr_terminate(lgr);
break; break;
default: default:
smc_wr_rx_post(link); /* refill WR RX */ smc_wr_rx_post(link); /* refill WR RX */