aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJitendra Bhivare <jitendra.bhivare@broadcom.com>2016-08-19 05:50:02 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2016-08-23 22:42:42 -0400
commit37f216482a72ea8ffc2935b2e7e926ba1241a2dd (patch)
tree7a0d012a79d873011ac0f3d1b01895ce8d3da78f
parentf7dd017e133e3b2d0395156f8d1ed16be732a6a7 (diff)
scsi: be2iscsi: Fix gateway APIs to support IPv4 & IPv6
Gateway APIs assume IP type as IPv4. Modify it to be generic to allow clearing of IPv6 gateway set using BIOS. Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c4
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.c124
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.h7
3 files changed, 62 insertions, 73 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index eab0f4fdbb31..3ebfeff42653 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -419,7 +419,7 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
419 } 419 }
420 break; 420 break;
421 case ISCSI_NET_PARAM_IPV4_GW: 421 case ISCSI_NET_PARAM_IPV4_GW:
422 ret = mgmt_set_gateway(phba, iface_param); 422 ret = beiscsi_if_set_gw(phba, BE2_IPV4, iface_param->value);
423 break; 423 break;
424 case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 424 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
425 if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP) 425 if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP)
@@ -635,7 +635,7 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
635 break; 635 break;
636 case ISCSI_NET_PARAM_IPV4_GW: 636 case ISCSI_NET_PARAM_IPV4_GW:
637 memset(&gateway, 0, sizeof(gateway)); 637 memset(&gateway, 0, sizeof(gateway));
638 len = mgmt_get_gateway(phba, BE2_IPV4, &gateway); 638 len = beiscsi_if_get_gw(phba, BE2_IPV4, &gateway);
639 if (!len) 639 if (!len)
640 len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr); 640 len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr);
641 break; 641 break;
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 83926e221f1e..9ef9f76d00d1 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1059,14 +1059,13 @@ mgmt_static_ip_modify(struct beiscsi_hba *phba,
1059 return rc; 1059 return rc;
1060} 1060}
1061 1061
1062static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr, 1062static int beiscsi_if_mod_gw(struct beiscsi_hba *phba,
1063 uint32_t gtway_action, uint32_t param_len) 1063 u32 action, u32 ip_type, u8 *gw)
1064{ 1064{
1065 struct be_cmd_set_def_gateway_req *req; 1065 struct be_cmd_set_def_gateway_req *req;
1066 struct be_dma_mem nonemb_cmd; 1066 struct be_dma_mem nonemb_cmd;
1067 int rt_val; 1067 int rt_val;
1068 1068
1069
1070 rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd, 1069 rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
1071 OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY, 1070 OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY,
1072 sizeof(*req)); 1071 sizeof(*req));
@@ -1074,12 +1073,60 @@ static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr,
1074 return rt_val; 1073 return rt_val;
1075 1074
1076 req = nonemb_cmd.va; 1075 req = nonemb_cmd.va;
1077 req->action = gtway_action; 1076 req->action = action;
1078 req->ip_addr.ip_type = BE2_IPV4; 1077 req->ip_addr.ip_type = ip_type;
1078 memcpy(req->ip_addr.addr, gw,
1079 (ip_type == BE2_IPV4) ? IP_V4_LEN : IP_V6_LEN);
1080 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
1081}
1079 1082
1080 memcpy(req->ip_addr.addr, gt_addr, sizeof(req->ip_addr.addr)); 1083int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw)
1084{
1085 struct be_cmd_get_def_gateway_resp gw_resp;
1086 int rt_val;
1081 1087
1082 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); 1088 memset(&gw_resp, 0, sizeof(gw_resp));
1089 rt_val = beiscsi_if_get_gw(phba, ip_type, &gw_resp);
1090 if (rt_val) {
1091 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1092 "BG_%d : Failed to Get Gateway Addr\n");
1093 return rt_val;
1094 }
1095
1096 rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_DEL, ip_type,
1097 gw_resp.ip_addr.addr);
1098 if (rt_val) {
1099 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1100 "BG_%d : Failed to clear Gateway Addr Set\n");
1101 return rt_val;
1102 }
1103
1104 rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_ADD, ip_type, gw);
1105 if (rt_val)
1106 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1107 "BG_%d : Failed to Set Gateway Addr\n");
1108
1109 return rt_val;
1110}
1111
1112int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
1113 struct be_cmd_get_def_gateway_resp *resp)
1114{
1115 struct be_cmd_get_def_gateway_req *req;
1116 struct be_dma_mem nonemb_cmd;
1117 int rc;
1118
1119 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
1120 OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY,
1121 sizeof(*resp));
1122 if (rc)
1123 return rc;
1124
1125 req = nonemb_cmd.va;
1126 req->ip_type = ip_type;
1127
1128 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, resp,
1129 sizeof(*resp));
1083} 1130}
1084 1131
1085int mgmt_set_ip(struct beiscsi_hba *phba, 1132int mgmt_set_ip(struct beiscsi_hba *phba,
@@ -1156,7 +1203,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
1156 /* Delete the Gateway settings if mode change is to DHCP */ 1203 /* Delete the Gateway settings if mode change is to DHCP */
1157 if (boot_proto == ISCSI_BOOTPROTO_DHCP) { 1204 if (boot_proto == ISCSI_BOOTPROTO_DHCP) {
1158 memset(&gtway_addr_set, 0, sizeof(gtway_addr_set)); 1205 memset(&gtway_addr_set, 0, sizeof(gtway_addr_set));
1159 rc = mgmt_get_gateway(phba, BE2_IPV4, &gtway_addr_set); 1206 rc = beiscsi_if_get_gw(phba, BE2_IPV4, &gtway_addr_set);
1160 if (rc) { 1207 if (rc) {
1161 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, 1208 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1162 "BG_%d : Failed to Get Gateway Addr\n"); 1209 "BG_%d : Failed to Get Gateway Addr\n");
@@ -1165,8 +1212,8 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
1165 1212
1166 if (gtway_addr_set.ip_addr.addr[0]) { 1213 if (gtway_addr_set.ip_addr.addr[0]) {
1167 gtway_addr = (uint8_t *)&gtway_addr_set.ip_addr.addr; 1214 gtway_addr = (uint8_t *)&gtway_addr_set.ip_addr.addr;
1168 rc = mgmt_modify_gateway(phba, gtway_addr, 1215 rc = beiscsi_if_mod_gw(phba, IP_ACTION_DEL,
1169 IP_ACTION_DEL, IP_V4_LEN); 1216 ip_type, gtway_addr);
1170 1217
1171 if (rc) { 1218 if (rc) {
1172 beiscsi_log(phba, KERN_WARNING, 1219 beiscsi_log(phba, KERN_WARNING,
@@ -1202,63 +1249,6 @@ exit:
1202 return rc; 1249 return rc;
1203} 1250}
1204 1251
1205int mgmt_set_gateway(struct beiscsi_hba *phba,
1206 struct iscsi_iface_param_info *gateway_param)
1207{
1208 struct be_cmd_get_def_gateway_resp gtway_addr_set;
1209 uint8_t *gtway_addr;
1210 int rt_val;
1211
1212 memset(&gtway_addr_set, 0, sizeof(gtway_addr_set));
1213 rt_val = mgmt_get_gateway(phba, BE2_IPV4, &gtway_addr_set);
1214 if (rt_val) {
1215 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1216 "BG_%d : Failed to Get Gateway Addr\n");
1217 return rt_val;
1218 }
1219
1220 if (gtway_addr_set.ip_addr.addr[0]) {
1221 gtway_addr = (uint8_t *)&gtway_addr_set.ip_addr.addr;
1222 rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_DEL,
1223 gateway_param->len);
1224 if (rt_val) {
1225 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1226 "BG_%d : Failed to clear Gateway Addr Set\n");
1227 return rt_val;
1228 }
1229 }
1230
1231 gtway_addr = (uint8_t *)&gateway_param->value;
1232 rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_ADD,
1233 gateway_param->len);
1234
1235 if (rt_val)
1236 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1237 "BG_%d : Failed to Set Gateway Addr\n");
1238
1239 return rt_val;
1240}
1241
1242int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type,
1243 struct be_cmd_get_def_gateway_resp *gateway)
1244{
1245 struct be_cmd_get_def_gateway_req *req;
1246 struct be_dma_mem nonemb_cmd;
1247 int rc;
1248
1249 rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd,
1250 OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY,
1251 sizeof(*gateway));
1252 if (rc)
1253 return rc;
1254
1255 req = nonemb_cmd.va;
1256 req->ip_type = ip_type;
1257
1258 return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, gateway,
1259 sizeof(*gateway));
1260}
1261
1262int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, 1252int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type,
1263 struct be_cmd_get_if_info_resp **if_info) 1253 struct be_cmd_get_if_info_resp **if_info)
1264{ 1254{
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index f3a48a04b2ca..fd9b68f318c0 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -298,11 +298,10 @@ int mgmt_get_nic_conf(struct beiscsi_hba *phba,
298int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, 298int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type,
299 struct be_cmd_get_if_info_resp **if_info); 299 struct be_cmd_get_if_info_resp **if_info);
300 300
301int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type, 301int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
302 struct be_cmd_get_def_gateway_resp *gateway); 302 struct be_cmd_get_def_gateway_resp *resp);
303 303
304int mgmt_set_gateway(struct beiscsi_hba *phba, 304int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw);
305 struct iscsi_iface_param_info *gateway_param);
306 305
307int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, 306int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba,
308 unsigned int *s_handle); 307 unsigned int *s_handle);