aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/be2iscsi
diff options
context:
space:
mode:
authorJohn Soni Jose <sony.john-n@emulex.com>2012-08-20 13:30:43 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-09-14 12:59:27 -0400
commit6f72238e774742f618ba0332b76b1860762a40cb (patch)
treec3f702662a58859b2c357e24593a4517bb019bc1 /drivers/scsi/be2iscsi
parentdf5d0e6ee9d68f874959fa028388efa26f495f63 (diff)
[SCSI] be2iscsi: Add support for configuring the VLAN on the adapter.
Add support for configuring the VLAN parameters on the adapter using the iscsiadm interface. Signed-off-by: John Soni Jose <sony.john-n@emulex.com> Signed-off-by: Jayamohan Kallickal <jayamohan.kallickal@emulex.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/be2iscsi')
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.c42
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.h9
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c76
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.c46
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.h4
5 files changed, 177 insertions, 0 deletions
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index d0058e38bc62..07d2cb126d93 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -934,3 +934,45 @@ int beiscsi_cmd_reset_function(struct beiscsi_hba *phba)
934 spin_unlock(&ctrl->mbox_lock); 934 spin_unlock(&ctrl->mbox_lock);
935 return status; 935 return status;
936} 936}
937
938/**
939 * be_cmd_set_vlan()- Configure VLAN paramters on the adapter
940 * @phba: device priv structure instance
941 * @vlan_tag: TAG to be set
942 *
943 * Set the VLAN_TAG for the adapter or Disable VLAN on adapter
944 *
945 * returns
946 * TAG for the MBX Cmd
947 * **/
948int be_cmd_set_vlan(struct beiscsi_hba *phba,
949 uint16_t vlan_tag)
950{
951 unsigned int tag = 0;
952 struct be_mcc_wrb *wrb;
953 struct be_cmd_set_vlan_req *req;
954 struct be_ctrl_info *ctrl = &phba->ctrl;
955
956 spin_lock(&ctrl->mbox_lock);
957 tag = alloc_mcc_tag(phba);
958 if (!tag) {
959 spin_unlock(&ctrl->mbox_lock);
960 return tag;
961 }
962
963 wrb = wrb_from_mccq(phba);
964 req = embedded_payload(wrb);
965 wrb->tag0 |= tag;
966 be_wrb_hdr_prepare(wrb, sizeof(*wrb), true, 0);
967 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
968 OPCODE_COMMON_ISCSI_NTWK_SET_VLAN,
969 sizeof(*req));
970
971 req->interface_hndl = phba->interface_handle;
972 req->vlan_priority = vlan_tag;
973
974 be_mcc_notify(phba);
975 spin_unlock(&ctrl->mbox_lock);
976
977 return tag;
978}
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 953c354c4d97..2c8f98df1287 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -449,6 +449,12 @@ struct be_cmd_get_def_gateway_resp {
449 struct ip_addr_format ip_addr; 449 struct ip_addr_format ip_addr;
450} __packed; 450} __packed;
451 451
452#define BEISCSI_VLAN_DISABLE 0xFFFF
453struct be_cmd_set_vlan_req {
454 struct be_cmd_req_hdr hdr;
455 u32 interface_hndl;
456 u32 vlan_priority;
457} __packed;
452/******************** Create CQ ***************************/ 458/******************** Create CQ ***************************/
453/** 459/**
454 * Pseudo amap definition in which each bit of the actual structure is defined 460 * Pseudo amap definition in which each bit of the actual structure is defined
@@ -688,6 +694,9 @@ int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
688 694
689bool is_link_state_evt(u32 trailer); 695bool is_link_state_evt(u32 trailer);
690 696
697/* Configuration Functions */
698int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
699
691struct be_default_pdu_context { 700struct be_default_pdu_context {
692 u32 dw[4]; 701 u32 dw[4];
693} __packed; 702} __packed;
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 8efdd8e2d989..ebb6c1fc1607 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -332,6 +332,51 @@ beiscsi_set_static_ip(struct Scsi_Host *shost,
332 return ret; 332 return ret;
333} 333}
334 334
335/**
336 * beiscsi_set_vlan_tag()- Set the VLAN TAG
337 * @shost: Scsi Host for the driver instance
338 * @iface_param: Interface paramters
339 *
340 * Set the VLAN TAG for the adapter or disable
341 * the VLAN config
342 *
343 * returns
344 * Success: 0
345 * Failure: Non-Zero Value
346 **/
347static int
348beiscsi_set_vlan_tag(struct Scsi_Host *shost,
349 struct iscsi_iface_param_info *iface_param)
350{
351 struct beiscsi_hba *phba = iscsi_host_priv(shost);
352 int ret = 0;
353
354 /* Get the Interface Handle */
355 if (mgmt_get_all_if_id(phba)) {
356 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
357 "BS_%d : Getting Interface Handle Failed\n");
358 return -EIO;
359 }
360
361 switch (iface_param->param) {
362 case ISCSI_NET_PARAM_VLAN_ENABLED:
363 if (iface_param->value[0] != ISCSI_VLAN_ENABLE)
364 ret = mgmt_set_vlan(phba, BEISCSI_VLAN_DISABLE);
365 break;
366 case ISCSI_NET_PARAM_VLAN_TAG:
367 ret = mgmt_set_vlan(phba,
368 *((uint16_t *)iface_param->value));
369 break;
370 default:
371 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
372 "BS_%d : Unkown Param Type : %d\n",
373 iface_param->param);
374 return -ENOSYS;
375 }
376 return ret;
377}
378
379
335static int 380static int
336beiscsi_set_ipv4(struct Scsi_Host *shost, 381beiscsi_set_ipv4(struct Scsi_Host *shost,
337 struct iscsi_iface_param_info *iface_param, 382 struct iscsi_iface_param_info *iface_param,
@@ -368,6 +413,10 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
368 ret = beiscsi_set_static_ip(shost, iface_param, 413 ret = beiscsi_set_static_ip(shost, iface_param,
369 data, dt_len); 414 data, dt_len);
370 break; 415 break;
416 case ISCSI_NET_PARAM_VLAN_ENABLED:
417 case ISCSI_NET_PARAM_VLAN_TAG:
418 ret = beiscsi_set_vlan_tag(shost, iface_param);
419 break;
371 default: 420 default:
372 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 421 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
373 "BS_%d : Param %d not supported\n", 422 "BS_%d : Param %d not supported\n",
@@ -489,6 +538,27 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
489 case ISCSI_NET_PARAM_IPV4_SUBNET: 538 case ISCSI_NET_PARAM_IPV4_SUBNET:
490 len = sprintf(buf, "%pI4\n", &if_info.ip_addr.subnet_mask); 539 len = sprintf(buf, "%pI4\n", &if_info.ip_addr.subnet_mask);
491 break; 540 break;
541 case ISCSI_NET_PARAM_VLAN_ENABLED:
542 len = sprintf(buf, "%s\n",
543 (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
544 ? "Disabled" : "Enabled");
545 break;
546 case ISCSI_NET_PARAM_VLAN_ID:
547 if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
548 return -EINVAL;
549 else
550 len = sprintf(buf, "%d\n",
551 (if_info.vlan_priority &
552 ISCSI_MAX_VLAN_ID));
553 break;
554 case ISCSI_NET_PARAM_VLAN_PRIORITY:
555 if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE)
556 return -EINVAL;
557 else
558 len = sprintf(buf, "%d\n",
559 ((if_info.vlan_priority >> 13) &
560 ISCSI_MAX_VLAN_PRIORITY));
561 break;
492 default: 562 default:
493 WARN_ON(1); 563 WARN_ON(1);
494 } 564 }
@@ -510,6 +580,9 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
510 case ISCSI_NET_PARAM_IPV4_SUBNET: 580 case ISCSI_NET_PARAM_IPV4_SUBNET:
511 case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 581 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
512 case ISCSI_NET_PARAM_IPV6_ADDR: 582 case ISCSI_NET_PARAM_IPV6_ADDR:
583 case ISCSI_NET_PARAM_VLAN_ENABLED:
584 case ISCSI_NET_PARAM_VLAN_ID:
585 case ISCSI_NET_PARAM_VLAN_PRIORITY:
513 len = be2iscsi_get_if_param(phba, iface, param, buf); 586 len = be2iscsi_get_if_param(phba, iface, param, buf);
514 break; 587 break;
515 case ISCSI_NET_PARAM_IFACE_ENABLE: 588 case ISCSI_NET_PARAM_IFACE_ENABLE:
@@ -1233,6 +1306,9 @@ umode_t be2iscsi_attr_is_visible(int param_type, int param)
1233 case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 1306 case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
1234 case ISCSI_NET_PARAM_IPV4_GW: 1307 case ISCSI_NET_PARAM_IPV4_GW:
1235 case ISCSI_NET_PARAM_IPV6_ADDR: 1308 case ISCSI_NET_PARAM_IPV6_ADDR:
1309 case ISCSI_NET_PARAM_VLAN_ID:
1310 case ISCSI_NET_PARAM_VLAN_PRIORITY:
1311 case ISCSI_NET_PARAM_VLAN_ENABLED:
1236 return S_IRUGO; 1312 return S_IRUGO;
1237 default: 1313 default:
1238 return 0; 1314 return 0;
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 3dca332acce2..aab5dd359e2c 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1090,3 +1090,49 @@ int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba,
1090 "BG_%d : Login to Boot Target Failed\n"); 1090 "BG_%d : Login to Boot Target Failed\n");
1091 return -ENXIO; 1091 return -ENXIO;
1092} 1092}
1093
1094/**
1095 * mgmt_set_vlan()- Issue and wait for CMD completion
1096 * @phba: device private structure instance
1097 * @vlan_tag: VLAN tag
1098 *
1099 * Issue the MBX Cmd and wait for the completion of the
1100 * command.
1101 *
1102 * returns
1103 * Success: 0
1104 * Failure: Non-Xero Value
1105 **/
1106int mgmt_set_vlan(struct beiscsi_hba *phba,
1107 uint16_t vlan_tag)
1108{
1109 unsigned int tag, wrb_num;
1110 unsigned short status, extd_status;
1111
1112 tag = be_cmd_set_vlan(phba, vlan_tag);
1113 if (!tag) {
1114 beiscsi_log(phba, KERN_ERR,
1115 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
1116 "BG_%d : VLAN Setting Failed\n");
1117 return -EBUSY;
1118 } else
1119 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
1120 phba->ctrl.mcc_numtag[tag]);
1121
1122 wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
1123 extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
1124 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
1125
1126 if (status || extd_status) {
1127 beiscsi_log(phba, KERN_ERR,
1128 (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
1129 "BS_%d : status : %d extd_status : %d\n",
1130 status, extd_status);
1131
1132 free_mcc_tag(&phba->ctrl, tag);
1133 return -EAGAIN;
1134 }
1135
1136 free_mcc_tag(&phba->ctrl, tag);
1137 return 0;
1138}
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index 63b8e81f3250..1bbac5c69da2 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -296,4 +296,8 @@ int mgmt_set_gateway(struct beiscsi_hba *phba,
296 296
297int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, 297int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba,
298 unsigned int *s_handle); 298 unsigned int *s_handle);
299
300unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba);
301
302int mgmt_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
299#endif 303#endif