diff options
author | Vu Pham <vu@mellanox.com> | 2013-08-28 16:23:34 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-09-10 19:48:50 -0400 |
commit | d40945d8c2fbbff8adb6f35cc3e268df4934eb2a (patch) | |
tree | 29dd17cc85d3f273652e70230d57cae2fa35f2ac /drivers/infiniband | |
parent | 90ecc6e251c06971a13f5b7bae0d7e29dffd0c6c (diff) |
iser-target: generalize rdma memory registration and cleanup
Current driver uses global dma key to register the memory pointed
by sg list provided by the target core.
This is the preparation step for adding more methods like fast
path memory registration, make the reg/unreg calls be function
pointers.
Signed-off-by: Vu Pham <vu@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 22 | ||||
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.h | 5 |
2 files changed, 23 insertions, 4 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 14fd0f401c3d..4c3d66009237 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -41,6 +41,12 @@ static struct workqueue_struct *isert_rx_wq; | |||
41 | static struct workqueue_struct *isert_comp_wq; | 41 | static struct workqueue_struct *isert_comp_wq; |
42 | 42 | ||
43 | static void | 43 | static void |
44 | isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn); | ||
45 | static int | ||
46 | isert_map_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | ||
47 | struct isert_rdma_wr *wr); | ||
48 | |||
49 | static void | ||
44 | isert_qp_event_callback(struct ib_event *e, void *context) | 50 | isert_qp_event_callback(struct ib_event *e, void *context) |
45 | { | 51 | { |
46 | struct isert_conn *isert_conn = (struct isert_conn *)context; | 52 | struct isert_conn *isert_conn = (struct isert_conn *)context; |
@@ -211,6 +217,10 @@ isert_create_device_ib_res(struct isert_device *device) | |||
211 | struct isert_cq_desc *cq_desc; | 217 | struct isert_cq_desc *cq_desc; |
212 | int ret = 0, i, j; | 218 | int ret = 0, i, j; |
213 | 219 | ||
220 | /* asign function handlers */ | ||
221 | device->reg_rdma_mem = isert_map_rdma; | ||
222 | device->unreg_rdma_mem = isert_unmap_cmd; | ||
223 | |||
214 | device->cqs_used = min_t(int, num_online_cpus(), | 224 | device->cqs_used = min_t(int, num_online_cpus(), |
215 | device->ib_device->num_comp_vectors); | 225 | device->ib_device->num_comp_vectors); |
216 | device->cqs_used = min(ISERT_MAX_CQ, device->cqs_used); | 226 | device->cqs_used = min(ISERT_MAX_CQ, device->cqs_used); |
@@ -1261,6 +1271,7 @@ isert_put_cmd(struct isert_cmd *isert_cmd) | |||
1261 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; | 1271 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1262 | struct isert_conn *isert_conn = isert_cmd->conn; | 1272 | struct isert_conn *isert_conn = isert_cmd->conn; |
1263 | struct iscsi_conn *conn = isert_conn->conn; | 1273 | struct iscsi_conn *conn = isert_conn->conn; |
1274 | struct isert_device *device = isert_conn->conn_device; | ||
1264 | 1275 | ||
1265 | pr_debug("Entering isert_put_cmd: %p\n", isert_cmd); | 1276 | pr_debug("Entering isert_put_cmd: %p\n", isert_cmd); |
1266 | 1277 | ||
@@ -1274,7 +1285,7 @@ isert_put_cmd(struct isert_cmd *isert_cmd) | |||
1274 | if (cmd->data_direction == DMA_TO_DEVICE) | 1285 | if (cmd->data_direction == DMA_TO_DEVICE) |
1275 | iscsit_stop_dataout_timer(cmd); | 1286 | iscsit_stop_dataout_timer(cmd); |
1276 | 1287 | ||
1277 | isert_unmap_cmd(isert_cmd, isert_conn); | 1288 | device->unreg_rdma_mem(isert_cmd, isert_conn); |
1278 | transport_generic_free_cmd(&cmd->se_cmd, 0); | 1289 | transport_generic_free_cmd(&cmd->se_cmd, 0); |
1279 | break; | 1290 | break; |
1280 | case ISCSI_OP_SCSI_TMFUNC: | 1291 | case ISCSI_OP_SCSI_TMFUNC: |
@@ -1348,9 +1359,10 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc, | |||
1348 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; | 1359 | struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; |
1349 | struct se_cmd *se_cmd = &cmd->se_cmd; | 1360 | struct se_cmd *se_cmd = &cmd->se_cmd; |
1350 | struct isert_conn *isert_conn = isert_cmd->conn; | 1361 | struct isert_conn *isert_conn = isert_cmd->conn; |
1362 | struct isert_device *device = isert_conn->conn_device; | ||
1351 | 1363 | ||
1352 | iscsit_stop_dataout_timer(cmd); | 1364 | iscsit_stop_dataout_timer(cmd); |
1353 | isert_unmap_cmd(isert_cmd, isert_conn); | 1365 | device->unreg_rdma_mem(isert_cmd, isert_conn); |
1354 | cmd->write_data_done = wr->cur_rdma_length; | 1366 | cmd->write_data_done = wr->cur_rdma_length; |
1355 | 1367 | ||
1356 | pr_debug("Cmd: %p RDMA_READ comp calling execute_cmd\n", isert_cmd); | 1368 | pr_debug("Cmd: %p RDMA_READ comp calling execute_cmd\n", isert_cmd); |
@@ -1936,13 +1948,14 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | |||
1936 | struct isert_cmd, iscsi_cmd); | 1948 | struct isert_cmd, iscsi_cmd); |
1937 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | 1949 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; |
1938 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1950 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1951 | struct isert_device *device = isert_conn->conn_device; | ||
1939 | struct ib_send_wr *wr_failed; | 1952 | struct ib_send_wr *wr_failed; |
1940 | int rc; | 1953 | int rc; |
1941 | 1954 | ||
1942 | pr_debug("Cmd: %p RDMA_WRITE data_length: %u\n", | 1955 | pr_debug("Cmd: %p RDMA_WRITE data_length: %u\n", |
1943 | isert_cmd, se_cmd->data_length); | 1956 | isert_cmd, se_cmd->data_length); |
1944 | wr->iser_ib_op = ISER_IB_RDMA_WRITE; | 1957 | wr->iser_ib_op = ISER_IB_RDMA_WRITE; |
1945 | rc = isert_map_rdma(conn, cmd, wr); | 1958 | rc = device->reg_rdma_mem(conn, cmd, wr); |
1946 | if (rc) { | 1959 | if (rc) { |
1947 | pr_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); | 1960 | pr_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); |
1948 | return rc; | 1961 | return rc; |
@@ -1977,13 +1990,14 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) | |||
1977 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); | 1990 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
1978 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; | 1991 | struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; |
1979 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; | 1992 | struct isert_conn *isert_conn = (struct isert_conn *)conn->context; |
1993 | struct isert_device *device = isert_conn->conn_device; | ||
1980 | struct ib_send_wr *wr_failed; | 1994 | struct ib_send_wr *wr_failed; |
1981 | int rc; | 1995 | int rc; |
1982 | 1996 | ||
1983 | pr_debug("Cmd: %p RDMA_READ data_length: %u write_data_done: %u\n", | 1997 | pr_debug("Cmd: %p RDMA_READ data_length: %u write_data_done: %u\n", |
1984 | isert_cmd, se_cmd->data_length, cmd->write_data_done); | 1998 | isert_cmd, se_cmd->data_length, cmd->write_data_done); |
1985 | wr->iser_ib_op = ISER_IB_RDMA_READ; | 1999 | wr->iser_ib_op = ISER_IB_RDMA_READ; |
1986 | rc = isert_map_rdma(conn, cmd, wr); | 2000 | rc = device->reg_rdma_mem(conn, cmd, wr); |
1987 | if (rc) { | 2001 | if (rc) { |
1988 | pr_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); | 2002 | pr_err("Cmd: %p failed to prepare RDMA res\n", isert_cmd); |
1989 | return rc; | 2003 | return rc; |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index 21ffd4eff004..76565030e4e7 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h | |||
@@ -128,6 +128,11 @@ struct isert_device { | |||
128 | struct ib_cq *dev_tx_cq[ISERT_MAX_CQ]; | 128 | struct ib_cq *dev_tx_cq[ISERT_MAX_CQ]; |
129 | struct isert_cq_desc *cq_desc; | 129 | struct isert_cq_desc *cq_desc; |
130 | struct list_head dev_node; | 130 | struct list_head dev_node; |
131 | int (*reg_rdma_mem)(struct iscsi_conn *conn, | ||
132 | struct iscsi_cmd *cmd, | ||
133 | struct isert_rdma_wr *wr); | ||
134 | void (*unreg_rdma_mem)(struct isert_cmd *isert_cmd, | ||
135 | struct isert_conn *isert_conn); | ||
131 | }; | 136 | }; |
132 | 137 | ||
133 | struct isert_np { | 138 | struct isert_np { |