Skip to content

Commit 147a908

Browse files
Shahed Shaikhdavem330
authored andcommitted
qlcnic: Fix updating netdev->features
o After change in EPORT features of 82xx adapter, netdev->features needs to be updated to reflect EPORT feature updates but driver was manipulating netdev->features at wrong place. o This patch uses netdev_update_features() and .ndo_fix_features() to update netdev->features properly. Signed-off-by: Shahed Shaikh <shahed.shaikh@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0ce54ce commit 147a908

File tree

4 files changed

+61
-46
lines changed

4 files changed

+61
-46
lines changed

drivers/net/ethernet/qlogic/qlcnic/qlcnic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,11 @@ struct qlcnic_ipaddr {
907907
#define QLCNIC_FW_HANG0x4000
908908
#define QLCNIC_FW_LRO_MSS_CAP0x8000
909909
#define QLCNIC_TX_INTR_SHARED0x10000
910+
#define QLCNIC_APP_CHANGED_FLAGS0x20000
910911
#define QLCNIC_IS_MSI_FAMILY(adapter) \
911912
((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED))
913+
#define QLCNIC_IS_TSO_CAPABLE(adapter) \
914+
((adapter)->ahw->capabilities & QLCNIC_FW_CAPABILITY_TSO)
912915

913916
#define QLCNIC_DEF_NUM_STS_DESC_RINGS4
914917
#define QLCNIC_MSIX_TBL_SPACE8192
@@ -1034,6 +1037,7 @@ struct qlcnic_adapter {
10341037
spinlock_t rx_mac_learn_lock;
10351038
u32 file_prd_off;/*File fw product offset*/
10361039
u32 fw_version;
1040+
u32 offload_flags;
10371041
const struct firmware *fw;
10381042
};
10391043

@@ -1542,6 +1546,8 @@ void qlcnic_add_lb_filter(struct qlcnic_adapter *, struct sk_buff *, int, u16);
15421546
int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter);
15431547
int qlcnic_read_mac_addr(struct qlcnic_adapter *);
15441548
int qlcnic_setup_netdev(struct qlcnic_adapter *, struct net_device *, int);
1549+
void qlcnic_set_netdev_features(struct qlcnic_adapter *,
1550+
struct qlcnic_esw_func_cfg *);
15451551
void qlcnic_sriov_vf_schedule_multi(struct net_device *);
15461552
void qlcnic_vf_add_mc_list(struct net_device *, u16);
15471553

drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,16 +973,57 @@ int qlcnic_change_mtu(struct net_device *netdev, int mtu)
973973
return rc;
974974
}
975975

976+
static netdev_features_t qlcnic_process_flags(struct qlcnic_adapter *adapter,
977+
netdev_features_t features)
978+
{
979+
u32 offload_flags = adapter->offload_flags;
980+
981+
if (offload_flags & BIT_0) {
982+
features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM |
983+
NETIF_F_IPV6_CSUM;
984+
adapter->rx_csum = 1;
985+
if (QLCNIC_IS_TSO_CAPABLE(adapter)) {
986+
if (!(offload_flags & BIT_1))
987+
features &= ~NETIF_F_TSO;
988+
else
989+
features |= NETIF_F_TSO;
990+
991+
if (!(offload_flags & BIT_2))
992+
features &= ~NETIF_F_TSO6;
993+
else
994+
features |= NETIF_F_TSO6;
995+
}
996+
} else {
997+
features &= ~(NETIF_F_RXCSUM |
998+
NETIF_F_IP_CSUM |
999+
NETIF_F_IPV6_CSUM);
1000+
1001+
if (QLCNIC_IS_TSO_CAPABLE(adapter))
1002+
features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
1003+
adapter->rx_csum = 0;
1004+
}
1005+
1006+
return features;
1007+
}
9761008

9771009
netdev_features_t qlcnic_fix_features(struct net_device *netdev,
9781010
netdev_features_t features)
9791011
{
9801012
struct qlcnic_adapter *adapter = netdev_priv(netdev);
1013+
netdev_features_t changed;
9811014

982-
if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) &&
983-
qlcnic_82xx_check(adapter)) {
984-
netdev_features_t changed = features ^ netdev->features;
985-
features ^= changed & (NETIF_F_ALL_CSUM | NETIF_F_RXCSUM);
1015+
if (qlcnic_82xx_check(adapter) &&
1016+
(adapter->flags & QLCNIC_ESWITCH_ENABLED)) {
1017+
if (adapter->flags & QLCNIC_APP_CHANGED_FLAGS) {
1018+
features = qlcnic_process_flags(adapter, features);
1019+
} else {
1020+
changed = features ^ netdev->features;
1021+
features ^= changed & (NETIF_F_RXCSUM |
1022+
NETIF_F_IP_CSUM |
1023+
NETIF_F_IPV6_CSUM |
1024+
NETIF_F_TSO |
1025+
NETIF_F_TSO6);
1026+
}
9861027
}
9871028

9881029
if (!(features & NETIF_F_RXCSUM))

drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,9 @@ static int qlcnic_start_firmware(struct qlcnic_adapter *);
8484
static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter);
8585
static void qlcnic_dev_set_npar_ready(struct qlcnic_adapter *);
8686
static int qlcnicvf_start_firmware(struct qlcnic_adapter *);
87-
static void qlcnic_set_netdev_features(struct qlcnic_adapter *,
88-
struct qlcnic_esw_func_cfg *);
8987
static int qlcnic_vlan_rx_add(struct net_device *, __be16, u16);
9088
static int qlcnic_vlan_rx_del(struct net_device *, __be16, u16);
9189

92-
#define QLCNIC_IS_TSO_CAPABLE(adapter) \
93-
((adapter)->ahw->capabilities & QLCNIC_FW_CAPABILITY_TSO)
94-
9590
static u32 qlcnic_vlan_tx_check(struct qlcnic_adapter *adapter)
9691
{
9792
struct qlcnic_hardware_context *ahw = adapter->ahw;
@@ -1074,8 +1069,6 @@ void qlcnic_set_eswitch_port_features(struct qlcnic_adapter *adapter,
10741069

10751070
if (!esw_cfg->promisc_mode)
10761071
adapter->flags |= QLCNIC_PROMISC_DISABLED;
1077-
1078-
qlcnic_set_netdev_features(adapter, esw_cfg);
10791072
}
10801073

10811074
int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *adapter)
@@ -1090,51 +1083,23 @@ int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *adapter)
10901083
return -EIO;
10911084
qlcnic_set_vlan_config(adapter, &esw_cfg);
10921085
qlcnic_set_eswitch_port_features(adapter, &esw_cfg);
1086+
qlcnic_set_netdev_features(adapter, &esw_cfg);
10931087

10941088
return 0;
10951089
}
10961090

1097-
static void
1098-
qlcnic_set_netdev_features(struct qlcnic_adapter *adapter,
1099-
struct qlcnic_esw_func_cfg *esw_cfg)
1091+
void qlcnic_set_netdev_features(struct qlcnic_adapter *adapter,
1092+
struct qlcnic_esw_func_cfg *esw_cfg)
11001093
{
11011094
struct net_device *netdev = adapter->netdev;
1102-
unsigned long features, vlan_features;
11031095

11041096
if (qlcnic_83xx_check(adapter))
11051097
return;
11061098

1107-
features = (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
1108-
NETIF_F_IPV6_CSUM | NETIF_F_GRO);
1109-
vlan_features = (NETIF_F_SG | NETIF_F_IP_CSUM |
1110-
NETIF_F_IPV6_CSUM);
1111-
1112-
if (QLCNIC_IS_TSO_CAPABLE(adapter)) {
1113-
features |= (NETIF_F_TSO | NETIF_F_TSO6);
1114-
vlan_features |= (NETIF_F_TSO | NETIF_F_TSO6);
1115-
}
1116-
1117-
if (netdev->features & NETIF_F_LRO)
1118-
features |= NETIF_F_LRO;
1119-
1120-
if (esw_cfg->offload_flags & BIT_0) {
1121-
netdev->features |= features;
1122-
adapter->rx_csum = 1;
1123-
if (!(esw_cfg->offload_flags & BIT_1)) {
1124-
netdev->features &= ~NETIF_F_TSO;
1125-
features &= ~NETIF_F_TSO;
1126-
}
1127-
if (!(esw_cfg->offload_flags & BIT_2)) {
1128-
netdev->features &= ~NETIF_F_TSO6;
1129-
features &= ~NETIF_F_TSO6;
1130-
}
1131-
} else {
1132-
netdev->features &= ~features;
1133-
features &= ~features;
1134-
adapter->rx_csum = 0;
1135-
}
1136-
1137-
netdev->vlan_features = (features & vlan_features);
1099+
adapter->offload_flags = esw_cfg->offload_flags;
1100+
adapter->flags |= QLCNIC_APP_CHANGED_FLAGS;
1101+
netdev_update_features(netdev);
1102+
adapter->flags &= ~QLCNIC_APP_CHANGED_FLAGS;
11381103
}
11391104

11401105
static int

drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ static ssize_t qlcnic_sysfs_write_esw_config(struct file *file,
544544
switch (esw_cfg[i].op_mode) {
545545
case QLCNIC_PORT_DEFAULTS:
546546
qlcnic_set_eswitch_port_features(adapter, &esw_cfg[i]);
547+
rtnl_lock();
548+
qlcnic_set_netdev_features(adapter, &esw_cfg[i]);
549+
rtnl_unlock();
547550
break;
548551
case QLCNIC_ADD_VLAN:
549552
qlcnic_set_vlan_config(adapter, &esw_cfg[i]);

0 commit comments

Comments
 (0)