Commit db02aea9 authored by Jitendra Bhivare's avatar Jitendra Bhivare Committed by Martin K. Petersen

scsi: be2iscsi: Move VLAN code to common iface_set_param

VLAN tag is L2 construct, move VLAN code out from configuring IP.
Rearrange and rename the APIs to make it consistent.
Replace ENOSYS with EPERM.
Signed-off-by: default avatarJitendra Bhivare <jitendra.bhivare@broadcom.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 0152a7e9
...@@ -315,8 +315,8 @@ void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba) ...@@ -315,8 +315,8 @@ void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba)
* Failure: Non-Zero Value * Failure: Non-Zero Value
**/ **/
static int static int
beiscsi_set_vlan_tag(struct Scsi_Host *shost, beiscsi_iface_config_vlan(struct Scsi_Host *shost,
struct iscsi_iface_param_info *iface_param) struct iscsi_iface_param_info *iface_param)
{ {
struct beiscsi_hba *phba = iscsi_host_priv(shost); struct beiscsi_hba *phba = iscsi_host_priv(shost);
int ret; int ret;
...@@ -329,20 +329,17 @@ beiscsi_set_vlan_tag(struct Scsi_Host *shost, ...@@ -329,20 +329,17 @@ beiscsi_set_vlan_tag(struct Scsi_Host *shost,
return ret; return ret;
} }
ret = -EPERM;
switch (iface_param->param) { switch (iface_param->param) {
case ISCSI_NET_PARAM_VLAN_ENABLED: case ISCSI_NET_PARAM_VLAN_ENABLED:
ret = 0;
if (iface_param->value[0] != ISCSI_VLAN_ENABLE) if (iface_param->value[0] != ISCSI_VLAN_ENABLE)
ret = mgmt_set_vlan(phba, BEISCSI_VLAN_DISABLE); ret = beiscsi_if_set_vlan(phba, BEISCSI_VLAN_DISABLE);
break; break;
case ISCSI_NET_PARAM_VLAN_TAG: case ISCSI_NET_PARAM_VLAN_TAG:
ret = mgmt_set_vlan(phba, ret = beiscsi_if_set_vlan(phba,
*((uint16_t *)iface_param->value)); *((uint16_t *)iface_param->value));
break; break;
default:
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
"BS_%d : Unknown Param Type : %d\n",
iface_param->param);
return -ENOSYS;
} }
return ret; return ret;
} }
...@@ -356,7 +353,7 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost, ...@@ -356,7 +353,7 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
struct beiscsi_hba *phba = iscsi_host_priv(shost); struct beiscsi_hba *phba = iscsi_host_priv(shost);
u8 *ip = NULL, *subnet = NULL, *gw; u8 *ip = NULL, *subnet = NULL, *gw;
struct nlattr *nla; struct nlattr *nla;
int ret = 0; int ret = -EPERM;
/* Check the param */ /* Check the param */
switch (info->param) { switch (info->param) {
...@@ -405,14 +402,6 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost, ...@@ -405,14 +402,6 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
} }
ret = beiscsi_if_en_static(phba, BE2_IPV4, ip, subnet); ret = beiscsi_if_en_static(phba, BE2_IPV4, ip, subnet);
break; break;
case ISCSI_NET_PARAM_VLAN_ENABLED:
case ISCSI_NET_PARAM_VLAN_TAG:
ret = beiscsi_set_vlan_tag(shost, info);
break;
default:
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : Param %d not supported\n",
info->param);
} }
return ret; return ret;
...@@ -424,7 +413,7 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost, ...@@ -424,7 +413,7 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost,
void *data, uint32_t dt_len) void *data, uint32_t dt_len)
{ {
struct beiscsi_hba *phba = iscsi_host_priv(shost); struct beiscsi_hba *phba = iscsi_host_priv(shost);
int ret = 0; int ret = -EPERM;
switch (iface_param->param) { switch (iface_param->param) {
case ISCSI_NET_PARAM_IFACE_ENABLE: case ISCSI_NET_PARAM_IFACE_ENABLE:
...@@ -439,14 +428,6 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost, ...@@ -439,14 +428,6 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost,
ret = beiscsi_if_en_static(phba, BE2_IPV6, ret = beiscsi_if_en_static(phba, BE2_IPV6,
iface_param->value, NULL); iface_param->value, NULL);
break; 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",
iface_param->param);
} }
return ret; return ret;
...@@ -485,24 +466,42 @@ int be2iscsi_iface_set_param(struct Scsi_Host *shost, ...@@ -485,24 +466,42 @@ int be2iscsi_iface_set_param(struct Scsi_Host *shost,
return -EINVAL; return -EINVAL;
} }
switch (iface_param->iface_type) { beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
case ISCSI_IFACE_TYPE_IPV4: "BS_%d : %s.0 set param %d",
ret = beiscsi_iface_config_ipv4(shost, iface_param, (iface_param->iface_type == ISCSI_IFACE_TYPE_IPV4) ?
data, dt_len); "ipv4" : "ipv6", iface_param->param);
break;
case ISCSI_IFACE_TYPE_IPV6: ret = -EPERM;
ret = beiscsi_iface_config_ipv6(shost, iface_param, switch (iface_param->param) {
data, dt_len); case ISCSI_NET_PARAM_VLAN_ENABLED:
case ISCSI_NET_PARAM_VLAN_TAG:
ret = beiscsi_iface_config_vlan(shost, iface_param);
break; break;
default: default:
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, switch (iface_param->iface_type) {
"BS_%d : Invalid iface type :%d passed\n", case ISCSI_IFACE_TYPE_IPV4:
iface_param->iface_type); ret = beiscsi_iface_config_ipv4(shost,
break; iface_param,
data, dt_len);
break;
case ISCSI_IFACE_TYPE_IPV6:
ret = beiscsi_iface_config_ipv6(shost,
iface_param,
data, dt_len);
break;
}
} }
if (ret == -EPERM) {
__beiscsi_log(phba, KERN_ERR,
"BS_%d : %s.0 set param %d not permitted",
(iface_param->iface_type ==
ISCSI_IFACE_TYPE_IPV4) ? "ipv4" : "ipv6",
iface_param->param);
ret = 0;
}
if (ret) if (ret)
return ret; break;
} }
return ret; return ret;
...@@ -548,16 +547,16 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba, ...@@ -548,16 +547,16 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
len = -EINVAL; len = -EINVAL;
else else
len = sprintf(buf, "%d\n", len = sprintf(buf, "%d\n",
(if_info->vlan_priority & (if_info->vlan_priority &
ISCSI_MAX_VLAN_ID)); ISCSI_MAX_VLAN_ID));
break; break;
case ISCSI_NET_PARAM_VLAN_PRIORITY: case ISCSI_NET_PARAM_VLAN_PRIORITY:
if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE)
len = -EINVAL; len = -EINVAL;
else else
len = sprintf(buf, "%d\n", len = sprintf(buf, "%d\n",
((if_info->vlan_priority >> 13) & ((if_info->vlan_priority >> 13) &
ISCSI_MAX_VLAN_PRIORITY)); ISCSI_MAX_VLAN_PRIORITY));
break; break;
default: default:
WARN_ON(1); WARN_ON(1);
......
...@@ -1001,6 +1001,9 @@ static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd, ...@@ -1001,6 +1001,9 @@ static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd,
} }
cmd->size = size; cmd->size = size;
be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size); be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size);
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BG_%d : subsystem iSCSI cmd %d size %d\n",
iscsi_cmd, size);
return 0; return 0;
} }
...@@ -1259,6 +1262,42 @@ int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type) ...@@ -1259,6 +1262,42 @@ int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type)
return rc; return rc;
} }
/**
* beiscsi_if_set_vlan()- Issue and wait for CMD completion
* @phba: device private structure instance
* @vlan_tag: VLAN tag
*
* Issue the MBX Cmd and wait for the completion of the
* command.
*
* returns
* Success: 0
* Failure: Non-Xero Value
**/
int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag)
{
int rc;
unsigned int tag;
tag = be_cmd_set_vlan(phba, vlan_tag);
if (!tag) {
beiscsi_log(phba, KERN_ERR,
(BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
"BG_%d : VLAN Setting Failed\n");
return -EBUSY;
}
rc = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL);
if (rc) {
beiscsi_log(phba, KERN_ERR,
(BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
"BS_%d : VLAN MBX Cmd Failed\n");
return rc;
}
return rc;
}
int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type,
struct be_cmd_get_if_info_resp **if_info) struct be_cmd_get_if_info_resp **if_info)
{ {
...@@ -1447,42 +1486,6 @@ int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, ...@@ -1447,42 +1486,6 @@ int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba,
return -ENXIO; return -ENXIO;
} }
/**
* mgmt_set_vlan()- Issue and wait for CMD completion
* @phba: device private structure instance
* @vlan_tag: VLAN tag
*
* Issue the MBX Cmd and wait for the completion of the
* command.
*
* returns
* Success: 0
* Failure: Non-Xero Value
**/
int mgmt_set_vlan(struct beiscsi_hba *phba,
uint16_t vlan_tag)
{
int rc;
unsigned int tag;
tag = be_cmd_set_vlan(phba, vlan_tag);
if (!tag) {
beiscsi_log(phba, KERN_ERR,
(BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
"BG_%d : VLAN Setting Failed\n");
return -EBUSY;
}
rc = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL);
if (rc) {
beiscsi_log(phba, KERN_ERR,
(BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
"BS_%d : VLAN MBX Cmd Failed\n");
return rc;
}
return rc;
}
/** /**
* beiscsi_drvr_ver_disp()- Display the driver Name and Version * beiscsi_drvr_ver_disp()- Display the driver Name and Version
* @dev: ptr to device not used. * @dev: ptr to device not used.
......
...@@ -308,7 +308,7 @@ int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, ...@@ -308,7 +308,7 @@ int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba,
unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba); unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba);
int mgmt_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
ssize_t beiscsi_drvr_ver_disp(struct device *dev, ssize_t beiscsi_drvr_ver_disp(struct device *dev,
struct device_attribute *attr, char *buf); struct device_attribute *attr, char *buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment