diff options
author | Bart Van Assche <bart.vanassche@sandisk.com> | 2016-02-11 14:07:49 -0500 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-02-29 17:12:35 -0500 |
commit | 2739b592d360fd2031262c034f0f73f6f4b7c394 (patch) | |
tree | 548fb7b13d7b117a4768023c93add40f44dc8ff4 | |
parent | 1e20a2a5107021144fd795bcb66a272fd80cb477 (diff) |
IB/srpt: Eliminate srpt_find_channel()
In the CM REQ message handler, store the channel pointer in
cm_id->context such that the function srpt_find_channel() is no
longer needed. Additionally, make the CM event messages more
informative.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Alex Estrin <alex.estrin@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/infiniband/ulp/srpt/ib_srpt.c | 94 |
1 files changed, 29 insertions, 65 deletions
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index ea7359447590..10bc1333a62c 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c | |||
@@ -1890,25 +1890,14 @@ static int srpt_shutdown_session(struct se_session *se_sess) | |||
1890 | * ib_destroy_cm_id(), which locks the cm_id spinlock and hence waits until | 1890 | * ib_destroy_cm_id(), which locks the cm_id spinlock and hence waits until |
1891 | * this function has finished). | 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 | int ret; | 1895 | int ret; |
1898 | bool do_reset = false; | 1896 | bool do_reset = false; |
1899 | 1897 | ||
1900 | WARN_ON_ONCE(irqs_disabled()); | 1898 | WARN_ON_ONCE(irqs_disabled()); |
1901 | 1899 | ||
1902 | sdev = cm_id->context; | 1900 | do_reset = srpt_set_ch_state(ch, CH_DRAINING); |
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); | ||
1912 | 1901 | ||
1913 | if (do_reset) { | 1902 | if (do_reset) { |
1914 | if (ch->sess) | 1903 | if (ch->sess) |
@@ -1922,34 +1911,6 @@ static void srpt_drain_channel(struct ib_cm_id *cm_id) | |||
1922 | } | 1911 | } |
1923 | 1912 | ||
1924 | /** | 1913 | /** |
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 | /** | ||
1953 | * srpt_release_channel() - Release channel resources. | 1914 | * srpt_release_channel() - Release channel resources. |
1954 | * | 1915 | * |
1955 | * Schedules the actual release because: | 1916 | * Schedules the actual release because: |
@@ -2132,6 +2093,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, | |||
2132 | memcpy(ch->t_port_id, req->target_port_id, 16); | 2093 | memcpy(ch->t_port_id, req->target_port_id, 16); |
2133 | ch->sport = &sdev->port[param->port - 1]; | 2094 | ch->sport = &sdev->port[param->port - 1]; |
2134 | ch->cm_id = cm_id; | 2095 | ch->cm_id = cm_id; |
2096 | cm_id->context = ch; | ||
2135 | /* | 2097 | /* |
2136 | * Avoid QUEUE_FULL conditions by limiting the number of buffers used | 2098 | * Avoid QUEUE_FULL conditions by limiting the number of buffers used |
2137 | * for the SRP protocol to the command queue size. | 2099 | * for the SRP protocol to the command queue size. |
@@ -2285,10 +2247,14 @@ out: | |||
2285 | return ret; | 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); | 2255 | pr_info("Received CM REJ for ch %s-%d; reason %d.\n", |
2291 | srpt_drain_channel(cm_id); | 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 | * An IB_CM_RTU_RECEIVED message indicates that the connection is established | 2263 | * An IB_CM_RTU_RECEIVED message indicates that the connection is established |
2298 | * and that the recipient may begin transmitting (RTU = ready to use). | 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 | int ret; | 2268 | int ret; |
2304 | 2269 | ||
2305 | ch = srpt_find_channel(cm_id->context, cm_id); | ||
2306 | BUG_ON(!ch); | ||
2307 | |||
2308 | if (srpt_set_ch_state(ch, CH_LIVE)) { | 2270 | if (srpt_set_ch_state(ch, CH_LIVE)) { |
2309 | struct srpt_recv_ioctx *ioctx, *ioctx_tmp; | 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 | * srpt_cm_dreq_recv() - Process reception of a DREQ message. | 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 | unsigned long flags; | 2290 | unsigned long flags; |
2330 | bool send_drep = false; | 2291 | bool send_drep = false; |
2331 | 2292 | ||
2332 | ch = srpt_find_channel(cm_id->context, cm_id); | 2293 | pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num, |
2333 | BUG_ON(!ch); | 2294 | ch->state); |
2334 | |||
2335 | pr_debug("cm_id= %p ch->state= %d\n", cm_id, ch->state); | ||
2336 | 2295 | ||
2337 | spin_lock_irqsave(&ch->spinlock, flags); | 2296 | spin_lock_irqsave(&ch->spinlock, flags); |
2338 | switch (ch->state) { | 2297 | switch (ch->state) { |
@@ -2369,6 +2328,7 @@ static void srpt_cm_dreq_recv(struct ib_cm_id *cm_id) | |||
2369 | */ | 2328 | */ |
2370 | static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | 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 | int ret; | 2332 | int ret; |
2373 | 2333 | ||
2374 | ret = 0; | 2334 | ret = 0; |
@@ -2378,27 +2338,31 @@ static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | |||
2378 | event->private_data); | 2338 | event->private_data); |
2379 | break; | 2339 | break; |
2380 | case IB_CM_REJ_RECEIVED: | 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 | break; | 2344 | break; |
2383 | case IB_CM_RTU_RECEIVED: | 2345 | case IB_CM_RTU_RECEIVED: |
2384 | case IB_CM_USER_ESTABLISHED: | 2346 | case IB_CM_USER_ESTABLISHED: |
2385 | srpt_cm_rtu_recv(cm_id); | 2347 | srpt_cm_rtu_recv(ch); |
2386 | break; | 2348 | break; |
2387 | case IB_CM_DREQ_RECEIVED: | 2349 | case IB_CM_DREQ_RECEIVED: |
2388 | srpt_cm_dreq_recv(cm_id); | 2350 | srpt_cm_dreq_recv(ch); |
2389 | break; | 2351 | break; |
2390 | case IB_CM_DREP_RECEIVED: | 2352 | case IB_CM_DREP_RECEIVED: |
2391 | pr_info("Received CM DREP message for cm_id %p.\n", | 2353 | pr_info("Received CM DREP message for ch %s-%d.\n", |
2392 | cm_id); | 2354 | ch->sess_name, ch->qp->qp_num); |
2393 | srpt_drain_channel(cm_id); | 2355 | srpt_drain_channel(ch); |
2394 | break; | 2356 | break; |
2395 | case IB_CM_TIMEWAIT_EXIT: | 2357 | case IB_CM_TIMEWAIT_EXIT: |
2396 | pr_info("Received CM TimeWait exit for cm_id %p.\n", cm_id); | 2358 | pr_info("Received CM TimeWait exit for ch %s-%d.\n", |
2397 | srpt_drain_channel(cm_id); | 2359 | ch->sess_name, ch->qp->qp_num); |
2360 | srpt_drain_channel(ch); | ||
2398 | break; | 2361 | break; |
2399 | case IB_CM_REP_ERROR: | 2362 | case IB_CM_REP_ERROR: |
2400 | pr_info("Received CM REP error for cm_id %p.\n", cm_id); | 2363 | pr_info("Received CM REP error for ch %s-%d.\n", ch->sess_name, |
2401 | srpt_drain_channel(cm_id); | 2364 | ch->qp->qp_num); |
2365 | srpt_drain_channel(ch); | ||
2402 | break; | 2366 | break; |
2403 | case IB_CM_DREQ_ERROR: | 2367 | case IB_CM_DREQ_ERROR: |
2404 | pr_info("Received CM DREQ ERROR event.\n"); | 2368 | pr_info("Received CM DREQ ERROR event.\n"); |