aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/bonding/bond_3ad.c11
-rw-r--r--drivers/net/bonding/bond_alb.c7
-rw-r--r--drivers/net/bonding/bond_main.c1
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h12
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c21
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/mbx.c4
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c129
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c99
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c41
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c52
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c41
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c63
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/vport.c3
-rw-r--r--drivers/net/ethernet/microchip/enc28j60.c7
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c2
-rw-r--r--drivers/net/geneve.c9
-rw-r--r--drivers/net/macsec.c1
-rw-r--r--drivers/net/phy/dp83867.c13
-rw-r--r--drivers/net/usb/cdc_ncm.c7
-rw-r--r--drivers/net/usb/r8152.c35
-rw-r--r--drivers/net/usb/usbnet.c10
-rw-r--r--drivers/s390/net/qeth_l2_main.c1
-rw-r--r--drivers/s390/net/qeth_l3_main.c1
-rw-r--r--include/linux/mlx5/driver.h1
-rw-r--r--include/linux/skbuff.h20
-rw-r--r--include/net/bonding.h7
-rw-r--r--include/net/ip.h5
-rw-r--r--net/bridge/br_netfilter_hooks.c2
-rw-r--r--net/core/flow_dissector.c43
-rw-r--r--net/core/skbuff.c18
-rw-r--r--net/decnet/dn_fib.c21
-rw-r--r--net/ipv4/ip_output.c4
-rw-r--r--net/ipv6/ip6_fib.c1
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/rds/tcp.c5
-rw-r--r--net/sched/act_mirred.c2
-rw-r--r--net/tipc/netlink_compat.c2
43 files changed, 527 insertions, 212 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index ca81f46ea1aa..edc70ffad660 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -101,11 +101,14 @@ enum ad_link_speed_type {
101#define MAC_ADDRESS_EQUAL(A, B) \ 101#define MAC_ADDRESS_EQUAL(A, B) \
102 ether_addr_equal_64bits((const u8 *)A, (const u8 *)B) 102 ether_addr_equal_64bits((const u8 *)A, (const u8 *)B)
103 103
104static struct mac_addr null_mac_addr = { { 0, 0, 0, 0, 0, 0 } }; 104static const u8 null_mac_addr[ETH_ALEN + 2] __long_aligned = {
105 0, 0, 0, 0, 0, 0
106};
105static u16 ad_ticks_per_sec; 107static u16 ad_ticks_per_sec;
106static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000; 108static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000;
107 109
108static const u8 lacpdu_mcast_addr[ETH_ALEN] = MULTICAST_LACPDU_ADDR; 110static const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned =
111 MULTICAST_LACPDU_ADDR;
109 112
110/* ================= main 802.3ad protocol functions ================== */ 113/* ================= main 802.3ad protocol functions ================== */
111static int ad_lacpdu_send(struct port *port); 114static int ad_lacpdu_send(struct port *port);
@@ -1739,7 +1742,7 @@ static void ad_clear_agg(struct aggregator *aggregator)
1739 aggregator->is_individual = false; 1742 aggregator->is_individual = false;
1740 aggregator->actor_admin_aggregator_key = 0; 1743 aggregator->actor_admin_aggregator_key = 0;
1741 aggregator->actor_oper_aggregator_key = 0; 1744 aggregator->actor_oper_aggregator_key = 0;
1742 aggregator->partner_system = null_mac_addr; 1745 eth_zero_addr(aggregator->partner_system.mac_addr_value);
1743 aggregator->partner_system_priority = 0; 1746 aggregator->partner_system_priority = 0;
1744 aggregator->partner_oper_aggregator_key = 0; 1747 aggregator->partner_oper_aggregator_key = 0;
1745 aggregator->receive_state = 0; 1748 aggregator->receive_state = 0;
@@ -1761,7 +1764,7 @@ static void ad_initialize_agg(struct aggregator *aggregator)
1761 if (aggregator) { 1764 if (aggregator) {
1762 ad_clear_agg(aggregator); 1765 ad_clear_agg(aggregator);
1763 1766
1764 aggregator->aggregator_mac_address = null_mac_addr; 1767 eth_zero_addr(aggregator->aggregator_mac_address.mac_addr_value);
1765 aggregator->aggregator_identifier = 0; 1768 aggregator->aggregator_identifier = 0;
1766 aggregator->slave = NULL; 1769 aggregator->slave = NULL;
1767 } 1770 }
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index c5ac160a8ae9..551f0f8dead3 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -42,13 +42,10 @@
42 42
43 43
44 44
45#ifndef __long_aligned 45static const u8 mac_bcast[ETH_ALEN + 2] __long_aligned = {
46#define __long_aligned __attribute__((aligned((sizeof(long)))))
47#endif
48static const u8 mac_bcast[ETH_ALEN] __long_aligned = {
49 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 46 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
50}; 47};
51static const u8 mac_v6_allmcast[ETH_ALEN] __long_aligned = { 48static const u8 mac_v6_allmcast[ETH_ALEN + 2] __long_aligned = {
52 0x33, 0x33, 0x00, 0x00, 0x00, 0x01 49 0x33, 0x33, 0x00, 0x00, 0x00, 0x01
53}; 50};
54static const int alb_delta_in_ticks = HZ / ALB_TIMER_TICKS_PER_SEC; 51static const int alb_delta_in_ticks = HZ / ALB_TIMER_TICKS_PER_SEC;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 941ec99cd3b6..a2afa3be17a4 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1584,6 +1584,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1584 } 1584 }
1585 1585
1586 /* check for initial state */ 1586 /* check for initial state */
1587 new_slave->link = BOND_LINK_NOCHANGE;
1587 if (bond->params.miimon) { 1588 if (bond->params.miimon) {
1588 if (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS) { 1589 if (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS) {
1589 if (bond->params.updelay) { 1590 if (bond->params.updelay) {
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 543bf38105c9..bfa26a2590c9 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -392,7 +392,7 @@ static void bcm_sysport_get_stats(struct net_device *dev,
392 else 392 else
393 p = (char *)priv; 393 p = (char *)priv;
394 p += s->stat_offset; 394 p += s->stat_offset;
395 data[i] = *(u32 *)p; 395 data[i] = *(unsigned long *)p;
396 } 396 }
397} 397}
398 398
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
index c4b262ca7d43..2accab386323 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
@@ -36,8 +36,8 @@
36#define __T4FW_VERSION_H__ 36#define __T4FW_VERSION_H__
37 37
38#define T4FW_VERSION_MAJOR 0x01 38#define T4FW_VERSION_MAJOR 0x01
39#define T4FW_VERSION_MINOR 0x0E 39#define T4FW_VERSION_MINOR 0x0F
40#define T4FW_VERSION_MICRO 0x04 40#define T4FW_VERSION_MICRO 0x25
41#define T4FW_VERSION_BUILD 0x00 41#define T4FW_VERSION_BUILD 0x00
42 42
43#define T4FW_MIN_VERSION_MAJOR 0x01 43#define T4FW_MIN_VERSION_MAJOR 0x01
@@ -45,8 +45,8 @@
45#define T4FW_MIN_VERSION_MICRO 0x00 45#define T4FW_MIN_VERSION_MICRO 0x00
46 46
47#define T5FW_VERSION_MAJOR 0x01 47#define T5FW_VERSION_MAJOR 0x01
48#define T5FW_VERSION_MINOR 0x0E 48#define T5FW_VERSION_MINOR 0x0F
49#define T5FW_VERSION_MICRO 0x04 49#define T5FW_VERSION_MICRO 0x25
50#define T5FW_VERSION_BUILD 0x00 50#define T5FW_VERSION_BUILD 0x00
51 51
52#define T5FW_MIN_VERSION_MAJOR 0x00 52#define T5FW_MIN_VERSION_MAJOR 0x00
@@ -54,8 +54,8 @@
54#define T5FW_MIN_VERSION_MICRO 0x00 54#define T5FW_MIN_VERSION_MICRO 0x00
55 55
56#define T6FW_VERSION_MAJOR 0x01 56#define T6FW_VERSION_MAJOR 0x01
57#define T6FW_VERSION_MINOR 0x0E 57#define T6FW_VERSION_MINOR 0x0F
58#define T6FW_VERSION_MICRO 0x04 58#define T6FW_VERSION_MICRO 0x25
59#define T6FW_VERSION_BUILD 0x00 59#define T6FW_VERSION_BUILD 0x00
60 60
61#define T6FW_MIN_VERSION_MAJOR 0x00 61#define T6FW_MIN_VERSION_MAJOR 0x00
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 73f745205a1c..2b2e2f8c6369 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -154,16 +154,6 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
154 writel(val, hw->hw_addr + reg); 154 writel(val, hw->hw_addr + reg);
155} 155}
156 156
157static bool e1000e_vlan_used(struct e1000_adapter *adapter)
158{
159 u16 vid;
160
161 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
162 return true;
163
164 return false;
165}
166
167/** 157/**
168 * e1000_regdump - register printout routine 158 * e1000_regdump - register printout routine
169 * @hw: pointer to the HW structure 159 * @hw: pointer to the HW structure
@@ -3453,8 +3443,7 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
3453 3443
3454 ew32(RCTL, rctl); 3444 ew32(RCTL, rctl);
3455 3445
3456 if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX || 3446 if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
3457 e1000e_vlan_used(adapter))
3458 e1000e_vlan_strip_enable(adapter); 3447 e1000e_vlan_strip_enable(adapter);
3459 else 3448 else
3460 e1000e_vlan_strip_disable(adapter); 3449 e1000e_vlan_strip_disable(adapter);
@@ -6926,6 +6915,14 @@ static netdev_features_t e1000_fix_features(struct net_device *netdev,
6926 if ((hw->mac.type >= e1000_pch2lan) && (netdev->mtu > ETH_DATA_LEN)) 6915 if ((hw->mac.type >= e1000_pch2lan) && (netdev->mtu > ETH_DATA_LEN))
6927 features &= ~NETIF_F_RXFCS; 6916 features &= ~NETIF_F_RXFCS;
6928 6917
6918 /* Since there is no support for separate Rx/Tx vlan accel
6919 * enable/disable make sure Tx flag is always in same state as Rx.
6920 */
6921 if (features & NETIF_F_HW_VLAN_CTAG_RX)
6922 features |= NETIF_F_HW_VLAN_CTAG_TX;
6923 else
6924 features &= ~NETIF_F_HW_VLAN_CTAG_TX;
6925
6929 return features; 6926 return features;
6930} 6927}
6931 6928
diff --git a/drivers/net/ethernet/intel/ixgbevf/mbx.c b/drivers/net/ethernet/intel/ixgbevf/mbx.c
index 61a80da8b6f0..2819abc454c7 100644
--- a/drivers/net/ethernet/intel/ixgbevf/mbx.c
+++ b/drivers/net/ethernet/intel/ixgbevf/mbx.c
@@ -85,7 +85,7 @@ static s32 ixgbevf_poll_for_ack(struct ixgbe_hw *hw)
85static s32 ixgbevf_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size) 85static s32 ixgbevf_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size)
86{ 86{
87 struct ixgbe_mbx_info *mbx = &hw->mbx; 87 struct ixgbe_mbx_info *mbx = &hw->mbx;
88 s32 ret_val = -IXGBE_ERR_MBX; 88 s32 ret_val = IXGBE_ERR_MBX;
89 89
90 if (!mbx->ops.read) 90 if (!mbx->ops.read)
91 goto out; 91 goto out;
@@ -111,7 +111,7 @@ out:
111static s32 ixgbevf_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size) 111static s32 ixgbevf_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size)
112{ 112{
113 struct ixgbe_mbx_info *mbx = &hw->mbx; 113 struct ixgbe_mbx_info *mbx = &hw->mbx;
114 s32 ret_val = -IXGBE_ERR_MBX; 114 s32 ret_val = IXGBE_ERR_MBX;
115 115
116 /* exit if either we can't write or there isn't a defined timeout */ 116 /* exit if either we can't write or there isn't a defined timeout */
117 if (!mbx->ops.write || !mbx->timeout) 117 if (!mbx->ops.write || !mbx->timeout)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index a6d26d351dfc..d5d263bda333 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3458,6 +3458,8 @@ static int mvneta_open(struct net_device *dev)
3458 return 0; 3458 return 0;
3459 3459
3460err_free_irq: 3460err_free_irq:
3461 unregister_cpu_notifier(&pp->cpu_notifier);
3462 on_each_cpu(mvneta_percpu_disable, pp, true);
3461 free_percpu_irq(pp->dev->irq, pp->ports); 3463 free_percpu_irq(pp->dev->irq, pp->ports);
3462err_cleanup_txqs: 3464err_cleanup_txqs:
3463 mvneta_cleanup_txqs(pp); 3465 mvneta_cleanup_txqs(pp);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 0b4986268cc9..d6e2a1cae19a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -295,6 +295,12 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
295 case MLX5_CMD_OP_DESTROY_FLOW_GROUP: 295 case MLX5_CMD_OP_DESTROY_FLOW_GROUP:
296 case MLX5_CMD_OP_DELETE_FLOW_TABLE_ENTRY: 296 case MLX5_CMD_OP_DELETE_FLOW_TABLE_ENTRY:
297 case MLX5_CMD_OP_DEALLOC_FLOW_COUNTER: 297 case MLX5_CMD_OP_DEALLOC_FLOW_COUNTER:
298 case MLX5_CMD_OP_2ERR_QP:
299 case MLX5_CMD_OP_2RST_QP:
300 case MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT:
301 case MLX5_CMD_OP_MODIFY_FLOW_TABLE:
302 case MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY:
303 case MLX5_CMD_OP_SET_FLOW_TABLE_ROOT:
298 return MLX5_CMD_STAT_OK; 304 return MLX5_CMD_STAT_OK;
299 305
300 case MLX5_CMD_OP_QUERY_HCA_CAP: 306 case MLX5_CMD_OP_QUERY_HCA_CAP:
@@ -321,8 +327,6 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
321 case MLX5_CMD_OP_RTR2RTS_QP: 327 case MLX5_CMD_OP_RTR2RTS_QP:
322 case MLX5_CMD_OP_RTS2RTS_QP: 328 case MLX5_CMD_OP_RTS2RTS_QP:
323 case MLX5_CMD_OP_SQERR2RTS_QP: 329 case MLX5_CMD_OP_SQERR2RTS_QP:
324 case MLX5_CMD_OP_2ERR_QP:
325 case MLX5_CMD_OP_2RST_QP:
326 case MLX5_CMD_OP_QUERY_QP: 330 case MLX5_CMD_OP_QUERY_QP:
327 case MLX5_CMD_OP_SQD_RTS_QP: 331 case MLX5_CMD_OP_SQD_RTS_QP:
328 case MLX5_CMD_OP_INIT2INIT_QP: 332 case MLX5_CMD_OP_INIT2INIT_QP:
@@ -342,7 +346,6 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
342 case MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT: 346 case MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT:
343 case MLX5_CMD_OP_MODIFY_ESW_VPORT_CONTEXT: 347 case MLX5_CMD_OP_MODIFY_ESW_VPORT_CONTEXT:
344 case MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT: 348 case MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT:
345 case MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT:
346 case MLX5_CMD_OP_QUERY_ROCE_ADDRESS: 349 case MLX5_CMD_OP_QUERY_ROCE_ADDRESS:
347 case MLX5_CMD_OP_SET_ROCE_ADDRESS: 350 case MLX5_CMD_OP_SET_ROCE_ADDRESS:
348 case MLX5_CMD_OP_QUERY_HCA_VPORT_CONTEXT: 351 case MLX5_CMD_OP_QUERY_HCA_VPORT_CONTEXT:
@@ -390,11 +393,12 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
390 case MLX5_CMD_OP_CREATE_RQT: 393 case MLX5_CMD_OP_CREATE_RQT:
391 case MLX5_CMD_OP_MODIFY_RQT: 394 case MLX5_CMD_OP_MODIFY_RQT:
392 case MLX5_CMD_OP_QUERY_RQT: 395 case MLX5_CMD_OP_QUERY_RQT:
396
393 case MLX5_CMD_OP_CREATE_FLOW_TABLE: 397 case MLX5_CMD_OP_CREATE_FLOW_TABLE:
394 case MLX5_CMD_OP_QUERY_FLOW_TABLE: 398 case MLX5_CMD_OP_QUERY_FLOW_TABLE:
395 case MLX5_CMD_OP_CREATE_FLOW_GROUP: 399 case MLX5_CMD_OP_CREATE_FLOW_GROUP:
396 case MLX5_CMD_OP_QUERY_FLOW_GROUP: 400 case MLX5_CMD_OP_QUERY_FLOW_GROUP:
397 case MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY: 401
398 case MLX5_CMD_OP_QUERY_FLOW_TABLE_ENTRY: 402 case MLX5_CMD_OP_QUERY_FLOW_TABLE_ENTRY:
399 case MLX5_CMD_OP_ALLOC_FLOW_COUNTER: 403 case MLX5_CMD_OP_ALLOC_FLOW_COUNTER:
400 case MLX5_CMD_OP_QUERY_FLOW_COUNTER: 404 case MLX5_CMD_OP_QUERY_FLOW_COUNTER:
@@ -602,11 +606,36 @@ static void dump_command(struct mlx5_core_dev *dev,
602 pr_debug("\n"); 606 pr_debug("\n");
603} 607}
604 608
609static u16 msg_to_opcode(struct mlx5_cmd_msg *in)
610{
611 struct mlx5_inbox_hdr *hdr = (struct mlx5_inbox_hdr *)(in->first.data);
612
613 return be16_to_cpu(hdr->opcode);
614}
615
616static void cb_timeout_handler(struct work_struct *work)
617{
618 struct delayed_work *dwork = container_of(work, struct delayed_work,
619 work);
620 struct mlx5_cmd_work_ent *ent = container_of(dwork,
621 struct mlx5_cmd_work_ent,
622 cb_timeout_work);
623 struct mlx5_core_dev *dev = container_of(ent->cmd, struct mlx5_core_dev,
624 cmd);
625
626 ent->ret = -ETIMEDOUT;
627 mlx5_core_warn(dev, "%s(0x%x) timeout. Will cause a leak of a command resource\n",
628 mlx5_command_str(msg_to_opcode(ent->in)),
629 msg_to_opcode(ent->in));
630 mlx5_cmd_comp_handler(dev, 1UL << ent->idx);
631}
632
605static void cmd_work_handler(struct work_struct *work) 633static void cmd_work_handler(struct work_struct *work)
606{ 634{
607 struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work); 635 struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work);
608 struct mlx5_cmd *cmd = ent->cmd; 636 struct mlx5_cmd *cmd = ent->cmd;
609 struct mlx5_core_dev *dev = container_of(cmd, struct mlx5_core_dev, cmd); 637 struct mlx5_core_dev *dev = container_of(cmd, struct mlx5_core_dev, cmd);
638 unsigned long cb_timeout = msecs_to_jiffies(MLX5_CMD_TIMEOUT_MSEC);
610 struct mlx5_cmd_layout *lay; 639 struct mlx5_cmd_layout *lay;
611 struct semaphore *sem; 640 struct semaphore *sem;
612 unsigned long flags; 641 unsigned long flags;
@@ -647,6 +676,9 @@ static void cmd_work_handler(struct work_struct *work)
647 dump_command(dev, ent, 1); 676 dump_command(dev, ent, 1);
648 ent->ts1 = ktime_get_ns(); 677 ent->ts1 = ktime_get_ns();
649 678
679 if (ent->callback)
680 schedule_delayed_work(&ent->cb_timeout_work, cb_timeout);
681
650 /* ring doorbell after the descriptor is valid */ 682 /* ring doorbell after the descriptor is valid */
651 mlx5_core_dbg(dev, "writing 0x%x to command doorbell\n", 1 << ent->idx); 683 mlx5_core_dbg(dev, "writing 0x%x to command doorbell\n", 1 << ent->idx);
652 wmb(); 684 wmb();
@@ -691,13 +723,6 @@ static const char *deliv_status_to_str(u8 status)
691 } 723 }
692} 724}
693 725
694static u16 msg_to_opcode(struct mlx5_cmd_msg *in)
695{
696 struct mlx5_inbox_hdr *hdr = (struct mlx5_inbox_hdr *)(in->first.data);
697
698 return be16_to_cpu(hdr->opcode);
699}
700
701static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent) 726static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent)
702{ 727{
703 unsigned long timeout = msecs_to_jiffies(MLX5_CMD_TIMEOUT_MSEC); 728 unsigned long timeout = msecs_to_jiffies(MLX5_CMD_TIMEOUT_MSEC);
@@ -706,13 +731,13 @@ static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent)
706 731
707 if (cmd->mode == CMD_MODE_POLLING) { 732 if (cmd->mode == CMD_MODE_POLLING) {
708 wait_for_completion(&ent->done); 733 wait_for_completion(&ent->done);
709 err = ent->ret; 734 } else if (!wait_for_completion_timeout(&ent->done, timeout)) {
710 } else { 735 ent->ret = -ETIMEDOUT;
711 if (!wait_for_completion_timeout(&ent->done, timeout)) 736 mlx5_cmd_comp_handler(dev, 1UL << ent->idx);
712 err = -ETIMEDOUT;
713 else
714 err = 0;
715 } 737 }
738
739 err = ent->ret;
740
716 if (err == -ETIMEDOUT) { 741 if (err == -ETIMEDOUT) {
717 mlx5_core_warn(dev, "%s(0x%x) timeout. Will cause a leak of a command resource\n", 742 mlx5_core_warn(dev, "%s(0x%x) timeout. Will cause a leak of a command resource\n",
718 mlx5_command_str(msg_to_opcode(ent->in)), 743 mlx5_command_str(msg_to_opcode(ent->in)),
@@ -761,6 +786,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
761 if (!callback) 786 if (!callback)
762 init_completion(&ent->done); 787 init_completion(&ent->done);
763 788
789 INIT_DELAYED_WORK(&ent->cb_timeout_work, cb_timeout_handler);
764 INIT_WORK(&ent->work, cmd_work_handler); 790 INIT_WORK(&ent->work, cmd_work_handler);
765 if (page_queue) { 791 if (page_queue) {
766 cmd_work_handler(&ent->work); 792 cmd_work_handler(&ent->work);
@@ -770,28 +796,26 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
770 goto out_free; 796 goto out_free;
771 } 797 }
772 798
773 if (!callback) { 799 if (callback)
774 err = wait_func(dev, ent); 800 goto out;
775 if (err == -ETIMEDOUT)
776 goto out;
777
778 ds = ent->ts2 - ent->ts1;
779 op = be16_to_cpu(((struct mlx5_inbox_hdr *)in->first.data)->opcode);
780 if (op < ARRAY_SIZE(cmd->stats)) {
781 stats = &cmd->stats[op];
782 spin_lock_irq(&stats->lock);
783 stats->sum += ds;
784 ++stats->n;
785 spin_unlock_irq(&stats->lock);
786 }
787 mlx5_core_dbg_mask(dev, 1 << MLX5_CMD_TIME,
788 "fw exec time for %s is %lld nsec\n",
789 mlx5_command_str(op), ds);
790 *status = ent->status;
791 free_cmd(ent);
792 }
793 801
794 return err; 802 err = wait_func(dev, ent);
803 if (err == -ETIMEDOUT)
804 goto out_free;
805
806 ds = ent->ts2 - ent->ts1;
807 op = be16_to_cpu(((struct mlx5_inbox_hdr *)in->first.data)->opcode);
808 if (op < ARRAY_SIZE(cmd->stats)) {
809 stats = &cmd->stats[op];
810 spin_lock_irq(&stats->lock);
811 stats->sum += ds;
812 ++stats->n;
813 spin_unlock_irq(&stats->lock);
814 }
815 mlx5_core_dbg_mask(dev, 1 << MLX5_CMD_TIME,
816 "fw exec time for %s is %lld nsec\n",
817 mlx5_command_str(op), ds);
818 *status = ent->status;
795 819
796out_free: 820out_free:
797 free_cmd(ent); 821 free_cmd(ent);
@@ -1181,41 +1205,30 @@ err_dbg:
1181 return err; 1205 return err;
1182} 1206}
1183 1207
1184void mlx5_cmd_use_events(struct mlx5_core_dev *dev) 1208static void mlx5_cmd_change_mod(struct mlx5_core_dev *dev, int mode)
1185{ 1209{
1186 struct mlx5_cmd *cmd = &dev->cmd; 1210 struct mlx5_cmd *cmd = &dev->cmd;
1187 int i; 1211 int i;
1188 1212
1189 for (i = 0; i < cmd->max_reg_cmds; i++) 1213 for (i = 0; i < cmd->max_reg_cmds; i++)
1190 down(&cmd->sem); 1214 down(&cmd->sem);
1191
1192 down(&cmd->pages_sem); 1215 down(&cmd->pages_sem);
1193 1216
1194 flush_workqueue(cmd->wq); 1217 cmd->mode = mode;
1195
1196 cmd->mode = CMD_MODE_EVENTS;
1197 1218
1198 up(&cmd->pages_sem); 1219 up(&cmd->pages_sem);
1199 for (i = 0; i < cmd->max_reg_cmds; i++) 1220 for (i = 0; i < cmd->max_reg_cmds; i++)
1200 up(&cmd->sem); 1221 up(&cmd->sem);
1201} 1222}
1202 1223
1203void mlx5_cmd_use_polling(struct mlx5_core_dev *dev) 1224void mlx5_cmd_use_events(struct mlx5_core_dev *dev)
1204{ 1225{
1205 struct mlx5_cmd *cmd = &dev->cmd; 1226 mlx5_cmd_change_mod(dev, CMD_MODE_EVENTS);
1206 int i; 1227}
1207
1208 for (i = 0; i < cmd->max_reg_cmds; i++)
1209 down(&cmd->sem);
1210
1211 down(&cmd->pages_sem);
1212
1213 flush_workqueue(cmd->wq);
1214 cmd->mode = CMD_MODE_POLLING;
1215 1228
1216 up(&cmd->pages_sem); 1229void mlx5_cmd_use_polling(struct mlx5_core_dev *dev)
1217 for (i = 0; i < cmd->max_reg_cmds; i++) 1230{
1218 up(&cmd->sem); 1231 mlx5_cmd_change_mod(dev, CMD_MODE_POLLING);
1219} 1232}
1220 1233
1221static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg) 1234static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg)
@@ -1251,6 +1264,8 @@ void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec)
1251 struct semaphore *sem; 1264 struct semaphore *sem;
1252 1265
1253 ent = cmd->ent_arr[i]; 1266 ent = cmd->ent_arr[i];
1267 if (ent->callback)
1268 cancel_delayed_work(&ent->cb_timeout_work);
1254 if (ent->page_queue) 1269 if (ent->page_queue)
1255 sem = &cmd->pages_sem; 1270 sem = &cmd->pages_sem;
1256 else 1271 else
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index baa991a23475..943b1bd434bf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -145,7 +145,6 @@ struct mlx5e_umr_wqe {
145 145
146#ifdef CONFIG_MLX5_CORE_EN_DCB 146#ifdef CONFIG_MLX5_CORE_EN_DCB
147#define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */ 147#define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */
148#define MLX5E_MIN_BW_ALLOC 1 /* Min percentage of BW allocation */
149#endif 148#endif
150 149
151struct mlx5e_params { 150struct mlx5e_params {
@@ -191,6 +190,7 @@ struct mlx5e_tstamp {
191enum { 190enum {
192 MLX5E_RQ_STATE_POST_WQES_ENABLE, 191 MLX5E_RQ_STATE_POST_WQES_ENABLE,
193 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, 192 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS,
193 MLX5E_RQ_STATE_FLUSH_TIMEOUT,
194}; 194};
195 195
196struct mlx5e_cq { 196struct mlx5e_cq {
@@ -220,6 +220,8 @@ typedef void (*mlx5e_fp_handle_rx_cqe)(struct mlx5e_rq *rq,
220typedef int (*mlx5e_fp_alloc_wqe)(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, 220typedef int (*mlx5e_fp_alloc_wqe)(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe,
221 u16 ix); 221 u16 ix);
222 222
223typedef void (*mlx5e_fp_dealloc_wqe)(struct mlx5e_rq *rq, u16 ix);
224
223struct mlx5e_dma_info { 225struct mlx5e_dma_info {
224 struct page *page; 226 struct page *page;
225 dma_addr_t addr; 227 dma_addr_t addr;
@@ -241,6 +243,7 @@ struct mlx5e_rq {
241 struct mlx5e_cq cq; 243 struct mlx5e_cq cq;
242 mlx5e_fp_handle_rx_cqe handle_rx_cqe; 244 mlx5e_fp_handle_rx_cqe handle_rx_cqe;
243 mlx5e_fp_alloc_wqe alloc_wqe; 245 mlx5e_fp_alloc_wqe alloc_wqe;
246 mlx5e_fp_dealloc_wqe dealloc_wqe;
244 247
245 unsigned long state; 248 unsigned long state;
246 int ix; 249 int ix;
@@ -305,6 +308,7 @@ struct mlx5e_sq_dma {
305enum { 308enum {
306 MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, 309 MLX5E_SQ_STATE_WAKE_TXQ_ENABLE,
307 MLX5E_SQ_STATE_BF_ENABLE, 310 MLX5E_SQ_STATE_BF_ENABLE,
311 MLX5E_SQ_STATE_TX_TIMEOUT,
308}; 312};
309 313
310struct mlx5e_ico_wqe_info { 314struct mlx5e_ico_wqe_info {
@@ -538,6 +542,7 @@ struct mlx5e_priv {
538 struct workqueue_struct *wq; 542 struct workqueue_struct *wq;
539 struct work_struct update_carrier_work; 543 struct work_struct update_carrier_work;
540 struct work_struct set_rx_mode_work; 544 struct work_struct set_rx_mode_work;
545 struct work_struct tx_timeout_work;
541 struct delayed_work update_stats_work; 546 struct delayed_work update_stats_work;
542 547
543 struct mlx5_core_dev *mdev; 548 struct mlx5_core_dev *mdev;
@@ -589,12 +594,16 @@ void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);
589int mlx5e_napi_poll(struct napi_struct *napi, int budget); 594int mlx5e_napi_poll(struct napi_struct *napi, int budget);
590bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget); 595bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget);
591int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); 596int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
597void mlx5e_free_tx_descs(struct mlx5e_sq *sq);
598void mlx5e_free_rx_descs(struct mlx5e_rq *rq);
592 599
593void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); 600void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
594void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); 601void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
595bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq); 602bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq);
596int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix); 603int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix);
597int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix); 604int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix);
605void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix);
606void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix);
598void mlx5e_post_rx_fragmented_mpwqe(struct mlx5e_rq *rq); 607void mlx5e_post_rx_fragmented_mpwqe(struct mlx5e_rq *rq);
599void mlx5e_complete_rx_linear_mpwqe(struct mlx5e_rq *rq, 608void mlx5e_complete_rx_linear_mpwqe(struct mlx5e_rq *rq,
600 struct mlx5_cqe64 *cqe, 609 struct mlx5_cqe64 *cqe,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index b2db180ae2a5..c585349e05c3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -96,7 +96,7 @@ static void mlx5e_build_tc_tx_bw(struct ieee_ets *ets, u8 *tc_tx_bw,
96 tc_tx_bw[i] = MLX5E_MAX_BW_ALLOC; 96 tc_tx_bw[i] = MLX5E_MAX_BW_ALLOC;
97 break; 97 break;
98 case IEEE_8021QAZ_TSA_ETS: 98 case IEEE_8021QAZ_TSA_ETS:
99 tc_tx_bw[i] = ets->tc_tx_bw[i] ?: MLX5E_MIN_BW_ALLOC; 99 tc_tx_bw[i] = ets->tc_tx_bw[i];
100 break; 100 break;
101 } 101 }
102 } 102 }
@@ -140,8 +140,12 @@ static int mlx5e_dbcnl_validate_ets(struct ieee_ets *ets)
140 140
141 /* Validate Bandwidth Sum */ 141 /* Validate Bandwidth Sum */
142 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 142 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
143 if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) 143 if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) {
144 if (!ets->tc_tx_bw[i])
145 return -EINVAL;
146
144 bw_sum += ets->tc_tx_bw[i]; 147 bw_sum += ets->tc_tx_bw[i];
148 }
145 } 149 }
146 150
147 if (bw_sum != 0 && bw_sum != 100) 151 if (bw_sum != 0 && bw_sum != 100)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index cb6defd71fc1..7a0dca29c642 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -39,6 +39,13 @@
39#include "eswitch.h" 39#include "eswitch.h"
40#include "vxlan.h" 40#include "vxlan.h"
41 41
42enum {
43 MLX5_EN_QP_FLUSH_TIMEOUT_MS = 5000,
44 MLX5_EN_QP_FLUSH_MSLEEP_QUANT = 20,
45 MLX5_EN_QP_FLUSH_MAX_ITER = MLX5_EN_QP_FLUSH_TIMEOUT_MS /
46 MLX5_EN_QP_FLUSH_MSLEEP_QUANT,
47};
48
42struct mlx5e_rq_param { 49struct mlx5e_rq_param {
43 u32 rqc[MLX5_ST_SZ_DW(rqc)]; 50 u32 rqc[MLX5_ST_SZ_DW(rqc)];
44 struct mlx5_wq_param wq; 51 struct mlx5_wq_param wq;
@@ -74,10 +81,13 @@ static void mlx5e_update_carrier(struct mlx5e_priv *priv)
74 port_state = mlx5_query_vport_state(mdev, 81 port_state = mlx5_query_vport_state(mdev,
75 MLX5_QUERY_VPORT_STATE_IN_OP_MOD_VNIC_VPORT, 0); 82 MLX5_QUERY_VPORT_STATE_IN_OP_MOD_VNIC_VPORT, 0);
76 83
77 if (port_state == VPORT_STATE_UP) 84 if (port_state == VPORT_STATE_UP) {
85 netdev_info(priv->netdev, "Link up\n");
78 netif_carrier_on(priv->netdev); 86 netif_carrier_on(priv->netdev);
79 else 87 } else {
88 netdev_info(priv->netdev, "Link down\n");
80 netif_carrier_off(priv->netdev); 89 netif_carrier_off(priv->netdev);
90 }
81} 91}
82 92
83static void mlx5e_update_carrier_work(struct work_struct *work) 93static void mlx5e_update_carrier_work(struct work_struct *work)
@@ -91,6 +101,26 @@ static void mlx5e_update_carrier_work(struct work_struct *work)
91 mutex_unlock(&priv->state_lock); 101 mutex_unlock(&priv->state_lock);
92} 102}
93 103
104static void mlx5e_tx_timeout_work(struct work_struct *work)
105{
106 struct mlx5e_priv *priv = container_of(work, struct mlx5e_priv,
107 tx_timeout_work);
108 int err;
109
110 rtnl_lock();
111 mutex_lock(&priv->state_lock);
112 if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
113 goto unlock;
114 mlx5e_close_locked(priv->netdev);
115 err = mlx5e_open_locked(priv->netdev);
116 if (err)
117 netdev_err(priv->netdev, "mlx5e_open_locked failed recovering from a tx_timeout, err(%d).\n",
118 err);
119unlock:
120 mutex_unlock(&priv->state_lock);
121 rtnl_unlock();
122}
123
94static void mlx5e_update_sw_counters(struct mlx5e_priv *priv) 124static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
95{ 125{
96 struct mlx5e_sw_stats *s = &priv->stats.sw; 126 struct mlx5e_sw_stats *s = &priv->stats.sw;
@@ -305,6 +335,7 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
305 } 335 }
306 rq->handle_rx_cqe = mlx5e_handle_rx_cqe_mpwrq; 336 rq->handle_rx_cqe = mlx5e_handle_rx_cqe_mpwrq;
307 rq->alloc_wqe = mlx5e_alloc_rx_mpwqe; 337 rq->alloc_wqe = mlx5e_alloc_rx_mpwqe;
338 rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe;
308 339
309 rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz); 340 rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz);
310 rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides); 341 rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides);
@@ -320,6 +351,7 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
320 } 351 }
321 rq->handle_rx_cqe = mlx5e_handle_rx_cqe; 352 rq->handle_rx_cqe = mlx5e_handle_rx_cqe;
322 rq->alloc_wqe = mlx5e_alloc_rx_wqe; 353 rq->alloc_wqe = mlx5e_alloc_rx_wqe;
354 rq->dealloc_wqe = mlx5e_dealloc_rx_wqe;
323 355
324 rq->wqe_sz = (priv->params.lro_en) ? 356 rq->wqe_sz = (priv->params.lro_en) ?
325 priv->params.lro_wqe_sz : 357 priv->params.lro_wqe_sz :
@@ -525,17 +557,25 @@ err_destroy_rq:
525 557
526static void mlx5e_close_rq(struct mlx5e_rq *rq) 558static void mlx5e_close_rq(struct mlx5e_rq *rq)
527{ 559{
560 int tout = 0;
561 int err;
562
528 clear_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state); 563 clear_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state);
529 napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */ 564 napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */
530 565
531 mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RDY, MLX5_RQC_STATE_ERR); 566 err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RDY, MLX5_RQC_STATE_ERR);
532 while (!mlx5_wq_ll_is_empty(&rq->wq)) 567 while (!mlx5_wq_ll_is_empty(&rq->wq) && !err &&
533 msleep(20); 568 tout++ < MLX5_EN_QP_FLUSH_MAX_ITER)
569 msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT);
570
571 if (err || tout == MLX5_EN_QP_FLUSH_MAX_ITER)
572 set_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state);
534 573
535 /* avoid destroying rq before mlx5e_poll_rx_cq() is done with it */ 574 /* avoid destroying rq before mlx5e_poll_rx_cq() is done with it */
536 napi_synchronize(&rq->channel->napi); 575 napi_synchronize(&rq->channel->napi);
537 576
538 mlx5e_disable_rq(rq); 577 mlx5e_disable_rq(rq);
578 mlx5e_free_rx_descs(rq);
539 mlx5e_destroy_rq(rq); 579 mlx5e_destroy_rq(rq);
540} 580}
541 581
@@ -782,6 +822,9 @@ static inline void netif_tx_disable_queue(struct netdev_queue *txq)
782 822
783static void mlx5e_close_sq(struct mlx5e_sq *sq) 823static void mlx5e_close_sq(struct mlx5e_sq *sq)
784{ 824{
825 int tout = 0;
826 int err;
827
785 if (sq->txq) { 828 if (sq->txq) {
786 clear_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state); 829 clear_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state);
787 /* prevent netif_tx_wake_queue */ 830 /* prevent netif_tx_wake_queue */
@@ -792,15 +835,24 @@ static void mlx5e_close_sq(struct mlx5e_sq *sq)
792 if (mlx5e_sq_has_room_for(sq, 1)) 835 if (mlx5e_sq_has_room_for(sq, 1))
793 mlx5e_send_nop(sq, true); 836 mlx5e_send_nop(sq, true);
794 837
795 mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY, MLX5_SQC_STATE_ERR); 838 err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY,
839 MLX5_SQC_STATE_ERR);
840 if (err)
841 set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state);
796 } 842 }
797 843
798 while (sq->cc != sq->pc) /* wait till sq is empty */ 844 /* wait till sq is empty, unless a TX timeout occurred on this SQ */
799 msleep(20); 845 while (sq->cc != sq->pc &&
846 !test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state)) {
847 msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT);
848 if (tout++ > MLX5_EN_QP_FLUSH_MAX_ITER)
849 set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state);
850 }
800 851
801 /* avoid destroying sq before mlx5e_poll_tx_cq() is done with it */ 852 /* avoid destroying sq before mlx5e_poll_tx_cq() is done with it */
802 napi_synchronize(&sq->channel->napi); 853 napi_synchronize(&sq->channel->napi);
803 854
855 mlx5e_free_tx_descs(sq);
804 mlx5e_disable_sq(sq); 856 mlx5e_disable_sq(sq);
805 mlx5e_destroy_sq(sq); 857 mlx5e_destroy_sq(sq);
806} 858}
@@ -1658,8 +1710,11 @@ static void mlx5e_netdev_set_tcs(struct net_device *netdev)
1658 1710
1659 netdev_set_num_tc(netdev, ntc); 1711 netdev_set_num_tc(netdev, ntc);
1660 1712
1713 /* Map netdev TCs to offset 0
1714 * We have our own UP to TXQ mapping for QoS
1715 */
1661 for (tc = 0; tc < ntc; tc++) 1716 for (tc = 0; tc < ntc; tc++)
1662 netdev_set_tc_queue(netdev, tc, nch, tc * nch); 1717 netdev_set_tc_queue(netdev, tc, nch, 0);
1663} 1718}
1664 1719
1665int mlx5e_open_locked(struct net_device *netdev) 1720int mlx5e_open_locked(struct net_device *netdev)
@@ -2590,6 +2645,29 @@ static netdev_features_t mlx5e_features_check(struct sk_buff *skb,
2590 return features; 2645 return features;
2591} 2646}
2592 2647
2648static void mlx5e_tx_timeout(struct net_device *dev)
2649{
2650 struct mlx5e_priv *priv = netdev_priv(dev);
2651 bool sched_work = false;
2652 int i;
2653
2654 netdev_err(dev, "TX timeout detected\n");
2655
2656 for (i = 0; i < priv->params.num_channels * priv->params.num_tc; i++) {
2657 struct mlx5e_sq *sq = priv->txq_to_sq_map[i];
2658
2659 if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, i)))
2660 continue;
2661 sched_work = true;
2662 set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state);
2663 netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n",
2664 i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc);
2665 }
2666
2667 if (sched_work && test_bit(MLX5E_STATE_OPENED, &priv->state))
2668 schedule_work(&priv->tx_timeout_work);
2669}
2670
2593static const struct net_device_ops mlx5e_netdev_ops_basic = { 2671static const struct net_device_ops mlx5e_netdev_ops_basic = {
2594 .ndo_open = mlx5e_open, 2672 .ndo_open = mlx5e_open,
2595 .ndo_stop = mlx5e_close, 2673 .ndo_stop = mlx5e_close,
@@ -2607,6 +2685,7 @@ static const struct net_device_ops mlx5e_netdev_ops_basic = {
2607#ifdef CONFIG_RFS_ACCEL 2685#ifdef CONFIG_RFS_ACCEL
2608 .ndo_rx_flow_steer = mlx5e_rx_flow_steer, 2686 .ndo_rx_flow_steer = mlx5e_rx_flow_steer,
2609#endif 2687#endif
2688 .ndo_tx_timeout = mlx5e_tx_timeout,
2610}; 2689};
2611 2690
2612static const struct net_device_ops mlx5e_netdev_ops_sriov = { 2691static const struct net_device_ops mlx5e_netdev_ops_sriov = {
@@ -2636,6 +2715,7 @@ static const struct net_device_ops mlx5e_netdev_ops_sriov = {
2636 .ndo_get_vf_config = mlx5e_get_vf_config, 2715 .ndo_get_vf_config = mlx5e_get_vf_config,
2637 .ndo_set_vf_link_state = mlx5e_set_vf_link_state, 2716 .ndo_set_vf_link_state = mlx5e_set_vf_link_state,
2638 .ndo_get_vf_stats = mlx5e_get_vf_stats, 2717 .ndo_get_vf_stats = mlx5e_get_vf_stats,
2718 .ndo_tx_timeout = mlx5e_tx_timeout,
2639}; 2719};
2640 2720
2641static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev) 2721static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev)
@@ -2838,6 +2918,7 @@ static void mlx5e_build_netdev_priv(struct mlx5_core_dev *mdev,
2838 2918
2839 INIT_WORK(&priv->update_carrier_work, mlx5e_update_carrier_work); 2919 INIT_WORK(&priv->update_carrier_work, mlx5e_update_carrier_work);
2840 INIT_WORK(&priv->set_rx_mode_work, mlx5e_set_rx_mode_work); 2920 INIT_WORK(&priv->set_rx_mode_work, mlx5e_set_rx_mode_work);
2921 INIT_WORK(&priv->tx_timeout_work, mlx5e_tx_timeout_work);
2841 INIT_DELAYED_WORK(&priv->update_stats_work, mlx5e_update_stats_work); 2922 INIT_DELAYED_WORK(&priv->update_stats_work, mlx5e_update_stats_work);
2842} 2923}
2843 2924
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 022acc2e8922..9f2a16a507e0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -212,6 +212,20 @@ err_free_skb:
212 return -ENOMEM; 212 return -ENOMEM;
213} 213}
214 214
215void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix)
216{
217 struct sk_buff *skb = rq->skb[ix];
218
219 if (skb) {
220 rq->skb[ix] = NULL;
221 dma_unmap_single(rq->pdev,
222 *((dma_addr_t *)skb->cb),
223 rq->wqe_sz,
224 DMA_FROM_DEVICE);
225 dev_kfree_skb(skb);
226 }
227}
228
215static inline int mlx5e_mpwqe_strides_per_page(struct mlx5e_rq *rq) 229static inline int mlx5e_mpwqe_strides_per_page(struct mlx5e_rq *rq)
216{ 230{
217 return rq->mpwqe_num_strides >> MLX5_MPWRQ_WQE_PAGE_ORDER; 231 return rq->mpwqe_num_strides >> MLX5_MPWRQ_WQE_PAGE_ORDER;
@@ -574,6 +588,30 @@ int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix)
574 return 0; 588 return 0;
575} 589}
576 590
591void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
592{
593 struct mlx5e_mpw_info *wi = &rq->wqe_info[ix];
594
595 wi->free_wqe(rq, wi);
596}
597
598void mlx5e_free_rx_descs(struct mlx5e_rq *rq)
599{
600 struct mlx5_wq_ll *wq = &rq->wq;
601 struct mlx5e_rx_wqe *wqe;
602 __be16 wqe_ix_be;
603 u16 wqe_ix;
604
605 while (!mlx5_wq_ll_is_empty(wq)) {
606 wqe_ix_be = *wq->tail_next;
607 wqe_ix = be16_to_cpu(wqe_ix_be);
608 wqe = mlx5_wq_ll_get_wqe(&rq->wq, wqe_ix);
609 rq->dealloc_wqe(rq, wqe_ix);
610 mlx5_wq_ll_pop(&rq->wq, wqe_ix_be,
611 &wqe->next.next_wqe_index);
612 }
613}
614
577#define RQ_CANNOT_POST(rq) \ 615#define RQ_CANNOT_POST(rq) \
578 (!test_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state) || \ 616 (!test_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state) || \
579 test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) 617 test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state))
@@ -878,6 +916,9 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
878 struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq); 916 struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq);
879 int work_done = 0; 917 int work_done = 0;
880 918
919 if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state)))
920 return 0;
921
881 if (cq->decmprs_left) 922 if (cq->decmprs_left)
882 work_done += mlx5e_decompress_cqes_cont(rq, cq, 0, budget); 923 work_done += mlx5e_decompress_cqes_cont(rq, cq, 0, budget);
883 924
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 5a750b9cd006..5740b465ef84 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -110,8 +110,20 @@ u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
110{ 110{
111 struct mlx5e_priv *priv = netdev_priv(dev); 111 struct mlx5e_priv *priv = netdev_priv(dev);
112 int channel_ix = fallback(dev, skb); 112 int channel_ix = fallback(dev, skb);
113 int up = (netdev_get_num_tc(dev) && skb_vlan_tag_present(skb)) ? 113 int up = 0;
114 skb->vlan_tci >> VLAN_PRIO_SHIFT : 0; 114
115 if (!netdev_get_num_tc(dev))
116 return channel_ix;
117
118 if (skb_vlan_tag_present(skb))
119 up = skb->vlan_tci >> VLAN_PRIO_SHIFT;
120
121 /* channel_ix can be larger than num_channels since
122 * dev->num_real_tx_queues = num_channels * num_tc
123 */
124 if (channel_ix >= priv->params.num_channels)
125 channel_ix = reciprocal_scale(channel_ix,
126 priv->params.num_channels);
115 127
116 return priv->channeltc_to_txq_map[channel_ix][up]; 128 return priv->channeltc_to_txq_map[channel_ix][up];
117} 129}
@@ -123,7 +135,7 @@ static inline u16 mlx5e_get_inline_hdr_size(struct mlx5e_sq *sq,
123 * headers and occur before the data gather. 135 * headers and occur before the data gather.
124 * Therefore these headers must be copied into the WQE 136 * Therefore these headers must be copied into the WQE
125 */ 137 */
126#define MLX5E_MIN_INLINE ETH_HLEN 138#define MLX5E_MIN_INLINE (ETH_HLEN + VLAN_HLEN)
127 139
128 if (bf) { 140 if (bf) {
129 u16 ihs = skb_headlen(skb); 141 u16 ihs = skb_headlen(skb);
@@ -135,7 +147,7 @@ static inline u16 mlx5e_get_inline_hdr_size(struct mlx5e_sq *sq,
135 return skb_headlen(skb); 147 return skb_headlen(skb);
136 } 148 }
137 149
138 return MLX5E_MIN_INLINE; 150 return max(skb_network_offset(skb), MLX5E_MIN_INLINE);
139} 151}
140 152
141static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data, 153static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data,
@@ -341,6 +353,35 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)
341 return mlx5e_sq_xmit(sq, skb); 353 return mlx5e_sq_xmit(sq, skb);
342} 354}
343 355
356void mlx5e_free_tx_descs(struct mlx5e_sq *sq)
357{
358 struct mlx5e_tx_wqe_info *wi;
359 struct sk_buff *skb;
360 u16 ci;
361 int i;
362
363 while (sq->cc != sq->pc) {
364 ci = sq->cc & sq->wq.sz_m1;
365 skb = sq->skb[ci];
366 wi = &sq->wqe_info[ci];
367
368 if (!skb) { /* nop */
369 sq->cc++;
370 continue;
371 }
372
373 for (i = 0; i < wi->num_dma; i++) {
374 struct mlx5e_sq_dma *dma =
375 mlx5e_dma_get(sq, sq->dma_fifo_cc++);
376
377 mlx5e_tx_dma_unmap(sq->pdev, dma);
378 }
379
380 dev_kfree_skb_any(skb);
381 sq->cc += wi->num_wqebbs;
382 }
383}
384
344bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) 385bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
345{ 386{
346 struct mlx5e_sq *sq; 387 struct mlx5e_sq *sq;
@@ -352,6 +393,9 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
352 393
353 sq = container_of(cq, struct mlx5e_sq, cq); 394 sq = container_of(cq, struct mlx5e_sq, cq);
354 395
396 if (unlikely(test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state)))
397 return false;
398
355 npkts = 0; 399 npkts = 0;
356 nbytes = 0; 400 nbytes = 0;
357 401
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 42d16b9458e4..96a59463ae65 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -108,15 +108,21 @@ static int in_fatal(struct mlx5_core_dev *dev)
108 108
109void mlx5_enter_error_state(struct mlx5_core_dev *dev) 109void mlx5_enter_error_state(struct mlx5_core_dev *dev)
110{ 110{
111 mutex_lock(&dev->intf_state_mutex);
111 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) 112 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
112 return; 113 goto unlock;
113 114
114 mlx5_core_err(dev, "start\n"); 115 mlx5_core_err(dev, "start\n");
115 if (pci_channel_offline(dev->pdev) || in_fatal(dev)) 116 if (pci_channel_offline(dev->pdev) || in_fatal(dev)) {
116 dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR; 117 dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR;
118 trigger_cmd_completions(dev);
119 }
117 120
118 mlx5_core_event(dev, MLX5_DEV_EVENT_SYS_ERROR, 0); 121 mlx5_core_event(dev, MLX5_DEV_EVENT_SYS_ERROR, 0);
119 mlx5_core_err(dev, "end\n"); 122 mlx5_core_err(dev, "end\n");
123
124unlock:
125 mutex_unlock(&dev->intf_state_mutex);
120} 126}
121 127
122static void mlx5_handle_bad_state(struct mlx5_core_dev *dev) 128static void mlx5_handle_bad_state(struct mlx5_core_dev *dev)
@@ -245,7 +251,6 @@ static void poll_health(unsigned long data)
245 u32 count; 251 u32 count;
246 252
247 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { 253 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
248 trigger_cmd_completions(dev);
249 mod_timer(&health->timer, get_next_poll_jiffies()); 254 mod_timer(&health->timer, get_next_poll_jiffies());
250 return; 255 return;
251 } 256 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index c65f4a13e17e..6695893ddd2d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1422,46 +1422,31 @@ void mlx5_disable_device(struct mlx5_core_dev *dev)
1422 mlx5_pci_err_detected(dev->pdev, 0); 1422 mlx5_pci_err_detected(dev->pdev, 0);
1423} 1423}
1424 1424
1425/* wait for the device to show vital signs. For now we check 1425/* wait for the device to show vital signs by waiting
1426 * that we can read the device ID and that the health buffer 1426 * for the health counter to start counting.
1427 * shows a non zero value which is different than 0xffffffff
1428 */ 1427 */
1429static void wait_vital(struct pci_dev *pdev) 1428static int wait_vital(struct pci_dev *pdev)
1430{ 1429{
1431 struct mlx5_core_dev *dev = pci_get_drvdata(pdev); 1430 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1432 struct mlx5_core_health *health = &dev->priv.health; 1431 struct mlx5_core_health *health = &dev->priv.health;
1433 const int niter = 100; 1432 const int niter = 100;
1433 u32 last_count = 0;
1434 u32 count; 1434 u32 count;
1435 u16 did;
1436 int i; 1435 int i;
1437 1436
1438 /* Wait for firmware to be ready after reset */
1439 msleep(1000);
1440 for (i = 0; i < niter; i++) {
1441 if (pci_read_config_word(pdev, 2, &did)) {
1442 dev_warn(&pdev->dev, "failed reading config word\n");
1443 break;
1444 }
1445 if (did == pdev->device) {
1446 dev_info(&pdev->dev, "device ID correctly read after %d iterations\n", i);
1447 break;
1448 }
1449 msleep(50);
1450 }
1451 if (i == niter)
1452 dev_warn(&pdev->dev, "%s-%d: could not read device ID\n", __func__, __LINE__);
1453
1454 for (i = 0; i < niter; i++) { 1437 for (i = 0; i < niter; i++) {
1455 count = ioread32be(health->health_counter); 1438 count = ioread32be(health->health_counter);
1456 if (count && count != 0xffffffff) { 1439 if (count && count != 0xffffffff) {
1457 dev_info(&pdev->dev, "Counter value 0x%x after %d iterations\n", count, i); 1440 if (last_count && last_count != count) {
1458 break; 1441 dev_info(&pdev->dev, "Counter value 0x%x after %d iterations\n", count, i);
1442 return 0;
1443 }
1444 last_count = count;
1459 } 1445 }
1460 msleep(50); 1446 msleep(50);
1461 } 1447 }
1462 1448
1463 if (i == niter) 1449 return -ETIMEDOUT;
1464 dev_warn(&pdev->dev, "%s-%d: could not read device ID\n", __func__, __LINE__);
1465} 1450}
1466 1451
1467static void mlx5_pci_resume(struct pci_dev *pdev) 1452static void mlx5_pci_resume(struct pci_dev *pdev)
@@ -1473,7 +1458,11 @@ static void mlx5_pci_resume(struct pci_dev *pdev)
1473 dev_info(&pdev->dev, "%s was called\n", __func__); 1458 dev_info(&pdev->dev, "%s was called\n", __func__);
1474 1459
1475 pci_save_state(pdev); 1460 pci_save_state(pdev);
1476 wait_vital(pdev); 1461 err = wait_vital(pdev);
1462 if (err) {
1463 dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__);
1464 return;
1465 }
1477 1466
1478 err = mlx5_load_one(dev, priv); 1467 err = mlx5_load_one(dev, priv);
1479 if (err) 1468 if (err)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
index 9eeee0545f1c..32dea3524cee 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
@@ -345,7 +345,6 @@ retry:
345 func_id, npages, err); 345 func_id, npages, err);
346 goto out_4k; 346 goto out_4k;
347 } 347 }
348 dev->priv.fw_pages += npages;
349 348
350 err = mlx5_cmd_status_to_err(&out.hdr); 349 err = mlx5_cmd_status_to_err(&out.hdr);
351 if (err) { 350 if (err) {
@@ -373,6 +372,33 @@ out_free:
373 return err; 372 return err;
374} 373}
375 374
375static int reclaim_pages_cmd(struct mlx5_core_dev *dev,
376 struct mlx5_manage_pages_inbox *in, int in_size,
377 struct mlx5_manage_pages_outbox *out, int out_size)
378{
379 struct fw_page *fwp;
380 struct rb_node *p;
381 u32 npages;
382 u32 i = 0;
383
384 if (dev->state != MLX5_DEVICE_STATE_INTERNAL_ERROR)
385 return mlx5_cmd_exec_check_status(dev, (u32 *)in, in_size,
386 (u32 *)out, out_size);
387
388 npages = be32_to_cpu(in->num_entries);
389
390 p = rb_first(&dev->priv.page_root);
391 while (p && i < npages) {
392 fwp = rb_entry(p, struct fw_page, rb_node);
393 out->pas[i] = cpu_to_be64(fwp->addr);
394 p = rb_next(p);
395 i++;
396 }
397
398 out->num_entries = cpu_to_be32(i);
399 return 0;
400}
401
376static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages, 402static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
377 int *nclaimed) 403 int *nclaimed)
378{ 404{
@@ -398,15 +424,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
398 in.func_id = cpu_to_be16(func_id); 424 in.func_id = cpu_to_be16(func_id);
399 in.num_entries = cpu_to_be32(npages); 425 in.num_entries = cpu_to_be32(npages);
400 mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen); 426 mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen);
401 err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen); 427 err = reclaim_pages_cmd(dev, &in, sizeof(in), out, outlen);
402 if (err) { 428 if (err) {
403 mlx5_core_err(dev, "failed reclaiming pages\n"); 429 mlx5_core_err(dev, "failed reclaiming pages: err %d\n", err);
404 goto out_free;
405 }
406 dev->priv.fw_pages -= npages;
407
408 if (out->hdr.status) {
409 err = mlx5_cmd_status_to_err(&out->hdr);
410 goto out_free; 430 goto out_free;
411 } 431 }
412 432
@@ -417,13 +437,15 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
417 err = -EINVAL; 437 err = -EINVAL;
418 goto out_free; 438 goto out_free;
419 } 439 }
420 if (nclaimed)
421 *nclaimed = num_claimed;
422 440
423 for (i = 0; i < num_claimed; i++) { 441 for (i = 0; i < num_claimed; i++) {
424 addr = be64_to_cpu(out->pas[i]); 442 addr = be64_to_cpu(out->pas[i]);
425 free_4k(dev, addr); 443 free_4k(dev, addr);
426 } 444 }
445
446 if (nclaimed)
447 *nclaimed = num_claimed;
448
427 dev->priv.fw_pages -= num_claimed; 449 dev->priv.fw_pages -= num_claimed;
428 if (func_id) 450 if (func_id)
429 dev->priv.vfs_pages -= num_claimed; 451 dev->priv.vfs_pages -= num_claimed;
@@ -514,14 +536,10 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev)
514 p = rb_first(&dev->priv.page_root); 536 p = rb_first(&dev->priv.page_root);
515 if (p) { 537 if (p) {
516 fwp = rb_entry(p, struct fw_page, rb_node); 538 fwp = rb_entry(p, struct fw_page, rb_node);
517 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { 539 err = reclaim_pages(dev, fwp->func_id,
518 free_4k(dev, fwp->addr); 540 optimal_reclaimed_pages(),
519 nclaimed = 1; 541 &nclaimed);
520 } else { 542
521 err = reclaim_pages(dev, fwp->func_id,
522 optimal_reclaimed_pages(),
523 &nclaimed);
524 }
525 if (err) { 543 if (err) {
526 mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", 544 mlx5_core_warn(dev, "failed reclaiming pages (%d)\n",
527 err); 545 err);
@@ -536,6 +554,13 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev)
536 } 554 }
537 } while (p); 555 } while (p);
538 556
557 WARN(dev->priv.fw_pages,
558 "FW pages counter is %d after reclaiming all pages\n",
559 dev->priv.fw_pages);
560 WARN(dev->priv.vfs_pages,
561 "VFs FW pages counter is %d after reclaiming all pages\n",
562 dev->priv.vfs_pages);
563
539 return 0; 564 return 0;
540} 565}
541 566
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
index daf44cd4c566..91846dfcbe9c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
@@ -513,7 +513,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
513{ 513{
514 int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); 514 int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
515 void *nic_vport_context; 515 void *nic_vport_context;
516 u8 *guid;
517 void *in; 516 void *in;
518 int err; 517 int err;
519 518
@@ -535,8 +534,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
535 534
536 nic_vport_context = MLX5_ADDR_OF(modify_nic_vport_context_in, 535 nic_vport_context = MLX5_ADDR_OF(modify_nic_vport_context_in,
537 in, nic_vport_context); 536 in, nic_vport_context);
538 guid = MLX5_ADDR_OF(nic_vport_context, nic_vport_context,
539 node_guid);
540 MLX5_SET64(nic_vport_context, nic_vport_context, node_guid, node_guid); 537 MLX5_SET64(nic_vport_context, nic_vport_context, node_guid, node_guid);
541 538
542 err = mlx5_modify_nic_vport_context(mdev, in, inlen); 539 err = mlx5_modify_nic_vport_context(mdev, in, inlen);
diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c
index 7066954c39d6..0a26b11ca8f6 100644
--- a/drivers/net/ethernet/microchip/enc28j60.c
+++ b/drivers/net/ethernet/microchip/enc28j60.c
@@ -1151,7 +1151,8 @@ static void enc28j60_irq_work_handler(struct work_struct *work)
1151 enc28j60_phy_read(priv, PHIR); 1151 enc28j60_phy_read(priv, PHIR);
1152 } 1152 }
1153 /* TX complete handler */ 1153 /* TX complete handler */
1154 if ((intflags & EIR_TXIF) != 0) { 1154 if (((intflags & EIR_TXIF) != 0) &&
1155 ((intflags & EIR_TXERIF) == 0)) {
1155 bool err = false; 1156 bool err = false;
1156 loop++; 1157 loop++;
1157 if (netif_msg_intr(priv)) 1158 if (netif_msg_intr(priv))
@@ -1203,7 +1204,7 @@ static void enc28j60_irq_work_handler(struct work_struct *work)
1203 enc28j60_tx_clear(ndev, true); 1204 enc28j60_tx_clear(ndev, true);
1204 } else 1205 } else
1205 enc28j60_tx_clear(ndev, true); 1206 enc28j60_tx_clear(ndev, true);
1206 locked_reg_bfclr(priv, EIR, EIR_TXERIF); 1207 locked_reg_bfclr(priv, EIR, EIR_TXERIF | EIR_TXIF);
1207 } 1208 }
1208 /* RX Error handler */ 1209 /* RX Error handler */
1209 if ((intflags & EIR_RXERIF) != 0) { 1210 if ((intflags & EIR_RXERIF) != 0) {
@@ -1238,6 +1239,8 @@ static void enc28j60_irq_work_handler(struct work_struct *work)
1238 */ 1239 */
1239static void enc28j60_hw_tx(struct enc28j60_net *priv) 1240static void enc28j60_hw_tx(struct enc28j60_net *priv)
1240{ 1241{
1242 BUG_ON(!priv->tx_skb);
1243
1241 if (netif_msg_tx_queued(priv)) 1244 if (netif_msg_tx_queued(priv))
1242 printk(KERN_DEBUG DRV_NAME 1245 printk(KERN_DEBUG DRV_NAME
1243 ": Tx Packet Len:%d\n", priv->tx_skb->len); 1246 ": Tx Packet Len:%d\n", priv->tx_skb->len);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
index 607bb7d4514d..87c642d3b075 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
@@ -772,6 +772,8 @@ netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
772 tx_ring->tx_stats.tx_bytes += skb->len; 772 tx_ring->tx_stats.tx_bytes += skb->len;
773 tx_ring->tx_stats.xmit_called++; 773 tx_ring->tx_stats.xmit_called++;
774 774
775 /* Ensure writes are complete before HW fetches Tx descriptors */
776 wmb();
775 qlcnic_update_cmd_producer(tx_ring); 777 qlcnic_update_cmd_producer(tx_ring);
776 778
777 return NETDEV_TX_OK; 779 return NETDEV_TX_OK;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a473c182c91d..e4071265be76 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2804,7 +2804,7 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)
2804 priv->tx_path_in_lpi_mode = true; 2804 priv->tx_path_in_lpi_mode = true;
2805 if (status & CORE_IRQ_TX_PATH_EXIT_LPI_MODE) 2805 if (status & CORE_IRQ_TX_PATH_EXIT_LPI_MODE)
2806 priv->tx_path_in_lpi_mode = false; 2806 priv->tx_path_in_lpi_mode = false;
2807 if (status & CORE_IRQ_MTL_RX_OVERFLOW) 2807 if (status & CORE_IRQ_MTL_RX_OVERFLOW && priv->hw->dma->set_rx_tail_ptr)
2808 priv->hw->dma->set_rx_tail_ptr(priv->ioaddr, 2808 priv->hw->dma->set_rx_tail_ptr(priv->ioaddr,
2809 priv->rx_tail_addr, 2809 priv->rx_tail_addr,
2810 STMMAC_CHAN0); 2810 STMMAC_CHAN0);
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index cc39cefeae45..9b3dc3c61e00 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1072,12 +1072,17 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
1072 1072
1073static int __geneve_change_mtu(struct net_device *dev, int new_mtu, bool strict) 1073static int __geneve_change_mtu(struct net_device *dev, int new_mtu, bool strict)
1074{ 1074{
1075 struct geneve_dev *geneve = netdev_priv(dev);
1075 /* The max_mtu calculation does not take account of GENEVE 1076 /* The max_mtu calculation does not take account of GENEVE
1076 * options, to avoid excluding potentially valid 1077 * options, to avoid excluding potentially valid
1077 * configurations. 1078 * configurations.
1078 */ 1079 */
1079 int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - sizeof(struct iphdr) 1080 int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - dev->hard_header_len;
1080 - dev->hard_header_len; 1081
1082 if (geneve->remote.sa.sa_family == AF_INET6)
1083 max_mtu -= sizeof(struct ipv6hdr);
1084 else
1085 max_mtu -= sizeof(struct iphdr);
1081 1086
1082 if (new_mtu < 68) 1087 if (new_mtu < 68)
1083 return -EINVAL; 1088 return -EINVAL;
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 0e7eff7f1cd2..8bcd78f94966 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2640,6 +2640,7 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
2640 u64_stats_update_begin(&secy_stats->syncp); 2640 u64_stats_update_begin(&secy_stats->syncp);
2641 secy_stats->stats.OutPktsUntagged++; 2641 secy_stats->stats.OutPktsUntagged++;
2642 u64_stats_update_end(&secy_stats->syncp); 2642 u64_stats_update_end(&secy_stats->syncp);
2643 skb->dev = macsec->real_dev;
2643 len = skb->len; 2644 len = skb->len;
2644 ret = dev_queue_xmit(skb); 2645 ret = dev_queue_xmit(skb);
2645 count_tx(dev, ret, len); 2646 count_tx(dev, ret, len);
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 2afa61b51d41..91177a4a32ad 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -57,6 +57,7 @@
57 57
58/* PHY CTRL bits */ 58/* PHY CTRL bits */
59#define DP83867_PHYCR_FIFO_DEPTH_SHIFT 14 59#define DP83867_PHYCR_FIFO_DEPTH_SHIFT 14
60#define DP83867_PHYCR_FIFO_DEPTH_MASK (3 << 14)
60 61
61/* RGMIIDCTL bits */ 62/* RGMIIDCTL bits */
62#define DP83867_RGMII_TX_CLK_DELAY_SHIFT 4 63#define DP83867_RGMII_TX_CLK_DELAY_SHIFT 4
@@ -133,8 +134,8 @@ static int dp83867_of_init(struct phy_device *phydev)
133static int dp83867_config_init(struct phy_device *phydev) 134static int dp83867_config_init(struct phy_device *phydev)
134{ 135{
135 struct dp83867_private *dp83867; 136 struct dp83867_private *dp83867;
136 int ret; 137 int ret, val;
137 u16 val, delay; 138 u16 delay;
138 139
139 if (!phydev->priv) { 140 if (!phydev->priv) {
140 dp83867 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83867), 141 dp83867 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83867),
@@ -151,8 +152,12 @@ static int dp83867_config_init(struct phy_device *phydev)
151 } 152 }
152 153
153 if (phy_interface_is_rgmii(phydev)) { 154 if (phy_interface_is_rgmii(phydev)) {
154 ret = phy_write(phydev, MII_DP83867_PHYCTRL, 155 val = phy_read(phydev, MII_DP83867_PHYCTRL);
155 (dp83867->fifo_depth << DP83867_PHYCR_FIFO_DEPTH_SHIFT)); 156 if (val < 0)
157 return val;
158 val &= ~DP83867_PHYCR_FIFO_DEPTH_MASK;
159 val |= (dp83867->fifo_depth << DP83867_PHYCR_FIFO_DEPTH_SHIFT);
160 ret = phy_write(phydev, MII_DP83867_PHYCTRL, val);
156 if (ret) 161 if (ret)
157 return ret; 162 return ret;
158 } 163 }
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 53759c315b97..877c9516e781 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -854,6 +854,13 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
854 if (cdc_ncm_init(dev)) 854 if (cdc_ncm_init(dev))
855 goto error2; 855 goto error2;
856 856
857 /* Some firmwares need a pause here or they will silently fail
858 * to set up the interface properly. This value was decided
859 * empirically on a Sierra Wireless MC7455 running 02.08.02.00
860 * firmware.
861 */
862 usleep_range(10000, 20000);
863
857 /* configure data interface */ 864 /* configure data interface */
858 temp = usb_set_interface(dev->udev, iface_no, data_altsetting); 865 temp = usb_set_interface(dev->udev, iface_no, data_altsetting);
859 if (temp) { 866 if (temp) {
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 4e257b8d8f3e..0da72d39b4f9 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -31,7 +31,7 @@
31#define NETNEXT_VERSION "08" 31#define NETNEXT_VERSION "08"
32 32
33/* Information for net */ 33/* Information for net */
34#define NET_VERSION "4" 34#define NET_VERSION "5"
35 35
36#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION 36#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
37#define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" 37#define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>"
@@ -624,6 +624,7 @@ struct r8152 {
624 int (*eee_get)(struct r8152 *, struct ethtool_eee *); 624 int (*eee_get)(struct r8152 *, struct ethtool_eee *);
625 int (*eee_set)(struct r8152 *, struct ethtool_eee *); 625 int (*eee_set)(struct r8152 *, struct ethtool_eee *);
626 bool (*in_nway)(struct r8152 *); 626 bool (*in_nway)(struct r8152 *);
627 void (*autosuspend_en)(struct r8152 *tp, bool enable);
627 } rtl_ops; 628 } rtl_ops;
628 629
629 int intr_interval; 630 int intr_interval;
@@ -2408,9 +2409,6 @@ static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable)
2408 if (enable) { 2409 if (enable) {
2409 u32 ocp_data; 2410 u32 ocp_data;
2410 2411
2411 r8153_u1u2en(tp, false);
2412 r8153_u2p3en(tp, false);
2413
2414 __rtl_set_wol(tp, WAKE_ANY); 2412 __rtl_set_wol(tp, WAKE_ANY);
2415 2413
2416 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG); 2414 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG);
@@ -2421,7 +2419,28 @@ static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable)
2421 2419
2422 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); 2420 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML);
2423 } else { 2421 } else {
2422 u32 ocp_data;
2423
2424 __rtl_set_wol(tp, tp->saved_wolopts); 2424 __rtl_set_wol(tp, tp->saved_wolopts);
2425
2426 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG);
2427
2428 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CONFIG34);
2429 ocp_data &= ~LINK_OFF_WAKE_EN;
2430 ocp_write_word(tp, MCU_TYPE_PLA, PLA_CONFIG34, ocp_data);
2431
2432 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML);
2433 }
2434}
2435
2436static void rtl8153_runtime_enable(struct r8152 *tp, bool enable)
2437{
2438 rtl_runtime_suspend_enable(tp, enable);
2439
2440 if (enable) {
2441 r8153_u1u2en(tp, false);
2442 r8153_u2p3en(tp, false);
2443 } else {
2425 r8153_u2p3en(tp, true); 2444 r8153_u2p3en(tp, true);
2426 r8153_u1u2en(tp, true); 2445 r8153_u1u2en(tp, true);
2427 } 2446 }
@@ -3512,7 +3531,7 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
3512 napi_disable(&tp->napi); 3531 napi_disable(&tp->napi);
3513 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3532 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3514 rtl_stop_rx(tp); 3533 rtl_stop_rx(tp);
3515 rtl_runtime_suspend_enable(tp, true); 3534 tp->rtl_ops.autosuspend_en(tp, true);
3516 } else { 3535 } else {
3517 cancel_delayed_work_sync(&tp->schedule); 3536 cancel_delayed_work_sync(&tp->schedule);
3518 tp->rtl_ops.down(tp); 3537 tp->rtl_ops.down(tp);
@@ -3538,7 +3557,7 @@ static int rtl8152_resume(struct usb_interface *intf)
3538 3557
3539 if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) { 3558 if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) {
3540 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3559 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3541 rtl_runtime_suspend_enable(tp, false); 3560 tp->rtl_ops.autosuspend_en(tp, false);
3542 clear_bit(SELECTIVE_SUSPEND, &tp->flags); 3561 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3543 napi_disable(&tp->napi); 3562 napi_disable(&tp->napi);
3544 set_bit(WORK_ENABLE, &tp->flags); 3563 set_bit(WORK_ENABLE, &tp->flags);
@@ -3557,7 +3576,7 @@ static int rtl8152_resume(struct usb_interface *intf)
3557 usb_submit_urb(tp->intr_urb, GFP_KERNEL); 3576 usb_submit_urb(tp->intr_urb, GFP_KERNEL);
3558 } else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3577 } else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3559 if (tp->netdev->flags & IFF_UP) 3578 if (tp->netdev->flags & IFF_UP)
3560 rtl_runtime_suspend_enable(tp, false); 3579 tp->rtl_ops.autosuspend_en(tp, false);
3561 clear_bit(SELECTIVE_SUSPEND, &tp->flags); 3580 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3562 } 3581 }
3563 3582
@@ -4137,6 +4156,7 @@ static int rtl_ops_init(struct r8152 *tp)
4137 ops->eee_get = r8152_get_eee; 4156 ops->eee_get = r8152_get_eee;
4138 ops->eee_set = r8152_set_eee; 4157 ops->eee_set = r8152_set_eee;
4139 ops->in_nway = rtl8152_in_nway; 4158 ops->in_nway = rtl8152_in_nway;
4159 ops->autosuspend_en = rtl_runtime_suspend_enable;
4140 break; 4160 break;
4141 4161
4142 case RTL_VER_03: 4162 case RTL_VER_03:
@@ -4152,6 +4172,7 @@ static int rtl_ops_init(struct r8152 *tp)
4152 ops->eee_get = r8153_get_eee; 4172 ops->eee_get = r8153_get_eee;
4153 ops->eee_set = r8153_set_eee; 4173 ops->eee_set = r8153_set_eee;
4154 ops->in_nway = rtl8153_in_nway; 4174 ops->in_nway = rtl8153_in_nway;
4175 ops->autosuspend_en = rtl8153_runtime_enable;
4155 break; 4176 break;
4156 4177
4157 default: 4178 default:
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 61ba46404937..6086a0163249 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -395,8 +395,11 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu)
395 dev->hard_mtu = net->mtu + net->hard_header_len; 395 dev->hard_mtu = net->mtu + net->hard_header_len;
396 if (dev->rx_urb_size == old_hard_mtu) { 396 if (dev->rx_urb_size == old_hard_mtu) {
397 dev->rx_urb_size = dev->hard_mtu; 397 dev->rx_urb_size = dev->hard_mtu;
398 if (dev->rx_urb_size > old_rx_urb_size) 398 if (dev->rx_urb_size > old_rx_urb_size) {
399 usbnet_pause_rx(dev);
399 usbnet_unlink_rx_urbs(dev); 400 usbnet_unlink_rx_urbs(dev);
401 usbnet_resume_rx(dev);
402 }
400 } 403 }
401 404
402 /* max qlen depend on hard_mtu and rx_urb_size */ 405 /* max qlen depend on hard_mtu and rx_urb_size */
@@ -1508,8 +1511,9 @@ static void usbnet_bh (unsigned long param)
1508 } else if (netif_running (dev->net) && 1511 } else if (netif_running (dev->net) &&
1509 netif_device_present (dev->net) && 1512 netif_device_present (dev->net) &&
1510 netif_carrier_ok(dev->net) && 1513 netif_carrier_ok(dev->net) &&
1511 !timer_pending (&dev->delay) && 1514 !timer_pending(&dev->delay) &&
1512 !test_bit (EVENT_RX_HALT, &dev->flags)) { 1515 !test_bit(EVENT_RX_PAUSED, &dev->flags) &&
1516 !test_bit(EVENT_RX_HALT, &dev->flags)) {
1513 int temp = dev->rxq.qlen; 1517 int temp = dev->rxq.qlen;
1514 1518
1515 if (temp < RX_QLEN(dev)) { 1519 if (temp < RX_QLEN(dev)) {
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 80b1979e8d95..df036b872b05 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -1051,6 +1051,7 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
1051 qeth_l2_set_offline(cgdev); 1051 qeth_l2_set_offline(cgdev);
1052 1052
1053 if (card->dev) { 1053 if (card->dev) {
1054 netif_napi_del(&card->napi);
1054 unregister_netdev(card->dev); 1055 unregister_netdev(card->dev);
1055 card->dev = NULL; 1056 card->dev = NULL;
1056 } 1057 }
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index ac544330daeb..709b52339ff9 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -3226,6 +3226,7 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)
3226 qeth_l3_set_offline(cgdev); 3226 qeth_l3_set_offline(cgdev);
3227 3227
3228 if (card->dev) { 3228 if (card->dev) {
3229 netif_napi_del(&card->napi);
3229 unregister_netdev(card->dev); 3230 unregister_netdev(card->dev);
3230 card->dev = NULL; 3231 card->dev = NULL;
3231 } 3232 }
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 80776d0c52dc..fd72ecf0ce9f 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -629,6 +629,7 @@ struct mlx5_cmd_work_ent {
629 void *uout; 629 void *uout;
630 int uout_size; 630 int uout_size;
631 mlx5_cmd_cbk_t callback; 631 mlx5_cmd_cbk_t callback;
632 struct delayed_work cb_timeout_work;
632 void *context; 633 void *context;
633 int idx; 634 int idx;
634 struct completion done; 635 struct completion done;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index ee38a4127475..f39b37180c41 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1062,6 +1062,7 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
1062} 1062}
1063 1063
1064void __skb_get_hash(struct sk_buff *skb); 1064void __skb_get_hash(struct sk_buff *skb);
1065u32 __skb_get_hash_symmetric(struct sk_buff *skb);
1065u32 skb_get_poff(const struct sk_buff *skb); 1066u32 skb_get_poff(const struct sk_buff *skb);
1066u32 __skb_get_poff(const struct sk_buff *skb, void *data, 1067u32 __skb_get_poff(const struct sk_buff *skb, void *data,
1067 const struct flow_keys *keys, int hlen); 1068 const struct flow_keys *keys, int hlen);
@@ -2870,6 +2871,25 @@ static inline void skb_postpush_rcsum(struct sk_buff *skb,
2870} 2871}
2871 2872
2872/** 2873/**
2874 * skb_push_rcsum - push skb and update receive checksum
2875 * @skb: buffer to update
2876 * @len: length of data pulled
2877 *
2878 * This function performs an skb_push on the packet and updates
2879 * the CHECKSUM_COMPLETE checksum. It should be used on
2880 * receive path processing instead of skb_push unless you know
2881 * that the checksum difference is zero (e.g., a valid IP header)
2882 * or you are setting ip_summed to CHECKSUM_NONE.
2883 */
2884static inline unsigned char *skb_push_rcsum(struct sk_buff *skb,
2885 unsigned int len)
2886{
2887 skb_push(skb, len);
2888 skb_postpush_rcsum(skb, skb->data, len);
2889 return skb->data;
2890}
2891
2892/**
2873 * pskb_trim_rcsum - trim received skb and update checksum 2893 * pskb_trim_rcsum - trim received skb and update checksum
2874 * @skb: buffer to trim 2894 * @skb: buffer to trim
2875 * @len: new length 2895 * @len: new length
diff --git a/include/net/bonding.h b/include/net/bonding.h
index 791800ddd6d9..6360c259da6d 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -34,6 +34,9 @@
34 34
35#define BOND_DEFAULT_MIIMON 100 35#define BOND_DEFAULT_MIIMON 100
36 36
37#ifndef __long_aligned
38#define __long_aligned __attribute__((aligned((sizeof(long)))))
39#endif
37/* 40/*
38 * Less bad way to call ioctl from within the kernel; this needs to be 41 * Less bad way to call ioctl from within the kernel; this needs to be
39 * done some other way to get the call out of interrupt context. 42 * done some other way to get the call out of interrupt context.
@@ -138,7 +141,9 @@ struct bond_params {
138 struct reciprocal_value reciprocal_packets_per_slave; 141 struct reciprocal_value reciprocal_packets_per_slave;
139 u16 ad_actor_sys_prio; 142 u16 ad_actor_sys_prio;
140 u16 ad_user_port_key; 143 u16 ad_user_port_key;
141 u8 ad_actor_system[ETH_ALEN]; 144
145 /* 2 bytes of padding : see ether_addr_equal_64bits() */
146 u8 ad_actor_system[ETH_ALEN + 2];
142}; 147};
143 148
144struct bond_parm_tbl { 149struct bond_parm_tbl {
diff --git a/include/net/ip.h b/include/net/ip.h
index 37165fba3741..08f36cd2b874 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -313,10 +313,9 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
313 return min(dst->dev->mtu, IP_MAX_MTU); 313 return min(dst->dev->mtu, IP_MAX_MTU);
314} 314}
315 315
316static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb) 316static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
317 const struct sk_buff *skb)
317{ 318{
318 struct sock *sk = skb->sk;
319
320 if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) { 319 if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) {
321 bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED; 320 bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED;
322 321
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index 2d25979273a6..77e7f69bf80d 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -700,7 +700,7 @@ static int
700br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, 700br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
701 int (*output)(struct net *, struct sock *, struct sk_buff *)) 701 int (*output)(struct net *, struct sock *, struct sk_buff *))
702{ 702{
703 unsigned int mtu = ip_skb_dst_mtu(skb); 703 unsigned int mtu = ip_skb_dst_mtu(sk, skb);
704 struct iphdr *iph = ip_hdr(skb); 704 struct iphdr *iph = ip_hdr(skb);
705 705
706 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) || 706 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index a669dea146c6..61ad43f61c5e 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -651,6 +651,23 @@ void make_flow_keys_digest(struct flow_keys_digest *digest,
651} 651}
652EXPORT_SYMBOL(make_flow_keys_digest); 652EXPORT_SYMBOL(make_flow_keys_digest);
653 653
654static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
655
656u32 __skb_get_hash_symmetric(struct sk_buff *skb)
657{
658 struct flow_keys keys;
659
660 __flow_hash_secret_init();
661
662 memset(&keys, 0, sizeof(keys));
663 __skb_flow_dissect(skb, &flow_keys_dissector_symmetric, &keys,
664 NULL, 0, 0, 0,
665 FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
666
667 return __flow_hash_from_keys(&keys, hashrnd);
668}
669EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);
670
654/** 671/**
655 * __skb_get_hash: calculate a flow hash 672 * __skb_get_hash: calculate a flow hash
656 * @skb: sk_buff to calculate flow hash from 673 * @skb: sk_buff to calculate flow hash from
@@ -868,6 +885,29 @@ static const struct flow_dissector_key flow_keys_dissector_keys[] = {
868 }, 885 },
869}; 886};
870 887
888static const struct flow_dissector_key flow_keys_dissector_symmetric_keys[] = {
889 {
890 .key_id = FLOW_DISSECTOR_KEY_CONTROL,
891 .offset = offsetof(struct flow_keys, control),
892 },
893 {
894 .key_id = FLOW_DISSECTOR_KEY_BASIC,
895 .offset = offsetof(struct flow_keys, basic),
896 },
897 {
898 .key_id = FLOW_DISSECTOR_KEY_IPV4_ADDRS,
899 .offset = offsetof(struct flow_keys, addrs.v4addrs),
900 },
901 {
902 .key_id = FLOW_DISSECTOR_KEY_IPV6_ADDRS,
903 .offset = offsetof(struct flow_keys, addrs.v6addrs),
904 },
905 {
906 .key_id = FLOW_DISSECTOR_KEY_PORTS,
907 .offset = offsetof(struct flow_keys, ports),
908 },
909};
910
871static const struct flow_dissector_key flow_keys_buf_dissector_keys[] = { 911static const struct flow_dissector_key flow_keys_buf_dissector_keys[] = {
872 { 912 {
873 .key_id = FLOW_DISSECTOR_KEY_CONTROL, 913 .key_id = FLOW_DISSECTOR_KEY_CONTROL,
@@ -889,6 +929,9 @@ static int __init init_default_flow_dissectors(void)
889 skb_flow_dissector_init(&flow_keys_dissector, 929 skb_flow_dissector_init(&flow_keys_dissector,
890 flow_keys_dissector_keys, 930 flow_keys_dissector_keys,
891 ARRAY_SIZE(flow_keys_dissector_keys)); 931 ARRAY_SIZE(flow_keys_dissector_keys));
932 skb_flow_dissector_init(&flow_keys_dissector_symmetric,
933 flow_keys_dissector_symmetric_keys,
934 ARRAY_SIZE(flow_keys_dissector_symmetric_keys));
892 skb_flow_dissector_init(&flow_keys_buf_dissector, 935 skb_flow_dissector_init(&flow_keys_buf_dissector,
893 flow_keys_buf_dissector_keys, 936 flow_keys_buf_dissector_keys,
894 ARRAY_SIZE(flow_keys_buf_dissector_keys)); 937 ARRAY_SIZE(flow_keys_buf_dissector_keys));
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f2b77e549c03..eb12d2161fb2 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3016,24 +3016,6 @@ int skb_append_pagefrags(struct sk_buff *skb, struct page *page,
3016EXPORT_SYMBOL_GPL(skb_append_pagefrags); 3016EXPORT_SYMBOL_GPL(skb_append_pagefrags);
3017 3017
3018/** 3018/**
3019 * skb_push_rcsum - push skb and update receive checksum
3020 * @skb: buffer to update
3021 * @len: length of data pulled
3022 *
3023 * This function performs an skb_push on the packet and updates
3024 * the CHECKSUM_COMPLETE checksum. It should be used on
3025 * receive path processing instead of skb_push unless you know
3026 * that the checksum difference is zero (e.g., a valid IP header)
3027 * or you are setting ip_summed to CHECKSUM_NONE.
3028 */
3029static unsigned char *skb_push_rcsum(struct sk_buff *skb, unsigned len)
3030{
3031 skb_push(skb, len);
3032 skb_postpush_rcsum(skb, skb->data, len);
3033 return skb->data;
3034}
3035
3036/**
3037 * skb_pull_rcsum - pull skb and update receive checksum 3019 * skb_pull_rcsum - pull skb and update receive checksum
3038 * @skb: buffer to update 3020 * @skb: buffer to update
3039 * @len: length of data pulled 3021 * @len: length of data pulled
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index df4803437888..a796fc7cbc35 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -41,6 +41,7 @@
41#include <net/dn_fib.h> 41#include <net/dn_fib.h>
42#include <net/dn_neigh.h> 42#include <net/dn_neigh.h>
43#include <net/dn_dev.h> 43#include <net/dn_dev.h>
44#include <net/nexthop.h>
44 45
45#define RT_MIN_TABLE 1 46#define RT_MIN_TABLE 1
46 47
@@ -150,14 +151,13 @@ static int dn_fib_count_nhs(const struct nlattr *attr)
150 struct rtnexthop *nhp = nla_data(attr); 151 struct rtnexthop *nhp = nla_data(attr);
151 int nhs = 0, nhlen = nla_len(attr); 152 int nhs = 0, nhlen = nla_len(attr);
152 153
153 while(nhlen >= (int)sizeof(struct rtnexthop)) { 154 while (rtnh_ok(nhp, nhlen)) {
154 if ((nhlen -= nhp->rtnh_len) < 0)
155 return 0;
156 nhs++; 155 nhs++;
157 nhp = RTNH_NEXT(nhp); 156 nhp = rtnh_next(nhp, &nhlen);
158 } 157 }
159 158
160 return nhs; 159 /* leftover implies invalid nexthop configuration, discard it */
160 return nhlen > 0 ? 0 : nhs;
161} 161}
162 162
163static int dn_fib_get_nhs(struct dn_fib_info *fi, const struct nlattr *attr, 163static int dn_fib_get_nhs(struct dn_fib_info *fi, const struct nlattr *attr,
@@ -167,21 +167,24 @@ static int dn_fib_get_nhs(struct dn_fib_info *fi, const struct nlattr *attr,
167 int nhlen = nla_len(attr); 167 int nhlen = nla_len(attr);
168 168
169 change_nexthops(fi) { 169 change_nexthops(fi) {
170 int attrlen = nhlen - sizeof(struct rtnexthop); 170 int attrlen;
171 if (attrlen < 0 || (nhlen -= nhp->rtnh_len) < 0) 171
172 if (!rtnh_ok(nhp, nhlen))
172 return -EINVAL; 173 return -EINVAL;
173 174
174 nh->nh_flags = (r->rtm_flags&~0xFF) | nhp->rtnh_flags; 175 nh->nh_flags = (r->rtm_flags&~0xFF) | nhp->rtnh_flags;
175 nh->nh_oif = nhp->rtnh_ifindex; 176 nh->nh_oif = nhp->rtnh_ifindex;
176 nh->nh_weight = nhp->rtnh_hops + 1; 177 nh->nh_weight = nhp->rtnh_hops + 1;
177 178
178 if (attrlen) { 179 attrlen = rtnh_attrlen(nhp);
180 if (attrlen > 0) {
179 struct nlattr *gw_attr; 181 struct nlattr *gw_attr;
180 182
181 gw_attr = nla_find((struct nlattr *) (nhp + 1), attrlen, RTA_GATEWAY); 183 gw_attr = nla_find((struct nlattr *) (nhp + 1), attrlen, RTA_GATEWAY);
182 nh->nh_gw = gw_attr ? nla_get_le16(gw_attr) : 0; 184 nh->nh_gw = gw_attr ? nla_get_le16(gw_attr) : 0;
183 } 185 }
184 nhp = RTNH_NEXT(nhp); 186
187 nhp = rtnh_next(nhp, &nhlen);
185 } endfor_nexthops(fi); 188 } endfor_nexthops(fi);
186 189
187 return 0; 190 return 0;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 124bf0a66328..4bd4921639c3 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -271,7 +271,7 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk
271 return dst_output(net, sk, skb); 271 return dst_output(net, sk, skb);
272 } 272 }
273#endif 273#endif
274 mtu = ip_skb_dst_mtu(skb); 274 mtu = ip_skb_dst_mtu(sk, skb);
275 if (skb_is_gso(skb)) 275 if (skb_is_gso(skb))
276 return ip_finish_output_gso(net, sk, skb, mtu); 276 return ip_finish_output_gso(net, sk, skb, mtu);
277 277
@@ -541,7 +541,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
541 541
542 iph = ip_hdr(skb); 542 iph = ip_hdr(skb);
543 543
544 mtu = ip_skb_dst_mtu(skb); 544 mtu = ip_skb_dst_mtu(sk, skb);
545 if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu) 545 if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu)
546 mtu = IPCB(skb)->frag_max_size; 546 mtu = IPCB(skb)->frag_max_size;
547 547
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 1bcef2369d64..771be1fa4176 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -177,6 +177,7 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
177 } 177 }
178 } 178 }
179 179
180 free_percpu(non_pcpu_rt->rt6i_pcpu);
180 non_pcpu_rt->rt6i_pcpu = NULL; 181 non_pcpu_rt->rt6i_pcpu = NULL;
181} 182}
182 183
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 9bff6ef16fa7..9f0983fa4d52 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1341,7 +1341,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f,
1341 struct sk_buff *skb, 1341 struct sk_buff *skb,
1342 unsigned int num) 1342 unsigned int num)
1343{ 1343{
1344 return reciprocal_scale(skb_get_hash(skb), num); 1344 return reciprocal_scale(__skb_get_hash_symmetric(skb), num);
1345} 1345}
1346 1346
1347static unsigned int fanout_demux_lb(struct packet_fanout *f, 1347static unsigned int fanout_demux_lb(struct packet_fanout *f,
diff --git a/net/rds/tcp.c b/net/rds/tcp.c
index 74ee126a6fe6..c8a7b4c90190 100644
--- a/net/rds/tcp.c
+++ b/net/rds/tcp.c
@@ -616,7 +616,7 @@ static int rds_tcp_init(void)
616 616
617 ret = rds_tcp_recv_init(); 617 ret = rds_tcp_recv_init();
618 if (ret) 618 if (ret)
619 goto out_slab; 619 goto out_pernet;
620 620
621 ret = rds_trans_register(&rds_tcp_transport); 621 ret = rds_trans_register(&rds_tcp_transport);
622 if (ret) 622 if (ret)
@@ -628,8 +628,9 @@ static int rds_tcp_init(void)
628 628
629out_recv: 629out_recv:
630 rds_tcp_recv_exit(); 630 rds_tcp_recv_exit();
631out_slab: 631out_pernet:
632 unregister_pernet_subsys(&rds_tcp_net_ops); 632 unregister_pernet_subsys(&rds_tcp_net_ops);
633out_slab:
633 kmem_cache_destroy(rds_tcp_conn_slab); 634 kmem_cache_destroy(rds_tcp_conn_slab);
634out: 635out:
635 return ret; 636 return ret;
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 128942bc9e42..1f5bd6ccbd2c 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -181,7 +181,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
181 181
182 if (!(at & AT_EGRESS)) { 182 if (!(at & AT_EGRESS)) {
183 if (m->tcfm_ok_push) 183 if (m->tcfm_ok_push)
184 skb_push(skb2, skb->mac_len); 184 skb_push_rcsum(skb2, skb->mac_len);
185 } 185 }
186 186
187 /* mirror is always swallowed */ 187 /* mirror is always swallowed */
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 3ad9fab1985f..1fd464764765 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -604,7 +604,7 @@ static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,
604 604
605 link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]); 605 link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
606 link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP])); 606 link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
607 nla_strlcpy(link_info.str, nla_data(link[TIPC_NLA_LINK_NAME]), 607 nla_strlcpy(link_info.str, link[TIPC_NLA_LINK_NAME],
608 TIPC_MAX_LINK_NAME); 608 TIPC_MAX_LINK_NAME);
609 609
610 return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO, 610 return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO,