@@ -165,19 +165,12 @@ static inline bool smc_cdc_before(u16 seq1, u16 seq2)
165165}
166166
167167static void smc_cdc_msg_recv_action (struct smc_sock * smc ,
168- struct smc_link * link ,
169168 struct smc_cdc_msg * cdc )
170169{
171170 union smc_host_cursor cons_old , prod_old ;
172171 struct smc_connection * conn = & smc -> conn ;
173172 int diff_cons , diff_prod ;
174173
175- if (!cdc -> prod_flags .failover_validation ) {
176- if (smc_cdc_before (ntohs (cdc -> seqno ),
177- conn -> local_rx_ctrl .seqno ))
178- /* received seqno is old */
179- return ;
180- }
181174 smc_curs_write (& prod_old ,
182175 smc_curs_read (& conn -> local_rx_ctrl .prod , conn ),
183176 conn );
@@ -236,26 +229,11 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
236229}
237230
238231/* called under tasklet context */
239- static inline void smc_cdc_msg_recv (struct smc_cdc_msg * cdc ,
240- struct smc_link * link , u64 wr_id )
232+ static void smc_cdc_msg_recv (struct smc_sock * smc , struct smc_cdc_msg * cdc )
241233{
242- struct smc_link_group * lgr = container_of (link , struct smc_link_group ,
243- lnk [SMC_SINGLE_LINK ]);
244- struct smc_connection * connection ;
245- struct smc_sock * smc ;
246-
247- /* lookup connection */
248- read_lock_bh (& lgr -> conns_lock );
249- connection = smc_lgr_find_conn (ntohl (cdc -> token ), lgr );
250- if (!connection ) {
251- read_unlock_bh (& lgr -> conns_lock );
252- return ;
253- }
254- smc = container_of (connection , struct smc_sock , conn );
255234 sock_hold (& smc -> sk );
256- read_unlock_bh (& lgr -> conns_lock );
257235 bh_lock_sock (& smc -> sk );
258- smc_cdc_msg_recv_action (smc , link , cdc );
236+ smc_cdc_msg_recv_action (smc , cdc );
259237 bh_unlock_sock (& smc -> sk );
260238 sock_put (& smc -> sk ); /* no free sk in softirq-context */
261239}
@@ -266,12 +244,31 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf)
266244{
267245 struct smc_link * link = (struct smc_link * )wc -> qp -> qp_context ;
268246 struct smc_cdc_msg * cdc = buf ;
247+ struct smc_connection * conn ;
248+ struct smc_link_group * lgr ;
249+ struct smc_sock * smc ;
269250
270251 if (wc -> byte_len < offsetof(struct smc_cdc_msg , reserved ))
271252 return ; /* short message */
272253 if (cdc -> len != SMC_WR_TX_SIZE )
273254 return ; /* invalid message */
274- smc_cdc_msg_recv (cdc , link , wc -> wr_id );
255+
256+ /* lookup connection */
257+ lgr = container_of (link , struct smc_link_group , lnk [SMC_SINGLE_LINK ]);
258+ read_lock_bh (& lgr -> conns_lock );
259+ conn = smc_lgr_find_conn (ntohl (cdc -> token ), lgr );
260+ read_unlock_bh (& lgr -> conns_lock );
261+ if (!conn )
262+ return ;
263+ smc = container_of (conn , struct smc_sock , conn );
264+
265+ if (!cdc -> prod_flags .failover_validation ) {
266+ if (smc_cdc_before (ntohs (cdc -> seqno ),
267+ conn -> local_rx_ctrl .seqno ))
268+ /* received seqno is old */
269+ return ;
270+ }
271+ smc_cdc_msg_recv (smc , cdc );
275272}
276273
277274static struct smc_wr_rx_handler smc_cdc_rx_handlers [] = {
0 commit comments