aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRajesh Borundia <rajesh.borundia@qlogic.com>2010-08-31 13:17:50 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-01 13:41:56 -0400
commit7373373d100e5aebe751af0b2609a9a01dad5ac1 (patch)
tree3816ae48d6f3f33beeb20f2c66b2b4ab333dc1fa /drivers
parentdcb50afff747d15fc2ffff762c08c325e4c229e5 (diff)
qlcnic: fix mac override capability
o Rename mac_learning to mac_override o Added check in set_mac to return error if mac override is disabled. o Disabling mac_override only supported for Non priviledged functions. Signed-off-by: Rajesh Borundia <rajesh.borundia@qlogic.com> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/qlcnic/qlcnic.h5
-rw-r--r--drivers/net/qlcnic/qlcnic_ctx.c13
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c23
3 files changed, 28 insertions, 13 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index 220370fac726..cd1a2e6f59d2 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -905,6 +905,7 @@ struct qlcnic_mac_req {
905#define QLCNIC_ADAPTER_INITIALIZED 0x80 905#define QLCNIC_ADAPTER_INITIALIZED 0x80
906#define QLCNIC_TAGGING_ENABLED 0x100 906#define QLCNIC_TAGGING_ENABLED 0x100
907#define QLCNIC_MACSPOOF 0x200 907#define QLCNIC_MACSPOOF 0x200
908#define QLCNIC_MAC_OVERRIDE_DISABLED 0x400
908#define QLCNIC_IS_MSI_FAMILY(adapter) \ 909#define QLCNIC_IS_MSI_FAMILY(adapter) \
909 ((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED)) 910 ((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED))
910 911
@@ -1060,7 +1061,7 @@ struct qlcnic_npar_info {
1060 u8 enable_pm; 1061 u8 enable_pm;
1061 u8 dest_npar; 1062 u8 dest_npar;
1062 u8 discard_tagged; 1063 u8 discard_tagged;
1063 u8 mac_learning; 1064 u8 mac_override;
1064 u8 mac_anti_spoof; 1065 u8 mac_anti_spoof;
1065 u8 promisc_mode; 1066 u8 promisc_mode;
1066 u8 offload_flags; 1067 u8 offload_flags;
@@ -1134,7 +1135,7 @@ struct qlcnic_esw_func_cfg {
1134 u8 host_vlan_tag; 1135 u8 host_vlan_tag;
1135 u8 promisc_mode; 1136 u8 promisc_mode;
1136 u8 discard_tagged; 1137 u8 discard_tagged;
1137 u8 mac_learning; 1138 u8 mac_override;
1138 u8 mac_anti_spoof; 1139 u8 mac_anti_spoof;
1139 u8 offload_flags; 1140 u8 offload_flags;
1140 u8 reserved[5]; 1141 u8 reserved[5];
diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c
index bd4b06b2d86d..95a821e0b66f 100644
--- a/drivers/net/qlcnic/qlcnic_ctx.c
+++ b/drivers/net/qlcnic/qlcnic_ctx.c
@@ -1100,10 +1100,11 @@ __qlcnic_get_eswitch_port_config(struct qlcnic_adapter *adapter,
1100 *arg1 = QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET); 1100 *arg1 = QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET);
1101 *arg2 = QLCRD32(adapter, QLCNIC_ARG2_CRB_OFFSET); 1101 *arg2 = QLCRD32(adapter, QLCNIC_ARG2_CRB_OFFSET);
1102 dev_info(&adapter->pdev->dev, 1102 dev_info(&adapter->pdev->dev,
1103 "eSwitch port config for pci func%d\n", pci_func); 1103 "eSwitch port config for pci func %d\n", pci_func);
1104 } else { 1104 } else {
1105 dev_err(&adapter->pdev->dev, 1105 dev_err(&adapter->pdev->dev,
1106 "Failed to get eswitch port config%d\n", pci_func); 1106 "Failed to get eswitch port config for pci func %d\n",
1107 pci_func);
1107 } 1108 }
1108 return err; 1109 return err;
1109} 1110}
@@ -1142,7 +1143,7 @@ int qlcnic_config_switch_port(struct qlcnic_adapter *adapter,
1142 arg1 &= ~BIT_4; 1143 arg1 &= ~BIT_4;
1143 if (!(esw_cfg->promisc_mode)) 1144 if (!(esw_cfg->promisc_mode))
1144 arg1 &= ~BIT_6; 1145 arg1 &= ~BIT_6;
1145 if (!(esw_cfg->mac_learning)) 1146 if (!(esw_cfg->mac_override))
1146 arg1 &= ~BIT_7; 1147 arg1 &= ~BIT_7;
1147 if (!(esw_cfg->mac_anti_spoof)) 1148 if (!(esw_cfg->mac_anti_spoof))
1148 arg2 &= ~BIT_0; 1149 arg2 &= ~BIT_0;
@@ -1175,10 +1176,10 @@ int qlcnic_config_switch_port(struct qlcnic_adapter *adapter,
1175 1176
1176 if (err != QLCNIC_RCODE_SUCCESS) { 1177 if (err != QLCNIC_RCODE_SUCCESS) {
1177 dev_err(&adapter->pdev->dev, 1178 dev_err(&adapter->pdev->dev,
1178 "Failed to configure eswitch port%d\n", pci_func); 1179 "Failed to configure eswitch pci func %d\n", pci_func);
1179 } else { 1180 } else {
1180 dev_info(&adapter->pdev->dev, 1181 dev_info(&adapter->pdev->dev,
1181 "Configured eSwitch for port %d\n", pci_func); 1182 "Configured eSwitch for pci func %d\n", pci_func);
1182 } 1183 }
1183 1184
1184 return err; 1185 return err;
@@ -1202,7 +1203,7 @@ qlcnic_get_eswitch_port_config(struct qlcnic_adapter *adapter,
1202 esw_cfg->discard_tagged = !!(arg1 & BIT_4); 1203 esw_cfg->discard_tagged = !!(arg1 & BIT_4);
1203 esw_cfg->host_vlan_tag = !!(arg1 & BIT_5); 1204 esw_cfg->host_vlan_tag = !!(arg1 & BIT_5);
1204 esw_cfg->promisc_mode = !!(arg1 & BIT_6); 1205 esw_cfg->promisc_mode = !!(arg1 & BIT_6);
1205 esw_cfg->mac_learning = !!(arg1 & BIT_7); 1206 esw_cfg->mac_override = !!(arg1 & BIT_7);
1206 esw_cfg->vlan_id = LSW(arg1 >> 16); 1207 esw_cfg->vlan_id = LSW(arg1 >> 16);
1207 esw_cfg->mac_anti_spoof = (arg2 & 0x1); 1208 esw_cfg->mac_anti_spoof = (arg2 & 0x1);
1208 esw_cfg->offload_flags = ((arg2 >> 1) & 0x7); 1209 esw_cfg->offload_flags = ((arg2 >> 1) & 0x7);
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 789fe817cfca..130f4dbe2f4b 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -343,6 +343,9 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p)
343 struct qlcnic_adapter *adapter = netdev_priv(netdev); 343 struct qlcnic_adapter *adapter = netdev_priv(netdev);
344 struct sockaddr *addr = p; 344 struct sockaddr *addr = p;
345 345
346 if ((adapter->flags & QLCNIC_MAC_OVERRIDE_DISABLED))
347 return -EOPNOTSUPP;
348
346 if (!is_valid_ether_addr(addr->sa_data)) 349 if (!is_valid_ether_addr(addr->sa_data))
347 return -EINVAL; 350 return -EINVAL;
348 351
@@ -741,10 +744,14 @@ qlcnic_set_eswitch_port_features(struct qlcnic_adapter *adapter,
741 struct qlcnic_esw_func_cfg *esw_cfg) 744 struct qlcnic_esw_func_cfg *esw_cfg)
742{ 745{
743 adapter->flags &= ~QLCNIC_MACSPOOF; 746 adapter->flags &= ~QLCNIC_MACSPOOF;
747 adapter->flags &= ~QLCNIC_MAC_OVERRIDE_DISABLED;
744 748
745 if (esw_cfg->mac_anti_spoof) 749 if (esw_cfg->mac_anti_spoof)
746 adapter->flags |= QLCNIC_MACSPOOF; 750 adapter->flags |= QLCNIC_MACSPOOF;
747 751
752 if (!esw_cfg->mac_override)
753 adapter->flags |= QLCNIC_MAC_OVERRIDE_DISABLED;
754
748 qlcnic_set_netdev_features(adapter, esw_cfg); 755 qlcnic_set_netdev_features(adapter, esw_cfg);
749} 756}
750 757
@@ -862,14 +869,14 @@ qlcnic_set_default_offload_settings(struct qlcnic_adapter *adapter)
862 memset(&esw_cfg, 0, sizeof(struct qlcnic_esw_func_cfg)); 869 memset(&esw_cfg, 0, sizeof(struct qlcnic_esw_func_cfg));
863 esw_cfg.pci_func = i; 870 esw_cfg.pci_func = i;
864 esw_cfg.offload_flags = BIT_0; 871 esw_cfg.offload_flags = BIT_0;
865 esw_cfg.mac_learning = BIT_0; 872 esw_cfg.mac_override = BIT_0;
866 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) 873 if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO)
867 esw_cfg.offload_flags |= (BIT_1 | BIT_2); 874 esw_cfg.offload_flags |= (BIT_1 | BIT_2);
868 if (qlcnic_config_switch_port(adapter, &esw_cfg)) 875 if (qlcnic_config_switch_port(adapter, &esw_cfg))
869 return -EIO; 876 return -EIO;
870 npar = &adapter->npars[i]; 877 npar = &adapter->npars[i];
871 npar->pvid = esw_cfg.vlan_id; 878 npar->pvid = esw_cfg.vlan_id;
872 npar->mac_learning = esw_cfg.offload_flags; 879 npar->mac_override = esw_cfg.mac_override;
873 npar->mac_anti_spoof = esw_cfg.mac_anti_spoof; 880 npar->mac_anti_spoof = esw_cfg.mac_anti_spoof;
874 npar->discard_tagged = esw_cfg.discard_tagged; 881 npar->discard_tagged = esw_cfg.discard_tagged;
875 npar->promisc_mode = esw_cfg.promisc_mode; 882 npar->promisc_mode = esw_cfg.promisc_mode;
@@ -887,7 +894,7 @@ qlcnic_reset_eswitch_config(struct qlcnic_adapter *adapter,
887 esw_cfg.op_mode = QLCNIC_PORT_DEFAULTS; 894 esw_cfg.op_mode = QLCNIC_PORT_DEFAULTS;
888 esw_cfg.pci_func = pci_func; 895 esw_cfg.pci_func = pci_func;
889 esw_cfg.vlan_id = npar->pvid; 896 esw_cfg.vlan_id = npar->pvid;
890 esw_cfg.mac_learning = npar->mac_learning; 897 esw_cfg.mac_override = npar->mac_override;
891 esw_cfg.discard_tagged = npar->discard_tagged; 898 esw_cfg.discard_tagged = npar->discard_tagged;
892 esw_cfg.mac_anti_spoof = npar->mac_anti_spoof; 899 esw_cfg.mac_anti_spoof = npar->mac_anti_spoof;
893 esw_cfg.offload_flags = npar->offload_flags; 900 esw_cfg.offload_flags = npar->offload_flags;
@@ -3042,6 +3049,10 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)
3042 3049
3043 qlcnic_check_options(adapter); 3050 qlcnic_check_options(adapter);
3044 3051
3052 err = qlcnic_set_eswitch_port_config(adapter);
3053 if (err)
3054 return err;
3055
3045 adapter->need_fw_reset = 0; 3056 adapter->need_fw_reset = 0;
3046 3057
3047 return err; 3058 return err;
@@ -3397,8 +3408,10 @@ validate_esw_config(struct qlcnic_adapter *adapter,
3397 switch (esw_cfg[i].op_mode) { 3408 switch (esw_cfg[i].op_mode) {
3398 case QLCNIC_PORT_DEFAULTS: 3409 case QLCNIC_PORT_DEFAULTS:
3399 if (QLC_DEV_GET_DRV(op_mode, pci_func) != 3410 if (QLC_DEV_GET_DRV(op_mode, pci_func) !=
3400 QLCNIC_NON_PRIV_FUNC) 3411 QLCNIC_NON_PRIV_FUNC) {
3401 esw_cfg[i].mac_anti_spoof = 0; 3412 esw_cfg[i].mac_anti_spoof = 0;
3413 esw_cfg[i].mac_override = 1;
3414 }
3402 break; 3415 break;
3403 case QLCNIC_ADD_VLAN: 3416 case QLCNIC_ADD_VLAN:
3404 if (!IS_VALID_VLAN(esw_cfg[i].vlan_id)) 3417 if (!IS_VALID_VLAN(esw_cfg[i].vlan_id))
@@ -3474,7 +3487,7 @@ qlcnic_sysfs_write_esw_config(struct file *file, struct kobject *kobj,
3474 switch (esw_cfg[i].op_mode) { 3487 switch (esw_cfg[i].op_mode) {
3475 case QLCNIC_PORT_DEFAULTS: 3488 case QLCNIC_PORT_DEFAULTS:
3476 npar->promisc_mode = esw_cfg[i].promisc_mode; 3489 npar->promisc_mode = esw_cfg[i].promisc_mode;
3477 npar->mac_learning = esw_cfg[i].mac_learning; 3490 npar->mac_override = esw_cfg[i].mac_override;
3478 npar->offload_flags = esw_cfg[i].offload_flags; 3491 npar->offload_flags = esw_cfg[i].offload_flags;
3479 npar->mac_anti_spoof = esw_cfg[i].mac_anti_spoof; 3492 npar->mac_anti_spoof = esw_cfg[i].mac_anti_spoof;
3480 npar->discard_tagged = esw_cfg[i].discard_tagged; 3493 npar->discard_tagged = esw_cfg[i].discard_tagged;