]> Pileus Git - ~andy/linux/blobdiff - drivers/scsi/be2iscsi/be_iscsi.c
Merge tag 'uapi-prep-20121002' of git://git.infradead.org/users/dhowells/linux-headers
[~andy/linux] / drivers / scsi / be2iscsi / be_iscsi.c
index 41b1fb70dd3bbf71ecfdfc933296c0d043d4f11b..aedb0d9a9dae652d753455df07c2aee1a4d9e867 100644 (file)
@@ -332,6 +332,51 @@ beiscsi_set_static_ip(struct Scsi_Host *shost,
        return ret;
 }
 
+/**
+ * beiscsi_set_vlan_tag()- Set the VLAN TAG
+ * @shost: Scsi Host for the driver instance
+ * @iface_param: Interface paramters
+ *
+ * Set the VLAN TAG for the adapter or disable
+ * the VLAN config
+ *
+ * returns
+ *     Success: 0
+ *     Failure: Non-Zero Value
+ **/
+static int
+beiscsi_set_vlan_tag(struct Scsi_Host *shost,
+                     struct iscsi_iface_param_info *iface_param)
+{
+       struct beiscsi_hba *phba = iscsi_host_priv(shost);
+       int ret = 0;
+
+       /* Get the Interface Handle */
+       if (mgmt_get_all_if_id(phba)) {
+               beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
+                           "BS_%d : Getting Interface Handle Failed\n");
+               return -EIO;
+       }
+
+       switch (iface_param->param) {
+       case ISCSI_NET_PARAM_VLAN_ENABLED:
+               if (iface_param->value[0] != ISCSI_VLAN_ENABLE)
+                       ret = mgmt_set_vlan(phba, BEISCSI_VLAN_DISABLE);
+               break;
+       case ISCSI_NET_PARAM_VLAN_TAG:
+               ret = mgmt_set_vlan(phba,
+                                   *((uint16_t *)iface_param->value));
+               break;
+       default:
+               beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
+                           "BS_%d : Unkown Param Type : %d\n",
+                           iface_param->param);
+               return -ENOSYS;
+       }
+       return ret;
+}
+
+
 static int
 beiscsi_set_ipv4(struct Scsi_Host *shost,
                struct iscsi_iface_param_info *iface_param,
@@ -368,6 +413,10 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
                ret = beiscsi_set_static_ip(shost, iface_param,
                                            data, dt_len);
                break;
+       case ISCSI_NET_PARAM_VLAN_ENABLED:
+       case ISCSI_NET_PARAM_VLAN_TAG:
+               ret = beiscsi_set_vlan_tag(shost, iface_param);
+               break;
        default:
                beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
                            "BS_%d : Param %d not supported\n",
@@ -489,6 +538,27 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
        case ISCSI_NET_PARAM_IPV4_SUBNET:
                len = sprintf(buf, "%pI4\n", &if_info.ip_addr.subnet_mask);
                break;
+       case ISCSI_NET_PARAM_VLAN_ENABLED:
+               len = sprintf(buf, "%s\n",
+                            (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
+                            ? "Disabled" : "Enabled");
+               break;
+       case ISCSI_NET_PARAM_VLAN_ID:
+               if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
+                       return -EINVAL;
+               else
+                       len = sprintf(buf, "%d\n",
+                                    (if_info.vlan_priority &
+                                    ISCSI_MAX_VLAN_ID));
+               break;
+       case ISCSI_NET_PARAM_VLAN_PRIORITY:
+               if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
+                       return -EINVAL;
+               else
+                       len = sprintf(buf, "%d\n",
+                                    ((if_info.vlan_priority >> 13) &
+                                    ISCSI_MAX_VLAN_PRIORITY));
+               break;
        default:
                WARN_ON(1);
        }
@@ -510,6 +580,9 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
        case ISCSI_NET_PARAM_IPV4_SUBNET:
        case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
        case ISCSI_NET_PARAM_IPV6_ADDR:
+       case ISCSI_NET_PARAM_VLAN_ENABLED:
+       case ISCSI_NET_PARAM_VLAN_ID:
+       case ISCSI_NET_PARAM_VLAN_PRIORITY:
                len = be2iscsi_get_if_param(phba, iface, param, buf);
                break;
        case ISCSI_NET_PARAM_IFACE_ENABLE:
@@ -792,7 +865,7 @@ int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba)
        int rc;
 
        if (strlen(phba->mac_address))
-               return strlcpy(buf, phba->mac_address, PAGE_SIZE);
+               return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN);
 
        memset(&resp, 0, sizeof(resp));
        rc = mgmt_get_nic_conf(phba, &resp);
@@ -1181,6 +1254,7 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
        struct beiscsi_endpoint *beiscsi_ep;
        struct beiscsi_hba *phba;
        unsigned int tag;
+       uint8_t mgmt_invalidate_flag, tcp_upload_flag;
        unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH;
 
        beiscsi_ep = ep->dd_data;
@@ -1189,26 +1263,23 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
                    "BS_%d : In beiscsi_ep_disconnect for ep_cid = %d\n",
                    beiscsi_ep->ep_cid);
 
-       if (!beiscsi_ep->conn) {
-               beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-                           "BS_%d : In beiscsi_ep_disconnect, no "
-                           "beiscsi_ep\n");
-               return;
+       if (beiscsi_ep->conn) {
+               beiscsi_conn = beiscsi_ep->conn;
+               iscsi_suspend_queue(beiscsi_conn->conn);
+               mgmt_invalidate_flag = ~BEISCSI_NO_RST_ISSUE;
+               tcp_upload_flag = CONNECTION_UPLOAD_GRACEFUL;
+       } else {
+               mgmt_invalidate_flag = BEISCSI_NO_RST_ISSUE;
+               tcp_upload_flag = CONNECTION_UPLOAD_ABORT;
        }
-       beiscsi_conn = beiscsi_ep->conn;
-       iscsi_suspend_queue(beiscsi_conn->conn);
-
-       beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-                   "BS_%d : In beiscsi_ep_disconnect ep_cid = %d\n",
-                   beiscsi_ep->ep_cid);
 
        tag = mgmt_invalidate_connection(phba, beiscsi_ep,
-                                           beiscsi_ep->ep_cid, 1,
-                                           savecfg_flag);
+                                         beiscsi_ep->ep_cid,
+                                         mgmt_invalidate_flag,
+                                         savecfg_flag);
        if (!tag) {
                beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-                           "BS_%d : mgmt_invalidate_connection"
-                           " Failed for cid=%d\n",
+                           "BS_%d : mgmt_invalidate_connection Failed for cid=%d\n",
                            beiscsi_ep->ep_cid);
        } else {
                wait_event_interruptible(phba->ctrl.mcc_wait[tag],
@@ -1216,7 +1287,7 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
                free_mcc_tag(&phba->ctrl, tag);
        }
 
-       beiscsi_close_conn(beiscsi_ep, CONNECTION_UPLOAD_GRACEFUL);
+       beiscsi_close_conn(beiscsi_ep, tcp_upload_flag);
        beiscsi_free_ep(beiscsi_ep);
        beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid);
        iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep);
@@ -1233,6 +1304,9 @@ umode_t be2iscsi_attr_is_visible(int param_type, int param)
                case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
                case ISCSI_NET_PARAM_IPV4_GW:
                case ISCSI_NET_PARAM_IPV6_ADDR:
+               case ISCSI_NET_PARAM_VLAN_ID:
+               case ISCSI_NET_PARAM_VLAN_PRIORITY:
+               case ISCSI_NET_PARAM_VLAN_ENABLED:
                        return S_IRUGO;
                default:
                        return 0;