aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Chaudhary <vikas.chaudhary@qlogic.com>2011-07-25 14:48:49 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-08-27 10:36:20 -0400
commit6ac73e8cb02e65abeb2f8d43f0fe48e485444b44 (patch)
treecfaeff9e95ed40c36cd5616c3c39e63802abf4fb
parent5431ae267ab20464cea3e1c1d1bc34d259f3973c (diff)
[SCSI] qla4xxx: Add VLAN support
Add support to set VLAN and show vlan settings in sysfs Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com> Signed-off-by: Harish Zunjarrao <harish.zunjarrao@qlogic.com> [Patch updated to new defines] Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/qla4xxx/ql4_fw.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c4
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c57
3 files changed, 61 insertions, 2 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 8ffdd347978..83e009cafa3 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -484,6 +484,7 @@ struct addr_ctrl_blk {
484#define TCPOPT_DHCP_ENABLE 0x0200 484#define TCPOPT_DHCP_ENABLE 0x0200
485 uint16_t ipv4_ip_opts; /* 34-35 */ 485 uint16_t ipv4_ip_opts; /* 34-35 */
486#define IPOPT_IPV4_PROTOCOL_ENABLE 0x8000 486#define IPOPT_IPV4_PROTOCOL_ENABLE 0x8000
487#define IPOPT_VLAN_TAGGING_ENABLE 0x2000
487 488
488 uint16_t iscsi_max_pdu_size; /* 36-37 */ 489 uint16_t iscsi_max_pdu_size; /* 36-37 */
489 uint8_t ipv4_tos; /* 38 */ 490 uint8_t ipv4_tos; /* 38 */
@@ -535,6 +536,7 @@ struct addr_ctrl_blk {
535 uint16_t ipv6_port; /* 204-205 */ 536 uint16_t ipv6_port; /* 204-205 */
536 uint16_t ipv6_opts; /* 206-207 */ 537 uint16_t ipv6_opts; /* 206-207 */
537#define IPV6_OPT_IPV6_PROTOCOL_ENABLE 0x8000 538#define IPV6_OPT_IPV6_PROTOCOL_ENABLE 0x8000
539#define IPV6_OPT_VLAN_TAGGING_ENABLE 0x2000
538 540
539 uint16_t ipv6_addtl_opts; /* 208-209 */ 541 uint16_t ipv6_addtl_opts; /* 208-209 */
540#define IPV6_ADDOPT_NEIGHBOR_DISCOVERY_ADDR_ENABLE 0x0002 /* Pri ACB 542#define IPV6_ADDOPT_NEIGHBOR_DISCOVERY_ADDR_ENABLE 0x0002 /* Pri ACB
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 0e7530e7e7d..ea04b6cecfa 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -351,6 +351,8 @@ qla4xxx_update_local_ip(struct scsi_qla_host *ha,
351 min(sizeof(ha->ip_config.gateway), 351 min(sizeof(ha->ip_config.gateway),
352 sizeof(init_fw_cb->ipv4_gw_addr))); 352 sizeof(init_fw_cb->ipv4_gw_addr)));
353 353
354 ha->ip_config.ipv4_vlan_tag = be16_to_cpu(init_fw_cb->ipv4_vlan_tag);
355
354 if (is_ipv6_enabled(ha)) { 356 if (is_ipv6_enabled(ha)) {
355 /* Save IPv6 Address */ 357 /* Save IPv6 Address */
356 ha->ip_config.ipv6_link_local_state = 358 ha->ip_config.ipv6_link_local_state =
@@ -378,6 +380,8 @@ qla4xxx_update_local_ip(struct scsi_qla_host *ha,
378 init_fw_cb->ipv6_dflt_rtr_addr, 380 init_fw_cb->ipv6_dflt_rtr_addr,
379 min(sizeof(ha->ip_config.ipv6_default_router_addr), 381 min(sizeof(ha->ip_config.ipv6_default_router_addr),
380 sizeof(init_fw_cb->ipv6_dflt_rtr_addr))); 382 sizeof(init_fw_cb->ipv6_dflt_rtr_addr)));
383 ha->ip_config.ipv6_vlan_tag =
384 be16_to_cpu(init_fw_cb->ipv6_vlan_tag);
381 } 385 }
382} 386}
383 387
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index a9da3152ee5..d5f9f60609b 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -185,6 +185,9 @@ static mode_t ql4_attr_is_visible(int param_type, int param)
185 case ISCSI_NET_PARAM_IPV6_ROUTER: 185 case ISCSI_NET_PARAM_IPV6_ROUTER:
186 case ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG: 186 case ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG:
187 case ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG: 187 case ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG:
188 case ISCSI_NET_PARAM_VLAN_ID:
189 case ISCSI_NET_PARAM_VLAN_PRIORITY:
190 case ISCSI_NET_PARAM_VLAN_ENABLED:
188 return S_IRUGO; 191 return S_IRUGO;
189 default: 192 default:
190 return 0; 193 return 0;
@@ -258,6 +261,38 @@ static int qla4xxx_get_iface_param(struct iscsi_iface *iface,
258 IPV6_ADDOPT_AUTOCONFIG_LINK_LOCAL_ADDR) ? 261 IPV6_ADDOPT_AUTOCONFIG_LINK_LOCAL_ADDR) ?
259 "auto" : "static"); 262 "auto" : "static");
260 break; 263 break;
264 case ISCSI_NET_PARAM_VLAN_ID:
265 if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
266 len = sprintf(buf, "%d\n",
267 (ha->ip_config.ipv4_vlan_tag &
268 ISCSI_MAX_VLAN_ID));
269 else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
270 len = sprintf(buf, "%d\n",
271 (ha->ip_config.ipv6_vlan_tag &
272 ISCSI_MAX_VLAN_ID));
273 break;
274 case ISCSI_NET_PARAM_VLAN_PRIORITY:
275 if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
276 len = sprintf(buf, "%d\n",
277 ((ha->ip_config.ipv4_vlan_tag >> 13) &
278 ISCSI_MAX_VLAN_PRIORITY));
279 else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
280 len = sprintf(buf, "%d\n",
281 ((ha->ip_config.ipv6_vlan_tag >> 13) &
282 ISCSI_MAX_VLAN_PRIORITY));
283 break;
284 case ISCSI_NET_PARAM_VLAN_ENABLED:
285 if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
286 len = sprintf(buf, "%s\n",
287 (ha->ip_config.ipv4_options &
288 IPOPT_VLAN_TAGGING_ENABLE) ?
289 "enabled" : "disabled");
290 else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
291 len = sprintf(buf, "%s\n",
292 (ha->ip_config.ipv6_options &
293 IPV6_OPT_VLAN_TAGGING_ENABLE) ?
294 "enabled" : "disabled");
295 break;
261 default: 296 default:
262 len = -ENOSYS; 297 len = -ENOSYS;
263 } 298 }
@@ -479,7 +514,16 @@ static void qla4xxx_set_ipv6(struct scsi_qla_host *ha,
479 case ISCSI_NET_PARAM_VLAN_ID: 514 case ISCSI_NET_PARAM_VLAN_ID:
480 if (iface_param->len != sizeof(init_fw_cb->ipv6_vlan_tag)) 515 if (iface_param->len != sizeof(init_fw_cb->ipv6_vlan_tag))
481 break; 516 break;
482 init_fw_cb->ipv6_vlan_tag = *(uint16_t *)iface_param->value; 517 init_fw_cb->ipv6_vlan_tag =
518 cpu_to_be16(*(uint16_t *)iface_param->value);
519 break;
520 case ISCSI_NET_PARAM_VLAN_ENABLED:
521 if (iface_param->value[0] == ISCSI_VLAN_ENABLE)
522 init_fw_cb->ipv6_opts |=
523 cpu_to_le16(IPV6_OPT_VLAN_TAGGING_ENABLE);
524 else
525 init_fw_cb->ipv6_opts &=
526 cpu_to_le16(~IPV6_OPT_VLAN_TAGGING_ENABLE);
483 break; 527 break;
484 default: 528 default:
485 ql4_printk(KERN_ERR, ha, "Unknown IPv6 param = %d\n", 529 ql4_printk(KERN_ERR, ha, "Unknown IPv6 param = %d\n",
@@ -530,7 +574,16 @@ static void qla4xxx_set_ipv4(struct scsi_qla_host *ha,
530 case ISCSI_NET_PARAM_VLAN_ID: 574 case ISCSI_NET_PARAM_VLAN_ID:
531 if (iface_param->len != sizeof(init_fw_cb->ipv4_vlan_tag)) 575 if (iface_param->len != sizeof(init_fw_cb->ipv4_vlan_tag))
532 break; 576 break;
533 init_fw_cb->ipv4_vlan_tag = *(uint16_t *)iface_param->value; 577 init_fw_cb->ipv4_vlan_tag =
578 cpu_to_be16(*(uint16_t *)iface_param->value);
579 break;
580 case ISCSI_NET_PARAM_VLAN_ENABLED:
581 if (iface_param->value[0] == ISCSI_VLAN_ENABLE)
582 init_fw_cb->ipv4_ip_opts |=
583 cpu_to_le16(IPOPT_VLAN_TAGGING_ENABLE);
584 else
585 init_fw_cb->ipv4_ip_opts &=
586 cpu_to_le16(~IPOPT_VLAN_TAGGING_ENABLE);
534 break; 587 break;
535 default: 588 default:
536 ql4_printk(KERN_ERR, ha, "Unknown IPv4 param = %d\n", 589 ql4_printk(KERN_ERR, ha, "Unknown IPv4 param = %d\n",