[SCSI] scsi_transport_iscsi: Add support to set CHAP entries
authorAdheer Chandravanshi <adheer.chandravanshi@qlogic.com>
Tue, 17 Sep 2013 11:54:48 +0000 (07:54 -0400)
committerJames Bottomley <JBottomley@Parallels.com>
Fri, 25 Oct 2013 08:58:01 +0000 (09:58 +0100)
For offload iSCSI like qla4xxx, CHAP entries are stored in adapter's
flash.
This patch adds support to add/update CHAP entries in adapter's flash
using iscsi tools, like Open-iSCSI.

Signed-off-by: Adheer Chandravanshi <adheer.chandravanshi@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/scsi_transport_iscsi.c
include/scsi/iscsi_if.h
include/scsi/scsi_transport_iscsi.h

index e4a989fa477d3bc3f94788455dec8f0b6ba2ff5d..63a6ca49d4e5e8d1b0f53c592943c279bcffcb60 100644 (file)
@@ -2744,6 +2744,28 @@ exit_get_chap:
        return err;
 }
 
+static int iscsi_set_chap(struct iscsi_transport *transport,
+                         struct iscsi_uevent *ev, uint32_t len)
+{
+       char *data = (char *)ev + sizeof(*ev);
+       struct Scsi_Host *shost;
+       int err = 0;
+
+       if (!transport->set_chap)
+               return -ENOSYS;
+
+       shost = scsi_host_lookup(ev->u.set_path.host_no);
+       if (!shost) {
+               pr_err("%s could not find host no %u\n",
+                      __func__, ev->u.set_path.host_no);
+               return -ENODEV;
+       }
+
+       err = transport->set_chap(shost, data, len);
+       scsi_host_put(shost);
+       return err;
+}
+
 static int iscsi_delete_chap(struct iscsi_transport *transport,
                             struct iscsi_uevent *ev)
 {
@@ -3234,6 +3256,10 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
        case ISCSI_UEVENT_LOGOUT_FLASHNODE_SID:
                err = iscsi_logout_flashnode_sid(transport, ev);
                break;
+       case ISCSI_UEVENT_SET_CHAP:
+               err = iscsi_set_chap(transport, ev,
+                                    nlmsg_attrlen(nlh, sizeof(*ev)));
+               break;
        default:
                err = -ENOSYS;
                break;
index 13d81c5c4ebf83dfa8d844fa6b4f64caf6725df7..5d6ed6cf12cc8c2c984e2565b028a55bedb001d8 100644 (file)
@@ -69,6 +69,7 @@ enum iscsi_uevent_e {
        ISCSI_UEVENT_LOGIN_FLASHNODE    = UEVENT_BASE + 28,
        ISCSI_UEVENT_LOGOUT_FLASHNODE   = UEVENT_BASE + 29,
        ISCSI_UEVENT_LOGOUT_FLASHNODE_SID       = UEVENT_BASE + 30,
+       ISCSI_UEVENT_SET_CHAP           = UEVENT_BASE + 31,
 
        /* up events */
        ISCSI_KEVENT_RECV_PDU           = KEVENT_BASE + 1,
@@ -309,8 +310,16 @@ enum iscsi_param_type {
        ISCSI_HOST_PARAM,       /* iscsi_host_param */
        ISCSI_NET_PARAM,        /* iscsi_net_param */
        ISCSI_FLASHNODE_PARAM,  /* iscsi_flashnode_param */
+       ISCSI_CHAP_PARAM,       /* iscsi_chap_param */
 };
 
+/* structure for minimalist usecase */
+struct iscsi_param_info {
+       uint32_t len;           /* Actual length of the param value */
+       uint16_t param;         /* iscsi param */
+       uint8_t value[0];       /* length sized value follows */
+} __packed;
+
 struct iscsi_iface_param_info {
        uint32_t iface_num;     /* iface number, 0 - n */
        uint32_t len;           /* Actual length of the param */
@@ -739,6 +748,14 @@ enum chap_type_e {
        CHAP_TYPE_IN,
 };
 
+enum iscsi_chap_param {
+       ISCSI_CHAP_PARAM_INDEX,
+       ISCSI_CHAP_PARAM_CHAP_TYPE,
+       ISCSI_CHAP_PARAM_USERNAME,
+       ISCSI_CHAP_PARAM_PASSWORD,
+       ISCSI_CHAP_PARAM_PASSWORD_LEN
+};
+
 #define ISCSI_CHAP_AUTH_NAME_MAX_LEN   256
 #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
 struct iscsi_chap_rec {
index d0f1602985e7efe6d6ab40dd67fbcc04e6a32276..fe7c8f3e93f81dad733c6cc6a08c2d8a65c3a8df 100644 (file)
@@ -152,6 +152,7 @@ struct iscsi_transport {
        int (*get_chap) (struct Scsi_Host *shost, uint16_t chap_tbl_idx,
                         uint32_t *num_entries, char *buf);
        int (*delete_chap) (struct Scsi_Host *shost, uint16_t chap_tbl_idx);
+       int (*set_chap) (struct Scsi_Host *shost, void *data, int len);
        int (*get_flashnode_param) (struct iscsi_bus_flash_session *fnode_sess,
                                    int param, char *buf);
        int (*set_flashnode_param) (struct iscsi_bus_flash_session *fnode_sess,