libcxgbi.c (6a8a2aa62da2fbe51f5449993fd366398048f465) libcxgbi.c (ae3d56d81507c33024ba7c1eae2ef433aa9bc0d5)
1/*
2 * libcxgbi.c: Chelsio common library for T3/T4 iSCSI driver.
3 *
4 * Copyright (c) 2010-2015 Chelsio Communications, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation.

--- 559 unchanged lines hidden (view full) ---

568 return NULL;
569 }
570
571 spin_lock_init(&csk->lock);
572 kref_init(&csk->refcnt);
573 skb_queue_head_init(&csk->receive_queue);
574 skb_queue_head_init(&csk->write_queue);
575 timer_setup(&csk->retry_timer, NULL, 0);
1/*
2 * libcxgbi.c: Chelsio common library for T3/T4 iSCSI driver.
3 *
4 * Copyright (c) 2010-2015 Chelsio Communications, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation.

--- 559 unchanged lines hidden (view full) ---

568 return NULL;
569 }
570
571 spin_lock_init(&csk->lock);
572 kref_init(&csk->refcnt);
573 skb_queue_head_init(&csk->receive_queue);
574 skb_queue_head_init(&csk->write_queue);
575 timer_setup(&csk->retry_timer, NULL, 0);
576 init_completion(&csk->cmpl);
577 rwlock_init(&csk->callback_lock);
578 csk->cdev = cdev;
579 csk->flags = 0;
580 cxgbi_sock_set_state(csk, CTP_CLOSED);
581
582 log_debug(1 << CXGBI_DBG_SOCK, "cdev 0x%p, new csk 0x%p.\n", cdev, csk);
583
584 return csk;

--- 622 unchanged lines hidden (view full) ---

1207 goto done;
1208}
1209
1210static inline void
1211scmd_get_params(struct scsi_cmnd *sc, struct scatterlist **sgl,
1212 unsigned int *sgcnt, unsigned int *dlen,
1213 unsigned int prot)
1214{
576 rwlock_init(&csk->callback_lock);
577 csk->cdev = cdev;
578 csk->flags = 0;
579 cxgbi_sock_set_state(csk, CTP_CLOSED);
580
581 log_debug(1 << CXGBI_DBG_SOCK, "cdev 0x%p, new csk 0x%p.\n", cdev, csk);
582
583 return csk;

--- 622 unchanged lines hidden (view full) ---

1206 goto done;
1207}
1208
1209static inline void
1210scmd_get_params(struct scsi_cmnd *sc, struct scatterlist **sgl,
1211 unsigned int *sgcnt, unsigned int *dlen,
1212 unsigned int prot)
1213{
1215 struct scsi_data_buffer *sdb = prot ? scsi_prot(sc) : scsi_out(sc);
1214 struct scsi_data_buffer *sdb = prot ? scsi_prot(sc) : &sc->sdb;
1216
1217 *sgl = sdb->table.sgl;
1218 *sgcnt = sdb->table.nents;
1219 *dlen = sdb->length;
1220 /* Caution: for protection sdb, sdb->length is invalid */
1221}
1222
1223void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *ppod,

--- 199 unchanged lines hidden (view full) ---

1423 struct cxgbi_conn *cconn = tcp_conn->dd_data;
1424 struct cxgbi_device *cdev = cconn->chba->cdev;
1425 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev);
1426 u32 tag = ntohl((__force u32)hdr_itt);
1427
1428 log_debug(1 << CXGBI_DBG_DDP,
1429 "cdev 0x%p, task 0x%p, release tag 0x%x.\n",
1430 cdev, task, tag);
1215
1216 *sgl = sdb->table.sgl;
1217 *sgcnt = sdb->table.nents;
1218 *dlen = sdb->length;
1219 /* Caution: for protection sdb, sdb->length is invalid */
1220}
1221
1222void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *ppod,

--- 199 unchanged lines hidden (view full) ---

1422 struct cxgbi_conn *cconn = tcp_conn->dd_data;
1423 struct cxgbi_device *cdev = cconn->chba->cdev;
1424 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev);
1425 u32 tag = ntohl((__force u32)hdr_itt);
1426
1427 log_debug(1 << CXGBI_DBG_DDP,
1428 "cdev 0x%p, task 0x%p, release tag 0x%x.\n",
1429 cdev, task, tag);
1431 if (sc &&
1432 (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_FROM_DEVICE) &&
1430 if (sc && sc->sc_data_direction == DMA_FROM_DEVICE &&
1433 cxgbi_ppm_is_ddp_tag(ppm, tag)) {
1434 struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
1435 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
1436
1437 if (!(cdev->flags & CXGBI_FLAG_USE_PPOD_OFLDQ))
1438 cdev->csk_ddp_clear_map(cdev, ppm, ttinfo);
1439 cxgbi_ppm_ppod_release(ppm, ttinfo->idx);
1440 dma_unmap_sg(&ppm->pdev->dev, ttinfo->sgl, ttinfo->nents,

--- 15 unchanged lines hidden (view full) ---

1456 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1457 struct cxgbi_conn *cconn = tcp_conn->dd_data;
1458 struct cxgbi_device *cdev = cconn->chba->cdev;
1459 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev);
1460 u32 sw_tag = cxgbi_build_sw_tag(task->itt, sess->age);
1461 u32 tag = 0;
1462 int err = -EINVAL;
1463
1431 cxgbi_ppm_is_ddp_tag(ppm, tag)) {
1432 struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
1433 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
1434
1435 if (!(cdev->flags & CXGBI_FLAG_USE_PPOD_OFLDQ))
1436 cdev->csk_ddp_clear_map(cdev, ppm, ttinfo);
1437 cxgbi_ppm_ppod_release(ppm, ttinfo->idx);
1438 dma_unmap_sg(&ppm->pdev->dev, ttinfo->sgl, ttinfo->nents,

--- 15 unchanged lines hidden (view full) ---

1454 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1455 struct cxgbi_conn *cconn = tcp_conn->dd_data;
1456 struct cxgbi_device *cdev = cconn->chba->cdev;
1457 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev);
1458 u32 sw_tag = cxgbi_build_sw_tag(task->itt, sess->age);
1459 u32 tag = 0;
1460 int err = -EINVAL;
1461
1464 if (sc &&
1465 (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_FROM_DEVICE)
1466 ) {
1462 if (sc && sc->sc_data_direction == DMA_FROM_DEVICE) {
1467 struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
1468 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
1469
1470 scmd_get_params(sc, &ttinfo->sgl, &ttinfo->nents,
1471 &tdata->dlen, 0);
1472 err = cxgbi_ddp_reserve(cconn, tdata, sw_tag, tdata->dlen);
1473 if (!err)
1474 tag = ttinfo->tag;

--- 417 unchanged lines hidden (view full) ---

1892 int headroom = SKB_TX_ISCSI_PDU_HEADER_MAX;
1893
1894 tcp_task->dd_data = tdata;
1895 task->hdr = NULL;
1896
1897 if (SKB_MAX_HEAD(cdev->skb_tx_rsvd) > (512 * MAX_SKB_FRAGS) &&
1898 (opcode == ISCSI_OP_SCSI_DATA_OUT ||
1899 (opcode == ISCSI_OP_SCSI_CMD &&
1463 struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
1464 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
1465
1466 scmd_get_params(sc, &ttinfo->sgl, &ttinfo->nents,
1467 &tdata->dlen, 0);
1468 err = cxgbi_ddp_reserve(cconn, tdata, sw_tag, tdata->dlen);
1469 if (!err)
1470 tag = ttinfo->tag;

--- 417 unchanged lines hidden (view full) ---

1888 int headroom = SKB_TX_ISCSI_PDU_HEADER_MAX;
1889
1890 tcp_task->dd_data = tdata;
1891 task->hdr = NULL;
1892
1893 if (SKB_MAX_HEAD(cdev->skb_tx_rsvd) > (512 * MAX_SKB_FRAGS) &&
1894 (opcode == ISCSI_OP_SCSI_DATA_OUT ||
1895 (opcode == ISCSI_OP_SCSI_CMD &&
1900 (scsi_bidi_cmnd(sc) || sc->sc_data_direction == DMA_TO_DEVICE))))
1896 sc->sc_data_direction == DMA_TO_DEVICE)))
1901 /* data could goes into skb head */
1902 headroom += min_t(unsigned int,
1903 SKB_MAX_HEAD(cdev->skb_tx_rsvd),
1904 conn->max_xmit_dlength);
1905
1906 tdata->skb = alloc_skb(cdev->skb_tx_rsvd + headroom, GFP_ATOMIC);
1907 if (!tdata->skb) {
1908 ndev->stats.tx_dropped++;

--- 58 unchanged lines hidden (view full) ---

1967 ntohl(task->cmdsn), ntohl(task->hdr->itt), offset, count);
1968
1969 skb_put(skb, task->hdr_len);
1970 tx_skb_setmode(skb, conn->hdrdgst_en, datalen ? conn->datadgst_en : 0);
1971 if (!count)
1972 return 0;
1973
1974 if (task->sc) {
1897 /* data could goes into skb head */
1898 headroom += min_t(unsigned int,
1899 SKB_MAX_HEAD(cdev->skb_tx_rsvd),
1900 conn->max_xmit_dlength);
1901
1902 tdata->skb = alloc_skb(cdev->skb_tx_rsvd + headroom, GFP_ATOMIC);
1903 if (!tdata->skb) {
1904 ndev->stats.tx_dropped++;

--- 58 unchanged lines hidden (view full) ---

1963 ntohl(task->cmdsn), ntohl(task->hdr->itt), offset, count);
1964
1965 skb_put(skb, task->hdr_len);
1966 tx_skb_setmode(skb, conn->hdrdgst_en, datalen ? conn->datadgst_en : 0);
1967 if (!count)
1968 return 0;
1969
1970 if (task->sc) {
1975 struct scsi_data_buffer *sdb = scsi_out(task->sc);
1971 struct scsi_data_buffer *sdb = &task->sc->sdb;
1976 struct scatterlist *sg = NULL;
1977 int err;
1978
1979 tdata->offset = offset;
1980 tdata->count = count;
1981 err = sgl_seek_offset(
1982 sdb->table.sgl, sdb->table.nents,
1983 tdata->offset, &tdata->sgoffset, &sg);

--- 263 unchanged lines hidden (view full) ---

2247 cls_conn, param, buflen, buf);
2248
2249 switch (param) {
2250 case ISCSI_PARAM_HDRDGST_EN:
2251 err = iscsi_set_param(cls_conn, param, buf, buflen);
2252 if (!err && conn->hdrdgst_en)
2253 err = csk->cdev->csk_ddp_setup_digest(csk, csk->tid,
2254 conn->hdrdgst_en,
1972 struct scatterlist *sg = NULL;
1973 int err;
1974
1975 tdata->offset = offset;
1976 tdata->count = count;
1977 err = sgl_seek_offset(
1978 sdb->table.sgl, sdb->table.nents,
1979 tdata->offset, &tdata->sgoffset, &sg);

--- 263 unchanged lines hidden (view full) ---

2243 cls_conn, param, buflen, buf);
2244
2245 switch (param) {
2246 case ISCSI_PARAM_HDRDGST_EN:
2247 err = iscsi_set_param(cls_conn, param, buf, buflen);
2248 if (!err && conn->hdrdgst_en)
2249 err = csk->cdev->csk_ddp_setup_digest(csk, csk->tid,
2250 conn->hdrdgst_en,
2255 conn->datadgst_en);
2251 conn->datadgst_en, 0);
2256 break;
2257 case ISCSI_PARAM_DATADGST_EN:
2258 err = iscsi_set_param(cls_conn, param, buf, buflen);
2259 if (!err && conn->datadgst_en)
2260 err = csk->cdev->csk_ddp_setup_digest(csk, csk->tid,
2261 conn->hdrdgst_en,
2252 break;
2253 case ISCSI_PARAM_DATADGST_EN:
2254 err = iscsi_set_param(cls_conn, param, buf, buflen);
2255 if (!err && conn->datadgst_en)
2256 err = csk->cdev->csk_ddp_setup_digest(csk, csk->tid,
2257 conn->hdrdgst_en,
2262 conn->datadgst_en);
2258 conn->datadgst_en, 0);
2263 break;
2264 case ISCSI_PARAM_MAX_R2T:
2265 return iscsi_tcp_set_max_r2t(conn, buf);
2266 case ISCSI_PARAM_MAX_RECV_DLENGTH:
2267 err = iscsi_set_param(cls_conn, param, buf, buflen);
2268 if (!err)
2269 err = cxgbi_conn_max_recv_dlength(conn);
2270 break;

--- 109 unchanged lines hidden (view full) ---

2380 return -EINVAL;
2381
2382 /* setup ddp pagesize */
2383 cep = ep->dd_data;
2384 csk = cep->csk;
2385
2386 ppm = csk->cdev->cdev2ppm(csk->cdev);
2387 err = csk->cdev->csk_ddp_setup_pgidx(csk, csk->tid,
2259 break;
2260 case ISCSI_PARAM_MAX_R2T:
2261 return iscsi_tcp_set_max_r2t(conn, buf);
2262 case ISCSI_PARAM_MAX_RECV_DLENGTH:
2263 err = iscsi_set_param(cls_conn, param, buf, buflen);
2264 if (!err)
2265 err = cxgbi_conn_max_recv_dlength(conn);
2266 break;

--- 109 unchanged lines hidden (view full) ---

2376 return -EINVAL;
2377
2378 /* setup ddp pagesize */
2379 cep = ep->dd_data;
2380 csk = cep->csk;
2381
2382 ppm = csk->cdev->cdev2ppm(csk->cdev);
2383 err = csk->cdev->csk_ddp_setup_pgidx(csk, csk->tid,
2388 ppm->tformat.pgsz_idx_dflt);
2384 ppm->tformat.pgsz_idx_dflt, 0);
2389 if (err < 0)
2390 return err;
2391
2392 err = iscsi_conn_bind(cls_session, cls_conn, is_leading);
2393 if (err)
2394 return -EINVAL;
2395
2396 /* calculate the tag idx bits needed for this conn based on cmds_max */

--- 387 unchanged lines hidden ---
2385 if (err < 0)
2386 return err;
2387
2388 err = iscsi_conn_bind(cls_session, cls_conn, is_leading);
2389 if (err)
2390 return -EINVAL;
2391
2392 /* calculate the tag idx bits needed for this conn based on cmds_max */

--- 387 unchanged lines hidden ---