aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-11-01 12:16:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-11-01 12:16:01 -0400
commit82aa4671516a3203261c835e98c3eecab10c994d (patch)
tree501e1dc6eae7d26c79129d2822bac3e24180b274
parentffb845db50012eb3704a270efdf9b98be4e3454a (diff)
parent46ebe2834ba5b541f28ee72e556a3fed42c47570 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) BPF verifier fixes from Daniel Borkmann. 2) HNS driver fixes from Huazhong Tan. 3) FDB only works for ethernet devices, reject attempts to install FDB rules for others. From Ido Schimmel. 4) Fix spectre V1 in vhost, from Jason Wang. 5) Don't pass on-stack object to irq_set_affinity_hint() in mvpp2 driver, from Marc Zyngier. 6) Fix mlx5e checksum handling when RXFCS is enabled, from Eric Dumazet. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (49 commits) openvswitch: Fix push/pop ethernet validation net: stmmac: Fix stmmac_mdio_reset() when building stmmac as modules bpf: test make sure to run unpriv test cases in test_verifier bpf: add various test cases to test_verifier bpf: don't set id on after map lookup with ptr_to_map_val return bpf: fix partial copy of map_ptr when dst is scalar libbpf: Fix compile error in libbpf_attach_type_by_name kselftests/bpf: use ping6 as the default ipv6 ping binary if it exists selftests: mlxsw: qos_mc_aware: Add a test for UC awareness selftests: mlxsw: qos_mc_aware: Tweak for min shaper mlxsw: spectrum: Set minimum shaper on MC TCs mlxsw: reg: QEEC: Add minimum shaper fields net: hns3: bugfix for rtnl_lock's range in the hclgevf_reset() net: hns3: bugfix for rtnl_lock's range in the hclge_reset() net: hns3: bugfix for handling mailbox while the command queue reinitialized net: hns3: fix incorrect return value/type of some functions net: hns3: bugfix for hclge_mdio_write and hclge_mdio_read net: hns3: bugfix for is_valid_csq_clean_head() net: hns3: remove unnecessary queue reset in the hns3_uninit_all_ring() net: hns3: bugfix for the initialization of command queue's spin lock ...
-rw-r--r--Documentation/networking/ip-sysctl.txt11
-rw-r--r--drivers/net/bonding/bond_netlink.c3
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hnae3.h6
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3_enet.c117
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3_enet.h2
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c26
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c2
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c42
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h2
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c6
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c4
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c19
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c2
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h2
-rw-r--r--drivers/net/ethernet/intel/Kconfig18
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_iov.c51
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_main.c2
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_pci.c2
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_type.h2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c2
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ptp.c8
-rw-r--r--drivers/net/ethernet/intel/ixgbe/Makefile2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h8
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c6
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c4
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/Makefile2
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf.h4
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c2
-rw-r--r--drivers/net/ethernet/marvell/mvpp2/mvpp2.h1
-rw-r--r--drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c45
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.c24
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/reg.h22
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c25
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c2
-rw-r--r--drivers/vhost/vhost.c2
-rw-r--r--include/linux/avf/virtchnl.h12
-rw-r--r--include/linux/bpf_verifier.h3
-rw-r--r--include/linux/inetdevice.h4
-rw-r--r--include/net/af_unix.h4
-rw-r--r--kernel/bpf/verifier.c21
-rw-r--r--net/core/rtnetlink.c10
-rw-r--r--net/ipv4/igmp.c53
-rw-r--r--net/ipv4/tcp_bpf.c1
-rw-r--r--net/openvswitch/flow_netlink.c4
-rw-r--r--net/sctp/associola.c10
-rw-r--r--net/sctp/socket.c8
-rw-r--r--net/xfrm/Kconfig1
-rw-r--r--tools/lib/bpf/libbpf.c13
-rw-r--r--tools/testing/selftests/bpf/flow_dissector_load.c2
-rwxr-xr-xtools/testing/selftests/bpf/test_skb_cgroup_id.sh3
-rwxr-xr-xtools/testing/selftests/bpf/test_sock_addr.sh3
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c321
-rwxr-xr-xtools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh95
56 files changed, 793 insertions, 274 deletions
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 163b5ff1073c..32b21571adfe 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -316,6 +316,17 @@ tcp_frto - INTEGER
316 316
317 By default it's enabled with a non-zero value. 0 disables F-RTO. 317 By default it's enabled with a non-zero value. 0 disables F-RTO.
318 318
319tcp_fwmark_accept - BOOLEAN
320 If set, incoming connections to listening sockets that do not have a
321 socket mark will set the mark of the accepting socket to the fwmark of
322 the incoming SYN packet. This will cause all packets on that connection
323 (starting from the first SYNACK) to be sent with that fwmark. The
324 listening socket's mark is unchanged. Listening sockets that already
325 have a fwmark set via setsockopt(SOL_SOCKET, SO_MARK, ...) are
326 unaffected.
327
328 Default: 0
329
319tcp_invalid_ratelimit - INTEGER 330tcp_invalid_ratelimit - INTEGER
320 Limit the maximal rate for sending duplicate acknowledgments 331 Limit the maximal rate for sending duplicate acknowledgments
321 in response to incoming TCP packets that are for an existing 332 in response to incoming TCP packets that are for an existing
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 9697977b80f0..6b9ad8673218 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -638,8 +638,7 @@ static int bond_fill_info(struct sk_buff *skb,
638 goto nla_put_failure; 638 goto nla_put_failure;
639 639
640 if (nla_put(skb, IFLA_BOND_AD_ACTOR_SYSTEM, 640 if (nla_put(skb, IFLA_BOND_AD_ACTOR_SYSTEM,
641 sizeof(bond->params.ad_actor_system), 641 ETH_ALEN, &bond->params.ad_actor_system))
642 &bond->params.ad_actor_system))
643 goto nla_put_failure; 642 goto nla_put_failure;
644 } 643 }
645 if (!bond_3ad_get_active_agg_info(bond, &info)) { 644 if (!bond_3ad_get_active_agg_info(bond, &info)) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index e82e4ca20620..055b40606dbc 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -316,8 +316,8 @@ struct hnae3_ae_ops {
316 int (*set_loopback)(struct hnae3_handle *handle, 316 int (*set_loopback)(struct hnae3_handle *handle,
317 enum hnae3_loop loop_mode, bool en); 317 enum hnae3_loop loop_mode, bool en);
318 318
319 void (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc, 319 int (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc,
320 bool en_mc_pmc); 320 bool en_mc_pmc);
321 int (*set_mtu)(struct hnae3_handle *handle, int new_mtu); 321 int (*set_mtu)(struct hnae3_handle *handle, int new_mtu);
322 322
323 void (*get_pauseparam)(struct hnae3_handle *handle, 323 void (*get_pauseparam)(struct hnae3_handle *handle,
@@ -391,7 +391,7 @@ struct hnae3_ae_ops {
391 int vector_num, 391 int vector_num,
392 struct hnae3_ring_chain_node *vr_chain); 392 struct hnae3_ring_chain_node *vr_chain);
393 393
394 void (*reset_queue)(struct hnae3_handle *handle, u16 queue_id); 394 int (*reset_queue)(struct hnae3_handle *handle, u16 queue_id);
395 u32 (*get_fw_version)(struct hnae3_handle *handle); 395 u32 (*get_fw_version)(struct hnae3_handle *handle);
396 void (*get_mdix_mode)(struct hnae3_handle *handle, 396 void (*get_mdix_mode)(struct hnae3_handle *handle,
397 u8 *tp_mdix_ctrl, u8 *tp_mdix); 397 u8 *tp_mdix_ctrl, u8 *tp_mdix);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 32f3aca814e7..3f96aa30068e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -509,16 +509,18 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev)
509 h->netdev_flags = new_flags; 509 h->netdev_flags = new_flags;
510} 510}
511 511
512void hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags) 512int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags)
513{ 513{
514 struct hns3_nic_priv *priv = netdev_priv(netdev); 514 struct hns3_nic_priv *priv = netdev_priv(netdev);
515 struct hnae3_handle *h = priv->ae_handle; 515 struct hnae3_handle *h = priv->ae_handle;
516 516
517 if (h->ae_algo->ops->set_promisc_mode) { 517 if (h->ae_algo->ops->set_promisc_mode) {
518 h->ae_algo->ops->set_promisc_mode(h, 518 return h->ae_algo->ops->set_promisc_mode(h,
519 promisc_flags & HNAE3_UPE, 519 promisc_flags & HNAE3_UPE,
520 promisc_flags & HNAE3_MPE); 520 promisc_flags & HNAE3_MPE);
521 } 521 }
522
523 return 0;
522} 524}
523 525
524void hns3_enable_vlan_filter(struct net_device *netdev, bool enable) 526void hns3_enable_vlan_filter(struct net_device *netdev, bool enable)
@@ -1494,18 +1496,22 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev,
1494 return ret; 1496 return ret;
1495} 1497}
1496 1498
1497static void hns3_restore_vlan(struct net_device *netdev) 1499static int hns3_restore_vlan(struct net_device *netdev)
1498{ 1500{
1499 struct hns3_nic_priv *priv = netdev_priv(netdev); 1501 struct hns3_nic_priv *priv = netdev_priv(netdev);
1502 int ret = 0;
1500 u16 vid; 1503 u16 vid;
1501 int ret;
1502 1504
1503 for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) { 1505 for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) {
1504 ret = hns3_vlan_rx_add_vid(netdev, htons(ETH_P_8021Q), vid); 1506 ret = hns3_vlan_rx_add_vid(netdev, htons(ETH_P_8021Q), vid);
1505 if (ret) 1507 if (ret) {
1506 netdev_warn(netdev, "Restore vlan: %d filter, ret:%d\n", 1508 netdev_err(netdev, "Restore vlan: %d filter, ret:%d\n",
1507 vid, ret); 1509 vid, ret);
1510 return ret;
1511 }
1508 } 1512 }
1513
1514 return ret;
1509} 1515}
1510 1516
1511static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, 1517static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
@@ -2727,7 +2733,7 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
2727 chain = devm_kzalloc(&pdev->dev, sizeof(*chain), 2733 chain = devm_kzalloc(&pdev->dev, sizeof(*chain),
2728 GFP_KERNEL); 2734 GFP_KERNEL);
2729 if (!chain) 2735 if (!chain)
2730 return -ENOMEM; 2736 goto err_free_chain;
2731 2737
2732 cur_chain->next = chain; 2738 cur_chain->next = chain;
2733 chain->tqp_index = tx_ring->tqp->tqp_index; 2739 chain->tqp_index = tx_ring->tqp->tqp_index;
@@ -2757,7 +2763,7 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
2757 while (rx_ring) { 2763 while (rx_ring) {
2758 chain = devm_kzalloc(&pdev->dev, sizeof(*chain), GFP_KERNEL); 2764 chain = devm_kzalloc(&pdev->dev, sizeof(*chain), GFP_KERNEL);
2759 if (!chain) 2765 if (!chain)
2760 return -ENOMEM; 2766 goto err_free_chain;
2761 2767
2762 cur_chain->next = chain; 2768 cur_chain->next = chain;
2763 chain->tqp_index = rx_ring->tqp->tqp_index; 2769 chain->tqp_index = rx_ring->tqp->tqp_index;
@@ -2772,6 +2778,16 @@ static int hns3_get_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
2772 } 2778 }
2773 2779
2774 return 0; 2780 return 0;
2781
2782err_free_chain:
2783 cur_chain = head->next;
2784 while (cur_chain) {
2785 chain = cur_chain->next;
2786 devm_kfree(&pdev->dev, chain);
2787 cur_chain = chain;
2788 }
2789
2790 return -ENOMEM;
2775} 2791}
2776 2792
2777static void hns3_free_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector, 2793static void hns3_free_vector_ring_chain(struct hns3_enet_tqp_vector *tqp_vector,
@@ -2821,7 +2837,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
2821 struct hnae3_handle *h = priv->ae_handle; 2837 struct hnae3_handle *h = priv->ae_handle;
2822 struct hns3_enet_tqp_vector *tqp_vector; 2838 struct hns3_enet_tqp_vector *tqp_vector;
2823 int ret = 0; 2839 int ret = 0;
2824 u16 i; 2840 int i;
2825 2841
2826 hns3_nic_set_cpumask(priv); 2842 hns3_nic_set_cpumask(priv);
2827 2843
@@ -2868,13 +2884,19 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
2868 hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain); 2884 hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain);
2869 2885
2870 if (ret) 2886 if (ret)
2871 return ret; 2887 goto map_ring_fail;
2872 2888
2873 netif_napi_add(priv->netdev, &tqp_vector->napi, 2889 netif_napi_add(priv->netdev, &tqp_vector->napi,
2874 hns3_nic_common_poll, NAPI_POLL_WEIGHT); 2890 hns3_nic_common_poll, NAPI_POLL_WEIGHT);
2875 } 2891 }
2876 2892
2877 return 0; 2893 return 0;
2894
2895map_ring_fail:
2896 while (i--)
2897 netif_napi_del(&priv->tqp_vector[i].napi);
2898
2899 return ret;
2878} 2900}
2879 2901
2880static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) 2902static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)
@@ -3031,8 +3053,10 @@ static int hns3_queue_to_ring(struct hnae3_queue *tqp,
3031 return ret; 3053 return ret;
3032 3054
3033 ret = hns3_ring_get_cfg(tqp, priv, HNAE3_RING_TYPE_RX); 3055 ret = hns3_ring_get_cfg(tqp, priv, HNAE3_RING_TYPE_RX);
3034 if (ret) 3056 if (ret) {
3057 devm_kfree(priv->dev, priv->ring_data[tqp->tqp_index].ring);
3035 return ret; 3058 return ret;
3059 }
3036 3060
3037 return 0; 3061 return 0;
3038} 3062}
@@ -3059,6 +3083,12 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv)
3059 3083
3060 return 0; 3084 return 0;
3061err: 3085err:
3086 while (i--) {
3087 devm_kfree(priv->dev, priv->ring_data[i].ring);
3088 devm_kfree(priv->dev,
3089 priv->ring_data[i + h->kinfo.num_tqps].ring);
3090 }
3091
3062 devm_kfree(&pdev->dev, priv->ring_data); 3092 devm_kfree(&pdev->dev, priv->ring_data);
3063 return ret; 3093 return ret;
3064} 3094}
@@ -3226,9 +3256,6 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv)
3226 int i; 3256 int i;
3227 3257
3228 for (i = 0; i < h->kinfo.num_tqps; i++) { 3258 for (i = 0; i < h->kinfo.num_tqps; i++) {
3229 if (h->ae_algo->ops->reset_queue)
3230 h->ae_algo->ops->reset_queue(h, i);
3231
3232 hns3_fini_ring(priv->ring_data[i].ring); 3259 hns3_fini_ring(priv->ring_data[i].ring);
3233 hns3_fini_ring(priv->ring_data[i + h->kinfo.num_tqps].ring); 3260 hns3_fini_ring(priv->ring_data[i + h->kinfo.num_tqps].ring);
3234 } 3261 }
@@ -3236,11 +3263,12 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv)
3236} 3263}
3237 3264
3238/* Set mac addr if it is configured. or leave it to the AE driver */ 3265/* Set mac addr if it is configured. or leave it to the AE driver */
3239static void hns3_init_mac_addr(struct net_device *netdev, bool init) 3266static int hns3_init_mac_addr(struct net_device *netdev, bool init)
3240{ 3267{
3241 struct hns3_nic_priv *priv = netdev_priv(netdev); 3268 struct hns3_nic_priv *priv = netdev_priv(netdev);
3242 struct hnae3_handle *h = priv->ae_handle; 3269 struct hnae3_handle *h = priv->ae_handle;
3243 u8 mac_addr_temp[ETH_ALEN]; 3270 u8 mac_addr_temp[ETH_ALEN];
3271 int ret = 0;
3244 3272
3245 if (h->ae_algo->ops->get_mac_addr && init) { 3273 if (h->ae_algo->ops->get_mac_addr && init) {
3246 h->ae_algo->ops->get_mac_addr(h, mac_addr_temp); 3274 h->ae_algo->ops->get_mac_addr(h, mac_addr_temp);
@@ -3255,8 +3283,9 @@ static void hns3_init_mac_addr(struct net_device *netdev, bool init)
3255 } 3283 }
3256 3284
3257 if (h->ae_algo->ops->set_mac_addr) 3285 if (h->ae_algo->ops->set_mac_addr)
3258 h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr, true); 3286 ret = h->ae_algo->ops->set_mac_addr(h, netdev->dev_addr, true);
3259 3287
3288 return ret;
3260} 3289}
3261 3290
3262static int hns3_restore_fd_rules(struct net_device *netdev) 3291static int hns3_restore_fd_rules(struct net_device *netdev)
@@ -3469,20 +3498,29 @@ err_out:
3469 return ret; 3498 return ret;
3470} 3499}
3471 3500
3472static void hns3_recover_hw_addr(struct net_device *ndev) 3501static int hns3_recover_hw_addr(struct net_device *ndev)
3473{ 3502{
3474 struct netdev_hw_addr_list *list; 3503 struct netdev_hw_addr_list *list;
3475 struct netdev_hw_addr *ha, *tmp; 3504 struct netdev_hw_addr *ha, *tmp;
3505 int ret = 0;
3476 3506
3477 /* go through and sync uc_addr entries to the device */ 3507 /* go through and sync uc_addr entries to the device */
3478 list = &ndev->uc; 3508 list = &ndev->uc;
3479 list_for_each_entry_safe(ha, tmp, &list->list, list) 3509 list_for_each_entry_safe(ha, tmp, &list->list, list) {
3480 hns3_nic_uc_sync(ndev, ha->addr); 3510 ret = hns3_nic_uc_sync(ndev, ha->addr);
3511 if (ret)
3512 return ret;
3513 }
3481 3514
3482 /* go through and sync mc_addr entries to the device */ 3515 /* go through and sync mc_addr entries to the device */
3483 list = &ndev->mc; 3516 list = &ndev->mc;
3484 list_for_each_entry_safe(ha, tmp, &list->list, list) 3517 list_for_each_entry_safe(ha, tmp, &list->list, list) {
3485 hns3_nic_mc_sync(ndev, ha->addr); 3518 ret = hns3_nic_mc_sync(ndev, ha->addr);
3519 if (ret)
3520 return ret;
3521 }
3522
3523 return ret;
3486} 3524}
3487 3525
3488static void hns3_remove_hw_addr(struct net_device *netdev) 3526static void hns3_remove_hw_addr(struct net_device *netdev)
@@ -3609,7 +3647,10 @@ int hns3_nic_reset_all_ring(struct hnae3_handle *h)
3609 int ret; 3647 int ret;
3610 3648
3611 for (i = 0; i < h->kinfo.num_tqps; i++) { 3649 for (i = 0; i < h->kinfo.num_tqps; i++) {
3612 h->ae_algo->ops->reset_queue(h, i); 3650 ret = h->ae_algo->ops->reset_queue(h, i);
3651 if (ret)
3652 return ret;
3653
3613 hns3_init_ring_hw(priv->ring_data[i].ring); 3654 hns3_init_ring_hw(priv->ring_data[i].ring);
3614 3655
3615 /* We need to clear tx ring here because self test will 3656 /* We need to clear tx ring here because self test will
@@ -3701,18 +3742,30 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
3701 bool vlan_filter_enable; 3742 bool vlan_filter_enable;
3702 int ret; 3743 int ret;
3703 3744
3704 hns3_init_mac_addr(netdev, false); 3745 ret = hns3_init_mac_addr(netdev, false);
3705 hns3_recover_hw_addr(netdev); 3746 if (ret)
3706 hns3_update_promisc_mode(netdev, handle->netdev_flags); 3747 return ret;
3748
3749 ret = hns3_recover_hw_addr(netdev);
3750 if (ret)
3751 return ret;
3752
3753 ret = hns3_update_promisc_mode(netdev, handle->netdev_flags);
3754 if (ret)
3755 return ret;
3756
3707 vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true; 3757 vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true;
3708 hns3_enable_vlan_filter(netdev, vlan_filter_enable); 3758 hns3_enable_vlan_filter(netdev, vlan_filter_enable);
3709 3759
3710
3711 /* Hardware table is only clear when pf resets */ 3760 /* Hardware table is only clear when pf resets */
3712 if (!(handle->flags & HNAE3_SUPPORT_VF)) 3761 if (!(handle->flags & HNAE3_SUPPORT_VF)) {
3713 hns3_restore_vlan(netdev); 3762 ret = hns3_restore_vlan(netdev);
3763 return ret;
3764 }
3714 3765
3715 hns3_restore_fd_rules(netdev); 3766 ret = hns3_restore_fd_rules(netdev);
3767 if (ret)
3768 return ret;
3716 3769
3717 /* Carrier off reporting is important to ethtool even BEFORE open */ 3770 /* Carrier off reporting is important to ethtool even BEFORE open */
3718 netif_carrier_off(netdev); 3771 netif_carrier_off(netdev);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index 71cfca132d0b..d3636d088aa3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -640,7 +640,7 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector,
640 u32 rl_value); 640 u32 rl_value);
641 641
642void hns3_enable_vlan_filter(struct net_device *netdev, bool enable); 642void hns3_enable_vlan_filter(struct net_device *netdev, bool enable);
643void hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags); 643int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags);
644 644
645#ifdef CONFIG_HNS3_DCB 645#ifdef CONFIG_HNS3_DCB
646void hns3_dcbnl_setup(struct hnae3_handle *handle); 646void hns3_dcbnl_setup(struct hnae3_handle *handle);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
index ac13cb2b168e..690f62ed87dc 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
@@ -24,15 +24,15 @@ static int hclge_ring_space(struct hclge_cmq_ring *ring)
24 return ring->desc_num - used - 1; 24 return ring->desc_num - used - 1;
25} 25}
26 26
27static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int h) 27static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int head)
28{ 28{
29 int u = ring->next_to_use; 29 int ntu = ring->next_to_use;
30 int c = ring->next_to_clean; 30 int ntc = ring->next_to_clean;
31 31
32 if (unlikely(h >= ring->desc_num)) 32 if (ntu > ntc)
33 return 0; 33 return head >= ntc && head <= ntu;
34 34
35 return u > c ? (h > c && h <= u) : (h > c || h <= u); 35 return head >= ntc || head <= ntu;
36} 36}
37 37
38static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring) 38static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring)
@@ -304,6 +304,10 @@ int hclge_cmd_queue_init(struct hclge_dev *hdev)
304{ 304{
305 int ret; 305 int ret;
306 306
307 /* Setup the lock for command queue */
308 spin_lock_init(&hdev->hw.cmq.csq.lock);
309 spin_lock_init(&hdev->hw.cmq.crq.lock);
310
307 /* Setup the queue entries for use cmd queue */ 311 /* Setup the queue entries for use cmd queue */
308 hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; 312 hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;
309 hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; 313 hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;
@@ -337,18 +341,20 @@ int hclge_cmd_init(struct hclge_dev *hdev)
337 u32 version; 341 u32 version;
338 int ret; 342 int ret;
339 343
344 spin_lock_bh(&hdev->hw.cmq.csq.lock);
345 spin_lock_bh(&hdev->hw.cmq.crq.lock);
346
340 hdev->hw.cmq.csq.next_to_clean = 0; 347 hdev->hw.cmq.csq.next_to_clean = 0;
341 hdev->hw.cmq.csq.next_to_use = 0; 348 hdev->hw.cmq.csq.next_to_use = 0;
342 hdev->hw.cmq.crq.next_to_clean = 0; 349 hdev->hw.cmq.crq.next_to_clean = 0;
343 hdev->hw.cmq.crq.next_to_use = 0; 350 hdev->hw.cmq.crq.next_to_use = 0;
344 351
345 /* Setup the lock for command queue */
346 spin_lock_init(&hdev->hw.cmq.csq.lock);
347 spin_lock_init(&hdev->hw.cmq.crq.lock);
348
349 hclge_cmd_init_regs(&hdev->hw); 352 hclge_cmd_init_regs(&hdev->hw);
350 clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); 353 clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
351 354
355 spin_unlock_bh(&hdev->hw.cmq.crq.lock);
356 spin_unlock_bh(&hdev->hw.cmq.csq.lock);
357
352 ret = hclge_cmd_query_firmware_version(&hdev->hw, &version); 358 ret = hclge_cmd_query_firmware_version(&hdev->hw, &version);
353 if (ret) { 359 if (ret) {
354 dev_err(&hdev->pdev->dev, 360 dev_err(&hdev->pdev->dev,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
index dca6f2326c26..123c37e653f3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
@@ -751,7 +751,7 @@ static void hclge_process_ncsi_error(struct hclge_dev *hdev,
751 ret = hclge_cmd_clear_error(hdev, &desc_wr, &desc_rd, 751 ret = hclge_cmd_clear_error(hdev, &desc_wr, &desc_rd,
752 HCLGE_NCSI_INT_CLR, 0); 752 HCLGE_NCSI_INT_CLR, 0);
753 if (ret) 753 if (ret)
754 dev_err(dev, "failed(=%d) to clear NCSI intrerrupt status\n", 754 dev_err(dev, "failed(=%d) to clear NCSI interrupt status\n",
755 ret); 755 ret);
756} 756}
757 757
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 5234b5373ed3..ffdd96020860 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2236,7 +2236,7 @@ static irqreturn_t hclge_misc_irq_handle(int irq, void *data)
2236 } 2236 }
2237 2237
2238 /* clear the source of interrupt if it is not cause by reset */ 2238 /* clear the source of interrupt if it is not cause by reset */
2239 if (event_cause != HCLGE_VECTOR0_EVENT_RST) { 2239 if (event_cause == HCLGE_VECTOR0_EVENT_MBX) {
2240 hclge_clear_event_cause(hdev, event_cause, clearval); 2240 hclge_clear_event_cause(hdev, event_cause, clearval);
2241 hclge_enable_vector(&hdev->misc_vector, true); 2241 hclge_enable_vector(&hdev->misc_vector, true);
2242 } 2242 }
@@ -2470,14 +2470,17 @@ static void hclge_reset(struct hclge_dev *hdev)
2470 handle = &hdev->vport[0].nic; 2470 handle = &hdev->vport[0].nic;
2471 rtnl_lock(); 2471 rtnl_lock();
2472 hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); 2472 hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
2473 rtnl_unlock();
2473 2474
2474 if (!hclge_reset_wait(hdev)) { 2475 if (!hclge_reset_wait(hdev)) {
2476 rtnl_lock();
2475 hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT); 2477 hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT);
2476 hclge_reset_ae_dev(hdev->ae_dev); 2478 hclge_reset_ae_dev(hdev->ae_dev);
2477 hclge_notify_client(hdev, HNAE3_INIT_CLIENT); 2479 hclge_notify_client(hdev, HNAE3_INIT_CLIENT);
2478 2480
2479 hclge_clear_reset_cause(hdev); 2481 hclge_clear_reset_cause(hdev);
2480 } else { 2482 } else {
2483 rtnl_lock();
2481 /* schedule again to check pending resets later */ 2484 /* schedule again to check pending resets later */
2482 set_bit(hdev->reset_type, &hdev->reset_pending); 2485 set_bit(hdev->reset_type, &hdev->reset_pending);
2483 hclge_reset_task_schedule(hdev); 2486 hclge_reset_task_schedule(hdev);
@@ -3314,8 +3317,8 @@ void hclge_promisc_param_init(struct hclge_promisc_param *param, bool en_uc,
3314 param->vf_id = vport_id; 3317 param->vf_id = vport_id;
3315} 3318}
3316 3319
3317static void hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc, 3320static int hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc,
3318 bool en_mc_pmc) 3321 bool en_mc_pmc)
3319{ 3322{
3320 struct hclge_vport *vport = hclge_get_vport(handle); 3323 struct hclge_vport *vport = hclge_get_vport(handle);
3321 struct hclge_dev *hdev = vport->back; 3324 struct hclge_dev *hdev = vport->back;
@@ -3323,7 +3326,7 @@ static void hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc,
3323 3326
3324 hclge_promisc_param_init(&param, en_uc_pmc, en_mc_pmc, true, 3327 hclge_promisc_param_init(&param, en_uc_pmc, en_mc_pmc, true,
3325 vport->vport_id); 3328 vport->vport_id);
3326 hclge_cmd_set_promisc_mode(hdev, &param); 3329 return hclge_cmd_set_promisc_mode(hdev, &param);
3327} 3330}
3328 3331
3329static int hclge_get_fd_mode(struct hclge_dev *hdev, u8 *fd_mode) 3332static int hclge_get_fd_mode(struct hclge_dev *hdev, u8 *fd_mode)
@@ -6107,31 +6110,28 @@ static u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle,
6107 return tqp->index; 6110 return tqp->index;
6108} 6111}
6109 6112
6110void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id) 6113int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
6111{ 6114{
6112 struct hclge_vport *vport = hclge_get_vport(handle); 6115 struct hclge_vport *vport = hclge_get_vport(handle);
6113 struct hclge_dev *hdev = vport->back; 6116 struct hclge_dev *hdev = vport->back;
6114 int reset_try_times = 0; 6117 int reset_try_times = 0;
6115 int reset_status; 6118 int reset_status;
6116 u16 queue_gid; 6119 u16 queue_gid;
6117 int ret; 6120 int ret = 0;
6118
6119 if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
6120 return;
6121 6121
6122 queue_gid = hclge_covert_handle_qid_global(handle, queue_id); 6122 queue_gid = hclge_covert_handle_qid_global(handle, queue_id);
6123 6123
6124 ret = hclge_tqp_enable(hdev, queue_id, 0, false); 6124 ret = hclge_tqp_enable(hdev, queue_id, 0, false);
6125 if (ret) { 6125 if (ret) {
6126 dev_warn(&hdev->pdev->dev, "Disable tqp fail, ret = %d\n", ret); 6126 dev_err(&hdev->pdev->dev, "Disable tqp fail, ret = %d\n", ret);
6127 return; 6127 return ret;
6128 } 6128 }
6129 6129
6130 ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true); 6130 ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true);
6131 if (ret) { 6131 if (ret) {
6132 dev_warn(&hdev->pdev->dev, 6132 dev_err(&hdev->pdev->dev,
6133 "Send reset tqp cmd fail, ret = %d\n", ret); 6133 "Send reset tqp cmd fail, ret = %d\n", ret);
6134 return; 6134 return ret;
6135 } 6135 }
6136 6136
6137 reset_try_times = 0; 6137 reset_try_times = 0;
@@ -6144,16 +6144,16 @@ void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
6144 } 6144 }
6145 6145
6146 if (reset_try_times >= HCLGE_TQP_RESET_TRY_TIMES) { 6146 if (reset_try_times >= HCLGE_TQP_RESET_TRY_TIMES) {
6147 dev_warn(&hdev->pdev->dev, "Reset TQP fail\n"); 6147 dev_err(&hdev->pdev->dev, "Reset TQP fail\n");
6148 return; 6148 return ret;
6149 } 6149 }
6150 6150
6151 ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, false); 6151 ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, false);
6152 if (ret) { 6152 if (ret)
6153 dev_warn(&hdev->pdev->dev, 6153 dev_err(&hdev->pdev->dev,
6154 "Deassert the soft reset fail, ret = %d\n", ret); 6154 "Deassert the soft reset fail, ret = %d\n", ret);
6155 return; 6155
6156 } 6156 return ret;
6157} 6157}
6158 6158
6159void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id) 6159void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index e3dfd654eca9..0d9215404269 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -778,7 +778,7 @@ int hclge_rss_init_hw(struct hclge_dev *hdev);
778void hclge_rss_indir_init_cfg(struct hclge_dev *hdev); 778void hclge_rss_indir_init_cfg(struct hclge_dev *hdev);
779 779
780void hclge_mbx_handler(struct hclge_dev *hdev); 780void hclge_mbx_handler(struct hclge_dev *hdev);
781void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id); 781int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id);
782void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id); 782void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id);
783int hclge_cfg_flowctrl(struct hclge_dev *hdev); 783int hclge_cfg_flowctrl(struct hclge_dev *hdev);
784int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id); 784int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
index 04462a347a94..f890022938d9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
@@ -400,6 +400,12 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
400 400
401 /* handle all the mailbox requests in the queue */ 401 /* handle all the mailbox requests in the queue */
402 while (!hclge_cmd_crq_empty(&hdev->hw)) { 402 while (!hclge_cmd_crq_empty(&hdev->hw)) {
403 if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) {
404 dev_warn(&hdev->pdev->dev,
405 "command queue needs re-initializing\n");
406 return;
407 }
408
403 desc = &crq->desc[crq->next_to_use]; 409 desc = &crq->desc[crq->next_to_use];
404 req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data; 410 req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data;
405 411
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index 24b1f2a0c32a..03018638f701 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -52,7 +52,7 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum,
52 struct hclge_desc desc; 52 struct hclge_desc desc;
53 int ret; 53 int ret;
54 54
55 if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) 55 if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state))
56 return 0; 56 return 0;
57 57
58 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false); 58 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false);
@@ -90,7 +90,7 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, int regnum)
90 struct hclge_desc desc; 90 struct hclge_desc desc;
91 int ret; 91 int ret;
92 92
93 if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) 93 if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state))
94 return 0; 94 return 0;
95 95
96 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true); 96 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index e0a86a58342c..085edb945389 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -925,12 +925,12 @@ static int hclgevf_cmd_set_promisc_mode(struct hclgevf_dev *hdev,
925 return status; 925 return status;
926} 926}
927 927
928static void hclgevf_set_promisc_mode(struct hnae3_handle *handle, 928static int hclgevf_set_promisc_mode(struct hnae3_handle *handle,
929 bool en_uc_pmc, bool en_mc_pmc) 929 bool en_uc_pmc, bool en_mc_pmc)
930{ 930{
931 struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); 931 struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
932 932
933 hclgevf_cmd_set_promisc_mode(hdev, en_uc_pmc, en_mc_pmc); 933 return hclgevf_cmd_set_promisc_mode(hdev, en_uc_pmc, en_mc_pmc);
934} 934}
935 935
936static int hclgevf_tqp_enable(struct hclgevf_dev *hdev, int tqp_id, 936static int hclgevf_tqp_enable(struct hclgevf_dev *hdev, int tqp_id,
@@ -1080,7 +1080,7 @@ static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
1080 1, false, NULL, 0); 1080 1, false, NULL, 0);
1081} 1081}
1082 1082
1083static void hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id) 1083static int hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
1084{ 1084{
1085 struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); 1085 struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
1086 u8 msg_data[2]; 1086 u8 msg_data[2];
@@ -1091,10 +1091,10 @@ static void hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
1091 /* disable vf queue before send queue reset msg to PF */ 1091 /* disable vf queue before send queue reset msg to PF */
1092 ret = hclgevf_tqp_enable(hdev, queue_id, 0, false); 1092 ret = hclgevf_tqp_enable(hdev, queue_id, 0, false);
1093 if (ret) 1093 if (ret)
1094 return; 1094 return ret;
1095 1095
1096 hclgevf_send_mbx_msg(hdev, HCLGE_MBX_QUEUE_RESET, 0, msg_data, 1096 return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_QUEUE_RESET, 0, msg_data,
1097 2, true, NULL, 0); 1097 2, true, NULL, 0);
1098} 1098}
1099 1099
1100static int hclgevf_notify_client(struct hclgevf_dev *hdev, 1100static int hclgevf_notify_client(struct hclgevf_dev *hdev,
@@ -1170,6 +1170,8 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
1170 /* bring down the nic to stop any ongoing TX/RX */ 1170 /* bring down the nic to stop any ongoing TX/RX */
1171 hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT); 1171 hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
1172 1172
1173 rtnl_unlock();
1174
1173 /* check if VF could successfully fetch the hardware reset completion 1175 /* check if VF could successfully fetch the hardware reset completion
1174 * status from the hardware 1176 * status from the hardware
1175 */ 1177 */
@@ -1181,12 +1183,15 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
1181 ret); 1183 ret);
1182 1184
1183 dev_warn(&hdev->pdev->dev, "VF reset failed, disabling VF!\n"); 1185 dev_warn(&hdev->pdev->dev, "VF reset failed, disabling VF!\n");
1186 rtnl_lock();
1184 hclgevf_notify_client(hdev, HNAE3_UNINIT_CLIENT); 1187 hclgevf_notify_client(hdev, HNAE3_UNINIT_CLIENT);
1185 1188
1186 rtnl_unlock(); 1189 rtnl_unlock();
1187 return ret; 1190 return ret;
1188 } 1191 }
1189 1192
1193 rtnl_lock();
1194
1190 /* now, re-initialize the nic client and ae device*/ 1195 /* now, re-initialize the nic client and ae device*/
1191 ret = hclgevf_reset_stack(hdev); 1196 ret = hclgevf_reset_stack(hdev);
1192 if (ret) 1197 if (ret)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c
index 967c993d5303..bbf9bdd0ee3e 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.c
@@ -532,7 +532,7 @@ void hinic_task_set_inner_l3(struct hinic_sq_task *task,
532} 532}
533 533
534void hinic_task_set_tunnel_l4(struct hinic_sq_task *task, 534void hinic_task_set_tunnel_l4(struct hinic_sq_task *task,
535 enum hinic_l4_offload_type l4_type, 535 enum hinic_l4_tunnel_type l4_type,
536 u32 tunnel_len) 536 u32 tunnel_len)
537{ 537{
538 task->pkt_info2 |= HINIC_SQ_TASK_INFO2_SET(l4_type, TUNNEL_L4TYPE) | 538 task->pkt_info2 |= HINIC_SQ_TASK_INFO2_SET(l4_type, TUNNEL_L4TYPE) |
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h
index a0dc63a4bfc7..038522e202b6 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_qp.h
@@ -160,7 +160,7 @@ void hinic_task_set_inner_l3(struct hinic_sq_task *task,
160 u32 network_len); 160 u32 network_len);
161 161
162void hinic_task_set_tunnel_l4(struct hinic_sq_task *task, 162void hinic_task_set_tunnel_l4(struct hinic_sq_task *task,
163 enum hinic_l4_offload_type l4_type, 163 enum hinic_l4_tunnel_type l4_type,
164 u32 tunnel_len); 164 u32 tunnel_len);
165 165
166void hinic_set_cs_inner_l4(struct hinic_sq_task *task, 166void hinic_set_cs_inner_l4(struct hinic_sq_task *task,
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
index fd3373d82a9e..59e1bc0f609e 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -200,6 +200,15 @@ config IXGBE_DCB
200 200
201 If unsure, say N. 201 If unsure, say N.
202 202
203config IXGBE_IPSEC
204 bool "IPSec XFRM cryptography-offload acceleration"
205 depends on IXGBE
206 depends on XFRM_OFFLOAD
207 default y
208 select XFRM_ALGO
209 ---help---
210 Enable support for IPSec offload in ixgbe.ko
211
203config IXGBEVF 212config IXGBEVF
204 tristate "Intel(R) 10GbE PCI Express Virtual Function Ethernet support" 213 tristate "Intel(R) 10GbE PCI Express Virtual Function Ethernet support"
205 depends on PCI_MSI 214 depends on PCI_MSI
@@ -217,6 +226,15 @@ config IXGBEVF
217 will be called ixgbevf. MSI-X interrupt support is required 226 will be called ixgbevf. MSI-X interrupt support is required
218 for this driver to work correctly. 227 for this driver to work correctly.
219 228
229config IXGBEVF_IPSEC
230 bool "IPSec XFRM cryptography-offload acceleration"
231 depends on IXGBEVF
232 depends on XFRM_OFFLOAD
233 default y
234 select XFRM_ALGO
235 ---help---
236 Enable support for IPSec offload in ixgbevf.ko
237
220config I40E 238config I40E
221 tristate "Intel(R) Ethernet Controller XL710 Family support" 239 tristate "Intel(R) Ethernet Controller XL710 Family support"
222 imply PTP_1588_CLOCK 240 imply PTP_1588_CLOCK
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_iov.c b/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
index e707d717012f..5d4f1761dc0c 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
@@ -244,7 +244,8 @@ process_mbx:
244 } 244 }
245 245
246 /* guarantee we have free space in the SM mailbox */ 246 /* guarantee we have free space in the SM mailbox */
247 if (!hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU)) { 247 if (hw->mbx.state == FM10K_STATE_OPEN &&
248 !hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU)) {
248 /* keep track of how many times this occurs */ 249 /* keep track of how many times this occurs */
249 interface->hw_sm_mbx_full++; 250 interface->hw_sm_mbx_full++;
250 251
@@ -302,6 +303,28 @@ void fm10k_iov_suspend(struct pci_dev *pdev)
302 } 303 }
303} 304}
304 305
306static void fm10k_mask_aer_comp_abort(struct pci_dev *pdev)
307{
308 u32 err_mask;
309 int pos;
310
311 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
312 if (!pos)
313 return;
314
315 /* Mask the completion abort bit in the ERR_UNCOR_MASK register,
316 * preventing the device from reporting these errors to the upstream
317 * PCIe root device. This avoids bringing down platforms which upgrade
318 * non-fatal completer aborts into machine check exceptions. Completer
319 * aborts can occur whenever a VF reads a queue it doesn't own.
320 */
321 pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_MASK, &err_mask);
322 err_mask |= PCI_ERR_UNC_COMP_ABORT;
323 pci_write_config_dword(pdev, pos + PCI_ERR_UNCOR_MASK, err_mask);
324
325 mmiowb();
326}
327
305int fm10k_iov_resume(struct pci_dev *pdev) 328int fm10k_iov_resume(struct pci_dev *pdev)
306{ 329{
307 struct fm10k_intfc *interface = pci_get_drvdata(pdev); 330 struct fm10k_intfc *interface = pci_get_drvdata(pdev);
@@ -317,6 +340,12 @@ int fm10k_iov_resume(struct pci_dev *pdev)
317 if (!iov_data) 340 if (!iov_data)
318 return -ENOMEM; 341 return -ENOMEM;
319 342
343 /* Lower severity of completer abort error reporting as
344 * the VFs can trigger this any time they read a queue
345 * that they don't own.
346 */
347 fm10k_mask_aer_comp_abort(pdev);
348
320 /* allocate hardware resources for the VFs */ 349 /* allocate hardware resources for the VFs */
321 hw->iov.ops.assign_resources(hw, num_vfs, num_vfs); 350 hw->iov.ops.assign_resources(hw, num_vfs, num_vfs);
322 351
@@ -460,20 +489,6 @@ void fm10k_iov_disable(struct pci_dev *pdev)
460 fm10k_iov_free_data(pdev); 489 fm10k_iov_free_data(pdev);
461} 490}
462 491
463static void fm10k_disable_aer_comp_abort(struct pci_dev *pdev)
464{
465 u32 err_sev;
466 int pos;
467
468 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
469 if (!pos)
470 return;
471
472 pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_SEVER, &err_sev);
473 err_sev &= ~PCI_ERR_UNC_COMP_ABORT;
474 pci_write_config_dword(pdev, pos + PCI_ERR_UNCOR_SEVER, err_sev);
475}
476
477int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs) 492int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs)
478{ 493{
479 int current_vfs = pci_num_vf(pdev); 494 int current_vfs = pci_num_vf(pdev);
@@ -495,12 +510,6 @@ int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs)
495 510
496 /* allocate VFs if not already allocated */ 511 /* allocate VFs if not already allocated */
497 if (num_vfs && num_vfs != current_vfs) { 512 if (num_vfs && num_vfs != current_vfs) {
498 /* Disable completer abort error reporting as
499 * the VFs can trigger this any time they read a queue
500 * that they don't own.
501 */
502 fm10k_disable_aer_comp_abort(pdev);
503
504 err = pci_enable_sriov(pdev, num_vfs); 513 err = pci_enable_sriov(pdev, num_vfs);
505 if (err) { 514 if (err) {
506 dev_err(&pdev->dev, 515 dev_err(&pdev->dev,
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index 503bbc017792..5b2a50e5798f 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -11,7 +11,7 @@
11 11
12#include "fm10k.h" 12#include "fm10k.h"
13 13
14#define DRV_VERSION "0.23.4-k" 14#define DRV_VERSION "0.26.1-k"
15#define DRV_SUMMARY "Intel(R) Ethernet Switch Host Interface Driver" 15#define DRV_SUMMARY "Intel(R) Ethernet Switch Host Interface Driver"
16const char fm10k_driver_version[] = DRV_VERSION; 16const char fm10k_driver_version[] = DRV_VERSION;
17char fm10k_driver_name[] = "fm10k"; 17char fm10k_driver_name[] = "fm10k";
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
index 02345d381303..e49fb51d3613 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
@@ -23,6 +23,8 @@ static const struct fm10k_info *fm10k_info_tbl[] = {
23 */ 23 */
24static const struct pci_device_id fm10k_pci_tbl[] = { 24static const struct pci_device_id fm10k_pci_tbl[] = {
25 { PCI_VDEVICE(INTEL, FM10K_DEV_ID_PF), fm10k_device_pf }, 25 { PCI_VDEVICE(INTEL, FM10K_DEV_ID_PF), fm10k_device_pf },
26 { PCI_VDEVICE(INTEL, FM10K_DEV_ID_SDI_FM10420_QDA2), fm10k_device_pf },
27 { PCI_VDEVICE(INTEL, FM10K_DEV_ID_SDI_FM10420_DA2), fm10k_device_pf },
26 { PCI_VDEVICE(INTEL, FM10K_DEV_ID_VF), fm10k_device_vf }, 28 { PCI_VDEVICE(INTEL, FM10K_DEV_ID_VF), fm10k_device_vf },
27 /* required last entry */ 29 /* required last entry */
28 { 0, } 30 { 0, }
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_type.h b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
index 3e608e493f9d..9fb9fca375e3 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_type.h
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
@@ -15,6 +15,8 @@ struct fm10k_hw;
15 15
16#define FM10K_DEV_ID_PF 0x15A4 16#define FM10K_DEV_ID_PF 0x15A4
17#define FM10K_DEV_ID_VF 0x15A5 17#define FM10K_DEV_ID_VF 0x15A5
18#define FM10K_DEV_ID_SDI_FM10420_QDA2 0x15D0
19#define FM10K_DEV_ID_SDI_FM10420_DA2 0x15D5
18 20
19#define FM10K_MAX_QUEUES 256 21#define FM10K_MAX_QUEUES 256
20#define FM10K_MAX_QUEUES_PF 128 22#define FM10K_MAX_QUEUES_PF 128
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 81b0e1f8d14b..ac5698ed0b11 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -3674,7 +3674,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
3674 dev_err(&pf->pdev->dev, "Invalid message from VF %d, opcode %d, len %d\n", 3674 dev_err(&pf->pdev->dev, "Invalid message from VF %d, opcode %d, len %d\n",
3675 local_vf_id, v_opcode, msglen); 3675 local_vf_id, v_opcode, msglen);
3676 switch (ret) { 3676 switch (ret) {
3677 case VIRTCHNL_ERR_PARAM: 3677 case VIRTCHNL_STATUS_ERR_PARAM:
3678 return -EPERM; 3678 return -EPERM;
3679 default: 3679 default:
3680 return -EINVAL; 3680 return -EINVAL;
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 9f4d700e09df..29ced6b74d36 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -51,9 +51,15 @@
51 * 51 *
52 * The 40 bit 82580 SYSTIM overflows every 52 * The 40 bit 82580 SYSTIM overflows every
53 * 2^40 * 10^-9 / 60 = 18.3 minutes. 53 * 2^40 * 10^-9 / 60 = 18.3 minutes.
54 *
55 * SYSTIM is converted to real time using a timecounter. As
56 * timecounter_cyc2time() allows old timestamps, the timecounter
57 * needs to be updated at least once per half of the SYSTIM interval.
58 * Scheduling of delayed work is not very accurate, so we aim for 8
59 * minutes to be sure the actual interval is shorter than 9.16 minutes.
54 */ 60 */
55 61
56#define IGB_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 9) 62#define IGB_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 8)
57#define IGB_PTP_TX_TIMEOUT (HZ * 15) 63#define IGB_PTP_TX_TIMEOUT (HZ * 15)
58#define INCPERIOD_82576 BIT(E1000_TIMINCA_16NS_SHIFT) 64#define INCPERIOD_82576 BIT(E1000_TIMINCA_16NS_SHIFT)
59#define INCVALUE_82576_MASK GENMASK(E1000_TIMINCA_16NS_SHIFT - 1, 0) 65#define INCVALUE_82576_MASK GENMASK(E1000_TIMINCA_16NS_SHIFT - 1, 0)
diff --git a/drivers/net/ethernet/intel/ixgbe/Makefile b/drivers/net/ethernet/intel/ixgbe/Makefile
index ca6b0c458e4a..4fb0d9e3f2da 100644
--- a/drivers/net/ethernet/intel/ixgbe/Makefile
+++ b/drivers/net/ethernet/intel/ixgbe/Makefile
@@ -17,4 +17,4 @@ ixgbe-$(CONFIG_IXGBE_DCB) += ixgbe_dcb.o ixgbe_dcb_82598.o \
17ixgbe-$(CONFIG_IXGBE_HWMON) += ixgbe_sysfs.o 17ixgbe-$(CONFIG_IXGBE_HWMON) += ixgbe_sysfs.o
18ixgbe-$(CONFIG_DEBUG_FS) += ixgbe_debugfs.o 18ixgbe-$(CONFIG_DEBUG_FS) += ixgbe_debugfs.o
19ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o 19ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o
20ixgbe-$(CONFIG_XFRM_OFFLOAD) += ixgbe_ipsec.o 20ixgbe-$(CONFIG_IXGBE_IPSEC) += ixgbe_ipsec.o
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index ec1b87cc4410..143bdd5ee2a0 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -769,9 +769,9 @@ struct ixgbe_adapter {
769#define IXGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */ 769#define IXGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */
770 u32 *rss_key; 770 u32 *rss_key;
771 771
772#ifdef CONFIG_XFRM_OFFLOAD 772#ifdef CONFIG_IXGBE_IPSEC
773 struct ixgbe_ipsec *ipsec; 773 struct ixgbe_ipsec *ipsec;
774#endif /* CONFIG_XFRM_OFFLOAD */ 774#endif /* CONFIG_IXGBE_IPSEC */
775 775
776 /* AF_XDP zero-copy */ 776 /* AF_XDP zero-copy */
777 struct xdp_umem **xsk_umems; 777 struct xdp_umem **xsk_umems;
@@ -1008,7 +1008,7 @@ void ixgbe_store_key(struct ixgbe_adapter *adapter);
1008void ixgbe_store_reta(struct ixgbe_adapter *adapter); 1008void ixgbe_store_reta(struct ixgbe_adapter *adapter);
1009s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg, 1009s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
1010 u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm); 1010 u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);
1011#ifdef CONFIG_XFRM_OFFLOAD 1011#ifdef CONFIG_IXGBE_IPSEC
1012void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter); 1012void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter);
1013void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter); 1013void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter);
1014void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter); 1014void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter);
@@ -1036,5 +1036,5 @@ static inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter,
1036 u32 *mbuf, u32 vf) { return -EACCES; } 1036 u32 *mbuf, u32 vf) { return -EACCES; }
1037static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, 1037static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter,
1038 u32 *mbuf, u32 vf) { return -EACCES; } 1038 u32 *mbuf, u32 vf) { return -EACCES; }
1039#endif /* CONFIG_XFRM_OFFLOAD */ 1039#endif /* CONFIG_IXGBE_IPSEC */
1040#endif /* _IXGBE_H_ */ 1040#endif /* _IXGBE_H_ */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 0049a2becd7e..113b38e0defb 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -8694,7 +8694,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
8694 8694
8695#endif /* IXGBE_FCOE */ 8695#endif /* IXGBE_FCOE */
8696 8696
8697#ifdef CONFIG_XFRM_OFFLOAD 8697#ifdef CONFIG_IXGBE_IPSEC
8698 if (skb->sp && !ixgbe_ipsec_tx(tx_ring, first, &ipsec_tx)) 8698 if (skb->sp && !ixgbe_ipsec_tx(tx_ring, first, &ipsec_tx))
8699 goto out_drop; 8699 goto out_drop;
8700#endif 8700#endif
@@ -10190,7 +10190,7 @@ ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
10190 * the TSO, so it's the exception. 10190 * the TSO, so it's the exception.
10191 */ 10191 */
10192 if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) { 10192 if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) {
10193#ifdef CONFIG_XFRM_OFFLOAD 10193#ifdef CONFIG_IXGBE_IPSEC
10194 if (!skb->sp) 10194 if (!skb->sp)
10195#endif 10195#endif
10196 features &= ~NETIF_F_TSO; 10196 features &= ~NETIF_F_TSO;
@@ -10883,7 +10883,7 @@ skip_sriov:
10883 if (hw->mac.type >= ixgbe_mac_82599EB) 10883 if (hw->mac.type >= ixgbe_mac_82599EB)
10884 netdev->features |= NETIF_F_SCTP_CRC; 10884 netdev->features |= NETIF_F_SCTP_CRC;
10885 10885
10886#ifdef CONFIG_XFRM_OFFLOAD 10886#ifdef CONFIG_IXGBE_IPSEC
10887#define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \ 10887#define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \
10888 NETIF_F_HW_ESP_TX_CSUM | \ 10888 NETIF_F_HW_ESP_TX_CSUM | \
10889 NETIF_F_GSO_ESP) 10889 NETIF_F_GSO_ESP)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index af25a8fffeb8..5dacfc870259 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -722,8 +722,10 @@ static inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)
722 ixgbe_set_vmvir(adapter, vfinfo->pf_vlan, 722 ixgbe_set_vmvir(adapter, vfinfo->pf_vlan,
723 adapter->default_up, vf); 723 adapter->default_up, vf);
724 724
725 if (vfinfo->spoofchk_enabled) 725 if (vfinfo->spoofchk_enabled) {
726 hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf); 726 hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf);
727 hw->mac.ops.set_mac_anti_spoofing(hw, true, vf);
728 }
727 } 729 }
728 730
729 /* reset multicast table array for vf */ 731 /* reset multicast table array for vf */
diff --git a/drivers/net/ethernet/intel/ixgbevf/Makefile b/drivers/net/ethernet/intel/ixgbevf/Makefile
index 297d0f0858b5..186a4bb24fde 100644
--- a/drivers/net/ethernet/intel/ixgbevf/Makefile
+++ b/drivers/net/ethernet/intel/ixgbevf/Makefile
@@ -10,5 +10,5 @@ ixgbevf-objs := vf.o \
10 mbx.o \ 10 mbx.o \
11 ethtool.o \ 11 ethtool.o \
12 ixgbevf_main.o 12 ixgbevf_main.o
13ixgbevf-$(CONFIG_XFRM_OFFLOAD) += ipsec.o 13ixgbevf-$(CONFIG_IXGBEVF_IPSEC) += ipsec.o
14 14
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index e399e1c0c54a..ecab686574b6 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -459,7 +459,7 @@ int ethtool_ioctl(struct ifreq *ifr);
459 459
460extern void ixgbevf_write_eitr(struct ixgbevf_q_vector *q_vector); 460extern void ixgbevf_write_eitr(struct ixgbevf_q_vector *q_vector);
461 461
462#ifdef CONFIG_XFRM_OFFLOAD 462#ifdef CONFIG_IXGBEVF_IPSEC
463void ixgbevf_init_ipsec_offload(struct ixgbevf_adapter *adapter); 463void ixgbevf_init_ipsec_offload(struct ixgbevf_adapter *adapter);
464void ixgbevf_stop_ipsec_offload(struct ixgbevf_adapter *adapter); 464void ixgbevf_stop_ipsec_offload(struct ixgbevf_adapter *adapter);
465void ixgbevf_ipsec_restore(struct ixgbevf_adapter *adapter); 465void ixgbevf_ipsec_restore(struct ixgbevf_adapter *adapter);
@@ -482,7 +482,7 @@ static inline int ixgbevf_ipsec_tx(struct ixgbevf_ring *tx_ring,
482 struct ixgbevf_tx_buffer *first, 482 struct ixgbevf_tx_buffer *first,
483 struct ixgbevf_ipsec_tx_data *itd) 483 struct ixgbevf_ipsec_tx_data *itd)
484{ return 0; } 484{ return 0; }
485#endif /* CONFIG_XFRM_OFFLOAD */ 485#endif /* CONFIG_IXGBEVF_IPSEC */
486 486
487void ixgbe_napi_add_all(struct ixgbevf_adapter *adapter); 487void ixgbe_napi_add_all(struct ixgbevf_adapter *adapter);
488void ixgbe_napi_del_all(struct ixgbevf_adapter *adapter); 488void ixgbe_napi_del_all(struct ixgbevf_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 98707ee11d72..5e47ede7e832 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -4150,7 +4150,7 @@ static int ixgbevf_xmit_frame_ring(struct sk_buff *skb,
4150 first->tx_flags = tx_flags; 4150 first->tx_flags = tx_flags;
4151 first->protocol = vlan_get_protocol(skb); 4151 first->protocol = vlan_get_protocol(skb);
4152 4152
4153#ifdef CONFIG_XFRM_OFFLOAD 4153#ifdef CONFIG_IXGBEVF_IPSEC
4154 if (skb->sp && !ixgbevf_ipsec_tx(tx_ring, first, &ipsec_tx)) 4154 if (skb->sp && !ixgbevf_ipsec_tx(tx_ring, first, &ipsec_tx))
4155 goto out_drop; 4155 goto out_drop;
4156#endif 4156#endif
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
index 176c6b56fdcc..398328f10743 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
@@ -796,6 +796,7 @@ struct mvpp2_queue_vector {
796 int nrxqs; 796 int nrxqs;
797 u32 pending_cause_rx; 797 u32 pending_cause_rx;
798 struct mvpp2_port *port; 798 struct mvpp2_port *port;
799 struct cpumask *mask;
799}; 800};
800 801
801struct mvpp2_port { 802struct mvpp2_port {
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 14f9679c957c..7a37a37e3fb3 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -3298,24 +3298,30 @@ static int mvpp2_irqs_init(struct mvpp2_port *port)
3298 for (i = 0; i < port->nqvecs; i++) { 3298 for (i = 0; i < port->nqvecs; i++) {
3299 struct mvpp2_queue_vector *qv = port->qvecs + i; 3299 struct mvpp2_queue_vector *qv = port->qvecs + i;
3300 3300
3301 if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE) 3301 if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE) {
3302 qv->mask = kzalloc(cpumask_size(), GFP_KERNEL);
3303 if (!qv->mask) {
3304 err = -ENOMEM;
3305 goto err;
3306 }
3307
3302 irq_set_status_flags(qv->irq, IRQ_NO_BALANCING); 3308 irq_set_status_flags(qv->irq, IRQ_NO_BALANCING);
3309 }
3303 3310
3304 err = request_irq(qv->irq, mvpp2_isr, 0, port->dev->name, qv); 3311 err = request_irq(qv->irq, mvpp2_isr, 0, port->dev->name, qv);
3305 if (err) 3312 if (err)
3306 goto err; 3313 goto err;
3307 3314
3308 if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE) { 3315 if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE) {
3309 unsigned long mask = 0;
3310 unsigned int cpu; 3316 unsigned int cpu;
3311 3317
3312 for_each_present_cpu(cpu) { 3318 for_each_present_cpu(cpu) {
3313 if (mvpp2_cpu_to_thread(port->priv, cpu) == 3319 if (mvpp2_cpu_to_thread(port->priv, cpu) ==
3314 qv->sw_thread_id) 3320 qv->sw_thread_id)
3315 mask |= BIT(cpu); 3321 cpumask_set_cpu(cpu, qv->mask);
3316 } 3322 }
3317 3323
3318 irq_set_affinity_hint(qv->irq, to_cpumask(&mask)); 3324 irq_set_affinity_hint(qv->irq, qv->mask);
3319 } 3325 }
3320 } 3326 }
3321 3327
@@ -3325,6 +3331,8 @@ err:
3325 struct mvpp2_queue_vector *qv = port->qvecs + i; 3331 struct mvpp2_queue_vector *qv = port->qvecs + i;
3326 3332
3327 irq_set_affinity_hint(qv->irq, NULL); 3333 irq_set_affinity_hint(qv->irq, NULL);
3334 kfree(qv->mask);
3335 qv->mask = NULL;
3328 free_irq(qv->irq, qv); 3336 free_irq(qv->irq, qv);
3329 } 3337 }
3330 3338
@@ -3339,6 +3347,8 @@ static void mvpp2_irqs_deinit(struct mvpp2_port *port)
3339 struct mvpp2_queue_vector *qv = port->qvecs + i; 3347 struct mvpp2_queue_vector *qv = port->qvecs + i;
3340 3348
3341 irq_set_affinity_hint(qv->irq, NULL); 3349 irq_set_affinity_hint(qv->irq, NULL);
3350 kfree(qv->mask);
3351 qv->mask = NULL;
3342 irq_clear_status_flags(qv->irq, IRQ_NO_BALANCING); 3352 irq_clear_status_flags(qv->irq, IRQ_NO_BALANCING);
3343 free_irq(qv->irq, qv); 3353 free_irq(qv->irq, qv);
3344 } 3354 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 5a6d0919533d..db00bf1c23f5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -43,6 +43,7 @@
43#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
44#include <linux/irq.h> 44#include <linux/irq.h>
45 45
46#include <net/ip.h>
46#if IS_ENABLED(CONFIG_IPV6) 47#if IS_ENABLED(CONFIG_IPV6)
47#include <net/ip6_checksum.h> 48#include <net/ip6_checksum.h>
48#endif 49#endif
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 94224c22ecc3..79638dcbae78 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -713,43 +713,15 @@ static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb)
713 rq->stats->ecn_mark += !!rc; 713 rq->stats->ecn_mark += !!rc;
714} 714}
715 715
716static __be32 mlx5e_get_fcs(struct sk_buff *skb) 716static u32 mlx5e_get_fcs(const struct sk_buff *skb)
717{ 717{
718 int last_frag_sz, bytes_in_prev, nr_frags; 718 const void *fcs_bytes;
719 u8 *fcs_p1, *fcs_p2; 719 u32 _fcs_bytes;
720 skb_frag_t *last_frag;
721 __be32 fcs_bytes;
722 720
723 if (!skb_is_nonlinear(skb)) 721 fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
724 return *(__be32 *)(skb->data + skb->len - ETH_FCS_LEN); 722 ETH_FCS_LEN, &_fcs_bytes);
725 723
726 nr_frags = skb_shinfo(skb)->nr_frags; 724 return __get_unaligned_cpu32(fcs_bytes);
727 last_frag = &skb_shinfo(skb)->frags[nr_frags - 1];
728 last_frag_sz = skb_frag_size(last_frag);
729
730 /* If all FCS data is in last frag */
731 if (last_frag_sz >= ETH_FCS_LEN)
732 return *(__be32 *)(skb_frag_address(last_frag) +
733 last_frag_sz - ETH_FCS_LEN);
734
735 fcs_p2 = (u8 *)skb_frag_address(last_frag);
736 bytes_in_prev = ETH_FCS_LEN - last_frag_sz;
737
738 /* Find where the other part of the FCS is - Linear or another frag */
739 if (nr_frags == 1) {
740 fcs_p1 = skb_tail_pointer(skb);
741 } else {
742 skb_frag_t *prev_frag = &skb_shinfo(skb)->frags[nr_frags - 2];
743
744 fcs_p1 = skb_frag_address(prev_frag) +
745 skb_frag_size(prev_frag);
746 }
747 fcs_p1 -= bytes_in_prev;
748
749 memcpy(&fcs_bytes, fcs_p1, bytes_in_prev);
750 memcpy(((u8 *)&fcs_bytes) + bytes_in_prev, fcs_p2, last_frag_sz);
751
752 return fcs_bytes;
753} 725}
754 726
755static u8 get_ip_proto(struct sk_buff *skb, __be16 proto) 727static u8 get_ip_proto(struct sk_buff *skb, __be16 proto)
@@ -797,8 +769,9 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
797 network_depth - ETH_HLEN, 769 network_depth - ETH_HLEN,
798 skb->csum); 770 skb->csum);
799 if (unlikely(netdev->features & NETIF_F_RXFCS)) 771 if (unlikely(netdev->features & NETIF_F_RXFCS))
800 skb->csum = csum_add(skb->csum, 772 skb->csum = csum_block_add(skb->csum,
801 (__force __wsum)mlx5e_get_fcs(skb)); 773 (__force __wsum)mlx5e_get_fcs(skb),
774 skb->len - ETH_FCS_LEN);
802 stats->csum_complete++; 775 stats->csum_complete++;
803 return; 776 return;
804 } 777 }
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 937d0ace699a..30f751e69698 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -943,8 +943,8 @@ static int mlxsw_devlink_core_bus_device_reload(struct devlink *devlink,
943 mlxsw_core->bus, 943 mlxsw_core->bus,
944 mlxsw_core->bus_priv, true, 944 mlxsw_core->bus_priv, true,
945 devlink); 945 devlink);
946 if (err) 946 mlxsw_core->reload_fail = !!err;
947 mlxsw_core->reload_fail = true; 947
948 return err; 948 return err;
949} 949}
950 950
@@ -1083,8 +1083,15 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
1083{ 1083{
1084 struct devlink *devlink = priv_to_devlink(mlxsw_core); 1084 struct devlink *devlink = priv_to_devlink(mlxsw_core);
1085 1085
1086 if (mlxsw_core->reload_fail) 1086 if (mlxsw_core->reload_fail) {
1087 goto reload_fail; 1087 if (!reload)
1088 /* Only the parts that were not de-initialized in the
1089 * failed reload attempt need to be de-initialized.
1090 */
1091 goto reload_fail_deinit;
1092 else
1093 return;
1094 }
1088 1095
1089 if (mlxsw_core->driver->fini) 1096 if (mlxsw_core->driver->fini)
1090 mlxsw_core->driver->fini(mlxsw_core); 1097 mlxsw_core->driver->fini(mlxsw_core);
@@ -1098,9 +1105,12 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
1098 if (!reload) 1105 if (!reload)
1099 devlink_resources_unregister(devlink, NULL); 1106 devlink_resources_unregister(devlink, NULL);
1100 mlxsw_core->bus->fini(mlxsw_core->bus_priv); 1107 mlxsw_core->bus->fini(mlxsw_core->bus_priv);
1101 if (reload) 1108
1102 return; 1109 return;
1103reload_fail: 1110
1111reload_fail_deinit:
1112 devlink_unregister(devlink);
1113 devlink_resources_unregister(devlink, NULL);
1104 devlink_free(devlink); 1114 devlink_free(devlink);
1105} 1115}
1106EXPORT_SYMBOL(mlxsw_core_bus_device_unregister); 1116EXPORT_SYMBOL(mlxsw_core_bus_device_unregister);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 32cb6718bb17..db3d2790aeec 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -3284,7 +3284,7 @@ static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3284 * Configures the ETS elements. 3284 * Configures the ETS elements.
3285 */ 3285 */
3286#define MLXSW_REG_QEEC_ID 0x400D 3286#define MLXSW_REG_QEEC_ID 0x400D
3287#define MLXSW_REG_QEEC_LEN 0x1C 3287#define MLXSW_REG_QEEC_LEN 0x20
3288 3288
3289MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN); 3289MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
3290 3290
@@ -3326,6 +3326,15 @@ MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3326 */ 3326 */
3327MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8); 3327MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3328 3328
3329/* reg_qeec_mise
3330 * Min shaper configuration enable. Enables configuration of the min
3331 * shaper on this ETS element
3332 * 0 - Disable
3333 * 1 - Enable
3334 * Access: RW
3335 */
3336MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
3337
3329enum { 3338enum {
3330 MLXSW_REG_QEEC_BYTES_MODE, 3339 MLXSW_REG_QEEC_BYTES_MODE,
3331 MLXSW_REG_QEEC_PACKETS_MODE, 3340 MLXSW_REG_QEEC_PACKETS_MODE,
@@ -3342,6 +3351,17 @@ enum {
3342 */ 3351 */
3343MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1); 3352MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3344 3353
3354/* The smallest permitted min shaper rate. */
3355#define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
3356
3357/* reg_qeec_min_shaper_rate
3358 * Min shaper information rate.
3359 * For CPU port, can only be configured for port hierarchy.
3360 * When in bytes mode, value is specified in units of 1000bps.
3361 * Access: RW
3362 */
3363MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
3364
3345/* reg_qeec_mase 3365/* reg_qeec_mase
3346 * Max shaper configuration enable. Enables configuration of the max 3366 * Max shaper configuration enable. Enables configuration of the max
3347 * shaper on this ETS element. 3367 * shaper on this ETS element.
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 8a4983adae94..a2df12b79f8e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -2740,6 +2740,21 @@ int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
2740 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); 2740 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl);
2741} 2741}
2742 2742
2743static int mlxsw_sp_port_min_bw_set(struct mlxsw_sp_port *mlxsw_sp_port,
2744 enum mlxsw_reg_qeec_hr hr, u8 index,
2745 u8 next_index, u32 minrate)
2746{
2747 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
2748 char qeec_pl[MLXSW_REG_QEEC_LEN];
2749
2750 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index,
2751 next_index);
2752 mlxsw_reg_qeec_mise_set(qeec_pl, true);
2753 mlxsw_reg_qeec_min_shaper_rate_set(qeec_pl, minrate);
2754
2755 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl);
2756}
2757
2743int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, 2758int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
2744 u8 switch_prio, u8 tclass) 2759 u8 switch_prio, u8 tclass)
2745{ 2760{
@@ -2817,6 +2832,16 @@ static int mlxsw_sp_port_ets_init(struct mlxsw_sp_port *mlxsw_sp_port)
2817 return err; 2832 return err;
2818 } 2833 }
2819 2834
2835 /* Configure the min shaper for multicast TCs. */
2836 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
2837 err = mlxsw_sp_port_min_bw_set(mlxsw_sp_port,
2838 MLXSW_REG_QEEC_HIERARCY_TC,
2839 i + 8, i,
2840 MLXSW_REG_QEEC_MIS_MIN);
2841 if (err)
2842 return err;
2843 }
2844
2820 /* Map all priorities to traffic class 0. */ 2845 /* Map all priorities to traffic class 0. */
2821 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 2846 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
2822 err = mlxsw_sp_port_prio_tc_set(mlxsw_sp_port, i, 0); 2847 err = mlxsw_sp_port_prio_tc_set(mlxsw_sp_port, i, 0);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index bc60d7a8b49d..739a51f0a366 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -2661,8 +2661,6 @@ static void mlxsw_sp_switchdev_bridge_fdb_event_work(struct work_struct *work)
2661 break; 2661 break;
2662 case SWITCHDEV_FDB_DEL_TO_DEVICE: 2662 case SWITCHDEV_FDB_DEL_TO_DEVICE:
2663 fdb_info = &switchdev_work->fdb_info; 2663 fdb_info = &switchdev_work->fdb_info;
2664 if (!fdb_info->added_by_user)
2665 break;
2666 mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, false); 2664 mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, false);
2667 break; 2665 break;
2668 case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */ 2666 case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index b72ef171477e..bdd351597b55 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -243,7 +243,7 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
243 */ 243 */
244int stmmac_mdio_reset(struct mii_bus *bus) 244int stmmac_mdio_reset(struct mii_bus *bus)
245{ 245{
246#if defined(CONFIG_STMMAC_PLATFORM) 246#if IS_ENABLED(CONFIG_STMMAC_PLATFORM)
247 struct net_device *ndev = bus->priv; 247 struct net_device *ndev = bus->priv;
248 struct stmmac_priv *priv = netdev_priv(ndev); 248 struct stmmac_priv *priv = netdev_priv(ndev);
249 unsigned int mii_address = priv->hw->mii.addr; 249 unsigned int mii_address = priv->hw->mii.addr;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index f52008bb8df7..3a5f81a66d34 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -30,6 +30,7 @@
30#include <linux/sched/mm.h> 30#include <linux/sched/mm.h>
31#include <linux/sched/signal.h> 31#include <linux/sched/signal.h>
32#include <linux/interval_tree_generic.h> 32#include <linux/interval_tree_generic.h>
33#include <linux/nospec.h>
33 34
34#include "vhost.h" 35#include "vhost.h"
35 36
@@ -1387,6 +1388,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg
1387 if (idx >= d->nvqs) 1388 if (idx >= d->nvqs)
1388 return -ENOBUFS; 1389 return -ENOBUFS;
1389 1390
1391 idx = array_index_nospec(idx, d->nvqs);
1390 vq = d->vqs[idx]; 1392 vq = d->vqs[idx];
1391 1393
1392 mutex_lock(&vq->mutex); 1394 mutex_lock(&vq->mutex);
diff --git a/include/linux/avf/virtchnl.h b/include/linux/avf/virtchnl.h
index 2c9756bd9c4c..b2488055fd1d 100644
--- a/include/linux/avf/virtchnl.h
+++ b/include/linux/avf/virtchnl.h
@@ -62,13 +62,19 @@
62/* Error Codes */ 62/* Error Codes */
63enum virtchnl_status_code { 63enum virtchnl_status_code {
64 VIRTCHNL_STATUS_SUCCESS = 0, 64 VIRTCHNL_STATUS_SUCCESS = 0,
65 VIRTCHNL_ERR_PARAM = -5, 65 VIRTCHNL_STATUS_ERR_PARAM = -5,
66 VIRTCHNL_STATUS_ERR_NO_MEMORY = -18,
66 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38, 67 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
67 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39, 68 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
68 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40, 69 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
69 VIRTCHNL_STATUS_NOT_SUPPORTED = -64, 70 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53,
71 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64,
70}; 72};
71 73
74/* Backward compatibility */
75#define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
76#define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
77
72#define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1 78#define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
73#define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2 79#define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
74#define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3 80#define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
@@ -831,7 +837,7 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
831 case VIRTCHNL_OP_EVENT: 837 case VIRTCHNL_OP_EVENT:
832 case VIRTCHNL_OP_UNKNOWN: 838 case VIRTCHNL_OP_UNKNOWN:
833 default: 839 default:
834 return VIRTCHNL_ERR_PARAM; 840 return VIRTCHNL_STATUS_ERR_PARAM;
835 } 841 }
836 /* few more checks */ 842 /* few more checks */
837 if (err_msg_format || valid_len != msglen) 843 if (err_msg_format || valid_len != msglen)
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 9e8056ec20fa..d93e89761a8b 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -51,6 +51,9 @@ struct bpf_reg_state {
51 * PTR_TO_MAP_VALUE_OR_NULL 51 * PTR_TO_MAP_VALUE_OR_NULL
52 */ 52 */
53 struct bpf_map *map_ptr; 53 struct bpf_map *map_ptr;
54
55 /* Max size from any of the above. */
56 unsigned long raw;
54 }; 57 };
55 /* Fixed part of pointer offset, pointer types only */ 58 /* Fixed part of pointer offset, pointer types only */
56 s32 off; 59 s32 off;
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index c759d1cbcedd..a64f21a97369 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -37,7 +37,9 @@ struct in_device {
37 unsigned long mr_v1_seen; 37 unsigned long mr_v1_seen;
38 unsigned long mr_v2_seen; 38 unsigned long mr_v2_seen;
39 unsigned long mr_maxdelay; 39 unsigned long mr_maxdelay;
40 unsigned char mr_qrv; 40 unsigned long mr_qi; /* Query Interval */
41 unsigned long mr_qri; /* Query Response Interval */
42 unsigned char mr_qrv; /* Query Robustness Variable */
41 unsigned char mr_gq_running; 43 unsigned char mr_gq_running;
42 unsigned char mr_ifc_count; 44 unsigned char mr_ifc_count;
43 struct timer_list mr_gq_timer; /* general query timer */ 45 struct timer_list mr_gq_timer; /* general query timer */
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index e2695c4bf358..ddbba838d048 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -13,7 +13,7 @@ void unix_notinflight(struct user_struct *user, struct file *fp);
13void unix_gc(void); 13void unix_gc(void);
14void wait_for_unix_gc(void); 14void wait_for_unix_gc(void);
15struct sock *unix_get_socket(struct file *filp); 15struct sock *unix_get_socket(struct file *filp);
16struct sock *unix_peer_get(struct sock *); 16struct sock *unix_peer_get(struct sock *sk);
17 17
18#define UNIX_HASH_SIZE 256 18#define UNIX_HASH_SIZE 256
19#define UNIX_HASH_BITS 8 19#define UNIX_HASH_BITS 8
@@ -40,7 +40,7 @@ struct unix_skb_parms {
40 u32 consumed; 40 u32 consumed;
41} __randomize_layout; 41} __randomize_layout;
42 42
43#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) 43#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
44 44
45#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock) 45#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
46#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock) 46#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 171a2c88e77d..1971ca325fb4 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2852,10 +2852,6 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn
2852 regs[BPF_REG_0].type = NOT_INIT; 2852 regs[BPF_REG_0].type = NOT_INIT;
2853 } else if (fn->ret_type == RET_PTR_TO_MAP_VALUE_OR_NULL || 2853 } else if (fn->ret_type == RET_PTR_TO_MAP_VALUE_OR_NULL ||
2854 fn->ret_type == RET_PTR_TO_MAP_VALUE) { 2854 fn->ret_type == RET_PTR_TO_MAP_VALUE) {
2855 if (fn->ret_type == RET_PTR_TO_MAP_VALUE)
2856 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE;
2857 else
2858 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL;
2859 /* There is no offset yet applied, variable or fixed */ 2855 /* There is no offset yet applied, variable or fixed */
2860 mark_reg_known_zero(env, regs, BPF_REG_0); 2856 mark_reg_known_zero(env, regs, BPF_REG_0);
2861 /* remember map_ptr, so that check_map_access() 2857 /* remember map_ptr, so that check_map_access()
@@ -2868,7 +2864,12 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn
2868 return -EINVAL; 2864 return -EINVAL;
2869 } 2865 }
2870 regs[BPF_REG_0].map_ptr = meta.map_ptr; 2866 regs[BPF_REG_0].map_ptr = meta.map_ptr;
2871 regs[BPF_REG_0].id = ++env->id_gen; 2867 if (fn->ret_type == RET_PTR_TO_MAP_VALUE) {
2868 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE;
2869 } else {
2870 regs[BPF_REG_0].type = PTR_TO_MAP_VALUE_OR_NULL;
2871 regs[BPF_REG_0].id = ++env->id_gen;
2872 }
2872 } else if (fn->ret_type == RET_PTR_TO_SOCKET_OR_NULL) { 2873 } else if (fn->ret_type == RET_PTR_TO_SOCKET_OR_NULL) {
2873 int id = acquire_reference_state(env, insn_idx); 2874 int id = acquire_reference_state(env, insn_idx);
2874 if (id < 0) 2875 if (id < 0)
@@ -3046,7 +3047,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
3046 dst_reg->umax_value = umax_ptr; 3047 dst_reg->umax_value = umax_ptr;
3047 dst_reg->var_off = ptr_reg->var_off; 3048 dst_reg->var_off = ptr_reg->var_off;
3048 dst_reg->off = ptr_reg->off + smin_val; 3049 dst_reg->off = ptr_reg->off + smin_val;
3049 dst_reg->range = ptr_reg->range; 3050 dst_reg->raw = ptr_reg->raw;
3050 break; 3051 break;
3051 } 3052 }
3052 /* A new variable offset is created. Note that off_reg->off 3053 /* A new variable offset is created. Note that off_reg->off
@@ -3076,10 +3077,11 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
3076 } 3077 }
3077 dst_reg->var_off = tnum_add(ptr_reg->var_off, off_reg->var_off); 3078 dst_reg->var_off = tnum_add(ptr_reg->var_off, off_reg->var_off);
3078 dst_reg->off = ptr_reg->off; 3079 dst_reg->off = ptr_reg->off;
3080 dst_reg->raw = ptr_reg->raw;
3079 if (reg_is_pkt_pointer(ptr_reg)) { 3081 if (reg_is_pkt_pointer(ptr_reg)) {
3080 dst_reg->id = ++env->id_gen; 3082 dst_reg->id = ++env->id_gen;
3081 /* something was added to pkt_ptr, set range to zero */ 3083 /* something was added to pkt_ptr, set range to zero */
3082 dst_reg->range = 0; 3084 dst_reg->raw = 0;
3083 } 3085 }
3084 break; 3086 break;
3085 case BPF_SUB: 3087 case BPF_SUB:
@@ -3108,7 +3110,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
3108 dst_reg->var_off = ptr_reg->var_off; 3110 dst_reg->var_off = ptr_reg->var_off;
3109 dst_reg->id = ptr_reg->id; 3111 dst_reg->id = ptr_reg->id;
3110 dst_reg->off = ptr_reg->off - smin_val; 3112 dst_reg->off = ptr_reg->off - smin_val;
3111 dst_reg->range = ptr_reg->range; 3113 dst_reg->raw = ptr_reg->raw;
3112 break; 3114 break;
3113 } 3115 }
3114 /* A new variable offset is created. If the subtrahend is known 3116 /* A new variable offset is created. If the subtrahend is known
@@ -3134,11 +3136,12 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
3134 } 3136 }
3135 dst_reg->var_off = tnum_sub(ptr_reg->var_off, off_reg->var_off); 3137 dst_reg->var_off = tnum_sub(ptr_reg->var_off, off_reg->var_off);
3136 dst_reg->off = ptr_reg->off; 3138 dst_reg->off = ptr_reg->off;
3139 dst_reg->raw = ptr_reg->raw;
3137 if (reg_is_pkt_pointer(ptr_reg)) { 3140 if (reg_is_pkt_pointer(ptr_reg)) {
3138 dst_reg->id = ++env->id_gen; 3141 dst_reg->id = ++env->id_gen;
3139 /* something was added to pkt_ptr, set range to zero */ 3142 /* something was added to pkt_ptr, set range to zero */
3140 if (smin_val < 0) 3143 if (smin_val < 0)
3141 dst_reg->range = 0; 3144 dst_reg->raw = 0;
3142 } 3145 }
3143 break; 3146 break;
3144 case BPF_AND: 3147 case BPF_AND:
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f679c7a7d761..e01274bd5e3e 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3600,6 +3600,11 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
3600 return -EINVAL; 3600 return -EINVAL;
3601 } 3601 }
3602 3602
3603 if (dev->type != ARPHRD_ETHER) {
3604 NL_SET_ERR_MSG(extack, "FDB add only supported for Ethernet devices");
3605 return -EINVAL;
3606 }
3607
3603 addr = nla_data(tb[NDA_LLADDR]); 3608 addr = nla_data(tb[NDA_LLADDR]);
3604 3609
3605 err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack); 3610 err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
@@ -3704,6 +3709,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
3704 return -EINVAL; 3709 return -EINVAL;
3705 } 3710 }
3706 3711
3712 if (dev->type != ARPHRD_ETHER) {
3713 NL_SET_ERR_MSG(extack, "FDB delete only supported for Ethernet devices");
3714 return -EINVAL;
3715 }
3716
3707 addr = nla_data(tb[NDA_LLADDR]); 3717 addr = nla_data(tb[NDA_LLADDR]);
3708 3718
3709 err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack); 3719 err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 4da39446da2d..765b2b32c4a4 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -111,13 +111,10 @@
111#ifdef CONFIG_IP_MULTICAST 111#ifdef CONFIG_IP_MULTICAST
112/* Parameter names and values are taken from igmp-v2-06 draft */ 112/* Parameter names and values are taken from igmp-v2-06 draft */
113 113
114#define IGMP_V1_ROUTER_PRESENT_TIMEOUT (400*HZ)
115#define IGMP_V2_ROUTER_PRESENT_TIMEOUT (400*HZ)
116#define IGMP_V2_UNSOLICITED_REPORT_INTERVAL (10*HZ) 114#define IGMP_V2_UNSOLICITED_REPORT_INTERVAL (10*HZ)
117#define IGMP_V3_UNSOLICITED_REPORT_INTERVAL (1*HZ) 115#define IGMP_V3_UNSOLICITED_REPORT_INTERVAL (1*HZ)
116#define IGMP_QUERY_INTERVAL (125*HZ)
118#define IGMP_QUERY_RESPONSE_INTERVAL (10*HZ) 117#define IGMP_QUERY_RESPONSE_INTERVAL (10*HZ)
119#define IGMP_QUERY_ROBUSTNESS_VARIABLE 2
120
121 118
122#define IGMP_INITIAL_REPORT_DELAY (1) 119#define IGMP_INITIAL_REPORT_DELAY (1)
123 120
@@ -935,13 +932,15 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
935 932
936 max_delay = IGMP_QUERY_RESPONSE_INTERVAL; 933 max_delay = IGMP_QUERY_RESPONSE_INTERVAL;
937 in_dev->mr_v1_seen = jiffies + 934 in_dev->mr_v1_seen = jiffies +
938 IGMP_V1_ROUTER_PRESENT_TIMEOUT; 935 (in_dev->mr_qrv * in_dev->mr_qi) +
936 in_dev->mr_qri;
939 group = 0; 937 group = 0;
940 } else { 938 } else {
941 /* v2 router present */ 939 /* v2 router present */
942 max_delay = ih->code*(HZ/IGMP_TIMER_SCALE); 940 max_delay = ih->code*(HZ/IGMP_TIMER_SCALE);
943 in_dev->mr_v2_seen = jiffies + 941 in_dev->mr_v2_seen = jiffies +
944 IGMP_V2_ROUTER_PRESENT_TIMEOUT; 942 (in_dev->mr_qrv * in_dev->mr_qi) +
943 in_dev->mr_qri;
945 } 944 }
946 /* cancel the interface change timer */ 945 /* cancel the interface change timer */
947 in_dev->mr_ifc_count = 0; 946 in_dev->mr_ifc_count = 0;
@@ -981,8 +980,21 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
981 if (!max_delay) 980 if (!max_delay)
982 max_delay = 1; /* can't mod w/ 0 */ 981 max_delay = 1; /* can't mod w/ 0 */
983 in_dev->mr_maxdelay = max_delay; 982 in_dev->mr_maxdelay = max_delay;
984 if (ih3->qrv) 983
985 in_dev->mr_qrv = ih3->qrv; 984 /* RFC3376, 4.1.6. QRV and 4.1.7. QQIC, when the most recently
985 * received value was zero, use the default or statically
986 * configured value.
987 */
988 in_dev->mr_qrv = ih3->qrv ?: net->ipv4.sysctl_igmp_qrv;
989 in_dev->mr_qi = IGMPV3_QQIC(ih3->qqic)*HZ ?: IGMP_QUERY_INTERVAL;
990
991 /* RFC3376, 8.3. Query Response Interval:
992 * The number of seconds represented by the [Query Response
993 * Interval] must be less than the [Query Interval].
994 */
995 if (in_dev->mr_qri >= in_dev->mr_qi)
996 in_dev->mr_qri = (in_dev->mr_qi/HZ - 1)*HZ;
997
986 if (!group) { /* general query */ 998 if (!group) { /* general query */
987 if (ih3->nsrcs) 999 if (ih3->nsrcs)
988 return true; /* no sources allowed */ 1000 return true; /* no sources allowed */
@@ -1723,18 +1735,30 @@ void ip_mc_down(struct in_device *in_dev)
1723 ip_mc_dec_group(in_dev, IGMP_ALL_HOSTS); 1735 ip_mc_dec_group(in_dev, IGMP_ALL_HOSTS);
1724} 1736}
1725 1737
1726void ip_mc_init_dev(struct in_device *in_dev)
1727{
1728#ifdef CONFIG_IP_MULTICAST 1738#ifdef CONFIG_IP_MULTICAST
1739static void ip_mc_reset(struct in_device *in_dev)
1740{
1729 struct net *net = dev_net(in_dev->dev); 1741 struct net *net = dev_net(in_dev->dev);
1742
1743 in_dev->mr_qi = IGMP_QUERY_INTERVAL;
1744 in_dev->mr_qri = IGMP_QUERY_RESPONSE_INTERVAL;
1745 in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv;
1746}
1747#else
1748static void ip_mc_reset(struct in_device *in_dev)
1749{
1750}
1730#endif 1751#endif
1752
1753void ip_mc_init_dev(struct in_device *in_dev)
1754{
1731 ASSERT_RTNL(); 1755 ASSERT_RTNL();
1732 1756
1733#ifdef CONFIG_IP_MULTICAST 1757#ifdef CONFIG_IP_MULTICAST
1734 timer_setup(&in_dev->mr_gq_timer, igmp_gq_timer_expire, 0); 1758 timer_setup(&in_dev->mr_gq_timer, igmp_gq_timer_expire, 0);
1735 timer_setup(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire, 0); 1759 timer_setup(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire, 0);
1736 in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv;
1737#endif 1760#endif
1761 ip_mc_reset(in_dev);
1738 1762
1739 spin_lock_init(&in_dev->mc_tomb_lock); 1763 spin_lock_init(&in_dev->mc_tomb_lock);
1740} 1764}
@@ -1744,15 +1768,10 @@ void ip_mc_init_dev(struct in_device *in_dev)
1744void ip_mc_up(struct in_device *in_dev) 1768void ip_mc_up(struct in_device *in_dev)
1745{ 1769{
1746 struct ip_mc_list *pmc; 1770 struct ip_mc_list *pmc;
1747#ifdef CONFIG_IP_MULTICAST
1748 struct net *net = dev_net(in_dev->dev);
1749#endif
1750 1771
1751 ASSERT_RTNL(); 1772 ASSERT_RTNL();
1752 1773
1753#ifdef CONFIG_IP_MULTICAST 1774 ip_mc_reset(in_dev);
1754 in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv;
1755#endif
1756 ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); 1775 ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS);
1757 1776
1758 for_each_pmc_rtnl(in_dev, pmc) { 1777 for_each_pmc_rtnl(in_dev, pmc) {
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index b7918d4caa30..3b45fe530f91 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -145,6 +145,7 @@ msg_bytes_ready:
145 ret = err; 145 ret = err;
146 goto out; 146 goto out;
147 } 147 }
148 copied = -EAGAIN;
148 } 149 }
149 ret = copied; 150 ret = copied;
150out: 151out:
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index a70097ecf33c..865ecef68196 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -3030,7 +3030,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
3030 * is already present */ 3030 * is already present */
3031 if (mac_proto != MAC_PROTO_NONE) 3031 if (mac_proto != MAC_PROTO_NONE)
3032 return -EINVAL; 3032 return -EINVAL;
3033 mac_proto = MAC_PROTO_NONE; 3033 mac_proto = MAC_PROTO_ETHERNET;
3034 break; 3034 break;
3035 3035
3036 case OVS_ACTION_ATTR_POP_ETH: 3036 case OVS_ACTION_ATTR_POP_ETH:
@@ -3038,7 +3038,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
3038 return -EINVAL; 3038 return -EINVAL;
3039 if (vlan_tci & htons(VLAN_TAG_PRESENT)) 3039 if (vlan_tci & htons(VLAN_TAG_PRESENT))
3040 return -EINVAL; 3040 return -EINVAL;
3041 mac_proto = MAC_PROTO_ETHERNET; 3041 mac_proto = MAC_PROTO_NONE;
3042 break; 3042 break;
3043 3043
3044 case OVS_ACTION_ATTR_PUSH_NSH: 3044 case OVS_ACTION_ATTR_PUSH_NSH:
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index a827a1f562bf..6a28b96e779e 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -499,8 +499,9 @@ void sctp_assoc_set_primary(struct sctp_association *asoc,
499void sctp_assoc_rm_peer(struct sctp_association *asoc, 499void sctp_assoc_rm_peer(struct sctp_association *asoc,
500 struct sctp_transport *peer) 500 struct sctp_transport *peer)
501{ 501{
502 struct list_head *pos; 502 struct sctp_transport *transport;
503 struct sctp_transport *transport; 503 struct list_head *pos;
504 struct sctp_chunk *ch;
504 505
505 pr_debug("%s: association:%p addr:%pISpc\n", 506 pr_debug("%s: association:%p addr:%pISpc\n",
506 __func__, asoc, &peer->ipaddr.sa); 507 __func__, asoc, &peer->ipaddr.sa);
@@ -564,7 +565,6 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
564 */ 565 */
565 if (!list_empty(&peer->transmitted)) { 566 if (!list_empty(&peer->transmitted)) {
566 struct sctp_transport *active = asoc->peer.active_path; 567 struct sctp_transport *active = asoc->peer.active_path;
567 struct sctp_chunk *ch;
568 568
569 /* Reset the transport of each chunk on this list */ 569 /* Reset the transport of each chunk on this list */
570 list_for_each_entry(ch, &peer->transmitted, 570 list_for_each_entry(ch, &peer->transmitted,
@@ -586,6 +586,10 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
586 sctp_transport_hold(active); 586 sctp_transport_hold(active);
587 } 587 }
588 588
589 list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list)
590 if (ch->transport == peer)
591 ch->transport = NULL;
592
589 asoc->peer.transport_count--; 593 asoc->peer.transport_count--;
590 594
591 sctp_transport_free(peer); 595 sctp_transport_free(peer);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index fc0386e8ff23..739f3e50120d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -7083,14 +7083,15 @@ static int sctp_getsockopt_pr_assocstatus(struct sock *sk, int len,
7083 } 7083 }
7084 7084
7085 policy = params.sprstat_policy; 7085 policy = params.sprstat_policy;
7086 if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL))) 7086 if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)) ||
7087 ((policy & SCTP_PR_SCTP_ALL) && (policy & SCTP_PR_SCTP_MASK)))
7087 goto out; 7088 goto out;
7088 7089
7089 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id); 7090 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
7090 if (!asoc) 7091 if (!asoc)
7091 goto out; 7092 goto out;
7092 7093
7093 if (policy & SCTP_PR_SCTP_ALL) { 7094 if (policy == SCTP_PR_SCTP_ALL) {
7094 params.sprstat_abandoned_unsent = 0; 7095 params.sprstat_abandoned_unsent = 0;
7095 params.sprstat_abandoned_sent = 0; 7096 params.sprstat_abandoned_sent = 0;
7096 for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) { 7097 for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) {
@@ -7142,7 +7143,8 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len,
7142 } 7143 }
7143 7144
7144 policy = params.sprstat_policy; 7145 policy = params.sprstat_policy;
7145 if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL))) 7146 if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)) ||
7147 ((policy & SCTP_PR_SCTP_ALL) && (policy & SCTP_PR_SCTP_MASK)))
7146 goto out; 7148 goto out;
7147 7149
7148 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id); 7150 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
diff --git a/net/xfrm/Kconfig b/net/xfrm/Kconfig
index 4a9ee2d83158..140270a13d54 100644
--- a/net/xfrm/Kconfig
+++ b/net/xfrm/Kconfig
@@ -8,7 +8,6 @@ config XFRM
8 8
9config XFRM_OFFLOAD 9config XFRM_OFFLOAD
10 bool 10 bool
11 depends on XFRM
12 11
13config XFRM_ALGO 12config XFRM_ALGO
14 tristate 13 tristate
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b607be7236d3..d6e62e90e8d4 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -2084,19 +2084,19 @@ void bpf_program__set_expected_attach_type(struct bpf_program *prog,
2084 prog->expected_attach_type = type; 2084 prog->expected_attach_type = type;
2085} 2085}
2086 2086
2087#define BPF_PROG_SEC_IMPL(string, ptype, eatype, atype) \ 2087#define BPF_PROG_SEC_IMPL(string, ptype, eatype, is_attachable, atype) \
2088 { string, sizeof(string) - 1, ptype, eatype, atype } 2088 { string, sizeof(string) - 1, ptype, eatype, is_attachable, atype }
2089 2089
2090/* Programs that can NOT be attached. */ 2090/* Programs that can NOT be attached. */
2091#define BPF_PROG_SEC(string, ptype) BPF_PROG_SEC_IMPL(string, ptype, 0, -EINVAL) 2091#define BPF_PROG_SEC(string, ptype) BPF_PROG_SEC_IMPL(string, ptype, 0, 0, 0)
2092 2092
2093/* Programs that can be attached. */ 2093/* Programs that can be attached. */
2094#define BPF_APROG_SEC(string, ptype, atype) \ 2094#define BPF_APROG_SEC(string, ptype, atype) \
2095 BPF_PROG_SEC_IMPL(string, ptype, 0, atype) 2095 BPF_PROG_SEC_IMPL(string, ptype, 0, 1, atype)
2096 2096
2097/* Programs that must specify expected attach type at load time. */ 2097/* Programs that must specify expected attach type at load time. */
2098#define BPF_EAPROG_SEC(string, ptype, eatype) \ 2098#define BPF_EAPROG_SEC(string, ptype, eatype) \
2099 BPF_PROG_SEC_IMPL(string, ptype, eatype, eatype) 2099 BPF_PROG_SEC_IMPL(string, ptype, eatype, 1, eatype)
2100 2100
2101/* Programs that can be attached but attach type can't be identified by section 2101/* Programs that can be attached but attach type can't be identified by section
2102 * name. Kept for backward compatibility. 2102 * name. Kept for backward compatibility.
@@ -2108,6 +2108,7 @@ static const struct {
2108 size_t len; 2108 size_t len;
2109 enum bpf_prog_type prog_type; 2109 enum bpf_prog_type prog_type;
2110 enum bpf_attach_type expected_attach_type; 2110 enum bpf_attach_type expected_attach_type;
2111 int is_attachable;
2111 enum bpf_attach_type attach_type; 2112 enum bpf_attach_type attach_type;
2112} section_names[] = { 2113} section_names[] = {
2113 BPF_PROG_SEC("socket", BPF_PROG_TYPE_SOCKET_FILTER), 2114 BPF_PROG_SEC("socket", BPF_PROG_TYPE_SOCKET_FILTER),
@@ -2198,7 +2199,7 @@ int libbpf_attach_type_by_name(const char *name,
2198 for (i = 0; i < ARRAY_SIZE(section_names); i++) { 2199 for (i = 0; i < ARRAY_SIZE(section_names); i++) {
2199 if (strncmp(name, section_names[i].sec, section_names[i].len)) 2200 if (strncmp(name, section_names[i].sec, section_names[i].len))
2200 continue; 2201 continue;
2201 if (section_names[i].attach_type == -EINVAL) 2202 if (!section_names[i].is_attachable)
2202 return -EINVAL; 2203 return -EINVAL;
2203 *attach_type = section_names[i].attach_type; 2204 *attach_type = section_names[i].attach_type;
2204 return 0; 2205 return 0;
diff --git a/tools/testing/selftests/bpf/flow_dissector_load.c b/tools/testing/selftests/bpf/flow_dissector_load.c
index d3273b5b3173..ae8180b11d5f 100644
--- a/tools/testing/selftests/bpf/flow_dissector_load.c
+++ b/tools/testing/selftests/bpf/flow_dissector_load.c
@@ -11,6 +11,8 @@
11#include <bpf/bpf.h> 11#include <bpf/bpf.h>
12#include <bpf/libbpf.h> 12#include <bpf/libbpf.h>
13 13
14#include "bpf_rlimit.h"
15
14const char *cfg_pin_path = "/sys/fs/bpf/flow_dissector"; 16const char *cfg_pin_path = "/sys/fs/bpf/flow_dissector";
15const char *cfg_map_name = "jmp_table"; 17const char *cfg_map_name = "jmp_table";
16bool cfg_attach = true; 18bool cfg_attach = true;
diff --git a/tools/testing/selftests/bpf/test_skb_cgroup_id.sh b/tools/testing/selftests/bpf/test_skb_cgroup_id.sh
index 42544a969abc..a9bc6f82abc1 100755
--- a/tools/testing/selftests/bpf/test_skb_cgroup_id.sh
+++ b/tools/testing/selftests/bpf/test_skb_cgroup_id.sh
@@ -10,7 +10,7 @@ wait_for_ip()
10 echo -n "Wait for testing link-local IP to become available " 10 echo -n "Wait for testing link-local IP to become available "
11 for _i in $(seq ${MAX_PING_TRIES}); do 11 for _i in $(seq ${MAX_PING_TRIES}); do
12 echo -n "." 12 echo -n "."
13 if ping -6 -q -c 1 -W 1 ff02::1%${TEST_IF} >/dev/null 2>&1; then 13 if $PING6 -c 1 -W 1 ff02::1%${TEST_IF} >/dev/null 2>&1; then
14 echo " OK" 14 echo " OK"
15 return 15 return
16 fi 16 fi
@@ -58,5 +58,6 @@ BPF_PROG_OBJ="${DIR}/test_skb_cgroup_id_kern.o"
58BPF_PROG_SECTION="cgroup_id_logger" 58BPF_PROG_SECTION="cgroup_id_logger"
59BPF_PROG_ID=0 59BPF_PROG_ID=0
60PROG="${DIR}/test_skb_cgroup_id_user" 60PROG="${DIR}/test_skb_cgroup_id_user"
61type ping6 >/dev/null 2>&1 && PING6="ping6" || PING6="ping -6"
61 62
62main 63main
diff --git a/tools/testing/selftests/bpf/test_sock_addr.sh b/tools/testing/selftests/bpf/test_sock_addr.sh
index 9832a875a828..3b9fdb8094aa 100755
--- a/tools/testing/selftests/bpf/test_sock_addr.sh
+++ b/tools/testing/selftests/bpf/test_sock_addr.sh
@@ -4,7 +4,8 @@ set -eu
4 4
5ping_once() 5ping_once()
6{ 6{
7 ping -${1} -q -c 1 -W 1 ${2%%/*} >/dev/null 2>&1 7 type ping${1} >/dev/null 2>&1 && PING="ping${1}" || PING="ping -${1}"
8 $PING -q -c 1 -W 1 ${2%%/*} >/dev/null 2>&1
8} 9}
9 10
10wait_for_ip() 11wait_for_ip()
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 36f3d3009d1a..6f61df62f690 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -76,7 +76,7 @@ struct bpf_test {
76 int fixup_percpu_cgroup_storage[MAX_FIXUPS]; 76 int fixup_percpu_cgroup_storage[MAX_FIXUPS];
77 const char *errstr; 77 const char *errstr;
78 const char *errstr_unpriv; 78 const char *errstr_unpriv;
79 uint32_t retval; 79 uint32_t retval, retval_unpriv;
80 enum { 80 enum {
81 UNDEF, 81 UNDEF,
82 ACCEPT, 82 ACCEPT,
@@ -3084,6 +3084,8 @@ static struct bpf_test tests[] = {
3084 .fixup_prog1 = { 2 }, 3084 .fixup_prog1 = { 2 },
3085 .result = ACCEPT, 3085 .result = ACCEPT,
3086 .retval = 42, 3086 .retval = 42,
3087 /* Verifier rewrite for unpriv skips tail call here. */
3088 .retval_unpriv = 2,
3087 }, 3089 },
3088 { 3090 {
3089 "stack pointer arithmetic", 3091 "stack pointer arithmetic",
@@ -6455,6 +6457,256 @@ static struct bpf_test tests[] = {
6455 .prog_type = BPF_PROG_TYPE_TRACEPOINT, 6457 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
6456 }, 6458 },
6457 { 6459 {
6460 "map access: known scalar += value_ptr",
6461 .insns = {
6462 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6463 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6464 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6465 BPF_LD_MAP_FD(BPF_REG_1, 0),
6466 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6467 BPF_FUNC_map_lookup_elem),
6468 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3),
6469 BPF_MOV64_IMM(BPF_REG_1, 4),
6470 BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_0),
6471 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 0),
6472 BPF_MOV64_IMM(BPF_REG_0, 1),
6473 BPF_EXIT_INSN(),
6474 },
6475 .fixup_map_array_48b = { 3 },
6476 .result = ACCEPT,
6477 .retval = 1,
6478 },
6479 {
6480 "map access: value_ptr += known scalar",
6481 .insns = {
6482 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6483 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6484 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6485 BPF_LD_MAP_FD(BPF_REG_1, 0),
6486 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6487 BPF_FUNC_map_lookup_elem),
6488 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3),
6489 BPF_MOV64_IMM(BPF_REG_1, 4),
6490 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
6491 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6492 BPF_MOV64_IMM(BPF_REG_0, 1),
6493 BPF_EXIT_INSN(),
6494 },
6495 .fixup_map_array_48b = { 3 },
6496 .result = ACCEPT,
6497 .retval = 1,
6498 },
6499 {
6500 "map access: unknown scalar += value_ptr",
6501 .insns = {
6502 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6503 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6504 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6505 BPF_LD_MAP_FD(BPF_REG_1, 0),
6506 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6507 BPF_FUNC_map_lookup_elem),
6508 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
6509 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6510 BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0xf),
6511 BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_0),
6512 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 0),
6513 BPF_MOV64_IMM(BPF_REG_0, 1),
6514 BPF_EXIT_INSN(),
6515 },
6516 .fixup_map_array_48b = { 3 },
6517 .result = ACCEPT,
6518 .retval = 1,
6519 },
6520 {
6521 "map access: value_ptr += unknown scalar",
6522 .insns = {
6523 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6524 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6525 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6526 BPF_LD_MAP_FD(BPF_REG_1, 0),
6527 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6528 BPF_FUNC_map_lookup_elem),
6529 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
6530 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6531 BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0xf),
6532 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
6533 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6534 BPF_MOV64_IMM(BPF_REG_0, 1),
6535 BPF_EXIT_INSN(),
6536 },
6537 .fixup_map_array_48b = { 3 },
6538 .result = ACCEPT,
6539 .retval = 1,
6540 },
6541 {
6542 "map access: value_ptr += value_ptr",
6543 .insns = {
6544 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6545 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6546 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6547 BPF_LD_MAP_FD(BPF_REG_1, 0),
6548 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6549 BPF_FUNC_map_lookup_elem),
6550 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),
6551 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_0),
6552 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6553 BPF_MOV64_IMM(BPF_REG_0, 1),
6554 BPF_EXIT_INSN(),
6555 },
6556 .fixup_map_array_48b = { 3 },
6557 .result = REJECT,
6558 .errstr = "R0 pointer += pointer prohibited",
6559 },
6560 {
6561 "map access: known scalar -= value_ptr",
6562 .insns = {
6563 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6564 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6565 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6566 BPF_LD_MAP_FD(BPF_REG_1, 0),
6567 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6568 BPF_FUNC_map_lookup_elem),
6569 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3),
6570 BPF_MOV64_IMM(BPF_REG_1, 4),
6571 BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
6572 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 0),
6573 BPF_MOV64_IMM(BPF_REG_0, 1),
6574 BPF_EXIT_INSN(),
6575 },
6576 .fixup_map_array_48b = { 3 },
6577 .result = REJECT,
6578 .errstr = "R1 tried to subtract pointer from scalar",
6579 },
6580 {
6581 "map access: value_ptr -= known scalar",
6582 .insns = {
6583 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6584 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6585 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6586 BPF_LD_MAP_FD(BPF_REG_1, 0),
6587 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6588 BPF_FUNC_map_lookup_elem),
6589 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3),
6590 BPF_MOV64_IMM(BPF_REG_1, 4),
6591 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
6592 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6593 BPF_MOV64_IMM(BPF_REG_0, 1),
6594 BPF_EXIT_INSN(),
6595 },
6596 .fixup_map_array_48b = { 3 },
6597 .result = REJECT,
6598 .errstr = "R0 min value is outside of the array range",
6599 },
6600 {
6601 "map access: value_ptr -= known scalar, 2",
6602 .insns = {
6603 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6604 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6605 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6606 BPF_LD_MAP_FD(BPF_REG_1, 0),
6607 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6608 BPF_FUNC_map_lookup_elem),
6609 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
6610 BPF_MOV64_IMM(BPF_REG_1, 6),
6611 BPF_MOV64_IMM(BPF_REG_2, 4),
6612 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
6613 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_2),
6614 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6615 BPF_MOV64_IMM(BPF_REG_0, 1),
6616 BPF_EXIT_INSN(),
6617 },
6618 .fixup_map_array_48b = { 3 },
6619 .result = ACCEPT,
6620 .retval = 1,
6621 },
6622 {
6623 "map access: unknown scalar -= value_ptr",
6624 .insns = {
6625 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6626 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6627 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6628 BPF_LD_MAP_FD(BPF_REG_1, 0),
6629 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6630 BPF_FUNC_map_lookup_elem),
6631 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
6632 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6633 BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0xf),
6634 BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
6635 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, 0),
6636 BPF_MOV64_IMM(BPF_REG_0, 1),
6637 BPF_EXIT_INSN(),
6638 },
6639 .fixup_map_array_48b = { 3 },
6640 .result = REJECT,
6641 .errstr = "R1 tried to subtract pointer from scalar",
6642 },
6643 {
6644 "map access: value_ptr -= unknown scalar",
6645 .insns = {
6646 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6647 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6648 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6649 BPF_LD_MAP_FD(BPF_REG_1, 0),
6650 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6651 BPF_FUNC_map_lookup_elem),
6652 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
6653 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6654 BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0xf),
6655 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
6656 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6657 BPF_MOV64_IMM(BPF_REG_0, 1),
6658 BPF_EXIT_INSN(),
6659 },
6660 .fixup_map_array_48b = { 3 },
6661 .result = REJECT,
6662 .errstr = "R0 min value is negative",
6663 },
6664 {
6665 "map access: value_ptr -= unknown scalar, 2",
6666 .insns = {
6667 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6668 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6669 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6670 BPF_LD_MAP_FD(BPF_REG_1, 0),
6671 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6672 BPF_FUNC_map_lookup_elem),
6673 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8),
6674 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6675 BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0xf),
6676 BPF_ALU64_IMM(BPF_OR, BPF_REG_1, 0x7),
6677 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1),
6678 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6679 BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0x7),
6680 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
6681 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6682 BPF_MOV64_IMM(BPF_REG_0, 1),
6683 BPF_EXIT_INSN(),
6684 },
6685 .fixup_map_array_48b = { 3 },
6686 .result = ACCEPT,
6687 .retval = 1,
6688 },
6689 {
6690 "map access: value_ptr -= value_ptr",
6691 .insns = {
6692 BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
6693 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
6694 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
6695 BPF_LD_MAP_FD(BPF_REG_1, 0),
6696 BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
6697 BPF_FUNC_map_lookup_elem),
6698 BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),
6699 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_0),
6700 BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
6701 BPF_MOV64_IMM(BPF_REG_0, 1),
6702 BPF_EXIT_INSN(),
6703 },
6704 .fixup_map_array_48b = { 3 },
6705 .result = REJECT,
6706 .errstr = "R0 invalid mem access 'inv'",
6707 .errstr_unpriv = "R0 pointer -= pointer prohibited",
6708 },
6709 {
6458 "map lookup helper access to map", 6710 "map lookup helper access to map",
6459 .insns = { 6711 .insns = {
6460 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), 6712 BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
@@ -13899,6 +14151,33 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
13899 } 14151 }
13900} 14152}
13901 14153
14154static int set_admin(bool admin)
14155{
14156 cap_t caps;
14157 const cap_value_t cap_val = CAP_SYS_ADMIN;
14158 int ret = -1;
14159
14160 caps = cap_get_proc();
14161 if (!caps) {
14162 perror("cap_get_proc");
14163 return -1;
14164 }
14165 if (cap_set_flag(caps, CAP_EFFECTIVE, 1, &cap_val,
14166 admin ? CAP_SET : CAP_CLEAR)) {
14167 perror("cap_set_flag");
14168 goto out;
14169 }
14170 if (cap_set_proc(caps)) {
14171 perror("cap_set_proc");
14172 goto out;
14173 }
14174 ret = 0;
14175out:
14176 if (cap_free(caps))
14177 perror("cap_free");
14178 return ret;
14179}
14180
13902static void do_test_single(struct bpf_test *test, bool unpriv, 14181static void do_test_single(struct bpf_test *test, bool unpriv,
13903 int *passes, int *errors) 14182 int *passes, int *errors)
13904{ 14183{
@@ -13907,6 +14186,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
13907 struct bpf_insn *prog = test->insns; 14186 struct bpf_insn *prog = test->insns;
13908 int map_fds[MAX_NR_MAPS]; 14187 int map_fds[MAX_NR_MAPS];
13909 const char *expected_err; 14188 const char *expected_err;
14189 uint32_t expected_val;
13910 uint32_t retval; 14190 uint32_t retval;
13911 int i, err; 14191 int i, err;
13912 14192
@@ -13926,6 +14206,8 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
13926 test->result_unpriv : test->result; 14206 test->result_unpriv : test->result;
13927 expected_err = unpriv && test->errstr_unpriv ? 14207 expected_err = unpriv && test->errstr_unpriv ?
13928 test->errstr_unpriv : test->errstr; 14208 test->errstr_unpriv : test->errstr;
14209 expected_val = unpriv && test->retval_unpriv ?
14210 test->retval_unpriv : test->retval;
13929 14211
13930 reject_from_alignment = fd_prog < 0 && 14212 reject_from_alignment = fd_prog < 0 &&
13931 (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS) && 14213 (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS) &&
@@ -13959,16 +14241,20 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
13959 __u8 tmp[TEST_DATA_LEN << 2]; 14241 __u8 tmp[TEST_DATA_LEN << 2];
13960 __u32 size_tmp = sizeof(tmp); 14242 __u32 size_tmp = sizeof(tmp);
13961 14243
14244 if (unpriv)
14245 set_admin(true);
13962 err = bpf_prog_test_run(fd_prog, 1, test->data, 14246 err = bpf_prog_test_run(fd_prog, 1, test->data,
13963 sizeof(test->data), tmp, &size_tmp, 14247 sizeof(test->data), tmp, &size_tmp,
13964 &retval, NULL); 14248 &retval, NULL);
14249 if (unpriv)
14250 set_admin(false);
13965 if (err && errno != 524/*ENOTSUPP*/ && errno != EPERM) { 14251 if (err && errno != 524/*ENOTSUPP*/ && errno != EPERM) {
13966 printf("Unexpected bpf_prog_test_run error\n"); 14252 printf("Unexpected bpf_prog_test_run error\n");
13967 goto fail_log; 14253 goto fail_log;
13968 } 14254 }
13969 if (!err && retval != test->retval && 14255 if (!err && retval != expected_val &&
13970 test->retval != POINTER_VALUE) { 14256 expected_val != POINTER_VALUE) {
13971 printf("FAIL retval %d != %d\n", retval, test->retval); 14257 printf("FAIL retval %d != %d\n", retval, expected_val);
13972 goto fail_log; 14258 goto fail_log;
13973 } 14259 }
13974 } 14260 }
@@ -14011,33 +14297,6 @@ static bool is_admin(void)
14011 return (sysadmin == CAP_SET); 14297 return (sysadmin == CAP_SET);
14012} 14298}
14013 14299
14014static int set_admin(bool admin)
14015{
14016 cap_t caps;
14017 const cap_value_t cap_val = CAP_SYS_ADMIN;
14018 int ret = -1;
14019
14020 caps = cap_get_proc();
14021 if (!caps) {
14022 perror("cap_get_proc");
14023 return -1;
14024 }
14025 if (cap_set_flag(caps, CAP_EFFECTIVE, 1, &cap_val,
14026 admin ? CAP_SET : CAP_CLEAR)) {
14027 perror("cap_set_flag");
14028 goto out;
14029 }
14030 if (cap_set_proc(caps)) {
14031 perror("cap_set_proc");
14032 goto out;
14033 }
14034 ret = 0;
14035out:
14036 if (cap_free(caps))
14037 perror("cap_free");
14038 return ret;
14039}
14040
14041static void get_unpriv_disabled() 14300static void get_unpriv_disabled()
14042{ 14301{
14043 char buf[2]; 14302 char buf[2];
diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh
index 0150bb2741eb..117f6f35d72f 100755
--- a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh
@@ -25,24 +25,24 @@
25# Thus we set MTU to 10K on all involved interfaces. Then both unicast and 25# Thus we set MTU to 10K on all involved interfaces. Then both unicast and
26# multicast traffic uses 8K frames. 26# multicast traffic uses 8K frames.
27# 27#
28# +-----------------------+ +----------------------------------+ 28# +---------------------------+ +----------------------------------+
29# | H1 | | H2 | 29# | H1 | | H2 |
30# | | | unicast --> + $h2.111 | 30# | | | unicast --> + $h2.111 |
31# | | | traffic | 192.0.2.129/28 | 31# | multicast | | traffic | 192.0.2.129/28 |
32# | multicast | | | e-qos-map 0:1 | 32# | traffic | | | e-qos-map 0:1 |
33# | traffic | | | | 33# | $h1 + <----- | | | |
34# | $h1 + <----- | | + $h2 | 34# | 192.0.2.65/28 | | | + $h2 |
35# +-----|-----------------+ +--------------|-------------------+ 35# +---------------|-----------+ +--------------|-------------------+
36# | | 36# | |
37# +-----|-------------------------------------------------|-------------------+ 37# +---------------|---------------------------------------|-------------------+
38# | + $swp1 + $swp2 | 38# | $swp1 + + $swp2 |
39# | | >1Gbps | >1Gbps | 39# | >1Gbps | | >1Gbps |
40# | +---|----------------+ +----------|----------------+ | 40# | +-------------|------+ +----------|----------------+ |
41# | | + $swp1.1 | | + $swp2.111 | | 41# | | $swp1.1 + | | + $swp2.111 | |
42# | | BR1 | SW | BR111 | | 42# | | BR1 | SW | BR111 | |
43# | | + $swp3.1 | | + $swp3.111 | | 43# | | $swp3.1 + | | + $swp3.111 | |
44# | +---|----------------+ +----------|----------------+ | 44# | +-------------|------+ +----------|----------------+ |
45# | \_________________________________________________/ | 45# | \_______________________________________/ |
46# | | | 46# | | |
47# | + $swp3 | 47# | + $swp3 |
48# | | 1Gbps bottleneck | 48# | | 1Gbps bottleneck |
@@ -51,6 +51,7 @@
51# | 51# |
52# +--|-----------------+ 52# +--|-----------------+
53# | + $h3 H3 | 53# | + $h3 H3 |
54# | | 192.0.2.66/28 |
54# | | | 55# | | |
55# | + $h3.111 | 56# | + $h3.111 |
56# | 192.0.2.130/28 | 57# | 192.0.2.130/28 |
@@ -59,6 +60,7 @@
59ALL_TESTS=" 60ALL_TESTS="
60 ping_ipv4 61 ping_ipv4
61 test_mc_aware 62 test_mc_aware
63 test_uc_aware
62" 64"
63 65
64lib_dir=$(dirname $0)/../../../net/forwarding 66lib_dir=$(dirname $0)/../../../net/forwarding
@@ -68,14 +70,14 @@ source $lib_dir/lib.sh
68 70
69h1_create() 71h1_create()
70{ 72{
71 simple_if_init $h1 73 simple_if_init $h1 192.0.2.65/28
72 mtu_set $h1 10000 74 mtu_set $h1 10000
73} 75}
74 76
75h1_destroy() 77h1_destroy()
76{ 78{
77 mtu_restore $h1 79 mtu_restore $h1
78 simple_if_fini $h1 80 simple_if_fini $h1 192.0.2.65/28
79} 81}
80 82
81h2_create() 83h2_create()
@@ -97,7 +99,7 @@ h2_destroy()
97 99
98h3_create() 100h3_create()
99{ 101{
100 simple_if_init $h3 102 simple_if_init $h3 192.0.2.66/28
101 mtu_set $h3 10000 103 mtu_set $h3 10000
102 104
103 vlan_create $h3 111 v$h3 192.0.2.130/28 105 vlan_create $h3 111 v$h3 192.0.2.130/28
@@ -108,7 +110,7 @@ h3_destroy()
108 vlan_destroy $h3 111 110 vlan_destroy $h3 111
109 111
110 mtu_restore $h3 112 mtu_restore $h3
111 simple_if_fini $h3 113 simple_if_fini $h3 192.0.2.66/28
112} 114}
113 115
114switch_create() 116switch_create()
@@ -251,7 +253,7 @@ measure_uc_rate()
251 # average ingress rate to somewhat mitigate this. 253 # average ingress rate to somewhat mitigate this.
252 local min_ingress=2147483648 254 local min_ingress=2147483648
253 255
254 mausezahn $h2.111 -p 8000 -A 192.0.2.129 -B 192.0.2.130 -c 0 \ 256 $MZ $h2.111 -p 8000 -A 192.0.2.129 -B 192.0.2.130 -c 0 \
255 -a own -b $h3mac -t udp -q & 257 -a own -b $h3mac -t udp -q &
256 sleep 1 258 sleep 1
257 259
@@ -291,7 +293,7 @@ test_mc_aware()
291 check_err $? "Could not get high enough UC-only ingress rate" 293 check_err $? "Could not get high enough UC-only ingress rate"
292 local ucth1=${uc_rate[1]} 294 local ucth1=${uc_rate[1]}
293 295
294 mausezahn $h1 -p 8000 -c 0 -a own -b bc -t udp -q & 296 $MZ $h1 -p 8000 -c 0 -a own -b bc -t udp -q &
295 297
296 local d0=$(date +%s) 298 local d0=$(date +%s)
297 local t0=$(ethtool_stats_get $h3 rx_octets_prio_0) 299 local t0=$(ethtool_stats_get $h3 rx_octets_prio_0)
@@ -311,7 +313,7 @@ test_mc_aware()
311 ret = 100 * ($ucth1 - $ucth2) / $ucth1 313 ret = 100 * ($ucth1 - $ucth2) / $ucth1
312 if (ret > 0) { ret } else { 0 } 314 if (ret > 0) { ret } else { 0 }
313 ") 315 ")
314 check_err $(bc <<< "$deg > 10") 316 check_err $(bc <<< "$deg > 25")
315 317
316 local interval=$((d1 - d0)) 318 local interval=$((d1 - d0))
317 local mc_ir=$(rate $u0 $u1 $interval) 319 local mc_ir=$(rate $u0 $u1 $interval)
@@ -335,6 +337,51 @@ test_mc_aware()
335 echo " egress UC throughput $(humanize ${uc_rate_2[1]})" 337 echo " egress UC throughput $(humanize ${uc_rate_2[1]})"
336 echo " ingress MC throughput $(humanize $mc_ir)" 338 echo " ingress MC throughput $(humanize $mc_ir)"
337 echo " egress MC throughput $(humanize $mc_er)" 339 echo " egress MC throughput $(humanize $mc_er)"
340 echo
341}
342
343test_uc_aware()
344{
345 RET=0
346
347 $MZ $h2.111 -p 8000 -A 192.0.2.129 -B 192.0.2.130 -c 0 \
348 -a own -b $h3mac -t udp -q &
349
350 local d0=$(date +%s)
351 local t0=$(ethtool_stats_get $h3 rx_octets_prio_1)
352 local u0=$(ethtool_stats_get $swp2 rx_octets_prio_1)
353 sleep 1
354
355 local attempts=50
356 local passes=0
357 local i
358
359 for ((i = 0; i < attempts; ++i)); do
360 if $ARPING -c 1 -I $h1 -b 192.0.2.66 -q -w 0.1; then
361 ((passes++))
362 fi
363
364 sleep 0.1
365 done
366
367 local d1=$(date +%s)
368 local t1=$(ethtool_stats_get $h3 rx_octets_prio_1)
369 local u1=$(ethtool_stats_get $swp2 rx_octets_prio_1)
370
371 local interval=$((d1 - d0))
372 local uc_ir=$(rate $u0 $u1 $interval)
373 local uc_er=$(rate $t0 $t1 $interval)
374
375 ((attempts == passes))
376 check_err $?
377
378 # Suppress noise from killing mausezahn.
379 { kill %% && wait; } 2>/dev/null
380
381 log_test "MC performace under UC overload"
382 echo " ingress UC throughput $(humanize ${uc_ir})"
383 echo " egress UC throughput $(humanize ${uc_er})"
384 echo " sent $attempts BC ARPs, got $passes responses"
338} 385}
339 386
340trap cleanup EXIT 387trap cleanup EXIT