@@ -1890,25 +1890,14 @@ static int srpt_shutdown_session(struct se_session *se_sess)
1890
1890
* ib_destroy_cm_id(), which locks the cm_id spinlock and hence waits until
1891
1891
* this function has finished).
1892
1892
*/
1893
- static void srpt_drain_channel (struct ib_cm_id * cm_id )
1893
+ static void srpt_drain_channel (struct srpt_rdma_ch * ch )
1894
1894
{
1895
- struct srpt_device * sdev ;
1896
- struct srpt_rdma_ch * ch ;
1897
1895
int ret ;
1898
1896
bool do_reset = false;
1899
1897
1900
1898
WARN_ON_ONCE (irqs_disabled ());
1901
1899
1902
- sdev = cm_id -> context ;
1903
- BUG_ON (!sdev );
1904
- spin_lock_irq (& sdev -> spinlock );
1905
- list_for_each_entry (ch , & sdev -> rch_list , list ) {
1906
- if (ch -> cm_id == cm_id ) {
1907
- do_reset = srpt_set_ch_state (ch , CH_DRAINING );
1908
- break ;
1909
- }
1910
- }
1911
- spin_unlock_irq (& sdev -> spinlock );
1900
+ do_reset = srpt_set_ch_state (ch , CH_DRAINING );
1912
1901
1913
1902
if (do_reset ) {
1914
1903
if (ch -> sess )
@@ -1921,34 +1910,6 @@ static void srpt_drain_channel(struct ib_cm_id *cm_id)
1921
1910
}
1922
1911
}
1923
1912
1924
- /**
1925
- * srpt_find_channel() - Look up an RDMA channel.
1926
- * @cm_id: Pointer to the CM ID of the channel to be looked up.
1927
- *
1928
- * Return NULL if no matching RDMA channel has been found.
1929
- */
1930
- static struct srpt_rdma_ch * srpt_find_channel (struct srpt_device * sdev ,
1931
- struct ib_cm_id * cm_id )
1932
- {
1933
- struct srpt_rdma_ch * ch ;
1934
- bool found ;
1935
-
1936
- WARN_ON_ONCE (irqs_disabled ());
1937
- BUG_ON (!sdev );
1938
-
1939
- found = false;
1940
- spin_lock_irq (& sdev -> spinlock );
1941
- list_for_each_entry (ch , & sdev -> rch_list , list ) {
1942
- if (ch -> cm_id == cm_id ) {
1943
- found = true;
1944
- break ;
1945
- }
1946
- }
1947
- spin_unlock_irq (& sdev -> spinlock );
1948
-
1949
- return found ? ch : NULL ;
1950
- }
1951
-
1952
1913
/**
1953
1914
* srpt_release_channel() - Release channel resources.
1954
1915
*
@@ -2132,6 +2093,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
2132
2093
memcpy (ch -> t_port_id , req -> target_port_id , 16 );
2133
2094
ch -> sport = & sdev -> port [param -> port - 1 ];
2134
2095
ch -> cm_id = cm_id ;
2096
+ cm_id -> context = ch ;
2135
2097
/*
2136
2098
* Avoid QUEUE_FULL conditions by limiting the number of buffers used
2137
2099
* for the SRP protocol to the command queue size.
@@ -2285,10 +2247,14 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
2285
2247
return ret ;
2286
2248
}
2287
2249
2288
- static void srpt_cm_rej_recv (struct ib_cm_id * cm_id )
2250
+ static void srpt_cm_rej_recv (struct srpt_rdma_ch * ch ,
2251
+ enum ib_cm_rej_reason reason ,
2252
+ const u8 * private_data ,
2253
+ u8 private_data_len )
2289
2254
{
2290
- pr_info ("Received IB REJ for cm_id %p.\n" , cm_id );
2291
- srpt_drain_channel (cm_id );
2255
+ pr_info ("Received CM REJ for ch %s-%d; reason %d.\n" ,
2256
+ ch -> sess_name , ch -> qp -> qp_num , reason );
2257
+ srpt_drain_channel (ch );
2292
2258
}
2293
2259
2294
2260
/**
@@ -2297,14 +2263,10 @@ static void srpt_cm_rej_recv(struct ib_cm_id *cm_id)
2297
2263
* An IB_CM_RTU_RECEIVED message indicates that the connection is established
2298
2264
* and that the recipient may begin transmitting (RTU = ready to use).
2299
2265
*/
2300
- static void srpt_cm_rtu_recv (struct ib_cm_id * cm_id )
2266
+ static void srpt_cm_rtu_recv (struct srpt_rdma_ch * ch )
2301
2267
{
2302
- struct srpt_rdma_ch * ch ;
2303
2268
int ret ;
2304
2269
2305
- ch = srpt_find_channel (cm_id -> context , cm_id );
2306
- BUG_ON (!ch );
2307
-
2308
2270
if (srpt_set_ch_state (ch , CH_LIVE )) {
2309
2271
struct srpt_recv_ioctx * ioctx , * ioctx_tmp ;
2310
2272
@@ -2323,16 +2285,13 @@ static void srpt_cm_rtu_recv(struct ib_cm_id *cm_id)
2323
2285
/**
2324
2286
* srpt_cm_dreq_recv() - Process reception of a DREQ message.
2325
2287
*/
2326
- static void srpt_cm_dreq_recv (struct ib_cm_id * cm_id )
2288
+ static void srpt_cm_dreq_recv (struct srpt_rdma_ch * ch )
2327
2289
{
2328
- struct srpt_rdma_ch * ch ;
2329
2290
unsigned long flags ;
2330
2291
bool send_drep = false;
2331
2292
2332
- ch = srpt_find_channel (cm_id -> context , cm_id );
2333
- BUG_ON (!ch );
2334
-
2335
- pr_debug ("cm_id= %p ch->state= %d\n" , cm_id , ch -> state );
2293
+ pr_debug ("ch %s-%d state %d\n" , ch -> sess_name , ch -> qp -> qp_num ,
2294
+ ch -> state );
2336
2295
2337
2296
spin_lock_irqsave (& ch -> spinlock , flags );
2338
2297
switch (ch -> state ) {
@@ -2369,6 +2328,7 @@ static void srpt_cm_dreq_recv(struct ib_cm_id *cm_id)
2369
2328
*/
2370
2329
static int srpt_cm_handler (struct ib_cm_id * cm_id , struct ib_cm_event * event )
2371
2330
{
2331
+ struct srpt_rdma_ch * ch = cm_id -> context ;
2372
2332
int ret ;
2373
2333
2374
2334
ret = 0 ;
@@ -2378,27 +2338,31 @@ static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
2378
2338
event -> private_data );
2379
2339
break ;
2380
2340
case IB_CM_REJ_RECEIVED :
2381
- srpt_cm_rej_recv (cm_id );
2341
+ srpt_cm_rej_recv (ch , event -> param .rej_rcvd .reason ,
2342
+ event -> private_data ,
2343
+ IB_CM_REJ_PRIVATE_DATA_SIZE );
2382
2344
break ;
2383
2345
case IB_CM_RTU_RECEIVED :
2384
2346
case IB_CM_USER_ESTABLISHED :
2385
- srpt_cm_rtu_recv (cm_id );
2347
+ srpt_cm_rtu_recv (ch );
2386
2348
break ;
2387
2349
case IB_CM_DREQ_RECEIVED :
2388
- srpt_cm_dreq_recv (cm_id );
2350
+ srpt_cm_dreq_recv (ch );
2389
2351
break ;
2390
2352
case IB_CM_DREP_RECEIVED :
2391
- pr_info ("Received CM DREP message for cm_id %p .\n" ,
2392
- cm_id );
2393
- srpt_drain_channel (cm_id );
2353
+ pr_info ("Received CM DREP message for ch %s-%d .\n" ,
2354
+ ch -> sess_name , ch -> qp -> qp_num );
2355
+ srpt_drain_channel (ch );
2394
2356
break ;
2395
2357
case IB_CM_TIMEWAIT_EXIT :
2396
- pr_info ("Received CM TimeWait exit for cm_id %p.\n" , cm_id );
2397
- srpt_drain_channel (cm_id );
2358
+ pr_info ("Received CM TimeWait exit for ch %s-%d.\n" ,
2359
+ ch -> sess_name , ch -> qp -> qp_num );
2360
+ srpt_drain_channel (ch );
2398
2361
break ;
2399
2362
case IB_CM_REP_ERROR :
2400
- pr_info ("Received CM REP error for cm_id %p.\n" , cm_id );
2401
- srpt_drain_channel (cm_id );
2363
+ pr_info ("Received CM REP error for ch %s-%d.\n" , ch -> sess_name ,
2364
+ ch -> qp -> qp_num );
2365
+ srpt_drain_channel (ch );
2402
2366
break ;
2403
2367
case IB_CM_DREQ_ERROR :
2404
2368
pr_info ("Received CM DREQ ERROR event.\n" );
0 commit comments