Skip to content

Commit d3cf81f

Browse files
Sagi Grimbergdledford
authored andcommitted
IB/iser,isert: Create and use new shared header
The iser RDMA_CM negotiation protocol is shared by the initiator and the target, so have a shared header for the defines and structure. Move relevant items from the initiator and target headers. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Jenny Derzhavetz <jennyf@mellanox.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 1caa70d commit d3cf81f

7 files changed

Lines changed: 106 additions & 74 deletions

File tree

‎drivers/infiniband/ulp/iser/iscsi_iser.h‎

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <scsi/scsi_transport_iscsi.h>
4949
#include <scsi/scsi_cmnd.h>
5050
#include <scsi/scsi_device.h>
51+
#include <scsi/iser.h>
5152

5253
#include <linux/interrupt.h>
5354
#include <linux/wait.h>
@@ -153,40 +154,8 @@
153154

154155
#define ISER_SIGNAL_CMD_COUNT 32
155156

156-
#define ISER_VER 0x10
157-
#define ISER_WSV 0x08
158-
#define ISER_RSV 0x04
159-
160-
/**
161-
* struct iser_hdr - iSER header
162-
*
163-
* @flags: flags support (zbva, remote_inv)
164-
* @rsvd: reserved
165-
* @write_stag: write rkey
166-
* @write_va: write virtual address
167-
* @reaf_stag: read rkey
168-
* @read_va: read virtual address
169-
*/
170-
struct iser_hdr {
171-
u8 flags;
172-
u8 rsvd[3];
173-
__be32 write_stag;
174-
__be64 write_va;
175-
__be32 read_stag;
176-
__be64 read_va;
177-
} __attribute__((packed));
178-
179-
180-
#define ISER_ZBVA_NOT_SUPPORTED 0x80
181-
#define ISER_SEND_W_INV_NOT_SUPPORTED 0x40
182-
183-
struct iser_cm_hdr {
184-
u8 flags;
185-
u8 rsvd[3];
186-
} __packed;
187-
188157
/* Constant PDU lengths calculations */
189-
#define ISER_HEADERS_LEN (sizeof(struct iser_hdr) + sizeof(struct iscsi_hdr))
158+
#define ISER_HEADERS_LEN (sizeof(struct iser_ctrl) + sizeof(struct iscsi_hdr))
190159

191160
#define ISER_RECV_DATA_SEG_LEN 128
192161
#define ISER_RX_PAYLOAD_SIZE (ISER_HEADERS_LEN + ISER_RECV_DATA_SEG_LEN)
@@ -283,7 +252,7 @@ enum iser_desc_type {
283252
* @sig_attrs: Signature attributes
284253
*/
285254
struct iser_tx_desc {
286-
struct iser_hdr iser_header;
255+
struct iser_ctrl iser_header;
287256
struct iscsi_hdr iscsi_header;
288257
enum iser_desc_type type;
289258
u64 dma_addr;
@@ -316,7 +285,7 @@ struct iser_tx_desc {
316285
* @pad: for sense data TODO: Modify to maximum sense length supported
317286
*/
318287
struct iser_rx_desc {
319-
struct iser_hdr iser_header;
288+
struct iser_ctrl iser_header;
320289
struct iscsi_hdr iscsi_header;
321290
char data[ISER_RECV_DATA_SEG_LEN];
322291
u64 dma_addr;

‎drivers/infiniband/ulp/iser/iser_initiator.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int iser_prepare_read_cmd(struct iscsi_task *task)
5151
struct iscsi_iser_task *iser_task = task->dd_data;
5252
struct iser_mem_reg *mem_reg;
5353
int err;
54-
struct iser_hdr *hdr = &iser_task->desc.iser_header;
54+
struct iser_ctrl *hdr = &iser_task->desc.iser_header;
5555
struct iser_data_buf *buf_in = &iser_task->data[ISER_DIR_IN];
5656

5757
err = iser_dma_map_task_data(iser_task,
@@ -104,7 +104,7 @@ iser_prepare_write_cmd(struct iscsi_task *task,
104104
struct iscsi_iser_task *iser_task = task->dd_data;
105105
struct iser_mem_reg *mem_reg;
106106
int err;
107-
struct iser_hdr *hdr = &iser_task->desc.iser_header;
107+
struct iser_ctrl *hdr = &iser_task->desc.iser_header;
108108
struct iser_data_buf *buf_out = &iser_task->data[ISER_DIR_OUT];
109109
struct ib_sge *tx_dsg = &iser_task->desc.tx_sg[1];
110110

@@ -167,7 +167,7 @@ static void iser_create_send_desc(struct iser_conn *iser_conn,
167167
ib_dma_sync_single_for_cpu(device->ib_device,
168168
tx_desc->dma_addr, ISER_HEADERS_LEN, DMA_TO_DEVICE);
169169

170-
memset(&tx_desc->iser_header, 0, sizeof(struct iser_hdr));
170+
memset(&tx_desc->iser_header, 0, sizeof(struct iser_ctrl));
171171
tx_desc->iser_header.flags = ISER_VER;
172172
tx_desc->num_sge = 1;
173173
}
@@ -574,7 +574,7 @@ void iser_login_rsp(struct ib_cq *cq, struct ib_wc *wc)
574574
desc->rsp_dma, ISER_RX_LOGIN_SIZE,
575575
DMA_FROM_DEVICE);
576576

577-
hdr = desc->rsp + sizeof(struct iser_hdr);
577+
hdr = desc->rsp + sizeof(struct iser_ctrl);
578578
data = desc->rsp + ISER_HEADERS_LEN;
579579
length = wc->byte_len - ISER_HEADERS_LEN;
580580

‎drivers/infiniband/ulp/iser/iser_verbs.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,9 @@ static void iser_route_handler(struct rdma_cm_id *cma_id)
812812
conn_param.rnr_retry_count = 6;
813813

814814
memset(&req_hdr, 0, sizeof(req_hdr));
815-
req_hdr.flags = (ISER_ZBVA_NOT_SUPPORTED |
816-
ISER_SEND_W_INV_NOT_SUPPORTED);
817-
conn_param.private_data = (void *)&req_hdr;
818-
conn_param.private_data_len = sizeof(struct iser_cm_hdr);
815+
req_hdr.flags = (ISER_ZBVA_NOT_SUP | ISER_SEND_W_INV_NOT_SUP);
816+
conn_param.private_data = (void *)&req_hdr;
817+
conn_param.private_data_len = sizeof(struct iser_cm_hdr);
819818

820819
ret = rdma_connect(cma_id, &conn_param);
821820
if (ret) {

‎drivers/infiniband/ulp/isert/ib_isert.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,8 @@ isert_create_send_desc(struct isert_conn *isert_conn,
10281028
ib_dma_sync_single_for_cpu(ib_dev, tx_desc->dma_addr,
10291029
ISER_HEADERS_LEN, DMA_TO_DEVICE);
10301030

1031-
memset(&tx_desc->iser_header, 0, sizeof(struct iser_hdr));
1032-
tx_desc->iser_header.flags = ISER_VER;
1031+
memset(&tx_desc->iser_header, 0, sizeof(struct iser_ctrl));
1032+
tx_desc->iser_header.flags = ISCSI_CTRL;
10331033

10341034
tx_desc->num_sge = 1;
10351035
tx_desc->isert_cmd = isert_cmd;
@@ -1521,21 +1521,21 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
15211521
static void
15221522
isert_rx_do_work(struct iser_rx_desc *rx_desc, struct isert_conn *isert_conn)
15231523
{
1524-
struct iser_hdr *iser_hdr = &rx_desc->iser_header;
1524+
struct iser_ctrl *iser_ctrl = &rx_desc->iser_header;
15251525
uint64_t read_va = 0, write_va = 0;
15261526
uint32_t read_stag = 0, write_stag = 0;
15271527

1528-
switch (iser_hdr->flags & 0xF0) {
1528+
switch (iser_ctrl->flags & 0xF0) {
15291529
case ISCSI_CTRL:
1530-
if (iser_hdr->flags & ISER_RSV) {
1531-
read_stag = be32_to_cpu(iser_hdr->read_stag);
1532-
read_va = be64_to_cpu(iser_hdr->read_va);
1530+
if (iser_ctrl->flags & ISER_RSV) {
1531+
read_stag = be32_to_cpu(iser_ctrl->read_stag);
1532+
read_va = be64_to_cpu(iser_ctrl->read_va);
15331533
isert_dbg("ISER_RSV: read_stag: 0x%x read_va: 0x%llx\n",
15341534
read_stag, (unsigned long long)read_va);
15351535
}
1536-
if (iser_hdr->flags & ISER_WSV) {
1537-
write_stag = be32_to_cpu(iser_hdr->write_stag);
1538-
write_va = be64_to_cpu(iser_hdr->write_va);
1536+
if (iser_ctrl->flags & ISER_WSV) {
1537+
write_stag = be32_to_cpu(iser_ctrl->write_stag);
1538+
write_va = be64_to_cpu(iser_ctrl->write_va);
15391539
isert_dbg("ISER_WSV: write_stag: 0x%x write_va: 0x%llx\n",
15401540
write_stag, (unsigned long long)write_va);
15411541
}
@@ -1546,7 +1546,7 @@ isert_rx_do_work(struct iser_rx_desc *rx_desc, struct isert_conn *isert_conn)
15461546
isert_err("iSER Hello message\n");
15471547
break;
15481548
default:
1549-
isert_warn("Unknown iSER hdr flags: 0x%02x\n", iser_hdr->flags);
1549+
isert_warn("Unknown iSER hdr flags: 0x%02x\n", iser_ctrl->flags);
15501550
break;
15511551
}
15521552

‎drivers/infiniband/ulp/isert/ib_isert.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <linux/in6.h>
44
#include <rdma/ib_verbs.h>
55
#include <rdma/rdma_cm.h>
6+
#include <scsi/iser.h>
7+
68

79
#define DRV_NAME "isert"
810
#define PFX DRV_NAME ": "
@@ -56,7 +58,7 @@ enum iser_conn_state {
5658
};
5759

5860
struct iser_rx_desc {
59-
struct iser_hdr iser_header;
61+
struct iser_ctrl iser_header;
6062
struct iscsi_hdr iscsi_header;
6163
char data[ISER_RECV_DATA_SEG_LEN];
6264
u64 dma_addr;
@@ -65,7 +67,7 @@ struct iser_rx_desc {
6567
} __packed;
6668

6769
struct iser_tx_desc {
68-
struct iser_hdr iser_header;
70+
struct iser_ctrl iser_header;
6971
struct iscsi_hdr iscsi_header;
7072
enum isert_desc_type type;
7173
u64 dma_addr;

‎drivers/infiniband/ulp/isert/isert_proto.h‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
/* From iscsi_iser.h */
22

3-
struct iser_hdr {
4-
u8 flags;
5-
u8 rsvd[3];
6-
__be32 write_stag; /* write rkey */
7-
__be64 write_va;
8-
__be32 read_stag; /* read rkey */
9-
__be64 read_va;
10-
} __packed;
11-
12-
/*Constant PDU lengths calculations */
13-
#define ISER_HEADERS_LEN (sizeof(struct iser_hdr) + sizeof(struct iscsi_hdr))
3+
/* Constant PDU lengths calculations */
4+
#define ISER_HEADERS_LEN (sizeof(struct iser_ctrl) + sizeof(struct iscsi_hdr))
145

156
#define ISER_RECV_DATA_SEG_LEN 8192
167
#define ISER_RX_PAYLOAD_SIZE (ISER_HEADERS_LEN + ISER_RECV_DATA_SEG_LEN)
@@ -38,10 +29,3 @@ struct iser_hdr {
3829

3930
#define ISER_RX_PAD_SIZE (ISER_RECV_DATA_SEG_LEN + 4096 - \
4031
(ISER_RX_PAYLOAD_SIZE + sizeof(u64) + sizeof(struct ib_sge)))
41-
42-
#define ISER_VER 0x10
43-
#define ISER_WSV 0x08
44-
#define ISER_RSV 0x04
45-
#define ISCSI_CTRL 0x10
46-
#define ISER_HELLO 0x20
47-
#define ISER_HELLORPLY 0x30

‎include/scsi/iser.h‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
3+
*
4+
* This software is available to you under a choice of one of two
5+
* licenses. You may choose to be licensed under the terms of the GNU
6+
* General Public License (GPL) Version 2, available from the file
7+
* COPYING in the main directory of this source tree, or the
8+
* OpenIB.org BSD license below:
9+
*
10+
* Redistribution and use in source and binary forms, with or
11+
* without modification, are permitted provided that the following
12+
* conditions are met:
13+
*
14+
* - Redistributions of source code must retain the above
15+
* copyright notice, this list of conditions and the following
16+
* disclaimer.
17+
*
18+
* - Redistributions in binary form must reproduce the above
19+
* copyright notice, this list of conditions and the following
20+
* disclaimer in the documentation and/or other materials
21+
* provided with the distribution.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
* SOFTWARE.
31+
*/
32+
#ifndef ISCSI_ISER_H
33+
#define ISCSI_ISER_H
34+
35+
#define ISER_ZBVA_NOT_SUP 0x80
36+
#define ISER_SEND_W_INV_NOT_SUP 0x40
37+
#define ISERT_ZBVA_NOT_USED 0x80
38+
#define ISERT_SEND_W_INV_NOT_USED 0x40
39+
40+
#define ISCSI_CTRL 0x10
41+
#define ISER_HELLO 0x20
42+
#define ISER_HELLORPLY 0x30
43+
44+
#define ISER_VER 0x10
45+
#define ISER_WSV 0x08
46+
#define ISER_RSV 0x04
47+
48+
/**
49+
* struct iser_cm_hdr - iSER CM header (from iSER Annex A12)
50+
*
51+
* @flags: flags support (zbva, send_w_inv)
52+
* @rsvd: reserved
53+
*/
54+
struct iser_cm_hdr {
55+
u8 flags;
56+
u8 rsvd[3];
57+
} __packed;
58+
59+
/**
60+
* struct iser_ctrl - iSER header of iSCSI control PDU
61+
*
62+
* @flags: opcode and read/write valid bits
63+
* @rsvd: reserved
64+
* @write_stag: write rkey
65+
* @write_va: write virtual address
66+
* @reaf_stag: read rkey
67+
* @read_va: read virtual address
68+
*/
69+
struct iser_ctrl {
70+
u8 flags;
71+
u8 rsvd[3];
72+
__be32 write_stag;
73+
__be64 write_va;
74+
__be32 read_stag;
75+
__be64 read_va;
76+
} __packed;
77+
78+
#endif /* ISCSI_ISER_H */

0 commit comments

Comments
 (0)