Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sagi Grimberg and committed by
Doug Ledford
d3cf81f9 1caa70d8

+106 -74
+4 -35
drivers/infiniband/ulp/iser/iscsi_iser.h
··· 48 48 #include <scsi/scsi_transport_iscsi.h> 49 49 #include <scsi/scsi_cmnd.h> 50 50 #include <scsi/scsi_device.h> 51 + #include <scsi/iser.h> 51 52 52 53 #include <linux/interrupt.h> 53 54 #include <linux/wait.h> ··· 154 153 155 154 #define ISER_SIGNAL_CMD_COUNT 32 156 155 157 - #define ISER_VER 0x10 158 - #define ISER_WSV 0x08 159 - #define ISER_RSV 0x04 160 - 161 - /** 162 - * struct iser_hdr - iSER header 163 - * 164 - * @flags: flags support (zbva, remote_inv) 165 - * @rsvd: reserved 166 - * @write_stag: write rkey 167 - * @write_va: write virtual address 168 - * @reaf_stag: read rkey 169 - * @read_va: read virtual address 170 - */ 171 - struct iser_hdr { 172 - u8 flags; 173 - u8 rsvd[3]; 174 - __be32 write_stag; 175 - __be64 write_va; 176 - __be32 read_stag; 177 - __be64 read_va; 178 - } __attribute__((packed)); 179 - 180 - 181 - #define ISER_ZBVA_NOT_SUPPORTED 0x80 182 - #define ISER_SEND_W_INV_NOT_SUPPORTED 0x40 183 - 184 - struct iser_cm_hdr { 185 - u8 flags; 186 - u8 rsvd[3]; 187 - } __packed; 188 - 189 156 /* Constant PDU lengths calculations */ 190 - #define ISER_HEADERS_LEN (sizeof(struct iser_hdr) + sizeof(struct iscsi_hdr)) 157 + #define ISER_HEADERS_LEN (sizeof(struct iser_ctrl) + sizeof(struct iscsi_hdr)) 191 158 192 159 #define ISER_RECV_DATA_SEG_LEN 128 193 160 #define ISER_RX_PAYLOAD_SIZE (ISER_HEADERS_LEN + ISER_RECV_DATA_SEG_LEN) ··· 252 283 * @sig_attrs: Signature attributes 253 284 */ 254 285 struct iser_tx_desc { 255 - struct iser_hdr iser_header; 286 + struct iser_ctrl iser_header; 256 287 struct iscsi_hdr iscsi_header; 257 288 enum iser_desc_type type; 258 289 u64 dma_addr; ··· 285 316 * @pad: for sense data TODO: Modify to maximum sense length supported 286 317 */ 287 318 struct iser_rx_desc { 288 - struct iser_hdr iser_header; 319 + struct iser_ctrl iser_header; 289 320 struct iscsi_hdr iscsi_header; 290 321 char data[ISER_RECV_DATA_SEG_LEN]; 291 322 u64 dma_addr;
+4 -4
drivers/infiniband/ulp/iser/iser_initiator.c
··· 51 51 struct iscsi_iser_task *iser_task = task->dd_data; 52 52 struct iser_mem_reg *mem_reg; 53 53 int err; 54 - struct iser_hdr *hdr = &iser_task->desc.iser_header; 54 + struct iser_ctrl *hdr = &iser_task->desc.iser_header; 55 55 struct iser_data_buf *buf_in = &iser_task->data[ISER_DIR_IN]; 56 56 57 57 err = iser_dma_map_task_data(iser_task, ··· 104 104 struct iscsi_iser_task *iser_task = task->dd_data; 105 105 struct iser_mem_reg *mem_reg; 106 106 int err; 107 - struct iser_hdr *hdr = &iser_task->desc.iser_header; 107 + struct iser_ctrl *hdr = &iser_task->desc.iser_header; 108 108 struct iser_data_buf *buf_out = &iser_task->data[ISER_DIR_OUT]; 109 109 struct ib_sge *tx_dsg = &iser_task->desc.tx_sg[1]; 110 110 ··· 167 167 ib_dma_sync_single_for_cpu(device->ib_device, 168 168 tx_desc->dma_addr, ISER_HEADERS_LEN, DMA_TO_DEVICE); 169 169 170 - memset(&tx_desc->iser_header, 0, sizeof(struct iser_hdr)); 170 + memset(&tx_desc->iser_header, 0, sizeof(struct iser_ctrl)); 171 171 tx_desc->iser_header.flags = ISER_VER; 172 172 tx_desc->num_sge = 1; 173 173 } ··· 574 574 desc->rsp_dma, ISER_RX_LOGIN_SIZE, 575 575 DMA_FROM_DEVICE); 576 576 577 - hdr = desc->rsp + sizeof(struct iser_hdr); 577 + hdr = desc->rsp + sizeof(struct iser_ctrl); 578 578 data = desc->rsp + ISER_HEADERS_LEN; 579 579 length = wc->byte_len - ISER_HEADERS_LEN; 580 580
+3 -4
drivers/infiniband/ulp/iser/iser_verbs.c
··· 812 812 conn_param.rnr_retry_count = 6; 813 813 814 814 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); 819 818 820 819 ret = rdma_connect(cma_id, &conn_param); 821 820 if (ret) {
+11 -11
drivers/infiniband/ulp/isert/ib_isert.c
··· 1028 1028 ib_dma_sync_single_for_cpu(ib_dev, tx_desc->dma_addr, 1029 1029 ISER_HEADERS_LEN, DMA_TO_DEVICE); 1030 1030 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; 1033 1033 1034 1034 tx_desc->num_sge = 1; 1035 1035 tx_desc->isert_cmd = isert_cmd; ··· 1521 1521 static void 1522 1522 isert_rx_do_work(struct iser_rx_desc *rx_desc, struct isert_conn *isert_conn) 1523 1523 { 1524 - struct iser_hdr *iser_hdr = &rx_desc->iser_header; 1524 + struct iser_ctrl *iser_ctrl = &rx_desc->iser_header; 1525 1525 uint64_t read_va = 0, write_va = 0; 1526 1526 uint32_t read_stag = 0, write_stag = 0; 1527 1527 1528 - switch (iser_hdr->flags & 0xF0) { 1528 + switch (iser_ctrl->flags & 0xF0) { 1529 1529 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); 1533 1533 isert_dbg("ISER_RSV: read_stag: 0x%x read_va: 0x%llx\n", 1534 1534 read_stag, (unsigned long long)read_va); 1535 1535 } 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); 1539 1539 isert_dbg("ISER_WSV: write_stag: 0x%x write_va: 0x%llx\n", 1540 1540 write_stag, (unsigned long long)write_va); 1541 1541 } ··· 1546 1546 isert_err("iSER Hello message\n"); 1547 1547 break; 1548 1548 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); 1550 1550 break; 1551 1551 } 1552 1552
+4 -2
drivers/infiniband/ulp/isert/ib_isert.h
··· 3 3 #include <linux/in6.h> 4 4 #include <rdma/ib_verbs.h> 5 5 #include <rdma/rdma_cm.h> 6 + #include <scsi/iser.h> 7 + 6 8 7 9 #define DRV_NAME "isert" 8 10 #define PFX DRV_NAME ": " ··· 58 56 }; 59 57 60 58 struct iser_rx_desc { 61 - struct iser_hdr iser_header; 59 + struct iser_ctrl iser_header; 62 60 struct iscsi_hdr iscsi_header; 63 61 char data[ISER_RECV_DATA_SEG_LEN]; 64 62 u64 dma_addr; ··· 67 65 } __packed; 68 66 69 67 struct iser_tx_desc { 70 - struct iser_hdr iser_header; 68 + struct iser_ctrl iser_header; 71 69 struct iscsi_hdr iscsi_header; 72 70 enum isert_desc_type type; 73 71 u64 dma_addr;
+2 -18
drivers/infiniband/ulp/isert/isert_proto.h
··· 1 1 /* From iscsi_iser.h */ 2 2 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)) 14 5 15 6 #define ISER_RECV_DATA_SEG_LEN 8192 16 7 #define ISER_RX_PAYLOAD_SIZE (ISER_HEADERS_LEN + ISER_RECV_DATA_SEG_LEN) ··· 29 38 30 39 #define ISER_RX_PAD_SIZE (ISER_RECV_DATA_SEG_LEN + 4096 - \ 31 40 (ISER_RX_PAYLOAD_SIZE + sizeof(u64) + sizeof(struct ib_sge))) 32 - 33 - #define ISER_VER 0x10 34 - #define ISER_WSV 0x08 35 - #define ISER_RSV 0x04 36 - #define ISCSI_CTRL 0x10 37 - #define ISER_HELLO 0x20 38 - #define ISER_HELLORPLY 0x30
+78
include/scsi/iser.h
··· 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 */